Skip to content

Commit

Permalink
Fix EXT2
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Sploit committed Jan 16, 2023
1 parent 7171249 commit 63eefc9
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
Binary file modified build/fs/ata.c.o
Binary file not shown.
Binary file modified build/fs/ext2.c.o
Binary file not shown.
Binary file modified build/iso/boot/kernel.elf
Binary file not shown.
Binary file modified build/kernel/init.c.o
Binary file not shown.
Binary file modified build/quantumos.iso
Binary file not shown.
2 changes: 0 additions & 2 deletions drivers/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <sys/memory.h>
#include <sys/pio.h>

#define DEBUG

void debug_putc(char c)
{
pio_outb(DEBUG_PORT, c);
Expand Down
Binary file modified ext2.img
Binary file not shown.
12 changes: 9 additions & 3 deletions fs/ata.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <core/string.h>

#include <sys/pio.h>
#include <sys/isr.h>
#include <sys/idt.h>

#include <fs/ata.h>

Expand Down Expand Up @@ -570,8 +572,6 @@ void ata_initialize(unsigned short __prim_base, unsigned short __prim_control,
if (__ata_devices[i].__reserved == 1)
{
quantum_info(0, " ATA\t", "Drive [%d] is online!", __ata_devices[i].__drive);
// #define ATA_DEBUG
#ifdef ATA_DEBUG
quantum_info(0, " ATA\t", "Model: [%s]", __ata_devices[i].__model);
quantum_info(0, " ATA\t", "Type: [%s]", (const char *[]) {"ATA", "ATAPI"}[__ata_devices[i].__type]);
quantum_info(0, " ATA\t", "Drive: [%d]", __ata_devices[i].__drive);
Expand All @@ -581,7 +581,6 @@ void ata_initialize(unsigned short __prim_base, unsigned short __prim_control,
quantum_info(0, " ATA\t", "Size: [%d] sectors | [%d] bytes", __ata_devices[i].__size, __ata_devices[i].__size * ATA_SECTOR_SIZE);
quantum_info(0, " ATA\t", "Signature: [0x%x]", __ata_devices[i].__signature);
quantum_info(0, " ATA\t", "Features: [%d]\n", __ata_devices[i].__features);
#endif
}
}
}
Expand Down Expand Up @@ -659,3 +658,10 @@ int ata_write_sectors(unsigned char __drive, unsigned char __nsectors, unsigned
return 0;
}

void ata_irq_handler(__registers_t *__regs)
{
pio_inb(__ata_channels[0].__no_intr);
pio_inb(__ata_channels[0].__bm_ide);

pio_outb(__ata_channels[0].__base, 0x00);
}
12 changes: 5 additions & 7 deletions fs/ext2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
#include <quantum/init.h>
#include <sys/memory.h>

void ext2_superblock_read(ext2_superblock_t* ext2_superblock)
{
ata_read_sectors(1, 2, 1, (unsigned int *)(ext2_superblock));
//ata_read_sectors(1, 3, 1, (unsigned int*)(ext2_superblock + 512));
}
static ext2_superblock_t* ext2_superblock;

void quantum_ext2_init()
{
ext2_superblock_t* ext2_superblock = (ext2_superblock_t*) kmalloc(sizeof(ext2_superblock_t *));
/* Allocate space */

unsigned int *__superblock_buffer = kmalloc(sizeof(*__superblock_buffer));

ext2_superblock_read(ext2_superblock);
ata_read_sectors(HARDDISK, 1, 2, (unsigned int *) ext2_superblock);

quantum_info(0, " Ext2 ", "Ext2 superblock info:");
quantum_info(0, " Ext2 ", "\tTotal inodes: %d", ext2_superblock->total_inodes);
Expand Down
6 changes: 4 additions & 2 deletions include/fs/ext2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef EXT2_H
#define EXT2_H

#define HARDDISK 0

#define EXT2_MAGIC 0xEF53

#define EXT2_CREATOR_ID_LINUX 0
Expand All @@ -12,7 +14,7 @@
typedef struct ext2_superblock_t {
unsigned int total_inodes;
unsigned int total_blocks;
unsigned int number_of_blocks;
unsigned int reserved_blocks;
unsigned int unallocated_blocks;
unsigned int unallocated_inodes;
unsigned int block_number;
Expand All @@ -35,7 +37,7 @@ typedef struct ext2_superblock_t {
unsigned int rev_level;
unsigned short def_resuid;
unsigned short def_resgid;
} ext2_superblock_t;
} __attribute__((packed)) ext2_superblock_t;

void ext2_superblock_read();

Expand Down
2 changes: 1 addition & 1 deletion kernel/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int quantum_get_kernel_mmap(KERNEL_MEMORY_MAP *__map, multiboot_info_t *__mboot)
return -1;
}

#define DEBUG
//#define DEBUG

void quantum_info(int __status, char* header, char* format, ...)
{
Expand Down

0 comments on commit 63eefc9

Please sign in to comment.