示例#1
0
bool
KBootParms::updateParameters(const void *bootData, bool updateKParms)
{
    char *index;

    if (!isBootData(bootData)) return false;

    if (parameterData) {

	// Have existing data we need to clean up 
	freeGlobal(parameterData, parameterDataLength);

	uval moreToDelete, restart=0;
	const char *key;
	char *value;

	// Remove all the entries from the hash
	moreToDelete = paramLookup.removeNext(key, value, restart);
	while (moreToDelete) {
	    moreToDelete = paramLookup.removeNext(key, value, restart);
	    err_printf("Deleting %s\n", key);
	}
    }

    parameterDataLength = *(uval32 *)bootData;
    parameterData = (char *)allocGlobal(parameterDataLength);
    memcpy(parameterData, bootData, parameterDataLength);
    index = parameterData + sizeof(uval32);

    passertMsg(strcmp(index, "KBootParms")==0, "Passed invalid boot data");
    index += strlen("KBootParms")+1;

    char *separator;
    int total_parm_length;
    while (index-parameterData < parameterDataLength) {
	err_printf("Got boot parameter data: %s\n", index);
	total_parm_length = strlen(index)+1;
	separator = strstr(index, "=");
	passertMsg(separator, "Bad boot parameter data %s", index);
	paramLookup.add(index, separator+1);
	*separator = 0;
	index += total_parm_length;
    }

    err_printf("Processed all boot parameters\n");
    bool success = true;

    if (updateKParms) {
	err_printf("About to update KParms\n");
	if (KParms::TheKParms->updatePart(dataRef, bootData, 
					  parameterDataLength)) {
	    success = false;
	}
	err_printf("Updated KParms\n");
    }
    
    return success;
}
示例#2
0
文件: pl-alloc.c 项目: brayc0/nlfetdb
Word
newTerm(void)
{ GET_LD
  Word t = allocGlobal(1);

  setVar(*t);

  return t;
}
示例#3
0
    PTYTaskInfo(pid_t _pid, pid_t _pgrp, pid_t _session,
		uval _tty, uval _leader) {
	// guess that 2048 is big enough for task struct
	mem = (char*)allocGlobal(2048);
	memset(mem, 0, 2048);

	t = getTaskStruct(mem, 2048, _pid, _pgrp, _session,
			  (struct tty_struct*)_tty, _leader);
    }
