Merge svn+ssh://svn.freebsd.org/base/head@218816

This commit is contained in:
Marcel Moolenaar 2011-02-18 21:39:09 +00:00
commit 9b4fcf851a
1463 changed files with 175015 additions and 121585 deletions

View File

@ -22,10 +22,7 @@ CFLAGS+= -I${.CURDIR}
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -mpreferred-stack-boundary=2
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2
.endif
.if ${MACHINE_CPUARCH} == "i386"
CFLAGS+= -mno-sse3
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
.endif
.if ${MACHINE} == "pc98"
CFLAGS+= -Os

View File

@ -68,7 +68,7 @@ acpi_machdep_init(device_t dev)
if (intr_model != ACPI_INTR_PIC)
acpi_SetIntrModel(intr_model);
SYSCTL_ADD_UINT(&sc->acpi_sysctl_ctx,
SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx,
SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO,
"reset_video", CTLFLAG_RW, &acpi_reset_video, 0,
"Call the VESA reset BIOS vector on the resume path");

View File

@ -311,6 +311,8 @@ amd64_mrstoreone(void *arg)
mrd = sc->mr_desc;
critical_enter();
/* Disable PGE. */
cr4 = rcr4();
load_cr4(cr4 & ~CR4_PGE);
@ -399,6 +401,8 @@ amd64_mrstoreone(void *arg)
/* Restore caches and PGE. */
load_cr0(cr0);
load_cr4(cr4);
critical_exit();
}
/*

View File

@ -58,17 +58,15 @@ IDTVEC(vec_name) ; \
FAKE_MCOUNT(TF_RIP(%rsp)) ; \
movq lapic, %rdx ; /* pointer to local APIC */ \
movl LA_ISR + 16 * (index)(%rdx), %eax ; /* load ISR */ \
bsrl %eax, %eax ; /* index of highset set bit in ISR */ \
jz 2f ; \
bsrl %eax, %eax ; /* index of highest set bit in ISR */ \
jz 1f ; \
addl $(32 * index),%eax ; \
1: ; \
movq %rsp, %rsi ; \
movl %eax, %edi ; /* pass the IRQ */ \
call lapic_handle_intr ; \
1: ; \
MEXITCOUNT ; \
jmp doreti ; \
2: movl $-1, %eax ; /* send a vector of -1 */ \
jmp 1b
jmp doreti
/*
* Handle "spurious INTerrupts".

View File

@ -94,7 +94,7 @@ END(cpu_throw)
ENTRY(cpu_switch)
/* Switch to new thread. First, save context. */
movq TD_PCB(%rdi),%r8
movb $1,PCB_FULL_IRET(%r8)
orl $PCB_FULL_IRET,PCB_FLAGS(%r8)
movq (%rsp),%rax /* Hardware registers */
movq %r15,PCB_R15(%r8)

View File

@ -75,11 +75,14 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_setregs = exec_setregs,
.sv_fixlimit = NULL,
.sv_maxssiz = NULL,
.sv_flags = SV_ABI_FREEBSD | SV_LP64,
.sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_SHP,
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
static Elf64_Brandinfo freebsd_brand_info = {
.brand = ELFOSABI_FREEBSD,
@ -129,7 +132,6 @@ SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t) elf64_insert_brand_entry,
&kfreebsd_brand_info);
void
elf64_dump_thread(struct thread *td __unused, void *dst __unused,
size_t *off __unused)

View File

@ -170,7 +170,7 @@ alltraps:
jz alltraps_testi /* already running with kernel GS.base */
swapgs
movq PCPU(CURPCB),%rdi
movb $0,PCB_FULL_IRET(%rdi)
andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi)
movw %fs,TF_FS(%rsp)
movw %gs,TF_GS(%rsp)
movw %es,TF_ES(%rsp)
@ -243,7 +243,7 @@ alltraps_noen:
jz 1f /* already running with kernel GS.base */
swapgs
movq PCPU(CURPCB),%rdi
movb $0,PCB_FULL_IRET(%rdi)
andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi)
1: movw %fs,TF_FS(%rsp)
movw %gs,TF_GS(%rsp)
movw %es,TF_ES(%rsp)
@ -294,7 +294,7 @@ IDTVEC(page)
jz 1f /* already running with kernel GS.base */
swapgs
movq PCPU(CURPCB),%rdi
movb $0,PCB_FULL_IRET(%rdi)
andl $~PCB_FULL_IRET,PCB_FLAGS(%rdi)
1: movq %cr2,%rdi /* preserve %cr2 before .. */
movq %rdi,TF_ADDR(%rsp) /* enabling interrupts. */
movw %fs,TF_FS(%rsp)
@ -324,7 +324,7 @@ IDTVEC(prot)
jz 2f /* already running with kernel GS.base */
1: swapgs
2: movq PCPU(CURPCB),%rdi
movb $1,PCB_FULL_IRET(%rdi) /* always full iret from GPF */
orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* always full iret from GPF */
movw %fs,TF_FS(%rsp)
movw %gs,TF_GS(%rsp)
movw %es,TF_ES(%rsp)
@ -356,7 +356,7 @@ IDTVEC(fast_syscall)
movw %es,TF_ES(%rsp)
movw %ds,TF_DS(%rsp)
movq PCPU(CURPCB),%r11
movb $0,PCB_FULL_IRET(%r11)
andl $~PCB_FULL_IRET,PCB_FLAGS(%r11)
sti
movq $KUDSEL,TF_SS(%rsp)
movq $KUCSEL,TF_CS(%rsp)
@ -380,7 +380,6 @@ IDTVEC(fast_syscall)
movq %rsp,%rdi
call syscall
movq PCPU(CURPCB),%rax
andq $~PCB_FULLCTX,PCB_FLAGS(%rax)
MEXITCOUNT
jmp doreti
@ -662,8 +661,8 @@ doreti_exit:
*/
testb $SEL_RPL_MASK,TF_CS(%rsp)
jz ld_regs
cmpb $0,PCB_FULL_IRET(%r8)
je ld_regs
testl $PCB_FULL_IRET,PCB_FLAGS(%r8)
jz ld_regs
testl $TF_HASSEGS,TF_FLAGS(%rsp)
je set_segs

View File

@ -426,7 +426,11 @@ fpudna(void)
fxrstor(&fpu_initialstate);
if (pcb->pcb_initial_fpucw != __INITIAL_FPUCW__)
fldcw(pcb->pcb_initial_fpucw);
fpuuserinited(curthread);
if (PCB_USER_FPU(pcb))
set_pcb_flags(pcb,
PCB_FPUINITDONE | PCB_USERFPUINITDONE);
else
set_pcb_flags(pcb, PCB_FPUINITDONE);
} else
fxrstor(pcb->pcb_save);
critical_exit();
@ -441,7 +445,7 @@ fpudrop()
KASSERT(td == curthread, ("fpudrop: fpcurthread != curthread"));
CRITICAL_ASSERT(td);
PCPU_SET(fpcurthread, NULL);
td->td_pcb->pcb_flags &= ~PCB_FPUINITDONE;
clear_pcb_flags(td->td_pcb, PCB_FPUINITDONE);
start_emulating();
}
@ -481,8 +485,10 @@ fpuuserinited(struct thread *td)
pcb = td->td_pcb;
if (PCB_USER_FPU(pcb))
pcb->pcb_flags |= PCB_FPUINITDONE;
pcb->pcb_flags |= PCB_USERFPUINITDONE;
set_pcb_flags(pcb,
PCB_FPUINITDONE | PCB_USERFPUINITDONE);
else
set_pcb_flags(pcb, PCB_FPUINITDONE);
}
/*
@ -498,7 +504,7 @@ fpusetregs(struct thread *td, struct savefpu *addr)
if (td == PCPU_GET(fpcurthread) && PCB_USER_FPU(pcb)) {
fxrstor(addr);
critical_exit();
pcb->pcb_flags |= PCB_FPUINITDONE | PCB_USERFPUINITDONE;
set_pcb_flags(pcb, PCB_FPUINITDONE | PCB_USERFPUINITDONE);
} else {
critical_exit();
bcopy(addr, &td->td_pcb->pcb_user_save, sizeof(*addr));
@ -607,8 +613,8 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
fpuexit(td);
ctx->prev = pcb->pcb_save;
pcb->pcb_save = &ctx->hwstate;
pcb->pcb_flags |= PCB_KERNFPU;
pcb->pcb_flags &= ~PCB_FPUINITDONE;
set_pcb_flags(pcb, PCB_KERNFPU);
clear_pcb_flags(pcb, PCB_FPUINITDONE);
return (0);
}
@ -624,16 +630,16 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx)
critical_exit();
pcb->pcb_save = ctx->prev;
if (pcb->pcb_save == &pcb->pcb_user_save) {
if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0)
pcb->pcb_flags |= PCB_FPUINITDONE;
else
pcb->pcb_flags &= ~PCB_FPUINITDONE;
pcb->pcb_flags &= ~PCB_KERNFPU;
if ((pcb->pcb_flags & PCB_USERFPUINITDONE) != 0) {
set_pcb_flags(pcb, PCB_FPUINITDONE);
clear_pcb_flags(pcb, PCB_KERNFPU);
} else
clear_pcb_flags(pcb, PCB_FPUINITDONE | PCB_KERNFPU);
} else {
if ((ctx->flags & FPU_KERN_CTX_FPUINITDONE) != 0)
pcb->pcb_flags |= PCB_FPUINITDONE;
set_pcb_flags(pcb, PCB_FPUINITDONE);
else
pcb->pcb_flags &= ~PCB_FPUINITDONE;
clear_pcb_flags(pcb, PCB_FPUINITDONE);
KASSERT(!PCB_USER_FPU(pcb), ("unpaired fpu_kern_leave"));
}
return (0);
@ -650,7 +656,7 @@ fpu_kern_thread(u_int flags)
KASSERT(pcb->pcb_save == &pcb->pcb_user_save, ("mangled pcb_save"));
KASSERT(PCB_USER_FPU(pcb), ("recursive call"));
pcb->pcb_flags |= PCB_KERNFPU;
set_pcb_flags(pcb, PCB_KERNFPU);
return (0);
}

View File

@ -145,23 +145,22 @@ ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
ASSYM(PCB_GDT, offsetof(struct pcb, pcb_gdt));
ASSYM(PCB_IDT, offsetof(struct pcb, pcb_idt));
ASSYM(PCB_LDT, offsetof(struct pcb, pcb_ldt));
ASSYM(PCB_TR, offsetof(struct pcb, pcb_tr));
ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
ASSYM(PCB_GS32SD, offsetof(struct pcb, pcb_gs32sd));
ASSYM(PCB_TSSP, offsetof(struct pcb, pcb_tssp));
ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_save));
ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct savefpu));
ASSYM(PCB_FULL_IRET, offsetof(struct pcb, pcb_full_iret));
ASSYM(PCB_GDT, offsetof(struct pcb, pcb_gdt));
ASSYM(PCB_IDT, offsetof(struct pcb, pcb_idt));
ASSYM(PCB_LDT, offsetof(struct pcb, pcb_ldt));
ASSYM(PCB_TR, offsetof(struct pcb, pcb_tr));
ASSYM(PCB_USERFPU, offsetof(struct pcb, pcb_user_save));
ASSYM(PCB_SIZE, sizeof(struct pcb));
ASSYM(PCB_FULL_IRET, PCB_FULL_IRET);
ASSYM(PCB_DBREGS, PCB_DBREGS);
ASSYM(PCB_32BIT, PCB_32BIT);
ASSYM(PCB_GS32BIT, PCB_GS32BIT);
ASSYM(PCB_FULLCTX, PCB_FULLCTX);
ASSYM(PCB_32BIT, PCB_32BIT);
ASSYM(COMMON_TSS_RSP0, offsetof(struct amd64tss, tss_rsp0));

View File

@ -109,6 +109,8 @@ static int hw_clockrate;
SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
&hw_clockrate, 0, "CPU instruction clock rate");
static eventhandler_tag tsc_post_tag;
static char cpu_brand[48];
static struct {
@ -392,28 +394,6 @@ printcpuinfo(void)
* If this CPU supports P-state invariant TSC then
* mention the capability.
*/
switch (cpu_vendor_id) {
case CPU_VENDOR_AMD:
if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
CPUID_TO_FAMILY(cpu_id) >= 0x10 ||
cpu_id == 0x60fb2)
tsc_is_invariant = 1;
break;
case CPU_VENDOR_INTEL:
if ((amd_pminfo & AMDPM_TSC_INVARIANT) ||
(CPUID_TO_FAMILY(cpu_id) == 0x6 &&
CPUID_TO_MODEL(cpu_id) >= 0xe) ||
(CPUID_TO_FAMILY(cpu_id) == 0xf &&
CPUID_TO_MODEL(cpu_id) >= 0x3))
tsc_is_invariant = 1;
break;
case CPU_VENDOR_CENTAUR:
if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
CPUID_TO_MODEL(cpu_id) >= 0xf &&
(rdmsr(0x1203) & 0x100000000ULL) == 0)
tsc_is_invariant = 1;
break;
}
if (tsc_is_invariant)
printf("\n TSC: P-state invariant");
@ -455,21 +435,29 @@ panicifcpuunsupported(void)
/* Update TSC freq with the value indicated by the caller. */
static void
tsc_freq_changed(void *arg, const struct cf_level *level, int status)
tsc_freq_changed(void *arg __unused, const struct cf_level *level, int status)
{
/*
* If there was an error during the transition or
* TSC is P-state invariant, don't do anything.
*/
if (status != 0 || tsc_is_invariant)
/* If there was an error during the transition, don't do anything. */
if (status != 0)
return;
/* Total setting for this level gives the new frequency in MHz. */
hw_clockrate = level->total_set.freq;
}
EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
EVENTHANDLER_PRI_ANY);
static void
hook_tsc_freq(void *arg __unused)
{
if (tsc_is_invariant)
return;
tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
tsc_freq_changed, NULL, EVENTHANDLER_PRI_ANY);
}
SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
/*
* Final stage of CPU identification.

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <sys/smp.h>
#include <machine/clock.h>
#include <machine/legacyvar.h>
#include <machine/resource.h>
@ -313,9 +314,19 @@ cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
{
struct cpu_device *cpdev;
if (index != CPU_IVAR_PCPU)
switch (index) {
case CPU_IVAR_PCPU:
cpdev = device_get_ivars(child);
*result = (uintptr_t)cpdev->cd_pcpu;
break;
case CPU_IVAR_NOMINAL_MHZ:
if (tsc_is_invariant) {
*result = (uintptr_t)(tsc_freq / 1000000);
break;
}
/* FALLTHROUGH */
default:
return (ENOENT);
cpdev = device_get_ivars(child);
*result = (uintptr_t)cpdev->cd_pcpu;
}
return (0);
}

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include "opt_isa.h"
#include "opt_kstack_pages.h"
#include "opt_maxmem.h"
#include "opt_msgbuf.h"
#include "opt_perfmon.h"
#include "opt_sched.h"
#include "opt_kdtrace.h"
@ -74,7 +73,6 @@ __FBSDID("$FreeBSD$");
#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/memrange.h>
#include <sys/msgbuf.h>
#include <sys/mutex.h>
#include <sys/pcpu.h>
@ -196,8 +194,6 @@ struct pcpu __pcpu[MAXCPU];
struct mtx icu_lock;
struct mem_range_softc mem_range_softc;
struct mtx dt_lock; /* lock for GDT and LDT */
static void
@ -303,6 +299,7 @@ void
sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{
struct sigframe sf, *sfp;
struct pcb *pcb;
struct proc *p;
struct thread *td;
struct sigacts *psp;
@ -312,6 +309,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
int oonstack;
td = curthread;
pcb = td->td_pcb;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
sig = ksi->ksi_signo;
@ -331,8 +329,11 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */
get_fpcontext(td, &sf.sf_uc.uc_mcontext);
fpstate_drop(td);
sf.sf_uc.uc_mcontext.mc_fsbase = td->td_pcb->pcb_fsbase;
sf.sf_uc.uc_mcontext.mc_gsbase = td->td_pcb->pcb_gsbase;
sf.sf_uc.uc_mcontext.mc_fsbase = pcb->pcb_fsbase;
sf.sf_uc.uc_mcontext.mc_gsbase = pcb->pcb_gsbase;
bzero(sf.sf_uc.uc_mcontext.mc_spare,
sizeof(sf.sf_uc.uc_mcontext.mc_spare));
bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__));
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
@ -354,6 +355,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Build the argument list for the signal handler. */
regs->tf_rdi = sig; /* arg 1 in %rdi */
regs->tf_rdx = (register_t)&sfp->sf_uc; /* arg 3 in %rdx */
bzero(&sf.sf_si, sizeof(sf.sf_si));
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */
@ -384,7 +386,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
}
regs->tf_rsp = (long)sfp;
regs->tf_rip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
regs->tf_rip = p->p_sysent->sv_sigcode_base;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucodesel;
regs->tf_ds = _udatasel;
@ -392,7 +394,7 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
@ -416,13 +418,17 @@ sigreturn(td, uap)
} */ *uap;
{
ucontext_t uc;
struct proc *p = td->td_proc;
struct pcb *pcb;
struct proc *p;
struct trapframe *regs;
ucontext_t *ucp;
long rflags;
int cs, error, ret;
ksiginfo_t ksi;
pcb = td->td_pcb;
p = td->td_proc;
error = copyin(uap->sigcntxp, &uc, sizeof(uc));
if (error != 0) {
uprintf("pid %d (%s): sigreturn copyin failed\n",
@ -481,8 +487,8 @@ sigreturn(td, uap)
return (ret);
}
bcopy(&ucp->uc_mcontext.mc_rdi, regs, sizeof(*regs));
td->td_pcb->pcb_fsbase = ucp->uc_mcontext.mc_fsbase;
td->td_pcb->pcb_gsbase = ucp->uc_mcontext.mc_gsbase;
pcb->pcb_fsbase = ucp->uc_mcontext.mc_fsbase;
pcb->pcb_gsbase = ucp->uc_mcontext.mc_gsbase;
#if defined(COMPAT_43)
if (ucp->uc_mcontext.mc_onstack & 1)
@ -492,8 +498,7 @@ sigreturn(td, uap)
#endif
kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
td->td_pcb->pcb_flags |= PCB_FULLCTX;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
@ -538,6 +543,10 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate)
if (pcpu_find(cpu_id) == NULL || rate == NULL)
return (EINVAL);
/* If TSC is P-state invariant, DELAY(9) based logic fails. */
if (tsc_is_invariant)
return (EOPNOTSUPP);
/* If we're booting, trust the rate calibrated moments ago. */
if (cold) {
*rate = tsc_freq;
@ -564,13 +573,7 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate)
thread_unlock(curthread);
#endif
/*
* Calculate the difference in readings, convert to Mhz, and
* subtract 0.5% of the total. Empirical testing has shown that
* overhead in DELAY() works out to approximately this value.
*/
tsc2 -= tsc1;
*rate = tsc2 * 1000 - tsc2 * 5;
*rate = (tsc2 - tsc1) * 1000;
return (0);
}
@ -860,9 +863,9 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
pcb->pcb_fsbase = 0;
pcb->pcb_gsbase = 0;
pcb->pcb_flags &= ~(PCB_32BIT | PCB_GS32BIT);
clear_pcb_flags(pcb, PCB_32BIT | PCB_GS32BIT);
pcb->pcb_initial_fpucw = __INITIAL_FPUCW__;
pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_rip = imgp->entry_addr;
@ -876,6 +879,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
td->td_retval[1] = 0;
/*
* Reset the hardware debug registers if they were in use.
@ -896,7 +900,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
*/
reset_dbregs();
}
pcb->pcb_flags &= ~PCB_DBREGS;
clear_pcb_flags(pcb, PCB_DBREGS);
}
/*
@ -1503,7 +1507,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
* calculation, etc.).
*/
while (phys_avail[pa_indx - 1] + PAGE_SIZE +
round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
round_page(msgbufsize) >= phys_avail[pa_indx]) {
physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
phys_avail[pa_indx--] = 0;
phys_avail[pa_indx--] = 0;
@ -1512,7 +1516,7 @@ getmemsize(caddr_t kmdp, u_int64_t first)
Maxmem = atop(phys_avail[pa_indx]);
/* Trim off space for the message buffer. */
phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
phys_avail[pa_indx] -= round_page(msgbufsize);
/* Map the message buffer. */
msgbufp = (struct msgbuf *)PHYS_TO_DMAP(phys_avail[pa_indx]);
@ -1527,12 +1531,14 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
struct nmi_pcpu *np;
u_int64_t msr;
char *env;
size_t kstack0_sz;
thread0.td_kstack = physfree + KERNBASE;
bzero((void *)thread0.td_kstack, KSTACK_PAGES * PAGE_SIZE);
physfree += KSTACK_PAGES * PAGE_SIZE;
thread0.td_pcb = (struct pcb *)
(thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
thread0.td_kstack_pages = KSTACK_PAGES;
kstack0_sz = thread0.td_kstack_pages * PAGE_SIZE;
bzero((void *)thread0.td_kstack, kstack0_sz);
physfree += kstack0_sz;
thread0.td_pcb = (struct pcb *)(thread0.td_kstack + kstack0_sz) - 1;
/*
* This may be done better later if it gets more high level
@ -1674,8 +1680,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
initializecpucache();
/* make an initial tss so cpu can get interrupt stack on syscall! */
common_tss[0].tss_rsp0 = thread0.td_kstack + \
KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb);
common_tss[0].tss_rsp0 = thread0.td_kstack +
kstack0_sz - sizeof(struct pcb);
/* Ensure the stack is aligned to 16 bytes */
common_tss[0].tss_rsp0 &= ~0xFul;
PCPU_SET(rsp0, common_tss[0].tss_rsp0);
@ -1713,7 +1719,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
/* now running on new page tables, configured,and u/iom is accessible */
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
fpuinit();
/* transfer to user mode */
@ -1836,6 +1842,12 @@ fill_regs(struct thread *td, struct reg *regs)
struct trapframe *tp;
tp = td->td_frame;
return (fill_frame_regs(tp, regs));
}
int
fill_frame_regs(struct trapframe *tp, struct reg *regs)
{
regs->r_r15 = tp->tf_r15;
regs->r_r14 = tp->tf_r14;
regs->r_r13 = tp->tf_r13;
@ -1906,8 +1918,8 @@ set_regs(struct thread *td, struct reg *regs)
tp->tf_fs = regs->r_fs;
tp->tf_gs = regs->r_gs;
tp->tf_flags = TF_HASSEGS;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
}
td->td_pcb->pcb_flags |= PCB_FULLCTX;
return (0);
}
@ -1998,8 +2010,10 @@ set_fpregs(struct thread *td, struct fpreg *fpregs)
int
get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
{
struct pcb *pcb;
struct trapframe *tp;
pcb = td->td_pcb;
tp = td->td_frame;
PROC_LOCK(curthread->td_proc);
mcp->mc_onstack = sigonstack(tp->tf_rsp);
@ -2037,8 +2051,9 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
mcp->mc_flags = tp->tf_flags;
mcp->mc_len = sizeof(*mcp);
get_fpcontext(td, mcp);
mcp->mc_fsbase = td->td_pcb->pcb_fsbase;
mcp->mc_gsbase = td->td_pcb->pcb_gsbase;
mcp->mc_fsbase = pcb->pcb_fsbase;
mcp->mc_gsbase = pcb->pcb_gsbase;
bzero(mcp->mc_spare, sizeof(mcp->mc_spare));
return (0);
}
@ -2051,10 +2066,12 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int flags)
int
set_mcontext(struct thread *td, const mcontext_t *mcp)
{
struct pcb *pcb;
struct trapframe *tp;
long rflags;
int ret;
pcb = td->td_pcb;
tp = td->td_frame;
if (mcp->mc_len != sizeof(*mcp) ||
(mcp->mc_flags & ~_MC_FLAG_MASK) != 0)
@ -2091,11 +2108,10 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
tp->tf_gs = mcp->mc_gs;
}
if (mcp->mc_flags & _MC_HASBASES) {
td->td_pcb->pcb_fsbase = mcp->mc_fsbase;
td->td_pcb->pcb_gsbase = mcp->mc_gsbase;
pcb->pcb_fsbase = mcp->mc_fsbase;
pcb->pcb_gsbase = mcp->mc_gsbase;
}
td->td_pcb->pcb_flags |= PCB_FULLCTX;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
return (0);
}
@ -2149,8 +2165,8 @@ fpstate_drop(struct thread *td)
* sendsig() is the only caller of fpugetuserregs()... perhaps we just
* have too many layers.
*/
curthread->td_pcb->pcb_flags &= ~(PCB_FPUINITDONE |
PCB_USERFPUINITDONE);
clear_pcb_flags(curthread->td_pcb,
PCB_FPUINITDONE | PCB_USERFPUINITDONE);
critical_exit();
}
@ -2264,7 +2280,7 @@ set_dbregs(struct thread *td, struct dbreg *dbregs)
pcb->pcb_dr6 = dbregs->dr[6];
pcb->pcb_dr7 = dbregs->dr[7];
pcb->pcb_flags |= PCB_DBREGS;
set_pcb_flags(pcb, PCB_DBREGS);
}
return (0);

