本文整理汇总了C++中PADDR函数的典型用法代码示例。如果您正苦于以下问题:C++ PADDR函数的具体用法?C++ PADDR怎么用?C++ PADDR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PADDR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vbesetup
static uint8_t*
vbesetup(Ureg *u, int ax)
{
// Yes, it's a PA, but it's a real mode PA, and 32 bits are fine.
uint32_t pa;
pa = PADDR(RMBUF);
memset(modebuf, 0, sizeof modebuf);
memset(u, 0, sizeof *u);
u->ax = ax;
u->es = (pa>>4)&0xF000;
u->di = pa&0xFFFF;
return modebuf;
}
示例2: residential_enduse
plugload::plugload(MODULE *module) : residential_enduse(module)
{
// first time init
if (oclass==NULL)
{
// register the class definition
oclass = gl_register_class(module,"plugload",sizeof(plugload),PC_BOTTOMUP);
if (oclass==NULL)
throw "unable to register class plugload";
else
oclass->trl = TRL_QUALIFIED;
// publish the class properties
if (gl_publish_variable(oclass,
PT_INHERIT, "residential_enduse",
PT_double,"circuit_split",PADDR(circuit_split),
PT_double,"demand[unit]",PADDR(shape.load),
PT_double,"installed_power[kW]",PADDR(shape.params.analog.power), PT_DESCRIPTION, "installed plugs capacity",
PT_complex,"actual_power[kVA]",PADDR(plugs_actual_power),PT_DESCRIPTION,"actual power demand",
NULL)<1)
GL_THROW("unable to publish properties in %s",__FILE__);
}
}
示例3: switchuvm
// Switch TSS and h/w page table to correspond to process p.
void
switchuvm(struct proc *p)
{
pushcli();
cpu->gdt[SEG_TSS] = SEG16(STS_T32A, &cpu->ts, sizeof(cpu->ts)-1, 0);
cpu->gdt[SEG_TSS].s = 0;
cpu->ts.ss0 = SEG_KDATA << 3;
cpu->ts.esp0 = (uint)proc->kstack + KSTACKSIZE;
ltr(SEG_TSS << 3);
if(p->pgdir == 0)
panic("switchuvm: no pgdir");
lcr3(PADDR(p->pgdir)); // switch to new address space
popcli();
}
示例4: mkmultiboot
void
mkmultiboot(void)
{
MMap *lmmap;
/* reuse the bios table memory */
multibootheader = (Mbi *)KADDR(BIOSTABLES);
memset(multibootheader, 0, sizeof *multibootheader);
lmmap = (MMap *)(multibootheader + 1);
memmove(lmmap, mmap, sizeof mmap);
multibootheader->cmdline = PADDR(BOOTLINE);
multibootheader->flags |= Fcmdline;
if(nmmap != 0){
multibootheader->mmapaddr = PADDR(lmmap);
multibootheader->mmaplength = nmmap*sizeof(MMap);
multibootheader->flags |= Fmmap;
}
multibootheader = (Mbi *)PADDR(multibootheader);
if(v_flag)
print("PADDR(&multibootheader) %#p\n", multibootheader);
}
示例5: page_init
void
page_init(void)
{
int i;
LIST_INIT (&page_free_list);
printf("freemem:\t%x\n", freemem);
freemem = ROUND(freemem, BY2PG);
printf("freemem:\t%x\n", freemem);
for (i = 0; i < PADDR(freemem) / BY2PG; i++) {
pages[i].pp_ref = 1;
}
printf("allocated pages:\t%d\n", i - 1);
for (i = PADDR(freemem) / BY2PG; i < npage; i++) {
pages[i].pp_ref = 0;
LIST_INSERT_HEAD(&page_free_list, &pages[i], pp_link);
}
printf("free pages:\t%d\n", npage - PADDR(freemem) / BY2PG);
}
示例6: shootdown_tlb_all
/* XXX naive */
static void shootdown_tlb_all(pgd_t *pgdir)
{
int i;
//dump_processors();
for(i=0;i<sysconf.lcpu_count;i++){
struct cpu *cpu = per_cpu_ptr(cpus, i);
if(cpu->id == myid())
continue;
if(cpu->arch_data.tlb_cr3 != PADDR(pgdir))
continue;
//kprintf("XX_TLB_SHUTDOWN %d %d\n", myid(), i);
lapic_send_ipi(cpu, T_TLBFLUSH);
}
}
示例7: check_boot_pgdir
static void
check_boot_pgdir(void) {
pte_t *ptep;
int i;
for (i = 0; i < npage; i += PGSIZE) {
assert((ptep = get_pte(boot_pgdir, (uintptr_t)KADDR(i), 0)) != NULL);
assert(PTE_ADDR(*ptep) == i);
}
assert(PDE_ADDR(boot_pgdir[PDX(VPT)]) == PADDR(boot_pgdir));
//cprintf("%08x\n",boot_pgdir[PDX(VPT)]);
//cprintf("%08x\n",PADDR(boot_pgdir));
assert(boot_pgdir[256] == 0);
struct Page *p;
p = alloc_page();
assert(page_insert(boot_pgdir, p, 0x40000100, PTE_TYPE_SRW) == 0);
assert(page_ref(p) == 1);
assert(page_insert(boot_pgdir, p, 0x40000100 + PGSIZE, PTE_TYPE_SRW) == 0);
assert(page_ref(p) == 2);
const char *str = "ucore: Hello world!!";
strcpy((void *)0x40000100, str);
assert(strcmp((void *)0x40000100, (void *)(0x40000100 + PGSIZE)) == 0);
cprintf("%s\n\n",(char*)0x40000100);
//cprintf("mstatus=%08x\n",read_mstatus_field(MSTATUS_PRV));
// cprintf("bageyalusilasiladi%s\n",((char*)0x40000100));
*(char *)(page2kva(p) + 0x100) = '\0';
//asm volatile("nop");
//asm volatile("nop");
//cprintf("\0\n");
// cprintf("%d\n",strlen((char *)0x40000100));
assert(strlen((const char *)0x40000100) == 0);
//assert(((const char *)0x30000100) == '\0');
//asm volatile("nop");
// asm volatile("nop");
free_page(p);
free_page(pde2page(boot_pgdir[256]));
//cprintf("haah2\n");
boot_pgdir[256] = 0;
cprintf("check_boot_pgdir() succeeded!\n");
}
示例8: sdioiosetup
static void
sdioiosetup(int write, void *buf, int bsize, int bcount)
{
int len;
uintptr pa;
pa = PADDR(buf);
if(write && !PIOwrite){
WR(DmaLSB, pa);
WR(DmaMSB, pa>>16);
len = bsize * bcount;
cachedwbse(buf, len);
l2cacheuwbse(buf, len);
}else if(!write && !PIOread){
示例9: link_object
series_reactor::series_reactor(MODULE *mod) : link_object(mod)
{
if(oclass == NULL)
{
pclass = link_object::oclass;
oclass = gl_register_class(mod,"series_reactor",sizeof(series_reactor),PC_PRETOPDOWN|PC_BOTTOMUP|PC_POSTTOPDOWN|PC_UNSAFE_OVERRIDE_OMIT|PC_AUTOLOCK);
if (oclass==NULL)
throw "unable to register class series_reactor";
else
oclass->trl = TRL_PROVEN;
if(gl_publish_variable(oclass,
PT_INHERIT, "link",
PT_complex, "phase_A_impedance[Ohm]",PADDR(phase_A_impedance),PT_DESCRIPTION,"Series impedance of reactor on phase A",
PT_double, "phase_A_resistance[Ohm]",PADDR(phase_A_impedance.Re()),PT_DESCRIPTION,"Resistive portion of phase A's impedance",
PT_double, "phase_A_reactance[Ohm]",PADDR(phase_A_impedance.Im()),PT_DESCRIPTION,"Reactive portion of phase A's impedance",
PT_complex, "phase_B_impedance[Ohm]",PADDR(phase_B_impedance),PT_DESCRIPTION,"Series impedance of reactor on phase B",
PT_double, "phase_B_resistance[Ohm]",PADDR(phase_B_impedance.Re()),PT_DESCRIPTION,"Resistive portion of phase B's impedance",
PT_double, "phase_B_reactance[Ohm]",PADDR(phase_B_impedance.Im()),PT_DESCRIPTION,"Reactive portion of phase B's impedance",
PT_complex, "phase_C_impedance[Ohm]",PADDR(phase_C_impedance),PT_DESCRIPTION,"Series impedance of reactor on phase C",
PT_double, "phase_C_resistance[Ohm]",PADDR(phase_C_impedance.Re()),PT_DESCRIPTION,"Resistive portion of phase C's impedance",
PT_double, "phase_C_reactance[Ohm]",PADDR(phase_C_impedance.Im()),PT_DESCRIPTION,"Reactive portion of phase C's impedance",
PT_double, "rated_current_limit[A]",PADDR(rated_current_limit),PT_DESCRIPTION,"Rated current limit for the reactor",
NULL) < 1) GL_THROW("unable to publish properties in %s",__FILE__);
//Publish deltamode functions
if (gl_publish_function(oclass, "interupdate_pwr_object", (FUNCTIONADDR)interupdate_link)==NULL)
GL_THROW("Unable to publish series reactor deltamode function");
//Publish restoration-related function (current update)
if (gl_publish_function(oclass, "update_power_pwr_object", (FUNCTIONADDR)updatepowercalc_link)==NULL)
GL_THROW("Unable to publish series reactor external power calculation function");
if (gl_publish_function(oclass, "check_limits_pwr_object", (FUNCTIONADDR)calculate_overlimit_link)==NULL)
GL_THROW("Unable to publish series reactor external power limit calculation function");
}
}
示例10: meminit
void
meminit(u32int)
{
MMap *map;
u32int modend;
u64int addr, last, len;
umbscan();
modend = PADDR(memstart);
last = 0;
for(map = mmap; map < &mmap[nmmap]; map++){
addr = (((u64int)map->base[1])<<32)|map->base[0];
len = (((u64int)map->length[1])<<32)|map->length[0];
switch(map->type){
default:
case 2: /* reserved */
case 3: /* ACPI Reclaim Memory */
case 4: /* ACPI NVS Memory */
break;
case 1: /* Memory */
if(addr < 1*MiB || addr+len < modend)
break;
if(addr < modend){
len -= modend - addr;
addr = modend;
}
mapraminit(addr, len);
break;
}
if(addr != last && addr > modend){
/*
* See the comments in main about space < 1MiB.
*/
if(addr >= 1*MiB || addr < 0x000A0000)
mapupainit(last, addr-last);
}
last = addr+len;
}
/*
changeconf("*noe820scan=1\n");
*/
if(MEMDEBUG)
memdebug();
}
示例11: mmuptpalloc
static Page*
mmuptpalloc(void)
{
void* va;
Page *page;
/*
* Do not really need a whole Page structure,
* but it makes testing this out a lot easier.
* Could keep a cache and free excess.
* Have to maintain any fiction for pexit?
*/
lock(&mmuptpfreelist.l);
if((page = mmuptpfreelist.next) != nil) {
mmuptpfreelist.next = page->next;
mmuptpfreelist.ref--;
unlock(&mmuptpfreelist.l);
if(page->ref++ != 0)
panic("mmuptpalloc ref\n");
page->prev = page->next = nil;
memset(UINT2PTR(page->va), 0, PTSZ);
if(page->pa == 0)
panic("mmuptpalloc: free page with pa == 0");
return page;
}
unlock(&mmuptpfreelist.l);
if((page = malloc(sizeof(Page))) == nil) {
print("mmuptpalloc Page\n");
return nil;
}
if((va = mallocalign(PTSZ, PTSZ, 0, 0)) == nil) {
print("mmuptpalloc va\n");
free(page);
return nil;
}
page->va = PTR2UINT(va);
page->pa = PADDR(va);
page->ref = 1;
if(page->pa == 0)
panic("mmuptpalloc: no pa");
return page;
}
示例12: initialize_vm_64
void initialize_vm_64(void){
uint64_t* pml4e;
pages = boot_alloc(npages*sizeof(struct PageStruct));
procs = boot_alloc(NPROCS*sizeof(struct ProcStruct));
proc_free_list = procs;
pml4e = boot_alloc(PGSIZE);
boot_pml4e = pml4e;
boot_cr3 = (physaddr_t*)PADDR(pml4e);
kmemset(boot_pml4e,0,PGSIZE);
initialize_page_lists();
printf("Total free=%d",free_pages);
// while(i--);
if( map_vm_pm(boot_pml4e, (uint64_t)PHYSBASE,PADDR(PHYSBASE),(uint64_t)(boot_alloc(0)-PHYSBASE),PTE_P|PTE_W)==-1)
while(1);
if( map_vm_pm(boot_pml4e, (uint64_t)KERNBASE+PGSIZE,0x1000,0x7000000-0x1000,PTE_P|PTE_W)==-1)//KERNELSTACK =tss.rspp0
while(1);
if( map_vm_pm(boot_pml4e, (uint64_t)VIDEO_START,PADDR(VIDEO_START),10*0x1000,PTE_P|PTE_W)==-1)
while(1);
printf("TotalFREE=%d",free_pages);
lcr3(boot_cr3);
}
示例13: test_tx_blocks
//test function to see if the Tx Buffers are properly linked.
void test_tx_blocks()
{
uint32_t start = e100_tx_info.tx_buff_va;
struct command_block * ptrcb;
int i ;
cprintf(" base va %x base Pa %x \n",start,PADDR(start));
cprintf("\n=====================================\n");
for ( i=0; i < E100_MAX_TX_BUFFERS ; i++)
{
ptrcb =(struct command_block * ) ( start + i * PGSIZE ) ;
cprintf(" [%d] : status %d , cmd : %d , link : %x \n",i,ptrcb->status,ptrcb->cmd,ptrcb->link);
}
cprintf("\n=====================================\n");
}
示例14: ohci_rtl8652_init
static int ohci_rtl8652_init(void)
{
/*register platform device*/
int retval;
//static struct platform_device *usb_dev_host = NULL;
if(usb_dev_host!=NULL)
{ printk("Ohci-rtl8652.c: OHCI device already init\n");
return -1;
}
struct resource r[2];
memset(&r, 0, sizeof(r));
r[0].start = PADDR(OHCI_RTL8652_USB_BASE);
r[0].end = PADDR(OHCI_RTL8652_USB_BASE)+sizeof(struct ohci_regs);
r[0].flags = IORESOURCE_MEM;
r[1].start = r[1].end = RTL8652_USB_IRQ;
r[1].flags = IORESOURCE_IRQ;
usb_dev_host = platform_device_register_simple("rtl8652-ohci", 0, r, 2);
usb_dev_host->dev.coherent_dma_mask = 0xffffffffUL;
usb_dev_host->dev.dma_mask = &usb_dev_host->dev.coherent_dma_mask;
if (IS_ERR(usb_dev_host))
{
retval = PTR_ERR(usb_dev_host);
usb_dev_host=NULL; //wei add
goto err;
}
return 0;
err:
return retval;
}
示例15: env_free
//
// Frees env e and all memory it uses.
//
void
env_free(struct Env *e)
{
pde_t *pgdir;
pte_t *pt;
uint32_t pdeno, pteno;
physaddr_t pa;
// If freeing the current environment, switch to kern_pgdir
// before freeing the page directory, just in case the page
// gets reused.
if (e == curenv)
lcr3(PADDR(kern_pgdir));
// Note the environment's demise.
cprintf("[%08x] free env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
// Flush all mapped pages in the user portion of the address space
static_assert(UTOP % PTSIZE == 0);
pgdir = e->env_pgdir;
for (pdeno = 0; pdeno < PDX(UTOP); pdeno++) {
// only look at mapped page tables
if (!(pgdir[pdeno] & PTE_P))
continue;
// find the pa and va of the page table
pt = (pte_t *) KADDR(PTE_ADDR(pgdir[pdeno]));
// unmap all PTEs in this page table
for (pteno = 0; pteno <= PTX(~0); pteno++) {
if (pt[pteno] & PTE_P)
page_remove(pgdir, PGADDR(pdeno, pteno, 0));
}
// free the page table itself
pgdir[pdeno] = 0;
page_decref(kva2page(pt));
}
// free the page directory
e->env_pgdir = 0;
page_decref(kva2page(pgdir));
// return the environment to the free list
e->env_status = ENV_FREE;
e->env_link = env_free_list;
env_free_list = e;
}