Skip to content
Merged

Ext2 #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,12 @@ index: cscope.files
ctags --C-kinds=+pxzL -L $<
cscope -b -q -i $<

.PHONY: clean-full
clean-full: clean
-rm -rdf userland/mlibc/

.PHONY: clean
clean:
$(MAKE) -C userland clean
-rm -rd $(OBJ_DIR)/ tags cscope.*

.PHONY: test-all
Expand Down Expand Up @@ -133,6 +136,7 @@ $(USERLAND_TARGETS): userland

$(TEST_TARGETS): test

.PHONY: $(TEST_EXEC)
$(TEST_EXEC): %: %.a $(OBJ_DIR)/boot.a $(OBJ_DIR)/kernel.a $(OBJ_DIR)/drivers.a
$(CC) -g -O0 -std=c23 $(CWARN) -fuse-ld=lld -o $@ $^

Expand Down
12 changes: 6 additions & 6 deletions boot/multiboot2/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct mb2_tag_t {

struct {
struct acpi_rsdp_t rsdp;
} __attribute__((packed)) rsdpv2;
} rsdpv2;

#ifdef GRAPHICSBASE
struct {
Expand All @@ -91,8 +91,8 @@ struct mb2_tag_t {
uint8_t framebuffer_green_mask_size;
uint8_t framebuffer_blue_field_position;
uint8_t framebuffer_blue_mask_size;
} __attribute__((packed)) rgb;
} __attribute__((packed)) color_info;
} rgb;
} color_info;
} __attribute__((packed)) framebuffer;
#endif /* GRAPHICSBASE */
} tag;
Expand All @@ -101,11 +101,11 @@ struct mb2_tag_t {
struct mb2_info_t {
const uint32_t total_size;
const uint32_t reserved;
} __attribute__((packed)) header;
} __attribute__((packed));

extern volatile struct gdt_t gdt[GDT_NUM_ENTRIES];
extern struct gdt_t gdt[GDT_NUM_ENTRIES];

static volatile struct mb2_tag_t* memmap_tag;
static struct mb2_tag_t* memmap_tag;

extern uint64_t init_stack_paddr;
extern uint64_t init_stack_vaddr;
Expand Down
26 changes: 16 additions & 10 deletions drivers/ahci/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ static enum disk_error_t ahci_read_lba(void* cntx, void* buffer, uint64_t lba, u


while (hba_read(ahci, PXTFD_OFF(port)) & TFD_STS_CON_MASK) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);
}

hba_write(ahci, PXCI_OFF(port), 1u << slot);

while (hba_read(ahci, PXCI_OFF(port)) & (1u << slot)) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);

if (hba_read(ahci, PXIS_OFF(port)) & IS_TFES) {
logging_log_error("AHCI error while reading");
Expand Down Expand Up @@ -381,13 +381,13 @@ static enum disk_error_t ahci_write_lba(void* cntx, void* buffer, uint64_t lba,


while (hba_read(ahci, PXTFD_OFF(port)) & TFD_STS_CON_MASK) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);
}

hba_write(ahci, PXCI_OFF(port), 1u << slot);

while (hba_read(ahci, PXCI_OFF(port)) & (1u << slot)) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);

if (hba_read(ahci, PXIS_OFF(port)) & IS_TFES) {
logging_log_error("AHCI error while reading");
Expand Down Expand Up @@ -462,13 +462,13 @@ static enum disk_error_t ahci_flush_cache(void* cntx) {
ahci->ports[port]->com_list[slot].ctba_u0 = 0;

while (hba_read(ahci, PXTFD_OFF(port)) & TFD_STS_CON_MASK) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);
}

hba_write(ahci, PXCI_OFF(port), 1u << slot);

while (hba_read(ahci, PXCI_OFF(port)) & (1u << slot)) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);

if (hba_read(ahci, PXIS_OFF(port)) & IS_TFES) {
logging_log_error("AHCI flush cache error");
Expand All @@ -494,7 +494,7 @@ static enum disk_error_t ahci_flush_cache(void* cntx) {
static void port_identify(struct ahci_t* ahci, uint32_t port) {
uint8_t slot;
uint32_t paddr_identity;
volatile uint16_t* identity;
uint16_t* identity;
uint8_t model[41];

paddr_identity = (uint32_t)mm_alloc_pmax(PAGE_SIZE_4K, 0, ~0u);
Expand All @@ -515,12 +515,18 @@ static void port_identify(struct ahci_t* ahci, uint32_t port) {

lock_acquire(&ahci->lock);
slot = find_slot(ahci, port);

if (slot == SLOT_NO_SLOT) {
logging_log_error("No available slots for identification");
panic(PANIC_STATE);
}

ahci->used_com |= 1u << slot;
lock_release(&ahci->lock);

kmemset(&ahci->ports[port]->com_list[slot], 0, sizeof(struct ahci_command_header_t));
kmemset(ahci->com_tables_v[slot], 0, PAGE_SIZE_4K);
kmemset((void*)identity, 0, PAGE_SIZE_4K);
kmemset(identity, 0, PAGE_SIZE_4K);

ahci->com_tables_v[slot]->prdt[0].dba = paddr_identity;
ahci->com_tables_v[slot]->prdt[0].dbau = 0;
Expand All @@ -542,13 +548,13 @@ static void port_identify(struct ahci_t* ahci, uint32_t port) {
ahci->ports[port]->com_list[slot].ctba_u0 = 0;

while (hba_read(ahci, PXTFD_OFF(port)) & TFD_STS_CON_MASK) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);
}

hba_write(ahci, PXCI_OFF(port), 1u << slot);

while (hba_read(ahci, PXCI_OFF(port)) & (1u << slot)) {
time_busy_wait(10 * TIME_CONV_MS_TO_NS);
time_busy_wait(100);
}

lock_release(&ahci->ports[port]->lock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/disk/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct disk_t {
struct disk_t* next;
};

uint8_t disk_lock;
static uint8_t disk_lock;

static struct disk_t* disk_list;
static uint64_t disk_id;
Expand Down
Loading
Loading