View File

@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
*/
MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
struct mem_range_softc mem_range_softc;
/* ARGSUSED */
int
memrw(struct cdev *dev, struct uio *uio, int flags)
@ -214,10 +216,3 @@ memioctl(struct cdev *dev __unused, u_long cmd, caddr_t data, int flags,
}
return (error);
}
void
dev_mem_md_init(void)
{
if (mem_range_softc.mr_op != NULL)
mem_range_softc.mr_op->init(&mem_range_softc);
}

View File

@ -1045,23 +1045,23 @@ u_int ipi_global;
u_int ipi_page;
u_int ipi_range;
u_int ipi_range_size;
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, &ipi_global, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, &ipi_page, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, &ipi_range, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW, &ipi_range_size,
0, "");
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_global, CTLFLAG_RW, &ipi_global, 0, "");
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_page, CTLFLAG_RW, &ipi_page, 0, "");
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range, CTLFLAG_RW, &ipi_range, 0, "");
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_range_size, CTLFLAG_RW,
&ipi_range_size, 0, "");
u_int ipi_masked_global;
u_int ipi_masked_page;
u_int ipi_masked_range;
u_int ipi_masked_range_size;
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_global, CTLFLAG_RW,
&ipi_masked_global, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_page, CTLFLAG_RW,
&ipi_masked_page, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range, CTLFLAG_RW,
&ipi_masked_range, 0, "");
SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW,
&ipi_masked_range_size, 0, "");
#endif /* COUNT_XINVLTLB_HITS */

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
@ -58,9 +59,24 @@ __FBSDID("$FreeBSD$");
#include <security/audit/audit.h>
#define MAX_LD 8192
int max_ldt_segment = 1024;
#define LD_PER_PAGE 512
#define NULL_LDT_BASE ((caddr_t)NULL)
SYSCTL_INT(_machdep, OID_AUTO, max_ldt_segment, CTLFLAG_RDTUN,
&max_ldt_segment, 0,
"Maximum number of allowed LDT segments in the single address space");
static void
max_ldt_segment_init(void *arg __unused)
{
TUNABLE_INT_FETCH("machdep.max_ldt_segment", &max_ldt_segment);
if (max_ldt_segment <= 0)
max_ldt_segment = 1;
if (max_ldt_segment > MAX_LD)
max_ldt_segment = MAX_LD;
}
SYSINIT(maxldt, SI_SUB_VM_CONF, SI_ORDER_ANY, max_ldt_segment_init, NULL);
#ifdef notyet
#ifdef SMP
@ -95,29 +111,23 @@ sysarch_ldt(struct thread *td, struct sysarch_args *uap, int uap_space)
largs = &la;
} else
largs = (struct i386_ldt_args *)uap->parms;
if (largs->num > max_ldt_segment || largs->num <= 0)
return (EINVAL);
switch (uap->op) {
case I386_GET_LDT:
error = amd64_get_ldt(td, largs);
break;
case I386_SET_LDT:
td->td_pcb->pcb_full_iret = 1;
if (largs->descs != NULL && largs->num > max_ldt_segment)
return (EINVAL);
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
if (largs->descs != NULL) {
lp = (struct user_segment_descriptor *)
kmem_alloc(kernel_map, largs->num *
sizeof(struct user_segment_descriptor));
if (lp == NULL) {
error = ENOMEM;
break;
}
lp = malloc(largs->num * sizeof(struct
user_segment_descriptor), M_TEMP, M_WAITOK);
error = copyin(largs->descs, lp, largs->num *
sizeof(struct user_segment_descriptor));
if (error == 0)
error = amd64_set_ldt(td, largs, lp);
kmem_free(kernel_map, (vm_offset_t)lp, largs->num *
sizeof(struct user_segment_descriptor));
free(lp, M_TEMP);
} else {
error = amd64_set_ldt(td, largs, NULL);
}
@ -133,7 +143,7 @@ update_gdt_gsbase(struct thread *td, uint32_t base)
if (td != curthread)
return;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
critical_enter();
sd = PCPU_GET(gs32p);
sd->sd_lobase = base & 0xffffff;
@ -148,7 +158,7 @@ update_gdt_fsbase(struct thread *td, uint32_t base)
if (td != curthread)
return;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
critical_enter();
sd = PCPU_GET(fs32p);
sd->sd_lobase = base & 0xffffff;
@ -204,7 +214,7 @@ sysarch(td, uap)
if (!error) {
pcb->pcb_fsbase = i386base;
td->td_frame->tf_fs = _ufssel;
pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
update_gdt_fsbase(td, i386base);
}
break;
@ -216,7 +226,7 @@ sysarch(td, uap)
error = copyin(uap->parms, &i386base, sizeof(i386base));
if (!error) {
pcb->pcb_gsbase = i386base;
pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
td->td_frame->tf_gs = _ugssel;
update_gdt_gsbase(td, i386base);
}
@ -230,7 +240,7 @@ sysarch(td, uap)
if (!error) {
if (a64base < VM_MAXUSER_ADDRESS) {
pcb->pcb_fsbase = a64base;
pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
td->td_frame->tf_fs = _ufssel;
} else
error = EINVAL;
@ -246,7 +256,7 @@ sysarch(td, uap)
if (!error) {
if (a64base < VM_MAXUSER_ADDRESS) {
pcb->pcb_gsbase = a64base;
pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
td->td_frame->tf_gs = _ugssel;
} else
error = EINVAL;
@ -533,13 +543,13 @@ amd64_set_ldt(td, uap, descs)
uap->start, uap->num, (void *)uap->descs);
#endif
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
p = td->td_proc;
if (descs == NULL) {
/* Free descriptors */
if (uap->start == 0 && uap->num == 0)
uap->num = max_ldt_segment;
if (uap->num <= 0)
if (uap->num == 0)
return (EINVAL);
if ((pldt = mdp->md_ldt) == NULL ||
uap->start >= max_ldt_segment)
@ -559,7 +569,7 @@ amd64_set_ldt(td, uap, descs)
/* verify range of descriptors to modify */
largest_ld = uap->start + uap->num;
if (uap->start >= max_ldt_segment ||
uap->num < 0 || largest_ld > max_ldt_segment)
largest_ld > max_ldt_segment)
return (EINVAL);
}

View File

@ -249,38 +249,8 @@ trap(struct trapframe *frame)
if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
type == T_BPTFLT) {
struct reg regs;
regs.r_r15 = frame->tf_r15;
regs.r_r14 = frame->tf_r14;
regs.r_r13 = frame->tf_r13;
regs.r_r12 = frame->tf_r12;
regs.r_r11 = frame->tf_r11;
regs.r_r10 = frame->tf_r10;
regs.r_r9 = frame->tf_r9;
regs.r_r8 = frame->tf_r8;
regs.r_rdi = frame->tf_rdi;
regs.r_rsi = frame->tf_rsi;
regs.r_rbp = frame->tf_rbp;
regs.r_rbx = frame->tf_rbx;
regs.r_rdx = frame->tf_rdx;
regs.r_rcx = frame->tf_rcx;
regs.r_rax = frame->tf_rax;
regs.r_rip = frame->tf_rip;
regs.r_cs = frame->tf_cs;
regs.r_rflags = frame->tf_rflags;
regs.r_rsp = frame->tf_rsp;
regs.r_ss = frame->tf_ss;
if (frame->tf_flags & TF_HASSEGS) {
regs.r_ds = frame->tf_ds;
regs.r_es = frame->tf_es;
regs.r_fs = frame->tf_fs;
regs.r_gs = frame->tf_gs;
} else {
regs.r_ds = 0;
regs.r_es = 0;
regs.r_fs = 0;
regs.r_gs = 0;
}
fill_frame_regs(frame, &regs);
if (type == T_DTRACE_PROBE &&
dtrace_fasttrap_probe_ptr != NULL &&
dtrace_fasttrap_probe_ptr(&regs) == 0)

View File

@ -1,234 +0,0 @@
/*-
* Copyright (c) 1998-2003 Poul-Henning Kamp
* 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_clock.h"
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/malloc.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/timetc.h>
#include <sys/kernel.h>
#include <sys/power.h>
#include <sys/smp.h>
#include <machine/clock.h>
#include <machine/md_var.h>
#include <machine/specialreg.h>
#include "cpufreq_if.h"
uint64_t tsc_freq;
int tsc_is_broken;
int tsc_is_invariant;
static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag;
SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN,
&tsc_is_invariant, 0, "Indicates whether the TSC is P-state invariant");
TUNABLE_INT("kern.timecounter.invariant_tsc", &tsc_is_invariant);
#ifdef SMP
static int smp_tsc;
SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc, CTLFLAG_RDTUN, &smp_tsc, 0,
"Indicates whether the TSC is safe to use in SMP mode");
TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc);
#endif
static void tsc_freq_changed(void *arg, const struct cf_level *level,
int status);
static void tsc_freq_changing(void *arg, const struct cf_level *level,
int *status);
static unsigned tsc_get_timecount(struct timecounter *tc);
static void tsc_levels_changed(void *arg, int unit);
static struct timecounter tsc_timecounter = {
tsc_get_timecount, /* get_timecount */
0, /* no poll_pps */
~0u, /* counter_mask */
0, /* frequency */
"TSC", /* name */
800, /* quality (adjusted in code) */
};
void
init_TSC(void)
{
u_int64_t tscval[2];
if (bootverbose)
printf("Calibrating TSC clock ... ");
tscval[0] = rdtsc();
DELAY(1000000);
tscval[1] = rdtsc();
tsc_freq = tscval[1] - tscval[0];
if (bootverbose)
printf("TSC clock: %lu Hz\n", tsc_freq);
/*
* Inform CPU accounting about our boot-time clock rate. Once the
* system is finished booting, we will get the real max clock rate
* via tsc_freq_max(). This also will be updated if someone loads
* a cpufreq driver after boot that discovers a new max frequency.
*/
set_cputicker(rdtsc, tsc_freq, 1);
/* Register to find out about changes in CPU frequency. */
tsc_pre_tag = EVENTHANDLER_REGISTER(cpufreq_pre_change,
tsc_freq_changing, NULL, EVENTHANDLER_PRI_FIRST);
tsc_post_tag = EVENTHANDLER_REGISTER(cpufreq_post_change,
tsc_freq_changed, NULL, EVENTHANDLER_PRI_FIRST);
tsc_levels_tag = EVENTHANDLER_REGISTER(cpufreq_levels_changed,
tsc_levels_changed, NULL, EVENTHANDLER_PRI_ANY);
}
void
init_TSC_tc(void)
{
#ifdef SMP
/*
* We can not use the TSC in SMP mode unless the TSCs on all CPUs
* are somehow synchronized. Some hardware configurations do
* this, but we have no way of determining whether this is the
* case, so we do not use the TSC in multi-processor systems
* unless the user indicated (by setting kern.timecounter.smp_tsc
* to 1) that he believes that his TSCs are synchronized.
*/
if (mp_ncpus > 1 && !smp_tsc)
tsc_timecounter.tc_quality = -100;
#endif
if (tsc_freq != 0 && !tsc_is_broken) {
tsc_timecounter.tc_frequency = tsc_freq;
tc_init(&tsc_timecounter);
}
}
/*
* When cpufreq levels change, find out about the (new) max frequency. We
* use this to update CPU accounting in case it got a lower estimate at boot.
*/
static void
tsc_levels_changed(void *arg, int unit)
{
device_t cf_dev;
struct cf_level *levels;
int count, error;
uint64_t max_freq;
if (tsc_is_invariant)
return;
/* Only use values from the first CPU, assuming all are equal. */
if (unit != 0)
return;
/* Find the appropriate cpufreq device instance. */
cf_dev = devclass_get_device(devclass_find("cpufreq"), unit);
if (cf_dev == NULL) {
printf("tsc_levels_changed() called but no cpufreq device?\n");
return;
}
/* Get settings from the device and find the max frequency. */
count = 64;
levels = malloc(count * sizeof(*levels), M_TEMP, M_NOWAIT);
if (levels == NULL)
return;
error = CPUFREQ_LEVELS(cf_dev, levels, &count);
if (error == 0 && count != 0) {
max_freq = (uint64_t)levels[0].total_set.freq * 1000000;
set_cputicker(rdtsc, max_freq, 1);
} else
printf("tsc_levels_changed: no max freq found\n");
free(levels, M_TEMP);
}
/*
* If the TSC timecounter is in use, veto the pending change. It may be
* possible in the future to handle a dynamically-changing timecounter rate.
*/
static void
tsc_freq_changing(void *arg, const struct cf_level *level, int *status)
{
if (*status != 0 || timecounter != &tsc_timecounter ||
tsc_is_invariant)
return;
printf("timecounter TSC must not be in use when "
"changing frequencies; change denied\n");
*status = EBUSY;
}
/* Update TSC freq with the value indicated by the caller. */
static void
tsc_freq_changed(void *arg, const struct cf_level *level, int status)
{
/*
* If there was an error during the transition or
* TSC is P-state invariant, don't do anything.
*/
if (status != 0 || tsc_is_invariant)
return;
/* Total setting for this level gives the new frequency in MHz. */
tsc_freq = (uint64_t)level->total_set.freq * 1000000;
tsc_timecounter.tc_frequency = tsc_freq;
}
static int
sysctl_machdep_tsc_freq(SYSCTL_HANDLER_ARGS)
{
int error;
uint64_t freq;
if (tsc_timecounter.tc_frequency == 0)
return (EOPNOTSUPP);
freq = tsc_freq;
error = sysctl_handle_quad(oidp, &freq, 0, req);
if (error == 0 && req->newptr != NULL) {
tsc_freq = freq;
tsc_timecounter.tc_frequency = tsc_freq;
}
return (error);
}
SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_QUAD | CTLFLAG_RW,
0, 0, sysctl_machdep_tsc_freq, "QU", "");
static unsigned
tsc_get_timecount(struct timecounter *tc)
{
return (rdtsc());
}

