diff options
author | Marvin Borner | 2019-11-20 22:17:48 +0100 |
---|---|---|
committer | Marvin Borner | 2019-11-20 22:28:30 +0100 |
commit | 0ba991750314310a5e53b0d8135aef5b1352b261 (patch) | |
tree | acae7106a24b85116cd7119bd239c3d9299f2ba8 /src/kernel/fs/marfs/disklevel.c | |
parent | 6ca5f1bcec7f0716bad5e1cdd38d41be137fe7e5 (diff) |
Began two-stage hdd bootloader and os installer
Diffstat (limited to 'src/kernel/fs/marfs/disklevel.c')
-rw-r--r-- | src/kernel/fs/marfs/disklevel.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/kernel/fs/marfs/disklevel.c b/src/kernel/fs/marfs/disklevel.c new file mode 100644 index 0000000..b6fc8c2 --- /dev/null +++ b/src/kernel/fs/marfs/disklevel.c @@ -0,0 +1,23 @@ +#include <stdint.h> +#include <kernel/fs/ata_pio.h> +#include "marfs.h" + +void marfs_format(void) { + // Create superblock + struct marfs_SUPERBLOCK sb; + sb.signature = 0x1083B99F34B59645; // Huh, magic?! + sb.n_inodes = (marfs_get_max_lba() - 2) >> 5; + sb.n_chunks = (marfs_get_max_lba() - (2 + sb.n_inodes)) >> 9; + sb.n_first_unallocated_inode = 0; + sb.s_first_inode = 2; + sb.s_first_chunk = 2 + sb.n_inodes; + + // Write to disk + marfs_writeSB(&sb); + + // Initialize the inodes + for (uint32_t i = 0; i < sb.n_inodes; i++) ATA_clear28(iface, 2 + i); + + // Initialize the chunks + for (uint32_t i = 0; i < sb.n_chunks; i++) ATA_clear28(iface, sb.s_first_chunk + i * 512); +} |