Skip to content

Add FileIO::write to ATA#772

Merged
vinc merged 4 commits intotrunkfrom
feature/ata-io-write
Aug 27, 2025
Merged

Add FileIO::write to ATA#772
vinc merged 4 commits intotrunkfrom
feature/ata-io-write

Conversation

@vinc
Copy link
Owner

@vinc vinc commented Aug 25, 2025

Allow users to write sectors to hard drives directly via the device files in /dev/ata

@vinc
Copy link
Owner Author

vinc commented Aug 25, 2025

For a long time I wanted to try to copy the bootloader from memory at 0x7C00 and the kernel at 0x400000 and see if I could get a working boot image with it, but a few bits differs. We can get them elsewhere, for example we can find 31 C0 at 0xB420 to replace the first two bytes of the first sector of the loader (that are 00 00 in memory), this make the OS boot pretty far but not without issues.

> memory dump 0xB420 2 > /ini/kernel.img          # 0x31C0
> memory dump 0x7C02 53246 >> /ini/kernel.img     # Loader
> memory dump 0x400000 2244608 >> /ini/kernel.img # Kernel
> read /ini/kernel.img > /dev/ata/0/1
> disk format /dev/ata/0/1

Now that large downloads are possible it's going to be easier to just download an image of the kernel from the network instead of trying to rebuild it from memory.

@vinc
Copy link
Owner Author

vinc commented Aug 25, 2025

The kernel image is a bit too large to be downloaded directly so #773 will add zlib support to download a compressed version.

@vinc
Copy link
Owner Author

vinc commented Aug 26, 2025

Now we can do this to install the loader and the kernel image at the beginning of the disk:

> pkg install kernel
> read /ini/kernel.img > /dev/ata/0/0

@vinc
Copy link
Owner Author

vinc commented Aug 26, 2025

We could add a zero program or script that would continuously output 0 to stdin until interrupted to replace disk erase /dev/ata/0/0 with zero => /dev/ata/0/0.

We could also do print /dev/random => /dev/ata/0/0 but each buffer written to stdin should be a multiple of 512 bytes in length.

@vinc vinc marked this pull request as ready for review August 27, 2025 07:14
@vinc vinc merged commit 609f83c into trunk Aug 27, 2025
1 check passed
@vinc vinc deleted the feature/ata-io-write branch August 27, 2025 07:14
@vinc vinc mentioned this pull request Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant