Align stack pointer on kernel proper entry to 16-byte. Eliminate dead-lock in frame allocator on OOM. Formatting.

This commit is contained in:
Dale Weiler 2015-05-21 15:09:42 -04:00
parent a699c91ddd
commit e27cb1b96f
7 changed files with 8 additions and 7 deletions

View File

@ -41,8 +41,11 @@ stack_top:
start: start:
/* Setup our stack */ /* Setup our stack */
mov $stack_top, %esp mov $stack_top, %esp
pushl %esp
/* Make sure our stack is 16-byte aligned */
and $-16, %esp
pushl %esp
pushl %eax /* Multiboot header magic */ pushl %eax /* Multiboot header magic */
pushl %ebx /* Multiboot header pointer */ pushl %ebx /* Multiboot header pointer */

View File

@ -74,7 +74,7 @@ void gdt_install(void) {
} }
static void write_tss(int32_t num, uint16_t ss0, uint32_t esp0) { static void write_tss(int32_t num, uint16_t ss0, uint32_t esp0) {
tss_entry_t *tss = &gdt.tss; tss_entry_t * tss = &gdt.tss;
uintptr_t base = (uintptr_t)tss; uintptr_t base = (uintptr_t)tss;
uintptr_t limit = base + sizeof *tss; uintptr_t limit = base + sizeof *tss;

View File

@ -44,7 +44,7 @@ void idt_set_gate(uint8_t num, idt_gate_t base, uint16_t sel, uint8_t flags) {
} }
void idt_install(void) { void idt_install(void) {
idt_pointer_t *idtp = &idt.pointer; idt_pointer_t * idtp = &idt.pointer;
idtp->limit = sizeof idt.entries - 1; idtp->limit = sizeof idt.entries - 1;
idtp->base = (uintptr_t)&ENTRY(0); idtp->base = (uintptr_t)&ENTRY(0);
memset(&ENTRY(0), 0, sizeof idt.entries); memset(&ENTRY(0), 0, sizeof idt.entries);

View File

@ -81,7 +81,7 @@ void int_enable(void) {
/* Interrupt Requests */ /* Interrupt Requests */
#define IRQ_CHAIN_SIZE 16 #define IRQ_CHAIN_SIZE 16
#define IRQ_CHAIN_DEPTH 4 #define IRQ_CHAIN_DEPTH 4
static void (*irqs[IRQ_CHAIN_SIZE])(void); static void (*irqs[IRQ_CHAIN_SIZE])(void);
static irq_handler_chain_t irq_routines[IRQ_CHAIN_SIZE * IRQ_CHAIN_DEPTH] = { NULL }; static irq_handler_chain_t irq_routines[IRQ_CHAIN_SIZE * IRQ_CHAIN_DEPTH] = { NULL };

View File

@ -14,8 +14,6 @@ typedef struct _pipe_device {
size_t read_ptr; size_t read_ptr;
size_t size; size_t size;
size_t refcount; size_t refcount;
//uint8_t volatile lock_read;
//uint8_t volatile lock_write;
volatile int lock_read[2]; volatile int lock_read[2];
volatile int lock_write[2]; volatile int lock_write[2];
list_t * wait_queue_readers; list_t * wait_queue_readers;

View File

@ -3,7 +3,6 @@
#include <types.h> #include <types.h>
typedef struct page { typedef struct page {
unsigned int present:1; unsigned int present:1;
unsigned int rw:1; unsigned int rw:1;

View File

@ -60,6 +60,7 @@ kmalloc_real(
spin_lock(frame_alloc_lock); spin_lock(frame_alloc_lock);
uint32_t index = first_n_frames((size + 0xFFF) / 0x1000); uint32_t index = first_n_frames((size + 0xFFF) / 0x1000);
if (index == 0xFFFFFFFF) { if (index == 0xFFFFFFFF) {
spin_unlock(frame_alloc_lock);
return 0; return 0;
} }
for (unsigned int i = 0; i < (size + 0xFFF) / 0x1000; ++i) { for (unsigned int i = 0; i < (size + 0xFFF) / 0x1000; ++i) {