Commit Graph

122 Commits

Author SHA1 Message Date
Russel Winder
9b2ff087d0 Add in all the amendments and new files needed to get the kernel building. 2009-08-01 17:50:59 +01:00
Russel Winder
d40c76de84 Remove all the SCons files pending starting a new build system. 2009-07-28 14:47:00 +01:00
Bahadir Balban
0dd8918ae5 Remove all references to ARM registers in system call arguments. 2009-06-10 17:30:02 +03:00
Bahadir Balban
4e43d09325 wait_on_prepare and wait_on_prepared_wait with preemption considered 2009-06-10 15:48:34 +03:00
Bahadir Balban
7ef479733f Fix to l4_mutex_control for the unexpected sleeping with mutex held
when preemption occurs after call to wait_on_prepare
2009-06-10 15:41:30 +03:00
Bahadir Balban
6b3ddadcf5 Cleaned up code for userspace mutexes.
- Issues: wait_on_prepare and wait_on_prepared_wait use cases
  are erroneous because they may sleep with mutex_control_lock
  taken if preemption occurs.
2009-06-10 14:37:23 +03:00
Bahadir Balban
49d47abe97 Evaluated license issues, made some other enhancements. 2009-06-08 17:00:21 +03:00
Bahadir Balban
276b4643c6 Removed linux linked list dependency. 2009-06-02 13:19:17 +03:00
Bahadir Balban
4757f46f71 Minor comment fixes. 2009-06-02 10:26:21 +03:00
Bahadir Balban
13d469f659 Removed all unecessary prints from the mutex test and the kernel
- removed (%d) Sleeping print from contended kernel mutexes.
- removed (%d) Waiting print from WAIT_EVENT used by the pager for suspending tasks.
- removed prints from the mutex_control syscall and user mutex test.
2009-06-01 16:02:10 +03:00
Bahadir Balban
3b9cda968d Added mutex locking to kmalloc/kfree. 2009-06-01 15:18:44 +03:00
Bahadir Balban
1de77f1b93 Merge branch 'devel' into fix-kmalloc 2009-06-01 15:08:28 +03:00
Bahadir Balban
4206c6e3fc An extra mutex_unlock has been removed 2009-06-01 15:06:07 +03:00
Bahadir Balban
53f54f2328 Modified kmalloc to cater for dynamic memory allocation on a previously allocated size 2009-06-01 14:48:26 +03:00
Bahadir Balban
33200c92df Mutex implementation almost working.
- Fixed a wrong instruction in mutex.S user library
- Added support for blocking lock/unlock
- Divided waiting into wait_on_prepare and wait_on_prepared_wait
  so that mutex_control lock is released after getting in the waitqueue.
- Declaring waitqueue on the stack should be done outside wait_on_prepare

Issues:
- Tests can be simplified for atomic data access instead of producer/consumer.
- kmalloc variable sized memory caches are not freed properly. Currently only the
  last slot can be freed, occupied correctly. it should be done in any slot, i.e.
  1, 2, 3, 4 instead of just 5.
- Need to add a mutex to kmalloc.
2009-06-01 14:11:40 +03:00
Bahadir Balban
ce79aa2b73 Mutex test progress
- Mutex test added. Forked tasks demonstrate produce/consumer using a
  shared mmap'ed page.
- Added l4lib assembler syscall
- Added forgotten SWI to mutex control offset in syscall page.
- Added mutex head initialization
- Contended child successfully sleeps in a waitqueue.

Issues:
- Somehow the child's produced page buffer is altered at about [4020] offset.
  Parent fails to validate buffer therefore.
- Need to add syncing to test so that parent does not unlock and lock again
  before child has a chance to lock buffer and produce.
2009-05-30 16:46:30 +03:00
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
ab9e036cb7 Updated test pass/fail print messages for test0 2009-05-28 13:23:44 +03:00
Bahadir Balban
e61e9e9533 Moved ipc flags manipulation to ipc.h glue file 2009-05-28 13:02:37 +03:00
Bahadir Balban
ba31e1b823 Added ipc save/restore for page-fault ipcs.
The save restore routines save all primary message registers and ipc flags.
2009-05-28 12:52:14 +03:00
Bahadir Balban
391b0ca1d0 Updated ipc flag names with kernel-only versions without the L4 prefix. 2009-05-28 12:01:48 +03:00
Bahadir Balban
b977e6597e Added per-task ipc flags checking instead of the active task flags.
Previously during ipc copy, only the currently active task flags were
checked. This means the flags of whoever doing the actual copy was used
in the ipc. Now flags are stored in the ktcb and checked by the copy routine.

