As suggested by Ingo, the "subsystem" parameter is now a string. That allows
modules to use their module name directly. Also introduced a whole range of reserved syscall functions in case we want to add some more. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10458 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b793d2a2bc
commit
dbef8d930c
@ -13,10 +13,11 @@
|
||||
* should be moved to KernelExport.h
|
||||
*/
|
||||
|
||||
typedef status_t (*syscall_hook)(uint32 subsystem, uint32 function, void *buffer, size_t bufferSize);
|
||||
typedef status_t (*syscall_hook)(const char *subsystem, uint32 function, void *buffer, size_t bufferSize);
|
||||
|
||||
/* predefined functions */
|
||||
#define B_SYSCALL_INFO ~0UL
|
||||
#define B_RESERVED_SYSCALL_BASE 0x80000000
|
||||
#define B_SYSCALL_INFO (B_RESERVED_SYSCALL_BASE)
|
||||
// gets a minimum version uint32, and fills it with the current version on return
|
||||
|
||||
/* syscall flags */
|
||||
@ -28,9 +29,9 @@ typedef status_t (*syscall_hook)(uint32 subsystem, uint32 function, void *buffer
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
status_t register_generic_syscall(uint32 subsystem, syscall_hook hook,
|
||||
status_t register_generic_syscall(const char *subsystem, syscall_hook hook,
|
||||
uint32 version, uint32 flags);
|
||||
status_t unregister_generic_syscall(uint32 subsystem, uint32 version);
|
||||
status_t unregister_generic_syscall(const char *subsystem, uint32 version);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ struct dirent;
|
||||
#endif
|
||||
|
||||
extern int _kern_null();
|
||||
extern status_t _kern_generic_syscall(uint32 subsystem, uint32 function,
|
||||
extern status_t _kern_generic_syscall(const char *subsystem, uint32 function,
|
||||
void *buffer, size_t bufferSize);
|
||||
|
||||
extern int _kern_getrlimit(int resource, struct rlimit * rlp);
|
||||
|
@ -33,14 +33,16 @@
|
||||
#include <user_atomic.h>
|
||||
#include <safemode.h>
|
||||
#include <arch/system_info.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
typedef struct generic_syscall generic_syscall;
|
||||
|
||||
struct generic_syscall {
|
||||
list_link link;
|
||||
uint32 subsystem;
|
||||
char subsystem[B_FILE_NAME_LENGTH];
|
||||
syscall_hook hook;
|
||||
uint32 version;
|
||||
uint32 flags;
|
||||
@ -52,14 +54,14 @@ static struct list sGenericSyscalls;
|
||||
|
||||
|
||||
static generic_syscall *
|
||||
find_generic_syscall(uint32 subsystem)
|
||||
find_generic_syscall(const char *subsystem)
|
||||
{
|
||||
generic_syscall *syscall = NULL;
|
||||
|
||||
ASSERT_LOCKED_MUTEX(&sGenericSyscallLock);
|
||||
|
||||
while ((syscall = list_get_next_item(&sGenericSyscalls, syscall)) != NULL) {
|
||||
if (syscall->subsystem == subsystem)
|
||||
if (!strcmp(syscall->subsystem, subsystem))
|
||||
return syscall;
|
||||
}
|
||||
|
||||
@ -75,12 +77,18 @@ find_generic_syscall(uint32 subsystem)
|
||||
*/
|
||||
|
||||
static inline status_t
|
||||
_user_generic_syscall(uint32 subsystem, uint32 function, void *buffer, size_t bufferSize)
|
||||
_user_generic_syscall(const char *userSubsystem, uint32 function,
|
||||
void *buffer, size_t bufferSize)
|
||||
{
|
||||
char subsystem[B_FILE_NAME_LENGTH];
|
||||
generic_syscall *syscall;
|
||||
status_t status;
|
||||
|
||||
dprintf("generic_syscall(subsystem = %lu, function = %lu)\n", subsystem, function);
|
||||
if (!IS_USER_ADDRESS(userSubsystem)
|
||||
|| user_strlcpy(subsystem, userSubsystem, sizeof(subsystem)) < B_OK)
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
//dprintf("generic_syscall(subsystem = \"%s\", function = %lu)\n", subsystem, function);
|
||||
|
||||
mutex_lock(&sGenericSyscallLock);
|
||||
|
||||
@ -90,7 +98,13 @@ _user_generic_syscall(uint32 subsystem, uint32 function, void *buffer, size_t bu
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (function == B_SYSCALL_INFO) {
|
||||
if (function >= B_RESERVED_SYSCALL_BASE) {
|
||||
if (function != B_SYSCALL_INFO) {
|
||||
// this is all we know
|
||||
status = B_NAME_NOT_FOUND;
|
||||
goto out;
|
||||
}
|
||||
|
||||
// special info syscall
|
||||
if (bufferSize != sizeof(uint32))
|
||||
status = B_BAD_VALUE;
|
||||
@ -197,7 +211,7 @@ generic_syscall_init(void)
|
||||
|
||||
|
||||
status_t
|
||||
register_generic_syscall(uint32 subsystem, syscall_hook hook,
|
||||
register_generic_syscall(const char *subsystem, syscall_hook hook,
|
||||
uint32 version, uint32 flags)
|
||||
{
|
||||
struct generic_syscall *previous, *syscall;
|
||||
@ -227,7 +241,7 @@ register_generic_syscall(uint32 subsystem, syscall_hook hook,
|
||||
goto out;
|
||||
}
|
||||
|
||||
syscall->subsystem = subsystem;
|
||||
strlcpy(syscall->subsystem, subsystem, sizeof(syscall->subsystem));
|
||||
syscall->hook = hook;
|
||||
syscall->version = version;
|
||||
syscall->flags = flags;
|
||||
@ -246,7 +260,7 @@ out:
|
||||
|
||||
|
||||
status_t
|
||||
unregister_generic_syscall(uint32 subsystem, uint32 version)
|
||||
unregister_generic_syscall(const char *subsystem, uint32 version)
|
||||
{
|
||||
// ToDo: we should only remove the syscall with the matching version
|
||||
generic_syscall *syscall;
|
||||
|
Loading…
Reference in New Issue
Block a user