Esempio n. 1
0
File: idt.c Progetto: osstudy/glidix
void idtReboot()
{
	ASM("cli");
	idtPtr.addr = 0;
	idtPtr.limit = 0;
	loadIDT();
	ASM("int $0x70");
	while (1) ASM("cli; hlt");
};
Esempio n. 2
0
File: idt.c Progetto: osstudy/glidix
void initIDT()
{
	// remap the IRQs
#if 0
	outb(0x20, 0x11);
	outb(0xA0, 0x11);
	outb(0x21, 0x20);
	outb(0xA1, 0x28);
	outb(0x21, 0x04);
	outb(0xA1, 0x02);
	outb(0x21, 0x01);
	outb(0xA1, 0x01);
	outb(0x21, 0x0);
	outb(0xA1, 0x0);
#endif

	outb(0xA1, 0xFF);
	outb(0x21, 0xFF);

	memset(idt, 0, 256*sizeof(IDTEntry));
	setGate(0, isr0);
	setGate(1, isr1);
	setGate(2, isr2);
	setGate(3, isr3);
	setGate(4, isr4);
	setGate(5, isr5);
	setGate(6, isr6);
	setGate(7, isr7);
	setGate(8, isr8);
	setGate(9, isr9);
	setGate(10, isr10);
	setGate(11, isr11);
	setGate(12, isr12);
	setGate(13, isr13);
	setGate(14, isr14);
	setGate(15, isr15);
	setGate(16, isr16);
	setGate(17, isr17);
	setGate(18, isr18);
	setGate(19, isr19);
	setGate(20, isr20);
	setGate(21, isr21);
	setGate(22, isr22);
	setGate(23, isr23);
	setGate(24, isr24);
	setGate(25, isr25);
	setGate(26, isr26);
	setGate(27, isr27);
	setGate(28, isr28);
	setGate(29, isr29);
	setGate(30, isr30);
	setGate(31, isr31);
	setGate(32, irq0);
	setGate(33, irq1);
	setGate(34, irq2);
	setGate(35, irq3);
	setGate(36, irq4);
	setGate(37, irq5);
	setGate(38, irq6);
	setGate(39, irq7);
	setGate(40, irq8);
	setGate(41, irq9);
	setGate(42, irq10);
	setGate(43, irq11);
	setGate(44, irq12);
	setGate(45, irq13);
	setGate(46, irq14);
	setGate(47, irq15);
	setGate(48, isr48);
	setGate(49, isr49);
	setGate(50, isr50);
	setGate(51, isr51);
	setGate(52, isr52);
	setGate(53, isr53);
	setGate(54, isr54);
	setGate(55, isr55);
	setGate(56, isr56);
	setGate(57, isr57);
	setGate(58, isr58);
	setGate(59, isr59);
	setGate(60, isr60);
	setGate(61, isr61);
	setGate(62, isr62);
	setGate(63, isr63);
	setGate(64, isr64);
	setGate(65, isr65);

	idtPtr.addr = (uint64_t) &idt[0];
	idtPtr.limit = (sizeof(IDTEntry) * 256) - 1;
	loadIDT();

	memset(irqHandlers, 0, sizeof(IRQHandler)*16);
	uptime = 0;
};
Esempio n. 3
0
int main(){
	int i = 0;
	clearScr();
	writeScr("Initializing OS", 0, 0);
	writeScr("Setting up OS descriptors...", 1, 0);

	constructGDT();
	lgdtT.offset = (uint32_t) &gdt;
	lgdtT.limit = (sizeof(struct gdt_entry)*5) - 1;
	loadGDT(&lgdtT);

	constructIDT();
	lidtT.offset = (uint32_t) &idt;
	lidtT.limit = (sizeof(struct idt_entry)*256) - 1;
	loadIDT(&lidtT);
	
	asm("cli");
	setupPIC();

	uint8_t cs = 8;
	uint8_t ds = 16; 
	uint8_t ss = 24;
	uint8_t fs = ds; 
	uint8_t es = 32;

	loadSegments(cs,ds,ss,fs,es);
	
	writeScrPM("done.", 2, 28);
	clearScrPM();
	head = null;
	tail = null;

  	writeScrPM("Running ten processes...", 0, 0);
	writeScrPM("-          -", 20, 0);
	mutex_init(&m);

	// Process 1
	createProcess(ds,  ss, stack[0] + STACK_SIZE, cs, (uint32_t) p1);
	
	// Process 2
	createProcess(ds,  ss, stack[1] + STACK_SIZE, cs, (uint32_t) p2);
	
	// Process 3
	createProcess(ds,  ss, stack[2] + STACK_SIZE, cs, (uint32_t) p3);
	
	// Process 4
	createProcess(ds,  ss, stack[3] + STACK_SIZE, cs, (uint32_t) p4);
	
	// Process 5
	createProcess(ds,  ss, stack[4] + STACK_SIZE, cs, (uint32_t) p5);
	
	// Process 6
	createProcess(ds,  ss, stack[5] + STACK_SIZE, cs, (uint32_t) p6);
	
	// Process 7
	createProcess(ds,  ss, stack[6] + STACK_SIZE, cs, (uint32_t) p7);
	// Process 8
	createProcess(ds,  ss, stack[7] + STACK_SIZE, cs, (uint32_t) p8);
	// Process 9
	createProcess(ds,  ss, stack[8] + STACK_SIZE, cs, (uint32_t) p9);
	// Process 10
	createProcess(ds,  ss, stack[9] + STACK_SIZE, cs, (uint32_t) p10);
	//*/
	start();
}