Commit Graph

63 Commits

Author SHA1 Message Date
Bahadir Balban
b11d4c4607 Added mutex_control syscall for userspace mutexes.
- Compiles and Codezero runs as normal without touching mutex implementation
- Mutex implementation needs testing.

The mutex control syscall allows userspace programs to declare any virtual
address as a mutex lock and ask for help from the kernel syscall
for resolving locking contentions.
2009-05-29 15:34:04 +03:00
Bahadir Balban
3ff519439b Added first part of extended ipc support.
- Extended ipc tests
- Need to copy from ktcb-to-ktcb instead of ktcb-to-user
- Need to check flags of both ipc parties before ipc copy type.
2009-05-27 14:07:17 +03:00
Bahadir Balban
5ac5889a0f Unstable changes for ipc - Fork fails for some reason 2009-05-23 18:43:55 +03:00
Bahadir Balban
cc96e2c86c Full IPC working.
- Test0 has a full ipc mr read/write test.
- A full ipc occurs for definite only if both parties use the FULL IPC flag.
  Otherwise the thread that makes the ipc copy rules on whether it was a short
  or a full copy.
2009-05-19 15:39:01 +03:00
Bahadir Balban
40e088b042 Modifications towards full ipc
- Added a full ipc send/recv test
- Removed non-zero value checking in r2 for ipc that was there
  to catch inadvertent full ipc calls.
- Added correct hanlding for read/write mrs for current status of utcb.

TODO:
- Add mapping of every utcb to every task for privileged access so that
  the kernel can access every utcb without switching spaces.
- Removal of same mappings
- Upon thread creation need to copy page tables accordingly i.e.
  each task will have its own utcb mapped with USER access, but every
  other utcb as kernel access only. Need to handle this case upon page
  table copying.
2009-05-17 20:49:13 +03:00
Bahadir Balban
93368447f9 Added kernel + libl4 changes for full and extended ipc.
- Short ipc working as normal. Full/extended ipc haven't been tested.
- Added automated compilation and inclusion of test executable in test0.
2009-05-15 19:14:40 +03:00
Bahadir Balban
814eba43dd l4lib changes to accomodate extended and full ipc.
- Added ARM register ipc usage explanation to glue/arm/message.h
- In the current design, the unused r2 register is a system register
  that kernel checks for ipc flags such as:
  - IPC type: e.g. full or extended.
  - In extended IPC, MR index containing message buffer ptr.
  - In extended IPC, message size
2009-05-14 20:23:10 +03:00
Bahadir Balban
548617660f Added l4_send/receive full/extended ipc prototype proposals 2009-05-14 18:38:28 +03:00
Bahadir Balban
680d20ff94 Initial changes to libl4 for full and extended ipc.
- Tag word will be used to specify full and extended ipc, and its size.
2009-05-13 16:08:37 +03:00
Bahadir Balban
cada0f8f18 New UTCB implementation almost working.
- KIP's pointer to UTCB seems to work with existing l4lib ipc functions.
- Works up to clone()
- In clone we mmap() the same UTCB on each new thread - excessive.
- Generally during page fault handling, cloned threads may fault on the same page
  multiple times even though a single handling would be enough for all of them.
  Need to detect and handle this.
2009-05-01 10:11:47 +03:00
Bahadir Balban
7a81db8782 Ongoing work for adding per-thread UTCB structures.
Added setting of utcb address to l4_thread_control.
This is going to be moved to exchange_registers() since we need to pass
both the utcb physical and virtual address and exregs fits such context
modification better than thread_control.
2009-04-29 16:53:04 +03:00
Bahadir Balban
54a9b2901d Removed allocation of utcb shared pages by mm0 completely.
- Now libl4 has no references to utcb page or shmat etc.
- Pager does not deal with special case utcb page allocation.
  It instead allocates a shared page from shm memory pool.
- All tasks working to original standard.

Next:
- Add per-thread utcb allocation from the kernel
- Add larger register file for standard ipc
- Add long ipc (up to 1Kb)
2009-04-22 14:48:43 +03:00
Bahadir Balban
203f053878 Removed special-case utcb shared page from posix services.
Previously a so-called utcb shared page was used for transfering
data between posix services. This was a special shmat/get/dt case
allocating from its own virtual pool. Now the term utcb is renamed
as a shared page and integrated with the shm* handling routines.

