diff options
author | neoraider <devnull@localhost> | 2005-04-18 17:18:02 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2005-04-18 17:18:02 +0200 |
commit | 2c7f83e006c3fee8d26e940eee801a4be9443e50 (patch) | |
tree | cb8273f74857305921b653aed0a0488b2d27c13a /boot | |
download | winx-2c7f83e006c3fee8d26e940eee801a4be9443e50.tar winx-2c7f83e006c3fee8d26e940eee801a4be9443e50.zip |
Diffstat (limited to 'boot')
-rw-r--r-- | boot/Makefile | 10 | ||||
-rw-r--r-- | boot/load.S | 254 |
2 files changed, 264 insertions, 0 deletions
diff --git a/boot/Makefile b/boot/Makefile new file mode 100644 index 0000000..2fc7d3d --- /dev/null +++ b/boot/Makefile @@ -0,0 +1,10 @@ +BOOT_FILES = boot/load.o + +boot/boot.o : $(BOOT_FILES) + @echo Linking $*.o + @ld -r -o $*.o $(BOOT_FILES) + @echo + +boot/load.o : boot/load.S include/asm/version.h + @echo Compiling boot/load.S + @cpp boot/load.S -I include | as -o $*.o diff --git a/boot/load.S b/boot/load.S new file mode 100644 index 0000000..f7a6ba0 --- /dev/null +++ b/boot/load.S @@ -0,0 +1,254 @@ +/* boot.S - main bootup file */ + +#include <asm/boot.h> +#include <asm/version.h> + +GDT_SIZE = (gdt_end - gdt) +IDT_SIZE = (idt_end - idt) +KERNEL_TRACKS = ((KERNEL_BLOCKS+DISK_SECTORS_PER_TRACK-1)/DISK_SECTORS_PER_TRACK) + + +.text + +.code16 + +.global start + +start: + +xor %ax,%ax +int $0x13 + +# Load kernel + +mov $0x0001,%cx +xor %dh,%dh +xor %bx,%bx +mov $0x50,%ax +mov %ax,%es + +load_kernel_loop: + +mov $0x02,%ah +mov $DISK_SECTORS_PER_TRACK,%al + +push %dx +int $0x13 +pop %dx + +jc error + +mov %es,%ax +add $(0x20*DISK_SECTORS_PER_TRACK),%ax +mov %ax,%es + + +add %dh,%ch +or %dh,%dh +jnz head0 +inc %dh +jmp head1 +head0: +xor %dh,%dh +head1: +cmp $(KERNEL_TRACKS/2),%ch +jb load_kernel_loop + +ljmp $0x50, $load + +load: + +cli + +mov %cs,%ax +mov %ax,%ds + +mov $0x01,%ah +mov $0b0010000000000000,%cx +int $0x10 + +mov $0x36,%al +out %al,$0x43 +mov $0x9B,%al +out %al,$0x40 +mov $0x2E,%al +out %al,$0x40 + +key_ready: +in $0x64,%al +and $0b00000010,%al +jnz key_ready +mov $0xED,%al +out %al,$0x60 +key_ready2: +in $0x64,%al +and $0b00000010,%al +jnz key_ready2 +xor %al,%al +out %al,$0x60 + +mov $0b00010001,%al +out %al,$0x20 +out %al,$0xA0 + +mov $0x20,%al +out %al,$0x21 + +mov $0x28,%al +out %al,$0xA1 + +mov $0b00000100,%al +out %al,$0x21 + +mov $0b00000010,%al +out %al,$0xA1 + +mov $0b00000001,%al +out %al,$0x21 +out %al,$0xA1 + +lgdt gdt_struct + +lidt idt_struct + +mov %cr0,%eax +or $1,%eax +mov %eax,%cr0 + +.byte 0xea +.word pmode +.word 8 + +pmode: + +.code32 + +mov $16,%ax +mov %ax,%ds + +mov $24,%ax +mov %ax,%ss +mov $0x1FFF,%esp + +sti + +cld + +pushl $'\f' +call print_char +addl $4,%esp + +pushl $0b00001111 +pushl $verstring +call print_attr +addl $8,%esp + +#call init_floppy + +#call test + +done: +xor %edx,%edx +call kb_read_keycode +or %eax,%eax +jz done +or %edx,%edx +jz done +and $0b10000000,%al +jnz done +pushl %edx +call print_char +addl $4,%esp +call floppy_proc +jmp done + +error: jmp error + + +.org 0x1FE + +.word 0xAA55 + +.org 0x200 + +.data + +gdt: + +.word 0, 0, 0, 0 # dummy +.word 0xFFFF, KERNEL_START, 0x9A00, 0x00CF # kernel code, 4 GB, code exec/read, 386 Segment +.word 0xFFFF, KERNEL_START, 0x9200, 0x00CF # kernel data, 4 GB, data read/write, 386 Segment +.word 0x2000, 0x8000, 0x9200, 0 # kernel stack, 8192 Bytes, data read/write, base address 0x8000 +.word 4000, 0x8000, 0x920B, 0 # VRAM, 4000 Bytes, data read/write, base address 0xB8000 +.word 0x0500, 0, 0x9200, 0 # BIOS data, 0x500 Bytes, data read/write, base address 0 + +gdt_end: + + +idt: + +.word EXC_DIV_ERROR, CODE_SEL, 0x8E00, 0 +.word EXC_DEBUG, CODE_SEL, 0x8E00, 0 +.word EXC_NMI, CODE_SEL, 0x8E00, 0 +.word EXC_BREAKPOINT, CODE_SEL, 0x8E00, 0 +.word EXC_INTO_OVERFLOW, CODE_SEL, 0x8E00, 0 +.word EXC_BOUND_OVERFLOW, CODE_SEL, 0x8E00, 0 +.word EXC_INVAL_OPCODE, CODE_SEL, 0x8E00, 0 +.word EXC_NO_COPROCESSOR, CODE_SEL, 0x8E00, 0 +.word EXC_DOUBLE_EXCEPTION, CODE_SEL, 0x8E00, 0 +.word EXC_COPROC_PROT_ERROR, CODE_SEL, 0x8E00, 0 +.word EXC_INVAL_TSS, CODE_SEL, 0x8E00, 0 +.word EXC_SEG_NOT_PRESENT, CODE_SEL, 0x8E00, 0 +.word EXC_STACK_FAULT, CODE_SEL, 0x8E00, 0 +.word EXC_GEN_PROT_VIOLATION, CODE_SEL, 0x8E00, 0 +.word EXC_PAGE_FAULT, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_COPROCESSOR_ERROR, CODE_SEL, 0x8E00, 0 +.word EXC_ALIGN_ERROR, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 +.word EXC_RESERVED, CODE_SEL, 0x8E00, 0 + +.word IRQ0, CODE_SEL, 0x8E00, 0 +.word IRQ1, CODE_SEL, 0x8E00, 0 +.word IRQ2, CODE_SEL, 0x8E00, 0 +.word IRQ3, CODE_SEL, 0x8E00, 0 +.word IRQ4, CODE_SEL, 0x8E00, 0 +.word IRQ5, CODE_SEL, 0x8E00, 0 +.word IRQ6, CODE_SEL, 0x8E00, 0 +.word IRQ7, CODE_SEL, 0x8E00, 0 +.word IRQ8, CODE_SEL, 0x8E00, 0 +.word IRQ9, CODE_SEL, 0x8E00, 0 +.word IRQ10, CODE_SEL, 0x8E00, 0 +.word IRQ11, CODE_SEL, 0x8E00, 0 +.word IRQ12, CODE_SEL, 0x8E00, 0 +.word IRQ13, CODE_SEL, 0x8E00, 0 +.word IRQ14, CODE_SEL, 0x8E00, 0 +.word IRQ15, CODE_SEL, 0x8E00, 0 + +idt_end: + + +gdt_struct: + +.word GDT_SIZE # gdt size +.long (KERNEL_START+gdt) # gdt base address + + +idt_struct: + +.word IDT_SIZE +.long (KERNEL_START+idt) + +verstring: .ascii "WINX " WINX_VERSION "\r\n\0" |