Move TIMEOUT(9) and ZONE(9) initialization

Delete most of virtual memory support.
This commit is contained in:
Sebastian Huber 2013-10-18 14:12:17 +02:00
parent a9be4b0481
commit ffcd542fe2
11 changed files with 178 additions and 259 deletions

View File

@ -87,7 +87,6 @@ LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-sysctlnametomib.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-taskqueue.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-taskqueue.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-thread.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-thread.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-timesupport.c LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-timesupport.c
LIB_C_FILES += rtemsbsd/rtems/rtems-bsd-vm_glue.c
LIB_C_FILES += rtemsbsd/rtems/rtems-kvm.c LIB_C_FILES += rtemsbsd/rtems/rtems-kvm.c
LIB_C_FILES += rtemsbsd/rtems/rtems-net-setup.c LIB_C_FILES += rtemsbsd/rtems/rtems-net-setup.c
LIB_C_FILES += rtemsbsd/rtems/rtems-syslog-initialize.c LIB_C_FILES += rtemsbsd/rtems/rtems-syslog-initialize.c

View File

@ -644,7 +644,6 @@ rtems.addRTEMSSourceFiles(
'rtems/rtems-bsd-taskqueue.c', 'rtems/rtems-bsd-taskqueue.c',
'rtems/rtems-bsd-thread.c', 'rtems/rtems-bsd-thread.c',
'rtems/rtems-bsd-timesupport.c', 'rtems/rtems-bsd-timesupport.c',
'rtems/rtems-bsd-vm_glue.c',
'rtems/rtems-kvm.c', 'rtems/rtems-kvm.c',
'rtems/rtems-net-setup.c', 'rtems/rtems-net-setup.c',
'rtems/rtems-syslog-initialize.c', 'rtems/rtems-syslog-initialize.c',
@ -778,6 +777,7 @@ base.addHeaderFiles(
'sys/vm/uma_dbg.h', 'sys/vm/uma_dbg.h',
'sys/vm/uma.h', 'sys/vm/uma.h',
'sys/vm/uma_int.h', 'sys/vm/uma_int.h',
'sys/vm/vm_extern.h',
'sys/vm/vm.h', 'sys/vm/vm.h',
] ]
) )

View File

@ -67,10 +67,8 @@ __FBSDID("$FreeBSD$");
#include <net/vnet.h> #include <net/vnet.h>
#include <security/mac/mac_framework.h> #include <security/mac/mac_framework.h>
#ifndef __rtems__
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_extern.h> #include <vm/vm_extern.h>
#endif
#ifdef __rtems__ #ifdef __rtems__
/* From FreeBSD file 'sys/kern/kern_mib.c' */ /* From FreeBSD file 'sys/kern/kern_mib.c' */
@ -1207,10 +1205,8 @@ kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old,
error = sysctl_root(0, name, namelen, &req); error = sysctl_root(0, name, namelen, &req);
SYSCTL_SUNLOCK(); SYSCTL_SUNLOCK();
#ifndef __rtems__
if (req.lock == REQ_WIRED && req.validlen > 0) if (req.lock == REQ_WIRED && req.validlen > 0)
vsunlock(req.oldptr, req.validlen); vsunlock(req.oldptr, req.validlen);
#endif /* __rtems__ */
if (error && error != ENOMEM) if (error && error != ENOMEM)
return (error); return (error);

View File

