Custom syscalls and how to install them.

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
piranha
Member
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.

Post by piranha »

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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
bloodhound23
Member
Member
Posts: 115
Joined: Wed Jan 23, 2008 7:13 pm
Contact:

Post by bloodhound23 »

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.

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.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Thats what I have working, I just want to figure out how to have modules create custom syscalls.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
bloodhound23
Member
Member
Posts: 115
Joined: Wed Jan 23, 2008 7:13 pm
Contact:

Post by bloodhound23 »

Well if you don't have your OS link the modules with the kernel, you could just have all your modules run once in userspace with a main procedure that calls the system call to create a system call for all of the necessary driver functions.
I thought I wasn't thinking, I thought wrong.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

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.
My OS is Perception.
Post Reply