View File

@ -88,8 +88,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
page_offset;
switch (uio->uio_segflg) {
case UIO_USERSPACE:
if (ticks - PCPU_GET(switchticks) >= hogticks)
uio_yield();
maybe_yield();
if (uio->uio_rw == UIO_READ)
error = copyout(cp, iov->iov_base, cnt);
else

View File

@ -190,7 +190,7 @@ cpu_fork(td1, p2, td2, flags)
pcb2->pcb_tssp = NULL;
/* New segment registers. */
pcb2->pcb_full_iret = 1;
set_pcb_flags(pcb2, PCB_FULL_IRET);
/* Copy the LDT, if necessary. */
mdp1 = &td1->td_proc->p_md;
@ -275,7 +275,7 @@ cpu_thread_exit(struct thread *td)
/* Disable any hardware breakpoints. */
if (pcb->pcb_flags & PCB_DBREGS) {
reset_dbregs();
pcb->pcb_flags &= ~PCB_DBREGS;
clear_pcb_flags(pcb, PCB_DBREGS);
}
}
@ -339,15 +339,13 @@ cpu_set_syscall_retval(struct thread *td, int error)
* Reconstruct pc, we know that 'syscall' is 2 bytes,
* lcall $X,y is 7 bytes, int 0x80 is 2 bytes.
* We saved this in tf_err.
* We have to do a full context restore so that %r10
* (which was holding the value of %rcx) is restored
* %r10 (which was holding the value of %rcx) is restored
* for the next iteration.
* r10 restore is only required for freebsd/amd64 processes,
* %r10 restore is only required for freebsd/amd64 processes,
* but shall be innocent for any ia32 ABI.
*/
td->td_frame->tf_rip -= td->td_frame->tf_err;
td->td_frame->tf_r10 = td->td_frame->tf_rcx;
td->td_pcb->pcb_flags |= PCB_FULLCTX;
break;
case EJUSTRETURN:
@ -387,9 +385,9 @@ cpu_set_upcall(struct thread *td, struct thread *td0)
* values here.
*/
bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
pcb2->pcb_flags &= ~(PCB_FPUINITDONE | PCB_USERFPUINITDONE);
clear_pcb_flags(pcb2, PCB_FPUINITDONE | PCB_USERFPUINITDONE);
pcb2->pcb_save = &pcb2->pcb_user_save;
pcb2->pcb_full_iret = 1;
set_pcb_flags(pcb2, PCB_FULL_IRET);
/*
* Create a new fresh stack for the new thread.
@ -447,7 +445,7 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
cpu_thread_clean(td);
#ifdef COMPAT_FREEBSD32
if (td->td_proc->p_sysent->sv_flags & SV_ILP32) {
if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
/*
* Set the trap frame to point at the beginning of the uts
* function.
@ -493,18 +491,20 @@ cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
int
cpu_set_user_tls(struct thread *td, void *tls_base)
{
struct pcb *pcb;
if ((u_int64_t)tls_base >= VM_MAXUSER_ADDRESS)
return (EINVAL);
pcb = td->td_pcb;
#ifdef COMPAT_FREEBSD32
if (td->td_proc->p_sysent->sv_flags & SV_ILP32) {
td->td_pcb->pcb_gsbase = (register_t)tls_base;
if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
pcb->pcb_gsbase = (register_t)tls_base;
return (0);
}
#endif
td->td_pcb->pcb_fsbase = (register_t)tls_base;
td->td_pcb->pcb_full_iret = 1;
pcb->pcb_fsbase = (register_t)tls_base;
set_pcb_flags(pcb, PCB_FULL_IRET);
return (0);
}

View File

@ -1,152 +1,24 @@
#
# XENHVM -- Xen HVM kernel configuration file for FreeBSD/amd64
#
# For more information on this file, please read the config(5) manual page,
# and/or the handbook section on Kernel Configuration Files:
#
# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
#
# The handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
# latest information.
#
# An exhaustive list of options and more detailed explanations of the
# device lines is also present in the ../../conf/NOTES and NOTES files.
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
# $FreeBSD$
cpu HAMMER
#
include GENERIC
ident XENHVM
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
makeoptions MODULES_OVERRIDE=""
options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
options INET # InterNETworking
options INET6 # IPv6 communications protocols
options SCTP # Stream Control Transmission Protocol
options FFS # Berkeley Fast Filesystem
options SOFTUPDATES # Enable FFS soft updates support
options UFS_ACL # Support for access control lists
options UFS_DIRHASH # Improve performance on big directories
options UFS_GJOURNAL # Enable gjournal-based UFS journaling
options MD_ROOT # MD is a potential root device
options NFSCLIENT # Network Filesystem Client
options NFSSERVER # Network Filesystem Server
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCLIENT
options MSDOSFS # MSDOS Filesystem
options CD9660 # ISO 9660 Filesystem
options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
options GEOM_PART_GPT # GUID Partition Tables.
options GEOM_LABEL # Provides labelization
options COMPAT_FREEBSD32 # Compatible with i386 binaries
options COMPAT_FREEBSD4 # Compatible with FreeBSD4
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
options COMPAT_FREEBSD6 # Compatible with FreeBSD6
options COMPAT_FREEBSD7 # Compatible with FreeBSD7
options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
options KTRACE # ktrace(1) support
options STACK # stack(9) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4)
options AUDIT # Security event auditing
#options KDTRACE_FRAME # Ensure frames are compiled in
#options KDTRACE_HOOKS # Kernel DTrace hooks
#
# Adaptive locks rely on a lock-free pointer read to determine the run state
# of the thread holding a lock when under contention; under a virtualisation
# system, the thread run state may not accurately reflect whether the thread
# (or rather its host VCPU) is actually executing. As such, disable this
# optimisation.
#
options NO_ADAPTIVE_MUTEXES
options NO_ADAPTIVE_RWLOCKS
# Debugging for use in -current
options KDB # Enable kernel debugger support.
options DDB # Support DDB.
options GDB # Support remote GDB.
options DEADLKRES # Enable the deadlock resolver
options INVARIANTS # Enable calls of extra sanity checking
options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
options WITNESS # Enable checks to detect deadlocks and cycles
options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
# Make an SMP-capable kernel by default
options SMP # Symmetric MultiProcessor Kernel
# CPU frequency control
device cpufreq
# Bus support.
device acpi
device pci
# Floppy drives
device fdc
options NO_ADAPTIVE_SX
# Xen HVM support
options XENHVM
device xenpci
# ATA and ATAPI devices
device ata
device atadisk # ATA disk drives
device ataraid # ATA RAID drives
device atapicd # ATAPI CDROM drives
device atapifd # ATAPI floppy drives
device atapist # ATAPI tape drives
options ATA_STATIC_ID # Static device numbering
# SCSI peripherals
device scbus # SCSI bus (required for SCSI)
device ch # SCSI media changers
device da # Direct Access (disks)
device sa # Sequential Access (tape etc)
device cd # CD
device pass # Passthrough device (direct SCSI access)
device ses # SCSI Environmental Services (and SAF-TE)
# atkbdc0 controls both the keyboard and the PS/2 mouse
device atkbdc # AT keyboard controller
device atkbd # AT keyboard
device psm # PS/2 mouse
device kbdmux # keyboard multiplexer
device vga # VGA video card driver
device splash # Splash screen and screen saver support
# syscons is the default console driver, resembling an SCO console
device sc
device agp # support several AGP chipsets
# Serial (COM) ports
device uart # Generic UART driver
# PCI Ethernet NICs that use the common MII bus controller code.
# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
device miibus # MII bus support
device re # RealTek 8139C+/8169/8169S/8110S
# Pseudo devices.
device loop # Network loopback
device random # Entropy device
device ether # Ethernet support
device tun # Packet tunnel.
device pty # BSD-style compatibility pseudo ttys
device md # Memory "disks"
device gif # IPv6 and IPv4 tunneling
device faith # IPv6-to-IPv4 relaying (translation)
device firmware # firmware assist module
# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
device bpf # Berkeley packet filter

View File

@ -125,7 +125,7 @@ set_regs32(struct thread *td, struct reg32 *regs)
tp->tf_fs = regs->r_fs;
tp->tf_es = regs->r_es;
tp->tf_ds = regs->r_ds;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_FULL_IRET);
tp->tf_flags = TF_HASSEGS;
tp->tf_rdi = regs->r_edi;
tp->tf_rsi = regs->r_esi;

View File

@ -130,8 +130,10 @@ ia32_set_fpcontext(struct thread *td, const struct ia32_mcontext *mcp)
static int
ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
{
struct pcb *pcb;
struct trapframe *tp;
pcb = td->td_pcb;
tp = td->td_frame;
PROC_LOCK(curthread->td_proc);
@ -163,9 +165,11 @@ ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
mcp->mc_ss = tp->tf_ss;
mcp->mc_len = sizeof(*mcp);
ia32_get_fpcontext(td, mcp);
mcp->mc_fsbase = td->td_pcb->pcb_fsbase;
mcp->mc_gsbase = td->td_pcb->pcb_gsbase;
td->td_pcb->pcb_full_iret = 1;
mcp->mc_fsbase = pcb->pcb_fsbase;
mcp->mc_gsbase = pcb->pcb_gsbase;
bzero(mcp->mc_spare1, sizeof(mcp->mc_spare1));
bzero(mcp->mc_spare2, sizeof(mcp->mc_spare2));
set_pcb_flags(pcb, PCB_FULL_IRET);
return (0);
}
@ -207,8 +211,7 @@ ia32_set_mcontext(struct thread *td, const struct ia32_mcontext *mcp)
tp->tf_rflags = rflags;
tp->tf_rsp = mcp->mc_esp;
tp->tf_ss = mcp->mc_ss;
td->td_pcb->pcb_flags |= PCB_FULLCTX;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (0);
}
@ -232,6 +235,7 @@ freebsd32_getcontext(struct thread *td, struct freebsd32_getcontext_args *uap)
PROC_LOCK(td->td_proc);
uc.uc_sigmask = td->td_sigmask;
PROC_UNLOCK(td->td_proc);
bzero(&uc.__spare__, sizeof(uc.__spare__));
ret = copyout(&uc, uap->ucp, UC_COPY_SIZE);
}
return (ret);
@ -347,6 +351,11 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
sf.sf_uc.uc_mcontext.mc_es = regs->tf_es;
sf.sf_uc.uc_mcontext.mc_fs = regs->tf_fs;
sf.sf_uc.uc_mcontext.mc_gs = regs->tf_gs;
bzero(sf.sf_uc.uc_mcontext.mc_fpregs,
sizeof(sf.sf_uc.uc_mcontext.mc_fpregs));
bzero(sf.sf_uc.uc_mcontext.__spare__,
sizeof(sf.sf_uc.uc_mcontext.__spare__));
bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__));
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
@ -364,6 +373,7 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Build the argument list for the signal handler. */
sf.sf_signum = sig;
sf.sf_ucontext = (register_t)&sfp->sf_uc;
bzero(&sf.sf_si, sizeof(sf.sf_si));
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
sf.sf_siginfo = (u_int32_t)(uintptr_t)&sfp->sf_si;
@ -392,13 +402,14 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
}
regs->tf_rsp = (uintptr_t)sfp;
regs->tf_rip = p->p_sysent->sv_psstrings - sz_freebsd4_ia32_sigcode;
regs->tf_rip = p->p_sysent->sv_sigcode_base + sz_ia32_sigcode -
sz_freebsd4_ia32_sigcode;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/* leave user %fs and %gs untouched */
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
@ -466,6 +477,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
fpstate_drop(td);
sf.sf_uc.uc_mcontext.mc_fsbase = td->td_pcb->pcb_fsbase;
sf.sf_uc.uc_mcontext.mc_gsbase = td->td_pcb->pcb_gsbase;
bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__));
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
@ -485,6 +497,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Build the argument list for the signal handler. */
sf.sf_signum = sig;
sf.sf_ucontext = (register_t)&sfp->sf_uc;
bzero(&sf.sf_si, sizeof(sf.sf_si));
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
sf.sf_siginfo = (u_int32_t)(uintptr_t)&sfp->sf_si;
@ -513,13 +526,13 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
}
regs->tf_rsp = (uintptr_t)sfp;
regs->tf_rip = p->p_sysent->sv_psstrings - *(p->p_sysent->sv_szsigcode);
regs->tf_rip = p->p_sysent->sv_sigcode_base;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/* XXXKIB leave user %fs and %gs untouched */
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
@ -614,7 +627,7 @@ freebsd4_freebsd32_sigreturn(td, uap)
regs->tf_gs = ucp->uc_mcontext.mc_gs;
kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
#endif /* COMPAT_FREEBSD4 */
@ -703,7 +716,7 @@ freebsd32_sigreturn(td, uap)
regs->tf_flags = TF_HASSEGS;
kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
@ -739,12 +752,10 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
load_cr0(rcr0() | CR0_MP | CR0_TS);
fpstate_drop(td);
/* Return via doreti so that we can change to a different %cs */
pcb->pcb_flags |= PCB_FULLCTX | PCB_32BIT;
pcb->pcb_flags &= ~PCB_GS32BIT;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
clear_pcb_flags(pcb, PCB_GS32BIT);
td->td_retval[1] = 0;
}

View File

