|
|
9faf9a |
/********************************************************/
|
|
|
9faf9a |
/* ntapi: Native API core library */
|
|
|
64e606 |
/* Copyright (C) 2013--2021 SysDeer Technologies, LLC */
|
|
|
9faf9a |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
9faf9a |
/********************************************************/
|
|
|
9faf9a |
|
|
|
9faf9a |
#include <psxtypes/psxtypes.h>
|
|
|
9faf9a |
#include <ntapi/nt_file.h>
|
|
|
9faf9a |
#include <ntapi/nt_string.h>
|
|
|
9faf9a |
#include <ntapi/nt_atomic.h>
|
|
|
9faf9a |
#include <ntapi/nt_port.h>
|
|
|
9faf9a |
#include <ntapi/nt_ipc.h>
|
|
|
9faf9a |
#include <ntapi/nt_sem.h>
|
|
|
9faf9a |
#include <ntapi/ntapi.h>
|
|
|
9faf9a |
#include "ntapi_impl.h"
|
|
|
9faf9a |
|
|
|
9faf9a |
static int32_t __sem_fdio(
|
|
|
9faf9a |
nt_sem_info * sem,
|
|
|
9faf9a |
nt_iosb * iosb,
|
|
|
9faf9a |
uint32_t opcode)
|
|
|
9faf9a |
{
|
|
|
9faf9a |
int32_t status;
|
|
|
9faf9a |
nt_sem_info_msg msg;
|
|
|
9faf9a |
|
|
|
9faf9a |
/* validate */
|
|
|
9faf9a |
if (!iosb)
|
|
|
9faf9a |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
9faf9a |
|
|
|
9faf9a |
/* msg */
|
|
|
9faf9a |
__ntapi->tt_aligned_block_memset(
|
|
|
9faf9a |
&msg,0,sizeof(msg));
|
|
|
9faf9a |
|
|
|
9faf9a |
msg.header.msg_type = NT_LPC_NEW_MESSAGE;
|
|
|
9faf9a |
msg.header.data_size = sizeof(msg.data);
|
|
|
9faf9a |
msg.header.msg_size = sizeof(msg);
|
|
|
9faf9a |
msg.data.ttyinfo.opcode = opcode;
|
|
|
9faf9a |
|
|
|
9faf9a |
msg.data.seminfo.semkey = sem->semkey;
|
|
|
9faf9a |
msg.data.seminfo.semid = sem->semid;
|
|
|
9faf9a |
msg.data.seminfo.sempid = sem->sempid;
|
|
|
9faf9a |
|
|
|
9faf9a |
if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg)))
|
|
|
9faf9a |
return status;
|
|
|
9faf9a |
else if (msg.data.ttyinfo.status)
|
|
|
9faf9a |
return msg.data.ttyinfo.status;
|
|
|
9faf9a |
|
|
|
9faf9a |
iosb->status = NT_STATUS_SUCCESS;
|
|
|
9faf9a |
iosb->info = 0;
|
|
|
9faf9a |
|
|
|
9faf9a |
return NT_STATUS_SUCCESS;
|
|
|
9faf9a |
}
|
|
|
9faf9a |
|
|
|
9faf9a |
int32_t __stdcall __ntapi_sem_cancel(
|
|
|
9faf9a |
__in nt_sem_info * sem,
|
|
|
9faf9a |
__out nt_iosb * iosb)
|
|
|
9faf9a |
{
|
|
|
9faf9a |
return __sem_fdio(sem,iosb,NT_TTY_SEM_CANCEL);
|
|
|
9faf9a |
}
|
|
|
9faf9a |
|
|
|
9faf9a |
int32_t __stdcall __ntapi_sem_free(
|
|
|
9faf9a |
__in nt_sem_info * sem,
|
|
|
9faf9a |
__out nt_iosb * iosb)
|
|
|
9faf9a |
{
|
|
|
9faf9a |
return __sem_fdio(sem,iosb,NT_TTY_SEM_FREE);
|
|
|
9faf9a |
}
|