📄 main.c
字号:
SysFatalError(errno);
/*---------------------------------------------------------------*/
/* Read record at requested offset. */
/*---------------------------------------------------------------*/
rc = read(fid, &record, sizeof(Record));
if (rc == -1)
SysFatalError(errno);
/*---------------------------------------------------------------*/
/* Update high or low pointer or break, depending on comparison. */
/*---------------------------------------------------------------*/
if (key < record.key)
high = pos - 1;
else if (key > record.key)
low = pos + 1;
else
break;
assert(low <= high);
}
}
/*-------------------------------------------------------------------*/
/* Get ending time stamp and calculate timing result. */
/*-------------------------------------------------------------------*/
delta = clock() - sample;
printf("Elapsed time for %u searches is %u seconds\n", i,
(delta + (CLOCKS_PER_SEC / 2)) / CLOCKS_PER_SEC);
close(fid);
taskSleep(50); /* wait til serial interrupts are over */
/*-------------------------------------------------------------------*/
/* Unmount the volume. */
/*-------------------------------------------------------------------*/
printf("Unmounting \"%s\" volume\n", vol_name);
taskSleep(1);
sample = clock();
if (unmount(vol_name))
SysFatalError(errno);
delta = clock() - sample;
printf("Elapsed time for unmount is %u seconds\n",
(delta + (CLOCKS_PER_SEC / 2)) / CLOCKS_PER_SEC);
}
/***********************************************************************/
/* Global Function Definitions */
/***********************************************************************/
/***********************************************************************/
/* main: Application entry point */
/* */
/***********************************************************************/
void main(ui32 unused)
{
int i;
/*-------------------------------------------------------------------*/
/* Lower interrupt mask and start scheduling. */
/*-------------------------------------------------------------------*/
OsStart();
/*-------------------------------------------------------------------*/
/* Lower our priority. */
/*-------------------------------------------------------------------*/
taskSetPri(RunningTask, 20);
/*-------------------------------------------------------------------*/
/* Null CWD variables and assign this task's user and group ID. */
/*-------------------------------------------------------------------*/
FsSetId(0, 0);
FsSaveCWD(0, 0);
/*-------------------------------------------------------------------*/
/* Initialize the file system. */
/*-------------------------------------------------------------------*/
if (InitFFS())
SysFatalError(errno);
#if NUM_RFS_VOLS
/*-------------------------------------------------------------------*/
/* Add the TargetRFS volume. */
/*-------------------------------------------------------------------*/
if (RfsAddVol(RFS_NAME))
SysFatalError(errno);
#endif
/*-------------------------------------------------------------------*/
/* Perform binary search on file system data. */
/*-------------------------------------------------------------------*/
for (i = 0;; ++i)
{
printf("\n****************** Test Loop %u ******************\n", i);
bsearch_app(Volume[i % NUM_FSYS], (i <= NUM_FSYS) && CREATE_DATA);
}
}
/***********************************************************************/
/* OsIdleTask: kernel idle task */
/* */
/***********************************************************************/
void OsIdleTask(ui32 unused)
{
/*-------------------------------------------------------------------*/
/* Loop forever. Feel free to add code here, but nothing that could */
/* block (Don't try a printf()). */
/*-------------------------------------------------------------------*/
for (;;) OsAuditStacks();
}
/***********************************************************************/
/* AppModule: Application interface to software module manager */
/* */
/* Input: req = module request code */
/* ... = additional parameters specific to request */
/* */
/***********************************************************************/
void *AppModule(int req, ...)
{
switch (req)
{
#if PCCARD_SUPPORT
va_list ap;
pccSocket *sock;
case kCardInserted:
printf("Known card inserted\n");
/*---------------------------------------------------------------*/
/* Use va_arg mechanism to fetch pointer to command string. */
/*---------------------------------------------------------------*/
va_start(ap, req);
sock = va_arg(ap, pccSocket *);
va_end(ap);
/*---------------------------------------------------------------*/
/* Parse card type. */
/*---------------------------------------------------------------*/
switch (sock->card.type)
{
case PCCC_ATA:
printf("ATA Drive\n");
if (pccAddATA(sock, "ata"))
{
perror("pccAddATA");
break;
}
break;
default:
printf("unk type = %d\n", sock->card.type);
break;
}
break;
case kCardRemoved:
printf("Card removed\n");
break;
#endif
}
return NULL;
}
/***********************************************************************/
/* FsGetId: Get process user and group ID */
/* */
/* Inputs: uid = place to store user ID */
/* gid = place to store group ID */
/* */
/***********************************************************************/
void FsGetId(uid_t *uid, gid_t *gid)
{
ui32 id = taskGetReg(RunningTask, ID_REG);
*uid = (uid_t)id;
*gid = id >> 16;
}
/***********************************************************************/
/* FsSetId: Set process user and group ID */
/* */
/* Inputs: uid = user ID */
/* gid = group ID */
/* */
/***********************************************************************/
void FsSetId(uid_t uid, gid_t gid)
{
ui32 id = (gid << 16) | uid;
taskSetReg(RunningTask, ID_REG, id);
}
/***********************************************************************/
/* FsSaveCWD: Save per-task current working directory state */
/* */
/* Inputs: word1 = 1 of 2 words to save */
/* word2 = 2 of 2 words to save */
/* */
/***********************************************************************/
void FsSaveCWD(ui32 word1, ui32 word2)
{
taskSetReg(RunningTask, CWD_WD1, word1);
taskSetReg(RunningTask, CWD_WD2, word2);
}
/***********************************************************************/
/* FsReadCWD: Read per-task current working directory state */
/* */
/* Outputs: word1 = 1 of 2 words to retrieve */
/* word2 = 2 of 2 words to retrieve */
/* */
/***********************************************************************/
void FsReadCWD(ui32 *word1, ui32 *word2)
{
*word1 = taskGetReg(RunningTask, CWD_WD1);
*word2 = taskGetReg(RunningTask, CWD_WD2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -