dig64.h revision 1.1.78.1 1 1.1.78.1 yamt /* $NetBSD: dig64.h,v 1.1.78.1 2009/08/19 18:46:22 yamt Exp $ */
2 1.1 cherry
3 1.1 cherry /*-
4 1.1 cherry * Copyright (c) 2002 Marcel Moolenaar
5 1.1 cherry * All rights reserved.
6 1.1 cherry *
7 1.1 cherry * Redistribution and use in source and binary forms, with or without
8 1.1 cherry * modification, are permitted provided that the following conditions
9 1.1 cherry * are met:
10 1.1 cherry *
11 1.1 cherry * 1. Redistributions of source code must retain the above copyright
12 1.1 cherry * notice, this list of conditions and the following disclaimer.
13 1.1 cherry * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 cherry * notice, this list of conditions and the following disclaimer in the
15 1.1 cherry * documentation and/or other materials provided with the distribution.
16 1.1 cherry *
17 1.1 cherry * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 1.1 cherry * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.1 cherry * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1 cherry * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 1.1 cherry * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 1.1 cherry * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 1.1 cherry * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 1.1 cherry * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 1.1 cherry * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 1.1 cherry * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 1.1 cherry *
28 1.1 cherry * $FreeBSD$
29 1.1 cherry */
30 1.1 cherry
31 1.1 cherry #ifndef _MACHINE_DIG64_H_
32 1.1 cherry #define _MACHINE_DIG64_H_
33 1.1 cherry
34 1.1.78.1 yamt /*
35 1.1.78.1 yamt * This header file written refer to 'DIG64 Desriptions for Primary Console &
36 1.1.78.1 yamt * Debug Port Devices'.
37 1.1.78.1 yamt */
38 1.1.78.1 yamt
39 1.1.78.1 yamt /* ACPI GAS (Generic Address Structure) */
40 1.1 cherry struct dig64_gas {
41 1.1 cherry uint8_t addr_space;
42 1.1 cherry uint8_t bit_width;
43 1.1 cherry uint8_t bit_offset;
44 1.1 cherry uint8_t _reserved_;
45 1.1 cherry /*
46 1.1 cherry * XXX using a 64-bit type for the address would cause padding and
47 1.1 cherry * using __packed would cause unaligned accesses...
48 1.1 cherry */
49 1.1 cherry uint32_t addr_low;
50 1.1 cherry uint32_t addr_high;
51 1.1 cherry };
52 1.1 cherry
53 1.1 cherry struct dig64_hcdp_entry {
54 1.1 cherry uint8_t type;
55 1.1.78.1 yamt #define DIG64_HCDP_CONSOLE DIG64_ENTRYTYPE_TYPE0
56 1.1.78.1 yamt #define DIG64_HCDP_DBGPORT DIG64_ENTRYTYPE_TYPE1
57 1.1 cherry uint8_t databits;
58 1.1 cherry uint8_t parity;
59 1.1.78.1 yamt #define DIG64_HCDP_PARITY_NO 1
60 1.1.78.1 yamt #define DIG64_HCDP_PARITY_EVEN 2
61 1.1.78.1 yamt #define DIG64_HCDP_PARITY_ODD 3
62 1.1.78.1 yamt #define DIG64_HCDP_PARITY_MARK 4
63 1.1.78.1 yamt #define DIG64_HCDP_PARITY_SPACE 5
64 1.1 cherry uint8_t stopbits;
65 1.1.78.1 yamt #define DIG64_HCDP_STOPBITS_1 1
66 1.1.78.1 yamt #define DIG64_HCDP_STOPBITS_15 2
67 1.1.78.1 yamt #define DIG64_HCDP_STOPBITS_2 3
68 1.1 cherry uint8_t pci_segment;
69 1.1 cherry uint8_t pci_bus;
70 1.1 cherry uint8_t pci_device:5;
71 1.1 cherry uint8_t _reserved1_:3;
72 1.1 cherry uint8_t pci_function:3;
73 1.1 cherry uint8_t _reserved2_:3;
74 1.1 cherry uint8_t interrupt:1;
75 1.1 cherry uint8_t pci_flag:1;
76 1.1 cherry /*
77 1.1 cherry * XXX using a 64-bit type for the baudrate would cause padding and
78 1.1 cherry * using __packed would cause unaligned accesses...
79 1.1 cherry */
80 1.1 cherry uint32_t baud_low;
81 1.1 cherry uint32_t baud_high;
82 1.1 cherry struct dig64_gas address;
83 1.1 cherry uint16_t pci_devid;
84 1.1 cherry uint16_t pci_vendor;
85 1.1 cherry uint32_t irq;
86 1.1 cherry uint32_t pclock;
87 1.1 cherry uint8_t pci_interface;
88 1.1 cherry uint8_t _reserved3_[7];
89 1.1 cherry };
90 1.1 cherry
91 1.1.78.1 yamt
92 1.1.78.1 yamt /* Device Specific Structures */
93 1.1.78.1 yamt
94 1.1.78.1 yamt struct dig64_vga_spec {
95 1.1.78.1 yamt uint8_t num; /*Number of Extended Address Space Descriptors*/
96 1.1.78.1 yamt struct {
97 1.1.78.1 yamt uint8_t data[56];
98 1.1.78.1 yamt } edesc[0];
99 1.1.78.1 yamt } __packed;
100 1.1.78.1 yamt
101 1.1.78.1 yamt
102 1.1.78.1 yamt /* Interconnect Specific Structure */
103 1.1.78.1 yamt
104 1.1.78.1 yamt #define DIG64_FLAGS_INTR_LEVEL (0 << 0) /* Level Triggered */
105 1.1.78.1 yamt #define DIG64_FLAGS_INTR_EDGE (1 << 0) /* Edge Triggered */
106 1.1.78.1 yamt #define DIG64_FLAGS_INTR_ACTH (0 << 1) /* Intr Active High */
107 1.1.78.1 yamt #define DIG64_FLAGS_INTR_ACTL (1 << 1) /* Intr Active Low */
108 1.1.78.1 yamt #define DIG64_FLAGS_TRANS_DENSE (0 << 3) /* Dense Transration */
109 1.1.78.1 yamt #define DIG64_FLAGS_TRANS_SPARSE (1 << 3) /* Sparse Transration */
110 1.1.78.1 yamt #define DIG64_FLAGS_TYPE_STATIC (0 << 4) /* Type Static */
111 1.1.78.1 yamt #define DIG64_FLAGS_TYPE_TRANS (1 << 4) /* Type Translation */
112 1.1.78.1 yamt #define DIG64_FLAGS_INTR_SUPP (1 << 6) /* Intrrupt supported */
113 1.1.78.1 yamt #define DIG64_FLAGS_MMIO_TRA_VALID (1 << 8)
114 1.1.78.1 yamt #define DIG64_FLAGS_IOPORT_TRA_VALID (1 << 9)
115 1.1.78.1 yamt
116 1.1.78.1 yamt struct dig64_acpi_spec {
117 1.1.78.1 yamt uint8_t type; /* = 0 indicating ACPI */
118 1.1.78.1 yamt uint8_t resv; /* must be 0 */
119 1.1.78.1 yamt uint16_t length; /* of the ACPI Specific Structure */
120 1.1.78.1 yamt uint32_t uid;
121 1.1.78.1 yamt uint32_t hid;
122 1.1.78.1 yamt uint32_t acpi_gsi; /* ACPI Global System Interrupt */
123 1.1.78.1 yamt uint64_t mmio_tra;
124 1.1.78.1 yamt uint64_t ioport_tra;
125 1.1.78.1 yamt uint16_t flags;
126 1.1.78.1 yamt } __packed;
127 1.1.78.1 yamt
128 1.1.78.1 yamt struct dig64_pci_spec {
129 1.1.78.1 yamt uint8_t type; /* = 1 indicating PCI */
130 1.1.78.1 yamt uint8_t resv; /* must be 0 */
131 1.1.78.1 yamt uint16_t length; /* of the PCI Specific Structure */
132 1.1.78.1 yamt uint8_t sgn; /* PCI Segment Group Number */
133 1.1.78.1 yamt uint8_t bus; /* PCI Bus Number */
134 1.1.78.1 yamt uint8_t device; /* PCI Device Number */
135 1.1.78.1 yamt uint8_t function; /* PCI Function Number */
136 1.1.78.1 yamt uint16_t device_id;
137 1.1.78.1 yamt uint16_t vendor_id;
138 1.1.78.1 yamt uint32_t acpi_gsi; /* ACPI Global System Interrupt */
139 1.1.78.1 yamt uint64_t mmio_tra;
140 1.1.78.1 yamt uint64_t ioport_tra;
141 1.1.78.1 yamt uint16_t flags;
142 1.1.78.1 yamt } __packed;
143 1.1.78.1 yamt
144 1.1.78.1 yamt
145 1.1.78.1 yamt struct dig64_pcdp_entry {
146 1.1.78.1 yamt uint8_t type;
147 1.1.78.1 yamt uint8_t primary;
148 1.1.78.1 yamt uint16_t length; /* in bytes */
149 1.1.78.1 yamt uint16_t index;
150 1.1.78.1 yamt #define DIG64_PCDP_CONOUTDEV 0
151 1.1.78.1 yamt #define DIG64_PCDP_NOT_VALID 1
152 1.1.78.1 yamt #define DIG64_PCDP_CONOUTDEV2 2
153 1.1.78.1 yamt #define DIG64_PCDP_CONINDEV 3
154 1.1.78.1 yamt
155 1.1.78.1 yamt union {
156 1.1.78.1 yamt /*
157 1.1.78.1 yamt * Interconnect Specific Structure,
158 1.1.78.1 yamt * and Device Specific Structure(s)
159 1.1.78.1 yamt */
160 1.1.78.1 yamt uint8_t type;
161 1.1.78.1 yamt #define DIG64_PCDP_SPEC_ACPI 0
162 1.1.78.1 yamt struct dig64_acpi_spec acpi;
163 1.1.78.1 yamt #define DIG64_PCDP_SPEC_PCI 1
164 1.1.78.1 yamt struct dig64_pci_spec pci;
165 1.1.78.1 yamt } specs;
166 1.1.78.1 yamt } __packed;
167 1.1.78.1 yamt
168 1.1 cherry struct dig64_hcdp_table {
169 1.1 cherry char signature[4];
170 1.1 cherry #define HCDP_SIGNATURE "HCDP"
171 1.1 cherry uint32_t length;
172 1.1.78.1 yamt uint8_t revision; /* It is PCDP, if '3' or greater. */
173 1.1 cherry uint8_t checksum;
174 1.1 cherry char oem_id[6];
175 1.1 cherry char oem_tbl_id[8];
176 1.1 cherry uint32_t oem_rev;
177 1.1 cherry char creator_id[4];
178 1.1 cherry uint32_t creator_rev;
179 1.1.78.1 yamt uint32_t entries; /* Number of Type0 and Type1 Entries. */
180 1.1.78.1 yamt union dev_desc { /* Device Descriptor */
181 1.1.78.1 yamt uint8_t type;
182 1.1.78.1 yamt #define DIG64_ENTRYTYPE_TYPE0 0 /* (UART | Bidirect) */
183 1.1.78.1 yamt #define DIG64_ENTRYTYPE_TYPE1 1 /* (UART | Debug Port) */
184 1.1.78.1 yamt #define DIG64_ENTRYTYPE_BIDIRECT (0<<0) /* bidirectional console */
185 1.1.78.1 yamt #define DIG64_ENTRYTYPE_DEBUGPORT (1<<0) /* debug port */
186 1.1.78.1 yamt #define DIG64_ENTRYTYPE_OUTONLY (2<<0) /* console output-only */
187 1.1.78.1 yamt #define DIG64_ENTRYTYPE_INONLY (3<<0) /* console input-only */
188 1.1.78.1 yamt #define DIG64_ENTRYTYPE_UART (0<<3)
189 1.1.78.1 yamt #define DIG64_ENTRYTYPE_VGA (1<<3)
190 1.1.78.1 yamt #define DIG64_ENTRYTYPE_VENDOR (1<<7) /* Vendor specific */
191 1.1.78.1 yamt struct dig64_hcdp_entry uart;
192 1.1.78.1 yamt struct dig64_pcdp_entry pcdp;
193 1.1.78.1 yamt } entry[0];
194 1.1 cherry };
195 1.1 cherry
196 1.1 cherry #endif
197