]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/i386/lib/bios.h
x86: Code cleanup
[people/ms/u-boot.git] / arch / i386 / lib / bios.h
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 #define SEGMENT 0x40
60 #define STACK 0x800 /* stack at 0x40:0x800 -> 0x800 */
61
62 /* save general registers */
63 /* save some segments */
64 /* save callers stack segment .. */
65 /* ... in gs */
66 /* setup my segments */
67 /* setup BIOS stackpointer */
68
69 #define MAKE_BIOS_STACK \
70 pushal; \
71 pushw %ds; \
72 pushw %gs; \
73 pushw %es; \
74 pushw %ss; \
75 popw %gs; \
76 movw $SEGMENT, %ax; \
77 movw %ax, %ds; \
78 movw %ax, %es; \
79 movw %ax, %ss; \
80 movw %sp, %bp; \
81 movw $STACK, %sp
82
83 #define RESTORE_CALLERS_STACK \
84 pushw %gs; /* restore callers stack segment */ \
85 popw %ss; \
86 movw %bp, %sp; /* restore stackpointer */ \
87 popw %es; /* restore segment selectors */ \
88 popw %gs; \
89 popw %ds; \
90 popal /* restore GP registers */
91
92 #endif