本文整理汇总了C++中dbtob函数的典型用法代码示例。如果您正苦于以下问题:C++ dbtob函数的具体用法?C++ dbtob怎么用?C++ dbtob使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbtob函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lqfs_initialize
static int
lqfs_initialize(qfsvfs_t *qfsvfsp, daddr_t bno, int ord, size_t nb,
struct fiolog *flp)
{
ml_odunit_t *ud, *ud2;
buf_t *bp;
timeval_lqfs_common_t tv;
int error = 0;
/* LINTED: warning: logical expression always true: op "||" */
ASSERT(sizeof (ml_odunit_t) < DEV_BSIZE);
ASSERT(nb >= ldl_minlogsize);
bp = QFS_GETBLK(qfsvfsp, qfsvfsp->mi.m_fs[ord].dev, bno,
dbtob(LS_SECTORS));
bzero(bp->b_un.b_addr, bp->b_bcount);
ud = (void *)bp->b_un.b_addr;
ud->od_version = LQFS_VERSION_LATEST;
ud->od_maxtransfer = MIN(VFS_IOTRANSZ(qfsvfsp), ldl_maxtransfer);
if (ud->od_maxtransfer < ldl_mintransfer) {
ud->od_maxtransfer = ldl_mintransfer;
}
ud->od_devbsize = DEV_BSIZE;
ud->od_requestsize = flp->nbytes_actual;
ud->od_statesize = dbtob(LS_SECTORS);
ud->od_logsize = nb - ud->od_statesize;
ud->od_statebno = INT32_C(0);
uniqtime(&tv);
if (tv.tv_usec == last_loghead_ident) {
tv.tv_usec++;
}
last_loghead_ident = tv.tv_usec;
ud->od_head_ident = tv.tv_usec;
ud->od_tail_ident = ud->od_head_ident;
ud->od_chksum = ud->od_head_ident + ud->od_tail_ident;
ud->od_bol_lof = dbtob(ud->od_statebno) + ud->od_statesize;
ud->od_eol_lof = ud->od_bol_lof + ud->od_logsize;
ud->od_head_lof = ud->od_bol_lof;
ud->od_tail_lof = ud->od_bol_lof;
ASSERT(lqfs_initialize_debug(ud));
ml_odunit_validate(ud);
ud2 = (void *)(bp->b_un.b_addr + DEV_BSIZE);
bcopy(ud, ud2, sizeof (*ud));
if ((error = SAM_BWRITE2(qfsvfsp, bp)) != 0) {
brelse(bp);
return (error);
}
brelse(bp);
return (0);
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:60,代码来源:lqfs.c
示例2: swapmode
static int swapmode(int *retavail, int *retfree)
{
int n;
struct swapent *sep;
*retavail = 0;
*retfree = 0;
n = swapctl(SWAP_NSWAP, 0, 0);
if (n < 1) {
warn("could not get swap information");
return 0;
}
sep = (struct swapent *) malloc(n * (sizeof(*sep)));
if (sep == NULL) {
warn("memory allocation failed");
return 0;
}
if (swapctl(SWAP_STATS, (void *) sep, n) < n) {
warn("could not get swap stats");
return 0;
}
for (; n > 0; n--) {
*retavail += (int) dbtob(sep[n - 1].se_nblks);
*retfree += (int) dbtob(sep[n - 1].se_nblks - sep[n - 1].se_inuse);
}
*retavail = (int) (*retavail / 1024);
*retfree = (int) (*retfree / 1024);
return 1;
}
开发者ID:dilawar,项目名称:suckless,代码行数:35,代码来源:netbsd.c
示例3: cpu_dump
/*
* Dump the machine-dependent dump header.
*/
u_int
cpu_dump(int (*dump)(dev_t, daddr_t, caddr_t, size_t), daddr_t *blknop)
{
extern cpu_kcore_hdr_t cpu_kcore_hdr;
char buf[dbtob(1)];
cpu_kcore_hdr_t *h;
kcore_seg_t *kseg;
int rc;
#ifdef DIAGNOSTIC
if (cpu_dumpsize() > btodb(sizeof buf)) {
printf("buffer too small in cpu_dump, ");
return (EINVAL); /* "aborted" */
}
#endif
bzero(buf, sizeof buf);
kseg = (kcore_seg_t *)buf;
h = (cpu_kcore_hdr_t *)(buf + ALIGN(sizeof(kcore_seg_t)));
/* Create the segment header */
CORE_SETMAGIC(*kseg, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
kseg->c_size = dbtob(1) - ALIGN(sizeof(kcore_seg_t));
bcopy(&cpu_kcore_hdr, h, sizeof(*h));
/* We can now fill kptp in the header... */
h->kcore_kptp = SH3_P1SEG_TO_PHYS((vaddr_t)pmap_kernel()->pm_ptp);
rc = (*dump)(dumpdev, *blknop, buf, sizeof buf);
*blknop += btodb(sizeof buf);
return (rc);
}
开发者ID:toddfries,项目名称:OpenBSD-sys-patches,代码行数:35,代码来源:machdep.c
示例4: cpu_dumpconf
void
cpu_dumpconf(void)
{
int nblks;
/*
* XXX include the final RAM page which is not included in physmem.
*/
if (dumpdev == NODEV)
return;
nblks = bdev_size(dumpdev);
if (nblks > 0) {
if (dumpsize > btoc(dbtob(nblks - dumplo)))
dumpsize = btoc(dbtob(nblks - dumplo));
else if (dumplo == 0)
dumplo = nblks - btodb(ctob(dumpsize));
}
/*
* Don't dump on the first PAGE_SIZE (why PAGE_SIZE?) in case the dump
* device includes a disk label.
*/
if (dumplo < btodb(PAGE_SIZE))
dumplo = btodb(PAGE_SIZE);
/*
* If we have nothing to dump (XXX implement crash dumps),
* make it clear for savecore that there is no dump.
*/
if (dumpsize <= 0)
dumplo = 0;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:31,代码来源:machdep.c
示例5: writeprivs
/*
* Convert a quotause list to an ASCII file.
*/
int
writeprivs(struct quotause *quplist, int outfd, char *name, int quotatype)
{
struct quotause *qup;
FILE *fd;
ftruncate(outfd, 0);
lseek(outfd, 0, L_SET);
if ((fd = fdopen(dup(outfd), "w")) == NULL)
err(1, "%s", tmpfil);
fprintf(fd, "Quotas for %s %s:\n", qfextension[quotatype], name);
for (qup = quplist; qup; qup = qup->next) {
fprintf(fd, "%s: %s %lu, limits (soft = %lu, hard = %lu)\n",
qup->fsname, "kbytes in use:",
(unsigned long)(dbtob(qup->dqblk.dqb_curblocks) / 1024),
(unsigned long)(dbtob(qup->dqblk.dqb_bsoftlimit) / 1024),
(unsigned long)(dbtob(qup->dqblk.dqb_bhardlimit) / 1024));
fprintf(fd, "%s %lu, limits (soft = %lu, hard = %lu)\n",
"\tinodes in use:",
(unsigned long)qup->dqblk.dqb_curinodes,
(unsigned long)qup->dqblk.dqb_isoftlimit,
(unsigned long)qup->dqblk.dqb_ihardlimit);
}
fclose(fd);
return (1);
}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:29,代码来源:edquota.c
示例6: raid_pw_write
/*
* NAMES: raid_pw_write
* DESCRIPTION: issue a syncronous write to write a pre-write entry
* PARAMETERS: mr_unit_t *un - pointer to the unit structure
* int column - column number for the pre-write entry
* raid_pwhdr_t *pwhp - needed for some infos about the pw header
* raid_rplybuf_t *bufp - pointer to the replay buffer structure
* RETURNS:
*/
static int
raid_pw_write(mr_unit_t *un, int column, raid_pwhdr_t *pwhp,
raid_rplybuf_t *bufp)
{
buf_t *bp;
int error;
/* if this column is no longer accessible, return */
if (!COLUMN_ISUP(un, column))
return (RAID_RPLY_COMPREPLAY);
/* set up pointers from raid_rplybuf_t *bufp */
bp = (buf_t *)bufp->rpl_buf;
/* calculate the data address or block number */
bp->b_un.b_addr = bufp->rpl_data + DEV_BSIZE;
bp->b_bufsize = dbtob(pwhp->rpw_blkcnt);
bp->b_bcount = dbtob(pwhp->rpw_blkcnt);
bp->b_flags = (B_WRITE | B_BUSY);
bp->b_edev = md_dev64_to_dev(un->un_column[column].un_dev);
bp->b_lblkno = un->un_column[column].un_devstart + pwhp->rpw_blkno;
bp->b_iodone = pw_write_done;
(void) md_call_strategy(bp, 0, NULL);
if (biowait(bp)) {
error = raid_replay_error(un, column);
return (error);
}
return (0);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:38,代码来源:raid_replay.c
示例7: physio_done
static void
physio_done(struct work *wk, void *dummy)
{
struct buf *bp = (void *)wk;
size_t todo = bp->b_bufsize;
size_t done = bp->b_bcount - bp->b_resid;
struct physio_stat *ps = bp->b_private;
bool is_iobuf;
KASSERT(&bp->b_work == wk);
KASSERT(bp->b_bcount <= todo);
KASSERT(bp->b_resid <= bp->b_bcount);
KASSERT((bp->b_flags & B_PHYS) != 0);
KASSERT(dummy == NULL);
vunmapbuf(bp, todo);
uvm_vsunlock(bp->b_proc->p_vmspace, bp->b_data, todo);
mutex_enter(&ps->ps_lock);
is_iobuf = (bp != ps->ps_orig_bp);
if (__predict_false(done != todo)) {
off_t endoffset = dbtob(bp->b_blkno) + done;
/*
* we got an error or hit EOM.
*
* we only care about the first one.
* ie. the one at the lowest offset.
*/
KASSERT(ps->ps_endoffset != endoffset);
DPRINTF(("%s: error=%d at %" PRIu64 " - %" PRIu64
", blkno=%" PRIu64 ", bcount=%d, flags=0x%x\n",
__func__, bp->b_error, dbtob(bp->b_blkno), endoffset,
bp->b_blkno, bp->b_bcount, bp->b_flags));
if (ps->ps_endoffset == -1 || endoffset < ps->ps_endoffset) {
DPRINTF(("%s: ps=%p, error %d -> %d, endoff %" PRIu64
" -> %" PRIu64 "\n",
__func__, ps,
ps->ps_error, bp->b_error,
ps->ps_endoffset, endoffset));
ps->ps_endoffset = endoffset;
ps->ps_error = bp->b_error;
}
ps->ps_failed++;
} else {
KASSERT(bp->b_error == 0);
}
ps->ps_running--;
cv_signal(&ps->ps_cv);
mutex_exit(&ps->ps_lock);
if (is_iobuf)
putiobuf(bp);
}
开发者ID:Tommmster,项目名称:netbsd-avr32,代码行数:58,代码来源:kern_physio.c
示例8: devread
static void
devread(int fd, void *buf, daddr_t blk, size_t size, char *msg)
{
if (lseek(fd, dbtob((off_t)blk), SEEK_SET) != dbtob((off_t)blk))
err(1, "%s: devread: lseek", msg);
if (read(fd, buf, size) != size)
err(1, "%s: devread: read", msg);
}
开发者ID:appleorange1,项目名称:bitrig,代码行数:9,代码来源:installboot.c
示例9: cpu_dumpsize
/*
* cpu_dumpsize: calculate size of machine-dependent kernel core dump headers.
*/
int
cpu_dumpsize(void)
{
int size;
size = ALIGN(sizeof(kcore_seg_t)) +
ALIGN(mem_cluster_cnt * sizeof(phys_ram_seg_t));
if (roundup(size, dbtob(1)) != dbtob(1))
return (-1);
return (1);
}
开发者ID:avsm,项目名称:openbsd-xen-sys,代码行数:15,代码来源:machdep.c
示例10: cpu_dumpsize
/*
* cpu_dumpsize: calculate size of machine-dependent kernel core dump headers.
*/
int
cpu_dumpsize()
{
int size;
size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)) +
ALIGN( bootconfig.dramblocks * sizeof(phys_ram_seg_t));
if (roundup(size, dbtob(1)) != dbtob(1))
return (-1);
return (1);
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:15,代码来源:stubs.c
示例11: devread
int
devread(int fd, void *buf, daddr_t blk, size_t size, char *msg)
{
if (lseek(fd, (off_t)dbtob(blk), SEEK_SET) != dbtob(blk)) {
warn("%s: devread: lseek", msg);
return 1;
}
if (read(fd, buf, size) != size) {
warn("%s: devread: read", msg);
return 1;
}
return 0;
}
开发者ID:MarginC,项目名称:kame,代码行数:14,代码来源:installboot.c
示例12: init_pw_area
/*
* NAME: init_pw_area
*
* DESCRIPTION: Initialize pre-write area to all zeros.
*
* PARAMETERS: minor_t mnum - minor number identity of metadevice
* md_dev64_t dev_to_write - index of column to resync
* int column_index - index of column to resync
*
* RETURN: 1 if write error on resync device, otherwise 0
*
* LOCKS: Expects Unit Reader Lock to be held across call.
*/
int
init_pw_area(
mr_unit_t *un,
md_dev64_t dev_to_write,
diskaddr_t pwstart,
uint_t col
)
{
buf_t buf;
caddr_t databuffer;
size_t copysize;
size_t bsize;
int error = 0;
int i;
ASSERT(un != NULL);
ASSERT(un->un_column[col].un_devflags & MD_RAID_DEV_ISOPEN);
bsize = un->un_iosize;
copysize = dbtob(bsize);
databuffer = kmem_zalloc(copysize, KM_SLEEP);
init_buf(&buf, (B_BUSY | B_WRITE), copysize);
for (i = 0; i < un->un_pwcnt; i++) {
/* magic field is 0 for 4.0 compatability */
RAID_FILLIN_RPW(databuffer, un, 0, 0,
0, 0, 0,
0, col, 0);
buf.b_un.b_addr = (caddr_t)databuffer;
buf.b_edev = md_dev64_to_dev(dev_to_write);
buf.b_bcount = dbtob(bsize);
buf.b_lblkno = pwstart + (i * un->un_iosize);
/* write buf */
(void) md_call_strategy(&buf, MD_STR_NOTTOP, NULL);
if (biowait(&buf)) {
error = 1;
break;
}
reset_buf(&buf, (B_BUSY | B_WRITE), copysize);
} /* for */
destroy_buf(&buf);
kmem_free(databuffer, copysize);
return (error);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:61,代码来源:raid_resync.c
示例13: ffs_sbput
/*
* Write a superblock to the devfd device from the memory pointed to by fs.
* Write out the superblock summary information if it is present.
*
* If the write is successful, zero is returned. Otherwise one of the
* following error values is returned:
* EIO: failed to write superblock.
* EIO: failed to write superblock summary information.
*/
int
ffs_sbput(void *devfd, struct fs *fs, off_t loc,
int (*writefunc)(void *devfd, off_t loc, void *buf, int size))
{
int i, error, blks, size;
uint8_t *space;
/*
* If there is summary information, write it first, so if there
* is an error, the superblock will not be marked as clean.
*/
if (fs->fs_csp != NULL) {
blks = howmany(fs->fs_cssize, fs->fs_fsize);
space = (uint8_t *)fs->fs_csp;
for (i = 0; i < blks; i += fs->fs_frag) {
size = fs->fs_bsize;
if (i + fs->fs_frag > blks)
size = (blks - i) * fs->fs_fsize;
if ((error = (*writefunc)(devfd,
dbtob(fsbtodb(fs, fs->fs_csaddr + i)),
space, size)) != 0)
return (error);
space += size;
}
}
fs->fs_fmod = 0;
fs->fs_time = UFS_TIME;
if ((error = (*writefunc)(devfd, loc, fs, fs->fs_sbsize)) != 0)
return (error);
return (0);
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:40,代码来源:ffs_subr.c
示例14: dumpconf
void
dumpconf(void)
{
cpu_kcore_hdr_t *h = &cpu_kcore_hdr;
u_int dumpextra, totaldumpsize; /* in disk blocks */
u_int seg, nblks;
if (dumpdev == NODEV ||
(nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0)
return;
if (nblks <= ctod(1))
return;
dumpsize = 0;
for (seg = 0; seg < h->kcore_nsegs; seg++)
dumpsize += atop(h->kcore_segs[seg].size);
dumpextra = cpu_dumpsize();
/* Always skip the first block, in case there is a label there. */
if (dumplo < btodb(1))
dumplo = btodb(1);
/* Put dump at the end of the partition, and make it fit. */
totaldumpsize = ctod(dumpsize) + dumpextra;
if (totaldumpsize > nblks - dumplo) {
totaldumpsize = dbtob(nblks - dumplo);
dumpsize = dtoc(totaldumpsize - dumpextra);
}
if (dumplo < nblks - totaldumpsize)
dumplo = nblks - totaldumpsize;
}
开发者ID:alenichev,项目名称:openbsd-kernel,代码行数:31,代码来源:sh_machdep.c
示例15: bread
/*
* Wrapper to enable Harvey's channel read function to be used like FreeBSD's
* block read function.
* Use when reading relative to a vnode.
*/
int32_t
bread(vnode *vn, daddr_t lblkno, size_t size, Buf **buf)
{
daddr_t pblkno;
int rcode = ufs_bmaparray(vn, lblkno, &pblkno, nil, nil, nil);
if (rcode) {
print("bread failed to transform logical block to physical\n");
return 1;
}
Buf *b = newbuf(size);
b->vnode = vn;
MountPoint *mp = vn->mount;
Chan *c = mp->chan;
int64_t offset = dbtob(pblkno);
int32_t bytesRead = c->dev->read(c, b->data, size, offset);
if (bytesRead != size) {
releasebuf(b);
print("bread returned wrong size\n");
return 1;
}
b->resid = size - bytesRead;
*buf = b;
return 0;
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:34,代码来源:ufs_harvey_internal.c
示例16: i_cpr_blockzero
/*
* the actual size of the statefile data isn't known until after all the
* compressed pages are written; even the inode size doesn't reflect the
* data size since there are usually many extra fs blocks. for recording
* the actual data size, the first sector of the statefile is copied to
* a tmp buf, and the copy is later updated and flushed to disk.
*/
int
i_cpr_blockzero(char *base, char **bufpp, int *blkno, vnode_t *vp)
{
extern int cpr_flush_write(vnode_t *);
static char cpr_sector[DEV_BSIZE];
cpr_ext bytes, *dst;
/*
* this routine is called after cdd_t and csu_md_t are copied
* to cpr_buf; mini-hack alert: the save/update method creates
* a dependency on the combined struct size being >= one sector
* or DEV_BSIZE; since introduction in Sol2.7, csu_md_t size is
* over 1K bytes and will probably grow with any changes.
*
* copy when vp is NULL, flush when non-NULL
*/
if (vp == NULL) {
ASSERT((*bufpp - base) >= DEV_BSIZE);
bcopy(base, cpr_sector, sizeof (cpr_sector));
return (0);
} else {
bytes = dbtob(*blkno);
dst = &((cdd_t *)cpr_sector)->cdd_filesize;
bcopy(&bytes, dst, sizeof (bytes));
bcopy(cpr_sector, base, sizeof (cpr_sector));
*bufpp = base + sizeof (cpr_sector);
*blkno = cpr_statefile_offset();
CPR_DEBUG(CPR_DEBUG1, "statefile data size: %ld\n\n", bytes);
return (cpr_flush_write(vp));
}
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:38,代码来源:cpr_impl.c
示例17: inc_inode_version
/*
* This function increments the inode version number
*
* This may be used one day by the NFS server
*/
static void
inc_inode_version(struct inode *inode, struct ext2_group_desc *gdp, int mode)
{
unsigned long inode_block;
struct buf *bh;
struct ext2_inode *raw_inode;
inode_block = gdp->bg_inode_table + (((inode->i_number - 1) %
EXT2_INODES_PER_GROUP(inode->i_sb)) /
EXT2_INODES_PER_BLOCK(inode->i_sb));
bh = bread (inode->i_sb->s_dev, dbtob(inode_block), inode->i_sb->s_blocksize);
if (!bh) {
kprintf ("inc_inode_version Cannot load inode table block - "
"inode=%lu, inode_block=%lu\n",
inode->i_number, inode_block);
inode->u.ext2_i.i_version = 1;
return;
}
raw_inode = ((struct ext2_inode *) bh->b_data) +
(((inode->i_number - 1) %
EXT2_INODES_PER_GROUP(inode->i_sb)) %
EXT2_INODES_PER_BLOCK(inode->i_sb));
raw_inode->i_version++;
inode->u.ext2_i.i_version = raw_inode->i_version;
bdwrite (bh);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:31,代码来源:ext2_linux_ialloc.c
示例18: xfs_buf_iorequest
/*
* Initiate IO on given buffer.
*/
int
xfs_buf_iorequest(struct xfs_buf *bp)
{
bp->b_flags &= ~(B_INVAL|B_DONE);
bp->b_ioflags &= ~BIO_ERROR;
if (bp->b_flags & B_ASYNC)
BUF_KERNPROC(bp);
if (bp->b_vp == NULL) {
if (bp->b_iocmd == BIO_WRITE) {
bp->b_flags &= ~(B_DELWRI | B_DEFERRED);
bufobj_wref(bp->b_bufobj);
}
bp->b_iooffset = (bp->b_blkno << BBSHIFT);
bstrategy(bp);
} else {
if (bp->b_iocmd == BIO_WRITE) {
/* Mark the buffer clean */
bundirty(bp);
bufobj_wref(bp->b_bufobj);
vfs_busy_pages(bp, 1);
} else if (bp->b_iocmd == BIO_READ) {
vfs_busy_pages(bp, 0);
}
bp->b_iooffset = dbtob(bp->b_blkno);
bstrategy(bp);
}
return 0;
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:34,代码来源:xfs_frw.c
示例19: blockest
/*
* This is an estimation of the number of TP_BSIZE blocks in the file.
* It estimates the number of blocks in files with holes by assuming
* that all of the blocks accounted for by di_blocks are data blocks
* (when some of the blocks are usually used for indirect pointers);
* hence the estimate may be high.
*/
int64_t
blockest(union dinode *dp)
{
int64_t blkest, sizeest;
/*
* dp->di_size is the size of the file in bytes.
* dp->di_blocks stores the number of sectors actually in the file.
* If there are more sectors than the size would indicate, this just
* means that there are indirect blocks in the file or unused
* sectors in the last file block; we can safely ignore these
* (blkest = sizeest below).
* If the file is bigger than the number of sectors would indicate,
* then the file has holes in it. In this case we must use the
* block count to estimate the number of data blocks used, but
* we use the actual size for estimating the number of indirect
* dump blocks (sizeest vs. blkest in the indirect block
* calculation).
*/
blkest = howmany(dbtob((int64_t)DIP(dp, di_blocks)), TP_BSIZE);
sizeest = howmany((int64_t)DIP(dp, di_size), TP_BSIZE);
if (blkest > sizeest)
blkest = sizeest;
if (DIP(dp, di_size) > sblock->fs_bsize * NDADDR) {
/* calculate the number of indirect blocks on the dump tape */
blkest +=
howmany(sizeest - NDADDR * sblock->fs_bsize / TP_BSIZE,
TP_NINDIR);
}
return (blkest + 1);
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:38,代码来源:traverse.c
示例20: cpu_dump
/*
* cpu_dump: dump the machine-dependent kernel core dump headers.
*/
int
cpu_dump()
{
int (*dump)(dev_t, daddr_t, void *, size_t);
char bf[dbtob(1)];
kcore_seg_t *segp;
cpu_kcore_hdr_t *cpuhdrp;
phys_ram_seg_t *memsegp;
const struct bdevsw *bdev;
int i;
bdev = bdevsw_lookup(dumpdev);
if (bdev == NULL)
return (ENXIO);
dump = bdev->d_dump;
memset(bf, 0, sizeof bf);
segp = (kcore_seg_t *)bf;
cpuhdrp = (cpu_kcore_hdr_t *)&bf[ALIGN(sizeof(*segp))];
memsegp = (phys_ram_seg_t *)&bf[ ALIGN(sizeof(*segp)) +
ALIGN(sizeof(*cpuhdrp))];
/*
* Generate a segment header.
*/
CORE_SETMAGIC(*segp, KCORE_MAGIC, MID_MACHINE, CORE_CPU);
segp->c_size = dbtob(1) - ALIGN(sizeof(*segp));
/*
* Add the machine-dependent header info.
*/
cpuhdrp->version = 1;
cpuhdrp->PAKernelL1Table = pmap_kernel_L1_addr();
cpuhdrp->UserL1TableSize = 0;
cpuhdrp->nmemsegs = bootconfig.dramblocks;
cpuhdrp->omemsegs = ALIGN(sizeof(*cpuhdrp));
/*
* Fill in the memory segment descriptors.
*/
for (i = 0; i < bootconfig.dramblocks; i++) {
memsegp[i].start = bootconfig.dram[i].address;
memsegp[i].size = bootconfig.dram[i].pages * PAGE_SIZE;
}
return (dump(dumpdev, dumplo, bf, dbtob(1)));
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:50,代码来源:stubs.c
注:本文中的dbtob函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论