minor stuff with the A20 line '-'
This commit is contained in:
parent
d3ba9640fc
commit
35c71e4b24
|
@ -0,0 +1,10 @@
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
// GNU GPL OS/K //
|
||||||
|
// //
|
||||||
|
// Authors: spectral` //
|
||||||
|
// NeoX //
|
||||||
|
// //
|
||||||
|
// Desc: ELF64 Parser and Loader //
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,6 @@
|
||||||
%define volumeLabel bp+0x2b ; Volume Label
|
%define volumeLabel bp+0x2b ; Volume Label
|
||||||
%define fatTypeLabel bp+0x36 ; File system type
|
%define fatTypeLabel bp+0x36 ; File system type
|
||||||
|
|
||||||
;; DISK BUFFER "SEGMENT"
|
|
||||||
%define BUFFER_SEG 0x07c0 ; (BUFFER_SEG << 4) + BUFFER_OFF = 0x07C00
|
|
||||||
%define BUFFER_OFF 0x0000
|
|
||||||
|
|
||||||
;; SECOND STAGE LOADER "SEGMENT"
|
|
||||||
%define LOAD_SEG LONG_SELECTOR-GDT64 ; (LOAD_SEG << 4) + LOAD_OFF = 0x070000
|
|
||||||
%define LOAD_OFF Kernel
|
|
||||||
|
|
||||||
|
|
||||||
[BITS 16]
|
[BITS 16]
|
||||||
|
@ -61,7 +54,7 @@ GDT64:
|
||||||
dd 0x0 ;
|
dd 0x0 ;
|
||||||
|
|
||||||
CODE_SELECTOR: ;; 32-bit code selector (ring 0)
|
CODE_SELECTOR: ;; 32-bit code selector (ring 0)
|
||||||
dw 0x0FFFF ; Segment Limit
|
dw 0x0000FFFF ; Segment Limit
|
||||||
db 0x0, 0x0, 0x0 ; Base Address
|
db 0x0, 0x0, 0x0 ; Base Address
|
||||||
db 10011010b ; |7|6|5|4|3|2|1|0|
|
db 10011010b ; |7|6|5|4|3|2|1|0|
|
||||||
; | | | | | | | `----- 1 when segment used.
|
; | | | | | | | `----- 1 when segment used.
|
||||||
|
@ -84,7 +77,7 @@ GDT64:
|
||||||
db 0x0 ; Base Address
|
db 0x0 ; Base Address
|
||||||
|
|
||||||
DATA_SELECTOR: ;; flat data selector (ring 0)
|
DATA_SELECTOR: ;; flat data selector (ring 0)
|
||||||
dw 0x0FFFF ; Segment Limit
|
dw 0x0000FFFF ; Segment Limit
|
||||||
db 0x0, 0x0, 0x0 ; Base Address
|
db 0x0, 0x0, 0x0 ; Base Address
|
||||||
db 10010010b ; |7|6|5|4|3|2|1|0|
|
db 10010010b ; |7|6|5|4|3|2|1|0|
|
||||||
; | | | | | | | `----- 1 when segment used.
|
; | | | | | | | `----- 1 when segment used.
|
||||||
|
@ -107,7 +100,7 @@ GDT64:
|
||||||
db 0x0 ; Base Address
|
db 0x0 ; Base Address
|
||||||
|
|
||||||
LONG_SELECTOR: ;; 64-bit code selector (ring 0)
|
LONG_SELECTOR: ;; 64-bit code selector (ring 0)
|
||||||
dw 0x0FFFF ; Segment Limit
|
dw 0x0000FFFF ; Segment Limit
|
||||||
db 0x0, 0x0, 0x0 ; Base Address
|
db 0x0, 0x0, 0x0 ; Base Address
|
||||||
db 10011010b ; |7|6|5|4|3|2|1|0|
|
db 10011010b ; |7|6|5|4|3|2|1|0|
|
||||||
; | | | | | | | `----- 1 when segment used.
|
; | | | | | | | `----- 1 when segment used.
|
||||||
|
@ -195,6 +188,21 @@ main32:
|
||||||
pop dword [VGA_HEIGHT32]
|
pop dword [VGA_HEIGHT32]
|
||||||
pop dword [VIDEO_MODE32]
|
pop dword [VIDEO_MODE32]
|
||||||
|
|
||||||
|
;; VERIFY A20
|
||||||
|
pushad
|
||||||
|
mov edi,0x112345 ;odd megabyte address.
|
||||||
|
mov esi,0x012345 ;even megabyte address.
|
||||||
|
mov [esi],esi ;making sure that both addresses contain diffrent values.
|
||||||
|
mov [edi],edi ;(if A20 line is cleared the two pointers would point to the address 0x012345 that would contain 0x112345 (edi))
|
||||||
|
cmpsd ;compare addresses to see if the're equivalent.
|
||||||
|
popad
|
||||||
|
jne .A20_on ;if not equivalent , A20 line is set.
|
||||||
|
mov WORD [A20_OK], 0
|
||||||
|
jmp .A20_end
|
||||||
|
.A20_on:
|
||||||
|
mov BYTE [A20_OK], 1
|
||||||
|
.A20_end:
|
||||||
|
|
||||||
;; INITIALIZE PROTECTED MODE SEGMENT REGISTERS
|
;; INITIALIZE PROTECTED MODE SEGMENT REGISTERS
|
||||||
mov ax, DATA_SELECTOR-GDT64
|
mov ax, DATA_SELECTOR-GDT64
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
@ -260,6 +268,7 @@ KernSearch db 0x09, " Loading the Kernel in RAM...", 0
|
||||||
txt db 0x09, " Switching to Long Mode... ", 0
|
txt db 0x09, " Switching to Long Mode... ", 0
|
||||||
Reinit db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0
|
Reinit db "Booting OS/K !", 0x0D, 0x0A, 0x0D, 0x0A, 0
|
||||||
Pass db " OK", 0x0A, 0x0D, 0
|
Pass db " OK", 0x0A, 0x0D, 0
|
||||||
|
Fail db " FAIL!", 0x0A, 0x0D, 0
|
||||||
msg db "The system is now in x64 mode. Is this not beautiful ?", 0x0A, 0x0D, 0
|
msg db "The system is now in x64 mode. Is this not beautiful ?", 0x0A, 0x0D, 0
|
||||||
|
|
||||||
NoLongMode db 0x0A, 0x0D, "ERROR : Your computer is not designed for x64 OS", 0
|
NoLongMode db 0x0A, 0x0D, "ERROR : Your computer is not designed for x64 OS", 0
|
||||||
|
@ -278,6 +287,7 @@ NextTRAM dq 0x0B8000 ; Last position of cursor
|
||||||
VIDEO_MODE64 dq 0
|
VIDEO_MODE64 dq 0
|
||||||
VGA_HEIGHT64 dq 0
|
VGA_HEIGHT64 dq 0
|
||||||
VGA_X dq 0
|
VGA_X dq 0
|
||||||
|
A20_OK db 0
|
||||||
|
|
||||||
main64:
|
main64:
|
||||||
pop qword [VGA_HEIGHT64]
|
pop qword [VGA_HEIGHT64]
|
||||||
|
@ -304,14 +314,13 @@ main64:
|
||||||
mov esi, EnA20
|
mov esi, EnA20
|
||||||
call write
|
call write
|
||||||
|
|
||||||
mov bl, 0x0A
|
cmp BYTE [A20_OK], 1
|
||||||
mov esi, Pass
|
je .A20Success
|
||||||
|
mov bl, 0x0C
|
||||||
|
mov esi, Fail
|
||||||
call write
|
call write
|
||||||
|
jmp Die
|
||||||
mov bl, 0x0F
|
.A20Success:
|
||||||
mov esi, KernSearch
|
|
||||||
call write
|
|
||||||
|
|
||||||
mov bl, 0x0A
|
mov bl, 0x0A
|
||||||
mov esi, Pass
|
mov esi, Pass
|
||||||
call write
|
call write
|
||||||
|
@ -328,6 +337,7 @@ main64:
|
||||||
mov esi, msg
|
mov esi, msg
|
||||||
call write
|
call write
|
||||||
|
|
||||||
|
|
||||||
jmp Die
|
jmp Die
|
||||||
|
|
||||||
; times 1024 nop
|
; times 1024 nop
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue