示例#1
0
primitiveFlushICacheFromTo(void)
{
	void *cpu;
	sqInt cpuAlien;
	usqIntptr_t endAddress;
	usqIntptr_t startAddress;

	startAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(1))
		: positive64BitValueOf(stackValue(1)));
	endAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(0))
		: positive64BitValueOf(stackValue(0)));
	cpuAlien = stackValue(2);
	if (failed()) {
		return null;
	}
	if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0
		? (cpuAlien + BaseHeaderSize) + BytesPerOop
		: longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) {
		primitiveFailFor(PrimErrBadReceiver);
		return null;
	}
	flushICacheFromTo(cpu, startAddress, endAddress);
	if (failed()) {
		return null;
	}
	pop(2);
	return null;
}
示例#2
0
	/* GdbARMPlugin>>#startOfData: */
static sqInt
startOfData(sqInt rcvr)
{
	return ((longAt(rcvr + BaseHeaderSize)) > 0
		? (rcvr + BaseHeaderSize) + BytesPerOop
		: longAt((rcvr + BaseHeaderSize) + BytesPerOop));
}
示例#3
0
primitiveResetCPU(void)
{
	void *cpu;
	sqInt cpuAlien;
	sqInt maybeErr;

	cpuAlien = stackValue(0);
	if (failed()) {
		return null;
	}
	if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0
		? (cpuAlien + BaseHeaderSize) + BytesPerOop
		: longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) {
		primitiveFailFor(PrimErrBadReceiver);
		return null;
	}
	maybeErr = resetCPU(cpu);
	if (maybeErr != 0) {
		primitiveFailFor(PrimErrInappropriate);
		return null;
	}
	if (failed()) {
		return null;
	}
	popthenPush(1, cpuAlien);
	return null;
}
示例#4
0
primitiveDisassembleAtInMemory(void)
{
	usqIntptr_t address;
	void *cpu;
	sqInt cpuAlien;
	sqInt instrLenOrErr;
	sqInt log;
	sqInt logLen;
	sqInt logObj;
	sqInt logObjData;
	char *memory;
	sqInt resultObj;

	logLen = 0;
	address = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(1))
		: positive64BitValueOf(stackValue(1)));
	success(isWordsOrBytes(stackValue(0)));
	memory = ((char *) (firstIndexableField(stackValue(0))));
	cpuAlien = stackValue(2);
	if (failed()) {
		return null;
	}
	if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0
		? (cpuAlien + BaseHeaderSize) + BytesPerOop
		: longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) {
		primitiveFailFor(PrimErrBadReceiver);
		return null;
	}
	instrLenOrErr = disassembleForAtInSize(cpu, address, memory, byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize)));
	if (instrLenOrErr < 0) {
		primitiveFailFor(PrimErrInappropriate);
		return null;
	}
	log = getlog((&logLen));
	resultObj = instantiateClassindexableSize(classArray(), 2);
	if (resultObj == 0) {
		primitiveFailFor(PrimErrNoMemory);
		return null;
	}
	pushRemappableOop(resultObj);
	logObj = instantiateClassindexableSize(classString(), logLen);
	if (failed()) {
		popRemappableOop();
		primitiveFailFor(PrimErrNoMemory);
		return null;
	}
	logObjData = arrayValueOf(logObj);
	memcpy(logObjData, log, logLen);
	resultObj = popRemappableOop();
	storePointerofObjectwithValue(0, resultObj, integerObjectOf(instrLenOrErr));
	storePointerofObjectwithValue(1, resultObj, logObj);
	if (failed()) {
		return null;
	}
	popthenPush(3, resultObj);
	return null;
}
示例#5
0
primitiveSingleStepInMemoryMinAddressMaxAddressReadWrite(void)
{
	void *cpu;
	sqInt cpuAlien;
	usqIntptr_t maxAddress;
	sqInt maybeErr;
	char *memory;
	sqInt memorySize;
	usqIntptr_t minAddress;
	usqIntptr_t minWriteMaxExecAddress;

	success(isWordsOrBytes(stackValue(3)));
	memory = ((char *) (firstIndexableField(stackValue(3))));
	minAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(2))
		: positive64BitValueOf(stackValue(2)));
	maxAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(1))
		: positive64BitValueOf(stackValue(1)));
	minWriteMaxExecAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(0))
		: positive64BitValueOf(stackValue(0)));
	cpuAlien = stackValue(4);
	if (failed()) {
		return null;
	}
	if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0
		? (cpuAlien + BaseHeaderSize) + BytesPerOop
		: longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) {
		primitiveFailFor(PrimErrBadReceiver);
		return null;
	}
	prevInterruptCheckChain = setInterruptCheckChain(forceStopOnInterrupt);
	if (prevInterruptCheckChain == (forceStopOnInterrupt)) {
		prevInterruptCheckChain == 0;
	}
	memorySize = byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize));
	maybeErr = singleStepCPUInSizeMinAddressReadWrite(cpu, memory, ((memorySize < maxAddress) ? memorySize : maxAddress), minAddress, minWriteMaxExecAddress);
	setInterruptCheckChain(prevInterruptCheckChain);
	if (maybeErr != 0) {
		primitiveFailFor(PrimErrInappropriate);
		return null;
	}
	if (failed()) {
		return null;
	}
	popthenPush(5, cpuAlien);
	return null;
}
示例#6
0
int 
Java_org_squeak_android_SqueakVM_loadImageHeap(JNIEnv *env, jobject self,
					       jstring imageName, 
					       int heapSize) {
  if(longAt(sqMemory) < 0xFFFF) {
    sqHeaderSize = longAt(sqMemory+4);
  } else {
    sqHeaderSize = byteSwapped(longAt(sqMemory+4));
  }
  initTimer();
  aioInit();
  dprintf(4, "loadImageHeap: headerSize = %d\n", sqHeaderSize);
  readImageFromFileHeapSizeStartingAt(0, heapSize-sqHeaderSize, 0);
  prepareActiveProcess();
  return 0;
}
示例#7
0
primitiveSingleStepInMemoryMinimumAddressReadWrite(void)
{
	void *cpu;
	sqInt cpuAlien;
	sqInt maybeErr;
	char *memory;
	usqIntptr_t minAddress;
	usqIntptr_t minWriteMaxExecAddress;

	success(isWordsOrBytes(stackValue(2)));
	memory = ((char *) (firstIndexableField(stackValue(2))));
	minAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(1))
		: positive64BitValueOf(stackValue(1)));
	minWriteMaxExecAddress = (BytesPerOop == 4
		? positive32BitValueOf(stackValue(0))
		: positive64BitValueOf(stackValue(0)));
	cpuAlien = stackValue(3);
	if (failed()) {
		return null;
	}
	if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0
		? (cpuAlien + BaseHeaderSize) + BytesPerOop
		: longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) {
		primitiveFailFor(PrimErrBadReceiver);
		return null;
	}
	maybeErr = singleStepCPUInSizeMinAddressReadWrite(cpu, memory, byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize)), minAddress, minWriteMaxExecAddress);
	if (maybeErr != 0) {
		primitiveFailFor(PrimErrInappropriate);
		return null;
	}
	if (failed()) {
		return null;
	}
	popthenPush(4, cpuAlien);
	return null;
}
示例#8
0
A pSimple_Connection::getAobjFromBuffer(MSBuffer *bb)
{
  ipcWarn(wrnlvl(),"%t pSimple_Connection::getAobjFromBuffer\n");
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  A d,z;
  I s;

  if(4>(s=hb->put()-hb->get()))
  {
    if(0>bufftobuff(bb,hb,4-s)) R(A)0;
    if(4>(s=hb->put()-hb->get())) R(A)0;
    s=longAt(hb->get());
    if(0>=s)
    {
      static char fmt[]="\343 IPC warning: zero-length message found.  s=%d [%d]\n";
      Warn(fmt,	s,handle());
      hb->reset();
      turnInReadOff();
      R(A)0;
    }

    // create read buffer, doubled as A-object char array
    d=gv(Ct,s);
    db->minofbuffer((C *)d); db->get(db->minofbuffer()); 
    db->put((C *)(d)); db->maxofbuffer(db->put()+s);
  }

  if(0>bufftobuff(bb,db,db->maxofbuffer()-db->put())) R(A)0;
  if(db->put()==db->maxofbuffer())
  {
    z=(A)db->minofbuffer();
    z->c=1;
    hb->reset();
    db->minofbuffer(0);
    db->clear();
    return z;
  }
  R(A)0;
}
示例#9
0
A pSimple_Connection::readOne(void)
{
  ipcWarn(wrnlvl(),"%t pSimple_Connection::readOne\n");
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  int slen;
  A d,z=(A)0;

  if(4>(slen=hb->put()-hb->get()))
  {
    if(0>readTheBuffer(hb,4-slen)) return (A)0;
    if(4>(slen=hb->put()-hb->get())) return (A)0;
    
    slen=longAt(hb->get());
    if(0>=slen)
    {
      static char fmt[]="\343 IPC warning: zero-length simple message.  slen=%d [%d]\n";
      Warn(fmt,	slen,handle());
      hb->reset();
      turnInReadOff();
      return (A)0;
    }
    d=gv(Ct,slen);
    db->minofbuffer((C *)d); db->get(db->minofbuffer()); 
    db->put((C *)(d)); db->maxofbuffer(db->put()+slen);
  }
  if(0>readTheBuffer(db,db->maxofbuffer()-db->put())) return (A)0;
  if(db->put()==db->maxofbuffer())
  {
    z=(A)db->minofbuffer();
    z->c=1;
    hb->reset();
    db->minofbuffer(0);
    db->clear();
    return z;
  }
  return (A)0;
}
示例#10
0
	/* GdbARMPlugin>>#sizeField: */
