本文整理汇总了C++中D1函数的典型用法代码示例。如果您正苦于以下问题:C++ D1函数的具体用法?C++ D1怎么用?C++ D1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: i_vldc_cb
/* ldc callback */
static uint_t
i_vldc_cb(uint64_t event, caddr_t arg)
{
int rv;
vldc_port_t *vport = (vldc_port_t *)arg;
ldc_status_t old_status;
short pollevents = 0;
ASSERT(vport != NULL);
ASSERT(vport->minorp != NULL);
D1("i_vldc_cb: [email protected]%d:%d callback invoked, channel=0x%lx, "
"event=0x%lx\n", vport->inst, vport->number, vport->ldc_id, event);
/* ensure the port can't be destroyed while we are handling the cb */
mutex_enter(&vport->minorp->lock);
if (vport->status == VLDC_PORT_CLOSED) {
return (LDC_SUCCESS);
}
old_status = vport->ldc_status;
rv = ldc_status(vport->ldc_handle, &vport->ldc_status);
if (rv != 0) {
DWARN("i_vldc_cb: [email protected]%d:%d could not get ldc status, "
"rv=%d\n", vport->inst, vport->number, rv);
mutex_exit(&vport->minorp->lock);
return (LDC_SUCCESS);
}
if (event & LDC_EVT_UP) {
pollevents |= POLLOUT;
vport->hanged_up = B_FALSE;
} else if (event & LDC_EVT_RESET) {
/*
* Mark the port in reset, if it is not CLOSED and
* the channel was previously in LDC_UP state. This
* implies that the port cannot be used until it has
* been closed and reopened.
*/
if (old_status == LDC_UP) {
vport->status = VLDC_PORT_RESET;
vport->hanged_up = B_TRUE;
pollevents = POLLHUP;
} else {
rv = ldc_up(vport->ldc_handle);
if (rv) {
DWARN("i_vldc_cb: [email protected]%d:%d cannot bring "
"channel UP rv=%d\n", vport->inst,
vport->number, rv);
mutex_exit(&vport->minorp->lock);
return (LDC_SUCCESS);
}
rv = ldc_status(vport->ldc_handle, &vport->ldc_status);
if (rv != 0) {
DWARN("i_vldc_cb: [email protected]%d:%d could not get "
"ldc status, rv=%d\n", vport->inst,
vport->number, rv);
mutex_exit(&vport->minorp->lock);
return (LDC_SUCCESS);
}
if (vport->ldc_status == LDC_UP) {
pollevents |= POLLOUT;
vport->hanged_up = B_FALSE;
}
}
} else if (event & LDC_EVT_DOWN) {
/*
* The other side went away - mark port in RESET state
*/
vport->status = VLDC_PORT_RESET;
vport->hanged_up = B_TRUE;
pollevents = POLLHUP;
}
if (event & LDC_EVT_READ)
pollevents |= POLLIN;
mutex_exit(&vport->minorp->lock);
if (pollevents != 0) {
D1("i_vldc_cb: [email protected]%d pollwakeup=0x%x\n",
vport->number, pollevents);
pollwakeup(&vport->poll, pollevents);
}
return (LDC_SUCCESS);
}
示例2: main
//.........这里部分代码省略.........
MyGlobalElements = new int[NumMyElements];
MaxMyGID = (Comm.MyPID()+1)*NumMyElements-1+IndexBase;
if (Comm.MyPID()>2) MaxMyGID+=3;
for (i = 0; i<NumMyElements; i++) MyGlobalElements[i] = MaxMyGID-i;
if (verbose) cout << "\n*********************************************************" << endl;
if (verbose) cout << "Checking Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements, IndexBase, Comm)" << endl;
if (verbose) cout << "*********************************************************" << endl;
Map = new Epetra_Map(NumGlobalElements, NumMyElements, MyGlobalElements,
IndexBase, Comm);
EPETRA_TEST_ERR(MultiVectorTests(*Map, NumVectors, verbose),ierr);
//EPETRA_TEST_ERR(MatrixTests(*Map, *LocalMap, NumVectors, verbose),ierr);
// Test Copy constructor
if (verbose) cout << "\n*********************************************************" << endl;
if (verbose) cout << "Checking Epetra_Map(*Map)" << endl;
if (verbose) cout << "*********************************************************" << endl;
Epetra_Map Map1(*Map);
EPETRA_TEST_ERR(MultiVectorTests(*Map, NumVectors, verbose),ierr);
//EPETRA_TEST_ERR(MatrixTests(*Map, *LocalMap, NumVectors, verbose),ierr);
delete [] MyGlobalElements;
delete Map;
delete LocalMap;
if (verbose1)
{
// Test MultiVector MFLOPS for 2D Dot Product
int M = 27;
int N = 27;
int K = 10000;
Epetra_Map Map2(-1, K, IndexBase, Comm);
Epetra_LocalMap Map3(M, IndexBase, Comm);
Epetra_MultiVector A(Map2,N);A.Random();
Epetra_MultiVector B(Map2,N);B.Random();
Epetra_MultiVector C(Map3,N);C.Random();
if (verbose) cout << "Testing Assignment operator" << endl;
double tmp1 = 1.00001* (double) (MyPID+1);
double tmp2 = tmp1;
A[1][1] = tmp1;
tmp2 = A[1][1];
cout << "On PE "<< MyPID << " A[1][1] should equal = " << tmp1;
if (tmp1==tmp2) cout << " and it does!" << endl;
else cout << " but it equals " << tmp2;
Comm.Barrier();
if (verbose) cout << "Testing MFLOPs" << endl;
Epetra_Flops counter;
C.SetFlopCounter(counter);
Epetra_Time mytimer(Comm);
C.Multiply('T', 'N', 0.5, A, B, 0.0);
double Multiply_time = mytimer.ElapsedTime();
double Multiply_flops = C.Flops();
if (verbose) cout << "\n\nTotal FLOPs = " << Multiply_flops << endl;
if (verbose) cout << "Total Time = " << Multiply_time << endl;
if (verbose) cout << "MFLOPs = " << Multiply_flops/Multiply_time/1000000.0 << endl;
Comm.Barrier();
// Test MultiVector ostream operator with Petra-defined uniform linear distribution constructor
// and a small vector
Epetra_Map Map4(100, IndexBase, Comm);
double * Dp = new double[200];
for (j=0; j<2; j++)
for (i=0; i<100; i++)
Dp[i+j*100] = i+j*100;
Epetra_MultiVector D(View, Map4,Dp, 100, 2);
if (verbose) cout << "\n\nTesting ostream operator: Multivector should be 100-by-2 and print i,j indices"
<< endl << endl;
cout << D << endl;
Epetra_BlockMap Map5(-1, 25, 4, IndexBase, Comm);
Epetra_MultiVector D1(View, Map5,Dp, 100, 2);
if (verbose) cout << "\n\nTesting ostream operator: Same Multivector as before except using BlockMap of 25x4"
<< endl << endl;
cout << D1 << endl;
if (verbose) cout << "Traceback Mode value = " << D.GetTracebackMode() << endl;
delete [] Dp;
}
#ifdef EPETRA_MPI
MPI_Finalize();
#endif
return ierr;
}
示例3: jffs2_prepare_write
int jffs2_prepare_write (struct file *filp, struct page *pg, unsigned start, unsigned end)
{
struct inode *inode = pg->mapping->host;
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
__u32 pageofs = pg->index << PAGE_CACHE_SHIFT;
int ret = 0;
D1(printk(KERN_DEBUG "jffs2_prepare_write() nrpages %ld\n", inode->i_mapping->nrpages));
if (pageofs > inode->i_size) {
/* Make new hole frag from old EOF to new page */
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
struct jffs2_raw_inode ri;
struct jffs2_full_dnode *fn;
__u32 phys_ofs, alloc_len;
D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
(unsigned int)inode->i_size, pageofs));
ret = jffs2_reserve_space(c, sizeof(ri), &phys_ofs, &alloc_len, ALLOC_NORMAL);
if (ret)
return ret;
down(&f->sem);
memset(&ri, 0, sizeof(ri));
ri.magic = JFFS2_MAGIC_BITMASK;
ri.nodetype = JFFS2_NODETYPE_INODE;
ri.totlen = sizeof(ri);
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node)-4);
ri.ino = f->inocache->ino;
ri.version = ++f->highest_version;
ri.mode = inode->i_mode;
ri.uid = inode->i_uid;
ri.gid = inode->i_gid;
ri.isize = max((__u32)inode->i_size, pageofs);
ri.atime = ri.ctime = ri.mtime = CURRENT_TIME;
ri.offset = inode->i_size;
ri.dsize = pageofs - inode->i_size;
ri.csize = 0;
ri.compr = JFFS2_COMPR_ZERO;
ri.node_crc = crc32(0, &ri, sizeof(ri)-8);
ri.data_crc = 0;
fn = jffs2_write_dnode(inode, &ri, NULL, 0, phys_ofs, NULL);
jffs2_complete_reservation(c);
if (IS_ERR(fn)) {
ret = PTR_ERR(fn);
up(&f->sem);
return ret;
}
ret = jffs2_add_full_dnode_to_inode(c, f, fn);
if (f->metadata) {
jffs2_mark_node_obsolete(c, f->metadata->raw);
jffs2_free_full_dnode(f->metadata);
f->metadata = NULL;
}
if (ret) {
D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in prepare_write, returned %d\n", ret));
jffs2_mark_node_obsolete(c, fn->raw);
jffs2_free_full_dnode(fn);
up(&f->sem);
return ret;
}
inode->i_size = pageofs;
up(&f->sem);
}
/* Read in the page if it wasn't already present, unless it's a whole page */
if (!Page_Uptodate(pg) && (start || end < PAGE_CACHE_SIZE)) {
down(&f->sem);
ret = jffs2_do_readpage_nolock(inode, pg);
up(&f->sem);
}
D1(printk(KERN_DEBUG "end prepare_write(). pg->flags %lx\n", pg->flags));
return ret;
}
示例4: jffs2_scan_medium
int jffs2_scan_medium(struct jffs2_sb_info *c)
{
int i, ret;
uint32_t empty_blocks = 0, bad_blocks = 0;
unsigned char *flashbuf = NULL;
uint32_t buf_size = 0;
struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
#ifndef __ECOS
size_t pointlen, try_size;
if (c->mtd->point) {
ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen,
(void **)&flashbuf, NULL);
if (!ret && pointlen < c->mtd->size) {
/* Don't muck about if it won't let us point to the whole flash */
D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen));
c->mtd->unpoint(c->mtd, 0, pointlen);
flashbuf = NULL;
}
if (ret)
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
}
#endif
if (!flashbuf) {
/* For NAND it's quicker to read a whole eraseblock at a time,
apparently */
if (jffs2_cleanmarker_oob(c))
try_size = c->sector_size;
if (c->mtd->type == MTD_NANDFLASH)
buf_size = c->sector_size;
else
try_size = PAGE_SIZE;
D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu "
"bytes\n", try_size));
flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
if (!flashbuf)
return -ENOMEM;
D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n",
try_size));
buf_size = (uint32_t)try_size;
}
if (jffs2_sum_active()) {
s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
if (!s) {
JFFS2_WARNING("Can't allocate memory for summary\n");
ret = -ENOMEM;
goto out;
}
}
for (i=0; i<c->nr_blocks; i++) {
struct jffs2_eraseblock *jeb = &c->blocks[i];
cond_resched();
/* reset summary info for next eraseblock scan */
jffs2_sum_reset_collected(s);
ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
buf_size, s);
if (ret < 0)
goto out;
jffs2_dbg_acct_paranoia_check_nolock(c, jeb);
/* Now decide which list to put it on */
switch(ret) {
case BLK_STATE_ALLFF:
/*
* Empty block. Since we can't be sure it
* was entirely erased, we just queue it for erase
* again. It will be marked as such when the erase
* is complete. Meanwhile we still count it as empty
* for later checks.
*/
empty_blocks++;
list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
break;
case BLK_STATE_CLEANMARKER:
/* Only a CLEANMARKER node is valid */
if (!jeb->dirty_size) {
/* It's actually free */
list_add(&jeb->list, &c->free_list);
c->nr_free_blocks++;
} else {
/* Dirt */
D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset));
list_add(&jeb->list, &c->erase_pending_list);
c->nr_erasing_blocks++;
}
break;
//.........这里部分代码省略.........
示例5: jffs2_free_inode_cache
void jffs2_free_inode_cache(struct jffs2_inode_cache *x)
{
D1(printk(KERN_DEBUG "Freeing inocache at %p\n", x));
kmem_cache_free(inode_cache_slab, x);
}
示例6: vsw_set_port_hw_addr
/*
* Program the macaddress and vlans of a port.
*
* Returns 0 on sucess, 1 on failure.
*/
static int
vsw_set_port_hw_addr(vsw_port_t *port)
{
vsw_t *vswp = port->p_vswp;
mac_diag_t diag;
uint8_t *macaddr;
uint16_t vid = VLAN_ID_NONE;
int rv;
uint16_t mac_flags = MAC_UNICAST_TAG_DISABLE |
MAC_UNICAST_STRIP_DISABLE;
D1(vswp, "%s: enter", __func__);
ASSERT(RW_WRITE_HELD(&port->maccl_rwlock));
if (port->p_mch == NULL)
return (0);
/*
* If the port has a specific 'pvid', then
* register with that vlan-id, otherwise register
* with VLAN_ID_NONE.
*/
if (port->pvid != vswp->default_vlan_id) {
vid = port->pvid;
}
macaddr = (uint8_t *)port->p_macaddr.ether_addr_octet;
if (!(vswp->smode & VSW_LAYER2_PROMISC)) {
mac_flags |= MAC_UNICAST_HW;
}
if (port->addr_set == B_FALSE) {
port->p_muh = NULL;
rv = mac_unicast_add(port->p_mch, macaddr, mac_flags,
&port->p_muh, vid, &diag);
if (rv != 0) {
cmn_err(CE_WARN, "vsw%d: Failed to program"
"macaddr,vid(%s, %d) err=%d",
vswp->instance, ether_sprintf((void *)macaddr),
vid, rv);
return (rv);
}
port->addr_set = B_TRUE;
D2(vswp, "%s:programmed macaddr(%s) vid(%d) into device %s",
__func__, ether_sprintf((void *)macaddr), vid,
vswp->physname);
}
/* Add vlans to the MAC layer */
vsw_mac_add_vlans(vswp, port->p_mch, macaddr,
mac_flags, port->vids, port->nvids);
/* Configure bandwidth to the MAC layer */
vsw_maccl_set_bandwidth(NULL, port, VSW_VNETPORT, port->p_bandwidth);
mac_rx_set(port->p_mch, vsw_port_rx_cb, (void *)port);
D1(vswp, "%s: exit", __func__);
return (rv);
}
示例7: jffs2_scan_dirent_node
static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
struct jffs2_raw_dirent *rd, uint32_t ofs, struct jffs2_summary *s)
{
struct jffs2_full_dirent *fd;
struct jffs2_inode_cache *ic;
uint32_t checkedlen;
uint32_t crc;
int err;
D1(printk(KERN_DEBUG "jffs2_scan_dirent_node(): Node at 0x%08x\n", ofs));
/* We don't get here unless the node is still valid, so we don't have to
mask in the ACCURATE bit any more. */
crc = crc32(0, rd, sizeof(*rd)-8);
if (crc != je32_to_cpu(rd->node_crc)) {
printk(KERN_NOTICE "jffs2_scan_dirent_node(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
ofs, je32_to_cpu(rd->node_crc), crc);
/* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen)))))
return err;
return 0;
}
pseudo_random += je32_to_cpu(rd->version);
/* Should never happen. Did. (OLPC trac #4184)*/
checkedlen = strnlen(rd->name, rd->nsize);
if (checkedlen < rd->nsize) {
printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n",
ofs, checkedlen);
}
fd = jffs2_alloc_full_dirent(checkedlen+1);
if (!fd) {
return -ENOMEM;
}
memcpy(&fd->name, rd->name, checkedlen);
fd->name[checkedlen] = 0;
crc = crc32(0, fd->name, rd->nsize);
if (crc != je32_to_cpu(rd->name_crc)) {
printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
ofs, je32_to_cpu(rd->name_crc), crc);
D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino)));
jffs2_free_full_dirent(fd);
/* FIXME: Why do we believe totlen? */
/* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen)))))
return err;
return 0;
}
ic = jffs2_scan_make_ino_cache(c, je32_to_cpu(rd->pino));
if (!ic) {
jffs2_free_full_dirent(fd);
return -ENOMEM;
}
fd->raw = jffs2_link_node_ref(c, jeb, ofs | dirent_node_state(rd),
PAD(je32_to_cpu(rd->totlen)), ic);
fd->next = NULL;
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
fd->nhash = full_name_hash(fd->name, checkedlen);
fd->type = rd->type;
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
if (jffs2_sum_active()) {
jffs2_sum_add_dirent_mem(s, rd, ofs - jeb->offset);
}
return 0;
}
示例8: entry
void Trr2kNNTN
( UpperOrLower uplo,
Orientation orientationOfC,
T alpha, const DistMatrix<T>& A, const DistMatrix<T>& B,
const DistMatrix<T>& C, const DistMatrix<T>& D,
T beta, DistMatrix<T>& E )
{
#ifndef RELEASE
CallStackEntry entry("internal::Trr2kNNTN");
if( E.Height() != E.Width() || A.Width() != C.Height() ||
A.Height() != E.Height() || C.Width() != E.Height() ||
B.Width() != E.Width() || D.Width() != E.Width() ||
A.Width() != B.Height() || C.Height() != D.Height() )
throw std::logic_error("Nonconformal Trr2kNNTN");
#endif
const Grid& g = E.Grid();
DistMatrix<T> AL(g), AR(g),
A0(g), A1(g), A2(g);
DistMatrix<T> BT(g), B0(g),
BB(g), B1(g),
B2(g);
DistMatrix<T> CT(g), C0(g),
CB(g), C1(g),
C2(g);
DistMatrix<T> DT(g), D0(g),
DB(g), D1(g),
D2(g);
DistMatrix<T,MC, STAR> A1_MC_STAR(g);
DistMatrix<T,MR, STAR> B1Trans_MR_STAR(g);
DistMatrix<T,STAR,MC > C1_STAR_MC(g);
DistMatrix<T,MR, STAR> D1Trans_MR_STAR(g);
A1_MC_STAR.AlignWith( E );
B1Trans_MR_STAR.AlignWith( E );
C1_STAR_MC.AlignWith( E );
D1Trans_MR_STAR.AlignWith( E );
LockedPartitionRight( A, AL, AR, 0 );
LockedPartitionDown
( B, BT,
BB, 0 );
LockedPartitionDown
( C, CT,
CB, 0 );
LockedPartitionDown
( D, DT,
DB, 0 );
while( AL.Width() < A.Width() )
{
LockedRepartitionRight
( AL, /**/ AR,
A0, /**/ A1, A2 );
LockedRepartitionDown
( BT, B0,
/**/ /**/
B1,
BB, B2 );
LockedRepartitionDown
( CT, C0,
/**/ /**/
C1,
CB, C2 );
LockedRepartitionDown
( DT, D0,
/**/ /**/
D1,
DB, D2 );
//--------------------------------------------------------------------//
A1_MC_STAR = A1;
C1_STAR_MC = C1;
B1Trans_MR_STAR.TransposeFrom( B1 );
D1Trans_MR_STAR.TransposeFrom( D1 );
LocalTrr2k
( uplo, TRANSPOSE, orientationOfC, TRANSPOSE,
alpha, A1_MC_STAR, B1Trans_MR_STAR,
C1_STAR_MC, D1Trans_MR_STAR,
beta, E );
//--------------------------------------------------------------------//
SlideLockedPartitionDown
( DT, D0,
D1,
/**/ /**/
DB, D2 );
SlideLockedPartitionDown
( CT, C0,
C1,
/**/ /**/
CB, C2 );
SlideLockedPartitionDown
( BT, B0,
B1,
/**/ /**/
BB, B2 );
SlideLockedPartitionRight
( AL, /**/ AR,
//.........这里部分代码省略.........
示例9: i_vldc_close_port
/* close a vldc port */
static int
i_vldc_close_port(vldc_t *vldcp, uint_t portno)
{
vldc_port_t *vport;
vldc_minor_t *vminor;
int rv = DDI_SUCCESS;
vport = &(vldcp->port[portno]);
ASSERT(MUTEX_HELD(&vport->minorp->lock));
D1("i_vldc_close_port: [email protected]%d:%d: closing port\n",
vport->inst, vport->minorp->portno);
vminor = vport->minorp;
switch (vport->status) {
case VLDC_PORT_CLOSED:
/* nothing to do */
DWARN("i_vldc_close_port: port %d in an unexpected "
"state (%d)\n", portno, vport->status);
return (DDI_SUCCESS);
case VLDC_PORT_READY:
case VLDC_PORT_RESET:
do {
rv = i_vldc_ldc_close(vport);
if (rv != EAGAIN)
break;
/*
* EAGAIN indicates that ldc_close() failed because
* ldc callback thread is active for the channel.
* cv_timedwait() is used to release vminor->lock and
* allow ldc callback thread to complete.
* after waking up, check if the port has been closed
* by another thread in the meantime.
*/
(void) cv_reltimedwait(&vminor->cv, &vminor->lock,
drv_usectohz(vldc_close_delay), TR_CLOCK_TICK);
rv = 0;
} while (vport->status != VLDC_PORT_CLOSED);
if ((rv != 0) || (vport->status == VLDC_PORT_CLOSED))
return (rv);
break;
case VLDC_PORT_OPEN:
break;
default:
DWARN("i_vldc_close_port: port %d in an unexpected "
"state (%d)\n", portno, vport->status);
ASSERT(0); /* fail quickly to help diagnosis */
return (EINVAL);
}
ASSERT(vport->status == VLDC_PORT_OPEN);
/* free memory */
kmem_free(vport->send_buf, vport->mtu);
kmem_free(vport->recv_buf, vport->mtu);
if (strcmp(vminor->sname, VLDC_HVCTL_SVCNAME) == 0)
kmem_free(vport->cookie_buf, vldc_max_cookie);
vport->status = VLDC_PORT_CLOSED;
return (rv);
}
示例10: vldc_detach
/*
* detach(9E): detach a device from the system.
*/
static int
vldc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
{
int i, instance;
vldc_t *vldcp;
switch (cmd) {
case DDI_DETACH:
instance = ddi_get_instance(dip);
vldcp = ddi_get_soft_state(vldc_ssp, instance);
if (vldcp == NULL) {
return (DDI_FAILURE);
}
D1("vldc_detach: DDI_DETACH instance=%d\n", instance);
mutex_enter(&vldcp->lock);
/* Fail the detach if all ports have not been removed. */
for (i = 0; i < VLDC_MAX_MINORS; i++) {
if (vldcp->minor_tbl[i].portno != VLDC_INVALID_PORTNO) {
D1("vldc_detach: [email protected]%d:%d is bound, "
"detach failed\n",
instance, vldcp->minor_tbl[i].portno);
mutex_exit(&vldcp->lock);
return (DDI_FAILURE);
}
}
/*
* Prevent MDEG from adding new ports before the callback can
* be unregistered. The lock can't be held accross the
* unregistration call because a callback may be in progress
* and blocked on the lock.
*/
vldcp->detaching = B_TRUE;
mutex_exit(&vldcp->lock);
if (i_vldc_mdeg_unregister(vldcp) != MDEG_SUCCESS) {
vldcp->detaching = B_FALSE;
return (DDI_FAILURE);
}
/* Tear down all bound ports and free resources. */
for (i = 0; i < VLDC_MAX_MINORS; i++) {
if (vldcp->minor_tbl[i].portno != VLDC_INVALID_PORTNO) {
(void) i_vldc_remove_port(vldcp, i);
}
mutex_destroy(&(vldcp->minor_tbl[i].lock));
cv_destroy(&(vldcp->minor_tbl[i].cv));
}
mutex_destroy(&vldcp->lock);
ddi_soft_state_free(vldc_ssp, instance);
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
示例11: i_vldc_add_port
/* add a vldc port */
static int
i_vldc_add_port(vldc_t *vldcp, md_t *mdp, mde_cookie_t node)
{
vldc_port_t *vport;
char *sname;
uint64_t portno;
int vldc_inst;
minor_t minor;
int minor_idx;
boolean_t new_minor;
int rv;
ASSERT(MUTEX_HELD(&vldcp->lock));
/* read in the port's id property */
if (md_get_prop_val(mdp, node, "id", &portno)) {
cmn_err(CE_NOTE, "?i_vldc_add_port: node 0x%lx of added "
"list has no 'id' property", node);
return (MDEG_FAILURE);
}
if (portno >= VLDC_MAX_PORTS) {
cmn_err(CE_NOTE, "?i_vldc_add_port: found port number (%lu) "
"larger than maximum supported number of ports", portno);
return (MDEG_FAILURE);
}
vport = &(vldcp->port[portno]);
if (vport->minorp != NULL) {
cmn_err(CE_NOTE, "?i_vldc_add_port: trying to add a port (%lu)"
" which is already bound", portno);
return (MDEG_FAILURE);
}
vport->number = portno;
/* get all channels for this device (currently only one) */
if (i_vldc_get_port_channel(mdp, node, &vport->ldc_id) == -1) {
return (MDEG_FAILURE);
}
/* set the default MTU */
vport->mtu = VLDC_DEFAULT_MTU;
/* get the service being exported by this port */
if (md_get_prop_str(mdp, node, "vldc-svc-name", &sname)) {
cmn_err(CE_NOTE, "?i_vldc_add_port: vdevice has no "
"'vldc-svc-name' property");
return (MDEG_FAILURE);
}
/* minor number look up */
for (minor_idx = 0; minor_idx < vldcp->minors_assigned;
minor_idx++) {
if (strcmp(vldcp->minor_tbl[minor_idx].sname, sname) == 0) {
/* found previously assigned minor number */
break;
}
}
new_minor = B_FALSE;
if (minor_idx == vldcp->minors_assigned) {
/* end of lookup - assign new minor number */
if (vldcp->minors_assigned == VLDC_MAX_MINORS) {
cmn_err(CE_NOTE, "?i_vldc_add_port: too many minor "
"nodes (%d)", minor_idx);
return (MDEG_FAILURE);
}
(void) strlcpy(vldcp->minor_tbl[minor_idx].sname,
sname, MAXPATHLEN);
vldcp->minors_assigned++;
new_minor = B_TRUE;
}
if (vldcp->minor_tbl[minor_idx].portno != VLDC_INVALID_PORTNO) {
cmn_err(CE_NOTE, "?i_vldc_add_port: trying to add a port (%lu)"
" which has a minor number in use by port (%u)",
portno, vldcp->minor_tbl[minor_idx].portno);
return (MDEG_FAILURE);
}
vldc_inst = ddi_get_instance(vldcp->dip);
vport->inst = vldc_inst;
vport->minorp = &vldcp->minor_tbl[minor_idx];
vldcp->minor_tbl[minor_idx].portno = portno;
vldcp->minor_tbl[minor_idx].in_use = 0;
D1("i_vldc_add_port: [email protected]%d:%d mtu=%d, ldc=%ld, service=%s\n",
vport->inst, vport->number, vport->mtu, vport->ldc_id, sname);
/*
* Create a minor node. The minor number is
* (vldc_inst << VLDC_INST_SHIFT) | minor_idx
*/
minor = (vldc_inst << VLDC_INST_SHIFT) | (minor_idx);
//.........这里部分代码省略.........
示例12: i_vldc_mdeg_register
/* register callback to mdeg */
static int
i_vldc_mdeg_register(vldc_t *vldcp)
{
mdeg_prop_spec_t *pspecp;
mdeg_node_spec_t *inst_specp;
mdeg_handle_t mdeg_hdl;
size_t templatesz;
int inst;
char *name;
size_t namesz;
char *nameprop;
int rv;
/* get the unique vldc instance assigned by the LDom manager */
inst = ddi_prop_get_int(DDI_DEV_T_ANY, vldcp->dip,
DDI_PROP_DONTPASS, "reg", -1);
if (inst == -1) {
cmn_err(CE_NOTE, "?vldc%d has no 'reg' property",
ddi_get_instance(vldcp->dip));
return (DDI_FAILURE);
}
/* get the name of the vldc instance */
rv = ddi_prop_lookup_string(DDI_DEV_T_ANY, vldcp->dip,
DDI_PROP_DONTPASS, "name", &nameprop);
if (rv != DDI_PROP_SUCCESS) {
cmn_err(CE_NOTE, "?vldc%d has no 'name' property",
ddi_get_instance(vldcp->dip));
return (DDI_FAILURE);
}
D1("i_vldc_mdeg_register: name=%s, instance=%d\n", nameprop, inst);
/*
* Allocate and initialize a per-instance copy
* of the global property spec array that will
* uniquely identify this vldc instance.
*/
templatesz = sizeof (vldc_prop_template);
pspecp = kmem_alloc(templatesz, KM_SLEEP);
bcopy(vldc_prop_template, pspecp, templatesz);
/* copy in the name property */
namesz = strlen(nameprop) + 1;
name = kmem_alloc(namesz, KM_SLEEP);
bcopy(nameprop, name, namesz);
VLDC_SET_MDEG_PROP_NAME(pspecp, name);
ddi_prop_free(nameprop);
/* copy in the instance property */
VLDC_SET_MDEG_PROP_INST(pspecp, inst);
/* initialize the complete prop spec structure */
inst_specp = kmem_alloc(sizeof (mdeg_node_spec_t), KM_SLEEP);
inst_specp->namep = "virtual-device";
inst_specp->specp = pspecp;
/* perform the registration */
rv = mdeg_register(inst_specp, &vport_match, i_vldc_mdeg_cb,
vldcp, &mdeg_hdl);
if (rv != MDEG_SUCCESS) {
cmn_err(CE_NOTE, "?i_vldc_mdeg_register: mdeg_register "
"failed, err = %d", rv);
kmem_free(name, namesz);
kmem_free(pspecp, templatesz);
kmem_free(inst_specp, sizeof (mdeg_node_spec_t));
return (DDI_FAILURE);
}
/* save off data that will be needed later */
vldcp->inst_spec = inst_specp;
vldcp->mdeg_hdl = mdeg_hdl;
return (DDI_SUCCESS);
}
示例13: i_vldc_mdeg_cb
/* mdeg callback */
static int
i_vldc_mdeg_cb(void *cb_argp, mdeg_result_t *resp)
{
vldc_t *vldcp;
int idx;
uint64_t portno;
int rv;
md_t *mdp;
mde_cookie_t node;
if (resp == NULL) {
D1("i_vldc_mdeg_cb: no result returned\n");
return (MDEG_FAILURE);
}
vldcp = (vldc_t *)cb_argp;
mutex_enter(&vldcp->lock);
if (vldcp->detaching == B_TRUE) {
D1("i_vldc_mdeg_cb: detach in progress\n");
mutex_exit(&vldcp->lock);
return (MDEG_FAILURE);
}
D1("i_vldc_mdeg_cb: added=%d, removed=%d, matched=%d\n",
resp->added.nelem, resp->removed.nelem, resp->match_prev.nelem);
/* process added ports */
for (idx = 0; idx < resp->added.nelem; idx++) {
mdp = resp->added.mdp;
node = resp->added.mdep[idx];
D1("i_vldc_mdeg_cb: processing added node 0x%lx\n", node);
/* attempt to add a port */
if ((rv = i_vldc_add_port(vldcp, mdp, node)) != MDEG_SUCCESS) {
cmn_err(CE_NOTE, "?i_vldc_mdeg_cb: unable to add port, "
"err = %d", rv);
}
}
/* process removed ports */
for (idx = 0; idx < resp->removed.nelem; idx++) {
mdp = resp->removed.mdp;
node = resp->removed.mdep[idx];
D1("i_vldc_mdeg_cb: processing removed node 0x%lx\n", node);
/* read in the port's id property */
if (md_get_prop_val(mdp, node, "id", &portno)) {
cmn_err(CE_NOTE, "?i_vldc_mdeg_cb: node 0x%lx of "
"removed list has no 'id' property", node);
continue;
}
/* attempt to remove a port */
if ((rv = i_vldc_remove_port(vldcp, portno)) != 0) {
cmn_err(CE_NOTE, "?i_vldc_mdeg_cb: unable to remove "
"port %lu, err %d", portno, rv);
}
}
/*
* Currently no support for updating already active ports. So, ignore
* the match_curr and match_prev arrays for now.
*/
mutex_exit(&vldcp->lock);
return (MDEG_SUCCESS);
}
示例14: jffs2_remove_node_refs_from_ino_list
/* Hmmm. Maybe we should accept the extra space it takes and make
this a standard doubly-linked list? */
static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
struct jffs2_raw_node_ref *ref, struct jffs2_eraseblock *jeb)
{
struct jffs2_inode_cache *ic = NULL;
struct jffs2_raw_node_ref **prev;
prev = &ref->next_in_ino;
/* Walk the inode's list once, removing any nodes from this eraseblock */
while (1) {
if (!(*prev)->next_in_ino) {
/* We're looking at the jffs2_inode_cache, which is
at the end of the linked list. Stash it and continue
from the beginning of the list */
ic = (struct jffs2_inode_cache *)(*prev);
prev = &ic->nodes;
continue;
}
if (((*prev)->flash_offset & ~(c->sector_size -1)) == jeb->offset) {
/* It's in the block we're erasing */
struct jffs2_raw_node_ref *this;
this = *prev;
*prev = this->next_in_ino;
this->next_in_ino = NULL;
if (this == ref)
break;
continue;
}
/* Not to be deleted. Skip */
prev = &((*prev)->next_in_ino);
}
/* PARANOIA */
if (!ic) {
printk(KERN_WARNING "inode_cache not found in remove_node_refs()!!\n");
return;
}
D1(printk(KERN_DEBUG "Removed nodes in range 0x%08x-0x%08x from ino #%u\n",
jeb->offset, jeb->offset + c->sector_size, ic->ino));
D2({
int i=0;
struct jffs2_raw_node_ref *this;
printk(KERN_DEBUG "After remove_node_refs_from_ino_list: \n" KERN_DEBUG);
this = ic->nodes;
while(this) {
printk( "0x%08x(%d)->", this->flash_offset & ~3, this->flash_offset &3);
if (++i == 5) {
printk("\n" KERN_DEBUG);
i=0;
}
this = this->next_in_ino;
}
printk("\n");
});
示例15: A1
void Render::addContainer()
{
glm::vec3 A1(0.0f, 0.0f, 0.0f);
glm::vec3 B1(1.0f, 0.0f, 0.0f);
glm::vec3 C1(1.0f, 0.0f, 1.0f);
glm::vec3 D1(0.0f, 0.0f, 1.0f);
glm::vec3 A2(0.0f, 1.0f, 0.0f);
glm::vec3 B2(1.0f, 1.0f, 0.0f);
glm::vec3 C2(1.0f, 1.0f, 1.0f);
glm::vec3 D2(0.0f, 1.0f, 1.0f);
glm::vec3 normal(0.0f, 0.0f, 0.0f);
vertices.push_back(A1);
normals.push_back(normal);
vertices.push_back(B1);
normals.push_back(normal);
vertices.push_back(A1);
normals.push_back(normal);
vertices.push_back(D1);
normals.push_back(normal);
vertices.push_back(B1);
normals.push_back(normal);
vertices.push_back(C1);
normals.push_back(normal);
vertices.push_back(D1);
normals.push_back(normal);
vertices.push_back(C1);
normals.push_back(normal);
vertices.push_back(A2);
normals.push_back(normal);
vertices.push_back(B2);
normals.push_back(normal);
vertices.push_back(A2);
normals.push_back(normal);
vertices.push_back(D2);
normals.push_back(normal);
vertices.push_back(B2);
normals.push_back(normal);
vertices.push_back(C2);
normals.push_back(normal);
vertices.push_back(D2);
normals.push_back(normal);
vertices.push_back(C2);
normals.push_back(normal);
vertices.push_back(A1);
normals.push_back(normal);
vertices.push_back(A2);
normals.push_back(normal);
vertices.push_back(B1);
normals.push_back(normal);
vertices.push_back(B2);
normals.push_back(normal);
vertices.push_back(C1);
normals.push_back(normal);
vertices.push_back(C2);
normals.push_back(normal);
vertices.push_back(D1);
normals.push_back(normal);
vertices.push_back(D2);
normals.push_back(normal);
}