@ -1,213 +1,6 @@
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*
* From: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
* $FreeBSD$
* This file is in the public domain.
*/
/* $FreeBSD$ */
#ifndef _MACHINE_INTTYPES_H_
#define _MACHINE_INTTYPES_H_
/*
* Macros for format specifiers.
*/
/* fprintf(3) macros for signed integers. */
#define PRId8 "d" /* int8_t */
#define PRId16 "d" /* int16_t */
#define PRId32 "d" /* int32_t */
#define PRId64 "ld" /* int64_t */
#define PRIdLEAST8 "d" /* int_least8_t */
#define PRIdLEAST16 "d" /* int_least16_t */
#define PRIdLEAST32 "d" /* int_least32_t */
#define PRIdLEAST64 "ld" /* int_least64_t */
#define PRIdFAST8 "d" /* int_fast8_t */
#define PRIdFAST16 "d" /* int_fast16_t */
#define PRIdFAST32 "d" /* int_fast32_t */
#define PRIdFAST64 "ld" /* int_fast64_t */
#define PRIdMAX "jd" /* intmax_t */
#define PRIdPTR "ld" /* intptr_t */
#define PRIi8 "i" /* int8_t */
#define PRIi16 "i" /* int16_t */
#define PRIi32 "i" /* int32_t */
#define PRIi64 "li" /* int64_t */
#define PRIiLEAST8 "i" /* int_least8_t */
#define PRIiLEAST16 "i" /* int_least16_t */
#define PRIiLEAST32 "i" /* int_least32_t */
#define PRIiLEAST64 "li" /* int_least64_t */
#define PRIiFAST8 "i" /* int_fast8_t */
#define PRIiFAST16 "i" /* int_fast16_t */
#define PRIiFAST32 "i" /* int_fast32_t */
#define PRIiFAST64 "li" /* int_fast64_t */
#define PRIiMAX "ji" /* intmax_t */
#define PRIiPTR "li" /* intptr_t */
/* fprintf(3) macros for unsigned integers. */
#define PRIo8 "o" /* uint8_t */
#define PRIo16 "o" /* uint16_t */
#define PRIo32 "o" /* uint32_t */
#define PRIo64 "lo" /* uint64_t */
#define PRIoLEAST8 "o" /* uint_least8_t */
#define PRIoLEAST16 "o" /* uint_least16_t */
#define PRIoLEAST32 "o" /* uint_least32_t */
#define PRIoLEAST64 "lo" /* uint_least64_t */
#define PRIoFAST8 "o" /* uint_fast8_t */
#define PRIoFAST16 "o" /* uint_fast16_t */
#define PRIoFAST32 "o" /* uint_fast32_t */
#define PRIoFAST64 "lo" /* uint_fast64_t */
#define PRIoMAX "jo" /* uintmax_t */
#define PRIoPTR "lo" /* uintptr_t */
#define PRIu8 "u" /* uint8_t */
#define PRIu16 "u" /* uint16_t */
#define PRIu32 "u" /* uint32_t */
#define PRIu64 "lu" /* uint64_t */
#define PRIuLEAST8 "u" /* uint_least8_t */
#define PRIuLEAST16 "u" /* uint_least16_t */
#define PRIuLEAST32 "u" /* uint_least32_t */
#define PRIuLEAST64 "lu" /* uint_least64_t */
#define PRIuFAST8 "u" /* uint_fast8_t */
#define PRIuFAST16 "u" /* uint_fast16_t */
#define PRIuFAST32 "u" /* uint_fast32_t */
#define PRIuFAST64 "lu" /* uint_fast64_t */
#define PRIuMAX "ju" /* uintmax_t */
#define PRIuPTR "lu" /* uintptr_t */
#define PRIx8 "x" /* uint8_t */
#define PRIx16 "x" /* uint16_t */
#define PRIx32 "x" /* uint32_t */
#define PRIx64 "lx" /* uint64_t */
#define PRIxLEAST8 "x" /* uint_least8_t */
#define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "x" /* uint_least32_t */
#define PRIxLEAST64 "lx" /* uint_least64_t */
#define PRIxFAST8 "x" /* uint_fast8_t */
#define PRIxFAST16 "x" /* uint_fast16_t */
#define PRIxFAST32 "x" /* uint_fast32_t */
#define PRIxFAST64 "lx" /* uint_fast64_t */
#define PRIxMAX "jx" /* uintmax_t */
#define PRIxPTR "lx" /* uintptr_t */
#define PRIX8 "X" /* uint8_t */
#define PRIX16 "X" /* uint16_t */
#define PRIX32 "X" /* uint32_t */
#define PRIX64 "lX" /* uint64_t */
#define PRIXLEAST8 "X" /* uint_least8_t */
#define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "X" /* uint_least32_t */
#define PRIXLEAST64 "lX" /* uint_least64_t */
#define PRIXFAST8 "X" /* uint_fast8_t */
#define PRIXFAST16 "X" /* uint_fast16_t */
#define PRIXFAST32 "X" /* uint_fast32_t */
#define PRIXFAST64 "lX" /* uint_fast64_t */
#define PRIXMAX "jX" /* uintmax_t */
#define PRIXPTR "lX" /* uintptr_t */
/* fscanf(3) macros for signed integers. */
#define SCNd8 "hhd" /* int8_t */
#define SCNd16 "hd" /* int16_t */
#define SCNd32 "d" /* int32_t */
#define SCNd64 "ld" /* int64_t */
#define SCNdLEAST8 "hhd" /* int_least8_t */
#define SCNdLEAST16 "hd" /* int_least16_t */
#define SCNdLEAST32 "d" /* int_least32_t */
#define SCNdLEAST64 "ld" /* int_least64_t */
#define SCNdFAST8 "d" /* int_fast8_t */
#define SCNdFAST16 "d" /* int_fast16_t */
#define SCNdFAST32 "d" /* int_fast32_t */
#define SCNdFAST64 "ld" /* int_fast64_t */
#define SCNdMAX "jd" /* intmax_t */
#define SCNdPTR "ld" /* intptr_t */
#define SCNi8 "hhi" /* int8_t */
#define SCNi16 "hi" /* int16_t */
#define SCNi32 "i" /* int32_t */
#define SCNi64 "li" /* int64_t */
#define SCNiLEAST8 "hhi" /* int_least8_t */
#define SCNiLEAST16 "hi" /* int_least16_t */
#define SCNiLEAST32 "i" /* int_least32_t */
#define SCNiLEAST64 "li" /* int_least64_t */
#define SCNiFAST8 "i" /* int_fast8_t */
#define SCNiFAST16 "i" /* int_fast16_t */
#define SCNiFAST32 "i" /* int_fast32_t */
#define SCNiFAST64 "li" /* int_fast64_t */
#define SCNiMAX "ji" /* intmax_t */
#define SCNiPTR "li" /* intptr_t */
/* fscanf(3) macros for unsigned integers. */
#define SCNo8 "hho" /* uint8_t */
#define SCNo16 "ho" /* uint16_t */
#define SCNo32 "o" /* uint32_t */
#define SCNo64 "lo" /* uint64_t */
#define SCNoLEAST8 "hho" /* uint_least8_t */
#define SCNoLEAST16 "ho" /* uint_least16_t */
#define SCNoLEAST32 "o" /* uint_least32_t */
#define SCNoLEAST64 "lo" /* uint_least64_t */
#define SCNoFAST8 "o" /* uint_fast8_t */
#define SCNoFAST16 "o" /* uint_fast16_t */
#define SCNoFAST32 "o" /* uint_fast32_t */
#define SCNoFAST64 "lo" /* uint_fast64_t */
#define SCNoMAX "jo" /* uintmax_t */
#define SCNoPTR "lo" /* uintptr_t */
#define SCNu8 "hhu" /* uint8_t */
#define SCNu16 "hu" /* uint16_t */
#define SCNu32 "u" /* uint32_t */
#define SCNu64 "lu" /* uint64_t */
#define SCNuLEAST8 "hhu" /* uint_least8_t */
#define SCNuLEAST16 "hu" /* uint_least16_t */
#define SCNuLEAST32 "u" /* uint_least32_t */
#define SCNuLEAST64 "lu" /* uint_least64_t */
#define SCNuFAST8 "u" /* uint_fast8_t */
#define SCNuFAST16 "u" /* uint_fast16_t */
#define SCNuFAST32 "u" /* uint_fast32_t */
#define SCNuFAST64 "lu" /* uint_fast64_t */
#define SCNuMAX "ju" /* uintmax_t */
#define SCNuPTR "lu" /* uintptr_t */
#define SCNx8 "hhx" /* uint8_t */
#define SCNx16 "hx" /* uint16_t */
#define SCNx32 "x" /* uint32_t */
#define SCNx64 "lx" /* uint64_t */
#define SCNxLEAST8 "hhx" /* uint_least8_t */
#define SCNxLEAST16 "hx" /* uint_least16_t */
#define SCNxLEAST32 "x" /* uint_least32_t */
#define SCNxLEAST64 "lx" /* uint_least64_t */
#define SCNxFAST8 "x" /* uint_fast8_t */
#define SCNxFAST16 "x" /* uint_fast16_t */
#define SCNxFAST32 "x" /* uint_fast32_t */
#define SCNxFAST64 "lx" /* uint_fast64_t */
#define SCNxMAX "jx" /* uintmax_t */
#define SCNxPTR "lx" /* uintptr_t */
#endif /* !_MACHINE_INTTYPES_H_ */
#include <x86/_inttypes.h>

View File

@ -40,8 +40,6 @@
* type converted according to the integral promotions. The subtraction for
* INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
* These numbers are for the default configuration of gcc. They work for
* some other compilers as well, but this should not be depended on.
*/
#define __CHAR_BIT 8 /* number of bits in a char */
@ -49,19 +47,19 @@
#define __SCHAR_MAX 0x7f /* max value for a signed char */
#define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */
#define __UCHAR_MAX 0xffU /* max value for an unsigned char */
#define __UCHAR_MAX 0xff /* max value for an unsigned char */
#define __USHRT_MAX 0xffffU /* max value for an unsigned short */
#define __USHRT_MAX 0xffff /* max value for an unsigned short */
#define __SHRT_MAX 0x7fff /* max value for a short */
#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */
#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
#define __INT_MAX 0x7fffffff /* max value for an int */
#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
#define __ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
#define __LONG_MAX 0x7fffffffffffffffL /* max for a long */
#define __LONG_MIN (-0x7fffffffffffffffL - 1) /* min for a long */
#define __ULONG_MAX 0xffffffffffffffff /* max for an unsigned long */
#define __LONG_MAX 0x7fffffffffffffff /* max for a long */
#define __LONG_MIN (-0x7fffffffffffffff - 1) /* min for a long */
/* max value for an unsigned long long */
#define __ULLONG_MAX 0xffffffffffffffffULL
@ -83,10 +81,7 @@
#define __LONG_BIT 64
#define __WORD_BIT 32
/*
* Minimum signal stack size. The current signal frame
* for i386 is 408 bytes large.
*/
/* Minimum signal stack size. */
#define __MINSIGSTKSZ (512 * 4)
#endif /* !_MACHINE__LIMITS_H_ */

View File

@ -52,8 +52,8 @@
#define UINT32_C(c) (c ## U)
#define UINT64_C(c) (c ## UL)
#define INTMAX_C(c) (c ## L)
#define UINTMAX_C(c) (c ## UL)
#define INTMAX_C(c) INT64_C(c)
#define UINTMAX_C(c) UINT64_C(c)
#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */

View File

@ -108,7 +108,8 @@ atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
{ \
__asm __volatile(MPLOCKED OP \
: "=m" (*p) \
: CONS (V), "m" (*p)); \
: CONS (V), "m" (*p) \
: "cc"); \
} \
\
static __inline void \
@ -117,7 +118,7 @@ atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
__asm __volatile(MPLOCKED OP \
: "=m" (*p) \
: CONS (V), "m" (*p) \
: "memory"); \
: "memory", "cc"); \
} \
struct __hack
@ -145,7 +146,7 @@ atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src)
: "r" (src), /* 2 */
"a" (expect), /* 3 */
"m" (*dst) /* 4 */
: "memory");
: "memory", "cc");
return (res);
}
@ -166,7 +167,7 @@ atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src)
: "r" (src), /* 2 */
"a" (expect), /* 3 */
"m" (*dst) /* 4 */
: "memory");
: "memory", "cc");
return (res);
}
@ -185,8 +186,8 @@ atomic_fetchadd_int(volatile u_int *p, u_int v)
"# atomic_fetchadd_int"
: "+r" (v), /* 0 (result) */
"=m" (*p) /* 1 */
: "m" (*p)); /* 2 */
: "m" (*p) /* 2 */
: "cc");
return (v);
}
@ -204,8 +205,8 @@ atomic_fetchadd_long(volatile u_long *p, u_long v)
"# atomic_fetchadd_long"
: "+r" (v), /* 0 (result) */
"=m" (*p) /* 1 */
: "m" (*p)); /* 2 */
: "m" (*p) /* 2 */
: "cc");
return (v);
}
@ -249,7 +250,7 @@ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \
: "=a" (res), /* 0 */ \
"=m" (*p) /* 1 */ \
: "m" (*p) /* 2 */ \
: "memory"); \
: "memory", "cc"); \
\
return (res); \
} \

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,7 @@
#ifdef _KERNEL
extern char btext[];
extern char etext[];
extern int tsc_present;
void cpu_halt(void);
void cpu_reset(void);

View File

@ -94,8 +94,9 @@ __ElfType(Auxinfo);
#define AT_NCPUS 19 /* Number of CPUs. */
#define AT_PAGESIZES 20 /* Pagesizes. */
#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */
#define AT_STACKPROT 23 /* Initial stack protection. */
#define AT_COUNT 22 /* Count of defined aux entry types. */
#define AT_COUNT 24 /* Count of defined aux entry types. */
/*
* Relocation types.

View File

@ -26,6 +26,9 @@
* $FreeBSD$
*/
#ifndef _MACHINE_MEMDEV_H_
#define _MACHINE_MEMDEV_H_
#define CDEV_MINOR_MEM 0
#define CDEV_MINOR_KMEM 1
@ -34,4 +37,4 @@ d_read_t memrw;
d_ioctl_t memioctl;
d_mmap_t memmmap;
void dev_mem_md_init(void);
#endif /* _MACHINE_MEMDEV_H_ */

View File

@ -66,37 +66,68 @@ struct pcb {
register_t pcb_dr6;
register_t pcb_dr7;
u_long pcb_flags;
struct region_descriptor pcb_gdt;
struct region_descriptor pcb_idt;
struct region_descriptor pcb_ldt;
uint16_t pcb_tr;
u_int pcb_flags;
#define PCB_FULL_IRET 0x01 /* full iret is required */
#define PCB_DBREGS 0x02 /* process using debug registers */
#define PCB_KERNFPU 0x04 /* kernel uses fpu */
#define PCB_FPUINITDONE 0x08 /* fpu state is initialized */
#define PCB_USERFPUINITDONE 0x10 /* fpu user state is initialized */
#define PCB_GS32BIT 0x20 /* linux gs switch */
#define PCB_32BIT 0x40 /* process has 32 bit context (segs etc) */
#define PCB_FULLCTX 0x80 /* full context restore on sysret */
uint16_t pcb_initial_fpucw;
caddr_t pcb_onfault; /* copyin/out fault recovery */
/* copyin/out fault recovery */
caddr_t pcb_onfault;
/* 32-bit segment descriptor */
struct user_segment_descriptor pcb_gs32sd;
/* local tss, with i/o bitmap; NULL for common */
struct amd64tss *pcb_tssp;
struct savefpu *pcb_save;
char pcb_full_iret;
struct region_descriptor pcb_gdt;
struct region_descriptor pcb_idt;
struct region_descriptor pcb_ldt;
uint16_t pcb_tr;
struct savefpu pcb_user_save;
struct savefpu *pcb_save;
struct savefpu pcb_user_save;
};
#ifdef _KERNEL
struct trapframe;
/*
* The pcb_flags is only modified by current thread, or by other threads
* when current thread is stopped. However, current thread may change it
* from the interrupt context in cpu_switch(), or in the trap handler.
* When we read-modify-write pcb_flags from C sources, compiler may generate
* code that is not atomic regarding the interrupt handler. If a trap or
* interrupt happens and any flag is modified from the handler, it can be
* clobbered with the cached value later. Therefore, we implement setting
* and clearing flags with single-instruction functions, which do not race
* with possible modification of the flags from the trap or interrupt context,
* because traps and interrupts are executed only on instruction boundary.
*/
static __inline void
set_pcb_flags(struct pcb *pcb, const u_int flags)
{
__asm __volatile("orl %1,%0"
: "=m" (pcb->pcb_flags) : "ir" (flags), "m" (pcb->pcb_flags)
: "cc");
}
static __inline void
clear_pcb_flags(struct pcb *pcb, const u_int flags)
{
__asm __volatile("andl %1,%0"
: "=m" (pcb->pcb_flags) : "ir" (~flags), "m" (pcb->pcb_flags)
: "cc");
}
void makectx(struct trapframe *, struct pcb *);
int savectx(struct pcb *);
#endif

View File