static sqInt
sizeField(sqInt rcvr)
{
	return longAt(rcvr + BaseHeaderSize);
}
示例#11
0
A pString_Connection::readBurst(void)
{
  ipcWarn(wrnlvl(),"%t pString_Connection::readBurst\n");
  MSBuffer bbuff;
  A d,z=(A)0;
  I slen=readFileLength(),slen1,n,s,count;
  if(-1==slen)R(A)0;
  if(0==slen)
  {
    static char fmt[]="\343 IPC warning: pA::ReadBurst: read event with no data [%d]\n";
    Warn(fmt, handle());
  }

  /* create buff to hold it.  Fill buffer */
  slen1=slen?slen:4;
  bbuff.minofbuffer(mab(slen1));
  bbuff.maxofbuffer(bbuff.minofbuffer()+slen1);
  bbuff.reset();
  if(0>(n=readTheBuffer(&bbuff,slen1))) {mfbuffer(&bbuff); R(A)0;}
  if(0==n&&0==slen) {turnInReadOff(); mfbuffer(&bbuff); R(A)0;}

  d=getAobjFromBuffer(&bbuff);
  if((A)0==d){mfbuffer(&bbuff); R(A)0;}

  // determine how many more complete A-objects lie in bbuff
  count=1;
  for(C *cp=bbuff.get();cp<bbuff.put();cp+=s)
  {
    s=longAt(cp);
    cp+=sizeof(long);
    if(s<=bbuff.put()-cp)++count;
  }

  // create result
  z=gv(Et,count);
  for(int i=0;i<count;++i)z->p[i]=(I)aplus_nl;
  int idx=0;
  z->p[idx++]=(I)d;

  // retrieve additional A-objects from bbuff, fill in z
  while(idx<count)
  {
    d=getAobjFromBuffer(&bbuff);
    if((A)0==d)break;
    z->p[idx++]=(I)d;
  }
  if(idx<count)
  {
    ipcWarn(wrnlvl(),"%t burst mode aborted.  Possible data loss.\n");
  }

  // run once more to clear out bbuff and move partial object into connection
  // buffers
  if(bbuff.get()==bbuff.put())turnInReadOff();
  else
  {
    d=getAobjFromBuffer(&bbuff);
    if((A)0!=d || bbuff.get()!=bbuff.put())
    {
      ipcWarn(wrnlvl(),"%t burst buffer not cleared: %d %d %d\n",
	    d,bbuff.get(),bbuff.put());
    }
  }

  // free bbuff;
  mfbuffer(&bbuff);

  return z;     
}