mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
prepare memory reorganization and minor fixes
This commit is contained in:
@@ -154,7 +154,7 @@ extern "C":
|
||||
|
||||
#ifdef INIT
|
||||
// Initialize most things (the rest is done in boot.S)
|
||||
void init ()
|
||||
void init (unsigned mem)
|
||||
// Start running the idle task for the first time.
|
||||
void run_idle (Thread *self)
|
||||
#endif
|
||||
|
||||
@@ -55,6 +55,8 @@ start_hack_for_disassembler:
|
||||
bne $a1, $a0, 1b
|
||||
addu $a0, 4
|
||||
|
||||
// First argument is the memory size: 128 megabytes.
|
||||
li $a0, 128 << 20
|
||||
la $t9, init
|
||||
jr $t9
|
||||
nop
|
||||
|
||||
@@ -111,6 +111,7 @@ static void init_threads ():
|
||||
Thread *previous = NULL
|
||||
first_scheduled = NULL
|
||||
first_sleeper = NULL
|
||||
Receiver *init_receiver = NULL
|
||||
for unsigned i = 0; i < NUM_THREADS; ++i:
|
||||
Memory *mem = top_memory.alloc_memory ()
|
||||
Thread *thread = mem->alloc_thread ()
|
||||
@@ -185,33 +186,27 @@ static void init_threads ():
|
||||
thread->arch.a1 = mkcap (mem, CAPTYPE_THREAD | CAP_THREAD_ALL_PRIV_RIGHTS, thread)
|
||||
thread->arch.a2 = mkcap (mem, CAPTYPE_MEMORY | CAP_MEMORY_ALL_RIGHTS, mem)
|
||||
thread->arch.a3 = mkcap (mem, CAPTYPE_RECEIVER | (1 << CAP_RECEIVER_CALL), recv)
|
||||
mem->pfree ((unsigned)pages)
|
||||
thread->flags = THREAD_FLAG_RUNNING | THREAD_FLAG_PRIV
|
||||
thread->schedule_next = NULL
|
||||
thread->schedule_prev = previous
|
||||
if previous:
|
||||
previous->schedule_next = thread
|
||||
else:
|
||||
if !i:
|
||||
first_scheduled = thread
|
||||
init_receiver = recv
|
||||
else:
|
||||
thread->arch.t0 = mkcap (mem, (unsigned)init_receiver, (void *)i)
|
||||
previous->schedule_next = thread
|
||||
thread->schedule_prev = previous
|
||||
previous = thread
|
||||
|
||||
mem->pfree ((unsigned)pages)
|
||||
thread->schedule_next = NULL
|
||||
|
||||
// Initialize the kernel, finish by falling into the idle task.
|
||||
extern unsigned _end
|
||||
void init ():
|
||||
void init (unsigned mem):
|
||||
// Disable interrupts and set interrupt vectors to normal.
|
||||
cp0_set0 (CP0_STATUS)
|
||||
// Initialize kernel variables to empty.
|
||||
sleepers = NULL
|
||||
runners = NULL
|
||||
zero_pages = NULL
|
||||
// Fill junk pages with all memory not currently used.
|
||||
junk_pages = (FreePage *)(((unsigned)&_end + ~PAGE_MASK) & PAGE_MASK)
|
||||
FreePage *p, *next
|
||||
unsigned count = 1
|
||||
for p = junk_pages, next = p; (unsigned)next - 0x80000000 < (1 << 27); p = next, next = (FreePage *)((unsigned)p + PAGE_SIZE):
|
||||
p->next = next
|
||||
++count
|
||||
p->next = NULL
|
||||
unsigned count = init_memory (mem)
|
||||
// initialize system control coprocessor.
|
||||
init_cp0 ()
|
||||
// initialize everything about the idle task.
|
||||
@@ -258,13 +253,13 @@ void init ():
|
||||
GPIO_GPDR (GPIO_USB_CLK_EN_PORT) |= 1 << GPIO_USB_CLK_EN
|
||||
|
||||
// Start the operating system timer, and set it to give an interrupt immediately.
|
||||
// This is better, because the kernel start with jumping into the idle task and
|
||||
// This is better, because the kernel starts with jumping into the idle task and
|
||||
// waiting for the first interrupt.
|
||||
unsigned latch = (JZ_EXTAL + (HZ >> 1)) / HZ
|
||||
ost_disable_all ()
|
||||
ost_set_mode (0, OST_TCSR_UIE | OST_TCSR_CKS_EXTAL)
|
||||
ost_set_reload (0, latch)
|
||||
ost_set_count (0, 0)
|
||||
ost_set_count (0, 1)
|
||||
ost_set_mode (0, OST_TCSR_UIE | OST_TCSR_CKS_EXTAL)
|
||||
ost_enable_channel (0)
|
||||
intc_unmask_irq (IRQ_OST0)
|
||||
|
||||
Reference in New Issue
Block a user