wake-0 / fhvOS

This repository contains an os for the arm cortex a8 in combination with beaglebone.
GNU General Public License v2.0
7 stars 1 forks source link

[SysCalls] Implement System API #31

Closed wake-0 closed 9 years ago

wake-0 commented 9 years ago

Implement Sytem API e.g. MINIX SysCalls.

Atm. the following calls should be implemented:

system.h:

1.) execute(char* command) 2.) yield() which switches to the next process 3.) exit() which quits the current process 4.) sleep(int) which sets a process's state to SLEEPING for the given amount of ms 5.) shutdown()

process.h:

1.) read_processes(..) returns a list of the running processes including meta-information 2.) kill_process(int) kills the process with the given id 3.) get_process_count() returns the number of running processes

filesystem.h:

1.) read_cwd(char* buf, int len) returns the current working directory into the given buf 2.) set_cwd(char* path) sets the current working directory to the given path 3.) read_file(char* name, char* buf, int len) opens the given file and reads len bytes of the file 4.) read_directory(char* name, ...) reads the directory content and returns containing directories and files including meta information

ipc.h:

1.) open_ipc_channel(..) opens a namespace in the IpcManager 2.) send_ipc_message(..) sends a message to a namespace 3.) has_ipc_message(..) returns true or false

stdio.h:

1.) print(char*, int) prints the given string to the console (this is a helper function only for getting printfto work in ext. processes)

devices.h:

1.) open_device(char* devicename) opens the device and returns the handle as int 2.) close_device(int) closes the device 3.) ioctl_device(int handle, int mode, int cmd, int len, char* buf) calls ioctl on the device 4.) ...

trylimits commented 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.

trylimits commented 9 years ago

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.

trylimits commented 9 years ago

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.

ghost commented 9 years ago

I'm sorry to say that the last commit is not 100% correct. Further explanation at our meeting.

trylimits commented 9 years ago

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.

wake-0 commented 9 years ago

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.

trylimits commented 9 years ago

Above commits implement the API for accessing the filesystem.

trylimits commented 9 years ago

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.

trylimits commented 9 years ago

Above commit removes this handling and calls the SWI instruction with a constant number. All the system calls still work.

trylimits commented 9 years ago

System API functions are done and are working well. Addtional functions should be discussed in new tickets.