本文整理汇总了C++中KDASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ KDASSERT函数的具体用法?C++ KDASSERT怎么用?C++ KDASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KDASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cpu_intr
void
cpu_intr(int ppl, vaddr_t pc, uint32_t status)
{
struct cpu_info * const ci = curcpu();
uint32_t pending;
int ipl;
#ifdef DIAGNOSTIC
const int mtx_count = ci->ci_mtx_count;
const u_int biglock_count = ci->ci_biglock_count;
const u_int blcnt = curlwp->l_blcnt;
#endif
KASSERT(ci->ci_cpl == IPL_HIGH);
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
ci->ci_data.cpu_nintr++;
while (ppl < (ipl = splintr(&pending))) {
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
splx(ipl); /* lower to interrupt level */
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
KASSERTMSG(ci->ci_cpl == ipl,
"%s: cpl (%d) != ipl (%d)", __func__, ci->ci_cpl, ipl);
KASSERT(pending != 0);
cf.pc = pc;
cf.sr = status;
cf.intr = (ci->ci_idepth > 1);
#ifdef MIPS3_ENABLE_CLOCK_INTR
if (pending & MIPS_INT_MASK_5) {
KASSERTMSG(ipl == IPL_SCHED,
"%s: ipl (%d) != IPL_SCHED (%d)",
__func__, ipl, IPL_SCHED);
/* call the common MIPS3 clock interrupt handler */
mips3_clockintr(&cf);
pending ^= MIPS_INT_MASK_5;
}
#endif
if (pending != 0) {
/* Process I/O and error interrupts. */
evbmips_iointr(ipl, pc, pending);
}
KASSERT(biglock_count == ci->ci_biglock_count);
KASSERT(blcnt == curlwp->l_blcnt);
KASSERT(mtx_count == ci->ci_mtx_count);
/*
* If even our spl is higher now (due to interrupting while
* spin-lock is held and higher IPL spin-lock is locked, it
* can no longer be locked so it's safe to lower IPL back
* to ppl.
*/
(void) splhigh(); /* disable interrupts */
}
KASSERT(ci->ci_cpl == IPL_HIGH);
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
}
示例2: sysfpga_intr_evcnt
struct evcnt *
sysfpga_intr_evcnt(int group, int inum)
{
struct evcnt *ev = NULL;
KDASSERT(group < SYSFPGA_NGROUPS);
KDASSERT(sysfpga_sc->sc_ih[group] != NULL);
switch (group) {
case SYSFPGA_IGROUP_IRL1:
KDASSERT(inum >= 0 && inum < SYSFPGA_IRL1_NINTR);
ev = &sysfpga_irl1_intr_events[inum];
break;
case SYSFPGA_IGROUP_IRL2:
ev = &sysfpga_irl2_intr_events;
break;
case SYSFPGA_IGROUP_IRL3:
ev = &sysfpga_irl3_intr_events;
break;
}
return (ev);
}
示例3: v7fs_readlink
int
v7fs_readlink(void *v)
{
struct vop_readlink_args /* {
struct vnode *a_vp;
struct uio *a_uio;
kauth_cred_t a_cred;
} */ *a = v;
struct uio *uio = a->a_uio;
struct vnode *vp = a->a_vp;
struct v7fs_node *v7node = vp->v_data;
struct v7fs_inode *inode = &v7node->inode;
struct v7fs_self *fs = v7node->v7fsmount->core;
int error = 0;
KDASSERT(vp->v_type == VLNK);
KDASSERT(uio->uio_offset >= 0);
KDASSERT(v7fs_inode_islnk(inode));
v7fs_daddr_t blk = inode->addr[0];
void *buf;
if (!(buf = scratch_read(fs, blk))) {
error = EIO;
goto error_exit;
}
if ((error = uiomove(buf, strlen(buf), uio))) {
DPRINTF("uiomove failed.\n");
}
scratch_free(fs, buf);
error_exit:
return error;
}
示例4: slugled_defer
static void
slugled_defer(device_t self)
{
struct slugled_softc *sc = device_private(self);
struct ixp425_softc *ixsc = ixp425_softc;
uint32_t reg;
int s;
s = splhigh();
/* Configure LED GPIO pins as output */
reg = GPIO_CONF_READ_4(ixsc, IXP425_GPIO_GPOER);
reg &= ~(LEDBITS_USB0 | LEDBITS_USB1);
reg &= ~(LEDBITS_READY | LEDBITS_STATUS);
GPIO_CONF_WRITE_4(ixsc, IXP425_GPIO_GPOER, reg);
/* All LEDs off */
reg = GPIO_CONF_READ_4(ixsc, IXP425_GPIO_GPOUTR);
reg |= LEDBITS_USB0 | LEDBITS_USB1;
reg &= ~(LEDBITS_STATUS | LEDBITS_READY);
GPIO_CONF_WRITE_4(ixsc, IXP425_GPIO_GPOUTR, reg);
splx(s);
if (shutdownhook_establish(slugled_shutdown, sc) == NULL)
aprint_error_dev(self, "WARNING - Failed to register shutdown hook\n");
callout_init(&sc->sc_usb0, 0);
callout_setfunc(&sc->sc_usb0, slugled_callout,
(void *)(uintptr_t)LEDBITS_USB0);
callout_init(&sc->sc_usb1, 0);
callout_setfunc(&sc->sc_usb1, slugled_callout,
(void *)(uintptr_t)LEDBITS_USB1);
callout_init(&sc->sc_usb2, 0);
callout_setfunc(&sc->sc_usb2, slugled_callout,
(void *)(uintptr_t)(LEDBITS_USB0 | LEDBITS_USB1));
sc->sc_usb0_ih = ixp425_intr_establish(PCI_INT_A, IPL_USB,
slugled_intr0, sc);
KDASSERT(sc->sc_usb0_ih != NULL);
sc->sc_usb1_ih = ixp425_intr_establish(PCI_INT_B, IPL_USB,
slugled_intr1, sc);
KDASSERT(sc->sc_usb1_ih != NULL);
sc->sc_usb2_ih = ixp425_intr_establish(PCI_INT_C, IPL_USB,
slugled_intr2, sc);
KDASSERT(sc->sc_usb2_ih != NULL);
sc->sc_tmr_ih = ixp425_intr_establish(IXP425_INT_TMR0, IPL_CLOCK,
slugled_tmr, NULL);
KDASSERT(sc->sc_tmr_ih != NULL);
}
示例5: v7fs_readdir
int
v7fs_readdir(void *v)
{
struct vop_readdir_args /* {
struct vnode *a_vp;
struct uio *a_uio;
kauth_cred_t a_cred;
int *a_eofflag;
off_t **a_cookies;
int *a_ncookies;
} */ *a = v;
struct uio *uio = a->a_uio;
struct vnode *vp = a->a_vp;
struct v7fs_node *v7node = vp->v_data;
struct v7fs_inode *inode = &v7node->inode;
struct v7fs_self *fs = v7node->v7fsmount->core;
struct dirent *dp;
int error;
DPRINTF("offset=%zu residue=%zu\n", uio->uio_offset, uio->uio_resid);
KDASSERT(vp->v_type == VDIR);
KDASSERT(uio->uio_offset >= 0);
KDASSERT(v7fs_inode_isdir(inode));
struct v7fs_readdir_arg arg;
arg.start = uio->uio_offset / sizeof(*dp);
arg.end = arg.start + uio->uio_resid / sizeof(*dp);
if (arg.start == arg.end) {/* user buffer has not enuf space. */
DPRINTF("uio buffer too small\n");
return ENOMEM;
}
dp = kmem_zalloc(sizeof(*dp), KM_SLEEP);
arg.cnt = 0;
arg.dp = dp;
arg.uio = uio;
*a->a_eofflag = false;
error = v7fs_datablock_foreach(fs, inode, readdir_subr, &arg);
if (error == V7FS_ITERATOR_END) {
*a->a_eofflag = true;
}
if (error < 0)
error = 0;
kmem_free(dp, sizeof(*dp));
return error;
}
示例6: ffs_wapbl_replay_finish
/*
* This function is invoked after a log is replayed to
* disk to perform logical cleanup actions as described by
* the log
*/
void
ffs_wapbl_replay_finish(struct mount *mp)
{
struct wapbl_replay *wr = mp->mnt_wapbl_replay;
int i;
int error;
if (!wr)
return;
KDASSERT((mp->mnt_flag & MNT_RDONLY) == 0);
for (i = 0; i < wr->wr_inodescnt; i++) {
struct vnode *vp;
struct inode *ip;
error = VFS_VGET(mp, wr->wr_inodes[i].wr_inumber, &vp);
if (error) {
printf("ffs_wapbl_replay_finish: "
"unable to cleanup inode %u\n",
wr->wr_inodes[i].wr_inumber);
continue;
}
ip = VTOI(vp);
KDASSERT(wr->wr_inodes[i].wr_inumber == ip->i_number);
#ifdef WAPBL_DEBUG
printf("ffs_wapbl_replay_finish: "
"cleaning inode %llu size=%llu mode=%o nlink=%d\n",
ip->i_number, DIP(ip, size), DIP(ip, mode), DIP(ip, nlink));
#endif
KASSERT(DIP(ip, nlink) == 0);
/*
* The journal may have left partially allocated inodes in mode
* zero. This may occur if a crash occurs betweeen the node
* allocation in ffs_nodeallocg and when the node is properly
* initialized in ufs_makeinode. If so, just dallocate them.
*/
if (DIP(ip, mode) == 0) {
UFS_WAPBL_BEGIN(mp);
ffs_inode_free(ip, ip->i_number,
wr->wr_inodes[i].wr_imode);
UFS_WAPBL_END(mp);
}
vput(vp);
}
wapbl_replay_stop(wr);
wapbl_replay_free(wr);
mp->mnt_wapbl_replay = NULL;
}
示例7: sh4_switch_setup
/*
* void sh4_switch_setup(struct proc *p):
* prepare kernel stack PTE table. sh4_switch_resume wired this PTE.
*/
void
sh4_switch_setup(struct proc *p)
{
pt_entry_t *pte;
struct md_upte *md_upte = p->p_md.md_upte;
uint32_t vpn;
int i, e;
vpn = (uint32_t)p->p_addr;
vpn &= ~PGOFSET;
e = SH4_UTLB_ENTRY - UPAGES;
for (i = 0; i < UPAGES; i++, e++, vpn += PAGE_SIZE) {
pte = __pmap_kpte_lookup(vpn);
KDASSERT(pte && *pte != 0);
/* Address array */
md_upte->addr = SH4_UTLB_AA | (e << SH4_UTLB_E_SHIFT);
md_upte->data = vpn | SH4_UTLB_AA_D | SH4_UTLB_AA_V;
md_upte++;
/* Data array */
md_upte->addr = SH4_UTLB_DA1 | (e << SH4_UTLB_E_SHIFT);
md_upte->data = (*pte & PG_HW_BITS) |
SH4_UTLB_DA1_D | SH4_UTLB_DA1_V;
md_upte++;
}
}
示例8: v7fs_update
int
v7fs_update(struct vnode *vp, const struct timespec *acc,
const struct timespec *mod, int flags)
{
struct v7fs_node *v7node = vp->v_data;
struct v7fs_inode *inode = &v7node->inode;
struct v7fs_self *fs = v7node->v7fsmount->core;
bool update = false;
DPRINTF("%p %zu %d\n", vp, vp->v_size, v7fs_inode_filesize(inode));
KDASSERT(vp->v_size == v7fs_inode_filesize(inode));
if (v7node->update_atime) {
inode->atime = acc ? acc->tv_sec : time_second;
v7node->update_atime = false;
update = true;
}
if (v7node->update_ctime) {
inode->ctime = time_second;
v7node->update_ctime = false;
update = true;
}
if (v7node->update_mtime) {
inode->mtime = mod ? mod->tv_sec : time_second;
v7node->update_mtime = false;
update = true;
}
if (update)
v7fs_inode_writeback(fs, inode);
return 0;
}
示例9: v7fs_strategy
int
v7fs_strategy(void *v)
{
struct vop_strategy_args /* {
struct vnode *a_vp;
struct buf *a_bp;
} */ *a = v;
struct buf *b = a->a_bp;
struct vnode *vp = a->a_vp;
struct v7fs_node *v7node = vp->v_data;
struct v7fs_mount *v7fsmount = v7node->v7fsmount;
int error;
DPRINTF("%p\n", vp);
KDASSERT(vp->v_type == VREG);
if (b->b_blkno == b->b_lblkno) {
error = VOP_BMAP(vp, b->b_lblkno, NULL, &b->b_blkno, NULL);
if (error) {
b->b_error = error;
biodone(b);
return error;
}
if ((long)b->b_blkno == -1)
clrbuf(b);
}
if ((long)b->b_blkno == -1) {
biodone(b);
return 0;
}
return VOP_STRATEGY(v7fsmount->devvp, b);
}
示例10: sh4_switch_setup
/*
* Prepare kernel stack PTE table. sh4_switch_resume wires these PTEs.
*/
void
sh4_switch_setup(struct lwp *l)
{
struct md_upte *md_upte;
uint32_t vpn;
pt_entry_t *pte;
int i, e;
md_upte = l->l_md.md_upte;
vpn = sh3_trunc_page(uvm_lwp_getuarea(l));
e = SH4_UTLB_ENTRY - UPAGES;
for (i = 0; i < UPAGES; ++i) {
pte = __pmap_kpte_lookup(vpn);
KDASSERT(pte && *pte != 0);
/* Address array */
md_upte->addr = SH4_UTLB_AA | (e << SH4_UTLB_E_SHIFT);
md_upte->data = vpn | SH4_UTLB_AA_D | SH4_UTLB_AA_V;
++md_upte;
/* Data array */
md_upte->addr = SH4_UTLB_DA1 | (e << SH4_UTLB_E_SHIFT);
md_upte->data = (*pte & PG_HW_BITS) |
SH4_UTLB_DA1_D | SH4_UTLB_DA1_V;
++md_upte;
vpn += PAGE_SIZE;
++e;
}
}
示例11: intc_intr
void
intc_intr(int ssr, int spc, int ssp)
{
struct intc_intrhand *ih;
int s, evtcode;
evtcode = _reg_read_4(SH4_INTEVT);
ih = EVTCODE_IH(evtcode);
KDASSERT(ih->ih_func);
/*
* On entry, all interrrupts are disabled, and exception is enabled.
* Enable higher level interrupt here.
*/
s = _cpu_intr_resume(ih->ih_level);
if (evtcode == SH_INTEVT_TMU0_TUNI0) { /* hardclock */
struct clockframe cf;
cf.spc = spc;
cf.ssr = ssr;
cf.ssp = ssp;
(*ih->ih_func)(&cf);
} else {
(*ih->ih_func)(ih->ih_arg);
}
}
示例12: bus_space_create
/* create default bus_space_tag */
bus_space_tag_t
bus_space_create(bus_space_tag_t t, const char *name,
bus_addr_t addr, bus_size_t size)
{
struct playstation2_bus_space *pbs = (void *)t; /* discard const */
if (pbs == 0)
pbs = malloc(sizeof(*pbs), M_DEVBUF, M_NOWAIT);
KDASSERT(pbs);
memset(pbs, 0, sizeof(*pbs));
/* set default method */
*pbs = _default_bus_space;
pbs->pbs_cookie = pbs;
/* set access region */
if (size == 0) {
pbs->pbs_base_addr = addr; /* no extent */
} else {
pbs->pbs_extent = extent_create(name, addr, addr + size - 1,
M_DEVBUF, 0, 0, EX_NOWAIT);
if (pbs->pbs_extent == 0) {
panic("%s:: unable to create bus_space for "
"0x%08lx-%#lx\n", __FUNCTION__, addr, size);
}
}
return (pbs);
}
示例13: intc_intr
void
intc_intr(int ssr, int spc, int ssp)
{
struct intc_intrhand *ih;
int evtcode;
u_int16_t r;
evtcode = _reg_read_4(CPU_IS_SH3 ? SH7709_INTEVT2 : SH4_INTEVT);
ih = EVTCODE_IH(evtcode);
KDASSERT(ih->ih_func);
/*
* On entry, all interrrupts are disabled,
* and exception is enabled for P3 access. (kernel stack is P3,
* SH3 may or may not cause TLB miss when access stack.)
* Enable higher level interrupt here.
*/
r = _reg_read_2(HD6446X_NIRR);
splx(ih->ih_level);
if (evtcode == SH_INTEVT_TMU0_TUNI0) {
struct clockframe cf;
cf.spc = spc;
cf.ssr = ssr;
cf.ssp = ssp;
(*ih->ih_func)(&cf);
__dbg_heart_beat(HEART_BEAT_RED);
} else if (evtcode ==
(CPU_IS_SH3 ? SH7709_INTEVT2_IRQ4 : SH_INTEVT_IRL11)) {
int cause = r & hd6446x_ienable;
struct hd6446x_intrhand *hh = &hd6446x_intrhand[ffs(cause) - 1];
if (cause == 0) {
printf("masked HD6446x interrupt.0x%04x\n", r);
_reg_write_2(HD6446X_NIRR, 0x0000);
return;
}
/* Enable higher level interrupt*/
hd6446x_intr_resume(hh->hh_ipl);
KDASSERT(hh->hh_func != NULL);
(*hh->hh_func)(hh->hh_arg);
__dbg_heart_beat(HEART_BEAT_GREEN);
} else {
(*ih->ih_func)(ih->ih_arg);
__dbg_heart_beat(HEART_BEAT_BLUE);
}
}
示例14: v7fs_create
int
v7fs_create(void *v)
{
struct vop_create_v3_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
struct vattr *a_vap;
} */ *a = v;
struct v7fs_node *parent_node = a->a_dvp->v_data;
struct v7fs_mount *v7fsmount = parent_node->v7fsmount;
struct v7fs_self *fs = v7fsmount->core;
struct mount *mp = v7fsmount->mountp;
struct v7fs_fileattr attr;
struct vattr *va = a->a_vap;
kauth_cred_t cr = a->a_cnp->cn_cred;
v7fs_ino_t ino;
int error = 0;
DPRINTF("%s parent#%d\n", a->a_cnp->cn_nameptr,
parent_node->inode.inode_number);
KDASSERT((va->va_type == VREG) || (va->va_type == VSOCK));
memset(&attr, 0, sizeof(attr));
attr.uid = kauth_cred_geteuid(cr);
attr.gid = kauth_cred_getegid(cr);
attr.mode = va->va_mode | vtype_to_v7fs_mode (va->va_type);
attr.device = 0;
/* Allocate disk entry. and register its entry to parent directory. */
if ((error = v7fs_file_allocate(fs, &parent_node->inode,
a->a_cnp->cn_nameptr, &attr, &ino))) {
DPRINTF("v7fs_file_allocate failed.\n");
return error;
}
/* Sync dirent size change. */
uvm_vnp_setsize(a->a_dvp, v7fs_inode_filesize(&parent_node->inode));
/* Get myself vnode. */
*a->a_vpp = 0;
if ((error = v7fs_vget(mp, ino, a->a_vpp))) {
DPRINTF("v7fs_vget failed.\n");
return error;
}
/* Scheduling update time. real update by v7fs_update */
struct v7fs_node *newnode = (*a->a_vpp)->v_data;
newnode->update_ctime = true;
newnode->update_mtime = true;
newnode->update_atime = true;
DPRINTF("allocated %s->#%d\n", a->a_cnp->cn_nameptr, ino);
if (error == 0)
VOP_UNLOCK(*a->a_vpp);
return error;
}
示例15: timer_one_shot
void
timer_one_shot(int timer)
{
KDASSERT(LEGAL_TIMER(timer) && timer != 0);
_reg_write_4(T_COUNT_REG(timer), 0);
_reg_write_4(T_COMP_REG(timer), 1);
_reg_write_4(T_MODE_REG(timer), T_MODE_CUE | T_MODE_CMPE);
}