Example #1
0
static int ramdisk_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
		       off_t offset, struct fuse_file_info *fi)
{
	struct stat stbuf;
	FileInfo *finf = File_find(path, root);
	if(finf == NULL) return -ENOENT;
	else if(finf->isFile) {
		File_stat(finf, &stbuf);
		char tmp[strlen(finf->name) + 1];
		strcpy(tmp, finf->name);
  		filler (buf, basename(tmp), &stbuf, 0);
	} else {
		filler (buf, ".", NULL, 0);
	  	filler (buf, "..", NULL, 0);
	  	FileInfo *child = finf->children;
	  	while(child != NULL) {
	  		File_stat(child, &stbuf);
			char tmp[strlen(child->name) + 1];
			strcpy(tmp, child->name);
	  		filler (buf, basename(tmp), &stbuf, 0);
	  		child = child->next;
	  	}
	}
	return 0;
}
Example #2
0
static int ramdisk_getattr(const char *path, struct stat *stbuf)
{
	FileInfo *fi = File_find(path, root);
	if(fi != NULL) {
		File_stat(fi, stbuf);
		return 0;
	} else {
		return -ENOENT;
	}
}
Example #3
0
/*
 *  ======== Processor_create ========
 */
Processor_Handle Processor_create(String imageName, String linkCfg,
    Processor_Attrs *attrs)
{
    Processor_Handle proc = NULL;
    File_Stat statBuf;

    GT_assert(curTrace, curInit == TRUE);

    GT_3trace(curTrace, GT_ENTER, "Processor_create> "
        "Enter(imageName='%s', linkCfg='%s', attrs=0x%x)\n", imageName,
        linkCfg, attrs);

    if (attrs == NULL) {
        attrs = &Processor_ATTRS;
    }

    if ((!Global_useLinkArbiter) &&
            (File_stat(imageName, &statBuf) != File_EOK)) {
        GT_1trace(curTrace, GT_7CLASS, "Processor_create> "
            "ERROR: cannot access file %s\n", imageName);
        return (NULL);
    }

    if ((proc = Memory_alloc(sizeof(Processor_Obj), NULL)) == NULL) {
        GT_0trace(curTrace, GT_7CLASS, "Processor_create> "
            "ERROR: Memory_alloc failed\n");
        return (NULL);
    }

    proc->attrs = *attrs;
    proc->imageName = imageName;
    proc->linkConfigName = linkCfg;
    proc->loaded = FALSE;
    proc->powerHandle = NULL;
    proc->connected = FALSE;

    if (doCmd(CREATE, proc) != SUCCESS) {
        Processor_delete(proc);
        return (NULL);
    }
    proc->loaded = TRUE;

    GT_1trace(curTrace, GT_ENTER, "Processor_create> return (0x%x)\n", proc);

    return (proc);
}
Example #4
0
/*
 *  ======== LAD_startupDsp ========
 */
