Closed wake-0 closed 9 years ago
Some clarifications on the system API:
We should have somewhere a folder api
which contains all necessary header files and source files for the system calls.
A system call immediately switches into supervisor/privileged mode and executes the corresponding kernel function and switches back to user mode.
The memory mapping of TTBR1 (kernel) has to be read/write-protected for user mode thus triggering a interrupt if a user process tries to access the kernel by bypassing the system API. This ISR should immediately kill the process.
Above comment is not entirely true. We discuss the concept in detail at Wed. See #75. If I find some time I will probably implement a prototype for a system call.
In the above commit I have refactored some code (according to our conventions) and implemented a working system call from the console to the kernel to start a process.
Discussion tomorrow I guess.
I'm sorry to say that the last commit is not 100% correct. Further explanation at our meeting.
I refactored the System API to a more useful structure. The main idea is that all system call functions are wrapped into a user API, such as execute(char* command)
and within that function a systemCallMessage_t
is assembled. The user functions should be placed into header files which fulfill the POSIX standard, e.g. execute(..)
is placed into system.h
.
Acc. to todays coaching readfile should only read chunks from the sd card so that there is not the problem that reading needs to much time.
Above commits implement the API for accessing the filesystem.
The function SystemCall(..)
in systemcall.c
includes a switch case handling the different system call ids. However, the systemCallMessage_t
struct already contains this information. In the kernel implementation we use the system call id from the latter, thus removing this switch case would make the implementation cleaner.
Above commit removes this handling and calls the SWI
instruction with a constant number. All the system calls still work.
System API functions are done and are working well. Addtional functions should be discussed in new tickets.
Implement Sytem API e.g. MINIX SysCalls.
Atm. the following calls should be implemented:
system.h
:1.)
2.)execute(char* command)
which switches to the next process 3.)yield()
which quits the current process 4.)exit()
which sets a process's state tosleep(int)
SLEEPING
for the given amount of ms 5.)shutdown()
process.h
:1.)
returns a list of the running processes including meta-information 2.)read_processes(..)
kills the process with the given id 3.)kill_process(int)
returns the number of running processesget_process_count()
filesystem.h
:1.)
returns the current working directory into the given buf 2.)read_cwd(char* buf, int len)
sets the current working directory to the given path 3.)set_cwd(char* path)
opens the given file and readsread_file(char* name, char* buf, int len)
len
bytes of the file 4.)reads the directory content and returns containing directories and files including meta informationread_directory(char* name, ...)
ipc.h
:1.)
open_ipc_channel(..)
opens a namespace in theIpcManager
2.)send_ipc_message(..)
sends a message to a namespace 3.)has_ipc_message(..)
returnstrue
orfalse
stdio.h
:1.)
prints the given string to the console (this is a helper function only for gettingprint(char*, int)
printf
to work in ext. processes)devices.h
:1.)
opens the device and returns the handle asopen_device(char* devicename)
int
2.)closes the device 3.)close_device(int)
calls ioctl on the device 4.) ...ioctl_device(int handle, int mode, int cmd, int len, char* buf)