#define SYS_SETFAULTHANDLER 3 // Set signal Handler
#define SYS_YIELD 4 // Yield remainder of timestamp
#define SYS_SLEEP 5 // Sleep until messaged or signaled
-#define SYS_WAIT 6 // Wait for a time or a message
+#define SYS_WAITEVENT 6 // Wait for an event
#define SYS_WAITTID 7 // Wait for a thread to do something
-#define SYS_SETNAME 8 // Set's the name of the current thread
-#define SYS_GETNAME 9 // Get's the name of a thread
+#define SYS_SETNAME 8 // Sets the name of the current thread
+#define SYS_GETNAME 9 // Gets the name of a thread
#define SYS_GETTID 10 // Get current thread ID
#define SYS_GETPID 11 // Get current thread group ID
#define SYS_SETPRI 12 // Set process priority
"SYS_SETFAULTHANDLER",
"SYS_YIELD",
"SYS_SLEEP",
- "SYS_WAIT",
+ "SYS_WAITEVENT",
"SYS_WAITTID",
"SYS_SETNAME",
"SYS_GETNAME",
%define SYS_SETFAULTHANDLER 3 ;Set signal Handler
%define SYS_YIELD 4 ;Yield remainder of timestamp
%define SYS_SLEEP 5 ;Sleep until messaged or signaled
-%define SYS_WAIT 6 ;Wait for a time or a message
+%define SYS_WAITEVENT 6 ;Wait for an event
%define SYS_WAITTID 7 ;Wait for a thread to do something
-%define SYS_SETNAME 8 ;Set's the name of the current thread
-%define SYS_GETNAME 9 ;Get's the name of a thread
+%define SYS_SETNAME 8 ;Sets the name of the current thread
+%define SYS_GETNAME 9 ;Gets the name of a thread
%define SYS_GETTID 10 ;Get current thread ID
%define SYS_GETPID 11 ;Get current thread group ID
%define SYS_SETPRI 12 ;Set process priority
* \param WriteHandles Handles to wait to write to
* \param ErrHandles Handle to wait for errors on
* \param Timeout Timeout for select() (if null, there is no timeout), if zero select() is non blocking
+ * \param ExtraEvents Extra event set to wait on
* \param IsKernel Use kernel handles as opposed to user handles
* \return Number of handles that actioned
*/
-extern int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel);
+extern int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, Uint32 ExtraEvents, BOOL IsKernel);
/**
* \brief Map a file into memory
#include <hal_proc.h>
#include <errno.h>
#include <threads.h>
+#include <events.h>
#define CHECK_NUM_NULLOK(v,size) \
if((v)&&!Syscall_Valid((size),(v))){ret=-1;err=-EINVAL;break;}
err = -ENOSYS;
ret = -1;
break;
-
+
+ // -- Wait fr an event
+ case SYS_WAITEVENT:
+ // Message mask
+ ret = Threads_WaitEvents(Regs->Arg1);
+ break;
+
// -- Wait for a thread
case SYS_WAITTID:
// Sanity Check (Status can be NULL)
(fd_set *)Regs->Arg3, // Write
(fd_set *)Regs->Arg4, // Errors
(tTime *)Regs->Arg5, // Timeout
+ (Uint32)Regs->Arg6, // Extra wakeup events
0 // User handles
);
break;
SYS_SETFAULTHANDLER Set signal Handler
SYS_YIELD Yield remainder of timestamp
SYS_SLEEP Sleep until messaged or signaled
-SYS_WAIT Wait for a time or a message
+SYS_WAITEVENT Wait for an event
SYS_WAITTID Wait for a thread to do something
-SYS_SETNAME Set's the name of the current thread
-SYS_GETNAME Get's the name of a thread
+SYS_SETNAME Sets the name of the current thread
+SYS_GETNAME Gets the name of a thread
SYS_GETTID Get current thread ID
SYS_GETPID Get current thread group ID
SYS_SETPRI Set process priority
// === PROTOTYPES ===
// int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout);
-// int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel);
+// int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, Uint32 ExtraEvents, BOOL IsKernel);
// int VFS_MarkFull(tVFS_Node *Node, BOOL IsBufferFull);
// int VFS_MarkAvaliable(tVFS_Node *Node, BOOL IsDataAvaliable);
// int VFS_MarkError(tVFS_Node *Node, BOOL IsErrorState);
return ret;
}
-int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, BOOL IsKernel)
+int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set *ErrHandles, tTime *Timeout, Uint32 ExtraEvents, BOOL IsKernel)
{
tThread *thisthread = Proc_GetCurThread();
int ret;
{
// TODO: Timeout
// TODO: Allow extra events to be waited upon
- Threads_WaitEvents( THREAD_EVENT_VFS );
+ Threads_WaitEvents( THREAD_EVENT_VFS|ExtraEvents );
}
// Fill output (modify *Handles)
IPC_FillSelect(&nfds, &fds);
nfds ++;
- if( select(nfds, &fds, NULL, NULL, NULL) == -1 ) {
+ if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
_SysDebug("ERROR: select() returned -1");
return -1;
}
{
case CONNTYPE_SENDMESSAGE:
// TODO: Less hack, I need a version of select for GetMessage etc
- if(SysGetMessage(NULL, NULL) == 0) sleep();
+ if(SysGetMessage(NULL, NULL) == 0) _SysWaitEvent(THREAD_EVENT_IPCMSG);
while(SysGetMessage(NULL, NULL))
{
pid_t tid;
-include ../Makefile.cfg
OBJ := main.o lib.o loadlib.o export.o elf.o pe.o
-OBJ += arch/$(ARCHDIR).ao
+OBJ += arch/$(ARCHDIR).ao_
BIN = ld-acess.so
EXTRABIN := libld-acess.so
EXTRACLEAN := $(_OBJPREFIX)_stublib.o
# Override .ao to look in the object prefix for the source
-%.ao: %.$(ASSUFFIX)
+$(_OBJPREFIX)arch/$(ARCHDIR).ao_: $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX)
@echo [AS] -o $@
@mkdir -p $(dir $@)
@$(AS) $(ASFLAGS) -o $@ $<
-.PRECIOUS: $(OBJ:%.ao=%.asm)
+#.PRECIOUS: $(OBJ:%.ao=%.asm)
# Preprocessing objects if needed
-$(_OBJPREFIX)%: %.h
+$(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX): arch/$(ARCHDIR).$(ASSUFFIX).h arch/syscalls.s.h
@echo [CPP] -o $@
@mkdir -p $(dir $@)
@$(CPP) $(CPPFLAGS) -P -D__ASSEMBLER__ $< -o $@
+$(_OBJPREFIX)_stublib.o: arch/syscalls.s.h
+
SYSCALL2(kill, SYS_KILL)
SYSCALL0(yield, SYS_YIELD)
SYSCALL0(sleep, SYS_SLEEP)
+SYSCALL1(_SysWaitEvent, SYS_WAITEVENT)
SYSCALL2(waittid, SYS_WAITTID)
SYSCALL0(gettid, SYS_GETTID)
SYSCALL1(chdir, SYS_CHDIR) // char*
SYSCALL3(ioctl, SYS_IOCTL) // int, int, void*
SYSCALL4(_SysMount, SYS_MOUNT) // char*, char*, char*, char*
-SYSCALL5(select, SYS_SELECT) // int, fd_set*, fd_set*, fd_set*, tTime*
+SYSCALL6(_SysSelect, SYS_SELECT) // int, fd_set*, fd_set*, fd_set*, tTime*, uint32_t
SYSCALL3(_SysOpenChild, SYS_OPENCHILD)
EXP(kill),
EXP(yield),
EXP(sleep),
+ EXP(_SysWaitEvent),
EXP(waittid),
EXP(gettid),
EXP(getpid),
EXP(chdir),
EXP(ioctl),
EXP(_SysMount),
- EXP(select),
+ EXP(_SysSelect),
EXP(_SysOpenChild),
# define NULL ((void*)0)
#endif
+#define THREAD_EVENT_VFS 0x0001
+#define THREAD_EVENT_IPCMSG 0x0002
+#define THREAD_EVENT_SIGNAL 0x0004
+
#define OPENFLAG_EXEC 0x01
#define OPENFLAG_READ 0x02
#define OPENFLAG_WRITE 0x04
extern void sleep(void);
extern void yield(void);
extern int kill(int pid, int sig);
-extern void wait(int miliseconds);
+//extern void wait(int miliseconds);
+extern int _SysWaitEvent(int EventMask);
extern int waittid(int id, int *status);
extern int clone(int flags, void *stack);
extern int execve(char *path, char **argv, char **envp);
extern int _SysOpenChild(int fd, char *name, int flags);
extern int _SysGetACL(int fd, t_sysACL *dest);
extern int _SysMount(const char *Device, const char *Directory, const char *Type, const char *Options);
-extern int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errfds, time_t *timeout);
+extern int _SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *err, time_t *timeout, int extraevents);
+#define select(nfs, rdfds, wrfds, erfds, timeout) _SysSelect(nfs, rdfds, wrfds, erfds, timeout, 0)
// --- IPC ---
extern int SysSendMessage(pid_t dest, uint length, const void *Data);