xref: /openbmc/u-boot/arch/x86/lib/bios.h (revision 618766c0)
1 /*
2  * (C) Copyright 2002
3  * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 
24 #ifndef _BIOS_H_
25 #define _BIOS_H_
26 
27 #define OFFS_ES		0	/* 16bit */
28 #define OFFS_GS		2	/* 16bit */
29 #define OFFS_DS		4	/* 16bit */
30 #define OFFS_EDI	6	/* 32bit */
31 #define OFFS_DI		6	/* low 16 bits of EDI */
32 #define OFFS_ESI	10	/* 32bit */
33 #define OFFS_SI		10	/* low 16 bits of ESI */
34 #define OFFS_EBP	14	/* 32bit */
35 #define OFFS_BP		14	/* low 16 bits of EBP */
36 #define OFFS_ESP	18	/* 32bit */
37 #define OFFS_SP		18	/* low 16 bits of ESP */
38 #define OFFS_EBX	22	/* 32bit */
39 #define OFFS_BX		22	/* low 16 bits of EBX */
40 #define OFFS_BL		22	/* low  8 bits of BX */
41 #define OFFS_BH		23	/* high 8 bits of BX */
42 #define OFFS_EDX	26	/* 32bit */
43 #define OFFS_DX		26	/* low 16 bits of EBX */
44 #define OFFS_DL		26	/* low  8 bits of BX */
45 #define OFFS_DH		27	/* high 8 bits of BX */
46 #define OFFS_ECX	30	/* 32bit */
47 #define OFFS_CX		30	/* low 16 bits of EBX */
48 #define OFFS_CL		30	/* low  8 bits of BX */
49 #define OFFS_CH		31	/* high 8 bits of BX */
50 #define OFFS_EAX	34	/* 32bit */
51 #define OFFS_AX		34	/* low 16 bits of EBX */
52 #define OFFS_AL		34	/* low  8 bits of BX */
53 #define OFFS_AH		35	/* high 8 bits of BX */
54 #define OFFS_VECTOR	38	/* 16bit */
55 #define OFFS_IP		40	/* 16bit */
56 #define OFFS_CS		42	/* 16bit */
57 #define OFFS_FLAGS	44	/* 16bit */
58 
59 /* stack at 0x40:0x800 -> 0x800 */
60 #define SEGMENT		0x40
61 #define STACK		0x800
62 
63 /*
64  * save general registers
65  * save some segments
66  * save callers stack segment
67  * setup BIOS segments
68  * setup BIOS stackpointer
69  */
70 #define MAKE_BIOS_STACK		\
71 	pushal;			\
72 	pushw	%ds;		\
73 	pushw	%gs;		\
74 	pushw	%es;		\
75 	pushw	%ss;		\
76 	popw	%gs;		\
77 	movw	$SEGMENT, %ax;	\
78 	movw	%ax, %ds;	\
79 	movw	%ax, %es;	\
80 	movw	%ax, %ss;	\
81 	movw	%sp, %bp;	\
82 	movw	$STACK, %sp
83 
84 /*
85  * restore callers stack segment
86  * restore some segments
87  * restore general registers
88  */
89 #define RESTORE_CALLERS_STACK	\
90 	pushw	%gs;		\
91 	popw	%ss;		\
92 	movw	%bp, %sp;	\
93 	popw	%es;		\
94 	popw	%gs;		\
95 	popw	%ds;		\
96 	popal
97 
98 #ifndef __ASSEMBLY__
99 #define BIOS_DATA	((char *)0x400)
100 #define BIOS_DATA_SIZE	256
101 #define BIOS_BASE	((char *)0xf0000)
102 #define BIOS_CS		0xf000
103 
104 extern ulong __bios_start;
105 extern ulong __bios_size;
106 
107 /* these are defined in a 16bit segment and needs
108  * to be accessed with the RELOC_16_xxxx() macros below
109  */
110 extern u16 ram_in_64kb_chunks;
111 extern u16 bios_equipment;
112 extern u8  pci_last_bus;
113 
114 extern void *rm_int00;
115 extern void *rm_int01;
116 extern void *rm_int02;
117 extern void *rm_int03;
118 extern void *rm_int04;
119 extern void *rm_int05;
120 extern void *rm_int06;
121 extern void *rm_int07;
122 extern void *rm_int08;
123 extern void *rm_int09;
124 extern void *rm_int0a;
125 extern void *rm_int0b;
126 extern void *rm_int0c;
127 extern void *rm_int0d;
128 extern void *rm_int0e;
129 extern void *rm_int0f;
130 extern void *rm_int10;
131 extern void *rm_int11;
132 extern void *rm_int12;
133 extern void *rm_int13;
134 extern void *rm_int14;
135 extern void *rm_int15;
136 extern void *rm_int16;
137 extern void *rm_int17;
138 extern void *rm_int18;
139 extern void *rm_int19;
140 extern void *rm_int1a;
141 extern void *rm_int1b;
142 extern void *rm_int1c;
143 extern void *rm_int1d;
144 extern void *rm_int1e;
145 extern void *rm_int1f;
146 extern void *rm_def_int;
147 
148 #define RELOC_16_LONG(seg, off) (*(u32 *)(seg << 4 | (u32)&off))
149 #define RELOC_16_WORD(seg, off) (*(u16 *)(seg << 4 | (u32)&off))
150 #define RELOC_16_BYTE(seg, off) (*(u8 *)(seg << 4 | (u32)&off))
151 
152 #ifdef PCI_BIOS_DEBUG
153 extern u32 num_pci_bios_present;
154 extern u32 num_pci_bios_find_device;
155 extern u32 num_pci_bios_find_class;
156 extern u32 num_pci_bios_generate_special_cycle;
157 extern u32 num_pci_bios_read_cfg_byte;
158 extern u32 num_pci_bios_read_cfg_word;
159 extern u32 num_pci_bios_read_cfg_dword;
160 extern u32 num_pci_bios_write_cfg_byte;
161 extern u32 num_pci_bios_write_cfg_word;
162 extern u32 num_pci_bios_write_cfg_dword;
163 extern u32 num_pci_bios_get_irq_routing;
164 extern u32 num_pci_bios_set_irq;
165 extern u32 num_pci_bios_unknown_function;
166 #endif
167 
168 #endif
169 
170 #endif
171