Generic l4 threads will use long-ipc and not this method. Posix
services will continue to communicate on a shared page for now.
	modified:   tasks/libl4/include/l4lib/ipcdefs.h
	modified:   tasks/libl4/src/init.c
	new file:   tasks/libposix/init.c
	modified:   tasks/mm0/include/shm.h
	modified:   tasks/mm0/include/task.h
	deleted:    tasks/mm0/include/utcb.h
	modified:   tasks/mm0/main.c
	modified:   tasks/mm0/src/boot.c
	modified:   tasks/mm0/src/clone.c
	modified:   tasks/mm0/src/execve.c
	modified:   tasks/mm0/src/exit.c
	modified:   tasks/mm0/src/init.c
	modified:   tasks/mm0/src/shm.c
	modified:   tasks/mm0/src/task.c
	deleted:    tasks/mm0/src/utcb.c
	deleted:    tools/l4-qemu
2009-04-22 11:58:58 +03:00
Bahadir Balban
d182b5b35a Initial changes for execve() support 2008-11-13 21:45:30 +02:00
Bahadir Balban
13b1b405a5 Cleaned up libposix mmap()
Now we have proper setting of errno and using pfn based mmap for both types of mmap calls.
2008-10-29 20:01:31 +02:00
Bahadir Balban
4046ad9e3f Added msync(), added handling of munmap/msync to pager main.c 2008-10-29 19:22:01 +02:00
Bahadir Balban
0db0f7e334 Multiple updates on sleeping, vma dropping and thread suspend.
- Updated sleeping paths such that a task is atomically put into
  a runqueue and made RUNNABLE, or removed from a runqueue and made SLEEPING.
- Modified vma dropping sources to handle both copy_on_write() and exit() cases
  in a common function.
- Added the first infrastructure to have a pager to suspend a task and wait for
  suspend completion from the scheduler.
2008-10-13 12:22:10 +03:00
Bahadir Balban
c54d505709 Changes towards exit. Need to fix thread suspend first. 2008-09-27 22:15:34 +03:00
Bahadir Balban
6b11d3cf02 Added exit() call to libposix 2008-09-18 16:28:51 +03:00
Bahadir Balban
30de876a6c Added MR #define place holders so that these are used instead of real register names 2008-09-15 18:27:41 +03:00
Bahadir Balban
4d1b649465 Fix to exregs.c functions 2008-09-15 18:16:02 +03:00
Bahadir Balban
9c2c9676e8 Added exregs_set_mr() function
Moved all exregs-related calls to libl4 since these are part of the L4 api.
2008-09-15 17:57:09 +03:00
Bahadir Balban
df2317e7aa exchange_registers(), modified thread_control calls seem to work
- Fixed do_mmap() so that it returns mapped address, and various bugs.
- A child seems to fork with new setup, but with incorrect return value.
  Need to use and test exregs() for fork + clone.
- Shmat searches an unmapped area if input arg is invalid, do_mmap()
  should do this.
2008-09-15 15:59:44 +03:00
Bahadir Balban
4fb5277123 Towards finishing exchange_registers()
- Added mutex_trylock()
- Implemented most of exchange_registers()
- thread_control() now needs a lock for operations that can modify thread context.
- thread_start() does not initialise scheduler flags, now done in thread_create.

TODO:
- Fork/clone'ed threads should retain their context in tcb, not syscall stack.
- exchange_registers() calls in userspace need cleaning up.
2008-09-13 18:07:00 +03:00
Bahadir Balban
0b3ab05a98 Some minor changes
Need to reimplement exchange_registers
2008-09-12 10:47:36 +03:00
Bahadir Balban
af03975dc1 Towards adding sys_clone()
Stopped working on self_spawn() - going to finish clone() syscall first.
Arch-specific clone() library call that does ipc() and cloned child setup.
- Need to finish thread_create() that satisfy clone() necessities. i.e. setting up its stack.
  Question: Does the pager (and thus the microkernel) have to explicitly set SP_USR?
  Once the call is known to be successful, the library could set it.
