Merge branch 'master' into ohligs

Conflicts:
	kernel/tasks.c
This commit is contained in:
Marian Ohligs 2011-07-30 19:21:25 +02:00
commit 94a98c5950
7 changed files with 172 additions and 153 deletions

View file

@ -70,7 +70,7 @@ $(NAME).elf:
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME).elf
qemu: newlib tools $(NAME).elf
qemu -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
qemu -monitor stdio -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.elf -initrd tools/initrd.img
qemudbg: newlib tools $(NAME).elf
qemu -S -s -smp 2 -net nic,model=rtl8139 -net user,hostfwd=tcp::12345-:7 -net dump -kernel metalsvm.elf -initrd tools/initrd.img

View file

@ -160,64 +160,72 @@ isr0:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 0
jmp isr_common_stub
jmp common_stub
; 1: Debug Exception
isr1:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 1
jmp isr_common_stub
jmp common_stub
; 2: Non Maskable Interrupt Exception
isr2:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 2
jmp isr_common_stub
jmp common_stub
; 3: Int 3 Exception
isr3:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 3
jmp isr_common_stub
jmp common_stub
; 4: INTO Exception
isr4:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 4
jmp isr_common_stub
jmp common_stub
; 5: Out of Bounds Exception
isr5:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 5
jmp isr_common_stub
jmp common_stub
; 6: Invalid Opcode Exception
isr6:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 6
jmp isr_common_stub
jmp common_stub
; 7: Coprocessor Not Available Exception
isr7:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 7
jmp isr_common_stub
jmp common_stub
; 8: Double Fault Exception (With Error Code!)
isr8:
@ -225,15 +233,16 @@ isr8:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 8
jmp isr_common_stub
jmp common_stub
; 9: Coprocessor Segment Overrun Exception
isr9:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 9
jmp isr_common_stub
jmp common_stub
; 10: Bad TSS Exception (With Error Code!)
isr10:
@ -241,7 +250,7 @@ isr10:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 10
jmp isr_common_stub
jmp common_stub
; 11: Segment Not Present Exception (With Error Code!)
isr11:
@ -249,7 +258,7 @@ isr11:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 11
jmp isr_common_stub
jmp common_stub
; 12: Stack Fault Exception (With Error Code!)
isr12:
@ -257,7 +266,7 @@ isr12:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 12
jmp isr_common_stub
jmp common_stub
; 13: General Protection Fault Exception (With Error Code!)
isr13:
@ -265,7 +274,7 @@ isr13:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 13
jmp isr_common_stub
jmp common_stub
; 14: Page Fault Exception (With Error Code!)
isr14:
@ -273,23 +282,25 @@ isr14:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 14
jmp isr_common_stub
jmp common_stub
; 15: Reserved Exception
isr15:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 15
jmp isr_common_stub
jmp common_stub
; 16: Floating Point Exception
isr16:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 16
jmp isr_common_stub
jmp common_stub
; 17: Alignment Check Exception
isr17:
@ -297,131 +308,133 @@ isr17:
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 17
jmp isr_common_stub
jmp common_stub
; 18: Machine Check Exception
isr18:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 18
jmp isr_common_stub
jmp common_stub
; 19: Reserved
isr19:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 19
jmp isr_common_stub
jmp common_stub
; 20: Reserved
isr20:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 20
jmp isr_common_stub
jmp common_stub
; 21: Reserved
isr21:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 21
jmp isr_common_stub
jmp common_stub
; 22: Reserved
isr22:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 22
jmp isr_common_stub
jmp common_stub
; 23: Reserved
isr23:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 23
jmp isr_common_stub
jmp common_stub
; 24: Reserved
isr24:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 24
jmp isr_common_stub
jmp common_stub
; 25: Reserved
isr25:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 25
jmp isr_common_stub
jmp common_stub
; 26: Reserved
isr26:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 26
jmp isr_common_stub
jmp common_stub
; 27: Reserved
isr27:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 27
jmp isr_common_stub
jmp common_stub
; 28: Reserved
isr28:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 28
jmp isr_common_stub
jmp common_stub
; 29: Reserved
isr29:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 29
jmp isr_common_stub
jmp common_stub
; 30: Reserved
isr30:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 30
jmp isr_common_stub
jmp common_stub
; 31: Reserved
isr31:
; isr0 - isr31 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 31
jmp isr_common_stub
isr_common_stub:
pusha
; use the same handler for interrupts and exceptions
push esp
call irq_handler
add esp, 4
popa
add esp, 4
iret
jmp common_stub
extern syscall_handler
@ -499,188 +512,189 @@ irq0:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 32
jmp irq_common_stub
jmp common_stub
; 33: IRQ1
irq1:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 33
jmp irq_common_stub
jmp common_stub
; 34: IRQ2
irq2:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 34
jmp irq_common_stub
jmp common_stub
; 35: IRQ3
irq3:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 35
jmp irq_common_stub
jmp common_stub
; 36: IRQ4
irq4:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 36
jmp irq_common_stub
jmp common_stub
; 37: IRQ5
irq5:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 37
jmp irq_common_stub
jmp common_stub
; 38: IRQ6
irq6:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 38
jmp irq_common_stub
jmp common_stub
; 39: IRQ7
irq7:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 39
jmp irq_common_stub
jmp common_stub
; 40: IRQ8
irq8:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 40
jmp irq_common_stub
jmp common_stub
; 41: IRQ9
irq9:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 41
jmp irq_common_stub
jmp common_stub
; 42: IRQ10
irq10:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 42
jmp irq_common_stub
jmp common_stub
; 43: IRQ11
irq11:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 43
jmp irq_common_stub
jmp common_stub
; 44: IRQ12
irq12:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 44
jmp irq_common_stub
jmp common_stub
; 45: IRQ13
irq13:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 45
jmp irq_common_stub
jmp common_stub
; 46: IRQ14
irq14:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 46
jmp irq_common_stub
jmp common_stub
; 47: IRQ15
irq15:
; irq0 - irq15 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 47
jmp irq_common_stub
jmp common_stub
; 48: IRQ16
irq16:
; irq16 - irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 48
jmp irq_common_stub
jmp common_stub
; 49: IRQ17
irq17:
; irq16- irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 49
jmp irq_common_stub
jmp common_stub
; 50: IRQ18
irq18:
; irq16 - irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 50
jmp irq_common_stub
jmp common_stub
; 51: IRQ19
irq19:
; irq16 - irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 51
jmp irq_common_stub
jmp common_stub
; 52: IRQ20
irq20:
; irq16- irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 52
jmp irq_common_stub
jmp common_stub
; 53: IRQ21
irq21:
@ -689,68 +703,69 @@ irq21:
; cli
push byte 0 ; error code
push byte 53
jmp irq_common_stub
jmp common_stub
; 54: IRQ22
irq22:
; irq16- irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; pseudo error code
push byte 54
jmp irq_common_stub
jmp common_stub
; 55: IRQ23
irq23:
; irq16 - irq23 are registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 55
jmp irq_common_stub
jmp common_stub
apic_timer:
; apic timer is registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 123
jmp irq_common_stub
jmp common_stub
apic_lint0:
; lint0 is registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 124
jmp irq_common_stub
jmp common_stub
apic_lint1:
; lint1 is registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 125
jmp irq_common_stub
jmp common_stub
apic_error:
; LVT error interrupt is registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 126
jmp irq_common_stub
jmp common_stub
apic_svr:
; SVR is registered as "Interrupt Gate"
; Therefore, the interrupt flag (IF) is already cleared.
; cli
push byte 0 ; error code
push byte 0 ; pseudo error code
push byte 127
jmp irq_common_stub
jmp common_stub
extern irq_handler
irq_common_stub:
common_stub:
pusha
; use the same handler for interrupts and exceptions

