mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-04-21 12:27:27 +03:00
make code work again
This commit is contained in:
@@ -115,6 +115,7 @@ void kMemory_arch_init (kMemory *mem):
|
||||
mem->arch.shadow = NULL
|
||||
|
||||
void kMemory_arch_free (kMemory *mem):
|
||||
//dbg_log_line ()
|
||||
while mem->arch.first_page_table:
|
||||
mem->unmap (mem->arch.first_page_table->first_page->page, mem->arch.first_page_table->first_page->mapping)
|
||||
if (kMemory *)asids[mem->arch.asid] == mem:
|
||||
@@ -125,6 +126,7 @@ void kMemory_arch_free (kMemory *mem):
|
||||
mem->zfree ((unsigned)mem->arch.directory)
|
||||
|
||||
static arch_page_table *alloc_page_table (kMemory *mem):
|
||||
//dbg_log_line ()
|
||||
arch_page_table *ret = (arch_page_table *)mem->search_free (sizeof (arch_page_table), (void **)&mem->arch.first_page_table)
|
||||
if !ret:
|
||||
return NULL
|
||||
@@ -132,6 +134,7 @@ static arch_page_table *alloc_page_table (kMemory *mem):
|
||||
return ret
|
||||
|
||||
static arch_page *alloc_page (kMemory *mem, arch_page_table *t):
|
||||
//dbg_log_line ()
|
||||
arch_page *ret = (arch_page *)mem->search_free (sizeof (arch_page), (void **)&t->first_page)
|
||||
if !ret:
|
||||
return NULL
|
||||
@@ -142,6 +145,7 @@ static arch_page *alloc_page (kMemory *mem, arch_page_table *t):
|
||||
return ret
|
||||
|
||||
static void free_page_table (arch_page_table *t, unsigned idx):
|
||||
//dbg_log_line ()
|
||||
kMemory *mem = t->address_space
|
||||
mem->zfree ((unsigned)mem->arch.directory[idx])
|
||||
mem->arch.directory[idx] = NULL
|
||||
@@ -154,6 +158,7 @@ static void free_page_table (arch_page_table *t, unsigned idx):
|
||||
mem->arch.shadow = NULL
|
||||
|
||||
static void tlb_reset (unsigned address, unsigned asid, unsigned value):
|
||||
//dbg_log_line ()
|
||||
cp0_set (CP0_ENTRY_HI, address | asid)
|
||||
__asm__ volatile ("tlbp")
|
||||
unsigned idx
|
||||
@@ -166,9 +171,10 @@ static void tlb_reset (unsigned address, unsigned asid, unsigned value):
|
||||
__asm__ volatile ("tlbwi")
|
||||
|
||||
static void free_page (arch_page_table *t, arch_page *p):
|
||||
dbg_log ("free page ")
|
||||
dbg_log_num ((unsigned)p)
|
||||
dbg_log_char ('\n')
|
||||
//dbg_log_line ()
|
||||
if !p:
|
||||
dpanic (0, "freeing page 0")
|
||||
return
|
||||
if p->prev_mapped:
|
||||
p->prev_mapped->next_mapped = p->next_mapped
|
||||
else:
|
||||
@@ -182,6 +188,7 @@ static void free_page (arch_page_table *t, arch_page *p):
|
||||
free_page_table (t, idx)
|
||||
|
||||
static unsigned make_entry_lo (kPage *page, bool readonly):
|
||||
//dbg_log_line ()
|
||||
if !page->frame:
|
||||
return 0
|
||||
unsigned flags
|
||||
@@ -195,6 +202,7 @@ static unsigned make_entry_lo (kPage *page, bool readonly):
|
||||
return ((page->frame & ~0x80000000) >> 6) | flags
|
||||
|
||||
bool kMemory_arch_map (kMemory *mem, kPage *page, unsigned address, bool readonly):
|
||||
//dbg_log_line ()
|
||||
if address >= 0x80000000:
|
||||
panic (0x32134293, "trying to map to kernel address")
|
||||
return false
|
||||
@@ -238,6 +246,15 @@ bool kMemory_arch_map (kMemory *mem, kPage *page, unsigned address, bool readonl
|
||||
return false
|
||||
unsigned idx = (address >> 12) & ((1 << 9) - 1)
|
||||
if table[idx]:
|
||||
dbg_log ("page already mapped: ")
|
||||
dbg_log_num (idx, 3)
|
||||
dbg_log (";")
|
||||
dbg_log_num (table[idx])
|
||||
dbg_log ("/")
|
||||
dbg_log_num (table[idx + 0x200])
|
||||
dbg_log (" table: ")
|
||||
dbg_log_num ((unsigned)table)
|
||||
dbg_log ("\n")
|
||||
mem->unmap ((kPage *)table[idx + 0x200], address)
|
||||
table[idx] = make_entry_lo (page, readonly)
|
||||
table[idx + 0x200] = (unsigned)p
|
||||
@@ -250,6 +267,7 @@ bool kMemory_arch_map (kMemory *mem, kPage *page, unsigned address, bool readonl
|
||||
return true
|
||||
|
||||
void kMemory_arch_unmap (kMemory *mem, kPage *page, unsigned address):
|
||||
//dbg_log_line ()
|
||||
unsigned didx = address >> 21
|
||||
unsigned tidx = (address >> 12) & ((1 << 9) - 1)
|
||||
unsigned *table = mem->arch.directory[didx]
|
||||
@@ -260,6 +278,7 @@ void kMemory_arch_unmap (kMemory *mem, kPage *page, unsigned address):
|
||||
free_page (t, p)
|
||||
|
||||
kPage *kMemory_arch_get_mapping (kMemory *mem, unsigned address, bool *readonly):
|
||||
//dbg_log_line ()
|
||||
if address >= 0x80000000 || !mem->arch.directory:
|
||||
return NULL
|
||||
unsigned *table = mem->arch.directory[address >> 21]
|
||||
@@ -274,6 +293,7 @@ kPage *kMemory_arch_get_mapping (kMemory *mem, unsigned address, bool *readonly)
|
||||
return page->page
|
||||
|
||||
void kPage_arch_update_mapping (kPage *page):
|
||||
//dbg_log_line ()
|
||||
if !page->arch.first_mapped:
|
||||
return
|
||||
kMemory *as = page->address_space
|
||||
@@ -290,6 +310,11 @@ void kPage_arch_update_mapping (kPage *page):
|
||||
as->arch.directory[de][te] = t
|
||||
tlb_reset (p->mapping & ~1, as->arch.asid, t)
|
||||
|
||||
typedef unsigned cacheline[8]
|
||||
void arch_uncache_page (unsigned page):
|
||||
for cacheline *line = (cacheline *)page; line < (cacheline *)(page + PAGE_SIZE); ++line:
|
||||
__asm__ volatile ("lw $k0, %0; cache 0x10, 0($k0); cache 0x11, 0($k0)" :: "m"(line))
|
||||
|
||||
void arch_register_interrupt (unsigned num, kReceiver *r):
|
||||
arch_interrupt_receiver[num] = r
|
||||
// And enable or disable the interrupt.
|
||||
|
||||
@@ -246,10 +246,8 @@ static void init_threads ():
|
||||
|
||||
// Initialize the kernel, finish by falling into the idle task.
|
||||
void init (unsigned mem):
|
||||
#ifndef NDEBUG
|
||||
// Initialize board-specific things.
|
||||
board_init ()
|
||||
#endif
|
||||
must_wait = false
|
||||
// Initialize kernel variables to empty.
|
||||
unsigned count = init_memory (mem)
|
||||
|
||||
Reference in New Issue
Block a user