Skip to content

Commit fa0b71f

Browse files
pasa cod a funcs
1 parent 2043ebe commit fa0b71f

2 files changed

Lines changed: 69 additions & 44 deletions

File tree

asm/bios/mbr.asm

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
;; 80286 because it uses prefix override for some instructions.
1414
;;==============================================================================
1515

16+
;; Payload recibido es todo lo enumerado a continuacion, pero en esta etapa de B
17+
;; bootload solo se pasa a memoria las porciones senaladas.
18+
;; +----------+---------+----------------+--/ /---+--------------+
19+
;; | start | tsl_sta | tsl_ | 00..00 | tsl.asm |
20+
;; | 16.asm | rt.asm | ap.asm | 00..00 | |
21+
;; | .text_ | .text_ | .text_ | .data | 00..00 | .text |.data |
22+
;; | start16 | low | low | _low | 00..00 | | |
23+
;; +----------+---------+--------+-------+--/ /---+-------+------+
24+
;; |^ |^ |^ |^ |^ |^ |^
25+
;; 0x7E00 0x8000 0x8200 0x8800 0x800000 802000 803000
26+
;; |<- 512 -->|<--------- 4KiB --------->| |<--- 12KiB --->|
27+
;; |<--copy-->|<--cpy-->|<-----copy----->|
28+
1629

1730
%include "./asm/include/mbr.inc"
1831
%include "./asm/include/sysvar.inc"
@@ -36,56 +49,20 @@ entryPoint:
3649

3750
mov [drvNum], dl ;; Bios passes drive number in dl.
3851

39-
4052
mov si, msg_extSupport
4153
call print_bios
4254

4355
call extensionTest
4456

45-
46-
load_start16_tsl_hi:
47-
mov si, msg_reading
48-
call print_bios
49-
50-
mov ax, (512 + 1) ;; Cant sectors. Load 512 = 262144 bytes = 256 KiB + 1 (
51-
;; start16.asm). TO-DO: en realidad solo 240 que es el t
52-
;; amano completo de la payload. Ya incluye a start16. R
53-
;; evisar tamanos.
54-
mov bx, 6117 ;; Offset = 8192.
55-
mov cx, 0x7E00 ;; Destination.
56-
call diskcpy ;; Copia payload completo. En este momento no tengo acce
57-
;; so a 0x800000 donde luego de activar modo progegido,
58-
;; copiare tsl.
59-
60-
mov si, msg_ok
61-
call print_bios
62-
6357
;; TO-DO reponer
6458
;;mov eax, [0x8000 + SIGNATURE_OFFSET]
6559
;;cmp eax, "BOOT" ;; Simple payload verification (tsl_start.sys binary).
6660
;;jne magic_fail
6761

62+
call load_start16_tsl_lo
6863

69-
a20:
70-
call a20_check
71-
jnz start16_prepare
64+
call a20_line
7265

73-
.a20_set:
74-
in al, 0x64 ;; Status.
75-
test al, 0x02
76-
jnz .a20_set
77-
mov al, 0xd1 ;; 8042 Write command.
78-
out 0x64, al
79-
80-
.check:
81-
in al, 0x64
82-
test al, 0x02
83-
jnz .check
84-
mov al, 0xdf
85-
out 0x60, al
86-
87-
88-
start16_prepare:
8966
mov eax, 0
9067
mov ebx, 0
9168
mov ecx, 0
@@ -114,6 +91,29 @@ failure:
11491
jmp $
11592

11693

94+
;;==============================================================================
95+
;; load_start16_tsl_lo | copy the required part of the payload
96+
;;==============================================================================
97+
98+
load_start16_tsl_lo:
99+
mov si, msg_reading
100+
call print_bios
101+
102+
mov ax, (512 + 1) ;; Cant sectors. Load 512 = 262144 bytes = 256 KiB + 1 (
103+
;; start16.asm). TO-DO: en realidad solo 240 que es el t
104+
;; amano completo de la payload. Ya incluye a start16. R
105+
;; evisar tamanos.
106+
mov bx, 6117 ;; Offset = 8192.
107+
mov cx, 0x7E00 ;; Destination.
108+
call diskcpy ;; Copia payload completo. En este momento no tengo acce
109+
;; so a 0x800000 donde luego de activar modo progegido,
110+
;; copiare tsl.
111+
mov si, msg_ok
112+
call print_bios
113+
114+
ret
115+
116+
117117
;;==============================================================================
118118
;; diskcpy | Copy n sectors from disk.
119119
;;==============================================================================
@@ -249,6 +249,31 @@ print_bios:
249249
ret
250250

251251

252+
;;==============================================================================
253+
;; a20_line | Config a20 line
254+
;;==============================================================================
255+
256+
257+
258+
a20_line:
259+
call a20_check
260+
jnz start16_continue
261+
262+
.a20_set:
263+
in al, 0x64 ;; Status.
264+
test al, 0x02
265+
jnz .a20_set
266+
mov al, 0xd1 ;; 8042 Write command.
267+
out 0x64, al
268+
269+
.check:
270+
in al, 0x64
271+
test al, 0x02
272+
jnz .check
273+
mov al, 0xdf
274+
out 0x60, al
275+
276+
252277
;;==============================================================================
253278
;; a20_check | Check the status of a20 line
254279
;;==============================================================================

asm/lib/lib.asm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ section .text
2727

2828

2929
;;==============================================================================
30-
; num2hexStr - escribe el hexadecimal de un nro, dentro de un placeholder utf8
30+
; num2hexStr | escribe el hexadecimal de un nro, dentro de un placeholder utf8
3131
;;==============================================================================
3232
;; Argumentos:
3333
;; -- placeholder por stack, 1er push.
@@ -81,7 +81,7 @@ num2hexStr:
8181

8282

8383
;;==============================================================================
84-
;; num2str - convierte un entero en un string null terminated
84+
;; num2str | convierte un entero en un string null terminated
8585
;;==============================================================================
8686
;; Argumentos:
8787
;; -- placeholder por stack, 1er push.
@@ -138,7 +138,7 @@ num2str:
138138

139139

140140
;;==============================================================================
141-
;; print - wrapper print_color, imprime por defecto con texto PRINT_COLOR_WHT.
141+
;; print | wrapper print_color, imprime por defecto con texto PRINT_COLOR_WHT.
142142
;;==============================================================================
143143
;; Argumentos:
144144
;; -- r9 = cadena fmt
@@ -154,7 +154,7 @@ print:
154154

155155

156156
;;==============================================================================
157-
;; print_color - impresion utf8 a buffer de video luego de ExitBootSerivces()
157+
;; print_color | impresion utf8 a buffer de video luego de ExitBootSerivces()
158158
;;==============================================================================
159159
;; Argumentos:
160160
;; -- r9 = cadena fmt
@@ -392,7 +392,7 @@ keyboard_command:
392392

393393

394394
;;==============================================================================
395-
;; keyboard_get_key | Se queda esperando tecla 'n'.
395+
;; keyboard_get_key | se queda esperando tecla 'n'.
396396
;;==============================================================================
397397

398398
keyboard_get_key:
@@ -423,7 +423,7 @@ keyboard_get_key:
423423

424424

425425
;;==============================================================================
426-
;; emptyKbBuffer - Vacia el teclado, dejando ninguna tecla pendiente.
426+
;; emptyKbBuffer | vacia el teclado, dejando ninguna tecla pendiente.
427427
;;==============================================================================
428428

429429
emptyKbBuffer:

0 commit comments

Comments
 (0)