summaryrefslogtreecommitdiff
path: root/boot0/disk_load_16.asm
blob: 55ad4aa97a4d6c664e95464296a4b68358acc359 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;disk_load_16
;


[bits 16]

STR_LBA:
    db "\nLBA Support Detected (no support yet)",0
    
STR_CHS
    db "CHS Support Detected",0

STR_ERROR
    db "Disk Read Error",0

STR_DONE
    db "Stage 2 Loaded",0

disk_load_16:

    pusha
    
   ; check if LBA is supported
    mov    ah,0x41
    mov    bx,0x55aa
    int    0x13                                                    
    jnc disk_load_lba
    jmp disk_load_chs


disk_load_lba:

    mov bx, STR_LBA
    call print_string
    call print_nextline
    jmp $
    jmp disk_load_finish

disk_load_chs:

    mov bx, STR_CHS
    call print_string
    call print_nextline

    mov bx,0		;target es:bx
    mov es,bx
    mov bx,0x7e00

    mov al,50		;number of sectors to read
    mov ah,0x02		;BIOS read sector func

    mov cl,2 ; sector
    mov ch,0 ; cylinder

    mov dl,[BOOT_DRIVE]
    mov dh,0 ;head

    int 0x13		;bios interrupt

    jnc disk_load_finish  

    jmp $

disk_load_finish:

    call print_nextline
    mov bx, STR_DONE
    call print_string
    call print_nextline


    popa
    ret