Skip to content

Commit 5b60f12

Browse files
bios lib separada y agregado a ld script
1 parent 38186d4 commit 5b60f12

25 files changed

Lines changed: 168 additions & 47 deletions

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ $(UEFI_SYS): build ./obj/lib.o ./obj/efi.o
4646
$(LD) -T $(LD_DIR)/uefi.ld -o $@ $(UEFI_OBJ) $(OBJ_DIR)/lib.o $(OBJ_DIR)/efi.o
4747
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/uefi.ld -o $(UEFI_ELF) $(UEFI_OBJ) $(OBJ_DIR)/lib.o $(OBJ_DIR)/efi.o
4848

49-
$(TSL_SYS): build $(TSL_OBJS_LO) $(TSL_OBJS_HI)
50-
$(LD) -T $(LD_DIR)/tsl.ld -o $@ $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o
51-
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl.ld -o $(TSL_ELF_LO) $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o
49+
$(TSL_SYS): build $(TSL_OBJS_LO) $(TSL_OBJS_HI) ./obj/bios16.o ./obj/bios32.o
50+
$(LD) -T $(LD_DIR)/tsl.ld -o $@ $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o
51+
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl.ld -o $(TSL_ELF_LO) $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o
5252
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl_hi.ld -o $(TSL_ELF_HI) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o
5353

5454
mbr: build

asm/bios/mbr.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

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

3333
;;global print_bios ;; Export symbol so to use this print function in start16.asm.
3434

asm/bios/start16.asm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
;;extern print_bios
1919
;;extern failure
2020
print_bios: equ 0x00de + 0x7c00 ;; print_bios en 0x7cde
21-
vesa: equ 0x011d + 0x7c00 ;; print_bios en 0x011d
21+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;vesa: equ 0x011d + 0x7c00 ;; print_bios en 0x011d
2222
diskcpy: equ 0x0 + 0x7c00 ;; print_bios en 0x011d
2323

2424
msg_ok: equ 0x00
2525

26+
;; /lib/bios.asm
27+
extern vesa
28+
extern vesa2uefi
2629

2730
;; tsl.asm
2831
extern start64
@@ -35,6 +38,9 @@ extern tmpGDTR64 ;; Only for bios boot. See tsl.asm 1178 TO-DO.
3538
extern SYS64_CODE_SEL
3639

3740

41+
section .text
42+
43+
3844
;;==============================================================================
3945
;;
4046
;;==============================================================================
@@ -235,7 +241,7 @@ load_tsl_hi:
235241

236242

237243

238-
call buildVideoData
244+
call vesa2uefi
239245

240246

241247
;;;;;;;;;;;;;;;;; 7f23

asm/lib/bios16.asm

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
;;==============================================================================
2+
;; 16 bits lib for bios boot | @file /asm/lib/bios16.asm
3+
;;==============================================================================
4+
5+
%include "./asm/include/sysvar.inc"
6+
7+
;; TO-DO: print_bios reponer el address correcto.
8+
extern print_bios
9+
print_bios: equ 0
10+
11+
global vesa
12+
global failure
13+
14+
15+
section .text_low
16+
17+
BITS 16
18+
19+
20+
;;==============================================================================
21+
;; vesa |
22+
;;==============================================================================
23+
;; No me gusta esta fun definida aqui y llamada en start. Luego veo que hacer.
24+
;; Esto es transitorio por cuestiones de espacio.
25+
;;==============================================================================
26+
27+
vesa:
28+
mov cx, 0x4000 - 1 ; Start looking from here
29+
30+
.vbe_search:
31+
inc cx
32+
mov bx, cx ; Mode is saved to BX for the set command later
33+
cmp cx, 0x5000
34+
35+
;;TO-DO: falta load mensaje error.
36+
je failure
37+
38+
mov edi, VBEModeInfoBlock ; VBE data will be stored at this address
39+
mov ax, 0x4F01 ; VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION - http://www.ctyme.com/intr/rb-0274.htm
40+
int 0x10
41+
cmp ax, 0x004F ; Return value in AX should equal 0x004F if command supported and successful
42+
jne .vbe_search ; Try next mode
43+
cmp byte [VBEModeInfoBlock.BitsPerPixel], 32 ; Desired bit depth
44+
jne .vbe_search ; If not equal, try next mode
45+
cmp word [VBEModeInfoBlock.XResolution], Horizontal_Resolution ; Desired XRes here
46+
jne .vbe_search
47+
cmp word [VBEModeInfoBlock.YResolution], Vertical_Resolution ; Desired YRes here
48+
jne .vbe_search
49+
or bx, 0x4000 ; Use linear/flat frame buffer model (set bit 14)
50+
mov ax, 0x4F02 ; VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE - http://www.ctyme.com/intr/rb-0275.htm
51+
int 0x10
52+
cmp ax, 0x004F ; Return value in AX should equal 0x004F if supported and successful
53+
54+
;;TO-DO: falta load mensaje error.
55+
jne failure
56+
57+
ret
58+
59+
60+
;;==============================================================================
61+
;; failure | abort boot with error notification
62+
;;==============================================================================
63+
;; Argument:
64+
;; -- si: string.
65+
;;
66+
;; TO-DO: codigo repetido. Ver si esto lo reemplazo por el failure definido en mbr.
67+
;;==============================================================================
68+
69+
failure:
70+
call print_bios
71+
72+
.halt:
73+
mov si, msg_halt
74+
call print_bios
75+
hlt
76+
jmp $
77+
78+
79+
80+
81+
msg_halt: db "System halted", 0
82+
x: dd msg_halt

