| 1 |
/* |
| 2 |
* purgatory: setup code |
| 3 |
* |
| 4 |
* Copyright (C) 2003,2004 Eric Biederman ([email protected]) |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation (version 2 of the License). |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#undef i386 |
| 21 |
|
| 22 |
.text |
| 23 |
.globl entry32, entry32_regs |
| 24 |
entry32: |
| 25 |
.code32 |
| 26 |
.arch i386 |
| 27 |
|
| 28 |
/* Setup a gdt that should that is generally usefully */ |
| 29 |
lgdt %cs:gdt |
| 30 |
|
| 31 |
/* load the data segments */ |
| 32 |
movl $0x18, %eax /* data segment */ |
| 33 |
movl %eax, %ds |
| 34 |
movl %eax, %es |
| 35 |
movl %eax, %ss |
| 36 |
movl %eax, %fs |
| 37 |
movl %eax, %gs |
| 38 |
|
| 39 |
/* load the code segment */ |
| 40 |
ljmp $0x10,$1f |
| 41 |
1: |
| 42 |
|
| 43 |
/* Load the registers */ |
| 44 |
movl eax, %eax |
| 45 |
movl ecx, %ecx |
| 46 |
movl edx, %edx |
| 47 |
movl esi, %esi |
| 48 |
movl edi, %edi |
| 49 |
movl esp, %esp |
| 50 |
movl ebp, %ebp |
| 51 |
movl ebx, %ebx |
| 52 |
|
| 53 |
/* Jump to the loaded image */ |
| 54 |
jmpl *(eip) |
| 55 |
|
| 56 |
.section ".rodata" |
| 57 |
.balign 16 |
| 58 |
gdt: |
| 59 |
/* 0x00 unusable segment so used as the gdt ptr */ |
| 60 |
.word gdt_end - gdt - 1 |
| 61 |
.long gdt |
| 62 |
.word 0 |
| 63 |
|
| 64 |
/* 0x08 dummy */ |
| 65 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 66 |
|
| 67 |
/* Documented linux kernel segments */ |
| 68 |
/* 0x10 4GB flat code segment */ |
| 69 |
.word 0xFFFF, 0x0000, 0x9A00, 0x00CF |
| 70 |
/* 0x18 4GB flat data segment */ |
| 71 |
.word 0xFFFF, 0x0000, 0x9200, 0x00CF |
| 72 |
|
| 73 |
/* 0x20 dummy */ |
| 74 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 75 |
/* 0x28 dummy */ |
| 76 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 77 |
/* 0x30 dummy */ |
| 78 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 79 |
/* 0x38 dummy */ |
| 80 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 81 |
/* 0x40 dummy */ |
| 82 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 83 |
/* 0x48 dummy */ |
| 84 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 85 |
/* 0x50 dummy */ |
| 86 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 87 |
/* 0x58 dummy */ |
| 88 |
.word 0x0000, 0x0000, 0x0000, 0x000 |
| 89 |
|
| 90 |
/* Segments used by the 2.5.x kernel */ |
| 91 |
/* 0x60 4GB flat code segment */ |
| 92 |
.word 0xFFFF, 0x0000, 0x9A00, 0x00CF |
| 93 |
/* 0x68 4GB flat data segment */ |
| 94 |
.word 0xFFFF, 0x0000, 0x9200, 0x00CF |
| 95 |
gdt_end: |
| 96 |
|
| 97 |
.data |
| 98 |
.balign 4 |
| 99 |
entry32_regs: |
| 100 |
eax: .long 0x00000000 |
| 101 |
ebx: .long 0x00000000 |
| 102 |
ecx: .long 0x00000000 |
| 103 |
edx: .long 0x00000000 |
| 104 |
esi: .long 0x00000000 |
| 105 |
edi: .long 0x00000000 |
| 106 |
esp: .long 0x00000000 |
| 107 |
ebp: .long 0x00000000 |
| 108 |
eip: .long entry16 |
| 109 |
.size entry32_regs, . - entry32_regs |
| 110 |
|