Compare commits
4 Commits
d8a89cfd2b
...
11656c2827
| Author | SHA1 | Date | |
|---|---|---|---|
| 11656c2827 | |||
| f87f88a0dc | |||
| 7baa53178a | |||
| 8002d1cb54 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,4 +10,5 @@ stevia-log
|
||||
*.map
|
||||
compose-dev.yaml
|
||||
eth_null-tx.log
|
||||
eth_null-txdump.txt
|
||||
eth_null-txdump.txt
|
||||
*.log
|
||||
3
Makefile
3
Makefile
@@ -38,9 +38,6 @@ QEMU_ARGS := \
|
||||
-device e1000,netdev=n0,mac=52:54:00:12:34:56 \
|
||||
-netdev user,id=n0 \
|
||||
-device piix3-usb-uhci \
|
||||
-device usb-ohci,id=ohci0 \
|
||||
-device usb-ehci,id=ehci0 \
|
||||
-device pcspk \
|
||||
-parallel null \
|
||||
-serial null -serial none -serial none -serial none \
|
||||
-chardev file,id=dbg,path=bochs-e9.log,append=on \
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
|
||||
%ifndef __INC_ERROR_CODES
|
||||
|
||||
; Errors
|
||||
; 12 Errors, 5 in use
|
||||
; MBR Error codes
|
||||
%define MBR_ERROR_DISK_T_ERR 'a'
|
||||
%define MBR_ERROR_NO_INT32E 'b'
|
||||
%define MBR_ERROR_NO_NO_BOOT_PART 'c'
|
||||
@@ -30,7 +29,7 @@
|
||||
%define MBR_ERROR_RESERVED_k 'k'
|
||||
%define MBR_ERROR_INT13h_EREAD_ERR 'l'
|
||||
|
||||
; 12 Error
|
||||
; VBR Error codes
|
||||
%define VBR_ERROR_WRONG_FAT_SIZE 'm'
|
||||
%define VBR_ERROR_NO_SIGNATURE 'n'
|
||||
%define VBR_ERROR_DISK_READ_ERR 'o'
|
||||
@@ -44,7 +43,7 @@
|
||||
%define VBR_ERROR_RESERVED_w 'w'
|
||||
%define VBR_ERROR_RESERVED_x 'x'
|
||||
|
||||
; 22 errors, 8 in use
|
||||
; Stage2 Error codes
|
||||
%define STAGE2_A20_FAILED 'A'
|
||||
%define STAGE2_SIGNATURE_MISSING 'B'
|
||||
%define STAGE2_MM_E820_NO_SUPPORT 'C'
|
||||
@@ -60,19 +59,19 @@
|
||||
%define STAGE2_FAT32_E_UNSUPPORTED 'M'
|
||||
%define STAGE2_FAT32_E_UNIMPLEMENTED 'N'
|
||||
%define STAGE2_ERROR_BAD_MBR 'O'
|
||||
%define STAGE2_ERROR_BAD_VBR 'P'
|
||||
%define STAGE2_ERROR_RESERVED_Q 'Q'
|
||||
%define STAGE2_ERROR_RESERVED_R 'R'
|
||||
%define STAGE2_ERROR_RESERVED_S 'S'
|
||||
%define STAGE2_ERROR_RESERVED_T 'T'
|
||||
%define STAGE2_ERROR_RESERVED_U 'U'
|
||||
%define STAGE2_ERROR_RESERVED_V 'V'
|
||||
%define STAGE2_VBR_E_ACTIVE 'P'
|
||||
%define STAGE2_VBR_E_SIGN 'Q'
|
||||
%define STAGE2_VBR_E_TOT 'R'
|
||||
%define STAGE2_VBR_E_FATSZ 'S'
|
||||
%define STAGE2_VBR_E_DIRENT 'T'
|
||||
%define STAGE2_VBR_E_PARTTYPE 'U'
|
||||
%define STAGE2_RESERVED_E_V 'V'
|
||||
|
||||
; for development only, specific errors should be above.
|
||||
%define STEVIA_DEBUG_OK 'W'
|
||||
%define STEVIA_DEBUG_ERR 'X'
|
||||
%define STEVIA_DEBUG_UNIMPLEMENTED 'Y'
|
||||
%define STEVIA_DEBUG_HALT 'Z'
|
||||
; Debug error codes
|
||||
%define STEVIA_DEBUG_OK 'W'
|
||||
%define STEVIA_DEBUG_ERR 'X'
|
||||
%define STEVIA_DEBUG_UNIMPLEMENTED 'Y'
|
||||
%define STEVIA_DEBUG_HALT 'Z'
|
||||
|
||||
%endif
|
||||
%define __INC_ERROR_CODES
|
||||
@@ -65,11 +65,11 @@ struc FAT32_bpb_t
|
||||
.u16_RootEntryCount16 resw 1 ; Root dir entry count field, 0 on fat32
|
||||
.u16_TotalSectors16 resw 1 ; total number of sectors size, 0 on fat32
|
||||
.u8_MediaDesc resb 1
|
||||
.u16_FatSize16 resw 1 ; FAT size 16, 0 on fat32
|
||||
.u16_FATSize16 resw 1 ; FAT size 16, 0 on fat32
|
||||
.u16_SectorsPerTrack resw 1
|
||||
.u16_HeadCount resw 1
|
||||
.u32_HiddenSectors resd 1
|
||||
.u32_TotalSectors resd 1
|
||||
.u32_TotalSectors32 resd 1
|
||||
endstruc
|
||||
|
||||
; EBPB Information (FAT32)
|
||||
@@ -89,7 +89,7 @@ endstruc
|
||||
; 8 System identifier string. Always "FAT32 ". The spec says never to trust the contents of this string for any use.
|
||||
|
||||
struc FAT32_ebpb_t
|
||||
.u32_FATSz resd 1 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
|
||||
.u32_FATSize32 resd 1 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
|
||||
.u16_ExtFlags resw 1
|
||||
.u16_FSVersion resw 1
|
||||
.u32_RootDirCluster resd 1
|
||||
|
||||
@@ -230,17 +230,27 @@ ReadVbrData:
|
||||
mov ax, word [bx + SteviaInfoStruct_t.p16_MbrPtr]
|
||||
add ax, DISK_PARTITION_TABLE_OFFSET
|
||||
mov bx, ax ; offset to part table
|
||||
|
||||
mov cx, 4 ; only checking 4 entries
|
||||
mov si, PartEntry_t.attributes
|
||||
|
||||
.find_active_L0:
|
||||
mov al, byte [bx + si]
|
||||
test al, 0x80 ; 0x80 == 1000_0000b
|
||||
je ReadVbrData.active_found
|
||||
mov al, [bx + PartEntry_t.attributes]
|
||||
cmp al, 0x80 ; 0x80 == 1000_0000b
|
||||
je ReadVbrData.check_fstype
|
||||
add bx, PartEntry_t_size ; next part entry's attributes
|
||||
loop ReadVbrData.find_active_L0
|
||||
jmp ReadVbrData.error_noactive
|
||||
.active_found:
|
||||
.check_fstype:
|
||||
; check for part_type = 0x0C (DOS 7.1+/W95 FAT32 w/ LBA) or 0x1C (Hidden 0x0C)
|
||||
__BOCHS_MAGIC_DEBUG
|
||||
mov al, [bx + PartEntry_t.part_type]
|
||||
cmp al, 0x0C
|
||||
je ReadVbrData.active_ok
|
||||
; *or*
|
||||
cmp al, 0x1C
|
||||
je ReadVbrData.active_ok
|
||||
|
||||
jmp ReadVbrData.error_badparttype ; error if part_type != 0x1C or 0x0C
|
||||
.active_ok:
|
||||
movzx ax, byte [bp + 4]
|
||||
push ax ; drive_num (2)
|
||||
push 0x01 ; count (2)
|
||||
@@ -257,18 +267,33 @@ ReadVbrData:
|
||||
mov bx, [bp + 6]
|
||||
cmp word [bx + 0x1FE], 0xAA55 ; check for bytes at end
|
||||
jne ReadVbrData.error_nosign
|
||||
.check_FAT_size:
|
||||
test word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotSectors16 will not be set if FAT32
|
||||
jnz ReadVbrData.error_badfatfs
|
||||
.check_FAT_sanity:
|
||||
; we only quickly validate that this is *probably* a FAT32 volume
|
||||
|
||||
add bx, 11 ; point bx at start of bpb (skip jmp code and ident)
|
||||
cmp word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotalSectors16 should be 0 (use TotalSectors32 in bpb)
|
||||
jne ReadVbrData.error_totsectors
|
||||
|
||||
cmp word [bx + FAT32_bpb_t.u16_FATSize16], 0 ; FatSize16 will be 0 if FAT32 (use FATSize32 in ebpb)
|
||||
jne ReadVbrData.error_fatsz
|
||||
|
||||
cmp word [bx + FAT32_bpb_t.u16_RootEntryCount16], 0 ; root dir info is in data clusters on fat32
|
||||
jne ReadVbrData.error_rootdir
|
||||
.endp:
|
||||
__CDECL16_PROC_EXIT
|
||||
ret
|
||||
.error_noactive:
|
||||
ERROR STAGE2_ERROR_BAD_VBR
|
||||
ERROR STAGE2_VBR_E_ACTIVE
|
||||
.error_nosign:
|
||||
ERROR STAGE2_ERROR_BAD_VBR
|
||||
.error_badfatfs:
|
||||
ERROR STAGE2_ERROR_BAD_VBR
|
||||
ERROR STAGE2_VBR_E_SIGN
|
||||
.error_totsectors:
|
||||
ERROR STAGE2_VBR_E_TOT
|
||||
.error_fatsz:
|
||||
ERROR STAGE2_VBR_E_FATSZ
|
||||
.error_rootdir:
|
||||
ERROR STAGE2_VBR_E_DIRENT
|
||||
.error_badparttype:
|
||||
ERROR STAGE2_VBR_E_PARTTYPE
|
||||
|
||||
; set ds and es segments back to the base of the loader
|
||||
%ifnmacro __TINY_DS_ES
|
||||
|
||||
Reference in New Issue
Block a user