本文整理汇总了C++中rtems_semaphore_release函数的典型用法代码示例。如果您正苦于以下问题:C++ rtems_semaphore_release函数的具体用法?C++ rtems_semaphore_release怎么用?C++ rtems_semaphore_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtems_semaphore_release函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: msdos_file_ftruncate
/* msdos_file_ftruncate --
* Truncate the file (if new length is greater then current do nothing).
*
* PARAMETERS:
* iop - file control block
* length - new length
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately).
*/
int
msdos_file_ftruncate(rtems_libio_t *iop, rtems_off64_t length)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
if (length >= fat_fd->fat_file_size)
return RC_OK;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
rc = fat_file_truncate(iop->pathinfo.mt_entry, fat_fd, length);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
/*
* fat_file_truncate do nothing if new length >= fat-file size, so update
* file size only if length < fat-file size
*/
if (length < fat_fd->fat_file_size)
iop->size = fat_fd->fat_file_size = length;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
开发者ID:rtemss,项目名称:rtems,代码行数:43,代码来源:msdos_file.c
示例2: msdos_file_lseek
/* msdos_file_lseek --
* Process lseek call to the file: extend file if lseek is up to the end
* of the file.
*
* PARAMETERS:
* iop - file control block
* offset - new offset
* whence - predefine directive
*
* RETURNS:
* new offset on success, or -1 if error occured (errno set
* appropriately).
*/
rtems_off64_t
msdos_file_lseek(rtems_libio_t *iop, rtems_off64_t offset, int whence)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
uint32_t real_size = 0;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
rc = fat_file_extend(iop->pathinfo.mt_entry, fat_fd, iop->offset,
&real_size);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
if (real_size > fat_fd->fat_file_size)
fat_fd->fat_file_size = iop->offset = real_size;
iop->size = fat_fd->fat_file_size;
rtems_semaphore_release(fs_info->vol_sema);
return iop->offset;
}
开发者ID:rtemss,项目名称:rtems,代码行数:43,代码来源:msdos_file.c
示例3: task
/*
* Task that calls the function we want to trace
*/
static void task(rtems_task_argument arg)
{
rtems_status_code sc;
uint32_t i;
for ( i = 0; i < ITERATIONS; i++ ) {
/*
* Wait until the previous task in the task chain
* has completed its operation.
*/
sc = rtems_semaphore_obtain(task_data[arg].prev_sem, 0, 0);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
add_number_wrapper(arg, i);
/*
* Signal the next task in the chain to continue
*/
sc = rtems_semaphore_release(task_data[arg].task_sem);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
/* Signal the main task that this task has finished */
sc = rtems_semaphore_release(finished_sem);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
rtems_task_suspend(rtems_task_self());
}
开发者ID:WattTech,项目名称:rtems,代码行数:30,代码来源:init.c
示例4: release_semaphore
static void release_semaphore(rtems_id timer, void *arg)
{
/* The arg is NULL */
test_context *ctx = &ctx_instance;
rtems_status_code sc;
if (
_Thread_Wait_flags_get(ctx->main_task_control)
== (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK)
) {
CORE_semaphore_Control *sem;
ctx->done = true;
sc = rtems_semaphore_release(ctx->semaphore_id);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
rtems_test_assert(
_Thread_Wait_flags_get(ctx->main_task_control)
== (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN)
);
sem = &ctx->semaphore_control->Core_control.Semaphore;
rtems_test_assert(sem->count == 0);
} else {
sc = rtems_semaphore_release(ctx->semaphore_id);
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
}
开发者ID:greenmeent,项目名称:rtems,代码行数:28,代码来源:init.c
示例5: msdos_file_open
/* msdos_file_open --
* Open fat-file which correspondes to the file
*
* PARAMETERS:
* iop - file control block
* pathname - name
* flag - flags
* mode - mode
*
* RETURNS:
* RC_OK, if file opened successfully, or -1 if error occured
* and errno set appropriately
*/
int
msdos_file_open(rtems_libio_t *iop, const char *pathname, uint32_t flag,
uint32_t mode)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
rc = fat_file_reopen(fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
if (iop->flags & LIBIO_FLAGS_APPEND)
iop->offset = fat_fd->fat_file_size;
iop->size = fat_fd->fat_file_size;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
开发者ID:rtemss,项目名称:rtems,代码行数:42,代码来源:msdos_file.c
示例6: OS_FileOpenCheck
/* --------------------------------------------------------------------------------------
Name: OS_FileOpenCheck
Purpose: Checks to see if a file is open
Returns: OS_FS_ERROR if the file is not open
OS_FS_SUCCESS if the file is open
---------------------------------------------------------------------------------------*/
int32 OS_FileOpenCheck(char *Filename)
{
rtems_status_code rtems_sc;
uint32 i;
if (Filename == NULL)
{
return(OS_FS_ERR_INVALID_POINTER);
}
rtems_sc = rtems_semaphore_obtain (OS_FDTableSem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
if ((OS_FDTable[i].IsValid == TRUE) && (strcmp(OS_FDTable[i].Path, Filename) == 0))
{
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
return(OS_FS_SUCCESS);
}
}/* end for */
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
return OS_FS_ERROR;
}/* end OS_FileOpenCheck */
开发者ID:felipeprov,项目名称:osal,代码行数:33,代码来源:osfileapi.c
示例7: rtems_termios_device_open
rtems_status_code
rtems_termios_device_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
rtems_status_code sc;
rtems_termios_device_node *device_node;
struct rtems_termios_tty *tty;
sc = rtems_semaphore_obtain(
rtems_termios_ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
return sc;
device_node = rtems_termios_find_device_node (major, minor);
if (device_node == NULL) {
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_INVALID_ID;
}
tty = rtems_termios_open_tty(
major, minor, arg, device_node->tty, device_node, NULL);
if (tty == NULL) {
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_NO_MEMORY;
}
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_SUCCESSFUL;
}
开发者ID:jingfenglanyun,项目名称:rtems,代码行数:33,代码来源:termios.c
示例8: rtems_termios_write
rtems_status_code
rtems_termios_write (void *arg)
{
rtems_libio_rw_args_t *args = arg;
struct rtems_termios_tty *tty = args->iop->data1;
rtems_status_code sc;
sc = rtems_semaphore_obtain (tty->osem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
return sc;
if (rtems_termios_linesw[tty->t_line].l_write != NULL) {
sc = rtems_termios_linesw[tty->t_line].l_write(tty,args);
rtems_semaphore_release (tty->osem);
return sc;
}
if (tty->termios.c_oflag & OPOST) {
uint32_t count = args->count;
char *buffer = args->buffer;
while (count--)
oproc (*buffer++, tty);
args->bytes_moved = args->count;
}
else {
rtems_termios_puts (args->buffer, args->count, tty);
args->bytes_moved = args->count;
}
rtems_semaphore_release (tty->osem);
return sc;
}
开发者ID:epicsdeb,项目名称:rtems,代码行数:29,代码来源:termios.c
示例9: msdos_file_sync
/* msdos_file_sync --
* Synchronize file - synchronize file data and if file is not removed
* synchronize file metadata.
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_sync(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
rc = fat_file_update(&fs_info->fat, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
rc = fat_sync(&fs_info->fat);
rtems_semaphore_release(fs_info->vol_sema);
if ( rc != 0 )
rtems_set_errno_and_return_minus_one(EIO);
return RC_OK;
}
开发者ID:AoLaD,项目名称:rtems,代码行数:38,代码来源:msdos_file.c
示例10: Task01
/* Task01 starts with priority 36 */
rtems_task Task01(rtems_task_argument ignored)
{
rtems_status_code status;
printf("TA01: started with priority %d\n", getprio());
status = rtems_semaphore_obtain( sem_id[0], RTEMS_WAIT, 0 );
directive_failed( status, "rtems_semaphore_obtain of S0\n");
printf("TA01: priority %d, holding S0\n", getprio());
status = rtems_semaphore_obtain( sem_id[1], RTEMS_WAIT, 0 );
directive_failed( status, "rtems_semaphore_obtain of S1");
printf("TA01: priority %d, holding S0, S1\n", getprio());
/* Start Task 2 (TA02) with priority 34. It will run immediately. */
status = rtems_task_start( Task_id[1], Task02, 0);
directive_failed( status, "rtems_task_start of TA02\n");
/* Start Task 3 (TA03) with priority 32. It will run immediately. */
status = rtems_task_start( Task_id[2], Task03, 0);
directive_failed( status, "rtems_task_start of TA03\n");
printf("TA01: priority %d, holding S0, S1\n", getprio());
status = rtems_semaphore_release(sem_id[1]);
directive_failed( status, "rtems_semaphore_release of S1\n");
printf("TA01: priority %d, holding S0\n", getprio());
status = rtems_semaphore_release(sem_id[0]);
directive_failed( status, "rtems_semaphore_release of S0\n");
printf("TA01: priority %d\n", getprio());
printf("TA01: exiting\n");
TEST_END();
rtems_test_exit(0);
}
开发者ID:gedare,项目名称:rtems,代码行数:36,代码来源:init.c
示例11: Task01
/* Task01 starts with priority 36 */
rtems_task Task01(rtems_task_argument ignored)
{
rtems_status_code status;
printf("TA01: started with priority %d\n", getprio());
status = rtems_semaphore_obtain( sem_id[0], RTEMS_WAIT, 0 );
directive_failed( status, "rtems_semaphore_obtain of S0\n");
printf("TA01: priority %d, holding S0\n", getprio());
status = rtems_semaphore_obtain( sem_id[1], RTEMS_WAIT, 0 );
directive_failed( status, "rtems_semaphore_obtain of S1");
printf("TA01: priority %d, holding S0, S1\n", getprio());
/* Start Task 2 (TA02) with priority 34. It will run immediately. */
status = rtems_task_start( Task_id[1], Task02, 0);
directive_failed( status, "rtems_task_start of TA02\n");
status = rtems_semaphore_release(sem_id[1]);
directive_failed( status, "rtems_semaphore_release of S1\n");
printf("TA01: priority %d, holding S0\n", getprio());
status = rtems_semaphore_release(sem_id[0]);
directive_failed( status, "rtems_semaphore_release of S0\n");
printf("TA01: priority %d\n", getprio());
printf("TA01: exiting\n");
printf("*** END OF SEM01 ***\n");
status = rtems_task_delete( RTEMS_SELF);
directive_failed( status, "rtems_task_delete TA01");
}
开发者ID:chch1028,项目名称:rtems,代码行数:31,代码来源:init.c
示例12: msdos_file_rmnod
/* msdos_file_rmnod --
* Remove node associated with a file - set up first name character to
* predefined value(and write it to the disk), and mark fat-file which
* correspondes to the file as "removed"
*
* PARAMETERS:
* pathloc - node description
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_rmnod(rtems_filesystem_location_info_t *parent_pathloc,
rtems_filesystem_location_info_t *pathloc)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = pathloc->node_access;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
/* mark file removed */
rc = msdos_set_first_char4file_name(pathloc->mt_entry,
&fat_fd->dir_pos,
MSDOS_THIS_DIR_ENTRY_EMPTY);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
fat_file_mark_removed(pathloc->mt_entry, fat_fd);
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
开发者ID:rtemss,项目名称:rtems,代码行数:40,代码来源:msdos_file.c
示例13: msdos_file_write
/* msdos_file_write --
* This routine writes the specified data buffer into the file pointed to
* by file control block.
*
* PARAMETERS:
* iop - file control block
* buffer - data to write
* count - count of bytes to write
*
* RETURNS:
* the number of bytes written on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
msdos_file_write(rtems_libio_t *iop,const void *buffer, size_t count)
{
ssize_t ret = 0;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
ret = fat_file_write(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
buffer);
if (ret < 0)
{
rtems_semaphore_release(fs_info->vol_sema);
return -1;
}
/*
* update file size in both fat-file descriptor and file control block if
* file was extended
*/
if (iop->offset + ret > fat_fd->fat_file_size)
fat_fd->fat_file_size = iop->offset + ret;
iop->size = fat_fd->fat_file_size;
rtems_semaphore_release(fs_info->vol_sema);
return ret;
}
开发者ID:rtemss,项目名称:rtems,代码行数:46,代码来源:msdos_file.c
示例14: task_pool_release
/*PAGE
*
* task_pool_release
*
* Return task obtained by 'obtain()' back to the task pool.
*
* Input parameters:
* info - pointer to corresponding SessionInfo structure.
*
* Output parameters:
* NONE
*
*/
static void
task_pool_release(FTPD_SessionInfo_t* info)
{
rtems_semaphore_obtain(task_pool.mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
task_pool.queue[task_pool.tail] = info;
if(++task_pool.tail >= task_pool.count)
task_pool.tail = 0;
rtems_semaphore_release(task_pool.mutex);
rtems_semaphore_release(task_pool.sem);
}
开发者ID:epicsdeb,项目名称:rtems,代码行数:23,代码来源:ftpd.c
示例15: rtems_termios_device_install
rtems_status_code rtems_termios_device_install(
const char *device_file,
rtems_device_major_number major,
rtems_device_minor_number minor,
const rtems_termios_device_handler *handler,
void *context
)
{
rtems_status_code sc;
rtems_termios_device_node *new_device_node;
rtems_termios_device_node *existing_device_node;
new_device_node = malloc(sizeof(*new_device_node));
if (new_device_node == NULL) {
return RTEMS_NO_MEMORY;
}
new_device_node->major = major;
new_device_node->minor = minor;
new_device_node->handler = handler;
new_device_node->context = context;
new_device_node->tty = NULL;
sc = rtems_semaphore_obtain(
rtems_termios_ttyMutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL) {
free(new_device_node);
return RTEMS_INCORRECT_STATE;
}
existing_device_node = rtems_termios_find_device_node (major, minor);
if (existing_device_node != NULL) {
free(new_device_node);
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_RESOURCE_IN_USE;
}
if (device_file != NULL) {
sc = rtems_io_register_name (device_file, major, minor);
if (sc != RTEMS_SUCCESSFUL) {
free(new_device_node);
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_UNSATISFIED;
}
}
rtems_chain_append_unprotected(
&rtems_termios_devices, &new_device_node->node);
rtems_semaphore_release (rtems_termios_ttyMutex);
return RTEMS_SUCCESSFUL;
}
开发者ID:jingfenglanyun,项目名称:rtems,代码行数:53,代码来源:termios.c
示例16: grtm_open
static rtems_device_driver grtm_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg)
{
struct grtm_priv *pDev;
struct drvmgr_dev *dev;
FUNCDBG();
if ( drvmgr_get_dev(&grtm_rmap_drv_info.general, minor, &dev) ) {
DBG("Wrong minor %d\n", minor);
return RTEMS_INVALID_NUMBER;
}
pDev = (struct grtm_priv *)dev->priv;
/* Wait until we get semaphore */
if ( rtems_semaphore_obtain(grtm_dev_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT) != RTEMS_SUCCESSFUL ){
return RTEMS_INTERNAL_ERROR;
}
/* Is device in use? */
if ( pDev->open ){
rtems_semaphore_release(grtm_dev_sem);
return RTEMS_RESOURCE_IN_USE;
}
/* Mark device taken */
pDev->open = 1;
rtems_semaphore_release(grtm_dev_sem);
DBG("grtm_open: OPENED minor %d (pDev: 0x%x)\n",pDev->minor,(unsigned int)pDev);
/* Set defaults */
pDev->config.timeout = RTEMS_NO_TIMEOUT; /* no timeout (wait forever) */
pDev->config.blocking = 0; /* polling mode */
pDev->running = 0; /* not in running mode yet */
memset(&pDev->config,0,sizeof(pDev->config));
/* The core has been reset when we execute here, so it is possible
* to read out what HW is implemented from core.
*/
grtm_hw_get_implementation(pDev, &pDev->hw_avail);
/* Get default modes */
grtm_hw_get_default_modes(&pDev->config,&pDev->hw_avail);
return RTEMS_SUCCESSFUL;
}
开发者ID:FullMentalPanic,项目名称:RTEMS_NEW_TOOL_CHAIN,代码行数:52,代码来源:grtm_rmap.c
示例17: OS_close
int32 OS_close (int32 filedes)
{
int status;
rtems_status_code rtems_sc;
/* Make sure the file descriptor is legit before using it */
if (filedes < 0 || filedes >= OS_MAX_NUM_OPEN_FILES || OS_FDTable[filedes].IsValid == FALSE)
{
return OS_FS_ERR_INVALID_FD;
}
else
{
status = close ((int) OS_FDTable[filedes].OSfd);
if (status == ERROR)
{
/*
** First, try one more time to close the file
** In case it was an interrupted system call
*/
status = close ((int) OS_FDTable[filedes].OSfd);
/*
** Next, remove the file from the OSAL list
** to free up that slot
*/
/* fill in the table before returning */
rtems_sc = rtems_semaphore_obtain (OS_FDTableSem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
OS_FDTable[filedes].OSfd = -1;
strcpy(OS_FDTable[filedes].Path, "\0");
OS_FDTable[filedes].User = 0;
OS_FDTable[filedes].IsValid = FALSE;
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
return OS_FS_ERROR;
}
else
{
/* fill in the table before returning */
rtems_sc = rtems_semaphore_obtain (OS_FDTableSem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
OS_FDTable[filedes].OSfd = -1;
strcpy(OS_FDTable[filedes].Path, "\0");
OS_FDTable[filedes].User = 0;
OS_FDTable[filedes].IsValid = FALSE;
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
return OS_FS_SUCCESS;
}
}
}/* end OS_close */
开发者ID:gpgreen,项目名称:osal-beagleboard,代码行数:51,代码来源:osfileapi.c
示例18: bfin_twi_isr
void bfin_twi_isr(int source) {
void *base;
int i;
uint16_t r;
uint16_t stat;
for (i = 0; i < N_BFIN_TWI; i++) {
base = twi[i].base;
if (base) {
stat = BFIN_REG16(base, TWI_INT_STAT_OFFSET);
if (stat) {
BFIN_REG16(base, TWI_INT_STAT_OFFSET) = stat;
if ((stat & TWI_INT_STAT_SINIT) && !twi[i].slaveActive) {
twi[i].slaveActive = true;
r = BFIN_REG16(base, TWI_FIFO_CTL_OFFSET);
BFIN_REG16(base, TWI_FIFO_CTL_OFFSET) = r | TWI_FIFO_CTL_XMTFLUSH;
BFIN_REG16(base, TWI_FIFO_CTL_OFFSET) = r;
r = BFIN_REG16(base, TWI_SLAVE_CTL_OFFSET);
BFIN_REG16(base, TWI_SLAVE_CTL_OFFSET) = r | TWI_SLAVE_CTL_STDVAL;
}
if (twi[i].slaveActive) {
if (stat & (TWI_INT_STAT_SCOMP | TWI_INT_STAT_SERR)) {
r = BFIN_REG16(base, TWI_SLAVE_CTL_OFFSET);
BFIN_REG16(base, TWI_SLAVE_CTL_OFFSET) = r & ~TWI_SLAVE_CTL_STDVAL;
twi[i].slaveActive = false;
}
}
if (twi[i].masterActive && !twi[i].slaveActive) {
if (stat & (TWI_INT_STAT_MCOMP | TWI_INT_STAT_MERR)) {
if (!(stat & TWI_INT_STAT_MERR)) {
rtems_semaphore_release(twi[i].irqSem);
} else
rtems_semaphore_release(twi[i].irqSem);
}
}
}
}
}
}
开发者ID:RTEMS,项目名称:rtems,代码行数:51,代码来源:twi.c
示例19: msdos_file_sync
/* msdos_file_sync --
* Synchronize file - synchronize file data and if file is not removed
* synchronize file metadata.
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_sync(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
fat_file_fd_t *fat_fd = iop->pathinfo.node_access;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
/* synchronize file data */
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
/*
* if fat-file descriptor is not marked "removed" - synchronize file
* metadata
*/
if (!FAT_FILE_IS_REMOVED(fat_fd))
{
rc = msdos_set_first_cluster_num(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
rc = msdos_set_file_size(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
rc = msdos_set_dir_wrt_time_and_date(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
}
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
开发者ID:rtemss,项目名称:rtems,代码行数:60,代码来源:msdos_file.c
示例20: OS_CloseFileByName
/* --------------------------------------------------------------------------------------
Name: OS_CloseFileByName
Purpose: Allows a file to be closed by name.
This will only work if the name passed in is the same name used to open
the file.
Returns: OS_FS_ERR_PATH_INVALID if the file is not found
OS_FS_ERROR if the file close returned an error
OS_FS_SUCCESS if the file close suceeded
---------------------------------------------------------------------------------------*/
int32 OS_CloseFileByName(char *Filename)
{
rtems_status_code rtems_sc;
uint32 i;
int status;
if (Filename == NULL)
{
return(OS_FS_ERR_INVALID_POINTER);
}
rtems_sc = rtems_semaphore_obtain (OS_FDTableSem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
for ( i = 0; i < OS_MAX_NUM_OPEN_FILES; i++)
{
if ((OS_FDTable[i].IsValid == TRUE) && (strcmp(OS_FDTable[i].Path, Filename) == 0))
{
/*
** Close the file
*/
status = close ((int) OS_FDTable[i].OSfd);
/*
** Next, remove the file from the OSAL list
** to free up that slot
*/
OS_FDTable[i].OSfd = -1;
strcpy(OS_FDTable[i].Path, "\0");
OS_FDTable[i].User = 0;
OS_FDTable[i].IsValid = FALSE;
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
if (status == ERROR)
{
return(OS_FS_ERROR);
}
else
{
return(OS_FS_SUCCESS);
}
}
}/* end for */
rtems_sc = rtems_semaphore_release (OS_FDTableSem);
return (OS_FS_ERR_PATH_INVALID);
}/* end OS_CloseFileByName */
开发者ID:gpgreen,项目名称:osal-beagleboard,代码行数:59,代码来源:osfileapi.c
注:本文中的rtems_semaphore_release函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论