Exemple #1
0
void mem_initialize(void)
{
	u32 cr;
	u32 cookie = irq_kill();

	gecko_printf("MEM: cleaning up\n");

	_ic_inval();
	_dc_inval();
	_tlb_inval();

	gecko_printf("MEM: unprotecting memory\n");

	mem_protect(0,NULL,NULL);

	gecko_printf("MEM: mapping sections\n");

	memset32(__page_table, 0, 16384);

	map_section(0x000, 0x000, 0x018, WRITEBACK_CACHE | DOMAIN(0) | AP_RWUSER);
	map_section(0x100, 0x100, 0x040, WRITEBACK_CACHE | DOMAIN(0) | AP_RWUSER);
	map_section(0x0d0, 0x0d0, 0x001, NONBUFFERABLE | DOMAIN(0) | AP_RWUSER);
	map_section(0x0d8, 0x0d8, 0x001, NONBUFFERABLE | DOMAIN(0) | AP_RWUSER);
	map_section(0xfff, 0xfff, 0x001, WRITEBACK_CACHE | DOMAIN(0) | AP_RWUSER);

	set_dacr(0xFFFFFFFF); //manager access for all domains, ignore AP
	set_ttbr((u32)__page_table); //configure translation table

	_drain_write_buffer();

	cr = get_cr();

#ifndef NO_CACHES
	gecko_printf("MEM: enabling caches\n");

	cr |= CR_DCACHE | CR_ICACHE;
	set_cr(cr);

	gecko_printf("MEM: enabling MMU\n");

	cr |= CR_MMU;
	set_cr(cr);
#endif

	gecko_printf("MEM: init done\n");

	irq_restore(cookie);
}
/* cpd_deallocate_domain: Insures all CPD entries owned by 'domain_p' are
 *   removed from CPD and the domain is deallocated.
 * Assumptions:
 *   - domain_p != NULL.
 *   - domain_p->region_p != NULL;
 *   - TLBs coherent, ie no TLB entries tagged with this domain.
 * Notes:
 *   - Should domain and region pointer updates be atomic?
 */
void
cpd_deallocate_domain(struct domain_struct* domain_p)
{
	int i;
	pmd_t* cpd_p = pmd_offset(pgd_offset_k(0), 0); /* Get CPD Address */
	struct cpd_struct* cpd_stat_p;

	//printk("** cpd_deallocate_domain: %d **\n", domain_p->number);

	/* Loop through CPD entries used by this domain */
	for (cpd_stat_p = domain_p->cpd_head; cpd_stat_p != NULL;
	     cpd_stat_p = cpd_stat_p->cpd_next) {

		i = STATS_P_TO_INDEX(cpd_stat_p);

		/* Update CPD */
		cpu_set_pmd(cpd_p + i, __pmd(0));

		/* Update domain_p */
		domain_p->cpd_count--;
	}

	/* Remove deallocate domain from address-space context */

	domain_p->cpd_head = NULL;
	domain_p->region_p->domain_p = NULL;
	domain_p->region_p = NULL;

#if LAZY_DISABLE
	/* Update the domain clock since we deallocated a domain */
	domain_clock++;
#endif

	//dump_cpd(1);

	set_dacr(current->thread.dacr);
     
}