Skip to content

Commit 96ba1cc

Browse files
committed
Refine the SDL-oriented system calls declaration
Replace the type of all int parameters of system calls with unsigned, because they are usually treated as uint32_t internally by the emulator. And change the name of the parameter "screen" of the "draw_frame" system call to "base" for the sake of consistency with the "setup_queue" system call.
1 parent 3011a36 commit 96ba1cc

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/syscall.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ These system calls are solely for the convenience of accessing the [SDL library]
103103

104104
**system call number**: `0xBEEF`
105105

106-
**synopsis**: `void draw_frame(void *screen, int width, int height)`
106+
**synopsis**: `void draw_frame(void *base, unsigned width, unsigned height)`
107107

108108
If a window does not already exist, one will be created with the specified `width` and `height`. The `screen` buffer will replace the content of the framebuffer, passing a different `width` or `height` compared to the size of the window is undefined behavior. This system call additionally polls events from the SDL library, and, if necessary, update the internal input specific event queue.
109109

@@ -113,7 +113,7 @@ The width and height are merely the virutal dimensions of the screen; they are u
113113

114114
**system call number**: `0xC0DE`
115115

116-
**synopsis**: `void *setup_queue(void *base, int capacity, unsigned int *event_count)`
116+
**synopsis**: `void setup_queue(void *base, unsigned capacity, unsigned *event_count)`
117117

118118
The user must pass a continuous memory chunk that contains two tightly packed queues, the event queue and the submission queue. And the submission queue is immediately following the last element of the event queue, which is the event queue's base address plus the size of each event element multiplied by the given capacity. If the capacity is not a power of two, it will be treated as the rounded value of the next highest power of two. Additionally, because the event counter variable serves as a notifier to the user that an event has been added to the event queue, it is critical to initialize it before passing its address to this system call.
119119

@@ -129,7 +129,7 @@ An event entry is made up of a 32-bit value representing the event's type and a
129129

130130
**system call number**: `0xFEED`
131131

132-
**synopsis**: `void submit_queue(int count)`
132+
**synopsis**: `void submit_queue(unsigned count)`
133133

134134
To inform the emulator that a batch of submissions should be processed, the application code should push several submissions into the queue first, and then pass the size of the submissions batch to this system call; the submissions will be processed and executed sequentially and immediately.
135135

src/syscall_sdl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void syscall_draw_frame(riscv_t *rv)
218218
{
219219
state_t *s = rv_userdata(rv); /* access userdata */
220220

221-
/* draw_frame(screen, width, height) */
221+
/* draw_frame(base, width, height) */
222222
const uint32_t screen = rv_get_reg(rv, rv_reg_a0);
223223
const uint32_t width = rv_get_reg(rv, rv_reg_a1);
224224
const uint32_t height = rv_get_reg(rv, rv_reg_a2);

0 commit comments

Comments
 (0)