Current use of the flags is to determine short/full/extended ipc.
2009-05-28 11:50:39 +03:00
Bahadir Balban
53310aa31b Extended IPC Support added.
Benefits & Facts:
- Messages up to 2 kilobytes may be sent.
- Both parties may use non-disjoint user buffers. E.g. any userspace address.
- Userspace buffers can page fault.
- Page faults punish timeslice of only the faulting thread.
- Any number of extended ipcs can take place at any one time, since
  only ktcbs of ipc parties are engaged. No global buffer is used.
  - This also provides smp-safety benefit.

Disadvantages:
- There is triple copying penalty. This has to be done:
  - Sender buffer to sender ktcb
  - Sender ktcb to receiver ktcb
  - Receiver ktcb to receiver buffer.
  This is due to the fact that buffers can be on non-disjoint userspace addresses.

If you want to avoid disadvantages and lose some of the benefits,
(e.g. address freedom, shorter copy size) use FULL IPC.
2009-05-27 14:36:11 +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
19c71cc658 Cleaned up thread_control functions 2009-05-26 17:29:10 +03:00
Bahadir Balban
93c7cf1995 Fixed fork() errors where forked thread is a copy of any cloned thread in parent address space.
Upon fork, child was created in a new space but as a copy of any
cloned thread in the parent space. This was due to the search of forker thread
by its space id (which is shared among many cloned threads).

Now fixed.
	modified:   src/api/thread.c
	modified:   tasks/mm0/src/task.c
2009-05-26 17:02:32 +03:00
Bahadir Balban
c25c81e95c Cleaner thread_create() 2009-05-26 16:48:36 +03:00
Bahadir Balban
bece68fbf7 Fixed omission of if curly brackets causing stack corruption.
Initialization a local pointer variable was only done in some conditions
causing the uninitialized pointer to corrupt kernel stack of current.
2009-05-25 12:12:21 +03:00
Bahadir Balban
5ac5889a0f Unstable changes for ipc - Fork fails for some reason 2009-05-23 18:43:55 +03:00
Bahadir Balban
577cc34db6 Changed full boolean with ipc flags and simplified ipc calls. 2009-05-23 13:52:06 +03:00
Bahadir Balban
63bf6c3e41 Added error signalling/handling functions that better clarify ipc calls. 2009-05-22 23:14:53 +03:00
Bahadir Balban
d632966778 Comment fix to utcb lazy mapping 2009-05-22 23:02:40 +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
3bbbcdfefa Full utcb copying partially works now. 2009-05-19 11:26:45 +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
3e91be04d2 SCHED_RESUME was omitted on execve() during thread_recycle. Now we do sched_init().
This caused the scheduler not to increment total priority count
which in turn caused the system to have wrong amount of priorities.
2009-05-14 13:55:15 +03:00
Bahadir Balban
8528e2e1ba Modified the kernel and all tasks with well-formatted printout messages. 2009-05-12 11:25:14 +03:00
Bahadir Balban
db0d756dfa Removed thread group id pool.
We don't need a separate group id pool for now.
2009-05-11 12:21:08 +03:00
Bahadir Balban
1b04037034 Address space creation/deletion implemented
- Proper releasing of user pmd and pgds when a space is not used.
- Proper releasing of task, space ids.

- At occasions a starting thread gets bogus SPSR, this needs investigating.
- At a very rare occasion arch_setup_new_thread() had a kernel data abort during
  register copying from one task to another. Needs investigating.
2009-05-11 12:10:12 +03:00
Bahadir Balban
7415546410 Reimplemented space handling by introducing an address_space structure.
- Fixed potential concurrency bugs due to preemption being enabled.
- Introduced a new address space structure to better account for
  address spaces and page tables.
- Currently executes fine up to forking. Will investigate.
2009-05-08 23:35:19 +03:00
Bahadir Balban
2df8875a88 Initialisation works OK with new address space structure.
Going to add:
- Address space create/delete add/remove
- KCTB create/delete add/remove
2009-05-07 11:08:35 +03:00
Bahadir Balban
6e1edc0aad Adding address space structure to ktcbs. Still booting until virtual memory is enabled. 2009-05-07 10:26:34 +03:00
Bahadir Balban
3acc66c2e7 Adding support for refcounted page tables. Fixed freeing of kernel pmds on copy_page_tables 2009-05-02 11:21:19 +03:00
Bahadir Balban
8ab892375e Comment title for kmalloc 2009-05-02 10:54:02 +03:00
Bahadir Balban
63e18b176e Fixed returning freed field of struct. 2009-05-02 10:44:23 +03:00
Bahadir Balban
9fbeefadb8 Slight modification in reaching/freeing of pmds. 2009-05-01 23:12:27 +03:00
Bahadir Balban
97bfd3bb9b Fixed error escalation in thread_create() and its function calls. 2009-05-01 22:39:31 +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