Unverified Commit d9aaf39e authored by PhoeniX's avatar PhoeniX

Add per-process I/O bitmap support

parent aa586c9d
Pipeline #1842 passed with stages
in 34 seconds
......@@ -151,7 +151,7 @@ class Interrupts {
static Handler* handlers;
static REC64 *idt;
static GDT *gdt;
static TSS64_ENT *tss;
static TSS64_ENT **tss;
static void init();
static uint64_t handle(uint8_t intr, uint64_t stack, uint64_t *cr3);
......
......@@ -26,7 +26,7 @@ struct Interrupts::Handler {
Interrupts::REC64 *Interrupts::idt = 0;
GDT *Interrupts::gdt = 0;
TSS64_ENT *Interrupts::tss = 0;
TSS64_ENT **Interrupts::tss = 0;
List<Interrupts::Callback*> *Interrupts::callbacks;
Mutex Interrupts::callback_locks[256];
Mutex Interrupts::fault;
......@@ -293,7 +293,7 @@ void Interrupts::init() {
uint64_t ncpu = ACPI::getController()->getCPUCount();
gdt = new(GDT::size(ncpu)) GDT();
tss = new TSS64_ENT[ncpu]();
tss = new TSS64_ENT*[ncpu]();
idt = new REC64[256]();
handlers = new Handler[256]();
......@@ -305,10 +305,14 @@ void Interrupts::init() {
for (uint32_t idx = 0; idx < ncpu; idx++) {
void *stack = Pagetable::alloc();
uintptr_t stack_ptr = uintptr_t(stack) + 0x1000;
Memory::zero(&tss[idx], sizeof(tss[idx]));
tss[idx].ist[0] = stack_ptr;
char *entbuf = reinterpret_cast<char*>(Heap::alloc(0x3000, 0x1000));
TSS64_ENT *ent = tss[idx] = reinterpret_cast<TSS64_ENT*>(entbuf + (0x1000 - sizeof(TSS64_ENT)));
Memory::zero(tss[idx], sizeof(TSS64_ENT) + 0x2000);
ent->ist[0] = stack_ptr;
ent->iomap_base = sizeof(TSS64_ENT);
gdt->sys_ents[idx] = GDT::SystemEntry(
uintptr_t(&tss[idx]), sizeof(TSS64_ENT),
uintptr_t(tss[idx]), sizeof(TSS64_ENT) + 0x2000,
0x9, 0, 0, 1, 0, 1, 0, 0);
}
......
......@@ -263,16 +263,23 @@ void Process::startup() {
addPage(sc_wrapper, reinterpret_cast<void*>(sc_wrapper), 5);
GDT::Entry *gdt_ent = reinterpret_cast<GDT::Entry*>(uintptr_t(gdt.addr) + 8 * 3);
GDT::Entry *gdt_top = reinterpret_cast<GDT::Entry*>(uintptr_t(gdt.addr) + gdt.limit);
void *iomap1 = Pagetable::alloc();
void *iomap2 = Pagetable::alloc();
Memory::fill(iomap1, 0xFF, 0x1000);
Memory::fill(iomap2, 0xFF, 0x1000);
while (gdt_ent < gdt_top) {
uintptr_t base = gdt_ent->getBase();
size_t limit = gdt_ent->getLimit();
if (((gdt_ent->type != 0x9) && (gdt_ent->type != 0xB)) || (limit
!= sizeof(TSS64_ENT))) {
if (((gdt_ent->type != 0x9) && (gdt_ent->type != 0xB)) || (limit != sizeof(TSS64_ENT) + 0x2000)) {
gdt_ent++;
continue;
}
uintptr_t page = base & KB4;
addPage(page, reinterpret_cast<void*>(page), 5);
addPage(page + 0x1000, iomap1, 5);
addPage(page + 0x2000, iomap2, 5);
GDT::SystemEntry *sysent = reinterpret_cast<GDT::SystemEntry*>(gdt_ent);
base = sysent->getBase();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment