greatbridf %!s(int64=4) %!d(string=hai) anos
pai
achega
1b7348b670
Modificáronse 6 ficheiros con 31 adicións e 6 borrados
  1. 1 0
      CMakeLists.txt
  2. 2 0
      include/asm/boot.h
  3. 2 0
      ldscript.ld
  4. 19 0
      src/asm/a20.s
  5. 3 6
      src/boot.s
  6. 4 0
      src/kernel_main.c

+ 1 - 0
CMakeLists.txt

@@ -9,6 +9,7 @@ set(EXTRACT_DIR ${PROJECT_BINARY_DIR}/extract)
 file(MAKE_DIRECTORY ${EXTRACT_DIR})
 
 set(BOOTLOADER_SOURCES src/boot.s
+                       src/asm/a20.s
                        )
 
 add_library(bootloader STATIC ${BOOTLOADER_SOURCES})

+ 2 - 0
include/asm/boot.h

@@ -6,3 +6,5 @@ struct gdt_descriptor {
 };
 
 extern struct gdt_descriptor asm_gdt_descriptor;
+
+extern uint32_t check_a20_on(void);

+ 2 - 0
ldscript.ld

@@ -5,6 +5,8 @@ SECTIONS
 {
     .text :
     {
+        *(.text.bootsect)
+        *(.text.loader)
         *(.text*)
         *(.rodata)
     }

+ 19 - 0
src/asm/a20.s

@@ -0,0 +1,19 @@
+.text
+
+.globl check_a20_on
+.type  check_a20_on @function
+
+check_a20_on:
+    pushal
+    movl $0x112345, %edi
+    movl $0x012345, %esi
+    movl %esi, (%esi)
+    movl %edi, (%edi)
+    cmpsd
+    popal
+    jne a20_on
+    movl $0, %eax
+    ret
+a20_on:
+    movl $1, %eax
+    ret

+ 3 - 6
src/boot.s

@@ -1,4 +1,4 @@
-.text
+.section .text.bootsect
 .code16
 
 # mbr
@@ -51,6 +51,7 @@ stack_base:
 .space 510 - (.-_start)
 .word 0xaa55
 
+.section .text.loader
 
 # loader
 
@@ -75,17 +76,13 @@ loader_start:
 start_32bit:
     movw $16, %ax
     movw %ax, %ds
+    movw %ax, %es
     movw %ax, %ss
 
 # set up stack
     movl $0x003fffff, %ebp
     movl $0x003fffff, %esp
 
-# breakpoint
-#ifdef _DEBUG
-    xchgw %bx, %bx
-#endif
-
     call kernel_main
 
 loader_halt:

+ 4 - 0
src/kernel_main.c

@@ -1,8 +1,12 @@
 #include <kernel_main.h>
 
+#include <asm/boot.h>
+
 void kernel_main(void)
 {
     asm volatile("xchgw %bx, %bx"); // magic breakpoint
+    uint32_t result;
+    result = check_a20_on();
 _loop:
     goto _loop;
 }