@ -157,10 +157,27 @@ MALLOC_DEFINE(M_CALLOUT, "callout", "Callout datastructures");
* This code is called very early in the kernel initialization sequence, * This code is called very early in the kernel initialization sequence,
* and may be called more then once. * and may be called more then once.
*/ */
#ifdef __rtems__
static void rtems_bsd_timeout_init(void *);
static void callout_cpu_init(struct callout_cpu *);
SYSINIT(rtems_bsd_timeout, SI_SUB_VM, SI_ORDER_FIRST, rtems_bsd_timeout_init,
NULL);
static void
rtems_bsd_timeout_init(void *unused)
#else /* __rtems__ */
caddr_t caddr_t
kern_timeout_callwheel_alloc(caddr_t v) kern_timeout_callwheel_alloc(caddr_t v)
#endif /* __rtems__ */
{ {
struct callout_cpu *cc; struct callout_cpu *cc;
#ifdef __rtems__
caddr_t v;
(void) unused;
#endif /* __rtems__ */
timeout_cpu = PCPU_GET(cpuid); timeout_cpu = PCPU_GET(cpuid);
cc = CC_CPU(timeout_cpu); cc = CC_CPU(timeout_cpu);
@ -173,11 +190,19 @@ kern_timeout_callwheel_alloc(caddr_t v)
; ;
callwheelmask = callwheelsize - 1; callwheelmask = callwheelsize - 1;
#ifdef __rtems__
v = malloc(ncallout * sizeof(*cc->cc_callout) + callwheelsize
* sizeof(*cc->cc_callwheel), M_CALLOUT, M_ZERO | M_WAITOK);
#endif /* __rtems__ */
cc->cc_callout = (struct callout *)v; cc->cc_callout = (struct callout *)v;
v = (caddr_t)(cc->cc_callout + ncallout); v = (caddr_t)(cc->cc_callout + ncallout);
cc->cc_callwheel = (struct callout_tailq *)v; cc->cc_callwheel = (struct callout_tailq *)v;
v = (caddr_t)(cc->cc_callwheel + callwheelsize); v = (caddr_t)(cc->cc_callwheel + callwheelsize);
#ifndef __rtems__
return(v); return(v);
#else /* __rtems__ */
callout_cpu_init(cc);
#endif /* __rtems__ */
} }
static void static void
@ -201,6 +226,7 @@ callout_cpu_init(struct callout_cpu *cc)
} }
} }
#ifndef __rtems__
/* /*
* kern_timeout_callwheel_init() - initialize previously reserved callwheel * kern_timeout_callwheel_init() - initialize previously reserved callwheel
* space. * space.
@ -213,6 +239,7 @@ kern_timeout_callwheel_init(void)
{ {
callout_cpu_init(CC_CPU(timeout_cpu)); callout_cpu_init(CC_CPU(timeout_cpu));
} }
#endif /* __rtems__ */
/* /*
* Start standard softclock thread. * Start standard softclock thread.

View File

@ -93,11 +93,9 @@ void rtems_page_free( void *address );
#include <vm/uma_int.h> #include <vm/uma_int.h>
#include <vm/uma_dbg.h> #include <vm/uma_dbg.h>
#ifndef __rtems__
#include <machine/vmparam.h> #include <machine/vmparam.h>
#include <ddb/ddb.h> #include <ddb/ddb.h>
#endif /* __rtems__ */
/* /*
* This is the zone and keg from which all zones are spawned. The idea is that * This is the zone and keg from which all zones are spawned. The idea is that
@ -125,10 +123,12 @@ static int uma_align_cache = 64 - 1;
static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets"); static MALLOC_DEFINE(M_UMAHASH, "UMAHash", "UMA Hash Buckets");
#ifndef __rtems__
/* /*
* Are we allowed to allocate buckets? * Are we allowed to allocate buckets?
*/ */
static int bucketdisable = 1; static int bucketdisable = 1;
#endif /* __rtems__ */
/* Linked list of all kegs in the system */ /* Linked list of all kegs in the system */
static LIST_HEAD(,uma_keg) uma_kegs = LIST_HEAD_INITIALIZER(uma_kegs); static LIST_HEAD(,uma_keg) uma_kegs = LIST_HEAD_INITIALIZER(uma_kegs);
@ -136,6 +136,7 @@ static LIST_HEAD(,uma_keg) uma_kegs = LIST_HEAD_INITIALIZER(uma_kegs);
/* This mutex protects the keg list */ /* This mutex protects the keg list */
static struct mtx uma_mtx; static struct mtx uma_mtx;
#ifndef __rtems__
/* Linked list of boot time pages */ /* Linked list of boot time pages */
static LIST_HEAD(,uma_slab) uma_boot_pages = static LIST_HEAD(,uma_slab) uma_boot_pages =
LIST_HEAD_INITIALIZER(uma_boot_pages); LIST_HEAD_INITIALIZER(uma_boot_pages);
@ -145,6 +146,7 @@ static struct mtx uma_boot_pages_mtx;
/* Is the VM done starting up? */ /* Is the VM done starting up? */
static int booted = 0; static int booted = 0;
#endif /* __rtems__ */
/* Maximum number of allowed items-per-slab if the slab header is OFFPAGE */ /* Maximum number of allowed items-per-slab if the slab header is OFFPAGE */
static u_int uma_max_ipers; static u_int uma_max_ipers;
@ -220,7 +222,9 @@ enum zfreeskip { SKIP_NONE, SKIP_DTOR, SKIP_FINI };
static void *obj_alloc(uma_zone_t, int, u_int8_t *, int); static void *obj_alloc(uma_zone_t, int, u_int8_t *, int);
#endif /* __rtems__ */ #endif /* __rtems__ */
static void *page_alloc(uma_zone_t, int, u_int8_t *, int); static void *page_alloc(uma_zone_t, int, u_int8_t *, int);
#ifndef __rtems__
static void *startup_alloc(uma_zone_t, int, u_int8_t *, int); static void *startup_alloc(uma_zone_t, int, u_int8_t *, int);
#endif /* __rtems__ */
static void page_free(void *, int, u_int8_t); static void page_free(void *, int, u_int8_t);
static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int); static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int);
static void cache_drain(uma_zone_t); static void cache_drain(uma_zone_t);
@ -250,7 +254,9 @@ static void bucket_free(uma_bucket_t);
static void bucket_zone_drain(void); static void bucket_zone_drain(void);
static int zone_alloc_bucket(uma_zone_t zone, int flags); static int zone_alloc_bucket(uma_zone_t zone, int flags);
static uma_slab_t zone_fetch_slab(uma_zone_t zone, uma_keg_t last, int flags); static uma_slab_t zone_fetch_slab(uma_zone_t zone, uma_keg_t last, int flags);
#ifndef __rtems__
static uma_slab_t zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int flags); static uma_slab_t zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int flags);
#endif /* __rtems__ */
static void *slab_alloc_item(uma_zone_t zone, uma_slab_t slab); static void *slab_alloc_item(uma_zone_t zone, uma_slab_t slab);
static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit, static uma_keg_t uma_kcreate(uma_zone_t zone, size_t size, uma_init uminit,
uma_fini fini, int align, u_int32_t flags); uma_fini fini, int align, u_int32_t flags);
@ -285,8 +291,8 @@ bucket_enable(void)
if (cnt.v_free_count < cnt.v_free_min) if (cnt.v_free_count < cnt.v_free_min)
bucketdisable = 1; bucketdisable = 1;
else else
#endif /* __rtems__ */
bucketdisable = 0; bucketdisable = 0;
#endif /* __rtems__ */
} }
/* /*
@ -336,6 +342,7 @@ bucket_alloc(int entries, int bflags)
struct uma_bucket_zone *ubz; struct uma_bucket_zone *ubz;
uma_bucket_t bucket; uma_bucket_t bucket;
#ifndef __rtems__
/* /*
* This is to stop us from allocating per cpu buckets while we're * This is to stop us from allocating per cpu buckets while we're
* running out of vm.boot_pages. Otherwise, we would exhaust the * running out of vm.boot_pages. Otherwise, we would exhaust the
@ -344,6 +351,7 @@ bucket_alloc(int entries, int bflags)
*/ */
if (bucketdisable) if (bucketdisable)
return (NULL); return (NULL);
#endif /* __rtems__ */
ubz = bucket_zone_lookup(entries); ubz = bucket_zone_lookup(entries);
bucket = zone_alloc_item(ubz->ubz_zone, NULL, bflags); bucket = zone_alloc_item(ubz->ubz_zone, NULL, bflags);
@ -944,6 +952,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int wait)
return (slab); return (slab);
} }
#ifndef __rtems__
/* /*
* This function is intended to be used early on in place of page_alloc() so * This function is intended to be used early on in place of page_alloc() so
* that we may use the boot time page cache to satisfy allocations before * that we may use the boot time page cache to satisfy allocations before
@ -997,6 +1006,7 @@ startup_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait)
#endif #endif
return keg->uk_allocf(zone, bytes, pflag, wait); return keg->uk_allocf(zone, bytes, pflag, wait);
} }
#endif /* __rtems__ */
/* /*
* Allocates a number of pages from the system * Allocates a number of pages from the system
@ -1009,11 +1019,6 @@ startup_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait)
* A pointer to the alloced memory or possibly * A pointer to the alloced memory or possibly
* NULL if M_NOWAIT is set. * NULL if M_NOWAIT is set.
*/ */
#ifdef __rtems__
#define PAGE_MASK (PAGE_SIZE-1)
#define round_page(x) ((((unsigned long )(x)) + PAGE_MASK) & ~(PAGE_MASK))
#endif
static void * static void *
page_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait) page_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait)
{ {
@ -1364,10 +1369,14 @@ keg_ctor(void *mem, int size, void *udata, int flags)
keg->uk_allocf = uma_small_alloc; keg->uk_allocf = uma_small_alloc;
keg->uk_freef = uma_small_free; keg->uk_freef = uma_small_free;
#endif #endif
#ifndef __rtems__
if (booted == 0) if (booted == 0)
keg->uk_allocf = startup_alloc; keg->uk_allocf = startup_alloc;
} else if (booted == 0 && (keg->uk_flags & UMA_ZFLAG_INTERNAL)) } else if (booted == 0 && (keg->uk_flags & UMA_ZFLAG_INTERNAL))
keg->uk_allocf = startup_alloc; keg->uk_allocf = startup_alloc;
#else /* __rtems__ */
}
#endif /* __rtems__ */
/* /*
* Initialize keg's lock (shared among zones). * Initialize keg's lock (shared among zones).
@ -1638,10 +1647,14 @@ void
uma_startup(void *bootmem, int boot_pages) uma_startup(void *bootmem, int boot_pages)
{ {
struct uma_zctor_args args; struct uma_zctor_args args;
#ifndef __rtems__
uma_slab_t slab; uma_slab_t slab;
#endif /* __rtems__ */
u_int slabsize; u_int slabsize;
u_int objsize, totsize, wsize; u_int objsize, totsize, wsize;
#ifndef __rtems__
int i; int i;
#endif /* __rtems__ */
#ifdef UMA_DEBUG #ifdef UMA_DEBUG
printf("Creating uma keg headers zone and keg.\n"); printf("Creating uma keg headers zone and keg.\n");
@ -1732,6 +1745,7 @@ uma_startup(void *bootmem, int boot_pages)
/* The initial zone has no Per cpu queues so it's smaller */ /* The initial zone has no Per cpu queues so it's smaller */
zone_ctor(kegs, sizeof(struct uma_zone), &args, M_WAITOK); zone_ctor(kegs, sizeof(struct uma_zone), &args, M_WAITOK);
#ifndef __rtems__
#ifdef UMA_DEBUG #ifdef UMA_DEBUG
printf("Filling boot free list.\n"); printf("Filling boot free list.\n");
#endif #endif
@ -1742,6 +1756,7 @@ uma_startup(void *bootmem, int boot_pages)
LIST_INSERT_HEAD(&uma_boot_pages, slab, us_link); LIST_INSERT_HEAD(&uma_boot_pages, slab, us_link);
} }
mtx_init(&uma_boot_pages_mtx, "UMA boot pages", NULL, MTX_DEF); mtx_init(&uma_boot_pages_mtx, "UMA boot pages", NULL, MTX_DEF);
#endif /* __rtems__ */
#ifdef UMA_DEBUG #ifdef UMA_DEBUG
printf("Creating uma zone headers zone and keg.\n"); printf("Creating uma zone headers zone and keg.\n");
@ -1806,19 +1821,31 @@ uma_startup(void *bootmem, int boot_pages)
printf("UMA startup complete.\n"); printf("UMA startup complete.\n");
#endif #endif
} }
#ifdef __rtems__
static void
rtems_bsd_uma_startup(void *unused)
{
(void) unused;
uma_startup(NULL, 0);
}
SYSINIT(rtems_bsd_uma_startup, SI_SUB_VM, SI_ORDER_FIRST,
rtems_bsd_uma_startup, NULL);
#endif /* __rtems__ */
#ifndef __rtems__
/* see uma.h */ /* see uma.h */
void void
uma_startup2(void) uma_startup2(void)
{ {
booted = 1; booted = 1;
#ifndef __rtems__
bucket_enable(); bucket_enable();
#endif /* __rtems__ */
#ifdef UMA_DEBUG #ifdef UMA_DEBUG
printf("UMA startup2 complete.\n"); printf("UMA startup2 complete.\n");
#endif #endif
} }
#endif /* __rtems__ */
/* /*
* Initialize our callout handle * Initialize our callout handle
@ -1907,6 +1934,7 @@ uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor,
return (zone_alloc_item(zones, &args, M_WAITOK)); return (zone_alloc_item(zones, &args, M_WAITOK));
} }
#ifndef __rtems__
static void static void
zone_lock_pair(uma_zone_t a, uma_zone_t b) zone_lock_pair(uma_zone_t a, uma_zone_t b)
{ {
@ -1927,7 +1955,6 @@ zone_unlock_pair(uma_zone_t a, uma_zone_t b)
ZONE_UNLOCK(b); ZONE_UNLOCK(b);
} }
#ifndef __rtems__
int int
uma_zsecond_add(uma_zone_t zone, uma_zone_t master) uma_zsecond_add(uma_zone_t zone, uma_zone_t master)
{ {
@ -2284,6 +2311,7 @@ zone_fetch_slab(uma_zone_t zone, uma_keg_t keg, int flags)
return (NULL); return (NULL);
} }
#ifndef __rtems__
/* /*
* uma_zone_fetch_slab_multi: Fetches a slab from one available keg. Returns * uma_zone_fetch_slab_multi: Fetches a slab from one available keg. Returns
* with the keg locked. Caller must call zone_relock() afterwards if the * with the keg locked. Caller must call zone_relock() afterwards if the
@ -2360,6 +2388,7 @@ zone_fetch_slab_multi(uma_zone_t zone, uma_keg_t last, int rflags)
} }
return (NULL); return (NULL);
} }
#endif /* __rtems__ */
static void * static void *
slab_alloc_item(uma_zone_t zone, uma_slab_t slab) slab_alloc_item(uma_zone_t zone, uma_slab_t slab)
@ -3078,9 +3107,7 @@ uma_reclaim(void)
#ifdef UMA_DEBUG #ifdef UMA_DEBUG
printf("UMA: vm asked us to release pages!\n"); printf("UMA: vm asked us to release pages!\n");
#endif #endif
#ifndef __rtems__
bucket_enable(); bucket_enable();
#endif /* __rtems__ */
zone_foreach(zone_drain); zone_foreach(zone_drain);
/* /*
* Some slabs may have been freed but this zone will be visited early * Some slabs may have been freed but this zone will be visited early

110
freebsd/sys/vm/vm_extern.h Normal file
View File

@ -0,0 +1,110 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
* $FreeBSD$
*/
#ifndef _VM_EXTERN_H_
#define _VM_EXTERN_H_
struct proc;
struct vmspace;
struct vnode;
#ifdef _KERNEL
int kernacc(void *, int, int);
vm_offset_t kmem_alloc(vm_map_t, vm_size_t);
vm_offset_t kmem_alloc_attr(vm_map_t map, vm_size_t size, int flags,
vm_paddr_t low, vm_paddr_t high, vm_memattr_t memattr);
vm_offset_t kmem_alloc_contig(vm_map_t map, vm_size_t size, int flags,
vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
unsigned long boundary, vm_memattr_t memattr);
vm_offset_t kmem_alloc_nofault(vm_map_t, vm_size_t);
vm_offset_t kmem_alloc_nofault_space(vm_map_t, vm_size_t, int);
vm_offset_t kmem_alloc_wait(vm_map_t, vm_size_t);
void kmem_free(vm_map_t, vm_offset_t, vm_size_t);
void kmem_free_wakeup(vm_map_t, vm_offset_t, vm_size_t);
void kmem_init(vm_offset_t, vm_offset_t);
vm_offset_t kmem_malloc(vm_map_t map, vm_size_t size, int flags);
int kmem_back(vm_map_t, vm_offset_t, vm_size_t, int);
vm_map_t kmem_suballoc(vm_map_t, vm_offset_t *, vm_offset_t *, vm_size_t,
boolean_t);
void swapout_procs(int);
int useracc(void *, int, int);
int vm_fault(vm_map_t, vm_offset_t, vm_prot_t, int);
void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
vm_ooffset_t *);
void vm_fault_unwire(vm_map_t, vm_offset_t, vm_offset_t, boolean_t);
int vm_fault_wire(vm_map_t, vm_offset_t, vm_offset_t, boolean_t, boolean_t);
int vm_forkproc(struct thread *, struct proc *, struct thread *, struct vmspace *, int);
void vm_waitproc(struct proc *);
int vm_mmap(vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int, objtype_t, void *, vm_ooffset_t);
void vm_set_page_size(void);
void vm_sync_icache(vm_map_t, vm_offset_t, vm_size_t);
struct vmspace *vmspace_alloc(vm_offset_t, vm_offset_t);
struct vmspace *vmspace_fork(struct vmspace *, vm_ooffset_t *);
int vmspace_exec(struct proc *, vm_offset_t, vm_offset_t);
int vmspace_unshare(struct proc *);
void vmspace_exit(struct thread *);
struct vmspace *vmspace_acquire_ref(struct proc *);
void vmspace_free(struct vmspace *);
void vmspace_exitfree(struct proc *);
void vnode_pager_setsize(struct vnode *, vm_ooffset_t);
#ifndef __rtems__
int vslock(void *, size_t);
void vsunlock(void *, size_t);
#else /* __rtems__ */
static inline int
vslock(void *addr, size_t len)
{
(void) addr;
(void) len;
return (0);
}
static inline void
vsunlock(void *addr, size_t len)
{
(void) addr;
(void) len;
}
#endif /* __rtems__ */
void vm_object_print(/* db_expr_t */ long, boolean_t, /* db_expr_t */ long,
char *);
int vm_fault_quick(caddr_t v, int prot);
struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
void vm_imgact_unmap_page(struct sf_buf *sf);
void vm_thread_dispose(struct thread *td);
int vm_thread_new(struct thread *td, int pages);
void vm_thread_swapin(struct thread *td);
void vm_thread_swapout(struct thread *td);
#endif /* _KERNEL */
#endif /* !_VM_EXTERN_H_ */

