I am at the point of allowing modules to create their own syscalls.
I have a syscall table (syscalls[MAXSYSCALL]). How would a module add a syscall to it?
I could have a 'total_syscalls' value and the module adds the syscall and then increments that value.
Or, I could have syscalls[WHATEVER_VALUE] call whatever is stored in another array, called custom_syscalls[]. Then you call syscalls[WHATEVER_VALUE] which calls custom_syscalls[registers->ebx] or something.
Thoughts? Other ideas?
-JL
Custom syscalls and how to install them.
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Custom syscalls and how to install them.
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
- bloodhound23
- Member
- Posts: 115
- Joined: Wed Jan 23, 2008 7:13 pm
- Contact:
I thought about something like this once. I thought about assigning each call a value and having a pointer to that function entered into a syscall table when the modules are loaded. All that is needed is the documentation for the driver and you can write assembly programs that utilize them. It's of course a bit more complicated than this, and there is the problem of having more than one driver trying to create a syscall with the same index into the table.
you could have something like this in asm.
you could have something like this in asm.
Code: Select all
mov ax,[index];the index into the table
;load parameters and such here
int 0x80;or whatever value you choose.
I thought I wasn't thinking, I thought wrong.
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Thats what I have working, I just want to figure out how to have modules create custom syscalls.
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
- bloodhound23
- Member
- Posts: 115
- Joined: Wed Jan 23, 2008 7:13 pm
- Contact:
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
I'm not sure what sort of driver/server system you are using, but basically store a list of (however big you want) of ints. Each int is the process ID of the server/driver to call when the syscall is fired.
When a syscall is fired, the kernel sends a SYSCALL event to the module (just like the kernel would call READ, WRITE, KILL, etc to the module). Attached to the message would include what syscall was called and the PID of the calling processes. You could possibly point to a struct which includes things like:
- Time of the syscall
- A bool that indicates if to wake the receiving program when the syscall has completed (if a program put itself to sleep after making the syscall (you'lld need sort of atomic syscall-and-sleep operation) for blocking operations). This could also be implemented as a address to a callback function.
When a syscall is fired, the kernel sends a SYSCALL event to the module (just like the kernel would call READ, WRITE, KILL, etc to the module). Attached to the message would include what syscall was called and the PID of the calling processes. You could possibly point to a struct which includes things like:
- Time of the syscall
- A bool that indicates if to wake the receiving program when the syscall has completed (if a program put itself to sleep after making the syscall (you'lld need sort of atomic syscall-and-sleep operation) for blocking operations). This could also be implemented as a address to a callback function.
My OS is Perception.