View file

@ -138,66 +138,66 @@ static int irq_install(void)
{
irq_remap();
idt_set_gate(32, (unsigned)irq0, KERNEL_CODE_SELECTOR,
idt_set_gate(32, (size_t)irq0, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(33, (unsigned)irq1, KERNEL_CODE_SELECTOR,
idt_set_gate(33, (size_t)irq1, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(34, (unsigned)irq2, KERNEL_CODE_SELECTOR,
idt_set_gate(34, (size_t)irq2, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(35, (unsigned)irq3, KERNEL_CODE_SELECTOR,
idt_set_gate(35, (size_t)irq3, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(36, (unsigned)irq4, KERNEL_CODE_SELECTOR,
idt_set_gate(36, (size_t)irq4, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(37, (unsigned)irq5, KERNEL_CODE_SELECTOR,
idt_set_gate(37, (size_t)irq5, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(38, (unsigned)irq6, KERNEL_CODE_SELECTOR,
idt_set_gate(38, (size_t)irq6, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(39, (unsigned)irq7, KERNEL_CODE_SELECTOR,
idt_set_gate(39, (size_t)irq7, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(40, (unsigned)irq8, KERNEL_CODE_SELECTOR,
idt_set_gate(40, (size_t)irq8, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(41, (unsigned)irq9, KERNEL_CODE_SELECTOR,
idt_set_gate(41, (size_t)irq9, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(42, (unsigned)irq10, KERNEL_CODE_SELECTOR,
idt_set_gate(42, (size_t)irq10, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(43, (unsigned)irq11, KERNEL_CODE_SELECTOR,
idt_set_gate(43, (size_t)irq11, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(44, (unsigned)irq12, KERNEL_CODE_SELECTOR,
idt_set_gate(44, (size_t)irq12, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(45, (unsigned)irq13, KERNEL_CODE_SELECTOR,
idt_set_gate(45, (size_t)irq13, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(46, (unsigned)irq14, KERNEL_CODE_SELECTOR,
idt_set_gate(46, (size_t)irq14, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(47, (unsigned)irq15, KERNEL_CODE_SELECTOR,
idt_set_gate(47, (size_t)irq15, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
if (has_apic()) {
idt_set_gate(48, (unsigned)irq16, KERNEL_CODE_SELECTOR,
idt_set_gate(48, (size_t)irq16, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(49, (unsigned)irq17, KERNEL_CODE_SELECTOR,
idt_set_gate(49, (size_t)irq17, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(50, (unsigned)irq18, KERNEL_CODE_SELECTOR,
idt_set_gate(50, (size_t)irq18, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(51, (unsigned)irq19, KERNEL_CODE_SELECTOR,
idt_set_gate(51, (size_t)irq19, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(52, (unsigned)irq20, KERNEL_CODE_SELECTOR,
idt_set_gate(52, (size_t)irq20, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(53, (unsigned)irq21, KERNEL_CODE_SELECTOR,
idt_set_gate(53, (size_t)irq21, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(54, (unsigned)irq22, KERNEL_CODE_SELECTOR,
idt_set_gate(54, (size_t)irq22, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(55, (unsigned)irq23, KERNEL_CODE_SELECTOR,
idt_set_gate(55, (size_t)irq23, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(123, (unsigned)apic_timer, KERNEL_CODE_SELECTOR,
idt_set_gate(123, (size_t)apic_timer, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(124, (unsigned)apic_lint0, KERNEL_CODE_SELECTOR,
idt_set_gate(124, (size_t)apic_lint0, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(125, (unsigned)apic_lint1, KERNEL_CODE_SELECTOR,
idt_set_gate(125, (size_t)apic_lint1, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(126, (unsigned)apic_error, KERNEL_CODE_SELECTOR,
idt_set_gate(126, (size_t)apic_error, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
idt_set_gate(127, (unsigned)apic_svr, KERNEL_CODE_SELECTOR,
idt_set_gate(127, (size_t)apic_svr, KERNEL_CODE_SELECTOR,
IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP);
}

View file

@ -60,9 +60,9 @@ typedef struct task {
/// Task id = position in the task table
tid_t id;
/// Task status (INVALID, READY, RUNNING, ...)
uint32_t status;
uint32_t status;
/// Usage in number of pages
atomic_int32_t user_usage;
atomic_int32_t user_usage;
/// Avoids concurrent access to the page directory
spinlock_t pgd_lock;
/// pointer to the page directory

View file

@ -99,12 +99,18 @@ int STDCALL network_task(void* arg)
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) {
#endif
kputs("Unable to add network interface\n");
return -ENXIO;
return -ENODEV;
}
netif_set_default(&netif);
netif_set_up(&netif);
/* test if interface is really up */
if (!netif_is_up(&netif)) {
kputs("network interface is not up\n");
return -ENODEV;
}
#ifndef CONFIG_ROCKCREEK
kprintf("Starting DHCPCD...\n");
dhcp_start(&netif);
@ -112,7 +118,7 @@ int STDCALL network_task(void* arg)
/* wait for ip address */
while(!netif.ip_addr.addr) {
rtl8139if_wait(&netif, 1);
udelay(500000);
reschedule();
}
#else
mmnif_open();

View file

@ -42,16 +42,18 @@
#include <asm/apic.h>
#include <asm/elf.h>
DEFINE_PER_CORE(task_t*, current_task, NULL);
/** @brief Array of task structures
*
* A task's id will be its position in this array.
*/
static task_t task_table[MAX_TASKS] = {[0 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), \
SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, FS_INIT, 0, 0, 0, 0}};
static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_RUNNING, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, FS_INIT, 0, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, FS_INIT, 0, 0, 0, 0}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
DEFINE_PER_CORE(task_t*, current_task, task_table+0);
/** @brief helper function for the assembly code to determine the current task
* @return Pointer to the task_t structure of current task
*/
@ -60,15 +62,11 @@ task_t* get_current_task(void) {
}
int multitasking_init(void) {
if (task_table[0].status == TASK_INVALID) {
task_table[0].id = 0;
task_table[0].status = TASK_RUNNING;
atomic_int32_set(&task_table[0].user_usage, 0);
if (BUILTIN_EXPECT(task_table[0].status == TASK_RUNNING, 1)) {
mailbox_wait_msg_init(&task_table[0].inbox);
memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS);
task_table[0].pgd = get_boot_pgd();
task_table[0].flags = TASK_DEFAULT_FLAGS;
per_core(current_task) = task_table+0;
return 0;
}

View file

@ -56,23 +56,23 @@ atomic_int32_t total_available_pages = ATOMIC_INIT(0);
extern const void kernel_start;
extern const void kernel_end;
inline static int page_marked(unsigned int i)
inline static int page_marked(size_t i)
{
unsigned int index = i >> 3;
unsigned int mod = i & 0x7;
size_t index = i >> 3;
size_t mod = i & 0x7;
return (bitmap[index] & (1 << mod));
}
inline static int page_unmarked(unsigned int i)
inline static int page_unmarked(size_t i)
{
return !page_marked(i);
}
inline static void page_set_mark(unsigned int i)
inline static void page_set_mark(size_t i)
{
unsigned int index = i >> 3;
unsigned int mod = i & 0x7;
size_t index = i >> 3;
size_t mod = i & 0x7;
//if (page_marked(i))
// kprintf("page %u is alread marked\n", i);
@ -80,10 +80,10 @@ inline static void page_set_mark(unsigned int i)
bitmap[index] = bitmap[index] | (1 << mod);
}
inline static void page_clear_mark(unsigned int i)
inline static void page_clear_mark(size_t i)
{
unsigned int index = i / 8;
unsigned int mod = i % 8;
size_t index = i / 8;
size_t mod = i % 8;
if (page_unmarked(i))
kprintf("page %u is already unmarked\n", i);