From owner-p4-projects@FreeBSD.ORG Tue Sep 9 13:18:58 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D76481065677; Tue, 9 Sep 2008 13:18:57 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98CF91065670 for ; Tue, 9 Sep 2008 13:18:57 +0000 (UTC) (envelope-from raj@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 8AA9B8FC13 for ; Tue, 9 Sep 2008 13:18:57 +0000 (UTC) (envelope-from raj@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m89DIvbb019007 for ; Tue, 9 Sep 2008 13:18:57 GMT (envelope-from raj@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m89DIvOc019001 for perforce@freebsd.org; Tue, 9 Sep 2008 13:18:57 GMT (envelope-from raj@freebsd.org) Date: Tue, 9 Sep 2008 13:18:57 GMT Message-Id: <200809091318.m89DIvOc019001@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to raj@freebsd.org using -f From: Rafal Jaworowski To: Perforce Change Reviews Cc: Subject: PERFORCE change 149474 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2008 13:18:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=149474 Change 149474 by raj@raj_mimi on 2008/09/09 13:18:50 Dynamically calculate the number of required L2 tables in initarm(). This lets the mv_machdep.c better handle varying sizes of system DRAM. Obtained from: Marvell, Semihalf Affected files ... .. //depot/projects/arm/src/sys/arm/mv/mv_machdep.c#3 edit Differences ... ==== //depot/projects/arm/src/sys/arm/mv/mv_machdep.c#3 (text+ko) ==== @@ -89,8 +89,12 @@ #define KERNEL_PT_SYS 0 /* Page table for mapping proc0 zero page */ #define KERNEL_PT_KERN 1 -/* This should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */ -#define NUM_KERNEL_PTS 8 +/* + * This is the number of L2 page tables required for covering max + * (hypothetical) memsize of 4GB and all kernel mappings (vectors, msgbuf, + * stacks etc.), uprounded to be divisible by 4. + */ +#define KERNEL_PT_MAX 78 /* Define various stack sizes in pages */ #define IRQ_STACK_SIZE 1 @@ -104,7 +108,7 @@ extern const struct pmap_devmap *pmap_devmap_bootstrap_table; extern vm_offset_t pmap_bootstrap_lastaddr; -struct pv_addr kernel_pt_table[NUM_KERNEL_PTS]; +struct pv_addr kernel_pt_table[KERNEL_PT_MAX]; extern void *_end; extern int *end; @@ -136,7 +140,7 @@ vm_offset_t freemempos; vm_offset_t l2_start; vm_offset_t lastaddr; - uint32_t memsize; + uint32_t memsize, l2size; boothowto = RB_VERBOSE | RB_SINGLE; @@ -150,6 +154,21 @@ pcpu_init(pcpup, 0, sizeof(struct pcpu)); PCPU_SET(curthread, &thread0); + memsize = platform_ramsize(); + + /* Calculate number of L2 tables needed for mapping vm_page_array */ + l2size = (memsize / PAGE_SIZE) * sizeof(struct vm_page); + l2size = (l2size >> L1_S_SHIFT) + 1; + + /* + * Add one table for end of kernel map, one for stacks, msgbuf and + * L1 and L2 tables map and one for vectors map. + */ + l2size += 3; + + /* Make it divisible by 4 */ + l2size = (l2size + 3) & ~3; + #define KERNEL_TEXT_BASE (KERNBASE) freemempos = (lastaddr + PAGE_MASK) & ~PAGE_MASK; @@ -167,7 +186,7 @@ freemempos += PAGE_SIZE; valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE); - for (i = 0; i < NUM_KERNEL_PTS; ++i) { + for (i = 0; i < l2size; ++i) { if (!(i % (PAGE_SIZE / L2_TABLE_SIZE_REAL))) { valloc_pages(kernel_pt_table[i], L2_TABLE_SIZE / PAGE_SIZE); @@ -210,11 +229,11 @@ * and kernel structures */ l2_start = lastaddr & ~(L1_S_OFFSET); - for (i = 0 ; i < NUM_KERNEL_PTS - 1; i++) + for (i = 0 ; i < l2size - 1; i++) pmap_link_l2pt(l1pagetable, l2_start + i * L1_S_SIZE, &kernel_pt_table[KERNEL_PT_KERN + i]); - pmap_curmaxkvaddr = l2_start + NUM_KERNEL_PTS * L1_S_SIZE; + pmap_curmaxkvaddr = l2_start + (l2size - 1) * L1_S_SIZE; /* Map kernel code and data */ pmap_map_chunk(l1pagetable, KERNVIRTADDR, KERNPHYSADDR, @@ -228,7 +247,7 @@ pmap_map_chunk(l1pagetable, kernel_pt_table[0].pv_va, kernel_pt_table[0].pv_pa, - L2_TABLE_SIZE_REAL * NUM_KERNEL_PTS, + L2_TABLE_SIZE_REAL * l2size, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE); /* Map allocated stacks and msgbuf */ @@ -249,7 +268,6 @@ cpu_tlb_flushID(); cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)); cninit(); - memsize = platform_ramsize(); physmem = memsize / PAGE_SIZE; /*