diff options
| author | Alejandro Sior <aho@sior.be> | 2022-05-21 14:04:42 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-05-21 14:04:42 +0200 |
| commit | 3aefeeb723b8822916fb39b7c32551c35c06e32f (patch) | |
| tree | 380494fb2184101961e395d6d81accf91138efbe | |
| parent | 35c9df451d4f415632a4a1f64b06d1de12340687 (diff) | |
boot: reorganize bios and drive modules
| -rw-r--r-- | bios/README | 2 | ||||
| -rw-r--r-- | bios/bios.ha | 13 | ||||
| -rw-r--r-- | bios/boot.ha | 12 | ||||
| -rw-r--r-- | bios/drive/+x86_64/drive.s | 7 | ||||
| -rw-r--r-- | drive/+bios/drive.ha (renamed from bios/drive/drive.ha) | 2 | ||||
| -rw-r--r-- | drive/README | 4 | ||||
| -rw-r--r-- | drive/drive.ha | 21 | ||||
| -rw-r--r-- | drive/errors.ha | 1 | ||||
| -rw-r--r-- | main.ha | 4 | ||||
| -rwxr-xr-x | run.sh | 2 |
10 files changed, 21 insertions, 47 deletions
diff --git a/bios/README b/bios/README new file mode 100644 index 0000000..1aa7f47 --- /dev/null +++ b/bios/README @@ -0,0 +1,2 @@ +bios is a facility to raise BIOS interrupts from long-mode and declares important boot constants. +It serves as a backend for various interface implementations.
\ No newline at end of file diff --git a/bios/bios.ha b/bios/bios.ha index 5a3c1aa..caaa37f 100644 --- a/bios/bios.ha +++ b/bios/bios.ha @@ -13,19 +13,6 @@ export type state = struct { // The set real mode registers export let regs: state; -// The address of a 512 bytes workspace that is located below 0xFFFFF and can be used to store the results -// of various bios calls -export const @symbol("_ws") ws: [4096]u8; - -// The boot drive number as given by the BIOS at boot time -export const @symbol("drive_no") drive_number: u8; - -// The amount of sectors per track that the boot drive has -export const @symbol("drive_spt") drive_sectors_per_track: u8; - -// The amount of heads that the boot drive has -export const @symbol("drive_heads") drive_heads: u8; - // Clears the BIOS mode registers export fn clearregs() void = { regs = state { diff --git a/bios/boot.ha b/bios/boot.ha new file mode 100644 index 0000000..e165f5a --- /dev/null +++ b/bios/boot.ha @@ -0,0 +1,12 @@ +// Address of a 4096 bytes workspace that is located below 0xFFFFF and can be used to store the results +// of various bios calls +export const @symbol("_ws") ws: [4096]u8; + +// Boot drive number as given by the BIOS at boot time +export const @symbol("drive_no") drive_number: u8; + +// Amount of sectors per track that the boot drive has +export const @symbol("drive_spt") drive_sectors_per_track: u8; + +// Amount of heads that the boot drive has +export const @symbol("drive_heads") drive_heads: u8; diff --git a/bios/drive/+x86_64/drive.s b/bios/drive/+x86_64/drive.s deleted file mode 100644 index 1f3828e..0000000 --- a/bios/drive/+x86_64/drive.s +++ /dev/null @@ -1,7 +0,0 @@ -.code16 - -.globl bios.drive.read -bios.drive.read: - mov $0x2, %ah - int $0x13 - ret diff --git a/bios/drive/drive.ha b/drive/+bios/drive.ha index a2992b8..da33740 100644 --- a/bios/drive/drive.ha +++ b/drive/+bios/drive.ha @@ -2,8 +2,6 @@ use bios; def sector_size: u32 = 512; -export type error = !void; - // Converts lba to the CHS format fn lbatochs(lba: u32) (u16, u16, u16) = { const temp = lba / bios::drive_sectors_per_track; diff --git a/drive/README b/drive/README new file mode 100644 index 0000000..cd7a6f8 --- /dev/null +++ b/drive/README @@ -0,0 +1,4 @@ +drive contains various implementations of the drive reading interface + +Currently, it supports: + - BIOS (via the bios module).
\ No newline at end of file diff --git a/drive/drive.ha b/drive/drive.ha deleted file mode 100644 index 259e7f5..0000000 --- a/drive/drive.ha +++ /dev/null @@ -1,21 +0,0 @@ -use bios; -use bios::drive; - -fn lba_to_chs(lba: u16) (u16, u16, u16) = { - //let temp = lba / bios::drive::drive_spt; - //let sector = (lba % bios::drive::drive_spt) + 1; - //let head = temp % bios::drive::drive_heads; - //let cylinder = temp / bios::drive::drive_heads; - - //return (cylinder, head, sector); - return (0, 0, 0); -}; - -export fn read(sector: u16, dest: uintptr) void = { - let chs = lba_to_chs(sector); - - //bios::regs.eax = 1 | 0x2 << 8; - //bios::regs.ebx = ws; - //bios::regs.ecx = chs.2 | chs.0 << 8; - //bios::regs.edx = bios::drive::drive_no | chs.1 << 8; -}; diff --git a/drive/errors.ha b/drive/errors.ha new file mode 100644 index 0000000..58742fb --- /dev/null +++ b/drive/errors.ha @@ -0,0 +1 @@ +export type error = !void; @@ -2,7 +2,6 @@ use vga; use term; use rt; use bios; -use bios::drive; use drive; export fn main() void = { @@ -15,9 +14,8 @@ export fn main() void = { term::print(&text, "a"); }; - //bios::drive::read(0, 512, bios::ws: uintptr); let dest = 0x100000: uintptr: *[*]u8; - bios::drive::read(0, 512, dest)!; + drive::read(0, 512, dest)!; if (dest[511] == 0xaa) { term::print(&text, "\nnice!"); }; @@ -9,7 +9,7 @@ export HAREPATH=. export LDFLAGS="--gc-sections" # :Do the build -hare build -X^ -T+x86_64 +hare build -X^ -T+x86_64 -T+bios # :Create a flat binary out of the elf file # (while also removing the breaking gnu note) |