@ -251,8 +251,6 @@ struct pmap {
pml4_entry_t *pm_pml4; /* KVA of level 4 page table */
TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
cpumask_t pm_active; /* active on cpus */
uint32_t pm_gen_count; /* generation count (pmap lock dropped) */
u_int pm_retries;
/* spare u_int here due to padding */
struct pmap_statistics pm_stats; /* pmap statistics */
vm_page_t pm_root; /* spare page table pages */

View File

@ -130,6 +130,7 @@ struct dbreg {
* XXX these interfaces are MI, so they should be declared in a MI place.
*/
int fill_regs(struct thread *, struct reg *);
int fill_frame_regs(struct trapframe *, struct reg *);
int set_regs(struct thread *, struct reg *);
int fill_fpregs(struct thread *, struct fpreg *);
int set_fpregs(struct thread *, struct fpreg *);

View File

@ -69,17 +69,6 @@
#define SGROWSIZ (128UL*1024) /* amount to grow stack */
#endif
/*
* The time for a process to be blocked before being very swappable.
* This is a number of seconds which the system takes as being a non-trivial
* amount of real time. You probably shouldn't change this;
* it is used in subtle ways (fractions and multiples of it are, that is, like
* half of a ``long time'', almost a long time, etc.)
* It is related to human patience and other factors which don't really
* change over time.
*/
#define MAXSLP 20
/*
* We provide a machine specific single page allocator through the use
* of the direct mapped segment. This uses 2MB pages for reduced
@ -186,7 +175,8 @@
#define VM_MAXUSER_ADDRESS UVADDR(NUPML4E, 0, 0, 0)
#define USRSTACK VM_MAXUSER_ADDRESS
#define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
#define USRSTACK SHAREDPAGE
#define VM_MAX_ADDRESS UPT_MAX_ADDRESS
#define VM_MIN_ADDRESS (0)

View File

@ -306,6 +306,7 @@ struct l_new_utsname {
#define LINUX_SIGPOLL LINUX_SIGIO
#define LINUX_SIGPWR 30
#define LINUX_SIGSYS 31
#define LINUX_SIGRTMIN 32
#define LINUX_SIGTBLSZ 31
#define LINUX_NSIG_WORDS 2
@ -370,28 +371,28 @@ typedef struct {
/* The Linux sigcontext, pretty much a standard 386 trapframe. */
struct l_sigcontext {
l_int sc_gs;
l_int sc_fs;
l_int sc_es;
l_int sc_ds;
l_int sc_edi;
l_int sc_esi;
l_int sc_ebp;
l_int sc_esp;
l_int sc_ebx;
l_int sc_edx;
l_int sc_ecx;
l_int sc_eax;
l_int sc_trapno;
l_int sc_err;
l_int sc_eip;
l_int sc_cs;
l_int sc_eflags;
l_int sc_esp_at_signal;
l_int sc_ss;
l_int sc_387;
l_int sc_mask;
l_int sc_cr2;
l_uint sc_gs;
l_uint sc_fs;
l_uint sc_es;
l_uint sc_ds;
l_uint sc_edi;
l_uint sc_esi;
l_uint sc_ebp;
l_uint sc_esp;
l_uint sc_ebx;
l_uint sc_edx;
l_uint sc_ecx;
l_uint sc_eax;
l_uint sc_trapno;
l_uint sc_err;
l_uint sc_eip;
l_uint sc_cs;
l_uint sc_eflags;
l_uint sc_esp_at_signal;
l_uint sc_ss;
l_uint sc_387;
l_uint sc_mask;
l_uint sc_cr2;
} __packed;
struct l_ucontext {
@ -920,4 +921,7 @@ struct linux_robust_list_head {
l_uintptr_t pending_list;
};
int linux_set_upcall_kse(struct thread *td, register_t stack);
int linux_set_cloned_tls(struct thread *td, void *desc);
#endif /* !_AMD64_LINUX_H_ */

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/syscallsubr.h>
#include <sys/sysproto.h>
#include <sys/unistd.h>
#include <sys/wait.h>
#include <machine/frame.h>
#include <machine/pcb.h>
@ -66,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <amd64/linux32/linux.h>
#include <amd64/linux32/linux32_proto.h>
#include <compat/linux/linux_ipc.h>
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_signal.h>
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_emul.h>
@ -106,6 +108,30 @@ bsd_to_linux_sigaltstack(int bsa)
return (lsa);
}
static void
bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru)
{
lru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
lru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
lru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
lru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
lru->ru_maxrss = ru->ru_maxrss;
lru->ru_ixrss = ru->ru_ixrss;
lru->ru_idrss = ru->ru_idrss;
lru->ru_isrss = ru->ru_isrss;
lru->ru_minflt = ru->ru_minflt;
lru->ru_majflt = ru->ru_majflt;
lru->ru_nswap = ru->ru_nswap;
lru->ru_inblock = ru->ru_inblock;
lru->ru_oublock = ru->ru_oublock;
lru->ru_msgsnd = ru->ru_msgsnd;
lru->ru_msgrcv = ru->ru_msgrcv;
lru->ru_nsignals = ru->ru_nsignals;
lru->ru_nvcsw = ru->ru_nvcsw;
lru->ru_nivcsw = ru->ru_nivcsw;
}
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
@ -131,7 +157,7 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
* linux_proc_init, this leads to a panic on KASSERT
* because such process has p->p_emuldata == NULL.
*/
if (td->td_proc->p_sysent == &elf_linux_sysvec)
if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
error = linux_proc_init(td, 0, 0);
return (error);
}
@ -383,279 +409,54 @@ linux_old_select(struct thread *td, struct linux_old_select_args *args)
}
int
linux_fork(struct thread *td, struct linux_fork_args *args)
linux_set_cloned_tls(struct thread *td, void *desc)
{
struct user_segment_descriptor sd;
struct l_user_desc info;
struct pcb *pcb;
int error;
struct proc *p2;
struct thread *td2;
int a[2];
#ifdef DEBUG
if (ldebug(fork))
printf(ARGS(fork, ""));
#endif
if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2)) != 0)
return (error);
if (error == 0) {
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
}
if (td->td_retval[1] == 1)
td->td_retval[0] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
td2 = FIRST_THREAD_IN_PROC(p2);
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
return (0);
}
int
linux_vfork(struct thread *td, struct linux_vfork_args *args)
{
int error;
struct proc *p2;
struct thread *td2;
#ifdef DEBUG
if (ldebug(vfork))
printf(ARGS(vfork, ""));
#endif
/* Exclude RFPPWAIT */
if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2)) != 0)
return (error);
if (error == 0) {
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
}
/* Are we the child? */
if (td->td_retval[1] == 1)
td->td_retval[0] = 0;
error = linux_proc_init(td, td->td_retval[0], 0);
if (error)
return (error);
PROC_LOCK(p2);
p2->p_flag |= P_PPWAIT;
PROC_UNLOCK(p2);
td2 = FIRST_THREAD_IN_PROC(p2);
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
/* wait for the children to exit, ie. emulate vfork */
PROC_LOCK(p2);
while (p2->p_flag & P_PPWAIT)
cv_wait(&p2->p_pwait, &p2->p_mtx);
PROC_UNLOCK(p2);
return (0);
}
int
linux_clone(struct thread *td, struct linux_clone_args *args)
{
int error, ff = RFPROC | RFSTOPPED;
struct proc *p2;
struct thread *td2;
int exit_signal;
struct linux_emuldata *em;
#ifdef DEBUG
if (ldebug(clone)) {
printf(ARGS(clone, "flags %x, stack %p, parent tid: %p, "
"child tid: %p"), (unsigned)args->flags,
args->stack, args->parent_tidptr, args->child_tidptr);
}
#endif
exit_signal = args->flags & 0x000000ff;
if (LINUX_SIG_VALID(exit_signal)) {
if (exit_signal <= LINUX_SIGTBLSZ)
exit_signal =
linux_to_bsd_signal[_SIG_IDX(exit_signal)];
} else if (exit_signal != 0)
return (EINVAL);
if (args->flags & LINUX_CLONE_VM)
ff |= RFMEM;
if (args->flags & LINUX_CLONE_SIGHAND)
ff |= RFSIGSHARE;
/*
* XXX: In Linux, sharing of fs info (chroot/cwd/umask)
* and open files is independant. In FreeBSD, its in one
* structure but in reality it does not cause any problems
* because both of these flags are usually set together.
*/
if (!(args->flags & (LINUX_CLONE_FILES | LINUX_CLONE_FS)))
ff |= RFFDG;
/*
* Attempt to detect when linux_clone(2) is used for creating
* kernel threads. Unfortunately despite the existence of the
* CLONE_THREAD flag, version of linuxthreads package used in
* most popular distros as of beginning of 2005 doesn't make
* any use of it. Therefore, this detection relies on
* empirical observation that linuxthreads sets certain
* combination of flags, so that we can make more or less
* precise detection and notify the FreeBSD kernel that several
* processes are in fact part of the same threading group, so
* that special treatment is necessary for signal delivery
* between those processes and fd locking.
*/
if ((args->flags & 0xffffff00) == LINUX_THREADING_FLAGS)
ff |= RFTHREAD;
if (args->flags & LINUX_CLONE_PARENT_SETTID)
if (args->parent_tidptr == NULL)
return (EINVAL);
error = fork1(td, ff, 0, &p2);
if (error)
return (error);
if (args->flags & (LINUX_CLONE_PARENT | LINUX_CLONE_THREAD)) {
sx_xlock(&proctree_lock);
PROC_LOCK(p2);
proc_reparent(p2, td->td_proc->p_pptr);
PROC_UNLOCK(p2);
sx_xunlock(&proctree_lock);
}
/* create the emuldata */
error = linux_proc_init(td, p2->p_pid, args->flags);
/* reference it - no need to check this */
em = em_find(p2, EMUL_DOLOCK);
KASSERT(em != NULL, ("clone: emuldata not found.\n"));
/* and adjust it */
if (args->flags & LINUX_CLONE_THREAD) {
#ifdef notyet
PROC_LOCK(p2);
p2->p_pgrp = td->td_proc->p_pgrp;
PROC_UNLOCK(p2);
#endif
exit_signal = 0;
}
if (args->flags & LINUX_CLONE_CHILD_SETTID)
em->child_set_tid = args->child_tidptr;
else
em->child_set_tid = NULL;
if (args->flags & LINUX_CLONE_CHILD_CLEARTID)
em->child_clear_tid = args->child_tidptr;
else
em->child_clear_tid = NULL;
EMUL_UNLOCK(&emul_lock);
if (args->flags & LINUX_CLONE_PARENT_SETTID) {
error = copyout(&p2->p_pid, args->parent_tidptr,
sizeof(p2->p_pid));
error = copyin(desc, &info, sizeof(struct l_user_desc));
if (error) {
printf(LMSG("copyin failed!"));
} else {
/* We might copy out the entry_number as GUGS32_SEL. */
info.entry_number = GUGS32_SEL;
error = copyout(&info, desc, sizeof(struct l_user_desc));
if (error)
printf(LMSG("copyout failed!"));
}
PROC_LOCK(p2);
p2->p_sigparent = exit_signal;
PROC_UNLOCK(p2);
td2 = FIRST_THREAD_IN_PROC(p2);
/*
* In a case of stack = NULL, we are supposed to COW calling process
* stack. This is what normal fork() does, so we just keep tf_rsp arg
* intact.
*/
if (args->stack)
td2->td_frame->tf_rsp = PTROUT(args->stack);
a[0] = LINUX_LDT_entry_a(&info);
a[1] = LINUX_LDT_entry_b(&info);
if (args->flags & LINUX_CLONE_SETTLS) {
struct user_segment_descriptor sd;
struct l_user_desc info;
int a[2];
error = copyin((void *)td->td_frame->tf_rsi, &info,
sizeof(struct l_user_desc));
if (error) {
printf(LMSG("copyin failed!"));
} else {
/* We might copy out the entry_number as GUGS32_SEL. */
info.entry_number = GUGS32_SEL;
error = copyout(&info, (void *)td->td_frame->tf_rsi,
sizeof(struct l_user_desc));
if (error)
printf(LMSG("copyout failed!"));
a[0] = LINUX_LDT_entry_a(&info);
a[1] = LINUX_LDT_entry_b(&info);
memcpy(&sd, &a, sizeof(a));
memcpy(&sd, &a, sizeof(a));
#ifdef DEBUG
if (ldebug(clone))
printf("Segment created in clone with "
"CLONE_SETTLS: lobase: %x, hibase: %x, "
"lolimit: %x, hilimit: %x, type: %i, "
"dpl: %i, p: %i, xx: %i, long: %i, "
"def32: %i, gran: %i\n", sd.sd_lobase,
sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit,
sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx,
sd.sd_long, sd.sd_def32, sd.sd_gran);
if (ldebug(clone))
printf("Segment created in clone with "
"CLONE_SETTLS: lobase: %x, hibase: %x, "
"lolimit: %x, hilimit: %x, type: %i, "
"dpl: %i, p: %i, xx: %i, long: %i, "
"def32: %i, gran: %i\n", sd.sd_lobase,
sd.sd_hibase, sd.sd_lolimit, sd.sd_hilimit,
sd.sd_type, sd.sd_dpl, sd.sd_p, sd.sd_xx,
sd.sd_long, sd.sd_def32, sd.sd_gran);
#endif
td2->td_pcb->pcb_gsbase = (register_t)info.base_addr;
/* XXXKIB td2->td_pcb->pcb_gs32sd = sd; */
td2->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL);
td2->td_pcb->pcb_flags |= PCB_GS32BIT | PCB_32BIT;
}
pcb = td->td_pcb;
pcb->pcb_gsbase = (register_t)info.base_addr;
/* XXXKIB pcb->pcb_gs32sd = sd; */
td->td_frame->tf_gs = GSEL(GUGS32_SEL, SEL_UPL);
set_pcb_flags(pcb, PCB_GS32BIT | PCB_32BIT);
}
#ifdef DEBUG
if (ldebug(clone))
printf(LMSG("clone: successful rfork to %d, "
"stack %p sig = %d"), (int)p2->p_pid, args->stack,
exit_signal);
#endif
if (args->flags & LINUX_CLONE_VFORK) {
PROC_LOCK(p2);
p2->p_flag |= P_PPWAIT;
PROC_UNLOCK(p2);
}
return (error);
}
/*
* Make this runnable after we are finished with it.
*/
thread_lock(td2);
TD_SET_CAN_RUN(td2);
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
int
linux_set_upcall_kse(struct thread *td, register_t stack)
{
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
if (args->flags & LINUX_CLONE_VFORK) {
/* wait for the children to exit, ie. emulate vfork */
PROC_LOCK(p2);
while (p2->p_flag & P_PPWAIT)
cv_wait(&p2->p_pwait, &p2->p_mtx);
PROC_UNLOCK(p2);
}
td->td_frame->tf_rsp = stack;
return (0);
}
@ -1124,24 +925,7 @@ linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
if (error != 0)
return (error);
if (uap->rusage != NULL) {
s32.ru_utime.tv_sec = s.ru_utime.tv_sec;
s32.ru_utime.tv_usec = s.ru_utime.tv_usec;
s32.ru_stime.tv_sec = s.ru_stime.tv_sec;
s32.ru_stime.tv_usec = s.ru_stime.tv_usec;
s32.ru_maxrss = s.ru_maxrss;
s32.ru_ixrss = s.ru_ixrss;
s32.ru_idrss = s.ru_idrss;
s32.ru_isrss = s.ru_isrss;
s32.ru_minflt = s.ru_minflt;
s32.ru_majflt = s.ru_majflt;
s32.ru_nswap = s.ru_nswap;
s32.ru_inblock = s.ru_inblock;
s32.ru_oublock = s.ru_oublock;
s32.ru_msgsnd = s.ru_msgsnd;
s32.ru_msgrcv = s.ru_msgrcv;
s32.ru_nsignals = s.ru_nsignals;
s32.ru_nvcsw = s.ru_nvcsw;
s32.ru_nivcsw = s.ru_nivcsw;
bsd_to_linux_rusage(&s, &s32);
error = copyout(&s32, uap->rusage, sizeof(s32));
}
return (error);
@ -1169,6 +953,7 @@ linux_set_thread_area(struct thread *td,
{
struct l_user_desc info;
struct user_segment_descriptor sd;
struct pcb *pcb;
int a[2];
int error;
@ -1257,9 +1042,44 @@ linux_set_thread_area(struct thread *td,
sd.sd_gran);
#endif
td->td_pcb->pcb_gsbase = (register_t)info.base_addr;
td->td_pcb->pcb_flags |= PCB_32BIT | PCB_GS32BIT;
pcb = td->td_pcb;
pcb->pcb_gsbase = (register_t)info.base_addr;
set_pcb_flags(pcb, PCB_32BIT | PCB_GS32BIT);
update_gdt_gsbase(td, info.base_addr);
return (0);
}
int
linux_wait4(struct thread *td, struct linux_wait4_args *args)
{
int error, options;
struct rusage ru, *rup;
struct l_rusage lru;
#ifdef DEBUG
if (ldebug(wait4))
printf(ARGS(wait4, "%d, %p, %d, %p"),
args->pid, (void *)args->status, args->options,
(void *)args->rusage);
#endif
options = (args->options & (WNOHANG | WUNTRACED));
/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
if (args->options & __WCLONE)
options |= WLINUXCLONE;
if (args->rusage != NULL)
rup = &ru;
else
rup = NULL;
error = linux_common_wait(td, args->pid, args->status, options, rup);
if (error)
return (error);
if (args->rusage != NULL) {
bsd_to_linux_rusage(rup, &lru);
error = copyout(&lru, args->rusage, sizeof(lru));
}
return (error);
}

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 2010-10-08 07:18:44Z kib
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 2011-02-12 15:33:25Z dchagin
*/
#ifndef _LINUX_SYSPROTO_H_
@ -375,7 +375,7 @@ struct linux_clone_args {
char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
char stack_l_[PADL_(void *)]; void * stack; char stack_r_[PADR_(void *)];
char parent_tidptr_l_[PADL_(void *)]; void * parent_tidptr; char parent_tidptr_r_[PADR_(void *)];
char dummy_l_[PADL_(int)]; int dummy; char dummy_r_[PADR_(int)];
char tls_l_[PADL_(void *)]; void * tls; char tls_r_[PADR_(void *)];
char child_tidptr_l_[PADL_(void *)]; void * child_tidptr; char child_tidptr_r_[PADR_(void *)];
};
struct linux_setdomainname_args {
@ -734,10 +734,10 @@ struct linux_tkill_args {
struct linux_sys_futex_args {
char uaddr_l_[PADL_(void *)]; void * uaddr; char uaddr_r_[PADR_(void *)];
char op_l_[PADL_(int)]; int op; char op_r_[PADR_(int)];
char val_l_[PADL_(int)]; int val; char val_r_[PADR_(int)];
char val_l_[PADL_(uint32_t)]; uint32_t val; char val_r_[PADR_(uint32_t)];
char timeout_l_[PADL_(struct l_timespec *)]; struct l_timespec * timeout; char timeout_r_[PADR_(struct l_timespec *)];
char uaddr2_l_[PADL_(void *)]; void * uaddr2; char uaddr2_r_[PADR_(void *)];
char val3_l_[PADL_(int)]; int val3; char val3_r_[PADR_(int)];
char uaddr2_l_[PADL_(uint32_t *)]; uint32_t * uaddr2; char uaddr2_r_[PADR_(uint32_t *)];
char val3_l_[PADL_(uint32_t)]; uint32_t val3; char val3_r_[PADR_(uint32_t)];
};
struct linux_sched_setaffinity_args {
char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 2010-10-08 07:18:44Z kib
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 2011-02-12 15:33:25Z dchagin
*/
#define LINUX_SYS_exit 1

View File

@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 213544 2010-10-08 07:18:44Z kib
* created from FreeBSD: head/sys/amd64/linux32/syscalls.master 218610 2011-02-12 15:33:25Z dchagin
*/
#include "opt_compat.h"

View File

@ -76,8 +76,8 @@ __FBSDID("$FreeBSD$");
#include <amd64/linux32/linux.h>
#include <amd64/linux32/linux32_proto.h>
#include <compat/linux/linux_futex.h>
#include <compat/linux/linux_emul.h>
#include <compat/linux/linux_futex.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_misc.h>
#include <compat/linux/linux_signal.h>
@ -422,7 +422,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
@ -545,7 +545,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
@ -643,7 +643,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
regs->tf_rflags = eflags;
regs->tf_rsp = frame.sf_sc.sc_esp_at_signal;
regs->tf_ss = frame.sf_sc.sc_ss;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
@ -742,7 +742,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
regs->tf_rflags = eflags;
regs->tf_rsp = context->sc_esp_at_signal;
regs->tf_ss = context->sc_ss;
td->td_pcb->pcb_full_iret = 1;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/*
* call sigaltstack & ignore results..
@ -865,13 +865,12 @@ exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
regs->tf_flags = TF_HASSEGS;
regs->tf_cs = _ucode32sel;
regs->tf_rbx = imgp->ps_strings;
td->td_pcb->pcb_full_iret = 1;
load_cr0(rcr0() | CR0_MP | CR0_TS);
fpstate_drop(td);
/* Return via doreti so that we can change to a different %cs */
pcb->pcb_flags |= PCB_FULLCTX | PCB_32BIT;
pcb->pcb_flags &= ~PCB_GS32BIT;
/* Do full restore on return so that we can change to a different %cs */
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
clear_pcb_flags(pcb, PCB_GS32BIT);
td->td_retval[1] = 0;
}

View File

@ -213,9 +213,8 @@
118 AUE_FSYNC NOPROTO { int fsync(int fd); }
119 AUE_SIGRETURN STD { int linux_sigreturn( \
struct l_sigframe *sfp); }
; linux uses some strange calling convention here so we have to use the dummy arg
120 AUE_RFORK STD { int linux_clone(l_int flags, void *stack, \
void *parent_tidptr, int dummy, void * child_tidptr); }
void *parent_tidptr, void *tls, void * child_tidptr); }
121 AUE_SYSCTL STD { int linux_setdomainname(char *name, \
int len); }
122 AUE_NULL STD { int linux_newuname( \
@ -405,8 +404,8 @@
237 AUE_NULL STD { int linux_fremovexattr(void); }
238 AUE_NULL STD { int linux_tkill(int tid, int sig); }
239 AUE_SENDFILE UNIMPL linux_sendfile64
240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, int val, \
struct l_timespec *timeout, void *uaddr2, int val3); }
240 AUE_NULL STD { int linux_sys_futex(void *uaddr, int op, uint32_t val, \
struct l_timespec *timeout, uint32_t *uaddr2, uint32_t val3); }
241 AUE_NULL STD { int linux_sched_setaffinity(l_pid_t pid, l_uint len, \
l_ulong *user_mask_ptr); }
242 AUE_NULL STD { int linux_sched_getaffinity(l_pid_t pid, l_uint len, \

View File

@ -169,9 +169,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
addr = lookup(lf, symidx, 1);
if (addr == 0)
return -1;
if (*where != addr)
*where = addr;
*where += addr;
break;
case R_ARM_COPY: /* none */

View File

@ -65,14 +65,20 @@ __FBSDID("$FreeBSD$");
ENTRY_NP(btext)
/*
* On entry:
* r0 - metadata pointer or 0
* r1 - if (r0 == 0) then metadata pointer
*/
ASENTRY_NP(_start)
/*
* Move metadata ptr to r12 (ip)
*/
/* Move metadata ptr to r12 (ip) */
mov ip, r0
ldr r0, =0
cmp ip, r0
bne 1f
mov ip, r1
1:
/* Make sure interrupts are disabled. */
mrs r7, cpsr
orr r7, r7, #(I32_bit|F32_bit)

View File

@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$");
*/
MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
struct mem_range_softc mem_range_softc;
/* ARGSUSED */
int
memrw(struct cdev *dev, struct uio *uio, int flags)
@ -163,8 +165,3 @@ memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
/* else panic! */
return (0);
}
void
dev_mem_md_init(void)
{
}

View File

@ -85,7 +85,7 @@ static int
arm32_set_tp(struct thread *td, void *args)
{
td->td_md.md_tp = args;
td->td_md.md_tp = (register_t)args;
return (0);
}
@ -93,7 +93,7 @@ static int
arm32_get_tp(struct thread *td, void *args)
{
td->td_retval[0] = (uint32_t)td->td_md.md_tp;
td->td_retval[0] = td->td_md.md_tp;
return (0);
}

View File

@ -94,8 +94,7 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
cp = (char*)sf_buf_kva(sf) + page_offset;
switch (uio->uio_segflg) {
case UIO_USERSPACE:
if (ticks - PCPU_GET(switchticks) >= hogticks)
uio_yield();
maybe_yield();
if (uio->uio_rw == UIO_READ)
error = copyout(cp, iov->iov_base, cnt);
else

View File

@ -146,7 +146,7 @@ cpu_fork(register struct thread *td1, register struct proc *p2,
/* Setup to release spin count in fork_exit(). */
td2->td_md.md_spinlock_count = 1;
td2->td_md.md_saved_cspr = 0;
td2->td_md.md_tp = *(uint32_t **)ARM_TP_ADDRESS;
td2->td_md.md_tp = *(register_t *)ARM_TP_ADDRESS;
}
void
@ -175,7 +175,7 @@ sf_buf_free(struct sf_buf *sf)
sf->m = NULL;
LIST_REMOVE(sf, list_entry);
if (sf_buf_alloc_want > 0)
wakeup_one(&sf_buf_freelist);
wakeup(&sf_buf_freelist);
}
mtx_unlock(&sf_buf_lock);
#endif
@ -370,10 +370,10 @@ cpu_set_user_tls(struct thread *td, void *tls_base)
{
if (td != curthread)
td->td_md.md_tp = tls_base;
td->td_md.md_tp = (register_t)tls_base;
else {
critical_enter();
*(void **)ARM_TP_ADDRESS = tls_base;
*(register_t *)ARM_TP_ADDRESS = (register_t)tls_base;
critical_exit();
}
return (0);

View File

@ -43,8 +43,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -302,8 +300,10 @@ initarm(void *arg, void *arg2)
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
/* Do basic tuning, hz etc */
init_param1();
/*
* Now we start construction of the L1 page table
* We start by mapping the L2 page tables into the L1.
@ -347,7 +347,7 @@ initarm(void *arg, void *arg2)
pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
L1_TABLE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
pmap_map_chunk(l1pagetable, msgbufpv.pv_va, msgbufpv.pv_pa,
MSGBUF_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
msgbufsize, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
@ -430,7 +430,7 @@ initarm(void *arg, void *arg2)
KERNVIRTADDR + 3 * memsize,
&kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;
@ -442,8 +442,6 @@ initarm(void *arg, void *arg2)
phys_avail[i++] = PHYSADDR + memsize;
phys_avail[i++] = 0;
phys_avail[i++] = 0;
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -

View File

@ -325,7 +325,7 @@ at91_pmc_clock_disable(struct at91_pmc_clock *clk)
static int
at91_pmc_pll_rate(struct at91_pmc_clock *clk, uint32_t reg)
{
uint32_t mul, div, freq;;
uint32_t mul, div, freq;
freq = clk->parent->hz;
div = (reg >> clk->pll_div_shift) & clk->pll_div_mask;

View File

@ -77,11 +77,7 @@ static unsigned at91st_get_timecount(struct timecounter *tc);
static struct timecounter at91st_timecounter = {
at91st_get_timecount, /* get_timecount */
NULL, /* no poll_pps */
#ifdef SKYEYE_WORKAROUNDS
0xffffffffu, /* counter_mask */
#else
0xfffffu, /* counter_mask */
#endif
32768, /* frequency */
"AT91RM9200 timer", /* name */
1000 /* quality */
@ -138,18 +134,10 @@ static devclass_t at91st_devclass;
DRIVER_MODULE(at91_st, atmelarm, at91st_driver, at91st_devclass, 0, 0);
#ifdef SKYEYE_WORKAROUNDS
static unsigned long tot_count = 0;
#endif
static unsigned
at91st_get_timecount(struct timecounter *tc)
{
#ifdef SKYEYE_WORKAROUNDS
return (tot_count);
#else
return (st_crtr());
#endif
}
/*
@ -189,9 +177,6 @@ clock_intr(void *arg)
/* The interrupt is shared, so we have to make sure it's for us. */
if (RD4(ST_SR) & ST_SR_PITS) {
#ifdef SKYEYE_WORKAROUNDS
tot_count += 32768 / hz;
#endif
hardclock(TRAPF_USERMODE(fp), TRAPF_PC(fp));
return (FILTER_HANDLED);
}

View File

@ -121,15 +121,11 @@ static const struct cpu_devs at91_devs[] =
DEVICE("at91_ssc", SSC2, 2),
DEVICE("spi", SPI, 0),
#ifndef SKYEYE_WORKAROUNDS
DEVICE("uart", DBGU, 0),
DEVICE("uart", USART0, 1),
DEVICE("uart", USART1, 2),
DEVICE("uart", USART2, 3),
DEVICE("uart", USART3, 4),
#else
DEVICE("uart", USART0, 0),
#endif
DEVICE("at91_aic", AIC, 0),
DEVICE("at91_mc", MC, 0),
DEVICE("at91_tc", TC0, 0),

View File

@ -433,6 +433,16 @@ ate_load_rx_buf(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
bus_dmamap_sync(sc->rx_desc_tag, sc->rx_desc_map, BUS_DMASYNC_POSTWRITE);
}
static uint32_t
ate_mac_hash(const uint8_t *buf)
{
uint32_t index = 0;
for (int i = 0; i < 48; i++) {
index ^= ((buf[i >> 3] >> (i & 7)) & 1) << (i % 6);
}
return (index);
}
/*
* Compute the multicast filter for this device.
*/
@ -462,8 +472,8 @@ ate_setmcast(struct ate_softc *sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_be(LLADDR((struct sockaddr_dl *)
ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
index = ate_mac_hash(LLADDR((struct sockaddr_dl *)
ifma->ifma_addr));
af[index >> 3] |= 1 << (index & 7);
}
if_maddr_runlock(ifp);

View File

@ -137,7 +137,6 @@ macb_watchdog(struct macb_softc *sc);
static int macb_intr_rx_locked(struct macb_softc *sc, int count);
static void macb_intr_task(void *arg, int pending __unused);
static void macb_tx_task(void *arg, int pending __unused);
static void macb_intr(void *xsc);
static void
@ -533,7 +532,7 @@ macb_watchdog(struct macb_softc *sc)
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
macbinit_locked(sc);
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task);
macbstart_locked(ifp);
}
@ -837,6 +836,7 @@ macb_intr(void *xsc)
return;
}
MACB_LOCK(sc);
status = read_4(sc, EMAC_ISR);
while (status) {
@ -846,16 +846,15 @@ macb_intr(void *xsc)
}
if (status & TCOMP_INTERRUPT) {
MACB_LOCK(sc);
macb_tx_cleanup(sc);
MACB_UNLOCK(sc);
}
status = read_4(sc, EMAC_ISR);
}
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
taskqueue_enqueue(sc->sc_tq, &sc->sc_tx_task);
macbstart_locked(ifp);
MACB_UNLOCK(sc);
}
static inline int
@ -1025,16 +1024,6 @@ macbstart(struct ifnet *ifp)
}
static void
macb_tx_task(void *arg, int pending __unused)
{
struct ifnet *ifp;
ifp = (struct ifnet *)arg;
macbstart(ifp);
}
static void
macbstop(struct macb_softc *sc)
{
@ -1392,7 +1381,6 @@ macb_attach(device_t dev)
sc->if_flags = ifp->if_flags;
TASK_INIT(&sc->sc_intr_task, 0, macb_intr_task, sc);
TASK_INIT(&sc->sc_tx_task, 0, macb_tx_task, ifp);
sc->sc_tq = taskqueue_create_fast("macb_taskq", M_WAITOK,
taskqueue_thread_enqueue, &sc->sc_tq);
@ -1434,8 +1422,18 @@ macb_detach(device_t dev)
struct macb_softc *sc;
sc = device_get_softc(dev);
ether_ifdetach(sc->ifp);
MACB_LOCK(sc);
macbstop(sc);
MACB_UNLOCK(sc);
callout_drain(&sc->tick_ch);
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
taskqueue_drain(sc->sc_tq, &sc->sc_intr_task);
taskqueue_free(sc->sc_tq);
macb_deactivate(dev);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
MACB_LOCK_DESTROY(sc);
return (0);
}

