blob: a220983df134f6b50090d2701710a0ee942ff30b [file] [log] [blame]
wdenkabda5ca2003-05-31 18:35:21 +00001/*
2 * (C) Copyright 2002
Albert ARIBAUD60fbc8d2011-08-04 18:45:45 +02003 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
wdenk57b2d802003-06-27 21:31:46 +00004 *
wdenkabda5ca2003-05-31 18:35:21 +00005 * 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
Graeme Russ883c6032011-11-08 02:33:15 +000027#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 */
wdenkabda5ca2003-05-31 18:35:21 +000058
Graeme Russ883c6032011-11-08 02:33:15 +000059/* stack at 0x40:0x800 -> 0x800 */
60#define SEGMENT 0x40
61#define STACK 0x800
wdenkabda5ca2003-05-31 18:35:21 +000062
Graeme Russ883c6032011-11-08 02:33:15 +000063/*
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; \
Graeme Russ45fc1d82011-04-13 19:43:26 +100082 movw $STACK, %sp
wdenkabda5ca2003-05-31 18:35:21 +000083
Graeme Russ883c6032011-11-08 02:33:15 +000084/*
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
104extern ulong __bios_start;
105extern 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 */
110extern u16 ram_in_64kb_chunks;
111extern u16 bios_equipment;
112extern u8 pci_last_bus;
113
114extern void *rm_int00;
115extern void *rm_int01;
116extern void *rm_int02;
117extern void *rm_int03;
118extern void *rm_int04;
119extern void *rm_int05;
120extern void *rm_int06;
121extern void *rm_int07;
122extern void *rm_int08;
123extern void *rm_int09;
124extern void *rm_int0a;
125extern void *rm_int0b;
126extern void *rm_int0c;
127extern void *rm_int0d;
128extern void *rm_int0e;
129extern void *rm_int0f;
130extern void *rm_int10;
131extern void *rm_int11;
132extern void *rm_int12;
133extern void *rm_int13;
134extern void *rm_int14;
135extern void *rm_int15;
136extern void *rm_int16;
137extern void *rm_int17;
138extern void *rm_int18;
139extern void *rm_int19;
140extern void *rm_int1a;
141extern void *rm_int1b;
142extern void *rm_int1c;
143extern void *rm_int1d;
144extern void *rm_int1e;
145extern void *rm_int1f;
146extern void *rm_def_int;
147
148extern void *realmode_reset;
149extern void *realmode_pci_bios_call_entry;
150
151#define RELOC_16_LONG(seg, off) (*(u32 *)(seg << 4 | (u32)&off))
152#define RELOC_16_WORD(seg, off) (*(u16 *)(seg << 4 | (u32)&off))
153#define RELOC_16_BYTE(seg, off) (*(u8 *)(seg << 4 | (u32)&off))
154
155#ifdef PCI_BIOS_DEBUG
156extern u32 num_pci_bios_present;
157extern u32 num_pci_bios_find_device;
158extern u32 num_pci_bios_find_class;
159extern u32 num_pci_bios_generate_special_cycle;
160extern u32 num_pci_bios_read_cfg_byte;
161extern u32 num_pci_bios_read_cfg_word;
162extern u32 num_pci_bios_read_cfg_dword;
163extern u32 num_pci_bios_write_cfg_byte;
164extern u32 num_pci_bios_write_cfg_word;
165extern u32 num_pci_bios_write_cfg_dword;
166extern u32 num_pci_bios_get_irq_routing;
167extern u32 num_pci_bios_set_irq;
168extern u32 num_pci_bios_unknown_function;
169#endif
170
171#endif
wdenkabda5ca2003-05-31 18:35:21 +0000172
173#endif