asm/lib/bios.asm renamed to asm/lib/bios32.asm

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,17 @@
11
;;==============================================================================
2-
;; Lib for bios boot | @file /asm/lib/bios.asm
2+
;; 32 bits lib for bios boot | @file /asm/lib/bios32.asm
33
;;==============================================================================
44

5+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;%include "./asm/include/sysvar.inc"
56

7+
global vesa2uefi
68

9+
extern failure
710

8-
;;==============================================================================
9-
;; vesa |
10-
;;==============================================================================
11-
;; No me gusta esta fun definida aqui y llamada en start. Luego veo que hacer.
12-
;; Esto es transitorio por cuestiones de espacio.
13-
;;==============================================================================
1411

15-
vesa:
16-
mov cx, 0x4000 - 1 ; Start looking from here
17-
18-
.vbe_search:
19-
inc cx
20-
mov bx, cx ; Mode is saved to BX for the set command later
21-
cmp cx, 0x5000
22-
23-
;;TO-DO: falta load mensaje error.
24-
je failure
25-
26-
mov edi, VBEModeInfoBlock ; VBE data will be stored at this address
27-
mov ax, 0x4F01 ; VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION - http://www.ctyme.com/intr/rb-0274.htm
28-
int 0x10
29-
cmp ax, 0x004F ; Return value in AX should equal 0x004F if command supported and successful
30-
jne .vbe_search ; Try next mode
31-
cmp byte [VBEModeInfoBlock.BitsPerPixel], 32 ; Desired bit depth
32-
jne .vbe_search ; If not equal, try next mode
33-
cmp word [VBEModeInfoBlock.XResolution], Horizontal_Resolution ; Desired XRes here
34-
jne .vbe_search
35-
cmp word [VBEModeInfoBlock.YResolution], Vertical_Resolution ; Desired YRes here
36-
jne .vbe_search
37-
or bx, 0x4000 ; Use linear/flat frame buffer model (set bit 14)
38-
mov ax, 0x4F02 ; VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE - http://www.ctyme.com/intr/rb-0275.htm
39-
int 0x10
40-
cmp ax, 0x004F ; Return value in AX should equal 0x004F if supported and successful
41-
42-
;;TO-DO: falta load mensaje error.
43-
jne failure
12+
section .text_low
4413

45-
ret
14+
BITS 32
4615

4716

4817
;;==============================================================================
@@ -115,7 +84,3 @@ vesa2uefi:
11584

11685
ret
11786

118-
119-
120-
121-

build/tsl.sys

14.3 KB
Binary file not shown.

build/uefi.sys

1 MB
Binary file not shown.

elf/tsl_hi.elf

35.1 KB
Binary file not shown.

elf/tsl_lo.elf

51.3 KB
Binary file not shown.

elf/uefi.elf

1.02 MB
Binary file not shown.

0 commit comments

Comments
 (0)