View File

@ -76,11 +76,7 @@ usart_at91rm92_probe(device_t dev)
switch (device_get_unit(dev))
{
case 0:
#ifdef SKYEYE_WORKAROUNDS
device_set_desc(dev, "USART0");
#else
device_set_desc(dev, "DBGU");
#endif
/*
* Setting sc_sysdev makes this device a 'system device' and
* indirectly makes it the system console.

View File

@ -73,13 +73,8 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
* XXX: Not pretty, but will work because we map the needed addresses
* early.
*/
#ifdef SKYEYE_WORKAROUNDS
di->bas.bsh = AT91RM92_BASE + AT91RM92_USART0_BASE;
di->baudrate = 38400;
#else
di->bas.bsh = AT91RM92_BASE + AT91RM92_DBGU_BASE;
di->baudrate = 115200;
#endif
di->bas.regshft = 0;
di->bas.rclk = 0;
di->databits = 8;

View File

@ -315,7 +315,6 @@ at91_usart_bus_probe(struct uart_softc *sc)
return (0);
}
#ifndef SKYEYE_WORKAROUNDS
static void
at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
{
@ -323,15 +322,12 @@ at91_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
return;
*(bus_addr_t *)arg = segs[0].ds_addr;
}
#endif
static int
at91_usart_bus_attach(struct uart_softc *sc)
{
#ifndef SKYEYE_WORKAROUNDS
int err;
int i;
#endif
uint32_t cr;
struct at91_usart_softc *atsc;
@ -349,7 +345,6 @@ at91_usart_bus_attach(struct uart_softc *sc)
atsc->flags |= HAS_TIMEOUT;
WR4(&sc->sc_bas, USART_IDR, 0xffffffff);
#ifndef SKYEYE_WORKAROUNDS
/*
* Allocate DMA tags and maps
*/
@ -380,7 +375,6 @@ at91_usart_bus_attach(struct uart_softc *sc)
atsc->ping = &atsc->ping_pong[0];
atsc->pong = &atsc->ping_pong[1];
}
#endif
/*
* Prime the pump with the RX buffer. We use two 64 byte bounce
@ -414,34 +408,25 @@ at91_usart_bus_attach(struct uart_softc *sc)
WR4(&sc->sc_bas, USART_IER, USART_CSR_RXRDY);
}
WR4(&sc->sc_bas, USART_IER, USART_CSR_RXBRK);
#ifndef SKYEYE_WORKAROUNDS
errout:;
// XXX bad
return (err);
#else
return (0);
#endif
}
static int
at91_usart_bus_transmit(struct uart_softc *sc)
{
#ifndef SKYEYE_WORKAROUNDS
bus_addr_t addr;
#endif
struct at91_usart_softc *atsc;
atsc = (struct at91_usart_softc *)sc;
#ifndef SKYEYE_WORKAROUNDS
if (bus_dmamap_load(atsc->dmatag, atsc->tx_map, sc->sc_txbuf,
sc->sc_txdatasz, at91_getaddr, &addr, 0) != 0)
return (EAGAIN);
bus_dmamap_sync(atsc->dmatag, atsc->tx_map, BUS_DMASYNC_PREWRITE);
#endif
uart_lock(sc->sc_hwmtx);
sc->sc_txbusy = 1;
#ifndef SKYEYE_WORKAROUNDS
/*
* Setup the PDC to transfer the data and interrupt us when it
* is done. We've already requested the interrupt.
@ -451,15 +436,6 @@ at91_usart_bus_transmit(struct uart_softc *sc)
WR4(&sc->sc_bas, PDC_PTCR, PDC_PTCR_TXTEN);
WR4(&sc->sc_bas, USART_IER, USART_CSR_ENDTX);
uart_unlock(sc->sc_hwmtx);
#else
for (int i = 0; i < sc->sc_txdatasz; i++)
at91_usart_putc(&sc->sc_bas, sc->sc_txbuf[i]);
/*
* XXX: Gross hack : Skyeye doesn't raise an interrupt once the
* transfer is done, so simulate it.
*/
WR4(&sc->sc_bas, USART_IER, USART_CSR_TXRDY);
#endif
return (0);
}
static int

View File

@ -1,85 +0,0 @@
# SKYEYE -- Kernel configuration for running the skyeye simulator
# simulating the Atmel AT91RM9200.
#
# For more information on this file, please read the handbook section on
# Kernel Configuration Files:
#
# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
#
# The handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
# latest information.
#
# An exhaustive list of options and more detailed explanations of the
# device lines is also present in the ../../conf/NOTES and NOTES files.
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
# $FreeBSD$
ident KB920X
options KERNPHYSADDR=0xc0000000
options KERNVIRTADDR=0xc0000000
options PHYSADDR=0xc0000000
include "../at91/std.kb920x"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
makeoptions CONF_CFLAGS=-mcpu=arm9
options DDB
options KDB
options SCHED_4BSD #4BSD scheduler
options INET #InterNETworking
options INET6 #IPv6 communications protocols
options FFS #Berkeley Fast Filesystem
options SOFTUPDATES #Enable FFS soft updates support
options UFS_ACL #Support for access control lists
options UFS_DIRHASH #Improve performance on big directories
options MD_ROOT #MD is a potential root device
options MD_ROOT_SIZE=4096
options ROOTDEVNAME=\"ufs:md0\"
options NFSCLIENT #Network Filesystem Client
options NFSSERVER #Network Filesystem Server
options NFSLOCKD #Network Lock Manager
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
#options MSDOSFS #MSDOS Filesystem
options CD9660 #ISO 9660 Filesystem
#options PROCFS #Process filesystem (requires PSEUDOFS)
options PSEUDOFS #Pseudo-filesystem framework
options SCSI_DELAY=5000 #Delay (in ms) before probing SCSI
#options KTRACE #ktrace(1) support
options SYSVSHM #SYSV-style shared memory
options SYSVMSG #SYSV-style message queues
options SYSVSEM #SYSV-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
device loop
device ether
#device saarm
device rl
device uart
#options AHC_REG_PRETTY_PRINT # Print register bitfields in debug
# output. Adds ~128k to driver.
#options AHD_REG_PRETTY_PRINT # Print register bitfields in debug
# output. Adds ~215k to driver.
# Debugging for use in -current
#options DEADLKRES #Enable the deadlock resolver
#options INVARIANTS #Enable calls of extra sanity checking
#options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS #Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed
# To make an SMP kernel, the next two are needed
#options SMP # Symmetric MultiProcessor Kernel
#options APIC_IO # Symmetric (APIC) I/O
device md
options SKYEYE_WORKAROUNDS
# Floppy drives