View File

@ -1,214 +0,0 @@
/**
* @file
*
* @ingroup rtems_bsd_rtems
*
* @brief TODO.
*/
/*
* COPYRIGHT (c) 2012.
* On-Line Applications Research Corporation (OAR).
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/rtems-bsd-config.h>
#include <rtems/bsd/sys/types.h>
#include <rtems/bsd/sys/param.h>
#include <rtems/bsd/sys/lock.h>
#include <sys/sched.h>
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <vm/uma.h>
#include <vm/uma_int.h>
#include <sys/systm.h>
/*
* System initialization
*/
static int boot_pages = UMA_BOOT_PAGES;
static void vm_mem_init(void *);
SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL);
static void
vm_mem_init(dummy)
void *dummy;
{
void *mapped;
static void *callwheel_array[270];
caddr_t c;
caddr_t p;
/*
* The values for mapped came from the freeBSD method
* vm_page_startup() in the freeBSD file vm_page.c.
* XXX - This may need to be adjusted for our system.
*/
mapped = calloc( boot_pages * UMA_SLAB_SIZE, 1 );
uma_startup((void *)mapped, boot_pages);
/*
* The following is doing a minimal amount of work from
* the method vm_ksubmap_init() in freeBSD vm_init.c.
*/
c = (caddr_t) callwheel_array;
p = kern_timeout_callwheel_alloc(c);
printf( "*** callwheel 0x%x 0x%x 0x%x\n", c, p, (c + sizeof(callwheel_array)) );
if ( p > (c + sizeof(callwheel_array)) )
panic( "*** not enough memory for callwheel_array ***" );
kern_timeout_callwheel_init();
uma_startup2();
}
/*
* MPSAFE
*
* WARNING! This code calls vm_map_check_protection() which only checks
* the associated vm_map_entry range. It does not determine whether the
* contents of the memory is actually readable or writable. In most cases
* just checking the vm_map_entry is sufficient within the kernel's address
* space.
*/
int
kernacc(addr, len, rw)
void *addr;
int len, rw;
{
return 1;
}
/*
* MPSAFE
*
* WARNING! This code calls vm_map_check_protection() which only checks
* the associated vm_map_entry range. It does not determine whether the
* contents of the memory is actually readable or writable. vmapbuf(),
* vm_fault_quick(), or copyin()/copout()/su*()/fu*() functions should be
* used in conjuction with this call.
*/
int
useracc(addr, len, rw)
void *addr;
int len, rw;
{
return 1;
}
int
vslock(void *addr, size_t len)
{
return 0;
}
void
vsunlock(void *addr, size_t len)
{
}
/*
* Destroy the given CPU private mapping and unpin the page that it mapped.
*/
void
vm_imgact_unmap_page(struct sf_buf *sf)
{
}
/*
* Create the kernel stack (including pcb for i386) for a new thread.
* This routine directly affects the fork perf for a process and
* create performance for a thread.
*/
int
vm_thread_new(struct thread *td, int pages)
{
return (1);
}
/*
* Dispose of a thread's kernel stack.
*/
void
vm_thread_dispose(struct thread *td)
{
}
/*
* Allow a thread's kernel stack to be paged out.
*/
void
vm_thread_swapout(struct thread *td)
{
}
/*
* Bring the kernel stack for a specified thread back in.
*/
void
vm_thread_swapin(struct thread *td)
{
}
/*
* Implement fork's actions on an address space.
* Here we arrange for the address space to be copied or referenced,
* allocate a user struct (pcb and kernel stack), then call the
* machine-dependent layer to fill those in and make the new process
* ready to run. The new process is set up so that it returns directly
* to user mode to avoid stack copying and relocation problems.
*/
int
vm_forkproc(td, p2, td2, vm2, flags)
struct thread *td;
struct proc *p2;
struct thread *td2;
struct vmspace *vm2;
int flags;
{
}
/*
* Called after process has been wait(2)'ed apon and is being reaped.
* The idea is to reclaim resources that we could not reclaim while
* the process was still executing.
*/
void
vm_waitproc(p)
struct proc *p;
{
}
void
faultin(p)
struct proc *p;
{
}
void
kick_proc0(void)
{
}

