📄 cpu_syspage_memory.c
字号:
/* * $QNXLicenseC: * Copyright 2007, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software except in * compliance with the License. You may obtain a copy of the License * at: http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ */#include "startup.h"//// Initialize CPU specific pointers in the system page.// This code is hardware independant and should not have to be// changed by end users.//voidcpu_init_syspage_memory() { set_syspage_section(&lsp.cpu.ppc_kerinfo, sizeof(*lsp.cpu.ppc_kerinfo.p));}struct syspage_entry *cpu_alloc_syspage_memory(paddr32_t *cpupagep, paddr32_t *syspagep, unsigned spsize) { struct syspage_entry *sp = lsp.syspage.p; struct system_private_entry *private = lsp.system_private.p; unsigned size; unsigned cpsize; paddr32_t syspage_paddr; paddr32_t cpupage_paddr; #define SP_OFFSET(field) PTR_DIFF(lsp.cpu.field.p, sp) #define INIT_ENTRY(_cpu,_field) \ sp->un._cpu._field.entry_size = lsp.cpu._cpu##_##_field.size; \ sp->un._cpu._field.entry_off = SP_OFFSET(_cpu##_##_field) // // Allocate the system page (and cpupage entries) and save it away. // The system page must be 4K aligned in a virtual system. // spsize = ROUND(spsize, private->pagesize); syspage_paddr = alloc_ram(NULL_PADDR, spsize, private->pagesize); if(syspage_paddr == NULL_PADDR32) { crash("could not allocate 0x%l bytes for syspage\n", spsize); } if(sp->num_cpu != 1) { // We're going to use a BAT register to map the cpupage entries // when we have more than one CPU. Have to align the memory // on a 128K boundry & spacing (that's the smallest a BAT can map). cpsize = KILO(128); } else if(shdr->flags1 & STARTUP_HDR_FLAGS1_VIRTUAL) { cpsize = ROUNDPG(sizeof(struct cpupage_entry)); } else { cpsize = sizeof(struct cpupage_entry); } size = sp->num_cpu * cpsize; cpupage_paddr = alloc_ram(NULL_PADDR, size, cpsize); if((cpupage_paddr == NULL_PADDR32) || (cpupage_paddr > MEG(256))) { crash("could not allocate 0x%l bytes for cpupage\n", size); } // // Have to reload private again since the alloc_ram's above may // have moved the sections around in memory. // private = lsp.system_private.p; private->user_syspageptr = TOPTR(syspage_paddr); private->kern_syspageptr = TOPTR(syspage_paddr); private->user_cpupageptr = TOPTR(cpupage_paddr); private->kern_cpupageptr = TOPTR(cpupage_paddr); private->cpupage_spacing = cpsize; *syspagep = syspage_paddr; *cpupagep = cpupage_paddr; INIT_ENTRY(ppc,boxinfo); INIT_ENTRY(ppc,kerinfo); INIT_ENTRY(ppc,smpinfo); INIT_ENTRY(ppc,tlbinfo); return((void *)syspage_paddr);}voidcpu_write_syspage_memory(paddr32_t sysp_paddr, unsigned sysp_size, unsigned callout_size) { /* * Flush the system page out of the dcache & icache so that callouts * are executed properly */ for(sysp_size += callout_size; sysp_size != 0; sysp_paddr += 4, sysp_size -= 4) { icache_flush(sysp_paddr); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -