diff options
author | Marvin Borner | 2020-04-15 21:17:41 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-15 21:17:41 +0200 |
commit | e07894d21a0101b10ee6ad851773b725cbb9150d (patch) | |
tree | 75631b318a9403395fbb3b40abdade8a475cd30b /src/kernel/fs | |
parent | aa3d1b4689e6dadd982fe1e5ca8af69ca39c617d (diff) |
Used macro magic to implement function-based logs
Diffstat (limited to 'src/kernel/fs')
-rw-r--r-- | src/kernel/fs/ata.c | 11 | ||||
-rw-r--r-- | src/kernel/fs/ata.h | 2 | ||||
-rw-r--r-- | src/kernel/fs/elf.c | 2 | ||||
-rw-r--r-- | src/kernel/fs/ext2/ext2.c | 14 | ||||
-rw-r--r-- | src/kernel/fs/load.c | 4 | ||||
-rw-r--r-- | src/kernel/fs/vfs/vfs.c | 10 |
6 files changed, 19 insertions, 24 deletions
diff --git a/src/kernel/fs/ata.c b/src/kernel/fs/ata.c index 52d1040..952261f 100644 --- a/src/kernel/fs/ata.c +++ b/src/kernel/fs/ata.c @@ -3,6 +3,7 @@ #include <kernel/fs/ata.h> #include <kernel/lib/lib.h> #include <kernel/lib/stdlib.h> +#include <kernel/lib/stdio.h> #include <kernel/memory/alloc.h> #include <kernel/pci/pci.h> #include <kernel/interrupts/interrupts.h> @@ -239,14 +240,14 @@ void ata_device_detect(ata_dev_t *dev, int primary) outb(dev->command, COMMAND_IDENTIFY); if (!inb(dev->status)) { - log("ata_detect_device: device does not exist"); + log("Device does not exist"); return; } uint8_t lba_lo = inb(dev->lba_lo); uint8_t lba_hi = inb(dev->lba_high); if (lba_lo != 0 || lba_hi != 0) { - log("ata_detect_device: not ata device"); + log("Device is not ata-compatible"); return; } uint8_t drq = 0, err = 0; @@ -255,7 +256,7 @@ void ata_device_detect(ata_dev_t *dev, int primary) err = inb(dev->status) & STATUS_ERR; } if (err) { - log("ata_detect_device: err when polling"); + log("Error while polling"); return; } @@ -268,6 +269,7 @@ void ata_device_detect(ata_dev_t *dev, int primary) pci_write_field(ata_device, PCI_COMMAND, pci_command_reg); } + log("Detected drive: %d", dev->drive); vfs_mount(dev->mountpoint, create_ata_device(dev)); } @@ -279,7 +281,10 @@ void ata_find(uint32_t device, uint16_t vendor_id, uint16_t device_id, void *ext void ata_init() { + log("0x%x", ata_device); pci_scan(&ata_find, -1, &ata_device); + serial_printf("0x%x - ", ata_device); + log("0x%x", ata_device); irq_install_handler(32 + 14, ata_handler); diff --git a/src/kernel/fs/ata.h b/src/kernel/fs/ata.h index 049f2bf..72ded20 100644 --- a/src/kernel/fs/ata.h +++ b/src/kernel/fs/ata.h @@ -116,4 +116,4 @@ void ata_device_detect(ata_dev_t *dev, int primary); void ata_init(); -#endif +#endif
\ No newline at end of file diff --git a/src/kernel/fs/elf.c b/src/kernel/fs/elf.c index 9af3636..b6d90c9 100644 --- a/src/kernel/fs/elf.c +++ b/src/kernel/fs/elf.c @@ -14,7 +14,7 @@ int is_elf(char *elf_data) elf_header_t *header = (elf_header_t *)elf_data; if (header->ident[0] == 0x7f && header->ident[1] == 'E' && header->ident[2] == 'L' && header->ident[3] == 'F') { - serial_printf("Buffer is valid ELF file!"); + log("Buffer is valid ELF file!"); return 1; } return 0; diff --git a/src/kernel/fs/ext2/ext2.c b/src/kernel/fs/ext2/ext2.c index fe45547..5fcc929 100644 --- a/src/kernel/fs/ext2/ext2.c +++ b/src/kernel/fs/ext2/ext2.c @@ -769,29 +769,21 @@ void ext2_init(char *device_path, char *mountpoint) ext2fs->blocks_per_group = ext2fs->sb->blocks_per_group; ext2fs->inodes_per_group = ext2fs->sb->inodes_per_group; - ext2fs->total_groups = ext2fs->sb->total_blocks / ext2fs->blocks_per_group; // REMEMBER: Zero Division Exception - log("9"); + ext2fs->total_groups = ext2fs->sb->total_blocks / + ext2fs->blocks_per_group; // REMEMBER: Zero Division Exception if (ext2fs->blocks_per_group * ext2fs->total_groups < ext2fs->total_groups) ext2fs->total_groups++; - log("10"); ext2fs->bgd_blocks = (ext2fs->total_groups * sizeof(bgd_t)) / ext2fs->block_size; - log("11"); if (ext2fs->bgd_blocks * ext2fs->block_size < ext2fs->total_groups * sizeof(bgd_t)) ext2fs->bgd_blocks++; - log("12"); ext2fs->bgds = kcalloc(sizeof(bgd_t), ext2fs->bgd_blocks * ext2fs->block_size); - log("13"); for (uint32_t i = 0; i < ext2fs->bgd_blocks; i++) { read_disk_block(ext2fs, 2, (void *)ext2fs->bgds + i * ext2fs->block_size); } - log("14"); inode_t *root_inode = kcalloc(sizeof(inode_t), 1); - log("15"); read_inode_metadata(ext2fs, root_inode, ROOT_INODE_NUMBER); - log("16"); vfs_mount(mountpoint, get_ext2_root(ext2fs, root_inode)); - log("17"); -} +}
\ No newline at end of file diff --git a/src/kernel/fs/load.c b/src/kernel/fs/load.c index ad76c5b..0206401 100644 --- a/src/kernel/fs/load.c +++ b/src/kernel/fs/load.c @@ -28,10 +28,10 @@ void load_binaries() kfree(user_e); if (font->magic != 0xf0f0f0f0) { - serial_printf("0x%x: WRONG FONT MAGIC!", font->magic); + log("0x%x: WRONG FONT MAGIC!", font->magic); halt_loop(); } */ } vga_log("Successfully loaded binaries"); -} +}
\ No newline at end of file diff --git a/src/kernel/fs/vfs/vfs.c b/src/kernel/fs/vfs/vfs.c index bbc3912..10d3c21 100644 --- a/src/kernel/fs/vfs/vfs.c +++ b/src/kernel/fs/vfs/vfs.c @@ -22,7 +22,7 @@ void vfs_db_listdir(char *name) { vfs_node_t *n = file_open(name, 0); if (!n) { - log("Could not list a directory that does not exist\n"); + log("Could not list a directory that does not exist"); return; } if (!n->listdir) @@ -35,7 +35,6 @@ void vfs_db_listdir(char *name) files++; } kfree(save); - log("\n"); } void print_vfstree_recur(gtreenode_t *node, int parent_offset) @@ -48,12 +47,11 @@ void print_vfstree_recur(gtreenode_t *node, int parent_offset) for (int i = 0; i < parent_offset; ++i) { strcat(tmp, " "); } - char *curr = tmp + strlen(tmp); struct vfs_entry *fnode = (struct vfs_entry *)node->value; if (fnode->file) { - log(curr, "%s(0x%x, %s)", fnode->name, (uint32_t)fnode->file, fnode->file->name); + log("%s(0x%x, %s)", fnode->name, (uint32_t)fnode->file, fnode->file->name); } else { - log(curr, "%s(empty)", fnode->name); + log("%s(empty)", fnode->name); } log("%s\n", tmp); len = strlen(fnode->name); @@ -368,4 +366,4 @@ void vfs_mount(char *path, vfs_node_t *fs_obj) return; } vfs_mount_recur(path + 1, vfs_tree->root, fs_obj); -}
\ No newline at end of file +} |