View File

@ -35,8 +35,6 @@
*
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -210,6 +208,9 @@ initarm(void *arg, void *arg2)
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
/* Do basic tuning, hz etc */
init_param1();
freemempos = (lastaddr + PAGE_MASK) & ~PAGE_MASK;
/* Define a macro to simplify memory allocation */
@ -251,7 +252,7 @@ initarm(void *arg, void *arg2)
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
/*
* Now we start construction of the L1 page table
@ -293,7 +294,7 @@ initarm(void *arg, void *arg2)
pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
L1_TABLE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
pmap_map_chunk(l1pagetable, msgbufpv.pv_va, msgbufpv.pv_pa,
MSGBUF_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
msgbufsize, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
pmap_map_chunk(l1pagetable, kernel_pt_table[loop].pv_va,
@ -372,7 +373,7 @@ initarm(void *arg, void *arg2)
&kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
@ -386,8 +387,6 @@ initarm(void *arg, void *arg2)
phys_avail[i++] = PHYSADDR + memsize;
phys_avail[i++] = 0;
phys_avail[i++] = 0;
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();

View File

@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/linker_set.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>

View File

@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/linker_set.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>

View File

@ -40,8 +40,6 @@
* type converted according to the integral promotions. The subtraction for
* INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
* These numbers are for the default configuration of gcc. They work for
* some other compilers as well, but this should not be depended on.
*/
#define __CHAR_BIT 8 /* number of bits in a char */
@ -55,20 +53,13 @@
#define __SHRT_MAX 0x7fff /* max value for a short */
#define __SHRT_MIN (-0x7fff - 1) /* min value for a short */
#define __UINT_MAX 0xffffffffU /* max value for an unsigned int */
#define __UINT_MAX 0xffffffff /* max value for an unsigned int */
#define __INT_MAX 0x7fffffff /* max value for an int */
#define __INT_MIN (-0x7fffffff - 1) /* min value for an int */
/* Bad hack for gcc configured to give 64-bit longs. */
#ifdef _LARGE_LONG
#define __ULONG_MAX 0xffffffffffffffffUL
#define __LONG_MAX 0x7fffffffffffffffL
#define __LONG_MIN (-0x7fffffffffffffffL - 1)
#else
#define __ULONG_MAX 0xffffffffUL /* max value for an unsigned long */
#define __LONG_MAX 0x7fffffffL /* max value for a long */
#define __LONG_MIN (-0x7fffffffL - 1) /* min value for a long */
#endif
/* max value for an unsigned long long */
#define __ULLONG_MAX 0xffffffffffffffffULL
@ -87,11 +78,7 @@
#define __QUAD_MAX __LLONG_MAX /* max value for a quad_t */
#define __QUAD_MIN __LLONG_MIN /* min value for a quad_t */
#ifdef _LARGE_LONG
#define __LONG_BIT 64
#else
#define __LONG_BIT 32
#endif
#define __WORD_BIT 32
/* Minimum signal stack size. */

View File

@ -45,8 +45,8 @@
#define UINT32_C(c) (c ## U)
#define UINT64_C(c) (c ## ULL)
#define INTMAX_C(c) (c ## LL)
#define UINTMAX_C(c) (c ## ULL)
#define INTMAX_C(c) INT64_C(c)
#define UINTMAX_C(c) UINT64_C(c)
#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */

View File

@ -52,16 +52,16 @@ typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
#ifdef __GNUCLIKE_ATTRIBUTE_MODE_DI
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
#else
#ifndef lint
__extension__
#endif
/* LONGLONG */
typedef long long __int64_t;
#ifndef lint
__extension__
#endif
/* LONGLONG */
typedef unsigned long long __uint64_t;
#endif
/*
* Standard type definitions.

View File

@ -82,8 +82,9 @@ __ElfType(Auxinfo);
#define AT_NCPUS 19 /* Number of CPUs. */
#define AT_PAGESIZES 20 /* Pagesizes. */
#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */
#define AT_STACKPROT 23 /* Initial stack protection. */
#define AT_COUNT 22 /* Count of defined aux entry types. */
#define AT_COUNT 24 /* Count of defined aux entry types. */
#define R_ARM_COUNT 33 /* Count of defined relocation types. */

View File

@ -44,6 +44,9 @@
/* Max interrupt number */
#define FDT_INTR_MAX NIRQ
/* Map phandle/intpin pair to global IRQ number */
#define FDT_MAP_IRQ(node, pin) (pin)
/*
* Bus space tag. XXX endianess info needs to be derived from the blob.
*/

View File

@ -26,6 +26,9 @@
* $FreeBSD$
*/
#ifndef _MACHINE_MEMDEV_H_
#define _MACHINE_MEMDEV_H_
#define CDEV_MINOR_MEM 0
#define CDEV_MINOR_KMEM 1
@ -34,4 +37,4 @@ d_read_t memrw;
d_mmap_t memmmap;
#define memioctl (d_ioctl_t *)NULL
void dev_mem_md_init(void);
#endif /* _MACHINE_MEMDEV_H_ */

View File

@ -29,6 +29,7 @@
#ifndef _MACHINE_METADATA_H_
#define _MACHINE_METADATA_H_
#define MODINFOMD_DTBP 0x1001
#define MODINFOMD_BOOTINFO 0x1001
#define MODINFOMD_DTBP 0x1002
#endif /* !_MACHINE_METADATA_H_ */

View File

@ -134,9 +134,7 @@ struct pmap {
struct l1_ttable *pm_l1;
struct l2_dtable *pm_l2[L2_SIZE];
pd_entry_t *pm_pdir; /* KVA of page directory */
uint32_t pm_gen_count; /* generation count (pmap lock dropped) */
u_int pm_retries;
cpumask_t pm_active; /* active on cpus */
cpumask_t pm_active; /* active on cpus */
struct pmap_statistics pm_stats; /* pmap statictics */
TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */
};
@ -204,7 +202,7 @@ vtopte(vm_offset_t va)
return (ptep);
}
extern vm_offset_t phys_avail[];
extern vm_paddr_t phys_avail[];
extern vm_offset_t virtual_avail;
extern vm_offset_t virtual_end;
@ -336,10 +334,6 @@ extern int pmap_needs_pte_sync;
#endif /* ARM_NMMUS > 1 */
#ifdef SKYEYE_WORKAROUNDS
#define PMAP_NEEDS_PTE_SYNC 1
#define PMAP_INCLUDE_PTE_SYNC
#else
#if (ARM_MMU_SA1 == 1) && (ARM_NMMUS == 1)
#define PMAP_NEEDS_PTE_SYNC 1
#define PMAP_INCLUDE_PTE_SYNC
@ -349,7 +343,6 @@ extern int pmap_needs_pte_sync;
#elif (ARM_MMU_SA1 == 0)
#define PMAP_NEEDS_PTE_SYNC 0
#endif
#endif
/*
* These macros return various bits based on kernel/user and protection.

View File

@ -50,7 +50,7 @@ struct mdthread {
register_t md_saved_cspr; /* (k) */
int md_ptrace_instr;
int md_ptrace_addr;
void *md_tp;
register_t md_tp;
void *md_ras_start;
void *md_ras_end;
};

View File

@ -146,7 +146,6 @@
#define DFLSSIZ (2*1024*1024)
#define MAXSSIZ (8*1024*1024)
#define SGROWSIZ (128*1024)
#define MAXSLP 20
#ifdef ARM_USE_SMALL_ALLOC
#define UMA_MD_SMALL_ALLOC

View File

@ -64,7 +64,6 @@ struct mv_gpio_softc {
bus_space_handle_t bsh;
uint8_t pin_num; /* number of GPIO pins */
uint8_t irq_num; /* number of real IRQs occupied by GPIO controller */
uint8_t use_high;
};
extern struct resource_spec mv_gpio_res[];
@ -74,7 +73,7 @@ static uint32_t gpio_setup[MV_GPIO_MAX_NPINS];
static int mv_gpio_probe(device_t);
static int mv_gpio_attach(device_t);
static void mv_gpio_intr(void *);
static int mv_gpio_intr(void *);
static void mv_gpio_intr_handler(int pin);
static uint32_t mv_gpio_reg_read(uint32_t reg);
@ -141,7 +140,6 @@ mv_gpio_attach(device_t dev)
uint32_t dev_id, rev_id;
sc = (struct mv_gpio_softc *)device_get_softc(dev);
if (sc == NULL)
return (ENXIO);
@ -156,12 +154,10 @@ mv_gpio_attach(device_t dev)
dev_id == MV_DEV_MV78100_Z0 ) {
sc->pin_num = 32;
sc->irq_num = 4;
sc->use_high = 0;
} else if (dev_id == MV_DEV_88F6281) {
sc->pin_num = 50;
sc->irq_num = 7;
sc->use_high = 1;
} else {
device_printf(dev, "unknown chip id=0x%x\n", dev_id);
@ -182,7 +178,7 @@ mv_gpio_attach(device_t dev)
bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_LEV_MASK, 0);
bus_space_write_4(sc->bst, sc->bsh, GPIO_INT_CAUSE, 0);
if (sc->use_high) {
if (sc->pin_num > GPIO_PINS_PER_REG) {
bus_space_write_4(sc->bst, sc->bsh,
GPIO_HI_INT_EDGE_MASK, 0);
bus_space_write_4(sc->bst, sc->bsh,
@ -193,8 +189,7 @@ mv_gpio_attach(device_t dev)
for (i = 0; i < sc->irq_num; i++) {
if (bus_setup_intr(dev, sc->res[1 + i],
INTR_TYPE_MISC | INTR_FAST,
(driver_filter_t *)mv_gpio_intr, NULL,
INTR_TYPE_MISC, mv_gpio_intr, NULL,
sc, &sc->ih_cookie[i]) != 0) {
bus_release_resources(dev, mv_gpio_res, sc->res);
device_printf(dev, "could not set up intr %d\n", i);
@ -208,7 +203,7 @@ mv_gpio_attach(device_t dev)
return (0);
}
static void
static int
mv_gpio_intr(void *arg)
{
uint32_t int_cause, gpio_val;
@ -218,7 +213,7 @@ mv_gpio_intr(void *arg)
int_cause = mv_gpio_reg_read(GPIO_INT_CAUSE);
gpio_val = mv_gpio_reg_read(GPIO_DATA_IN);
gpio_val &= int_cause;
if (mv_gpio_softc->use_high) {
if (mv_gpio_softc->pin_num > GPIO_PINS_PER_REG) {
int_cause_hi = mv_gpio_reg_read(GPIO_HI_INT_CAUSE);
gpio_val_hi = mv_gpio_reg_read(GPIO_HI_DATA_IN);
gpio_val_hi &= int_cause_hi;
@ -232,7 +227,7 @@ mv_gpio_intr(void *arg)
i++;
}
if (mv_gpio_softc->use_high) {
if (mv_gpio_softc->pin_num > GPIO_PINS_PER_REG) {
i = 0;
while (gpio_val_hi != 0) {
if (gpio_val_hi & 1)
@ -241,6 +236,8 @@ mv_gpio_intr(void *arg)
i++;
}
}
return (FILTER_HANDLED);
}
/*

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <machine/bus.h>
@ -143,27 +144,38 @@ static devclass_t mv_ic_devclass;
DRIVER_MODULE(ic, simplebus, mv_ic_driver, mv_ic_devclass, 0, 0);
int
arm_get_next_irq(int last __unused)
arm_get_next_irq(int last)
{
int irq;
u_int filt, irq;
int next;
filt = ~((last >= 0) ? (2 << last) - 1 : 0);
irq = mv_ic_get_cause() & mv_ic_get_mask();
if (irq)
return (ffs(irq) - 1);
if (irq & filt) {
next = ffs(irq & filt) - 1;
goto out;
}
if (mv_ic_sc->ic_high_regs) {
filt = ~((last >= 32) ? (2 << (last - 32)) - 1 : 0);
irq = mv_ic_get_cause_hi() & mv_ic_get_mask_hi();
if (irq)
return (ffs(irq) + 31);
if (irq & filt) {
next = ffs(irq & filt) + 31;
goto out;
}
}
if (mv_ic_sc->ic_error_regs) {
filt = ~((last >= 64) ? (2 << (last - 64)) - 1 : 0);
irq = mv_ic_get_cause_error() & mv_ic_get_mask_error();
if (irq)
return (ffs(irq) + 63);
if (irq & filt) {
next = ffs(irq & filt) + 63;
goto out;
}
}
next = -1;
return (-1);
out:
CTR3(KTR_INTR, "%s: last=%d, next=%d", __func__, last, next);
return (next);
}
static void

View File

@ -35,7 +35,6 @@
* from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45
*/
#include "opt_msgbuf.h"
#include "opt_ddb.h"
#include "opt_platform.h"
@ -119,6 +118,10 @@ extern unsigned char _edata[];
extern unsigned char __bss_start[];
extern unsigned char _end[];
#ifdef DDB
extern vm_offset_t ksym_start, ksym_end;
#endif
extern u_int data_abort_handler_address;
extern u_int prefetch_abort_handler_address;
extern u_int undefined_handler_address;
@ -331,6 +334,10 @@ initarm(void *mdp, void *unused __unused)
dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
lastaddr = MD_FETCH(kmdp, MODINFOMD_KERNEND,
vm_offset_t);
#ifdef DDB
ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
#endif
}
} else {
@ -427,7 +434,10 @@ initarm(void *mdp, void *unused __unused)
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
init_param1();
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
/*
* Now we start construction of the L1 page table
@ -575,7 +585,7 @@ initarm(void *mdp, void *unused __unused)
pmap_bootstrap(freemempos, pmap_bootstrap_lastaddr, &kernel_l1pt);
msgbufp = (void *)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
/*
@ -584,7 +594,6 @@ initarm(void *mdp, void *unused __unused)
physmap_init();
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -

View File

@ -212,23 +212,17 @@ static struct mtx pcicfg_mtx;
static int
mv_pcib_probe(device_t self)
{
phandle_t parnode;
phandle_t node;
/*
* The PCI subnode does not have the 'compatible' property, so we need
* to check in the parent PCI node. However the parent is not
* represented by a separate ofw_bus child, and therefore
* ofw_bus_is_compatible() cannot be used, but direct fdt equivalent.
*/
parnode = OF_parent(ofw_bus_get_node(self));
if (parnode == 0)
node = ofw_bus_get_node(self);
if (!fdt_is_type(node, "pci"))
return (ENXIO);
if (!(fdt_is_compatible(parnode, "mrvl,pcie") ||
fdt_is_compatible(parnode, "mrvl,pci")))
if (!(fdt_is_compatible(node, "mrvl,pcie") ||
fdt_is_compatible(node, "mrvl,pci")))
return (ENXIO);
device_set_desc(self, "Marvell Integrated PCI/PCI-E Controller");
return (BUS_PROBE_DEFAULT);
}
@ -243,15 +237,16 @@ mv_pcib_attach(device_t self)
sc = device_get_softc(self);
sc->sc_dev = self;
parnode = OF_parent(ofw_bus_get_node(self));
if (fdt_is_compatible(parnode, "mrvl,pcie")) {
node = ofw_bus_get_node(self);
parnode = OF_parent(node);
if (fdt_is_compatible(node, "mrvl,pcie")) {
sc->sc_type = MV_TYPE_PCIE;
sc->sc_mem_win_target = MV_WIN_PCIE_MEM_TARGET;
sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR;
sc->sc_io_win_target = MV_WIN_PCIE_IO_TARGET;
sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR;
#ifdef SOC_MV_ORION
} else if (fdt_is_compatible(parnode, "mrvl,pci")) {
} else if (fdt_is_compatible(node, "mrvl,pci")) {
sc->sc_type = MV_TYPE_PCI;
sc->sc_mem_win_target = MV_WIN_PCI_MEM_TARGET;
sc->sc_mem_win_attr = MV_WIN_PCI_MEM_ATTR;
@ -261,8 +256,6 @@ mv_pcib_attach(device_t self)
} else
return (ENXIO);
node = ofw_bus_get_node(self);
/*
* Get PCI interrupt info.
*/

View File

@ -150,6 +150,7 @@ mv_timer_attach(device_t dev)
write_cpu_ctrl(BRIDGE_IRQ_CAUSE, irq_cause);
irq_mask = read_cpu_ctrl(BRIDGE_IRQ_MASK);
irq_mask |= IRQ_TIMER0_MASK;
irq_mask &= ~IRQ_TIMER1_MASK;
write_cpu_ctrl(BRIDGE_IRQ_MASK, irq_mask);
sc->et.et_name = "CPUTimer0";
@ -229,7 +230,7 @@ DELAY(int usec)
if (!timers_initialized) {
for (; usec > 0; usec--)
for (val = 100; val > 0; val--)
;
__asm __volatile("nop" ::: "memory");
return;
}

View File

@ -200,7 +200,7 @@ cpu_initclocks(void)
if (!irq)
panic("Unable to allocate the clock irq handler.\n");
err = bus_setup_intr(dev, irq, INTR_TYPE_CLK | INTR_FAST,
err = bus_setup_intr(dev, irq, INTR_TYPE_CLK,
clock_intr, NULL, NULL, &ihl);
if (err != 0)
panic("Unable to setup the clock irq handler.\n");

View File

@ -43,7 +43,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include "opt_ddb.h"
#include <sys/cdefs.h>
@ -298,7 +297,7 @@ initarm(void *arg, void *arg2)
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
/*
* Now we start construction of the L1 page table
* We start by mapping the L2 page tables into the L1.
@ -338,7 +337,7 @@ initarm(void *arg, void *arg2)
pmap_map_chunk(l1pagetable, kernel_l1pt.pv_va, kernel_l1pt.pv_pa,
L1_TABLE_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
pmap_map_chunk(l1pagetable, msgbufpv.pv_va, msgbufpv.pv_pa,
MSGBUF_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
msgbufsize, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
@ -429,7 +428,7 @@ initarm(void *arg, void *arg2)
KERNVIRTADDR + 3 * memsize,
&kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
physmem = memsize / PAGE_SIZE;

View File

@ -1,10 +1,10 @@
#$FreeBSD$
include "../s3c2xx0/std.s3c2410"
makeoptions KERNPHYSADDR=0x30408000
makeoptions KERNVIRTADDR=0xc0408000
options KERNPHYSADDR=0x30408000
options KERNVIRTADDR=0xc0408000
makeoptions KERNPHYSADDR=0x30000000
makeoptions KERNVIRTADDR=0xc0000000
options KERNPHYSADDR=0x30000000
options KERNVIRTADDR=0xc0000000
options PHYSADDR=0x30000000
options STARTUP_PAGETABLE_ADDR=0x30800000

View File

@ -226,6 +226,9 @@ initarm(void *arg, void *arg2)
pcpu_init(pc, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
/* Do basic tuning, hz etc */
init_param1();
physical_start = (vm_offset_t) KERNBASE;
physical_end = lastaddr;
physical_freestart = (((vm_offset_t)physical_end) + PAGE_MASK) & ~PAGE_MASK;
@ -408,8 +411,6 @@ initarm(void *arg, void *arg2)
mutex_init();
pmap_bootstrap(freemempos, 0xd0000000, &kernel_l1pt);
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -

View File

@ -45,8 +45,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -212,6 +210,9 @@ initarm(void *arg, void *arg2)
(var) = freemempos; \
memset((char *)(var), 0, ((np) * PAGE_SIZE));
/* Do basic tuning, hz etc */
init_param1();
while (((freemempos - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) != 0)
freemempos -= PAGE_SIZE;
valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
@ -247,7 +248,7 @@ initarm(void *arg, void *arg2)
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
alloc_pages(minidataclean.pv_pa, 1);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
#ifdef ARM_USE_SMALL_ALLOC
freemempos -= PAGE_SIZE;
freemem_pt = trunc_page(freemem_pt);
@ -397,7 +398,7 @@ initarm(void *arg, void *arg2)
pmap_bootstrap(pmap_curmaxkvaddr,
0xd0000000, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;
@ -413,8 +414,6 @@ initarm(void *arg, void *arg2)
phys_avail[i++] = 0;
phys_avail[i] = 0;
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -

View File

@ -45,8 +45,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -202,6 +200,9 @@ initarm(void *arg, void *arg2)
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
/* Do basic tuning, hz etc */
init_param1();
freemempos = 0xa0200000;
/* Define a macro to simplify memory allocation */
#define valloc_pages(var, np) \
@ -247,7 +248,7 @@ initarm(void *arg, void *arg2)
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
alloc_pages(minidataclean.pv_pa, 1);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
#ifdef ARM_USE_SMALL_ALLOC
freemempos -= PAGE_SIZE;
freemem_pt = trunc_page(freemem_pt);
@ -403,7 +404,7 @@ initarm(void *arg, void *arg2)
pmap_bootstrap(pmap_curmaxkvaddr,
0xd0000000, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;
@ -419,8 +420,6 @@ initarm(void *arg, void *arg2)
phys_avail[i++] = 0;
phys_avail[i] = 0;
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();
return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -

View File

@ -45,8 +45,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -242,7 +240,7 @@ initarm(void *arg, void *arg2)
valloc_pages(abtstack, ABT_STACK_SIZE);
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
#ifdef ARM_USE_SMALL_ALLOC
freemempos -= PAGE_SIZE;
freemem_pt = trunc_page(freemem_pt);
@ -375,7 +373,7 @@ initarm(void *arg, void *arg2)
pmap_bootstrap(pmap_curmaxkvaddr,
0xd0000000, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;

View File

@ -148,7 +148,7 @@ avila_gpio_pin_configure(struct avila_gpio_softc *sc, struct gpio_pin *pin,
* Manage input/output
*/
if (flags & (GPIO_PIN_INPUT|GPIO_PIN_OUTPUT)) {
IXP4XX_GPIO_LOCK(sc);
IXP4XX_GPIO_LOCK();
pin->gp_flags &= ~(GPIO_PIN_INPUT|GPIO_PIN_OUTPUT);
if (flags & GPIO_PIN_OUTPUT) {
pin->gp_flags |= GPIO_PIN_OUTPUT;
@ -158,7 +158,7 @@ avila_gpio_pin_configure(struct avila_gpio_softc *sc, struct gpio_pin *pin,
pin->gp_flags |= GPIO_PIN_INPUT;
GPIO_SET_BITS(sc, IXP425_GPIO_GPOER, mask);
}
IXP4XX_GPIO_UNLOCK(sc);
IXP4XX_GPIO_UNLOCK();
}
}
@ -190,11 +190,11 @@ avila_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & (1 << pin)))
return (EINVAL);
IXP4XX_GPIO_LOCK(sc);
IXP4XX_GPIO_LOCK();
/* refresh since we do not own all the pins */
sc->sc_pins[pin].gp_flags = avila_gpio_pin_flags(sc, pin);
*flags = sc->sc_pins[pin].gp_flags;
IXP4XX_GPIO_UNLOCK(sc);
IXP4XX_GPIO_UNLOCK();
return (0);
}
@ -242,12 +242,12 @@ avila_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & mask))
return (EINVAL);
IXP4XX_GPIO_LOCK(sc);
IXP4XX_GPIO_LOCK();
if (value)
GPIO_SET_BITS(sc, IXP425_GPIO_GPOUTR, mask);
else
GPIO_CLEAR_BITS(sc, IXP425_GPIO_GPOUTR, mask);
IXP4XX_GPIO_UNLOCK(sc);
IXP4XX_GPIO_UNLOCK();
return (0);
}
@ -260,9 +260,9 @@ avila_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val)
if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & (1 << pin)))
return (EINVAL);
IXP4XX_GPIO_LOCK(sc);
IXP4XX_GPIO_LOCK();
*val = (GPIO_CONF_READ_4(sc, IXP425_GPIO_GPINR) & (1 << pin)) ? 1 : 0;
IXP4XX_GPIO_UNLOCK(sc);
IXP4XX_GPIO_UNLOCK();
return (0);
}
@ -277,13 +277,13 @@ avila_gpio_pin_toggle(device_t dev, uint32_t pin)
if (pin >= IXP4XX_GPIO_PINS || !(sc->sc_valid & mask))
return (EINVAL);
IXP4XX_GPIO_LOCK(sc);
IXP4XX_GPIO_LOCK();
res = GPIO_CONF_READ_4(sc, IXP425_GPIO_GPINR) & mask;
if (res)
GPIO_CLEAR_BITS(sc, IXP425_GPIO_GPOUTR, mask);
else
GPIO_SET_BITS(sc, IXP425_GPIO_GPOUTR, mask);
IXP4XX_GPIO_UNLOCK(sc);
IXP4XX_GPIO_UNLOCK();
return (0);
}

