refactor(boot): create fat_read_bpb func
This commit is contained in:
parent
899e456249
commit
e0ab3e5c1a
|
@ -5,6 +5,7 @@ LOADER_SRCS = loader.asm \
|
||||||
../common/bootinfo.inc \
|
../common/bootinfo.inc \
|
||||||
../../kernel/sys/bootinfo.inc \
|
../../kernel/sys/bootinfo.inc \
|
||||||
../../kernel/sys/register.inc \
|
../../kernel/sys/register.inc \
|
||||||
|
fat.inc \
|
||||||
video.inc \
|
video.inc \
|
||||||
memory.inc \
|
memory.inc \
|
||||||
logger.inc \
|
logger.inc \
|
||||||
|
|
30
boot/loader/fat.inc
Normal file
30
boot/loader/fat.inc
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
;; File: fat.inc
|
||||||
|
|
||||||
|
include '../common/fat12.inc'
|
||||||
|
|
||||||
|
fat_read_bpb:
|
||||||
|
mov ax, DISK_BUFFER/0x10
|
||||||
|
mov es, ax
|
||||||
|
xor bx, bx
|
||||||
|
mov ax, 0
|
||||||
|
mov cx, 1
|
||||||
|
call disk_read_sectors
|
||||||
|
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.sects_per_track]
|
||||||
|
mov word [sectors_per_track], ax
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.heads_per_cyl]
|
||||||
|
mov word [heads_per_cylinder], ax
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.bytes_per_sects]
|
||||||
|
mov word [bytes_per_sector], ax
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.sects_per_FAT]
|
||||||
|
mov word [sectors_per_FAT], ax
|
||||||
|
mov byte al, [DISK_BUFFER + fat_bpb.FAT_count]
|
||||||
|
mov byte [FAT_count], al
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.reserved_sects]
|
||||||
|
mov word [reserved_sectors], ax
|
||||||
|
mov word ax, [DISK_BUFFER + fat_bpb.root_dir_entries]
|
||||||
|
mov word [root_dir_entries], ax
|
||||||
|
mov byte al, [DISK_BUFFER + fat_bpb.sects_per_clust]
|
||||||
|
mov byte [sectors_per_cluster], al
|
||||||
|
ret
|
||||||
|
|
|
@ -80,29 +80,7 @@ _start:
|
||||||
; for now fat12 is asumed
|
; for now fat12 is asumed
|
||||||
.fat_fallback:
|
.fat_fallback:
|
||||||
; get bpb
|
; get bpb
|
||||||
mov ax, DISK_BUFFER/0x10
|
call fat_read_bpb
|
||||||
mov es, ax
|
|
||||||
xor bx, bx
|
|
||||||
mov ax, 0
|
|
||||||
mov cx, 1
|
|
||||||
call disk_read_sectors
|
|
||||||
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.sects_per_track]
|
|
||||||
mov word [sectors_per_track], ax
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.heads_per_cyl]
|
|
||||||
mov word [heads_per_cylinder], ax
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.bytes_per_sects]
|
|
||||||
mov word [bytes_per_sector], ax
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.sects_per_FAT]
|
|
||||||
mov word [sectors_per_FAT], ax
|
|
||||||
mov byte al, [DISK_BUFFER + fat_bpb.FAT_count]
|
|
||||||
mov byte [FAT_count], al
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.reserved_sects]
|
|
||||||
mov word [reserved_sectors], ax
|
|
||||||
mov word ax, [DISK_BUFFER + fat_bpb.root_dir_entries]
|
|
||||||
mov word [root_dir_entries], ax
|
|
||||||
mov byte al, [DISK_BUFFER + fat_bpb.sects_per_clust]
|
|
||||||
mov byte [sectors_per_cluster], al
|
|
||||||
|
|
||||||
call fat_load_root
|
call fat_load_root
|
||||||
|
|
||||||
|
@ -177,7 +155,7 @@ _start:
|
||||||
|
|
||||||
include 'a20.inc'
|
include 'a20.inc'
|
||||||
include '../common/bios.inc'
|
include '../common/bios.inc'
|
||||||
include '../common/fat12.inc'
|
include 'fat.inc'
|
||||||
include 'disk.inc'
|
include 'disk.inc'
|
||||||
include 'logger.inc'
|
include 'logger.inc'
|
||||||
include 'memory.inc'
|
include 'memory.inc'
|
||||||
|
|
Loading…
Reference in a new issue