本文整理汇总了C++中ptoa函数的典型用法代码示例。如果您正苦于以下问题:C++ ptoa函数的具体用法?C++ ptoa怎么用?C++ ptoa使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ptoa函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cpu_startup
static void
cpu_startup(void *dummy)
{
/*
* Initialise the decrementer-based clock.
*/
decr_init();
/*
* Good {morning,afternoon,evening,night}.
*/
cpu_setup(PCPU_GET(cpuid));
#ifdef PERFMON
perfmon_init();
#endif
printf("real memory = %ju (%ju MB)\n", ptoa((uintmax_t)physmem),
ptoa((uintmax_t)physmem) / 1048576);
realmem = physmem;
if (bootverbose)
printf("available KVA = %zu (%zu MB)\n",
virtual_end - virtual_avail,
(virtual_end - virtual_avail) / 1048576);
/*
* Display any holes after the first chunk of extended memory.
*/
if (bootverbose) {
int indx;
printf("Physical memory chunk(s):\n");
for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
vm_paddr_t size1 =
phys_avail[indx + 1] - phys_avail[indx];
#ifdef __powerpc64__
printf("0x%016jx - 0x%016jx, %jd bytes (%jd pages)\n",
#else
printf("0x%09jx - 0x%09jx, %ju bytes (%ju pages)\n",
#endif
(uintmax_t)phys_avail[indx],
(uintmax_t)phys_avail[indx + 1] - 1,
(uintmax_t)size1, (uintmax_t)size1 / PAGE_SIZE);
}
}
vm_ksubmap_init(&kmi);
printf("avail memory = %ju (%ju MB)\n",
ptoa((uintmax_t)vm_cnt.v_free_count),
ptoa((uintmax_t)vm_cnt.v_free_count) / 1048576);
/*
* Set up buffers, so they can be used to read disk labels.
*/
bufinit();
vm_pager_bufferinit();
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:60,代码来源:machdep.c
示例2: check_phdr
/*
* Prevent loading a kernel if it would overlap the SRM.
*/
int
check_phdr(void *hdr)
{
Elf64_Phdr *phdr = (Elf64_Phdr *)hdr;
struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR;
struct mddt *mddtp;
struct mddt_cluster *memc;
u_int64_t cstart, cend;
u_int64_t i;
mddtp = (struct mddt *)(((caddr_t)hwrpb) + hwrpb->rpb_memdat_off);
for (i = 0; i < mddtp->mddt_cluster_cnt; i++) {
memc = &mddtp->mddt_clusters[i];
if (memc->mddt_usage & MDDT_PALCODE) {
cstart = ALPHA_PHYS_TO_K0SEG(ptoa(memc->mddt_pfn));
cend = cstart + ptoa(memc->mddt_pg_cnt);
if (phdr->p_vaddr + phdr->p_memsz <= cstart ||
phdr->p_vaddr >= cend)
continue;
printf("SRM console and kernel image would overlap.\n"
"Please report this to <[email protected]>, "
"with the following values:\n"
"SRM range: %p-%p\n"
"kernel range: %p-%p\n",
cstart, cend, phdr->p_vaddr,
phdr->p_vaddr + phdr->p_memsz);
return 1;
}
}
return 0;
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:37,代码来源:loadfile_subr.c
示例3: sh_startup
void
sh_startup()
{
vaddr_t minaddr, maxaddr;
printf("%s", version);
if (*cpu_model != '\0')
printf("%s\n", cpu_model);
#ifdef DEBUG
printf("general exception handler:\t%d byte\n",
sh_vector_generic_end - sh_vector_generic);
printf("TLB miss exception handler:\t%d byte\n",
#if defined(SH3) && defined(SH4)
CPU_IS_SH3 ? sh3_vector_tlbmiss_end - sh3_vector_tlbmiss :
sh4_vector_tlbmiss_end - sh4_vector_tlbmiss
#elif defined(SH3)
sh3_vector_tlbmiss_end - sh3_vector_tlbmiss
#elif defined(SH4)
sh4_vector_tlbmiss_end - sh4_vector_tlbmiss
#endif
);
printf("interrupt exception handler:\t%d byte\n",
sh_vector_interrupt_end - sh_vector_interrupt);
#endif /* DEBUG */
printf("real mem = %u (%uMB)\n", ptoa(physmem),
ptoa(physmem) / 1024 / 1024);
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
minaddr = vm_map_min(kernel_map);
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
/*
* Allocate a submap for physio
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, FALSE, NULL);
/*
* Set up buffers, so they can be used to read disk labels.
*/
bufinit();
printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free),
ptoa(uvmexp.free) / 1024 / 1024);
if (boothowto & RB_CONFIG) {
#ifdef BOOT_CONFIG
user_config();
#else
printf("kernel does not support -c; continuing..\n");
#endif
}
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:58,代码来源:sh_machdep.c
示例4: cpu_startup
void
cpu_startup()
{
vaddr_t minaddr, maxaddr;
/*
* Good {morning,afternoon,evening,night}.
*/
printf(version);
printf("real mem = %lu (%luMB)\n", ptoa(physmem),
ptoa(physmem)/1024/1024);
/*
* Grab machine dependent memory spaces
*/
platform->startup();
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
minaddr = vm_map_min(kernel_map);
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
/*
* Allocate map for physio.
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, FALSE, NULL);
printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free),
ptoa(uvmexp.free)/1024/1024);
/*
* Set up buffers, so they can be used to read disk labels.
*/
bufinit();
/*
* Configure the system.
*/
if (boothowto & RB_CONFIG) {
#ifdef BOOT_CONFIG
user_config();
#else
printf("kernel does not support -c; continuing..\n");
#endif
}
}
开发者ID:toddfries,项目名称:OpenBSD-sys-patches,代码行数:50,代码来源:machdep.c
示例5: rbus_min_start_hint
/*
* Dynamically set the start address for rbus. This must be called
* before rbus is initialized. The start address should be determined
* by the amount of installed memory. Generally 1 GB has been found
* to be a good value, but it fails on some Thinkpads (e.g. 2645-4AU),
* for which 0.5 GB is a good value. It also fails on (at least)
* Thinkpads with 2GB of RAM, for which 2 GB is a good value.
*
* Thus, a general strategy of setting rbus_min_start to the amount of
* memory seems in order. However, the actual amount of memory is
* generally slightly more than the amount found, e.g. 1014MB vs 1024,
* or 2046 vs 2048.
*/
bus_addr_t
rbus_min_start_hint(void)
{
bus_addr_t rbus_min_start = RBUS_MIN_START;
size_t ram = ptoa(physmem);
if (ram <= 192 * 1024 * 1024UL) {
/*
* <= 192 MB, so try 0.5 GB. This will work on
* Thinkpad 600E (2645-4AU), which fails at 1 GB, and
* on some other older machines that may have trouble
* with addresses needing more than 20 bits.
*/
rbus_min_start = 512 * 1024 * 1024UL;
}
if (ram >= 1024 * 1024 * 1024UL) {
/*
* > 1 GB, so try 2 GB.
*/
rbus_min_start = 2 * 1024 * 1024 * 1024UL;
}
/* Not tested in > 2 GB case. */
if (ram > 2 * 1024 * 1024 * 1024UL) {
/*
* > 2 GB, so try 3 GB.
*/
rbus_min_start = 3 * 1024 * 1024 * 1024UL;
}
return (rbus_min_start);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:46,代码来源:rbus_machdep.c
示例6: vm_mem_bootstrap
void
vm_mem_bootstrap(void)
{
vm_offset_t start, end;
/*
* Initializes resident memory structures.
* From here on, all physical memory is accounted for,
* and we use only virtual addresses.
*/
vm_page_bootstrap(&start, &end);
/*
* Initialize other VM packages
*/
zone_bootstrap();
vm_object_bootstrap();
vm_map_init();
kmem_init(start, end);
pmap_init();
zone_init((vm_size_t)ptoa(vm_page_free_count));
kalloc_init();
#if MACH_RT
rtalloc_init();
#endif /* MACH_RT */
vm_fault_init();
vm_page_module_init();
memory_manager_default_init();
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:31,代码来源:vm_init.c
示例7: drm_mmap
int drm_mmap(struct dev_mmap_args *ap)
{
struct cdev *kdev = ap->a_head.a_dev;
vm_offset_t offset = ap->a_offset;
struct drm_device *dev = drm_get_device_from_kdev(kdev);
struct drm_file *file_priv = NULL;
drm_local_map_t *map;
enum drm_map_type type;
vm_paddr_t phys;
DRM_LOCK();
file_priv = drm_find_file_by_proc(dev, DRM_CURPROC);
DRM_UNLOCK();
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return EINVAL;
}
if (!file_priv->authenticated)
return EACCES;
if (dev->dma && offset < ptoa(dev->dma->page_count)) {
drm_device_dma_t *dma = dev->dma;
DRM_SPINLOCK(&dev->dma_lock);
if (dma->pagelist != NULL) {
unsigned long page = offset >> PAGE_SHIFT;
unsigned long phys = dma->pagelist[page];
ap->a_result = atop(phys);
DRM_SPINUNLOCK(&dev->dma_lock);
return 0;
} else {
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:34,代码来源:drm_vm.c
示例8: dumpconf
/*
* This is called by configure to set dumplo and dumpsize.
* Dumps always skip the first PAGE_SIZE of disk space
* in case there might be a disk label stored there.
* If there is extra space, put dump at the end to
* reduce the chance that swapping trashes it.
*/
void
dumpconf(void)
{
int nblks; /* size of dump area */
if (dumpdev == NODEV ||
(nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0)
return;
if (nblks <= ctod(1))
return;
dumpsize = physmem;
/* aviion only uses a single segment. */
cpu_kcore_hdr.ram_segs[0].start = 0;
cpu_kcore_hdr.ram_segs[0].size = ptoa(physmem);
cpu_kcore_hdr.cputype = cputyp;
/*
* Don't dump on the first block
* in case the dump device includes a disk label.
*/
if (dumplo < ctod(1))
dumplo = ctod(1);
/* Put dump at end of partition, and make it fit. */
if (dumpsize + 1 > dtoc(nblks - dumplo))
dumpsize = dtoc(nblks - dumplo) - 1;
if (dumplo < nblks - ctod(dumpsize) - 1)
dumplo = nblks - ctod(dumpsize) - 1;
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:38,代码来源:machdep.c
示例9: drmmmap
paddr_t
drmmmap(dev_t kdev, off_t offset, int prot)
{
struct drm_device *dev = drm_get_device_from_kdev(kdev);
drm_local_map_t *map;
struct drm_file *priv;
drm_map_type_t type;
paddr_t phys;
DRM_LOCK();
priv = drm_find_file_by_minor(dev, minor(kdev));
DRM_UNLOCK();
if (priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return (EINVAL);
}
if (!priv->authenticated)
return (EACCES);
if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
drm_device_dma_t *dma = dev->dma;
DRM_SPINLOCK(&dev->dma_lock);
if (dma->pagelist != NULL) {
unsigned long page = offset >> PAGE_SHIFT;
unsigned long phys = dma->pagelist[page];
DRM_SPINUNLOCK(&dev->dma_lock);
return (atop(phys));
} else {
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:32,代码来源:drm_vm.c
示例10: drm_mmap
paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
{
DRM_DEVICE;
drm_local_map_t *map;
drm_file_t *priv;
drm_map_type_t type;
paddr_t phys;
uintptr_t roffset;
DRM_LOCK();
priv = drm_find_file_by_proc(dev, DRM_CURPROC);
DRM_UNLOCK();
if (priv == NULL) {
DRM_ERROR("can't find authenticator\n");
return -1;
}
if (!priv->authenticated)
return -1;
if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) {
drm_device_dma_t *dma = dev->dma;
DRM_SPINLOCK(&dev->dma_lock);
if (dma->pagelist != NULL) {
unsigned long page = offset >> PAGE_SHIFT;
unsigned long pphys = dma->pagelist[page];
#ifdef macppc
return pphys;
#else
return atop(pphys);
#endif
} else {
开发者ID:Tommmster,项目名称:netbsd-avr32,代码行数:35,代码来源:drm_vm.c
示例11: cpu_uarea_alloc
void *
cpu_uarea_alloc(bool system)
{
struct pglist pglist;
int error;
/*
* Allocate a new physically contiguous uarea which can be
* direct-mapped.
*/
error = uvm_pglistalloc(USPACE, 0, ptoa(physmem), 0, 0, &pglist, 1, 1);
if (error) {
return NULL;
}
/*
* Get the physical address from the first page.
*/
const struct vm_page * const pg = TAILQ_FIRST(&pglist);
KASSERT(pg != NULL);
const paddr_t pa = VM_PAGE_TO_PHYS(pg);
/*
* We need to return a direct-mapped VA for the pa.
*/
return (void *)PMAP_MAP_POOLPAGE(pa);
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:28,代码来源:vm_machdep.c
示例12: cpu_startup
/*
* cpu_startup: allocate memory for variable-sized tables,
* initialize CPU, and do autoconfiguration.
*/
void
cpu_startup(void)
{
vaddr_t minaddr, maxaddr;
#ifdef DEBUG
extern int pmapdebug;
int opmapdebug = pmapdebug;
pmapdebug = 0;
#endif
cpu_setmodel("FIC8234");
if (fputype != FPU_NONE)
m68k_make_fpu_idle_frame();
/*
* Good {morning,afternoon,evening,night}.
*/
printf("%s%s", copyright, version);
identifycpu();
printf("real mem = %d\n", ctob(physmem));
minaddr = 0;
/*
* Allocate a submap for physio
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, false, NULL);
#ifdef DEBUG
pmapdebug = opmapdebug;
#endif
printf("avail mem = %ld\n", ptoa(uvmexp.free));
}
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:39,代码来源:machdep.c
示例13: cpu_startup
/*
* Allocate memory for variable-sized tables,
*/
void
cpu_startup(void)
{
vaddr_t minaddr, maxaddr;
char pbuf[9];
/*
* Good {morning,afternoon,evening,night}.
*/
printf("%s%s", copyright, version);
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
printf("total memory = %s\n", pbuf);
minaddr = 0;
/*
* Allocate a submap for physio.
*/
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE,
0, false, NULL);
/*
* (No need to allocate an mbuf cluster submap. Mbuf clusters
* are allocated via the pool allocator, and we use KSEG to
* map those pages.)
*/
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:33,代码来源:machdep.c
示例14: dumpconf
void
dumpconf(void)
{
int nblks, block;
if (dumpdev == NODEV ||
(nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0)
return;
if (nblks <= ctod(1))
return;
dumpsize = physmem;
/* Always skip the first CLBYTES, in case there is a label there. */
if (dumplo < ctod(1))
dumplo = ctod(1);
/* Put dump at end of partition, and make it fit. */
if (dumpsize + 1 > dtoc(nblks - dumplo))
dumpsize = dtoc(nblks - dumplo) - 1;
if (dumplo < nblks - ctod(dumpsize) - 1)
dumplo = nblks - ctod(dumpsize) - 1;
for (block = 0; block < bootconfig.dramblocks; block++) {
cpu_kcore_hdr.ram_segs[block].start =
bootconfig.dram[block].address;
cpu_kcore_hdr.ram_segs[block].size =
ptoa(bootconfig.dram[block].pages);
}
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:30,代码来源:stubs.c
示例15: mmmmap
paddr_t
mmmmap(dev_t dev, off_t off, int prot)
{
struct proc *p = curproc; /* XXX */
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
if ((u_int)off > ptoa(physmem) && suser(p) != 0)
return -1;
return off;
#ifdef APERTURE
/* minor device 4 is aperture driver */
case 4:
/* Check if a write combining mapping is requested. */
if (off >= MEMRANGE_WC_RANGE)
off = (off - MEMRANGE_WC_RANGE) | PMAP_WC;
switch (allowaperture) {
case 1:
/* Allow mapping of the VGA framebuffer & BIOS only */
if ((off >= VGA_START && off <= BIOS_END) ||
(unsigned)off > (unsigned)ptoa(physmem))
return off;
else
return -1;
case 2:
case 3:
/* Allow mapping of the whole 1st megabyte
for x86emu */
if (off <= BIOS_END ||
(unsigned)off > (unsigned)ptoa(physmem))
return off;
else
return -1;
default:
return -1;
}
#endif
default:
return -1;
}
}
开发者ID:bluhm,项目名称:sys,代码行数:45,代码来源:mem.c
示例16: default_pager_info
kern_return_t
default_pager_info(
mach_port_t pager,
default_pager_info_t *infop)
{
vm_size_t pages_total, pages_free;
if (pager != default_pager_default_port)
return KERN_INVALID_ARGUMENT;
bs_global_info(&pages_total, &pages_free);
infop->dpi_total_space = ptoa(pages_total);
infop->dpi_free_space = ptoa(pages_free);
infop->dpi_page_size = vm_page_size;
return KERN_SUCCESS;
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:18,代码来源:default_pager.c
示例17: cpu_init_kcore_hdr
/*
* Fill the machine-dependent dump header.
*/
void
cpu_init_kcore_hdr()
{
extern cpu_kcore_hdr_t cpu_kcore_hdr;
cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
phys_ram_seg_t *seg = cpu_kcore_hdr.kcore_segs;
struct vm_physseg *physseg = vm_physmem;
u_int i;
bzero(h, sizeof(*h));
h->kcore_nsegs = min(NPHYS_RAM_SEGS, (u_int)vm_nphysseg);
for (i = h->kcore_nsegs; i != 0; i--) {
seg->start = ptoa(physseg->start);
seg->size = (psize_t)ptoa(physseg->end - physseg->start);
seg++;
physseg++;
}
}
开发者ID:toddfries,项目名称:OpenBSD-sys-patches,代码行数:22,代码来源:machdep.c
示例18: cpu_startup
void
cpu_startup(void)
{
extern int physmem;
extern struct vm_map *mb_map;
vaddr_t minaddr, maxaddr;
char pbuf[9];
printf("%s%s", copyright, version);
format_bytes(pbuf, sizeof(pbuf), ptoa(physmem));
printf("total memory = %s\n", pbuf);
minaddr = 0;
mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL);
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:19,代码来源:cpu.c
示例19: iomap_init
/*
* Initialize the external I/O extent map.
*/
void
iomap_init(void)
{
/* extiobase is initialized by pmap_bootstrap(). */
extio_ex = extent_create("extio", (u_long) extiobase,
(u_long) extiobase + (ptoa(EIOMAPSIZE) - 1), M_DEVBUF,
(void *) extio_ex_storage, sizeof(extio_ex_storage),
EX_NOCOALESCE|EX_NOWAIT);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:13,代码来源:autoconf.c
示例20: pmap_bootstrap_md
vaddr_t
pmap_bootstrap_md(vaddr_t vaddr)
{
/*
* Get ethernet buffer - need ETHERPAGES pages physically contiguous
* below 16MB.
*/
if (vaddr < 0x01000000 - ptoa(ETHERPAGES)) {
etherlen = ptoa(ETHERPAGES);
etherbuf = (void *)vaddr;
vaddr = pmap_map(vaddr, avail_start, avail_start + etherlen,
UVM_PROT_RW, CACHE_INH);
virtual_avail += etherlen;
avail_start += etherlen;
}
return vaddr;
}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:20,代码来源:pmap_bootstrap.c
注:本文中的ptoa函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论