]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/postcode.h
2 * Copyright (c) 2008 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _I386_POSTCODE_H_
30 #define _I386_POSTCODE_H_
32 /* Define this to delay about 1 sec after posting each code */
33 //#define POSTCODE_DELAY 1
35 /* The POSTCODE is port 0x80 */
38 #define SPINCOUNT 300000000
39 #define CPU_PAUSE() rep; nop
43 * Macro to output byte value to postcode, destoying register al.
44 * Additionally, if POSTCODE_DELAY, spin for about a second.
48 outb %al,$(POSTPORT); \
49 movl $(SPINCOUNT), %eax; \
55 outw %ax,$(POSTPORT); \
56 movl $(SPINCOUNT), %eax; \
66 #endif /* POSTCODE_DELAY */
68 #define POSTCODE(XX) \
72 #define POSTCODE2(XXXX) \
76 /* Output byte value to postcode, without destoying register eax */
77 #define POSTCODE_SAVE_EAX(XX) \
83 * Display a 32-bit value to the post card - low byte to high byte
84 * Entry: value in %ebx
85 * Exit: %ebx preserved; %eax destroyed
87 #define POSTCODE32_EBX \
109 #define POSTCODE_SAVE_EAX(X)
110 #define POSTCODE32_EBX
114 * The following postcodes are defined for stages of early startup:
117 #define PSTART_ENTRY 0xFF
118 #define PSTART_REBASE 0xFE
119 #define PSTART_BEFORE_PAGING 0xFE
120 #define PSTART_VSTART 0xFD
121 #define VSTART_ENTRY 0xFC
122 #define VSTART_IDLE_PTS_INIT 0xFB
123 #define VSTART_PHYSMAP_INIT 0xFA
124 #define VSTART_DESC_ALIAS_INIT 0xF9
125 #define VSTART_SET_CR3 0xF8
126 #define VSTART_CPU_DESC_INIT 0xF7
127 #define VSTART_CPU_MODE_INIT 0xF6
128 #define VSTART_EXIT 0xF5
129 #define I386_INIT_ENTRY 0xF4
130 #define CPU_INIT_D 0xF3
131 #define PE_INIT_PLATFORM_D 0xF2
133 #define SLAVE_STARTPROG_ENTRY 0xEF
134 #define SLAVE_PSTART 0xEE
135 #define I386_INIT_SLAVE 0xED
137 #define PANIC_DOUBLE_FAULT 0xDF /* Double Fault exception */
138 #define PANIC_MACHINE_CHECK 0xDE /* Machine-Check */
139 #define MP_KDP_ENTER 0xDB /* Machine in kdp DeBugger */
140 #define PANIC_HLT 0xD1 /* Die an early death */
141 #define NO_64BIT 0x64 /* No 64-bit support yet */
143 #define ACPI_WAKE_START_ENTRY 0xCF
144 #define ACPI_WAKE_PROT_ENTRY 0xCE
145 #define ACPI_WAKE_PAGED_ENTRY 0xCD
147 #define CPU_IA32_ENABLE_ENTRY 0xBF
148 #define CPU_IA32_ENABLE_EXIT 0xBE
149 #define ML_LOAD_DESC64_ENTRY 0xBD
150 #define ML_LOAD_DESC64_GDT 0xBC
151 #define ML_LOAD_DESC64_IDT 0xBB
152 #define ML_LOAD_DESC64_LDT 0xBA
153 #define ML_LOAD_DESC64_EXIT 0xB9
154 #define CPU_IA32_DISABLE_ENTRY 0xB8
155 #define CPU_IA32_DISABLE_EXIT 0xB7
159 _postcode_delay(uint32_t spincount
)
161 asm volatile("1: \n\t"
165 : : "a" (spincount
));
168 _postcode(uint8_t xx
)
170 asm volatile("outb %0, %1" : : "a" (xx
), "N" (POSTPORT
));
173 _postcode2(uint16_t xxxx
)
175 asm volatile("outw %0, %1" : : "a" (xxxx
), "N" (POSTPORT
));
183 _postcode_delay(SPINCOUNT
);
187 postcode2(uint8_t xxxx
)
191 _postcode_delay(SPINCOUNT
);
195 #define postcode(xx) do {} while(0)
196 #define postcode2(xxxx) do {} while(0)
200 #endif /* _I386_POSTCODE_H_ */