示例#4
0
/*virtual*/ SysStatus
FileLinuxPacket::connect(const char* addr, uval addrLen,
			 GenState &moreAvail, ThreadWait **tw)
{
    AutoLock<LockType> al(&objLock);

    if (remote) {
	freeGlobal(remote, remoteLen);
    }
    remote = (char*)allocGlobal(addrLen);
    remoteLen = addrLen;
    memcpy(remote, addr, addrLen);

    if (local) {
	freeGlobal(local, localLen);
    }
    localLen = sizeof(localaddr) + 1;
    local = (char*)allocGlobal(localLen);
    memcpy(local, localaddr, localLen);

    moreAvail = available;
    return 0;
}
示例#5
0
文件: pl-alloc.c 项目: brayc0/nlfetdb
static Word
allocString(size_t len ARG_LD)
{ size_t lw = (len+sizeof(word))/sizeof(word);
  int pad = (int)(lw*sizeof(word) - len);
  Word p = allocGlobal(2 + lw);
  word m = mkStrHdr(lw, pad);

  if ( !p )
    return NULL;

  p[0]    = m;
  p[lw]   = 0L;				/* zero the pad bytes */
  p[lw+1] = m;

  return p;
}
示例#6
0
/*virtual*/ SysStatus
FileLinuxPacket::bind(const char* addr, uval addrLen)
{
    SysStatus rc;
    AutoLock<LockType> al(&objLock); // locks now, unlocks on return
    uval len = addrLen;
    char *buf = (char*)allocGlobal(len);
    memcpy(buf, addr, addrLen);
    rc = sps._bind(buf, addrLen);
    if (_SUCCESS(rc)) {
	if (local) {
	    freeGlobal(local, localLen);
	}
	local = buf;
	localLen = addrLen;
    } else {
	freeGlobal(buf, len);
    }
    return rc;

}
示例#7
0
文件: SDCCmem.c 项目: doniexun/kcc
/*-----------------------------------------------------------------*/
int
allocVariables (symbol * symChain)
{
  symbol *sym;
  symbol *csym;
  int stack = 0;
  int saveLevel = 0;

  /* go thru the symbol chain   */
  for (sym = symChain; sym; sym = sym->next)
    {
      /* if this is a typedef then add it */
      /* to the typedef table             */
      if (IS_TYPEDEF (sym->etype))
        {
          /* check if the typedef already exists    */
          csym = findSym (TypedefTab, NULL, sym->name);
          if (csym && csym->level == sym->level)
            werror (E_DUPLICATE_TYPEDEF, sym->name);

          SPEC_EXTR (sym->etype) = 0;
          addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
          continue;             /* go to the next one */
        }
      /* make sure it already exists */
      csym = findSymWithLevel (SymbolTab, sym);
      if (!csym || (csym && csym->level != sym->level))
        csym = sym;

      /* check the declaration */
      checkDecl (csym, 0);

      /* if this is a function or a pointer to a */
      /* function then do args processing        */
      if (funcInChain (csym->type))
        {
          processFuncArgs (csym);
        }

      /* if this is an extern variable then change */
      /* the level to zero temporarily             */
      if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
        {
          saveLevel = csym->level;
          csym->level = 0;
        }

      /* if this is a literal then it is an enumerated */
      /* type so need not allocate it space for it     */
      if (IS_LITERAL (sym->etype))
        continue;

      /* generate the actual declaration */
      if (csym->level)
        {
          allocLocal (csym);
          if (csym->onStack)
            stack += getSize (csym->type);
        }
      else
        allocGlobal (csym);

      /* restore the level */
      if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
        csym->level = saveLevel;
    }

  return stack;
}
示例#8
0
文件: SDCCmem.c 项目: doniexun/kcc
/*-----------------------------------------------------------------*/
void
allocLocal (symbol * sym)
{
  /* generate an unique name */
  SNPRINTF (sym->rname, sizeof(sym->rname),
            "%s%s_%s_%d_%d",
            port->fun_prefix,
            currFunc->name, sym->name, sym->level, sym->block);

  sym->islocal = 1;
  sym->localof = currFunc;

  /* if this is a static variable */
  if (IS_STATIC (sym->etype))
    {
      allocGlobal (sym);
      sym->allocreq = 1;
      return;
    }

  /* if volatile then */
  if (IS_VOLATILE (sym->etype))
    sym->allocreq = 1;

  /* this is automatic           */

  /* if it's to be placed on the stack */
  if (options.stackAuto || reentrant)
    {
      sym->onStack = 1;
      if (options.useXstack)
        {
          /* PENDING: stack direction for xstack */
          SPEC_OCLS (sym->etype) = xstack;
          SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1);
          xstackPtr += getSize (sym->type);
        }
      else
        {
          SPEC_OCLS (sym->etype) = istack;
          if (port->stack.direction > 0)
            {
              SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1);
              stackPtr += getSize (sym->type);
            }
          else
            {
              stackPtr -= getSize (sym->type);
              SPEC_STAK (sym->etype) = sym->stack = stackPtr;
            }
        }
      allocIntoSeg (sym);
      return;
    }

  /* else depending on the storage class specified */

  /* if this is a function then assign code space    */
  if (IS_FUNC (sym->type))
    {
      SPEC_OCLS (sym->etype) = code;
      return;
    }

  /* if this is a bit variable and no storage class */
  if (bit && IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
    {
      SPEC_SCLS (sym->type) = S_BIT;
      SPEC_OCLS (sym->type) = bit;
      allocIntoSeg (sym);
      return;
    }

  if ((SPEC_SCLS (sym->etype) == S_DATA) || (SPEC_SCLS (sym->etype) == S_REGISTER))
    {
      SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
      allocIntoSeg (sym);
      return;
    }

  if (allocDefault (sym))
    {
      return;
    }

  /* again note that we have put it into the overlay segment
     will remove and put into the 'data' segment if required after
     overlay  analysis has been done */
  if (options.model == MODEL_SMALL)
    {
      SPEC_OCLS (sym->etype) =
        (options.noOverlay ? port->mem.default_local_map : overlay);
    }
  else
    {
      SPEC_OCLS (sym->etype) = port->mem.default_local_map;
    }
  allocIntoSeg (sym);
}
示例#9
0
    inline void * operator new(size_t size)
    {
	tassert(size==sizeof(PgAllocTest), err_printf("bad size\n"));
	return allocGlobal(sizeof(PgAllocTest));
    }
