mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-04 18:27:07 +08:00
parent
9800a0f9fa
commit
e56b5cb135
@ -222,6 +222,15 @@ configure with:
|
|||||||
The LibBSD Waf support splits the options and converts them to uppercase and
|
The LibBSD Waf support splits the options and converts them to uppercase and
|
||||||
adds them -D options on the compiler command line.
|
adds them -D options on the compiler command line.
|
||||||
|
|
||||||
|
The list is:
|
||||||
|
|
||||||
|
bootverbose: Verbose boot of the kernel
|
||||||
|
verbose_sysinit: Verbose printing of all the SYSINIT calls
|
||||||
|
bus_debug: Bus debugging support
|
||||||
|
ktr: Kernel trace
|
||||||
|
ktr_verbose: Verbose kernel trace
|
||||||
|
invariants: Invariants build of the kernel
|
||||||
|
|
||||||
SMP Requirements
|
SMP Requirements
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@ -189,7 +189,9 @@ ithread_update(struct intr_thread *ithd)
|
|||||||
_Thread_Set_name(td->td_thread, ie->ie_fullname);
|
_Thread_Set_name(td->td_thread, ie->ie_fullname);
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
#ifdef KTR
|
#ifdef KTR
|
||||||
|
#ifndef __rtems__
|
||||||
sched_clear_tdname(td);
|
sched_clear_tdname(td);
|
||||||
|
#endif /* __rtems__ */
|
||||||
#endif
|
#endif
|
||||||
thread_lock(td);
|
thread_lock(td);
|
||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
@ -1242,11 +1244,7 @@ ithread_loop(void *arg)
|
|||||||
int wake;
|
int wake;
|
||||||
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
#ifndef __rtems__
|
|
||||||
p = td->td_proc;
|
p = td->td_proc;
|
||||||
#else /* __rtems__ */
|
|
||||||
p = NULL;
|
|
||||||
#endif /* __rtems__ */
|
|
||||||
ithd = (struct intr_thread *)arg;
|
ithd = (struct intr_thread *)arg;
|
||||||
KASSERT(ithd->it_thread == td,
|
KASSERT(ithd->it_thread == td,
|
||||||
("%s: ithread and proc linkage out of sync", __func__));
|
("%s: ithread and proc linkage out of sync", __func__));
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <machine/rtems-bsd-kernel-space.h>
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
*
|
*
|
||||||
@ -34,13 +36,15 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_ddb.h"
|
#include <rtems/bsd/local/opt_ddb.h>
|
||||||
#include "opt_ktr.h"
|
#include <rtems/bsd/local/opt_ktr.h>
|
||||||
#include "opt_alq.h"
|
#include <rtems/bsd/local/opt_alq.h>
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
#ifndef __rtems__
|
||||||
#include <sys/alq.h>
|
#include <sys/alq.h>
|
||||||
|
#endif /* __rtems__ */
|
||||||
#include <sys/cons.h>
|
#include <sys/cons.h>
|
||||||
#include <sys/cpuset.h>
|
#include <sys/cpuset.h>
|
||||||
#include <sys/kdb.h>
|
#include <sys/kdb.h>
|
||||||
@ -111,6 +115,7 @@ SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD,
|
|||||||
SYSCTL_UQUAD(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD,
|
SYSCTL_UQUAD(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD,
|
||||||
&ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel");
|
&ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel");
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
static int
|
static int
|
||||||
sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS)
|
sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
@ -133,6 +138,7 @@ SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask,
|
|||||||
CTLFLAG_RWTUN | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0,
|
CTLFLAG_RWTUN | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0,
|
||||||
sysctl_debug_ktr_cpumask, "S",
|
sysctl_debug_ktr_cpumask, "S",
|
||||||
"Bitmask of CPUs on which KTR logging is enabled");
|
"Bitmask of CPUs on which KTR logging is enabled");
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sysctl_debug_ktr_clear(SYSCTL_HANDLER_ARGS)
|
sysctl_debug_ktr_clear(SYSCTL_HANDLER_ARGS)
|
||||||
@ -221,11 +227,13 @@ sysctl_debug_ktr_entries(SYSCTL_HANDLER_ARGS)
|
|||||||
/* Disable ktr temporarily. */
|
/* Disable ktr temporarily. */
|
||||||
mask = ktr_mask;
|
mask = ktr_mask;
|
||||||
ktr_mask = 0;
|
ktr_mask = 0;
|
||||||
|
#ifndef __rtems__
|
||||||
/* Wait for threads to go idle. */
|
/* Wait for threads to go idle. */
|
||||||
if ((error = quiesce_all_cpus("ktrent", PCATCH)) != 0) {
|
if ((error = quiesce_all_cpus("ktrent", PCATCH)) != 0) {
|
||||||
ktr_mask = mask;
|
ktr_mask = mask;
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
#endif /* __rtems__ */
|
||||||
if (ktr_buf != ktr_buf_init)
|
if (ktr_buf != ktr_buf_init)
|
||||||
oldbuf = ktr_buf;
|
oldbuf = ktr_buf;
|
||||||
else
|
else
|
||||||
|
@ -138,9 +138,7 @@ int
|
|||||||
_sleep(void *ident, struct lock_object *lock, int priority,
|
_sleep(void *ident, struct lock_object *lock, int priority,
|
||||||
const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
|
const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
|
||||||
{
|
{
|
||||||
#ifndef __rtems__
|
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
#endif /* __rtems__ */
|
|
||||||
struct lock_class *class;
|
struct lock_class *class;
|
||||||
uintptr_t lock_state;
|
uintptr_t lock_state;
|
||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
@ -150,9 +148,7 @@ _sleep(void *ident, struct lock_object *lock, int priority,
|
|||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
WITNESS_SAVE_DECL(lock_witness);
|
WITNESS_SAVE_DECL(lock_witness);
|
||||||
|
|
||||||
#ifndef __rtems__
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
#endif /* __rtems__ */
|
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
if (KTRPOINT(td, KTR_CSW))
|
if (KTRPOINT(td, KTR_CSW))
|
||||||
ktrcsw(1, 0, wmesg);
|
ktrcsw(1, 0, wmesg);
|
||||||
@ -165,10 +161,10 @@ _sleep(void *ident, struct lock_object *lock, int priority,
|
|||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
KASSERT(TD_IS_RUNNING(td), ("_sleep: curthread not running"));
|
KASSERT(TD_IS_RUNNING(td), ("_sleep: curthread not running"));
|
||||||
KASSERT(td->td_epochnest == 0, ("sleeping in an epoch section"));
|
KASSERT(td->td_epochnest == 0, ("sleeping in an epoch section"));
|
||||||
|
#endif /* __rtems__ */
|
||||||
if (priority & PDROP)
|
if (priority & PDROP)
|
||||||
KASSERT(lock != NULL && lock != &Giant.lock_object,
|
KASSERT(lock != NULL && lock != &Giant.lock_object,
|
||||||
("PDROP requires a non-Giant lock"));
|
("PDROP requires a non-Giant lock"));
|
||||||
#endif /* __rtems__ */
|
|
||||||
if (lock != NULL)
|
if (lock != NULL)
|
||||||
class = LOCK_CLASS(lock);
|
class = LOCK_CLASS(lock);
|
||||||
else
|
else
|
||||||
@ -181,10 +177,8 @@ _sleep(void *ident, struct lock_object *lock, int priority,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
catch = priority & PCATCH;
|
catch = priority & PCATCH;
|
||||||
pri = priority & PRIMASK;
|
|
||||||
#else /* __rtems__ */
|
|
||||||
pri = priority;
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
pri = priority & PRIMASK;
|
||||||
|
|
||||||
#ifndef __rtems__
|
#ifndef __rtems__
|
||||||
KASSERT(!TD_ON_SLEEPQ(td), ("recursive sleep"));
|
KASSERT(!TD_ON_SLEEPQ(td), ("recursive sleep"));
|
||||||
|
@ -218,6 +218,7 @@ uprintf(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tprintf and vtprintf print on the controlling terminal associated with the
|
* tprintf and vtprintf print on the controlling terminal associated with the
|
||||||
@ -236,6 +237,7 @@ tprintf(struct proc *p, int pri, const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
vtprintf(struct proc *p, int pri, const char *fmt, va_list ap)
|
vtprintf(struct proc *p, int pri, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
#ifndef __rtems__
|
||||||
struct tty *tp = NULL;
|
struct tty *tp = NULL;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
struct putchar_arg pca;
|
struct putchar_arg pca;
|
||||||
@ -271,8 +273,12 @@ vtprintf(struct proc *p, int pri, const char *fmt, va_list ap)
|
|||||||
if (sess != NULL)
|
if (sess != NULL)
|
||||||
sess_release(sess);
|
sess_release(sess);
|
||||||
msgbuftrigger = 1;
|
msgbuftrigger = 1;
|
||||||
|
#else /* __rtems__ */
|
||||||
|
vprintf(fmt, ap);
|
||||||
|
#endif /* __rtems__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __rtems__
|
||||||
/*
|
/*
|
||||||
* Ttyprintf displays a message on a tty; it should be used only by
|
* Ttyprintf displays a message on a tty; it should be used only by
|
||||||
* the tty driver, or anything that knows the underlying tty will not
|
* the tty driver, or anything that knows the underlying tty will not
|
||||||
|
@ -83,7 +83,8 @@ extern int boothowto; /* reboot flags, from console subsystem */
|
|||||||
extern int bootverbose; /* nonzero to print verbose messages */
|
extern int bootverbose; /* nonzero to print verbose messages */
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
#ifdef BOOTVERBOSE
|
#ifdef BOOTVERBOSE
|
||||||
extern int bootverbose; /* nonzero to print verbose messages */
|
extern int rtems_bsd_bootverbose; /* nonzero to print verbose messages */
|
||||||
|
#define bootverbose rtems_bsd_bootverbose
|
||||||
#else
|
#else
|
||||||
#define bootverbose 0 /* Remove all verbose code for the standard RTEMS build */
|
#define bootverbose 0 /* Remove all verbose code for the standard RTEMS build */
|
||||||
#endif /* BOOTVERBOSE */
|
#endif /* BOOTVERBOSE */
|
||||||
@ -407,6 +408,20 @@ int copyout_nofault(const void * _Nonnull __restrict kaddr,
|
|||||||
void * __restrict udaddr, size_t len);
|
void * __restrict udaddr, size_t len);
|
||||||
|
|
||||||
#else /* __rtems__ */
|
#else /* __rtems__ */
|
||||||
|
static inline int
|
||||||
|
copystr(const void * _Nonnull __restrict kfaddr,
|
||||||
|
void * _Nonnull __restrict kdaddr, size_t len,
|
||||||
|
size_t * __restrict lencopied)
|
||||||
|
{
|
||||||
|
if (lencopied != NULL) {
|
||||||
|
*lencopied = len;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(kdaddr, kfaddr, len);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
|
copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
|
||||||
size_t len, size_t * __restrict lencopied)
|
size_t len, size_t * __restrict lencopied)
|
||||||
|
@ -2609,8 +2609,10 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
|
|||||||
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
|
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
|
||||||
|
|
||||||
/* This is the fast path allocation */
|
/* This is the fast path allocation */
|
||||||
|
#ifndef __rtems__
|
||||||
CTR4(KTR_UMA, "uma_zalloc_arg thread %x zone %s(%p) flags %d",
|
CTR4(KTR_UMA, "uma_zalloc_arg thread %x zone %s(%p) flags %d",
|
||||||
curthread, zone->uz_name, zone, flags);
|
curthread, zone->uz_name, zone, flags);
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
if (flags & M_WAITOK) {
|
if (flags & M_WAITOK) {
|
||||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
|
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
|
||||||
@ -2698,9 +2700,11 @@ zalloc_start:
|
|||||||
*/
|
*/
|
||||||
bucket = cache->uc_freebucket;
|
bucket = cache->uc_freebucket;
|
||||||
if (bucket != NULL && bucket->ub_cnt > 0) {
|
if (bucket != NULL && bucket->ub_cnt > 0) {
|
||||||
|
#ifndef __rtems__
|
||||||
CTR2(KTR_UMA,
|
CTR2(KTR_UMA,
|
||||||
"uma_zalloc: zone %s(%p) swapping empty with alloc",
|
"uma_zalloc: zone %s(%p) swapping empty with alloc",
|
||||||
zone->uz_name, zone);
|
zone->uz_name, zone);
|
||||||
|
#endif /* __rtems__ */
|
||||||
cache->uc_freebucket = cache->uc_allocbucket;
|
cache->uc_freebucket = cache->uc_allocbucket;
|
||||||
cache->uc_allocbucket = bucket;
|
cache->uc_allocbucket = bucket;
|
||||||
goto zalloc_start;
|
goto zalloc_start;
|
||||||
@ -2784,8 +2788,10 @@ zalloc_start:
|
|||||||
* will use the just filled bucket.
|
* will use the just filled bucket.
|
||||||
*/
|
*/
|
||||||
bucket = zone_alloc_bucket(zone, udata, domain, flags);
|
bucket = zone_alloc_bucket(zone, udata, domain, flags);
|
||||||
|
#ifndef __rtems__
|
||||||
CTR3(KTR_UMA, "uma_zalloc: zone %s(%p) bucket zone returned %p",
|
CTR3(KTR_UMA, "uma_zalloc: zone %s(%p) bucket zone returned %p",
|
||||||
zone->uz_name, zone, bucket);
|
zone->uz_name, zone, bucket);
|
||||||
|
#endif /* __rtems__ */
|
||||||
if (bucket != NULL) {
|
if (bucket != NULL) {
|
||||||
ZONE_LOCK(zone);
|
ZONE_LOCK(zone);
|
||||||
critical_enter();
|
critical_enter();
|
||||||
@ -2835,9 +2841,11 @@ uma_zalloc_domain(uma_zone_t zone, void *udata, int domain, int flags)
|
|||||||
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
|
random_harvest_fast_uma(&zone, sizeof(zone), RANDOM_UMA);
|
||||||
|
|
||||||
/* This is the fast path allocation */
|
/* This is the fast path allocation */
|
||||||
|
#ifndef __rtems__
|
||||||
CTR5(KTR_UMA,
|
CTR5(KTR_UMA,
|
||||||
"uma_zalloc_domain thread %x zone %s(%p) domain %d flags %d",
|
"uma_zalloc_domain thread %x zone %s(%p) domain %d flags %d",
|
||||||
curthread, zone->uz_name, zone, domain, flags);
|
curthread, zone->uz_name, zone, domain, flags);
|
||||||
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
if (flags & M_WAITOK) {
|
if (flags & M_WAITOK) {
|
||||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
|
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
|
||||||
|
@ -195,6 +195,7 @@ class rtems(builder.Module):
|
|||||||
'rtems/rtems-kernel-init.c',
|
'rtems/rtems-kernel-init.c',
|
||||||
'rtems/rtems-kernel-irqs.c',
|
'rtems/rtems-kernel-irqs.c',
|
||||||
'rtems/rtems-kernel-jail.c',
|
'rtems/rtems-kernel-jail.c',
|
||||||
|
'rtems/rtems-kernel-lockmgr.c',
|
||||||
'rtems/rtems-kernel-malloc.c',
|
'rtems/rtems-kernel-malloc.c',
|
||||||
'rtems/rtems-kernel-mbuf.c',
|
'rtems/rtems-kernel-mbuf.c',
|
||||||
'rtems/rtems-kernel-mtxpool.c',
|
'rtems/rtems-kernel-mtxpool.c',
|
||||||
@ -498,6 +499,7 @@ class base(builder.Module):
|
|||||||
'sys/kern/kern_event.c',
|
'sys/kern/kern_event.c',
|
||||||
'sys/kern/kern_hhook.c',
|
'sys/kern/kern_hhook.c',
|
||||||
'sys/kern/kern_intr.c',
|
'sys/kern/kern_intr.c',
|
||||||
|
'sys/kern/kern_ktr.c',
|
||||||
'sys/kern/kern_khelp.c',
|
'sys/kern/kern_khelp.c',
|
||||||
'sys/kern/kern_linker.c',
|
'sys/kern/kern_linker.c',
|
||||||
'sys/kern/kern_mbuf.c',
|
'sys/kern/kern_mbuf.c',
|
||||||
|
0
rtemsbsd/include/rtems/bsd/local/opt_alq.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_alq.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_ktr.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_ktr.h
Normal file
@ -44,6 +44,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/ktr.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
@ -187,5 +188,11 @@ rtems_bsd_initialize(void)
|
|||||||
mutex_init();
|
mutex_init();
|
||||||
mi_startup();
|
mi_startup();
|
||||||
|
|
||||||
|
#ifdef KTR
|
||||||
|
ktr_verbose = 10;
|
||||||
|
ktr_mask = KTR_ALL;
|
||||||
|
ktr_mask = KTR_GEN | KTR_LOCK | KTR_VFS | KTR_VOP | KTR_BUF | KTR_MALLOC | KTR_SYSC | KTR_RUNQ;
|
||||||
|
#endif
|
||||||
|
|
||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
@ -260,6 +260,9 @@ rtems_bsd_thread_start(struct thread **td_ptr, void (*func)(void *), void *arg,
|
|||||||
BSD_ASSERT(td != NULL);
|
BSD_ASSERT(td != NULL);
|
||||||
|
|
||||||
_Thread_Set_name(thread, name);
|
_Thread_Set_name(thread, name);
|
||||||
|
#ifdef KTR
|
||||||
|
strlcpy(td->td_name, name, sizeof(td->td_name));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (rtems_bsd_thread_ready_to_start) {
|
if (rtems_bsd_thread_ready_to_start) {
|
||||||
sc = rtems_task_start(task_id, (rtems_task_entry) func,
|
sc = rtems_task_start(task_id, (rtems_task_entry) func,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user