View File

@ -49,7 +49,6 @@ static void Init(rtems_task_argument arg)
sc = rtems_bsd_initialize(); sc = rtems_bsd_initialize();
assert(sc == RTEMS_SUCCESSFUL); assert(sc == RTEMS_SUCCESSFUL);
timeout_table_init();
callout_tick_task_init(); callout_tick_task_init();
timeout_test(); timeout_test();

View File

@ -39,30 +39,6 @@
#include "timeout_helper.h" #include "timeout_helper.h"
void timeout_table_init()
{
size_t size = 0;
caddr_t v = 0;
void* firstaddr = 0;
/* calculates how much memory is needed */
v = kern_timeout_callwheel_alloc(v);
/* allocate memory */
size = (size_t)v;
firstaddr = malloc(round_page(size));
assert(firstaddr != NULL);
/* now set correct addresses for callwheel */
v = (caddr_t) firstaddr;
v = kern_timeout_callwheel_alloc(v);
assert((size_t)((void *)v - firstaddr) == size);
/* Initialize the callouts we just allocated. */
kern_timeout_callwheel_init();
}
#define CALLOUT_TICK_TASK_PRIO (PRIORITY_DEFAULT_MAXIMUM - 1) #define CALLOUT_TICK_TASK_PRIO (PRIORITY_DEFAULT_MAXIMUM - 1)
#define CALLOUT_TICK_TASK_STACK_SIZE (1024) #define CALLOUT_TICK_TASK_STACK_SIZE (1024)
#define CALLOUT_TICK_TASK_NAME rtems_build_name('C', 'O', 'U', 'T') #define CALLOUT_TICK_TASK_NAME rtems_build_name('C', 'O', 'U', 'T')

View File

@ -36,7 +36,6 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
void timeout_table_init(void);
void callout_tick_task_init(void); void callout_tick_task_init(void);
#ifdef __cplusplus #ifdef __cplusplus