1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-07-07 15:31:06 +03:00
iris/mips.hhp
Bas Wijnen 616e81d7a8 more
2009-05-18 23:18:23 +02:00

95 lines
2.1 KiB
Plaintext

#pypp 0
#ifndef _ARCH_HH
#define _ARCH_HH
#define PAGE_BITS (12)
#define PAGE_SIZE (1 << PAGE_BITS)
#define PAGE_MASK (~(PAGE_SIZE - 1))
struct Thread_arch:
unsigned at, v0, v1, a0, a1, a2, a3
unsigned t0, t1, t2, t3, t4, t5, t6, t7, t8, t9
unsigned gp, fp, ra, hi, lo, k0, k1
struct Memory_arch:
unsigned asid
Page ***directory
static void Memory_arch_unmap (Memory *mem, Page *page, void *address)
#endif // _ARCH_HH
#ifdef ARCH_PART2
static void Thread_arch_init (Thread *thread):
thread->arch.at = 0
thread->arch.v0 = 0
thread->arch.v1 = 0
thread->arch.a0 = 0
thread->arch.a1 = 0
thread->arch.a2 = 0
thread->arch.a3 = 0
thread->arch.t0 = 0
thread->arch.t1 = 0
thread->arch.t2 = 0
thread->arch.t3 = 0
thread->arch.t4 = 0
thread->arch.t5 = 0
thread->arch.t6 = 0
thread->arch.t7 = 0
thread->arch.t8 = 0
thread->arch.t9 = 0
thread->arch.gp = 0
thread->arch.fp = 0
thread->arch.ra = 0
thread->arch.hi = 0
thread->arch.lo = 0
thread->arch.k0 = 0
thread->arch.k1 = 0
EXTERN unsigned g_asid
static void Memory_arch_init (Memory *mem):
++g_asid
g_asid &= 0x3f
if !g_asid:
++g_asid
mem->arch.asid = g_asid
mem->arch.directory = NULL
static void Memory_arch_free (Memory *mem):
if !mem->arch.directory:
return
for unsigned i = 0; i < PAGE_SIZE; ++i:
Page **table = mem->arch.directory[i]
if !table:
continue
for unsigned j = 0; j < PAGE_SIZE; ++j:
Page *page = table[j]
if !page:
continue
mem->unmap (page, (void *)(i * 0x1000 * 0x400 + j * 0x1000))
mem->unuse ()
mem->zfree (table)
mem->arch.directory[i] = NULL
mem->unuse ()
mem->zfree (mem->arch.directory)
static void Memory_arch_unmap (Memory *mem, Page *page, void *address):
// Functions which can be called from assembly must not be mangled.
extern "C":
// Kernel entry points, called from entry.S.
Thread *interrupt (Thread *current)
Thread *cache_error (Thread *current)
Thread *exception (Thread *current)
Thread *tlb_refill (Thread *current, unsigned EntryHi)
#ifdef INIT
// Initialize most things (the rest is done in boot.S)
void init ()
// Start running the idle task for the first time.
void run_idle (Thread *self)
#endif
#endif // ARCH_PART2