2008-09-11 16:56:41 +03:00
Bahadir Balban
002fe79a54 Added thread group identification to c0 and libl4
tgid will be used when threads will be created in same address space.
2008-09-09 15:39:56 +03:00
Bahadir Balban
1a90b655c7 Added child utcb initialisation to fork call implementation in libposix. 2008-08-22 00:26:19 +03:00
Bahadir Balban
1d15821acb Added ipc to notify vfs about a forked child.
TODO: Need to ensure child shmat()s its own utcb
after a fork (possibly in libposix/fork.c)
2008-08-22 00:11:06 +03:00
Bahadir Balban
6be310f460 Added sys_close and sys_fsync
Untested.
2008-05-23 03:59:18 +00:00
Bahadir Balban
00b47117b0 Added sys_stat, sys_fstat and their libposix glue. 2008-05-22 11:21:27 +00:00
Bahadir Balban
bd8b182f1b Added syscall to update filestats (size) from pager.
After flushing written/truncated pages, stats are updated
so that vfs is synced with new file info such as its size.
2008-05-21 10:23:11 +00:00
Bahadir Balban
e8bb529dcb Now we save/restore utcb registers if we do a second ipc before returning the first. 2008-04-22 00:30:07 +01:00
Bahadir Balban
9992d100d7 Few fixes in libposix error checking.
size_t is a non-negative type and negative error checking didn't work. Now fixed.
Fixed various issues with reading file pages in the sys_read() path.
2008-04-20 02:12:53 +01:00
Bahadir Balban
cff7a505e8 Changed time representation to posix style struct timeval/ gettimeofday. 2008-04-18 13:58:37 +01:00
Bahadir Balban
5563cc1c6b Minor changes on sys_time
A get/set flag determines whether to read or write time.
2008-04-18 01:03:39 +01:00
Bahadir Balban
a87914910c Added a new system call sys_timer.
sys_timer accumulates timer ticks into seconds, minutes, hours and days.
It's left to the user to calculate from days into a date. It is not yet
known if the calculation is even roughly correct.

Reduced 2 kmem_reclaim/grant calls into one kmem_control call.
2008-04-18 00:46:29 +01:00
Bahadir Balban
287b7705da Towards working mkdir. 2008-04-14 14:38:04 +01:00
Bahadir Balban
7b2f9f96cf os_readdir() now using utcb as dirent buffer. 2008-04-13 16:32:34 +01:00
Bahadir Balban
4b1abc60a6 Various minor fixes.
Removed some commented out code.
Removed excessive printfs.
Fixed spid not initialising for mm0
Fixed some faults with fs0.

TODO:
- Need to store vfs files in a separate list.
- Need to define vnum as a vfs-file-specific data, i.e. in priv_data field of vm_file.
- Need to then fix vfs_receive_sys_open.
2008-03-24 22:39:21 +00:00
Bahadir Balban
b369ff6efe Added copy-on-write shared memory but untested yet.
For anonymous shm, mmap now adds a shm_file and devzero behind it
as two vm_objects. Faults are handled by copy_on_write(). Just as
shadows copy r/w pages from original files, it should copy r/w
pages from devzero into the shm_file in front.

shmat/shmget uses mmap to set-up their areas.

Untested yet so bugs expected.

	modified:   tasks/libl4/src/init.c
	modified:   tasks/mm0/include/shm.h
	modified:   tasks/mm0/include/vm_area.h
	modified:   tasks/mm0/src/fault.c
	modified:   tasks/mm0/src/mmap.c
	modified:   tasks/mm0/src/shm.c
2008-03-21 15:40:54 +00:00
Bahadir Balban
466138f125 shmat/shmget for utcbs are working for now.
faults on shared memory needs to be implemented.
2008-03-19 22:26:38 +00:00
Bahadir Balban
55d24dbbdf Managed to pass utcb information to tasks via an ipc() call.
Removed setting of tag during ipc_return(). So it does not overwrite
return value anymore.

