The Pedigree Project 0.1
pedigree-c-syscalls.c
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include "pedigree/kernel/compiler.h"
21#include "pedigree/kernel/processor/types.h"
22
23#include <unistd.h>
24
25#include "pedigree-c-syscall.h"
26#include "pedigreecSyscallNumbers.h"
27
30EXPORTED_PUBLIC int pedigree_load_keymap(char* buf, size_t sz);
31
32EXPORTED_PUBLIC void pedigree_reboot(void);
33
34EXPORTED_PUBLIC void pedigree_haltfs(void);
35
36EXPORTED_PUBLIC int pedigree_get_mount(char* mount_buf, char* info_buf, size_t n);
37
38EXPORTED_PUBLIC void* pedigree_sys_request_mem(size_t len);
39
40EXPORTED_PUBLIC void pedigree_input_inhibit_events(int inhibit);
41
42EXPORTED_PUBLIC int pedigree_event_return(void);
43
44EXPORTED_PUBLIC void pedigree_module_load(char* file);
45
46EXPORTED_PUBLIC void pedigree_module_unload(char* name);
47
48EXPORTED_PUBLIC int pedigree_module_is_loaded(char* name);
49
50EXPORTED_PUBLIC int pedigree_module_get_depending(char* name, char* buf, size_t bufsz);
51
52EXPORTED_PUBLIC int pedigree_login(uid_t uid);
53
54int pedigree_load_keymap(char* buf, size_t sz) {
55 return syscall2(PEDIGREE_LOAD_KEYMAP, (long)buf, (long)sz);
56}
57
58void pedigree_reboot() {
59 syscall0(PEDIGREE_REBOOT);
60}
61
62void pedigree_haltfs() {
63 syscall0(PEDIGREE_HALTFS);
64}
65
66int pedigree_get_mount(char* mount_buf, char* info_buf, size_t n) {
67 return syscall3(PEDIGREE_GET_MOUNT, (long)mount_buf, (long)info_buf, n);
68}
69
70void* pedigree_sys_request_mem(size_t len) {
71 uintptr_t result = syscall1(PEDIGREE_SYS_REQUEST_MEM, (long)len);
72 return (void*)result;
73}
74
75void pedigree_input_inhibit_events(int inhibit) {
76 syscall1(PEDIGREE_INPUT_INHIBIT_EVENTS, inhibit);
77}
78
79int pedigree_event_return() {
80 return (int)syscall0(PEDIGREE_EVENT_RETURN);
81}
82
83void pedigree_module_load(char* file) {
84 syscall1(PEDIGREE_MODULE_LOAD, (long)file);
85}
86
87void pedigree_module_unload(char* name) {
88 syscall1(PEDIGREE_MODULE_UNLOAD, (long)name);
89}
90
91int pedigree_module_is_loaded(char* name) {
92 return syscall1(PEDIGREE_MODULE_IS_LOADED, (long)name);
93}
94
95int pedigree_module_get_depending(char* name, char* buf, size_t bufsz) {
96 return syscall3(PEDIGREE_MODULE_GET_DEPENDING, (long)name, (long)buf, bufsz);
97}
98
99// Pedigree-specific function: switch this process to a known uid.
100int pedigree_login(uid_t uid) {
101 return (long)syscall1(PEDIGREE_LOGIN, uid);
102}