| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /* arch/x86/boot/setup32.S
- *
- * This file is part of xnix.
- *
- * XNIX is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * XNIX is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XNIX. If not, see <https://www.gnu.org/licenses/>
- */
- .code16
- /* switch to the protected-mode, and to real system */
- .globl _start
- _start: xorw %ax, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %ss
- /* yeah, we should move it again. */
- movw $0x7e00, %di
- movw $0x8000, %si
- movw $512, %cx
- cld
- rep
- movsb
- movw $0x7c00, %sp
- ljmp $0, $real_start
- real_start:
- /* open a20 */
- cli
- inb $0x92, %al
- orb $0x02, %al
- outb %al, $0x92
- /* setup idt and gdt */
- lgdt gdt32_descr
- movl %cr0, %eax
- orl $1, %eax
- /* that's it! */
- movl %eax, %cr0
- /* setup paging */
- movl $0, %edi
- movl $512, %ecx
- xorl %eax, %eax
- cld
- rsetpt: rep
- stosl
- movl $0x00001007, 0
- movl $0x00001007, 0xc00
-
- movl $0x1000, %edi
- movl $1024, %ecx
- movl $0x00000007, %eax
- rsetp: stosl
- addl $4096, %eax
- loop rsetp
- xorl %eax, %eax
- movl %eax, %cr3
- movl %cr0, %eax
- orl $0x80000000, %eax
- movl %eax, %cr0
- ljmp $0x08, $init_prot
- .code32
- init_prot:
- movl $0x10, %eax
- movl %eax, %ds
- movl %eax, %es
- movl %eax, %fs
- movl %eax, %gs
- movl %eax, %ss
- movl $0x7c00, %esp
- /* move it to 1mb */
- movl $1048576, %edi
- movl $0x8400, %esi
- movl $131072, %ecx
- cld
- rep
- movsl
- ljmp $0x08, $1048576
- .globl gdt32
- gdt32: .long 0x00000000, 0x00000000
- .long 0x0000ffff, 0x00cf9a00
- .long 0x0000ffff, 0x00cf9200
- .globl gdt32_descr
- gdt32_descr:
- .word . - gdt32
- .long gdt32
|