diff options
author | Marvin Borner | 2021-04-10 00:26:39 +0200 |
---|---|---|
committer | Marvin Borner | 2021-04-10 00:26:39 +0200 |
commit | 9655593d80e23d2ea3c091e3187e8e47b278bc3d (patch) | |
tree | f618723fd9d457147f4663d2d4990f69fabb2d48 /kernel/drivers | |
parent | eeb88df1d501ccec4737c18dddb7ca0a1176304f (diff) |
Gave procs own kernel stack (TSS)
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/cpu.c | 13 | ||||
-rw-r--r-- | kernel/drivers/ide.c | 20 |
2 files changed, 28 insertions, 5 deletions
diff --git a/kernel/drivers/cpu.c b/kernel/drivers/cpu.c index 5d53bef..62b0328 100644 --- a/kernel/drivers/cpu.c +++ b/kernel/drivers/cpu.c @@ -91,6 +91,19 @@ void fpu_restore(void) __asm__ volatile("fxrstor (%0)" ::"r"(fpu_state)); } +PROTECTED extern u32 tss_entry; +void tss_set_stack(u32 ss, u32 esp) +{ + assert(tss_entry && ss && esp); + struct { + u32 prev; + u32 esp0; + u32 ss0; + } *tss = (void *)tss_entry; + tss->esp0 = esp; + tss->ss0 = ss; +} + CLEAR static struct cpuid cpuid(u32 code) { u32 a, b, c, d; diff --git a/kernel/drivers/ide.c b/kernel/drivers/ide.c index f19fe4d..408630d 100644 --- a/kernel/drivers/ide.c +++ b/kernel/drivers/ide.c @@ -6,7 +6,9 @@ #include <fs.h> #include <ide.h> #include <mem.h> +#include <pci.h> #include <print.h> +#include <str.h> PROTECTED static u8 *ide_buf = NULL; @@ -130,11 +132,9 @@ CLEAR static void ata_probe(void) struct ata_data *data = malloc(sizeof(*data)); data->drive = (bus << 1) | drive; - char *str = malloc(40); - for (int j = 0; j < 40; j += 2) { - str[j] = ide_buf[ATA_IDENT_MODEL + j + 1]; - str[j + 1] = ide_buf[ATA_IDENT_MODEL + j]; - } + char *str = zalloc(8); + strlcpy(str, "hd", 8); + str[2] = 'a' + i; dev->name = str; dev->type = DEV_BLOCK; @@ -156,8 +156,18 @@ CLEAR static void ata_probe(void) } } +CLEAR static void ata_find(u32 device, u16 vendor_id, u16 device_id, void *extra) +{ + if ((vendor_id == 0x8086) && (device_id == 0x7010)) { + *((u32 *)extra) = device; + } +} + +static u32 ata_device_pci = 0; CLEAR void ata_install(void) { + pci_scan(&ata_find, -1, &ata_device_pci); + assert(ata_device_pci); ide_buf = zalloc(SECTOR_SIZE); ata_probe(); } |