View File

@ -45,8 +45,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@ -247,6 +245,9 @@ initarm(void *arg, void *arg2)
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
/* Do basic tuning, hz etc */
init_param1();
/*
* We allocate memory downwards from where we were loaded
* by RedBoot; first the L1 page table, then NUM_KERNEL_PTS
@ -314,7 +315,7 @@ initarm(void *arg, void *arg2)
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
alloc_pages(minidataclean.pv_pa, 1);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
#ifdef ARM_USE_SMALL_ALLOC
freemempos -= PAGE_SIZE;
freemem_pt = trunc_page(freemem_pt);
@ -460,7 +461,7 @@ initarm(void *arg, void *arg2)
pmap_bootstrap(pmap_curmaxkvaddr, 0xd0000000, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;
@ -476,8 +477,6 @@ initarm(void *arg, void *arg2)
phys_avail[i++] = 0;
phys_avail[i] = 0;
/* Do basic tuning, hz etc */
init_param1();
init_param2(physmem);
kdb_init();

View File

@ -45,7 +45,6 @@
* Created : 17/09/94
*/
#include "opt_msgbuf.h"
#include "opt_ddb.h"
#include <sys/cdefs.h>
@ -229,7 +228,7 @@ initarm(void *arg, void *arg2)
valloc_pages(undstack, UND_STACK_SIZE);
valloc_pages(kernelstack, KSTACK_PAGES);
alloc_pages(minidataclean.pv_pa, 1);
valloc_pages(msgbufpv, round_page(MSGBUF_SIZE) / PAGE_SIZE);
valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
#ifdef ARM_USE_SMALL_ALLOC
freemempos -= PAGE_SIZE;
freemem_pt = trunc_page(freemem_pt);
@ -393,7 +392,7 @@ initarm(void *arg, void *arg2)
dump_avail[i] = 0;
pmap_bootstrap(pmap_curmaxkvaddr, 0xd0000000, &kernel_l1pt);
msgbufp = (void*)msgbufpv.pv_va;
msgbufinit(msgbufp, MSGBUF_SIZE);
msgbufinit(msgbufp, msgbufsize);
mutex_init();
i = 0;

View File

@ -24,7 +24,6 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(start)
SEARCH_DIR(/usr/local/arm/2.95.3/arm-linux/lib);
SECTIONS
{
/* Read-only sections, merged into text segment: */

View File

@ -24,9 +24,6 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(start)
SEARCH_DIR(/usr/local/arm/2.95.3/arm-linux/lib);
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */

View File

@ -609,6 +609,14 @@ Note that
the NBUF parameter will override this limit.
Modifies
.Dv VM_BCACHE_SIZE_MAX .
.It Va kern.msgbufsize
Sets the size of the kernel message buffer.
The default limit of 64KB is usually sufficient unless
large amounts of trace data need to be collected
between opportunities to examine the buffer or
dump it to a file.
Overrides kernel option
.Dv MSGBUF_SIZE .
.It Va machdep.disable_mtrrs
Disable the use of i686 MTRRs (x86 only).
.It Va net.inet.tcp.tcbhashsize

View File

@ -122,7 +122,7 @@ lookup(const char *path)
const char *s;
ino_t ino;
ssize_t n;
int dt;
uint8_t dt;
ino = ROOTINO;
dt = DT_DIR;

View File

@ -262,6 +262,7 @@ efinet_dev_init()
int err, i, nifs;
sz = 0;
handles = NULL;
status = BS->LocateHandle(ByProtocol, &sn_guid, 0, &sz, 0);
if (status == EFI_BUFFER_TOO_SMALL) {
handles = (EFI_HANDLE *)malloc(sz);

View File

@ -69,6 +69,7 @@ efipart_init(void)
int err;
sz = 0;
hin = NULL;
status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, 0);
if (status == EFI_BUFFER_TOO_SMALL) {
hin = (EFI_HANDLE *)malloc(sz * 2);

View File

@ -308,8 +308,36 @@
};
};
pci0: pcie@f1040000 {
compatible = "mrvl,pcie";
device_type = "pci";
#interrupt-cells = <1>;
#size-cells = <2>;
#address-cells = <3>;
reg = <0xf1040000 0x2000>;
bus-range = <0 255>;
ranges = <0x02000000 0x0 0xf2000000 0xf2000000 0x0 0x04000000
0x01000000 0x0 0x00000000 0xf1100000 0x0 0x00100000>;
clock-frequency = <33333333>;
interrupt-parent = <&PIC>;
interrupts = <68>;
interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
interrupt-map = <
/* IDSEL 0x1 */
0x0800 0x0 0x0 0x1 &PIC 0x20
0x0800 0x0 0x0 0x2 &PIC 0x21
0x0800 0x0 0x0 0x3 &PIC 0x22
0x0800 0x0 0x0 0x4 &PIC 0x23
>;
};
sram@fd000000 {
compatible = "mrvl,cesa-sram";
reg = <0xfd000000 0x00100000>;
};
chosen {
stdin = "serial0";
stdout = "serial0";
};
};

View File

@ -9,10 +9,7 @@ CLEANFILES= softcore.c testmain testmain.o
CFLAGS+= -ffreestanding
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -mpreferred-stack-boundary=2
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2
.endif
.if ${MACHINE_CPUARCH} == "i386"
CFLAGS+= -mno-sse3
CFLAGS+= -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
.endif
.if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm"
CFLAGS+= -msoft-float

View File

@ -193,7 +193,7 @@ at-xy ." `--{__________) "
then
else
menuidx @
1+ dup
1+
menuidx !
-2 bootacpikey !
then

View File

@ -99,6 +99,7 @@ module_path="/boot/modules" # Set the module search path
#kern.maxswzone="" # Set the max swmeta KVA storage
#kern.maxtsiz="" # Set the max text size
#kern.maxusers="32" # Set size of various static tables
#kern.msgbufsize="65536" # Set size of kernel message buffer
#kern.nbuf="" # Set the number of buffer headers
#kern.ncallout="" # Set the maximum # of timer events
#kern.ngroups="1023" # Set the maximum # of supplemental groups
@ -251,6 +252,7 @@ pf_load="NO" # packet filter
### Networking drivers #####################################
##############################################################
bridgestp_load="NO" # if_bridge(4) support
miibus_load="NO" # miibus support, needed for some drivers
if_ae_load="NO" # Attansic/Atheros L2 FastEthernet
if_age_load="NO" # Attansic/Atheros L1 Gigabit Ethernet
@ -263,8 +265,10 @@ if_axe_load="NO" # ASIX Electronics AX88172 USB Ethernet
if_bce_load="NO" # Broadcom NetXtreme II Gigabit Ethernet
if_bfe_load="NO" # Broadcom BCM4401
if_bge_load="NO" # Broadcom BCM570x PCI Gigabit Ethernet
if_bridge_load="NO" # if_bridge(4) devices
if_bwi_load="NO" # Broadcom BCM53xx IEEE 802.11b/g wireness NICs
if_bwn_load="NO" # Broadcom BCM43xx IEEE 802.11 wireless NICs
if_carp_load="NO" # carp(4) devices
if_cas_load="NO" # Sun Cassini/Cassini+ and NS DP83065 Saturn
if_cm_load="NO" # SMC (90c26, 90c56, 90c66)
if_cs_load="NO" # Crystal Semiconductor CS8920
@ -295,6 +299,7 @@ if_iwn_load="NO" # Intel Wireless WiFi Link 802.11n wireless
if_ixgb_load="NO" # Intel PRO/10Gb Ethernet
if_ixgbe_load="NO" # Intel PRO/10Gb Ethernet PCI Express
if_jme_load="NO" # JMicron JMC250 Gigabit/JMC260 Fast Ethernet
if_lagg_load="NO" # lagg(4) devices
if_le_load="NO" # AMD Am7900 LANCE and Am79C9xx PCnet
if_lge_load="NO" # Level 1 LXT1001 NetCellerator PCI Gigabit
# Ethernet
@ -328,6 +333,7 @@ if_tl_load="NO" # Texas Instruments TNETE100 ("ThunderLAN")
if_tx_load="NO" # SMC 83c17x Fast Ethernet
if_txp_load="NO" # 3Com 3XP Typhoon/Sidewinder (3CR990)
if_vge_load="NO" # VIA VT6122 PCI Gigabit Ethernet
if_vte_load="NO" # DM&P Vortex86 RDC R6040 Fast Ethernet
if_uath_load="NO" # Atheros USB wireless for AR5005UG & AR5005UX
if_udav_load="NO" # Davicom DM9601 USB Ethernet
if_upgt_load="NO" # Conexant/Intersil PrismGT USB wireless

View File

@ -6,7 +6,7 @@ BINDIR?= /boot
LOADER_ADDRESS?=0x200000
CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 \
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
LDFLAGS+= -nostdlib
.if ${MACHINE_CPUARCH} == "amd64"

View File

@ -31,7 +31,6 @@ CFLAGS= -Os \
-fno-unit-at-a-time \
-mno-align-long-strings \
-mrtd \
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
-D${BOOT2_UFS} \
-DFLAGS=${BOOT_BOOT1_FLAGS} \
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \

View File

@ -132,7 +132,7 @@ static struct dsk {
} dsk;
static char cmd[512], cmddup[512];
static char kname[1024];
static uint32_t opts;
static uint16_t opts;
static int comspeed = SIOSPD;
static struct bootinfo bootinfo;
static uint8_t ioctrl = IO_KEYBOARD;
@ -233,7 +233,7 @@ putc(int c)
int
main(void)
{
int autoboot;
uint8_t autoboot;
ino_t ino;
dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
@ -320,7 +320,8 @@ load(void)
caddr_t p;
ino_t ino;
uint32_t addr, x;
int fmt, i, j;
int i, j;
uint8_t fmt;
if (!(ino = lookup(kname))) {
if (!ls)
@ -346,23 +347,6 @@ load(void)
p += roundup2(hdr.ex.a_text, PAGE_SIZE);
if (xfsread(ino, p, hdr.ex.a_data))
return;
p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
bootinfo.bi_symtab = VTOP(p);
*(uint32_t*)p = hdr.ex.a_syms;
p += sizeof(hdr.ex.a_syms);
if (hdr.ex.a_syms) {
if (xfsread(ino, p, hdr.ex.a_syms))
return;
p += hdr.ex.a_syms;
if (xfsread(ino, p, sizeof(int)))
return;
x = *(uint32_t *)p;
p += sizeof(int);
x -= sizeof(int);
if (xfsread(ino, p, x))
return;
p += x;
}
} else {
fs_off = hdr.eh.e_phoff;
for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
@ -394,8 +378,8 @@ load(void)
}
}
addr = hdr.eh.e_entry & 0xffffff;
bootinfo.bi_esymtab = VTOP(p);
}
bootinfo.bi_esymtab = VTOP(p);
bootinfo.bi_kernelname = VTOP(kname);
bootinfo.bi_bios_dev = dsk.drive;
__exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),

View File

@ -26,7 +26,6 @@ CFLAGS= -DBOOTPROG=\"gptboot\" \
-fno-unit-at-a-time \
-mno-align-long-strings \
-mrtd \
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
-DGPT \
-D${GPTBOOT_UFS} \
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \

View File

@ -23,7 +23,6 @@ CFLAGS= -DBOOTPROG=\"gptzfsboot\" \
-fno-unit-at-a-time \
-mno-align-long-strings \
-mrtd \
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
-DGPT -DBOOT2 \
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
-DSIOFMT=${B2SIOFMT} \

Some files were not shown because too many files have changed in this diff Show More