/*
- * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
- *
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
* @APPLE_LICENSE_OSREFERENCE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
int adspallocate(), adsprelease();
int adspInited = 0;
-atlock_t adspall_lock;
-atlock_t adspgen_lock;
GLOBAL adspGlobal;
/**********/
gref_t *gref;
CCBPtr sp;
at_ddp_t *p;
- int s, l;
gbuf_t *mb;
switch (gbuf_type(mp)) {
case MSG_DATA:
p = (at_ddp_t *)gbuf_rptr(mp);
- ATDISABLE(s, adspall_lock);
sp = adsp_inputQ[p->dst_socket];
if ((sp == 0) || (sp->gref==0) || (sp->state==sClosed))
{
- ATENABLE(s, adspall_lock);
gbuf_freem(mp);
return;
}
} while ((sp = sp->otccbLink) != 0);
if (sp == 0)
{
- ATENABLE(s, adspall_lock);
gbuf_freem(mp);
return;
}
gbuf_next(mb) = mp;
} else
sp->deferred_mb = mp;
- ATENABLE(s, adspall_lock);
return;
}
- ATDISABLE(l, sp->lockRemove);
sp->lockFlag = 1;
- ATENABLE(l, adspall_lock);
while (mp) {
adsp_rput(sp->gref, mp);
if ((mp = sp->deferred_mb) != 0) {
}
}
sp->lockFlag = 0;
- ATENABLE(s, sp->lockRemove);
return;
case MSG_IOCACK:
int adsp_writeable(gref)
gref_t *gref;
{
- int s, rc;
+ int rc;
CCBPtr sp;
if (gref->info == 0)
return(1);
sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
- ATDISABLE(s, sp->lock);
rc = CalcSendQFree(sp);
- ATENABLE(s, sp->lock);
return rc;
}
gref_t *gref;
{
register CCBPtr sp;
- int s;
if (!adspInited)
adsp_init();
sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
gref->readable = adsp_readable;
gref->writeable = adsp_writeable;
- ATDISABLE(s, adspall_lock);
if ((sp->otccbLink = ccb_used_list) != 0)
sp->otccbLink->ccbLink = sp;
ccb_used_list = sp;
- ATENABLE(s, adspall_lock);
return 0;
}
int adsp_close(gref)
gref_t *gref;
{
- int s, l;
unsigned char localSocket;
/* make sure we've not yet removed the CCB (e.g., due to TrashSession) */
- ATDISABLE(l, adspgen_lock);
if (gref->info) {
CCBPtr sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
- ATDISABLE(s, sp->lock);
- ATENABLE(s, adspgen_lock);
localSocket = sp->localSocket;
- ATENABLE(l, sp->lock);
if (localSocket)
adspRelease(gref);
else
gbuf_freeb((gbuf_t *)gref->info);
}
} else
- ATENABLE(l, adspgen_lock);
return 0;
}
gbuf_t *mp;
{
int rc;
- int s;
gbuf_t *xm;
ioc_t *iocbp;
CCBPtr sp;
adsp_iocnak(gref, mp, EINVAL);
}
v = *(unsigned char *)gbuf_rptr(gbuf_cont(mp));
- ATDISABLE(s, adspall_lock);
if ( (v != 0)
&& ((v > DDP_SOCKET_LAST) || (v < 2)
|| ddp_socket_inuse(v, DDP_ADSP))) {
- ATENABLE(s, adspall_lock);
iocbp->ioc_rval = -1;
adsp_iocnak(gref, mp, EINVAL);
}
else {
if (v == 0) {
- ATENABLE(s, adspall_lock);
if ((v = adspAssignSocket(gref, 0)) == 0) {
iocbp->ioc_rval = -1;
adsp_iocnak(gref, mp, EINVAL);
adsp_inputC[v] = 1;
adsp_inputQ[v] = sp;
adsp_pidM[v] = sp->pid;
- ATENABLE(s, adspall_lock);
adsp_dequeue_ccb(sp);
}
*(unsigned char *)gbuf_rptr(gbuf_cont(mp)) = v;
if (!gref->info)
gbuf_freem(mp);
else {
- ATDISABLE(s, sp->lockClose);
rc = adspWriteHandler(gref, mp);
- ATENABLE(s, sp->lockClose);
switch (rc) {
case STR_PUTNEXT:
{
unsigned char sVal, sMax, sMin, sSav, inputC;
CCBPtr sp;
- int s;
sMax = flag ? DDP_SOCKET_LAST-46 : DDP_SOCKET_LAST-6;
sMin = DDP_SOCKET_1st_DYNAMIC;
- ATDISABLE(s, adspall_lock);
for (inputC=255, sVal=sMax; sVal >= sMin; sVal--) {
if (!ddp_socket_inuse(sVal, DDP_ADSP))
break;
}
}
if (sVal < sMin) {
- if (!flag || (inputC == 255)) {
- ATENABLE(s, adspall_lock);
+ if (!flag || (inputC == 255))
return 0;
- }
sVal = sSav;
}
sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
- ATENABLE(s, adspall_lock);
adsp_dequeue_ccb(sp);
- ATDISABLE(s, adspall_lock);
adsp_inputC[sVal]++;
sp->otccbLink = adsp_inputQ[sVal];
adsp_inputQ[sVal] = sp;
if (!flag)
adsp_pidM[sVal] = sp->pid;
- ATENABLE(s, adspall_lock);
return sVal;
}
CCBPtr curr_sp;
CCBPtr prev_sp;
int pid = 0;
- int s, l;
dPrintf(D_M_ADSP, D_L_TRACE, ("adspDeassignSocket: pid=%d,s=%d\n",
sp->pid, sp->localSocket));
- ATDISABLE(s, adspall_lock);
sVal = sp->localSocket;
if ((curr_sp = adsp_inputQ[sVal]) != 0) {
prev_sp = 0;
curr_sp = curr_sp->otccbLink;
}
if (curr_sp) {
- ATDISABLE(l, sp->lockRemove);
if (prev_sp)
prev_sp->otccbLink = sp->otccbLink;
else
adsp_inputQ[sVal] = sp->otccbLink;
- ATENABLE(l, sp->lockRemove);
if (adsp_inputQ[sVal])
adsp_inputC[sVal]--;
else {
sp->ccbLink = 0;
sp->otccbLink = 0;
sp->localSocket = 0;
- ATENABLE(s, adspall_lock);
return pid ? 0 : 1;
}
}
- ATENABLE(s, adspall_lock);
dPrintf(D_M_ADSP, D_L_ERROR,
("adspDeassignSocket: closing, no CCB block, trouble ahead\n"));
adsp_dequeue_ccb(sp)
CCB *sp;
{
- int s;
- ATDISABLE(s, adspall_lock);
if (sp == ccb_used_list) {
if ((ccb_used_list = sp->otccbLink) != 0)
sp->otccbLink->ccbLink = 0;
sp->otccbLink = 0;
sp->ccbLink = 0;
- ATENABLE(s, adspall_lock);
}
void SndMsgUp(gref, mp)