LAD_Status LAD_startupDsp(LAD_ClientHandle handle, Int cpuId,
                          String linkConfigName, String imageName)
{
    File_Stat   fileStat;
    Int         linkConfigIdDSP = -1;
    PROC_State  procState;
    Int         clientId = (Int)handle;
    Int         linkConfigId;
    Bool        startingDSP = FALSE;    /* Will start DSP */
    UInt32      dspStatus = 0;
    LadRegData  ladData;
    DWORD       waitStatus;
    DSP_STATUS  linkStatus = DSP_SOK;
    LAD_Status  status = LAD_SUCCESS;

    /* sanity check params  */
    if ((imageName == NULL) || (clientId >= LAD_MAXNUMCLIENTS) ||
            (clientId < 0)) {
        return (LAD_INVALIDARG);
    }

    /* check for initialization and connection */
    if ((refCount <= 0) ||
            (clientInfo[handle].connectedToLAD == FALSE)) {
        PRINTVERBOSE0(
            "\nLAD_startupDsp: rejecting since not connected to LAD\n");
        return (LAD_NOTCONNECTED);
    }

    /* Check that server file exists */
    if (File_stat(imageName, &fileStat) != File_EOK) {
        PRINTVERBOSE0("LAD_startupDSP: server file doesn't exist!\n");
        PRINTVERBOSE0("LAD_startupDSP: returning LAD_INVALIDARG\n");
        return (LAD_INVALIDARG);
    }

    /* map the Link config name to an index */
    if (_LAD_getConfigId(linkConfigName, (UInt32 *)&linkConfigId) == FALSE) {
        PRINTVERBOSE0("LAD_startupDsp: lookup of Link config name failed!\n");
        PRINTVERBOSE0("LAD_startupDsp: returning LAD_INVALIDARG\n");
        return (LAD_INVALIDARG);
    }

    PRINTVERBOSE1("\nLAD_startupDsp: linkConfigId = %x\n", linkConfigId);

    /*
     *  check if cpuId is valid for the linkConfigId. NOTE: MAX_DSPS is a
     *  compile define that is set in dsplinkcfg.pl.
     */
    if (cpuId > (MAX_DSPS - 1)) {
        PRINTVERBOSE0("LAD_startupDsp: cpuId out of range for Link config\n");
        PRINTVERBOSE0("LAD_startupDsp: returning LAD_INVALIDARG\n");
        return (LAD_INVALIDARG);
    }

    /* Enter critical section */
    waitStatus = WaitForSingleObject(_LAD_mutex, TIMEOUT);
    if (waitStatus != WAIT_OBJECT_0) {
        if (waitStatus == WAIT_TIMEOUT) {
            PRINTVERBOSE0("LAD_startupDsp: WaitForSingleObject() timed out\n");
            PRINTVERBOSE0("LAD_startupDsp: returning LAD_FAILURE\n");
            return (LAD_FAILURE);
        }
        else {
            PRINTVERBOSE0("LAD_startupDsp: WaitForSingleObject() failed!\n");
            PRINTVERBOSE0("LAD_startupDsp: returning LAD_FAILURE\n");
            return (LAD_FAILURE);
        }
    }

    /* Get the status of the DSP */
    linkStatus = PROC_getState(cpuId, &procState);

    if (linkStatus == DSP_SOK) {
        PRINTVERBOSE1("\nLAD_startupDsp: PROC state=%x\n", procState);
    }
    else {
        ReleaseMutex(_LAD_mutex);
        PRINTVERBOSE1("\nLAD_startupDsp: PROC_getState FAILED 0x%lx\n",
                      linkStatus);
        PRINTVERBOSE0("LAD_startupDsp: returning LAD_FAILURE\n");
        return (LAD_FAILURE);
    }

    /* if DSP already started... */
    if (procState == LAD_STARTED) {

        /* Read LAD data from registry. */
        status = getLadRegData(&ladData, LadKey_ALL);
        if (status != LAD_SUCCESS) {
            PRINTVERBOSE0("\nLAD_startupDsp: getLadRegData() failed!\n");
        }
        else {
            /*  check for exact match */
            if (linkConfigId != ladData.linkConfigId) {
                PRINTVERBOSE0("LAD_startupDsp: linkConfig does not match\n");
                PRINTVERBOSE0("    the currintly loaded DSP.\n");
                PRINTVERBOSE0("    LAD_ACCESSDENIED\n");
                status = LAD_ACCESSDENIED;
            }
            if (strcmp(imageName, ladData.imageName) != 0) {
                /* when no match reject the request */
                PRINTVERBOSE0("LAD_startupDsp: imageName does not match\n");
                PRINTVERBOSE0("    the currintly loaded DSP.\n");
                PRINTVERBOSE0("    LAD_ACCESSDENIED\n");
                status = LAD_ACCESSDENIED;
            }
        }

        if (status == LAD_SUCCESS) {
            /* Image and link config match, increment started clients count */
            ladData.numClientsStarted++;
            setLadRegData(&ladData, LadKey_NUMCLIENTSSTARTED);

            clientCpu[clientId] = cpuId;
            clientStarted[clientId] = TRUE;
            status = LAD_ALREADYRUNNING;
            PRINTVERBOSE0("\n    LAD_ALREADYRUNNING")
        }