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.
This commit is contained in:
Bahadir Balban
2008-04-18 00:46:29 +01:00
parent 73058dc249
commit a87914910c
12 changed files with 122 additions and 133 deletions

View File

@@ -64,13 +64,14 @@ typedef int (*__l4_exchange_registers_t)(unsigned int pc, unsigned int sp,
extern __l4_exchange_registers_t __l4_exchange_registers;
int l4_exchange_registers(unsigned int pc, unsigned int sp, int pager, l4id_t tid);
typedef int (*__l4_kmem_reclaim_t)(unsigned long *pfn, int *npages);
extern __l4_kmem_reclaim_t __l4_kmem_reclaim;
int l4_kmem_reclaim(unsigned long *pfn, int *npages);
typedef int (*__l4_kmem_control_t)(unsigned long pfn, int npages, int grant);
extern __l4_kmem_control_t __l4_kmem_control;
int l4_kmem_control(unsigned long pfn, int npages, int grant);
typedef int (*__l4_time_t)(void *time_info, int set);
extern __l4_time_t __l4_time;
int l4_time(void *time_info, int set);
typedef int (*__l4_kmem_grant_t)(unsigned long pfn, int npages);
extern __l4_kmem_grant_t __l4_kmem_grant;
int l4_kmem_grant(unsigned long pfn, int npages);
/* To be supplied by server tasks. */

View File

@@ -139,49 +139,4 @@ static inline void *l4_unmap_helper(void *virt, int npages)
return virt_to_phys(virt);
}
/*
* A helper to produce grant ipc between a pager and its client, or a
* synchronous syscall to the kernel in case the grant is to the kernel.
*/
static inline int l4_grant_pages(unsigned long pfn, int npages, l4id_t tid)
{
/* Only a pager can grant pages to kernel. */
if (tid == KERNEL_TID) {
/* Granting physical pages via a system call in kernel case. */
return l4_kmem_grant(pfn, npages);
} else {
/*
* FIXME: This should set up appropriate message registers and
* call l4_ipc() on the target thread. Pages given are virtual.
*/
while(1);
}
return 0;
}
/*
* NOTE: This is just brainstroming yet.
* A helper to reclaim unused pages. A pager can reclaim pages from kernel or
* other tasks this way.
*/
static inline int l4_reclaim_pages(l4id_t tid)
{
unsigned long pfn;
int npages;
if (tid == KERNEL_TID) {
/*
* A single contiguous sequence of physical pages are returned
* by kernel via a syscall. Simpler the better for now.
*/
l4_kmem_reclaim(&pfn, &npages);
} else {
/*
* An ipc to a task where pfn and npages come in message regs.
*/
while(1);
}
return 0;
}
#endif /* __L4LIB_SYSLIB_H__ */

View File

@@ -83,27 +83,28 @@ END_PROC(l4_unmap)
/*
* System call that grants a set of pages to the kernel.
* @r0 = physical pfn, @r1 = number of pages
* @r0 = physical pfn, @r1 = number of pages, @r2 = whether to
* grant or reclaim kernel memory. grant = 1, reclaim = 0.
*/
BEGIN_PROC(l4_kmem_grant)
BEGIN_PROC(l4_kmem_control)
stmfd sp!, {lr}
ldr r12, =__l4_kmem_grant
ldr r12, =__l4_kmem_control
mov lr, pc
ldr pc, [r12]
ldmfd sp!, {pc} @ Restore original lr and return.
END_PROC(l4_kmem_grant)
END_PROC(l4_kmem_control)
/*
* System call that reclaims a set of pages from the kernel.
* @r0 = ptr to physical pfn, @r1 = ptr to number of pages
* System call that gets or sets the time info structure.
* @r0 = ptr to time structure @r1 = set or get. set = 1, get = 0.
*/
BEGIN_PROC(l4_kmem_reclaim)
BEGIN_PROC(l4_time)
stmfd sp!, {lr}
ldr r12, =__l4_kmem_reclaim
ldr r12, =__l4_time
mov lr, pc
ldr pc, [r12]
ldmfd sp!, {pc} @ Restore original lr and return.
END_PROC(l4_kmem_reclaim)
END_PROC(l4_time)
/*
* System call that controls thread creation, destruction and modification.

View File

@@ -23,8 +23,8 @@ __l4_thread_control_t __l4_thread_control = 0;
__l4_ipc_control_t __l4_ipc_control = 0;
__l4_space_control_t __l4_space_control = 0;
__l4_exchange_registers_t __l4_exchange_registers = 0;
__l4_kmem_grant_t __l4_kmem_grant = 0;
__l4_kmem_reclaim_t __l4_kmem_reclaim = 0;
__l4_kmem_control_t __l4_kmem_control = 0;
__l4_time_t __l4_time = 0;
struct kip *kip;
@@ -120,8 +120,8 @@ void __l4_init(void)
__l4_space_control= (__l4_space_control_t)kip->space_control;
__l4_exchange_registers =
(__l4_exchange_registers_t)kip->exchange_registers;
__l4_kmem_grant = (__l4_kmem_grant_t)kip->kmem_grant;
__l4_kmem_reclaim = (__l4_kmem_reclaim_t)kip->kmem_reclaim;
__l4_kmem_control = (__l4_kmem_control_t)kip->kmem_control;
__l4_time = (__l4_time_t)kip->time;
utcb_init();
}

View File

@@ -50,7 +50,7 @@ void init_mm(struct initdata *initdata)
// printf("%s: Initialised utcb address pool.\n", __TASKNAME__);
/* Give the kernel some memory to use for its allocators */
l4_kmem_grant(__pfn(alloc_page(__pfn(SZ_1MB))), __pfn(SZ_1MB));
l4_kmem_control(__pfn(alloc_page(__pfn(SZ_1MB))), __pfn(SZ_1MB), 1);
}
void initialise(void)