summaryrefslogtreecommitdiff
path: root/doc/syscalls.txt
blob: 8053b386794f2b360c8ce15b5e40b016165548cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Syscalls pass by int64. The identifier of the called function is in eax, parameters
are in ebx, ecx, edx, esi, edi.

Syscall list :

id=eax	Name			Parameters				Description
  0		thread_exit		none					Signal kernel that current thread has finished
  1		schedule		none					Switch to next thread (might be the current one)
  2		thread_sleep	ebx: time (int) msecs	Tell kernel to put current thread to sleep
  3		process_exit	ebx: return value (int)	Tell kernel to end current process, cleaning up everything
  4		printk			ebx: addr of a string	Print a message to screen
  5		thread_new		ebx: entry point		Creates a new thread
						ecx: data pointer
						edx: stack pointer
  6		irq_wait		ebx: irq number			Waits for an IRQ (requires privilege PL_DRIVER)
  7		proc_priv		none					Returns current process privilege level
  8		shm_create		ebx: offset				Create a shared memory segment at offset (ret = errcode)
						ecx: length
  9		shm_delete		ebx: offset				Delete a shared memory segment at offset (ret = errcode)
  10	object_create	none					Creates an object for current process (returns a descriptor to it)
  11	object_owned	ebx: object descriptor	True (1) if object with this descriptor is ours, false(0) elsewhere
  12	object_close	ebx: object descriptor	Closes descriptor to an object (deleting it if necessary)
  13	request_get		ebx: object descriptor	Gets a request pending on object (only if we own it)
						ecx: pointer to write request
						edx: wait for a request ?
  14	request_has		ebx: object descriptor	Is there a request waiting on this object ?
  15	request_answer	ebx: object descriptor
						ecx, edx: answer		Answer a request on object
  16	request_mapShm	ebx: object descriptor	Map shared memory sent with request to receiver's address space
						ecx: offset
						edx: parameter number (0, 1 or 2)
  17	request			ebx: object descriptor	Send a blocking request to object
						ecx: pointer to user_sendrequest struct with information
  18	send_msg		same as above			Send a nonblocking request to object, same as above
  19	proc_setheap	ebx: start address		Creates/resizes/moves the heap segment allocated to this process (one per process)
						ecx: end address

If a processes wishes to exit with an error code, it HAS to use process_exit. thread_exit will do nothing.

====== SYSCALL DESCRIPTION ======

= object_create (10)
Parameters: none
Returns: descriptor to created object, 0 if failure (should not happen)
Creates an object belonging to current proces.

= object_owned (11)
Parameters: an object descriptor
Returns:
- 1 if object belongs to current process
- 0 if object does not belong to current process
- -10 if descriptor does not exist

= object_close (12)
Parameters: an object descriptor
Returns: nothing
Closes a given descriptor to an object. If descriptor does not exist, call is ignored.

= request_get (13)
Parameters: an object descriptor, a pointer to a location to write request, a boolean : wait for a request?
Returns:
- -10 if descriptor does not exist
- -2 if object is not possesed by current process
- -3 if a blocking request is currently being processed
- -1 if no request is pending and [wait] is not set
- 0 if a request was written to location (call successful)
Fetches a waiting request or message on object, and deletes it or acknowledge it.

= request_has (14)
Parameters: an object descriptor
Returns:
- -10 if descriptor does not exist
- -2 if object is not possesed by current process
- 0 if no request is pending
- 1 if a waiting request is there
- 2 if a request is being processed

= request_answer (15)
Parameters: an object descriptor, two ints forming a long long if necessary, an int which is the return status (error code) of the function
Returns: nothing
Answers a request marked as currently being processed, ignoring cases where :
- descriptor does not exist
- object does not belong to process
- no request was being processed

= request_mapShm (16)
Parameters: [id] object descriptor, [pos] pointer to a location, [number] int
Returns:
- -9 if [number] < 0 or [number] > 2
- -10 if descriptor does not exist
- -2 if object is not possesed by current process
- -3 if no request is being processed
- -4 if there is usually no shared memory in parameter [number]
- -7 if sender process is receiver process, in which case memory is already mapped somewhere
- -5 if no shared memory was sent by this parameter
- 0 if shared memory in parameter [number] of currently processed request of object [id] was mapped at [pos]

= request (17)
Parameters: [id] object descriptor, [pos] pointer to request data
Returns:
- -1 if an unknown error happened (should not happen)
- -10 if descriptor does not exist
- -11 if objet cannot handle requests
- -2 if request was interrupted
- 0 if request was handled and result written in [pos]->answer

= send_msg (18)
Parameters: [id] object descriptor, [pos] pointer to request data
Returns:
- -1 if an unknown error happened (should not happen)
- -10 if descriptor does not exist
- -11 if object cannot handle requests
- 0 if nonblocking message was sent