Skip to content

Commit dd15335

Browse files
mbr solo carga tsl
1 parent 90958e2 commit dd15335

13 files changed

Lines changed: 81 additions & 74 deletions

File tree

asm/bios/mbr.asm

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
;; -- https://github.com/fysnet/FYSOS/blob/master/boot/embr/embr.asm
88
;; http://www.ctyme.com/intr/rb-0708.htm
99
;; -- https://stanislavs.org/helppc/int_10.html
10-
;; -- https://wiki.osdev.org/A20_Line
1110
;;
1211
;; This mbr is for 32 and 64 bit machines. Will not work fine on 16 bit 8086 or
1312
;; 80286 because it uses prefix override for some instructions.
1413
;;==============================================================================
1514

15+
1616
;; Payload recibido es todo lo enumerado a continuacion, pero en esta etapa de B
1717
;; bootload solo se pasa a memoria las porciones senaladas.
1818
;; +----------+---------+----------------+--/ /---+--------------+
@@ -28,7 +28,6 @@
2828

2929

3030
%include "./asm/include/mbr.inc"
31-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;%include "./asm/include/sysvar.inc"
3231

3332
global print_bios ;; Export symbol so to use this print function in start16.asm.
3433
global diskcpy
@@ -37,13 +36,13 @@ global failure
3736

3837
section .text
3938

39+
BITS 16
40+
4041

4142
;;=============================================================================
4243
;;
4344
;;=============================================================================
4445

45-
BITS 16
46-
4746
entryPoint:
4847
cli
4948
cld
@@ -67,7 +66,6 @@ entryPoint:
6766
;;jne magic_fail
6867

6968
call load_start16_tsl_lo
70-
call a20_line
7169

7270
mov eax, 0
7371
mov ebx, 0
@@ -255,75 +253,6 @@ print_bios:
255253
ret
256254

257255

258-
;;==============================================================================
259-
;; a20_line | config a20 line
260-
;;==============================================================================
261-
262-
a20_line:
263-
call a20_check
264-
jnz .end
265-
266-
.a20_set:
267-
in al, 0x64 ;; Status.
268-
test al, 0x02
269-
jnz .a20_set
270-
mov al, 0xd1 ;; 8042 Write command.
271-
out 0x64, al
272-
273-
.check:
274-
in al, 0x64
275-
test al, 0x02
276-
jnz .check
277-
mov al, 0xdf
278-
out 0x60, al
279-
280-
.end:
281-
ret
282-
283-
284-
;;==============================================================================
285-
;; a20_check | check the status of a20 line
286-
;;==============================================================================
287-
;; Returns:
288-
;; -- FLAGS[zero] = 1 (a20 disabled) | FLAGS[zero] = 0 (a20 enabled)
289-
;;
290-
;; Preserves all registers including segment registers.
291-
;;==============================================================================
292-
293-
a20_check:
294-
pusha
295-
push ds
296-
push es
297-
298-
xor ax, ax
299-
mov es, ax
300-
not ax ;; 0xFFFF
301-
mov ds, ax
302-
303-
mov di, 0x0500
304-
mov si, 0x0510
305-
306-
mov al, [es:di]
307-
push ax
308-
mov al, [ds:si]
309-
push ax
310-
311-
mov byte [es:di], 0x00
312-
mov byte [ds:si], 0xFF ;; Will overwrite the prev move if a20 not set.
313-
cmp byte [es:di], 0xFF
314-
315-
pop ax
316-
mov [ds:si], al
317-
pop ax
318-
mov [es:di], al
319-
320-
pop es
321-
pop ds
322-
popa
323-
324-
ret
325-
326-
327256
;;==============================================================================
328257
;; section .data
329258
;;==============================================================================

asm/bios/start16.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
;; Para bios boot primero real mode a protected mode. Uefi saltea esta parte, ya
55
;; bootea en 64.
66
;;
7+
;; -- https://wiki.osdev.org/A20_Line
78
;; https://wiki.osdev.org/Detecting_Memory_(x86)#BIOS_Function:_INT_0x15,_EAX_=_
89
;; 0xE820
910
;; https://wiki.osdev.org/Detecting_Memory_(x86)#Getting_an_E820_Memory_Map
@@ -18,6 +19,7 @@ extern diskcpy
1819
extern msg_ok
1920

2021
;; /lib/bios16.asm
22+
extern a20_line
2123
extern e820
2224
extern vesa
2325

@@ -48,6 +50,9 @@ section .text
4850
BITS 16
4951

5052
start16:
53+
54+
call a20_line
55+
5156
mov si, msg_e820
5257
call print_bios
5358

@@ -61,6 +66,7 @@ start16:
6166
or al, 0x01 ;; Set protected mode bit.
6267
mov cr0, eax
6368

69+
start32_jump:
6470
jmp 0x08:start32 ;; To 32-bit code.
6571

6672

@@ -115,6 +121,7 @@ en_paging:
115121

116122
mov bl, 'B'
117123

124+
start64_jump:
118125
jmp SYS64_CODE_SEL:start64 ;; To 64-bit mode.
119126

120127

asm/lib/bios16.asm

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
;; mbr.asm
88
extern failure
99

10+
global a20_line
1011
global e820
1112
global vesa
1213

@@ -15,6 +16,76 @@ section .text
1516
BITS 16
1617

1718

19+
20+
;;==============================================================================
21+
;; a20_line | config a20 line
22+
;;==============================================================================
23+
24+
a20_line:
25+
call a20_check
26+
jnz .end
27+
28+
.a20_set:
29+
in al, 0x64 ;; Status.
30+
test al, 0x02
31+
jnz .a20_set
32+
mov al, 0xd1 ;; 8042 Write command.
33+
out 0x64, al
34+
35+
.check:
36+
in al, 0x64
37+
test al, 0x02
38+
jnz .check
39+
mov al, 0xdf
40+
out 0x60, al
41+
42+
.end:
43+
ret
44+
45+
46+
;;==============================================================================
47+
;; a20_check | check the status of a20 line
48+
;;==============================================================================
49+
;; Returns:
50+
;; -- FLAGS[zero] = 1 (a20 disabled) | FLAGS[zero] = 0 (a20 enabled)
51+
;;
52+
;; Preserves all registers including segment registers.
53+
;;==============================================================================
54+
55+
a20_check:
56+
pusha
57+
push ds
58+
push es
59+
60+
xor ax, ax
61+
mov es, ax
62+
not ax ;; 0xFFFF
63+
mov ds, ax
64+
65+
mov di, 0x0500
66+
mov si, 0x0510
67+
68+
mov al, [es:di]
69+
push ax
70+
mov al, [ds:si]
71+
push ax
72+
73+
mov byte [es:di], 0x00
74+
mov byte [ds:si], 0xFF ;; Will overwrite the prev move if a20 not set.
75+
cmp byte [es:di], 0xFF
76+
77+
pop ax
78+
mov [ds:si], al
79+
pop ax
80+
mov [es:di], al
81+
82+
pop es
83+
pop ds
84+
popa
85+
86+
ret
87+
88+
1889
;;==============================================================================
1990
;;e820 | build memmap
2091
;;==============================================================================

build/tsl.sys

0 Bytes
Binary file not shown.

elf/mbr.elf

-304 Bytes
Binary file not shown.

elf/tsl_lo.elf

304 Bytes
Binary file not shown.

obj/bios16.o

320 Bytes
Binary file not shown.

obj/mbr.o

-288 Bytes
Binary file not shown.

obj/mbr_symbols.o

0 Bytes
Binary file not shown.

obj/start16.o

128 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)