Next stage is for the tasks to map their utcb via shmget/shmat before
accessing.
2008-03-19 02:55:31 +00:00
Bahadir Balban
16617eed36 Various changes to incorporate new utcb setup.
Issues with l4_return value not reaching client side
	modified:   libs/c/include/stdio.h
	modified:   src/arch/arm/exception.c
	modified:   src/glue/arm/init.c
	modified:   tasks/fs0/src/task.c
	modified:   tasks/libl4/include/l4lib/arch-arm/utcb.h
	modified:   tasks/libl4/src/arm/syscalls.S
	modified:   tasks/libl4/src/init.c
	deleted:    tasks/libl4/tagfilelist
	modified:   tasks/libposix/open.c
	modified:   tasks/mm0/include/utcb.h
	modified:   tasks/mm0/include/vm_area.h
	modified:   tasks/mm0/main.c
	modified:   tasks/mm0/src/init.c
	modified:   tasks/mm0/src/task.c
	modified:   tasks/mm0/src/utcb.c
	modified:   tasks/mm0/src/vm_object.c
2008-03-19 02:27:53 +00:00
Bahadir Balban
ac3935a5d9 Initial efforts to transform utcb handling. 2008-03-18 21:50:47 +00:00
Bahadir Balban
58b833dd7f Forks and COW situations show that we need vm objects rather than vm_files.
This is the first commit towards implementing vm object based paging with
right COW methods.
2008-03-03 22:05:01 +00:00
Bahadir Balban
4f346cea53 Added the first means to pass information between 2 tasks using the
utcb as a shared page instead of the message registers.

Implemented the code that passes task information from mm0 to fs0
using the fs0 utcb. The code seems to work OK but:

There's an issue with anon pages that they end up on the same swapfile
and with same file offsets (e.g. utcb and stack at offset 0). Need to
fix this issue but otherwise this implementation seems to work.

TODO:
- Separate anon regions into separate vmfiles.
- Possibly map the stacks from virtual files so that they can be
  read from userspace in the future for debugging.
- Possibly utcb could be created as a shared memory object using shmget/shmat
  during startup.
2008-02-29 21:56:05 +00:00
Bahadir Balban
55117c600b Back to the same fs0 bug point as before, but environment, disjoint utcb addresses
and passing of utcb address information via the environment are implemented.
2008-02-29 12:33:53 +00:00
Bahadir Balban
617d24b4f0 Modified task initialisation so that stack now comes beneath the environment
Environment is backed by a special per-task file maintained by mm0 for each task.
This file is filled in by the env pager, by simple copying of env data into the
faulty page upon a fault. UTCB and all anon regions (stack) could use the same
scheme.

Fixed IS_ERR(x) to accept negative values that are above -1000 for errors. This
protects against false positives for pointers such as 0xE0000000.

	modified:   include/l4/generic/scheduler.h
	modified:   include/l4/macros.h
	modified:   src/arch/arm/exception.c
	modified:   tasks/fs0/include/linker.lds
	modified:   tasks/libl4/src/init.c
	modified:   tasks/libposix/shm.c
	new file:   tasks/mm0/include/env.h
	modified:   tasks/mm0/include/file.h
	new file:   tasks/mm0/include/lib/addr.h
	deleted:    tasks/mm0/include/lib/vaddr.h
	modified:   tasks/mm0/include/task.h
	new file:   tasks/mm0/include/utcb.h
	new file:   tasks/mm0/src/env.c
	modified:   tasks/mm0/src/fault.c
	modified:   tasks/mm0/src/file.c
	modified:   tasks/mm0/src/init.c
	new file:   tasks/mm0/src/lib/addr.c
	modified:   tasks/mm0/src/lib/idpool.c
	deleted:    tasks/mm0/src/lib/vaddr.c
	modified:   tasks/mm0/src/mmap.c
	modified:   tasks/mm0/src/shm.c
	modified:   tasks/mm0/src/task.c
	new file:   tasks/mm0/src/utcb.c
	modified:   tasks/test0/include/linker.lds
2008-02-29 01:43:56 +00:00
Bahadir Balban
e7b0e46065 Preparing to add utcbs at disjoint virtual addresses.
This will help when syscalls have long arguments individual
utcbs can be mapped to server tasks and kept mapped in until the
tasks die, as opposed to map requests every time a server task maps
a different utcb at the same virtual address.

The changes have preparation code to also passing the utcb info
through the stack as part of the environment.

To sum up env and arg regions have also been added above the stack and
env region is to be used to pass on the utcb address information at
task startup.
2008-02-28 00:25:04 +00:00