示例#10
0
SysStatus
__SetupStack(uval stackBottomLocal, uval &__stackTopLocal,
	     uval &__stackTop, ProgExec::XferInfo *info,
	     ProgExec::ArgDesc* args)
{
    EXECTYPE exectype; // To make WORDTYPE work

    SysStatus rc;
    ProgExec::BinInfo &exec = info->exec.prog;
    uval stackTop = __stackTop;
    uval stackTopLocal = __stackTopLocal;
    char **envp;
    char **argv, **argvp;
    // Put argc, argv on top of stack (envp, aux vec to follow)
    envp = args->getEnvp();
    uval envcChild = VecLen(envp);
    WORDTYPE* envpChild = (WORDTYPE*)allocGlobal(sizeof(WORDTYPE)*envcChild);

    rc = PushStrings<EXECTYPE,WORDTYPE>(envp, envpChild, envcChild-1, stackTop,
					stackTopLocal, stackBottomLocal);

    _IF_FAILURE_RET(rc);
    envpChild[envcChild-1] = (WORDTYPE)NULL;

    argv = args->getArgv();
    argvp = args->getArgvPrefix();
    
    uval argcChild = VecLen(argv);
    uval argcpCount = 0;
    if(argvp) {
	argcpCount = VecLen(argvp)-1; // don't include null entry
	argcChild += argcpCount;
    }
    
    WORDTYPE* argvChild = (WORDTYPE*)allocGlobal(sizeof(WORDTYPE)*argcChild);

    rc = PushStrings<EXECTYPE,WORDTYPE>(argv, argvChild + argcpCount,
					argcChild-argcpCount-1, stackTop,
					stackTopLocal, stackBottomLocal);

    _IF_FAILURE_RET(rc);
    argvChild[argcChild -1] = (WORDTYPE)NULL;

    if(argcpCount) {
	/*
	 * A prefix, containing the shell interpreter args, is present
	 * so push it on top of the original parameters
	 */
	rc = PushStrings<EXECTYPE,WORDTYPE>(argvp, argvChild,
					argcpCount, stackTop,
					stackTopLocal, stackBottomLocal);
	_IF_FAILURE_RET(rc);
    }
	
    // Put in architecture specific aux vector
    uval origLocal = stackTopLocal;
    rc = ProgExec::PutAuxVector<EXECTYPE>(stackTopLocal, exec);
    _IF_FAILURE_RET(rc);

    stackTop -= (origLocal - stackTopLocal);
    info->auxv = (ElfW(auxv_t)*)stackTop;


    stackTopLocal -= envcChild * sizeof(WORDTYPE);
    stackTop -= envcChild * sizeof(WORDTYPE);
    memcpy((char*)stackTopLocal,envpChild, envcChild * sizeof(WORDTYPE));

    info->envp = (char**)stackTop;

    stackTopLocal -= argcChild * sizeof(WORDTYPE);
    stackTop -= argcChild * sizeof(WORDTYPE);
    memcpy((char*)stackTopLocal,argvChild, argcChild * sizeof(WORDTYPE));
    info->argv = (char**)stackTop;

    stackTopLocal -= sizeof(WORDTYPE);
    stackTop -= sizeof(WORDTYPE);
    *(WORDTYPE*)stackTopLocal = (WORDTYPE)(argcChild-1); //store argc on stack
    info->argc = argcChild-1;

    __stackTopLocal = stackTopLocal;
    __stackTop = stackTop;
    freeGlobal(envpChild, envcChild*sizeof(WORDTYPE));
    freeGlobal(argvChild, argcChild*sizeof(WORDTYPE));
    return 0;
}