working on types and eisa bus driver

This commit is contained in:
Gregory Kenneth Bowne 2023-07-19 23:31:54 -07:00
parent 79a27d232c
commit c4749319be
5 changed files with 58 additions and 12 deletions

View File

@ -22,7 +22,36 @@ void eisa_init()
// Detect and configure EISA devices // Detect and configure EISA devices
void eisa_detect_devices() void eisa_detect_devices()
{ {
// Add any necessary device detection and configuration code here uint32_t bus, slot, func;
uint16_t vendor_id, device_id, class_code;
for (bus = 0; bus < 256; bus++)
{
for (slot = 0; slot < 32; slot++)
{
for (func = 0; func < 8; func++)
{
uint32_t address = (bus << 16) | (slot << 11) | (func << 8);
uint32_t id = eisa_read_config_dword(address, 0);
vendor_id = id & 0xFFFF;
device_id = (id >> 16) & 0xFFFF;
class_code = eisa_read_config_word(address, 10);
if (vendor_id != 0xFFFF)
{
// Device detected, do something with it
if (vendor_id == MY_DEVICE_VENDOR_ID &&
device_id == MY_DEVICE_DEVICE_ID &&
class_code == MY_DEVICE_CLASS_CODE)
{
// This is my device, configure it
uint32_t config1 = eisa_read_config_dword(address, 4);
uint32_t config2 = eisa_read_config_dword(address, 8);
// Do something with the configuration data
}
}
}
}
}
} }
// Read from an EISA device // Read from an EISA device

View File

@ -4,12 +4,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "../display.h" #include "../display/display.h"
#include "../interrupts.h"
#include "../io/io.h" #include "../io/io.h"
#include "../keyboard.h" #include "../keyboard/keyboard.h"
#include "../screen/screen.h"
#include "../string.h" #include "../string.h"
#include "./screen/screen.h"
#include "./tty.h" #include "./tty.h"

View File

@ -0,0 +1,18 @@
#include "./types.h"
void gdt_set_entry(gdt_entry_t *entry, uint32_t base, uint32_t limit,
uint16_t flags)
{
entry->base = base;
entry->limit = limit;
entry->flags = flags;
}
void idt_set_entry(idt_entry_t *entry, uint32_t base, uint16_t selector,
uint16_t flags)
{
entry->base_low = base & 0xFFFF;
entry->base_high = (base >> 16) & 0xFFFF;
entry->selector = selector;
entry->flags = flags;
}

View File

@ -14,11 +14,11 @@ typedef struct
typedef struct typedef struct
{ {
uint16_t base_lo; // Lower 16 bits of handler function address uint16_t base_low;
uint16_t selector; // Kernel segment selector uint16_t selector;
uint8_t always0; // Always 0 uint8_t zero;
uint8_t flags; // Flags uint8_t flags;
uint16_t base_hi; // Upper 16 bits of handler function address uint16_t base_high;
} idt_entry_t; } __attribute__((packed)) idt_entry_t;
#endif /* TYPES_H */ #endif /* TYPES_H */

View File

@ -16,7 +16,7 @@ struct isr_regs
}; };
// Register an ISR // Register an ISR
void isr_register(uint8_t num, void (*handler)(void)); void isr_register(uint8_t num, void (*handler)(struct isr_regs *regs));
// ISR handler // ISR handler
void isr_handler(struct isr_regs *regs); void isr_handler(struct isr_regs *regs);