From e85c7466a34ad29d9301b09a555dfaa96f7c408c Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 22:24:45 +0000 Subject: [PATCH 001/164] MFC @ 221273 From d0e06d02bc16b86afdae303a0b8a82812a55e8ac Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 22:30:18 +0000 Subject: [PATCH 002/164] idle_cpus_mask is just used in the SMP case and within sched_4BSD. Declare appropriately. --- sys/kern/sched_4bsd.c | 2 ++ sys/kern/subr_smp.c | 1 - sys/sys/smp.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 9424f73d2d80..668ecd165e52 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -155,6 +155,8 @@ static struct runq runq; */ static struct runq runq_pcpu[MAXCPU]; long runq_length[MAXCPU]; + +static cpumask_t idle_cpus_mask; #endif struct pcpuidlestat { diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 9ae63810f72b..aba6f0e1ea7e 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #ifdef SMP volatile cpumask_t stopped_cpus; volatile cpumask_t started_cpus; -cpumask_t idle_cpus_mask; cpumask_t hlt_cpus_mask; cpumask_t logical_cpus_mask; diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 6104d3e22422..544cb9575f91 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -73,7 +73,6 @@ extern int smp_active; extern int smp_cpus; extern volatile cpumask_t started_cpus; extern volatile cpumask_t stopped_cpus; -extern cpumask_t idle_cpus_mask; extern cpumask_t hlt_cpus_mask; extern cpumask_t logical_cpus_mask; #endif /* SMP */ From 5d1f479a00fe7df60e46d8e0d48b5e50f09e026b Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 22:33:11 +0000 Subject: [PATCH 003/164] Remove unnecessary usage of memory barriers when dealing with pmc_cpumask. Discussed with: fabient --- sys/dev/hwpmc/hwpmc_mod.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 4fa169c6b349..55ed262e20f7 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf, done: /* mark CPU as needing processing */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); return (error); } @@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu) break; if (ps->ps_nsamples == PMC_SAMPLE_INUSE) { /* Need a rescan at a later time. */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); break; } @@ -4782,7 +4782,7 @@ pmc_cleanup(void) PMCDBG(MOD,INI,0, "%s", "cleanup"); /* switch off sampling */ - atomic_store_rel_int(&pmc_cpumask, 0); + atomic_store_int(&pmc_cpumask, 0); pmc_intr = NULL; sx_xlock(&pmc_sx); From 3fcaa270bf26cf5b7b13f23688accabede67dd29 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 22:34:44 +0000 Subject: [PATCH 004/164] Fix a typo/error. --- sys/dev/hwpmc/hwpmc_mod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 55ed262e20f7..d6225d8f5ae3 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -4782,7 +4782,7 @@ pmc_cleanup(void) PMCDBG(MOD,INI,0, "%s", "cleanup"); /* switch off sampling */ - atomic_store_int(&pmc_cpumask, 0); + pmc_cpumask = 0; pmc_intr = NULL; sx_xlock(&pmc_sx); From 05a159a130624404fd72473d6a0b3fc99176ea86 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 23:02:17 +0000 Subject: [PATCH 005/164] Remove the support for lazy cr3 switching from i386. amd64 has already this micro-optimization removed. Submitted by: kib --- sys/i386/i386/apic_vector.s | 16 ------- sys/i386/i386/db_trace.c | 3 +- sys/i386/i386/mp_machdep.c | 7 --- sys/i386/i386/pmap.c | 93 ------------------------------------- sys/i386/i386/swtch.s | 6 --- sys/i386/include/smp.h | 4 +- sys/i386/xen/pmap.c | 92 ------------------------------------ 7 files changed, 2 insertions(+), 219 deletions(-) diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s index 86e78c4beb2e..a78b60107e05 100644 --- a/sys/i386/i386/apic_vector.s +++ b/sys/i386/i386/apic_vector.s @@ -357,20 +357,4 @@ IDTVEC(rendezvous) POP_FRAME iret -/* - * Clean up when we lose out on the lazy context switch optimization. - * ie: when we are about to release a PTD but a cpu is still borrowing it. - */ - SUPERALIGN_TEXT -IDTVEC(lazypmap) - PUSH_FRAME - SET_KERNEL_SREGS - cld - - call pmap_lazyfix_action - - movl lapic, %eax - movl $0, LA_EOI(%eax) /* End Of Interrupt to APIC */ - POP_FRAME - iret #endif /* SMP */ diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 445d9c5fe0df..79da4dc576dc 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -312,8 +312,7 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) frame_type = TRAP_TIMERINT; else if (strcmp(name, "Xcpustop") == 0 || strcmp(name, "Xrendezvous") == 0 || - strcmp(name, "Xipi_intr_bitmap_handler") == 0 || - strcmp(name, "Xlazypmap") == 0) + strcmp(name, "Xipi_intr_bitmap_handler") == 0) frame_type = TRAP_INTERRUPT; } diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 871ccb49f5f0..a07b06c53f75 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -165,7 +165,6 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; -u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -552,10 +551,6 @@ cpu_mp_start(void) setidt(IPI_INVLCACHE, IDTVEC(invlcache), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); - /* Install an inter-CPU IPI for lazy pmap release */ - setidt(IPI_LAZYPMAP, IDTVEC(lazypmap), - SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); - /* Install an inter-CPU IPI for all-CPU rendezvous */ setidt(IPI_RENDEZVOUS, IDTVEC(rendezvous), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); @@ -1682,8 +1677,6 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:rendezvous", i); intrcnt_add(buf, &ipi_rendezvous_counts[i]); - snprintf(buf, sizeof(buf), "cpu%d:lazypmap", i); - intrcnt_add(buf, &ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:hardclock", i); intrcnt_add(buf, &ipi_hardclock_counts[i]); } diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index d10bbe5a7701..e1fe137e4d31 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1881,98 +1881,6 @@ pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags) * Pmap allocation/deallocation routines. ***************************************************/ -#ifdef SMP -/* - * Deal with a SMP shootdown of other users of the pmap that we are - * trying to dispose of. This can be a bit hairy. - */ -static cpumask_t *lazymask; -static u_int lazyptd; -static volatile u_int lazywait; - -void pmap_lazyfix_action(void); - -void -pmap_lazyfix_action(void) -{ - cpumask_t mymask = PCPU_GET(cpumask); - -#ifdef COUNT_IPIS - (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++; -#endif - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); - atomic_store_rel_int(&lazywait, 1); -} - -static void -pmap_lazyfix_self(cpumask_t mymask) -{ - - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); -} - - -static void -pmap_lazyfix(pmap_t pmap) -{ - cpumask_t mymask, mask; - u_int spins; - - while ((mask = pmap->pm_active) != 0) { - spins = 50000000; - mask = mask & -mask; /* Find least significant set bit */ - mtx_lock_spin(&smp_ipi_mtx); -#ifdef PAE - lazyptd = vtophys(pmap->pm_pdpt); -#else - lazyptd = vtophys(pmap->pm_pdir); -#endif - mymask = PCPU_GET(cpumask); - if (mask == mymask) { - lazymask = &pmap->pm_active; - pmap_lazyfix_self(mymask); - } else { - atomic_store_rel_int((u_int *)&lazymask, - (u_int)&pmap->pm_active); - atomic_store_rel_int(&lazywait, 0); - ipi_selected(mask, IPI_LAZYPMAP); - while (lazywait == 0) { - ia32_pause(); - if (--spins == 0) - break; - } - } - mtx_unlock_spin(&smp_ipi_mtx); - if (spins == 0) - printf("pmap_lazyfix: spun for 50000000\n"); - } -} - -#else /* SMP */ - -/* - * Cleaning up on uniprocessor is easy. For various reasons, we're - * unlikely to have to even execute this code, including the fact - * that the cleanup is deferred until the parent does a wait(2), which - * means that another userland process has run. - */ -static void -pmap_lazyfix(pmap_t pmap) -{ - u_int cr3; - - cr3 = vtophys(pmap->pm_pdir); - if (cr3 == rcr3()) { - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - pmap->pm_active &= ~(PCPU_GET(cpumask)); - } -} -#endif /* SMP */ - /* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. @@ -1990,7 +1898,6 @@ pmap_release(pmap_t pmap) KASSERT(pmap->pm_root == NULL, ("pmap_release: pmap has reserved page table page(s)")); - pmap_lazyfix(pmap); mtx_lock_spin(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 680b032557c9..654756910ea3 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -174,12 +174,6 @@ ENTRY(cpu_switch) /* switch address space */ movl PCB_CR3(%edx),%eax -#ifdef PAE - cmpl %eax,IdlePDPT /* Kernel address space? */ -#else - cmpl %eax,IdlePTD /* Kernel address space? */ -#endif - je sw0 READ_CR3(%ebx) /* The same address space? */ cmpl %ebx,%eax je sw0 diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index d364cd9ebbcc..b512e00b4228 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -42,7 +42,6 @@ extern u_long *ipi_invlrng_counts[MAXCPU]; extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; -extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ @@ -53,8 +52,7 @@ inthand_t IDTVEC(invlcache), /* Write back and invalidate cache */ IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ IDTVEC(cpustop), /* CPU stops & waits to be restarted */ - IDTVEC(rendezvous), /* handle CPU rendezvous */ - IDTVEC(lazypmap); /* handle lazy pmap release */ + IDTVEC(rendezvous); /* handle CPU rendezvous */ /* functions in mp_machdep.c */ void cpu_add(u_int apic_id, char boot_cpu); diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index eb3c803ca924..671e955812e0 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -1681,98 +1681,6 @@ pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags) * Pmap allocation/deallocation routines. ***************************************************/ -#ifdef SMP -/* - * Deal with a SMP shootdown of other users of the pmap that we are - * trying to dispose of. This can be a bit hairy. - */ -static cpumask_t *lazymask; -static u_int lazyptd; -static volatile u_int lazywait; - -void pmap_lazyfix_action(void); - -void -pmap_lazyfix_action(void) -{ - cpumask_t mymask = PCPU_GET(cpumask); - -#ifdef COUNT_IPIS - (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++; -#endif - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); - atomic_store_rel_int(&lazywait, 1); -} - -static void -pmap_lazyfix_self(cpumask_t mymask) -{ - - if (rcr3() == lazyptd) - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - atomic_clear_int(lazymask, mymask); -} - - -static void -pmap_lazyfix(pmap_t pmap) -{ - cpumask_t mymask, mask; - u_int spins; - - while ((mask = pmap->pm_active) != 0) { - spins = 50000000; - mask = mask & -mask; /* Find least significant set bit */ - mtx_lock_spin(&smp_ipi_mtx); -#ifdef PAE - lazyptd = vtophys(pmap->pm_pdpt); -#else - lazyptd = vtophys(pmap->pm_pdir); -#endif - mymask = PCPU_GET(cpumask); - if (mask == mymask) { - lazymask = &pmap->pm_active; - pmap_lazyfix_self(mymask); - } else { - atomic_store_rel_int((u_int *)&lazymask, - (u_int)&pmap->pm_active); - atomic_store_rel_int(&lazywait, 0); - ipi_selected(mask, IPI_LAZYPMAP); - while (lazywait == 0) { - ia32_pause(); - if (--spins == 0) - break; - } - } - mtx_unlock_spin(&smp_ipi_mtx); - if (spins == 0) - printf("pmap_lazyfix: spun for 50000000\n"); - } -} - -#else /* SMP */ - -/* - * Cleaning up on uniprocessor is easy. For various reasons, we're - * unlikely to have to even execute this code, including the fact - * that the cleanup is deferred until the parent does a wait(2), which - * means that another userland process has run. - */ -static void -pmap_lazyfix(pmap_t pmap) -{ - u_int cr3; - - cr3 = vtophys(pmap->pm_pdir); - if (cr3 == rcr3()) { - load_cr3(PCPU_GET(curpcb)->pcb_cr3); - pmap->pm_active &= ~(PCPU_GET(cpumask)); - } -} -#endif /* SMP */ - /* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. From 1ce93775ecf7328fdda6b30ca7461bec07e27812 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 23:12:37 +0000 Subject: [PATCH 006/164] Add the function md_assert_nopreempt(), which is a very consistent function on the possibility of a thread to not preempt. As this function is very tied to x86 (interrupts disabled checkings) it is not intended to be used in MI code. --- sys/amd64/amd64/mp_machdep.c | 16 ++++++++++++++++ sys/amd64/include/smp.h | 1 + sys/i386/i386/mp_machdep.c | 16 ++++++++++++++++ sys/i386/include/smp.h | 1 + sys/i386/xen/mp_machdep.c | 16 ++++++++++++++++ 5 files changed, 50 insertions(+) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 8e8dc67bdc1c..70ba466720f4 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -1428,6 +1428,22 @@ cpususpend_handler(void) intr_restore(rf); } +void +md_assert_nopreempt(void) +{ +#ifdef INVARIANTS + struct thread *td; + register_t rflags; + + td = curthread; + rflags = read_rflags(); + + if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) + panic("Preemption still allowed, thread %s\n", + (td->td_pinned <= 0) ? "not pinned" : "pinned"); +#endif +} + /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index ec107f931055..bafb349ced2f 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -64,6 +64,7 @@ void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpumask_t cpus, u_int ipi); +void md_assert_nopreempt(void); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index a07b06c53f75..f36bf1d5c0de 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -1486,6 +1486,22 @@ cpustop_handler(void) } } +void +md_assert_nopreempt(void) +{ +#ifdef INVARIANTS + struct thread *td; + register_t rflags; + + td = curthread; + rflags = read_rflags(); + + if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) + panic("Preemption still allowed, thread %s\n", + (td->td_pinned <= 0) ? "not pinned" : "pinned"); +#endif +} + /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index b512e00b4228..2e2ede4f66f1 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -65,6 +65,7 @@ void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpumask_t cpus, u_int ipi); +void md_assert_nopreempt(void); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 6e0fa2338f88..845fa439d854 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -1241,6 +1241,22 @@ cpustop_handler(void) } } +void +md_assert_nopreempt(void) +{ +#ifdef INVARIANTS + struct thread *td; + register_t rflags; + + td = curthread; + rflags = read_rflags(); + + if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) + panic("Preemption still allowed, thread %s\n", + (td->td_pinned <= 0) ? "not pinned" : "pinned"); +#endif +} + /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. From 7ac8b4739c3f301ecd125a4698c2731e3aef4366 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 30 Apr 2011 23:28:07 +0000 Subject: [PATCH 007/164] - Remove the following sysctl: kern.sched.ipiwakeup.onecpu kern.sched.ipiwakeup.htt2 Because they are absolutely obsolete. Probabilly the whole wakeup forward mechanism should be revisited for a better fitting in modern hw. - As map2 variable is no longer used rename map3 to map2 - Fix a string by making more informative the msg and removing the arguments passing Approved by: julian --- sys/kern/sched_4bsd.c | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 668ecd165e52..fef9e256f6bb 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -235,16 +235,6 @@ SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, useloop, CTLFLAG_RW, &forward_wakeup_use_loop, 0, "Use a loop to find idle cpus"); -static int forward_wakeup_use_single = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, onecpu, CTLFLAG_RW, - &forward_wakeup_use_single, 0, - "Only signal one idle cpu"); - -static int forward_wakeup_use_htt = 0; -SYSCTL_INT(_kern_sched_ipiwakeup, OID_AUTO, htt2, CTLFLAG_RW, - &forward_wakeup_use_htt, 0, - "account for htt"); - #endif #if 0 static int sched_followon = 0; @@ -1064,7 +1054,7 @@ static int forward_wakeup(int cpunum) { struct pcpu *pc; - cpumask_t dontuse, id, map, map2, map3, me; + cpumask_t dontuse, id, map, map2, me; mtx_assert(&sched_lock, MA_OWNED); @@ -1089,13 +1079,13 @@ forward_wakeup(int cpunum) return (0); dontuse = me | stopped_cpus | hlt_cpus_mask; - map3 = 0; + map2 = 0; if (forward_wakeup_use_loop) { SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; if ((id & dontuse) == 0 && pc->pc_curthread == pc->pc_idlethread) { - map3 |= id; + map2 |= id; } } } @@ -1106,33 +1096,19 @@ forward_wakeup(int cpunum) /* If they are both on, compare and use loop if different. */ if (forward_wakeup_use_loop) { - if (map != map3) { - printf("map (%02X) != map3 (%02X)\n", map, - map3); - map = map3; + if (map != map2) { + printf("map != map2, loop method preferred\n"); + map = map2; } } } else { - map = map3; + map = map2; } /* If we only allow a specific CPU, then mask off all the others. */ if (cpunum != NOCPU) { KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum.")); map &= (1 << cpunum); - } else { - /* Try choose an idle die. */ - if (forward_wakeup_use_htt) { - map2 = (map & (map >> 1)) & 0x5555; - if (map2) { - map = map2; - } - } - - /* Set only one bit. */ - if (forward_wakeup_use_single) { - map = map & ((~map) + 1); - } } if (map) { forward_wakeups_delivered++; From b55fd3d196536fe391b443cd24f7be3c4b5783ae Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 1 May 2011 00:08:13 +0000 Subject: [PATCH 008/164] Remove unnused typedef. --- sys/i386/include/xen/xenvar.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/i386/include/xen/xenvar.h b/sys/i386/include/xen/xenvar.h index 4f8c857fb36d..365930a7960a 100644 --- a/sys/i386/include/xen/xenvar.h +++ b/sys/i386/include/xen/xenvar.h @@ -99,7 +99,6 @@ void xpq_init(void); (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG) #define DECLARE_BITMAP(name,bits) \ unsigned long name[BITS_TO_LONGS(bits)] -typedef struct { DECLARE_BITMAP(bits, NR_CPUS); } xen_cpumask_t; int xen_create_contiguous_region(vm_page_t pages, int npages); From 8844d3fb82ff374bdbe0da16411eecfd786bbc77 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 2 May 2011 13:56:47 +0000 Subject: [PATCH 009/164] - Merge a fix fixup for the last lazyfix removal - Sync xen with i386 about the ipi_send_cpu() usage --- sys/i386/xen/mp_machdep.c | 81 ++++++++++++++------------------------- sys/i386/xen/pmap.c | 1 - 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 845fa439d854..2cd07627cb10 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -153,7 +153,6 @@ static cpumask_t hyperthreading_cpus_mask; extern void Xhypervisor_callback(void); extern void failsafe_callback(void); -extern void pmap_lazyfix_action(void); struct cpu_group * cpu_topo(void) @@ -340,24 +339,16 @@ iv_invlcache(uintptr_t a, uintptr_t b) atomic_add_int(&smp_tlb_wait, 1); } -static void -iv_lazypmap(uintptr_t a, uintptr_t b) -{ - pmap_lazyfix_action(); - atomic_add_int(&smp_tlb_wait, 1); -} - /* * These start from "IPI offset" APIC_IPI_INTS */ -static call_data_func_t *ipi_vectors[6] = +static call_data_func_t *ipi_vectors[5] = { iv_rendezvous, iv_invltlb, iv_invlpg, iv_invlrng, iv_invlcache, - iv_lazypmap, }; /* @@ -956,6 +947,30 @@ start_ap(int apic_id) return 0; /* return FAILURE */ } +/* + * send an IPI to a specific CPU. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (!old_pending) + ipi_pcpu(cpu, RESCHEDULE_VECTOR); + } else { + KASSERT(call_data != NULL, ("call_data not set")); + ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); + } +} + /* * Flush the TLB on all other CPU's */ @@ -1098,14 +1113,6 @@ void ipi_selected(cpumask_t cpus, u_int ipi) { int cpu; - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1115,23 +1122,11 @@ ipi_selected(cpumask_t cpus, u_int ipi) if (ipi == IPI_STOP_HARD) atomic_set_int(&ipi_nmi_pending, cpus); - CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi); while ((cpu = ffs(cpus)) != 0) { cpu--; cpus &= ~(1 << cpu); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (!old_pending) - ipi_pcpu(cpu, RESCHEDULE_VECTOR); - } else { - KASSERT(call_data != NULL, ("call_data not set")); - ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); - } + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); + ipi_send_cpu(cpu, ipi); } } @@ -1141,14 +1136,6 @@ ipi_selected(cpumask_t cpus, u_int ipi) void ipi_cpu(int cpu, u_int ipi) { - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1159,19 +1146,7 @@ ipi_cpu(int cpu, u_int ipi) atomic_set_int(&ipi_nmi_pending, 1 << cpu); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (!old_pending) - ipi_pcpu(cpu, RESCHEDULE_VECTOR); - } else { - KASSERT(call_data != NULL, ("call_data not set")); - ipi_pcpu(cpu, CALL_FUNCTION_VECTOR); - } + ipi_send_cpu(cpu, ipi); } /* diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index 671e955812e0..cf36f5edddb3 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -1706,7 +1706,6 @@ pmap_release(pmap_t pmap) mtx_lock(&createdelete_lock); #endif - pmap_lazyfix(pmap); mtx_lock_spin(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); From fd4965df40517e8f3eac90b6e4aa7e03bb3b5370 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 2 May 2011 14:23:36 +0000 Subject: [PATCH 010/164] MFC @ r221324 --- contrib/openresolv/resolvconf.conf.5.in | 2 +- sbin/mount_nfs/Makefile | 2 +- sbin/recoverdisk/recoverdisk.1 | 49 +++++++++++++-------- sbin/recoverdisk/recoverdisk.c | 19 +++++--- share/man/man4/vxge.4 | 5 +-- share/misc/bsd-family-tree | 3 +- sys/amd64/conf/GENERIC | 10 +++++ sys/amd64/pci/pci_bus.c | 1 + sys/conf/NOTES | 7 +++ sys/conf/files | 1 + sys/conf/kern.mk | 21 ++++----- sys/conf/options | 3 ++ sys/dev/acpica/acpi_pcib_acpi.c | 1 + sys/dev/pci/pci.c | 1 + sys/dev/pci/pci_pci.c | 1 + sys/dev/wpi/if_wpi.c | 4 +- sys/fs/nfs/nfs_commonport.c | 2 + sys/i386/conf/GENERIC | 10 +++++ sys/i386/pci/pci_bus.c | 1 + sys/mips/atheros/ar724x_pci.c | 38 ++++++---------- sys/mips/conf/PB92.hints | 6 ++- sys/nfs/nfssvc.h | 1 + sys/x86/x86/mptable_pci.c | 1 + sys/x86/x86/nexus.c | 58 ++++++++++++++++--------- usr.bin/man/man.sh | 16 ++++--- usr.bin/nfsstat/nfsstat.1 | 3 +- usr.bin/nfsstat/nfsstat.c | 9 ++-- 27 files changed, 173 insertions(+), 102 deletions(-) diff --git a/contrib/openresolv/resolvconf.conf.5.in b/contrib/openresolv/resolvconf.conf.5.in index 9a47a1caed6f..98a3017b7e53 100644 --- a/contrib/openresolv/resolvconf.conf.5.in +++ b/contrib/openresolv/resolvconf.conf.5.in @@ -43,7 +43,7 @@ Listed below are the standard .Nm variables that may be set. .Pp -After updaing this file, you may wish to run +After updating this file, you may wish to run .Nm resolvconf -u to apply the new configuration. .Sh RESOLVCONF OPTIONS diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile index 3068f0b86fab..cccc517a2552 100644 --- a/sbin/mount_nfs/Makefile +++ b/sbin/mount_nfs/Makefile @@ -5,7 +5,7 @@ PROG= mount_nfs SRCS= mount_nfs.c getmntopts.c mounttab.c MAN= mount_nfs.8 -MLINKS= mount_nfs.8 mount_newnfs.8 +MLINKS= mount_nfs.8 mount_oldnfs.8 MOUNT= ${.CURDIR}/../mount UMNTALL= ${.CURDIR}/../../usr.sbin/rpc.umntall diff --git a/sbin/recoverdisk/recoverdisk.1 b/sbin/recoverdisk/recoverdisk.1 index 1759a7dc91b1..9eff8f747bb5 100644 --- a/sbin/recoverdisk/recoverdisk.1 +++ b/sbin/recoverdisk/recoverdisk.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 6, 2006 +.Dd May 1, 2011 .Dt RECOVERDISK 1 .Os .Sh NAME @@ -33,17 +33,20 @@ .Sh SYNOPSIS .Nm .Op Fl b Ar bigsize -.Op Fl r Ar rlist -.Op Fl s Ar snapshot -.Op Fl w Ar wlist -.Ar special -.Op Ar file +.Op Fl r Ar readlist +.Op Fl s Ar interval +.Op Fl w Ar writelist +.Ar source +.Op Ar destination .Sh DESCRIPTION The .Nm utility reads data from the -.Ar special +.Ar source file until all blocks could be successfully read. +If +.Ar destination +was specified all data is being written to that file. It starts reading in multiples of the sector size. Whenever a block fails, it is put to the end of the working queue and will be read again, possibly with a smaller read size. @@ -59,13 +62,13 @@ The options are as follows: The size of reads attempted first. The middle pass is roughly the logarithmic average of the bigsize and the sectorsize. -.It Fl r Ar rlist +.It Fl r Ar readlist Read the list of blocks and block sizes to read from the specified file. -.It Fl s Ar snapshot -How often we should update the worklist file while things go OK. -The default is 60 and the units is "progress messages" so if things +.It Fl s Ar interval +How often we should update the writelist file while things go OK. +The default is 60 and the unit is "progress messages" so if things go well, this is the same as once per minute. -.It Fl w Ar wlist +.It Fl w Ar writelist Write the list of remaining blocks to read to the specified file if .Nm is aborted via @@ -102,20 +105,19 @@ Percent complete. .Sh EXAMPLES .Bd -literal # recover data from failing hard drive ad3 -touch /data/lots_of_space -recoverdisk /dev/ad3 /data/lots_of_space +recoverdisk /dev/ad3 /data/disk.img # clone a hard disk recoverdisk /dev/ad3 /dev/ad4 # read an ISO image from a CD-ROM -touch /data/cd.iso; recoverdisk /dev/acd0 /data/cd.iso +recoverdisk /dev/cd0 /data/cd.iso # continue reading from a broken CD and update the existing worklist -recoverdisk -r worklist -w worklist /dev/acd0 /data/cd.iso +recoverdisk -r worklist -w worklist /dev/cd0 /data/cd.iso # recover a single file from the unreadable media -touch file.avi; recoverdisk /cdrom/file.avi file.avi +recoverdisk /cdrom/file.avi file.avi # If the disk hangs the system on read-errors try: recoverdisk -b 0 /dev/ad3 /somewhere @@ -133,7 +135,7 @@ utility first appeared in The original implementation was done by .An Poul-Henning Kamp Aq phk@FreeBSD.org with minor improvements from -.An Ulrich Sp\(:orlein Aq uspoerlein@gmail.com . +.An Ulrich Sp\(:orlein Aq uqs@FreeBSD.org . .Pp This manual page was written by .An Ulrich Sp\(:orlein . @@ -144,4 +146,13 @@ This is due to the DMA reads being split up into blocks of at most 128kB. These reads then fail if the sectorsize is not a divisor of 128kB. When reading a full raw audio CD, this leads to roughly 700 error messages flying by. -This is harmless. +This is harmless and can be avoided by setting +.Fl b +to no more than 128kB. +.\".Pp +.\"When reading from optical media, a bug in the GEOM framework will +.\"prevent it from seeing that the media has been removed. +.\"The device can still be opened, but all reads will fail. +.\"This is usually harmless, but will send +.\".Nm +.\"into an infinite loop. diff --git a/sbin/recoverdisk/recoverdisk.c b/sbin/recoverdisk/recoverdisk.c index f4a6b5d9cab5..3930ef19c266 100644 --- a/sbin/recoverdisk/recoverdisk.c +++ b/sbin/recoverdisk/recoverdisk.c @@ -86,7 +86,7 @@ save_worklist(void) if (file == NULL) err(1, "Error opening file %s", wworklist); - TAILQ_FOREACH(llp, &lumps, list) + TAILQ_FOREACH(llp, &lumps, list) fprintf(file, "%jd %jd %d\n", (intmax_t)llp->start, (intmax_t)llp->len, llp->state); @@ -134,8 +134,8 @@ read_worklist(off_t t) static void usage(void) { - (void)fprintf(stderr, - "usage: recoverdisk [-r worklist] [-w worklist] source-drive [destination]\n"); + (void)fprintf(stderr, "usage: recoverdisk [-b bigsize] [-r readlist] " + "[-s interval] [-w writelist] source [destination]\n"); exit(1); } @@ -153,7 +153,7 @@ main(int argc, char * const argv[]) int fdr, fdw; off_t t, d, start, len; size_t i, j; - int error, flags, state; + int error, state; u_char *buf; u_int sectorsize; time_t t1, t2; @@ -196,7 +196,6 @@ main(int argc, char * const argv[]) error = fstat(fdr, &sb); if (error < 0) err(1, "fstat failed"); - flags = O_WRONLY; if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) { error = ioctl(fdr, DIOCGSECTORSIZE, §orsize); if (error < 0) @@ -210,7 +209,6 @@ main(int argc, char * const argv[]) err(1, "DIOCGMEDIASIZE failed"); } else { t = sb.st_size; - flags |= O_CREAT | O_TRUNC; } if (bigsize < minsize) @@ -229,9 +227,12 @@ main(int argc, char * const argv[]) err(1, "Cannot allocate %zu bytes buffer", bigsize); if (argc > 1) { - fdw = open(argv[1], flags, DEFFILEMODE); + fdw = open(argv[1], O_WRONLY | O_CREAT, DEFFILEMODE); if (fdw < 0) err(1, "Cannot open write descriptor %s", argv[1]); + if (ftruncate(fdw, t) < 0) + err(1, "Cannot truncate output %s to %jd bytes", + argv[1], (intmax_t)t); } else fdw = -1; @@ -292,6 +293,10 @@ main(int argc, char * const argv[]) } printf("\n%jd %zu failed (%s)\n", lp->start, i, strerror(errno)); + if (errno == EINVAL) { + printf("read() size too big? Try with -b 131072"); + aborting = 1; + } if (errno == ENXIO) aborting = 1; new_lump(lp->start, i, lp->state + 1); diff --git a/share/man/man4/vxge.4 b/share/man/man4/vxge.4 index 9f4f9b4cf44d..72a644d26e27 100644 --- a/share/man/man4/vxge.4 +++ b/share/man/man4/vxge.4 @@ -49,13 +49,12 @@ The .Nm driver provides support for Neterion X3100 adapters. The driver supports TCP Segmentation Offload (TSO/LSO), -Large Receive Offlaod (LRO), Jumbo Frames, Receive Traffic Hash (RTH), +Large Receive Offload (LRO), Jumbo Frames, Receive Traffic Hash (RTH), VLAN, Promiscuous mode and Multi function mode. .Pp - The .Nm -driver supports following function modes: +driver supports the following function modes: .Bd -ragged -offset indent .Cd "SF1_VP17 - 1 function with 17 VPATHs" .Ed diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree index 23a85eed7158..1d20448f2ffd 100644 --- a/share/misc/bsd-family-tree +++ b/share/misc/bsd-family-tree @@ -246,7 +246,7 @@ FreeBSD 5.2 | | | | | | | | | NetBSD 5.1 | | | FreeBSD FreeBSD | | | | | 8.2 7.4 | | | DragonFly 2.10.1 - | v | | | | + | v | | OpenBSD 4.9 | | | | | | FreeBSD 9 -current | NetBSD -current OpenBSD -current | | | | | | @@ -533,6 +533,7 @@ NetBSD 5.1 2010-11-19 [NBD] FreeBSD 7.4 2011-02-24 [FBD] FreeBSD 8.2 2011-02-24 [FBD] DragonFly 2.10.1 2011-04-26 [DFB] +OpenBSD 4.9 2011-05-01 [OBD] Bibliography ------------------------ diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index e20bc6fe49ed..33c142c1ea9c 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -261,8 +261,16 @@ device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath +#device bwi # Broadcom BCM430x/BCM431x wireless NICs. +#device bwn # Broadcom BCM43xx wireless NICs. +device ipw # Intel 2100 wireless NICs. +device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. +device iwn # Intel 4965/1000/5000/6000 wireless NICs. +device malo # Marvell Libertas wireless NICs. +device mwl # Marvell 88W8363 802.11n wireless NICs. device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. +device wpi # Intel 3945ABG wireless NICs. # Pseudo devices. device loop # Network loopback @@ -314,7 +322,9 @@ device rue # RealTek RTL8150 USB Ethernet device udav # Davicom DM9601E USB # USB Wireless device rum # Ralink Technology RT2501USB wireless NICs +device run # Ralink Technology RT2700/RT2800/RT3000 NICs. device uath # Atheros AR5523 wireless NICs +device upgt # Conexant/Intersil PrismGT wireless NICs. device ural # Ralink Technology RT2500USB wireless NICs device urtw # Realtek RTL8187B/L wireless NICs device zyd # ZyDAS zb1211/zb1211b wireless NICs diff --git a/sys/amd64/pci/pci_bus.c b/sys/amd64/pci/pci_bus.c index e943df1278e6..0f33cdf229ea 100644 --- a/sys/amd64/pci/pci_bus.c +++ b/sys/amd64/pci/pci_bus.c @@ -348,6 +348,7 @@ static device_method_t legacy_pcib_methods[] = { DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 1c0224737f8b..94311c61cfda 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1940,6 +1940,8 @@ device xmphy # XaQti XMAC II # lge: Support for PCI gigabit ethernet adapters based on the Level 1 # LXT1001 NetCellerator chipset. This includes the D-Link DGE-500SX, # SMC TigerCard 1000 (SMC9462SX), and some Addtron cards. +# malo: Marvell Libertas wireless NICs. +# mwl: Marvell 88W8363 802.11n wireless NICs. # msk: Support for gigabit ethernet adapters based on the Marvell/SysKonnect # Yukon II Gigabit controllers, including 88E8021, 88E8022, 88E8061, # 88E8062, 88E8035, 88E8036, 88E8038, 88E8050, 88E8052, 88E8053, @@ -2131,6 +2133,8 @@ options AH_RXCFG_SDMAMW_4BYTES device ath_rate_sample # SampleRate tx rate control for ath device bwi # Broadcom BCM430* BCM431* device bwn # Broadcom BCM43xx +device malo # Marvell Libertas wireless NICs. +device mwl # Marvell 88W8363 802.11n wireless NICs. device ral # Ralink Technology RT2500 wireless NICs. # Use "private" jumbo buffers allocated exclusively for the ti(4) driver. @@ -2727,6 +2731,9 @@ device run # Atheros AR5523 wireless driver device uath # +# Conexant/Intersil PrismGT wireless driver +device upgt +# # Ralink Technology RT2500USB wireless driver device ural # diff --git a/sys/conf/files b/sys/conf/files index 2280ecab0d0c..5488f69f7446 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1995,6 +1995,7 @@ dev/wi/if_wi.c optional wi dev/wi/if_wi_pccard.c optional wi pccard dev/wi/if_wi_pci.c optional wi pci dev/wl/if_wl.c optional wl isa +dev/wpi/if_wpi.c optional wpi pci wpifw.c optional wpifw \ compile-with "${AWK} -f $S/tools/fw_stub.awk wpi.fw:wpifw:153229 -mwpi -c${.TARGET}" \ no-implicit-rule before-depend local \ diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 1e583788a20e..23ad3e2f50a6 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -3,24 +3,25 @@ # # Warning flags for compiling the kernel and components of the kernel. # -# Note that the newly added -Wcast-qual is responsible for generating +# Note that the newly added -Wcast-qual is responsible for generating # most of the remaining warnings. Warnings introduced with -Wall will # also pop up, but are easier to fix. CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \ -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \ - -Wundef -Wno-pointer-sign -fformat-extensions + -Wundef -Wno-pointer-sign -fformat-extensions \ + -Wmissing-include-dirs # # The following flags are next up for working on: -# -W +# -Wextra # -# On the i386, do not align the stack to 16-byte boundaries. Otherwise GCC -# 2.95 adds code to the entry and exit point of every function to align the +# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95 +# and above adds code to the entry and exit point of every function to align the # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack -# per function call. While the 16-byte alignment may benefit micro benchmarks, +# per function call. While the 16-byte alignment may benefit micro benchmarks, # it is probably an overall loss as it makes the code bigger (less efficient # use of code cache tag lines) and uses more stack (less efficient use of data -# cache tag lines). Explicitly prohibit the use of SSE and other SIMD +# cache tag lines). Explicitly prohibit the use of FPU, SSE and other SIMD # operations inside the kernel itself. These operations are exclusively # reserved for user applications. # @@ -35,6 +36,7 @@ INLINE_LIMIT?= 8000 .if ${MACHINE_CPUARCH} == "arm" INLINE_LIMIT?= 8000 .endif + # # For IA-64, we use r13 for the kernel globals pointer and we only use # a very small subset of float registers for integer divides. @@ -98,7 +100,7 @@ INLINE_LIMIT?= 8000 CFLAGS+= -ffreestanding # -# GCC SSP support. +# GCC SSP support # .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" @@ -106,9 +108,8 @@ CFLAGS+= -fstack-protector .endif # -# Enable CTF conversation on request. +# Enable CTF conversation on request # .if defined(WITH_CTF) .undef NO_CTF .endif - diff --git a/sys/conf/options b/sys/conf/options index 25f171a39efd..4ddb9fad9c3f 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -775,6 +775,8 @@ ATH_ENABLE_11N opt_ah.h # options for the Atheros hal AH_SUPPORT_AR5416 opt_ah.h +# XXX For now, this breaks non-AR9130 chipsets, so only use it +# XXX when actually targetting AR9130. AH_SUPPORT_AR9130 opt_ah.h AH_DEBUG opt_ah.h @@ -791,6 +793,7 @@ AH_MAXCHAN opt_ah.h AH_RXCFG_SDMAMW_4BYTES opt_ah.h # AR5416 and later interrupt mitigation +# XXX do not use this for AR9130 AH_AR5416_INTERRUPT_MITIGATION opt_ah.h # options for the Broadcom BCM43xx driver (bwi) diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index 2ea9f2c1e1c8..49367d028e5e 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -100,6 +100,7 @@ static device_method_t acpi_pcib_acpi_methods[] = { DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e14dc93ac947..70d5590032b4 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -142,6 +142,7 @@ static device_method_t pci_methods[] = { DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_delete_resource, pci_delete_resource), DEVMETHOD(bus_alloc_resource, pci_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource), DEVMETHOD(bus_activate_resource, pci_activate_resource), DEVMETHOD(bus_deactivate_resource, pci_deactivate_resource), diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 199c13297786..eaaf6d3a68f8 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -73,6 +73,7 @@ static device_method_t pcib_methods[] = { DEVMETHOD(bus_read_ivar, pcib_read_ivar), DEVMETHOD(bus_write_ivar, pcib_write_ivar), DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index 53ad7f3357ac..e1fffe14214e 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -2298,7 +2298,7 @@ wpi_mrr_setup(struct wpi_softc *sc) } /* setup MRR for control frames */ - mrr.which = htole32(WPI_MRR_CTL); + mrr.which = WPI_MRR_CTL; error = wpi_cmd(sc, WPI_CMD_MRR_SETUP, &mrr, sizeof mrr, 0); if (error != 0) { device_printf(sc->sc_dev, @@ -2307,7 +2307,7 @@ wpi_mrr_setup(struct wpi_softc *sc) } /* setup MRR for data frames */ - mrr.which = htole32(WPI_MRR_DATA); + mrr.which = WPI_MRR_DATA; error = wpi_cmd(sc, WPI_CMD_MRR_SETUP, &mrr, sizeof mrr, 0); if (error != 0) { device_printf(sc->sc_dev, diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index 2073d260d5b2..d9780e4c48ae 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -404,6 +404,8 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap, struct ucred *cred) } else if (uap->flag & NFSSVC_GETSTATS) { error = copyout(&newnfsstats, CAST_USER_ADDR_T(uap->argp), sizeof (newnfsstats)); + if ((uap->flag & NFSSVC_ZEROSTATS) != 0 && error == 0) + bzero(&newnfsstats, sizeof(newnfsstats)); return (error); } else if (uap->flag & NFSSVC_NFSUSERDPORT) { u_short sockport; diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index 5d80a4300077..c8f8363bf966 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -273,9 +273,17 @@ device ath_pci # Atheros pci/cardbus glue device ath_hal # pci/cardbus chip support options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors device ath_rate_sample # SampleRate tx rate control for ath +#device bwi # Broadcom BCM430x/BCM431x wireless NICs. +#device bwn # Broadcom BCM43xx wireless NICs. +device ipw # Intel 2100 wireless NICs. +device iwi # Intel 2200BG/2225BG/2915ABG wireless NICs. +device iwn # Intel 4965/1000/5000/6000 wireless NICs. +device malo # Marvell Libertas wireless NICs. +device mwl # Marvell 88W8363 802.11n wireless NICs. device ral # Ralink Technology RT2500 wireless NICs. device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. #device wl # Older non 802.11 Wavelan wireless NIC. +device wpi # Intel 3945ABG wireless NICs. # Pseudo devices. device loop # Network loopback @@ -327,7 +335,9 @@ device rue # RealTek RTL8150 USB Ethernet device udav # Davicom DM9601E USB # USB Wireless device rum # Ralink Technology RT2501USB wireless NICs +device run # Ralink Technology RT2700/RT2800/RT3000 NICs. device uath # Atheros AR5523 wireless NICs +device upgt # Conexant/Intersil PrismGT wireless NICs. device ural # Ralink Technology RT2500USB wireless NICs device urtw # Realtek RTL8187B/L wireless NICs device zyd # ZyDAS zb1211/zb1211b wireless NICs diff --git a/sys/i386/pci/pci_bus.c b/sys/i386/pci/pci_bus.c index b7fa7d1e6f16..eb26b8664fa4 100644 --- a/sys/i386/pci/pci_bus.c +++ b/sys/i386/pci/pci_bus.c @@ -565,6 +565,7 @@ static device_method_t legacy_pcib_methods[] = { DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), diff --git a/sys/mips/atheros/ar724x_pci.c b/sys/mips/atheros/ar724x_pci.c index 827e7012a613..36586a27f495 100644 --- a/sys/mips/atheros/ar724x_pci.c +++ b/sys/mips/atheros/ar724x_pci.c @@ -57,8 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* XXX */ -#include /* XXX */ +#include #include @@ -113,7 +112,7 @@ static uint32_t ar724x_pci_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) { - uint32_t cmd, data, shift, mask; + uint32_t data, shift, mask; /* Register access is 32-bit aligned */ shift = (reg & 3) * 8; @@ -125,18 +124,9 @@ ar724x_pci_read_config(device_t dev, u_int bus, u_int slot, u_int func, dprintf("%s: tag (%x, %x, %x) reg %d(%d)\n", __func__, bus, slot, func, reg, bytes); - if ((bus == 0) && (slot == 0) && (func == 0)) { + if ((bus == 0) && (slot == 0) && (func == 0)) data = ATH_READ_REG(AR724X_PCI_CFG_BASE + (reg & ~3)); - /* - * WAR for BAR issue - We are unable to access the PCI device - * space if we set the BAR with proper base address. - */ - if (reg == PCIR_BAR(0) && bytes == 4) { - cmd = (ar71xx_soc == AR71XX_SOC_AR7240) ? - 0xffff : 0x1000ffff; - ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, cmd, bytes); - } - } else + else data = -1; /* Get request bytes from 32-bit word */ @@ -158,14 +148,14 @@ ar724x_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func, if ((bus != 0) || (slot != 0) || (func != 0)) return; - ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, data, bytes); /* - * WAR for BAR issue - We are unable to access the PCI device space - * if we set the BAR with proper base address. - * Force a flush here (at register writing). + * WAR for BAR issue on AR7240 - We are unable to access the PCI device + * space if we set the BAR with proper base address. */ - if (reg == PCIR_BAR(0) && bytes == 4) - (void)ar724x_pci_read_config(dev, bus, slot, func, reg, bytes); + if (reg == PCIR_BAR(0) && bytes == 4 && ar71xx_soc == AR71XX_SOC_AR7240) + ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, 0xffff, bytes); + else + ar724x_pci_write(AR724X_PCI_CFG_BASE, reg, data, bytes); } static void @@ -232,6 +222,9 @@ ar724x_pci_setup(device_t dev) else reg = 0x1ffc1; ATH_WRITE_REG(AR724X_PCI_APP, reg); + /* Flush write */ + (void) ATH_READ_REG(AR724X_PCI_APP); + DELAY(1000); reg = ATH_READ_REG(AR724X_PCI_RESET); @@ -457,10 +450,7 @@ ar724x_pci_activate_resource(device_t bus, device_t child, int type, int rid, case SYS_RES_MEMORY: case SYS_RES_IOPORT: - /* XXX */ - //rman_set_bustag(r, ar71xx_bus_space_pcimem); - //rman_set_bustag(r, mips_bus_space_generic); - rman_set_bustag(r, ar71xx_bus_space_reversed); + rman_set_bustag(r, ar71xx_bus_space_pcimem); break; } } diff --git a/sys/mips/conf/PB92.hints b/sys/mips/conf/PB92.hints index 9e9b122086a2..014e62f4d237 100644 --- a/sys/mips/conf/PB92.hints +++ b/sys/mips/conf/PB92.hints @@ -30,7 +30,11 @@ hint.arge.0.at="nexus0" hint.arge.0.maddr=0x19000000 hint.arge.0.msize=0x1000 hint.arge.0.irq=2 -hint.arge.0.phymask=0x1 + +# AR8316 workaround for now +hint.arge.0.media=1000 +hint.arge.0.fduplex=1 +hint.arge.0.phymask=0x3 # GPIO hint.gpio.0.at="apb0" diff --git a/sys/nfs/nfssvc.h b/sys/nfs/nfssvc.h index d756dbf5046b..e226e2bab9a3 100644 --- a/sys/nfs/nfssvc.h +++ b/sys/nfs/nfssvc.h @@ -64,5 +64,6 @@ #define NFSSVC_CBADDSOCK 0x00200000 #define NFSSVC_GETSTATS 0x00400000 #define NFSSVC_BACKUPSTABLE 0x00800000 +#define NFSSVC_ZEROSTATS 0x01000000 /* modifier for GETSTATS */ #endif /* _NFS_NFSSVC_H */ diff --git a/sys/x86/x86/mptable_pci.c b/sys/x86/x86/mptable_pci.c index 398444ce3141..c2b6cee6d943 100644 --- a/sys/x86/x86/mptable_pci.c +++ b/sys/x86/x86/mptable_pci.c @@ -116,6 +116,7 @@ static device_method_t mptable_hostb_methods[] = { DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c index 3564078f2e79..9ead8c842cae 100644 --- a/sys/x86/x86/nexus.c +++ b/sys/x86/x86/nexus.c @@ -100,6 +100,8 @@ static device_t nexus_add_child(device_t bus, u_int order, const char *name, int unit); static struct resource *nexus_alloc_resource(device_t, device_t, int, int *, u_long, u_long, u_long, u_int); +static int nexus_adjust_resource(device_t, device_t, int, struct resource *, + u_long, u_long); #ifdef SMP static int nexus_bind_intr(device_t, device_t, struct resource *, int); #endif @@ -144,6 +146,7 @@ static device_method_t nexus_methods[] = { DEVMETHOD(bus_print_child, nexus_print_child), DEVMETHOD(bus_add_child, nexus_add_child), DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), + DEVMETHOD(bus_adjust_resource, nexus_adjust_resource), DEVMETHOD(bus_release_resource, nexus_release_resource), DEVMETHOD(bus_activate_resource, nexus_activate_resource), DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), @@ -332,6 +335,23 @@ nexus_add_child(device_t bus, u_int order, const char *name, int unit) return(child); } +static struct rman * +nexus_rman(int type) +{ + switch (type) { + case SYS_RES_IRQ: + return (&irq_rman); + case SYS_RES_DRQ: + return (&drq_rman); + case SYS_RES_IOPORT: + return (&port_rman); + case SYS_RES_MEMORY: + return (&mem_rman); + default: + return (NULL); + } +} + /* * Allocate a resource on behalf of child. NB: child is usually going to be a * child of one of our descendants, not a direct child of nexus0. @@ -364,27 +384,9 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, } flags &= ~RF_ACTIVE; - - switch (type) { - case SYS_RES_IRQ: - rm = &irq_rman; - break; - - case SYS_RES_DRQ: - rm = &drq_rman; - break; - - case SYS_RES_IOPORT: - rm = &port_rman; - break; - - case SYS_RES_MEMORY: - rm = &mem_rman; - break; - - default: - return 0; - } + rm = nexus_rman(type); + if (rm == NULL) + return (NULL); rv = rman_reserve_resource(rm, start, end, count, flags, child); if (rv == 0) @@ -401,6 +403,20 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, return rv; } +static int +nexus_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + struct rman *rm; + + rm = nexus_rman(type); + if (rm == NULL) + return (ENXIO); + if (!rman_is_region_manager(r, rm)) + return (EINVAL); + return (rman_adjust_resource(r, start, end)); +} + static int nexus_activate_resource(device_t bus, device_t child, int type, int rid, struct resource *r) diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 147ce586cc13..f1c91ee1bc92 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -889,16 +889,18 @@ do_whatis() { search_whatis whatis "$@" } -EQN=/usr/bin/eqn +# User's PATH setting decides on the groff-suite to pick up. +EQN=eqn +NROFF='groff -S -P-c -Wall -mtty-char -man' +PIC=pic +REFER=refer +TBL=tbl +TROFF='groff -S -P-c -man' +VGRIND=vgrind + COL=/usr/bin/col LOCALE=/usr/bin/locale -NROFF='/usr/bin/groff -S -Wall -mtty-char -man' -PIC=/usr/bin/pic SYSCTL=/sbin/sysctl -TBL=/usr/bin/tbl -TROFF='/usr/bin/groff -S -man' -REFER=/usr/bin/refer -VGRIND=/usr/bin/vgrind debug=0 man_default_sections='1:1aout:8:2:3:n:4:5:6:7:9:l' diff --git a/usr.bin/nfsstat/nfsstat.1 b/usr.bin/nfsstat/nfsstat.1 index fcd4c00c886e..c05d8cd8afa1 100644 --- a/usr.bin/nfsstat/nfsstat.1 +++ b/usr.bin/nfsstat/nfsstat.1 @@ -28,7 +28,7 @@ .\" From: @(#)nfsstat.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd October 18, 2007 +.Dd May 1, 2011 .Dt NFSSTAT 1 .Os .Sh NAME @@ -78,7 +78,6 @@ activity for both the client and server at second intervals. .It Fl z Reset statistics after displaying them. -(Not currently supported by the experimental nfs subsystem.) .It Fl e Gather statistics from the experimental nfs subsystem that includes support for NFSv4 instead of the regular nfs subsystem. diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index 81a22608f29a..dfbecc7aa0ee 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -85,6 +85,7 @@ static int zflag = 0; static int run_v4 = 0; static int printtitle = 1; static struct ext_nfsstats ext_nfsstats; +static int nfssvc_flag; void intpr(int, int); void printhdr(int, int); @@ -107,6 +108,7 @@ main(int argc, char **argv) char *memf, *nlistf; char errbuf[_POSIX2_LINE_MAX]; + nfssvc_flag = NFSSVC_GETSTATS; interval = 0; memf = nlistf = NULL; while ((ch = getopt(argc, argv, "cesWM:N:w:z")) != -1) @@ -135,6 +137,7 @@ main(int argc, char **argv) break; case 'z': zflag = 1; + nfssvc_flag |= NFSSVC_ZEROSTATS; break; case 'e': run_v4 = 1; @@ -161,7 +164,7 @@ main(int argc, char **argv) errx(1, "experimental client/server not loaded"); if (run_v4 != 0) { - if (nfssvc(NFSSVC_GETSTATS, &ext_nfsstats) < 0) + if (nfssvc(nfssvc_flag, &ext_nfsstats) < 0) err(1, "Can't get stats"); } else if (nlistf != NULL || memf != NULL) { deadkernel = 1; @@ -793,13 +796,13 @@ exp_sidewaysintpr(u_int interval, int clientOnly, int serverOnly) int hdrcnt = 1; ext_nfsstatsp = &lastst; - if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) + if (nfssvc(nfssvc_flag, ext_nfsstatsp) < 0) err(1, "Can't get stats"); sleep(interval); for (;;) { ext_nfsstatsp = &nfsstats; - if (nfssvc(NFSSVC_GETSTATS, ext_nfsstatsp) < 0) + if (nfssvc(nfssvc_flag, ext_nfsstatsp) < 0) err(1, "Can't get stats"); if (--hdrcnt == 0) { From 2659f411b4e4694842db7e1089b47976a37a7053 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 2 May 2011 17:13:40 +0000 Subject: [PATCH 011/164] Remove the redefinition of MEMSTAT_MAXCPU and just use MAXCPU for that. Reviewed by: sbruno --- lib/libmemstat/memstat.c | 2 +- lib/libmemstat/memstat.h | 7 ------- lib/libmemstat/memstat_internal.h | 4 ++-- lib/libmemstat/memstat_malloc.c | 13 ++++--------- lib/libmemstat/memstat_uma.c | 9 +++++---- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c index 1a08d3f4d462..b2749e2b4933 100644 --- a/lib/libmemstat/memstat.c +++ b/lib/libmemstat/memstat.c @@ -193,7 +193,7 @@ _memstat_mt_reset_stats(struct memory_type *mtp) mtp->mt_zonefree = 0; mtp->mt_kegfree = 0; - for (i = 0; i < MEMSTAT_MAXCPU; i++) { + for (i = 0; i < MAXCPU; i++) { mtp->mt_percpu_alloc[i].mtp_memalloced = 0; mtp->mt_percpu_alloc[i].mtp_memfreed = 0; mtp->mt_percpu_alloc[i].mtp_numallocs = 0; diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h index bc1a336a5d77..fa269443196e 100644 --- a/lib/libmemstat/memstat.h +++ b/lib/libmemstat/memstat.h @@ -29,13 +29,6 @@ #ifndef _MEMSTAT_H_ #define _MEMSTAT_H_ -#include - -/* - * Number of CPU slots in library-internal data structures. - */ -#define MEMSTAT_MAXCPU MAXCPU - /* * Amount of caller data to maintain for each caller data slot. Applications * must not request more than this number of caller save data, or risk diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h index b7fdd7197cfe..8881e585f526 100644 --- a/lib/libmemstat/memstat_internal.h +++ b/lib/libmemstat/memstat_internal.h @@ -100,11 +100,11 @@ struct memory_type { uint64_t mtp_sizemask; /* Per-CPU mt_sizemask. */ void *mtp_caller_pointer[MEMSTAT_MAXCALLER]; uint64_t mtp_caller_uint64[MEMSTAT_MAXCALLER]; - } mt_percpu_alloc[MEMSTAT_MAXCPU]; + } mt_percpu_alloc[MAXCPU]; struct { uint64_t mtp_free; /* Per-CPU cache free items. */ - } mt_percpu_cache[MEMSTAT_MAXCPU]; + } mt_percpu_cache[MAXCPU]; LIST_ENTRY(memory_type) mt_list; /* List of types. */ }; diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c index 28a48c660546..a8d14f87593c 100644 --- a/lib/libmemstat/memstat_malloc.c +++ b/lib/libmemstat/memstat_malloc.c @@ -96,7 +96,7 @@ memstat_sysctl_malloc(struct memory_type_list *list, int flags) return (-1); } - if (maxcpus > MEMSTAT_MAXCPU) { + if (maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -160,7 +160,7 @@ memstat_sysctl_malloc(struct memory_type_list *list, int flags) return (-1); } - if (mtshp->mtsh_maxcpus > MEMSTAT_MAXCPU) { + if (mtshp->mtsh_maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); @@ -295,7 +295,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) void *kmemstatistics; int hint_dontsearch, j, mp_maxcpus, ret; char name[MEMTYPE_MAXNAME]; - struct malloc_type_stats mts[MEMSTAT_MAXCPU], *mtsp; + struct malloc_type_stats mts[MAXCPU], *mtsp; struct malloc_type_internal *mtip; struct malloc_type type, *typep; kvm_t *kvm; @@ -322,7 +322,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) return (-1); } - if (mp_maxcpus > MEMSTAT_MAXCPU) { + if (mp_maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -348,11 +348,6 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) list->mtl_error = ret; return (-1); } - - /* - * Since our compile-time value for MAXCPU may differ from the - * kernel's, we populate our own array. - */ mtip = type.ks_handle; ret = kread(kvm, mtip->mti_stats, mts, mp_maxcpus * sizeof(struct malloc_type_stats), 0); diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 4aae61a9bb05..10ff8ec36a81 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -27,6 +27,7 @@ */ #include +#include #include #define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ @@ -104,7 +105,7 @@ memstat_sysctl_uma(struct memory_type_list *list, int flags) return (-1); } - if (maxcpus > MEMSTAT_MAXCPU) { + if (maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -168,7 +169,7 @@ memstat_sysctl_uma(struct memory_type_list *list, int flags) return (-1); } - if (ushp->ush_maxcpus > MEMSTAT_MAXCPU) { + if (ushp->ush_maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); @@ -313,7 +314,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) struct uma_keg *kzp, kz; int hint_dontsearch, i, mp_maxid, ret; char name[MEMTYPE_MAXNAME]; - __cpumask_t all_cpus; + cpuset_t all_cpus; kvm_t *kvm; kvm = (kvm_t *)kvm_handle; @@ -407,7 +408,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) if (kz.uk_flags & UMA_ZFLAG_INTERNAL) goto skip_percpu; for (i = 0; i < mp_maxid + 1; i++) { - if ((all_cpus & (1 << i)) == 0) + if (!CPU_ISSET(i, &all_cpus)) continue; ucp = &ucp_array[i]; mtp->mt_numallocs += ucp->uc_allocs; From 9cbe3ac7df61bd74f5efe4f03b97567ae4ec0564 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 3 May 2011 18:36:36 +0000 Subject: [PATCH 012/164] Make CPU_MAXSETSIZE dependant by MAXCPU as well. Discussed with: jhb --- sys/sys/cpuset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 854fa29608ca..32639913973c 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -36,7 +36,7 @@ #define CPU_SETSIZE MAXCPU #endif -#define CPU_MAXSIZE 128 +#define CPU_MAXSIZE (4 * MAXCPU) #ifndef CPU_SETSIZE #define CPU_SETSIZE CPU_MAXSIZE From 083b019c4e040625f7ec5a5d294721a9adce464a Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 3 May 2011 18:48:06 +0000 Subject: [PATCH 013/164] Add a comment explaining the discrepancy in size between kernel and userland of cpuset_t. Discussed with: jhb --- sys/sys/cpuset.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 32639913973c..131d05567b87 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -36,6 +36,10 @@ #define CPU_SETSIZE MAXCPU #endif +/* + * In userland a bigger cpuset structure is preferable in order to cope + * with kernel bumping of MAXCPU and still have a compatible layout. + */ #define CPU_MAXSIZE (4 * MAXCPU) #ifndef CPU_SETSIZE From b29cc3952a764273e14611c937ada7bdd422f371 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 3 May 2011 18:57:46 +0000 Subject: [PATCH 014/164] MFC --- bin/stty/stty.c | 5 +- cddl/compat/opensolaris/misc/zmount.c | 6 +- contrib/bsnmp/snmp_mibII/mibII_interfaces.c | 3 +- contrib/one-true-awk/FIXES | 26 + contrib/one-true-awk/README | 2 +- contrib/one-true-awk/b.c | 6 +- contrib/one-true-awk/lib.c | 3 +- contrib/one-true-awk/main.c | 19 +- contrib/one-true-awk/makefile | 13 +- contrib/one-true-awk/run.c | 12 +- contrib/texinfo/makeinfo/sectioning.c | 4 +- etc/newsyslog.conf | 2 +- lib/libstand/__main.c | 2 +- lib/libstand/bswap.c | 9 +- lib/libstand/cd9660.c | 2 +- lib/libstand/dosfs.c | 4 +- lib/libstand/environment.c | 5 +- lib/libstand/getopt.c | 5 +- lib/libstand/net.c | 1 + lib/libstand/tftp.c | 52 +- lib/libstand/udp.c | 1 + sbin/geom/class/part/geom_part.c | 93 ++- sbin/geom/class/part/gpart.8 | 33 +- share/man/man4/sem.4 | 8 +- sys/amd64/conf/DEFAULTS | 2 + sys/amd64/pci/pci_bus.c | 1 + sys/boot/ia64/common/exec.c | 2 +- sys/cam/cam_xpt.c | 9 +- sys/conf/makeLINT.mk | 28 + sys/conf/options | 1 + sys/dev/acpica/acpi_pcib_acpi.c | 13 +- sys/dev/acpica/acpi_pcib_pci.c | 1 + sys/dev/bxe/if_bxe.c | 2 +- sys/dev/pci/pci.c | 20 + sys/dev/pci/pci_pci.c | 652 +++++++++++++++++++- sys/dev/pci/pcib_private.h | 30 + sys/dev/sound/pcm/dsp.c | 2 +- sys/dev/vxge/include/build-version.h | 2 +- sys/dev/vxge/vxge.c | 23 +- sys/dev/vxge/vxge.h | 1 - sys/i386/conf/DEFAULTS | 2 + sys/i386/pci/pci_bus.c | 1 + sys/kern/kern_jail.c | 116 +++- sys/kern/kern_racct.c | 14 +- sys/kern/kern_rctl.c | 95 ++- sys/sparc64/pci/apb.c | 1 + sys/sparc64/pci/ofw_pcib.c | 1 + sys/sys/jail.h | 13 +- sys/sys/rctl.h | 4 +- sys/x86/pci/qpi.c | 1 + sys/x86/x86/mptable_pci.c | 1 + tools/tools/vxge/vxge_info.c | 10 + usr.bin/calendar/calendars/calendar.freebsd | 8 +- usr.bin/login/login.c | 16 +- usr.bin/rctl/rctl.8 | 8 +- usr.sbin/makefs/cd9660/cd9660_eltorito.c | 79 +++ 56 files changed, 1240 insertions(+), 235 deletions(-) diff --git a/bin/stty/stty.c b/bin/stty/stty.c index f6daaf076ad8..b70f49fcad98 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -61,9 +61,11 @@ main(int argc, char *argv[]) struct info i; enum FMT fmt; int ch; + const char *file; fmt = NOTSET; i.fd = STDIN_FILENO; + file = "stdin"; opterr = 0; while (optind < argc && @@ -79,6 +81,7 @@ main(int argc, char *argv[]) case 'f': if ((i.fd = open(optarg, O_RDONLY | O_NONBLOCK)) < 0) err(1, "%s", optarg); + file = optarg; break; case 'g': fmt = GFLAG; @@ -92,7 +95,7 @@ args: argc -= optind; argv += optind; if (tcgetattr(i.fd, &i.t) < 0) - errx(1, "stdin isn't a terminal"); + errx(1, "%s isn't a terminal", file); if (ioctl(i.fd, TIOCGETD, &i.ldisc) < 0) err(1, "TIOCGETD"); if (ioctl(i.fd, TIOCGWINSZ, &i.win) < 0) diff --git a/cddl/compat/opensolaris/misc/zmount.c b/cddl/compat/opensolaris/misc/zmount.c index b4f99e3be9fd..d46b378ea92a 100644 --- a/cddl/compat/opensolaris/misc/zmount.c +++ b/cddl/compat/opensolaris/misc/zmount.c @@ -98,8 +98,10 @@ zmount(const char *spec, const char *dir, int mflag, char *fstype, build_iovec(&iov, &iovlen, "fspath", __DECONST(char *, dir), (size_t)-1); build_iovec(&iov, &iovlen, "from", __DECONST(char *, spec), (size_t)-1); - for (p = optstr; p != NULL; strsep(&p, ",/ ")) - build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); + for (p = optstr; p != NULL; strsep(&p, ",/ ")) { + if (*p != '\0') + build_iovec(&iov, &iovlen, p, NULL, (size_t)-1); + } rv = nmount(iov, iovlen, 0); free(optstr); return (rv); diff --git a/contrib/bsnmp/snmp_mibII/mibII_interfaces.c b/contrib/bsnmp/snmp_mibII/mibII_interfaces.c index a1817d39f92f..f425a2703f29 100644 --- a/contrib/bsnmp/snmp_mibII/mibII_interfaces.c +++ b/contrib/bsnmp/snmp_mibII/mibII_interfaces.c @@ -289,8 +289,7 @@ op_ifentry(struct snmp_context *ctx, struct snmp_value *value, * cable) and hence return 'dormant'. */ if (ifp->mib.ifmd_flags & IFF_RUNNING) { - if (ifp->mib.ifmd_data.ifi_link_state == - LINK_STATE_DOWN) + if (ifp->mib.ifmd_data.ifi_link_state != LINK_STATE_UP) value->v.integer = 5; /* state dormant */ else value->v.integer = 1; /* state up */ diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES index bda79768606a..36ef237ed91c 100644 --- a/contrib/one-true-awk/FIXES +++ b/contrib/one-true-awk/FIXES @@ -25,6 +25,32 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +May 1, 2011: + after advice from todd miller, kevin lo, ruslan ermilov, + and arnold robbins, changed srand() to return the previous + seed (which is 1 on the first call of srand). the seed is + an Awkfloat internally though converted to unsigned int to + pass to the library srand(). thanks, everyone. + + fixed a subtle (and i hope low-probability) overflow error + in fldbld, by adding space for one extra \0. thanks to + robert bassett for spotting this one and providing a fix. + + removed the files related to compilation on windows. i no + longer have anything like a current windows environment, so + i can't test any of it. + +May 23, 2010: + fixed long-standing overflow bug in run.c; many thanks to + nelson beebe for spotting it and providing the fix. + + fixed bug that didn't parse -vd=1 properly; thanks to santiago + vila for spotting it. + +Feb 8, 2010: + i give up. replaced isblank with isspace in b.c; there are + no consistent header files. + Nov 26, 2009: fixed a long-standing issue with when FS takes effect. a change to FS is now noticed immediately for subsequent splits. diff --git a/contrib/one-true-awk/README b/contrib/one-true-awk/README index 21255a1ca020..24aaf9092d58 100644 --- a/contrib/one-true-awk/README +++ b/contrib/one-true-awk/README @@ -29,7 +29,7 @@ by Al Aho, Brian Kernighan, and Peter Weinberger Changes, mostly bug fixes and occasional enhancements, are listed in FIXES. If you distribute this code further, please please please distribute FIXES with it. If you find errors, please report them -to bwk@bell-labs.com. Thanks. +to bwk@cs.princeton.edu. Thanks. The program itself is created by make diff --git a/contrib/one-true-awk/b.c b/contrib/one-true-awk/b.c index baefe6f71e27..c05e0f358632 100644 --- a/contrib/one-true-awk/b.c +++ b/contrib/one-true-awk/b.c @@ -752,7 +752,7 @@ Node *unary(Node *np) /* #define HAS_ISBLANK */ #ifndef HAS_ISBLANK -int (isblank)(int c) +int (xisblank)(int c) { return c==' ' || c=='\t'; } @@ -766,7 +766,11 @@ struct charclass { } charclasses[] = { { "alnum", 5, isalnum }, { "alpha", 5, isalpha }, +#ifndef HAS_ISBLANK + { "blank", 5, isspace }, /* was isblank */ +#else { "blank", 5, isblank }, +#endif { "cntrl", 5, iscntrl }, { "digit", 5, isdigit }, { "graph", 5, isgraph }, diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c index 017b37670d07..d7eee31db43f 100644 --- a/contrib/one-true-awk/lib.c +++ b/contrib/one-true-awk/lib.c @@ -256,6 +256,7 @@ void fldbld(void) /* create fields from current record */ { /* this relies on having fields[] the same length as $0 */ /* the fields are all stored in this one array with \0's */ + /* possibly with a final trailing \0 not associated with any field */ char *r, *fr, sep; Cell *p; int i, j, n; @@ -268,7 +269,7 @@ void fldbld(void) /* create fields from current record */ n = strlen(r); if (n > fieldssize) { xfree(fields); - if ((fields = (char *) malloc(n+1)) == NULL) + if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */ FATAL("out of space for fields in fldbld %d", n); fieldssize = n; } diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c index d78a8511e79b..27a49e40cf3a 100644 --- a/contrib/one-true-awk/main.c +++ b/contrib/one-true-awk/main.c @@ -25,7 +25,7 @@ THIS SOFTWARE. #include __FBSDID("$FreeBSD$"); -const char *version = "version 20091126 (FreeBSD)"; +const char *version = "version 20110501 (FreeBSD)"; #define DEBUG #include @@ -41,6 +41,7 @@ extern char **environ; extern int nfields; int dbg = 0; +Awkfloat srand_seed = 1; char *cmdname; /* gets argv[0] for error messages */ extern FILE *yyin; /* lex input file */ char *lexprog; /* points to program argument if it exists */ @@ -71,6 +72,10 @@ int main(int argc, char *argv[]) exit(1); } signal(SIGFPE, fpecatch); + + srand_seed = 1; + srand(srand_seed); + yyin = NULL; symtab = makesymtab(NSYMTAB/NSYMTAB); while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { @@ -120,14 +125,10 @@ int main(int argc, char *argv[]) WARNING("field separator FS is empty"); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ - if (argv[1][2] != 0) { /* arg is -vsomething */ - if (argv[1][2] != 0) - setclvar(&argv[1][2]); - } else { /* arg is -v something */ - argc--; argv++; - if (argc > 1 && isclvar(argv[1])) - setclvar(argv[1]); - } + if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1])) + setclvar(argv[1]); + else if (argv[1][2] != '\0') + setclvar(&argv[1][2]); break; case 'd': dbg = atoi(&argv[1][2]); diff --git a/contrib/one-true-awk/makefile b/contrib/one-true-awk/makefile index 9d3985be2d4c..f93f0a8bdb87 100644 --- a/contrib/one-true-awk/makefile +++ b/contrib/one-true-awk/makefile @@ -26,13 +26,12 @@ CFLAGS = -g CFLAGS = -O2 CFLAGS = -CC = gcc -Wall -g -Wwrite-strings -CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov CC = gcc -Wall -g CC = cc +CC = gcc -Wall -g -Wwrite-strings +CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov CC = gcc -O4 - YACC = bison -y YACC = yacc YFLAGS = -d @@ -40,13 +39,13 @@ YFLAGS = -d OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \ - maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c + maketab.c parse.c lib.c run.c tran.c proctab.c LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \ - lib.c run.c tran.c missing95.c + lib.c run.c tran.c -SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \ - vcvars32.bat buildwin.bat awk.1 +SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile \ + awk.1 a.out: ytab.o $(OFILES) $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c index 20c08b10525a..82c29ceabaf8 100644 --- a/contrib/one-true-awk/run.c +++ b/contrib/one-true-awk/run.c @@ -69,6 +69,7 @@ void tempfree(Cell *p) { jmp_buf env; extern int pairstack[]; +extern Awkfloat srand_seed; Node *winner = NULL; /* root of parse tree */ Cell *tmps; /* free temporary cells for execution */ @@ -1469,6 +1470,7 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis Cell *x, *y; Awkfloat u; int t; + Awkfloat tmp; char *p, *buf; Node *nextarg; FILE *fp; @@ -1520,7 +1522,10 @@ Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg lis u = time((time_t *)0); else u = getfval(x); + tmp = u; srand((unsigned int) u); + u = srand_seed; + srand_seed = tmp; break; case FTOUPPER: case FTOLOWER: @@ -1890,9 +1895,10 @@ Cell *gsub(Node **a, int nnn) /* global substitute */ adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub"); while ((*pb++ = *sptr++) != 0) ; - done: if (pb > buf + bufsz) - FATAL("gsub result2 %.30s too big; can't happen", buf); - *pb = '\0'; + done: if (pb < buf + bufsz) + *pb = '\0'; + else if (*(pb-1) != '\0') + FATAL("gsub result2 %.30s truncated; can't happen", buf); setsval(x, buf); /* BUG: should be able to avoid copy + free */ pfa->initstat = tempstat; } diff --git a/contrib/texinfo/makeinfo/sectioning.c b/contrib/texinfo/makeinfo/sectioning.c index ce32aeb3a7e5..1683d11b6e39 100644 --- a/contrib/texinfo/makeinfo/sectioning.c +++ b/contrib/texinfo/makeinfo/sectioning.c @@ -256,13 +256,13 @@ current_chapter_number (void) return xstrdup (""); else if (enum_marker == APPENDIX_MAGIC) { - char s[1]; + char s[2]; sprintf (s, "%c", numbers[0] + 64); return xstrdup (s); } else { - char s[5]; + char s[11]; sprintf (s, "%d", numbers[0]); return xstrdup (s); } diff --git a/etc/newsyslog.conf b/etc/newsyslog.conf index 79ad03739ccb..67aa11726d6a 100644 --- a/etc/newsyslog.conf +++ b/etc/newsyslog.conf @@ -8,7 +8,7 @@ # is no process which needs to be signalled when a given log file is # rotated, then the entry for that file should include the 'N' flag. # -# The 'flags' field is one or more of the letters: BCGJNUWZ or a '-'. +# The 'flags' field is one or more of the letters: BCDGJNUXZ or a '-'. # # Note: some sites will want to select more restrictive protections than the # defaults. In particular, it may be desirable to switch many of the 644 diff --git a/lib/libstand/__main.c b/lib/libstand/__main.c index 1c7e67703e0d..e38f33865c05 100644 --- a/lib/libstand/__main.c +++ b/lib/libstand/__main.c @@ -38,6 +38,6 @@ __FBSDID("$FreeBSD$"); void __main(void); void -__main() +__main(void) { } diff --git a/lib/libstand/bswap.c b/lib/libstand/bswap.c index a9bd323b7f62..212e2afe4b81 100644 --- a/lib/libstand/bswap.c +++ b/lib/libstand/bswap.c @@ -16,9 +16,11 @@ static char *rcsid = "$NetBSD: bswap64.c,v 1.1 1997/10/09 15:42:33 bouyer Exp $" #undef bswap32 #undef bswap64 +u_int32_t bswap32(u_int32_t x); +u_int64_t bswap64(u_int64_t x); + u_int32_t -bswap32(x) - u_int32_t x; +bswap32(u_int32_t x) { return ((x << 24) & 0xff000000 ) | ((x << 8) & 0x00ff0000 ) | @@ -27,8 +29,7 @@ bswap32(x) } u_int64_t -bswap64(x) - u_int64_t x; +bswap64(u_int64_t x) { u_int32_t *p = (u_int32_t*)&x; u_int32_t t; diff --git a/lib/libstand/cd9660.c b/lib/libstand/cd9660.c index 449480b5531e..c6bcef2ec9c2 100644 --- a/lib/libstand/cd9660.c +++ b/lib/libstand/cd9660.c @@ -545,7 +545,7 @@ cd9660_readdir(struct open_file *f, struct dirent *d) } static int -cd9660_write(struct open_file *f, void *start, size_t size, size_t *resid) +cd9660_write(struct open_file *f __unused, void *start __unused, size_t size __unused, size_t *resid __unused) { return EROFS; } diff --git a/lib/libstand/dosfs.c b/lib/libstand/dosfs.c index 5ba10c11adf2..e15ecdcf6fb3 100644 --- a/lib/libstand/dosfs.c +++ b/lib/libstand/dosfs.c @@ -358,7 +358,7 @@ dos_stat(struct open_file *fd, struct stat *sb) static int dos_readdir(struct open_file *fd, struct dirent *d) { - DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; + /* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */ u_char fn[261]; DOS_DIR dd; size_t res; @@ -414,7 +414,7 @@ dos_readdir(struct open_file *fd, struct dirent *d) } } - d->d_fileno = dd.de.clus[1] << 8 + dd.de.clus[0]; + d->d_fileno = (dd.de.clus[1] << 8) + dd.de.clus[0]; d->d_reclen = sizeof(*d); d->d_type = (dd.de.attr & FA_DIR) ? DT_DIR : DT_REG; memcpy(d->d_name, fn, sizeof(d->d_name)); diff --git a/lib/libstand/environment.c b/lib/libstand/environment.c index 3505ccd98d4d..fde4cf9c3874 100644 --- a/lib/libstand/environment.c +++ b/lib/libstand/environment.c @@ -207,13 +207,14 @@ env_discard(struct env_var *ev) } int -env_noset(struct env_var *ev, int flags, const void *value) +env_noset(struct env_var *ev __unused, int flags __unused, + const void *value __unused) { return(EPERM); } int -env_nounset(struct env_var *ev) +env_nounset(struct env_var *ev __unused) { return(EPERM); } diff --git a/lib/libstand/getopt.c b/lib/libstand/getopt.c index bb57fcd49e75..cfe405a85d63 100644 --- a/lib/libstand/getopt.c +++ b/lib/libstand/getopt.c @@ -52,10 +52,7 @@ char *optarg; /* argument associated with option */ * Parse argc/argv argument vector. */ int -getopt(nargc, nargv, ostr) - int nargc; - char * const *nargv; - const char *ostr; +getopt(int nargc, char * const *nargv, const char *ostr) { static char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ diff --git a/lib/libstand/net.c b/lib/libstand/net.c index d417bfb08486..81b4521c4c02 100644 --- a/lib/libstand/net.c +++ b/lib/libstand/net.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c index 23594bbd67b1..29590fcd7461 100644 --- a/lib/libstand/tftp.c +++ b/lib/libstand/tftp.c @@ -110,11 +110,7 @@ static const int tftperrors[8] = { }; static ssize_t -recvtftp(d, pkt, len, tleft) - struct iodesc *d; - void *pkt; - ssize_t len; - time_t tleft; +recvtftp(struct iodesc *d, void *pkt, ssize_t len, time_t tleft) { struct tftphdr *t; @@ -152,14 +148,14 @@ recvtftp(d, pkt, len, tleft) printf("illegal tftp error %d\n", ntohs(t->th_code)); errno = EIO; } else { -#ifdef DEBUG +#ifdef TFTP_DEBUG printf("tftp-error %d\n", ntohs(t->th_code)); #endif errno = tftperrors[ntohs(t->th_code)]; } return (-1); default: -#ifdef DEBUG +#ifdef TFTP_DEBUG printf("tftp type %d not handled\n", ntohs(t->th_opcode)); #endif return (-1); @@ -168,8 +164,7 @@ recvtftp(d, pkt, len, tleft) /* send request, expect first block (or error) */ static int -tftp_makereq(h) - struct tftp_handle *h; +tftp_makereq(struct tftp_handle *h) { struct { u_char header[HEADER_SIZE]; @@ -212,8 +207,7 @@ tftp_makereq(h) /* ack block, expect next */ static int -tftp_getnextblock(h) - struct tftp_handle *h; +tftp_getnextblock(struct tftp_handle *h) { struct { u_char header[HEADER_SIZE]; @@ -246,9 +240,7 @@ tftp_getnextblock(h) } static int -tftp_open(path, f) - const char *path; - struct open_file *f; +tftp_open(const char *path, struct open_file *f) { struct tftp_handle *tftpfile; struct iodesc *io; @@ -287,11 +279,8 @@ tftp_open(path, f) } static int -tftp_read(f, addr, size, resid) - struct open_file *f; - void *addr; - size_t size; - size_t *resid; /* out */ +tftp_read(struct open_file *f, void *addr, size_t size, + size_t *resid /* out */) { struct tftp_handle *tftpfile; static int tc = 0; @@ -314,7 +303,7 @@ tftp_read(f, addr, size, resid) res = tftp_getnextblock(tftpfile); if (res) { /* no answer */ -#ifdef DEBUG +#ifdef TFTP_DEBUG printf("tftp: read error\n"); #endif return (res); @@ -330,7 +319,7 @@ tftp_read(f, addr, size, resid) inbuffer = tftpfile->validsize - offinblock; if (inbuffer < 0) { -#ifdef DEBUG +#ifdef TFTP_DEBUG printf("tftp: invalid offset %d\n", tftpfile->off); #endif @@ -347,7 +336,7 @@ tftp_read(f, addr, size, resid) if ((tftpfile->islastblock) && (count == inbuffer)) break; /* EOF */ } else { -#ifdef DEBUG +#ifdef TFTP_DEBUG printf("tftp: block %d not found\n", needblock); #endif return (EINVAL); @@ -361,8 +350,7 @@ tftp_read(f, addr, size, resid) } static int -tftp_close(f) - struct open_file *f; +tftp_close(struct open_file *f) { struct tftp_handle *tftpfile; tftpfile = (struct tftp_handle *) f->f_fsdata; @@ -377,19 +365,14 @@ tftp_close(f) } static int -tftp_write(f, start, size, resid) - struct open_file *f; - void *start; - size_t size; - size_t *resid; /* out */ +tftp_write(struct open_file *f __unused, void *start __unused, size_t size __unused, + size_t *resid /* out */ __unused) { return (EROFS); } static int -tftp_stat(f, sb) - struct open_file *f; - struct stat *sb; +tftp_stat(struct open_file *f, struct stat *sb) { struct tftp_handle *tftpfile; tftpfile = (struct tftp_handle *) f->f_fsdata; @@ -403,10 +386,7 @@ tftp_stat(f, sb) } static off_t -tftp_seek(f, offset, where) - struct open_file *f; - off_t offset; - int where; +tftp_seek(struct open_file *f, off_t offset, int where) { struct tftp_handle *tftpfile; tftpfile = (struct tftp_handle *) f->f_fsdata; diff --git a/lib/libstand/udp.c b/lib/libstand/udp.c index 194f564531a8..d41be902a3f7 100644 --- a/lib/libstand/udp.c +++ b/lib/libstand/udp.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 8593d20891c0..ed7b8f830cc7 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -93,6 +93,7 @@ static void gpart_restore(struct gctl_req *, unsigned int); struct g_command PUBSYM(class_commands)[] = { { "add", 0, gpart_issue, { + { 'a', "alignment", GPART_AUTOFILL, G_TYPE_STRING }, { 'b', "start", GPART_AUTOFILL, G_TYPE_STRING }, { 's', "size", GPART_AUTOFILL, G_TYPE_STRING }, { 't', "type", NULL, G_TYPE_STRING }, @@ -100,7 +101,8 @@ struct g_command PUBSYM(class_commands)[] = { { 'l', "label", G_VAL_OPTIONAL, G_TYPE_STRING }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, - "[-b start] [-s size] -t type [-i index] [-l label] [-f flags] geom" + "[-a alignment] [-b start] [-s size] -t type [-i index] " + "[-l label] [-f flags] geom" }, { "backup", 0, gpart_backup, G_NULL_OPTS, "geom" @@ -168,11 +170,12 @@ struct g_command PUBSYM(class_commands)[] = { "-a attrib -i index [-f flags] geom" }, { "resize", 0, gpart_issue, { + { 'a', "alignment", GPART_AUTOFILL, G_TYPE_STRING }, { 's', "size", GPART_AUTOFILL, G_TYPE_STRING }, { 'i', GPART_PARAM_INDEX, NULL, G_TYPE_NUMBER }, { 'f', "flags", GPART_FLAGS, G_TYPE_STRING }, G_OPT_SENTINEL }, - "[-s size] -i index [-f flags] geom" + "[-a alignment] [-s size] -i index [-f flags] geom" }, { "restore", 0, gpart_restore, { { 'F', "force", NULL, G_TYPE_BOOL }, @@ -298,6 +301,9 @@ fmtattrib(struct gprovider *pp) return (buf); } +#define ALIGNDOWN(d, a) (-(a) & (d)) +#define ALIGNUP(d, a) (-(-(a) & -(d))) + static int gpart_autofill_resize(struct gctl_req *req) { @@ -306,7 +312,7 @@ gpart_autofill_resize(struct gctl_req *req) struct ggeom *gp; struct gprovider *pp; off_t last, size, start, new_size; - off_t lba, new_lba; + off_t lba, new_lba, alignment; const char *s; int error, idx; @@ -333,6 +339,19 @@ gpart_autofill_resize(struct gctl_req *req) if (pp == NULL) errx(EXIT_FAILURE, "Provider for geom %s not found.", s); + s = gctl_get_ascii(req, "alignment"); + alignment = 1; + if (*s != '*') { + error = g_parse_lba(s, pp->lg_sectorsize, &alignment); + if (error) + errc(EXIT_FAILURE, error, "Invalid alignment param"); + if (alignment == 0) + errx(EXIT_FAILURE, "Invalid alignment param"); + } + error = gctl_delete_param(req, "alignment"); + if (error) + errc(EXIT_FAILURE, error, "internal error"); + s = gctl_get_ascii(req, "size"); if (*s == '*') new_size = 0; @@ -341,10 +360,14 @@ gpart_autofill_resize(struct gctl_req *req) if (error) errc(EXIT_FAILURE, error, "Invalid size param"); /* no autofill necessary. */ - goto done; + if (alignment == 1) + goto done; + if (new_size > alignment) + new_size = ALIGNDOWN(new_size, alignment); } last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0); + last = ALIGNDOWN(last, alignment); LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "index"); if (s == NULL) @@ -376,7 +399,7 @@ gpart_autofill_resize(struct gctl_req *req) size = lba - start; pp = find_provider(gp, lba); if (pp == NULL) - new_size = last - start + 1; + new_size = ALIGNDOWN(last - start + 1, alignment); else { s = find_provcfg(pp, "start"); if (s == NULL) { @@ -389,6 +412,7 @@ gpart_autofill_resize(struct gctl_req *req) * Is there any free space between current and * next providers? */ + new_lba = ALIGNUP(new_lba, alignment); if (new_lba > lba) new_size = new_lba - start; else { @@ -410,12 +434,12 @@ gpart_autofill(struct gctl_req *req) struct gclass *cp; struct ggeom *gp; struct gprovider *pp; - off_t first, last; - off_t size, start; - off_t lba, len; + off_t first, last, a_first; + off_t size, start, a_lba; + off_t lba, len, alignment; uintmax_t grade; const char *s; - int error, has_size, has_start; + int error, has_size, has_start, has_alignment; s = gctl_get_ascii(req, "verb"); if (strcmp(s, "resize") == 0) @@ -442,6 +466,20 @@ gpart_autofill(struct gctl_req *req) if (pp == NULL) errx(EXIT_FAILURE, "Provider for geom %s not found.", s); + s = gctl_get_ascii(req, "alignment"); + has_alignment = (*s == '*') ? 0 : 1; + alignment = 1; + if (has_alignment) { + error = g_parse_lba(s, pp->lg_sectorsize, &alignment); + if (error) + errc(EXIT_FAILURE, error, "Invalid alignment param"); + if (alignment == 0) + errx(EXIT_FAILURE, "Invalid alignment param"); + } + error = gctl_delete_param(req, "alignment"); + if (error) + errc(EXIT_FAILURE, error, "internal error"); + s = gctl_get_ascii(req, "size"); has_size = (*s == '*') ? 0 : 1; size = 0; @@ -449,6 +487,8 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &size); if (error) errc(EXIT_FAILURE, error, "Invalid size param"); + if (size > alignment) + size = ALIGNDOWN(size, alignment); } s = gctl_get_ascii(req, "start"); @@ -458,15 +498,18 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &start); if (error) errc(EXIT_FAILURE, error, "Invalid start param"); + start = ALIGNUP(start, alignment); } /* No autofill necessary. */ - if (has_size && has_start) + if (has_size && has_start && !has_alignment) goto done; first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 0); last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0); grade = ~0ULL; + a_first = ALIGNUP(first, alignment); + last = ALIGNDOWN(last, alignment); while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); if (s == NULL) { @@ -475,23 +518,24 @@ gpart_autofill(struct gctl_req *req) } else lba = (off_t)strtoimax(s, NULL, 0); - if (first < lba) { + a_lba = ALIGNDOWN(lba, alignment); + if (first < a_lba && a_first < a_lba) { /* Free space [first, lba> */ - len = lba - first; + len = a_lba - a_first; if (has_size) { if (len >= size && (uintmax_t)(len - size) < grade) { - start = first; + start = a_first; grade = len - size; } } else if (has_start) { - if (start >= first && start < lba) { - size = lba - start; - grade = start - first; + if (start >= a_first && start < a_lba) { + size = a_lba - start; + grade = start - a_first; } } else { if (grade == ~0ULL || len > size) { - start = first; + start = a_first; size = len; grade = 0; } @@ -505,24 +549,25 @@ gpart_autofill(struct gctl_req *req) (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; } else first = (off_t)strtoimax(s, NULL, 0) + 1; + a_first = ALIGNUP(first, alignment); } - if (first <= last) { + if (a_first <= last) { /* Free space [first-last] */ - len = last - first + 1; + len = ALIGNDOWN(last - a_first + 1, alignment); if (has_size) { if (len >= size && (uintmax_t)(len - size) < grade) { - start = first; + start = a_first; grade = len - size; } } else if (has_start) { - if (start >= first && start <= last) { - size = last - start + 1; - grade = start - first; + if (start >= a_first && start <= last) { + size = ALIGNDOWN(last - start + 1, alignment); + grade = start - a_first; } } else { if (grade == ~0ULL || len > size) { - start = first; + start = a_first; size = len; grade = 0; } diff --git a/sbin/geom/class/part/gpart.8 b/sbin/geom/class/part/gpart.8 index 51b1af5cba51..436a1a041712 100644 --- a/sbin/geom/class/part/gpart.8 +++ b/sbin/geom/class/part/gpart.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 12, 2011 +.Dd May 03, 2011 .Dt GPART 8 .Os .Sh NAME @@ -91,6 +91,7 @@ utility: .Nm .Cm add .Fl t Ar type +.Op Fl a Ar alignment .Op Fl b Ar start .Op Fl s Ar size .Op Fl i Ar index @@ -148,6 +149,7 @@ utility: .Nm .Cm resize .Fl i Ar index +.Op Fl a Ar alignment .Op Fl s Ar size .Op Fl f Ar flags .Ar geom @@ -209,7 +211,17 @@ Partition types are discussed below in the section entitled .Sx "PARTITION TYPES" . .Pp Additional options include: -.Bl -tag -width 10n +.Bl -tag -width 12n +.It Fl a Ar alignment +If specified, then +.Nm +utility tries to align +.Ar start +offset and partition +.Ar size +to be multiple of +.Ar alignment +value. .It Fl i Ar index The index in the partition table at which the new partition is to be placed. @@ -416,7 +428,15 @@ to maximum available from given geom .Ar geom . .Pp Additional options include: -.Bl -tag -width 10n +.Bl -tag -width 12n +.It Fl a Ar alignment +If specified, then +.Nm +utility tries to align partition +.Ar size +to be multiple of +.Ar alignment +value. .It Fl f Ar flags Additional operational flags. See the section entitled @@ -834,6 +854,13 @@ partition that would contain UFS where the system boots from. /sbin/gpart add -s 512M -t freebsd-ufs da0 .Ed .Pp +Create a 15GB-sized +.Cm freebsd-ufs +partition that would contain UFS and aligned on 4KB boundaries: +.Bd -literal -offset indent +/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0 +.Ed +.Pp After having created all required partitions, embed bootstrap code into them. .Bd -literal -offset indent /sbin/gpart bootcode -p /boot/boot1 da0 diff --git a/share/man/man4/sem.4 b/share/man/man4/sem.4 index 4a641dc646f3..3cc3a499a71f 100644 --- a/share/man/man4/sem.4 +++ b/share/man/man4/sem.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 11, 2006 +.Dd May 3, 2011 .Dt SEM 4 .Os .Sh NAME @@ -73,9 +73,5 @@ dynamic kernel module. .Sh HISTORY The .Nm -facility appeared as a kernel option in -.Fx 3.0 . -The -.Nm -kernel module appeared in +facility appeared in .Fx 5.0 . diff --git a/sys/amd64/conf/DEFAULTS b/sys/amd64/conf/DEFAULTS index 1fb52b34e0c2..2c221cb76bb9 100644 --- a/sys/amd64/conf/DEFAULTS +++ b/sys/amd64/conf/DEFAULTS @@ -20,3 +20,5 @@ options GEOM_PART_BSD options GEOM_PART_EBR options GEOM_PART_EBR_COMPAT options GEOM_PART_MBR + +options NEW_PCIB diff --git a/sys/amd64/pci/pci_bus.c b/sys/amd64/pci/pci_bus.c index 0f33cdf229ea..7c377ac4ced5 100644 --- a/sys/amd64/pci/pci_bus.c +++ b/sys/amd64/pci/pci_bus.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/boot/ia64/common/exec.c b/sys/boot/ia64/common/exec.c index 6c7f0279f0ba..dd9c9ba05e63 100644 --- a/sys/boot/ia64/common/exec.c +++ b/sys/boot/ia64/common/exec.c @@ -76,7 +76,7 @@ sz2shft(vm_offset_t ofs, vm_size_t sz) shft = 12; /* Start with 4K */ s = 1 << shft; - while (s < sz) { + while (s <= sz) { shft++; s <<= 1; } diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index cf7394834f08..1ce205d2a64f 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -3600,9 +3600,12 @@ xpt_path_legacy_ata_id(struct cam_path *path) } xpt_unlock_buses(); } - if (path->target != NULL) - return (bus_id * 2 + path->target->target_id); - else + if (path->target != NULL) { + if (path->target->target_id < 2) + return (bus_id * 2 + path->target->target_id); + else + return (-1); + } else return (bus_id * 2); } diff --git a/sys/conf/makeLINT.mk b/sys/conf/makeLINT.mk index e5ac2217e53a..50a74a34dcc9 100644 --- a/sys/conf/makeLINT.mk +++ b/sys/conf/makeLINT.mk @@ -16,6 +16,34 @@ LINT: ${NOTES} ../../conf/makeLINT.sed echo "include ${.TARGET}" > ${.TARGET}-VIMAGE echo "ident ${.TARGET}-VIMAGE" >> ${.TARGET}-VIMAGE echo "options VIMAGE" >> ${.TARGET}-VIMAGE + echo "include ${.TARGET}" > ${.TARGET}-NOINET + echo "ident ${.TARGET}-NOINET" >> ${.TARGET}-NOINET + echo 'makeoptions MKMODULESENV+="WITHOUT_INET_SUPPORT="' >> ${.TARGET}-NOINET + echo "nooptions INET" >> ${.TARGET}-NOINET + echo "nodevice gre" >> ${.TARGET}-NOINET + echo "include ${.TARGET}" > ${.TARGET}-NOINET6 + echo "ident ${.TARGET}-NOINET6" >> ${.TARGET}-NOINET6 + echo "nooptions INET6" >> ${.TARGET}-NOINET6 + echo "include ${.TARGET}" > ${.TARGET}-NOIP + echo "ident ${.TARGET}-NOIP" >> ${.TARGET}-NOIP + echo 'makeoptions MKMODULESENV+="WITHOUT_INET_SUPPORT="' >> ${.TARGET}-NOIP + echo 'makeoptions MKMODULESENV+="WITHOUT_INET6_SUPPORT="' >> ${.TARGET}-NOIP + echo "nooptions INET" >> ${.TARGET}-NOIP + echo "nooptions INET6" >> ${.TARGET}-NOIP + echo "nodevice age" >> ${.TARGET}-NOIP + echo "nodevice alc" >> ${.TARGET}-NOIP + echo "nodevice ale" >> ${.TARGET}-NOIP + echo "nodevice bxe" >> ${.TARGET}-NOIP + echo "nodevice em" >> ${.TARGET}-NOIP + echo "nodevice fxp" >> ${.TARGET}-NOIP + echo "nodevice igb" >> ${.TARGET}-NOIP + echo "nodevice jme" >> ${.TARGET}-NOIP + echo "nodevice msk" >> ${.TARGET}-NOIP + echo "nodevice mxge" >> ${.TARGET}-NOIP + echo "nodevice sge" >> ${.TARGET}-NOIP + echo "nodevice sk" >> ${.TARGET}-NOIP + echo "nodevice txp" >> ${.TARGET}-NOIP + echo "nodevice vxge" >> ${.TARGET}-NOIP .endif .if ${TARGET} == "powerpc" || ${TARGET} == "mips" echo "machine ${TARGET} ${TARGET_ARCH}" >> ${.TARGET} diff --git a/sys/conf/options b/sys/conf/options index 4ddb9fad9c3f..a608d86382f6 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -136,6 +136,7 @@ MFI_DEBUG opt_mfi.h MFI_DECODE_LOG opt_mfi.h MPROF_BUFFERS opt_mprof.h MPROF_HASH_SIZE opt_mprof.h +NEW_PCIB opt_global.h NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h NO_ADAPTIVE_RWLOCKS NO_ADAPTIVE_SX diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index dc3e5b10620f..e4efefff66d3 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -370,11 +371,17 @@ acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid, * Hardcoding like this sucks, so a more MD/MI way needs to be * found to do it. This is typically only used on older laptops * that don't have pci busses behind pci bridge, so assuming > 32MB - * is liekly OK. + * is likely OK. + * + * PCI-PCI bridges may allocate smaller ranges for their windows, + * but the heuristics here should apply to those, so we allow + * several different end addresses. */ - if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) + if (type == SYS_RES_MEMORY && start == 0UL && (end == ~0UL || + end == 0xffffffff)) start = acpi_host_mem_start; - if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) + if (type == SYS_RES_IOPORT && start == 0UL && (end == ~0UL || + end == 0xffff || end == 0xffffffff)) start = 0x1000; return (bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags)); diff --git a/sys/dev/acpica/acpi_pcib_pci.c b/sys/dev/acpica/acpi_pcib_pci.c index a76698141f08..7dbccd6a2086 100644 --- a/sys/dev/acpica/acpi_pcib_pci.c +++ b/sys/dev/acpica/acpi_pcib_pci.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/dev/bxe/if_bxe.c b/sys/dev/bxe/if_bxe.c index a877ba02488e..05ed74719f4c 100644 --- a/sys/dev/bxe/if_bxe.c +++ b/sys/dev/bxe/if_bxe.c @@ -3600,7 +3600,7 @@ bxe_initial_phy_init(struct bxe_softc *sc) * It is recommended to turn off RX flow control for 5771x * when using jumbo frames for better performance. */ - if (!IS_E1HMF(sc) & (sc->mbuf_alloc_size > 5000)) + if (!IS_E1HMF(sc) && (sc->mbuf_alloc_size > 5000)) sc->link_params.req_fc_auto_adv = FLOW_CTRL_TX; else sc->link_params.req_fc_auto_adv = FLOW_CTRL_BOTH; diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 70d5590032b4..22046c1f30f7 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -3967,6 +3967,26 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, break; case SYS_RES_IOPORT: case SYS_RES_MEMORY: +#ifdef NEW_PCIB + /* + * PCI-PCI bridge I/O window resources are not BARs. + * For those allocations just pass the request up the + * tree. + */ + if (cfg->hdrtype == PCIM_HDRTYPE_BRIDGE) { + switch (*rid) { + case PCIR_IOBASEL_1: + case PCIR_MEMBASE_1: + case PCIR_PMBASEL_1: + /* + * XXX: Should we bother creating a resource + * list entry? + */ + return (bus_generic_alloc_resource(dev, child, + type, rid, start, end, count, flags)); + } + } +#endif /* Reserve resources for this BAR if needed. */ rle = resource_list_find(rl, type, *rid); if (rle == NULL) { diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index eaaf6d3a68f8..f68973b395a9 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -36,14 +36,16 @@ __FBSDID("$FreeBSD$"); */ #include -#include -#include -#include #include -#include +#include +#include +#include +#include #include #include +#include +#include #include #include @@ -73,8 +75,13 @@ static device_method_t pcib_methods[] = { DEVMETHOD(bus_read_ivar, pcib_read_ivar), DEVMETHOD(bus_write_ivar, pcib_write_ivar), DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), +#ifdef NEW_PCIB + DEVMETHOD(bus_adjust_resource, pcib_adjust_resource), + DEVMETHOD(bus_release_resource, pcib_release_resource), +#else DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), DEVMETHOD(bus_release_resource, bus_generic_release_resource), +#endif DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), @@ -100,6 +107,243 @@ static devclass_t pcib_devclass; DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc)); DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0); +#ifdef NEW_PCIB +/* + * XXX Todo: + * - properly handle the ISA enable bit. If it is set, we should change + * the behavior of the I/O window resource and rman to not allocate the + * blocked ranges (upper 768 bytes of each 1K in the first 64k of the + * I/O port address space). + */ + +/* + * Is a resource from a child device sub-allocated from one of our + * resource managers? + */ +static int +pcib_is_resource_managed(struct pcib_softc *sc, int type, struct resource *r) +{ + + switch (type) { + case SYS_RES_IOPORT: + return (rman_is_region_manager(r, &sc->io.rman)); + case SYS_RES_MEMORY: + /* Prefetchable resources may live in either memory rman. */ + if (rman_get_flags(r) & RF_PREFETCHABLE && + rman_is_region_manager(r, &sc->pmem.rman)) + return (1); + return (rman_is_region_manager(r, &sc->mem.rman)); + } + return (0); +} + +static int +pcib_is_window_open(struct pcib_window *pw) +{ + + return (pw->valid && pw->base < pw->limit); +} + +/* + * XXX: If RF_ACTIVE did not also imply allocating a bus space tag and + * handle for the resource, we could pass RF_ACTIVE up to the PCI bus + * when allocating the resource windows and rely on the PCI bus driver + * to do this for us. + */ +static void +pcib_activate_window(struct pcib_softc *sc, int type) +{ + + PCI_ENABLE_IO(device_get_parent(sc->dev), sc->dev, type); +} + +static void +pcib_write_windows(struct pcib_softc *sc, int mask) +{ + device_t dev; + uint32_t val; + + dev = sc->dev; + if (sc->io.valid && mask & WIN_IO) { + val = pci_read_config(dev, PCIR_IOBASEL_1, 1); + if ((val & PCIM_BRIO_MASK) == PCIM_BRIO_32) { + pci_write_config(dev, PCIR_IOBASEH_1, + sc->io.base >> 16, 2); + pci_write_config(dev, PCIR_IOLIMITH_1, + sc->io.limit >> 16, 2); + } + pci_write_config(dev, PCIR_IOBASEL_1, sc->io.base >> 8, 1); + pci_write_config(dev, PCIR_IOLIMITL_1, sc->io.limit >> 8, 1); + } + + if (mask & WIN_MEM) { + pci_write_config(dev, PCIR_MEMBASE_1, sc->mem.base >> 16, 2); + pci_write_config(dev, PCIR_MEMLIMIT_1, sc->mem.limit >> 16, 2); + } + + if (sc->pmem.valid && mask & WIN_PMEM) { + val = pci_read_config(dev, PCIR_PMBASEL_1, 2); + if ((val & PCIM_BRPM_MASK) == PCIM_BRPM_64) { + pci_write_config(dev, PCIR_PMBASEH_1, + sc->pmem.base >> 32, 4); + pci_write_config(dev, PCIR_PMLIMITH_1, + sc->pmem.limit >> 32, 4); + } + pci_write_config(dev, PCIR_PMBASEL_1, sc->pmem.base >> 16, 2); + pci_write_config(dev, PCIR_PMLIMITL_1, sc->pmem.limit >> 16, 2); + } +} + +static void +pcib_alloc_window(struct pcib_softc *sc, struct pcib_window *w, int type, + int flags, pci_addr_t max_address) +{ + char buf[64]; + int error, rid; + + if (max_address != (u_long)max_address) + max_address = ~0ul; + w->rman.rm_start = 0; + w->rman.rm_end = max_address; + w->rman.rm_type = RMAN_ARRAY; + snprintf(buf, sizeof(buf), "%s %s window", + device_get_nameunit(sc->dev), w->name); + w->rman.rm_descr = strdup(buf, M_DEVBUF); + error = rman_init(&w->rman); + if (error) + panic("Failed to initialize %s %s rman", + device_get_nameunit(sc->dev), w->name); + + if (!pcib_is_window_open(w)) + return; + + if (w->base > max_address || w->limit > max_address) { + device_printf(sc->dev, + "initial %s window has too many bits, ignoring\n", w->name); + return; + } + rid = w->reg; + w->res = bus_alloc_resource(sc->dev, type, &rid, w->base, w->limit, + w->limit - w->base + 1, flags); + if (w->res == NULL) { + device_printf(sc->dev, + "failed to allocate initial %s window: %#jx-%#jx\n", + w->name, (uintmax_t)w->base, (uintmax_t)w->limit); + w->base = max_address; + w->limit = 0; + pcib_write_windows(sc, w->mask); + return; + } + pcib_activate_window(sc, type); + + error = rman_manage_region(&w->rman, rman_get_start(w->res), + rman_get_end(w->res)); + if (error) + panic("Failed to initialize rman with resource"); +} + +/* + * Initialize I/O windows. + */ +static void +pcib_probe_windows(struct pcib_softc *sc) +{ + pci_addr_t max; + device_t dev; + uint32_t val; + + dev = sc->dev; + + /* Determine if the I/O port window is implemented. */ + val = pci_read_config(dev, PCIR_IOBASEL_1, 1); + if (val == 0) { + /* + * If 'val' is zero, then only 16-bits of I/O space + * are supported. + */ + pci_write_config(dev, PCIR_IOBASEL_1, 0xff, 1); + if (pci_read_config(dev, PCIR_IOBASEL_1, 1) != 0) { + sc->io.valid = 1; + pci_write_config(dev, PCIR_IOBASEL_1, 0, 1); + } + } else + sc->io.valid = 1; + + /* Read the existing I/O port window. */ + if (sc->io.valid) { + sc->io.reg = PCIR_IOBASEL_1; + sc->io.step = 12; + sc->io.mask = WIN_IO; + sc->io.name = "I/O port"; + if ((val & PCIM_BRIO_MASK) == PCIM_BRIO_32) { + sc->io.base = PCI_PPBIOBASE( + pci_read_config(dev, PCIR_IOBASEH_1, 2), val); + sc->io.limit = PCI_PPBIOLIMIT( + pci_read_config(dev, PCIR_IOLIMITH_1, 2), + pci_read_config(dev, PCIR_IOLIMITL_1, 1)); + max = 0xffffffff; + } else { + sc->io.base = PCI_PPBIOBASE(0, val); + sc->io.limit = PCI_PPBIOLIMIT(0, + pci_read_config(dev, PCIR_IOLIMITL_1, 1)); + max = 0xffff; + } + pcib_alloc_window(sc, &sc->io, SYS_RES_IOPORT, 0, max); + } + + /* Read the existing memory window. */ + sc->mem.valid = 1; + sc->mem.reg = PCIR_MEMBASE_1; + sc->mem.step = 20; + sc->mem.mask = WIN_MEM; + sc->mem.name = "memory"; + sc->mem.base = PCI_PPBMEMBASE(0, + pci_read_config(dev, PCIR_MEMBASE_1, 2)); + sc->mem.limit = PCI_PPBMEMLIMIT(0, + pci_read_config(dev, PCIR_MEMLIMIT_1, 2)); + pcib_alloc_window(sc, &sc->mem, SYS_RES_MEMORY, 0, 0xffffffff); + + /* Determine if the prefetchable memory window is implemented. */ + val = pci_read_config(dev, PCIR_PMBASEL_1, 2); + if (val == 0) { + /* + * If 'val' is zero, then only 32-bits of memory space + * are supported. + */ + pci_write_config(dev, PCIR_PMBASEL_1, 0xffff, 2); + if (pci_read_config(dev, PCIR_PMBASEL_1, 2) != 0) { + sc->pmem.valid = 1; + pci_write_config(dev, PCIR_PMBASEL_1, 0, 2); + } + } else + sc->pmem.valid = 1; + + /* Read the existing prefetchable memory window. */ + if (sc->pmem.valid) { + sc->pmem.reg = PCIR_PMBASEL_1; + sc->pmem.step = 20; + sc->pmem.mask = WIN_PMEM; + sc->pmem.name = "prefetch"; + if ((val & PCIM_BRPM_MASK) == PCIM_BRPM_64) { + sc->pmem.base = PCI_PPBMEMBASE( + pci_read_config(dev, PCIR_PMBASEH_1, 4), val); + sc->pmem.limit = PCI_PPBMEMLIMIT( + pci_read_config(dev, PCIR_PMLIMITH_1, 4), + pci_read_config(dev, PCIR_PMLIMITL_1, 2)); + max = 0xffffffffffffffff; + } else { + sc->pmem.base = PCI_PPBMEMBASE(0, val); + sc->pmem.limit = PCI_PPBMEMLIMIT(0, + pci_read_config(dev, PCIR_PMLIMITL_1, 2)); + max = 0xffffffff; + } + pcib_alloc_window(sc, &sc->pmem, SYS_RES_MEMORY, + RF_PREFETCHABLE, max); + } +} + +#else + /* * Is the prefetch window open (eg, can we allocate memory in it?) */ @@ -230,6 +474,7 @@ pcib_set_mem_decode(struct pcib_softc *sc) pci_write_config(dev, PCIR_PMLIMITH_1, pmemhi, 4); pci_write_config(dev, PCIR_PMLIMITL_1, sc->pmemlimit >> 16, 2); } +#endif /* * Get current bridge configuration. @@ -247,10 +492,12 @@ pcib_cfg_save(struct pcib_softc *sc) sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); sc->bridgectl = pci_read_config(dev, PCIR_BRIDGECTL_1, 2); sc->seclat = pci_read_config(dev, PCIR_SECLAT_1, 1); +#ifndef NEW_PCIB if (sc->command & PCIM_CMD_PORTEN) pcib_get_io_decode(sc); if (sc->command & PCIM_CMD_MEMEN) pcib_get_mem_decode(sc); +#endif } /* @@ -269,10 +516,14 @@ pcib_cfg_restore(struct pcib_softc *sc) pci_write_config(dev, PCIR_SUBBUS_1, sc->subbus, 1); pci_write_config(dev, PCIR_BRIDGECTL_1, sc->bridgectl, 2); pci_write_config(dev, PCIR_SECLAT_1, sc->seclat, 1); +#ifdef NEW_PCIB + pcib_write_windows(sc, WIN_IO | WIN_MEM | WIN_PMEM); +#else if (sc->command & PCIM_CMD_PORTEN) pcib_set_io_decode(sc); if (sc->command & PCIM_CMD_MEMEN) pcib_set_mem_decode(sc); +#endif } /* @@ -389,18 +640,35 @@ pcib_attach_common(device_t dev) if ((pci_get_devid(dev) & 0xff00ffff) == 0x24008086 || pci_read_config(dev, PCIR_PROGIF, 1) == PCIP_BRIDGE_PCI_SUBTRACTIVE) sc->flags |= PCIB_SUBTRACTIVE; - + +#ifdef NEW_PCIB + pcib_probe_windows(sc); +#endif if (bootverbose) { device_printf(dev, " domain %d\n", sc->domain); device_printf(dev, " secondary bus %d\n", sc->secbus); device_printf(dev, " subordinate bus %d\n", sc->subbus); - device_printf(dev, " I/O decode 0x%x-0x%x\n", sc->iobase, sc->iolimit); +#ifdef NEW_PCIB + if (pcib_is_window_open(&sc->io)) + device_printf(dev, " I/O decode 0x%jx-0x%jx\n", + (uintmax_t)sc->io.base, (uintmax_t)sc->io.limit); + if (pcib_is_window_open(&sc->mem)) + device_printf(dev, " memory decode 0x%jx-0x%jx\n", + (uintmax_t)sc->mem.base, (uintmax_t)sc->mem.limit); + if (pcib_is_window_open(&sc->pmem)) + device_printf(dev, " prefetched decode 0x%jx-0x%jx\n", + (uintmax_t)sc->pmem.base, (uintmax_t)sc->pmem.limit); +#else + if (pcib_is_io_open(sc)) + device_printf(dev, " I/O decode 0x%x-0x%x\n", + sc->iobase, sc->iolimit); if (pcib_is_nonprefetch_open(sc)) device_printf(dev, " memory decode 0x%jx-0x%jx\n", (uintmax_t)sc->membase, (uintmax_t)sc->memlimit); if (pcib_is_prefetch_open(sc)) device_printf(dev, " prefetched decode 0x%jx-0x%jx\n", (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit); +#endif else device_printf(dev, " no prefetched decode\n"); if (sc->flags & PCIB_SUBTRACTIVE) @@ -502,6 +770,377 @@ pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) return(ENOENT); } +#ifdef NEW_PCIB +static const char * +pcib_child_name(device_t child) +{ + static char buf[64]; + + if (device_get_nameunit(child) != NULL) + return (device_get_nameunit(child)); + snprintf(buf, sizeof(buf), "pci%d:%d:%d:%d", pci_get_domain(child), + pci_get_bus(child), pci_get_slot(child), pci_get_function(child)); + return (buf); +} + +/* + * Attempt to allocate a resource from the existing resources assigned + * to a window. + */ +static struct resource * +pcib_suballoc_resource(struct pcib_softc *sc, struct pcib_window *w, + device_t child, int type, int *rid, u_long start, u_long end, u_long count, + u_int flags) +{ + struct resource *res; + + if (!pcib_is_window_open(w)) + return (NULL); + + res = rman_reserve_resource(&w->rman, start, end, count, + flags & ~RF_ACTIVE, child); + if (res == NULL) + return (NULL); + + if (bootverbose) + device_printf(sc->dev, + "allocated %s range (%#lx-%#lx) for rid %x of %s\n", + w->name, rman_get_start(res), rman_get_end(res), *rid, + pcib_child_name(child)); + rman_set_rid(res, *rid); + + /* + * If the resource should be active, pass that request up the + * tree. This assumes the parent drivers can handle + * activating sub-allocated resources. + */ + if (flags & RF_ACTIVE) { + if (bus_activate_resource(child, type, *rid, res) != 0) { + rman_release_resource(res); + return (NULL); + } + } + + return (res); +} + +/* + * Attempt to grow a window to make room for a given resource request. + * The 'step' parameter is log_2 of the desired I/O window's alignment. + */ +static int +pcib_grow_window(struct pcib_softc *sc, struct pcib_window *w, int type, + u_long start, u_long end, u_long count, u_int flags) +{ + u_long align, start_free, end_free, front, back; + int error, rid; + + /* + * Clamp the desired resource range to the maximum address + * this window supports. Reject impossible requests. + */ + if (!w->valid) + return (EINVAL); + if (end > w->rman.rm_end) + end = w->rman.rm_end; + if (start + count - 1 > end || start + count < start) + return (EINVAL); + + /* + * If there is no resource at all, just try to allocate enough + * aligned space for this resource. + */ + if (w->res == NULL) { + if (RF_ALIGNMENT(flags) < w->step) { + flags &= ~RF_ALIGNMENT_MASK; + flags |= RF_ALIGNMENT_LOG2(w->step); + } + start &= ~((1ul << w->step) - 1); + end |= ((1ul << w->step) - 1); + count = roundup2(count, 1ul << w->step); + rid = w->reg; + w->res = bus_alloc_resource(sc->dev, type, &rid, start, end, + count, flags & ~RF_ACTIVE); + if (w->res == NULL) { + if (bootverbose) + device_printf(sc->dev, + "failed to allocate initial %s window (%#lx-%#lx,%#lx)\n", + w->name, start, end, count); + return (ENXIO); + } + if (bootverbose) + device_printf(sc->dev, + "allocated initial %s window of %#lx-%#lx\n", + w->name, rman_get_start(w->res), + rman_get_end(w->res)); + error = rman_manage_region(&w->rman, rman_get_start(w->res), + rman_get_end(w->res)); + if (error) { + if (bootverbose) + device_printf(sc->dev, + "failed to add initial %s window to rman\n", + w->name); + bus_release_resource(sc->dev, type, w->reg, w->res); + w->res = NULL; + return (error); + } + pcib_activate_window(sc, type); + goto updatewin; + } + + /* + * See if growing the window would help. Compute the minimum + * amount of address space needed on both the front and back + * ends of the existing window to satisfy the allocation. + * + * For each end, build a candidate region adjusting for the + * required alignment, etc. If there is a free region at the + * edge of the window, grow from the inner edge of the free + * region. Otherwise grow from the window boundary. + * + * XXX: Special case: if w->res is completely empty and the + * request size is larger than w->res, we should find the + * optimal aligned buffer containing w->res and allocate that. + */ + if (bootverbose) + device_printf(sc->dev, + "attempting to grow %s window for (%#lx-%#lx,%#lx)\n", + w->name, start, end, count); + align = 1ul << RF_ALIGNMENT(flags); + if (start < rman_get_start(w->res)) { + if (rman_first_free_region(&w->rman, &start_free, &end_free) != + 0 || start_free != rman_get_start(w->res)) + end_free = rman_get_start(w->res) - 1; + if (end_free > end) + end_free = end; + + /* Move end_free down until it is properly aligned. */ + end_free &= ~(align - 1); + front = end_free - count; + + /* + * The resource would now be allocated at (front, + * end_free). Ensure that fits in the (start, end) + * bounds. end_free is checked above. If 'front' is + * ok, ensure it is properly aligned for this window. + * Also check for underflow. + */ + if (front >= start && front <= end_free) { + if (bootverbose) + printf("\tfront candidate range: %#lx-%#lx\n", + front, end_free); + front &= (1ul << w->step) - 1; + front = rman_get_start(w->res) - front; + } else + front = 0; + } else + front = 0; + if (end > rman_get_end(w->res)) { + if (rman_last_free_region(&w->rman, &start_free, &end_free) != + 0 || end_free != rman_get_end(w->res)) + start_free = rman_get_end(w->res) + 1; + if (start_free < start) + start_free = start; + + /* Move start_free up until it is properly aligned. */ + start_free = roundup2(start_free, align); + back = start_free + count; + + /* + * The resource would now be allocated at (start_free, + * back). Ensure that fits in the (start, end) + * bounds. start_free is checked above. If 'back' is + * ok, ensure it is properly aligned for this window. + * Also check for overflow. + */ + if (back <= end && start_free <= back) { + if (bootverbose) + printf("\tback candidate range: %#lx-%#lx\n", + start_free, back); + back = roundup2(back, w->step) - 1; + back -= rman_get_end(w->res); + } else + back = 0; + } else + back = 0; + + /* + * Try to allocate the smallest needed region first. + * If that fails, fall back to the other region. + */ + error = ENOSPC; + while (front != 0 || back != 0) { + if (front != 0 && (front <= back || back == 0)) { + error = bus_adjust_resource(sc->dev, type, w->res, + rman_get_start(w->res) - front, + rman_get_end(w->res)); + if (error == 0) + break; + front = 0; + } else { + error = bus_adjust_resource(sc->dev, type, w->res, + rman_get_start(w->res), + rman_get_end(w->res) + back); + if (error == 0) + break; + back = 0; + } + } + + if (error) + return (error); + if (bootverbose) + device_printf(sc->dev, "grew %s window to %#lx-%#lx\n", + w->name, rman_get_start(w->res), rman_get_end(w->res)); + + /* Add the newly allocated region to the resource manager. */ + if (w->base != rman_get_start(w->res)) { + KASSERT(w->limit == rman_get_end(w->res), ("both ends moved")); + error = rman_manage_region(&w->rman, rman_get_start(w->res), + w->base - 1); + } else { + KASSERT(w->limit != rman_get_end(w->res), + ("neither end moved")); + error = rman_manage_region(&w->rman, w->limit + 1, + rman_get_end(w->res)); + } + if (error) { + if (bootverbose) + device_printf(sc->dev, + "failed to expand %s resource manager\n", w->name); + bus_adjust_resource(sc->dev, type, w->res, w->base, w->limit); + return (error); + } + +updatewin: + /* Save the new window. */ + w->base = rman_get_start(w->res); + w->limit = rman_get_end(w->res); + KASSERT((w->base & ((1ul << w->step) - 1)) == 0, + ("start address is not aligned")); + KASSERT((w->limit & ((1ul << w->step) - 1)) == (1ul << w->step) - 1, + ("end address is not aligned")); + pcib_write_windows(sc, w->mask); + return (0); +} + +/* + * We have to trap resource allocation requests and ensure that the bridge + * is set up to, or capable of handling them. + */ +struct resource * +pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct pcib_softc *sc; + struct resource *r; + + sc = device_get_softc(dev); + + /* + * VGA resources are decoded iff the VGA enable bit is set in + * the bridge control register. VGA resources do not fall into + * the resource windows and are passed up to the parent. + */ + if ((type == SYS_RES_IOPORT && pci_is_vga_ioport_range(start, end)) || + (type == SYS_RES_MEMORY && pci_is_vga_memory_range(start, end))) { + if (sc->bridgectl & PCIB_BCR_VGA_ENABLE) + return (bus_generic_alloc_resource(dev, child, type, + rid, start, end, count, flags)); + else + return (NULL); + } + + switch (type) { + case SYS_RES_IOPORT: + r = pcib_suballoc_resource(sc, &sc->io, child, type, rid, start, + end, count, flags); + if (r != NULL) + break; + if (pcib_grow_window(sc, &sc->io, type, start, end, count, + flags) == 0) + r = pcib_suballoc_resource(sc, &sc->io, child, type, + rid, start, end, count, flags); + break; + case SYS_RES_MEMORY: + /* + * For prefetchable resources, prefer the prefetchable + * memory window, but fall back to the regular memory + * window if that fails. Try both windows before + * attempting to grow a window in case the firmware + * has used a range in the regular memory window to + * map a prefetchable BAR. + */ + if (flags & RF_PREFETCHABLE) { + r = pcib_suballoc_resource(sc, &sc->pmem, child, type, + rid, start, end, count, flags); + if (r != NULL) + break; + } + r = pcib_suballoc_resource(sc, &sc->mem, child, type, rid, + start, end, count, flags); + if (r != NULL) + break; + if (flags & RF_PREFETCHABLE) { + if (pcib_grow_window(sc, &sc->pmem, type, start, end, + count, flags) == 0) { + r = pcib_suballoc_resource(sc, &sc->pmem, child, + type, rid, start, end, count, flags); + if (r != NULL) + break; + } + } + if (pcib_grow_window(sc, &sc->mem, type, start, end, count, + flags & ~RF_PREFETCHABLE) == 0) + r = pcib_suballoc_resource(sc, &sc->mem, child, type, + rid, start, end, count, flags); + break; + default: + return (bus_generic_alloc_resource(dev, child, type, rid, + start, end, count, flags)); + } + + /* + * If attempts to suballocate from the window fail but this is a + * subtractive bridge, pass the request up the tree. + */ + if (sc->flags & PCIB_SUBTRACTIVE && r == NULL) + return (bus_generic_alloc_resource(dev, child, type, rid, + start, end, count, flags)); + return (r); +} + +int +pcib_adjust_resource(device_t bus, device_t child, int type, struct resource *r, + u_long start, u_long end) +{ + struct pcib_softc *sc; + + sc = device_get_softc(bus); + if (pcib_is_resource_managed(sc, type, r)) + return (rman_adjust_resource(r, start, end)); + return (bus_generic_adjust_resource(bus, child, type, r, start, end)); +} + +int +pcib_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + struct pcib_softc *sc; + int error; + + sc = device_get_softc(dev); + if (pcib_is_resource_managed(sc, type, r)) { + if (rman_get_flags(r) & RF_ACTIVE) { + error = bus_deactivate_resource(child, type, rid, r); + if (error) + return (error); + } + return (rman_release_resource(r)); + } + return (bus_generic_release_resource(dev, child, type, rid, r)); +} +#else /* * We have to trap resource allocation requests and ensure that the bridge * is set up to, or capable of handling them. @@ -657,6 +1296,7 @@ pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, return (bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags)); } +#endif /* * PCIB interface. diff --git a/sys/dev/pci/pcib_private.h b/sys/dev/pci/pcib_private.h index b6e49de57ae6..1574deb752b3 100644 --- a/sys/dev/pci/pcib_private.h +++ b/sys/dev/pci/pcib_private.h @@ -39,6 +39,24 @@ */ DECLARE_CLASS(pcib_driver); +#ifdef NEW_PCIB +#define WIN_IO 0x1 +#define WIN_MEM 0x2 +#define WIN_PMEM 0x4 + +struct pcib_window { + pci_addr_t base; /* base address */ + pci_addr_t limit; /* topmost address */ + struct rman rman; + struct resource *res; + int reg; /* resource id from parent */ + int valid; + int mask; /* WIN_* bitmask of this window */ + int step; /* log_2 of window granularity */ + const char *name; +}; +#endif + /* * Bridge-specific data. */ @@ -53,12 +71,18 @@ struct pcib_softc u_int pribus; /* primary bus number */ u_int secbus; /* secondary bus number */ u_int subbus; /* subordinate bus number */ +#ifdef NEW_PCIB + struct pcib_window io; /* I/O port window */ + struct pcib_window mem; /* memory window */ + struct pcib_window pmem; /* prefetchable memory window */ +#else pci_addr_t pmembase; /* base address of prefetchable memory */ pci_addr_t pmemlimit; /* topmost address of prefetchable memory */ pci_addr_t membase; /* base address of memory window */ pci_addr_t memlimit; /* topmost address of memory window */ uint32_t iobase; /* base address of port window */ uint32_t iolimit; /* topmost address of port window */ +#endif uint16_t secstat; /* secondary bus status register */ uint16_t bridgectl; /* bridge control register */ uint8_t seclat; /* secondary bus latency timer */ @@ -74,6 +98,12 @@ int pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); int pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value); struct resource *pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags); +#ifdef NEW_PCIB +int pcib_adjust_resource(device_t bus, device_t child, int type, + struct resource *r, u_long start, u_long end); +int pcib_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r); +#endif int pcib_maxslots(device_t dev); uint32_t pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width); void pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width); diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index 19801b2e694c..66d0c8c13ef4 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -1655,7 +1655,7 @@ dsp_ioctl(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, /* XXX abusive DMA update: chn_rdupdate(rdch); */ a->bytes = sndbuf_gettotal(bs); a->blocks = sndbuf_getblocks(bs) - rdch->blocks; - a->ptr = sndbuf_getreadyptr(bs); + a->ptr = sndbuf_getfreeptr(bs); rdch->blocks = sndbuf_getblocks(bs); CHN_UNLOCK(rdch); } else diff --git a/sys/dev/vxge/include/build-version.h b/sys/dev/vxge/include/build-version.h index 9eca7b2a673f..5bc550ada8b3 100644 --- a/sys/dev/vxge/include/build-version.h +++ b/sys/dev/vxge/include/build-version.h @@ -3,5 +3,5 @@ #ifndef BUILD_VERSION_H #define BUILD_VERSION_H /* Do not edit! Automatically generated when released. */ -#define GENERATED_BUILD_VERSION 22708 +#define GENERATED_BUILD_VERSION 22770 #endif /* BUILD_VERSION_H */ diff --git a/sys/dev/vxge/vxge.c b/sys/dev/vxge/vxge.c index 05bbbb855a63..94ca609cb69b 100644 --- a/sys/dev/vxge/vxge.c +++ b/sys/dev/vxge/vxge.c @@ -357,6 +357,9 @@ vxge_init_locked(vxge_dev_t *vdev) if (!vpath_handle) continue; + /* Enabling mcast for all vpath */ + vxge_hal_vpath_mcast_enable(vpath_handle); + /* Enabling bcast for all vpath */ status = vxge_hal_vpath_bcast_enable(vpath_handle); if (status != VXGE_HAL_OK) @@ -2879,26 +2882,6 @@ vxge_promisc_set(vxge_dev_t *vdev) ifp = vdev->ifp; - if ((ifp->if_flags & IFF_ALLMULTI) && (!vdev->all_multi_flag)) { - for (i = 0; i < vdev->no_of_vpath; i++) { - vpath_handle = vxge_vpath_handle_get(vdev, i); - if (!vpath_handle) - continue; - - vxge_hal_vpath_mcast_enable(vpath_handle); - vdev->all_multi_flag = 1; - } - - } else if (!(ifp->if_flags & IFF_ALLMULTI) && (vdev->all_multi_flag)) { - for (i = 0; i < vdev->no_of_vpath; i++) { - vpath_handle = vxge_vpath_handle_get(vdev, i); - if (!vpath_handle) - continue; - - vxge_hal_vpath_mcast_disable(vpath_handle); - vdev->all_multi_flag = 0; - } - } for (i = 0; i < vdev->no_of_vpath; i++) { vpath_handle = vxge_vpath_handle_get(vdev, i); if (!vpath_handle) diff --git a/sys/dev/vxge/vxge.h b/sys/dev/vxge/vxge.h index 630bbefed54d..439c1ced443f 100644 --- a/sys/dev/vxge/vxge.h +++ b/sys/dev/vxge/vxge.h @@ -406,7 +406,6 @@ struct vxge_dev_t { int no_of_vpath; u64 active_port; u32 no_of_func; - u32 all_multi_flag; u32 hw_fw_version; u32 max_supported_vpath; int rx_mbuf_sz; diff --git a/sys/i386/conf/DEFAULTS b/sys/i386/conf/DEFAULTS index 32e77e41979b..78d807c3d344 100644 --- a/sys/i386/conf/DEFAULTS +++ b/sys/i386/conf/DEFAULTS @@ -28,3 +28,5 @@ options GEOM_PART_MBR # enable support for native hardware options NATIVE device atpic + +options NEW_PCIB diff --git a/sys/i386/pci/pci_bus.c b/sys/i386/pci/pci_bus.c index eb26b8664fa4..61dab3f143b8 100644 --- a/sys/i386/pci/pci_bus.c +++ b/sys/i386/pci/pci_bus.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 22b97e854ad1..5850ad1b512b 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$"); #define DEFAULT_HOSTUUID "00000000-0000-0000-0000-000000000000" MALLOC_DEFINE(M_PRISON, "prison", "Prison structures"); +MALLOC_DEFINE(M_PRISON_RACCT, "prison_racct", "Prison racct structures"); /* Keep struct prison prison0 and some code in kern_jail_set() readable. */ #ifdef INET @@ -114,10 +115,11 @@ struct prison prison0 = { }; MTX_SYSINIT(prison0, &prison0.pr_mtx, "jail mutex", MTX_DEF); -/* allprison and lastprid are protected by allprison_lock. */ +/* allprison, allprison_racct and lastprid are protected by allprison_lock. */ struct sx allprison_lock; SX_SYSINIT(allprison_lock, &allprison_lock, "allprison"); struct prisonlist allprison = TAILQ_HEAD_INITIALIZER(allprison); +LIST_HEAD(, prison_racct) allprison_racct; int lastprid = 0; static int do_jail_attach(struct thread *td, struct prison *pr); @@ -125,6 +127,10 @@ static void prison_complete(void *context, int pending); static void prison_deref(struct prison *pr, int flags); static char *prison_path(struct prison *pr1, struct prison *pr2); static void prison_remove_one(struct prison *pr); +#ifdef RACCT +static void prison_racct_attach(struct prison *pr); +static void prison_racct_detach(struct prison *pr); +#endif #ifdef INET static int _prison_check_ip4(struct prison *pr, struct in_addr *ia); static int prison_restrict_ip4(struct prison *pr, struct in_addr *newip4); @@ -1197,7 +1203,6 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) root = mypr->pr_root; vref(root); } - racct_create(&pr->pr_racct); strlcpy(pr->pr_hostuuid, DEFAULT_HOSTUUID, HOSTUUIDLEN); pr->pr_flags |= PR_HOST; #if defined(INET) || defined(INET6) @@ -1657,6 +1662,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) pr->pr_flags = (pr->pr_flags & ~ch_flags) | pr_flags; mtx_unlock(&pr->pr_mtx); +#ifdef RACCT + if (created) + prison_racct_attach(pr); +#endif + /* Locks may have prevented a complete restriction of child IP * addresses. If so, allocate some more memory and try again. */ @@ -2533,10 +2543,9 @@ prison_deref(struct prison *pr, int flags) if (pr->pr_cpuset != NULL) cpuset_rel(pr->pr_cpuset); osd_jail_exit(pr); -#ifdef RCTL - rctl_racct_release(pr->pr_racct); +#ifdef RACCT + prison_racct_detach(pr); #endif - racct_destroy(&pr->pr_racct); free(pr, M_PRISON); /* Removing a prison frees a reference on its parent. */ @@ -4277,14 +4286,103 @@ void prison_racct_foreach(void (*callback)(struct racct *racct, void *arg2, void *arg3), void *arg2, void *arg3) { - struct prison *pr; + struct prison_racct *prr; sx_slock(&allprison_lock); - TAILQ_FOREACH(pr, &allprison, pr_list) - (callback)(pr->pr_racct, arg2, arg3); + LIST_FOREACH(prr, &allprison_racct, prr_next) + (callback)(prr->prr_racct, arg2, arg3); sx_sunlock(&allprison_lock); } +static struct prison_racct * +prison_racct_find_locked(const char *name) +{ + struct prison_racct *prr; + + sx_assert(&allprison_lock, SA_XLOCKED); + + if (name[0] == '\0' || strlen(name) >= MAXHOSTNAMELEN) + return (NULL); + + LIST_FOREACH(prr, &allprison_racct, prr_next) { + if (strcmp(name, prr->prr_name) != 0) + continue; + + /* Found prison_racct with a matching name? */ + prison_racct_hold(prr); + return (prr); + } + + /* Add new prison_racct. */ + prr = malloc(sizeof(*prr), M_PRISON_RACCT, M_ZERO | M_WAITOK); + racct_create(&prr->prr_racct); + + strcpy(prr->prr_name, name); + refcount_init(&prr->prr_refcount, 1); + LIST_INSERT_HEAD(&allprison_racct, prr, prr_next); + + return (prr); +} + +struct prison_racct * +prison_racct_find(const char *name) +{ + struct prison_racct *prr; + + sx_xlock(&allprison_lock); + prr = prison_racct_find_locked(name); + sx_xunlock(&allprison_lock); + return (prr); +} + +void +prison_racct_hold(struct prison_racct *prr) +{ + + refcount_acquire(&prr->prr_refcount); +} + +void +prison_racct_free(struct prison_racct *prr) +{ + int old; + + old = prr->prr_refcount; + if (old > 1 && atomic_cmpset_int(&prr->prr_refcount, old, old - 1)) + return; + + sx_xlock(&allprison_lock); + if (refcount_release(&prr->prr_refcount)) { + racct_destroy(&prr->prr_racct); + LIST_REMOVE(prr, prr_next); + sx_xunlock(&allprison_lock); + free(prr, M_PRISON_RACCT); + + return; + } + sx_xunlock(&allprison_lock); +} + +#ifdef RACCT +static void +prison_racct_attach(struct prison *pr) +{ + struct prison_racct *prr; + + prr = prison_racct_find_locked(pr->pr_name); + KASSERT(prr != NULL, ("cannot find prison_racct")); + + pr->pr_prison_racct = prr; +} + +static void +prison_racct_detach(struct prison *pr) +{ + prison_racct_free(pr->pr_prison_racct); + pr->pr_prison_racct = NULL; +} +#endif /* RACCT */ + #ifdef DDB static void diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 5778bfe54d77..98bd9c56a0ed 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -313,7 +313,8 @@ racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, amount); for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) - racct_alloc_resource(pr->pr_racct, resource, amount); + racct_alloc_resource(pr->pr_prison_racct->prr_racct, resource, + amount); racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, amount); } @@ -522,7 +523,8 @@ racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount) racct_alloc_resource(cred->cr_ruidinfo->ui_racct, resource, -amount); for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) - racct_alloc_resource(pr->pr_racct, resource, -amount); + racct_alloc_resource(pr->pr_prison_racct->prr_racct, resource, + -amount); racct_alloc_resource(cred->cr_loginclass->lc_racct, resource, -amount); } @@ -669,9 +671,11 @@ racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, } if (newpr != oldpr) { for (pr = oldpr; pr != NULL; pr = pr->pr_parent) - racct_sub_racct(pr->pr_racct, p->p_racct); + racct_sub_racct(pr->pr_prison_racct->prr_racct, + p->p_racct); for (pr = newpr; pr != NULL; pr = pr->pr_parent) - racct_add_racct(pr->pr_racct, p->p_racct); + racct_add_racct(pr->pr_prison_racct->prr_racct, + p->p_racct); } mtx_unlock(&racct_lock); @@ -744,7 +748,7 @@ racct_init(void) /* * XXX: Move this somewhere. */ - racct_create(&prison0.pr_racct); + prison0.pr_prison_racct = prison_racct_find("0"); } SYSINIT(racct, SI_SUB_RACCT, SI_ORDER_FIRST, racct_init, NULL); diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c index 88a971c932e8..2d43bdce521c 100644 --- a/sys/kern/kern_rctl.c +++ b/sys/kern/kern_rctl.c @@ -241,7 +241,8 @@ rctl_available_resource(const struct proc *p, const struct rctl_rule *rule) break; case RCTL_SUBJECT_TYPE_JAIL: available = rule->rr_amount - - cred->cr_prison->pr_racct->r_resources[resource]; + cred->cr_prison->pr_prison_racct->prr_racct-> + r_resources[resource]; break; default: panic("rctl_compute_available: unknown per %d", @@ -327,7 +328,7 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount) printf("rctl: rule \"%s\" matched by pid %d " "(%s), uid %d, jail %s\n", sbuf_data(&sb), p->p_pid, p->p_comm, p->p_ucred->cr_uid, - p->p_ucred->cr_prison->pr_name); + p->p_ucred->cr_prison->pr_prison_racct->prr_name); sbuf_delete(&sb); free(buf, M_RCTL); link->rrl_exceeded = 1; @@ -346,7 +347,7 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount) rctl_rule_to_sbuf(&sb, rule); sbuf_printf(&sb, " pid=%d ruid=%d jail=%s", p->p_pid, p->p_ucred->cr_ruid, - p->p_ucred->cr_prison->pr_name); + p->p_ucred->cr_prison->pr_prison_racct->prr_name); sbuf_finish(&sb); devctl_notify_f("RCTL", "rule", "matched", sbuf_data(&sb), M_NOWAIT); @@ -481,9 +482,9 @@ rctl_rule_matches(const struct rctl_rule *rule, const struct rctl_rule *filter) return (0); break; case RCTL_SUBJECT_TYPE_JAIL: - if (filter->rr_subject.rs_prison != NULL && - rule->rr_subject.rs_prison != - filter->rr_subject.rs_prison) + if (filter->rr_subject.rs_prison_racct != NULL && + rule->rr_subject.rs_prison_racct != + filter->rr_subject.rs_prison_racct) return (0); break; default: @@ -635,7 +636,10 @@ rctl_rule_acquire_subject(struct rctl_rule *rule) switch (rule->rr_subject_type) { case RCTL_SUBJECT_TYPE_UNDEFINED: case RCTL_SUBJECT_TYPE_PROCESS: + break; case RCTL_SUBJECT_TYPE_JAIL: + if (rule->rr_subject.rs_prison_racct != NULL) + prison_racct_hold(rule->rr_subject.rs_prison_racct); break; case RCTL_SUBJECT_TYPE_USER: if (rule->rr_subject.rs_uip != NULL) @@ -658,7 +662,10 @@ rctl_rule_release_subject(struct rctl_rule *rule) switch (rule->rr_subject_type) { case RCTL_SUBJECT_TYPE_UNDEFINED: case RCTL_SUBJECT_TYPE_PROCESS: + break; case RCTL_SUBJECT_TYPE_JAIL: + if (rule->rr_subject.rs_prison_racct != NULL) + prison_racct_free(rule->rr_subject.rs_prison_racct); break; case RCTL_SUBJECT_TYPE_USER: if (rule->rr_subject.rs_uip != NULL) @@ -686,7 +693,7 @@ rctl_rule_alloc(int flags) rule->rr_subject.rs_proc = NULL; rule->rr_subject.rs_uip = NULL; rule->rr_subject.rs_loginclass = NULL; - rule->rr_subject.rs_prison = NULL; + rule->rr_subject.rs_prison_racct = NULL; rule->rr_per = RCTL_SUBJECT_TYPE_UNDEFINED; rule->rr_resource = RACCT_UNDEFINED; rule->rr_action = RCTL_ACTION_UNDEFINED; @@ -708,7 +715,7 @@ rctl_rule_duplicate(const struct rctl_rule *rule, int flags) copy->rr_subject.rs_proc = rule->rr_subject.rs_proc; copy->rr_subject.rs_uip = rule->rr_subject.rs_uip; copy->rr_subject.rs_loginclass = rule->rr_subject.rs_loginclass; - copy->rr_subject.rs_prison = rule->rr_subject.rs_prison; + copy->rr_subject.rs_prison_racct = rule->rr_subject.rs_prison_racct; copy->rr_per = rule->rr_per; copy->rr_resource = rule->rr_resource; copy->rr_action = rule->rr_action; @@ -784,7 +791,7 @@ rctl_rule_fully_specified(const struct rctl_rule *rule) return (0); break; case RCTL_SUBJECT_TYPE_JAIL: - if (rule->rr_subject.rs_prison == NULL) + if (rule->rr_subject.rs_prison_racct == NULL) return (0); break; default: @@ -833,7 +840,7 @@ rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep) rule->rr_subject.rs_proc = NULL; rule->rr_subject.rs_uip = NULL; rule->rr_subject.rs_loginclass = NULL; - rule->rr_subject.rs_prison = NULL; + rule->rr_subject.rs_prison_racct = NULL; } else { switch (rule->rr_subject_type) { case RCTL_SUBJECT_TYPE_UNDEFINED: @@ -866,23 +873,12 @@ rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep) } break; case RCTL_SUBJECT_TYPE_JAIL: - rule->rr_subject.rs_prison = - prison_find_name(&prison0, subject_idstr); - if (rule->rr_subject.rs_prison == NULL) { - /* - * No jail with that name; try with the JID. - */ - error = str2id(subject_idstr, &id); - if (error != 0) - goto out; - rule->rr_subject.rs_prison = prison_find(id); - if (rule->rr_subject.rs_prison == NULL) { - error = ESRCH; - goto out; - } + rule->rr_subject.rs_prison_racct = + prison_racct_find(subject_idstr); + if (rule->rr_subject.rs_prison_racct == NULL) { + error = ENAMETOOLONG; + goto out; } - /* prison_find() returns with mutex held. */ - mtx_unlock(&rule->rr_subject.rs_prison->pr_mtx); break; default: panic("rctl_string_to_rule: unknown subject type %d", @@ -944,6 +940,7 @@ rctl_rule_add(struct rctl_rule *rule) struct ucred *cred; struct uidinfo *uip; struct prison *pr; + struct prison_racct *prr; struct loginclass *lc; struct rctl_rule *rule2; int match; @@ -1008,9 +1005,9 @@ rctl_rule_add(struct rctl_rule *rule) break; case RCTL_SUBJECT_TYPE_JAIL: - pr = rule->rr_subject.rs_prison; - KASSERT(pr != NULL, ("rctl_rule_add: NULL pr")); - rctl_racct_add_rule(pr->pr_racct, rule); + prr = rule->rr_subject.rs_prison_racct; + KASSERT(prr != NULL, ("rctl_rule_add: NULL pr")); + rctl_racct_add_rule(prr->prr_racct, rule); break; default: @@ -1040,7 +1037,7 @@ rctl_rule_add(struct rctl_rule *rule) case RCTL_SUBJECT_TYPE_JAIL: match = 0; for (pr = cred->cr_prison; pr != NULL; pr = pr->pr_parent) { - if (pr == rule->rr_subject.rs_prison) { + if (pr->pr_prison_racct == rule->rr_subject.rs_prison_racct) { match = 1; break; } @@ -1144,11 +1141,11 @@ rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule) rule->rr_subject.rs_loginclass->lc_name); break; case RCTL_SUBJECT_TYPE_JAIL: - if (rule->rr_subject.rs_prison == NULL) + if (rule->rr_subject.rs_prison_racct == NULL) sbuf_printf(sb, ":"); else sbuf_printf(sb, "%s:", - rule->rr_subject.rs_prison->pr_name); + rule->rr_subject.rs_prison_racct->prr_name); break; default: panic("rctl_rule_to_sbuf: unknown subject type %d", @@ -1245,7 +1242,7 @@ rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap) struct proc *p; struct uidinfo *uip; struct loginclass *lc; - struct prison *pr; + struct prison_racct *prr; error = priv_check(td, PRIV_RCTL_GET_RACCT); if (error != 0) @@ -1256,11 +1253,9 @@ rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap) return (error); sx_slock(&allproc_lock); - sx_slock(&allprison_lock); error = rctl_string_to_rule(inputstr, &filter); free(inputstr, M_RCTL); if (error != 0) { - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } @@ -1295,19 +1290,18 @@ rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap) outputsbuf = rctl_racct_to_sbuf(lc->lc_racct, 1); break; case RCTL_SUBJECT_TYPE_JAIL: - pr = filter->rr_subject.rs_prison; - if (pr == NULL) { + prr = filter->rr_subject.rs_prison_racct; + if (prr == NULL) { error = EINVAL; goto out; } - outputsbuf = rctl_racct_to_sbuf(pr->pr_racct, 1); + outputsbuf = rctl_racct_to_sbuf(prr->prr_racct, 1); break; default: error = EINVAL; } out: rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); if (error != 0) return (error); @@ -1354,11 +1348,9 @@ rctl_get_rules(struct thread *td, struct rctl_get_rules_args *uap) return (error); sx_slock(&allproc_lock); - sx_slock(&allprison_lock); error = rctl_string_to_rule(inputstr, &filter); free(inputstr, M_RCTL); if (error != 0) { - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } @@ -1406,7 +1398,6 @@ rctl_get_rules(struct thread *td, struct rctl_get_rules_args *uap) error = rctl_write_outbuf(sb, uap->outbufp, uap->outbuflen); rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); free(buf, M_RCTL); return (error); @@ -1431,30 +1422,25 @@ rctl_get_limits(struct thread *td, struct rctl_get_limits_args *uap) return (error); sx_slock(&allproc_lock); - sx_slock(&allprison_lock); error = rctl_string_to_rule(inputstr, &filter); free(inputstr, M_RCTL); if (error != 0) { - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } if (filter->rr_subject_type == RCTL_SUBJECT_TYPE_UNDEFINED) { rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (EINVAL); } if (filter->rr_subject_type != RCTL_SUBJECT_TYPE_PROCESS) { rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (EOPNOTSUPP); } if (filter->rr_subject.rs_proc == NULL) { rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (EINVAL); } @@ -1486,7 +1472,6 @@ rctl_get_limits(struct thread *td, struct rctl_get_limits_args *uap) error = rctl_write_outbuf(sb, uap->outbufp, uap->outbuflen); rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); free(buf, M_RCTL); return (error); @@ -1508,11 +1493,9 @@ rctl_add_rule(struct thread *td, struct rctl_add_rule_args *uap) return (error); sx_slock(&allproc_lock); - sx_slock(&allprison_lock); error = rctl_string_to_rule(inputstr, &rule); free(inputstr, M_RCTL); if (error != 0) { - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } @@ -1532,7 +1515,6 @@ rctl_add_rule(struct thread *td, struct rctl_add_rule_args *uap) out: rctl_rule_release(rule); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } @@ -1553,18 +1535,15 @@ rctl_remove_rule(struct thread *td, struct rctl_remove_rule_args *uap) return (error); sx_slock(&allproc_lock); - sx_slock(&allprison_lock); error = rctl_string_to_rule(inputstr, &filter); free(inputstr, M_RCTL); if (error != 0) { - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); } error = rctl_rule_remove(filter); rctl_rule_release(filter); - sx_sunlock(&allprison_lock); sx_sunlock(&allproc_lock); return (error); @@ -1580,12 +1559,12 @@ rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred) struct rctl_rule_link *link, *newlink; struct uidinfo *newuip; struct loginclass *newlc; - struct prison *newpr; + struct prison_racct *newprr; LIST_HEAD(, rctl_rule_link) newrules; newuip = newcred->cr_ruidinfo; newlc = newcred->cr_loginclass; - newpr = newcred->cr_prison; + newprr = newcred->cr_prison->pr_prison_racct; LIST_INIT(&newrules); @@ -1605,7 +1584,7 @@ rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred) rulecnt++; LIST_FOREACH(link, &newlc->lc_racct->r_rule_links, rrl_next) rulecnt++; - LIST_FOREACH(link, &newpr->pr_racct->r_rule_links, rrl_next) + LIST_FOREACH(link, &newprr->prr_racct->r_rule_links, rrl_next) rulecnt++; rw_runlock(&rctl_lock); @@ -1655,7 +1634,7 @@ rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred) rulecnt--; } - LIST_FOREACH(link, &newpr->pr_racct->r_rule_links, rrl_next) { + LIST_FOREACH(link, &newprr->prr_racct->r_rule_links, rrl_next) { if (newlink == NULL) goto goaround; rctl_rule_acquire(link->rrl_rule); diff --git a/sys/sparc64/pci/apb.c b/sys/sparc64/pci/apb.c index f260f32182ed..87f182109569 100644 --- a/sys/sparc64/pci/apb.c +++ b/sys/sparc64/pci/apb.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/sparc64/pci/ofw_pcib.c b/sys/sparc64/pci/ofw_pcib.c index e533221ac7c3..45c9f1c9747f 100644 --- a/sys/sparc64/pci/ofw_pcib.c +++ b/sys/sparc64/pci/ofw_pcib.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/sys/jail.h b/sys/sys/jail.h index b83ac1b8a3c9..bbaf38162e7c 100644 --- a/sys/sys/jail.h +++ b/sys/sys/jail.h @@ -136,6 +136,7 @@ MALLOC_DECLARE(M_PRISON); #define HOSTUUIDLEN 64 struct racct; +struct prison_racct; /* * This structure describes a prison. It is pointed to by all struct @@ -168,7 +169,7 @@ struct prison { int pr_ip6s; /* (p) number of v6 IPs */ struct in_addr *pr_ip4; /* (p) v4 IPs of jail */ struct in6_addr *pr_ip6; /* (p) v6 IPs of jail */ - struct racct *pr_racct; /* (c) resource accounting */ + struct prison_racct *pr_prison_racct; /* (c) racct jail proxy */ void *pr_sparep[3]; int pr_childcount; /* (a) number of child jails */ int pr_childmax; /* (p) maximum child jails */ @@ -183,6 +184,13 @@ struct prison { char pr_domainname[MAXHOSTNAMELEN]; /* (p) jail domainname */ char pr_hostuuid[HOSTUUIDLEN]; /* (p) jail hostuuid */ }; + +struct prison_racct { + LIST_ENTRY(prison_racct) prr_next; + char prr_name[MAXHOSTNAMELEN]; + u_int prr_refcount; + struct racct *prr_racct; +}; #endif /* _KERNEL || _WANT_PRISON */ #ifdef _KERNEL @@ -385,6 +393,9 @@ int prison_priv_check(struct ucred *cred, int priv); int sysctl_jail_param(SYSCTL_HANDLER_ARGS); void prison_racct_foreach(void (*callback)(struct racct *racct, void *arg2, void *arg3), void *arg2, void *arg3); +struct prison_racct *prison_racct_find(const char *name); +void prison_racct_hold(struct prison_racct *prr); +void prison_racct_free(struct prison_racct *prr); #endif /* _KERNEL */ #endif /* !_SYS_JAIL_H_ */ diff --git a/sys/sys/rctl.h b/sys/sys/rctl.h index d61defd8e427..1e0342732b80 100644 --- a/sys/sys/rctl.h +++ b/sys/sys/rctl.h @@ -44,7 +44,7 @@ struct proc; struct uidinfo; struct loginclass; -struct prison; +struct prison_racct; struct ucred; struct rctl_rule_link; @@ -70,7 +70,7 @@ struct rctl_rule { struct proc *rs_proc; struct uidinfo *rs_uip; struct loginclass *rs_loginclass; - struct prison *rs_prison; + struct prison_racct *rs_prison_racct; } rr_subject; int rr_per; int rr_resource; diff --git a/sys/x86/pci/qpi.c b/sys/x86/pci/qpi.c index 131519530194..d14494ca1bbf 100644 --- a/sys/x86/pci/qpi.c +++ b/sys/x86/pci/qpi.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/x86/x86/mptable_pci.c b/sys/x86/x86/mptable_pci.c index c2b6cee6d943..48eec7f6563e 100644 --- a/sys/x86/x86/mptable_pci.c +++ b/sys/x86/x86/mptable_pci.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/tools/tools/vxge/vxge_info.c b/tools/tools/vxge/vxge_info.c index 6a561374c6dc..d213d8727476 100644 --- a/tools/tools/vxge/vxge_info.c +++ b/tools/tools/vxge/vxge_info.c @@ -31,6 +31,7 @@ /*$FreeBSD$*/ #include "vxge_info.h" +#include static int sockfd; static struct ifreq ifr; @@ -38,6 +39,15 @@ static struct ifreq ifr; int main(int argc, char *argv[]) { + uid_t uid; + + uid = getuid(); + + if (uid) { + printf("vxge-manage: Operation not permitted.\nExiting...\n"); + goto _exit0; + } + if (argc >= 4) { if (!((strcasecmp(argv[2], "regs") == 0) || (strcasecmp(argv[2], "stats") == 0) || diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd index 65ec5fdcf630..83f3151609b0 100644 --- a/usr.bin/calendar/calendars/calendar.freebsd +++ b/usr.bin/calendar/calendars/calendar.freebsd @@ -45,8 +45,8 @@ 02/01 Juli Mallett born in Washington, Pennsylvania, United States, 1985 02/02 Diomidis D. Spinellis born in Athens, Greece, 1967 02/02 Michael W Lucas born in Detroit, Michigan, United States, 1967 -02/02 Yoichi Nakayama born in Tsu, Mie, Japan, 1976 02/02 Dmitry Chagin born in Stalingrad, USSR, 1976 +02/02 Yoichi Nakayama born in Tsu, Mie, Japan, 1976 02/05 Frank Laszlo born in Howell, Michigan, United States, 1983 02/10 David Greenman born in Portland, Oregon, United States, 1968 02/10 Paul Richards born in Ammanford, Carmarthenshire, United Kingdom, 1968 @@ -68,7 +68,6 @@ 02/24 Johan Karlsson born in Mariannelund, Sweden, 1974 02/24 Colin Percival born in Burnaby, Canada, 1981 02/26 Pietro Cerutti born in Faido, Switzerland, 1984 -05/19 Sofian Brabez born in Toulouse, France, 1984 02/28 Daichi GOTO born in Shimizu Suntou, Shizuoka, Japan, 1980 03/01 Hye-Shik Chang born in Daejeon, Republic of Korea, 1980 03/02 Cy Schubert born in Edmonton, Alberta, Canada, 1956 @@ -151,7 +150,8 @@ 05/17 Thomas Abthorpe born in Port Arthur, Ontario, Canada, 1968 05/19 Philippe Charnier born in Fontainebleau, France, 1966 05/19 Ian Dowse born in Dublin, Ireland, 1975 -05/20 Dan Moschuk died in Burlington, Ontario, Canada, 2010 +05/19 Sofian Brabez born in Toulouse, France, 1984 +05/20 Dan Moschuk died in Burlington, Ontario, Canada, 2010 05/21 Kris Kennaway born in Winnipeg, Manitoba, Canada, 1978 05/22 Clive Tong-I Lin born in Changhua, Taiwan, Republic of China, 1978 05/22 Michael Bushkov born in Rostov-on-Don, Russian Federation, 1985 @@ -175,7 +175,7 @@ 06/04 Justin Gibbs born in San Pedro, California, United States, 1973 06/04 Jason Evans born in Greeley, Colorado, United States, 1973 06/04 Thomas Moestl born in Braunschweig, Niedersachsen, Germany, 1980 -06/04 Zack Kirsch born in Memphis, Tennessee, United States, 1982 +06/04 Zack Kirsch born in Memphis, Tennessee, United States, 1982 06/06 Sergei Kolobov born in Karpinsk, Russian Federation, 1972 06/06 Alan Eldridge died in Denver, Colorado, 2003 06/07 Jimmy Olgeni born in Milano, Italy, 1976 diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index e671c8dfac75..1de440bfc449 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -380,6 +380,19 @@ main(int argc, char *argv[]) au_login_success(); #endif + /* + * This needs to happen before login_getpwclass to support + * home directories on GSS-API authenticated NFS where the + * kerberos credentials need to be saved so that the kernel + * can authenticate to the NFS server. + */ + pam_err = pam_setcred(pamh, pam_silent|PAM_ESTABLISH_CRED); + if (pam_err != PAM_SUCCESS) { + pam_syslog("pam_setcred()"); + bail(NO_SLEEP_EXIT, 1); + } + pam_cred_established = 1; + /* * Establish the login class. */ @@ -513,12 +526,11 @@ main(int argc, char *argv[]) bail(NO_SLEEP_EXIT, 1); } - pam_err = pam_setcred(pamh, pam_silent|PAM_ESTABLISH_CRED); + pam_err = pam_setcred(pamh, pam_silent|PAM_REINITIALIZE_CRED); if (pam_err != PAM_SUCCESS) { pam_syslog("pam_setcred()"); bail(NO_SLEEP_EXIT, 1); } - pam_cred_established = 1; pam_err = pam_open_session(pamh, pam_silent); if (pam_err != PAM_SUCCESS) { diff --git a/usr.bin/rctl/rctl.8 b/usr.bin/rctl/rctl.8 index f30f4c3f024f..bddd3130ff25 100644 --- a/usr.bin/rctl/rctl.8 +++ b/usr.bin/rctl/rctl.8 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 14, 2011 +.Dd May 3, 2011 .Dt RCTL 8 .Os .Sh NAME @@ -90,7 +90,7 @@ Subject defines the kind of entity the rule applies to. It can be either process, user, login class, or jail. .Pp Subject ID identifies the subject. It can be user name, -numerical user ID, login class name, jail name, or numerical jail ID. +numerical user ID, login class name, or jail name. .Pp Resource identifies the resource the rule controls. .Pp @@ -177,9 +177,9 @@ Prevent user "joe" from allocating more than 1GB of virtual memory. .Pp Remove all RCTL rules. .Pp -.Dl rctl -hu jail:5 +.Dl rctl -hu jail:www .Pp -Display resource usage information for jail with JID 5. +Display resource usage information for jail named "www". .Pp .Dl rctl -l process:512 .Pp diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c index 055451d1800c..f0c8b2d4b18f 100644 --- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c +++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c @@ -31,6 +31,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. */ + +#include + #include "cd9660.h" #include "cd9660_eltorito.h" @@ -497,11 +500,43 @@ cd9660_setup_boot_volume_descriptor(volume_descriptor *bvd) return 1; } +static int +cd9660_write_apm_partition_entry(FILE *fd, int index, int total_partitions, + off_t sector_start, off_t nsectors, off_t sector_size, + const char *part_name, const char *part_type) { + uint32_t apm32; + uint16_t apm16; + + fseeko(fd, (off_t)(index + 1) * sector_size, SEEK_SET); + + /* Signature */ + apm16 = htons(0x504d); + fwrite(&apm16, sizeof(apm16), 1, fd); + apm16 = 0; + fwrite(&apm16, sizeof(apm16), 1, fd); + + /* Total number of partitions */ + apm32 = htonl(total_partitions); + fwrite(&apm32, sizeof(apm32), 1, fd); + /* Bounds */ + apm32 = htonl(sector_start); + fwrite(&apm32, sizeof(apm32), 1, fd); + apm32 = htonl(nsectors); + fwrite(&apm32, sizeof(apm32), 1, fd); + + fwrite(part_name, strlen(part_name) + 1, 1, fd); + fseek(fd, 32 - strlen(part_name) - 1, SEEK_CUR); + fwrite(part_type, strlen(part_type) + 1, 1, fd); + + return 0; +} + int cd9660_write_boot(FILE *fd) { struct boot_catalog_entry *e; struct cd9660_boot_image *t; + int apm_partitions = 0; /* write boot catalog */ if (fseeko(fd, (off_t)diskStructure.boot_catalog_sector * @@ -533,7 +568,51 @@ cd9660_write_boot(FILE *fd) t->filename, t->sector); } cd9660_copy_file(fd, t->sector, t->filename); + + if (t->system == ET_SYS_MAC) + apm_partitions++; + } + + if (apm_partitions > 0) { + /* Write DDR and global APM info */ + uint32_t apm32; + uint16_t apm16; + int total_parts; + + fseek(fd, 0, SEEK_SET); + apm16 = htons(0x4552); + fwrite(&apm16, sizeof(apm16), 1, fd); + apm16 = htons(diskStructure.sectorSize); + fwrite(&apm16, sizeof(apm16), 1, fd); + apm32 = htonl(diskStructure.totalSectors); + fwrite(&apm32, sizeof(apm32), 1, fd); + + /* Count total needed entries */ + total_parts = 2 + apm_partitions; /* Self + ISO9660 */ + + /* Write self-descriptor */ + cd9660_write_apm_partition_entry(fd, 0, + total_parts, 1, total_parts, diskStructure.sectorSize, + "Apple", "Apple_partition_map"); + + /* Write ISO9660 descriptor, enclosing the whole disk */ + cd9660_write_apm_partition_entry(fd, 1, + total_parts, 0, diskStructure.totalSectors, + diskStructure.sectorSize, "", "CD_ROM_Mode_1"); + + /* Write all partition entries */ + apm_partitions = 0; + TAILQ_FOREACH(t, &diskStructure.boot_images, image_list) { + if (t->system != ET_SYS_MAC) + continue; + + cd9660_write_apm_partition_entry(fd, + 2 + apm_partitions++, total_parts, + t->sector, t->num_sectors, diskStructure.sectorSize, + "CD Boot", "Apple_Bootstrap"); + } } return 0; } + From ed9b4cbe96f6aed547db56209b74fb5ecbae994b Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 4 May 2011 14:55:57 +0000 Subject: [PATCH 015/164] Revert comment introduction. It seems I'm the only one who didn't know of the size mismatch. --- sys/sys/cpuset.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 131d05567b87..32639913973c 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -36,10 +36,6 @@ #define CPU_SETSIZE MAXCPU #endif -/* - * In userland a bigger cpuset structure is preferable in order to cope - * with kernel bumping of MAXCPU and still have a compatible layout. - */ #define CPU_MAXSIZE (4 * MAXCPU) #ifndef CPU_SETSIZE From f756d5bed6346f4902b1da276e52098882a7a66b Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 4 May 2011 20:29:40 +0000 Subject: [PATCH 016/164] Revert md_assert_preempt() introduction. Discussed with: jeff, jhb --- sys/amd64/amd64/mp_machdep.c | 16 ---------------- sys/amd64/include/smp.h | 1 - sys/i386/i386/mp_machdep.c | 16 ---------------- sys/i386/include/smp.h | 1 - sys/i386/xen/mp_machdep.c | 16 ---------------- 5 files changed, 50 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 70ba466720f4..8e8dc67bdc1c 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -1428,22 +1428,6 @@ cpususpend_handler(void) intr_restore(rf); } -void -md_assert_nopreempt(void) -{ -#ifdef INVARIANTS - struct thread *td; - register_t rflags; - - td = curthread; - rflags = read_rflags(); - - if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) - panic("Preemption still allowed, thread %s\n", - (td->td_pinned <= 0) ? "not pinned" : "pinned"); -#endif -} - /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index bafb349ced2f..ec107f931055 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -64,7 +64,6 @@ void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpumask_t cpus, u_int ipi); -void md_assert_nopreempt(void); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index f36bf1d5c0de..a07b06c53f75 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -1486,22 +1486,6 @@ cpustop_handler(void) } } -void -md_assert_nopreempt(void) -{ -#ifdef INVARIANTS - struct thread *td; - register_t rflags; - - td = curthread; - rflags = read_rflags(); - - if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) - panic("Preemption still allowed, thread %s\n", - (td->td_pinned <= 0) ? "not pinned" : "pinned"); -#endif -} - /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index 2e2ede4f66f1..b512e00b4228 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -65,7 +65,6 @@ void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpumask_t cpus, u_int ipi); -void md_assert_nopreempt(void); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 2cd07627cb10..670d110af49c 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -1216,22 +1216,6 @@ cpustop_handler(void) } } -void -md_assert_nopreempt(void) -{ -#ifdef INVARIANTS - struct thread *td; - register_t rflags; - - td = curthread; - rflags = read_rflags(); - - if ((rflags & PSL_I) != 0 && td->td_critnest <= 0) - panic("Preemption still allowed, thread %s\n", - (td->td_pinned <= 0) ? "not pinned" : "pinned"); -#endif -} - /* * This is called once the rest of the system is up and running and we're * ready to let the AP's out of the pen. From fe4de567b50f7ca317b16f69b7b3a7de693025af Mon Sep 17 00:00:00 2001 From: attilio Date: Thu, 5 May 2011 14:39:14 +0000 Subject: [PATCH 017/164] Commit the support for removing cpumask_t and replacing it directly with cpuset_t objects. That is going to offer the underlying support for a simple bump of MAXCPU and then support for number of cpus > 32 (as it is today). Right now, cpumask_t is an int, 32 bits on all our supported architecture. cpumask_t on the other side is implemented as an array of longs, and easilly extendible by definition. The architectures touched by this commit are the following: - amd64 - i386 - pc98 - arm - ia64 - XEN while the others are still missing. Userland is believed to be fully converted with the changes contained here. Some technical notes: - This commit may be considered an ABI nop for all the architectures different from amd64 and ia64 (and sparc64 in the future) - per-cpu members, which are now converted to cpuset_t, needs to be accessed avoiding migration, because the size of cpuset_t should be considered unknown - size of cpuset_t objects is different from kernel and userland (this is primirally done in order to leave some more space in userland to cope with KBI extensions). If you need to access kernel cpuset_t from the userland please refer to example in this patch on how to do that correctly (kgdb may be a good source, for example). - Support for other architectures is going to be added soon - Only MAXCPU for amd64 is bumped now The patch has been tested by sbruno and Nicholas Esborn on opteron 4 x 12 pack CPUs. More testing on big SMP is expected to came soon. pluknet tested the patch with his 8-ways on both amd64 and i386. Tested by: pluknet, sbruno, gianni, Nicholas Esborn Reviewed by: jeff, jhb, sbruno --- gnu/usr.bin/gdb/kgdb/kthr.c | 18 +- lib/libmemstat/memstat_uma.c | 10 +- sys/amd64/acpica/acpi_wakeup.c | 21 +- sys/amd64/amd64/intr_machdep.c | 10 +- sys/amd64/amd64/mp_machdep.c | 224 ++++++++++++---------- sys/amd64/amd64/pmap.c | 84 ++++---- sys/amd64/amd64/vm_machdep.c | 21 +- sys/amd64/include/_types.h | 1 - sys/amd64/include/param.h | 2 +- sys/amd64/include/pmap.h | 3 +- sys/amd64/include/smp.h | 8 +- sys/arm/arm/pmap.c | 4 +- sys/arm/include/_types.h | 1 - sys/arm/include/pmap.h | 3 +- sys/cddl/dev/cyclic/i386/cyclic_machdep.c | 4 +- sys/cddl/dev/dtrace/amd64/dtrace_subr.c | 9 +- sys/cddl/dev/dtrace/i386/dtrace_subr.c | 10 +- sys/dev/hwpmc/hwpmc_mod.c | 8 +- sys/dev/xen/control/control.c | 21 +- sys/geom/eli/g_eli.c | 2 +- sys/i386/i386/intr_machdep.c | 10 +- sys/i386/i386/mp_machdep.c | 212 ++++++++++---------- sys/i386/i386/pmap.c | 91 +++++---- sys/i386/i386/vm_machdep.c | 36 ++-- sys/i386/include/_types.h | 1 - sys/i386/include/pmap.h | 3 +- sys/i386/include/sf_buf.h | 3 +- sys/i386/include/smp.h | 8 +- sys/i386/xen/mp_machdep.c | 117 ++++++----- sys/i386/xen/pmap.c | 54 +++--- sys/ia64/ia64/mp_machdep.c | 14 +- sys/ia64/include/_types.h | 1 - sys/ia64/include/smp.h | 4 +- sys/kern/kern_cpuset.c | 48 ++++- sys/kern/kern_pmc.c | 6 +- sys/kern/kern_rmlock.c | 15 +- sys/kern/sched_4bsd.c | 66 ++++--- sys/kern/sched_ule.c | 9 +- sys/kern/subr_kdb.c | 3 +- sys/kern/subr_pcpu.c | 2 +- sys/kern/subr_smp.c | 87 +++++---- sys/ofed/include/linux/list.h | 1 + sys/sys/_cpuset.h | 52 +++++ sys/sys/_rmlock.h | 2 +- sys/sys/cpuset.h | 62 ++++-- sys/sys/pcpu.h | 5 +- sys/sys/pmckern.h | 4 +- sys/sys/smp.h | 26 +-- sys/sys/types.h | 1 - sys/x86/x86/local_apic.c | 2 +- usr.sbin/pmccontrol/pmccontrol.c | 23 ++- 51 files changed, 871 insertions(+), 561 deletions(-) create mode 100644 sys/sys/_cpuset.h diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index 5036c9c9aaa9..461f408a73d9 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -37,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -48,7 +50,7 @@ static CORE_ADDR dumppcb; static int dumptid; static CORE_ADDR stoppcbs; -static __cpumask_t stopped_cpus; +static cpuset_t stopped_cpus; static struct kthr *first; struct kthr *curkthr; @@ -76,6 +78,7 @@ kgdb_thr_init(void) { struct proc p; struct thread td; + long cpusetsize; struct kthr *kt; CORE_ADDR addr; uintptr_t paddr; @@ -102,10 +105,11 @@ kgdb_thr_init(void) dumptid = -1; addr = kgdb_lookup("stopped_cpus"); - if (addr != 0) - kvm_read(kvm, addr, &stopped_cpus, sizeof(stopped_cpus)); - else - stopped_cpus = 0; + CPU_ZERO(&stopped_cpus); + cpusetsize = sysconf(_SC_CPUSET_SIZE); + if (cpusetsize != -1 && (u_long)cpusetsize <= sizeof(cpuset_t) && + addr != 0) + kvm_read(kvm, addr, &stopped_cpus, cpusetsize); stoppcbs = kgdb_lookup("stoppcbs"); @@ -126,8 +130,8 @@ kgdb_thr_init(void) kt->kaddr = addr; if (td.td_tid == dumptid) kt->pcb = dumppcb; - else if (td.td_state == TDS_RUNNING && ((1 << td.td_oncpu) & stopped_cpus) - && stoppcbs != 0) + else if (td.td_state == TDS_RUNNING && stoppcbs != 0 && + CPU_ISSET(td.td_oncpu, &stopped_cpus)) kt->pcb = (uintptr_t) stoppcbs + sizeof(struct pcb) * td.td_oncpu; else kt->pcb = (uintptr_t)td.td_pcb; diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 10ff8ec36a81..302093744b5c 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "memstat.h" #include "memstat_internal.h" @@ -315,6 +316,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) int hint_dontsearch, i, mp_maxid, ret; char name[MEMTYPE_MAXNAME]; cpuset_t all_cpus; + long cpusetsize; kvm_t *kvm; kvm = (kvm_t *)kvm_handle; @@ -338,7 +340,13 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) list->mtl_error = ret; return (-1); } - ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0); + cpusetsize = sysconf(_SC_CPUSET_SIZE); + if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { + list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL; + return (-1); + } + CPU_ZERO(&all_cpus); + ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, cpusetsize, 0); if (ret != 0) { list->mtl_error = ret; return (-1); diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c index 57341c938f14..29e66c52a2f2 100644 --- a/sys/amd64/acpica/acpi_wakeup.c +++ b/sys/amd64/acpica/acpi_wakeup.c @@ -78,7 +78,7 @@ static void acpi_stop_beep(void *); #ifdef SMP static int acpi_wakeup_ap(struct acpi_softc *, int); -static void acpi_wakeup_cpus(struct acpi_softc *, cpumask_t); +static void acpi_wakeup_cpus(struct acpi_softc *, const cpuset_t *); #endif #define WAKECODE_VADDR(sc) ((sc)->acpi_wakeaddr + (3 * PAGE_SIZE)) @@ -173,7 +173,7 @@ acpi_wakeup_ap(struct acpi_softc *sc, int cpu) #define BIOS_WARM (0x0a) static void -acpi_wakeup_cpus(struct acpi_softc *sc, cpumask_t wakeup_cpus) +acpi_wakeup_cpus(struct acpi_softc *sc, const cpuset_t *wakeup_cpus) { uint32_t mpbioswarmvec; int cpu; @@ -192,7 +192,7 @@ acpi_wakeup_cpus(struct acpi_softc *sc, cpumask_t wakeup_cpus) /* Wake up each AP. */ for (cpu = 1; cpu < mp_ncpus; cpu++) { - if ((wakeup_cpus & (1 << cpu)) == 0) + if (!CPU_ISSET(cpu, wakeup_cpus)) continue; if (acpi_wakeup_ap(sc, cpu) == 0) { /* restore the warmstart vector */ @@ -214,7 +214,7 @@ int acpi_sleep_machdep(struct acpi_softc *sc, int state) { #ifdef SMP - cpumask_t wakeup_cpus; + cpuset_t wakeup_cpus; #endif register_t cr3, rf; ACPI_STATUS status; @@ -244,10 +244,9 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) if (savectx(susppcbs[0])) { #ifdef SMP - if (wakeup_cpus != 0 && suspend_cpus(wakeup_cpus) == 0) { - device_printf(sc->acpi_dev, - "Failed to suspend APs: CPU mask = 0x%jx\n", - (uintmax_t)(wakeup_cpus & ~stopped_cpus)); + if (!CPU_EMPTY(&wakeup_cpus) && + suspend_cpus(wakeup_cpus) == 0) { + device_printf(sc->acpi_dev, "Failed to suspend APs\n"); goto out; } #endif @@ -282,8 +281,8 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) PCPU_SET(switchtime, 0); PCPU_SET(switchticks, ticks); #ifdef SMP - if (wakeup_cpus != 0) - acpi_wakeup_cpus(sc, wakeup_cpus); + if (!CPU_EMPTY(&wakeup_cpus)) + acpi_wakeup_cpus(sc, &wakeup_cpus); #endif acpi_resync_clock(sc); ret = 0; @@ -291,7 +290,7 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state) out: #ifdef SMP - if (wakeup_cpus != 0) + if (!CPU_EMPTY(&wakeup_cpus)) restart_cpus(wakeup_cpus); #endif diff --git a/sys/amd64/amd64/intr_machdep.c b/sys/amd64/amd64/intr_machdep.c index 4edef81c01fa..3a8953153ff8 100644 --- a/sys/amd64/amd64/intr_machdep.c +++ b/sys/amd64/amd64/intr_machdep.c @@ -443,8 +443,7 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) * allocate CPUs round-robin. */ -/* The BSP is always a valid target. */ -static cpumask_t intr_cpus = (1 << 0); +static cpuset_t intr_cpus; static int current_cpu; /* @@ -466,7 +465,7 @@ intr_next_cpu(void) current_cpu++; if (current_cpu > mp_maxid) current_cpu = 0; - } while (!(intr_cpus & (1 << current_cpu))); + } while (!CPU_ISSET(current_cpu, &intr_cpus)); mtx_unlock_spin(&icu_lock); return (apic_id); } @@ -497,7 +496,7 @@ intr_add_cpu(u_int cpu) printf("INTR: Adding local APIC %d as a target\n", cpu_apic_ids[cpu]); - intr_cpus |= (1 << cpu); + CPU_SET(cpu, &intr_cpus); } /* @@ -510,6 +509,9 @@ intr_shuffle_irqs(void *arg __unused) struct intsrc *isrc; int i; + /* The BSP is always a valid target. */ + CPU_SETOF(0, &intr_cpus); + /* Don't bother on UP. */ if (mp_ncpus == 1) return; diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 8e8dc67bdc1c..57e91a8444cc 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef GPROF #include #endif @@ -125,7 +126,7 @@ extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32); * Local data and functions. */ -static volatile cpumask_t ipi_nmi_pending; +static volatile cpuset_t ipi_nmi_pending; /* used to hold the AP's until we are ready to release them */ static struct mtx ap_boot_mtx; @@ -161,7 +162,7 @@ static void release_aps(void *dummy); static int hlt_logical_cpus; static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ -static cpumask_t hyperthreading_cpus_mask; +static cpuset_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; static struct sysctl_ctx_list logical_cpu_clist; static u_int bootMP_size; @@ -311,7 +312,7 @@ topo_probe(void) if (cpu_topo_probed) return; - logical_cpus_mask = 0; + CPU_ZERO(&logical_cpus_mask); if (mp_ncpus <= 1) cpu_cores = cpu_logical = 1; else if (cpu_vendor_id == CPU_VENDOR_AMD) @@ -455,7 +456,7 @@ cpu_mp_probe(void) * Always record BSP in CPU map so that the mbuf init code works * correctly. */ - all_cpus = 1; + CPU_SETOF(0, &all_cpus); if (mp_ncpus == 0) { /* * No CPUs were found, so this must be a UP system. Setup @@ -582,6 +583,7 @@ cpu_mp_announce(void) void init_secondary(void) { + cpuset_t tcpuset, tallcpus; struct pcpu *pc; struct nmi_pcpu *np; u_int64_t msr, cr0; @@ -713,19 +715,22 @@ init_secondary(void) CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid)); printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); + tcpuset = PCPU_GET(cpumask); /* Determine if we are a logical CPU. */ /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) - logical_cpus_mask |= PCPU_GET(cpumask); - + CPU_OR(&logical_cpus_mask, &tcpuset); + /* Determine if we are a hyperthread. */ if (hyperthreading_cpus > 1 && PCPU_GET(apic_id) % hyperthreading_cpus != 0) - hyperthreading_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&hyperthreading_cpus_mask, &tcpuset); /* Build our map of 'other' CPUs. */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + CPU_NAND(&tallcpus, &tcpuset); + PCPU_SET(other_cpus, tallcpus); if (bootverbose) lapic_dump("AP"); @@ -868,6 +873,7 @@ assign_cpu_ids(void) static int start_all_aps(void) { + cpuset_t tallcpus, tcpuset; vm_offset_t va = boot_address + KERNBASE; u_int64_t *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; @@ -932,11 +938,14 @@ start_all_aps(void) panic("AP #%d (PHY# %d) failed!", cpu, apic_id); } - all_cpus |= (1 << cpu); /* record AP in CPU map */ + CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ } /* build our map of 'other' CPUs */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + tcpuset = PCPU_GET(cpumask); + CPU_NAND(&tallcpus, &tcpuset); + PCPU_SET(other_cpus, tallcpus); /* restore the warmstart vector */ *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; @@ -1064,6 +1073,30 @@ SYSCTL_UINT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW, &ipi_masked_range_size, 0, ""); #endif /* COUNT_XINVLTLB_HITS */ +/* + * Send an IPI to specified CPU handling the bitmap logic. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (old_pending) + return; + } + lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); +} + /* * Flush the TLB on all other CPU's */ @@ -1088,28 +1121,19 @@ smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2) } static void -smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) +smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) { - int ncpu, othercpus; + int cpu, ncpu, othercpus; othercpus = mp_ncpus - 1; - if (mask == (cpumask_t)-1) { - ncpu = othercpus; - if (ncpu < 1) + if (CPU_ISFULLSET(&mask)) { + if (othercpus < 1) return; } else { - mask &= ~PCPU_GET(cpumask); - if (mask == 0) - return; - ncpu = bitcount32(mask); - if (ncpu > othercpus) { - /* XXX this should be a panic offence */ - printf("SMP: tlb shootdown to %d other cpus (only have %d)\n", - ncpu, othercpus); - ncpu = othercpus; - } - /* XXX should be a panic, implied by mask == 0 above */ - if (ncpu < 1) + sched_pin(); + CPU_NAND(&mask, PCPU_PTR(cpumask)); + sched_unpin(); + if (CPU_EMPTY(&mask)) return; } if (!(read_rflags() & PSL_I)) @@ -1118,39 +1142,25 @@ smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_o smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); - if (mask == (cpumask_t)-1) + if (CPU_ISFULLSET(&mask)) { + ncpu = othercpus; ipi_all_but_self(vector); - else - ipi_selected(mask, vector); + } else { + ncpu = 0; + while ((cpu = cpusetobj_ffs(&mask)) != 0) { + cpu--; + CPU_CLR(cpu, &mask); + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, + cpu, vector); + ipi_send_cpu(cpu, vector); + ncpu++; + } + } while (smp_tlb_wait < ncpu) ia32_pause(); mtx_unlock_spin(&smp_ipi_mtx); } -/* - * Send an IPI to specified CPU handling the bitmap logic. - */ -static void -ipi_send_cpu(int cpu, u_int ipi) -{ - u_int bitmap, old_pending, new_pending; - - KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - return; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); -} - void smp_cache_flush(void) { @@ -1197,7 +1207,7 @@ smp_invlpg_range(vm_offset_t addr1, vm_offset_t addr2) } void -smp_masked_invltlb(cpumask_t mask) +smp_masked_invltlb(cpuset_t mask) { if (smp_started) { @@ -1209,7 +1219,7 @@ smp_masked_invltlb(cpumask_t mask) } void -smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) +smp_masked_invlpg(cpuset_t mask, vm_offset_t addr) { if (smp_started) { @@ -1221,7 +1231,7 @@ smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) } void -smp_masked_invlpg_range(cpumask_t mask, vm_offset_t addr1, vm_offset_t addr2) +smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2) { if (smp_started) { @@ -1274,7 +1284,7 @@ ipi_bitmap_handler(struct trapframe frame) * send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, u_int ipi) +ipi_selected(cpuset_t cpus, u_int ipi) { int cpu; @@ -1284,12 +1294,12 @@ ipi_selected(cpumask_t cpus, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, cpus); + CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi); - while ((cpu = ffs(cpus)) != 0) { + while ((cpu = cpusetobj_ffs(&cpus)) != 0) { cpu--; - cpus &= ~(1 << cpu); + CPU_CLR(cpu, &cpus); + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); } } @@ -1307,7 +1317,7 @@ ipi_cpu(int cpu, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, 1 << cpu); + CPU_SET_ATOMIC(cpu, &ipi_nmi_pending); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); @@ -1320,8 +1330,10 @@ void ipi_all_but_self(u_int ipi) { + sched_pin(); if (IPI_IS_BITMAPED(ipi)) { ipi_selected(PCPU_GET(other_cpus), ipi); + sched_unpin(); return; } @@ -1331,7 +1343,8 @@ ipi_all_but_self(u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, PCPU_GET(other_cpus)); + CPU_OR_ATOMIC(&ipi_nmi_pending, PCPU_PTR(other_cpus)); + sched_unpin(); CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); @@ -1340,7 +1353,7 @@ ipi_all_but_self(u_int ipi) int ipi_nmi_handler() { - cpumask_t cpumask; + cpuset_t cpumask; /* * As long as there is not a simple way to know about a NMI's @@ -1348,11 +1361,13 @@ ipi_nmi_handler() * the global pending bitword an IPI_STOP_HARD has been issued * and should be handled. */ + sched_pin(); cpumask = PCPU_GET(cpumask); - if ((ipi_nmi_pending & cpumask) == 0) + sched_unpin(); + if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask)) return (1); - atomic_clear_int(&ipi_nmi_pending, cpumask); + CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask); cpustop_handler(); return (0); } @@ -1364,23 +1379,25 @@ ipi_nmi_handler() void cpustop_handler(void) { - cpumask_t cpumask; + cpuset_t cpumask; u_int cpu; + sched_pin(); cpu = PCPU_GET(cpuid); cpumask = PCPU_GET(cpumask); + sched_unpin(); savectx(&stoppcbs[cpu]); /* Indicate that we are stopped */ - atomic_set_int(&stopped_cpus, cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &cpumask); /* Wait for restart */ - while (!(started_cpus & cpumask)) + while (!CPU_OVERLAP(&started_cpus, &cpumask)) ia32_pause(); - atomic_clear_int(&started_cpus, cpumask); - atomic_clear_int(&stopped_cpus, cpumask); + CPU_NAND_ATOMIC(&started_cpus, &cpumask); + CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); if (cpu == 0 && cpustop_restartfunc != NULL) { cpustop_restartfunc(); @@ -1395,7 +1412,7 @@ cpustop_handler(void) void cpususpend_handler(void) { - cpumask_t cpumask; + cpuset_t cpumask; register_t cr3, rf; u_int cpu; @@ -1407,7 +1424,7 @@ cpususpend_handler(void) if (savectx(susppcbs[cpu])) { wbinvd(); - atomic_set_int(&stopped_cpus, cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &cpumask); } else { pmap_init_pat(); PCPU_SET(switchtime, 0); @@ -1415,11 +1432,11 @@ cpususpend_handler(void) } /* Wait for resume */ - while (!(started_cpus & cpumask)) + while (!CPU_OVERLAP(&started_cpus, &cpumask)) ia32_pause(); - atomic_clear_int(&started_cpus, cpumask); - atomic_clear_int(&stopped_cpus, cpumask); + CPU_NAND_ATOMIC(&started_cpus, &cpumask); + CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); /* Restore CR3 and enable interrupts */ load_cr3(cr3); @@ -1447,30 +1464,30 @@ SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); static int sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) { - cpumask_t mask; + cpuset_t mask; int error; mask = hlt_cpus_mask; - error = sysctl_handle_int(oidp, &mask, 0, req); + error = sysctl_handle_opaque(oidp, &mask, sizeof(mask), req); if (error || !req->newptr) return (error); - if (logical_cpus_mask != 0 && - (mask & logical_cpus_mask) == logical_cpus_mask) + if (!CPU_EMPTY(&logical_cpus_mask) && + CPU_SUBSET(&mask, &logical_cpus_mask)) hlt_logical_cpus = 1; else hlt_logical_cpus = 0; if (! hyperthreading_allowed) - mask |= hyperthreading_cpus_mask; + CPU_OR(&mask, &hyperthreading_cpus_mask); - if ((mask & all_cpus) == all_cpus) - mask &= ~(1<<0); + if (CPU_SUBSET(&mask, &all_cpus)) + CPU_CLR(0, &mask); hlt_cpus_mask = mask; return (error); } -SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, CTLTYPE_INT|CTLFLAG_RW, - 0, 0, sysctl_hlt_cpus, "IU", +SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, + CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_hlt_cpus, "S", "Bitmap of CPUs to halt. 101 (binary) will halt CPUs 0 and 2."); static int @@ -1484,15 +1501,15 @@ sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) return (error); if (disable) - hlt_cpus_mask |= logical_cpus_mask; + CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); else - hlt_cpus_mask &= ~logical_cpus_mask; + CPU_NAND(&hlt_cpus_mask, &logical_cpus_mask); if (! hyperthreading_allowed) - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - if ((hlt_cpus_mask & all_cpus) == all_cpus) - hlt_cpus_mask &= ~(1<<0); + if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) + CPU_CLR(0, &hlt_cpus_mask); hlt_logical_cpus = disable; return (error); @@ -1519,18 +1536,18 @@ sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) #endif if (allowed) - hlt_cpus_mask &= ~hyperthreading_cpus_mask; + CPU_NAND(&hlt_cpus_mask, &hyperthreading_cpus_mask); else - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - if (logical_cpus_mask != 0 && - (hlt_cpus_mask & logical_cpus_mask) == logical_cpus_mask) + if (!CPU_EMPTY(&logical_cpus_mask) && + CPU_SUBSET(&hlt_cpus_mask, &logical_cpus_mask)) hlt_logical_cpus = 1; else hlt_logical_cpus = 0; - if ((hlt_cpus_mask & all_cpus) == all_cpus) - hlt_cpus_mask &= ~(1<<0); + if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) + CPU_CLR(0, &hlt_cpus_mask); hyperthreading_allowed = allowed; return (error); @@ -1540,7 +1557,7 @@ static void cpu_hlt_setup(void *dummy __unused) { - if (logical_cpus_mask != 0) { + if (!CPU_EMPTY(&logical_cpus_mask)) { TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", &hlt_logical_cpus); sysctl_ctx_init(&logical_cpu_clist); @@ -1554,20 +1571,21 @@ cpu_hlt_setup(void *dummy __unused) &logical_cpus_mask, 0, ""); if (hlt_logical_cpus) - hlt_cpus_mask |= logical_cpus_mask; + CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); /* * If necessary for security purposes, force * hyperthreading off, regardless of the value * of hlt_logical_cpus. */ - if (hyperthreading_cpus_mask) { + if (!CPU_EMPTY(&hyperthreading_cpus_mask)) { SYSCTL_ADD_PROC(&logical_cpu_clist, SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_hyperthreading_allowed, "IU", ""); if (! hyperthreading_allowed) - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, + &hyperthreading_cpus_mask); } } } @@ -1576,7 +1594,7 @@ SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_ANY, cpu_hlt_setup, NULL); int mp_grab_cpu_hlt(void) { - cpumask_t mask; + cpuset_t mask; #ifdef MP_WATCHDOG u_int cpuid; #endif @@ -1589,7 +1607,7 @@ mp_grab_cpu_hlt(void) #endif retval = 0; - while (mask & hlt_cpus_mask) { + while (CPU_OVERLAP(&mask, &hlt_cpus_mask)) { retval = 1; __asm __volatile("sti; hlt" : : : "memory"); } diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index c9ff9bcc14ae..025ca5f981c9 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -123,6 +123,8 @@ __FBSDID("$FreeBSD$"); #include #ifdef SMP #include +#else +#include #endif #include @@ -581,7 +583,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr) PMAP_LOCK_INIT(kernel_pmap); kernel_pmap->pm_pml4 = (pdp_entry_t *)PHYS_TO_DMAP(KPML4phys); kernel_pmap->pm_root = NULL; - kernel_pmap->pm_active = -1; /* don't allow deactivation */ + CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvchunk); /* @@ -923,19 +925,20 @@ pmap_update_pde_invalidate(vm_offset_t va, pd_entry_t newpde) void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invlpg(va); smp_invlpg(va); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invlpg(va); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg(pmap->pm_active & other_cpus, va); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg(other_cpus, va); } sched_unpin(); } @@ -943,23 +946,23 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; vm_offset_t addr; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); smp_invlpg_range(sva, eva); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg_range(pmap->pm_active & other_cpus, - sva, eva); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg_range(other_cpus, sva, eva); } sched_unpin(); } @@ -967,19 +970,20 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) void pmap_invalidate_all(pmap_t pmap) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invltlb(); smp_invltlb(); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invltlb(); - if (pmap->pm_active & other_cpus) - smp_masked_invltlb(pmap->pm_active & other_cpus); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invltlb(other_cpus); } sched_unpin(); } @@ -995,8 +999,8 @@ pmap_invalidate_cache(void) } struct pde_action { - cpumask_t store; /* processor that updates the PDE */ - cpumask_t invalidate; /* processors that invalidate their TLB */ + cpuset_t store; /* processor that updates the PDE */ + cpuset_t invalidate; /* processors that invalidate their TLB */ vm_offset_t va; pd_entry_t *pde; pd_entry_t newpde; @@ -1007,8 +1011,12 @@ pmap_update_pde_action(void *arg) { struct pde_action *act = arg; - if (act->store == PCPU_GET(cpumask)) + sched_pin(); + if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { + sched_unpin(); pde_store(act->pde, act->newpde); + } else + sched_unpin(); } static void @@ -1016,8 +1024,12 @@ pmap_update_pde_teardown(void *arg) { struct pde_action *act = arg; - if ((act->invalidate & PCPU_GET(cpumask)) != 0) + sched_pin(); + if (CPU_OVERLAP(&act->invalidate, PCPU_PTR(cpumask))) { + sched_unpin(); pmap_update_pde_invalidate(act->va, act->newpde); + } else + sched_unpin(); } /* @@ -1032,26 +1044,28 @@ static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) { struct pde_action act; - cpumask_t active, cpumask; + cpuset_t active, cpumask, other_cpus; sched_pin(); cpumask = PCPU_GET(cpumask); + other_cpus = PCPU_GET(other_cpus); if (pmap == kernel_pmap) active = all_cpus; else active = pmap->pm_active; - if ((active & PCPU_GET(other_cpus)) != 0) { + if (CPU_OVERLAP(&active, &other_cpus)) { act.store = cpumask; act.invalidate = active; act.va = va; act.pde = pde; act.newpde = newpde; - smp_rendezvous_cpus(cpumask | active, + CPU_OR(&cpumask, &active); + smp_rendezvous_cpus(cpumask, smp_no_rendevous_barrier, pmap_update_pde_action, pmap_update_pde_teardown, &act); } else { pde_store(pde, newpde); - if ((active & cpumask) != 0) + if (CPU_OVERLAP(&active, &cpumask)) pmap_update_pde_invalidate(va, newpde); } sched_unpin(); @@ -1065,7 +1079,7 @@ PMAP_INLINE void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invlpg(va); } @@ -1074,7 +1088,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { vm_offset_t addr; - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); } @@ -1083,7 +1097,7 @@ PMAP_INLINE void pmap_invalidate_all(pmap_t pmap) { - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invltlb(); } @@ -1099,7 +1113,7 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) { pde_store(pde, newpde); - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) pmap_update_pde_invalidate(va, newpde); } #endif /* !SMP */ @@ -1607,7 +1621,7 @@ pmap_pinit0(pmap_t pmap) PMAP_LOCK_INIT(pmap); pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(KPML4phys); pmap->pm_root = NULL; - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); PCPU_SET(curpmap, pmap); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -1649,7 +1663,7 @@ pmap_pinit(pmap_t pmap) pmap->pm_pml4[PML4PML4I] = VM_PAGE_TO_PHYS(pml4pg) | PG_V | PG_RW | PG_A | PG_M; pmap->pm_root = NULL; - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -5087,11 +5101,11 @@ pmap_activate(struct thread *td) pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); #ifdef SMP - atomic_clear_int(&oldpmap->pm_active, PCPU_GET(cpumask)); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); #else - oldpmap->pm_active &= ~PCPU_GET(cpumask); - pmap->pm_active |= PCPU_GET(cpumask); + CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask)); #endif cr3 = DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4); td->td_pcb->pcb_cr3 = cr3; diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 972484a80a08..13f5cd06b2b3 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -512,11 +514,13 @@ cpu_set_user_tls(struct thread *td, void *tls_base) static void cpu_reset_proxy() { + cpuset_t tcrp; cpu_reset_proxy_active = 1; while (cpu_reset_proxy_active == 1) ; /* Wait for other cpu to see that we've started */ - stop_cpus((1< +#include #include #include @@ -251,7 +252,7 @@ struct pmap { struct mtx pm_mtx; 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 */ + cpuset_t pm_active; /* active on cpus */ /* spare u_int here due to padding */ struct pmap_statistics pm_stats; /* pmap statistics */ vm_page_t pm_root; /* spare page table pages */ diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index ec107f931055..a009b35b150e 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -63,17 +63,17 @@ void ipi_all_but_self(u_int ipi); void ipi_bitmap_handler(struct trapframe frame); void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); -void ipi_selected(cpumask_t cpus, u_int ipi); +void ipi_selected(cpuset_t cpus, u_int ipi); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); void smp_invlpg(vm_offset_t addr); -void smp_masked_invlpg(cpumask_t mask, vm_offset_t addr); +void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva); -void smp_masked_invlpg_range(cpumask_t mask, vm_offset_t startva, +void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva, vm_offset_t endva); void smp_invltlb(void); -void smp_masked_invltlb(cpumask_t mask); +void smp_masked_invltlb(cpuset_t mask); #endif /* !LOCORE */ #endif /* SMP */ diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c index f33a692e7302..16487b08ef9d 100644 --- a/sys/arm/arm/pmap.c +++ b/sys/arm/arm/pmap.c @@ -2395,7 +2395,7 @@ pmap_bootstrap(vm_offset_t firstaddr, vm_offset_t lastaddr, struct pv_addr *l1pt cpu_cpwait(); PMAP_LOCK_INIT(kernel_pmap); - kernel_pmap->pm_active = -1; + CPU_FILL(&kernel_pmap->pm_active); kernel_pmap->pm_domain = PMAP_DOMAIN_KERNEL; TAILQ_INIT(&kernel_pmap->pm_pvlist); @@ -3826,7 +3826,7 @@ pmap_pinit(pmap_t pmap) pmap_alloc_l1(pmap); bzero(pmap->pm_l2, sizeof(pmap->pm_l2)); - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvlist); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h index 48dd2a784fd7..d8386f3225d0 100644 --- a/sys/arm/include/_types.h +++ b/sys/arm/include/_types.h @@ -67,7 +67,6 @@ typedef unsigned long long __uint64_t; * Standard type definitions. */ typedef __uint32_t __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef __int32_t __critical_t; typedef double __double_t; typedef double __float_t; diff --git a/sys/arm/include/pmap.h b/sys/arm/include/pmap.h index 701390a33852..3d63432e332a 100644 --- a/sys/arm/include/pmap.h +++ b/sys/arm/include/pmap.h @@ -62,6 +62,7 @@ #ifndef LOCORE #include +#include #include #include @@ -134,7 +135,7 @@ struct pmap { struct l1_ttable *pm_l1; struct l2_dtable *pm_l2[L2_SIZE]; pd_entry_t *pm_pdir; /* KVA of page directory */ - cpumask_t pm_active; /* active on cpus */ + cpuset_t pm_active; /* active on cpus */ struct pmap_statistics pm_stats; /* pmap statictics */ TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ }; diff --git a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c index 1c18fc14e96c..dc6cb712f228 100644 --- a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c +++ b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c @@ -121,7 +121,9 @@ static void reprogram(cyb_arg_t arg, hrtime_t exp) static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param) { + cpuset_t cpus; - smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid), + CPU_SETOF(c->cpuid, &cpus); + smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, param); } diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c index 102ea0495aff..bc4b8b62b985 100644 --- a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c @@ -113,12 +113,12 @@ dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) void dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg) { - cpumask_t cpus; + cpuset_t cpus; if (cpu == DTRACE_CPUALL) cpus = all_cpus; else - cpus = (cpumask_t)1 << cpu; + CPU_SETOF(cpu, &cpus); smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, arg); @@ -394,7 +394,7 @@ dtrace_gethrtime_init(void *arg) { struct pcpu *pc; uint64_t tsc_f; - cpumask_t map; + cpuset_t map; int i; /* @@ -432,7 +432,8 @@ dtrace_gethrtime_init(void *arg) continue; pc = pcpu_find(i); - map = PCPU_GET(cpumask) | pc->pc_cpumask; + map = PCPU_GET(cpumask); + CPU_OR(&map, &pc->pc_cpumask); smp_rendezvous_cpus(map, dtrace_gethrtime_init_sync, dtrace_gethrtime_init_cpu, diff --git a/sys/cddl/dev/dtrace/i386/dtrace_subr.c b/sys/cddl/dev/dtrace/i386/dtrace_subr.c index 50793c4da4fc..7d460bc2e03b 100644 --- a/sys/cddl/dev/dtrace/i386/dtrace_subr.c +++ b/sys/cddl/dev/dtrace/i386/dtrace_subr.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -113,12 +114,12 @@ dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) void dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg) { - cpumask_t cpus; + cpuset_t cpus; if (cpu == DTRACE_CPUALL) cpus = all_cpus; else - cpus = (cpumask_t)1 << cpu; + CPU_SETOF(cpu, &cpus); smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, arg); @@ -392,9 +393,9 @@ dtrace_gethrtime_init_cpu(void *arg) static void dtrace_gethrtime_init(void *arg) { + cpuset_t map; struct pcpu *pc; uint64_t tsc_f; - cpumask_t map; int i; /* @@ -432,7 +433,8 @@ dtrace_gethrtime_init(void *arg) continue; pc = pcpu_find(i); - map = PCPU_GET(cpumask) | pc->pc_cpumask; + map = PCPU_GET(cpumask); + CPU_OR(&map, &pc->pc_cpumask); smp_rendezvous_cpus(map, dtrace_gethrtime_init_sync, dtrace_gethrtime_init_cpu, diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index d6225d8f5ae3..4cfcea87fa5b 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -1991,7 +1991,7 @@ pmc_hook_handler(struct thread *td, int function, void *arg) * had already processed the interrupt). We don't * lose the interrupt sample. */ - atomic_clear_int(&pmc_cpumask, (1 << PCPU_GET(cpuid))); + CPU_CLR_ATOMIC(PCPU_GET(cpuid), &pmc_cpumask); pmc_process_samples(PCPU_GET(cpuid)); break; @@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf, done: /* mark CPU as needing processing */ - atomic_set_int(&pmc_cpumask, (1 << cpu)); + CPU_SET_ATOMIC(cpu, &pmc_cpumask); return (error); } @@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu) break; if (ps->ps_nsamples == PMC_SAMPLE_INUSE) { /* Need a rescan at a later time. */ - atomic_set_int(&pmc_cpumask, (1 << cpu)); + CPU_SET_ATOMIC(cpu, &pmc_cpumask); break; } @@ -4782,7 +4782,7 @@ pmc_cleanup(void) PMCDBG(MOD,INI,0, "%s", "cleanup"); /* switch off sampling */ - pmc_cpumask = 0; + CPU_ZERO(&pmc_cpumask); pmc_intr = NULL; sx_xlock(&pmc_sx); diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c index c03d5365530b..0f4418142684 100644 --- a/sys/dev/xen/control/control.c +++ b/sys/dev/xen/control/control.c @@ -203,24 +203,29 @@ xctrl_suspend() unsigned long max_pfn, start_info_mfn; #ifdef SMP - cpumask_t map; + struct thread *td; + cpuset_t map; /* * Bind us to CPU 0 and stop any other VCPUs. */ - thread_lock(curthread); - sched_bind(curthread, 0); - thread_unlock(curthread); + td = curthread; + thread_lock(td); + sched_bind(td, 0); + thread_unlock(td); KASSERT(PCPU_GET(cpuid) == 0, ("xen_suspend: not running on cpu 0")); - map = PCPU_GET(other_cpus) & ~stopped_cpus; - if (map) + sched_pin(); + map = PCPU_GET(other_cpus); + sched_unpin(); + CPU_NAND(&map, &stopped_cpus); + if (!CPU_EMPTY(&map)) stop_cpus(map); #endif if (DEVICE_SUSPEND(root_bus) != 0) { printf("xen_suspend: device_suspend failed\n"); #ifdef SMP - if (map) + if (!CPU_EMPTY(&map)) restart_cpus(map); #endif return; @@ -289,7 +294,7 @@ xctrl_suspend() thread_lock(curthread); sched_unbind(curthread); thread_unlock(curthread); - if (map) + if (!CPU_EMPTY(&map)) restart_cpus(map); #endif } diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 8b22ee58d72b..6466aef72ab7 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -661,7 +661,7 @@ static int g_eli_cpu_is_disabled(int cpu) { #ifdef SMP - return ((hlt_cpus_mask & (1 << cpu)) != 0); + return (CPU_ISSET(cpu, &hlt_cpus_mask)); #else return (0); #endif diff --git a/sys/i386/i386/intr_machdep.c b/sys/i386/i386/intr_machdep.c index 77b80048620f..56529f7b5b03 100644 --- a/sys/i386/i386/intr_machdep.c +++ b/sys/i386/i386/intr_machdep.c @@ -409,8 +409,7 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) * allocate CPUs round-robin. */ -/* The BSP is always a valid target. */ -static cpumask_t intr_cpus = (1 << 0); +static cpuset_t intr_cpus; static int current_cpu; /* @@ -432,7 +431,7 @@ intr_next_cpu(void) current_cpu++; if (current_cpu > mp_maxid) current_cpu = 0; - } while (!(intr_cpus & (1 << current_cpu))); + } while (!CPU_ISSET(current_cpu, &intr_cpus)); mtx_unlock_spin(&icu_lock); return (apic_id); } @@ -463,7 +462,7 @@ intr_add_cpu(u_int cpu) printf("INTR: Adding local APIC %d as a target\n", cpu_apic_ids[cpu]); - intr_cpus |= (1 << cpu); + CPU_SET(cpu, &intr_cpus); } /* @@ -483,6 +482,9 @@ intr_shuffle_irqs(void *arg __unused) return; #endif + /* The BSP is always a valid target. */ + CPU_SETOF(0, &intr_cpus); + /* Don't bother on UP. */ if (mp_ncpus == 1) return; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index a07b06c53f75..dfe6434518f0 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* cngetc() */ +#include #ifdef GPROF #include #endif @@ -172,7 +173,7 @@ static u_long *ipi_hardclock_counts[MAXCPU]; * Local data and functions. */ -static volatile cpumask_t ipi_nmi_pending; +static volatile cpuset_t ipi_nmi_pending; /* used to hold the AP's until we are ready to release them */ static struct mtx ap_boot_mtx; @@ -209,7 +210,7 @@ static void release_aps(void *dummy); static int hlt_logical_cpus; static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ -static cpumask_t hyperthreading_cpus_mask; +static cpuset_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; static struct sysctl_ctx_list logical_cpu_clist; @@ -358,7 +359,7 @@ topo_probe(void) if (cpu_topo_probed) return; - logical_cpus_mask = 0; + CPU_ZERO(&logical_cpus_mask); if (mp_ncpus <= 1) cpu_cores = cpu_logical = 1; else if (cpu_vendor_id == CPU_VENDOR_AMD) @@ -500,7 +501,7 @@ cpu_mp_probe(void) * Always record BSP in CPU map so that the mbuf init code works * correctly. */ - all_cpus = 1; + CPU_SETOF(0, &all_cpus); if (mp_ncpus == 0) { /* * No CPUs were found, so this must be a UP system. Setup @@ -631,6 +632,7 @@ cpu_mp_announce(void) void init_secondary(void) { + cpuset_t tcpuset, tallcpus; struct pcpu *pc; vm_offset_t addr; int gsel_tss; @@ -755,19 +757,22 @@ init_secondary(void) CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid)); printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); + tcpuset = PCPU_GET(cpumask); /* Determine if we are a logical CPU. */ /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) - logical_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&logical_cpus_mask, &tcpuset); /* Determine if we are a hyperthread. */ if (hyperthreading_cpus > 1 && PCPU_GET(apic_id) % hyperthreading_cpus != 0) - hyperthreading_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&hyperthreading_cpus_mask, &tcpuset); /* Build our map of 'other' CPUs. */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + CPU_NAND(&tallcpus, &tcpuset); + PCPU_SET(other_cpus, tallcpus); if (bootverbose) lapic_dump("AP"); @@ -904,6 +909,7 @@ assign_cpu_ids(void) static int start_all_aps(void) { + cpuset_t tallcpus; #ifndef PC98 u_char mpbiosreason; #endif @@ -963,11 +969,13 @@ start_all_aps(void) } CHECK_PRINT("trace"); /* show checkpoints */ - all_cpus |= (1 << cpu); /* record AP in CPU map */ + CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ } /* build our map of 'other' CPUs */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + CPU_NAND(&tallcpus, PCPU_PTR(cpumask)); + PCPU_SET(other_cpus, tallcpus); /* restore the warmstart vector */ *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; @@ -1163,6 +1171,30 @@ SYSCTL_INT(_debug_xhits, OID_AUTO, ipi_masked_range_size, CTLFLAG_RW, &ipi_masked_range_size, 0, ""); #endif /* COUNT_XINVLTLB_HITS */ +/* + * Send an IPI to specified CPU handling the bitmap logic. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (old_pending) + return; + } + lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); +} + /* * Flush the TLB on all other CPU's */ @@ -1187,28 +1219,19 @@ smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2) } static void -smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) +smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) { - int ncpu, othercpus; + int cpu, ncpu, othercpus; othercpus = mp_ncpus - 1; - if (mask == (u_int)-1) { - ncpu = othercpus; - if (ncpu < 1) + if (CPU_ISFULLSET(&mask)) { + if (othercpus < 1) return; } else { - mask &= ~PCPU_GET(cpumask); - if (mask == 0) - return; - ncpu = bitcount32(mask); - if (ncpu > othercpus) { - /* XXX this should be a panic offence */ - printf("SMP: tlb shootdown to %d other cpus (only have %d)\n", - ncpu, othercpus); - ncpu = othercpus; - } - /* XXX should be a panic, implied by mask == 0 above */ - if (ncpu < 1) + sched_pin(); + CPU_NAND(&mask, PCPU_PTR(cpumask)); + sched_unpin(); + if (CPU_EMPTY(&mask)) return; } if (!(read_eflags() & PSL_I)) @@ -1217,39 +1240,25 @@ smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_o smp_tlb_addr1 = addr1; smp_tlb_addr2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); - if (mask == (u_int)-1) + if (CPU_ISFULLSET(&mask)) { + ncpu = othercpus; ipi_all_but_self(vector); - else - ipi_selected(mask, vector); + } else { + ncpu = 0; + while ((cpu = cpusetobj_ffs(&mask)) != 0) { + cpu--; + CPU_CLR(cpu, &mask); + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, + vector); + ipi_send_cpu(cpu, vector); + ncpu++; + } + } while (smp_tlb_wait < ncpu) ia32_pause(); mtx_unlock_spin(&smp_ipi_mtx); } -/* - * Send an IPI to specified CPU handling the bitmap logic. - */ -static void -ipi_send_cpu(int cpu, u_int ipi) -{ - u_int bitmap, old_pending, new_pending; - - KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - return; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); -} - void smp_cache_flush(void) { @@ -1296,7 +1305,7 @@ smp_invlpg_range(vm_offset_t addr1, vm_offset_t addr2) } void -smp_masked_invltlb(cpumask_t mask) +smp_masked_invltlb(cpuset_t mask) { if (smp_started) { @@ -1308,7 +1317,7 @@ smp_masked_invltlb(cpumask_t mask) } void -smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) +smp_masked_invlpg(cpuset_t mask, vm_offset_t addr) { if (smp_started) { @@ -1320,7 +1329,7 @@ smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) } void -smp_masked_invlpg_range(cpumask_t mask, vm_offset_t addr1, vm_offset_t addr2) +smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2) { if (smp_started) { @@ -1373,7 +1382,7 @@ ipi_bitmap_handler(struct trapframe frame) * send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, u_int ipi) +ipi_selected(cpuset_t cpus, u_int ipi) { int cpu; @@ -1383,12 +1392,12 @@ ipi_selected(cpumask_t cpus, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, cpus); + CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi); - while ((cpu = ffs(cpus)) != 0) { + while ((cpu = cpusetobj_ffs(&cpus)) != 0) { cpu--; - cpus &= ~(1 << cpu); + CPU_CLR(cpu, &cpus); + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); } } @@ -1406,7 +1415,7 @@ ipi_cpu(int cpu, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, 1 << cpu); + CPU_SET_ATOMIC(cpu, &ipi_nmi_pending); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); @@ -1419,8 +1428,10 @@ void ipi_all_but_self(u_int ipi) { + sched_pin(); if (IPI_IS_BITMAPED(ipi)) { ipi_selected(PCPU_GET(other_cpus), ipi); + sched_unpin(); return; } @@ -1430,7 +1441,9 @@ ipi_all_but_self(u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, PCPU_GET(other_cpus)); + CPU_OR_ATOMIC(&ipi_nmi_pending, PCPU_PTR(other_cpus)); + sched_unpin(); + CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS); } @@ -1438,7 +1451,7 @@ ipi_all_but_self(u_int ipi) int ipi_nmi_handler() { - cpumask_t cpumask; + cpuset_t cpumask; /* * As long as there is not a simple way to know about a NMI's @@ -1446,11 +1459,13 @@ ipi_nmi_handler() * the global pending bitword an IPI_STOP_HARD has been issued * and should be handled. */ + sched_pin(); cpumask = PCPU_GET(cpumask); - if ((ipi_nmi_pending & cpumask) == 0) + sched_unpin(); + if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask)) return (1); - atomic_clear_int(&ipi_nmi_pending, cpumask); + CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask); cpustop_handler(); return (0); } @@ -1462,23 +1477,25 @@ ipi_nmi_handler() void cpustop_handler(void) { - cpumask_t cpumask; + cpuset_t cpumask; u_int cpu; + sched_pin(); cpu = PCPU_GET(cpuid); cpumask = PCPU_GET(cpumask); + sched_unpin(); savectx(&stoppcbs[cpu]); /* Indicate that we are stopped */ - atomic_set_int(&stopped_cpus, cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &cpumask); /* Wait for restart */ - while (!(started_cpus & cpumask)) + while (!CPU_OVERLAP(&started_cpus, &cpumask)) ia32_pause(); - atomic_clear_int(&started_cpus, cpumask); - atomic_clear_int(&stopped_cpus, cpumask); + CPU_NAND_ATOMIC(&started_cpus, &cpumask); + CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); if (cpu == 0 && cpustop_restartfunc != NULL) { cpustop_restartfunc(); @@ -1505,30 +1522,30 @@ SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); static int sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) { - cpumask_t mask; + cpuset_t mask; int error; mask = hlt_cpus_mask; - error = sysctl_handle_int(oidp, &mask, 0, req); + error = sysctl_handle_opaque(oidp, &mask, sizeof(mask), req); if (error || !req->newptr) return (error); - if (logical_cpus_mask != 0 && - (mask & logical_cpus_mask) == logical_cpus_mask) + if (!CPU_EMPTY(&logical_cpus_mask) && + CPU_SUBSET(&mask, &logical_cpus_mask)) hlt_logical_cpus = 1; else hlt_logical_cpus = 0; if (! hyperthreading_allowed) - mask |= hyperthreading_cpus_mask; + CPU_OR(&mask, &hyperthreading_cpus_mask); - if ((mask & all_cpus) == all_cpus) - mask &= ~(1<<0); + if (CPU_SUBSET(&mask, &all_cpus)) + CPU_CLR(0, &mask); hlt_cpus_mask = mask; return (error); } -SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, CTLTYPE_INT|CTLFLAG_RW, - 0, 0, sysctl_hlt_cpus, "IU", +SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, + CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_hlt_cpus, "S", "Bitmap of CPUs to halt. 101 (binary) will halt CPUs 0 and 2."); static int @@ -1542,15 +1559,15 @@ sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) return (error); if (disable) - hlt_cpus_mask |= logical_cpus_mask; + CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); else - hlt_cpus_mask &= ~logical_cpus_mask; + CPU_NAND(&hlt_cpus_mask, &logical_cpus_mask); if (! hyperthreading_allowed) - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - if ((hlt_cpus_mask & all_cpus) == all_cpus) - hlt_cpus_mask &= ~(1<<0); + if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) + CPU_CLR(0, &hlt_cpus_mask); hlt_logical_cpus = disable; return (error); @@ -1577,18 +1594,18 @@ sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) #endif if (allowed) - hlt_cpus_mask &= ~hyperthreading_cpus_mask; + CPU_NAND(&hlt_cpus_mask, &hyperthreading_cpus_mask); else - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - if (logical_cpus_mask != 0 && - (hlt_cpus_mask & logical_cpus_mask) == logical_cpus_mask) + if (!CPU_EMPTY(&logical_cpus_mask) && + CPU_SUBSET(&hlt_cpus_mask, &logical_cpus_mask)) hlt_logical_cpus = 1; else hlt_logical_cpus = 0; - if ((hlt_cpus_mask & all_cpus) == all_cpus) - hlt_cpus_mask &= ~(1<<0); + if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) + CPU_CLR(0, &hlt_cpus_mask); hyperthreading_allowed = allowed; return (error); @@ -1598,7 +1615,7 @@ static void cpu_hlt_setup(void *dummy __unused) { - if (logical_cpus_mask != 0) { + if (!CPU_EMPTY(&logical_cpus_mask)) { TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", &hlt_logical_cpus); sysctl_ctx_init(&logical_cpu_clist); @@ -1612,20 +1629,21 @@ cpu_hlt_setup(void *dummy __unused) &logical_cpus_mask, 0, ""); if (hlt_logical_cpus) - hlt_cpus_mask |= logical_cpus_mask; + CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); /* * If necessary for security purposes, force * hyperthreading off, regardless of the value * of hlt_logical_cpus. */ - if (hyperthreading_cpus_mask) { + if (!CPU_EMPTY(&hyperthreading_cpus_mask)) { SYSCTL_ADD_PROC(&logical_cpu_clist, SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_hyperthreading_allowed, "IU", ""); if (! hyperthreading_allowed) - hlt_cpus_mask |= hyperthreading_cpus_mask; + CPU_OR(&hlt_cpus_mask, + &hyperthreading_cpus_mask); } } } @@ -1634,7 +1652,7 @@ SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_ANY, cpu_hlt_setup, NULL); int mp_grab_cpu_hlt(void) { - cpumask_t mask; + cpuset_t mask; #ifdef MP_WATCHDOG u_int cpuid; #endif @@ -1647,7 +1665,7 @@ mp_grab_cpu_hlt(void) #endif retval = 0; - while (mask & hlt_cpus_mask) { + while (CPU_OVERLAP(&mask, &hlt_cpus_mask)) { retval = 1; __asm __volatile("sti; hlt" : : : "memory"); } diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index e1fe137e4d31..c85f1387030e 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -125,6 +125,8 @@ __FBSDID("$FreeBSD$"); #include #ifdef SMP #include +#else +#include #endif #include @@ -386,7 +388,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) kernel_pmap->pm_pdpt = (pdpt_entry_t *) (KERNBASE + (u_int)IdlePDPT); #endif kernel_pmap->pm_root = NULL; - kernel_pmap->pm_active = -1; /* don't allow deactivation */ + CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvchunk); LIST_INIT(&allpmaps); @@ -930,19 +932,20 @@ pmap_update_pde_invalidate(vm_offset_t va, pd_entry_t newpde) void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invlpg(va); smp_invlpg(va); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invlpg(va); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg(pmap->pm_active & other_cpus, va); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg(other_cpus, va); } sched_unpin(); } @@ -950,23 +953,23 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; vm_offset_t addr; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); smp_invlpg_range(sva, eva); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg_range(pmap->pm_active & other_cpus, - sva, eva); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg_range(other_cpus, sva, eva); } sched_unpin(); } @@ -974,19 +977,20 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) void pmap_invalidate_all(pmap_t pmap) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invltlb(); smp_invltlb(); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invltlb(); - if (pmap->pm_active & other_cpus) - smp_masked_invltlb(pmap->pm_active & other_cpus); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invltlb(other_cpus); } sched_unpin(); } @@ -1002,8 +1006,8 @@ pmap_invalidate_cache(void) } struct pde_action { - cpumask_t store; /* processor that updates the PDE */ - cpumask_t invalidate; /* processors that invalidate their TLB */ + cpuset_t store; /* processor that updates the PDE */ + cpuset_t invalidate; /* processors that invalidate their TLB */ vm_offset_t va; pd_entry_t *pde; pd_entry_t newpde; @@ -1016,7 +1020,10 @@ pmap_update_pde_kernel(void *arg) pd_entry_t *pde; pmap_t pmap; - if (act->store == PCPU_GET(cpumask)) + sched_pin(); + if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { + sched_unpin(); + /* * Elsewhere, this operation requires allpmaps_lock for * synchronization. Here, it does not because it is being @@ -1026,6 +1033,8 @@ pmap_update_pde_kernel(void *arg) pde = pmap_pde(pmap, act->va); pde_store(pde, act->newpde); } + } else + sched_unpin(); } static void @@ -1033,8 +1042,12 @@ pmap_update_pde_user(void *arg) { struct pde_action *act = arg; - if (act->store == PCPU_GET(cpumask)) + sched_pin(); + if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) { + sched_unpin(); pde_store(act->pde, act->newpde); + } else + sched_unpin(); } static void @@ -1042,8 +1055,12 @@ pmap_update_pde_teardown(void *arg) { struct pde_action *act = arg; - if ((act->invalidate & PCPU_GET(cpumask)) != 0) + sched_pin(); + if (CPU_OVERLAP(&act->invalidate, PCPU_PTR(cpumask))) { + sched_unpin(); pmap_update_pde_invalidate(act->va, act->newpde); + } else + sched_unpin(); } /* @@ -1058,21 +1075,23 @@ static void pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) { struct pde_action act; - cpumask_t active, cpumask; + cpuset_t active, cpumask, other_cpus; sched_pin(); cpumask = PCPU_GET(cpumask); + other_cpus = PCPU_GET(other_cpus); if (pmap == kernel_pmap) active = all_cpus; else active = pmap->pm_active; - if ((active & PCPU_GET(other_cpus)) != 0) { + if (CPU_OVERLAP(&active, &other_cpus)) { act.store = cpumask; act.invalidate = active; act.va = va; act.pde = pde; act.newpde = newpde; - smp_rendezvous_cpus(cpumask | active, + CPU_OR(&cpumask, &active); + smp_rendezvous_cpus(cpumask, smp_no_rendevous_barrier, pmap == kernel_pmap ? pmap_update_pde_kernel : pmap_update_pde_user, pmap_update_pde_teardown, &act); @@ -1081,7 +1100,7 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) pmap_kenter_pde(va, newpde); else pde_store(pde, newpde); - if ((active & cpumask) != 0) + if (CPU_OVERLAP(&active, &cpumask)) pmap_update_pde_invalidate(va, newpde); } sched_unpin(); @@ -1095,7 +1114,7 @@ PMAP_INLINE void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invlpg(va); } @@ -1104,7 +1123,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { vm_offset_t addr; - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); } @@ -1113,7 +1132,7 @@ PMAP_INLINE void pmap_invalidate_all(pmap_t pmap) { - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invltlb(); } @@ -1132,7 +1151,7 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde) pmap_kenter_pde(va, newpde); else pde_store(pde, newpde); - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) pmap_update_pde_invalidate(va, newpde); } #endif /* !SMP */ @@ -1689,7 +1708,7 @@ pmap_pinit0(pmap_t pmap) pmap->pm_pdpt = (pdpt_entry_t *)(KERNBASE + (vm_offset_t)IdlePDPT); #endif pmap->pm_root = NULL; - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); PCPU_SET(curpmap, pmap); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -1770,7 +1789,7 @@ pmap_pinit(pmap_t pmap) #endif } - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -4985,11 +5004,11 @@ pmap_activate(struct thread *td) pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); #if defined(SMP) - atomic_clear_int(&oldpmap->pm_active, PCPU_GET(cpumask)); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); #else - oldpmap->pm_active &= ~1; - pmap->pm_active |= 1; + CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask)); #endif #ifdef PAE cr3 = vtophys(pmap->pm_pdpt); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 232e1a1f308e..a084e09526aa 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -573,11 +573,13 @@ kvtop(void *addr) static void cpu_reset_proxy() { + cpuset_t tcrp; cpu_reset_proxy_active = 1; while (cpu_reset_proxy_active == 1) ; /* Wait for other cpu to see that we've started */ - stop_cpus((1<cpumask = 0; + CPU_ZERO(&sf->cpumask); shootdown: sched_pin(); cpumask = PCPU_GET(cpumask); - if ((sf->cpumask & cpumask) == 0) { - sf->cpumask |= cpumask; + if (!CPU_OVERLAP(&cpumask, &sf->cpumask)) { + CPU_OR(&sf->cpumask, &cpumask); invlpg(sf->kva); } if ((flags & SFB_CPUPRIVATE) == 0) { - other_cpus = PCPU_GET(other_cpus) & ~sf->cpumask; - if (other_cpus != 0) { - sf->cpumask |= other_cpus; + other_cpus = PCPU_GET(other_cpus); + CPU_NAND(&other_cpus, &sf->cpumask); + if (!CPU_EMPTY(&other_cpus)) { + CPU_OR(&sf->cpumask, &other_cpus); smp_masked_invlpg(other_cpus, sf->kva); } } - sched_unpin(); + sched_unpin(); #else if ((opte & (PG_V | PG_A)) == (PG_V | PG_A)) pmap_invalidate_page(kernel_pmap, sf->kva); diff --git a/sys/i386/include/_types.h b/sys/i386/include/_types.h index 7a969fedf160..3194fd691f67 100644 --- a/sys/i386/include/_types.h +++ b/sys/i386/include/_types.h @@ -69,7 +69,6 @@ typedef unsigned long long __uint64_t; * Standard type definitions. */ typedef unsigned long __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef __int32_t __critical_t; typedef long double __double_t; typedef long double __float_t; diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h index eeada2e400f4..3012a000ae5c 100644 --- a/sys/i386/include/pmap.h +++ b/sys/i386/include/pmap.h @@ -155,6 +155,7 @@ #ifndef LOCORE #include +#include #include #include @@ -433,7 +434,7 @@ struct pmap { struct mtx pm_mtx; pd_entry_t *pm_pdir; /* KVA of page directory */ TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */ - cpumask_t pm_active; /* active on cpus */ + cpuset_t pm_active; /* active on cpus */ struct pmap_statistics pm_stats; /* pmap statistics */ LIST_ENTRY(pmap) pm_list; /* List of all pmaps */ #ifdef PAE diff --git a/sys/i386/include/sf_buf.h b/sys/i386/include/sf_buf.h index 7bc1095c9590..415dcbb86e63 100644 --- a/sys/i386/include/sf_buf.h +++ b/sys/i386/include/sf_buf.h @@ -29,6 +29,7 @@ #ifndef _MACHINE_SF_BUF_H_ #define _MACHINE_SF_BUF_H_ +#include #include struct vm_page; @@ -40,7 +41,7 @@ struct sf_buf { vm_offset_t kva; /* va of mapping */ int ref_count; /* usage of this mapping */ #ifdef SMP - cpumask_t cpumask; /* cpus on which mapping is valid */ + cpuset_t cpumask; /* cpus on which mapping is valid */ #endif }; diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index b512e00b4228..cdec9c87bace 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -64,17 +64,17 @@ void ipi_bitmap_handler(struct trapframe frame); #endif void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); -void ipi_selected(cpumask_t cpus, u_int ipi); +void ipi_selected(cpuset_t cpus, u_int ipi); u_int mp_bootaddress(u_int); int mp_grab_cpu_hlt(void); void smp_cache_flush(void); void smp_invlpg(vm_offset_t addr); -void smp_masked_invlpg(cpumask_t mask, vm_offset_t addr); +void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva); -void smp_masked_invlpg_range(cpumask_t mask, vm_offset_t startva, +void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva, vm_offset_t endva); void smp_invltlb(void); -void smp_masked_invltlb(cpumask_t mask); +void smp_masked_invltlb(cpuset_t mask); #ifdef XEN void ipi_to_irq_init(void); diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 670d110af49c..1146ac2351e6 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* cngetc() */ +#include #ifdef GPROF #include #endif @@ -116,7 +117,7 @@ volatile int smp_tlb_wait; typedef void call_data_func_t(uintptr_t , uintptr_t); static u_int logical_cpus; -static volatile cpumask_t ipi_nmi_pending; +static volatile cpuset_t ipi_nmi_pending; /* used to hold the AP's until we are ready to release them */ static struct mtx ap_boot_mtx; @@ -149,7 +150,7 @@ static int start_ap(int apic_id); static void release_aps(void *dummy); static u_int hyperthreading_cpus; -static cpumask_t hyperthreading_cpus_mask; +static cpuset_t hyperthreading_cpus_mask; extern void Xhypervisor_callback(void); extern void failsafe_callback(void); @@ -238,7 +239,7 @@ cpu_mp_probe(void) * Always record BSP in CPU map so that the mbuf init code works * correctly. */ - all_cpus = 1; + CPU_SETOF(0, &all_cpus); if (mp_ncpus == 0) { /* * No CPUs were found, so this must be a UP system. Setup @@ -292,7 +293,8 @@ cpu_mp_start(void) start_all_aps(); /* Setup the initial logical CPUs info. */ - logical_cpus = logical_cpus_mask = 0; + logical_cpus = 0; + CPU_ZERO(&logical_cpus_mask); if (cpu_feature & CPUID_HTT) logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16; @@ -512,6 +514,7 @@ xen_smp_intr_init_cpus(void *unused) void init_secondary(void) { + cpuset_t tcpuset, tallcpus; vm_offset_t addr; int gsel_tss; @@ -591,18 +594,21 @@ init_secondary(void) CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid)); printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid)); + tcpuset = PCPU_GET(cpumask); /* Determine if we are a logical CPU. */ if (logical_cpus > 1 && PCPU_GET(apic_id) % logical_cpus != 0) - logical_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&logical_cpus_mask, &tcpuset); /* Determine if we are a hyperthread. */ if (hyperthreading_cpus > 1 && PCPU_GET(apic_id) % hyperthreading_cpus != 0) - hyperthreading_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&hyperthreading_cpus_mask, &tcpuset); /* Build our map of 'other' CPUs. */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + CPU_NAND(&tallcpus, &tcpuset); + PCPU_SET(other_cpus, tallcpus); #if 0 if (bootverbose) lapic_dump("AP"); @@ -713,6 +719,7 @@ assign_cpu_ids(void) int start_all_aps(void) { + cpuset_t tallcpus; int x,apic_id, cpu; struct pcpu *pc; @@ -766,12 +773,14 @@ start_all_aps(void) panic("bye-bye"); } - all_cpus |= (1 << cpu); /* record AP in CPU map */ + CPU_SET(cpu, &all_cpus); /* record AP in CPU map */ } /* build our map of 'other' CPUs */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + tallcpus = all_cpus; + CPU_NAND(&tallcpus, PCPU_PTR(cpumask)); + PCPU_SET(other_cpus, tallcpus); pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1); @@ -1000,29 +1009,20 @@ smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2) } static void -smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) +smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_offset_t addr2) { - int ncpu, othercpus; + int cpu, ncpu, othercpus; struct _call_data data; othercpus = mp_ncpus - 1; - if (mask == (u_int)-1) { - ncpu = othercpus; - if (ncpu < 1) + if (CPU_ISFULLSET(&mask)) { + if (othercpus < 1) return; } else { - mask &= ~PCPU_GET(cpumask); - if (mask == 0) - return; - ncpu = bitcount32(mask); - if (ncpu > othercpus) { - /* XXX this should be a panic offence */ - printf("SMP: tlb shootdown to %d other cpus (only have %d)\n", - ncpu, othercpus); - ncpu = othercpus; - } - /* XXX should be a panic, implied by mask == 0 above */ - if (ncpu < 1) + critical_enter(); + CPU_NAND(&mask, PCPU_PTR(cpumask)); + critical_exit(); + if (CPU_EMPTY(&mask)) return; } if (!(read_eflags() & PSL_I)) @@ -1034,10 +1034,20 @@ smp_targeted_tlb_shootdown(cpumask_t mask, u_int vector, vm_offset_t addr1, vm_o call_data->arg1 = addr1; call_data->arg2 = addr2; atomic_store_rel_int(&smp_tlb_wait, 0); - if (mask == (u_int)-1) + if (CPU_ISFULLSET(&mask)) { + ncpu = othercpus; ipi_all_but_self(vector); - else - ipi_selected(mask, vector); + } else { + ncpu = 0; + while ((cpu = cpusetobj_ffs(&mask)) != 0) { + cpu--; + CPU_CLR(cpu, &mask); + CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, + vector); + ipi_send_cpu(cpu, vector); + ncpu++; + } + } while (smp_tlb_wait < ncpu) ia32_pause(); call_data = NULL; @@ -1080,7 +1090,7 @@ smp_invlpg_range(vm_offset_t addr1, vm_offset_t addr2) } void -smp_masked_invltlb(cpumask_t mask) +smp_masked_invltlb(cpuset_t mask) { if (smp_started) { @@ -1089,7 +1099,7 @@ smp_masked_invltlb(cpumask_t mask) } void -smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) +smp_masked_invlpg(cpuset_t mask, vm_offset_t addr) { if (smp_started) { @@ -1098,7 +1108,7 @@ smp_masked_invlpg(cpumask_t mask, vm_offset_t addr) } void -smp_masked_invlpg_range(cpumask_t mask, vm_offset_t addr1, vm_offset_t addr2) +smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2) { if (smp_started) { @@ -1110,7 +1120,7 @@ smp_masked_invlpg_range(cpumask_t mask, vm_offset_t addr1, vm_offset_t addr2) * send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, u_int ipi) +ipi_selected(cpuset_t cpus, u_int ipi) { int cpu; @@ -1120,11 +1130,11 @@ ipi_selected(cpumask_t cpus, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, cpus); + CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus); - while ((cpu = ffs(cpus)) != 0) { + while ((cpu = cpusetobj_ffs(&cpus)) != 0) { cpu--; - cpus &= ~(1 << cpu); + CPU_CLR(cpu, &cpus); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); } @@ -1143,7 +1153,7 @@ ipi_cpu(int cpu, u_int ipi) * Set the mask of receiving CPUs for this purpose. */ if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, 1 << cpu); + CPU_SET_ATOMIC(cpu, &ipi_nmi_pending); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); ipi_send_cpu(cpu, ipi); @@ -1155,23 +1165,27 @@ ipi_cpu(int cpu, u_int ipi) void ipi_all_but_self(u_int ipi) { + cpuset_t other_cpus; /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit * of help in order to understand what is the source. * Set the mask of receiving CPUs for this purpose. */ + sched_pin(); + other_cpus = PCPU_GET(other_cpus); + sched_unpin(); if (ipi == IPI_STOP_HARD) - atomic_set_int(&ipi_nmi_pending, PCPU_GET(other_cpus)); + CPU_OR_ATOMIC(&ipi_nmi_pending, &other_cpus); CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi); - ipi_selected(PCPU_GET(other_cpus), ipi); + ipi_selected(other_cpus, ipi); } int ipi_nmi_handler() { - cpumask_t cpumask; + cpuset_t cpumask; /* * As long as there is not a simple way to know about a NMI's @@ -1179,11 +1193,13 @@ ipi_nmi_handler() * the global pending bitword an IPI_STOP_HARD has been issued * and should be handled. */ + sched_pin(); cpumask = PCPU_GET(cpumask); - if ((ipi_nmi_pending & cpumask) == 0) + sched_unpin(); + if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask)) return (1); - atomic_clear_int(&ipi_nmi_pending, cpumask); + CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask); cpustop_handler(); return (0); } @@ -1195,20 +1211,25 @@ ipi_nmi_handler() void cpustop_handler(void) { - int cpu = PCPU_GET(cpuid); - int cpumask = PCPU_GET(cpumask); + cpuset_t cpumask; + int cpu; + + sched_pin(); + cpumask = PCPU_GET(cpumask); + cpu = PCPU_GET(cpuid); + sched_unpin(); savectx(&stoppcbs[cpu]); /* Indicate that we are stopped */ - atomic_set_int(&stopped_cpus, cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &cpumask); /* Wait for restart */ - while (!(started_cpus & cpumask)) + while (!CPU_OVERLAP(&started_cpus, &cpumask)) ia32_pause(); - atomic_clear_int(&started_cpus, cpumask); - atomic_clear_int(&stopped_cpus, cpumask); + CPU_NAND_ATOMIC(&started_cpus, &cpumask); + CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); if (cpu == 0 && cpustop_restartfunc != NULL) { cpustop_restartfunc(); diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index cf36f5edddb3..74ace613d133 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -422,7 +422,7 @@ pmap_bootstrap(vm_paddr_t firstaddr) #ifdef PAE kernel_pmap->pm_pdpt = (pdpt_entry_t *) (KERNBASE + (u_int)IdlePDPT); #endif - kernel_pmap->pm_active = -1; /* don't allow deactivation */ + CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvchunk); LIST_INIT(&allpmaps); mtx_init(&allpmaps_lock, "allpmaps", NULL, MTX_SPIN); @@ -802,22 +802,23 @@ pmap_cache_bits(int mode, boolean_t is_pde) void pmap_invalidate_page(pmap_t pmap, vm_offset_t va) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; CTR2(KTR_PMAP, "pmap_invalidate_page: pmap=%p va=0x%x", pmap, va); sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invlpg(va); smp_invlpg(va); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invlpg(va); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg(pmap->pm_active & other_cpus, va); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg(other_cpus, va); } sched_unpin(); PT_UPDATES_FLUSH(); @@ -826,26 +827,26 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; vm_offset_t addr; CTR3(KTR_PMAP, "pmap_invalidate_page: pmap=%p eva=0x%x sva=0x%x", pmap, sva, eva); sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); smp_invlpg_range(sva, eva); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); - if (pmap->pm_active & other_cpus) - smp_masked_invlpg_range(pmap->pm_active & other_cpus, - sva, eva); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invlpg_range(other_cpus, sva, eva); } sched_unpin(); PT_UPDATES_FLUSH(); @@ -854,21 +855,22 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) void pmap_invalidate_all(pmap_t pmap) { - cpumask_t cpumask, other_cpus; + cpuset_t cpumask, other_cpus; CTR1(KTR_PMAP, "pmap_invalidate_page: pmap=%p", pmap); sched_pin(); - if (pmap == kernel_pmap || pmap->pm_active == all_cpus) { + if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) { invltlb(); smp_invltlb(); } else { cpumask = PCPU_GET(cpumask); other_cpus = PCPU_GET(other_cpus); - if (pmap->pm_active & cpumask) + if (CPU_OVERLAP(&pmap->pm_active, &cpumask)) invltlb(); - if (pmap->pm_active & other_cpus) - smp_masked_invltlb(pmap->pm_active & other_cpus); + CPU_AND(&other_cpus, &pmap->pm_active); + if (!CPU_EMPTY(&other_cpus)) + smp_masked_invltlb(other_cpus); } sched_unpin(); } @@ -893,7 +895,7 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va) CTR2(KTR_PMAP, "pmap_invalidate_page: pmap=%p va=0x%x", pmap, va); - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invlpg(va); PT_UPDATES_FLUSH(); } @@ -907,7 +909,7 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva) CTR3(KTR_PMAP, "pmap_invalidate_range: pmap=%p sva=0x%x eva=0x%x", pmap, sva, eva); - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) for (addr = sva; addr < eva; addr += PAGE_SIZE) invlpg(addr); PT_UPDATES_FLUSH(); @@ -919,7 +921,7 @@ pmap_invalidate_all(pmap_t pmap) CTR1(KTR_PMAP, "pmap_invalidate_all: pmap=%p", pmap); - if (pmap == kernel_pmap || pmap->pm_active) + if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active)) invltlb(); } @@ -1449,7 +1451,7 @@ pmap_pinit0(pmap_t pmap) #ifdef PAE pmap->pm_pdpt = (pdpt_entry_t *)(KERNBASE + (vm_offset_t)IdlePDPT); #endif - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); PCPU_SET(curpmap, pmap); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -1556,7 +1558,7 @@ pmap_pinit(pmap_t pmap) } xen_flush_queue(); vm_page_unlock_queues(); - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvchunk); bzero(&pmap->pm_stats, sizeof pmap->pm_stats); @@ -4030,11 +4032,11 @@ pmap_activate(struct thread *td) pmap = vmspace_pmap(td->td_proc->p_vmspace); oldpmap = PCPU_GET(curpmap); #if defined(SMP) - atomic_clear_int(&oldpmap->pm_active, PCPU_GET(cpumask)); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); #else - oldpmap->pm_active &= ~1; - pmap->pm_active |= 1; + CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask)); #endif #ifdef PAE cr3 = vtophys(pmap->pm_pdpt); diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index 5804f8cd69b7..015378514687 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -139,18 +139,18 @@ ia64_ih_rndzvs(struct thread *td, u_int xiv, struct trapframe *tf) static u_int ia64_ih_stop(struct thread *td, u_int xiv, struct trapframe *tf) { - cpumask_t mybit; + cpuset_t mybit; PCPU_INC(md.stats.pcs_nstops); mybit = PCPU_GET(cpumask); savectx(PCPU_PTR(md.pcb)); - atomic_set_int(&stopped_cpus, mybit); - while ((started_cpus & mybit) == 0) + CPU_OR_ATOMIC(&stopped_cpus, &mybit); + while (!CPU_OVERLAP(&started_cpus, &mybit)) cpu_spinwait(); - atomic_clear_int(&started_cpus, mybit); - atomic_clear_int(&stopped_cpus, mybit); + CPU_NAND_ATOMIC(&started_cpus, &mybit); + CPU_NAND_ATOMIC(&stopped_cpus, &mybit); return (0); } @@ -458,12 +458,12 @@ cpu_mp_unleash(void *dummy) * send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, int ipi) +ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { - if (cpus & pc->pc_cpumask) + if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) ipi_send(pc, ipi); } } diff --git a/sys/ia64/include/_types.h b/sys/ia64/include/_types.h index 8fc1be2f3873..0c2f5cc38d0b 100644 --- a/sys/ia64/include/_types.h +++ b/sys/ia64/include/_types.h @@ -59,7 +59,6 @@ typedef unsigned long __uint64_t; * Standard type definitions. */ typedef __int32_t __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef __int64_t __critical_t; typedef double __double_t; typedef float __float_t; diff --git a/sys/ia64/include/smp.h b/sys/ia64/include/smp.h index 26557a712705..d2aff76c3ad5 100644 --- a/sys/ia64/include/smp.h +++ b/sys/ia64/include/smp.h @@ -14,6 +14,8 @@ #ifndef LOCORE +#include + struct pcpu; struct ia64_ap_state { @@ -44,7 +46,7 @@ extern int ia64_ipi_wakeup; void ipi_all_but_self(int ipi); void ipi_cpu(int cpu, u_int ipi); -void ipi_selected(cpumask_t cpus, int ipi); +void ipi_selected(cpuset_t cpus, int ipi); void ipi_send(struct pcpu *, int ipi); #endif /* !LOCORE */ diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index bf9eac79ac8e..9ed19d4d60d9 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -616,6 +616,49 @@ cpuset_setproc(pid_t pid, struct cpuset *set, cpuset_t *mask) return (error); } +/* + * Calculate the ffs() of the cpuset. + */ +int +cpusetobj_ffs(const cpuset_t *set) +{ + size_t i; + int cbit; + + cbit = 0; + for (i = 0; i < _NCPUWORDS; i++) { + if (set->__bits[i] != 0) { + cbit = ffsl(set->__bits[i]); + cbit += i * _NCPUBITS; + break; + } + } + return (cbit); +} + +/* + * Return a string representing a valid layout for a cpuset_t object. + * It expects an incoming buffer at least sized as CPUSETBUFSIZ. + */ +char * +cpusetobj_strprint(char *buf, const cpuset_t *set) +{ + char *tbuf; + size_t i, bytesp, bufsiz; + + tbuf = buf; + bytesp = 0; + bufsiz = CPUSETBUFSIZ; + + for (i = 0; i < (_NCPUWORDS - 1); i++) { + bytesp = snprintf(tbuf, bufsiz, "%lx, ", set->__bits[i]); + bufsiz -= bytesp; + tbuf += bytesp; + } + snprintf(tbuf, bufsiz, "%lx", set->__bits[_NCPUWORDS - 1]); + return (buf); +} + /* * Apply an anonymous mask to a single thread. */ @@ -754,11 +797,10 @@ cpuset_init(void *arg) { cpuset_t mask; - CPU_ZERO(&mask); #ifdef SMP - mask.__bits[0] = all_cpus; + mask = all_cpus; #else - mask.__bits[0] = 1; + CPU_SETOF(0, &mask); #endif if (cpuset_modify(cpuset_zero, &mask)) panic("Can't set initial cpuset mask.\n"); diff --git a/sys/kern/kern_pmc.c b/sys/kern/kern_pmc.c index 7532378c7a2d..8d9c7c04a711 100644 --- a/sys/kern/kern_pmc.c +++ b/sys/kern/kern_pmc.c @@ -55,7 +55,7 @@ int (*pmc_hook)(struct thread *td, int function, void *arg) = NULL; int (*pmc_intr)(int cpu, struct trapframe *tf) = NULL; /* Bitmask of CPUs requiring servicing at hardclock time */ -volatile cpumask_t pmc_cpumask; +volatile cpuset_t pmc_cpumask; /* * A global count of SS mode PMCs. When non-zero, this means that @@ -112,7 +112,7 @@ pmc_cpu_is_active(int cpu) { #ifdef SMP return (pmc_cpu_is_present(cpu) && - (hlt_cpus_mask & (1 << cpu)) == 0); + !CPU_ISSET(cpu, &hlt_cpus_mask)); #else return (1); #endif @@ -139,7 +139,7 @@ int pmc_cpu_is_primary(int cpu) { #ifdef SMP - return ((logical_cpus_mask & (1 << cpu)) == 0); + return (!CPU_ISSET(cpu, &logical_cpus_mask)); #else return (1); #endif diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 7f2b4e7367be..3214e1b55e2f 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -263,7 +263,7 @@ _rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) pc = pcpu_find(curcpu); /* Check if we just need to do a proper critical_exit. */ - if (!(pc->pc_cpumask & rm->rm_writecpus)) { + if (!CPU_OVERLAP(&pc->pc_cpumask, &rm->rm_writecpus)) { critical_exit(); return (1); } @@ -325,7 +325,7 @@ _rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) critical_enter(); pc = pcpu_find(curcpu); - rm->rm_writecpus &= ~pc->pc_cpumask; + CPU_NAND(&rm->rm_writecpus, &pc->pc_cpumask); rm_tracker_add(pc, tracker); sched_pin(); critical_exit(); @@ -366,7 +366,8 @@ _rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker, int trylock) * Fast path to combine two common conditions into a single * conditional jump. */ - if (0 == (td->td_owepreempt | (rm->rm_writecpus & pc->pc_cpumask))) + if (0 == (td->td_owepreempt | + CPU_OVERLAP(&rm->rm_writecpus, &pc->pc_cpumask))) return (1); /* We do not have a read token and need to acquire one. */ @@ -429,17 +430,17 @@ _rm_wlock(struct rmlock *rm) { struct rm_priotracker *prio; struct turnstile *ts; - cpumask_t readcpus; + cpuset_t readcpus; if (rm->lock_object.lo_flags & RM_SLEEPABLE) sx_xlock(&rm->rm_lock_sx); else mtx_lock(&rm->rm_lock_mtx); - if (rm->rm_writecpus != all_cpus) { + if (CPU_CMP(&rm->rm_writecpus, &all_cpus)) { /* Get all read tokens back */ - - readcpus = all_cpus & (all_cpus & ~rm->rm_writecpus); + readcpus = all_cpus; + CPU_NAND(&readcpus, &rm->rm_writecpus); rm->rm_writecpus = all_cpus; /* diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index fef9e256f6bb..2fad27ce505c 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -156,7 +156,7 @@ static struct runq runq; static struct runq runq_pcpu[MAXCPU]; long runq_length[MAXCPU]; -static cpumask_t idle_cpus_mask; +static cpuset_t idle_cpus_mask; #endif struct pcpuidlestat { @@ -951,7 +951,8 @@ sched_switch(struct thread *td, struct thread *newtd, int flags) if (td->td_flags & TDF_IDLETD) { TD_SET_CAN_RUN(td); #ifdef SMP - idle_cpus_mask &= ~PCPU_GET(cpumask); + /* Spinlock held here, assume no migration. */ + CPU_NAND(&idle_cpus_mask, PCPU_PTR(cpumask)); #endif } else { if (TD_IS_RUNNING(td)) { @@ -1025,7 +1026,7 @@ sched_switch(struct thread *td, struct thread *newtd, int flags) #ifdef SMP if (td->td_flags & TDF_IDLETD) - idle_cpus_mask |= PCPU_GET(cpumask); + CPU_OR(&idle_cpus_mask, PCPU_PTR(cpumask)); #endif sched_lock.mtx_lock = (uintptr_t)td; td->td_oncpu = PCPU_GET(cpuid); @@ -1054,7 +1055,8 @@ static int forward_wakeup(int cpunum) { struct pcpu *pc; - cpumask_t dontuse, id, map, map2, me; + cpuset_t dontuse, id, map, map2, me; + int iscpuset; mtx_assert(&sched_lock, MA_OWNED); @@ -1071,32 +1073,38 @@ forward_wakeup(int cpunum) /* * Check the idle mask we received against what we calculated * before in the old version. + * + * Also note that sched_lock is held now, thus no migration is + * expected. */ me = PCPU_GET(cpumask); /* Don't bother if we should be doing it ourself. */ - if ((me & idle_cpus_mask) && (cpunum == NOCPU || me == (1 << cpunum))) + if (CPU_OVERLAP(&me, &idle_cpus_mask) && + (cpunum == NOCPU || CPU_ISSET(cpunum, &me))) return (0); - dontuse = me | stopped_cpus | hlt_cpus_mask; - map2 = 0; + dontuse = me; + CPU_OR(&dontuse, &stopped_cpus); + CPU_OR(&dontuse, &hlt_cpus_mask); + CPU_ZERO(&map2); if (forward_wakeup_use_loop) { SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; - if ((id & dontuse) == 0 && + if (!CPU_OVERLAP(&id, &dontuse) && pc->pc_curthread == pc->pc_idlethread) { - map2 |= id; + CPU_OR(&map2, &id); } } } if (forward_wakeup_use_mask) { - map = 0; - map = idle_cpus_mask & ~dontuse; + map = idle_cpus_mask; + CPU_NAND(&map, &dontuse); /* If they are both on, compare and use loop if different. */ if (forward_wakeup_use_loop) { - if (map != map2) { + if (CPU_CMP(&map, &map2)) { printf("map != map2, loop method preferred\n"); map = map2; } @@ -1108,18 +1116,22 @@ forward_wakeup(int cpunum) /* If we only allow a specific CPU, then mask off all the others. */ if (cpunum != NOCPU) { KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum.")); - map &= (1 << cpunum); + iscpuset = CPU_ISSET(cpunum, &map); + if (iscpuset == 0) + CPU_ZERO(&map); + else + CPU_SETOF(cpunum, &map); } - if (map) { + if (!CPU_EMPTY(&map)) { forward_wakeups_delivered++; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; - if ((map & id) == 0) + if (!CPU_OVERLAP(&map, &id)) continue; if (cpu_idle_wakeup(pc->pc_cpuid)) - map &= ~id; + CPU_NAND(&map, &id); } - if (map) + if (!CPU_EMPTY(&map)) ipi_selected(map, IPI_AST); return (1); } @@ -1135,7 +1147,7 @@ kick_other_cpu(int pri, int cpuid) int cpri; pcpu = pcpu_find(cpuid); - if (idle_cpus_mask & pcpu->pc_cpumask) { + if (CPU_OVERLAP(&idle_cpus_mask, &pcpu->pc_cpumask)) { forward_wakeups_delivered++; if (!cpu_idle_wakeup(cpuid)) ipi_cpu(cpuid, IPI_AST); @@ -1193,6 +1205,7 @@ void sched_add(struct thread *td, int flags) #ifdef SMP { + cpuset_t idle, me, tidlemsk; struct td_sched *ts; int forwarded = 0; int cpu; @@ -1262,11 +1275,20 @@ sched_add(struct thread *td, int flags) kick_other_cpu(td->td_priority, cpu); } else { if (!single_cpu) { - cpumask_t me = PCPU_GET(cpumask); - cpumask_t idle = idle_cpus_mask & me; - if (!idle && ((flags & SRQ_INTR) == 0) && - (idle_cpus_mask & ~(hlt_cpus_mask | me))) + /* + * Thread spinlock is held here, assume no + * migration is possible. + */ + me = PCPU_GET(cpumask); + idle = idle_cpus_mask; + tidlemsk = idle; + CPU_AND(&idle, &me); + CPU_OR(&me, &hlt_cpus_mask); + CPU_NAND(&tidlemsk, &me); + + if (CPU_EMPTY(&idle) && ((flags & SRQ_INTR) == 0) && + !CPU_EMPTY(&tidlemsk)) forwarded = forward_wakeup(cpu); } diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index ac18e778ae28..05267f3d6adb 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -564,7 +564,7 @@ struct cpu_search { #define CPUSET_FOREACH(cpu, mask) \ for ((cpu) = 0; (cpu) <= mp_maxid; (cpu)++) \ - if ((mask) & 1 << (cpu)) + if (CPU_ISSET(cpu, &mask)) static __inline int cpu_search(struct cpu_group *cg, struct cpu_search *low, struct cpu_search *high, const int match); @@ -2650,15 +2650,16 @@ static int sysctl_kern_sched_topology_spec_internal(struct sbuf *sb, struct cpu_group *cg, int indent) { + char cpusetbuf[CPUSETBUFSIZ]; int i, first; sbuf_printf(sb, "%*s\n", indent, "", 1 + indent / 2, cg->cg_level); - sbuf_printf(sb, "%*s ", indent, "", - cg->cg_count, cg->cg_mask); + sbuf_printf(sb, "%*s ", indent, "", + cg->cg_count, cpusetobj_strprint(cpusetbuf, &cg->cg_mask)); first = TRUE; for (i = 0; i < MAXCPU; i++) { - if ((cg->cg_mask & (1 << i)) != 0) { + if (CPU_ISSET(i, &cg->cg_mask)) { if (!first) sbuf_printf(sb, ", "); else diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 342c5ca1879d..bb78c00a7591 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -413,7 +413,8 @@ kdb_thr_ctx(struct thread *thr) #if defined(SMP) && defined(KDB_STOPPEDPCB) SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { - if (pc->pc_curthread == thr && (stopped_cpus & pc->pc_cpumask)) + if (pc->pc_curthread == thr && + CPU_OVERLAP(&stopped_cpus, &pc->pc_cpumask)) return (KDB_STOPPEDPCB(pc)); } #endif diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c index de5cafccf7f3..9201bb7e8cfc 100644 --- a/sys/kern/subr_pcpu.c +++ b/sys/kern/subr_pcpu.c @@ -87,7 +87,7 @@ pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) KASSERT(cpuid >= 0 && cpuid < MAXCPU, ("pcpu_init: invalid cpuid %d", cpuid)); pcpu->pc_cpuid = cpuid; - pcpu->pc_cpumask = 1 << cpuid; + CPU_SETOF(cpuid, &pcpu->pc_cpumask); cpuid_to_pcpu[cpuid] = pcpu; SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu); cpu_pcpu_init(pcpu, cpuid, size); diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index aba6f0e1ea7e..ae061f36c3b5 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -53,15 +53,15 @@ __FBSDID("$FreeBSD$"); #include "opt_sched.h" #ifdef SMP -volatile cpumask_t stopped_cpus; -volatile cpumask_t started_cpus; -cpumask_t hlt_cpus_mask; -cpumask_t logical_cpus_mask; +volatile cpuset_t stopped_cpus; +volatile cpuset_t started_cpus; +cpuset_t hlt_cpus_mask; +cpuset_t logical_cpus_mask; void (*cpustop_restartfunc)(void); #endif /* This is used in modules that need to work in both SMP and UP. */ -cpumask_t all_cpus; +cpuset_t all_cpus; int mp_ncpus; /* export this for libkvm consumers. */ @@ -199,8 +199,11 @@ forward_signal(struct thread *td) * */ static int -generic_stop_cpus(cpumask_t map, u_int type) +generic_stop_cpus(cpuset_t map, u_int type) { +#ifdef KTR + char cpusetbuf[CPUSETBUFSIZ]; +#endif static volatile u_int stopping_cpu = NOCPU; int i; @@ -215,7 +218,8 @@ generic_stop_cpus(cpumask_t map, u_int type) if (!smp_started) return (0); - CTR2(KTR_SMP, "stop_cpus(%x) with %u type", map, type); + CTR2(KTR_SMP, "stop_cpus(%s) with %u type", + cpusetobj_strprint(cpusetbuf, &map), type); if (stopping_cpu != PCPU_GET(cpuid)) while (atomic_cmpset_int(&stopping_cpu, NOCPU, @@ -227,7 +231,7 @@ generic_stop_cpus(cpumask_t map, u_int type) ipi_selected(map, type); i = 0; - while ((stopped_cpus & map) != map) { + while (!CPU_SUBSET(&stopped_cpus, &map)) { /* spin */ cpu_spinwait(); i++; @@ -244,14 +248,14 @@ generic_stop_cpus(cpumask_t map, u_int type) } int -stop_cpus(cpumask_t map) +stop_cpus(cpuset_t map) { return (generic_stop_cpus(map, IPI_STOP)); } int -stop_cpus_hard(cpumask_t map) +stop_cpus_hard(cpuset_t map) { return (generic_stop_cpus(map, IPI_STOP_HARD)); @@ -259,7 +263,7 @@ stop_cpus_hard(cpumask_t map) #if defined(__amd64__) int -suspend_cpus(cpumask_t map) +suspend_cpus(cpuset_t map) { return (generic_stop_cpus(map, IPI_SUSPEND)); @@ -280,19 +284,22 @@ suspend_cpus(cpumask_t map) * 1: ok */ int -restart_cpus(cpumask_t map) +restart_cpus(cpuset_t map) { +#ifdef KTR + char cpusetbuf[CPUSETBUFSIZ]; +#endif if (!smp_started) return 0; - CTR1(KTR_SMP, "restart_cpus(%x)", map); + CTR1(KTR_SMP, "restart_cpus(%s)", cpusetobj_strprint(cpusetbuf, &map)); /* signal other cpus to restart */ - atomic_store_rel_int(&started_cpus, map); + CPU_COPY_STORE_REL(&map, &started_cpus); /* wait for each to clear its bit */ - while ((stopped_cpus & map) != 0) + while (CPU_OVERLAP(&stopped_cpus, &map)) cpu_spinwait(); return 1; @@ -348,13 +355,13 @@ smp_rendezvous_action(void) } void -smp_rendezvous_cpus(cpumask_t map, +smp_rendezvous_cpus(cpuset_t map, void (* setup_func)(void *), void (* action_func)(void *), void (* teardown_func)(void *), void *arg) { - int i, ncpus = 0; + int curcpumap, i, ncpus = 0; if (!smp_started) { if (setup_func != NULL) @@ -367,11 +374,11 @@ smp_rendezvous_cpus(cpumask_t map, } CPU_FOREACH(i) { - if (((1 << i) & map) != 0) + if (CPU_ISSET(i, &map)) ncpus++; } if (ncpus == 0) - panic("ncpus is 0 with map=0x%x", map); + panic("ncpus is 0 with non-zero map"); /* obtain rendezvous lock */ mtx_lock_spin(&smp_ipi_mtx); @@ -387,10 +394,12 @@ smp_rendezvous_cpus(cpumask_t map, atomic_store_rel_int(&smp_rv_waiters[0], 0); /* signal other processors, which will enter the IPI with interrupts off */ - ipi_selected(map & ~(1 << curcpu), IPI_RENDEZVOUS); + curcpumap = CPU_ISSET(curcpu, &map); + CPU_CLR(curcpu, &map); + ipi_selected(map, IPI_RENDEZVOUS); /* Check if the current CPU is in the map */ - if ((map & (1 << curcpu)) != 0) + if (curcpumap != 0) smp_rendezvous_action(); if (teardown_func == smp_no_rendevous_barrier) @@ -415,6 +424,7 @@ static struct cpu_group group[MAXCPU]; struct cpu_group * smp_topo(void) { + char cpusetbuf[CPUSETBUFSIZ], cpusetbuf2[CPUSETBUFSIZ]; struct cpu_group *top; /* @@ -461,9 +471,10 @@ smp_topo(void) if (top->cg_count != mp_ncpus) panic("Built bad topology at %p. CPU count %d != %d", top, top->cg_count, mp_ncpus); - if (top->cg_mask != all_cpus) - panic("Built bad topology at %p. CPU mask 0x%X != 0x%X", - top, top->cg_mask, all_cpus); + if (CPU_CMP(&top->cg_mask, &all_cpus)) + panic("Built bad topology at %p. CPU mask (%s) != (%s)", + top, cpusetobj_strprint(cpusetbuf, &top->cg_mask), + cpusetobj_strprint(cpusetbuf2, &all_cpus)); return (top); } @@ -488,11 +499,13 @@ static int smp_topo_addleaf(struct cpu_group *parent, struct cpu_group *child, int share, int count, int flags, int start) { - cpumask_t mask; + char cpusetbuf[CPUSETBUFSIZ], cpusetbuf2[CPUSETBUFSIZ]; + cpuset_t mask; int i; - for (mask = 0, i = 0; i < count; i++, start++) - mask |= (1 << start); + CPU_ZERO(&mask); + for (i = 0; i < count; i++, start++) + CPU_SET(start, &mask); child->cg_parent = parent; child->cg_child = NULL; child->cg_children = 0; @@ -502,10 +515,12 @@ smp_topo_addleaf(struct cpu_group *parent, struct cpu_group *child, int share, child->cg_mask = mask; parent->cg_children++; for (; parent != NULL; parent = parent->cg_parent) { - if ((parent->cg_mask & child->cg_mask) != 0) - panic("Duplicate children in %p. mask 0x%X child 0x%X", - parent, parent->cg_mask, child->cg_mask); - parent->cg_mask |= child->cg_mask; + if (CPU_OVERLAP(&parent->cg_mask, &child->cg_mask)) + panic("Duplicate children in %p. mask (%s) child (%s)", + parent, + cpusetobj_strprint(cpusetbuf, &parent->cg_mask), + cpusetobj_strprint(cpusetbuf2, &child->cg_mask)); + CPU_OR(&parent->cg_mask, &child->cg_mask); parent->cg_count += child->cg_count; } @@ -565,20 +580,20 @@ struct cpu_group * smp_topo_find(struct cpu_group *top, int cpu) { struct cpu_group *cg; - cpumask_t mask; + cpuset_t mask; int children; int i; - mask = (1 << cpu); + CPU_SETOF(cpu, &mask); cg = top; for (;;) { - if ((cg->cg_mask & mask) == 0) + if (!CPU_OVERLAP(&cg->cg_mask, &mask)) return (NULL); if (cg->cg_children == 0) return (cg); children = cg->cg_children; for (i = 0, cg = cg->cg_child; i < children; cg++, i++) - if ((cg->cg_mask & mask) != 0) + if (CPU_OVERLAP(&cg->cg_mask, &mask)) break; } return (NULL); @@ -586,7 +601,7 @@ smp_topo_find(struct cpu_group *top, int cpu) #else /* !SMP */ void -smp_rendezvous_cpus(cpumask_t map, +smp_rendezvous_cpus(cpuset_t map, void (*setup_func)(void *), void (*action_func)(void *), void (*teardown_func)(void *), diff --git a/sys/ofed/include/linux/list.h b/sys/ofed/include/linux/list.h index f6f9404307c8..61b42d242a43 100644 --- a/sys/ofed/include/linux/list.h +++ b/sys/ofed/include/linux/list.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/sys/_cpuset.h b/sys/sys/_cpuset.h new file mode 100644 index 000000000000..62a0e9d425d0 --- /dev/null +++ b/sys/sys/_cpuset.h @@ -0,0 +1,52 @@ +/*- + * Copyright (c) 2008, Jeffrey Roberson + * All rights reserved. + * + * Copyright (c) 2008 Nokia Corporation + * 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 unmodified, 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 ``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 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS__CPUSET_H_ +#define _SYS__CPUSET_H_ + +#ifdef _KERNEL +#define CPU_SETSIZE MAXCPU +#endif + +#define CPU_MAXSIZE (4 * MAXCPU) + +#ifndef CPU_SETSIZE +#define CPU_SETSIZE CPU_MAXSIZE +#endif + +#define _NCPUBITS (sizeof(long) * NBBY) /* bits per mask */ +#define _NCPUWORDS howmany(CPU_SETSIZE, _NCPUBITS) + +typedef struct _cpuset { + long __bits[howmany(CPU_SETSIZE, _NCPUBITS)]; +} cpuset_t; + +#endif /* !_SYS__CPUSET_H_ */ diff --git a/sys/sys/_rmlock.h b/sys/sys/_rmlock.h index 75a159c1082e..15d6c4953e85 100644 --- a/sys/sys/_rmlock.h +++ b/sys/sys/_rmlock.h @@ -45,7 +45,7 @@ LIST_HEAD(rmpriolist,rm_priotracker); struct rmlock { struct lock_object lock_object; - volatile cpumask_t rm_writecpus; + volatile cpuset_t rm_writecpus; LIST_HEAD(,rm_priotracker) rm_activeReaders; union { struct mtx _rm_lock_mtx; diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 32639913973c..e06df54ab018 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -32,22 +32,9 @@ #ifndef _SYS_CPUSET_H_ #define _SYS_CPUSET_H_ -#ifdef _KERNEL -#define CPU_SETSIZE MAXCPU -#endif +#include -#define CPU_MAXSIZE (4 * MAXCPU) - -#ifndef CPU_SETSIZE -#define CPU_SETSIZE CPU_MAXSIZE -#endif - -#define _NCPUBITS (sizeof(long) * NBBY) /* bits per mask */ -#define _NCPUWORDS howmany(CPU_SETSIZE, _NCPUBITS) - -typedef struct _cpuset { - long __bits[howmany(CPU_SETSIZE, _NCPUBITS)]; -} cpuset_t; +#define CPUSETBUFSIZ ((2 + sizeof(long) * 2) * _NCPUWORDS) #define __cpuset_mask(n) ((long)1 << ((n) % _NCPUBITS)) #define CPU_CLR(n, p) ((p)->__bits[(n)/_NCPUBITS] &= ~__cpuset_mask(n)) @@ -66,6 +53,11 @@ typedef struct _cpuset { (p)->__bits[__i] = -1; \ } while (0) +#define CPU_SETOF(n, p) do { \ + CPU_ZERO(p); \ + ((p)->__bits[(n)/_NCPUBITS] = __cpuset_mask(n)); \ +} while (0) + /* Is p empty. */ #define CPU_EMPTY(p) __extension__ ({ \ __size_t __i; \ @@ -75,6 +67,15 @@ typedef struct _cpuset { __i == _NCPUWORDS; \ }) +/* Is p full set. */ +#define CPU_ISFULLSET(p) __extension__ ({ \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + if ((p)->__bits[__i] != (long)-1) \ + break; \ + __i == _NCPUWORDS; \ +}) + /* Is c a subset of p. */ #define CPU_SUBSET(p, c) __extension__ ({ \ __size_t __i; \ @@ -124,6 +125,35 @@ typedef struct _cpuset { (d)->__bits[__i] &= ~(s)->__bits[__i]; \ } while (0) +#ifdef _KERNEL +#define CPU_CLR_ATOMIC(n, p) \ + atomic_clear_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) + +#define CPU_SET_ATOMIC(n, p) \ + atomic_set_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) + +#define CPU_OR_ATOMIC(d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + atomic_set_long(&(d)->__bits[__i], \ + (s)->__bits[__i]); \ +} while (0) + +#define CPU_NAND_ATOMIC(d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + atomic_clear_long(&(d)->__bits[__i], \ + (s)->__bits[__i]); \ +} while (0) + +#define CPU_COPY_STORE_REL(f, t) do { \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + atomic_store_rel_long(&(t)->__bits[__i], \ + (f)->__bits[__i]); \ +} while (0) +#endif /* !_KERNEL */ + /* * Valid cpulevel_t values. */ @@ -184,6 +214,8 @@ void cpuset_rel(struct cpuset *); int cpuset_setthread(lwpid_t id, cpuset_t *); int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); +int cpusetobj_ffs(const cpuset_t *); +char *cpusetobj_strprint(char *, const cpuset_t *); #else __BEGIN_DECLS diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index ad1cf33e05b2..1b7f24f39117 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -37,6 +37,7 @@ #error "no assembler-serviceable parts inside" #endif +#include #include #include #include @@ -162,8 +163,8 @@ struct pcpu { uint64_t pc_switchtime; /* cpu_ticks() at last csw */ int pc_switchticks; /* `ticks' at last csw */ u_int pc_cpuid; /* This cpu number */ - cpumask_t pc_cpumask; /* This cpu mask */ - cpumask_t pc_other_cpus; /* Mask of all other cpus */ + cpuset_t pc_cpumask; /* This cpu mask */ + cpuset_t pc_other_cpus; /* Mask of all other cpus */ SLIST_ENTRY(pcpu) pc_allcpu; struct lock_list_entry *pc_spinlocks; #ifdef KTR diff --git a/sys/sys/pmckern.h b/sys/sys/pmckern.h index 3e8c1ef3fb68..796c4cadab77 100644 --- a/sys/sys/pmckern.h +++ b/sys/sys/pmckern.h @@ -76,7 +76,7 @@ extern int (*pmc_intr)(int _cpu, struct trapframe *_frame); extern struct sx pmc_sx; /* Per-cpu flags indicating availability of sampling data */ -extern volatile cpumask_t pmc_cpumask; +extern volatile cpuset_t pmc_cpumask; /* Count of system-wide sampling PMCs in existence */ extern volatile int pmc_ss_count; @@ -122,7 +122,7 @@ do { \ #define PMC_SYSTEM_SAMPLING_ACTIVE() (pmc_ss_count > 0) /* Check if a CPU has recorded samples. */ -#define PMC_CPU_HAS_SAMPLES(C) (__predict_false(pmc_cpumask & (1 << (C)))) +#define PMC_CPU_HAS_SAMPLES(C) (__predict_false(CPU_ISSET(C, &pmc_cpumask))) /* * Helper functions. diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 544cb9575f91..410adfa827e3 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -16,6 +16,8 @@ #ifndef LOCORE +#include + /* * Topology of a NUMA or HTT system. * @@ -32,7 +34,7 @@ struct cpu_group { struct cpu_group *cg_parent; /* Our parent group. */ struct cpu_group *cg_child; /* Optional children groups. */ - cpumask_t cg_mask; /* Mask of cpus in this group. */ + cpuset_t cg_mask; /* Mask of cpus in this group. */ int8_t cg_count; /* Count of cpus in this group. */ int8_t cg_children; /* Number of children groups. */ int8_t cg_level; /* Shared cache level. */ @@ -71,10 +73,10 @@ struct cpu_group *smp_topo_find(struct cpu_group *top, int cpu); extern void (*cpustop_restartfunc)(void); extern int smp_active; extern int smp_cpus; -extern volatile cpumask_t started_cpus; -extern volatile cpumask_t stopped_cpus; -extern cpumask_t hlt_cpus_mask; -extern cpumask_t logical_cpus_mask; +extern volatile cpuset_t started_cpus; +extern volatile cpuset_t stopped_cpus; +extern cpuset_t hlt_cpus_mask; +extern cpuset_t logical_cpus_mask; #endif /* SMP */ extern u_int mp_maxid; @@ -82,14 +84,14 @@ extern int mp_maxcpus; extern int mp_ncpus; extern volatile int smp_started; -extern cpumask_t all_cpus; +extern cpuset_t all_cpus; /* * Macro allowing us to determine whether a CPU is absent at any given * time, thus permitting us to configure sparse maps of cpuid-dependent * (per-CPU) structures. */ -#define CPU_ABSENT(x_cpu) ((all_cpus & (1 << (x_cpu))) == 0) +#define CPU_ABSENT(x_cpu) (!CPU_ISSET(x_cpu, &all_cpus)) /* * Macros to iterate over non-absent CPUs. CPU_FOREACH() takes an @@ -158,11 +160,11 @@ void cpu_mp_setmaxid(void); void cpu_mp_start(void); void forward_signal(struct thread *); -int restart_cpus(cpumask_t); -int stop_cpus(cpumask_t); -int stop_cpus_hard(cpumask_t); +int restart_cpus(cpuset_t); +int stop_cpus(cpuset_t); +int stop_cpus_hard(cpuset_t); #if defined(__amd64__) -int suspend_cpus(cpumask_t); +int suspend_cpus(cpuset_t); #endif void smp_rendezvous_action(void); extern struct mtx smp_ipi_mtx; @@ -173,7 +175,7 @@ void smp_rendezvous(void (*)(void *), void (*)(void *), void (*)(void *), void *arg); -void smp_rendezvous_cpus(cpumask_t, +void smp_rendezvous_cpus(cpuset_t, void (*)(void *), void (*)(void *), void (*)(void *), diff --git a/sys/sys/types.h b/sys/sys/types.h index c747d166e81d..5cc005d22e19 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -143,7 +143,6 @@ typedef __clockid_t clockid_t; #define _CLOCKID_T_DECLARED #endif -typedef __cpumask_t cpumask_t; typedef __critical_t critical_t; /* Critical section value */ typedef __int64_t daddr_t; /* disk address */ diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 804c411b951c..e81d2fe8af4d 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -807,7 +807,7 @@ lapic_handle_timer(struct trapframe *frame) * and unlike other schedulers it actually schedules threads to * those CPUs. */ - if ((hlt_cpus_mask & (1 << PCPU_GET(cpuid))) != 0) + if (CPU_ISSET(PCPU_GET(cpuid), &hlt_cpus_mask)) return; #endif diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c index cce1e0ef14ac..67ed6cd46b4f 100644 --- a/usr.sbin/pmccontrol/pmccontrol.c +++ b/usr.sbin/pmccontrol/pmccontrol.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -133,26 +134,30 @@ pmcc_init_debug(void) static int pmcc_do_enable_disable(struct pmcc_op_list *op_list) { + long cpusetsize; int c, error, i, j, ncpu, npmc, t; - cpumask_t haltedcpus, cpumask; + cpuset_t haltedcpus, cpumask; struct pmcc_op *np; unsigned char *map; unsigned char op; int cpu, pmc; - size_t dummy; if ((ncpu = pmc_ncpu()) < 0) err(EX_OSERR, "Unable to determine the number of cpus"); /* Determine the set of active CPUs. */ - cpumask = (1 << ncpu) - 1; - dummy = sizeof(int); - haltedcpus = (cpumask_t) 0; - if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus, - &dummy, NULL, 0) < 0) + cpusetsize = sysconf(_SC_CPUSET_SIZE); + if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { err(EX_OSERR, "ERROR: Cannot determine which CPUs are " "halted"); - cpumask &= ~haltedcpus; + } + CPU_ZERO(&haltedcpus); + if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus, + (size_t *)&cpusetsize, NULL, 0) < 0) + err(EX_OSERR, "ERROR: Cannot determine which CPUs are " + "halted"); + CPU_FILL(&cpumask); + CPU_NAND(&cpumask, &haltedcpus); /* Determine the maximum number of PMCs in any CPU. */ npmc = 0; @@ -200,7 +205,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list) if (cpu == PMCC_CPU_ALL) for (i = 0; i < ncpu; i++) { - if ((1 << i) & cpumask) + if (CPU_ISSET(i, &cpumask)) SET_PMCS(i, pmc, op); } else From 67be81a4431c6880187d414c512a2f8414a9d2d0 Mon Sep 17 00:00:00 2001 From: attilio Date: Thu, 5 May 2011 19:35:12 +0000 Subject: [PATCH 018/164] Revert this, as in userland MAXCPU is always 1. Reported by: marcel --- sys/sys/_cpuset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/_cpuset.h b/sys/sys/_cpuset.h index 62a0e9d425d0..42a0a6a9db81 100644 --- a/sys/sys/_cpuset.h +++ b/sys/sys/_cpuset.h @@ -36,7 +36,7 @@ #define CPU_SETSIZE MAXCPU #endif -#define CPU_MAXSIZE (4 * MAXCPU) +#define CPU_MAXSIZE 128 #ifndef CPU_SETSIZE #define CPU_SETSIZE CPU_MAXSIZE From a605037db4804f131a2612a33030d7863e23ae81 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 6 May 2011 15:31:27 +0000 Subject: [PATCH 019/164] Fix breakage. Reported by: sbruno --- usr.sbin/pmccontrol/pmccontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c index 67ed6cd46b4f..836025b926fc 100644 --- a/usr.sbin/pmccontrol/pmccontrol.c +++ b/usr.sbin/pmccontrol/pmccontrol.c @@ -28,7 +28,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include #include #include #include From 8534b0c2951283889da00ca8a244058185638240 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 6 May 2011 21:53:29 +0000 Subject: [PATCH 020/164] Add sparc64 support. Compiled (and helped) by: pluknet --- sys/sparc64/include/_types.h | 1 - sys/sparc64/include/pmap.h | 3 +- sys/sparc64/include/smp.h | 47 ++++++++----- sys/sparc64/sparc64/intr_machdep.c | 10 +-- sys/sparc64/sparc64/mp_machdep.c | 102 +++++++++++++++++------------ sys/sparc64/sparc64/pmap.c | 8 +-- sys/sparc64/sparc64/tlb.c | 6 +- 7 files changed, 105 insertions(+), 72 deletions(-) diff --git a/sys/sparc64/include/_types.h b/sys/sparc64/include/_types.h index f810c159a6ef..7e993c4c370a 100644 --- a/sys/sparc64/include/_types.h +++ b/sys/sparc64/include/_types.h @@ -55,7 +55,6 @@ typedef unsigned long __uint64_t; * Standard type definitions. */ typedef __int32_t __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef __int64_t __critical_t; typedef double __double_t; typedef float __float_t; diff --git a/sys/sparc64/include/pmap.h b/sys/sparc64/include/pmap.h index e16ea9776029..adad2575598e 100644 --- a/sys/sparc64/include/pmap.h +++ b/sys/sparc64/include/pmap.h @@ -40,6 +40,7 @@ #define _MACHINE_PMAP_H_ #include +#include #include #include #include @@ -61,7 +62,7 @@ struct pmap { struct mtx pm_mtx; struct tte *pm_tsb; vm_object_t pm_tsb_obj; - cpumask_t pm_active; + cpuset_t pm_active; u_int pm_context[MAXCPU]; struct pmap_statistics pm_stats; }; diff --git a/sys/sparc64/include/smp.h b/sys/sparc64/include/smp.h index 3ca8e0380444..f8f7d1c192b2 100644 --- a/sys/sparc64/include/smp.h +++ b/sys/sparc64/include/smp.h @@ -38,6 +38,7 @@ #ifndef LOCORE +#include #include #include @@ -76,17 +77,17 @@ struct cpu_start_args { }; struct ipi_cache_args { - cpumask_t ica_mask; + cpuset_t ica_mask; vm_paddr_t ica_pa; }; struct ipi_rd_args { - cpumask_t ira_mask; + cpuset_t ira_mask; register_t *ira_val; }; struct ipi_tlb_args { - cpumask_t ita_mask; + cpuset_t ita_mask; struct pmap *ita_pmap; u_long ita_start; u_long ita_end; @@ -100,7 +101,7 @@ extern struct pcb stoppcbs[]; void cpu_mp_bootstrap(struct pcpu *pc); void cpu_mp_shutdown(void); -typedef void cpu_ipi_selected_t(u_int, u_long, u_long, u_long); +typedef void cpu_ipi_selected_t(cpuset_t, u_long, u_long, u_long); extern cpu_ipi_selected_t *cpu_ipi_selected; typedef void cpu_ipi_single_t(u_int, u_long, u_long, u_long); extern cpu_ipi_single_t *cpu_ipi_single; @@ -140,7 +141,7 @@ ipi_all_but_self(u_int ipi) } static __inline void -ipi_selected(u_int cpus, u_int ipi) +ipi_selected(cpuset_t cpus, u_int ipi) { cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_level, ipi); @@ -197,7 +198,8 @@ ipi_rd(u_int cpu, void *func, u_long *val) sched_pin(); ira = &ipi_rd_args; mtx_lock_spin(&ipi_mtx); - ira->ira_mask = 1 << cpu | PCPU_GET(cpumask); + ira->ira_mask = PCPU_GET(cpumask); + CPU_SET(cpu, &ira->ira_mask); ira->ira_val = val; cpu_ipi_single(cpu, 0, (u_long)func, (u_long)ira); return (&ira->ira_mask); @@ -207,18 +209,21 @@ static __inline void * ipi_tlb_context_demap(struct pmap *pm) { struct ipi_tlb_args *ita; - cpumask_t cpus; + cpuset_t cpus; if (smp_cpus == 1) return (NULL); sched_pin(); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) { + cpus = pm->pm_active; + CPU_AND(&cpus, PCPU_PTR(other_cpus)); + if (CPU_EMPTY(&cpus)) { sched_unpin(); return (NULL); } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); + CPU_OR(&cpus, PCPU_PTR(cpumask)); + ita->ita_mask = cpus; ita->ita_pmap = pm; cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap, (u_long)ita); @@ -229,18 +234,21 @@ static __inline void * ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va) { struct ipi_tlb_args *ita; - cpumask_t cpus; + cpuset_t cpus; if (smp_cpus == 1) return (NULL); sched_pin(); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) { + cpus = pm->pm_active; + CPU_AND(&cpus, PCPU_PTR(other_cpus)); + if (CPU_EMPTY(&cpus)) { sched_unpin(); return (NULL); } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); + CPU_OR(&cpus, PCPU_PTR(cpumask)); + ita->ita_mask = cpus; ita->ita_pmap = pm; ita->ita_va = va; cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_page_demap, (u_long)ita); @@ -251,18 +259,21 @@ static __inline void * ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) { struct ipi_tlb_args *ita; - cpumask_t cpus; + cpuset_t cpus; if (smp_cpus == 1) return (NULL); sched_pin(); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) { + cpus = pm->pm_active; + CPU_AND(&cpus, PCPU_PTR(other_cpus)); + if (CPU_EMPTY(&cpus)) { sched_unpin(); return (NULL); } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); + CPU_OR(&cpus, PCPU_PTR(cpumask)); + ita->ita_mask = cpus; ita->ita_pmap = pm; ita->ita_start = start; ita->ita_end = end; @@ -274,11 +285,11 @@ ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) static __inline void ipi_wait(void *cookie) { - volatile cpumask_t *mask; + volatile cpuset_t *mask; if ((mask = cookie) != NULL) { - atomic_clear_int(mask, PCPU_GET(cpumask)); - while (*mask != 0) + CPU_NAND_ATOMIC(mask, PCPU_PTR(cpumask)); + while (!CPU_EMPTY(mask)) ; mtx_unlock_spin(&ipi_mtx); sched_unpin(); diff --git a/sys/sparc64/sparc64/intr_machdep.c b/sys/sparc64/sparc64/intr_machdep.c index f6ef9a7bf113..ed301826693c 100644 --- a/sys/sparc64/sparc64/intr_machdep.c +++ b/sys/sparc64/sparc64/intr_machdep.c @@ -445,8 +445,7 @@ intr_describe(int vec, void *ih, const char *descr) * allocate CPUs round-robin. */ -/* The BSP is always a valid target. */ -static cpumask_t intr_cpus = (1 << 0); +static cpuset_t intr_cpus; static int current_cpu; static void @@ -468,7 +467,7 @@ intr_assign_next_cpu(struct intr_vector *iv) current_cpu++; if (current_cpu > mp_maxid) current_cpu = 0; - } while (!(intr_cpus & (1 << current_cpu))); + } while (!CPU_ISSET(current_cpu, &intr_cpus)); } /* Attempt to bind the specified IRQ to the specified CPU. */ @@ -504,7 +503,7 @@ intr_add_cpu(u_int cpu) if (bootverbose) printf("INTR: Adding CPU %d as a target\n", cpu); - intr_cpus |= (1 << cpu); + CPU_SET(cpu, &intr_cpus); } /* @@ -518,6 +517,9 @@ intr_shuffle_irqs(void *arg __unused) struct intr_vector *iv; int i; + /* The BSP is always a valid target. */ + CPU_SETOF(0, &intr_cpus); + /* Don't bother on UP. */ if (mp_ncpus == 1) return; diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 8700f8904860..9bee247d0605 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -121,7 +121,7 @@ cpu_ipi_single_t *cpu_ipi_single; static vm_offset_t mp_tramp; static u_int cpuid_to_mid[MAXCPU]; static int isjbus; -static volatile cpumask_t shutdown_cpus; +static volatile cpuset_t shutdown_cpus; static void ap_count(phandle_t node, u_int mid, u_int cpu_impl); static void ap_start(phandle_t node, u_int mid, u_int cpu_impl); @@ -228,7 +228,7 @@ void cpu_mp_setmaxid() { - all_cpus = 1 << curcpu; + CPU_SETOF(curcpu, &all_cpus); mp_ncpus = 1; mp_maxid = 0; @@ -283,6 +283,7 @@ sun4u_startcpu(phandle_t cpu, void *func, u_long arg) void cpu_mp_start(void) { + cpuset_t ocpus; mtx_init(&ipi_mtx, "ipi", NULL, MTX_SPIN); @@ -299,7 +300,9 @@ cpu_mp_start(void) KASSERT(!isjbus || mp_ncpus <= IDR_JALAPENO_MAX_BN_PAIRS, ("%s: can only IPI a maximum of %d JBus-CPUs", __func__, IDR_JALAPENO_MAX_BN_PAIRS)); - PCPU_SET(other_cpus, all_cpus & ~(1 << curcpu)); + ocpus = all_cpus; + CPU_CLR(curcpu, &ocpus); + PCPU_SET(other_cpus, ocpus); smp_active = 1; } @@ -357,7 +360,7 @@ ap_start(phandle_t node, u_int mid, u_int cpu_impl) cache_init(pc); - all_cpus |= 1 << cpuid; + CPU_SET(cpuid, &all_cpus); intr_add_cpu(cpuid); } @@ -421,6 +424,7 @@ cpu_mp_unleash(void *v) void cpu_mp_bootstrap(struct pcpu *pc) { + cpuset_t ocpus; volatile struct cpu_start_args *csa; csa = &cpu_start_args; @@ -465,7 +469,9 @@ cpu_mp_bootstrap(struct pcpu *pc) smp_cpus++; KASSERT(curthread != NULL, ("%s: curthread", __func__)); - PCPU_SET(other_cpus, all_cpus & ~(1 << curcpu)); + ocpus = all_cpus; + CPU_CLR(curcpu, &all_cpus); + PCPU_SET(other_cpus, ocpus); printf("SMP: AP CPU #%d Launched!\n", curcpu); csa->csa_count--; @@ -484,14 +490,22 @@ cpu_mp_bootstrap(struct pcpu *pc) void cpu_mp_shutdown(void) { + cpuset_t cpus; int i; critical_enter(); shutdown_cpus = PCPU_GET(other_cpus); - if (stopped_cpus != PCPU_GET(other_cpus)) /* XXX */ - stop_cpus(stopped_cpus ^ PCPU_GET(other_cpus)); + cpus = shutdown_cpus; + + /* XXX: Stopp all the CPUs which aren't already. */ + if (CPU_CMP(&stopped_cpus, &cpus)) { + + /* pc_other_cpus is just a flat "on" mask without curcpu. */ + CPU_NAND(&cpus, &stopped_cpus); + stop_cpus(cpus); + } i = 0; - while (shutdown_cpus != 0) { + while (!CPU_EMPTY(&shutdown_cpus)) { if (i++ > 100000) { printf("timeout shutting down CPUs.\n"); break; @@ -509,20 +523,24 @@ cpu_ipi_ast(struct trapframe *tf) static void cpu_ipi_stop(struct trapframe *tf) { + cpuset_t tcmask; CTR2(KTR_SMP, "%s: stopped %d", __func__, curcpu); + sched_pin(); savectx(&stoppcbs[curcpu]); - atomic_set_acq_int(&stopped_cpus, PCPU_GET(cpumask)); - while ((started_cpus & PCPU_GET(cpumask)) == 0) { - if ((shutdown_cpus & PCPU_GET(cpumask)) != 0) { - atomic_clear_int(&shutdown_cpus, PCPU_GET(cpumask)); + tcmask = PCPU_GET(cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &tcmask); + while (!CPU_OVERLAP(&started_cpus, &tcmask)) { + if (CPU_OVERLAP(&shutdown_cpus, &tcmask)) { + CPU_OR_ATOMIC(&shutdown_cpus, &tcmask); (void)intr_disable(); for (;;) ; } } - atomic_clear_rel_int(&started_cpus, PCPU_GET(cpumask)); - atomic_clear_rel_int(&stopped_cpus, PCPU_GET(cpumask)); + CPU_NAND_ATOMIC(&started_cpus, &tcmask); + CPU_NAND_ATOMIC(&stopped_cpus, &tcmask); + sched_unpin(); CTR2(KTR_SMP, "%s: restarted %d", __func__, curcpu); } @@ -551,13 +569,13 @@ cpu_ipi_hardclock(struct trapframe *tf) } static void -spitfire_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) +spitfire_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { u_int cpu; - while (cpus) { - cpu = ffs(cpus) - 1; - cpus &= ~(1 << cpu); + while (CPU_EMPTY(&cpus)) { + cpu = cpusetobj_ffs(&cpus) - 1; + CPU_CLR(cpu, &cpus); spitfire_ipi_single(cpu, d0, d1, d2); } } @@ -657,20 +675,21 @@ cheetah_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2) } static void -cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) +cheetah_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { + char pbuf[CPUSETBUFSIZ]; register_t s; u_long ids; u_int bnp; u_int cpu; int i; - KASSERT((cpus & (1 << curcpu)) == 0, - ("%s: CPU can't IPI itself", __func__)); + KASSERT(!CPU_ISSET(curcpu, &cpus), ("%s: CPU can't IPI itself", + __func__)); KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & IDR_CHEETAH_ALL_BUSY) == 0, ("%s: outstanding dispatch", __func__)); - if (cpus == 0) + if (CPU_EMPTY(&cpus)) return; ids = 0; for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) { @@ -681,7 +700,7 @@ cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) membar(Sync); bnp = 0; for (cpu = 0; cpu < mp_ncpus; cpu++) { - if ((cpus & (1 << cpu)) != 0) { + if (CPU_ISSET(cpu, &cpus)) { stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << IDC_ITID_SHIFT) | bnp << IDC_BN_SHIFT, ASI_SDB_INTR_W, 0); @@ -698,9 +717,9 @@ cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) return; bnp = 0; for (cpu = 0; cpu < mp_ncpus; cpu++) { - if ((cpus & (1 << cpu)) != 0) { + if (CPU_ISSET(cpu, &cpus)) { if ((ids & (IDR_NACK << (2 * bnp))) == 0) - cpus &= ~(1 << cpu); + CPU_CLR(cpu, &cpus); bnp++; } } @@ -709,7 +728,7 @@ cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) * CPUs we actually haven't tried to send an IPI to, * but which apparently can be safely ignored. */ - if (cpus == 0) + if (CPU_EMPTY(&cpus)) return; /* * Leave interrupts enabled for a bit before retrying @@ -719,11 +738,11 @@ cheetah_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) DELAY(2 * mp_ncpus); } if (kdb_active != 0 || panicstr != NULL) - printf("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)\n", - __func__, cpus, ids); + printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", + __func__, cpusetobj_strprint(pbuf, &cpus), ids); else - panic("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)", - __func__, cpus, ids); + panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)", + __func__, cpusetobj_strprint(pbuf, &cpus), ids); } static void @@ -772,19 +791,20 @@ jalapeno_ipi_single(u_int cpu, u_long d0, u_long d1, u_long d2) } static void -jalapeno_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) +jalapeno_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { + char pbuf[CPUSETBUFSIZ]; register_t s; u_long ids; u_int cpu; int i; - KASSERT((cpus & (1 << curcpu)) == 0, - ("%s: CPU can't IPI itself", __func__)); + KASSERT(!CPU_ISSET(curcpu, &cpus), ("%s: CPU can't IPI itself", + __func__)); KASSERT((ldxa(0, ASI_INTR_DISPATCH_STATUS) & IDR_CHEETAH_ALL_BUSY) == 0, ("%s: outstanding dispatch", __func__)); - if (cpus == 0) + if (CPU_EMPTY(&cpus)) return; ids = 0; for (i = 0; i < IPI_RETRIES * mp_ncpus; i++) { @@ -794,7 +814,7 @@ jalapeno_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) stxa(AA_SDB_INTR_D2, ASI_SDB_INTR_W, d2); membar(Sync); for (cpu = 0; cpu < mp_ncpus; cpu++) { - if ((cpus & (1 << cpu)) != 0) { + if (CPU_ISSET(cpu, &cpus)) { stxa(AA_INTR_SEND | (cpuid_to_mid[cpu] << IDC_ITID_SHIFT), ASI_SDB_INTR_W, 0); membar(Sync); @@ -808,10 +828,10 @@ jalapeno_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) (IDR_CHEETAH_ALL_BUSY | IDR_CHEETAH_ALL_NACK)) == 0) return; for (cpu = 0; cpu < mp_ncpus; cpu++) - if ((cpus & (1 << cpu)) != 0) + if (CPU_ISSET(cpu, &cpus)) if ((ids & (IDR_NACK << (2 * cpuid_to_mid[cpu]))) == 0) - cpus &= ~(1 << cpu); + CPU_CLR(cpu, &cpus); /* * Leave interrupts enabled for a bit before retrying * in order to avoid deadlocks if the other CPUs are @@ -820,9 +840,9 @@ jalapeno_ipi_selected(u_int cpus, u_long d0, u_long d1, u_long d2) DELAY(2 * mp_ncpus); } if (kdb_active != 0 || panicstr != NULL) - printf("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)\n", - __func__, cpus, ids); + printf("%s: couldn't send IPI (cpus=%s ids=0x%lu)\n", + __func__, cpusetobj_strprint(pbuf, &cpus), ids); else - panic("%s: couldn't send IPI (cpus=0x%u ids=0x%lu)", - __func__, cpus, ids); + panic("%s: couldn't send IPI (cpus=%s ids=0x%lu)", + __func__, cpusetobj_strprint(pbuf, &cpus), ids); } diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index 09482b9dedae..22393a0802ba 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -664,7 +664,7 @@ pmap_bootstrap(u_int cpu_impl) pm = kernel_pmap; for (i = 0; i < MAXCPU; i++) pm->pm_context[i] = TLB_CTX_KERNEL; - pm->pm_active = ~0; + CPU_ZERO(&pm->pm_active); /* * Flush all non-locked TLB entries possibly left over by the @@ -1189,7 +1189,7 @@ pmap_pinit0(pmap_t pm) PMAP_LOCK_INIT(pm); for (i = 0; i < MAXCPU; i++) pm->pm_context[i] = TLB_CTX_KERNEL; - pm->pm_active = 0; + CPU_ZERO(&pm->pm_active); pm->pm_tsb = NULL; pm->pm_tsb_obj = NULL; bzero(&pm->pm_stats, sizeof(pm->pm_stats)); @@ -1229,7 +1229,7 @@ pmap_pinit(pmap_t pm) mtx_lock_spin(&sched_lock); for (i = 0; i < MAXCPU; i++) pm->pm_context[i] = -1; - pm->pm_active = 0; + CPU_ZERO(&pm->pm_active); mtx_unlock_spin(&sched_lock); VM_OBJECT_LOCK(pm->pm_tsb_obj); @@ -2230,7 +2230,7 @@ pmap_activate(struct thread *td) PCPU_SET(tlb_ctx, context + 1); pm->pm_context[curcpu] = context; - pm->pm_active |= PCPU_GET(cpumask); + CPU_OR(&pm->pm_active, PCPU_PTR(cpumask)); PCPU_SET(pmap, pm); stxa(AA_DMMU_TSB, ASI_DMMU, pm->pm_tsb); diff --git a/sys/sparc64/sparc64/tlb.c b/sys/sparc64/sparc64/tlb.c index 990c77763750..9fcece6f43a6 100644 --- a/sys/sparc64/sparc64/tlb.c +++ b/sys/sparc64/sparc64/tlb.c @@ -80,7 +80,7 @@ tlb_context_demap(struct pmap *pm) PMAP_STATS_INC(tlb_ncontext_demap); cookie = ipi_tlb_context_demap(pm); s = intr_disable(); - if (pm->pm_active & PCPU_GET(cpumask)) { + if (CPU_OVERLAP(&pm->pm_active, PCPU_PTR(cpumask))) { KASSERT(pm->pm_context[curcpu] != -1, ("tlb_context_demap: inactive pmap?")); stxa(TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, ASI_DMMU_DEMAP, 0); @@ -101,7 +101,7 @@ tlb_page_demap(struct pmap *pm, vm_offset_t va) PMAP_STATS_INC(tlb_npage_demap); cookie = ipi_tlb_page_demap(pm, va); s = intr_disable(); - if (pm->pm_active & PCPU_GET(cpumask)) { + if (CPU_OVERLAP(&pm->pm_active, PCPU_PTR(cpumask))) { KASSERT(pm->pm_context[curcpu] != -1, ("tlb_page_demap: inactive pmap?")); if (pm == kernel_pmap) @@ -128,7 +128,7 @@ tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) PMAP_STATS_INC(tlb_nrange_demap); cookie = ipi_tlb_range_demap(pm, start, end); s = intr_disable(); - if (pm->pm_active & PCPU_GET(cpumask)) { + if (CPU_OVERLAP(&pm->pm_active, PCPU_PTR(cpumask))) { KASSERT(pm->pm_context[curcpu] != -1, ("tlb_range_demap: inactive pmap?")); if (pm == kernel_pmap) From a0b51ba62fa86f5faf7bbd81e0b91ba497fec05a Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 6 May 2011 22:45:33 +0000 Subject: [PATCH 021/164] MFC --- bin/sh/mksyntax.c | 2 + bin/sh/parser.c | 145 ++++++- bin/sh/parser.h | 16 +- bin/sh/sh.1 | 73 +++- contrib/llvm/lib/Support/Unix/Host.inc | 4 + contrib/one-true-awk/FIXES | 5 + contrib/one-true-awk/main.c | 4 +- contrib/one-true-awk/proctab.c | 207 ---------- lib/libc/net/sctp_sys_calls.c | 141 +++---- lib/libutil/libutil.h | 11 +- release/amd64/mkisoimages.sh | 1 - release/generate-release.sh | 27 +- release/i386/mkisoimages.sh | 1 - release/ia64/mkisoimages.sh | 27 +- release/pc98/mkisoimages.sh | 1 - release/powerpc/mkisoimages.sh | 2 - share/man/man4/Makefile | 1 + share/man/man9/Makefile | 1 + sys/amd64/amd64/mp_machdep.c | 27 +- sys/amd64/include/specialreg.h | 2 + sys/boot/i386/boot2/Makefile | 3 +- sys/dev/ahci/ahci.c | 1 + sys/dev/ath/ath_hal/ar5416/ar5416.h | 1 + sys/dev/ath/ath_hal/ar5416/ar5416_misc.c | 19 + sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 7 +- sys/dev/bm/if_bm.c | 34 +- sys/dev/coretemp/coretemp.c | 9 + sys/dev/cxgbe/t4_main.c | 2 +- sys/dev/e1000/if_em.c | 4 +- sys/dev/xl/if_xl.c | 233 +++++------ sys/fs/nfs/nfs.h | 2 +- sys/fs/nfsclient/nfs_clvfsops.c | 2 +- sys/fs/nfsserver/nfs_nfsdport.c | 17 +- sys/geom/geom_map.c | 455 ++++++++++++---------- sys/i386/i386/mp_machdep.c | 27 +- sys/i386/include/specialreg.h | 2 + sys/ia64/isa/isa.c | 22 -- sys/isa/isa_common.c | 4 +- sys/isa/isa_common.h | 6 - sys/mips/atheros/ar71xx_gpio.c | 15 +- sys/mips/atheros/ar71xx_gpiovar.h | 2 + sys/mips/atheros/ar724xreg.h | 2 - sys/mips/atheros/ar91xxreg.h | 2 - sys/net/if_tun.c | 20 +- sys/netinet/ipfw/ip_dn_glue.c | 2 +- sys/netinet/ipfw/ip_dummynet.c | 1 + sys/netinet/sctp_auth.h | 4 +- sys/nfsclient/nfs_bio.c | 2 +- sys/nfsclient/nfs_kdtrace.c | 2 +- sys/nfsclient/nfs_kdtrace.h | 120 ------ sys/nfsclient/nfs_subs.c | 2 +- sys/nfsclient/nfs_vnops.c | 2 +- sys/powerpc/conf/GENERIC | 2 +- sys/powerpc/mpc85xx/isa.c | 17 - sys/powerpc/powermac/macio.c | 31 ++ sys/powerpc/powermac/maciovar.h | 10 + sys/sparc64/isa/isa.c | 23 -- sys/sys/stdint.h | 51 +-- sys/sys/types.h | 46 +-- sys/x86/isa/isa.c | 22 -- sys/x86/x86/local_apic.c | 38 +- tools/build/options/WITHOUT_ACCT | 2 +- tools/build/options/WITHOUT_FDT | 4 +- tools/build/options/WITHOUT_FLOPPY | 2 +- tools/build/options/WITH_GPIO | 2 - usr.sbin/makefs/cd9660/cd9660_eltorito.c | 47 +-- 66 files changed, 908 insertions(+), 1113 deletions(-) delete mode 100644 contrib/one-true-awk/proctab.c delete mode 100644 sys/nfsclient/nfs_kdtrace.h delete mode 100644 tools/build/options/WITH_GPIO diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index 6bd1390343c1..9aa7450772b7 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -64,6 +64,7 @@ struct synclass synclass[] = { { "CWORD", "character is nothing special" }, { "CNL", "newline character" }, { "CBACK", "a backslash character" }, + { "CSBACK", "a backslash character in single quotes" }, { "CSQUOTE", "single quote" }, { "CDQUOTE", "double quote" }, { "CENDQUOTE", "a terminating quote" }, @@ -224,6 +225,7 @@ main(int argc __unused, char **argv __unused) init(); fputs("\n/* syntax table used when in single quotes */\n", cfile); add("\n", "CNL"); + add("\\", "CSBACK"); add("'", "CENDQUOTE"); /* ':/' for tilde expansion, '-' for [a\-x] pattern ranges */ add("!*?[=~:/-", "CCTL"); diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 43822f934d62..5133d67f9bfa 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1126,6 +1126,127 @@ parsebackq(char *out, struct nodelist **pbqlist, } +/* + * Called to parse a backslash escape sequence inside $'...'. + * The backslash has already been read. + */ +static char * +readcstyleesc(char *out) +{ + int c, v, i, n; + + c = pgetc(); + switch (c) { + case '\0': + synerror("Unterminated quoted string"); + case '\n': + plinno++; + if (doprompt) + setprompt(2); + else + setprompt(0); + return out; + case '\\': + case '\'': + case '"': + v = c; + break; + case 'a': v = '\a'; break; + case 'b': v = '\b'; break; + case 'e': v = '\033'; break; + case 'f': v = '\f'; break; + case 'n': v = '\n'; break; + case 'r': v = '\r'; break; + case 't': v = '\t'; break; + case 'v': v = '\v'; break; + case 'x': + v = 0; + for (;;) { + c = pgetc(); + if (c >= '0' && c <= '9') + v = (v << 4) + c - '0'; + else if (c >= 'A' && c <= 'F') + v = (v << 4) + c - 'A' + 10; + else if (c >= 'a' && c <= 'f') + v = (v << 4) + c - 'a' + 10; + else + break; + } + pungetc(); + break; + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + v = c - '0'; + c = pgetc(); + if (c >= '0' && c <= '7') { + v <<= 3; + v += c - '0'; + c = pgetc(); + if (c >= '0' && c <= '7') { + v <<= 3; + v += c - '0'; + } else + pungetc(); + } else + pungetc(); + break; + case 'c': + c = pgetc(); + if (c < 0x3f || c > 0x7a || c == 0x60) + synerror("Bad escape sequence"); + if (c == '\\' && pgetc() != '\\') + synerror("Bad escape sequence"); + if (c == '?') + v = 127; + else + v = c & 0x1f; + break; + case 'u': + case 'U': + n = c == 'U' ? 8 : 4; + v = 0; + for (i = 0; i < n; i++) { + c = pgetc(); + if (c >= '0' && c <= '9') + v = (v << 4) + c - '0'; + else if (c >= 'A' && c <= 'F') + v = (v << 4) + c - 'A' + 10; + else if (c >= 'a' && c <= 'f') + v = (v << 4) + c - 'a' + 10; + else + synerror("Bad escape sequence"); + } + if (v == 0 || (v >= 0xd800 && v <= 0xdfff)) + synerror("Bad escape sequence"); + /* We really need iconv here. */ + if (v > 127) + v = '?'; + break; + default: + synerror("Bad escape sequence"); + } + v = (char)v; + /* + * We can't handle NUL bytes. + * POSIX says we should skip till the closing quote. + */ + if (v == '\0') { + while ((c = pgetc()) != '\'') { + if (c == '\\') + c = pgetc(); + if (c == PEOF) + synerror("Unterminated quoted string"); + } + pungetc(); + return out; + } + if (SQSYNTAX[v] == CCTL) + USTPUTC(CTLESC, out); + USTPUTC(v, out); + return out; +} + + /* * If eofmark is NULL, read a word or a redirection symbol. If eofmark * is not NULL, read a here document. In the latter case, eofmark is the @@ -1158,6 +1279,7 @@ readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs) struct tokenstate state_static[MAXNEST_static]; int maxnest = MAXNEST_static; struct tokenstate *state = state_static; + int sqiscstyle = 0; startlinno = plinno; quotef = 0; @@ -1188,6 +1310,12 @@ readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs) setprompt(0); c = pgetc(); goto loop; /* continue outer loop */ + case CSBACK: + if (sqiscstyle) { + out = readcstyleesc(out); + break; + } + /* FALLTHROUGH */ case CWORD: USTPUTC(c, out); break; @@ -1232,6 +1360,7 @@ readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs) case CSQUOTE: USTPUTC(CTLQUOTEMARK, out); state[level].syntax = SQSYNTAX; + sqiscstyle = 0; break; case CDQUOTE: USTPUTC(CTLQUOTEMARK, out); @@ -1450,11 +1579,7 @@ parsesub: { int c1; c = pgetc(); - if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && - !is_special(c)) { - USTPUTC('$', out); - pungetc(); - } else if (c == '(') { /* $(command) or $((arith)) */ + if (c == '(') { /* $(command) or $((arith)) */ if (pgetc() == '(') { PARSEARITH(); } else { @@ -1465,7 +1590,7 @@ parsesub: { state[level].syntax == DQSYNTAX || state[level].syntax == ARISYNTAX); } - } else { + } else if (c == '{' || is_name(c) || is_special(c)) { USTPUTC(CTLVAR, out); typeloc = out - stackblock(); USTPUTC(VSNORMAL, out); @@ -1612,6 +1737,14 @@ parsesub: { newvarnest++; } } + } else if (c == '\'' && state[level].syntax == BASESYNTAX) { + /* $'cstylequotes' */ + USTPUTC(CTLQUOTEMARK, out); + state[level].syntax = SQSYNTAX; + sqiscstyle = 1; + } else { + USTPUTC('$', out); + pungetc(); } goto parsesub_return; } diff --git a/bin/sh/parser.h b/bin/sh/parser.h index 64ec97ffff54..dfbda861e0c8 100644 --- a/bin/sh/parser.h +++ b/bin/sh/parser.h @@ -34,16 +34,16 @@ */ /* control characters in argument strings */ -#define CTLESC '\201' -#define CTLVAR '\202' -#define CTLENDVAR '\203' -#define CTLBACKQ '\204' +#define CTLESC '\300' +#define CTLVAR '\301' +#define CTLENDVAR '\371' +#define CTLBACKQ '\372' #define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ /* CTLBACKQ | CTLQUOTE == '\205' */ -#define CTLARI '\206' -#define CTLENDARI '\207' -#define CTLQUOTEMARK '\210' -#define CTLQUOTEEND '\211' /* only for ${v+-...} */ +#define CTLARI '\374' +#define CTLENDARI '\375' +#define CTLQUOTEMARK '\376' +#define CTLQUOTEEND '\377' /* only for ${v+-...} */ /* variable substitution byte (follows CTLVAR) */ #define VSTYPE 0x0f /* type of variable substitution */ diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index e9f34fb8ca73..e240d7dc28f4 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd May 5, 2011 .Dt SH 1 .Os .Sh NAME @@ -396,13 +396,82 @@ Quoting is used to remove the special meaning of certain characters or words to the shell, such as operators, whitespace, keywords, or alias names. .Pp -There are three types of quoting: matched single quotes, +There are four types of quoting: matched single quotes, +dollar-single quotes, matched double quotes, and backslash. .Bl -tag -width indent .It Single Quotes Enclosing characters in single quotes preserves the literal meaning of all the characters (except single quotes, making it impossible to put single-quotes in a single-quoted string). +.It Dollar-Single Quotes +Enclosing characters between +.Li $' +and +.Li ' +preserves the literal meaning of all characters +except backslashes and single quotes. +A backslash introduces a C-style escape sequence: +.Bl -tag -width xUnnnnnnnn +.It \ea +Alert (ring the terminal bell) +.It \eb +Backspace +.It \ec Ns Ar c +The control character denoted by +.Li ^ Ns Ar c +in +.Xr stty 1 . +If +.Ar c +is a backslash, it must be doubled. +.It \ee +The ESC character +.Tn ( ASCII +0x1b) +.It \ef +Formfeed +.It \en +Newline +.It \er +Carriage return +.It \et +Horizontal tab +.It \ev +Vertical tab +.It \e\e +Literal backslash +.It \e\&' +Literal single-quote +.It \e\&" +Literal double-quote +.It \e Ns Ar nnn +The byte whose octal value is +.Ar nnn +(one to three digits) +.It \ex Ns Ar nn +The byte whose hexadecimal value is +.Ar nn +(one or more digits only the last two of which are used) +.It \eu Ns Ar nnnn +The Unicode code point +.Ar nnnn +(four hexadecimal digits) +.It \eU Ns Ar nnnnnnnn +The Unicode code point +.Ar nnnnnnnn +(eight hexadecimal digits) +.El +.Pp +The sequences for Unicode code points currently only provide useful results +for values below 128. +They reject code point 0 and UTF-16 surrogates. +.Pp +If an escape sequence would produce a byte with value 0, +that byte and the rest of the string until the matching single-quote +are ignored. +.Pp +Any other string starting with a backslash is an error. .It Double Quotes Enclosing characters within double quotes preserves the literal meaning of all characters except dollar sign diff --git a/contrib/llvm/lib/Support/Unix/Host.inc b/contrib/llvm/lib/Support/Unix/Host.inc index 8cbec8cd7ee8..9c7523071dd4 100644 --- a/contrib/llvm/lib/Support/Unix/Host.inc +++ b/contrib/llvm/lib/Support/Unix/Host.inc @@ -35,6 +35,9 @@ static std::string getOSVersion() { } std::string sys::getHostTriple() { +#ifdef __FreeBSD__ + return LLVM_HOSTTRIPLE; +#else // FIXME: Derive directly instead of relying on the autoconf generated // variable. @@ -91,4 +94,5 @@ std::string sys::getHostTriple() { } return Triple; +#endif } diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES index 36ef237ed91c..e6edc5309cc1 100644 --- a/contrib/one-true-awk/FIXES +++ b/contrib/one-true-awk/FIXES @@ -25,6 +25,11 @@ THIS SOFTWARE. This file lists all bug fixes, changes, etc., made since the AWK book was sent to the printers in August, 1987. +May 6, 2011: + added #ifdef for isblank. + now allows -ffoo as well as -f foo arguments. + (thanks, ruslan) + May 1, 2011: after advice from todd miller, kevin lo, ruslan ermilov, and arnold robbins, changed srand() to return the previous diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c index 27a49e40cf3a..b40a39d3e788 100644 --- a/contrib/one-true-awk/main.c +++ b/contrib/one-true-awk/main.c @@ -25,7 +25,7 @@ THIS SOFTWARE. #include __FBSDID("$FreeBSD$"); -const char *version = "version 20110501 (FreeBSD)"; +const char *version = "version 20110506 (FreeBSD)"; #define DEBUG #include @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) safe = 1; break; case 'f': /* next argument is program filename */ - if (argv[1][2] != 0) { /* arg is -fsomething */ + if (argv[1][2] != 0) { /* arg is -fsomething */ if (npfile >= MAX_PFILE - 1) FATAL("too many -f options"); pfile[npfile++] = &argv[1][2]; diff --git a/contrib/one-true-awk/proctab.c b/contrib/one-true-awk/proctab.c deleted file mode 100644 index e4eddfda92d1..000000000000 --- a/contrib/one-true-awk/proctab.c +++ /dev/null @@ -1,207 +0,0 @@ -#include -#include "awk.h" -#include "ytab.h" - -static char *printname[93] = { - (char *) "FIRSTTOKEN", /* 258 */ - (char *) "PROGRAM", /* 259 */ - (char *) "PASTAT", /* 260 */ - (char *) "PASTAT2", /* 261 */ - (char *) "XBEGIN", /* 262 */ - (char *) "XEND", /* 263 */ - (char *) "NL", /* 264 */ - (char *) "ARRAY", /* 265 */ - (char *) "MATCH", /* 266 */ - (char *) "NOTMATCH", /* 267 */ - (char *) "MATCHOP", /* 268 */ - (char *) "FINAL", /* 269 */ - (char *) "DOT", /* 270 */ - (char *) "ALL", /* 271 */ - (char *) "CCL", /* 272 */ - (char *) "NCCL", /* 273 */ - (char *) "CHAR", /* 274 */ - (char *) "OR", /* 275 */ - (char *) "STAR", /* 276 */ - (char *) "QUEST", /* 277 */ - (char *) "PLUS", /* 278 */ - (char *) "EMPTYRE", /* 279 */ - (char *) "AND", /* 280 */ - (char *) "BOR", /* 281 */ - (char *) "APPEND", /* 282 */ - (char *) "EQ", /* 283 */ - (char *) "GE", /* 284 */ - (char *) "GT", /* 285 */ - (char *) "LE", /* 286 */ - (char *) "LT", /* 287 */ - (char *) "NE", /* 288 */ - (char *) "IN", /* 289 */ - (char *) "ARG", /* 290 */ - (char *) "BLTIN", /* 291 */ - (char *) "BREAK", /* 292 */ - (char *) "CLOSE", /* 293 */ - (char *) "CONTINUE", /* 294 */ - (char *) "DELETE", /* 295 */ - (char *) "DO", /* 296 */ - (char *) "EXIT", /* 297 */ - (char *) "FOR", /* 298 */ - (char *) "FUNC", /* 299 */ - (char *) "SUB", /* 300 */ - (char *) "GSUB", /* 301 */ - (char *) "IF", /* 302 */ - (char *) "INDEX", /* 303 */ - (char *) "LSUBSTR", /* 304 */ - (char *) "MATCHFCN", /* 305 */ - (char *) "NEXT", /* 306 */ - (char *) "NEXTFILE", /* 307 */ - (char *) "ADD", /* 308 */ - (char *) "MINUS", /* 309 */ - (char *) "MULT", /* 310 */ - (char *) "DIVIDE", /* 311 */ - (char *) "MOD", /* 312 */ - (char *) "ASSIGN", /* 313 */ - (char *) "ASGNOP", /* 314 */ - (char *) "ADDEQ", /* 315 */ - (char *) "SUBEQ", /* 316 */ - (char *) "MULTEQ", /* 317 */ - (char *) "DIVEQ", /* 318 */ - (char *) "MODEQ", /* 319 */ - (char *) "POWEQ", /* 320 */ - (char *) "PRINT", /* 321 */ - (char *) "PRINTF", /* 322 */ - (char *) "SPRINTF", /* 323 */ - (char *) "ELSE", /* 324 */ - (char *) "INTEST", /* 325 */ - (char *) "CONDEXPR", /* 326 */ - (char *) "POSTINCR", /* 327 */ - (char *) "PREINCR", /* 328 */ - (char *) "POSTDECR", /* 329 */ - (char *) "PREDECR", /* 330 */ - (char *) "VAR", /* 331 */ - (char *) "IVAR", /* 332 */ - (char *) "VARNF", /* 333 */ - (char *) "CALL", /* 334 */ - (char *) "NUMBER", /* 335 */ - (char *) "STRING", /* 336 */ - (char *) "REGEXPR", /* 337 */ - (char *) "GETLINE", /* 338 */ - (char *) "SUBSTR", /* 339 */ - (char *) "SPLIT", /* 340 */ - (char *) "RETURN", /* 341 */ - (char *) "WHILE", /* 342 */ - (char *) "CAT", /* 343 */ - (char *) "UMINUS", /* 344 */ - (char *) "NOT", /* 345 */ - (char *) "POWER", /* 346 */ - (char *) "INCR", /* 347 */ - (char *) "DECR", /* 348 */ - (char *) "INDIRECT", /* 349 */ - (char *) "LASTTOKEN", /* 350 */ -}; - - -Cell *(*proctab[93])(Node **, int) = { - nullproc, /* FIRSTTOKEN */ - program, /* PROGRAM */ - pastat, /* PASTAT */ - dopa2, /* PASTAT2 */ - nullproc, /* XBEGIN */ - nullproc, /* XEND */ - nullproc, /* NL */ - array, /* ARRAY */ - matchop, /* MATCH */ - matchop, /* NOTMATCH */ - nullproc, /* MATCHOP */ - nullproc, /* FINAL */ - nullproc, /* DOT */ - nullproc, /* ALL */ - nullproc, /* CCL */ - nullproc, /* NCCL */ - nullproc, /* CHAR */ - nullproc, /* OR */ - nullproc, /* STAR */ - nullproc, /* QUEST */ - nullproc, /* PLUS */ - nullproc, /* EMPTYRE */ - boolop, /* AND */ - boolop, /* BOR */ - nullproc, /* APPEND */ - relop, /* EQ */ - relop, /* GE */ - relop, /* GT */ - relop, /* LE */ - relop, /* LT */ - relop, /* NE */ - instat, /* IN */ - arg, /* ARG */ - bltin, /* BLTIN */ - jump, /* BREAK */ - closefile, /* CLOSE */ - jump, /* CONTINUE */ - awkdelete, /* DELETE */ - dostat, /* DO */ - jump, /* EXIT */ - forstat, /* FOR */ - nullproc, /* FUNC */ - sub, /* SUB */ - gsub, /* GSUB */ - ifstat, /* IF */ - sindex, /* INDEX */ - nullproc, /* LSUBSTR */ - matchop, /* MATCHFCN */ - jump, /* NEXT */ - jump, /* NEXTFILE */ - arith, /* ADD */ - arith, /* MINUS */ - arith, /* MULT */ - arith, /* DIVIDE */ - arith, /* MOD */ - assign, /* ASSIGN */ - nullproc, /* ASGNOP */ - assign, /* ADDEQ */ - assign, /* SUBEQ */ - assign, /* MULTEQ */ - assign, /* DIVEQ */ - assign, /* MODEQ */ - assign, /* POWEQ */ - printstat, /* PRINT */ - awkprintf, /* PRINTF */ - awksprintf, /* SPRINTF */ - nullproc, /* ELSE */ - intest, /* INTEST */ - condexpr, /* CONDEXPR */ - incrdecr, /* POSTINCR */ - incrdecr, /* PREINCR */ - incrdecr, /* POSTDECR */ - incrdecr, /* PREDECR */ - nullproc, /* VAR */ - nullproc, /* IVAR */ - getnf, /* VARNF */ - call, /* CALL */ - nullproc, /* NUMBER */ - nullproc, /* STRING */ - nullproc, /* REGEXPR */ - awkgetline, /* GETLINE */ - substr, /* SUBSTR */ - split, /* SPLIT */ - jump, /* RETURN */ - whilestat, /* WHILE */ - cat, /* CAT */ - arith, /* UMINUS */ - boolop, /* NOT */ - arith, /* POWER */ - nullproc, /* INCR */ - nullproc, /* DECR */ - indirect, /* INDIRECT */ - nullproc, /* LASTTOKEN */ -}; - -char *tokname(int n) -{ - static char buf[100]; - - if (n < FIRSTTOKEN || n > LASTTOKEN) { - sprintf(buf, "token %d", n); - return buf; - } - return printname[n-FIRSTTOKEN]; -} diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c index fcf4886e493e..09216695149c 100644 --- a/lib/libc/net/sctp_sys_calls.c +++ b/lib/libc/net/sctp_sys_calls.c @@ -1,33 +1,35 @@ -/* $KAME: sctp_sys_calls.c,v 1.9 2004/08/17 06:08:53 itojun Exp $ */ - -/* - * Copyright (C) 2002-2007 Cisco Systems Inc, - * All rights reserved. +/*- + * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved. + * Copyright (c) 2008-2011, by Michael Tuexen. 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. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * modification, are permitted provided that the following conditions are met: * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 PROJECT 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. + * a) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * b) 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. + * + * c) Neither the name of Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 __FBSDID("$FreeBSD$"); #include @@ -58,7 +60,6 @@ __FBSDID("$FreeBSD$"); #define SCTP_CONTROL_VEC_SIZE_SND 8192 #define SCTP_CONTROL_VEC_SIZE_RCV 16384 #define SCTP_STACK_BUF_SIZE 2048 -#define SCTP_SMALL_IOVEC_SIZE 2 #ifdef SCTP_DEBUG_PRINT_ADDRESS @@ -398,6 +399,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size) case SCTP_LOCAL_AUTH_CHUNKS: ((struct sctp_authchunks *)arg)->gauth_assoc_id = id; break; + case SCTP_TIMEOUTS: + ((struct sctp_timeouts *)arg)->stimo_assoc_id = id; + break; default: break; } @@ -551,11 +555,10 @@ sctp_sendmsg(int s, return (syscall(SYS_sctp_generic_sendmsg, s, data, len, to, tolen, &sinfo, 0)); #else - ssize_t sz; struct msghdr msg; struct sctp_sndrcvinfo *s_info; - struct iovec iov[SCTP_SMALL_IOVEC_SIZE]; + struct iovec iov; char controlVector[SCTP_CONTROL_VEC_SIZE_RCV]; struct cmsghdr *cmsg; struct sockaddr *who = NULL; @@ -564,20 +567,8 @@ sctp_sendmsg(int s, struct sockaddr_in6 in6; } addr; -/* - fprintf(io, "sctp_sendmsg(sd:%d, data:%x, len:%d, to:%x, tolen:%d, ppid:%x, flags:%x str:%d ttl:%d ctx:%x\n", - s, - (u_int)data, - (int)len, - (u_int)to, - (int)tolen, - ppid, flags, - (int)stream_no, - (int)timetolive, - (u_int)context); - fflush(io); -*/ - if ((tolen > 0) && ((to == NULL) || (tolen < sizeof(struct sockaddr)))) { + if ((tolen > 0) && + ((to == NULL) || (tolen < sizeof(struct sockaddr)))) { errno = EINVAL; return -1; } @@ -587,7 +578,8 @@ sctp_sendmsg(int s, errno = EINVAL; return -1; } - if ((to->sa_len > 0) && (to->sa_len != sizeof(struct sockaddr_in))) { + if ((to->sa_len > 0) && + (to->sa_len != sizeof(struct sockaddr_in))) { errno = EINVAL; return -1; } @@ -598,7 +590,8 @@ sctp_sendmsg(int s, errno = EINVAL; return -1; } - if ((to->sa_len > 0) && (to->sa_len != sizeof(struct sockaddr_in6))) { + if ((to->sa_len > 0) && + (to->sa_len != sizeof(struct sockaddr_in6))) { errno = EINVAL; return -1; } @@ -610,10 +603,8 @@ sctp_sendmsg(int s, } who = (struct sockaddr *)&addr; } - iov[0].iov_base = (char *)data; - iov[0].iov_len = len; - iov[1].iov_base = NULL; - iov[1].iov_len = 0; + iov.iov_base = (char *)data; + iov.iov_len = len; if (who) { msg.msg_name = (caddr_t)who; @@ -622,7 +613,7 @@ sctp_sendmsg(int s, msg.msg_name = (caddr_t)NULL; msg.msg_namelen = 0; } - msg.msg_iov = iov; + msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = (caddr_t)controlVector; @@ -681,7 +672,7 @@ sctp_send(int sd, const void *data, size_t len, #else ssize_t sz; struct msghdr msg; - struct iovec iov[SCTP_SMALL_IOVEC_SIZE]; + struct iovec iov; struct sctp_sndrcvinfo *s_info; char controlVector[SCTP_CONTROL_VEC_SIZE_SND]; struct cmsghdr *cmsg; @@ -690,14 +681,12 @@ sctp_send(int sd, const void *data, size_t len, errno = EINVAL; return (-1); } - iov[0].iov_base = (char *)data; - iov[0].iov_len = len; - iov[1].iov_base = NULL; - iov[1].iov_len = 0; + iov.iov_base = (char *)data; + iov.iov_len = len; msg.msg_name = 0; msg.msg_namelen = 0; - msg.msg_iov = iov; + msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = (caddr_t)controlVector; @@ -736,7 +725,7 @@ sctp_sendx(int sd, const void *msg, size_t msg_len, return (-1); } #ifdef SYS_sctp_generic_sendmsg - if (addrcnt < SCTP_SMALL_IOVEC_SIZE) { + if (addrcnt == 1) { socklen_t l; /* @@ -846,18 +835,18 @@ sctp_recvmsg(int s, int *msg_flags) { #ifdef SYS_sctp_generic_recvmsg - struct iovec iov[SCTP_SMALL_IOVEC_SIZE]; + struct iovec iov; - iov[0].iov_base = dbuf; - iov[0].iov_len = len; + iov.iov_base = dbuf; + iov.iov_len = len; return (syscall(SYS_sctp_generic_recvmsg, s, - iov, 1, from, fromlen, sinfo, msg_flags)); + &iov, 1, from, fromlen, sinfo, msg_flags)); #else struct sctp_sndrcvinfo *s_info; ssize_t sz; int sinfo_found = 0; struct msghdr msg; - struct iovec iov[SCTP_SMALL_IOVEC_SIZE]; + struct iovec iov; char controlVector[SCTP_CONTROL_VEC_SIZE_RCV]; struct cmsghdr *cmsg; @@ -866,30 +855,28 @@ sctp_recvmsg(int s, return (-1); } msg.msg_flags = 0; - iov[0].iov_base = dbuf; - iov[0].iov_len = len; - iov[1].iov_base = NULL; - iov[1].iov_len = 0; + iov.iov_base = dbuf; + iov.iov_len = len; msg.msg_name = (caddr_t)from; if (fromlen == NULL) msg.msg_namelen = 0; else msg.msg_namelen = *fromlen; - msg.msg_iov = iov; + msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = (caddr_t)controlVector; msg.msg_controllen = sizeof(controlVector); errno = 0; sz = recvmsg(s, &msg, *msg_flags); - if (sz <= 0) + *msg_flags = msg.msg_flags; + if (sz <= 0) { return (sz); - + } s_info = NULL; len = sz; - *msg_flags = msg.msg_flags; - if (sinfo) + if (sinfo) { sinfo->sinfo_assoc_id = 0; - + } if ((msg.msg_controllen) && sinfo) { /* * parse through and see if we find the sctp_sndrcvinfo (if @@ -940,7 +927,7 @@ int sctp_peeloff(int sd, sctp_assoc_t assoc_id) { struct sctp_peeloff_opt peeloff; - int error; + int result; socklen_t optlen; /* set in the socket option params */ @@ -948,10 +935,9 @@ sctp_peeloff(int sd, sctp_assoc_t assoc_id) peeloff.s = sd; peeloff.assoc_id = assoc_id; optlen = sizeof(peeloff); - error = getsockopt(sd, IPPROTO_SCTP, SCTP_PEELOFF, (void *)&peeloff, - &optlen); - if (error) { - errno = error; + result = getsockopt(sd, IPPROTO_SCTP, SCTP_PEELOFF, (void *)&peeloff, &optlen); + + if (result < 0) { return (-1); } else { return (peeloff.new_sd); @@ -984,4 +970,3 @@ sctp_peeloff(int sd, sctp_assoc_t assoc_id) #undef SCTP_CONTROL_VEC_SIZE_SND #undef SCTP_CONTROL_VEC_SIZE_RCV #undef SCTP_STACK_BUF_SIZE -#undef SCTP_SMALL_IOVEC_SIZE diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h index 5dca37c3aa9f..f39e4f591dfe 100644 --- a/lib/libutil/libutil.h +++ b/lib/libutil/libutil.h @@ -41,22 +41,13 @@ #include #include +#include #ifndef _GID_T_DECLARED typedef __gid_t gid_t; #define _GID_T_DECLARED #endif -#ifndef _INT64_T_DECLARED -typedef __int64_t int64_t; -#define _INT64_T_DECLARED -#endif - -#ifndef _UINT64_T_DECLARED -typedef __uint64_t uint64_t; -#define _UINT64_T_DECLARED -#endif - #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh index 384f44fb6b3d..74a34a93221e 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -23,7 +23,6 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. -publisher="The FreeBSD Project. http://www.freebsd.org/" if [ "x$1" = "x-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot" diff --git a/release/generate-release.sh b/release/generate-release.sh index e29aabbad72f..62d052813f55 100755 --- a/release/generate-release.sh +++ b/release/generate-release.sh @@ -21,7 +21,9 @@ # mkdir -p $2/usr/src -svn co ${SVNROOT:-svn://svn.freebsd.org/base}/$1 $2/usr/src || exit 1 +set -e # Everything must succeed + +svn co ${SVNROOT:-svn://svn.freebsd.org/base}/$1 $2/usr/src if [ ! -z $CVSUP_HOST ]; then cat > $2/docports-supfile << EOF *default host=$CVSUP_HOST @@ -35,32 +37,33 @@ if [ ! -z $CVSUP_HOST ]; then EOF elif [ ! -z $CVSROOT ]; then cd $2/usr - cvs -R ${CVSARGS} -d ${CVSROOT} co -P -r ${CVS_TAG:-HEAD} ports || exit 1 - cvs -R ${CVSARGS} -d ${CVSROOT} co -P -r ${CVS_TAG:-HEAD} doc || exit 1 + cvs -R ${CVSARGS} -d ${CVSROOT} co -P -r ${CVS_TAG:-HEAD} ports + cvs -R ${CVSARGS} -d ${CVSROOT} co -P -r ${CVS_TAG:-HEAD} doc fi cd $2/usr/src -make $MAKE_FLAGS buildworld || exit 1 -make installworld distribution DESTDIR=$2 || exit 1 +make $MAKE_FLAGS buildworld +make installworld distribution DESTDIR=$2 mount -t devfs devfs $2/dev +trap "umount $2/dev" EXIT # Clean up devfs mount on exit if [ ! -z $CVSUP_HOST ]; then cp /etc/resolv.conf $2/etc/resolv.conf # Checkout ports and doc trees - chroot $2 /usr/bin/csup /docports-supfile || exit 1 + chroot $2 /usr/bin/csup /docports-supfile fi if [ -d $2/usr/doc ]; then cp /etc/resolv.conf $2/etc/resolv.conf # Build ports to build the docs, then build the docs - chroot $2 /bin/sh -c 'pkg_add -r docproj || (cd /usr/ports/textproc/docproj && make install clean BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes)' || exit 1 - chroot $2 /bin/sh -c "cd /usr/doc && make $MAKE_FLAGS 'FORMATS=html html-split txt' URLS_ABSOLUTE=YES" || exit 1 + chroot $2 /bin/sh -c 'pkg_add -r docproj || (cd /usr/ports/textproc/docproj && make install clean BATCH=yes WITHOUT_X11=yes JADETEX=no WITHOUT_PYTHON=yes)' + chroot $2 make -C /usr/doc $MAKE_FLAGS 'FORMATS=html html-split txt' URLS_ABSOLUTE=YES fi -chroot $2 /bin/sh -c "cd /usr/src && make $MAKE_FLAGS buildworld buildkernel" || exit 1 -chroot $2 /bin/sh -c "cd /usr/src/release && make obj" || exit 1 -chroot $2 /bin/sh -c "cd /usr/src/release && make release" || exit 1 -chroot $2 /bin/sh -c "cd /usr/src/release && make install DESTDIR=/R" || exit 1 +chroot $2 make -C /usr/src $MAKE_FLAGS buildworld buildkernel +chroot $2 make -C /usr/src/release obj +chroot $2 make -C /usr/src/release release +chroot $2 make -C /usr/src/release install DESTDIR=/R diff --git a/release/i386/mkisoimages.sh b/release/i386/mkisoimages.sh index 384f44fb6b3d..74a34a93221e 100644 --- a/release/i386/mkisoimages.sh +++ b/release/i386/mkisoimages.sh @@ -23,7 +23,6 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. -publisher="The FreeBSD Project. http://www.freebsd.org/" if [ "x$1" = "x-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o bootimage=i386;$4/boot/cdboot -o no-emul-boot" diff --git a/release/ia64/mkisoimages.sh b/release/ia64/mkisoimages.sh index edb4bc39adb3..33ba1927ad61 100644 --- a/release/ia64/mkisoimages.sh +++ b/release/ia64/mkisoimages.sh @@ -41,27 +41,6 @@ LABEL=$1; shift NAME=$1; shift BASE=$1; shift -MKISOFS=mkisofs -MKISOFS_PKG=cdrtools -MKISOFS_PORT=/usr/ports/sysutils/${MKISOFS_PKG} - -if ! which ${MKISOFS} > /dev/null; then - echo -n "${MKISOFS}(8) does not exist: " - if [ -f ${MKISOFS_PORT}/Makefile ]; then - echo building the port... - if ! (cd ${MKISOFS_PORT} && make install BATCH=yes && make clean); then - echo "error: cannot build ${MKISOFS}(8). Bailing out..." - exit 2 - fi - else - echo fetching the package... - if ! pkg_add -r ${MKISOFS_PKG}; then - echo "error: cannot fetch ${MKISOFS}(8). Bailing out..." - exit 2 - fi - fi -fi - EFIPART=efipart.sys # To create a bootable CD under EFI, the boot image should be an EFI @@ -84,15 +63,13 @@ if [ $bootable = yes ]; then mv $MNT/boot/loader.efi $MNT/efi/boot/bootia64.efi umount $MNT mdconfig -d -u $md - BOOTOPTS="-b $EFIPART -no-emul-boot" + BOOTOPTS="-b bootimage=i386;$EFIPART -o no-emul-boot" else BOOTOPTS="" fi -publisher="The FreeBSD Project. http://www.freebsd.org/" - echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab -$MKISOFS $BOOTOPTS -r -J -V $LABEL -publisher "$publisher" -o $NAME $BASE $* +makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL $NAME $BASE $* rm -f $BASE/$EFIPART rm $1/etc/fstab exit 0 diff --git a/release/pc98/mkisoimages.sh b/release/pc98/mkisoimages.sh index 45b4c7c94475..313641be4f89 100644 --- a/release/pc98/mkisoimages.sh +++ b/release/pc98/mkisoimages.sh @@ -23,7 +23,6 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. -publisher="The FreeBSD Project. http://www.freebsd.org/" if [ "x$1" = "x-b" ]; then # This is highly x86-centric and will be used directly below. bootable="-o generic-bootimage=$4/boot/cdboot" diff --git a/release/powerpc/mkisoimages.sh b/release/powerpc/mkisoimages.sh index 52c3b08b6f77..5c4b0df391f2 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -23,13 +23,11 @@ # extra-bits-dir, if provided, contains additional files to be merged # into base-bits-dir as part of making the image. -publisher="The FreeBSD Project. http://www.freebsd.org/" if [ "x$1" = "x-b" ]; then uudecode -o /tmp/hfs-boot-block.bz2 `dirname $0`/hfs-boot.bz2.uu bzip2 -d /tmp/hfs-boot-block.bz2 OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ') OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}') - echo dd if=$4/boot/loader of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc dd if=$4/boot/loader of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot" diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 1a5514fb0ca2..f71da84d7716 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -134,6 +134,7 @@ MAN= aac.4 \ geom.4 \ geom_fox.4 \ geom_linux_lvm.4 \ + geom_map.4 \ geom_uzip.4 \ gif.4 \ gpib.4 \ diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 8385c504de78..50edf73b6791 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -781,6 +781,7 @@ MLINKS+=make_dev.9 destroy_dev.9 \ make_dev.9 destroy_dev_sched_cb.9 \ make_dev.9 dev_depends.9 \ make_dev.9 make_dev_alias.9 \ + make_dev.9 make_dev_alias_p.9 \ make_dev.9 make_dev_cred.9 \ make_dev.9 make_dev_credf.9 \ make_dev.9 make_dev_p.9 diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 57e91a8444cc..9e20f95d1d14 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -177,11 +177,34 @@ mem_range_AP_init(void) static void topo_probe_amd(void) { + int core_id_bits; + int id; /* AMD processors do not support HTT. */ - cpu_cores = (amd_feature2 & AMDID2_CMP) != 0 ? - (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1; cpu_logical = 1; + + if ((amd_feature2 & AMDID2_CMP) == 0) { + cpu_cores = 1; + return; + } + + core_id_bits = (cpu_procinfo2 & AMDID_COREID_SIZE) >> + AMDID_COREID_SIZE_SHIFT; + if (core_id_bits == 0) { + cpu_cores = (cpu_procinfo2 & AMDID_CMP_CORES) + 1; + return; + } + + /* Fam 10h and newer should get here. */ + for (id = 0; id <= MAX_APIC_ID; id++) { + /* Check logical CPU availability. */ + if (!cpu_info[id].cpu_present || cpu_info[id].cpu_disabled) + continue; + /* Check if logical CPU has the same package ID. */ + if ((id >> core_id_bits) != (boot_cpu_id >> core_id_bits)) + continue; + cpu_cores++; + } } /* diff --git a/sys/amd64/include/specialreg.h b/sys/amd64/include/specialreg.h index 9428dd906125..ac5206358b5e 100644 --- a/sys/amd64/include/specialreg.h +++ b/sys/amd64/include/specialreg.h @@ -228,6 +228,8 @@ * AMD extended function 8000_0008h ecx info */ #define AMDID_CMP_CORES 0x000000ff +#define AMDID_COREID_SIZE 0x0000f000 +#define AMDID_COREID_SIZE_SHIFT 12 /* * CPUID manufacturers identifiers diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 6dc27d2dd410..9568c1c10991 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -43,7 +43,8 @@ CFLAGS= -Os \ -Winline --param max-inline-insns-single=100 .if ${CC:T:Mclang} == "clang" -CFLAGS+= -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 +CFLAGS+= -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 \ + -mllvm -enable-load-pre=false # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS+= ${.IMPSRC:T:Mboot1.S:C/^.+$/-no-integrated-as/} .endif diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index b4d0652a90d3..f26bf3b497a2 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -184,6 +184,7 @@ static struct { {0x91201b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_NOBSYRES}, {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_NOBSYRES}, {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_SATA2|AHCI_Q_NOBSYRES}, + {0x91821b4b, 0x00, "Marvell 88SE9182", AHCI_Q_NOBSYRES}, {0x06201103, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, {0x06201b4b, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, {0x06221103, 0x00, "HighPoint RocketRAID 622", AHCI_Q_NOBSYRES}, diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index 38a346e2ee1a..3738aaf6cd12 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -199,6 +199,7 @@ extern HAL_STATUS ar5416GetCapability(struct ath_hal *ah, extern HAL_BOOL ar5416GetDiagState(struct ath_hal *ah, int request, const void *args, uint32_t argsize, void **result, uint32_t *resultsize); +extern HAL_BOOL ar5416SetRifsDelay(struct ath_hal *ah, HAL_BOOL enable); extern HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c b/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c index aa31824a0624..087bf92c789f 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c @@ -368,6 +368,25 @@ typedef struct { uint8_t qcu_complete_state; } hal_mac_hang_check_t; +HAL_BOOL +ar5416SetRifsDelay(struct ath_hal *ah, HAL_BOOL enable) +{ + uint32_t val; + + /* Only support disabling RIFS delay for now */ + HALASSERT(enable == AH_FALSE); + + if (enable == AH_TRUE) + return AH_FALSE; + + /* Change RIFS init delay to 0 */ + val = OS_REG_READ(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS); + val &= ~AR_PHY_RIFS_INIT_DELAY; + OS_REG_WRITE(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS, val); + + return AH_TRUE; +} + static HAL_BOOL ar5416CompareDbgHang(struct ath_hal *ah, const mac_dbg_regs_t *regs, const hal_mac_hang_check_t *check) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index 4917caac1a77..12f30f1c8361 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -2520,11 +2520,8 @@ ar5416OverrideIni(struct ath_hal *ah, const struct ieee80211_channel *chan) * Disable RIFS search on some chips to avoid baseband * hang issues. */ - if (AR_SREV_HOWL(ah) || AR_SREV_SOWL(ah)) { - val = OS_REG_READ(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS); - val &= ~AR_PHY_RIFS_INIT_DELAY; - OS_REG_WRITE(ah, AR_PHY_HEAVY_CLIP_FACTOR_RIFS, val); - } + if (AR_SREV_HOWL(ah) || AR_SREV_SOWL(ah)) + (void) ar5416SetRifsDelay(ah, AH_FALSE); } struct ini { diff --git a/sys/dev/bm/if_bm.c b/sys/dev/bm/if_bm.c index ded2b42f6f3f..481d7cb5a900 100644 --- a/sys/dev/bm/if_bm.c +++ b/sys/dev/bm/if_bm.c @@ -558,6 +558,7 @@ bm_attach(device_t dev) } /* alloc interrupt */ + bm_disable_interrupts(sc); sc->sc_txdmairqid = BM_TXDMA_INTERRUPT; sc->sc_txdmairq = bus_alloc_resource_any(dev, SYS_RES_IRQ, @@ -591,9 +592,6 @@ bm_attach(device_t dev) eaddr = sc->sc_enaddr; OF_getprop(node, "local-mac-address", eaddr, ETHER_ADDR_LEN); - /* reset the adapter */ - bm_chip_setup(sc); - /* * Setup MII * On Apple BMAC controllers, we end up in a weird state of @@ -608,6 +606,9 @@ bm_attach(device_t dev) return (error); } + /* reset the adapter */ + bm_chip_setup(sc); + sc->sc_mii = device_get_softc(sc->sc_miibus); if_initname(ifp, device_get_name(sc->sc_dev), @@ -1129,31 +1130,26 @@ bm_chip_setup(struct bm_softc *sc) { uint16_t reg; uint16_t *eaddr_sect; - char path[128]; - ihandle_t bmac_ih; + struct mii_data *mii; + struct mii_softc *miisc; eaddr_sect = (uint16_t *)(sc->sc_enaddr); + dbdma_stop(sc->sc_txdma); + dbdma_stop(sc->sc_rxdma); - /* - * Enable BMAC cell by opening and closing its OF node. This enables - * the cell in macio as a side effect. We should probably directly - * twiddle the FCR bits, but we lack a good interface for this at the - * present time. - */ - - OF_package_to_path(ofw_bus_get_node(sc->sc_dev), path, sizeof(path)); - bmac_ih = OF_open(path); - if (bmac_ih == -1) { - device_printf(sc->sc_dev, - "Enabling BMAC cell failed! Hoping it's already active.\n"); - } else { - OF_close(bmac_ih); + /* Reset MII */ + mii = device_get_softc(sc->sc_miibus); + LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { + PHY_RESET(miisc); + PHY_WRITE(miisc, MII_BMCR, PHY_READ(miisc, MII_BMCR) & + ~BMCR_ISO); } /* Reset chip */ CSR_WRITE_2(sc, BM_RX_RESET, 0x0000); CSR_WRITE_2(sc, BM_TX_RESET, 0x0001); do { + DELAY(10); reg = CSR_READ_2(sc, BM_TX_RESET); } while (reg & 0x0001); diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c index 777a591e5f8c..411b9eecf167 100644 --- a/sys/dev/coretemp/coretemp.c +++ b/sys/dev/coretemp/coretemp.c @@ -197,6 +197,15 @@ coretemp_attach(device_t dev) default: /* Unknown stepping */ break; } + } else if (cpu_model == 0x1c) { + switch (cpu_stepping) { + case 0xa: /* 45nm Atom D400, N400 and D500 series */ + sc->sc_tjmax = 100; + break; + default: + sc->sc_tjmax = 90; + break; + } } else { /* * Attempt to get Tj(max) from MSR IA32_TEMPERATURE_TARGET. diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 9037318a13da..929f31b06dee 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -415,7 +415,7 @@ t4_attach(device_t dev) /* These are total (sum of all ports) limits for a bus driver */ rc = -t4_cfg_pfvf(sc, sc->mbox, sc->pf, 0, - 64, /* max # of egress queues */ + 128, /* max # of egress queues */ 64, /* max # of egress Ethernet or control queues */ 64, /* max # of ingress queues with fl/interrupt */ 0, /* max # of ingress queues without interrupt */ diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index fb6ed6743917..156f8b23003d 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -3901,7 +3901,7 @@ em_setup_receive_ring(struct rx_ring *rxr) struct adapter *adapter = rxr->adapter; struct em_buffer *rxbuf; bus_dma_segment_t seg[1]; - int i, j, nsegs, error; + int i, j, nsegs, error = 0; /* Clear the ring contents */ @@ -3919,7 +3919,7 @@ em_setup_receive_ring(struct rx_ring *rxr) if (++j == adapter->num_rx_desc) j = 0; - while(j != rxr->next_to_check) { + while (j != rxr->next_to_check) { rxbuf = &rxr->rx_buffers[i]; rxbuf->m_head = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, adapter->rx_mbuf_sz); diff --git a/sys/dev/xl/if_xl.c b/sys/dev/xl/if_xl.c index 1db6ece71f98..004b511e1129 100644 --- a/sys/dev/xl/if_xl.c +++ b/sys/dev/xl/if_xl.c @@ -263,10 +263,11 @@ static void xl_mii_send(struct xl_softc *, u_int32_t, int); static int xl_mii_readreg(struct xl_softc *, struct xl_mii_frame *); static int xl_mii_writereg(struct xl_softc *, struct xl_mii_frame *); +static void xl_rxfilter(struct xl_softc *); +static void xl_rxfilter_90x(struct xl_softc *); +static void xl_rxfilter_90xB(struct xl_softc *); static void xl_setcfg(struct xl_softc *); static void xl_setmode(struct xl_softc *, int); -static void xl_setmulti(struct xl_softc *); -static void xl_setmulti_hash(struct xl_softc *); static void xl_reset(struct xl_softc *); static int xl_list_rx_init(struct xl_softc *); static int xl_list_tx_init(struct xl_softc *); @@ -701,101 +702,133 @@ xl_read_eeprom(struct xl_softc *sc, caddr_t dest, int off, int cnt, int swap) return (err ? 1 : 0); } +static void +xl_rxfilter(struct xl_softc *sc) +{ + + if (sc->xl_type == XL_TYPE_905B) + xl_rxfilter_90xB(sc); + else + xl_rxfilter_90x(sc); +} + /* * NICs older than the 3c905B have only one multicast option, which * is to enable reception of all multicast frames. */ static void -xl_setmulti(struct xl_softc *sc) +xl_rxfilter_90x(struct xl_softc *sc) { - struct ifnet *ifp = sc->xl_ifp; + struct ifnet *ifp; struct ifmultiaddr *ifma; u_int8_t rxfilt; - int mcnt = 0; XL_LOCK_ASSERT(sc); + ifp = sc->xl_ifp; + XL_SEL_WIN(5); rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER); + rxfilt &= ~(XL_RXFILTER_ALLFRAMES | XL_RXFILTER_ALLMULTI | + XL_RXFILTER_BROADCAST | XL_RXFILTER_INDIVIDUAL); - if (ifp->if_flags & IFF_ALLMULTI) { - rxfilt |= XL_RXFILTER_ALLMULTI; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - return; + /* Set the individual bit to receive frames for this host only. */ + rxfilt |= XL_RXFILTER_INDIVIDUAL; + /* Set capture broadcast bit to capture broadcast frames. */ + if (ifp->if_flags & IFF_BROADCAST) + rxfilt |= XL_RXFILTER_BROADCAST; + + /* If we want promiscuous mode, set the allframes bit. */ + if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) { + if (ifp->if_flags & IFF_PROMISC) + rxfilt |= XL_RXFILTER_ALLFRAMES; + if (ifp->if_flags & IFF_ALLMULTI) + rxfilt |= XL_RXFILTER_ALLMULTI; + } else { + if_maddr_rlock(ifp); + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + rxfilt |= XL_RXFILTER_ALLMULTI; + break; + } + if_maddr_runlock(ifp); } - if_maddr_rlock(ifp); - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) - mcnt++; - if_maddr_runlock(ifp); - - if (mcnt) - rxfilt |= XL_RXFILTER_ALLMULTI; - else - rxfilt &= ~XL_RXFILTER_ALLMULTI; - - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); + CSR_WRITE_2(sc, XL_COMMAND, rxfilt | XL_CMD_RX_SET_FILT); + XL_SEL_WIN(7); } /* * 3c905B adapters have a hash filter that we can program. */ static void -xl_setmulti_hash(struct xl_softc *sc) +xl_rxfilter_90xB(struct xl_softc *sc) { - struct ifnet *ifp = sc->xl_ifp; - int h = 0, i; + struct ifnet *ifp; struct ifmultiaddr *ifma; + int i, mcnt; + u_int16_t h; u_int8_t rxfilt; - int mcnt = 0; XL_LOCK_ASSERT(sc); + ifp = sc->xl_ifp; + XL_SEL_WIN(5); rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER); + rxfilt &= ~(XL_RXFILTER_ALLFRAMES | XL_RXFILTER_ALLMULTI | + XL_RXFILTER_BROADCAST | XL_RXFILTER_INDIVIDUAL | + XL_RXFILTER_MULTIHASH); - if (ifp->if_flags & IFF_ALLMULTI) { - rxfilt |= XL_RXFILTER_ALLMULTI; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - return; - } else - rxfilt &= ~XL_RXFILTER_ALLMULTI; + /* Set the individual bit to receive frames for this host only. */ + rxfilt |= XL_RXFILTER_INDIVIDUAL; + /* Set capture broadcast bit to capture broadcast frames. */ + if (ifp->if_flags & IFF_BROADCAST) + rxfilt |= XL_RXFILTER_BROADCAST; - /* first, zot all the existing hash bits */ - for (i = 0; i < XL_HASHFILT_SIZE; i++) - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|i); + /* If we want promiscuous mode, set the allframes bit. */ + if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) { + if (ifp->if_flags & IFF_PROMISC) + rxfilt |= XL_RXFILTER_ALLFRAMES; + if (ifp->if_flags & IFF_ALLMULTI) + rxfilt |= XL_RXFILTER_ALLMULTI; + } else { + /* First, zot all the existing hash bits. */ + for (i = 0; i < XL_HASHFILT_SIZE; i++) + CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH | i); - /* now program new ones */ - if_maddr_rlock(ifp); - TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - /* - * Note: the 3c905B currently only supports a 64-bit hash - * table, which means we really only need 6 bits, but the - * manual indicates that future chip revisions will have a - * 256-bit hash table, hence the routine is set up to - * calculate 8 bits of position info in case we need it some - * day. - * Note II, The Sequel: _CURRENT_ versions of the 3c905B have - * a 256 bit hash table. This means we have to use all 8 bits - * regardless. On older cards, the upper 2 bits will be - * ignored. Grrrr.... - */ - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF; - CSR_WRITE_2(sc, XL_COMMAND, - h | XL_CMD_RX_SET_HASH | XL_HASH_SET); - mcnt++; + /* Now program new ones. */ + mcnt = 0; + if_maddr_rlock(ifp); + TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { + if (ifma->ifma_addr->sa_family != AF_LINK) + continue; + /* + * Note: the 3c905B currently only supports a 64-bit + * hash table, which means we really only need 6 bits, + * but the manual indicates that future chip revisions + * will have a 256-bit hash table, hence the routine + * is set up to calculate 8 bits of position info in + * case we need it some day. + * Note II, The Sequel: _CURRENT_ versions of the + * 3c905B have a 256 bit hash table. This means we have + * to use all 8 bits regardless. On older cards, the + * upper 2 bits will be ignored. Grrrr.... + */ + h = ether_crc32_be(LLADDR((struct sockaddr_dl *) + ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF; + CSR_WRITE_2(sc, XL_COMMAND, + h | XL_CMD_RX_SET_HASH | XL_HASH_SET); + mcnt++; + } + if_maddr_runlock(ifp); + if (mcnt > 0) + rxfilt |= XL_RXFILTER_MULTIHASH; } - if_maddr_runlock(ifp); - - if (mcnt) - rxfilt |= XL_RXFILTER_MULTIHASH; - else - rxfilt &= ~XL_RXFILTER_MULTIHASH; CSR_WRITE_2(sc, XL_COMMAND, rxfilt | XL_CMD_RX_SET_FILT); + XL_SEL_WIN(7); } static void @@ -2485,8 +2518,7 @@ xl_encap(struct xl_softc *sc, struct xl_chain *c, struct mbuf **m_head) htole32(sc->xl_cdata.xl_tx_segs[i].ds_len); total_len += sc->xl_cdata.xl_tx_segs[i].ds_len; } - c->xl_ptr->xl_frag[nseg - 1].xl_len = - htole32(sc->xl_cdata.xl_tx_segs[nseg - 1].ds_len | XL_LAST_FRAG); + c->xl_ptr->xl_frag[nseg - 1].xl_len |= htole32(XL_LAST_FRAG); c->xl_ptr->xl_status = htole32(total_len); c->xl_ptr->xl_next = 0; @@ -2611,8 +2643,7 @@ xl_start_locked(struct ifnet *ifp) * get an interrupt once for the whole chain rather than * once for each packet. */ - cur_tx->xl_ptr->xl_status = htole32(le32toh(cur_tx->xl_ptr->xl_status) | - XL_TXSTAT_DL_INTR); + cur_tx->xl_ptr->xl_status |= htole32(XL_TXSTAT_DL_INTR); bus_dmamap_sync(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_dmamap, BUS_DMASYNC_PREWRITE); @@ -2628,8 +2659,8 @@ xl_start_locked(struct ifnet *ifp) sc->xl_cdata.xl_tx_tail->xl_ptr->xl_next = htole32(start_tx->xl_phys); status = sc->xl_cdata.xl_tx_tail->xl_ptr->xl_status; - sc->xl_cdata.xl_tx_tail->xl_ptr->xl_status = - htole32(le32toh(status) & ~XL_TXSTAT_DL_INTR); + sc->xl_cdata.xl_tx_tail->xl_ptr->xl_status &= + htole32(~XL_TXSTAT_DL_INTR); sc->xl_cdata.xl_tx_tail = cur_tx; } else { sc->xl_cdata.xl_tx_head = start_tx; @@ -2733,8 +2764,7 @@ xl_start_90xB_locked(struct ifnet *ifp) * get an interrupt once for the whole chain rather than * once for each packet. */ - cur_tx->xl_ptr->xl_status = htole32(le32toh(cur_tx->xl_ptr->xl_status) | - XL_TXSTAT_DL_INTR); + cur_tx->xl_ptr->xl_status |= htole32(XL_TXSTAT_DL_INTR); bus_dmamap_sync(sc->xl_ldata.xl_tx_tag, sc->xl_ldata.xl_tx_dmamap, BUS_DMASYNC_PREWRITE); @@ -2763,7 +2793,6 @@ xl_init_locked(struct xl_softc *sc) { struct ifnet *ifp = sc->xl_ifp; int error, i; - u_int16_t rxfilt = 0; struct mii_data *mii = NULL; XL_LOCK_ASSERT(sc); @@ -2862,39 +2891,7 @@ xl_init_locked(struct xl_softc *sc) } /* Set RX filter bits. */ - XL_SEL_WIN(5); - rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER); - - /* Set the individual bit to receive frames for this host only. */ - rxfilt |= XL_RXFILTER_INDIVIDUAL; - - /* If we want promiscuous mode, set the allframes bit. */ - if (ifp->if_flags & IFF_PROMISC) { - rxfilt |= XL_RXFILTER_ALLFRAMES; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - } else { - rxfilt &= ~XL_RXFILTER_ALLFRAMES; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - } - - /* - * Set capture broadcast bit to capture broadcast frames. - */ - if (ifp->if_flags & IFF_BROADCAST) { - rxfilt |= XL_RXFILTER_BROADCAST; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - } else { - rxfilt &= ~XL_RXFILTER_BROADCAST; - CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_FILT|rxfilt); - } - - /* - * Program the multicast filter, if necessary. - */ - if (sc->xl_type == XL_TYPE_905B) - xl_setmulti_hash(sc); - else - xl_setmulti(sc); + xl_rxfilter(sc); /* * Load the address of the RX list. We have to @@ -3123,30 +3120,16 @@ xl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct ifreq *ifr = (struct ifreq *) data; int error = 0, mask; struct mii_data *mii = NULL; - u_int8_t rxfilt; switch (command) { case SIOCSIFFLAGS: XL_LOCK(sc); - - XL_SEL_WIN(5); - rxfilt = CSR_READ_1(sc, XL_W5_RX_FILTER); if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING && - ifp->if_flags & IFF_PROMISC && - !(sc->xl_if_flags & IFF_PROMISC)) { - rxfilt |= XL_RXFILTER_ALLFRAMES; - CSR_WRITE_2(sc, XL_COMMAND, - XL_CMD_RX_SET_FILT|rxfilt); - XL_SEL_WIN(7); - } else if (ifp->if_drv_flags & IFF_DRV_RUNNING && - !(ifp->if_flags & IFF_PROMISC) && - sc->xl_if_flags & IFF_PROMISC) { - rxfilt &= ~XL_RXFILTER_ALLFRAMES; - CSR_WRITE_2(sc, XL_COMMAND, - XL_CMD_RX_SET_FILT|rxfilt); - XL_SEL_WIN(7); - } else + (ifp->if_flags ^ sc->xl_if_flags) & + (IFF_PROMISC | IFF_ALLMULTI)) + xl_rxfilter(sc); + else xl_init_locked(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) @@ -3154,18 +3137,14 @@ xl_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } sc->xl_if_flags = ifp->if_flags; XL_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: /* XXX Downcall from if_addmulti() possibly with locks held. */ XL_LOCK(sc); - if (sc->xl_type == XL_TYPE_905B) - xl_setmulti_hash(sc); - else - xl_setmulti(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + xl_rxfilter(sc); XL_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: diff --git a/sys/fs/nfs/nfs.h b/sys/fs/nfs/nfs.h index 0bf0f74d716b..c8bb0d6957cd 100644 --- a/sys/fs/nfs/nfs.h +++ b/sys/fs/nfs/nfs.h @@ -39,7 +39,7 @@ */ #define NFS_MAXIOVEC 34 -#define NFS_TICKINTVL 10 /* Desired time for a tick (msec) */ +#define NFS_TICKINTVL 500 /* Desired time for a tick (msec) */ #define NFS_HZ (hz / nfscl_ticks) /* Ticks/sec */ #define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */ #define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */ diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 8b4fc6aee8b4..b11160be6fcd 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -1224,7 +1224,7 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, if ((argp->flags & (NFSMNT_NFSV3 | NFSMNT_NFSV4)) == 0) nmp->nm_maxfilesize = 0xffffffffLL; else - nmp->nm_maxfilesize = (u_int64_t)0x80000000 * DEV_BSIZE - 1; + nmp->nm_maxfilesize = OFF_MAX; nmp->nm_timeo = NFS_TIMEO; nmp->nm_retry = NFS_RETRANS; diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 90e7d4ffe0ce..9ea077dcc5df 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -1280,8 +1280,23 @@ nfsvno_fsync(struct vnode *vp, u_int64_t off, int cnt, struct ucred *cred, int nfsvno_statfs(struct vnode *vp, struct statfs *sf) { + int error; - return (VFS_STATFS(vp->v_mount, sf)); + error = VFS_STATFS(vp->v_mount, sf); + if (error == 0) { + /* + * Since NFS handles these values as unsigned on the + * wire, there is no way to represent negative values, + * so set them to 0. Without this, they will appear + * to be very large positive values for clients like + * Solaris10. + */ + if (sf->f_bavail < 0) + sf->f_bavail = 0; + if (sf->f_ffree < 0) + sf->f_ffree = 0; + } + return (error); } /* diff --git a/sys/geom/geom_map.c b/sys/geom/geom_map.c index 5acaefb83b29..7f1b24012ceb 100644 --- a/sys/geom/geom_map.c +++ b/sys/geom/geom_map.c @@ -43,81 +43,73 @@ __FBSDID("$FreeBSD$"); #include #include #include - #include + #include #include -#define MAP_CLASS_NAME "MAP" - -struct map_desc { - uint8_t name [16]; /* null-terminated name */ - uint32_t offset; /* offset in flash */ - uint32_t addr; /* address in memory */ - uint32_t size; /* image size in bytes */ - uint32_t entry; /* offset in image for entry point */ - uint32_t dsize; /* data size in bytes */ -}; - +#define MAP_CLASS_NAME "MAP" #define MAP_MAXSLICE 64 +#define MAP_MAX_MARKER_LEN 64 struct g_map_softc { - uint32_t entry [MAP_MAXSLICE]; - uint32_t dsize [MAP_MAXSLICE]; - uint8_t readonly[MAP_MAXSLICE]; - g_access_t *parent_access; + off_t offset[MAP_MAXSLICE]; /* offset in flash */ + off_t size[MAP_MAXSLICE]; /* image size in bytes */ + off_t entry[MAP_MAXSLICE]; + off_t dsize[MAP_MAXSLICE]; + uint8_t readonly[MAP_MAXSLICE]; + g_access_t *parent_access; }; -static int -g_map_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) -{ - return (ENOIOCTL); -} - static int g_map_access(struct g_provider *pp, int dread, int dwrite, int dexcl) { - struct g_geom *gp = pp->geom; - struct g_slicer *gsp = gp->softc; - struct g_map_softc *sc = gsp->softc; + struct g_geom *gp; + struct g_slicer *gsp; + struct g_map_softc *sc; + + gp = pp->geom; + gsp = gp->softc; + sc = gsp->softc; if (dwrite > 0 && sc->readonly[pp->index]) return (EPERM); + return (sc->parent_access(pp, dread, dwrite, dexcl)); - /* - * no (sc->parent_access(pp, dread, dwrite, dexcl));, - * We need to have way for update flash - */ } static int g_map_start(struct bio *bp) { struct g_provider *pp; - struct g_geom *gp; + struct g_geom *gp; struct g_map_softc *sc; struct g_slicer *gsp; - int idx; + int idx; pp = bp->bio_to; idx = pp->index; gp = pp->geom; gsp = gp->softc; sc = gsp->softc; + if (bp->bio_cmd == BIO_GETATTR) { if (g_handleattr_int(bp, MAP_CLASS_NAME "::entry", - sc->entry[idx])) + sc->entry[idx])) { return (1); + } if (g_handleattr_int(bp, MAP_CLASS_NAME "::dsize", - sc->dsize[idx])) + sc->dsize[idx])) { return (1); + } } + return (0); } static void g_map_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, - struct g_consumer *cp __unused, struct g_provider *pp) + struct g_consumer *cp __unused, struct g_provider *pp) { struct g_map_softc *sc; struct g_slicer *gsp; @@ -127,45 +119,237 @@ g_map_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, g_slice_dumpconf(sb, indent, gp, cp, pp); if (pp != NULL) { if (indent == NULL) { - sbuf_printf(sb, " entry %d", sc->entry[pp->index]); - sbuf_printf(sb, " dsize %d", sc->dsize[pp->index]); + sbuf_printf(sb, " entry %lld", sc->entry[pp->index]); + sbuf_printf(sb, " dsize %lld", sc->dsize[pp->index]); } else { - sbuf_printf(sb, "%s%d\n", indent, - sc->entry[pp->index]); - sbuf_printf(sb, "%s%d\n", indent, - sc->dsize[pp->index]); + sbuf_printf(sb, "%s%lld\n", indent, + sc->entry[pp->index]); + sbuf_printf(sb, "%s%lld\n", indent, + sc->dsize[pp->index]); } } } -#include +static int +find_marker(struct g_consumer *cp, const char *line, off_t *offset) +{ + off_t search_start, search_offset, search_step; + size_t sectorsize; + uint8_t *buf; + char *op, key[MAP_MAX_MARKER_LEN], search_key[MAP_MAX_MARKER_LEN]; + int ret, c; + /* Try convert to numeric first */ + *offset = strtouq(line, &op, 0); + if (*op == '\0') + return (0); + + bzero(search_key, MAP_MAX_MARKER_LEN); + sectorsize = cp->provider->sectorsize; + + ret = sscanf(line, "search:%qi:%qi:%63c", + &search_start, &search_step, search_key); + if (ret < 3) + return (1); + + if (bootverbose) { + printf("MAP: search key \"%s\" from 0x%llx, step 0x%llx\n", + search_key, search_start, search_step); + } + + /* error if search_key is empty */ + if (strlen(search_key) < 1) + return (1); + + /* sscanf successful, and we start marker search */ + for (search_offset = search_start; + search_offset < cp->provider->mediasize; + search_offset += search_step) { + + g_topology_unlock(); + buf = g_read_data(cp, rounddown(search_offset, sectorsize), + roundup(strlen(search_key), sectorsize), NULL); + g_topology_lock(); + + /* Wildcard, replace '.' with byte from data */ + /* TODO: add support wildcard escape '\.' */ + + strncpy(key, search_key, MAP_MAX_MARKER_LEN); + + for (c = 0; c < MAP_MAX_MARKER_LEN && key[c]; c++) { + if (key[c] == '.') { + key[c] = ((char *)(buf + + (search_offset % sectorsize)))[c]; + } + } + + if (buf != NULL && strncmp(buf + search_offset % sectorsize, + key, strlen(search_key)) == 0) { + g_free(buf); + /* Marker found, so return their offset */ + *offset = search_offset; + return (0); + } + g_free(buf); + } + + /* Marker not found */ + return (1); +} + +static int +g_map_parse_part(struct g_class *mp, struct g_provider *pp, + struct g_consumer *cp, struct g_geom *gp, struct g_map_softc *sc, int i) +{ + const char *value, *name; + char *op; + off_t start, end, offset, size, dsize; + int readonly, ret; + + /* hint.map.0.at="cfid0" - bind to cfid0 media */ + if (resource_string_value("map", i, "at", &value) != 0) + return (1); + + /* Check if this correct provider */ + if (strcmp(pp->name, value) != 0) + return (1); + + /* + * hint.map.0.name="uboot" - name of partition, will be available + * as "/dev/map/uboot" + */ + if (resource_string_value("map", i, "name", &name) != 0) { + if (bootverbose) + printf("MAP: hint.map.%d has no name\n", i); + return (1); + } + + /* + * hint.map.0.start="0x00010000" - partition start at 0x00010000 + * or hint.map.0.start="search:0x00010000:0x200:marker text" - + * search for text "marker text", begin at 0x10000, step 0x200 + * until we found marker or end of media reached + */ + if (resource_string_value("map", i, "start", &value) != 0) { + if (bootverbose) + printf("MAP: \"%s\" has no start value\n", name); + return (1); + } + if (find_marker(cp, value, &start) != 0) { + if (bootverbose) { + printf("MAP: \"%s\" can't parse/use start value\n", + name); + } + return (1); + } + + /* like "start" */ + if (resource_string_value("map", i, "end", &value) != 0) { + if (bootverbose) + printf("MAP: \"%s\" has no end value\n", name); + return (1); + } + if (find_marker(cp, value, &end) != 0) { + if (bootverbose) { + printf("MAP: \"%s\" can't parse/use start value\n", + name); + } + return (1); + } + + /* variable readonly optional, disable write access */ + if (resource_int_value("map", i, "readonly", &readonly) != 0) + readonly = 0; + + /* offset of partition data, from partition begin */ + if (resource_string_value("map", i, "offset", &value) == 0) { + offset = strtouq(value, &op, 0); + if (*op != '\0') { + if (bootverbose) { + printf("MAP: \"%s\" can't parse offset\n", + name); + } + return (1); + } + } else { + offset = 0; + } + + /* partition data size */ + if (resource_string_value("map", i, "dsize", &value) == 0) { + dsize = strtouq(value, &op, 0); + if (*op != '\0') { + if (bootverbose) { + printf("MAP: \"%s\" can't parse dsize\n", + name); + } + return (1); + } + } else { + dsize = 0; + } + + size = end - start; + if (dsize == 0) + dsize = size - offset; + + /* end is 0 or size is 0, No MAP - so next */ + if (end < start) { + if (bootverbose) { + printf("MAP: \"%s\", \"end\" less than " + "\"start\"\n", name); + } + return (1); + } + + if (offset + dsize > size) { + if (bootverbose) { + printf("MAP: \"%s\", \"dsize\" bigger than " + "partition - offset\n", name); + } + return (1); + } + + ret = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + offset, + dsize, cp->provider->sectorsize, "map/%s", name); + if (ret != 0) { + if (bootverbose) { + printf("MAP: g_slice_config returns %d for \"%s\"\n", + ret, name); + } + return (1); + } + + if (bootverbose) { + printf("MAP: %llxx%llx, data=%llxx%llx " + "\"/dev/map/%s\"\n", + start, size, offset, dsize, name); + } + + sc->offset[i] = start; + sc->size[i] = size; + sc->entry[i] = offset; + sc->dsize[i] = dsize; + sc->readonly[i] = readonly ? 1 : 0; + + return (0); +} static struct g_geom * -g_map_taste(struct g_class *mp, struct g_provider *pp, int insist) +g_map_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) { - struct g_geom *gp; - struct g_consumer *cp; struct g_map_softc *sc; - int error , sectorsize, i, ret; - struct map_desc *head; - u_int32_t start = 0, end = 0, size = 0, off, readonly; - const char *name; - const char *at; - const char *search; - int search_start = 0, search_end = 0; - u_char *buf; - uint32_t offmask; - u_int blksize;/* NB: flash block size stored as stripesize */ - off_t offset; + struct g_consumer *cp; + struct g_geom *gp; + int i; g_trace(G_T_TOPOLOGY, "map_taste(%s,%s)", mp->name, pp->name); g_topology_assert(); - if (!strcmp(pp->geom->class->name, MAP_CLASS_NAME)) + if (strcmp(pp->geom->class->name, MAP_CLASS_NAME) == 0) return (NULL); gp = g_slice_new(mp, MAP_MAXSLICE, pp, &cp, &sc, sizeof(*sc), - g_map_start); + g_map_start); if (gp == NULL) return (NULL); @@ -173,160 +357,14 @@ g_map_taste(struct g_class *mp, struct g_provider *pp, int insist) sc->parent_access = gp->access; gp->access = g_map_access; - sectorsize = cp->provider->sectorsize; - blksize = cp->provider->stripesize; - if (powerof2(cp->provider->mediasize)) - offmask = cp->provider->mediasize - 1; - else - offmask = 0xffffffff; /* XXX */ + for (i = 0; i < MAP_MAXSLICE; i++) + g_map_parse_part(mp, pp, cp, gp, sc, i); - g_topology_unlock(); - head = NULL; - offset = cp->provider->mediasize - blksize; - g_topology_lock(); - - for (i = 0; i < MAP_MAXSLICE; i++) { - search_start = search_end = start = end = off = readonly = 0; - - ret = resource_string_value("map", i, "at", &at); - if (ret) - continue; - - /* Check if my provider */ - if (strncmp(pp->name, at, strlen(at))) - continue; - - ret = resource_string_value("map", i, "start", &search); - - if (!ret && strncmp(search, "search", 6) == 0) { - uint32_t search_offset, search_start = 0; - uint32_t search_step = 0; - const char *search_key; - char key[255]; - int c; - - ret = resource_int_value("map", i, "searchstart", - &search_start); - ret = resource_int_value("map", i, "searchstep", - &search_step); - if (ret) - search_step = 0x10000U; - ret = resource_string_value("map", i, "searchkey", &search_key); - if (ret) - continue; - - printf("GEOM_MAP: searchkey=\"%s\"\n", search_key); - for (search_offset = search_start; - search_offset < cp->provider->mediasize && start == 0; - search_offset += search_step) { - buf = g_read_data(cp, - rounddown(search_offset, sectorsize), - roundup(strlen(search_key), sectorsize), - NULL); - - /* Wildcard, replace '.' with byte from data */ - strncpy(key, search_key, 255); - for (c = 0; c < 255 && key[c]; c++) - if (key[c] == '.') - key[c] = ((char *)(buf + search_offset % sectorsize))[c]; - - if (buf != NULL && strncmp( - buf + search_offset % sectorsize, - key, strlen(search_key)) == 0) - start = search_offset; - g_free(buf); - } - if (!start) - continue; - } else { - ret = resource_int_value("map", i, "start", &start); - if (ret) - continue; - } - - ret = resource_string_value("map", i, "end", &search); - - if (!ret && strncmp(search, "search", 6) == 0) { - uint32_t search_offset, search_start = 0, search_step = 0; - const char *search_key; - char key[255]; - int c; - - ret = resource_int_value("map", i, "searchstart", &search_start); - ret = resource_int_value("map", i, "searchstep", &search_step); - if (ret) - search_step = 0x10000U; - ret = resource_string_value("map", i, "searchkey", &search_key); - if (ret) - continue; - - for (search_offset = search_start; - search_offset < cp->provider->mediasize && end == 0; - search_offset += search_step) { - buf = g_read_data(cp, - rounddown(search_offset, sectorsize), - roundup(strlen(search_key), sectorsize), - NULL); - - /* Wildcard, replace '.' with byte from data */ - strncpy(key, search_key, 255); - for (c = 0; c < 255 && key[c]; c++) - if (key[c] == '.') - key[c] = ((char *)(buf + search_offset % sectorsize))[c]; - - if (buf != NULL && strncmp( - buf + search_offset % sectorsize, - key, strlen(search_key)) == 0) - end = search_offset; - g_free(buf); - } - if (!end) - continue; - } else { - ret = resource_int_value("map", i, "end", &end); - if (ret) - continue; - } - size = end - start; - - /* end is 0 or size is 0, No MAP - so next */ - if (end == 0 || size == 0) - continue; - ret = resource_int_value("map", i, "offset", &off); - ret = resource_int_value("map", i, "readonly", &readonly); - ret = resource_string_value("map", i, "name", &name); - /* No name or error read name */ - if (ret) - continue; - - if (off > size) - printf("%s: off(%d) > size(%d) for \"%s\"\n", - __func__, off, size, name); - - error = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + off, - size - off, sectorsize, "map/%s", name); - printf("MAP: %08x-%08x, offset=%08x \"map/%s\"\n", - (uint32_t) start, - (uint32_t) size, - (uint32_t) off, - name - ); - - if (error) - printf("%s g_slice_config returns %d for \"%s\"\n", - __func__, error, name); - - sc->entry[i] = off; - sc->dsize[i] = size - off; - sc->readonly[i] = readonly ? 1 : 0; - } - - - if (i == 0) - return (NULL); g_access(cp, -1, 0, 0); if (LIST_EMPTY(&gp->provider)) { + if (bootverbose) + printf("MAP: No valid partition found at %s\n", pp->name); g_slice_spoiled(cp); return (NULL); } @@ -336,7 +374,7 @@ g_map_taste(struct g_class *mp, struct g_provider *pp, int insist) static void g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb) { - struct g_geom *gp; + struct g_geom *gp; g_topology_assert(); gp = gctl_get_geom(req, mp, "geom"); @@ -351,6 +389,5 @@ static struct g_class g_map_class = { .taste = g_map_taste, .dumpconf = g_map_dumpconf, .ctlreq = g_map_config, - .ioctl = g_map_ioctl, }; DECLARE_GEOM_CLASS(g_map_class, g_map); diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index dfe6434518f0..966e46ea0729 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -224,11 +224,34 @@ mem_range_AP_init(void) static void topo_probe_amd(void) { + int core_id_bits; + int id; /* AMD processors do not support HTT. */ - cpu_cores = (amd_feature2 & AMDID2_CMP) != 0 ? - (cpu_procinfo2 & AMDID_CMP_CORES) + 1 : 1; cpu_logical = 1; + + if ((amd_feature2 & AMDID2_CMP) == 0) { + cpu_cores = 1; + return; + } + + core_id_bits = (cpu_procinfo2 & AMDID_COREID_SIZE) >> + AMDID_COREID_SIZE_SHIFT; + if (core_id_bits == 0) { + cpu_cores = (cpu_procinfo2 & AMDID_CMP_CORES) + 1; + return; + } + + /* Fam 10h and newer should get here. */ + for (id = 0; id <= MAX_APIC_ID; id++) { + /* Check logical CPU availability. */ + if (!cpu_info[id].cpu_present || cpu_info[id].cpu_disabled) + continue; + /* Check if logical CPU has the same package ID. */ + if ((id >> core_id_bits) != (boot_cpu_id >> core_id_bits)) + continue; + cpu_cores++; + } } /* diff --git a/sys/i386/include/specialreg.h b/sys/i386/include/specialreg.h index cfb205f17ff0..adccaf4483f9 100644 --- a/sys/i386/include/specialreg.h +++ b/sys/i386/include/specialreg.h @@ -227,6 +227,8 @@ * AMD extended function 8000_0008h ecx info */ #define AMDID_CMP_CORES 0x000000ff +#define AMDID_COREID_SIZE 0x0000f000 +#define AMDID_COREID_SIZE_SHIFT 12 /* * CPUID manufacturers identifiers diff --git a/sys/ia64/isa/isa.c b/sys/ia64/isa/isa.c index 646723716ee9..cdb93cc35c1a 100644 --- a/sys/ia64/isa/isa.c +++ b/sys/ia64/isa/isa.c @@ -135,25 +135,3 @@ isa_release_resource(device_t bus, device_t child, int type, int rid, struct resource_list *rl = &idev->id_resources; return resource_list_release(rl, bus, child, type, rid, r); } - -/* - * We can't use the bus_generic_* versions of these methods because those - * methods always pass the bus param as the requesting device, and we need - * to pass the child (the i386 nexus knows about this and is prepared to - * deal). - */ -int -isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags, - driver_filter_t filter, void (*ihand)(void *), void *arg, - void **cookiep) -{ - return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags, - filter, ihand, arg, cookiep)); -} - -int -isa_teardown_intr(device_t bus, device_t child, struct resource *r, - void *cookie) -{ - return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie)); -} diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index 1d1a13af6472..9e10320a5ae7 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -1071,8 +1071,8 @@ static device_method_t isa_methods[] = { DEVMETHOD(bus_write_ivar, isa_write_ivar), DEVMETHOD(bus_child_detached, isa_child_detached), DEVMETHOD(bus_driver_added, isa_driver_added), - DEVMETHOD(bus_setup_intr, isa_setup_intr), - DEVMETHOD(bus_teardown_intr, isa_teardown_intr), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_get_resource_list,isa_get_resource_list), DEVMETHOD(bus_alloc_resource, isa_alloc_resource), diff --git a/sys/isa/isa_common.h b/sys/isa/isa_common.h index 340ad1762268..a6702f492af3 100644 --- a/sys/isa/isa_common.h +++ b/sys/isa/isa_common.h @@ -73,11 +73,5 @@ extern struct resource *isa_alloc_resource(device_t bus, device_t child, extern int isa_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r); -extern int isa_setup_intr(device_t bus, device_t child, struct resource *r, - int flags, driver_filter_t *filter, void (*ihand)(void *), void *arg, - void **cookiep); -extern int isa_teardown_intr(device_t bus, device_t child, struct resource *r, - void *cookie); - extern driver_t isa_driver; extern devclass_t isa_devclass; diff --git a/sys/mips/atheros/ar71xx_gpio.c b/sys/mips/atheros/ar71xx_gpio.c index 866c72b5b740..09b4d50124f4 100644 --- a/sys/mips/atheros/ar71xx_gpio.c +++ b/sys/mips/atheros/ar71xx_gpio.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "gpio_if.h" @@ -144,7 +145,19 @@ static int ar71xx_gpio_pin_max(device_t dev, int *maxpin) { - *maxpin = AR71XX_GPIO_PINS - 1; + switch (ar71xx_soc) { + case AR71XX_SOC_AR9130: + case AR71XX_SOC_AR9132: + *maxpin = AR91XX_GPIO_PINS - 1; + break; + case AR71XX_SOC_AR7240: + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + *maxpin = AR724X_GPIO_PINS - 1; + break; + default: + *maxpin = AR71XX_GPIO_PINS - 1; + } return (0); } diff --git a/sys/mips/atheros/ar71xx_gpiovar.h b/sys/mips/atheros/ar71xx_gpiovar.h index a9ed7e074221..3489f5a7aea5 100644 --- a/sys/mips/atheros/ar71xx_gpiovar.h +++ b/sys/mips/atheros/ar71xx_gpiovar.h @@ -52,6 +52,8 @@ GPIO_WRITE(sc, reg, GPIO_READ(sc, (reg)) & ~(bits)) #define AR71XX_GPIO_PINS 12 +#define AR724X_GPIO_PINS 18 +#define AR91XX_GPIO_PINS 22 struct ar71xx_gpio_softc { device_t dev; diff --git a/sys/mips/atheros/ar724xreg.h b/sys/mips/atheros/ar724xreg.h index eaceb1d61886..73e20afe95d2 100644 --- a/sys/mips/atheros/ar724xreg.h +++ b/sys/mips/atheros/ar724xreg.h @@ -105,6 +105,4 @@ #define AR724X_GPIO_FUNC_UART_EN (1 >> 1) #define AR724X_GPIO_FUNC_JTAG_DISABLE (1 >> 0) -#define AR724X_GPIO_COUNT 18 - #endif diff --git a/sys/mips/atheros/ar91xxreg.h b/sys/mips/atheros/ar91xxreg.h index 729d9ffcf7d0..2dfaeb5936c0 100644 --- a/sys/mips/atheros/ar91xxreg.h +++ b/sys/mips/atheros/ar91xxreg.h @@ -81,6 +81,4 @@ #define AR91XX_GPIO_FUNC_UART_EN (1 << 8) #define AR91XX_GPIO_FUNC_USB_CLK_EN (1 << 4) -#define AR91XX_GPIO_COUNT 22 - #endif diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 7c01ebe14cf6..4e727d9df3f3 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -228,8 +228,8 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen, i = clone_create(&tunclones, &tun_cdevsw, &u, dev, 0); if (i) { if (append_unit) { - namelen = snprintf(devname, sizeof(devname), "%s%d", name, - u); + namelen = snprintf(devname, sizeof(devname), "%s%d", + name, u); name = devname; } /* No preexisting struct cdev *, create one */ @@ -577,11 +577,8 @@ tunifioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * tunoutput - queue packets from higher level ready to put out. */ static int -tunoutput( - struct ifnet *ifp, - struct mbuf *m0, - struct sockaddr *dst, - struct route *ro) +tunoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, + struct route *ro) { struct tun_softc *tp = ifp->if_softc; u_short cached_tun_flags; @@ -661,10 +658,8 @@ tunoutput( } error = (ifp->if_transmit)(ifp, m0); - if (error) { - ifp->if_collisions++; + if (error) return (ENOBUFS); - } ifp->if_opackets++; return (0); } @@ -673,7 +668,8 @@ tunoutput( * the cdevsw interface is now pretty minimal. */ static int -tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) +tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, + struct thread *td) { int error; struct tun_softc *tp = dev->si_drv1; @@ -995,7 +991,7 @@ tunkqfilter(struct cdev *dev, struct knote *kn) ifp->if_xname, dev2unit(dev)); kn->kn_fop = &tun_write_filterops; break; - + default: TUNDEBUG(ifp, "%s kqfilter: invalid filter, minor = %#x\n", ifp->if_xname, dev2unit(dev)); diff --git a/sys/netinet/ipfw/ip_dn_glue.c b/sys/netinet/ipfw/ip_dn_glue.c index 3f968df3182b..9fc6b23f662e 100644 --- a/sys/netinet/ipfw/ip_dn_glue.c +++ b/sys/netinet/ipfw/ip_dn_glue.c @@ -624,7 +624,7 @@ dn_c_copy_pipe(struct dn_schk *s, struct copy_args *a, int nq) /* These 4 field are the same in pipe7 and pipe8 */ pipe7->next.sle_next = (struct dn_pipe7 *)DN_IS_PIPE; pipe7->bandwidth = l->bandwidth; - pipe7->delay = l->delay; + pipe7->delay = l->delay * 1000 / hz; pipe7->pipe_nr = l->link_nr - DN_MAX_ID; if (!is7) { diff --git a/sys/netinet/ipfw/ip_dummynet.c b/sys/netinet/ipfw/ip_dummynet.c index d44fd10c9d36..ba6e89254273 100644 --- a/sys/netinet/ipfw/ip_dummynet.c +++ b/sys/netinet/ipfw/ip_dummynet.c @@ -808,6 +808,7 @@ copy_obj(char **start, char *end, void *_o, const char *msg, int i) /* Adjust burst parameter for link */ struct dn_link *l = (struct dn_link *)*start; l->burst = div64(l->burst, 8 * hz); + l->delay = l->delay * 1000 / hz; } else if (o->type == DN_SCH) { /* Set id->id to the number of instances */ struct dn_schk *s = _o; diff --git a/sys/netinet/sctp_auth.h b/sys/netinet/sctp_auth.h index 653620dc3afe..9406ce898b67 100644 --- a/sys/netinet/sctp_auth.h +++ b/sys/netinet/sctp_auth.h @@ -89,7 +89,7 @@ typedef struct sctp_hmaclist { } sctp_hmaclist_t; /* authentication info */ -typedef struct sctp_authinfo { +typedef struct sctp_authinformation { sctp_key_t *random; /* local random key (concatenated) */ uint32_t random_len; /* local random number length for param */ sctp_key_t *peer_random;/* peer's random key (concatenated) */ @@ -98,7 +98,7 @@ typedef struct sctp_authinfo { uint16_t active_keyid; /* active send keyid */ uint16_t assoc_keyid; /* current send keyid (cached) */ uint16_t recv_keyid; /* last recv keyid (cached) */ -} sctp_authinfo_t; +} sctp_authinfo_t; diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index 047df94c431f..9a777c877fc3 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include static struct buf *nfs_getcacheblk(struct vnode *vp, daddr_t bn, int size, struct thread *td); diff --git a/sys/nfsclient/nfs_kdtrace.c b/sys/nfsclient/nfs_kdtrace.c index 3a478e0abf26..429dbc3baeb2 100644 --- a/sys/nfsclient/nfs_kdtrace.c +++ b/sys/nfsclient/nfs_kdtrace.c @@ -539,4 +539,4 @@ DEV_MODULE(dtnfsclient, dtnfsclient_modevent, NULL); MODULE_VERSION(dtnfsclient, 1); MODULE_DEPEND(dtnfsclient, dtrace, 1, 1, 1); MODULE_DEPEND(dtnfsclient, opensolaris, 1, 1, 1); -MODULE_DEPEND(dtnfsclient, nfs, 1, 1, 1); +MODULE_DEPEND(dtnfsclient, oldnfs, 1, 1, 1); diff --git a/sys/nfsclient/nfs_kdtrace.h b/sys/nfsclient/nfs_kdtrace.h deleted file mode 100644 index d29aa683a714..000000000000 --- a/sys/nfsclient/nfs_kdtrace.h +++ /dev/null @@ -1,120 +0,0 @@ -/*- - * Copyright (c) 2009 Robert N. M. Watson - * All rights reserved. - * - * This software was developed at the University of Cambridge Computer - * Laboratory with support from a grant from Google, Inc. - * - * 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. - * - * $FreeBSD$ - */ - -#ifndef _NFSCLIENT_NFS_KDTRACE_H_ -#define _NFSCLIENT_NFS_KDTRACE_H_ - -#ifdef KDTRACE_HOOKS -#include - -/* - * Definitions for NFS access cache probes. - */ -extern uint32_t nfsclient_accesscache_flush_done_id; -extern uint32_t nfsclient_accesscache_get_hit_id; -extern uint32_t nfsclient_accesscache_get_miss_id; -extern uint32_t nfsclient_accesscache_load_done_id; - -#define KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp) do { \ - if (dtrace_nfsclient_accesscache_flush_done_probe != NULL) \ - (dtrace_nfsclient_accesscache_flush_done_probe)( \ - nfsclient_accesscache_flush_done_id, (vp)); \ -} while (0) - -#define KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode) do { \ - if (dtrace_nfsclient_accesscache_get_hit_probe != NULL) \ - (dtrace_nfsclient_accesscache_get_hit_probe)( \ - nfsclient_accesscache_get_hit_id, (vp), (uid), \ - (mode)); \ -} while (0) - -#define KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode) do { \ - if (dtrace_nfsclient_accesscache_get_miss_probe != NULL) \ - (dtrace_nfsclient_accesscache_get_miss_probe)( \ - nfsclient_accesscache_get_miss_id, (vp), (uid), \ - (mode)); \ -} while (0) - -#define KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) do { \ - if (dtrace_nfsclient_accesscache_load_done_probe != NULL) \ - (dtrace_nfsclient_accesscache_load_done_probe)( \ - nfsclient_accesscache_load_done_id, (vp), (uid), \ - (rmode), (error)); \ -} while (0) - -/* - * Definitions for NFS attribute cache probes. - */ -extern uint32_t nfsclient_attrcache_flush_done_id; -extern uint32_t nfsclient_attrcache_get_hit_id; -extern uint32_t nfsclient_attrcache_get_miss_id; -extern uint32_t nfsclient_attrcache_load_done_id; - -#define KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp) do { \ - if (dtrace_nfsclient_attrcache_flush_done_probe != NULL) \ - (dtrace_nfsclient_attrcache_flush_done_probe)( \ - nfsclient_attrcache_flush_done_id, (vp)); \ -} while (0) - -#define KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap) do { \ - if (dtrace_nfsclient_attrcache_get_hit_probe != NULL) \ - (dtrace_nfsclient_attrcache_get_hit_probe)( \ - nfsclient_attrcache_get_hit_id, (vp), (vap)); \ -} while (0) - -#define KDTRACE_NFS_ATTRCACHE_GET_MISS(vp) do { \ - if (dtrace_nfsclient_attrcache_get_miss_probe != NULL) \ - (dtrace_nfsclient_attrcache_get_miss_probe)( \ - nfsclient_attrcache_get_miss_id, (vp)); \ -} while (0) - -#define KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error) do { \ - if (dtrace_nfsclient_attrcache_load_done_probe != NULL) \ - (dtrace_nfsclient_attrcache_load_done_probe)( \ - nfsclient_attrcache_load_done_id, (vp), (vap), \ - (error)); \ -} while (0) - -#else /* !KDTRACE_HOOKS */ - -#define KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp) -#define KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode) -#define KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode) -#define KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) - -#define KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp) -#define KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap) -#define KDTRACE_NFS_ATTRCACHE_GET_MISS(vp) -#define KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error) - -#endif /* KDTRACE_HOOKS */ - -#endif /* !_NFSCLIENT_NFS_KDTRACE_H_ */ diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index e1ecd1972b84..fe4f5cc545a1 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 33506a415ef1..fb3a746c9461 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -74,7 +74,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include diff --git a/sys/powerpc/conf/GENERIC b/sys/powerpc/conf/GENERIC index 2459988baeac..d221a9727cc1 100644 --- a/sys/powerpc/conf/GENERIC +++ b/sys/powerpc/conf/GENERIC @@ -77,7 +77,7 @@ options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones # To make an SMP kernel, the next line is needed -#options SMP # Symmetric MultiProcessor Kernel +options SMP # Symmetric MultiProcessor Kernel # CPU frequency control device cpufreq diff --git a/sys/powerpc/mpc85xx/isa.c b/sys/powerpc/mpc85xx/isa.c index a1715efea5ca..1020e775117e 100644 --- a/sys/powerpc/mpc85xx/isa.c +++ b/sys/powerpc/mpc85xx/isa.c @@ -82,20 +82,3 @@ isa_release_resource(device_t bus, device_t child, int type, int rid, return (resource_list_release(rl, bus, child, type, rid, r)); } - -int -isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags, - driver_filter_t filter, void (*ihand)(void *), void *arg, void **cookiep) -{ - - return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags, - filter, ihand, arg, cookiep)); -} - -int -isa_teardown_intr(device_t bus, device_t child, struct resource *r, - void *cookie) -{ - - return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie)); -} diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index 5ca008983386..7b38060dfd12 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -65,6 +65,10 @@ struct macio_softc { vm_offset_t sc_base; vm_offset_t sc_size; struct rman sc_mem_rman; + + /* FCR registers */ + int sc_memrid; + struct resource *sc_memr; }; static MALLOC_DEFINE(M_MACIO, "macio", "macio device information"); @@ -296,6 +300,10 @@ macio_attach(device_t dev) sc->sc_base = reg[2]; sc->sc_size = MACIO_REG_SIZE; + sc->sc_memrid = PCIR_BAR(0); + sc->sc_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->sc_memrid, RF_ACTIVE); + sc->sc_mem_rman.rm_type = RMAN_ARRAY; sc->sc_mem_rman.rm_descr = "MacIO Device Memory"; error = rman_init(&sc->sc_mem_rman); @@ -347,6 +355,29 @@ macio_attach(device_t dev) continue; } device_set_ivars(cdev, dinfo); + + /* Set FCRs to enable some devices */ + if (sc->sc_memr == NULL) + continue; + + if (strcmp(ofw_bus_get_name(cdev), "bmac") == 0 || + strcmp(ofw_bus_get_compat(cdev), "bmac+") == 0) { + uint32_t fcr; + + fcr = bus_read_4(sc->sc_memr, HEATHROW_FCR); + + fcr |= FCR_ENET_ENABLE & ~FCR_ENET_RESET; + bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr); + DELAY(50000); + fcr |= FCR_ENET_RESET; + bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr); + DELAY(50000); + fcr &= ~FCR_ENET_RESET; + bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr); + DELAY(50000); + + bus_write_4(sc->sc_memr, HEATHROW_FCR, fcr); + } } return (bus_generic_attach(dev)); diff --git a/sys/powerpc/powermac/maciovar.h b/sys/powerpc/powermac/maciovar.h index c1ff391f90dc..ea0a029be21b 100644 --- a/sys/powerpc/powermac/maciovar.h +++ b/sys/powerpc/powermac/maciovar.h @@ -37,6 +37,16 @@ */ #define MACIO_REG_SIZE 0x7ffff +/* + * Feature Control Registers (FCR) + */ +#define HEATHROW_FCR 0x38 +#define KEYLARGO_FCR0 0x38 +#define KEYLARGO_FCR1 0x3c + +#define FCR_ENET_ENABLE 0x60000000 +#define FCR_ENET_RESET 0x80000000 + /* * Format of a macio reg property entry. */ diff --git a/sys/sparc64/isa/isa.c b/sys/sparc64/isa/isa.c index 9159cdac9420..6e221330029e 100644 --- a/sys/sparc64/isa/isa.c +++ b/sys/sparc64/isa/isa.c @@ -359,26 +359,3 @@ isa_release_resource(device_t bus, device_t child, int type, int rid, return (bus_generic_rl_release_resource(bus, child, type, rid, res)); } - -int -isa_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, - driver_filter_t *filter, driver_intr_t *intr, void *arg, void **cookiep) -{ - - /* - * Just pass through. This is going to be handled by either - * one of the parent PCI buses or the nexus device. - * The interrupt had been routed before it was added to the - * resource list of the child. - */ - return (bus_generic_setup_intr(dev, child, irq, flags, filter, intr, - arg, cookiep)); -} - -int -isa_teardown_intr(device_t dev, device_t child, struct resource *irq, - void *cookie) -{ - - return (bus_generic_teardown_intr(dev, child, irq, cookie)); -} diff --git a/sys/sys/stdint.h b/sys/sys/stdint.h index 27f6dae997fd..d5d92a5f4611 100644 --- a/sys/sys/stdint.h +++ b/sys/sys/stdint.h @@ -33,46 +33,7 @@ #include #include - -#ifndef _INT8_T_DECLARED -typedef __int8_t int8_t; -#define _INT8_T_DECLARED -#endif - -#ifndef _INT16_T_DECLARED -typedef __int16_t int16_t; -#define _INT16_T_DECLARED -#endif - -#ifndef _INT32_T_DECLARED -typedef __int32_t int32_t; -#define _INT32_T_DECLARED -#endif - -#ifndef _INT64_T_DECLARED -typedef __int64_t int64_t; -#define _INT64_T_DECLARED -#endif - -#ifndef _UINT8_T_DECLARED -typedef __uint8_t uint8_t; -#define _UINT8_T_DECLARED -#endif - -#ifndef _UINT16_T_DECLARED -typedef __uint16_t uint16_t; -#define _UINT16_T_DECLARED -#endif - -#ifndef _UINT32_T_DECLARED -typedef __uint32_t uint32_t; -#define _UINT32_T_DECLARED -#endif - -#ifndef _UINT64_T_DECLARED -typedef __uint64_t uint64_t; -#define _UINT64_T_DECLARED -#endif +#include typedef __int_least8_t int_least8_t; typedef __int_least16_t int_least16_t; @@ -94,13 +55,13 @@ typedef __uint_fast16_t uint_fast16_t; typedef __uint_fast32_t uint_fast32_t; typedef __uint_fast64_t uint_fast64_t; +#ifndef _INTMAX_T_DECLARED typedef __intmax_t intmax_t; +#define _INTMAX_T_DECLARED +#endif +#ifndef _UINTMAX_T_DECLARED typedef __uintmax_t uintmax_t; - -#ifndef _INTPTR_T_DECLARED -typedef __intptr_t intptr_t; -typedef __uintptr_t uintptr_t; -#define _INTPTR_T_DECLARED +#define _UINTMAX_T_DECLARED #endif #endif /* !_SYS_STDINT_H_ */ diff --git a/sys/sys/types.h b/sys/sys/types.h index 5cc005d22e19..cb513afeb5ee 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -60,51 +60,7 @@ typedef unsigned int uint; /* Sys V compatibility */ /* * XXX POSIX sized integrals that should appear only in . */ -#ifndef _INT8_T_DECLARED -typedef __int8_t int8_t; -#define _INT8_T_DECLARED -#endif - -#ifndef _INT16_T_DECLARED -typedef __int16_t int16_t; -#define _INT16_T_DECLARED -#endif - -#ifndef _INT32_T_DECLARED -typedef __int32_t int32_t; -#define _INT32_T_DECLARED -#endif - -#ifndef _INT64_T_DECLARED -typedef __int64_t int64_t; -#define _INT64_T_DECLARED -#endif - -#ifndef _UINT8_T_DECLARED -typedef __uint8_t uint8_t; -#define _UINT8_T_DECLARED -#endif - -#ifndef _UINT16_T_DECLARED -typedef __uint16_t uint16_t; -#define _UINT16_T_DECLARED -#endif - -#ifndef _UINT32_T_DECLARED -typedef __uint32_t uint32_t; -#define _UINT32_T_DECLARED -#endif - -#ifndef _UINT64_T_DECLARED -typedef __uint64_t uint64_t; -#define _UINT64_T_DECLARED -#endif - -#ifndef _INTPTR_T_DECLARED -typedef __intptr_t intptr_t; -typedef __uintptr_t uintptr_t; -#define _INTPTR_T_DECLARED -#endif +#include typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */ typedef __uint16_t u_int16_t; diff --git a/sys/x86/isa/isa.c b/sys/x86/isa/isa.c index 7b2982a7b54a..1a5713731836 100644 --- a/sys/x86/isa/isa.c +++ b/sys/x86/isa/isa.c @@ -237,28 +237,6 @@ isa_release_resource(device_t bus, device_t child, int type, int rid, return resource_list_release(rl, bus, child, type, rid, r); } -/* - * We can't use the bus_generic_* versions of these methods because those - * methods always pass the bus param as the requesting device, and we need - * to pass the child (the i386 nexus knows about this and is prepared to - * deal). - */ -int -isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags, - driver_filter_t *filter, void (*ihand)(void *), void *arg, - void **cookiep) -{ - return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags, - filter, ihand, arg, cookiep)); -} - -int -isa_teardown_intr(device_t bus, device_t child, struct resource *r, - void *cookie) -{ - return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie)); -} - /* * On this platform, isa can also attach to the legacy bus. */ diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index e81d2fe8af4d..dfef3a76fc73 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -159,9 +159,8 @@ static struct eventtimer lapic_et; static void lapic_enable(void); static void lapic_resume(struct pic *pic); -static void lapic_timer_enable_intr(void); -static void lapic_timer_oneshot(u_int count); -static void lapic_timer_periodic(u_int count); +static void lapic_timer_oneshot(u_int count, int enable_int); +static void lapic_timer_periodic(u_int count, int enable_int); static void lapic_timer_stop(void); static void lapic_timer_set_divisor(u_int divisor); static uint32_t lvt_mode(struct lapic *la, u_int pin, uint32_t value); @@ -379,13 +378,11 @@ lapic_setup(int boot) if (la->la_timer_mode != 0) { KASSERT(la->la_timer_period != 0, ("lapic%u: zero divisor", lapic_id())); - lapic_timer_stop(); lapic_timer_set_divisor(lapic_timer_divisor); - lapic_timer_enable_intr(); if (la->la_timer_mode == 1) - lapic_timer_periodic(la->la_timer_period); + lapic_timer_periodic(la->la_timer_period, 1); else - lapic_timer_oneshot(la->la_timer_period); + lapic_timer_oneshot(la->la_timer_period, 1); } /* Program error LVT and clear any existing errors. */ @@ -496,7 +493,7 @@ lapic_et_start(struct eventtimer *et, /* Try to calibrate the local APIC timer. */ do { lapic_timer_set_divisor(lapic_timer_divisor); - lapic_timer_oneshot(APIC_TIMER_MAX_COUNT); + lapic_timer_oneshot(APIC_TIMER_MAX_COUNT, 0); DELAY(1000000); value = APIC_TIMER_MAX_COUNT - lapic->ccr_timer; if (value != APIC_TIMER_MAX_COUNT) @@ -516,9 +513,7 @@ lapic_et_start(struct eventtimer *et, et->et_max_period.frac = ((0xfffffffeLLU << 32) / et->et_frequency) << 32; } - lapic_timer_stop(); lapic_timer_set_divisor(lapic_timer_divisor); - lapic_timer_enable_intr(); la = &lapics[lapic_id()]; if (period != NULL) { la->la_timer_mode = 1; @@ -526,14 +521,14 @@ lapic_et_start(struct eventtimer *et, (et->et_frequency * (period->frac >> 32)) >> 32; if (period->sec != 0) la->la_timer_period += et->et_frequency * period->sec; - lapic_timer_periodic(la->la_timer_period); + lapic_timer_periodic(la->la_timer_period, 1); } else { la->la_timer_mode = 2; la->la_timer_period = (et->et_frequency * (first->frac >> 32)) >> 32; if (first->sec != 0) la->la_timer_period += et->et_frequency * first->sec; - lapic_timer_oneshot(la->la_timer_period); + lapic_timer_oneshot(la->la_timer_period, 1); } return (0); } @@ -838,25 +833,29 @@ lapic_timer_set_divisor(u_int divisor) } static void -lapic_timer_oneshot(u_int count) +lapic_timer_oneshot(u_int count, int enable_int) { u_int32_t value; value = lapic->lvt_timer; value &= ~APIC_LVTT_TM; value |= APIC_LVTT_TM_ONE_SHOT; + if (enable_int) + value &= ~APIC_LVT_M; lapic->lvt_timer = value; lapic->icr_timer = count; } static void -lapic_timer_periodic(u_int count) +lapic_timer_periodic(u_int count, int enable_int) { u_int32_t value; value = lapic->lvt_timer; value &= ~APIC_LVTT_TM; value |= APIC_LVTT_TM_PERIODIC; + if (enable_int) + value &= ~APIC_LVT_M; lapic->lvt_timer = value; lapic->icr_timer = count; } @@ -870,17 +869,6 @@ lapic_timer_stop(void) value &= ~APIC_LVTT_TM; value |= APIC_LVT_M; lapic->lvt_timer = value; - lapic->icr_timer = 0; -} - -static void -lapic_timer_enable_intr(void) -{ - u_int32_t value; - - value = lapic->lvt_timer; - value &= ~APIC_LVT_M; - lapic->lvt_timer = value; } void diff --git a/tools/build/options/WITHOUT_ACCT b/tools/build/options/WITHOUT_ACCT index 537ee96b6269..4538ee7b8af9 100644 --- a/tools/build/options/WITHOUT_ACCT +++ b/tools/build/options/WITHOUT_ACCT @@ -1,5 +1,5 @@ .\" $FreeBSD$ Set to not build process accounting tools such as -.Xr ac 8 +.Xr ac 8 and .Xr accton 8 . diff --git a/tools/build/options/WITHOUT_FDT b/tools/build/options/WITHOUT_FDT index 8f32d85c3cf0..d3ade054c42a 100644 --- a/tools/build/options/WITHOUT_FDT +++ b/tools/build/options/WITHOUT_FDT @@ -1,3 +1,3 @@ .\" $FreeBSD$ -Set to not build Flattened Device Tree support as part of the base system. This -includes the device tree compiler (dtc) and libfdt support library. +Set to not build Flattened Device Tree support as part of the base system. +This includes the device tree compiler (dtc) and libfdt support library. diff --git a/tools/build/options/WITHOUT_FLOPPY b/tools/build/options/WITHOUT_FLOPPY index 1e478d2ac463..ea78d28c8e4b 100644 --- a/tools/build/options/WITHOUT_FLOPPY +++ b/tools/build/options/WITHOUT_FLOPPY @@ -1,3 +1,3 @@ .\" $FreeBSD$ -Set to not build or install programs +Set to not build or install programs for operating floppy disk driver. diff --git a/tools/build/options/WITH_GPIO b/tools/build/options/WITH_GPIO deleted file mode 100644 index a8ee399c2738..000000000000 --- a/tools/build/options/WITH_GPIO +++ /dev/null @@ -1,2 +0,0 @@ -.\" $FreeBSD$ -Set to build gpioctl(8) as part of the base system. diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c index fef2fda395e5..09aa3a5610a0 100644 --- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c +++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c @@ -528,25 +528,6 @@ cd9660_write_apm_partition_entry(FILE *fd, int index, int total_partitions, fseek(fd, 32 - strlen(part_name) - 1, SEEK_CUR); fwrite(part_type, strlen(part_type) + 1, 1, fd); - if (sector_size > 512) { - /* - * Some old broken software looks at 512-byte boundaries for - * partition table entries instead of sector boundaries. We - * can fit 3 entries into the first 2048-byte block, so use - * that to humor old code. - */ - - int n_512_parts = (sector_size / 512) - 1; - if (n_512_parts > total_partitions) - n_512_parts = total_partitions; - - if (index < n_512_parts) - cd9660_write_apm_partition_entry(fd, index, n_512_parts, - sector_start * (sector_size / 512), - nsectors * (sector_size / 512), 512, part_name, - part_type); - } - return 0; } @@ -601,23 +582,30 @@ cd9660_write_boot(FILE *fd) fseek(fd, 0, SEEK_SET); apm16 = htons(0x4552); fwrite(&apm16, sizeof(apm16), 1, fd); - apm16 = htons(diskStructure.sectorSize); + /* Device block size */ + apm16 = htons(512); fwrite(&apm16, sizeof(apm16), 1, fd); - apm32 = htonl(diskStructure.totalSectors); + /* Device block count */ + apm32 = htonl(diskStructure.totalSectors * + (diskStructure.sectorSize / 512)); fwrite(&apm32, sizeof(apm32), 1, fd); + /* Device type/id */ + apm16 = htons(1); + fwrite(&apm16, sizeof(apm16), 1, fd); + fwrite(&apm16, sizeof(apm16), 1, fd); /* Count total needed entries */ total_parts = 2 + apm_partitions; /* Self + ISO9660 */ /* Write self-descriptor */ - cd9660_write_apm_partition_entry(fd, 0, - total_parts, 1, total_parts, diskStructure.sectorSize, - "Apple", "Apple_partition_map"); + cd9660_write_apm_partition_entry(fd, 0, total_parts, 1, + total_parts, 512, "Apple", "Apple_partition_map"); /* Write ISO9660 descriptor, enclosing the whole disk */ - cd9660_write_apm_partition_entry(fd, 1, - total_parts, 0, diskStructure.totalSectors, - diskStructure.sectorSize, "", "CD_ROM_Mode_1"); + cd9660_write_apm_partition_entry(fd, 1, total_parts, 0, + diskStructure.totalSectors * + (diskStructure.sectorSize / 512), 512, "ISO9660", + "CD_ROM_Mode_1"); /* Write all partition entries */ apm_partitions = 0; @@ -627,8 +615,9 @@ cd9660_write_boot(FILE *fd) cd9660_write_apm_partition_entry(fd, 2 + apm_partitions++, total_parts, - t->sector, t->num_sectors, diskStructure.sectorSize, - "CD Boot", "Apple_Bootstrap"); + t->sector * (diskStructure.sectorSize / 512), + t->num_sectors * (diskStructure.sectorSize / 512), + 512, "CD Boot", "Apple_Bootstrap"); } } From c4bfd6e6a0b17327594355e2f9784702882de234 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 8 May 2011 00:39:49 +0000 Subject: [PATCH 022/164] All architectures define the size-bounded types (uint32_t, uint64_t, etc.) starting from base C types (int, long, etc). That is also reflected when building atomic operations, as the size-bounded types are built from the base C types. However, powerpc does the inverse thing, leading to a serie of nasty bugs. Cleanup the atomic implementation by defining as base the base C type version and depending on them, appropriately. Tested by: jceel --- sys/powerpc/include/atomic.h | 604 +++++++++++++++++++---------------- 1 file changed, 320 insertions(+), 284 deletions(-) diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index c3dc3cc58afc..cadd4be87d6f 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -48,13 +48,7 @@ * { *p += v; } */ -#define __ATOMIC_ADD_8(p, v, t) \ - 8-bit atomic_add not implemented - -#define __ATOMIC_ADD_16(p, v, t) \ - 16-bit atomic_add not implemented - -#define __ATOMIC_ADD_32(p, v, t) \ +#define __atomic_add_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " add %0, %3, %0\n" \ @@ -63,10 +57,10 @@ : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_ADD_32 */ + /* __atomic_add_int */ #ifdef __powerpc64__ -#define __ATOMIC_ADD_64(p, v, t) \ +#define __atomic_add_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " add %0, %3, %0\n" \ @@ -75,69 +69,78 @@ : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_ADD_64 */ + /* __atomic_add_long */ #else -#define __ATOMIC_ADD_64(p, v, t) \ - 64-bit atomic_add not implemented +#define __atomic_add_long(p, v, t) \ + long atomic_add not implemented #endif -#define _ATOMIC_ADD(width, suffix, type) \ +#define _ATOMIC_ADD(type) \ static __inline void \ - atomic_add_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_ADD_##width(p, v, t); \ + atomic_add_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ } \ \ static __inline void \ - atomic_add_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_ADD_##width(p, v, t); \ + atomic_add_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_add_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_add_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_add_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_ADD_##width(p, v, t); \ + __atomic_add_##type(p, v, t); \ } \ /* _ATOMIC_ADD */ -#if 0 -_ATOMIC_ADD(8, 8, uint8_t) -_ATOMIC_ADD(8, char, u_char) -_ATOMIC_ADD(16, 16, uint16_t) -_ATOMIC_ADD(16, short, u_short) -#endif -_ATOMIC_ADD(32, 32, uint32_t) -_ATOMIC_ADD(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_ADD(64, 64, uint64_t) -_ATOMIC_ADD(64, long, u_long) -_ATOMIC_ADD(64, ptr, uintptr_t) -#else -_ATOMIC_ADD(32, long, u_long) -_ATOMIC_ADD(32, ptr, uintptr_t) -#endif +_ATOMIC_ADD(int) +#define atomic_add_32 atomic_add_int +#define atomic_add_acq_32 atomic_add_acq_int +#define atomic_add_rel_32 atomic_add_rel_int + +#ifdef __powerpc64__ +_ATOMIC_ADD(long) + +#define atomic_add_64 atomic_add_long +#define atomic_add_acq_64 atomic_add_acq_long +#define atomic_add_rel_64 atomic_add_rel_long + +#define atomic_add_ptr(p, v) \ + atomic_add_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_add_acq_ptr(p, v) \ + atomic_add_acq_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_add_rel_ptr(p, v) \ + atomic_add_rel_long((volatile u_long *)(p), (u_long)(v)) +#else +#define atomic_add_long(p, v) \ + atomic_add_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_acq_long(p, v) \ + atomic_add_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_rel_long(p, v) \ + atomic_add_rel_int((volatile u_int *)(p), (u_int)(v)) + +#define atomic_add_ptr(p, v) \ + atomic_add_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_acq_ptr(p, v) \ + atomic_add_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_rel_ptr(p, v) \ + atomic_add_rel_int((volatile u_int *)(p), (u_int)(v)) +#endif #undef _ATOMIC_ADD -#undef __ATOMIC_ADD_64 -#undef __ATOMIC_ADD_32 -#undef __ATOMIC_ADD_16 -#undef __ATOMIC_ADD_8 +#undef __atomic_add_long +#undef __atomic_add_int /* * atomic_clear(p, v) * { *p &= ~v; } */ -#define __ATOMIC_CLEAR_8(p, v, t) \ - 8-bit atomic_clear not implemented - -#define __ATOMIC_CLEAR_16(p, v, t) \ - 16-bit atomic_clear not implemented - -#define __ATOMIC_CLEAR_32(p, v, t) \ +#define __atomic_clear_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " andc %0, %0, %3\n" \ @@ -146,10 +149,10 @@ _ATOMIC_ADD(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_CLEAR_32 */ + /* __atomic_clear_int */ #ifdef __powerpc64__ -#define __ATOMIC_CLEAR_64(p, v, t) \ +#define __atomic_clear_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " andc %0, %0, %3\n" \ @@ -158,56 +161,72 @@ _ATOMIC_ADD(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_CLEAR_64 */ + /* __atomic_clear_long */ #else -#define __ATOMIC_CLEAR_64(p, v, t) \ - 64-bit atomic_clear not implemented +#define __atomic_clear_long(p, v, t) \ + long atomic_clear not implemented #endif -#define _ATOMIC_CLEAR(width, suffix, type) \ +#define _ATOMIC_CLEAR(type) \ static __inline void \ - atomic_clear_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + atomic_clear_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ } \ \ static __inline void \ - atomic_clear_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + atomic_clear_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_clear_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_clear_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_clear_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_CLEAR_##width(p, v, t); \ + __atomic_clear_##type(p, v, t); \ } \ /* _ATOMIC_CLEAR */ -#if 0 -_ATOMIC_CLEAR(8, 8, uint8_t) -_ATOMIC_CLEAR(8, char, u_char) -_ATOMIC_CLEAR(16, 16, uint16_t) -_ATOMIC_CLEAR(16, short, u_short) -#endif -_ATOMIC_CLEAR(32, 32, uint32_t) -_ATOMIC_CLEAR(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_CLEAR(64, 64, uint64_t) -_ATOMIC_CLEAR(64, long, u_long) -_ATOMIC_CLEAR(64, ptr, uintptr_t) -#else -_ATOMIC_CLEAR(32, long, u_long) -_ATOMIC_CLEAR(32, ptr, uintptr_t) -#endif -#undef _ATOMIC_CLEAR -#undef __ATOMIC_CLEAR_64 -#undef __ATOMIC_CLEAR_32 -#undef __ATOMIC_CLEAR_16 -#undef __ATOMIC_CLEAR_8 +_ATOMIC_CLEAR(int) + +#define atomic_clear_32 atomic_clear_int +#define atomic_clear_acq_32 atomic_clear_acq_int +#define atomic_clear_rel_32 atomic_clear_rel_int + +#ifdef __powerpc64__ +_ATOMIC_CLEAR(long) + +#define atomic_clear_64 atomic_clear_long +#define atomic_clear_acq_64 atomic_clear_acq_long +#define atomic_clear_rel_64 atomic_clear_rel_long + +#define atomic_clear_ptr(p, v) \ + atomic_clear_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_clear_acq_ptr(p, v) \ + atomic_clear_acq_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_clear_rel_ptr(p, v) \ + atomic_clear_rel_long((volatile u_long *)(p), (u_long)(v)) +#else +#define atomic_clear_long(p, v) \ + atomic_clear_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_acq_long(p, v) \ + atomic_clear_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_rel_long(p, v) \ + atomic_clear_rel_int((volatile u_int *)(p), (u_int)(v)) + +#define atomic_clear_ptr(p, v) \ + atomic_clear_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_acq_ptr(p, v) \ + atomic_clear_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_rel_ptr(p, v) \ + atomic_clear_rel_int((volatile u_int *)(p), (u_int)(v)) +#endif +#undef _ATOMIC_ADD +#undef __atomic_clear_long +#undef __atomic_clear_int /* * atomic_cmpset(p, o, n) @@ -229,13 +248,7 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) * { *p |= v; } */ -#define __ATOMIC_SET_8(p, v, t) \ - 8-bit atomic_set not implemented - -#define __ATOMIC_SET_16(p, v, t) \ - 16-bit atomic_set not implemented - -#define __ATOMIC_SET_32(p, v, t) \ +#define __atomic_set_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " or %0, %3, %0\n" \ @@ -244,10 +257,10 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SET_32 */ + /* __atomic_set_int */ #ifdef __powerpc64__ -#define __ATOMIC_SET_64(p, v, t) \ +#define __atomic_set_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " or %0, %3, %0\n" \ @@ -256,69 +269,78 @@ _ATOMIC_CLEAR(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SET_64 */ + /* __atomic_set_long */ #else -#define __ATOMIC_SET_64(p, v, t) \ - 64-bit atomic_set not implemented +#define __atomic_set_long(p, v, t) \ + long atomic_set not implemented #endif -#define _ATOMIC_SET(width, suffix, type) \ +#define _ATOMIC_SET(type) \ static __inline void \ - atomic_set_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SET_##width(p, v, t); \ + atomic_set_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ } \ \ static __inline void \ - atomic_set_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SET_##width(p, v, t); \ + atomic_set_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_set_##type(p, v, t); \ __ATOMIC_BARRIER; \ } \ \ static __inline void \ - atomic_set_rel_##suffix(volatile type *p, type v) { \ - type t; \ + atomic_set_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ __ATOMIC_BARRIER; \ - __ATOMIC_SET_##width(p, v, t); \ + __atomic_set_##type(p, v, t); \ } \ /* _ATOMIC_SET */ -#if 0 -_ATOMIC_SET(8, 8, uint8_t) -_ATOMIC_SET(8, char, u_char) -_ATOMIC_SET(16, 16, uint16_t) -_ATOMIC_SET(16, short, u_short) -#endif -_ATOMIC_SET(32, 32, uint32_t) -_ATOMIC_SET(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_SET(64, 64, uint64_t) -_ATOMIC_SET(64, long, u_long) -_ATOMIC_SET(64, ptr, uintptr_t) -#else -_ATOMIC_SET(32, long, u_long) -_ATOMIC_SET(32, ptr, uintptr_t) -#endif +_ATOMIC_SET(int) +#define atomic_set_32 atomic_set_int +#define atomic_set_acq_32 atomic_set_acq_int +#define atomic_set_rel_32 atomic_set_rel_int + +#ifdef __powerpc64__ +_ATOMIC_SET(long) + +#define atomic_set_64 atomic_set_long +#define atomic_set_acq_64 atomic_set_acq_long +#define atomic_set_rel_64 atomic_set_rel_long + +#define atomic_set_ptr(p, v) \ + atomic_set_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_set_acq_ptr(p, v) \ + atomic_set_acq_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_set_rel_ptr(p, v) \ + atomic_set_rel_long((volatile u_long *)(p), (u_long)(v)) +#else +#define atomic_set_long(p, v) \ + atomic_set_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_acq_long(p, v) \ + atomic_set_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_rel_long(p, v) \ + atomic_set_rel_int((volatile u_int *)(p), (u_int)(v)) + +#define atomic_set_ptr(p, v) \ + atomic_set_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_acq_ptr(p, v) \ + atomic_set_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_rel_ptr(p, v) \ + atomic_set_rel_int((volatile u_int *)(p), (u_int)(v)) +#endif #undef _ATOMIC_SET -#undef __ATOMIC_SET_64 -#undef __ATOMIC_SET_32 -#undef __ATOMIC_SET_16 -#undef __ATOMIC_SET_8 +#undef __atomic_set_long +#undef __atomic_set_int /* * atomic_subtract(p, v) * { *p -= v; } */ -#define __ATOMIC_SUBTRACT_8(p, v, t) \ - 8-bit atomic_subtract not implemented - -#define __ATOMIC_SUBTRACT_16(p, v, t) \ - 16-bit atomic_subtract not implemented - -#define __ATOMIC_SUBTRACT_32(p, v, t) \ +#define __atomic_subtract_int(p, v, t) \ __asm __volatile( \ "1: lwarx %0, 0, %2\n" \ " subf %0, %3, %0\n" \ @@ -327,10 +349,10 @@ _ATOMIC_SET(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SUBTRACT_32 */ + /* __atomic_subtract_int */ #ifdef __powerpc64__ -#define __ATOMIC_SUBTRACT_64(p, v, t) \ +#define __atomic_subtract_long(p, v, t) \ __asm __volatile( \ "1: ldarx %0, 0, %2\n" \ " subf %0, %3, %0\n" \ @@ -339,56 +361,71 @@ _ATOMIC_SET(32, ptr, uintptr_t) : "=&r" (t), "=m" (*p) \ : "r" (p), "r" (v), "m" (*p) \ : "cc", "memory") \ - /* __ATOMIC_SUBTRACT_64 */ + /* __atomic_subtract_long */ #else -#define __ATOMIC_SUBTRACT_64(p, v, t) \ - 64-bit atomic_subtract not implemented +#define __atomic_subtract_long(p, v, t) \ + long atomic_subtract not implemented #endif -#define _ATOMIC_SUBTRACT(width, suffix, type) \ - static __inline void \ - atomic_subtract_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - } \ - \ - static __inline void \ - atomic_subtract_acq_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - __ATOMIC_BARRIER; \ - } \ - \ - static __inline void \ - atomic_subtract_rel_##suffix(volatile type *p, type v) { \ - type t; \ - __ATOMIC_BARRIER; \ - __ATOMIC_SUBTRACT_##width(p, v, t); \ - } \ +#define _ATOMIC_SUBTRACT(type) \ + static __inline void \ + atomic_subtract_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + } \ + \ + static __inline void \ + atomic_subtract_acq_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __atomic_subtract_##type(p, v, t); \ + __ATOMIC_BARRIER; \ + } \ + \ + static __inline void \ + atomic_subtract_rel_##type(volatile u_##type *p, u_##type v) { \ + u_##type t; \ + __ATOMIC_BARRIER; \ + __atomic_subtract_##type(p, v, t); \ + } \ /* _ATOMIC_SUBTRACT */ -#if 0 -_ATOMIC_SUBTRACT(8, 8, uint8_t) -_ATOMIC_SUBTRACT(8, char, u_char) -_ATOMIC_SUBTRACT(16, 16, uint16_t) -_ATOMIC_SUBTRACT(16, short, u_short) -#endif -_ATOMIC_SUBTRACT(32, 32, uint32_t) -_ATOMIC_SUBTRACT(32, int, u_int) -#ifdef __powerpc64__ -_ATOMIC_SUBTRACT(64, 64, uint64_t) -_ATOMIC_SUBTRACT(64, long, u_long) -_ATOMIC_SUBTRACT(64, ptr, uintptr_t) -#else -_ATOMIC_SUBTRACT(32, long, u_long) -_ATOMIC_SUBTRACT(32, ptr, uintptr_t) -#endif +_ATOMIC_SUBTRACT(int) +#define atomic_subtract_32 atomic_subtract_int +#define atomic_subtract_acq_32 atomic_subtract_acq_int +#define atomic_subtract_rel_32 atomic_subtract_rel_int + +#ifdef __powerpc64__ +_ATOMIC_SUBTRACT(long) + +#define atomic_subtract_64 atomic_subtract_long +#define atomic_subtract_acq_64 atomic_subract_acq_long +#define atomic_subtract_rel_64 atomic_subtract_rel_long + +#define atomic_subtract_ptr(p, v) \ + atomic_subtract_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_subtract_acq_ptr(p, v) \ + atomic_subtract_acq_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_subtract_rel_ptr(p, v) \ + atomic_subtract_rel_long((volatile u_long *)(p), (u_long)(v)) +#else +#define atomic_subtract_long(p, v) \ + atomic_subtract_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_acq_long(p, v) \ + atomic_subtract_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_rel_long(p, v) \ + atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) + +#define atomic_subtract_ptr(p, v) \ + atomic_subtract_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_acq_ptr(p, v) \ + atomic_subtract_acq_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_rel_ptr(p, v) \ + atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) +#endif #undef _ATOMIC_SUBTRACT -#undef __ATOMIC_SUBTRACT_64 -#undef __ATOMIC_SUBTRACT_32 -#undef __ATOMIC_SUBTRACT_16 -#undef __ATOMIC_SUBTRACT_8 +#undef __atomic_subtract_long +#undef __atomic_subtract_int /* * atomic_store_rel(p, v) @@ -399,10 +436,10 @@ _ATOMIC_SUBTRACT(32, ptr, uintptr_t) * Old/original implementations that still need revisiting. */ -static __inline uint32_t -atomic_readandclear_32(volatile uint32_t *addr) +static __inline u_int +atomic_readandclear_int(volatile u_int *addr) { - uint32_t result,temp; + u_int result,temp; #ifdef __GNUCLIKE_ASM __asm __volatile ( @@ -420,10 +457,10 @@ atomic_readandclear_32(volatile uint32_t *addr) } #ifdef __powerpc64__ -static __inline uint64_t -atomic_readandclear_64(volatile uint64_t *addr) +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) { - uint64_t result,temp; + u_long result,temp; #ifdef __GNUCLIKE_ASM __asm __volatile ( @@ -441,37 +478,25 @@ atomic_readandclear_64(volatile uint64_t *addr) } #endif -#define atomic_readandclear_int atomic_readandclear_32 +#define atomic_readandclear_32 atomic_readandclear_int #ifdef __powerpc64__ -#define atomic_readandclear_long atomic_readandclear_64 -#define atomic_readandclear_ptr atomic_readandclear_64 +#define atomic_readandclear_64 atomic_readandclear_long + +#define atomic_readandclear_ptr(p) \ + atomic_readandclear_long((volatile u_long *)(p)) #else -#define atomic_readandclear_long atomic_readandclear_32 -#define atomic_readandclear_ptr atomic_readandclear_32 +#define atomic_readandclear_long(p) \ + atomic_readandclear_int((volatile u_int *)(p)) + +#define atomic_readandclear_ptr(p) \ + atomic_readandclear_int((volatile u_int *)(p)) #endif /* * We assume that a = b will do atomic loads and stores. */ -#define ATOMIC_STORE_LOAD(TYPE, WIDTH) \ -static __inline u_##TYPE \ -atomic_load_acq_##WIDTH(volatile u_##TYPE *p) \ -{ \ - u_##TYPE v; \ - \ - v = *p; \ - __ATOMIC_BARRIER; \ - return (v); \ -} \ - \ -static __inline void \ -atomic_store_rel_##WIDTH(volatile u_##TYPE *p, u_##TYPE v) \ -{ \ - __ATOMIC_BARRIER; \ - *p = v; \ -} \ - \ +#define ATOMIC_STORE_LOAD(TYPE) \ static __inline u_##TYPE \ atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ { \ @@ -489,25 +514,32 @@ atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) \ *p = v; \ } -ATOMIC_STORE_LOAD(char, 8) -ATOMIC_STORE_LOAD(short, 16) -ATOMIC_STORE_LOAD(int, 32) -#ifdef __powerpc64__ -ATOMIC_STORE_LOAD(long, 64) -#endif +ATOMIC_STORE_LOAD(int) + +#define atomic_load_acq_32 atomic_load_acq_int +#define atomic_store_rel_32 atomic_store_rel_int #ifdef __powerpc64__ -#define atomic_load_acq_long atomic_load_acq_64 -#define atomic_store_rel_long atomic_store_rel_64 -#define atomic_load_acq_ptr atomic_load_acq_64 -#define atomic_store_rel_ptr atomic_store_rel_64 +ATOMIC_STORE_LOAD(long) + +#define atomic_load_acq_64 atomic_load_acq_long +#define atomic_store_rel_64 atomic_store_rel_long + +#define atomic_load_acq_ptr(p) \ + atomic_load_acq_long((volatile u_long *)(p)) +#define atomic_store_rel_ptr(p, v) \ + atomic_store_rel_long((volatile u_long *)(p), (u_long)(v)) #else -#define atomic_load_acq_long atomic_load_acq_32 -#define atomic_store_rel_long atomic_store_rel_32 -#define atomic_load_acq_ptr atomic_load_acq_32 -#define atomic_store_rel_ptr atomic_store_rel_32 -#endif +#define atomic_load_acq_long(p) \ + atomic_load_acq_int((volatile u_int *)(p)) +#define atomic_store_rel_long(p, v) \ + atomic_store_rel_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_load_acq_ptr(p) \ + atomic_load_acq_int((volatile u_int *)(p)) +#define atomic_store_rel_ptr(p, v) \ + atomic_store_rel_int((volatile u_int *)(p), (u_int)(v)) +#endif #undef ATOMIC_STORE_LOAD /* @@ -516,7 +548,7 @@ ATOMIC_STORE_LOAD(long, 64) * zero if the compare failed, nonzero otherwise. */ static __inline int -atomic_cmpset_32(volatile uint32_t* p, uint32_t cmpval, uint32_t newval) +atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) { int ret; @@ -541,6 +573,28 @@ atomic_cmpset_32(volatile uint32_t* p, uint32_t cmpval, uint32_t newval) return (ret); } +static __inline int +atomic_cmpset_acq_int(volatile u_int *p, u_int cmpval, u_int newval) +{ + int retval; + + retval = atomic_cmpset_int(p, cmpval, newval); + __ATOMIC_BARRIER; + return (retval); +} + +static __inline int +atomic_cmpset_rel_int(volatile u_int *p, u_int cmpval, u_int newval) +{ + __ATOMIC_BARRIER; + return (atomic_cmpset_int(p, cmpval, newval)); +} + +#define atomic_cmpset_32 atomic_cmpset_int +#define atomic_cmpset_acq_32 atomic_cmpset_acq_int +#define atomic_cmpset_rel_32 atomic_cmpset_rel_int + +#ifdef __powerpc64__ static __inline int atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) { @@ -548,26 +602,15 @@ atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) #ifdef __GNUCLIKE_ASM __asm __volatile ( - #ifdef __powerpc64__ "1:\tldarx %0, 0, %2\n\t" /* load old value */ "cmpld %3, %0\n\t" /* compare */ "bne 2f\n\t" /* exit if not equal */ "stdcx. %4, 0, %2\n\t" /* attempt to store */ - #else - "1:\tlwarx %0, 0, %2\n\t" /* load old value */ - "cmplw %3, %0\n\t" /* compare */ - "bne 2f\n\t" /* exit if not equal */ - "stwcx. %4, 0, %2\n\t" /* attempt to store */ - #endif "bne- 1b\n\t" /* spin if failed */ "li %0, 1\n\t" /* success - retval = 1 */ "b 3f\n\t" /* we've succeeded */ "2:\n\t" - #ifdef __powerpc64__ "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - #else - "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - #endif "li %0, 0\n\t" /* failure - retval = 0 */ "3:\n\t" : "=&r" (ret), "=m" (*p) @@ -578,33 +621,6 @@ atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) return (ret); } -#define atomic_cmpset_int atomic_cmpset_32 - -#ifdef __powerpc64__ -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) -#else -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) -#endif - -static __inline int -atomic_cmpset_acq_32(volatile uint32_t *p, uint32_t cmpval, uint32_t newval) -{ - int retval; - - retval = atomic_cmpset_32(p, cmpval, newval); - __ATOMIC_BARRIER; - return (retval); -} - -static __inline int -atomic_cmpset_rel_32(volatile uint32_t *p, uint32_t cmpval, uint32_t newval) -{ - __ATOMIC_BARRIER; - return (atomic_cmpset_32(p, cmpval, newval)); -} - static __inline int atomic_cmpset_acq_long(volatile u_long *p, u_long cmpval, u_long newval) { @@ -622,39 +638,59 @@ atomic_cmpset_rel_long(volatile u_long *p, u_long cmpval, u_long newval) return (atomic_cmpset_long(p, cmpval, newval)); } -#define atomic_cmpset_acq_int atomic_cmpset_acq_32 -#define atomic_cmpset_rel_int atomic_cmpset_rel_32 +#define atomic_cmpset_64 atomic_cmpset_long +#define atomic_cmpset_acq_64 atomic_cmpset_acq_long +#define atomic_cmpset_rel_64 atomic_cmpset_rel_long -#ifdef __powerpc64__ -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_long((volatile u_long *)(dst), (u_long)(old), (u_long)(new)) +#define atomic_cmpset_ptr(dst, old, new) \ + atomic_cmpset_long((volatile u_long *)(dst), (u_long)(old), \ + (u_long)(new)) +#define atomic_cmpset_acq_ptr(dst, old, new) \ + atomic_cmpset_acq_long((volatile u_long *)(dst), (u_long)(old), \ + (u_long)(new)) +#define atomic_cmpset_rel_ptr(dst, old, new) \ + atomic_cmpset_rel_long((volatile u_long *)(dst), (u_long)(old), \ + (u_long)(new)) #else -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) +#define atomic_cmpset_long(dst, old, new) \ + atomic_cmpset_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) +#define atomic_cmpset_acq_long(dst, old, new) \ + atomic_cmpset_acq_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) +#define atomic_cmpset_rel_long(dst, old, new) \ + atomic_cmpset_rel_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) + +#define atomic_cmpset_ptr(dst, old, new) \ + atomic_cmpset_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) +#define atomic_cmpset_acq_ptr(dst, old, new) \ + atomic_cmpset_acq_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) +#define atomic_cmpset_rel_ptr(dst, old, new) \ + atomic_cmpset_rel_int((volatile u_int *)(dst), (u_int)(old), \ + (u_int)(new)) #endif -static __inline uint32_t -atomic_fetchadd_32(volatile uint32_t *p, uint32_t v) +static __inline u_int +atomic_fetchadd_int(volatile u_int *p, u_int v) { - uint32_t value; + u_int value; do { value = *p; - } while (!atomic_cmpset_32(p, value, value + v)); + } while (!atomic_cmpset_int(p, value, value + v)); return (value); } -#define atomic_fetchadd_int atomic_fetchadd_32 +#define atomic_fetchadd_32 atomic_fetchadd_int #ifdef __powerpc64__ -static __inline uint64_t -atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) +static __inline u_long +atomic_fetchadd_long(volatile u_long *p, u_long v) { - uint64_t value; + u_long value; do { value = *p; @@ -662,10 +698,10 @@ atomic_fetchadd_64(volatile uint64_t *p, uint64_t v) return (value); } -#define atomic_fetchadd_long atomic_fetchadd_64 +#define atomic_fetchadd_64 atomic_fetchadd_long #else -#define atomic_fetchadd_long(p, v) \ - (u_long)atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_fetchadd_long(p, v) \ + (u_long)atomic_fetchadd_int((volatile u_int *)(p), (u_int)(v)) #endif #endif /* ! _MACHINE_ATOMIC_H_ */ From cf9c204572b33c27e35e696f54133ec1848e9d02 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 8 May 2011 14:23:21 +0000 Subject: [PATCH 023/164] - Fix a typo - Fix an inversion in the logic --- sys/sparc64/sparc64/mp_machdep.c | 2 +- sys/sparc64/sparc64/pmap.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 9bee247d0605..9055d8b520b4 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -497,7 +497,7 @@ cpu_mp_shutdown(void) shutdown_cpus = PCPU_GET(other_cpus); cpus = shutdown_cpus; - /* XXX: Stopp all the CPUs which aren't already. */ + /* XXX: Stop all the CPUs which aren't already. */ if (CPU_CMP(&stopped_cpus, &cpus)) { /* pc_other_cpus is just a flat "on" mask without curcpu. */ diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index 22393a0802ba..49eeae6b6ba6 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -664,7 +664,7 @@ pmap_bootstrap(u_int cpu_impl) pm = kernel_pmap; for (i = 0; i < MAXCPU; i++) pm->pm_context[i] = TLB_CTX_KERNEL; - CPU_ZERO(&pm->pm_active); + CPU_FILL(&pm->pm_active); /* * Flush all non-locked TLB entries possibly left over by the From 10ea4d196652fe0eb9ae279f5d068bf297eae8c6 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 8 May 2011 14:29:25 +0000 Subject: [PATCH 024/164] Revert MAXCPU introduction. In userland it is always 1. Noted by: marcel --- lib/libmemstat/memstat.c | 2 +- lib/libmemstat/memstat.h | 6 ++++++ lib/libmemstat/memstat_internal.h | 4 ++-- lib/libmemstat/memstat_malloc.c | 13 +++++++++---- lib/libmemstat/memstat_uma.c | 5 ++--- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/libmemstat/memstat.c b/lib/libmemstat/memstat.c index b2749e2b4933..1a08d3f4d462 100644 --- a/lib/libmemstat/memstat.c +++ b/lib/libmemstat/memstat.c @@ -193,7 +193,7 @@ _memstat_mt_reset_stats(struct memory_type *mtp) mtp->mt_zonefree = 0; mtp->mt_kegfree = 0; - for (i = 0; i < MAXCPU; i++) { + for (i = 0; i < MEMSTAT_MAXCPU; i++) { mtp->mt_percpu_alloc[i].mtp_memalloced = 0; mtp->mt_percpu_alloc[i].mtp_memfreed = 0; mtp->mt_percpu_alloc[i].mtp_numallocs = 0; diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h index fa269443196e..5267e78aa05e 100644 --- a/lib/libmemstat/memstat.h +++ b/lib/libmemstat/memstat.h @@ -29,6 +29,12 @@ #ifndef _MEMSTAT_H_ #define _MEMSTAT_H_ +/* + * Number of CPU slots in library-internal data structures. This should be + * at least value of MAXCPU from param.h + */ +#define MEMSTAT_MAXCPU 32 + /* * Amount of caller data to maintain for each caller data slot. Applications * must not request more than this number of caller save data, or risk diff --git a/lib/libmemstat/memstat_internal.h b/lib/libmemstat/memstat_internal.h index 8881e585f526..b7fdd7197cfe 100644 --- a/lib/libmemstat/memstat_internal.h +++ b/lib/libmemstat/memstat_internal.h @@ -100,11 +100,11 @@ struct memory_type { uint64_t mtp_sizemask; /* Per-CPU mt_sizemask. */ void *mtp_caller_pointer[MEMSTAT_MAXCALLER]; uint64_t mtp_caller_uint64[MEMSTAT_MAXCALLER]; - } mt_percpu_alloc[MAXCPU]; + } mt_percpu_alloc[MEMSTAT_MAXCPU]; struct { uint64_t mtp_free; /* Per-CPU cache free items. */ - } mt_percpu_cache[MAXCPU]; + } mt_percpu_cache[MEMSTAT_MAXCPU]; LIST_ENTRY(memory_type) mt_list; /* List of types. */ }; diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c index a8d14f87593c..28a48c660546 100644 --- a/lib/libmemstat/memstat_malloc.c +++ b/lib/libmemstat/memstat_malloc.c @@ -96,7 +96,7 @@ memstat_sysctl_malloc(struct memory_type_list *list, int flags) return (-1); } - if (maxcpus > MAXCPU) { + if (maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -160,7 +160,7 @@ memstat_sysctl_malloc(struct memory_type_list *list, int flags) return (-1); } - if (mtshp->mtsh_maxcpus > MAXCPU) { + if (mtshp->mtsh_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); @@ -295,7 +295,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) void *kmemstatistics; int hint_dontsearch, j, mp_maxcpus, ret; char name[MEMTYPE_MAXNAME]; - struct malloc_type_stats mts[MAXCPU], *mtsp; + struct malloc_type_stats mts[MEMSTAT_MAXCPU], *mtsp; struct malloc_type_internal *mtip; struct malloc_type type, *typep; kvm_t *kvm; @@ -322,7 +322,7 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) return (-1); } - if (mp_maxcpus > MAXCPU) { + if (mp_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -348,6 +348,11 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle) list->mtl_error = ret; return (-1); } + + /* + * Since our compile-time value for MAXCPU may differ from the + * kernel's, we populate our own array. + */ mtip = type.ks_handle; ret = kread(kvm, mtip->mti_stats, mts, mp_maxcpus * sizeof(struct malloc_type_stats), 0); diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 302093744b5c..8e2c4e8b0132 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -27,7 +27,6 @@ */ #include -#include #include #define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ @@ -106,7 +105,7 @@ memstat_sysctl_uma(struct memory_type_list *list, int flags) return (-1); } - if (maxcpus > MAXCPU) { + if (maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -170,7 +169,7 @@ memstat_sysctl_uma(struct memory_type_list *list, int flags) return (-1); } - if (ushp->ush_maxcpus > MAXCPU) { + if (ushp->ush_maxcpus > MEMSTAT_MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); From 060cccb5372db4bb6441c43f1c99bfab65c6b010 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 8 May 2011 14:45:53 +0000 Subject: [PATCH 025/164] Fix a mismerge. --- lib/libmemstat/memstat_uma.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 8e2c4e8b0132..485a4f279906 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -27,6 +27,7 @@ */ #include +#include #include #define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ From 76bdb089757672665285495e9f8a29d1fccd1d7d Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 9 May 2011 15:59:34 +0000 Subject: [PATCH 026/164] - Introduce stubs for type-pun from long to int - Don't auto-cast _ptr operations as initially they were intended to be used rarely and consumers had to cast on their own. Reported by: bde, andreast --- sys/powerpc/include/atomic.h | 285 ++++++++++++++++------------------- 1 file changed, 130 insertions(+), 155 deletions(-) diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index cadd4be87d6f..165efcf88e02 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -43,6 +43,31 @@ #define wmb() mb() #define rmb() mb() +#define _ATOMIC_PUN_LTOI(FUNC) \ + static __inline void \ + atomic_##FUNC##_long(volatile u_long *p, u_long v) \ + { \ + \ + atomic_##FUNC##_int((volatile u_int *)p, (u_int)v); \ + } \ + \ + static __inline void \ + atomic_##FUNC##_acq_long(volatile u_long *p, u_long v) \ + { \ + \ + atomic_##FUNC##_acq_int((volatile u_int *)p, \ + (u_int)v); \ + } \ + \ + static __inline void \ + atomic_##FUNC##_rel_long(volatile u_long *p, u_long v) \ + { \ + \ + atomic_##FUNC##_rel_int((volatile u_int *)p, \ + (u_int)v); \ + } \ + /* _ATOMIC_PUN_LTOI */ + /* * atomic_add(p, v) * { *p += v; } @@ -110,26 +135,15 @@ _ATOMIC_ADD(long) #define atomic_add_acq_64 atomic_add_acq_long #define atomic_add_rel_64 atomic_add_rel_long -#define atomic_add_ptr(p, v) \ - atomic_add_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_add_acq_ptr(p, v) \ - atomic_add_acq_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_add_rel_ptr(p, v) \ - atomic_add_rel_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_add_ptr atomic_add_long +#define atomic_add_acq_ptr atomic_add_acq_long +#define atomic_add_rel_ptr atomic_add_rel_long #else -#define atomic_add_long(p, v) \ - atomic_add_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_acq_long(p, v) \ - atomic_add_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_rel_long(p, v) \ - atomic_add_rel_int((volatile u_int *)(p), (u_int)(v)) +_ATOMIC_PUN_LTOI(add) -#define atomic_add_ptr(p, v) \ - atomic_add_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_acq_ptr(p, v) \ - atomic_add_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_rel_ptr(p, v) \ - atomic_add_rel_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_ptr atomic_add_int +#define atomic_add_acq_ptr atomic_add_acq_int +#define atomic_add_rel_ptr atomic_add_rel_int #endif #undef _ATOMIC_ADD #undef __atomic_add_long @@ -203,26 +217,15 @@ _ATOMIC_CLEAR(long) #define atomic_clear_acq_64 atomic_clear_acq_long #define atomic_clear_rel_64 atomic_clear_rel_long -#define atomic_clear_ptr(p, v) \ - atomic_clear_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_clear_acq_ptr(p, v) \ - atomic_clear_acq_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_clear_rel_ptr(p, v) \ - atomic_clear_rel_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_clear_ptr atomic_clear_long +#define atomic_clear_acq_ptr atomic_clear_acq_long +#define atomic_clear_rel_ptr atomic_clear_rel_long #else -#define atomic_clear_long(p, v) \ - atomic_clear_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_clear_acq_long(p, v) \ - atomic_clear_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_clear_rel_long(p, v) \ - atomic_clear_rel_int((volatile u_int *)(p), (u_int)(v)) +_ATOMIC_PUN_LTOI(clear) -#define atomic_clear_ptr(p, v) \ - atomic_clear_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_clear_acq_ptr(p, v) \ - atomic_clear_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_clear_rel_ptr(p, v) \ - atomic_clear_rel_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_ptr atomic_clear_int +#define atomic_clear_acq_ptr atomic_clear_acq_int +#define atomic_clear_rel_ptr atomic_clear_rel_int #endif #undef _ATOMIC_ADD #undef __atomic_clear_long @@ -310,26 +313,15 @@ _ATOMIC_SET(long) #define atomic_set_acq_64 atomic_set_acq_long #define atomic_set_rel_64 atomic_set_rel_long -#define atomic_set_ptr(p, v) \ - atomic_set_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_set_acq_ptr(p, v) \ - atomic_set_acq_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_set_rel_ptr(p, v) \ - atomic_set_rel_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_set_ptr atomic_set_long +#define atomic_set_acq_ptr atomic_set_acq_long +#define atomic_set_rel_ptr atomic_set_rel_long #else -#define atomic_set_long(p, v) \ - atomic_set_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_set_acq_long(p, v) \ - atomic_set_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_set_rel_long(p, v) \ - atomic_set_rel_int((volatile u_int *)(p), (u_int)(v)) +_ATOMIC_PUN_LTOI(set) -#define atomic_set_ptr(p, v) \ - atomic_set_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_set_acq_ptr(p, v) \ - atomic_set_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_set_rel_ptr(p, v) \ - atomic_set_rel_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_ptr atomic_set_int +#define atomic_set_acq_ptr atomic_set_acq_int +#define atomic_set_rel_ptr atomic_set_rel_int #endif #undef _ATOMIC_SET #undef __atomic_set_long @@ -402,31 +394,22 @@ _ATOMIC_SUBTRACT(long) #define atomic_subtract_acq_64 atomic_subract_acq_long #define atomic_subtract_rel_64 atomic_subtract_rel_long -#define atomic_subtract_ptr(p, v) \ - atomic_subtract_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_subtract_acq_ptr(p, v) \ - atomic_subtract_acq_long((volatile u_long *)(p), (u_long)(v)) -#define atomic_subtract_rel_ptr(p, v) \ - atomic_subtract_rel_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_subtract_ptr atomic_subtract_long +#define atomic_subtract_acq_ptr atomic_subtract_acq_long +#define atomic_subtract_rel_ptr atomic_subtract_rel_long #else -#define atomic_subtract_long(p, v) \ - atomic_subtract_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_acq_long(p, v) \ - atomic_subtract_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_rel_long(p, v) \ - atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) +_ATOMIC_PUN_LTOI(subtract) -#define atomic_subtract_ptr(p, v) \ - atomic_subtract_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_acq_ptr(p, v) \ - atomic_subtract_acq_int((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_rel_ptr(p, v) \ - atomic_subtract_rel_int((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_ptr atomic_subtract_int +#define atomic_subtract_acq_ptr atomic_subtract_acq_int +#define atomic_subtract_rel_ptr atomic_subtract_rel_int #endif #undef _ATOMIC_SUBTRACT #undef __atomic_subtract_long #undef __atomic_subtract_int +#undef _ATOMIC_PUN_LTOI + /* * atomic_store_rel(p, v) */ @@ -483,14 +466,16 @@ atomic_readandclear_long(volatile u_long *addr) #ifdef __powerpc64__ #define atomic_readandclear_64 atomic_readandclear_long -#define atomic_readandclear_ptr(p) \ - atomic_readandclear_long((volatile u_long *)(p)) +#define atomic_readandclear_ptr atomic_readandclear_long #else -#define atomic_readandclear_long(p) \ - atomic_readandclear_int((volatile u_int *)(p)) +static __inline u_long +atomic_readandclear_long(volatile u_long *addr) +{ -#define atomic_readandclear_ptr(p) \ - atomic_readandclear_int((volatile u_int *)(p)) + return ((u_long)atomic_readandclear_int((volatile u_int *)addr)); +} + +#define atomic_readandclear_ptr atomic_readandclear_int #endif /* @@ -525,20 +510,25 @@ ATOMIC_STORE_LOAD(long) #define atomic_load_acq_64 atomic_load_acq_long #define atomic_store_rel_64 atomic_store_rel_long -#define atomic_load_acq_ptr(p) \ - atomic_load_acq_long((volatile u_long *)(p)) -#define atomic_store_rel_ptr(p, v) \ - atomic_store_rel_long((volatile u_long *)(p), (u_long)(v)) +#define atomic_load_acq_ptr atomic_load_acq_long +#define atomic_store_rel_ptr atomic_store_rel_long #else -#define atomic_load_acq_long(p) \ - atomic_load_acq_int((volatile u_int *)(p)) -#define atomic_store_rel_long(p, v) \ - atomic_store_rel_int((volatile u_int *)(p), (u_int)(v)) +static __inline u_long +atomic_load_acq_long(volatile u_long *addr) +{ -#define atomic_load_acq_ptr(p) \ - atomic_load_acq_int((volatile u_int *)(p)) -#define atomic_store_rel_ptr(p, v) \ - atomic_store_rel_int((volatile u_int *)(p), (u_int)(v)) + return ((u_long)atomic_load_acq_int((volatile u_int *)addr)); +} + +static __inline void +atomic_store_rel_long(volatile u_long *addr, u_long val) +{ + + atomic_store_rel_int((volatile u_int *)addr, (u_int)val); +} + +#define atomic_load_acq_ptr atomic_load_acq_int +#define atomic_store_rel_ptr atomic_store_rel_int #endif #undef ATOMIC_STORE_LOAD @@ -572,6 +562,42 @@ atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) return (ret); } +static __inline int +atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) +{ + int ret; + +#ifdef __GNUCLIKE_ASM + __asm __volatile ( + #ifdef __powerpc64__ + "1:\tldarx %0, 0, %2\n\t" /* load old value */ + "cmpld %3, %0\n\t" /* compare */ + "bne 2f\n\t" /* exit if not equal */ + "stdcx. %4, 0, %2\n\t" /* attempt to store */ + #else + "1:\tlwarx %0, 0, %2\n\t" /* load old value */ + "cmplw %3, %0\n\t" /* compare */ + "bne 2f\n\t" /* exit if not equal */ + "stwcx. %4, 0, %2\n\t" /* attempt to store */ + #endif + "bne- 1b\n\t" /* spin if failed */ + "li %0, 1\n\t" /* success - retval = 1 */ + "b 3f\n\t" /* we've succeeded */ + "2:\n\t" + #ifdef __powerpc64__ + "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + #else + "stwcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ + #endif + "li %0, 0\n\t" /* failure - retval = 0 */ + "3:\n\t" + : "=&r" (ret), "=m" (*p) + : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) + : "cc", "memory"); +#endif + + return (ret); +} static __inline int atomic_cmpset_acq_int(volatile u_int *p, u_int cmpval, u_int newval) @@ -590,37 +616,6 @@ atomic_cmpset_rel_int(volatile u_int *p, u_int cmpval, u_int newval) return (atomic_cmpset_int(p, cmpval, newval)); } -#define atomic_cmpset_32 atomic_cmpset_int -#define atomic_cmpset_acq_32 atomic_cmpset_acq_int -#define atomic_cmpset_rel_32 atomic_cmpset_rel_int - -#ifdef __powerpc64__ -static __inline int -atomic_cmpset_long(volatile u_long* p, u_long cmpval, u_long newval) -{ - int ret; - -#ifdef __GNUCLIKE_ASM - __asm __volatile ( - "1:\tldarx %0, 0, %2\n\t" /* load old value */ - "cmpld %3, %0\n\t" /* compare */ - "bne 2f\n\t" /* exit if not equal */ - "stdcx. %4, 0, %2\n\t" /* attempt to store */ - "bne- 1b\n\t" /* spin if failed */ - "li %0, 1\n\t" /* success - retval = 1 */ - "b 3f\n\t" /* we've succeeded */ - "2:\n\t" - "stdcx. %0, 0, %2\n\t" /* clear reservation (74xx) */ - "li %0, 0\n\t" /* failure - retval = 0 */ - "3:\n\t" - : "=&r" (ret), "=m" (*p) - : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) - : "cc", "memory"); -#endif - - return (ret); -} - static __inline int atomic_cmpset_acq_long(volatile u_long *p, u_long cmpval, u_long newval) { @@ -638,39 +633,22 @@ atomic_cmpset_rel_long(volatile u_long *p, u_long cmpval, u_long newval) return (atomic_cmpset_long(p, cmpval, newval)); } +#define atomic_cmpset_32 atomic_cmpset_int +#define atomic_cmpset_acq_32 atomic_cmpset_acq_int +#define atomic_cmpset_rel_32 atomic_cmpset_rel_int + +#ifdef __powerpc64__ #define atomic_cmpset_64 atomic_cmpset_long #define atomic_cmpset_acq_64 atomic_cmpset_acq_long #define atomic_cmpset_rel_64 atomic_cmpset_rel_long -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_long((volatile u_long *)(dst), (u_long)(old), \ - (u_long)(new)) -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_long((volatile u_long *)(dst), (u_long)(old), \ - (u_long)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_long((volatile u_long *)(dst), (u_long)(old), \ - (u_long)(new)) +#define atomic_cmpset_ptr atomic_cmpset_long +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long #else -#define atomic_cmpset_long(dst, old, new) \ - atomic_cmpset_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) -#define atomic_cmpset_acq_long(dst, old, new) \ - atomic_cmpset_acq_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) -#define atomic_cmpset_rel_long(dst, old, new) \ - atomic_cmpset_rel_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) - -#define atomic_cmpset_ptr(dst, old, new) \ - atomic_cmpset_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) -#define atomic_cmpset_acq_ptr(dst, old, new) \ - atomic_cmpset_acq_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) -#define atomic_cmpset_rel_ptr(dst, old, new) \ - atomic_cmpset_rel_int((volatile u_int *)(dst), (u_int)(old), \ - (u_int)(new)) +#define atomic_cmpset_ptr atomic_cmpset_int +#define atomic_cmpset_acq_ptr atomic_cmpset_acq_int +#define atomic_cmpset_rel_ptr atomic_cmpset_rel_int #endif static __inline u_int @@ -684,9 +662,6 @@ atomic_fetchadd_int(volatile u_int *p, u_int v) return (value); } -#define atomic_fetchadd_32 atomic_fetchadd_int - -#ifdef __powerpc64__ static __inline u_long atomic_fetchadd_long(volatile u_long *p, u_long v) { @@ -698,10 +673,10 @@ atomic_fetchadd_long(volatile u_long *p, u_long v) return (value); } +#define atomic_fetchadd_32 atomic_fetchadd_int + +#ifdef __powerpc64__ #define atomic_fetchadd_64 atomic_fetchadd_long -#else -#define atomic_fetchadd_long(p, v) \ - (u_long)atomic_fetchadd_int((volatile u_int *)(p), (u_int)(v)) #endif #endif /* ! _MACHINE_ATOMIC_H_ */ From 804b67ba6f3c9599eb747562e13e498f7111cbb4 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 9 May 2011 16:16:15 +0000 Subject: [PATCH 027/164] Add the powerpc support. Note that there is a dirty hack for calling openpic_write(), but nwhitehorn approved it. Discussed with: nwhitehorn --- sys/powerpc/aim/mmu_oea.c | 13 ++++++++++--- sys/powerpc/aim/mmu_oea64.c | 13 ++++++++++--- sys/powerpc/booke/pmap.c | 10 ++++++---- sys/powerpc/include/_types.h | 1 - sys/powerpc/include/openpicvar.h | 2 +- sys/powerpc/include/pmap.h | 5 +++-- sys/powerpc/include/smp.h | 4 +++- sys/powerpc/powerpc/intr_machdep.c | 7 ++++--- sys/powerpc/powerpc/mp_machdep.c | 26 ++++++++++++++------------ sys/powerpc/powerpc/openpic.c | 9 +++++++-- sys/powerpc/powerpc/pic_if.m | 3 ++- 11 files changed, 60 insertions(+), 33 deletions(-) diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c index 30435f527fd6..441014106524 100644 --- a/sys/powerpc/aim/mmu_oea.c +++ b/sys/powerpc/aim/mmu_oea.c @@ -118,11 +118,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -838,7 +841,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) PMAP_LOCK_INIT(kernel_pmap); for (i = 0; i < 16; i++) kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i; - kernel_pmap->pm_active = ~0; + CPU_FILL(&kernel_pmap->pm_active); /* * Set up the Open Firmware mappings @@ -960,7 +963,9 @@ moea_activate(mmu_t mmu, struct thread *td) pm = &td->td_proc->p_vmspace->vm_pmap; pmr = pm->pmap_phys; - pm->pm_active |= PCPU_GET(cpumask); + sched_pin(); + CPU_OR(&pm->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); PCPU_SET(curpmap, pmr); } @@ -970,7 +975,9 @@ moea_deactivate(mmu_t mmu, struct thread *td) pmap_t pm; pm = &td->td_proc->p_vmspace->vm_pmap; - pm->pm_active &= ~PCPU_GET(cpumask); + sched_pin(); + CPU_NAND(&pm->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); PCPU_SET(curpmap, NULL); } diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index d20de530455b..775a17c53e38 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -118,11 +118,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -845,7 +848,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend) #endif kernel_pmap->pmap_phys = kernel_pmap; - kernel_pmap->pm_active = ~0; + CPU_FILL(&kernel_pmap->pm_active); PMAP_LOCK_INIT(kernel_pmap); @@ -1013,7 +1016,9 @@ moea64_activate(mmu_t mmu, struct thread *td) pmap_t pm; pm = &td->td_proc->p_vmspace->vm_pmap; - pm->pm_active |= PCPU_GET(cpumask); + sched_pin(); + CPU_OR(&pm->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); #ifdef __powerpc64__ PCPU_SET(userslb, pm->pm_slb); @@ -1028,7 +1033,9 @@ moea64_deactivate(mmu_t mmu, struct thread *td) pmap_t pm; pm = &td->td_proc->p_vmspace->vm_pmap; - pm->pm_active &= ~(PCPU_GET(cpumask)); + sched_pin(); + CPU_NAND(&pm->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); #ifdef __powerpc64__ PCPU_SET(userslb, NULL); #else diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 2fffa3f14b96..7fd55f84e184 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -1228,7 +1228,7 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend) PTE_VALID; } /* Mark kernel_pmap active on all CPUs */ - kernel_pmap->pm_active = ~0; + CPU_FILL(&kernel_pmap->pm_active); /*******************************************************/ /* Final setup */ @@ -1483,7 +1483,7 @@ mmu_booke_pinit(mmu_t mmu, pmap_t pmap) PMAP_LOCK_INIT(pmap); for (i = 0; i < MAXCPU; i++) pmap->pm_tid[i] = TID_NONE; - pmap->pm_active = 0; + CPU_ZERO(&kernel_pmap->pm_active); bzero(&pmap->pm_stats, sizeof(pmap->pm_stats)); bzero(&pmap->pm_pdir, sizeof(pte_t *) * PDIR_NENTRIES); TAILQ_INIT(&pmap->pm_ptbl_list); @@ -1838,7 +1838,7 @@ mmu_booke_activate(mmu_t mmu, struct thread *td) mtx_lock_spin(&sched_lock); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); PCPU_SET(curpmap, pmap); if (pmap->pm_tid[PCPU_GET(cpuid)] == TID_NONE) @@ -1867,7 +1867,9 @@ mmu_booke_deactivate(mmu_t mmu, struct thread *td) CTR5(KTR_PMAP, "%s: td=%p, proc = '%s', id = %d, pmap = 0x%08x", __func__, td, td->td_proc->p_comm, td->td_proc->p_pid, pmap); - atomic_clear_int(&pmap->pm_active, PCPU_GET(cpumask)); + sched_pin(); + CPU_NAND_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); + sched_unpin(); PCPU_SET(curpmap, NULL); } diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h index fae241676ad3..b0b582e7080b 100644 --- a/sys/powerpc/include/_types.h +++ b/sys/powerpc/include/_types.h @@ -72,7 +72,6 @@ typedef unsigned long long __uint64_t; * Standard type definitions. */ typedef __uint32_t __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef double __double_t; typedef double __float_t; #ifdef __LP64__ diff --git a/sys/powerpc/include/openpicvar.h b/sys/powerpc/include/openpicvar.h index 4fb9aa73bba4..605dc0f8daa3 100644 --- a/sys/powerpc/include/openpicvar.h +++ b/sys/powerpc/include/openpicvar.h @@ -57,7 +57,7 @@ int openpic_common_attach(device_t, uint32_t); /* * PIC interface. */ -void openpic_bind(device_t dev, u_int irq, cpumask_t cpumask); +void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask); void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity); void openpic_dispatch(device_t, struct trapframe *); void openpic_enable(device_t, u_int, u_int); diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h index 369ca9d97d60..9166d04ba7d9 100644 --- a/sys/powerpc/include/pmap.h +++ b/sys/powerpc/include/pmap.h @@ -66,6 +66,7 @@ #include #include +#include #include #include #include @@ -98,7 +99,7 @@ struct pmap { #else register_t pm_sr[16]; #endif - cpumask_t pm_active; + cpuset_t pm_active; struct pmap *pmap_phys; struct pmap_statistics pm_stats; @@ -175,7 +176,7 @@ void slb_free_user_cache(struct slb **); struct pmap { struct mtx pm_mtx; /* pmap mutex */ tlbtid_t pm_tid[MAXCPU]; /* TID to identify this pmap entries in TLB */ - cpumask_t pm_active; /* active on cpus */ + cpuset_t pm_active; /* active on cpus */ struct pmap_statistics pm_stats; /* pmap statistics */ /* Page table directory, array of pointers to page tables. */ diff --git a/sys/powerpc/include/smp.h b/sys/powerpc/include/smp.h index cf952788c680..32fcfb4b8f60 100644 --- a/sys/powerpc/include/smp.h +++ b/sys/powerpc/include/smp.h @@ -40,9 +40,11 @@ #ifndef LOCORE +#include + void ipi_all_but_self(int ipi); void ipi_cpu(int cpu, u_int ipi); -void ipi_selected(cpumask_t cpus, int ipi); +void ipi_selected(cpuset_t cpus, int ipi); struct cpuref { uintptr_t cr_hwref; diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c index b76ca41304ff..2026b05bc16f 100644 --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -98,7 +99,7 @@ struct powerpc_intr { u_int intline; u_int vector; u_int cntindex; - cpumask_t cpu; + cpuset_t cpu; enum intr_trigger trig; enum intr_polarity pol; }; @@ -205,7 +206,7 @@ intr_lookup(u_int irq) #ifdef SMP i->cpu = all_cpus; #else - i->cpu = 1; + CPU_SETOF(0, &i->cpu); #endif for (vector = 0; vector < INTR_VECTORS && vector <= nvectors; @@ -296,7 +297,7 @@ powerpc_assign_intr_cpu(void *arg, u_char cpu) if (cpu == NOCPU) i->cpu = all_cpus; else - i->cpu = 1 << cpu; + CPU_SETOF(cpu, &i->cpu); if (!cold && i->pic != NULL && i->pic == root_pic) PIC_BIND(i->pic, i->intline, i->cpu); diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 02920da3dfa8..2e2fe24c1c13 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -157,7 +158,7 @@ cpu_mp_start(void) cpu.cr_cpuid); goto next; } - if (all_cpus & (1 << cpu.cr_cpuid)) { + if (CPU_ISSET(cpu.cr_cpuid, &all_cpus)) { printf("SMP: cpu%d: skipped - duplicate ID\n", cpu.cr_cpuid); goto next; @@ -174,9 +175,9 @@ cpu_mp_start(void) pc->pc_cpuid = bsp.cr_cpuid; pc->pc_bsp = 1; } - pc->pc_cpumask = 1 << pc->pc_cpuid; + CPU_SETOF(pc->pc_cpuid, &pc->pc_cpumask); pc->pc_hwref = cpu.cr_hwref; - all_cpus |= pc->pc_cpumask; + CPU_OR(&all_cpus, &pc->pc_cpumask); next: error = platform_smp_next_cpu(&cpu); } @@ -214,7 +215,8 @@ cpu_mp_unleash(void *dummy) smp_cpus = 0; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { cpus++; - pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask; + pc->pc_other_cpus = all_cpus; + CPU_NAND(&pc->pc_other_cpus, &pc->pc_cpumask); if (!pc->pc_bsp) { if (bootverbose) printf("Waking up CPU %d (dev=%x)\n", @@ -236,7 +238,7 @@ cpu_mp_unleash(void *dummy) pc->pc_cpuid, pc->pc_pir, pc->pc_awake); smp_cpus++; } else - stopped_cpus |= (1 << pc->pc_cpuid); + CPU_SET(pc->pc_cpuid, &stopped_cpus); } ap_awake = 1; @@ -276,7 +278,7 @@ SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL); int powerpc_ipi_handler(void *arg) { - cpumask_t self; + cpuset_t self; uint32_t ipimask; int msg; @@ -311,11 +313,11 @@ powerpc_ipi_handler(void *arg) savectx(&stoppcbs[PCPU_GET(cpuid)]); self = PCPU_GET(cpumask); savectx(PCPU_GET(curpcb)); - atomic_set_int(&stopped_cpus, self); - while ((started_cpus & self) == 0) + CPU_OR_ATOMIC(&stopped_cpus, &self); + while (!CPU_OVERLAP(&started_cpus, &self)) cpu_spinwait(); - atomic_clear_int(&started_cpus, self); - atomic_clear_int(&stopped_cpus, self); + CPU_NAND_ATOMIC(&started_cpus, &self); + CPU_NAND_ATOMIC(&stopped_cpus, &self); CTR1(KTR_SMP, "%s: IPI_STOP (restart)", __func__); break; case IPI_HARDCLOCK: @@ -343,12 +345,12 @@ ipi_send(struct pcpu *pc, int ipi) /* Send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, int ipi) +ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { - if (cpus & pc->pc_cpumask) + if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) ipi_send(pc, ipi); } } diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c index 042f8b846fa1..edccf61c713b 100644 --- a/sys/powerpc/powerpc/openpic.c +++ b/sys/powerpc/powerpc/openpic.c @@ -231,7 +231,7 @@ openpic_common_attach(device_t dev, uint32_t node) */ void -openpic_bind(device_t dev, u_int irq, cpumask_t cpumask) +openpic_bind(device_t dev, u_int irq, cpuset_t cpumask) { struct openpic_softc *sc; @@ -240,7 +240,12 @@ openpic_bind(device_t dev, u_int irq, cpumask_t cpumask) return; sc = device_get_softc(dev); - openpic_write(sc, OPENPIC_IDEST(irq), cpumask); + + /* + * XXX: openpic_write() is very special and just needs a 32 bits mask. + * For the moment, just play dirty and get the first half word. + */ + openpic_write(sc, OPENPIC_IDEST(irq), (long)cpumask & 0xffffffff); } void diff --git a/sys/powerpc/powerpc/pic_if.m b/sys/powerpc/powerpc/pic_if.m index 185cc0887796..e429d31f5038 100644 --- a/sys/powerpc/powerpc/pic_if.m +++ b/sys/powerpc/powerpc/pic_if.m @@ -28,6 +28,7 @@ # #include +#include #include INTERFACE pic; @@ -35,7 +36,7 @@ INTERFACE pic; METHOD void bind { device_t dev; u_int irq; - cpumask_t cpumask; + cpuset_t cpumask; }; METHOD void config { From d7cb9e4814bba4248531bd7a258d2ec72da2ebaf Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 9 May 2011 18:53:13 +0000 Subject: [PATCH 028/164] MFC --- sys/amd64/include/clock.h | 1 - sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 3 +- sys/dev/ath/ath_hal/ar9002/ar9285_attach.c | 3 +- sys/dev/ath/ath_hal/ar9002/ar9285_phy.c | 18 ++- sys/dev/ath/ath_hal/ar9002/ar9285_phy.h | 2 +- sys/dev/bxe/if_bxe.c | 125 ++++++++++---------- sys/dev/bxe/if_bxe.h | 4 +- sys/dev/syscons/syscons.c | 98 +++++++++++++--- sys/dev/syscons/syscons.h | 1 - sys/i386/include/clock.h | 1 - sys/isa/syscons_isa.c | 127 --------------------- sys/pc98/cbus/syscons_cbus.c | 54 --------- sys/x86/isa/clock.c | 1 - sys/x86/x86/tsc.c | 85 ++++++++++++-- 14 files changed, 238 insertions(+), 285 deletions(-) diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index b50ed659e620..d2602d88f4f4 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -29,7 +29,6 @@ void i8254_init(void); void startrtclock(void); void init_TSC(void); -void init_TSC_tc(void); #define HAS_TIMER_SPKR 1 int timer_spkr_acquire(void); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index 21c0ad66446d..d1ccfc4f9f09 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -1296,7 +1296,8 @@ ar5416InitChainMasks(struct ath_hal *ah) { int rx_chainmask = AH5416(ah)->ah_rx_chainmask; - if (rx_chainmask) + /* Flip this for this chainmask regardless of chip */ + if (rx_chainmask == 0x5) OS_REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP, AR_PHY_SWAP_ALT_CHAIN); /* diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c b/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c index 653b586e77fb..129f094079f5 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_attach.c @@ -401,8 +401,9 @@ ar9285FillCapabilityInfo(struct ath_hal *ah) if (AR_SREV_KITE_12_OR_LATER(ah)) pCap->halPSPollBroken = AH_FALSE; + /* Only RX STBC supported */ pCap->halRxStbcSupport = 1; - pCap->halTxStbcSupport = 1; + pCap->halTxStbcSupport = 0; return AH_TRUE; } diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c b/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c index e9c2c55b5f68..e4e73d47f080 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c @@ -75,24 +75,30 @@ ar9285_antdiv_comb_conf_set(struct ath_hal *ah, } /* - * Check whether antenna diversity should be enabled + * Check whether combined + fast antenna diversity should be enabled. + * + * This enables software-driven RX antenna diversity based on RX + * RSSI + antenna config packet sampling. */ -int +HAL_BOOL ar9285_check_div_comb(struct ath_hal *ah) { uint8_t ant_div_ctl1; HAL_EEPROM_v4k *ee = AH_PRIVATE(ah)->ah_eeprom; const MODAL_EEP4K_HEADER *pModal = &ee->ee_base.modalHeader; + /* For now, simply disable this until it's better debugged. -adrian */ + return AH_FALSE; + if (! AR_SREV_KITE(ah)) - return 0; + return AH_FALSE; if (pModal->version < 3) - return 0; + return AH_FALSE; ant_div_ctl1 = pModal->antdiv_ctl1; if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) - return 1; + return AH_TRUE; - return 0; + return AH_FALSE; } diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h b/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h index 3ddad1402056..b2367185f105 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h @@ -41,6 +41,6 @@ extern void ar9285_antdiv_comb_conf_set(struct ath_hal *ah, struct ar9285_antcomb_conf *antconf); extern void ar9285_antdiv_comb_conf_get(struct ath_hal *ah, struct ar9285_antcomb_conf *antconf); -extern int ar9285_check_div_comb(struct ath_hal *ah); +extern HAL_BOOL ar9285_check_div_comb(struct ath_hal *ah); #endif diff --git a/sys/dev/bxe/if_bxe.c b/sys/dev/bxe/if_bxe.c index 05ed74719f4c..6b24dc48c2f4 100644 --- a/sys/dev/bxe/if_bxe.c +++ b/sys/dev/bxe/if_bxe.c @@ -3323,7 +3323,7 @@ bxe_stop_locked(struct bxe_softc *sc, int unload_mode) bxe_set_mac_addr_e1(sc, 0); for (i = 0; i < config->hdr.length; i++) - CAM_INVALIDATE(config->config_table[i]); + CAM_INVALIDATE(&config->config_table[i]); config->hdr.length = i; config->hdr.offset = BXE_MAX_MULTICAST * (1 + port); @@ -14254,6 +14254,8 @@ static void bxe_set_mac_addr_e1(struct bxe_softc *sc, int set) { struct mac_configuration_cmd *config; + struct mac_configuration_entry *config_table; + uint8_t *eaddr; int port; DBENTER(BXE_VERBOSE_MISC); @@ -14274,43 +14276,40 @@ bxe_set_mac_addr_e1(struct bxe_softc *sc, int set) config->hdr.reserved1 = 0; /* Program the primary MAC address. */ - config->config_table[0].cam_entry.msb_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[0]); - config->config_table[0].cam_entry.middle_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[2]); - config->config_table[0].cam_entry.lsb_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[4]); - config->config_table[0].cam_entry.flags = htole16(port); + config_table = &config->config_table[0]; + eaddr = sc->link_params.mac_addr; + config_table->cam_entry.msb_mac_addr = eaddr[0] << 8 | eaddr[1]; + config_table->cam_entry.middle_mac_addr = eaddr[2] << 8 | eaddr[3]; + config_table->cam_entry.lsb_mac_addr = eaddr[4] << 8 | eaddr[5]; + config_table->cam_entry.flags = htole16(port); if (set) - config->config_table[0].target_table_entry.flags = 0; + config_table->target_table_entry.flags = 0; else - CAM_INVALIDATE(config->config_table[0]); + CAM_INVALIDATE(config_table); - /* t48 config->config_table[0].target_table_entry.client_id = 0; */ - config->config_table[0].target_table_entry.vlan_id = 0; + config_table->target_table_entry.vlan_id = 0; DBPRINT(sc, BXE_VERBOSE, "%s(): %s MAC (%04x:%04x:%04x)\n", __FUNCTION__, (set ? "Setting" : "Clearing"), - config->config_table[0].cam_entry.msb_mac_addr, - config->config_table[0].cam_entry.middle_mac_addr, - config->config_table[0].cam_entry.lsb_mac_addr); + config_table->cam_entry.msb_mac_addr, + config_table->cam_entry.middle_mac_addr, + config_table->cam_entry.lsb_mac_addr); /* Program the broadcast MAC address. */ - config->config_table[1].cam_entry.msb_mac_addr = 0xffff; - config->config_table[1].cam_entry.middle_mac_addr = 0xffff; - config->config_table[1].cam_entry.lsb_mac_addr = 0xffff; - config->config_table[1].cam_entry.flags = htole16(port); + config_table = &config->config_table[1]; + config_table->cam_entry.msb_mac_addr = 0xffff; + config_table->cam_entry.middle_mac_addr = 0xffff; + config_table->cam_entry.lsb_mac_addr = 0xffff; + config_table->cam_entry.flags = htole16(port); if (set) - config->config_table[1].target_table_entry.flags = + config_table->target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_BROADCAST; else - CAM_INVALIDATE(config->config_table[1]); - - /*t48 config->config_table[1].target_table_entry.client_id = 0; */ - config->config_table[1].target_table_entry.vlan_id = 0; + CAM_INVALIDATE(config_table); + config_table->target_table_entry.vlan_id = 0; /* Post the command to slow path queue. */ bxe_sp_post(sc, RAMROD_CMD_ID_ETH_SET_MAC, 0, @@ -14330,6 +14329,8 @@ static void bxe_set_mac_addr_e1h(struct bxe_softc *sc, int set) { struct mac_configuration_cmd_e1h *config; + struct mac_configuration_entry_e1h *config_table; + uint8_t *eaddr; int func, port; DBENTER(BXE_VERBOSE_MISC); @@ -14356,30 +14357,27 @@ bxe_set_mac_addr_e1h(struct bxe_softc *sc, int set) config->hdr.reserved1 = 0; /* Program the primary MAC address. */ - config->config_table[0].msb_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[0]); - config->config_table[0].middle_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[2]); - config->config_table[0].lsb_mac_addr = - ntohs(*(uint16_t *)&sc->link_params.mac_addr[4]); - config->config_table[0].clients_bit_vector = - htole32(1 << sc->fp->cl_id); + config_table = &config->config_table[0]; + eaddr = sc->link_params.mac_addr; + config_table->msb_mac_addr = eaddr[0] << 8 | eaddr[1]; + config_table->middle_mac_addr = eaddr[2] << 8 | eaddr[3]; + config_table->lsb_mac_addr = eaddr[4] << 8 | eaddr[5]; + config_table->clients_bit_vector = htole32(1 << sc->fp->cl_id); - config->config_table[0].vlan_id = 0; - config->config_table[0].e1hov_id = htole16(sc->e1hov); + config_table->vlan_id = 0; + config_table->e1hov_id = htole16(sc->e1hov); if (set) - config->config_table[0].flags = port; + config_table->flags = port; else - config->config_table[0].flags = + config_table->flags = MAC_CONFIGURATION_ENTRY_E1H_ACTION_TYPE; DBPRINT(sc, BXE_VERBOSE_MISC, "%s(): %s MAC (%04x:%04x:%04x), E1HOV = %d, CLID = %d\n", __FUNCTION__, (set ? "Setting" : "Clearing"), - config->config_table[0].msb_mac_addr, - config->config_table[0].middle_mac_addr, - config->config_table[0].lsb_mac_addr, sc->e1hov, BP_L_ID(sc)); + config_table->msb_mac_addr, config_table->middle_mac_addr, + config_table->lsb_mac_addr, sc->e1hov, BP_L_ID(sc)); bxe_sp_post(sc, RAMROD_CMD_ID_ETH_SET_MAC, 0, U64_HI(BXE_SP_MAPPING(sc, mac_config)), @@ -14402,7 +14400,9 @@ bxe_set_rx_mode(struct bxe_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; struct mac_configuration_cmd *config; + struct mac_configuration_entry *config_table; uint32_t mc_filter[MC_HASH_SIZE]; + uint8_t *maddr; uint32_t crc, bit, regidx, rx_mode; int i, old, offset, port; @@ -14431,8 +14431,8 @@ bxe_set_rx_mode(struct bxe_softc *sc) /* Enable promiscuous mode. */ rx_mode = BXE_RX_MODE_PROMISC; - } else if ((ifp->if_flags & IFF_ALLMULTI) || - (ifp->if_amcount > BXE_MAX_MULTICAST)) { + } else if (ifp->if_flags & IFF_ALLMULTI || + ifp->if_amcount > BXE_MAX_MULTICAST) { DBPRINT(sc, BXE_VERBOSE_MISC, "%s(): Enabling all multicast mode.\n", __FUNCTION__); @@ -14453,28 +14453,28 @@ bxe_set_rx_mode(struct bxe_softc *sc) TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; - - config->config_table[i].cam_entry.msb_mac_addr = - bswap16(*(uint32_t *)(LLADDR((struct sockaddr_dl *)ifma->ifma_addr))); - config->config_table[i].cam_entry.middle_mac_addr = - bswap16(*(uint16_t *)(LLADDR((struct sockaddr_dl *)ifma->ifma_addr) + 2)); - config->config_table[i].cam_entry.lsb_mac_addr = - bswap16(*(uint16_t *)(LLADDR((struct sockaddr_dl *)ifma->ifma_addr) + 4)); - - config->config_table[i].cam_entry.flags = htole16(port); - config->config_table[i].target_table_entry.flags = 0; - config->config_table[i].target_table_entry. - clients_bit_vector = htole32(1 << BP_L_ID(sc)); - config->config_table[i].target_table_entry.vlan_id = 0; - + maddr = (uint8_t *)LLADDR( + (struct sockaddr_dl *)ifma->ifma_addr); + config_table = &config->config_table[i]; + config_table->cam_entry.msb_mac_addr = + maddr[0] << 8 | maddr[1]; + config_table->cam_entry.middle_mac_addr = + maddr[2] << 8 | maddr[3]; + config_table->cam_entry.lsb_mac_addr = + maddr[4] << 8 | maddr[5]; + config_table->cam_entry.flags = htole16(port); + config_table->target_table_entry.flags = 0; + config_table->target_table_entry. + clients_bit_vector = + htole32(1 << BP_L_ID(sc)); + config_table->target_table_entry.vlan_id = 0; i++; - DBPRINT(sc, BXE_INFO, "%s(): Setting MCAST[%d] (%04X:%04X:%04X)\n", __FUNCTION__, i, - config->config_table[i].cam_entry.msb_mac_addr, - config->config_table[i].cam_entry.middle_mac_addr, - config->config_table[i].cam_entry.lsb_mac_addr); + config_table->cam_entry.msb_mac_addr, + config_table->cam_entry.middle_mac_addr, + config_table->cam_entry.lsb_mac_addr); } IF_ADDR_UNLOCK(ifp); @@ -14484,11 +14484,11 @@ bxe_set_rx_mode(struct bxe_softc *sc) /* Invalidate any extra MC entries in the CAM. */ if (old > i) { for (; i < old; i++) { - if (CAM_IS_INVALID( - config->config_table[i])) + config_table = &config->config_table[i]; + if (CAM_IS_INVALID(config_table)) break; /* Invalidate */ - CAM_INVALIDATE(config->config_table[i]); + CAM_INVALIDATE(config_table); } } @@ -14501,7 +14501,6 @@ bxe_set_rx_mode(struct bxe_softc *sc) bxe_sp_post(sc, RAMROD_CMD_ID_ETH_SET_MAC, 0, U64_HI(BXE_SP_MAPPING(sc, mcast_config)), U64_LO(BXE_SP_MAPPING(sc, mcast_config)), 0); - } else { /* E1H */ /* Accept one or more multicasts */ memset(mc_filter, 0, 4 * MC_HASH_SIZE); diff --git a/sys/dev/bxe/if_bxe.h b/sys/dev/bxe/if_bxe.h index cb3e9c7745e5..4f8528faa50b 100644 --- a/sys/dev/bxe/if_bxe.h +++ b/sys/dev/bxe/if_bxe.h @@ -1773,11 +1773,11 @@ struct bxe_softc { USTORM_ETH_ST_CONTEXT_CONFIG_BD_SB_INDEX_NUMBER)) #define CAM_IS_INVALID(x) \ - (x.target_table_entry.flags == \ + ((x)->target_table_entry.flags == \ TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) #define CAM_INVALIDATE(x) \ - (x.target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) + ((x)->target_table_entry.flags = TSTORM_CAM_TARGET_TABLE_ENTRY_ACTION_TYPE) /* Number of uint32_t elements in multicast hash array. */ #define MC_HASH_SIZE 8 diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 477f877ef635..b12b6541268a 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -104,7 +104,8 @@ static scr_stat main_console; static struct tty *main_devs[MAXCONS]; static char init_done = COLD; -static char shutdown_in_progress = FALSE; +static int shutdown_in_progress = FALSE; +static int suspend_in_progress = FALSE; static char sc_malloc = FALSE; static int saver_mode = CONS_NO_SAVER; /* LKM/user saver */ @@ -128,6 +129,13 @@ static void none_saver(sc_softc_t *sc, int blank) { } static void (*current_saver)(sc_softc_t *, int) = none_saver; #endif +#ifdef SC_NO_SUSPEND_VTYSWITCH +static int sc_no_suspend_vtswitch = 1; +#else +static int sc_no_suspend_vtswitch = 0; +#endif +static int sc_susp_scr; + SYSCTL_NODE(_hw, OID_AUTO, syscons, CTLFLAG_RD, 0, "syscons"); SYSCTL_NODE(_hw_syscons, OID_AUTO, saver, CTLFLAG_RD, 0, "saver"); SYSCTL_INT(_hw_syscons_saver, OID_AUTO, keybonly, CTLFLAG_RW, @@ -142,6 +150,9 @@ SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey, 0, "enable keyboard debug"); #endif +TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); +SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, + &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT) #include "font.h" #endif @@ -170,7 +181,9 @@ static kbd_callback_func_t sckbdevent; static void scinit(int unit, int flags); static scr_stat *sc_get_stat(struct tty *tp); static void scterm(int unit, int flags); -static void scshutdown(void *arg, int howto); +static void scshutdown(void *, int); +static void scsuspend(void *); +static void scresume(void *); static u_int scgetc(sc_softc_t *sc, u_int flags); #define SCGETC_CN 1 #define SCGETC_NONBLOCK 2 @@ -518,10 +531,15 @@ sc_attach_unit(int unit, int flags) printf("\n"); } - /* register a shutdown callback for the kernel console */ - if (sc_console_unit == unit) - EVENTHANDLER_REGISTER(shutdown_pre_sync, scshutdown, - (void *)(uintptr_t)unit, SHUTDOWN_PRI_DEFAULT); + /* Register suspend/resume/shutdown callbacks for the kernel console. */ + if (sc_console_unit == unit) { + EVENTHANDLER_REGISTER(power_suspend, scsuspend, NULL, + EVENTHANDLER_PRI_ANY); + EVENTHANDLER_REGISTER(power_resume, scresume, NULL, + EVENTHANDLER_PRI_ANY); + EVENTHANDLER_REGISTER(shutdown_pre_sync, scshutdown, NULL, + SHUTDOWN_PRI_DEFAULT); + } for (vc = 0; vc < sc->vtys; vc++) { if (sc->dev[vc] == NULL) { @@ -1718,7 +1736,7 @@ sccnupdate(scr_stat *scp) { /* this is a cut-down version of scrn_timer()... */ - if (scp->sc->suspend_in_progress || scp->sc->font_loading_in_progress) + if (suspend_in_progress || scp->sc->font_loading_in_progress) return; if (debugger > 0 || panicstr || shutdown_in_progress) { @@ -1768,7 +1786,7 @@ scrn_timer(void *arg) return; /* don't do anything when we are performing some I/O operations */ - if (sc->suspend_in_progress || sc->font_loading_in_progress) { + if (suspend_in_progress || sc->font_loading_in_progress) { if (again) timeout(scrn_timer, sc, hz / 10); return; @@ -3007,16 +3025,64 @@ scterm(int unit, int flags) } static void -scshutdown(void *arg, int howto) +scshutdown(__unused void *arg, __unused int howto) { - /* assert(sc_console != NULL) */ - sc_touch_scrn_saver(); - if (!cold && sc_console - && sc_console->sc->cur_scp->smode.mode == VT_AUTO - && sc_console->smode.mode == VT_AUTO) - sc_switch_scr(sc_console->sc, sc_console->index); - shutdown_in_progress = TRUE; + KASSERT(sc_console != NULL, ("sc_console != NULL")); + KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); + KASSERT(sc_console->sc->cur_scp != NULL, + ("sc_console->sc->cur_scp != NULL")); + + sc_touch_scrn_saver(); + if (!cold && + sc_console->sc->cur_scp->index != sc_console->index && + sc_console->sc->cur_scp->smode.mode == VT_AUTO && + sc_console->smode.mode == VT_AUTO) + sc_switch_scr(sc_console->sc, sc_console->index); + shutdown_in_progress = TRUE; +} + +static void +scsuspend(__unused void *arg) +{ + int retry; + + KASSERT(sc_console != NULL, ("sc_console != NULL")); + KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); + KASSERT(sc_console->sc->cur_scp != NULL, + ("sc_console->sc->cur_scp != NULL")); + + sc_susp_scr = sc_console->sc->cur_scp->index; + if (sc_no_suspend_vtswitch || + sc_susp_scr == sc_console->index) { + sc_touch_scrn_saver(); + sc_susp_scr = -1; + return; + } + for (retry = 0; retry < 10; retry++) { + sc_switch_scr(sc_console->sc, sc_console->index); + if (!sc_console->sc->switch_in_progress) + break; + pause("scsuspend", hz); + } + suspend_in_progress = TRUE; +} + +static void +scresume(__unused void *arg) +{ + + KASSERT(sc_console != NULL, ("sc_console != NULL")); + KASSERT(sc_console->sc != NULL, ("sc_console->sc != NULL")); + KASSERT(sc_console->sc->cur_scp != NULL, + ("sc_console->sc->cur_scp != NULL")); + + suspend_in_progress = FALSE; + if (sc_susp_scr < 0) { + mark_all(sc_console->sc->cur_scp); + return; + } + sc_switch_scr(sc_console->sc, sc_susp_scr); } int diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index 5efdb981b4ce..a23f88474a30 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -230,7 +230,6 @@ typedef struct sc_softc { char switch_in_progress; char write_in_progress; char blink_in_progress; - char suspend_in_progress; struct mtx video_mtx; long scrn_time_stamp; diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index 75817d0c56b8..d980ec7bd6d9 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -30,7 +30,6 @@ void i8254_init(void); void startrtclock(void); void timer_restore(void); void init_TSC(void); -void init_TSC_tc(void); #define HAS_TIMER_SPKR 1 int timer_spkr_acquire(void); diff --git a/sys/isa/syscons_isa.c b/sys/isa/syscons_isa.c index 6b257ab8f1bd..7d8e9c87d6f1 100644 --- a/sys/isa/syscons_isa.c +++ b/sys/isa/syscons_isa.c @@ -69,17 +69,6 @@ __FBSDID("$FreeBSD$"); static devclass_t sc_devclass; static sc_softc_t main_softc; -#ifdef SC_NO_SUSPEND_VTYSWITCH -static int sc_no_suspend_vtswitch = 1; -#else -static int sc_no_suspend_vtswitch = 0; -#endif -static int sc_cur_scr; - -TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); -SYSCTL_DECL(_hw_syscons); -SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, - &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); static void scidentify(driver_t *driver, device_t parent) @@ -108,53 +97,6 @@ scattach(device_t dev) SC_AUTODETECT_KBD)); } -static int -scsuspend(device_t dev) -{ - int retry = 10; - sc_softc_t *sc; - - sc = &main_softc; - - if (sc->cur_scp == NULL) - return (0); - - if (sc->suspend_in_progress == 0) { - sc_cur_scr = sc->cur_scp->index; - if (!sc_no_suspend_vtswitch && sc_cur_scr != 0) - do { - sc_switch_scr(sc, 0); - if (!sc->switch_in_progress) - break; - pause("scsuspend", hz); - } while (retry--); - } - sc->suspend_in_progress++; - - return (0); -} - -static int -scresume(device_t dev) -{ - sc_softc_t *sc; - - sc = &main_softc; - - if (sc->cur_scp == NULL) - return (0); - - sc->suspend_in_progress--; - if (sc->suspend_in_progress == 0) { - if (!sc_no_suspend_vtswitch && sc_cur_scr != 0) - sc_switch_scr(sc, sc_cur_scr); - else - mark_all(sc->cur_scp); - } - - return (0); -} - int sc_max_unit(void) { @@ -300,8 +242,6 @@ static device_method_t sc_methods[] = { DEVMETHOD(device_identify, scidentify), DEVMETHOD(device_probe, scprobe), DEVMETHOD(device_attach, scattach), - DEVMETHOD(device_suspend, scsuspend), - DEVMETHOD(device_resume, scresume), { 0, 0 } }; @@ -312,70 +252,3 @@ static driver_t sc_driver = { }; DRIVER_MODULE(sc, isa, sc_driver, sc_devclass, 0, 0); - -static devclass_t scpm_devclass; - -static void -scpm_identify(driver_t *driver, device_t parent) -{ - - device_add_child(parent, "scpm", 0); -} - -static int -scpm_probe(device_t dev) -{ - - device_set_desc(dev, SC_DRIVER_NAME " suspend/resume"); - device_quiet(dev); - - return (BUS_PROBE_DEFAULT); -} - -static int -scpm_attach(device_t dev) -{ - - bus_generic_probe(dev); - bus_generic_attach(dev); - - return (0); -} - -static int -scpm_suspend(device_t dev) -{ - int error; - - error = bus_generic_suspend(dev); - if (error != 0) - return (error); - - return (scsuspend(dev)); -} - -static int -scpm_resume(device_t dev) -{ - - scresume(dev); - - return (bus_generic_resume(dev)); -} - -static device_method_t scpm_methods[] = { - DEVMETHOD(device_identify, scpm_identify), - DEVMETHOD(device_probe, scpm_probe), - DEVMETHOD(device_attach, scpm_attach), - DEVMETHOD(device_suspend, scpm_suspend), - DEVMETHOD(device_resume, scpm_resume), - { 0, 0 } -}; - -static driver_t scpm_driver = { - "scpm", - scpm_methods, - 0 -}; - -DRIVER_MODULE(scpm, vgapm, scpm_driver, scpm_devclass, 0, 0); diff --git a/sys/pc98/cbus/syscons_cbus.c b/sys/pc98/cbus/syscons_cbus.c index 0220b2f82a07..e5c29795ee2a 100644 --- a/sys/pc98/cbus/syscons_cbus.c +++ b/sys/pc98/cbus/syscons_cbus.c @@ -49,17 +49,6 @@ __FBSDID("$FreeBSD$"); static devclass_t sc_devclass; static sc_softc_t main_softc; -#ifdef SC_NO_SUSPEND_VTYSWITCH -static int sc_no_suspend_vtswitch = 1; -#else -static int sc_no_suspend_vtswitch = 0; -#endif -static int sc_cur_scr; - -TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); -SYSCTL_DECL(_hw_syscons); -SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, - &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); static void scidentify(driver_t *driver, device_t parent) @@ -87,47 +76,6 @@ scattach(device_t dev) return sc_attach_unit(device_get_unit(dev), device_get_flags(dev)); } -static int -scsuspend(device_t dev) -{ - int retry = 10; - sc_softc_t *sc; - - sc = &main_softc; - - if (sc->cur_scp == NULL) - return (0); - - sc_cur_scr = sc->cur_scp->index; - - if (sc_no_suspend_vtswitch) - return (0); - - do { - sc_switch_scr(sc, 0); - if (!sc->switch_in_progress) { - break; - } - pause("scsuspend", hz); - } while (retry--); - - return (0); -} - -static int -scresume(device_t dev) -{ - sc_softc_t *sc; - - if (sc_no_suspend_vtswitch) - return (0); - - sc = &main_softc; - sc_switch_scr(sc, sc_cur_scr); - - return (0); -} - int sc_max_unit(void) { @@ -242,8 +190,6 @@ static device_method_t sc_methods[] = { DEVMETHOD(device_identify, scidentify), DEVMETHOD(device_probe, scprobe), DEVMETHOD(device_attach, scattach), - DEVMETHOD(device_suspend, scsuspend), - DEVMETHOD(device_resume, scresume), { 0, 0 } }; diff --git a/sys/x86/isa/clock.c b/sys/x86/isa/clock.c index fdfc1ee17af5..a74c11f563a2 100644 --- a/sys/x86/isa/clock.c +++ b/sys/x86/isa/clock.c @@ -498,7 +498,6 @@ void cpu_initclocks(void) { - init_TSC_tc(); cpu_initclocks_bsp(); } diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 34d445be9235..d82bd736eb3f 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -326,7 +326,73 @@ init_TSC(void) tsc_levels_changed, NULL, EVENTHANDLER_PRI_ANY); } -void +#ifdef SMP + +#define TSC_READ(x) \ +static void \ +tsc_read_##x(void *arg) \ +{ \ + uint32_t *tsc = arg; \ + u_int cpu = PCPU_GET(cpuid); \ + \ + tsc[cpu * 3 + x] = rdtsc32(); \ +} +TSC_READ(0) +TSC_READ(1) +TSC_READ(2) +#undef TSC_READ + +#define N 1000 + +static void +comp_smp_tsc(void *arg) +{ + uint32_t *tsc; + int32_t d1, d2; + u_int cpu = PCPU_GET(cpuid); + u_int i, j, size; + + size = (mp_maxid + 1) * 3; + for (i = 0, tsc = arg; i < N; i++, tsc += size) + CPU_FOREACH(j) { + if (j == cpu) + continue; + d1 = tsc[cpu * 3 + 1] - tsc[j * 3]; + d2 = tsc[cpu * 3 + 2] - tsc[j * 3 + 1]; + if (d1 <= 0 || d2 <= 0) { + smp_tsc = 0; + return; + } + } +} + +static int +test_smp_tsc(void) +{ + uint32_t *data, *tsc; + u_int i, size; + + if (!smp_tsc && !tsc_is_invariant) + return (-100); + size = (mp_maxid + 1) * 3; + data = malloc(sizeof(*data) * size * N, M_TEMP, M_WAITOK); + for (i = 0, tsc = data; i < N; i++, tsc += size) + smp_rendezvous(tsc_read_0, tsc_read_1, tsc_read_2, tsc); + smp_tsc = 1; /* XXX */ + smp_rendezvous(smp_no_rendevous_barrier, comp_smp_tsc, + smp_no_rendevous_barrier, data); + free(data, M_TEMP); + if (bootverbose) + printf("SMP: %sed TSC synchronization test\n", + smp_tsc ? "pass" : "fail"); + return (smp_tsc ? 800 : -100); +} + +#undef N + +#endif /* SMP */ + +static void init_TSC_tc(void) { @@ -347,26 +413,25 @@ init_TSC_tc(void) tsc_timecounter.tc_quality = -1000; if (bootverbose) printf("TSC timecounter disabled: APM enabled.\n"); + goto init; } #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. + * We can not use the TSC in SMP mode unless the TSCs on all CPUs are + * synchronized. If the user is sure that the system has synchronized + * TSCs, set kern.timecounter.smp_tsc tunable to a non-zero value. */ - if (mp_ncpus > 1 && !smp_tsc) - tsc_timecounter.tc_quality = -100; + if (smp_cpus > 1) + tsc_timecounter.tc_quality = test_smp_tsc(); #endif - +init: if (tsc_freq != 0) { tsc_timecounter.tc_frequency = tsc_freq; tc_init(&tsc_timecounter); } } +SYSINIT(tsc_tc, SI_SUB_SMP, SI_ORDER_ANY, init_TSC_tc, NULL); /* * When cpufreq levels change, find out about the (new) max frequency. We From cab9c6a12aa2c9f169eab93065280cc3b54bb772 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 9 May 2011 22:13:07 +0000 Subject: [PATCH 029/164] Fix by hand files that aren't added automatically by svn. BIG SUCKAGE! --- share/man/man4/geom_map.4 | 179 ++++++++++++++++++ sys/nfs/nfs_kdtrace.h | 120 ++++++++++++ sys/sys/_stdint.h | 82 ++++++++ tools/build/options/WITHOUT_GPIO | 4 + .../regression/bin/sh/parser/dollar-quote1.0 | 12 ++ .../regression/bin/sh/parser/dollar-quote2.0 | 5 + .../regression/bin/sh/parser/dollar-quote3.0 | 22 +++ .../regression/bin/sh/parser/dollar-quote4.0 | 19 ++ .../regression/bin/sh/parser/dollar-quote5.0 | 12 ++ .../regression/bin/sh/parser/dollar-quote6.0 | 5 + .../regression/bin/sh/parser/dollar-quote7.0 | 6 + .../regression/bin/sh/parser/dollar-quote8.0 | 11 ++ .../regression/bin/sh/parser/dollar-quote9.0 | 8 + 13 files changed, 485 insertions(+) create mode 100644 share/man/man4/geom_map.4 create mode 100644 sys/nfs/nfs_kdtrace.h create mode 100644 sys/sys/_stdint.h create mode 100644 tools/build/options/WITHOUT_GPIO create mode 100644 tools/regression/bin/sh/parser/dollar-quote1.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote2.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote3.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote4.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote5.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote6.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote7.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote8.0 create mode 100644 tools/regression/bin/sh/parser/dollar-quote9.0 diff --git a/share/man/man4/geom_map.4 b/share/man/man4/geom_map.4 new file mode 100644 index 000000000000..3d65dcd7650b --- /dev/null +++ b/share/man/man4/geom_map.4 @@ -0,0 +1,179 @@ +.\" +.\" Copyright (c) 2011 Aleksandr Rybalko +.\" 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. +.\" +.\" $FreeBSD$ +.\" +.Dd April 5, 2011 +.Dt GEOM_MAP 4 +.Os +.Sh NAME +.Nm geom_map +.Nd "GEOM module that map difined items as separate partitions" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device geom_map" +.Ed +.Sh DESCRIPTION +The +.Nm +framework provides support for mapping defined parts of the media. Basicaly it +is helpful in the embedded devices where in the one continous flash are loader, +kernel and rootfs parts. The +.Nm +allows making them available as separate parts and protect loader from +overwriting. +.Pp +At boot time +.Nm +partitions listed (only with bootverbose) as: +.Bd -literal -offset indent +MAP: 0x30000, data=0x30000 "/dev/map/bootloader" +MAP: 30000x10000, data=0x10000 "/dev/map/factory" +MAP: 40000x7a0000, data=0x7a0000 "/dev/map/upgrade" +MAP: search key ".!/bin/sh" from 0x100000, step 0x10000 +MAP: 40000x110000, data=0x110000 "/dev/map/kernel" +MAP: search key ".!/bin/sh" from 0x100000, step 0x10000 +MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" +MAP: 7e0000x20000, data=0x20000 "/dev/map/config" +.Ed +.Pp +Also +.Nm +current configuration can be accessible with sysctl's kern.geom.conftxt, +kern.geom.confxml, kern.geom.confdot or geom map list. +.Bd -literal -offset indent +# sysctl kern.geom.conftxt +kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc +0 DISK cfid0 8388608 4 hd 0 sc 0 +1 MAP map/config 131072 4 i 5 o 8257536 entry 0 dsize 131072 +1 MAP map/rootfs 6881280 4 i 4 o 1376256 entry 0 dsize 6881280 +2 UNCOMPRESS map/rootfs.uncompress 18677760 512 +1 MAP map/kernel 1114112 4 i 3 o 262144 entry 0 dsize 1114112 +1 MAP map/upgrade 7995392 4 i 2 o 262144 entry 0 dsize 7995392 +1 MAP map/factory 65536 4 i 1 o 196608 entry 0 dsize 65536 +1 MAP map/bootloader 196608 4 i 0 o 0 entry 0 dsize 196608 +.Ed +.Pp +Driver configuration can be done in device hints file. List of used parameters: +.Bl -tag -width indent +.It Fa at +select media to attach +.It Fa name +name of partiton (will create device /dev/map/that_name) +.It Fa start +offset from the beginning of the parent media to start of the mapped partition. +This field can also have special value +"search:searchstart:searchstep:searchkey", where: +.Bl -tag -width indent +.It Fa searchstart +offset from the beginning of the parent media where search will be started +.It Fa searchstep +value of the increment used while searching for the partition boundary markers +.It Fa searchkey +key which will be used to find partition boundary markers. Wildcard "." char +can be used to match any char on that position +.El +.It Fa end +offset from the beginning of the parent media to end of the mapped partition. +This field can also have special value +"search:searchstart:searchstep:searchkey", look "start" for details. +.It Fa offset +offset where the data of mapped partition begins +.El +.Pp +Each record contains start address(bytes) from the media begin, size(bytes), +offset where the data of mapped partition begins, and the name of new device. +.Bd -literal -offset indent +MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" +.Ed +.Bd -literal +00150000 - begin address +00690000 - size +00000000 - data begin from zero offset +00690000 - data size +"map/rootfs" - new media will be accessible via /dev/map/rootfs dev. +.Ed +.Sh EXAMPLES +.Pp +.Bl -bullet -compact +If we need to implement layout shown above, we need to define the folowing +hints: +.Bd -literal -offset indent +hint.map.0.at="cfid0" +hint.map.0.start=0x00000000 +hint.map.0.end=0x00030000 +hint.map.0.name="bootloader" +hint.map.0.readonly=1 + +.Ed +define "/dev/map/bootloader" at disk "cfid0" starting at 0x00000000 and end +0x00030000, also marked as readonly. +.Bd -literal -offset indent +hint.map.1.at="cfid0" +hint.map.1.start=0x00030000 +hint.map.1.end=0x00040000 +hint.map.1.name="factory" + +hint.map.2.at="cfid0" +hint.map.2.start=0x00040000 +hint.map.2.end=0x007e0000 +hint.map.2.name="upgrade" + +hint.map.3.at="cfid0" +hint.map.3.name="kernel" +hint.map.3.start=0x00040000 +hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh" + +.Ed +define "/dev/map/kernel" at disk "cfid0" starting at 0x00040000, but end +position must be searched by the key ".!/bin/sh", from offset 0x00100000 to end +of media with step 0x10000. Real marker in that case is "#!/bin/sh", but "#" +terminates the line when hints file is parsed, so we need to use wildcard "." +instead of "#". +.Bd -literal -offset indent +hint.map.4.at="cfid0" +hint.map.4.name="rootfs" +hint.map.4.start="search:0x00100000:0x10000:.!/bin/sh" +hint.map.4.end=0x007e0000 + +hint.map.5.at="cfid0" +hint.map.5.start=0x007e0000 +hint.map.5.end=0x00800000 +hint.map.5.name="config" +.Ed +.El +.Sh SEE ALSO +.Xr GEOM 4 , +.Xr geom 8 , +.Xr sysctl 8 +.Sh AUTHORS +.An -nosplit +The +.Nm +driver was written by +.An "Aleksandr Rybalko" Aq ray@ddteam.net . diff --git a/sys/nfs/nfs_kdtrace.h b/sys/nfs/nfs_kdtrace.h new file mode 100644 index 000000000000..d29aa683a714 --- /dev/null +++ b/sys/nfs/nfs_kdtrace.h @@ -0,0 +1,120 @@ +/*- + * Copyright (c) 2009 Robert N. M. Watson + * All rights reserved. + * + * This software was developed at the University of Cambridge Computer + * Laboratory with support from a grant from Google, Inc. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _NFSCLIENT_NFS_KDTRACE_H_ +#define _NFSCLIENT_NFS_KDTRACE_H_ + +#ifdef KDTRACE_HOOKS +#include + +/* + * Definitions for NFS access cache probes. + */ +extern uint32_t nfsclient_accesscache_flush_done_id; +extern uint32_t nfsclient_accesscache_get_hit_id; +extern uint32_t nfsclient_accesscache_get_miss_id; +extern uint32_t nfsclient_accesscache_load_done_id; + +#define KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp) do { \ + if (dtrace_nfsclient_accesscache_flush_done_probe != NULL) \ + (dtrace_nfsclient_accesscache_flush_done_probe)( \ + nfsclient_accesscache_flush_done_id, (vp)); \ +} while (0) + +#define KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode) do { \ + if (dtrace_nfsclient_accesscache_get_hit_probe != NULL) \ + (dtrace_nfsclient_accesscache_get_hit_probe)( \ + nfsclient_accesscache_get_hit_id, (vp), (uid), \ + (mode)); \ +} while (0) + +#define KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode) do { \ + if (dtrace_nfsclient_accesscache_get_miss_probe != NULL) \ + (dtrace_nfsclient_accesscache_get_miss_probe)( \ + nfsclient_accesscache_get_miss_id, (vp), (uid), \ + (mode)); \ +} while (0) + +#define KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) do { \ + if (dtrace_nfsclient_accesscache_load_done_probe != NULL) \ + (dtrace_nfsclient_accesscache_load_done_probe)( \ + nfsclient_accesscache_load_done_id, (vp), (uid), \ + (rmode), (error)); \ +} while (0) + +/* + * Definitions for NFS attribute cache probes. + */ +extern uint32_t nfsclient_attrcache_flush_done_id; +extern uint32_t nfsclient_attrcache_get_hit_id; +extern uint32_t nfsclient_attrcache_get_miss_id; +extern uint32_t nfsclient_attrcache_load_done_id; + +#define KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp) do { \ + if (dtrace_nfsclient_attrcache_flush_done_probe != NULL) \ + (dtrace_nfsclient_attrcache_flush_done_probe)( \ + nfsclient_attrcache_flush_done_id, (vp)); \ +} while (0) + +#define KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap) do { \ + if (dtrace_nfsclient_attrcache_get_hit_probe != NULL) \ + (dtrace_nfsclient_attrcache_get_hit_probe)( \ + nfsclient_attrcache_get_hit_id, (vp), (vap)); \ +} while (0) + +#define KDTRACE_NFS_ATTRCACHE_GET_MISS(vp) do { \ + if (dtrace_nfsclient_attrcache_get_miss_probe != NULL) \ + (dtrace_nfsclient_attrcache_get_miss_probe)( \ + nfsclient_attrcache_get_miss_id, (vp)); \ +} while (0) + +#define KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error) do { \ + if (dtrace_nfsclient_attrcache_load_done_probe != NULL) \ + (dtrace_nfsclient_attrcache_load_done_probe)( \ + nfsclient_attrcache_load_done_id, (vp), (vap), \ + (error)); \ +} while (0) + +#else /* !KDTRACE_HOOKS */ + +#define KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp) +#define KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode) +#define KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode) +#define KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) + +#define KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp) +#define KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap) +#define KDTRACE_NFS_ATTRCACHE_GET_MISS(vp) +#define KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error) + +#endif /* KDTRACE_HOOKS */ + +#endif /* !_NFSCLIENT_NFS_KDTRACE_H_ */ diff --git a/sys/sys/_stdint.h b/sys/sys/_stdint.h new file mode 100644 index 000000000000..d0f92493b052 --- /dev/null +++ b/sys/sys/_stdint.h @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 2011 David E. O'Brien + * Copyright (c) 2001 Mike Barcroft + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS__STDINT_H_ +#define _SYS__STDINT_H_ + +#ifndef _INT8_T_DECLARED +typedef __int8_t int8_t; +#define _INT8_T_DECLARED +#endif + +#ifndef _INT16_T_DECLARED +typedef __int16_t int16_t; +#define _INT16_T_DECLARED +#endif + +#ifndef _INT32_T_DECLARED +typedef __int32_t int32_t; +#define _INT32_T_DECLARED +#endif + +#ifndef _INT64_T_DECLARED +typedef __int64_t int64_t; +#define _INT64_T_DECLARED +#endif + +#ifndef _UINT8_T_DECLARED +typedef __uint8_t uint8_t; +#define _UINT8_T_DECLARED +#endif + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + +#ifndef _INTPTR_T_DECLARED +typedef __intptr_t intptr_t; +#define _INTPTR_T_DECLARED +#endif +#ifndef _UINTPTR_T_DECLARED +typedef __uintptr_t uintptr_t; +#define _UINTPTR_T_DECLARED +#endif + +#endif /* !_SYS__STDINT_H_ */ diff --git a/tools/build/options/WITHOUT_GPIO b/tools/build/options/WITHOUT_GPIO new file mode 100644 index 000000000000..08c565d76986 --- /dev/null +++ b/tools/build/options/WITHOUT_GPIO @@ -0,0 +1,4 @@ +.\" $FreeBSD: head/tools/build/options/WITHOUT_GPIO 221541 2011-05-06 19:14:06Z ru $ +Set to not build +.Xr gpioctl 8 +as part of the base system. diff --git a/tools/regression/bin/sh/parser/dollar-quote1.0 b/tools/regression/bin/sh/parser/dollar-quote1.0 new file mode 100644 index 000000000000..2554eedca8aa --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote1.0 @@ -0,0 +1,12 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote1.0 221513 2011-05-05 20:55:55Z jilles $ + +set -e + +[ $'hi' = hi ] +[ $'hi +there' = 'hi +there' ] +[ $'\"\'\\\a\b\f\t\v' = "\"'\\$(printf "\a\b\f\t\v")" ] +[ $'hi\nthere' = 'hi +there' ] +[ $'a\rb' = "$(printf "a\rb")" ] diff --git a/tools/regression/bin/sh/parser/dollar-quote2.0 b/tools/regression/bin/sh/parser/dollar-quote2.0 new file mode 100644 index 000000000000..0e959338d680 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote2.0 @@ -0,0 +1,5 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote2.0 221513 2011-05-05 20:55:55Z jilles $ + +# This depends on the ASCII character set. + +[ $'\e' = "$(printf "\033")" ] diff --git a/tools/regression/bin/sh/parser/dollar-quote3.0 b/tools/regression/bin/sh/parser/dollar-quote3.0 new file mode 100644 index 000000000000..7c0f9663cb35 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote3.0 @@ -0,0 +1,22 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote3.0 221513 2011-05-05 20:55:55Z jilles $ + +unset LC_ALL +LC_CTYPE=en_US.ISO8859-1 +export LC_CTYPE + +e= +for i in 0 1 2 3; do + for j in 0 1 2 3 4 5 6 7; do + for k in 0 1 2 3 4 5 6 7; do + case $i$j$k in + 000) continue ;; + esac + e="$e\\$i$j$k" + done + done +done +ee=`printf "$e"` +[ "${#ee}" = 255 ] || echo length bad + +# Start a new shell so the locale change is picked up. +[ "$(${SH} -c "printf %s \$'$e'")" = "$ee" ] diff --git a/tools/regression/bin/sh/parser/dollar-quote4.0 b/tools/regression/bin/sh/parser/dollar-quote4.0 new file mode 100644 index 000000000000..6403ad9f37f6 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote4.0 @@ -0,0 +1,19 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote4.0 221513 2011-05-05 20:55:55Z jilles $ + +unset LC_ALL +LC_CTYPE=en_US.ISO8859-1 +export LC_CTYPE + +e= +for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do + for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do + case $i$j in + 00) continue ;; + esac + e="$e\x$i$j" + done +done + +# Start a new shell so the locale change is picked up. +ee="$(${SH} -c "printf %s \$'$e'")" +[ "${#ee}" = 255 ] || echo length bad diff --git a/tools/regression/bin/sh/parser/dollar-quote5.0 b/tools/regression/bin/sh/parser/dollar-quote5.0 new file mode 100644 index 000000000000..b5e20a4c5d84 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote5.0 @@ -0,0 +1,12 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote5.0 221513 2011-05-05 20:55:55Z jilles $ + +# This depends on the ASCII character set. + +set -e + +[ $'\ca\cb\cc\cd\ce\cf\cg\ch\ci\cj\ck\cl\cm\cn\co\cp\cq\cr\cs\ct\cu\cv\cw\cx\cy\cz' = $'\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032' ] +[ $'\cA\cB\cC\cD\cE\cF\cG\cH\cI\cJ\cK\cL\cM\cN\cO\cP\cQ\cR\cS\cT\cU\cV\cW\cX\cY\cZ' = $'\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032' ] +[ $'\c[' = $'\033' ] +[ $'\c]' = $'\035' ] +[ $'\c^' = $'\036' ] +[ $'\c_' = $'\037' ] diff --git a/tools/regression/bin/sh/parser/dollar-quote6.0 b/tools/regression/bin/sh/parser/dollar-quote6.0 new file mode 100644 index 000000000000..92046137a15f --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote6.0 @@ -0,0 +1,5 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote6.0 221513 2011-05-05 20:55:55Z jilles $ + +# This depends on the ASCII character set. + +[ $'\c\\' = $'\034' ] diff --git a/tools/regression/bin/sh/parser/dollar-quote7.0 b/tools/regression/bin/sh/parser/dollar-quote7.0 new file mode 100644 index 000000000000..9c6bd39030b0 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote7.0 @@ -0,0 +1,6 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote7.0 221513 2011-05-05 20:55:55Z jilles $ + +set -e + +[ $'\u0024\u0040\u0060' = '$@`' ] +[ $'\U00000024\U00000040\U00000060' = '$@`' ] diff --git a/tools/regression/bin/sh/parser/dollar-quote8.0 b/tools/regression/bin/sh/parser/dollar-quote8.0 new file mode 100644 index 000000000000..de9161437cf4 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote8.0 @@ -0,0 +1,11 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote8.0 221513 2011-05-05 20:55:55Z jilles $ + +[ $'hello\0' = hello ] +[ $'hello\0world' = hello ] +[ $'hello\0'$'world' = helloworld ] +[ $'hello\000' = hello ] +[ $'hello\000world' = hello ] +[ $'hello\000'$'world' = helloworld ] +[ $'hello\x00' = hello ] +[ $'hello\x00world' = hello ] +[ $'hello\x00'$'world' = helloworld ] diff --git a/tools/regression/bin/sh/parser/dollar-quote9.0 b/tools/regression/bin/sh/parser/dollar-quote9.0 new file mode 100644 index 000000000000..8a4ea9f21d92 --- /dev/null +++ b/tools/regression/bin/sh/parser/dollar-quote9.0 @@ -0,0 +1,8 @@ +# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote9.0 221513 2011-05-05 20:55:55Z jilles $ + +# POSIX and C99 say D800-DFFF are undefined in a universal character name. +# We reject this but many other shells expand to something that looks like +# CESU-8. + +v=$( (eval ": \$'\uD800'") 2>&1 >/dev/null) +[ $? -ne 0 ] && [ -n "$v" ] From a7f2d2bb76f345d4f40a3a90fdb730c4e791400e Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 9 May 2011 22:29:54 +0000 Subject: [PATCH 030/164] MFC --- contrib/less/LICENSE | 2 +- contrib/less/Makefile.aut | 8 + contrib/less/Makefile.wnm | 4 +- contrib/less/NEWS | 31 + contrib/less/README | 8 +- contrib/less/brac.c | 2 +- contrib/less/ch.c | 2 +- contrib/less/charset.c | 6 +- contrib/less/charset.h | 2 +- contrib/less/cmd.h | 3 +- contrib/less/cmdbuf.c | 6 +- contrib/less/command.c | 573 ++-- contrib/less/configure | 5974 +++++++++++-------------------------- contrib/less/configure.ac | 16 +- contrib/less/cvt.c | 2 +- contrib/less/decode.c | 3 +- contrib/less/defines.ds | 2 +- contrib/less/defines.h.in | 6 + contrib/less/defines.o2 | 2 +- contrib/less/defines.o9 | 2 +- contrib/less/defines.wn | 12 +- contrib/less/edit.c | 2 +- contrib/less/filename.c | 22 +- contrib/less/forwback.c | 2 +- contrib/less/funcs.h | 4 +- contrib/less/help.c | 9 + contrib/less/ifile.c | 2 +- contrib/less/input.c | 7 +- contrib/less/jump.c | 2 +- contrib/less/less.h | 4 +- contrib/less/less.hlp | 9 + contrib/less/less.man | 620 ++-- contrib/less/less.nro | 52 +- contrib/less/lessecho.c | 4 +- contrib/less/lessecho.man | 2 +- contrib/less/lessecho.nro | 2 +- contrib/less/lesskey.c | 3 +- contrib/less/lesskey.h | 2 +- contrib/less/lesskey.man | 36 +- contrib/less/lesskey.nro | 12 +- contrib/less/lglob.h | 2 +- contrib/less/line.c | 2 +- contrib/less/linenum.c | 2 +- contrib/less/lsystem.c | 2 +- contrib/less/main.c | 6 +- contrib/less/mark.c | 2 +- contrib/less/mkhelp.c | 2 +- contrib/less/optfunc.c | 2 +- contrib/less/option.c | 100 +- contrib/less/option.h | 6 +- contrib/less/opttbl.c | 18 +- contrib/less/os.c | 43 +- contrib/less/output.c | 3 +- contrib/less/pattern.c | 8 +- contrib/less/pattern.h | 2 +- contrib/less/pckeys.h | 2 +- contrib/less/position.c | 2 +- contrib/less/position.h | 2 +- contrib/less/prompt.c | 6 +- contrib/less/screen.c | 4 +- contrib/less/scrsize.c | 2 +- contrib/less/search.c | 160 +- contrib/less/signal.c | 4 +- contrib/less/tags.c | 2 +- contrib/less/ttyin.c | 2 +- contrib/less/version.c | 17 +- sys/dev/bge/if_bge.c | 81 +- sys/dev/mii/brgphy.c | 1 + sys/dev/mii/miidevs | 1 + sys/vm/vm_object.c | 18 + 70 files changed, 2932 insertions(+), 5034 deletions(-) diff --git a/contrib/less/LICENSE b/contrib/less/LICENSE index 54a2a1fbddfa..c7168e718272 100644 --- a/contrib/less/LICENSE +++ b/contrib/less/LICENSE @@ -2,7 +2,7 @@ ------------ Less -Copyright (C) 1984-2009 Mark Nudelman +Copyright (C) 1984-2011 Mark Nudelman Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/contrib/less/Makefile.aut b/contrib/less/Makefile.aut index 2f2b9976b938..b3ee3f4639d1 100644 --- a/contrib/less/Makefile.aut +++ b/contrib/less/Makefile.aut @@ -34,6 +34,14 @@ DISTFILES = \ all: help.c funcs.h ${srcdir}/configure +release: .FORCE + ${MAKE} -f Makefile.aut tagall + ${MAKE} -f Makefile.aut all + ${MAKE} -f Makefile.aut clean + ${MAKE} -f Makefile.aut dist + +.FORCE: + help.c: less.hlp mkhelp -mv -f ${srcdir}/help.c ${srcdir}/help.c.old rm -rf help.c diff --git a/contrib/less/Makefile.wnm b/contrib/less/Makefile.wnm index e19ba1fd6145..7b33833837d1 100644 --- a/contrib/less/Makefile.wnm +++ b/contrib/less/Makefile.wnm @@ -7,11 +7,11 @@ CC = cl # Normal flags CFLAGS = /nologo /ML /W3 /GX /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c -LDFLAGS = /subsystem:console /incremental:no /machine:I386 +LDFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 # Debugging flags #CFLAGS = /nologo /MDd /W3 /GX /Od /Gm /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c -#LDFLAGS = /subsystem:console /incremental:yes /debug /machine:I386 +#LDFLAGS = /nologo /subsystem:console /incremental:yes /debug /machine:I386 LD = link LIBS = user32.lib diff --git a/contrib/less/NEWS b/contrib/less/NEWS index 161795c5915f..4beefaf08209 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -10,6 +10,37 @@ To report bugs, suggestions or comments, send email to bug-less@gnu.org or markn@greenwoodsoftware.com. +====================================================================== + + Major changes between "less" versions 436 and 443 + +* Change search behavior such that when a search is given an explicit + pattern, the entire displayed screen is included in the search and + not just the portion after the target line. + +* Add -A option to change search behavior to the old way: only + the portion of the screen after the target line is searched. + +* Add %F formatting to prompt strings, replaced by the last component + of the input file. + +* Control-G while editing a command exits the command. + +* Less now exits with status 2 if control-C is pressed and -K is in effect. + +* Fix "ungetc overflow" when passing long commands via the -p option. + +* Fix bug in using line filtering via the & command + in combination with -i and -I. + +* Fix bug in handling negative arguments to the -j option. + +* Fix bug in handling %t in prompt strings. + +* Improve handling of long option names. + +* Improve percentage calculation for very large files. + ====================================================================== Major changes between "less" versions 429 and 436 diff --git a/contrib/less/README b/contrib/less/README index 9b9e455668b8..8d5a95b02c95 100644 --- a/contrib/less/README +++ b/contrib/less/README @@ -7,9 +7,9 @@ ************************************************************************** ************************************************************************** - Less, version 436 + Less, version 443 - This is the distribution of less, version 436, released 07 Jul 2009. + This is the distribution of less, version 443, released 09 Apr 2011. This program is part of the GNU project (http://www.gnu.org). This program is free software. You may redistribute it and/or @@ -101,6 +101,10 @@ complaints, etc., you may mail to the author at markn@greenwoodsoftware.com. Note to hackers: comments noting possible improvements are enclosed in double curly brackets {{ like this }}. +(Note that the above note was originally written at a time when +"hackers" most commonly meant "enthusiastic and dedicated computer +programmers", not "persons who attempt to circumvent computer security".) + ======================================================================= diff --git a/contrib/less/brac.c b/contrib/less/brac.c index 45e40094d3f9..22c71ebfc831 100644 --- a/contrib/less/brac.c +++ b/contrib/less/brac.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/ch.c b/contrib/less/ch.c index 51d6bd87e528..1b84ec1618fd 100644 --- a/contrib/less/ch.c +++ b/contrib/less/ch.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/charset.c b/contrib/less/charset.c index ab4bc53d2cc4..12b59d6b731a 100644 --- a/contrib/less/charset.c +++ b/contrib/less/charset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -395,7 +395,7 @@ init_charset() binary_char(c) LWCHAR c; { - if (utf_mode) + if (utf_mode) return (is_ubin_char(c)); c &= 0377; return (chardef[c] & IS_BINARY_CHAR); @@ -817,7 +817,7 @@ static struct wchar_range ubin_table[] = { { 0x000B, 0x000C} /* Cc */, { 0x000E, 0x001A} /* Cc */, { 0x001C, 0x001F} /* Cc */, - { 0x007F, 0x009F} /* Cc */, + { 0x007F, 0x009F} /* Cc */, #if 0 { 0x00AD, 0x00AD} /* Cf */, #endif diff --git a/contrib/less/charset.h b/contrib/less/charset.h index af2ec6303238..8ccf748df09e 100644 --- a/contrib/less/charset.h +++ b/contrib/less/charset.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2009 Mark Nudelman + * Copyright (C) 2005-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/cmd.h b/contrib/less/cmd.h index 3eda6479c768..3176b917226a 100644 --- a/contrib/less/cmd.h +++ b/contrib/less/cmd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -98,6 +98,7 @@ #define EC_F_COMPLETE 17 #define EC_B_COMPLETE 18 #define EC_LITERAL 19 +#define EC_ABORT 20 #define EC_NOACTION 101 #define EC_UINVALID 102 diff --git a/contrib/less/cmdbuf.c b/contrib/less/cmdbuf.c index fea9da355ca7..74a74ffe9b10 100644 --- a/contrib/less/cmdbuf.c +++ b/contrib/less/cmdbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -857,6 +857,10 @@ cmd_edit(c) case EC_LINEKILL: not_in_completion(); return (cmd_kill()); + case EC_ABORT: + not_in_completion(); + (void) cmd_kill(); + return (CC_QUIT); case EC_W_BACKSPACE: not_in_completion(); return (cmd_werase()); diff --git a/contrib/less/command.c b/contrib/less/command.c index 7e328c06e913..653db0bd0d9f 100644 --- a/contrib/less/command.c +++ b/contrib/less/command.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -57,8 +57,6 @@ extern int shift_count; extern int oldbot; extern int forw_prompt; -static char ungot[UNGOT_SIZE]; -static char *ungotp = NULL; #if SHELL_ESCAPE static char *shellcmd = NULL; /* For holding last shell command for "!!" */ #endif @@ -66,7 +64,8 @@ static int mca; /* The multicharacter command (action) */ static int search_type; /* The previous type of search */ static LINENUM number; /* The number typed by the user */ static long fraction; /* The fractional part of the number */ -static char optchar; +static struct loption *curropt; +static int opt_lower; static int optflag; static int optgetname; static POSITION bottompos; @@ -75,6 +74,13 @@ static int save_hshift; static char pipec; #endif +struct ungot { + struct ungot *ug_next; + char ug_char; +}; +static struct ungot* ungot = NULL; +static int unget_end = 0; + static void multi_search(); /* @@ -228,8 +234,8 @@ exec_mca() every_first_cmd = save(cbuf); break; case A_OPT_TOGGLE: - toggle_option(optchar, cbuf, optflag); - optchar = '\0'; + toggle_option(curropt, opt_lower, cbuf, optflag); + curropt = NULL; break; case A_F_BRACKET: match_brac(cbuf[0], cbuf[1], 1, (int) number); @@ -282,22 +288,254 @@ exec_mca() } /* - * Add a character to a multi-character command. + * Is a character an erase or kill char? + */ + static int +is_erase_char(c) + int c; +{ + return (c == erase_char || c == erase2_char || c == kill_char); +} + +/* + * Handle the first char of an option (after the initial dash). + */ + static int +mca_opt_first_char(c) + int c; +{ + int flag = (optflag & ~OPT_NO_PROMPT); + if (flag == OPT_NO_TOGGLE) + { + switch (c) + { + case '_': + /* "__" = long option name. */ + optgetname = TRUE; + mca_opt_toggle(); + return (MCA_MORE); + } + } else + { + switch (c) + { + case '+': + /* "-+" = UNSET. */ + optflag = (flag == OPT_UNSET) ? + OPT_TOGGLE : OPT_UNSET; + mca_opt_toggle(); + return (MCA_MORE); + case '!': + /* "-!" = SET */ + optflag = (flag == OPT_SET) ? + OPT_TOGGLE : OPT_SET; + mca_opt_toggle(); + return (MCA_MORE); + case CONTROL('P'): + optflag ^= OPT_NO_PROMPT; + mca_opt_toggle(); + return (MCA_MORE); + case '-': + /* "--" = long option name. */ + optgetname = TRUE; + mca_opt_toggle(); + return (MCA_MORE); + } + } + /* Char was not handled here. */ + return (NO_MCA); +} + +/* + * Add a char to a long option name. + * See if we've got a match for an option name yet. + * If so, display the complete name and stop + * accepting chars until user hits RETURN. + */ + static int +mca_opt_nonfirst_char(c) + int c; +{ + char *p; + char *oname; + + if (curropt != NULL) + { + /* + * Already have a match for the name. + * Don't accept anything but erase/kill. + */ + if (is_erase_char(c)) + return (MCA_DONE); + return (MCA_MORE); + } + /* + * Add char to cmd buffer and try to match + * the option name. + */ + if (cmd_char(c) == CC_QUIT) + return (MCA_DONE); + p = get_cmdbuf(); + opt_lower = ASCII_IS_LOWER(p[0]); + curropt = findopt_name(&p, &oname, NULL); + if (curropt != NULL) + { + /* + * Got a match. + * Remember the option and + * display the full option name. + */ + cmd_reset(); + mca_opt_toggle(); + for (p = oname; *p != '\0'; p++) + { + c = *p; + if (!opt_lower && ASCII_IS_LOWER(c)) + c = ASCII_TO_UPPER(c); + if (cmd_char(c) != CC_OK) + return (MCA_DONE); + } + } + return (MCA_MORE); +} + +/* + * Handle a char of an option toggle command. + */ + static int +mca_opt_char(c) + int c; +{ + PARG parg; + + /* + * This may be a short option (single char), + * or one char of a long option name, + * or one char of the option parameter. + */ + if (curropt == NULL && len_cmdbuf() == 0) + { + int ret = mca_opt_first_char(c); + if (ret != NO_MCA) + return (ret); + } + if (optgetname) + { + /* We're getting a long option name. */ + if (c != '\n' && c != '\r') + return (mca_opt_nonfirst_char(c)); + if (curropt == NULL) + { + parg.p_string = get_cmdbuf(); + error("There is no --%s option", &parg); + return (MCA_DONE); + } + optgetname = FALSE; + cmd_reset(); + } else + { + if (is_erase_char(c)) + return (NO_MCA); + if (curropt != NULL) + /* We're getting the option parameter. */ + return (NO_MCA); + curropt = findopt(c); + if (curropt == NULL) + { + parg.p_string = propt(c); + error("There is no %s option", &parg); + return (MCA_DONE); + } + } + /* + * If the option which was entered does not take a + * parameter, toggle the option immediately, + * so user doesn't have to hit RETURN. + */ + if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE || + !opt_has_param(curropt)) + { + toggle_option(curropt, ASCII_IS_LOWER(c), "", optflag); + return (MCA_DONE); + } + /* + * Display a prompt appropriate for the option parameter. + */ + start_mca(A_OPT_TOGGLE, opt_prompt(curropt), (void*)NULL, 0); + return (MCA_MORE); +} + +/* + * Handle a char of a search command. + */ + static int +mca_search_char(c) + int c; +{ + int flag = 0; + + /* + * Certain characters as the first char of + * the pattern have special meaning: + * ! Toggle the NO_MATCH flag + * * Toggle the PAST_EOF flag + * @ Toggle the FIRST_FILE flag + */ + if (len_cmdbuf() > 0) + return (NO_MCA); + + switch (c) + { + case '*': + if (less_is_more) + break; + case CONTROL('E'): /* ignore END of file */ + if (mca != A_FILTER) + flag = SRCH_PAST_EOF; + break; + case '@': + if (less_is_more) + break; + case CONTROL('F'): /* FIRST file */ + if (mca != A_FILTER) + flag = SRCH_FIRST_FILE; + break; + case CONTROL('K'): /* KEEP position */ + if (mca != A_FILTER) + flag = SRCH_NO_MOVE; + break; + case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */ + flag = SRCH_NO_REGEX; + break; + case CONTROL('N'): /* NOT match */ + case '!': + flag = SRCH_NO_MATCH; + break; + } + + if (flag != 0) + { + search_type ^= flag; + mca_search(); + return (MCA_MORE); + } + return (NO_MCA); +} + +/* + * Handle a character of a multi-character command. */ static int mca_char(c) int c; { - char *p; - int flag; - char buf[3]; - PARG parg; + int ret; switch (mca) { case 0: /* - * Not in a multicharacter command. + * We're not in a multicharacter command. */ return (NO_MCA); @@ -320,7 +558,8 @@ mca_char(c) { /* * Not part of the number. - * Treat as a normal command character. + * End the number and treat this char + * as a normal command character. */ number = cmd_int(&fraction); mca = 0; @@ -330,218 +569,26 @@ mca_char(c) break; case A_OPT_TOGGLE: - /* - * Special case for the TOGGLE_OPTION command. - * If the option letter which was entered is a - * single-char option, execute the command immediately, - * so user doesn't have to hit RETURN. - * If the first char is + or -, this indicates - * OPT_UNSET or OPT_SET respectively, instead of OPT_TOGGLE. - * "--" begins inputting a long option name. - */ - if (optchar == '\0' && len_cmdbuf() == 0) - { - flag = (optflag & ~OPT_NO_PROMPT); - if (flag == OPT_NO_TOGGLE) - { - switch (c) - { - case '_': - /* "__" = long option name. */ - optgetname = TRUE; - mca_opt_toggle(); - return (MCA_MORE); - } - } else - { - switch (c) - { - case '+': - /* "-+" = UNSET. */ - optflag = (flag == OPT_UNSET) ? - OPT_TOGGLE : OPT_UNSET; - mca_opt_toggle(); - return (MCA_MORE); - case '!': - /* "-!" = SET */ - optflag = (flag == OPT_SET) ? - OPT_TOGGLE : OPT_SET; - mca_opt_toggle(); - return (MCA_MORE); - case CONTROL('P'): - optflag ^= OPT_NO_PROMPT; - mca_opt_toggle(); - return (MCA_MORE); - case '-': - /* "--" = long option name. */ - optgetname = TRUE; - mca_opt_toggle(); - return (MCA_MORE); - } - } - } - if (optgetname) - { - /* - * We're getting a long option name. - * See if we've matched an option name yet. - * If so, display the complete name and stop - * accepting chars until user hits RETURN. - */ - struct loption *o; - char *oname; - int lc; - - if (c == '\n' || c == '\r') - { - /* - * When the user hits RETURN, make sure - * we've matched an option name, then - * pretend he just entered the equivalent - * option letter. - */ - if (optchar == '\0') - { - parg.p_string = get_cmdbuf(); - error("There is no --%s option", &parg); - return (MCA_DONE); - } - optgetname = FALSE; - cmd_reset(); - c = optchar; - } else - { - if (optchar != '\0') - { - /* - * Already have a match for the name. - * Don't accept anything but erase/kill. - */ - if (c == erase_char || - c == erase2_char || - c == kill_char) - return (MCA_DONE); - return (MCA_MORE); - } - /* - * Add char to cmd buffer and try to match - * the option name. - */ - if (cmd_char(c) == CC_QUIT) - return (MCA_DONE); - p = get_cmdbuf(); - lc = ASCII_IS_LOWER(p[0]); - o = findopt_name(&p, &oname, NULL); - if (o != NULL) - { - /* - * Got a match. - * Remember the option letter and - * display the full option name. - */ - optchar = o->oletter; - if (!lc && ASCII_IS_LOWER(optchar)) - optchar = ASCII_TO_UPPER(optchar); - cmd_reset(); - mca_opt_toggle(); - for (p = oname; *p != '\0'; p++) - { - c = *p; - if (!lc && ASCII_IS_LOWER(c)) - c = ASCII_TO_UPPER(c); - if (cmd_char(c) != CC_OK) - return (MCA_DONE); - } - } - return (MCA_MORE); - } - } else - { - if (c == erase_char || c == erase2_char || c == kill_char) - break; - if (optchar != '\0') - /* We already have the option letter. */ - break; - } - - optchar = c; - if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE || - single_char_option(c)) - { - toggle_option(c, "", optflag); - return (MCA_DONE); - } - /* - * Display a prompt appropriate for the option letter. - */ - if ((p = opt_prompt(c)) == NULL) - { - buf[0] = '-'; - buf[1] = c; - buf[2] = '\0'; - p = buf; - } - start_mca(A_OPT_TOGGLE, p, (void*)NULL, 0); - return (MCA_MORE); + ret = mca_opt_char(c); + if (ret != NO_MCA) + return (ret); + break; case A_F_SEARCH: case A_B_SEARCH: case A_FILTER: - /* - * Special case for search commands. - * Certain characters as the first char of - * the pattern have special meaning: - * ! Toggle the NO_MATCH flag - * * Toggle the PAST_EOF flag - * @ Toggle the FIRST_FILE flag - */ - if (len_cmdbuf() > 0) - /* - * Only works for the first char of the pattern. - */ - break; + ret = mca_search_char(c); + if (ret != NO_MCA) + return (ret); + break; - flag = 0; - switch (c) - { - case '*': - if (less_is_more) - break; - case CONTROL('E'): /* ignore END of file */ - if (mca != A_FILTER) - flag = SRCH_PAST_EOF; - break; - case '@': - if (less_is_more) - break; - case CONTROL('F'): /* FIRST file */ - if (mca != A_FILTER) - flag = SRCH_FIRST_FILE; - break; - case CONTROL('K'): /* KEEP position */ - if (mca != A_FILTER) - flag = SRCH_NO_MOVE; - break; - case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */ - flag = SRCH_NO_REGEX; - break; - case CONTROL('N'): /* NOT match */ - case '!': - flag = SRCH_NO_MATCH; - break; - } - if (flag != 0) - { - search_type ^= flag; - mca_search(); - return (MCA_MORE); - } + default: + /* Other multicharacter command. */ break; } /* - * Any other multicharacter command - * is terminated by a newline. + * The multichar command is terminated by a newline. */ if (c == '\n' || c == '\r') { @@ -641,7 +688,7 @@ prompt() { register char *p; - if (ungotp != NULL && ungotp > ungot) + if (ungot != NULL) { /* * No prompt necessary if commands are from @@ -731,47 +778,58 @@ dispversion() public int getcc() { - if (ungotp == NULL) + if (unget_end) + { + /* + * We have just run out of ungotten chars. + */ + unget_end = 0; + if (len_cmdbuf() == 0 || !empty_screen()) + return (getchr()); + /* + * Command is incomplete, so try to complete it. + */ + switch (mca) + { + case A_DIGIT: + /* + * We have a number but no command. Treat as #g. + */ + return ('g'); + + case A_F_SEARCH: + case A_B_SEARCH: + /* + * We have "/string" but no newline. Add the \n. + */ + return ('\n'); + + default: + /* + * Some other incomplete command. Let user complete it. + */ + return (getchr()); + } + } + + if (ungot == NULL) + { /* * Normal case: no ungotten chars, so get one from the user. */ return (getchr()); - - if (ungotp > ungot) - /* - * Return the next ungotten char. - */ - return (*--ungotp); + } /* - * We have just run out of ungotten chars. + * Return the next ungotten char. */ - ungotp = NULL; - if (len_cmdbuf() == 0 || !empty_screen()) - return (getchr()); - /* - * Command is incomplete, so try to complete it. - */ - switch (mca) { - case A_DIGIT: - /* - * We have a number but no command. Treat as #g. - */ - return ('g'); - - case A_F_SEARCH: - case A_B_SEARCH: - /* - * We have "/string" but no newline. Add the \n. - */ - return ('\n'); - - default: - /* - * Some other incomplete command. Let user complete it. - */ - return (getchr()); + struct ungot *ug = ungot; + char c = ug->ug_char; + ungot = ug->ug_next; + free(ug); + unget_end = (ungot == NULL); + return (c); } } @@ -783,14 +841,11 @@ getcc() ungetcc(c) int c; { - if (ungotp == NULL) - ungotp = ungot; - if (ungotp >= ungot + sizeof(ungot)) - { - error("ungetcc overflow", NULL_PARG); - quit(QUIT_ERROR); - } - *ungotp++ = c; + struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot)); + + ug->ug_char = c; + ug->ug_next = ungot; + ungot = ug; } /* @@ -933,7 +988,7 @@ commands() mca = 0; cmd_accept(); number = 0; - optchar = '\0'; + curropt = NULL; /* * See if any signals need processing. diff --git a/contrib/less/configure b/contrib/less/configure index a417a53bfc2e..f2a7c8c73b3b 100755 --- a/contrib/less/configure +++ b/contrib/less/configure @@ -1,18 +1,22 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for less 1. +# Generated by GNU Autoconf 2.67 for less 1. +# # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -20,23 +24,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -44,7 +40,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -55,7 +57,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -78,13 +80,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -94,15 +89,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -114,12 +109,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -131,7 +130,248 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -145,8 +385,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -166,295 +410,19 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= @@ -471,8 +439,7 @@ test \$exitcode = 0") || { s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the @@ -482,29 +449,18 @@ test \$exitcode = 0") || { exit } - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -534,7 +490,7 @@ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -553,10 +509,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -570,11 +526,11 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -589,7 +545,6 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='less' @@ -597,6 +552,7 @@ PACKAGE_TARNAME='less' PACKAGE_VERSION='1' PACKAGE_STRING='less 1' PACKAGE_BUGREPORT='' +PACKAGE_URL='' ac_unique_file="forwback.c" # Factoring default headers for most tests. @@ -681,6 +637,7 @@ bindir program_transform_name prefix exec_prefix +PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -693,6 +650,7 @@ ac_user_opts=' enable_option_checking enable_largefile with_secure +with_no_float with_regex with_editor ' @@ -767,8 +725,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -813,8 +772,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -840,8 +798,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1045,8 +1002,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1062,8 +1018,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1093,17 +1048,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1120,15 +1075,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1151,8 +1104,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1166,8 +1118,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1182,11 +1134,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1225,13 +1175,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1271,7 +1219,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1332,6 +1280,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-secure Compile in secure mode + --with-no-float Do not use floating point --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library auto --with-editor=PROGRAM use PROGRAM as the default editor vi @@ -1341,13 +1290,14 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. +Report bugs to the package provider. _ACEOF ac_status=$? fi @@ -1411,21 +1361,426 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF less configure 1 -generated by GNU Autoconf 2.63 +generated by GNU Autoconf 2.67 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval "test \"\${$3+set}\"" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_type + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by less $as_me 1, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -1461,8 +1816,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done + $as_echo "PATH: $as_dir" + done IFS=$as_save_IFS } >&5 @@ -1499,9 +1854,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -1517,13 +1872,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -1535,11 +1890,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -1548,13 +1901,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -1573,11 +1926,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -1590,11 +1941,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -1608,11 +1957,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -1626,46 +1973,53 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h + # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -1676,19 +2030,23 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5 ; } fi done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -1696,7 +2054,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1711,11 +2069,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -1725,17 +2083,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -1747,43 +2105,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi - - - - - - - - - - - - - - - - - - - - - - - - +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -1805,9 +2140,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -1818,24 +2153,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -1845,9 +2180,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -1858,24 +2193,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -1884,7 +2219,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -1898,9 +2233,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -1911,24 +2246,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -1938,9 +2273,9 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -1952,18 +2287,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -1982,10 +2317,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -1997,9 +2332,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2010,24 +2345,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2041,9 +2376,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2054,24 +2389,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2084,7 +2419,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2095,57 +2430,37 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2161,8 +2476,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2178,17 +2493,17 @@ do done rm -f $ac_rmfiles -if { (ac_try="$ac_link_default" +if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -2205,7 +2520,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -2224,84 +2539,41 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" +if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -2316,32 +2588,83 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5 ; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2353,17 +2676,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" +if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -2376,31 +2699,23 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2414,37 +2729,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -2453,20 +2747,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2477,35 +2767,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2516,36 +2782,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2556,42 +2798,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -2608,18 +2825,14 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -2676,32 +2889,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -2712,17 +2902,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -2731,17 +2923,13 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for library containing strerror" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } -if test "${ac_cv_search_strerror+set}" = set; then +if test "${ac_cv_search_strerror+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -2766,54 +2954,27 @@ for ac_lib in '' cposix; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_strerror=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_strerror+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_strerror+set}" = set; then : break fi done -if test "${ac_cv_search_strerror+set}" = set; then - : +if test "${ac_cv_search_strerror+set}" = set; then : + else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 $as_echo "$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -2823,14 +2984,14 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -2845,11 +3006,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -2858,78 +3015,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : break fi @@ -2941,7 +3054,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -2952,11 +3065,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -2965,87 +3074,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c @@ -3055,9 +3117,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -3068,7 +3130,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue @@ -3088,7 +3150,7 @@ case `"$ac_path_GREP" --version 2>&1` in $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" @@ -3103,26 +3165,24 @@ esac $ac_path_GREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -3136,7 +3196,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue @@ -3156,7 +3216,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" @@ -3171,12 +3231,10 @@ esac $ac_path_EGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -3184,29 +3242,25 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" if test $ac_cv_c_compiler_gnu = yes; then - { $as_echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } -if test "${ac_cv_prog_gcc_traditional+set}" = set; then +if test "${ac_cv_prog_gcc_traditional+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then + $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no @@ -3215,24 +3269,20 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "$ac_pattern" >/dev/null 2>&1; then + $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 $as_echo "$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" @@ -3256,9 +3306,7 @@ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do fi done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -3284,10 +3332,10 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3295,11 +3343,11 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -3336,7 +3384,7 @@ case $as_dir/ in ;; esac -done + done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir @@ -3352,7 +3400,7 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -3366,15 +3414,15 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Checks for compilation model. # Check whether --enable-largefile was given. -if test "${enable_largefile+set}" = set; then +if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then - { $as_echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } -if test "${ac_cv_sys_largefile_CC+set}" = set; then +if test "${ac_cv_sys_largefile_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no @@ -3383,11 +3431,7 @@ else while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. @@ -3406,60 +3450,14 @@ main () return 0; } _ACEOF - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext break done @@ -3467,23 +3465,19 @@ rm -f core conftest.err conftest.$ac_objext rm -f conftest.$ac_ext fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi - { $as_echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if test "${ac_cv_sys_file_offset_bits+set}" = set; then +if test "${ac_cv_sys_file_offset_bits+set}" = set; then : $as_echo_n "(cached) " >&6 else while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. @@ -3502,38 +3496,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include @@ -3553,38 +3520,15 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; @@ -3596,17 +3540,13 @@ _ACEOF esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then - { $as_echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } -if test "${ac_cv_sys_large_files+set}" = set; then +if test "${ac_cv_sys_large_files+set}" = set; then : $as_echo_n "(cached) " >&6 else while :; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. @@ -3625,38 +3565,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include @@ -3676,38 +3589,15 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; @@ -3723,18 +3613,14 @@ fi # Checks for general libraries. -{ $as_echo "$as_me:$LINENO: checking for tgoto in -ltinfo" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgoto in -ltinfo" >&5 $as_echo_n "checking for tgoto in -ltinfo... " >&6; } -if test "${ac_cv_lib_tinfo_tgoto+set}" = set; then +if test "${ac_cv_lib_tinfo_tgoto+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltinfo $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -3752,60 +3638,31 @@ return tgoto (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_tinfo_tgoto=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_tinfo_tgoto=no + ac_cv_lib_tinfo_tgoto=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_tinfo_tgoto" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgoto" >&5 $as_echo "$ac_cv_lib_tinfo_tgoto" >&6; } -if test "x$ac_cv_lib_tinfo_tgoto" = x""yes; then +if test "x$ac_cv_lib_tinfo_tgoto" = x""yes; then : have_tinfo=yes else have_tinfo=no fi -{ $as_echo "$as_me:$LINENO: checking for initscr in -lxcurses" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lxcurses" >&5 $as_echo_n "checking for initscr in -lxcurses... " >&6; } -if test "${ac_cv_lib_xcurses_initscr+set}" = set; then +if test "${ac_cv_lib_xcurses_initscr+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lxcurses $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -3823,60 +3680,31 @@ return initscr (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_xcurses_initscr=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_xcurses_initscr=no + ac_cv_lib_xcurses_initscr=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_xcurses_initscr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xcurses_initscr" >&5 $as_echo "$ac_cv_lib_xcurses_initscr" >&6; } -if test "x$ac_cv_lib_xcurses_initscr" = x""yes; then +if test "x$ac_cv_lib_xcurses_initscr" = x""yes; then : have_xcurses=yes else have_xcurses=no fi -{ $as_echo "$as_me:$LINENO: checking for initscr in -lncursesw" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncursesw" >&5 $as_echo_n "checking for initscr in -lncursesw... " >&6; } -if test "${ac_cv_lib_ncursesw_initscr+set}" = set; then +if test "${ac_cv_lib_ncursesw_initscr+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncursesw $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -3894,60 +3722,31 @@ return initscr (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncursesw_initscr=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_ncursesw_initscr=no + ac_cv_lib_ncursesw_initscr=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_initscr" >&5 $as_echo "$ac_cv_lib_ncursesw_initscr" >&6; } -if test "x$ac_cv_lib_ncursesw_initscr" = x""yes; then +if test "x$ac_cv_lib_ncursesw_initscr" = x""yes; then : have_ncursesw=yes else have_ncursesw=no fi -{ $as_echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5 $as_echo_n "checking for initscr in -lncurses... " >&6; } -if test "${ac_cv_lib_ncurses_initscr+set}" = set; then +if test "${ac_cv_lib_ncurses_initscr+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lncurses $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -3965,60 +3764,31 @@ return initscr (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ncurses_initscr=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_ncurses_initscr=no + ac_cv_lib_ncurses_initscr=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5 $as_echo "$ac_cv_lib_ncurses_initscr" >&6; } -if test "x$ac_cv_lib_ncurses_initscr" = x""yes; then +if test "x$ac_cv_lib_ncurses_initscr" = x""yes; then : have_ncurses=yes else have_ncurses=no fi -{ $as_echo "$as_me:$LINENO: checking for initscr in -lcurses" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lcurses" >&5 $as_echo_n "checking for initscr in -lcurses... " >&6; } -if test "${ac_cv_lib_curses_initscr+set}" = set; then +if test "${ac_cv_lib_curses_initscr+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcurses $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4036,60 +3806,31 @@ return initscr (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_curses_initscr=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_curses_initscr=no + ac_cv_lib_curses_initscr=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_curses_initscr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_initscr" >&5 $as_echo "$ac_cv_lib_curses_initscr" >&6; } -if test "x$ac_cv_lib_curses_initscr" = x""yes; then +if test "x$ac_cv_lib_curses_initscr" = x""yes; then : have_curses=yes else have_curses=no fi -{ $as_echo "$as_me:$LINENO: checking for tgetent in -ltermcap" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 $as_echo_n "checking for tgetent in -ltermcap... " >&6; } -if test "${ac_cv_lib_termcap_tgetent+set}" = set; then +if test "${ac_cv_lib_termcap_tgetent+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltermcap $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4107,60 +3848,31 @@ return tgetent (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_termcap_tgetent=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_termcap_tgetent=no + ac_cv_lib_termcap_tgetent=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_termcap_tgetent" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 $as_echo "$ac_cv_lib_termcap_tgetent" >&6; } -if test "x$ac_cv_lib_termcap_tgetent" = x""yes; then +if test "x$ac_cv_lib_termcap_tgetent" = x""yes; then : have_termcap=yes else have_termcap=no fi -{ $as_echo "$as_me:$LINENO: checking for tgetent in -ltermlib" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermlib" >&5 $as_echo_n "checking for tgetent in -ltermlib... " >&6; } -if test "${ac_cv_lib_termlib_tgetent+set}" = set; then +if test "${ac_cv_lib_termlib_tgetent+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltermlib $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4178,43 +3890,18 @@ return tgetent (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_termlib_tgetent=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_termlib_tgetent=no + ac_cv_lib_termlib_tgetent=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_termlib_tgetent" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termlib_tgetent" >&5 $as_echo "$ac_cv_lib_termlib_tgetent" >&6; } -if test "x$ac_cv_lib_termlib_tgetent" = x""yes; then +if test "x$ac_cv_lib_termlib_tgetent" = x""yes; then : have_termlib=yes else have_termlib=no @@ -4222,19 +3909,14 @@ fi # Regular expressions (regcmp) are in -lgen on Solaris 2, # and in -lintl on SCO Unix. - -{ $as_echo "$as_me:$LINENO: checking for regcmp in -lgen" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for regcmp in -lgen" >&5 $as_echo_n "checking for regcmp in -lgen... " >&6; } -if test "${ac_cv_lib_gen_regcmp+set}" = set; then +if test "${ac_cv_lib_gen_regcmp+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgen $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4252,43 +3934,18 @@ return regcmp (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_gen_regcmp=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_gen_regcmp=no + ac_cv_lib_gen_regcmp=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_gen_regcmp" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_regcmp" >&5 $as_echo "$ac_cv_lib_gen_regcmp" >&6; } -if test "x$ac_cv_lib_gen_regcmp" = x""yes; then +if test "x$ac_cv_lib_gen_regcmp" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGEN 1 _ACEOF @@ -4297,19 +3954,14 @@ _ACEOF fi - -{ $as_echo "$as_me:$LINENO: checking for regcmp in -lintl" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for regcmp in -lintl" >&5 $as_echo_n "checking for regcmp in -lintl... " >&6; } -if test "${ac_cv_lib_intl_regcmp+set}" = set; then +if test "${ac_cv_lib_intl_regcmp+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lintl $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4327,43 +3979,18 @@ return regcmp (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_intl_regcmp=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_intl_regcmp=no + ac_cv_lib_intl_regcmp=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_intl_regcmp" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_intl_regcmp" >&5 $as_echo "$ac_cv_lib_intl_regcmp" >&6; } -if test "x$ac_cv_lib_intl_regcmp" = x""yes; then +if test "x$ac_cv_lib_intl_regcmp" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBINTL 1 _ACEOF @@ -4372,19 +3999,14 @@ _ACEOF fi - -{ $as_echo "$as_me:$LINENO: checking for regcmp in -lPW" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for regcmp in -lPW" >&5 $as_echo_n "checking for regcmp in -lPW... " >&6; } -if test "${ac_cv_lib_PW_regcmp+set}" = set; then +if test "${ac_cv_lib_PW_regcmp+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lPW $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4402,43 +4024,18 @@ return regcmp (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_PW_regcmp=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_PW_regcmp=no + ac_cv_lib_PW_regcmp=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_PW_regcmp" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_PW_regcmp" >&5 $as_echo "$ac_cv_lib_PW_regcmp" >&6; } -if test "x$ac_cv_lib_PW_regcmp" = x""yes; then +if test "x$ac_cv_lib_PW_regcmp" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPW 1 _ACEOF @@ -4449,7 +4046,7 @@ fi # Checks for terminal libraries -{ $as_echo "$as_me:$LINENO: checking for working terminal libraries" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working terminal libraries" >&5 $as_echo_n "checking for working terminal libraries... " >&6; } TERMLIBS= @@ -4472,11 +4069,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-ltinfo" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4487,38 +4080,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4530,11 +4098,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lxcurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4545,38 +4109,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4588,11 +4127,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lncursesw" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4603,38 +4138,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4646,11 +4156,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lncurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4661,38 +4167,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4704,11 +4185,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4719,38 +4196,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4763,11 +4215,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses -ltermcap" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4778,38 +4226,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4823,11 +4246,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-ltermcap" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4838,38 +4257,13 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi @@ -4881,11 +4275,7 @@ if test "x$TERMLIBS" = x; then TERMLIBS="-lcurses -ltermlib" SAVE_LIBS=$LIBS LIBS="$LIBS $TERMLIBS" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4896,63 +4286,34 @@ tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : termok=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - termok=no + termok=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$SAVE_LIBS if test $termok = no; then TERMLIBS=""; fi fi fi if test "x$TERMLIBS" = x; then - { $as_echo "$as_me:$LINENO: result: Cannot find terminal libraries - configure failed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Cannot find terminal libraries - configure failed" >&5 $as_echo "Cannot find terminal libraries - configure failed" >&6; } exit 1 fi -{ $as_echo "$as_me:$LINENO: result: using $TERMLIBS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $TERMLIBS" >&5 $as_echo "using $TERMLIBS" >&6; } LIBS="$LIBS $TERMLIBS" # Checks for header files. -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4967,48 +4328,23 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no + ac_cv_header_stdc=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -5018,18 +4354,14 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -5039,14 +4371,10 @@ fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5073,118 +4401,33 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : +if ac_fn_c_try_run "$LINENO"; then : + else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5194,159 +4437,11 @@ fi done - - - - - - - - - - - - - - - - for ac_header in ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h wctype.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5357,16 +4452,12 @@ done # Checks for typedefs, structures, and compiler characteristics. -{ $as_echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } -if test "${ac_cv_header_stat_broken+set}" = set; then +if test "${ac_cv_header_stat_broken+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5388,54 +4479,27 @@ extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1]; #endif _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stat_broken=no else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stat_broken=yes + ac_cv_header_stat_broken=yes fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stat_broken" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5 $as_echo "$ac_cv_header_stat_broken" >&6; } if test $ac_cv_header_stat_broken = yes; then -cat >>confdefs.h <<\_ACEOF -#define STAT_MACROS_BROKEN 1 -_ACEOF +$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then +if test "${ac_cv_c_const+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -5495,140 +4559,24 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_const=no + ac_cv_c_const=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then -cat >>confdefs.h <<\_ACEOF -#define const /**/ -_ACEOF +$as_echo "#define const /**/" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking for off_t" >&5 -$as_echo_n "checking for off_t... " >&6; } -if test "${ac_cv_type_off_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_off_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (off_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof ((off_t))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" +if test "x$ac_cv_type_off_t" = x""yes; then : - ac_cv_type_off_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -$as_echo "$ac_cv_type_off_t" >&6; } -if test "x$ac_cv_type_off_t" = x""yes; then - : else cat >>confdefs.h <<_ACEOF @@ -5637,102 +4585,9 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking for size_t" >&5 -$as_echo_n "checking for size_t... " >&6; } -if test "${ac_cv_type_size_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_size_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (size_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof ((size_t))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = x""yes; then : - ac_cv_type_size_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 -$as_echo "$ac_cv_type_size_t" >&6; } -if test "x$ac_cv_type_size_t" = x""yes; then - : else cat >>confdefs.h <<_ACEOF @@ -5741,16 +4596,12 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then +if test "${ac_cv_header_time+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5765,41 +4616,18 @@ return 0; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_time=no + ac_cv_header_time=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then -cat >>confdefs.h <<\_ACEOF -#define TIME_WITH_SYS_TIME 1 -_ACEOF +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi @@ -5825,31 +4653,6 @@ fi - - - - - - - - - - - - - - - - - - - - - - - - - @@ -5859,102 +4662,9 @@ fi # Checks for identifiers. -{ $as_echo "$as_me:$LINENO: checking for off_t" >&5 -$as_echo_n "checking for off_t... " >&6; } -if test "${ac_cv_type_off_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_off_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof (off_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -if (sizeof ((off_t))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" +if test "x$ac_cv_type_off_t" = x""yes; then : - ac_cv_type_off_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 -$as_echo "$ac_cv_type_off_t" >&6; } -if test "x$ac_cv_type_off_t" = x""yes; then - : else cat >>confdefs.h <<_ACEOF @@ -5963,13 +4673,9 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking for void" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for void" >&5 $as_echo_n "checking for void... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -5980,45 +4686,18 @@ void *foo = 0; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_VOID 1 -_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_VOID 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: checking for const" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for const" >&5 $as_echo_n "checking for const... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -6029,45 +4708,18 @@ const int foo = 0; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_CONST 1 -_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_CONST 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: checking for time_t" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for time_t" >&5 $as_echo_n "checking for time_t... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -6078,45 +4730,18 @@ time_t t = 0; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_TIME_T 1 -_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_TIME_T 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: checking for st_ino in struct stat" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for st_ino in struct stat" >&5 $as_echo_n "checking for st_ino in struct stat... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -6128,50 +4753,23 @@ struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_STAT_INO 1 -_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_STAT_INO 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Checks for library functions. -{ $as_echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then +if test "${ac_cv_type_signal+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -6184,35 +4782,14 @@ return *(signal (0, 0)) (0) == 1; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_signal=void + ac_cv_type_signal=void fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF @@ -6220,108 +4797,11 @@ cat >>confdefs.h <<_ACEOF _ACEOF - - - - - - - - - for ac_func in fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -6331,13 +4811,9 @@ done # AC_CHECK_FUNCS may not work for inline functions, so test these separately. -{ $as_echo "$as_me:$LINENO: checking for memcpy" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for memcpy" >&5 $as_echo_n "checking for memcpy... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STRING_H @@ -6351,51 +4827,20 @@ memcpy(0,0,0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_MEMCPY 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_MEMCPY 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for strchr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strchr" >&5 $as_echo_n "checking for strchr... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STRING_H @@ -6409,51 +4854,20 @@ strchr("x",'x'); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_STRCHR 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRCHR 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for strstr" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strstr" >&5 $as_echo_n "checking for strstr... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STRING_H @@ -6467,145 +4881,28 @@ strstr("x","x"); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_STRSTR 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRSTR 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext # Some systems have termios.h but not the corresponding functions. -{ $as_echo "$as_me:$LINENO: checking for tcgetattr" >&5 -$as_echo_n "checking for tcgetattr... " >&6; } -if test "${ac_cv_func_tcgetattr+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define tcgetattr to an innocuous variant, in case declares tcgetattr. - For example, HP-UX 11i declares gettimeofday. */ -#define tcgetattr innocuous_tcgetattr - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char tcgetattr (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef tcgetattr - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char tcgetattr (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_tcgetattr || defined __stub___tcgetattr -choke me -#endif - -int -main () -{ -return tcgetattr (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_tcgetattr=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_tcgetattr=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_tcgetattr" >&5 -$as_echo "$ac_cv_func_tcgetattr" >&6; } -if test "x$ac_cv_func_tcgetattr" = x""yes; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_TERMIOS_FUNCS 1 -_ACEOF +ac_fn_c_check_func "$LINENO" "tcgetattr" "ac_cv_func_tcgetattr" +if test "x$ac_cv_func_tcgetattr" = x""yes; then : + $as_echo "#define HAVE_TERMIOS_FUNCS 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking for fileno" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fileno" >&5 $as_echo_n "checking for fileno... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STDIO_H @@ -6619,51 +4916,20 @@ static int x; x = fileno(stdin); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_FILENO 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_FILENO 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for strerror" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strerror" >&5 $as_echo_n "checking for strerror... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_STDIO_H @@ -6683,51 +4949,20 @@ static char *x; x = strerror(0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_STRERROR 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_STRERROR 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for sys_errlist" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys_errlist" >&5 $as_echo_n "checking for sys_errlist... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -6738,141 +4973,20 @@ extern char *sys_errlist[]; static char **x; x = sys_errlist; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_SYS_ERRLIST 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for sigset_t" >&5 -$as_echo_n "checking for sigset_t... " >&6; } -if test "${ac_cv_type_sigset_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_type_sigset_t=no -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -if (sizeof (sigset_t)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - -int -main () -{ -if (sizeof ((sigset_t))) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_sigset_t=yes -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_sigset_t" >&5 -$as_echo "$ac_cv_type_sigset_t" >&6; } -if test "x$ac_cv_type_sigset_t" = x""yes; then +ac_fn_c_check_type "$LINENO" "sigset_t" "ac_cv_type_sigset_t" "#include +" +if test "x$ac_cv_type_sigset_t" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SIGSET_T 1 @@ -6882,13 +4996,9 @@ _ACEOF fi -{ $as_echo "$as_me:$LINENO: checking for sigemptyset" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigemptyset" >&5 $as_echo_n "checking for sigemptyset... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -6901,52 +5011,21 @@ sigset_t s; sigemptyset(&s); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_SIGEMPTYSET 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_SIGEMPTYSET 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext have_errno=no -{ $as_echo "$as_me:$LINENO: checking for errno" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for errno" >&5 $as_echo_n "checking for errno... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_ERRNO_H @@ -6960,48 +5039,15 @@ static int x; x = errno; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes - in errno.h" >&5 -$as_echo "yes - in errno.h" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_ERRNO 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - in errno.h" >&5 +$as_echo "yes - in errno.h" >&6; }; $as_echo "#define HAVE_ERRNO 1" >>confdefs.h have_errno=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test $have_errno = no; then -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_ERRNO_H @@ -7015,55 +5061,22 @@ extern int errno; static int x; x = errno; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes - must define" >&5 -$as_echo "yes - must define" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_ERRNO 1 -_ACEOF - cat >>confdefs.h <<\_ACEOF -#define MUST_DEFINE_ERRNO 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - must define" >&5 +$as_echo "yes - must define" >&6; }; $as_echo "#define HAVE_ERRNO 1" >>confdefs.h + $as_echo "#define MUST_DEFINE_ERRNO 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: checking for locale" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for locale" >&5 $as_echo_n "checking for locale... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -7076,51 +5089,20 @@ setlocale(LC_CTYPE,""); isprint(0); iscntrl(0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_LOCALE 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_LOCALE 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for ctype functions" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ctype functions" >&5 $as_echo_n "checking for ctype functions... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_CTYPE_H @@ -7134,51 +5116,20 @@ static int x; x = isupper(x); x = tolower(x); x = toupper(x); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_UPPER_LOWER 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_UPPER_LOWER 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext - -{ $as_echo "$as_me:$LINENO: checking for wctype functions" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype functions" >&5 $as_echo_n "checking for wctype functions... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -7189,53 +5140,22 @@ iswlower(0); iswupper(0); towlower(0); towupper(0); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_WCTYPE 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_WCTYPE 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext # Checks for external variable ospeed in the termcap library. have_ospeed=no -{ $as_echo "$as_me:$LINENO: checking termcap for ospeed" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking termcap for ospeed" >&5 $as_echo_n "checking termcap for ospeed... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7253,48 +5173,15 @@ ospeed = 0; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes - in termcap.h" >&5 -$as_echo "yes - in termcap.h" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_OSPEED 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - in termcap.h" >&5 +$as_echo "yes - in termcap.h" >&6; }; $as_echo "#define HAVE_OSPEED 1" >>confdefs.h have_ospeed=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test $have_ospeed = no; then -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -7305,75 +5192,80 @@ extern short ospeed; ospeed = 0; return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: yes - must define" >&5 -$as_echo "yes - must define" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_OSPEED 1 -_ACEOF - cat >>confdefs.h <<\_ACEOF -#define MUST_DEFINE_OSPEED 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes - must define" >&5 +$as_echo "yes - must define" >&6; }; $as_echo "#define HAVE_OSPEED 1" >>confdefs.h + $as_echo "#define MUST_DEFINE_OSPEED 1" >>confdefs.h else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi # Compile in secure mode? # Check whether --with-secure was given. -if test "${with_secure+set}" = set; then - withval=$with_secure; cat >>confdefs.h <<\_ACEOF -#define SECURE_COMPILE 1 -_ACEOF +if test "${with_secure+set}" = set; then : + withval=$with_secure; $as_echo "#define SECURE_COMPILE 1" >>confdefs.h else - cat >>confdefs.h <<\_ACEOF -#define SECURE_COMPILE 0 -_ACEOF + $as_echo "#define SECURE_COMPILE 0" >>confdefs.h fi +# Should we use floating point? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for floating point" >&5 +$as_echo_n "checking for floating point... " >&6; } + +# Check whether --with-no-float was given. +if test "${with_no_float+set}" = set; then : + withval=$with_no_float; WANT_NO_FLOAT=1 +else + WANT_NO_FLOAT=0 +fi + +if test $WANT_NO_FLOAT = 0; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +double f1 = 12.5; double f2 = f1*f1/2.5; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; }; $as_echo "#define HAVE_FLOAT 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled by user" >&5 +$as_echo "disabled by user" >&6; } +fi + # Checks for regular expression functions. have_regex=no have_posix_regex=unknown -{ $as_echo "$as_me:$LINENO: checking for regcomp" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for regcomp" >&5 $as_echo_n "checking for regcomp... " >&6; } # Select a regular expression library. WANT_REGEX=auto # Check whether --with-regex was given. -if test "${with_regex+set}" = set; then +if test "${with_regex+set}" = set; then : withval=$with_regex; WANT_REGEX="$withval" fi @@ -7382,14 +5274,10 @@ if test $have_regex = no; then if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then # Some versions of Solaris have a regcomp() function, but it doesn't work! # So we run a test program. If we're cross-compiling, do it the old way. -if test "$cross_compiling" = yes; then +if test "$cross_compiling" = yes; then : have_posix_regex=unknown else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7404,56 +5292,23 @@ if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */ #endif exit(0); } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_run "$LINENO"; then : have_posix_regex=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -have_posix_regex=no + have_posix_regex=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - if test $have_posix_regex = yes; then - { $as_echo "$as_me:$LINENO: result: using POSIX regcomp" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using POSIX regcomp" >&5 $as_echo "using POSIX regcomp" >&6; } - cat >>confdefs.h <<\_ACEOF -#define HAVE_POSIX_REGCOMP 1 -_ACEOF + $as_echo "#define HAVE_POSIX_REGCOMP 1" >>confdefs.h have_regex=yes elif test $have_posix_regex = unknown; then - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7466,45 +5321,16 @@ regex_t *r; regfree(r); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: using POSIX regcomp" >&5 +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using POSIX regcomp" >&5 $as_echo "using POSIX regcomp" >&6; } - cat >>confdefs.h <<\_ACEOF -#define HAVE_POSIX_REGCOMP 1 -_ACEOF + $as_echo "#define HAVE_POSIX_REGCOMP 1" >>confdefs.h have_regex=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi @@ -7512,18 +5338,14 @@ fi if test $have_regex = no; then if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then -{ $as_echo "$as_me:$LINENO: checking for pcre_compile in -lpcre" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5 $as_echo_n "checking for pcre_compile in -lpcre... " >&6; } -if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then +if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7541,47 +5363,20 @@ return pcre_compile (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcre_pcre_compile=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pcre_pcre_compile=no + ac_cv_lib_pcre_pcre_compile=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_compile" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_compile" >&5 $as_echo "$ac_cv_lib_pcre_pcre_compile" >&6; } -if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then - { $as_echo "$as_me:$LINENO: result: using pcre" >&5 -$as_echo "using pcre" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_PCRE 1 -_ACEOF +if test "x$ac_cv_lib_pcre_pcre_compile" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using pcre" >&5 +$as_echo "using pcre" >&6; }; $as_echo "#define HAVE_PCRE 1" >>confdefs.h LIBS="$LIBS -lpcre" have_regex=yes fi @@ -7590,96 +5385,10 @@ fi if test $have_regex = no; then if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then -{ $as_echo "$as_me:$LINENO: checking for regcmp" >&5 -$as_echo_n "checking for regcmp... " >&6; } -if test "${ac_cv_func_regcmp+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define regcmp to an innocuous variant, in case declares regcmp. - For example, HP-UX 11i declares gettimeofday. */ -#define regcmp innocuous_regcmp - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char regcmp (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef regcmp - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char regcmp (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_regcmp || defined __stub___regcmp -choke me -#endif - -int -main () -{ -return regcmp (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_regcmp=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_regcmp=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_regcmp" >&5 -$as_echo "$ac_cv_func_regcmp" >&6; } -if test "x$ac_cv_func_regcmp" = x""yes; then - { $as_echo "$as_me:$LINENO: result: using regcmp" >&5 -$as_echo "using regcmp" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_REGCMP 1 -_ACEOF +ac_fn_c_check_func "$LINENO" "regcmp" "ac_cv_func_regcmp" +if test "x$ac_cv_func_regcmp" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using regcmp" >&5 +$as_echo "using regcmp" >&6; }; $as_echo "#define HAVE_REGCMP 1" >>confdefs.h have_regex=yes fi @@ -7688,11 +5397,7 @@ fi if test $have_regex = no; then if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "regexp.h" @@ -7704,150 +5409,31 @@ regcomp(""); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - { $as_echo "$as_me:$LINENO: result: using V8 regcomp" >&5 -$as_echo "using V8 regcomp" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_V8_REGCOMP 1 -_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using V8 regcomp" >&5 +$as_echo "using V8 regcomp" >&6; }; $as_echo "#define HAVE_V8_REGCOMP 1" >>confdefs.h have_regex=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi fi if test $have_regex = no && test -f ${srcdir}/regexp.c; then if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then -{ $as_echo "$as_me:$LINENO: result: using V8 regcomp -- local source" >&5 -$as_echo "using V8 regcomp -- local source" >&6; }; cat >>confdefs.h <<\_ACEOF -#define HAVE_V8_REGCOMP 1 -_ACEOF - cat >>confdefs.h <<\_ACEOF -#define HAVE_REGEXEC2 1 -_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using V8 regcomp -- local source" >&5 +$as_echo "using V8 regcomp -- local source" >&6; }; $as_echo "#define HAVE_V8_REGCOMP 1" >>confdefs.h + $as_echo "#define HAVE_REGEXEC2 1" >>confdefs.h REGEX_O='regexp.$(O)' have_regex=yes fi fi if test $have_regex = no; then if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then -{ $as_echo "$as_me:$LINENO: result: using re_comp" >&5 -$as_echo "using re_comp" >&6; }; { $as_echo "$as_me:$LINENO: checking for re_comp" >&5 -$as_echo_n "checking for re_comp... " >&6; } -if test "${ac_cv_func_re_comp+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define re_comp to an innocuous variant, in case declares re_comp. - For example, HP-UX 11i declares gettimeofday. */ -#define re_comp innocuous_re_comp - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char re_comp (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef re_comp - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char re_comp (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_re_comp || defined __stub___re_comp -choke me -#endif - -int -main () -{ -return re_comp (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func_re_comp=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func_re_comp=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_re_comp" >&5 -$as_echo "$ac_cv_func_re_comp" >&6; } -if test "x$ac_cv_func_re_comp" = x""yes; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_RE_COMP 1 -_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using re_comp" >&5 +$as_echo "using re_comp" >&6; }; ac_fn_c_check_func "$LINENO" "re_comp" "ac_cv_func_re_comp" +if test "x$ac_cv_func_re_comp" = x""yes; then : + $as_echo "#define HAVE_RE_COMP 1" >>confdefs.h have_regex=yes fi @@ -7855,31 +5441,26 @@ fi fi if test $have_regex = no; then -{ $as_echo "$as_me:$LINENO: result: cannot find regular expression library" >&5 -$as_echo "cannot find regular expression library" >&6; }; cat >>confdefs.h <<\_ACEOF -#define NO_REGEX 1 -_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot find regular expression library" >&5 +$as_echo "cannot find regular expression library" >&6; }; $as_echo "#define NO_REGEX 1" >>confdefs.h fi # Check whether --with-editor was given. -if test "${with_editor+set}" = set; then +if test "${with_editor+set}" = set; then : withval=$with_editor; cat >>confdefs.h <<_ACEOF #define EDIT_PGM "$withval" _ACEOF else - cat >>confdefs.h <<\_ACEOF -#define EDIT_PGM "vi" -_ACEOF + $as_echo "#define EDIT_PGM \"vi\"" >>confdefs.h fi - ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -7909,13 +5490,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -7923,8 +5504,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -7947,11 +5528,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -7965,14 +5546,15 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -7984,9 +5566,10 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -7996,17 +5579,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -8014,23 +5598,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -8038,7 +5614,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -8049,7 +5631,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -8072,13 +5654,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -8088,15 +5663,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -8108,12 +5683,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -8125,7 +5704,89 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -8139,8 +5800,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -8160,76 +5825,25 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -8258,8 +5872,56 @@ fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -8278,10 +5940,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -8296,13 +5958,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Save the log message, to keep $[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by less $as_me 1, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -8333,13 +6001,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -8355,16 +6025,17 @@ $config_files Configuration headers: $config_headers -Report bugs to ." +Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ less config.status 1 -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.67, + with options \\"\$ac_cs_config\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -8380,11 +6051,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -8398,27 +6074,29 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -8426,11 +6104,10 @@ Try \`$0 --help' for more information." >&2 ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" + *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac @@ -8479,9 +6156,7 @@ do "defines.h") CONFIG_HEADERS="$CONFIG_HEADERS defines.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -8507,7 +6182,7 @@ $debug || trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. @@ -8518,11 +6193,7 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -8530,7 +6201,13 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' @@ -8547,24 +6224,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -8586,7 +6257,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -8600,7 +6271,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -8653,22 +6324,28 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -8696,9 +6373,7 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -8783,9 +6458,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -8798,9 +6471,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -8828,12 +6499,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -8844,7 +6513,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -8857,9 +6526,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -8887,47 +6554,7 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -8979,7 +6606,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= - ac_sed_dataroot=' /datarootdir/ { p @@ -8989,12 +6615,11 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p -' +/@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -9004,7 +6629,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -9032,26 +6657,22 @@ s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -9062,25 +6683,19 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; @@ -9090,15 +6705,12 @@ $as_echo "$as_me: error: could not create -" >&2;} done # for ac_tag -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -9119,10 +6731,10 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/contrib/less/configure.ac b/contrib/less/configure.ac index 6188dd50d136..0b386b075724 100644 --- a/contrib/less/configure.ac +++ b/contrib/less/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -# Copyright (C) 1984-2009 Mark Nudelman +# Copyright (C) 1984-2011 Mark Nudelman # # You may distribute under the terms of either the GNU General Public # License or the Less License, as specified in the README file. @@ -195,6 +195,8 @@ AH_TEMPLATE([HAVE_REGEXEC2], []) AH_TEMPLATE([HAVE_VOID], [Define HAVE_VOID if your compiler supports the "void" type.]) +AH_TEMPLATE([HAVE_FLOAT], + [Define HAVE_FLOAT if your compiler supports the "double" type.]) AH_TEMPLATE([HAVE_CONST], [Define HAVE_CONST if your compiler supports the "const" modifier.]) AH_TEMPLATE([HAVE_STAT_INO], @@ -366,6 +368,18 @@ AC_ARG_WITH(secure, [ --with-secure Compile in secure mode], AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0)) +# Should we use floating point? +AC_MSG_CHECKING(for floating point) +AC_ARG_WITH(no-float, + [ --with-no-float Do not use floating point], + WANT_NO_FLOAT=1, WANT_NO_FLOAT=0) +if test $WANT_NO_FLOAT = 0; then + AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;], + [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT)], [AC_MSG_RESULT(no)]) +else + AC_MSG_RESULT(disabled by user) +fi + # Checks for regular expression functions. have_regex=no have_posix_regex=unknown diff --git a/contrib/less/cvt.c b/contrib/less/cvt.c index ec54b599dcd8..74439847e013 100644 --- a/contrib/less/cvt.c +++ b/contrib/less/cvt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/decode.c b/contrib/less/decode.c index 628856dbc20d..65d65bb65624 100644 --- a/contrib/less/decode.c +++ b/contrib/less/decode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -202,6 +202,7 @@ static unsigned char edittable[] = SK(SK_UP_ARROW),0, EC_UP, /* UPARROW */ ESC,'j',0, EC_DOWN, /* ESC j */ SK(SK_DOWN_ARROW),0, EC_DOWN, /* DOWNARROW */ + CONTROL('G'),0, EC_ABORT, /* CTRL-G */ }; /* diff --git a/contrib/less/defines.ds b/contrib/less/defines.ds index ca2e534a496e..4dbbd6518a18 100644 --- a/contrib/less/defines.ds +++ b/contrib/less/defines.ds @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/defines.h.in b/contrib/less/defines.h.in index 8da1baeceda5..8d4506383f75 100644 --- a/contrib/less/defines.h.in +++ b/contrib/less/defines.h.in @@ -219,6 +219,9 @@ /* Define HAVE_FILENO if you have the fileno() macro. */ #undef HAVE_FILENO +/* Define HAVE_FLOAT if your compiler supports the "double" type. */ +#undef HAVE_FLOAT + /* Define to 1 if you have the `fsync' function. */ #undef HAVE_FSYNC @@ -386,6 +389,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/contrib/less/defines.o2 b/contrib/less/defines.o2 index 8092dd50d824..0fd8cc735036 100644 --- a/contrib/less/defines.o2 +++ b/contrib/less/defines.o2 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/defines.o9 b/contrib/less/defines.o9 index 092856b83548..3bb1d2cb8caa 100644 --- a/contrib/less/defines.o9 +++ b/contrib/less/defines.o9 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/defines.wn b/contrib/less/defines.wn index 38f0fe22047a..416a548e745c 100644 --- a/contrib/less/defines.wn +++ b/contrib/less/defines.wn @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -272,7 +272,7 @@ #define HAVE_SYSTEM 1 /* Define if you have the snprintf function. */ -#define HAVE_SNPRINTF 0 +#define HAVE_SNPRINTF 1 /* Define if you have the header file. */ #define HAVE_CTYPE_H 1 @@ -286,8 +286,11 @@ /* Define if you have the header file. */ #define HAVE_FCNTL_H 1 +/* Define HAVE_FLOAT if your compiler supports the "double" type. */ +#define HAVE_FLOAT 1 + /* Define if you have the header file. */ -#define HAVE_LIMITS_H 0 +#define HAVE_LIMITS_H 1 /* Define if you have the header file. */ #define HAVE_STDIO_H 1 @@ -331,3 +334,6 @@ #define popen _popen #define pclose _pclose +#define snprintf _snprintf + +#pragma warning(disable:4996) diff --git a/contrib/less/edit.c b/contrib/less/edit.c index 001ce5fd7fa2..4781d95988e4 100644 --- a/contrib/less/edit.c +++ b/contrib/less/edit.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/filename.c b/contrib/less/filename.c index fb6f389f9e14..0bbe82ab21cd 100644 --- a/contrib/less/filename.c +++ b/contrib/less/filename.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -400,6 +400,7 @@ fexpand(s) return (e); } + #if TAB_COMPLETE_FILENAME /* @@ -1057,3 +1058,22 @@ shell_coption() { return ("-c"); } + +/* + * Return last component of a pathname. + */ + public char * +last_component(name) + char *name; +{ + char *slash; + + for (slash = name + strlen(name); slash > name; ) + { + --slash; + if (*slash == *PATHNAME_SEP || *slash == '/') + return (slash + 1); + } + return (name); +} + diff --git a/contrib/less/forwback.c b/contrib/less/forwback.c index 51b6d453753a..cbb618209866 100644 --- a/contrib/less/forwback.c +++ b/contrib/less/forwback.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/funcs.h b/contrib/less/funcs.h index 38b82f43447e..8464ada4b64f 100644 --- a/contrib/less/funcs.h +++ b/contrib/less/funcs.h @@ -127,6 +127,7 @@ public char * bad_file (); public POSITION filesize (); public char * shell_coption (); + public char * last_component (); public int eof_displayed (); public int entire_file_displayed (); public void squish_check (); @@ -211,9 +212,10 @@ public void opt_quote (); public void opt_query (); public int get_swindow (); + public char * propt (); public void scan_option (); public void toggle_option (); - public int single_char_option (); + public int opt_has_param (); public char * opt_prompt (); public int isoptpending (); public void nopendopt (); diff --git a/contrib/less/help.c b/contrib/less/help.c index 531aa16f29f3..85b0a4adf946 100644 --- a/contrib/less/help.c +++ b/contrib/less/help.c @@ -115,6 +115,8 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','h','e','l','p',' ','(','f','r','o','m',' ','c','o','m','m','a','n','d',' ','l','i','n','e',')','.','\n', ' ',' ','-','a',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','s','e','a','r','c','h','-','s','k','i','p','-','s','c','r','e','e','n','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','s','k','i','p','s',' ','c','u','r','r','e','n','t',' ','s','c','r','e','e','n','.','\n', +' ',' ','-','A',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','S','E','A','R','C','H','-','S','K','I','P','-','S','C','R','E','E','N','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','F','o','r','w','a','r','d',' ','s','e','a','r','c','h',' ','a','l','w','a','y','s',' ','s','k','i','p','s',' ','t','a','r','g','e','t',' ','l','i','n','e','.','\n', ' ',' ','-','b',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','b','u','f','f','e','r','s','=','[','_','\b','N',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','N','u','m','b','e','r',' ','o','f',' ','b','u','f','f','e','r','s','.','\n', ' ',' ','-','B',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','a','u','t','o','-','b','u','f','f','e','r','s','\n', @@ -147,6 +149,8 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','i','s','p','l','a','y',' ','a',' ','s','t','a','t','u','s',' ','c','o','l','u','m','n',' ','a','t',' ','l','e','f','t',' ','e','d','g','e',' ','o','f',' ','s','c','r','e','e','n','.','\n', ' ',' ','-','k',' ','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']',' ',' ','.',' ',' ','-','-','l','e','s','s','k','e','y','-','f','i','l','e','=','[','_','\b','f','_','\b','i','_','\b','l','_','\b','e',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','U','s','e',' ','a',' ','l','e','s','s','k','e','y',' ','f','i','l','e','.','\n', +' ',' ','-','K',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','-','-','q','u','i','t','-','o','n','-','i','n','t','r','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','E','x','i','t',' ','l','e','s','s',' ','i','n',' ','r','e','s','p','o','n','s','e',' ','t','o',' ','c','t','r','l','-','C','.','\n', ' ',' ','-','L',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','l','e','s','s','o','p','e','n','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','I','g','n','o','r','e',' ','t','h','e',' ','L','E','S','S','O','P','E','N',' ','e','n','v','i','r','o','n','m','e','n','t',' ','v','a','r','i','a','b','l','e','.','\n', ' ',' ','-','m',' ',' ','-','M',' ',' ','.','.','.','.',' ',' ','-','-','l','o','n','g','-','p','r','o','m','p','t',' ',' ','-','-','L','O','N','G','-','P','R','O','M','P','T','\n', @@ -197,6 +201,11 @@ constant char helpdata[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','d','i','s','p','l','a','y',' ','t','i','l','d','e','s',' ','a','f','t','e','r',' ','e','n','d',' ','o','f',' ','f','i','l','e','.','\n', ' ',' ','-','#',' ','[','_','\b','N',']',' ',' ','.','.','.','.',' ',' ','-','-','s','h','i','f','t','=','[','_','\b','N',']','\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','H','o','r','i','z','o','n','t','a','l',' ','s','c','r','o','l','l',' ','a','m','o','u','n','t',' ','(','0',' ','=',' ','o','n','e',' ','h','a','l','f',' ','s','c','r','e','e','n',' ','w','i','d','t','h',')','\n', +' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','n','o','-','k','e','y','p','a','d','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','D','o','n','\'','t',' ','s','e','n','d',' ','k','e','y','p','a','d',' ','i','n','i','t','/','d','e','i','n','i','t',' ','s','e','q','u','e','n','c','e','.','\n', +' ',' ',' ',' ',' ',' ','.','.','.','.','.','.','.','.',' ',' ','-','-','f','o','l','l','o','w','-','n','a','m','e','\n', +' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','T','h','e',' ','F',' ','c','o','m','m','a','n','d',' ','c','h','a','n','g','e','s',' ','f','i','l','e','s',' ','i','f',' ','t','h','e',' ','i','n','p','u','t',' ','f','i','l','e',' ','i','s',' ','r','e','n','a','m','e','d','.','\n', +'\n', '\n', ' ','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','\n', '\n', diff --git a/contrib/less/ifile.c b/contrib/less/ifile.c index 2a351d1af5d8..971e3b5e25e0 100644 --- a/contrib/less/ifile.c +++ b/contrib/less/ifile.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/input.c b/contrib/less/input.c index 058dec3a1ca6..b82868bca4d2 100644 --- a/contrib/less/input.c +++ b/contrib/less/input.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -181,6 +181,11 @@ forw_line(curr_pos) { do { + if (ABORT_SIGS()) + { + null_line(); + return (NULL_POSITION); + } c = ch_forw_get(); } while (c != '\n' && c != EOI); new_pos = ch_tell(); diff --git a/contrib/less/jump.c b/contrib/less/jump.c index e4bfa807a083..d7ec77046f80 100644 --- a/contrib/less/jump.c +++ b/contrib/less/jump.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/less.h b/contrib/less/less.h index ff032d7f1d95..bad585d3a1f5 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -345,6 +345,7 @@ struct textlist #define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */ #define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */ #define SRCH_FILTER (1 << 13) /* Search is for '&' (filter) command */ +#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */ #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ (((t) & ~SRCH_FORW) | SRCH_BACK) : \ @@ -474,6 +475,7 @@ struct textlist #define QUIT_OK 0 #define QUIT_ERROR 1 +#define QUIT_INTERRUPT 2 #define QUIT_SAVED_STATUS (-1) #define FOLLOW_DESC 0 diff --git a/contrib/less/less.hlp b/contrib/less/less.hlp index 15ece5a017ce..84d951f0d53f 100644 --- a/contrib/less/less.hlp +++ b/contrib/less/less.hlp @@ -112,6 +112,8 @@ Display help (from command line). -a ........ --search-skip-screen Forward search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Forward search always skips target line. -b [_N] .... --buffers=[_N] Number of buffers. -B ........ --auto-buffers @@ -144,6 +146,8 @@ Display a status column at left edge of screen. -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] Use a lesskey file. + -K --quit-on-intr + Exit less in response to ctrl-C. -L ........ --no-lessopen Ignore the LESSOPEN environment variable. -m -M .... --long-prompt --LONG-PROMPT @@ -194,6 +198,11 @@ Don't display tildes after end of file. -# [_N] .... --shift=[_N] Horizontal scroll amount (0 = one half screen width) + ........ --no-keypad + Don't send keypad init/deinit sequence. + ........ --follow-name + The F command changes files if the input file is renamed. + --------------------------------------------------------------------------- diff --git a/contrib/less/less.man b/contrib/less/less.man index 00b9684a879f..86e329c0fa53 100644 --- a/contrib/less/less.man +++ b/contrib/less/less.man @@ -10,7 +10,7 @@ LESS(1) LESS(1) less --help less -V less --version - less [-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~] + less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~] [-b space] [-h lines] [-j line] [-k keyfile] [-{oO} logfile] [-p pattern] [-P prompt] [-t tag] [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines] @@ -55,7 +55,7 @@ LESS(1) LESS(1) Like SPACE, but scrolls a full screenful, even if it reaches end-of-file in the process. - RETURN or ^N or e or ^E or j or ^J + ENTER or RETURN or ^N or e or ^E or j or ^J Scroll forward N lines, default 1. The entire N lines are dis- played, even if N is more than the screen size. @@ -172,7 +172,7 @@ LESS(1) LESS(1) Search forward in the file for the N-th line containing the pat- tern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your - system. The search starts at the second line displayed (but see + system. The search starts at the first line displayed (but see the -a and -j options, which change this). Certain characters are special if entered at the beginning of @@ -270,98 +270,98 @@ LESS(1) LESS(1) ^N or ! Display only lines which do NOT match the pattern. - ^R Don't interpret regular expression metacharacters; that + ^R Don't interpret regular expression metacharacters; that is, do a simple textual comparison. :e [filename] - Examine a new file. If the filename is missing, the "current" - file (see the :n and :p commands below) from the list of files - in the command line is re-examined. A percent sign (%) in the - filename is replaced by the name of the current file. A pound - sign (#) is replaced by the name of the previously examined - file. However, two consecutive percent signs are simply + Examine a new file. If the filename is missing, the "current" + file (see the :n and :p commands below) from the list of files + in the command line is re-examined. A percent sign (%) in the + filename is replaced by the name of the current file. A pound + sign (#) is replaced by the name of the previously examined + file. However, two consecutive percent signs are simply replaced with a single percent sign. This allows you to enter a - filename that contains a percent sign in the name. Similarly, - two consecutive pound signs are replaced with a single pound - sign. The filename is inserted into the command line list of - files so that it can be seen by subsequent :n and :p commands. + filename that contains a percent sign in the name. Similarly, + two consecutive pound signs are replaced with a single pound + sign. The filename is inserted into the command line list of + files so that it can be seen by subsequent :n and :p commands. If the filename consists of several files, they are all inserted - into the list of files and the first one is examined. If the + into the list of files and the first one is examined. If the filename contains one or more spaces, the entire filename should be enclosed in double quotes (also see the -" option). ^X^V or E - Same as :e. Warning: some systems use ^V as a special literal- - ization character. On such systems, you may not be able to use + Same as :e. Warning: some systems use ^V as a special literal- + ization character. On such systems, you may not be able to use ^V. - :n Examine the next file (from the list of files given in the com- - mand line). If a number N is specified, the N-th next file is + :n Examine the next file (from the list of files given in the com- + mand line). If a number N is specified, the N-th next file is examined. :p Examine the previous file in the command line list. If a number N is specified, the N-th previous file is examined. - :x Examine the first file in the command line list. If a number N + :x Examine the first file in the command line list. If a number N is specified, the N-th file in the list is examined. :d Remove the current file from the list of files. - t Go to the next tag, if there were more than one matches for the + t Go to the next tag, if there were more than one matches for the current tag. See the -t option for more details about tags. - T Go to the previous tag, if there were more than one matches for + T Go to the previous tag, if there were more than one matches for the current tag. = or ^G or :f - Prints some information about the file being viewed, including - its name and the line number and byte offset of the bottom line - being displayed. If possible, it also prints the length of the - file, the number of lines in the file and the percent of the + Prints some information about the file being viewed, including + its name and the line number and byte offset of the bottom line + being displayed. If possible, it also prints the length of the + file, the number of lines in the file and the percent of the file above the last displayed line. - - Followed by one of the command line option letters (see OPTIONS - below), this will change the setting of that option and print a - message describing the new setting. If a ^P (CONTROL-P) is + - Followed by one of the command line option letters (see OPTIONS + below), this will change the setting of that option and print a + message describing the new setting. If a ^P (CONTROL-P) is entered immediately after the dash, the setting of the option is - changed but no message is printed. If the option letter has a - numeric value (such as -b or -h), or a string value (such as -P - or -t), a new value may be entered after the option letter. If - no new value is entered, a message describing the current set- + changed but no message is printed. If the option letter has a + numeric value (such as -b or -h), or a string value (such as -P + or -t), a new value may be entered after the option letter. If + no new value is entered, a message describing the current set- ting is printed and nothing is changed. - -- Like the - command, but takes a long option name (see OPTIONS - below) rather than a single option letter. You must press - RETURN after typing the option name. A ^P immediately after the - second dash suppresses printing of a message describing the new - setting, as in the - command. + -- Like the - command, but takes a long option name (see OPTIONS + below) rather than a single option letter. You must press ENTER + or RETURN after typing the option name. A ^P immediately after + the second dash suppresses printing of a message describing the + new setting, as in the - command. - -+ Followed by one of the command line option letters this will - reset the option to its default setting and print a message - describing the new setting. (The "-+X" command does the same - thing as "-+X" on the command line.) This does not work for + -+ Followed by one of the command line option letters this will + reset the option to its default setting and print a message + describing the new setting. (The "-+X" command does the same + thing as "-+X" on the command line.) This does not work for string-valued options. - --+ Like the -+ command, but takes a long option name rather than a + --+ Like the -+ command, but takes a long option name rather than a single option letter. - -! Followed by one of the command line option letters, this will - reset the option to the "opposite" of its default setting and - print a message describing the new setting. This does not work + -! Followed by one of the command line option letters, this will + reset the option to the "opposite" of its default setting and + print a message describing the new setting. This does not work for numeric or string-valued options. - --! Like the -! command, but takes a long option name rather than a + --! Like the -! command, but takes a long option name rather than a single option letter. - _ (Underscore.) Followed by one of the command line option let- - ters, this will print a message describing the current setting + _ (Underscore.) Followed by one of the command line option let- + ters, this will print a message describing the current setting of that option. The setting of the option is not changed. __ (Double underscore.) Like the _ (underscore) command, but takes a long option name rather than a single option letter. You must - press RETURN after typing the option name. + press ENTER or RETURN after typing the option name. - +cmd Causes the specified cmd to be executed each time a new file is + +cmd Causes the specified cmd to be executed each time a new file is examined. For example, +G causes less to initially display each file starting at the end rather than the beginning. @@ -370,51 +370,49 @@ LESS(1) LESS(1) q or Q or :q or :Q or ZZ Exits less. - The following four commands may or may not be valid, depending on your + The following four commands may or may not be valid, depending on your particular installation. - - v Invokes an editor to edit the current file being viewed. The + v Invokes an editor to edit the current file being viewed. The editor is taken from the environment variable VISUAL if defined, - or EDITOR if VISUAL is not defined, or defaults to "vi" if nei- - ther VISUAL nor EDITOR is defined. See also the discussion of + or EDITOR if VISUAL is not defined, or defaults to "vi" if nei- + ther VISUAL nor EDITOR is defined. See also the discussion of LESSEDIT under the section on PROMPTS below. ! shell-command - Invokes a shell to run the shell-command given. A percent sign - (%) in the command is replaced by the name of the current file. + Invokes a shell to run the shell-command given. A percent sign + (%) in the command is replaced by the name of the current file. A pound sign (#) is replaced by the name of the previously exam- - ined file. "!!" repeats the last shell command. "!" with no - shell command simply invokes a shell. On Unix systems, the - shell is taken from the environment variable SHELL, or defaults - to "sh". On MS-DOS and OS/2 systems, the shell is the normal + ined file. "!!" repeats the last shell command. "!" with no + shell command simply invokes a shell. On Unix systems, the + shell is taken from the environment variable SHELL, or defaults + to "sh". On MS-DOS and OS/2 systems, the shell is the normal command processor. | shell-command - represents any mark letter. Pipes a section of the input - file to the given shell command. The section of the file to be - piped is between the first line on the current screen and the - position marked by the letter. may also be ^ or $ to indi- + represents any mark letter. Pipes a section of the input + file to the given shell command. The section of the file to be + piped is between the first line on the current screen and the + position marked by the letter. may also be ^ or $ to indi- cate beginning or end of file respectively. If is . or new- line, the current screen is piped. s filename - Save the input to a file. This only works if the input is a + Save the input to a file. This only works if the input is a pipe, not an ordinary file. - OPTIONS - Command line options are described below. Most options may be changed + Command line options are described below. Most options may be changed while less is running, via the "-" command. - Most options may be given in one of two forms: either a dash followed - by a single letter, or two dashes followed by a long option name. A - long option name may be abbreviated as long as the abbreviation is + Most options may be given in one of two forms: either a dash followed + by a single letter, or two dashes followed by a long option name. A + long option name may be abbreviated as long as the abbreviation is unambiguous. For example, --quit-at-eof may be abbreviated --quit, but not --qui, since both --quit-at-eof and --quiet begin with --qui. Some - long option names are in uppercase, such as --QUIT-AT-EOF, as distinct - from --quit-at-eof. Such option names need only have their first let- - ter capitalized; the remainder of the name may be in either case. For + long option names are in uppercase, such as --QUIT-AT-EOF, as distinct + from --quit-at-eof. Such option names need only have their first let- + ter capitalized; the remainder of the name may be in either case. For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF. Options are also taken from the environment variable "LESS". For exam- @@ -427,33 +425,47 @@ LESS(1) LESS(1) LESS="-options"; export LESS - On MS-DOS, you don't need the quotes, but you should replace any per- + On MS-DOS, you don't need the quotes, but you should replace any per- cent signs in the options string by double percent signs. - The environment variable is parsed before the command line, so command - line options override the LESS environment variable. If an option - appears in the LESS variable, it can be reset to its default value on + The environment variable is parsed before the command line, so command + line options override the LESS environment variable. If an option + appears in the LESS variable, it can be reset to its default value on the command line by beginning the command line option with "-+". - For options like -P or -D which take a following string, a dollar sign - ($) must be used to signal the end of the string. For example, to set - two -D options on MS-DOS, you must have a dollar sign between them, + For options like -P or -D which take a following string, a dollar sign + ($) must be used to signal the end of the string. For example, to set + two -D options on MS-DOS, you must have a dollar sign between them, like this: LESS="-Dn9.1$-Ds4.1" -? or --help - This option displays a summary of the commands accepted by less - (the same as the h command). (Depending on how your shell - interprets the question mark, it may be necessary to quote the + This option displays a summary of the commands accepted by less + (the same as the h command). (Depending on how your shell + interprets the question mark, it may be necessary to quote the question mark, thus: "-\?".) -a or --search-skip-screen - Causes searches to start after the last line displayed on the - screen, thus skipping all lines displayed on the screen. By - default, searches start at the second line on the screen (or - after the last found line; see the -j option). + By default, forward searches start at the top of the displayed + screen and backwards searches start at the bottom of the dis- + played screen (except for repeated searches invoked by the n or + N commands, which start after or before the "target" line + respectively; see the -j option for more about the target line). + The -a option causes forward searches to instead start at the + bottom of the screen and backward searches to start at the top + of the screen, thus skipping all lines displayed on the screen. + + -A or --SEARCH-SKIP-SCREEN + Causes all forward searches (not just non-repeated searches) to + start just after the target line, and all backward searches to + start just before the target line. Thus, forward searches will + skip part of the displayed screen (from the first line up to and + including the target line). Similarly backwards searches will + skip the displayed screen from the last line up to and including + the target line. This was the default behavior in less versions + prior to 441. -bn or --buffers=n Specifies the amount of buffer space less will use for each @@ -468,12 +480,12 @@ LESS(1) LESS(1) By default, when data is read from a pipe, buffers are allocated automatically as needed. If a large amount of data is read from the pipe, this can cause a large amount of memory to be allo- - cated. The -B option disables this automatic allocation of - buffers for pipes, so that only 64K (or the amount of space - specified by the -b option) is used for the pipe. Warning: use - of -B can result in erroneous display, since only the most - recently viewed part of the piped data is kept in memory; any - earlier data is lost. + cated. The -B option disables this automatic allocation of buf- + fers for pipes, so that only 64K (or the amount of space speci- + fied by the -b option) is used for the pipe. Warning: use of -B + can result in erroneous display, since only the most recently + viewed part of the piped data is kept in memory; any earlier + data is lost. -c or --clear-screen Causes full screen repaints to be painted from the top line @@ -565,90 +577,91 @@ LESS(1) LESS(1) that the target line remains at the specified fraction of the screen height. If any form of the -j option is used, forward searches begin at the line immediately after the target line, - and backward searches begin at the target line. For example, if - "-j4" is used, the target line is the fourth line on the screen, - so forward searches begin at the fifth line on the screen. + and backward searches begin at the target line, unless changed + by -a or -A. For example, if "-j4" is used, the target line is + the fourth line on the screen, so forward searches begin at the + fifth line on the screen. -J or --status-column - Displays a status column at the left edge of the screen. The - status column shows the lines that matched the current search. - The status column is also used if the -w or -W option is in + Displays a status column at the left edge of the screen. The + status column shows the lines that matched the current search. + The status column is also used if the -w or -W option is in effect. -kfilename or --lesskey-file=filename - Causes less to open and interpret the named file as a lesskey + Causes less to open and interpret the named file as a lesskey (1) file. Multiple -k options may be specified. If the LESSKEY - or LESSKEY_SYSTEM environment variable is set, or if a lesskey + or LESSKEY_SYSTEM environment variable is set, or if a lesskey file is found in a standard place (see KEY BINDINGS), it is also used as a lesskey file. -K or --quit-on-intr - Causes less to exit immediately when an interrupt character - (usually ^C) is typed. Normally, an interrupt character causes - less to stop whatever it is doing and return to its command - prompt. Note that use of this option makes it impossible to - return to the command prompt from the "F" command. + Causes less to exit immediately (with status 2) when an inter- + rupt character (usually ^C) is typed. Normally, an interrupt + character causes less to stop whatever it is doing and return to + its command prompt. Note that use of this option makes it + impossible to return to the command prompt from the "F" command. -L or --no-lessopen - Ignore the LESSOPEN environment variable (see the INPUT PRE- - PROCESSOR section below). This option can be set from within - less, but it will apply only to files opened subsequently, not + Ignore the LESSOPEN environment variable (see the INPUT PRE- + PROCESSOR section below). This option can be set from within + less, but it will apply only to files opened subsequently, not to the file which is currently open. -m or --long-prompt - Causes less to prompt verbosely (like more), with the percent + Causes less to prompt verbosely (like more), with the percent into the file. By default, less prompts with a colon. -M or --LONG-PROMPT Causes less to prompt even more verbosely than more. -n or --line-numbers - Suppresses line numbers. The default (to use line numbers) may - cause less to run more slowly in some cases, especially with a - very large input file. Suppressing line numbers with the -n - option will avoid this problem. Using line numbers means: the + Suppresses line numbers. The default (to use line numbers) may + cause less to run more slowly in some cases, especially with a + very large input file. Suppressing line numbers with the -n + option will avoid this problem. Using line numbers means: the line number will be displayed in the verbose prompt and in the = - command, and the v command will pass the current line number to - the editor (see also the discussion of LESSEDIT in PROMPTS + command, and the v command will pass the current line number to + the editor (see also the discussion of LESSEDIT in PROMPTS below). -N or --LINE-NUMBERS - Causes a line number to be displayed at the beginning of each + Causes a line number to be displayed at the beginning of each line in the display. -ofilename or --log-file=filename - Causes less to copy its input to the named file as it is being + Causes less to copy its input to the named file as it is being viewed. This applies only when the input file is a pipe, not an - ordinary file. If the file already exists, less will ask for + ordinary file. If the file already exists, less will ask for confirmation before overwriting it. -Ofilename or --LOG-FILE=filename The -O option is like -o, but it will overwrite an existing file without asking for confirmation. - If no log file has been specified, the -o and -O options can be - used from within less to specify a log file. Without a file + If no log file has been specified, the -o and -O options can be + used from within less to specify a log file. Without a file name, they will simply report the name of the log file. The "s" command is equivalent to specifying -o from within less. -ppattern or --pattern=pattern - The -p option on the command line is equivalent to specifying - +/pattern; that is, it tells less to start at the first occur- + The -p option on the command line is equivalent to specifying + +/pattern; that is, it tells less to start at the first occur- rence of pattern in the file. -Pprompt or --prompt=prompt - Provides a way to tailor the three prompt styles to your own + Provides a way to tailor the three prompt styles to your own preference. This option would normally be put in the LESS envi- ronment variable, rather than being typed in with each less com- mand. Such an option must either be the last option in the LESS - variable, or be terminated by a dollar sign. -Ps followed by a - string changes the default (short) prompt to that string. -Pm - changes the medium (-m) prompt. -PM changes the long (-M) - prompt. -Ph changes the prompt for the help screen. -P= - changes the message printed by the = command. -Pw changes the - message printed while waiting for data (in the F command). All - prompt strings consist of a sequence of letters and special - escape sequences. See the section on PROMPTS for more details. + variable, or be terminated by a dollar sign. -Ps followed by a + string changes the default (short) prompt to that string. -Pm + changes the medium (-m) prompt. -PM changes the long (-M) + prompt. -Ph changes the prompt for the help screen. -P= + changes the message printed by the = command. -Pw changes the + message printed while waiting for data (in the F command). All + prompt strings consist of a sequence of letters and special + escape sequences. See the section on PROMPTS for more details. -q or --quiet or --silent Causes moderately "quiet" operation: the terminal bell is not @@ -749,55 +762,55 @@ LESS(1) LESS(1) screen. Also highlights the target line after a g or p command. The highlight is removed at the next command which causes move- ment. The entire line is highlighted, unless the -J option is - in effect, in which case only the status column is highlighted. + in effect, in which case only the status column is highlighted. -W or --HILITE-UNREAD Like -w, but temporarily highlights the first new line after any forward movement command larger than one line. -xn,... or --tabs=n,... - Sets tab stops. If only one n is specified, tab stops are set - at multiples of n. If multiple values separated by commas are - specified, tab stops are set at those positions, and then con- - tinue with the same spacing as the last two. For example, - -x9,17 will set tabs at positions 9, 17, 25, 33, etc. The + Sets tab stops. If only one n is specified, tab stops are set + at multiples of n. If multiple values separated by commas are + specified, tab stops are set at those positions, and then con- + tinue with the same spacing as the last two. For example, + -x9,17 will set tabs at positions 9, 17, 25, 33, etc. The default for n is 8. -X or --no-init Disables sending the termcap initialization and deinitialization - strings to the terminal. This is sometimes desirable if the - deinitialization string does something unnecessary, like clear- + strings to the terminal. This is sometimes desirable if the + deinitialization string does something unnecessary, like clear- ing the screen. -yn or --max-forw-scroll=n Specifies a maximum number of lines to scroll forward. If it is - necessary to scroll forward more than n lines, the screen is - repainted instead. The -c or -C option may be used to repaint - from the top of the screen if desired. By default, any forward + necessary to scroll forward more than n lines, the screen is + repainted instead. The -c or -C option may be used to repaint + from the top of the screen if desired. By default, any forward movement causes scrolling. -[z]n or --window=n - Changes the default scrolling window size to n lines. The + Changes the default scrolling window size to n lines. The default is one screenful. The z and w commands can also be used - to change the window size. The "z" may be omitted for compati- + to change the window size. The "z" may be omitted for compati- bility with some versions of more. If the number n is negative, - it indicates n lines less than the current screen size. For + it indicates n lines less than the current screen size. For example, if the screen is 24 lines, -z-4 sets the scrolling win- - dow to 20 lines. If the screen is resized to 40 lines, the + dow to 20 lines. If the screen is resized to 40 lines, the scrolling window automatically changes to 36 lines. -"cc or --quotes=cc - Changes the filename quoting character. This may be necessary - if you are trying to name a file which contains both spaces and - quote characters. Followed by a single character, this changes - the quote character to that character. Filenames containing a + Changes the filename quoting character. This may be necessary + if you are trying to name a file which contains both spaces and + quote characters. Followed by a single character, this changes + the quote character to that character. Filenames containing a space should then be surrounded by that character rather than by - double quotes. Followed by two characters, changes the open - quote to the first character, and the close quote to the second + double quotes. Followed by two characters, changes the open + quote to the first character, and the close quote to the second character. Filenames containing a space should then be preceded - by the open quote character and followed by the close quote - character. Note that even after the quote characters are - changed, this option remains -" (a dash followed by a double + by the open quote character and followed by the close quote + character. Note that even after the quote characters are + changed, this option remains -" (a dash followed by a double quote). -~ or --tilde @@ -807,19 +820,19 @@ LESS(1) LESS(1) -# or --shift Specifies the default number of positions to scroll horizontally - in the RIGHTARROW and LEFTARROW commands. If the number speci- - fied is zero, it sets the default number of positions to one + in the RIGHTARROW and LEFTARROW commands. If the number speci- + fied is zero, it sets the default number of positions to one half of the screen width. Alternately, the number may be speci- - fied as a fraction of the width of the screen, starting with a - decimal point: .5 is half of the screen width, .3 is three - tenths of the screen width, and so on. If the number is speci- - fied as a fraction, the actual number of scroll positions is - recalculated if the terminal window is resized, so that the - actual scroll remains at the specified fraction of the screen + fied as a fraction of the width of the screen, starting with a + decimal point: .5 is half of the screen width, .3 is three + tenths of the screen width, and so on. If the number is speci- + fied as a fraction, the actual number of scroll positions is + recalculated if the terminal window is resized, so that the + actual scroll remains at the specified fraction of the screen width. --no-keypad - Disables sending the keypad initialization and deinitialization + Disables sending the keypad initialization and deinitialization strings to the terminal. This is sometimes useful if the keypad strings make the numeric keypad behave in an undesirable manner. @@ -833,34 +846,34 @@ LESS(1) LESS(1) has been created with the same name as the original (now renamed) file), less will display the contents of that new file. - -- A command line argument of "--" marks the end of option argu- - ments. Any arguments following this are interpreted as file- + -- A command line argument of "--" marks the end of option argu- + ments. Any arguments following this are interpreted as file- names. This can be useful when viewing a file whose name begins with a "-" or "+". - + If a command line option begins with +, the remainder of that - option is taken to be an initial command to less. For example, - +G tells less to start at the end of the file rather than the - beginning, and +/xyz tells it to start at the first occurrence - of "xyz" in the file. As a special case, + acts like + + If a command line option begins with +, the remainder of that + option is taken to be an initial command to less. For example, + +G tells less to start at the end of the file rather than the + beginning, and +/xyz tells it to start at the first occurrence + of "xyz" in the file. As a special case, + acts like +g; that is, it starts the display at the specified line - number (however, see the caveat under the "g" command above). - If the option starts with ++, the initial command applies to - every file being viewed, not just the first one. The + command + number (however, see the caveat under the "g" command above). + If the option starts with ++, the initial command applies to + every file being viewed, not just the first one. The + command described previously may also be used to set (or change) an ini- tial command for every file. LINE EDITING - When entering command line at the bottom of the screen (for example, a + When entering command line at the bottom of the screen (for example, a filename for the :e command, or the pattern for a search command), cer- - tain keys can be used to manipulate the command line. Most commands - have an alternate form in [ brackets ] which can be used if a key does - not exist on a particular keyboard. (Note that the forms beginning - with ESC do not work in some MS-DOS and Windows systems because ESC is - the line erase character.) Any of these special keys may be entered - literally by preceding it with the "literal" character, either ^V or - ^A. A backslash itself may also be entered literally by entering two + tain keys can be used to manipulate the command line. Most commands + have an alternate form in [ brackets ] which can be used if a key does + not exist on a particular keyboard. (Note that the forms beginning + with ESC do not work in some MS-DOS and Windows systems because ESC is + the line erase character.) Any of these special keys may be entered + literally by preceding it with the "literal" character, either ^V or + ^A. A backslash itself may also be entered literally by entering two backslashes. LEFTARROW [ ESC-h ] @@ -870,7 +883,7 @@ LESS(1) LESS(1) Move the cursor one space to the right. ^LEFTARROW [ ESC-b or ESC-LEFTARROW ] - (That is, CONTROL and LEFTARROW simultaneously.) Move the cur- + (That is, CONTROL and LEFTARROW simultaneously.) Move the cur- sor one word to the left. ^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ] @@ -884,18 +897,18 @@ LESS(1) LESS(1) Move the cursor to the end of the line. BACKSPACE - Delete the character to the left of the cursor, or cancel the + Delete the character to the left of the cursor, or cancel the command if the command line is empty. DELETE or [ ESC-x ] Delete the character under the cursor. ^BACKSPACE [ ESC-BACKSPACE ] - (That is, CONTROL and BACKSPACE simultaneously.) Delete the + (That is, CONTROL and BACKSPACE simultaneously.) Delete the word to the left of the cursor. ^DELETE [ ESC-X or ESC-DELETE ] - (That is, CONTROL and DELETE simultaneously.) Delete the word + (That is, CONTROL and DELETE simultaneously.) Delete the word under the cursor. UPARROW [ ESC-k ] @@ -904,13 +917,13 @@ LESS(1) LESS(1) DOWNARROW [ ESC-j ] Retrieve the next command line. - TAB Complete the partial filename to the left of the cursor. If it - matches more than one filename, the first match is entered into - the command line. Repeated TABs will cycle thru the other + TAB Complete the partial filename to the left of the cursor. If it + matches more than one filename, the first match is entered into + the command line. Repeated TABs will cycle thru the other matching filenames. If the completed filename is a directory, a - "/" is appended to the filename. (On MS-DOS systems, a "\" is - appended.) The environment variable LESSSEPARATOR can be used - to specify a different character to append to a directory name. + "/" is appended to the filename. (On MS-DOS systems, a "\" is + appended.) The environment variable LESSSEPARATOR can be used + to specify a different character to append to a directory name. BACKTAB [ ESC-TAB ] Like, TAB, but cycles in the reverse direction thru the matching @@ -926,6 +939,8 @@ LESS(1) LESS(1) acter in Unix to something other than ^U, that character is used instead of ^U. + ^G Delete the entire command line and return to the main prompt. + KEY BINDINGS You may define your own less commands by using the program lesskey (1) @@ -960,40 +975,40 @@ LESS(1) LESS(1) INPUT PREPROCESSOR - You may define an "input preprocessor" for less. Before less opens a + You may define an "input preprocessor" for less. Before less opens a file, it first gives your input preprocessor a chance to modify the way - the contents of the file are displayed. An input preprocessor is sim- - ply an executable program (or shell script), which writes the contents + the contents of the file are displayed. An input preprocessor is sim- + ply an executable program (or shell script), which writes the contents of the file to a different file, called the replacement file. The con- - tents of the replacement file are then displayed in place of the con- - tents of the original file. However, it will appear to the user as if - the original file is opened; that is, less will display the original + tents of the replacement file are then displayed in place of the con- + tents of the original file. However, it will appear to the user as if + the original file is opened; that is, less will display the original filename as the name of the current file. - An input preprocessor receives one command line argument, the original - filename, as entered by the user. It should create the replacement - file, and when finished, print the name of the replacement file to its - standard output. If the input preprocessor does not output a replace- - ment filename, less uses the original file, as normal. The input pre- - processor is not called when viewing standard input. To set up an - input preprocessor, set the LESSOPEN environment variable to a command - line which will invoke your input preprocessor. This command line - should include one occurrence of the string "%s", which will be - replaced by the filename when the input preprocessor command is + An input preprocessor receives one command line argument, the original + filename, as entered by the user. It should create the replacement + file, and when finished, print the name of the replacement file to its + standard output. If the input preprocessor does not output a replace- + ment filename, less uses the original file, as normal. The input pre- + processor is not called when viewing standard input. To set up an + input preprocessor, set the LESSOPEN environment variable to a command + line which will invoke your input preprocessor. This command line + should include one occurrence of the string "%s", which will be + replaced by the filename when the input preprocessor command is invoked. When less closes a file opened in such a way, it will call another pro- - gram, called the input postprocessor, which may perform any desired - clean-up action (such as deleting the replacement file created by + gram, called the input postprocessor, which may perform any desired + clean-up action (such as deleting the replacement file created by LESSOPEN). This program receives two command line arguments, the orig- - inal filename as entered by the user, and the name of the replacement - file. To set up an input postprocessor, set the LESSCLOSE environment - variable to a command line which will invoke your input postprocessor. - It may include two occurrences of the string "%s"; the first is - replaced with the original name of the file and the second with the + inal filename as entered by the user, and the name of the replacement + file. To set up an input postprocessor, set the LESSCLOSE environment + variable to a command line which will invoke your input postprocessor. + It may include two occurrences of the string "%s"; the first is + replaced with the original name of the file and the second with the name of the replacement file, which was output by LESSOPEN. - For example, on many Unix systems, these two scripts will allow you to + For example, on many Unix systems, these two scripts will allow you to keep files in compressed format, but still let less view them directly: lessopen.sh: @@ -1165,9 +1180,9 @@ LESS(1) LESS(1) may include one printf-style escape sequence (a % followed by x, X, o, d, etc.). For example, if LESSBINFMT is "*u[%x]", binary characters are displayed in underlined hexadecimal surrounded by brackets. The - default if no LESSBINFMT is specified is "*s<%X>". The default if no - LESSBINFMT is specified is "*s<%02X>". Warning: the result of expand- - ing the character via LESSBINFMT must be less than 31 characters. + default if no LESSBINFMT is specified is "*s<%02X>". Warning: the + result of expanding the character via LESSBINFMT must be less than 31 + characters. When the character set is utf-8, the LESSUTFBINFMT environment variable acts similarly to LESSBINFMT but it applies to Unicode code points that @@ -1219,13 +1234,16 @@ LESS(1) LESS(1) %f Replaced by the name of the current input file. - %i Replaced by the index of the current file in the list of input + %F Replaced by the last component of the name of the current input + file. + + %i Replaced by the index of the current file in the list of input files. - %lX Replaced by the line number of a line in the input file. The + %lX Replaced by the line number of a line in the input file. The line to be used is determined by the X, as with the %b option. - %L Replaced by the line number of the last line in the input file. + %L Replaced by the line number of the last line in the input file. %m Replaced by the total number of input files. @@ -1258,7 +1276,7 @@ LESS(1) LESS(1) are included in the string if and only if the IF condition is false. Condition characters (which follow a question mark) may be: - ?a True if any characters have been included in the prompt so far. + ?a True if any characters have been included in the prompt so far. ?bX True if the byte offset of the specified line is known. @@ -1270,7 +1288,7 @@ LESS(1) LESS(1) ?e True if at end-of-file. - ?f True if there is an input filename (that is, if input is not a + ?f True if there is an input filename (that is, if input is not a pipe). ?lX True if the line number of the specified line is known. @@ -1281,46 +1299,46 @@ LESS(1) LESS(1) ?n True if this is the first prompt in a new input file. - ?pX True if the percent into the current input file, based on byte + ?pX True if the percent into the current input file, based on byte offsets, of the specified line is known. - ?PX True if the percent into the current input file, based on line + ?PX True if the percent into the current input file, based on line numbers, of the specified line is known. ?s Same as "?B". - ?x True if there is a next input file (that is, if the current + ?x True if there is a next input file (that is, if the current input file is not the last one). - Any characters other than the special ones (question mark, colon, - period, percent, and backslash) become literally part of the prompt. - Any of the special characters may be included in the prompt literally + Any characters other than the special ones (question mark, colon, + period, percent, and backslash) become literally part of the prompt. + Any of the special characters may be included in the prompt literally by preceding it with a backslash. Some examples: ?f%f:Standard input. - This prompt prints the filename, if known; otherwise the string "Stan- + This prompt prints the filename, if known; otherwise the string "Stan- dard input". ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-... - This prompt would print the filename, if known. The filename is fol- - lowed by the line number, if known, otherwise the percent if known, - otherwise the byte offset if known. Otherwise, a dash is printed. - Notice how each question mark has a matching period, and how the % + This prompt would print the filename, if known. The filename is fol- + lowed by the line number, if known, otherwise the percent if known, + otherwise the byte offset if known. Otherwise, a dash is printed. + Notice how each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash. ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t - This prints the filename if this is the first prompt in a file, fol- - lowed by the "file N of N" message if there is more than one input - file. Then, if we are at end-of-file, the string "(END)" is printed - followed by the name of the next file, if there is one. Finally, any + This prints the filename if this is the first prompt in a file, fol- + lowed by the "file N of N" message if there is more than one input + file. Then, if we are at end-of-file, the string "(END)" is printed + followed by the name of the next file, if there is one. Finally, any trailing spaces are truncated. This is the default prompt. For refer- - ence, here are the defaults for the other two prompts (-m and -M - respectively). Each is broken into two lines here for readability + ence, here are the defaults for the other two prompts (-m and -M + respectively). Each is broken into two lines here for readability only. ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.: @@ -1334,22 +1352,22 @@ LESS(1) LESS(1) ?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. . byte %bB?s/%s. ?e(END) :?pB%pB\%..%t - The prompt expansion features are also used for another purpose: if an - environment variable LESSEDIT is defined, it is used as the command to - be executed when the v command is invoked. The LESSEDIT string is - expanded in the same way as the prompt strings. The default value for + The prompt expansion features are also used for another purpose: if an + environment variable LESSEDIT is defined, it is used as the command to + be executed when the v command is invoked. The LESSEDIT string is + expanded in the same way as the prompt strings. The default value for LESSEDIT is: %E ?lm+%lm. %f Note that this expands to the editor name, followed by a + and the line - number, followed by the file name. If your editor does not accept the - "+linenumber" syntax, or has other differences in invocation syntax, + number, followed by the file name. If your editor does not accept the + "+linenumber" syntax, or has other differences in invocation syntax, the LESSEDIT variable can be changed to modify this default. SECURITY - When the environment variable LESSSECURE is set to 1, less runs in a + When the environment variable LESSSECURE is set to 1, less runs in a "secure" mode. This means these features are disabled: ! the shell command @@ -1375,54 +1393,54 @@ LESS(1) LESS(1) COMPATIBILITY WITH MORE If the environment variable LESS_IS_MORE is set to 1, or if the program - is invoked via a file link named "more", less behaves (mostly) in con- - formance with the POSIX "more" command specification. In this mode, + is invoked via a file link named "more", less behaves (mostly) in con- + formance with the POSIX "more" command specification. In this mode, less behaves differently in these ways: - The -e option works differently. If the -e option is not set, less - behaves as if the -E option were set. If the -e option is set, less + The -e option works differently. If the -e option is not set, less + behaves as if the -E option were set. If the -e option is set, less behaves as if the -e and -F options were set. - The -m option works differently. If the -m option is not set, the - medium prompt is used, and it is prefixed with the string "--More--". + The -m option works differently. If the -m option is not set, the + medium prompt is used, and it is prefixed with the string "--More--". If the -m option is set, the short prompt is used. - The -n option acts like the -z option. The normal behavior of the -n + The -n option acts like the -z option. The normal behavior of the -n option is unavailable in this mode. - The parameter to the -p option is taken to be a less command rather + The parameter to the -p option is taken to be a less command rather than a search pattern. - The LESS environment variable is ignored, and the MORE environment + The LESS environment variable is ignored, and the MORE environment variable is used in its place. ENVIRONMENT VARIABLES Environment variables may be specified either in the system environment - as usual, or in a lesskey (1) file. If environment variables are - defined in more than one place, variables defined in a local lesskey - file take precedence over variables defined in the system environment, + as usual, or in a lesskey (1) file. If environment variables are + defined in more than one place, variables defined in a local lesskey + file take precedence over variables defined in the system environment, which take precedence over variables defined in the system-wide lesskey file. COLUMNS Sets the number of columns on the screen. Takes precedence over - the number of columns specified by the TERM variable. (But if + the number of columns specified by the TERM variable. (But if you have a windowing system which supports TIOCGWINSZ or - WIOCGETD, the window system's idea of the screen size takes + WIOCGETD, the window system's idea of the screen size takes precedence over the LINES and COLUMNS environment variables.) EDITOR The name of the editor (used for the v command). - HOME Name of the user's home directory (used to find a lesskey file + HOME Name of the user's home directory (used to find a lesskey file on Unix and OS/2 systems). HOMEDRIVE, HOMEPATH - Concatenation of the HOMEDRIVE and HOMEPATH environment vari- + Concatenation of the HOMEDRIVE and HOMEPATH environment vari- ables is the name of the user's home directory if the HOME vari- able is not set (only in the Windows version). - INIT Name of the user's init directory (used to find a lesskey file + INIT Name of the user's init directory (used to find a lesskey file on OS/2 systems). LANG Language for determining the character set. @@ -1433,12 +1451,12 @@ LESS(1) LESS(1) LESS Options which are passed to less automatically. LESSANSIENDCHARS - Characters which may end an ANSI color escape sequence (default + Characters which may end an ANSI color escape sequence (default "m"). LESSANSIMIDCHARS - Characters which may appear between the ESC character and the - end character in an ANSI color escape sequence (default + Characters which may appear between the ESC character and the + end character in an ANSI color escape sequence (default "0123456789;[?!"'#%()*+ ". LESSBINFMT @@ -1455,24 +1473,24 @@ LESS(1) LESS(1) LESSECHO Name of the lessecho program (default "lessecho"). The lessecho - program is needed to expand metacharacters, such as * and ?, in + program is needed to expand metacharacters, such as * and ?, in filenames on Unix systems. LESSEDIT - Editor prototype string (used for the v command). See discus- + Editor prototype string (used for the v command). See discus- sion under PROMPTS. LESSGLOBALTAGS - Name of the command used by the -t option to find global tags. + Name of the command used by the -t option to find global tags. Normally should be set to "global" if your system has the global (1) command. If not set, global tags are not used. LESSHISTFILE - Name of the history file used to remember search commands and - shell commands between invocations of less. If set to "-" or - "/dev/null", a history file is not used. The default is - "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on DOS and - Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" + Name of the history file used to remember search commands and + shell commands between invocations of less. If set to "-" or + "/dev/null", a history file is not used. The default is + "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on DOS and + Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" on OS/2 systems. LESSHISTSIZE @@ -1486,13 +1504,13 @@ LESS(1) LESS(1) Name of the default system-wide lesskey(1) file. LESSMETACHARS - List of characters which are considered "metacharacters" by the + List of characters which are considered "metacharacters" by the shell. LESSMETAESCAPE - Prefix which less will add before each metacharacter in a com- - mand sent to the shell. If LESSMETAESCAPE is an empty string, - commands containing metacharacters will not be passed to the + Prefix which less will add before each metacharacter in a com- + mand sent to the shell. If LESSMETAESCAPE is an empty string, + commands containing metacharacters will not be passed to the shell. LESSOPEN @@ -1502,7 +1520,7 @@ LESS(1) LESS(1) Runs less in "secure" mode. See discussion under SECURITY. LESSSEPARATOR - String to be appended to a directory name in filename comple- + String to be appended to a directory name in filename comple- tion. LESSUTFBINFMT @@ -1511,16 +1529,16 @@ LESS(1) LESS(1) LESS_IS_MORE Emulate the more (1) command. - LINES Sets the number of lines on the screen. Takes precedence over + LINES Sets the number of lines on the screen. Takes precedence over the number of lines specified by the TERM variable. (But if you - have a windowing system which supports TIOCGWINSZ or WIOCGETD, - the window system's idea of the screen size takes precedence + have a windowing system which supports TIOCGWINSZ or WIOCGETD, + the window system's idea of the screen size takes precedence over the LINES and COLUMNS environment variables.) - PATH User's search path (used to find a lesskey file on MS-DOS and + PATH User's search path (used to find a lesskey file on MS-DOS and OS/2 systems). - SHELL The shell used to execute the ! command, as well as to expand + SHELL The shell used to execute the ! command, as well as to expand filenames. TERM The type of terminal on which less is being run. @@ -1533,33 +1551,33 @@ LESS(1) LESS(1) COPYRIGHT - Copyright (C) 1984-2009 Mark Nudelman + Copyright (C) 1984-2011 Mark Nudelman - less is part of the GNU project and is free software. You can redis- - tribute it and/or modify it under the terms of either (1) the GNU Gen- - eral Public License as published by the Free Software Foundation; or + less is part of the GNU project and is free software. You can redis- + tribute it and/or modify it under the terms of either (1) the GNU Gen- + eral Public License as published by the Free Software Foundation; or (2) the Less License. See the file README in the less distribution for more details regarding redistribution. You should have received a copy - of the GNU General Public License along with the source for less; see - the file COPYING. If not, write to the Free Software Foundation, 59 - Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also + of the GNU General Public License along with the source for less; see + the file COPYING. If not, write to the Free Software Foundation, 59 + Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also have received a copy of the Less License; see the file LICENSE. less is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- - NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- + NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. AUTHOR Mark Nudelman + Send bug reports or comments to the above address or to bug- + less@gnu.org. See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less. - Send bug reports or comments to the above address or to - bug-less@gnu.org. For more information, see the less homepage at http://www.greenwoodsoftware.com/less. - Version 436: 07 Jul 2009 LESS(1) + Version 443: 09 Apr 2011 LESS(1) diff --git a/contrib/less/less.nro b/contrib/less/less.nro index 952a3f90a4a2..33050e15bb45 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 436: 07 Jul 2009" +.TH LESS 1 "Version 443: 09 Apr 2011" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -10,7 +10,7 @@ less \- opposite of more .br .B "less \-\-version" .br -.B "less [\-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]" +.B "less [\-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]" .br .B " [\-b \fIspace\fP] [\-h \fIlines\fP] [\-j \fIline\fP] [\-k \fIkeyfile\fP]" .br @@ -65,7 +65,7 @@ Like SPACE, but if N is specified, it becomes the new window size. .IP "ESC-SPACE" Like SPACE, but scrolls a full screenful, even if it reaches end-of-file in the process. -.IP "RETURN or ^N or e or ^E or j or ^J" +.IP "ENTER or RETURN or ^N or e or ^E or j or ^J" Scroll forward N lines, default 1. The entire N lines are displayed, even if N is more than the screen size. .IP "d or ^D" @@ -178,7 +178,7 @@ Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system. -The search starts at the second line displayed +The search starts at the first line displayed (but see the \-a and \-j options, which change this). .sp Certain characters are special @@ -333,7 +333,7 @@ the current setting is printed and nothing is changed. .IP \-\- Like the \- command, but takes a long option name (see OPTIONS below) rather than a single option letter. -You must press RETURN after typing the option name. +You must press ENTER or RETURN after typing the option name. A ^P immediately after the second dash suppresses printing of a message describing the new setting, as in the \- command. .IP \-+ @@ -363,7 +363,7 @@ The setting of the option is not changed. (Double underscore.) Like the _ (underscore) command, but takes a long option name rather than a single option letter. -You must press RETURN after typing the option name. +You must press ENTER or RETURN after typing the option name. .IP +cmd Causes the specified cmd to be executed each time a new file is examined. For example, +G causes @@ -465,11 +465,24 @@ This option displays a summary of the commands accepted by (Depending on how your shell interprets the question mark, it may be necessary to quote the question mark, thus: "\-\e?".) .IP "\-a or \-\-search-skip-screen" -Causes searches to start after the last line -displayed on the screen, +By default, forward searches start at the top of the displayed screen +and backwards searches start at the bottom of the displayed screen +(except for repeated searches invoked by the n or N commands, +which start after or before the "target" line respectively; +see the \-j option for more about the target line). +The \-a option causes forward searches to instead start at +the bottom of the screen +and backward searches to start at the top of the screen, thus skipping all lines displayed on the screen. -By default, searches start at the second line on the screen -(or after the last found line; see the \-j option). +.IP "\-A or \-\-SEARCH-SKIP-SCREEN" +Causes all forward searches (not just non-repeated searches) +to start just after the target line, and all backward searches +to start just before the target line. +Thus, forward searches will skip part of the displayed screen +(from the first line up to and including the target line). +Similarly backwards searches will skip the displayed screen +from the last line up to and including the target line. +This was the default behavior in less versions prior to 441. .IP "\-b\fIn\fP or \-\-buffers=\fIn\fP" Specifies the amount of buffer space .I less @@ -590,7 +603,8 @@ is recalculated if the terminal window is resized, so that the target line remains at the specified fraction of the screen height. If any form of the \-j option is used, forward searches begin at the line immediately after the target line, -and backward searches begin at the target line. +and backward searches begin at the target line, +unless changed by \-a or \-A. For example, if "\-j4" is used, the target line is the fourth line on the screen, so forward searches begin at the fifth line on the screen. @@ -613,7 +627,8 @@ file. .IP "\-K or \-\-quit-on-intr" Causes .I less -to exit immediately when an interrupt character (usually ^C) is typed. +to exit immediately (with status 2) +when an interrupt character (usually ^C) is typed. Normally, an interrupt character causes .I less to stop whatever it is doing and return to its command prompt. @@ -970,6 +985,8 @@ Delete the entire command line, or cancel the command if the command line is empty. If you have changed your line-kill character in Unix to something other than ^U, that character is used instead of ^U. +.IP "^G" +Delete the entire command line and return to the main prompt. .SH "KEY BINDINGS" You may define your own @@ -1290,7 +1307,6 @@ The remainder of LESSBINFMT is a string which may include one printf-style escape sequence (a % followed by x, X, o, d, etc.). For example, if LESSBINFMT is "*u[%x]", binary characters are displayed in underlined hexadecimal surrounded by brackets. -The default if no LESSBINFMT is specified is "*s<%X>". The default if no LESSBINFMT is specified is "*s<%02X>". Warning: the result of expanding the character via LESSBINFMT must be less than 31 characters. @@ -1347,6 +1363,8 @@ or the EDITOR environment variable if VISUAL is not defined). See the discussion of the LESSEDIT feature below. .IP "%f" Replaced by the name of the current input file. +.IP "%F" +Replaced by the last component of the name of the current input file. .IP "%i" Replaced by the index of the current file in the list of input files. @@ -1664,7 +1682,7 @@ The name of the editor (used for the v command). lesskey(1) .SH COPYRIGHT -Copyright (C) 1984-2009 Mark Nudelman +Copyright (C) 1984-2011 Mark Nudelman .PP less is part of the GNU project and is free software. You can redistribute it and/or modify it @@ -1689,12 +1707,10 @@ See the GNU General Public License for more details. .PP Mark Nudelman .br +Send bug reports or comments to the above address or to bug-less@gnu.org. +.br See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less. .br -Send bug reports or comments to the above address or to -.br -bug-less@gnu.org. -.br For more information, see the less homepage at .br http://www.greenwoodsoftware.com/less. diff --git a/contrib/less/lessecho.c b/contrib/less/lessecho.c index bf6f19d78ccf..6dcaf6c820b9 100644 --- a/contrib/less/lessecho.c +++ b/contrib/less/lessecho.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -28,7 +28,7 @@ #include "less.h" -static char *version = "$Revision: 1.13 $"; +static char *version = "$Revision: 1.14 $"; static int quote_all = 0; static char openquote = '"'; diff --git a/contrib/less/lessecho.man b/contrib/less/lessecho.man index 98f719ccf072..32bccba8889a 100644 --- a/contrib/less/lessecho.man +++ b/contrib/less/lessecho.man @@ -46,4 +46,4 @@ LESSECHO(1) LESSECHO(1) - Version 436: 07 Jul 2009 LESSECHO(1) + Version 443: 09 Apr 2011 LESSECHO(1) diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index 613dff611aab..5c17708f9edb 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 436: 07 Jul 2009" +.TH LESSECHO 1 "Version 443: 09 Apr 2011" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/contrib/less/lesskey.c b/contrib/less/lesskey.c index 54d6b771f1d7..1ee2c4040209 100644 --- a/contrib/less/lesskey.c +++ b/contrib/less/lesskey.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -166,6 +166,7 @@ struct cmdname editnames[] = { "insert", EC_INSERT }, { "invalid", EC_UINVALID }, { "kill-line", EC_LINEKILL }, + { "abort", EC_ABORT }, { "left", EC_LEFT }, { "literal", EC_LITERAL }, { "right", EC_RIGHT }, diff --git a/contrib/less/lesskey.h b/contrib/less/lesskey.h index 088f95aebf7e..9a457a924fbe 100644 --- a/contrib/less/lesskey.h +++ b/contrib/less/lesskey.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/lesskey.man b/contrib/less/lesskey.man index 27cd19d8db20..b315ea672442 100644 --- a/contrib/less/lesskey.man +++ b/contrib/less/lesskey.man @@ -13,7 +13,7 @@ LESSKEY(1) LESSKEY(1) DESCRIPTION Lesskey is used to specify a set of key bindings to be used by less. - The input file is a text file which describes the key bindings, If the + The input file is a text file which describes the key bindings. If the input file is "-", standard input is read. If no input file is speci- fied, a standard filename is used as the name of the input file, which depends on the system being used: On Unix systems, $HOME/.lesskey is @@ -105,7 +105,7 @@ LESSKEY(1) LESSKEY(1) can be used in certain cases to extend the functionality of a command. For example, see the "{" and ":t" commands in the example below. The extra string has a special meaning for the "quit" action: when less - quits, first character of the extra string is used as its exit status. + quits, first character of the extra string is used as its exit status. EXAMPLE @@ -225,12 +225,12 @@ LESSKEY(1) LESSKEY(1) PRECEDENCE - Commands specified by lesskey take precedence over the default com- - mands. A default command key may be disabled by including it in the - input file with the action "invalid". Alternatively, a key may be - defined to do nothing by using the action "noaction". "noaction" is + Commands specified by lesskey take precedence over the default com- + mands. A default command key may be disabled by including it in the + input file with the action "invalid". Alternatively, a key may be + defined to do nothing by using the action "noaction". "noaction" is similar to "invalid", but less will give an error beep for an "invalid" - command, but not for a "noaction" command. In addition, ALL default + command, but not for a "noaction" command. In addition, ALL default commands may be disabled by adding this control line to the input file: #stop @@ -287,6 +287,7 @@ LESSKEY(1) LESSKEY(1) \ek up \ku up \ej down + ^G abort @@ -322,27 +323,22 @@ LESSKEY(1) LESSKEY(1) WARNINGS - It is not possible to specify special keys, such as uparrow, in a key- - board-independent manner. The only way to specify such keys is to - specify the escape sequence which a particular keyboard sends when such - a key is pressed. - - On MS-DOS and OS/2 systems, certain keys send a sequence of characters - which start with a NUL character (0). This NUL character should be + On MS-DOS and OS/2 systems, certain keys send a sequence of characters + which start with a NUL character (0). This NUL character should be represented as \340 in a lesskey file. COPYRIGHT - Copyright (C) 2000-2009 Mark Nudelman + Copyright (C) 2000-2011 Mark Nudelman lesskey is part of the GNU project and is free software; you can redis- - tribute it and/or modify it under the terms of the GNU General Public + tribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - lesskey is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + lesskey is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along @@ -358,4 +354,4 @@ LESSKEY(1) LESSKEY(1) - Version 436: 07 Jul 2009 LESSKEY(1) + Version 443: 09 Apr 2011 LESSKEY(1) diff --git a/contrib/less/lesskey.nro b/contrib/less/lesskey.nro index fb6c61aab92f..8c99a0f8cfc2 100644 --- a/contrib/less/lesskey.nro +++ b/contrib/less/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 436: 07 Jul 2009" +.TH LESSKEY 1 "Version 443: 09 Apr 2011" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS @@ -13,7 +13,7 @@ lesskey \- specify key bindings for less .I Lesskey is used to specify a set of key bindings to be used by .I less. -The input file is a text file which describes the key bindings, +The input file is a text file which describes the key bindings. If the input file is "-", standard input is read. If no input file is specified, a standard filename is used as the name of the input file, which depends on the system being used: @@ -311,6 +311,7 @@ default line-editing keys used by less: \eek up \eku up \eej down + ^G abort .fi .sp @@ -349,17 +350,12 @@ is run, and specifies the character set to be "latin1": less(1) .SH WARNINGS -It is not possible to specify special keys, such as uparrow, -in a keyboard-independent manner. -The only way to specify such keys is to specify the escape sequence -which a particular keyboard sends when such a key is pressed. -.PP On MS-DOS and OS/2 systems, certain keys send a sequence of characters which start with a NUL character (0). This NUL character should be represented as \e340 in a lesskey file. .SH COPYRIGHT -Copyright (C) 2000-2009 Mark Nudelman +Copyright (C) 2000-2011 Mark Nudelman .PP lesskey is part of the GNU project and is free software; you can redistribute it and/or modify it diff --git a/contrib/less/lglob.h b/contrib/less/lglob.h index e5d0c508347e..e2427e3abb40 100644 --- a/contrib/less/lglob.h +++ b/contrib/less/lglob.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/line.c b/contrib/less/line.c index 5a35084e9399..0a951f6fe81f 100644 --- a/contrib/less/line.c +++ b/contrib/less/line.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/linenum.c b/contrib/less/linenum.c index ae450853e8fe..4369f87b266d 100644 --- a/contrib/less/linenum.c +++ b/contrib/less/linenum.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/lsystem.c b/contrib/less/lsystem.c index 18b259e18b3f..0a8ca52ea5a8 100644 --- a/contrib/less/lsystem.c +++ b/contrib/less/lsystem.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/main.c b/contrib/less/main.c index 9ae74cac258f..8c522eb8fb9f 100644 --- a/contrib/less/main.c +++ b/contrib/less/main.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -33,7 +33,6 @@ public char * progname; public int quitting; public int secure; public int dohelp; -public int less_is_more; #if LOGFILE public int logfile = -1; @@ -56,6 +55,7 @@ extern int jump_sline; static char consoleTitle[256]; #endif +extern int less_is_more; extern int missing_cap; extern int know_dumb; extern int quit_if_one_screen; @@ -415,7 +415,7 @@ quit(status) */ close(2); #endif -#if WIN32 +#ifdef WIN32 SetConsoleTitle(consoleTitle); #endif close_getchr(); diff --git a/contrib/less/mark.c b/contrib/less/mark.c index 5e2215eb4abb..585b412b49d2 100644 --- a/contrib/less/mark.c +++ b/contrib/less/mark.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/mkhelp.c b/contrib/less/mkhelp.c index d5365f7f1019..4aa8cbda6aa2 100644 --- a/contrib/less/mkhelp.c +++ b/contrib/less/mkhelp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/optfunc.c b/contrib/less/optfunc.c index 2416afd863ca..79ac7c62268a 100644 --- a/contrib/less/optfunc.c +++ b/contrib/less/optfunc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/option.c b/contrib/less/option.c index 98419161f696..acb8962527ec 100644 --- a/contrib/less/option.c +++ b/contrib/less/option.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -24,7 +24,6 @@ static struct loption *pendopt; public int plusoption = FALSE; -static char *propt(); static char *optstring(); static int flip_triple(); @@ -33,6 +32,35 @@ extern int less_is_more; extern int quit_at_eof; extern char *every_first_cmd; +/* + * Return a printable description of an option. + */ + static char * +opt_desc(o) + struct loption *o; +{ + static char buf[OPTNAME_MAX + 10]; + if (o->oletter == OLETTER_NONE) + SNPRINTF1(buf, sizeof(buf), "--%s", o->onames->oname); + else + SNPRINTF2(buf, sizeof(buf), "-%c (--%s)", o->oletter, o->onames->oname); + return (buf); +} + +/* + * Return a string suitable for printing as the "name" of an option. + * For example, if the option letter is 'x', just return "-x". + */ + public char * +propt(c) + int c; +{ + static char buf[8]; + + sprintf(buf, "-%s", prchar(c)); + return (buf); +} + /* * Scan an argument (either from the command line or from the * LESS environment variable) and process it. @@ -69,7 +97,7 @@ scan_option(s) (*pendopt->ofunc)(INIT, s); break; case NUMBER: - printopt = propt(pendopt->oletter); + printopt = opt_desc(pendopt); *(pendopt->ovar) = getnum(&s, printopt, (int*)NULL); break; } @@ -261,12 +289,12 @@ scan_option(s) * OPT_SET set to the inverse of the default value */ public void -toggle_option(c, s, how_toggle) - int c; +toggle_option(o, lower, s, how_toggle) + struct loption *o; + int lower; char *s; int how_toggle; { - register struct loption *o; register int num; int no_prompt; int err; @@ -275,27 +303,22 @@ toggle_option(c, s, how_toggle) no_prompt = (how_toggle & OPT_NO_PROMPT); how_toggle &= ~OPT_NO_PROMPT; - /* - * Look up the option letter in the option table. - */ - o = findopt(c); if (o == NULL) { - parg.p_string = propt(c); - error("There is no %s option", &parg); + error("No such option", NULL_PARG); return; } if (how_toggle == OPT_TOGGLE && (o->otype & NO_TOGGLE)) { - parg.p_string = propt(c); + parg.p_string = opt_desc(o); error("Cannot change the %s option", &parg); return; - } + } if (how_toggle == OPT_NO_TOGGLE && (o->otype & NO_QUERY)) { - parg.p_string = propt(c); + parg.p_string = opt_desc(o); error("Cannot query the %s option", &parg); return; } @@ -355,15 +378,13 @@ toggle_option(c, s, how_toggle) switch (how_toggle) { case OPT_TOGGLE: - *(o->ovar) = flip_triple(*(o->ovar), - ASCII_IS_LOWER(c)); + *(o->ovar) = flip_triple(*(o->ovar), lower); break; case OPT_UNSET: *(o->ovar) = o->odefault; break; case OPT_SET: - *(o->ovar) = flip_triple(o->odefault, - ASCII_IS_LOWER(c)); + *(o->ovar) = flip_triple(o->odefault, lower); break; } break; @@ -465,33 +486,17 @@ flip_triple(val, lc) } /* - * Return a string suitable for printing as the "name" of an option. - * For example, if the option letter is 'x', just return "-x". - */ - static char * -propt(c) - int c; -{ - static char buf[8]; - - sprintf(buf, "-%s", prchar(c)); - return (buf); -} - -/* - * Determine if an option is a single character option (BOOL or TRIPLE), - * or if it a multi-character option (NUMBER). + * Determine if an option takes a parameter. */ public int -single_char_option(c) - int c; +opt_has_param(o) + struct loption *o; { - register struct loption *o; - - o = findopt(c); if (o == NULL) - return (TRUE); - return ((o->otype & (BOOL|TRIPLE|NOVAR|NO_TOGGLE)) != 0); + return (0); + if (o->otype & (BOOL|TRIPLE|NOVAR|NO_TOGGLE)) + return (0); + return (1); } /* @@ -499,14 +504,11 @@ single_char_option(c) * Only string and number valued options have prompts. */ public char * -opt_prompt(c) - int c; +opt_prompt(o) + struct loption *o; { - register struct loption *o; - - o = findopt(c); if (o == NULL || (o->otype & (STRING|NUMBER)) == 0) - return (NULL); + return ("?"); return (o->odesc[0]); } @@ -541,7 +543,7 @@ nostring(printopt) public void nopendopt() { - nostring(propt(pendopt->oletter)); + nostring(opt_desc(pendopt)); } /* diff --git a/contrib/less/option.h b/contrib/less/option.h index c393ed4b2c87..a32139eea66a 100644 --- a/contrib/less/option.h +++ b/contrib/less/option.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -27,6 +27,8 @@ #define OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR) +#define OLETTER_NONE '\1' /* Invalid option letter */ + /* * Argument to a handling function tells what type of activity: */ @@ -50,6 +52,8 @@ struct optname struct optname *onext; /* List of synonymous option names */ }; +#define OPTNAME_MAX 32 /* Max length of long option name */ + struct loption { char oletter; /* The controlling letter (a-z) */ diff --git a/contrib/less/opttbl.c b/contrib/less/opttbl.c index c96b333bfcc6..d1c60a27c8c9 100644 --- a/contrib/less/opttbl.c +++ b/contrib/less/opttbl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -133,11 +133,11 @@ static struct optname follow_optname = { "follow-name", NULL }; static struct loption option[] = { { 'a', &a_optname, - BOOL, OPT_OFF, &how_search, NULL, + TRIPLE, OPT_ONPLUS, &how_search, NULL, { "Search includes displayed screen", "Search skips displayed screen", - NULL + "Search includes all of displayed screen" } }, @@ -237,7 +237,7 @@ static struct loption option[] = STRING, 0, NULL, opt_j, { "Target line: ", - "0123456789.", + "0123456789.-", NULL } }, @@ -427,7 +427,7 @@ static struct loption option[] = NULL } }, - { '.', &keypad_optname, + { OLETTER_NONE, &keypad_optname, BOOL|NO_TOGGLE, OPT_OFF, &no_keypad, NULL, { "Use keypad mode", @@ -435,7 +435,7 @@ static struct loption option[] = NULL } }, - { '.', &oldbot_optname, + { OLETTER_NONE, &oldbot_optname, BOOL, OPT_OFF, &oldbot, NULL, { "Use new bottom of screen behavior", @@ -443,11 +443,11 @@ static struct loption option[] = NULL } }, - { '.', &follow_optname, + { OLETTER_NONE, &follow_optname, BOOL, FOLLOW_DESC, &follow_mode, NULL, { - "F command Follows file descriptor", - "F command Follows file name", + "F command follows file descriptor", + "F command follows file name", NULL } }, diff --git a/contrib/less/os.c b/contrib/less/os.c index ffa495d39dcf..dbb52fe3b85f 100644 --- a/contrib/less/os.c +++ b/contrib/less/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -250,6 +250,28 @@ errno_message(filename) return (m); } +/* #define HAVE_FLOAT 0 */ + + static POSITION +muldiv(val, num, den) + POSITION val, num, den; +{ +#if HAVE_FLOAT + double v = (((double) val) * num) / den; + return ((POSITION) (v + 0.5)); +#else + POSITION v = ((POSITION) val) * num; + + if (v / num == val) + /* No overflow */ + return (POSITION) (v / den); + else + /* Above calculation overflows; + * use a method that is less precise but won't overflow. */ + return (POSITION) (val / (den / num)); +#endif +} + /* * Return the ratio of two POSITIONS, as a percentage. * {{ Assumes a POSITION is a long int. }} @@ -258,12 +280,7 @@ errno_message(filename) percentage(num, den) POSITION num, den; { - POSITION num100 = num * 100; - - if (num100 / 100 == num) - return (num100 / den); - else - return (num / (den / 100)); + return (int) muldiv(num, (POSITION) 100, den); } /* @@ -276,19 +293,11 @@ percent_pos(pos, percent, fraction) long fraction; { /* Change percent (parts per 100) to perden (parts per NUM_FRAC_DENOM). */ - long perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100); - POSITION temp; + POSITION perden = (percent * (NUM_FRAC_DENOM / 100)) + (fraction / 100); if (perden == 0) return (0); - temp = pos * perden; /* This might overflow. */ - if (temp / perden == pos) - /* No overflow */ - return (temp / NUM_FRAC_DENOM); - else - /* Above calculation overflows; - * use a method that is less precise but won't overflow. */ - return (perden * (pos / NUM_FRAC_DENOM)); + return (POSITION) muldiv(pos, perden, (POSITION) NUM_FRAC_DENOM); } #if !HAVE_STRCHR diff --git a/contrib/less/output.c b/contrib/less/output.c index 2e7b31c0b207..a4fdada1ba7c 100644 --- a/contrib/less/output.c +++ b/contrib/less/output.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -532,6 +532,7 @@ error(fmt, parg) get_return(); lower_left(); + clear_eol(); if (col >= sc_width) /* diff --git a/contrib/less/pattern.c b/contrib/less/pattern.c index f1fb3ef697e3..ca349b6c1928 100644 --- a/contrib/less/pattern.c +++ b/contrib/less/pattern.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -254,8 +254,8 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) if (search_type & SRCH_NO_REGEX) matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep); - else - { + else + { #if HAVE_POSIX_REGCOMP { regmatch_t rm; @@ -314,7 +314,7 @@ match_pattern(pattern, tpattern, line, line_len, sp, ep, notbol, search_type) #if NO_REGEX matched = match(tpattern, strlen(tpattern), line, line_len, sp, ep); #endif - } + } matched = (!(search_type & SRCH_NO_MATCH) && matched) || ((search_type & SRCH_NO_MATCH) && !matched); return (matched); diff --git a/contrib/less/pattern.h b/contrib/less/pattern.h index d3939a4a3b34..c92aa0295528 100644 --- a/contrib/less/pattern.h +++ b/contrib/less/pattern.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/pckeys.h b/contrib/less/pckeys.h index 04bac1d74fd3..3708d85f43df 100644 --- a/contrib/less/pckeys.h +++ b/contrib/less/pckeys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/position.c b/contrib/less/position.c index 883a0fba9b7d..8c05c5dd1299 100644 --- a/contrib/less/position.c +++ b/contrib/less/position.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/position.h b/contrib/less/position.h index e7291b71a4a3..146972ca79f2 100644 --- a/contrib/less/position.h +++ b/contrib/less/position.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/prompt.c b/contrib/less/prompt.c index 636624d91b9f..daad00de2578 100644 --- a/contrib/less/prompt.c +++ b/contrib/less/prompt.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -304,6 +304,9 @@ protochar(c, where, iseditproto) case 'f': /* File name */ ap_str(get_filename(curr_ifile)); break; + case 'F': /* Last component of file name */ + ap_str(last_component(get_filename(curr_ifile))); + break; case 'i': /* Index into list of files */ #if TAGS if (ntags()) @@ -364,6 +367,7 @@ protochar(c, where, iseditproto) case 't': /* Truncate trailing spaces in the message */ while (mp > message && mp[-1] == ' ') mp--; + *mp = '\0'; break; case 'T': /* Type of list */ #if TAGS diff --git a/contrib/less/screen.c b/contrib/less/screen.c index f61d21798dea..928967da1136 100644 --- a/contrib/less/screen.c +++ b/contrib/less/screen.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -1789,7 +1789,7 @@ win32_scroll_up(n) /* Move the source text to the top of the screen. */ new_org.X = rcSrc.Left; - /* new_org.Y = rcClip.top; -- doesn't compile under MSVC6 */ + new_org.Y = rcClip.Top; /* Fill the right character and attributes. */ fillchar.Char.AsciiChar = ' '; diff --git a/contrib/less/scrsize.c b/contrib/less/scrsize.c index a33564a18d77..05d041ee5fba 100644 --- a/contrib/less/scrsize.c +++ b/contrib/less/scrsize.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/search.c b/contrib/less/search.c index a70af0fb40d7..0b8b961cee9b 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -72,6 +72,25 @@ struct pattern_info { static struct pattern_info search_info; static struct pattern_info filter_info; +/* + * Are there any uppercase letters in this string? + */ + static int +is_ucase(str) + char *str; +{ + char *str_end = str + strlen(str); + LWCHAR ch; + + while (str < str_end) + { + ch = step_char(&str, +1, str_end); + if (IS_UPPER(ch)) + return (1); + } + return (0); +} + /* * Compile and save a search pattern. */ @@ -95,6 +114,16 @@ set_pattern(info, pattern, search_type) strcpy(info->text, pattern); } info->search_type = search_type; + + /* + * Ignore case if -I is set OR + * -i is set AND the pattern is all lowercase. + */ + is_ucase_pattern = is_ucase(pattern); + if (is_ucase_pattern && caseless != OPT_ONPLUS) + is_caseless = 0; + else + is_caseless = caseless; return 0; } @@ -157,25 +186,6 @@ get_cvt_ops() return (ops); } -/* - * Are there any uppercase letters in this string? - */ - static int -is_ucase(str) - char *str; -{ - char *str_end = str + strlen(str); - LWCHAR ch; - - while (str < str_end) - { - ch = step_char(&str, +1, str_end); - if (IS_UPPER(ch)) - return (1); - } - return (0); -} - /* * Is there a previous (remembered) search pattern? */ @@ -231,7 +241,7 @@ repaint_hilite(on) goto_line(slinenum); put_line(); } - lower_left(); // if !oldbot + lower_left(); hide_hilite = save_hide_hilite; } @@ -601,7 +611,7 @@ search_pos(search_type) */ if (search_type & SRCH_FORW) { - return (ch_zero()); + pos = ch_zero(); } else { pos = ch_length(); @@ -610,46 +620,66 @@ search_pos(search_type) (void) ch_end_seek(); pos = ch_length(); } - return (pos); } - } - if (how_search) + linenum = 0; + } else { - /* - * Search does not include current screen. - */ - if (search_type & SRCH_FORW) - linenum = BOTTOM_PLUS_ONE; - else - linenum = TOP; - pos = position(linenum); - } else - { - /* - * Search includes current screen. - * It starts at the jump target (if searching backwards), - * or at the jump target plus one (if forwards). - */ - linenum = adjsline(jump_sline); - pos = position(linenum); - if (search_type & SRCH_FORW) + int add_one = 0; + + if (how_search == OPT_ON) { - pos = forw_raw_line(pos, (char **)NULL, (int *)NULL); - while (pos == NULL_POSITION) - { - if (++linenum >= sc_height) - break; - pos = position(linenum); - } + /* + * Search does not include current screen. + */ + if (search_type & SRCH_FORW) + linenum = BOTTOM_PLUS_ONE; + else + linenum = TOP; + } else if (how_search == OPT_ONPLUS && !(search_type & SRCH_AFTER_TARGET)) + { + /* + * Search includes all of displayed screen. + */ + if (search_type & SRCH_FORW) + linenum = TOP; + else + linenum = BOTTOM_PLUS_ONE; } else { - while (pos == NULL_POSITION) - { - if (--linenum < 0) - break; - pos = position(linenum); - } + /* + * Search includes the part of current screen beyond the jump target. + * It starts at the jump target (if searching backwards), + * or at the jump target plus one (if forwards). + */ + linenum = jump_sline; + if (search_type & SRCH_FORW) + add_one = 1; } + linenum = adjsline(linenum); + pos = position(linenum); + if (add_one) + pos = forw_raw_line(pos, (char **)NULL, (int *)NULL); + } + + /* + * If the line is empty, look around for a plausible starting place. + */ + if (search_type & SRCH_FORW) + { + while (pos == NULL_POSITION) + { + if (++linenum >= sc_height) + break; + pos = position(linenum); + } + } else + { + while (pos == NULL_POSITION) + { + if (--linenum < 0) + break; + pos = position(linenum); + } } return (pos); } @@ -791,7 +821,7 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) if (prev_pattern(&search_info)) { line_match = match_pattern(search_info.compiled, search_info.text, - cline, line_len, &sp, &ep, 0, search_type); //FIXME search_info.search_type + cline, line_len, &sp, &ep, 0, search_type); if (line_match) { /* @@ -855,12 +885,6 @@ hist_pattern(search_type) if (set_pattern(&search_info, pattern, search_type) < 0) return (0); - is_ucase_pattern = is_ucase(pattern); - if (is_ucase_pattern && caseless != OPT_ONPLUS) - is_caseless = 0; - else - is_caseless = caseless; - #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS && !hide_hilite) hilite_screen(); @@ -894,6 +918,7 @@ search(search_type, pattern, n) /* * A null pattern means use the previously compiled pattern. */ + search_type |= SRCH_AFTER_TARGET; if (!prev_pattern(&search_info) && !hist_pattern(search_type)) { error("No previous regular expression", NULL_PARG); @@ -932,15 +957,6 @@ search(search_type, pattern, n) */ if (set_pattern(&search_info, pattern, search_type) < 0) return (-1); - /* - * Ignore case if -I is set OR - * -i is set AND the pattern is all lowercase. - */ - is_ucase_pattern = is_ucase(pattern); - if (is_ucase_pattern && caseless != OPT_ONPLUS) - is_caseless = 0; - else - is_caseless = caseless; #if HILITE_SEARCH if (hilite_search) { diff --git a/contrib/less/signal.c b/contrib/less/signal.c index 08fda859825a..f305c12f0501 100644 --- a/contrib/less/signal.c +++ b/contrib/less/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -256,6 +256,6 @@ psignals() if (tsignals & S_INTERRUPT) { if (quit_on_intr) - quit(QUIT_OK); + quit(QUIT_INTERRUPT); } } diff --git a/contrib/less/tags.c b/contrib/less/tags.c index 2f39d429e66f..c00f9d488dd5 100644 --- a/contrib/less/tags.c +++ b/contrib/less/tags.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c index 131d4430d736..00f2c9e4ad58 100644 --- a/contrib/less/ttyin.c +++ b/contrib/less/ttyin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. diff --git a/contrib/less/version.c b/contrib/less/version.c index 84c7613db52e..be75d2033fd2 100644 --- a/contrib/less/version.c +++ b/contrib/less/version.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2009 Mark Nudelman + * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -729,6 +729,19 @@ v433 6/28/09 Cleanup search code. v434 6/29/09 More cleanup. v435 7/04/09 Fix bugs with non-regex filtering. v436 7/05/09 Fix memory leak. +----------------------------------------------------------------- +v437 7/14/09 Fix bug in handling some long option names; + make percentage calculation more accurate. +v438 12/29/10 Fix bugs with -i/-I and & filtering; + exit with status 2 on ctrl-C with -K. +v439 12/31/10 Add -A option. +v440 1/5/11 Fix bug displaying prompt after = command. +v441 1/21/11 Fix semi-infinite loop if no newlines in file; + make new -A behavior the default. +----------------------------------------------------------------- +v442 3/2/11 Fix search bug. + Add ctrl-G line edit command. +v443 4/9/11 Fix Windows build. */ -char version[] = "436"; +char version[] = "443"; diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index ed79ba3883c6..10f984757e1a 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -403,6 +403,7 @@ static void bge_start(struct ifnet *); static int bge_ioctl(struct ifnet *, u_long, caddr_t); static void bge_init_locked(struct bge_softc *); static void bge_init(void *); +static void bge_stop_block(struct bge_softc *, bus_size_t, uint32_t); static void bge_stop(struct bge_softc *); static void bge_watchdog(struct bge_softc *); static int bge_shutdown(device_t); @@ -1593,22 +1594,19 @@ bge_blockinit(struct bge_softc *sc) CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_HIWAT, 10); /* Enable buffer manager */ - if (!(BGE_IS_5705_PLUS(sc))) { - CSR_WRITE_4(sc, BGE_BMAN_MODE, - BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN); + CSR_WRITE_4(sc, BGE_BMAN_MODE, + BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN); - /* Poll for buffer manager start indication */ - for (i = 0; i < BGE_TIMEOUT; i++) { - DELAY(10); - if (CSR_READ_4(sc, BGE_BMAN_MODE) & BGE_BMANMODE_ENABLE) - break; - } + /* Poll for buffer manager start indication */ + for (i = 0; i < BGE_TIMEOUT; i++) { + DELAY(10); + if (CSR_READ_4(sc, BGE_BMAN_MODE) & BGE_BMANMODE_ENABLE) + break; + } - if (i == BGE_TIMEOUT) { - device_printf(sc->bge_dev, - "buffer manager failed to start\n"); - return (ENXIO); - } + if (i == BGE_TIMEOUT) { + device_printf(sc->bge_dev, "buffer manager failed to start\n"); + return (ENXIO); } /* Enable flow-through queues */ @@ -5136,6 +5134,20 @@ bge_watchdog(struct bge_softc *sc) ifp->if_oerrors++; } +static void +bge_stop_block(struct bge_softc *sc, bus_size_t reg, uint32_t bit) +{ + int i; + + BGE_CLRBIT(sc, reg, bit); + + for (i = 0; i < BGE_TIMEOUT; i++) { + if ((CSR_READ_4(sc, reg) & bit) == 0) + return; + DELAY(100); + } +} + /* * Stop the adapter and free any mbufs allocated to the * RX and TX lists. @@ -5164,35 +5176,36 @@ bge_stop(struct bge_softc *sc) /* * Disable all of the receiver blocks. */ - BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDBDI_MODE, BGE_RBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RBDC_MODE, BGE_RBDCMODE_ENABLE); + bge_stop_block(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); + bge_stop_block(sc, BGE_RBDI_MODE, BGE_RBDIMODE_ENABLE); + bge_stop_block(sc, BGE_RXLP_MODE, BGE_RXLPMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_RXLS_MODE, BGE_RXLSMODE_ENABLE); + bge_stop_block(sc, BGE_RDBDI_MODE, BGE_RBDIMODE_ENABLE); + bge_stop_block(sc, BGE_RDC_MODE, BGE_RDCMODE_ENABLE); + bge_stop_block(sc, BGE_RBDC_MODE, BGE_RBDCMODE_ENABLE); /* * Disable all of the transmit blocks. */ - BGE_CLRBIT(sc, BGE_SRS_MODE, BGE_SRSMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SBDI_MODE, BGE_SBDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SDI_MODE, BGE_SDIMODE_ENABLE); - BGE_CLRBIT(sc, BGE_RDMA_MODE, BGE_RDMAMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SDC_MODE, BGE_SDCMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); - BGE_CLRBIT(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE); + bge_stop_block(sc, BGE_SRS_MODE, BGE_SRSMODE_ENABLE); + bge_stop_block(sc, BGE_SBDI_MODE, BGE_SBDIMODE_ENABLE); + bge_stop_block(sc, BGE_SDI_MODE, BGE_SDIMODE_ENABLE); + bge_stop_block(sc, BGE_RDMA_MODE, BGE_RDMAMODE_ENABLE); + bge_stop_block(sc, BGE_SDC_MODE, BGE_SDCMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); + bge_stop_block(sc, BGE_SBDC_MODE, BGE_SBDCMODE_ENABLE); /* * Shut down all of the memory managers and related * state machines. */ - BGE_CLRBIT(sc, BGE_HCC_MODE, BGE_HCCMODE_ENABLE); - BGE_CLRBIT(sc, BGE_WDMA_MODE, BGE_WDMAMODE_ENABLE); - if (!(BGE_IS_5705_PLUS(sc))) - BGE_CLRBIT(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE); + bge_stop_block(sc, BGE_HCC_MODE, BGE_HCCMODE_ENABLE); + bge_stop_block(sc, BGE_WDMA_MODE, BGE_WDMAMODE_ENABLE); + if (BGE_IS_5700_FAMILY(sc)) + bge_stop_block(sc, BGE_MBCF_MODE, BGE_MBCFMODE_ENABLE); + CSR_WRITE_4(sc, BGE_FTQ_RESET, 0xFFFFFFFF); CSR_WRITE_4(sc, BGE_FTQ_RESET, 0); if (!(BGE_IS_5705_PLUS(sc))) { diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c index 4c07739fe759..8e3986a80be1 100644 --- a/sys/dev/mii/brgphy.c +++ b/sys/dev/mii/brgphy.c @@ -140,6 +140,7 @@ static const struct mii_phydesc brgphys[] = { MII_PHY_DESC(BROADCOM2, BCM5761), MII_PHY_DESC(BROADCOM2, BCM5784), MII_PHY_DESC(BROADCOM3, BCM5717C), + MII_PHY_DESC(BROADCOM3, BCM5719C), MII_PHY_DESC(BROADCOM3, BCM57765), MII_PHY_DESC(xxBROADCOM_ALT1, BCM5906), MII_PHY_END diff --git a/sys/dev/mii/miidevs b/sys/dev/mii/miidevs index 7532b29971c1..527494009401 100644 --- a/sys/dev/mii/miidevs +++ b/sys/dev/mii/miidevs @@ -177,6 +177,7 @@ model BROADCOM2 BCM5709C 0x003c BCM5709 10/100/1000baseT PHY model BROADCOM2 BCM5761 0x003d BCM5761 10/100/1000baseT PHY model BROADCOM2 BCM5709S 0x003f BCM5709S 1000/2500baseSX PHY model BROADCOM3 BCM5717C 0x0020 BCM5717C 1000BASE-T media interface +model BROADCOM3 BCM5719C 0x0022 BCM5719C 1000BASE-T media interface model BROADCOM3 BCM57765 0x0024 BCM57765 1000BASE-T media interface model xxBROADCOM_ALT1 BCM5906 0x0004 BCM5906 10/100baseTX media interface diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 5df2f31fa0b9..dbcac8529754 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1467,6 +1467,24 @@ vm_object_backing_scan(vm_object_t object, int op) } pp = vm_page_lookup(object, new_pindex); + if ( + (op & OBSC_COLLAPSE_NOWAIT) != 0 && + (pp != NULL && pp->valid == 0) + ) { + /* + * The page in the parent is not (yet) valid. + * We don't know anything about the state of + * the original page. It might be mapped, + * so we must avoid the next if here. + * + * This is due to a race in vm_fault() where + * we must unbusy the original (backing_obj) + * page before we can (re)lock the parent. + * Hence we can get here. + */ + p = next; + continue; + } if ( pp != NULL || vm_pager_has_page(object, new_pindex, NULL, NULL) From 76d9a072333e46ec2f88a30987db93b41bf66e00 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 10 May 2011 13:48:21 +0000 Subject: [PATCH 031/164] Make the intended change. --- sys/powerpc/powerpc/openpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c index edccf61c713b..347dc3fb4eeb 100644 --- a/sys/powerpc/powerpc/openpic.c +++ b/sys/powerpc/powerpc/openpic.c @@ -245,7 +245,7 @@ openpic_bind(device_t dev, u_int irq, cpuset_t cpumask) * XXX: openpic_write() is very special and just needs a 32 bits mask. * For the moment, just play dirty and get the first half word. */ - openpic_write(sc, OPENPIC_IDEST(irq), (long)cpumask & 0xffffffff); + openpic_write(sc, OPENPIC_IDEST(irq), cpumask.__bits[0] & 0xffffffff); } void From 0f9cccb0914c700193f383678454afb985969c38 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 10 May 2011 13:49:34 +0000 Subject: [PATCH 032/164] Avoid breaking strict-aliasing. --- usr.sbin/pmccontrol/pmccontrol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c index 836025b926fc..80d4bd7c3dde 100644 --- a/usr.sbin/pmccontrol/pmccontrol.c +++ b/usr.sbin/pmccontrol/pmccontrol.c @@ -141,6 +141,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list) unsigned char *map; unsigned char op; int cpu, pmc; + size_t setsize; if ((ncpu = pmc_ncpu()) < 0) err(EX_OSERR, "Unable to determine the number of cpus"); @@ -152,8 +153,9 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list) "halted"); } CPU_ZERO(&haltedcpus); + setsize = (size_t)cpusetsize; if (ncpu > 1 && sysctlbyname("machdep.hlt_cpus", &haltedcpus, - (size_t *)&cpusetsize, NULL, 0) < 0) + &setsize, NULL, 0) < 0) err(EX_OSERR, "ERROR: Cannot determine which CPUs are " "halted"); CPU_FILL(&cpumask); From 396e1498b7d3d489c65cf73c4917943dd12a5d8f Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 10 May 2011 13:59:33 +0000 Subject: [PATCH 033/164] Remove strict-aliasing fixup where it is easy to avoid that as it leads to a faster implementation. Requested by: bde --- sys/powerpc/include/atomic.h | 89 +++++++++++++++++------------------- 1 file changed, 41 insertions(+), 48 deletions(-) diff --git a/sys/powerpc/include/atomic.h b/sys/powerpc/include/atomic.h index 165efcf88e02..77f573233401 100644 --- a/sys/powerpc/include/atomic.h +++ b/sys/powerpc/include/atomic.h @@ -43,31 +43,6 @@ #define wmb() mb() #define rmb() mb() -#define _ATOMIC_PUN_LTOI(FUNC) \ - static __inline void \ - atomic_##FUNC##_long(volatile u_long *p, u_long v) \ - { \ - \ - atomic_##FUNC##_int((volatile u_int *)p, (u_int)v); \ - } \ - \ - static __inline void \ - atomic_##FUNC##_acq_long(volatile u_long *p, u_long v) \ - { \ - \ - atomic_##FUNC##_acq_int((volatile u_int *)p, \ - (u_int)v); \ - } \ - \ - static __inline void \ - atomic_##FUNC##_rel_long(volatile u_long *p, u_long v) \ - { \ - \ - atomic_##FUNC##_rel_int((volatile u_int *)p, \ - (u_int)v); \ - } \ - /* _ATOMIC_PUN_LTOI */ - /* * atomic_add(p, v) * { *p += v; } @@ -97,7 +72,15 @@ /* __atomic_add_long */ #else #define __atomic_add_long(p, v, t) \ - long atomic_add not implemented + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " add %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_add_long */ #endif #define _ATOMIC_ADD(type) \ @@ -123,14 +106,13 @@ /* _ATOMIC_ADD */ _ATOMIC_ADD(int) +_ATOMIC_ADD(long) #define atomic_add_32 atomic_add_int #define atomic_add_acq_32 atomic_add_acq_int #define atomic_add_rel_32 atomic_add_rel_int #ifdef __powerpc64__ -_ATOMIC_ADD(long) - #define atomic_add_64 atomic_add_long #define atomic_add_acq_64 atomic_add_acq_long #define atomic_add_rel_64 atomic_add_rel_long @@ -139,8 +121,6 @@ _ATOMIC_ADD(long) #define atomic_add_acq_ptr atomic_add_acq_long #define atomic_add_rel_ptr atomic_add_rel_long #else -_ATOMIC_PUN_LTOI(add) - #define atomic_add_ptr atomic_add_int #define atomic_add_acq_ptr atomic_add_acq_int #define atomic_add_rel_ptr atomic_add_rel_int @@ -178,7 +158,15 @@ _ATOMIC_PUN_LTOI(add) /* __atomic_clear_long */ #else #define __atomic_clear_long(p, v, t) \ - long atomic_clear not implemented + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " andc %0, %0, %3\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_clear_long */ #endif #define _ATOMIC_CLEAR(type) \ @@ -205,14 +193,13 @@ _ATOMIC_PUN_LTOI(add) _ATOMIC_CLEAR(int) +_ATOMIC_CLEAR(long) #define atomic_clear_32 atomic_clear_int #define atomic_clear_acq_32 atomic_clear_acq_int #define atomic_clear_rel_32 atomic_clear_rel_int #ifdef __powerpc64__ -_ATOMIC_CLEAR(long) - #define atomic_clear_64 atomic_clear_long #define atomic_clear_acq_64 atomic_clear_acq_long #define atomic_clear_rel_64 atomic_clear_rel_long @@ -221,13 +208,11 @@ _ATOMIC_CLEAR(long) #define atomic_clear_acq_ptr atomic_clear_acq_long #define atomic_clear_rel_ptr atomic_clear_rel_long #else -_ATOMIC_PUN_LTOI(clear) - #define atomic_clear_ptr atomic_clear_int #define atomic_clear_acq_ptr atomic_clear_acq_int #define atomic_clear_rel_ptr atomic_clear_rel_int #endif -#undef _ATOMIC_ADD +#undef _ATOMIC_CLEAR #undef __atomic_clear_long #undef __atomic_clear_int @@ -275,7 +260,15 @@ _ATOMIC_PUN_LTOI(clear) /* __atomic_set_long */ #else #define __atomic_set_long(p, v, t) \ - long atomic_set not implemented + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " or %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_set_long */ #endif #define _ATOMIC_SET(type) \ @@ -301,14 +294,13 @@ _ATOMIC_PUN_LTOI(clear) /* _ATOMIC_SET */ _ATOMIC_SET(int) +_ATOMIC_SET(long) #define atomic_set_32 atomic_set_int #define atomic_set_acq_32 atomic_set_acq_int #define atomic_set_rel_32 atomic_set_rel_int #ifdef __powerpc64__ -_ATOMIC_SET(long) - #define atomic_set_64 atomic_set_long #define atomic_set_acq_64 atomic_set_acq_long #define atomic_set_rel_64 atomic_set_rel_long @@ -317,8 +309,6 @@ _ATOMIC_SET(long) #define atomic_set_acq_ptr atomic_set_acq_long #define atomic_set_rel_ptr atomic_set_rel_long #else -_ATOMIC_PUN_LTOI(set) - #define atomic_set_ptr atomic_set_int #define atomic_set_acq_ptr atomic_set_acq_int #define atomic_set_rel_ptr atomic_set_rel_int @@ -356,7 +346,15 @@ _ATOMIC_PUN_LTOI(set) /* __atomic_subtract_long */ #else #define __atomic_subtract_long(p, v, t) \ - long atomic_subtract not implemented + __asm __volatile( \ + "1: lwarx %0, 0, %2\n" \ + " subf %0, %3, %0\n" \ + " stwcx. %0, 0, %2\n" \ + " bne- 1b\n" \ + : "=&r" (t), "=m" (*p) \ + : "r" (p), "r" (v), "m" (*p) \ + : "cc", "memory") \ + /* __atomic_subtract_long */ #endif #define _ATOMIC_SUBTRACT(type) \ @@ -382,14 +380,13 @@ _ATOMIC_PUN_LTOI(set) /* _ATOMIC_SUBTRACT */ _ATOMIC_SUBTRACT(int) +_ATOMIC_SUBTRACT(long) #define atomic_subtract_32 atomic_subtract_int #define atomic_subtract_acq_32 atomic_subtract_acq_int #define atomic_subtract_rel_32 atomic_subtract_rel_int #ifdef __powerpc64__ -_ATOMIC_SUBTRACT(long) - #define atomic_subtract_64 atomic_subtract_long #define atomic_subtract_acq_64 atomic_subract_acq_long #define atomic_subtract_rel_64 atomic_subtract_rel_long @@ -398,8 +395,6 @@ _ATOMIC_SUBTRACT(long) #define atomic_subtract_acq_ptr atomic_subtract_acq_long #define atomic_subtract_rel_ptr atomic_subtract_rel_long #else -_ATOMIC_PUN_LTOI(subtract) - #define atomic_subtract_ptr atomic_subtract_int #define atomic_subtract_acq_ptr atomic_subtract_acq_int #define atomic_subtract_rel_ptr atomic_subtract_rel_int @@ -408,8 +403,6 @@ _ATOMIC_PUN_LTOI(subtract) #undef __atomic_subtract_long #undef __atomic_subtract_int -#undef _ATOMIC_PUN_LTOI - /* * atomic_store_rel(p, v) */ From c6cd792c28dac274cbcdfcef8acc787f624a07ad Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 10 May 2011 18:01:53 +0000 Subject: [PATCH 034/164] Sync with -CURRENT --- lib/libmemstat/memstat.h | 2 +- tools/build/options/WITHOUT_GPIO | 2 +- tools/regression/bin/sh/parser/dollar-quote1.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote2.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote3.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote4.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote5.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote6.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote7.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote8.0 | 2 +- tools/regression/bin/sh/parser/dollar-quote9.0 | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/libmemstat/memstat.h b/lib/libmemstat/memstat.h index 5267e78aa05e..e973f1a52db4 100644 --- a/lib/libmemstat/memstat.h +++ b/lib/libmemstat/memstat.h @@ -31,7 +31,7 @@ /* * Number of CPU slots in library-internal data structures. This should be - * at least value of MAXCPU from param.h + * at least the value of MAXCPU from param.h. */ #define MEMSTAT_MAXCPU 32 diff --git a/tools/build/options/WITHOUT_GPIO b/tools/build/options/WITHOUT_GPIO index 08c565d76986..0b1d091470d0 100644 --- a/tools/build/options/WITHOUT_GPIO +++ b/tools/build/options/WITHOUT_GPIO @@ -1,4 +1,4 @@ -.\" $FreeBSD: head/tools/build/options/WITHOUT_GPIO 221541 2011-05-06 19:14:06Z ru $ +.\" $FreeBSD$ Set to not build .Xr gpioctl 8 as part of the base system. diff --git a/tools/regression/bin/sh/parser/dollar-quote1.0 b/tools/regression/bin/sh/parser/dollar-quote1.0 index 2554eedca8aa..12061417e108 100644 --- a/tools/regression/bin/sh/parser/dollar-quote1.0 +++ b/tools/regression/bin/sh/parser/dollar-quote1.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote1.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ set -e diff --git a/tools/regression/bin/sh/parser/dollar-quote2.0 b/tools/regression/bin/sh/parser/dollar-quote2.0 index 0e959338d680..4617ed8d9086 100644 --- a/tools/regression/bin/sh/parser/dollar-quote2.0 +++ b/tools/regression/bin/sh/parser/dollar-quote2.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote2.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ # This depends on the ASCII character set. diff --git a/tools/regression/bin/sh/parser/dollar-quote3.0 b/tools/regression/bin/sh/parser/dollar-quote3.0 index 7c0f9663cb35..a7e68527791c 100644 --- a/tools/regression/bin/sh/parser/dollar-quote3.0 +++ b/tools/regression/bin/sh/parser/dollar-quote3.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote3.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ unset LC_ALL LC_CTYPE=en_US.ISO8859-1 diff --git a/tools/regression/bin/sh/parser/dollar-quote4.0 b/tools/regression/bin/sh/parser/dollar-quote4.0 index 6403ad9f37f6..f620af5b12c2 100644 --- a/tools/regression/bin/sh/parser/dollar-quote4.0 +++ b/tools/regression/bin/sh/parser/dollar-quote4.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote4.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ unset LC_ALL LC_CTYPE=en_US.ISO8859-1 diff --git a/tools/regression/bin/sh/parser/dollar-quote5.0 b/tools/regression/bin/sh/parser/dollar-quote5.0 index b5e20a4c5d84..c2c44ca620e5 100644 --- a/tools/regression/bin/sh/parser/dollar-quote5.0 +++ b/tools/regression/bin/sh/parser/dollar-quote5.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote5.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ # This depends on the ASCII character set. diff --git a/tools/regression/bin/sh/parser/dollar-quote6.0 b/tools/regression/bin/sh/parser/dollar-quote6.0 index 92046137a15f..a4b1e3f48729 100644 --- a/tools/regression/bin/sh/parser/dollar-quote6.0 +++ b/tools/regression/bin/sh/parser/dollar-quote6.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote6.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ # This depends on the ASCII character set. diff --git a/tools/regression/bin/sh/parser/dollar-quote7.0 b/tools/regression/bin/sh/parser/dollar-quote7.0 index 9c6bd39030b0..c866b1af68bb 100644 --- a/tools/regression/bin/sh/parser/dollar-quote7.0 +++ b/tools/regression/bin/sh/parser/dollar-quote7.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote7.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ set -e diff --git a/tools/regression/bin/sh/parser/dollar-quote8.0 b/tools/regression/bin/sh/parser/dollar-quote8.0 index de9161437cf4..8f0b41a0a3f7 100644 --- a/tools/regression/bin/sh/parser/dollar-quote8.0 +++ b/tools/regression/bin/sh/parser/dollar-quote8.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote8.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ [ $'hello\0' = hello ] [ $'hello\0world' = hello ] diff --git a/tools/regression/bin/sh/parser/dollar-quote9.0 b/tools/regression/bin/sh/parser/dollar-quote9.0 index 8a4ea9f21d92..df64b7dfc0b1 100644 --- a/tools/regression/bin/sh/parser/dollar-quote9.0 +++ b/tools/regression/bin/sh/parser/dollar-quote9.0 @@ -1,4 +1,4 @@ -# $FreeBSD: head/tools/regression/bin/sh/parser/dollar-quote9.0 221513 2011-05-05 20:55:55Z jilles $ +# $FreeBSD$ # POSIX and C99 say D800-DFFF are undefined in a universal character name. # We reject this but many other shells expand to something that looks like From b9d59669da825f7c04b5808e9576c387e2a66a35 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 10 May 2011 18:19:56 +0000 Subject: [PATCH 035/164] Fix an inversion in logic. Submitted by: marius --- sys/sparc64/sparc64/mp_machdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 9055d8b520b4..59deb9de857e 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -532,7 +532,7 @@ cpu_ipi_stop(struct trapframe *tf) CPU_OR_ATOMIC(&stopped_cpus, &tcmask); while (!CPU_OVERLAP(&started_cpus, &tcmask)) { if (CPU_OVERLAP(&shutdown_cpus, &tcmask)) { - CPU_OR_ATOMIC(&shutdown_cpus, &tcmask); + CPU_NAND_ATOMIC(&shutdown_cpus, &tcmask); (void)intr_disable(); for (;;) ; From 0bddc6598ec0e5296369283d3869b75e140109dd Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 11 May 2011 21:10:43 +0000 Subject: [PATCH 036/164] Update for the fact that pm_active and pc_cpumask were changed to cpuset_t. This now calculates pc_cpumask based on pc_cpuid itself as the former is slated for being deorbited. This branch now at least boots UP again. MP needs more things converted and the existing conversion from cpumask_t to cpuset_t still has bugs. --- sys/sparc64/sparc64/genassym.c | 3 +++ sys/sparc64/sparc64/swtch.S | 40 ++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/sys/sparc64/sparc64/genassym.c b/sys/sparc64/sparc64/genassym.c index c0d268b05727..752f38b90012 100644 --- a/sys/sparc64/sparc64/genassym.c +++ b/sys/sparc64/sparc64/genassym.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -66,6 +67,8 @@ ASSYM(PCPU_PAGES, PCPU_PAGES); ASSYM(TAR_VPN_SHIFT, TAR_VPN_SHIFT); +ASSYM(_NCPUBITS, _NCPUBITS); + #ifdef SUN4U ASSYM(TLB_DEMAP_ALL, TLB_DEMAP_ALL); #endif diff --git a/sys/sparc64/sparc64/swtch.S b/sys/sparc64/sparc64/swtch.S index ea13779c46e4..75157343cdc8 100644 --- a/sys/sparc64/sparc64/swtch.S +++ b/sys/sparc64/sparc64/swtch.S @@ -164,20 +164,29 @@ ENTRY(cpu_switch) * If there was no non-kernel pmap, don't try to deactivate it. */ brz,pn %l2, 3f - lduw [PCPU(CPUMASK)], %l4 + lduw [PCPU(CPUID)], %l3 /* * Mark the pmap of the last non-kernel vmspace to run as no longer * active on this CPU. */ - lduw [%l2 + PM_ACTIVE], %l3 - andn %l3, %l4, %l3 - stw %l3, [%l2 + PM_ACTIVE] + mov _NCPUBITS, %l5 + mov %g0, %y + udiv %l3, %l5, %l6 + srl %l6, 0, %l4 + sllx %l4, PTR_SHIFT, %l4 + add %l4, PM_ACTIVE, %l4 + smul %l6, %l5, %l5 + sub %l3, %l5, %l5 + mov 1, %l6 + sllx %l6, %l5, %l5 + ldx [%l2 + %l4], %l6 + andn %l6, %l5, %l6 + stx %l6, [%l2 + %l4] /* * Take away its context number. */ - lduw [PCPU(CPUID)], %l3 sllx %l3, INT_SHIFT, %l3 add %l2, PM_CONTEXT, %l4 mov -1, %l5 @@ -210,18 +219,27 @@ ENTRY(cpu_switch) /* * Set the new context number in the pmap. */ - lduw [PCPU(CPUID)], %i4 - sllx %i4, INT_SHIFT, %i4 + lduw [PCPU(CPUID)], %l3 + sllx %l3, INT_SHIFT, %i4 add %l1, PM_CONTEXT, %i5 stw %i3, [%i4 + %i5] /* * Mark the pmap as active on this CPU. */ - lduw [%l1 + PM_ACTIVE], %i4 - lduw [PCPU(CPUMASK)], %i5 - or %i4, %i5, %i4 - stw %i4, [%l1 + PM_ACTIVE] + mov _NCPUBITS, %l5 + mov %g0, %y + udiv %l3, %l5, %l6 + srl %l6, 0, %l4 + sllx %l4, PTR_SHIFT, %l4 + add %l4, PM_ACTIVE, %l4 + smul %l6, %l5, %l5 + sub %l3, %l5, %l5 + mov 1, %l6 + sllx %l6, %l5, %l5 + ldx [%l1 + %l4], %l6 + or %l6, %l5, %l6 + stx %l6, [%l1 + %l4] /* * Make note of the change in pmap. From b6efe673b328a0f60e1f62ccd905b4b26fbc996f Mon Sep 17 00:00:00 2001 From: marius Date: Wed, 11 May 2011 21:15:12 +0000 Subject: [PATCH 037/164] The ita_mask should include curcpu but the cpuset passed to cpu_ipi_selected() must not, otherwise we tell the CPU to IPI itself, which the sun4u CPUs don't support. For reasons unknown so far MD and MI IPI use actually still triggers that assertion though. --- sys/sparc64/include/smp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/sparc64/include/smp.h b/sys/sparc64/include/smp.h index f8f7d1c192b2..1ba0d9e9f137 100644 --- a/sys/sparc64/include/smp.h +++ b/sys/sparc64/include/smp.h @@ -222,8 +222,8 @@ ipi_tlb_context_demap(struct pmap *pm) } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - CPU_OR(&cpus, PCPU_PTR(cpumask)); ita->ita_mask = cpus; + CPU_OR(&ita->ita_mask, PCPU_PTR(cpumask)); ita->ita_pmap = pm; cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap, (u_long)ita); @@ -247,8 +247,8 @@ ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va) } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - CPU_OR(&cpus, PCPU_PTR(cpumask)); ita->ita_mask = cpus; + CPU_OR(&ita->ita_mask, PCPU_PTR(cpumask)); ita->ita_pmap = pm; ita->ita_va = va; cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_page_demap, (u_long)ita); @@ -272,8 +272,8 @@ ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) } ita = &ipi_tlb_args; mtx_lock_spin(&ipi_mtx); - CPU_OR(&cpus, PCPU_PTR(cpumask)); ita->ita_mask = cpus; + CPU_OR(&ita->ita_mask, PCPU_PTR(cpumask)); ita->ita_pmap = pm; ita->ita_start = start; ita->ita_end = end; From 22bfcf5b903832f985a3d630fdad61b72a9d1763 Mon Sep 17 00:00:00 2001 From: marius Date: Thu, 12 May 2011 09:29:24 +0000 Subject: [PATCH 038/164] Update for the fact that the first members of the IPI args structures and pc_cpumask were changed to cpuset_t. This now calculates the cpumask based on pc_cpuid itself as pc_cpumask is slated for being deorbited. Note that this needs r221750 to be MFC'ed in order to compile. This seems to work fine but after a few dozens of successful IPIs something suddenly adds pc_cpuid to pc_other_cpus, causing the respective assertions in mp_machdep.c to be triggered when the latter is used as the base for the targets. --- sys/sparc64/sparc64/genassym.c | 1 - sys/sparc64/sparc64/mp_exception.S | 32 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/sys/sparc64/sparc64/genassym.c b/sys/sparc64/sparc64/genassym.c index 752f38b90012..2d1e901e3e2b 100644 --- a/sys/sparc64/sparc64/genassym.c +++ b/sys/sparc64/sparc64/genassym.c @@ -164,7 +164,6 @@ ASSYM(MAXCOMLEN, MAXCOMLEN); ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); -ASSYM(PC_CPUMASK, offsetof(struct pcpu, pc_cpumask)); ASSYM(PC_IRHEAD, offsetof(struct pcpu, pc_irhead)); ASSYM(PC_IRTAIL, offsetof(struct pcpu, pc_irtail)); ASSYM(PC_IRFREE, offsetof(struct pcpu, pc_irfree)); diff --git a/sys/sparc64/sparc64/mp_exception.S b/sys/sparc64/sparc64/mp_exception.S index 5a8a1054c859..d378035f01f3 100644 --- a/sys/sparc64/sparc64/mp_exception.S +++ b/sys/sparc64/sparc64/mp_exception.S @@ -38,9 +38,19 @@ __FBSDID("$FreeBSD$"); .register %g2, #ignore .register %g3, #ignore -#define IPI_DONE(r1, r2, r3, r4) \ - lduw [PCPU(CPUMASK)], r4 ; \ - ATOMIC_CLEAR_INT(r1, r2, r3, r4) +#define IPI_DONE(r1, r2, r3, r4, r5) \ + lduw [PCPU(CPUID)], r2 ; \ + mov _NCPUBITS, r3 ; \ + mov %g0, %y ; \ + udiv r2, r3, r4 ; \ + srl r4, 0, r5 ; \ + sllx r5, PTR_SHIFT, r5 ; \ + add r1, r5, r1 ; \ + smul r4, r3, r3 ; \ + sub r2, r3, r3 ; \ + mov 1, r4 ; \ + sllx r4, r3, r4 ; \ + ATOMIC_CLEAR_LONG(r1, r2, r3, r4) /* * Invalidate a physical page in the data cache. For UltraSPARC I and II. @@ -77,7 +87,7 @@ ENTRY(tl_ipi_spitfire_dcache_page_inval) 2: brgz,pt %g2, 1b sub %g2, %g4, %g2 - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_spitfire_dcache_page_inval) @@ -117,7 +127,7 @@ ENTRY(tl_ipi_spitfire_icache_page_inval) 2: brgz,pt %g2, 1b sub %g2, %g4, %g2 - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_spitfire_icache_page_inval) @@ -148,7 +158,7 @@ ENTRY(tl_ipi_cheetah_dcache_page_inval) blt,a,pt %xcc, 1b nop - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_cheetah_dcache_page_inval) @@ -204,7 +214,7 @@ ENTRY(tl_ipi_tlb_page_demap) stxa %g0, [%g2] ASI_IMMU_DEMAP flush %g3 - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_tlb_page_demap) @@ -247,7 +257,7 @@ ENTRY(tl_ipi_tlb_range_demap) blt,a,pt %xcc, 1b nop - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_tlb_range_demap) @@ -271,7 +281,7 @@ ENTRY(tl_ipi_tlb_context_demap) stxa %g0, [%g1] ASI_IMMU_DEMAP flush %g3 - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_tlb_context_demap) @@ -283,7 +293,7 @@ ENTRY(tl_ipi_stick_rd) rd %asr24, %g2 stx %g2, [%g1] - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_stick_rd) @@ -295,6 +305,6 @@ ENTRY(tl_ipi_tick_rd) rd %tick, %g2 stx %g2, [%g1] - IPI_DONE(%g5, %g1, %g2, %g3) + IPI_DONE(%g5, %g1, %g2, %g3, %g4) retry END(tl_ipi_tick_rd) From ebb514a54a986a57e6598abb60f6972023bfff8f Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 14:57:20 +0000 Subject: [PATCH 039/164] Fix remaining bits that actually weren't converted by mistake. Reported by: sbruno --- sys/ia64/ia64/mp_machdep.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index 015378514687..e3df54a0286c 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -286,7 +286,7 @@ cpu_mp_add(u_int acpi_id, u_int id, u_int eid) cpuid = (IA64_LID_GET_SAPIC_ID(ia64_get_lid()) == sapic_id) ? 0 : smp_cpus++; - KASSERT((all_cpus & (1UL << cpuid)) == 0, + KASSERT(!CPU_ISSET(cpuid, &all_cpus), ("%s: cpu%d already in CPU map", __func__, acpi_id)); if (cpuid != 0) { @@ -300,7 +300,7 @@ cpu_mp_add(u_int acpi_id, u_int id, u_int eid) pc->pc_acpi_id = acpi_id; pc->pc_md.lid = IA64_LID_SET_SAPIC_ID(sapic_id); - all_cpus |= (1UL << pc->pc_cpuid); + CPU_SET(pc->pc_cpuid, &all_cpus); } void @@ -359,7 +359,8 @@ cpu_mp_start() SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { pc->pc_md.current_pmap = kernel_pmap; - pc->pc_other_cpus = all_cpus & ~pc->pc_cpumask; + pc->pc_other_cpus = all_cpus; + CPU_NAND(&pc->pc_other_cpus, &pc->pc_cpumask); /* The BSP is obviously running already. */ if (pc->pc_cpuid == 0) { pc->pc_md.awake = 1; From d576c60fd2f8392ecbb5566b3703fa5dac85d9e9 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 15:09:35 +0000 Subject: [PATCH 040/164] After rewriting powerpc atomic we decided to commit at the constraint that for _ptr operations, when not used directly with uintptr_t, we needed to manually cast. Use the cast on the _ptr version, where it actually wasn't (please note that i386 doesn't get it right, while amd64 doesn't seem to compile cfi neither in LINT, that is why it doesn't fail). Reported by: sbruno --- sys/dev/cfi/cfi_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/cfi/cfi_dev.c b/sys/dev/cfi/cfi_dev.c index d6357531ab8f..9b232bd064ea 100644 --- a/sys/dev/cfi/cfi_dev.c +++ b/sys/dev/cfi/cfi_dev.c @@ -145,7 +145,8 @@ cfi_devopen(struct cdev *dev, int oflags, int devtype, struct thread *td) sc = dev->si_drv1; /* We allow only 1 open. */ - if (!atomic_cmpset_acq_ptr(&sc->sc_opened, NULL, td->td_proc)) + if (!atomic_cmpset_acq_ptr((uintptr_t *)&sc->sc_opened, + (uintptr_t)NULL, (uintptr_t)td->td_proc)) return (EBUSY); return (0); } From d62a193525b7f197ac10cb251e579ab064483b92 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 15:20:57 +0000 Subject: [PATCH 041/164] MFC --- lib/libfetch/Makefile | 1 - lib/libfetch/common.c | 1 + lib/libfetch/file.c | 3 + lib/libfetch/ftp.c | 2 +- lib/libfetch/http.c | 204 +++++++++--------- lib/libprocstat/Makefile | 8 +- lib/libprocstat/libprocstat.c | 4 +- release/powerpc/mkisoimages.sh | 14 ++ sys/dev/ath/ath_hal/ar5416/ar5416.h | 9 + sys/dev/ath/ath_hal/ar5416/ar5416_cal.c | 5 +- sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 98 ++++++--- sys/dev/ath/ath_hal/ar9002/ar9280_olc.c | 9 + sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c | 25 ++- sys/dev/ath/ath_hal/ar9002/ar9285_reset.c | 33 +-- sys/dev/ath/if_ath.c | 4 +- sys/dev/bge/if_bge.c | 85 ++++++-- sys/dev/bge/if_bgereg.h | 15 ++ sys/dev/bm/if_bm.c | 10 - sys/dev/bxe/if_bxe.c | 105 +++++++-- sys/dev/bxe/if_bxe.h | 3 +- sys/dev/mii/atphy.c | 12 ++ sys/dev/mii/mii_physubr.c | 15 +- sys/dev/pci/isa_pci.c | 118 +++++++++- sys/dev/xen/balloon/balloon.c | 18 +- sys/i386/i386/machdep.c | 14 +- sys/i386/xen/clock.c | 197 ++++++++--------- sys/i386/xen/mp_machdep.c | 5 +- sys/kern/kern_clocksource.c | 5 - sys/kern/kern_synch.c | 4 +- sys/kern/kern_sysctl.c | 2 +- sys/kern/vfs_bio.c | 2 +- sys/kern/vfs_mount.c | 2 +- sys/kern/vfs_subr.c | 4 +- sys/kern/vfs_vnops.c | 2 +- sys/kern/vnode_if.src | 4 +- sys/sys/priority.h | 6 + sys/ufs/ffs/ffs_softdep.c | 2 +- usr.bin/fstat/fstat.c | 5 +- usr.bin/mkuzip/mkuzip.c | 2 +- 39 files changed, 690 insertions(+), 367 deletions(-) diff --git a/lib/libfetch/Makefile b/lib/libfetch/Makefile index 5091adf7c334..7b29aa2df5e5 100644 --- a/lib/libfetch/Makefile +++ b/lib/libfetch/Makefile @@ -26,7 +26,6 @@ LDADD= -lmd CFLAGS+= -DFTP_COMBINE_CWDS CSTD?= c99 -WARNS?= 2 SHLIB_MAJOR= 6 diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index ff10d27b419e..fefc4c5defd6 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -213,6 +213,7 @@ fetch_reopen(int sd) /* allocate and fill connection structure */ if ((conn = calloc(1, sizeof(*conn))) == NULL) return (NULL); + fcntl(sd, F_SETFD, FD_CLOEXEC); conn->sd = sd; ++conn->ref; return (conn); diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c index a1492ba05637..dffaad8278fb 100644 --- a/lib/libfetch/file.c +++ b/lib/libfetch/file.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -57,6 +58,7 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags) fetch_syserr(); } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); return (f); } @@ -84,6 +86,7 @@ fetchPutFile(struct url *u, const char *flags) fetch_syserr(); } + fcntl(fileno(f), F_SETFD, FD_CLOEXEC); return (f); } diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index d9810066cd8b..04ae07e9e189 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -127,7 +127,7 @@ unmappedaddr(struct sockaddr_in6 *sin6) !IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) return; sin4 = (struct sockaddr_in *)sin6; - addr = *(u_int32_t *)&sin6->sin6_addr.s6_addr[12]; + addr = *(u_int32_t *)(uintptr_t)&sin6->sin6_addr.s6_addr[12]; port = sin6->sin6_port; memset(sin4, 0, sizeof(struct sockaddr_in)); sin4->sin_addr.s_addr = addr; diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 531342a70068..309cbf261c39 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -454,7 +454,7 @@ http_match(const char *str, const char *hdr) * Get the next header and return the appropriate symbolic code. We * need to read one line ahead for checking for a continuation line * belonging to the current header (continuation lines start with - * white space). + * white space). * * We get called with a fresh line already in the conn buffer, either * from the previous http_next_header() invocation, or, the first @@ -462,7 +462,7 @@ http_match(const char *str, const char *hdr) * * This stops when we encounter an empty line (we dont read beyond the header * area). - * + * * Note that the "headerbuf" is just a place to return the result. Its * contents are not used for the next call. This means that no cleanup * is needed when ie doing another connection, just call the cleanup when @@ -487,7 +487,7 @@ init_http_headerbuf(http_headerbuf_t *buf) buf->buflen = 0; } -static void +static void clean_http_headerbuf(http_headerbuf_t *buf) { if (buf->buf) @@ -496,10 +496,10 @@ clean_http_headerbuf(http_headerbuf_t *buf) } /* Remove whitespace at the end of the buffer */ -static void +static void http_conn_trimright(conn_t *conn) { - while (conn->buflen && + while (conn->buflen && isspace((unsigned char)conn->buf[conn->buflen - 1])) conn->buflen--; conn->buf[conn->buflen] = '\0'; @@ -508,11 +508,11 @@ http_conn_trimright(conn_t *conn) static hdr_t http_next_header(conn_t *conn, http_headerbuf_t *hbuf, const char **p) { - int i, len; + unsigned int i, len; - /* + /* * Have to do the stripping here because of the first line. So - * it's done twice for the subsequent lines. No big deal + * it's done twice for the subsequent lines. No big deal */ http_conn_trimright(conn); if (conn->buflen == 0) @@ -527,19 +527,19 @@ http_next_header(conn_t *conn, http_headerbuf_t *hbuf, const char **p) strcpy(hbuf->buf, conn->buf); hbuf->buflen = conn->buflen; - /* + /* * Fetch possible continuation lines. Stop at 1st non-continuation - * and leave it in the conn buffer - */ + * and leave it in the conn buffer + */ for (i = 0; i < HTTP_MAX_CONT_LINES; i++) { if (fetch_getln(conn) == -1) return (hdr_syserror); - /* + /* * Note: we carry on the idea from the previous version * that a pure whitespace line is equivalent to an empty * one (so it's not continuation and will be handled when - * we are called next) + * we are called next) */ http_conn_trimright(conn); if (conn->buf[0] != ' ' && conn->buf[0] != "\t"[0]) @@ -555,7 +555,7 @@ http_next_header(conn_t *conn, http_headerbuf_t *hbuf, const char **p) } strcpy(hbuf->buf + hbuf->buflen, conn->buf); hbuf->buflen += conn->buflen; - } + } /* * We could check for malformed headers but we don't really care. @@ -574,12 +574,12 @@ http_next_header(conn_t *conn, http_headerbuf_t *hbuf, const char **p) * [Proxy-]Authenticate header parsing */ -/* - * Read doublequote-delimited string into output buffer obuf (allocated +/* + * Read doublequote-delimited string into output buffer obuf (allocated * by caller, whose responsibility it is to ensure that it's big enough) * cp points to the first char after the initial '"' - * Handles \ quoting - * Returns pointer to the first char after the terminating double quote, or + * Handles \ quoting + * Returns pointer to the first char after the terminating double quote, or * NULL for error. */ static const char * @@ -620,7 +620,7 @@ typedef struct { int nc; /* Nonce count */ } http_auth_challenge_t; -static void +static void init_http_auth_challenge(http_auth_challenge_t *b) { b->scheme = HTTPAS_UNKNOWN; @@ -628,18 +628,18 @@ init_http_auth_challenge(http_auth_challenge_t *b) b->stale = b->nc = 0; } -static void +static void clean_http_auth_challenge(http_auth_challenge_t *b) { - if (b->realm) + if (b->realm) free(b->realm); - if (b->qop) + if (b->qop) free(b->qop); - if (b->nonce) + if (b->nonce) free(b->nonce); - if (b->opaque) + if (b->opaque) free(b->opaque); - if (b->algo) + if (b->algo) free(b->algo); init_http_auth_challenge(b); } @@ -652,7 +652,7 @@ typedef struct { int valid; /* We did parse an authenticate header */ } http_auth_challenges_t; -static void +static void init_http_auth_challenges(http_auth_challenges_t *cs) { int i; @@ -661,7 +661,7 @@ init_http_auth_challenges(http_auth_challenges_t *cs) cs->count = cs->valid = 0; } -static void +static void clean_http_auth_challenges(http_auth_challenges_t *cs) { int i; @@ -675,19 +675,19 @@ clean_http_auth_challenges(http_auth_challenges_t *cs) init_http_auth_challenges(cs); } -/* +/* * Enumeration for lexical elements. Separators will be returned as their own * ascii value */ typedef enum {HTTPHL_WORD=256, HTTPHL_STRING=257, HTTPHL_END=258, HTTPHL_ERROR = 259} http_header_lex_t; -/* +/* * Determine what kind of token comes next and return possible value * in buf, which is supposed to have been allocated big enough by - * caller. Advance input pointer and return element type. + * caller. Advance input pointer and return element type. */ -static int +static int http_header_lex(const char **cpp, char *buf) { size_t l; @@ -716,7 +716,7 @@ http_header_lex(const char **cpp, char *buf) return (HTTPHL_WORD); } -/* +/* * Read challenges from http xxx-authenticate header and accumulate them * in the challenges list structure. * @@ -728,7 +728,7 @@ http_header_lex(const char **cpp, char *buf) * * We support both approaches anyway */ -static int +static int http_parse_authenticate(const char *cp, http_auth_challenges_t *cs) { int ret = -1; @@ -752,7 +752,7 @@ http_parse_authenticate(const char *cp, http_auth_challenges_t *cs) /* Loop on challenges */ for (; cs->count < MAX_CHALLENGES; cs->count++) { - cs->challenges[cs->count] = + cs->challenges[cs->count] = malloc(sizeof(http_auth_challenge_t)); if (cs->challenges[cs->count] == NULL) { fetch_syserr(); @@ -765,14 +765,14 @@ http_parse_authenticate(const char *cp, http_auth_challenges_t *cs) cs->challenges[cs->count]->scheme = HTTPAS_DIGEST; } else { cs->challenges[cs->count]->scheme = HTTPAS_UNKNOWN; - /* - * Continue parsing as basic or digest may + /* + * Continue parsing as basic or digest may * follow, and the syntax is the same for * all. We'll just ignore this one when * looking at the list */ } - + /* Loop on attributes */ for (;;) { /* Key */ @@ -791,31 +791,31 @@ http_parse_authenticate(const char *cp, http_auth_challenges_t *cs) goto out; if (!strcasecmp(key, "realm")) - cs->challenges[cs->count]->realm = + cs->challenges[cs->count]->realm = strdup(value); else if (!strcasecmp(key, "qop")) - cs->challenges[cs->count]->qop = + cs->challenges[cs->count]->qop = strdup(value); else if (!strcasecmp(key, "nonce")) - cs->challenges[cs->count]->nonce = + cs->challenges[cs->count]->nonce = strdup(value); else if (!strcasecmp(key, "opaque")) - cs->challenges[cs->count]->opaque = + cs->challenges[cs->count]->opaque = strdup(value); else if (!strcasecmp(key, "algorithm")) - cs->challenges[cs->count]->algo = + cs->challenges[cs->count]->algo = strdup(value); else if (!strcasecmp(key, "stale")) - cs->challenges[cs->count]->stale = + cs->challenges[cs->count]->stale = strcasecmp(value, "no"); /* Else ignore unknown attributes */ /* Comma or Next challenge or End */ lex = http_header_lex(&cp, key); - /* - * If we get a word here, this is the beginning of the - * next challenge. Break the attributes loop - */ + /* + * If we get a word here, this is the beginning of the + * next challenge. Break the attributes loop + */ if (lex == HTTPHL_WORD) break; @@ -832,10 +832,10 @@ http_parse_authenticate(const char *cp, http_auth_challenges_t *cs) } /* End attributes loop */ } /* End challenge loop */ - /* - * Challenges max count exceeded. This really can't happen - * with normal data, something's fishy -> error - */ + /* + * Challenges max count exceeded. This really can't happen + * with normal data, something's fishy -> error + */ out: if (key) @@ -1011,16 +1011,16 @@ init_http_auth_params(http_auth_params_t *s) s->scheme = s->realm = s->user = s->password = 0; } -static void +static void clean_http_auth_params(http_auth_params_t *s) { - if (s->scheme) + if (s->scheme) free(s->scheme); - if (s->realm) + if (s->realm) free(s->realm); - if (s->user) + if (s->user) free(s->user); - if (s->password) + if (s->password) free(s->password); init_http_auth_params(s); } @@ -1075,7 +1075,7 @@ http_authfromenv(const char *p, http_auth_params_t *parms) } ret = 0; out: - if (ret == -1) + if (ret == -1) clean_http_auth_params(parms); if (str) free(str); @@ -1083,11 +1083,11 @@ http_authfromenv(const char *p, http_auth_params_t *parms) } -/* +/* * Digest response: the code to compute the digest is taken from the - * sample implementation in RFC2616 + * sample implementation in RFC2616 */ -#define IN +#define IN const #define OUT #define HASHLEN 16 @@ -1096,7 +1096,7 @@ typedef char HASH[HASHLEN]; typedef char HASHHEX[HASHHEXLEN+1]; static const char *hexchars = "0123456789abcdef"; -static void +static void CvtHex(IN HASH Bin, OUT HASHHEX Hex) { unsigned short i; @@ -1112,7 +1112,7 @@ CvtHex(IN HASH Bin, OUT HASHHEX Hex) }; /* calculate H(A1) as per spec */ -static void +static void DigestCalcHA1( IN char * pszAlg, IN char * pszUserName, @@ -1147,7 +1147,7 @@ DigestCalcHA1( } /* calculate request-digest/response-digest as per HTTP Digest spec */ -static void +static void DigestCalcResponse( IN HASHHEX HA1, /* H(A1) */ IN char * pszNonce, /* nonce from server */ @@ -1160,7 +1160,7 @@ DigestCalcResponse( OUT HASHHEX Response /* request-digest or response-digest */ ) { -/* DEBUG(fprintf(stderr, +/* DEBUG(fprintf(stderr, "Calc: HA1[%s] Nonce[%s] qop[%s] method[%s] URI[%s]\n", HA1, pszNonce, pszQop, pszMethod, pszDigestUri));*/ MD5_CTX Md5Ctx; @@ -1199,8 +1199,8 @@ DigestCalcResponse( CvtHex(RespHash, Response); } -/* - * Generate/Send a Digest authorization header +/* + * Generate/Send a Digest authorization header * This looks like: [Proxy-]Authorization: credentials * * credentials = "Digest" digest-response @@ -1233,10 +1233,10 @@ http_digest_auth(conn_t *conn, const char *hdr, http_auth_challenge_t *c, DEBUG(fprintf(stderr, "realm/nonce not set in challenge\n")); return(-1); } - if (!c->algo) + if (!c->algo) c->algo = strdup(""); - if (asprintf(&options, "%s%s%s%s", + if (asprintf(&options, "%s%s%s%s", *c->algo? ",algorithm=" : "", c->algo, c->opaque? ",opaque=" : "", c->opaque?c->opaque:"")== -1) return (-1); @@ -1264,13 +1264,13 @@ http_digest_auth(conn_t *conn, const char *hdr, http_auth_challenge_t *c, r = http_cmd(conn, "%s: Digest username=\"%s\",realm=\"%s\"," "nonce=\"%s\",uri=\"%s\",response=\"%s\"," "qop=\"auth\", cnonce=\"%s\", nc=%s%s", - hdr, parms->user, c->realm, + hdr, parms->user, c->realm, c->nonce, url->doc, digest, cnonce, noncecount, options); } else { r = http_cmd(conn, "%s: Digest username=\"%s\",realm=\"%s\"," "nonce=\"%s\",uri=\"%s\",response=\"%s\"%s", - hdr, parms->user, c->realm, + hdr, parms->user, c->realm, c->nonce, url->doc, digest, options); } if (options) @@ -1301,7 +1301,7 @@ http_basic_auth(conn_t *conn, const char *hdr, const char *usr, const char *pwd) } /* - * Chose the challenge to answer and call the appropriate routine to + * Chose the challenge to answer and call the appropriate routine to * produce the header. */ static int @@ -1327,16 +1327,16 @@ http_authorize(conn_t *conn, const char *hdr, http_auth_challenges_t *cs, } /* Error if "Digest" was specified and there is no Digest challenge */ - if (!digest && (parms->scheme && + if (!digest && (parms->scheme && !strcasecmp(parms->scheme, "digest"))) { - DEBUG(fprintf(stderr, + DEBUG(fprintf(stderr, "Digest auth in env, not supported by peer\n")); return (-1); } - /* - * If "basic" was specified in the environment, or there is no Digest + /* + * If "basic" was specified in the environment, or there is no Digest * challenge, do the basic thing. Don't need a challenge for this, - * so no need to check basic!=NULL + * so no need to check basic!=NULL */ if (!digest || (parms->scheme && !strcasecmp(parms->scheme,"basic"))) return (http_basic_auth(conn,hdr,parms->user,parms->password)); @@ -1492,7 +1492,7 @@ http_request(struct url *URL, const char *op, struct url_stat *us, http_auth_challenges_t proxy_challenges; /* The following calls don't allocate anything */ - init_http_headerbuf(&headerbuf); + init_http_headerbuf(&headerbuf); init_http_auth_challenges(&server_challenges); init_http_auth_challenges(&proxy_challenges); @@ -1578,65 +1578,65 @@ http_request(struct url *URL, const char *op, struct url_stat *us, /* virtual host */ http_cmd(conn, "Host: %s", host); - /* - * Proxy authorization: we only send auth after we received - * a 407 error. We do not first try basic anyway (changed - * when support was added for digest-auth) - */ + /* + * Proxy authorization: we only send auth after we received + * a 407 error. We do not first try basic anyway (changed + * when support was added for digest-auth) + */ if (purl && proxy_challenges.valid) { http_auth_params_t aparams; init_http_auth_params(&aparams); if (*purl->user || *purl->pwd) { - aparams.user = purl->user ? + aparams.user = purl->user ? strdup(purl->user) : strdup(""); aparams.password = purl->pwd? strdup(purl->pwd) : strdup(""); - } else if ((p = getenv("HTTP_PROXY_AUTH")) != NULL && + } else if ((p = getenv("HTTP_PROXY_AUTH")) != NULL && *p != '\0') { if (http_authfromenv(p, &aparams) < 0) { http_seterr(HTTP_NEED_PROXY_AUTH); goto ouch; } } - http_authorize(conn, "Proxy-Authorization", + http_authorize(conn, "Proxy-Authorization", &proxy_challenges, &aparams, url); clean_http_auth_params(&aparams); } - /* - * Server authorization: we never send "a priori" + /* + * Server authorization: we never send "a priori" * Basic auth, which used to be done if user/pass were * set in the url. This would be weird because we'd send the - * password in the clear even if Digest is finally to be + * password in the clear even if Digest is finally to be * used (it would have made more sense for the - * pre-digest version to do this when Basic was specified - * in the environment) - */ + * pre-digest version to do this when Basic was specified + * in the environment) + */ if (server_challenges.valid) { http_auth_params_t aparams; init_http_auth_params(&aparams); if (*url->user || *url->pwd) { - aparams.user = url->user ? + aparams.user = url->user ? strdup(url->user) : strdup(""); - aparams.password = url->pwd ? + aparams.password = url->pwd ? strdup(url->pwd) : strdup(""); - } else if ((p = getenv("HTTP_AUTH")) != NULL && + } else if ((p = getenv("HTTP_AUTH")) != NULL && *p != '\0') { if (http_authfromenv(p, &aparams) < 0) { http_seterr(HTTP_NEED_AUTH); goto ouch; } - } else if (fetchAuthMethod && + } else if (fetchAuthMethod && fetchAuthMethod(url) == 0) { - aparams.user = url->user ? + aparams.user = url->user ? strdup(url->user) : strdup(""); - aparams.password = url->pwd ? + aparams.password = url->pwd ? strdup(url->pwd) : strdup(""); } else { http_seterr(HTTP_NEED_AUTH); goto ouch; } - http_authorize(conn, "Authorization", + http_authorize(conn, "Authorization", &server_challenges, &aparams, url); clean_http_auth_params(&aparams); } @@ -1804,12 +1804,12 @@ http_request(struct url *URL, const char *op, struct url_stat *us, } while (h > hdr_end); /* we need to provide authentication */ - if (conn->err == HTTP_NEED_AUTH || + if (conn->err == HTTP_NEED_AUTH || conn->err == HTTP_NEED_PROXY_AUTH) { e = conn->err; - if ((conn->err == HTTP_NEED_AUTH && - !server_challenges.valid) || - (conn->err == HTTP_NEED_PROXY_AUTH && + if ((conn->err == HTTP_NEED_AUTH && + !server_challenges.valid) || + (conn->err == HTTP_NEED_PROXY_AUTH && !proxy_challenges.valid)) { /* 401/7 but no www/proxy-authenticate ?? */ DEBUG(fprintf(stderr, "401/7 and no auth header\n")); diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile index dc3dd581b789..e289ef51dbbe 100644 --- a/lib/libprocstat/Makefile +++ b/lib/libprocstat/Makefile @@ -9,7 +9,6 @@ SRCS= cd9660.c \ libprocstat.c \ msdosfs.c \ ntfs.c \ - nwfs.c \ smbfs.c \ udf.c @@ -18,9 +17,14 @@ CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE SHLIB_MAJOR= 1 WITHOUT_MAN= yes +.if ${MK_NCP} != "no" +CFLAGS+= -DLIBPROCSTAT_NWFS +SRCS+= nwfs.c +.endif + # XXX This is a hack. .if ${MK_CDDL} != "no" -CFLAGS+= -DZFS +CFLAGS+= -DLIBPROCSTAT_ZFS OBJS+= zfs/zfs.o SOBJS+= zfs/zfs.So POBJS+= zfs/zfs.po diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index cfe81a2438a6..95b00d32bf75 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -873,11 +873,13 @@ procstat_get_vnode_info_kvm(kvm_t *kd, struct filestat *fst, FSTYPE(msdosfs), FSTYPE(nfs), FSTYPE(ntfs), +#ifdef LIBPROCSTAT_NWFS FSTYPE(nwfs), +#endif FSTYPE(smbfs), FSTYPE(udf), FSTYPE(ufs), -#ifdef ZFS +#ifdef LIBPROCSTAT_ZFS FSTYPE(zfs), #endif }; diff --git a/release/powerpc/mkisoimages.sh b/release/powerpc/mkisoimages.sh index 5c4b0df391f2..63619fb62716 100644 --- a/release/powerpc/mkisoimages.sh +++ b/release/powerpc/mkisoimages.sh @@ -24,6 +24,7 @@ # into base-bits-dir as part of making the image. if [ "x$1" = "x-b" ]; then + # Apple boot code uudecode -o /tmp/hfs-boot-block.bz2 `dirname $0`/hfs-boot.bz2.uu bzip2 -d /tmp/hfs-boot-block.bz2 OFFSET=$(hd /tmp/hfs-boot-block | grep 'Loader START' | cut -f 1 -d ' ') @@ -31,6 +32,17 @@ if [ "x$1" = "x-b" ]; then dd if=$4/boot/loader of=/tmp/hfs-boot-block seek=$OFFSET conv=notrunc bootable="-o bootimage=macppc;/tmp/hfs-boot-block -o no-emul-boot" + + # pSeries/PAPR boot code + mkdir -p $4/ppc/chrp + cp $4/boot/loader $4/ppc/chrp + cat > $4/ppc/bootinfo.txt << EOF + +FreeBSD Install +FreeBSD +boot &device;:&partition;,\ppc\chrp\loader + +EOF shift else bootable="" @@ -48,3 +60,5 @@ echo "/dev/iso9660/`echo $LABEL | tr '[:lower:]' '[:upper:]'` / cd9660 ro 0 0" > makefs -t cd9660 $bootable -o rockridge -o label=$LABEL $NAME $* rm $1/etc/fstab rm /tmp/hfs-boot-block +rm -rf $1/ppc + diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index 3738aaf6cd12..14ad03c55fd7 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -237,6 +237,15 @@ extern HAL_BOOL ar5416GetChipPowerLimits(struct ath_hal *ah, struct ieee80211_channel *chan); extern void ar5416GetChannelCenters(struct ath_hal *, const struct ieee80211_channel *chan, CHAN_CENTERS *centers); +extern void ar5416SetRatesArrayFromTargetPower(struct ath_hal *ah, + const struct ieee80211_channel *chan, + int16_t *ratesArray, + const CAL_TARGET_POWER_LEG *targetPowerCck, + const CAL_TARGET_POWER_LEG *targetPowerCckExt, + const CAL_TARGET_POWER_LEG *targetPowerOfdm, + const CAL_TARGET_POWER_LEG *targetPowerOfdmExt, + const CAL_TARGET_POWER_HT *targetPowerHt20, + const CAL_TARGET_POWER_HT *targetPowerHt40); extern void ar5416GetTargetPowers(struct ath_hal *ah, const struct ieee80211_channel *chan, CAL_TARGET_POWER_HT *powInfo, diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c index 33366609ada9..35dc3df3631c 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c @@ -492,8 +492,9 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan, if (AH5416(ah)->ah_cal_pacal) AH5416(ah)->ah_cal_pacal(ah, AH_FALSE); - /* Do temperature compensation if the chipset needs it */ - AH5416(ah)->ah_olcTempCompensation(ah); + /* Do open-loop temperature compensation if the chipset needs it */ + if (ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)) + AH5416(ah)->ah_olcTempCompensation(ah); /* * Get the value from the previous NF cal diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index c57e6b985ca0..e8eec8623367 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -202,8 +202,11 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode, */ ar5416InitChainMasks(ah); - /* Setup the open-loop temperature compensation if required */ - AH5416(ah)->ah_olcInit(ah); + /* Setup the open-loop power calibration if required */ + if (ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)) { + AH5416(ah)->ah_olcInit(ah); + AH5416(ah)->ah_olcTempCompensation(ah); + } /* Setup the transmit power values. */ if (!ah->ah_setTxPower(ah, chan, rfXpdGain)) { @@ -1634,6 +1637,63 @@ ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan) * Helper functions common for AP/CB/XB */ +/* + * Set the target power array "ratesArray" from the + * given set of target powers. + * + * This is used by the various chipset/EEPROM TX power + * setup routines. + */ +void +ar5416SetRatesArrayFromTargetPower(struct ath_hal *ah, + const struct ieee80211_channel *chan, + int16_t *ratesArray, + const CAL_TARGET_POWER_LEG *targetPowerCck, + const CAL_TARGET_POWER_LEG *targetPowerCckExt, + const CAL_TARGET_POWER_LEG *targetPowerOfdm, + const CAL_TARGET_POWER_LEG *targetPowerOfdmExt, + const CAL_TARGET_POWER_HT *targetPowerHt20, + const CAL_TARGET_POWER_HT *targetPowerHt40) +{ +#define N(a) (sizeof(a)/sizeof(a[0])) + int i; + + /* Blank the rates array, to be consistent */ + for (i = 0; i < Ar5416RateSize; i++) + ratesArray[i] = 0; + + /* Set rates Array from collected data */ + ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] = + ratesArray[rate18mb] = ratesArray[rate24mb] = targetPowerOfdm->tPow2x[0]; + ratesArray[rate36mb] = targetPowerOfdm->tPow2x[1]; + ratesArray[rate48mb] = targetPowerOfdm->tPow2x[2]; + ratesArray[rate54mb] = targetPowerOfdm->tPow2x[3]; + ratesArray[rateXr] = targetPowerOfdm->tPow2x[0]; + + for (i = 0; i < N(targetPowerHt20->tPow2x); i++) { + ratesArray[rateHt20_0 + i] = targetPowerHt20->tPow2x[i]; + } + + if (IEEE80211_IS_CHAN_2GHZ(chan)) { + ratesArray[rate1l] = targetPowerCck->tPow2x[0]; + ratesArray[rate2s] = ratesArray[rate2l] = targetPowerCck->tPow2x[1]; + ratesArray[rate5_5s] = ratesArray[rate5_5l] = targetPowerCck->tPow2x[2]; + ratesArray[rate11s] = ratesArray[rate11l] = targetPowerCck->tPow2x[3]; + } + if (IEEE80211_IS_CHAN_HT40(chan)) { + for (i = 0; i < N(targetPowerHt40->tPow2x); i++) { + ratesArray[rateHt40_0 + i] = targetPowerHt40->tPow2x[i]; + } + ratesArray[rateDupOfdm] = targetPowerHt40->tPow2x[0]; + ratesArray[rateDupCck] = targetPowerHt40->tPow2x[0]; + ratesArray[rateExtOfdm] = targetPowerOfdmExt->tPow2x[0]; + if (IEEE80211_IS_CHAN_2GHZ(chan)) { + ratesArray[rateExtCck] = targetPowerCckExt->tPow2x[0]; + } + } +#undef N +} + /* * ar5416SetPowerPerRateTable * @@ -1855,33 +1915,13 @@ ar5416SetPowerPerRateTable(struct ath_hal *ah, struct ar5416eeprom *pEepData, } /* end ctl mode checking */ /* Set rates Array from collected data */ - ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] = ratesArray[rate18mb] = ratesArray[rate24mb] = targetPowerOfdm.tPow2x[0]; - ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1]; - ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2]; - ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3]; - ratesArray[rateXr] = targetPowerOfdm.tPow2x[0]; - - for (i = 0; i < N(targetPowerHt20.tPow2x); i++) { - ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i]; - } - - if (IEEE80211_IS_CHAN_2GHZ(chan)) { - ratesArray[rate1l] = targetPowerCck.tPow2x[0]; - ratesArray[rate2s] = ratesArray[rate2l] = targetPowerCck.tPow2x[1]; - ratesArray[rate5_5s] = ratesArray[rate5_5l] = targetPowerCck.tPow2x[2]; - ratesArray[rate11s] = ratesArray[rate11l] = targetPowerCck.tPow2x[3]; - } - if (IEEE80211_IS_CHAN_HT40(chan)) { - for (i = 0; i < N(targetPowerHt40.tPow2x); i++) { - ratesArray[rateHt40_0 + i] = targetPowerHt40.tPow2x[i]; - } - ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0]; - ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0]; - ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0]; - if (IEEE80211_IS_CHAN_2GHZ(chan)) { - ratesArray[rateExtCck] = targetPowerCckExt.tPow2x[0]; - } - } + ar5416SetRatesArrayFromTargetPower(ah, chan, ratesArray, + &targetPowerCck, + &targetPowerCckExt, + &targetPowerOfdm, + &targetPowerOfdmExt, + &targetPowerHt20, + &targetPowerHt40); return AH_TRUE; #undef EXT_ADDITIVE #undef CTL_11A_EXT diff --git a/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c b/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c index da5e4ed7be0c..361930bf4b3f 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9280_olc.c @@ -43,6 +43,12 @@ ar9280olcInit(struct ath_hal *ah) { uint32_t i; + /* Only do OLC if it's enabled for this chipset */ + if (! ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)) + return; + + HALDEBUG(ah, HAL_DEBUG_RESET, "%s: Setting up TX gain tables.\n", __func__); + for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++) AH9280(ah)->originalGain[i] = MS(OS_REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4), AR_PHY_TX_GAIN); @@ -126,6 +132,9 @@ ar9280olcTemperatureCompensation(struct ath_hal *ah) int delta, currPDADC, regval; uint8_t hpwr_5g = 0; + if (! ath_hal_eepromGetFlag(ah, AR_EEP_OL_PWRCTRL)) + return; + rddata = OS_REG_READ(ah, AR_PHY_TX_PWRCTRL4); currPDADC = MS(rddata, AR_PHY_TX_PWRCTRL_PD_AVG_OUT); diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c b/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c index a1c2bd26f0fe..84c7682aa3c7 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_diversity.c @@ -368,27 +368,32 @@ ar9285_ant_comb_scan(struct ath_hal *ah, struct ath_rx_status *rs, int curr_main_set, curr_bias; int main_rssi = rs->rs_rssi_ctl[0]; int alt_rssi = rs->rs_rssi_ctl[1]; - int rx_ant_conf, main_ant_conf; + int rx_ant_conf, main_ant_conf, alt_ant_conf; HAL_BOOL short_scan = AH_FALSE; + rx_ant_conf = (rs->rs_rssi_ctl[2] >> 4) & ATH_ANT_RX_MASK; + main_ant_conf = (rs->rs_rssi_ctl[2] >> 2) & ATH_ANT_RX_MASK; + alt_ant_conf = (rs->rs_rssi_ctl[2] >> 0) & ATH_ANT_RX_MASK; + +#if 0 + HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: RSSI %d/%d, conf %x/%x, rxconf %x, LNA: %d; ANT: %d; FastDiv: %d\n", + __func__, main_rssi, alt_rssi, main_ant_conf,alt_ant_conf, rx_ant_conf, + !!(rs->rs_rssi_ctl[2] & 0x80), !!(rs->rs_rssi_ctl[2] & 0x40), !!(rs->rs_rssi_ext[2] & 0x40)); +#endif + if (! ar9285_check_div_comb(ah)) return; if (AH5212(ah)->ah_diversity == AH_FALSE) return; - rx_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_CURRENT_SHIFT) & - ATH_ANT_RX_MASK; - main_ant_conf = (rs->rs_rssi_ctl[2] >> ATH_ANT_RX_MAIN_SHIFT) & - ATH_ANT_RX_MASK; - #if 0 HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: main: %d, alt: %d, rx_ant_conf: %x, main_ant_conf: %x\n", __func__, main_rssi, alt_rssi, rx_ant_conf, main_ant_conf); #endif /* Record packet only when alt_rssi is positive */ - if (alt_rssi > 0) { + if (main_rssi > 0 && alt_rssi > 0) { antcomb->total_pkt_count++; antcomb->main_total_rssi += main_rssi; antcomb->alt_total_rssi += alt_rssi; @@ -613,13 +618,13 @@ ar9285_ant_comb_scan(struct ath_hal *ah, struct ath_rx_status *rs, HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: alt_recv_cnt=%d\n", __func__, antcomb->alt_recv_cnt); - if (curr_alt_set != div_ant_conf.alt_lna_conf) +// if (curr_alt_set != div_ant_conf.alt_lna_conf) HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: lna_conf: %x -> %x\n", __func__, curr_alt_set, div_ant_conf.alt_lna_conf); - if (curr_main_set != div_ant_conf.main_lna_conf) +// if (curr_main_set != div_ant_conf.main_lna_conf) HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: main_lna_conf: %x -> %x\n", __func__, curr_main_set, div_ant_conf.main_lna_conf); - if (curr_bias != div_ant_conf.fast_div_bias) +// if (curr_bias != div_ant_conf.fast_div_bias) HALDEBUG(ah, HAL_DEBUG_DIVERSITY, "%s: fast_div_bias: %x -> %x\n", __func__, curr_bias, div_ant_conf.fast_div_bias); diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c b/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c index d8087033e460..1a0c77be26d9 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c @@ -533,32 +533,15 @@ ar9285SetPowerPerRateTable(struct ath_hal *ah, struct ar5416eeprom_4k *pEepData, } } /* end ctl mode checking */ - /* Set rates Array from collected data */ - ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] = ratesArray[rate18mb] = ratesArray[rate24mb] = targetPowerOfdm.tPow2x[0]; - ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1]; - ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2]; - ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3]; - ratesArray[rateXr] = targetPowerOfdm.tPow2x[0]; + /* Set rates Array from collected data */ + ar5416SetRatesArrayFromTargetPower(ah, chan, ratesArray, + &targetPowerCck, + &targetPowerCckExt, + &targetPowerOfdm, + &targetPowerOfdmExt, + &targetPowerHt20, + &targetPowerHt40); - for (i = 0; i < N(targetPowerHt20.tPow2x); i++) { - ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i]; - } - - ratesArray[rate1l] = targetPowerCck.tPow2x[0]; - ratesArray[rate2s] = ratesArray[rate2l] = targetPowerCck.tPow2x[1]; - ratesArray[rate5_5s] = ratesArray[rate5_5l] = targetPowerCck.tPow2x[2]; - ratesArray[rate11s] = ratesArray[rate11l] = targetPowerCck.tPow2x[3]; - if (IEEE80211_IS_CHAN_HT40(chan)) { - for (i = 0; i < N(targetPowerHt40.tPow2x); i++) { - ratesArray[rateHt40_0 + i] = targetPowerHt40.tPow2x[i]; - } - ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0]; - ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0]; - ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0]; - if (IEEE80211_IS_CHAN_2GHZ(chan)) { - ratesArray[rateExtCck] = targetPowerCckExt.tPow2x[0]; - } - } return AH_TRUE; #undef EXT_ADDITIVE #undef CTL_11G_EXT diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 9234c264392a..8f13b267c0e4 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -1946,17 +1946,15 @@ ath_calcrxfilter(struct ath_softc *sc) IEEE80211_IS_CHAN_ANYG(ic->ic_curchan)) rfilt |= HAL_RX_FILTER_BEACON; -#if 0 /* * Enable hardware PS-POLL RX only for hostap mode; * STA mode sends PS-POLL frames but never * receives them. */ - if (ath_hal_getcapability(ah, HAL_CAP_HAS_PSPOLL, + if (ath_hal_getcapability(sc->sc_ah, HAL_CAP_PSPOLL, 0, NULL) == HAL_OK && ic->ic_opmode == IEEE80211_M_HOSTAP) rfilt |= HAL_RX_FILTER_PSPOLL; -#endif if (sc->sc_nmeshvaps) { rfilt |= HAL_RX_FILTER_BEACON; diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 10f984757e1a..3d725fcc4f9a 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -171,6 +171,7 @@ static const struct bge_type { { BCOM_VENDORID, BCOM_DEVICEID_BCM5715S }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5717 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5718 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM5719 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5720 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5721 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5722 }, @@ -299,6 +300,7 @@ static const struct bge_revision { { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, { BGE_CHIPID_BCM5717_A0, "BCM5717 A0" }, { BGE_CHIPID_BCM5717_B0, "BCM5717 B0" }, + { BGE_CHIPID_BCM5719_A0, "BCM5719 A0" }, { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, { BGE_CHIPID_BCM5755_A1, "BCM5755 A1" }, { BGE_CHIPID_BCM5755_A2, "BCM5755 A2" }, @@ -346,6 +348,7 @@ static const struct bge_revision const bge_majorrevs[] = { { BGE_ASICREV_BCM57765, "unknown BCM57765" }, { BGE_ASICREV_BCM57780, "unknown BCM57780" }, { BGE_ASICREV_BCM5717, "unknown BCM5717" }, + { BGE_ASICREV_BCM5719, "unknown BCM5719" }, { 0, NULL } }; @@ -1481,6 +1484,14 @@ bge_chipinit(struct bge_softc *sc) dma_rw_ctl &= ~BGE_PCIDMARWCTL_DIS_CACHE_ALIGNMENT; if (sc->bge_chipid == BGE_CHIPID_BCM57765_A0) dma_rw_ctl &= ~BGE_PCIDMARWCTL_CRDRDR_RDMA_MRRS_MSK; + /* + * Enable HW workaround for controllers that misinterpret + * a status tag update and leave interrupts permanently + * disabled. + */ + if (sc->bge_asicrev != BGE_ASICREV_BCM5717 && + sc->bge_asicrev != BGE_ASICREV_BCM57765) + dma_rw_ctl |= BGE_PCIDMARWCTL_TAGGED_STATUS_WA; } pci_write_config(sc->bge_dev, BGE_PCI_DMA_RW_CTL, dma_rw_ctl, 4); @@ -1537,7 +1548,7 @@ bge_blockinit(struct bge_softc *sc) struct bge_rcb *rcb; bus_size_t vrcb; bge_hostaddr taddr; - uint32_t val; + uint32_t dmactl, val; int i, limit; /* @@ -1594,8 +1605,16 @@ bge_blockinit(struct bge_softc *sc) CSR_WRITE_4(sc, BGE_BMAN_DMA_DESCPOOL_HIWAT, 10); /* Enable buffer manager */ - CSR_WRITE_4(sc, BGE_BMAN_MODE, - BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN); + val = BGE_BMANMODE_ENABLE | BGE_BMANMODE_LOMBUF_ATTN; + /* + * Change the arbitration algorithm of TXMBUF read request to + * round-robin instead of priority based for BCM5719. When + * TXFIFO is almost empty, RDMA will hold its request until + * TXFIFO is not almost empty. + */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5719) + val |= BGE_BMANMODE_NO_TX_UNDERRUN; + CSR_WRITE_4(sc, BGE_BMAN_MODE, val); /* Poll for buffer manager start indication */ for (i = 0; i < BGE_TIMEOUT; i++) { @@ -1692,7 +1711,8 @@ bge_blockinit(struct bge_softc *sc) rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(BGE_MAX_FRAMELEN, 0); } - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM5719) rcb->bge_nicaddr = BGE_STD_RX_RINGS_5717; else rcb->bge_nicaddr = BGE_STD_RX_RINGS; @@ -1724,7 +1744,8 @@ bge_blockinit(struct bge_softc *sc) BUS_DMASYNC_PREREAD); rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, BGE_RCB_FLAG_USE_EXT_RX_BD | BGE_RCB_FLAG_RING_DISABLED); - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM5719) rcb->bge_nicaddr = BGE_JUMBO_RX_RINGS_5717; else rcb->bge_nicaddr = BGE_JUMBO_RX_RINGS; @@ -1812,7 +1833,8 @@ bge_blockinit(struct bge_softc *sc) BGE_HOSTADDR(taddr, sc->bge_ldata.bge_tx_ring_paddr); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_hi, taddr.bge_addr_hi); RCB_WRITE_4(sc, vrcb, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo); - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM5719) RCB_WRITE_4(sc, vrcb, bge_nicaddr, BGE_SEND_RING_5717); else RCB_WRITE_4(sc, vrcb, bge_nicaddr, @@ -1825,7 +1847,8 @@ bge_blockinit(struct bge_softc *sc) * 'ring diabled' bit in the flags field of all the receive * return ring control blocks, located in NIC memory. */ - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) { + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM5719) { /* Should be 17, use 16 until we get an SRAM map. */ limit = 16; } else if (!BGE_IS_5705_PLUS(sc)) @@ -2029,15 +2052,35 @@ bge_blockinit(struct bge_softc *sc) sc->bge_asicrev == BGE_ASICREV_BCM5785 || sc->bge_asicrev == BGE_ASICREV_BCM57780 || BGE_IS_5717_PLUS(sc)) { + dmactl = CSR_READ_4(sc, BGE_RDMA_RSRVCTRL); + /* + * Adjust tx margin to prevent TX data corruption and + * fix internal FIFO overflow. + */ + if (sc->bge_asicrev == BGE_ASICREV_BCM5719) { + dmactl &= ~(BGE_RDMA_RSRVCTRL_FIFO_LWM_MASK | + BGE_RDMA_RSRVCTRL_FIFO_HWM_MASK | + BGE_RDMA_RSRVCTRL_TXMRGN_MASK); + dmactl |= BGE_RDMA_RSRVCTRL_FIFO_LWM_1_5K | + BGE_RDMA_RSRVCTRL_FIFO_HWM_1_5K | + BGE_RDMA_RSRVCTRL_TXMRGN_320B; + } /* * Enable fix for read DMA FIFO overruns. * The fix is to limit the number of RX BDs * the hardware would fetch at a fime. */ - CSR_WRITE_4(sc, BGE_RDMA_RSRVCTRL, - CSR_READ_4(sc, BGE_RDMA_RSRVCTRL) | + CSR_WRITE_4(sc, BGE_RDMA_RSRVCTRL, dmactl | BGE_RDMA_RSRVCTRL_FIFO_OFLW_FIX); } + + if (sc->bge_asicrev == BGE_ASICREV_BCM5719) { + CSR_WRITE_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL, + CSR_READ_4(sc, BGE_RDMA_LSO_CRPTEN_CTRL) | + BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_BD_4K | + BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_LSO_4K); + } + CSR_WRITE_4(sc, BGE_RDMA_MODE, val); DELAY(40); @@ -2189,6 +2232,7 @@ bge_probe(device_t dev) switch (pci_get_device(dev)) { case BCOM_DEVICEID_BCM5717: case BCOM_DEVICEID_BCM5718: + case BCOM_DEVICEID_BCM5719: id = pci_read_config(dev, BGE_PCI_GEN2_PRODID_ASICREV, 4); break; @@ -2712,6 +2756,7 @@ bge_attach(device_t dev) switch (pci_get_device(dev)) { case BCOM_DEVICEID_BCM5717: case BCOM_DEVICEID_BCM5718: + case BCOM_DEVICEID_BCM5719: sc->bge_chipid = pci_read_config(dev, BGE_PCI_GEN2_PRODID_ASICREV, 4); break; @@ -2742,11 +2787,13 @@ bge_attach(device_t dev) * BCM57XX | 1 | X | X | X | * BCM5704 | 1 | X | 1 | X | * BCM5717 | 1 | 8 | 2 | 9 | + * BCM5719 | 1 | 8 | 2 | 9 | * * Other addresses may respond but they are not * IEEE compliant PHYs and should be ignored. */ - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) { + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM5719) { f = pci_get_function(dev); if (sc->bge_chipid == BGE_CHIPID_BCM5717_A0) { if (CSR_READ_4(sc, BGE_SGDIG_STS) & @@ -2754,7 +2801,7 @@ bge_attach(device_t dev) phy_addr = f + 8; else phy_addr = f + 1; - } else if (sc->bge_chipid == BGE_CHIPID_BCM5717_B0) { + } else { if (CSR_READ_4(sc, BGE_CPMU_PHY_STRAP) & BGE_CPMU_PHY_STRAP_IS_SERDES) phy_addr = f + 8; @@ -2780,11 +2827,17 @@ bge_attach(device_t dev) /* Save chipset family. */ switch (sc->bge_asicrev) { case BGE_ASICREV_BCM5717: + case BGE_ASICREV_BCM5719: sc->bge_flags |= BGE_FLAG_SHORT_DMA_BUG; case BGE_ASICREV_BCM57765: sc->bge_flags |= BGE_FLAG_5717_PLUS | BGE_FLAG_5755_PLUS | BGE_FLAG_575X_PLUS | BGE_FLAG_5705_PLUS | BGE_FLAG_JUMBO | BGE_FLAG_JUMBO_FRAME; + if (sc->bge_asicrev == BGE_ASICREV_BCM5719 && + sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { + /* Jumbo frame on BCM5719 A0 does not work. */ + sc->bge_flags &= ~BGE_FLAG_JUMBO_FRAME; + } break; case BGE_ASICREV_BCM5755: case BGE_ASICREV_BCM5761: @@ -2832,6 +2885,7 @@ bge_attach(device_t dev) if ((BGE_IS_5705_PLUS(sc)) && sc->bge_asicrev != BGE_ASICREV_BCM5906 && sc->bge_asicrev != BGE_ASICREV_BCM5717 && + sc->bge_asicrev != BGE_ASICREV_BCM5719 && sc->bge_asicrev != BGE_ASICREV_BCM5785 && sc->bge_asicrev != BGE_ASICREV_BCM57765 && sc->bge_asicrev != BGE_ASICREV_BCM57780) { @@ -2914,6 +2968,11 @@ bge_attach(device_t dev) if (BGE_IS_5717_PLUS(sc)) { /* BCM5717 requires different TSO configuration. */ sc->bge_flags |= BGE_FLAG_TSO3; + if (sc->bge_asicrev == BGE_ASICREV_BCM5719 && + sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { + /* TSO on BCM5719 A0 does not work. */ + sc->bge_flags &= ~BGE_FLAG_TSO3; + } } else if (BGE_IS_5755_PLUS(sc)) { /* * BCM5754 and BCM5787 shares the same ASIC id so @@ -2936,7 +2995,9 @@ bge_attach(device_t dev) */ sc->bge_flags |= BGE_FLAG_PCIE; sc->bge_expcap = reg; - if (pci_get_max_read_req(dev) != 4096) + if (sc->bge_asicrev == BGE_ASICREV_BCM5719) + pci_set_max_read_req(dev, 2048); + else if (pci_get_max_read_req(dev) != 4096) pci_set_max_read_req(dev, 4096); } else { /* diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h index dffec31d4900..9b830211756f 100644 --- a/sys/dev/bge/if_bgereg.h +++ b/sys/dev/bge/if_bgereg.h @@ -319,6 +319,7 @@ #define BGE_CHIPID_BCM57780_A1 0x57780001 #define BGE_CHIPID_BCM5717_A0 0x05717000 #define BGE_CHIPID_BCM5717_B0 0x05717100 +#define BGE_CHIPID_BCM5719_A0 0x05719000 #define BGE_CHIPID_BCM57765_A0 0x57785000 #define BGE_CHIPID_BCM57765_B0 0x57785100 @@ -342,6 +343,7 @@ #define BGE_ASICREV_USE_PRODID_REG 0x0f /* BGE_PCI_PRODID_ASICREV ASIC rev. identifiers. */ #define BGE_ASICREV_BCM5717 0x5717 +#define BGE_ASICREV_BCM5719 0x5719 #define BGE_ASICREV_BCM5761 0x5761 #define BGE_ASICREV_BCM5784 0x5784 #define BGE_ASICREV_BCM5785 0x5785 @@ -385,6 +387,7 @@ #define BGE_PCIDMARWCTL_RD_CMD_SHIFT(x) ((x) << 24) #define BGE_PCIDMARWCTL_WR_CMD_SHIFT(x) ((x) << 28) +#define BGE_PCIDMARWCTL_TAGGED_STATUS_WA 0x00000080 #define BGE_PCIDMARWCTL_CRDRDR_RDMA_MRRS_MSK 0x00000380 #define BGE_PCI_READ_BNDRY_DISABLE 0x00000000 @@ -1494,6 +1497,7 @@ #define BGE_BMANMODE_ATTN 0x00000004 #define BGE_BMANMODE_TESTMODE 0x00000008 #define BGE_BMANMODE_LOMBUF_ATTN 0x00000010 +#define BGE_BMANMODE_NO_TX_UNDERRUN 0x80000000 /* Buffer manager status register */ #define BGE_BMANSTAT_ERRO 0x00000004 @@ -1506,6 +1510,7 @@ #define BGE_RDMA_MODE 0x4800 #define BGE_RDMA_STATUS 0x4804 #define BGE_RDMA_RSRVCTRL 0x4900 +#define BGE_RDMA_LSO_CRPTEN_CTRL 0x4910 /* Read DMA mode register */ #define BGE_RDMAMODE_RESET 0x00000001 @@ -1540,6 +1545,15 @@ /* Read DMA Reserved Control register */ #define BGE_RDMA_RSRVCTRL_FIFO_OFLW_FIX 0x00000004 +#define BGE_RDMA_RSRVCTRL_FIFO_LWM_1_5K 0x00000C00 +#define BGE_RDMA_RSRVCTRL_FIFO_HWM_1_5K 0x000C0000 +#define BGE_RDMA_RSRVCTRL_TXMRGN_320B 0x28000000 +#define BGE_RDMA_RSRVCTRL_FIFO_LWM_MASK 0x00000FF0 +#define BGE_RDMA_RSRVCTRL_FIFO_HWM_MASK 0x000FF000 +#define BGE_RDMA_RSRVCTRL_TXMRGN_MASK 0xFFE00000 + +#define BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_BD_4K 0x00030000 +#define BGE_RDMA_LSO_CRPTEN_CTRL_BLEN_LSO_4K 0x000C0000 /* * Write DMA control registers @@ -2261,6 +2275,7 @@ struct bge_status_block { #define BCOM_DEVICEID_BCM5715S 0x1679 #define BCOM_DEVICEID_BCM5717 0x1655 #define BCOM_DEVICEID_BCM5718 0x1656 +#define BCOM_DEVICEID_BCM5719 0x1657 #define BCOM_DEVICEID_BCM5720 0x1658 #define BCOM_DEVICEID_BCM5721 0x1659 #define BCOM_DEVICEID_BCM5722 0x165A diff --git a/sys/dev/bm/if_bm.c b/sys/dev/bm/if_bm.c index 481d7cb5a900..1977f92b64a1 100644 --- a/sys/dev/bm/if_bm.c +++ b/sys/dev/bm/if_bm.c @@ -1130,21 +1130,11 @@ bm_chip_setup(struct bm_softc *sc) { uint16_t reg; uint16_t *eaddr_sect; - struct mii_data *mii; - struct mii_softc *miisc; eaddr_sect = (uint16_t *)(sc->sc_enaddr); dbdma_stop(sc->sc_txdma); dbdma_stop(sc->sc_rxdma); - /* Reset MII */ - mii = device_get_softc(sc->sc_miibus); - LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { - PHY_RESET(miisc); - PHY_WRITE(miisc, MII_BMCR, PHY_READ(miisc, MII_BMCR) & - ~BMCR_ISO); - } - /* Reset chip */ CSR_WRITE_2(sc, BM_RX_RESET, 0x0000); CSR_WRITE_2(sc, BM_TX_RESET, 0x0001); diff --git a/sys/dev/bxe/if_bxe.c b/sys/dev/bxe/if_bxe.c index 6b24dc48c2f4..cf0a40e6d888 100644 --- a/sys/dev/bxe/if_bxe.c +++ b/sys/dev/bxe/if_bxe.c @@ -1330,9 +1330,9 @@ bxe_interrupt_attach(struct bxe_softc *sc) /* Setup the slowpath deferred task queue. */ TASK_INIT(&sc->task, 0, bxe_task_sp, sc); sc->tq = taskqueue_create_fast("bxe_spq", M_NOWAIT, - taskqueue_thread_enqueue, &sc->tq); + taskqueue_thread_enqueue, &sc->tq); taskqueue_start_threads(&sc->tq, 1, PI_NET, "%s spq", - device_get_nameunit(sc->dev)); + device_get_nameunit(sc->dev)); #endif /* Setup interrupt handlers. */ @@ -1359,13 +1359,19 @@ bxe_interrupt_attach(struct bxe_softc *sc) goto bxe_interrupt_attach_exit; } +#if __FreeBSD_version >= 800504 + bus_describe_intr(sc->dev, + sc->bxe_msix_res[0], + sc->bxe_msix_tag[0], + "sp"); +#endif + /* Now initialize the fastpath vectors. */ for (i = 0; i < (sc->num_queues); i++) { fp = &sc->fp[i]; - DBPRINT(sc, - (BXE_VERBOSE_LOAD | BXE_VERBOSE_INTR), - "%s(): Enabling MSI-X[%d] vector.\n", - __FUNCTION__, i + 1); + DBPRINT(sc, (BXE_VERBOSE_LOAD | BXE_VERBOSE_INTR), + "%s(): Enabling MSI-X[%d] vector.\n", + __FUNCTION__, i + 1); /* * Setup the interrupt handler. Note that we pass the * fastpath context to the interrupt handler in this @@ -1377,8 +1383,7 @@ bxe_interrupt_attach(struct bxe_softc *sc) NULL, bxe_intr_fp, fp, - &sc->bxe_msix_tag[i + 1] - ); + &sc->bxe_msix_tag[i + 1]); if (rc) { BXE_PRINTF( @@ -1386,6 +1391,21 @@ bxe_interrupt_attach(struct bxe_softc *sc) __FILE__, __LINE__, (i + 1)); goto bxe_interrupt_attach_exit; } + +#if __FreeBSD_version >= 800504 + bus_describe_intr(sc->dev, + sc->bxe_msix_res[i + 1], + sc->bxe_msix_tag[i + 1], + "fp[%02d]", + i); +#endif + + /* Bind the fastpath instance to a CPU. */ + if (sc->num_queues > 1) { + bus_bind_intr(sc->dev, + sc->bxe_msix_res[i + 1], i); + } + #ifdef BXE_TASK TASK_INIT(&fp->task, 0, bxe_task_fp, fp); fp->tq = taskqueue_create_fast("bxe_fpq", M_NOWAIT, @@ -1418,6 +1438,13 @@ bxe_interrupt_attach(struct bxe_softc *sc) goto bxe_interrupt_attach_exit; } +#if __FreeBSD_version >= 800504 + bus_describe_intr(sc->dev, + sc->bxe_msi_res[0], + sc->bxe_msi_tag[0], + "sp"); +#endif + /* Now initialize the fastpath vectors. */ for (i = 0; i < (sc->num_queues); i++) { fp = &sc->fp[i]; @@ -1445,6 +1472,15 @@ bxe_interrupt_attach(struct bxe_softc *sc) __FILE__, __LINE__, (i + 1)); goto bxe_interrupt_attach_exit; } + +#if __FreeBSD_version >= 800504 + bus_describe_intr(sc->dev, + sc->bxe_msi_res[i + 1], + sc->bxe_msi_tag[i + 1], + "fp[%02d]", + i); +#endif + #ifdef BXE_TASK TASK_INIT(&fp->task, 0, bxe_task_fp, fp); fp->tq = taskqueue_create_fast("bxe_fpq", M_NOWAIT, @@ -3646,7 +3682,7 @@ bxe_alloc_buf_rings(struct bxe_softc *sc) if (fp != NULL) { fp->br = buf_ring_alloc(BXE_BR_SIZE, - M_DEVBUF, M_WAITOK, &fp->mtx); + M_DEVBUF, M_DONTWAIT, &fp->mtx); if (fp->br == NULL) { rc = ENOMEM; return(rc); @@ -9404,7 +9440,7 @@ bxe_tx_mq_start(struct ifnet *ifp, struct mbuf *m) /* - * Multiqueue (RSS) transmit routine. + * Multiqueue (TSS) transmit routine. * * Returns: * 0 if transmit succeeds, !0 otherwise. @@ -9415,14 +9451,18 @@ bxe_tx_mq_start_locked(struct ifnet *ifp, { struct bxe_softc *sc; struct mbuf *next; - int rc = 0, tx_count = 0; + int depth, rc = 0, tx_count = 0; sc = fp->sc; DBENTER(BXE_EXTREME_SEND); + depth = drbr_inuse(ifp, fp->br); + if (depth > fp->max_drbr_queue_depth) { + fp->max_drbr_queue_depth = depth; + } DBPRINT(sc, BXE_EXTREME_SEND, "%s(): fp[%02d], drbr queue depth=%d\n", - __FUNCTION__, fp->index, drbr_inuse(ifp, fp->br)); + __FUNCTION__, fp->index, depth); BXE_FP_LOCK_ASSERT(fp); @@ -10509,11 +10549,11 @@ bxe_alloc_mbuf(struct bxe_fastpath *fp, int size) /* Check whether the allocation succeeded and handle a failure. */ if (__predict_false(m_new == NULL)) { - DBPRINT(sc, BXE_WARN, "%s(): mbuf allocation failure!\n", - __FUNCTION__); + DBPRINT(sc, BXE_WARN, "%s(): Failed to allocate %d byte " + "mbuf on fp[%02d]!\n", __FUNCTION__, size, fp->index); fp->mbuf_alloc_failed++; - goto bxe_alloc_mbuf_exit; - } + goto bxe_alloc_mbuf_exit; + } /* Do a little extra error checking when debugging. */ DBRUN(M_ASSERTPKTHDR(m_new)); @@ -10556,7 +10596,7 @@ bxe_map_mbuf(struct bxe_fastpath *fp, struct mbuf *m, bus_dma_tag_t tag, __FUNCTION__); sc->debug_mbuf_sim_map_failed++; fp->mbuf_alloc_failed++; - DBRUN(sc->debug_memory_allocated -= m->m_len); + sc->debug_memory_allocated -= m->m_len; m_freem(m); rc = EINVAL; goto bxe_map_mbuf_exit; @@ -10568,10 +10608,11 @@ bxe_map_mbuf(struct bxe_fastpath *fp, struct mbuf *m, bus_dma_tag_t tag, /* Handle any mapping errors. */ if (__predict_false(rc)) { - DBPRINT(sc, BXE_WARN, "%s(): mbuf mapping failure (%d)!\n", - __FUNCTION__, rc); - m_freem(m); + DBPRINT(sc, BXE_WARN, "%s(): mbuf mapping failure (%d) on " + "fp[%02d]!\n", __FUNCTION__, rc, fp->index); fp->mbuf_alloc_failed++; + DBRUN(sc->debug_memory_allocated -= m->m_len); + m_freem(m); goto bxe_map_mbuf_exit; } @@ -10583,6 +10624,7 @@ bxe_map_mbuf(struct bxe_fastpath *fp, struct mbuf *m, bus_dma_tag_t tag, *seg = segs[0]; bxe_map_mbuf_exit: + DBEXIT(BXE_INSANE); return (rc); } @@ -10961,6 +11003,19 @@ bxe_init_rx_chains(struct bxe_softc *sc) } } + /* + * ToDo: Need a cleanup path if memory allocation + * fails during initializtion. This is especially + * easy if multiqueue is used on a system with + * jumbo frames and many CPUs. On my 16GB system + * with 8 CPUs I get the following defaults: + * + * kern.ipc.nmbjumbo16: 3200 + * kern.ipc.nmbjumbo9: 6400 + * kern.ipc.nmbjumbop: 12800 + * kern.ipc.nmbclusters: 25600 + */ + DBEXIT(BXE_VERBOSE_LOAD | BXE_VERBOSE_RESET); } @@ -15554,7 +15609,7 @@ bxe_txeof(struct bxe_fastpath *fp) #endif txbd = - &fp->tx_bd_chain[TX_PAGE(sw_tx_chain_cons)][TX_IDX(sw_tx_chain_cons)].start_bd; +&fp->tx_bd_chain[TX_PAGE(sw_tx_chain_cons)][TX_IDX(sw_tx_chain_cons)].start_bd; #ifdef BXE_DEBUG if (txbd == NULL) { @@ -15764,7 +15819,7 @@ bxe_change_mtu(struct bxe_softc *sc, int if_drv_running) sc->bxe_ifp->if_mtu = ifp->if_mtu; if (if_drv_running) { DBPRINT(sc, BXE_INFO_IOCTL, "%s(): Changing the MTU to %d.\n", - __FUNCTION__, sc->port.ether_mtu); + __FUNCTION__, sc->bxe_ifp->if_mtu); bxe_stop_locked(sc, UNLOAD_NORMAL); bxe_init_locked(sc, LOAD_NORMAL); @@ -16315,6 +16370,12 @@ bxe_add_sysctls(struct bxe_softc *sc) "tx_chain_lost_mbuf", CTLFLAG_RD, &fp->tx_chain_lost_mbuf, "Mbufs lost on TX chain count"); + + SYSCTL_ADD_INT(ctx, queue_list, OID_AUTO, + "max_drbr_queue_depth", + CTLFLAG_RD, &fp->max_drbr_queue_depth, + 0, "Driver queue maximum dpeth"); + #ifdef BXE_DEBUG SYSCTL_ADD_ULONG(ctx, queue_list, OID_AUTO, "null_cqe_flags", diff --git a/sys/dev/bxe/if_bxe.h b/sys/dev/bxe/if_bxe.h index 4f8528faa50b..8da3db4b0219 100644 --- a/sys/dev/bxe/if_bxe.h +++ b/sys/dev/bxe/if_bxe.h @@ -1110,6 +1110,8 @@ struct bxe_fastpath { int sge_mbuf_alloc; int tpa_mbuf_alloc; + int max_drbr_queue_depth; + uint64_t tpa_queue_used; unsigned long null_cqe_flags; @@ -1148,7 +1150,6 @@ struct bxe_fastpath { #define BXE_TX_CHAIN_PAGE_SZ BCM_PAGE_SIZE #define BXE_RX_CHAIN_PAGE_SZ BCM_PAGE_SIZE -/* ToDo: Audit this structure for unused varaibles. */ struct bxe_softc { struct ifnet *bxe_ifp; int media; diff --git a/sys/dev/mii/atphy.c b/sys/dev/mii/atphy.c index 0d80ba120e6e..b5cf14f44fa2 100644 --- a/sys/dev/mii/atphy.c +++ b/sys/dev/mii/atphy.c @@ -359,6 +359,18 @@ atphy_setmedia(struct mii_softc *sc, int media) (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0) PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX); + else if (sc->mii_mpd_model == MII_MODEL_xxATHEROS_F1) { + /* + * AR8132 has 10/100 PHY and the PHY uses the same + * model number of F1 gigabit PHY. The PHY has no + * ability to establish gigabit link so explicitly + * disable 1000baseT configuration for the PHY. + * Otherwise, there is a case that atphy(4) could + * not establish a link against gigabit link partner + * unless the link partner supports down-shifting. + */ + PHY_WRITE(sc, MII_100T2CR, 0); + } PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG); return (EJUSTRETURN); diff --git a/sys/dev/mii/mii_physubr.c b/sys/dev/mii/mii_physubr.c index b3013ba02445..be6650595cf2 100644 --- a/sys/dev/mii/mii_physubr.c +++ b/sys/dev/mii/mii_physubr.c @@ -257,7 +257,7 @@ void mii_phy_reset(struct mii_softc *sc) { struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur; - int reg, i; + int i, reg; if ((sc->mii_flags & MIIF_NOISOLATE) != 0) reg = BMCR_RESET; @@ -273,11 +273,14 @@ mii_phy_reset(struct mii_softc *sc) DELAY(1000); } - if ((sc->mii_flags & MIIF_NOISOLATE) == 0) { - if ((ife == NULL && sc->mii_inst != 0) || - (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst)) - PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); - } + /* NB: a PHY may default to isolation. */ + reg &= ~BMCR_ISO; + if ((sc->mii_flags & MIIF_NOISOLATE) == 0 && + ((ife == NULL && sc->mii_inst != 0) || + (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst))) + reg |= BMCR_ISO; + if (PHY_READ(sc, MII_BMCR) != reg) + PHY_WRITE(sc, MII_BMCR, reg); } void diff --git a/sys/dev/pci/isa_pci.c b/sys/dev/pci/isa_pci.c index 073aff7a8095..be3f3ac9393e 100644 --- a/sys/dev/pci/isa_pci.c +++ b/sys/dev/pci/isa_pci.c @@ -45,12 +45,22 @@ __FBSDID("$FreeBSD$"); #include #include -static int isab_probe(device_t dev); +#include +#include +#include + +static int isab_pci_probe(device_t dev); +static int isab_pci_attach(device_t dev); +static struct resource * isab_pci_alloc_resource(device_t dev, + device_t child, int type, int *rid, u_long start, u_long end, u_long count, + u_int flags); +static int isab_pci_release_resource(device_t dev, device_t child, + int type, int rid, struct resource *r); static device_method_t isab_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, isab_probe), - DEVMETHOD(device_attach, isab_attach), + DEVMETHOD(device_probe, isab_pci_probe), + DEVMETHOD(device_attach, isab_pci_attach), DEVMETHOD(device_detach, bus_generic_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), @@ -58,8 +68,8 @@ static device_method_t isab_methods[] = { /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_alloc_resource, isab_pci_alloc_resource), + DEVMETHOD(bus_release_resource, isab_pci_release_resource), DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), @@ -68,10 +78,19 @@ static device_method_t isab_methods[] = { { 0, 0 } }; +struct isab_pci_resource { + struct resource *ip_res; + int ip_refs; +}; + +struct isab_pci_softc { + struct isab_pci_resource isab_pci_res[PCIR_MAX_BAR_0 + 1]; +}; + static driver_t isab_driver = { "isab", isab_methods, - 0, + sizeof(struct isab_pci_softc), }; DRIVER_MODULE(isab, pci, isab_driver, isab_devclass, 0, 0); @@ -81,7 +100,7 @@ DRIVER_MODULE(isab, pci, isab_driver, isab_devclass, 0, 0); * report themselves. */ static int -isab_probe(device_t dev) +isab_pci_probe(device_t dev) { int matched = 0; @@ -139,3 +158,88 @@ isab_probe(device_t dev) } return(ENXIO); } + +static int +isab_pci_attach(device_t dev) +{ + + bus_generic_probe(dev); + return (isab_attach(dev)); +} + +static struct resource * +isab_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, + u_long start, u_long end, u_long count, u_int flags) +{ + struct isab_pci_softc *sc; + int bar; + + if (device_get_parent(child) != dev) + return bus_generic_alloc_resource(dev, child, type, rid, start, + end, count, flags); + + switch (type) { + case SYS_RES_MEMORY: + case SYS_RES_IOPORT: + /* + * For BARs, we cache the resource so that we only allocate it + * from the PCI bus once. + */ + bar = PCI_RID2BAR(*rid); + if (bar < 0 || bar > PCIR_MAX_BAR_0) + return (NULL); + sc = device_get_softc(dev); + if (sc->isab_pci_res[bar].ip_res == NULL) + sc->isab_pci_res[bar].ip_res = bus_alloc_resource(dev, type, + rid, start, end, count, flags); + if (sc->isab_pci_res[bar].ip_res != NULL) + sc->isab_pci_res[bar].ip_refs++; + return (sc->isab_pci_res[bar].ip_res); + } + + return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, type, rid, + start, end, count, flags)); +} + +static int +isab_pci_release_resource(device_t dev, device_t child, int type, int rid, + struct resource *r) +{ + struct isab_pci_softc *sc; + int bar, error; + + if (device_get_parent(child) != dev) + return bus_generic_release_resource(dev, child, type, rid, r); + + switch (type) { + case SYS_RES_MEMORY: + case SYS_RES_IOPORT: + /* + * For BARs, we release the resource from the PCI bus + * when the last child reference goes away. + */ + bar = PCI_RID2BAR(rid); + if (bar < 0 || bar > PCIR_MAX_BAR_0) + return (EINVAL); + sc = device_get_softc(dev); + if (sc->isab_pci_res[bar].ip_res == NULL) + return (EINVAL); + KASSERT(sc->isab_pci_res[bar].ip_res == r, + ("isa_pci resource mismatch")); + if (sc->isab_pci_res[bar].ip_refs > 1) { + sc->isab_pci_res[bar].ip_refs--; + return (0); + } + KASSERT(sc->isab_pci_res[bar].ip_refs > 0, + ("isa_pci resource reference count underflow")); + error = bus_release_resource(dev, type, rid, r); + if (error == 0) { + sc->isab_pci_res[bar].ip_res = NULL; + sc->isab_pci_res[bar].ip_refs = 0; + } + return (error); + } + + return (BUS_RELEASE_RESOURCE(device_get_parent(dev), child, type, + rid, r)); +} diff --git a/sys/dev/xen/balloon/balloon.c b/sys/dev/xen/balloon/balloon.c index dff80ba3e8f1..81d1094e180c 100644 --- a/sys/dev/xen/balloon/balloon.c +++ b/sys/dev/xen/balloon/balloon.c @@ -147,12 +147,6 @@ balloon_retrieve(void) return page; } -static void -balloon_alarm(void *unused) -{ - wakeup(balloon_process); -} - static unsigned long current_target(void) { @@ -378,6 +372,8 @@ balloon_process(void *unused) mtx_lock(&balloon_mutex); for (;;) { + int sleep_time; + do { credit = current_target() - bs.current_pages; if (credit > 0) @@ -389,9 +385,12 @@ balloon_process(void *unused) /* Schedule more work if there is some still to be done. */ if (current_target() != bs.current_pages) - timeout(balloon_alarm, NULL, ticks + hz); + sleep_time = hz; + else + sleep_time = 0; - msleep(balloon_process, &balloon_mutex, 0, "balloon", -1); + msleep(balloon_process, &balloon_mutex, 0, "balloon", + sleep_time); } mtx_unlock(&balloon_mutex); } @@ -474,9 +473,6 @@ balloon_init(void *arg) bs.hard_limit = ~0UL; kproc_create(balloon_process, NULL, NULL, 0, 0, "balloon"); -// init_timer(&balloon_timer); -// balloon_timer.data = 0; -// balloon_timer.function = balloon_alarm; #ifndef XENHVM /* Initialise the balloon with excess memory space. */ diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 265a5c42a1f6..fbf444a3eb4a 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1351,7 +1351,9 @@ void (*cpu_idle_fn)(int) = cpu_idle_acpi; void cpu_idle(int busy) { +#ifndef XEN uint64_t msr; +#endif CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); @@ -1367,34 +1369,32 @@ cpu_idle(int busy) goto out; } } +#endif /* If we have time - switch timers into idle mode. */ if (!busy) { critical_enter(); cpu_idleclock(); } -#endif - /* Apply AMD APIC timer C1E workaround. */ - if (cpu_ident_amdc1e #ifndef XEN - && cpu_disable_deep_sleep -#endif - ) { + /* Apply AMD APIC timer C1E workaround. */ + if (cpu_ident_amdc1e && cpu_disable_deep_sleep) { msr = rdmsr(MSR_AMDK8_IPM); if (msr & AMDK8_CMPHALT) wrmsr(MSR_AMDK8_IPM, msr & ~AMDK8_CMPHALT); } +#endif /* Call main idle method. */ cpu_idle_fn(busy); -#ifndef XEN /* Switch timers mack into active mode. */ if (!busy) { cpu_activeclock(); critical_exit(); } +#ifndef XEN out: #endif CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done", diff --git a/sys/i386/xen/clock.c b/sys/i386/xen/clock.c index 091c8c79e108..f5965bf4f913 100644 --- a/sys/i386/xen/clock.c +++ b/sys/i386/xen/clock.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -301,38 +302,44 @@ static struct timecounter xen_timecounter = { 0 /* quality */ }; +static struct eventtimer xen_et; + +struct xen_et_state { + int mode; +#define MODE_STOP 0 +#define MODE_PERIODIC 1 +#define MODE_ONESHOT 2 + int64_t period; + int64_t next; +}; + +static DPCPU_DEFINE(struct xen_et_state, et_state); + static int clkintr(void *arg) { - int64_t delta_cpu, delta; - struct trapframe *frame = (struct trapframe *)arg; + int64_t now; int cpu = smp_processor_id(); struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu); + struct xen_et_state *state = DPCPU_PTR(et_state); do { __get_time_values_from_xen(); - - delta = delta_cpu = - shadow->system_timestamp + get_nsec_offset(shadow); - delta -= processed_system_time; - delta_cpu -= per_cpu(processed_system_time, cpu); - + now = shadow->system_timestamp + get_nsec_offset(shadow); } while (!time_values_up_to_date(cpu)); - - if (unlikely(delta < (int64_t)0) || unlikely(delta_cpu < (int64_t)0)) { - printf("Timer ISR: Time went backwards: %lld\n", delta); - return (FILTER_HANDLED); - } - + /* Process elapsed ticks since last call. */ - while (delta >= NS_PER_TICK) { - delta -= NS_PER_TICK; - processed_system_time += NS_PER_TICK; - per_cpu(processed_system_time, cpu) += NS_PER_TICK; - if (PCPU_GET(cpuid) == 0) - hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); - else - hardclock_cpu(TRAPF_USERMODE(frame)); + processed_system_time = now; + if (state->mode == MODE_PERIODIC) { + while (now >= state->next) { + state->next += state->period; + if (xen_et.et_active) + xen_et.et_event_cb(&xen_et, xen_et.et_arg); + } + HYPERVISOR_set_timer_op(state->next + 50000); + } else if (state->mode == MODE_ONESHOT) { + if (xen_et.et_active) + xen_et.et_event_cb(&xen_et, xen_et.et_arg); } /* * Take synchronised time from Xen once a minute if we're not @@ -484,12 +491,14 @@ DELAY(int n) void timer_restore(void) { + struct xen_et_state *state = DPCPU_PTR(et_state); + /* Get timebases for new environment. */ __get_time_values_from_xen(); /* Reset our own concept of passage of system time. */ processed_system_time = per_cpu(shadow_time, 0).system_timestamp; - per_cpu(processed_system_time, 0) = processed_system_time; + state->next = processed_system_time; } void @@ -503,7 +512,6 @@ startrtclock() /* initialize xen values */ __get_time_values_from_xen(); processed_system_time = per_cpu(shadow_time, 0).system_timestamp; - per_cpu(processed_system_time, 0) = processed_system_time; __cpu_khz = 1000000ULL << 32; info = &HYPERVISOR_shared_info->vcpu_info[0].time; @@ -759,7 +767,49 @@ resettodr() } #endif -static struct vcpu_set_periodic_timer xen_set_periodic_tick; +static int +xen_et_start(struct eventtimer *et, + struct bintime *first, struct bintime *period) +{ + struct xen_et_state *state = DPCPU_PTR(et_state); + struct shadow_time_info *shadow; + int64_t fperiod; + + __get_time_values_from_xen(); + + if (period != NULL) { + state->mode = MODE_PERIODIC; + state->period = (1000000000LL * + (uint32_t)(period->frac >> 32)) >> 32; + if (period->sec != 0) + state->period += 1000000000LL * period->sec; + } else { + state->mode = MODE_ONESHOT; + state->period = 0; + } + if (first != NULL) { + fperiod = (1000000000LL * (uint32_t)(first->frac >> 32)) >> 32; + if (first->sec != 0) + fperiod += 1000000000LL * first->sec; + } else + fperiod = state->period; + + shadow = &per_cpu(shadow_time, smp_processor_id()); + state->next = shadow->system_timestamp + get_nsec_offset(shadow); + state->next += fperiod; + HYPERVISOR_set_timer_op(state->next + 50000); + return (0); +} + +static int +xen_et_stop(struct eventtimer *et) +{ + struct xen_et_state *state = DPCPU_PTR(et_state); + + state->mode = MODE_STOP; + HYPERVISOR_set_timer_op(0); + return (0); +} /* * Start clocks running. @@ -770,56 +820,48 @@ cpu_initclocks(void) unsigned int time_irq; int error; - xen_set_periodic_tick.period_ns = NS_PER_TICK; - - HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, 0, - &xen_set_periodic_tick); - - error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", - clkintr, NULL, NULL, - INTR_TYPE_CLK, &time_irq); + HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, 0, NULL); + error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "cpu0:timer", + clkintr, NULL, NULL, INTR_TYPE_CLK, &time_irq); if (error) panic("failed to register clock interrupt\n"); /* should fast clock be enabled ? */ - + + bzero(&xen_et, sizeof(xen_et)); + xen_et.et_name = "ixen"; + xen_et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | + ET_FLAGS_PERCPU; + xen_et.et_quality = 600; + xen_et.et_frequency = 0; + xen_et.et_min_period.sec = 0; + xen_et.et_min_period.frac = 0x00400000LL << 32; + xen_et.et_max_period.sec = 2; + xen_et.et_max_period.frac = 0; + xen_et.et_start = xen_et_start; + xen_et.et_stop = xen_et_stop; + xen_et.et_priv = NULL; + et_register(&xen_et); + + cpu_initclocks_bsp(); } int ap_cpu_initclocks(int cpu) { + char buf[MAXCOMLEN + 1]; unsigned int time_irq; int error; - xen_set_periodic_tick.period_ns = NS_PER_TICK; - - HYPERVISOR_vcpu_op(VCPUOP_set_periodic_timer, cpu, - &xen_set_periodic_tick); - error = bind_virq_to_irqhandler(VIRQ_TIMER, 0, "clk", - clkintr, NULL, NULL, - INTR_TYPE_CLK, &time_irq); + HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL); + snprintf(buf, sizeof(buf), "cpu%d:timer", cpu); + error = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, buf, + clkintr, NULL, NULL, INTR_TYPE_CLK, &time_irq); if (error) panic("failed to register clock interrupt\n"); - return (0); } - -void -cpu_startprofclock(void) -{ - - printf("cpu_startprofclock: profiling clock is not supported\n"); -} - -void -cpu_stopprofclock(void) -{ - - printf("cpu_stopprofclock: profiling clock is not supported\n"); -} -#define NSEC_PER_USEC 1000 - static uint32_t xen_get_timecount(struct timecounter *tc) { @@ -842,45 +884,11 @@ get_system_time(int ticks) return processed_system_time + (ticks * NS_PER_TICK); } -/* - * Track behavior of cur_timer->get_offset() functionality in timer_tsc.c - */ - - -/* Convert jiffies to system time. */ -static uint64_t -ticks_to_system_time(int newticks) -{ - int delta; - uint64_t st; - - delta = newticks - ticks; - if (delta < 1) { - /* Triggers in some wrap-around cases, - * but that's okay: - * we just end up with a shorter timeout. */ - st = processed_system_time + NS_PER_TICK; - } else if (((unsigned int)delta >> (BITS_PER_LONG-3)) != 0) { - /* Very long timeout means there is no pending timer. - * We indicate this to Xen by passing zero timeout. */ - st = 0; - } else { - st = processed_system_time + delta * (uint64_t)NS_PER_TICK; - } - - return (st); -} - void idle_block(void) { - uint64_t timeout; - timeout = ticks_to_system_time(ticks + 1) + NS_PER_TICK/2; - - __get_time_values_from_xen(); - PANIC_IF(HYPERVISOR_set_timer_op(timeout) != 0); - HYPERVISOR_sched_op(SCHEDOP_block, 0); + HYPERVISOR_sched_op(SCHEDOP_block, 0); } int @@ -903,6 +911,3 @@ timer_spkr_setfreq(int freq) } - - - diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 1146ac2351e6..1565859cf0b5 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -625,8 +625,11 @@ init_secondary(void) while (smp_started == 0) ia32_pause(); - PCPU_SET(curthread, PCPU_GET(idlethread)); + + /* Start per-CPU event timers. */ + cpu_initclocks_ap(); + /* enter the scheduler */ sched_throw(NULL); diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index d55d85c8431a..604bd2d056f2 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -31,9 +31,6 @@ __FBSDID("$FreeBSD$"); * Common routines to manage event timers hardware. */ -/* XEN has own timer routines now. */ -#ifndef XEN - #include "opt_device_polling.h" #include "opt_kdtrace.h" @@ -899,5 +896,3 @@ sysctl_kern_eventtimer_periodic(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_kern_eventtimer, OID_AUTO, periodic, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_eventtimer_periodic, "I", "Enable event timer periodic mode"); - -#endif diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index a3e920d043f2..d3aef7648d55 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -551,7 +551,7 @@ maybe_yield(void) { if (should_yield()) - kern_yield(curthread->td_user_pri); + kern_yield(PRI_USER); } void @@ -562,6 +562,8 @@ kern_yield(int prio) td = curthread; DROP_GIANT(); thread_lock(td); + if (prio == PRI_USER) + prio = td->td_user_pri; if (prio >= 0) sched_prio(td, prio); mi_switch(SW_VOL | SWT_RELINQUISH, NULL); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 0f1e35786c9d..8d2fddec6b0f 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1590,7 +1590,7 @@ userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, SYSCTL_XUNLOCK(); if (error != EAGAIN) break; - kern_yield(curthread->td_user_pri); + kern_yield(PRI_USER); } CURVNET_RESTORE(); diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 06e86254046f..0b5e973bc734 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2234,7 +2234,7 @@ buf_daemon() while (numdirtybuffers > lodirtybuffers) { if (buf_do_flush(NULL) == 0) break; - kern_yield(-1); + kern_yield(PRI_UNCHANGED); } lodirtybuffers = lodirtysave; diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 7bdb29cf8b67..2e07cf1c7859 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1644,7 +1644,7 @@ __mnt_vnode_next(struct vnode **mvp, struct mount *mp) KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch")); if (should_yield()) { MNT_IUNLOCK(mp); - kern_yield(-1); + kern_yield(PRI_UNCHANGED); MNT_ILOCK(mp); } vp = TAILQ_NEXT(*mvp, v_nmntvnodes); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index dead54648dc9..741061d639ef 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -718,7 +718,7 @@ vlrureclaim(struct mount *mp) continue; MNT_IUNLOCK(mp); yield: - kern_yield(-1); + kern_yield(PRI_UNCHANGED); relock_mnt: MNT_ILOCK(mp); } @@ -831,7 +831,7 @@ vnlru_proc(void) vnlru_nowhere++; tsleep(vnlruproc, PPAUSE, "vlrup", hz * 3); } else - kern_yield(-1); + kern_yield(PRI_UNCHANGED); } } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7b5cad1f04fd..e8bcc91cb969 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -491,7 +491,7 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred, break; offset += chunk; base = (char *)base + chunk; - kern_yield(curthread->td_user_pri); + kern_yield(PRI_USER); } while (len); if (aresid) *aresid = len + iaresid; diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index f4ac4a25802a..f75e7dfa9f01 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -625,6 +625,6 @@ vop_vptocnp { vop_allocate { IN struct vnode *vp; - IN off_t *offset; - IN off_t *len; + INOUT off_t *offset; + INOUT off_t *len; }; diff --git a/sys/sys/priority.h b/sys/sys/priority.h index 8ada2db11e20..6548a35c9526 100644 --- a/sys/sys/priority.h +++ b/sys/sys/priority.h @@ -117,6 +117,12 @@ #define PRI_MIN_IDLE (224) #define PRI_MAX_IDLE (PRI_MAX) +#ifdef _KERNEL +/* Other arguments for kern_yield(9). */ +#define PRI_USER -2 /* Change to current user priority. */ +#define PRI_UNCHANGED -1 /* Do not change priority. */ +#endif + struct priority { u_char pri_class; /* Scheduling class. */ u_char pri_level; /* Normal priority level. */ diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index a6d444158b15..a7ae484fcb1a 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1412,7 +1412,7 @@ softdep_process_worklist(mp, full) */ if (should_yield()) { FREE_LOCK(&lk); - kern_yield(-1); + kern_yield(PRI_UNCHANGED); bwillwrite(); ACQUIRE_LOCK(&lk); } diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 9d057e516769..531eef23c445 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -452,7 +453,7 @@ print_vnode_info(struct procstat *procstat, struct filestat *fst) else { strmode(vn.vn_mode, mode); } - (void)printf(" %6ld %10s", vn.vn_fileid, mode); + (void)printf(" %6jd %10s", (intmax_t)vn.vn_fileid, mode); if (vn.vn_type == PS_FST_VTYPE_VBLK || vn.vn_type == PS_FST_VTYPE_VCHR) { if (nflg || !*vn.vn_devname) @@ -461,7 +462,7 @@ print_vnode_info(struct procstat *procstat, struct filestat *fst) printf(" %6s", vn.vn_devname); } } else - printf(" %6lu", vn.vn_size); + printf(" %6ju", (uintmax_t)vn.vn_size); print_access_flags(fst->fs_fflags); } diff --git a/usr.bin/mkuzip/mkuzip.c b/usr.bin/mkuzip/mkuzip.c index 02ebefa8094f..08c8ed0beab5 100644 --- a/usr.bin/mkuzip/mkuzip.c +++ b/usr.bin/mkuzip/mkuzip.c @@ -31,7 +31,7 @@ #define CLOOP_MAGIC_LEN 128 static char CLOOP_MAGIC_START[] = "#!/bin/sh\n#V2.0 Format\n" - "m=geom_uzip\n(kldstat -m $m 2>&-||kldload $m)>&-&&" + "(kldstat -qm g_uzip||kldload geom_uzip)>&-&&" "mount_cd9660 /dev/`mdconfig -af $0`.uzip $1\nexit $?\n"; static char *readblock(int, char *, u_int32_t); From f85a68226d2be0976168e6991b49816dba73e975 Mon Sep 17 00:00:00 2001 From: marius Date: Fri, 13 May 2011 15:21:31 +0000 Subject: [PATCH 042/164] When setting up pc_other_cpus for APs based on pc_allcpu clear pc_cpuid in the former rather than the latter. This gets this branch working on at least Jalapeno-class CPUs. --- sys/sparc64/sparc64/mp_machdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 59deb9de857e..a314eb04c77e 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -470,7 +470,7 @@ cpu_mp_bootstrap(struct pcpu *pc) smp_cpus++; KASSERT(curthread != NULL, ("%s: curthread", __func__)); ocpus = all_cpus; - CPU_CLR(curcpu, &all_cpus); + CPU_CLR(curcpu, &ocpus); PCPU_SET(other_cpus, ocpus); printf("SMP: AP CPU #%d Launched!\n", curcpu); From a0db972f622c3a9dd2d45cdd27cc47dd31961dbb Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 16:39:47 +0000 Subject: [PATCH 043/164] Fix the _long() rappresentation on mips by casting the long arguments to u_int for all the functions. Reviewed by: art, imp --- sys/mips/include/atomic.h | 61 ++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/sys/mips/include/atomic.h b/sys/mips/include/atomic.h index 7b4a82cb06a9..9a0c557ee08c 100644 --- a/sys/mips/include/atomic.h +++ b/sys/mips/include/atomic.h @@ -581,32 +581,47 @@ atomic_fetchadd_64(__volatile uint64_t *p, uint64_t v) #else /* !__mips_n64 */ /* Operations on longs. */ -#define atomic_set_long atomic_set_32 -#define atomic_set_acq_long atomic_set_acq_32 -#define atomic_set_rel_long atomic_set_rel_32 -#define atomic_clear_long atomic_clear_32 -#define atomic_clear_acq_long atomic_clear_acq_32 -#define atomic_clear_rel_long atomic_clear_rel_32 -#define atomic_add_long(p, v) \ +#define atomic_set_long(p, v) \ + atomic_set_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_acq_long(p, v) \ + atomic_set_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_set_rel_long(p, v) \ + atomic_set_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_long(p, v) \ + atomic_clear_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_acq_long(p, v) \ + atomic_clear_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_clear_rel_long(p, v) \ + atomic_clear_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_long(p, v) \ atomic_add_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_add_acq_long atomic_add_acq_32 -#define atomic_add_rel_long atomic_add_rel_32 -#define atomic_subtract_long(p, v) \ +#define atomic_add_acq_long(p, v) \ + atomic_add_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_add_rel_long(p, v) \ + atomic_add_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_long(p, v) \ atomic_subtract_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_subtract_acq_long atomic_subtract_acq_32 -#define atomic_subtract_rel_long atomic_subtract_rel_32 -#define atomic_cmpset_long atomic_cmpset_32 -#define atomic_cmpset_acq_long(p, cmpval, newval) \ - atomic_cmpset_acq_32((volatile u_int *)(p), \ - (u_int)(cmpval), (u_int)(newval)) -#define atomic_cmpset_rel_long(p, cmpval, newval) \ - atomic_cmpset_rel_32((volatile u_int *)(p), \ - (u_int)(cmpval), (u_int)(newval)) -#define atomic_load_acq_long atomic_load_acq_32 -#define atomic_store_rel_long atomic_store_rel_32 -#define atomic_fetchadd_long(p, v) \ +#define atomic_subtract_acq_long(p, v) \ + atomic_subtract_acq_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_subtract_rel_long(p, v) \ + atomic_subtract_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_cmpset_long(p, cmpval, newval) \ + atomic_cmpset_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_cmpset_acq_long(p, cmpval, newval) \ + atomic_cmpset_acq_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_cmpset_rel_long(p, cmpval, newval) \ + atomic_cmpset_rel_32((volatile u_int *)(p), (u_int)(cmpval), \ + (u_int)(newval)) +#define atomic_load_acq_long(p) \ + (u_long)atomic_load_acq_32((volatile u_int *)(p)) +#define atomic_store_rel_long(p, v) \ + atomic_store_rel_32((volatile u_int *)(p), (u_int)(v)) +#define atomic_fetchadd_long(p, v) \ atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v)) -#define atomic_readandclear_long atomic_readandclear_32 +#define atomic_readandclear_long(p) \ + atomic_readandclear_32((volatile u_int *)(p)) #endif /* __mips_n64 */ From dcae8c96267648ce6ae3191f642d5ddd62d0b319 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 16:42:05 +0000 Subject: [PATCH 044/164] Add the cpuset_t conversion for mips. --- sys/mips/cavium/octeon_mp.c | 14 ++++++++-- sys/mips/include/_types.h | 1 - sys/mips/include/hwfunc.h | 4 ++- sys/mips/include/pmap.h | 3 +- sys/mips/include/smp.h | 4 ++- sys/mips/mips/mp_machdep.c | 55 +++++++++++++++++++++++-------------- sys/mips/mips/pmap.c | 36 ++++++++++++++++-------- sys/mips/rmi/xlr_machdep.c | 10 +++++-- sys/mips/sibyte/sb_scd.c | 11 ++++++-- 9 files changed, 96 insertions(+), 42 deletions(-) diff --git a/sys/mips/cavium/octeon_mp.c b/sys/mips/cavium/octeon_mp.c index 78eafa678118..5e494b895c96 100644 --- a/sys/mips/cavium/octeon_mp.c +++ b/sys/mips/cavium/octeon_mp.c @@ -102,10 +102,20 @@ platform_init_ap(int cpuid) mips_wbflush(); } -cpumask_t +cpuset_t platform_cpu_mask(void) { - return (octeon_bootinfo->core_mask); + cpuset_t cpumask; + + CPU_ZERO(&cpumask); + + /* + * XXX: hack in order to simplify CPU set building, assuming that + * core_mask is 32-bits. + */ + memcpy(&cpumask, &octeon_bootinfo->core_mask, + sizeof(octeon_bootinfo->core_mask)); + return (cpumask); } struct cpu_group * diff --git a/sys/mips/include/_types.h b/sys/mips/include/_types.h index 4d57e20db108..2f23db6d9b3a 100644 --- a/sys/mips/include/_types.h +++ b/sys/mips/include/_types.h @@ -73,7 +73,6 @@ typedef unsigned long long __uint64_t; * Standard type definitions. */ typedef __int32_t __clock_t; /* clock()... */ -typedef unsigned int __cpumask_t; typedef double __double_t; typedef double __float_t; #ifdef __mips_n64 diff --git a/sys/mips/include/hwfunc.h b/sys/mips/include/hwfunc.h index 683aedb0c9ac..4e6ddf548b4c 100644 --- a/sys/mips/include/hwfunc.h +++ b/sys/mips/include/hwfunc.h @@ -28,6 +28,8 @@ #ifndef _MACHINE_HWFUNC_H_ #define _MACHINE_HWFUNC_H_ +#include + struct trapframe; struct timecounter; /* @@ -91,7 +93,7 @@ extern int platform_processor_id(void); /* * Return the cpumask of available processors. */ -extern cpumask_t platform_cpu_mask(void); +extern cpuset_t platform_cpu_mask(void); /* * Return the topology of processors on this platform diff --git a/sys/mips/include/pmap.h b/sys/mips/include/pmap.h index e71063592a80..90375ebd3448 100644 --- a/sys/mips/include/pmap.h +++ b/sys/mips/include/pmap.h @@ -58,6 +58,7 @@ #ifndef LOCORE #include +#include #include #include @@ -83,7 +84,7 @@ struct pmap { pd_entry_t *pm_segtab; /* KVA of segment table */ TAILQ_HEAD(, pv_entry) pm_pvlist; /* list of mappings in * pmap */ - cpumask_t pm_active; /* active on cpus */ + cpuset_t pm_active; /* active on cpus */ struct { u_int32_t asid:ASID_BITS; /* TLB address space tag */ u_int32_t gen:ASIDGEN_BITS; /* its generation number */ diff --git a/sys/mips/include/smp.h b/sys/mips/include/smp.h index 58aaf03165bf..0fcca9af1542 100644 --- a/sys/mips/include/smp.h +++ b/sys/mips/include/smp.h @@ -17,6 +17,8 @@ #ifdef _KERNEL +#include + #include /* @@ -33,7 +35,7 @@ void ipi_all_but_self(int ipi); void ipi_cpu(int cpu, u_int ipi); -void ipi_selected(cpumask_t cpus, int ipi); +void ipi_selected(cpuset_t cpus, int ipi); void smp_init_secondary(u_int32_t cpuid); void mpentry(void); diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index e94573674c05..eb36d6fef653 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -80,15 +81,16 @@ ipi_all_but_self(int ipi) /* Send an IPI to a set of cpus. */ void -ipi_selected(cpumask_t cpus, int ipi) +ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; - CTR3(KTR_SMP, "%s: cpus: %x, ipi: %x\n", __func__, cpus, ipi); - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { - if ((cpus & pc->pc_cpumask) != 0) + if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) { + CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc, + ipi); ipi_send(pc, ipi); + } } } @@ -108,7 +110,7 @@ static int mips_ipi_handler(void *arg) { int cpu; - cpumask_t cpumask; + cpuset_t cpumask; u_int ipi, ipi_bitmap; int bit; @@ -148,14 +150,14 @@ mips_ipi_handler(void *arg) tlb_save(); /* Indicate we are stopped */ - atomic_set_int(&stopped_cpus, cpumask); + CPU_OR_ATOMIC(&stopped_cpus, &cpumask); /* Wait for restart */ - while ((started_cpus & cpumask) == 0) + while (!CPU_OVERLAP(&started_cpus, &cpumask)) cpu_spinwait(); - atomic_clear_int(&started_cpus, cpumask); - atomic_clear_int(&stopped_cpus, cpumask); + CPU_NAND_ATOMIC(&started_cpus, &cpumask); + CPU_NAND_ATOMIC(&stopped_cpus, &cpumask); CTR0(KTR_SMP, "IPI_STOP (restart)"); break; case IPI_PREEMPT: @@ -200,14 +202,21 @@ start_ap(int cpuid) void cpu_mp_setmaxid(void) { - cpumask_t cpumask; + cpuset_t cpumask; + int cpu, last; cpumask = platform_cpu_mask(); - mp_ncpus = bitcount32(cpumask); + mp_ncpus = 0; + last = 1; + while ((cpu = cpusetobj_ffs(&cpumask)) != 0) { + last = cpu; + mp_ncpus++; + CPU_CLR(cpu, &cpumask); + } if (mp_ncpus <= 0) mp_ncpus = 1; - mp_maxid = min(fls(cpumask), MAXCPU) - 1; + mp_maxid = min(last, MAXCPU) - 1; } void @@ -233,16 +242,16 @@ void cpu_mp_start(void) { int error, cpuid; - cpumask_t cpumask; + cpuset_t cpumask, ocpus; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); - all_cpus = 0; + CPU_ZERO(&all_cpus); cpumask = platform_cpu_mask(); - while (cpumask != 0) { - cpuid = ffs(cpumask) - 1; - cpumask &= ~(1 << cpuid); + while (!CPU_EMPTY(&cpumask)) { + cpuid = cpusetobj_ffs(&cpumask) - 1; + CPU_CLR(cpuid, &cpumask); if (cpuid >= MAXCPU) { printf("cpu_mp_start: ignoring AP #%d.\n", cpuid); @@ -257,15 +266,19 @@ cpu_mp_start(void) if (bootverbose) printf("AP #%d started!\n", cpuid); } - all_cpus |= 1 << cpuid; + CPU_SET(cpuid, &all_cpus); } - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + ocpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &ocpus); + PCPU_SET(other_cpus, ocpus); } void smp_init_secondary(u_int32_t cpuid) { + cpuset_t ocpus; + /* TLB */ mips_wr_wired(0); tlb_invalidate_all(); @@ -303,7 +316,9 @@ smp_init_secondary(u_int32_t cpuid) CTR1(KTR_SMP, "SMP: AP CPU #%d launched", PCPU_GET(cpuid)); /* Build our map of 'other' CPUs. */ - PCPU_SET(other_cpus, all_cpus & ~PCPU_GET(cpumask)); + ocpus = all_cpus; + CPU_CLR(PCPU_GET(cpuid), &ocpus); + PCPU_SET(other_cpus, ocpus); if (bootverbose) printf("SMP: AP CPU #%d launched.\n", PCPU_GET(cpuid)); diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c index 7f0f4f004c80..f7ea660d019c 100644 --- a/sys/mips/mips/pmap.c +++ b/sys/mips/mips/pmap.c @@ -471,7 +471,7 @@ pmap_create_kernel_pagetable(void) PMAP_LOCK_INIT(kernel_pmap); kernel_pmap->pm_segtab = kernel_segmap; - kernel_pmap->pm_active = ~0; + CPU_FILL(&kernel_pmap->pm_active); TAILQ_INIT(&kernel_pmap->pm_pvlist); kernel_pmap->pm_asid[0].asid = PMAP_ASID_RESERVED; kernel_pmap->pm_asid[0].gen = 0; @@ -630,10 +630,14 @@ pmap_invalidate_all_local(pmap_t pmap) tlb_invalidate_all(); return; } - if (pmap->pm_active & PCPU_GET(cpumask)) + sched_pin(); + if (CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) { + sched_unpin(); tlb_invalidate_all_user(pmap); - else + } else { + sched_unpin(); pmap->pm_asid[PCPU_GET(cpuid)].gen = 0; + } } #ifdef SMP @@ -667,12 +671,16 @@ pmap_invalidate_page_local(pmap_t pmap, vm_offset_t va) tlb_invalidate_address(pmap, va); return; } - if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) + sched_pin(); + if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) { + sched_unpin(); return; - else if (!(pmap->pm_active & PCPU_GET(cpumask))) { + } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) { pmap->pm_asid[PCPU_GET(cpuid)].gen = 0; + sched_unpin(); return; } + sched_unpin(); tlb_invalidate_address(pmap, va); } @@ -716,12 +724,16 @@ pmap_update_page_local(pmap_t pmap, vm_offset_t va, pt_entry_t pte) tlb_update(pmap, va, pte); return; } - if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) + sched_pin(); + if (pmap->pm_asid[PCPU_GET(cpuid)].gen != PCPU_GET(asid_generation)) { + sched_unpin(); return; - else if (!(pmap->pm_active & PCPU_GET(cpumask))) { + } else if (!CPU_OVERLAP(&pmap->pm_active, PCPU_PTR(cpumask))) { pmap->pm_asid[PCPU_GET(cpuid)].gen = 0; + sched_unpin(); return; } + sched_unpin(); tlb_update(pmap, va, pte); } @@ -1041,7 +1053,7 @@ pmap_pinit0(pmap_t pmap) PMAP_LOCK_INIT(pmap); pmap->pm_segtab = kernel_segmap; - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); pmap->pm_ptphint = NULL; for (i = 0; i < MAXCPU; i++) { pmap->pm_asid[i].asid = PMAP_ASID_RESERVED; @@ -1102,7 +1114,7 @@ pmap_pinit(pmap_t pmap) ptdva = MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(ptdpg)); pmap->pm_segtab = (pd_entry_t *)ptdva; - pmap->pm_active = 0; + CPU_ZERO(&pmap->pm_active); pmap->pm_ptphint = NULL; for (i = 0; i < MAXCPU; i++) { pmap->pm_asid[i].asid = PMAP_ASID_RESERVED; @@ -2948,8 +2960,8 @@ pmap_activate(struct thread *td) oldpmap = PCPU_GET(curpmap); if (oldpmap) - atomic_clear_32(&oldpmap->pm_active, PCPU_GET(cpumask)); - atomic_set_32(&pmap->pm_active, PCPU_GET(cpumask)); + CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask)); + CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask)); pmap_asid_alloc(pmap); if (td == curthread) { PCPU_SET(segbase, pmap->pm_segtab); @@ -3283,7 +3295,7 @@ pmap_kextract(vm_offset_t va) pt_entry_t *ptep; /* Is the kernel pmap initialized? */ - if (kernel_pmap->pm_active) { + if (!CPU_EMPTY(&kernel_pmap->pm_active)) { /* It's inside the virtual address range */ ptep = pmap_pte(kernel_pmap, va); if (ptep) { diff --git a/sys/mips/rmi/xlr_machdep.c b/sys/mips/rmi/xlr_machdep.c index 4a1734a893fd..7181a5caa864 100644 --- a/sys/mips/rmi/xlr_machdep.c +++ b/sys/mips/rmi/xlr_machdep.c @@ -614,11 +614,17 @@ platform_processor_id(void) return (xlr_hwtid_to_cpuid[xlr_cpu_id()]); } -cpumask_t +cpuset_t platform_cpu_mask(void) { + cpuset_t cpumask; + int i, s; - return (~0U >> (32 - (xlr_ncores * xlr_threads_per_core))); + CPU_ZERO(&cpumask); + s = xlr_ncores * xlr_threads_per_core; + for (i = 0; i < s; i++) + CPU_SET(i, &cpumask); + return (cpumask); } struct cpu_group * diff --git a/sys/mips/sibyte/sb_scd.c b/sys/mips/sibyte/sb_scd.c index e5ac23c17720..f2035d818180 100644 --- a/sys/mips/sibyte/sb_scd.c +++ b/sys/mips/sibyte/sb_scd.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -242,11 +243,17 @@ sb_clear_mailbox(int cpu, uint64_t val) sb_store64(regaddr, val); } -cpumask_t +cpuset_t platform_cpu_mask(void) { + cpuset_t cpumask; + int i, s; - return (~0U >> (32 - SYSREV_NUM_PROCESSORS(sb_read_sysrev()))); + CPU_ZERO(&cpumask); + s = SYSREV_NUM_PROCESSORS(sb_read_sysrev()); + for (i = 0; i < s; i++) + CPU_SET(i, &cpumask); + return (cpumask); } #endif /* SMP */ From a79fdc81aa4d25507b90e10fedbc38d5ad84ba4a Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 19:56:58 +0000 Subject: [PATCH 045/164] Fix a brain-o in platform_cpu_mask() by just specifying a possible cpuset_t to be copied, rather than return the array. I can't rely anymore on this being a simple int/long object. Reported by: art --- sys/mips/cavium/octeon_mp.c | 10 ++++------ sys/mips/include/hwfunc.h | 2 +- sys/mips/mips/mp_machdep.c | 4 ++-- sys/mips/rmi/xlr_machdep.c | 10 ++++------ sys/mips/sibyte/sb_scd.c | 10 ++++------ 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/sys/mips/cavium/octeon_mp.c b/sys/mips/cavium/octeon_mp.c index 5e494b895c96..efddee86ae0f 100644 --- a/sys/mips/cavium/octeon_mp.c +++ b/sys/mips/cavium/octeon_mp.c @@ -102,20 +102,18 @@ platform_init_ap(int cpuid) mips_wbflush(); } -cpuset_t -platform_cpu_mask(void) +void +platform_cpu_mask(cpuset_t *mask) { - cpuset_t cpumask; - CPU_ZERO(&cpumask); + CPU_ZERO(mask); /* * XXX: hack in order to simplify CPU set building, assuming that * core_mask is 32-bits. */ - memcpy(&cpumask, &octeon_bootinfo->core_mask, + memcpy(mask, &octeon_bootinfo->core_mask, sizeof(octeon_bootinfo->core_mask)); - return (cpumask); } struct cpu_group * diff --git a/sys/mips/include/hwfunc.h b/sys/mips/include/hwfunc.h index 4e6ddf548b4c..a9e3285f5395 100644 --- a/sys/mips/include/hwfunc.h +++ b/sys/mips/include/hwfunc.h @@ -93,7 +93,7 @@ extern int platform_processor_id(void); /* * Return the cpumask of available processors. */ -extern cpuset_t platform_cpu_mask(void); +extern void platform_cpu_mask(cpuset_t *mask); /* * Return the topology of processors on this platform diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index eb36d6fef653..289c0a77b58b 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -205,7 +205,7 @@ cpu_mp_setmaxid(void) cpuset_t cpumask; int cpu, last; - cpumask = platform_cpu_mask(); + platform_cpu_mask(&cpumask); mp_ncpus = 0; last = 1; while ((cpu = cpusetobj_ffs(&cpumask)) != 0) { @@ -247,7 +247,7 @@ cpu_mp_start(void) mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); CPU_ZERO(&all_cpus); - cpumask = platform_cpu_mask(); + platform_cpu_mask(&cpumask); while (!CPU_EMPTY(&cpumask)) { cpuid = cpusetobj_ffs(&cpumask) - 1; diff --git a/sys/mips/rmi/xlr_machdep.c b/sys/mips/rmi/xlr_machdep.c index 7181a5caa864..836c605f7de3 100644 --- a/sys/mips/rmi/xlr_machdep.c +++ b/sys/mips/rmi/xlr_machdep.c @@ -614,17 +614,15 @@ platform_processor_id(void) return (xlr_hwtid_to_cpuid[xlr_cpu_id()]); } -cpuset_t -platform_cpu_mask(void) +void +platform_cpu_mask(cpuset_t *mask) { - cpuset_t cpumask; int i, s; - CPU_ZERO(&cpumask); + CPU_ZERO(mask); s = xlr_ncores * xlr_threads_per_core; for (i = 0; i < s; i++) - CPU_SET(i, &cpumask); - return (cpumask); + CPU_SET(i, mask); } struct cpu_group * diff --git a/sys/mips/sibyte/sb_scd.c b/sys/mips/sibyte/sb_scd.c index f2035d818180..50b99876acaa 100644 --- a/sys/mips/sibyte/sb_scd.c +++ b/sys/mips/sibyte/sb_scd.c @@ -243,17 +243,15 @@ sb_clear_mailbox(int cpu, uint64_t val) sb_store64(regaddr, val); } -cpuset_t -platform_cpu_mask(void) +void +platform_cpu_mask(cpuset_t *mask) { - cpuset_t cpumask; int i, s; - CPU_ZERO(&cpumask); + CPU_ZERO(mask); s = SYSREV_NUM_PROCESSORS(sb_read_sysrev()); for (i = 0; i < s; i++) - CPU_SET(i, &cpumask); - return (cpumask); + CPU_SET(i, mask); } #endif /* SMP */ From 9ff3491e673bf8c43598fcc1af408f5e7c80e854 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 13 May 2011 20:58:48 +0000 Subject: [PATCH 046/164] MFC --- bin/chmod/chmod.1 | 6 ++--- bin/ls/ls.1 | 8 +++---- lib/libc/sys/chmod.2 | 4 ++-- lib/libc/sys/stat.2 | 4 ++-- share/man/man3/Makefile | 6 ++++- share/man/man3/queue.3 | 42 ++++++++++++++++++++++++++++++++-- sys/amd64/include/vmparam.h | 2 ++ sys/arm/arm/pmap.c | 2 +- sys/arm/include/vmparam.h | 3 +++ sys/dev/md/md.c | 10 ++++---- sys/dev/null/null.c | 19 ++++++++++----- sys/i386/include/vmparam.h | 2 ++ sys/ia64/include/vmparam.h | 2 ++ sys/mips/include/vmparam.h | 2 ++ sys/powerpc/include/vmparam.h | 2 ++ sys/sparc64/include/vmparam.h | 7 ++++++ sys/sun4v/include/vmparam.h | 2 ++ sys/sys/queue.h | 13 ++++++----- sys/sys/systm.h | 2 ++ sys/vm/vm_kern.c | 31 +++++++++++++++++++++++++ tools/tools/nanobsd/nanobsd.sh | 28 +++++++++++++++++------ 21 files changed, 158 insertions(+), 39 deletions(-) diff --git a/bin/chmod/chmod.1 b/bin/chmod/chmod.1 index 4ba231b3f033..34a1ff018d9f 100644 --- a/bin/chmod/chmod.1 +++ b/bin/chmod/chmod.1 @@ -134,7 +134,7 @@ will run with effective gid set to the gid of the file owner. See .Xr chmod 2 and -.Xr sticky 8 . +.Xr sticky 7 . .It Li 0400 Allow read by owner. .It Li 0200 @@ -325,10 +325,10 @@ option is non-standard and its use in scripts is not recommended. .Xr umask 2 , .Xr fts 3 , .Xr setmode 3 , +.Xr sticky 7 , .Xr symlink 7 , .Xr chown 8 , -.Xr mount 8 , -.Xr sticky 8 +.Xr mount 8 .Sh STANDARDS The .Nm diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index 22f4fc0a8f3e..3b23df45b88e 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -459,7 +459,7 @@ but not execute or search permission. (See .Xr chmod 1 or -.Xr sticky 8 . ) +.Xr sticky 7 . ) .It Sy t The sticky bit is set (mode .Li 1000 ) , @@ -467,7 +467,7 @@ and is searchable or executable. (See .Xr chmod 1 or -.Xr sticky 8 . ) +.Xr sticky 7 . ) .El .El .Pp @@ -683,9 +683,9 @@ specification. .Xr strmode 3 , .Xr termcap 5 , .Xr maclabel 7 , +.Xr sticky 7 , .Xr symlink 7 , -.Xr getfmac 8 , -.Xr sticky 8 +.Xr getfmac 8 .Sh STANDARDS With the exception of options .Fl I , g , n diff --git a/lib/libc/sys/chmod.2 b/lib/libc/sys/chmod.2 index 3547aec8aff2..997df88e9a86 100644 --- a/lib/libc/sys/chmod.2 +++ b/lib/libc/sys/chmod.2 @@ -161,7 +161,7 @@ The sticky bit may be set by any user on a directory which the user owns or has appropriate permissions. For more details of the properties of the sticky bit, see -.Xr sticky 8 . +.Xr sticky 7 . .Pp If mode ISUID (set UID) is set on a directory, and the MNT_SUIDDIR option was used in the mount of the file system, @@ -289,7 +289,7 @@ nor a file descriptor associated with a directory. .Xr chown 2 , .Xr open 2 , .Xr stat 2 , -.Xr sticky 8 +.Xr sticky 7 .Sh STANDARDS The .Fn chmod diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index ab37c0d54088..7f6d5338e131 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -401,8 +401,8 @@ nor a file descriptor associated with a directory. .Xr fhstat 2 , .Xr statfs 2 , .Xr utimes 2 , -.Xr symlink 7 , -.Xr sticky 8 +.Xr sticky 7 , +.Xr symlink 7 .Sh STANDARDS The .Fn stat diff --git a/share/man/man3/Makefile b/share/man/man3/Makefile index 9111c5c2b1f7..148f460ca177 100644 --- a/share/man/man3/Makefile +++ b/share/man/man3/Makefile @@ -53,6 +53,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 LIST_INSERT_HEAD.3 \ queue.3 LIST_NEXT.3 \ queue.3 LIST_REMOVE.3 \ + queue.3 LIST_SWAP.3 \ queue.3 SLIST_EMPTY.3 \ queue.3 SLIST_ENTRY.3 \ queue.3 SLIST_FIRST.3 \ @@ -67,6 +68,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 SLIST_REMOVE.3 \ queue.3 SLIST_REMOVE_AFTER.3 \ queue.3 SLIST_REMOVE_HEAD.3 \ + queue.3 SLIST_SWAP.3 \ queue.3 STAILQ_CONCAT.3 \ queue.3 STAILQ_EMPTY.3 \ queue.3 STAILQ_ENTRY.3 \ @@ -84,6 +86,7 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 STAILQ_REMOVE.3 \ queue.3 STAILQ_REMOVE_AFTER.3 \ queue.3 STAILQ_REMOVE_HEAD.3 \ + queue.3 STAILQ_SWAP.3 \ queue.3 TAILQ_CONCAT.3 \ queue.3 TAILQ_EMPTY.3 \ queue.3 TAILQ_ENTRY.3 \ @@ -102,7 +105,8 @@ MLINKS+= queue.3 LIST_EMPTY.3 \ queue.3 TAILQ_LAST.3 \ queue.3 TAILQ_NEXT.3 \ queue.3 TAILQ_PREV.3 \ - queue.3 TAILQ_REMOVE.3 + queue.3 TAILQ_REMOVE.3 \ + queue.3 TAILQ_SWAP.3 MLINKS+= stdarg.3 va_arg.3 \ stdarg.3 va_copy.3 \ stdarg.3 va_end.3 \ diff --git a/share/man/man3/queue.3 b/share/man/man3/queue.3 index 506d526d22be..007ca5c629b1 100644 --- a/share/man/man3/queue.3 +++ b/share/man/man3/queue.3 @@ -32,7 +32,7 @@ .\" @(#)queue.3 8.2 (Berkeley) 1/24/94 .\" $FreeBSD$ .\" -.Dd March 24, 2006 +.Dd May 13, 2011 .Dt QUEUE 3 .Os .Sh NAME @@ -50,6 +50,7 @@ .Nm SLIST_REMOVE_AFTER , .Nm SLIST_REMOVE_HEAD , .Nm SLIST_REMOVE , +.Nm SLIST_SWAP , .Nm STAILQ_CONCAT , .Nm STAILQ_EMPTY , .Nm STAILQ_ENTRY , @@ -67,6 +68,7 @@ .Nm STAILQ_REMOVE_AFTER , .Nm STAILQ_REMOVE_HEAD , .Nm STAILQ_REMOVE , +.Nm STAILQ_SWAP , .Nm LIST_EMPTY , .Nm LIST_ENTRY , .Nm LIST_FIRST , @@ -80,6 +82,7 @@ .Nm LIST_INSERT_HEAD , .Nm LIST_NEXT , .Nm LIST_REMOVE , +.Nm LIST_SWAP , .Nm TAILQ_CONCAT , .Nm TAILQ_EMPTY , .Nm TAILQ_ENTRY , @@ -98,7 +101,8 @@ .Nm TAILQ_LAST , .Nm TAILQ_NEXT , .Nm TAILQ_PREV , -.Nm TAILQ_REMOVE +.Nm TAILQ_REMOVE , +.Nm TAILQ_SWAP .Nd implementations of singly-linked lists, singly-linked tail queues, lists and tail queues .Sh SYNOPSIS @@ -118,6 +122,7 @@ lists and tail queues .Fn SLIST_REMOVE_AFTER "TYPE *elm" "SLIST_ENTRY NAME" .Fn SLIST_REMOVE_HEAD "SLIST_HEAD *head" "SLIST_ENTRY NAME" .Fn SLIST_REMOVE "SLIST_HEAD *head" "TYPE *elm" "TYPE" "SLIST_ENTRY NAME" +.Fn SLIST_SWAP "SLIST_HEAD *head1" "SLIST_HEAD *head2" "SLIST_ENTRY NAME" .\" .Fn STAILQ_CONCAT "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" .Fn STAILQ_EMPTY "STAILQ_HEAD *head" @@ -136,6 +141,7 @@ lists and tail queues .Fn STAILQ_REMOVE_AFTER "STAILQ_HEAD *head" "TYPE *elm" "STAILQ_ENTRY NAME" .Fn STAILQ_REMOVE_HEAD "STAILQ_HEAD *head" "STAILQ_ENTRY NAME" .Fn STAILQ_REMOVE "STAILQ_HEAD *head" "TYPE *elm" "TYPE" "STAILQ_ENTRY NAME" +.Fn STAILQ_SWAP "STAILQ_HEAD *head1" "STAILQ_HEAD *head2" "STAILQ_ENTRY NAME" .\" .Fn LIST_EMPTY "LIST_HEAD *head" .Fn LIST_ENTRY "TYPE" @@ -150,6 +156,7 @@ lists and tail queues .Fn LIST_INSERT_HEAD "LIST_HEAD *head" "TYPE *elm" "LIST_ENTRY NAME" .Fn LIST_NEXT "TYPE *elm" "LIST_ENTRY NAME" .Fn LIST_REMOVE "TYPE *elm" "LIST_ENTRY NAME" +.Fn LIST_SWAP "LIST_HEAD *head1" "LIST_HEAD *head2" "TYPE" "LIST_ENTRY NAME" .\" .Fn TAILQ_CONCAT "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TAILQ_ENTRY NAME" .Fn TAILQ_EMPTY "TAILQ_HEAD *head" @@ -170,6 +177,7 @@ lists and tail queues .Fn TAILQ_NEXT "TYPE *elm" "TAILQ_ENTRY NAME" .Fn TAILQ_PREV "TYPE *elm" "HEADNAME" "TAILQ_ENTRY NAME" .Fn TAILQ_REMOVE "TAILQ_HEAD *head" "TYPE *elm" "TAILQ_ENTRY NAME" +.Fn TAILQ_SWAP "TAILQ_HEAD *head1" "TAILQ_HEAD *head2" "TYPE" "TAILQ_ENTRY NAME" .\" .Sh DESCRIPTION These macros define and operate on four types of data structures: @@ -184,6 +192,8 @@ Insertion of a new entry after any element in the list. O(1) removal of an entry from the head of the list. .It Forward traversal through the list. +.It +Swawpping the contents of two lists. .El .Pp Singly-linked lists are the simplest of the four data structures @@ -402,6 +412,13 @@ The macro removes the element .Fa elm from the list. +.Pp +The macro +.Nm SLIST_SWAP +swaps the contents of +.Fa head1 +and +.Fa head2 . .Sh SINGLY-LINKED LIST EXAMPLE .Bd -literal SLIST_HEAD(slisthead, entry) head = @@ -584,6 +601,13 @@ The macro removes the element .Fa elm from the tail queue. +.Pp +The macro +.Nm STAILQ_SWAP +swaps the contents of +.Fa head1 +and +.Fa head2 . .Sh SINGLY-LINKED TAIL QUEUE EXAMPLE .Bd -literal STAILQ_HEAD(stailhead, entry) head = @@ -743,6 +767,13 @@ The macro removes the element .Fa elm from the list. +.Pp +The macro +.Nm LIST_SWAP +swaps the contents of +.Fa head1 +and +.Fa head2 . .Sh LIST EXAMPLE .Bd -literal LIST_HEAD(listhead, entry) head = @@ -942,6 +973,13 @@ The macro removes the element .Fa elm from the tail queue. +.Pp +The macro +.Nm TAILQ_SWAP +swaps the contents of +.Fa head1 +and +.Fa head2 . .Sh TAIL QUEUE EXAMPLE .Bd -literal TAILQ_HEAD(tailhead, entry) head = diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 38a621485ce3..0c656023fd4c 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -212,4 +212,6 @@ #define VM_INITIAL_PAGEIN 16 #endif +#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ + #endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c index 16487b08ef9d..cecf3638d95f 100644 --- a/sys/arm/arm/pmap.c +++ b/sys/arm/arm/pmap.c @@ -3646,7 +3646,7 @@ pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired) pte = *ptep; pg = PHYS_TO_VM_PAGE(l2pte_pa(pte)); if (pg) - pmap_modify_pv(pg, pmap, va, PVF_WIRED, wired); + pmap_modify_pv(pg, pmap, va, PVF_WIRED, wired ? PVF_WIRED : 0); vm_page_unlock_queues(); PMAP_UNLOCK(pmap); } diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h index c608daa8423d..dd1ba1c46cf2 100644 --- a/sys/arm/include/vmparam.h +++ b/sys/arm/include/vmparam.h @@ -150,4 +150,7 @@ #ifdef ARM_USE_SMALL_ALLOC #define UMA_MD_SMALL_ALLOC #endif /* ARM_USE_SMALL_ALLOC */ + +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ + #endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 79bf19c4e5b2..c48872869b42 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -89,6 +89,8 @@ #include #include +#include + #define MD_MODVER 1 #define MD_SHUTDOWN 0x10000 /* Tell worker thread to terminate. */ @@ -205,9 +207,6 @@ struct md_s { vm_object_t object; }; -/* Used for BIO_DELETE on MD_VNODE */ -static u_char zero[PAGE_SIZE]; - static struct indir * new_indir(u_int shift) { @@ -560,7 +559,8 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) * that the two cases end up having very little in common. */ if (bp->bio_cmd == BIO_DELETE) { - zerosize = sizeof(zero) - (sizeof(zero) % sc->sectorsize); + zerosize = ZERO_REGION_SIZE - + (ZERO_REGION_SIZE % sc->sectorsize); auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_offset = (vm_ooffset_t)bp->bio_offset; @@ -573,7 +573,7 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = 0; while (auio.uio_offset < end) { - aiov.iov_base = zero; + aiov.iov_base = __DECONST(void *, zero_region); aiov.iov_len = end - auio.uio_offset; if (aiov.iov_len > zerosize) aiov.iov_len = zerosize; diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c index 3005c19ccbf4..b053d5d55d37 100644 --- a/sys/dev/null/null.c +++ b/sys/dev/null/null.c @@ -39,7 +39,9 @@ __FBSDID("$FreeBSD$"); #include #include #include + #include +#include /* For use with destroy_dev(9). */ static struct cdev *null_dev; @@ -65,8 +67,6 @@ static struct cdevsw zero_cdevsw = { .d_flags = D_MMAP_ANON, }; -static void *zbuf; - /* ARGSUSED */ static int null_write(struct cdev *dev __unused, struct uio *uio, int flags __unused) @@ -95,10 +95,19 @@ null_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused, static int zero_read(struct cdev *dev __unused, struct uio *uio, int flags __unused) { + void *zbuf; + ssize_t len; int error = 0; - while (uio->uio_resid > 0 && error == 0) - error = uiomove(zbuf, MIN(uio->uio_resid, PAGE_SIZE), uio); + KASSERT(uio->uio_rw == UIO_READ, + ("Can't be in %s for write", __func__)); + zbuf = __DECONST(void *, zero_region); + while (uio->uio_resid > 0 && error == 0) { + len = uio->uio_resid; + if (len > ZERO_REGION_SIZE) + len = ZERO_REGION_SIZE; + error = uiomove(zbuf, len, uio); + } return (error); } @@ -111,7 +120,6 @@ null_modevent(module_t mod __unused, int type, void *data __unused) case MOD_LOAD: if (bootverbose) printf("null: \n"); - zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO); null_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &null_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0666, "null"); zero_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &zero_cdevsw, 0, @@ -121,7 +129,6 @@ null_modevent(module_t mod __unused, int type, void *data __unused) case MOD_UNLOAD: destroy_dev(null_dev); destroy_dev(zero_dev); - free(zbuf, M_TEMP); break; case MOD_SHUTDOWN: diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index 9eaa3f7a9b9a..8fe9b2b612b6 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -198,4 +198,6 @@ #define VM_INITIAL_PAGEIN 16 #endif +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ + #endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/ia64/include/vmparam.h b/sys/ia64/include/vmparam.h index e93ca1bb0c54..16c5e7dda7a9 100644 --- a/sys/ia64/include/vmparam.h +++ b/sys/ia64/include/vmparam.h @@ -215,4 +215,6 @@ #define VM_INITIAL_PAGEIN 16 #endif +#define ZERO_REGION_SIZE (2 * 1024 * 1024) /* 2MB */ + #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/mips/include/vmparam.h b/sys/mips/include/vmparam.h index ef01601dd4ed..4a702f51fdf1 100644 --- a/sys/mips/include/vmparam.h +++ b/sys/mips/include/vmparam.h @@ -187,4 +187,6 @@ */ #define VM_NFREEORDER 9 +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ + #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/powerpc/include/vmparam.h b/sys/powerpc/include/vmparam.h index d72e0eac7826..cec455f2fded 100644 --- a/sys/powerpc/include/vmparam.h +++ b/sys/powerpc/include/vmparam.h @@ -198,4 +198,6 @@ struct pmap_physseg { #endif #endif +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ + #endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/sparc64/include/vmparam.h b/sys/sparc64/include/vmparam.h index 0638d0d78bf7..1b9e537ef17f 100644 --- a/sys/sparc64/include/vmparam.h +++ b/sys/sparc64/include/vmparam.h @@ -240,4 +240,11 @@ extern vm_offset_t vm_max_kernel_address; +/* + * Older sparc64 machines have a virtually indexed L1 data cache of 16KB. + * Consequently, mapping the same physical page multiple times may have + * caching disabled. + */ +#define ZERO_REGION_SIZE PAGE_SIZE + #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/sun4v/include/vmparam.h b/sys/sun4v/include/vmparam.h index 65c7f78548bb..5195f1d57d89 100644 --- a/sys/sun4v/include/vmparam.h +++ b/sys/sun4v/include/vmparam.h @@ -223,4 +223,6 @@ #define UMA_MD_SMALL_ALLOC extern vm_offset_t vm_max_kernel_address; +#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ + #endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/sys/queue.h b/sys/sys/queue.h index f0bae8d91184..274e636c5330 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -99,6 +99,7 @@ * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - * _REMOVE + + + + + * _SWAP + + + + * */ #ifdef QUEUE_MACRO_DEBUG @@ -307,18 +308,18 @@ struct { \ TRASHIT(*oldnext); \ } while (0) -#define STAILQ_REMOVE_HEAD(head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - #define STAILQ_REMOVE_AFTER(head, elm, field) do { \ if ((STAILQ_NEXT(elm, field) = \ STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ (head)->stqh_last = &STAILQ_NEXT((elm), field); \ } while (0) +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if ((STAILQ_FIRST((head)) = \ + STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ + (head)->stqh_last = &STAILQ_FIRST((head)); \ +} while (0) + #define STAILQ_SWAP(head1, head2, type) do { \ struct type *swap_first = STAILQ_FIRST(head1); \ struct type **swap_last = (head1)->stqh_last; \ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 80fb0a93fef6..e563a5a6d3cb 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -125,6 +125,8 @@ extern char static_hints[]; /* by config for now */ extern char **kenvp; +extern const void *zero_region; /* address space maps to a zeroed page */ + /* * General function declarations. */ diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 0360af78d467..23884af0b3aa 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -91,6 +91,9 @@ vm_map_t exec_map=0; vm_map_t pipe_map; vm_map_t buffer_map=0; +const void *zero_region; +CTASSERT((ZERO_REGION_SIZE & PAGE_MASK) == 0); + /* * kmem_alloc_nofault: * @@ -527,6 +530,32 @@ kmem_free_wakeup(map, addr, size) vm_map_unlock(map); } +static void +kmem_init_zero_region(void) +{ + vm_offset_t addr, i; + vm_page_t m; + int error; + + /* + * Map a single physical page of zeros to a larger virtual range. + * This requires less looping in places that want large amounts of + * zeros, while not using much more physical resources. + */ + addr = kmem_alloc_nofault(kernel_map, ZERO_REGION_SIZE); + m = vm_page_alloc(NULL, OFF_TO_IDX(addr - VM_MIN_KERNEL_ADDRESS), + VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO); + if ((m->flags & PG_ZERO) == 0) + pmap_zero_page(m); + for (i = 0; i < ZERO_REGION_SIZE; i += PAGE_SIZE) + pmap_qenter(addr + i, &m, 1); + error = vm_map_protect(kernel_map, addr, addr + ZERO_REGION_SIZE, + VM_PROT_READ, TRUE); + KASSERT(error == 0, ("error=%d", error)); + + zero_region = (const void *)addr; +} + /* * kmem_init: * @@ -555,6 +584,8 @@ kmem_init(start, end) start, VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT); /* ... and ending with the completion of the above `insert' */ vm_map_unlock(m); + + kmem_init_zero_region(); } #ifdef DIAGNOSTIC diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh index 8078d11e9d56..58d685b4ebfa 100644 --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -418,7 +418,7 @@ populate_slice ( ) ( echo "Creating ${dev} with ${dir} (mounting on ${mnt})" newfs_part $dev $mnt $lbl cd ${dir} - find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt} + find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${mnt} df -i ${mnt} umount ${mnt} ) @@ -567,8 +567,10 @@ create_i386_diskimage ( ) ( dd if=/dev/${MD} of=${IMG} bs=64k fi - echo "Writing out _.disk.image..." - dd if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k + if ${do_copyout_partition} ; then + echo "Writing out _.disk.image..." + dd if=/dev/${MD}s1 of=${NANO_DISKIMGDIR}/_.disk.image bs=64k + fi mdconfig -d -u $MD trap - 1 2 15 EXIT @@ -674,7 +676,7 @@ cust_allow_ssh_root () ( cust_install_files () ( cd ${NANO_TOOLS}/Files - find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${NANO_WORLDDIR} + find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${NANO_WORLDDIR} ) ####################################################################### @@ -682,12 +684,18 @@ cust_install_files () ( cust_pkg () ( + # If the package directory doesn't exist, we're done. + if [ ! -d ${NANO_PACKAGE_DIR} ]; then + echo "DONE 0 packages" + return 0 + fi + # Copy packages into chroot mkdir -p ${NANO_WORLDDIR}/Pkg ( cd ${NANO_PACKAGE_DIR} find ${NANO_PACKAGE_LIST} -print | - cpio -dumpv ${NANO_WORLDDIR}/Pkg + cpio -Ldumpv ${NANO_WORLDDIR}/Pkg ) # Count & report how many we have to install @@ -758,8 +766,9 @@ pprint() { usage () { ( - echo "Usage: $0 [-biknqvw] [-c config_file]" + echo "Usage: $0 [-bfiknqvw] [-c config_file]" echo " -b suppress builds (both kernel and world)" + echo " -f suppress code slice extraction" echo " -i suppress disk image build" echo " -k suppress buildkernel" echo " -n add -DNO_CLEAN to buildworld, buildkernel, etc" @@ -778,9 +787,10 @@ do_clean=true do_kernel=true do_world=true do_image=true +do_copyout_partition=true set +e -args=`getopt bc:hiknqvw $*` +args=`getopt bc:fhiknqvw $*` if [ $? -ne 0 ] ; then usage exit 2 @@ -806,6 +816,10 @@ do shift shift ;; + -f) + do_copyout_partition=false + shift + ;; -h) usage ;; From 548a471624011260b4f4033bddb96cfa5bd895bd Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 14 May 2011 02:28:26 +0000 Subject: [PATCH 047/164] MFC --- Makefile | 5 +- Makefile.inc1 | 2 +- UPDATING | 3 + gnu/usr.bin/send-pr/categories | 1 - gnu/usr.bin/send-pr/send-pr.1 | 3 - lib/libc/sparc64/sys/Makefile.inc | 3 - lib/libc/sparc64/sys/__sparc_utrap_gen.S | 4 - lib/libdisk/Makefile | 4 - lib/libkvm/Makefile | 4 - lib/libkvm/kvm_sparc64.c | 4 - release/doc/share/sgml/release.ent | 1 - release/sun4v/boot_crunch.conf | 44 - release/sun4v/mkisoimages.sh | 72 - share/man/man4/ddb.4 | 2 +- share/man/man5/src.conf.5 | 4 +- sys/Makefile | 2 +- sys/boot/Makefile | 2 +- sys/boot/common/loader.8 | 2 +- sys/boot/sparc64/loader/main.c | 71 +- sys/conf/Makefile.sun4v | 49 - sys/conf/files.sun4v | 111 - sys/conf/options.sun4v | 15 - sys/dev/ath/ath_hal/ar5416/ar5416_cal.c | 2 +- sys/dev/ath/ath_rate/sample/tx_schedules.h | 2 +- sys/fs/ext2fs/ext2_lookup.c | 16 +- sys/modules/mem/Makefile | 14 - sys/modules/uart/Makefile | 4 +- sys/sparc64/sparc64/autoconf.c | 3 - sys/sparc64/sparc64/genassym.c | 56 - sys/sparc64/sparc64/mem.c | 6 - sys/sun4v/cddl/mdesc/mdesc_diff.c | 603 ----- sys/sun4v/cddl/mdesc/mdesc_findname.c | 67 - sys/sun4v/cddl/mdesc/mdesc_findnodeprop.c | 76 - sys/sun4v/cddl/mdesc/mdesc_fini.c | 48 - sys/sun4v/cddl/mdesc/mdesc_getbinsize.c | 46 - sys/sun4v/cddl/mdesc/mdesc_getgen.c | 46 - sys/sun4v/cddl/mdesc/mdesc_getpropdata.c | 65 - sys/sun4v/cddl/mdesc/mdesc_getpropstr.c | 62 - sys/sun4v/cddl/mdesc/mdesc_getpropval.c | 68 - sys/sun4v/cddl/mdesc/mdesc_init_intern.c | 178 -- sys/sun4v/cddl/mdesc/mdesc_nodecount.c | 44 - sys/sun4v/cddl/mdesc/mdesc_rootnode.c | 44 - sys/sun4v/cddl/mdesc/mdesc_scandag.c | 191 -- sys/sun4v/cddl/t1_copy.S | 1598 ------------- sys/sun4v/compile/.cvsignore | 0 sys/sun4v/conf/.cvsignore | 1 - sys/sun4v/conf/DEFAULTS | 13 - sys/sun4v/conf/GENERIC | 217 -- sys/sun4v/conf/GENERIC.hints | 1 - sys/sun4v/conf/Makefile | 5 - sys/sun4v/conf/NOTES | 117 - sys/sun4v/include/_align.h | 44 - sys/sun4v/include/_bus.h | 43 - sys/sun4v/include/_inttypes.h | 213 -- sys/sun4v/include/_limits.h | 85 - sys/sun4v/include/_stdint.h | 164 -- sys/sun4v/include/_types.h | 113 - sys/sun4v/include/asi.h | 178 -- sys/sun4v/include/asm.h | 116 - sys/sun4v/include/asmacros.h | 340 --- sys/sun4v/include/atomic.h | 299 --- sys/sun4v/include/bus.h | 844 ------- sys/sun4v/include/bus_dma.h | 145 -- sys/sun4v/include/bus_private.h | 84 - sys/sun4v/include/ccr.h | 46 - sys/sun4v/include/cddl/mdesc.h | 216 -- sys/sun4v/include/cddl/mdesc_impl.h | 162 -- sys/sun4v/include/clock.h | 35 - sys/sun4v/include/cmt.h | 7 - sys/sun4v/include/cpu.h | 74 - sys/sun4v/include/cpufunc.h | 252 --- sys/sun4v/include/db_machdep.h | 69 - sys/sun4v/include/elf.h | 109 - sys/sun4v/include/endian.h | 7 - sys/sun4v/include/exec.h | 34 - sys/sun4v/include/fireplane.h | 7 - sys/sun4v/include/float.h | 84 - sys/sun4v/include/floatingpoint.h | 37 - sys/sun4v/include/fp.h | 39 - sys/sun4v/include/frame.h | 94 - sys/sun4v/include/fsr.h | 112 - sys/sun4v/include/gdb_machdep.h | 57 - sys/sun4v/include/hv_api.h | 243 -- sys/sun4v/include/hv_pcivar.h | 51 - sys/sun4v/include/hviommu.h | 39 - sys/sun4v/include/hypervisorvar.h | 350 --- sys/sun4v/include/idprom.h | 63 - sys/sun4v/include/ieee.h | 137 -- sys/sun4v/include/ieeefp.h | 26 - sys/sun4v/include/in_cksum.h | 7 - sys/sun4v/include/instr.h | 618 ----- sys/sun4v/include/intr_machdep.h | 107 - sys/sun4v/include/jbus.h | 7 - sys/sun4v/include/kdb.h | 55 - sys/sun4v/include/kerneldump.h | 51 - sys/sun4v/include/ktr.h | 95 - sys/sun4v/include/limits.h | 41 - sys/sun4v/include/lsu.h | 68 - sys/sun4v/include/md_var.h | 63 - sys/sun4v/include/mdesc_bus.h | 72 - sys/sun4v/include/mdesc_bus_subr.h | 47 - sys/sun4v/include/memdev.h | 40 - sys/sun4v/include/metadata.h | 45 - sys/sun4v/include/mmu.h | 123 - sys/sun4v/include/nexusvar.h | 44 - sys/sun4v/include/ofw_machdep.h | 44 - sys/sun4v/include/ofw_mem.h | 46 - sys/sun4v/include/ofw_nexus.h | 81 - sys/sun4v/include/param.h | 140 -- sys/sun4v/include/pcb.h | 68 - sys/sun4v/include/pcpu.h | 112 - sys/sun4v/include/pmap.h | 131 -- sys/sun4v/include/pmc_mdep.h | 28 - sys/sun4v/include/proc.h | 68 - sys/sun4v/include/profile.h | 102 - sys/sun4v/include/pstate.h | 59 - sys/sun4v/include/ptrace.h | 36 - sys/sun4v/include/reg.h | 113 - sys/sun4v/include/reloc.h | 30 - sys/sun4v/include/resource.h | 45 - sys/sun4v/include/runq.h | 58 - sys/sun4v/include/sc_machdep.h | 76 - sys/sun4v/include/setjmp.h | 57 - sys/sun4v/include/sf_buf.h | 59 - sys/sun4v/include/sigframe.h | 40 - sys/sun4v/include/signal.h | 47 - sys/sun4v/include/smp.h | 262 --- sys/sun4v/include/stack.h | 35 - sys/sun4v/include/stdarg.h | 101 - sys/sun4v/include/sun4v_cpufunc.h | 91 - sys/sun4v/include/sysarch.h | 72 - sys/sun4v/include/tick.h | 34 - sys/sun4v/include/tlb.h | 95 - sys/sun4v/include/trap.h | 154 -- sys/sun4v/include/tsb.h | 84 - sys/sun4v/include/tstate.h | 84 - sys/sun4v/include/tte.h | 258 --- sys/sun4v/include/tte_hash.h | 78 - sys/sun4v/include/ucontext.h | 64 - sys/sun4v/include/upa.h | 7 - sys/sun4v/include/utrap.h | 111 - sys/sun4v/include/varargs.h | 87 - sys/sun4v/include/ver.h | 7 - sys/sun4v/include/vm.h | 35 - sys/sun4v/include/vmparam.h | 228 -- sys/sun4v/include/watch.h | 41 - sys/sun4v/include/wstate.h | 59 - sys/sun4v/mdesc/mdesc_bus_if.m | 127 -- sys/sun4v/mdesc/mdesc_bus_subr.c | 133 -- sys/sun4v/mdesc/mdesc_init.c | 306 --- sys/sun4v/mdesc/mdesc_subr.c | 76 - sys/sun4v/mdesc/mdesc_vdevfindnode.c | 101 - sys/sun4v/mdesc/mdesc_vdevfindval.c | 99 - sys/sun4v/sun4v/bus_machdep.c | 845 ------- sys/sun4v/sun4v/clock.c | 47 - sys/sun4v/sun4v/db_hwwatch.c | 229 -- sys/sun4v/sun4v/db_interface.c | 105 - sys/sun4v/sun4v/db_trace.c | 302 --- sys/sun4v/sun4v/dump_machdep.c | 228 -- sys/sun4v/sun4v/exception.S | 2025 ----------------- sys/sun4v/sun4v/hcall.S | 1852 --------------- sys/sun4v/sun4v/hv_pci.c | 488 ---- sys/sun4v/sun4v/hvcons.c | 371 --- sys/sun4v/sun4v/hviommu.c | 935 -------- sys/sun4v/sun4v/interrupt.S | 585 ----- sys/sun4v/sun4v/intr_machdep.c | 443 ---- sys/sun4v/sun4v/locore.S | 111 - sys/sun4v/sun4v/machdep.c | 1016 --------- sys/sun4v/sun4v/mp_exception.S | 280 --- sys/sun4v/sun4v/mp_locore.S | 173 -- sys/sun4v/sun4v/mp_machdep.c | 613 ----- sys/sun4v/sun4v/nexus.c | 626 ----- sys/sun4v/sun4v/pmap.c | 2388 -------------------- sys/sun4v/sun4v/rtc.c | 106 - sys/sun4v/sun4v/simdisk.c | 251 -- sys/sun4v/sun4v/stack_machdep.c | 82 - sys/sun4v/sun4v/support.S | 924 -------- sys/sun4v/sun4v/swtch.S | 257 --- sys/sun4v/sun4v/tick.c | 235 -- sys/sun4v/sun4v/trap.c | 633 ------ sys/sun4v/sun4v/trap_trace.S | 38 - sys/sun4v/sun4v/tsb.c | 284 --- sys/sun4v/sun4v/tte.c | 130 -- sys/sun4v/sun4v/tte_hash.c | 656 ------ sys/sun4v/sun4v/uio_machdep.c | 126 -- sys/sun4v/sun4v/vm_machdep.c | 466 ---- sys/sun4v/sun4v/vnex.c | 368 --- sys/sun4v/sun4v/wbuf.S | 222 -- sys/sys/kdb.h | 2 +- sys/sys/param.h | 2 +- usr.bin/rpcinfo/rpcinfo.c | 20 +- usr.sbin/bsdinstall/partedit/Makefile | 3 - 192 files changed, 33 insertions(+), 33205 deletions(-) delete mode 100644 release/sun4v/boot_crunch.conf delete mode 100644 release/sun4v/mkisoimages.sh delete mode 100644 sys/conf/Makefile.sun4v delete mode 100644 sys/conf/files.sun4v delete mode 100644 sys/conf/options.sun4v delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_diff.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_findname.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_findnodeprop.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_fini.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_getbinsize.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_getgen.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_getpropdata.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_getpropstr.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_getpropval.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_init_intern.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_nodecount.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_rootnode.c delete mode 100644 sys/sun4v/cddl/mdesc/mdesc_scandag.c delete mode 100644 sys/sun4v/cddl/t1_copy.S delete mode 100644 sys/sun4v/compile/.cvsignore delete mode 100644 sys/sun4v/conf/.cvsignore delete mode 100644 sys/sun4v/conf/DEFAULTS delete mode 100644 sys/sun4v/conf/GENERIC delete mode 100644 sys/sun4v/conf/GENERIC.hints delete mode 100644 sys/sun4v/conf/Makefile delete mode 100644 sys/sun4v/conf/NOTES delete mode 100644 sys/sun4v/include/_align.h delete mode 100644 sys/sun4v/include/_bus.h delete mode 100644 sys/sun4v/include/_inttypes.h delete mode 100644 sys/sun4v/include/_limits.h delete mode 100644 sys/sun4v/include/_stdint.h delete mode 100644 sys/sun4v/include/_types.h delete mode 100644 sys/sun4v/include/asi.h delete mode 100644 sys/sun4v/include/asm.h delete mode 100644 sys/sun4v/include/asmacros.h delete mode 100644 sys/sun4v/include/atomic.h delete mode 100644 sys/sun4v/include/bus.h delete mode 100644 sys/sun4v/include/bus_dma.h delete mode 100644 sys/sun4v/include/bus_private.h delete mode 100644 sys/sun4v/include/ccr.h delete mode 100644 sys/sun4v/include/cddl/mdesc.h delete mode 100644 sys/sun4v/include/cddl/mdesc_impl.h delete mode 100644 sys/sun4v/include/clock.h delete mode 100644 sys/sun4v/include/cmt.h delete mode 100644 sys/sun4v/include/cpu.h delete mode 100644 sys/sun4v/include/cpufunc.h delete mode 100644 sys/sun4v/include/db_machdep.h delete mode 100644 sys/sun4v/include/elf.h delete mode 100644 sys/sun4v/include/endian.h delete mode 100644 sys/sun4v/include/exec.h delete mode 100644 sys/sun4v/include/fireplane.h delete mode 100644 sys/sun4v/include/float.h delete mode 100644 sys/sun4v/include/floatingpoint.h delete mode 100644 sys/sun4v/include/fp.h delete mode 100644 sys/sun4v/include/frame.h delete mode 100644 sys/sun4v/include/fsr.h delete mode 100644 sys/sun4v/include/gdb_machdep.h delete mode 100644 sys/sun4v/include/hv_api.h delete mode 100644 sys/sun4v/include/hv_pcivar.h delete mode 100644 sys/sun4v/include/hviommu.h delete mode 100644 sys/sun4v/include/hypervisorvar.h delete mode 100644 sys/sun4v/include/idprom.h delete mode 100644 sys/sun4v/include/ieee.h delete mode 100644 sys/sun4v/include/ieeefp.h delete mode 100644 sys/sun4v/include/in_cksum.h delete mode 100644 sys/sun4v/include/instr.h delete mode 100644 sys/sun4v/include/intr_machdep.h delete mode 100644 sys/sun4v/include/jbus.h delete mode 100644 sys/sun4v/include/kdb.h delete mode 100644 sys/sun4v/include/kerneldump.h delete mode 100644 sys/sun4v/include/ktr.h delete mode 100644 sys/sun4v/include/limits.h delete mode 100644 sys/sun4v/include/lsu.h delete mode 100644 sys/sun4v/include/md_var.h delete mode 100644 sys/sun4v/include/mdesc_bus.h delete mode 100644 sys/sun4v/include/mdesc_bus_subr.h delete mode 100644 sys/sun4v/include/memdev.h delete mode 100644 sys/sun4v/include/metadata.h delete mode 100644 sys/sun4v/include/mmu.h delete mode 100644 sys/sun4v/include/nexusvar.h delete mode 100644 sys/sun4v/include/ofw_machdep.h delete mode 100644 sys/sun4v/include/ofw_mem.h delete mode 100644 sys/sun4v/include/ofw_nexus.h delete mode 100644 sys/sun4v/include/param.h delete mode 100644 sys/sun4v/include/pcb.h delete mode 100644 sys/sun4v/include/pcpu.h delete mode 100644 sys/sun4v/include/pmap.h delete mode 100644 sys/sun4v/include/pmc_mdep.h delete mode 100644 sys/sun4v/include/proc.h delete mode 100644 sys/sun4v/include/profile.h delete mode 100644 sys/sun4v/include/pstate.h delete mode 100644 sys/sun4v/include/ptrace.h delete mode 100644 sys/sun4v/include/reg.h delete mode 100644 sys/sun4v/include/reloc.h delete mode 100644 sys/sun4v/include/resource.h delete mode 100644 sys/sun4v/include/runq.h delete mode 100644 sys/sun4v/include/sc_machdep.h delete mode 100644 sys/sun4v/include/setjmp.h delete mode 100644 sys/sun4v/include/sf_buf.h delete mode 100644 sys/sun4v/include/sigframe.h delete mode 100644 sys/sun4v/include/signal.h delete mode 100644 sys/sun4v/include/smp.h delete mode 100644 sys/sun4v/include/stack.h delete mode 100644 sys/sun4v/include/stdarg.h delete mode 100644 sys/sun4v/include/sun4v_cpufunc.h delete mode 100644 sys/sun4v/include/sysarch.h delete mode 100644 sys/sun4v/include/tick.h delete mode 100644 sys/sun4v/include/tlb.h delete mode 100644 sys/sun4v/include/trap.h delete mode 100644 sys/sun4v/include/tsb.h delete mode 100644 sys/sun4v/include/tstate.h delete mode 100644 sys/sun4v/include/tte.h delete mode 100644 sys/sun4v/include/tte_hash.h delete mode 100644 sys/sun4v/include/ucontext.h delete mode 100644 sys/sun4v/include/upa.h delete mode 100644 sys/sun4v/include/utrap.h delete mode 100644 sys/sun4v/include/varargs.h delete mode 100644 sys/sun4v/include/ver.h delete mode 100644 sys/sun4v/include/vm.h delete mode 100644 sys/sun4v/include/vmparam.h delete mode 100644 sys/sun4v/include/watch.h delete mode 100644 sys/sun4v/include/wstate.h delete mode 100644 sys/sun4v/mdesc/mdesc_bus_if.m delete mode 100644 sys/sun4v/mdesc/mdesc_bus_subr.c delete mode 100644 sys/sun4v/mdesc/mdesc_init.c delete mode 100644 sys/sun4v/mdesc/mdesc_subr.c delete mode 100644 sys/sun4v/mdesc/mdesc_vdevfindnode.c delete mode 100644 sys/sun4v/mdesc/mdesc_vdevfindval.c delete mode 100644 sys/sun4v/sun4v/bus_machdep.c delete mode 100644 sys/sun4v/sun4v/clock.c delete mode 100644 sys/sun4v/sun4v/db_hwwatch.c delete mode 100644 sys/sun4v/sun4v/db_interface.c delete mode 100644 sys/sun4v/sun4v/db_trace.c delete mode 100644 sys/sun4v/sun4v/dump_machdep.c delete mode 100644 sys/sun4v/sun4v/exception.S delete mode 100644 sys/sun4v/sun4v/hcall.S delete mode 100644 sys/sun4v/sun4v/hv_pci.c delete mode 100644 sys/sun4v/sun4v/hvcons.c delete mode 100644 sys/sun4v/sun4v/hviommu.c delete mode 100644 sys/sun4v/sun4v/interrupt.S delete mode 100644 sys/sun4v/sun4v/intr_machdep.c delete mode 100644 sys/sun4v/sun4v/locore.S delete mode 100644 sys/sun4v/sun4v/machdep.c delete mode 100644 sys/sun4v/sun4v/mp_exception.S delete mode 100644 sys/sun4v/sun4v/mp_locore.S delete mode 100644 sys/sun4v/sun4v/mp_machdep.c delete mode 100644 sys/sun4v/sun4v/nexus.c delete mode 100644 sys/sun4v/sun4v/pmap.c delete mode 100644 sys/sun4v/sun4v/rtc.c delete mode 100644 sys/sun4v/sun4v/simdisk.c delete mode 100644 sys/sun4v/sun4v/stack_machdep.c delete mode 100644 sys/sun4v/sun4v/support.S delete mode 100644 sys/sun4v/sun4v/swtch.S delete mode 100644 sys/sun4v/sun4v/tick.c delete mode 100644 sys/sun4v/sun4v/trap.c delete mode 100644 sys/sun4v/sun4v/trap_trace.S delete mode 100644 sys/sun4v/sun4v/tsb.c delete mode 100644 sys/sun4v/sun4v/tte.c delete mode 100644 sys/sun4v/sun4v/tte_hash.c delete mode 100644 sys/sun4v/sun4v/uio_machdep.c delete mode 100644 sys/sun4v/sun4v/vm_machdep.c delete mode 100644 sys/sun4v/sun4v/vnex.c delete mode 100644 sys/sun4v/sun4v/wbuf.S diff --git a/Makefile b/Makefile index 9af12a32942a..e28569a0e66b 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ _MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${ # Guess machine architecture from machine type, and vice versa. .if !defined(TARGET_ARCH) && defined(TARGET) -_TARGET_ARCH= ${TARGET:S/pc98/i386/:S/sun4v/sparc64/:S/mips/mipsel/} +_TARGET_ARCH= ${TARGET:S/pc98/i386/:S/mips/mipsel/} .elif !defined(TARGET) && defined(TARGET_ARCH) && \ ${TARGET_ARCH} != ${MACHINE_ARCH} _TARGET= ${TARGET_ARCH:C/mips.*e[lb]/mips/:C/armeb/arm/} @@ -323,12 +323,11 @@ toolchains: # existing system is. # .if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets) -TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v +TARGETS?=amd64 arm i386 ia64 mips pc98 powerpc sparc64 TARGET_ARCHES_arm?= arm armeb TARGET_ARCHES_mips?= mipsel mipseb mips64el mips64eb mipsn32eb TARGET_ARCHES_powerpc?= powerpc powerpc64 TARGET_ARCHES_pc98?= i386 -TARGET_ARCHES_sun4v?= sparc64 .for target in ${TARGETS} TARGET_ARCHES_${target}?= ${target} .endfor diff --git a/Makefile.inc1 b/Makefile.inc1 index fc774f2adfd0..907cdce7d5bf 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -130,7 +130,7 @@ VERSION!= uname -srp VERSION+= ${OSRELDATE} .endif -KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips mips64el/mips mips64eb/mips mipsn32el/mips mipsn32eb/mips powerpc powerpc64/powerpc sparc64 sparc64/sun4v +KNOWN_ARCHES?= amd64 arm armeb/arm i386 i386/pc98 ia64 mipsel/mips mipseb/mips mips64el/mips mips64eb/mips mipsn32el/mips mipsn32eb/mips powerpc powerpc64/powerpc sparc64 .if ${TARGET} == ${TARGET_ARCH} _t= ${TARGET} .else diff --git a/UPDATING b/UPDATING index 10db764786df..1ff9e8ffb76d 100644 --- a/UPDATING +++ b/UPDATING @@ -22,6 +22,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110513: + Support for sun4v architecture is officially dropped + 20110430: Users of the Atheros AR71xx SoC code now need to add 'device ar71xx_pci' into their kernel configurations along with 'device pci'. diff --git a/gnu/usr.bin/send-pr/categories b/gnu/usr.bin/send-pr/categories index 35c116529e67..da511e74291e 100644 --- a/gnu/usr.bin/send-pr/categories +++ b/gnu/usr.bin/send-pr/categories @@ -16,7 +16,6 @@ ports powerpc sparc64 standards -sun4v threads usb www diff --git a/gnu/usr.bin/send-pr/send-pr.1 b/gnu/usr.bin/send-pr/send-pr.1 index 36e2c5adbf88..49fd42b5df99 100644 --- a/gnu/usr.bin/send-pr/send-pr.1 +++ b/gnu/usr.bin/send-pr/send-pr.1 @@ -233,9 +233,6 @@ SPARC processor specific problems. .B standards Standards conformance issues. .TP -.B sun4v -Problems specific to the SPARC sun4v architecture and processors. -.TP .B threads Problems related to threading on FreeBSD. .TP diff --git a/lib/libc/sparc64/sys/Makefile.inc b/lib/libc/sparc64/sys/Makefile.inc index 43e4edb0012f..dedf78327eb3 100644 --- a/lib/libc/sparc64/sys/Makefile.inc +++ b/lib/libc/sparc64/sys/Makefile.inc @@ -11,9 +11,6 @@ SRCS+= __sparc_sigtramp_setup.c \ sigcode.S CFLAGS+= -I${.CURDIR}/sparc64/fpu -.if ${MACHINE} == "sun4v" -CFLAGS+= -DSUN4V -.endif MDASM+= brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction.S diff --git a/lib/libc/sparc64/sys/__sparc_utrap_gen.S b/lib/libc/sparc64/sys/__sparc_utrap_gen.S index 4fb128dd3f6a..6f6f0e3d2c57 100644 --- a/lib/libc/sparc64/sys/__sparc_utrap_gen.S +++ b/lib/libc/sparc64/sys/__sparc_utrap_gen.S @@ -38,10 +38,6 @@ __FBSDID("$FreeBSD$"); #include "assym.s" ENTRY(__sparc_utrap_gen) -#ifdef SUN4V - save - ta %xcc, ST_FPEMU_CONTEXT -#endif sub %sp, UF_SIZEOF, %sp stx %o0, [%sp + SPOFF + CCFSZ + UF_TYPE] diff --git a/lib/libdisk/Makefile b/lib/libdisk/Makefile index 47cf372e70e9..9f3e093075d7 100644 --- a/lib/libdisk/Makefile +++ b/lib/libdisk/Makefile @@ -10,11 +10,7 @@ _open_disk= open_disk.c LIB= disk SRCS= blocks.c ${_change} chunk.c create_chunk.c disk.c ${_open_disk} \ rules.c write_disk.c -.if ${MACHINE} == "sun4v" -SRCS+= write_sparc64_disk.c -.else SRCS+= write_${MACHINE}_disk.c -.endif INCS= libdisk.h diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile index cda977135213..1250bf717fb4 100644 --- a/lib/libkvm/Makefile +++ b/lib/libkvm/Makefile @@ -5,10 +5,6 @@ LIB= kvm SHLIBDIR?= /lib CFLAGS+=-DLIBC_SCCS -I${.CURDIR} -.if ${MACHINE} == "sun4v" -CFLAGS+=-DSUN4V -.endif - .if exists(${.CURDIR}/kvm_${MACHINE_ARCH}.c) KVM_ARCH=${MACHINE_ARCH} .else diff --git a/lib/libkvm/kvm_sparc64.c b/lib/libkvm/kvm_sparc64.c index a534d1da6bbf..1f925a9d500a 100644 --- a/lib/libkvm/kvm_sparc64.c +++ b/lib/libkvm/kvm_sparc64.c @@ -188,11 +188,9 @@ _kvm_initvtop(kvm_t *kd) int _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa) { -#if !defined(SUN4V) struct tte tte; off_t tte_off; u_long vpn; -#endif off_t pa_off; u_long pg_off; int rest; @@ -200,7 +198,6 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa) pg_off = va & PAGE_MASK; if (va >= VM_MIN_DIRECT_ADDRESS) pa_off = TLB_DIRECT_TO_PHYS(va) & ~PAGE_MASK; -#if !defined(SUN4V) else { vpn = btop(va); tte_off = kd->vmst->vm_tsb_off + @@ -211,7 +208,6 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa) goto invalid; pa_off = TTE_GET_PA(&tte); } -#endif rest = PAGE_SIZE - pg_off; pa_off = _kvm_find_off(kd->vmst, pa_off, rest); if (pa_off == KVM_OFF_NOTFOUND) diff --git a/release/doc/share/sgml/release.ent b/release/doc/share/sgml/release.ent index c6a60dc465f0..0a4c1ce1e881 100644 --- a/release/doc/share/sgml/release.ent +++ b/release/doc/share/sgml/release.ent @@ -57,7 +57,6 @@ - diff --git a/release/sun4v/boot_crunch.conf b/release/sun4v/boot_crunch.conf deleted file mode 100644 index bd4bc1d8c96e..000000000000 --- a/release/sun4v/boot_crunch.conf +++ /dev/null @@ -1,44 +0,0 @@ -# $FreeBSD$ - -buildopts -DRELEASE_CRUNCH -Dlint - -srcdirs /usr/src/bin -progs hostname -progs pwd -progs rm -progs sh -progs test -ln sh -sh -ln test [ - -srcdirs /usr/src/sbin -progs camcontrol -progs dhclient -progs fsck_ffs -progs ifconfig -progs mount_nfs -progs newfs -progs route -progs rtsol -progs tunefs -ln fsck_ffs fsck_4.2bsd -ln fsck_ffs fsck_ufs - -srcdirs /usr/src/usr.bin -progs cpio -progs find -progs minigzip -progs sed -ln minigzip gzip -ln minigzip gunzip -ln minigzip zcat - -srcdirs /usr/src/usr.sbin -progs arp -progs ppp -progs sysinstall -progs usbconfig - -libs -ll -ledit -lutil -lmd -lcrypt -lftpio -lz -lnetgraph -libs -lodialog -lncurses -ldisk -lcam -lsbuf -lufs -lbsdxml -libs -larchive -lcrypto -lbz2 -llzma -lusb -ljail diff --git a/release/sun4v/mkisoimages.sh b/release/sun4v/mkisoimages.sh deleted file mode 100644 index c2937cbf6ee6..000000000000 --- a/release/sun4v/mkisoimages.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -# -# Module: mkisoimages.sh -# Author: Jordan K Hubbard -# Date: 22 June 2001 -# -# $FreeBSD$ -# -# This script is used by release/Makefile to build the (optional) ISO images -# for a FreeBSD release. It is considered architecture dependent since each -# platform has a slightly unique way of making bootable CDs. This script -# is also allowed to generate any number of images since that is more of -# publishing decision than anything else. -# -# Usage: -# -# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir] -# -# Where -b is passed if the ISO image should be made "bootable" by -# whatever standards this architecture supports (may be unsupported), -# image-label is the ISO image label, image-name is the filename of the -# resulting ISO image, base-bits-dir contains the image contents and -# extra-bits-dir, if provided, contains additional files to be merged -# into base-bits-dir as part of making the image. - -publisher="The FreeBSD Project. http://www.freebsd.org/" -IMG=/tmp/bootfs -MNT=/mnt - -if [ "x$1" = "x-b" ]; then - dd if=/dev/zero of=${IMG} bs=512 count=1024 - MD=`mdconfig -a -t vnode -f ${IMG}` - sunlabel -w -B -b $4/boot/boot1 ${MD} auto - newfs -O1 -o space -m 0 /dev/${MD} - mount /dev/${MD} ${MNT} - mkdir ${MNT}/boot - cp $4/boot/loader ${MNT}/boot - umount ${MNT} - mdconfig -d -u ${MD#md} - bootable="-B ,,,,${IMG}" - shift -else - bootable="" -fi - -if [ $# -lt 3 ]; then - echo Usage: $0 '[-b] image-label image-name base-bits-dir [extra-bits-dir]' - rm -f ${IMG} - exit 1 -fi - -type mkisofs 2>&1 | grep " is " >/dev/null -if [ $? -ne 0 ]; then - echo The cdrtools port is not installed. Trying to get it now. - if [ -f /usr/ports/sysutils/cdrtools/Makefile ]; then - cd /usr/ports/sysutils/cdrtools && make install BATCH=yes && make clean - else - if ! pkg_add -r cdrtools; then - echo "Could not get it via pkg_add - please go install this" - echo "from the ports collection and run this script again." - exit 2 - fi - fi -fi - -LABEL=$1; shift -NAME=$1; shift - -echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab -mkisofs $bootable -r -J -V $LABEL -publisher "$publisher" -o $NAME $* -rm $1/etc/fstab -rm -f ${IMG} diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4 index e3594cc4b22c..b9a8c82bbd56 100644 --- a/share/man/man4/ddb.4 +++ b/share/man/man4/ddb.4 @@ -1373,7 +1373,7 @@ The kernel debugger was entered as a result of the sysctl being set. .It Dv kdb.enter.trapsig The kernel debugger was entered as a result of a trapsig event on the sparc64 -or sun4v platform. +platform. .It Dv kdb.enter.unionfs The kernel debugger was entered as a result of an assertion failure in the union file system. diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 96561b742f9e..134e4f310fba 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -257,7 +257,7 @@ When set, it also enforces the following options: Set to not build the Clang C/C++ compiler. .Pp It is a default setting on -arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mipseb, mips/mips64el, mips/mips64eb, mips/mipsn32eb, powerpc/powerpc64, sparc64/sparc64 and sun4v/sparc64. +arm/arm, arm/armeb, ia64/ia64, mips/mipsel, mips/mipseb, mips/mips64el, mips/mips64eb, mips/mipsn32eb, powerpc/powerpc64 and sparc64/sparc64. .It Va WITH_CLANG .\" from FreeBSD: head/tools/build/options/WITH_CLANG 221730 2011-05-10 11:14:40Z ru Set to build the Clang C/C++ compiler. @@ -337,7 +337,7 @@ Set to not build Flattened Device Tree support as part of the base system. This includes the device tree compiler (dtc) and libfdt support library. .Pp It is a default setting on -amd64/amd64, i386/i386, ia64/ia64, mips/mipsel, mips/mipseb, mips/mips64el, mips/mips64eb, mips/mipsn32eb, pc98/i386, powerpc/powerpc64, sparc64/sparc64 and sun4v/sparc64. +amd64/amd64, i386/i386, ia64/ia64, mips/mipsel, mips/mipseb, mips/mips64el, mips/mips64eb, mips/mipsn32eb, pc98/i386, powerpc/powerpc64 and sparc64/sparc64. .It Va WITH_FDT .\" from FreeBSD: head/tools/build/options/WITH_FDT 221730 2011-05-10 11:14:40Z ru Set to build Flattened Device Tree support as part of the base system. diff --git a/sys/Makefile b/sys/Makefile index ce604f7fd9f2..3b24ed95ca54 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -14,7 +14,7 @@ CSCOPEDIRS= boot bsm cam cddl compat conf contrib crypto ddb dev fs gdb \ netsmb nfs nfsclient nfsserver nlm opencrypto \ pci rpc security sys ufs vm xdr ${CSCOPE_ARCHDIR} .if defined(ALL_ARCH) -CSCOPE_ARCHDIR ?= amd64 arm i386 ia64 mips pc98 powerpc sparc64 sun4v x86 +CSCOPE_ARCHDIR ?= amd64 arm i386 ia64 mips pc98 powerpc sparc64 x86 .else CSCOPE_ARCHDIR ?= ${MACHINE} .endif diff --git a/sys/boot/Makefile b/sys/boot/Makefile index 6c879972f928..cfc82b98201f 100644 --- a/sys/boot/Makefile +++ b/sys/boot/Makefile @@ -13,7 +13,7 @@ SUBDIR+= fdt .endif # Pick the machine-dependent subdir based on the target architecture. -ADIR= ${MACHINE:S/amd64/i386/:S/sun4v/sparc64/:S/powerpc64/powerpc/} +ADIR= ${MACHINE:S/amd64/i386/:S/powerpc64/powerpc/} .if exists(${.CURDIR}/${ADIR}/.) SUBDIR+= ${ADIR} .endif diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8 index 94b4e6a38150..51c0ab903819 100644 --- a/sys/boot/common/loader.8 +++ b/sys/boot/common/loader.8 @@ -597,7 +597,7 @@ Modifies kernel option Limits the amount of KVM reserved for use by the buffer cache, specified in bytes. The default maximum is 200MB on i386, -and 400MB on amd64, sparc64, and sun4v. +and 400MB on amd64 and sparc64. This parameter is used to prevent the buffer cache from eating too much KVM in large-memory machine configurations. diff --git a/sys/boot/sparc64/loader/main.c b/sys/boot/sparc64/loader/main.c index dc5369847608..9a3ae58b2ddf 100644 --- a/sys/boot/sparc64/loader/main.c +++ b/sys/boot/sparc64/loader/main.c @@ -113,13 +113,11 @@ static int map_phys(int, size_t, vm_offset_t, vm_offset_t); static void release_phys(vm_offset_t, u_int); static int __elfN(exec)(struct preloaded_file *); static int mmu_mapin_sun4u(vm_offset_t, vm_size_t); -static int mmu_mapin_sun4v(vm_offset_t, vm_size_t); static vm_offset_t init_heap(void); static phandle_t find_bsp_sun4u(phandle_t, uint32_t); const char *cpu_cpuid_prop_sun4u(void); uint32_t cpu_get_mid_sun4u(void); static void tlb_init_sun4u(void); -static void tlb_init_sun4v(void); #ifdef LOADER_DEBUG typedef u_int64_t tte_t; @@ -129,7 +127,6 @@ static void pmap_print_tte_sun4u(tte_t, tte_t); #endif static struct mmu_ops mmu_ops_sun4u = { tlb_init_sun4u, mmu_mapin_sun4u }; -static struct mmu_ops mmu_ops_sun4v = { tlb_init_sun4v, mmu_mapin_sun4v }; /* sun4u */ struct tlb_entry *dtlb_store; @@ -140,16 +137,6 @@ static int cpu_impl; static u_int dtlb_slot_max; static u_int itlb_slot_max; -/* sun4v */ -static struct tlb_entry *tlb_store; -static int is_sun4v = 0; -/* - * no direct TLB access on sun4v - * we somewhat arbitrarily declare enough - * slots to cover a 4GB AS with 4MB pages - */ -#define SUN4V_TLB_SLOT_MAX (1 << 10) - static vm_offset_t curkva = 0; static vm_offset_t heapva; @@ -568,47 +555,6 @@ mmu_mapin_sun4u(vm_offset_t va, vm_size_t len) return (0); } -static int -mmu_mapin_sun4v(vm_offset_t va, vm_size_t len) -{ - vm_offset_t pa, mva; - - if (va + len > curkva) - curkva = va + len; - - pa = (vm_offset_t)-1; - len += va & PAGE_MASK_4M; - va &= ~PAGE_MASK_4M; - while (len) { - if ((va >> 22) > SUN4V_TLB_SLOT_MAX) - panic("%s: trying to map more than 4GB", __func__); - if (tlb_store[va >> 22].te_pa == -1) { - /* Allocate a physical page, claim the virtual area */ - if (pa == (vm_offset_t)-1) { - pa = alloc_phys(PAGE_SIZE_4M, PAGE_SIZE_4M); - if (pa == (vm_offset_t)-1) - panic("%s: out of memory", __func__); - mva = claim_virt(va, PAGE_SIZE_4M, 0); - if (mva != va) - panic("%s: can't claim virtual page " - "(wanted %#lx, got %#lx)", - __func__, va, mva); - } - - tlb_store[va >> 22].te_pa = pa; - if (map_phys(-1, PAGE_SIZE_4M, va, pa) == -1) - printf("%s: can't map physical page\n", - __func__); - pa = (vm_offset_t)-1; - } - len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; - va += PAGE_SIZE_4M; - } - if (pa != (vm_offset_t)-1) - release_phys(pa, PAGE_SIZE_4M); - return (0); -} - static vm_offset_t init_heap(void) { @@ -739,14 +685,6 @@ tlb_init_sun4u(void) panic("%s: can't allocate TLB store", __func__); } -static void -tlb_init_sun4v(void) -{ - - tlb_store = malloc(SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store)); - memset(tlb_store, 0xFF, SUN4V_TLB_SLOT_MAX * sizeof(*tlb_store)); -} - int main(int (*openfirm)(void *)) { @@ -777,14 +715,7 @@ main(int (*openfirm)(void *)) if ((root = OF_peer(0)) == -1) panic("%s: can't get root phandle", __func__); OF_getprop(root, "compatible", compatible, sizeof(compatible)); - if (!strcmp(compatible, "sun4v")) { - printf("\nBooting with sun4v support.\n"); - mmu_ops = &mmu_ops_sun4v; - is_sun4v = 1; - } else { - printf("\nBooting with sun4u support.\n"); - mmu_ops = &mmu_ops_sun4u; - } + mmu_ops = &mmu_ops_sun4u; mmu_ops->tlb_init(); diff --git a/sys/conf/Makefile.sun4v b/sys/conf/Makefile.sun4v deleted file mode 100644 index 947ec87ace50..000000000000 --- a/sys/conf/Makefile.sun4v +++ /dev/null @@ -1,49 +0,0 @@ -# Makefile.sparc64 -- with config changes. -# Copyright 1990 W. Jolitz -# from: @(#)Makefile.i386 7.1 5/10/91 -# $FreeBSD$ -# -# Makefile for FreeBSD -# -# This makefile is constructed from a machine description: -# config machineid -# Most changes should be made in the machine description -# /sys/sparc64/conf/``machineid'' -# after which you should do -# config machineid -# Generic makefile changes should be made in -# /sys/conf/Makefile.sparc64 -# after which config should be rerun for all machines. -# - -# Which version of config(8) is required. -%VERSREQ= 600004 - -STD8X16FONT?= iso - -.if !defined(S) -.if exists(./@/.) -S= ./@ -.else -S= ../../.. -.endif -.endif -.include "$S/conf/kern.pre.mk" - -MDOBJS= exception.o interrupt.o - -%BEFORE_DEPEND - -%OBJS - -%FILES.c - -%FILES.s - -%FILES.m - -%CLEAN - -%RULES - -.include "$S/conf/kern.post.mk" diff --git a/sys/conf/files.sun4v b/sys/conf/files.sun4v deleted file mode 100644 index 7a33442067b7..000000000000 --- a/sys/conf/files.sun4v +++ /dev/null @@ -1,111 +0,0 @@ -# This file tells config what files go into building a kernel, -# files marked standard are always included. -# -# $FreeBSD$ -# -# The long compile-with and dependency lines are required because of -# limitations in config: backslash-newline doesn't work in strings, and -# dependency lines other than the first are silently ignored. -# -atkbdmap.h optional atkbd_dflt_keymap \ - compile-with "/usr/sbin/kbdcontrol -L ${ATKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > atkbdmap.h" \ - no-obj no-implicit-rule before-depend \ - clean "atkbdmap.h" -# -ukbdmap.h optional ukbd_dflt_keymap \ - compile-with "/usr/sbin/kbdcontrol -L ${UKBD_DFLT_KEYMAP} | sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /' > ukbdmap.h" \ - no-obj no-implicit-rule before-depend \ - clean "ukbdmap.h" -# -# -crypto/blowfish/bf_enc.c optional crypto | ipsec -crypto/des/des_enc.c optional crypto | ipsec | netsmb -dev/ofw/ofw_bus_if.m standard -dev/ofw/ofw_bus_subr.c standard -dev/ofw/ofw_console.c optional ofw_console -dev/ofw/ofw_if.m standard -dev/ofw/ofw_standard.c standard -dev/ofw/openfirm.c standard -dev/ofw/openfirmio.c standard -dev/ofw/openpromio.c standard -dev/uart/uart_cpu_sparc64.c optional uart -kern/kern_clocksource.c standard -kern/syscalls.c optional ktr -libkern/ffs.c standard -libkern/ffsl.c standard -libkern/fls.c standard -libkern/flsl.c standard -libkern/memmove.c standard -sparc64/ebus/ebus.c optional ebus -sparc64/isa/isa.c optional isa -sparc64/isa/isa_dma.c optional isa -sparc64/isa/ofw_isa.c optional ebus | isa -sparc64/sparc64/autoconf.c standard -sun4v/sun4v/bus_machdep.c standard -sun4v/sun4v/clock.c standard -sparc64/sparc64/db_disasm.c optional ddb -sun4v/sun4v/db_interface.c optional ddb -sun4v/sun4v/db_trace.c optional ddb -sun4v/sun4v/db_hwwatch.c optional ddb -sun4v/sun4v/dump_machdep.c standard -sparc64/sparc64/elf_machdep.c standard -sun4v/sun4v/exception.S standard no-obj -sparc64/sparc64/gdb_machdep.c optional gdb -sun4v/sun4v/hv_pci.c optional pci -sun4v/sun4v/trap_trace.S optional trap_tracing -sparc64/pci/ofw_pcib.c optional pci -sparc64/pci/ofw_pcib_subr.c optional pci -sparc64/pci/ofw_pcibus.c optional pci -sparc64/pci/ofw_pci_if.m optional pci - -# XXX hvcons should be optional -sun4v/sun4v/hvcons.c standard -sun4v/sun4v/hcall.S standard -sun4v/sun4v/hviommu.c standard -sparc64/sparc64/identcpu.c standard -sparc64/sparc64/in_cksum.c optional inet | inet6 -sun4v/sun4v/interrupt.S standard no-obj -sun4v/sun4v/intr_machdep.c standard -sun4v/sun4v/locore.S standard no-obj -sun4v/sun4v/machdep.c standard -sparc64/sparc64/mem.c optional mem -sun4v/sun4v/mp_exception.S optional smp -sun4v/sun4v/mp_locore.S optional smp -sun4v/sun4v/mp_machdep.c optional smp -sun4v/sun4v/nexus.c standard -sun4v/cddl/t1_copy.S standard -sparc64/sparc64/ofw_machdep.c standard -sun4v/sun4v/pmap.c standard -sparc64/sparc64/prof_machdep.c optional profiling-routine -sparc64/sparc64/rwindow.c standard -sun4v/sun4v/rtc.c standard -sun4v/sun4v/simdisk.c optional simulator -sun4v/sun4v/stack_machdep.c optional ddb | stack -sun4v/sun4v/support.S standard -sparc64/sparc64/sys_machdep.c standard -sun4v/sun4v/swtch.S standard -sun4v/sun4v/tsb.c standard -sun4v/sun4v/tte.c standard -sun4v/sun4v/tte_hash.c standard -sun4v/sun4v/tick.c standard -sun4v/sun4v/trap.c standard -sun4v/sun4v/uio_machdep.c standard -sun4v/sun4v/vm_machdep.c standard -sun4v/sun4v/vnex.c standard -sun4v/dev/vnet.c optional vnet - - -sun4v/mdesc/mdesc_bus_if.m standard -sun4v/mdesc/mdesc_init.c standard -sun4v/mdesc/mdesc_subr.c standard -sun4v/mdesc/mdesc_bus_subr.c standard -sun4v/cddl/mdesc/mdesc_findname.c standard -sun4v/cddl/mdesc/mdesc_getpropstr.c standard -sun4v/cddl/mdesc/mdesc_getpropval.c standard -sun4v/cddl/mdesc/mdesc_init_intern.c standard -sun4v/cddl/mdesc/mdesc_nodecount.c standard -sun4v/cddl/mdesc/mdesc_findnodeprop.c standard -sun4v/cddl/mdesc/mdesc_rootnode.c standard -sun4v/cddl/mdesc/mdesc_scandag.c standard -sun4v/mdesc/mdesc_vdevfindnode.c standard -sun4v/mdesc/mdesc_vdevfindval.c standard diff --git a/sys/conf/options.sun4v b/sys/conf/options.sun4v deleted file mode 100644 index 54c0fe2d93a9..000000000000 --- a/sys/conf/options.sun4v +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD$ - -SUN4V opt_global.h - -OFW_PCI_DEBUG opt_ofw_pci.h -OFWCONS_POLL_HZ opt_ofw.h -# Debug IOMMU inserts/removes using diagnostic accesses. Very loud. -IOMMU_DIAG opt_iommu.h -PMAP_STATS opt_pmap.h -SIMULATOR opt_simulator.h - -DTRACE opt_global.h - -TRAP_TRACING opt_trap_trace.h -TRAP_TRACE_ENTRIES opt_trap_trace.h diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c index 35dc3df3631c..d8609bb899a0 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c @@ -277,7 +277,7 @@ ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan) /* * Enable IQ, ADC Gain, ADC DC Offset Cals */ - if (AR_SREV_SOWL_10_OR_LATER(ah)) { + if (AR_SREV_HOWL(ah) || AR_SREV_SOWL_10_OR_LATER(ah)) { /* Setup all non-periodic, init time only calibrations */ /* XXX: Init DC Offset not working yet */ #if 0 diff --git a/sys/dev/ath/ath_rate/sample/tx_schedules.h b/sys/dev/ath/ath_rate/sample/tx_schedules.h index b0fd4e02ea38..d8e9f325dfee 100644 --- a/sys/dev/ath/ath_rate/sample/tx_schedules.h +++ b/sys/dev/ath/ath_rate/sample/tx_schedules.h @@ -172,7 +172,7 @@ static const struct txschedule series_half[] = { #undef H #ifdef Q -#undef Q /* sun4v bogosity */ +#undef Q #endif #define Q(_r) \ (((_r) == 1.5) ? 0 : (((_r) ==2.25) ? 1 : (((_r) == 3) ? 2 : \ diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index 5e23b34f2095..b293d7ff8bab 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -119,17 +119,11 @@ static int ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de, /* * Vnode op for reading directories. * - * The routine below assumes that the on-disk format of a directory - * is the same as that defined by . If the on-disk - * format changes, then it will be necessary to do a conversion - * from the on-disk format that read returns to the format defined - * by . - */ -/* - * this is exactly what we do here - the problem is that the conversion - * will blow up some entries by four bytes, so it can't be done in place. - * This is too bad. Right now the conversion is done entry by entry, the - * converted entry is sent via uiomove. + * This function has to convert directory entries from the on-disk + * format to the format defined by . Unfortunately, the + * conversion will blow up some entries by four bytes, so it can't be + * done in place. Instead, the conversion is done entry by entry and + * the converted entry is sent via uiomove. * * XXX allocate a buffer, convert as many entries as possible, then send * the whole buffer to uiomove diff --git a/sys/modules/mem/Makefile b/sys/modules/mem/Makefile index 952f50f1ca26..3710c5dca630 100644 --- a/sys/modules/mem/Makefile +++ b/sys/modules/mem/Makefile @@ -14,18 +14,4 @@ SRCS+= amd64_mem.c .endif SRCS+= bus_if.h device_if.h -.if ${MACHINE} == "sun4v" -SRCS+= opt_global.h - -.if defined(KERNBUILDDIR) -MKDEP= -include ${KERNBUILDDIR}/opt_global.h -.else -CFLAGS+= -include opt_global.h -MKDEP= -include opt_global.h - -opt_global.h: - echo "#define SUN4V 1" > ${.TARGET} -.endif -.endif - .include diff --git a/sys/modules/uart/Makefile b/sys/modules/uart/Makefile index 1a5ce4436da5..9afb86cf80b8 100644 --- a/sys/modules/uart/Makefile +++ b/sys/modules/uart/Makefile @@ -14,9 +14,7 @@ SRCS= uart_bus_acpi.c ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \ uart_dev_ns8250.c uart_dev_quicc.c uart_dev_sab82532.c \ uart_dev_z8530.c \ uart_if.c uart_if.h uart_subr.c uart_tty.c -.if ${MACHINE} == "sun4v" -SRCS+= uart_cpu_sparc64.c -.elif exists(${.CURDIR}/../../dev/uart/uart_cpu_${MACHINE}.c) +.if exists(${.CURDIR}/../../dev/uart/uart_cpu_${MACHINE}.c) SRCS+= uart_cpu_${MACHINE}.c .endif SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \ diff --git a/sys/sparc64/sparc64/autoconf.c b/sys/sparc64/sparc64/autoconf.c index 68161566d896..394fa320f7d2 100644 --- a/sys/sparc64/sparc64/autoconf.c +++ b/sys/sparc64/sparc64/autoconf.c @@ -66,9 +66,6 @@ static void configure(void *dummy) { -#ifdef SUN4V - intr_restore_all(0x16); -#endif root_bus_configure(); #ifdef DEV_ISA /* diff --git a/sys/sparc64/sparc64/genassym.c b/sys/sparc64/sparc64/genassym.c index 2d1e901e3e2b..89ec718b94a2 100644 --- a/sys/sparc64/sparc64/genassym.c +++ b/sys/sparc64/sparc64/genassym.c @@ -46,18 +46,11 @@ __FBSDID("$FreeBSD$"); #ifdef SUN4U #include #endif -#ifdef SUN4V -#include -#endif #include #include #include #include #include -#ifdef SUN4V -#include -#include -#endif #include ASSYM(KERNBASE, KERNBASE); @@ -96,9 +89,6 @@ ASSYM(CSA_TICK, offsetof(struct cpu_start_args, csa_tick)); ASSYM(CSA_TTES, offsetof(struct cpu_start_args, csa_ttes)); ASSYM(CSA_VER, offsetof(struct cpu_start_args, csa_ver)); #endif -#ifdef SUN4V -ASSYM(CSA_CPUID, offsetof(struct cpu_start_args, csa_cpuid)); -#endif #endif #ifdef SUN4U @@ -144,20 +134,6 @@ ASSYM(TLB_DIRECT_TO_TTE_MASK, TLB_DIRECT_TO_TTE_MASK); ASSYM(TV_SIZE_BITS, TV_SIZE_BITS); #endif -#ifdef SUN4V -ASSYM(VTD_REF, VTD_REF); -ASSYM(VTD_W, VTD_W); -ASSYM(VTD_SW_W, VTD_SW_W); -ASSYM(VTD_LOCK, VTD_LOCK); - -ASSYM(THE_SHIFT, THE_SHIFT); -ASSYM(PM_HASHSCRATCH, offsetof(struct pmap, pm_hashscratch)); -ASSYM(PM_TSBSCRATCH, offsetof(struct pmap, pm_tsbscratch)); -ASSYM(PM_TSB_RA, offsetof(struct pmap, pm_tsb_ra)); -ASSYM(PM_TLBACTIVE, offsetof(struct pmap, pm_tlbactive)); -ASSYM(HASH_ENTRY_SHIFT, HASH_ENTRY_SHIFT); -#endif - ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); ASSYM(MAXCOMLEN, MAXCOMLEN); @@ -170,35 +146,6 @@ ASSYM(PC_IRFREE, offsetof(struct pcpu, pc_irfree)); ASSYM(PC_CNT, offsetof(struct pcpu, pc_cnt)); ASSYM(PC_SIZEOF, sizeof(struct pcpu)); -#ifdef SUN4V -ASSYM(PC_CPU_Q_RA, offsetof(struct pcpu, pc_cpu_q_ra)); -ASSYM(PC_CPU_Q_SIZE, offsetof(struct pcpu, pc_cpu_q_size)); -ASSYM(PC_DEV_Q_RA, offsetof(struct pcpu, pc_dev_q_ra)); -ASSYM(PC_DEV_Q_SIZE, offsetof(struct pcpu, pc_dev_q_size)); - -ASSYM(PC_RQ_BASE, offsetof(struct pcpu, pc_rq_ra)); -ASSYM(PC_RQ_SIZE, offsetof(struct pcpu, pc_rq_size)); -ASSYM(PC_NRQ_BASE, offsetof(struct pcpu, pc_nrq_ra)); -ASSYM(PC_NRQ_SIZE, offsetof(struct pcpu, pc_nrq_size)); -ASSYM(PC_MONDO_DATA, offsetof(struct pcpu, pc_mondo_data)); -ASSYM(PC_MONDO_DATA_RA, offsetof(struct pcpu, pc_mondo_data_ra)); - -ASSYM(PC_KWBUF_FULL, offsetof(struct pcpu, pc_kwbuf_full)); -ASSYM(PC_KWBUF_SP, offsetof(struct pcpu, pc_kwbuf_sp)); -ASSYM(PC_KWBUF, offsetof(struct pcpu, pc_kwbuf)); -ASSYM(PC_PAD, offsetof(struct pcpu, pad)); -ASSYM(PC_PMAP, offsetof(struct pcpu, pc_curpmap)); -ASSYM(PC_TSBWBUF, offsetof(struct pcpu, pc_tsbwbuf)); - -ASSYM(PCB_KSTACK, offsetof(struct pcb, pcb_kstack)); -ASSYM(PCB_TSTATE, offsetof(struct pcb, pcb_tstate)); -ASSYM(PCB_TPC, offsetof(struct pcb, pcb_tpc)); -ASSYM(PCB_TNPC, offsetof(struct pcb, pcb_tnpc)); -ASSYM(PCB_TT, offsetof(struct pcb, pcb_tt)); -ASSYM(PCB_SFAR, offsetof(struct pcb, pcb_sfar)); -ASSYM(PM_TSB_MISS_COUNT, offsetof(struct pmap, pm_tsb_miss_count)); -ASSYM(PM_TSB_CAP_MISS_COUNT, offsetof(struct pmap, pm_tsb_cap_miss_count)); -#endif #ifdef SUN4U ASSYM(PC_CACHE, offsetof(struct pcpu, pc_cache)); ASSYM(PC_MID, offsetof(struct pcpu, pc_mid)); @@ -300,9 +247,6 @@ ASSYM(TF_TAR, offsetof(struct trapframe, tf_tar)); ASSYM(TF_TYPE, offsetof(struct trapframe, tf_type)); ASSYM(TF_Y, offsetof(struct trapframe, tf_y)); #endif -#ifdef SUN4V -ASSYM(TF_ASI, offsetof(struct trapframe, tf_asi)); -#endif ASSYM(TF_TNPC, offsetof(struct trapframe, tf_tnpc)); ASSYM(TF_TPC, offsetof(struct trapframe, tf_tpc)); ASSYM(TF_TSTATE, offsetof(struct trapframe, tf_tstate)); diff --git a/sys/sparc64/sparc64/mem.c b/sys/sparc64/sparc64/mem.c index e7ab8e40451b..68c397e2f3f8 100644 --- a/sys/sparc64/sparc64/mem.c +++ b/sys/sparc64/sparc64/mem.c @@ -69,9 +69,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifndef SUN4V #include -#endif #include #include #include @@ -137,18 +135,14 @@ memrw(struct cdev *dev, struct uio *uio, int flags) if (m != NULL) { if (ova == 0) { -#ifndef SUN4V if (dcache_color_ignore == 0) colors = DCACHE_COLORS; -#endif ova = kmem_alloc_wait(kernel_map, PAGE_SIZE * colors); } -#ifndef SUN4V if (colors != 1 && m->md.color != -1) va = ova + m->md.color * PAGE_SIZE; else -#endif va = ova; pmap_qenter(va, &m, 1); error = uiomove((void *)(va + off), cnt, diff --git a/sys/sun4v/cddl/mdesc/mdesc_diff.c b/sys/sun4v/cddl/mdesc/mdesc_diff.c deleted file mode 100644 index 4bd2334730c7..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_diff.c +++ /dev/null @@ -1,603 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mdesc_diff.c 1.1 06/05/16 SMI" - -#include -#ifdef _KERNEL -#include -#else /* _KERNEL */ -#include -#include -#endif /* _KERNEL */ -#include -#include -#include - -#define MDD_FREE_CHECK(mdp, ptr, sz) \ - do { \ - if (ptr) mdp->freep(ptr, sz); \ - _NOTE(CONSTCOND) } while (0) - -#define MD_DIFF_MAGIC 0x4D445F4449464621ull /* 'MD_DIFF!' */ -#define MD_DIFF_NOMATCH (-1) -#define MD_DIFF_MATCH (1) - -typedef struct { - mde_cookie_t *mdep; - uint_t nelem; -} md_diff_t; - -typedef struct { - uint64_t mdd_magic; - md_diff_t added; - md_diff_t removed; - md_diff_t match1; - md_diff_t match2; - void *(*allocp)(size_t); - void (*freep)(void *, size_t); -} md_diff_impl_t; - -/* - * Internal utility functions - */ -static int mdd_scan_for_nodes(md_t *mdp, mde_cookie_t start, - char *compnodep, int *countp, mde_cookie_t **nodespp); - -static boolean_t mdd_any_dup_nodes(md_impl_t *mdp, md_prop_match_t *pmp, - int count, mde_cookie_t *nodesp); - -static int mdd_node_list_match(md_impl_t *md1, md_impl_t *md2, - md_element_t *match_nodep, mde_cookie_t *match_listp, - uint8_t *match_seenp, int start, int end, md_prop_match_t *match_elemsp); - -static int mdd_node_compare(md_impl_t *mdap, md_impl_t *mdbp, - md_element_t *nodeap, md_element_t *nodebp, md_prop_match_t *match_elemsp); - -/* - * Given two DAGs and information about how to uniquely identify - * the nodes of interest, determine which nodes have been added - * to the second MD, removed from the first MD, or exist in both - * MDs. This information is recorded and can be accessed using the - * opaque cookie returned to the caller. - */ -md_diff_cookie_t -md_diff_init(md_t *md1p, mde_cookie_t start1, md_t *md2p, mde_cookie_t start2, - char *compnodep, md_prop_match_t *match_fieldsp) -{ - int idx; - md_impl_t *md1 = (md_impl_t *)md1p; - md_impl_t *md2 = (md_impl_t *)md2p; - mde_cookie_t *md1nodesp = NULL; - mde_cookie_t *md2nodesp = NULL; - int md1count = 0; - int md2count = 0; - uint8_t *seenp = NULL; - - /* variables used to gather results */ - md_diff_impl_t *diff_res; - mde_cookie_t *mde_add_scr; - mde_cookie_t *mde_rem_scr; - mde_cookie_t *mde_match1_scr; - mde_cookie_t *mde_match2_scr; - int nadd = 0; - int nrem = 0; - int nmatch = 0; - - /* sanity check params */ - if ((md1p == NULL) || (md2p == NULL)) - return (MD_INVAL_DIFF_COOKIE); - - if ((start1 == MDE_INVAL_ELEM_COOKIE) || - (start2 == MDE_INVAL_ELEM_COOKIE)) - return (MD_INVAL_DIFF_COOKIE); - - if ((compnodep == NULL) || (match_fieldsp == NULL)) - return (MD_INVAL_DIFF_COOKIE); - - /* - * Prepare an array of the matching nodes from the first MD. - */ - if (mdd_scan_for_nodes(md1p, - start1, compnodep, &md1count, &md1nodesp) == -1) - return (MD_INVAL_DIFF_COOKIE); - - /* sanity check that all nodes are unique */ - if (md1nodesp && - mdd_any_dup_nodes(md1, match_fieldsp, md1count, md1nodesp)) { - MDD_FREE_CHECK(md1, md1nodesp, sizeof (mde_cookie_t) * - md1count); - return (MD_INVAL_DIFF_COOKIE); - } - - - /* - * Prepare an array of the matching nodes from the second MD. - */ - if (mdd_scan_for_nodes(md2p, - start2, compnodep, &md2count, &md2nodesp) == -1) - return (MD_INVAL_DIFF_COOKIE); - - /* sanity check that all nodes are unique */ - if (md2nodesp && - mdd_any_dup_nodes(md2, match_fieldsp, md2count, md2nodesp)) { - MDD_FREE_CHECK(md1, md1nodesp, sizeof (mde_cookie_t) * - md1count); - MDD_FREE_CHECK(md2, md2nodesp, sizeof (mde_cookie_t) * - md2count); - return (MD_INVAL_DIFF_COOKIE); - } - - /* setup our result structure */ - diff_res = md1->allocp(sizeof (md_diff_impl_t)); - bzero(diff_res, sizeof (md_diff_impl_t)); - diff_res->allocp = md1->allocp; - diff_res->freep = md1->freep; - diff_res->mdd_magic = MD_DIFF_MAGIC; - - /* - * Special cases for empty lists - */ - if ((md1count == 0) && (md2count != 0)) { - /* all the nodes found were added */ - diff_res->added.mdep = md2nodesp; - diff_res->added.nelem = md2count; - return ((mde_cookie_t)diff_res); - } - - if ((md1count != 0) && (md2count == 0)) { - /* all the nodes found were removed */ - diff_res->removed.mdep = md1nodesp; - diff_res->removed.nelem = md1count; - return ((mde_cookie_t)diff_res); - } - - if ((md1count == 0) && (md2count == 0)) - /* no nodes found */ - return ((mde_cookie_t)diff_res); - - /* - * Both lists have some elements. Allocate some scratch - * buffers to sort them into our three categories, added, - * removed, and matched pairs. - */ - mde_add_scr = diff_res->allocp(sizeof (mde_cookie_t) * md2count); - mde_rem_scr = diff_res->allocp(sizeof (mde_cookie_t) * md1count); - mde_match1_scr = diff_res->allocp(sizeof (mde_cookie_t) * md1count); - mde_match2_scr = diff_res->allocp(sizeof (mde_cookie_t) * md2count); - - /* array of seen flags only needed for md2 */ - seenp = (uint8_t *)diff_res->allocp(sizeof (uint8_t) * md2count); - bzero(seenp, sizeof (uint8_t) * md2count); - - /* - * Make a pass through the md1 node array. Make note of - * any nodes not in the md2 array, indicating that they - * have been removed. Also keep track of the nodes that - * are present in both arrays for the matched pair results. - */ - for (idx = 0; idx < md1count; idx++) { - - md_element_t *elem = &(md1->mdep[md1nodesp[idx]]); - - int match = mdd_node_list_match(md1, md2, elem, md2nodesp, - seenp, 0, md2count - 1, match_fieldsp); - - if (match == MD_DIFF_NOMATCH) - /* record deleted node */ - mde_rem_scr[nrem++] = md1nodesp[idx]; - else { - /* record matched node pair */ - mde_match1_scr[nmatch] = md1nodesp[idx]; - mde_match2_scr[nmatch] = md2nodesp[match]; - nmatch++; - - /* mark that this match has been recorded */ - seenp[match] = 1; - } - } - - /* - * Make a pass through the md2 array. Any nodes that have - * not been marked as seen have been added. - */ - for (idx = 0; idx < md2count; idx++) { - if (!seenp[idx]) - /* record added node */ - mde_add_scr[nadd++] = md2nodesp[idx]; - } - - /* fill in the added node list */ - if (nadd) { - int addsz = sizeof (mde_cookie_t) * nadd; - diff_res->added.mdep = (mde_cookie_t *)diff_res->allocp(addsz); - - bcopy(mde_add_scr, diff_res->added.mdep, addsz); - - diff_res->added.nelem = nadd; - } - - /* fill in the removed node list */ - if (nrem) { - int remsz = sizeof (mde_cookie_t) * nrem; - diff_res->removed.mdep = - (mde_cookie_t *)diff_res->allocp(remsz); - - bcopy(mde_rem_scr, diff_res->removed.mdep, remsz); - diff_res->removed.nelem = nrem; - } - - /* fill in the matching node lists */ - if (nmatch) { - int matchsz = sizeof (mde_cookie_t) * nmatch; - diff_res->match1.mdep = - (mde_cookie_t *)diff_res->allocp(matchsz); - diff_res->match2.mdep = - (mde_cookie_t *)diff_res->allocp(matchsz); - - bcopy(mde_match1_scr, diff_res->match1.mdep, matchsz); - bcopy(mde_match2_scr, diff_res->match2.mdep, matchsz); - diff_res->match1.nelem = nmatch; - diff_res->match2.nelem = nmatch; - } - - /* clean up */ - md1->freep(md1nodesp, sizeof (mde_cookie_t) * md1count); - md2->freep(md2nodesp, sizeof (mde_cookie_t) * md2count); - - diff_res->freep(mde_add_scr, sizeof (mde_cookie_t) * md2count); - diff_res->freep(mde_rem_scr, sizeof (mde_cookie_t) * md1count); - diff_res->freep(mde_match1_scr, sizeof (mde_cookie_t) * md1count); - diff_res->freep(mde_match2_scr, sizeof (mde_cookie_t) * md2count); - - diff_res->freep(seenp, sizeof (uint8_t) * md2count); - - return ((md_diff_cookie_t)diff_res); -} - -/* - * Returns an array of the nodes added to the second MD in a - * previous md_diff_init() call. Returns the number of elements - * in the returned array. If the value is zero, the pointer - * passed back will be NULL. - */ -int -md_diff_added(md_diff_cookie_t mdd, mde_cookie_t **mde_addedp) -{ - md_diff_impl_t *mddp = (md_diff_impl_t *)mdd; - - if ((mddp == NULL) || (mddp->mdd_magic != MD_DIFF_MAGIC)) - return (-1); - - *mde_addedp = mddp->added.mdep; - - return (mddp->added.nelem); -} - -/* - * Returns an array of the nodes removed from the first MD in a - * previous md_diff_init() call. Returns the number of elements - * in the returned array. If the value is zero, the pointer - * passed back will be NULL. - */ -int -md_diff_removed(md_diff_cookie_t mdd, mde_cookie_t **mde_removedp) -{ - md_diff_impl_t *mddp = (md_diff_impl_t *)mdd; - - if ((mddp == NULL) || (mddp->mdd_magic != MD_DIFF_MAGIC)) - return (-1); - - *mde_removedp = mddp->removed.mdep; - - return (mddp->removed.nelem); -} - -/* - * Returns a pair of parallel arrays that contain nodes that were - * considered matching based on the match criteria passed in to - * a previous md_diff_init() call. Returns the number of elements - * in the arrays. If the value is zero, both pointers passed back - * will be NULL. - */ -int -md_diff_matched(md_diff_cookie_t mdd, mde_cookie_t **mde_match1p, - mde_cookie_t **mde_match2p) -{ - md_diff_impl_t *mddp = (md_diff_impl_t *)mdd; - - if ((mddp == NULL) || (mddp->mdd_magic != MD_DIFF_MAGIC)) - return (-1); - - *mde_match1p = mddp->match1.mdep; - *mde_match2p = mddp->match2.mdep; - - return (mddp->match1.nelem); -} - -/* - * Deallocate any storage used to store results of a previous - * md_diff_init() call. Returns 0 on success and -1 on failure. - */ -int -md_diff_fini(md_diff_cookie_t mdd) -{ - md_diff_impl_t *mddp = (md_diff_impl_t *)mdd; - - if ((mddp == NULL) || (mddp->mdd_magic != MD_DIFF_MAGIC)) - return (-1); - - mddp->mdd_magic = 0; - - MDD_FREE_CHECK(mddp, mddp->added.mdep, mddp->added.nelem * - sizeof (mde_cookie_t)); - - MDD_FREE_CHECK(mddp, mddp->removed.mdep, mddp->removed.nelem * - sizeof (mde_cookie_t)); - - MDD_FREE_CHECK(mddp, mddp->match1.mdep, mddp->match1.nelem * - sizeof (mde_cookie_t)); - - MDD_FREE_CHECK(mddp, mddp->match2.mdep, mddp->match2.nelem * - sizeof (mde_cookie_t)); - - mddp->freep(mddp, sizeof (md_diff_impl_t)); - - return (0); -} - -/* - * Walk the "fwd" DAG in an MD and return an array of nodes that are - * of the specified type. The start param is used to start the walk - * from an arbitrary location in the DAG. Returns an array of nodes - * as well as a count of the number of nodes in the array. If the - * count is zero, the node pointer will be passed back as NULL. - * - * Returns: 0 success; -1 failure - */ -static int -mdd_scan_for_nodes(md_t *mdp, - mde_cookie_t start, char *compnodep, int *countp, mde_cookie_t **nodespp) -{ - mde_str_cookie_t cname; - mde_str_cookie_t aname; - md_impl_t *mdip = (md_impl_t *)mdp; - - if (mdip == NULL) - return (-1); - - cname = md_find_name(mdp, compnodep); - aname = md_find_name(mdp, "fwd"); - - /* get the number of nodes of interest in the DAG */ - *countp = md_scan_dag(mdp, start, cname, aname, NULL); - if (*countp == 0) { - *nodespp = NULL; - return (0); - } - - /* allocate the storage */ - *nodespp = mdip->allocp(sizeof (mde_cookie_t) * (*countp)); - - /* populate our array with the matching nodes */ - (void) md_scan_dag(mdp, start, cname, aname, *nodespp); - - return (0); -} - -/* - * Walk an array of nodes and check if there are any duplicate - * nodes. A duplicate is determined based on the specified match - * criteria. Returns B_TRUE if there are any duplicates and B_FALSE - * otherwise. - */ -static boolean_t -mdd_any_dup_nodes(md_impl_t *mdp, md_prop_match_t *pmp, int count, - mde_cookie_t *nodesp) -{ - int idx; - int match; - md_element_t *elem; - - ASSERT(count > 0 || nodesp == NULL); - - for (idx = 0; idx < count; idx++) { - elem = &(mdp->mdep[nodesp[idx]]); - - match = mdd_node_list_match(mdp, mdp, elem, nodesp, NULL, - idx + 1, count - 1, pmp); - - if (match != MD_DIFF_NOMATCH) - return (B_TRUE); - } - - return (B_FALSE); -} - -/* - * Given a node and a array of nodes, compare the node to all elements - * in the specified start-end range of the array. If the node matches - * one of the nodes in the array, return the index of that node. Otherwise - * return MD_DIFF_NOMATCH. - * - * The optional seen array parameter can be used to optimize repeated - * calls to this function. If the seen array indicates that an element - * has already been matched, the full comparison is not necessary. - */ -static int -mdd_node_list_match(md_impl_t *md1, md_impl_t *md2, md_element_t *match_nodep, - mde_cookie_t *match_listp, uint8_t *match_seenp, int start, int end, - md_prop_match_t *match_elemsp) -{ - int match; - int idx; - md_element_t *elem; - - for (idx = start; idx <= end; idx++) { - - if ((match_seenp != NULL) && (match_seenp[idx])) - continue; - - elem = &(md2->mdep[match_listp[idx]]); - - match = mdd_node_compare(md1, md2, match_nodep, elem, - match_elemsp); - if (match == MD_DIFF_MATCH) - return (idx); - } - - return (MD_DIFF_NOMATCH); -} - -/* - * Given two nodes and a list of properties, compare the nodes. - * A match is concluded if both nodes have all of the specified - * properties and all the values of those properties are the - * same. Returns MD_DIFF_NOMATCH if the nodes do not match and - * MD_DIFF_MATCH otherwise. - */ -static int -mdd_node_compare(md_impl_t *mdap, md_impl_t *mdbp, md_element_t *nodeap, - md_element_t *nodebp, md_prop_match_t *match_elemsp) -{ - md_element_t *ap; - md_element_t *bp; - boolean_t nodea_interest; - boolean_t nodeb_interest; - int idx; - - /* make sure we are starting at the beginning of the nodes */ - if ((MDE_TAG(nodeap) != MDET_NODE) || (MDE_TAG(nodebp) != MDET_NODE)) - return (MD_DIFF_NOMATCH); - - for (idx = 0; match_elemsp[idx].type != MDET_LIST_END; idx++) { - - int type; - - nodea_interest = B_FALSE; - nodeb_interest = B_FALSE; - - type = match_elemsp[idx].type; - - /* - * Check node A for the property of interest - */ - for (ap = nodeap; MDE_TAG(ap) != MDET_NODE_END; ap++) { - char *elemname; - - if (MDE_TAG(ap) != type) - continue; - - elemname = mdap->namep + MDE_NAME(ap); - - if (strcmp(elemname, match_elemsp[idx].namep) == 0) { - /* found the property of interest */ - nodea_interest = B_TRUE; - break; - } - } - - /* node A is not of interest */ - if (!nodea_interest) - return (MD_DIFF_NOMATCH); - - /* - * Check node B for the property of interest - */ - for (bp = nodebp; MDE_TAG(bp) != MDET_NODE_END; bp++) { - char *elemname; - - if (MDE_TAG(bp) != type) - continue; - - elemname = mdbp->namep + MDE_NAME(bp); - - if (strcmp(elemname, match_elemsp[idx].namep) == 0) { - nodeb_interest = B_TRUE; - break; - } - } - - /* node B is not of interest */ - if (!nodeb_interest) - return (MD_DIFF_NOMATCH); - - /* - * Both nodes have the property of interest. The - * nodes are not a match unless the value of that - * property match - */ - switch (type) { - case MDET_PROP_VAL: - if (MDE_PROP_VALUE(ap) != MDE_PROP_VALUE(bp)) - return (MD_DIFF_NOMATCH); - break; - - case MDET_PROP_STR: { - char *stra = (char *)(mdap->datap + - MDE_PROP_DATA_OFFSET(ap)); - char *strb = (char *)(mdbp->datap + - MDE_PROP_DATA_OFFSET(bp)); - - if (strcmp(stra, strb) != 0) - return (MD_DIFF_NOMATCH); - break; - } - - case MDET_PROP_DAT: { - - caddr_t dataa; - caddr_t datab; - - if (MDE_PROP_DATA_LEN(ap) != MDE_PROP_DATA_LEN(bp)) - return (MD_DIFF_NOMATCH); - - dataa = (caddr_t)(mdap->datap + - MDE_PROP_DATA_OFFSET(ap)); - datab = (caddr_t)(mdbp->datap + - MDE_PROP_DATA_OFFSET(bp)); - - if (memcmp(dataa, datab, MDE_PROP_DATA_LEN(ap)) != 0) - return (MD_DIFF_NOMATCH); - - break; - } - - default: - /* unsupported prop type */ - return (MD_DIFF_NOMATCH); - } - } - - /* - * All the specified properties exist in both - * nodes and have the same value. The two nodes - * match. - */ - - return (MD_DIFF_MATCH); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_findname.c b/sys/sun4v/cddl/mdesc/mdesc_findname.c deleted file mode 100644 index c9616192a113..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_findname.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - - -#include - -#ifdef _KERNEL -#include -#else -#include -#endif - -#include -#include - -mde_str_cookie_t -md_find_name(md_t *ptr, char *namep) -{ - int idx, len; - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - /* - * At some point init should build a local hash table to - * speed these name searches ... for now use brute force - * because the machien descriptions are so small anyway. - */ - - for (idx = 0; idx < mdp->name_blk_size; idx += len) { - char *p; - - p = &(mdp->namep[idx]); - - len = strlen(p)+1; - - if (strcmp(p, namep) == 0) - return ((mde_str_cookie_t)idx); - } - - return (MDE_INVAL_STR_COOKIE); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_findnodeprop.c b/sys/sun4v/cddl/mdesc/mdesc_findnodeprop.c deleted file mode 100644 index 558b97631b17..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_findnodeprop.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include -#include -#include -#include - -mde_cookie_t -md_find_node_prop(md_impl_t *mdp, - mde_cookie_t node, - mde_str_cookie_t prop_name, - int tag_type) -{ - md_element_t *mdep; - int idx; - - if (node == MDE_INVAL_ELEM_COOKIE || - prop_name == MDE_INVAL_STR_COOKIE) { - return (MDE_INVAL_ELEM_COOKIE); - } - - idx = (int)node; - mdep = &(mdp->mdep[idx]); - - /* Skip over any empty elements */ - while (MDE_TAG(mdep) == MDET_NULL) { - idx++; - mdep++; - } - - /* see if cookie is infact a node */ - if (MDE_TAG(mdep) != MDET_NODE) { - return (MDE_INVAL_ELEM_COOKIE); - } - - /* - * Simply walk the elements in the node - * looking for a property with a matching name. - */ - - for (idx++, mdep++; MDE_TAG(mdep) != MDET_NODE_END; idx++, mdep++) { - if (MDE_TAG(mdep) == tag_type) { - if (MDE_NAME(mdep) == prop_name) { - return ((mde_cookie_t)idx); - } - } - } - - return (MDE_INVAL_ELEM_COOKIE); /* no such property name */ -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_fini.c b/sys/sun4v/cddl/mdesc/mdesc_fini.c deleted file mode 100644 index ff32ce8c8b50..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_fini.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mdesc_fini.c 1.4 06/05/16 SMI" - -#include -#include -#include - -/* - * Cleanup the internal MD structure. Does not - * deallocate the buffer holding the MD. - */ -int -md_fini(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - mdp->freep(mdp, sizeof (md_impl_t)); - - return (0); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_getbinsize.c b/sys/sun4v/cddl/mdesc/mdesc_getbinsize.c deleted file mode 100644 index c3e2386c86e7..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_getbinsize.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mdesc_getbinsize.c 1.1 06/05/16 SMI" - -#include -#include -#include -#include - -size_t -md_get_bin_size(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - if (mdp == NULL) - return (0); - - return (mdp->size); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_getgen.c b/sys/sun4v/cddl/mdesc/mdesc_getgen.c deleted file mode 100644 index 7d1ad5198b46..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_getgen.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mdesc_getgen.c 1.1 06/05/16 SMI" - -#include -#include -#include -#include - -uint64_t -md_get_gen(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - if (mdp == NULL) - return (MDESC_INVAL_GEN); - - return (mdp->gen); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_getpropdata.c b/sys/sun4v/cddl/mdesc/mdesc_getpropdata.c deleted file mode 100644 index 199a4362e498..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_getpropdata.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "@(#)mdesc_getpropdata.c 1.2 05/06/08 SMI" - -#include -#include -#include - -int -md_get_prop_data(md_t *ptr, mde_cookie_t node, char *namep, - uint8_t **datap, int *lenp) -{ - mde_str_cookie_t prop_name; - md_impl_t *mdp; - mde_cookie_t elem; - - mdp = (md_impl_t *)ptr; - - if (node == MDE_INVAL_ELEM_COOKIE) { - return (-1); - } - - prop_name = md_find_name(ptr, namep); - if (prop_name == MDE_INVAL_STR_COOKIE) { - return (-1); - } - - elem = md_find_node_prop(mdp, node, prop_name, MDET_PROP_DAT); - - if (elem != MDE_INVAL_ELEM_COOKIE) { - md_element_t *mdep; - mdep = &(mdp->mdep[(int)elem]); - - *lenp = (int)MDE_PROP_DATA_LEN(mdep); - *datap = mdp->datap+(int)MDE_PROP_DATA_OFFSET(mdep); - return (0); - } - - return (-1); /* no such property name */ -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_getpropstr.c b/sys/sun4v/cddl/mdesc/mdesc_getpropstr.c deleted file mode 100644 index 61f9c307884f..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_getpropstr.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#include - -int -md_get_prop_str(md_t *ptr, mde_cookie_t node, char *namep, char **strp) -{ - mde_str_cookie_t prop_name; - md_impl_t *mdp; - mde_cookie_t elem; - - mdp = (md_impl_t *)ptr; - - if (node == MDE_INVAL_ELEM_COOKIE) { - return (-1); - } - - prop_name = md_find_name(ptr, namep); - if (prop_name == MDE_INVAL_STR_COOKIE) { - return (-1); - } - - elem = md_find_node_prop(mdp, node, prop_name, MDET_PROP_STR); - - if (elem != MDE_INVAL_ELEM_COOKIE) { - md_element_t *mdep; - mdep = &(mdp->mdep[(int)elem]); - - *strp = (char *)(mdp->datap+ - MDE_PROP_DATA_OFFSET(mdep)); - return (0); - } - - return (-1); /* no such property name */ -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_getpropval.c b/sys/sun4v/cddl/mdesc/mdesc_getpropval.c deleted file mode 100644 index 3a17d5c7b01d..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_getpropval.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include -#ifdef _KERNEL -#include -#else -#include -#endif - -#include -#include - -int -md_get_prop_val(md_t *ptr, mde_cookie_t node, char *namep, uint64_t *valp) -{ - mde_str_cookie_t prop_name; - md_impl_t *mdp; - mde_cookie_t elem; - - mdp = (md_impl_t *)ptr; - - if (node == MDE_INVAL_ELEM_COOKIE) { - return (-1); - } - - prop_name = md_find_name(ptr, namep); - if (prop_name == MDE_INVAL_STR_COOKIE) { - return (-1); - } - - elem = md_find_node_prop(mdp, node, prop_name, MDET_PROP_VAL); - - if (elem != MDE_INVAL_ELEM_COOKIE) { - md_element_t *mdep; - mdep = &(mdp->mdep[(int)elem]); - - *valp = MDE_PROP_VALUE(mdep); - return (0); - } - - return (-1); /* no such property name */ -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_init_intern.c b/sys/sun4v/cddl/mdesc/mdesc_init_intern.c deleted file mode 100644 index dd5973e067f3..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_init_intern.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#include -#include - -md_t * -md_init_intern(uint64_t *ptr, void *(*allocp)(size_t), - void (*freep)(void *, size_t)) -{ - md_impl_t *mdp; - int idx; - int count; - int done; - uint64_t gen; - mde_str_cookie_t root_name; - - /* - * Very basic checkup for alignment to avoid - * bus error issues. - */ - if ((((uintptr_t)ptr) & 7) != 0) - return (NULL); - - mdp = (md_impl_t *)allocp(sizeof (md_impl_t)); - - if (mdp == NULL) - return (NULL); - - mdp->allocp = allocp; - mdp->freep = freep; - - mdp->caddr = (char *)ptr; - - /* - * setup internal structures - */ - - mdp->headerp = (md_header_t *)mdp->caddr; - - if (mdtoh32(mdp->headerp->transport_version) != MD_TRANSPORT_VERSION) { - goto cleanup_nohash; - } - - mdp->node_blk_size = mdtoh32(mdp->headerp->node_blk_sz); - mdp->name_blk_size = mdtoh32(mdp->headerp->name_blk_sz); - mdp->data_blk_size = mdtoh32(mdp->headerp->data_blk_sz); - - mdp->size = MD_HEADER_SIZE + mdp->node_blk_size + - mdp->name_blk_size + mdp->data_blk_size; - - mdp->mdep = (md_element_t *)(mdp->caddr + MD_HEADER_SIZE); - mdp->namep = (char *)(mdp->caddr + MD_HEADER_SIZE + mdp->node_blk_size); - mdp->datap = (uint8_t *)(mdp->caddr + MD_HEADER_SIZE + - mdp->name_blk_size + mdp->node_blk_size); - - mdp->root_node = MDE_INVAL_ELEM_COOKIE; - - - /* - * Should do a lot more sanity checking here. - */ - - /* - * Should initialize a name hash here if we intend to use one - */ - - /* - * Setup to find the root node - */ - root_name = md_find_name((md_t *)mdp, "root"); - if (root_name == MDE_INVAL_STR_COOKIE) { - goto cleanup; - } - - /* - * One more property we need is the count of nodes in the - * DAG, not just the number of elements. - * - * We try and pickup the root node along the way here. - */ - - for (done = 0, idx = 0, count = 0; !done; ) { - md_element_t *np; - - np = &(mdp->mdep[idx]); - - switch (MDE_TAG(np)) { - case MDET_LIST_END: - done = 1; - break; - - case MDET_NODE: - if (root_name == MDE_NAME(np)) { - if (mdp->root_node != MDE_INVAL_ELEM_COOKIE) { - /* Gah .. more than one root */ - goto cleanup; - } - mdp->root_node = (mde_cookie_t)idx; - } - idx = MDE_PROP_INDEX(np); - count++; - break; - - default: - idx++; /* ignore */ - } - } - - /* - * Ensure there is a root node - */ - if (mdp->root_node == MDE_INVAL_ELEM_COOKIE) { - goto cleanup; - } - - /* - * Register the counts - */ - - mdp->element_count = idx + 1; /* include LIST_END */ - mdp->node_count = count; - - /* - * Final sanity check that everything adds up - */ - if (mdp->element_count != (mdp->node_blk_size / MD_ELEMENT_SIZE)) - goto cleanup; - - mdp->md_magic = LIBMD_MAGIC; - - /* - * Setup MD generation - */ - if (md_get_prop_val((md_t *)mdp, mdp->root_node, - "md-generation#", &gen) != 0) - mdp->gen = MDESC_INVAL_GEN; - else - mdp->gen = gen; - - return ((md_t *)mdp); - -cleanup: - /* - * Clean up here - including a name hash if - * we build one. - */ - -cleanup_nohash: - mdp->freep(mdp, sizeof (md_impl_t)); - return (NULL); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_nodecount.c b/sys/sun4v/cddl/mdesc/mdesc_nodecount.c deleted file mode 100644 index 1c0376d5138e..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_nodecount.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include -#include -#include - -int -md_node_count(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - if (mdp->md_magic != LIBMD_MAGIC) - return (-1); - - return (mdp->node_count); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_rootnode.c b/sys/sun4v/cddl/mdesc/mdesc_rootnode.c deleted file mode 100644 index 2e4437aa131d..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_rootnode.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include -#include -#include - -mde_cookie_t -md_root_node(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - - if (mdp->md_magic != LIBMD_MAGIC) - return (MDE_INVAL_ELEM_COOKIE); - - return (mdp->root_node); -} diff --git a/sys/sun4v/cddl/mdesc/mdesc_scandag.c b/sys/sun4v/cddl/mdesc/mdesc_scandag.c deleted file mode 100644 index 4d7716a14cae..000000000000 --- a/sys/sun4v/cddl/mdesc/mdesc_scandag.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#ifdef _KERNEL -#include -#else -#include -#include -#endif - -#include -#include - -static int -mdl_scan_dag(md_impl_t *mdp, - int nodeidx, - mde_str_cookie_t node_cookie, - mde_str_cookie_t arc_cookie, - uint8_t *dseenp, - int *idxp, - mde_cookie_t *stashp, - int level); - - -int -md_scan_dag(md_t *ptr, - mde_cookie_t startnode, - mde_str_cookie_t node_name_cookie, - mde_str_cookie_t arc_name_cookie, - mde_cookie_t *stashp) -{ - int res; - int idx; - uint8_t *seenp; - md_impl_t *mdp; - int start; - - mdp = (md_impl_t *)ptr; - - /* - * Possible the caller was lazy and didn't check the - * validitiy of either the node name or the arc name - * on calling ... in which case fail to find any - * nodes. - * This is distinct, from a fail (-1) since we return - * that nothing was found. - */ - - if (node_name_cookie == MDE_INVAL_STR_COOKIE || - arc_name_cookie == MDE_INVAL_STR_COOKIE) return 0; - - /* - * if we want to start at the top, start at index 0 - */ - - start = (int)startnode; - if (start == MDE_INVAL_ELEM_COOKIE) start = 0; - - /* - * Scan from the start point until the first node. - */ - while (MDE_TAG(&mdp->mdep[start]) == MDET_NULL) start++; - - /* - * This was a bogus start point if no node found - */ - if (MDE_TAG(&mdp->mdep[start]) != MDET_NODE) { - return (-1); /* illegal start node specified */ - } - - /* - * Allocate a recursion mask on the local stack fail - * if we can't allocate the recursion detection. - */ - seenp = (uint8_t *)mdp->allocp(mdp->element_count); - if (seenp == NULL) - return (-1); - (void) memset(seenp, 0, mdp->element_count); - - /* - * Now build the list of requested nodes. - */ - idx = 0; - res = mdl_scan_dag(mdp, start, - node_name_cookie, arc_name_cookie, - seenp, &idx, stashp, 0); - - mdp->freep(seenp, mdp->element_count); - - return (res >= 0 ? idx : res); -} - - - - - -static int -mdl_scan_dag(md_impl_t *mdp, - int nodeidx, - mde_str_cookie_t node_name_cookie, - mde_str_cookie_t arc_name_cookie, - uint8_t *seenp, - int *idxp, - mde_cookie_t *stashp, - int level) -{ - md_element_t *mdep; - - mdep = &(mdp->mdep[nodeidx]); - - /* see if cookie is infact a node */ - if (MDE_TAG(mdep) != MDET_NODE) - return (-1); - - /* have we been here before ? */ - if (seenp[nodeidx]) - return (0); - seenp[nodeidx] = 1; - - /* is this node of the type we seek ? */ - -#ifdef DEBUG_LIBMDESC - { - int x; - for (x = 0; x < level; x++) - printf("-"); - printf("%d (%s)\n", nodeidx, (char *)(mdp->datap + MDE_NAME(mdep))); - } -#endif - - if (MDE_NAME(mdep) == node_name_cookie) { - /* record the node in the list and keep searching */ - if (stashp != NULL) { - stashp[*idxp] = (mde_cookie_t)nodeidx; - } - (*idxp)++; -#ifdef DEBUG_LIBMDESC - printf("\t* %d\n", *idxp); -#endif - } - - /* - * Simply walk the elements in the node. - * if we find a matching arc, then recursively call - * the subordinate looking for a match - */ - - for (mdep++; MDE_TAG(mdep) != MDET_NODE_END; mdep++) { - if (MDE_TAG(mdep) == MDET_PROP_ARC && - MDE_NAME(mdep) == arc_name_cookie) { - int res; - - res = mdl_scan_dag(mdp, - (int)mdep->d.prop_idx, - node_name_cookie, - arc_name_cookie, - seenp, idxp, stashp, level+1); - - if (res == -1) - return (res); - } - } - - return (0); -} diff --git a/sys/sun4v/cddl/t1_copy.S b/sys/sun4v/cddl/t1_copy.S deleted file mode 100644 index 6fe5a3d877aa..000000000000 --- a/sys/sun4v/cddl/t1_copy.S +++ /dev/null @@ -1,1598 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http: //www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -__FBSDID("$FreeBSD$") - -#include -#include -#include -#include -#include -#include -#include -#include - - .register %g2,#ignore - .register %g3,#ignore - .register %g6,#ignore - .register %g7,#ignore - - -/* - * This define is to align data for the unaligned source cases. - * The data1, data2 and data3 is merged into data1 and data2. - * The data3 is preserved for next merge. - */ -#define ALIGN_DATA(data1, data2, data3, lshift, rshift, tmp) \ - sllx data1, lshift, data1 ;\ - srlx data2, rshift, tmp ;\ - or data1, tmp, data1 ;\ - sllx data2, lshift, data2 ;\ - srlx data3, rshift, tmp ;\ - or data2, tmp, data2 -/* - * This macro is to align the data. Basically it merges - * data1 and data2 to form double word. - */ -#define ALIGN_DATA_EW(data1, data2, lshift, rshift, tmp) \ - sllx data1, lshift, data1 ;\ - srlx data2, rshift, tmp ;\ - or data1, tmp, data1 - - - - - -/* - * DGDEF and DGDEF2 provide global data declarations. - * - * DGDEF provides a word aligned word of storage. - * - * DGDEF2 allocates "sz" bytes of storage with **NO** alignment. This - * implies this macro is best used for byte arrays. - * - * DGDEF3 allocates "sz" bytes of storage with "algn" alignment. - */ -#define DGDEF2(name, sz) \ - .section ".data" ; \ - .global name ; \ - .type name, @object ; \ - .size name, sz; \ -name: - -#define DGDEF3(name, sz, algn) \ - .section ".data" ; \ - .align algn ; \ - .global name ; \ - .type name, @object ; \ - .size name, sz; \ -name: - -#define DGDEF(name) DGDEF3(name, 4, 4) - -.align 4 -DGDEF(hw_copy_limit_1) -.word 0x100 -DGDEF(hw_copy_limit_2) -.word 0x200 -DGDEF(hw_copy_limit_4) -.word 0x400 -DGDEF(hw_copy_limit_8) -.word 0x400 -.align 64 -.section ".text" - - -#if defined(lint) - -/*ARGSUSED*/ -void -ovbcopy(const void *from, void *to, size_t count) -{} - -#else /* lint */ - -ENTRY(bcopy) - tst %o2 ! check count - bgu,a %xcc, 1f ! nothing to do or bad arguments - subcc %o0, %o1, %o3 ! difference of from and to address - - retl ! return - nop -1: - bneg,a %xcc, 2f - neg %o3 ! if < 0, make it positive -2: cmp %o2, %o3 ! cmp size and abs(from - to) - bleu %xcc, novbcopy ! if size <= abs(diff): use bcopy, - nop - cmp %o0, %o1 ! compare from and to addresses - blu %xcc, ov_bkwd ! if from < to, copy backwards - nop - ! - ! Copy forwards. - ! -ov_fwd: - ldub [%o0], %o3 ! read from address - inc %o0 ! inc from address - stb %o3, [%o1] ! write to address - deccc %o2 ! dec count - bgu %xcc, ov_fwd ! loop till done - inc %o1 ! inc to address - - retl ! return - nop - ! - ! Copy backwards. - ! -ov_bkwd: - deccc %o2 ! dec count - ldub [%o0 + %o2], %o3 ! get byte at end of src - bgu %xcc, ov_bkwd ! loop till done - stb %o3, [%o1 + %o2] ! delay slot, store at end of dst - - retl ! return - nop -END(bcopy) - -#endif /* lint */ - - - -/* - * Copy a block of storage - must not overlap (from + len <= to). - */ -ENTRY(novbcopy) - - save %sp, -SA(MINFRAME), %sp - -do_copy: - cmp %i2, 12 ! for small counts - blu %xcc, bytecp ! just copy bytes - nop - - cmp %i2, 128 ! for less than 128 bytes - blu,pn %xcc, bcb_punt ! no block st/quad ld - nop -#if 0 - set use_hw_bcopy, %o2 - ld [%o2], %o2 - tst %o2 - bz bcb_punt - nop -#endif - subcc %i1, %i0, %i3 - bneg,a,pn %xcc, 1f - neg %i3 -1: - /* - * Compare against 256 since we should be checking block addresses - * and (dest & ~63) - (src & ~63) can be 3 blocks even if - * src = dest + (64 * 3) + 63. - */ - cmp %i3, 256 - blu,pn %xcc, bcb_punt - nop - - /* - * Copy that reach here have at least 2 blocks of data to copy. - */ -do_blockcopy: - ! Swap src/dst since the code below is memcpy code - ! and memcpy/bcopy have different calling sequences - mov %i1, %i5 - mov %i0, %i1 - mov %i5, %i0 - - andcc %i0, 0x3f, %i3 ! is dst aligned on a 64 bytes - bz %xcc, chksrc ! dst is already double aligned - sub %i3, 0x40, %i3 - neg %i3 ! bytes till dst 64 bytes aligned - sub %i2, %i3, %i2 ! update i2 with new count - -1: ldub [%i1], %i4 - stb %i4, [%i0] - inc %i1 - deccc %i3 - bgu %xcc, 1b - inc %i0 - - ! Now Destination is block (64 bytes) aligned -chksrc: - andn %i2, 0x3f, %i3 ! %i3 count is multiple of block size - sub %i2, %i3, %i2 ! Residue bytes in %i2 - - wr %g0, ASI_LDSTBI_P, %asi - - andcc %i1, 0xf, %o2 ! is src quadword aligned - bz,pn %xcc, blkcpy ! src offset in %o2 - nop - cmp %o2, 0x8 - bg cpy_upper_double - nop - bl cpy_lower_double - nop - - ! Falls through when source offset is equal to 8 i.e. - ! source is double word aligned. - ! In this case no shift/merge of data is required - sub %i1, %o2, %i1 ! align the src at 16 bytes. - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1+0x0]%asi, %l2 -loop0: - ldda [%i1+0x10]%asi, %l4 - prefetch [%l0+0x40], #one_read - - stxa %l3, [%i0+0x0]%asi - stxa %l4, [%i0+0x8]%asi - - ldda [%i1+0x20]%asi, %l2 - stxa %l5, [%i0+0x10]%asi - stxa %l2, [%i0+0x18]%asi - - ldda [%i1+0x30]%asi, %l4 - stxa %l3, [%i0+0x20]%asi - stxa %l4, [%i0+0x28]%asi - - ldda [%i1+0x40]%asi, %l2 - stxa %l5, [%i0+0x30]%asi - stxa %l2, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - add %i1, 0x40, %i1 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, loop0 - add %i0, 0x40, %i0 - ba blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - -cpy_lower_double: - sub %i1, %o2, %i1 ! align the src at 16 bytes. - sll %o2, 3, %o0 ! %o0 left shift - mov 0x40, %o1 - sub %o1, %o0, %o1 ! %o1 right shift = (64 - left shift) - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1+0x0]%asi, %l2 ! partial data in %l2 and %l3 has - ! complete data -loop1: - ldda [%i1+0x10]%asi, %l4 ! %l4 has partial data for this read. - ALIGN_DATA(%l2, %l3, %l4, %o0, %o1, %l6) ! merge %l2, %l3 and %l4 - ! into %l2 and %l3 - prefetch [%l0+0x40], #one_read - stxa %l2, [%i0+0x0]%asi - stxa %l3, [%i0+0x8]%asi - - ldda [%i1+0x20]%asi, %l2 - ALIGN_DATA(%l4, %l5, %l2, %o0, %o1, %l6) ! merge %l2 with %l5 and - stxa %l4, [%i0+0x10]%asi ! %l4 from previous read - stxa %l5, [%i0+0x18]%asi ! into %l4 and %l5 - - ! Repeat the same for next 32 bytes. - - ldda [%i1+0x30]%asi, %l4 - ALIGN_DATA(%l2, %l3, %l4, %o0, %o1, %l6) - stxa %l2, [%i0+0x20]%asi - stxa %l3, [%i0+0x28]%asi - - ldda [%i1+0x40]%asi, %l2 - ALIGN_DATA(%l4, %l5, %l2, %o0, %o1, %l6) - stxa %l4, [%i0+0x30]%asi - stxa %l5, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - add %i1, 0x40, %i1 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, loop1 - add %i0, 0x40, %i0 - ba blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - -cpy_upper_double: - sub %i1, %o2, %i1 ! align the src at 16 bytes. - mov 0x8, %o0 - sub %o2, %o0, %o0 - sll %o0, 3, %o0 ! %o0 left shift - mov 0x40, %o1 - sub %o1, %o0, %o1 ! %o1 right shift = (64 - left shift) - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1+0x0]%asi, %l2 ! partial data in %l3 for this read and - ! no data in %l2 -loop2: - ldda [%i1+0x10]%asi, %l4 ! %l4 has complete data and %l5 has - ! partial - ALIGN_DATA(%l3, %l4, %l5, %o0, %o1, %l6) ! merge %l3, %l4 and %l5 - ! into %l3 and %l4 - prefetch [%l0+0x40], #one_read - stxa %l3, [%i0+0x0]%asi - stxa %l4, [%i0+0x8]%asi - - ldda [%i1+0x20]%asi, %l2 - ALIGN_DATA(%l5, %l2, %l3, %o0, %o1, %l6) ! merge %l2 and %l3 with - stxa %l5, [%i0+0x10]%asi ! %l5 from previous read - stxa %l2, [%i0+0x18]%asi ! into %l5 and %l2 - - ! Repeat the same for next 32 bytes. - - ldda [%i1+0x30]%asi, %l4 - ALIGN_DATA(%l3, %l4, %l5, %o0, %o1, %l6) - stxa %l3, [%i0+0x20]%asi - stxa %l4, [%i0+0x28]%asi - - ldda [%i1+0x40]%asi, %l2 - ALIGN_DATA(%l5, %l2, %l3, %o0, %o1, %l6) - stxa %l5, [%i0+0x30]%asi - stxa %l2, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - add %i1, 0x40, %i1 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, loop2 - add %i0, 0x40, %i0 - ba blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - - - ! Both Source and Destination are block aligned. - ! Do fast copy using ASI_LDSTBI_P -blkcpy: - prefetch [%i1+0x0], #one_read -1: - ldda [%i1+0x0]%asi, %l0 - ldda [%i1+0x10]%asi, %l2 - prefetch [%i1+0x40], #one_read - - stxa %l0, [%i0+0x0]%asi - ldda [%i1+0x20]%asi, %l4 - ldda [%i1+0x30]%asi, %l6 - - stxa %l1, [%i0+0x8]%asi - stxa %l2, [%i0+0x10]%asi - stxa %l3, [%i0+0x18]%asi - stxa %l4, [%i0+0x20]%asi - stxa %l5, [%i0+0x28]%asi - stxa %l6, [%i0+0x30]%asi - stxa %l7, [%i0+0x38]%asi - - add %i1, 0x40, %i1 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, 1b - add %i0, 0x40, %i0 - -blkdone: - tst %i2 - bz,pt %xcc, blkexit - nop - -residue: - ldub [%i1], %i4 - stb %i4, [%i0] - inc %i1 - deccc %i2 - bgu %xcc, residue - inc %i0 - -blkexit: - membar #Sync ! sync error barrier - ret - restore %g0, 0, %o0 - -bcb_punt: - ! - ! use aligned transfers where possible - ! - xor %i0, %i1, %o4 ! xor from and to address - btst 7, %o4 ! if lower three bits zero - bz aldoubcp ! can align on double boundary - nop ! assembler complaints about label - - xor %i0, %i1, %o4 ! xor from and to address - btst 3, %o4 ! if lower two bits zero - bz alwordcp ! can align on word boundary - btst 3, %i0 ! delay slot, from address unaligned? - ! - ! use aligned reads and writes where possible - ! this differs from wordcp in that it copes - ! with odd alignment between source and destnation - ! using word reads and writes with the proper shifts - ! in between to align transfers to and from memory - ! i0 - src address, i1 - dest address, i2 - count - ! i3, i4 - tmps for used generating complete word - ! i5 (word to write) - ! l0 size in bits of upper part of source word (US) - ! l1 size in bits of lower part of source word (LS = 32 - US) - ! l2 size in bits of upper part of destination word (UD) - ! l3 size in bits of lower part of destination word (LD = 32 - UD) - ! l4 number of bytes leftover after aligned transfers complete - ! l5 the number 32 - ! - mov 32, %l5 ! load an oft-needed constant - bz align_dst_only - btst 3, %i1 ! is destnation address aligned? - clr %i4 ! clear registers used in either case - bz align_src_only - clr %l0 - ! - ! both source and destination addresses are unaligned - ! -1: ! align source - ldub [%i0], %i3 ! read a byte from source address - add %i0, 1, %i0 ! increment source address - or %i4, %i3, %i4 ! or in with previous bytes (if any) - btst 3, %i0 ! is source aligned? - add %l0, 8, %l0 ! increment size of upper source (US) - bnz,a 1b - sll %i4, 8, %i4 ! make room for next byte - - sub %l5, %l0, %l1 ! generate shift left count (LS) - sll %i4, %l1, %i4 ! prepare to get rest - ld [%i0], %i3 ! read a word - add %i0, 4, %i0 ! increment source address - srl %i3, %l0, %i5 ! upper src bits into lower dst bits - or %i4, %i5, %i5 ! merge - mov 24, %l3 ! align destination -1: - srl %i5, %l3, %i4 ! prepare to write a single byte - stb %i4, [%i1] ! write a byte - add %i1, 1, %i1 ! increment destination address - sub %i2, 1, %i2 ! decrement count - btst 3, %i1 ! is destination aligned? - bnz,a 1b - sub %l3, 8, %l3 ! delay slot, decrement shift count (LD) - sub %l5, %l3, %l2 ! generate shift left count (UD) - sll %i5, %l2, %i5 ! move leftover into upper bytes - cmp %l2, %l0 ! cmp # reqd to fill dst w old src left - bgu %xcc, more_needed ! need more to fill than we have - nop - - sll %i3, %l1, %i3 ! clear upper used byte(s) - srl %i3, %l1, %i3 - ! get the odd bytes between alignments - sub %l0, %l2, %l0 ! regenerate shift count - sub %l5, %l0, %l1 ! generate new shift left count (LS) - and %i2, 3, %l4 ! must do remaining bytes if count%4 > 0 - andn %i2, 3, %i2 ! # of aligned bytes that can be moved - srl %i3, %l0, %i4 - or %i5, %i4, %i5 - st %i5, [%i1] ! write a word - subcc %i2, 4, %i2 ! decrement count - bz %xcc, unalign_out - add %i1, 4, %i1 ! increment destination address - - b 2f - sll %i3, %l1, %i5 ! get leftover into upper bits -more_needed: - sll %i3, %l0, %i3 ! save remaining byte(s) - srl %i3, %l0, %i3 - sub %l2, %l0, %l1 ! regenerate shift count - sub %l5, %l1, %l0 ! generate new shift left count - sll %i3, %l1, %i4 ! move to fill empty space - b 3f - or %i5, %i4, %i5 ! merge to complete word - ! - ! the source address is aligned and destination is not - ! -align_dst_only: - ld [%i0], %i4 ! read a word - add %i0, 4, %i0 ! increment source address - mov 24, %l0 ! initial shift alignment count -1: - srl %i4, %l0, %i3 ! prepare to write a single byte - stb %i3, [%i1] ! write a byte - add %i1, 1, %i1 ! increment destination address - sub %i2, 1, %i2 ! decrement count - btst 3, %i1 ! is destination aligned? - bnz,a 1b - sub %l0, 8, %l0 ! delay slot, decrement shift count -xfer: - sub %l5, %l0, %l1 ! generate shift left count - sll %i4, %l1, %i5 ! get leftover -3: - and %i2, 3, %l4 ! must do remaining bytes if count%4 > 0 - andn %i2, 3, %i2 ! # of aligned bytes that can be moved -2: - ld [%i0], %i3 ! read a source word - add %i0, 4, %i0 ! increment source address - srl %i3, %l0, %i4 ! upper src bits into lower dst bits - or %i5, %i4, %i5 ! merge with upper dest bits (leftover) - st %i5, [%i1] ! write a destination word - subcc %i2, 4, %i2 ! decrement count - bz %xcc, unalign_out ! check if done - add %i1, 4, %i1 ! increment destination address - b 2b ! loop - sll %i3, %l1, %i5 ! get leftover -unalign_out: - tst %l4 ! any bytes leftover? - bz %xcc, cpdone - nop -1: - sub %l0, 8, %l0 ! decrement shift - srl %i3, %l0, %i4 ! upper src byte into lower dst byte - stb %i4, [%i1] ! write a byte - subcc %l4, 1, %l4 ! decrement count - bz %xcc, cpdone ! done? - add %i1, 1, %i1 ! increment destination - tst %l0 ! any more previously read bytes - bnz %xcc, 1b ! we have leftover bytes - mov %l4, %i2 ! delay slot, mv cnt where dbytecp wants - b dbytecp ! let dbytecp do the rest - sub %i0, %i1, %i0 ! i0 gets the difference of src and dst - ! - ! the destination address is aligned and the source is not - ! -align_src_only: - ldub [%i0], %i3 ! read a byte from source address - add %i0, 1, %i0 ! increment source address - or %i4, %i3, %i4 ! or in with previous bytes (if any) - btst 3, %i0 ! is source aligned? - add %l0, 8, %l0 ! increment shift count (US) - bnz,a align_src_only - sll %i4, 8, %i4 ! make room for next byte - b,a xfer - ! - ! if from address unaligned for double-word moves, - ! move bytes till it is, if count is < 56 it could take - ! longer to align the thing than to do the transfer - ! in word size chunks right away - ! -aldoubcp: - cmp %i2, 56 ! if count < 56, use wordcp, it takes - blu,a %xcc, alwordcp ! longer to align doubles than words - mov 3, %o0 ! mask for word alignment - call alignit ! copy bytes until aligned - mov 7, %o0 ! mask for double alignment - ! - ! source and destination are now double-word aligned - ! i3 has aligned count returned by alignit - ! - and %i2, 7, %i2 ! unaligned leftover count - sub %i0, %i1, %i0 ! i0 gets the difference of src and dst -5: - ldx [%i0+%i1], %o4 ! read from address - stx %o4, [%i1] ! write at destination address - subcc %i3, 8, %i3 ! dec count - bgu %xcc, 5b - add %i1, 8, %i1 ! delay slot, inc to address - cmp %i2, 4 ! see if we can copy a word - blu %xcc, dbytecp ! if 3 or less bytes use bytecp - nop - ! - ! for leftover bytes we fall into wordcp, if needed - ! -wordcp: - and %i2, 3, %i2 ! unaligned leftover count -5: - ld [%i0+%i1], %o4 ! read from address - st %o4, [%i1] ! write at destination address - subcc %i3, 4, %i3 ! dec count - bgu %xcc, 5b - add %i1, 4, %i1 ! delay slot, inc to address - b,a dbytecp - - ! we come here to align copies on word boundaries -alwordcp: - call alignit ! go word-align it - mov 3, %o0 ! bits that must be zero to be aligned - b wordcp - sub %i0, %i1, %i0 ! i0 gets the difference of src and dst - - ! - ! byte copy, works with any alignment - ! -bytecp: - b dbytecp - sub %i0, %i1, %i0 ! i0 gets difference of src and dst - - ! - ! differenced byte copy, works with any alignment - ! assumes dest in %i1 and (source - dest) in %i0 - ! -1: - stb %o4, [%i1] ! write to address - inc %i1 ! inc to address -dbytecp: - deccc %i2 ! dec count - bgeu,a %xcc, 1b ! loop till done - ldub [%i0+%i1], %o4 ! read from address -cpdone: - membar #Sync ! sync error barrier - ret - restore %g0, 0, %o0 ! return (0) - -/* - * Common code used to align transfers on word and doubleword - * boudaries. Aligns source and destination and returns a count - * of aligned bytes to transfer in %i3 - */ -1: - inc %i0 ! inc from - stb %o4, [%i1] ! write a byte - inc %i1 ! inc to - dec %i2 ! dec count -alignit: - btst %o0, %i0 ! %o0 is bit mask to check for alignment - bnz,a 1b - ldub [%i0], %o4 ! read next byte - - retl - andn %i2, %o0, %i3 ! return size of aligned bytes -END(novbcopy) - - -/* - * hwblkclr - clears block-aligned, block-multiple-sized regions that are - * longer than 256 bytes in length using Niagara's block stores/quad store. - * If the criteria for using this routine are not met then it calls bzero - * and returns 1. Otherwise 0 is returned indicating success. - * Caller is responsible for ensuring use_hw_bzero is true and that - * kpreempt_disable() has been called. - */ -#ifdef lint -/*ARGSUSED*/ -int -hwblkclr(void *addr, size_t len) -{ - return(0); -} -#else /* lint */ - ! %i0 - start address - ! %i1 - length of region (multiple of 64) - -ENTRY(hwblkclr) - save %sp, -SA(MINFRAME), %sp - - ! Must be block-aligned - andcc %i0, 0x3f, %g0 - bnz,pn %xcc, 1f - nop - - ! ... and must be 256 bytes or more - cmp %i1, 0x100 - blu,pn %xcc, 1f - nop - - ! ... and length must be a multiple of 64 - andcc %i1, 0x3f, %g0 - bz,pn %xcc, pz_doblock - wr %g0, ASI_LDSTBI_P, %asi - -1: ! punt, call bzero but notify the caller that bzero was used - mov %i0, %o0 - call bzero - mov %i1, %o1 - ret - restore %g0, 1, %o0 ! return (1) - did not use block operations - - ! Already verified that there are at least 256 bytes to set -pz_doblock: - stxa %g0, [%i0+0x0]%asi - stxa %g0, [%i0+0x40]%asi - stxa %g0, [%i0+0x80]%asi - stxa %g0, [%i0+0xc0]%asi - - stxa %g0, [%i0+0x8]%asi - stxa %g0, [%i0+0x10]%asi - stxa %g0, [%i0+0x18]%asi - stxa %g0, [%i0+0x20]%asi - stxa %g0, [%i0+0x28]%asi - stxa %g0, [%i0+0x30]%asi - stxa %g0, [%i0+0x38]%asi - - stxa %g0, [%i0+0x48]%asi - stxa %g0, [%i0+0x50]%asi - stxa %g0, [%i0+0x58]%asi - stxa %g0, [%i0+0x60]%asi - stxa %g0, [%i0+0x68]%asi - stxa %g0, [%i0+0x70]%asi - stxa %g0, [%i0+0x78]%asi - - stxa %g0, [%i0+0x88]%asi - stxa %g0, [%i0+0x90]%asi - stxa %g0, [%i0+0x98]%asi - stxa %g0, [%i0+0xa0]%asi - stxa %g0, [%i0+0xa8]%asi - stxa %g0, [%i0+0xb0]%asi - stxa %g0, [%i0+0xb8]%asi - - stxa %g0, [%i0+0xc8]%asi - stxa %g0, [%i0+0xd0]%asi - stxa %g0, [%i0+0xd8]%asi - stxa %g0, [%i0+0xe0]%asi - stxa %g0, [%i0+0xe8]%asi - stxa %g0, [%i0+0xf0]%asi - stxa %g0, [%i0+0xf8]%asi - - sub %i1, 0x100, %i1 - cmp %i1, 0x100 - bgu,pt %xcc, pz_doblock - add %i0, 0x100, %i0 - -2: - ! Check if more than 64 bytes to set - cmp %i1,0x40 - blu %xcc, pz_finish - nop - -3: - stxa %g0, [%i0+0x0]%asi - stxa %g0, [%i0+0x8]%asi - stxa %g0, [%i0+0x10]%asi - stxa %g0, [%i0+0x18]%asi - stxa %g0, [%i0+0x20]%asi - stxa %g0, [%i0+0x28]%asi - stxa %g0, [%i0+0x30]%asi - stxa %g0, [%i0+0x38]%asi - - subcc %i1, 0x40, %i1 - bgu,pt %xcc, 3b - add %i0, 0x40, %i0 - -pz_finish: - membar #Sync - ret - restore %g0, 0, %o0 ! return (bzero or not) -END(hwblkclr) -#endif /* lint */ - -#if defined(lint) - -/* ARGSUSED */ -void -bzero(void *addr, size_t count) -{} - -#else /* lint */ - -ENTRY(bzero) - wr %g0, ASI_P, %asi - - cmp %o1, 7 - blu,pn %xcc, byteclr - nop - - cmp %o1, 15 - blu,pn %xcc, wdalign - nop - - andcc %o0, 7, %o3 ! is add aligned on a 8 byte bound - bz,pt %xcc, blkalign ! already double aligned - sub %o3, 8, %o3 ! -(bytes till double aligned) - add %o1, %o3, %o1 ! update o1 with new count - -1: - stba %g0, [%o0]%asi - inccc %o3 - bl,pt %xcc, 1b - inc %o0 - - ! Now address is double aligned -blkalign: - cmp %o1, 0x80 ! check if there are 128 bytes to set - blu,pn %xcc, bzero_small - mov %o1, %o3 -#if 0 - sethi %hi(use_hw_bzero), %o2 - ld [%o2 + %lo(use_hw_bzero)], %o2 - tst %o2 - bz %xcc, bzero_small - mov %o1, %o3 -#endif - rd %asi, %o3 - wr %g0, ASI_LDSTBI_P, %asi - cmp %o3, ASI_P - bne,a %xcc, algnblk - wr %g0, ASI_LDSTBI_AIUS, %asi - -algnblk: - andcc %o0, 0x3f, %o3 ! is block aligned? - bz,pt %xcc, bzero_blk - sub %o3, 0x40, %o3 ! -(bytes till block aligned) - add %o1, %o3, %o1 ! o1 is the remainder - - ! Clear -(%o3) bytes till block aligned -1: - stxa %g0, [%o0]%asi - addcc %o3, 8, %o3 - bl,pt %xcc, 1b - add %o0, 8, %o0 - -bzero_blk: - and %o1, 0x3f, %o3 ! calc bytes left after blk clear - andn %o1, 0x3f, %o4 ! calc size of blocks in bytes - - cmp %o4, 0x100 ! 256 bytes or more - blu,pn %xcc, 3f - nop - -2: - stxa %g0, [%o0+0x0]%asi - stxa %g0, [%o0+0x40]%asi - stxa %g0, [%o0+0x80]%asi - stxa %g0, [%o0+0xc0]%asi - - stxa %g0, [%o0+0x8]%asi - stxa %g0, [%o0+0x10]%asi - stxa %g0, [%o0+0x18]%asi - stxa %g0, [%o0+0x20]%asi - stxa %g0, [%o0+0x28]%asi - stxa %g0, [%o0+0x30]%asi - stxa %g0, [%o0+0x38]%asi - - stxa %g0, [%o0+0x48]%asi - stxa %g0, [%o0+0x50]%asi - stxa %g0, [%o0+0x58]%asi - stxa %g0, [%o0+0x60]%asi - stxa %g0, [%o0+0x68]%asi - stxa %g0, [%o0+0x70]%asi - stxa %g0, [%o0+0x78]%asi - - stxa %g0, [%o0+0x88]%asi - stxa %g0, [%o0+0x90]%asi - stxa %g0, [%o0+0x98]%asi - stxa %g0, [%o0+0xa0]%asi - stxa %g0, [%o0+0xa8]%asi - stxa %g0, [%o0+0xb0]%asi - stxa %g0, [%o0+0xb8]%asi - - stxa %g0, [%o0+0xc8]%asi - stxa %g0, [%o0+0xd0]%asi - stxa %g0, [%o0+0xd8]%asi - stxa %g0, [%o0+0xe0]%asi - stxa %g0, [%o0+0xe8]%asi - stxa %g0, [%o0+0xf0]%asi - stxa %g0, [%o0+0xf8]%asi - - sub %o4, 0x100, %o4 - cmp %o4, 0x100 - bgu,pt %xcc, 2b - add %o0, 0x100, %o0 - -3: - ! ... check if 64 bytes to set - cmp %o4, 0x40 - blu %xcc, bzero_blk_done - nop - -4: - stxa %g0, [%o0+0x0]%asi - stxa %g0, [%o0+0x8]%asi - stxa %g0, [%o0+0x10]%asi - stxa %g0, [%o0+0x18]%asi - stxa %g0, [%o0+0x20]%asi - stxa %g0, [%o0+0x28]%asi - stxa %g0, [%o0+0x30]%asi - stxa %g0, [%o0+0x38]%asi - - subcc %o4, 0x40, %o4 - bgu,pt %xcc, 3b - add %o0, 0x40, %o0 - -bzero_blk_done: - membar #Sync - ! - ! Undo asi register setting. - ! - rd %asi, %o4 - wr %g0, ASI_P, %asi - cmp %o4, ASI_LDSTBI_P - bne,a %xcc, bzero_small - wr %g0, ASI_AIUS, %asi - -bzero_small: - ! Set the remaining doubles - subcc %o3, 8, %o3 ! Can we store any doubles? - blu,pn %xcc, byteclr - and %o1, 7, %o1 ! calc bytes left after doubles - -dbclr: - stxa %g0, [%o0]%asi ! Clear the doubles - subcc %o3, 8, %o3 - bgeu,pt %xcc, dbclr - add %o0, 8, %o0 - - ba byteclr - nop - -wdalign: - andcc %o0, 3, %o3 ! is add aligned on a word boundary - bz,pn %xcc, wdclr - andn %o1, 3, %o3 ! create word sized count in %o3 - - dec %o1 ! decrement count - stba %g0, [%o0]%asi ! clear a byte - ba wdalign - inc %o0 ! next byte - -wdclr: - sta %g0, [%o0]%asi ! 4-byte clearing loop - subcc %o3, 4, %o3 - bnz,pt %xcc, wdclr - inc 4, %o0 - - and %o1, 3, %o1 ! leftover count, if any - -byteclr: - ! Set the leftover bytes - brz %o1, bzero_exit - nop - -7: - deccc %o1 ! byte clearing loop - stba %g0, [%o0]%asi - bgu,pt %xcc, 7b - inc %o0 - -bzero_exit: - retl - clr %o0 ! return (0) - -END(bzero) -#endif /* lint */ - - -#if 0 -#define SMALL_LIMIT 7 -#if defined(lint) - -/*ARGSUSED*/ -int -copyin(const void *uaddr, void *kaddr, size_t count) -{ return (0); } - -#else /* lint */ - -ENTRY(copyin) - ! - ! Check the length and bail if zero. - ! - tst %o2 - bnz,pt %xcc, 1f - nop - retl - clr %o0 -#if 0 -1: - sethi %hi(copyio_fault), %o4 - or %o4, %lo(copyio_fault), %o4 - sethi %hi(copyio_fault_nowindow), %o3 - ldn [THREAD_REG + T_LOFAULT], SAVED_LOFAULT - or %o3, %lo(copyio_fault_nowindow), %o3 - membar #Sync - stn %o3, [THREAD_REG + T_LOFAULT] - - mov %o0, SAVE_SRC - mov %o1, SAVE_DST - mov %o2, SAVE_COUNT -#endif - ! - ! Check to see if we're more than SMALL_LIMIT. - ! - subcc %o2, SMALL_LIMIT, %o3 - bgu,a,pt %xcc, dci_ns - or %o0, %o1, %o3 - ! - ! What was previously ".small_copyin" - ! -dcibcp: - sub %g0, %o2, %o3 ! setup for copy loop - add %o0, %o2, %o0 - add %o1, %o2, %o1 - ba,pt %xcc, dcicl - lduba [%o0 + %o3]ASI_AIUS, %o4 - ! - ! %o0 and %o1 point at the end and remain pointing at the end - ! of their buffers. We pull things out by adding %o3 (which is - ! the negation of the length) to the buffer end which gives us - ! the curent location in the buffers. By incrementing %o3 we walk - ! through both buffers without having to bump each buffer's - ! pointer. A very fast 4 instruction loop. - ! - .align 16 -dcicl: - stb %o4, [%o1 + %o3] - inccc %o3 - bl,a,pt %xcc, dcicl - lduba [%o0 + %o3]ASI_AIUS, %o4 - ! - ! We're done. Go home. - ! - membar #Sync - retl - clr %o0 - ! - ! Try aligned copies from here. - ! -dci_ns: - ! - ! See if we're single byte aligned. If we are, check the - ! limit for single byte copies. If we're smaller, or equal, - ! bounce to the byte for byte copy loop. Otherwise do it in - ! HW (if enabled). - ! - btst 1, %o3 - bz,a,pt %icc, dcih8 - btst 7, %o3 - ! - ! We're single byte aligned. - ! - sethi %hi(hw_copy_limit_1), %o3 - ld [%o3 + %lo(hw_copy_limit_1)], %o3 - ! - ! Is HW copy on? If not do everything byte for byte. - ! - tst %o3 - bz,pn %icc, dcibcp - subcc %o3, %o2, %o3 - ! - ! Are we bigger than the HW limit? If not - ! go to byte for byte. - ! - bge,pt %xcc, dcibcp - nop - ! - ! We're big enough and copy is on. Do it with HW. - ! - ba,pt %xcc, big_copyin - nop -dcih8: - ! - ! 8 byte aligned? - ! - bnz,a %xcc, dcih4 - btst 3, %o3 - ! - ! We're eight byte aligned. - ! - sethi %hi(hw_copy_limit_8), %o3 - ld [%o3 + %lo(hw_copy_limit_8)], %o3 - ! - ! Is HW assist on? If not, do it with the aligned copy. - ! - tst %o3 - bz,pn %icc, dcis8 - subcc %o3, %o2, %o3 - bge %xcc, dcis8 - nop - ba,pt %xcc, big_copyin - nop -dcis8: - ! - ! Housekeeping for copy loops. Uses same idea as in the byte for - ! byte copy loop above. - ! - add %o0, %o2, %o0 - add %o1, %o2, %o1 - sub %g0, %o2, %o3 - ba,pt %xcc, didebc - srl %o2, 3, %o2 ! Number of 8 byte chunks to copy - ! - ! 4 byte aligned? - ! -dcih4: - bnz %xcc, dcih2 - sethi %hi(hw_copy_limit_4), %o3 - ld [%o3 + %lo(hw_copy_limit_4)], %o3 - ! - ! Is HW assist on? If not, do it with the aligned copy. - ! - tst %o3 - bz,pn %icc, dcis4 - subcc %o3, %o2, %o3 - ! - ! We're negative if our size is less than or equal to hw_copy_limit_4. - ! - bge %xcc, dcis4 - nop - ba,pt %xcc, big_copyin - nop -dcis4: - ! - ! Housekeeping for copy loops. Uses same idea as in the byte - ! for byte copy loop above. - ! - add %o0, %o2, %o0 - add %o1, %o2, %o1 - sub %g0, %o2, %o3 - ba,pt %xcc, didfbc - srl %o2, 2, %o2 ! Number of 4 byte chunks to copy -dcih2: - ! - ! We're two byte aligned. Check for "smallness" - ! done in delay at .dcih4 - ! - bleu,pt %xcc, dcis2 - sethi %hi(hw_copy_limit_2), %o3 - ld [%o3 + %lo(hw_copy_limit_2)], %o3 - ! - ! Is HW assist on? If not, do it with the aligned copy. - ! - tst %o3 - bz,pn %icc, dcis2 - subcc %o3, %o2, %o3 - ! - ! Are we larger than the HW limit? - ! - bge %xcc, dcis2 - nop - ! - ! HW assist is on and we're large enough to use it. - ! - ba,pt %xcc, big_copyin - nop - ! - ! Housekeeping for copy loops. Uses same idea as in the byte - ! for byte copy loop above. - ! -dcis2: - add %o0, %o2, %o0 - add %o1, %o2, %o1 - sub %g0, %o2, %o3 - ba,pt %xcc, didtbc - srl %o2, 1, %o2 ! Number of 2 byte chunks to copy - ! -small_copyin: - ! - ! Why are we doing this AGAIN? There are certain conditions in - ! big copyin that will cause us to forgo the HW assisted copys - ! and bounce back to a non-hw assisted copy. This dispatches - ! those copies. Note that we branch around this in the main line - ! code. - ! - ! We make no check for limits or HW enablement here. We've - ! already been told that we're a poster child so just go off - ! and do it. - ! - or %o0, %o1, %o3 - btst 1, %o3 - bnz %icc, dcibcp ! Most likely - btst 7, %o3 - bz %icc, dcis8 - btst 3, %o3 - bz %icc, dcis4 - nop - ba,pt %xcc, dcis2 - nop - ! - ! Eight byte aligned copies. A steal from the original .small_copyin - ! with modifications. %o2 is number of 8 byte chunks to copy. When - ! done, we examine %o3. If this is < 0, we have 1 - 7 bytes more - ! to copy. - ! - .align 32 -didebc: - ldxa [%o0 + %o3]ASI_AIUS, %o4 - deccc %o2 - stx %o4, [%o1 + %o3] - bg,pt %xcc, didebc - addcc %o3, 8, %o3 - ! - ! End of copy loop. Most 8 byte aligned copies end here. - ! - bz,pt %xcc, dcifh - nop - ! - ! Something is left. Do it byte for byte. - ! - ba,pt %xcc, dcicl - lduba [%o0 + %o3]ASI_AIUS, %o4 - ! - ! 4 byte copy loop. %o2 is number of 4 byte chunks to copy. - ! - .align 32 -didfbc: - lduwa [%o0 + %o3]ASI_AIUS, %o4 - deccc %o2 - st %o4, [%o1 + %o3] - bg,pt %xcc, didfbc - addcc %o3, 4, %o3 - ! - ! End of copy loop. Most 4 byte aligned copies end here. - ! - bz,pt %xcc, dcifh - nop - ! - ! Something is left. Do it byte for byte. - ! - ba,pt %xcc, dcicl - lduba [%o0 + %o3]ASI_AIUS, %o4 - ! - ! 2 byte aligned copy loop. %o2 is number of 2 byte chunks to - ! copy. - ! - .align 32 -didtbc: - lduha [%o0 + %o3]ASI_AIUS, %o4 - deccc %o2 - sth %o4, [%o1 + %o3] - bg,pt %xcc, didtbc - addcc %o3, 2, %o3 - ! - ! End of copy loop. Most 2 byte aligned copies end here. - ! - bz,pt %xcc, dcifh - nop - ! - ! Deal with the last byte - ! - lduba [%o0 + %o3]ASI_AIUS, %o4 - stb %o4, [%o1 + %o3] -dcifh: - membar #Sync - retl - clr %o0 - -big_copyin: - ! - ! We're going off to do a block copy. - ! Switch fault hendlers and grab a window. We - ! don't do a membar #Sync since we've done only - ! kernel data to this point. - ! - save %sp, -SA(MINFRAME), %sp - - ! Copy in that reach here are larger than 256 bytes. The - ! hw_copy_limit_1 is set to 256. Never set this limit less - ! 128 bytes. -do_blockcopyin: - - ! Swap src/dst since the code below is memcpy code - ! and memcpy/bcopy have different calling sequences - mov %i1, %i5 - mov %i0, %i1 - mov %i5, %i0 - - andcc %i0, 7, %i3 ! is dst double aligned - bz %xcc, copyin_blkcpy - sub %i3, 8, %i3 - neg %i3 ! bytes till double aligned - sub %i2, %i3, %i2 ! update %i2 with new count - - ! Align Destination on double-word boundary - -1: lduba [%i1]ASI_AIUS, %i4 - inc %i1 - stb %i4, [%i0] - deccc %i3 - bgu %xcc, 1b - inc %i0 - -copyin_blkcpy: - andcc %i0, 63, %i3 - bz,pn %xcc, copyin_blalign ! now block aligned - sub %i3, 64, %i3 - neg %i3 ! bytes till block aligned - sub %i2, %i3, %i2 ! update %i2 with new count - - ! Copy %i3 bytes till dst is block (64 byte) aligned. use - ! double word copies. - - andcc %i1, 7, %g1 ! is src aligned on a 8 bytes - bz %xcc, ci_dbcopy ! %g1 has source offset (last 3-bits) - sll %g1, 3, %l1 ! left shift - mov 0x40, %l2 - sub %l2, %l1, %l2 ! right shift = (64 - left shift) - - ! Now use double word copies to align destination. -ci_double: - sub %i1, %g1, %i1 ! align the src at 8 bytes. - ldxa [%i1]ASI_AIUS, %o2 -2: - add %i1, 0x8, %i1 - ldxa [%i1]ASI_AIUS, %o4 - ALIGN_DATA_EW(%o2, %o4, %l1, %l2, %o3) - stx %o2, [%i0] - mov %o4, %o2 - subcc %i3, 0x8, %i3 - bgu,pt %xcc, 2b - add %i0, 0x8, %i0 - ba copyin_blalign - add %i1, %g1, %i1 - - ! Both source and destination are double aligned. - ! No shift and merge of data required in this case. -ci_dbcopy: - ldxa [%i1]ASI_AIUS, %o2 - stx %o2, [%i0] - add %i1, 0x8, %i1 - subcc %i3, 0x8, %i3 - bgu,pt %xcc, ci_dbcopy - add %i0, 0x8, %i0 - -copyin_blalign: - andn %i2, 0x3f, %i3 ! %i3 count is multiple of block size - sub %i2, %i3, %i2 ! Residue bytes in %i2 - - wr %g0, ASI_LDSTBI_P, %asi - - andcc %i1, 0xf, %o2 ! is src quadword aligned - bz,pn %xcc, ci_blkcpy ! src offset in %o2 (last 4-bits) - nop - cmp %o2, 0x8 - bg ci_upper_double - nop - bl ci_lower_double - nop - - ! Falls through when source offset is equal to 8 i.e. - ! source is double word aligned. - ! In this case no shift/merge of data is required - - sub %i1, %o2, %i1 ! align the src at 16 bytes. - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1]ASI_LDSTBI_AIUS, %l2 -ci_loop0: - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 - - prefetch [%l0+0x40], #one_read - - stxa %l3, [%i0+0x0]%asi - stxa %l4, [%i0+0x8]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - - stxa %l5, [%i0+0x10]%asi - stxa %l2, [%i0+0x18]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 - - stxa %l3, [%i0+0x20]%asi - stxa %l4, [%i0+0x28]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - - stxa %l5, [%i0+0x30]%asi - stxa %l2, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, ci_loop0 - add %i0, 0x40, %i0 - ba ci_blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - -ci_lower_double: - - sub %i1, %o2, %i1 ! align the src at 16 bytes. - sll %o2, 3, %o0 ! %o0 left shift - mov 0x40, %o1 - sub %o1, %o0, %o1 ! %o1 right shift = (64 - left shift) - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1]ASI_LDSTBI_AIUS, %l2 ! partial data in %l2 - ! and %l3 has complete - ! data -ci_loop1: - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 ! %l4 has partial data - ! for this read. - ALIGN_DATA(%l2, %l3, %l4, %o0, %o1, %l6) ! merge %l2, %l3 and %l4 - ! into %l2 and %l3 - - prefetch [%l0+0x40], #one_read - - stxa %l2, [%i0+0x0]%asi - stxa %l3, [%i0+0x8]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - ALIGN_DATA(%l4, %l5, %l2, %o0, %o1, %l6) ! merge %l2 with %l5 and - ! %l4 from previous read - ! into %l4 and %l5 - stxa %l4, [%i0+0x10]%asi - stxa %l5, [%i0+0x18]%asi - - ! Repeat the same for next 32 bytes. - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 - ALIGN_DATA(%l2, %l3, %l4, %o0, %o1, %l6) - - stxa %l2, [%i0+0x20]%asi - stxa %l3, [%i0+0x28]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - ALIGN_DATA(%l4, %l5, %l2, %o0, %o1, %l6) - - stxa %l4, [%i0+0x30]%asi - stxa %l5, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, ci_loop1 - add %i0, 0x40, %i0 - ba ci_blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - -ci_upper_double: - - sub %i1, %o2, %i1 ! align the src at 16 bytes. - sub %o2, 0x8, %o0 - sll %o0, 3, %o0 ! %o0 left shift - mov 0x40, %o1 - sub %o1, %o0, %o1 ! %o1 right shift = (64 - left shift) - andn %i1, 0x3f, %l0 ! %l0 has block aligned source - prefetch [%l0+0x0], #one_read - ldda [%i1]ASI_LDSTBI_AIUS, %l2 ! partial data in %l3 - ! for this read and - ! no data in %l2 -ci_loop2: - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 ! %l4 has complete data - ! and %l5 has partial - ALIGN_DATA(%l3, %l4, %l5, %o0, %o1, %l6) ! merge %l3, %l4 and %l5 - ! into %l3 and %l4 - prefetch [%l0+0x40], #one_read - - stxa %l3, [%i0+0x0]%asi - stxa %l4, [%i0+0x8]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - ALIGN_DATA(%l5, %l2, %l3, %o0, %o1, %l6) ! merge %l2 and %l3 with - ! %l5 from previous read - ! into %l5 and %l2 - - stxa %l5, [%i0+0x10]%asi - stxa %l2, [%i0+0x18]%asi - - ! Repeat the same for next 32 bytes. - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l4 - ALIGN_DATA(%l3, %l4, %l5, %o0, %o1, %l6) - - stxa %l3, [%i0+0x20]%asi - stxa %l4, [%i0+0x28]%asi - - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - ALIGN_DATA(%l5, %l2, %l3, %o0, %o1, %l6) - - stxa %l5, [%i0+0x30]%asi - stxa %l2, [%i0+0x38]%asi - - add %l0, 0x40, %l0 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, ci_loop2 - add %i0, 0x40, %i0 - ba ci_blkdone - add %i1, %o2, %i1 ! increment the source by src offset - ! the src offset was stored in %o2 - - - ! Do fast copy using ASI_LDSTBI_P -ci_blkcpy: - - andn %i1, 0x3f, %o0 ! %o0 has block aligned source - prefetch [%o0+0x0], #one_read -1: - ldda [%i1]ASI_LDSTBI_AIUS, %l0 - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l2 - add %i1, 0x10, %i1 - - prefetch [%o0+0x40], #one_read - - stxa %l0, [%i0+0x0]%asi - - ldda [%i1]ASI_LDSTBI_AIUS, %l4 - add %i1, 0x10, %i1 - ldda [%i1]ASI_LDSTBI_AIUS, %l6 - add %i1, 0x10, %i1 - - stxa %l1, [%i0+0x8]%asi - stxa %l2, [%i0+0x10]%asi - stxa %l3, [%i0+0x18]%asi - stxa %l4, [%i0+0x20]%asi - stxa %l5, [%i0+0x28]%asi - stxa %l6, [%i0+0x30]%asi - stxa %l7, [%i0+0x38]%asi - - add %o0, 0x40, %o0 - subcc %i3, 0x40, %i3 - bgu,pt %xcc, 1b - add %i0, 0x40, %i0 - -ci_blkdone: - membar #Sync - - ! Copy as much rest of the data as double word copy. -ci_dwcp: - cmp %i2, 0x8 ! Not enough bytes to copy as double - blu %xcc, ci_dbdone - nop - - andn %i2, 0x7, %i3 ! %i3 count is multiple of 8 bytes size - sub %i2, %i3, %i2 ! Residue bytes in %i2 - - andcc %i1, 7, %g1 ! is src aligned on a 8 bytes - bz %xcc, ci_cpy_db - nop - - sll %g1, 3, %l0 ! left shift - mov 0x40, %l1 - sub %l1, %l0, %l1 ! right shift = (64 - left shift) - -ci_cpy_dbwd: - sub %i1, %g1, %i1 ! align the src at 8 bytes. - ldxa [%i1]ASI_AIUS, %o2 -3: - add %i1, 0x8, %i1 - ldxa [%i1]ASI_AIUS, %o4 - ALIGN_DATA_EW(%o2, %o4, %l0, %l1, %o3) - stx %o2, [%i0] - mov %o4, %o2 - subcc %i3, 0x8, %i3 - bgu,pt %xcc, 3b - add %i0, 0x8, %i0 - ba ci_dbdone - add %i1, %g1, %i1 - -ci_cpy_db: - ldxa [%i1]ASI_AIUS, %o2 - stx %o2, [%i0] - add %i1, 0x8, %i1 - subcc %i3, 0x8, %i3 - bgu,pt %xcc, ci_cpy_db - add %i0, 0x8, %i0 - -ci_dbdone: - tst %i2 - bz,pt %xcc, copyin_exit - nop - - ! Copy the residue as byte copy -ci_residue: - lduba [%i1]ASI_AIUS, %i4 - stb %i4, [%i0] - inc %i1 - deccc %i2 - bgu %xcc, ci_residue - inc %i0 - -copyin_exit: - membar #Sync - ret - restore %g0, 0, %o0 -END(copyin) - -#endif /* lint */ -#endif - diff --git a/sys/sun4v/compile/.cvsignore b/sys/sun4v/compile/.cvsignore deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sys/sun4v/conf/.cvsignore b/sys/sun4v/conf/.cvsignore deleted file mode 100644 index 232298edb15f..000000000000 --- a/sys/sun4v/conf/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -[A-Za-z0-9]* diff --git a/sys/sun4v/conf/DEFAULTS b/sys/sun4v/conf/DEFAULTS deleted file mode 100644 index 87a55ec4737a..000000000000 --- a/sys/sun4v/conf/DEFAULTS +++ /dev/null @@ -1,13 +0,0 @@ -# -# DEFAULTS -- Default kernel configuration file for FreeBSD/sun4v -# -# $FreeBSD$ - -machine sun4v sparc64 - -# Pseudo devices. -device mem # Memory and kernel memory devices - -# Default partitioning schemes -options GEOM_PART_BSD -options GEOM_PART_VTOC8 diff --git a/sys/sun4v/conf/GENERIC b/sys/sun4v/conf/GENERIC deleted file mode 100644 index 0efdc5c005c5..000000000000 --- a/sys/sun4v/conf/GENERIC +++ /dev/null @@ -1,217 +0,0 @@ -# -# GENERIC -- Generic kernel configuration file for FreeBSD/sparc64 -# -# 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. -# -# For hardware specific information check HARDWARE.TXT -# -# $FreeBSD$ - -cpu SUN4V -ident GENERIC - -makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions NO_MODULES="" # disable modules (aicasm in buildenv) - -# Platforms supported -# At this time all platforms are supported, as-is. - -options SCHED_4BSD # 4BSD 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 NFSCL # New Network Filesystem Client -options NFSD # New Network Filesystem Server -options NFSLOCKD # Network Lock Manager -options NFS_ROOT # NFS usable as /, requires NFSCLIENT -#options MSDOSFS # MSDOS Filesystem -options NULLFS -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 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 AHC_REG_PRETTY_PRINT # Print register bitfields in debug - # output. Adds ~128k to driver. -options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. -options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4) -options AUDIT # Security event auditing -options MAC # TrustedBSD MAC Framework -options INCLUDE_CONFIG_FILE # Include this file in kernel - -# Debugging for use in -current -options KDB # Enable kernel debugger support. -options KDB_TRACE -options DDB # Support DDB. -#options TRAP_TRACING # Enable trap tracing. -#options TRAP_TRACE_ENTRIES=256 # Trap trace buffer entries. -#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 -#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones -#options DEBUG_LOCKS -#options DEBUG_VFS_LOCKS - -# To make an SMP kernel, the next line is needed -options SMP # Symmetric MultiProcessor Kernel - -# Standard busses -device pci -#device isa - - -# Floppy drives -#device fdc - -# ATA and ATAPI devices -device ata -options ATA_CAM - -# SCSI Controllers -#device ahc # AHA2940 and onboard AIC7xxx devices -#device isp # Qlogic family -#device ispfw # Firmware module for Qlogic host adapters -device mpt # LSI-Logic MPT-Fusion (not yet) -#device ncr # NCR/Symbios Logic -#device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') -#device esp # NCR53c9x (FEPS/FAS366) - -# 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) - -# RAID controllers -#device amr # AMI MegaRAID -#device mlx # Mylex DAC960 family - -# syscons is the default console driver, resembling an SCO console -#device sc -#device splash # Splash screen and screen saver support -#options KBD_INSTALL_CDEV # install a CDEV entry in /dev - -#device ofw_console # Open Firmware console device - -# Builtin hardware -#device auxio # auxiliary I/O device -#device clkbrd # Clock Board (blinkenlight on Sun Exx00) -#device eeprom # eeprom (really a front-end for the MK48Txx) -#device mk48txx # Mostek MK48Txx clocks -#device rtc # rtc (really a front-end for the MC146818) -#device mc146818 # Motorola MC146818 and compatible clocks - -# Serial (COM) ports -#device sab # Siemens SAB82532 based serial ports -#device uart # Multi-uart driver -#device puc # Multi-channel uarts - -# Parallel port -#device ppc -#device ppbus # Parallel port bus (required) -#device lpt # Printer -#device plip # TCP/IP over parallel -#device ppi # Parallel port interface device -#device vpo # Requires scbus and da - -# PCI Ethernet NICs. -#device de # DEC/Intel DC21x4x (``Tulip'') -device em # Intel PRO/1000 adapter Gigabit Ethernet Card -#device ixgb # Intel PRO/10GbE Ethernet Card -#device le # AMD Am7900 LANCE and Am79C9xx PCnet -#device txp # 3Com 3cR990 (``Typhoon'') -#device vx # 3Com 3c590, 3c595 (``Vortex'') - -# 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 bge # Broadcom BCM570xx Gigabit Ethernet - -# Pseudo devices. -device loop # Network loopback -device random # Entropy device -device ether # Ethernet support -device vlan # 802.1Q VLAN 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) - -# 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 - -# USB support -options USB_DEBUG # enable debug msgs -#device uhci # UHCI PCI->USB interface -#device ohci # OHCI PCI->USB interface -device usb # USB Bus (required) -#device udbp # USB Double Bulk Pipe devices (needs netgraph) -device uhid # "Human Interface Devices" -#device ukbd # Keyboard -device ulpt # Printer -#device umass # Disks/Mass storage - Requires scbus and da -device ums # Mouse -#device urio # Diamond Rio 500 MP3 player -# USB Ethernet, requires mii -#device aue # ADMtek USB Ethernet -#device axe # ASIX Electronics USB Ethernet -#device cdce # Generic USB over Ethernet -#device cue # CATC USB Ethernet -#device kue # Kawasaki LSI USB Ethernet -#device rue # RealTek RTL8150 USB Ethernet - -# FireWire support -#device firewire # FireWire bus code -#device sbp # SCSI over FireWire (Requires scbus and da) -#device fwe # Ethernet over FireWire (non-standard!) - -#options SIMULATOR # compile for ISA simulator -#options KTR -#options KTR_MASK=(KTR_TRAP) -#options USB_DEBUG -#options USB_VERBOSE -#options DEBUG_LOCKS -#options DEBUG_VFS_LOCKS - -device ccd - -# sched_lock incurs a rather high overhead at a 1000Hz with 32 cpus -# on most arches and in most cases 1000Hz pessimizes performance -# its choice was not adequately researched -options HZ=100 diff --git a/sys/sun4v/conf/GENERIC.hints b/sys/sun4v/conf/GENERIC.hints deleted file mode 100644 index e8c0da7a1d7e..000000000000 --- a/sys/sun4v/conf/GENERIC.hints +++ /dev/null @@ -1 +0,0 @@ -# $FreeBSD$ diff --git a/sys/sun4v/conf/Makefile b/sys/sun4v/conf/Makefile deleted file mode 100644 index 1c33841c2489..000000000000 --- a/sys/sun4v/conf/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -TARGET=sun4v - -.include "${.CURDIR}/../../conf/makeLINT.mk" diff --git a/sys/sun4v/conf/NOTES b/sys/sun4v/conf/NOTES deleted file mode 100644 index b655ae278a6f..000000000000 --- a/sys/sun4v/conf/NOTES +++ /dev/null @@ -1,117 +0,0 @@ -# $FreeBSD$ -# -# This file contains machine dependent kernel configuration notes. For -# machine independent notes, look in /sys/conf/NOTES. - - -##################################################################### -# CPU OPTIONS - -# -# You must specify at least one CPU (the one you intend to run on); -# deleting the specification for CPUs you don't need to use may make -# parts of the system run faster. -# XXX: On the Sparc64, there is only one CPU type -cpu SUN4V - - -##################################################################### -# HARDWARE BUS CONFIGURATION - -device ebus -device isa -device pci - - -##################################################################### -# HARDWARE DEVICE CONFIGURATION - -# -# Optional devices: -# - -device ofw_console # Open Firmware console device -option OFWCONS_POLL_HZ=4 # 20 or more works best on Ultra2 - - -##################################################################### -# Devices we don't want to deal with - -nodevice aha -nodevice bktr -nodevice blank_saver -nodevice bt -nodevice daemon_saver -nodevice dpt -nodevice dragon_saver -nodevice ep -nodevice ex -nodevice fade_saver -nodevice fdc -nodevice fire_saver -nodevice green_saver -nodevice hwpmc -nodevice logo_saver -nodevice pcii -nodevice ppc -nodevice rain_saver -nodevice sc -nodevice si -nodevice snake_saver -nodevice snd_ad1816 -nodevice snd_als4000 -nodevice snd_cmi -nodevice snd_cs4281 -nodevice snd_csa -nodevice snd_ds1 -nodevice snd_emu10k1 -nodevice snd_emu10kx -nodevice snd_ess -nodevice snd_fm801 -nodevice snd_gusc -nodevice snd_ich -nodevice snd_maestro -nodevice snd_maestro3 -nodevice snd_mss -nodevice snd_neomagic -nodevice snd_sb16 -nodevice snd_sb8 -nodevice snd_sbc -nodevice snd_solo -nodevice snd_t4dwave -nodevice snd_uaudio -nodevice snd_via8233 -nodevice snd_via82c686 -nodevice snd_vibes -nodevice splash -nodevice star_saver -nodevice tnt4882 -nodevice uart -nodevice ukbd -nodevice warp_saver -nodevice wds - - -##################################################################### -# Options we don't want to deal with - -nooption FDC_DEBUG -nooption SC_RENDER_DEBUG -nooption SC_DEBUG_LEVEL -nooption PPC_DEBUG -nooption PPC_PROBE_CHIPSET -nooption SC_NO_SUSPEND_VTYSWITCH -nooption SC_NO_FONT_LOADING -nooption SC_KERNEL_CONS_REV_ATTR -nooption SC_KERNEL_CONS_ATTR -nooption SC_NORM_REV_ATTR -nooption SC_NORM_ATTR -nooption SC_DFLT_FONT -nooption SC_ALT_MOUSE_IMAGE -nooption EXT2FS - - -##################################################################### -# Make options we don't want to deal with - -nomakeoption SC_DFLT_FONT diff --git a/sys/sun4v/include/_align.h b/sys/sun4v/include/_align.h deleted file mode 100644 index bce15576e0f0..000000000000 --- a/sys/sun4v/include/_align.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $FreeBSD$ - */ - -#ifndef _SUN4V_INCLUDE__ALIGN_H_ -#define _SUN4V_INCLUDE__ALIGN_H_ - -/* - * Round p (pointer or byte index) up to a correctly-aligned value - * for all data types (int, long, ...). The result is unsigned int - * and must be cast to any desired pointer type. - */ -#define _ALIGNBYTES 0xf -#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) - -#endif /* !_SUN4V_INCLUDE__ALIGN_H_ */ diff --git a/sys/sun4v/include/_bus.h b/sys/sun4v/include/_bus.h deleted file mode 100644 index 7cbe96f96fd6..000000000000 --- a/sys/sun4v/include/_bus.h +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * Copyright (c) 2005 M. Warner Losh. - * 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, - * without modification, immediately at the beginning of the file. - * 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. - * - * $FreeBSD$ - */ - -#ifndef SPARC64_INCLUDE__BUS_H -#define SPARC64_INCLUDE__BUS_H - -/* - * Bus address and size types - */ -typedef u_long bus_space_handle_t; -typedef int bus_type_t; -typedef u_long bus_addr_t; -typedef u_long bus_size_t; -typedef struct bus_space_tag *bus_space_tag_t; - -#endif /* SPARC64_INCLUDE__BUS_H */ diff --git a/sys/sun4v/include/_inttypes.h b/sys/sun4v/include/_inttypes.h deleted file mode 100644 index 264c8753476f..000000000000 --- a/sys/sun4v/include/_inttypes.h +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * 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.4 2008/04/28 20:23:36 martin Exp $ - * $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_ */ diff --git a/sys/sun4v/include/_limits.h b/sys/sun4v/include/_limits.h deleted file mode 100644 index 49a768b087e0..000000000000 --- a/sys/sun4v/include/_limits.h +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE__LIMITS_H_ -#define _MACHINE__LIMITS_H_ - -/* - * According to ANSI (section 2.2.4.2), the values below must be usable by - * #if preprocessing directives. Additionally, the expression must have the - * same type as would an expression that is an object of the corresponding - * 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). - */ - -#define __CHAR_BIT 8 /* number of bits in a char */ - -#define __SCHAR_MAX 0x7f /* max value for a signed char */ -#define __SCHAR_MIN (-0x7f-1) /* min value for a signed char */ - -#define __UCHAR_MAX 0xff /* max value for an unsigned char */ - -#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 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 0xffffffffffffffff /* max for an unsigned long */ -#define __LONG_MAX 0x7fffffffffffffff /* max for a long */ -#define __LONG_MIN (-0x7fffffffffffffff-1) /* min for a long */ - -/* Long longs have the same size but not the same type as longs. */ - /* max for an unsigned long long */ -#define __ULLONG_MAX 0xffffffffffffffffULL -#define __LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */ -#define __LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */ - -#define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ - -#define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ - -#define __OFF_MAX __LONG_MAX /* max value for an off_t */ -#define __OFF_MIN __LONG_MIN /* min value for an off_t */ - -/* Quads and longs are the same size. Ensure they stay in sync. */ -#define __UQUAD_MAX (__ULONG_MAX) /* max value for a uquad_t */ -#define __QUAD_MAX (__LONG_MAX) /* max value for a quad_t */ -#define __QUAD_MIN (__LONG_MIN) /* min value for a quad_t */ - -#define __LONG_BIT 64 -#define __WORD_BIT 32 - -/* Minimum signal stack size. */ -#define __MINSIGSTKSZ (1024 * 4) - -#endif /* !_MACHINE__LIMITS_H_ */ diff --git a/sys/sun4v/include/_stdint.h b/sys/sun4v/include/_stdint.h deleted file mode 100644 index e36c6598861b..000000000000 --- a/sys/sun4v/include/_stdint.h +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * Copyright (c) 2001, 2002 Mike Barcroft - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE__STDINT_H_ -#define _MACHINE__STDINT_H_ - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) - -#define INT8_C(c) (c) -#define INT16_C(c) (c) -#define INT32_C(c) (c) -#define INT64_C(c) (c ## L) - -#define UINT8_C(c) (c) -#define UINT16_C(c) (c) -#define UINT32_C(c) (c ## U) -#define UINT64_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) */ - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) - -/* - * ISO/IEC 9899:1999 - * 7.18.2.1 Limits of exact-width integer types - */ -/* Minimum values of exact-width signed integer types. */ -#define INT8_MIN (-0x7f-1) -#define INT16_MIN (-0x7fff-1) -#define INT32_MIN (-0x7fffffff-1) -#define INT64_MIN (-0x7fffffffffffffffL-1) - -/* Maximum values of exact-width signed integer types. */ -#define INT8_MAX 0x7f -#define INT16_MAX 0x7fff -#define INT32_MAX 0x7fffffff -#define INT64_MAX 0x7fffffffffffffffL - -/* Maximum values of exact-width unsigned integer types. */ -#define UINT8_MAX 0xff -#define UINT16_MAX 0xffff -#define UINT32_MAX 0xffffffffU -#define UINT64_MAX 0xffffffffffffffffUL - -/* - * ISO/IEC 9899:1999 - * 7.18.2.2 Limits of minimum-width integer types - */ -/* Minimum values of minimum-width signed integer types. */ -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST64_MIN INT64_MIN - -/* Maximum values of minimum-width signed integer types. */ -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MAX INT64_MAX - -/* Maximum values of minimum-width unsigned integer types. */ -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.3 Limits of fastest minimum-width integer types - */ -/* Minimum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MIN INT32_MIN -#define INT_FAST16_MIN INT32_MIN -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST64_MIN INT64_MIN - -/* Maximum values of fastest minimum-width signed integer types. */ -#define INT_FAST8_MAX INT32_MAX -#define INT_FAST16_MAX INT32_MAX -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MAX INT64_MAX - -/* Maximum values of fastest minimum-width unsigned integer types. */ -#define UINT_FAST8_MAX UINT32_MAX -#define UINT_FAST16_MAX UINT32_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.4 Limits of integer types capable of holding object pointers - */ -#define INTPTR_MIN INT64_MIN -#define INTPTR_MAX INT64_MAX -#define UINTPTR_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.2.5 Limits of greatest-width integer types - */ -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -/* - * ISO/IEC 9899:1999 - * 7.18.3 Limits of other integer types - */ -/* Limits of ptrdiff_t. */ -#define PTRDIFF_MIN INT64_MIN -#define PTRDIFF_MAX INT64_MAX - -/* Limits of sig_atomic_t. */ -#define SIG_ATOMIC_MIN INT32_MIN -#define SIG_ATOMIC_MAX INT32_MAX - -/* Limit of size_t. */ -#define SIZE_MAX UINT64_MAX - -#ifndef WCHAR_MIN /* Also possibly defined in */ -/* Limits of wchar_t. */ -#define WCHAR_MIN INT32_MIN -#define WCHAR_MAX INT32_MAX -#endif - -/* Limits of wint_t. */ -#define WINT_MIN INT32_MIN -#define WINT_MAX INT32_MAX - -#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - -#endif /* !_MACHINE__STDINT_H_ */ diff --git a/sys/sun4v/include/_types.h b/sys/sun4v/include/_types.h deleted file mode 100644 index 612bda749a85..000000000000 --- a/sys/sun4v/include/_types.h +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * Copyright (c) 2002 Mike Barcroft - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 - * From: @(#)types.h 8.3 (Berkeley) 1/5/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -/* - * Basic types upon which most other types are built. - */ -typedef __signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -typedef long __int64_t; -typedef unsigned long __uint64_t; - -/* - * Standard type definitions. - */ -typedef __int32_t __clock_t; /* clock()... */ -typedef __uint32_t __cpumask_t; -typedef __int64_t __critical_t; -typedef double __double_t; -typedef float __float_t; -typedef __int64_t __intfptr_t; -typedef __int64_t __intmax_t; -typedef __int64_t __intptr_t; -typedef __int32_t __int_fast8_t; -typedef __int32_t __int_fast16_t; -typedef __int32_t __int_fast32_t; -typedef __int64_t __int_fast64_t; -typedef __int8_t __int_least8_t; -typedef __int16_t __int_least16_t; -typedef __int32_t __int_least32_t; -typedef __int64_t __int_least64_t; -typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */ -typedef __int64_t __register_t; -typedef __int64_t __segsz_t; /* segment size (in pages) */ -typedef __uint64_t __size_t; /* sizeof() */ -typedef __int64_t __ssize_t; /* byte count or error */ -typedef __int64_t __time_t; /* time()... */ -typedef __uint64_t __uintfptr_t; -typedef __uint64_t __uintmax_t; -typedef __uint64_t __uintptr_t; -typedef __uint32_t __uint_fast8_t; -typedef __uint32_t __uint_fast16_t; -typedef __uint32_t __uint_fast32_t; -typedef __uint64_t __uint_fast64_t; -typedef __uint8_t __uint_least8_t; -typedef __uint16_t __uint_least16_t; -typedef __uint32_t __uint_least32_t; -typedef __uint64_t __uint_least64_t; -typedef __uint64_t __u_register_t; -typedef __uint64_t __vm_offset_t; -typedef __int64_t __vm_ooffset_t; -typedef __uint64_t __vm_paddr_t; -typedef __uint64_t __vm_pindex_t; -typedef __uint64_t __vm_size_t; - -/* - * Unusual type definitions. - */ -#ifdef __GNUCLIKE_BUILTIN_VARARGS -typedef __builtin_va_list __va_list; /* internally known to gcc */ -#else -typedef char * __va_list; -#endif /* __GNUCLIKE_BUILTIN_VARARGS */ -#if defined(__GNUCLIKE_BUILTIN_VAALIST) && !defined(__GNUC_VA_LIST) \ - && !defined(__NO_GNUC_VA_LIST) -#define __GNUC_VA_LIST -typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/ -#endif - -typedef __uint64_t tte_t; - -#endif /* !_MACHINE__TYPES_H_ */ diff --git a/sys/sun4v/include/asi.h b/sys/sun4v/include/asi.h deleted file mode 100644 index e37785993c08..000000000000 --- a/sys/sun4v/include/asi.h +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * - * 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 BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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: BSDI: asi.h,v 1.3 1997/08/08 14:31:42 torek - * $FreeBSD$ - */ - -#ifndef _MACHINE_ASI_H_ -#define _MACHINE_ASI_H_ - -/* - * UltraSPARC Architecture 2005 ASIs - */ -#define ASI_N 0x04 /* ASI_NUCLEUS */ - -#define ASI_NL 0x0c /* ASI_NUCLEUS_LITTLE */ - -#define ASI_AIUP 0x10 /* ASI_AS_IF_USER_PRIMARY */ -#define ASI_AIUS 0x11 /* ASI_AS_IF_USER_SECONDARY */ - -#define ASI_REAL 0x14 -#define ASI_REAL_IO 0x15 -#define ASI_BLK_AIUP 0x16 /* ASI_BLOCK_AS_IF_USER_PRIMARY */ -#define ASI_BLK_AIUS 0x17 /* ASI_BLOCK_AS_IF_USER_SECONDARY */ -#define ASI_AIUPL 0x18 /* ASI_AS_IF_USER_PRIMARY_LITTLE */ -#define ASI_AIUSL 0x19 /* ASI_AS_IF_USER_SECONDARY_LITTLE */ - -#define ASI_REAL_L 0x1C /* ASI_REAL_LITTLE */ -#define ASI_REAL_IO_L 0x1D /* ASI_REAL_IO_LITTLE */ -#define ASI_BLK_AIUPL 0x1E /* ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE */ -#define ASI_BLK_AIUSL 0x1F /* ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE */ -#define ASI_SCRATCHPAD 0x20 -#define ASI_MMU_CONTEXTID 0x21 -#define ASI_LDTD_AIUP 0x22 /* ASI_LOAD_TWIN_DW_AS_IF_USER_PRIMARY */ -#define ASI_LDSTBI_AIUP 0x22 -#define ASI_LDTD_AIUS 0x23 /* ASI_LOAD_TWIN_DW_AS_IF_USER_SECONDARY */ -#define ASI_LDSTBI_AIUS 0x23 -#define ASI_QUEUE 0x25 -#define ASI_LDTD_REAL 0x26 /* ASI_LOAD_TWIN_DW_REAL */ -#define ASI_STBI_REAL 0x26 -#define ASI_LDTD_N 0x27 /* ASI_LOAD_TWIN_DW_NUCLEUS */ -#define ASI_LDSTBI_N 0x27 - -#define ASI_LDTD_AIUPL 0x2A /* ASI_LD_TWIN_DW_AS_IF_USER_PRIMARY_LITTLE */ -#define ASI_LDTD_AIUSL 0x2B /* ASI_LD_TWIN_DW_AS_IF_USER_SECONDARY_LITTLE */ - -#define ASI_LDTD_REAL_L 0x2E /* ASI_LOAD_TWIN_DW_REAL_LITTLE */ -#define ASI_LDTD_NL 0x2F /* ASI_LOAD_TWIN_DW_NUCLEUS_LITTLE */ - - - -#define ASI_P 0x80 /* ASI_PRIMARY */ -#define ASI_S 0x81 /* ASI_SECONDARY */ -#define ASI_PNF 0x82 /* ASI_PRIMARY_NO_FAULT */ -#define ASI_SNF 0x83 /* ASI_SECONDARY_NO_FAULT */ - -#define ASI_PL 0x88 /* ASI_PRIMARY_LITTLE */ -#define ASI_SL 0x89 /* ASI_SECONDARY_LITTLE */ -#define ASI_PNFL 0x8a /* ASI_PRIMARY_NO_FAULT_LITTLE */ -#define ASI_SNFL 0x8b /* ASI_SECONDARY_NO_FAULT_LITTLE */ - -#define ASI_PST8_P 0xc0 -#define ASI_PST8_S 0xc1 -#define ASI_PST16_P 0xc2 -#define ASI_PST16_S 0xc3 -#define ASI_PST32_P 0xc4 -#define ASI_PST32_S 0xc5 - - -#define ASI_PST8_PL 0xc8 -#define ASI_PST8_SL 0xc9 -#define ASI_PST16_PL 0xca -#define ASI_PST16_SL 0xcb -#define ASI_PST32_PL 0xcc -#define ASI_PST32_SL 0xcd - -#define ASI_FL8_P 0xd0 -#define ASI_FL8_S 0xd1 -#define ASI_FL16_P 0xd2 -#define ASI_FL16_S 0xd3 - -#define ASI_FL8_PL 0xd8 -#define ASI_FL8_SL 0xd9 -#define ASI_FL16_PL 0xda -#define ASI_FL16_SL 0xdb - -#define ASI_LDTD_P 0xe2 /* ASI_LOAD_TWIN_DW_PRIMARY */ -#define ASI_LDSTBI_P 0xe2 - -#define ASI_LDTD_S 0xe3 /* ASI_LOAD_TWIN_DW_SECONDARY */ - -#define ASI_LDTD_PL 0xea /* ASI_LOAD_TWIN_DW_PRIMARY_LITTLE */ -#define ASI_LDTD_SL 0xeb /* ASI_LOAD_TWIN_DW_SECONDARY_LITTLE */ - -#define ASI_BLK_P 0xf0 /* ASI_BLOCK_PRIMARY */ -#define ASI_BLK_S 0xf1 /* ASI_BLOCK_SECONDARY */ - -#define ASI_BLK_PL 0xf8 /* ASI_BLOCK_PRIMARY_LITTLE */ -#define ASI_BLK_SL 0xf9 /* ASI_BLOCK_SECONDARY_LITTLE */ - - - -#define ASI_SCRATCHPAD_0_REG 0x00 -#define ASI_SCRATCHPAD_1_REG 0x08 -#define ASI_SCRATCHPAD_2_REG 0x10 -#define ASI_SCRATCHPAD_3_REG 0x18 -#define ASI_SCRATCHPAD_6_REG 0x30 -#define ASI_SCRATCHPAD_7_REG 0x38 - - -#define SCRATCH_REG_MMFSA ASI_SCRATCHPAD_0_REG -#define SCRATCH_REG_PCPU ASI_SCRATCHPAD_1_REG -#define SCRATCH_REG_HASH_KERNEL ASI_SCRATCHPAD_2_REG -#define SCRATCH_REG_TSB_KERNEL ASI_SCRATCHPAD_3_REG -#define SCRATCH_REG_HASH_USER ASI_SCRATCHPAD_6_REG -#define SCRATCH_REG_TSB_USER ASI_SCRATCHPAD_7_REG - -#define MMU_CID_P 0x08 -#define MMU_CID_S 0x10 - -#define CPU_MONDO_QUEUE_HEAD 0x3c0 -#define CPU_MONDO_QUEUE_TAIL 0x3c8 -#define DEV_MONDO_QUEUE_HEAD 0x3d0 -#define DEV_MONDO_QUEUE_TAIL 0x3d8 -#define RESUMABLE_ERROR_QUEUE_HEAD 0x3e0 -#define RESUMABLE_ERROR_QUEUE_TAIL 0x3e8 -#define NONRESUMABLE_ERROR_QUEUE_HEAD 0x3f0 -#define NONRESUMABLE_ERROR_QUEUE_TAIL 0x3f8 - -#define Q(queue_head) (queue_head >> 4) - - -/* - * sparc64 compat for the loader - */ -#define AA_IMMU_TAR 0x30 -#define AA_DMMU_TAR 0x30 - -#define ASI_UPA_CONFIG_REG 0x4a /* US-I, II */ -#define ASI_FIREPLANE_CONFIG_REG 0x4a /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_CONFIG 0x0 /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_ADDRESS 0x8 /* US-III{,+}, IV{,+} */ -#define AA_FIREPLANE_CONFIG_2 0x10 /* US-IV{,+} */ -#define ASI_JBUS_CONFIG_REG 0x4a /* US-IIIi{,+} */ -#define ASI_IMMU 0x50 -#define ASI_ITLB_DATA_IN_REG 0x54 -#define ASI_ITLB_DATA_ACCESS_REG 0x55 -#define ASI_ITLB_TAG_READ_REG 0x56 -#define ASI_IMMU_DEMAP 0x57 -#define ASI_DMMU 0x58 -#define ASI_DTLB_DATA_IN_REG 0x5c -#define ASI_DTLB_DATA_ACCESS_REG 0x5d -#define ASI_DTLB_TAG_READ_REG 0x5e -#define ASI_INTR_ID 0x63 /* US-IV{,+} */ -#define AA_INTR_ID 0x0 /* US-IV{,+} */ - -#endif /* !_MACHINE_ASI_H_ */ diff --git a/sys/sun4v/include/asm.h b/sys/sun4v/include/asm.h deleted file mode 100644 index 780149b5e644..000000000000 --- a/sys/sun4v/include/asm.h +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 - * from: FreeBSD: src/sys/i386/include/asm.h,v 1.7 2000/01/25 - * $FreeBSD$ - */ - -#ifndef _MACHINE_ASM_H_ -#define _MACHINE_ASM_H_ - -#define __ASM__ - -#include - -#ifdef PIC -#define PIC_PROLOGUE(r1, r2) \ - sethi %hi(_GLOBAL_OFFSET_TABLE_-4), r1 ; \ - rd %pc, r2 ; \ - or r1, %lo(_GLOBAL_OFFSET_TABLE_+4), r1 ; \ - add r2, r1, r2 -#define SET(name, r1, r2) \ - set name, r2 ; \ - ldx [r1 + r2], r2 -#else -#define PIC_PROLOGUE(r1, r2) -#define SET(name, r1, r2) \ - set name, r2 -#endif - -/* - * CNAME and HIDENAME manage the relationship between symbol names in C - * and the equivalent assembly language names. CNAME is given a name as - * it would be used in a C program. It expands to the equivalent assembly - * language name. HIDENAME is given an assembly-language name, and expands - * to a possibly-modified form that will be invisible to C programs. - */ -#define CNAME(csym) csym -#define HIDENAME(asmsym) __CONCAT(.,asmsym) - -#define CCFSZ 192 -#define SPOFF 2047 - -#define _ALIGN_TEXT .align 32 - -#define _START_ENTRY \ - .text ; \ - _ALIGN_TEXT - -/* - * Define a function entry point. - * - * The compiler produces #function for the .type pseudo-op, but the '#' - * character has special meaning in cpp macros, so we use @function like - * other architectures. The assembler seems to accept both. - * The assembler also accepts a .proc pseudo-op, which is used by the - * peep hole optimizer, whose argument is the type code of the return - * value. Since this is difficult to predict and its expected that - * assembler code is already optimized, we leave it out. - */ -#define _ENTRY(x) \ - _START_ENTRY ; \ - .globl CNAME(x) ; \ - .type CNAME(x),@function ; \ -CNAME(x): - -#define ENTRY(x) _ENTRY(x) -#define END(x) .size x, . - x - -#define STACK_ALIGN 64 -#define SA(X) (((X)+(STACK_ALIGN-1)) & ~(STACK_ALIGN-1)) -#define WINDOWSIZE64 (16*8) -#define MINFRAME64 (WINDOWSIZE64 + 64) -#define MINFRAME MINFRAME64 -#define REGOFF SA(MINFRAME) - -/* - * Kernel RCS ID tag and copyright macros - */ - -#undef __FBSDID -#if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s -#else -#define __FBSDID(s) /* nothing */ -#endif /* not lint and not STRIP_FBSDID */ - -#endif /* !_MACHINE_ASM_H_ */ diff --git a/sys/sun4v/include/asmacros.h b/sys/sun4v/include/asmacros.h deleted file mode 100644 index 884dc5caabe0..000000000000 --- a/sys/sun4v/include/asmacros.h +++ /dev/null @@ -1,340 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_ASMACROS_H_ -#define _MACHINE_ASMACROS_H_ - -#ifdef _KERNEL - -/* - * %g7 points to per-cpu data. - */ -#define PCPU_REG %g7 - - -#ifdef LOCORE - -/* - * Atomically decrement an integer in memory. - */ -#define ATOMIC_DEC_INT(r1, r2, r3) \ - lduw [r1], r2 ; \ -9: sub r2, 1, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically increment an integer in memory. - */ -#define ATOMIC_INC_INT(r1, r2, r3) \ - lduw [r1], r2 ; \ -9: add r2, 1, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically increment an u_long in memory. - */ -#define ATOMIC_INC_ULONG(r1, r2, r3) \ - ldx [r1], r2 ; \ -9: add r2, 1, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -/* - * Atomically clear a number of bits of an integer in memory. - */ -#define ATOMIC_CLEAR_INT(r1, r2, r3, bits) \ - lduw [r1], r2 ; \ -9: andn r2, bits, r3 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %icc, 9b ; \ - mov r3, r2 - -#define PCPU(member) PCPU_REG + PC_ ## member -#define PCPU_ADDR(member, reg) \ - add PCPU_REG, PC_ ## member, reg - -#define DEBUGGER() \ - ta %xcc, 1 - -#define PANIC(msg, r1) \ - .sect .rodata ; \ -9: .asciz msg ; \ - .previous ; \ - SET(9b, r1, %o0) ; \ - call panic ; \ - nop - -#ifdef INVARIANTS -#define KASSERT(r1, msg) \ - brnz r1, 8f ; \ - nop ; \ - PANIC(msg, r1) ; \ -8: -#else -#define KASSERT(r1, msg) -#endif - -#define PUTS(msg, r1) \ - .sect .rodata ; \ -9: .asciz msg ; \ - .previous ; \ - SET(9b, r1, %o0) ; \ - call printf ; \ - nop - -#define _ALIGN_DATA .align 8 - -#define DATA(name) \ - .data ; \ - _ALIGN_DATA ; \ - .globl name ; \ - .type name, @object ; \ -name: - -#define EMPTY - -#define GET_MMFSA_SCRATCH(reg) \ - ldxa [%g0 + %g0]ASI_SCRATCHPAD, reg; - - -#define GET_PCPU_PHYS_SCRATCH(tmp) \ - sethi %uhi(VM_MIN_DIRECT_ADDRESS), tmp; \ - mov SCRATCH_REG_PCPU, PCPU_REG; \ - sllx tmp, 32, tmp; \ - ldxa [%g0 + PCPU_REG]ASI_SCRATCHPAD, PCPU_REG; \ - andn PCPU_REG, tmp, PCPU_REG - -#define GET_PCPU_SCRATCH \ - mov SCRATCH_REG_PCPU, PCPU_REG; \ - ldxa [%g0 + PCPU_REG]ASI_SCRATCHPAD, PCPU_REG; - -#define GET_PCPU_SCRATCH_SLOW(reg) \ - mov SCRATCH_REG_PCPU, reg; \ - ldxa [reg]ASI_SCRATCHPAD, PCPU_REG; - -#define GET_HASH_SCRATCH_USER(reg) \ - mov SCRATCH_REG_HASH_USER, reg; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; - -#define GET_HASH_SCRATCH_KERNEL(reg) \ - mov SCRATCH_REG_HASH_KERNEL, reg; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; - -#define GET_HASH_PHYS_SCRATCH_USER(tmp, reg) \ - sethi %uhi(VM_MIN_DIRECT_ADDRESS), tmp; \ - mov SCRATCH_REG_HASH_USER, reg; \ - sllx tmp, 32, tmp; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; \ - andn reg, tmp, reg; - -#define GET_HASH_PHYS_SCRATCH_KERNEL(tmp, reg) \ - sethi %uhi(VM_MIN_DIRECT_ADDRESS), tmp; \ - mov SCRATCH_REG_HASH_KERNEL, reg; \ - sllx tmp, 32, tmp; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; \ - andn reg, tmp, reg; - - - -#define GET_TSB_SCRATCH_USER(reg) \ - mov SCRATCH_REG_TSB_USER, reg; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; - -#define GET_TSB_SCRATCH_KERNEL(reg) \ - mov SCRATCH_REG_TSB_KERNEL, reg; \ - ldxa [%g0 + reg]ASI_SCRATCHPAD, reg; - -#define SET_SCRATCH(offsetreg, reg) stxa reg, [%g0 + offsetreg]ASI_SCRATCHPAD - - -#define GET_PCB_PHYS(tmp, reg) \ - mov PC_CURPCB, reg; \ - GET_PCPU_PHYS_SCRATCH(tmp); \ - ldxa [PCPU_REG + reg]ASI_REAL, reg; \ - sub reg, tmp, reg; - - -#define GET_PCB(reg) \ - GET_PCPU_SCRATCH; \ - ldx [PCPU_REG + PC_CURPCB], reg; - -#define SET_MMU_CONTEXT(typereg, reg) stxa reg, [typereg]ASI_MMU_CONTEXTID -#define GET_MMU_CONTEXT(typereg, reg) ldxa [typereg]ASI_MMU_CONTEXTID, reg - - - -#define SAVE_GLOBALS(TF) \ - stx %g1, [TF + TF_G1]; \ - stx %g2, [TF + TF_G2]; \ - stx %g3, [TF + TF_G3]; \ - stx %g4, [TF + TF_G4]; \ - stx %g5, [TF + TF_G5]; \ - stx %g6, [TF + TF_G6]; - -#define RESTORE_GLOBALS_USER(TF) \ - ldx [TF + TF_G1], %g1; \ - ldx [TF + TF_G2], %g2; \ - ldx [TF + TF_G3], %g3; \ - ldx [TF + TF_G4], %g4; \ - ldx [TF + TF_G5], %g5; \ - ldx [TF + TF_G6], %g6; \ - ldx [TF + TF_G7], %g7; - -#define RESTORE_GLOBALS_KERNEL(TF) \ - mov SCRATCH_REG_PCPU, %g7; \ - ldx [TF + TF_G1], %g1; \ - ldx [TF + TF_G2], %g2; \ - ldx [TF + TF_G3], %g3; \ - ldx [TF + TF_G4], %g4; \ - ldx [TF + TF_G5], %g5; \ - ldx [TF + TF_G6], %g6; \ - ldxa [%g0 + %g7]ASI_SCRATCHPAD, %g7; - -#define SAVE_OUTS(TF) \ - stx %i0, [TF + TF_O0]; \ - stx %i1, [TF + TF_O1]; \ - stx %i2, [TF + TF_O2]; \ - stx %i3, [TF + TF_O3]; \ - stx %i4, [TF + TF_O4]; \ - stx %i5, [TF + TF_O5]; \ - stx %i6, [TF + TF_O6]; \ - stx %i7, [TF + TF_O7]; - -#define RESTORE_OUTS(TF) \ - ldx [TF + TF_O0], %i0; \ - ldx [TF + TF_O1], %i1; \ - ldx [TF + TF_O2], %i2; \ - ldx [TF + TF_O3], %i3; \ - ldx [TF + TF_O4], %i4; \ - ldx [TF + TF_O5], %i5; \ - ldx [TF + TF_O6], %i6; \ - ldx [TF + TF_O7], %i7; - - -#define SAVE_WINDOW(SBP) \ - stx %l0, [SBP + (0*8)]; \ - stx %l1, [SBP + (1*8)]; \ - stx %l2, [SBP + (2*8)]; \ - stx %l3, [SBP + (3*8)]; \ - stx %l4, [SBP + (4*8)]; \ - stx %l5, [SBP + (5*8)]; \ - stx %l6, [SBP + (6*8)]; \ - stx %l7, [SBP + (7*8)]; \ - stx %i0, [SBP + (8*8)]; \ - stx %i1, [SBP + (9*8)]; \ - stx %i2, [SBP + (10*8)]; \ - stx %i3, [SBP + (11*8)]; \ - stx %i4, [SBP + (12*8)]; \ - stx %i5, [SBP + (13*8)]; \ - stx %i6, [SBP + (14*8)]; \ - stx %i7, [SBP + (15*8)]; - -#define SAVE_WINDOW_ASI(SBP) \ - stxa %l0, [SBP + (0*8)]%asi; \ - stxa %l1, [SBP + (1*8)]%asi; \ - stxa %l2, [SBP + (2*8)]%asi; \ - stxa %l3, [SBP + (3*8)]%asi; \ - stxa %l4, [SBP + (4*8)]%asi; \ - stxa %l5, [SBP + (5*8)]%asi; \ - stxa %l6, [SBP + (6*8)]%asi; \ - stxa %l7, [SBP + (7*8)]%asi; \ - stxa %i0, [SBP + (8*8)]%asi; \ - stxa %i1, [SBP + (9*8)]%asi; \ - stxa %i2, [SBP + (10*8)]%asi; \ - stxa %i3, [SBP + (11*8)]%asi; \ - stxa %i4, [SBP + (12*8)]%asi; \ - stxa %i5, [SBP + (13*8)]%asi; \ - stxa %i6, [SBP + (14*8)]%asi; \ - stxa %i7, [SBP + (15*8)]%asi; - -#define SAVE_LOCALS_ASI(SBP) \ - stxa %l0, [SBP + (0*8)]%asi; \ - stxa %l1, [SBP + (1*8)]%asi; \ - stxa %l2, [SBP + (2*8)]%asi; \ - stxa %l3, [SBP + (3*8)]%asi; \ - stxa %l4, [SBP + (4*8)]%asi; \ - stxa %l5, [SBP + (5*8)]%asi; \ - stxa %l6, [SBP + (6*8)]%asi; \ - stxa %l7, [SBP + (7*8)]%asi; - -#define RESTORE_LOCALS_ASI(SBP) \ - ldxa [SBP + (0*8)]%asi, %l0; \ - ldxa [SBP + (1*8)]%asi, %l1; \ - ldxa [SBP + (2*8)]%asi, %l2; \ - ldxa [SBP + (3*8)]%asi, %l3; \ - ldxa [SBP + (4*8)]%asi, %l4; \ - ldxa [SBP + (5*8)]%asi, %l5; \ - ldxa [SBP + (6*8)]%asi, %l6; \ - ldxa [SBP + (7*8)]%asi, %l7; - -#define SAVE_OUTS_ASI(SBP) \ - stxa %o0, [SBP + (0*8)]%asi; \ - stxa %o1, [SBP + (1*8)]%asi; \ - stxa %o2, [SBP + (2*8)]%asi; \ - stxa %o3, [SBP + (3*8)]%asi; \ - stxa %o4, [SBP + (4*8)]%asi; \ - stxa %o5, [SBP + (5*8)]%asi; \ - stxa %o6, [SBP + (6*8)]%asi; \ - stxa %o7, [SBP + (7*8)]%asi; - -#define RESTORE_OUTS_ASI(SBP) \ - ldxa [SBP + (0*8)]%asi, %o0; \ - ldxa [SBP + (1*8)]%asi, %o1; \ - ldxa [SBP + (2*8)]%asi, %o2; \ - ldxa [SBP + (3*8)]%asi, %o3; \ - ldxa [SBP + (4*8)]%asi, %o4; \ - ldxa [SBP + (5*8)]%asi, %o5; \ - ldxa [SBP + (6*8)]%asi, %o6; \ - ldxa [SBP + (7*8)]%asi, %o7; - - -#define TTRACE_ADD_SAFE(SBP, arg0, arg1, arg2, arg3, arg4) \ - SAVE_OUTS_ASI(SBP); \ - mov arg0, %o0; \ - mov arg1, %o1; \ - mov arg2, %o2; \ - mov arg3, %o3; \ - mov arg4, %o4; \ - RESTORE_OUTS_ASI(SBP); - - -#endif /* LOCORE */ - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_ASMACROS_H_ */ diff --git a/sys/sun4v/include/atomic.h b/sys/sun4v/include/atomic.h deleted file mode 100644 index c5005fabdf8e..000000000000 --- a/sys/sun4v/include/atomic.h +++ /dev/null @@ -1,299 +0,0 @@ -/*- - * Copyright (c) 1998 Doug Rabson. - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11 - * $FreeBSD$ - */ - -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ - -#include - -#define mb() __asm__ __volatile__ ("membar #MemIssue": : :"memory") -#define wmb() mb() -#define rmb() mb() - -/* Userland needs different ASI's. */ -#ifdef _KERNEL -#define __ASI_ATOMIC ASI_N -#else -#define __ASI_ATOMIC ASI_P -#endif - -/* - * Various simple arithmetic on memory which is atomic in the presence - * of interrupts and multiple processors. See atomic(9) for details. - * Note that efficient hardware support exists only for the 32 and 64 - * bit variants; the 8 and 16 bit versions are not provided and should - * not be used in MI code. - * - * This implementation takes advantage of the fact that the sparc64 - * cas instruction is both a load and a store. The loop is often coded - * as follows: - * - * do { - * expect = *p; - * new = expect + 1; - * } while (cas(p, expect, new) != expect); - * - * which performs an unnnecessary load on each iteration that the cas - * operation fails. Modified as follows: - * - * expect = *p; - * for (;;) { - * new = expect + 1; - * result = cas(p, expect, new); - * if (result == expect) - * break; - * expect = result; - * } - * - * the return value of cas is used to avoid the extra reload. - * - * The memory barriers provided by the acq and rel variants are intended - * to be sufficient for use of relaxed memory ordering. Due to the - * suggested assembly syntax of the membar operands containing a # - * character, they cannot be used in macros. The cmask and mmask bits - * are hard coded in machine/cpufunc.h and used here through macros. - * Hopefully sun will choose not to change the bit numbers. - */ - -#define itype(sz) uint ## sz ## _t - -#define atomic_cas_32(p, e, s) casa(p, e, s, __ASI_ATOMIC) -#define atomic_cas_64(p, e, s) casxa(p, e, s, __ASI_ATOMIC) - -#define atomic_cas(p, e, s, sz) \ - atomic_cas_ ## sz(p, e, s) - -#define atomic_cas_acq(p, e, s, sz) ({ \ - itype(sz) v; \ - v = atomic_cas(p, e, s, sz); \ - membar(LoadLoad | LoadStore); \ - v; \ -}) - -#define atomic_cas_rel(p, e, s, sz) ({ \ - itype(sz) v; \ - membar(LoadStore | StoreStore); \ - v = atomic_cas(p, e, s, sz); \ - v; \ -}) - -#define atomic_op(p, op, v, sz) ({ \ - itype(sz) e, r, s; \ - for (e = *(volatile itype(sz) *)p;; e = r) { \ - s = e op v; \ - r = atomic_cas_ ## sz(p, e, s); \ - if (r == e) \ - break; \ - } \ - e; \ -}) - -#define atomic_op_acq(p, op, v, sz) ({ \ - itype(sz) t; \ - t = atomic_op(p, op, v, sz); \ - membar(LoadLoad | LoadStore); \ - t; \ -}) - -#define atomic_op_rel(p, op, v, sz) ({ \ - itype(sz) t; \ - membar(LoadStore | StoreStore); \ - t = atomic_op(p, op, v, sz); \ - t; \ -}) - -#define atomic_load(p, sz) \ - atomic_cas(p, 0, 0, sz) - -#define atomic_load_acq(p, sz) ({ \ - itype(sz) v; \ - v = atomic_load(p, sz); \ - membar(LoadLoad | LoadStore); \ - v; \ -}) - -#define atomic_load_clear(p, sz) ({ \ - itype(sz) e, r; \ - for (e = *(volatile itype(sz) *)p;; e = r) { \ - r = atomic_cas(p, e, 0, sz); \ - if (r == e) \ - break; \ - } \ - e; \ -}) - -#define atomic_store(p, v, sz) do { \ - itype(sz) e, r; \ - for (e = *(volatile itype(sz) *)p;; e = r) { \ - r = atomic_cas(p, e, v, sz); \ - if (r == e) \ - break; \ - } \ -} while (0) - -#define atomic_store_rel(p, v, sz) do { \ - membar(LoadStore | StoreStore); \ - atomic_store(p, v, sz); \ -} while (0) - -#define ATOMIC_GEN(name, ptype, vtype, atype, sz) \ - \ -static __inline vtype \ -atomic_add_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op(p, +, v, sz)); \ -} \ -static __inline vtype \ -atomic_add_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq(p, +, v, sz)); \ -} \ -static __inline vtype \ -atomic_add_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel(p, +, v, sz)); \ -} \ - \ -static __inline vtype \ -atomic_clear_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op(p, &, ~v, sz)); \ -} \ -static __inline vtype \ -atomic_clear_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq(p, &, ~v, sz)); \ -} \ -static __inline vtype \ -atomic_clear_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel(p, &, ~v, sz)); \ -} \ - \ -static __inline int \ -atomic_cmpset_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas(p, e, s, sz)) == e); \ -} \ -static __inline int \ -atomic_cmpset_acq_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas_acq(p, e, s, sz)) == e); \ -} \ -static __inline int \ -atomic_cmpset_rel_ ## name(volatile ptype p, vtype e, vtype s) \ -{ \ - return (((vtype)atomic_cas_rel(p, e, s, sz)) == e); \ -} \ - \ -static __inline vtype \ -atomic_load_ ## name(volatile ptype p) \ -{ \ - return ((vtype)atomic_cas(p, 0, 0, sz)); \ -} \ -static __inline vtype \ -atomic_load_acq_ ## name(volatile ptype p) \ -{ \ - return ((vtype)atomic_cas_acq(p, 0, 0, sz)); \ -} \ - \ -static __inline vtype \ -atomic_readandclear_ ## name(volatile ptype p) \ -{ \ - return ((vtype)atomic_load_clear(p, sz)); \ -} \ - \ -static __inline vtype \ -atomic_set_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op(p, |, v, sz)); \ -} \ -static __inline vtype \ -atomic_set_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq(p, |, v, sz)); \ -} \ -static __inline vtype \ -atomic_set_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel(p, |, v, sz)); \ -} \ - \ -static __inline vtype \ -atomic_subtract_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op(p, -, v, sz)); \ -} \ -static __inline vtype \ -atomic_subtract_acq_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_acq(p, -, v, sz)); \ -} \ -static __inline vtype \ -atomic_subtract_rel_ ## name(volatile ptype p, atype v) \ -{ \ - return ((vtype)atomic_op_rel(p, -, v, sz)); \ -} \ - \ -static __inline void \ -atomic_store_ ## name(volatile ptype p, vtype v) \ -{ \ - atomic_store(p, v, sz); \ -} \ -static __inline void \ -atomic_store_rel_ ## name(volatile ptype p, vtype v) \ -{ \ - atomic_store_rel(p, v, sz); \ -} - -ATOMIC_GEN(int, u_int *, u_int, u_int, 32); -ATOMIC_GEN(32, uint32_t *, uint32_t, uint32_t, 32); - -ATOMIC_GEN(long, u_long *, u_long, u_long, 64); -ATOMIC_GEN(64, uint64_t *, uint64_t, uint64_t, 64); - -ATOMIC_GEN(ptr, uintptr_t *, uintptr_t, uintptr_t, 64); - -#define atomic_fetchadd_int atomic_add_int -#define atomic_fetchadd_32 atomic_add_32 -#define atomic_fetchadd_long atomic_add_long - -#undef ATOMIC_GEN -#undef atomic_cas -#undef atomic_cas_acq -#undef atomic_cas_rel -#undef atomic_op -#undef atomic_op_acq -#undef atomic_op_rel -#undef atomic_load_acq -#undef atomic_store_rel -#undef atomic_load_clear - -#endif /* !_MACHINE_ATOMIC_H_ */ diff --git a/sys/sun4v/include/bus.h b/sys/sun4v/include/bus.h deleted file mode 100644 index d2abee4d9910..000000000000 --- a/sys/sun4v/include/bus.h +++ /dev/null @@ -1,844 +0,0 @@ -/*- - * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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. - */ -/* - * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved. - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp - * and - * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09 - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_BUS_H_ -#define _MACHINE_BUS_H_ - -#ifdef BUS_SPACE_DEBUG -#include -#endif - -#include -#include - -/* - * Nexus and SBus spaces are non-cached and big endian - * (except for RAM and PROM) - * - * PCI spaces are non-cached and little endian - */ -#define NEXUS_BUS_SPACE 0 -#define SBUS_BUS_SPACE 1 -#define PCI_CONFIG_BUS_SPACE 2 -#define PCI_IO_BUS_SPACE 3 -#define PCI_MEMORY_BUS_SPACE 4 -#define LAST_BUS_SPACE 5 - -extern const int bus_type_asi[]; -extern const int bus_stream_asi[]; - -#define __BUS_SPACE_HAS_STREAM_METHODS 1 - -#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF -#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF -#define BUS_SPACE_MAXSIZE 0xFFFFFFFFFFFFFFFF -#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF -#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF -#define BUS_SPACE_MAXADDR 0xFFFFFFFF - -#define BUS_SPACE_UNRESTRICTED (~0) - -struct bus_space_tag { - void *bst_cookie; - bus_space_tag_t bst_parent; - int bst_type; - - void (*bst_bus_barrier)(bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, int); -}; - -/* - * Bus space function prototypes. - */ -static void bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t, - bus_size_t, int); -static int bus_space_subregion(bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, bus_space_handle_t *); - -/* - * Map a region of device bus space into CPU virtual address space. - */ - -static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr, - bus_size_t size, int flags, bus_space_handle_t *bshp); - -static __inline int -bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr, - bus_size_t size __unused, int flags __unused, bus_space_handle_t *bshp) -{ - - *bshp = addr; - return (0); -} - -/* - * Unmap a region of device bus space. - */ -static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t size); - -static __inline void -bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused, - bus_size_t size __unused) -{ - -} - -/* This macro finds the first "upstream" implementation of method `f' */ -#define _BS_CALL(t,f) \ - while (t->f == NULL) \ - t = t->bst_parent; \ - return (*(t)->f) - -static __inline void -bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - bus_size_t s, int f) -{ - - _BS_CALL(t, bst_bus_barrier)(t, h, o, s, f); -} - -static __inline int -bus_space_subregion(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - bus_size_t s, bus_space_handle_t *hp) -{ - - *hp = h + o; - return (0); -} - -/* flags for bus space map functions */ -#define BUS_SPACE_MAP_CACHEABLE 0x0001 -#define BUS_SPACE_MAP_LINEAR 0x0002 -#define BUS_SPACE_MAP_READONLY 0x0004 -#define BUS_SPACE_MAP_PREFETCHABLE 0x0008 -/* placeholders for bus functions... */ -#define BUS_SPACE_MAP_BUS1 0x0100 -#define BUS_SPACE_MAP_BUS2 0x0200 -#define BUS_SPACE_MAP_BUS3 0x0400 -#define BUS_SPACE_MAP_BUS4 0x0800 - -/* flags for bus_space_barrier() */ -#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ -#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ - -#ifdef BUS_SPACE_DEBUG -#define KTR_BUS KTR_SPARE2 -#define __BUS_DEBUG_ACCESS(h, o, desc, sz) do { \ - CTR4(KTR_BUS, "bus space: %s %d: handle %#lx, offset %#lx", \ - (desc), (sz), (h), (o)); \ -} while (0) -#else -#define __BUS_DEBUG_ACCESS(h, o, desc, sz) -#endif - -static __inline uint8_t -bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 1); - return (lduba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint16_t -bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 2); - return (lduha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint32_t -bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 4); - return (lduwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline uint64_t -bus_space_read_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read", 8); - return (ldxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type])); -} - -static __inline void -bus_space_read_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_1(t, h, o); -} - -static __inline void -bus_space_read_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_2(t, h, o); -} - -static __inline void -bus_space_read_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_4(t, h, o); -} - -static __inline void -bus_space_read_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_8(t, h, o); -} - -static __inline void -bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 1); - stba_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 2); - stha_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 4); - stwa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write", 8); - stxa_nc((caddr_t)(h + o), bus_type_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_1(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_2(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_4(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_8(t, h, o, *a++); -} - -static __inline void -bus_space_set_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_1(t, h, o, v); -} - -static __inline void -bus_space_set_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_2(t, h, o, v); -} - -static __inline void -bus_space_set_multi_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_4(t, h, o, v); -} - -static __inline void -bus_space_set_multi_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_8(t, h, o, v); -} - -static __inline void -bus_space_read_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - *a = bus_space_read_1(t, h, o); -} - -static __inline void -bus_space_read_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - *a = bus_space_read_2(t, h, o); -} - -static __inline void -bus_space_read_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - *a = bus_space_read_4(t, h, o); -} - -static __inline void -bus_space_read_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - *a = bus_space_read_8(t, h, o); -} - -static __inline void -bus_space_write_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - bus_space_write_1(t, h, o, *a); -} - -static __inline void -bus_space_write_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - bus_space_write_2(t, h, o, *a); -} - -static __inline void -bus_space_write_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - bus_space_write_4(t, h, o, *a); -} - -static __inline void -bus_space_write_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - bus_space_write_8(t, h, o, *a); -} - -static __inline void -bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint8_t v, bus_size_t c) -{ - - for (; c; c--, o++) - bus_space_write_1(t, h, o, v); -} - -static __inline void -bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint16_t v, bus_size_t c) -{ - - for (; c; c--, o += 2) - bus_space_write_2(t, h, o, v); -} - -static __inline void -bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint32_t v, bus_size_t c) -{ - - for (; c; c--, o += 4) - bus_space_write_4(t, h, o, v); -} - -static __inline void -bus_space_set_region_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - const uint64_t v, bus_size_t c) -{ - - for (; c; c--, o += 8) - bus_space_write_8(t, h, o, v); -} - -static __inline void -bus_space_copy_region_1(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1++, o2++) - bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_2(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 2, o2 += 2) - bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_4(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 4, o2 += 4) - bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2)); -} - -static __inline void -bus_space_copy_region_8(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 8, o2 += 8) - bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2)); -} - -static __inline uint8_t -bus_space_read_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 1); - return (lduba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint16_t -bus_space_read_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 2); - return (lduha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint32_t -bus_space_read_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 4); - return (lduwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline uint64_t -bus_space_read_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) -{ - - __BUS_DEBUG_ACCESS(h, o, "read stream", 8); - return (ldxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type])); -} - -static __inline void -bus_space_read_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_1(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_2(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_4(t, h, o); -} - -static __inline void -bus_space_read_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t *a, size_t c) -{ - - while (c-- > 0) - *a++ = bus_space_read_stream_8(t, h, o); -} - -static __inline void -bus_space_write_stream_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint8_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 1); - stba_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint16_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 2); - stha_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint32_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 4); - stwa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_stream_8(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, - uint64_t v) -{ - - __BUS_DEBUG_ACCESS(h, o, "write stream", 8); - stxa_nc((caddr_t)(h + o), bus_stream_asi[t->bst_type], v); -} - -static __inline void -bus_space_write_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_1(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_2(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_4(t, h, o, *a++); -} - -static __inline void -bus_space_write_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t *a, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_8(t, h, o, *a++); -} - -static __inline void -bus_space_set_multi_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_1(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_2(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_4(t, h, o, v); -} - -static __inline void -bus_space_set_multi_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t v, size_t c) -{ - - while (c-- > 0) - bus_space_write_stream_8(t, h, o, v); -} - -static __inline void -bus_space_read_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - *a = bus_space_read_stream_1(t, h, o); -} - -static __inline void -bus_space_read_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - *a = bus_space_read_stream_2(t, h, o); -} - -static __inline void -bus_space_read_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - *a = bus_space_read_stream_4(t, h, o); -} - -static __inline void -bus_space_read_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - *a = bus_space_read_stream_8(t, h, o); -} - -static __inline void -bus_space_write_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o++) - bus_space_write_stream_1(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 2) - bus_space_write_stream_2(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 4) - bus_space_write_stream_4(t, h, o, *a); -} - -static __inline void -bus_space_write_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t *a, bus_size_t c) -{ - - for (; c; a++, c--, o += 8) - bus_space_write_stream_8(t, h, o, *a); -} - -static __inline void -bus_space_set_region_stream_1(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint8_t v, bus_size_t c) -{ - - for (; c; c--, o++) - bus_space_write_stream_1(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_2(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint16_t v, bus_size_t c) -{ - - for (; c; c--, o += 2) - bus_space_write_stream_2(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_4(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint32_t v, bus_size_t c) -{ - - for (; c; c--, o += 4) - bus_space_write_stream_4(t, h, o, v); -} - -static __inline void -bus_space_set_region_stream_8(bus_space_tag_t t, bus_space_handle_t h, - bus_size_t o, const uint64_t v, bus_size_t c) -{ - - for (; c; c--, o += 8) - bus_space_write_stream_8(t, h, o, v); -} - -static __inline void -bus_space_copy_region_stream_1(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1++, o2++) - bus_space_write_stream_1(t, h1, o1, bus_space_read_stream_1(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_2(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 2, o2 += 2) - bus_space_write_stream_2(t, h1, o1, bus_space_read_stream_2(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_4(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 4, o2 += 4) - bus_space_write_stream_4(t, h1, o1, bus_space_read_stream_4(t, h2, - o2)); -} - -static __inline void -bus_space_copy_region_stream_8(bus_space_tag_t t, bus_space_handle_t h1, - bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - - for (; c; c--, o1 += 8, o2 += 8) - bus_space_write_stream_8(t, h1, o1, bus_space_read_8(t, h2, o2)); -} - -#include - -#endif /* !_MACHINE_BUS_H_ */ diff --git a/sys/sun4v/include/bus_dma.h b/sys/sun4v/include/bus_dma.h deleted file mode 100644 index 9e069df9874e..000000000000 --- a/sys/sun4v/include/bus_dma.h +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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. - */ -/* - * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved. - * Copyright (c) 1996 Charles M. Hannum. All rights reserved. - * Copyright (c) 1996 Christopher G. Demetriou. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp - * and - * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09 - * - * $FreeBSD$ - */ - -#ifndef _SPARC64_BUS_DMA_H -#define _SPARC64_BUS_DMA_H - -#include - -/* DMA support */ - -/* - * Method table for a bus_dma_tag. - */ -struct bus_dma_methods { - int (*dm_dmamap_create)(bus_dma_tag_t, int, bus_dmamap_t *); - int (*dm_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t); - int (*dm_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, bus_dmamap_callback_t *, void *, int); - int (*dm_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t, - struct mbuf *, bus_dmamap_callback2_t *, void *, int); - int (*dm_dmamap_load_mbuf_sg)(bus_dma_tag_t, bus_dmamap_t, - struct mbuf *, bus_dma_segment_t *segs, int *nsegs, int); - int (*dm_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t, struct uio *, - bus_dmamap_callback2_t *, void *, int); - void (*dm_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); - void (*dm_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, - bus_dmasync_op_t); - int (*dm_dmamem_alloc)(bus_dma_tag_t, void **, int, bus_dmamap_t *); - void (*dm_dmamem_free)(bus_dma_tag_t, void *, bus_dmamap_t); -}; - -/* - * bus_dma_tag_t - * - * A machine-dependent opaque type describing the implementation of - * DMA for a given bus. - */ -struct bus_dma_tag { - void *dt_cookie; /* cookie used in the guts */ - bus_dma_tag_t dt_parent; - bus_size_t dt_alignment; - bus_size_t dt_boundary; - bus_addr_t dt_lowaddr; - bus_addr_t dt_highaddr; - bus_dma_filter_t *dt_filter; - void *dt_filterarg; - bus_size_t dt_maxsize; - int dt_nsegments; - bus_size_t dt_maxsegsz; - int dt_flags; - int dt_ref_count; - int dt_map_count; - bus_dma_lock_t *dt_lockfunc; - void * *dt_lockfuncarg; - bus_dma_segment_t *dt_segments; - - struct bus_dma_methods *dt_mt; -}; - -#define bus_dmamap_create(t, f, p) \ - ((t)->dt_mt->dm_dmamap_create((t), (f), (p))) -#define bus_dmamap_destroy(t, p) \ - ((t)->dt_mt->dm_dmamap_destroy((t), (p))) -#define bus_dmamap_load(t, m, p, s, cb, cba, f) \ - ((t)->dt_mt->dm_dmamap_load((t), (m), (p), (s), (cb), (cba), (f))) -#define bus_dmamap_load_mbuf(t, m, mb, cb, cba, f) \ - ((t)->dt_mt->dm_dmamap_load_mbuf((t), (m), (mb), (cb), (cba), (f))) -#define bus_dmamap_load_mbuf_sg(t, m, mb, segs, nsegs, f) \ - ((t)->dt_mt->dm_dmamap_load_mbuf_sg((t), (m), (mb), (segs), (nsegs), (f))) -#define bus_dmamap_load_uio(t, m, ui, cb, cba, f) \ - ((t)->dt_mt->dm_dmamap_load_uio((t), (m), (ui), (cb), (cba), (f))) -#define bus_dmamap_unload(t, p) \ - ((t)->dt_mt->dm_dmamap_unload((t), (p))) -#define bus_dmamap_sync(t, m, op) \ - ((t)->dt_mt->dm_dmamap_sync((t), (m), (op))) -#define bus_dmamem_alloc(t, v, f, m) \ - ((t)->dt_mt->dm_dmamem_alloc((t), (v), (f), (m))) -#define bus_dmamem_free(t, v, m) \ - ((t)->dt_mt->dm_dmamem_free((t), (v), (m))) - -#endif /* !_SPARC64_BUS_DMA_H_ */ diff --git a/sys/sun4v/include/bus_private.h b/sys/sun4v/include/bus_private.h deleted file mode 100644 index ca6536d1c968..000000000000 --- a/sys/sun4v/include/bus_private.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 1997, 1998 Justin T. Gibbs. - * Copyright (c) 2002 by Thomas Moestl . - * 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 ``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. - * - * from: FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.25 2002/01/05 - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_BUS_PRIVATE_H_ -#define _MACHINE_BUS_PRIVATE_H_ - -#include - -/* - * Helpers - */ -int sparc64_bus_mem_map(bus_space_tag_t, bus_space_handle_t, bus_size_t, - int, vm_offset_t, void **); -int sparc64_bus_mem_unmap(void *, bus_size_t); -bus_space_handle_t sparc64_fake_bustag(int, bus_addr_t, struct bus_space_tag *); - -struct bus_dmamap_res { - struct resource *dr_res; - bus_size_t dr_used; - bus_size_t dr_offset; - SLIST_ENTRY(bus_dmamap_res) dr_link; -}; - -/* - * Callers of the bus_dma interfaces must always protect their tags and maps - * appropriately against concurrent access. However, when a map is on a LRU - * queue, there is a second access path to it; for this case, the locking rules - * are given in the parenthesized comments below: - * q - locked by the mutex protecting the queue. - * p - private to the owner of the map, no access through the queue. - * * - comment refers to pointer target. - * Only the owner of the map is allowed to insert the map into a queue. Removal - * and repositioning (i.e. temporal removal and reinsertion) is allowed to all - * if the queue lock is held. - */ -struct bus_dmamap { - TAILQ_ENTRY(bus_dmamap) dm_maplruq; /* (q) */ - SLIST_HEAD(, bus_dmamap_res) dm_reslist; /* (q, *q) */ - int dm_onq; /* (q) */ - int dm_flags; /* (p) */ -}; - -/* Flag values. */ -#define DMF_LOADED 1 /* Map is loaded */ -#define DMF_COHERENT 2 /* Coherent mapping requested */ - -int sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp); -void sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map); - -/* - * XXX: This is a kluge. It would be better to handle dma tags in a hierarchical - * way, and have a BUS_GET_DMA_TAG(); however, since this is not currently the - * case, save a root tag in the relevant bus attach function and use that. - */ -extern bus_dma_tag_t sparc64_root_dma_tag; - -#endif /* !_MACHINE_BUS_PRIVATE_H_ */ diff --git a/sys/sun4v/include/ccr.h b/sys/sun4v/include/ccr.h deleted file mode 100644 index 2b7ac84ec9b6..000000000000 --- a/sys/sun4v/include/ccr.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CCR_H_ -#define _MACHINE_CCR_H_ - -#define ICC_SHIFT 0 -#define ICC_BITS 4 -#define ICC_MASK ((1UL << ICC_BITS) - 1) -#define ICC_C (1UL << 0) -#define ICC_V (1UL << 1) -#define ICC_Z (1UL << 2) -#define ICC_N (1UL << 3) - -#define XCC_SHIFT 4 -#define XCC_BITS 4 -#define XCC_MASK (((1UL << XCC_BITS) - 1) << XCC_SHIFT) -#define XCC_C (1UL << 4) -#define XCC_V (1UL << 5) -#define XCC_Z (1UL << 6) -#define XCC_N (1UL << 7) - -#endif /* !_MACHINE_CCR_H_ */ diff --git a/sys/sun4v/include/cddl/mdesc.h b/sys/sun4v/include/cddl/mdesc.h deleted file mode 100644 index 2e5148d3e22d..000000000000 --- a/sys/sun4v/include/cddl/mdesc.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MDESC_H_ -#define _MDESC_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Each logical domain is detailed via a (Virtual) Machine Description - * available to each guest Operating System courtesy of a - * Hypervisor service. - */ - - - -#ifdef _ASM -#define U8(_s) _s -#define U16(_s) _s -#define U32(_s) _s -#define U64(_s) _s -#else -#define U8(_s) ((uint8_t)(_s)) -#define U16(_s) ((uint16_t)(_s)) -#define U32(_s) ((uint32_t)(_s)) -#define U64(_s) ((uint64_t)(_s)) -#endif - - - - - - /* the version this library understands */ - -#define MD_HEADER_VERS_OFF 0x0 -#define MD_HEADER_NODE_OFF 0x4 -#define MD_HEADER_NAME_OFF 0x8 -#define MD_HEADER_DATA_OFF 0xc - -#define MD_HEADER_SIZE 0x10 - -#define MD_TRANSPORT_VERSION U32(0x10000) - -#define MD_ELEMENT_SIZE 0x10 - -#define MDE_ILLEGAL_IDX U64(-1) - -#define MDET_LIST_END U8(0x0) -#define MDET_NULL U8(' ') -#define MDET_NODE U8('N') -#define MDET_NODE_END U8('E') -#define MDET_PROP_ARC U8('a') -#define MDET_PROP_VAL U8('v') -#define MDET_PROP_STR U8('s') -#define MDET_PROP_DAT U8('d') - - -#ifndef _ASM /* { */ - -/* - * Opaque handles for use in external interfaces - */ - -typedef void *md_t; - -typedef uint64_t mde_cookie_t; -#define MDE_INVAL_ELEM_COOKIE ((mde_cookie_t)-1) - -typedef uint32_t mde_str_cookie_t; -#define MDE_INVAL_STR_COOKIE ((mde_str_cookie_t)-1) - -typedef uint64_t md_diff_cookie_t; -#define MD_INVAL_DIFF_COOKIE ((md_diff_cookie_t)-1) - -#define MDESC_INVAL_GEN (0) - -/* - * External structure for MD diff interface - */ -typedef struct { - uint8_t type; /* property type */ - char *namep; /* property name */ -} md_prop_match_t; - - -/* - * External Interface - */ - -extern md_t *md_init_intern(uint64_t *, - void *(*allocp)(size_t), - void (*freep)(void *, size_t)); - -extern int md_fini(md_t *); - -extern int md_node_count(md_t *); - -extern mde_str_cookie_t md_find_name(md_t *, char *namep); - -extern mde_cookie_t md_root_node(md_t *); - -extern uint64_t md_get_gen(md_t *); - -extern size_t md_get_bin_size(md_t *); - -extern int md_scan_dag(md_t *, - mde_cookie_t, - mde_str_cookie_t, - mde_str_cookie_t, - mde_cookie_t *); - -extern int md_get_prop_val(md_t *, - mde_cookie_t, - char *, - uint64_t *); - -extern int md_get_prop_str(md_t *, - mde_cookie_t, - char *, - char **); - -extern int md_get_prop_data(md_t *, - mde_cookie_t, - char *, - uint8_t **, - int *); - -extern md_diff_cookie_t md_diff_init(md_t *, - mde_cookie_t, - md_t *, - mde_cookie_t, - char *, - md_prop_match_t *); - -extern int md_diff_added(md_diff_cookie_t, - mde_cookie_t **); - -extern int md_diff_removed(md_diff_cookie_t, - mde_cookie_t **); - -extern int md_diff_matched(md_diff_cookie_t, - mde_cookie_t **, - mde_cookie_t **); - -extern int md_diff_fini(md_diff_cookie_t); - -/***************** NON-CDDL BEGIN *******************************/ - -#include -extern int md_get_prop_alloc(md_t *, mde_cookie_t, char *, - int, uint8_t **); -extern int md_vdev_find_val(device_t dev, char *namep, - uint64_t *valp); - -extern int md_vdev_find_node(device_t dev, mde_cookie_t *valp); - -MALLOC_DECLARE(M_MDPROP); -extern void mdesc_init(void); -extern int mdesc_update(void); - - -extern md_t * md_get(void); -extern void md_put(md_t *); - -/***************** NON-CDDL END *******************************/ - - - -#endif /* } _ASM */ - - - -/* - * ioctl info for mdesc device - */ - -#define MDESCIOC ('m' << 24 | 'd' << 16 | 'd' << 8) - -#define MDESCIOCGSZ (MDESCIOC | 1) /* Get quote buffer size */ -#define MDESCIOCSSZ (MDESCIOC | 2) /* Set new quote buffer size */ -#define MDESCIOCDISCARD (MDESCIOC | 3) /* Discard quotes and reset */ - -#ifdef __cplusplus -} -#endif - -#endif /* _MDESC_H_ */ diff --git a/sys/sun4v/include/cddl/mdesc_impl.h b/sys/sun4v/include/cddl/mdesc_impl.h deleted file mode 100644 index 46c58ee3289a..000000000000 --- a/sys/sun4v/include/cddl/mdesc_impl.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * $FreeBSD$ - */ - -/* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MDESC_IMPL_H_ -#define _MDESC_IMPL_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -#define LIBMD_MAGIC 0x4d61636844657363ULL /* MachDesc */ - -#ifndef _ASM - - /* - * Internal definitions - */ - - -/* - * Each MD has the following header to - * provide information about each section of the MD. - * - * There are 3 sections: - * The description list, the name table and the data block. - * - * All values are stored in network byte order. - * - * Elements in the first (description list) section are defined by their - * index location within the node block. An index is simply the byte offset - * within the block / element size (16bytes). All elements are referred to - * by their index, to avoid bugs related to alignment etc. - * - * The name_len field holds the storage length of an ASCII name, NOT the strlen. - * The header fields are written in network - * byte order. - */ - -struct md_header_s { - uint32_t transport_version; - uint32_t node_blk_sz; /* size in bytes of the node block */ - uint32_t name_blk_sz; /* size in bytes of the name block */ - uint32_t data_blk_sz; /* size in bytes of the data block */ -}; - -typedef struct md_header_s md_header_t; - - - -#if defined(_BIG_ENDIAN) && !defined(lint) -#define mdtoh8(x) ((uint8_t)(x)) -#define mdtoh16(x) ((uint16_t)(x)) -#define mdtoh32(x) ((uint32_t)(x)) -#define mdtoh64(x) ((uint64_t)(x)) -#define htomd8(x) (x) -#define htomd16(x) (x) -#define htomd32(x) (x) -#define htomd64(x) (x) -#else -#define mdtoh8(x) ((uint8_t)(x)) -extern uint16_t mdtoh16(uint16_t); -extern uint32_t mdtoh32(uint32_t); -extern uint64_t mdtoh64(uint64_t); -#define htomd8(x) ((uint8_t)(x)) -extern uint16_t htomd16(uint16_t); -extern uint32_t htomd32(uint32_t); -extern uint64_t htomd64(uint64_t); -#endif - - - -struct MD_ELEMENT { - uint8_t tag; - uint8_t name_len; - uint16_t _reserved; - uint32_t name_offset; /* mde_str_cookie_t */ - union { - struct { - uint32_t len; - uint32_t offset; - } prop_data; /* for PROP_DATA and PROP_STR */ - uint64_t prop_val; /* for PROP_VAL */ - uint64_t prop_idx; /* for PROP_ARC and NODE */ - } d; -}; - -typedef struct MD_ELEMENT md_element_t; - -struct MACHINE_DESCRIPTION { - caddr_t caddr; - - void *(*allocp)(size_t); - void (*freep)(void *, size_t); - - md_header_t *headerp; - md_element_t *mdep; - char *namep; - uint8_t *datap; - - int node_blk_size; - int name_blk_size; - int data_blk_size; - - int element_count; - int node_count; - - mde_cookie_t root_node; - - int size; - uint64_t gen; - - uint64_t md_magic; -}; - -typedef struct MACHINE_DESCRIPTION md_impl_t; - -#define MDE_TAG(_p) mdtoh8((_p)->tag) -#define MDE_NAME(_p) mdtoh32((_p)->name_offset) -#define MDE_NAME_LEN(_p) mdtoh32((_p)->name_len) -#define MDE_PROP_DATA_OFFSET(_p) mdtoh32((_p)->d.prop_data.offset) -#define MDE_PROP_DATA_LEN(_p) mdtoh32((_p)->d.prop_data.len) -#define MDE_PROP_VALUE(_p) mdtoh64((_p)->d.prop_val) -#define MDE_PROP_INDEX(_p) mdtoh64((_p)->d.prop_idx) - -extern mde_str_cookie_t md_ident_name_str(char *); - -extern mde_cookie_t md_find_node_prop(md_impl_t *, - mde_cookie_t, - mde_str_cookie_t, - int); -#endif /* _ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _MDESC_IMPL_H_ */ diff --git a/sys/sun4v/include/clock.h b/sys/sun4v/include/clock.h deleted file mode 100644 index d95cff630040..000000000000 --- a/sys/sun4v/include/clock.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CLOCK_H_ -#define _MACHINE_CLOCK_H_ - -extern u_long tick_freq; -extern u_long tick_MHz; - -#endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/sun4v/include/cmt.h b/sys/sun4v/include/cmt.h deleted file mode 100644 index 4fddc63d21fa..000000000000 --- a/sys/sun4v/include/cmt.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/cpu.h b/sys/sun4v/include/cpu.h deleted file mode 100644 index 8bca727a253b..000000000000 --- a/sys/sun4v/include/cpu.h +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 - * from: FreeBSD: src/sys/i386/include/cpu.h,v 1.62 2001/06/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_CPU_H_ -#define _MACHINE_CPU_H_ - -#include -#include -extern void cpu_yield(void); - -#define TRAPF_PC(tfp) ((tfp)->tf_tpc) -#define TRAPF_USERMODE(tfp) (((tfp)->tf_tstate & TSTATE_PRIV) == 0) - -#define cpu_getstack(td) ((td)->td_frame->tf_sp) -#define cpu_setstack(td, sp) ((td)->td_frame->tf_sp = (sp)) -#define cpu_spinwait() - -#ifdef _KERNEL - -extern char btext[]; -extern char etext[]; - -void cpu_halt(void); -void cpu_reset(void); -void fork_trampoline(void); -void swi_vm(void *v); - -static __inline u_int64_t -get_cyclecount(void) -{ - - return (rd(tick)); -} - -#define UNIMPLEMENTED panic("%s not implemented", __FUNCTION__) - -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) -#endif - -#endif /* !_MACHINE_CPU_H_ */ diff --git a/sys/sun4v/include/cpufunc.h b/sys/sun4v/include/cpufunc.h deleted file mode 100644 index b20b8111a8a5..000000000000 --- a/sys/sun4v/include/cpufunc.h +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_CPUFUNC_H_ -#define _MACHINE_CPUFUNC_H_ - -#include -#include - -struct thread; - -/* - * Membar operand macros for use in other macros when # is a special - * character. Keep these in sync with what the hardware expects. - */ -#define C_Lookaside (0) -#define C_MemIssue (1) -#define C_Sync (2) -#define M_LoadLoad (0) -#define M_StoreLoad (1) -#define M_LoadStore (2) -#define M_StoreStore (3) - -#define CMASK_SHIFT (4) -#define MMASK_SHIFT (0) - -#define CMASK_GEN(bit) ((1 << (bit)) << CMASK_SHIFT) -#define MMASK_GEN(bit) ((1 << (bit)) << MMASK_SHIFT) - -#define Lookaside CMASK_GEN(C_Lookaside) -#define MemIssue CMASK_GEN(C_MemIssue) -#define Sync CMASK_GEN(C_Sync) -#define LoadLoad MMASK_GEN(M_LoadLoad) -#define StoreLoad MMASK_GEN(M_StoreLoad) -#define LoadStore MMASK_GEN(M_LoadStore) -#define StoreStore MMASK_GEN(M_StoreStore) - -#define casa(rs1, rs2, rd, asi) ({ \ - u_int __rd = (uint32_t)(rd); \ - __asm __volatile("casa [%2] %3, %4, %0" \ - : "+r" (__rd), "=m" (*rs1) \ - : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1)); \ - __rd; \ -}) - -#define casxa(rs1, rs2, rd, asi) ({ \ - u_long __rd = (uint64_t)(rd); \ - __asm __volatile("casxa [%2] %3, %4, %0" \ - : "+r" (__rd), "=m" (*rs1) \ - : "r" (rs1), "n" (asi), "r" (rs2), "m" (*rs1)); \ - __rd; \ -}) - -#define flush(va) do { \ - __asm __volatile("flush %0" : : "r" (va)); \ -} while (0) - -#define flushw() do { \ - __asm __volatile("flushw" : :); \ -} while (0) - -#define mov(val, reg) do { \ - __asm __volatile("mov %0, %" __XSTRING(reg) : : "r" (val)); \ -} while (0) - -/* Generate ld*a/st*a functions for non-constant ASIs. */ -#define LDNC_GEN(tp, o) \ - static __inline tp \ - o ## _nc(caddr_t va, int asi) \ - { \ - tp r; \ - __asm __volatile("wr %2, 0, %%asi;" #o " [%1] %%asi, %0"\ - : "=r" (r) : "r" (va), "r" (asi)); \ - return (r); \ - } - -LDNC_GEN(u_char, lduba); -LDNC_GEN(u_short, lduha); -LDNC_GEN(u_int, lduwa); -LDNC_GEN(u_long, ldxa); - -#define LD_GENERIC(va, asi, op, type) ({ \ - type __r; \ - __asm __volatile(#op " [%1] %2, %0" \ - : "=r" (__r) : "r" (va), "n" (asi)); \ - __r; \ -}) - -#define lduba(va, asi) LD_GENERIC(va, asi, lduba, u_char) -#define lduha(va, asi) LD_GENERIC(va, asi, lduha, u_short) -#define lduwa(va, asi) LD_GENERIC(va, asi, lduwa, u_int) -#define ldxa(va, asi) LD_GENERIC(va, asi, ldxa, u_long) - -#if 0 -#define STNC_GEN(tp, o) \ - static __inline void \ - o ## _nc(caddr_t va, int asi, tp val) \ - { \ - __asm __volatile(#o " %0, [%g0 + %1] %2"\ - : : "r" (val), "r" (va), "r" (asi)); \ - } -#else -#define STNC_GEN(tp, o) \ - static __inline void \ - o ## _nc(caddr_t va, int asi, tp val) \ - { \ - __asm __volatile("wr %2, 0, %%asi;" #o " %0, [%1] %%asi"\ - : : "r" (val), "r" (va), "r" (asi)); \ - } -#endif - -STNC_GEN(u_char, stba); -STNC_GEN(u_short, stha); -STNC_GEN(u_int, stwa); -STNC_GEN(u_long, stxa); - -#define ST_GENERIC(va, asi, val, op) \ - __asm __volatile(#op " %0, [%1] %2" \ - : : "r" (val), "r" (va), "n" (asi)); \ - -#define stba(va, asi, val) ST_GENERIC(va, asi, val, stba) -#define stha(va, asi, val) ST_GENERIC(va, asi, val, stha) -#define stwa(va, asi, val) ST_GENERIC(va, asi, val, stwa) -#define stxa(va, asi, val) ST_GENERIC(va, asi, val, stxa) - -/* - * Attempt to read from addr, val. If a Data Access Error trap happens, - * they return -1 and the contents of val is undefined. A return of 0 - * means no trap happened, and the contents of val is valid. - */ -int fasword8(u_long asi, void *addr, uint8_t *val); -int fasword16(u_long asi, void *addr, uint16_t *val); -int fasword32(u_long asi, void *addr, uint32_t *val); - -#define membar(mask) do { \ - __asm __volatile("membar %0" : : "n" (mask) : "memory"); \ -} while (0) - -#define rd(name) ({ \ - uint64_t __sr; \ - __asm __volatile("rd %%" #name ", %0" : "=r" (__sr) :); \ - __sr; \ -}) - -#define wr(name, val, xorval) do { \ - __asm __volatile("wr %0, %1, %%" #name \ - : : "r" (val), "rI" (xorval)); \ -} while (0) - -#define rdpr(name) ({ \ - uint64_t __pr; \ - __asm __volatile("rdpr %%" #name", %0" : "=r" (__pr) :); \ - __pr; \ -}) - -#define wrpr(name, val, xorval) do { \ - __asm __volatile("wrpr %0, %1, %%" #name \ - : : "r" (val), "rI" (xorval)); \ -} while (0) - -/* - * Trick GAS/GCC into compiling access to TICK/(S)TICK_COMPARE independently - * of the selected instruction set. - */ -#define rdtickcmpr() rd(asr23) -#define rdstick() rd(asr24) -#define rdstickcmpr() rd(asr25) -#define wrtickcmpr(val, xorval) wr(asr23, (val), (xorval)) -#define wrstick(val, xorval) wr(asr24, (val), (xorval)) -#define wrstickcmpr(val, xorval) wr(asr25, (val), (xorval)) - -static __inline void -breakpoint(void) -{ - - __asm __volatile("ta %%xcc, 1" : :); -} - -static __inline register_t -intr_disable_all(void) -{ - register_t s; - - s = rdpr(pstate); - wrpr(pstate, s & ~PSTATE_IE, 0); - return (s); -} -#define intr_restore_all(s) wrpr(pstate, (s), 0) - -static __inline register_t -intr_disable(void) -{ - register_t s; - - s = rdpr(pil); - wrpr(pil, 14, 0); - return (s); -} -#define intr_restore(s) wrpr(pil, (s), 0) - -/* - * In some places, it is required that the store is directly followed by a - * membar #Sync. Don't trust the compiler to not insert instructions in - * between. We also need to disable interrupts completely. - */ -#define stxa_sync(va, asi, val) do { \ - register_t s; \ - s = intr_disable_all(); \ - __asm __volatile("stxa %0, [%1] %2; membar #Sync" \ - : : "r" (val), "r" (va), "n" (asi)); \ - intr_restore_all(s); \ -} while (0) - -void ascopy(u_long asi, vm_offset_t src, vm_offset_t dst, size_t len); -void ascopyfrom(u_long sasi, vm_offset_t src, caddr_t dst, size_t len); -void ascopyto(caddr_t src, u_long dasi, vm_offset_t dst, size_t len); -void aszero(u_long asi, vm_offset_t dst, size_t len); - -#include - -#define USE_CPU_NANOSECONDS -#define nanoseconds() rd(tick) - -#undef LDNC_GEN -#undef STNC_GEN - -#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/sys/sun4v/include/db_machdep.h b/sys/sun4v/include/db_machdep.h deleted file mode 100644 index 439df3699df5..000000000000 --- a/sys/sun4v/include/db_machdep.h +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * Mach Operating System - * Copyright (c) 1991,1990 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - * - * from: FreeBSD: src/sys/i386/include/db_machdep.h,v 1.16 1999/10/04 - * $FreeBSD$ - */ - -#ifndef _MACHINE_DB_MACHDEP_H_ -#define _MACHINE_DB_MACHDEP_H_ - -#include -#include - -#define BYTE_MSF (1) - -typedef vm_offset_t db_addr_t; -typedef long db_expr_t; - -#define PC_REGS() ((db_addr_t)kdb_thrctx->pcb_pc) - -#define BKPT_INST (0x91d03001) -#define BKPT_SIZE (4) -#define BKPT_SET(inst) (BKPT_INST) - -#define BKPT_SKIP do { \ - kdb_frame->tf_tpc = kdb_frame->tf_tnpc + 4; \ - kdb_frame->tf_tnpc += 8; \ -} while (0) - -#define db_clear_single_step kdb_cpu_clear_singlestep -#define db_set_single_step kdb_cpu_set_singlestep - -#define IS_BREAKPOINT_TRAP(type, code) (type == T_BREAKPOINT) -#define IS_WATCHPOINT_TRAP(type, code) (0) - -#define inst_trap_return(ins) (0) -#define inst_return(ins) (0) -#define inst_call(ins) (0) -#define inst_load(ins) (0) -#define inst_store(ins) (0) - -#define DB_SMALL_VALUE_MAX (0x7fffffff) -#define DB_SMALL_VALUE_MIN (-0x40001) - -#define DB_ELFSIZE 64 - -#endif /* !_MACHINE_DB_MACHDEP_H_ */ diff --git a/sys/sun4v/include/elf.h b/sys/sun4v/include/elf.h deleted file mode 100644 index f61b8604ae40..000000000000 --- a/sys/sun4v/include/elf.h +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * Copyright (c) 1996-1997 John D. Polstra. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_ELF_H_ -#define _MACHINE_ELF_H_ 1 - -/* - * ELF definitions for the sparc64 architecture. - */ - -#include /* Definitions common to all 32 bit architectures. */ -#include /* Definitions common to all 64 bit architectures. */ - -#ifndef __ELF_WORD_SIZE -#define __ELF_WORD_SIZE 64 /* Used by */ -#endif -#include - -#define ELF_ARCH EM_SPARCV9 - -#define ELF_MACHINE_OK(x) ((x) == ELF_ARCH) - -/* - * Auxiliary vector entries for passing information to the interpreter. - */ - -typedef struct { /* Auxiliary vector entry on initial stack */ - int a_type; /* Entry type. */ - union { - int a_val; /* Integer value. */ - } a_un; -} Elf32_Auxinfo; - -typedef struct { /* Auxiliary vector entry on initial stack */ - long a_type; /* Entry type. */ - union { - long a_val; /* Integer value. */ - void *a_ptr; /* Address. */ - void (*a_fcn)(void); /* Function pointer (not used). */ - } a_un; -} Elf64_Auxinfo; - -__ElfType(Auxinfo); - -/* Values for a_type. */ -#define AT_NULL 0 /* Terminates the vector. */ -#define AT_IGNORE 1 /* Ignored entry. */ -#define AT_EXECFD 2 /* File descriptor of program to load. */ -#define AT_PHDR 3 /* Program header of program already loaded. */ -#define AT_PHENT 4 /* Size of each program header entry. */ -#define AT_PHNUM 5 /* Number of program header entries. */ -#define AT_PAGESZ 6 /* Page size in bytes. */ -#define AT_BASE 7 /* Interpreter's base address. */ -#define AT_FLAGS 8 /* Flags (unused). */ -#define AT_ENTRY 9 /* Where interpreter should transfer control. */ -#define AT_NOTELF 10 /* Program is not ELF ?? */ -#define AT_UID 11 /* Real uid. */ -#define AT_EUID 12 /* Effective uid. */ -#define AT_GID 13 /* Real gid. */ -#define AT_EGID 14 /* Effective gid. */ -#define AT_EXECPATH 15 /* Path to the executable. */ -#define AT_CANARY 16 /* Canary for SSP */ -#define AT_CANARYLEN 17 /* Length of the canary. */ -#define AT_OSRELDATE 18 /* OSRELDATE. */ -#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 24 /* Count of defined aux entry types. */ - -/* Define "machine" characteristics */ -#if __ELF_WORD_SIZE == 32 -#define ELF_TARG_CLASS ELFCLASS32 -#else -#define ELF_TARG_CLASS ELFCLASS64 -#endif -#define ELF_TARG_DATA ELFDATA2MSB -#define ELF_TARG_MACH ELF_ARCH -#define ELF_TARG_VER 1 - -#define ET_DYN_LOAD_ADDR 0x100000 - -#endif /* !_MACHINE_ELF_H_ */ diff --git a/sys/sun4v/include/endian.h b/sys/sun4v/include/endian.h deleted file mode 100644 index c28b04fed2cd..000000000000 --- a/sys/sun4v/include/endian.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/exec.h b/sys/sun4v/include/exec.h deleted file mode 100644 index c0f93b68bf90..000000000000 --- a/sys/sun4v/include/exec.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ - -#define __LDPGSZ 8192 - -#endif /* !_MACHINE_EXEC_H_ */ diff --git a/sys/sun4v/include/fireplane.h b/sys/sun4v/include/fireplane.h deleted file mode 100644 index 7c81412db3e5..000000000000 --- a/sys/sun4v/include/fireplane.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/float.h b/sys/sun4v/include/float.h deleted file mode 100644 index de1d7feacede..000000000000 --- a/sys/sun4v/include/float.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 1992, 1993, 2001 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)float.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: float.h,v 1.3 2001/09/21 20:48:02 eeh Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_FLOAT_H_ -#define _MACHINE_FLOAT_H_ - -#include - -__BEGIN_DECLS -extern int __flt_rounds(void); -__END_DECLS - -#define FLT_RADIX 2 /* b */ -#define FLT_ROUNDS __flt_rounds() -#if __ISO_C_VISIBLE >= 1999 -#define FLT_EVAL_METHOD 0 /* no promotion */ -#define DECIMAL_DIG 36 /* max precision in decimal digits */ -#endif - -#define FLT_MANT_DIG 24 /* p */ -#define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */ -#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ -#define FLT_MIN_EXP (-125) /* emin */ -#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ -#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ -#define FLT_MAX_EXP 128 /* emax */ -#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ -#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ - -#define DBL_MANT_DIG 53 -#define DBL_EPSILON 2.2204460492503131E-16 -#define DBL_DIG 15 -#define DBL_MIN_EXP (-1021) -#define DBL_MIN 2.2250738585072014E-308 -#define DBL_MIN_10_EXP (-307) -#define DBL_MAX_EXP 1024 -#define DBL_MAX 1.7976931348623157E+308 -#define DBL_MAX_10_EXP 308 - -#define LDBL_MANT_DIG 113 -#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L -#define LDBL_DIG 33 -#define LDBL_MIN_EXP (-16381) -#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L -#define LDBL_MIN_10_EXP (-4931) -#define LDBL_MAX_EXP (+16384) -#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L -#define LDBL_MAX_10_EXP (+4932) - -#endif /* _MACHINE_FLOAT_H_ */ diff --git a/sys/sun4v/include/floatingpoint.h b/sys/sun4v/include/floatingpoint.h deleted file mode 100644 index d47756a00c6c..000000000000 --- a/sys/sun4v/include/floatingpoint.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2002 David O'Brien . - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _FLOATINGPOINT_H_ -#define _FLOATINGPOINT_H_ - -#include - -#endif /* !_FLOATINGPOINT_H_ */ diff --git a/sys/sun4v/include/fp.h b/sys/sun4v/include/fp.h deleted file mode 100644 index bf0d79a8aba6..000000000000 --- a/sys/sun4v/include/fp.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FP_H_ -#define _MACHINE_FP_H_ - -#ifdef _KERNEL - -/* - * Note: The pointer passed to savefpctx must be aligned on a 64 byte - * boundary. - */ -void savefpctx(uint32_t *fp); - -#endif /* _KERNEL */ -#endif /* !_MACHINE_FP_H_ */ diff --git a/sys/sun4v/include/frame.h b/sys/sun4v/include/frame.h deleted file mode 100644 index 55438ac6a20e..000000000000 --- a/sys/sun4v/include/frame.h +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FRAME_H_ -#define _MACHINE_FRAME_H_ - -#define RW_SHIFT 7 -#define SPOFF 2047 -#define BIAS SPOFF /* XXX - open/netbsd compat */ - -#ifndef LOCORE - -/* - * NOTE: keep this structure in sync with struct reg and struct mcontext. - */ -struct trapframe { - uint64_t tf_global[8]; - uint64_t tf_out[8]; - uint64_t tf_fprs; - uint64_t tf_fsr; - uint64_t tf_gsr; - uint64_t tf_pad0[1]; - uint64_t tf_pil; - uint64_t tf_pad1[3]; - uint64_t tf_tnpc; - uint64_t tf_tpc; - uint64_t tf_tstate; - uint64_t tf_pad2[2]; - uint64_t tf_wstate; - uint64_t tf_asi; - uint64_t tf_pad3[1]; -} __aligned(64); -/* extra padding can go away once we re-shuffle user-land mcontext - */ - -#define tf_sp tf_out[6] - -#define TF_DONE(tf) do { \ - tf->tf_tpc = tf->tf_tnpc; \ - tf->tf_tnpc += 4; \ -} while (0) - -struct frame { - u_long fr_local[8]; - u_long fr_in[8]; - u_long fr_pad[8]; -}; -#define fr_arg fr_in -#define fr_fp fr_in[6] -#define fr_pc fr_in[7] - -#define v9next_frame(fp) ((struct frame *)(fp->fr_fp + BIAS)) - -/* - * Frame used for pcb_rw. - */ -struct rwindow { - u_long rw_local[8]; - u_long rw_in[8]; -}; - -struct thread; - -int rwindow_save(struct thread *td); -int rwindow_load(struct thread *td, struct trapframe *tf, int n); - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_FRAME_H_ */ diff --git a/sys/sun4v/include/fsr.h b/sys/sun4v/include/fsr.h deleted file mode 100644 index db0039a236e0..000000000000 --- a/sys/sun4v/include/fsr.h +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_FSR_H_ -#define _MACHINE_FSR_H_ - -#define FPRS_DL (1 << 0) -#define FPRS_DU (1 << 1) -#define FPRS_FEF (1 << 2) - -#ifndef LOCORE - -#define FSR_EXC_BITS 5 -#define FSR_EXC_MASK ((1UL << FSR_EXC_BITS) - 1) -#define FSR_CEXC_SHIFT 0 -#define FSR_CEXC_MASK (FSR_EXC_MASK << FSR_CEXC_SHIFT) -#define FSR_CEXC(b) ((unsigned long)(b) << FSR_CEXC_SHIFT) -#define FSR_GET_CEXC(x) (((x) & FSR_CEXC_MASK) >> FSR_CEXC_SHIFT) -#define FSR_AEXC_SHIFT 5 -#define FSR_AEXC_MASK (FSR_EXC_MASK << FSR_AEXC_SHIFT) -#define FSR_AEXC(b) ((unsigned long)(b) << FSR_AEXC_SHIFT) -#define FSR_GET_AEXC(x) (((x) & FSR_AEXC_MASK) >> FSR_AEXC_SHIFT) -#define FSR_QNE (1UL << 13) -#define FSR_NS (1UL << 22) -#define FSR_TEM_SHIFT 23 -#define FSR_TEM_MASK (FSR_EXC_MASK << FSR_TEM_SHIFT) -#define FSR_TEM(b) ((unsigned long)(b) << FSR_TEM_SHIFT) -#define FSR_GET_TEM(x) (((x) & FSR_TEM_MASK) >> FSR_TEM_SHIFT) -#define FSR_FCC0_SHIFT 10 -#define FSR_FCC0_BITS 2 -#define FSR_FCC0_MASK (((1UL << FSR_FCC0_BITS) - 1) << FSR_FCC0_SHIFT) -#define FSR_FCC0(x) ((unsigned long)(x) << FSR_FCC0_SHIFT) -#define FSR_GET_FCC0(x) (((x) & FSR_FCC0_MASK) >> FSR_FCC0_SHIFT) -#define FSR_FTT_SHIFT 14 -#define FSR_FTT_BITS 3 -#define FSR_FTT_MASK (((1UL << FSR_FTT_BITS) - 1) << FSR_FTT_SHIFT) -#define FSR_FTT(x) ((unsigned long)(x) << FSR_FTT_SHIFT) -#define FSR_GET_FTT(x) (((x) & FSR_FTT_MASK) >> FSR_FTT_SHIFT) -#define FSR_VER_SHIFT 17 -#define FSR_GET_VER(x) (((x) >> FSR_VER_SHIFT) & 7) -#define FSR_RD_SHIFT 30 -#define FSR_RD_BITS 2 -#define FSR_RD_MASK (((1UL << FSR_RD_BITS) - 1) << FSR_RD_SHIFT) -#define FSR_RD(x) ((unsigned long)(x) << FSR_RD_SHIFT) -#define FSR_GET_RD(x) (((x) & FSR_RD_MASK) >> FSR_RD_SHIFT) -#define FSR_FCC1_SHIFT 32 -#define FSR_FCC1_BITS 2 -#define FSR_FCC1_MASK (((1UL << FSR_FCC1_BITS) - 1) << FSR_FCC1_SHIFT) -#define FSR_FCC1(x) ((unsigned long)(x) << FSR_FCC1_SHIFT) -#define FSR_GET_FCC1(x) (((x) & FSR_FCC1_MASK) >> FSR_FCC1_SHIFT) -#define FSR_FCC2_SHIFT 34 -#define FSR_FCC2_BITS 2 -#define FSR_FCC2_MASK (((1UL << FSR_FCC2_BITS) - 1) << FSR_FCC2_SHIFT) -#define FSR_FCC2(x) ((unsigned long)(x) << FSR_FCC2_SHIFT) -#define FSR_GET_FCC2(x) (((x) & FSR_FCC2_MASK) >> FSR_FCC2_SHIFT) -#define FSR_FCC3_SHIFT 36 -#define FSR_FCC3_BITS 2 -#define FSR_FCC3_MASK (((1UL << FSR_FCC3_BITS) - 1) << FSR_FCC3_SHIFT) -#define FSR_FCC3(x) ((unsigned long)(x) << FSR_FCC3_SHIFT) -#define FSR_GET_FCC3(x) (((x) & FSR_FCC3_MASK) >> FSR_FCC3_SHIFT) - -/* CEXC/AEXC/TEM exception values */ -#define FSR_NX (1 << 0) -#define FSR_DZ (1 << 1) -#define FSR_UF (1 << 2) -#define FSR_OF (1 << 3) -#define FSR_NV (1 << 4) -/* FTT values. */ -#define FSR_FTT_NONE 0 -#define FSR_FTT_IEEE 1 -#define FSR_FTT_UNFIN 2 -#define FSR_FTT_UNIMP 3 -#define FSR_FTT_SEQERR 4 -#define FSR_FTT_HWERR 5 -#define FSR_FTT_INVREG 6 -/* RD values */ -#define FSR_RD_N 0 /* nearest */ -#define FSR_RD_Z 1 /* zero */ -#define FSR_RD_PINF 2 /* +infinity */ -#define FSR_RD_NINF 3 /* -infinity */ -/* condition codes */ -#define FSR_CC_EQ 0 /* a = b */ -#define FSR_CC_LT 1 /* a < b */ -#define FSR_CC_GT 2 /* a > b */ -#define FSR_CC_UO 3 /* unordered */ - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_FSR_H_ */ diff --git a/sys/sun4v/include/gdb_machdep.h b/sys/sun4v/include/gdb_machdep.h deleted file mode 100644 index efbc5e78524b..000000000000 --- a/sys/sun4v/include/gdb_machdep.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2004 Marcel Moolenaar - * 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 ``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 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_GDB_MACHDEP_H_ -#define _MACHINE_GDB_MACHDEP_H_ - -#define GDB_BUFSZ 600 -#define GDB_NREGS 86 -#define GDB_REG_PC 80 - -static __inline size_t -gdb_cpu_regsz(int regnum) -{ - return ((regnum >= 32 && regnum < 64) ? sizeof(float) : sizeof(long)); -} - -static __inline int -gdb_cpu_query(void) -{ - return (0); -} - -static __inline int -gdb_cpu_signal(int vector, int _) -{ - return (vector); -} - -void *gdb_cpu_getreg(int, size_t *); -void gdb_cpu_setreg(int, void *); - -#endif /* !_MACHINE_GDB_MACHDEP_H_ */ diff --git a/sys/sun4v/include/hv_api.h b/sys/sun4v/include/hv_api.h deleted file mode 100644 index 8407631b44e4..000000000000 --- a/sys/sun4v/include/hv_api.h +++ /dev/null @@ -1,243 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_HV_API_H -#define _MACHINE_HV_API_H - -typedef uint64_t devhandle_t; -typedef uint64_t pci_device_t; -typedef uint32_t pci_config_offset_t; -typedef uint8_t pci_config_size_t; - -typedef uint64_t tsbid_t; -typedef uint32_t pages_t; -typedef enum io_attributes { - PCI_MAP_ATTR_READ = (uint32_t)0x01, - PCI_MAP_ATTR_WRITE = (uint32_t)0x02, -} io_attributes_t; -typedef enum io_sync_direction { - IO_SYNC_DEVICE = (uint32_t)0x01, - IO_SYNC_CPU = (uint32_t)0x02, -} io_sync_direction_t; -typedef uint64_t io_page_list_t; -typedef uint64_t r_addr_t; -typedef uint64_t io_addr_t; - -/* - * Section 10 Domain Services - */ - -extern void hv_mach_sir(void); -extern void hv_mach_exit(uint64_t exit_code); -extern uint64_t hv_mach_desc(uint64_t buffer_ra, uint64_t *buffer_sizep); -extern uint64_t hv_mach_watchdog(uint64_t timeout, uint64_t *time_remaining); - -/* - * Section 11 CPU Services - */ - -extern uint64_t hv_cpu_yield(void); -extern uint64_t hv_cpu_state(uint64_t cpuid, uint64_t *state); -extern uint64_t hv_cpu_mondo_send(int ncpu, vm_paddr_t cpulist_ra); -extern uint64_t hv_cpu_qconf(int queue, vm_paddr_t ra, int nentries); - -/* - * Section 12 MMU Services - */ -/* - * TSB description structure for MMU_TSB_CTX0 and MMU_TSB_CTXNON0. - */ -typedef struct hv_tsb_info { - uint16_t hti_idxpgsz; /* page size used for index shift in TSB */ - uint16_t hti_assoc; /* associativity of TSB */ - uint32_t hti_ntte; /* size of TSB in TTEs */ - uint32_t hti_ctx_index; /* context index */ - uint32_t hti_pgszs; /* page size bitmask */ - uint64_t hti_ra; /* real address of TSB base */ - uint64_t hti_rsvd; /* reserved */ -} hv_tsb_info_t; - - -extern uint64_t hv_mmu_tsb_ctx0(uint64_t, uint64_t); -extern uint64_t hv_mmu_tsb_ctxnon0(uint64_t, uint64_t); -extern uint64_t hv_mmu_map_perm_addr(vm_offset_t va, uint64_t, tte_t tte, uint64_t flags); - -/* - * Section 13 Cache and Memory Services - */ - -extern uint64_t hv_mem_scrub(vm_paddr_t ra, uint64_t length, uint64_t *scrubbed); - -/* - * Section 14 Device Interrupt Services - */ -extern uint64_t hv_intr_devino_to_sysino(devhandle_t dev_hdl, uint32_t devino, uint64_t *sysino); -extern uint64_t hv_intr_getenabled(uint64_t sysino, int *enabled); -extern uint64_t hv_intr_setenabled(uint64_t sysino, int enabled); -extern uint64_t hv_intr_getstate(uint64_t sysino, int *state); -extern uint64_t hv_intr_setstate(uint64_t sysino, int state); -extern uint64_t hv_intr_gettarget(uint64_t sysino, int *cpuid); -extern uint64_t hv_intr_settarget(uint64_t sysino, int cpuid); - -extern uint64_t hv_vintr_getcookie(devhandle_t dh, uint64_t devino, uint64_t *cookie); -extern uint64_t hv_vintr_setcookie(devhandle_t dh, uint64_t devino, uint64_t cookie); -extern uint64_t hv_vintr_getenabled(devhandle_t dh, uint64_t devino, int *enabled); -extern uint64_t hv_vintr_setenabled(devhandle_t dh, uint64_t devino, int enabled); -extern uint64_t hv_vintr_getstate(devhandle_t dh, uint64_t devino, int *state); -extern uint64_t hv_vintr_setstate(devhandle_t dh, uint64_t devino, int state); -extern uint64_t hv_vintr_gettarget(devhandle_t dh, uint64_t devino, int *cpuid); -extern uint64_t hv_vintr_settarget(devhandle_t dh, uint64_t devino, int cpuid); - - -/* - * Section 15 Time of Day Services - */ - -extern uint64_t hv_tod_get(uint64_t *seconds); -extern uint64_t hv_tod_set(uint64_t); - -/* - * Section 16 Console Services - */ - -extern int64_t hv_cons_putchar(uint8_t); -extern int64_t hv_cons_getchar(uint8_t *); -extern int64_t hv_cons_write(uint64_t buf_raddr, uint64_t size, uint64_t *nwritten); -extern int64_t hv_cons_read(uint64_t buf_raddr, uint64_t size, uint64_t *nread); - -extern void hv_cnputs(char *); - -/* - * Section 17 Core Dump Services - */ - -extern uint64_t hv_dump_buf_update(uint64_t, uint64_t, uint64_t *); - - -/* - * Section 18 Trap Trace Services - */ - -typedef struct trap_trace_entry { - uint8_t tte_type; /* Hypervisor or guest entry. */ - uint8_t tte_hpstat; /* Hyper-privileged state. */ - uint8_t tte_tl; /* Trap level. */ - uint8_t tte_gl; /* Global register level. */ - uint16_t tte_tt; /* Trap type.*/ - uint16_t tte_tag; /* Extended trap identifier. */ - uint64_t tte_tstate; /* Trap state. */ - uint64_t tte_tick; /* Tick. */ - uint64_t tte_tpc; /* Trap PC. */ - uint64_t tte_f1; /* Entry specific. */ - uint64_t tte_f2; /* Entry specific. */ - uint64_t tte_f3; /* Entry specific. */ - uint64_t tte_f4; /* Entry specific. */ -} trap_trace_entry_t; - -extern uint64_t hv_ttrace_buf_info(uint64_t *, uint64_t *); -extern uint64_t hv_ttrace_buf_conf(uint64_t, uint64_t, uint64_t *); -extern uint64_t hv_ttrace_enable(uint64_t, uint64_t *); -extern uint64_t hv_ttrace_freeze(uint64_t, uint64_t *); -extern uint64_t hv_ttrace_addentry(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); - -/* - * Section 19 Logical Domain Channel Services - * - */ -typedef struct ldc_state_info { - uint64_t lsi_head_offset; - uint64_t lsi_tail_offset; - uint64_t lsi_channel_state; -} ldc_state_info_t; - -#define LDC_CHANNEL_DOWN 0 -#define LDC_CHANNEL_UP 1 - -extern uint64_t hv_ldc_tx_qconf(uint64_t ldc_id, uint64_t base_raddr, uint64_t nentries); -extern uint64_t hv_ldc_tx_qinfo(uint64_t ldc_id, uint64_t *base_raddr, uint64_t *nentries); -extern uint64_t hv_ldc_tx_get_state(uint64_t ldc_id, ldc_state_info_t *info); -extern uint64_t hv_ldc_tx_set_qtail(uint64_t ldc_id, uint64_t tail_offset); -extern uint64_t hv_ldc_rx_get_state(uint64_t ldc_id, ldc_state_info_t *info); -extern uint64_t hv_ldc_rx_qconf(uint64_t ldc_id, uint64_t base_raddr, uint64_t nentries); -extern uint64_t hv_ldc_rx_qinfo(uint64_t ldc_id, uint64_t *base_raddr, uint64_t *nentries); -extern uint64_t hv_ldc_rx_set_qhead(uint64_t ldc_id, uint64_t head_offset); - - -/* - * Section 20 PCI I/O Services - * - */ - -typedef union pci_cfg_data { - uint8_t b; - uint16_t w; - uint32_t dw; - uint64_t qw; -} pci_cfg_data_t; - -extern uint64_t hv_pci_iommu_map(devhandle_t dh, uint64_t tsbid, uint64_t nttes, io_attributes_t io_attributes, - io_page_list_t io_page_list, pages_t *nttes_mapped); -extern uint64_t hv_pci_iommu_demap(devhandle_t dh, uint64_t tsbid, uint64_t nttes, pages_t *nttes_demapped); -extern uint64_t hv_pci_iommu_getmap(devhandle_t dh, uint64_t tsbid, io_attributes_t *io_attributes, - vm_paddr_t *ra); -extern uint64_t hv_pci_iommu_getbypass(devhandle_t dh, vm_paddr_t ra, uint64_t io_attributes, uint64_t *io_addr); -extern uint64_t hv_pci_config_get(devhandle_t dh, uint64_t pci_device, uint64_t pci_config_offset, uint64_t size, - pci_cfg_data_t *data); -extern uint64_t hv_pci_config_put(devhandle_t dh, uint64_t pci_device, uint64_t pci_config_offset, uint64_t size, - pci_cfg_data_t data); -extern uint64_t hv_pci_peek(devhandle_t dh, vm_paddr_t ra, uint64_t size, uint32_t *error_flag, uint64_t *data); -extern uint64_t hv_pci_poke(devhandle_t dh, vm_paddr_t ra, uint64_t size, uint64_t data, uint64_t pci_device, - uint32_t *error_flag); -extern uint64_t hv_pci_dma_sync(devhandle_t dh, vm_paddr_t ra, uint64_t size, uint64_t io_sync_direction, - uint64_t *nsynced); - - -/* - * Section 21 MSI Services - * - */ - -/* - * Section 22 UltraSPARC T1 Performance Counters - * - */ - -/* - * Section 23 UltraSPARC T1 MMU Statistics Counters - * - */ - -/* - * Simulator Services - */ -extern void hv_magic_trap_on(void); -extern void hv_magic_trap_off(void); -extern int hv_sim_read(uint64_t offset, vm_paddr_t buffer_ra, uint64_t size); -extern int hv_sim_write(uint64_t offset, vm_paddr_t buffer_ra, uint64_t size); - -#endif /* _MACHINE_HV_API_H */ diff --git a/sys/sun4v/include/hv_pcivar.h b/sys/sun4v/include/hv_pcivar.h deleted file mode 100644 index 37414693b28d..000000000000 --- a/sys/sun4v/include/hv_pcivar.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright 2006 John-Mark Gurney. - * 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. - * - * - * $FreeBSD$ - */ - -#ifndef _HV_PCIVAR_H_ -#define _HV_PCIVAR_H_ - -struct hvpci_softc { - devhandle_t hs_devhandle; - phandle_t hs_node; - uint8_t hs_busnum; - - struct ofw_bus_iinfo hs_pci_iinfo; - - struct bus_dma_tag hs_dmatag; - - struct rman hs_pci_mem_rman; - bus_space_tag_t hs_pci_memt; - bus_space_handle_t hs_pci_memh; - - struct rman hs_pci_io_rman; - bus_space_tag_t hs_pci_iot; - bus_space_handle_t hs_pci_ioh; -}; - -#endif /* _HV_PCIVAR_H_ */ diff --git a/sys/sun4v/include/hviommu.h b/sys/sun4v/include/hviommu.h deleted file mode 100644 index a8f8474cb2ea..000000000000 --- a/sys/sun4v/include/hviommu.h +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright 2006 John-Mark Gurney. - * 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. - * - * - * $FreeBSD$ - */ - -#ifndef _HVIOMMU_H_ -#define _HVIOMMU_H_ - -struct hviommu; - -extern struct bus_dma_methods hviommu_dma_methods; - -struct hviommu *hviommu_init(devhandle_t dh, u_long dvmabase, u_long dvmasize); - -#endif /* _HVIOMMU_H_ */ diff --git a/sys/sun4v/include/hypervisorvar.h b/sys/sun4v/include/hypervisorvar.h deleted file mode 100644 index 4f5ea7fd1d0b..000000000000 --- a/sys/sun4v/include/hypervisorvar.h +++ /dev/null @@ -1,350 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - - -#ifndef _MACHINE_HYPERVISORVAR_H_ -#define _MACHINE_HYPERVISORVAR_H_ -/* - * Trap types - */ -#define FAST_TRAP 0x80 /* Function # in %o5 */ -#define CPU_TICK_NPT 0x81 -#define CPU_STICK_NPT 0x82 -#define MMU_MAP_ADDR 0x83 -#define MMU_UNMAP_ADDR 0x84 -#define TTRACE_ADDENTRY 0x85 - -#define CORE_TRAP 0xff - -/* - * Status returns in %o0. - */ -#define H_EOK 0 /* Successful return */ -#define H_ENOCPU 1 /* Invalid CPU id */ -#define H_ENORADDR 2 /* Invalid real address */ -#define H_ENOINTR 3 /* Invalid interrupt id */ -#define H_EBADPGSZ 4 /* Invalid pagesize encoding */ -#define H_EBADTSB 5 /* Invalid TSB description */ -#define H_EINVAL 6 /* Invalid argument */ -#define H_EBADTRAP 7 /* Invalid function number */ -#define H_EBADALIGN 8 /* Invalid address alignment */ -#define H_EWOULDBLOCK 9 /* Cannot complete operation */ - /* without blocking */ -#define H_ENOACCESS 10 /* No access to resource */ -#define H_EIO 11 /* I/O error */ -#define H_ECPUERROR 12 /* CPU is in error state */ -#define H_ENOTSUPPORTED 13 /* Function not supported */ -#define H_ENOMAP 14 /* Mapping is not valid, */ - /* no translation exists */ -#define H_ETOOMANY 15 /* Too many items specified / limit reached */ -#define H_ECHANNEL 16 /* Invalid LDC channel */ - -#define H_BREAK -1 /* Console Break */ -#define H_HUP -2 /* Console Break */ - -/* - * Mondo CPU ID argument processing. - */ -#define HV_SEND_MONDO_ENTRYDONE 0xffff - -/* - * Function numbers for CORE_TRAP. - */ -#define API_SET_VERSION 0x00 -#define API_PUTCHAR 0x01 -#define API_EXIT 0x02 -#define API_GET_VERSION 0x03 - -/* - * Function numbers for FAST_TRAP. - */ -#define MACH_EXIT 0x00 -#define MACH_DESC 0x01 -#define MACH_SIR 0x02 -#define MACH_SET_SOFT_STATE 0x03 -#define MACH_GET_SOFT_STATE 0x04 -#define MACH_WATCHDOG 0x05 - -#define CPU_START 0x10 -#define CPU_STOP 0x11 -#define CPU_YIELD 0x12 -#define CPU_QCONF 0x14 -#define CPU_QINFO 0x15 -#define CPU_MYID 0x16 -#define CPU_STATE 0x17 -#define CPU_SET_RTBA 0x18 -#define CPU_GET_RTBA 0x19 - - -#define MMU_TSB_CTX0 0x20 -#define MMU_TSB_CTXNON0 0x21 -#define MMU_DEMAP_PAGE 0x22 -#define MMU_DEMAP_CTX 0x23 -#define MMU_DEMAP_ALL 0x24 -#define MMU_MAP_PERM_ADDR 0x25 -#define MMU_FAULT_AREA_CONF 0x26 -#define MMU_ENABLE 0x27 -#define MMU_UNMAP_PERM_ADDR 0x28 -#define MMU_TSB_CTX0_INFO 0x29 -#define MMU_TSB_CTXNON0_INFO 0x2a -#define MMU_FAULT_AREA_INFO 0x2b - -/* - * Bits for MMU functions flags argument: - * arg3 of MMU_MAP_ADDR - * arg3 of MMU_DEMAP_CTX - * arg2 of MMU_DEMAP_ALL - */ -#define MAP_DTLB 0x1 -#define MAP_ITLB 0x2 - - - - -#define MEM_SCRUB 0x31 -#define MEM_SYNC 0x32 -#define CPU_MONDO_SEND 0x42 -#define TOD_GET 0x50 -#define TOD_SET 0x51 -#define CONS_GETCHAR 0x60 -#define CONS_PUTCHAR 0x61 -#define CONS_READ 0x62 -#define CONS_WRITE 0x63 - -#define SVC_SEND 0x80 -#define SVC_RECV 0x81 -#define SVC_GETSTATUS 0x82 -#define SVC_SETSTATUS 0x83 -#define SVC_CLRSTATUS 0x84 - -#define TTRACE_BUF_CONF 0x90 -#define TTRACE_BUF_INFO 0x91 -#define TTRACE_ENABLE 0x92 -#define TTRACE_FREEZE 0x93 - -#define DUMP_BUF_UPDATE 0x94 -#define DUMP_BUF_INFO 0x95 - -#define INTR_DEVINO2SYSINO 0xa0 -#define INTR_GETENABLED 0xa1 -#define INTR_SETENABLED 0xa2 -#define INTR_GETSTATE 0xa3 -#define INTR_SETSTATE 0xa4 -#define INTR_GETTARGET 0xa5 -#define INTR_SETTARGET 0xa6 - -#define VINTR_GETCOOKIE 0xa7 -#define VINTR_SETCOOKIE 0xa8 -#define VINTR_GETENABLED 0xa9 -#define VINTR_SETENABLED 0xaa -#define VINTR_GETSTATE 0xab -#define VINTR_SETSTATE 0xac -#define VINTR_GETTARGET 0xad -#define VINTR_SETTARGET 0xae - - -#define PCI_IOMMU_MAP 0xb0 -#define PCI_IOMMU_DEMAP 0xb1 -#define PCI_IOMMU_GETMAP 0xb2 -#define PCI_IOMMU_GETBYPASS 0xb3 - -#define PCI_CONFIG_GET 0xb4 -#define PCI_CONFIG_PUT 0xb5 - -#define PCI_PEEK 0xb6 -#define PCI_POKE 0xb7 - -#define PCI_DMA_SYNC 0xb8 - -#define PCI_MSIQ_CONF 0xc0 -#define PCI_MSIQ_INFO 0xc1 -#define PCI_MSIQ_GETVALID 0xc2 -#define PCI_MSIQ_SETVALID 0xc3 -#define PCI_MSIQ_GETSTATE 0xc4 -#define PCI_MSIQ_SETSTATE 0xc5 -#define PCI_MSIQ_GETHEAD 0xc6 -#define PCI_MSIQ_SETHEAD 0xc7 -#define PCI_MSIQ_GETTAIL 0xc8 - -#define PCI_MSI_GETVALID 0xc9 -#define PCI_MSI_SETVALID 0xca -#define PCI_MSI_GETMSIQ 0xcb -#define PCI_MSI_SETMSIQ 0xcc -#define PCI_MSI_GETSTATE 0xcd -#define PCI_MSI_SETSTATE 0xce - -#define PCI_MSG_GETMSIQ 0xd0 -#define PCI_MSG_SETMSIQ 0xd1 -#define PCI_MSG_GETVALID 0xd2 -#define PCI_MSG_SETVALID 0xd3 - -#define LDC_TX_QCONF 0xe0 -#define LDC_TX_QINFO 0xe1 -#define LDC_TX_GET_STATE 0xe2 -#define LDC_TX_SET_QTAIL 0xe3 -#define LDC_RX_QCONF 0xe4 -#define LDC_RX_QINFO 0xe5 -#define LDC_RX_GET_STATE 0xe6 -#define LDC_RX_SET_QHEAD 0xe7 - -#define LDC_SET_MAPTABLE 0xea -#define LDC_GET_MAPTABLE 0xeb -#define LDC_COPY 0xec -#define LDC_MAPIN 0xed -#define LDC_UNMAP 0xee -#define LDC_REVOKE 0xef - - -#define SIM_READ 0xf0 -#define SIM_WRITE 0xf1 - - -#define NIAGARA_GET_PERFREG 0x100 -#define NIAGARA_SET_PERFREG 0x101 - -#define NIAGARA_MMUSTAT_CONF 0x102 -#define NIAGARA_MMUSTAT_INFO 0x103 - -/* - * Interrupt state manipulation definitions. - */ - -#define HV_INTR_IDLE_STATE 0 -#define HV_INTR_RECEIVED_STATE 1 -#define HV_INTR_DELIVERED_STATE 2 - -#define HV_INTR_DISABLED 0 -#define HV_INTR_ENABLED 1 - -#ifndef LOCORE - - -#ifdef SET_MMU_STATS -#ifndef TTE4V_NPGSZ -#define TTE4V_NPGSZ 8 -#endif /* TTE4V_NPGSZ */ -/* - * MMU statistics structure for MMU_STAT_AREA - */ -struct mmu_stat_one { - uint64_t hit_ctx0[TTE4V_NPGSZ]; - uint64_t hit_ctxn0[TTE4V_NPGSZ]; - uint64_t tsb_miss; - uint64_t tlb_miss; /* miss, no TSB set */ - uint64_t map_ctx0[TTE4V_NPGSZ]; - uint64_t map_ctxn0[TTE4V_NPGSZ]; -}; - -struct mmu_stat { - struct mmu_stat_one immu_stat; - struct mmu_stat_one dmmu_stat; - uint64_t set_ctx0; - uint64_t set_ctxn0; -}; -#endif /* SET_MMU_STATS */ - -#endif /* _ASM */ - -/* - * CPU States - */ -#define CPU_STATE_INVALID 0x0 -#define CPU_STATE_IDLE 0x1 /* cpu not started */ -#define CPU_STATE_GUEST 0x2 /* cpu running guest code */ -#define CPU_STATE_ERROR 0x3 /* cpu is in the error state */ -#define CPU_STATE_LAST_PUBLIC CPU_STATE_ERROR /* last valid state */ - -/* - * MMU fault status area - */ - -#define MMFSA_TYPE_ 0x00 /* fault type */ -#define MMFSA_ADDR_ 0x08 /* fault address */ -#define MMFSA_CTX_ 0x10 /* fault context */ - -#define MMFSA_I_ 0x00 /* start of fields for I */ -#define MMFSA_I_TYPE (MMFSA_I_ + MMFSA_TYPE_) /* instruction fault type */ -#define MMFSA_I_ADDR (MMFSA_I_ + MMFSA_ADDR_) /* instruction fault address */ -#define MMFSA_I_CTX (MMFSA_I_ + MMFSA_CTX_) /* instruction fault context */ - -#define MMFSA_D_ 0x40 /* start of fields for D */ -#define MMFSA_D_TYPE (MMFSA_D_ + MMFSA_TYPE_) /* data fault type */ -#define MMFSA_D_ADDR (MMFSA_D_ + MMFSA_ADDR_) /* data fault address */ -#define MMFSA_D_CTX (MMFSA_D_ + MMFSA_CTX_) /* data fault context */ - -#define MMFSA_F_FMISS 1 /* fast miss */ -#define MMFSA_F_FPROT 2 /* fast protection */ -#define MMFSA_F_MISS 3 /* mmu miss */ -#define MMFSA_F_INVRA 4 /* invalid RA */ -#define MMFSA_F_PRIV 5 /* privilege violation */ -#define MMFSA_F_PROT 6 /* protection violation */ -#define MMFSA_F_NFO 7 /* NFO access */ -#define MMFSA_F_SOPG 8 /* so page */ -#define MMFSA_F_INVVA 9 /* invalid VA */ -#define MMFSA_F_INVASI 10 /* invalid ASI */ -#define MMFSA_F_NCATM 11 /* non-cacheable atomic */ -#define MMFSA_F_PRVACT 12 /* privileged action */ -#define MMFSA_F_WPT 13 /* watchpoint hit */ -#define MMFSA_F_UNALIGN 14 /* unaligned access */ -#define MMFSA_F_INVPGSZ 15 /* invalid page size */ - -#define MMFSA_SIZE 0x80 /* in bytes, 64 byte aligned */ - -/* - * MMU fault status - MMFSA_IFS and MMFSA_DFS - */ -#define MMFS_FV 0x00000001 -#define MMFS_OW 0x00000002 -#define MMFS_W 0x00000004 -#define MMFS_PR 0x00000008 -#define MMFS_CT 0x00000030 -#define MMFS_E 0x00000040 -#define MMFS_FT 0x00003f80 -#define MMFS_ME 0x00004000 -#define MMFS_TM 0x00008000 -#define MMFS_ASI 0x00ff0000 -#define MMFS_NF 0x01000000 - -/* - * DMA sync parameter definitions - */ -#define HVIO_DMA_SYNC_DIR_TO_DEV 0x01 -#define HVIO_DMA_SYNC_DIR_FROM_DEV 0x02 - -#ifdef SIMULATOR -#define MAGIC_TRAP_ON ta 0x77 -#define MAGIC_TRAP_OFF ta 0x78 -#define MAGIC_EXIT ta 0x71 -#else -#define MAGIC_TRAP_ON nop -#define MAGIC_TRAP_OFF nop -#define MAGIC_EXIT nop -#endif - - -#endif /*_MACHINE_HYPERVISORVAR_H_ */ diff --git a/sys/sun4v/include/idprom.h b/sys/sun4v/include/idprom.h deleted file mode 100644 index df76a7f73122..000000000000 --- a/sys/sun4v/include/idprom.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1993 Adam Glass - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Adam Glass. - * 4. The name of the Author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: NetBSD: idprom.h,v 1.2 1998/09/05 23:57:26 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_IDPROM_H_ -#define _MACHINE_IDPROM_H_ - -/* - * ID prom format. The ``host id'' is set up by taking the machine - * ID as the top byte and the hostid field as the remaining three. - * The id_xxx0 field appears to contain some other number. The id_xxx1 - * contains a bunch of 00's and a5's on my machines, suggesting it is - * not actually used. The checksum seems to include them, however. - */ -struct idprom { - u_char id_format; /* format identifier (= 1) */ - u_char id_machine; /* machine type (see param.h) */ - u_char id_ether[6]; /* ethernet address */ - int id_date; /* date of manufacture */ - u_char id_hostid[3]; /* ``host id'' bytes */ - u_char id_checksum; /* xor of everything else */ - char id_undef[16]; /* undefined */ -}; - -#define ID_SUN4_100 0x22 -#define ID_SUN4_200 0x21 -#define ID_SUN4_300 0x23 -#define ID_SUN4_400 0x24 - -#define IDPROM_VERSION 1 - -#endif /* !_MACHINE_IDPROM_H_ */ diff --git a/sys/sun4v/include/ieee.h b/sys/sun4v/include/ieee.h deleted file mode 100644 index 82ba9a1ae62f..000000000000 --- a/sys/sun4v/include/ieee.h +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ieee.h 8.1 (Berkeley) 6/11/93 - * from: NetBSD: ieee.h,v 1.1.1.1 1998/06/20 04:58:51 eeh Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_IEEE_H_ -#define _MACHINE_IEEE_H_ - -/* - * ieee.h defines the machine-dependent layout of the machine's IEEE - * floating point. It does *not* define (yet?) any of the rounding - * mode bits, exceptions, and so forth. - */ - -/* - * Define the number of bits in each fraction and exponent. - * - * k k+1 - * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented - * - * (-exp_bias+1) - * as fractions that look like 0.fffff x 2 . This means that - * - * -126 - * the number 0.10000 x 2 , for instance, is the same as the normalized - * - * -127 -128 - * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero - * - * -129 - * in the fraction; to represent 2 , we need two, and so on. This - * - * (-exp_bias-fracbits+1) - * implies that the smallest denormalized number is 2 - * - * for whichever format we are talking about: for single precision, for - * - * -126 -149 - * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and - * - * -149 == -127 - 23 + 1. - */ -#define SNG_EXPBITS 8 -#define SNG_FRACBITS 23 - -#define DBL_EXPBITS 11 -#define DBL_FRACBITS 52 - -#ifdef notyet -#define E80_EXPBITS 15 -#define E80_FRACBITS 64 -#endif - -#define EXT_EXPBITS 15 -#define EXT_FRACBITS 112 - -struct ieee_single { - u_int sng_sign:1; - u_int sng_exp:8; - u_int sng_frac:23; -}; - -struct ieee_double { - u_int dbl_sign:1; - u_int dbl_exp:11; - u_int dbl_frach:20; - u_int dbl_fracl; -}; - -struct ieee_ext { - u_int ext_sign:1; - u_int ext_exp:15; - u_int ext_frach:16; - u_int ext_frachm; - u_int ext_fraclm; - u_int ext_fracl; -}; - -/* - * Floats whose exponent is in [1..INFNAN) (of whatever type) are - * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. - * Floats whose exponent is zero are either zero (iff all fraction - * bits are zero) or subnormal values. - * - * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its - * high fraction; if the bit is set, it is a `quiet NaN'. - */ -#define SNG_EXP_INFNAN 255 -#define DBL_EXP_INFNAN 2047 -#define EXT_EXP_INFNAN 32767 - -#if 0 -#define SNG_QUIETNAN (1 << 22) -#define DBL_QUIETNAN (1 << 19) -#define EXT_QUIETNAN (1 << 15) -#endif - -/* - * Exponent biases. - */ -#define SNG_EXP_BIAS 127 -#define DBL_EXP_BIAS 1023 -#define EXT_EXP_BIAS 16383 - -#endif diff --git a/sys/sun4v/include/ieeefp.h b/sys/sun4v/include/ieeefp.h deleted file mode 100644 index 11264949acee..000000000000 --- a/sys/sun4v/include/ieeefp.h +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Written by J.T. Conklin, Apr 6, 1995 - * Public domain. - * $FreeBSD$ - */ - -#ifndef _MACHINE_IEEEFP_H_ -#define _MACHINE_IEEEFP_H_ - -#include - -typedef int fp_except_t; -#define FP_X_IMP FSR_NX /* imprecise (loss of precision) */ -#define FP_X_DZ FSR_DZ /* divide-by-zero exception */ -#define FP_X_UFL FSR_UF /* underflow exception */ -#define FP_X_OFL FSR_OF /* overflow exception */ -#define FP_X_INV FSR_NV /* invalid operation exception */ - -typedef enum { - FP_RN = FSR_RD_N, /* round to nearest representable number */ - FP_RZ = FSR_RD_Z, /* round to zero (truncate) */ - FP_RP = FSR_RD_PINF, /* round toward positive infinity */ - FP_RM = FSR_RD_NINF /* round toward negative infinity */ -} fp_rnd_t; - -#endif /* _MACHINE_IEEEFP_H_ */ diff --git a/sys/sun4v/include/in_cksum.h b/sys/sun4v/include/in_cksum.h deleted file mode 100644 index f35a50351ef0..000000000000 --- a/sys/sun4v/include/in_cksum.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/instr.h b/sys/sun4v/include/instr.h deleted file mode 100644 index d6befbbc3ffe..000000000000 --- a/sys/sun4v/include/instr.h +++ /dev/null @@ -1,618 +0,0 @@ -/*- - * Copyright (c) 1994 David S. Miller, davem@nadzieja.rutgers.edu - * Copyright (c) 1995 Paul Kranenburg - * Copyright (c) 2001 Thomas Moestl - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by David Miller. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: db_disasm.c,v 1.9 2000/08/16 11:29:42 pk Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_INSTR_H_ -#define _MACHINE_INSTR_H_ - -/* - * Definitions for all instruction formats - */ -#define IF_OP_SHIFT 30 -#define IF_OP_BITS 2 -#define IF_IMM_SHIFT 0 /* Immediate/Displacement */ - -/* - * Definitions for format 2 - */ -#define IF_F2_RD_SHIFT 25 -#define IF_F2_RD_BITS 5 -#define IF_F2_A_SHIFT 29 -#define IF_F2_A_BITS 1 -#define IF_F2_COND_SHIFT 25 -#define IF_F2_COND_BITS 4 -#define IF_F2_RCOND_SHIFT 25 -#define IF_F2_RCOND_BITS 3 -#define IF_F2_OP2_SHIFT 22 -#define IF_F2_OP2_BITS 3 -#define IF_F2_CC1_SHIFT 21 -#define IF_F2_CC1_BITS 1 -#define IF_F2_CC0_SHIFT 20 -#define IF_F2_CC0_BITS 1 -#define IF_F2_CC_SHIFT 20 /* CC0 and CC1 combined. */ -#define IF_F2_CC_BITS 2 -#define IF_F2_D16HI_SHIFT 20 -#define IF_F2_D16HI_BITS 2 -#define IF_F2_P_SHIFT 19 -#define IF_F2_P_BITS 1 -#define IF_F2_RS1_SHIFT 14 -#define IF_F2_RS1_BITS 5 - -/* - * Definitions for format 3 - */ -#define IF_F3_OP3_SHIFT 19 -#define IF_F3_OP3_BITS 6 -#define IF_F3_RD_SHIFT IF_F2_RD_SHIFT -#define IF_F3_RD_BITS IF_F2_RD_BITS -#define IF_F3_FCN_SHIFT 25 -#define IF_F3_FCN_BITS 5 -#define IF_F3_CC1_SHIFT 26 -#define IF_F3_CC1_BITS 1 -#define IF_F3_CC0_SHIFT 25 -#define IF_F3_CC0_BITS 1 -#define IF_F3_CC_SHIFT 25 /* CC0 and CC1 combined. */ -#define IF_F3_CC_BITS 2 -#define IF_F3_RS1_SHIFT IF_F2_RS1_SHIFT -#define IF_F3_RS1_BITS IF_F2_RS1_BITS -#define IF_F3_I_SHIFT 13 -#define IF_F3_I_BITS 1 -#define IF_F3_X_SHIFT 12 -#define IF_F3_X_BITS 1 -#define IF_F3_RCOND_SHIFT 10 -#define IF_F3_RCOND_BITS 3 -#define IF_F3_IMM_ASI_SHIFT 5 -#define IF_F3_IMM_ASI_BITS 8 -#define IF_F3_OPF_SHIFT 5 -#define IF_F3_OPF_BITS 9 -#define IF_F3_CMASK_SHIFT 4 -#define IF_F3_CMASK_BITS 3 -#define IF_F3_RS2_SHIFT 0 -#define IF_F3_RS2_BITS 5 -#define IF_F3_SHCNT32_SHIFT 0 -#define IF_F3_SHCNT32_BITS 5 -#define IF_F3_SHCNT64_SHIFT 0 -#define IF_F3_SHCNT64_BITS 6 - -/* - * Definitions for format 4 - */ -#define IF_F4_OP3_SHIFT IF_F3_OP3_SHIFT -#define IF_F4_OP3_BITS IF_F3_OP3_BITS -#define IF_F4_RD_SHIFT IF_F2_RD_SHIFT -#define IF_F4_RD_BITS IF_F2_RD_BITS -#define IF_F4_RS1_SHIFT IF_F2_RS1_SHIFT -#define IF_F4_RS1_BITS IF_F2_RS1_BITS -#define IF_F4_TCOND_SHIFT IF_F2_COND_SHIFT /* cond for Tcc */ -#define IF_F4_TCOND_BITS IF_F2_COND_BITS -#define IF_F4_CC2_SHIFT 18 -#define IF_F4_CC2_BITS 1 -#define IF_F4_COND_SHIFT 14 -#define IF_F4_COND_BITS 4 -#define IF_F4_I_SHIFT IF_F3_I_SHIFT -#define IF_F4_I_BITS IF_F3_I_BITS -#define IF_F4_OPF_CC_SHIFT 11 -#define IF_F4_OPF_CC_BITS 3 -#define IF_F4_CC1_SHIFT 12 -#define IF_F4_CC1_BITS 1 -#define IF_F4_CC0_SHIFT 11 -#define IF_F4_CC0_BITS 1 -#define IF_F4_RCOND_SHIFT IF_F3_RCOND_SHIFT -#define IF_F4_RCOND_BITS IF_F3_RCOND_BITS -#define IF_F4_OPF_LOW_SHIFT 5 -#define IF_F4_RS2_SHIFT IF_F3_RS2_SHIFT -#define IF_F4_RS2_BITS IF_F3_RS2_BITS -#define IF_F4_SW_TRAP_SHIFT 0 -#define IF_F4_SW_TRAP_BITS 7 - -/* - * Macros to decode instructions - */ -/* Extract a field */ -#define IF_MASK(s, w) (((1 << (w)) - 1) << (s)) -#define IF_EXTRACT(x, s, w) (((x) & IF_MASK((s), (w))) >> (s)) -#define IF_DECODE(x, f) \ - IF_EXTRACT((x), IF_ ## f ## _SHIFT, IF_ ## f ## _BITS) - -/* Sign-extend a field of width W */ -#define IF_SEXT(x, w) \ - (((x) & (1L << ((w) - 1))) != 0 ? \ - (-1L - ((x) ^ ((1L << (w)) - 1))) : (x)) - -#if 0 -/* - * The following C variant is from db_disassemble.c, and surely faster, but it - * relies on behaviour that is undefined by the C standard (>> in conjunction - * with signed negative arguments). - */ -#define IF_SEXT(v, w) ((((long long)(v)) << (64 - w)) >> (64 - w)) -/* Assembler version of the above */ -#define IF_SEXT(v, w) \ - { u_long t; ( __asm __volatile("sllx %1, %2, %0; srax %0, %2, %0" : - "=r" (t) : "r" (v) : "i" (64 - w)); t)} -#endif - -/* All instruction formats */ -#define IF_OP(i) IF_DECODE(i, OP) - -/* Instruction format 2 */ -#define IF_F2_RD(i) IF_DECODE((i), F2_RD) -#define IF_F2_A(i) IF_DECODE((i), F2_A) -#define IF_F2_COND(i) IF_DECODE((i), F2_COND) -#define IF_F2_RCOND(i) IF_DECODE((i), F2_RCOND) -#define IF_F2_OP2(i) IF_DECODE((i), F2_OP2) -#define IF_F2_CC1(i) IF_DECODE((i), F2_CC1) -#define IF_F2_CC0(i) IF_DECODE((i), F2_CC0) -#define IF_F2_CC(i) IF_DECODE((i), F2_CC) -#define IF_F2_D16HI(i) IF_DECODE((i), F2_D16HI) -#define IF_F2_P(i) IF_DECODE((i), F2_P) -#define IF_F2_RS1(i) IF_DECODE((i), F2_RS1) - -/* Instruction format 3 */ -#define IF_F3_OP3(i) IF_DECODE((i), F3_OP3) -#define IF_F3_RD(i) IF_F2_RD((i)) -#define IF_F3_FCN(i) IF_DECODE((i), F3_FCN) -#define IF_F3_CC1(i) IF_DECODE((i), F3_CC1) -#define IF_F3_CC0(i) IF_DECODE((i), F3_CC0) -#define IF_F3_CC(i) IF_DECODE((i), F3_CC) -#define IF_F3_RS1(i) IF_F2_RS1((i)) -#define IF_F3_I(i) IF_DECODE((i), F3_I) -#define IF_F3_X(i) IF_DECODE((i), F3_X) -#define IF_F3_RCOND(i) IF_DECODE((i), F3_RCOND) -#define IF_F3_IMM_ASI(i) IF_DECODE((i), F3_IMM_ASI) -#define IF_F3_OPF(i) IF_DECODE((i), F3_OPF) -#define IF_F3_CMASK(i) IF_DECODE((i), F3_CMASK) -#define IF_F3_RS2(i) IF_DECODE((i), F3_RS2) -#define IF_F3_SHCNT32(i) IF_DECODE((i), F3_SHCNT32) -#define IF_F3_SHCNT64(i) IF_DECODE((i), F3_SHCNT64) - -/* Instruction format 4 */ -#define IF_F4_OP3(i) IF_F3_OP3((i)) -#define IF_F4_RD(i) IF_F3_RD((i)) -#define IF_F4_TCOND(i) IF_DECODE((i), F4_TCOND) -#define IF_F4_RS1(i) IF_F3_RS1((i)) -#define IF_F4_CC2(i) IF_DECODE((i), F4_CC2) -#define IF_F4_COND(i) IF_DECODE((i), F4_COND) -#define IF_F4_I(i) IF_F3_I((i)) -#define IF_F4_OPF_CC(i) IF_DECODE((i), F4_OPF_CC) -#define IF_F4_RCOND(i) IF_F3_RCOND((i)) -#define IF_F4_OPF_LOW(i, w) IF_EXTRACT((i), IF_F4_OPF_LOW_SHIFT, (w)) -#define IF_F4_RS2(i) IF_F3_RS2((i)) -#define IF_F4_SW_TRAP(i) IF_DECODE((i), F4_SW_TRAP) - -/* Extract an immediate from an instruction, with an without sign extension */ -#define IF_IMM(i, w) IF_EXTRACT((i), IF_IMM_SHIFT, (w)) -#define IF_SIMM(i, w) ({ u_long b = (w), x = IF_IMM((i), b); IF_SEXT((x), b); }) - -/* - * Macros to encode instructions - */ -#define IF_INSERT(x, s, w) (((x) & ((1 << (w)) - 1)) << (s)) -#define IF_ENCODE(x, f) \ - IF_INSERT((x), IF_ ## f ## _SHIFT, IF_ ## f ## _BITS) - -/* All instruction formats */ -#define EIF_OP(x) IF_ENCODE((x), OP) - -/* Instruction format 2 */ -#define EIF_F2_RD(x) IF_ENCODE((x), F2_RD) -#define EIF_F2_A(x) IF_ENCODE((x), F2_A) -#define EIF_F2_COND(x) IF_ENCODE((x), F2_COND) -#define EIF_F2_RCOND(x) IF_ENCODE((x), F2_RCOND) -#define EIF_F2_OP2(x) IF_ENCODE((x), F2_OP2) -#define EIF_F2_CC1(x) IF_ENCODE((x), F2_CC1) -#define EIF_F2_CC0(x) IF_ENCODE((x), F2_CC0) -#define EIF_F2_D16HI(x) IF_ENCODE((x), F2_D16HI) -#define EIF_F2_P(x) IF_ENCODE((x), F2_P) -#define EIF_F2_RS1(x) IF_ENCODE((x), F2_RS1) - -/* Instruction format 3 */ -#define EIF_F3_OP3(x) IF_ENCODE((x), F3_OP3) -#define EIF_F3_RD(x) EIF_F2_RD((x)) -#define EIF_F3_FCN(x) IF_ENCODE((x), F3_FCN) -#define EIF_F3_CC1(x) IF_ENCODE((x), F3_CC1) -#define EIF_F3_CC0(x) IF_ENCODE((x), F3_CC0) -#define EIF_F3_RS1(x) EIF_F2_RS1((x)) -#define EIF_F3_I(x) IF_ENCODE((x), F3_I) -#define EIF_F3_X(x) IF_ENCODE((x), F3_X) -#define EIF_F3_RCOND(x) IF_ENCODE((x), F3_RCOND) -#define EIF_F3_IMM_ASI(x) IF_ENCODE((x), F3_IMM_ASI) -#define EIF_F3_OPF(x) IF_ENCODE((x), F3_OPF) -#define EIF_F3_CMASK(x) IF_ENCODE((x), F3_CMASK) -#define EIF_F3_RS2(x) IF_ENCODE((x), F3_RS2) -#define EIF_F3_SHCNT32(x) IF_ENCODE((x), F3_SHCNT32) -#define EIF_F3_SHCNT64(x) IF_ENCODE((x), F3_SHCNT64) - -/* Instruction format 4 */ -#define EIF_F4_OP3(x) EIF_F3_OP3((x)) -#define EIF_F4_RD(x) EIF_F2_RD((x)) -#define EIF_F4_TCOND(x) IF_ENCODE((x), F4_TCOND) -#define EIF_F4_RS1(x) EIF_F2_RS1((x)) -#define EIF_F4_CC2(x) IF_ENCODE((x), F4_CC2) -#define EIF_F4_COND(x) IF_ENCODE((x), F4_COND) -#define EIF_F4_I(x) EIF_F3_I((x)) -#define EIF_F4_OPF_CC(x) IF_ENCODE((x), F4_OPF_CC) -#define EIF_F4_RCOND(x) EIF_F3_RCOND((x)) -#define EIF_F4_OPF_LOW(i, w) IF_INSERT((x), IF_F4_OPF_CC_SHIFT, (w)) -#define EIF_F4_RS2(x) EIF_F3_RS2((x)) -#define EIF_F4_SW_TRAP(x) IF_ENCODE((x), F4_SW_TRAP) - -/* Immediates */ -#define EIF_IMM(x, w) IF_INSERT((x), IF_IMM_SHIFT, (w)) -#define EIF_SIMM(x, w) IF_EIMM((x), (w)) - -/* - * OP field values (specifying the instruction format) - */ -#define IOP_FORM2 0x00 /* Format 2: sethi, branches */ -#define IOP_CALL 0x01 /* Format 1: call */ -#define IOP_MISC 0x02 /* Format 3 or 4: arith & misc */ -#define IOP_LDST 0x03 /* Format 4: loads and stores */ - -/* - * OP2/OP3 values (specifying the actual instruction) - */ -/* OP2 values for format 2 (OP = 0) */ -#define INS0_ILLTRAP 0x00 -#define INS0_BPcc 0x01 -#define INS0_Bicc 0x02 -#define INS0_BPr 0x03 -#define INS0_SETHI 0x04 /* with rd = 0 and imm22 = 0, nop */ -#define INS0_FBPfcc 0x05 -#define INS0_FBfcc 0x06 -/* undefined 0x07 */ - -/* OP3 values for Format 3 and 4 (OP = 2) */ -#define INS2_ADD 0x00 -#define INS2_AND 0x01 -#define INS2_OR 0x02 -#define INS2_XOR 0x03 -#define INS2_SUB 0x04 -#define INS2_ANDN 0x05 -#define INS2_ORN 0x06 -#define INS2_XNOR 0x07 -#define INS2_ADDC 0x08 -#define INS2_MULX 0x09 -#define INS2_UMUL 0x0a -#define INS2_SMUL 0x0b -#define INS2_SUBC 0x0c -#define INS2_UDIVX 0x0d -#define INS2_UDIV 0x0e -#define INS2_SDIV 0x0f -#define INS2_ADDcc 0x10 -#define INS2_ANDcc 0x11 -#define INS2_ORcc 0x12 -#define INS2_XORcc 0x13 -#define INS2_SUBcc 0x14 -#define INS2_ANDNcc 0x15 -#define INS2_ORNcc 0x16 -#define INS2_XNORcc 0x17 -#define INS2_ADDCcc 0x18 -/* undefined 0x19 */ -#define INS2_UMULcc 0x1a -#define INS2_SMULcc 0x1b -#define INS2_SUBCcc 0x1c -/* undefined 0x1d */ -#define INS2_UDIVcc 0x1e -#define INS2_SDIVcc 0x1f -#define INS2_TADDcc 0x20 -#define INS2_TSUBcc 0x21 -#define INS2_TADDccTV 0x22 -#define INS2_TSUBccTV 0x23 -#define INS2_MULScc 0x24 -#define INS2_SSL 0x25 /* SLLX when IF_X(i) == 1 */ -#define INS2_SRL 0x26 /* SRLX when IF_X(i) == 1 */ -#define INS2_SRA 0x27 /* SRAX when IF_X(i) == 1 */ -#define INS2_RD 0x28 /* and MEMBAR, STBAR */ -/* undefined 0x29 */ -#define INS2_RDPR 0x2a -#define INS2_FLUSHW 0x2b -#define INS2_MOVcc 0x2c -#define INS2_SDIVX 0x2d -#define INS2_POPC 0x2e /* undefined if IF_RS1(i) != 0 */ -#define INS2_MOVr 0x2f -#define INS2_WR 0x30 /* and SIR */ -#define INS2_SV_RSTR 0x31 /* saved, restored */ -#define INS2_WRPR 0x32 -/* undefined 0x33 */ -#define INS2_FPop1 0x34 /* further encoded in opf field */ -#define INS2_FPop2 0x35 /* further encoded in opf field */ -#define INS2_IMPLDEP1 0x36 -#define INS2_IMPLDEP2 0x37 -#define INS2_JMPL 0x38 -#define INS2_RETURN 0x39 -#define INS2_Tcc 0x3a -#define INS2_FLUSH 0x3b -#define INS2_SAVE 0x3c -#define INS2_RESTORE 0x3d -#define INS2_DONE_RETR 0x3e /* done, retry */ -/* undefined 0x3f */ - -/* OP3 values for format 3 (OP = 3) */ -#define INS3_LDUW 0x00 -#define INS3_LDUB 0x01 -#define INS3_LDUH 0x02 -#define INS3_LDD 0x03 -#define INS3_STW 0x04 -#define INS3_STB 0x05 -#define INS3_STH 0x06 -#define INS3_STD 0x07 -#define INS3_LDSW 0x08 -#define INS3_LDSB 0x09 -#define INS3_LDSH 0x0a -#define INS3_LDX 0x0b -/* undefined 0x0c */ -#define INS3_LDSTUB 0x0d -#define INS3_STX 0x0e -#define INS3_SWAP 0x0f -#define INS3_LDUWA 0x10 -#define INS3_LDUBA 0x11 -#define INS3_LDUHA 0x12 -#define INS3_LDDA 0x13 -#define INS3_STWA 0x14 -#define INS3_STBA 0x15 -#define INS3_STHA 0x16 -#define INS3_STDA 0x17 -#define INS3_LDSWA 0x18 -#define INS3_LDSBA 0x19 -#define INS3_LDSHA 0x1a -#define INS3_LDXA 0x1b -/* undefined 0x1c */ -#define INS3_LDSTUBA 0x1d -#define INS3_STXA 0x1e -#define INS3_SWAPA 0x1f -#define INS3_LDF 0x20 -#define INS3_LDFSR 0x21 /* and LDXFSR */ -#define INS3_LDQF 0x22 -#define INS3_LDDF 0x23 -#define INS3_STF 0x24 -#define INS3_STFSR 0x25 /* and STXFSR */ -#define INS3_STQF 0x26 -#define INS3_STDF 0x27 -/* undefined 0x28 - 0x2c */ -#define INS3_PREFETCH 0x2d -/* undefined 0x2e - 0x2f */ -#define INS3_LDFA 0x30 -/* undefined 0x31 */ -#define INS3_LDQFA 0x32 -#define INS3_LDDFA 0x33 -#define INS3_STFA 0x34 -/* undefined 0x35 */ -#define INS3_STQFA 0x36 -#define INS3_STDFA 0x37 -/* undefined 0x38 - 0x3b */ -#define INS3_CASA 0x39 -#define INS3_PREFETCHA 0x3a -#define INS3_CASXA 0x3b - -/* - * OPF values (floating point instructions, IMPLDEP) - */ -/* - * These values are or'ed to the FPop values to get the instructions. - * They describe the operand type(s). - */ -#define INSFP_i 0x000 /* 32-bit int */ -#define INSFP_s 0x001 /* 32-bit single */ -#define INSFP_d 0x002 /* 64-bit double */ -#define INSFP_q 0x003 /* 128-bit quad */ -/* FPop1. The comments give the types for which this instruction is defined. */ -#define INSFP1_FMOV 0x000 /* s, d, q */ -#define INSFP1_FNEG 0x004 /* s, d, q */ -#define INSFP1_FABS 0x008 /* s, d, q */ -#define INSFP1_FSQRT 0x028 /* s, d, q */ -#define INSFP1_FADD 0x040 /* s, d, q */ -#define INSFP1_FSUB 0x044 /* s, d, q */ -#define INSFP1_FMUL 0x048 /* s, d, q */ -#define INSFP1_FDIV 0x04c /* s, d, q */ -#define INSFP1_FsMULd 0x068 /* s */ -#define INSFP1_FdMULq 0x06c /* d */ -#define INSFP1_FTOx 0x080 /* s, d, q */ -#define INSFP1_FxTOs 0x084 /* special: i only */ -#define INSFP1_FxTOd 0x088 /* special: i only */ -#define INSFP1_FxTOq 0x08c /* special: i only */ -#define INSFP1_FTOs 0x0c4 /* i, d, q */ -#define INSFP1_FTOd 0x0c8 /* i, s, q */ -#define INSFP1_FTOq 0x0cc /* i, s, d */ -#define INSFP1_FTOi 0x0d0 /* i, s, d */ - -/* FPop2 */ -#define INSFP2_FMOV_CCMUL 0x40 -#define INSFP2_FMOV_CCOFFS 0x00 -/* Use the IFCC_* constants for cc. Operand types: s, d, q */ -#define INSFP2_FMOV_CC(cc) ((cc) * INSFP2_FMOV_CCMUL + INSFP2_FMOV_CCOFFS) -#define INSFP2_FMOV_RCMUL 0x20 -#define INSFP2_FMOV_RCOFFS 0x04 -/* Use the IRCOND_* constants for rc. Operand types: s, d, q */ -#define INSFP2_FMOV_RC(rc) ((rc) * INSFP2_FMOV_RCMUL + INSFP2_FMOV_RCOFFS) -#define INSFP2_FCMP 0x050 /* s, d, q */ -#define INSFP2_FCMPE 0x054 /* s, d, q */ - -/* Decode 5-bit register field into 6-bit number (for doubles and quads). */ -#define INSFPdq_RN(rn) (((rn) & ~1) | (((rn) & 1) << 5)) - -/* IMPLDEP1 for Sun UltraSparc */ -#define IIDP1_EDGE8 0x00 -#define IIDP1_EDGE8N 0x01 /* US-III */ -#define IIDP1_EDGE8L 0x02 -#define IIDP1_EDGE8LN 0x03 /* US-III */ -#define IIDP1_EDGE16 0x04 -#define IIDP1_EDGE16N 0x05 /* US-III */ -#define IIDP1_EDGE16L 0x06 -#define IIDP1_EDGE16LN 0x07 /* US-III */ -#define IIDP1_EDGE32 0x08 -#define IIDP1_EDGE32N 0x09 /* US-III */ -#define IIDP1_EDGE32L 0x0a -#define IIDP1_EDGE32LN 0x0b /* US-III */ -#define IIDP1_ARRAY8 0x10 -#define IIDP1_ARRAY16 0x12 -#define IIDP1_ARRAY32 0x14 -#define IIDP1_ALIGNADDRESS 0x18 -#define IIDP1_BMASK 0x19 /* US-III */ -#define IIDP1_ALIGNADDRESS_L 0x1a -#define IIDP1_FCMPLE16 0x20 -#define IIDP1_FCMPNE16 0x22 -#define IIDP1_FCMPLE32 0x24 -#define IIDP1_FCMPNE32 0x26 -#define IIDP1_FCMPGT16 0x28 -#define IIDP1_FCMPEQ16 0x2a -#define IIDP1_FCMPGT32 0x2c -#define IIDP1_FCMPEQ32 0x2e -#define IIDP1_FMUL8x16 0x31 -#define IIDP1_FMUL8x16AU 0x33 -#define IIDP1_FMUL8X16AL 0x35 -#define IIDP1_FMUL8SUx16 0x36 -#define IIDP1_FMUL8ULx16 0x37 -#define IIDP1_FMULD8SUx16 0x38 -#define IIDP1_FMULD8ULx16 0x39 -#define IIDP1_FPACK32 0x3a -#define IIDP1_FPACK16 0x3b -#define IIDP1_FPACKFIX 0x3d -#define IIDP1_PDIST 0x3e -#define IIDP1_FALIGNDATA 0x48 -#define IIDP1_FPMERGE 0x4b -#define IIDP1_BSHUFFLE 0x4c /* US-III */ -#define IIDP1_FEXPAND 0x4d -#define IIDP1_FPADD16 0x50 -#define IIDP1_FPADD16S 0x51 -#define IIDP1_FPADD32 0x52 -#define IIDP1_FPADD32S 0x53 -#define IIDP1_SUB16 0x54 -#define IIDP1_SUB16S 0x55 -#define IIDP1_SUB32 0x56 -#define IIDP1_SUB32S 0x57 -#define IIDP1_FZERO 0x60 -#define IIDP1_FZEROS 0x61 -#define IIDP1_FNOR 0x62 -#define IIDP1_FNORS 0x63 -#define IIDP1_FANDNOT2 0x64 -#define IIDP1_FANDNOT2S 0x65 -#define IIDP1_NOT2 0x66 -#define IIDP1_NOT2S 0x67 -#define IIDP1_FANDNOT1 0x68 -#define IIDP1_FANDNOT1S 0x69 -#define IIDP1_FNOT1 0x6a -#define IIDP1_FNOT1S 0x6b -#define IIDP1_FXOR 0x6c -#define IIDP1_FXORS 0x6d -#define IIDP1_FNAND 0x6e -#define IIDP1_FNANDS 0x6f -#define IIDP1_FAND 0x70 -#define IIDP1_FANDS 0x71 -#define IIDP1_FXNOR 0x72 -#define IIDP1_FXNORS 0x73 -#define IIDP1_FSRC1 0x74 -#define IIDP1_FSRC1S 0x75 -#define IIDP1_FORNOT2 0x76 -#define IIDP1_FORNOT2S 0x77 -#define IIDP1_FSRC2 0x78 -#define IIDP1_FSRC2S 0x79 -#define IIDP1_FORNOT1 0x7a -#define IIDP1_FORNOT1S 0x7b -#define IIDP1_FOR 0x7c -#define IIDP1_FORS 0x7d -#define IIDP1_FONE 0x7e -#define IIDP1_FONES 0x7f -#define IIDP1_SHUTDOWN 0x80 -#define IIDP1_SIAM 0x81 /* US-III */ - -/* - * Instruction modifiers - */ -/* cond values for integer ccr's */ -#define IICOND_N 0x00 -#define IICOND_E 0x01 -#define IICOND_LE 0x02 -#define IICOND_L 0x03 -#define IICOND_LEU 0x04 -#define IICOND_CS 0x05 -#define IICOND_NEG 0x06 -#define IICOND_VS 0x07 -#define IICOND_A 0x08 -#define IICOND_NE 0x09 -#define IICOND_G 0x0a -#define IICOND_GE 0x0b -#define IICOND_GU 0x0c -#define IICOND_CC 0x0d -#define IICOND_POS 0x0e -#define IICOND_VC 0x0f - -/* cond values for fp ccr's */ -#define IFCOND_N 0x00 -#define IFCOND_NE 0x01 -#define IFCOND_LG 0x02 -#define IFCOND_UL 0x03 -#define IFCOND_L 0x04 -#define IFCOND_UG 0x05 -#define IFCOND_G 0x06 -#define IFCOND_U 0x07 -#define IFCOND_A 0x08 -#define IFCOND_E 0x09 -#define IFCOND_UE 0x0a -#define IFCOND_GE 0x0b -#define IFCOND_UGE 0x0c -#define IFCOND_LE 0x0d -#define IFCOND_ULE 0x0e -#define IFCOND_O 0x0f - -/* rcond values for BPr, MOVr, FMOVr */ -#define IRCOND_Z 0x01 -#define IRCOND_LEZ 0x02 -#define IRCOND_LZ 0x03 -#define IRCOND_NZ 0x05 -#define IRCOND_GZ 0x06 -#define IRCOND_GEZ 0x07 - -/* cc values for MOVcc and FMOVcc */ -#define IFCC_ICC 0x04 -#define IFCC_XCC 0x06 -/* if true, the lower 2 bits are the fcc number */ -#define IFCC_FCC(c) ((c) & 3) -#define IFCC_GET_FCC(c) ((c) & 3) -#define IFCC_ISFCC(c) (((c) & 4) == 0) - -/* cc values for BPc and Tcc */ -#define IBCC_ICC 0x00 -#define IBCC_XCC 0x02 - -/* - * Integer registers - */ -#define IREG_G0 0x00 -#define IREG_O0 0x08 -#define IREG_L0 0x10 -#define IREQ_I0 0x18 - -#endif /* !_MACHINE_INSTR_H_ */ diff --git a/sys/sun4v/include/intr_machdep.h b/sys/sun4v/include/intr_machdep.h deleted file mode 100644 index f686e66f37e4..000000000000 --- a/sys/sun4v/include/intr_machdep.h +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_INTR_MACHDEP_H_ -#define _MACHINE_INTR_MACHDEP_H_ - -#define IRSR_BUSY (1 << 5) - -#define PIL_MAX (1 << 4) -#define IV_MAX (1 << 11) - -#define IR_FREE (PIL_MAX * 2) - -#define IH_SHIFT PTR_SHIFT -#define IQE_SHIFT 5 -#define IV_SHIFT 5 - -#define PIL_LOW 1 /* stray interrupts */ -#define PIL_ITHREAD 2 /* interrupts that use ithreads */ -#define PIL_RENDEZVOUS 3 /* smp rendezvous ipi */ -#define PIL_AST 4 /* ast ipi */ -#define PIL_STOP 5 /* stop cpu ipi */ -#define PIL_PREEMPT 6 /* preempt idle thread cpu ipi */ -#define PIL_HARDCLOCK 7 /* hardclock broadcast */ -#define PIL_FAST 13 /* fast interrupts */ -#define PIL_TICK 14 - -#ifndef LOCORE - -struct trapframe; - -typedef void ih_func_t(struct trapframe *); -typedef void iv_func_t(void *); - -struct ithd; - -struct intr_request { - struct intr_request *ir_next; - iv_func_t *ir_func; - void *ir_arg; - u_int ir_vec; - u_int ir_pri; -}; - -struct intr_vector { - iv_func_t *iv_func; - void *iv_arg; - struct intr_event *iv_event; - u_int iv_pri; - u_int iv_vec; -}; - -extern ih_func_t *intr_handlers[]; -extern struct intr_vector intr_vectors[]; - -void intr_setup(int level, ih_func_t *ihf, int pri, iv_func_t *ivf, - void *iva); -int inthand_add(const char *name, int vec, int (*filt)(void *), - void (*handler)(void *), void *arg, int flags, void **cookiep); -int inthand_remove(int vec, void *cookie); -void cpu_intrq_init(void); - -ih_func_t intr_fast; - -#define CPU_LIST_SIZE (MAXCPU * sizeof(uint16_t)) - -#define INTR_CPU_Q_SIZE (cpu_q_entries * INTR_REPORT_SIZE) -#define INTR_DEV_Q_SIZE (dev_q_entries * INTR_REPORT_SIZE) - -#endif /* !LOCORE */ - -#define INTR_REPORT_SIZE 64 - -#define CPU_RQ_ENTRIES 64 -#define CPU_NRQ_ENTRIES 64 - -#define Q_ENTRY_SIZE 64 -#define CPU_RQ_SIZE (CPU_RQ_ENTRIES * Q_ENTRY_SIZE) -#define CPU_NRQ_SIZE (CPU_NRQ_ENTRIES * Q_ENTRY_SIZE) - - -#endif /* !_MACHINE_INTR_MACHDEP_H_ */ diff --git a/sys/sun4v/include/jbus.h b/sys/sun4v/include/jbus.h deleted file mode 100644 index 502f7851e408..000000000000 --- a/sys/sun4v/include/jbus.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/kdb.h b/sys/sun4v/include/kdb.h deleted file mode 100644 index 92b2ed7d4e42..000000000000 --- a/sys/sun4v/include/kdb.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2004 Marcel Moolenaar - * 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 ``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 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_KDB_H_ -#define _MACHINE_KDB_H_ - -#include - -static __inline void -kdb_cpu_clear_singlestep(void) -{ -} - -static __inline void -kdb_cpu_set_singlestep(void) -{ -} - -static __inline void -kdb_cpu_sync_icache(unsigned char *addr, size_t size) -{ -} - -static __inline void -kdb_cpu_trap(int vector, int _) -{ - flushw(); -} - -#endif /* _MACHINE_KDB_H_ */ diff --git a/sys/sun4v/include/kerneldump.h b/sys/sun4v/include/kerneldump.h deleted file mode 100644 index 7fad3fce88dd..000000000000 --- a/sys/sun4v/include/kerneldump.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2002 by Thomas Moestl . - * 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_KERNELDUMP_H_ -#define _MACHINE_KERNELDUMP_H_ - -struct sparc64_dump_reg { - vm_paddr_t dr_pa; - vm_offset_t dr_size; - vm_offset_t dr_offs; -}; - -/* - * Kernel dump format for sparc64. This does not use ELF because it is of no - * avail (only libkvm knows how to translate addresses properly anyway) and - * would require some ugly hacks. - */ -struct sparc64_dump_hdr { - vm_offset_t dh_hdr_size; - vm_paddr_t dh_tsb_pa; - vm_size_t dh_tsb_size; - vm_size_t dh_tsb_mask; - int dh_nregions; - struct sparc64_dump_reg dh_regions[]; -}; - -#endif /* _MACHINE_KERNELDUMP_H_ */ diff --git a/sys/sun4v/include/ktr.h b/sys/sun4v/include/ktr.h deleted file mode 100644 index 10e33cf0386b..000000000000 --- a/sys/sun4v/include/ktr.h +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 1996 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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 BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_KTR_H_ -#define _MACHINE_KTR_H_ - -#include - -#include - -#ifndef LOCORE - -#define KTR_CPU PCPU_GET(cpuid) - -#else - -#define AND(var, mask, r1, r2) \ - SET(var, r2, r1) ; \ - lduw [r1], r2 ; \ - and r2, mask, r1 - -#define TEST(var, mask, r1, r2, l1) \ - AND(var, mask, r1, r2) ; \ - brz r1, l1 ## f ; \ - nop - -/* - * XXX could really use another register... - */ -#define ATR(desc, r1, r2, r3, l1, l2) \ - .sect .rodata ; \ -l1: .asciz desc ; \ - .previous ; \ - SET(ktr_idx, r2, r1) ; \ - lduw [r1], r2 ; \ -l2: add r2, 1, r3 ; \ - set KTR_ENTRIES - 1, r1 ; \ - and r3, r1, r3 ; \ - set ktr_idx, r1 ; \ - casa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne %icc, l2 ## b ; \ - mov r3, r2 ; \ - SET(ktr_buf, r3, r1) ; \ - mulx r2, KTR_SIZEOF, r2 ; \ - add r1, r2, r1 ; \ - rd %tick, r2 ; \ - stx r2, [r1 + KTR_TIMESTAMP] ; \ - UPA_GET_MID(r2) ; \ - stw r2, [r1 + KTR_CPU] ; \ - stw %g0, [r1 + KTR_LINE] ; \ - stx %g0, [r1 + KTR_FILE] ; \ - SET(l1 ## b, r3, r2) ; \ - stx r2, [r1 + KTR_DESC] - -#define CATR(mask, desc, r1, r2, r3, l1, l2, l3) \ - set mask, r1 ; \ - TEST(ktr_mask, r1, r2, r2, l3) ; \ - UPA_GET_MID(r1) ; \ - mov 1, r2 ; \ - sllx r2, r1, r1 ; \ - TEST(ktr_cpumask, r1, r2, r3, l3) ; \ - ATR(desc, r1, r2, r3, l1, l2) - -#endif /* LOCORE */ - -#endif /* !_MACHINE_KTR_H_ */ diff --git a/sys/sun4v/include/limits.h b/sys/sun4v/include/limits.h deleted file mode 100644 index 679dcec51b31..000000000000 --- a/sys/sun4v/include/limits.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE_LIMITS_H_ -#define _MACHINE_LIMITS_H_ - -#include - -#if __CC_SUPPORTS_WARNING -#warning "machine/limits.h is deprecated. Include sys/limits.h instead." -#endif - -#include - -#endif /* !_MACHINE_LIMITS_H_ */ diff --git a/sys/sun4v/include/lsu.h b/sys/sun4v/include/lsu.h deleted file mode 100644 index a8787dcabdc7..000000000000 --- a/sys/sun4v/include/lsu.h +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_LSU_H_ -#define _MACHINE_LSU_H_ - -/* - * Definitions for the Load-Store-Unit Control Register. This is called - * Data Cache Unit Control Register (DCUCR) for UltraSPARC-III. - */ -#define LSU_IC (1UL << 0) -#define LSU_DC (1UL << 1) -#define LSU_IM (1UL << 2) -#define LSU_DM (1UL << 3) - -/* Parity control mask, UltraSPARC-I and II series only. */ -#define LSU_FM_SHIFT 4 -#define LSU_FM_BITS 16 -#define LSU_FM_MASK (((1UL << LSU_FM_BITS) - 1) << LSU_FM_SHIFT) - -#define LSU_VM_SHIFT 25 -#define LSU_VM_BITS 8 -#define LSU_VM_MASK (((1UL << LSU_VM_BITS) - 1) << LSU_VM_SHIFT) - -#define LSU_PM_SHIFT 33 -#define LSU_PM_BITS 8 -#define LSU_PM_MASK (((1UL << LSU_PM_BITS) - 1) << LSU_PM_SHIFT) - -#define LSU_VW (1UL << 21) -#define LSU_VR (1UL << 22) -#define LSU_PW (1UL << 23) -#define LSU_PR (1UL << 24) - -/* The following bits are valid for the UltraSPARC-III series only. */ -#define LSU_WE (1UL << 41) -#define LSU_SL (1UL << 42) -#define LSU_SPE (1UL << 43) -#define LSU_HPE (1UL << 44) -#define LSU_PE (1UL << 45) -#define LSU_RE (1UL << 46) -#define LSU_ME (1UL << 47) -#define LSU_CV (1UL << 48) -#define LSU_CP (1UL << 49) - -#endif /* _MACHINE_LSU_H_ */ diff --git a/sys/sun4v/include/md_var.h b/sys/sun4v/include/md_var.h deleted file mode 100644 index 9c48897ac81d..000000000000 --- a/sys/sun4v/include/md_var.h +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * Copyright (c) 1995 Bruce D. Evans. - * 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. - * 3. Neither the name of the author nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * 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. - * - * from: FreeBSD: src/sys/i386/include/md_var.h,v 1.40 2001/07/12 - * $FreeBSD$ - */ - -#ifndef _MACHINE_MD_VAR_H_ -#define _MACHINE_MD_VAR_H_ - -typedef void cpu_block_copy_t(const void *src, void *dst, size_t len); -typedef void cpu_block_zero_t(void *dst, size_t len); - -extern char tl0_base[], tl0_end[]; -extern char _end[]; - -extern long Maxmem; - -extern vm_offset_t kstack0; -extern vm_paddr_t kstack0_phys; - -struct pcpu; -struct md_utrap; - -void cpu_identify(u_long vers, u_int clock, u_int id); -void cpu_setregs(struct pcpu *pc); -int is_physical_memory(vm_paddr_t addr); -struct md_utrap *utrap_alloc(void); -void utrap_free(struct md_utrap *ut); -struct md_utrap *utrap_hold(struct md_utrap *ut); - - -extern cpu_block_copy_t *cpu_block_copy; -extern cpu_block_zero_t *cpu_block_zero; - - - -#endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/sun4v/include/mdesc_bus.h b/sys/sun4v/include/mdesc_bus.h deleted file mode 100644 index bdc115153efc..000000000000 --- a/sys/sun4v/include/mdesc_bus.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MDESC_BUS_H_ -#define _MACHINE_MDESC_BUS_H_ - -#include -#include - -#include "mdesc_bus_if.h" - -static __inline const char * -mdesc_bus_get_compat(device_t dev) -{ - - return (MDESC_BUS_GET_COMPAT(device_get_parent(dev), dev)); -} - -static __inline const struct mdesc_bus_devinfo * -mdesc_bus_get_model(device_t dev) -{ - - return (MDESC_BUS_GET_DEVINFO(device_get_parent(dev), dev)); -} - -static __inline const char * -mdesc_bus_get_name(device_t dev) -{ - - return (MDESC_BUS_GET_NAME(device_get_parent(dev), dev)); -} - -static __inline const char * -mdesc_bus_get_type(device_t dev) -{ - - return (MDESC_BUS_GET_TYPE(device_get_parent(dev), dev)); -} - -static __inline uint64_t -mdesc_bus_get_handle(device_t dev) -{ - - return (MDESC_BUS_GET_HANDLE(device_get_parent(dev), dev)); -} - -#endif /* !_MACHINE_MDESC_BUS_H_ */ diff --git a/sys/sun4v/include/mdesc_bus_subr.h b/sys/sun4v/include/mdesc_bus_subr.h deleted file mode 100644 index d25e0b5aa357..000000000000 --- a/sys/sun4v/include/mdesc_bus_subr.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MDESC_MDESC_BUS_SUBR_H_ -#define _MACHINE_MDESC_MDESC_BUS_SUBR_H_ - -#include - -#include -#include - -#include "mdesc_bus_if.h" - -int mdesc_bus_gen_setup_devinfo(struct mdesc_bus_devinfo *, mde_cookie_t); -void mdesc_bus_gen_destroy_devinfo(struct mdesc_bus_devinfo *); - -mdesc_bus_get_compat_t mdesc_bus_gen_get_compat; -mdesc_bus_get_name_t mdesc_bus_gen_get_name; -mdesc_bus_get_type_t mdesc_bus_gen_get_type; -mdesc_bus_get_handle_t mdesc_bus_gen_get_handle; - -#endif /* !_MACHINE_MDESC_MDESC_BUS_SUBR_H_ */ diff --git a/sys/sun4v/include/memdev.h b/sys/sun4v/include/memdev.h deleted file mode 100644 index f16ba16d5f6b..000000000000 --- a/sys/sun4v/include/memdev.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2004 Mark R V Murray - * 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 - * in this position and unchanged. - * 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 AUTHORS ``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 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_MEMDEV_H_ -#define _MACHINE_MEMDEV_H_ - -#define CDEV_MINOR_MEM 0 -#define CDEV_MINOR_KMEM 1 - -d_open_t memopen; -d_read_t memrw; -#define memioctl (d_ioctl_t *)NULL -#define memmmap (d_mmap_t *)NULL - -#endif /* _MACHINE_MEMDEV_H_ */ diff --git a/sys/sun4v/include/metadata.h b/sys/sun4v/include/metadata.h deleted file mode 100644 index d14e1f150d63..000000000000 --- a/sys/sun4v/include/metadata.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_METADATA_H_ -#define _MACHINE_METADATA_H_ - -#define MODINFOMD_ENVP 0x1001 -#define MODINFOMD_HOWTO 0x1002 -#define MODINFOMD_KERNEND 0x1003 -#define MODINFOMD_DTLB_SLOTS 0x1004 -#define MODINFOMD_ITLB_SLOTS 0x1005 -#define MODINFOMD_DTLB 0x1006 -#define MODINFOMD_ITLB 0x1007 - -struct tlb_entry { - vm_offset_t te_pa; - vm_offset_t te_va; -}; - -#endif /* !_MACHINE_METADATA_H_ */ diff --git a/sys/sun4v/include/mmu.h b/sys/sun4v/include/mmu.h deleted file mode 100644 index 838213633a9d..000000000000 --- a/sys/sun4v/include/mmu.h +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - - -#ifndef _MACHINE_MMU_H_ -#define _MACHINE_MMU_H_ - - -#define FAST_IMMU_MISS_TT 0x64 -#define FAST_DMMU_MISS_TT 0x68 -#define FAST_PROT_TT 0x6c - -/* - * Constants defining alternate spaces - * and register layouts within them, - * and a few other interesting assembly constants. - */ - -/* - * vaddr offsets of various registers - */ -#define MMU_PCONTEXT 0x08 /* primary context number */ -#define MMU_SCONTEXT 0x10 /* secondary context number */ - -/* - * Pseudo Synchronous Fault Status Register Layout - * - * IMMU and DMMU maintain their own pseudo SFSR Register - * - * +------------------------------------------------+ - * | Reserved | Context | FT | - * +----------------------|-------------------------+ - * 63 32 31 16 15 0 - * - */ -#define SFSR_FT 0x0000FFFF /* fault type mask */ -#define SFSR_CTX 0xFFFF0000 /* fault context mask */ - -/* - * Definition of FT (Fault Type) bit field of sfsr. - */ -#define FT_NONE 0x00 -#define FT_PRIV MMFSA_F_PRIV /* privilege violation */ -#define FT_SPEC_LD MMFSA_F_SOPG /* speculative ld to e page */ -#define FT_ATOMIC_NC MMFSA_F_NCATM /* atomic to nc page */ -#define FT_ILL_ALT MMFSA_F_INVASI /* illegal lda/sta */ -#define FT_NFO MMFSA_F_NFO /* normal access to nfo page */ -#define FT_RANGE MMFSA_F_INVVA /* dmmu or immu address out of range */ -#define FT_NEW_FMISS MMFSA_F_FMISS /* fast miss */ -#define FT_NEW_FPROT MMFSA_F_FPROT /* fast protection */ -#define FT_NEW_MISS MMFSA_F_MISS /* mmu miss */ -#define FT_NEW_INVRA MMFSA_F_INVRA /* invalid RA */ -#define FT_NEW_PROT MMFSA_F_PROT /* protection violation */ -#define FT_NEW_PRVACT MMFSA_F_PRVACT /* privileged action */ -#define FT_NEW_WPT MMFSA_F_WPT /* watchpoint hit */ -#define FT_NEW_UNALIGN MMFSA_F_UNALIGN /* unaligned access */ -#define FT_NEW_INVPGSZ MMFSA_F_INVPGSZ /* invalid page size */ - -#define SFSR_FT_SHIFT 0 /* amt. to shift right to get flt type */ -#define SFSR_CTX_SHIFT 16 /* to shift right to get context */ -#define X_FAULT_TYPE(x) (((x) & SFSR_FT) >> SFSR_FT_SHIFT) -#define X_FAULT_CTX(x) (((x) & SFSR_CTX) >> SFSR_CTX_SHIFT) - -/* - * MMU TAG TARGET register Layout - * - * +-----+---------+------+-------------------------+ - * | 000 | context | -- | virtual address [63:22] | - * +-----+---------+------+-------------------------+ - * 63 61 60 48 47 42 41 0 - */ -#define TTARGET_CTX_SHIFT 48 -#define TTARGET_VA_SHIFT 22 - - -#define TTARGET_VA_BITS 42 -#define TTARGET_VA_MASK ((1UL << TTARGET_VA_BITS) - 1) - - -/* - * MMU PRIMARY/SECONDARY CONTEXT register - */ -#define CTXREG_CTX_MASK 0x1FFF - -/* - * The kernel always runs in KCONTEXT, and no user mappings - * are ever valid in it (so any user access pagefaults). - */ -#define KCONTEXT 0 -#define CTX_OTHER_SHIFT 16 - -/* - * FLUSH_ADDR is used in the flush instruction to guarantee stores to mmu - * registers complete. It is selected so it won't miss in the tlb. - */ -#define FLUSH_ADDR (KERNBASE + 2 * PAGE_SIZE_4M) - -#endif /* _MACHINE_MMU_H_ */ diff --git a/sys/sun4v/include/nexusvar.h b/sys/sun4v/include/nexusvar.h deleted file mode 100644 index 5e28696ff799..000000000000 --- a/sys/sun4v/include/nexusvar.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_NEXUSVAR_H_ -#define _MACHINE_NEXUSVAR_H_ - -extern struct bus_dma_tag nexus_dmatag; - -enum nexus_ivars { - NEXUS_IVAR_DEVHANDLE, -}; - -#define NEXUS_ACCESSOR(var, ivar, type) \ - __BUS_ACCESSOR(nexus, var, NEXUS, ivar, type) - -NEXUS_ACCESSOR(devhandle, DEVHANDLE, uint64_t) - -#undef NEXUS_ACCESSOR - -#endif /* _MACHINE_NEXUSVAR_H_ */ diff --git a/sys/sun4v/include/ofw_machdep.h b/sys/sun4v/include/ofw_machdep.h deleted file mode 100644 index 658d9c7b0d25..000000000000 --- a/sys/sun4v/include/ofw_machdep.h +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2001 by Thomas Moestl . - * 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_MACHDEP_H_ -#define _MACHINE_OFW_MACHDEP_H_ - -#include -#include -#include - -typedef uint64_t cell_t; - -int OF_decode_addr(phandle_t, int, int *, bus_addr_t *); -void OF_getetheraddr(device_t, u_char *); -u_int OF_getscsinitid(device_t); -void cpu_shutdown(void *); -int ofw_entry(void *); -void ofw_exit(void *); - -#endif /* _MACHINE_OFW_MACHDEP_H_ */ diff --git a/sys/sun4v/include/ofw_mem.h b/sys/sun4v/include/ofw_mem.h deleted file mode 100644 index af9089ed034a..000000000000 --- a/sys/sun4v/include/ofw_mem.h +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_MEM_H_ -#define _MACHINE_OFW_MEM_H_ - -struct ofw_mem_region { - vm_paddr_t mr_start; - vm_size_t mr_size; -}; - -struct ofw_map { - vm_offset_t om_start; - vm_size_t om_size; - u_long om_tte; -}; - -extern struct ofw_mem_region sparc64_memreg[]; -extern int sparc64_nmemreg; - -#endif diff --git a/sys/sun4v/include/ofw_nexus.h b/sys/sun4v/include/ofw_nexus.h deleted file mode 100644 index fdb287d68853..000000000000 --- a/sys/sun4v/include/ofw_nexus.h +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * Copyright (c) 1999 Matthew R. Green - * 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 ``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 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. - */ - -/*- - * Copyright (c) 1998, 1999 Eduardo E. Horvath - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: psychoreg.h,v 1.14 2008/05/30 02:29:37 mrg Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_NEXUS_H_ -#define _MACHINE_OFW_NEXUS_H_ - -/* - * These are the regs used for devices on the nexus. They apply to all of - * Fireplane/Safari, JBus and UPA. - */ - -struct nexus_regs { - uint32_t phys_hi; - uint32_t phys_lo; - uint32_t size_hi; - uint32_t size_lo; -}; - -#define NEXUS_REG_PHYS(r) \ - (((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo) -#define NEXUS_REG_SIZE(r) \ - (((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo) - -#endif /* !_MACHINE_OFW_NEXUS_H_ */ - - diff --git a/sys/sun4v/include/param.h b/sys/sun4v/include/param.h deleted file mode 100644 index 2ca699e838a3..000000000000 --- a/sys/sun4v/include/param.h +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)param.h 5.8 (Berkeley) 6/28/91 - * $FreeBSD$ - */ - -#ifndef _SUN4V_INCLUDE_PARAM_H_ -#define _SUN4V_INCLUDE_PARAM_H_ - -/* - * Machine dependent constants for sparc64. - */ - -#include - -#ifndef MACHINE -#define MACHINE "sun4v" -#endif -#ifndef MACHINE_ARCH -#define MACHINE_ARCH "sparc64" -#endif -#define MID_MACHINE MID_SPARC64 - -#if defined(SMP) || defined(KLD_MODULE) -#define MAXCPU 32 -#else -#define MAXCPU 1 -#endif /* SMP || KLD_MODULE */ - -#define INT_SHIFT 2 -#define PTR_SHIFT 3 - -#define ALIGNBYTES _ALIGNBYTES -#define ALIGN(p) _ALIGN(p) -/* - * ALIGNED_POINTER is a boolean macro that checks whether an address - * is valid to fetch data elements of type t from on this architecture. - * This does not reflect the optimal alignment, just the possibility - * (within reasonable limits). - */ -#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof (t) - 1)) == 0) - -/* - * CACHE_LINE_SIZE is the compile-time maximum cache line size for an - * architecture. It should be used with appropriate caution. - */ -#define CACHE_LINE_SHIFT 7 -#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) - -#define PAGE_SHIFT_8K 13 -#define PAGE_SIZE_8K (1L<> PAGE_SHIFT) -#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) - -#define sparc64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) -#define sparc64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) - -#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) -#endif /* LOCORE */ - -#endif /* !_SUN4V_INCLUDE_PARAM_H_ */ diff --git a/sys/sun4v/include/pcb.h b/sys/sun4v/include/pcb.h deleted file mode 100644 index ae366e5ae45f..000000000000 --- a/sys/sun4v/include/pcb.h +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_PCB_H_ -#define _MACHINE_PCB_H_ - -#ifndef LOCORE -#include -#endif - -#define MAXWIN 8 - -#define PCB_FEF (1 << 0) - -#ifndef LOCORE - -/* NOTE: pcb_ufp must be aligned on a 64 byte boundary. */ -struct pcb { - struct rwindow pcb_rw[MAXWIN]; /* wbuf for page faults during spill / fill trap handling */ - uint32_t pcb_kfp[64]; /* used for regs in handling kernel floating point exc */ - uint32_t pcb_ufp[64]; /* used for regs in handling user floating point exc */ - uint64_t pcb_rwsp[MAXWIN]; /* spbuf sp's for each wbuf */ - uint64_t pcb_flags; - uint64_t pcb_nsaved; /* number of windows saved in pcb_rw */ - uint64_t pcb_pc; - uint64_t pcb_sp; - uint64_t pcb_kstack; /* pcb's kernel stack */ - uint64_t pcb_tstate; - uint64_t pcb_tpc; - uint64_t pcb_tnpc; - uint64_t pcb_tt; - uint64_t pcb_sfar; - uint64_t pcb_pad[7]; -} __aligned(64); - -#ifdef _KERNEL -void makectx(struct trapframe *tf, struct pcb *pcb); -int savectx(struct pcb *pcb); -#endif - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_PCB_H_ */ diff --git a/sys/sun4v/include/pcpu.h b/sys/sun4v/include/pcpu.h deleted file mode 100644 index ba7925661ba3..000000000000 --- a/sys/sun4v/include/pcpu.h +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * Copyright (c) 1999 Luoqi Chen - * 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. - * - * from: FreeBSD: src/sys/i386/include/globaldata.h,v 1.27 2001/04/27 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PCPU_H_ -#define _MACHINE_PCPU_H_ - -#include -#include -#include - -#define ALT_STACK_SIZE 128 - -struct pmap; - -#ifdef KTR -#define PCPU_MD_FIELDS_PAD (3 - (PCPU_NAME_LEN + 7) / 8) -#else -#define PCPU_MD_FIELDS_PAD 3 -#endif - -/* - * Inside the kernel, the globally reserved register g7 is used to - * point at the globaldata structure. - */ -#define PCPU_MD_FIELDS \ - struct intr_request pc_irpool[IR_FREE]; \ - struct intr_request *pc_irhead; \ - struct intr_request **pc_irtail; \ - struct intr_request *pc_irfree; \ - struct pmap *pc_curpmap; \ - vm_offset_t pc_addr; \ - vm_offset_t *pc_mondo_data; \ - vm_offset_t *pc_cpu_list; \ - vm_offset_t *pc_cpu_q; \ - vm_offset_t *pc_dev_q; \ - vm_offset_t *pc_rq; \ - vm_offset_t *pc_nrq; \ - vm_paddr_t pc_mondo_data_ra; \ - vm_paddr_t pc_cpu_list_ra; \ - vm_paddr_t pc_cpu_q_ra; \ - uint64_t pc_cpu_q_size; \ - vm_paddr_t pc_dev_q_ra; \ - uint64_t pc_dev_q_size; \ - vm_paddr_t pc_rq_ra; \ - uint64_t pc_rq_size; \ - vm_paddr_t pc_nrq_ra; \ - uint64_t pc_nrq_size; \ - u_long pc_tickref; \ - u_long pc_tickadj; \ - u_long pc_tickincrement; \ - struct rwindow pc_kwbuf; \ - u_long pc_kwbuf_sp; \ - u_int pc_kwbuf_full; \ - struct rwindow pc_tsbwbuf[2]; \ - uint16_t pc_cpulist[MAXCPU]; \ - uint64_t pad[PCPU_MD_FIELDS_PAD]; - - /* XXX SUN4V_FIXME - as we access the *_ra and *_size fields in quick - * succession we _really_ want them to be L1 cache line size aligned - * and it is quite possible that we want all of ASI_QUEUE fields to - * be L2 cache aligned - they're surrounded by per-cpu data, so there is - * no possibility of false sharing, but this might help in reducing misses - */ - -#ifdef _KERNEL - -extern void *dpcpu0; - -struct pcpu; - -register struct pcpu *pcpup __asm__(__XSTRING(PCPU_REG)); - -#define PCPU_GET(member) (pcpup->pc_ ## member) - -/* - * XXX The implementation of this operation should be made atomic - * with respect to preemption. - */ -#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value)) -#define PCPU_INC(member) PCPU_ADD(member, 1) -#define PCPU_PTR(member) (&pcpup->pc_ ## member) -#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PCPU_H_ */ diff --git a/sys/sun4v/include/pmap.h b/sys/sun4v/include/pmap.h deleted file mode 100644 index 9c2c486b823a..000000000000 --- a/sys/sun4v/include/pmap.h +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department and William Jolitz of UUNET Technologies Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 - * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 - * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ - -#include -#include -#include -#include -#include - -#define TSB_INIT_SHIFT 3 -#define PMAP_CONTEXT_MAX 8192 -/* - * We don't want TSBs getting above 1MB - which is enough - * for a working set of 512MB - revisit in the future - */ -#define TSB_MAX_RESIZE (20 - TSB_INIT_SHIFT - PAGE_SHIFT) - -typedef struct pmap *pmap_t; - -struct pv_entry; -struct tte_hash; - -struct md_page { - int pv_list_count; - TAILQ_HEAD(, pv_entry) pv_list; -}; - - -struct pmap { - uint64_t pm_context; - uint64_t pm_hashscratch; - uint64_t pm_tsbscratch; - vm_paddr_t pm_tsb_ra; - - struct mtx pm_mtx; - struct tte_hash *pm_hash; - TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ - struct hv_tsb_info pm_tsb; - cpumask_t pm_active; /* mask of cpus currently using pmap */ - cpumask_t pm_tlbactive; /* mask of cpus that have used this pmap */ - struct pmap_statistics pm_stats; - uint32_t pm_tsb_miss_count; - uint32_t pm_tsb_cap_miss_count; - vm_paddr_t pm_old_tsb_ra[TSB_MAX_RESIZE]; -}; - -#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) -#define PMAP_LOCK_ASSERT(pmap, type) \ - mtx_assert(&(pmap)->pm_mtx, (type)) -#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) -#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ - NULL, MTX_DEF | MTX_DUPOK) -#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) -#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) -#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) -#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) - -/* - * For each vm_page_t, there is a list of all currently valid virtual - * mappings of that page. An entry is a pv_entry_t, the list is pv_list. - */ - -typedef struct pv_entry { - pmap_t pv_pmap; - vm_offset_t pv_va; - TAILQ_ENTRY(pv_entry) pv_list; - TAILQ_ENTRY(pv_entry) pv_plist; -} *pv_entry_t; - -#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT -#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) -#define pmap_page_set_memattr(m, ma) (void)0 - -void pmap_bootstrap(vm_offset_t ekva); -vm_paddr_t pmap_kextract(vm_offset_t va); - -void pmap_invalidate_page(pmap_t pmap, vm_offset_t va, int cleartsb); -void pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int cleartsb); -void pmap_invalidate_all(pmap_t pmap); -void pmap_scrub_pages(vm_paddr_t pa, int64_t size); -void pmap_free_contig_pages(void *ptr, int npages); -void *pmap_alloc_zeroed_contig_pages(int npages, uint64_t alignment); - -#define vtophys(va) pmap_kextract((vm_offset_t)(va)) - -extern struct pmap kernel_pmap_store; -#define kernel_pmap (&kernel_pmap_store) -extern vm_paddr_t phys_avail[]; -extern vm_offset_t virtual_avail; -extern vm_offset_t virtual_end; -extern vm_paddr_t msgbuf_phys; - -#endif /* !_MACHINE_PMAP_H_ */ diff --git a/sys/sun4v/include/pmc_mdep.h b/sys/sun4v/include/pmc_mdep.h deleted file mode 100644 index 7ced0b9559e9..000000000000 --- a/sys/sun4v/include/pmc_mdep.h +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_PMC_MDEP_H_ -#define _MACHINE_PMC_MDEP_H_ - -union pmc_md_op_pmcallocate { - uint64_t __pad[4]; -}; - -/* Logging */ -#define PMCLOG_READADDR PMCLOG_READ64 -#define PMCLOG_EMITADDR PMCLOG_EMIT64 - -#if _KERNEL -union pmc_md_pmc { -}; - -#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */ -#define PMC_TRAPFRAME_TO_FP(TF) (0) -#define PMC_TRAPFRAME_TO_SP(TF) (0) - -#endif - -#endif /* !_MACHINE_PMC_MDEP_H_ */ diff --git a/sys/sun4v/include/proc.h b/sys/sun4v/include/proc.h deleted file mode 100644 index dceea17a33e7..000000000000 --- a/sys/sun4v/include/proc.h +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * Copyright (c) 1991 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 - * from: FreeBSD: src/sys/i386/include/proc.h,v 1.11 2001/06/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PROC_H_ -#define _MACHINE_PROC_H_ - -#include - -struct md_utrap { - utrap_entry_t *ut_precise[UT_MAX]; /* must be first */ - int ut_refcnt; -}; - -struct mdthread { - int md_spinlock_count; /* (k) */ - register_t md_saved_pil; /* (k) */ -}; - -struct mdproc { - struct md_utrap *md_utrap; - void *md_sigtramp; -}; - -#define KINFO_PROC_SIZE 1088 - -#ifdef _KERNEL - -struct syscall_args { - u_int code; - struct sysent *callp; - register_t args[8]; - int narg; -}; -#define HAVE_SYSCALL_ARGS_DEF 1 - -#endif - -#endif /* !_MACHINE_PROC_H_ */ diff --git a/sys/sun4v/include/profile.h b/sys/sun4v/include/profile.h deleted file mode 100644 index 6c7d1b297ac9..000000000000 --- a/sys/sun4v/include/profile.h +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - * - * from: NetBSD: profile.h,v 1.9 1997/04/06 08:47:37 cgd Exp - * from: FreeBSD: src/sys/alpha/include/profile.h,v 1.4 1999/12/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_PROFILE_H_ -#define _MACHINE_PROFILE_H_ - -#if !defined(_KERNEL) && !defined(_SYS_CDEFS_H_) -#error this file needs sys/cdefs.h as a prerequisite -#endif - -#define FUNCTION_ALIGNMENT 32 - -typedef u_long fptrdiff_t; - -#ifdef _KERNEL - -#include -#include - -#define _MCOUNT_DECL void mcount -#define MCOUNT - -#define MCOUNT_DECL(s) register_t s; -#define MCOUNT_ENTER(s) s = rdpr(pil); wrpr(pil, 0, PIL_TICK) -#define MCOUNT_EXIT(s) wrpr(pil, 0, s) - -void bintr(void); -void btrap(void); -void eintr(void); -void user(void); - -#define MCOUNT_FROMPC_USER(pc) \ - ((pc < (uintfptr_t)VM_MAXUSER_ADDRESS) ? (uintfptr_t)user : pc) - -#define MCOUNT_FROMPC_INTR(pc) \ - ((pc >= (uintfptr_t)btrap && pc < (uintfptr_t)eintr) ? \ - ((pc >= (uintfptr_t)bintr) ? (uintfptr_t)bintr : \ - (uintfptr_t)btrap) : ~0UL) - -void mcount(uintfptr_t frompc, uintfptr_t selfpc); - -#else /* !_KERNEL */ - -typedef u_long uintfptr_t; - -#define _MCOUNT_DECL static __inline void __mcount - -#ifdef __GNUCLIKE_ASM -#define MCOUNT \ -void \ -_mcount() \ -{ \ - uintfptr_t frompc, selfpc; \ - \ - /* \ - * Find the return address for mcount, \ - * and the return address for mcount's caller. \ - * \ - * selfpc = pc pushed by call to mcount \ - */ \ - __asm("add %%o7, 8, %0" : "=r" (selfpc)); \ - /* \ - * frompc = pc pushed by call to mcount's caller. \ - */ \ - __asm("add %%i7, 8, %0" : "=r" (frompc)); \ - __mcount(frompc, selfpc); \ -} -#else /* !__GNUCLIKE_ASM */ -#define MCOUNT -#endif /* __GNUCLIKE_ASM */ - -#endif /* _KERNEL */ - -#endif /* !_MACHINE_PROFILE_H_ */ diff --git a/sys/sun4v/include/pstate.h b/sys/sun4v/include/pstate.h deleted file mode 100644 index f0e5b68d6556..000000000000 --- a/sys/sun4v/include/pstate.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_PSTATE_H_ -#define _MACHINE_PSTATE_H_ - -#define PSTATE_IE (1<<1) -#define PSTATE_PRIV (1<<2) -#define PSTATE_AM (1<<3) -#define PSTATE_PEF (1<<4) -#define PSTATE_RED (1<<5) - -#define PSTATE_MM_SHIFT (6) -#define PSTATE_MM_SIZE (2) -#define PSTATE_MM_MASK (((1<. - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ diff --git a/sys/sun4v/include/resource.h b/sys/sun4v/include/resource.h deleted file mode 100644 index 229d14f253b0..000000000000 --- a/sys/sun4v/include/resource.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_RESOURCE_H_ -#define _MACHINE_RESOURCE_H_ 1 - -/* - * Definitions of resource types for Intel Architecture machines - * with support for legacy ISA devices and drivers. - */ - -#define SYS_RES_IRQ 1 /* interrupt lines */ -#define SYS_RES_DRQ 2 /* isa dma lines */ -#define SYS_RES_MEMORY 3 /* i/o memory */ -#define SYS_RES_IOPORT 4 /* i/o ports */ - -#endif /* !_MACHINE_RESOURCE_H_ */ diff --git a/sys/sun4v/include/runq.h b/sys/sun4v/include/runq.h deleted file mode 100644 index 6d03646fd539..000000000000 --- a/sys/sun4v/include/runq.h +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_RUNQ_H_ -#define _MACHINE_RUNQ_H_ - -#define RQB_LEN (1UL) /* Number of priority status words. */ -#define RQB_L2BPW (6UL) /* Log2(sizeof(rqb_word_t) * NBBY)). */ -#define RQB_BPW (1UL<> RQB_L2BPW) - -#define RQB_FFS(word) (ffs64(word) - 1) - -/* - * Type of run queue status word. - */ -typedef u_int64_t rqb_word_t; - -static __inline u_long -ffs64(u_long mask) -{ - u_long bit; - - if (mask == 0) - return (0); - for (bit = 1; (mask & 1UL) == 0; bit++) - mask >>= 1UL; - return (bit); -} - -#endif diff --git a/sys/sun4v/include/sc_machdep.h b/sys/sun4v/include/sc_machdep.h deleted file mode 100644 index 3a492f2383ba..000000000000 --- a/sys/sun4v/include/sc_machdep.h +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2003 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_SC_MACHDEP_H_ -#define _MACHINE_SC_MACHDEP_H_ - -/* Color attributes for foreground text */ - -#define FG_BLACK 0x0 -#define FG_BLUE 0x1 -#define FG_GREEN 0x2 -#define FG_CYAN 0x3 -#define FG_RED 0x4 -#define FG_MAGENTA 0x5 -#define FG_BROWN 0x6 -#define FG_LIGHTGREY 0x7 -#define FG_DARKGREY 0x8 -#define FG_LIGHTBLUE 0x9 -#define FG_LIGHTGREEN 0xa -#define FG_LIGHTCYAN 0xb -#define FG_LIGHTRED 0xc -#define FG_LIGHTMAGENTA 0xd -#define FG_YELLOW 0xe -#define FG_WHITE 0xf -#define FG_BLINK 0x80 - -/* Color attributes for text background */ - -#define BG_BLACK 0x00 -#define BG_BLUE 0x10 -#define BG_GREEN 0x20 -#define BG_CYAN 0x30 -#define BG_RED 0x40 -#define BG_MAGENTA 0x50 -#define BG_BROWN 0x60 -#define BG_LIGHTGREY 0x70 -#define BG_DARKGREY 0x80 -#define BG_LIGHTBLUE 0x90 -#define BG_LIGHTGREEN 0xa0 -#define BG_LIGHTCYAN 0xb0 -#define BG_LIGHTRED 0xc0 -#define BG_LIGHTMAGENTA 0xd0 -#define BG_YELLOW 0xe0 -#define BG_WHITE 0xf0 - -#define SC_NORM_ATTR (FG_BLACK | BG_WHITE) -#define SC_NORM_REV_ATTR (FG_WHITE | BG_BLACK) -#define SC_KERNEL_CONS_ATTR (FG_BLACK | BG_WHITE) -#define SC_KERNEL_CONS_REV_ATTR (FG_WHITE | BG_BLACK) - -#endif /* !_MACHINE_SC_MACHDEP_H_ */ diff --git a/sys/sun4v/include/setjmp.h b/sys/sun4v/include/setjmp.h deleted file mode 100644 index f58776dce61c..000000000000 --- a/sys/sun4v/include/setjmp.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1998 John Birrell . - * 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. - * 3. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * From: FreeBSD: src/sys/i386/include/setjmp.h,v 1.5 2000/10/06 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SETJMP_H_ -#define _MACHINE_SETJMP_H_ - -#include - -#define _JBLEN 5 - -#define _JB_FP 0 -#define _JB_PC 1 -#define _JB_SP 2 -#define _JB_SIGMASK 3 -#define _JB_SIGFLAG 5 - -/* - * jmp_buf and sigjmp_buf are encapsulated in different structs to force - * compile-time diagnostics for mismatches. The structs are the same - * internally to avoid some run-time errors for mismatches. - */ -#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE -typedef struct _sigjmp_buf { long _sjb[_JBLEN + 1]; } sigjmp_buf[1]; -#endif - -typedef struct _jmp_buf { long _jb[_JBLEN + 1]; } jmp_buf[1]; - -#endif /* !_MACHINE_SETJMP_H_ */ diff --git a/sys/sun4v/include/sf_buf.h b/sys/sun4v/include/sf_buf.h deleted file mode 100644 index b090cb26601d..000000000000 --- a/sys/sun4v/include/sf_buf.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2003 Alan L. Cox - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_SF_BUF_H_ -#define _MACHINE_SF_BUF_H_ - -#include - -#include -#include -#include -/* - * On this machine, the only purpose for which sf_buf is used is to implement - * an opaque pointer required by the machine-independent parts of the kernel. - * That pointer references the vm_page that is "mapped" by the sf_buf. The - * actual mapping is provided by the direct virtual-to-physical mapping. - */ -struct sf_buf; - -static __inline vm_offset_t -sf_buf_kva(struct sf_buf *sf) -{ - - return (TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS((vm_page_t)sf))); -} - -static __inline struct vm_page * -sf_buf_page(struct sf_buf *sf) -{ - - return ((vm_page_t)sf); -} - -#endif /* !_MACHINE_SF_BUF_H_ */ diff --git a/sys/sun4v/include/sigframe.h b/sys/sun4v/include/sigframe.h deleted file mode 100644 index fd40afdd1209..000000000000 --- a/sys/sun4v/include/sigframe.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 1999 Marcel Moolenaar - * 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 - * in this position and unchanged. - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: FreeBSD: src/sys/alpha/include/sigframe.h,v 1.1 1999/09/29 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SIGFRAME_H_ -#define _MACHINE_SIGFRAME_H_ 1 - -struct sigframe { - ucontext_t sf_uc; - siginfo_t sf_si; -}; - -#endif /* _MACHINE_SIGFRAME_H_ */ diff --git a/sys/sun4v/include/signal.h b/sys/sun4v/include/signal.h deleted file mode 100644 index d96cef6dd6c8..000000000000 --- a/sys/sun4v/include/signal.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1986, 1989, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)signal.h 8.1 (Berkeley) 6/11/93 - * from: FreeBSD: src/sys/i386/include/signal.h,v 1.13 2000/11/09 - * $FreeBSD$ - */ - -#ifndef _MACHINE_SIGNAL_H_ -#define _MACHINE_SIGNAL_H_ - -#include - -typedef long sig_atomic_t; - -#if __BSD_VISIBLE -struct sigcontext { - int _dummy; -}; -#endif /* __BSD_VISIBLE */ - -#endif /* !_MACHINE_SIGNAL_H_ */ diff --git a/sys/sun4v/include/smp.h b/sys/sun4v/include/smp.h deleted file mode 100644 index c075cacfa86f..000000000000 --- a/sys/sun4v/include/smp.h +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_SMP_H_ -#define _MACHINE_SMP_H_ - -#define CPU_CLKSYNC 1 -#define CPU_INIT 2 -#define CPU_BOOTSTRAP 3 - -#ifndef LOCORE - -#include -#include - -#define IDR_BUSY (1<<0) -#define IDR_NACK (1<<1) - -#define IPI_AST PIL_AST -#define IPI_RENDEZVOUS PIL_RENDEZVOUS -#define IPI_STOP PIL_STOP -#define IPI_STOP_HARD PIL_STOP -#define IPI_PREEMPT PIL_PREEMPT -#define IPI_HARDCLOCK PIL_HARDCLOCK - -#define IPI_RETRIES 5000 - -struct cpu_start_args { - u_int csa_count; - u_int csa_state; - vm_offset_t csa_pcpu; - u_int csa_cpuid; -}; - -struct ipi_cache_args { - cpumask_t ica_mask; - vm_paddr_t ica_pa; -}; - -struct ipi_tlb_args { - cpumask_t ita_mask; - struct pmap *ita_pmap; - u_long ita_start; - u_long ita_end; -}; -#define ita_va ita_start - -struct pcpu; - -void cpu_mp_bootstrap(struct pcpu *pc); -void cpu_mp_shutdown(void); - -void cpu_ipi_selected(int cpu_count, uint16_t *cpulist, u_long d0, u_long d1, u_long d2, uint64_t *ackmask); -void cpu_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2); - -void cpu_ipi_ast(struct trapframe *tf); -void cpu_ipi_stop(struct trapframe *tf); -void cpu_ipi_preempt(struct trapframe *tf); -void cpu_ipi_hardclock(struct trapframe *tf); - -void ipi_all_but_self(u_int ipi); -void ipi_cpu(int cpu, u_int ipi); -void ipi_selected(cpumask_t cpus, u_int ipi); - -vm_offset_t mp_tramp_alloc(void); -void mp_set_tsb_desc_ra(vm_paddr_t); -void mp_add_nucleus_mapping(vm_offset_t, uint64_t); -extern struct mtx ipi_mtx; -extern struct ipi_cache_args ipi_cache_args; -extern struct ipi_tlb_args ipi_tlb_args; - -extern vm_offset_t mp_tramp; -extern char *mp_tramp_code; -extern u_long mp_tramp_code_len; -extern u_long mp_tramp_tte_slots; -extern u_long mp_tramp_tsb_desc_ra; -extern u_long mp_tramp_func; - -extern void mp_startup(void); - -extern char tl_ipi_level[]; -extern char tl_invltlb[]; -extern char tl_invlctx[]; -extern char tl_invlpg[]; -extern char tl_invlrng[]; -extern char tl_tsbupdate[]; -extern char tl_ttehashupdate[]; - -#ifdef SMP - -#if defined(_MACHINE_PMAP_H_) && defined(_SYS_MUTEX_H_) -#if 0 -static __inline void * -ipi_dcache_page_inval(void *func, vm_paddr_t pa) -{ - struct ipi_cache_args *ica; - - if (smp_cpus == 1) - return (NULL); - ica = &ipi_cache_args; - mtx_lock_spin(&ipi_mtx); - ica->ica_mask = all_cpus; - ica->ica_pa = pa; - cpu_ipi_selected(PCPU_GET(other_cpus), 0, (u_long)func, (u_long)ica); - return (&ica->ica_mask); -} - -static __inline void * -ipi_icache_page_inval(void *func, vm_paddr_t pa) -{ - struct ipi_cache_args *ica; - - if (smp_cpus == 1) - return (NULL); - ica = &ipi_cache_args; - mtx_lock_spin(&ipi_mtx); - ica->ica_mask = all_cpus; - ica->ica_pa = pa; - cpu_ipi_selected(PCPU_GET(other_cpus), 0, (u_long)func, (u_long)ica); - return (&ica->ica_mask); -} - -static __inline void * -ipi_tlb_context_demap(struct pmap *pm) -{ - struct ipi_tlb_args *ita; - cpumask_t cpus; - - if (smp_cpus == 1) - return (NULL); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) - return (NULL); - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); - ita->ita_pmap = pm; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_context_demap, - (u_long)ita); - return (&ita->ita_mask); -} - -static __inline void * -ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va) -{ - struct ipi_tlb_args *ita; - cpumask_t cpus; - - if (smp_cpus == 1) - return (NULL); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) - return (NULL); - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); - ita->ita_pmap = pm; - ita->ita_va = va; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_page_demap, (u_long)ita); - return (&ita->ita_mask); -} - -static __inline void * -ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) -{ - struct ipi_tlb_args *ita; - cpumask_t cpus; - - if (smp_cpus == 1) - return (NULL); - if ((cpus = (pm->pm_active & PCPU_GET(other_cpus))) == 0) - return (NULL); - ita = &ipi_tlb_args; - mtx_lock_spin(&ipi_mtx); - ita->ita_mask = cpus | PCPU_GET(cpumask); - ita->ita_pmap = pm; - ita->ita_start = start; - ita->ita_end = end; - cpu_ipi_selected(cpus, 0, (u_long)tl_ipi_tlb_range_demap, (u_long)ita); - return (&ita->ita_mask); -} -#endif -static __inline void -ipi_wait(void *cookie) -{ - volatile cpumask_t *mask; - - if ((mask = cookie) != NULL) { - atomic_clear_int(mask, PCPU_GET(cpumask)); - while (*mask != 0) - ; - mtx_unlock_spin(&ipi_mtx); - } -} - -#endif /* _MACHINE_PMAP_H_ && _SYS_MUTEX_H_ */ - -#else - -static __inline void * -ipi_dcache_page_inval(void *func, vm_paddr_t pa) -{ - return (NULL); -} - -static __inline void * -ipi_icache_page_inval(void *func, vm_paddr_t pa) -{ - return (NULL); -} - -static __inline void * -ipi_tlb_context_demap(struct pmap *pm) -{ - return (NULL); -} - -static __inline void * -ipi_tlb_page_demap(struct pmap *pm, vm_offset_t va) -{ - return (NULL); -} - -static __inline void * -ipi_tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end) -{ - return (NULL); -} - -static __inline void -ipi_wait(void *cookie) -{ -} - -#endif /* SMP */ - -#endif /* !LOCORE */ - -#endif /* !_MACHINE_SMP_H_ */ diff --git a/sys/sun4v/include/stack.h b/sys/sun4v/include/stack.h deleted file mode 100644 index 8131ce5c3baf..000000000000 --- a/sys/sun4v/include/stack.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_STACK_H_ -#define _MACHINE_STACK_H_ - -#define INKERNEL(va) \ - ((va) >= VM_MIN_KERNEL_ADDRESS && (va) <= VM_MAX_KERNEL_ADDRESS) - -#endif /* !_MACHINE_STACK_H_ */ diff --git a/sys/sun4v/include/stdarg.h b/sys/sun4v/include/stdarg.h deleted file mode 100644 index 9e6cd94c70dc..000000000000 --- a/sys/sun4v/include/stdarg.h +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2002 David E. O'Brien. All rights reserved. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)stdarg.h 8.2 (Berkeley) 9/27/93 - * $NetBSD: stdarg.h,v 1.11 2000/07/23 21:36:56 mycroft Exp $ - * $FreeBSD$ - */ - -#ifndef _MACHINE_STDARG_H_ -#define _MACHINE_STDARG_H_ - -#include -#include - -#ifndef _VA_LIST_DECLARED -#define _VA_LIST_DECLARED -typedef __va_list va_list; -#endif - -#ifdef __GNUCLIKE_BUILTIN_STDARG - -#define va_start(ap, last) \ - __builtin_va_start((ap), (last)) - -#define va_arg(ap, type) \ - __builtin_va_arg((ap), type) - -#if __ISO_C_VISIBLE >= 1999 -#define va_copy(dest, src) \ - __builtin_va_copy((dest), (src)) -#endif - -#define va_end(ap) \ - __builtin_va_end(ap) - -#else /* ! __GNUCLIKE_BUILTIN_STDARG */ - -#if !defined(__GNUCLIKE_BUILTIN_NEXT_ARG) && !defined(lint) -#error no support for your compiler -#endif - -#define va_start(ap, last) \ - (__builtin_next_arg(last), (ap) = (va_list)__builtin_saveregs()) - -#define va_end(ap) - -#define __va_arg8(ap, type) \ - (*(type *)(void *)((ap) += 8, (ap) - 8)) -#define __va_arg16(ap, type) \ - (*(type *)(void *)((ap) = (va_list)(((unsigned long)(ap) + 31) & -16),\ - (ap) - 16)) -#define __va_int(ap, type) \ - (*(type *)(void *)((ap) += 8, (ap) - sizeof(type))) - -#define __REAL_TYPE_CLASS 8 -#define __RECORD_TYPE_CLASS 12 -#define va_arg(ap, type) \ - (__builtin_classify_type(*(type *)0) == __REAL_TYPE_CLASS ? \ - (__alignof__(type) == 16 ? __va_arg16(ap, type) : \ - __va_arg8(ap, type)) : \ - (__builtin_classify_type(*(type *)0) < __RECORD_TYPE_CLASS ? \ - __va_int(ap, type) : \ - (sizeof(type) <= 8 ? __va_arg8(ap, type) : \ - (sizeof(type) <= 16 ? __va_arg16(ap, type) : \ - *__va_arg8(ap, type *))))) - -#endif /* __GNUCLIKE_BUILTIN_STDARG */ - -#endif /* !_MACHINE_STDARG_H_ */ diff --git a/sys/sun4v/include/sun4v_cpufunc.h b/sys/sun4v/include/sun4v_cpufunc.h deleted file mode 100644 index 61eb2cca1393..000000000000 --- a/sys/sun4v/include/sun4v_cpufunc.h +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_SUN4V_CPUFUNC_H_ -#define _MACHINE_SUN4V_CPUFUNC_H_ -#include -void set_mmfsa_scratchpad(vm_paddr_t mmfsa); - -void set_hash_user_scratchpad(uint64_t); -void set_tsb_user_scratchpad(uint64_t); -void set_hash_kernel_scratchpad(uint64_t); -void set_tsb_kernel_scratchpad(uint64_t); -void init_mondo(uint64_t func, uint64_t arg1, uint64_t arg2, uint64_t arg3); -void init_mondo_queue(void); - -static __inline void * -set_tba(void *ntba) -{ - void *otba; - otba = (char *)rdpr(tba); - wrpr(tba, ntba, 0); - return otba; -} - - - -static __inline void -set_wstate(u_long nwstate) -{ - wrpr(wstate, nwstate, 0); -} - -void invlpg(uint16_t ctx, vm_offset_t va); - -void invlctx(uint16_t ctx); - -void invltlb(void); - -static __inline void -store_real(vm_paddr_t ra, uint64_t val) -{ - stxa(ra, ASI_REAL, val); -} - -static __inline void -store_real_sync(vm_paddr_t ra, uint64_t val) -{ - stxa_sync(ra, ASI_REAL, val); -} - -static __inline uint64_t -load_real(vm_paddr_t ra) -{ - uint64_t val; - val = ldxa(ra, ASI_REAL); - return val; -} - - -void load_real_dw(vm_paddr_t ra, uint64_t *lo, uint64_t *hi); -void bzerophyspage(vm_paddr_t ra, uint64_t size); -int hwblkclr(void *p, uint64_t size); -int novbcopy(void *src, void *dst, uint64_t size); - - -#endif /* !_MACHINE_CPUFUNC_H_ */ diff --git a/sys/sun4v/include/sysarch.h b/sys/sun4v/include/sysarch.h deleted file mode 100644 index c209ef8048d2..000000000000 --- a/sys/sun4v/include/sysarch.h +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * Copyright (c) 1993 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: FreeBSD: src/sys/i386/include/sysarch.h,v 1.14 2000/09/21 - * $FreeBSD$ - */ - -/* - * Architecture specific syscalls (sparc64) - */ -#ifndef _MACHINE_SYSARCH_H_ -#define _MACHINE_SYSARCH_H_ - -#define SPARC_UTRAP_INSTALL 1 -#define SPARC_SIGTRAMP_INSTALL 2 - -struct sparc_utrap_install_args { - int num; - const struct sparc_utrap_args *handlers; -}; - -struct sparc_sigtramp_install_args { - void *sia_new; - void **sia_old; -}; - -struct sparc_utrap_args { - utrap_entry_t type; - utrap_handler_t new_precise; - utrap_handler_t new_deferred; - utrap_handler_t *old_precise; - utrap_handler_t *old_deferred; -}; - -#ifndef _KERNEL -#include - -__BEGIN_DECLS -int __sparc_utrap_install(utrap_entry_t type, utrap_handler_t new_precise, - utrap_handler_t new_deferred, - utrap_handler_t *old_precise, - utrap_handler_t *old_deferred); -int sysarch(int, void *); -__END_DECLS -#endif - -#endif /* !_MACHINE_SYSARCH_H_ */ diff --git a/sys/sun4v/include/tick.h b/sys/sun4v/include/tick.h deleted file mode 100644 index 1bb739e78aad..000000000000 --- a/sys/sun4v/include/tick.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TICK_H_ -#define _MACHINE_TICK_H_ - -void tick_init(u_long clock); - -#endif diff --git a/sys/sun4v/include/tlb.h b/sys/sun4v/include/tlb.h deleted file mode 100644 index 74e008ebcf6c..000000000000 --- a/sys/sun4v/include/tlb.h +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TLB_H_ -#define _MACHINE_TLB_H_ - -#define TLB_DIRECT_ADDRESS_BITS (43) -#define TLB_DIRECT_PAGE_BITS (PAGE_SHIFT_4M) - -#define TLB_DIRECT_ADDRESS_MASK ((1UL << TLB_DIRECT_ADDRESS_BITS) - 1) -#define TLB_DIRECT_PAGE_MASK ((1UL << TLB_DIRECT_PAGE_BITS) - 1) - -#define TLB_PHYS_TO_DIRECT(pa) \ - ((pa) | VM_MIN_DIRECT_ADDRESS) -#define TLB_DIRECT_TO_PHYS(va) \ - ((va) & TLB_DIRECT_ADDRESS_MASK) -#define TLB_DIRECT_TO_TTE_MASK \ - (TD_V | TD_4M | (TLB_DIRECT_ADDRESS_MASK - TLB_DIRECT_PAGE_MASK)) - -#define TLB_DAR_SLOT_SHIFT (3) -#define TLB_DAR_SLOT(slot) ((slot) << TLB_DAR_SLOT_SHIFT) - -#define TAR_VPN_SHIFT (13) -#define TAR_CTX_MASK ((1 << TAR_VPN_SHIFT) - 1) - -#define TLB_TAR_VA(va) ((va) & ~TAR_CTX_MASK) -#define TLB_TAR_CTX(ctx) ((ctx) & TAR_CTX_MASK) - -#define TLB_DEMAP_ID_SHIFT (4) -#define TLB_DEMAP_ID_PRIMARY (0) -#define TLB_DEMAP_ID_SECONDARY (1) -#define TLB_DEMAP_ID_NUCLEUS (2) - -#define TLB_DEMAP_TYPE_SHIFT (6) -#define TLB_DEMAP_TYPE_PAGE (0) -#define TLB_DEMAP_TYPE_CONTEXT (1) - -#define TLB_DEMAP_VA(va) ((va) & ~PAGE_MASK) -#define TLB_DEMAP_ID(id) ((id) << TLB_DEMAP_ID_SHIFT) -#define TLB_DEMAP_TYPE(type) ((type) << TLB_DEMAP_TYPE_SHIFT) - -#define TLB_DEMAP_PAGE (TLB_DEMAP_TYPE(TLB_DEMAP_TYPE_PAGE)) -#define TLB_DEMAP_CONTEXT (TLB_DEMAP_TYPE(TLB_DEMAP_TYPE_CONTEXT)) - -#define TLB_DEMAP_PRIMARY (TLB_DEMAP_ID(TLB_DEMAP_ID_PRIMARY)) -#define TLB_DEMAP_SECONDARY (TLB_DEMAP_ID(TLB_DEMAP_ID_SECONDARY)) -#define TLB_DEMAP_NUCLEUS (TLB_DEMAP_ID(TLB_DEMAP_ID_NUCLEUS)) - -#define TLB_CTX_KERNEL (0) -#define TLB_CTX_USER_MIN (1) -#define TLB_CTX_USER_MAX (8192) - -typedef void tlb_flush_user_t(void); - -struct pmap; -struct tlb_entry; - -extern int kernel_tlb_slots; -extern struct tlb_entry *kernel_tlbs; - -void tlb_context_demap(struct pmap *pm); -void tlb_page_demap(struct pmap *pm, vm_offset_t va); -void tlb_range_demap(struct pmap *pm, vm_offset_t start, vm_offset_t end); - -tlb_flush_user_t cheetah_tlb_flush_user; -tlb_flush_user_t spitfire_tlb_flush_user; - -extern tlb_flush_user_t *tlb_flush_user; - -#endif /* !_MACHINE_TLB_H_ */ diff --git a/sys/sun4v/include/trap.h b/sys/sun4v/include/trap.h deleted file mode 100644 index 8922a356b300..000000000000 --- a/sys/sun4v/include/trap.h +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TRAP_H_ -#define _MACHINE_TRAP_H_ - -#ifdef _KERNEL - -#define T_RESERVED 0 -#define T_INSTRUCTION_EXCEPTION 1 -#define T_INSTRUCTION_ERROR 2 -#define T_INSTRUCTION_PROTECTION 3 -#define T_ILLTRAP_INSTRUCTION 4 -#define T_ILLEGAL_INSTRUCTION 5 -#define T_PRIVILEGED_OPCODE 6 -#define T_FP_DISABLED 7 -#define T_FP_EXCEPTION_IEEE_754 8 -#define T_FP_EXCEPTION_OTHER 9 -#define T_TAG_OVERFLOW 10 -#define T_DIVISION_BY_ZERO 11 -#define T_DATA_EXCEPTION 12 -#define T_DATA_ERROR 13 -#define T_DATA_PROTECTION 14 -#define T_MEM_ADDRESS_NOT_ALIGNED 15 -#define T_ALIGNMENT 15 -#define T_PRIVILEGED_ACTION 16 -#define T_ASYNC_DATA_ERROR 17 -#define T_TRAP_INSTRUCTION_16 18 -#define T_TRAP_INSTRUCTION_17 19 -#define T_TRAP_INSTRUCTION_18 20 -#define T_TRAP_INSTRUCTION_19 21 -#define T_TRAP_INSTRUCTION_20 22 -#define T_TRAP_INSTRUCTION_21 23 -#define T_TRAP_INSTRUCTION_22 24 -#define T_TRAP_INSTRUCTION_23 25 -#define T_TRAP_INSTRUCTION_24 26 -#define T_TRAP_INSTRUCTION_25 27 -#define T_TRAP_INSTRUCTION_26 28 -#define T_TRAP_INSTRUCTION_27 29 -#define T_TRAP_INSTRUCTION_28 30 -#define T_TRAP_INSTRUCTION_29 31 -#define T_TRAP_INSTRUCTION_30 32 -#define T_TRAP_INSTRUCTION_31 33 -#define T_INSTRUCTION_MISS 34 -#define T_DATA_MISS 35 - -#define T_INTERRUPT 36 -#define T_PA_WATCHPOINT 37 -#define T_VA_WATCHPOINT 38 -#define T_CORRECTED_ECC_ERROR 39 -#define T_SPILL 40 -#define T_FILL 41 -#define T_FILL_RET 42 -#define T_BREAKPOINT 43 -#define T_CLEAN_WINDOW 44 -#define T_RANGE_CHECK 45 -#define T_FIX_ALIGNMENT 46 -#define T_INTEGER_OVERFLOW 47 -#define T_SYSCALL 48 -#define T_RSTRWP_PHYS 49 -#define T_RSTRWP_VIRT 50 -#define T_KSTACK_FAULT 51 -#define T_RESUMABLE_ERROR 52 -#define T_NONRESUMABLE_ERROR 53 - -#define T_MAX (T_NONRESUMABLE_ERROR + 1) - -#define T_KERNEL 64 - -#define TRAP_MASK ((1<<6)-1) -#define TRAP_CTX_SHIFT 8 -/* - * These defines are used by the TL1 tlb miss handlers to calculate - * the pc to jump to in the case the entry was not found in the TSB. - */ - -#define WTRAP_ALIGN 0x7f /* window handlers are 128 byte align */ -#define WTRAP_FAULTOFF 124 /* last instruction in handler */ - -/* use the following defines to determine if trap was a fill or a spill */ -#define WTRAP_TTMASK 0x180 -#define WTRAP_TYPE 0x080 - -#define TT_INSTRUCTION_EXCEPTION 0x8 -#define TT_INSTRUCTION_MISS 0x9 -#define TT_ILLEGAL_INSTRUCTION 0x10 -#define TT_PRIVILEGED_OPCODE 0x11 -#define TT_FP_EXCEPTION_IEEE_754 0x21 -#define TT_FP_EXCEPTION_OTHER 0x22 -#define TT_TAG_OVERFLOW 0x23 -#define TT_DIVISION_BY_ZERO 0x28 -#define TT_DATA_EXCEPTION 0x30 -#define TT_DATA_MISS 0x31 -#define TT_ALIGNNMENT 0x34 -#define TT_DATA_PROTECTION 0x6c -#define TT_ALIGNMENT 0x6c -#define TT_BREAKPOINT 0x76 - -#define PTL1_BAD_DEBUG 0 -#define PTL1_BAD_WTRAP 1 -#define PTL1_BAD_KMISS 2 -#define PTL1_BAD_KPROT_FAULT 3 -#define PTL1_BAD_ISM 4 -#define PTL1_BAD_MMUTRAP 5 -#define PTL1_BAD_TRAP 6 -#define PTL1_BAD_NOT_WTRAP 7 -#if 0 -#define PTL1_BAD_FPTRAP 7 -#endif -#define PTL1_BAD_INTR_REQ 8 -#define PTL1_BAD_TRACE_PTR 9 - -#define PTL1_BAD_STACK 10 -#define PTL1_BAD_DTRACE_FLAGS 11 -#define PTL1_BAD_CTX_STEAL 12 -#define PTL1_BAD_ECC 13 -#define PTL1_BAD_HCALL 14 -#define PTL1_BAD_GL 15 - - -#ifndef LOCORE -extern const char *const trap_msg[]; -extern void set_mmfsa_traptable(void *, uint64_t); -extern void trap_init(void); -#endif - -#endif - -#endif /* !_MACHINE_TRAP_H_ */ diff --git a/sys/sun4v/include/tsb.h b/sys/sun4v/include/tsb.h deleted file mode 100644 index 30fa1f873a64..000000000000 --- a/sys/sun4v/include/tsb.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TSB_H_ -#define _MACHINE_TSB_H_ - -#define MAX_TSB_INFO 2 - -/* - * Values for "tsb_ttesz_mask" bitmask. - */ -#define TSB8K (1 << TTE8K) -#define TSB64K (1 << TTE64K) -#define TSB512K (1 << TTE512K) -#define TSB4M (1 << TTE4M) -#define TSB32M (1 << TTE32M) -#define TSB256M (1 << TTE256M) - -/* - * Kernel TSBs - */ -#define TSB8K_INDEX 0 -#define TSB4M_INDEX 1 - -extern hv_tsb_info_t kernel_td[MAX_TSB_INFO]; - -struct hv_tsb_info; - - -void tsb_init(struct hv_tsb_info *tsb, uint64_t *scratchval, uint64_t page_shift); - -void tsb_deinit(struct hv_tsb_info *tsb); - -void tsb_assert_invalid(struct hv_tsb_info *tsb, vm_offset_t va); - -void tsb_set_tte(struct hv_tsb_info *tsb, vm_offset_t va, tte_t tte_data, uint64_t ctx); - -void tsb_set_tte_real(struct hv_tsb_info *tsb, vm_offset_t index_va, - vm_offset_t tag_va, tte_t tte_data, uint64_t ctx); - -tte_t tsb_get_tte(struct hv_tsb_info *tsb, vm_offset_t va); - -tte_t tsb_lookup_tte(vm_offset_t va, uint64_t context); - -void tsb_clear(struct hv_tsb_info *tsb); - -void tsb_clear_tte(struct hv_tsb_info *tsb, vm_offset_t va); - -void tsb_clear_range(struct hv_tsb_info *tsb, vm_offset_t sva, vm_offset_t eva); - -uint64_t tsb_set_scratchpad_kernel(struct hv_tsb_info *tsb); - -uint64_t tsb_set_scratchpad_user(struct hv_tsb_info *tsb); - -int tsb_size(struct hv_tsb_info *tsb); - -int tsb_page_shift(pmap_t pmap); - -#endif /* !_MACHINE_TSB_H_ */ diff --git a/sys/sun4v/include/tstate.h b/sys/sun4v/include/tstate.h deleted file mode 100644 index 8bb5b2417727..000000000000 --- a/sys/sun4v/include/tstate.h +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TSTATE_H_ -#define _MACHINE_TSTATE_H_ - -#include -#include - -#define TSTATE_CWP_SHIFT 0 -#define TSTATE_CWP_BITS 5 -#define TSTATE_CWP_MASK \ - (((1 << TSTATE_CWP_BITS) - 1) << TSTATE_CWP_SHIFT) -#define TSTATE_CWP(x) ((x & TSTATE_CWP_MASK) >> TSTATE_CWP_SHIFT) - -#define TSTATE_PSTATE_SHIFT 8 -#define TSTATE_PSTATE_BITS 12 -#define TSTATE_PSTATE_MASK \ - (((1 << TSTATE_PSTATE_BITS) - 1) << TSTATE_PSTATE_SHIFT) -#define TSTATE_PSTATE(x) ((x) << TSTATE_PSTATE_SHIFT) -#define TSTATE_AG TSTATE_PSTATE(PSTATE_AG) -#define TSTATE_IE TSTATE_PSTATE(PSTATE_IE) -#define TSTATE_PRIV TSTATE_PSTATE(PSTATE_PRIV) -#define TSTATE_AM TSTATE_PSTATE(PSTATE_AM) -#define TSTATE_PEF TSTATE_PSTATE(PSTATE_PEF) -#define TSTATE_RED TSTATE_PSTATE(PSTATE_RED) -#define TSTATE_MM_TSO TSTATE_PSTATE(PSTATE_MM_TSO) -#define TSTATE_MM_PSO TSTATE_PSTATE(PSTATE_MM_PSO) -#define TSTATE_MM_RMO TSTATE_PSTATE(PSTATE_MM_RMO) -#define TSTATE_TLE TSTATE_PSTATE(PSTATE_TLE) -#define TSTATE_CLE TSTATE_PSTATE(PSTATE_CLE) -#define TSTATE_MG TSTATE_PSTATE(PSTATE_MG) -#define TSTATE_IG TSTATE_PSTATE(PSTATE_IG) -#define TSTATE_KERNEL TSTATE_PSTATE(PSTATE_KERNEL) - - -#define TSTATE_ASI_SHIFT 24 -#define TSTATE_ASI_BITS 8 -#define TSTATE_ASI_MASK \ - (((1 << TSTATE_ASI_BITS) - 1) << TSTATE_ASI_SHIFT) -#define TSTATE_ASI(x) ((x & TSTATE_ASI_MASK) >> TSTATE_ASI_SHIFT) - -#define TSTATE_CCR_SHIFT 32 -#define TSTATE_ICC_SHIFT (TSTATE_CCR_SHIFT + ICC_SHIFT) -#define TSTATE_ICC_MASK (ICC_MASK << TSTATE_CCR_SHIFT) -#define TSTATE_XCC_SHIFT (TSTATE_CCR_SHIFT + XCC_SHIFT) -#define TSTATE_XCC_MASK (XCC_MASK << TSTATE_CCR_SHIFT) -#define TSTATE_CCR(x) ((x) << TSTATE_CCR_SHIFT) -#define TSTATE_ICC_C TSTATE_CCR(ICC_C) -#define TSTATE_ICC_V TSTATE_CCR(ICC_V) -#define TSTATE_ICC_Z TSTATE_CCR(ICC_Z) -#define TSTATE_ICC_N TSTATE_CCR(ICC_N) -#define TSTATE_XCC_C TSTATE_CCR(XCC_C) -#define TSTATE_XCC_V TSTATE_CCR(XCC_V) -#define TSTATE_XCC_Z TSTATE_CCR(XCC_Z) -#define TSTATE_XCC_N TSTATE_CCR(XCC_N) - -#define TSTATE_SECURE(tstate) \ - PSTATE_SECURE(((tstate) >> TSTATE_PSTATE_SHIFT) & ((1 << TSTATE_PSTATE_BITS) - 1)) - -#endif /* !_MACHINE_TSTATE_H_ */ diff --git a/sys/sun4v/include/tte.h b/sys/sun4v/include/tte.h deleted file mode 100644 index 9b190275d7f5..000000000000 --- a/sys/sun4v/include/tte.h +++ /dev/null @@ -1,258 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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: BSDI: pmap.v9.h,v 1.10.2.6 1999/08/23 22:18:44 cp Exp - * $FreeBSD$ - */ - -#ifndef _MACHINE_TTE_H_ -#define _MACHINE_TTE_H_ - -#define TTE_SHIFT (4) - -#define TD_SOFT2_SHIFT (50) -#define TD_DIAG_SHIFT (41) -#define TD_PA_SHIFT (13) -#define TD_SOFT_SHIFT (7) - -#define TD_SOFT2_BITS (9) -#define TD_DIAG_BITS (9) -#define TD_PA_CH_BITS (30) -#define TD_PA_SF_BITS (28) -#define TD_PA_BITS (42) -#define TD_SOFT_BITS (6) - -#define TD_SOFT2_MASK ((1UL << TD_SOFT2_BITS) - 1) -#define TD_DIAG_MASK ((1UL << TD_DIAG_BITS) - 1) -#define TD_PA_CH_MASK ((1UL << TD_PA_CH_BITS) - 1) -#define TD_PA_SF_MASK ((1UL << TD_PA_SF_BITS) - 1) -#define TD_PA_MASK ((1UL << TD_PA_BITS) - 1) -#define TD_SOFT_MASK ((1UL << TD_SOFT_BITS) - 1) - -#define TTE8K (0UL) -#define TTE64K (1UL) -#define TTE512K (2UL) -#define TTE4M (3UL) -#define TTE32M (4UL) -#define TTE256M (5UL) -#define TTE2G (6UL) -#define TTE16G (7UL) - -#define TD_PA(pa) ((pa) & (TD_PA_MASK << TD_PA_SHIFT)) -/* NOTE: bit 6 of TD_SOFT will be sign-extended if used as an immediate. */ -#define TD_FAKE ((1UL << 5) << TD_SOFT_SHIFT) -#define TD_EXEC ((1UL << 4) << TD_SOFT_SHIFT) -#define TD_REF ((1UL << 3) << TD_SOFT_SHIFT) -#define TD_PV ((1UL << 2) << TD_SOFT_SHIFT) -#define TD_SW ((1UL << 1) << TD_SOFT_SHIFT) -#define TD_WIRED ((1UL << 0) << TD_SOFT_SHIFT) -#define TD_L (1UL << 6) -#define TD_CP (1UL << 5) -#define TD_CV (1UL << 4) -#define TD_E (1UL << 3) -#define TD_P (1UL << 2) -#define TD_W (1UL << 1) -#define TD_G (1UL << 0) - - -#define TTE_GET_PAGE_SIZE(tp) \ - (1 << TTE_GET_PAGE_SHIFT(tp)) -#define TTE_GET_PAGE_MASK(tp) \ - (TTE_GET_PAGE_SIZE(tp) - 1) - -#define TTE_GET_PA(tte_data) \ - (tte_data & (TD_PA_MASK << TD_PA_SHIFT)) -#define TTE_GET_VPN(tp) \ - ((tp)->tte_vpn >> TV_SIZE_BITS) -#define TTE_GET_VA(tp) \ - (TTE_GET_VPN(tp) << TTE_GET_PAGE_SHIFT(tp)) -#define TTE_GET_PMAP(tp) \ - (((tp)->tte_data & TD_P) != 0 ? \ - (kernel_pmap) : \ - (PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)(tp)))->md.pmap)) -#define TTE_ZERO(tp) \ - memset(tp, 0, sizeof(*tp)) - -struct pmap; -#define PTE_SHIFT (3) -#define PT_SHIFT (PAGE_SHIFT - PTE_SHIFT) - -#define VTD_SOFT_SHIFT (56) - -#define VTD_V (1UL << 63) -#define VTD_NFO (1UL << 62) -#define VTD_PA(pa) ((pa) & (TD_PA_MASK << TD_PA_SHIFT)) -#define VTD_IE (1UL << 12) -#define VTD_E (1UL << 11) -#define VTD_CP (1UL << 10) -#define VTD_CV (1UL << 9) -#define VTD_P (1UL << 8) -#define VTD_X (1UL << 7) -#define VTD_W (1UL << 6) - -#define VTD_REF (1UL << 5) -#define VTD_SW_W (1UL << 4) -#define VTD_MANAGED (1UL << 58) -#define VTD_WIRED (1UL << 57) -#define VTD_LOCK (1UL << 56) - - - -#define VTD_8K TTE8K -#define VTD_64K TTE64K -#define VTD_512K TTE512K -#define VTD_4M TTE4M -#define VTD_32M TTE32M -#define VTD_256M TTE256M - - -/* - * sparc64 compatibility for the loader - */ - -#define TD_SIZE_SHIFT (61) -#define TS_4M (3UL) - -#define TD_V (1UL << 63) -#define TD_4M (TS_4M << TD_SIZE_SHIFT) - -/* - * default flags for kernel pages - */ -#define TTE_KERNEL VTD_V | VTD_CP | VTD_CV | VTD_P | VTD_X | VTD_W | VTD_SW_W | VTD_REF | VTD_WIRED -#define TTE_KERNEL_MINFLAGS VTD_P -#define TTE_MINFLAGS VTD_V | VTD_CP | VTD_CV - -#define VTD_SIZE_BITS (4) -#define VTD_SIZE_MASK ((1 << VTD_SIZE_BITS) - 1) - - -#define TTE_SIZE_SPREAD (3) -#define TTE_PAGE_SHIFT(sz) \ - (PAGE_SHIFT + ((sz) * TTE_SIZE_SPREAD)) -#define TTE_GET_SIZE(tte_data) \ - (tte_data & VTD_SIZE_MASK) -#define TTE_GET_PAGE_SHIFT(tte_data) \ - TTE_PAGE_SHIFT(TTE_GET_SIZE(tte_data)) - -#ifdef notyet -typedef union { - struct tte { - unsigned int v:1; /* <63> valid */ - unsigned int nfo:1; /* <62> non-fault only */ - unsigned int sw:3; /* <61:59> sw */ - unsigned int managed:1; /* <58> managed */ - unsigned int wired:1; /* <57> wired */ - unsigned int lock:1; /* <56> sw - locked */ - unsigned long pa:43; /* <55:13> pa */ - unsigned int ie:1; /* <12> 1=invert endianness */ - unsigned int e:1; /* <11> side effect */ - unsigned int cp:1; /* <10> physically cache */ - unsigned int cv:1; /* <9> virtually cache */ - unsigned int p:1; /* <8> privilege required */ - unsigned int x:1; /* <7> execute perm */ - unsigned int w:1; /* <6> write perm */ - unsigned int ref:1; /* <5> sw - ref */ - unsigned int wr_perm:1; /* <4> sw - write perm */ - unsigned int rsvd:1; /* <3> reserved */ - unsigned int sz:3; /* <2:0> pagesize */ - } tte_bit; - uint64_t ll; -} tte_t; -#endif - -#define tte_val tte_bit.v /* use < 0 check in asm */ -#define tte_size tte_bit.sz -#define tte_nfo tte_bit.nfo -#define tte_ie tte_bit.ie -#define tte_wired tte_bit.wired -#define tte_pa tte_bit.pa -#define tte_ref tte_bit.ref -#define tte_wr_perm tte_bit.wr_perm -#define tte_exec_perm tte_bit.x -#define tte_lock tte_bit.lock -#define tte_cp tte_bit.cp -#define tte_cv tte_bit.cv -#define tte_se tte_bit.e -#define tte_priv tte_bit.p -#define tte_hwwr tte_bit.w - -#define TTE_IS_VALID(ttep) ((ttep)->tte_inthi < 0) -#define TTE_SET_INVALID(ttep) ((ttep)->tte_val = 0) -#define TTE_IS_8K(ttep) (TTE_CSZ(ttep) == TTE8K) -#define TTE_IS_WIRED(ttep) ((ttep)->tte_wired) -#define TTE_IS_WRITABLE(ttep) ((ttep)->tte_wr_perm) -#define TTE_IS_EXECUTABLE(ttep) ((ttep)->tte_exec_perm) -#define TTE_IS_PRIVILEGED(ttep) ((ttep)->tte_priv) -#define TTE_IS_NOSYNC(ttep) ((ttep)->tte_no_sync) -#define TTE_IS_LOCKED(ttep) ((ttep)->tte_lock) -#define TTE_IS_SIDEFFECT(ttep) ((ttep)->tte_se) -#define TTE_IS_NFO(ttep) ((ttep)->tte_nfo) - -#define TTE_IS_REF(ttep) ((ttep)->tte_ref) -#define TTE_IS_MOD(ttep) ((ttep)->tte_hwwr) -#define TTE_IS_IE(ttep) ((ttep)->tte_ie) -#define TTE_SET_SUSPEND(ttep) ((ttep)->tte_suspend = 1) -#define TTE_CLR_SUSPEND(ttep) ((ttep)->tte_suspend = 0) -#define TTE_IS_SUSPEND(ttep) ((ttep)->tte_suspend) -#define TTE_SET_REF(ttep) ((ttep)->tte_ref = 1) -#define TTE_CLR_REF(ttep) ((ttep)->tte_ref = 0) -#define TTE_SET_LOCKED(ttep) ((ttep)->tte_lock = 1) -#define TTE_CLR_LOCKED(ttep) ((ttep)->tte_lock = 0) -#define TTE_SET_MOD(ttep) ((ttep)->tte_hwwr = 1) -#define TTE_CLR_MOD(ttep) ((ttep)->tte_hwwr = 0) -#define TTE_SET_RM(ttep) \ - (((ttep)->tte_intlo) = \ - (ttep)->tte_intlo | TTE_HWWR_INT | TTE_REF_INT) -#define TTE_CLR_RM(ttep) \ - (((ttep)->tte_intlo) = \ - (ttep)->tte_intlo & ~(TTE_HWWR_INT | TTE_REF_INT)) - -#define TTE_SET_WRT(ttep) ((ttep)->tte_wr_perm = 1) -#define TTE_CLR_WRT(ttep) ((ttep)->tte_wr_perm = 0) -#define TTE_SET_EXEC(ttep) ((ttep)->tte_exec_perm = 1) -#define TTE_CLR_EXEC(ttep) ((ttep)->tte_exec_perm = 0) -#define TTE_SET_PRIV(ttep) ((ttep)->tte_priv = 1) -#define TTE_CLR_PRIV(ttep) ((ttep)->tte_priv = 0) - -#define TTE_BSZS_SHIFT(sz) ((sz) * 3) - -struct pmap; - -void tte_clear_phys_bit(vm_page_t m, uint64_t flags); - -void tte_set_phys_bit(vm_page_t m, uint64_t flags); - -boolean_t tte_get_phys_bit(vm_page_t m, uint64_t flags); - -void tte_clear_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags); - -void tte_set_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags); - -boolean_t tte_get_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags); - -#endif /* !_MACHINE_TTE_H_ */ diff --git a/sys/sun4v/include/tte_hash.h b/sys/sun4v/include/tte_hash.h deleted file mode 100644 index 82f620df6e3b..000000000000 --- a/sys/sun4v/include/tte_hash.h +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_TTE_HASH_H_ -#define _MACHINE_TTE_HASH_H_ - -#define HASH_ENTRY_SHIFT 2 -#define HASH_ENTRIES ((1 << HASH_ENTRY_SHIFT) - 1) -#define THE_SHIFT (TTE_SHIFT + HASH_ENTRY_SHIFT) /* size of TSB entry * #entries */ -#define TH_COLLISION_SHIFT 47 /* bit 47 will never be set for a valid tag */ -#define TH_COLLISION (1UL << TH_COLLISION_SHIFT) -#define TH_INVALID_SHIFT 46 /* bit 47 will never be set for a valid tag */ -#define TH_INVALID (1UL << TH_INVALID_SHIFT) - - -struct tte_hash; -typedef struct tte_hash *tte_hash_t; - -void tte_hash_init(void); - -void tte_hash_clear(tte_hash_t hash); - -tte_t tte_hash_clear_bits(tte_hash_t hash, vm_offset_t va, uint64_t flags); - -tte_hash_t tte_hash_kernel_create(vm_offset_t, uint16_t, vm_paddr_t); - -tte_hash_t tte_hash_create(uint64_t context, uint64_t *scratchval); - -void tte_hash_destroy(tte_hash_t th); - -tte_t tte_hash_delete(tte_hash_t hash, vm_offset_t va); - -void tte_hash_delete_all(tte_hash_t hash); - -void tte_hash_insert(tte_hash_t hash, vm_offset_t va, tte_t data); - -tte_t tte_hash_lookup(tte_hash_t hash, vm_offset_t va); - -tte_t tte_hash_lookup_nolock(tte_hash_t hash, vm_offset_t va); - -tte_hash_t tte_hash_reset(tte_hash_t hash, uint64_t *scratchval); - -uint64_t tte_hash_set_scratchpad_kernel(tte_hash_t th); - -uint64_t tte_hash_set_scratchpad_user(tte_hash_t th, uint64_t context); - -tte_t tte_hash_update(tte_hash_t hash, vm_offset_t va, tte_t tte_data); - -int tte_hash_needs_resize(tte_hash_t th); - -tte_hash_t tte_hash_resize(tte_hash_t th); - -#endif /* _MACHINE_TTE_HASH_H_ */ diff --git a/sys/sun4v/include/ucontext.h b/sys/sun4v/include/ucontext.h deleted file mode 100644 index c05ec26a9053..000000000000 --- a/sys/sun4v/include/ucontext.h +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 1999 Marcel Moolenaar - * 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 - * in this position and unchanged. - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: FreeBSD: src/sys/alpha/include/ucontext.h,v 1.3 1999/10/08 - * $FreeBSD$ - */ - -#ifndef _MACHINE_UCONTEXT_H_ -#define _MACHINE_UCONTEXT_H_ - -struct __mcontext { - uint64_t mc_global[8]; - uint64_t mc_out[8]; - uint64_t mc_local[8]; - uint64_t mc_in[8]; - uint32_t mc_fp[64]; -} __aligned(64); - -typedef struct __mcontext mcontext_t; - -#define mc_flags mc_global[0] -#define mc_sp mc_out[6] -#define mc_fprs mc_local[0] -#define mc_fsr mc_local[1] -#define mc_gsr mc_local[2] -#define mc_tnpc mc_in[0] -#define mc_tpc mc_in[1] -#define mc_tstate mc_in[2] -#define mc_y mc_in[4] -#define mc_wstate mc_in[5] - -#define _MC_VERSION_SHIFT 0 -#define _MC_VERSION_BITS 32 -#define _MC_VERSION 1L - -#define _MC_FLAGS_SHIFT 32 -#define _MC_FLAGS_BITS 32 -#define _MC_VOLUNTARY ((1L << 0) << _MC_FLAGS_SHIFT) - -#endif /* !_MACHINE_UCONTEXT_H_ */ diff --git a/sys/sun4v/include/upa.h b/sys/sun4v/include/upa.h deleted file mode 100644 index 70bf34d3353d..000000000000 --- a/sys/sun4v/include/upa.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/utrap.h b/sys/sun4v/include/utrap.h deleted file mode 100644 index 45019c8ca9ee..000000000000 --- a/sys/sun4v/include/utrap.h +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_UTRAP_H_ -#define _MACHINE_UTRAP_H_ - -#define UT_INSTRUCTION_EXCEPTION 1 -#define UT_INSTRUCTION_ERROR 2 -#define UT_INSTRUCTION_PROTECTION 3 -#define UT_ILLTRAP_INSTRUCTION 4 -#define UT_ILLEGAL_INSTRUCTION 5 -#define UT_PRIVILEGED_OPCODE 6 -#define UT_FP_DISABLED 7 -#define UT_FP_EXCEPTION_IEEE_754 8 -#define UT_FP_EXCEPTION_OTHER 9 -#define UT_TAG_OVERFLOW 10 -#define UT_DIVISION_BY_ZERO 11 -#define UT_DATA_EXCEPTION 12 -#define UT_DATA_ERROR 13 -#define UT_DATA_PROTECTION 14 -#define UT_MEM_ADDRESS_NOT_ALIGNED 15 -#define UT_PRIVILEGED_ACTION 16 -#define UT_ASYNC_DATA_ERROR 17 -#define UT_TRAP_INSTRUCTION_16 18 -#define UT_TRAP_INSTRUCTION_17 19 -#define UT_TRAP_INSTRUCTION_18 20 -#define UT_TRAP_INSTRUCTION_19 21 -#define UT_TRAP_INSTRUCTION_20 22 -#define UT_TRAP_INSTRUCTION_21 23 -#define UT_TRAP_INSTRUCTION_22 24 -#define UT_TRAP_INSTRUCTION_23 25 -#define UT_TRAP_INSTRUCTION_24 26 -#define UT_TRAP_INSTRUCTION_25 27 -#define UT_TRAP_INSTRUCTION_26 28 -#define UT_TRAP_INSTRUCTION_27 29 -#define UT_TRAP_INSTRUCTION_28 30 -#define UT_TRAP_INSTRUCTION_29 31 -#define UT_TRAP_INSTRUCTION_30 32 -#define UT_TRAP_INSTRUCTION_31 33 -#define UT_INSTRUCTION_MISS 34 -#define UT_DATA_MISS 35 -#define UT_MAX 36 - -#define ST_SUNOS_SYSCALL 0 -#define ST_BREAKPOINT 1 -#define ST_DIVISION_BY_ZERO 2 -#define ST_FLUSH_WINDOWS 3 /* XXX implement! */ -#define ST_CLEAN_WINDOW 4 -#define ST_RANGE_CHECK 5 -#define ST_FIX_ALIGNMENT 6 -#define ST_INTEGER_OVERFLOW 7 -/* 8 is 32-bit ABI syscall (old solaris syscall?) */ -#define ST_BSD_SYSCALL 9 -#define ST_FP_RESTORE 10 -#define ST_FPEMU_CONTEXT 11 -/* 11-15 are available */ -/* 16 is linux 32 bit syscall (but supposed to be reserved, grr) */ -/* 17 is old linux 64 bit syscall (but supposed to be reserved, grr) */ -/* 16-31 are reserved for user applications (utraps) */ -#define ST_GETCC 32 /* XXX implement! */ -#define ST_SETCC 33 /* XXX implement! */ -#define ST_GETPSR 34 /* XXX implement! */ -#define ST_SETPSR 35 /* XXX implement! */ -/* 36-63 are available */ -#define ST_SOLARIS_SYSCALL 64 -#define ST_SYSCALL 65 -#define ST_SYSCALL32 66 -/* 67 is reserved to OS source licensee */ -/* 68 is return from deferred trap (not supported) */ -/* 69-95 are reserved to SPARC international */ -/* 96-108 are available */ -/* 109 is linux 64 bit syscall */ -/* 110 is linux 64 bit getcontext (?) */ -/* 111 is linux 64 bit setcontext (?) */ -/* 112-255 are available */ - -#define UTH_NOCHANGE (-1) - -#ifndef __ASM__ - -typedef int utrap_entry_t; -typedef void *utrap_handler_t; - -#endif - -#endif diff --git a/sys/sun4v/include/varargs.h b/sys/sun4v/include/varargs.h deleted file mode 100644 index bb58ce87f997..000000000000 --- a/sys/sun4v/include/varargs.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2002 David E. O'Brien. All rights reserved. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)varargs.h 8.3 (Berkeley) 3/22/94 - * $FreeBSD$ - */ - -#ifndef _MACHINE_VARARGS_H_ -#define _MACHINE_VARARGS_H_ - -#ifndef _SYS_CDEFS_H_ -#error this file needs sys/cdefs.h as a prerequisite -#endif - -#ifdef __GNUCLIKE_BUILTIN_VARARGS - -#include - -#ifndef _VA_LIST_DECLARED -#define _VA_LIST_DECLARED -typedef __va_list va_list; -#endif - -typedef int __builtin_va_alist_t __attribute__((__mode__(__word__))); - -#define va_alist __builtin_va_alist -#define va_dcl __builtin_va_alist_t __builtin_va_alist; ... -#define va_start(ap) __builtin_varargs_start(ap) -#define va_arg(ap, type) __builtin_va_arg((ap), type) -#define va_end(ap) __builtin_va_end(ap) - -#else /* !__GNUCLIKE_BUILTIN_VARARGS */ - -#include - -#define __va_ellipsis ... - -#define va_alist __builtin_va_alist -#define va_dcl long __builtin_va_alist; __va_ellipsis - -#undef va_start -#define va_start(ap) \ - ((ap) = (va_list)__builtin_saveregs()) - -#endif /* __GNUCLIKE_BUILTIN_VARARGS */ - -#endif /* !_MACHINE_VARARGS_H_ */ diff --git a/sys/sun4v/include/ver.h b/sys/sun4v/include/ver.h deleted file mode 100644 index d752cc702250..000000000000 --- a/sys/sun4v/include/ver.h +++ /dev/null @@ -1,7 +0,0 @@ -/*- - * This file is in the public domain. - * - * $FreeBSD$ - */ - -#include diff --git a/sys/sun4v/include/vm.h b/sys/sun4v/include/vm.h deleted file mode 100644 index 7ec2d9e692a9..000000000000 --- a/sys/sun4v/include/vm.h +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * Copyright (c) 2009 Alan L. Cox - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_VM_H_ -#define _MACHINE_VM_H_ - -/* Memory attribute configuration is not (yet) implemented. */ -#define VM_MEMATTR_DEFAULT 0 - -#endif /* !_MACHINE_VM_H_ */ diff --git a/sys/sun4v/include/vmparam.h b/sys/sun4v/include/vmparam.h deleted file mode 100644 index 5195f1d57d89..000000000000 --- a/sys/sun4v/include/vmparam.h +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * Copyright (c) 1994 John S. Dyson - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 - * from: FreeBSD: src/sys/i386/include/vmparam.h,v 1.33 2000/03/30 - * $FreeBSD$ - */ - -#ifndef _MACHINE_VMPARAM_H_ -#define _MACHINE_VMPARAM_H_ - -/* - * Virtual memory related constants, all in bytes - */ -#ifndef MAXTSIZ -#define MAXTSIZ (1*1024*1024*1024) /* max text size */ -#endif -#ifndef DFLDSIZ -#define DFLDSIZ (128*1024*1024) /* initial data size limit */ -#endif -#ifndef MAXDSIZ -#define MAXDSIZ (1*1024*1024*1024) /* max data size */ -#endif -#ifndef DFLSSIZ -#define DFLSSIZ (128*1024*1024) /* initial stack size limit */ -#endif -#ifndef MAXSSIZ -#define MAXSSIZ (1*1024*1024*1024) /* max stack size */ -#endif -#ifndef SGROWSIZ -#define SGROWSIZ (128*1024) /* amount to grow stack */ -#endif - -/* - * The physical address space is densely populated. - */ -#define VM_PHYSSEG_DENSE - -/* - * The number of PHYSSEG entries must be one greater than the number - * of phys_avail entries because the phys_avail entry that spans the - * largest physical address that is accessible by ISA DMA is split - * into two PHYSSEG entries. - */ -#define VM_PHYSSEG_MAX 64 - -/* - * Create three free page pools: VM_FREEPOOL_DEFAULT is the default pool - * from which physical pages are allocated and VM_FREEPOOL_DIRECT is - * the pool from which physical pages for small UMA objects are - * allocated. - */ -#define VM_NFREEPOOL 3 -#define VM_FREEPOOL_CACHE 2 -#define VM_FREEPOOL_DEFAULT 0 -#define VM_FREEPOOL_DIRECT 1 - -/* - * Create two free page lists: VM_FREELIST_DEFAULT is for physical - * pages that are above the largest physical address that is - * accessible by ISA DMA and VM_FREELIST_ISADMA is for physical pages - * that are below that address. - */ -#define VM_NFREELIST 2 -#define VM_FREELIST_DEFAULT 0 -#define VM_FREELIST_ISADMA 1 - -/* - * An allocation size of 16MB is supported in order to optimize the - * use of the direct map by UMA. Specifically, a cache line contains - * at most four TTEs, collectively mapping 16MB of physical memory. - * By reducing the number of distinct 16MB "pages" that are used by UMA, - * the physical memory allocator reduces the likelihood of both 4MB - * page TLB misses and cache misses caused by 4MB page TLB misses. - */ -#define VM_NFREEORDER 12 - -/* - * Only one memory domain. - */ -#ifndef VM_NDOMAIN -#define VM_NDOMAIN 1 -#endif - -/* - * Disable superpage reservations. - */ -#ifndef VM_NRESERVLEVEL -#define VM_NRESERVLEVEL 0 -#endif - -/* - * Address space layout. - * - * UltraSPARC I and II implement a 44 bit virtual address space. The address - * space is split into 2 regions at each end of the 64 bit address space, with - * an out of range "hole" in the middle. UltraSPARC III implements the full - * 64 bit virtual address space, but we don't really have any use for it and - * 43 bits of user address space is considered to be "enough", so we ignore it. - * - * Upper region: 0xffffffffffffffff - * 0xfffff80000000000 - * - * Hole: 0xfffff7ffffffffff - * 0x0000080000000000 - * - * Lower region: 0x000007ffffffffff - * 0x0000000000000000 - * - * In general we ignore the upper region, and use the lower region as mappable - * space. - * - * We define some interesting address constants: - * - * VM_MIN_ADDRESS and VM_MAX_ADDRESS define the start and of the entire 64 bit - * address space, mostly just for convenience. - * - * VM_MIN_DIRECT_ADDRESS and VM_MAX_DIRECT_ADDRESS define the start and end - * of the direct mapped region. This maps virtual addresses to physical - * addresses directly using 4mb tlb entries, with the physical address encoded - * in the lower 43 bits of virtual address. These mappings are convenient - * because they do not require page tables, and because they never change they - * do not require tlb flushes. However, since these mappings are cacheable, - * we must ensure that all pages accessed this way are either not double - * mapped, or that all other mappings have virtual color equal to physical - * color, in order to avoid creating illegal aliases in the data cache. - * - * VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS define the start and end of - * mappable kernel virtual address space. VM_MIN_KERNEL_ADDRESS is basically - * arbitrary, a convenient address is chosen which allows both the kernel text - * and data and the prom's address space to be mapped with 1 4mb tsb page. - * VM_MAX_KERNEL_ADDRESS is variable, computed at startup time based on the - * amount of physical memory available. Each 4mb tsb page provides 1g of - * virtual address space, with the only practical limit being available - * phsyical memory. - * - * VM_MIN_PROM_ADDRESS and VM_MAX_PROM_ADDRESS define the start and end of the - * prom address space. On startup the prom's mappings are duplicated in the - * kernel tsb, to allow prom memory to be accessed normally by the kernel. - * - * VM_MIN_USER_ADDRESS and VM_MAX_USER_ADDRESS define the start and end of the - * user address space. There are some hardware errata about using addresses - * at the boundary of the va hole, so we allow just under 43 bits of user - * address space. Note that the kernel and user address spaces overlap, but - * this doesn't matter because they use different tlb contexts, and because - * the kernel address space is not mapped into each process' address space. - */ -#define VM_MIN_ADDRESS (0x0000000000000000UL) -#define VM_MAX_ADDRESS (0xffffffffffffffffUL) - -#define VM_MIN_DIRECT_ADDRESS (0xfffff80000000000UL) -#define VM_MAX_DIRECT_ADDRESS (VM_MAX_ADDRESS) - -#define VM_MIN_KERNEL_ADDRESS (0x00000000c0000000UL) -#define VM_MAX_KERNEL_ADDRESS (vm_max_kernel_address) - -#define VM_MIN_PROM_ADDRESS (0x00000000f0000000UL) -#define VM_MAX_PROM_ADDRESS (0x00000000ffffffffUL) - -#define VM_MIN_USER_ADDRESS (0x0000000000002000UL) -#define VM_MAX_USER_ADDRESS (0x000007fe00000000UL) - -#define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS) -#define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS) - -#define KERNBASE (VM_MIN_KERNEL_ADDRESS) -#define PROMBASE (VM_MIN_PROM_ADDRESS) -#define USRSTACK (VM_MAX_USER_ADDRESS) - -/* - * Virtual size (bytes) for various kernel submaps. - */ -#ifndef VM_KMEM_SIZE -#define VM_KMEM_SIZE (16*1024*1024) -#endif - -/* - * How many physical pages per KVA page allocated. - * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), - * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) - * is the total KVA space allocated for kmem_map. - */ -#ifndef VM_KMEM_SIZE_SCALE -#define VM_KMEM_SIZE_SCALE (3) -#endif - -/* - * Initial pagein size of beginning of executable file. - */ -#ifndef VM_INITIAL_PAGEIN -#define VM_INITIAL_PAGEIN 16 -#endif -#define UMA_MD_SMALL_ALLOC -extern vm_offset_t vm_max_kernel_address; - -#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */ - -#endif /* !_MACHINE_VMPARAM_H_ */ diff --git a/sys/sun4v/include/watch.h b/sys/sun4v/include/watch.h deleted file mode 100644 index bb658f9efb53..000000000000 --- a/sys/sun4v/include/watch.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright 2001 by Thomas Moestl . 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 ``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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_WATCH_H_ -#define _MACHINE_WATCH_H_ - -int watch_phys_set_mask(vm_paddr_t pa, u_long mask); -int watch_phys_set(vm_paddr_t pa, int sz); -vm_paddr_t watch_phys_get(int *bm); -void watch_phys_clear(void); -int watch_phys_active(void); -int watch_virt_set_mask(vm_offset_t va, u_long mask); -int watch_virt_set(vm_offset_t va, int sz); -vm_offset_t watch_virt_get(int *bm); -void watch_virt_clear(void); -int watch_virt_active(void); - -#endif /* _MACHINE_WATCH_H_ */ diff --git a/sys/sun4v/include/wstate.h b/sys/sun4v/include/wstate.h deleted file mode 100644 index 3d42bf9e326b..000000000000 --- a/sys/sun4v/include/wstate.h +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_WSTATE_H_ -#define _MACHINE_WSTATE_H_ - -/* - * Window State Register (WSTATE) - * - * |------------| - * |OTHER|NORMAL| - * |-----|------| - * 5 3 2 0 - */ - -#define WSTATE_BAD 0 /* unused */ -#define WSTATE_U32 1 /* 32b stack */ -#define WSTATE_U64 2 /* 64b stack */ -#define WSTATE_CLEAN32 3 /* cleanwin workaround, 32b stack */ -#define WSTATE_CLEAN64 4 /* cleanwin workaround, 64b stack */ -#define WSTATE_K32 5 /* priv 32b stack */ -#define WSTATE_K64 6 /* priv 64b stack */ -#define WSTATE_KMIX 7 /* priv mixed stack */ - -#define WSTATE_CLEAN_OFFSET 2 -#define WSTATE_SHIFT 3 /* normal-to-other shift */ -#define WSTATE_MASK 7 /* mask for each set */ -#define WSTATE(o, n) (((o) << WSTATE_SHIFT) | (n)) - -#define WSTATE_USER32 WSTATE(WSTATE_BAD, WSTATE_U32) -#define WSTATE_USER64 WSTATE(WSTATE_BAD, WSTATE_U64) -#define WSTATE_KERN WSTATE(WSTATE_U32, WSTATE_K64) - -#endif /* !_MACHINE_WSTATE_H_ */ diff --git a/sys/sun4v/mdesc/mdesc_bus_if.m b/sys/sun4v/mdesc/mdesc_bus_if.m deleted file mode 100644 index 9f5df3d95a89..000000000000 --- a/sys/sun4v/mdesc/mdesc_bus_if.m +++ /dev/null @@ -1,127 +0,0 @@ -#- -# Copyright (c) 2001, 2003 by Thomas Moestl -# Copyright (c) 2004, 2005 by Marius Strobl -# Copyright (c) 2006 by Kip Macy -# 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 ``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. -# -# $FreeBSD$ - -# Interface for retrieving the package handle and a subset, namely -# 'compatible', 'device_type', 'model' and 'name', of the standard -# properties of a device on an Open Firmware assisted bus for use -# in device drivers. The rest of the standard properties, 'address', -# 'interrupts', 'reg' and 'status', are not covered by this interface -# as they are expected to be only of interest in the respective bus -# driver. - -#include - -#include - -INTERFACE mdesc_bus; - -HEADER { - struct mdesc_bus_devinfo { - char *mbd_compat; - char *mbd_name; - char *mbd_type; - uint64_t mbd_handle; - }; -}; - -CODE { - static mdesc_bus_get_devinfo_t mdesc_bus_default_get_devinfo; - static mdesc_bus_get_compat_t mdesc_bus_default_get_compat; - static mdesc_bus_get_name_t mdesc_bus_default_get_name; - static mdesc_bus_get_type_t mdesc_bus_default_get_type; - - static const struct mdesc_bus_devinfo * - mdesc_bus_default_get_devinfo(device_t bus, device_t dev) - { - - return (NULL); - } - - static const char * - mdesc_bus_default_get_compat(device_t bus, device_t dev) - { - - return (NULL); - } - - static const char * - mdesc_bus_default_get_name(device_t bus, device_t dev) - { - - return (NULL); - } - - static const char * - mdesc_bus_default_get_type(device_t bus, device_t dev) - { - - return (NULL); - } - - static uint64_t - mdesc_bus_default_get_handle(device_t bus, device_t dev) - { - - return (0); - } -}; - -# Get the mdesc_bus_devinfo struct for the device dev on the bus. Used for bus -# drivers which use the generic methods in mdesc_bus_subr.c to implement the -# reset of this interface. The default method will return NULL, which means -# there is no such struct associated with the device. -METHOD const struct mdesc_bus_devinfo * get_devinfo { - device_t bus; - device_t dev; -} DEFAULT mdesc_bus_default_get_devinfo; - -# Get the alternate firmware name for the device dev on the bus. The default -# method will return NULL, which means the device doesn't have such a property. -METHOD const char * get_compat { - device_t bus; - device_t dev; -} DEFAULT mdesc_bus_default_get_compat; - -# Get the firmware name for the device dev on the bus. The default method will -# return NULL, which means the device doesn't have such a property. -METHOD const char * get_name { - device_t bus; - device_t dev; -} DEFAULT mdesc_bus_default_get_name; - -# Get the firmware device type for the device dev on the bus. The default -# method will return NULL, which means the device doesn't have such a property. -METHOD const char * get_type { - device_t bus; - device_t dev; -} DEFAULT mdesc_bus_default_get_type; - -METHOD uint64_t get_handle { - device_t bus; - device_t dev; -} DEFAULT mdesc_bus_default_get_handle; diff --git a/sys/sun4v/mdesc/mdesc_bus_subr.c b/sys/sun4v/mdesc/mdesc_bus_subr.c deleted file mode 100644 index 0399168a2a1c..000000000000 --- a/sys/sun4v/mdesc/mdesc_bus_subr.c +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "mdesc_bus_if.h" - -MALLOC_DEFINE(M_MDPROP, "mdesc", "machine description"); - -int -mdesc_bus_gen_setup_devinfo(struct mdesc_bus_devinfo *mbd, mde_cookie_t node) -{ - md_t *mdp; - - if (mbd == NULL) - return (ENOMEM); - - mdp = md_get(); - - /* The 'name' property is considered mandatory. */ - if ((md_get_prop_alloc(mdp, node, "name", MDET_PROP_STR, (uint8_t **)&mbd->mbd_name)) == -1) - return (EINVAL); - md_get_prop_alloc(mdp, node, "compatible", MDET_PROP_DAT, (uint8_t **)&mbd->mbd_compat); - md_get_prop_alloc(mdp, node, "device-type", MDET_PROP_STR, (uint8_t **)&mbd->mbd_type); - md_get_prop_val(mdp, node, "cfg-handle", &mbd->mbd_handle); - - md_put(mdp); - return (0); -} - -void -mdesc_bus_gen_destroy_devinfo(struct mdesc_bus_devinfo *mbd) -{ - - if (mbd == NULL) - return; - if (mbd->mbd_compat != NULL) - free(mbd->mbd_compat, M_MDPROP); - if (mbd->mbd_name != NULL) - free(mbd->mbd_name, M_MDPROP); - if (mbd->mbd_type != NULL) - free(mbd->mbd_type, M_MDPROP); -} - -const char * -mdesc_bus_gen_get_compat(device_t bus, device_t dev) -{ - const struct mdesc_bus_devinfo *mbd; - - mbd = MDESC_BUS_GET_DEVINFO(bus, dev); - if (mbd == NULL) - return (NULL); - return (mbd->mbd_compat); -} - -const char * -mdesc_bus_gen_get_name(device_t bus, device_t dev) -{ - const struct mdesc_bus_devinfo *mbd; - - mbd = MDESC_BUS_GET_DEVINFO(bus, dev); - if (mbd == NULL) - return (NULL); - return (mbd->mbd_name); -} - -const char * -mdesc_bus_gen_get_type(device_t bus, device_t dev) -{ - const struct mdesc_bus_devinfo *mbd; - - mbd = MDESC_BUS_GET_DEVINFO(bus, dev); - if (mbd == NULL) - return (NULL); - return (mbd->mbd_type); -} - -uint64_t -mdesc_bus_gen_get_handle(device_t bus, device_t dev) -{ - const struct mdesc_bus_devinfo *mbd; - - mbd = MDESC_BUS_GET_DEVINFO(bus, dev); - if (mbd == NULL) - return (0); - return (mbd->mbd_handle); -} - - - - - - - - - diff --git a/sys/sun4v/mdesc/mdesc_init.c b/sys/sun4v/mdesc/mdesc_init.c deleted file mode 100644 index bb2990de94c2..000000000000 --- a/sys/sun4v/mdesc/mdesc_init.c +++ /dev/null @@ -1,306 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - - -static void mdesc_postvm_init(void *); -/* - * It doesn't really matter when this happens right now - * it just needs to happen before device initialization - * and after VM initialization. Later on we will end up - * doing this statically from pmap_bootstrap so that we - * can kill off all calls to OBP. OBP removal is not in - * the critical path for sun4v at this time. - */ -SYSINIT(mdesc_init, SI_SUB_CPU, SI_ORDER_SECOND, mdesc_postvm_init, NULL); - - -#define UNIMPLEMENTED panic("%s not implemented.", __FUNCTION__) - -typedef struct mdesc_memops_ { - void *(*mm_buf_alloc)(size_t size, size_t align); - void (*mm_buf_free)(void *, size_t size); - void *(*mm_meta_alloc)(size_t size); - void (*mm_meta_free)(void *, size_t size); -} mdesc_memops_t; - -typedef struct mdesc_ { - uint64_t md_gen; /* md-generation# */ - struct mtx md_lock; - void *md_addr; /* address of raw MD */ - uint64_t md_size; /* size of raw MD */ - uint64_t md_buf_size; /* size of buffer allocated for MD */ - int md_refcount; /* reference count */ - mdesc_memops_t *md_memops; /* Memory operations for this MD */ -} mdesc_t; - - - -static mdesc_t *curr_mdesc = NULL; -static struct mtx curr_mdesc_lock; -static mdesc_memops_t *mdesc_memops; - -static void *mdesc_boot_buf_alloc(size_t size, size_t align); -static void mdesc_boot_buf_free(void *buf, size_t align); -static void *mdesc_boot_meta_alloc(size_t size); -static void mdesc_boot_meta_free(void *buf, size_t size); - -static void *mdesc_buf_alloc(size_t size, size_t align); -static void mdesc_buf_free(void *buf, size_t align); -static void *mdesc_meta_alloc(size_t size); -static void mdesc_meta_free(void *buf, size_t size); - -static mdesc_memops_t mdesc_boot_memops = { - mdesc_boot_buf_alloc, - mdesc_boot_buf_free, - mdesc_boot_meta_alloc, - mdesc_boot_meta_free, -}; - -static mdesc_memops_t mdesc_generic_memops = { - mdesc_buf_alloc, - mdesc_buf_free, - mdesc_meta_alloc, - mdesc_meta_free, -}; - -static void * -mdesc_boot_buf_alloc(size_t size, size_t align) -{ - UNIMPLEMENTED; -} - -static void -mdesc_boot_buf_free(void *buf, size_t align) -{ - UNIMPLEMENTED; -} - -static void * -mdesc_boot_meta_alloc(size_t size) -{ - UNIMPLEMENTED; -} - -static void -mdesc_boot_meta_free(void *buf, size_t size) -{ - UNIMPLEMENTED; -} - -static void * -mdesc_buf_alloc(size_t size, size_t align) -{ - return pmap_alloc_zeroed_contig_pages(size/PAGE_SIZE, align); -} - -static void -mdesc_buf_free(void *buf, size_t align) -{ - contigfree(buf, PAGE_SIZE /*fix me*/, M_MDPROP); -} - -static void * -mdesc_meta_alloc(size_t size) -{ - return malloc(size, M_MDPROP, M_NOWAIT); -} - -static void -mdesc_meta_free(void *buf, size_t size) -{ - free(buf, M_MDPROP); -} - -void -mdesc_init(void) -{ - - mtx_init(&curr_mdesc_lock, "current machine description lock", NULL, MTX_DEF); - mdesc_memops = &mdesc_boot_memops; -} - -static void -mdesc_postvm_init(void *unused) -{ - mdesc_memops = &mdesc_generic_memops; -} - -static mdesc_t * -mdesc_alloc(void) -{ - mdesc_t *mdp; - - mdp = (mdesc_t *)(mdesc_memops->mm_meta_alloc)(sizeof(mdesc_t)); - if (mdp != NULL) { - bzero(mdp, sizeof(*mdp)); - mdp->md_memops = mdesc_memops; - mtx_init(&mdp->md_lock, "machine descriptor lock", NULL, MTX_DEF); - } - - return (mdp); -} - -int -mdesc_update(void) -{ - uint64_t rv; - uint64_t mdesc_size, mdesc_buf_size = 0; - void *buf = NULL; -#ifdef notyet - uint64_t gen; -#endif - do { - if (buf != NULL) - (mdesc_memops->mm_buf_free)(buf, mdesc_buf_size); - - mdesc_size = 0LL; - do { - rv = hv_mach_desc((uint64_t)0, &mdesc_size); - if (rv != H_EOK && rv != H_EINVAL) - printf("retrying to fetch mdesc size\n"); - } while (rv != H_EOK && rv != H_EINVAL); - - mdesc_size = mdesc_buf_size = round_page(mdesc_size); - - if ((buf = (*mdesc_memops->mm_buf_alloc)(mdesc_buf_size, PAGE_SIZE)) == NULL) { - rv = ENOMEM; - goto done; - } - - rv = hv_mach_desc(vtophys(buf), &mdesc_size); - - if (rv != H_EOK && rv != H_EINVAL) { - goto done; - } - } while (mdesc_size > mdesc_buf_size); - - KASSERT(rv == H_EOK, ("unexpected return from hv_mach_desc")); - - /* XXX we ignore the generation count... not all versions may - * support it - */ - - if (curr_mdesc->md_refcount == 0) { - (*mdesc_memops->mm_buf_free) (curr_mdesc->md_addr, curr_mdesc->md_size); - } else { - panic("out of date machine description list not implemented"); - } - - mtx_lock(&curr_mdesc_lock); -#ifdef notyet - curr_mdesc->md_gen = gen; -#endif - curr_mdesc->md_addr = buf; - curr_mdesc->md_size = mdesc_size; - curr_mdesc->md_buf_size = mdesc_buf_size; - mtx_unlock(&curr_mdesc_lock); - - return (0); - - done: - if (buf != NULL) - (*mdesc_memops->mm_buf_free)(buf, mdesc_buf_size); - return (rv); -} - -md_t * -md_get(void) -{ - md_t *mdp; - int rc; - - /* - * XXX This should actually happen in init - */ - if (curr_mdesc == NULL) { - if ((curr_mdesc = mdesc_alloc()) == NULL) - panic("machine description allocation failed"); - if ((rc = mdesc_update()) != 0) - panic("machine description update failed: %d", rc); - } - - mtx_lock(&curr_mdesc_lock); - curr_mdesc->md_refcount++; - mdp = md_init_intern(curr_mdesc->md_addr, - curr_mdesc->md_memops->mm_meta_alloc, - curr_mdesc->md_memops->mm_meta_free); - mtx_unlock(&curr_mdesc_lock); - - return (mdp); -} - -void -md_put(md_t *ptr) -{ - md_impl_t *mdp; - - mdp = (md_impl_t *)ptr; - -#ifdef notyet - mtx_lock(&curr_mdesc_lock) - - /* XXX check against generation */ - if (curr_mdesc->md_gen == mdp->md_gen) { - curr_mdesc->md_refcount--; - mtx_unlock(&curr_mdesc_lock) - goto done; - } - mtx_unlock(&curr_mdesc_lock); - /* - * MD is on the out of date list - */ - - done: -#endif - /* - * We don't keep an out of date list currently - */ - mtx_lock(&curr_mdesc_lock); - curr_mdesc->md_refcount--; - mtx_unlock(&curr_mdesc_lock); - mdp->freep(mdp, sizeof(md_impl_t)); -} - - diff --git a/sys/sun4v/mdesc/mdesc_subr.c b/sys/sun4v/mdesc/mdesc_subr.c deleted file mode 100644 index 4840708abddb..000000000000 --- a/sys/sun4v/mdesc/mdesc_subr.c +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - - -#include -#include - - -int -md_get_prop_alloc(md_t *ptr, mde_cookie_t node, char *namep, int tag_type, - uint8_t **datap) -{ - mde_str_cookie_t prop_name; - md_impl_t *mdp; - mde_cookie_t elem; - int len; - - mdp = (md_impl_t *)ptr; - - if (node == MDE_INVAL_ELEM_COOKIE) { - return (-1); - } - - prop_name = md_find_name(ptr, namep); - if (prop_name == MDE_INVAL_STR_COOKIE) { - return (-1); - } - - elem = md_find_node_prop(mdp, node, prop_name, tag_type); - - if (elem != MDE_INVAL_ELEM_COOKIE) { - md_element_t *mdep; - mdep = &(mdp->mdep[(int)elem]); - - len = (int)MDE_PROP_DATA_LEN(mdep); - KASSERT(len > 0, ("invalid length")); - *datap = malloc(len, M_MDPROP, M_WAITOK); - bcopy(mdp->datap + (int)MDE_PROP_DATA_OFFSET(mdep), *datap, len); - return (0); - } - - return (-1); /* no such property name */ -} - - diff --git a/sys/sun4v/mdesc/mdesc_vdevfindnode.c b/sys/sun4v/mdesc/mdesc_vdevfindnode.c deleted file mode 100644 index e90702dde583..000000000000 --- a/sys/sun4v/mdesc/mdesc_vdevfindnode.c +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - -int -md_vdev_find_node(device_t dev, mde_cookie_t *valp) -{ - uint64_t cfg_handle; - mde_cookie_t rootnode, node, *listp = NULL; - int i, listsz, num_nodes, num_devices, error; - md_t *mdp; - - cfg_handle = mdesc_bus_get_handle(dev); - - error = EINVAL; - - if ((mdp = md_get()) == NULL) - return (ENXIO); - - num_nodes = md_node_count(mdp); - listsz = num_nodes * sizeof(mde_cookie_t); - listp = (mde_cookie_t *)malloc(listsz, M_DEVBUF, M_WAITOK); - rootnode = md_root_node(mdp); - node = error = 0; - - num_devices = md_scan_dag(mdp, rootnode, - md_find_name(mdp, "virtual-device"), - md_find_name(mdp, "fwd"), listp); - - if (num_devices == 0) { - error = ENOENT; - goto done; - } - - for (i = 0; i < num_devices; i++) { - uint64_t thandle; - - node = listp[i]; - md_get_prop_val(mdp, node, "cfg-handle", &thandle); - if (thandle == cfg_handle) { - *valp = node; - break; - } - } - -done: - md_put(mdp); - - return (error); -} - diff --git a/sys/sun4v/mdesc/mdesc_vdevfindval.c b/sys/sun4v/mdesc/mdesc_vdevfindval.c deleted file mode 100644 index be2db6f6eac1..000000000000 --- a/sys/sun4v/mdesc/mdesc_vdevfindval.c +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - -int -md_vdev_find_val(device_t dev, char *namep, uint64_t *valp) -{ - uint64_t cfg_handle; - mde_cookie_t rootnode, node, *listp = NULL; - int i, listsz, num_nodes, num_devices, error; - md_t *mdp; - - cfg_handle = mdesc_bus_get_handle(dev); - - if ((mdp = md_get()) == NULL) - return (ENXIO); - - num_nodes = md_node_count(mdp); - listsz = num_nodes * sizeof(mde_cookie_t); - listp = (mde_cookie_t *)malloc(listsz, M_DEVBUF, M_WAITOK); - rootnode = md_root_node(mdp); - node = error = 0; - - num_devices = md_scan_dag(mdp, rootnode, - md_find_name(mdp, "virtual-device"), - md_find_name(mdp, "fwd"), listp); - - if (num_devices == 0) { - error = ENOENT; - goto done; - } - - for (i = 0; i < num_devices; i++) { - uint64_t thandle; - - node = listp[i]; - md_get_prop_val(mdp, node, "cfg-handle", &thandle); - if (thandle == cfg_handle) - break; - } - - md_get_prop_val(mdp, node, namep, valp); -done: - free(listp, M_DEVBUF); - md_put(mdp); - - return (error); -} - diff --git a/sys/sun4v/sun4v/bus_machdep.c b/sys/sun4v/sun4v/bus_machdep.c deleted file mode 100644 index 0d20d6cefee4..000000000000 --- a/sys/sun4v/sun4v/bus_machdep.c +++ /dev/null @@ -1,845 +0,0 @@ -/*- - * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * 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. - */ -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (c) 1997, 1998 Justin T. Gibbs. - * All rights reserved. - * Copyright 2001 by Thomas Moestl . 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, - * without modification, immediately at the beginning of the file. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * from: @(#)machdep.c 8.6 (Berkeley) 1/14/94 - * from: NetBSD: machdep.c,v 1.221 2008/04/28 20:23:37 martin Exp - * and - * from: FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.24 2001/08/15 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -static void nexus_bus_barrier(bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, int); - -/* ASIs for bus access */ -const int bus_type_asi[] = { - ASI_REAL_IO, /* nexus */ - ASI_REAL_IO, /* SBus */ - ASI_REAL_IO_L, /* PCI configuration space */ - ASI_REAL_IO_L, /* PCI memory space */ - ASI_REAL_IO_L, /* PCI I/O space */ - 0 -}; - -const int bus_stream_asi[] = { - ASI_REAL_IO, /* nexus */ - ASI_REAL_IO, /* SBus */ - ASI_REAL_IO, /* PCI configuration space */ - ASI_REAL_IO, /* PCI memory space */ - ASI_REAL_IO, /* PCI I/O space */ - 0 -}; - -/* - * Convenience function for manipulating driver locks from busdma (during - * busdma_swi, for example). Drivers that don't provide their own locks - * should specify &Giant to dmat->lockfuncarg. Drivers that use their own - * non-mutex locking scheme don't have to use this at all. - */ -void -busdma_lock_mutex(void *arg, bus_dma_lock_op_t op) -{ - struct mtx *dmtx; - - dmtx = (struct mtx *)arg; - switch (op) { - case BUS_DMA_LOCK: - mtx_lock(dmtx); - break; - case BUS_DMA_UNLOCK: - mtx_unlock(dmtx); - break; - default: - panic("Unknown operation 0x%x for busdma_lock_mutex!", op); - } -} - -/* - * dflt_lock should never get called. It gets put into the dma tag when - * lockfunc == NULL, which is only valid if the maps that are associated - * with the tag are meant to never be defered. - * XXX Should have a way to identify which driver is responsible here. - */ -static void -dflt_lock(void *arg, bus_dma_lock_op_t op) -{ - - panic("driver error: busdma dflt_lock called"); -} - -/* - * Since there is no way for a device to obtain a dma tag from its parent - * we use this kluge to handle different the different supported bus systems. - * The sparc64_root_dma_tag is used as parent for tags that have none, so that - * the correct methods will be used. - */ -bus_dma_tag_t sparc64_root_dma_tag; - -/* - * Allocate a device specific dma_tag. - */ -int -bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment, - bus_size_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr, - bus_dma_filter_t *filter, void *filterarg, bus_size_t maxsize, - int nsegments, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, - void *lockfuncarg, bus_dma_tag_t *dmat) -{ - bus_dma_tag_t impptag; - bus_dma_tag_t newtag; - - /* Return a NULL tag on failure */ - *dmat = NULL; - - newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF, M_NOWAIT); - if (newtag == NULL) - return (ENOMEM); - - impptag = parent != NULL ? parent : sparc64_root_dma_tag; - /* - * The method table pointer and the cookie need to be taken over from - * the parent or the root tag. - */ - newtag->dt_cookie = impptag->dt_cookie; - newtag->dt_mt = impptag->dt_mt; - - newtag->dt_parent = parent; - newtag->dt_alignment = alignment; - newtag->dt_boundary = boundary; - newtag->dt_lowaddr = trunc_page((vm_offset_t)lowaddr) + (PAGE_SIZE - 1); - newtag->dt_highaddr = trunc_page((vm_offset_t)highaddr) + - (PAGE_SIZE - 1); - newtag->dt_filter = filter; - newtag->dt_filterarg = filterarg; - newtag->dt_maxsize = maxsize; - newtag->dt_nsegments = nsegments; - newtag->dt_maxsegsz = maxsegsz; - newtag->dt_flags = flags; - newtag->dt_ref_count = 1; /* Count ourselves */ - newtag->dt_map_count = 0; - - if (lockfunc != NULL) { - newtag->dt_lockfunc = lockfunc; - newtag->dt_lockfuncarg = lockfuncarg; - } else { - newtag->dt_lockfunc = dflt_lock; - newtag->dt_lockfuncarg = NULL; - } - - newtag->dt_segments = NULL; - - /* Take into account any restrictions imposed by our parent tag. */ - if (parent != NULL) { - newtag->dt_lowaddr = ulmin(parent->dt_lowaddr, - newtag->dt_lowaddr); - newtag->dt_highaddr = ulmax(parent->dt_highaddr, - newtag->dt_highaddr); - if (newtag->dt_boundary == 0) - newtag->dt_boundary = parent->dt_boundary; - else if (parent->dt_boundary != 0) - newtag->dt_boundary = ulmin(parent->dt_boundary, - newtag->dt_boundary); - atomic_add_int(&parent->dt_ref_count, 1); - } - - if (newtag->dt_boundary > 0) - newtag->dt_maxsegsz = ulmin(newtag->dt_maxsegsz, - newtag->dt_boundary); - - *dmat = newtag; - return (0); -} - -int -bus_dma_tag_destroy(bus_dma_tag_t dmat) -{ - bus_dma_tag_t parent; - - if (dmat != NULL) { - if (dmat->dt_map_count != 0) - return (EBUSY); - while (dmat != NULL) { - parent = dmat->dt_parent; - atomic_subtract_int(&dmat->dt_ref_count, 1); - if (dmat->dt_ref_count == 0) { - if (dmat->dt_segments != NULL) - free(dmat->dt_segments, M_DEVBUF); - free(dmat, M_DEVBUF); - /* - * Last reference count, so - * release our reference - * count on our parent. - */ - dmat = parent; - } else - dmat = NULL; - } - } - return (0); -} - -/* Allocate/free a tag, and do the necessary management work. */ -int -sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp) -{ - - if (dmat->dt_segments == NULL) { - dmat->dt_segments = (bus_dma_segment_t *)malloc( - sizeof(bus_dma_segment_t) * dmat->dt_nsegments, M_DEVBUF, - M_NOWAIT); - if (dmat->dt_segments == NULL) - return (ENOMEM); - } - *mapp = malloc(sizeof(**mapp), M_DEVBUF, M_NOWAIT | M_ZERO); - if (*mapp == NULL) - return (ENOMEM); - - SLIST_INIT(&(*mapp)->dm_reslist); - dmat->dt_map_count++; - return (0); -} - -void -sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map) -{ - - free(map, M_DEVBUF); - dmat->dt_map_count--; -} - -static int -nexus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) -{ - - return (sparc64_dma_alloc_map(dmat, mapp)); -} - -static int -nexus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map) -{ - - sparc64_dma_free_map(dmat, map); - return (0); -} - -/* - * Utility function to load a linear buffer. lastaddrp holds state - * between invocations (for multiple-buffer loads). segp contains - * the starting segment on entrace, and the ending segment on exit. - * first indicates if this is the first invocation of this function. - */ -static int -_nexus_dmamap_load_buffer(bus_dma_tag_t dmat, void *buf, bus_size_t buflen, - struct thread *td, int flags, bus_addr_t *lastaddrp, - bus_dma_segment_t *segs, int *segp, int first) -{ - bus_size_t sgsize; - bus_addr_t curaddr, lastaddr, baddr, bmask; - vm_offset_t vaddr = (vm_offset_t)buf; - int seg; - pmap_t pmap; - - if (td != NULL) - pmap = vmspace_pmap(td->td_proc->p_vmspace); - else - pmap = NULL; - - lastaddr = *lastaddrp; - bmask = ~(dmat->dt_boundary - 1); - - for (seg = *segp; buflen > 0 ; ) { - /* - * Get the physical address for this segment. - */ - if (pmap) - curaddr = pmap_extract(pmap, vaddr); - else - curaddr = pmap_kextract(vaddr); - - /* - * Compute the segment size, and adjust counts. - */ - sgsize = PAGE_SIZE - ((u_long)curaddr & PAGE_MASK); - if (sgsize > dmat->dt_maxsegsz) - sgsize = dmat->dt_maxsegsz; - if (buflen < sgsize) - sgsize = buflen; - - /* - * Make sure we don't cross any boundaries. - */ - if (dmat->dt_boundary > 0) { - baddr = (curaddr + dmat->dt_boundary) & bmask; - if (sgsize > (baddr - curaddr)) - sgsize = (baddr - curaddr); - } - - /* - * Insert chunk into a segment, coalescing with - * previous segment if possible. - */ - if (first) { - segs[seg].ds_addr = curaddr; - segs[seg].ds_len = sgsize; - first = 0; - } else { - if (curaddr == lastaddr && - (segs[seg].ds_len + sgsize) <= dmat->dt_maxsegsz && - (dmat->dt_boundary == 0 || - (segs[seg].ds_addr & bmask) == (curaddr & bmask))) - segs[seg].ds_len += sgsize; - else { - if (++seg >= dmat->dt_nsegments) - break; - segs[seg].ds_addr = curaddr; - segs[seg].ds_len = sgsize; - } - } - - lastaddr = curaddr + sgsize; - vaddr += sgsize; - buflen -= sgsize; - } - - *segp = seg; - *lastaddrp = lastaddr; - - /* - * Did we fit? - */ - return (buflen != 0 ? EFBIG : 0); /* XXX better return value here? */ -} - -/* - * Common function for loading a DMA map with a linear buffer. May - * be called by bus-specific DMA map load functions. - * - * Most SPARCs have IOMMUs in the bus controllers. In those cases - * they only need one segment and will use virtual addresses for DVMA. - * Those bus controllers should intercept these vectors and should - * *NEVER* call nexus_dmamap_load() which is used only by devices that - * bypass DVMA. - */ -static int -nexus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, - bus_size_t buflen, bus_dmamap_callback_t *callback, void *callback_arg, - int flags) -{ - bus_addr_t lastaddr; - int error, nsegs; - - error = _nexus_dmamap_load_buffer(dmat, buf, buflen, NULL, flags, - &lastaddr, dmat->dt_segments, &nsegs, 1); - - if (error == 0) { - (*callback)(callback_arg, dmat->dt_segments, nsegs + 1, 0); - map->dm_flags |= DMF_LOADED; - } else - (*callback)(callback_arg, NULL, 0, error); - - return (0); -} - -/* - * Like nexus_dmamap_load(), but for mbufs. - */ -static int -nexus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, - bus_dmamap_callback2_t *callback, void *callback_arg, int flags) -{ - int nsegs, error; - - M_ASSERTPKTHDR(m0); - - nsegs = 0; - error = 0; - if (m0->m_pkthdr.len <= dmat->dt_maxsize) { - int first = 1; - bus_addr_t lastaddr = 0; - struct mbuf *m; - - for (m = m0; m != NULL && error == 0; m = m->m_next) { - if (m->m_len > 0) { - error = _nexus_dmamap_load_buffer(dmat, - m->m_data, m->m_len,NULL, flags, &lastaddr, - dmat->dt_segments, &nsegs, first); - first = 0; - } - } - } else { - error = EINVAL; - } - - if (error) { - /* force "no valid mappings" in callback */ - (*callback)(callback_arg, dmat->dt_segments, 0, 0, error); - } else { - map->dm_flags |= DMF_LOADED; - (*callback)(callback_arg, dmat->dt_segments, nsegs + 1, - m0->m_pkthdr.len, error); - } - return (error); -} - -static int -nexus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, - bus_dma_segment_t *segs, int *nsegs, int flags) -{ - int error; - - M_ASSERTPKTHDR(m0); - - *nsegs = 0; - error = 0; - if (m0->m_pkthdr.len <= dmat->dt_maxsize) { - int first = 1; - bus_addr_t lastaddr = 0; - struct mbuf *m; - - for (m = m0; m != NULL && error == 0; m = m->m_next) { - if (m->m_len > 0) { - error = _nexus_dmamap_load_buffer(dmat, - m->m_data, m->m_len,NULL, flags, &lastaddr, - segs, nsegs, first); - first = 0; - } - } - } else { - error = EINVAL; - } - - ++*nsegs; - return (error); -} - -/* - * Like nexus_dmamap_load(), but for uios. - */ -static int -nexus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, struct uio *uio, - bus_dmamap_callback2_t *callback, void *callback_arg, int flags) -{ - bus_addr_t lastaddr; - int nsegs, error, first, i; - bus_size_t resid; - struct iovec *iov; - struct thread *td = NULL; - - resid = uio->uio_resid; - iov = uio->uio_iov; - - if (uio->uio_segflg == UIO_USERSPACE) { - td = uio->uio_td; - KASSERT(td != NULL, ("%s: USERSPACE but no proc", __func__)); - } - - nsegs = 0; - error = 0; - first = 1; - for (i = 0; i < uio->uio_iovcnt && resid != 0 && !error; i++) { - /* - * Now at the first iovec to load. Load each iovec - * until we have exhausted the residual count. - */ - bus_size_t minlen = - resid < iov[i].iov_len ? resid : iov[i].iov_len; - caddr_t addr = (caddr_t) iov[i].iov_base; - - if (minlen > 0) { - error = _nexus_dmamap_load_buffer(dmat, addr, minlen, - td, flags, &lastaddr, dmat->dt_segments, &nsegs, - first); - first = 0; - - resid -= minlen; - } - } - - if (error) { - /* force "no valid mappings" in callback */ - (*callback)(callback_arg, dmat->dt_segments, 0, 0, error); - } else { - map->dm_flags |= DMF_LOADED; - (*callback)(callback_arg, dmat->dt_segments, nsegs + 1, - uio->uio_resid, error); - } - return (error); -} - -/* - * Common function for unloading a DMA map. May be called by - * bus-specific DMA map unload functions. - */ -static void -nexus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) -{ - - map->dm_flags &= ~DMF_LOADED; -} - -/* - * Common function for DMA map synchronization. May be called - * by bus-specific DMA map synchronization functions. - */ -static void -nexus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op) -{ - - /* - * We sync out our caches, but the bus must do the same. - * - * Actually a #Sync is expensive. We should optimize. - */ - if ((op & BUS_DMASYNC_PREREAD) || (op & BUS_DMASYNC_PREWRITE)) { - /* - * Don't really need to do anything, but flush any pending - * writes anyway. - */ - membar(Sync); - } -#if 0 - /* Should not be needed. */ - if (op & BUS_DMASYNC_POSTREAD) { - ecache_flush((vm_offset_t)map->buf, - (vm_offset_t)map->buf + map->buflen - 1); - } -#endif - if (op & BUS_DMASYNC_POSTWRITE) { - /* Nothing to do. Handled by the bus controller. */ - } -} - -/* - * Common function for DMA-safe memory allocation. May be called - * by bus-specific DMA memory allocation functions. - */ -static int -nexus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags, - bus_dmamap_t *mapp) -{ - int mflags; - - if (flags & BUS_DMA_NOWAIT) - mflags = M_NOWAIT; - else - mflags = M_WAITOK; - if (flags & BUS_DMA_ZERO) - mflags |= M_ZERO; - - /* - * XXX: - * (dmat->dt_alignment < dmat->dt_maxsize) is just a quick hack; the - * exact alignment guarantees of malloc need to be nailed down, and - * the code below should be rewritten to take that into account. - * - * In the meantime, we'll warn the user if malloc gets it wrong. - */ - if (dmat->dt_maxsize <= PAGE_SIZE && - dmat->dt_alignment < dmat->dt_maxsize) - *vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags); - else { - /* - * XXX use contigmalloc until it is merged into this - * facility and handles multi-seg allocations. Nobody - * is doing multi-seg allocations yet though. - */ - *vaddr = contigmalloc(dmat->dt_maxsize, M_DEVBUF, mflags, - 0ul, dmat->dt_lowaddr, - dmat->dt_alignment ? dmat->dt_alignment : 1UL, - dmat->dt_boundary); - } - if (*vaddr == NULL) - return (ENOMEM); - if ((uintptr_t)*vaddr % dmat->dt_alignment) - printf("%s: failed to align memory properly.\n", __func__); - return (0); -} - -/* - * Common function for freeing DMA-safe memory. May be called by - * bus-specific DMA memory free functions. - */ -static void -nexus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) -{ - - if (dmat->dt_maxsize <= PAGE_SIZE && - dmat->dt_alignment < dmat->dt_maxsize) - free(vaddr, M_DEVBUF); - else - contigfree(vaddr, dmat->dt_maxsize, M_DEVBUF); -} - -struct bus_dma_methods nexus_dma_methods = { - nexus_dmamap_create, - nexus_dmamap_destroy, - nexus_dmamap_load, - nexus_dmamap_load_mbuf, - nexus_dmamap_load_mbuf_sg, - nexus_dmamap_load_uio, - nexus_dmamap_unload, - nexus_dmamap_sync, - nexus_dmamem_alloc, - nexus_dmamem_free, -}; - -struct bus_dma_tag nexus_dmatag = { - NULL, - NULL, - 8, - 0, - 0, - 0x3ffffffff, - NULL, /* XXX */ - NULL, - 0x3ffffffff, /* XXX */ - 0xff, /* XXX */ - 0xffffffff, /* XXX */ - 0, - 0, - 0, - NULL, - NULL, - NULL, - &nexus_dma_methods, -}; - -/* - * Helpers to map/unmap bus memory - */ -int -sparc64_bus_mem_map(bus_space_tag_t tag, bus_space_handle_t handle, - bus_size_t size, int flags, vm_offset_t vaddr, void **hp) -{ -#if 0 - vm_offset_t addr; - vm_offset_t sva; - vm_offset_t va; - vm_paddr_t pa; - vm_size_t vsz; - u_long pm_flags; - - addr = (vm_offset_t)handle; - size = round_page(size); - if (size == 0) { - printf("%s: zero size\n", __func__); - return (EINVAL); - } - switch (tag->bst_type) { - case PCI_CONFIG_BUS_SPACE: - case PCI_IO_BUS_SPACE: - case PCI_MEMORY_BUS_SPACE: - pm_flags = TD_IE; - break; - default: - pm_flags = 0; - break; - } - - if (!(flags & BUS_SPACE_MAP_CACHEABLE)) - pm_flags |= TD_E; - - if (vaddr != 0L) - sva = trunc_page(vaddr); - else { - if ((sva = kmem_alloc_nofault(kernel_map, size)) == 0) - panic("%s: cannot allocate virtual memory", __func__); - } - - /* Preserve page offset. */ - *hp = (void *)(sva | ((u_long)addr & PAGE_MASK)); - - pa = trunc_page(addr); - if ((flags & BUS_SPACE_MAP_READONLY) == 0) - pm_flags |= TD_W; - - va = sva; - vsz = size; - do { - pmap_kenter_flags(va, pa, pm_flags); - va += PAGE_SIZE; - pa += PAGE_SIZE; - } while ((vsz -= PAGE_SIZE) > 0); - tlb_range_demap(kernel_pmap, sva, sva + size - 1); -#endif - return (0); -} - -int -sparc64_bus_mem_unmap(void *bh, bus_size_t size) -{ -#if 0 - vm_offset_t sva; - vm_offset_t va; - vm_offset_t endva; - - sva = trunc_page((vm_offset_t)bh); - endva = sva + round_page(size); - for (va = sva; va < endva; va += PAGE_SIZE) - pmap_kremove_flags(va); - tlb_range_demap(kernel_pmap, sva, sva + size - 1); - kmem_free(kernel_map, sva, size); -#endif - return (0); -} - -/* - * Fake up a bus tag, for use by console drivers in early boot when the - * regular means to allocate resources are not yet available. - * Addr is the physical address of the desired start of the handle. - */ -bus_space_handle_t -sparc64_fake_bustag(int space, bus_addr_t addr, struct bus_space_tag *ptag) -{ - - ptag->bst_cookie = NULL; - ptag->bst_parent = NULL; - ptag->bst_type = space; - ptag->bst_bus_barrier = nexus_bus_barrier; - return (addr); -} - -/* - * Base bus space handlers. - */ - -static void -nexus_bus_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, - bus_size_t size, int flags) -{ - - /* - * We have lots of alternatives depending on whether we're - * synchronizing loads with loads, loads with stores, stores - * with loads, or stores with stores. The only ones that seem - * generic are #Sync and #MemIssue. I'll use #Sync for safety. - */ - switch(flags) { - case BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE: - case BUS_SPACE_BARRIER_READ: - case BUS_SPACE_BARRIER_WRITE: - membar(Sync); - break; - default: - panic("%s: unknown flags", __func__); - } - return; -} - -struct bus_space_tag nexus_bustag = { - NULL, /* cookie */ - NULL, /* parent bus tag */ - NEXUS_BUS_SPACE, /* type */ - nexus_bus_barrier, /* bus_space_barrier */ -}; diff --git a/sys/sun4v/sun4v/clock.c b/sys/sun4v/sun4v/clock.c deleted file mode 100644 index 75f6d43aba6c..000000000000 --- a/sys/sun4v/sun4v/clock.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#include -#include -#include - -u_long tick_freq; -u_long tick_MHz; - -void -DELAY(int n) -{ - u_long start, end; - - start = rd(tick); - if (n < 0) - return; - end = start + (u_long)n * tick_MHz; - while (rd(tick) < end) - ; -} diff --git a/sys/sun4v/sun4v/db_hwwatch.c b/sys/sun4v/sun4v/db_hwwatch.c deleted file mode 100644 index 0a878ca0b9dd..000000000000 --- a/sys/sun4v/sun4v/db_hwwatch.c +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * Copyright 2001 by Thomas Moestl . 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. - * - * $FreeBSD$ - */ - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#if 0 -static void db_watch_print(vm_offset_t wp, int bm); - -int -watch_phys_set_mask(vm_paddr_t pa, u_long mask) -{ - u_long lsucr; - - stxa_sync(AA_DMMU_PWPR, ASI_DMMU, pa & (((2UL << 38) - 1) << 3)); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - lsucr = ((lsucr | LSU_PW) & ~LSU_PM_MASK) | - (mask << LSU_PM_SHIFT); - stxa_sync(0, ASI_LSU_CTL_REG, lsucr); - return (0); -} - -int -watch_phys_set(vm_paddr_t pa, int sz) -{ - u_long off; - - off = (u_long)pa & 7; - /* Test for misaligned watch points. */ - if (off + sz > 8) - return (-1); - return (watch_phys_set_mask(pa, ((1 << sz) - 1) << off)); -} - -vm_paddr_t -watch_phys_get(int *bm) -{ - vm_paddr_t pa; - u_long lsucr; - - if (!watch_phys_active()) - return (0); - - pa = ldxa(AA_DMMU_PWPR, ASI_DMMU); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - *bm = (lsucr & LSU_PM_MASK) >> LSU_PM_SHIFT; - - return (pa); -} - -void -watch_phys_clear() -{ - stxa_sync(0, ASI_LSU_CTL_REG, - ldxa(0, ASI_LSU_CTL_REG) & ~LSU_PW); -} - -int -watch_phys_active() -{ - - return (ldxa(0, ASI_LSU_CTL_REG) & LSU_PW); -} - -int -watch_virt_set_mask(vm_offset_t va, u_long mask) -{ - u_long lsucr; - - stxa_sync(AA_DMMU_VWPR, ASI_DMMU, va & (((2UL << 41) - 1) << 3)); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - lsucr = ((lsucr | LSU_VW) & ~LSU_VM_MASK) | - (mask << LSU_VM_SHIFT); - stxa_sync(0, ASI_LSU_CTL_REG, lsucr); - return (0); -} - -int -watch_virt_set(vm_offset_t va, int sz) -{ - u_long off; - - off = (u_long)va & 7; - /* Test for misaligned watch points. */ - if (off + sz > 8) - return (-1); - return (watch_virt_set_mask(va, ((1 << sz) - 1) << off)); -} - -vm_offset_t -watch_virt_get(int *bm) -{ - u_long va; - u_long lsucr; - - if (!watch_virt_active()) - return (0); - - va = ldxa(AA_DMMU_VWPR, ASI_DMMU); - lsucr = ldxa(0, ASI_LSU_CTL_REG); - *bm = (lsucr & LSU_VM_MASK) >> LSU_VM_SHIFT; - - return ((vm_offset_t)va); -} - -void -watch_virt_clear() -{ - stxa_sync(0, ASI_LSU_CTL_REG, - ldxa(0, ASI_LSU_CTL_REG) & ~LSU_VW); -} - -int -watch_virt_active() -{ - - return (ldxa(0, ASI_LSU_CTL_REG) & LSU_VW); -} - -int -db_md_set_watchpoint(db_expr_t addr, db_expr_t size) -{ - int dummy; - - if (watch_virt_active()) { - db_printf("Overwriting previously active watch point at " - "0x%lx\n", watch_virt_get(&dummy)); - } - return (watch_virt_set(addr, size)); -} - -int -db_md_clr_watchpoint(db_expr_t addr, db_expr_t size) -{ - - watch_virt_clear(); - return (0); -} - -void -db_watch_print(vm_offset_t wp, int bm) -{ - int i; - - db_printf("\tat 0x%lx, active bytes: ", (u_long)wp); - for (i = 0; i < 8; i++) { - if ((bm & (1 << i)) != 0) - db_printf("%d ", i); - } - if (bm == 0) - db_printf("none"); - db_printf("\n"); -} - -void -db_md_list_watchpoints(void) -{ - vm_offset_t va; - vm_paddr_t pa; - int bm; - - db_printf("Physical address watchpoint:\n"); - if (watch_phys_active()) { - pa = watch_phys_get(&bm); - db_watch_print(pa, bm); - } else - db_printf("\tnot active.\n"); - db_printf("Virtual address watchpoint:\n"); - if (watch_virt_active()) { - va = watch_virt_get(&bm); - db_watch_print(va, bm); - } else - db_printf("\tnot active.\n"); -} -#endif -void -db_md_list_watchpoints(void) -{ -} - -int -db_md_clr_watchpoint(db_expr_t addr, db_expr_t size) -{ - - return (0); -} - -int -db_md_set_watchpoint(db_expr_t addr, db_expr_t size) -{ - return (0); -} diff --git a/sys/sun4v/sun4v/db_interface.c b/sys/sun4v/sun4v/db_interface.c deleted file mode 100644 index 3ba816f969f4..000000000000 --- a/sys/sun4v/sun4v/db_interface.c +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -int -db_read_bytes(vm_offset_t addr, size_t size, char *data) -{ - jmp_buf jb; - void *prev_jb; - char *src; - int ret; - - prev_jb = kdb_jmpbuf(jb); - ret = setjmp(jb); - if (ret == 0) { - src = (char *)addr; - while (size-- > 0) - *data++ = *src++; - } - (void)kdb_jmpbuf(prev_jb); - return (ret); -} - -int -db_write_bytes(vm_offset_t addr, size_t size, char *data) -{ - jmp_buf jb; - void *prev_jb; - char *dst; - int ret; - - prev_jb = kdb_jmpbuf(jb); - ret = setjmp(jb); - if (ret == 0) { - dst = (char *)addr; - while (size-- > 0) - *dst++ = *data++; - } - (void)kdb_jmpbuf(prev_jb); - return (ret); -} - -void -db_show_mdpcpu(struct pcpu *pc) -{ -} - -DB_COMMAND(reboot, db_reboot) -{ - cpu_reset(); -} - -DB_COMMAND(halt, db_halt) -{ - cpu_halt(); -} diff --git a/sys/sun4v/sun4v/db_trace.c b/sys/sun4v/sun4v/db_trace.c deleted file mode 100644 index 2e389ba0b4e9..000000000000 --- a/sys/sun4v/sun4v/db_trace.c +++ /dev/null @@ -1,302 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static db_varfcn_t db_frame; - -#define DB_OFFSET(x) (db_expr_t *)offsetof(struct trapframe, x) -struct db_variable db_regs[] = { - { "g0", DB_OFFSET(tf_global[0]), db_frame }, - { "g1", DB_OFFSET(tf_global[1]), db_frame }, - { "g2", DB_OFFSET(tf_global[2]), db_frame }, - { "g3", DB_OFFSET(tf_global[3]), db_frame }, - { "g4", DB_OFFSET(tf_global[4]), db_frame }, - { "g5", DB_OFFSET(tf_global[5]), db_frame }, - { "g6", DB_OFFSET(tf_global[6]), db_frame }, - { "g7", DB_OFFSET(tf_global[7]), db_frame }, - { "i0", DB_OFFSET(tf_out[0]), db_frame }, - { "i1", DB_OFFSET(tf_out[1]), db_frame }, - { "i2", DB_OFFSET(tf_out[2]), db_frame }, - { "i3", DB_OFFSET(tf_out[3]), db_frame }, - { "i4", DB_OFFSET(tf_out[4]), db_frame }, - { "i5", DB_OFFSET(tf_out[5]), db_frame }, - { "i6", DB_OFFSET(tf_out[6]), db_frame }, - { "i7", DB_OFFSET(tf_out[7]), db_frame }, - { "tnpc", DB_OFFSET(tf_tnpc), db_frame }, - { "tpc", DB_OFFSET(tf_tpc), db_frame }, - { "tstate", DB_OFFSET(tf_tstate), db_frame }, -}; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); - -static int -db_frame(struct db_variable *vp, db_expr_t *valuep, int op) -{ - uint64_t *reg; - - if (kdb_frame == NULL) - return (0); - reg = (uint64_t*)((uintptr_t)kdb_frame + (uintptr_t)vp->valuep); - if (op == DB_VAR_GET) - *valuep = *reg; - else - *reg = *valuep; - return (1); -} - -/* - * User stack trace (debugging aid). - */ -static void -db_utrace(struct thread *td, struct trapframe *tf, int count) -{ - struct pcb *pcb; - db_addr_t sp, rsp, o7, pc; - int i, found; - - pcb = td->td_pcb; - sp = db_get_value((db_addr_t)&tf->tf_sp, sizeof(tf->tf_sp), FALSE); - o7 = db_get_value((db_addr_t)&tf->tf_out[7], sizeof(tf->tf_out[7]), - FALSE); - pc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); - db_printf("user trace: trap %%o7=%#lx\n", o7); - while (count-- && sp != 0 && !db_pager_quit) { - db_printf("pc %#lx, sp %#lx\n", pc, sp); - /* First, check whether the frame is in the pcb. */ - found = 0; - for (i = 0; i < pcb->pcb_nsaved; i++) { - if (pcb->pcb_rwsp[i] == sp) { - found = 1; - sp = pcb->pcb_rw[i].rw_in[6]; - pc = pcb->pcb_rw[i].rw_in[7]; - break; - } - } - if (!found) { - rsp = sp + SPOFF; - sp = 0; - if (copyin((void *)(rsp + offsetof(struct frame, fr_fp)), - &sp, sizeof(sp)) != 0 || - copyin((void *)(rsp + offsetof(struct frame, fr_pc)), - &pc, sizeof(pc)) != 0) - break; - } - } - db_printf("done\n"); -} - -static int -db_print_trap(struct thread *td, struct trapframe *tf, int count) -{ - struct proc *p; - const char *symname; - c_db_sym_t sym; - db_expr_t diff; - db_addr_t func; - db_addr_t tpc; - u_long type; -#if 0 - u_long sfar; - u_long sfsr; - u_long tar; - u_long level; - u_long pil; -#endif - u_long code; - u_long o7; - int user; - - type = 5; - p = td->td_proc; -#if 0 - type = db_get_value((db_addr_t)&tf->tf_type, - sizeof(tf->tf_type), FALSE); - db_printf("-- %s", trap_msg[type & ~T_KERNEL]); -#endif - switch (type & ~T_KERNEL) { - case T_DATA_PROTECTION: -#if 0 - tar = (u_long)db_get_value((db_addr_t)&tf->tf_tar, - sizeof(tf->tf_tar), FALSE); - db_printf(" tar=%#lx", tar); -#endif - /* fall through */ - case T_DATA_EXCEPTION: - case T_INSTRUCTION_EXCEPTION: - case T_MEM_ADDRESS_NOT_ALIGNED: -#if 0 - sfar = (u_long)db_get_value((db_addr_t)&tf->tf_sfar, - sizeof(tf->tf_sfar), FALSE); - sfsr = (u_long)db_get_value((db_addr_t)&tf->tf_sfsr, - sizeof(tf->tf_sfsr), FALSE); - db_printf(" sfar=%#lx sfsr=%#lx", sfar, sfsr); -#endif - break; - case T_DATA_MISS: - case T_INSTRUCTION_MISS: -#if 0 - tar = (u_long)db_get_value((db_addr_t)&tf->tf_tar, - sizeof(tf->tf_tar), FALSE); - db_printf(" tar=%#lx", tar); -#endif - break; - case T_SYSCALL: - code = db_get_value((db_addr_t)&tf->tf_global[1], - sizeof(tf->tf_global[1]), FALSE); - db_printf(" (%ld", code); - if (code >= 0 && code < p->p_sysent->sv_size) { - func = (db_addr_t)p->p_sysent->sv_table[code].sy_call; - sym = db_search_symbol(func, DB_STGY_ANY, &diff); - if (sym != DB_SYM_NULL && diff == 0) { - db_symbol_values(sym, &symname, NULL); - db_printf(", %s, %s", p->p_sysent->sv_name, - symname); - } - db_printf(")"); - } - break; - case T_INTERRUPT: -#if 0 - level = (u_long)db_get_value((db_addr_t)&tf->tf_level, - sizeof(tf->tf_level), FALSE); - pil = (u_long)db_get_value((db_addr_t)&tf->tf_pil, - sizeof(tf->tf_pil), FALSE); - db_printf(" level=%#lx pil=%#lx", level, pil); -#endif - break; - default: - break; - } - o7 = (u_long)db_get_value((db_addr_t)&tf->tf_out[7], - sizeof(tf->tf_out[7]), FALSE); - db_printf(" %%o7=%#lx --\n", o7); - user = (type & T_KERNEL) == 0; - if (user) { - tpc = db_get_value((db_addr_t)&tf->tf_tpc, - sizeof(tf->tf_tpc), FALSE); - db_printf("userland() at "); - db_printsym(tpc, DB_STGY_PROC); - db_printf("\n"); - db_utrace(td, tf, count); - } - return (user); -} - -static int -db_backtrace(struct thread *td, struct frame *fp, int count) -{ - struct trapframe *tf; - const char *name; - c_db_sym_t sym; - db_expr_t offset; - db_expr_t value; - db_addr_t npc; - db_addr_t pc; - int trap; - int user; - - if (count == -1) - count = 1024; - - trap = 0; - user = 0; - npc = 0; - while (count-- && !user && !db_pager_quit) { - pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, - sizeof(fp->fr_pc), FALSE); - if (trap) { - pc = npc; - trap = 0; - } - if (!INKERNEL((vm_offset_t)pc)) - break; - sym = db_search_symbol(pc, DB_STGY_ANY, &offset); - if (sym == C_DB_SYM_NULL) { - value = 0; - name = NULL; - } else - db_symbol_values(sym, &name, &value); - if (name == NULL) - name = "(null)"; - fp = (struct frame *)(db_get_value((db_addr_t)&fp->fr_fp, - sizeof(fp->fr_fp), FALSE) + SPOFF); - if (bcmp(name, "tl0_", 4) == 0 || - bcmp(name, "tl1_", 4) == 0) { - tf = (struct trapframe *)(fp + 1); - npc = db_get_value((db_addr_t)&tf->tf_tpc, - sizeof(tf->tf_tpc), FALSE); - user = db_print_trap(td, tf, count); - trap = 1; - } else { - db_printf("%s() at ", name); - db_printsym(pc, DB_STGY_PROC); - db_printf("\n"); - } - } - return (0); -} - -void -db_trace_self(void) -{ - - db_backtrace(curthread, - (struct frame *)__builtin_frame_address(1), -1); -} - -int -db_trace_thread(struct thread *td, int count) -{ - struct pcb *ctx; - - ctx = kdb_thr_ctx(td); - return (db_backtrace(td, - (struct frame *)(ctx->pcb_sp + SPOFF), count)); -} diff --git a/sys/sun4v/sun4v/dump_machdep.c b/sys/sun4v/sun4v/dump_machdep.c deleted file mode 100644 index c0f797842cee..000000000000 --- a/sys/sun4v/sun4v/dump_machdep.c +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * Copyright (c) 2002 Marcel Moolenaar - * Copyright (c) 2002 Thomas Moestl - * 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 ``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 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - - -CTASSERT(sizeof(struct kerneldumpheader) == DEV_BSIZE); - -static struct kerneldumpheader kdh; -static off_t dumplo, dumppos; - -/* Handle buffered writes. */ -static char buffer[DEV_BSIZE]; -static vm_size_t fragsz; - -#define MAXDUMPSZ (MAXDUMPPGS << PAGE_SHIFT) - -static int -buf_write(struct dumperinfo *di, char *ptr, size_t sz) -{ - size_t len; - int error; - - while (sz) { - len = DEV_BSIZE - fragsz; - if (len > sz) - len = sz; - bcopy(ptr, buffer + fragsz, len); - fragsz += len; - ptr += len; - sz -= len; - if (fragsz == DEV_BSIZE) { - error = dump_write(di, buffer, 0, dumplo, - DEV_BSIZE); - if (error) - return error; - dumplo += DEV_BSIZE; - fragsz = 0; - } - } - - return (0); -} - -static int -buf_flush(struct dumperinfo *di) -{ - int error; - - if (fragsz == 0) - return (0); - - error = dump_write(di, buffer, 0, dumplo, DEV_BSIZE); - dumplo += DEV_BSIZE; - return (error); -} - -static int -reg_write(struct dumperinfo *di, vm_paddr_t pa, vm_size_t size) -{ - struct sparc64_dump_reg r; - - r.dr_pa = pa; - r.dr_size = size; - r.dr_offs = dumppos; - dumppos += size; - return (buf_write(di, (char *)&r, sizeof(r))); -} - -static int -blk_dump(struct dumperinfo *di, vm_paddr_t pa, vm_size_t size) -{ - vm_size_t pos, rsz; - vm_offset_t va; - int c, counter, error, twiddle; - - printf(" chunk at %#lx: %ld bytes ", (u_long)pa, (long)size); - - va = 0L; - error = counter = twiddle = 0; - for (pos = 0; pos < size; pos += MAXDUMPSZ, counter++) { - if (counter % 128 == 0) - printf("%c\b", "|/-\\"[twiddle++ & 3]); - rsz = size - pos; - rsz = (rsz > MAXDUMPSZ) ? MAXDUMPSZ : rsz; -#ifdef notyet - va = TLB_PHYS_TO_DIRECT(pa + pos); -#endif - error = dump_write(di, (void *)va, 0, dumplo, rsz); - if (error) - break; - dumplo += rsz; - - /* Check for user abort. */ - c = cncheckc(); - if (c == 0x03) - return (ECANCELED); - if (c != -1) - printf("(CTRL-C to abort) "); - } - printf("... %s\n", (error) ? "fail" : "ok"); - return (error); -} - -void -dumpsys(struct dumperinfo *di) -{ - struct sparc64_dump_hdr hdr; - vm_size_t size, totsize, hdrsize; - int error, i, nreg; - - /* Calculate dump size. */ - size = 0; - nreg = sparc64_nmemreg; - for (i = 0; i < sparc64_nmemreg; i++) - size += sparc64_memreg[i].mr_size; - /* Account for the header size. */ - hdrsize = roundup2(sizeof(hdr) + sizeof(struct sparc64_dump_reg) * nreg, - DEV_BSIZE); - size += hdrsize; - - totsize = size + 2 * sizeof(kdh); - if (totsize > di->mediasize) { - printf("Insufficient space on device (need %ld, have %ld), " - "refusing to dump.\n", (long)totsize, - (long)di->mediasize); - error = ENOSPC; - goto fail; - } - - /* Determine dump offset on device. */ - dumplo = di->mediaoffset + di->mediasize - totsize; - - mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, di->blocksize); - - printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg); - - /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); - if (error) - goto fail; - dumplo += sizeof(kdh); - - /* Dump the private header. */ - hdr.dh_hdr_size = hdrsize; -#ifdef notyet - /* XXX SUN4V_FIXME */ - hdr.dh_tsb_pa = tsb_kernel_phys; - hdr.dh_tsb_size = tsb_kernel_size; -#endif - hdr.dh_nregions = nreg; - - if (buf_write(di, (char *)&hdr, sizeof(hdr)) != 0) - goto fail; - - dumppos = hdrsize; - /* Now, write out the region descriptors. */ - for (i = 0; i < sparc64_nmemreg; i++) { - error = reg_write(di, sparc64_memreg[i].mr_start, - sparc64_memreg[i].mr_size); - if (error != 0) - goto fail; - } - buf_flush(di); - - /* Dump memory chunks. */ - for (i = 0; i < sparc64_nmemreg; i++) { - error = blk_dump(di, sparc64_memreg[i].mr_start, - sparc64_memreg[i].mr_size); - if (error != 0) - goto fail; - } - - /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); - if (error) - goto fail; - - /* Signal completion, signoff and exit stage left. */ - dump_write(di, NULL, 0, 0, 0); - printf("\nDump complete\n"); - return; - - fail: - /* XXX It should look more like VMS :-) */ - printf("** DUMP FAILED (ERROR %d) **\n", error); -} diff --git a/sys/sun4v/sun4v/exception.S b/sys/sun4v/sun4v/exception.S deleted file mode 100644 index c1e6faa68041..000000000000 --- a/sys/sun4v/sun4v/exception.S +++ /dev/null @@ -1,2025 +0,0 @@ -/* - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$") - -#include "opt_compat.h" -#include "opt_ddb.h" -#include "opt_simulator.h" -#include "opt_trap_trace.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "assym.s" - -#define PMAP_DEBUG - -#define SPILL_FILL_MAGIC_TRAP_ON nop -#define SPILL_FILL_MAGIC_TRAP_OFF nop - -#define REGSIZE 8 - - .register %g2,#ignore - .register %g3,#ignore - .register %g6,#ignore - .register %g7,#ignore - - .globl trap_conversion - -#define PCB_REG %g6 - -#define PUTCHAR(x) \ -0: ; \ - mov x, %o0 ; \ - mov CONS_PUTCHAR, %o5 ; \ - ta FAST_TRAP ; \ - brnz %o0, 0b ; \ - nop - -/* - * Atomically set the reference bit in a tte. - */ -#define TTE_SET_BIT(r1, r2, r3, bit) \ - add r1, TTE_DATA, r1 ; \ - ldx [r1], r2 ; \ -9: or r2, bit, r3 ; \ - casxa [r1] ASI_N, r2, r3 ; \ - cmp r2, r3 ; \ - bne,pn %xcc, 9b ; \ - mov r3, r2 - -#define TTE_SET_REF(r1, r2, r3) TTE_SET_BIT(r1, r2, r3, TD_REF) -#define TTE_SET_W(r1, r2, r3) TTE_SET_BIT(r1, r2, r3, TD_W) - - -/* - * Macros for spilling and filling live windows. - * Here we use the more complicated [regaddr] format which requires - * us to interleave setting the globals in order to be able to use - * imm_asi - we don't ever implicitly assume kernel context as in - * Solaris' spill/fill handlers so that we have the option of using - * block initializing stores - twin doubleword loads could also be - * advantageous but will require an additional macro - * - */ - - -#define SPILL(storer, base, size) \ - storer %l0, [base + (0 * size)] ; \ - storer %l1, [base + (1 * size)] ; \ - storer %l2, [base + (2 * size)] ; \ - storer %l3, [base + (3 * size)] ; \ - storer %l4, [base + (4 * size)] ; \ - storer %l5, [base + (5 * size)] ; \ - storer %l6, [base + (6 * size)] ; \ - storer %l7, [base + (7 * size)] ; \ - storer %i0, [base + (8 * size)] ; \ - storer %i1, [base + (9 * size)] ; \ - storer %i2, [base + (10 * size)] ; \ - storer %i3, [base + (11 * size)] ; \ - storer %i4, [base + (12 * size)] ; \ - storer %i5, [base + (13 * size)] ; \ - storer %i6, [base + (14 * size)] ; \ - storer %i7, [base + (15 * size)] - -#define SPILL_ASI(storer, bias, size, asi) \ - mov 0 + bias, %g1 ;\ - storer %l0, [%sp + %g1]asi ;\ - mov size + bias, %g2 ;\ - storer %l1, [%sp + %g2]asi ;\ - mov (2 * size) + bias, %g3 ;\ - storer %l2, [%sp + %g3]asi ;\ - mov (3 * size) + bias, %g4 ;\ - storer %l3, [%sp + %g4]asi ;\ - add %sp, (4 * size), %g5 ;\ - storer %l4, [%g5 + %g1]asi ;\ - storer %l5, [%g5 + %g2]asi ;\ - storer %l6, [%g5 + %g3]asi ;\ - storer %l7, [%g5 + %g4]asi ;\ - add %g5, (4 * size), %g5 ;\ - storer %i0, [%g5 + %g1]asi ;\ - storer %i1, [%g5 + %g2]asi ;\ - storer %i2, [%g5 + %g3]asi ;\ - storer %i3, [%g5 + %g4]asi ;\ - add %g5, (4 * size), %g5 ;\ - storer %i4, [%g5 + %g1]asi ;\ - storer %i5, [%g5 + %g2]asi ;\ - storer %i6, [%g5 + %g3]asi ;\ - storer %i7, [%g5 + %g4]asi - -/* 16 instructions */ -#define SPILL_ASI_64 \ - stxa %l0, [%g1 + 0x0]%asi ;\ - stxa %i0, [%g1 + 0x40]%asi ;\ - stxa %l1, [%g1 + 0x8]%asi ;\ - stxa %l2, [%g1 + 0x10]%asi ;\ - stxa %l3, [%g1 + 0x18]%asi ;\ - stxa %l4, [%g1 + 0x20]%asi ;\ - stxa %l5, [%g1 + 0x28]%asi ;\ - stxa %l6, [%g1 + 0x30]%asi ;\ - stxa %l7, [%g1 + 0x38]%asi ;\ - stxa %i1, [%g1 + 0x48]%asi ;\ - stxa %i2, [%g1 + 0x50]%asi ;\ - stxa %i3, [%g1 + 0x58]%asi ;\ - stxa %i4, [%g1 + 0x60]%asi ;\ - stxa %i5, [%g1 + 0x68]%asi ;\ - stxa %i6, [%g1 + 0x70]%asi ;\ - stxa %i7, [%g1 + 0x78]%asi - -/* 23 instructions */ -#define FILL(loader, bias, size, asi) \ - mov 0 + bias, %g1 ;\ - loader [%sp + %g1]asi, %l0 ;\ - mov size + bias, %g2 ;\ - loader [%sp + %g2]asi, %l1 ;\ - mov (2 * size) + bias, %g3 ;\ - loader [%sp + %g3]asi, %l2 ;\ - mov (3 * size) + bias, %g4 ;\ - loader [%sp + %g4]asi, %l3 ;\ - add %sp, (4 * size), %g5 ;\ - loader [%g5 + %g1]asi, %l4 ;\ - loader [%g5 + %g2]asi, %l5 ;\ - loader [%g5 + %g3]asi, %l6 ;\ - loader [%g5 + %g4]asi, %l7 ;\ - add %g5, (4 * size), %g5 ;\ - loader [%g5 + %g1]asi, %i0 ;\ - loader [%g5 + %g2]asi, %i1 ;\ - loader [%g5 + %g3]asi, %i2 ;\ - loader [%g5 + %g4]asi, %i3 ;\ - add %g5, (4 * size), %g5 ;\ - loader [%g5 + %g1]asi, %i4 ;\ - loader [%g5 + %g2]asi, %i5 ;\ - loader [%g5 + %g3]asi, %i6 ;\ - loader [%g5 + %g4]asi, %i7 - -#define SPILL_ASI_SET(storer, size) \ - storer %l0, [%g1 + (0 * size)]%asi ;\ - storer %l1, [%g1 + (1 * size)]%asi ;\ - storer %l2, [%g1 + (2 * size)]%asi ;\ - storer %l3, [%g1 + (3 * size)]%asi ;\ - storer %l4, [%g1 + (4 * size)]%asi ;\ - storer %l5, [%g1 + (5 * size)]%asi ;\ - storer %l6, [%g1 + (6 * size)]%asi ;\ - storer %l7, [%g1 + (7 * size)]%asi ;\ - storer %i0, [%g1 + (8 * size)]%asi ;\ - storer %i1, [%g1 + (9 * size)]%asi ;\ - storer %i2, [%g1 + (10 * size)]%asi ;\ - storer %i3, [%g1 + (11 * size)]%asi ;\ - storer %i4, [%g1 + (12 * size)]%asi ;\ - storer %i5, [%g1 + (13 * size)]%asi ;\ - storer %i6, [%g1 + (14 * size)]%asi ;\ - storer %i7, [%g1 + (15 * size)]%asi - -/* 16 instructions */ -#define FILL_ASI_SET(loader, size) \ - loader [%g1 + 0x0]%asi, %l0 ;\ - loader [%g1 + (size * 1)]%asi, %l1 ;\ - loader [%g1 + (size * 2)]%asi, %l2 ;\ - loader [%g1 + (size * 3)]%asi, %l3 ;\ - loader [%g1 + (size * 4)]%asi, %l4 ;\ - loader [%g1 + (size * 5)]%asi, %l5 ;\ - loader [%g1 + (size * 6)]%asi, %l6 ;\ - loader [%g1 + (size * 7)]%asi, %l7 ;\ - loader [%g1 + (size * 8)]%asi, %i0 ;\ - loader [%g1 + (size * 9)]%asi, %i1 ;\ - loader [%g1 + (size * 10)]%asi, %i2 ;\ - loader [%g1 + (size * 11)]%asi, %i3 ;\ - loader [%g1 + (size * 12)]%asi, %i4 ;\ - loader [%g1 + (size * 13)]%asi, %i5 ;\ - loader [%g1 + (size * 14)]%asi, %i6 ;\ - loader [%g1 + (size * 15)]%asi, %i7 - -/* 9 instructions */ -#define FILL_DW \ - prefetch [%g1 + 0x40], #one_read ;\ - ldda [%g1 + 0]%asi, %l0 ;\ - ldda [%g1 + 0x10]%asi, %l2 ;\ - ldda [%g1 + 0x20]%asi, %l4 ;\ - ldda [%g1 + 0x30]%asi, %l6 ;\ - ldda [%g1 + 0x40]%asi, %i0 ;\ - ldda [%g1 + 0x50]%asi, %i2 ;\ - ldda [%g1 + 0x60]%asi, %i4 ;\ - ldda [%g1 + 0x70]%asi, %i6 - -#include - /* - * Clean window traps occur when %cleanwin is zero to ensure that data - * is not leaked between address spaces in registers. - */ - .macro clean_window - clr %o0 - clr %o1 - clr %o2 - clr %o3 - clr %o4 - clr %o5 - clr %o6 - clr %o7 - clr %l0 - clr %l1 - clr %l2 - clr %l3 - clr %l4 - clr %l5 - clr %l6 - rdpr %cleanwin, %l7 - inc %l7 - wrpr %l7, 0, %cleanwin - clr %l7 - retry - .align 128 - .endm - - .macro tl0_split - .endm - - .macro tl0_setup type - rdpr %tt, %g3 - sub %g0, 1, %g4 - set trap, %g1 - ba %xcc, tl0_trap - mov \type, %g2 - .endm - - /* - * Generic trap type. Call trap() with the specified type. - */ - .macro tl0_gen type - tl0_setup \type - .align 32 - .endm - - /* - * This is used to suck up the massive swaths of reserved trap types. - * Generates count "reserved" trap vectors. - */ - - .macro tl0_reserved count - .rept \count - tl0_gen T_RESERVED - .align 32 - .endr - .endm - - .macro tl1_setup type - rdpr %tt, %g3 - sub %g0, 1, %g4 - set trap, %g1 - ba %xcc, tl1_trap - mov \type, %g2 - .endm - - .macro tl1_gen type - tl1_setup \type - .align 32 - .endm - - .macro tl1_reserved count - .rept \count - tl1_gen T_RESERVED - .endr - .endm - - .macro insn_excptn - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_D_ADDR, %g2 - ldxa [%g1 + %g2]ASI_REAL, %g3 - sub %g0, 1, %g4 - set trap, %g1 - ba,pt %xcc, tl0_trap - mov T_INSTRUCTION_EXCEPTION, %g2 - - .align 32 - .endm - - .macro insn_miss - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_I_TYPE, %g2 - mov MMFSA_I_ADDR, %g3 - mov MMFSA_I_CTX, %g7 - ldxa [%g1 + %g2]ASI_REAL, %g4 - ba,pt %xcc, tsb_miss_handler - ldxa [%g1 + %g3]ASI_REAL, %g5 - .align 32 - .endm - - .macro data_excptn - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_D_ADDR, %g2 - ba,pt %xcc, data_excptn_fault - ldxa [%g1 + %g2]ASI_REAL, %g3 - .align 32 - .endm - -ENTRY(data_excptn_fault) - mov MMFSA_D_CTX, %g7 - ldxa [%g1 + %g7]ASI_REAL, %g4 - sllx %g4, TRAP_CTX_SHIFT, %g4 - or %g4, T_DATA_EXCEPTION, %g2 - set trap, %g1 - ba,pt %xcc, tl0_trap - sub %g0, 1, %g4 -END(data_excptn_fault) - - .macro data_miss - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_D_TYPE, %g2 - mov MMFSA_D_ADDR, %g3 - mov MMFSA_D_CTX, %g7 - ldxa [%g1 + %g2]ASI_REAL, %g4 - ba,pt %xcc, tsb_miss_handler - ldxa [%g1 + %g3]ASI_REAL, %g5 - .align 32 - .endm - - .macro data_prot - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_D_ADDR, %g3 - mov MMFSA_D_CTX, %g7 - ba,pt %xcc, tsb_miss_handler - ldxa [%g1 + %g3]ASI_REAL, %g5 - .align 32 - .endm - - .macro tl0_align - GET_MMFSA_SCRATCH(%g1) - mov MMFSA_D_ADDR, %g3 - mov MMFSA_D_CTX, %g7 - ba,pt %xcc, align_fault - ldxa [%g1 + %g3]ASI_REAL, %g3 - .align 32 - .endm - -ENTRY(align_fault) - ldxa [%g1 + %g7]ASI_REAL, %g4 - sllx %g4, TRAP_CTX_SHIFT, %g4 - or %g4, T_MEM_ADDRESS_NOT_ALIGNED, %g2 - set trap, %g1 - ba,pt %xcc, tl0_trap - sub %g0, 1, %g4 -END(align_fault) - - .macro cpu_mondo - ba,a,pt %xcc, cpu_mondo - .align 32 - .endm - - .macro dev_mondo - ba,a,pt %xcc, dev_mondo - .align 32 - .endm - - .macro resumable_error - !MAGIC_TRAP_ON - !MAGIC_EXIT - clr %g3 - sub %g0, 1, %g4 - set trap, %g1 - ba,pt %xcc, tl0_trap - mov T_RESUMABLE_ERROR, %g2 - .align 32 - .endm - - .macro nonresumable_error - clr %g3 - sub %g0, 1, %g4 - set trap, %g1 - ba,pt %xcc, tl0_trap - mov T_NONRESUMABLE_ERROR, %g2 - .align 32 - .endm - - -#define ALIGN_128 .align 128 -#define SYNC #Sync -#define LOOKASIDE #Lookaside - -#ifdef USE_FAST_SPILLFILL -#define spill_64bit_asi(asival, asival_unaligned, target) \ - wr %g0, asival, %asi ; \ - add %sp, SPOFF, %g1 ; \ - SPILL_ASI_64 ; \ - membar LOOKASIDE ; \ - saved ; \ - retry ; \ - .skip (31-21)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 - -#define spill_64clean(asival, asival_unaligned, target) \ - wr %g0, asival, %asi ; \ - add %sp, SPOFF, %g1 ; \ - SPILL_ASI_64 ; \ - membar LOOKASIDE ; \ - b spill_clean ; \ - mov WSTATE_USER64, %g7 ; \ - .skip (31-21)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 - -#define fill_64bit_asi(asival, asival_unaligned, target) \ - add %sp, SPOFF, %g1 ; \ - wr %g0, asival, %asi ; \ - FILL_DW ; \ - restored ; \ - retry ; \ - .skip (31-13)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 -#else -#define spill_64bit_asi(asival, asival_unaligned, target) \ - wr %g0, asival_unaligned, %asi ; \ - add %sp, SPOFF, %g1 ; \ - SPILL_ASI_SET(stxa, 8) ; \ - saved ; \ - retry ; \ - .skip (31-20)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 - -#define spill_64clean(asival, asival_unaligned, target) \ - wr %g0, asival_unaligned, %asi ; \ - add %sp, SPOFF, %g1 ; \ - SPILL_ASI_SET(stxa, 8) ; \ - b spill_clean ; \ - mov WSTATE_USER64, %g7 ; \ - .skip (31-20)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 - -#define fill_64bit_asi(asival, asival_unaligned, target) \ - wr %g0, asival_unaligned, %asi ; \ - add %sp, SPOFF, %g1 ; \ - FILL_ASI_SET(ldxa, 8) ; \ - restored ; \ - retry ; \ - .skip (31-20)*4 ; \ - ba,a,pt %xcc, fault_64bit_##target ; \ - ALIGN_128 -#endif - -#define spill_32bit_asi(asi, target) \ - srl %sp, 0, %sp ; \ - SPILL_FILL_MAGIC_TRAP_ON; \ - SPILL_ASI(sta, 0, 4, asi) ; \ - saved ; \ - SPILL_FILL_MAGIC_TRAP_OFF; \ - retry ; \ - .skip (31-28)*4 ; \ - ba,a,pt %xcc, fault_32bit_##target ; \ - ALIGN_128 - -#define spill_32clean(asi, target) \ - srl %sp, 0, %sp ; \ - SPILL_FILL_MAGIC_TRAP_ON; \ - SPILL_ASI(sta, 0, 4, asi) ; \ - b spill_clean ; \ - mov WSTATE_USER32, %g7 ; \ - .skip (31-27)*4 ; \ - ba,a,pt %xcc, fault_32bit_##target ; \ - ALIGN_128 - -#define fill_32bit_asi(asi, target) \ - srl %sp, 0, %sp ; \ - SPILL_FILL_MAGIC_TRAP_ON; \ - FILL(lda, 0, 4, asi) ; \ - restored ; \ - retry ; \ - .skip (31-27)*4 ; \ - ba,a,pt %xcc, fault_32bit_##target ; \ - ALIGN_128 - -.align 128 -ENTRY(fill_64bit_slow_fn0) -fill_slow_start: - FILL_ASI_SET(ldxa, 8); - restored ; - retry ; - .skip (31-18)*4 ; - ba,a,pt %xcc, fault_64bit_fn0 ; - .align 128 -END(fill_64bit_slow_fn0) -ENTRY(fill_64bit_slow_not) - FILL_ASI_SET(ldxa, 8); - restored ; - retry ; - .skip (31-18)*4 ; - ba,a,pt %xcc, fault_64bit_not ; - .align 128 -END(fill_64bit_slow_not) -fill_slow_end: - - .macro spill_32bit_primary_sn0 - spill_32bit_asi(ASI_AIUP, sn0) - .endm - - .macro spill_64bit_primary_sn0 - spill_64bit_asi(ASI_LDSTBI_AIUP, ASI_AIUP, sn0) - .endm - - .macro spill_32clean_primary_sn0 - spill_32clean(ASI_AIUP, sn0) - .endm - - .macro spill_64clean_primary_sn0 - spill_64clean(ASI_LDSTBI_AIUP, ASI_AIUP, sn0) - .endm - - .macro spill_32bit_nucleus_not - spill_32bit_asi(ASI_N, not) - .endm - - .macro spill_64bit_nucleus_not - spill_64bit_asi(ASI_LDSTBI_N, ASI_N, not) - .endm - - .macro spill_32bit_secondary_so0 - spill_32bit_asi(ASI_AIUS, so0) - .endm - - .macro spill_64bit_secondary_so0 - spill_64bit_asi(ASI_LDSTBI_AIUS, ASI_AIUS, so0) - .endm - - .macro fill_32bit_primary_fn0 - fill_32bit_asi(ASI_AIUP, fn0) - .endm - - .macro fill_64bit_primary_fn0 - fill_64bit_asi(ASI_LDSTBI_AIUP, ASI_AIUP, fn0) - .endm - - .macro fill_32bit_nucleus_not - fill_32bit_asi(ASI_N, not) - .endm - - .macro fill_64bit_nucleus_not - fill_64bit_asi(ASI_LDSTBI_N, ASI_N, not) - .endm - - .macro spill_32bit_tt1_primary_sn1 - ba,a,pt %xcc, fault_32bit_sn1 - nop - .align 128 - .endm - - .macro spill_64bit_tt1_primary_sn1 - ba,a,pt %xcc, fault_64bit_sn1 - nop - .align 128 - .endm - - .macro spill_64bit_ktt1_sk - ba,a,pt %xcc, fault_64bit_sk - nop - .align 128 - .endm - - .macro spill_mixed_ktt1_sk - btst 1, %sp - bz,a,pt %xcc, fault_32bit_sk - srl %sp, 0, %sp - ba,a,pt %xcc, fault_64bit_sk - nop - .align 128 - .endm - - .macro spill_32bit_tt1_secondary_so1 - ba,a,pt %xcc, fault_32bit_so1 - nop - .align 128 - .endm - - .macro spill_64bit_tt1_secondary_so1 - ba,a,pt %xcc, fault_64bit_so1 - nop - .align 128 - .endm - - .macro spill_mixed -! MAGIC_EXIT - nop - .align 128 - .endm - - .macro fill_mixed -! MAGIC_EXIT - nop - .align 128 - .endm - - .macro tl1_align - ba,a,pt %xcc, tl1_trap - .align 32 - .endm - - .macro tl0_pil_entry level, mask - wrpr %g0, 1, %gl - set \mask, %g1 - clr %g2 - clr %g3 - wr %g1, 0, %clear_softint - ba %xcc, tl0_intr - mov \level, %g4 - .align 32 - .endm - -#define INTR(level, traplvl) \ - tl ## traplvl ## _pil_entry level, 1 << level - -#define TICK(traplvl) \ - tl ## traplvl ## _pil_entry PIL_TICK, 1 - -#define INTR_LEVEL(tl) \ - INTR(1, tl) ; \ - INTR(2, tl) ; \ - INTR(3, tl) ; \ - INTR(4, tl) ; \ - INTR(5, tl) ; \ - INTR(6, tl) ; \ - INTR(7, tl) ; \ - INTR(8, tl) ; \ - INTR(9, tl) ; \ - INTR(10, tl) ; \ - INTR(11, tl) ; \ - INTR(12, tl) ; \ - INTR(13, tl) ; \ -tick_ ## tl ## _entry: \ - TICK(tl) ; \ - INTR(15, tl) ; - - .macro tl0_pil - INTR_LEVEL(0) - .endm - - - .macro tl0_syscall - clr %g3 - sub %g0, 1, %g4 - set syscall, %g1 - ba %xcc, tl0_trap - mov T_SYSCALL, %g2 - .align 32 - .endm - -#ifdef KDTRACE - .macro dtrace_fasttrap - sethi %hi(dtrace_fasttrap_probe_ptr), %g4 - ldx [%g4 + %lo(dtrace_fasttrap_probe_ptr)], %g4 - set dtrace_fasttrap_probe, %g1 - brnz,pn %g4, tl0_utrap - sub %g0, 1, %g4 - .align 32 - .endm - - .macro dtrace_pid - set dtrace_pid_probe, %g1 - ba,pt %xcc, tl0_utrap - sub %g0, 1, %g4 - .align 32 - .endm - - .macro dtrace_return - set dtrace_return_probe, %g1 - ba,pt %xcc, tl0_utrap - sub %g0, 1, %g4 - .align 32 - .endm -#else - .macro dtrace_fasttrap - nop - .align 32 - .endm - - .macro dtrace_pid - nop - .align 32 - .endm - - .macro dtrace_return - nop - .align 32 - .endm -#endif - - ! fetch FP context into local registers - .macro tl0_fpemu_context - GET_PCB(PCB_REG) ! 3 instructions - ldx [PCB_REG + PCB_TSTATE], %l5 ! %tstate - ldx [PCB_REG + PCB_TPC], %l6 ! %tpc - ldx [PCB_REG + PCB_TNPC], %l7 ! %tnpc - ldx [PCB_REG + PCB_TT], %g2 ! %tt - ba,a,pt %xcc, tl0_fpemu_context - .align 32 - .endm - -ENTRY(tl0_fpemu_context) - mov %g2, %o0 - clr %o1 - ldx [PCB_REG + PCB_SFAR], %o4 - - rd %fprs, %l1 - or %l1, FPRS_FEF, %l2 - wr %l2, 0, %fprs - stx %fsr, [PCB_REG + PCB_PAD] - ldx [PCB_REG + PCB_PAD], %l4 - wr %l1, 0, %fprs - - sub %fp, CCFSZ, %sp - done -END(tl0_fpemu_context) - - .macro tl0_fp_restore - GET_PCB(PCB_REG) ! 3 instructions - ldx [%g6 + PCB_FLAGS], %g1 - ba,pt %xcc, tl0_fp_restore - wr %g0, FPRS_FEF, %fprs - .align 32 - .endm - - .macro tl0_fp_enable - GET_PCB(PCB_REG) ! 3 instructions - ldx [PCB_REG + PCB_FLAGS], %g1 - andcc %g1, PCB_FEF, %g0 - bnz,pt %xcc, tl0_fp_restore - wr %g0, FPRS_FEF, %fprs - retry - .align 32 - .endm - -ENTRY(tl0_fp_restore) - andn %g1, PCB_FEF, %g1 - stx %g1, [%g6 + PCB_FLAGS] - - ldd [PCB_REG + PCB_UFP + (0 * 64)], %f0 - ldd [PCB_REG + PCB_UFP + (1 * 64)], %f16 - ldd [PCB_REG + PCB_UFP + (2 * 64)], %f32 - ldd [PCB_REG + PCB_UFP + (3 * 64)], %f48 - retry -END(tl0_fp_restore) - - .macro tl1_insn_excptn - nop - .align 32 - .endm - - - .macro tl1_soft count - .rept \count - tl1_gen T_SOFT | T_KERNEL - .endr - .endm - - .sect .trap - .align 0x8000 - .globl tl0_base -tl0_base: - tl0_reserved 8 ! 0x0-0x7 -tl0_insn_excptn: - insn_excptn ! 0x8 -tl0_insn_miss: - insn_miss ! 0x9 - tl0_reserved 6 ! 0xa-0xf -tl0_insn_illegal: - tl0_gen T_ILLEGAL_INSTRUCTION ! 0x10 -tl0_priv_opcode: - tl0_gen T_PRIVILEGED_OPCODE ! 0x11 - tl0_reserved 14 ! 0x12-0x1f -tl0_fp_disabled: - tl0_fp_enable ! 0x20 -tl0_fp_ieee: - tl0_gen T_FP_EXCEPTION_IEEE_754 ! 0x21 -tl0_fp_other: - tl0_gen T_FP_EXCEPTION_OTHER ! 0x22 -tl0_tag_ovflw: - tl0_gen T_TAG_OVERFLOW ! 0x23 -tl0_clean_window: - clean_window ! 0x24 -tl0_divide: - tl0_gen T_DIVISION_BY_ZERO ! 0x28 - tl0_reserved 7 ! 0x29-0x2f -tl0_data_excptn: - data_excptn ! 0x30 -tl0_data_miss: - data_miss ! 0x31 - tl0_reserved 2 ! 0x32-0x33 -tl0_align: - tl0_align ! 0x34 -tl0_align_lddf: - tl0_gen T_RESERVED ! 0x35 -tl0_align_stdf: - tl0_gen T_RESERVED ! 0x36 -tl0_priv_action: - tl0_gen T_PRIVILEGED_ACTION ! 0x37 - tl0_reserved 9 ! 0x38-0x40 -tl0_intr_level_41: - tl0_pil ! 0x41-0x4f - tl0_reserved 18 ! 0x50-0x61 -tl0_watch_virt_62: - tl0_gen T_VA_WATCHPOINT ! 0x62 - tl0_reserved 9 ! 0x63-0x6b -tl0_data_prot_6c: - data_prot ! 0x6c - tl0_reserved 9 ! 0x6d-0x75 -tl0_breakpoint_76: - tl0_gen T_BREAKPOINT ! 0x76 - tl0_reserved 5 ! 0x77-0x7b -tl0_cpu_mondo_7c: - cpu_mondo ! 0x7c -tl0_dev_mondo_7d: - dev_mondo ! 0x7d -tl0_resumable_error_7e: - resumable_error ! 0x7e -tl0_nonresumable_error_7f: - nonresumable_error ! 0x7f -tl0_spill_n_normal_80: -tl0_spill_0_normal: - tl0_reserved 4 ! 0x80 -tl0_spill_1_normal: - spill_32bit_primary_sn0 ! 0x84 -tl0_spill_2_normal: - spill_64bit_primary_sn0 ! 0x88 -tl0_spill_3_normal: - spill_32clean_primary_sn0 ! 0x8c -tl0_spill_4_normal: - spill_64clean_primary_sn0 ! 0x90 -tl0_spill_5_normal: - spill_32bit_nucleus_not ! 0x94 -tl0_spill_6_normal: - spill_64bit_nucleus_not ! 0x98 -tl0_spill_7_normal: - spill_mixed ! 0x9c -tl0_spill_0_other: - tl0_reserved 4 ! 0xa0 -tl0_spill_1_other: - spill_32bit_secondary_so0 ! 0xa4 -tl0_spill_2_other: - spill_64bit_secondary_so0 ! 0xa8 -tl0_spill_3_other: - spill_32bit_secondary_so0 ! 0xac -tl0_spill_4_other: - spill_64bit_secondary_so0 ! 0xb0 -tl0_spill_5_other: - tl0_reserved 4 ! 0xb4 -tl0_spill_6_other: - tl0_reserved 4 ! 0xb8 -tl0_spill_7_other: - tl0_reserved 4 ! 0xbc -tl0_fill_n_normal: - tl0_reserved 4 ! 0xc0 -tl0_fill_1_normal: - fill_32bit_primary_fn0 ! 0xc4 -tl0_fill_2_normal: - fill_64bit_primary_fn0 ! 0xc8 -tl0_fill_3_normal: - fill_32bit_primary_fn0 ! 0xcc -tl0_fill_4_normal: - fill_64bit_primary_fn0 ! 0xd0 -tl0_fill_5_normal: - fill_32bit_nucleus_not ! 0xd4 -tl0_fill_6_normal: - fill_64bit_nucleus_not ! 0xd8 -tl0_fill_7_normal: - fill_mixed ! 0xdc -tl0_fill_n_other_e0: - tl0_reserved 32 ! 0xe0-0xff -tl0_soft_100: - tl0_gen T_SYSCALL ! 0x100 - tl0_gen T_BREAKPOINT ! 0x101 - tl0_gen T_DIVISION_BY_ZERO ! 0x102 - tl0_reserved 1 ! 0x103 - tl0_gen T_CLEAN_WINDOW ! 0x104 - tl0_gen T_RANGE_CHECK ! 0x105 - tl0_gen T_FIX_ALIGNMENT ! 0x106 - tl0_gen T_INTEGER_OVERFLOW ! 0x107 - tl0_gen T_SYSCALL ! 0x108 - tl0_gen T_SYSCALL ! 0x109 - tl0_fp_restore ! 0x10a - tl0_fpemu_context ! 0x10b - tl0_reserved 4 ! 0x10c-0x10f - tl0_gen T_TRAP_INSTRUCTION_16 ! 0x110 - tl0_gen T_TRAP_INSTRUCTION_17 ! 0x111 - tl0_gen T_TRAP_INSTRUCTION_18 ! 0x112 - tl0_gen T_TRAP_INSTRUCTION_19 ! 0x113 - tl0_gen T_TRAP_INSTRUCTION_20 ! 0x114 - tl0_gen T_TRAP_INSTRUCTION_21 ! 0x115 - tl0_gen T_TRAP_INSTRUCTION_22 ! 0x116 - tl0_gen T_TRAP_INSTRUCTION_23 ! 0x117 - tl0_gen T_TRAP_INSTRUCTION_24 ! 0x118 - tl0_gen T_TRAP_INSTRUCTION_25 ! 0x119 - tl0_gen T_TRAP_INSTRUCTION_26 ! 0x11a - tl0_gen T_TRAP_INSTRUCTION_27 ! 0x11b - tl0_gen T_TRAP_INSTRUCTION_28 ! 0x11c - tl0_gen T_TRAP_INSTRUCTION_29 ! 0x11d - tl0_gen T_TRAP_INSTRUCTION_30 ! 0x11e - tl0_gen T_TRAP_INSTRUCTION_31 ! 0x11f - tl0_reserved 24 ! 0x120-0x137 -tl0_dtrace_pid: - dtrace_pid ! 0x138 -tl0_dtrace_fasttrap: - dtrace_fasttrap ! 0x139 -tl0_dtrace_return: - dtrace_return ! 0x13a - tl0_reserved 5 ! 0x13b - 0x13f - tl0_gen T_SYSCALL ! 0x140 LP64 system call - tl0_syscall ! 0x141 - tl0_gen T_SYSCALL ! 0x142 - tl0_gen T_SYSCALL ! 0x143 - tl0_reserved 188 ! 0x144-0x1ff -tl1_base: - tl1_reserved 9 ! 0x200-0x208 -tl1_insn_miss_209: - insn_miss ! 0x209 - tl1_reserved 26 ! 0x20a-0x223 -tl1_clean_window_224: - clean_window ! 0x224 -tl1_divide_228: - tl1_reserved 8 ! 0x228-0x22f -tl1_data_excptn_230: - data_excptn ! 0x230 -tl1_data_miss_231: - data_miss ! 0x231 - tl1_reserved 2 ! 0x232-0x233 -tl1_align: - tl1_align ! 0x234 - tl1_reserved 55 ! 0x235-0x26b -tl1_data_prot: - data_prot ! 0x26c - tl1_reserved 18 ! 0x26c-0x27e -tl1_nonresumable_error: - nonresumable_error ! 0x27f -tl1_spill_n_normal: -tl1_spill_0_normal: - tl1_reserved 4 ! 0x280 -tl1_spill_1_normal: - spill_32bit_tt1_primary_sn1 ! 0x284 -tl1_spill_2_normal: - spill_64bit_tt1_primary_sn1 ! 0x288 -tl1_spill_3_normal: - spill_32bit_tt1_primary_sn1 ! 0x28c -tl1_spill_4_normal: - spill_64bit_tt1_primary_sn1 ! 0x290 -tl1_spill_5_normal: - tl1_reserved 4 ! 0x294 -tl1_spill_6_normal: - spill_64bit_ktt1_sk ! 0x298 -tl1_spill_7_normal: - spill_mixed_ktt1_sk ! 0x29c -tl1_spill_n_other: -tl1_spill_0_other: - tl1_reserved 4 ! 0x2a0 -tl1_spill_1_other: - spill_32bit_tt1_secondary_so1 ! 0x2a4 -tl1_spill_2_other: - spill_64bit_tt1_secondary_so1 ! 0x2a8 -tl1_spill_3_other: - spill_32bit_tt1_secondary_so1 ! 0x2ac -tl1_spill_4_other: - spill_64bit_tt1_secondary_so1 ! 0x2b0 -tl1_spill_5_other: - tl1_reserved 4 ! 0x2b4 -tl1_spill_6_other: - tl1_reserved 4 ! 0x2b8 -tl1_spill_7_other: - tl1_reserved 4 ! 0x2bc -tl1_fill_n_normal: - tl1_reserved 32 ! 0x2c0-0x2df -tl1_fill_n_other: - tl1_reserved 32 ! 0x2e0-0x2ff -tl1_soft_traps: - tl1_reserved 256 -.globl tl1_end -tl1_end: - -spill_clean: - sethi %hi(nwin_minus_one), %g5 - ld [%g5 + %lo(nwin_minus_one)], %g5 - rdpr %cwp, %g6 - deccc %g6 - movneg %xcc, %g5, %g6 ! if (--%cwp < 0) %g6 = nwin-1 - wrpr %g6, %cwp - clr %l0 - clr %l1 - clr %l2 - clr %l3 - clr %l4 - clr %l5 - clr %l6 - clr %l7 - wrpr %g0, %g7, %wstate - saved - retry - - - -#define KWBUF64_TO_STACK(SBP,SPP,TMP) \ - ldx [SBP + (0*8)], TMP; \ - stx TMP, [SPP + SPOFF + 0]; \ - ldx [SBP + (1*8)], TMP; \ - stx TMP, [SPP + SPOFF + 8]; \ - ldx [SBP + (2*8)], TMP; \ - stx TMP, [SPP + SPOFF + 16]; \ - ldx [SBP + (3*8)], TMP; \ - stx TMP, [SPP + SPOFF + 24]; \ - ldx [SBP + (4*8)], TMP; \ - stx TMP, [SPP + SPOFF + 32]; \ - ldx [SBP + (5*8)], TMP; \ - stx TMP, [SPP + SPOFF + 40]; \ - ldx [SBP + (6*8)], TMP; \ - stx TMP, [SPP + SPOFF + 48]; \ - ldx [SBP + (7*8)], TMP; \ - stx TMP, [SPP + SPOFF + 56]; \ - ldx [SBP + (8*8)], TMP; \ - stx TMP, [SPP + SPOFF + 64]; \ - ldx [SBP + (9*8)], TMP; \ - stx TMP, [SPP + SPOFF + 72]; \ - ldx [SBP + (10*8)], TMP; \ - stx TMP, [SPP + SPOFF + 80]; \ - ldx [SBP + (11*8)], TMP; \ - stx TMP, [SPP + SPOFF + 88]; \ - ldx [SBP + (12*8)], TMP; \ - stx TMP, [SPP + SPOFF + 96]; \ - ldx [SBP + (13*8)], TMP; \ - stx TMP, [SPP + SPOFF + 104]; \ - ldx [SBP + (14*8)], TMP; \ - stx TMP, [SPP + SPOFF + 112]; \ - ldx [SBP + (15*8)], TMP; \ - stx TMP, [SPP + SPOFF + 120]; - - -#define fill_64bit_rtt(asi_num) \ - wr %g0, asi_num, %asi ;\ - rdpr %cwp, %g1 ;\ - sub %g1, 1, %g1 ;\ - wrpr %g1, %cwp ;\ - ldxa [%sp + SPOFF + 0]%asi, %l0 ;\ - ldxa [%sp + SPOFF + 8]%asi, %l1 ;\ - ldxa [%sp + SPOFF + 16]%asi, %l2 ;\ - ldxa [%sp + SPOFF + 24]%asi, %l3 ;\ - ldxa [%sp + SPOFF + 32]%asi, %l4 ;\ - ldxa [%sp + SPOFF + 40]%asi, %l5 ;\ - ldxa [%sp + SPOFF + 48]%asi, %l6 ;\ - ldxa [%sp + SPOFF + 56]%asi, %l7 ;\ - ldxa [%sp + SPOFF + 64]%asi, %i0 ;\ - ldxa [%sp + SPOFF + 72]%asi, %i1 ;\ - ldxa [%sp + SPOFF + 80]%asi, %i2 ;\ - ldxa [%sp + SPOFF + 88]%asi, %i3 ;\ - ldxa [%sp + SPOFF + 96]%asi, %i4 ;\ - ldxa [%sp + SPOFF + 104]%asi, %i5 ;\ - ldxa [%sp + SPOFF + 112]%asi, %i6 ;\ - ldxa [%sp + SPOFF + 120]%asi, %i7 ;\ - restored ;\ - add %g1, 1, %g1 ;\ - wrpr %g1, %cwp - - - - -ENTRY(utl0) - SAVE_GLOBALS(%l7) - rd %asi, %g1 - SAVE_OUTS(%l7) - stx %g1, [%l7 + TF_ASI] - GET_PCPU_SCRATCH_SLOW(%g6) - wrpr %g0, PSTATE_KERNEL, %pstate ! enable ints - - brnz %o1, common_utrap - nop - call spinlock_enter - nop -common_uintr: - jmpl %l3, %o7 ! call interrupt handler - mov %l7, %o0 - call spinlock_exit - nop - ba,pt %xcc, user_rtt - nop -common_utrap: - jmpl %l3, %o7 ! call trap handler / syscall - mov %l7, %o0 - - ldx [PCPU_REG + PC_CURPCB], %g6 - ldx [%g6 + PCB_KSTACK], %g6 - sub %g6, TF_SIZEOF, %sp - add %sp, REGOFF + SPOFF, %l7 -ENTRY(user_rtt) - ! pil handling needs to be re-visited - wrpr %g0, PIL_TICK, %pil - ldx [PCPU(CURTHREAD)], %l4 - lduw [%l4 + TD_FLAGS], %l1 - ldx [%l4 + TD_MD + MD_SAVED_PIL], %l0 - set TDF_ASTPENDING | TDF_NEEDRESCHED, %l2 - and %l1, %l2, %l1 - brz,a,pt %l1, 1f - nop - - ! handle AST and retry return - wrpr %g0, %l0, %pil - call ast - mov %l7, %o0 - ba,pt %xcc, user_rtt - nop - -1: - ldx [PCPU_REG + PC_CURPCB], %g6 - ldx [%g6 + PCB_NSAVED], %l1 - brz,a,pt %l1, 2f - nop - wrpr %g0, %l0, %pil - mov T_SPILL, %o1 - call trap - mov %l7, %o0 - ba,pt %xcc, user_rtt - nop -2: - - ld [%l7 + TF_WSTATE], %l3 - ! - ! restore user globals and outs - ! - rdpr %pstate, %l1 - ldx [%l7 + TF_ASI], %g1 - wrpr %l1, PSTATE_IE, %pstate - wr %g1, 0, %asi - RESTORE_GLOBALS_USER(%l7) - wrpr %g0, 1, %gl - RESTORE_OUTS(%l7) - - wrpr %g0, 0, %pil ! drop pil to 0 - wrpr %g0, 1, %tl ! raise tl -> 1 before setting pcontext - - mov MMU_CID_S, %g1 - GET_MMU_CONTEXT(%g1, %g2) - mov MMU_CID_P, %g1 - sethi %hi(FLUSH_ADDR), %g3 - SET_MMU_CONTEXT(%g1, %g2) - flush %g3 ! flush required by immu - ! hangover from US I - ! - ! setup trap regs - ! - - ldx [%l7 + TF_TPC], %g1 - ldx [%l7 + TF_TNPC], %g2 - ldx [%l7 + TF_TSTATE], %l0 - ldx [%l7 + TF_FPRS], %l1 - - wrpr %g1, %tpc - wrpr %g2, %tnpc - andn %l0, TSTATE_CWP_MASK, %g6 - - wr %g0, FPRS_FEF, %fprs - ldx [%l7 + TF_FSR], %fsr - wr %l1, 0, %fprs - - - ! - ! switch "other" windows back to "normal" windows and - ! restore to window we originally trapped in - ! - rdpr %otherwin, %g1 - wrpr %g0, 0, %otherwin - add %l3, WSTATE_CLEAN_OFFSET, %l3 ! convert to "clean" wstate - wrpr %g0, %l3, %wstate - wrpr %g0, %g1, %canrestore - - rdpr %canrestore, %g1 - brnz %g1, 3f - nop ! no trap, use restore directly - rdpr %cwp, %g1 - wrpr %g1, %g6, %tstate ! needed by wbuf recovery code - ! hand craft the restore to avoid getting to TL > 2 - rdpr %wstate, %g1 - btst 1, %g1 - beq 4f - nop - .global rtt_fill_start -rtt_fill_start: -#if 0 - fill_32bit_rtt(ASI_AIUP) - ba,a 3f -#endif -4: - membar #Lookaside - fill_64bit_rtt(ASI_AIUP) - .global rtt_fill_end -rtt_fill_end: -3: - restore ! should not trap -2: - - ! - ! set %cleanwin to %canrestore - ! set %tstate to the correct %cwp - ! retry resumes user execution - ! - rdpr %canrestore, %g1 - wrpr %g0, %g1, %cleanwin - rdpr %cwp, %g1 - wrpr %g1, %g6, %tstate - retry -END(user_rtt) -END(utl0) - -ENTRY(ktl0) - nop - SAVE_GLOBALS(%l7) - rd %asi, %g1 - SAVE_OUTS(%l7) - stx %g1, [%l7 + TF_ASI] - GET_PCPU_SCRATCH_SLOW(%g6) ! we really shouldn't need this ... - wrpr %g0, PSTATE_KERNEL, %pstate ! enable interrupts - - brnz %o1, common_ktrap - nop - call spinlock_enter - nop -common_kintr: - jmpl %l3, %o7 ! call trap handler - mov %l7, %o0 - call spinlock_exit - nop - b common_rtt - nop -common_ktrap: - jmpl %l3, %o7 ! call trap handler - mov %l7, %o0 - -ENTRY(krtt) -common_rtt: - ! - ! restore globals and outs - ! - rdpr %pstate, %l1 - ldx [%l7 + TF_ASI], %g1 - wrpr %l1, PSTATE_IE, %pstate - wr %g1, 0, %asi - - RESTORE_GLOBALS_KERNEL(%l7) - - ! switch to global set 1 - wrpr %g0, 1, %gl - RESTORE_OUTS(%l7) -#ifdef notyet - ! - ! set %pil from max(old pil, cur_thread_spl) - ! - ldn [%l0 + T_CPU], %l0 - ld [%l0 + CPU_BASE_SPL], %l0 - cmp %l6, %l0 - movg %xcc, %l6, %l0 - wrpr %g0, %l0, %pil -#endif - GET_PCPU_SCRATCH - ldx [PCPU(CURTHREAD)], %l0 - ldx [%l0 + TD_MD + MD_SAVED_PIL], %l0 - wrpr %g0, %l0, %pil - ! - ! raise tl - ! setup trap regs - ! restore to window we originally trapped in - ! - wrpr %g0, 1, %tl - - ldx [%l7 + TF_TSTATE], %l0 - ldx [%l7 + TF_TPC], %g1 - ldx [%l7 + TF_TNPC], %g2 - ldx [%l7 + TF_FPRS], %l1 - - andn %l0, TSTATE_CWP_MASK, %g6 - wrpr %g1, %tpc - wrpr %g2, %tnpc - - - wr %g0, FPRS_FEF, %fprs - ldx [%l7 + TF_FSR], %fsr - wr %l1, 0, %fprs - - rdpr %canrestore, %g1 - brnz %g1, 3f - nop ! can use restore directly - rdpr %cwp, %g1 - wrpr %g1, %g6, %tstate ! needed by wbuf recovery code - - ! avoid going above TL2 - fill_64bit_rtt(ASI_N) - -3: - restore - ! - ! set %tstate to the correct %cwp - ! - rdpr %cwp, %g1 - wrpr %g1, %g6, %tstate - retry -END(krtt) -END(ktl0) - - - -ENTRY(tl0_ktrap) - GET_PCPU_SCRATCH - set ktl0, %g6 - - save %sp, -(CCFSZ + TF_SIZEOF), %sp - - brz %g2, 2f - nop - or %g2, T_KERNEL, %g2 -2: - ! if the kwbuf is full we need to save to the stack now - ld [PCPU_REG + PC_KWBUF_FULL], %o0 - brz,pt %o0, 1f - nop - st %g0, [PCPU_REG + PC_KWBUF_FULL] - ldx [PCPU_REG + PC_KWBUF_SP], %o1 - add PCPU_REG, PC_KWBUF, %o0 - KWBUF64_TO_STACK(%o0, %o1, %o2) -1: - ba,a,pt %xcc, win_saved -END(tl0_ktrap) - - - ! register convention: - ! %g2=level %g1=mask - -ENTRY(tl0_intr) - SET(intr_handlers, %g7, %g6) - sllx %g4, IH_SHIFT, %g7 - ldx [%g6 + %g7], %g1 ! pointer to interrupt handler - rdpr %pil, %g5 - mov %g5, %g4 - - ! %g1 pc of trap handler - ! %g2, %g3 args of trap handler - ! %g2 software trap type - ! %g3 additional argument to trap - ! %g4 desired pil - ! %g5, %g6 temps - ! %g7 saved - - ! %l0, %l1 temps - ! %l3 saved %g1 - ! %l4 flags - ! %l5 memory fault info - ! %l6 %pil for priv traps - ! %l7 trapframe - -ENTRY(tl0_trap) - /* if we're at tl2 we have some extra work to do */ - rdpr %tl, %g5 - cmp %g5, 2 - be,pn %xcc, tl1_trap - nop - - rdpr %tstate, %g5 - btst TSTATE_PRIV, %g5 - and %g5, TSTATE_CWP_MASK, %g6 - wrpr %g0, %g6, %cwp - bnz,pn %xcc, tl0_ktrap - nop -ENTRY(tl0_utrap) - GET_PCPU_SCRATCH - - and %g2, TRAP_MASK, %g4 - cmp %g4, UT_MAX - bge,a,pt %xcc, tl0_skip_utrap - nop - - ldx [PCPU(CURTHREAD)], %g5 - ldx [%g5 + TD_PROC], %g5 - ldx [%g5 + P_MD + MD_UTRAP], %g5 - brz,pn %g5, tl0_skip_utrap - sllx %g4, PTR_SHIFT, %g6 - ldx [%g5 + %g6], %g5 - brz,pn %g5, tl0_skip_utrap - nop - - mov %g4, %g2 - mov %g5, %g4 - - ! 0) save trap state to memory - ldx [PCPU_REG + PC_CURPCB], %g6 - rdpr %tstate, %g5 - stx %g5, [%g6 + PCB_TSTATE] - rdpr %tpc, %g5 - stx %g5, [%g6 + PCB_TPC] - rdpr %tnpc, %g5 - stx %g5, [%g6 + PCB_TNPC] - stx %g2, [%g6 + PCB_TT] - stx %g3, [%g6 + PCB_SFAR] - - wrpr %g4, %tnpc - done -tl0_skip_utrap: - -#ifdef notyet - /* we need to determine from the hardware the number of register windows */ - sethi %hi(nwin_minus_one), %g5 - ld [%g5 + %lo(nwin_minus_one)], %g5 -#else - mov nwin_minus_one, %g5 -#endif - ldx [PCPU_REG + PC_CURPCB], %g6 - wrpr %g0, %g5, %cleanwin - ldx [%g6 + PCB_KSTACK], %g6 - brnz,pt %g6, 5f - nop - set PCPU_PAGES*PAGE_SIZE - PC_SIZEOF, %g6 - add %g7, %g6, %g6 - sub %g6, SPOFF + CCFSZ, %g6 - mov T_KSTACK_FAULT, %g2 - set trap, %g3 -5: - sub %g6, TF_SIZEOF, %g6 - - save %g6, 0, %sp - rdpr %canrestore, %l0 - rdpr %wstate, %l1 - wrpr %g0, 0, %canrestore - sllx %l1, WSTATE_SHIFT, %l1 - wrpr %l1, WSTATE_K64, %wstate - wrpr %g0, %l0, %otherwin - ! - ! set pcontext to run kernel - ! - mov KCONTEXT, %l0 - mov MMU_CID_P, %l1 - sethi %hi(FLUSH_ADDR), %l2 - SET_MMU_CONTEXT(%l1, %l0) - flush %l2 ! flush/membar required by immu for - ! consistency guarantee - set utl0, %g6 -win_saved: - mov %g1, %l3 ! set trap/interrupt for tl0 -#ifdef TRAP_TRACING - GET_PCPU_SCRATCH - rdpr %tl, %g1 - dec %g1 - sll %g1, RW_SHIFT, %g1 - add %g1, PC_TSBWBUF, %g1 - add PCPU_REG, %g1, %g1 - wr %g0, ASI_N, %asi - TTRACE_ADD_SAFE(%g1, 0, 0, 0, 0, 0) - mov %l3, %g1 -#endif - mov %g2, %o1 ! trap type - mov %g3, %o2 ! fault info if set - mov %g5, %l6 ! %pil if priv trap - ! - ! save state in trapframe - ! - add %sp, REGOFF + SPOFF, %l7 - rdpr %tpc, %l0 - rdpr %tnpc, %l1 - rdpr %tstate, %l2 - stx %l0, [%l7 + TF_TPC] - rd %fprs, %l0 - stx %l1, [%l7 + TF_TNPC] - stx %l2, [%l7 + TF_TSTATE] - stx %l0, [%l7 + TF_FPRS] - - /* - * According to the sparc64 port fp must me enabled - * before reading %fsr - */ - wr %g0, FPRS_FEF, %fprs - stx %fsr, [%l7 + TF_FSR] - wr %g0, 0, %fprs - ! - ! setup pil - ! - brlz,pt %g4, 1f - nop -#if 0 -#ifdef PMAP_DEBUG - rdpr %pil, %l0 - cmp %g4, %l0 - bge,pt %xcc, 10f - nop - call panic -10: -#endif -#endif - wrpr %g0, %g4, %pil -1: - wrpr %g0, %g6, %tnpc - - ! save g7 before it can be overwritten by PCPU when returning from an interrupt - wrpr %g0, 0, %gl - stx %g7, [%l7 + TF_G7] - wrpr %g0, 1, %gl - - rdpr %cwp, %l0 - set TSTATE_KERNEL, %l1 - wrpr %l1, %l0, %tstate - done -END(tl0_utrap) -END(tl0_trap) -END(tl0_intr) - - -/* - * workaround for CPP brokenness - */ -#define LOADLOAD #LoadLoad -#define LOADSTORE #LoadStore -#define STORESTORE #StoreStore - - -#define WORKING -#ifdef WORKING -#define ENTER LOADLOAD -#define EXIT LOADSTORE|STORESTORE -#else -#define ENTER #Sync -#define EXIT #Sync -#endif - -#define THE_LOCK_ENTER(addr, lock_bit, oldval, newval, label1) \ - mov 1, lock_bit ; \ - add addr, 8, addr ; \ - sllx lock_bit, 56, lock_bit ; \ -label1: ; \ - ldxa [addr]%asi, oldval; \ - or oldval, lock_bit, newval; \ - andn oldval, lock_bit, oldval; \ - casxa [addr]%asi, oldval, newval; \ - cmp newval, oldval ; \ - bne,pn %xcc, label1 ## b ; \ - membar ENTER ; \ - sub addr, 8, addr ; - -#define THE_LOCK_EXIT(addr, lock_bit, tmp)\ - membar EXIT ; \ - ldxa [addr + 8]%asi, tmp ; \ - andn tmp, lock_bit, tmp ; \ - stxa tmp, [addr + 8]%asi ; - -#define HASH_LOOKUP(addr, tag, searchtag, faillabel, matchlabel) \ - ldda [addr]%asi, tag ; \ - cmp tag, %g0 ; \ - be,pn %xcc, faillabel ; \ - nop ; \ - cmp tag, searchtag ; \ - be,pn %xcc, matchlabel ;\ - nop - -#define RESTORE_TRAPWIN(pcpu, cansave, label1, label2) \ - brz cansave, label1 ## f; \ - nop ; \ - restore ; \ - ba,a,pt %xcc, label2 ## f ; \ -label1: ; \ - rdpr %tl, cansave ; \ - dec cansave ; \ - sll cansave, RW_SHIFT, cansave ; \ - add cansave, PC_TSBWBUF, cansave ; \ - add pcpu, cansave, cansave ; \ - RESTORE_LOCALS_ASI(cansave) ; \ -label2: - -ENTRY(hash_bucket_lock) - wr %g0, ASI_N, %asi - rdpr %pstate, %o1 - and %o1, PSTATE_INTR_DISABLE, %o2 - wrpr %o2, %pstate - THE_LOCK_ENTER(%o0, %o3, %o4, %o5, 1) - mov %o1, %o0 - retl - nop -END(hash_bucket_lock) - - -ENTRY(hash_bucket_unlock) - mov 1, %g2 - wr %g0, ASI_N, %asi - sllx %g2, 56, %g2 - THE_LOCK_EXIT(%o0, %g2, %g3) - wrpr %o1, %pstate - retl - nop -END(hash_bucket_unlock) - - -! %g3==trap type -! %g4==fault type (if data miss) -! %g5==fault addr -! internal usage: -! %g1==absolute index -! %g2==hash base, pointer to hash entry -! %g3==flag bits, TSB (RA) -! %g4==fault type,entry tag -! %g5==tag -! %g6==context -! %g7 temp -ENTRY(tsb_miss_handler) - ldxa [%g1 + %g7]ASI_REAL, %g6 ! load in the context - - GET_HASH_SCRATCH_USER(%g2) - GET_TSB_SCRATCH_USER(%g4) - - brnz,pn %g6, 2f - nop - GET_HASH_SCRATCH_KERNEL(%g2) - GET_TSB_SCRATCH_KERNEL(%g4) -2: - - rdpr %tl, %g1 ! need to use real addresses? - mov ASI_LDTD_N, %g3 - wr %g0, ASI_N, %asi - dec %g1 - GET_PCPU_SCRATCH - - brz,pt %g1, 3f ! for tl == 1 - nop - sethi %uhi(VM_MIN_DIRECT_ADDRESS), %g1 - wr %g0, ASI_REAL, %asi - sllx %g1, 32, %g1 - mov ASI_LDTD_REAL, %g3 - andn %g2, %g1, %g2 - andn %g4, %g1, %g4 - andn %g7, %g1, %g7 -3: -#ifdef notyet - rdpr %cansave, %g1 - /* XXX use save operation if %g1 > 0 and tl == 1 */ -#endif - rdpr %tl, %g1 - dec %g1 - sll %g1, RW_SHIFT, %g1 - add %g1, PC_TSBWBUF, %g1 - add PCPU_REG, %g1, %g1 -#ifdef TRAP_TRACING - TTRACE_ADD_SAFE(%g1, 0, 0, 0, 0, 0) -#endif - SAVE_LOCALS_ASI(%g1) - mov 0, %g1 ! cansave is 0 - ! %g1 == %cansave - ! %g2 == hash scratch value - ! %g3 == TWDW ASI - ! %g4 == TSB RA - ! %g5 == fault addr - ! %g6 == context - - srlx %g5, TTARGET_VA_SHIFT, %l0 - sllx %g6, TTARGET_CTX_SHIFT, %l1 - or %l0, %l1, %l2 ! %l2 == search tag - -tsb_miss_compute_hash_addr: - sethi %hi(PAGE_SIZE), %l0 - sub %l0, 1, %l1 ! %l1==PAGE_MASK - - and %g2, %l1, %l3 ! size stored in lower 13 bits - andn %g2, %l1, %g2 ! actual VA/RA of hash - - ! XXX only handle 8k page miss - ! calculate hash index - srlx %g5, PAGE_SHIFT, %l4 ! absolute hash index - sllx %l3, (PAGE_SHIFT - THE_SHIFT), %l0 ! size of hash in THEs - sub %l0, 1, %l5 ! THE_MASK - and %l4, %l5, %l5 ! masked hash index - sllx %l5, THE_SHIFT, %l5 ! masked hash offset - ! fetch hash entries - exit when we find what were looking for - - ! %g2==entry base - add %g2, %l5, %g2 ! base + offset == entry base - - - THE_LOCK_ENTER(%g2, %l0, %l7, %l6, 6) - - ! %g1 == cansave - ! %g2 == THE - ! %g3 == TWDW ASI - ! %g4 == TSB RA - ! %g5 == fault addr - ! %g6 == context - ! %g7 == PCPU_REG - ! %l0 == VTD_LOCK - ! %l1 == PAGE_MASK - ! %l2 == search tag - ! %l4 == absolute index - - ! %l3 == ASI - ! %l5 == saved head of bucket - ! %l6 == tag - ! %l7 == data - - rd %asi, %l3 - wr %g0, %g3, %asi - mov %g2, %l5 ! save head of bucket - rdpr %tt, %g3 ! reload trap type - -tsb_miss_lookup_0: - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -tsb_miss_lookup_1: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -tsb_miss_lookup_2: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -#if HASH_ENTRY_SHIFT > 2 -tsb_miss_lookup_3: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -tsb_miss_lookup_4: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -tsb_miss_lookup_5: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -tsb_miss_lookup_6: - add %g2, 16, %g2 - HASH_LOOKUP(%g2, %l6, %l2, tsb_miss_not_found, tsb_miss_found) -#endif -tsb_miss_collision: - add %g2, 16, %g2 - ldda [%g2]%asi, %l6 - - sethi %uhi(VM_MIN_DIRECT_ADDRESS), %g3 - cmp %l3, ASI_N - sllx %g3, 32, %g3 - beq,pt %xcc, 7f - nop - andn %l7, %g3, %l7 ! generate real address -7: - srl %l6, 0, %l6 - sethi %hi(0xcafebabe), %g3 - mov %l7, %g2 - or %g3, %lo(0xcafebabe), %g3 - cmp %g3, %l6 - rdpr %tt, %g3 - beq,pt %xcc, tsb_miss_lookup_0 - nop - -tsb_miss_not_found: - ! we need to jump to tl0_trap to drop us back down to tl0 - ! and take us to trap(...) to service the fault - wr %g0, %l3, %asi - THE_LOCK_EXIT(%l5, %l0, %g2) - - andn %g5, %l1, %g5 ! fault page PA - - RESTORE_TRAPWIN(PCPU_REG, %g1, 14, 15) - - ! convert hardware trap type to kernel trap type - set trap_conversion, %g2 - sllx %g3, INT_SHIFT, %g3 - ld [%g2 + %g3], %g2 - - sethi %hi(trap), %g1 - or %g6, %g5, %g3 ! trap data - sub %g0, 1, %g4 ! pil info - ba %xcc, tl0_trap - or %g1, %lo(trap), %g1 - -tsb_miss_found: - - wr %g0, %l3, %asi - cmp %g3, TT_DATA_MISS ! TSB data miss - be,pt %xcc, 9f - or %l7, VTD_REF, %l7 ! set referenced unconditionally - cmp %g3, TT_INSTRUCTION_MISS ! TSB instruction miss - be,pt %xcc, 9f - nop - cmp %g3, TT_DATA_PROTECTION ! protection fault - bne,pn %xcc, unsupported_fault_trap ! we don't handle any other fault types currently - nop - andcc %l7, VTD_SW_W, %g0 ! write enabled? - bz,a,pn %xcc, prot_fault_trap ! write to read only page - nop - or %l7, VTD_W, %l7 ! add modifed bit -9: - - andn %l7, %l0, %l7 ! remove lock bit - - and %g4, %l1, %g3 ! shift of TSB in pages - andn %g4, %l1, %l3 ! TSB real address - - mov 1, %l2 - add %g3, (PAGE_SHIFT - TTE_SHIFT), %g3 ! add shift value for number of ttes / page - sllx %l2, %g3, %g3 ! nttes - - subx %g3, 1, %g3 ! TSB_MASK - and %g3, %l4, %g3 ! masked index - sllx %g3, TTE_SHIFT, %g3 ! masked byte offset - add %g3, %l3, %g3 ! TTE RA - - rdpr %tl, %l2 ! don't track misses for kernel context - brz,pn %g6, 13f - dec %l2 - brnz,pn %l2, 13f ! don't track misses at tl > 1 - nop - ldx [PCPU(PMAP)], %l1 - ld [%l1 + PM_TSB_MISS_COUNT], %l3 - add 1, %l3, %l3 - st %l3, [%l1 + PM_TSB_MISS_COUNT] - - ! if the data value is zero then this is not a capacity miss - ldda [%g3]ASI_LDTD_N, %l2 - brz,pt %l3, 13f - nop - ! compare the tag bits - if they're the same we're merely - ! changing the mapping - brz,pt %l3, 13f - nop - cmp %l6, %l2 - beq,pt %xcc, 13f - nop - - ld [%l1 + PM_TSB_CAP_MISS_COUNT], %l3 - add 1, %l3, %l3 - st %l3, [%l1 + PM_TSB_CAP_MISS_COUNT] - -13: stxa %g0, [%g3 + 8]%asi ! invalidate data - membar #StoreStore - - stxa %l6, [%g3]%asi ! store tag - stxa %l7, [%g3 + 8]%asi ! store data - stxa %l7, [%g2 + 8]%asi ! update TTE with ref bit - membar #StoreLoad - - THE_LOCK_EXIT(%l5, %l0, %l7) - RESTORE_TRAPWIN(PCPU_REG, %g1, 13, 16) -upgrade_demap: - rdpr %tt, %g3 - cmp %g3, TT_DATA_PROTECTION - beq,pn %xcc, demap_begin - sethi %hi(PAGE_SIZE), %g1 - retry -demap_begin: - dec %g1 - mov %o0, %g1 - mov %o1, %g2 - mov %o2, %g3 - mov MAP_DTLB, %o2 - mov %g5, %o0 - mov %g6, %o1 - ta MMU_UNMAP_ADDR - mov %g1, %o0 - mov %g2, %o1 - mov %g3, %o2 - retry -END(tsb_miss_handler) - - -/* - * Write to read-only page - */ -! %g1 == cansave -! %g4 == tag -! %g5 == fault addr -! %g6 == context -! %l0 == VTD_LOCK -! %l5 == head of bucket - -ENTRY(prot_fault_trap) - THE_LOCK_EXIT(%l5, %l0, %g2) - RESTORE_TRAPWIN(PCPU_REG, %g1, 14, 15) - sethi %hi(trap), %g1 - mov T_DATA_PROTECTION, %g2 - or %g5, %g6, %g3 - sub %g0, 1, %g4 - ba %xcc, tl0_trap - or %g1, %lo(trap), %g1 -END(prot_fault_trap) -/* - * Programming error - */ -ENTRY(unsupported_fault_trap) - add 0x20, %g3, %g1 - PUTCHAR(0x5b) - PUTCHAR(%g1) - PUTCHAR(0x5d) -END(unsupported_fault_trap) - - -/* - * Freshly forked processes come here when switched to for the first time. - * The arguments to fork_exit() have been setup in the locals, we must move - * them to the outs. - */ -ENTRY(fork_trampoline) - mov %l0, %o0 - mov %l1, %o1 - call fork_exit - mov %l2, %o2 - ba,pt %xcc, user_rtt - add %sp, CCFSZ + SPOFF, %l7 -END(fork_trampoline) - - - - .comm intrnames, IV_MAX * (MAXCOMLEN + 1) - .comm eintrnames, 0 - - .comm intrcnt, IV_MAX * 8 - .comm eintrcnt, 0 - -#define TRAP_ENTRY_SHIFT 5 -#define TRAP_ENTRY_MASK 0x1ff -ENTRY(tl1_trap) - ! assume no tl1 handler - rdpr %tpc, %g7 - - set rtt_fill_start, %g6 - cmp %g7, %g6 - blu,pn %xcc, 1f - .empty - set rtt_fill_end, %g6 - cmp %g7, %g6 - bgeu,pn %xcc, 1f - nop - set fault_rtt_fn1, %g7 - ba,a,pt %xcc, 4f -1: -#ifdef USING_OPTIMIZED_SPILL_FILL - set fill_slow_start, %g6 - cmp %g7, %g6 - bleu,a,pn %xcc, 2f - nop - set fill_slow_end, %g6 - cmp %g7, %g6 - blu,a,pn %xcc, 3f - nop -#endif -2: - set tl1_end, %g6 - cmp %g7, %g6 - bgeu,a,pn %xcc, ptl1_panic - mov PTL1_BAD_TRAP, %g1 - ! tpc is in the trap table - ! convert to trap index - srl %g7, TRAP_ENTRY_SHIFT, %g6 - and %g6, TRAP_ENTRY_MASK, %g6 - ! check for window trap type - and %g6, WTRAP_TTMASK, %g6 - cmp %g6, WTRAP_TYPE - bne,a,pn %xcc, ptl1_panic - mov PTL1_BAD_NOT_WTRAP, %g1 -3: - andn %g7, WTRAP_ALIGN, %g7 - add %g7, WTRAP_FAULTOFF, %g7 -4: - wrpr %g0, %g7, %tnpc - wrpr %g0, 1, %gl - rdpr %tt, %g2 - GET_MMFSA_SCRATCH(%g7) - - ! convert hardware trap type to kernel trap type - set trap_conversion, %g1 - sllx %g2, INT_SHIFT, %g2 - ld [%g1 + %g2], %g2 - - wr %g0, ASI_REAL, %asi - ldxa [%g7 + MMFSA_D_ADDR]%asi, %g3 - ldxa [%g7 + MMFSA_D_CTX]%asi, %g7 - ! XXX we're only handling page faults here - srlx %g3, PAGE_SHIFT, %g3 - sllx %g3, PAGE_SHIFT, %g3 ! mask off bottom - or %g3, %g7, %g3 - done -#ifdef notyet - sllx %g7, TRAP_CTX_SHIFT, %g7 - or %g7, %g5, %g5 - done -#endif -END(tl1_trap) diff --git a/sys/sun4v/sun4v/hcall.S b/sys/sun4v/sun4v/hcall.S deleted file mode 100644 index 1e5309800a79..000000000000 --- a/sys/sun4v/sun4v/hcall.S +++ /dev/null @@ -1,1852 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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. - * - * $FreeBSD$ - */ - -#include - -#include -#include -#include -#include -#include - -#include "assym.s" -/* - * Section 9 API Versioning - * - */ - -/* - * request and check for a version of the hypervisor apis - * which may be compatible - * - * arg0 api_group (%o0) - * arg1 major_number (%o1) - * arg2 req_minor_number (%o2) - * - * ret0 status (%o0) - * ret1 act_minor_number (%o1) - * - */ -ENTRY(api_set_version) - mov API_SET_VERSION, %o5 - ta CORE_TRAP - retl - stx %o1, [%o3] -END(api_set_version) - -/* - * retrieve the major and minor number of the most recently - * successfully negotiated API - * - * arg0 api_group (%o0) - * - * ret0 status (%o0) - * ret1 major_number (%o1) - * ret2 major_number (%o2) - * - */ -ENTRY(api_get_version) - mov %o2, %o4 - mov %o1, %o3 - mov API_GET_VERSION, %o5 - ta CORE_TRAP - retl - stx %o1, [%o4] - -END(api_get_version) - -/* - * Section 10 Domain Services - * - */ - -/* - * stop all CPUs in the virtual machine domain and place them - * in the stopped state - * - * arg0 exit_code (%o0) - * - */ -ENTRY(hv_mach_exit) - mov MACH_EXIT, %o5 - ta FAST_TRAP - retl - nop -END(hv_mach_exit) - -/* - * copy the most current machine description into buffer - * upon success or EINVAL the service returns the actual - * size of the machine description - * - * arg0 buffer (%o0) - * arg1 length (%o1) - * - * ret0 status (%o0) - * ret1 length (%o1) - * - */ -ENTRY(hv_mach_desc) - mov %o1, %o2 - ldx [%o1], %o1 - mov MACH_DESC, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_mach_desc) - -/* - * execute a software initiated reset of a virtual machine domain - * - */ -ENTRY(hv_mach_sir) - mov MACH_SIR, %o5 - ta FAST_TRAP - retl - nop -END(hv_mach_sir) - -/* - * report the guests soft state to the hypervisor - * - * arg0 soft_state (%o0) - * arg1 soft_state_desc_ptr (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mach_set_soft_state) - mov MACH_SET_SOFT_STATE, %o5 - ta FAST_TRAP - retl - nop -END(hv_mach_set_soft_state) - -/* - * retrieve the current value of the guest's software state - * - * arg0 soft_desc_ptr (%o0) - * - * ret0 status (%o0) - * arg1 soft_state (%o1) - * - */ -ENTRY(hv_mach_get_soft_state) - mov %o1, %o2 - mov MACH_SET_SOFT_STATE, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_mach_get_soft_state) - -/* - * set a watchdog timer, 0 disables, upon success - * time_remaining contains the time previously remaining - * - * arg0 timeout (%o0) - * - * ret0 status (%o0) - * ret1 time_remaining (%o1) - * - */ -ENTRY(hv_mach_watchdog) - mov %o1, %o2 - mov MACH_WATCHDOG, %o5 - ta FAST_TRAP - brnz,pn %o0, 1f - nop - stx %o1, [%o2] -1: retl - nop -END(hv_mach_watchdog) - -/* - * Section 11 CPU Services - * - */ - -/* - * start CPU with id cpuid with pc in %pc and real trap base address - * of rtba - * - * arg0 cpuid (%o0) - * arg1 pc (%o1) - * arg2 rtba (%o2) - * arg3 target_arg0 (%o3) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cpu_start) - mov CPU_START, %o5 - ta FAST_TRAP - retl - nop -END(hv_cpu_start) - -/* - * stop CPU with id cpuid - * - * arg0 cpuid (%o0) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cpu_stop) - mov CPU_STOP, %o5 - ta FAST_TRAP - retl - nop -END(hv_cpu_stop) - -/* - * set the real trap base address of the local cpu to rtba - * upon success the previous_rtba contains the address of the - * old rtba - * - * arg0 rtba (%o0) - * - * ret0 status (%o0) - * ret1 previous_rtba(%o1) - * - */ -ENTRY(hv_cpu_set_rtba) - mov %o1, %o2 - mov CPU_SET_RTBA, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] - -END(hv_cpu_set_rtba) - -/* - * return the current real trap base address - * - * ret0 status (%o0) - * ret1 rtba (%o1) - * - */ -ENTRY(hv_cpu_get_rtba) - mov CPU_GET_RTBA, %o5 - ta FAST_TRAP - retl - nop -END(hv_cpu_get_rtba) - -/* - * suspend execution on current cpu - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cpu_yield) - mov CPU_YIELD, %o5 - ta FAST_TRAP - retl - nop -END(hv_cpu_yield) - -/* - * configure queue of size nentries to be placed at base raddr - * - * arg0 queue (%o0) - * arg1 base raddr (%o1) - * arg2 nentries (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cpu_qconf) - mov CPU_QCONF, %o5 - ta FAST_TRAP - retl - nop -END(hv_cpu_qconf) - -/* - * return configuration of queue queue - * - * arg0 queue (%o0) - * - * ret0 status (%o0) - * ret1 base raddr (%o1) - * ret2 nentries (%o2) - * - */ -ENTRY(hv_cpu_qinfo) -END(hv_cpu_qinfo) - -/* - * send cpu mondo interrupt to cpulist - * - * arg0 ncpus (%o0) - * arg1 cpu list ra (%o1) - * arg2 mondo data ra(%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cpu_mondo_send) - ldx [PCPU(MONDO_DATA_RA)], %o2 - mov CPU_MONDO_SEND, %o5 - ta FAST_TRAP - retl - membar #Sync -END(hv_cpu_mondo_send) - -/* - * return the hypervisor id for the current cpu - * - * ret0 status (%o0) - * ret1 cpuid (%o1) - * - */ -ENTRY(hv_cpu_myid) - mov %o0, %o2 - mov CPU_MYID, %o5 - ta FAST_TRAP - stx %o1, [%o2] - retl - nop -END(hv_cpu_myid) - -/* - * retrieve the current state of cpu cpuid - * - * arg0 cpuid (%o0) - * - * ret0 status (%o0) - * ret1 state (%o1) - * - */ -ENTRY(hv_cpu_state) - mov %o1, %o2 - mov CPU_STATE, %o5 - ta FAST_TRAP - stx %o1, [%o2] - retl - nop -END(hv_cpu_state) - -/* - * Section 12 MMU Services - * - */ - -/* - * set the tsb(s) for the current cpu for context 0 - * - * arg0 ntsb (%o0) - * arg1 tsbdptr (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_tsb_ctx0) - mov MMU_TSB_CTX0, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_tsb_ctx0) - -/* - * set the tsb(s) for the current cpu for non-zero contexts - * - * arg0 ntsb (%o0) - * arg1 tsbptr (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_tsb_ctxnon0) - mov MMU_TSB_CTXNON0, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_tsb_ctxnon0) - -/* - * demap any page mapping of virtual address vaddr in context ctx - * - * arg0 reserved (%o0) - * arg1 reserved (%o1) - * arg2 vaddr (%o2) - * arg3 ctx (%o3) - * arg4 flags (%o4) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_demap_page) - mov MMU_DEMAP_PAGE, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_demap_page) - -/* - * demap all non-permanent virtual address mappings in context ctx - * - * arg0 reserved (%o0) - * arg1 reserved (%o1) - * arg2 ctx (%o2) - * arg3 flags (%o3) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_demap_ctx) - mov MMU_DEMAP_CTX, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_demap_ctx) - -/* - * demap all non-permanent virtual address mappings for the current - * virtual cpu - * - * arg0 reserved (%o0) - * arg1 reserved (%o1) - * arg2 flags (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_demap_all) - mov MMU_DEMAP_ALL, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_demap_all) - -/* - * create a non-permanent mapping for the calling virtual cpu - * - * arg0 vaddr (%o0) - * arg1 context (%o1) - * arg2 TTE (%o2) - * arg3 flags (%o3) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_map_addr) - mov MMU_MAP_ADDR, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_map_addr) - -/* - * create a permanent mapping for the calling virtual cpu - * - * arg0 vaddr (%o0) - * arg1 reserved (%o1) - * arg2 TTE (%o2) - * arg3 flags (%o3) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_map_perm_addr) - mov MMU_MAP_PERM_ADDR, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_map_perm_addr) - -/* - * demap virtual address vaddr in context ctx on current virtual cpu - * - * arg0 vaddr (%o0) - * arg1 ctx (%o1) - * arg2 flags (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_unmap_addr) - mov MMU_UNMAP_ADDR, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_unmap_addr) - -/* - * demap any permanent mapping at virtual address vaddr on current virtual cpu - * - * arg0 vaddr (%o0) - * arg1 reserved (%o1) - * arg2 flags (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_unmap_perm_addr) - mov %o1, %o2 - clr %o1 - mov MMU_UNMAP_PERM_ADDR, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_unmap_perm_addr) - -/* - * configure the MMU fault status area for the current virtual cpu - * - * arg0 raddr (%o0) - * - * ret0 status (%o0) - * ret1 prev_raddr (%o1) - * - */ -ENTRY(hv_mmu_fault_area_conf) - mov %o1, %o2 - mov MMU_FAULT_AREA_CONF, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_mmu_fault_area_conf) - -/* - * enable or disable virtual address translation for the current virtual cpu - * - * arg0 enable_flag (%o0) - * arg1 return_target (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_mmu_enable) - mov MMU_ENABLE, %o5 - ta FAST_TRAP - retl - nop -END(hv_mmu_enable) - -/* - * return the TSB configuration as previously defined by mmu_tsb_ctx0 - * - * arg0 maxtsbs (%o0) - * arg1 buffer_ra (%o1) - * - * ret0 status (%o0) - * ret1 ntsbs (%o1) - * - */ -ENTRY(hv_mmu_tsb_ctx0_info) - mov %o1, %o2 - mov MMU_TSB_CTX0_INFO, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_mmu_tsb_ctx0_info) - -/* - * return the TSB configuration as previously defined by mmu_tsb_ctxnon0 - * - * arg0 maxtsbs (%o0) - * arg1 buffer_ra (%o1) - * - * ret0 status (%o0) - * ret1 ntsbs (%o1) - * - */ -ENTRY(hv_mmu_tsb_ctxnon0_info) - mov %o1, %o2 - mov MMU_TSB_CTXNON0_INFO, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_mmu_tsb_ctxnon0_info) - -/* - * return the MMU fault status area defined for the current virtual cpu - * - * ret0 status (%o0) - * ret1 mmfsara (%o1) - * - */ -ENTRY(hv_mmu_fault_area_info) - mov %o0, %o2 - mov MMU_FAULT_AREA_INFO, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] - -END(hv_mmu_fault_area_info) - -/* - * Section 13 Cache and Memory Services - * - */ - -/* - * zero from raddr to raddr+length-1 - * - * arg0 raddr (%o0) - * arg1 length (%o1) - * - * ret0 status (%o0) - * ret1 length scrubbed (%o1) - * - */ -ENTRY(hv_mem_scrub) - mov MEM_SCRUB, %o5 - ta FAST_TRAP - stx %o1, [%o2] - retl - nop -END(hv_mem_scrub) - -/* - * for the memory address range from raddr to raddr+length-1 - * for the next access within that range from main system memory - * - * arg0 raddr (%o0) - * arg1 length (%o1) - * - * ret0 status (%o0) - * ret1 length synced (%o1) - * - */ -ENTRY(hv_mem_sync) - mov MEM_SYNC, %o5 - ta FAST_TRAP - stx %o1, [%o2] - retl - nop -END(hv_mem_sync) - -/* - * Section 14 Device Interrupt Services - * - */ - -/* - * converts a device specific interrupt number given by - * devhandle and devino to a system specific ino (sysino) - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * - * ret0 status (%o0) - * ret1 sysino (%o1) - * - */ -ENTRY(hv_intr_devino_to_sysino) - mov INTR_DEVINO2SYSINO, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_intr_devino_to_sysino) - -/* - * return intr enabled state - * - * arg0 sysino (%o0) - * - * ret0 status (%o0) - * ret1 intr_enabled (%o1) - * - */ -ENTRY(hv_intr_getenabled) - mov %o1, %o2 - mov INTR_GETENABLED, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_intr_getenabled) - -/* - * set intr enabled state - * - * arg0 sysino (%o0) - * arg1 intr_enabled (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_intr_setenabled) - mov INTR_SETENABLED, %o5 - ta FAST_TRAP - retl - nop -END(hv_intr_setenabled) - -/* - * return current state of the interrupt given - * by the sysino - * - * arg0 sysino (%o0) - * - * ret0 status (%o0) - * ret1 intr_state (%o1) - * - */ -ENTRY(hv_intr_getstate) - mov %o1, %o2 - mov INTR_GETSTATE, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_intr_getstate) - -/* - * set the current state of the interrupt given - * by the sysino - * - * arg0 sysino (%o0) - * arg1 intr_state (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_intr_setstate) - mov INTR_SETSTATE, %o5 - ta FAST_TRAP - retl - nop -END(hv_intr_setstate) - -/* - * return the cpuid that is the current target of the - * interrupt given by the sysino - * - * arg0 sysino (%o0) - * - * ret0 status (%o0) - * ret1 cpuid (%o1) - * - */ -ENTRY(hv_intr_gettarget) - mov %o1, %o2 - mov INTR_GETTARGET, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_intr_gettarget) - -/* - * set the target to cpuid that for the - * interrupt given by the sysino - * - * arg0 sysino (%o0) - * arg1 cpuid (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_intr_settarget) - mov INTR_SETTARGET, %o5 - ta FAST_TRAP - retl - nop -END(hv_intr_settarget) - -/* - * get the cookie value that will be delivered - * in word 0 of a dev_mondo packet to a guest - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * - * ret0 status (%o0) - * ret1 cookie_value (%o1) - * - */ -ENTRY(hv_vintr_getcookie) - mov VINTR_GETCOOKIE, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_vintr_getcookie) - -/* - * set the cookie value that will be delivered - * in word 0 of a dev_mondo packet to a guest - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * ret2 cookie_value (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_vintr_setcookie) - mov VINTR_SETCOOKIE, %o5 - ta FAST_TRAP - retl - nop -END(hv_vintr_setcookie) - -/* - * get the enabled status of the interrupt - * defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * - * ret0 status (%o0) - * ret1 intr_enabled (%o1) - * - */ -ENTRY(hv_vintr_getenabled) - mov VINTR_GETENABLED, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_vintr_getenabled) - -/* - * set the enabled status of the interrupt - * defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * arg2 intr_enabled (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_vintr_setenabled) - mov VINTR_SETENABLED, %o5 - ta FAST_TRAP - retl - nop -END(hv_vintr_setenabled) - -/* - * get the current state of the interrupt - * defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * - * ret0 status (%o0) - * ret1 intr_state (%o1) - * - */ -ENTRY(hv_vintr_getstate) - mov VINTR_GETSTATE, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_vintr_getstate) - -/* - * set the current state of the interrupt - * defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * arg2 intr_state (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_vintr_setstate) - mov VINTR_SETSTATE, %o5 - ta FAST_TRAP - retl - nop -END(hv_vintr_setstate) - -/* - * get the cpuid that is the current target - * of the interrupt defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * - * ret0 status (%o0) - * ret1 cpuid (%o1) - * - */ -ENTRY(hv_vintr_gettarget) - mov VINTR_GETTARGET, %o5 - ta FAST_TRAP - retl - st %o1, [%o2] -END(hv_vintr_gettarget) - -/* - * set the cpuid that is the current target - * of the interrupt defined by devino - * - * arg0 devhandle (%o0) - * arg1 devino (%o1) - * arg2 cpuid (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_vintr_settarget) - mov VINTR_SETTARGET, %o5 - ta FAST_TRAP - retl - nop -END(hv_vintr_settarget) - - -/* - * Section 15 Time of Day Services - * - */ - -/* - * get the current time of day - * - * ret0 status (%o0) - * ret1 time-of-day (%o1) - * - */ -ENTRY(hv_tod_get) - mov %o0, %o2 - mov TOD_GET, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_tod_get) - -/* - * set the current time-of-day - * arg0 tod (%o0) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_tod_set) - mov TOD_SET, %o5 - ta FAST_TRAP - retl - nop -END(hv_tod_set) - -/* - * Section 16 Console Services - * - */ - -/* - * return a character from the console device - * - * ret0 status (%o0) - * ret1 character (%o1) - * - */ -ENTRY(hv_cons_getchar) - mov %o0, %o2 - mov CONS_GETCHAR, %o5 - ta FAST_TRAP - brnz,a %o0, 1f - mov 1, %o0 - - cmp %o1, H_BREAK - be 1f - mov %o1, %o0 - - cmp %o1, H_HUP - be 1f - mov %o1, %o0 - - stb %o1, [%o2] - mov 0, %o0 -1: - retl - nop -END(hv_cons_getchar) - -/* - * send a character to the console device - * arg0 char (%o0) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_cons_putchar) - mov CONS_PUTCHAR, %o5 - ta FAST_TRAP - retl - nop -END(hv_cons_putchar) - -/* - * write characters in raddr to console - * arg0 raddr (%o0) - * arg1 size (%o1) - * - * ret0 status (%o0) - * ret1 char written (%o1) - * - */ -ENTRY(hv_cons_write) - mov %o2, %o3 - mov CONS_WRITE, %o5 - ta FAST_TRAP - brnz,a %o0, 1f ! failure, just return error - mov 1, %o0 - stx %o1, [%o3] -1: retl - nop -END(hv_cons_write) - -/* - * read up to size characters from console in to raddr - * arg0 raddr (%o0) - * arg1 size - * - * ret0 status (%o0) - * ret1 char written (%o1) - * - */ -ENTRY(hv_cons_read) - mov %o2, %o3 - mov CONS_READ, %o5 - ta FAST_TRAP - brnz,a %o0, 1f ! failure, just return error - mov 1, %o0 - - cmp %o1, H_BREAK - be 1f - mov %o1, %o0 - - cmp %o1, H_HUP - be 1f - mov %o1, %o0 - - stx %o1, [%o3] -1: retl - nop -END(hv_cons_read) - - -/* - * Section 17 Core Dump Services - * - */ - -/* - * declare a domain dump buffer to the hypervisor - * arg0 raddr (%o0) - * arg1 size (%o1) - * - * ret0 status (%o0) - * ret1 required size of the dump buffer (%o1) - * - */ -ENTRY(hv_dump_buf_update) - mov DUMP_BUF_UPDATE, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_dump_buf_update) - -/* - * return the currently configured dump buffer description - * - * ret0 status (%o0) - * ret1 ra of the current dump buffer (%o1) - * ret2 size of the current dump buffer (%o2) - * - */ -ENTRY(hv_dump_buf_info) - mov %o0, %o3 - mov %o1, %o4 - mov DUMP_BUF_INFO, %o5 - ta FAST_TRAP - stx %o1, [%o3] - retl - stx %o2, [%o4] -END(hv_dump_buf_info) - -/* - * Section 18 Trap Trace Services - * - */ - -/* - * arg0 RA base of buffer (%o0) - * arg1 buf size in no. of entries (%o1) - * - * ret0 status (%o0) - * ret1 minimum size in no. of entries on failure, - * actual size in no. of entries on success (%o1) - * - */ -ENTRY(hv_ttrace_buf_conf) - mov TTRACE_BUF_CONF, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_ttrace_buf_conf) - -/* - * return the size and location of a previously declare - * trap-trace buffer - * - * ret0 status (%o0) - * ret1 RA base of buffer (%o1) - * ret2 size in no. of entries (%o2) - * - */ -ENTRY(hv_ttrace_buf_info) - mov %o0, %o3 - mov %o1, %o4 - mov TTRACE_BUF_INFO, %o5 - ta FAST_TRAP - stx %o1, [%o3] - retl - stx %o2, [%o4] -END(hv_ttrace_buf_info) - -/* - * enable / disable trap tracing - * - * arg0 enable / disable (%o0) - * - * ret0 status (%o0) - * ret1 previous enable state (%o1) - * - */ -ENTRY(hv_ttrace_enable) - mov %o1, %o2 - mov TTRACE_ENABLE, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_ttrace_enable) - -/* - * TTRACE_FREEZE - * arg0 enable/ freeze (%o0) - * - * ret0 status (%o0) - * ret1 previous freeze state (%o1) - * - */ -ENTRY(hv_ttrace_freeze) - mov %o1, %o2 - mov TTRACE_FREEZE, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_ttrace_freeze) - -/* - * add an entry to the trap trace buffer - * - * arg0 tag (16-bits) (%o0) - * arg1 data word 0 (%o1) - * arg2 data word 1 (%o2) - * arg3 data word 2 (%o3) - * arg4 data word 3 (%o4) - * - * ret0 status (%o0) - * -*/ -ENTRY(hv_ttrace_addentry) - ta TTRACE_ADDENTRY - retl - nop -END(hv_ttrace_addentry) - -/* - * Section 19 Logical Domain Channel Services - * - */ - -/* - * configure ldc tx queue - * - * arg0 ldc_id (%o0) - * arg1 base_raddr (%o1) - * arg2 nentries (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_tx_qconf) - mov LDC_TX_QCONF, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_tx_qconf) - -/* - * return configuration info for ldc tx queue - * - * arg0 ldc_id (%o0) - * - * ret0 status (%o0) - * ret1 base_raddr (%o1) - * ret2 nentries (%o2) - * - */ -ENTRY(hv_ldc_tx_qinfo) - mov %o1, %o3 - mov %o2, %o4 - mov LDC_TX_QINFO, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o3] - stx %o2, [%o4] -1: retl - nop -END(hv_ldc_tx_qinfo) - -/* - * get the state of the ldc tx queue - * - * arg0 ldc_id (%o0) - * - * ret0 status (%o0) - * ret1 head_offset (%o1) - * ret2 tail_offset (%o2) - * ret3 channel_state (%o3) - * - */ -ENTRY(hv_ldc_tx_get_state) - mov %o1, %o4 - mov LDC_TX_GET_STATE, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o4] - stx %o2, [%o4 + 8] - stx %o3, [%o4 + 16] -1: retl - nop -END(hv_ldc_tx_get_state) - -/* - * update the tail pointer of the ldc tx queue - * - * arg0 ldc_id (%o0) - * arg1 tail_offset (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_tx_set_qtail) - mov LDC_TX_SET_QTAIL, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_tx_set_qtail) - -/* - * configure ldc rx queue - * - * arg0 ldc_id (%o0) - * arg1 base_raddr (%o1) - * arg2 nentries (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_rx_qconf) - mov LDC_RX_QCONF, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_rx_qconf) - -/* - * return configuration info for ldc rx queue - * - * arg0 ldc_id (%o0) - * - * ret0 status (%o0) - * ret1 base_raddr (%o1) - * ret2 nentries (%o2) - * - */ -ENTRY(hv_ldc_rx_qinfo) - mov %o1, %o3 - mov %o2, %o4 - mov LDC_RX_QINFO, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o3] - stx %o2, [%o4] -1: retl - nop -END(hv_ldc_rx_qinfo) - -/* - * get the state of the ldc rx queue - * - * arg0 ldc_id (%o0) - * - * ret0 status (%o0) - * ret1 head_offset (%o1) - * ret2 tail_offset (%o2) - * ret3 channel_state (%o3) - * - */ -ENTRY(hv_ldc_rx_get_state) - mov %o1, %o4 - mov LDC_RX_GET_STATE, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o4] - stx %o2, [%o4 + 8] - stx %o3, [%o4 + 16] -1: retl - nop -END(hv_ldc_rx_get_state) - -/* - * update the head pointer of the ldc rx queue - * - * arg0 ldc_id (%o0) - * arg1 head_offset (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_rx_set_qhead) - mov LDC_RX_SET_QHEAD, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_rx_set_qhead) - -/* - * declare an export map table - * - * arg0 channel (%o0) - * arg1 base_ra (%o1) - * arg2 nentries (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_set_map_table) - mov LDC_SET_MAPTABLE, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_set_map_table) - -/* - * retrieve the current map table configuration associated - * with the given domain channel - * - * arg0 channel (%o0) - * - * ret0 status (%o0) - * ret1 base_ra (%o1) - * ret2 nentries (%o2) - * - */ -ENTRY(hv_ldc_get_map_table) - mov %o1, %o3 - mov %o2, %o4 - mov LDC_GET_MAPTABLE, %o5 - ta FAST_TRAP - stx %o1, [%o3] - retl - stx %o2, [%o4] -END(hv_ldc_get_map_table) - -/* - * copy data into or out of a local memory region form or to - * the logical domain at the other end of the specified domain - * channel - * - * arg0 channel (%o0) - * arg1 flags (%o1) - * arg2 cookie (%o2) - * arg3 raddr (%o3) - * arg4 length (%o4) - * - * ret0 status (%o0) - * ret1 ret_length (%o1) - * - */ -ENTRY(hv_ldc_copy) -END(hv_ldc_copy) - -/* - * attempt to map into the local guest's real address space the - * page identified by the shared memory cookie - * - * arg0 channel (%o0) - * arg1 cookie (%o1) - * - * ret0 status (%o0) - * ret1 raddr (%o1) - * ret2 perms (%o2) - * - */ -ENTRY(hv_ldc_mapin) - mov %o3, %o4 - mov %o2, %o3 - mov LDC_MAPIN, %o5 - ta FAST_TRAP - stx %o1, [%o3] - retl - stx %o2, [%o4] -END(hv_ldc_mapin) - -/* - * attempt unmap from the local guest's real address space the imported - * page mapped at the real address raddr - * - * arg0 raddr (%o0) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_unmap) - mov LDC_UNMAP, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_unmap) - -/* - * forcibly unmap from a remote guest's real address space a page - * previously exported by the local guest - * - * arg0 channel (%o0) - * arg1 cookie (%o1) - * arg2 revoke_cookie (%o2) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_ldc_revoke) - mov LDC_REVOKE, %o5 - ta FAST_TRAP - retl - nop -END(hv_ldc_revoke) - -/* - * Section 20 PCI I/O Services - * - */ - -/* - * create iommu mappings in the device defined by devhandle - * - * arg0 devhandle (%o0) - * arg1 tsbid (%o1) - * arg2 nttes (%o2) - * arg3 io_attributes (%o3) - * arg4 io_page_list_p (%o4) - * - * ret0 status (%o0) - * ret1 nttes_mapped (%o1) - * - */ -ENTRY(hv_pci_iommu_map) - save %sp, -CCFSZ, %sp - mov %i0, %o0 - mov %i1, %o1 - mov %i2, %o2 - mov %i3, %o3 - mov %i4, %o4 - mov PCI_IOMMU_MAP, %o5 - ta FAST_TRAP - brnz %o0, 1f - mov %o0, %i0 - stuw %o1, [%i5] -1: - ret - restore -END(hv_pci_iommu_map) - -/* - * demap and flush iommu mappings in the device defined by devhandle - * - * arg0 devhandle (%o0) - * arg1 tsbid (%o1) - * arg2 nttes (%o2) - * - * ret0 status (%o0) - * ret1 nttes_demapped (%o1) - * - */ -ENTRY(hv_pci_iommu_demap) - mov PCI_IOMMU_DEMAP, %o5 - ta FAST_TRAP - brz,a %o0, 1f - stuw %o1, [%o3] -1: retl - nop -END(hv_pci_iommu_demap) - -/* - * read and return the mapping in the device defined by devhandle - * - * arg0 devhandle (%o0) - * arg1 tsbid (%o1) - * - * ret0 status (%o0) - * ret1 io_attributes (%o1) - * ret2 ra (%o2) - * - */ -ENTRY(hv_pci_iommu_getmap) - mov %o3, %o4 - mov %o2, %o3 - mov PCI_IOMMU_GETMAP, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - st %o1, [%o3] - stx %o2, [%o4] -1: retl - nop -END(hv_pci_iommu_getmap) - -/* - * create a "special" mapping in the device given by devhandle - * - * arg0 devhandle (%o0) - * arg1 r_addr (%o1) - * arg2 io_attributes (%o2) - * - * ret0 status (%o0) - * ret1 io_addr (%o1) - * - */ -ENTRY(hv_pci_iommu_getbypass) - mov PCI_IOMMU_GETBYPASS, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o3] -1: retl - nop -END(hv_pci_iommu_getbypass) - -/* - * read PCI configuration space for adapter specified by devhandle - * - * arg0 devhandle (%o0) - * arg1 pci_device (%o1) - * arg2 pci_config_offset(%o2) - * arg3 size (%o3) - * - * ret0 status (%o0) - * ret1 error_flag (%o1) - * ret2 data (%o2) - * - */ -ENTRY(hv_pci_config_get) - mov PCI_CONFIG_GET, %o5 - ta FAST_TRAP - brnz %o0, 1f - movrnz %o1, -1, %o2 - brz,a %o1, 1f - stuw %o2, [%o4] -1: retl - nop -END(hv_pci_config_get) - -/* - * write PCI config space for the PCI adapter - * specified by devhandle - * - * arg0 devhandle (%o0) - * arg1 pci_device (%o1) - * arg2 pci_config_offset(%o2) - * arg3 size (%o3) - * arg4 data (%o4) - * - * ret0 status (%o0) - * ret1 error_flag (%o1) - * - */ -ENTRY(hv_pci_config_put) - mov PCI_CONFIG_PUT, %o5 - ta FAST_TRAP - retl - nop -END(hv_pci_config_put) - -/* - * read the io-address given by devhandle, raddr, and size - * - * arg0 devhandle (%o0) - * arg1 raddr (%o1) - * arg2 size (%o2) - * - * ret0 status (%o0) - * ret1 error_flag (%o1) - * ret2 data (%o2) - * - */ -ENTRY(hv_pci_peek) - mov PCI_PEEK, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - st %o1, [%o3] - stx %o2, [%o4] -1: retl - nop -END(hv_pci_peek) - -/* - * attempt to write data to the io-address - * specified by devhandle, raddr, and size - * - * arg0 devhandle (%o0) - * arg1 raddr (%o1) - * arg2 size (%o2) - * arg3 data (%o3) - * arg4 pci_device (%o4) - * - * ret0 status (%o0) - * ret1 error_flag (%o1) - * - */ -ENTRY(hv_pci_poke) - save %sp, -CCFSZ, %sp - mov %i0, %o0 - mov %i1, %o1 - mov %i2, %o2 - mov %i3, %o3 - mov %i4, %o4 - mov PCI_POKE, %o5 - ta FAST_TRAP - brnz %o0, 1f - mov %o0, %i0 - stuw %o1, [%i5] -1: - ret - restore -END(hv_pci_poke) - -/* - * attempt to write data to the io-address - * specified by devhandle, raddr, and size - * - * arg0 devhandle (%o0) - * arg1 raddr (%o1) - * arg2 size (%o2) - * arg3 io_sync_direction(%o3) - * - * ret0 status (%o0) - * ret1 nsynced (%o1) - * - */ -ENTRY(hv_pci_dma_sync) - mov PCI_DMA_SYNC, %o5 - ta FAST_TRAP - brnz %o0, 1f - nop - stx %o1, [%o4] -1: retl - nop -END(hv_pci_dma_sync) - -/* - * Section 21 MSI Services - * - */ - -ENTRY(hv_pci_msiq_conf) -END(hv_pci_msiq_conf) - -ENTRY(hv_pci_msiq_info) -END(hv_pci_msiq_info) - -ENTRY(hv_pci_msiq_getvalid) -END(hv_pci_msiq_getvalid) - -ENTRY(hv_pci_msiq_setvalid) -END(hv_pci_msiq_setvalid) - -ENTRY(hv_pci_msiq_getstate) -END(hv_pci_msiq_getstate) - -ENTRY(hv_pci_msiq_setstate) -END(hv_pci_msiq_setstate) - -ENTRY(hv_pci_msiq_gethead) -END(hv_pci_msiq_gethead) - -ENTRY(hv_pci_msiq_sethead) -END(hv_pci_msiq_sethead) - -ENTRY(hv_pci_msiq_gettail) -END(hv_pci_msiq_gettail) - -ENTRY(hv_pci_msi_getvalid) -END(hv_pci_msi_getvalid) - -ENTRY(hv_pci_msi_setvalid) -END(hv_pci_msi_setvalid) - -ENTRY(hv_pci_msi_getmsiq) -END(hv_pci_msi_getmsiq) - -ENTRY(hv_pci_msi_setmsiq) -END(hv_pci_msi_setmsiq) - -ENTRY(hv_pci_msi_getstate) -END(hv_pci_msi_getstate) - -ENTRY(hv_pci_msi_setstate) -END(hv_pci_msi_setstate) - -ENTRY(hv_pci_msg_getmsiq) -END(hv_pci_msg_getmsiq) - -ENTRY(hv_pci_msg_setmsiq) -END(hv_pci_msg_setmsiq) - -ENTRY(hv_pci_msg_getvalid) -END(hv_pci_msg_getvalid) - -ENTRY(hv_pci_msg_setvalid) -END(hv_pci_msg_setvalid) - -/* - * Section 22 UltraSPARC T1 Performance Counters - * - */ - - -/* - * read the value of the DRAM/JBus performance register as selected by - * the perfreg argument - * - * arg0 perfreg (%o0) - * - * ret0 status (%o0) - * ret1 value (%o1) - * - */ -ENTRY(hv_niagara_get_perfreg) - mov %o1, %o2 - mov NIAGARA_GET_PERFREG, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_niagara_get_perfreg) - -/* - * set the value of the DRAM/JBus performance register as selected by - * the perfreg argument - * - * arg0 perfreg (%o0) - * arg1 value (%o1) - * - * ret0 status (%o0) - * - */ -ENTRY(hv_niagara_set_perfreg) - mov NIAGARA_SET_PERFREG, %o5 - ta FAST_TRAP - retl - nop -END(hv_niagara_set_perfreg) - -/* - * Section 23 UltraSPARC T1 MMU Statistics Counters - * - */ - -/* - * enable MMU statistics collection and supply the buffer to deposit the - * results for the current virtual cpu - * - * arg0 raddr (%o0) - * - * ret0 status (%o0) - * ret1 prev_raddr (%o1) - * - */ -ENTRY(hv_niagara_mmustat_conf) - mov %o1, %o2 - mov NIAGARA_MMUSTAT_CONF, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_niagara_mmustat_conf) - -/* - * query the status and the real address for the currently configured buffer - * - * ret0 status (%o0) - * ret1 raddr (%o1) - * - */ -ENTRY(hv_niagara_mmustat_info) - mov %o0, %o2 - mov NIAGARA_MMUSTAT_INFO, %o5 - ta FAST_TRAP - retl - stx %o1, [%o2] -END(hv_niagara_mmustat_info) - -/* - * Simulator Services - * - */ - -ENTRY(hv_magic_trap_on) - ta 0x77 - retl - nop -END(hv_magic_trap_on) - -ENTRY(hv_magic_trap_off) - ta 0x78 - retl - nop -END(hv_magic_trap_off) - - -ENTRY(hv_sim_read) - mov SIM_READ, %o5 - ta FAST_TRAP - retl - nop -END(hv_read) - -ENTRY(hv_sim_write) - mov SIM_WRITE, %o5 - ta FAST_TRAP - retl - nop -END(hv_write) - - diff --git a/sys/sun4v/sun4v/hv_pci.c b/sys/sun4v/sun4v/hv_pci.c deleted file mode 100644 index 6d691ba83632..000000000000 --- a/sys/sun4v/sun4v/hv_pci.c +++ /dev/null @@ -1,488 +0,0 @@ -/*- - * Copyright 2006 John-Mark Gurney. - * 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 -__FBSDID("$FreeBSD$"); - -/* - * Support for the Hypervisor PCI bus. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "pcib_if.h" - -/* - * XXX - should get this through the bus, but Sun overloaded the reg OFW - * property, so there isn't normal resources associated w/ this device. - */ -extern struct bus_space_tag nexus_bustag; -/* - * Methods - */ -static device_probe_t hvpci_probe; -static device_attach_t hvpci_attach; -static bus_read_ivar_t hvpci_read_ivar; -static bus_write_ivar_t hvpci_write_ivar; -static bus_alloc_resource_t hvpci_alloc_resource; -static bus_activate_resource_t hvpci_activate_resource; -static bus_deactivate_resource_t hvpci_deactivate_resource; -static bus_release_resource_t hvpci_release_resource; -static bus_get_dma_tag_t hvpci_get_dma_tag; -static pcib_maxslots_t hvpci_maxslots; -static pcib_read_config_t hvpci_read_config; -static pcib_write_config_t hvpci_write_config; -static pcib_route_interrupt_t hvpci_route_interrupt; -static ofw_bus_get_node_t hvpci_get_node; - -static device_method_t hv_pcib_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hvpci_probe), - DEVMETHOD(device_attach, hvpci_attach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, hvpci_read_ivar), - DEVMETHOD(bus_write_ivar, hvpci_write_ivar), - DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), - DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), - DEVMETHOD(bus_alloc_resource, hvpci_alloc_resource), - DEVMETHOD(bus_activate_resource, hvpci_activate_resource), - DEVMETHOD(bus_deactivate_resource, hvpci_deactivate_resource), - DEVMETHOD(bus_release_resource, hvpci_release_resource), - DEVMETHOD(bus_get_dma_tag, hvpci_get_dma_tag), - - /* pcib interface */ - DEVMETHOD(pcib_maxslots, hvpci_maxslots), - DEVMETHOD(pcib_read_config, hvpci_read_config), - DEVMETHOD(pcib_write_config, hvpci_write_config), - DEVMETHOD(pcib_route_interrupt, hvpci_route_interrupt), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_node, hvpci_get_node), - - { 0, 0 } -}; - -static driver_t hvpci_driver = { - "pcib", - hv_pcib_methods, - sizeof(struct hvpci_softc), -}; - -static devclass_t hvpci_devclass; - -DRIVER_MODULE(hvpci, nexus, hvpci_driver, hvpci_devclass, 0, 0); - -static int -hvpci_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "pci") != 0) - return (ENXIO); - - device_set_desc(dev, "Hypervisor PCI Bridge"); - return (0); -} - -static int -hvpci_attach(device_t dev) -{ - struct ofw_pci_ranges *range; - struct rman *rmanp; - struct hvpci_softc *sc; - struct hviommu *himp; - bus_space_tag_t *btp; - phandle_t node; - uint32_t *dvma; - int br[2]; - int n, type; - int i, nrange; - - sc = device_get_softc(dev); - - node = ofw_bus_get_node(dev); - if (node == -1) - panic("%s: ofw_bus_get_node failed.", __func__); - - sc->hs_node = node; - - /* Setup the root bus number for this bus */ - n = OF_getprop(node, "bus-range", &br[0], sizeof br); - if (n == -1) - panic("%s: could not get bus-range", __func__); - if (n != sizeof br) - panic("%s: broken bus-range (%d)", __func__, n); - sc->hs_busnum = br[0]; - - /* Setup the HyperVisor devhandle for this bus */ - sc->hs_devhandle = nexus_get_devhandle(dev); - - /* Pull in the ra addresses out of OFW */ - nrange = OF_getprop_alloc(node, "ranges", sizeof *range, - (void **)&range); - - /* Initialize memory and I/O rmans. */ - for (i = 0; i < nrange; i++) { -/* XXX - from sun4v/io/px/px_lib4v.c: px_ranges_phi_mask */ -#define PHYS_MASK ((1ll << (28 + 32)) - 1) - switch (OFW_PCI_RANGE_CS(&range[i])) { - case OFW_PCI_CS_IO: - rmanp = &sc->hs_pci_io_rman; - rmanp->rm_descr = "HyperVisor PCI I/O Ports"; - btp = &sc->hs_pci_iot; - sc->hs_pci_ioh = OFW_PCI_RANGE_PHYS(&range[i]) & - PHYS_MASK; - type = PCI_IO_BUS_SPACE; -#ifdef DEBUG - printf("io handle: %#lx\n", sc->hs_pci_ioh); -#endif - break; - - case OFW_PCI_CS_MEM32: - rmanp = &sc->hs_pci_mem_rman; - rmanp->rm_descr = "HyperVisor PCI Memory"; - btp = &sc->hs_pci_memt; - sc->hs_pci_memh = OFW_PCI_RANGE_PHYS(&range[i]) & - PHYS_MASK; - type = PCI_MEMORY_BUS_SPACE; - break; - - case OFW_PCI_CS_MEM64: - continue; - - default: - panic("%s: unknown range type: %d", __func__, - OFW_PCI_RANGE_CS(&range[i])); - } - rmanp->rm_type = RMAN_ARRAY; - if (rman_init(rmanp) != 0 || rman_manage_region(rmanp, 0, - OFW_PCI_RANGE_SIZE(&range[i])) != 0) - panic("%s: failed to set up rman type: %d", __func__, - OFW_PCI_RANGE_CS(&range[i])); - - *btp = (bus_space_tag_t)malloc(sizeof **btp, M_DEVBUF, - M_WAITOK|M_ZERO); - (*btp)->bst_parent = &nexus_bustag; - (*btp)->bst_type = type; - } - free(range, M_OFWPROP); - - nrange = OF_getprop_alloc(node, "virtual-dma", sizeof *dvma, - (void **)&dvma); - KASSERT(nrange == 2, ("virtual-dma propery invalid")); - - /* Setup bus_dma_tag */ - himp = hviommu_init(sc->hs_devhandle, dvma[0], dvma[1]); - sc->hs_dmatag.dt_cookie = himp; - sc->hs_dmatag.dt_mt = &hviommu_dma_methods; - sc->hs_dmatag.dt_lowaddr = ~0; - sc->hs_dmatag.dt_highaddr = ~0; - sc->hs_dmatag.dt_boundary = BUS_SPACE_MAXADDR_32BIT + 1; - - free(dvma, M_OFWPROP); - - /* Setup ofw imap */ - ofw_bus_setup_iinfo(node, &sc->hs_pci_iinfo, sizeof(ofw_pci_intr_t)); - - device_add_child(dev, "pci", -1); - - return (bus_generic_attach(dev)); -} - -static int -hvpci_maxslots(device_t dev) -{ - - return (0); -} - -#define HVPCI_BDF(b, d, f) \ - ((b & 0xff) << 16) | ((d & 0x1f) << 11) | ((f & 0x7) << 8) -static uint32_t -hvpci_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - int width) -{ - struct hvpci_softc *sc; - uint32_t data = -1; - uint64_t r; - uint32_t ret; - - sc = device_get_softc(dev); - - r = hv_pci_config_get(sc->hs_devhandle, HVPCI_BDF(bus, slot, func), - reg, width, (pci_cfg_data_t *)&data); - - if (r == H_EOK) { - switch (width) { - case 1: - ret = data & 0xff; - if (ret == 0 && reg == PCIR_INTLINE) - ret = PCI_INVALID_IRQ; - break; - case 2: - ret = data & 0xffff; - break; - case 4: - ret = data; - break; - default: - ret = -1; - } - return ret; - } - - return -1; -} - -static void -hvpci_write_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg, - uint32_t val, int width) -{ - struct hvpci_softc *sc; - pci_cfg_data_t data = { 0 }; - uint64_t r; - - sc = device_get_softc(dev); - switch (width) { - case 1: - data.qw = (uint8_t)val; - break; - case 2: - data.qw = (uint16_t)(val & 0xffff); - break; - case 4: - data.qw = (uint32_t)val; - break; - default: - panic("unsupported width: %d", width); - } - - r = hv_pci_config_put(sc->hs_devhandle, HVPCI_BDF(bus, slot, func), - reg, width, (pci_cfg_data_t)data); - - if (r) - printf("put failed with: %ld\n", r); -} - -static int -hvpci_route_interrupt(device_t bridge, device_t dev, int pin) -{ - struct hvpci_softc *sc; - struct ofw_pci_register reg; - phandle_t node; - ofw_pci_intr_t pintr, mintr; - int obli; - uint8_t maskbuf[sizeof(reg) + sizeof(pintr)]; - - sc = device_get_softc(bridge); - node = ofw_bus_get_node(dev); - pintr = pin; - obli = ofw_bus_lookup_imap(node, &sc->hs_pci_iinfo, ®, sizeof(reg), - &pintr, sizeof(pintr), &mintr, sizeof(mintr), NULL, maskbuf); - device_printf(dev, "called hvpci_route_intr: %d, got: mintr: %#x\n", - obli, mintr); - if (obli) - return (mintr); - - panic("pin %d not found in imap of %s", pin, device_get_nameunit(bridge)); -} - -static phandle_t -hvpci_get_node(device_t bus, device_t dev) -{ - struct hvpci_softc *sc; - - sc = device_get_softc(bus); - - return (sc->hs_node); -} - -static int -hvpci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct hvpci_softc *sc; - - sc = device_get_softc(dev); - - switch (which) { - case PCIB_IVAR_DOMAIN: - *result = 0; - return (0); - case PCIB_IVAR_BUS: - *result = sc->hs_busnum; - return (0); - } - - return (ENOENT); -} - -static int -hvpci_write_ivar(device_t dev, device_t child, int which, uintptr_t value) -{ - struct hvpci_softc *sc; - - sc = device_get_softc(dev); - switch (which) { - case PCIB_IVAR_DOMAIN: - return (EINVAL); - case PCIB_IVAR_BUS: - sc->hs_busnum = value; - return (0); - } - - return (ENOENT); -} - -static struct resource * -hvpci_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct hvpci_softc *sc; - struct resource *rv; - struct rman *rm; - bus_space_tag_t bt; - bus_space_handle_t bh; - int needactivate; - - sc = device_get_softc(bus); - - needactivate = flags & RF_ACTIVE; - flags &= ~RF_ACTIVE; - - switch (type) { - case SYS_RES_IRQ: - return BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, - rid, start, end, count, flags); - break; - - case SYS_RES_MEMORY: - rm = &sc->hs_pci_mem_rman; - bt = sc->hs_pci_memt; - bh = sc->hs_pci_memh; - break; - - case SYS_RES_IOPORT: -#ifdef DEBUG - printf("alloc: start: %#lx, end: %#lx, count: %#lx\n", start, end, count); -#endif - rm = &sc->hs_pci_io_rman; - bt = sc->hs_pci_iot; - bh = sc->hs_pci_ioh; - break; - - default: - return (NULL); - } - - rv = rman_reserve_resource(rm, start, end, count, flags, child); - if (rv == NULL) - return (NULL); - - bh += rman_get_start(rv); - rman_set_bustag(rv, bt); - rman_set_bushandle(rv, bh); - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv)) { - rman_release_resource(rv); - return (NULL); - } - } - - return (rv); -} - -static int -hvpci_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - void *p; - - if (type == SYS_RES_MEMORY) { - /* XXX - we may still need to set the IE bit on the mapping */ - p = (void *)TLB_PHYS_TO_DIRECT(rman_get_bushandle(r)); - rman_set_virtual(r, p); - } - return (rman_activate_resource(r)); -} - -static int -hvpci_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - - return (0); -} - -static int -hvpci_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - - return (0); -} - -static bus_dma_tag_t -hvpci_get_dma_tag(device_t bus, device_t child) -{ - struct hvpci_softc *sc; - - sc = device_get_softc(bus); - - return &sc->hs_dmatag; -} diff --git a/sys/sun4v/sun4v/hvcons.c b/sys/sun4v/sun4v/hvcons.c deleted file mode 100644 index 60f830b08c7f..000000000000 --- a/sys/sun4v/sun4v/hvcons.c +++ /dev/null @@ -1,371 +0,0 @@ -/*- - * Copyright (C) 2006 Kip Macy - * 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 Kip Macy ``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 Kip Macy 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "mdesc_bus_if.h" - -#include "opt_simulator.h" - -#include -#include -#include - -#define HVCN_POLL_FREQ 10 - -static tsw_open_t hvcn_open; -static tsw_outwakeup_t hvcn_outwakeup; -static tsw_close_t hvcn_close; - -static struct ttydevsw hvcn_class = { - .tsw_open = hvcn_open, - .tsw_outwakeup = hvcn_outwakeup, - .tsw_close = hvcn_close, -}; - -#define PCBURST 16 -static struct tty *hvcn_tp = NULL; -static struct resource *hvcn_irq; -static void *hvcn_intrhand; - -static int bufindex; -static int buflen; -static u_char buf[PCBURST]; -static int polltime; -static struct callout_handle hvcn_timeouthandle - = CALLOUT_HANDLE_INITIALIZER(&hvcn_timeouthandle); - -#if defined(KDB) -static int alt_break_state; -#endif - -static void hvcn_timeout(void *); - -static cn_probe_t hvcn_cnprobe; -static cn_init_t hvcn_cninit; -static cn_getc_t hvcn_cngetc; -static cn_putc_t hvcn_cnputc; -static cn_term_t hvcn_cnterm; - - -CONSOLE_DRIVER(hvcn); - -void -hv_cnputs(char *p) -{ - int c, error; - - while ((c = *p++) != '\0') { - if (c == '\n') { - do { - error = hv_cons_putchar('\r'); - } while (error == H_EWOULDBLOCK); - } - do { - error = hv_cons_putchar(c); - } while (error == H_EWOULDBLOCK); - } -} - -static int -hvcn_open(struct tty *tp) -{ - - /* - * Set up timeout to trigger fake interrupts to transmit - * trailing data. - */ - polltime = hz / HVCN_POLL_FREQ; - if (polltime < 1) - polltime = 1; - hvcn_timeouthandle = timeout(hvcn_timeout, tp, polltime); - - buflen = 0; - - return (0); -} - -static void -hvcn_close(struct tty *tp) -{ - untimeout(hvcn_timeout, tp, hvcn_timeouthandle); -} - -static void -hvcn_cnprobe(struct consdev *cp) -{ - -#if 0 - char name[64]; - - node = OF_peer(0); - if (node == -1) - panic("%s: OF_peer failed.", __func__); - - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - OF_getprop(node, "name", name, sizeof(name)); - if (!strcmp(name, "virtual-devices")) - break; - } - - if (node == 0) - goto done; - - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - OF_getprop(node, "name", name, sizeof(name)); - if (!strcmp(name, "console")) - break; - } -done: -#endif - cp->cn_pri = CN_NORMAL; - -} - -static void -hvcn_cninit(struct consdev *cp) -{ - - strcpy(cp->cn_name, "hvcn"); -} - -static int -hvcn_cngetc(struct consdev *cp) -{ - unsigned char ch; - int l; - - ch = '\0'; - - while ((l = hv_cons_getchar(&ch)) != H_EOK) { -#if defined(KDB) - int kdb_brk; - - if (l == H_BREAK || l == H_HUP) - kdb_enter(KDB_WHY_BREAK, "Break sequence on console"); - - if ((kdb_brk = kdb_alt_break(ch, &alt_break_state)) != 0) { - switch (kdb_brk) { - case KDB_REQ_DEBUGGER: - kdb_enter(KDB_WHY_BREAK, - "Break sequence on console"); - break; - case KDB_REQ_PANIC: - kdb_panic("Panic sequence on console"); - break; - case KDB_REQ_REBOOT: - kdb_reboot(); - break; - } - } -#endif - if (l != -2 && l != 0) { - return (-1); - } - } - - - - return (ch); -} - -static int -hvcn_cncheckc(struct consdev *cp) -{ - unsigned char ch; - int l; - - if ((l = hv_cons_getchar(&ch)) == H_EOK) { -#if defined(KDB) - if (l == H_BREAK || l == H_HUP) - kdb_enter(KDB_WHY_BREAK, "Break sequence on console"); - if (kdb_alt_break(ch, &alt_break_state)) - kdb_enter(KDB_WHY_BREAK, "Break sequence on console"); -#endif - return (ch); - } - - return (-1); -} - - -static void -hvcn_cnterm(struct consdev *cp) -{ - ; -} - -static void -hvcn_cnputc(struct consdev *cp, int c) -{ - - int error; - - error = 0; - do { - if (c == '\n') - error = hv_cons_putchar('\r'); - } while (error == H_EWOULDBLOCK); - do { - error = hv_cons_putchar(c); - } while (error == H_EWOULDBLOCK); -} - -static void -hvcn_outwakeup(struct tty *tp) -{ - - for (;;) { - /* Refill the input buffer. */ - if (buflen == 0) { - buflen = ttydisc_getc(tp, buf, PCBURST); - bufindex = 0; - } - - /* Transmit the input buffer. */ - while (buflen) { - if (hv_cons_putchar(buf[bufindex]) == H_EWOULDBLOCK) - return; - bufindex++; - buflen--; - } - } -} - -static void -hvcn_intr(void *v) -{ - struct tty *tp = v; - int c; - - tty_lock(tp); - - /* Receive data. */ - while ((c = hvcn_cncheckc(NULL)) != -1) - ttydisc_rint(tp, c, 0); - ttydisc_rint_done(tp); - - /* Transmit trailing data. */ - hvcn_outwakeup(tp); - tty_unlock(tp); -} - -static void -hvcn_timeout(void *v) -{ - hvcn_intr(v); - - hvcn_timeouthandle = timeout(hvcn_timeout, v, polltime); -} - - -static int -hvcn_dev_probe(device_t dev) -{ - - if (strcmp(mdesc_bus_get_name(dev), "console")) - return (ENXIO); - - device_set_desc(dev, "sun4v virtual console"); - - return (0); -} - - -static int -hvcn_dev_attach(device_t dev) -{ - - struct tty *tp; - int error, rid; - - /* belongs in attach - but attach is getting called multiple times - * for reasons I have not delved into - */ - - if (hvcn_consdev.cn_pri == CN_DEAD || - hvcn_consdev.cn_name[0] == '\0') - return (ENXIO); - - tp = tty_alloc(&hvcn_class, NULL); - tty_makedev(tp, NULL, "v%r", 1); - tty_makealias(tp, "hvcn"); - - rid = 0; - - if ((hvcn_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(dev, "couldn't map interrupt\n"); - error = ENXIO; - goto fail; - - } - error = bus_setup_intr(dev, hvcn_irq, INTR_TYPE_TTY, NULL, hvcn_intr, hvcn_tp, - hvcn_intrhand); - - if (error) - device_printf(dev, "couldn't set up irq\n"); - - -fail: - return (error); - -} - -static device_method_t hvcn_methods[] = { - DEVMETHOD(device_probe, hvcn_dev_probe), - DEVMETHOD(device_attach, hvcn_dev_attach), - {0, 0} -}; - - -static driver_t hvcn_driver = { - "hvcn", - hvcn_methods, - 0, -}; - - -static devclass_t hvcn_devclass; - -DRIVER_MODULE(hvcn, vnex, hvcn_driver, hvcn_devclass, 0, 0); diff --git a/sys/sun4v/sun4v/hviommu.c b/sys/sun4v/sun4v/hviommu.c deleted file mode 100644 index 88ea70c5e11f..000000000000 --- a/sys/sun4v/sun4v/hviommu.c +++ /dev/null @@ -1,935 +0,0 @@ -/*- - * Copyright (c) 1999, 2000 Matthew R. Green - * 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 ``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 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: iommu.c,v 1.82 2008/05/30 02:29:37 mrg Exp - */ -/*- - * Copyright (c) 1999-2002 Eduardo Horvath - * Copyright (c) 2001-2003 Thomas Moestl - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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: sbus.c,v 1.50 2002/06/20 18:26:24 eeh Exp - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - - -#include - -/* - * Tuning constants. - */ -#define IOMMU_MAX_PRE (32 * 1024) -#define IOMMU_MAX_PRE_SEG 3 - -#define IO_PAGE_SIZE PAGE_SIZE_8K -#define IO_PAGE_MASK PAGE_MASK_8K -#define IO_PAGE_SHIFT PAGE_SHIFT_8K -#define round_io_page(x) round_page(x) -#define trunc_io_page(x) trunc_page(x) - - -MALLOC_DEFINE(M_HVIOMMU, "hviommu", "HyperVisor IOMMU"); - -TAILQ_HEAD(hviommu_maplruq_head, bus_dmamap); - -struct hviommu { - struct mtx him_mtx; - - devhandle_t him_handle; - u_long him_dvmabase; - u_long him_dvmasize; - - struct hviommu_maplruq_head him_maplruq; - struct rman him_rman; -}; - -#define VA_TO_TSBID(him, va) ((va - (him)->him_dvmabase) >> IO_PAGE_SHIFT) - -#ifdef IOMMU_DEBUG -#define DPRINTF printf -#else -#define DPRINTF(...) -#endif - -/* - * Always overallocate one page; this is needed to handle alignment of the - * buffer, so it makes sense using a lazy allocation scheme. - */ -#define IOMMU_SIZE_ROUNDUP(sz) \ - (round_io_page(sz) + IO_PAGE_SIZE) - -/* Resource helpers */ -#define IOMMU_RES_TO(v) ((v) >> IO_PAGE_SHIFT) -#define IOMMU_RES_START(res) \ - ((bus_addr_t)rman_get_start(res) << IO_PAGE_SHIFT) -#define IOMMU_RES_END(res) \ - ((bus_addr_t)(rman_get_end(res) + 1) << IO_PAGE_SHIFT) -#define IOMMU_RES_SIZE(res) \ - ((bus_size_t)rman_get_size(res) << IO_PAGE_SHIFT) - -/* Helpers for struct bus_dmamap_res */ -#define BDR_START(r) IOMMU_RES_START((r)->dr_res) -#define BDR_END(r) IOMMU_RES_END((r)->dr_res) -#define BDR_SIZE(r) IOMMU_RES_SIZE((r)->dr_res) - -/* Locking macros. */ -#define HIM_LOCK(him) mtx_lock(&him->him_mtx) -#define HIM_LOCK_ASSERT(him) mtx_assert(&him->him_mtx, MA_OWNED) -#define HIM_UNLOCK(him) mtx_unlock(&him->him_mtx) - -/* LRU queue handling for lazy resource allocation. */ -static __inline void -hviommu_map_insq(struct hviommu *him, bus_dmamap_t map) -{ - - HIM_LOCK_ASSERT(him); - if (!SLIST_EMPTY(&map->dm_reslist)) { - if (map->dm_onq) - TAILQ_REMOVE(&him->him_maplruq, map, dm_maplruq); - TAILQ_INSERT_TAIL(&him->him_maplruq, map, dm_maplruq); - map->dm_onq = 1; - } -} - -static __inline void -hviommu_map_remq(struct hviommu *him, bus_dmamap_t map) -{ - - HIM_LOCK_ASSERT(him); - if (map->dm_onq) - TAILQ_REMOVE(&him->him_maplruq, map, dm_maplruq); - map->dm_onq = 0; -} - -struct hviommu * -hviommu_init(devhandle_t dh, u_long dvmabase, u_long dvmasize) -{ - struct hviommu *him; - u_long end; - - him = malloc(sizeof *him, M_HVIOMMU, M_WAITOK|M_ZERO); - - mtx_init(&him->him_mtx, "hviommu", NULL, MTX_DEF); - him->him_handle = dh; - him->him_dvmabase = dvmabase; - him->him_dvmasize = dvmasize; - - TAILQ_INIT(&him->him_maplruq); - him->him_rman.rm_type = RMAN_ARRAY; - him->him_rman.rm_descr = "HyperVisor IOMMU Memory"; - end = him->him_dvmabase + him->him_dvmasize - 1; - if (rman_init(&him->him_rman) != 0 || - rman_manage_region(&him->him_rman, him->him_dvmabase >> - IO_PAGE_SHIFT, end >> IO_PAGE_SHIFT) != 0) - panic("%s: can't initalize rman", __func__); - - return him; -} - -static void -hviommu_remove(struct hviommu *him, vm_offset_t va, vm_size_t len) -{ - uint64_t error; - pages_t demapped; - - KASSERT(va >= him->him_dvmabase, - ("%s: va 0x%lx not in DVMA space", __func__, (u_long)va)); - KASSERT(va + len >= va, - ("%s: va 0x%lx + len 0x%lx wraps", __func__, (long)va, (long)len)); - KASSERT((va & IO_PAGE_MASK) == 0 && (len & IO_PAGE_MASK) == 0, - ("%s: va %#lx or len %#lx not page aligned", __func__, va, len)); - while (len > 0) { - if ((error = hv_pci_iommu_demap(him->him_handle, - VA_TO_TSBID(him, va), len >> IO_PAGE_SHIFT, &demapped))) { - printf("%s: demap: va: %#lx, npages: %#lx, err: %ld\n", - __func__, va, len >> IO_PAGE_SHIFT, error); - demapped = 1; - } - va += demapped << IO_PAGE_SHIFT; - len -= demapped << IO_PAGE_SHIFT; - } -} - -/* - * Allocate DVMA virtual memory for a map. The map may not be on a queue, so - * that it can be freely modified. - */ -static int -hviommu_dvma_valloc(bus_dma_tag_t t, struct hviommu *him, bus_dmamap_t map, - bus_size_t size) -{ - struct resource *res; - struct bus_dmamap_res *bdr; - bus_size_t align, sgsize; - - KASSERT(!map->dm_onq, ("hviommu_dvma_valloc: map on queue!")); - if ((bdr = malloc(sizeof(*bdr), M_HVIOMMU, M_NOWAIT)) == NULL) - return (EAGAIN); - - /* - * If a boundary is specified, a map cannot be larger than it; however - * we do not clip currently, as that does not play well with the lazy - * allocation code. - * Alignment to a page boundary is always enforced. - */ - align = (t->dt_alignment + IO_PAGE_MASK) >> IO_PAGE_SHIFT; - sgsize = IOMMU_RES_TO(round_io_page(size)); - if (t->dt_boundary > 0 && t->dt_boundary < IO_PAGE_SIZE) - panic("hviommu_dvmamap_load: illegal boundary specified"); - res = rman_reserve_resource_bound(&him->him_rman, 0L, - IOMMU_RES_TO(t->dt_lowaddr), sgsize, - IOMMU_RES_TO(t->dt_boundary), - RF_ACTIVE | rman_make_alignment_flags(align), NULL); - if (res == NULL) { - free(bdr, M_HVIOMMU); - return (ENOMEM); - } - - bdr->dr_res = res; - bdr->dr_used = 0; - SLIST_INSERT_HEAD(&map->dm_reslist, bdr, dr_link); - return (0); -} - -/* Unload the map and mark all resources as unused, but do not free them. */ -static void -hviommu_dvmamap_vunload(struct hviommu *him, bus_dmamap_t map) -{ - struct bus_dmamap_res *r; - - SLIST_FOREACH(r, &map->dm_reslist, dr_link) { - hviommu_remove(him, BDR_START(r), BDR_SIZE(r)); - r->dr_used = 0; - } -} - -/* Free a DVMA virtual memory resource. */ -static __inline void -hviommu_dvma_vfree_res(bus_dmamap_t map, struct bus_dmamap_res *r) -{ - - KASSERT(r->dr_used == 0, ("hviommu_dvma_vfree_res: resource busy!")); - if (r->dr_res != NULL && rman_release_resource(r->dr_res) != 0) - printf("warning: DVMA space lost\n"); - SLIST_REMOVE(&map->dm_reslist, r, bus_dmamap_res, dr_link); - free(r, M_HVIOMMU); -} - -/* Free all DVMA virtual memory for a map. */ -static void -hviommu_dvma_vfree(struct hviommu *him, bus_dmamap_t map) -{ - - HIM_LOCK(him); - hviommu_map_remq(him, map); - hviommu_dvmamap_vunload(him, map); - HIM_UNLOCK(him); - while (!SLIST_EMPTY(&map->dm_reslist)) - hviommu_dvma_vfree_res(map, SLIST_FIRST(&map->dm_reslist)); -} - -/* Prune a map, freeing all unused DVMA resources. */ -static bus_size_t -hviommu_dvma_vprune(struct hviommu *him, bus_dmamap_t map) -{ - struct bus_dmamap_res *r, *n; - bus_size_t freed = 0; - - HIM_LOCK_ASSERT(him); - for (r = SLIST_FIRST(&map->dm_reslist); r != NULL; r = n) { - n = SLIST_NEXT(r, dr_link); - if (r->dr_used == 0) { - freed += BDR_SIZE(r); - hviommu_dvma_vfree_res(map, r); - } - } - if (SLIST_EMPTY(&map->dm_reslist)) - hviommu_map_remq(him, map); - return (freed); -} - -/* - * Try to find a suitably-sized (and if requested, -aligned) slab of DVMA - * memory with IO page offset voffs. - */ -static bus_addr_t -hviommu_dvma_vfindseg(bus_dmamap_t map, vm_offset_t voffs, bus_size_t size, - bus_addr_t amask) -{ - struct bus_dmamap_res *r; - bus_addr_t dvmaddr, dvmend; - - KASSERT(!map->dm_onq, ("hviommu_dvma_vfindseg: map on queue!")); - SLIST_FOREACH(r, &map->dm_reslist, dr_link) { - dvmaddr = round_io_page(BDR_START(r) + r->dr_used); - /* Alignment can only work with voffs == 0. */ - dvmaddr = (dvmaddr + amask) & ~amask; - dvmaddr += voffs; - dvmend = dvmaddr + size; - if (dvmend <= BDR_END(r)) { - r->dr_used = dvmend - BDR_START(r); - r->dr_offset = voffs; - return (dvmaddr); - } - } - return (0); -} - -/* - * Try to find or allocate a slab of DVMA space; see above. - */ -static int -hviommu_dvma_vallocseg(bus_dma_tag_t dt, struct hviommu *him, bus_dmamap_t map, - vm_offset_t voffs, bus_size_t size, bus_addr_t amask, bus_addr_t *addr) -{ - bus_dmamap_t tm, last; - bus_addr_t dvmaddr, freed; - int error, complete = 0; - - dvmaddr = hviommu_dvma_vfindseg(map, voffs, size, amask); - - /* Need to allocate. */ - if (dvmaddr == 0) { - while ((error = hviommu_dvma_valloc(dt, him, map, - voffs + size)) == ENOMEM && !complete) { - /* - * Free the allocated DVMA of a few maps until - * the required size is reached. This is an - * approximation to not have to call the allocation - * function too often; most likely one free run - * will not suffice if not one map was large enough - * itself due to fragmentation. - */ - HIM_LOCK(him); - freed = 0; - last = TAILQ_LAST(&him->him_maplruq, hviommu_maplruq_head); - do { - tm = TAILQ_FIRST(&him->him_maplruq); - complete = tm == last; - if (tm == NULL) - break; - freed += hviommu_dvma_vprune(him, tm); - /* Move to the end. */ - hviommu_map_insq(him, tm); - } while (freed < size && !complete); - HIM_UNLOCK(him); - } - if (error != 0) - return (error); - dvmaddr = hviommu_dvma_vfindseg(map, voffs, size, amask); - KASSERT(dvmaddr != 0, - ("hviommu_dvma_vallocseg: allocation failed unexpectedly!")); - } - *addr = dvmaddr; - return (0); -} - -static int -hviommu_dvmamem_alloc(bus_dma_tag_t dt, void **vaddr, int flags, - bus_dmamap_t *mapp) -{ - struct hviommu *him = dt->dt_cookie; - int error, mflags; - - /* - * XXX: This will break for 32 bit transfers on machines with more than - * 16G (1 << 34 bytes) of memory. - */ - if ((error = sparc64_dma_alloc_map(dt, mapp)) != 0) - return (error); - - if ((flags & BUS_DMA_NOWAIT) != 0) - mflags = M_NOWAIT; - else - mflags = M_WAITOK; - if ((flags & BUS_DMA_ZERO) != 0) - mflags |= M_ZERO; - - if ((*vaddr = malloc(dt->dt_maxsize, M_HVIOMMU, mflags)) == NULL) { - error = ENOMEM; - sparc64_dma_free_map(dt, *mapp); - return (error); - } - if ((flags & BUS_DMA_COHERENT) != 0) - (*mapp)->dm_flags |= DMF_COHERENT; - /* - * Try to preallocate DVMA space. If this fails, it is retried at load - * time. - */ - hviommu_dvma_valloc(dt, him, *mapp, IOMMU_SIZE_ROUNDUP(dt->dt_maxsize)); - HIM_LOCK(him); - hviommu_map_insq(him, *mapp); - HIM_UNLOCK(him); - return (0); -} - -static void -hviommu_dvmamem_free(bus_dma_tag_t dt, void *vaddr, bus_dmamap_t map) -{ - struct hviommu *him = dt->dt_cookie; - - hviommu_dvma_vfree(him, map); - sparc64_dma_free_map(dt, map); - free(vaddr, M_HVIOMMU); -} - -static int -hviommu_dvmamap_create(bus_dma_tag_t dt, int flags, bus_dmamap_t *mapp) -{ - struct hviommu *him = dt->dt_cookie; - bus_size_t totsz, presz, currsz; - int error, i, maxpre; - - if ((error = sparc64_dma_alloc_map(dt, mapp)) != 0) - return (error); - if ((flags & BUS_DMA_COHERENT) != 0) - (*mapp)->dm_flags |= DMF_COHERENT; - /* - * Preallocate DVMA space; if this fails now, it is retried at load - * time. Through bus_dmamap_load_mbuf() and bus_dmamap_load_uio(), it - * is possible to have multiple discontiguous segments in a single map, - * which is handled by allocating additional resources, instead of - * increasing the size, to avoid fragmentation. - * Clamp preallocation to IOMMU_MAX_PRE. In some situations we can - * handle more; that case is handled by reallocating at map load time. - */ - totsz = ulmin(IOMMU_SIZE_ROUNDUP(dt->dt_maxsize), IOMMU_MAX_PRE); - error = hviommu_dvma_valloc(dt, him, *mapp, totsz); - if (error != 0) - return (0); - /* - * Try to be smart about preallocating some additional segments if - * needed. - */ - maxpre = imin(dt->dt_nsegments, IOMMU_MAX_PRE_SEG); - presz = dt->dt_maxsize / maxpre; - for (i = 1; i < maxpre && totsz < IOMMU_MAX_PRE; i++) { - currsz = round_io_page(ulmin(presz, IOMMU_MAX_PRE - totsz)); - error = hviommu_dvma_valloc(dt, him, *mapp, currsz); - if (error != 0) - break; - totsz += currsz; - } - HIM_LOCK(him); - hviommu_map_insq(him, *mapp); - HIM_UNLOCK(him); - return (0); -} - -static int -hviommu_dvmamap_destroy(bus_dma_tag_t dt, bus_dmamap_t map) -{ - struct hviommu *him = dt->dt_cookie; - - hviommu_dvma_vfree(him, map); - sparc64_dma_free_map(dt, map); - return (0); -} - -#define IOTTE_CNT 64 - -static void -hviommu_map_pages(struct hviommu *him, bus_addr_t dvmaddr, uint64_t *iottes, pages_t iottecnt) -{ - uint64_t err; -#ifdef IOMMU_DEBUG - bus_addr_t ra; - io_attributes_t ioattr; -#endif - pages_t mapcnt; - int cntdone; - int i; - - DPRINTF("mapping: dh: %#lx, dvmaddr: %#lx, tsbid: %#lx, cnt: %d\n", - him->him_handle, dvmaddr, VA_TO_TSBID(him, dvmaddr), iottecnt); - for (i = 0; i < iottecnt; i++) { - DPRINTF("iotte:%#lx\n", iottes[i]); - } - - /* push tte's */ - cntdone = 0; - while (cntdone < iottecnt) { - if ((err = hv_pci_iommu_map(him->him_handle, VA_TO_TSBID(him, - dvmaddr), iottecnt, PCI_MAP_ATTR_READ | PCI_MAP_ATTR_WRITE, - (io_page_list_t)pmap_kextract((vm_offset_t)&iottes[0]), - &mapcnt))) { - DPRINTF("iommu_map: err: %ld\n", err); - mapcnt = 1; - } - cntdone += mapcnt; - } - for (i = 0; i < iottecnt; i++) { - DPRINTF("err: %ld", hv_pci_iommu_getmap(him->him_handle, - VA_TO_TSBID(him, dvmaddr + i * IO_PAGE_SIZE), - &ioattr, &ra)); - DPRINTF(", ioattr: %d, raddr: %#lx\n", ioattr, ra); - } -} - -/* - * IOMMU DVMA operations, common to SBUS and PCI. - */ -static int -hviommu_dvmamap_load_buffer(bus_dma_tag_t dt, struct hviommu *him, - bus_dmamap_t map, void *buf, bus_size_t buflen, struct thread *td, - int flags, bus_dma_segment_t *segs, int *segp, int align) -{ - uint64_t iottes[IOTTE_CNT]; - bus_addr_t amask, dvmaddr, iottebase; - bus_size_t sgsize, esize; - vm_offset_t vaddr, voffs; - vm_paddr_t curaddr; - int error, sgcnt, firstpg; - pmap_t pmap = NULL; - pages_t iottecnt; - - KASSERT(buflen != 0, ("hviommu_dvmamap_load_buffer: buflen == 0!")); - if (buflen > dt->dt_maxsize) - return (EINVAL); - - if (td != NULL) - pmap = vmspace_pmap(td->td_proc->p_vmspace); - - vaddr = (vm_offset_t)buf; - voffs = vaddr & IO_PAGE_MASK; - amask = align ? dt->dt_alignment - 1 : 0; - - /* Try to find a slab that is large enough. */ - error = hviommu_dvma_vallocseg(dt, him, map, voffs, buflen, amask, - &dvmaddr); - if (error != 0) - return (error); - - DPRINTF("vallocseg: dvmaddr: %#lx, voffs: %#lx, buflen: %#lx\n", - dvmaddr, voffs, buflen); - sgcnt = *segp; - firstpg = 1; - iottecnt = 0; - iottebase = 0; /* shutup gcc */ - for (; buflen > 0; ) { - /* - * Get the physical address for this page. - */ - if (pmap != NULL) - curaddr = pmap_extract(pmap, vaddr); - else - curaddr = pmap_kextract(vaddr); - - /* - * Compute the segment size, and adjust counts. - */ - sgsize = IO_PAGE_SIZE - ((u_long)vaddr & IO_PAGE_MASK); - if (buflen < sgsize) - sgsize = buflen; - - buflen -= sgsize; - vaddr += sgsize; - -#if 0 - hviommu_enter(him, trunc_io_page(dvmaddr), trunc_io_page(curaddr), - flags); -#else - if (iottecnt == 0) - iottebase = trunc_io_page(dvmaddr); - DPRINTF("adding: %#lx\n", trunc_io_page(curaddr)); - iottes[iottecnt++] = trunc_io_page(curaddr); - - if (iottecnt >= IOTTE_CNT) { - hviommu_map_pages(him, iottebase, iottes, iottecnt); - iottecnt = 0; - } -#endif - - /* - * Chop the chunk up into segments of at most maxsegsz, but try - * to fill each segment as well as possible. - */ - if (!firstpg) { - esize = ulmin(sgsize, - dt->dt_maxsegsz - segs[sgcnt].ds_len); - segs[sgcnt].ds_len += esize; - sgsize -= esize; - dvmaddr += esize; - } - while (sgsize > 0) { - sgcnt++; - if (sgcnt >= dt->dt_nsegments) - return (EFBIG); - /* - * No extra alignment here - the common practice in the - * busdma code seems to be that only the first segment - * needs to satisfy the alignment constraints (and that - * only for bus_dmamem_alloc()ed maps). It is assumed - * that such tags have maxsegsize >= maxsize. - */ - esize = ulmin(sgsize, dt->dt_maxsegsz); - segs[sgcnt].ds_addr = dvmaddr; - segs[sgcnt].ds_len = esize; - sgsize -= esize; - dvmaddr += esize; - } - - firstpg = 0; - } - hviommu_map_pages(him, iottebase, iottes, iottecnt); - *segp = sgcnt; - return (0); -} - -static int -hviommu_dvmamap_load(bus_dma_tag_t dt, bus_dmamap_t map, void *buf, - bus_size_t buflen, bus_dmamap_callback_t *cb, void *cba, - int flags) -{ - struct hviommu *him = dt->dt_cookie; - int error, seg = -1; - - if ((map->dm_flags & DMF_LOADED) != 0) { -#ifdef DIAGNOSTIC - printf("hviommu_dvmamap_load: map still in use\n"); -#endif - bus_dmamap_unload(dt, map); - } - - /* - * Make sure that the map is not on a queue so that the resource list - * may be safely accessed and modified without needing the lock to - * cover the whole operation. - */ - HIM_LOCK(him); - hviommu_map_remq(him, map); - HIM_UNLOCK(him); - - error = hviommu_dvmamap_load_buffer(dt, him, map, buf, buflen, NULL, - flags, dt->dt_segments, &seg, 1); - - HIM_LOCK(him); - hviommu_map_insq(him, map); - if (error != 0) { - hviommu_dvmamap_vunload(him, map); - HIM_UNLOCK(him); - (*cb)(cba, dt->dt_segments, 0, error); - } else { - HIM_UNLOCK(him); - map->dm_flags |= DMF_LOADED; - (*cb)(cba, dt->dt_segments, seg + 1, 0); - } - - return (error); -} - -static int -hviommu_dvmamap_load_mbuf(bus_dma_tag_t dt, bus_dmamap_t map, struct mbuf *m0, - bus_dmamap_callback2_t *cb, void *cba, int flags) -{ - struct hviommu *him = dt->dt_cookie; - struct mbuf *m; - int error = 0, first = 1, nsegs = -1; - - M_ASSERTPKTHDR(m0); - - if ((map->dm_flags & DMF_LOADED) != 0) { -#ifdef DIAGNOSTIC - printf("hviommu_dvmamap_load_mbuf: map still in use\n"); -#endif - bus_dmamap_unload(dt, map); - } - - HIM_LOCK(him); - hviommu_map_remq(him, map); - HIM_UNLOCK(him); - - if (m0->m_pkthdr.len <= dt->dt_maxsize) { - for (m = m0; m != NULL && error == 0; m = m->m_next) { - if (m->m_len == 0) - continue; - error = hviommu_dvmamap_load_buffer(dt, him, map, - m->m_data, m->m_len, NULL, flags, dt->dt_segments, - &nsegs, first); - first = 0; - } - } else - error = EINVAL; - - HIM_LOCK(him); - hviommu_map_insq(him, map); - if (error != 0) { - hviommu_dvmamap_vunload(him, map); - HIM_UNLOCK(him); - /* force "no valid mappings" in callback */ - (*cb)(cba, dt->dt_segments, 0, 0, error); - } else { - HIM_UNLOCK(him); - map->dm_flags |= DMF_LOADED; - (*cb)(cba, dt->dt_segments, nsegs + 1, m0->m_pkthdr.len, 0); - } - return (error); -} - -static int -hviommu_dvmamap_load_mbuf_sg(bus_dma_tag_t dt, bus_dmamap_t map, - struct mbuf *m0, bus_dma_segment_t *segs, int *nsegs, int flags) -{ - struct hviommu *him = dt->dt_cookie; - struct mbuf *m; - int error = 0, first = 1; - - M_ASSERTPKTHDR(m0); - - *nsegs = -1; - if ((map->dm_flags & DMF_LOADED) != 0) { -#ifdef DIAGNOSTIC - printf("hviommu_dvmamap_load_mbuf: map still in use\n"); -#endif - bus_dmamap_unload(dt, map); - } - - HIM_LOCK(him); - hviommu_map_remq(him, map); - HIM_UNLOCK(him); - - if (m0->m_pkthdr.len <= dt->dt_maxsize) { - for (m = m0; m != NULL && error == 0; m = m->m_next) { - if (m->m_len == 0) - continue; - error = hviommu_dvmamap_load_buffer(dt, him, map, - m->m_data, m->m_len, NULL, flags, segs, - nsegs, first); - first = 0; - } - } else - error = EINVAL; - - HIM_LOCK(him); - hviommu_map_insq(him, map); - if (error != 0) { - hviommu_dvmamap_vunload(him, map); - } else { - map->dm_flags |= DMF_LOADED; - ++*nsegs; - } - HIM_UNLOCK(him); - return (error); -} - -static int -hviommu_dvmamap_load_uio(bus_dma_tag_t dt, bus_dmamap_t map, struct uio *uio, - bus_dmamap_callback2_t *cb, void *cba, int flags) -{ - struct hviommu *him = dt->dt_cookie; - struct iovec *iov; - struct thread *td = NULL; - bus_size_t minlen, resid; - int nsegs = -1, error = 0, first = 1, i; - - if ((map->dm_flags & DMF_LOADED) != 0) { -#ifdef DIAGNOSTIC - printf("hviommu_dvmamap_load_uio: map still in use\n"); -#endif - bus_dmamap_unload(dt, map); - } - - HIM_LOCK(him); - hviommu_map_remq(him, map); - HIM_UNLOCK(him); - - resid = uio->uio_resid; - iov = uio->uio_iov; - - if (uio->uio_segflg == UIO_USERSPACE) { - td = uio->uio_td; - KASSERT(td != NULL, - ("%s: USERSPACE but no proc", __func__)); - } - - for (i = 0; i < uio->uio_iovcnt && resid != 0 && error == 0; i++) { - /* - * Now at the first iovec to load. Load each iovec - * until we have exhausted the residual count. - */ - minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len; - if (minlen == 0) - continue; - - error = hviommu_dvmamap_load_buffer(dt, him, map, - iov[i].iov_base, minlen, td, flags, dt->dt_segments, - &nsegs, first); - first = 0; - - resid -= minlen; - } - - HIM_LOCK(him); - hviommu_map_insq(him, map); - if (error) { - hviommu_dvmamap_vunload(him, map); - HIM_UNLOCK(him); - /* force "no valid mappings" in callback */ - (*cb)(cba, dt->dt_segments, 0, 0, error); - } else { - HIM_UNLOCK(him); - map->dm_flags |= DMF_LOADED; - (*cb)(cba, dt->dt_segments, nsegs + 1, uio->uio_resid, 0); - } - return (error); -} - -static void -hviommu_dvmamap_unload(bus_dma_tag_t dt, bus_dmamap_t map) -{ - struct hviommu *him = dt->dt_cookie; - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - HIM_LOCK(him); - hviommu_dvmamap_vunload(him, map); - hviommu_map_insq(him, map); - HIM_UNLOCK(him); - map->dm_flags &= ~DMF_LOADED; -} - -static void -hviommu_dvmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op) -{ - struct hviommu *him = dt->dt_cookie; - struct bus_dmamap_res *r; - vm_offset_t va; - vm_size_t len; - size_t synced; - bus_addr_t ra; - uint64_t err; - io_attributes_t ioattr; - vm_paddr_t raddr; - io_sync_direction_t iodir; - - if ((map->dm_flags & DMF_LOADED) == 0) - return; - - iodir = 0; - - if (op & (BUS_DMASYNC_POSTREAD)) - iodir |= IO_SYNC_CPU; - if (op & (BUS_DMASYNC_PREWRITE)) - iodir |= IO_SYNC_DEVICE; - - if ((op & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_POSTWRITE)) != 0) - membar(Sync); - - /* nothing to be done */ - if (!iodir) - return; - - HIM_LOCK(him); - SLIST_FOREACH(r, &map->dm_reslist, dr_link) { - va = (vm_offset_t)BDR_START(r) + r->dr_offset ; - len = r->dr_used; - while (len > 0) { - if ((err = hv_pci_iommu_getmap(him->him_handle, - VA_TO_TSBID(him, va), &ioattr, &ra))) { - if (err != H_ENOMAP) - printf("failed to _g=etmap: err: %ld, handle: %#lx, tsbid: %#lx\n", - err, him->him_handle, VA_TO_TSBID(him, va)); - continue; - } - if ((err = hv_pci_dma_sync(him->him_handle, ra, - ulmin(len, (trunc_io_page(ra) + IO_PAGE_SIZE) - ra), - iodir, &synced))) { - printf("failed to dma_sync: err: %ld, handle: %#lx, ra: %#lx, len: %#lx, dir: %d\n", - err, him->him_handle, ra, ulmin(len, - (trunc_io_page(ra) + IO_PAGE_SIZE) - ra), - iodir); - synced = ulmin(len, (trunc_io_page(ra) + IO_PAGE_SIZE) - ra); - printf("err: %ld", hv_pci_iommu_getmap(him->him_handle, VA_TO_TSBID(him, va), - &ioattr, &raddr)); - printf(", ioattr: %d, raddr: %#lx\n", ioattr, raddr); - } - va += synced; - len -= synced; - } - } - HIM_UNLOCK(him); - - if ((op & BUS_DMASYNC_PREWRITE) != 0) - membar(Sync); -} - -struct bus_dma_methods hviommu_dma_methods = { - .dm_dmamap_create = hviommu_dvmamap_create, - .dm_dmamap_destroy = hviommu_dvmamap_destroy, - .dm_dmamap_load = hviommu_dvmamap_load, - .dm_dmamap_load_mbuf = hviommu_dvmamap_load_mbuf, - .dm_dmamap_load_mbuf_sg = hviommu_dvmamap_load_mbuf_sg, - .dm_dmamap_load_uio = hviommu_dvmamap_load_uio, - .dm_dmamap_unload = hviommu_dvmamap_unload, - .dm_dmamap_sync = hviommu_dvmamap_sync, - .dm_dmamem_alloc = hviommu_dvmamem_alloc, - .dm_dmamem_free = hviommu_dvmamem_free, -}; diff --git a/sys/sun4v/sun4v/interrupt.S b/sys/sun4v/sun4v/interrupt.S deleted file mode 100644 index 61f3bbe8688a..000000000000 --- a/sys/sun4v/sun4v/interrupt.S +++ /dev/null @@ -1,585 +0,0 @@ -/*- - * Copyright (c) 2002 Jake Burkholder. - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include "opt_simulator.h" -#include "opt_trap_trace.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "assym.s" - -#define PUTCHAR(x) \ -0: mov x, %o0 ; \ - mov CONS_PUTCHAR, %o5 ; \ - ta FAST_TRAP ; \ - brnz %o0, 0b ; \ - nop - -ENTRY(intr_fast) - save %sp, -CCFSZ, %sp -1: ldx [PCPU(IRHEAD)], %l0 - brnz,a,pt %l0, 2f - nop - - ret - restore - -2: wrpr %g0, PSTATE_NORMAL, %pstate - - ldx [%l0 + IR_NEXT], %l1 - brnz,pt %l1, 3f - stx %l1, [PCPU(IRHEAD)] - PCPU_ADDR(IRHEAD, %l1) - stx %l1, [PCPU(IRTAIL)] - -3: ldx [%l0 + IR_FUNC], %o0 - ldx [%l0 + IR_ARG], %o1 - lduw [%l0 + IR_VEC], %o2 - - /* intrcnt[intr_countp[%o2]]++ */ - SET(intrcnt, %l7, %l2) /* %l2 = intrcnt */ - prefetcha [%l2] ASI_N, 1 - SET(intr_countp, %l7, %l3) /* %l3 = intr_countp */ - sllx %o2, 1, %l4 /* %l4 = vec << 1 */ - lduh [%l4 + %l3], %l5 /* %l5 = intr_countp[%o2] */ - sllx %l5, 3, %l6 /* %l6 = intr_countp[%o2] << 3 */ - add %l6, %l2, %l7 /* %l7 = intrcnt[intr_countp[%o2]] */ - ldx [%l7], %l2 - inc %l2 - stx %l2, [%l7] - - ldx [PCPU(IRFREE)], %l1 - stx %l1, [%l0 + IR_NEXT] - stx %l0, [PCPU(IRFREE)] - - wrpr %g0, PSTATE_KERNEL, %pstate - - call %o0 - mov %o1, %o0 - - ba,a %xcc, 1b - nop -END(intr_fast) - -/* - * Running tally of invalid CPU mondo interrupts - */ -#if defined(lint) -uint64_t cpu_mondo_invalid; -#else /* lint */ - .data - .globl cpu_mondo_invalid - .align 8 -cpu_mondo_invalid: - .skip 8 - - .text -#endif /* lint */ - -#if defined(lint) -void -cpu_mondo(void) -{} -#else /* lint */ - -/* - * (TT 0x7c, TL>0) CPU Mondo Queue Handler - * Globals are the Interrupt Globals. - * - * Interrupts in sun4v are delivered to privileged code in the form - * of interrupt reports. Each interrupt report is 64-bytes long, - * consisting of 8 64-bit words. Each interrupt report is appended - * onto the appropriate interrupt queue of which there are currently two, - * one for CPU mondos (formerly referred to as cross trap function - * requests) and one for device mondos. Each queue has its own - * trap vector. - * - * New reports are appended onto the tail of the queue, and privileged - * code reads the report from the queue's head. The head pointer is stored - * in a register and is equal to the current offset from the base address - * of its associated queue. - * - * The structure of the cpu mondo report follows sun4u conventions: - * - * word 0: address of cross-trap handler - * word 1: first argument to handler - * word 2: second argument to handler - * word 3-7: unused - * - * Privileged code is responsible for incrementing the head pointer - * to remove each entry. The pointers are updated using modulo - * arithmetic such that the queue is empty when head == tail and is full - * when the addition of an entry would make head == tail. - * - * This trap handler is called when the cpu mondo queue becomes non-empty - * and will continue to be called while interrupts enabled until the - * queue becomes empty. - * - */ -ENTRY(cpu_mondo) -#ifdef TRAP_TRACING - GET_PCPU_PHYS_SCRATCH(%g1) - rdpr %tl, %g1 - dec %g1 - sll %g1, RW_SHIFT, %g1 - add %g1, PC_TSBWBUF, %g1 - add PCPU_REG, %g1, %g1 - wr %g0, ASI_REAL, %asi - TTRACE_ADD_SAFE(%g1, 0, 0, 0, 0, 0) -#endif - ! - ! Register Usage:- - ! %g5 PC for fasttrap TL>0 handler - ! %g1 arg 1 - ! %g2 arg 2 - ! %g3 queue base RA, ackmask - ! %g4 queue size mask - ! %g6 head ptr - mov CPU_MONDO_QUEUE_HEAD, %g1 - ldxa [%g1]ASI_QUEUE, %g6 ! %g6 = head ptr - mov CPU_MONDO_QUEUE_TAIL, %g2 - ldxa [%g2]ASI_QUEUE, %g4 ! %g4 = tail ptr - cmp %g6, %g4 - be,pn %xcc, 0f ! head == tail - nop - - /* - * Get the address of the current CPU and index into - * the pcpu structure for the Q values. - */ - GET_PCPU_SCRATCH - ldx [PCPU(CPU_Q_RA)], %g3 ! %g3 = queue base PA - ldx [PCPU(CPU_Q_SIZE)], %g4 ! %g4 = queue size - sub %g4, 1, %g4 ! %g4 = queue size mask - - ! Load interrupt receive data registers 1 and 2 to fetch - ! the arguments for the fast trap handler. - ! - ! Since the data words in the interrupt report are not defined yet - ! we assume that the consective words contain valid data and preserve - ! sun4u's xcall mondo arguments. - ! Register usage: - ! %g5 PC for fasttrap TL>0 handler - ! %g1 arg 1 - ! %g2 arg 2 - - ldxa [%g3 + %g6]ASI_REAL, %g5 ! get PC from q base + head - add %g6, 0x8, %g6 ! inc head 8 bytes - ldxa [%g3 + %g6]ASI_REAL, %g1 ! read data word 1 - add %g6, 0x8, %g6 ! inc head 8 bytes - ldxa [%g3 + %g6]ASI_REAL, %g2 ! read data word 2 - add %g6, 0x8, %g6 ! inc head 8 bytes - ldxa [%g3 + %g6]ASI_REAL, %g7 ! read data word 3 - add %g6, (INTR_REPORT_SIZE - 24) , %g6 ! inc head to next record - - and %g6, %g4, %g6 ! and size mask for wrap around - mov CPU_MONDO_QUEUE_HEAD, %g3 - stxa %g6, [%g3]ASI_QUEUE ! store head pointer - membar #Sync - - mov %g7, %g3 ! ackmask - /* - * For now catch invalid PC being passed via cpu_mondo queue - */ - set KERNBASE, %g4 - cmp %g5, %g4 - bl,a,pn %xcc, 1f ! branch if bad %pc - nop - - jmp %g5 ! jump to traphandler - nop -1: - ! invalid trap handler, discard it for now - set cpu_mondo_invalid, %g4 - ldx [%g4], %g5 - inc %g5 - stx %g5, [%g4] -0: - retry - /* NOTREACHED */ -END(cpu_mondo) - -#endif /* lint */ - - -#if defined(lint) -void -dev_mondo(void) -{} -#else /* lint */ - -/* - * (TT 0x7d, TL>0) Dev Mondo Queue Handler - * Globals are the Interrupt Globals. - * - * Device interrupt reports take the following form: - * Bits: 63 11 10 6 5 0 - * word 0: | zero | | bus port | | device ID | - * word 1-7: unused - * - */ -ENTRY(dev_mondo) -#ifdef TRAP_TRACING - GET_PCPU_PHYS_SCRATCH(%g1) - rdpr %tl, %g1 - dec %g1 - sll %g1, RW_SHIFT, %g1 - add %g1, PC_TSBWBUF, %g1 - add PCPU_REG, %g1, %g1 - wr %g0, ASI_REAL, %asi - TTRACE_ADD_SAFE(%g1, 0, 0, 0, 0, 0) -#endif - /* - * Register Usage:- - * %g5 inum - * %g1 ptr to intrerrupt vector entry for inum - * %g3 queue base PA - * %g4 queue size mask - * %g6 head ptr - */ -! mov %o0, %g1 -! mov %o5, %g6 -! PUTCHAR(0x2b) -! PUTCHAR(0x2b) -! mov %g1, %o0 -! mov %g6, %o5 - - mov DEV_MONDO_QUEUE_HEAD, %g1 - ldxa [%g1]ASI_QUEUE, %g6 ! %g6 = head ptr - mov DEV_MONDO_QUEUE_TAIL, %g2 - ldxa [%g2]ASI_QUEUE, %g4 ! %g4 = tail ptr - cmp %g6, %g4 - be,pn %xcc, 0f ! head == tail - nop - - /* - * Get CPU address and index to Q base - */ - GET_PCPU_SCRATCH - ldx [PCPU(DEV_Q_RA)], %g3 ! %g3 = queue base PA - - /* - * Register usage: - * %g5 - inum - */ - ldxa [%g3 + %g6]ASI_REAL, %g5 ! %g5 = inum from q base + head - - /* - * We verify that inum is valid ( < IV_MAX). If it is greater - * than IV_MAX, we let the software interrupt handler take care - * of it. - */ - set IV_MAX, %g4 - cmp %g5, %g4 - bgeu,a,pn %xcc, 1f - ldx [PCPU(DEV_Q_SIZE)], %g4 ! queue size (delay slot) - - /* - * Find the function, argument and desired priority from the - * intr_vectors table - */ - set intr_vectors, %g1 - sll %g5, IV_SHIFT, %g2 - add %g1, %g2, %g1 ! %g1 = &intr_vectors[inum] - - /* - * Get an intr_request from the free list. There should always be one - * unless we are getting an interrupt storm from stray interrupts, in - * which case the we will dereference a NULL pointer and panic. - */ - ldx [PCPU(IRFREE)], %g2 ! %g2 = ptr to tail element - - /* - * Sun4v-fixme: It might be better to have the software interrupt - * handler deal with this scenario rather than just panic. - */ - !brz,a,pt %g2, 1f - !ldx [PCPU(DEV_Q_SIZE)], %g4 ! queue size (delay slot) - - ldx [%g2 + IR_NEXT], %g3 ! %g3 = next element in list - stx %g3, [PCPU(IRFREE)] ! %g3 is now the tail - - /* - * Store the vector number, function, argument, and priority. - */ - stw %g5, [%g2 + IR_VEC] - ldx [%g1 + IV_FUNC], %g3 ! %g3 = function ptr - stx %g3, [%g2 + IR_FUNC] - ldx [%g1 + IV_ARG], %g3 ! %g3 = argument ptr - stx %g3, [%g2 + IR_ARG] - lduw [%g1 + IV_PRI], %g1 ! %g1 = priority - stw %g1, [%g2 + IR_PRI] - - /* - * Link it onto the end of the active list - */ - stx %g0, [%g2 + IR_NEXT] - ldx [PCPU(IRTAIL)], %g3 ! %g3 = ptr to tail - stx %g2, [%g3] - add %g2, IR_NEXT, %g2 - stx %g2, [PCPU(IRTAIL)] - - /* - * Unlike Solaris, FreeBSD throws away the rest of the - * 64-byte packet. We may want to revisit this philosophy - * at some point since information in the packet is defined by - * the device and MAY be meaningful. - * - * For now, we retain FreeBSD's sun4u semantics. - */ - ldx [PCPU(DEV_Q_SIZE)], %g4 ! queue size - -1: sub %g4, 1, %g4 ! %g4 = queue size mask - add %g6, INTR_REPORT_SIZE, %g6 ! inc head to next record - and %g6, %g4, %g6 ! and mask for wrap around - mov DEV_MONDO_QUEUE_HEAD, %g3 - stxa %g6, [%g3]ASI_QUEUE ! increment head offset - membar #Sync - - /* - * Trigger a softint at the level indicated by the priority - */ - mov 1, %g6 - sllx %g6, %g1, %g6 - wr %g6, 0, %set_softint -#if 0 - mov %o0, %g1 - mov %o5, %g6 - PUTCHAR(0x2b) - PUTCHAR(0x2b) - mov %g1, %o0 - mov %g6, %o5 -#endif - /* - * Done, retry the instruction - */ -0: retry - - - /* NOTREACHED */ -END(dev_mondo) -#endif /* lint */ - -ENTRY(tl_invlctx) - mov %o0, %g2 - mov %o1, %g4 - mov %o2, %g5 - mov %o3, %g6 - mov %o5, %g7 - mov %g0, %o0 - mov %g0, %o1 - mov %g1, %o2 - mov MAP_ITLB|MAP_DTLB, %o3 - mov MMU_DEMAP_CTX, %o5 - ta FAST_TRAP - brnz,a,pn %o0, interrupt_panic_bad_hcall - mov MMU_DEMAP_CTX, %o1 - mov %g2, %o0 - mov %g4, %o1 - mov %g5, %o2 - mov %g6, %o3 - mov %g7, %o5 - ba,pt %xcc, set_ackmask - membar #Sync -END(tl_invlctx) - -ENTRY(tl_invltlb) - mov %o0, %g1 - mov %o1, %g2 - mov %o2, %g4 - mov %o5, %g5 - clr %o0 - clr %o1 - mov MAP_ITLB | MAP_DTLB, %o2 - mov MMU_DEMAP_ALL, %o5 - ta FAST_TRAP - brnz,a,pn %o0, interrupt_panic_bad_hcall - mov MMU_DEMAP_ALL, %o1 - mov %g1, %o0 - mov %g2, %o1 - mov %g4, %o2 - mov %g5, %o5 - ba,pt %xcc, set_ackmask - membar #Sync -END(tl_invltlb) - -ENTRY(tl_invlpg) - mov %o0, %g5 - mov %o1, %g6 - mov %o2, %g7 - mov MAP_ITLB|MAP_DTLB, %o2 - mov %g1, %o0 - mov %g2, %o1 - ta MMU_UNMAP_ADDR - brnz,a,pn %o0, interrupt_panic_bad_hcall - mov MMU_UNMAP_ADDR, %o1 - mov %g5, %o0 - mov %g6, %o1 - mov %g7, %o2 - ba,pt %xcc, set_ackmask - membar #Sync -END(tl_invlpg) - -ENTRY(tl_invlrng) - sethi %hi(PAGE_SIZE), %g5 - dec %g5 - and %g1, %g5, %g4 - andn %g1, %g5, %g1 - dec %g4 - -1: mov %o0, %g5 - mov %o1, %g6 - mov %o2, %g7 - mov MAP_ITLB|MAP_DTLB, %o2 - mov %g1, %o0 - mov %g2, %o1 - ta MMU_UNMAP_ADDR - brnz,a,pn %o0, interrupt_panic_bad_hcall - mov MMU_UNMAP_ADDR, %o1 - - brnz,pt %g4, 1b - dec %g4 - - mov %g5, %o0 - mov %g6, %o1 - mov %g7, %o2 - ba,pt %xcc, set_ackmask - membar #Sync -END(tl_invlrng) - - - -ENTRY(tl_tsbupdate) -/* compare current context with one to be updated */ - mov MMU_CID_S, %g4 - GET_MMU_CONTEXT(%g4, %g4) - - cmp %g1, %g4 - bne,a,pt %xcc, set_ackmask - membar #Sync -/* update scratch pointer to tsbscratch */ - wr %g0, ASI_REAL, %asi - ldxa [%g2]%asi, %g4 ! tsbscratch - ldxa [%g2 + 8]%asi, %g2 ! tsb_ra - mov SCRATCH_REG_TSB_USER, %g5 - SET_SCRATCH(%g5, %g4) - -/* reset tsb context with hypervisor */ - mov %o0, %g1 - mov %o1, %g2 - mov %o5, %g4 - mov 1, %o0 - mov %g2, %o1 - mov MMU_TSB_CTXNON0, %o5 - ta FAST_TRAP - - /* XXX test %o0 */ - mov %g1, %o0 - mov %g2, %o1 - mov %g4, %o5 - ba,pt %xcc, set_ackmask - membar #Sync -END(tl_tsbupdate) - -ENTRY(tl_ttehashupdate) -/* compare current context with one to be updated */ - mov MMU_CID_S, %g4 - GET_MMU_CONTEXT(%g4, %g4) - cmp %g1, %g4 - bne,a,pt %xcc, set_ackmask - membar #Sync -/* update scratch pointer to hashscratch */ - mov SCRATCH_REG_HASH_USER, %g4 - SET_SCRATCH(%g4, %g2) -END(tl_ttehashupdate) - -ENTRY(set_ackmask) - GET_PCPU_PHYS_SCRATCH(%g6) - wr %g0, ASI_REAL, %asi - -#ifdef TRAP_TRACING - /* pcpu->pad[0] = %pc */ - rd %pc, %g4 - stxa %g4, [PCPU(PAD)]%asi - - /* pcpu->pad[1] = %tick */ - rdpr %tick, %g4 - stxa %g4, [PCPU(PAD) + 8]%asi - - /* - * Increment a counter which might help us notice if we're - * stuck in a loop. pcpu->pad[2] = count - */ - ldxa [PCPU(PAD) + 16]%asi, %g4 - add %g4, 1, %g4 - stxa %g4, [PCPU(PAD) + 16]%asi -#endif - - lda [PCPU(CPUMASK)]%asi, %g4 - lda [%g3]%asi, %g1 -1: or %g1, %g4, %g2 - casa [%g3]%asi, %g1, %g2 - cmp %g1, %g2 - bne,a,pn %xcc, 1b - lda [%g3]%asi, %g1 - retry -END(set_ackmask) - - /* - * interrupt_panic_bad_hcall is called when a hcall returns - * unexpected error - * %o0 error number - * %o1 hcall number - */ - - .text -interrupt_bad_hcall_error: - .asciz "hypervisor call 0x%x returned an unexpected error %d" - - -ENTRY(interrupt_panic_bad_hcall) - PUTCHAR(0x5b) - PUTCHAR(0x5b) - PUTCHAR(0x5b) - PUTCHAR(0x5b) - PUTCHAR(0x5b) - mov %o0, %o2 - sethi %hi(interrupt_bad_hcall_error), %o0 - or %o0, %lo(interrupt_bad_hcall_error), %o0 - mov %o7, %o3 - call panic - mov %o3, %o7 -END(interrupt_panic_bad_hcall) diff --git a/sys/sun4v/sun4v/intr_machdep.c b/sys/sun4v/sun4v/intr_machdep.c deleted file mode 100644 index 358740237f59..000000000000 --- a/sys/sun4v/sun4v/intr_machdep.c +++ /dev/null @@ -1,443 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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. - * - * from: @(#)isa.c 7.2 (Berkeley) 5/13/91 - * form: src/sys/i386/isa/intr_machdep.c,v 1.57 2001/07/20 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define PANIC_IF(exp) if (unlikely(exp)) {panic("%s: %s:%d", #exp, __FILE__, __LINE__);} - -#define MAX_STRAY_LOG 5 - -CTASSERT((1 << IV_SHIFT) == sizeof(struct intr_vector)); - -ih_func_t *intr_handlers[PIL_MAX]; -uint16_t pil_countp[PIL_MAX]; - -struct intr_vector intr_vectors[IV_MAX]; -uint16_t intr_countp[IV_MAX]; -static u_long intr_stray_count[IV_MAX]; - -static char *pil_names[] = { - "stray", - "low", /* PIL_LOW */ - "ithrd", /* PIL_ITHREAD */ - "rndzvs", /* PIL_RENDEZVOUS */ - "ast", /* PIL_AST */ - "stop", /* PIL_STOP */ - "preempt", /* PIL_PREEMPT */ - "hardclock", /* PIL_HARDCLOCK */ - "stray", "stray", "stray", "stray", "stray", - "fast", /* PIL_FAST */ - "tick", /* PIL_TICK */ -}; - - -/* - * XXX SUN4V_FIXME - the queue size values should - * really be calculated based on the size of the partition - * - */ - -int cpu_q_entries = 128; -int dev_q_entries = 128; - -static vm_offset_t *mondo_data_array; -static vm_offset_t *cpu_list_array; -static vm_offset_t *cpu_q_array; -static vm_offset_t *dev_q_array; -static vm_offset_t *rq_array; -static vm_offset_t *nrq_array; -static int cpu_list_size; - - - -/* protect the intr_vectors table */ -static struct mtx intr_table_lock; - -static void intr_execute_handlers(void *); -static void intr_stray_level(struct trapframe *); -static void intr_stray_vector(void *); -static int intrcnt_setname(const char *, int); -static void intrcnt_updatename(int, const char *, int); -static void cpu_intrq_alloc(void); - -/* - * not MPSAFE - */ -static void -intrcnt_updatename(int vec, const char *name, int ispil) -{ - static int intrcnt_index, stray_pil_index, stray_vec_index; - int name_index; - - if (intrnames[0] == '\0') { - /* for bitbucket */ - if (bootverbose) - printf("initalizing intr_countp\n"); - intrcnt_setname("???", intrcnt_index++); - - stray_vec_index = intrcnt_index++; - intrcnt_setname("stray", stray_vec_index); - for (name_index = 0; name_index < IV_MAX; name_index++) - intr_countp[name_index] = stray_vec_index; - - stray_pil_index = intrcnt_index++; - intrcnt_setname("pil", stray_pil_index); - for (name_index = 0; name_index < PIL_MAX; name_index++) - pil_countp[name_index] = stray_pil_index; - } - - if (name == NULL) - name = "???"; - - if (!ispil && intr_countp[vec] != stray_vec_index) - name_index = intr_countp[vec]; - else if (ispil && pil_countp[vec] != stray_pil_index) - name_index = pil_countp[vec]; - else - name_index = intrcnt_index++; - - if (intrcnt_setname(name, name_index)) - name_index = 0; - - if (!ispil) - intr_countp[vec] = name_index; - else - pil_countp[vec] = name_index; -} - -static int -intrcnt_setname(const char *name, int index) -{ - - if (intrnames + (MAXCOMLEN + 1) * index >= eintrnames) - return (E2BIG); - snprintf(intrnames + (MAXCOMLEN + 1) * index, MAXCOMLEN + 1, "%-*s", - MAXCOMLEN, name); - return (0); -} - -void -intr_setup(int pri, ih_func_t *ihf, int vec, iv_func_t *ivf, void *iva) -{ - char pilname[MAXCOMLEN + 1]; - u_long ps; - - ps = intr_disable_all(); - if (vec != -1) { - intr_vectors[vec].iv_func = ivf; - intr_vectors[vec].iv_arg = iva; - intr_vectors[vec].iv_pri = pri; - intr_vectors[vec].iv_vec = vec; - } - snprintf(pilname, MAXCOMLEN + 1, "pil%d: %s", pri, pil_names[pri]); - intrcnt_updatename(pri, pilname, 1); - intr_handlers[pri] = ihf; - intr_restore_all(ps); -} - -static void -intr_stray_level(struct trapframe *tf) -{ - - printf("stray level interrupt - pil=%ld\n", tf->tf_pil); -} - -static void -intr_stray_vector(void *cookie) -{ - struct intr_vector *iv; - - iv = cookie; - if (intr_stray_count[iv->iv_vec] < MAX_STRAY_LOG) { - printf("stray vector interrupt %d\n", iv->iv_vec); - intr_stray_count[iv->iv_vec]++; - if (intr_stray_count[iv->iv_vec] >= MAX_STRAY_LOG) - printf("got %d stray interrupt %d's: not logging " - "anymore\n", MAX_STRAY_LOG, iv->iv_vec); - } -} - -static void -intr_init(void) -{ - int i; - - /* Mark all interrupts as being stray. */ - for (i = 0; i < PIL_MAX; i++) - intr_handlers[i] = intr_stray_level; - for (i = 0; i < IV_MAX; i++) { - intr_vectors[i].iv_func = intr_stray_vector; - intr_vectors[i].iv_arg = &intr_vectors[i]; - intr_vectors[i].iv_pri = PIL_LOW; - intr_vectors[i].iv_vec = i; - } - intr_handlers[PIL_LOW] = intr_fast; - -#ifdef SMP - intr_handlers[PIL_AST] = cpu_ipi_ast; - intr_handlers[PIL_RENDEZVOUS] = (ih_func_t *)smp_rendezvous_action; - intr_handlers[PIL_STOP]= cpu_ipi_stop; - intr_handlers[PIL_PREEMPT]= cpu_ipi_preempt; - intr_handlers[PIL_HARDCLOCK]= cpu_ipi_hardclock; -#endif - mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN); - cpu_intrq_alloc(); - cpu_intrq_init(); - -} -SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL); - -static void -intr_enable(void *cookie) -{ - int vec; - - vec = (uintptr_t)cookie; - hv_intr_setstate(vec, HV_INTR_IDLE_STATE); -} - -static void -intr_execute_handlers(void *cookie) -{ - struct intr_vector *iv; - - iv = cookie; - if (intr_event_handle(iv->iv_event, NULL) != 0) - intr_stray_vector(iv); -} - -int -inthand_add(const char *name, int vec, driver_filter_t *filt, - void (*handler)(void *), void *arg, int flags, void **cookiep) -{ - struct intr_vector *iv; - struct intr_event *ie; /* descriptor for the IRQ */ - struct intr_event *orphan; - int errcode, pil; - - /* - * Work around a race where more than one CPU may be registering - * handlers on the same IRQ at the same time. - */ - iv = &intr_vectors[vec]; - mtx_lock_spin(&intr_table_lock); - ie = iv->iv_event; - mtx_unlock_spin(&intr_table_lock); - if (ie == NULL) { - errcode = intr_event_create(&ie, (void *)(intptr_t)vec, 0, vec, - NULL, intr_enable, intr_enable, NULL, "vec%d:", vec); - if (errcode) - return (errcode); - mtx_lock_spin(&intr_table_lock); - if (iv->iv_event == NULL) { - iv->iv_event = ie; - mtx_unlock_spin(&intr_table_lock); - } else { - orphan = ie; - ie = iv->iv_event; - mtx_unlock_spin(&intr_table_lock); - intr_event_destroy(orphan); - } - } - - errcode = intr_event_add_handler(ie, name, filt, handler, arg, - intr_priority(flags), flags, cookiep); - - if (errcode) - return (errcode); - - pil = (filt != NULL) ? PIL_FAST : PIL_ITHREAD; - - intr_setup(pil, intr_fast, vec, intr_execute_handlers, iv); - - intr_stray_count[vec] = 0; - - intrcnt_updatename(vec, ie->ie_fullname, 0); - - return (0); -} - -int -inthand_remove(int vec, void *cookie) -{ - struct intr_vector *iv; - int error; - - error = intr_event_remove_handler(cookie); - if (error == 0) { - /* - * XXX: maybe this should be done regardless of whether - * intr_event_remove_handler() succeeded? - * XXX: aren't the PIL's backwards below? - */ - iv = &intr_vectors[vec]; - mtx_lock_spin(&intr_table_lock); - if (iv->iv_event == NULL) - intr_setup(PIL_ITHREAD, intr_fast, vec, - intr_stray_vector, iv); - else - intr_setup(PIL_LOW, intr_fast, vec, - intr_execute_handlers, iv); - mtx_unlock_spin(&intr_table_lock); - } - return (error); -} - -/* - * Allocate and register intrq fields - */ -static void -cpu_intrq_alloc(void) -{ - - mondo_data_array = malloc(INTR_REPORT_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(mondo_data_array == NULL); - - cpu_list_size = CPU_LIST_SIZE > INTR_REPORT_SIZE ? CPU_LIST_SIZE : INTR_REPORT_SIZE; - cpu_list_array = malloc(cpu_list_size*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(cpu_list_array == NULL); - - cpu_q_array = malloc(INTR_CPU_Q_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(cpu_q_array == NULL); - - dev_q_array = malloc(INTR_DEV_Q_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(dev_q_array == NULL); - - rq_array = malloc(2*CPU_RQ_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(rq_array == NULL); - - nrq_array = malloc(2*CPU_NRQ_SIZE*MAXCPU, M_DEVBUF, M_WAITOK | M_ZERO); - PANIC_IF(nrq_array == NULL); - -} - -void -cpu_intrq_init() -{ - - uint64_t error; - - pcpup->pc_mondo_data = (vm_offset_t *) ((char *)mondo_data_array + curcpu*INTR_REPORT_SIZE); - pcpup->pc_mondo_data_ra = vtophys(pcpup->pc_mondo_data); - - pcpup->pc_cpu_q = (vm_offset_t *)((char *)cpu_q_array + curcpu*INTR_CPU_Q_SIZE); - - pcpup->pc_cpu_q_ra = vtophys(pcpup->pc_cpu_q); - pcpup->pc_cpu_q_size = INTR_CPU_Q_SIZE; - - pcpup->pc_dev_q = (vm_offset_t *)((char *)dev_q_array + curcpu*INTR_DEV_Q_SIZE); - pcpup->pc_dev_q_ra = vtophys(pcpup->pc_dev_q); - pcpup->pc_dev_q_size = INTR_DEV_Q_SIZE; - - pcpup->pc_rq = (vm_offset_t *)((char *)rq_array + curcpu*2*CPU_RQ_SIZE); - pcpup->pc_rq_ra = vtophys(pcpup->pc_rq); - pcpup->pc_rq_size = CPU_RQ_SIZE; - - pcpup->pc_nrq = (vm_offset_t *)((char *)nrq_array + curcpu*2*CPU_NRQ_SIZE); - pcpup->pc_nrq_ra = vtophys(pcpup->pc_nrq); - pcpup->pc_nrq_size = CPU_NRQ_SIZE; - - - error = hv_cpu_qconf(Q(CPU_MONDO_QUEUE_HEAD), pcpup->pc_cpu_q_ra, cpu_q_entries); - if (error != H_EOK) - panic("cpu_mondo queue configuration failed: %lu va=%p ra=0x%lx", error, - pcpup->pc_cpu_q, pcpup->pc_cpu_q_ra); - - error = hv_cpu_qconf(Q(DEV_MONDO_QUEUE_HEAD), pcpup->pc_dev_q_ra, dev_q_entries); - if (error != H_EOK) - panic("dev_mondo queue configuration failed: %lu", error); - - error = hv_cpu_qconf(Q(RESUMABLE_ERROR_QUEUE_HEAD), pcpup->pc_rq_ra, CPU_RQ_ENTRIES); - if (error != H_EOK) - panic("resumable error queue configuration failed: %lu", error); - - error = hv_cpu_qconf(Q(NONRESUMABLE_ERROR_QUEUE_HEAD), pcpup->pc_nrq_ra, CPU_NRQ_ENTRIES); - if (error != H_EOK) - panic("non-resumable error queue configuration failed: %lu", error); - -} diff --git a/sys/sun4v/sun4v/locore.S b/sys/sun4v/sun4v/locore.S deleted file mode 100644 index dade43292df7..000000000000 --- a/sys/sun4v/sun4v/locore.S +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "assym.s" - - .register %g2,#ignore - - .globl kernbase - .set kernbase,KERNBASE - - .globl nwin_minus_one - .set nwin_minus_one,7 - -/* - * void _start(caddr_t metadata, u_long o1, u_long o2, u_long o3, - * u_long ofw_vec) - */ -ENTRY(btext) -ENTRY(_start) - /* - * Initialize misc state to known values. Interrupts disabled, normal - * globals, windows flushed (cr = 0, cs = nwindows - 1), no clean - * windows, pil 0, and floating point disabled. - */ - wrpr %g0, PSTATE_NORMAL, %pstate - flushw - wrpr %g0, 0, %cleanwin - wrpr %g0, 0, %pil - wr %g0, 0, %fprs - - /* - * Get onto our per-cpu panic stack, which precedes the struct pcpu in - * the per-cpu page. - */ - SET(pcpu0 + (PCPU_PAGES * PAGE_SIZE) - PC_SIZEOF, %l1, %l0) - sub %l0, SPOFF + CCFSZ, %sp - - /* - * Do initial bootstrap to setup pmap and thread0. - */ - call sparc64_init - nop - - GET_PCB(%g6) - /* - * Get onto thread0's kstack. - */ - ldx [%g6 + PCB_KSTACK], %sp - - /* - * And away we go. This doesn't return. - */ - call mi_startup - nop - sir - ! NOTREACHED -END(_start) - -/* - * void cpu_setregs(struct pcpu *pc) - */ -ENTRY(cpu_setregs) - - /* - * Disable interrupts, normal globals. - */ - mov %o0, PCPU_REG - - /* - * store PCPU_REG into its scratchpad register - * this allows us to retrieve it in the trap handlers - - * where we receive a new set of globals - */ - mov SCRATCH_REG_PCPU, %g2 - stxa PCPU_REG, [%g2]ASI_SCRATCHPAD - - retl - nop -END(cpu_setregs) diff --git a/sys/sun4v/sun4v/machdep.c b/sys/sun4v/sun4v/machdep.c deleted file mode 100644 index 9475933ff764..000000000000 --- a/sys/sun4v/sun4v/machdep.c +++ /dev/null @@ -1,1016 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * Copyright (c) 1992 Terrence R. Lambert. - * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * from: FreeBSD: src/sys/i386/i386/machdep.c,v 1.477 2001/08/27 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "opt_compat.h" -#include "opt_ddb.h" -#include "opt_kstack_pages.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* XXX move this to a header */ -extern void mdesc_init(void); - -typedef int ofw_vec_t(void *); - -#ifdef DDB -extern vm_offset_t ksym_start, ksym_end; -#endif - -struct tlb_entry *kernel_tlbs; -int kernel_tlb_slots; - -int cold = 1; -long Maxmem; -long realmem; - -void *dpcpu0; -char pcpu0[PCPU_PAGES * PAGE_SIZE]; -struct trapframe frame0; -int trap_conversion[256]; -vm_paddr_t mmu_fault_status_area; - -vm_offset_t kstack0; -vm_paddr_t kstack0_phys; - -struct kva_md_info kmi; - -u_long ofw_vec; -u_long ofw_tba; - -/* - * Note: timer quality for CPU's is set low to try and prevent them from - * being chosen as the primary timecounter. The CPU counters are not - * synchronized among the CPU's so in MP machines this causes problems - * when calculating the time. With this value the CPU's should only be - * chosen as the primary timecounter as a last resort. - */ - -#define UP_TICK_QUALITY 1000 -#ifdef SUN4V -#define MP_TICK_QUALITY 1000 -#else -#define MP_TICK_QUALITY -100 -#endif - - - - - -static struct timecounter tick_tc; - -char sparc64_model[32]; - -cpu_block_copy_t *cpu_block_copy; -cpu_block_zero_t *cpu_block_zero; - -static timecounter_get_t tick_get_timecount; -void sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, - ofw_vec_t *vec); -void sparc64_shutdown_final(void *dummy, int howto); - -static void cpu_startup(void *); -SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL); - -CTASSERT((1 << INT_SHIFT) == sizeof(int)); -CTASSERT((1 << PTR_SHIFT) == sizeof(char *)); - -CTASSERT(sizeof(struct reg) == 256); -CTASSERT(sizeof(struct fpreg) == 272); -CTASSERT(sizeof(struct __mcontext) == 512); - -CTASSERT((sizeof(struct pcb) & (64 - 1)) == 0); -CTASSERT((offsetof(struct pcb, pcb_kfp) & (64 - 1)) == 0); -CTASSERT((offsetof(struct pcb, pcb_ufp) & (64 - 1)) == 0); -CTASSERT(sizeof(struct pcb) <= ((KSTACK_PAGES * PAGE_SIZE) / 8)); - -CTASSERT(sizeof(struct pcpu) <= ((PCPU_PAGES * PAGE_SIZE) / 2)); -CTASSERT((sizeof(struct pcpu) & ((1<<6)-1)) == 0); - - -#define BVPRINTF(x) \ - if (bootverbose) \ - printf(x); - -static void -cpu_startup(void *arg) -{ - vm_paddr_t physsz; - int i; - - tick_tc.tc_get_timecount = tick_get_timecount; - tick_tc.tc_poll_pps = NULL; - tick_tc.tc_counter_mask = ~0u; - tick_tc.tc_frequency = tick_freq; - tick_tc.tc_name = "tick"; - tick_tc.tc_quality = UP_TICK_QUALITY; -#ifdef SMP - /* - * We do not know if each CPU's tick counter is synchronized. - */ - if (cpu_mp_probe()) - tick_tc.tc_quality = MP_TICK_QUALITY; -#endif - - tc_init(&tick_tc); - - physsz = 0; - for (i = 0; i < sparc64_nmemreg; i++) - physsz += sparc64_memreg[i].mr_size; - printf("real memory = %lu (%lu MB)\n", physsz, - physsz / (1024 * 1024)); - realmem = (long)physsz; - - vm_ksubmap_init(&kmi); - - bufinit(); - vm_pager_bufferinit(); - - EVENTHANDLER_REGISTER(shutdown_final, sparc64_shutdown_final, NULL, - SHUTDOWN_PRI_LAST); - - printf("avail memory = %lu (%lu MB)\n", cnt.v_free_count * PAGE_SIZE, - cnt.v_free_count / ((1024 * 1024) / PAGE_SIZE)); - - if (bootverbose) - printf("machine: %s\n", sparc64_model); - -#ifdef notyet - cpu_identify(rdpr(ver), tick_freq, PCPU_GET(cpuid)); -#endif -} - -void -cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) -{ - struct intr_request *ir; - int i; - - pcpu->pc_irtail = &pcpu->pc_irhead; - for (i = 0; i < IR_FREE; i++) { - ir = &pcpu->pc_irpool[i]; - ir->ir_next = pcpu->pc_irfree; - pcpu->pc_irfree = ir; - } -} - -void -spinlock_enter(void) -{ - struct thread *td; - register_t pil; - - td = curthread; - if (td->td_md.md_spinlock_count == 0) { - pil = intr_disable(); - td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_pil = pil; - } else - td->td_md.md_spinlock_count++; - critical_enter(); -} - -void -spinlock_exit(void) -{ - struct thread *td; - register_t pil; - - td = curthread; - critical_exit(); - pil = td->td_md.md_saved_pil; - td->td_md.md_spinlock_count--; - if (td->td_md.md_spinlock_count == 0) - intr_restore(pil); -} - -unsigned -tick_get_timecount(struct timecounter *tc) -{ - return ((unsigned)rd(tick)); -} - -void -sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec) -{ - phandle_t child; - phandle_t root; - struct pcpu *pc; - vm_offset_t end; - caddr_t kmdp; - u_int clock; - char *env; - char type[8]; - vm_paddr_t mmfsa; - int i; - - end = 0; - kmdp = NULL; - - /* - * XXX - */ - bootverbose = 1; - - /* - * Set up Open Firmware entry points - */ - ofw_tba = rdpr(tba); - ofw_vec = (u_long)vec; - - /* - * Parse metadata if present and fetch parameters. Must be before the - * console is inited so cninit gets the right value of boothowto. - */ - if (mdp != NULL) { - preload_metadata = mdp; - kmdp = preload_search_by_type("elf kernel"); - if (kmdp != NULL) { - boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int); - kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *); - end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); - kernel_tlb_slots = MD_FETCH(kmdp, MODINFOMD_DTLB_SLOTS, - int); - kernel_tlbs = (void *)preload_search_info(kmdp, - MODINFO_METADATA | MODINFOMD_DTLB); - } - } - - if (boothowto & RB_VERBOSE) - bootverbose = 1; - - init_param1(); - - /* - * Initialize Open Firmware (needed for console). - */ - OF_install(OFW_STD_DIRECT, 0); - OF_init(ofw_entry); - - root = OF_peer(0); - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - OF_getprop(child, "device_type", type, sizeof(type)); - if (strcmp(type, "cpu") == 0) - break; - } - - OF_getprop(child, "clock-frequency", &clock, sizeof(clock)); - - /* - * Initialize the console before printing anything. - * console uses the pcpu area for serialization - */ - pc = (struct pcpu *)(pcpu0 + (PCPU_PAGES * PAGE_SIZE)) - 1; - cpu_setregs(pc); - - /* - * Initialize proc0 stuff (p_contested needs to be done early). - */ - - proc_linkup0(&proc0, &thread0); - proc0.p_md.md_sigtramp = NULL; - proc0.p_md.md_utrap = NULL; - frame0.tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_PRIV; - thread0.td_frame = &frame0; - if ((u_long)thread0.td_frame & 0x3f) { - panic("unaligned frame0"); - } - - /* - * Prime our per-cpu data page for use. Note, we are using it for our - * stack, so don't pass the real size (PAGE_SIZE) to pcpu_init or - * it'll zero it out from under us. - */ - pc = (struct pcpu *)(pcpu0 + (PCPU_PAGES * PAGE_SIZE)) - 1; - pcpu_init(pc, 0, sizeof(struct pcpu)); - pc->pc_curthread = &thread0; - pc->pc_addr = (vm_offset_t)pcpu0; - - cninit(); - tick_init(clock); - - printf("cpu0: UltraSparc T1 Processor (%d.%02d MHz CPU)\n", - (clock + 4999) / 1000000, ((clock + 4999) / 10000) % 100); - - /* - * Panic is there is no metadata. Most likely the kernel was booted - * directly, instead of through loader(8). - */ - if (mdp == NULL || kmdp == NULL) { - printf("sparc64_init: no loader metadata.\n" - "This probably means you are not using loader(8).\n"); - panic("sparc64_init"); - } - - /* - * Sanity check the kernel end, which is important. - */ - if (end == 0) { - printf("sparc64_init: warning, kernel end not specified.\n" - "Attempting to continue anyway.\n"); - end = (vm_offset_t)_end; - } - - cpu_block_copy = bcopy; - cpu_block_zero = bzero; - -#ifdef SMP - mp_tramp = mp_tramp_alloc(); -#endif - - env = getenv("kernelname"); - if (env != NULL) { - strlcpy(kernelname, env, sizeof(kernelname)); - freeenv(env); - } - - /* - * Initialize global registers. - * needed for curthread to work - */ - cpu_setregs(pc); - - /* - * Initialize virtual memory and calculate physmem. - */ - pmap_bootstrap(end); - - thread0.td_kstack = kstack0; - thread0.td_md.md_saved_pil = 0; - thread0.td_pcb = (struct pcb *) - (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; - thread0.td_pcb->pcb_kstack = (uint64_t)(((char *)thread0.td_pcb) - (CCFSZ + SPOFF)); - thread0.td_pcb = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)thread0.td_pcb)); - pc->pc_curpcb = thread0.td_pcb; - - if (((thread0.td_pcb->pcb_kstack + SPOFF) & 0x3f) != 0) { - printf("unaligned stack pcb_kstack & 0x3f == 0x%lx\n", - ((thread0.td_pcb->pcb_kstack + SPOFF) & 0x3f)); - } - - /* - * Update PCPU_REG to point to direct address - * to support easy phys <-> virt translation in trap handler - */ - pc = (struct pcpu *)TLB_PHYS_TO_DIRECT(vtophys(pc)); - - BVPRINTF("initializing cpu regs\n"); - cpu_setregs(pc); - - /* - * Initialize tunables. - */ - BVPRINTF("initialize tunables\n"); - init_param2(physmem); - - /* - * setup trap table and fault status area - */ - BVPRINTF("initialize trap tables\n"); - - mmfsa = mmu_fault_status_area + MMFSA_SIZE; - BVPRINTF("setwstate\n"); - set_wstate(WSTATE_KERN); - BVPRINTF("set_mmfsa_scratchpad\n"); - set_mmfsa_scratchpad(mmfsa); - - BVPRINTF("init_mondo_queue\n"); - init_mondo_queue(); - BVPRINTF("set_mmfsa_traptable\n"); - set_mmfsa_traptable(&tl0_base, mmfsa); - BVPRINTF("trap conversion\n"); - for (i = 0; i < 256; i++) - trap_conversion[i] = 0; - trap_conversion[TT_INSTRUCTION_EXCEPTION] = T_INSTRUCTION_EXCEPTION; - trap_conversion[TT_INSTRUCTION_MISS] = T_INSTRUCTION_MISS; - trap_conversion[TT_ILLEGAL_INSTRUCTION] = T_ILLEGAL_INSTRUCTION; - trap_conversion[TT_PRIVILEGED_OPCODE] = T_PRIVILEGED_OPCODE; - trap_conversion[TT_FP_EXCEPTION_IEEE_754] = T_FP_EXCEPTION_IEEE_754; - trap_conversion[TT_TAG_OVERFLOW] = T_TAG_OVERFLOW; - trap_conversion[TT_DIVISION_BY_ZERO] = T_DIVISION_BY_ZERO; - trap_conversion[TT_DATA_EXCEPTION] = T_DATA_EXCEPTION; - trap_conversion[TT_DATA_MISS] = T_DATA_MISS; - trap_conversion[TT_ALIGNMENT] = T_ALIGNMENT; - trap_conversion[TT_DATA_PROTECTION] = T_DATA_PROTECTION; - - /* - * Initialize the message buffer (after setting trap table). - */ - BVPRINTF("initialize msgbuf\n"); - dpcpu_init(dpcpu0, 0); - msgbufinit(msgbufp, msgbufsize); - - BVPRINTF("initialize mutexes\n"); - mutex_init(); - - BVPRINTF("initialize machine descriptor table\n"); - mdesc_init(); - - BVPRINTF("initialize get model name\n"); - OF_getprop(root, "name", sparc64_model, sizeof(sparc64_model) - 1); - - BVPRINTF("initialize kdb\n"); - kdb_init(); - -#ifdef KDB - if (boothowto & RB_KDB) - kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); -#endif - BVPRINTF("sparc64_init done\n"); -} - -void -sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) -{ - struct trapframe *tf; - struct sigframe *sfp; - struct sigacts *psp; - struct sigframe sf; - struct thread *td; - struct frame *fp; - struct proc *p; - int oonstack; - u_long sp; - int sig; - int code; - - oonstack = 0; - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - code = ksi->ksi_code; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - tf = td->td_frame; - sp = tf->tf_sp + SPOFF; - oonstack = sigonstack(sp); - - CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, - catcher, sig); - - /* Make sure we have a signal trampoline to return to. */ - if (p->p_md.md_sigtramp == NULL) { - /* - * No signal tramoline... kill the process. - */ - CTR0(KTR_SIG, "sendsig: no sigtramp"); - printf("sendsig: %s is too old, rebuild it\n", p->p_comm); - sigexit(td, sig); - /* NOTREACHED */ - } - - /* Save user context. */ - bzero(&sf, sizeof(sf)); - get_mcontext(td, &sf.sf_uc.uc_mcontext, 0); - sf.sf_uc.uc_sigmask = *mask; - sf.sf_uc.uc_stack = td->td_sigstk; - sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) - ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; - - /* Allocate and validate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - sfp = (struct sigframe *)(td->td_sigstk.ss_sp + - td->td_sigstk.ss_size - sizeof(struct sigframe)); - } else - sfp = (struct sigframe *)sp - 1; - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - - fp = (struct frame *)sfp - 1; - - /* Translate the signal if appropriate. */ - if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - - /* Build the argument list for the signal handler. */ - tf->tf_out[0] = sig; - tf->tf_out[2] = (register_t)&sfp->sf_uc; - tf->tf_out[4] = (register_t)catcher; - - /* Fill siginfo structure. */ - sf.sf_si = ksi->ksi_info; - sf.sf_si.si_addr = (void *)tf->tf_tpc; - if (SIGISMEMBER(psp->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - tf->tf_out[1] = (register_t)&sfp->sf_si; - - /* Fill in POSIX parts. */ - sf.sf_si = ksi->ksi_info; - sf.sf_si.si_signo = sig; /* maybe a translated signal */ - } else { - /* Old FreeBSD-style arguments. */ - tf->tf_out[1] = ksi->ksi_code; - tf->tf_out[3] = (register_t)ksi->ksi_addr; - } - - /* Copy the sigframe out to the user's stack. */ - if (rwindow_save(td) != 0 || copyout(&sf, sfp, sizeof(*sfp)) != 0 || - suword(&fp->fr_in[6], tf->tf_out[6]) != 0) { - /* - * Something is wrong with the stack pointer. - * ...Kill the process. - */ - CTR2(KTR_SIG, "sendsig: sigexit td=%p sfp=%p", td, sfp); - PROC_LOCK(p); - sigexit(td, SIGILL); - /* NOTREACHED */ - } - - tf->tf_tpc = (u_long)p->p_md.md_sigtramp; - tf->tf_tnpc = tf->tf_tpc + 4; - tf->tf_sp = (u_long)fp - SPOFF; - - CTR3(KTR_SIG, "sendsig: return td=%p pc=%#lx sp=%#lx", td, tf->tf_tpc, - tf->tf_sp); - - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} - -#ifndef _SYS_SYSPROTO_H_ -struct sigreturn_args { - ucontext_t *ucp; -}; -#endif - -/* - * MPSAFE - */ -int -sigreturn(struct thread *td, struct sigreturn_args *uap) -{ - struct proc *p; - mcontext_t *mc; - ucontext_t uc; - int error; - - p = td->td_proc; - if (rwindow_save(td)) { - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - CTR2(KTR_SIG, "sigreturn: td=%p ucp=%p", td, uap->sigcntxp); - if (copyin(uap->sigcntxp, &uc, sizeof(uc)) != 0) { - CTR1(KTR_SIG, "sigreturn: efault td=%p", td); - return (EFAULT); - } - - mc = &uc.uc_mcontext; - error = set_mcontext(td, mc); - if (error != 0) - return (error); - - kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); - - CTR4(KTR_SIG, "sigreturn: return td=%p pc=%#lx sp=%#lx tstate=%#lx", - td, mc->mc_tpc, mc->mc_sp, mc->mc_tstate); - return (EJUSTRETURN); -} - -#ifdef COMPAT_FREEBSD4 -int -freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap) -{ - - return sigreturn(td, (struct sigreturn_args *)uap); -} -#endif - -/* - * Construct a PCB from a trapframe. This is called from kdb_trap() where - * we want to start a backtrace from the function that caused us to enter - * the debugger. We have the context in the trapframe, but base the trace - * on the PCB. The PCB doesn't have to be perfect, as long as it contains - * enough for a backtrace. - */ -void -makectx(struct trapframe *tf, struct pcb *pcb) -{ - - pcb->pcb_pc = tf->tf_tpc; - pcb->pcb_sp = tf->tf_sp; -} - -int -get_mcontext(struct thread *td, mcontext_t *mc, int flags) -{ - struct trapframe *tf; - struct pcb *pcb; - - tf = td->td_frame; - pcb = td->td_pcb; - bcopy(tf, mc, sizeof(*tf)); - if (flags & GET_MC_CLEAR_RET) { - mc->mc_out[0] = 0; - mc->mc_out[1] = 0; - } - mc->mc_flags = _MC_VERSION; - critical_enter(); - if ((tf->tf_fprs & FPRS_FEF) != 0) { - savefpctx(pcb->pcb_ufp); - pcb->pcb_flags |= PCB_FEF; - tf->tf_fprs &= ~FPRS_FEF; - } - if ((pcb->pcb_flags & PCB_FEF) != 0) { - bcopy(pcb->pcb_ufp, mc->mc_fp, sizeof(mc->mc_fp)); - mc->mc_fprs |= FPRS_FEF; - } - critical_exit(); - return (0); -} - -int -set_mcontext(struct thread *td, const mcontext_t *mc) -{ - struct trapframe *tf; - struct pcb *pcb; - uint64_t wstate; - - if (!TSTATE_SECURE(mc->mc_tstate) || - (mc->mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION) - return (EINVAL); - tf = td->td_frame; - pcb = td->td_pcb; - /* Make sure the windows are spilled first. */ - flushw(); - wstate = tf->tf_wstate; - bcopy(mc, tf, sizeof(*tf)); - tf->tf_wstate = wstate; - if ((mc->mc_fprs & FPRS_FEF) != 0) { - tf->tf_fprs = 0; - bcopy(mc->mc_fp, pcb->pcb_ufp, sizeof(pcb->pcb_ufp)); - pcb->pcb_flags |= PCB_FEF; - } - return (0); -} - -/* - * Exit the kernel and execute a firmware call that will not return, as - * specified by the arguments. - */ -void -cpu_shutdown(void *args) -{ - -#ifdef SMP - cpu_mp_shutdown(); -#endif - hv_mach_exit(0); -} - -/* - * Flush the D-cache for non-DMA I/O so that the I-cache can - * be made coherent later. - */ -void -cpu_flush_dcache(void *ptr, size_t len) -{ - /* TBD */ -} - -/* Get current clock frequency for the given cpu id. */ -int -cpu_est_clockrate(int cpu_id, uint64_t *rate) -{ - - return (ENXIO); -} - -/* - * Duplicate OF_exit() with a different firmware call function that restores - * the trap table, otherwise a RED state exception is triggered in at least - * some firmware versions. - */ -void -cpu_halt(void) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - } args = { - (cell_t)"exit", - 0, - 0 - }; - - cpu_shutdown(&args); -} - -void -sparc64_shutdown_final(void *dummy, int howto) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - } args = { - (cell_t)"SUNW,power-off", - 0, - 0 - }; - - /* Turn the power off? */ - if ((howto & RB_POWEROFF) != 0) - cpu_shutdown(&args); - /* In case of halt, return to the firmware */ - if ((howto & RB_HALT) != 0) - cpu_halt(); -} - -void -cpu_idle(int busy) -{ - - if (rdpr(pil) != 0) - panic("pil in cpu_idle not 0 - %ld", rdpr(pil)); - if (rdpr(pstate) != 0x16) - panic("interrupts disabled in cpu_idle 0x%lx", rdpr(pstate)); - /* XXX heinous hack begin*/ - - cpu_yield(); -} - -int -cpu_idle_wakeup(int cpu) -{ - - return (0); -} - -int -ptrace_set_pc(struct thread *td, u_long addr) -{ - - td->td_frame->tf_tpc = addr; - td->td_frame->tf_tnpc = addr + 4; - return (0); -} - -int -ptrace_single_step(struct thread *td) -{ - /* TODO; */ - return (0); -} - -int -ptrace_clear_single_step(struct thread *td) -{ - /* TODO; */ - return (0); -} - -void -exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) -{ - struct trapframe *tf; - struct pcb *pcb; - struct proc *p; - uint64_t kstack; - u_long sp; - - /* XXX no cpu_exec */ - - p = td->td_proc; - p->p_md.md_sigtramp = NULL; - if (p->p_md.md_utrap != NULL) { - utrap_free(p->p_md.md_utrap); - p->p_md.md_utrap = NULL; - } - pcb = td->td_pcb; - kstack = pcb->pcb_kstack; - tf = td->td_frame; - sp = rounddown(stack, 16); - bzero(pcb, sizeof(*pcb)); - bzero(tf, sizeof(*tf)); - pcb->pcb_kstack = kstack; - - tf->tf_out[0] = stack; - tf->tf_out[3] = p->p_sysent->sv_psstrings; - tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); - - tf->tf_tnpc = imgp->entry_addr + 4; - tf->tf_tpc = imgp->entry_addr; - tf->tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_MM_TSO; - - td->td_retval[0] = tf->tf_out[0]; - td->td_retval[1] = tf->tf_out[1]; -} - -int -fill_regs(struct thread *td, struct reg *regs) -{ - - bcopy(td->td_frame, regs, sizeof(*regs)); - return (0); -} - -int -set_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *tf; - - if (!TSTATE_SECURE(regs->r_tstate)) - return (EINVAL); - tf = td->td_frame; - regs->r_wstate = tf->tf_wstate; - bcopy(regs, tf, sizeof(*regs)); - return (0); -} - -int -fill_dbregs(struct thread *td, struct dbreg *dbregs) -{ - - return (ENOSYS); -} - -int -set_dbregs(struct thread *td, struct dbreg *dbregs) -{ - - return (ENOSYS); -} - -int -fill_fpregs(struct thread *td, struct fpreg *fpregs) -{ - struct trapframe *tf; - struct pcb *pcb; - - pcb = td->td_pcb; - tf = td->td_frame; - tf->tf_fprs = ~FPRS_FEF; - bcopy(pcb->pcb_ufp, fpregs->fr_regs, sizeof(fpregs->fr_regs)); - fpregs->fr_fsr = tf->tf_fsr; - fpregs->fr_gsr = tf->tf_gsr; - return (0); -} - -int -set_fpregs(struct thread *td, struct fpreg *fpregs) -{ - struct trapframe *tf; - struct pcb *pcb; - - pcb = td->td_pcb; - tf = td->td_frame; - tf->tf_fprs &= ~FPRS_FEF; - bcopy(fpregs->fr_regs, pcb->pcb_ufp, sizeof(pcb->pcb_ufp)); - tf->tf_fsr = fpregs->fr_fsr; - tf->tf_gsr = fpregs->fr_gsr; - return (0); -} - -struct md_utrap * -utrap_alloc(void) -{ - struct md_utrap *ut; - - ut = malloc(sizeof(struct md_utrap), M_SUBPROC, M_WAITOK | M_ZERO); - ut->ut_refcnt = 1; - return (ut); -} - -void -utrap_free(struct md_utrap *ut) -{ - int refcnt; - - if (ut == NULL) - return; - mtx_pool_lock(mtxpool_sleep, ut); - ut->ut_refcnt--; - refcnt = ut->ut_refcnt; - mtx_pool_unlock(mtxpool_sleep, ut); - if (refcnt == 0) - free(ut, M_SUBPROC); -} - -struct md_utrap * -utrap_hold(struct md_utrap *ut) -{ - - if (ut == NULL) - return (NULL); - mtx_pool_lock(mtxpool_sleep, ut); - ut->ut_refcnt++; - mtx_pool_unlock(mtxpool_sleep, ut); - return (ut); -} - -void -cpu_yield(void) -{ - if (rdpr(pil) < PIL_TICK) - hv_cpu_yield(); -} diff --git a/sys/sun4v/sun4v/mp_exception.S b/sys/sun4v/sun4v/mp_exception.S deleted file mode 100644 index 699d766fa7c3..000000000000 --- a/sys/sun4v/sun4v/mp_exception.S +++ /dev/null @@ -1,280 +0,0 @@ -/*- - * Copyright (c) 2002 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "assym.s" - - .register %g2, #ignore - .register %g3, #ignore - -#define IPI_DONE(r1, r2, r3, r4) \ - lduw [PCPU(CPUMASK)], r4 ; \ - ATOMIC_CLEAR_INT(r1, r2, r3, r4) - -/* - * Invalidate a physical page in the data cache. For UltraSPARC I and II. - */ -#if 0 -ENTRY(tl_ipi_spitfire_dcache_page_inval) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_dcache_page_inval: pa=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ICA_PA], %g2 - stx %g2, [%g1 + KTR_PARM1] -9: -#endif - - ldx [%g5 + ICA_PA], %g6 - srlx %g6, PAGE_SHIFT - DC_TAG_SHIFT, %g6 - - SET(cache, %g3, %g2) - lduw [%g2 + DC_SIZE], %g3 - lduw [%g2 + DC_LINESIZE], %g4 - sub %g3, %g4, %g2 - -1: ldxa [%g2] ASI_DCACHE_TAG, %g1 - srlx %g1, DC_VALID_SHIFT, %g3 - andcc %g3, DC_VALID_MASK, %g0 - bz,pt %xcc, 2f - set DC_TAG_MASK, %g3 - sllx %g3, DC_TAG_SHIFT, %g3 - and %g1, %g3, %g1 - cmp %g1, %g6 - bne,a,pt %xcc, 2f - nop - stxa %g1, [%g2] ASI_DCACHE_TAG - membar #Sync - -2: brgz,pt %g2, 1b - sub %g2, %g4, %g2 - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_spitfire_dcache_page_inval) - -/* - * Invalidate a physical page in the instruction cache. For UltraSPARC I and - * II. - */ -ENTRY(tl_ipi_spitfire_icache_page_inval) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_icache_page_inval: pa=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ICA_PA], %g2 - stx %g2, [%g1 + KTR_PARM1] -9: -#endif - - ldx [%g5 + ICA_PA], %g6 - srlx %g6, PAGE_SHIFT - IC_TAG_SHIFT, %g6 - - SET(cache, %g3, %g2) - lduw [%g2 + IC_SIZE], %g3 - lduw [%g2 + IC_LINESIZE], %g4 - sub %g3, %g4, %g2 - -1: ldda [%g2] ASI_ICACHE_TAG, %g0 /*, %g1 */ - srlx %g1, IC_VALID_SHIFT, %g3 - andcc %g3, IC_VALID_MASK, %g0 - bz,pt %xcc, 2f - set IC_TAG_MASK, %g3 - sllx %g3, IC_TAG_SHIFT, %g3 - and %g1, %g3, %g1 - cmp %g1, %g6 - bne,a,pt %xcc, 2f - nop - stxa %g1, [%g2] ASI_ICACHE_TAG - membar #Sync - -2: brgz,pt %g2, 1b - sub %g2, %g4, %g2 - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_spitfire_icache_page_inval) - -/* - * Invalidate a physical page in the data cache. For UltraSPARC III. - */ -ENTRY(tl_ipi_cheetah_dcache_page_inval) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_dcache_page_inval: pa=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ICA_PA], %g2 - stx %g2, [%g1 + KTR_PARM1] -9: -#endif - - ldx [%g5 + ICA_PA], %g1 - - set PAGE_SIZE, %g2 - add %g1, %g2, %g3 - - SET(cache, %g4, %g2) - lduw [%g2 + DC_LINESIZE], %g2 - -1: stxa %g0, [%g1] ASI_DCACHE_INVALIDATE - membar #Sync - - add %g1, %g2, %g1 - cmp %g1, %g3 - blt,a,pt %xcc, 1b - nop - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_cheetah_dcache_page_inval) -#endif - -/* - * Trigger a softint at the desired level. - */ -ENTRY(tl_ipi_level) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "tl_ipi_level: cpuid=%d mid=%d d1=%#lx d2=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - lduw [PCPU(CPUID)], %g2 - stx %g2, [%g1 + KTR_PARM1] - lduw [PCPU(MID)], %g2 - stx %g2, [%g1 + KTR_PARM2] - stx %g4, [%g1 + KTR_PARM3] - stx %g5, [%g1 + KTR_PARM4] -9: -#endif - - mov 1, %g2 - sllx %g2, %g1, %g2 - wr %g2, 0, %set_softint - retry -END(tl_ipi_level) - -/* - * Demap a page from the dtlb and/or itlb. - */ -#if 0 -ENTRY(tl_ipi_tlb_page_demap) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_tlb_page_demap: pm=%p va=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ITA_PMAP], %g2 - stx %g2, [%g1 + KTR_PARM1] - ldx [%g5 + ITA_VA], %g2 - stx %g2, [%g1 + KTR_PARM2] -9: -#endif - - ldx [%g5 + ITA_PMAP], %g1 - - SET(kernel_pmap_store, %g3, %g2) - mov TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE, %g3 - - cmp %g1, %g2 - movne %xcc, TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, %g3 - - ldx [%g5 + ITA_VA], %g2 - or %g2, %g3, %g2 - - stxa %g0, [%g2] ASI_DMMU_DEMAP - stxa %g0, [%g2] ASI_IMMU_DEMAP - membar #Sync - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_tlb_page_demap) - -/* - * Demap a range of pages from the dtlb and itlb. - */ -ENTRY(tl_ipi_tlb_range_demap) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_tlb_range_demap: pm=%p start=%#lx end=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ITA_PMAP], %g2 - stx %g2, [%g1 + KTR_PARM1] - ldx [%g5 + ITA_START], %g2 - stx %g2, [%g1 + KTR_PARM2] - ldx [%g5 + ITA_END], %g2 - stx %g2, [%g1 + KTR_PARM3] -9: -#endif - - ldx [%g5 + ITA_PMAP], %g1 - - SET(kernel_pmap_store, %g3, %g2) - mov TLB_DEMAP_NUCLEUS | TLB_DEMAP_PAGE, %g3 - - cmp %g1, %g2 - movne %xcc, TLB_DEMAP_PRIMARY | TLB_DEMAP_PAGE, %g3 - - ldx [%g5 + ITA_START], %g1 - ldx [%g5 + ITA_END], %g2 - - set PAGE_SIZE, %g6 - -1: or %g1, %g3, %g4 - stxa %g0, [%g4] ASI_DMMU_DEMAP - stxa %g0, [%g4] ASI_IMMU_DEMAP - membar #Sync - - add %g1, %g6, %g1 - cmp %g1, %g2 - blt,a,pt %xcc, 1b - nop - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_tlb_range_demap) - -/* - * Demap the primary context from the dtlb and itlb. - */ -ENTRY(tl_ipi_tlb_context_demap) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "ipi_tlb_page_demap: pm=%p va=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - ldx [%g5 + ITA_PMAP], %g2 - stx %g2, [%g1 + KTR_PARM1] - ldx [%g5 + ITA_VA], %g2 - stx %g2, [%g1 + KTR_PARM2] -9: -#endif - - mov TLB_DEMAP_PRIMARY | TLB_DEMAP_CONTEXT, %g1 - stxa %g0, [%g1] ASI_DMMU_DEMAP - stxa %g0, [%g1] ASI_IMMU_DEMAP - membar #Sync - - IPI_DONE(%g5, %g1, %g2, %g3) - retry -END(tl_ipi_tlb_context_demap) -#endif diff --git a/sys/sun4v/sun4v/mp_locore.S b/sys/sun4v/sun4v/mp_locore.S deleted file mode 100644 index 5d34eeec678b..000000000000 --- a/sys/sun4v/sun4v/mp_locore.S +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 2002 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include "assym.s" - - .register %g2, #ignore - .register %g3, #ignore - - .text - _ALIGN_TEXT - -1: rd %pc, %l0 ! startpc - mov %o0, %g1 ! save arg to to mp_tramp_func - ldx [%l0 + (6f-1b)], %l1 ! read mp_tramp_tte_slots - add %l0, (7f-1b), %l2 ! %l2 points to start of slot area - clr %l3 -2: cmp %l3, %l1 ! number of slots entered == total? - be %xcc, 3f - nop - ldx [%l2], %o0 ! VA - mov 0, %o1 ! ctx0 - ldx [%l2 + 8], %o2 ! TTE - mov MAP_ITLB|MAP_DTLB, %o3 - mov MMU_MAP_PERM_ADDR, %o5 - ta FAST_TRAP -#ifdef DEBUG - brz %o0, 9f - nop - ta 0x77 - ta 0x71 -9: -#endif - add %l2, 16, %l2 ! point %l2 at next slot - inc %l3 - ba %xcc, 2b - nop -3: - ldx [%l0 + (4f-1b)], %o1 ! read mp_tramp_tsb_ra - mov 2, %o0 - mov MMU_TSB_CTX0, %o5 ! set ctx0 TSBs - ta FAST_TRAP -#ifdef DEBUG - brz %o0, 9f - nop - ta 0x77 - ta 0x71 -9: -#endif - ldx [%l0 + (5f-1b)], %l1 ! fetch mp_tramp_func - jmpl %l1, %g0 ! and off we go - mov %g1, %o0 - _ALIGN_DATA -4: .xword 0x0 -5: .xword 0x0 -6: .xword 0x0 -7: - -DATA(mp_tramp_code) - .xword 1b -DATA(mp_tramp_code_len) - .xword 7b-1b -DATA(mp_tramp_tsb_desc_ra) - .xword 4b-1b -DATA(mp_tramp_func) - .xword 5b-1b -DATA(mp_tramp_tte_slots) - .xword 6b-1b - - -#define PUTCHAR(x) \ - mov x, %o0 ; \ - mov CONS_WRITE, %o5 ; \ - ta FAST_TRAP -/* - * void mp_startup(void) - */ -ENTRY(mp_startup) - wrpr %g0, PSTATE_NORMAL, %pstate - wrpr %g0, 0, %cleanwin - wrpr %g0, 0, %pil - wr %g0, 0, %fprs - - SET(cpu_start_args, %l1, %l0) -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "mp_start: cpu %d entered kernel" - , %g1, %g2, %g3, 7, 8, 9) - stx %o0, [%g1 + KTR_PARM1] -9: -#endif - - /* - * Inform the boot processor we have inited. - */ - mov CPU_INIT, %l1 - membar #LoadStore - stw %l1, [%l0 + CSA_STATE] - -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, "_mp_start: cpu %d got start signal" - , %g1, %g2, %g3, 7, 8, 9) - stx %o0, [%g1 + KTR_PARM1] -9: -#endif -2: - ld [%l0 + CSA_CPUID], %l1 - cmp %l1, %o0 - bne %xcc, 2b - nop - - /* - * Get onto our per-cpu panic stack, which precedes the struct pcpu - * in the per-cpu page. - */ - ldx [%l0 + CSA_PCPU], %l1 - set PCPU_PAGES * PAGE_SIZE - PC_SIZEOF, %l2 - add %l1, %l2, %l1 - sub %l1, SPOFF + CCFSZ, %sp - wrpr %g0, PIL_TICK, %pil -#if KTR_COMPILE & KTR_SMP - CATR(KTR_SMP, - "_mp_start: bootstrap cpuid=%d mid=%d pcpu=%#lx data=%#lx sp=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - lduw [%l1 + PC_CPUID], %g2 - stx %g2, [%g1 + KTR_PARM1] - lduw [%l1 + PC_MID], %g2 - stx %g2, [%g1 + KTR_PARM2] - stx %l1, [%g1 + KTR_PARM3] - stx %sp, [%g1 + KTR_PARM5] -9: -#endif - - /* - * And away we go. This doesn't return. - */ - call cpu_mp_bootstrap - mov %l1, %o0 - sir - ! NOTREACHED -END(mp_startup) diff --git a/sys/sun4v/sun4v/mp_machdep.c b/sys/sun4v/sun4v/mp_machdep.c deleted file mode 100644 index b3c89d27366e..000000000000 --- a/sys/sun4v/sun4v/mp_machdep.c +++ /dev/null @@ -1,613 +0,0 @@ -/*- - * Copyright (c) 1997 Berkeley Software Design, Inc. 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. - * 3. Berkeley Software Design Inc's name may not be used to endorse or - * promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``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 BERKELEY SOFTWARE DESIGN INC 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 BSDI: locore.s,v 1.36.2.15 1999/08/23 22:34:41 cp Exp - */ -/*- - * Copyright (c) 2002 Jake Burkholder. - * Copyright (c) 2006 Kip Macy . - * 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 -__FBSDID("$FreeBSD$"); - -#include "opt_trap_trace.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Argument area used to pass data to non-boot processors as they start up. - * This must be statically initialized with a known invalid cpuid, - * - */ -struct cpu_start_args cpu_start_args = { 0, -1, 0, -1 }; -struct ipi_cache_args ipi_cache_args; -struct ipi_tlb_args ipi_tlb_args; -struct pcb stoppcbs[MAXCPU]; - -struct mtx ipi_mtx; - -vm_offset_t mp_tramp; - -u_int mp_boot_mid; - -static volatile cpuset_t shutdown_cpus; - -void cpu_mp_unleash(void *); -SYSINIT(cpu_mp_unleash, SI_SUB_SMP, SI_ORDER_FIRST, cpu_mp_unleash, NULL); - -#ifdef TRAP_TRACING -#ifndef TRAP_TRACE_ENTRIES -#define TRAP_TRACE_ENTRIES 64 -#endif -extern trap_trace_entry_t trap_trace_entry[MAXCPU][TRAP_TRACE_ENTRIES]; - -static void -mp_trap_trace_init(void) -{ - uint64_t ret, ret1; - - printf("curcpu %d trap_trace_entry %p TRAP_TRACE_ENTRIES %d\n", curcpu, &trap_trace_entry[curcpu][0], TRAP_TRACE_ENTRIES); - - /* Configure the trap trace buffer for the current CPU. */ - if ((ret = hv_ttrace_buf_conf((uint64_t) vtophys(&trap_trace_entry[curcpu][0]), - (uint64_t) TRAP_TRACE_ENTRIES, &ret1)) != 0) - printf("%s: hv_ttrace_buf_conf error %lu\n", __FUNCTION__, ret); - - /* Enable trap tracing for the current CPU. */ - else if ((ret = hv_ttrace_enable((uint64_t) -1, &ret1)) != 0) - printf("%s: hv_ttrace_enable error %lu\n", __FUNCTION__, ret); -} - -void trap_trace_report(int); - -static int trace_trap_lock; - -void -trap_trace_report(int cpuid) -{ - int i, j; - - while (!atomic_cmpset_acq_int(&trace_trap_lock, 0, 1)) - DELAY(10000); - - for (i = 0; i < MAXCPU; i++) { - if (cpuid != -1 && cpuid != i) - continue; - - for (j = 0; j < TRAP_TRACE_ENTRIES; j++) { - trap_trace_entry_t *p = &trap_trace_entry[i][j]; - - printf("0x%08jx [%02d][%04d] tpc 0x%jx type 0x%x hpstat 0x%x tl %u gl %u tt 0x%hx tag 0x%hx tstate 0x%jx f1 0x%jx f2 0x%jx f3 0x%jx f4 0x%jx\n", - p->tte_tick, i, j, p->tte_tpc,p->tte_type,p->tte_hpstat, - p->tte_tl,p->tte_gl,p->tte_tt,p->tte_tag,p->tte_tstate, - p->tte_f1,p->tte_f2,p->tte_f3,p->tte_f4); - } - } - - atomic_store_rel_int(&trace_trap_lock, 0); -} -#endif - -vm_offset_t -mp_tramp_alloc(void) -{ - char *v; - int i; - - v = OF_claim(NULL, PAGE_SIZE, PAGE_SIZE); - if (v == NULL) - panic("mp_tramp_alloc"); - bcopy(mp_tramp_code, v, mp_tramp_code_len); - - *(u_long *)(v + mp_tramp_func) = (u_long)mp_startup; - - for (i = 0; i < PAGE_SIZE; i += sizeof(long)*4 /* XXX L1 cacheline size */) - flush(v + i); - return (vm_offset_t)v; -} - -void -mp_set_tsb_desc_ra(vm_paddr_t tsb_desc_ra) -{ - *(u_long *)(mp_tramp + mp_tramp_tsb_desc_ra) = tsb_desc_ra; -} - -void -mp_add_nucleus_mapping(vm_offset_t va, tte_t tte_data) -{ - static int slot; - uint64_t *entry; - - entry = (uint64_t *)(mp_tramp + mp_tramp_code_len + slot*sizeof(*entry)*2); - *(entry) = va; - *(entry + 1) = tte_data; - *(uint64_t *)(mp_tramp + mp_tramp_tte_slots) = slot + 1; - slot++; -} - -/* - * Probe for other cpus. - */ -void -cpu_mp_setmaxid(void) -{ - phandle_t child; - phandle_t root; - char buf[128]; - int cpus; - - CPU_SETOF(PCPU_GET(cpuid), &all_cpus); - mp_ncpus = 1; - - cpus = 0; - root = OF_peer(0); - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (OF_getprop(child, "device_type", buf, sizeof(buf)) > 0 && - strcmp(buf, "cpu") == 0) - cpus++; - } - mp_maxid = cpus - 1; - -} - -int -cpu_mp_probe(void) -{ - return (mp_maxid > 0); -} - -struct cpu_group * -cpu_topo(void) -{ - - return smp_topo_none(); -} - -static int -start_ap_bycpuid(int cpuid, void *func, u_long arg) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t cpuid; - cell_t func; - cell_t arg; - cell_t result; - } args = { - (cell_t)"SUNW,start-cpu-by-cpuid", - 3, - 1, - 0, - 0, - 0, - 0 - }; - - args.cpuid = cpuid; - args.func = (cell_t)func; - args.arg = (cell_t)arg; - ofw_entry(&args); - return (int)args.result; - -} - -/* - * Fire up any non-boot processors. - */ -void -cpu_mp_start(void) -{ - volatile struct cpu_start_args *csa; - struct pcpu *pc; - phandle_t child; - phandle_t root; - vm_offset_t va; - char buf[128]; - u_int clock; - int cpuid, bp_skipped; - u_long s; - cpuset_t ocpus; - - root = OF_peer(0); - csa = &cpu_start_args; - clock = cpuid = bp_skipped = 0; - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (OF_getprop(child, "device_type", buf, sizeof(buf)) <= 0 || - strcmp(buf, "cpu") != 0) - continue; - /* skip boot processor */ - if (!bp_skipped) { - bp_skipped = 1; - continue; - } - cpuid++; - - if (OF_getprop(child, "clock-frequency", &clock, - sizeof(clock)) <= 0) - panic("cpu_mp_start: can't get clock"); - - csa->csa_state = 0; - start_ap_bycpuid(cpuid, (void *)mp_tramp, (uint64_t)cpuid); - s = intr_disable(); - while (csa->csa_state != CPU_INIT) - ; - intr_restore(s); - mp_ncpus = cpuid + 1; -#if 0 - cpu_identify(0, clock, cpuid); -#endif - va = kmem_alloc(kernel_map, PCPU_PAGES * PAGE_SIZE); - pc = (struct pcpu *)(va + (PCPU_PAGES * PAGE_SIZE)) - 1; - pcpu_init(pc, cpuid, sizeof(*pc)); - dpcpu_init((void *)kmem_alloc(kernel_map, DPCPU_SIZE), - cpuid); - pc->pc_addr = va; - - CPU_SET(cpuid, &all_cpus); - - if (mp_ncpus == MAXCPU) - break; - } - printf("%d cpus: UltraSparc T1 Processor (%d.%02d MHz CPU)\n", mp_ncpus, - (clock + 4999) / 1000000, ((clock + 4999) / 10000) % 100); - - ocpus = all_cpus; - CPU_CLR(PCPU_GET(cpuid), &ocpus); - PCPU_SET(other_cpus, ocpus); - smp_active = 1; -} - -void -cpu_mp_announce(void) -{ -} - -void -cpu_mp_unleash(void *v) -{ - volatile struct cpu_start_args *csa; - struct pcpu *pc; - u_long s; - - csa = &cpu_start_args; - csa->csa_count = mp_ncpus; - printf("mp_ncpus=%d\n", mp_ncpus); - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { - if (pc->pc_cpuid == PCPU_GET(cpuid)) - continue; - - KASSERT(pc->pc_idlethread != NULL, - ("cpu_mp_unleash: idlethread is NULL")); - pc->pc_curthread = pc->pc_idlethread; - pc->pc_curpcb = pc->pc_curthread->td_pcb; - pc->pc_curpmap = kernel_pmap; - csa->csa_state = 0; - csa->csa_pcpu = TLB_PHYS_TO_DIRECT(vtophys(pc->pc_addr)); - DELAY(300); - /* allow AP to run */ - csa->csa_cpuid = pc->pc_cpuid; - membar(Sync); - s = intr_disable(); - while (csa->csa_state != CPU_BOOTSTRAP) - ; - intr_restore(s); - } - - membar(StoreLoad); - csa->csa_count = 0; - smp_started = 1; -} - -void -cpu_mp_bootstrap(struct pcpu *pc) -{ - cpuset_t ocpus; - volatile struct cpu_start_args *csa; - - csa = &cpu_start_args; - cpu_setregs(pc); - tsb_set_scratchpad_kernel(&kernel_pmap->pm_tsb); - tte_hash_set_scratchpad_kernel(kernel_pmap->pm_hash); - trap_init(); - cpu_intrq_init(); - -#ifdef TRAP_TRACING - mp_trap_trace_init(); -#endif - - /* - * enable interrupts now that we have our trap table set - */ - intr_restore_all(PSTATE_KERNEL); - - smp_cpus++; - KASSERT(curthread != NULL, ("cpu_mp_bootstrap: curthread")); - ocpus = all_cpus; - CPU_CLR(curcpu, &ocpus); - PCPU_SET(other_cpus, ocpus); - printf("AP: #%d\n", curcpu); - csa->csa_count--; - membar(StoreLoad); - csa->csa_state = CPU_BOOTSTRAP; - - while (csa->csa_count != 0) - ; - - /* Start per-CPU event timers. */ - cpu_initclocks_ap(); - - /* ok, now enter the scheduler */ - sched_throw(NULL); -} - -void -cpu_mp_shutdown(void) -{ - cpuset_t cpus; - int i; - - critical_enter(); - shutdown_cpus = PCPU_GET(other_cpus); - cpus = shutdown_cpus; - - /* XXX: Stop all the CPUs which aren't already. */ - if (CPU_CMP(&stopped_cpus, &cpus)) { - - /* pc_other_cpus is just a flat "on" mask without curcpu. */ - CPU_NAND(&cpus, &stopped_cpus); - stop_cpus(cpus); - } - i = 0; - while (!CPU_EMPTY(&shutdown_cpus)) { - if (i++ > 100000) { - printf("timeout shutting down CPUs.\n"); - break; - } - } - /* XXX: delay a bit to allow the CPUs to actually enter the PROM. */ - DELAY(100000); - critical_exit(); -} - -void -cpu_ipi_ast(struct trapframe *tf) -{ -} - -void -cpu_ipi_stop(struct trapframe *tf) -{ - - savectx(&stoppcbs[curcpu]); - atomic_set_acq_int(&stopped_cpus, PCPU_GET(cpumask)); - while ((started_cpus & PCPU_GET(cpumask)) == 0) { - if ((shutdown_cpus & PCPU_GET(cpumask)) != 0) { - atomic_clear_int(&shutdown_cpus, PCPU_GET(cpumask)); - } - } - atomic_clear_rel_int(&started_cpus, PCPU_GET(cpumask)); - atomic_clear_rel_int(&stopped_cpus, PCPU_GET(cpumask)); - CTR1(KTR_SMP, "cpu_ipi_stop: restarted %d", curcpu); -} - -void -cpu_ipi_preempt(struct trapframe *tf) -{ - sched_preempt(curthread); -} - -void -cpu_ipi_hardclock(struct trapframe *tf) -{ - struct trapframe *oldframe; - struct thread *td; - - critical_enter(); - td = curthread; - td->td_intr_nesting_level++; - oldframe = td->td_intr_frame; - td->td_intr_frame = tf; - hardclockintr(); - td->td_intr_frame = oldframe; - td->td_intr_nesting_level--; - critical_exit(); -} - -void -cpu_ipi_selected(int cpu_count, uint16_t *cpulist, u_long d0, u_long d1, u_long d2, uint64_t *ackmask) -{ - - int i, retries; - - init_mondo(d0, d1, d2, (uint64_t)pmap_kextract((vm_offset_t)ackmask)); - - retries = 0; - -retry: - if (cpu_count) { - int error, new_cpu_count; - vm_paddr_t cpulist_ra; - - cpulist_ra = TLB_DIRECT_TO_PHYS((vm_offset_t)cpulist); - if ((error = hv_cpu_mondo_send(cpu_count, cpulist_ra)) == H_EWOULDBLOCK) { - new_cpu_count = 0; - for (i = 0; i < cpu_count; i++) { - if (cpulist[i] != 0xffff) - cpulist[new_cpu_count++] = cpulist[i]; - } - cpu_count = new_cpu_count; - retries++; - if (cpu_count == 0) { - printf("no more cpus to send to but mondo_send returned EWOULDBLOCK\n"); - return; - } - if ((retries & 0x1) == 0x1) - DELAY(10); - - if (retries < 50000) - goto retry; - else { - printf("used up retries - cpus remaining: %d - cpus: ", - cpu_count); - for (i = 0; i < cpu_count; i++) - printf("#%d ", cpulist[i]); - printf("\n"); - } - } - if (error == H_ENOCPU) { - printf("bad cpuid: "); - for (i = 0; i < cpu_count; i++) - printf("#%d ", cpulist[i]); - printf("\n"); - } - if (error) - panic("can't handle error %d from cpu_mondo_send\n", error); - } -} - -void -ipi_selected(cpuset_t icpus, u_int ipi) -{ - int cpu_count, cpu; - uint16_t *cpulist; - uint64_t ackmask; - - KASSERT(!CPU_ISSET(PCPU_GET(cpuid), &icpus), - ("Invalid passed CPU mask")); - - /* - * - * 3) forward_wakeup appears to abuse ASTs - * 4) handling 4-way threading vs 2-way threading should happen here - * and not in forward wakeup - */ - cpulist = PCPU_GET(cpulist); - - for (cpu_count = 0; (cpu = cpusetobj_ffs(&cpus)) != 0 && cpu < MAXCPU; - CPU_CLR(cpu, &cpus)) { - cpulist[cpu_count] = (uint16_t)cpu; - cpu_count++; - - } - - cpu_ipi_selected(cpu_count, cpulist, (u_long)tl_ipi_level, ipi, 0, - &ackmask); -} - -void -ipi_cpu(int cpu, u_int ipi) -{ - int cpu_count; - uint16_t *cpulist; - uint64_t ackmask; - - /* - * - * 3) forward_wakeup appears to abuse ASTs - * 4) handling 4-way threading vs 2-way threading should happen here - * and not in forward wakeup - */ - cpulist = PCPU_GET(cpulist); - if (PCPU_GET(cpumask) & (1 << cpu)) - cpu_count = 0; - else { - cpulist[0] = (uint16_t)cpu; - cpu_count = 1; - } - cpu_ipi_selected(cpu_count, cpulist, (u_long)tl_ipi_level, ipi, 0, - &ackmask); -} - -void -ipi_all_but_self(u_int ipi) -{ - ipi_selected(PCPU_GET(other_cpus), ipi); -} diff --git a/sys/sun4v/sun4v/nexus.c b/sys/sun4v/sun4v/nexus.c deleted file mode 100644 index 125b2f712422..000000000000 --- a/sys/sun4v/sun4v/nexus.c +++ /dev/null @@ -1,626 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * Copyright 2001 by Thomas Moestl . - * Copyright 2006 by Marius Strobl . - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. 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: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -/* - * The nexus (which is a pseudo-bus actually) iterates over the nodes that - * hang from the Open Firmware root node and adds them as devices to this bus - * (except some special nodes which are excluded) so that drivers can be - * attached to them. - * - * Additionally, interrupt setup/teardown and some resource management are - * done at this level. - * - * Maybe this code should get into dev/ofw to some extent, as some of it should - * work for all Open Firmware based machines... - */ - -struct nexus_devinfo { - struct ofw_bus_devinfo ndi_obdinfo; - struct resource_list ndi_rl; - struct rman ndi_intr_rman; - - devhandle_t ndi_devhandle; -}; - -struct nexus_softc { - struct rman sc_mem_rman; -}; - -static device_probe_t nexus_probe; -static device_attach_t nexus_attach; -static bus_print_child_t nexus_print_child; -static bus_add_child_t nexus_add_child; -static bus_probe_nomatch_t nexus_probe_nomatch; -static bus_read_ivar_t nexus_read_ivar; -static bus_setup_intr_t nexus_setup_intr; -static bus_teardown_intr_t nexus_teardown_intr; -static bus_alloc_resource_t nexus_alloc_resource; -static bus_get_resource_list_t nexus_get_resource_list; -static bus_activate_resource_t nexus_activate_resource; -static bus_deactivate_resource_t nexus_deactivate_resource; -static bus_release_resource_t nexus_release_resource; -static ofw_bus_get_devinfo_t nexus_get_devinfo; - -static int nexus_inlist(const char *, const char **); -static struct nexus_devinfo * nexus_setup_dinfo(device_t, phandle_t); -static void nexus_destroy_dinfo(struct nexus_devinfo *); -static int nexus_print_res(struct nexus_devinfo *); - -static device_method_t nexus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, nexus_probe), - DEVMETHOD(device_attach, nexus_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, nexus_print_child), - DEVMETHOD(bus_probe_nomatch, nexus_probe_nomatch), - DEVMETHOD(bus_read_ivar, nexus_read_ivar), - DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), - DEVMETHOD(bus_add_child, nexus_add_child), - DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), - DEVMETHOD(bus_activate_resource, nexus_activate_resource), - DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), - DEVMETHOD(bus_release_resource, nexus_release_resource), - DEVMETHOD(bus_setup_intr, nexus_setup_intr), - DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, nexus_get_resource_list), - - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, nexus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - - { 0, 0 } -}; - -static devclass_t nexus_devclass; - -DEFINE_CLASS_0(nexus, nexus_driver, nexus_methods, sizeof(struct nexus_softc)); -DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0); - -static const char *nexus_excl_name[] = { - "aliases", - "associations", - "chosen", - "counter-timer", /* No separate device; handled by psycho/sbus */ - "memory", - "openprom", - "options", - "packages", - "rsc", - "virtual-memory", - NULL -}; - -static const char *nexus_excl_type[] = { - "cpu", - NULL -}; - -extern struct bus_space_tag nexus_bustag; - -#define SUN4V_REG_SPEC2CFG_HDL(x) ((x >> 32) & ~(0xfull << 28)) - -static int -nexus_inlist(const char *name, const char **list) -{ - int i; - - if (name == NULL) - return (0); - for (i = 0; list[i] != NULL; i++) - if (strcmp(name, list[i]) == 0) - return (1); - return (0); -} - -#define NEXUS_EXCLUDED(name, type) \ - (nexus_inlist((name), nexus_excl_name) || \ - ((type) != NULL && nexus_inlist((type), nexus_excl_type))) - -static int -nexus_probe(device_t dev) -{ - - /* Nexus does always match. */ - device_set_desc(dev, "Open Firmware Nexus device"); - return (0); -} - -static int -nexus_attach(device_t dev) -{ - struct nexus_devinfo *ndi; - struct nexus_softc *sc; - device_t cdev; - phandle_t node; - - node = OF_peer(0); - if (node == -1) - panic("%s: OF_peer failed.", __func__); - - sc = device_get_softc(dev); - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "Device Memory"; - if (rman_init(&sc->sc_mem_rman) != 0 || - rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) - panic("%s: failed to set up rmans.", __func__); - - /* - * Allow devices to identify. - */ - bus_generic_probe(dev); - - /* - * Now walk the OFW tree and attach top-level devices. - */ - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - if ((ndi = nexus_setup_dinfo(dev, node)) == NULL) - continue; - cdev = device_add_child(dev, NULL, -1); - if (cdev == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - ndi->ndi_obdinfo.obd_name); - nexus_destroy_dinfo(ndi); - continue; - } - device_set_ivars(cdev, ndi); - } - return (bus_generic_attach(dev)); -} - -static device_t -nexus_add_child(device_t dev, u_int order, const char *name, int unit) -{ - device_t cdev; - struct nexus_devinfo *ndi; - - cdev = device_add_child_ordered(dev, order, name, unit); - if (cdev == NULL) - return (NULL); - - ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); - ndi->ndi_obdinfo.obd_node = -1; - ndi->ndi_obdinfo.obd_name = strdup(name, M_OFWPROP); - resource_list_init(&ndi->ndi_rl); - ndi->ndi_intr_rman.rm_type = RMAN_ARRAY; - ndi->ndi_intr_rman.rm_descr = "Interrupts"; - if (rman_init(&ndi->ndi_intr_rman) != 0 || - rman_manage_region(&ndi->ndi_intr_rman, 0, IV_MAX - 1) != 0) - panic("%s: failed to set up rmans.", __func__); - - device_set_ivars(cdev, ndi); - - return (cdev); -} - -static int -nexus_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += nexus_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -nexus_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - nexus_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static int -nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct nexus_devinfo *ndi; - - ndi = device_get_ivars(child); - - switch (which) { - case NEXUS_IVAR_DEVHANDLE: - *(uint64_t *)result = ndi->ndi_devhandle; - break; - - default: - return (ENOENT); - } - - return (0); -} - -#ifdef SUN4V - -static int -nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, - driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) -{ - struct nexus_devinfo *ndi; - device_t ichild; - uint64_t ihdl; - uint64_t ino; - int error, cpuid; - - /* we need the devinfo from the immediate child */ - ichild = child; - while (device_get_parent(ichild) != dev) - ichild = device_get_parent(ichild); - - ndi = device_get_ivars(ichild); - - if (res == NULL) - panic("%s: NULL interrupt resource!", __func__); -#ifdef DEBUG - printf("dev=%s child=%s\n", ofw_bus_get_name(dev), ofw_bus_get_name(child)); -#endif - ino = rman_get_start(res); -#ifdef DEBUG - printf("child=%s reg=0x%lx ino=0x%lx\n", ofw_bus_get_name(child), - ndi->ndi_devhandle, ino); -#endif - - if (hv_intr_devino_to_sysino(ndi->ndi_devhandle, (uint32_t)ino, - &ihdl) != H_EOK) { - error = ENXIO; - goto fail; - } - - if ((rman_get_flags(res) & RF_SHAREABLE) == 0) - flags |= INTR_EXCL; - - /* We depend here on rman_activate_resource() being idempotent. */ - if ((error = rman_activate_resource(res))) - goto fail; - - error = inthand_add(device_get_nameunit(child), ihdl, - filt, intr, arg, flags, cookiep); - - cpuid = 0; - if (hv_intr_settarget(ihdl, cpuid) != H_EOK) { - error = ENXIO; - goto fail; - } - if (hv_intr_setstate(ihdl, HV_INTR_IDLE_STATE) != H_EOK) { - error = ENXIO; - goto fail; - } - if (hv_intr_setenabled(ihdl, HV_INTR_ENABLED) != H_EOK) { - error = ENXIO; - goto fail; - } - - -fail: - - return (error); -} - -static int -nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih) -{ - - inthand_remove(rman_get_start(r), ih); - return (0); -} - -#else - -static int -nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, - driver_intr_t *intr, void *arg, void **cookiep) -{ - int error; - - if (res == NULL) - panic("%s: NULL interrupt resource!", __func__); - - if ((rman_get_flags(res) & RF_SHAREABLE) == 0) - flags |= INTR_EXCL; - - /* We depend here on rman_activate_resource() being idempotent. */ - error = rman_activate_resource(res); - if (error) - return (error); - - error = inthand_add(device_get_nameunit(child), rman_get_start(res), - intr, arg, flags, cookiep); - - return (error); -} - -static int -nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih) -{ - - inthand_remove(rman_get_start(r), ih); - return (0); -} - -#endif - -static struct resource * -nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct nexus_softc *sc; - struct rman *rm; - struct resource *rv; - struct resource_list_entry *rle; - struct nexus_devinfo *ndi; - device_t subord; - int isdefault, needactivate, passthrough; - - isdefault = (start == 0UL && end == ~0UL); - needactivate = flags & RF_ACTIVE; - passthrough = (device_get_parent(child) != bus); - sc = device_get_softc(bus); - rle = NULL; - - if (!passthrough) { - rle = resource_list_find(BUS_GET_RESOURCE_LIST(bus, child), - type, *rid); - if (rle == NULL) - return (NULL); - if (rle->res != NULL) - panic("%s: resource entry is busy", __func__); - if (isdefault) { - start = rle->start; - count = ulmax(count, rle->count); - end = ulmax(rle->end, start + count - 1); - } - } - - switch (type) { - case SYS_RES_IRQ: - /* find the immediate subordinate */ - subord = child; - while (device_get_parent(subord) != bus) - subord = device_get_parent(subord); - ndi = device_get_ivars(subord); - rm = &ndi->ndi_intr_rman; - break; - case SYS_RES_MEMORY: - rm = &sc->sc_mem_rman; - break; - default: - return (NULL); - } - - flags &= ~RF_ACTIVE; - rv = rman_reserve_resource(rm, start, end, count, flags, child); - if (type == SYS_RES_IRQ && rv == NULL) { - printf("%s: start: %ld, end: %ld, flags: %#x\n", __func__, - start, end, flags); - } - if (rv == NULL) - return (NULL); - if (type == SYS_RES_MEMORY) { - rman_set_bustag(rv, &nexus_bustag); - rman_set_bushandle(rv, rman_get_start(rv)); - } - - if (needactivate) { - if (bus_activate_resource(child, type, *rid, rv) != 0) { - rman_release_resource(rv); - return (NULL); - } - } - - if (!passthrough) - rle->res = rv; - - return (rv); -} - -static int -nexus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - - /* Not much to be done yet... */ - return (rman_activate_resource(r)); -} - -static int -nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - - /* Not much to be done yet... */ - return (rman_deactivate_resource(r)); -} - -static int -nexus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *r) -{ - int error; - - if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - return (rman_release_resource(r)); -} - -static struct resource_list * -nexus_get_resource_list(device_t dev, device_t child) -{ - struct nexus_devinfo *ndi; - - ndi = device_get_ivars(child); - return (&ndi->ndi_rl); -} - -static const struct ofw_bus_devinfo * -nexus_get_devinfo(device_t dev, device_t child) -{ - struct nexus_devinfo *ndi; - - ndi = device_get_ivars(child); - return (&ndi->ndi_obdinfo); -} - -static struct nexus_devinfo * -nexus_setup_dinfo(device_t dev, phandle_t node) -{ - struct nexus_devinfo *ndi; - struct nexus_regs *reg; - bus_addr_t phys; - uint32_t naddrcell, nintrcell; - uint32_t *intr; - int i, rid; - int nintr; - int nreg; - - ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&ndi->ndi_obdinfo, node) != 0) { - free(ndi, M_DEVBUF); - return (NULL); - } - if (NEXUS_EXCLUDED(ndi->ndi_obdinfo.obd_name, - ndi->ndi_obdinfo.obd_type)) { - ofw_bus_gen_destroy_devinfo(&ndi->ndi_obdinfo); - free(ndi, M_DEVBUF); - return (NULL); - } - resource_list_init(&ndi->ndi_rl); - nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®); - if (nreg != 1) { - device_printf(dev, "<%s>: incomplete: %d\n", - ndi->ndi_obdinfo.obd_name, nreg); - nexus_destroy_dinfo(ndi); - return (NULL); - } - phys = NEXUS_REG_PHYS(®[0]); - ndi->ndi_devhandle = SUN4V_REG_SPEC2CFG_HDL(phys); - free(reg, M_OFWPROP); - - if (OF_getprop(node, "#address-cells", &naddrcell, - sizeof naddrcell) != sizeof naddrcell || OF_getprop(node, - "#interrupt-cells", &nintrcell, sizeof nintrcell) != - sizeof nintrcell || nintrcell != 1) - panic("can't get cell sizes"); /* or invalid intr cell size */ - - nintr = OF_getprop_alloc(node, "interrupt-map", sizeof(*intr), - (void **)&intr); - for (i = 0; i < nintr; rid++, i += naddrcell + nintrcell + 2) { - /* - * interrupt-map is: - * addr,intr,phandle,parent's intr - */ - rid = intr[i + naddrcell]; - /* XXX - technically, we need to pull the parent's - * #interrupt-cells, but we'll assume it's 1 like we enforce - * nintercell to be above. - */ - resource_list_add(&ndi->ndi_rl, SYS_RES_IRQ, rid, - intr[i + naddrcell + nintrcell + 1], - intr[i + naddrcell + nintrcell + 1], 1); - } - free(intr, M_OFWPROP); - - ndi->ndi_intr_rman.rm_type = RMAN_ARRAY; - ndi->ndi_intr_rman.rm_descr = "Interrupts"; - if (rman_init(&ndi->ndi_intr_rman) != 0 || - rman_manage_region(&ndi->ndi_intr_rman, 0, IV_MAX - 1) != 0) - panic("%s: failed to set up rmans.", __func__); - - return (ndi); -} - -static void -nexus_destroy_dinfo(struct nexus_devinfo *ndi) -{ - - resource_list_free(&ndi->ndi_rl); - ofw_bus_gen_destroy_devinfo(&ndi->ndi_obdinfo); - free(ndi, M_DEVBUF); -} - -static int -nexus_print_res(struct nexus_devinfo *ndi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&ndi->ndi_rl, "mem", SYS_RES_MEMORY, - "%#lx"); - rv += resource_list_print_type(&ndi->ndi_rl, "irq", SYS_RES_IRQ, - "%ld"); - return (rv); -} - - diff --git a/sys/sun4v/sun4v/pmap.c b/sys/sun4v/sun4v/pmap.c deleted file mode 100644 index 502da80e9ab2..000000000000 --- a/sys/sun4v/sun4v/pmap.c +++ /dev/null @@ -1,2388 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include "opt_kstack_pages.h" -#include "opt_pmap.h" -#include "opt_trap_trace.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef TRAP_TRACING -void trap_trace_report(int); -#endif - -#if 1 -#define PMAP_DEBUG -#endif -#ifndef PMAP_SHPGPERPROC -#define PMAP_SHPGPERPROC 200 -#endif - -/* - * Virtual and physical address of message buffer. - */ -struct msgbuf *msgbufp; -vm_paddr_t msgbuf_phys; - -/* - * Map of physical memory reagions. - */ -vm_paddr_t phys_avail[128]; -vm_paddr_t phys_avail_tmp[128]; -static struct ofw_mem_region mra[128]; -static struct ofw_map translations[128]; -static int translations_size; - - -struct ofw_mem_region sparc64_memreg[128]; -int sparc64_nmemreg; - -extern vm_paddr_t mmu_fault_status_area; - -/* - * First and last available kernel virtual addresses. - */ -vm_offset_t virtual_avail; -vm_offset_t virtual_end; -vm_offset_t kernel_vm_end; -vm_offset_t vm_max_kernel_address; - -#ifndef PMAP_SHPGPERPROC -#define PMAP_SHPGPERPROC 200 -#endif -/* - * Data for the pv entry allocation mechanism - */ -static uma_zone_t pvzone; -static struct vm_object pvzone_obj; -static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0; -int pmap_debug = 0; -static int pmap_debug_range = 1; -static int use_256M_pages = 1; - -static struct mtx pmap_ctx_lock; -static uint16_t ctx_stack[PMAP_CONTEXT_MAX]; -static int ctx_stack_top; - -static int permanent_mappings = 0; -static uint64_t nucleus_memory; -static uint64_t nucleus_mappings[4]; -/* - * Kernel pmap. - */ -struct pmap kernel_pmap_store; - -hv_tsb_info_t kernel_td[MAX_TSB_INFO]; - -/* - * This should be determined at boot time - * with tiny TLBS it doesn't make sense to try and selectively - * invalidate more than this - */ -#define MAX_INVALIDATES 32 -#define MAX_TSB_CLEARS 128 - -/* - * Allocate physical memory for use in pmap_bootstrap. - */ -static vm_paddr_t pmap_bootstrap_alloc(vm_size_t size); - -/* - * If user pmap is processed with pmap_remove and with pmap_remove and the - * resident count drops to 0, there are no more pages to remove, so we - * need not continue. - */ -#define PMAP_REMOVE_DONE(pm) \ - ((pm) != kernel_pmap && (pm)->pm_stats.resident_count == 0) - -/* - * Kernel MMU interface - */ -#define curthread_pmap vmspace_pmap(curthread->td_proc->p_vmspace) - -#ifdef PMAP_DEBUG -#define KDPRINTF if (pmap_debug) printf -#define DPRINTF \ - if (curthread_pmap && (curthread_pmap->pm_context != 0) && ((PCPU_GET(cpumask) & curthread_pmap->pm_active) == 0)) \ - panic("cpumask(0x%x) & active (0x%x) == 0 pid == %d\n", \ - PCPU_GET(cpumask), curthread_pmap->pm_active, curthread->td_proc->p_pid); \ -if (pmap_debug) printf - - -#else -#define DPRINTF(...) -#define KDPRINTF(...) -#endif - - -static void free_pv_entry(pv_entry_t pv); -static pv_entry_t get_pv_entry(pmap_t locked_pmap); -static void pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va); -static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, - vm_offset_t va); - -static void pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t m); -static void pmap_remove_entry(struct pmap *pmap, vm_page_t m, vm_offset_t va); -static void pmap_remove_tte(pmap_t pmap, tte_t tte_data, vm_offset_t va); -static void pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot); -static void pmap_tsb_reset(pmap_t pmap); -static void pmap_tsb_resize(pmap_t pmap); -static void pmap_tte_hash_resize(pmap_t pmap); - -void pmap_set_ctx_panic(uint64_t error, vm_paddr_t tsb_ra, pmap_t pmap); - -struct tsb_resize_info { - uint64_t tri_tsbscratch; - uint64_t tri_tsb_ra; -}; - -/* - * Quick sort callout for comparing memory regions. - */ -static int mr_cmp(const void *a, const void *b); -static int om_cmp(const void *a, const void *b); -static int -mr_cmp(const void *a, const void *b) -{ - const struct ofw_mem_region *mra; - const struct ofw_mem_region *mrb; - - mra = a; - mrb = b; - if (mra->mr_start < mrb->mr_start) - return (-1); - else if (mra->mr_start > mrb->mr_start) - return (1); - else - return (0); -} -static int -om_cmp(const void *a, const void *b) -{ - const struct ofw_map *oma; - const struct ofw_map *omb; - - oma = a; - omb = b; - if (oma->om_start < omb->om_start) - return (-1); - else if (oma->om_start > omb->om_start) - return (1); - else - return (0); -} - -static __inline void -free_context(uint16_t ctx) -{ - mtx_lock_spin(&pmap_ctx_lock); - ctx_stack[ctx_stack_top++] = ctx; - mtx_unlock_spin(&pmap_ctx_lock); - - KASSERT(ctx_stack_top < PMAP_CONTEXT_MAX, - ("context stack overrun - system error")); -} - -static __inline uint16_t -get_context(void) -{ - uint16_t ctx; - - mtx_lock_spin(&pmap_ctx_lock); - ctx = ctx_stack[--ctx_stack_top]; - mtx_unlock_spin(&pmap_ctx_lock); - - KASSERT(ctx_stack_top > 0, - ("context stack underrun - need to implement context stealing")); - - return ctx; -} - -static __inline void -free_pv_entry(pv_entry_t pv) -{ - pv_entry_count--; - uma_zfree(pvzone, pv); -} - -/* - * get a new pv_entry, allocating a block from the system - * when needed. - */ -static pv_entry_t -get_pv_entry(pmap_t locked_pmap) -{ - static const struct timeval printinterval = { 60, 0 }; - static struct timeval lastprint; - struct vpgqueues *vpq; - uint64_t tte_data; - pmap_t pmap; - pv_entry_t allocated_pv, next_pv, pv; - vm_offset_t va; - vm_page_t m; - - PMAP_LOCK_ASSERT(locked_pmap, MA_OWNED); - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - allocated_pv = uma_zalloc(pvzone, M_NOWAIT); - if (allocated_pv != NULL) { - pv_entry_count++; - if (pv_entry_count > pv_entry_high_water) - pagedaemon_wakeup(); - else - return (allocated_pv); - } - - /* - * Reclaim pv entries: At first, destroy mappings to inactive - * pages. After that, if a pv entry is still needed, destroy - * mappings to active pages. - */ - if (ratecheck(&lastprint, &printinterval)) - printf("Approaching the limit on PV entries, " - "increase the vm.pmap.shpgperproc tunable.\n"); - - vpq = &vm_page_queues[PQ_INACTIVE]; -retry: - TAILQ_FOREACH(m, &vpq->pl, pageq) { - if (m->hold_count || m->busy) - continue; - TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) { - va = pv->pv_va; - pmap = pv->pv_pmap; - /* Avoid deadlock and lock recursion. */ - if (pmap > locked_pmap) - PMAP_LOCK(pmap); - else if (pmap != locked_pmap && !PMAP_TRYLOCK(pmap)) - continue; - pmap->pm_stats.resident_count--; - - tte_data = tte_hash_delete(pmap->pm_hash, va); - - KASSERT((tte_data & VTD_WIRED) == 0, - ("get_pv_entry: wired pte %#jx", (uintmax_t)tte_data)); - if (tte_data & VTD_REF) - vm_page_flag_set(m, PG_REFERENCED); - if (tte_data & VTD_W) { - KASSERT((tte_data & VTD_SW_W), - ("get_pv_entry: modified page not writable: va: %lx, tte: %lx", - va, tte_data)); - vm_page_dirty(m); - } - - pmap_invalidate_page(pmap, va, TRUE); - TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); - TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - m->md.pv_list_count--; - - if (pmap != locked_pmap) - PMAP_UNLOCK(pmap); - if (allocated_pv == NULL) - allocated_pv = pv; - else - free_pv_entry(pv); - } - if (TAILQ_EMPTY(&m->md.pv_list)) - vm_page_flag_clear(m, PG_WRITEABLE); - } - if (allocated_pv == NULL) { - if (vpq == &vm_page_queues[PQ_INACTIVE]) { - vpq = &vm_page_queues[PQ_ACTIVE]; - goto retry; - } - panic("get_pv_entry: increase the vm.pmap.shpgperproc tunable"); - } - return (allocated_pv); -} - -/* - * Allocate a physical page of memory directly from the phys_avail map. - * Can only be called from pmap_bootstrap before avail start and end are - * calculated. - */ -static vm_paddr_t -pmap_bootstrap_alloc(vm_size_t size) -{ - vm_paddr_t pa; - int i; - - size = round_page(size); - - for (i = 0; phys_avail[i + 1] != 0; i += 2) { - if (phys_avail[i + 1] - phys_avail[i] < size) - continue; - pa = phys_avail[i]; - phys_avail[i] += size; - pmap_scrub_pages(pa, size); - return (pa); - } - panic("pmap_bootstrap_alloc"); -} - -/* - * Activate a user pmap. The pmap must be activated before its address space - * can be accessed in any way. - */ -void -pmap_activate(struct thread *td) -{ - pmap_t pmap, oldpmap; - int err; - - critical_enter(); - pmap = vmspace_pmap(td->td_proc->p_vmspace); - oldpmap = PCPU_GET(curpmap); -#if defined(SMP) - atomic_clear_int(&oldpmap->pm_active, PCPU_GET(cpumask)); - atomic_set_int(&pmap->pm_tlbactive, PCPU_GET(cpumask)); - atomic_set_int(&pmap->pm_active, PCPU_GET(cpumask)); -#else - oldpmap->pm_active &= ~1; - pmap->pm_active |= 1; - pmap->pm_tlbactive |= 1; -#endif - - pmap->pm_hashscratch = tte_hash_set_scratchpad_user(pmap->pm_hash, pmap->pm_context); - pmap->pm_tsbscratch = tsb_set_scratchpad_user(&pmap->pm_tsb); - pmap->pm_tsb_miss_count = pmap->pm_tsb_cap_miss_count = 0; - - PCPU_SET(curpmap, pmap); - if (pmap->pm_context != 0) - if ((err = hv_mmu_tsb_ctxnon0(1, pmap->pm_tsb_ra)) != H_EOK) - panic("failed to set TSB 0x%lx - context == %ld\n", - pmap->pm_tsb_ra, pmap->pm_context); - stxa(MMU_CID_S, ASI_MMU_CONTEXTID, pmap->pm_context); - membar(Sync); - critical_exit(); -} - -void -pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz) -{ -} - -/* - * Increase the starting virtual address of the given mapping if a - * different alignment might result in more superpage mappings. - */ -void -pmap_align_superpage(vm_object_t object, vm_ooffset_t offset, - vm_offset_t *addr, vm_size_t size) -{ -} - -/* - * Bootstrap the system enough to run with virtual memory. - */ -void -pmap_bootstrap(vm_offset_t ekva) -{ - struct pmap *pm; - vm_offset_t off, va; - vm_paddr_t pa, tsb_8k_pa, tsb_4m_pa, kernel_hash_pa, nucleus_memory_start; - vm_size_t physsz, virtsz, kernel_hash_shift; - ihandle_t pmem, vmem; - int i, j, k, sz; - uint64_t tsb_8k_size, tsb_4m_size, error, physmem_tunable, physmemstart_tunable; - vm_paddr_t real_phys_avail[128], tmp_phys_avail[128], bounds; - - - if ((vmem = OF_finddevice("/virtual-memory")) == -1) - panic("pmap_bootstrap: finddevice /virtual-memory"); - if ((sz = OF_getproplen(vmem, "translations")) == -1) - panic("pmap_bootstrap: getproplen translations"); - if (sizeof(translations) < sz) - panic("pmap_bootstrap: translations too small"); - bzero(translations, sz); - if (OF_getprop(vmem, "translations", translations, sz) == -1) - panic("pmap_bootstrap: getprop /virtual-memory/translations"); - sz /= sizeof(*translations); - translations_size = sz; - nucleus_memory_start = 0; - CTR0(KTR_PMAP, "pmap_bootstrap: translations"); - qsort(translations, sz, sizeof (*translations), om_cmp); - - for (i = 0; i < sz; i++) { - KDPRINTF("om_size=%ld om_start=%lx om_tte=%lx\n", - translations[i].om_size, translations[i].om_start, - translations[i].om_tte); - if ((translations[i].om_start >= KERNBASE) && - (translations[i].om_start <= KERNBASE + 3*PAGE_SIZE_4M)) { - for (j = 0; j < translations[i].om_size; j += PAGE_SIZE_4M) { - KDPRINTF("mapping permanent translation\n"); - pa = TTE_GET_PA(translations[i].om_tte) + j; - va = translations[i].om_start + j; - error = hv_mmu_map_perm_addr(va, KCONTEXT, - pa | TTE_KERNEL | VTD_4M, MAP_ITLB | MAP_DTLB); - if (error != H_EOK) - panic("map_perm_addr returned error=%ld", error); - - if ((nucleus_memory_start == 0) || (pa < nucleus_memory_start)) - nucleus_memory_start = pa; - printf("nucleus_mappings[%d] = 0x%lx\n", permanent_mappings, pa); - nucleus_mappings[permanent_mappings++] = pa; - nucleus_memory += PAGE_SIZE_4M; -#ifdef SMP - mp_add_nucleus_mapping(va, pa|TTE_KERNEL|VTD_4M); -#endif - } - } - } - - /* - * Find out what physical memory is available from the prom and - * initialize the phys_avail array. This must be done before - * pmap_bootstrap_alloc is called. - */ - if ((pmem = OF_finddevice("/memory")) == -1) - panic("pmap_bootstrap: finddevice /memory"); - if ((sz = OF_getproplen(pmem, "available")) == -1) - panic("pmap_bootstrap: getproplen /memory/available"); - if (sizeof(vm_paddr_t)*128 < sz) /* FIXME */ - panic("pmap_bootstrap: phys_avail too small"); - if (sizeof(mra) < sz) - panic("pmap_bootstrap: mra too small"); - bzero(mra, sz); - if (OF_getprop(pmem, "available", mra, sz) == -1) - panic("pmap_bootstrap: getprop /memory/available"); - - sz /= sizeof(*mra); - CTR0(KTR_PMAP, "pmap_bootstrap: physical memory"); - - qsort(mra, sz, sizeof (*mra), mr_cmp); - physmemstart_tunable = physmem_tunable = physmem = physsz = 0; - - if (TUNABLE_ULONG_FETCH("hw.physmemstart", &physmemstart_tunable)) { - KDPRINTF("desired physmemstart=0x%lx\n", physmemstart_tunable); - } - if (TUNABLE_ULONG_FETCH("hw.physmem", &physmem_tunable)) { - physmem = atop(physmem_tunable); - KDPRINTF("desired physmem=0x%lx\n", physmem_tunable); - } - if ((physmem_tunable != 0) && (physmemstart_tunable != 0)) - physmem_tunable += physmemstart_tunable; - - bzero(real_phys_avail, sizeof(real_phys_avail)); - bzero(tmp_phys_avail, sizeof(tmp_phys_avail)); - - for (i = 0, j = 0; i < sz; i++) { - uint64_t size; - KDPRINTF("start=%#lx size=%#lx\n", mra[i].mr_start, mra[i].mr_size); - if (mra[i].mr_size < PAGE_SIZE_4M) - continue; - - if ((mra[i].mr_start & PAGE_MASK_4M) || (mra[i].mr_size & PAGE_MASK_4M)) { - uint64_t newstart, roundup; - newstart = ((mra[i].mr_start + (PAGE_MASK_4M)) & ~PAGE_MASK_4M); - roundup = newstart - mra[i].mr_start; - size = (mra[i].mr_size - roundup) & ~PAGE_MASK_4M; - mra[i].mr_start = newstart; - if (size < PAGE_SIZE_4M) - continue; - mra[i].mr_size = size; - } - real_phys_avail[j] = mra[i].mr_start; - if (physmem_tunable != 0 && ((physsz + mra[i].mr_size) >= physmem_tunable)) { - mra[i].mr_size = physmem_tunable - physsz; - physsz = physmem_tunable; - real_phys_avail[j + 1] = mra[i].mr_start + mra[i].mr_size; - break; - } - physsz += mra[i].mr_size; - real_phys_avail[j + 1] = mra[i].mr_start + mra[i].mr_size; - j += 2; - } - physmem = btoc(physsz - physmemstart_tunable); - - /* - * This is needed for versions of OFW that would allocate us memory - * and then forget to remove it from the available ranges ... - * as well as for compensating for the above move of nucleus pages - */ - for (i = 0, j = 0, bounds = (1UL<<32); real_phys_avail[i] != 0; i += 2) { - vm_paddr_t start = real_phys_avail[i]; - uint64_t end = real_phys_avail[i + 1]; - CTR2(KTR_PMAP, "start=%#lx size=%#lx\n", start, end); - KDPRINTF("real_phys start=%#lx end=%#lx\n", start, end); - /* - * Is kernel memory at the beginning of range? - */ - if (nucleus_memory_start == start) { - start += nucleus_memory; - } - /* - * Is kernel memory at the end of range? - */ - if (nucleus_memory_start == (end - nucleus_memory)) - end -= nucleus_memory; - - if (physmemstart_tunable != 0 && - (end < physmemstart_tunable)) - continue; - - if (physmemstart_tunable != 0 && - ((start < physmemstart_tunable))) { - start = physmemstart_tunable; - } - - /* - * Is kernel memory in the middle somewhere? - */ - if ((nucleus_memory_start > start) && - (nucleus_memory_start < end)) { - phys_avail[j] = start; - phys_avail[j+1] = nucleus_memory_start; - start = nucleus_memory_start + nucleus_memory; - j += 2; - } - /* - * Break phys_avail up on 4GB boundaries to try - * to work around PCI-e allocation bug - * we rely on the fact that kernel memory is allocated - * from the first 4GB of physical memory - */ - while (bounds < start) - bounds += (1UL<<32); - - while (bounds < end) { - phys_avail[j] = start; - phys_avail[j + 1] = bounds; - start = bounds; - bounds += (1UL<<32); - j += 2; - } - phys_avail[j] = start; - phys_avail[j + 1] = end; - j += 2; - } - - /* - * Merge nucleus memory in to real_phys_avail - * - */ - for (i = 0; real_phys_avail[i] != 0; i += 2) { - if (real_phys_avail[i] == nucleus_memory_start + nucleus_memory) - real_phys_avail[i] -= nucleus_memory; - - if (real_phys_avail[i + 1] == nucleus_memory_start) - real_phys_avail[i + 1] += nucleus_memory; - - if (real_phys_avail[i + 1] == real_phys_avail[i + 2]) { - real_phys_avail[i + 1] = real_phys_avail[i + 3]; - for (k = i + 2; real_phys_avail[k] != 0; k += 2) { - real_phys_avail[k] = real_phys_avail[k + 2]; - real_phys_avail[k + 1] = real_phys_avail[k + 3]; - } - } - } - for (i = 0; phys_avail[i] != 0; i += 2) - if (pmap_debug_range || pmap_debug) - printf("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n", - i, phys_avail[i], i+1, phys_avail[i+1]); - - /* - * Shuffle the memory range containing the 256MB page with - * nucleus_memory to the beginning of the phys_avail array - * so that physical memory from that page is preferentially - * allocated first - */ - for (j = 0; phys_avail[j] != 0; j += 2) - if (nucleus_memory_start < phys_avail[j]) - break; - /* - * Don't shuffle unless we have a full 256M page in the range - * our kernel malloc appears to be horribly brittle - */ - if ((phys_avail[j + 1] - phys_avail[j]) < - (PAGE_SIZE_256M - nucleus_memory)) - goto skipshuffle; - - for (i = j, k = 0; phys_avail[i] != 0; k++, i++) - tmp_phys_avail[k] = phys_avail[i]; - for (i = 0; i < j; i++) - tmp_phys_avail[k + i] = phys_avail[i]; - for (i = 0; i < 128; i++) - phys_avail[i] = tmp_phys_avail[i]; - -skipshuffle: - for (i = 0; real_phys_avail[i] != 0; i += 2) - if (pmap_debug_range || pmap_debug) - printf("real_phys_avail[%d]=0x%lx real_phys_avail[%d]=0x%lx\n", - i, real_phys_avail[i], i+1, real_phys_avail[i+1]); - - for (i = 0; phys_avail[i] != 0; i += 2) - if (pmap_debug_range || pmap_debug) - printf("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n", - i, phys_avail[i], i+1, phys_avail[i+1]); - /* - * Calculate the size of kernel virtual memory, and the size and mask - * for the kernel tsb. - */ - virtsz = roundup(physsz, PAGE_SIZE_4M << (PAGE_SHIFT - TTE_SHIFT)); - vm_max_kernel_address = VM_MIN_KERNEL_ADDRESS + virtsz; - - /* - * Set the start and end of kva. The kernel is loaded at the first - * available 4 meg super page, so round up to the end of the page. - */ - virtual_avail = roundup2(ekva, PAGE_SIZE_4M); - virtual_end = vm_max_kernel_address; - kernel_vm_end = vm_max_kernel_address; - - /* - * Allocate and map a 4MB page for the kernel hashtable - * - */ -#ifndef SIMULATOR - kernel_hash_shift = 10; /* PAGE_SIZE_4M*2 */ -#else - kernel_hash_shift = 6; /* PAGE_SIZE_8K*64 */ -#endif - - kernel_hash_pa = pmap_bootstrap_alloc((1<<(kernel_hash_shift + PAGE_SHIFT))); - if (kernel_hash_pa & PAGE_MASK_4M) - panic("pmap_bootstrap: hashtable pa unaligned\n"); - /* - * Set up TSB descriptors for the hypervisor - * - */ -#ifdef notyet - tsb_8k_size = virtsz >> (PAGE_SHIFT - TTE_SHIFT); -#else - /* avoid alignment complaints from the hypervisor */ - tsb_8k_size = PAGE_SIZE_4M; -#endif - - tsb_8k_pa = pmap_bootstrap_alloc(tsb_8k_size); - if (tsb_8k_pa & PAGE_MASK_4M) - panic("pmap_bootstrap: tsb unaligned\n"); - KDPRINTF("tsb_8k_size is 0x%lx, tsb_8k_pa is 0x%lx\n", tsb_8k_size, tsb_8k_pa); - - tsb_4m_size = (virtsz >> (PAGE_SHIFT_4M - TTE_SHIFT)) << 3; - tsb_4m_pa = pmap_bootstrap_alloc(tsb_4m_size); - - kernel_td[TSB8K_INDEX].hti_idxpgsz = TTE8K; - kernel_td[TSB8K_INDEX].hti_assoc = 1; - kernel_td[TSB8K_INDEX].hti_ntte = (tsb_8k_size >> TTE_SHIFT); - kernel_td[TSB8K_INDEX].hti_ctx_index = 0; - kernel_td[TSB8K_INDEX].hti_pgszs = TSB8K; - kernel_td[TSB8K_INDEX].hti_rsvd = 0; - kernel_td[TSB8K_INDEX].hti_ra = tsb_8k_pa; - - /* - * Initialize kernel's private TSB from 8K page TSB - * - */ - kernel_pmap->pm_tsb.hti_idxpgsz = TTE8K; - kernel_pmap->pm_tsb.hti_assoc = 1; - kernel_pmap->pm_tsb.hti_ntte = (tsb_8k_size >> TTE_SHIFT); - kernel_pmap->pm_tsb.hti_ctx_index = 0; - kernel_pmap->pm_tsb.hti_pgszs = TSB8K; - kernel_pmap->pm_tsb.hti_rsvd = 0; - kernel_pmap->pm_tsb.hti_ra = tsb_8k_pa; - - kernel_pmap->pm_tsb_ra = vtophys((vm_offset_t)&kernel_pmap->pm_tsb); - tsb_set_scratchpad_kernel(&kernel_pmap->pm_tsb); - - /* - * Initialize kernel TSB for 4M pages - * currently (not by design) used for permanent mappings - */ - - - KDPRINTF("tsb_4m_pa is 0x%lx tsb_4m_size is 0x%lx\n", tsb_4m_pa, tsb_4m_size); - kernel_td[TSB4M_INDEX].hti_idxpgsz = TTE4M; - kernel_td[TSB4M_INDEX].hti_assoc = 1; - kernel_td[TSB4M_INDEX].hti_ntte = (tsb_4m_size >> TTE_SHIFT); - kernel_td[TSB4M_INDEX].hti_ctx_index = 0; - kernel_td[TSB4M_INDEX].hti_pgszs = TSB4M|TSB256M; - kernel_td[TSB4M_INDEX].hti_rsvd = 0; - kernel_td[TSB4M_INDEX].hti_ra = tsb_4m_pa; - /* - * allocate MMU fault status areas for all CPUS - */ - mmu_fault_status_area = pmap_bootstrap_alloc(MMFSA_SIZE*MAXCPU); - - /* - * Allocate and map the dynamic per-CPU area for the BSP. - */ - dpcpu0 = (void *)TLB_PHYS_TO_DIRECT(pmap_bootstrap_alloc(DPCPU_SIZE)); - - /* - * Allocate and map the message buffer. - */ - msgbuf_phys = pmap_bootstrap_alloc(msgbufsize); - msgbufp = (struct msgbuf *)TLB_PHYS_TO_DIRECT(msgbuf_phys); - - /* - * Allocate a kernel stack with guard page for thread0 and map it into - * the kernel tsb. - */ - pa = pmap_bootstrap_alloc(KSTACK_PAGES*PAGE_SIZE); - kstack0_phys = pa; - virtual_avail += KSTACK_GUARD_PAGES * PAGE_SIZE; - kstack0 = virtual_avail; - virtual_avail += KSTACK_PAGES * PAGE_SIZE; - for (i = 0; i < KSTACK_PAGES; i++) { - pa = kstack0_phys + i * PAGE_SIZE; - va = kstack0 + i * PAGE_SIZE; - tsb_set_tte_real(&kernel_td[TSB8K_INDEX], va, va, - pa | TTE_KERNEL | VTD_8K, 0); - } - /* - * Calculate the last available physical address. - */ - for (i = 0; phys_avail[i + 2] != 0; i += 2) - KDPRINTF("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n", - i, phys_avail[i], i+1, phys_avail[i+1]); - KDPRINTF("phys_avail[%d]=0x%lx phys_avail[%d]=0x%lx\n", - i, phys_avail[i], i+1, phys_avail[i+1]); - - Maxmem = sparc64_btop(phys_avail[i + 1]); - - /* - * Add the prom mappings to the kernel tsb. - */ - for (i = 0; i < sz; i++) { - CTR3(KTR_PMAP, - "translation: start=%#lx size=%#lx tte=%#lx", - translations[i].om_start, translations[i].om_size, - translations[i].om_tte); - KDPRINTF("om_size=%ld om_start=%lx om_tte=%lx\n", - translations[i].om_size, translations[i].om_start, - translations[i].om_tte); - - if (translations[i].om_start < VM_MIN_PROM_ADDRESS || - translations[i].om_start > VM_MAX_PROM_ADDRESS) - continue; - - for (off = 0; off < translations[i].om_size; - off += PAGE_SIZE) { - va = translations[i].om_start + off; - pa = TTE_GET_PA(translations[i].om_tte) + off; - tsb_assert_invalid(&kernel_td[TSB8K_INDEX], va); - tsb_set_tte_real(&kernel_td[TSB8K_INDEX], va, va, pa | - TTE_KERNEL | VTD_8K, 0); - } - } - - if ((error = hv_mmu_tsb_ctx0(MAX_TSB_INFO, - vtophys((vm_offset_t)kernel_td))) != H_EOK) - panic("failed to set ctx0 TSBs error: %ld", error); - -#ifdef SMP - mp_set_tsb_desc_ra(vtophys((vm_offset_t)&kernel_td)); -#endif - /* - * setup direct mappings - * - */ - for (i = 0, pa = real_phys_avail[i]; pa != 0; i += 2, pa = real_phys_avail[i]) { - vm_paddr_t tag_pa = 0, next_pa = 0; - uint64_t size_bits = VTD_4M; - while (pa < real_phys_avail[i + 1]) { - if (use_256M_pages && - (pa & PAGE_MASK_256M) == 0 && - ((pa + PAGE_SIZE_256M) <= real_phys_avail[i + 1])) { - tag_pa = pa; - size_bits = VTD_256M; - next_pa = pa + PAGE_SIZE_256M; - } else if (next_pa <= pa) { - tag_pa = pa; - size_bits = VTD_4M; - } - tsb_assert_invalid(&kernel_td[TSB4M_INDEX], TLB_PHYS_TO_DIRECT(pa)); - tsb_set_tte_real(&kernel_td[TSB4M_INDEX], TLB_PHYS_TO_DIRECT(pa), - TLB_PHYS_TO_DIRECT(pa), - tag_pa | TTE_KERNEL | size_bits, 0); - pa += PAGE_SIZE_4M; - } - } - - /* - * Get the available physical memory ranges from /memory/reg. These - * are only used for kernel dumps, but it may not be wise to do prom - * calls in that situation. - */ - if ((sz = OF_getproplen(pmem, "reg")) == -1) - panic("pmap_bootstrap: getproplen /memory/reg"); - if (sizeof(sparc64_memreg) < sz) - panic("pmap_bootstrap: sparc64_memreg too small"); - if (OF_getprop(pmem, "reg", sparc64_memreg, sz) == -1) - panic("pmap_bootstrap: getprop /memory/reg"); - sparc64_nmemreg = sz / sizeof(*sparc64_memreg); - - pm = kernel_pmap; - pm->pm_active = ~0; - pm->pm_tlbactive = ~0; - - PMAP_LOCK_INIT(kernel_pmap); - - TAILQ_INIT(&kernel_pmap->pm_pvlist); - - /* - * This could happen earlier - but I put it here to avoid - * attempts to do updates until they're legal - */ - pm->pm_hash = tte_hash_kernel_create(TLB_PHYS_TO_DIRECT(kernel_hash_pa), kernel_hash_shift, - pmap_bootstrap_alloc(PAGE_SIZE)); - pm->pm_hashscratch = tte_hash_set_scratchpad_kernel(pm->pm_hash); - - for (i = 0; i < translations_size; i++) { - KDPRINTF("om_size=%ld om_start=%lx om_tte=%lx\n", - translations[i].om_size, translations[i].om_start, - translations[i].om_tte); - - if (translations[i].om_start < VM_MIN_PROM_ADDRESS || - translations[i].om_start > VM_MAX_PROM_ADDRESS) { - KDPRINTF("skipping\n"); - continue; - } - for (off = 0; off < translations[i].om_size; off += PAGE_SIZE) { - va = translations[i].om_start + off; - pa = TTE_GET_PA(translations[i].om_tte) + off; - tte_hash_insert(pm->pm_hash, va, pa | TTE_KERNEL | VTD_8K); - } - KDPRINTF("set om_size=%ld om_start=%lx om_tte=%lx\n", - translations[i].om_size, translations[i].om_start, - translations[i].om_tte); - } - for (i = 0; i < KSTACK_PAGES; i++) { - pa = kstack0_phys + i * PAGE_SIZE; - va = kstack0 + i * PAGE_SIZE; - tte_hash_insert(pm->pm_hash, va, pa | TTE_KERNEL | VTD_8K); - } - /* - * Add direct mappings to hash - * - */ -#ifdef notyet - /* hash only supports 8k pages */ - for (pa = PAGE_SIZE_4M; pa < phys_avail[2]; pa += PAGE_SIZE_4M) - tte_hash_insert(pm->pm_hash, TLB_PHYS_TO_DIRECT(pa), - pa | TTE_KERNEL | VTD_4M); -#endif - - - if (bootverbose) - printf("pmap_bootstrap done\n"); -} - - - -/* - * Routine: pmap_change_wiring - * Function: Change the wiring attribute for a map/virtual-address - * pair. - * In/out conditions: - * The mapping must already exist in the pmap. - */ -void -pmap_change_wiring(pmap_t pmap, vm_offset_t va, boolean_t wired) -{ - boolean_t iswired; - PMAP_LOCK(pmap); - iswired = tte_get_virt_bit(pmap, va, VTD_WIRED); - - if (wired && !iswired) { - pmap->pm_stats.wired_count++; - tte_set_virt_bit(pmap, va, VTD_WIRED); - } else if (!wired && iswired) { - pmap->pm_stats.wired_count--; - tte_clear_virt_bit(pmap, va, VTD_WIRED); - } - PMAP_UNLOCK(pmap); -} - -void -pmap_clear_modify(vm_page_t m) -{ - KDPRINTF("pmap_clear_modify(0x%lx)\n", VM_PAGE_TO_PHYS(m)); - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_clear_modify: page %p is not managed", m)); - VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); - KASSERT((m->oflags & VPO_BUSY) == 0, - ("pmap_clear_modify: page %p is busy", m)); - - /* - * If the page is not PG_WRITEABLE, then no TTEs can have VTD_W set. - * If the object containing the page is locked and the page is not - * VPO_BUSY, then PG_WRITEABLE cannot be concurrently set. - */ - if ((m->flags & PG_WRITEABLE) == 0) - return; - vm_page_lock_queues(); - tte_clear_phys_bit(m, VTD_W); - vm_page_unlock_queues(); -} - -void -pmap_clear_reference(vm_page_t m) -{ - KDPRINTF("pmap_clear_reference(0x%lx)\n", VM_PAGE_TO_PHYS(m)); - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_clear_reference: page %p is not managed", m)); - vm_page_lock_queues(); - tte_clear_phys_bit(m, VTD_REF); - vm_page_unlock_queues(); -} - -void -pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, - vm_size_t len, vm_offset_t src_addr) -{ - vm_offset_t addr, end_addr; - - end_addr = src_addr + len; - /* - * Don't let optional prefaulting of pages make us go - * way below the low water mark of free pages or way - * above high water mark of used pv entries. - */ - if (cnt.v_free_count < cnt.v_free_reserved || - pv_entry_count > pv_entry_high_water) - return; - - - vm_page_lock_queues(); - if (dst_pmap < src_pmap) { - PMAP_LOCK(dst_pmap); - PMAP_LOCK(src_pmap); - } else { - PMAP_LOCK(src_pmap); - PMAP_LOCK(dst_pmap); - } - for (addr = src_addr; addr < end_addr; addr += PAGE_SIZE) { - tte_t tte_data; - vm_page_t m; - - tte_data = tte_hash_lookup(src_pmap->pm_hash, addr); - - if ((tte_data & VTD_MANAGED) != 0) { - if (tte_hash_lookup(dst_pmap->pm_hash, addr) == 0) { - m = PHYS_TO_VM_PAGE(TTE_GET_PA(tte_data)); - - tte_hash_insert(dst_pmap->pm_hash, addr, tte_data & ~(VTD_W|VTD_REF|VTD_WIRED)); - dst_pmap->pm_stats.resident_count++; - pmap_insert_entry(dst_pmap, addr, m); - } - } - } - vm_page_unlock_queues(); - PMAP_UNLOCK(src_pmap); - PMAP_UNLOCK(dst_pmap); -} - -void -pmap_copy_page(vm_page_t src, vm_page_t dst) -{ - vm_paddr_t srcpa, dstpa; - srcpa = VM_PAGE_TO_PHYS(src); - dstpa = VM_PAGE_TO_PHYS(dst); - - novbcopy((char *)TLB_PHYS_TO_DIRECT(srcpa), (char *)TLB_PHYS_TO_DIRECT(dstpa), PAGE_SIZE); - - -} - -static __inline void -pmap_add_tte(pmap_t pmap, vm_offset_t va, vm_page_t m, tte_t *tte_data, int wired) -{ - - if (wired) - pmap->pm_stats.wired_count++; - - if ((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0) { - pmap_insert_entry(pmap, va, m); - *tte_data |= VTD_MANAGED; - } -} - -/* - * Map the given physical page at the specified virtual address in the - * target pmap with the protection requested. If specified the page - * will be wired down. - */ -void -pmap_enter(pmap_t pmap, vm_offset_t va, vm_prot_t access, vm_page_t m, - vm_prot_t prot, boolean_t wired) -{ - vm_paddr_t pa, opa; - uint64_t tte_data, otte_data; - pv_entry_t pv; - vm_page_t om; - int invlva; - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) != 0 || - (m->oflags & VPO_BUSY) != 0, - ("pmap_enter: page %p is not busy", m)); - if (pmap->pm_context) - DPRINTF("pmap_enter(va=%lx, pa=0x%lx, prot=%x)\n", va, - VM_PAGE_TO_PHYS(m), prot); - - om = NULL; - - vm_page_lock_queues(); - PMAP_LOCK(pmap); - - tte_data = pa = VM_PAGE_TO_PHYS(m); - otte_data = tte_hash_delete(pmap->pm_hash, va); - opa = TTE_GET_PA(otte_data); - - if (opa == 0) { - /* - * This is a new mapping - */ - pmap->pm_stats.resident_count++; - pmap_add_tte(pmap, va, m, &tte_data, wired); - - } else if (pa != opa) { - pv = NULL; - /* - * Mapping has changed, handle validating new mapping. - * - */ - if (otte_data & VTD_WIRED) - pmap->pm_stats.wired_count--; - - if (otte_data & VTD_MANAGED) { - om = PHYS_TO_VM_PAGE(opa); - pv = pmap_pvh_remove(&om->md, pmap, va); - } - - if (wired) - pmap->pm_stats.wired_count++; - - if ((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0) { - if (pv == NULL) - pv = get_pv_entry(pmap); - pv->pv_va = va; - pv->pv_pmap = pmap; - TAILQ_INSERT_TAIL(&pmap->pm_pvlist, pv, pv_plist); - TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); - m->md.pv_list_count++; - tte_data |= VTD_MANAGED; - } else if (pv != NULL) - free_pv_entry(pv); - - } else /* (pa == opa) */ { - /* - * Mapping has not changed, must be protection or wiring change. - */ - - /* - * Wiring change, just update stats. We don't worry about - * wiring PT pages as they remain resident as long as there - * are valid mappings in them. Hence, if a user page is wired, - * the PT page will be also. - */ - if (wired && ((otte_data & VTD_WIRED) == 0)) - pmap->pm_stats.wired_count++; - else if (!wired && (otte_data & VTD_WIRED)) - pmap->pm_stats.wired_count--; - - if (otte_data & VTD_MANAGED) { - om = m; - tte_data |= VTD_MANAGED; - } - } - - /* - * Now validate mapping with desired protection/wiring. - */ - if ((prot & VM_PROT_WRITE) != 0) { - tte_data |= VTD_SW_W; - if ((tte_data & VTD_MANAGED) != 0) - vm_page_flag_set(m, PG_WRITEABLE); - } - if ((prot & VM_PROT_EXECUTE) != 0) - tte_data |= VTD_X; - if (wired) - tte_data |= VTD_WIRED; - if (pmap == kernel_pmap) - tte_data |= VTD_P; - - invlva = FALSE; - if ((otte_data & ~(VTD_W|VTD_REF)) != tte_data) { - if (otte_data & VTD_V) { - if (otte_data & VTD_REF) { - if (otte_data & VTD_MANAGED) - vm_page_flag_set(om, PG_REFERENCED); - if ((opa != pa) || ((opa & VTD_X) != (pa & VTD_X))) - invlva = TRUE; - } - if (otte_data & VTD_W) { - if (otte_data & VTD_MANAGED) - vm_page_dirty(om); - if ((pa & VTD_SW_W) != 0) - invlva = TRUE; - } - if ((otte_data & VTD_MANAGED) != 0 && - TAILQ_EMPTY(&om->md.pv_list)) - vm_page_flag_clear(om, PG_WRITEABLE); - if (invlva) - pmap_invalidate_page(pmap, va, TRUE); - } - } - - - tte_hash_insert(pmap->pm_hash, va, tte_data|TTE_MINFLAGS|VTD_REF); - /* - * XXX this needs to be locked for the threaded / kernel case - */ - tsb_set_tte(&pmap->pm_tsb, va, tte_data|TTE_MINFLAGS|VTD_REF, - pmap->pm_context); - - if (tte_hash_needs_resize(pmap->pm_hash)) - pmap_tte_hash_resize(pmap); - - /* - * 512 is an arbitrary number of tsb misses - */ - if (0 && pmap->pm_context != 0 && pmap->pm_tsb_miss_count > 512) - pmap_tsb_resize(pmap); - - vm_page_unlock_queues(); - - PMAP_UNLOCK(pmap); -} - -/* - * Maps a sequence of resident pages belonging to the same object. - * The sequence begins with the given page m_start. This page is - * mapped at the given virtual address start. Each subsequent page is - * mapped at a virtual address that is offset from start by the same - * amount as the page is offset from m_start within the object. The - * last page in the sequence is the page with the largest offset from - * m_start that can be mapped at a virtual address less than the given - * virtual address end. Not every virtual page between start and end - * is mapped; only those for which a resident page exists with the - * corresponding offset from m_start are mapped. - */ -void -pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_offset_t end, - vm_page_t m_start, vm_prot_t prot) -{ - vm_page_t m; - vm_pindex_t diff, psize; - - VM_OBJECT_LOCK_ASSERT(m_start->object, MA_OWNED); - psize = atop(end - start); - m = m_start; - vm_page_lock_queues(); - PMAP_LOCK(pmap); - while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) { - pmap_enter_quick_locked(pmap, start + ptoa(diff), m, prot); - m = TAILQ_NEXT(m, listq); - } - vm_page_unlock_queues(); - PMAP_UNLOCK(pmap); -} - -void -pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot) -{ - - vm_page_lock_queues(); - PMAP_LOCK(pmap); - pmap_enter_quick_locked(pmap, va, m, prot); - vm_page_unlock_queues(); - PMAP_UNLOCK(pmap); -} - -static void -pmap_enter_quick_locked(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot) -{ - - tte_t tte_data; - - if (pmap->pm_context) - KDPRINTF("pmap_enter_quick(ctx=0x%lx va=%lx, pa=0x%lx prot=%x)\n", - pmap->pm_context, va, VM_PAGE_TO_PHYS(m), prot); - - PMAP_LOCK_ASSERT(pmap, MA_OWNED); - if (tte_hash_lookup(pmap->pm_hash, va)) - return; - - tte_data = VM_PAGE_TO_PHYS(m); - /* - * Enter on the PV list if part of our managed memory. Note that we - * raise IPL while manipulating pv_table since pmap_enter can be - * called at interrupt time. - */ - if ((m->flags & (PG_FICTITIOUS|PG_UNMANAGED)) == 0) { - pmap_insert_entry(pmap, va, m); - tte_data |= VTD_MANAGED; - } - - pmap->pm_stats.resident_count++; - - if ((prot & VM_PROT_EXECUTE) != 0) - tte_data |= VTD_X; - - tte_hash_insert(pmap->pm_hash, va, tte_data | TTE_MINFLAGS); -} - -/* - * Extract the physical page address associated with the given - * map/virtual_address pair. - */ -vm_paddr_t -pmap_extract(pmap_t pmap, vm_offset_t va) -{ - vm_paddr_t pa; - tte_t tte_data; - - tte_data = tte_hash_lookup(pmap->pm_hash, va); - pa = TTE_GET_PA(tte_data) | (va & TTE_GET_PAGE_MASK(tte_data)); - - return (pa); -} - -/* - * Atomically extract and hold the physical page with the given - * pmap and virtual address pair if that mapping permits the given - * protection. - */ -vm_page_t -pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot) -{ - tte_t tte_data; - vm_page_t m; - vm_paddr_t pa; - - m = NULL; - pa = 0; - PMAP_LOCK(pmap); -retry: - tte_data = tte_hash_lookup(pmap->pm_hash, va); - if (tte_data != 0 && - ((tte_data & VTD_SW_W) || (prot & VM_PROT_WRITE) == 0)) { - if (vm_page_pa_tryrelock(pmap, TTE_GET_PA(tte_data), &pa)) - goto retry; - m = PHYS_TO_VM_PAGE(TTE_GET_PA(tte_data)); - vm_page_hold(m); - } - PA_UNLOCK_COND(pa); - PMAP_UNLOCK(pmap); - - return (m); -} - -void * -pmap_alloc_zeroed_contig_pages(int npages, uint64_t alignment) -{ - vm_page_t m, tm; - int i; - void *ptr; - - m = NULL; - while (m == NULL) { - for (i = 0; phys_avail[i + 1] != 0; i += 2) { - m = vm_phys_alloc_contig(npages, phys_avail[i], - phys_avail[i + 1], alignment, (1UL<<34)); - if (m) - goto found; - } - if (m == NULL) { - printf("vm_phys_alloc_contig failed - waiting to retry\n"); - VM_WAIT; - } - } -found: - for (i = 0, tm = m; i < npages; i++, tm++) { - tm->wire_count++; - if ((tm->flags & PG_ZERO) == 0) - pmap_zero_page(tm); - } - ptr = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)); - - return (ptr); -} - -void -pmap_free_contig_pages(void *ptr, int npages) -{ - int i; - vm_page_t m; - - m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)ptr)); - for (i = 0; i < npages; i++, m++) { - m->wire_count--; - atomic_subtract_int(&cnt.v_wire_count, 1); - vm_page_free(m); - } -} - -void -pmap_growkernel(vm_offset_t addr) -{ - return; -} - -void -pmap_init(void) -{ - - /* allocate pv_entry zones */ - int shpgperproc = PMAP_SHPGPERPROC; - - for (ctx_stack_top = 1; ctx_stack_top < PMAP_CONTEXT_MAX; ctx_stack_top++) - ctx_stack[ctx_stack_top] = ctx_stack_top; - - mtx_init(&pmap_ctx_lock, "ctx lock", NULL, MTX_SPIN); - - /* - * Initialize the address space (zone) for the pv entries. Set a - * high water mark so that the system can recover from excessive - * numbers of pv entries. - */ - pvzone = uma_zcreate("PV ENTRY", sizeof(struct pv_entry), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); - TUNABLE_INT_FETCH("vm.pmap.shpgperproc", &shpgperproc); - pv_entry_max = shpgperproc * maxproc + cnt.v_page_count; - TUNABLE_INT_FETCH("vm.pmap.pv_entries", &pv_entry_max); - pv_entry_high_water = 9 * (pv_entry_max / 10); - uma_zone_set_obj(pvzone, &pvzone_obj, pv_entry_max); - - tte_hash_init(); - -} - -/* - * Create a pv entry for page at pa for - * (pmap, va). - */ -static void -pmap_insert_entry(pmap_t pmap, vm_offset_t va, vm_page_t m) -{ - pv_entry_t pv; - - KDPRINTF("pmap_insert_entry(va=0x%lx, pa=0x%lx)\n", va, VM_PAGE_TO_PHYS(m)); - pv = get_pv_entry(pmap); - pv->pv_va = va; - pv->pv_pmap = pmap; - - PMAP_LOCK_ASSERT(pmap, MA_OWNED); - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - TAILQ_INSERT_TAIL(&pmap->pm_pvlist, pv, pv_plist); - TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); - m->md.pv_list_count++; -} - -#ifdef TRAP_TRACING -static int trap_trace_report_done; -#endif - -#ifdef SMP -static cpumask_t -pmap_ipi(pmap_t pmap, char *func, uint64_t arg1, uint64_t arg2) -{ - - int i, cpu_count, retried; - cpumask_t cpus; - cpumask_t cpumask, active, curactive; - cpumask_t active_total, ackmask; - uint16_t *cpulist; - - retried = 0; - - if (!smp_started) - return (0); - - cpumask = PCPU_GET(cpumask); - cpulist = PCPU_GET(cpulist); - curactive = 0; - - if (rdpr(pil) != 14) - panic("pil %ld != 14", rdpr(pil)); - -#ifndef CPUMASK_NOT_BEING_ERRONEOUSLY_CHANGED - /* by definition cpumask should have curcpu's bit set */ - if (cpumask != (1 << curcpu)) - panic("cpumask(0x%x) != (1 << curcpu) (0x%x)\n", - cpumask, (1 << curcpu)); - -#endif -#ifdef notyet - if ((active_total = (pmap->pm_tlbactive & ~cpumask)) == 0) - goto done; - - if (pmap->pm_context != 0) - active_total = active = (pmap->pm_tlbactive & ~cpumask); - else -#endif - active_total = active = PCPU_GET(other_cpus); - - if (active == 0) - goto done; - - retry: - - for (i = curactive = cpu_count = 0, cpus = active; i < mp_ncpus && cpus; i++, cpus = (cpus>>1)) { - if ((cpus & 0x1) == 0) - continue; - - curactive |= (1 << i); - cpulist[cpu_count] = (uint16_t)i; - cpu_count++; - } - - ackmask = 0; - cpu_ipi_selected(cpu_count, cpulist, (uint64_t)func, (uint64_t)arg1, - (uint64_t)arg2, (uint64_t *)&ackmask); - - while (ackmask != curactive) { - membar(Sync); - i++; - if (i > 10000000) { -#ifdef TRAP_TRACING - int j; -#endif - uint64_t cpu_state; - printf("cpu with cpumask=0x%x appears to not be responding to ipis\n", - curactive & ~ackmask); - -#ifdef TRAP_TRACING - if (!trap_trace_report_done) { - trap_trace_report_done = 1; - for (j = 0; j < MAXCPU; j++) - if (((1 << j) & curactive & ~ackmask) != 0) { - struct pcpu *pc = pcpu_find(j); - printf("pcpu pad 0x%jx 0x%jx 0x%jx 0x%jx 0x%jx 0x%jx 0x%jx\n", - pc->pad[0], pc->pad[1], pc->pad[2], pc->pad[3], - pc->pad[4], pc->pad[5], pc->pad[6]); - trap_trace_report(j); - } - } -#endif - - hv_cpu_state((uint64_t)ffs64(curactive & ~ackmask), &cpu_state); - printf("cpu_state of %ld is %ld\n", ffs64(curactive & ~ackmask), cpu_state); - if (!retried) { - printf("I'm going to send off another ipi just to confirm that it isn't a memory barrier bug\n" - "and then I'm going to panic\n"); - - retried = 1; - goto retry; - } - - panic(" ackmask=0x%x active=0x%x\n", ackmask, curactive); - } - } - - active_total |= curactive; - if ((active = ((pmap->pm_tlbactive & all_cpus) & ~(active_total|cpumask))) != 0) { - printf("pmap_ipi: retrying"); - goto retry; - } - done: - return (active_total); -} -#endif - -void -pmap_invalidate_page(pmap_t pmap, vm_offset_t va, int cleartsb) -{ - - if (cleartsb == TRUE) - tsb_clear_tte(&pmap->pm_tsb, va); - - DPRINTF("pmap_invalidate_page(va=0x%lx)\n", va); - spinlock_enter(); - invlpg(va, pmap->pm_context); -#ifdef SMP - pmap_ipi(pmap, (void *)tl_invlpg, (uint64_t)va, (uint64_t)pmap->pm_context); -#endif - spinlock_exit(); -} - -void -pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int cleartsb) -{ - vm_offset_t tva, invlrngva; - char *func; -#ifdef SMP - cpumask_t active; -#endif - if ((eva - sva) == PAGE_SIZE) { - pmap_invalidate_page(pmap, sva, cleartsb); - return; - } - - - KASSERT(sva < eva, ("invalidating negative or zero range sva=0x%lx eva=0x%lx", sva, eva)); - - if (cleartsb == TRUE) - tsb_clear_range(&pmap->pm_tsb, sva, eva); - - spinlock_enter(); - if ((sva - eva) < PAGE_SIZE*64) { - for (tva = sva; tva < eva; tva += PAGE_SIZE_8K) - invlpg(tva, pmap->pm_context); - func = tl_invlrng; - } else if (pmap->pm_context) { - func = tl_invlctx; - invlctx(pmap->pm_context); - - } else { - func = tl_invltlb; - invltlb(); - } -#ifdef SMP - invlrngva = sva | ((eva - sva) >> PAGE_SHIFT); - active = pmap_ipi(pmap, (void *)func, pmap->pm_context, invlrngva); - active &= ~pmap->pm_active; - atomic_clear_int(&pmap->pm_tlbactive, active); -#endif - spinlock_exit(); -} - -void -pmap_invalidate_all(pmap_t pmap) -{ - - KASSERT(pmap != kernel_pmap, ("invalidate_all called on kernel_pmap")); - - tsb_clear(&pmap->pm_tsb); - - spinlock_enter(); - invlctx(pmap->pm_context); -#ifdef SMP - pmap_ipi(pmap, tl_invlctx, pmap->pm_context, 0); - pmap->pm_tlbactive = pmap->pm_active; -#endif - spinlock_exit(); -} - -boolean_t -pmap_is_modified(vm_page_t m) -{ - boolean_t rv; - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_is_modified: page %p is not managed", m)); - - /* - * If the page is not VPO_BUSY, then PG_WRITEABLE cannot be - * concurrently set while the object is locked. Thus, if PG_WRITEABLE - * is clear, no TTEs can have VTD_W set. - */ - VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); - if ((m->oflags & VPO_BUSY) == 0 && - (m->flags & PG_WRITEABLE) == 0) - return (FALSE); - vm_page_lock_queues(); - rv = tte_get_phys_bit(m, VTD_W); - vm_page_unlock_queues(); - return (rv); -} - - -boolean_t -pmap_is_prefaultable(pmap_t pmap, vm_offset_t va) -{ - return (tte_hash_lookup(pmap->pm_hash, va) == 0); -} - -/* - * Return whether or not the specified physical page was referenced - * in any physical maps. - */ -boolean_t -pmap_is_referenced(vm_page_t m) -{ - boolean_t rv; - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_is_referenced: page %p is not managed", m)); - vm_page_lock_queues(); - rv = tte_get_phys_bit(m, VTD_REF); - vm_page_unlock_queues(); - return (rv); -} - -/* - * Extract the physical page address associated with the given kernel virtual - * address. - */ - -vm_paddr_t -pmap_kextract(vm_offset_t va) -{ - tte_t tte_data; - vm_paddr_t pa; - - pa = 0; - if (va > KERNBASE && va < KERNBASE + nucleus_memory) { - uint64_t offset; - offset = va - KERNBASE; - pa = nucleus_mappings[offset >> 22] | (va & PAGE_MASK_4M); - } - if ((pa == 0) && (tte_data = tsb_lookup_tte(va, 0)) != 0) - pa = TTE_GET_PA(tte_data) | (va & TTE_GET_PAGE_MASK(tte_data)); - - if ((pa == 0) && (tte_data = tte_hash_lookup(kernel_pmap->pm_hash, va)) != 0) - pa = TTE_GET_PA(tte_data) | (va & TTE_GET_PAGE_MASK(tte_data)); - - return pa; -} - -/* - * Map a range of physical addresses into kernel virtual address space. - * - * The value passed in *virt is a suggested virtual address for the mapping. - * Architectures which can support a direct-mapped physical to virtual region - * can return the appropriate address within that region, leaving '*virt' - * unchanged. - */ -vm_offset_t -pmap_map(vm_offset_t *virt, vm_paddr_t start, vm_paddr_t end, int prot) -{ - return TLB_PHYS_TO_DIRECT(start); -} - -int -pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa) -{ - return (0); -} - -void -pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, - vm_pindex_t index, vm_size_t size) -{ - printf("pmap_object_init_pt\n"); - return; -} - -/* - * Returns true if the pmap's pv is one of the first - * 16 pvs linked to from this page. This count may - * be changed upwards or downwards in the future; it - * is only necessary that true be returned for a small - * subset of pmaps for proper page aging. - */ -boolean_t -pmap_page_exists_quick(pmap_t pmap, vm_page_t m) -{ - pv_entry_t pv; - int loops = 0; - boolean_t rv; - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_page_exists_quick: page %p is not managed", m)); - rv = FALSE; - vm_page_lock_queues(); - TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { - if (pv->pv_pmap == pmap) { - rv = TRUE; - break; - } - loops++; - if (loops >= 16) - break; - } - vm_page_unlock_queues(); - return (rv); -} - -/* - * Initialize a vm_page's machine-dependent fields. - */ -void -pmap_page_init(vm_page_t m) -{ - - TAILQ_INIT(&m->md.pv_list); - m->md.pv_list_count = 0; -} - -/* - * Return the number of managed mappings to the given physical page - * that are wired. - */ -int -pmap_page_wired_mappings(vm_page_t m) -{ - pmap_t pmap; - pv_entry_t pv; - uint64_t tte_data; - int count; - - count = 0; - if ((m->flags & PG_FICTITIOUS) != 0) - return (count); - vm_page_lock_queues(); - TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { - pmap = pv->pv_pmap; - PMAP_LOCK(pmap); - tte_data = tte_hash_lookup(pmap->pm_hash, pv->pv_va); - if ((tte_data & VTD_WIRED) != 0) - count++; - PMAP_UNLOCK(pmap); - } - vm_page_unlock_queues(); - return (count); -} - -/* - * Lower the permission for all mappings to a given page. - */ -void -pmap_remove_write(vm_page_t m) -{ - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_remove_write: page %p is not managed", m)); - - /* - * If the page is not VPO_BUSY, then PG_WRITEABLE cannot be set by - * another thread while the object is locked. Thus, if PG_WRITEABLE - * is clear, no page table entries need updating. - */ - VM_OBJECT_LOCK_ASSERT(m->object, MA_OWNED); - if ((m->oflags & VPO_BUSY) == 0 && - (m->flags & PG_WRITEABLE) == 0) - return; - vm_page_lock_queues(); - tte_clear_phys_bit(m, VTD_SW_W|VTD_W); - vm_page_flag_clear(m, PG_WRITEABLE); - vm_page_unlock_queues(); -} - -/* - * Initialize the pmap associated with process 0. - */ -void -pmap_pinit0(pmap_t pmap) -{ - PMAP_LOCK_INIT(pmap); - pmap->pm_active = pmap->pm_tlbactive = ~0; - pmap->pm_context = 0; - pmap->pm_tsb_ra = kernel_pmap->pm_tsb_ra; - pmap->pm_hash = kernel_pmap->pm_hash; - critical_enter(); - PCPU_SET(curpmap, pmap); - critical_exit(); - TAILQ_INIT(&pmap->pm_pvlist); - bzero(&pmap->pm_stats, sizeof pmap->pm_stats); -} - -/* - * Initialize a preallocated and zeroed pmap structure, such as one in a - * vmspace structure. - */ -int -pmap_pinit(pmap_t pmap) -{ - int i; - - pmap->pm_context = get_context(); - pmap->pm_tsb_ra = vtophys(&pmap->pm_tsb); - - vm_page_lock_queues(); - pmap->pm_hash = tte_hash_create(pmap->pm_context, &pmap->pm_hashscratch); - tsb_init(&pmap->pm_tsb, &pmap->pm_tsbscratch, TSB_INIT_SHIFT); - vm_page_unlock_queues(); - pmap->pm_tsb_miss_count = pmap->pm_tsb_cap_miss_count = 0; - pmap->pm_active = pmap->pm_tlbactive = 0; - for (i = 0; i < TSB_MAX_RESIZE; i++) - pmap->pm_old_tsb_ra[i] = 0; - - TAILQ_INIT(&pmap->pm_pvlist); - PMAP_LOCK_INIT(pmap); - bzero(&pmap->pm_stats, sizeof pmap->pm_stats); - return (1); -} - -/* - * Set the physical protection on the specified range of this map as requested. - */ -void -pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot) -{ - - int anychanged; - vm_offset_t tva; - uint64_t clearbits; - - DPRINTF("pmap_protect(0x%lx, 0x%lx, %d)\n", sva, eva, prot); - - if ((prot & VM_PROT_READ) == VM_PROT_NONE) { - pmap_remove(pmap, sva, eva); - return; - } - - if ((prot & (VM_PROT_WRITE|VM_PROT_EXECUTE)) == - (VM_PROT_WRITE|VM_PROT_EXECUTE)) - return; - - clearbits = anychanged = 0; - - if ((prot & VM_PROT_WRITE) == 0) - clearbits |= (VTD_W|VTD_SW_W); - if ((prot & VM_PROT_EXECUTE) == 0) - clearbits |= VTD_X; - - vm_page_lock_queues(); - PMAP_LOCK(pmap); - for (tva = sva; tva < eva; tva += PAGE_SIZE) { - uint64_t otte_data; - vm_page_t m; - - if ((otte_data = tte_hash_clear_bits(pmap->pm_hash, tva, - clearbits)) == 0) - continue; - /* - * XXX technically we should do a shootdown if it - * was referenced and was executable - but is not now - */ - if (!anychanged && (otte_data & VTD_W)) - anychanged = 1; - - if ((otte_data & (VTD_MANAGED | VTD_W)) == (VTD_MANAGED | - VTD_W)) { - m = PHYS_TO_VM_PAGE(TTE_GET_PA(otte_data)); - vm_page_dirty(m); - } - } - - vm_page_unlock_queues(); - if (anychanged) - pmap_invalidate_range(pmap, sva, eva, TRUE); - PMAP_UNLOCK(pmap); -} - -/* - * Map a list of wired pages into kernel virtual address space. This is - * intended for temporary mappings which do not need page modification or - * references recorded. Existing mappings in the region are overwritten. - */ -void -pmap_qenter(vm_offset_t sva, vm_page_t *m, int count) -{ - vm_offset_t va; - tte_t otte; - - otte = 0; - va = sva; - while (count-- > 0) { - otte |= tte_hash_update(kernel_pmap->pm_hash, va, - VM_PAGE_TO_PHYS(*m) | TTE_KERNEL | VTD_8K); - va += PAGE_SIZE; - m++; - } - if ((otte & VTD_REF) != 0) - pmap_invalidate_range(kernel_pmap, sva, va, FALSE); -} - -/* - * Remove page mappings from kernel virtual address space. Intended for - * temporary mappings entered by pmap_qenter. - */ -void -pmap_qremove(vm_offset_t sva, int count) -{ - vm_offset_t va; - tte_t otte; - - va = sva; - - otte = 0; - while (count-- > 0) { - otte |= tte_hash_delete(kernel_pmap->pm_hash, va); - va += PAGE_SIZE; - } - if ((otte & VTD_REF) != 0) - pmap_invalidate_range(kernel_pmap, sva, va, TRUE); -} - -/* - * Release any resources held by the given physical map. - * Called when a pmap initialized by pmap_pinit is being released. - * Should only be called if the map contains no valid mappings. - */ -void -pmap_release(pmap_t pmap) -{ - KASSERT(pmap->pm_stats.resident_count == 0, - ("pmap_release: pmap resident count %ld != 0", - pmap->pm_stats.resident_count)); - - tsb_deinit(&pmap->pm_tsb); - tte_hash_destroy(pmap->pm_hash); - free_context(pmap->pm_context); - PMAP_LOCK_DESTROY(pmap); -} - -/* - * Remove the given range of addresses from the specified map. - */ -void -pmap_remove(pmap_t pmap, vm_offset_t start, vm_offset_t end) -{ - int invlva; - vm_offset_t tva; - uint64_t tte_data; - /* - * Perform an unsynchronized read. This is, however, safe. - */ - if (pmap->pm_stats.resident_count == 0) - return; - - DPRINTF("pmap_remove(start=0x%lx, end=0x%lx)\n", - start, end); - invlva = 0; - vm_page_lock_queues(); - PMAP_LOCK(pmap); - for (tva = start; tva < end; tva += PAGE_SIZE) { - if ((tte_data = tte_hash_delete(pmap->pm_hash, tva)) == 0) - continue; - pmap_remove_tte(pmap, tte_data, tva); - if (tte_data & (VTD_REF|VTD_W)) - invlva = 1; - } - vm_page_unlock_queues(); - if (invlva) - pmap_invalidate_range(pmap, start, end, TRUE); - PMAP_UNLOCK(pmap); -} - -/* - * Routine: pmap_remove_all - * Function: - * Removes this physical page from - * all physical maps in which it resides. - * Reflects back modify bits to the pager. - * - * Notes: - * Original versions of this routine were very - * inefficient because they iteratively called - * pmap_remove (slow...) - */ - -void -pmap_remove_all(vm_page_t m) -{ - pv_entry_t pv; - uint64_t tte_data; - DPRINTF("pmap_remove_all 0x%lx\n", VM_PAGE_TO_PHYS(m)); - - vm_page_lock_queues(); - while ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) { - PMAP_LOCK(pv->pv_pmap); - pv->pv_pmap->pm_stats.resident_count--; - - tte_data = tte_hash_delete(pv->pv_pmap->pm_hash, pv->pv_va); - - if (tte_data & VTD_WIRED) - pv->pv_pmap->pm_stats.wired_count--; - if (tte_data & VTD_REF) - vm_page_flag_set(m, PG_REFERENCED); - - /* - * Update the vm_page_t clean and reference bits. - */ - if (tte_data & VTD_W) { - KASSERT((tte_data & VTD_SW_W), - ("pmap_remove_all: modified page not writable: va: %lx, tte: %lx", - pv->pv_va, tte_data)); - vm_page_dirty(m); - } - - pmap_invalidate_page(pv->pv_pmap, pv->pv_va, TRUE); - TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist); - TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - m->md.pv_list_count--; - PMAP_UNLOCK(pv->pv_pmap); - free_pv_entry(pv); - } - vm_page_flag_clear(m, PG_WRITEABLE); - vm_page_unlock_queues(); -} - -static pv_entry_t -pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, vm_offset_t va) -{ - pv_entry_t pv; - if (pmap != kernel_pmap) - DPRINTF("pmap_pvh_remove(va=0x%lx, pa=0x%lx)\n", va, - VM_PAGE_TO_PHYS(member2struct(vm_page, md, pvh))); - PMAP_LOCK_ASSERT(pmap, MA_OWNED); - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - if (pvh->pv_list_count < pmap->pm_stats.resident_count) { - TAILQ_FOREACH(pv, &pvh->pv_list, pv_list) { - if (pmap == pv->pv_pmap && va == pv->pv_va) - break; - } - } else { - TAILQ_FOREACH(pv, &pmap->pm_pvlist, pv_plist) { - if (va == pv->pv_va) - break; - } - } - if (pv != NULL) { - TAILQ_REMOVE(&pvh->pv_list, pv, pv_list); - pvh->pv_list_count--; - TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); - } - return (pv); -} - -static void -pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va) -{ - pv_entry_t pv; - - pv = pmap_pvh_remove(pvh, pmap, va); - KASSERT(pv != NULL, ("pmap_pvh_free: pv not found va=0x%lx pa=0x%lx", - va, VM_PAGE_TO_PHYS(member2struct(vm_page, md, pvh)))); - free_pv_entry(pv); -} - -static void -pmap_remove_entry(pmap_t pmap, vm_page_t m, vm_offset_t va) -{ - - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - pmap_pvh_free(&m->md, pmap, va); - if (TAILQ_EMPTY(&m->md.pv_list)) - vm_page_flag_clear(m, PG_WRITEABLE); -} - - -void -pmap_remove_pages(pmap_t pmap) -{ - - vm_page_t m; - pv_entry_t pv, npv; - tte_t tte_data; - - DPRINTF("pmap_remove_pages(ctx=0x%lx)\n", pmap->pm_context); - vm_page_lock_queues(); - PMAP_LOCK(pmap); - for (pv = TAILQ_FIRST(&pmap->pm_pvlist); pv; pv = npv) { - tte_data = tte_hash_delete(pmap->pm_hash, pv->pv_va); - - if (tte_data == 0) { - printf("TTE IS ZERO @ VA %016lx\n", pv->pv_va); - panic("bad tte"); - } - if (tte_data & VTD_WIRED) { - panic("wired page in process not handled correctly"); - pmap->pm_stats.wired_count--; - } - m = PHYS_TO_VM_PAGE(TTE_GET_PA(tte_data)); - - pmap->pm_stats.resident_count--; - - if (tte_data & VTD_W) { - vm_page_dirty(m); - } - - npv = TAILQ_NEXT(pv, pv_plist); - TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist); - - m->md.pv_list_count--; - TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - if (TAILQ_EMPTY(&m->md.pv_list)) - vm_page_flag_clear(m, PG_WRITEABLE); - - free_pv_entry(pv); - } - pmap->pm_hash = tte_hash_reset(pmap->pm_hash, &pmap->pm_hashscratch); - if (0) - pmap_tsb_reset(pmap); - - vm_page_unlock_queues(); - pmap_invalidate_all(pmap); - PMAP_UNLOCK(pmap); -} - -static void -pmap_tsb_reset(pmap_t pmap) -{ - int i; - - for (i = 1; i < TSB_MAX_RESIZE && pmap->pm_old_tsb_ra[i]; i++) { - pmap_free_contig_pages((void *)TLB_PHYS_TO_DIRECT(pmap->pm_old_tsb_ra[i]), - (1 << (TSB_INIT_SHIFT + i))); - pmap->pm_old_tsb_ra[i] = 0; - } - if (pmap->pm_old_tsb_ra[0] != 0) { - vm_paddr_t tsb_pa = pmap->pm_tsb.hti_ra; - int size = tsb_size(&pmap->pm_tsb); - pmap->pm_tsb.hti_ntte = (1 << (TSB_INIT_SHIFT + PAGE_SHIFT - TTE_SHIFT)); - pmap->pm_tsb.hti_ra = pmap->pm_old_tsb_ra[0]; - pmap_free_contig_pages((void *)TLB_PHYS_TO_DIRECT(tsb_pa), size); - pmap->pm_tsbscratch = pmap->pm_tsb.hti_ra | (uint64_t)TSB_INIT_SHIFT; - pmap->pm_old_tsb_ra[0] = 0; - } -} - -void -pmap_scrub_pages(vm_paddr_t pa, int64_t size) -{ - uint64_t bytes_zeroed; - while (size > 0) { - hv_mem_scrub(pa, size, &bytes_zeroed); - pa += bytes_zeroed; - size -= bytes_zeroed; - } -} - -static void -pmap_remove_tte(pmap_t pmap, tte_t tte_data, vm_offset_t va) -{ - - vm_page_t m; - - if (pmap != kernel_pmap) - DPRINTF("pmap_remove_tte(va=0x%lx, pa=0x%lx)\n", va, TTE_GET_PA(tte_data)); - - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - PMAP_LOCK_ASSERT(pmap, MA_OWNED); - if (tte_data & VTD_WIRED) - pmap->pm_stats.wired_count--; - - pmap->pm_stats.resident_count--; - - if (tte_data & VTD_MANAGED) { - m = PHYS_TO_VM_PAGE(TTE_GET_PA(tte_data)); - if (tte_data & VTD_W) { - vm_page_dirty(m); - } - if (tte_data & VTD_REF) - vm_page_flag_set(m, PG_REFERENCED); - pmap_remove_entry(pmap, m, va); - } -} - -/* resize the tsb if the number of capacity misses is greater than 1/4 of - * the total - */ -static void -pmap_tsb_resize(pmap_t pmap) -{ - uint32_t miss_count; - uint32_t cap_miss_count; - struct tsb_resize_info info; - hv_tsb_info_t hvtsb; - uint64_t tsbscratch; - - KASSERT(pmap == curthread_pmap, ("operating on non-current pmap")); - miss_count = pmap->pm_tsb_miss_count; - cap_miss_count = pmap->pm_tsb_cap_miss_count; - int npages_shift = tsb_page_shift(pmap); - - if (npages_shift < (TSB_INIT_SHIFT + TSB_MAX_RESIZE) && - cap_miss_count > (miss_count >> 1)) { - DPRINTF("resizing tsb for proc=%s pid=%d\n", - curthread->td_proc->p_comm, curthread->td_proc->p_pid); - pmap->pm_old_tsb_ra[npages_shift - TSB_INIT_SHIFT] = pmap->pm_tsb.hti_ra; - - /* double TSB size */ - tsb_init(&hvtsb, &tsbscratch, npages_shift + 1); -#ifdef SMP - spinlock_enter(); - /* reset tsb */ - bcopy(&hvtsb, &pmap->pm_tsb, sizeof(hv_tsb_info_t)); - pmap->pm_tsbscratch = tsb_set_scratchpad_user(&pmap->pm_tsb); - - if (hv_mmu_tsb_ctxnon0(1, pmap->pm_tsb_ra) != H_EOK) - panic("failed to set TSB 0x%lx - context == %ld\n", - pmap->pm_tsb_ra, pmap->pm_context); - info.tri_tsbscratch = pmap->pm_tsbscratch; - info.tri_tsb_ra = pmap->pm_tsb_ra; - pmap_ipi(pmap, tl_tsbupdate, pmap->pm_context, vtophys(&info)); - pmap->pm_tlbactive = pmap->pm_active; - spinlock_exit(); -#else - bcopy(&hvtsb, &pmap->pm_tsb, sizeof(hvtsb)); - if (hv_mmu_tsb_ctxnon0(1, pmap->pm_tsb_ra) != H_EOK) - panic("failed to set TSB 0x%lx - context == %ld\n", - pmap->pm_tsb_ra, pmap->pm_context); - pmap->pm_tsbscratch = tsb_set_scratchpad_user(&pmap->pm_tsb); -#endif - } - pmap->pm_tsb_miss_count = 0; - pmap->pm_tsb_cap_miss_count = 0; -} - -static void -pmap_tte_hash_resize(pmap_t pmap) -{ - tte_hash_t old_th = pmap->pm_hash; - - pmap->pm_hash = tte_hash_resize(pmap->pm_hash); - spinlock_enter(); - if (curthread->td_proc->p_numthreads != 1) - pmap_ipi(pmap, tl_ttehashupdate, pmap->pm_context, pmap->pm_hashscratch); - - pmap->pm_hashscratch = tte_hash_set_scratchpad_user(pmap->pm_hash, pmap->pm_context); - spinlock_exit(); - tte_hash_destroy(old_th); -} - -/* - * pmap_ts_referenced: - * - * Return a count of reference bits for a page, clearing those bits. - * It is not necessary for every reference bit to be cleared, but it - * is necessary that 0 only be returned when there are truly no - * reference bits set. - * - * XXX: The exact number of bits to check and clear is a matter that - * should be tested and standardized at some point in the future for - * optimal aging of shared pages. - */ - -int -pmap_ts_referenced(vm_page_t m) -{ - int rv; - pv_entry_t pv, pvf, pvn; - pmap_t pmap; - tte_t otte_data; - - KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0, - ("pmap_ts_referenced: page %p is not managed", m)); - rv = 0; - vm_page_lock_queues(); - if ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) { - - pvf = pv; - - do { - pvn = TAILQ_NEXT(pv, pv_list); - - TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); - - TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); - - pmap = pv->pv_pmap; - PMAP_LOCK(pmap); - otte_data = tte_hash_clear_bits(pmap->pm_hash, pv->pv_va, VTD_REF); - if ((otte_data & VTD_REF) != 0) { - pmap_invalidate_page(pmap, pv->pv_va, TRUE); - - rv++; - if (rv > 4) { - PMAP_UNLOCK(pmap); - break; - } - } - - PMAP_UNLOCK(pmap); - } while ((pv = pvn) != NULL && pv != pvf); - } - vm_page_unlock_queues(); - return (rv); -} - -void -pmap_zero_page(vm_page_t m) -{ - hwblkclr((void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)), PAGE_SIZE); -} - -void -pmap_zero_page_area(vm_page_t m, int off, int size) -{ - vm_paddr_t pa; - vm_offset_t va; - - pa = VM_PAGE_TO_PHYS(m); - va = TLB_PHYS_TO_DIRECT(pa); - if (off == 0 && size == PAGE_SIZE) - hwblkclr((void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)), PAGE_SIZE); - else - bzero((char *)(va + off), size); - -} - -void -pmap_zero_page_idle(vm_page_t m) -{ - hwblkclr((void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)), PAGE_SIZE); -} - -void -pmap_set_ctx_panic(uint64_t error, vm_paddr_t tsb_ra, pmap_t pmap) -{ - panic("setting ctxnon0 failed ctx=0x%lx hvtsb_ra=0x%lx tsbscratch=0x%lx error=0x%lx", - pmap->pm_context, tsb_ra, pmap->pm_tsbscratch, error); - -} diff --git a/sys/sun4v/sun4v/rtc.c b/sys/sun4v/sun4v/rtc.c deleted file mode 100644 index eb8c1e36de4b..000000000000 --- a/sys/sun4v/sun4v/rtc.c +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include "clock_if.h" - -static int hv_rtc_attach(device_t dev); -static int hv_rtc_probe(device_t dev); -static int hv_settime(device_t dev, struct timespec *ts); -static int hv_gettime(device_t dev, struct timespec *ts); - -static device_method_t hv_rtc_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, hv_rtc_probe), - DEVMETHOD(device_attach, hv_rtc_attach), - - /* clock interface */ - DEVMETHOD(clock_gettime, hv_gettime), - DEVMETHOD(clock_settime, hv_settime), - - { 0, 0 } -}; - -static driver_t hv_rtc_driver = { - "hv_rtc", - hv_rtc_methods, - 0 -}; -static devclass_t hv_rtc_devclass; -DRIVER_MODULE(rtc, vnex, hv_rtc_driver, hv_rtc_devclass, 0, 0); - -static int -hv_rtc_probe(device_t dev) -{ - if (strcmp(mdesc_bus_get_name(dev), "rtc") == 0) { - return (0); - } - - return (ENXIO); -} - -static int -hv_rtc_attach(device_t dev) -{ - clock_register(dev, 1000000); - return (0); -} - -static int -hv_settime(device_t dev, struct timespec *ts) -{ - hv_tod_set(ts->tv_sec); - return (0); -} - -static int -hv_gettime(device_t dev, struct timespec *ts) -{ - ts->tv_nsec = 0; - hv_tod_get(&ts->tv_sec); - return (0); -} diff --git a/sys/sun4v/sun4v/simdisk.c b/sys/sun4v/sun4v/simdisk.c deleted file mode 100644 index 3c77e41d2d40..000000000000 --- a/sys/sun4v/sun4v/simdisk.c +++ /dev/null @@ -1,251 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * Copyright (c) 2001 Benno Rice - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - - -#include - -#define HVD_BLOCKSIZE 512 - -struct hvd_softc -{ - struct bio_queue_head hvd_bio_queue; - struct mtx hvd_queue_mtx; - off_t hvd_mediasize; - unsigned hvd_sectorsize; - unsigned hvd_fwheads; - unsigned hvd_fwsectors; - struct proc *hvd_procp; - struct g_geom *hvd_gp; - struct g_provider *hvd_pp; -} hvd_softc; - -static g_init_t g_hvd_init; -static g_start_t g_hvd_start; -static g_access_t g_hvd_access; - -struct g_class g_hvd_class = { - .name = "HVD", - .version = G_VERSION, - .init = g_hvd_init, - .start = g_hvd_start, - .access = g_hvd_access, -}; - -DECLARE_GEOM_CLASS(g_hvd_class, g_hvd); - - - -static int -hvd_startio(struct hvd_softc *sc, struct bio *bp) -{ - u_int r; - int len, rlen, wlen; - uint64_t page_off; - - r = H_EOK; - len = 0; - - page_off = bp->bio_offset & PAGE_MASK; - - - switch (bp->bio_cmd) { - case BIO_READ: - if (bp->bio_length > (PAGE_SIZE - page_off)) { - len = rlen = (PAGE_SIZE - page_off); - r = hv_sim_read(bp->bio_offset, vtophys((char *)bp->bio_data), rlen); - } - for (; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { - rlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; - r = hv_sim_read(bp->bio_offset + len, vtophys((char *)bp->bio_data + len), rlen); - - } - break; - case BIO_WRITE: - if (bp->bio_length > (PAGE_SIZE - page_off)) { - len = wlen = (PAGE_SIZE - page_off); - r = hv_sim_write(bp->bio_offset, vtophys((char *)bp->bio_data), wlen); - } - for (; len < bp->bio_length && r == H_EOK; len += PAGE_SIZE) { - wlen = (bp->bio_length - len) > PAGE_SIZE ? PAGE_SIZE : bp->bio_length - len; - r = hv_sim_write(bp->bio_offset + len, vtophys((char *)bp->bio_data + len), wlen); - } - break; - } - if (r != H_EOK) - panic("invalid I/O"); - - bp->bio_resid = 0; - return (0); -} - -static void -hvd_kthread(void *arg) -{ - struct hvd_softc *sc; - struct bio *bp; - int error; - - sc = arg; - curthread->td_base_pri = PRIBIO; - - for (;;) { - mtx_lock(&sc->hvd_queue_mtx); - bp = bioq_takefirst(&sc->hvd_bio_queue); - if (!bp) { - msleep(sc, &sc->hvd_queue_mtx, PRIBIO | PDROP, - "hvdwait", 0); - continue; - } - mtx_unlock(&sc->hvd_queue_mtx); - if (bp->bio_cmd == BIO_GETATTR) { - error = EOPNOTSUPP; - } else - error = hvd_startio(sc, bp); - - if (error != -1) { - bp->bio_completed = bp->bio_length; - g_io_deliver(bp, error); - } - } -} - -static void -g_hvd_init(struct g_class *mp __unused) -{ - struct hvd_softc *sc; - struct g_geom *gp; - struct g_provider *pp; - int error; - printf("calling g_hvd_init\n"); - - sc = (struct hvd_softc *)malloc(sizeof *sc, M_DEVBUF, - M_WAITOK|M_ZERO); - bioq_init(&sc->hvd_bio_queue); - mtx_init(&sc->hvd_queue_mtx, "hvd bio queue", NULL, MTX_DEF); - sc->hvd_mediasize = (off_t)0x20000000; - sc->hvd_sectorsize = HVD_BLOCKSIZE; - sc->hvd_fwsectors = 0; - sc->hvd_fwheads = 0; - error = kproc_create(hvd_kthread, sc, &sc->hvd_procp, 0, 0, - "hvd0"); - if (error != 0) { - free(sc, M_DEVBUF); - return; - } - - gp = g_new_geomf(&g_hvd_class, "hvd0"); - gp->softc = sc; - pp = g_new_providerf(gp, "hvd0"); - pp->mediasize = sc->hvd_mediasize; - pp->sectorsize = sc->hvd_sectorsize; - sc->hvd_gp = gp; - sc->hvd_pp = pp; - g_error_provider(pp, 0); -} - -static void -g_hvd_start(struct bio *bp) -{ - struct hvd_softc *sc; -#if 0 - printf("in hvd_start\n"); -#endif - sc = bp->bio_to->geom->softc; - mtx_lock(&sc->hvd_queue_mtx); - bioq_disksort(&sc->hvd_bio_queue, bp); - mtx_unlock(&sc->hvd_queue_mtx); - wakeup(sc); -} - -static int -g_hvd_access(struct g_provider *pp, int r, int w, int e) -{ - - if (pp->geom->softc == NULL) - return (ENXIO); - return (0); -} - -static int -hvd_probe(device_t dev) -{ - - if (strcmp(ofw_bus_get_name(dev), "disk")) - return (ENXIO); - - device_set_desc(dev, "sun4v virtual disk"); - - return (0); -} - - -static int -hvd_attach(device_t dev) -{ - return (0); -} - -static device_method_t hvd_methods[] = { - DEVMETHOD(device_probe, hvd_probe), - DEVMETHOD(device_attach, hvd_attach), - {0, 0} -}; - - -static driver_t hvd_driver = { - "hvd", - hvd_methods, - 0, -}; - - -static devclass_t hvd_devclass; - -DRIVER_MODULE(hvd, vnex, hvd_driver, hvd_devclass, 0, 0); diff --git a/sys/sun4v/sun4v/stack_machdep.c b/sys/sun4v/sun4v/stack_machdep.c deleted file mode 100644 index 6b91dc1d52f1..000000000000 --- a/sys/sun4v/sun4v/stack_machdep.c +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * Copyright (c) 2005 Antoine Brodin - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include -#include - -static void stack_capture(struct stack *st, struct frame *frame); - -static void -stack_capture(struct stack *st, struct frame *frame) -{ - struct frame *fp; - vm_offset_t callpc; - - stack_zero(st); - fp = frame; - for (;;) { - if (!INKERNEL((vm_offset_t)fp) || - !ALIGNED_POINTER(fp, uint64_t)) - break; - callpc = fp->fr_pc; - if (!INKERNEL(callpc)) - break; - if (stack_put(st, callpc) == -1) - break; - if (v9next_frame(fp) <= fp || - v9next_frame(fp) >= frame + KSTACK_PAGES * PAGE_SIZE) - break; - fp = v9next_frame(fp); - } -} - -void -stack_save_td(struct stack *st, struct thread *td) -{ - - if (TD_IS_SWAPPED(td)) - panic("stack_save_td: swapped"); - if (TD_IS_RUNNING(td)) - panic("stack_save_td: running"); - - stack_capture(st, (struct frame *)(td->td_pcb->pcb_sp + SPOFF)); -} - -void -stack_save(struct stack *st) -{ - - stack_capture(st, (struct frame *)__builtin_frame_address(1)); -} diff --git a/sys/sun4v/sun4v/support.S b/sys/sun4v/sun4v/support.S deleted file mode 100644 index 699a40f25456..000000000000 --- a/sys/sun4v/sun4v/support.S +++ /dev/null @@ -1,924 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include -#include -#include -#include - -#include "assym.s" - - .register %g2, #ignore - .register %g3, #ignore - .register %g6, #ignore - -#define E /* empty */ - -/* - * Generate load and store instructions for the corresponding width and asi - * (or not). Note that we want to evaluate the macro args before - * concatenating, so that E really turns into nothing. - */ -#define _LD(w, a) ld ## w ## a -#define _ST(w, a) st ## w ## a - -#define LD(w, a) _LD(w, a) -#define ST(w, a) _ST(w, a) - -/* - * Common code for copy routines. - * - * We use large macros to generate functions for each of the copy routines. - * This allows the load and store instructions to be generated for the right - * operation, asi or not. It is possible to write an asi independent function - * but this would require 2 expensive wrs in the main loop to switch %asi. - * It would also screw up profiling (if we ever get it), but may save some I$. - * We assume that either one of dasi and sasi is empty, or that they are both - * the same (empty or non-empty). It is up to the caller to set %asi. - */ - -/* - * ASI independent implementation of copystr(9). - * Used to implement copyinstr() and copystr(). - * - * Return value is in %g1. - */ -#define _COPYSTR(src, dst, len, done, sa, sasi, da, dasi) \ - brz len, 4f ; \ - mov src, %g2 ; \ -1: deccc 1, len ; \ - bl,a,pn %xcc, 3f ; \ - nop ; \ - LD(ub, sa) [src] sasi, %g1 ; \ - ST(b, da) %g1, [dst] dasi ; \ - brz,pn %g1, 3f ; \ - inc src ; \ - ba %xcc, 1b ; \ - inc dst ; \ -2: mov ENAMETOOLONG, %g1 ; \ -3: sub src, %g2, %g2 ; \ - brnz,a done, 4f ; \ - stx %g2, [done] ; \ -4: - -/* - * ASI independent implementation of memset(3). - * Used to implement bzero(), memset() and aszero(). - * - * If the pattern is non-zero, duplicate it to fill 64 bits. - * Store bytes until dst is 8-byte aligned, then store 8 bytes. - * It has yet to be determined how much unrolling is beneficial. - * Could also read and compare before writing to minimize snoop traffic. - * - * XXX bzero() should be implemented as - * #define bzero(dst, len) (void)memset((dst), 0, (len)) - * if at all. - */ -#define _MEMSET(dst, pat, len, da, dasi) \ - brlez,pn len, 5f ; \ - and pat, 0xff, pat ; \ - brz,pt pat, 1f ; \ - sllx pat, 8, %g1 ; \ - or pat, %g1, pat ; \ - sllx pat, 16, %g1 ; \ - or pat, %g1, pat ; \ - sllx pat, 32, %g1 ; \ - or pat, %g1, pat ; \ - .align 16 ; \ -1: deccc 1, len ; \ - bl,pn %xcc, 5f ; \ - btst 7, dst ; \ - bz,a,pt %xcc, 2f ; \ - inc 1, len ; \ - ST(b, da) pat, [dst] dasi ; \ - ba %xcc, 1b ; \ - inc dst ; \ - .align 16 ; \ -2: deccc 32, len ; \ - bl,a,pn %xcc, 3f ; \ - inc 32, len ; \ - ST(x, da) pat, [dst] dasi ; \ - ST(x, da) pat, [dst + 8] dasi ; \ - ST(x, da) pat, [dst + 16] dasi ; \ - ST(x, da) pat, [dst + 24] dasi ; \ - ba %xcc, 2b ; \ - inc 32, dst ; \ - .align 16 ; \ -3: deccc 8, len ; \ - bl,a,pn %xcc, 4f ; \ - inc 8, len ; \ - ST(x, da) pat, [dst] dasi ; \ - ba %xcc, 3b ; \ - inc 8, dst ; \ - .align 16 ; \ -4: deccc 1, len ; \ - bl,a,pn %xcc, 5f ; \ - nop ; \ - ST(b, da) pat, [dst] dasi ; \ - ba %xcc, 4b ; \ - inc 1, dst ; \ -5: - -/* - * ASI independent implementation of memcpy(3). - * Used to implement bcopy(), copyin(), copyout(), memcpy(), ascopy(), - * ascopyfrom() and ascopyto(). - * - * Transfer bytes until dst is 8-byte aligned. If src is then also 8 byte - * aligned, transfer 8 bytes, otherwise finish with bytes. The unaligned - * case could be optimized, but it is expected that this is the uncommon - * case and of questionable value. The code to do so is also rather large - * and ugly. It has yet to be determined how much unrolling is beneficial. - * - * XXX bcopy() must also check for overlap. This is stupid. - * XXX bcopy() should be implemented as - * #define bcopy(src, dst, len) (void)memcpy((dst), (src), (len)) - * if at all. - */ -#define _MEMCPY(dst, src, len, da, dasi, sa, sasi) \ -1: deccc 1, len ; \ - bl,pn %xcc, 6f ; \ - btst 7, dst ; \ - bz,a,pt %xcc, 2f ; \ - inc 1, len ; \ - LD(ub, sa) [src] sasi, %g1 ; \ - ST(b, da) %g1, [dst] dasi ; \ - inc 1, src ; \ - ba %xcc, 1b ; \ - inc 1, dst ; \ - .align 16 ; \ -2: btst 7, src ; \ - bz,a,pt %xcc, 3f ; \ - nop ; \ - ba,a %xcc, 5f ; \ - .align 16 ; \ -3: deccc 32, len ; \ - bl,a,pn %xcc, 4f ; \ - inc 32, len ; \ - LD(x, sa) [src] sasi, %g1 ; \ - LD(x, sa) [src + 8] sasi, %g2 ; \ - LD(x, sa) [src + 16] sasi, %g3 ; \ - LD(x, sa) [src + 24] sasi, %g4 ; \ - ST(x, da) %g1, [dst] dasi ; \ - ST(x, da) %g2, [dst + 8] dasi ; \ - ST(x, da) %g3, [dst + 16] dasi ; \ - ST(x, da) %g4, [dst + 24] dasi ; \ - inc 32, src ; \ - ba %xcc, 3b ; \ - inc 32, dst ; \ - .align 16 ; \ -4: deccc 8, len ; \ - bl,a,pn %xcc, 5f ; \ - inc 8, len ; \ - LD(x, sa) [src] sasi, %g1 ; \ - ST(x, da) %g1, [dst] dasi ; \ - inc 8, src ; \ - ba %xcc, 4b ; \ - inc 8, dst ; \ - .align 16 ; \ -5: deccc 1, len ; \ - bl,a,pn %xcc, 6f ; \ - nop ; \ - LD(ub, sa) [src] sasi, %g1 ; \ - ST(b, da) %g1, [dst] dasi ; \ - inc src ; \ - ba %xcc, 5b ; \ - inc dst ; \ -6: - -/* - * void ascopy(u_long asi, vm_offset_t src, vm_offset_t dst, size_t len) - */ -ENTRY(ascopy) - wr %o0, 0, %asi - _MEMCPY(%o2, %o1, %o3, a, %asi, a, %asi) - retl - nop -END(ascopy) - -/* - * void ascopyfrom(u_long sasi, vm_offset_t src, caddr_t dst, size_t len) - */ -ENTRY(ascopyfrom) - wr %o0, 0, %asi - _MEMCPY(%o2, %o1, %o3, E, E, a, %asi) - retl - nop -END(ascopyfrom) - -/* - * void ascopyto(caddr_t src, u_long dasi, vm_offset_t dst, size_t len) - */ -ENTRY(ascopyto) - wr %o1, 0, %asi - _MEMCPY(%o2, %o0, %o3, a, %asi, E, E) - retl - nop -END(ascopyto) - -/* - * void aszero(u_long asi, vm_offset_t pa, size_t len) - */ -ENTRY(aszero) - wr %o0, 0, %asi - _MEMSET(%o1, %g0, %o2, a, %asi) - retl - nop -END(aszero) - -/* - * int bcmp(const void *b1, const void *b2, size_t len) - */ -ENTRY(bcmp) - brz,pn %o2, 2f - clr %o3 -1: ldub [%o0 + %o3], %o4 - ldub [%o1 + %o3], %o5 - cmp %o4, %o5 - bne,pn %xcc, 2f - inc %o3 - deccc %o2 - bne,pt %xcc, 1b - nop -2: retl - mov %o2, %o0 -END(bcmp) -#if 0 -/* - * void bcopy(const void *src, void *dst, size_t len) - */ -ENTRY(bcopy) - /* - * Check for overlap, and copy backwards if so. - */ - sub %o1, %o0, %g1 - cmp %g1, %o2 - bgeu,a,pt %xcc, 3f - nop - - /* - * Copy backwards. - */ - add %o0, %o2, %o0 - add %o1, %o2, %o1 -1: deccc 1, %o2 - bl,a,pn %xcc, 2f - nop - dec 1, %o0 - ldub [%o0], %g1 - dec 1, %o1 - ba %xcc, 1b - stb %g1, [%o1] -2: retl - nop - - /* - * Do the fast version. - */ -3: _MEMCPY(%o1, %o0, %o2, E, E, E, E) - retl - nop -END(bcopy) - -/* - * void bzero(void *b, size_t len) - */ -ENTRY(bzero) - _MEMSET(%o0, %g0, %o1, E, E) - retl - nop -END(bzero) -#endif -/* - * int copystr(const void *src, void *dst, size_t len, size_t *done) - */ -ENTRY(copystr) - _COPYSTR(%o0, %o1, %o2, %o3, E, E, E, E) - retl - mov %g1, %o0 -END(copystr) - -/* - * void *memcpy(void *dst, const void *src, size_t len) - */ -ENTRY(memcpy) - mov %o0, %o3 - _MEMCPY(%o3, %o1, %o2, E, E, E, E) - retl - nop -END(memcpy) - -/* - * void *memset(void *b, int c, size_t len) - */ -ENTRY(memset) - mov %o0, %o3 - _MEMSET(%o3, %o1, %o2, E, E) - retl - nop -END(memset) - - .globl copy_nofault_begin -copy_nofault_begin: - nop -#if 1 -/* - * int copyin(const void *uaddr, void *kaddr, size_t len) - */ -ENTRY(copyin) - wr %g0, ASI_AIUS, %asi - _MEMCPY(%o1, %o0, %o2, E, E, a, %asi) - retl - clr %o0 -END(copyin) -#endif -/* - * int copyinstr(const void *uaddr, void *kaddr, size_t len, size_t *done) - */ -ENTRY(copyinstr) - wr %g0, ASI_AIUS, %asi - _COPYSTR(%o0, %o1, %o2, %o3, a, %asi, E, E) - retl - mov %g1, %o0 -END(copyinstr) - -/* - * int copyout(const void *kaddr, void *uaddr, size_t len) - */ -ENTRY(copyout) - wr %g0, ASI_AIUS, %asi - _MEMCPY(%o1, %o0, %o2, a, %asi, E, E) - retl - clr %o0 -END(copyout) - - .globl copy_nofault_end -copy_nofault_end: - nop - -ENTRY(copy_fault) - retl - mov EFAULT, %o0 -END(copy_fault) - - .globl fs_nofault_begin -fs_nofault_begin: - nop - -/* - * Chatty aliases for fetch, store functions. - */ - .globl fubyte, fusword, fuword, subyte, susword, suword - .set fubyte, fuword8 - .set fusword, fuword16 - .set fuword, fuword64 - .set subyte, suword8 - .set susword, suword16 - .set suword, suword64 - - .globl casuword, fuptr, suptr - .set casuword, casuword64 - .set fuptr, fuword64 - .set suptr, suword64 - -/* - * int32_t casuword32(volatile int32_t *p, int32_t e, int32_t s) - */ -ENTRY(casuword32) - casa [%o0] ASI_AIUS, %o1, %o2 - retl - mov %o2, %o0 -END(casuword32) - -/* - * int64_t casuword64(volatile int64_t *p, int64_t e, int64_t s) - */ -ENTRY(casuword64) - casxa [%o0] ASI_AIUS, %o1, %o2 - retl - mov %o2, %o0 -END(casuword64) - -/* - * int fuword8(const void *base) - */ -ENTRY(fuword8) - retl - lduba [%o0] ASI_AIUS, %o0 -END(fuword8) - -/* - * int fuword16(const void *base) - */ -ENTRY(fuword16) - retl - lduha [%o0] ASI_AIUS, %o0 -END(fuword16) - -/* - * int32_t fuword32(const void *base) - */ -ENTRY(fuword32) - retl - lduwa [%o0] ASI_AIUS, %o0 -END(fuword32) - -/* - * int64_t fuword64(const void *base) - */ -ENTRY(fuword64) - retl - ldxa [%o0] ASI_AIUS, %o0 -END(fuword64) - -/* - * int suword8(const void *base, int word) - */ -ENTRY(suword8) - stba %o1, [%o0] ASI_AIUS - retl - clr %o0 -END(suword8) - -/* - * int suword16(const void *base, int word) - */ -ENTRY(suword16) - stha %o1, [%o0] ASI_AIUS - retl - clr %o0 -END(suword16) - -/* - * int suword32(const void *base, int32_t word) - */ -ENTRY(suword32) - stwa %o1, [%o0] ASI_AIUS - retl - clr %o0 -END(suword32) - -/* - * int suword64(const void *base, int64_t word) - */ -ENTRY(suword64) - stxa %o1, [%o0] ASI_AIUS - retl - clr %o0 -END(suword64) - - .globl fs_nofault_intr_begin -fs_nofault_intr_begin: - nop - -/* - * int fuswintr(const void *base) - */ -ENTRY(fuswintr) - retl - lduha [%o0] ASI_AIUS, %o0 -END(fuswintr) - -/* - * int suswintr(const void *base, int word) - */ -ENTRY(suswintr) - stha %o1, [%o0] ASI_AIUS - retl - clr %o0 -END(suswintr) - - .globl fs_nofault_intr_end -fs_nofault_intr_end: - nop - - .globl fs_nofault_end -fs_nofault_end: - nop - -ENTRY(fs_fault) - retl - mov -1, %o0 -END(fsfault) - - .globl fas_nofault_begin -fas_nofault_begin: - -/* - * int fasword8(u_long asi, uint64_t addr, uint8_t *val) - */ -ENTRY(fasword8) - wr %o0, 0, %asi - membar #Sync - lduba [%o1] %asi, %o3 - membar #Sync - stb %o3, [%o2] - retl - clr %o0 -END(fasword8) - -/* - * int fasword16(u_long asi, uint64_t addr, uint16_t *val) - */ -ENTRY(fasword16) - wr %o0, 0, %asi - membar #Sync - lduha [%o1] %asi, %o3 - membar #Sync - sth %o3, [%o2] - retl - clr %o0 -END(fasword16) - -/* - * int fasword32(u_long asi, uint64_t addr, uint32_t *val) - */ -ENTRY(fasword32) - wr %o0, 0, %asi - membar #Sync - lduwa [%o1] %asi, %o3 - membar #Sync - stw %o3, [%o2] - retl - clr %o0 -END(fasword32) - - .globl fas_nofault_end -fas_nofault_end: - nop - - .globl fas_fault -ENTRY(fas_fault) - retl - mov -1, %o0 -END(fas_fault) - - .globl fpu_fault_begin -fpu_fault_begin: - nop - - .globl fpu_fault_end -fpu_fault_end: - nop - - .globl fpu_fault_size - .set fpu_fault_size, fpu_fault_end - fpu_fault_begin - -ENTRY(longjmp) - set 1, %g3 - movrz %o1, %o1, %g3 - mov %o0, %g1 - ldx [%g1 + _JB_FP], %g2 -1: cmp %fp, %g2 - bl,a,pt %xcc, 1b - restore - bne,pn %xcc, 2f - ldx [%g1 + _JB_SP], %o2 - cmp %o2, %sp - blt,pn %xcc, 2f - movge %xcc, %o2, %sp - ldx [%g1 + _JB_PC], %o7 - retl - mov %g3, %o0 -2: PANIC("longjmp botch", %l1) -END(longjmp) - -ENTRY(setjmp) - stx %sp, [%o0 + _JB_SP] - stx %o7, [%o0 + _JB_PC] - stx %fp, [%o0 + _JB_FP] - retl - clr %o0 -END(setjmp) - -/* - * void ofw_entry(cell_t args[]) - */ -ENTRY(ofw_entry) - save %sp, -CCFSZ, %sp - SET(ofw_vec, %l7, %l6) - ldx [%l6], %l6 - rdpr %pil, %l7 - wrpr %g0, PIL_TICK, %pil - call %l6 - mov %i0, %o0 - wrpr %l7, 0, %pil - ret - restore %o0, %g0, %o0 -END(ofw_entry) - -#ifdef notyet -/* SUN4V_FIXME - uses a now illegal ASI */ -/* - * void ofw_exit(cell_t args[]) - */ -ENTRY(ofw_exit) - save %sp, -CCFSZ, %sp - flushw - wrpr %g0, PIL_TICK, %pil - SET(ofw_tba, %l7, %l5) - ldx [%l5], %l5 - wrpr %l5, 0, %tba ! restore the ofw trap table - SET(ofw_vec, %l7, %l6) - ldx [%l6], %l6 - SET(kstack0 + KSTACK_PAGES * PAGE_SIZE - PCB_SIZEOF, %l7, %l0) - sub %l0, SPOFF, %fp ! setup a stack in a locked page - sub %l0, SPOFF + CCFSZ, %sp - mov AA_DMMU_PCXR, %l3 ! set context 0 - stxa %g0, [%l3] ASI_DMMU - membar #Sync - wrpr %g0, 0, %tl ! force trap level 0 - call %l6 - mov %i0, %o0 - ! never to return -END(ofw_exit) - -#endif -ENTRY(set_mmfsa_scratchpad) - stxa %o0, [%g0]ASI_SCRATCHPAD - retl - nop -END(set_mmfsa_scratchpad) -ENTRY(set_pcpu_scratchpad) - mov SCRATCH_REG_PCPU, %g2 - stxa %o0, [%g0 + %g2]ASI_SCRATCHPAD - retl - nop -END(set_pcpu_scratchpad) -ENTRY(set_hash_kernel_scratchpad) - mov SCRATCH_REG_HASH_KERNEL, %g2 - stxa %o0, [%g0 + %g2]ASI_SCRATCHPAD - retl - nop -END(set_hash_kernel_scratchpad) -ENTRY(set_tsb_kernel_scratchpad) - mov SCRATCH_REG_TSB_KERNEL, %g2 - stxa %o0, [%g0 + %g2]ASI_SCRATCHPAD - retl - nop -END(set_tsb_kernel_scratchpad) - -ENTRY(set_hash_user_scratchpad) - mov SCRATCH_REG_HASH_USER, %g2 - stxa %o0, [%g0 + %g2]ASI_SCRATCHPAD - retl - nop -END(set_hash_user_scratchpad) -ENTRY(set_tsb_user_scratchpad) - mov SCRATCH_REG_TSB_USER, %g2 - stxa %o0, [%g0 + %g2]ASI_SCRATCHPAD - retl - nop -END(set_tsb_user_scratchpad) - - -/* - * %o0 ra - real address - * [%o1] lo - lower 64-bits - * [%o2] hi - upper 64-bits - */ - -ENTRY(load_real_dw) - save %sp, -SA(MINFRAME64), %sp - ldda [%g0 + %i0]ASI_LDTD_REAL, %l0 - stx %l0, [%i1] - stx %l1, [%i2] - restore - retl - nop -END(load_real_dw) - -/* - * %o0 = vaddr - * %o1 = ctxnum - */ -ENTRY(invlpg) - mov %o0, %o2 - mov %o1, %o3 - mov %g0, %o0 - mov %g0, %o1 - mov MAP_ITLB | MAP_DTLB, %o4 - mov MMU_DEMAP_PAGE, %o5 - ta FAST_TRAP - brz,pt %o0, 1f - nop - ba,pt %xcc, panic_bad_hcall - mov MMU_DEMAP_PAGE, %o1 -1: - retl - nop -END(invlpg) - - -/* - * %o0 = ctxnum - * - */ -ENTRY(invlctx) - cmp %o0, %g0 - bne %xcc, 2f - nop - MAGIC_TRAP_ON - MAGIC_EXIT -2: - mov %o0, %o2 - mov %g0, %o0 - mov %g0, %o1 - mov MAP_ITLB | MAP_DTLB, %o3 - mov MMU_DEMAP_CTX, %o5 - ta FAST_TRAP - brz,pt %o0, 1f - nop - ba,pt %xcc, panic_bad_hcall - mov MMU_DEMAP_CTX, %o1 -1: - retl - nop -END(invlctx) - -ENTRY(invltlb) - mov %g0, %o0 - mov %g0, %o1 - mov MAP_ITLB | MAP_DTLB, %o2 - mov MMU_DEMAP_ALL, %o5 - ta FAST_TRAP - brz,pt %o0, 1f - nop - ba,pt %xcc, panic_bad_hcall - mov MMU_DEMAP_ALL, %o1 -1: - retl - nop -END(invltlb) - - - /* - * panic_bad_hcall is called when a hcall returns - * unexpected error - * %o0 error number - * %o1 hcall number - */ - - .text -bad_hcall_error: - .asciz "hypervisor call 0x%x returned an unexpected error %d" - - -ENTRY(panic_bad_hcall) - mov %o0, %o2 - sethi %hi(bad_hcall_error), %o0 - or %o0, %lo(bad_hcall_error), %o0 - mov %o7, %o3 - call panic - mov %o3, %o7 -END(panic_bad_hcall) - - - -! %o0 = pa -! %o1 = size - -ENTRY(bzerophyspage) - save %sp, -SA(MINFRAME64), %sp - mov 8, %l1 - mov 16, %l2 - mov 24, %l3 - mov 32, %l4 - mov 40, %l5 - mov 48, %l6 - mov 56, %l7 -1: stxa %g0, [%i0]ASI_REAL - stxa %g0, [%i0 + %l1]ASI_REAL - stxa %g0, [%i0 + %l2]ASI_REAL - stxa %g0, [%i0 + %l3]ASI_REAL - stxa %g0, [%i0 + %l4]ASI_REAL - stxa %g0, [%i0 + %l5]ASI_REAL - stxa %g0, [%i0 + %l6]ASI_REAL - stxa %g0, [%i0 + %l7]ASI_REAL - sub %i1, 64, %i1 - brnz,pt %i1, 1b - add %i0, 64, %i0 - membar #Sync - ret - restore - -END(bzerophyspage) - -ENTRY(init_mondo) - ldx [PCPU(MONDO_DATA)], %g2 - stx %o0, [%g2] - stx %o1, [%g2+8] - stx %o2, [%g2+0x10] - stx %o3, [%g2+0x18] - stx %g0, [%g2+0x20] - stx %g0, [%g2+0x28] - stx %g0, [%g2+0x30] - stx %g0, [%g2+0x38] - retl - membar #Sync -END(init_mondo) - - -ENTRY(init_mondo_queue) - mov CPU_MONDO_QUEUE_TAIL, %g2 - ldxa [%g2]ASI_QUEUE, %g2 - mov CPU_MONDO_QUEUE_HEAD, %g6 - stxa %g2, [%g6]ASI_QUEUE - mov DEV_MONDO_QUEUE_TAIL, %g2 - ldxa [%g2]ASI_QUEUE, %g2 - mov DEV_MONDO_QUEUE_HEAD, %g6 - stxa %g2, [%g6]ASI_QUEUE - retl - membar #Sync -END(init_mondo_queue) - -#ifdef GPROF - -ENTRY(user) - nop - -ENTRY(btrap) - nop - -ENTRY(etrap) - nop - -ENTRY(bintr) - nop - -ENTRY(eintr) - nop - - -/* - * XXX including sys/gmon.h in genassym.c is not possible due to uintfptr_t - * badness. - */ -#define GM_STATE 0x0 -#define GMON_PROF_OFF 3 -#define GMON_PROF_HIRES 4 - - .globl _mcount - .set _mcount, __cyg_profile_func_enter - -ENTRY(__cyg_profile_func_enter) - SET(_gmonparam, %o3, %o2) - lduw [%o2 + GM_STATE], %o3 - cmp %o3, GMON_PROF_OFF - be,a,pn %icc, 1f - nop - SET(mcount, %o3, %o2) - jmpl %o2, %g0 - nop -1: retl - nop -END(__cyg_profile_func_enter) - -#ifdef GUPROF - -ENTRY(__cyg_profile_func_exit) - SET(_gmonparam, %o3, %o2) - lduw [%o2 + GM_STATE], %o3 - cmp %o3, GMON_PROF_HIRES - be,a,pn %icc, 1f - nop - SET(mexitcount, %o3, %o2) - jmpl %o2, %g0 - nop -1: retl - nop -END(__cyg_profile_func_exit) - -#endif /* GUPROF */ - -#endif /* GPROF */ diff --git a/sys/sun4v/sun4v/swtch.S b/sys/sun4v/sun4v/swtch.S deleted file mode 100644 index a3d8324a62ba..000000000000 --- a/sys/sun4v/sun4v/swtch.S +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include "assym.s" - - .register %g2, #ignore - .register %g3, #ignore - -#define PCB_REG %g6 - -#define MEMBAR_PRE membar #LoadStore|#StoreStore -#define MEMBAR_POST membar #LoadLoad - -#define ATOMIC_CLEAR_INT_BIT(addr, old, bit, new, label) \ - MEMBAR_PRE ; \ - ld [addr], old ; \ -label: andn old, bit, new ; \ - cas [addr], old, new ; \ - cmp old, new ; \ - bne,a,pn %icc, label ## b ; \ - ld [addr], old ; \ - MEMBAR_POST - -#define ATOMIC_SET_INT_BIT(addr, old, bit, new, label) \ - MEMBAR_PRE ; \ - ld [addr], old ; \ -label: or old, bit, new ; \ - cas [addr], old, new ; \ - cmp old, new ; \ - bne,a,pn %icc, label ## b ; \ - ld [addr], old ; \ - MEMBAR_POST -/* - * void cpu_throw(struct thread *old, struct thread *new) - */ -ENTRY(cpu_throw) - save %sp, -CCFSZ, %sp - flushw - ba %xcc, .Lsw1 - mov %i1, %i0 -END(cpu_throw) - -/* - * void cpu_switch(struct thread *old, struct thread *new) - */ -ENTRY(cpu_switch) - save %sp, -CCFSZ, %sp - ldx [PCPU(CURPCB)], PCB_REG - mov %i1, %i0 - - /* - * If the current thread was using floating point in the kernel, save - * its context. The userland floating point context has already been - * saved in that case. - */ - rd %fprs, %l2 - andcc %l2, FPRS_FEF, %g0 - bz,a,pt %xcc, 1f - nop - call savefpctx - add PCB_REG, PCB_KFP, %o0 - ba,a %xcc, 2f - nop - - /* - * If the current thread was using floating point in userland, save - * its context. - */ -1: sub PCB_REG, TF_SIZEOF, %l2 - ldx [%l2 + TF_FPRS], %l3 - andcc %l3, FPRS_FEF, %g0 - bz,a,pt %xcc, 2f - nop - call savefpctx - add PCB_REG, PCB_UFP, %o0 - andn %l3, FPRS_FEF, %l3 - stx %l3, [%l2 + TF_FPRS] - - ldx [PCB_REG + PCB_FLAGS], %l3 - or %l3, PCB_FEF, %l3 - stx %l3, [PCB_REG + PCB_FLAGS] - - /* - * Flush the windows out to the stack and save the current frame - * pointer and program counter. - */ -2: flushw - stx %fp, [PCB_REG + PCB_SP] - stx %i7, [PCB_REG + PCB_PC] - - - /* - * Load the new thread's frame pointer and program counter, and set - * the current thread and pcb. - */ -.Lsw1: -#if KTR_COMPILE & KTR_PROC & 0 - CATR(KTR_PROC, "cpu_switch: new td=%p pc=%#lx fp=%#lx" - , %g1, %g2, %g3, 7, 8, 9) - stx %i0, [%g1 + KTR_PARM1] - ldx [%i0 + TD_PCB], %g2 - ldx [%g2 + PCB_PC], %g3 - stx %g3, [%g1 + KTR_PARM2] - ldx [%g2 + PCB_SP], %g3 - stx %g3, [%g1 + KTR_PARM3] -9: -#endif - - ldx [%i0 + TD_PCB], %i1 - - stx %i0, [PCPU(CURTHREAD)] - stx %i1, [PCPU(CURPCB)] - - mov %i1, PCB_REG ! load in new PCB - - ldx [PCB_REG + PCB_SP], %fp - ldx [PCB_REG + PCB_PC], %i7 - sub %fp, CCFSZ, %sp - - /* - * Point to the pmaps of the new process, and of the last non-kernel - * process to run. - */ - ldx [%i0 + TD_PROC], %i2 - ldx [PCPU(PMAP)], %l2 - ldx [%i2 + P_VMSPACE], %i5 - add %i5, VM_PMAP, %i2 - -#if KTR_COMPILE & KTR_PROC & 0 - CATR(KTR_PROC, "cpu_switch: new pmap=%p old pmap=%p" - , %g1, %g2, %g3, 7, 8, 9) - stx %i2, [%g1 + KTR_PARM1] - stx %l2, [%g1 + KTR_PARM2] -9: -#endif - /* - * If they are the same we are done. - */ - cmp %l2, %i2 ! current pmap == new pmap? - be,a,pn %xcc, 5f - nop - ldx [%i2 + PM_CONTEXT], %l5 ! new context - ldx [%l2 + PM_CONTEXT], %l3 ! old context - cmp %g0, %l5 - be,pn %xcc, 5f ! new context == kernel? - ld [PCPU(CPUMASK)], %l4 - - brz %l3, 10f ! old context == kernel? - nop - - /* - * Mark the old pmap as no longer active on this CPU - */ - add %l2, PM_ACTIVE, %l2 - ATOMIC_CLEAR_INT_BIT(%l2, %l3, %l4, %l6, 8) - -10: - add %i2, PM_ACTIVE, %i3 - ATOMIC_SET_INT_BIT(%i3, %l3, %l4, %l6, 11) - - add %i2, PM_TLBACTIVE, %i3 - ATOMIC_SET_INT_BIT(%i3, %l3, %l4, %l6, 12) - - mov SCRATCH_REG_HASH_USER, %l6 - mov SCRATCH_REG_TSB_USER, %l7 - ldx [%i2 + PM_HASHSCRATCH], %l3 - ldx [%i2 + PM_TSBSCRATCH], %l4 - stx %i2, [PCPU(PMAP)] - - SET_SCRATCH(%l6,%l3) ! XXX we're assuming the - SET_SCRATCH(%l7,%l4) ! scratch values <= 32 bits - - - ldx [%i2 + PM_TSB_RA], %l3 - - mov MMU_CID_S, %l6 - - mov 1, %o0 - mov %l3, %o1 - mov MMU_TSB_CTXNON0, %o5 - ta FAST_TRAP - cmp %g0, %o0 - be %xcc, 4f - nop - MAGIC_TRAP_ON - MAGIC_EXIT - -4: /* - * install the new secondary context number in the cpu. - */ - - SET_MMU_CONTEXT(%l6, %l5) - membar #Sync - /* - * Done. Return and load the new process's window from the stack. - */ -5: ret - restore -END(cpu_switch) - -ENTRY(savectx) - save %sp, -CCFSZ, %sp - flushw - call savefpctx - add %i0, PCB_UFP, %o0 - stx %fp, [%i0 + PCB_SP] - stx %i7, [%i0 + PCB_PC] - ret - restore %g0, 0, %o0 -END(savectx) - -/* - * void savefpctx(uint32_t *); - */ -ENTRY(savefpctx) - wr %g0, FPRS_FEF, %fprs - std %f0, [%o0 + (0 * 64)] - std %f16, [%o0 + (1 * 64)] - std %f32, [%o0 + (2 * 64)] - std %f48, [%o0 + (3 * 64)] - retl - wr %g0, 0, %fprs -END(savefpctx) diff --git a/sys/sun4v/sun4v/tick.c b/sys/sun4v/sun4v/tick.c deleted file mode 100644 index d8cfd1cc16dc..000000000000 --- a/sys/sun4v/sun4v/tick.c +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * Copyright (c) 2001 Jake Burkholder. - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#ifdef DEBUG -#include -#endif - -SYSCTL_NODE(_machdep, OID_AUTO, tick, CTLFLAG_RD, 0, "tick statistics"); - -static int adjust_edges = 0; -SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_edges, CTLFLAG_RD, &adjust_edges, - 0, "total number of times tick interrupts got more than 12.5% behind"); - -static int adjust_excess = 0; -SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_excess, CTLFLAG_RD, &adjust_excess, - 0, "total number of ignored tick interrupts"); - -static int adjust_missed = 0; -SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_missed, CTLFLAG_RD, &adjust_missed, - 0, "total number of missed tick interrupts"); - -static int adjust_ticks = 0; -SYSCTL_INT(_machdep_tick, OID_AUTO, adjust_ticks, CTLFLAG_RD, &adjust_ticks, - 0, "total number of tick interrupts with adjustment"); - -static struct eventtimer tick_et; - -static int tick_et_start(struct eventtimer *et, - struct bintime *first, struct bintime *period); -static int tick_et_stop(struct eventtimer *et); -static void tick_intr(struct trapframe *); - -static uint64_t -tick_cputicks(void) -{ - - return (rd(tick)); -} - -void -cpu_initclocks(void) -{ - - intr_setup(PIL_TICK, tick_intr, -1, NULL, NULL); - - tick_et.et_name = "tick"; - tick_et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT | - ET_FLAGS_PERCPU; - tick_et.et_quality = 1000; - tick_et.et_frequency = tick_freq; - tick_et.et_min_period.sec = 0; - tick_et.et_min_period.frac = 0x00010000LLU << 32; /* To be safe. */ - tick_et.et_max_period.sec = 3600 * 24; /* No practical limit. */ - tick_et.et_max_period.frac = 0; - tick_et.et_start = tick_et_start; - tick_et.et_stop = tick_et_stop; - tick_et.et_priv = NULL; - et_register(&tick_et); - - cpu_initclocks_bsp(); -} - -static __inline void -tick_process(struct trapframe *tf) -{ - struct trapframe *oldframe; - struct thread *td; - - if (tick_et.et_active) { - td = curthread; - oldframe = td->td_intr_frame; - td->td_intr_frame = tf; - tick_et.et_event_cb(&tick_et, tick_et.et_arg); - td->td_intr_frame = oldframe; - } -} - -static void -tick_intr(struct trapframe *tf) -{ - u_long adj, ref, s, tick, tick_increment; - long delta; - int count; - -#ifdef DEBUG - if (curthread->td_critnest > 2 || curthread->td_critnest < 1) - panic("nested hardclock %d\n", curthread->td_critnest); -#endif - tick_increment = PCPU_GET(tickincrement); - /* - * The sequence of reading the TICK register, calculating the value - * of the next tick and writing it to the TICK_CMPR register must not - * be interrupted, not even by an IPI, otherwise a value that is in - * the past could be written in the worst case, causing hardclock to - * stop. - */ - adj = PCPU_GET(tickadj); - s = intr_disable_all(); - tick = rd(tick); - if (tick_increment != 0) - wrtickcmpr(tick + tick_increment - adj, 0); - else - wrtickcmpr(1L << 63, 0); - intr_restore_all(s); - - ref = PCPU_GET(tickref); - delta = tick - ref; - count = 0; - while (delta >= tick_increment) { - tick_process(tf); - delta -= tick_increment; - ref += tick_increment; - if (adj != 0) - adjust_ticks++; - count++; - if (tick_increment == 0) - break; - } - if (count > 0) { - adjust_missed += count - 1; - if (delta > (tick_increment >> 3)) { - if (adj == 0) - adjust_edges++; - adj = tick_increment >> 4; - } else - adj = 0; - } else { - adj = 0; - adjust_excess++; - } - PCPU_SET(tickref, ref); - PCPU_SET(tickadj, adj); -} - -void -tick_init(u_long clock) -{ - - tick_freq = clock; - tick_MHz = clock / 1000000; - set_cputicker(tick_cputicks, tick_freq, 0); -} - -static int -tick_et_start(struct eventtimer *et, - struct bintime *first, struct bintime *period) -{ - u_long fdiv, div; - u_long base; - register_t s; - - if (period != NULL) { - div = (tick_et.et_frequency * (period->frac >> 32)) >> 32; - if (period->sec != 0) - div += tick_et.et_frequency * period->sec; - } else - div = 0; - if (first != NULL) { - fdiv = (tick_et.et_frequency * (first->frac >> 32)) >> 32; - if (first->sec != 0) - fdiv += tick_et.et_frequency * first->sec; - } else - fdiv = div; - PCPU_SET(tickincrement, div); - - /* - * Try to make the tick interrupts as synchronously as possible on - * all CPUs to avoid inaccuracies for migrating processes. Leave out - * one tick to make sure that it is not missed. - */ - critical_enter(); - PCPU_SET(tickadj, 0); - s = intr_disable_all(); - base = rd(tick); - if (div != 0) - base = roundup(base, div); - PCPU_SET(tickref, base); - wrtickcmpr(base + fdiv, 0); - intr_restore_all(s); - critical_exit(); - return (0); -} - -static int -tick_et_stop(struct eventtimer *et) -{ - - PCPU_SET(tickincrement, 0); - wrtickcmpr(1L << 63, 0); - return (0); -} - diff --git a/sys/sun4v/sun4v/trap.c b/sys/sun4v/sun4v/trap.c deleted file mode 100644 index e62859998557..000000000000 --- a/sys/sun4v/sun4v/trap.c +++ /dev/null @@ -1,633 +0,0 @@ -/*- - * Copyright (c) 2001, Jake Burkholder - * Copyright (C) 1994, David Greenman - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the University of Utah, and William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE 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. - * - * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * from: FreeBSD: src/sys/i386/i386/trap.c,v 1.197 2001/07/19 - * $FreeBSD$ - */ - -#include "opt_ddb.h" -#include "opt_ktr.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -void trap(struct trapframe *tf, int64_t type, uint64_t data); -void syscall(struct trapframe *tf); - -extern vm_paddr_t mmu_fault_status_area; - -static int trap_pfault(struct thread *td, struct trapframe *tf, int64_t type, uint64_t data); - -extern char copy_fault[]; -extern char copy_nofault_begin[]; -extern char copy_nofault_end[]; - -extern char fs_fault[]; -extern char fs_nofault_begin[]; -extern char fs_nofault_end[]; -extern char fs_nofault_intr_begin[]; -extern char fs_nofault_intr_end[]; - -extern char fas_fault[]; -extern char fas_nofault_begin[]; -extern char fas_nofault_end[]; - -const char *const trap_msg[] = { - "reserved", - "instruction access exception", - "instruction access error", - "instruction access protection", - "illtrap instruction", - "illegal instruction", - "privileged opcode", - "floating point disabled", - "floating point exception ieee 754", - "floating point exception other", - "tag overflow", - "division by zero", - "data access exception", - "data access error", - "data access protection", - "memory address not aligned", - "privileged action", - "async data error", - "trap instruction 16", - "trap instruction 17", - "trap instruction 18", - "trap instruction 19", - "trap instruction 20", - "trap instruction 21", - "trap instruction 22", - "trap instruction 23", - "trap instruction 24", - "trap instruction 25", - "trap instruction 26", - "trap instruction 27", - "trap instruction 28", - "trap instruction 29", - "trap instruction 30", - "trap instruction 31", - "fast instruction access mmu miss", - "fast data access mmu miss", - "interrupt", - "physical address watchpoint", - "virtual address watchpoint", - "corrected ecc error", - "spill", - "fill", - "fill", - "breakpoint", - "clean window", - "range check", - "fix alignment", - "integer overflow", - "syscall", - "restore physical watchpoint", - "restore virtual watchpoint", - "kernel stack fault", - "resumable error", - "nonresumable error" -}; - -const int trap_sig[] = { - SIGILL, /* reserved */ - SIGILL, /* instruction access exception */ - SIGILL, /* instruction access error */ - SIGILL, /* instruction access protection */ - SIGILL, /* illtrap instruction */ - SIGILL, /* illegal instruction */ - SIGBUS, /* privileged opcode */ - SIGFPE, /* floating point disabled */ - SIGFPE, /* floating point exception ieee 754 */ - SIGFPE, /* floating point exception other */ - SIGEMT, /* tag overflow */ - SIGFPE, /* division by zero */ - SIGILL, /* data access exception */ - SIGILL, /* data access error */ - SIGBUS, /* data access protection */ - SIGBUS, /* memory address not aligned */ - SIGBUS, /* privileged action */ - SIGBUS, /* async data error */ - SIGILL, /* trap instruction 16 */ - SIGILL, /* trap instruction 17 */ - SIGILL, /* trap instruction 18 */ - SIGILL, /* trap instruction 19 */ - SIGILL, /* trap instruction 20 */ - SIGILL, /* trap instruction 21 */ - SIGILL, /* trap instruction 22 */ - SIGILL, /* trap instruction 23 */ - SIGILL, /* trap instruction 24 */ - SIGILL, /* trap instruction 25 */ - SIGILL, /* trap instruction 26 */ - SIGILL, /* trap instruction 27 */ - SIGILL, /* trap instruction 28 */ - SIGILL, /* trap instruction 29 */ - SIGILL, /* trap instruction 30 */ - SIGILL, /* trap instruction 31 */ - SIGFPE, /* floating point error */ - SIGSEGV, /* fast data access mmu miss */ - -1, /* interrupt */ - -1, /* physical address watchpoint */ - -1, /* virtual address watchpoint */ - -1, /* corrected ecc error */ - SIGILL, /* spill */ - SIGILL, /* fill */ - SIGILL, /* fill */ - SIGTRAP, /* breakpoint */ - SIGILL, /* clean window */ - SIGILL, /* range check */ - SIGILL, /* fix alignment */ - SIGILL, /* integer overflow */ - SIGSYS, /* syscall */ - -1, /* restore physical watchpoint */ - -1, /* restore virtual watchpoint */ - -1, /* kernel stack fault */ -}; - -CTASSERT(sizeof(struct trapframe) == 256); - -int debugger_on_signal = 0; -#ifdef DEBUG -SYSCTL_INT(_debug, OID_AUTO, debugger_on_signal, CTLFLAG_RW, - &debugger_on_signal, 0, ""); -#endif - -/* - * This interface allows the client to safely take over the %tba by - * the prom's service. The prom will take care of the quiescence of - * interrupts and handle any pending soft interrupts. - * This call also sets the MMU fault status area for the CPU. - */ -void -set_mmfsa_traptable(void *tba_addr, uint64_t mmfsa_ra) -{ - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t tba_addr; - cell_t mmfsa_ra; - } args = { - (cell_t)"SUNW,set-trap-table", - 2, - }; - - args.tba_addr = (cell_t)tba_addr; - args.mmfsa_ra = mmfsa_ra; - ofw_entry(&args); -} - -void -trap_init(void) -{ - vm_paddr_t mmfsa; - - mmfsa = mmu_fault_status_area + (MMFSA_SIZE*curcpu); - - set_wstate(WSTATE_KERN); - set_mmfsa_scratchpad(mmfsa); - - init_mondo_queue(); - set_mmfsa_traptable(&tl0_base, mmfsa); -} - -void -trap(struct trapframe *tf, int64_t type, uint64_t data) -{ - struct thread *td; - struct proc *p; - int error, sig, ctx; - uint64_t trapno; - register_t addr; - ksiginfo_t ksi; - - td = curthread; - - CTR4(KTR_TRAP, "trap: %p type=%s (%s) pil=%#lx", td, - trap_msg[trapno], - (TRAPF_USERMODE(tf) ? "user" : "kernel"), rdpr(pil)); - - PCPU_INC(cnt.v_trap); - - trapno = (type & TRAP_MASK); - ctx = (type >> TRAP_CTX_SHIFT); - - if (((tf->tf_tstate & TSTATE_PRIV) == 0) || (ctx != 0)) { - KASSERT(td != NULL, ("trap: curthread NULL")); - KASSERT(td->td_proc != NULL, ("trap: curproc NULL")); - - p = td->td_proc; - td->td_pticks = 0; - td->td_frame = tf; - addr = tf->tf_tpc; - if (td->td_ucred != p->p_ucred) - cred_update_thread(td); - - switch (trapno) { - case T_DATA_MISS: - case T_DATA_PROTECTION: - addr = TLB_TAR_VA(data); - case T_INSTRUCTION_MISS: - sig = trap_pfault(td, tf, trapno, data); - break; - case T_FILL: - sig = rwindow_load(td, tf, 2); - break; - case T_FILL_RET: - sig = rwindow_load(td, tf, 1); - break; - case T_SPILL: - sig = rwindow_save(td); - break; - case T_DATA_EXCEPTION: - case T_DATA_ERROR: - case T_MEM_ADDRESS_NOT_ALIGNED: - printf("bad trap trapno=%ld data=0x%lx pc=0x%lx\n", - trapno, data, tf->tf_tpc); - if (tf->tf_tpc >= (u_long)copy_nofault_begin && - tf->tf_tpc <= (u_long)copy_nofault_end) { - tf->tf_tpc = (u_long)copy_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - sig = 0; - break; - } - if (tf->tf_tpc >= (u_long)fs_nofault_begin && - tf->tf_tpc <= (u_long)fs_nofault_end) { - tf->tf_tpc = (u_long)fs_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - sig = 0; - break; - } - - addr = data; - sig = trap_sig[trapno]; - break; - - default: - if (trapno < 0 || trapno >= T_MAX || - trap_sig[trapno] == -1) - panic("trap: bad trap type"); - sig = trap_sig[trapno]; - break; - } - - if (sig != 0) { - /* Translate fault for emulators. */ - if (p->p_sysent->sv_transtrap != NULL) { - sig = p->p_sysent->sv_transtrap(sig, - trapno); - } - if (debugger_on_signal && - (sig == 4 || sig == 10 || sig == 11)) - kdb_enter(KDB_WHY_TRAPSIG, "trapsig"); -#ifdef VERBOSE - if (sig == 4 || sig == 10 || sig == 11) - printf("trap: %ld:%s: 0x%lx at 0x%lx on cpu=%d sig=%d proc=%s\n", - trapno, trap_msg[trapno], data, tf->tf_tpc, curcpu, sig, curthread->td_name); -#endif - /* XXX I've renumbered the traps to largely reflect what the hardware uses - * so this will need to be re-visited - */ - ksiginfo_init_trap(&ksi); - ksi.ksi_signo = sig; - ksi.ksi_code = (int)trapno; /* XXX not POSIX */ - ksi.ksi_addr = (void *)addr; - ksi.ksi_trapno = (int)trapno; - trapsignal(td, &ksi); - } - - userret(td, tf); - mtx_assert(&Giant, MA_NOTOWNED); - } else { - KASSERT((type & T_KERNEL) != 0, - ("trap: kernel trap isn't - trap: %ld:%s: 0x%lx at 0x%lx on cpu=%d\n", - trapno, trap_msg[trapno], data, tf->tf_tpc, curcpu)); - - if (kdb_active) { - kdb_reenter(); - return; - } - - switch (trapno) { - case T_BREAKPOINT: - case T_KSTACK_FAULT: - error = (kdb_trap(trapno, 0, tf) == 0); - TF_DONE(tf); - break; - case T_DATA_MISS: - case T_DATA_PROTECTION: - case T_INSTRUCTION_MISS: - error = trap_pfault(td, tf, trapno, data); - break; - case T_DATA_EXCEPTION: - printf("data exception on 0x%lx at 0x%lx\n", data, tf->tf_tpc); - printf("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx\n", trapno, - trap_msg[trapno], data, tf->tf_tpc, tf->tf_tnpc); - case T_ILLEGAL_INSTRUCTION: - if (tf->tf_tpc > KERNBASE) { - printf("illinstr: 0x%lx\n", tf->tf_tpc); - printf("illinstr: 0x%x\n", *((uint32_t *)tf->tf_tpc)); - } - case T_DATA_ERROR: - case T_ALIGNMENT: - if (tf->tf_asi == ASI_AIUS) { - if (tf->tf_tpc >= (u_long)copy_nofault_begin && - tf->tf_tpc <= (u_long)copy_nofault_end) { - tf->tf_tpc = (u_long)copy_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - error = 0; - break; - } - - printf("ASI_AIUS but bad tpc\n"); - } - if (tf->tf_tpc >= (u_long)fs_nofault_begin && - tf->tf_tpc <= (u_long)fs_nofault_end) { - tf->tf_tpc = (u_long)fs_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - error = 0; - break; - } - printf("asi=0x%lx\n", tf->tf_asi); - error = 1; - break; - default: - printf("unchecked trap 0x%lx asi=0x%lx\n", trapno, tf->tf_asi); - error = 1; - break; - } - - if (error != 0) - panic("trap: %ld=%s: 0x%lx at 0x%lx:0x%lx error=%d asi=0x%lx", - trapno, trap_msg[trapno], data, tf->tf_tpc, - tf->tf_tnpc, error, tf->tf_asi); - } - CTR1(KTR_TRAP, "trap: td=%p return", td); -} - -static int -trap_pfault(struct thread *td, struct trapframe *tf, int64_t type, uint64_t data) -{ - struct vmspace *vm; - struct proc *p; - vm_offset_t va; - vm_prot_t prot; - u_long ctx; - int rv; - - if (td == NULL) - return (-1); - - p = td->td_proc; - - rv = KERN_SUCCESS; - ctx = TLB_TAR_CTX(data); - type = type & ~T_KERNEL; - va = TLB_TAR_VA(data); - - - if (data > VM_MIN_DIRECT_ADDRESS) - printf("trap_pfault(type=%ld, data=0x%lx, tpc=0x%lx, ctx=0x%lx)\n", - type, data, tf->tf_tpc, ctx); - -#if 0 - CTR4(KTR_TRAP, "trap_pfault: td=%p pm_ctx=%#lx va=%#lx ctx=%#lx", - td, p->p_vmspace->vm_pmap.pm_context, va, ctx); -#endif - KASSERT(td->td_pcb != NULL, ("trap_pfault: pcb NULL")); - KASSERT(td->td_proc != NULL, ("trap_pfault: curproc NULL")); - KASSERT(td->td_proc->p_vmspace != NULL, ("trap_pfault: vmspace NULL")); - - - if (type == T_DATA_PROTECTION) - prot = VM_PROT_WRITE; - else { - if (type == T_DATA_MISS) - prot = VM_PROT_READ; - else - prot = VM_PROT_READ | VM_PROT_EXECUTE; - } - - if (ctx != TLB_CTX_KERNEL) { - if ((tf->tf_tstate & TSTATE_PRIV) != 0 && - (tf->tf_tpc >= (u_long)fs_nofault_intr_begin && - tf->tf_tpc <= (u_long)fs_nofault_intr_end)) { - tf->tf_tpc = (u_long)fs_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - return (0); - } - - /* - * This is a fault on non-kernel virtual memory. - */ - vm = p->p_vmspace; - - /* - * Keep swapout from messing with us during this - * critical time. - */ - PROC_LOCK(p); - ++p->p_lock; - PROC_UNLOCK(p); - - /* Fault in the user page. */ - rv = vm_fault(&vm->vm_map, va, prot, VM_FAULT_NORMAL); - - /* - * Now the process can be swapped again. - */ - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - } else { - /* - * This is a fault on kernel virtual memory. Attempts to - * access kernel memory from user mode cause privileged - * action traps, not page fault. - */ - KASSERT(tf->tf_tstate & TSTATE_PRIV, - ("trap_pfault: fault on nucleus context from user mode")); - - /* - * Don't have to worry about process locking or stacks in the - * kernel. - */ - rv = vm_fault(kernel_map, va, prot, VM_FAULT_NORMAL); - } - - CTR3(KTR_TRAP, "trap_pfault: return td=%p va=%#lx rv=%d", - td, va, rv); - if (rv == KERN_SUCCESS) - return (0); - if (ctx != TLB_CTX_KERNEL && (tf->tf_tstate & TSTATE_PRIV) != 0) { - if (tf->tf_tpc >= (u_long)fs_nofault_begin && - tf->tf_tpc <= (u_long)fs_nofault_end) { - tf->tf_tpc = (u_long)fs_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - return (0); - } - if (tf->tf_tpc >= (u_long)copy_nofault_begin && - tf->tf_tpc <= (u_long)copy_nofault_end) { - tf->tf_tpc = (u_long)copy_fault; - tf->tf_tnpc = tf->tf_tpc + 4; - return (0); - } - } - return ((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV); -} - -/* Maximum number of arguments that can be passed via the out registers. */ -#define REG_MAXARGS 6 - -int -cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa) -{ - struct trapframe *tf; - struct proc *p; - register_t *argp; - int reg; - int regcnt; - int error; - - p = td->td_proc; - tf = td->td_frame; - reg = 0; - regcnt = REG_MAXARGS; - - sa->code = tf->tf_global[1]; - - if (sa->code == SYS_syscall || sa->code == SYS___syscall) { - sa->code = tf->tf_out[reg++]; - regcnt--; - } - - if (p->p_sysent->sv_mask) - sa->code &= p->p_sysent->sv_mask; - if (sa->code >= p->p_sysent->sv_size) - sa->callp = &p->p_sysent->sv_table[0]; - else - sa->callp = &p->p_sysent->sv_table[sa->code]; - - sa->narg = sa->callp->sy_narg; - KASSERT(sa->narg <= sizeof(sa->args) / sizeof(sa->args[0]), - ("Too many syscall arguments!")); - error = 0; - argp = sa->args; - bcopy(&tf->tf_out[reg], sa->args, sizeof(sa->args[0]) * regcnt); - if (sa->narg > regcnt) - error = copyin((void *)(tf->tf_out[6] + SPOFF + - offsetof(struct frame, fr_pad[6])), &sa->args[regcnt], - (sa->narg - regcnt) * sizeof(sa->args[0])); - if (error == 0) { - td->td_retval[0] = 0; - td->td_retval[1] = 0; - } - - return (error); -} - -/* - * Syscall handler. The arguments to the syscall are passed in the o registers - * by the caller, and are saved in the trap frame. The syscall number is passed - * in %g1 (and also saved in the trap frame). - */ -void -syscall(struct trapframe *tf) -{ - struct thread *td; - struct syscall_args sa; - int error; - - td = curthread; - td->td_frame = tf; - - KASSERT(td != NULL, ("trap: curthread NULL")); - KASSERT(td->td_proc != NULL, ("trap: curproc NULL")); - - /* - * For syscalls, we don't want to retry the faulting instruction - * (usually), instead we need to advance one instruction. - */ - td->td_pcb->pcb_tpc = tf->tf_tpc; - TF_DONE(tf); - - error = syscallenter(td, &sa); - syscallret(td, error, &sa); -} - diff --git a/sys/sun4v/sun4v/trap_trace.S b/sys/sun4v/sun4v/trap_trace.S deleted file mode 100644 index 03341c90751f..000000000000 --- a/sys/sun4v/sun4v/trap_trace.S +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 John Birrell jb@freebsd.org - * 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 -__FBSDID("$FreeBSD$") - -#include "opt_trap_trace.h" - -#include - - .data - .globl trap_trace_entry - .align 64 -trap_trace_entry: - .skip MAXCPU * TRAP_TRACE_ENTRIES * 64 diff --git a/sys/sun4v/sun4v/tsb.c b/sys/sun4v/sun4v/tsb.c deleted file mode 100644 index 7ea8d0442645..000000000000 --- a/sys/sun4v/sun4v/tsb.c +++ /dev/null @@ -1,284 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - - -#include "opt_ddb.h" -#include "opt_pmap.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -CTASSERT(sizeof(tte_t) == sizeof(uint64_t)); -#define TSB_MASK(tsb) ((tsb->hti_ntte) - 1) -/* make TSB start off at the same size as the hash */ -#define TSB_SIZE 8 - -#ifdef DEBUG_TSB -#define DPRINTF printf -#else -#define DPRINTF(...) -#endif - -void tsb_sysinit(void); - -void -tsb_init(hv_tsb_info_t *hvtsb, uint64_t *scratchval, uint64_t page_shift) -{ - void *ptr; - int npages = (1 << page_shift); - - ptr = pmap_alloc_zeroed_contig_pages(npages, npages*PAGE_SIZE); - - if ((((uint64_t)ptr) & (npages*PAGE_SIZE - 1)) != 0) - panic("vm_page_alloc_contig allocated unaligned pages: %p", - ptr); - - hvtsb->hti_idxpgsz = TTE8K; - hvtsb->hti_assoc = 1; - hvtsb->hti_ntte = (npages*PAGE_SIZE >> TTE_SHIFT); - hvtsb->hti_ctx_index = -1; /* TSBs aren't shared so if we don't - * set the context in the TTEs we can - * simplify miss handling slightly - */ - hvtsb->hti_pgszs = TSB8K; - hvtsb->hti_rsvd = 0; - hvtsb->hti_ra = TLB_DIRECT_TO_PHYS((vm_offset_t)ptr); - - *scratchval = ((uint64_t) ptr) | page_shift; -} - -void -tsb_deinit(hv_tsb_info_t *hvtsb) -{ - vm_page_t m, tm; - int i; - - - m = PHYS_TO_VM_PAGE((vm_paddr_t)hvtsb->hti_ra); - for (i = 0, tm = m; i < TSB_SIZE; i++, m++) { - tm->wire_count--; - atomic_subtract_int(&cnt.v_wire_count, 1); - vm_page_free(tm); - } -} - - -void -tsb_assert_invalid(hv_tsb_info_t *tsb, vm_offset_t va) -{ - vm_paddr_t tsb_load_pa; - uint64_t tsb_index, tsb_shift, tte_tag, tte_data; - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - tsb_index = (va >> tsb_shift) & TSB_MASK(tsb); - tsb_load_pa = tsb->hti_ra + 2*tsb_index*sizeof(uint64_t); - load_real_dw(tsb_load_pa, &tte_tag, &tte_data); - if (tte_tag == 0 && tte_data == 0) - return; - printf("tsb_shift=0x%lx tsb_index=0x%lx\n", tsb_shift, tsb_index); - printf("tte_tag=0x%lx tte_data=0x%lx TSB_MASK=%lx\n", tte_tag, tte_data, (uint64_t)TSB_MASK(tsb)); - panic("non-zero entry found where not expected"); - -} - -void -tsb_set_tte_real(hv_tsb_info_t *tsb, vm_offset_t index_va, vm_offset_t tag_va, - uint64_t tte_data, uint64_t ctx) -{ - vm_paddr_t tsb_store_pa; - uint64_t tsb_index, tsb_shift, tte_tag; - DPRINTF("tsb_set_tte index_va: 0x%lx tag_va: 0x%lx idxpgsz: %x ", - index_va, tag_va, tsb->hti_idxpgsz); - - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - - tsb_index = (index_va >> tsb_shift) & TSB_MASK(tsb); - DPRINTF("tsb_index_absolute: 0x%lx tsb_index: 0x%lx\n", (index_va >> tsb_shift), tsb_index); - tsb_store_pa = tsb->hti_ra + 2*tsb_index*sizeof(uint64_t); - - /* store new value with valid bit cleared - * to avoid invalid intermediate value; - */ - store_real(tsb_store_pa + sizeof(uint64_t), tte_data); - tte_tag = (ctx << TTARGET_CTX_SHIFT) | (tag_va >> TTARGET_VA_SHIFT); - store_real(tsb_store_pa, tte_tag); -} - - -void -tsb_set_tte(hv_tsb_info_t *tsb, vm_offset_t va, uint64_t tte_data, uint64_t ctx) -{ - - uint64_t tsb_index, tsb_shift, tte_tag; - tte_t *entry; - - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - tsb_index = (va >> tsb_shift) & TSB_MASK(tsb); - entry = (tte_t *)TLB_PHYS_TO_DIRECT(tsb->hti_ra + 2*tsb_index*sizeof(uint64_t)); - tte_tag = (ctx << TTARGET_CTX_SHIFT) | (va >> TTARGET_VA_SHIFT); - /* store new value with valid bit cleared - * to avoid invalid intermediate value; - */ - *(entry + 1) = 0; - membar(StoreLoad); - *(entry) = tte_tag; - *(entry + 1) = tte_data; - membar(Sync); -} - - -void -tsb_clear(hv_tsb_info_t *tsb) -{ - hwblkclr((void *)TLB_PHYS_TO_DIRECT(tsb->hti_ra), tsb->hti_ntte << TTE_SHIFT); -} - -void -tsb_clear_tte(hv_tsb_info_t *tsb, vm_offset_t va) -{ - tte_t *entry; - uint64_t tsb_index, tsb_shift; - - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - tsb_index = (va >> tsb_shift) & TSB_MASK(tsb); - entry = (tte_t *)TLB_PHYS_TO_DIRECT(tsb->hti_ra + 2*tsb_index*sizeof(uint64_t)); - - *(entry + 1) = 0; - - membar(Sync); -} - -void -tsb_clear_range(hv_tsb_info_t *tsb, vm_offset_t sva, vm_offset_t eva) -{ - vm_offset_t tva; - uint64_t tsb_index, tsb_shift, tsb_mask; - tte_t *entry; - - tsb_mask = TSB_MASK(tsb); - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - - for (tva = sva; tva < eva; tva += PAGE_SIZE) { - tsb_index = (tva >> tsb_shift) & tsb_mask; - entry = (tte_t *)TLB_PHYS_TO_DIRECT(tsb->hti_ra + 2*tsb_index*sizeof(uint64_t)); - *(entry + 1) = 0; - } - - membar(Sync); -} - -tte_t -tsb_get_tte(hv_tsb_info_t *tsb, vm_offset_t va) -{ - tte_t *entry; - uint64_t tsb_index, tsb_shift, tte_tag, tte_data; - - tsb_shift = TTE_PAGE_SHIFT(tsb->hti_idxpgsz); - tsb_index = (va >> tsb_shift) & TSB_MASK(tsb); - entry = (tte_t *)TLB_PHYS_TO_DIRECT(tsb->hti_ra + 2*tsb_index*sizeof(uint64_t)); - tte_tag = *(entry); - tte_data = *(entry + 1); - - if ((tte_tag << TTARGET_VA_SHIFT) == (va & ~PAGE_MASK_4M)) - return tte_data; - - return (0UL); -} - -tte_t -tsb_lookup_tte(vm_offset_t va, uint64_t ctx) -{ - tte_t tte_data; - - tte_data = 0; - - if ((tte_data = tsb_get_tte(&kernel_td[TSB4M_INDEX], va)) != 0) - goto done; - - /* - * handle user data - */ -done: - return tte_data; -} - -uint64_t -tsb_set_scratchpad_kernel(hv_tsb_info_t *tsb) -{ - uint64_t tsb_shift, tsb_scratch; - tsb_shift = ffs(tsb->hti_ntte >> (PAGE_SHIFT - TTE_SHIFT)) - 1; - tsb_scratch = TLB_PHYS_TO_DIRECT(tsb->hti_ra) | tsb_shift; - - set_tsb_kernel_scratchpad(tsb_scratch); - membar(Sync); - return tsb_scratch; -} - -uint64_t -tsb_set_scratchpad_user(hv_tsb_info_t *tsb) -{ - uint64_t tsb_shift, tsb_scratch; - tsb_shift = ffs(tsb->hti_ntte >> (PAGE_SHIFT - TTE_SHIFT)) - 1; - tsb_scratch = TLB_PHYS_TO_DIRECT(tsb->hti_ra) | tsb_shift; - set_tsb_user_scratchpad(tsb_scratch); - membar(Sync); - return tsb_scratch; -} - -int -tsb_size(hv_tsb_info_t *hvtsb) -{ - return (hvtsb->hti_ntte >> (PAGE_SHIFT - TTE_SHIFT)); -} - -int -tsb_page_shift(pmap_t pmap) -{ - return (pmap->pm_tsbscratch & PAGE_MASK); -} diff --git a/sys/sun4v/sun4v/tte.c b/sys/sun4v/sun4v/tte.c deleted file mode 100644 index 997633690817..000000000000 --- a/sys/sun4v/sun4v/tte.c +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include "opt_ddb.h" -#include "opt_pmap.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -void -tte_clear_phys_bit(vm_page_t m, uint64_t flags) -{ - pv_entry_t pv; - tte_t active_flags = (flags & ~VTD_SW_W); - - if (m->flags & PG_FICTITIOUS) - return; - - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - /* - * Loop over all current mappings setting/clearing as appropos If - * setting RO do we need to clear the VAC? - */ - TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { - tte_t otte_data, matchbits; - pmap_t pmap; - - pmap = pv->pv_pmap; - PMAP_LOCK(pmap); - otte_data = tte_hash_clear_bits(pmap->pm_hash, pv->pv_va, flags); - if ((matchbits = (otte_data & active_flags)) != 0) { - if ((otte_data & (VTD_SW_W|VTD_W)) == (VTD_SW_W|VTD_W)) - vm_page_dirty(m); - pmap_invalidate_page(pmap, pv->pv_va, TRUE); - } - PMAP_UNLOCK(pmap); - } -} - -boolean_t -tte_get_phys_bit(vm_page_t m, uint64_t flags) -{ - - pv_entry_t pv; - pmap_t pmap; - boolean_t rv; - - rv = FALSE; - if (m->flags & PG_FICTITIOUS) - return (rv); - - mtx_assert(&vm_page_queue_mtx, MA_OWNED); - TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { - tte_t otte_data; - - pmap = pv->pv_pmap; - otte_data = tte_hash_lookup(pmap->pm_hash, pv->pv_va); - if ((rv = ((otte_data & flags) != 0))) - break; - } - - return (rv); -} - -void -tte_clear_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags) -{ - (void)tte_hash_clear_bits(pmap->pm_hash, va, flags); -} - -void -tte_set_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags) -{ - UNIMPLEMENTED; -} - -boolean_t -tte_get_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags) -{ - tte_t tte_data; - - tte_data = tte_hash_lookup(pmap->pm_hash, va); - - return ((tte_data & flags) == flags); -} diff --git a/sys/sun4v/sun4v/tte_hash.c b/sys/sun4v/sun4v/tte_hash.c deleted file mode 100644 index a02c93b535a4..000000000000 --- a/sys/sun4v/sun4v/tte_hash.c +++ /dev/null @@ -1,656 +0,0 @@ -/*- - * Copyright (c) 2006 Kip Macy - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef DEBUG -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#define HASH_SIZE (1 << HASH_ENTRY_SHIFT) -#define HASH_MASK(th) ((1<<(th->th_shift+PAGE_SHIFT-THE_SHIFT))-1) -#define NULL_TAG 0 -#define MAGIC_VALUE 0xcafebabe - -struct tte_hash_entry; -struct of_field; - -#define MAX_FRAGMENT_ENTRIES ((PAGE_SIZE / sizeof(struct tte_hash_entry)) - 1) - -typedef struct tte_hash_field_ { - uint64_t tag; - uint64_t data; -} tte_hash_field, *tte_hash_field_t; - -struct of_field { - int16_t count; - uint8_t lock; - uint8_t pad; - uint32_t flags; - struct tte_hash_entry *next; -}; - -typedef struct tte_hash_entry { - tte_hash_field the_fields[HASH_ENTRIES]; - struct of_field of; -} *tte_hash_entry_t; - -struct fragment_header { - struct tte_hash_fragment *fh_next; - uint8_t fh_count; - uint8_t fh_free_head; - uint8_t pad[sizeof(struct tte_hash_entry) - 10]; -}; - -CTASSERT(sizeof(struct fragment_header) == sizeof(struct tte_hash_entry)); - -SLIST_HEAD(tte_hash_list, tte_hash); - -struct tte_hash_list hash_free_list[PAGE_SHIFT]; - -struct tte_hash { - uint16_t th_shift; /* effective size in pages */ - uint16_t th_context; /* TLB context */ - uint32_t th_entries; /* # pages held */ - tte_hash_entry_t th_hashtable; /* hash of TTEs */ - struct tte_hash_fragment *th_fhhead; - struct tte_hash_fragment *th_fhtail; - SLIST_ENTRY(tte_hash) th_next; -}; - -struct tte_hash_fragment { - struct fragment_header thf_head; - struct tte_hash_entry thf_entries[MAX_FRAGMENT_ENTRIES]; -}; - -CTASSERT(sizeof(struct tte_hash_fragment) == PAGE_SIZE); - - -static struct tte_hash kernel_tte_hash; -/* - * Data for the tte_hash allocation mechanism - */ -static uma_zone_t thzone; -static struct vm_object thzone_obj; -static int tte_hash_count = 0, tte_hash_max = 0; - -extern uint64_t hash_bucket_lock(tte_hash_field_t fields); -extern void hash_bucket_unlock(tte_hash_field_t fields, uint64_t s); - -static tte_hash_t -get_tte_hash(void) -{ - tte_hash_t th; - - th = uma_zalloc(thzone, M_NOWAIT); - - KASSERT(th != NULL, ("tte_hash allocation failed")); - tte_hash_count++; - return th; - -} - -static __inline void -free_tte_hash(tte_hash_t th) -{ - tte_hash_count--; - uma_zfree(thzone, th); -} - -static tte_hash_t -tte_hash_cached_get(int shift) -{ - tte_hash_t th; - struct tte_hash_list *head; - - th = NULL; - head = &hash_free_list[shift]; - if (!SLIST_EMPTY(head)) { - th = SLIST_FIRST(head); - SLIST_REMOVE_HEAD(head, th_next); - } - return (th); -} - -static void -tte_hash_cached_free(tte_hash_t th) -{ - th->th_context = 0xffff; - SLIST_INSERT_HEAD(&hash_free_list[th->th_shift - HASH_ENTRY_SHIFT], th, th_next); -} - -void -tte_hash_init(void) -{ - int i; - - thzone = uma_zcreate("TTE_HASH", sizeof(struct tte_hash), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); - tte_hash_max = maxproc; - uma_zone_set_obj(thzone, &thzone_obj, tte_hash_max); - for (i = 0; i < PAGE_SHIFT; i++) - SLIST_INIT(&hash_free_list[i]); -} - -tte_hash_t -tte_hash_kernel_create(vm_offset_t va, uint16_t shift, vm_paddr_t fragment_page) -{ - tte_hash_t th; - - th = &kernel_tte_hash; - th->th_shift = shift; - th->th_entries = 0; - th->th_context = 0; - th->th_hashtable = (tte_hash_entry_t)va; - th->th_fhtail = th->th_fhhead = (void *)TLB_PHYS_TO_DIRECT(fragment_page); - - return (th); -} - -static inline void * -alloc_zeroed_page(void) -{ - vm_page_t m; - static int color; - void *ptr; - - m = NULL; - - while (m == NULL) { - m = vm_page_alloc(NULL, color++, - VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | - VM_ALLOC_ZERO); - - if (m == NULL) - VM_WAIT; - } - - if ((m->flags & PG_ZERO) == 0) - pmap_zero_page(m); - - ptr = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)); - return (ptr); -} - -static inline void -free_fragment_pages(void *ptr) -{ - struct tte_hash_fragment *fh; - vm_page_t m; - - for (fh = ptr; fh != NULL; fh = fh->thf_head.fh_next) { - m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)fh)); - m->wire_count--; - atomic_subtract_int(&cnt.v_wire_count, 1); - vm_page_free(m); - } -} - -static inline tte_hash_t -_tte_hash_create(uint64_t context, uint64_t *scratchval, uint16_t shift) -{ - tte_hash_t th; - - th = get_tte_hash(); - th->th_shift = shift; - th->th_entries = 0; - th->th_context = (uint16_t)context; - - th->th_hashtable = pmap_alloc_zeroed_contig_pages((1 << shift), PAGE_SIZE); - - th->th_fhtail = th->th_fhhead = alloc_zeroed_page(); - KASSERT(th->th_fhtail != NULL, ("th->th_fhtail == NULL")); - - if (scratchval) - *scratchval = (uint64_t)((vm_offset_t)th->th_hashtable) | ((vm_offset_t)(1 << shift)); - - return (th); -} - - -tte_hash_t -tte_hash_create(uint64_t context, uint64_t *scratchval) -{ - return (_tte_hash_create(context, scratchval, HASH_ENTRY_SHIFT)); -} - -void -tte_hash_destroy(tte_hash_t th) -{ - tte_hash_cached_free(th); -} - -static void -_tte_hash_reset(tte_hash_t th) -{ - - free_fragment_pages(th->th_fhhead->thf_head.fh_next); - - th->th_fhtail = th->th_fhhead; - hwblkclr(th->th_fhhead, PAGE_SIZE); -#if 0 - if (th->th_entries != 0) -#endif - hwblkclr(th->th_hashtable, (1 << (th->th_shift + PAGE_SHIFT))); - th->th_entries = 0; -} - -tte_hash_t -tte_hash_reset(tte_hash_t th, uint64_t *scratchval) -{ - tte_hash_t newth; - - if (th->th_shift != HASH_ENTRY_SHIFT && (newth = tte_hash_cached_get(0)) != NULL) { - newth->th_context = th->th_context; - tte_hash_cached_free(th); - *scratchval = (uint64_t)((vm_offset_t)newth->th_hashtable) | ((vm_offset_t)HASH_SIZE); - } else { - newth = th; - } - _tte_hash_reset(newth); - - return (newth); -} - -static __inline void -tte_hash_set_field(tte_hash_field_t field, uint64_t tag, tte_t tte) -{ - field->tag = tag; - field->data = tte | (field->data & VTD_LOCK); -} - -static __inline tte_hash_entry_t -find_entry(tte_hash_t th, vm_offset_t va, int page_shift) -{ - uint64_t hash_index; - - hash_index = (va >> page_shift) & HASH_MASK(th); - return (&th->th_hashtable[hash_index]); -} - -static __inline tte_hash_entry_t -tte_hash_lookup_last_entry(tte_hash_entry_t entry) -{ - - while (entry->of.next) - entry = entry->of.next; - - return (entry); -} - -static tte_hash_entry_t -tte_hash_allocate_fragment_entry(tte_hash_t th) -{ - struct tte_hash_fragment *fh; - tte_hash_entry_t newentry; - - fh = th->th_fhtail; - if (fh->thf_head.fh_free_head == MAX_FRAGMENT_ENTRIES) { - fh = th->th_fhtail = fh->thf_head.fh_next = alloc_zeroed_page(); - fh->thf_head.fh_free_head = 1; -#ifdef NOISY_DEBUG - printf("new fh=%p \n", fh); -#endif - } - newentry = &fh->thf_entries[fh->thf_head.fh_free_head]; - - fh->thf_head.fh_free_head++; - fh->thf_head.fh_count++; - - return (newentry); -} - -/* - * if a match for va is found the tte value is returned - * and if field is non-null field will point to that entry - * - * - */ -static __inline tte_t -_tte_hash_lookup(tte_hash_entry_t entry, tte_t tte_tag, tte_hash_field_t *field) -{ - int i; - tte_t tte_data; - tte_hash_field_t fields; - - tte_data = 0; - do { - fields = entry->the_fields; - for (i = 0; i < entry->of.count; i++) { - if (fields[i].tag == tte_tag) { - tte_data = (fields[i].data & ~VTD_LOCK); - *field = &fields[i]; - goto done; - } - } -#ifdef DEBUG - if (entry->of.next && entry->of.flags != MAGIC_VALUE) - panic("overflow pointer not null without flags set entry= %p next=%p flags=0x%x count=%d", - entry, entry->of.next, entry->of.flags, entry->of.count); -#endif - entry = entry->of.next; - } while (entry); - -done: - return (tte_data); -} - - -static __inline void -_tte_hash_lookup_last(tte_hash_entry_t entry, tte_hash_field_t *field) -{ - - tte_hash_field_t fields; - - fields = entry->the_fields; - - while (entry->of.next && (entry->of.next->of.count > 1)) - entry = entry->of.next; - - if (entry->of.next && entry->of.next->of.count == 1) { - *field = &entry->of.next->the_fields[0]; - entry->of.next = NULL; - entry->of.flags = 0; - } else { -#ifdef DEBUG - if (entry->of.count == 0) - panic("count zero"); -#endif - *field = &entry->the_fields[--entry->of.count]; - } -} - -tte_t -tte_hash_clear_bits(tte_hash_t th, vm_offset_t va, uint64_t flags) -{ - uint64_t s; - tte_hash_entry_t entry; - tte_t otte_data, tte_tag; - tte_hash_field_t field = NULL; - - /* XXX - only handle 8K pages for now */ - entry = find_entry(th, va, PAGE_SHIFT); - - tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT)); - - s = hash_bucket_lock(entry->the_fields); - if((otte_data = _tte_hash_lookup(entry, tte_tag, &field)) != 0) - tte_hash_set_field(field, field->tag, field->data & ~flags); - hash_bucket_unlock(entry->the_fields, s); - return (otte_data); -} - -tte_t -tte_hash_delete(tte_hash_t th, vm_offset_t va) -{ - uint64_t s; - tte_hash_entry_t entry; - tte_t tte_data, tte_tag; - tte_hash_field_t lookup_field = NULL; - tte_hash_field_t last_field = NULL; - - /* XXX - only handle 8K pages for now */ - entry = find_entry(th, va, PAGE_SHIFT); - - tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT)); - - s = hash_bucket_lock(entry->the_fields); - - if ((tte_data = _tte_hash_lookup(entry, tte_tag, &lookup_field)) == 0) - goto done; - - _tte_hash_lookup_last(entry, &last_field); - -#ifdef DEBUG - if (last_field->tag == 0) { - hash_bucket_unlock(entry->the_fields, s); - panic("lookup_last failed for va=0x%lx\n", va); - } -#endif - /* move last field's values in to the field we are deleting */ - if (lookup_field != last_field) - tte_hash_set_field(lookup_field, last_field->tag, last_field->data); - - tte_hash_set_field(last_field, 0, 0); -done: - hash_bucket_unlock(entry->the_fields, s); - if (tte_data) - th->th_entries--; - - return (tte_data); -} - -static __inline int -tte_hash_insert_locked(tte_hash_t th, tte_hash_entry_t entry, uint64_t tte_tag, tte_t tte_data) -{ - tte_hash_entry_t lentry; - - lentry = tte_hash_lookup_last_entry(entry); - - if (lentry->of.count == HASH_ENTRIES) - return -1; - tte_hash_set_field(&lentry->the_fields[lentry->of.count++], - tte_tag, tte_data); - th->th_entries++; - return (0); -} - -static __inline void -tte_hash_extend_locked(tte_hash_t th, tte_hash_entry_t entry, tte_hash_entry_t newentry, uint64_t tte_tag, tte_t tte_data) -{ - tte_hash_entry_t lentry; - - lentry = tte_hash_lookup_last_entry(entry); - lentry->of.flags = MAGIC_VALUE; - lentry->of.next = newentry; - tte_hash_set_field(&newentry->the_fields[newentry->of.count++], tte_tag, tte_data); - th->th_entries++; -} - -void -tte_hash_insert(tte_hash_t th, vm_offset_t va, tte_t tte_data) -{ - - tte_hash_entry_t entry, newentry; - tte_t tte_tag; - uint64_t s; - int retval; - -#ifdef DEBUG - if (tte_hash_lookup(th, va) != 0) - panic("mapping for va=0x%lx already exists", va); -#endif - entry = find_entry(th, va, PAGE_SHIFT); /* should actually be a function of tte_data */ - tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT)); - - s = hash_bucket_lock(entry->the_fields); - retval = tte_hash_insert_locked(th, entry, tte_tag, tte_data); - hash_bucket_unlock(entry->the_fields, s); - - if (retval == -1) { - newentry = tte_hash_allocate_fragment_entry(th); - s = hash_bucket_lock(entry->the_fields); - tte_hash_extend_locked(th, entry, newentry, tte_tag, tte_data); - hash_bucket_unlock(entry->the_fields, s); - } - -#ifdef DEBUG - if (tte_hash_lookup(th, va) == 0) - panic("insert for va=0x%lx failed", va); -#endif -} - -/* - * If leave_locked is true the tte's data field will be returned to - * the caller with the hash bucket left locked - */ -tte_t -tte_hash_lookup(tte_hash_t th, vm_offset_t va) -{ - uint64_t s; - tte_hash_entry_t entry; - tte_t tte_data, tte_tag; - tte_hash_field_t field = NULL; - /* XXX - only handle 8K pages for now */ - entry = find_entry(th, va, PAGE_SHIFT); - - tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT)); - - s = hash_bucket_lock(entry->the_fields); - tte_data = _tte_hash_lookup(entry, tte_tag, &field); - hash_bucket_unlock(entry->the_fields, s); - - return (tte_data); -} - -uint64_t -tte_hash_set_scratchpad_kernel(tte_hash_t th) -{ - - uint64_t hash_scratch; - /* This breaks if a hash table grows above 32MB - */ - hash_scratch = ((vm_offset_t)th->th_hashtable) | ((vm_offset_t)(1<th_shift)); - set_hash_kernel_scratchpad(hash_scratch); - - return (hash_scratch); -} - -uint64_t -tte_hash_set_scratchpad_user(tte_hash_t th, uint64_t context) -{ - - uint64_t hash_scratch; - /* This breaks if a hash table grows above 32MB - */ - th->th_context = (uint16_t)context; - hash_scratch = ((vm_offset_t)th->th_hashtable) | ((vm_offset_t)(1<th_shift)); - set_hash_user_scratchpad(hash_scratch); - - return (hash_scratch); -} - -tte_t -tte_hash_update(tte_hash_t th, vm_offset_t va, tte_t tte_data) -{ - - uint64_t s; - tte_hash_entry_t entry; - tte_t otte_data, tte_tag; - tte_hash_field_t field = NULL; - - entry = find_entry(th, va, PAGE_SHIFT); /* should actually be a function of tte_data */ - - tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT)); - s = hash_bucket_lock(entry->the_fields); - otte_data = _tte_hash_lookup(entry, tte_tag, &field); - - if (otte_data == 0) { - hash_bucket_unlock(entry->the_fields, s); - tte_hash_insert(th, va, tte_data); - } else { - tte_hash_set_field(field, tte_tag, tte_data); - hash_bucket_unlock(entry->the_fields, s); - } - return (otte_data); -} - -/* - * resize when the average entry has a full fragment entry - */ -int -tte_hash_needs_resize(tte_hash_t th) -{ - return ((th->th_entries > (1 << (th->th_shift + PAGE_SHIFT - TTE_SHIFT + 1))) - && (th != &kernel_tte_hash)); -} - -tte_hash_t -tte_hash_resize(tte_hash_t th) -{ - int i, j, nentries; - tte_hash_t newth; - tte_hash_entry_t src_entry, dst_entry, newentry; - - KASSERT(th != &kernel_tte_hash,("tte_hash_resize not supported for this pmap")); - if ((newth = tte_hash_cached_get((th->th_shift - HASH_ENTRY_SHIFT) + 1)) != NULL) { - newth->th_context = th->th_context; - _tte_hash_reset(newth); - } else { - newth = _tte_hash_create(th->th_context, NULL, (th->th_shift + 1)); - } - - nentries = (1 << (th->th_shift + PAGE_SHIFT - THE_SHIFT)); - for (i = 0; i < nentries; i++) { - tte_hash_field_t fields; - src_entry = (&th->th_hashtable[i]); - do { - fields = src_entry->the_fields; - for (j = 0; j < src_entry->of.count; j++) { - int shift = TTARGET_VA_SHIFT - PAGE_SHIFT; - uint64_t index = ((fields[j].tag<th_hashtable[index]); - if (tte_hash_insert_locked(newth, dst_entry, fields[j].tag, fields[j].data) == -1) { - newentry = tte_hash_allocate_fragment_entry(newth); - tte_hash_extend_locked(newth, dst_entry, newentry, fields[j].tag, fields[j].data); - } - } - src_entry = src_entry->of.next; - } while (src_entry); - } - - KASSERT(th->th_entries == newth->th_entries, - ("not all entries copied old=%d new=%d", th->th_entries, newth->th_entries)); - - return (newth); -} diff --git a/sys/sun4v/sun4v/uio_machdep.c b/sys/sun4v/sun4v/uio_machdep.c deleted file mode 100644 index 513991279c17..000000000000 --- a/sys/sun4v/sun4v/uio_machdep.c +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * Copyright (c) 2004 Alan L. Cox - * Copyright (c) 1982, 1986, 1991, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/* - * Implement uiomove(9) from physical memory using a combination - * of the direct mapping and sf_bufs to reduce the creation and - * destruction of ephemeral mappings. - */ -int -uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio) -{ - struct thread *td = curthread; - struct iovec *iov; - void *cp; - vm_offset_t page_offset; - vm_paddr_t pa; - vm_page_t m; - size_t cnt; - int error = 0; - int save = 0; - - KASSERT(uio->uio_rw == UIO_READ || uio->uio_rw == UIO_WRITE, - ("uiomove_fromphys: mode")); - KASSERT(uio->uio_segflg != UIO_USERSPACE || uio->uio_td == curthread, - ("uiomove_fromphys proc")); - save = td->td_pflags & TDP_DEADLKTREAT; - td->td_pflags |= TDP_DEADLKTREAT; - while (n > 0 && uio->uio_resid) { - iov = uio->uio_iov; - cnt = iov->iov_len; - if (cnt == 0) { - uio->uio_iov++; - uio->uio_iovcnt--; - continue; - } - if (cnt > n) - cnt = n; - page_offset = offset & PAGE_MASK; - cnt = ulmin(cnt, PAGE_SIZE - page_offset); - m = ma[offset >> PAGE_SHIFT]; - pa = VM_PAGE_TO_PHYS(m); - cp = (char *)TLB_PHYS_TO_DIRECT(pa) + page_offset; - switch (uio->uio_segflg) { - case UIO_USERSPACE: - maybe_yield(); - if (uio->uio_rw == UIO_READ) - error = copyout(cp, iov->iov_base, cnt); - else - error = copyin(iov->iov_base, cp, cnt); - if (error) { - goto out; - } - break; - case UIO_SYSSPACE: - if (uio->uio_rw == UIO_READ) - bcopy(cp, iov->iov_base, cnt); - else - bcopy(iov->iov_base, cp, cnt); - break; - case UIO_NOCOPY: - break; - } - iov->iov_base = (char *)iov->iov_base + cnt; - iov->iov_len -= cnt; - uio->uio_resid -= cnt; - uio->uio_offset += cnt; - offset += cnt; - n -= cnt; - } -out: - if (save == 0) - td->td_pflags &= ~TDP_DEADLKTREAT; - return (error); -} diff --git a/sys/sun4v/sun4v/vm_machdep.c b/sys/sun4v/sun4v/vm_machdep.c deleted file mode 100644 index 6219a6847c1f..000000000000 --- a/sys/sun4v/sun4v/vm_machdep.c +++ /dev/null @@ -1,466 +0,0 @@ -/*- - * Copyright (c) 1982, 1986 The Regents of the University of California. - * Copyright (c) 1989, 1990 William Jolitz - * Copyright (c) 1994 John Dyson - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department, and William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 - * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * from: FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.167 2001/07/12 - * $FreeBSD$ - */ - -#include "opt_pmap.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void -cpu_exit(struct thread *td) -{ - struct proc *p; - - p = td->td_proc; - p->p_md.md_sigtramp = NULL; - if (p->p_md.md_utrap != NULL) { - utrap_free(p->p_md.md_utrap); - p->p_md.md_utrap = NULL; - } -} - -void -cpu_thread_exit(struct thread *td) -{ -} - -void -cpu_thread_clean(struct thread *td) -{ -} - -void -cpu_thread_alloc(struct thread *td) -{ - struct pcb *pcb; - - pcb = (struct pcb *)((td->td_kstack + td->td_kstack_pages * PAGE_SIZE - - sizeof(struct pcb)) & ~0x3fUL); - pcb->pcb_kstack = (uint64_t)(((char *)pcb) - (CCFSZ + SPOFF)); - pcb->pcb_nsaved = 0; - td->td_frame = (struct trapframe *)pcb - 1; - pcb = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)pcb)); - KASSERT(pcb > (struct pcb *)VM_MIN_DIRECT_ADDRESS,("pcb is NULL")); - td->td_pcb = pcb; - -} - -void -cpu_thread_free(struct thread *td) -{ -} - -void -cpu_thread_swapin(struct thread *td) -{ -} - -void -cpu_thread_swapout(struct thread *td) -{ -} - -void -cpu_set_syscall_retval(struct thread *td, int error) -{ - - switch (error) { - case 0: - td->td_frame->tf_out[0] = td->td_retval[0]; - td->td_frame->tf_out[1] = td->td_retval[1]; - td->td_frame->tf_tstate &= ~TSTATE_XCC_C; - break; - - case ERESTART: - /* - * Undo the tpc advancement we have done on syscall - * enter, we want to reexecute the system call. - */ - td->td_frame->tf_tpc = td->td_pcb->pcb_tpc; - td->td_frame->tf_tnpc -= 4; - break; - - case EJUSTRETURN: - break; - - default: - if (td->td_proc->p_sysent->sv_errsize) { - if (error >= td->td_proc->p_sysent->sv_errsize) - error = -1; /* XXX */ - else - error = td->td_proc->p_sysent->sv_errtbl[error]; - } - td->td_frame->tf_out[0] = error; - td->td_frame->tf_tstate |= TSTATE_XCC_C; - break; - } -} - -void -cpu_set_upcall(struct thread *td, struct thread *td0) -{ - struct trapframe *tf; - struct frame *fr; - struct pcb *pcb; - - bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); - - pcb = td->td_pcb; - - tf = td->td_frame; - fr = (struct frame *)tf - 1; - fr->fr_local[0] = (u_long)fork_return; - fr->fr_local[1] = (u_long)td; - fr->fr_local[2] = (u_long)tf; - pcb->pcb_pc = (u_long)fork_trampoline - 8; - pcb->pcb_sp = (u_long)fr - SPOFF; - - /* Setup to release spin count in fork_exit(). */ - td->td_md.md_spinlock_count = 1; - td->td_md.md_saved_pil = 0; -} - -void -cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, - stack_t *stack) -{ - struct trapframe *tf; - uint64_t sp; - - if (td == curthread) - flushw(); - tf = td->td_frame; - sp = (uint64_t)stack->ss_sp + stack->ss_size; - tf->tf_out[0] = (uint64_t)arg; - tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); - tf->tf_tpc = (uint64_t)entry; - tf->tf_tnpc = tf->tf_tpc + 4; - - td->td_retval[0] = tf->tf_out[0]; - td->td_retval[1] = tf->tf_out[1]; -} - -int -cpu_set_user_tls(struct thread *td, void *tls_base) -{ - - if (td == curthread) - flushw(); - td->td_frame->tf_global[7] = (uint64_t) tls_base; - return (0); -} - -/* - * Finish a fork operation, with process p2 nearly set up. - * Copy and update the pcb, set up the stack so that the child - * ready to run and return to user mode. - */ -void -cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) -{ - struct trapframe *tf; - struct frame *fp; - struct pcb *pcb1; - struct pcb *pcb2, *pcb2orig; - vm_offset_t sp; - int error; - int i; - - KASSERT(td1 == curthread || td1 == &thread0, - ("cpu_fork: p1 not curproc and not proc0")); - - if ((flags & RFPROC) == 0) - return; - - p2->p_md.md_sigtramp = td1->td_proc->p_md.md_sigtramp; - p2->p_md.md_utrap = utrap_hold(td1->td_proc->p_md.md_utrap); - - /* The pcb must be aligned on a 64-byte boundary. */ - pcb1 = td1->td_pcb; - - pcb2orig = (struct pcb *)((td2->td_kstack + td2->td_kstack_pages * - PAGE_SIZE - sizeof(struct pcb)) & ~0x3fUL); - pcb2 = (struct pcb *)TLB_PHYS_TO_DIRECT(vtophys((vm_offset_t)pcb2orig)); - - td2->td_pcb = pcb2; - - /* - * Ensure that p1's pcb is up to date. - */ - critical_enter(); - if ((td1->td_frame->tf_fprs & FPRS_FEF) != 0) - savefpctx(pcb1->pcb_ufp); - critical_exit(); - /* Make sure the copied windows are spilled. */ - flushw(); - /* Copy the pcb (this will copy the windows saved in the pcb, too). */ - bcopy(pcb1, pcb2, sizeof(*pcb1)); - - /* - * If we're creating a new user process and we're sharing the address - * space, the parent's top most frame must be saved in the pcb. The - * child will pop the frame when it returns to user mode, and may - * overwrite it with its own data causing much suffering for the - * parent. We check if its already in the pcb, and if not copy it - * in. Its unlikely that the copyin will fail, but if so there's not - * much we can do. The parent will likely crash soon anyway in that - * case. - */ - if ((flags & RFMEM) != 0 && td1 != &thread0) { - sp = td1->td_frame->tf_sp; - for (i = 0; i < pcb1->pcb_nsaved; i++) { - if (pcb1->pcb_rwsp[i] == sp) - break; - } - if (i == pcb1->pcb_nsaved) { - error = copyin((caddr_t)sp + SPOFF, &pcb1->pcb_rw[i], - sizeof(struct rwindow)); - if (error == 0) { - pcb1->pcb_rwsp[i] = sp; - pcb1->pcb_nsaved++; - } - } - } - - /* - * Create a new fresh stack for the new process. - * Copy the trap frame for the return to user mode as if from a - * syscall. This copies most of the user mode register values. - */ - tf = (struct trapframe *)pcb2orig - 1; - bcopy(td1->td_frame, tf, sizeof(*tf)); - - tf->tf_out[0] = 0; /* Child returns zero */ - tf->tf_out[1] = 0; - tf->tf_tstate &= ~TSTATE_XCC_C; /* success */ - tf->tf_fprs = 0; - tf->tf_wstate = WSTATE_U64; - - - td2->td_frame = tf; - fp = (struct frame *)tf - 1; - fp->fr_local[0] = (u_long)fork_return; - fp->fr_local[1] = (u_long)td2; - fp->fr_local[2] = (u_long)tf; - /* Terminate stack traces at this frame. */ - fp->fr_pc = fp->fr_fp = 0; - pcb2->pcb_sp = (u_long)fp - SPOFF; - pcb2->pcb_pc = (u_long)fork_trampoline - 8; - pcb2->pcb_kstack = (uint64_t)(((char *)pcb2orig) - (CCFSZ + SPOFF)); - - /* Setup to release spin count in fork_exit(). */ - td2->td_md.md_spinlock_count = 1; - td2->td_md.md_saved_pil = 0; - - /* - * Now, cpu_switch() can schedule the new process. - */ -} - -void -cpu_reset(void) -{ - static char bspec[64] = ""; - phandle_t chosen; -#ifdef notyet - static struct { - cell_t name; - cell_t nargs; - cell_t nreturns; - cell_t bootspec; - } args = { - (cell_t)"boot", - 1, - 0, - (cell_t)bspec - }; -#endif - if ((chosen = OF_finddevice("/chosen")) != 0) { - if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1) - bspec[0] = '\0'; - bspec[sizeof(bspec) - 1] = '\0'; - } - hv_mach_sir(); -} - -/* - * Intercept the return address from a freshly forked process that has NOT - * been scheduled yet. - * - * This is needed to make kernel threads stay in kernel mode. - */ -void -cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg) -{ - struct frame *fp; - struct pcb *pcb; - - pcb = td->td_pcb; - fp = (struct frame *)(pcb->pcb_sp + SPOFF); - fp->fr_local[0] = (u_long)func; - fp->fr_local[1] = (u_long)arg; -} - -int -is_physical_memory(vm_paddr_t addr) -{ - struct ofw_mem_region *mr; - - for (mr = sparc64_memreg; mr < sparc64_memreg + sparc64_nmemreg; mr++) - if (addr >= mr->mr_start && addr < mr->mr_start + mr->mr_size) - return (1); - return (0); -} - -/* - * Get an sf_buf from the freelist. Will block if none are available. - */ -struct sf_buf * -sf_buf_alloc(struct vm_page *m, int flags) -{ - return ((struct sf_buf *)m); -} - -/* - * Release resources back to the system. - */ -void -sf_buf_free(struct sf_buf *sf) -{ -} - -void -swi_vm(void *v) -{ - - /* - * Nothing to do here yet - busdma bounce buffers are not yet - * implemented. - */ -} - -void * -uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) -{ - static vm_pindex_t color; - vm_paddr_t pa; - vm_page_t m; - int pflags; - void *va; - - - *flags = UMA_SLAB_PRIV; - - if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) - pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED; - else - pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED; - - if (wait & M_ZERO) - pflags |= VM_ALLOC_ZERO; - - for (;;) { - m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ); - if (m == NULL) { - if (wait & M_NOWAIT) - return (NULL); - else - VM_WAIT; - } else - break; - } - - pa = VM_PAGE_TO_PHYS(m); - va = (void *)TLB_PHYS_TO_DIRECT(pa); - if ((wait & M_ZERO) && ((m->flags & PG_ZERO) == 0)) - hwblkclr((void *)TLB_PHYS_TO_DIRECT(pa), PAGE_SIZE); - return (va); -} - -void -uma_small_free(void *mem, int size, u_int8_t flags) -{ - vm_page_t m; - - m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)mem)); - m->wire_count--; - vm_page_free(m); - atomic_subtract_int(&cnt.v_wire_count, 1); -} diff --git a/sys/sun4v/sun4v/vnex.c b/sys/sun4v/sun4v/vnex.c deleted file mode 100644 index d2554ebf4f40..000000000000 --- a/sys/sun4v/sun4v/vnex.c +++ /dev/null @@ -1,368 +0,0 @@ -/*- - * Copyright (c) 2006 by Marius Strobl . - * Copyright (c) 2006 Kip Macy . - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - - -#define SUN4V_REG_SPEC2CFG_HDL(x) ((x >> 32) & ~(0xfull << 28)) - -static device_probe_t vnex_probe; -static device_attach_t vnex_attach; -static bus_print_child_t vnex_print_child; -static bus_add_child_t vnex_add_child; -static bus_probe_nomatch_t vnex_probe_nomatch; -static bus_setup_intr_t vnex_setup_intr; -static bus_teardown_intr_t vnex_teardown_intr; -static bus_get_resource_list_t vnex_get_resource_list; -static mdesc_bus_get_devinfo_t vnex_get_devinfo; - -static struct vnex_devinfo * vnex_setup_dinfo(device_t, mde_cookie_t node); -static void vnex_destroy_dinfo(struct vnex_devinfo *); -static int vnex_print_res(struct vnex_devinfo *); - -struct vnex_devinfo { - struct mdesc_bus_devinfo vndi_mbdinfo; - struct resource_list vndi_rl; - - /* Some common properties. */ - struct nexus_regs *vndi_reg; - int vndi_nreg; -}; - -struct vnex_softc { - struct rman sc_intr_rman; - struct rman sc_mem_rman; -}; - -static device_method_t vnex_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, vnex_probe), - DEVMETHOD(device_attach, vnex_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface */ - DEVMETHOD(bus_print_child, vnex_print_child), - DEVMETHOD(bus_probe_nomatch, vnex_probe_nomatch), - DEVMETHOD(bus_read_ivar, bus_generic_read_ivar), - DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), - DEVMETHOD(bus_add_child, vnex_add_child), - DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), - DEVMETHOD(bus_release_resource, bus_generic_release_resource), - DEVMETHOD(bus_setup_intr, vnex_setup_intr), - DEVMETHOD(bus_teardown_intr, vnex_teardown_intr), - DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, vnex_get_resource_list), - - /* ofw_bus interface */ - /* mdesc_bus interface */ - DEVMETHOD(mdesc_bus_get_devinfo, vnex_get_devinfo), - DEVMETHOD(mdesc_bus_get_compat, mdesc_bus_gen_get_compat), - DEVMETHOD(mdesc_bus_get_name, mdesc_bus_gen_get_name), - DEVMETHOD(mdesc_bus_get_type, mdesc_bus_gen_get_type), - - { 0, 0 } -}; - - -static driver_t vnex_driver = { - "vnex", - vnex_methods, - sizeof(struct vnex_softc), -}; - - -static devclass_t vnex_devclass; -DRIVER_MODULE(vnex, nexus, vnex_driver, vnex_devclass, 0, 0); - - -static int -vnex_probe(device_t dev) -{ - if (strcmp(ofw_bus_get_name(dev), "virtual-devices")) - return (ENXIO); - - device_set_desc(dev, "virtual nexus device"); - return (0); -} - - -static int -vnex_attach(device_t dev) -{ - struct vnex_devinfo *vndi; - struct vnex_softc *sc; - device_t cdev; - phandle_t node; - mde_cookie_t rootnode, *listp = NULL; - int i, listsz, num_nodes, num_devices; - md_t *mdp; - - - node = ofw_bus_get_node(dev); - if (node == -1) - panic("%s: ofw_bus_get_node failed.", __func__); - - sc = device_get_softc(dev); - sc->sc_intr_rman.rm_type = RMAN_ARRAY; - sc->sc_intr_rman.rm_descr = "Interrupts"; - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "Device Memory"; - if (rman_init(&sc->sc_intr_rman) != 0 || - rman_init(&sc->sc_mem_rman) != 0 || - rman_manage_region(&sc->sc_intr_rman, 0, IV_MAX - 1) != 0 || - rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) - panic("%s: failed to set up rmans.", __func__); - - if ((mdp = md_get()) == NULL) - return (ENXIO); - - num_nodes = md_node_count(mdp); - listsz = num_nodes * sizeof(mde_cookie_t); - listp = (mde_cookie_t *)malloc(listsz, M_DEVBUF, M_WAITOK); - rootnode = md_root_node(mdp); - - /* - * scan the machine description for virtual devices - */ - num_devices = md_scan_dag(mdp, rootnode, - md_find_name(mdp, "virtual-device"), - md_find_name(mdp, "fwd"), listp); - - for (i = 0; i < num_devices; i++) { - if ((vndi = vnex_setup_dinfo(dev, listp[i])) == NULL) - continue; - - cdev = device_add_child(dev, NULL, -1); - if (cdev == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - vndi->vndi_mbdinfo.mbd_name); - vnex_destroy_dinfo(vndi); - continue; - } - device_set_ivars(cdev, vndi); - } - bus_generic_attach(dev); - free(listp, M_DEVBUF); - - return (0); -} - -static device_t -vnex_add_child(device_t dev, u_int order, const char *name, int unit) -{ - device_t cdev; - struct vnex_devinfo *vndi; - - cdev = device_add_child_ordered(dev, order, name, unit); - if (cdev == NULL) - return (NULL); - - vndi = malloc(sizeof(*vndi), M_DEVBUF, M_WAITOK | M_ZERO); - vndi->vndi_mbdinfo.mbd_name = strdup(name, M_OFWPROP); - resource_list_init(&vndi->vndi_rl); - device_set_ivars(cdev, vndi); - - return (cdev); -} - -static int -vnex_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += vnex_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -vnex_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", mdesc_bus_get_name(child)); - vnex_print_res(device_get_ivars(child)); - type = mdesc_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - - -static int -vnex_setup_intr(device_t dev, device_t child, struct resource *res, int flags, - driver_filter_t *filt,driver_intr_t *intr, void *arg, void **cookiep) -{ - - uint64_t reg, nreg; - uint64_t ihdl, cfg; - uint64_t ino, nino; - int error, cpuid; - - if (res == NULL) - panic("%s: NULL interrupt resource!", __func__); - - if ((error = bus_get_resource(dev, SYS_RES_MEMORY, 0, ®, &nreg))) - goto fail; - - if ((error = bus_get_resource(child, SYS_RES_IRQ, 0, &ino, &nino))) - goto fail; - - cfg = SUN4V_REG_SPEC2CFG_HDL(reg); - - if (hv_intr_devino_to_sysino(cfg, (uint32_t)ino, &ihdl) != H_EOK) { - error = ENXIO; - goto fail; - } - - cpuid = 0; - - if (hv_intr_settarget(ihdl, cpuid) != H_EOK) { - error = ENXIO; - goto fail; - } - - if (hv_intr_setstate(ihdl, HV_INTR_IDLE_STATE) != H_EOK) { - error = ENXIO; - goto fail; - } - - if (hv_intr_setenabled(ihdl, HV_INTR_ENABLED) != H_EOK) { - error = ENXIO; - goto fail; - } - - if ((rman_get_flags(res) & RF_SHAREABLE) == 0) - flags |= INTR_EXCL; - - /* We depend here on rman_activate_resource() being idempotent. */ - if ((error = rman_activate_resource(res))) - goto fail; - - error = inthand_add(device_get_nameunit(child), ihdl, - filt, intr, arg, flags, cookiep); - - printf("inthandler added\n"); -fail: - - return (error); -} - -static int -vnex_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih) -{ - - inthand_remove(rman_get_start(r), ih); - return (0); -} - -static struct resource_list * -vnex_get_resource_list(device_t dev, device_t child) -{ - struct vnex_devinfo *vndi; - - vndi = device_get_ivars(child); - return (&vndi->vndi_rl); -} - -static const struct mdesc_bus_devinfo * -vnex_get_devinfo(device_t dev, device_t child) -{ - struct vnex_devinfo *vndi; - - vndi = device_get_ivars(child); - return (&vndi->vndi_mbdinfo); -} - -static struct vnex_devinfo * -vnex_setup_dinfo(device_t dev, mde_cookie_t node) -{ - struct vnex_devinfo *vndi; - - vndi = malloc(sizeof(*vndi), M_DEVBUF, M_WAITOK | M_ZERO); - if (mdesc_bus_gen_setup_devinfo(&vndi->vndi_mbdinfo, node) != 0) { - free(vndi, M_DEVBUF); - return (NULL); - } - - return (vndi); -} - -static void -vnex_destroy_dinfo(struct vnex_devinfo *vndi) -{ - - resource_list_free(&vndi->vndi_rl); - mdesc_bus_gen_destroy_devinfo(&vndi->vndi_mbdinfo); - free(vndi, M_DEVBUF); -} - - -static int -vnex_print_res(struct vnex_devinfo *vndi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&vndi->vndi_rl, "mem", SYS_RES_MEMORY, - "%#lx"); - rv += resource_list_print_type(&vndi->vndi_rl, "irq", SYS_RES_IRQ, - "%ld"); - return (rv); -} diff --git a/sys/sun4v/sun4v/wbuf.S b/sys/sun4v/sun4v/wbuf.S deleted file mode 100644 index baf868a80ec4..000000000000 --- a/sys/sun4v/sun4v/wbuf.S +++ /dev/null @@ -1,222 +0,0 @@ -#include -__FBSDID("$FreeBSD$") - -#include -#include -#include -#include -#include - -#include "assym.s" - -ENTRY(fault_32bit_sn0) - MAGIC_TRAP_ON - MAGIC_EXIT -END(fault_32bit_sn0) - -ENTRY(fault_32bit_sn1) - MAGIC_TRAP_ON - MAGIC_EXIT -END(fault_32bit_sn1) - -ENTRY(fault_32bit_so0) - MAGIC_TRAP_ON - MAGIC_EXIT -END(fault_32bit_so0) - -ENTRY(fault_32bit_so1) - MAGIC_TRAP_ON - MAGIC_EXIT -END(fault_32bit_so1) - -ENTRY(fault_64bit_sn0) - GET_PCB(%g4) - stx %sp, [%g4 + PCB_RWSP] - add %g4, PCB_RW, %g5 - SAVE_WINDOW(%g5) - mov 1, %g5 - stx %g5, [%g4 + PCB_NSAVED] - - set trap, %g1 - sub %g0, 1, %g4 - - rdpr %tstate, %g5 - and %g5, TSTATE_CWP_MASK, %g5 - ba,pt %xcc, tl0_skip_utrap - wrpr %g0, %g5, %cwp -END(fault_64bit_sn0) - -ENTRY(fault_64bit_sn1) - /* XXX need to use physical addresses here */ - GET_PCB_PHYS(%g5, %g6) - wr %g0, ASI_REAL, %asi - stxa %sp, [%g6 + PCB_RWSP]%asi - add %g6, PCB_RW, %g5 - SAVE_WINDOW_ASI(%g5) - mov 1, %g5 - stxa %g5, [%g6 + PCB_NSAVED]%asi - saved - set tl0_trap, %g5 - wrpr %g5, %tnpc - done -END(fault_64bit_sn1) - -ENTRY(fault_32bit_sk) - MAGIC_TRAP_ON - MAGIC_EXIT -END(fault_32bit_sk) - -ENTRY(fault_64bit_sk) - GET_PCPU_PHYS_SCRATCH(%g5) - wr %g0, ASI_REAL, %asi - stxa %sp, [PCPU_REG + PC_KWBUF_SP]%asi - add PCPU_REG, PC_KWBUF, %g6 - SAVE_WINDOW_ASI(%g6) - mov 1, %g6 - sta %g6, [PCPU_REG + PC_KWBUF_FULL]%asi - saved - retry -END(fault_64bit_sk) - - -ENTRY(fault_64bit_so0) - GET_PCB(%g6) - ldx [%g6 + PCB_NSAVED], %g2 - add %g2, 1, %g3 - stx %g3, [%g6 + PCB_NSAVED] - - sll %g2, PTR_SHIFT, %g4 - add %g6, PCB_RWSP, %g3 - stx %sp, [%g3 + %g4] - sll %g2, RW_SHIFT, %g4 - add %g4, %g6, %g4 - add %g4, PCB_RW, %g3 - SAVE_WINDOW(%g3) - saved - retry -END(fault_64bit_so0) - -ENTRY(fault_64bit_so1) - GET_PCB_PHYS(%g5, %g6) - wr %g0, ASI_REAL, %asi - ldxa [%g6 + PCB_NSAVED]%asi, %g5 - add %g5, 1, %g7 - stxa %g7, [%g6 + PCB_NSAVED]%asi - - sll %g5, PTR_SHIFT, %g7 - add %g6, %g7, %g7 - stxa %sp, [%g7 + PCB_RWSP]%asi - - sll %g5, RW_SHIFT, %g7 ! offset - add %g6, %g7, %g7 ! pcb + offset - add %g7, PCB_RW, %g7 ! offset into wbuf area - - SAVE_WINDOW_ASI(%g7) - saved - set tl0_trap, %g5 - wrpr %g5, %tnpc - done -END(fault_64bit_so1) - -ENTRY(fault_32bit_fn0) - MAGIC_TRAP_ON - MAGIC_EXIT -fault_fn0_common: - set trap, %g1 - sub %g0, 1, %g4 - rdpr %tstate, %g5 - and %g5, TSTATE_CWP_MASK, %g5 - GET_PCPU_SCRATCH - ba,pt %xcc, tl0_skip_utrap - wrpr %g0, %g5, %cwp -END(fault_32bit_fn0) - MAGIC_TRAP_ON - MAGIC_EXIT -ENTRY(fault_32bit_fn1) - MAGIC_TRAP_ON - MAGIC_EXIT -fault_fn1_common: - rdpr %tstate, %g1 - and %g1, TSTATE_CWP_MASK, %g1 - wrpr %g0, %g1, %cwp - ! - ! fake tl1 traps regs so that after pagefault runs, we - ! re-execute at user_rtt. - ! - wrpr %g0, 1, %tl - set TSTATE_KERNEL | TSTATE_IE, %g1 - wrpr %g0, %g1, %tstate - set user_rtt, %g1 - wrpr %g0, %g1, %tpc - add %g1, 4, %g1 - wrpr %g0, %g1, %tnpc - - set trap, %g1 - mov 1, %g5 - sllx %g5, CTX_OTHER_SHIFT, %g5 - or %g5, %g2, %g2 - - sub %g0, 1, %g4 - rdpr %wstate, %l1 - sllx %l1, WSTATE_SHIFT, %l1 - wrpr %l1, WSTATE_K64, %wstate - mov KCONTEXT, %g5 - mov MMU_CID_P, %g6 - SET_MMU_CONTEXT(%g6, %g5) - - - ba,pt %xcc, tl0_ktrap - membar #Sync -END(fault_32bit_fn1) - -ENTRY(fault_64bit_fn0) - b fault_fn0_common - nop -END(fault_64bit_fn0) - -ENTRY(fault_64bit_fn1) - wrpr %g0, 1, %gl - b fault_fn1_common - nop -END(fault_64bit_fn1) - -ENTRY(fault_rtt_fn1) - b fault_fn1_common - nop -END(fault_rtt_fn1) - - -ENTRY(fault_32bit_not) -ENTRY(fault_64bit_not) - - ba,pt %xcc, ptl1_panic - mov PTL1_BAD_WTRAP, %g1 - -END(fault_32bit_not) -END(fault_64bit_not) - -ENTRY(ptl1_panic) - GET_PCB_PHYS(%g5, %g6) -#ifdef TRAP_TRACING - wr %g0, ASI_REAL, %asi - /* pcpu->pad[0] = %tpc */ - rdpr %tpc, %g4 - stxa %g4, [PCPU(PAD)]%asi - - /* pcpu->pad[1] = %l7 */ - stxa %l7, [PCPU(PAD) + 8]%asi - /* pcpu->pad[2] = pcb->pcb_kstack */ - ldxa [%g6 + PCB_KSTACK]%asi, %g6 - stxa %g6, [PCPU(PAD) + 16]%asi - rdpr %tt, %g6 - stxa %g6, [PCPU(PAD) + 24]%asi - wrpr %g0, 1, %tl - rdpr %tt, %g6 - stxa %g6, [PCPU(PAD) + 32]%asi -#endif - - -2: nop - ba,a,pt %xcc, 2b - -END(ptl1_panic) diff --git a/sys/sys/kdb.h b/sys/sys/kdb.h index 9685d77c042f..2982e03c75f1 100644 --- a/sys/sys/kdb.h +++ b/sys/sys/kdb.h @@ -101,7 +101,7 @@ extern const char * volatile kdb_why; #define KDB_WHY_CAM "cam" /* CAM has entered debugger. */ #define KDB_WHY_NDIS "ndis" /* NDIS entered debugger. */ #define KDB_WHY_ACPI "acpi" /* ACPI entered debugger. */ -#define KDB_WHY_TRAPSIG "trapsig" /* Sun4v/Sparc fault. */ +#define KDB_WHY_TRAPSIG "trapsig" /* Sparc fault. */ #define KDB_WHY_POWERFAIL "powerfail" /* Powerfail NMI. */ #define KDB_WHY_MAC "mac" /* MAC Framework. */ #define KDB_WHY_POWERPC "powerpc" /* Unhandled powerpc intr. */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 5919c05a3f39..7fbcde54fb43 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 900036 /* Master, propagated to newvers */ +#define __FreeBSD_version 900037 /* Master, propagated to newvers */ #ifdef _KERNEL #define P_OSREL_SIGSEGV 700004 diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c index 549bef5e109d..a9e76d920ca0 100644 --- a/usr.bin/rpcinfo/rpcinfo.c +++ b/usr.bin/rpcinfo/rpcinfo.c @@ -128,9 +128,9 @@ struct rpcbdump_short { #ifdef PORTMAP -static void ip_ping(u_short, char *, int, char **); +static void ip_ping(u_short, const char *, int, char **); static CLIENT *clnt_com_create(struct sockaddr_in *, u_long, u_long, int *, - char *); + const char *); static void pmapdump(int, char **); static void get_inet_address(struct sockaddr_in *, char *); #endif @@ -336,7 +336,7 @@ local_rpcb(u_long prog, u_long vers) #ifdef PORTMAP static CLIENT * clnt_com_create(struct sockaddr_in *addr, u_long prog, u_long vers, - int *fdp, char *trans) + int *fdp, const char *trans) { CLIENT *clnt; @@ -369,7 +369,7 @@ clnt_com_create(struct sockaddr_in *addr, u_long prog, u_long vers, * version 0 calls succeeds, it tries for MAXVERS call and repeats the same. */ static void -ip_ping(u_short portnum, char *trans, int argc, char **argv) +ip_ping(u_short portnum, const char *trans, int argc, char **argv) { CLIENT *client; int fd = RPC_ANYFD; @@ -594,7 +594,7 @@ reply_proc(void *res, struct netbuf *who, struct netconfig *nconf) { char *uaddr; char hostbuf[NI_MAXHOST]; - char *hostname; + const char *hostname; struct sockaddr *sa = (struct sockaddr *)who->buf; if (getnameinfo(sa, sa->sa_len, hostbuf, NI_MAXHOST, NULL, 0, 0)) { @@ -987,15 +987,15 @@ rpcbgetstat(int argc, char **argv) #define MAXLINE 256 char linebuf[MAXLINE]; char *cp, *lp; - char *pmaphdr[] = { + const char *pmaphdr[] = { "NULL", "SET", "UNSET", "GETPORT", "DUMP", "CALLIT" }; - char *rpcb3hdr[] = { + const char *rpcb3hdr[] = { "NULL", "SET", "UNSET", "GETADDR", "DUMP", "CALLIT", "TIME", "U2T", "T2U" }; - char *rpcb4hdr[] = { + const char *rpcb4hdr[] = { "NULL", "SET", "UNSET", "GETADDR", "DUMP", "CALLIT", "TIME", "U2T", "T2U", "VERADDR", "INDRECT", "GETLIST", "GETSTAT" }; @@ -1455,7 +1455,7 @@ progping(char *netid, int argc, char **argv) } static void -usage() +usage(void) { fprintf(stderr, "usage: rpcinfo [-m | -s] [host]\n"); #ifdef PORTMAP @@ -1536,7 +1536,7 @@ pstatus(register CLIENT *client, u_long prog, u_long vers) static CLIENT * clnt_rpcbind_create(char *host, int rpcbversnum, struct netbuf **targaddr) { - static char *tlist[3] = { + static const char *tlist[3] = { "circuit_n", "circuit_v", "datagram_v" }; int i; diff --git a/usr.sbin/bsdinstall/partedit/Makefile b/usr.sbin/bsdinstall/partedit/Makefile index 80d89cc1a1bf..9618b09b5ebd 100644 --- a/usr.sbin/bsdinstall/partedit/Makefile +++ b/usr.sbin/bsdinstall/partedit/Makefile @@ -9,9 +9,6 @@ PARTEDIT_ARCH= ${MACHINE} .if ${MACHINE} == "i386" || ${MACHINE} == "amd64" PARTEDIT_ARCH= x86 .endif -.if ${MACHINE} == "sun4v" -PARTEDIT_ARCH= sparc64 -.endif .if !exists(partedit_${PARTEDIT_ARCH}.c) PARTEDIT_ARCH= generic .endif From 743de88b75a2b2c470eddf243e06c04dbe8663c2 Mon Sep 17 00:00:00 2001 From: sbruno Date: Sat, 14 May 2011 17:56:13 +0000 Subject: [PATCH 048/164] Increase size of cg_count to allow us to utilize >128 CPUs. Pad cg_count and cg_children to keep the struct aligned Reviewed by: attilio@ --- sys/sys/smp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 410adfa827e3..66e800873e4b 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -35,8 +35,8 @@ struct cpu_group { struct cpu_group *cg_parent; /* Our parent group. */ struct cpu_group *cg_child; /* Optional children groups. */ cpuset_t cg_mask; /* Mask of cpus in this group. */ - int8_t cg_count; /* Count of cpus in this group. */ - int8_t cg_children; /* Number of children groups. */ + int32_t cg_count; /* Count of cpus in this group. */ + int16_t cg_children; /* Number of children groups. */ int8_t cg_level; /* Shared cache level. */ int8_t cg_flags; /* Traversal modifiers. */ }; From 9309cc63ed0edb010fd6cb468850c07a474310f5 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 14 May 2011 18:22:08 +0000 Subject: [PATCH 049/164] Simplify the code here. Submitted by: jhb --- sys/kern/kern_cpuset.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 9ed19d4d60d9..d604c5937938 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -797,11 +797,7 @@ cpuset_init(void *arg) { cpuset_t mask; -#ifdef SMP mask = all_cpus; -#else - CPU_SETOF(0, &mask); -#endif if (cpuset_modify(cpuset_zero, &mask)) panic("Can't set initial cpuset mask.\n"); cpuset_zero->cs_flags |= CPU_SET_RDONLY; From c5a5c48e70de18e3c28cb0005fc2d9ab6a83a8f7 Mon Sep 17 00:00:00 2001 From: attilio Date: Sat, 14 May 2011 19:36:12 +0000 Subject: [PATCH 050/164] Fix a longstanding bug where only the first part of the cpumask was correctly set full. Submitted by: anonymous --- sys/kern/kern_cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index d604c5937938..5d058e6f6528 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -719,7 +719,7 @@ cpuset_thread0(void) * cpuset_create() due to NULL parent. */ set = uma_zalloc(cpuset_zone, M_WAITOK | M_ZERO); - set->cs_mask.__bits[0] = -1; + CPU_FILL(&set->cs_mask); LIST_INIT(&set->cs_children); LIST_INSERT_HEAD(&cpuset_ids, set, cs_link); set->cs_ref = 1; From e0bdfaa331e0646b286138c0a1ebde578634f499 Mon Sep 17 00:00:00 2001 From: marius Date: Sat, 14 May 2011 23:20:14 +0000 Subject: [PATCH 051/164] Fix yet another inversion in the logic by applying the x86 version of this, which avoids CPU_EMPTY() in the first place. Do I get a beer or something for every inversion I find? --- sys/sparc64/sparc64/mp_machdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index a314eb04c77e..7edc3a33014a 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -573,8 +573,8 @@ spitfire_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2) { u_int cpu; - while (CPU_EMPTY(&cpus)) { - cpu = cpusetobj_ffs(&cpus) - 1; + while ((cpu = cpusetobj_ffs(&cpus)) != 0) { + cpu--; CPU_CLR(cpu, &cpus); spitfire_ipi_single(cpu, d0, d1, d2); } From d57a3c7c06068d612eb55c91583ac76deaf90bf6 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 16 May 2011 16:34:03 +0000 Subject: [PATCH 052/164] MFC --- bin/sh/eval.c | 3 +- bin/sh/miscbltin.c | 4 +- bin/sh/var.c | 11 +-- sbin/geom/class/part/geom_part.c | 24 +++-- sys/cddl/dev/cyclic/cyclic.c | 14 ++- sys/cddl/dev/cyclic/i386/cyclic_machdep.c | 38 ++++---- sys/dev/ath/if_ath.c | 12 +++ sys/dev/ath/if_ath_sysctl.c | 6 ++ sys/dev/ath/if_athioctl.h | 17 ++-- sys/dev/bge/if_bge.c | 2 +- sys/dev/glxiic/glxiic.c | 47 ++++----- sys/fs/nfs/nfs_commonkrpc.c | 12 +-- sys/fs/nfs/nfs_commonport.c | 10 +- sys/fs/nfsclient/nfs_clkrpc.c | 2 - sys/fs/nfsclient/nfs_clnfsiod.c | 12 +-- sys/fs/nfsclient/nfs_clsubs.c | 4 +- sys/fs/nfsclient/nfs_clvfsops.c | 16 ++-- sys/fs/nfsclient/nfs_clvnops.c | 18 ++-- sys/geom/part/g_part.c | 110 ++++++++++++++++++---- sys/kern/kern_clocksource.c | 73 +++++++++++--- sys/kern/subr_sbuf.c | 16 ++-- sys/nfs/nfs_common.c | 2 +- sys/nfsclient/nfs.h | 2 +- sys/nfsclient/nfs_krpc.c | 10 +- sys/nfsclient/nfs_nfsiod.c | 12 +-- sys/nfsclient/nfs_subs.c | 4 +- sys/nfsclient/nfs_vfsops.c | 18 ++-- sys/nfsclient/nfs_vnops.c | 18 ++-- sys/powerpc/aim/mmu_oea64.c | 5 - sys/powerpc/powerpc/platform.c | 2 +- sys/sys/dtrace_bsd.h | 9 +- sys/sys/sbuf.h | 12 +-- usr.bin/nfsstat/nfsstat.c | 4 +- usr.sbin/nfsd/nfsv4.4 | 54 +++++------ 34 files changed, 370 insertions(+), 233 deletions(-) diff --git a/bin/sh/eval.c b/bin/sh/eval.c index b0ee28e7b0e7..b19c24f81a91 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -552,7 +552,8 @@ evalpipe(union node *n) if (prevfd >= 0) close(prevfd); prevfd = pip[0]; - close(pip[1]); + if (pip[1] != -1) + close(pip[1]); } INTON; if (n->npipe.backgnd == 0) { diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index dc200b6d566e..fce13b5c147d 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -465,7 +465,7 @@ ulimitcmd(int argc __unused, char **argv __unused) "(-%c) ", l->option); out1fmt("%-18s %18s ", l->name, optbuf); if (val == RLIM_INFINITY) - out1fmt("unlimited\n"); + out1str("unlimited\n"); else { val /= l->factor; @@ -491,7 +491,7 @@ ulimitcmd(int argc __unused, char **argv __unused) val = limit.rlim_max; if (val == RLIM_INFINITY) - out1fmt("unlimited\n"); + out1str("unlimited\n"); else { val /= l->factor; diff --git a/bin/sh/var.c b/bin/sh/var.c index 84b6dea66d4c..f6d7fb1c1aa0 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -681,14 +681,13 @@ exportcmd(int argc, char **argv) out1str(cmdname); out1c(' '); } - p = strchr(vp->text, '='); if (values && !(vp->flags & VUNSET)) { - p++; - outbin(vp->text, p - vp->text, - out1); - out1qstr(p); + outbin(vp->text, + vp->name_len + 1, out1); + out1qstr(vp->text + + vp->name_len + 1); } else - outbin(vp->text, p - vp->text, + outbin(vp->text, vp->name_len, out1); out1c('\n'); } diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index 81d02914f9d1..19d1502fbe7d 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -416,7 +416,7 @@ gpart_autofill(struct gctl_req *req) struct gprovider *pp; off_t first, last, a_first; off_t size, start, a_lba; - off_t lba, len, alignment; + off_t lba, len, alignment, offset; uintmax_t grade; const char *s; int error, has_size, has_start, has_alignment; @@ -467,8 +467,6 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &size); if (error) errc(EXIT_FAILURE, error, "Invalid size param"); - if (size > alignment) - size = ALIGNDOWN(size, alignment); } s = gctl_get_ascii(req, "start"); @@ -478,22 +476,29 @@ gpart_autofill(struct gctl_req *req) error = g_parse_lba(s, pp->lg_sectorsize, &start); if (error) errc(EXIT_FAILURE, error, "Invalid start param"); - start = ALIGNUP(start, alignment); } /* No autofill necessary. */ if (has_size && has_start && !has_alignment) goto done; + /* Adjust parameters to offset value for better alignment */ + s = find_provcfg(pp, "offset"); + offset = (s == NULL) ? 0: + (off_t)strtoimax(s, NULL, 0) / pp->lg_sectorsize; + start = ALIGNUP(start + offset, alignment); + if (size + offset > alignment) + size = ALIGNDOWN(size + offset, alignment); + first = (off_t)strtoimax(find_geomcfg(gp, "first"), NULL, 0); last = (off_t)strtoimax(find_geomcfg(gp, "last"), NULL, 0); grade = ~0ULL; - a_first = ALIGNUP(first, alignment); - last = ALIGNDOWN(last, alignment); + a_first = ALIGNUP(first + offset, alignment); + last = ALIGNDOWN(last + offset, alignment); while ((pp = find_provider(gp, first)) != NULL) { s = find_provcfg(pp, "start"); lba = (off_t)strtoimax(s, NULL, 0); - a_lba = ALIGNDOWN(lba, alignment); + a_lba = ALIGNDOWN(lba + offset, alignment); if (first < a_lba && a_first < a_lba) { /* Free space [first, lba> */ len = a_lba - a_first; @@ -519,7 +524,7 @@ gpart_autofill(struct gctl_req *req) s = find_provcfg(pp, "end"); first = (off_t)strtoimax(s, NULL, 0) + 1; - a_first = ALIGNUP(first, alignment); + a_first = ALIGNUP(first + offset, alignment); } if (a_first <= last) { /* Free space [first-last] */ @@ -543,12 +548,11 @@ gpart_autofill(struct gctl_req *req) } } } - if (grade == ~0ULL) { geom_deletetree(&mesh); return (ENOSPC); } - + start -= offset; /* Return back to real offset */ done: snprintf(ssize, sizeof(ssize), "%jd", (intmax_t)size); gctl_change_param(req, "size", -1, ssize); diff --git a/sys/cddl/dev/cyclic/cyclic.c b/sys/cddl/dev/cyclic/cyclic.c index b9a6979924db..e7b7f50f1917 100644 --- a/sys/cddl/dev/cyclic/cyclic.c +++ b/sys/cddl/dev/cyclic/cyclic.c @@ -341,6 +341,16 @@ static cyc_backend_t cyclic_backend; MALLOC_DEFINE(M_CYCLIC, "cyclic", "Cyclic timer subsystem"); +static __inline hrtime_t +cyc_gethrtime(void) +{ + struct bintime bt; + + binuptime(&bt); + return ((hrtime_t)bt.sec * NANOSEC + + (((uint64_t)NANOSEC * (uint32_t)(bt.frac >> 32)) >> 32)); +} + /* * Returns 1 if the upheap propagated to the root, 0 if it did not. This * allows the caller to reprogram the backend only when the root has been @@ -507,7 +517,7 @@ cyclic_fire(cpu_t *c) cyc_index_t *heap = cpu->cyp_heap; cyclic_t *cyclic, *cyclics = cpu->cyp_cyclics; void *arg = be->cyb_arg; - hrtime_t now = gethrtime(); + hrtime_t now = cyc_gethrtime(); hrtime_t exp; if (cpu->cyp_nelems == 0) { @@ -687,7 +697,7 @@ cyclic_add_xcall(cyc_xcallarg_t *arg) * If a start time hasn't been explicitly specified, we'll * start on the next interval boundary. */ - cyclic->cy_expire = (gethrtime() / cyclic->cy_interval + 1) * + cyclic->cy_expire = (cyc_gethrtime() / cyclic->cy_interval + 1) * cyclic->cy_interval; } else { cyclic->cy_expire = when->cyt_when; diff --git a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c index dc6cb712f228..9ba2fd3c0086 100644 --- a/sys/cddl/dev/cyclic/i386/cyclic_machdep.c +++ b/sys/cddl/dev/cyclic/i386/cyclic_machdep.c @@ -30,6 +30,7 @@ static void enable(cyb_arg_t); static void disable(cyb_arg_t); static void reprogram(cyb_arg_t, hrtime_t); static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *); +static void cyclic_clock(struct trapframe *frame); static cyc_backend_t be = { NULL, /* cyb_configure */ @@ -45,6 +46,7 @@ static void cyclic_ap_start(void *dummy) { /* Initialise the rest of the CPUs. */ + cyclic_clock_func = cyclic_clock; cyclic_mp_init(); } @@ -63,18 +65,10 @@ cyclic_machdep_init(void) static void cyclic_machdep_uninit(void) { - int i; - - for (i = 0; i <= mp_maxid; i++) - /* Reset the cyclic clock callback hook. */ - cyclic_clock_func[i] = NULL; - /* De-register the cyclic backend. */ cyclic_uninit(); } -static hrtime_t exp_due[MAXCPU]; - /* * This function is the one registered by the machine dependent * initialiser as the callback for high speed timer events. @@ -84,7 +78,7 @@ cyclic_clock(struct trapframe *frame) { cpu_t *c = &solaris_cpu[curcpu]; - if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[curcpu]) { + if (c->cpu_cyclic != NULL) { if (TRAPF_USERMODE(frame)) { c->cpu_profile_pc = 0; c->cpu_profile_upc = TRAPF_PC(frame); @@ -102,24 +96,32 @@ cyclic_clock(struct trapframe *frame) } } -static void enable(cyb_arg_t arg) +static void +enable(cyb_arg_t arg __unused) { - /* Register the cyclic clock callback function. */ - cyclic_clock_func[curcpu] = cyclic_clock; + } -static void disable(cyb_arg_t arg) +static void +disable(cyb_arg_t arg __unused) { - /* Reset the cyclic clock callback function. */ - cyclic_clock_func[curcpu] = NULL; + } -static void reprogram(cyb_arg_t arg, hrtime_t exp) +static void +reprogram(cyb_arg_t arg __unused, hrtime_t exp) { - exp_due[curcpu] = exp; + struct bintime bt; + struct timespec ts; + + ts.tv_sec = exp / 1000000000; + ts.tv_nsec = exp % 1000000000; + timespec2bintime(&ts, &bt); + clocksource_cyc_set(&bt); } -static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param) +static void xcall(cyb_arg_t arg __unused, cpu_t *c, cyc_func_t func, + void *param) { cpuset_t cpus; diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index 8f13b267c0e4..745a0d5a9509 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -3966,9 +3966,21 @@ ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) sc->sc_stats.ast_tx_fifoerr++; if (ts->ts_status & HAL_TXERR_FILT) sc->sc_stats.ast_tx_filtered++; + if (ts->ts_status & HAL_TXERR_XTXOP) + sc->sc_stats.ast_tx_xtxop++; + if (ts->ts_status & HAL_TXERR_TIMER_EXPIRED) + sc->sc_stats.ast_tx_timerexpired++; + + /* XXX HAL_TX_DATA_UNDERRUN */ + /* XXX HAL_TX_DELIM_UNDERRUN */ + if (bf->bf_m->m_flags & M_FF) sc->sc_stats.ast_ff_txerr++; } + /* XXX when is this valid? */ + if (ts->ts_status & HAL_TX_DESC_CFG_ERR) + sc->sc_stats.ast_tx_desccfgerr++; + sr = ts->ts_shortretry; lr = ts->ts_longretry; sc->sc_stats.ast_tx_shortretry += sr; diff --git a/sys/dev/ath/if_ath_sysctl.c b/sys/dev/ath/if_ath_sysctl.c index 8e064971bfbc..6c1a6b210425 100644 --- a/sys/dev/ath/if_ath_sysctl.c +++ b/sys/dev/ath/if_ath_sysctl.c @@ -709,6 +709,12 @@ ath_sysctl_stats_attach(struct ath_softc *sc) &sc->sc_stats.ast_tx_timeout, 0, "TX Global Timeout"); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_cst", CTLFLAG_RD, &sc->sc_stats.ast_tx_cst, 0, "TX Carrier Sense Timeout"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_xtxop", CTLFLAG_RD, + &sc->sc_stats.ast_tx_xtxop, 0, "TX exceeded TXOP"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_timerexpired", CTLFLAG_RD, + &sc->sc_stats.ast_tx_timerexpired, 0, "TX exceeded TX_TIMER register"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_desccfgerr", CTLFLAG_RD, + &sc->sc_stats.ast_tx_desccfgerr, 0, "TX Descriptor Cfg Error"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); diff --git a/sys/dev/ath/if_athioctl.h b/sys/dev/ath/if_athioctl.h index 1c9d23fe7cd7..98dd03791d99 100644 --- a/sys/dev/ath/if_athioctl.h +++ b/sys/dev/ath/if_athioctl.h @@ -121,17 +121,20 @@ struct ath_stats { u_int32_t ast_be_missed; /* missed beacons */ u_int32_t ast_ani_cal; /* ANI calibrations performed */ u_int32_t ast_rx_agg; /* number of aggregate frames RX'ed */ - u_int32_t ast_rx_halfgi; - u_int32_t ast_rx_2040; - u_int32_t ast_rx_pre_crc_err; - u_int32_t ast_rx_post_crc_err; - u_int32_t ast_rx_decrypt_busy_err; + u_int32_t ast_rx_halfgi; /* RX half-GI */ + u_int32_t ast_rx_2040; /* RX 40mhz frame */ + u_int32_t ast_rx_pre_crc_err; /* RX pre-delimiter CRC error */ + u_int32_t ast_rx_post_crc_err; /* RX post-delimiter CRC error */ + u_int32_t ast_rx_decrypt_busy_err; /* RX decrypt engine busy error */ u_int32_t ast_rx_hi_rx_chain; u_int32_t ast_tx_htprotect; /* HT tx frames with protection */ - u_int32_t ast_rx_hitqueueend; + u_int32_t ast_rx_hitqueueend; /* RX hit descr queue end */ u_int32_t ast_tx_timeout; /* Global TX timeout */ u_int32_t ast_tx_cst; /* Carrier sense timeout */ - u_int32_t ast_pad[16]; + u_int32_t ast_tx_xtxop; /* tx exceeded TXOP */ + u_int32_t ast_tx_timerexpired; /* tx exceeded TX_TIMER */ + u_int32_t ast_tx_desccfgerr; /* tx desc cfg error */ + u_int32_t ast_pad[13]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 3d725fcc4f9a..0f87eb0ba5f5 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -2836,7 +2836,7 @@ bge_attach(device_t dev) if (sc->bge_asicrev == BGE_ASICREV_BCM5719 && sc->bge_chipid == BGE_CHIPID_BCM5719_A0) { /* Jumbo frame on BCM5719 A0 does not work. */ - sc->bge_flags &= ~BGE_FLAG_JUMBO_FRAME; + sc->bge_flags &= ~BGE_FLAG_JUMBO; } break; case BGE_ASICREV_BCM5755: diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c index 204095166192..6eeac7cee381 100644 --- a/sys/dev/glxiic/glxiic.c +++ b/sys/dev/glxiic/glxiic.c @@ -153,9 +153,10 @@ struct glxiic_softc { }; #ifdef GLXIIC_DEBUG -#define DEBUG(fmt, args...) log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args) +#define GLXIIC_DEBUG_LOG(fmt, args...) \ + log(LOG_DEBUG, "%s: " fmt "\n" , __func__ , ## args) #else -#define DEBUG(fmt, args...) +#define GLXIIC_DEBUG_LOG(fmt, args...) #endif #define GLXIIC_SCLFRQ(n) ((n << 1)) @@ -540,7 +541,7 @@ glxiic_timeout(void *arg) sc = (struct glxiic_softc *)arg; - DEBUG("timeout in state %d", sc->state); + GLXIIC_DEBUG_LOG("timeout in state %d", sc->state); if (glxiic_state_table[sc->state].master) { sc->error = IIC_ETIMEOUT; @@ -604,7 +605,7 @@ glxiic_handle_slave_match_locked(struct glxiic_softc *sc, uint8_t status) glxiic_set_state_locked(sc, GLXIIC_STATE_SLAVE_RX); iicbus_intr(sc->iicbus, INTR_GENERAL, &addr); } else { - DEBUG("unknown slave match"); + GLXIIC_DEBUG_LOG("unknown slave match"); return (IIC_ESTATUS); } @@ -618,7 +619,7 @@ glxiic_state_idle_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in idle"); + GLXIIC_DEBUG_LOG("bus error in idle"); return (IIC_EBUSERR); } @@ -637,7 +638,7 @@ glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in slave tx"); + GLXIIC_DEBUG_LOG("bus error in slave tx"); return (IIC_EBUSERR); } @@ -658,7 +659,7 @@ glxiic_state_slave_tx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting data in slave tx"); + GLXIIC_DEBUG_LOG("not awaiting data in slave tx"); return (IIC_ESTATUS); } @@ -678,7 +679,7 @@ glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in slave rx"); + GLXIIC_DEBUG_LOG("bus error in slave rx"); return (IIC_EBUSERR); } @@ -694,7 +695,7 @@ glxiic_state_slave_rx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("no pending data in slave rx"); + GLXIIC_DEBUG_LOG("no pending data in slave rx"); return (IIC_ESTATUS); } @@ -714,17 +715,17 @@ glxiic_state_master_addr_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error after master start"); + GLXIIC_DEBUG_LOG("bus error after master start"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master after master start"); + GLXIIC_DEBUG_LOG("not bus master after master start"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting address in master addr"); + GLXIIC_DEBUG_LOG("not awaiting address in master addr"); return (IIC_ESTATUS); } @@ -755,17 +756,17 @@ glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master tx"); + GLXIIC_DEBUG_LOG("bus error in master tx"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master tx"); + GLXIIC_DEBUG_LOG("not bus master in master tx"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in master tx"); + GLXIIC_DEBUG_LOG("slave nack in master tx"); return (IIC_ENOACK); } @@ -775,7 +776,7 @@ glxiic_state_master_tx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("not awaiting data in master tx"); + GLXIIC_DEBUG_LOG("not awaiting data in master tx"); return (IIC_ESTATUS); } @@ -796,17 +797,17 @@ glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master rx"); + GLXIIC_DEBUG_LOG("bus error in master rx"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master rx"); + GLXIIC_DEBUG_LOG("not bus master in master rx"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in rx"); + GLXIIC_DEBUG_LOG("slave nack in rx"); return (IIC_ENOACK); } @@ -825,7 +826,7 @@ glxiic_state_master_rx_callback(struct glxiic_softc *sc, uint8_t status) } if ((status & GLXIIC_SMB_STS_SDAST_BIT) == 0) { - DEBUG("no pending data in master rx"); + GLXIIC_DEBUG_LOG("no pending data in master rx"); return (IIC_ESTATUS); } @@ -849,17 +850,17 @@ glxiic_state_master_stop_callback(struct glxiic_softc *sc, uint8_t status) GLXIIC_ASSERT_LOCKED(sc); if ((status & GLXIIC_SMB_STS_BER_BIT) != 0) { - DEBUG("bus error in master stop"); + GLXIIC_DEBUG_LOG("bus error in master stop"); return (IIC_EBUSERR); } if ((status & GLXIIC_SMB_STS_MASTER_BIT) == 0) { - DEBUG("not bus master in master stop"); + GLXIIC_DEBUG_LOG("not bus master in master stop"); return (IIC_ESTATUS); } if ((status & GLXIIC_SMB_STS_NEGACK_BIT) != 0) { - DEBUG("slave nack in master stop"); + GLXIIC_DEBUG_LOG("slave nack in master stop"); return (IIC_ENOACK); } diff --git a/sys/fs/nfs/nfs_commonkrpc.c b/sys/fs/nfs/nfs_commonkrpc.c index 8b5f3910900d..ba1ac4efbb4b 100644 --- a/sys/fs/nfs/nfs_commonkrpc.c +++ b/sys/fs/nfs/nfs_commonkrpc.c @@ -78,17 +78,17 @@ static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; static int nfs_keytab_enctype = ETYPE_DES_CBC_CRC; -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "Buffer reservation size 2 < x < 64"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, "Number of times the nfs client has had to reconnect"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, "Number of seconds to delay a retry after receiving EJUKEBOX"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, "Disable weak cache consistency checking when server returns an error"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, keytab_enctype, CTLFLAG_RW, &nfs_keytab_enctype, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, keytab_enctype, CTLFLAG_RW, &nfs_keytab_enctype, 0, "Encryption type for the keytab entry used by nfs"); static void nfs_down(struct nfsmount *, struct thread *, const char *, diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index ee37cbc18a08..62549158870d 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -69,14 +69,12 @@ void (*ncl_call_invalcaches)(struct vnode *) = NULL; static int nfs_realign_test; static int nfs_realign_count; -SYSCTL_NODE(_vfs, OID_AUTO, newnfs, CTLFLAG_RW, 0, "New NFS filesystem"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, +SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "New NFS filesystem"); +SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "Number of realign tests done"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, +SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "Number of mbuf realignments done"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs4acl_enable, CTLFLAG_RW, &nfsrv_useacl, - 0, "Enable NFSv4 ACLs"); -SYSCTL_STRING(_vfs_newnfs, OID_AUTO, callback_addr, CTLFLAG_RW, +SYSCTL_STRING(_vfs_nfs, OID_AUTO, callback_addr, CTLFLAG_RW, nfsv4_callbackaddr, sizeof(nfsv4_callbackaddr), "NFSv4 callback addr for server to use"); diff --git a/sys/fs/nfsclient/nfs_clkrpc.c b/sys/fs/nfsclient/nfs_clkrpc.c index 1b6734d74f5b..c4f7e94c103c 100644 --- a/sys/fs/nfsclient/nfs_clkrpc.c +++ b/sys/fs/nfsclient/nfs_clkrpc.c @@ -46,8 +46,6 @@ __FBSDID("$FreeBSD$"); NFSDLOCKMUTEX; -SYSCTL_DECL(_vfs_newnfs); - SVCPOOL *nfscbd_pool; static int nfs_cbproc(struct nfsrv_descript *, u_int32_t); diff --git a/sys/fs/nfsclient/nfs_clnfsiod.c b/sys/fs/nfsclient/nfs_clnfsiod.c index 7ee19ad0fd02..0f1810fe00c4 100644 --- a/sys/fs/nfsclient/nfs_clnfsiod.c +++ b/sys/fs/nfsclient/nfs_clnfsiod.c @@ -80,11 +80,11 @@ static void nfssvc_iod(void *); static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON]; -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); /* Maximum number of seconds a nfsiod kthread will sleep before exiting */ static unsigned int nfs_iodmaxidle = 120; -SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, +SYSCTL_UINT(_vfs_nfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, "Max number of seconds an nfsiod kthread will sleep before exiting"); /* Maximum number of nfsiod kthreads */ @@ -123,7 +123,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS) mtx_unlock(&ncl_iod_mutex); return (0); } -SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmin), sysctl_iodmin, "IU", "Min number of nfsiod kthreads to keep as spares"); @@ -159,7 +159,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS) mtx_unlock(&ncl_iod_mutex); return (0); } -SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (ncl_iodmax), sysctl_iodmax, "IU", "Max number of nfsiod kthreads"); @@ -214,7 +214,7 @@ nfsiod_setup(void *dummy) { int error; - TUNABLE_INT_FETCH("vfs.newnfs.iodmin", &nfs_iodmin); + TUNABLE_INT_FETCH("vfs.nfs.iodmin", &nfs_iodmin); nfscl_init(); mtx_lock(&ncl_iod_mutex); /* Silently limit the start number of nfsiod's */ @@ -231,7 +231,7 @@ nfsiod_setup(void *dummy) SYSINIT(newnfsiod, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, nfsiod_setup, NULL); static int nfs_defect = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, +SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "Allow nfsiods to migrate serving different mounts"); /* diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c index 7bff646a6e49..0c0563150ee0 100644 --- a/sys/fs/nfsclient/nfs_clsubs.c +++ b/sys/fs/nfsclient/nfs_clsubs.c @@ -174,9 +174,9 @@ ncl_printf(const char *fmt, ...) #ifdef NFS_ACDEBUG #include -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); static int nfs_acdebug; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, ""); +SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, ""); #endif /* diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index b11160be6fcd..b062d2cd46c6 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -83,18 +83,16 @@ extern struct nfsstats newnfsstats; MALLOC_DEFINE(M_NEWNFSREQ, "newnfsclient_req", "New NFS request header"); MALLOC_DEFINE(M_NEWNFSMNT, "newnfsmnt", "New NFS mount struct"); -SYSCTL_DECL(_vfs_newnfs); -SYSCTL_STRUCT(_vfs_newnfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, - &newnfsstats, nfsstats, "S,nfsstats"); +SYSCTL_DECL(_vfs_nfs); static int nfs_ip_paranoia = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, &nfs_ip_paranoia, 0, ""); static int nfs_tprintf_initial_delay = NFS_TPRINTF_INITIAL_DELAY; -SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_INITIAL_DELAY, +SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_INITIAL_DELAY, downdelayinitial, CTLFLAG_RW, &nfs_tprintf_initial_delay, 0, ""); /* how long between console messages "nfs server foo not responding" */ static int nfs_tprintf_delay = NFS_TPRINTF_DELAY; -SYSCTL_INT(_vfs_newnfs, NFS_TPRINTF_DELAY, +SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_DELAY, downdelayinterval, CTLFLAG_RW, &nfs_tprintf_delay, 0, ""); static int nfs_mountroot(struct mount *); @@ -152,14 +150,14 @@ struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; int nfs_diskless_valid = 0; #endif -SYSCTL_INT(_vfs_newnfs, OID_AUTO, diskless_valid, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly"); -SYSCTL_STRING(_vfs_newnfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, +SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, nfsv3_diskless.root_hostnam, 0, "Path to nfs root"); -SYSCTL_OPAQUE(_vfs_newnfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, +SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, &nfsv3_diskless.root_saddr, sizeof(nfsv3_diskless.root_saddr), "%Ssockaddr_in", "Diskless root nfs address"); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 6dc709fc9ce4..eac9eaa4c19f 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -199,27 +199,27 @@ static int nfs_renameit(struct vnode *sdvp, struct vnode *svp, */ #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) -SYSCTL_DECL(_vfs_newnfs); +SYSCTL_DECL(_vfs_nfs); static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout"); static int nfs_prime_access_cache = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, &nfs_prime_access_cache, 0, "Prime NFS ACCESS cache when fetching attributes"); static int newnfs_commit_on_close = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, commit_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_on_close, CTLFLAG_RW, &newnfs_commit_on_close, 0, "write+commit on close, else only write"); static int nfs_clean_pages_on_close = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, &nfs_clean_pages_on_close, 0, "NFS clean dirty pages on close"); int newnfs_directio_enable = 0; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, &newnfs_directio_enable, 0, "Enable NFS directio"); /* @@ -234,14 +234,14 @@ SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, * meaningful. */ int newnfs_directio_allow_mmap = 1; -SYSCTL_INT(_vfs_newnfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, +SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, &newnfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); #if 0 -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, &newnfsstats.accesscache_hits, 0, "NFS ACCESS cache hit count"); -SYSCTL_INT(_vfs_newnfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, +SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, &newnfsstats.accesscache_misses, 0, "NFS ACCESS cache miss count"); #endif diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index aa5444e3c8f4..a3f857599f42 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -104,6 +105,13 @@ struct g_part_alias_list { { "netbsd-swap", G_PART_ALIAS_NETBSD_SWAP }, }; +SYSCTL_DECL(_kern_geom); +SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0, "GEOM_PART stuff"); +static u_int check_integrity = 1; +TUNABLE_INT("kern.geom.part.check_integrity", &check_integrity); +SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity, CTLFLAG_RW, + &check_integrity, 1, "Enable integrity checking"); + /* * The GEOM partitioning class. */ @@ -231,47 +239,111 @@ g_part_geometry(struct g_part_table *table, struct g_consumer *cp, } } +#define DPRINTF(...) if (bootverbose) { \ + printf("GEOM_PART: " __VA_ARGS__); \ +} + static int g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp) { struct g_part_entry *e1, *e2; struct g_provider *pp; + int failed; + failed = 0; pp = cp->provider; - if (table->gpt_first > table->gpt_last || - table->gpt_last > pp->mediasize / pp->sectorsize - 1) - goto fail; - + if (table->gpt_last < table->gpt_first) { + DPRINTF("last LBA is below first LBA: %jd < %jd\n", + (intmax_t)table->gpt_last, (intmax_t)table->gpt_first); + failed++; + } + if (table->gpt_last > pp->mediasize / pp->sectorsize - 1) { + DPRINTF("last LBA extends beyond mediasize: " + "%jd > %jd\n", (intmax_t)table->gpt_last, + (intmax_t)pp->mediasize / pp->sectorsize - 1); + failed++; + } LIST_FOREACH(e1, &table->gpt_entry, gpe_entry) { if (e1->gpe_deleted || e1->gpe_internal) continue; - if (e1->gpe_start < table->gpt_first || - e1->gpe_start > table->gpt_last || - e1->gpe_end < e1->gpe_start || - e1->gpe_end > table->gpt_last) - goto fail; + if (e1->gpe_start < table->gpt_first) { + DPRINTF("partition %d has start offset below first " + "LBA: %jd < %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_start, + (intmax_t)table->gpt_first); + failed++; + } + if (e1->gpe_start > table->gpt_last) { + DPRINTF("partition %d has start offset beyond last " + "LBA: %jd > %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_start, + (intmax_t)table->gpt_last); + failed++; + } + if (e1->gpe_end < e1->gpe_start) { + DPRINTF("partition %d has end offset below start " + "offset: %jd < %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_end, + (intmax_t)e1->gpe_start); + failed++; + } + if (e1->gpe_end > table->gpt_last) { + DPRINTF("partition %d has end offset beyond last " + "LBA: %jd > %jd\n", e1->gpe_index, + (intmax_t)e1->gpe_end, + (intmax_t)table->gpt_last); + failed++; + } e2 = e1; while ((e2 = LIST_NEXT(e2, gpe_entry)) != NULL) { if (e2->gpe_deleted || e2->gpe_internal) continue; if (e1->gpe_start >= e2->gpe_start && - e1->gpe_start <= e2->gpe_end) - goto fail; + e1->gpe_start <= e2->gpe_end) { + DPRINTF("partition %d has start offset inside " + "partition %d: start[%d] %jd >= start[%d] " + "%jd <= end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e2->gpe_index, (intmax_t)e2->gpe_start, + e1->gpe_index, (intmax_t)e1->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_end); + failed++; + } if (e1->gpe_end >= e2->gpe_start && - e1->gpe_end <= e2->gpe_end) - goto fail; + e1->gpe_end <= e2->gpe_end) { + DPRINTF("partition %d has end offset inside " + "partition %d: start[%d] %jd >= end[%d] " + "%jd <= end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e2->gpe_index, (intmax_t)e2->gpe_start, + e1->gpe_index, (intmax_t)e1->gpe_end, + e2->gpe_index, (intmax_t)e2->gpe_end); + failed++; + } if (e1->gpe_start < e2->gpe_start && - e1->gpe_end > e2->gpe_end) - goto fail; + e1->gpe_end > e2->gpe_end) { + DPRINTF("partition %d contains partition %d: " + "start[%d] %jd > start[%d] %jd, end[%d] " + "%jd < end[%d] %jd\n", + e1->gpe_index, e2->gpe_index, + e1->gpe_index, (intmax_t)e1->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_start, + e2->gpe_index, (intmax_t)e2->gpe_end, + e1->gpe_index, (intmax_t)e1->gpe_end); + failed++; + } } } - return (0); -fail: - if (bootverbose) + if (failed != 0) { printf("GEOM_PART: integrity check failed (%s, %s)\n", pp->name, table->gpt_scheme->name); - return (EINVAL); + if (check_integrity != 0) + return (EINVAL); + table->gpt_corrupt = 1; + } + return (0); } +#undef DPRINTF struct g_part_entry * g_part_new_entry(struct g_part_table *table, int index, quad_t start, diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index 604bd2d056f2..dd8bab5275e7 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #ifdef KDTRACE_HOOKS #include -cyclic_clock_func_t cyclic_clock_func[MAXCPU]; +cyclic_clock_func_t cyclic_clock_func = NULL; #endif int cpu_disable_deep_sleep = 0; /* Timer dies in C3. */ @@ -128,6 +128,9 @@ struct pcpu_state { struct bintime nexthard; /* Next hardlock() event. */ struct bintime nextstat; /* Next statclock() event. */ struct bintime nextprof; /* Next profclock() event. */ +#ifdef KDTRACE_HOOKS + struct bintime nextcyc; /* Next OpenSolaris cyclics event. */ +#endif int ipi; /* This CPU needs IPI. */ int idle; /* This CPU is in idle mode. */ }; @@ -190,17 +193,10 @@ handleevents(struct bintime *now, int fake) usermode = TRAPF_USERMODE(frame); pc = TRAPF_PC(frame); } -#ifdef KDTRACE_HOOKS - /* - * If the DTrace hooks are configured and a callback function - * has been registered, then call it to process the high speed - * timers. - */ - if (!fake && cyclic_clock_func[curcpu] != NULL) - (*cyclic_clock_func[curcpu])(frame); -#endif + runs = 0; state = DPCPU_PTR(timerstate); + while (bintime_cmp(now, &state->nexthard, >=)) { bintime_add(&state->nexthard, &hardperiod); runs++; @@ -224,6 +220,16 @@ handleevents(struct bintime *now, int fake) } } else state->nextprof = state->nextstat; + +#ifdef KDTRACE_HOOKS + if (fake == 0 && cyclic_clock_func != NULL && + state->nextcyc.sec != -1 && + bintime_cmp(now, &state->nextcyc, >=)) { + state->nextcyc.sec = -1; + (*cyclic_clock_func)(frame); + } +#endif + getnextcpuevent(&t, 0); if (fake == 2) { state->nextevent = t; @@ -263,10 +269,13 @@ getnextcpuevent(struct bintime *event, int idle) } else { /* If CPU is active - handle all types of events. */ if (bintime_cmp(event, &state->nextstat, >)) *event = state->nextstat; - if (profiling && - bintime_cmp(event, &state->nextprof, >)) + if (profiling && bintime_cmp(event, &state->nextprof, >)) *event = state->nextprof; } +#ifdef KDTRACE_HOOKS + if (state->nextcyc.sec != -1 && bintime_cmp(event, &state->nextcyc, >)) + *event = state->nextcyc; +#endif } /* @@ -590,6 +599,9 @@ cpu_initclocks_bsp(void) CPU_FOREACH(cpu) { state = DPCPU_ID_PTR(cpu, timerstate); mtx_init(&state->et_hw_mtx, "et_hw_mtx", NULL, MTX_SPIN); +#ifdef KDTRACE_HOOKS + state->nextcyc.sec = -1; +#endif } #ifdef SMP callout_new_inserted = cpu_new_callout; @@ -784,6 +796,43 @@ cpu_activeclock(void) spinlock_exit(); } +#ifdef KDTRACE_HOOKS +void +clocksource_cyc_set(const struct bintime *t) +{ + struct bintime now; + struct pcpu_state *state; + + state = DPCPU_PTR(timerstate); + if (periodic) + now = state->now; + else + binuptime(&now); + + CTR4(KTR_SPARE2, "set_cyc at %d: now %d.%08x%08x", + curcpu, now.sec, (unsigned int)(now.frac >> 32), + (unsigned int)(now.frac & 0xffffffff)); + CTR4(KTR_SPARE2, "set_cyc at %d: t %d.%08x%08x", + curcpu, t->sec, (unsigned int)(t->frac >> 32), + (unsigned int)(t->frac & 0xffffffff)); + + ET_HW_LOCK(state); + if (bintime_cmp(t, &state->nextcyc, ==)) { + ET_HW_UNLOCK(state); + return; + } + state->nextcyc = *t; + if (bintime_cmp(&state->nextcyc, &state->nextevent, >=)) { + ET_HW_UNLOCK(state); + return; + } + state->nextevent = state->nextcyc; + if (!periodic) + loadtimer(&now, 0); + ET_HW_UNLOCK(state); +} +#endif + #ifdef SMP static void cpu_new_callout(int cpu, int ticks) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 0d083b4b33e9..793e17ec4ebb 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -94,7 +94,8 @@ _assert_sbuf_integrity(const char *fun, struct sbuf *s) KASSERT(s->s_buf != NULL, ("%s called with uninitialized or corrupt sbuf", fun)); KASSERT(s->s_len < s->s_size, - ("wrote past end of sbuf (%d >= %d)", s->s_len, s->s_size)); + ("wrote past end of sbuf (%jd >= %jd)", + (intmax_t)s->s_len, (intmax_t)s->s_size)); } static void @@ -255,16 +256,17 @@ sbuf_clear(struct sbuf *s) * Effectively truncates the sbuf at the new position. */ int -sbuf_setpos(struct sbuf *s, int pos) +sbuf_setpos(struct sbuf *s, ssize_t pos) { assert_sbuf_integrity(s); assert_sbuf_state(s, 0); KASSERT(pos >= 0, - ("attempt to seek to a negative position (%d)", pos)); + ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); KASSERT(pos < s->s_size, - ("attempt to seek past end of sbuf (%d >= %d)", pos, s->s_size)); + ("attempt to seek past end of sbuf (%jd >= %jd)", + (intmax_t)pos, (intmax_t)s->s_size)); if (pos < 0 || pos > s->s_len) return (-1); @@ -640,7 +642,7 @@ sbuf_trim(struct sbuf *s) * Check if an sbuf has an error. */ int -sbuf_error(struct sbuf *s) +sbuf_error(const struct sbuf *s) { return (s->s_error); @@ -691,7 +693,7 @@ sbuf_data(struct sbuf *s) /* * Return the length of the sbuf data. */ -int +ssize_t sbuf_len(struct sbuf *s) { @@ -728,7 +730,7 @@ sbuf_delete(struct sbuf *s) * Check if an sbuf has been finished. */ int -sbuf_done(struct sbuf *s) +sbuf_done(const struct sbuf *s) { return (SBUF_ISFINISHED(s)); diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c index c56f31f9331a..09dbfabed320 100644 --- a/sys/nfs/nfs_common.c +++ b/sys/nfs/nfs_common.c @@ -361,7 +361,7 @@ nfsm_adv_xx(int s, struct mbuf **md, caddr_t *dpos) * * We would prefer to avoid this situation entirely. The situation does not * occur with NFS/UDP and is supposed to only occassionally occur with TCP. - * Use vfs.nfs.realign_count and realign_test to check this. + * Use vfs.nfs_common.realign_count and realign_test to check this. */ int nfs_realign(struct mbuf **pm, int how) diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h index 99b86f85d7a2..22a291a0d89c 100644 --- a/sys/nfsclient/nfs.h +++ b/sys/nfsclient/nfs.h @@ -107,7 +107,7 @@ #endif /* - * vfs.nfs sysctl(3) identifiers + * vfs.oldnfs sysctl(3) identifiers */ #define NFS_NFSSTATS 1 /* struct: struct nfsstats */ diff --git a/sys/nfsclient/nfs_krpc.c b/sys/nfsclient/nfs_krpc.c index bfb1ea177eff..242d42521f38 100644 --- a/sys/nfsclient/nfs_krpc.c +++ b/sys/nfsclient/nfs_krpc.c @@ -93,16 +93,16 @@ static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; static int fake_wchan; -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); -SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "Buffer reservation size 2 < x < 64"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0, "Number of times the nfs client has had to reconnect"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs3_jukebox_delay, CTLFLAG_RW, &nfs3_jukebox_delay, 0, "Number of seconds to delay a retry after receiving EJUKEBOX"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, "Disable weak cache consistency checking when server returns an error"); diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index fcb987e57677..d34c205a48e5 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -78,11 +78,11 @@ static void nfssvc_iod(void *); static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON]; -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); /* Maximum number of seconds a nfsiod kthread will sleep before exiting */ static unsigned int nfs_iodmaxidle = 120; -SYSCTL_UINT(_vfs_nfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, +SYSCTL_UINT(_vfs_oldnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0, "Max number of seconds an nfsiod kthread will sleep before exiting"); /* Maximum number of nfsiod kthreads */ @@ -121,7 +121,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS) mtx_unlock(&nfs_iod_mtx); return (0); } -SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_oldnfs, OID_AUTO, iodmin, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmin), sysctl_iodmin, "IU", "Min number of nfsiod kthreads to keep as spares"); @@ -158,7 +158,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS) mtx_unlock(&nfs_iod_mtx); return (0); } -SYSCTL_PROC(_vfs_nfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, +SYSCTL_PROC(_vfs_oldnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, sizeof (nfs_iodmax), sysctl_iodmax, "IU", "Max number of nfsiod kthreads"); @@ -213,7 +213,7 @@ nfsiod_setup(void *dummy) { int error; - TUNABLE_INT_FETCH("vfs.nfs.iodmin", &nfs_iodmin); + TUNABLE_INT_FETCH("vfs.oldnfs.iodmin", &nfs_iodmin); mtx_lock(&nfs_iod_mtx); /* Silently limit the start number of nfsiod's */ if (nfs_iodmin > NFS_MAXASYNCDAEMON) @@ -229,7 +229,7 @@ nfsiod_setup(void *dummy) SYSINIT(nfsiod, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY, nfsiod_setup, NULL); static int nfs_defect = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "Allow nfsiods to migrate serving different mounts"); /* diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c index fe4f5cc545a1..19fde06dab07 100644 --- a/sys/nfsclient/nfs_subs.c +++ b/sys/nfsclient/nfs_subs.c @@ -653,9 +653,9 @@ nfs_loadattrcache(struct vnode **vpp, struct mbuf **mdp, caddr_t *dposp, #ifdef NFS_ACDEBUG #include -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); static int nfs_acdebug; -SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "Toggle acdebug (attribute cache debug) flag"); #endif diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index ba3f41d5552f..04fd37500669 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -90,25 +90,25 @@ uma_zone_t nfsmount_zone; struct nfsstats nfsstats; -SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "NFS filesystem"); -SYSCTL_STRUCT(_vfs_nfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, +SYSCTL_NODE(_vfs, OID_AUTO, oldnfs, CTLFLAG_RW, 0, "Old NFS filesystem"); +SYSCTL_STRUCT(_vfs_oldnfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RW, &nfsstats, nfsstats, "S,nfsstats"); static int nfs_ip_paranoia = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_ip_paranoia, CTLFLAG_RW, &nfs_ip_paranoia, 0, "Disallow accepting replies from IPs which differ from those sent"); #ifdef NFS_DEBUG int nfs_debug; -SYSCTL_INT(_vfs_nfs, OID_AUTO, debug, CTLFLAG_RW, &nfs_debug, 0, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, debug, CTLFLAG_RW, &nfs_debug, 0, "Toggle debug flag"); #endif static int nfs_tprintf_initial_delay = NFS_TPRINTF_INITIAL_DELAY; -SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_INITIAL_DELAY, +SYSCTL_INT(_vfs_oldnfs, NFS_TPRINTF_INITIAL_DELAY, downdelayinitial, CTLFLAG_RW, &nfs_tprintf_initial_delay, 0, "Delay before printing \"nfs server not responding\" messages"); /* how long between console messages "nfs server foo not responding" */ static int nfs_tprintf_delay = NFS_TPRINTF_DELAY; -SYSCTL_INT(_vfs_nfs, NFS_TPRINTF_DELAY, +SYSCTL_INT(_vfs_oldnfs, NFS_TPRINTF_DELAY, downdelayinterval, CTLFLAG_RW, &nfs_tprintf_delay, 0, "Delay between printing \"nfs server not responding\" messages"); @@ -176,14 +176,14 @@ struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; int nfs_diskless_valid = 0; #endif -SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, diskless_valid, CTLFLAG_RD, &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly"); -SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, +SYSCTL_STRING(_vfs_oldnfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD, nfsv3_diskless.root_hostnam, 0, "Path to nfs root"); -SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, +SYSCTL_OPAQUE(_vfs_oldnfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD, &nfsv3_diskless.root_saddr, sizeof nfsv3_diskless.root_saddr, "%Ssockaddr_in", "Diskless root nfs address"); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index fb3a746c9461..61fcb6c5714f 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -217,27 +217,27 @@ struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON]; int nfs_numasync = 0; #define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) -SYSCTL_DECL(_vfs_nfs); +SYSCTL_DECL(_vfs_oldnfs); static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO; -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW, &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout"); static int nfs_prime_access_cache = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, prime_access_cache, CTLFLAG_RW, &nfs_prime_access_cache, 0, "Prime NFS ACCESS cache when fetching attributes"); static int nfsv3_commit_on_close = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfsv3_commit_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfsv3_commit_on_close, CTLFLAG_RW, &nfsv3_commit_on_close, 0, "write+commit on close, else only write"); static int nfs_clean_pages_on_close = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, clean_pages_on_close, CTLFLAG_RW, &nfs_clean_pages_on_close, 0, "NFS clean dirty pages on close"); int nfs_directio_enable = 0; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, &nfs_directio_enable, 0, "Enable NFS directio"); /* @@ -252,14 +252,14 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, * meaningful. */ int nfs_directio_allow_mmap = 1; -SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, nfs_directio_allow_mmap, CTLFLAG_RW, &nfs_directio_allow_mmap, 0, "Enable mmaped IO on file with O_DIRECT opens"); #if 0 -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_hits, CTLFLAG_RD, &nfsstats.accesscache_hits, 0, "NFS ACCESS cache hit count"); -SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, +SYSCTL_INT(_vfs_oldnfs, OID_AUTO, access_cache_misses, CTLFLAG_RD, &nfsstats.accesscache_misses, 0, "NFS ACCESS cache miss count"); #endif diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index 775a17c53e38..b2e104a2fd6f 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -1148,8 +1148,6 @@ moea64_zero_page_area(mmu_t mmu, vm_page_t m, int off, int size) { vm_offset_t pa = VM_PAGE_TO_PHYS(m); - if (!moea64_initialized) - panic("moea64_zero_page: can't zero pa %#" PRIxPTR, pa); if (size + off > PAGE_SIZE) panic("moea64_zero_page: size + off > PAGE_SIZE"); @@ -1172,9 +1170,6 @@ moea64_zero_page(mmu_t mmu, vm_page_t m) vm_offset_t pa = VM_PAGE_TO_PHYS(m); vm_offset_t va, off; - if (!moea64_initialized) - panic("moea64_zero_page: can't zero pa %#zx", pa); - if (!hw_direct_map) { mtx_lock(&moea64_scratchpage_mtx); diff --git a/sys/powerpc/powerpc/platform.c b/sys/powerpc/powerpc/platform.c index 02d89ee3dae2..9eb8f30e4501 100644 --- a/sys/powerpc/powerpc/platform.c +++ b/sys/powerpc/powerpc/platform.c @@ -93,7 +93,7 @@ mem_valid(vm_offset_t addr, int len) for (i = 0; i < npregions; i++) if ((addr >= pregions[i].mr_start) - && (addr + len < pregions[i].mr_start + pregions[i].mr_size)) + && (addr + len <= pregions[i].mr_start + pregions[i].mr_size)) return (0); return (EFAULT); diff --git a/sys/sys/dtrace_bsd.h b/sys/sys/dtrace_bsd.h index 2eded7b689a3..15e1be9d7616 100644 --- a/sys/sys/dtrace_bsd.h +++ b/sys/sys/dtrace_bsd.h @@ -44,14 +44,9 @@ struct reg; * subsystem into the appropriate timer interrupt. */ typedef void (*cyclic_clock_func_t)(struct trapframe *); +extern cyclic_clock_func_t cyclic_clock_func; -/* - * These external variables are actually machine-dependent, so - * they might not actually exist. - * - * Defining them here avoids a proliferation of header files. - */ -extern cyclic_clock_func_t cyclic_clock_func[]; +void clocksource_cyc_set(const struct bintime *t); /* * The dtrace module handles traps that occur during a DTrace probe. diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h index eeb38140da52..2a9cb0e9c1f0 100644 --- a/sys/sys/sbuf.h +++ b/sys/sys/sbuf.h @@ -44,8 +44,8 @@ struct sbuf { sbuf_drain_func *s_drain_func; /* drain function */ void *s_drain_arg; /* user-supplied drain argument */ int s_error; /* current error code */ - int s_size; /* size of storage buffer */ - int s_len; /* current length of string */ + ssize_t s_size; /* size of storage buffer */ + ssize_t s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ #define SBUF_AUTOEXTEND 0x00000001 /* automatically extend buffer */ #define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ @@ -63,7 +63,7 @@ struct sbuf *sbuf_new(struct sbuf *, char *, int, int); #define sbuf_new_auto() \ sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) void sbuf_clear(struct sbuf *); -int sbuf_setpos(struct sbuf *, int); +int sbuf_setpos(struct sbuf *, ssize_t); int sbuf_bcat(struct sbuf *, const void *, size_t); int sbuf_bcpy(struct sbuf *, const void *, size_t); int sbuf_cat(struct sbuf *, const char *); @@ -75,11 +75,11 @@ int sbuf_vprintf(struct sbuf *, const char *, __va_list) int sbuf_putc(struct sbuf *, int); void sbuf_set_drain(struct sbuf *, sbuf_drain_func *, void *); int sbuf_trim(struct sbuf *); -int sbuf_error(struct sbuf *); +int sbuf_error(const struct sbuf *); int sbuf_finish(struct sbuf *); char *sbuf_data(struct sbuf *); -int sbuf_len(struct sbuf *); -int sbuf_done(struct sbuf *); +ssize_t sbuf_len(struct sbuf *); +int sbuf_done(const struct sbuf *); void sbuf_delete(struct sbuf *); #ifdef _KERNEL diff --git a/usr.bin/nfsstat/nfsstat.c b/usr.bin/nfsstat/nfsstat.c index b833123ef622..b8f29e66bf6b 100644 --- a/usr.bin/nfsstat/nfsstat.c +++ b/usr.bin/nfsstat/nfsstat.c @@ -221,10 +221,10 @@ readstats(struct nfsstats **stp, struct nfsrvstats **srvstp, int zero) if (zero) bzero(&zerostat, sizeof(zerostat)); buflen = sizeof(struct nfsstats); - if (*stp != NULL && sysctlbyname("vfs.nfs.nfsstats", *stp, + if (*stp != NULL && sysctlbyname("vfs.oldnfs.nfsstats", *stp, &buflen, zero ? &zerostat : NULL, zero ? buflen : 0) < 0) { if (errno != ENOENT) - err(1, "sysctl: vfs.nfs.nfsstats"); + err(1, "sysctl: vfs.oldnfs.nfsstats"); *stp = NULL; } buflen = sizeof(struct nfsrvstats); diff --git a/usr.sbin/nfsd/nfsv4.4 b/usr.sbin/nfsd/nfsv4.4 index 071a646814e4..ba855d20e05f 100644 --- a/usr.sbin/nfsd/nfsv4.4 +++ b/usr.sbin/nfsd/nfsv4.4 @@ -24,14 +24,14 @@ .\" .\" $FreeBSD$ .\" -.Dd April 10, 2011 +.Dd May 15, 2011 .Dt NFSV4 4 .Os .Sh NAME .Nm NFSv4 .Nd NFS Version 4 Protocol .Sh DESCRIPTION -The experimental NFS client and server provides support for the +The NFS client and server provides support for the .Tn NFSv4 specification; see .%T "Network File System (NFS) Version 4 Protocol RFC 3530" . @@ -153,27 +153,11 @@ with RPCSEC_GSS (sec=krb5, krb5i, krb5p), only names and KerberosV tickets will go on the wire. .Sh SERVER SETUP .Pp -To set up the experimental NFS server that supports +To set up the NFS server that supports .Nm , -you will need to either build a kernel with: -.sp -.Bd -literal -offset indent -compact -options NFSD -.Ed -and not -.Bd -literal -offset indent -compact -options NFSSERVER -.Ed -.sp -or start -.Xr mountd 8 -and -.Xr nfsd 8 -with the ``-e'' option to force use of the experimental server. -The -.Xr nfsuserd 8 -daemon must also be running. -This will occur if +you will need to either set the variables in +.Xr rc.conf 5 +as follows: .sp .Bd -literal -offset indent -compact nfs_server_enable="YES" @@ -181,8 +165,14 @@ nfsv4_server_enable="YES" nfsuserd_enable="YES" .Ed .sp -are set in -.Xr rc.conf 5 . +or start +.Xr mountd 8 +and +.Xr nfsd 8 +without the ``-o'' option, which would force use of the old server. +The +.Xr nfsuserd 8 +daemon must also be running. .Pp You will also need to add at least one ``V4:'' line to the .Xr exports 5 @@ -196,7 +186,7 @@ there are a couple of .Xr sysctl 8 variables that you can change, which might improve performance. .Bl -tag -width Ds -.It Cm vfs.newnfs.issue_delegations +.It Cm vfs.nfsd.issue_delegations when set non-zero, allows the server to issue Open Delegations to clients. These delegations permit the client to manipulate the file @@ -208,7 +198,7 @@ This can only be enabled when the file systems being exported to clients are not being accessed locally on the server and, if being accessed via NFS Version 2 or 3 clients, these clients cannot be using the NLM. -.It Cm vfs.newnfs.enable_locallocks +.It Cm vfs.nfsd.enable_locallocks can be set to 0 to disable acquisition of local byte range locks. Disabling local locking can only be done if neither local accesses to the exported file systems nor the NLM is operating on them. @@ -217,7 +207,7 @@ to the exported file systems nor the NLM is operating on them. Note that Samba server access would be considered ``local access'' for the above discussion. .Pp -To build a kernel with the experimental +To build a kernel with the NFS server that supports .Nm linked into it, the .sp @@ -235,7 +225,9 @@ To do an mount, specify the ``nfsv4'' option on the .Xr mount_nfs 8 command line. -This will force use of the experimental client plus set ``tcp'' and +This will force use of the client that supports +.Nm +plus set ``tcp'' and .Nm . .Pp The @@ -269,16 +261,16 @@ To get callbacks to work when behind a NAT gateway, a port for the callback service will need to be set up on the NAT gateway and then the address of the NAT gateway (host IP plus port#) will need to be set by assigning the .Xr sysctl 8 -variable vfs.newnfs.callback_addr to a string of the form: +variable vfs.nfs.callback_addr to a string of the form: .sp N.N.N.N.N.N .sp where the first 4 Ns are the host IP address and the last two are the port# in network byte order (all decimal #s in the range 0-255). .Pp -To build a kernel with the experimental +To build a kernel with the client that supports .Nm -client linked into it, the option +linked into it, the option .sp .Bd -literal -offset indent -compact options NFSCL From 91b7b9b42725727fac6e5ae79b23628febe6ab79 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 17 May 2011 22:27:35 +0000 Subject: [PATCH 053/164] MFC --- share/man/man4/ahci.4 | 20 +++++++++++- sys/dev/ahci/ahci.c | 71 +++++++++++++++++++++++++++++++++++++++++++ sys/dev/ahci/ahci.h | 12 ++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) diff --git a/share/man/man4/ahci.4 b/share/man/man4/ahci.4 index 144d64b831a1..68aea35b6676 100644 --- a/share/man/man4/ahci.4 +++ b/share/man/man4/ahci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2010 +.Dd May 17, 2011 .Dt AHCI 4 .Os .Sh NAME @@ -121,6 +121,15 @@ hardware command queues (up to 32 commands per port), Native Command Queuing, SATA interface Power Management, device hot-plug and Message Signaled Interrupts. .Pp +Driver supports "LED" enclosure management messages, defined by the AHCI. +When supported by hardware, it allows to control per-port activity, locate +and fault LEDs via the +.Xr led 4 +API for localization and status reporting purposes. +Supporting AHCI controllers may transmit that information to the backplane +controllers via SGPIO interface. Backplane controllers interpret received +statuses in some way (IBPI standard) to report them using present indicators. +.Pp AHCI hardware is also supported by ataahci driver from .Xr ata 4 subsystem. @@ -135,6 +144,15 @@ subclass 6 (SATA) and programming interface 1 (AHCI). Also, in cooperation with atamarvell and atajmicron drivers of ata(4), it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers, such as JMicron JMB36x and Marvell 88SX61xx. +.Sh FILES +.Bl -tag -width /dev/led/ahcich*.locate +.It Pa /dev/led/ahcich*.act +activity LED device nodes +.It Pa /dev/led/ahcich*.fault +fault LED device nodes +.It Pa /dev/led/ahcich*.locate +locate LED device nodes +.El .Sh SEE ALSO .Xr ada 4 , .Xr ata 4 , diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 6ff8f9d72ef4..2a064923cf3c 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include "ahci.h" @@ -68,6 +69,7 @@ static int ahci_ch_resume(device_t dev); static void ahci_ch_pm(void *arg); static void ahci_ch_intr_locked(void *data); static void ahci_ch_intr(void *data); +static void ahci_ch_led(void *priv, int onoff); static int ahci_ctlr_reset(device_t dev); static int ahci_ctlr_setup(device_t dev); static void ahci_begin_transaction(device_t dev, union ccb *ccb); @@ -418,6 +420,8 @@ ahci_attach(device_t dev) ctlr->caps &= ~AHCI_CAP_SNCQ; if ((ctlr->caps & AHCI_CAP_CCCS) == 0) ctlr->ccc = 0; + mtx_init(&ctlr->em_mtx, "AHCI EM lock", NULL, MTX_DEF); + ctlr->emloc = ATA_INL(ctlr->r_mem, AHCI_EM_LOC); ahci_ctlr_setup(dev); /* Setup interrupts. */ if (ahci_setup_interrupt(dev)) { @@ -521,6 +525,7 @@ ahci_detach(device_t dev) rman_fini(&ctlr->sc_iomem); if (ctlr->r_mem) bus_release_resource(dev, SYS_RES_MEMORY, ctlr->r_rid, ctlr->r_mem); + mtx_destroy(&ctlr->em_mtx); return (0); } @@ -887,6 +892,7 @@ ahci_ch_attach(device_t dev) struct cam_devq *devq; int rid, error, i, sata_rev = 0; u_int32_t version; + char buf[32]; ch->dev = dev; ch->unit = (intptr_t)device_get_ivars(dev); @@ -995,6 +1001,25 @@ ahci_ch_attach(device_t dev) ahci_ch_pm, dev); } mtx_unlock(&ch->mtx); + if ((ch->caps & AHCI_CAP_EMS) && + (ctlr->capsem & AHCI_EM_LED)) { + for (i = 0; i < AHCI_NUM_LEDS; i++) { + ch->leds[i].dev = dev; + ch->leds[i].num = i; + } + if ((ctlr->capsem & AHCI_EM_ALHD) == 0) { + snprintf(buf, sizeof(buf), "%s.act", + device_get_nameunit(dev)); + ch->leds[0].led = led_create(ahci_ch_led, + &ch->leds[0], buf); + } + snprintf(buf, sizeof(buf), "%s.locate", + device_get_nameunit(dev)); + ch->leds[1].led = led_create(ahci_ch_led, &ch->leds[1], buf); + snprintf(buf, sizeof(buf), "%s.fault", + device_get_nameunit(dev)); + ch->leds[2].led = led_create(ahci_ch_led, &ch->leds[2], buf); + } return (0); err3: @@ -1014,7 +1039,12 @@ static int ahci_ch_detach(device_t dev) { struct ahci_channel *ch = device_get_softc(dev); + int i; + for (i = 0; i < AHCI_NUM_LEDS; i++) { + if (ch->leds[i].led) + led_destroy(ch->leds[i].led); + } mtx_lock(&ch->mtx); xpt_async(AC_LOST_DEVICE, ch->path, NULL); /* Forget about reset. */ @@ -1137,6 +1167,47 @@ static driver_t ahcich_driver = { }; DRIVER_MODULE(ahcich, ahci, ahcich_driver, ahcich_devclass, 0, 0); +static void +ahci_ch_setleds(device_t dev) +{ + struct ahci_channel *ch; + struct ahci_controller *ctlr; + size_t buf; + int i, timeout; + int16_t val; + + ctlr = device_get_softc(device_get_parent(dev)); + ch = device_get_softc(dev); + + val = 0; + for (i = 0; i < AHCI_NUM_LEDS; i++) + val |= ch->leds[i].state << (i * 3); + + buf = (ctlr->emloc & 0xffff0000) >> 14; + mtx_lock(&ctlr->em_mtx); + timeout = 1000; + while (ATA_INL(ctlr->r_mem, AHCI_EM_CTL) & (AHCI_EM_TM | AHCI_EM_RST) && + --timeout > 0) + DELAY(1000); + if (timeout == 0) + device_printf(dev, "EM timeout\n"); + ATA_OUTL(ctlr->r_mem, buf, (1 << 8) | (0 << 16) | (0 << 24)); + ATA_OUTL(ctlr->r_mem, buf + 4, ch->unit | (val << 16)); + ATA_OUTL(ctlr->r_mem, AHCI_EM_CTL, AHCI_EM_TM); + mtx_unlock(&ctlr->em_mtx); +} + +static void +ahci_ch_led(void *priv, int onoff) +{ + struct ahci_led *led; + + led = (struct ahci_led *)priv; + + led->state = onoff; + ahci_ch_setleds(led->dev); +} + struct ahci_dc_cb_args { bus_addr_t maddr; int error; diff --git a/sys/dev/ahci/ahci.h b/sys/dev/ahci/ahci.h index cd5356a3f622..3ace69fff925 100644 --- a/sys/dev/ahci/ahci.h +++ b/sys/dev/ahci/ahci.h @@ -376,6 +376,15 @@ struct ahci_device { u_int caps; }; +struct ahci_led { + device_t dev; /* Device handle */ + struct cdev *led; + uint8_t num; /* Number of this led */ + uint8_t state; /* State of this led */ +}; + +#define AHCI_NUM_LEDS 3 + /* structure describing an ATA channel */ struct ahci_channel { device_t dev; /* Device handle */ @@ -386,6 +395,7 @@ struct ahci_channel { struct ata_dma dma; /* DMA data */ struct cam_sim *sim; struct cam_path *path; + struct ahci_led leds[3]; uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t chcaps; /* Channel capabilities */ @@ -443,6 +453,7 @@ struct ahci_controller { uint32_t caps; /* Controller capabilities */ uint32_t caps2; /* Controller capabilities */ uint32_t capsem; /* Controller capabilities */ + uint32_t emloc; /* EM buffer location */ int quirks; int numirqs; int channels; @@ -453,6 +464,7 @@ struct ahci_controller { void (*function)(void *); void *argument; } interrupt[AHCI_MAX_PORTS]; + struct mtx em_mtx; /* EM access lock */ }; enum ahci_err_type { From 0828d417d4beda5c42e8953b1905d327f1da5653 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 15:50:12 +0000 Subject: [PATCH 054/164] Fix mismerge. Reported by: pluknet --- sys/kern/subr_smp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 83655e83159f..ce66f44cbaf8 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -53,10 +53,10 @@ __FBSDID("$FreeBSD$"); #include "opt_sched.h" #ifdef SMP -volatile cpumask_t stopped_cpus; -volatile cpumask_t started_cpus; -cpumask_t hlt_cpus_mask; -cpumask_t logical_cpus_mask; +volatile cpuset_t stopped_cpus; +volatile cpuset_t started_cpus; +cpuset_t hlt_cpus_mask; +cpuset_t logical_cpus_mask; void (*cpustop_restartfunc)(void); #endif From 6a2b7fdc52eb14729c2189dc85555fa8b5a37cb0 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 16:01:29 +0000 Subject: [PATCH 055/164] MFC --- lib/libprocstat/libprocstat.c | 1 + sys/amd64/amd64/identcpu.c | 53 +++++++++---------- sys/amd64/include/specialreg.h | 13 ++++- .../opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 6 +++ sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 4 -- sys/dev/ath/ath_rate/sample/sample.c | 34 +++++++++--- sys/dev/sound/usb/uaudio.c | 7 +-- sys/dev/usb/input/uhid.c | 4 -- sys/dev/usb/input/ukbd.c | 4 +- sys/dev/usb/input/ums.c | 4 +- sys/dev/usb/storage/umass.c | 5 +- sys/dev/usb/storage/ustorage_fs.c | 6 +-- sys/dev/usb/usb_device.c | 11 ---- sys/dev/usb/usbdi.h | 1 - sys/i386/i386/identcpu.c | 52 +++++++++--------- sys/i386/include/specialreg.h | 13 ++++- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c | 9 ++-- 17 files changed, 121 insertions(+), 106 deletions(-) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 8440bec2cbc6..384fe735e643 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -132,6 +132,7 @@ procstat_close(struct procstat *procstat) assert(procstat); if (procstat->type == PROCSTAT_KVM) kvm_close(procstat->kd); + free(procstat); } struct procstat * diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c index 1da4181f5ea4..805ba1e3dce4 100644 --- a/sys/amd64/amd64/identcpu.c +++ b/sys/amd64/amd64/identcpu.c @@ -216,6 +216,14 @@ printcpuinfo(void) printf(" Family = %x", CPUID_TO_FAMILY(cpu_id)); printf(" Model = %x", CPUID_TO_MODEL(cpu_id)); printf(" Stepping = %u", cpu_id & CPUID_STEPPING); + + /* + * AMD CPUID Specification + * http://support.amd.com/us/Embedded_TechDocs/25481.pdf + * + * Intel Processor Identification and CPUID Instruction + * http://www.intel.com/assets/pdf/appnote/241618.pdf + */ if (cpu_high > 0) { /* @@ -277,38 +285,29 @@ printcpuinfo(void) "\012SSSE3" /* SSSE3 */ "\013CNXT-ID" /* L1 context ID available */ "\014" - "\015" + "\015FMA" /* Fused Multiply Add */ "\016CX16" /* CMPXCHG16B Instruction */ "\017xTPR" /* Send Task Priority Messages*/ "\020PDCM" /* Perf/Debug Capability MSR */ "\021" - "\022PCID" /* Process-context Identifiers */ + "\022PCID" /* Process-context Identifiers*/ "\023DCA" /* Direct Cache Access */ - "\024SSE4.1" - "\025SSE4.2" + "\024SSE4.1" /* SSE 4.1 */ + "\025SSE4.2" /* SSE 4.2 */ "\026x2APIC" /* xAPIC Extensions */ - "\027MOVBE" - "\030POPCNT" - "\031" - "\032AESNI" /* AES Crypto*/ - "\033XSAVE" - "\034OSXSAVE" - "\035" - "\036" + "\027MOVBE" /* MOVBE Instruction */ + "\030POPCNT" /* POPCNT Instruction */ + "\031TSCDLT" /* TSC-Deadline Timer */ + "\032AESNI" /* AES Crypto */ + "\033XSAVE" /* XSAVE/XRSTOR States */ + "\034OSXSAVE" /* OS-Enabled State Management*/ + "\035AVX" /* Advanced Vector Extensions */ + "\036F16C" /* Half-precision conversions */ "\037" "\040HV" /* Hypervisor */ ); } - /* - * AMD64 Architecture Programmer's Manual Volume 3: - * General-Purpose and System Instructions - * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf - * - * IA-32 Intel Architecture Software Developer's Manual, - * Volume 2A: Instruction Set Reference, A-M - * ftp://download.intel.com/design/Pentium4/manuals/25366617.pdf - */ if (amd_feature != 0) { printf("\n AMD Features=0x%b", amd_feature, "\020" /* in hex */ @@ -361,18 +360,18 @@ printcpuinfo(void) "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */ "\012OSVW" /* OS visible workaround */ "\013IBS" /* Instruction based sampling */ - "\014SSE5" /* SSE5 */ + "\014XOP" /* XOP extended instructions */ "\015SKINIT" /* SKINIT/STGI */ "\016WDT" /* Watchdog timer */ "\017" - "\020" - "\021" + "\020LWP" /* Lightweight Profiling */ + "\021FMA4" /* 4-operand FMA instructions */ "\022" "\023" - "\024" + "\024NodeId" /* NodeId MSR support */ "\025" - "\026" - "\027" + "\026TBM" /* Trailing Bit Manipulation */ + "\027Topology" /* Topology Extensions */ "\030" "\031" "\032" diff --git a/sys/amd64/include/specialreg.h b/sys/amd64/include/specialreg.h index ac5206358b5e..4c501660909a 100644 --- a/sys/amd64/include/specialreg.h +++ b/sys/amd64/include/specialreg.h @@ -123,6 +123,7 @@ #define CPUID2_TM2 0x00000100 #define CPUID2_SSSE3 0x00000200 #define CPUID2_CNXTID 0x00000400 +#define CPUID2_FMA 0x00001000 #define CPUID2_CX16 0x00002000 #define CPUID2_XTPR 0x00004000 #define CPUID2_PDCM 0x00008000 @@ -133,7 +134,12 @@ #define CPUID2_X2APIC 0x00200000 #define CPUID2_MOVBE 0x00400000 #define CPUID2_POPCNT 0x00800000 +#define CPUID2_TSCDLT 0x01000000 #define CPUID2_AESNI 0x02000000 +#define CPUID2_XSAVE 0x04000000 +#define CPUID2_OSXSAVE 0x08000000 +#define CPUID2_AVX 0x10000000 +#define CPUID2_F16C 0x20000000 #define CPUID2_HV 0x80000000 /* @@ -170,9 +176,14 @@ #define AMDID2_PREFETCH 0x00000100 #define AMDID2_OSVW 0x00000200 #define AMDID2_IBS 0x00000400 -#define AMDID2_SSE5 0x00000800 +#define AMDID2_XOP 0x00000800 #define AMDID2_SKINIT 0x00001000 #define AMDID2_WDT 0x00002000 +#define AMDID2_LWP 0x00008000 +#define AMDID2_FMA4 0x00010000 +#define AMDID2_NODE_ID 0x00080000 +#define AMDID2_TBM 0x00200000 +#define AMDID2_TOPOLOGY 0x00400000 /* * CPUID instruction 1 eax info diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index f8912ca4e29f..ba13747ddb38 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -689,6 +689,9 @@ zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) * and destroying snapshots requires descendent permissions, a successfull * check of the top level snapshot applies to snapshots of all descendent * datasets as well. + * + * The top level snapshot may not exist when doing a recursive destroy. + * In this case fallback to permissions of the parent dataset. */ static int zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) @@ -700,6 +703,9 @@ zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, cred_t *cr) error = zfs_secpolicy_destroy_perms(dsname, cr); + if (error == ENOENT) + error = zfs_secpolicy_destroy_perms(zc->zc_name, cr); + strfree(dsname); return (error); } diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index e45a8293e1fa..d2ae351f7306 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -1368,10 +1368,6 @@ ar5416UpdateChainMasks(struct ath_hal *ah, HAL_BOOL is_ht) AH5416(ah)->ah_rx_chainmask); } -#ifndef IS_5GHZ_FAST_CLOCK_EN -#define IS_5GHZ_FAST_CLOCK_EN(ah, chan) AH_FALSE -#endif - void ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan) { diff --git a/sys/dev/ath/ath_rate/sample/sample.c b/sys/dev/ath/ath_rate/sample/sample.c index 312623e05660..27bb98cf8739 100644 --- a/sys/dev/ath/ath_rate/sample/sample.c +++ b/sys/dev/ath/ath_rate/sample/sample.c @@ -161,9 +161,10 @@ dot11rate_label(const HAL_RATE_TABLE *rt, int rix) * or -1 if all the average_tx_times are 0. */ static __inline int -pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, +pick_best_rate(struct ath_node *an, const HAL_RATE_TABLE *rt, int size_bin, int require_acked_before) { + struct sample_node *sn = ATH_NODE_SAMPLE(an); int best_rate_rix, best_rate_tt; uint32_t mask; int rix, tt; @@ -174,6 +175,12 @@ pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, if ((mask & 1) == 0) /* not a supported rate */ continue; + /* Don't pick a non-HT rate for a HT node */ + if ((an->an_node.ni_flags & IEEE80211_NODE_HT) && + (rt->info[rix].phy != IEEE80211_T_HT)) { + continue; + } + tt = sn->stats[size_bin][rix].average_tx_time; if (tt <= 0 || (require_acked_before && @@ -196,11 +203,12 @@ pick_best_rate(struct sample_node *sn, const HAL_RATE_TABLE *rt, * Pick a good "random" bit-rate to sample other than the current one. */ static __inline int -pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, +pick_sample_rate(struct sample_softc *ssc , struct ath_node *an, const HAL_RATE_TABLE *rt, int size_bin) { #define DOT11RATE(ix) (rt->info[ix].dot11Rate & IEEE80211_RATE_VAL) #define MCS(ix) (rt->info[ix].dot11Rate | IEEE80211_RATE_MCS) + struct sample_node *sn = ATH_NODE_SAMPLE(an); int current_rix, rix; unsigned current_tt; uint32_t mask; @@ -208,6 +216,7 @@ pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, current_rix = sn->current_rix[size_bin]; if (current_rix < 0) { /* no successes yet, send at the lowest bit-rate */ + /* XXX should return MCS0 if HT */ return 0; } @@ -223,6 +232,13 @@ pick_sample_rate(struct sample_softc *ssc , struct sample_node *sn, continue; } + /* if the node is HT and the rate isn't HT, don't bother sample */ + if ((an->an_node.ni_flags & IEEE80211_NODE_HT) && + (rt->info[rix].phy != IEEE80211_T_HT)) { + mask &= ~(1<stats[size_bin][rix].perfect_tx_time > current_tt) { mask &= ~(1< 11M */ - if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) { - mask &= ~(1< 11M for non-HT rates */ + if (! (an->an_node.ni_flags & IEEE80211_NODE_HT)) { + if (DOT11RATE(rix) > 2*11 && rix > current_rix + 2) { + mask &= ~(1<last_sample_rix[size_bin] = rix; @@ -327,7 +345,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, /* XXX TODO: this doesn't know about 11gn vs 11g protection; teach it */ mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT); - best_rix = pick_best_rate(sn, rt, size_bin, !mrr); + best_rix = pick_best_rate(an, rt, size_bin, !mrr); if (best_rix >= 0) { average_tx_time = sn->stats[size_bin][best_rix].average_tx_time; } else { @@ -338,7 +356,7 @@ ath_rate_findrate(struct ath_softc *sc, struct ath_node *an, * rates to sample_rate% of the total transmission time. */ if (sn->sample_tt[size_bin] < average_tx_time * (sn->packets_since_sample[size_bin]*ssc->sample_rate/100)) { - rix = pick_sample_rate(ssc, sn, rt, size_bin); + rix = pick_sample_rate(ssc, an, rt, size_bin); IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, "size %u sample rate %d current rate %d", bin_to_size(size_bin), RATE(rix), diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 8fbb7a6bdfec..4f8670a5213e 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -539,9 +539,6 @@ uaudio_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); - if (uaa->use_generic == 0) - return (ENXIO); - /* lookup non-standard device */ if (uaa->info.bInterfaceClass != UICLASS_AUDIO) { @@ -555,7 +552,7 @@ uaudio_probe(device_t dev) if (usb_test_quirk(uaa, UQ_BAD_AUDIO)) return (ENXIO); else - return (0); + return (BUS_PROBE_GENERIC); } /* check for MIDI stream */ @@ -564,7 +561,7 @@ uaudio_probe(device_t dev) if (usb_test_quirk(uaa, UQ_BAD_MIDI)) return (ENXIO); else - return (0); + return (BUS_PROBE_GENERIC); } return (ENXIO); } diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c index 8b33f83c860f..a7fd899c6fe0 100644 --- a/sys/dev/usb/input/uhid.c +++ b/sys/dev/usb/input/uhid.c @@ -617,10 +617,6 @@ uhid_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give Mouse and Keyboard drivers a try first */ - return (ENXIO); - } if (uaa->info.bInterfaceClass != UICLASS_HID) { /* the Xbox 360 gamepad doesn't use the HID class */ diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index 201523338485..918266389a49 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -771,7 +771,7 @@ ukbd_probe(device_t dev) if (usb_test_quirk(uaa, UQ_KBD_IGNORE)) return (ENXIO); else - return (BUS_PROBE_GENERIC); + return (BUS_PROBE_DEFAULT); } error = usbd_req_get_hid_desc(uaa->device, NULL, @@ -793,7 +793,7 @@ ukbd_probe(device_t dev) if (usb_test_quirk(uaa, UQ_KBD_IGNORE)) error = ENXIO; else - error = BUS_PROBE_GENERIC; + error = BUS_PROBE_DEFAULT; } else error = ENXIO; diff --git a/sys/dev/usb/input/ums.c b/sys/dev/usb/input/ums.c index af4bfc9fc0af..af9aa1f3a980 100644 --- a/sys/dev/usb/input/ums.c +++ b/sys/dev/usb/input/ums.c @@ -373,7 +373,7 @@ ums_probe(device_t dev) if ((uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) && (uaa->info.bInterfaceProtocol == UIPROTO_MOUSE)) - return (BUS_PROBE_GENERIC); + return (BUS_PROBE_DEFAULT); error = usbd_req_get_hid_desc(uaa->device, NULL, &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex); @@ -383,7 +383,7 @@ ums_probe(device_t dev) if (hid_is_collection(d_ptr, d_len, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))) - error = BUS_PROBE_GENERIC; + error = BUS_PROBE_DEFAULT; else error = ENXIO; diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index de6ad9da9a92..158d8432d7db 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -782,6 +782,7 @@ umass_probe_proto(device_t dev, struct usb_attach_arg *uaa) uint32_t proto = umass_get_proto(uaa->iface); memset(&ret, 0, sizeof(ret)); + ret.error = BUS_PROBE_GENERIC; /* Search for protocol enforcement */ @@ -870,10 +871,6 @@ umass_probe(device_t dev) if (uaa->usb_mode != USB_MODE_HOST) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give other drivers a try first */ - return (ENXIO); - } temp = umass_probe_proto(dev, uaa); return (temp.error); diff --git a/sys/dev/usb/storage/ustorage_fs.c b/sys/dev/usb/storage/ustorage_fs.c index c62c96b74cc2..dbf025ab895e 100644 --- a/sys/dev/usb/storage/ustorage_fs.c +++ b/sys/dev/usb/storage/ustorage_fs.c @@ -334,10 +334,6 @@ ustorage_fs_probe(device_t dev) if (uaa->usb_mode != USB_MODE_DEVICE) { return (ENXIO); } - if (uaa->use_generic == 0) { - /* give other drivers a try first */ - return (ENXIO); - } /* Check for a standards compliant device */ id = usbd_get_interface_descriptor(uaa->iface); if ((id == NULL) || @@ -346,7 +342,7 @@ ustorage_fs_probe(device_t dev) (id->bInterfaceProtocol != UIPROTO_MASS_BBB)) { return (ENXIO); } - return (0); + return (BUS_PROBE_GENERIC); } static int diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index a8b79a84b781..893e79dba07f 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -1334,7 +1334,6 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index) uaa.info.bIfaceIndex = i; uaa.info.bIfaceNum = iface->idesc->bInterfaceNumber; - uaa.use_generic = 0; uaa.driver_info = 0; /* reset driver_info */ DPRINTFN(2, "iclass=%u/%u/%u iindex=%u/%u\n", @@ -1344,16 +1343,6 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index) uaa.info.bIfaceIndex, uaa.info.bIfaceNum); - /* try specific interface drivers first */ - - if (usb_probe_and_attach_sub(udev, &uaa)) { - /* ignore */ - } - /* try generic interface drivers last */ - - uaa.use_generic = 1; - uaa.driver_info = 0; /* reset driver_info */ - if (usb_probe_and_attach_sub(udev, &uaa)) { /* ignore */ } diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 9bd326e70709..8f6da7c68c81 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -357,7 +357,6 @@ struct usb_attach_arg { struct usb_interface *iface; /* current interface */ enum usb_hc_mode usb_mode; /* host or device mode */ uint8_t port; - uint8_t use_generic; /* hint for generic drivers */ uint8_t dev_state; #define UAA_DEV_READY 0 #define UAA_DEV_DISABLED 1 diff --git a/sys/i386/i386/identcpu.c b/sys/i386/i386/identcpu.c index cd90d478ee43..de0ee09a8ce2 100644 --- a/sys/i386/i386/identcpu.c +++ b/sys/i386/i386/identcpu.c @@ -693,6 +693,13 @@ printcpuinfo(void) printf(" Stepping = %u", cpu_id & CPUID_STEPPING); if (cpu_vendor_id == CPU_VENDOR_CYRIX) printf("\n DIR=0x%04x", cyrix_did); + /* + * AMD CPUID Specification + * http://support.amd.com/us/Embedded_TechDocs/25481.pdf + * + * Intel Processor Identification and CPUID Instruction + * http://www.intel.com/assets/pdf/appnote/241618.pdf + */ if (cpu_high > 0) { /* @@ -754,38 +761,29 @@ printcpuinfo(void) "\012SSSE3" /* SSSE3 */ "\013CNXT-ID" /* L1 context ID available */ "\014" - "\015" + "\015FMA" /* Fused Multiply Add */ "\016CX16" /* CMPXCHG16B Instruction */ "\017xTPR" /* Send Task Priority Messages*/ "\020PDCM" /* Perf/Debug Capability MSR */ "\021" - "\022PCID" /* Process-context Identifiers */ + "\022PCID" /* Process-context Identifiers*/ "\023DCA" /* Direct Cache Access */ - "\024SSE4.1" - "\025SSE4.2" + "\024SSE4.1" /* SSE 4.1 */ + "\025SSE4.2" /* SSE 4.2 */ "\026x2APIC" /* xAPIC Extensions */ - "\027MOVBE" - "\030POPCNT" - "\031" - "\032AESNI" /* AES Crypto*/ - "\033XSAVE" - "\034OSXSAVE" - "\035" - "\036" + "\027MOVBE" /* MOVBE Instruction */ + "\030POPCNT" /* POPCNT Instruction */ + "\031TSCDLT" /* TSC-Deadline Timer */ + "\032AESNI" /* AES Crypto */ + "\033XSAVE" /* XSAVE/XRSTOR States */ + "\034OSXSAVE" /* OS-Enabled State Management*/ + "\035AVX" /* Advanced Vector Extensions */ + "\036F16C" /* Half-precision conversions */ "\037" "\040HV" /* Hypervisor */ ); } - /* - * AMD64 Architecture Programmer's Manual Volume 3: - * General-Purpose and System Instructions - * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf - * - * IA-32 Intel Architecture Software Developer's Manual, - * Volume 2A: Instruction Set Reference, A-M - * ftp://download.intel.com/design/Pentium4/manuals/25366617.pdf - */ if (amd_feature != 0) { printf("\n AMD Features=0x%b", amd_feature, "\020" /* in hex */ @@ -838,18 +836,18 @@ printcpuinfo(void) "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */ "\012OSVW" /* OS visible workaround */ "\013IBS" /* Instruction based sampling */ - "\014SSE5" /* SSE5 */ + "\014XOP" /* XOP extended instructions */ "\015SKINIT" /* SKINIT/STGI */ "\016WDT" /* Watchdog timer */ "\017" - "\020" - "\021" + "\020LWP" /* Lightweight Profiling */ + "\021FMA4" /* 4-operand FMA instructions */ "\022" "\023" - "\024" + "\024NodeId" /* NodeId MSR support */ "\025" - "\026" - "\027" + "\026TBM" /* Trailing Bit Manipulation */ + "\027Topology" /* Topology Extensions */ "\030" "\031" "\032" diff --git a/sys/i386/include/specialreg.h b/sys/i386/include/specialreg.h index adccaf4483f9..e3199f7a1a36 100644 --- a/sys/i386/include/specialreg.h +++ b/sys/i386/include/specialreg.h @@ -120,6 +120,7 @@ #define CPUID2_TM2 0x00000100 #define CPUID2_SSSE3 0x00000200 #define CPUID2_CNXTID 0x00000400 +#define CPUID2_FMA 0x00001000 #define CPUID2_CX16 0x00002000 #define CPUID2_XTPR 0x00004000 #define CPUID2_PDCM 0x00008000 @@ -130,7 +131,12 @@ #define CPUID2_X2APIC 0x00200000 #define CPUID2_MOVBE 0x00400000 #define CPUID2_POPCNT 0x00800000 +#define CPUID2_TSCDLT 0x01000000 #define CPUID2_AESNI 0x02000000 +#define CPUID2_XSAVE 0x04000000 +#define CPUID2_OSXSAVE 0x08000000 +#define CPUID2_AVX 0x10000000 +#define CPUID2_F16C 0x20000000 #define CPUID2_HV 0x80000000 /* @@ -167,9 +173,14 @@ #define AMDID2_PREFETCH 0x00000100 #define AMDID2_OSVW 0x00000200 #define AMDID2_IBS 0x00000400 -#define AMDID2_SSE5 0x00000800 +#define AMDID2_XOP 0x00000800 #define AMDID2_SKINIT 0x00001000 #define AMDID2_WDT 0x00002000 +#define AMDID2_LWP 0x00008000 +#define AMDID2_FMA4 0x00010000 +#define AMDID2_NODE_ID 0x00080000 +#define AMDID2_TBM 0x00200000 +#define AMDID2_TOPOLOGY 0x00400000 /* * CPUID instruction 1 eax info diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c index ee7fc35ab756..a13ef4d05f96 100644 --- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c +++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c @@ -409,6 +409,7 @@ static int ubt_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + int error; if (uaa->usb_mode != USB_MODE_HOST) return (ENXIO); @@ -416,14 +417,14 @@ ubt_probe(device_t dev) if (uaa->info.bIfaceIndex != 0) return (ENXIO); - if (uaa->use_generic == 0) - return (ENXIO); - if (usbd_lookup_id_by_uaa(ubt_ignore_devs, sizeof(ubt_ignore_devs), uaa) == 0) return (ENXIO); - return (usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa)); + error = usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa); + if (error == 0) + return (BUS_PROBE_GENERIC); + return (error); } /* ubt_probe */ /* From 91d9575722ed7a0062444a75cd501b9ae67c6fa1 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 16:20:28 +0000 Subject: [PATCH 056/164] MFC From 4be0b380f5d0ebcdd8204b3dd1abd7d9cbb384db Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 16:56:36 +0000 Subject: [PATCH 057/164] Fix usage of cpumask that cannot be used like that anymore. Reported by: pluknet --- sys/powerpc/booke/platform_bare.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/booke/platform_bare.c b/sys/powerpc/booke/platform_bare.c index 8e03bd32d460..6790e2bf0cec 100644 --- a/sys/powerpc/booke/platform_bare.c +++ b/sys/powerpc/booke/platform_bare.c @@ -241,7 +241,7 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) int timeout; eebpcr = ccsr_read4(OCP85XX_EEBPCR); - if ((eebpcr & (pc->pc_cpumask << 24)) != 0) { + if ((eebpcr & (1 << (pc->pc_cpuid + 24))) != 0) { printf("%s: CPU=%d already out of hold-off state!\n", __func__, pc->pc_cpuid); return (ENXIO); @@ -259,7 +259,7 @@ bare_smp_start_cpu(platform_t plat, struct pcpu *pc) /* * Release AP from hold-off state */ - eebpcr |= (pc->pc_cpumask << 24); + eebpcr |= (1 << (pc->pc_cpuid + 24)); ccsr_write4(OCP85XX_EEBPCR, eebpcr); __asm __volatile("isync; msync"); From ff6227dac7969d6ee829411d886560babf9263a7 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 17:18:44 +0000 Subject: [PATCH 058/164] MFC --- Makefile.inc1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.inc1 b/Makefile.inc1 index 4aa53da83d2f..1e613affecda 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1552,7 +1552,8 @@ _xb-build-tools: _xb-cross-tools: .for _tool in \ gnu/usr.bin/binutils \ - gnu/usr.bin/cc + gnu/usr.bin/cc \ + usr.bin/ar ${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,depend,all)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ obj; \ @@ -1577,7 +1578,8 @@ _xi-cross-tools: @echo "_xi-cross-tools" .for _tool in \ gnu/usr.bin/binutils \ - gnu/usr.bin/cc + gnu/usr.bin/cc \ + usr.bin/ar ${_+_}@${ECHODIR} "===> xdev ${_tool} (install)"; \ cd ${.CURDIR}/${_tool}; \ ${CDMAKE} DIRPRFX=${_tool}/ install DESTDIR=${XDDESTDIR} From f8e98f8a14bc1430bfe19cc9d343cfb4c36c2c01 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 18 May 2011 19:46:26 +0000 Subject: [PATCH 059/164] Fix compilation. Submitted by: andreast --- sys/powerpc/mpc85xx/openpic_fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/powerpc/mpc85xx/openpic_fdt.c b/sys/powerpc/mpc85xx/openpic_fdt.c index 7cf18eaaff90..1cd936956281 100644 --- a/sys/powerpc/mpc85xx/openpic_fdt.c +++ b/sys/powerpc/mpc85xx/openpic_fdt.c @@ -37,11 +37,12 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include +#include + #include "pic_if.h" static int openpic_fdt_probe(device_t); From ccbb37970b3270861b379906a11b534a14e9631d Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 20 May 2011 14:53:16 +0000 Subject: [PATCH 060/164] Reintroduce the lazypmap infrastructure and convert it to using cpuset_t. Requested by: alc --- sys/i386/i386/apic_vector.s | 16 ++++++ sys/i386/i386/db_trace.c | 3 +- sys/i386/i386/mp_machdep.c | 7 +++ sys/i386/i386/pmap.c | 99 +++++++++++++++++++++++++++++++++++++ sys/i386/i386/swtch.s | 6 +++ sys/i386/include/smp.h | 4 +- sys/i386/xen/mp_machdep.c | 11 ++++- sys/i386/xen/pmap.c | 99 +++++++++++++++++++++++++++++++++++++ 8 files changed, 242 insertions(+), 3 deletions(-) diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s index a78b60107e05..86e78c4beb2e 100644 --- a/sys/i386/i386/apic_vector.s +++ b/sys/i386/i386/apic_vector.s @@ -357,4 +357,20 @@ IDTVEC(rendezvous) POP_FRAME iret +/* + * Clean up when we lose out on the lazy context switch optimization. + * ie: when we are about to release a PTD but a cpu is still borrowing it. + */ + SUPERALIGN_TEXT +IDTVEC(lazypmap) + PUSH_FRAME + SET_KERNEL_SREGS + cld + + call pmap_lazyfix_action + + movl lapic, %eax + movl $0, LA_EOI(%eax) /* End Of Interrupt to APIC */ + POP_FRAME + iret #endif /* SMP */ diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 79da4dc576dc..445d9c5fe0df 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -312,7 +312,8 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) frame_type = TRAP_TIMERINT; else if (strcmp(name, "Xcpustop") == 0 || strcmp(name, "Xrendezvous") == 0 || - strcmp(name, "Xipi_intr_bitmap_handler") == 0) + strcmp(name, "Xipi_intr_bitmap_handler") == 0 || + strcmp(name, "Xlazypmap") == 0) frame_type = TRAP_INTERRUPT; } diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 966e46ea0729..fbaae89408a4 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -166,6 +166,7 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; +u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -575,6 +576,10 @@ cpu_mp_start(void) setidt(IPI_INVLCACHE, IDTVEC(invlcache), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); + /* Install an inter-CPU IPI for lazy pmap release */ + setidt(IPI_LAZYPMAP, IDTVEC(lazypmap), + SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); + /* Install an inter-CPU IPI for all-CPU rendezvous */ setidt(IPI_RENDEZVOUS, IDTVEC(rendezvous), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); @@ -1718,6 +1723,8 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:rendezvous", i); intrcnt_add(buf, &ipi_rendezvous_counts[i]); + snprintf(buf, sizeof(buf), "cpu%d:lazypmap", i); + intrcnt_add(buf, &ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), "cpu%d:hardclock", i); intrcnt_add(buf, &ipi_hardclock_counts[i]); } diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index c85f1387030e..d0699b5311a9 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1900,6 +1900,104 @@ pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags) * Pmap allocation/deallocation routines. ***************************************************/ +#ifdef SMP +/* + * Deal with a SMP shootdown of other users of the pmap that we are + * trying to dispose of. This can be a bit hairy. + */ +static cpuset_t *lazymask; +static u_int lazyptd; +static volatile u_int lazywait; + +void pmap_lazyfix_action(void); + +void +pmap_lazyfix_action(void) +{ + +#ifdef COUNT_IPIS + (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++; +#endif + if (rcr3() == lazyptd) + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_CLR_ATOMIC(PCPU_GET(cpuid), lazymask); + atomic_store_rel_int(&lazywait, 1); +} + +static void +pmap_lazyfix_self(cpuset_t mymask) +{ + + if (rcr3() == lazyptd) + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_NAND_ATOMIC(lazymask, &mymask); +} + + +static void +pmap_lazyfix(pmap_t pmap) +{ + cpuset_t mymask, mask; + u_int spins; + int lbs; + + mask = pmap->pm_active; + while (!CPU_EMPTY(&mask)) { + spins = 50000000; + + /* Find least significant set bit. */ + lsb = cpusetobj_ffs(&mask); + lsb--; + CPU_SETOF(lsb, &mask); + mtx_lock_spin(&smp_ipi_mtx); +#ifdef PAE + lazyptd = vtophys(pmap->pm_pdpt); +#else + lazyptd = vtophys(pmap->pm_pdir); +#endif + mymask = PCPU_GET(cpumask); + if (mask == mymask) { + lazymask = &pmap->pm_active; + pmap_lazyfix_self(mymask); + } else { + atomic_store_rel_int((u_int *)&lazymask, + (u_int)&pmap->pm_active); + atomic_store_rel_int(&lazywait, 0); + ipi_selected(mask, IPI_LAZYPMAP); + while (lazywait == 0) { + ia32_pause(); + if (--spins == 0) + break; + } + } + mtx_unlock_spin(&smp_ipi_mtx); + if (spins == 0) + printf("pmap_lazyfix: spun for 50000000\n"); + mask = pmap->pm_active; + } +} + +#else /* SMP */ + +/* + * Cleaning up on uniprocessor is easy. For various reasons, we're + * unlikely to have to even execute this code, including the fact + * that the cleanup is deferred until the parent does a wait(2), which + * means that another userland process has run. + */ +static void +pmap_lazyfix(pmap_t pmap) +{ + u_int cr3; + + cr3 = vtophys(pmap->pm_pdir); + if (cr3 == rcr3()) { + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_CLR(PCPU_GET(cpuid), &pmap->pm_active); + } +} +#endif /* SMP */ + /* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. @@ -1917,6 +2015,7 @@ pmap_release(pmap_t pmap) KASSERT(pmap->pm_root == NULL, ("pmap_release: pmap has reserved page table page(s)")); + pmap_lazyfix(pmap); mtx_lock_spin(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s index 654756910ea3..680b032557c9 100644 --- a/sys/i386/i386/swtch.s +++ b/sys/i386/i386/swtch.s @@ -174,6 +174,12 @@ ENTRY(cpu_switch) /* switch address space */ movl PCB_CR3(%edx),%eax +#ifdef PAE + cmpl %eax,IdlePDPT /* Kernel address space? */ +#else + cmpl %eax,IdlePTD /* Kernel address space? */ +#endif + je sw0 READ_CR3(%ebx) /* The same address space? */ cmpl %ebx,%eax je sw0 diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index cdec9c87bace..33b2578d3a59 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -42,6 +42,7 @@ extern u_long *ipi_invlrng_counts[MAXCPU]; extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; +extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ @@ -52,7 +53,8 @@ inthand_t IDTVEC(invlcache), /* Write back and invalidate cache */ IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ IDTVEC(cpustop), /* CPU stops & waits to be restarted */ - IDTVEC(rendezvous); /* handle CPU rendezvous */ + IDTVEC(rendezvous), /* handle CPU rendezvous */ + IDTVEC(lazypmap); /* handle lazy pmap release */ /* functions in mp_machdep.c */ void cpu_add(u_int apic_id, char boot_cpu); diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c index 1565859cf0b5..2d05596b89d2 100644 --- a/sys/i386/xen/mp_machdep.c +++ b/sys/i386/xen/mp_machdep.c @@ -154,6 +154,7 @@ static cpuset_t hyperthreading_cpus_mask; extern void Xhypervisor_callback(void); extern void failsafe_callback(void); +extern void pmap_lazyfix_action(void); struct cpu_group * cpu_topo(void) @@ -341,16 +342,24 @@ iv_invlcache(uintptr_t a, uintptr_t b) atomic_add_int(&smp_tlb_wait, 1); } +static void +iv_lazypmap(uintptr_t a, uintptr_t b) +{ + pmap_lazyfix_action(); + atomic_add_int(&smp_tlb_wait, 1); +} + /* * These start from "IPI offset" APIC_IPI_INTS */ -static call_data_func_t *ipi_vectors[5] = +static call_data_func_t *ipi_vectors[6] = { iv_rendezvous, iv_invltlb, iv_invlpg, iv_invlrng, iv_invlcache, + iv_lazypmap, }; /* diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index 74ace613d133..1149b6f516c4 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -1683,6 +1683,104 @@ pmap_allocpte(pmap_t pmap, vm_offset_t va, int flags) * Pmap allocation/deallocation routines. ***************************************************/ +#ifdef SMP +/* + * Deal with a SMP shootdown of other users of the pmap that we are + * trying to dispose of. This can be a bit hairy. + */ +static cpuset_t *lazymask; +static u_int lazyptd; +static volatile u_int lazywait; + +void pmap_lazyfix_action(void); + +void +pmap_lazyfix_action(void) +{ + +#ifdef COUNT_IPIS + (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++; +#endif + if (rcr3() == lazyptd) + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_CLR_ATOMIC(PCPU_GET(cpuid), lazymask); + atomic_store_rel_int(&lazywait, 1); +} + +static void +pmap_lazyfix_self(cpuset_t mymask) +{ + + if (rcr3() == lazyptd) + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_NAND_ATOMIC(lazymask, &mymask); +} + + +static void +pmap_lazyfix(pmap_t pmap) +{ + cpuset_t mymask, mask; + u_int spins; + int lsb; + + mask = pmap->pm_active; + while (!CPU_EMPTY(&mask)) { + spins = 50000000; + + /* Find least significant set bit. */ + lsb = cpusetobj_ffs(&mask); + lsb--; + CPU_SETOF(lsb, &mask); + mtx_lock_spin(&smp_ipi_mtx); +#ifdef PAE + lazyptd = vtophys(pmap->pm_pdpt); +#else + lazyptd = vtophys(pmap->pm_pdir); +#endif + mymask = PCPU_GET(cpumask); + if (mask == mymask) { + lazymask = &pmap->pm_active; + pmap_lazyfix_self(mymask); + } else { + atomic_store_rel_int((u_int *)&lazymask, + (u_int)&pmap->pm_active); + atomic_store_rel_int(&lazywait, 0); + ipi_selected(mask, IPI_LAZYPMAP); + while (lazywait == 0) { + ia32_pause(); + if (--spins == 0) + break; + } + } + mtx_unlock_spin(&smp_ipi_mtx); + if (spins == 0) + printf("pmap_lazyfix: spun for 50000000\n"); + mask = pmap->pm_active; + } +} + +#else /* SMP */ + +/* + * Cleaning up on uniprocessor is easy. For various reasons, we're + * unlikely to have to even execute this code, including the fact + * that the cleanup is deferred until the parent does a wait(2), which + * means that another userland process has run. + */ +static void +pmap_lazyfix(pmap_t pmap) +{ + u_int cr3; + + cr3 = vtophys(pmap->pm_pdir); + if (cr3 == rcr3()) { + load_cr3(PCPU_GET(curpcb)->pcb_cr3); + CPU_CLR(PCPU_GET(cpuid), &pmap->pm_active); + } +} +#endif /* SMP */ + /* * Release any resources held by the given physical map. * Called when a pmap initialized by pmap_pinit is being released. @@ -1708,6 +1806,7 @@ pmap_release(pmap_t pmap) mtx_lock(&createdelete_lock); #endif + pmap_lazyfix(pmap); mtx_lock_spin(&allpmaps_lock); LIST_REMOVE(pmap, pm_list); mtx_unlock_spin(&allpmaps_lock); From 58bd8f51970aaf3192e8efade58fe9548c2b150a Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 22 May 2011 20:19:01 +0000 Subject: [PATCH 061/164] Fix a bug where the index cpu is just plain wrong, thus the kernel livelocks. Reported by: gonzo --- sys/mips/mips/mp_machdep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index 289c0a77b58b..8c93bd134fcc 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -210,8 +210,9 @@ cpu_mp_setmaxid(void) last = 1; while ((cpu = cpusetobj_ffs(&cpumask)) != 0) { last = cpu; - mp_ncpus++; + cpu--; CPU_CLR(cpu, &cpumask); + mp_ncpus++; } if (mp_ncpus <= 0) mp_ncpus = 1; From 750009665bbebcbb1a091fddb3e27507a3bc3ab7 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 22 May 2011 20:24:36 +0000 Subject: [PATCH 062/164] Add a "safety belt" check for lsb setting. I don't think it is really necessary because the cpumask is known to be != 0, but it is just in case. Requested by: kib --- sys/i386/i386/pmap.c | 1 + sys/i386/xen/pmap.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index d0699b5311a9..a09138cb2567 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1947,6 +1947,7 @@ pmap_lazyfix(pmap_t pmap) /* Find least significant set bit. */ lsb = cpusetobj_ffs(&mask); + MPASS(lsb != 0); lsb--; CPU_SETOF(lsb, &mask); mtx_lock_spin(&smp_ipi_mtx); diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index 1149b6f516c4..2f3953884ab1 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -1730,6 +1730,7 @@ pmap_lazyfix(pmap_t pmap) /* Find least significant set bit. */ lsb = cpusetobj_ffs(&mask); + MPASS(lsb != 0); lsb--; CPU_SETOF(lsb, &mask); mtx_lock_spin(&smp_ipi_mtx); From 08bcb681d2e1e3a0707624ad288cb81cd79bed89 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 22 May 2011 20:29:47 +0000 Subject: [PATCH 063/164] Make cpusetobj_strprint() prepare the string in order to print the least significant cpuset_t word at the outmost right part of the string (more far from the beginning of it). This follows the natural build of bits rappresentation in the words. --- sys/kern/kern_cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 5d058e6f6528..3b2c653de9ef 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -650,12 +650,12 @@ cpusetobj_strprint(char *buf, const cpuset_t *set) bytesp = 0; bufsiz = CPUSETBUFSIZ; - for (i = 0; i < (_NCPUWORDS - 1); i++) { + for (i = _NCPUWORDS - 1; i > 0; i--) { bytesp = snprintf(tbuf, bufsiz, "%lx, ", set->__bits[i]); bufsiz -= bytesp; tbuf += bytesp; } - snprintf(tbuf, bufsiz, "%lx", set->__bits[_NCPUWORDS - 1]); + snprintf(tbuf, bufsiz, "%lx", set->__bits[0]); return (buf); } From b580be6dfd3bce7b7a252cf3446d750faca58427 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 22 May 2011 21:46:55 +0000 Subject: [PATCH 064/164] MFC --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 4 ++-- sys/ufs/ufs/ufs_vfsops.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 85e3d44d39a6..fffc181e00ca 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -2069,7 +2069,7 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) VN_HOLD(*vpp); } ZFS_EXIT(zfsvfs); - err = zfs_vnode_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + err = zfs_vnode_lock(*vpp, flags | LK_RETRY); if (err != 0) *vpp = NULL; return (err); @@ -2096,7 +2096,7 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) *vpp = ZTOV(zp); ZFS_EXIT(zfsvfs); - err = zfs_vnode_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + err = zfs_vnode_lock(*vpp, flags | LK_RETRY); if (err == 0) vnode_create_vobject(*vpp, zp->z_size, curthread); else diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index b71fc169a366..74a863a0bc8f 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -218,7 +218,7 @@ ufs_fhtovp(mp, ufhp, flags, vpp) struct vnode *nvp; int error; - error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); + error = VFS_VGET(mp, ufhp->ufid_ino, flags, &nvp); if (error) { *vpp = NULLVP; return (error); From 6d7371f9503a4d916171e610f74e6bcf20071227 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 23 May 2011 01:17:30 +0000 Subject: [PATCH 065/164] MFC --- contrib/binutils/binutils/objcopy.c | 3 ++- contrib/binutils/binutils/readelf.c | 2 +- contrib/binutils/binutils/strings.c | 6 ++--- contrib/binutils/gas/read.h | 2 +- contrib/binutils/gas/write.c | 4 ++-- contrib/binutils/ld/ldlang.c | 9 ++++---- contrib/gcc/combine.c | 2 +- contrib/gcc/emit-rtl.c | 11 +++++---- contrib/gcc/function.c | 13 ++++------- contrib/gcc/omp-low.c | 2 +- contrib/gcc/tree-cfg.c | 4 ++-- contrib/gcc/tree-vect-patterns.c | 2 +- contrib/gcclibs/libiberty/regex.c | 2 +- sys/amd64/conf/GENERIC | 2 ++ sys/conf/NOTES | 2 +- sys/kern/kern_cpuset.c | 36 +++++++++++++++++++++++++++++ sys/kern/kern_ktr.c | 25 ++++++++++++-------- sys/sparc64/include/ktr.h | 2 ++ sys/sys/cpuset.h | 1 + sys/sys/ktr.h | 1 - 20 files changed, 89 insertions(+), 42 deletions(-) diff --git a/contrib/binutils/binutils/objcopy.c b/contrib/binutils/binutils/objcopy.c index 06e2946ce349..23a067616a08 100644 --- a/contrib/binutils/binutils/objcopy.c +++ b/contrib/binutils/binutils/objcopy.c @@ -1542,7 +1542,8 @@ copy_object (bfd *ibfd, bfd *obfd) /* Umm, not sure what to do in this case. */ debuglink_vma = 0x1000; - bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma); + (void) bfd_set_section_vma (obfd, gnu_debuglink_section, + debuglink_vma); } } diff --git a/contrib/binutils/binutils/readelf.c b/contrib/binutils/binutils/readelf.c index 59a20906acc5..a8c5ccc4d12d 100644 --- a/contrib/binutils/binutils/readelf.c +++ b/contrib/binutils/binutils/readelf.c @@ -9701,7 +9701,7 @@ process_archive (char *file_name, FILE *file) } if ((longnames_size & 1) != 0) - getc (file); + (void) getc (file); got = fread (&arhdr, 1, sizeof arhdr, file); if (got != sizeof arhdr) diff --git a/contrib/binutils/binutils/strings.c b/contrib/binutils/binutils/strings.c index 2238574bac04..386bac7c264f 100644 --- a/contrib/binutils/binutils/strings.c +++ b/contrib/binutils/binutils/strings.c @@ -593,7 +593,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 8: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Lo ", (unsigned long long) start); + printf ("%7llo ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG @@ -608,7 +608,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 10: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Ld ", (unsigned long long) start); + printf ("%7lld ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG @@ -623,7 +623,7 @@ print_strings (const char *filename, FILE *stream, file_off address, case 16: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7Lx ", (unsigned long long) start); + printf ("%7llx ", (unsigned long long) start); else #else # if !BFD_HOST_64BIT_LONG diff --git a/contrib/binutils/gas/read.h b/contrib/binutils/gas/read.h index 6ac153b6d492..342a7e44a4f0 100644 --- a/contrib/binutils/gas/read.h +++ b/contrib/binutils/gas/read.h @@ -30,7 +30,7 @@ extern char *input_line_pointer; /* -> char we are parsing now. */ #ifdef PERMIT_WHITESPACE #define SKIP_WHITESPACE() \ - ((*input_line_pointer == ' ') ? ++input_line_pointer : 0) + do { if (*input_line_pointer == ' ') ++input_line_pointer; } while (0) #else #define SKIP_WHITESPACE() know(*input_line_pointer != ' ' ) #endif diff --git a/contrib/binutils/gas/write.c b/contrib/binutils/gas/write.c index 29ea2843857f..6b4af524b88e 100644 --- a/contrib/binutils/gas/write.c +++ b/contrib/binutils/gas/write.c @@ -345,7 +345,7 @@ record_alignment (/* Segment to which alignment pertains. */ return; if ((unsigned int) align > bfd_get_section_alignment (stdoutput, seg)) - bfd_set_section_alignment (stdoutput, seg, align); + (void) bfd_set_section_alignment (stdoutput, seg, align); } int @@ -2247,7 +2247,7 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass) newf = frag_alloc (ob); obstack_blank_fast (ob, fragP->fr_var); - obstack_finish (ob); + (void) obstack_finish (ob); memcpy (newf, fragP, SIZEOF_STRUCT_FRAG); memcpy (newf->fr_literal, fragP->fr_literal + fragP->fr_fix, diff --git a/contrib/binutils/ld/ldlang.c b/contrib/binutils/ld/ldlang.c index 5c2697458bfc..191936f344ad 100644 --- a/contrib/binutils/ld/ldlang.c +++ b/contrib/binutils/ld/ldlang.c @@ -4274,9 +4274,10 @@ lang_size_sections_1 " section %s\n"), os->name); input = os->children.head->input_section.section; - bfd_set_section_vma (os->bfd_section->owner, - os->bfd_section, - bfd_section_vma (input->owner, input)); + (void) bfd_set_section_vma (os->bfd_section->owner, + os->bfd_section, + bfd_section_vma (input->owner, + input)); os->bfd_section->size = input->size; break; } @@ -4361,7 +4362,7 @@ lang_size_sections_1 os->name, (unsigned long) (newdot - savedot)); } - bfd_set_section_vma (0, os->bfd_section, newdot); + (void) bfd_set_section_vma (0, os->bfd_section, newdot); os->bfd_section->output_offset = 0; } diff --git a/contrib/gcc/combine.c b/contrib/gcc/combine.c index c5655ea40380..f44b24685876 100644 --- a/contrib/gcc/combine.c +++ b/contrib/gcc/combine.c @@ -12442,7 +12442,7 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2, REG_N_DEATHS (REGNO (XEXP (note, 0)))++; REG_NOTES (place2) = gen_rtx_fmt_ee (GET_CODE (note), - REG_NOTE_KIND (note), + GET_MODE (note), XEXP (note, 0), REG_NOTES (place2)); } diff --git a/contrib/gcc/emit-rtl.c b/contrib/gcc/emit-rtl.c index 9607bf696536..73ce0b4b8ab7 100644 --- a/contrib/gcc/emit-rtl.c +++ b/contrib/gcc/emit-rtl.c @@ -3210,7 +3210,7 @@ try_split (rtx pat, rtx trial, int last) { if (CALL_P (insn)) REG_NOTES (insn) - = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note), + = gen_rtx_EXPR_LIST (GET_MODE (note), XEXP (note, 0), REG_NOTES (insn)); insn = PREV_INSN (insn); @@ -3223,7 +3223,7 @@ try_split (rtx pat, rtx trial, int last) { if (JUMP_P (insn)) REG_NOTES (insn) - = gen_rtx_EXPR_LIST (REG_NOTE_KIND (note), + = gen_rtx_EXPR_LIST (GET_MODE (note), XEXP (note, 0), REG_NOTES (insn)); insn = PREV_INSN (insn); @@ -4589,7 +4589,8 @@ set_unique_reg_note (rtx insn, enum reg_note kind, rtx datum) return note; } - REG_NOTES (insn) = gen_rtx_EXPR_LIST (kind, datum, REG_NOTES (insn)); + REG_NOTES (insn) = gen_rtx_EXPR_LIST ((enum machine_mode) kind, datum, + REG_NOTES (insn)); return REG_NOTES (insn); } @@ -5344,12 +5345,12 @@ emit_copy_of_insn_after (rtx insn, rtx after) { if (GET_CODE (link) == EXPR_LIST) REG_NOTES (new) - = copy_insn_1 (gen_rtx_EXPR_LIST (REG_NOTE_KIND (link), + = copy_insn_1 (gen_rtx_EXPR_LIST (GET_MODE (link), XEXP (link, 0), REG_NOTES (new))); else REG_NOTES (new) - = copy_insn_1 (gen_rtx_INSN_LIST (REG_NOTE_KIND (link), + = copy_insn_1 (gen_rtx_INSN_LIST (GET_MODE (link), XEXP (link, 0), REG_NOTES (new))); } diff --git a/contrib/gcc/function.c b/contrib/gcc/function.c index 7549ec421f07..59970c4bafb4 100644 --- a/contrib/gcc/function.c +++ b/contrib/gcc/function.c @@ -4008,22 +4008,19 @@ stack_protect_epilogue (void) /* Allow the target to compare Y with X without leaking either into a register. */ - switch (HAVE_stack_protect_test != 0) + if (HAVE_stack_protect_test != 0) { - case 1: tmp = gen_stack_protect_test (x, y, label); if (tmp) { emit_insn (tmp); - break; + goto done; } - /* FALLTHRU */ - - default: - emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label); - break; } + emit_cmp_and_jump_insns (x, y, EQ, NULL_RTX, ptr_mode, 1, label); + done: + /* The noreturn predictor has been moved to the tree level. The rtl-level predictors estimate this branch about 20%, which isn't enough to get things moved out of line. Since this is the only extant case of adding diff --git a/contrib/gcc/omp-low.c b/contrib/gcc/omp-low.c index 3008a1b3c8f2..49fb8c93fd7f 100644 --- a/contrib/gcc/omp-low.c +++ b/contrib/gcc/omp-low.c @@ -118,7 +118,7 @@ static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *); /* Find an OpenMP clause of type KIND within CLAUSES. */ static tree -find_omp_clause (tree clauses, enum tree_code kind) +find_omp_clause (tree clauses, enum omp_clause_code kind) { for (; clauses ; clauses = OMP_CLAUSE_CHAIN (clauses)) if (OMP_CLAUSE_CODE (clauses) == kind) diff --git a/contrib/gcc/tree-cfg.c b/contrib/gcc/tree-cfg.c index 1c855b793110..7573439c6541 100644 --- a/contrib/gcc/tree-cfg.c +++ b/contrib/gcc/tree-cfg.c @@ -2854,7 +2854,7 @@ bsi_insert_before (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); update_modified_stmts (t); - tsi_link_before (&i->tsi, t, m); + tsi_link_before (&i->tsi, t, (enum tsi_iterator_update) m); } @@ -2867,7 +2867,7 @@ bsi_insert_after (block_stmt_iterator *i, tree t, enum bsi_iterator_update m) { set_bb_for_stmt (t, i->bb); update_modified_stmts (t); - tsi_link_after (&i->tsi, t, m); + tsi_link_after (&i->tsi, t, (enum tsi_iterator_update) m); } diff --git a/contrib/gcc/tree-vect-patterns.c b/contrib/gcc/tree-vect-patterns.c index 1c57c59ebb9b..5907f88d2b32 100644 --- a/contrib/gcc/tree-vect-patterns.c +++ b/contrib/gcc/tree-vect-patterns.c @@ -487,7 +487,7 @@ vect_pattern_recog_1 ( } else { - enum tree_code vec_mode; + enum machine_mode vec_mode; enum insn_code icode; optab optab; diff --git a/contrib/gcclibs/libiberty/regex.c b/contrib/gcclibs/libiberty/regex.c index fa1df197ce9d..c24026e9e461 100644 --- a/contrib/gcclibs/libiberty/regex.c +++ b/contrib/gcclibs/libiberty/regex.c @@ -149,7 +149,7 @@ char *realloc (); # include # ifndef bzero # ifndef _LIBC -# define bzero(s, n) (memset (s, '\0', n), (s)) +# define bzero(s, n) ((void) (memset (s, '\0', n), (s))) # else # define bzero(s, n) __bzero (s, n) # endif diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index c43cd3365fff..52cda528dc3a 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -75,6 +75,8 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones +options KTR +options KTR_CPUMASK=("0x3") # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 94311c61cfda..966b3cfbc2c6 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -441,7 +441,7 @@ options KTR options KTR_ENTRIES=1024 options KTR_COMPILE=(KTR_INTR|KTR_PROC) options KTR_MASK=KTR_INTR -options KTR_CPUMASK=0x3 +options KTR_CPUMASK=("0x3") options KTR_VERBOSE # diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 3b2c653de9ef..5ca3be2b5597 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -659,6 +660,41 @@ cpusetobj_strprint(char *buf, const cpuset_t *set) return (buf); } +/* + * Build a valid cpuset_t object from a string representation. + * It expects an incoming buffer at least sized as CPUSETBUFSIZ. + */ +int +cpusetobj_strscan(cpuset_t *set, const char *buf) +{ + u_int nwords; + int i; + + if (strlen(buf) > CPUSETBUFSIZ - 1) + return (-1); + + /* Allow to pass a shorter version of the mask when necessary. */ + nwords = 1; + for (i = 0; buf[i] != '\0'; i++) + if (buf[i] == ',') + nwords++; + if (nwords > _NCPUWORDS) + return (-1); + + CPU_ZERO(set); + for (i = nwords - 1; i > 0; i--) { + if (!sscanf(buf, "%lx, ", &set->__bits[i])) + return (-1); + buf = strstr(buf, " "); + if (buf == NULL) + return (-1); + buf++; + } + if (!sscanf(buf, "%lx", &set->__bits[0])) + return (-1); + return (0); +} + /* * Apply an anonymous mask to a single thread. */ diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 2e5e06f671b2..c62f78498525 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -40,8 +40,10 @@ __FBSDID("$FreeBSD$"); #include "opt_alq.h" #include +#include #include #include +#include #include #include #include @@ -68,10 +70,6 @@ __FBSDID("$FreeBSD$"); #define KTR_MASK (0) #endif -#ifndef KTR_CPUMASK -#define KTR_CPUMASK (~0) -#endif - #ifndef KTR_TIME #define KTR_TIME get_cyclecount() #endif @@ -84,10 +82,10 @@ FEATURE(ktr, "Kernel support for KTR kernel tracing facility"); SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); -int ktr_cpumask = KTR_CPUMASK; -TUNABLE_INT("debug.ktr.cpumask", &ktr_cpumask); -SYSCTL_INT(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, - &ktr_cpumask, 0, "Bitmask of CPUs on which KTR logging is enabled"); +static char ktr_cpumask[CPUSETBUFSIZ]; +TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask, sizeof(ktr_cpumask)); +SYSCTL_STRING(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, ktr_cpumask, + sizeof(ktr_cpumask), "Bitmask of CPUs on which KTR logging is enabled"); int ktr_mask = KTR_MASK; TUNABLE_INT("debug.ktr.mask", &ktr_mask); @@ -198,6 +196,7 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5, u_long arg6) { + cpuset_t intern_cpumask; struct ktr_entry *entry; #ifdef KTR_ALQ struct ale *ale = NULL; @@ -212,8 +211,16 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, return; if ((ktr_mask & mask) == 0) return; +#ifndef KTR_CPUMASK + CPU_FILL(&intern_cpumask); +#else + if (ktr_cpumask[0] == '\0') + strncpy(ktr_cpumask, KTR_CPUMASK, sizeof(ktr_cpumask)); + if (cpusetobj_strscan(&intern_cpumask, ktr_cpumask) == -1) + return; +#endif cpu = KTR_CPU; - if (((1 << cpu) & ktr_cpumask) == 0) + if (!CPU_ISSET(cpu, &intern_cpumask)) return; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td = curthread; diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h index 5948ba29fb3e..0cd96e162494 100644 --- a/sys/sparc64/include/ktr.h +++ b/sys/sparc64/include/ktr.h @@ -85,7 +85,9 @@ l2: add r2, 1, r3 ; \ lduw [PCPU(MID)], r1 ; \ mov 1, r2 ; \ sllx r2, r1, r1 ; \ +#if 0 TEST(ktr_cpumask, r1, r2, r3, l3) ; \ +#endif ATR(desc, r1, r2, r3, l1, l2) #endif /* LOCORE */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index e06df54ab018..55ba5d1cdc23 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -216,6 +216,7 @@ int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); int cpusetobj_ffs(const cpuset_t *); char *cpusetobj_strprint(char *, const cpuset_t *); +int cpusetobj_strscan(cpuset_t *, const char *); #else __BEGIN_DECLS diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 3b78101dd1b4..6fe72de3b038 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -107,7 +107,6 @@ struct ktr_entry { u_long ktr_parms[KTR_PARMS]; }; -extern int ktr_cpumask; extern int ktr_mask; extern int ktr_entries; extern int ktr_verbose; From 66305282ac742acac807ca249a5265954a288f53 Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 23 May 2011 23:50:21 +0000 Subject: [PATCH 066/164] Revert a patch that unvolountary sneaked in while I was MFCing. --- sys/conf/NOTES | 2 +- sys/kern/kern_cpuset.c | 36 ------------------------------------ sys/kern/kern_ktr.c | 25 +++++++++---------------- sys/sparc64/include/ktr.h | 2 -- sys/sys/cpuset.h | 1 - sys/sys/ktr.h | 1 + 6 files changed, 11 insertions(+), 56 deletions(-) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 966b3cfbc2c6..94311c61cfda 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -441,7 +441,7 @@ options KTR options KTR_ENTRIES=1024 options KTR_COMPILE=(KTR_INTR|KTR_PROC) options KTR_MASK=KTR_INTR -options KTR_CPUMASK=("0x3") +options KTR_CPUMASK=0x3 options KTR_VERBOSE # diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 5ca3be2b5597..3b2c653de9ef 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -660,41 +659,6 @@ cpusetobj_strprint(char *buf, const cpuset_t *set) return (buf); } -/* - * Build a valid cpuset_t object from a string representation. - * It expects an incoming buffer at least sized as CPUSETBUFSIZ. - */ -int -cpusetobj_strscan(cpuset_t *set, const char *buf) -{ - u_int nwords; - int i; - - if (strlen(buf) > CPUSETBUFSIZ - 1) - return (-1); - - /* Allow to pass a shorter version of the mask when necessary. */ - nwords = 1; - for (i = 0; buf[i] != '\0'; i++) - if (buf[i] == ',') - nwords++; - if (nwords > _NCPUWORDS) - return (-1); - - CPU_ZERO(set); - for (i = nwords - 1; i > 0; i--) { - if (!sscanf(buf, "%lx, ", &set->__bits[i])) - return (-1); - buf = strstr(buf, " "); - if (buf == NULL) - return (-1); - buf++; - } - if (!sscanf(buf, "%lx", &set->__bits[0])) - return (-1); - return (0); -} - /* * Apply an anonymous mask to a single thread. */ diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index c62f78498525..2e5e06f671b2 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -40,10 +40,8 @@ __FBSDID("$FreeBSD$"); #include "opt_alq.h" #include -#include #include #include -#include #include #include #include @@ -70,6 +68,10 @@ __FBSDID("$FreeBSD$"); #define KTR_MASK (0) #endif +#ifndef KTR_CPUMASK +#define KTR_CPUMASK (~0) +#endif + #ifndef KTR_TIME #define KTR_TIME get_cyclecount() #endif @@ -82,10 +84,10 @@ FEATURE(ktr, "Kernel support for KTR kernel tracing facility"); SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); -static char ktr_cpumask[CPUSETBUFSIZ]; -TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask, sizeof(ktr_cpumask)); -SYSCTL_STRING(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, ktr_cpumask, - sizeof(ktr_cpumask), "Bitmask of CPUs on which KTR logging is enabled"); +int ktr_cpumask = KTR_CPUMASK; +TUNABLE_INT("debug.ktr.cpumask", &ktr_cpumask); +SYSCTL_INT(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, + &ktr_cpumask, 0, "Bitmask of CPUs on which KTR logging is enabled"); int ktr_mask = KTR_MASK; TUNABLE_INT("debug.ktr.mask", &ktr_mask); @@ -196,7 +198,6 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5, u_long arg6) { - cpuset_t intern_cpumask; struct ktr_entry *entry; #ifdef KTR_ALQ struct ale *ale = NULL; @@ -211,16 +212,8 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, return; if ((ktr_mask & mask) == 0) return; -#ifndef KTR_CPUMASK - CPU_FILL(&intern_cpumask); -#else - if (ktr_cpumask[0] == '\0') - strncpy(ktr_cpumask, KTR_CPUMASK, sizeof(ktr_cpumask)); - if (cpusetobj_strscan(&intern_cpumask, ktr_cpumask) == -1) - return; -#endif cpu = KTR_CPU; - if (!CPU_ISSET(cpu, &intern_cpumask)) + if (((1 << cpu) & ktr_cpumask) == 0) return; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td = curthread; diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h index 0cd96e162494..5948ba29fb3e 100644 --- a/sys/sparc64/include/ktr.h +++ b/sys/sparc64/include/ktr.h @@ -85,9 +85,7 @@ l2: add r2, 1, r3 ; \ lduw [PCPU(MID)], r1 ; \ mov 1, r2 ; \ sllx r2, r1, r1 ; \ -#if 0 TEST(ktr_cpumask, r1, r2, r3, l3) ; \ -#endif ATR(desc, r1, r2, r3, l1, l2) #endif /* LOCORE */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 55ba5d1cdc23..e06df54ab018 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -216,7 +216,6 @@ int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); int cpusetobj_ffs(const cpuset_t *); char *cpusetobj_strprint(char *, const cpuset_t *); -int cpusetobj_strscan(cpuset_t *, const char *); #else __BEGIN_DECLS diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 6fe72de3b038..3b78101dd1b4 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -107,6 +107,7 @@ struct ktr_entry { u_long ktr_parms[KTR_PARMS]; }; +extern int ktr_cpumask; extern int ktr_mask; extern int ktr_entries; extern int ktr_verbose; From 2bb57ae0161679cd71be261a7cd885ba449094ec Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 23 May 2011 23:51:01 +0000 Subject: [PATCH 067/164] Revert a patch that involountary sneaked in while I was MFCing. --- sys/amd64/conf/GENERIC | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 52cda528dc3a..c43cd3365fff 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -75,8 +75,6 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require options WITNESS # Enable checks to detect deadlocks and cycles options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones -options KTR -options KTR_CPUMASK=("0x3") # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel From 9879530ca1401176b647cf90fcd0e4ccf4f8869e Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 23 May 2011 23:58:02 +0000 Subject: [PATCH 068/164] MFC --- sbin/hastctl/hastctl.c | 11 ++ sbin/hastd/control.c | 17 +++ sbin/hastd/hast.h | 11 ++ sbin/hastd/primary.c | 11 ++ sbin/hastd/secondary.c | 14 ++ sbin/hastd/subr.c | 8 +- share/man/man4/msk.4 | 4 +- sys/conf/kern.post.mk | 4 +- sys/conf/kmod.mk | 4 +- sys/conf/newvers.sh | 2 +- sys/dev/acpica/acpi_hpet.c | 2 +- sys/dev/acpica/acpi_timer.c | 2 +- sys/dev/msk/if_msk.c | 170 +++++++++++++----------- sys/dev/msk/if_mskreg.h | 10 ++ sys/fs/nfsclient/nfs_clvfsops.c | 10 ++ sys/geom/gate/g_gate.c | 3 + sys/kern/kern_environment.c | 8 +- sys/kern/vfs_bio.c | 2 +- sys/netinet/in_pcb.c | 228 ++++++++++++++++++-------------- sys/netinet/in_pcb.h | 77 +++++++---- sys/netinet6/in6_pcb.c | 25 ++-- sys/netinet6/in6_src.c | 6 +- usr.bin/gzip/Makefile | 2 +- usr.bin/gzip/gzip.1 | 8 +- usr.bin/gzip/gzip.c | 11 +- usr.bin/gzip/zdiff | 119 +++++++++++------ usr.bin/gzip/zdiff.1 | 59 +++++++-- usr.bin/gzip/zuncompress.c | 2 +- 28 files changed, 535 insertions(+), 295 deletions(-) diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c index c4cd6a4b91c1..2f8a6eb8dff7 100644 --- a/sbin/hastctl/hastctl.c +++ b/sbin/hastctl/hastctl.c @@ -341,6 +341,17 @@ control_status(struct nv *nv) printf(" dirty: %ju (%NB)\n", (uintmax_t)nv_get_uint64(nv, "dirty%u", ii), (intmax_t)nv_get_uint64(nv, "dirty%u", ii)); + printf(" statistics:\n"); + printf(" reads: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_read%u", ii)); + printf(" writes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_write%u", ii)); + printf(" deletes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_delete%u", ii)); + printf(" flushes: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_flush%u", ii)); + printf(" activemap updates: %ju\n", + (uint64_t)nv_get_uint64(nv, "stat_activemap_update%u", ii)); } return (ret); } diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c index dce2d53bcc3a..4d00403924d3 100644 --- a/sbin/hastd/control.c +++ b/sbin/hastd/control.c @@ -199,6 +199,16 @@ control_status_worker(struct hast_resource *res, struct nv *nvout, "extentsize%u", no); nv_add_uint32(nvout, nv_get_uint32(cnvin, "keepdirty"), "keepdirty%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_read"), + "stat_read%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_write"), + "stat_write%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_delete"), + "stat_delete%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_flush"), + "stat_flush%u", no); + nv_add_uint64(nvout, nv_get_uint64(cnvin, "stat_activemap_update"), + "stat_activemap_update%u", no); end: if (cnvin != NULL) nv_free(cnvin); @@ -446,6 +456,13 @@ ctrl_thread(void *arg) nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); nv_add_uint64(nvout, (uint64_t)0, "dirty"); } + nv_add_uint64(nvout, res->hr_stat_read, "stat_read"); + nv_add_uint64(nvout, res->hr_stat_write, "stat_write"); + nv_add_uint64(nvout, res->hr_stat_delete, + "stat_delete"); + nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush"); + nv_add_uint64(nvout, res->hr_stat_activemap_update, + "stat_activemap_update"); nv_add_int16(nvout, 0, "error"); break; case CONTROL_RELOAD: diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h index 3f2616228352..a62b63a263f6 100644 --- a/sbin/hastd/hast.h +++ b/sbin/hastd/hast.h @@ -218,6 +218,17 @@ struct hast_resource { /* Locked used to synchronize access to hr_amp. */ pthread_mutex_t hr_amp_lock; + /* Number of BIO_READ requests. */ + uint64_t hr_stat_read; + /* Number of BIO_WRITE requests. */ + uint64_t hr_stat_write; + /* Number of BIO_DELETE requests. */ + uint64_t hr_stat_delete; + /* Number of BIO_FLUSH requests. */ + uint64_t hr_stat_flush; + /* Number of activemap updates. */ + uint64_t hr_stat_activemap_update; + /* Next resource. */ TAILQ_ENTRY(hast_resource) hr_next; }; diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index d8eb664740cb..1f6585c87a1a 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -1117,6 +1117,7 @@ ggate_recv_thread(void *arg) */ switch (ggio->gctl_cmd) { case BIO_READ: + res->hr_stat_read++; pjdlog_debug(2, "ggate_recv: (%p) Moving request to the send queue.", hio); @@ -1145,6 +1146,7 @@ ggate_recv_thread(void *arg) QUEUE_INSERT1(hio, send, ncomp); break; case BIO_WRITE: + res->hr_stat_write++; if (res->hr_resuid == 0) { /* * This is first write, initialize localcnt and @@ -1183,12 +1185,21 @@ ggate_recv_thread(void *arg) mtx_lock(&res->hr_amp_lock); if (activemap_write_start(res->hr_amp, ggio->gctl_offset, ggio->gctl_length)) { + res->hr_stat_activemap_update++; (void)hast_activemap_flush(res); } mtx_unlock(&res->hr_amp_lock); /* FALLTHROUGH */ case BIO_DELETE: case BIO_FLUSH: + switch (ggio->gctl_cmd) { + case BIO_DELETE: + res->hr_stat_delete++; + break; + case BIO_FLUSH: + res->hr_stat_flush++; + break; + } pjdlog_debug(2, "ggate_recv: (%p) Moving request to the send queues.", hio); diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 176d0470eedb..1597af83a85d 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -612,6 +612,20 @@ recv_thread(void *arg) QUEUE_INSERT(send, hio); continue; } + switch (hio->hio_cmd) { + case HIO_READ: + res->hr_stat_read++; + break; + case HIO_WRITE: + res->hr_stat_write++; + break; + case HIO_DELETE: + res->hr_stat_delete++; + break; + case HIO_FLUSH: + res->hr_stat_flush++; + break; + } reqlog(LOG_DEBUG, 2, -1, hio, "recv: (%p) Got request header: ", hio); if (hio->hio_cmd == HIO_KEEPALIVE) { diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c index 29f33e7d32c4..806338b4bfc0 100644 --- a/sbin/hastd/subr.c +++ b/sbin/hastd/subr.c @@ -224,7 +224,13 @@ drop_privs(struct hast_resource *res) return (-1); } - if (res == NULL || res->hr_role != HAST_ROLE_PRIMARY) + /* + * Until capsicum doesn't allow ioctl(2) we cannot use it to sandbox + * primary and secondary worker processes, as primary uses GGATE + * ioctls and secondary uses ioctls to handle BIO_DELETE and BIO_FLUSH. + * For now capsicum is only used to sandbox hastctl. + */ + if (res == NULL) capsicum = (cap_enter() == 0); else capsicum = false; diff --git a/share/man/man4/msk.4 b/share/man/man4/msk.4 index fe32a68a4226..200c6f7f3e52 100644 --- a/share/man/man4/msk.4 +++ b/share/man/man4/msk.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 23, 2010 +.Dd May 23, 2011 .Dt MSK 4 .Os .Sh NAME @@ -195,6 +195,8 @@ Marvell Yukon 88E8071 Gigabit Ethernet .It Marvell Yukon 88E8072 Gigabit Ethernet .It +Marvell Yukon 88E8075 Gigabit Ethernet +.It SysKonnect SK-9Sxx Gigabit Ethernet .It SysKonnect SK-9Exx Gigabit Ethernet diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 21d9572d8d50..8cb36f9f0fdf 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -228,7 +228,7 @@ kernel-install: mkdir -p ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} .if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif .if defined(KERNEL_EXTRA_INSTALL) @@ -241,7 +241,7 @@ kernel-reinstall: @-chflags -R noschg ${DESTDIR}${KODIR} ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR} .if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR} .endif diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index b50fc6833fbb..36e0b9d51bfc 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -286,8 +286,8 @@ realinstall: _kmodinstall _kmodinstall: ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR} -.if defined(DEBUG) && !defined(INSTALL_NODEBUG) && \ - (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} == "yes") +.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && \ + (defined(MK_KERNEL_SYMBOLS) && ${MK_KERNEL_SYMBOLS} != "no") ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \ ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR} .endif diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index 6fe0a639a547..9681c7904d43 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -139,4 +139,4 @@ int osreldate = ${RELDATE}; char kern_ident[] = "${i}"; EOF -echo `expr ${v} + 1` > version +echo $((v + 1)) > version diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 4ea5c8583b13..40e8676fceb3 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -476,7 +476,7 @@ hpet_attach(device_t dev) sc->tc.tc_get_timecount = hpet_get_timecount, sc->tc.tc_counter_mask = ~0u, sc->tc.tc_name = "HPET", - sc->tc.tc_quality = 900, + sc->tc.tc_quality = 950, sc->tc.tc_frequency = sc->freq; sc->tc.tc_priv = sc; tc_init(&sc->tc); diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c index f4562067080b..17416838e9e4 100644 --- a/sys/dev/acpica/acpi_timer.c +++ b/sys/dev/acpica/acpi_timer.c @@ -203,7 +203,7 @@ acpi_timer_probe(device_t dev) if (j == 10) { acpi_timer_timecounter.tc_name = "ACPI-fast"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount; - acpi_timer_timecounter.tc_quality = 1000; + acpi_timer_timecounter.tc_quality = 900; } else { acpi_timer_timecounter.tc_name = "ACPI-safe"; acpi_timer_timecounter.tc_get_timecount = acpi_timer_get_timecount_safe; diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 3af1b205fda9..2adbf1cb2c7a 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -221,6 +221,10 @@ static struct msk_product { "Marvell Yukon 88E8071 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_436C, "Marvell Yukon 88E8072 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_436D, + "Marvell Yukon 88E8055 Gigabit Ethernet" }, + { VENDORID_MARVELL, DEVICEID_MRVL_4370, + "Marvell Yukon 88E8075 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4380, "Marvell Yukon 88E8057 Gigabit Ethernet" }, { VENDORID_MARVELL, DEVICEID_MRVL_4381, @@ -1030,7 +1034,10 @@ msk_ioctl(struct ifnet *ifp, u_long command, caddr_t data) } } ifp->if_mtu = ifr->ifr_mtu; - msk_init_locked(sc_if); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + msk_init_locked(sc_if); + } } MSK_IF_UNLOCK(sc_if); break; @@ -1212,37 +1219,30 @@ msk_phy_power(struct msk_softc *sc, int mode) */ CSR_WRITE_1(sc, B2_Y2_CLK_GATE, val); - val = CSR_PCI_READ_4(sc, PCI_OUR_REG_1); - val &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); + our = CSR_PCI_READ_4(sc, PCI_OUR_REG_1); + our &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); if (sc->msk_hw_id == CHIP_ID_YUKON_XL) { if (sc->msk_hw_rev > CHIP_REV_YU_XL_A1) { /* Deassert Low Power for 1st PHY. */ - val |= PCI_Y2_PHY1_COMA; + our |= PCI_Y2_PHY1_COMA; if (sc->msk_num_port > 1) - val |= PCI_Y2_PHY2_COMA; + our |= PCI_Y2_PHY2_COMA; } } - /* Release PHY from PowerDown/COMA mode. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_1, val); - switch (sc->msk_hw_id) { - case CHIP_ID_YUKON_EC_U: - case CHIP_ID_YUKON_EX: - case CHIP_ID_YUKON_FE_P: - case CHIP_ID_YUKON_UL_2: - case CHIP_ID_YUKON_OPT: - CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_OFF); - - /* Enable all clocks. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); - our = CSR_PCI_READ_4(sc, PCI_OUR_REG_4); - our &= (PCI_FORCE_ASPM_REQUEST|PCI_ASPM_GPHY_LINK_DOWN| - PCI_ASPM_INT_FIFO_EMPTY|PCI_ASPM_CLKRUN_REQUEST); + if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U || + sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id >= CHIP_ID_YUKON_FE_P) { + val = CSR_PCI_READ_4(sc, PCI_OUR_REG_4); + val &= (PCI_FORCE_ASPM_REQUEST | + PCI_ASPM_GPHY_LINK_DOWN | PCI_ASPM_INT_FIFO_EMPTY | + PCI_ASPM_CLKRUN_REQUEST); /* Set all bits to 0 except bits 15..12. */ - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_4, our); - our = CSR_PCI_READ_4(sc, PCI_OUR_REG_5); - our &= PCI_CTL_TIM_VMAIN_AV_MSK; - CSR_PCI_WRITE_4(sc, PCI_OUR_REG_5, our); + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_4, val); + val = CSR_PCI_READ_4(sc, PCI_OUR_REG_5); + val &= PCI_CTL_TIM_VMAIN_AV_MSK; + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_5, val); CSR_PCI_WRITE_4(sc, PCI_CFG_REG_1, 0); + CSR_WRITE_2(sc, B0_CTST, Y2_HW_WOL_ON); /* * Disable status race, workaround for * Yukon EC Ultra & Yukon EX. @@ -1251,10 +1251,10 @@ msk_phy_power(struct msk_softc *sc, int mode) val |= GLB_GPIO_STAT_RACE_DIS; CSR_WRITE_4(sc, B2_GP_IO, val); CSR_READ_4(sc, B2_GP_IO); - break; - default: - break; } + /* Release PHY from PowerDown/COMA mode. */ + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_1, our); + for (i = 0; i < sc->msk_num_port; i++) { CSR_WRITE_2(sc, MR_ADDR(i, GMAC_LINK_CTRL), GMLC_RST_SET); @@ -1300,28 +1300,33 @@ mskc_reset(struct msk_softc *sc) bus_addr_t addr; uint16_t status; uint32_t val; - int i; - - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); + int i, initram; /* Disable ASF. */ - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) { - status = CSR_READ_2(sc, B28_Y2_ASF_HCU_CCSR); - /* Clear AHB bridge & microcontroller reset. */ - status &= ~(Y2_ASF_HCU_CCSR_AHB_RST | - Y2_ASF_HCU_CCSR_CPU_RST_MODE); - /* Clear ASF microcontroller state. */ - status &= ~ Y2_ASF_HCU_CCSR_UC_STATE_MSK; - CSR_WRITE_2(sc, B28_Y2_ASF_HCU_CCSR, status); - } else - CSR_WRITE_1(sc, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); - CSR_WRITE_2(sc, B0_CTST, Y2_ASF_DISABLE); - - /* - * Since we disabled ASF, S/W reset is required for Power Management. - */ - CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); + if (sc->msk_hw_id >= CHIP_ID_YUKON_XL && + sc->msk_hw_id <= CHIP_ID_YUKON_SUPR) { + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { + CSR_WRITE_4(sc, B28_Y2_CPU_WDOG, 0); + status = CSR_READ_2(sc, B28_Y2_ASF_HCU_CCSR); + /* Clear AHB bridge & microcontroller reset. */ + status &= ~(Y2_ASF_HCU_CCSR_AHB_RST | + Y2_ASF_HCU_CCSR_CPU_RST_MODE); + /* Clear ASF microcontroller state. */ + status &= ~Y2_ASF_HCU_CCSR_UC_STATE_MSK; + status &= ~Y2_ASF_HCU_CCSR_CPU_CLK_DIVIDE_MSK; + CSR_WRITE_2(sc, B28_Y2_ASF_HCU_CCSR, status); + CSR_WRITE_4(sc, B28_Y2_CPU_WDOG, 0); + } else + CSR_WRITE_1(sc, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); + CSR_WRITE_2(sc, B0_CTST, Y2_ASF_DISABLE); + /* + * Since we disabled ASF, S/W reset is required for + * Power Management. + */ + CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); + CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); + } /* Clear all error bits in the PCI status register. */ status = pci_read_config(sc->msk_dev, PCIR_STATUS, 2); @@ -1362,17 +1367,22 @@ mskc_reset(struct msk_softc *sc) /* Reset GPHY/GMAC Control */ for (i = 0; i < sc->msk_num_port; i++) { /* GPHY Control reset. */ - CSR_WRITE_4(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_SET); - CSR_WRITE_4(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_CLR); + CSR_WRITE_1(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_SET); + CSR_WRITE_1(sc, MR_ADDR(i, GPHY_CTRL), GPC_RST_CLR); /* GMAC Control reset. */ CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_SET); CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_RST_CLR); CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_F_LOOPB_OFF); - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) CSR_WRITE_4(sc, MR_ADDR(i, GMAC_CTRL), GMC_BYP_MACSECRX_ON | GMC_BYP_MACSECTX_ON | GMC_BYP_RETR_ON); } + + if (sc->msk_hw_id == CHIP_ID_YUKON_SUPR && + sc->msk_hw_rev > CHIP_REV_YU_SU_B0) + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, PCI_CLK_MACSEC_DIS); if (sc->msk_hw_id == CHIP_ID_YUKON_OPT && sc->msk_hw_rev == 0) { /* Disable PCIe PHY powerdown(reg 0x80, bit7). */ CSR_WRITE_4(sc, Y2_PEX_PHY_DATA, (0x0080 << 16) | 0x0080); @@ -1396,8 +1406,14 @@ mskc_reset(struct msk_softc *sc) CSR_WRITE_1(sc, GMAC_TI_ST_CTRL, GMT_ST_STOP); CSR_WRITE_1(sc, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); + initram = 0; + if (sc->msk_hw_id == CHIP_ID_YUKON_XL || + sc->msk_hw_id == CHIP_ID_YUKON_EC || + sc->msk_hw_id == CHIP_ID_YUKON_FE) + initram++; + /* Configure timeout values. */ - for (i = 0; i < sc->msk_num_port; i++) { + for (i = 0; initram > 0 && i < sc->msk_num_port; i++) { CSR_WRITE_2(sc, SELECT_RAM_BUFFER(i, B3_RI_CTRL), RI_RST_SET); CSR_WRITE_2(sc, SELECT_RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR); CSR_WRITE_1(sc, SELECT_RAM_BUFFER(i, B3_RI_WTO_R1), @@ -1706,13 +1722,15 @@ mskc_attach(device_t dev) } } + /* Enable all clocks before accessing any registers. */ + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); + CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); sc->msk_hw_id = CSR_READ_1(sc, B2_CHIP_ID); sc->msk_hw_rev = (CSR_READ_1(sc, B2_MAC_CFG) >> 4) & 0x0f; /* Bail out if chip is not recognized. */ if (sc->msk_hw_id < CHIP_ID_YUKON_XL || sc->msk_hw_id > CHIP_ID_YUKON_OPT || - sc->msk_hw_id == CHIP_ID_YUKON_SUPR || sc->msk_hw_id == CHIP_ID_YUKON_UNKNOWN) { device_printf(dev, "unknown device: id=0x%02x, rev=0x%02x\n", sc->msk_hw_id, sc->msk_hw_rev); @@ -1746,9 +1764,6 @@ mskc_attach(device_t dev) resource_int_value(device_get_name(dev), device_get_unit(dev), "int_holdoff", &sc->msk_int_holdoff); - /* Soft reset. */ - CSR_WRITE_2(sc, B0_CTST, CS_RST_SET); - CSR_WRITE_2(sc, B0_CTST, CS_RST_CLR); sc->msk_pmd = CSR_READ_1(sc, B2_PMD_TYP); /* Check number of MACs. */ sc->msk_num_port = 1; @@ -1822,6 +1837,11 @@ mskc_attach(device_t dev) sc->msk_clock = 156; /* 156 MHz */ sc->msk_pflags |= MSK_FLAG_JUMBO; break; + case CHIP_ID_YUKON_SUPR: + sc->msk_clock = 125; /* 125 MHz */ + sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_DESCV2 | + MSK_FLAG_AUTOTX_CSUM; + break; case CHIP_ID_YUKON_UL_2: sc->msk_clock = 125; /* 125 MHz */ sc->msk_pflags |= MSK_FLAG_JUMBO; @@ -2963,6 +2983,7 @@ mskc_resume(device_t dev) MSK_LOCK(sc); + CSR_PCI_WRITE_4(sc, PCI_OUR_REG_3, 0); mskc_reset(sc); for (i = 0; i < sc->msk_num_port; i++) { if (sc->msk_if[i] != NULL && sc->msk_if[i]->msk_ifp != NULL && @@ -3654,37 +3675,24 @@ msk_set_tx_stfwd(struct msk_if_softc *sc_if) ifp = sc_if->msk_ifp; sc = sc_if->msk_softc; - switch (sc->msk_hw_id) { - case CHIP_ID_YUKON_EX: - if (sc->msk_hw_rev == CHIP_REV_YU_EX_A0) - goto yukon_ex_workaround; - if (ifp->if_mtu > ETHERMTU) - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_ENA | TX_STFW_ENA); - else - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_DIS | TX_STFW_ENA); - break; - default: -yukon_ex_workaround: + if ((sc->msk_hw_id == CHIP_ID_YUKON_EX && + sc->msk_hw_rev != CHIP_REV_YU_EX_A0) || + sc->msk_hw_id >= CHIP_ID_YUKON_SUPR) { + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_ENA); + } else { if (ifp->if_mtu > ETHERMTU) { /* Set Tx GMAC FIFO Almost Empty Threshold. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_AE_THR), MSK_ECU_JUMBO_WM << 16 | MSK_ECU_AE_THR); /* Disable Store & Forward mode for Tx. */ - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_ENA | TX_STFW_DIS); + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_DIS); } else { - /* Enable Store & Forward mode for Tx. */ - CSR_WRITE_4(sc, - MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), - TX_JUMBO_DIS | TX_STFW_ENA); + CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, TX_GMF_CTRL_T), + TX_STFW_ENA); } - break; } } @@ -3737,7 +3745,8 @@ msk_init_locked(struct msk_if_softc *sc_if) CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_SET); CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_RST_CLR); CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_F_LOOPB_OFF); - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, GMAC_CTRL), GMC_BYP_MACSECRX_ON | GMC_BYP_MACSECTX_ON | GMC_BYP_RETR_ON); @@ -3932,7 +3941,8 @@ msk_init_locked(struct msk_if_softc *sc_if) msk_stop(sc_if); return; } - if (sc->msk_hw_id == CHIP_ID_YUKON_EX) { + if (sc->msk_hw_id == CHIP_ID_YUKON_EX || + sc->msk_hw_id == CHIP_ID_YUKON_SUPR) { /* Disable flushing of non-ASF packets. */ CSR_WRITE_4(sc, MR_ADDR(sc_if->msk_port, RX_GMF_CTRL_T), GMF_RX_MACSEC_FLUSH_OFF); diff --git a/sys/dev/msk/if_mskreg.h b/sys/dev/msk/if_mskreg.h index 3b05b9ba8587..583f5e88ef80 100644 --- a/sys/dev/msk/if_mskreg.h +++ b/sys/dev/msk/if_mskreg.h @@ -144,6 +144,8 @@ #define DEVICEID_MRVL_436A 0x436A #define DEVICEID_MRVL_436B 0x436B #define DEVICEID_MRVL_436C 0x436C +#define DEVICEID_MRVL_436D 0x436D +#define DEVICEID_MRVL_4370 0x4370 #define DEVICEID_MRVL_4380 0x4380 #define DEVICEID_MRVL_4381 0x4381 @@ -321,6 +323,9 @@ #define PCI_OS_SPD_X100 2 /* PCI-X 100MHz Bus */ #define PCI_OS_SPD_X133 3 /* PCI-X 133MHz Bus */ +/* PCI_OUR_REG_3 32 bit Our Register 3 (Yukon-ECU only) */ +#define PCI_CLK_MACSEC_DIS BIT_17 /* Disable Clock MACSec. */ + /* PCI_OUR_REG_4 32 bit Our Register 4 (Yukon-ECU only) */ #define PCI_TIMER_VALUE_MSK (0xff<<16) /* Bit 23..16: Timer Value Mask */ #define PCI_FORCE_ASPM_REQUEST BIT_15 /* Force ASPM Request (A1 only) */ @@ -677,6 +682,7 @@ /* ASF Subsystem Registers (Yukon-2 only) */ #define B28_Y2_SMB_CONFIG 0x0e40 /* 32 bit ASF SMBus Config Register */ #define B28_Y2_SMB_CSD_REG 0x0e44 /* 32 bit ASF SMB Control/Status/Data */ +#define B28_Y2_CPU_WDOG 0x0e48 /* 32 bit Watchdog Register */ #define B28_Y2_ASF_IRQ_V_BASE 0x0e60 /* 32 bit ASF IRQ Vector Base */ #define B28_Y2_ASF_STAT_CMD 0x0e68 /* 32 bit ASF Status and Command Reg */ #define B28_Y2_ASF_HCU_CCSR 0x0e68 /* 32 bit ASF HCU CCSR (Yukon EX) */ @@ -918,6 +924,10 @@ #define CHIP_REV_YU_EX_A0 1 /* Chip Rev. for Yukon-2 EX A0 */ #define CHIP_REV_YU_EX_B0 2 /* Chip Rev. for Yukon-2 EX B0 */ +#define CHIP_REV_YU_SU_A0 0 /* Chip Rev. for Yukon-2 SUPR A0 */ +#define CHIP_REV_YU_SU_B0 1 /* Chip Rev. for Yukon-2 SUPR B0 */ +#define CHIP_REV_YU_SU_B1 3 /* Chip Rev. for Yukon-2 SUPR B1 */ + /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ #define Y2_STATUS_LNK2_INAC BIT_7 /* Status Link 2 inactiv (0 = activ) */ #define Y2_CLK_GAT_LNK2_DIS BIT_6 /* Disable clock gating Link 2 */ diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index 8dc5b0b4b0f2..84725dde0e16 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -79,6 +79,7 @@ FEATURE(nfscl, "NFSv4 client"); extern int nfscl_ticks; extern struct timeval nfsboottime; extern struct nfsstats newnfsstats; +extern int nfsrv_useacl; MALLOC_DEFINE(M_NEWNFSREQ, "newnfsclient_req", "New NFS request header"); MALLOC_DEFINE(M_NEWNFSMNT, "newnfsmnt", "New NFS mount struct"); @@ -1331,6 +1332,15 @@ mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam, if (argp->flags & NFSMNT_NFSV3) ncl_fsinfo(nmp, *vpp, cred, td); + /* Mark if the mount point supports NFSv4 ACLs. */ + if ((argp->flags & NFSMNT_NFSV4) != 0 && nfsrv_useacl != 0 && + ret == 0 && + NFSISSET_ATTRBIT(&nfsva.na_suppattr, NFSATTRBIT_ACL)) { + MNT_ILOCK(mp); + mp->mnt_flag |= MNT_NFS4ACLS; + MNT_IUNLOCK(mp); + } + /* * Lose the lock but keep the ref. */ diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index 9b4d782aa410..22338a513caa 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -180,6 +180,7 @@ g_gate_start(struct bio *bp) break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: /* XXX: Hack to allow read-only mounts. */ if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) { g_io_deliver(bp, EPERM); @@ -580,6 +581,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa switch (bp->bio_cmd) { case BIO_READ: case BIO_DELETE: + case BIO_FLUSH: break; case BIO_WRITE: error = copyout(bp->bio_data, ggio->gctl_data, @@ -643,6 +645,7 @@ g_gate_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct threa break; case BIO_DELETE: case BIO_WRITE: + case BIO_FLUSH: break; } } diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c index 41a9fa8e8310..16760ce90c54 100644 --- a/sys/kern/kern_environment.c +++ b/sys/kern/kern_environment.c @@ -225,13 +225,19 @@ static void init_dynamic_kenv(void *data __unused) { char *cp; - int len, i; + size_t len; + int i; kenvp = malloc((KENV_SIZE + 1) * sizeof(char *), M_KENV, M_WAITOK | M_ZERO); i = 0; for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { len = strlen(cp) + 1; + if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { + printf("WARNING: too long kenv string, ignoring %s\n", + cp); + continue; + } if (i < KENV_SIZE) { kenvp[i] = malloc(len, M_KENV, M_WAITOK); strcpy(kenvp[i++], cp); diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 0b5e973bc734..00681cae2f93 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -654,7 +654,7 @@ bufinit(void) * To support extreme low-memory systems, make sure hidirtybuffers cannot * eat up all available buffer space. This occurs when our minimum cannot * be met. We try to size hidirtybuffers to 3/4 our buffer space assuming - * BKVASIZE'd (8K) buffers. + * BKVASIZE'd buffers. */ while ((long)hidirtybuffers * BKVASIZE > 3 * hibufspace / 4) { hidirtybuffers >>= 1; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b3bb8d9bb017..9bde3c821242 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2,8 +2,12 @@ * Copyright (c) 1982, 1986, 1991, 1993, 1995 * The Regents of the University of California. * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * + * Portions of this software were developed by Robert N. M. Watson under + * contract to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -50,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -287,7 +292,7 @@ in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo) #endif INP_WLOCK(inp); inp->inp_gencnt = ++pcbinfo->ipi_gencnt; - inp->inp_refcount = 1; /* Reference from the inpcbinfo */ + refcount_init(&inp->inp_refcount, 1); /* Reference from inpcbinfo */ #if defined(IPSEC) || defined(MAC) out: if (error != 0) { @@ -329,7 +334,7 @@ in_pcbbind(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) #if defined(INET) || defined(INET6) int in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, - struct ucred *cred, int wild) + struct ucred *cred, int lookupflags) { struct inpcbinfo *pcbinfo; struct inpcb *tmpinp; @@ -424,14 +429,14 @@ in_pcb_lport(struct inpcb *inp, struct in_addr *laddrp, u_short *lportp, #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) tmpinp = in6_pcblookup_local(pcbinfo, - &inp->in6p_laddr, lport, wild, cred); + &inp->in6p_laddr, lport, lookupflags, cred); #endif #if defined(INET) && defined(INET6) else #endif #ifdef INET tmpinp = in_pcblookup_local(pcbinfo, laddr, - lport, wild, cred); + lport, lookupflags, cred); #endif } while (tmpinp != NULL); @@ -464,7 +469,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; struct in_addr laddr; u_short lport = 0; - int wild = 0, reuseport = (so->so_options & SO_REUSEPORT); + int lookupflags = 0, reuseport = (so->so_options & SO_REUSEPORT); int error; /* @@ -480,7 +485,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, if (nam != NULL && laddr.s_addr != INADDR_ANY) return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; if (nam == NULL) { if ((error = prison_local_ip4(cred, &laddr)) != 0) return (error); @@ -561,7 +566,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, return (EADDRINUSE); } t = in_pcblookup_local(pcbinfo, sin->sin_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && (t->inp_flags & INP_TIMEWAIT)) { /* * XXXRW: If an incpb has had its timewait @@ -590,7 +595,7 @@ in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp, if (*lportp != 0) lport = *lportp; if (lport == 0) { - error = in_pcb_lport(inp, &laddr, &lport, cred, wild); + error = in_pcb_lport(inp, &laddr, &lport, cred, lookupflags); if (error != 0) return (error); @@ -1028,26 +1033,121 @@ in_pcbdetach(struct inpcb *inp) } /* - * in_pcbfree_internal() frees an inpcb that has been detached from its - * socket, and whose reference count has reached 0. It will also remove the - * inpcb from any global lists it might remain on. + * in_pcbref() bumps the reference count on an inpcb in order to maintain + * stability of an inpcb pointer despite the inpcb lock being released. This + * is used in TCP when the inpcbinfo lock needs to be acquired or upgraded, + * but where the inpcb lock is already held. + * + * in_pcbref() should be used only to provide brief memory stability, and + * must always be followed by a call to INP_WLOCK() and in_pcbrele() to + * garbage collect the inpcb if it has been in_pcbfree()'d from another + * context. Until in_pcbrele() has returned that the inpcb is still valid, + * lock and rele are the *only* safe operations that may be performed on the + * inpcb. + * + * While the inpcb will not be freed, releasing the inpcb lock means that the + * connection's state may change, so the caller should be careful to + * revalidate any cached state on reacquiring the lock. Drop the reference + * using in_pcbrele(). */ -static void -in_pcbfree_internal(struct inpcb *inp) +void +in_pcbref(struct inpcb *inp) { - struct inpcbinfo *ipi = inp->inp_pcbinfo; - KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); - KASSERT(inp->inp_refcount == 0, ("%s: refcount !0", __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); INP_WLOCK_ASSERT(inp); + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + refcount_acquire(&inp->inp_refcount); +} + +/* + * Drop a refcount on an inpcb elevated using in_pcbref(); because a call to + * in_pcbfree() may have been made between in_pcbref() and in_pcbrele(), we + * return a flag indicating whether or not the inpcb remains valid. If it is + * valid, we return with the inpcb lock held. + * + * Notice that, unlike in_pcbref(), the inpcb lock must be held to drop a + * reference on an inpcb. Historically more work was done here (actually, in + * in_pcbfree_internal()) but has been moved to in_pcbfree() to avoid the + * need for the pcbinfo lock in in_pcbrele(). Deferring the free is entirely + * about memory stability (and continued use of the write lock). + */ +int +in_pcbrele_rlocked(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + INP_RLOCK_ASSERT(inp); + + if (refcount_release(&inp->inp_refcount) == 0) + return (0); + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_RUNLOCK(inp); + pcbinfo = inp->inp_pcbinfo; + uma_zfree(pcbinfo->ipi_zone, inp); + return (1); +} + +int +in_pcbrele_wlocked(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + + KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); + + INP_WLOCK_ASSERT(inp); + + if (refcount_release(&inp->inp_refcount) == 0) + return (0); + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_WUNLOCK(inp); + pcbinfo = inp->inp_pcbinfo; + uma_zfree(pcbinfo->ipi_zone, inp); + return (1); +} + +/* + * Temporary wrapper. + */ +int +in_pcbrele(struct inpcb *inp) +{ + + return (in_pcbrele_wlocked(inp)); +} + +/* + * Unconditionally schedule an inpcb to be freed by decrementing its + * reference count, which should occur only after the inpcb has been detached + * from its socket. If another thread holds a temporary reference (acquired + * using in_pcbref()) then the free is deferred until that reference is + * released using in_pcbrele(), but the inpcb is still unlocked. Almost all + * work, including removal from global lists, is done in this context, where + * the pcbinfo lock is held. + */ +void +in_pcbfree(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; + + KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", __func__)); + + INP_INFO_WLOCK_ASSERT(pcbinfo); + INP_WLOCK_ASSERT(inp); + + /* XXXRW: Do as much as possible here. */ #ifdef IPSEC if (inp->inp_sp != NULL) ipsec_delete_pcbpolicy(inp); #endif /* IPSEC */ - inp->inp_gencnt = ++ipi->ipi_gencnt; + inp->inp_gencnt = ++pcbinfo->ipi_gencnt; in_pcbremlists(inp); #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) { @@ -1064,82 +1164,10 @@ in_pcbfree_internal(struct inpcb *inp) #endif inp->inp_vflag = 0; crfree(inp->inp_cred); - #ifdef MAC mac_inpcb_destroy(inp); #endif - INP_WUNLOCK(inp); - uma_zfree(ipi->ipi_zone, inp); -} - -/* - * in_pcbref() bumps the reference count on an inpcb in order to maintain - * stability of an inpcb pointer despite the inpcb lock being released. This - * is used in TCP when the inpcbinfo lock needs to be acquired or upgraded, - * but where the inpcb lock is already held. - * - * While the inpcb will not be freed, releasing the inpcb lock means that the - * connection's state may change, so the caller should be careful to - * revalidate any cached state on reacquiring the lock. Drop the reference - * using in_pcbrele(). - */ -void -in_pcbref(struct inpcb *inp) -{ - - INP_WLOCK_ASSERT(inp); - - KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); - - inp->inp_refcount++; -} - -/* - * Drop a refcount on an inpcb elevated using in_pcbref(); because a call to - * in_pcbfree() may have been made between in_pcbref() and in_pcbrele(), we - * return a flag indicating whether or not the inpcb remains valid. If it is - * valid, we return with the inpcb lock held. - */ -int -in_pcbrele(struct inpcb *inp) -{ -#ifdef INVARIANTS - struct inpcbinfo *ipi = inp->inp_pcbinfo; -#endif - - KASSERT(inp->inp_refcount > 0, ("%s: refcount 0", __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); - INP_WLOCK_ASSERT(inp); - - inp->inp_refcount--; - if (inp->inp_refcount > 0) - return (0); - in_pcbfree_internal(inp); - return (1); -} - -/* - * Unconditionally schedule an inpcb to be freed by decrementing its - * reference count, which should occur only after the inpcb has been detached - * from its socket. If another thread holds a temporary reference (acquired - * using in_pcbref()) then the free is deferred until that reference is - * released using in_pcbrele(), but the inpcb is still unlocked. - */ -void -in_pcbfree(struct inpcb *inp) -{ -#ifdef INVARIANTS - struct inpcbinfo *ipi = inp->inp_pcbinfo; -#endif - - KASSERT(inp->inp_socket == NULL, ("%s: inp_socket != NULL", - __func__)); - - INP_INFO_WLOCK_ASSERT(ipi); - INP_WLOCK_ASSERT(inp); - - if (!in_pcbrele(inp)) + if (!in_pcbrele_wlocked(inp)) INP_WUNLOCK(inp); } @@ -1307,7 +1335,7 @@ in_pcbpurgeif0(struct inpcbinfo *pcbinfo, struct ifnet *ifp) #define INP_LOOKUP_MAPPED_PCB_COST 3 struct inpcb * in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, - u_short lport, int wild_okay, struct ucred *cred) + u_short lport, int lookupflags, struct ucred *cred) { struct inpcb *inp; #ifdef INET6 @@ -1317,9 +1345,12 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, #endif int wildcard; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); - if (!wild_okay) { + if ((lookupflags & INPLOOKUP_WILDCARD) == 0) { struct inpcbhead *head; /* * Look for an unconnected (wildcard foreign addr) PCB that @@ -1425,13 +1456,16 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, */ struct inpcb * in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, - u_int fport_arg, struct in_addr laddr, u_int lport_arg, int wildcard, + u_int fport_arg, struct in_addr laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) { struct inpcbhead *head; struct inpcb *inp, *tmpinp; u_short fport = fport_arg, lport = lport_arg; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); /* @@ -1467,7 +1501,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, /* * Then look for a wildcard match, if requested. */ - if (wildcard == INPLOOKUP_WILDCARD) { + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { struct inpcb *local_wild = NULL, *local_exact = NULL; #ifdef INET6 struct inpcb *local_wild_mapped = NULL; @@ -1538,7 +1572,7 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, if (local_wild_mapped != NULL) return (local_wild_mapped); #endif /* defined(INET6) */ - } /* if (wildcard == INPLOOKUP_WILDCARD) */ + } /* if ((lookupflags & INPLOOKUP_WILDCARD) != 0) */ return (NULL); } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 813011ecbf1d..14d4ea233751 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,8 +1,12 @@ /*- * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. + * Copyright (c) 2010-2011 Juniper Networks, Inc. * All rights reserved. * + * Portions of this software were developed by Robert N. M. Watson under + * contract to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -260,53 +264,70 @@ struct inpcbport { u_short phd_port; }; -/* +/*- * Global data structure for each high-level protocol (UDP, TCP, ...) in both * IPv4 and IPv6. Holds inpcb lists and information for managing them. + * + * Each pcbinfo is protected by ipi_lock, covering mutable global fields (such + * as the global pcb list) and hashed lookup tables. The lock order is: + * + * ipi_lock (before) inpcb locks + * + * Locking key: + * + * (c) Constant or nearly constant after initialisation + * (g) Locked by ipi_lock + * (h) Read using either ipi_lock or inpcb lock; write requires both. + * (x) Synchronisation properties poorly defined */ struct inpcbinfo { + /* + * Global lock protecting global inpcb list, inpcb count, hash tables, + * etc. + */ + struct rwlock ipi_lock; + /* * Global list of inpcbs on the protocol. */ - struct inpcbhead *ipi_listhead; - u_int ipi_count; + struct inpcbhead *ipi_listhead; /* (g) */ + u_int ipi_count; /* (g) */ + + /* + * Generation count -- incremented each time a connection is allocated + * or freed. + */ + u_quad_t ipi_gencnt; /* (g) */ + + /* + * Fields associated with port lookup and allocation. + */ + u_short ipi_lastport; /* (x) */ + u_short ipi_lastlow; /* (x) */ + u_short ipi_lasthi; /* (x) */ + + /* + * UMA zone from which inpcbs are allocated for this protocol. + */ + struct uma_zone *ipi_zone; /* (c) */ /* * Global hash of inpcbs, hashed by local and foreign addresses and * port numbers. */ - struct inpcbhead *ipi_hashbase; - u_long ipi_hashmask; + struct inpcbhead *ipi_hashbase; /* (g) */ + u_long ipi_hashmask; /* (g) */ /* * Global hash of inpcbs, hashed by only local port number. */ - struct inpcbporthead *ipi_porthashbase; - u_long ipi_porthashmask; - - /* - * Fields associated with port lookup and allocation. - */ - u_short ipi_lastport; - u_short ipi_lastlow; - u_short ipi_lasthi; - - /* - * UMA zone from which inpcbs are allocated for this protocol. - */ - struct uma_zone *ipi_zone; - - /* - * Generation count--incremented each time a connection is allocated - * or freed. - */ - u_quad_t ipi_gencnt; - struct rwlock ipi_lock; + struct inpcbporthead *ipi_porthashbase; /* (g) */ + u_long ipi_porthashmask; /* (g) */ /* * Pointer to network stack instance */ - struct vnet *ipi_vnet; + struct vnet *ipi_vnet; /* (c) */ /* * general use 2 @@ -513,6 +534,8 @@ void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, void in_pcbref(struct inpcb *); void in_pcbrehash(struct inpcb *); int in_pcbrele(struct inpcb *); +int in_pcbrele_rlocked(struct inpcb *); +int in_pcbrele_wlocked(struct inpcb *); void in_pcbsetsolabel(struct socket *so); int in_getpeeraddr(struct socket *so, struct sockaddr **nam); int in_getsockaddr(struct socket *so, struct sockaddr **nam); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 9e64562f9366..eacce8c5376d 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -111,7 +111,8 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; u_short lport = 0; - int error, wild = 0, reuseport = (so->so_options & SO_REUSEPORT); + int error, lookupflags = 0; + int reuseport = (so->so_options & SO_REUSEPORT); INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); @@ -121,7 +122,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, if (inp->inp_lport || !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; if (nam == NULL) { if ((error = prison_local_ip6(cred, &inp->in6p_laddr, ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) @@ -226,7 +227,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, #endif } t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && (reuseport & ((t->inp_flags & INP_TIMEWAIT) ? intotw(t)->tw_so_options : t->inp_socket->so_options)) == 0) @@ -238,7 +239,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, in6_sin6_2_sin(&sin, sin6); t = in_pcblookup_local(pcbinfo, sin.sin_addr, - lport, wild, cred); + lport, lookupflags, cred); if (t && t->inp_flags & INP_TIMEWAIT) { if ((reuseport & intotw(t)->tw_so_options) == 0 && @@ -652,14 +653,17 @@ in6_pcbnotify(struct inpcbinfo *pcbinfo, struct sockaddr *dst, */ struct inpcb * in6_pcblookup_local(struct inpcbinfo *pcbinfo, struct in6_addr *laddr, - u_short lport, int wild_okay, struct ucred *cred) + u_short lport, int lookupflags, struct ucred *cred) { register struct inpcb *inp; int matchwild = 3, wildcard; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_WLOCK_ASSERT(pcbinfo); - if (!wild_okay) { + if ((lookupflags & INPLOOKUP_WILDCARD) == 0) { struct inpcbhead *head; /* * Look for an unconnected (wildcard foreign addr) PCB that @@ -815,7 +819,7 @@ in6_rtchange(struct inpcb *inp, int errno) */ struct inpcb * in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, - u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int wildcard, + u_int fport_arg, struct in6_addr *laddr, u_int lport_arg, int lookupflags, struct ifnet *ifp) { struct inpcbhead *head; @@ -823,6 +827,9 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_short fport = fport_arg, lport = lport_arg; int faith; + KASSERT((lookupflags & ~(INPLOOKUP_WILDCARD)) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + INP_INFO_LOCK_ASSERT(pcbinfo); if (faithprefix_p != NULL) @@ -862,7 +869,7 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, /* * Then look for a wildcard match, if requested. */ - if (wildcard == INPLOOKUP_WILDCARD) { + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { struct inpcb *local_wild = NULL, *local_exact = NULL; struct inpcb *jail_wild = NULL; int injail; @@ -919,7 +926,7 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, return (local_exact); if (local_wild != NULL) return (local_wild); - } /* if (wildcard == INPLOOKUP_WILDCARD) */ + } /* if ((lookupflags & INPLOOKUP_WILDCARD) != 0) */ /* * Not found. diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index b491e0e7ab10..5202e091bc92 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -851,7 +851,7 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred) { struct socket *so = inp->inp_socket; u_int16_t lport = 0; - int error, wild = 0; + int error, lookupflags = 0; #ifdef INVARIANTS struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; #endif @@ -866,11 +866,11 @@ in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred) /* XXX: this is redundant when called from in6_pcbbind */ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) - wild = INPLOOKUP_WILDCARD; + lookupflags = INPLOOKUP_WILDCARD; inp->inp_flags |= INP_ANONPORT; - error = in_pcb_lport(inp, NULL, &lport, cred, wild); + error = in_pcb_lport(inp, NULL, &lport, cred, lookupflags); if (error != 0) return (error); diff --git a/usr.bin/gzip/Makefile b/usr.bin/gzip/Makefile index 048033738756..16a825f66133 100644 --- a/usr.bin/gzip/Makefile +++ b/usr.bin/gzip/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2006/05/12 02:01:15 mrg Exp $ +# $NetBSD: Makefile,v 1.13 2009/04/14 22:15:20 lukem Exp $ # $FreeBSD$ .include diff --git a/usr.bin/gzip/gzip.1 b/usr.bin/gzip/gzip.1 index 848a4b391c94..c0dc670a2cf2 100644 --- a/usr.bin/gzip/gzip.1 +++ b/usr.bin/gzip/gzip.1 @@ -25,7 +25,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 27, 2010 +.Dd May 23, 2011 .Dt GZIP 1 .Os .Sh NAME @@ -127,9 +127,9 @@ stream, leaving files intact. This option selects decompression rather than compression. .It Fl f , -force This option turns on force mode. -This allows files with multiple links, overwriting of pre-existing -files, reading from or writing to a terminal, and when combined -with the +This allows files with multiple links, symbolic links to regular files, +overwriting of pre-existing files, reading from or writing to a terminal, +and when combined with the .Fl c option, allowing non-compressed data to pass through unchanged. .It Fl h , -help diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index d86e84b65407..927493eced7d 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -1,4 +1,4 @@ -/* $NetBSD: gzip.c,v 1.97 2009/10/11 09:17:21 mrg Exp $ */ +/* $NetBSD: gzip.c,v 1.99 2011/03/23 12:59:44 tsutsui Exp $ */ /*- * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green @@ -31,7 +31,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006\ Matthew R. Green. All rights reserved."); -__RCSID("$FreeBSD$"); +__FBSDID("$FreeBSD$"); #endif /* not lint */ /* @@ -146,7 +146,7 @@ static suffixes_t suffixes[] = { #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0]) #define SUFFIX_MAXLEN 30 -static const char gzip_version[] = "FreeBSD gzip 20100407"; +static const char gzip_version[] = "FreeBSD gzip 20110523"; #ifndef SMALL static const char gzip_copyright[] = \ @@ -314,7 +314,7 @@ main(int argc, char **argv) dflag = cflag = 1; #ifdef SMALL -#define OPT_LIST "123456789cdhltV" +#define OPT_LIST "123456789cdhlV" #else #define OPT_LIST "123456789acdfhklLNnqrS:tVv" #endif @@ -918,6 +918,7 @@ gz_uncompress(int in, int out, char *pre, size_t prelen, off_t *gsizep, case Z_BUF_ERROR: if (z.avail_out > 0 && !done_reading) continue; + case Z_STREAM_END: case Z_OK: break; @@ -1781,7 +1782,7 @@ handle_pathname(char *path) } retry: - if (stat(path, &sb) != 0) { + if (stat(path, &sb) != 0 || (fflag == 0 && lstat(path, &sb) != 0)) { /* lets try .gz if we're decompressing */ if (dflag && s == NULL && errno == ENOENT) { len = strlen(path); diff --git a/usr.bin/gzip/zdiff b/usr.bin/gzip/zdiff index 34caf2bdfb83..9e9aca677e25 100644 --- a/usr.bin/gzip/zdiff +++ b/usr.bin/gzip/zdiff @@ -1,10 +1,12 @@ #!/bin/sh - # -# $NetBSD: zdiff,v 1.3 2004/03/29 10:01:00 wiz Exp $ +# $NetBSD: zdiff,v 1.5 2010/04/14 20:30:28 joerg Exp $ +# # $OpenBSD: zdiff,v 1.2 2003/07/29 07:42:44 otto Exp $ # #- # Copyright (c) 2003 Todd C. Miller +# Copyright (c) 2010 Joerg Sonnenberger # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -31,7 +33,57 @@ case $0 in *) prog=diff ;; esac -USAGE="usage: z$prog [options] file1 [file2]" +USAGE="usage: $0 [options] file1 [file2]" + +check_suffix() { + case "$1" in + *[._-][Zz]) + setvar $2 "${1%??}" + setvar $3 "gzip -cdqf" + ;; + *[._-]bz) + setvar $2 "${1%???}" + setvar $3 "bzip2 -cdqf" + ;; + *[._-]gz) + setvar $2 "${1%???}" + setvar $3 "gzip -cdqf" + ;; + *[._-]xz) + setvar $2 "${1%???}" + setvar $3 "xz -cdqf" + ;; + *[._-]bz2) + setvar $2 "${1%????}" + setvar $3 "bzip2 -cdqf" + ;; + *[._-]lzma) + setvar $2 "${1%?????}" + setvar $3 "xz -cdqf" + ;; + *.t[ag]z) + setvar $2 "${1%??}"ar + setvar $3 "gzip -cdqf" + ;; + *.tbz) + setvar $2 "${1%??}"ar + setvar $3 "bzip2 -cdqf" + ;; + *.tbz2) + setvar $2 "${1%???}"ar + setvar $3 "bzip2 -cdqf" + ;; + *.t[lx]z) + setvar $2 "${1%??}"ar + setvar $3 "xz -cdqf" + ;; + *) + setvar $2 "$1" + setvar $3 "" + ;; + esac +} + # Pull out any command line flags so we can pass them to diff/cmp # XXX - assumes there is no optarg @@ -42,6 +94,9 @@ while test $# -ne 0; do shift break ;; + -) + break + ;; -*) flags="$flags $1" shift @@ -55,52 +110,28 @@ done if [ $# -eq 1 ]; then # One file given, compare compressed to uncompressed files="$1" - case "$1" in - *[._-][Zz]) - files="${1%??}" - ;; - *[._-]gz) - files="${1%???}" - ;; - *.t[ag]z) - files="${1%??}"ar - ;; - *) echo "z$prog: unknown suffix" 1>&2 - exit 1 - esac - gzip -cdfq "$1" | $prog $flags - "$files" + check_suffix "$1" files filt + if [ -z "$filt" ]; then + echo "z$prog: unknown suffix" 1>&2 + exit 1 + fi + $filt -- "$1" | $prog $flags -- - "$files" status=$? elif [ $# -eq 2 ]; then # Two files given, compare the two uncompressing as needed - case "$1" in - *[._-][Zz]|*[._-]gz|*.t[ag]z) - files=- - filt="gzip -cdfq $1" - ;; - *) - files="$1" - ;; - esac - case "$2" in - *[._-][Zz]|*[._-]gz|*.t[ag]z) - if [ "$files" = "-" ]; then - tmp=`mktemp -t z$prog.XXXXXXXXXX` || exit 1 - trap "rm -f $tmp" 0 1 2 3 13 15 - gzip -cdfq "$2" > $tmp - files="$files $tmp" - else - files="$files -" - filt="gzip -cdfq $2" - fi - ;; - *) - files="$files $2" - ;; - esac - if [ -n "$filt" ]; then - $filt | $prog $flags $files + check_suffix "$1" files filt + check_suffix "$2" files2 filt2 + if [ -z "$filt" -a -z "$filt2" ]; then + $prog $flags -- "$1" "$2" + elif [ -z "$filt" -a -n "$filt2" -a "$1" != "-" ]; then + $filt2 -- "$2" | $prog $flags -- "$1" - + elif [ -n "$filt" -a -z "$filt2" -a "$2" != "-" ]; then + $filt -- "$1" | $prog $flags -- - "$2" else - $prog $flags $files + tmp=`mktemp -t z$prog.XXXXXXXXXX` || exit 1 + trap "rm -f $tmp" 0 1 2 3 13 15 + ${filt2:-cat} -- "$2" > $tmp || exit $? + ${filt:-cat} -- "$1" | $prog $flags -- - "$tmp" fi status=$? else diff --git a/usr.bin/gzip/zdiff.1 b/usr.bin/gzip/zdiff.1 index 2a6a4c8c74a8..52b5fbd100e0 100644 --- a/usr.bin/gzip/zdiff.1 +++ b/usr.bin/gzip/zdiff.1 @@ -1,7 +1,8 @@ -.\" $NetBSD: zdiff.1,v 1.3 2003/12/28 12:48:03 wiz Exp $ +.\" $NetBSD: zdiff.1,v 1.5 2010/04/14 19:52:05 wiz Exp $ .\" $OpenBSD: zdiff.1,v 1.2 2003/07/13 17:39:14 millert Exp $ .\" .\" Copyright (c) 2003 Todd C. Miller +.\" Copyright (c) 2010 Joerg Sonnenberger .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -20,7 +21,7 @@ .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" .\" $FreeBSD$ -.Dd January 26, 2007 +.Dd May 23, 2011 .Dt ZDIFF 1 .Os .Sh NAME @@ -45,15 +46,6 @@ are filters that invoke or .Xr diff 1 respectively to compare compressed files. -Such files generally have a -.Dq Z -or -.Dq gz -extension (both the -.Xr compress 1 -and -.Xr gzip 1 -formats are supported). Any .Ar options that are specified are passed to @@ -70,6 +62,45 @@ When both or .Ar file2 are specified, either file may be compressed. +.Pp +Extensions handled by +.Xr gzip 1 : +.Bl -bullet -compact +.It +z, Z, +.It +gz, +.It +taz, +.It +tgz. +.El +.Pp +Extensions handled by +.Xr bzip2 1 : +.Bl -bullet -compact +.It +bz, +.It +bz2, +.It +tbz, +.It +tbz2. +.El +.Pp +Extensions handled by +.Xr xz 1 : +.Bl -bullet -compact +.It +lzma, +.It +xz, +.It +tlz, +.It +txz. +.El .Sh ENVIRONMENT .Bl -tag -width "TMPDIR" .It Ev TMPDIR @@ -88,9 +119,11 @@ Temporary file for .Nm zdiff . .El .Sh SEE ALSO +.Xr bzip2 1 , .Xr cmp 1 , -.Xr compress 1 , -.Xr diff 1 +.Xr diff 1 , +.Xr gzip 1 , +.Xr xz 1 .Sh CAVEATS .Nm zcmp and diff --git a/usr.bin/gzip/zuncompress.c b/usr.bin/gzip/zuncompress.c index 8e619bde1549..f68ba595680b 100644 --- a/usr.bin/gzip/zuncompress.c +++ b/usr.bin/gzip/zuncompress.c @@ -1,4 +1,4 @@ -/* $NetBSD: zuncompress.c,v 1.7 2009/04/12 10:31:14 lukem Exp $ */ +/* $NetBSD: zuncompress.c,v 1.8 2010/11/06 21:42:32 mrg Exp $ */ /*- * Copyright (c) 1985, 1986, 1992, 1993 From c0038ec50d088a2152d05e1da7d5b4cec45e8d27 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 24 May 2011 15:47:40 +0000 Subject: [PATCH 069/164] - Fix a misusage of cpuset_t objects - Fix a typo Reported by: pluknet --- sys/i386/i386/pmap.c | 4 ++-- sys/i386/xen/pmap.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index a09138cb2567..3f9248df2b35 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -1939,7 +1939,7 @@ pmap_lazyfix(pmap_t pmap) { cpuset_t mymask, mask; u_int spins; - int lbs; + int lsb; mask = pmap->pm_active; while (!CPU_EMPTY(&mask)) { @@ -1957,7 +1957,7 @@ pmap_lazyfix(pmap_t pmap) lazyptd = vtophys(pmap->pm_pdir); #endif mymask = PCPU_GET(cpumask); - if (mask == mymask) { + if (!CPU_CMP(&mask, &mymask)) { lazymask = &pmap->pm_active; pmap_lazyfix_self(mymask); } else { diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c index 2f3953884ab1..3efa4f1e174a 100644 --- a/sys/i386/xen/pmap.c +++ b/sys/i386/xen/pmap.c @@ -1740,7 +1740,7 @@ pmap_lazyfix(pmap_t pmap) lazyptd = vtophys(pmap->pm_pdir); #endif mymask = PCPU_GET(cpumask); - if (mask == mymask) { + if (!CPU_CMP(&mask, &mymask)) { lazymask = &pmap->pm_active; pmap_lazyfix_self(mymask); } else { From 9a75ededfbf8db715ecf5af60beb219e832c77da Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 27 May 2011 15:50:14 +0000 Subject: [PATCH 070/164] In the near future cpuset_t objects in struct pcpu will be axed out, but as long as this does not happen, we need to fix interfaces to userland in order to not break run-time accesses to the structure. Reviwed by: kib Tested by: pluknet --- lib/libkvm/kvm_pcpu.c | 31 +++++++++++++++++++++++++++++-- sys/sys/pcpu.h | 14 ++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c index fd09fc88fb1c..bc73baff19cc 100644 --- a/lib/libkvm/kvm_pcpu.c +++ b/lib/libkvm/kvm_pcpu.c @@ -39,11 +39,13 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include #include #include +#include #include "kvm_private.h" @@ -118,6 +120,9 @@ _kvm_pcpu_clear(void) void * kvm_getpcpu(kvm_t *kd, int cpu) { + long kcpusetsize; + ssize_t nbytes; + uintptr_t readptr; char *buf; if (kd == NULL) { @@ -125,6 +130,10 @@ kvm_getpcpu(kvm_t *kd, int cpu) return (NULL); } + kcpusetsize = sysconf(_SC_CPUSET_SIZE); + if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) + return ((void *)-1); + if (maxcpu == 0) if (_kvm_pcpu_init(kd) < 0) return ((void *)-1); @@ -137,8 +146,26 @@ kvm_getpcpu(kvm_t *kd, int cpu) _kvm_err(kd, kd->program, "out of memory"); return ((void *)-1); } - if (kvm_read(kd, (uintptr_t)pcpu_data[cpu], buf, sizeof(struct pcpu)) != - sizeof(struct pcpu)) { + nbytes = sizeof(struct pcpu) - 2 * kcpusetsize; + readptr = (uintptr_t)pcpu_data[cpu]; + if (kvm_read(kd, readptr, buf, nbytes) != nbytes) { + _kvm_err(kd, kd->program, "unable to read per-CPU data"); + free(buf); + return ((void *)-1); + } + + /* Fetch the valid cpuset_t objects. */ + CPU_ZERO((cpuset_t *)(buf + nbytes)); + CPU_ZERO((cpuset_t *)(buf + nbytes + sizeof(cpuset_t))); + readptr += nbytes; + if (kvm_read(kd, readptr, buf + nbytes, kcpusetsize) != kcpusetsize) { + _kvm_err(kd, kd->program, "unable to read per-CPU data"); + free(buf); + return ((void *)-1); + } + readptr += kcpusetsize; + if (kvm_read(kd, readptr, buf + nbytes + sizeof(cpuset_t), + kcpusetsize) != kcpusetsize) { _kvm_err(kd, kd->program, "unable to read per-CPU data"); free(buf); return ((void *)-1); diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 1b7f24f39117..752d2dfbec0c 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -163,8 +163,6 @@ struct pcpu { uint64_t pc_switchtime; /* cpu_ticks() at last csw */ int pc_switchticks; /* `ticks' at last csw */ u_int pc_cpuid; /* This cpu number */ - cpuset_t pc_cpumask; /* This cpu mask */ - cpuset_t pc_other_cpus; /* Mask of all other cpus */ SLIST_ENTRY(pcpu) pc_allcpu; struct lock_list_entry *pc_spinlocks; #ifdef KTR @@ -198,6 +196,18 @@ struct pcpu { * if only to make kernel debugging easier. */ PCPU_MD_FIELDS; + + /* + * XXX + * For the time being, keep the cpuset_t objects as the very last + * members of the structure. + * They are actually tagged to be removed soon, but as long as this + * does not happen, it is necessary to find a way to implement + * easilly interfaces to userland and leaving them last makes that + * possible. + */ + cpuset_t pc_cpumask; /* This cpu mask */ + cpuset_t pc_other_cpus; /* Mask of all other cpus */ } __aligned(CACHE_LINE_SIZE); #ifdef _KERNEL From cc1bd831c19be5a5a5ce6c3efef4c3874ddfabb0 Mon Sep 17 00:00:00 2001 From: attilio Date: Fri, 27 May 2011 16:01:51 +0000 Subject: [PATCH 071/164] Style fix: cast to size_t rather than u_long when comparing to sizeof() rets. Requested by: kib --- gnu/usr.bin/gdb/kgdb/kthr.c | 2 +- lib/libkvm/kvm_pcpu.c | 2 +- lib/libmemstat/memstat_uma.c | 2 +- usr.sbin/pmccontrol/pmccontrol.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index 461f408a73d9..7b39929fa55a 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -107,7 +107,7 @@ kgdb_thr_init(void) addr = kgdb_lookup("stopped_cpus"); CPU_ZERO(&stopped_cpus); cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize != -1 && (u_long)cpusetsize <= sizeof(cpuset_t) && + if (cpusetsize != -1 && (size_t)cpusetsize <= sizeof(cpuset_t) && addr != 0) kvm_read(kvm, addr, &stopped_cpus, cpusetsize); diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c index bc73baff19cc..7e421aeb893c 100644 --- a/lib/libkvm/kvm_pcpu.c +++ b/lib/libkvm/kvm_pcpu.c @@ -131,7 +131,7 @@ kvm_getpcpu(kvm_t *kd, int cpu) } kcpusetsize = sysconf(_SC_CPUSET_SIZE); - if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) + if (kcpusetsize == -1 || (size_t)kcpusetsize > sizeof(cpuset_t)) return ((void *)-1); if (maxcpu == 0) diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 485a4f279906..b9bde7d4179c 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -341,7 +341,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) return (-1); } cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { + if (cpusetsize == -1 || (size_t)cpusetsize > sizeof(cpuset_t)) { list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL; return (-1); } diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c index 80d4bd7c3dde..28f7ab493363 100644 --- a/usr.sbin/pmccontrol/pmccontrol.c +++ b/usr.sbin/pmccontrol/pmccontrol.c @@ -148,7 +148,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list) /* Determine the set of active CPUs. */ cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { + if (cpusetsize == -1 || (size_t)cpusetsize > sizeof(cpuset_t)) { err(EX_OSERR, "ERROR: Cannot determine which CPUs are " "halted"); } From bc42b89c8c032701b87cd4ddfafdba1a6acb1125 Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 29 May 2011 18:13:04 +0000 Subject: [PATCH 072/164] Remove the unnecessary _KERNEL protection --- sys/sys/cpuset.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index e06df54ab018..45252638e15a 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -125,7 +125,6 @@ (d)->__bits[__i] &= ~(s)->__bits[__i]; \ } while (0) -#ifdef _KERNEL #define CPU_CLR_ATOMIC(n, p) \ atomic_clear_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) @@ -152,7 +151,6 @@ atomic_store_rel_long(&(t)->__bits[__i], \ (f)->__bits[__i]); \ } while (0) -#endif /* !_KERNEL */ /* * Valid cpulevel_t values. From 8dd6262cd373f038ccdf8cfe1bb317679fd36c2b Mon Sep 17 00:00:00 2001 From: attilio Date: Sun, 29 May 2011 18:33:13 +0000 Subject: [PATCH 073/164] MFC --- contrib/ntp/ntpd/ntp_io.c | 9 +- share/man/man4/vge.4 | 9 +- sys/boot/powerpc/ofw/Makefile | 1 + sys/conf/files.powerpc | 1 + sys/dev/iicbus/ad7417.c | 457 ++++++++++++++++++++++++ sys/kern/uipc_socket.c | 14 +- sys/netinet/in.c | 25 +- sys/powerpc/conf/GENERIC | 1 + sys/powerpc/conf/GENERIC64 | 1 + sys/powerpc/conf/NOTES | 1 + tools/regression/bin/sh/builtins/set1.0 | 32 ++ 11 files changed, 534 insertions(+), 17 deletions(-) create mode 100644 sys/dev/iicbus/ad7417.c create mode 100644 tools/regression/bin/sh/builtins/set1.0 diff --git a/contrib/ntp/ntpd/ntp_io.c b/contrib/ntp/ntpd/ntp_io.c index 71ee15fef6f6..8dac3c494b8e 100644 --- a/contrib/ntp/ntpd/ntp_io.c +++ b/contrib/ntp/ntpd/ntp_io.c @@ -1753,7 +1753,12 @@ void enable_multicast_if(struct interface *iface, struct sockaddr_storage *maddr) { #ifdef MCAST +#ifdef IP_MULTICAST_LOOP /*u_char*/ TYPEOF_IP_MULTICAST_LOOP off = 0; +#endif +#ifdef IPV6_MULTICAST_LOOP + u_int off6 = 0; /* RFC 3493, 5.2. defines type unsigned int */ +#endif switch (maddr->ss_family) { @@ -1797,9 +1802,9 @@ enable_multicast_if(struct interface *iface, struct sockaddr_storage *maddr) * Don't send back to itself, but allow it to fail to set it */ if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, - (char *) &off, sizeof(off)) == -1) { + (char *) &off6, sizeof(off6)) == -1) { netsyslog(LOG_ERR, - "setsockopt IP_MULTICAST_LOOP failure: %m on socket %d, addr %s for multicast address %s", + "setsockopt IPV6_MULTICAST_LOOP failure: %m on socket %d, addr %s for multicast address %s", iface->fd, stoa(&iface->sin), stoa(maddr)); } #endif diff --git a/share/man/man4/vge.4 b/share/man/man4/vge.4 index ae0206a62e89..3ab9bce59c09 100644 --- a/share/man/man4/vge.4 +++ b/share/man/man4/vge.4 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 23, 2010 +.Dd May 29, 2011 .Dt VGE 4 .Os .Sh NAME @@ -66,13 +66,14 @@ The MAC supports TCP/IP hardware checksums (IPv4 only), TCP large send, VLAN tag insertion and stripping, as well as VLAN filtering, a 64-entry CAM filter and a 64-entry VLAN filter, 64-bit multicast hash filter, 4 separate transmit DMA queues, flow control -and jumbo frames up to 16K in size. +and jumbo frames (not on VT6130/VT6132) up to 16K in size. The Velocity family controllers have a 16K receive FIFO and 48K transmit FIFO. .Pp The .Nm driver takes advantage of the controller's checksum offload and VLAN -tagging features, as well as the jumbo frame and CAM filter support. +tagging features, as well as the jumbo frame (except VT6130/VT6132) and CAM +filter support. The CAM filter is used for multicast address filtering to provide 64 perfect multicast address filter support. If it is necessary for the interface to join more than 64 multicast @@ -81,6 +82,8 @@ groups, the driver will switch over to using the hash filter. The jumbo frame support can be enabled by setting the interface MTU to any value larger than the default of 1500 bytes, up to a maximum of 9000 bytes. +Jumbo frames are disabled on the VT6130/VT6132 controllers because the TX +MAC will hang when trying to send a frame that is larger than 4K. The receive and transmit checksum offload support can be toggled on and off using the .Xr ifconfig 8 diff --git a/sys/boot/powerpc/ofw/Makefile b/sys/boot/powerpc/ofw/Makefile index aab4d15f306a..079f552b5a9d 100644 --- a/sys/boot/powerpc/ofw/Makefile +++ b/sys/boot/powerpc/ofw/Makefile @@ -103,6 +103,7 @@ loader.help: help.common help.ofw .PATH: ${.CURDIR}/../../forth FILES= loader.help loader.4th support.4th loader.conf +FILES+= screen.4th frames.4th FILES+= beastie.4th brand.4th check-password.4th color.4th delay.4th FILES+= menu.4th menu-commands.4th shortcuts.4th version.4th FILESDIR_loader.conf= /boot/defaults diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc index 7e72b1931314..7d4e2a2a7963 100644 --- a/sys/conf/files.powerpc +++ b/sys/conf/files.powerpc @@ -27,6 +27,7 @@ dev/cfi/cfi_bus_fdt.c optional cfi fdt dev/fb/fb.c optional sc dev/fdt/fdt_powerpc.c optional fdt dev/hwpmc/hwpmc_powerpc.c optional hwpmc +dev/iicbus/ad7417.c optional ad7417 powermac dev/iicbus/ds1775.c optional ds1775 powermac dev/iicbus/max6690.c optional max6690 powermac dev/kbd/kbd.c optional sc diff --git a/sys/dev/iicbus/ad7417.c b/sys/dev/iicbus/ad7417.c new file mode 100644 index 000000000000..aa26d6fbbc37 --- /dev/null +++ b/sys/dev/iicbus/ad7417.c @@ -0,0 +1,457 @@ +/*- + * Copyright (c) 2010 Andreas Tobler + * 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 ``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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +#define FCU_ZERO_C_TO_K 2732 + +/* CPU A/B sensors, temp and adc: AD7417. */ + +#define AD7417_TEMP 0x00 +#define AD7417_CONFIG 0x01 +#define AD7417_ADC 0x04 +#define AD7417_CONFIG2 0x05 +#define AD7417_CONFMASK 0xe0 + +uint8_t adc741x_config; + +struct ad7417_sensor { + int id; + char location[32]; + enum { + ADC7417_TEMP_SENSOR, + ADC7417_ADC_SENSOR + } type; +}; + +/* Regular bus attachment functions */ +static int ad7417_probe(device_t); +static int ad7417_attach(device_t); + +/* Utility functions */ +static int ad7417_sensor_sysctl(SYSCTL_HANDLER_ARGS); +static int ad7417_write(device_t dev, uint32_t addr, uint8_t reg, + uint8_t *buf, int len); +static int ad7417_read_1(device_t dev, uint32_t addr, uint8_t reg, + uint8_t *data); +static int ad7417_read_2(device_t dev, uint32_t addr, uint8_t reg, + uint16_t *data); + +struct ad7417_softc { + device_t sc_dev; + uint32_t sc_addr; + struct ad7417_sensor *sc_sensors; + int sc_nsensors; +}; +static device_method_t ad7417_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ad7417_probe), + DEVMETHOD(device_attach, ad7417_attach), + { 0, 0 }, +}; + +static driver_t ad7417_driver = { + "ad7417", + ad7417_methods, + sizeof(struct ad7417_softc) +}; + +static devclass_t ad7417_devclass; + +DRIVER_MODULE(ad7417, iicbus, ad7417_driver, ad7417_devclass, 0, 0); +MALLOC_DEFINE(M_AD7417, "ad7417", "Supply-Monitor AD7417"); + + +static int +ad7417_write(device_t dev, uint32_t addr, uint8_t reg, uint8_t *buff, int len) +{ + unsigned char buf[4]; + struct iic_msg msg[] = { + { addr, IIC_M_WR, 0, buf } + }; + + msg[0].len = len + 1; + buf[0] = reg; + memcpy(buf + 1, buff, len); + + if (iicbus_transfer(dev, msg, 1) != 0) { + device_printf(dev, "iicbus write failed\n"); + return (EIO); + } + + return (0); + +} + +static int +ad7417_read_1(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data) +{ + uint8_t buf[4]; + + struct iic_msg msg[2] = { + { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, + { addr, IIC_M_RD, 1, buf }, + }; + + if (iicbus_transfer(dev, msg, 2) != 0) { + device_printf(dev, "iicbus read failed\n"); + return (EIO); + } + + *data = *((uint8_t*)buf); + + return (0); +} + +static int +ad7417_read_2(device_t dev, uint32_t addr, uint8_t reg, uint16_t *data) +{ + uint8_t buf[4]; + + struct iic_msg msg[2] = { + { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, + { addr, IIC_M_RD, 2, buf }, + }; + + if (iicbus_transfer(dev, msg, 2) != 0) { + device_printf(dev, "iicbus read failed\n"); + return (EIO); + } + + *data = *((uint16_t*)buf); + + return (0); +} + +static int +ad7417_init_adc(device_t dev, uint32_t addr) +{ + uint8_t buf; + + adc741x_config = 0; + /* Clear Config2 */ + buf = 0; + ad7417_write(dev, addr, AD7417_CONFIG2, &buf, 1); + + /* Read & cache Config1 */ + buf = 0; + ad7417_write(dev, addr, AD7417_CONFIG, &buf, 1); + + ad7417_read_1(dev, addr, AD7417_CONFIG, &buf); + adc741x_config = (uint8_t)buf; + + /* Disable shutdown mode */ + adc741x_config &= 0xfe; + buf = adc741x_config; + ad7417_write(dev, addr, AD7417_CONFIG, &buf, 1); + + return (0); + +} +static int +ad7417_probe(device_t dev) +{ + const char *name, *compatible; + struct ad7417_softc *sc; + + name = ofw_bus_get_name(dev); + compatible = ofw_bus_get_compat(dev); + + if (!name) + return (ENXIO); + + if (strcmp(name, "supply-monitor") != 0 || + strcmp(compatible, "ad7417") != 0) + return (ENXIO); + + sc = device_get_softc(dev); + sc->sc_dev = dev; + sc->sc_addr = iicbus_get_addr(dev); + + device_set_desc(dev, "Supply-Monitor AD7417"); + + return (0); +} + +/* + * This function returns the number of sensors. If we call it the second time + * and we have allocated memory for sc->sc_sensors, we fill in the properties. + */ +static int +ad7417_fill_sensor_prop(device_t dev) +{ + phandle_t child; + struct ad7417_softc *sc; + u_int id[10]; + char location[96]; + char type[32]; + int i = 0, j, len = 0, prop_len, prev_len = 0; + + sc = device_get_softc(dev); + + child = ofw_bus_get_node(dev); + + /* Fill the sensor location property. */ + prop_len = OF_getprop(child, "hwsensor-location", location, + sizeof(location)); + while (len < prop_len) { + if (sc->sc_sensors != NULL) + strcpy(sc->sc_sensors[i].location, location + len); + prev_len = strlen(location + len) + 1; + len += prev_len; + i++; + } + if (sc->sc_sensors == NULL) + return (i); + + /* Fill the fan type property. */ + len = 0; + i = 0; + prev_len = 0; + prop_len = OF_getprop(child, "hwsensor-type", type, sizeof(type)); + while (len < prop_len) { + if (strcmp(type + len, "temperature") == 0) + sc->sc_sensors[i].type = ADC7417_TEMP_SENSOR; + else + sc->sc_sensors[i].type = ADC7417_ADC_SENSOR; + prev_len = strlen(type + len) + 1; + len += prev_len; + i++; + } + + /* Fill the sensor id property. Taken from OF. */ + prop_len = OF_getprop(child, "hwsensor-id", id, sizeof(id)); + for (j = 0; j < i; j++) + sc->sc_sensors[j].id = id[j]; + + return (i); +} + +static int +ad7417_attach(device_t dev) +{ + struct ad7417_softc *sc; + struct sysctl_oid *oid, *sensroot_oid; + struct sysctl_ctx_list *ctx; + char sysctl_name[32]; + int i, j; + const char *unit; + const char *desc; + + sc = device_get_softc(dev); + + sc->sc_nsensors = 0; + + /* Count the actual number of sensors. */ + sc->sc_nsensors = ad7417_fill_sensor_prop(dev); + + device_printf(dev, "%d sensors detected.\n", sc->sc_nsensors); + + if (sc->sc_nsensors == 0) + device_printf(dev, "WARNING: No AD7417 sensors detected!\n"); + + sc->sc_sensors = malloc (sc->sc_nsensors * sizeof(struct ad7417_sensor), + M_AD7417, M_WAITOK | M_ZERO); + + ctx = device_get_sysctl_ctx(dev); + sensroot_oid = SYSCTL_ADD_NODE(ctx, + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, "sensor", + CTLFLAG_RD, 0, "AD7417 Sensor Information"); + + /* Now we can fill the properties into the allocated struct. */ + sc->sc_nsensors = ad7417_fill_sensor_prop(dev); + + /* Add sysctls for the sensors. */ + for (i = 0; i < sc->sc_nsensors; i++) { + for (j = 0; j < strlen(sc->sc_sensors[i].location); j++) { + sysctl_name[j] = tolower(sc->sc_sensors[i].location[j]); + if (isspace(sysctl_name[j])) + sysctl_name[j] = '_'; + } + sysctl_name[j] = 0; + + oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid), + OID_AUTO, + sysctl_name, CTLFLAG_RD, 0, + "Sensor Information"); + + if (sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR) { + unit = "temp"; + desc = "Sensor temp in C"; + } else { + unit = "volt"; + desc = "Sensor Volt in V"; + } + /* I use i to pass the sensor id. */ + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, + unit, CTLTYPE_INT | CTLFLAG_RD, dev, + i, ad7417_sensor_sysctl, + sc->sc_sensors[i].type == ADC7417_TEMP_SENSOR ? + "IK" : "I", desc); + } + /* Dump sensor location, ID & type. */ + if (bootverbose) { + device_printf(dev, "Sensors\n"); + for (i = 0; i < sc->sc_nsensors; i++) { + device_printf(dev, "Location: %s ID: %d type: %d\n", + sc->sc_sensors[i].location, + sc->sc_sensors[i].id, + sc->sc_sensors[i].type); + } + } + + return (0); +} + +static int +ad7417_get_temp(device_t dev, uint32_t addr, int *temp) +{ + uint16_t buf[2]; + uint16_t read; + + ad7417_read_2(dev, addr, AD7417_TEMP, buf); + read = *((int16_t*)buf); + + /* The ADC is 10 bit, the resolution is 0.25 C. + The temperature is in tenth kelvin. + */ + *temp = (((int16_t)(read & 0xffc0)) >> 6) * 25 / 10; + return (0); +} + +static int +ad7417_get_adc(device_t dev, uint32_t addr, unsigned int *value, + uint8_t chan) +{ + uint8_t cfg1, tmp; + uint16_t read, buf[2]; + + ad7417_read_1(dev, addr, AD7417_CONFIG, &cfg1); + + tmp = chan << 5; + + cfg1 = (cfg1 & ~AD7417_CONFMASK) | (tmp & AD7417_CONFMASK); + + ad7417_write(dev, addr, AD7417_CONFIG, &cfg1, 1); + + ad7417_read_2(dev, addr, AD7417_ADC, buf); + + read = *((uint16_t*)buf); + + *value = ((uint32_t)read) >> 6; + + return (0); +} + +static int +ad7417_sensor_read(device_t dev, struct ad7417_sensor *sens, int *temp) +{ + struct ad7417_softc *sc; + + sc = device_get_softc(dev); + + /* Init the ADC. */ + ad7417_init_adc(sc->sc_dev, sc->sc_addr); + + if (sens->type == ADC7417_TEMP_SENSOR) { + ad7417_get_temp(sc->sc_dev, sc->sc_addr, temp); + *temp += FCU_ZERO_C_TO_K; + } else { + uint8_t chan; + switch (sens->id) { + case 11: + case 16: + chan = 1; + break; + case 12: + case 17: + chan = 2; + break; + case 13: + case 18: + chan = 3; + break; + case 14: + case 19: + chan = 4; + break; + default: + chan = 1; + } + + ad7417_get_adc(sc->sc_dev, sc->sc_addr, temp, chan); + } + return (0); +} + +static int +ad7417_sensor_sysctl(SYSCTL_HANDLER_ARGS) +{ + device_t dev; + struct ad7417_softc *sc; + struct ad7417_sensor *sens; + int value = 0; + int error; + int temp; + + dev = arg1; + sc = device_get_softc(dev); + sens = &sc->sc_sensors[arg2]; + + error = ad7417_sensor_read(dev, sens, &value); + if (error != 0) + return (error); + + temp = value; + + error = sysctl_handle_int(oidp, &temp, 0, req); + + return (error); +} diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 54a050f2a39a..3334fc2c8ad0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1845,10 +1845,16 @@ soreceive_generic(struct socket *so, struct sockaddr **psa, struct uio *uio, } SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv); - error = sbwait(&so->so_rcv); - if (error) { - SOCKBUF_UNLOCK(&so->so_rcv); - goto release; + /* + * We could receive some data while was notifying + * the protocol. Skip blocking in this case. + */ + if (so->so_rcv.sb_mb == NULL) { + error = sbwait(&so->so_rcv); + if (error) { + SOCKBUF_UNLOCK(&so->so_rcv); + goto release; + } } m = so->so_rcv.sb_mb; if (m != NULL) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 684d808b9a8e..7ae8477cd101 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -548,7 +548,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, * is the same as before, then the call is * un-necessarily executed here. */ - in_ifscrub(ifp, ia, 0); + in_ifscrub(ifp, ia, LLE_STATIC); ia->ia_sockmask = ifra->ifra_mask; ia->ia_sockmask.sin_family = AF_INET; ia->ia_subnetmask = @@ -557,7 +557,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, } if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sin_family == AF_INET)) { - in_ifscrub(ifp, ia, 0); + in_ifscrub(ifp, ia, LLE_STATIC); ia->ia_dstaddr = ifra->ifra_dstaddr; maskIsNew = 1; /* We lie; but the effect's the same */ } @@ -1179,14 +1179,20 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) && (ia->ia_ifp->if_type != IFT_CARP)) { ifa_ref(&ia->ia_ifa); IN_IFADDR_RUNLOCK(); - rtinit(&(target->ia_ifa), (int)RTM_DELETE, + error = rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target)); - target->ia_flags &= ~IFA_ROUTE; - + if (error == 0) + target->ia_flags &= ~IFA_ROUTE; + else + log(LOG_INFO, "in_scrubprefix: err=%d, old prefix delete failed\n", + error); error = rtinit(&ia->ia_ifa, (int)RTM_ADD, rtinitflags(ia) | RTF_UP); if (error == 0) ia->ia_flags |= IFA_ROUTE; + else + log(LOG_INFO, "in_scrubprefix: err=%d, new prefix add failed\n", + error); ifa_free(&ia->ia_ifa); return (error); } @@ -1210,9 +1216,12 @@ in_scrubprefix(struct in_ifaddr *target, u_int flags) /* * As no-one seem to have this prefix, we can remove the route. */ - rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target)); - target->ia_flags &= ~IFA_ROUTE; - return (0); + error = rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target)); + if (error == 0) + target->ia_flags &= ~IFA_ROUTE; + else + log(LOG_INFO, "in_scrubprefix: err=%d, prefix delete failed\n", error); + return (error); } #undef rtinitflags diff --git a/sys/powerpc/conf/GENERIC b/sys/powerpc/conf/GENERIC index d221a9727cc1..af4b19a113a3 100644 --- a/sys/powerpc/conf/GENERIC +++ b/sys/powerpc/conf/GENERIC @@ -174,6 +174,7 @@ device sbp # SCSI over FireWire (Requires scbus and da) device fwe # Ethernet over FireWire (non-standard!) # Misc +device ad7417 # PowerMac7,2 temperature sensor device ds1775 # PowerMac7,2 temperature sensor device fcu # Apple Fan Control Unit device max6690 # PowerMac7,2 temperature sensor diff --git a/sys/powerpc/conf/GENERIC64 b/sys/powerpc/conf/GENERIC64 index d7526b3d8000..ab4a0dcbc994 100644 --- a/sys/powerpc/conf/GENERIC64 +++ b/sys/powerpc/conf/GENERIC64 @@ -175,6 +175,7 @@ device sbp # SCSI over FireWire (Requires scbus and da) device fwe # Ethernet over FireWire (non-standard!) # Misc +device ad7417 # PowerMac7,2 temperature sensor device ds1775 # PowerMac7,2 temperature sensor device fcu # Apple Fan Control Unit device max6690 # PowerMac7,2 temperature sensor diff --git a/sys/powerpc/conf/NOTES b/sys/powerpc/conf/NOTES index b80a8173895a..374106df1682 100644 --- a/sys/powerpc/conf/NOTES +++ b/sys/powerpc/conf/NOTES @@ -39,6 +39,7 @@ device kiic # Apple Keywest I2C Controller device ofwd # Open Firmware disks device adb # Apple Desktop Bus device cuda # VIA-CUDA ADB interface +device ad7417 # PowerMac7,2 temperature sensor device ds1775 # PowerMac7,2 temperature sensor device fcu # Apple Fan Control Unit device max6690 # PowerMac7,2 temperature sensor diff --git a/tools/regression/bin/sh/builtins/set1.0 b/tools/regression/bin/sh/builtins/set1.0 new file mode 100644 index 000000000000..0043f45aedd5 --- /dev/null +++ b/tools/regression/bin/sh/builtins/set1.0 @@ -0,0 +1,32 @@ +# $FreeBSD: projects/largeSMP/tools/regression/bin/sh/builtins/set1.0 222451 2011-05-29 15:02:10Z jilles $ + +set +C +set +f +set -e + +settings=$(set +o) +set -C +set -f +set +e +case $- in +*C*) ;; +*) echo missing C ;; +esac +case $- in +*f*) ;; +*) echo missing C ;; +esac +case $- in +*e*) echo bad e ;; +esac +eval "$settings" +case $- in +*C*) echo bad C ;; +esac +case $- in +*f*) echo bad f ;; +esac +case $- in +*e*) ;; +*) echo missing e ;; +esac From 066c7ac96c87ad7070c7f2469bab58ef10a9f636 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 31 May 2011 20:23:33 +0000 Subject: [PATCH 074/164] Revert a change that crept in during MFC. --- sys/conf/NOTES | 7 ++--- sys/kern/kern_cpuset.c | 36 ----------------------- sys/kern/kern_ktr.c | 61 +++++++-------------------------------- sys/sparc64/include/ktr.h | 2 -- sys/sys/cpuset.h | 1 - sys/sys/ktr.h | 5 +--- 6 files changed, 13 insertions(+), 99 deletions(-) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index b84d0c535b14..94311c61cfda 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -432,10 +432,7 @@ options KTRACE_REQUEST_POOL=101 # defined by the KTR_* constants in . KTR_MASK defines the # initial value of the ktr_mask variable which determines at runtime # what events to trace. KTR_CPUMASK determines which CPU's log -# events, with bit X corresponding to CPU X. The layout of the string -# passed as KTR_CPUMASK must match a serie of bitmasks each of them -# separated by the ", " characters (ie: -# KTR_CPUMASK=("0xAF, 0xFFFFFFFFFFFFFFFF")). KTR_VERBOSE enables +# events, with bit X corresponding to CPU X. KTR_VERBOSE enables # dumping of KTR events to the console by default. This functionality # can be toggled via the debug.ktr_verbose sysctl and defaults to off # if KTR_VERBOSE is not defined. See ktr(4) and ktrdump(8) for details. @@ -444,7 +441,7 @@ options KTR options KTR_ENTRIES=1024 options KTR_COMPILE=(KTR_INTR|KTR_PROC) options KTR_MASK=KTR_INTR -options KTR_CPUMASK=("0x3") +options KTR_CPUMASK=0x3 options KTR_VERBOSE # diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 5ca3be2b5597..3b2c653de9ef 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -660,41 +659,6 @@ cpusetobj_strprint(char *buf, const cpuset_t *set) return (buf); } -/* - * Build a valid cpuset_t object from a string representation. - * It expects an incoming buffer at least sized as CPUSETBUFSIZ. - */ -int -cpusetobj_strscan(cpuset_t *set, const char *buf) -{ - u_int nwords; - int i; - - if (strlen(buf) > CPUSETBUFSIZ - 1) - return (-1); - - /* Allow to pass a shorter version of the mask when necessary. */ - nwords = 1; - for (i = 0; buf[i] != '\0'; i++) - if (buf[i] == ',') - nwords++; - if (nwords > _NCPUWORDS) - return (-1); - - CPU_ZERO(set); - for (i = nwords - 1; i > 0; i--) { - if (!sscanf(buf, "%lx, ", &set->__bits[i])) - return (-1); - buf = strstr(buf, " "); - if (buf == NULL) - return (-1); - buf++; - } - if (!sscanf(buf, "%lx", &set->__bits[0])) - return (-1); - return (0); -} - /* * Apply an anonymous mask to a single thread. */ diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 3a91dd6545ce..2e5e06f671b2 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -40,10 +40,8 @@ __FBSDID("$FreeBSD$"); #include "opt_alq.h" #include -#include #include #include -#include #include #include #include @@ -70,6 +68,10 @@ __FBSDID("$FreeBSD$"); #define KTR_MASK (0) #endif +#ifndef KTR_CPUMASK +#define KTR_CPUMASK (~0) +#endif + #ifndef KTR_TIME #define KTR_TIME get_cyclecount() #endif @@ -82,6 +84,11 @@ FEATURE(ktr, "Kernel support for KTR kernel tracing facility"); SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); +int ktr_cpumask = KTR_CPUMASK; +TUNABLE_INT("debug.ktr.cpumask", &ktr_cpumask); +SYSCTL_INT(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, + &ktr_cpumask, 0, "Bitmask of CPUs on which KTR logging is enabled"); + int ktr_mask = KTR_MASK; TUNABLE_INT("debug.ktr.mask", &ktr_mask); SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RW, @@ -99,54 +106,6 @@ int ktr_version = KTR_VERSION; SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, "Version of the KTR interface"); -cpuset_t ktr_cpumask; -static char ktr_cpumask_str[CPUSETBUFSIZ]; -TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str)); - -static void -ktr_cpumask_initializer(void *dummy __unused) -{ - - CPU_FILL(&ktr_cpumask); -#ifdef KTR_CPUMASK - if (cpusetobj_strscan(&ktr_cpumask, KTR_CPUMASK) == -1) - CPU_FILL(&ktr_cpumask); -#endif - - /* - * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be - * already set, if necessary. - */ - if (ktr_cpumask_str[0] != '\0' && - cpusetobj_strscan(&ktr_cpumask, ktr_cpumask_str) == -1) - CPU_FILL(&ktr_cpumask); -} -SYSINIT(ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, - ktr_cpumask_initializer, NULL); - -static int -sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) -{ - char lktr_cpumask_str[CPUSETBUFSIZ]; - cpuset_t imask; - int error; - - memset(lktr_cpumask_str, 0, sizeof(lktr_cpumask_str)); - error = sysctl_handle_string(oidp, lktr_cpumask_str, - sizeof(lktr_cpumask_str), req); - if (error != 0 || req->newptr == NULL) - return (error); - if (cpusetobj_strscan(&imask, lktr_cpumask_str) == -1) - return (EINVAL); - CPU_COPY(&imask, &ktr_cpumask); - - return (error); -} -SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask, - CTLFLAG_RW | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, - sysctl_debug_ktr_cpumask, "S", - "Bitmask of CPUs on which KTR logging is enabled"); - volatile int ktr_idx = 0; struct ktr_entry ktr_buf[KTR_ENTRIES]; @@ -254,7 +213,7 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, if ((ktr_mask & mask) == 0) return; cpu = KTR_CPU; - if (!CPU_ISSET(cpu, &ktr_cpumask)) + if (((1 << cpu) & ktr_cpumask) == 0) return; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td = curthread; diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h index 2a9966b7ce9c..5948ba29fb3e 100644 --- a/sys/sparc64/include/ktr.h +++ b/sys/sparc64/include/ktr.h @@ -85,9 +85,7 @@ l2: add r2, 1, r3 ; \ lduw [PCPU(MID)], r1 ; \ mov 1, r2 ; \ sllx r2, r1, r1 ; \ -#ifdef notyet \ TEST(ktr_cpumask, r1, r2, r3, l3) ; \ -#endif \ ATR(desc, r1, r2, r3, l1, l2) #endif /* LOCORE */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 030a874bf7d4..45252638e15a 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -214,7 +214,6 @@ int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); int cpusetobj_ffs(const cpuset_t *); char *cpusetobj_strprint(char *, const cpuset_t *); -int cpusetobj_strscan(cpuset_t *, const char *); #else __BEGIN_DECLS diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 7885b22f4aee..3b78101dd1b4 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -97,9 +97,6 @@ #ifndef LOCORE -#include -#include - struct ktr_entry { u_int64_t ktr_timestamp; int ktr_cpu; @@ -110,7 +107,7 @@ struct ktr_entry { u_long ktr_parms[KTR_PARMS]; }; -extern cpuset_t ktr_cpumask; +extern int ktr_cpumask; extern int ktr_mask; extern int ktr_entries; extern int ktr_verbose; From a924571ff72281d66b56beff01ea2b9ed8de6961 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 31 May 2011 20:48:58 +0000 Subject: [PATCH 075/164] Fix KTR_CPUMASK in order to accept a string representing a cpuset_t. This introduce all the underlying support for making this possible (via the function cpusetobj_strscan() and keeps ktr_cpumask exported. sparc64 implements its own assembly primitives for tracing events and needs to properly check it. Anyway the sparc64 logic is not implemented yet due to lack of knowledge (by me) and time (by marius), but it is just a matter of using ktr_cpumask when possible. Tested and fixed by: pluknet Reviewed by: marius --- sys/conf/NOTES | 7 +++-- sys/kern/kern_cpuset.c | 38 ++++++++++++++++++++++++ sys/kern/kern_ktr.c | 61 ++++++++++++++++++++++++++++++++------- sys/sparc64/include/ktr.h | 2 ++ sys/sys/cpuset.h | 1 + sys/sys/ktr.h | 5 +++- 6 files changed, 101 insertions(+), 13 deletions(-) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 94311c61cfda..b84d0c535b14 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -432,7 +432,10 @@ options KTRACE_REQUEST_POOL=101 # defined by the KTR_* constants in . KTR_MASK defines the # initial value of the ktr_mask variable which determines at runtime # what events to trace. KTR_CPUMASK determines which CPU's log -# events, with bit X corresponding to CPU X. KTR_VERBOSE enables +# events, with bit X corresponding to CPU X. The layout of the string +# passed as KTR_CPUMASK must match a serie of bitmasks each of them +# separated by the ", " characters (ie: +# KTR_CPUMASK=("0xAF, 0xFFFFFFFFFFFFFFFF")). KTR_VERBOSE enables # dumping of KTR events to the console by default. This functionality # can be toggled via the debug.ktr_verbose sysctl and defaults to off # if KTR_VERBOSE is not defined. See ktr(4) and ktrdump(8) for details. @@ -441,7 +444,7 @@ options KTR options KTR_ENTRIES=1024 options KTR_COMPILE=(KTR_INTR|KTR_PROC) options KTR_MASK=KTR_INTR -options KTR_CPUMASK=0x3 +options KTR_CPUMASK=("0x3") options KTR_VERBOSE # diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c index 3b2c653de9ef..e1f2801643ac 100644 --- a/sys/kern/kern_cpuset.c +++ b/sys/kern/kern_cpuset.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -659,6 +660,43 @@ cpusetobj_strprint(char *buf, const cpuset_t *set) return (buf); } +/* + * Build a valid cpuset_t object from a string representation. + * It expects an incoming buffer at least sized as CPUSETBUFSIZ. + */ +int +cpusetobj_strscan(cpuset_t *set, const char *buf) +{ + u_int nwords; + int i, ret; + + if (strlen(buf) > CPUSETBUFSIZ - 1) + return (-1); + + /* Allow to pass a shorter version of the mask when necessary. */ + nwords = 1; + for (i = 0; buf[i] != '\0'; i++) + if (buf[i] == ',') + nwords++; + if (nwords > _NCPUWORDS) + return (-1); + + CPU_ZERO(set); + for (i = nwords - 1; i > 0; i--) { + ret = sscanf(buf, "%lx, ", &set->__bits[i]); + if (ret == 0 || ret == -1) + return (-1); + buf = strstr(buf, " "); + if (buf == NULL) + return (-1); + buf++; + } + ret = sscanf(buf, "%lx", &set->__bits[0]); + if (ret == 0 || ret == -1) + return (-1); + return (0); +} + /* * Apply an anonymous mask to a single thread. */ diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 2e5e06f671b2..eff3d5bd68ab 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -40,8 +40,10 @@ __FBSDID("$FreeBSD$"); #include "opt_alq.h" #include +#include #include #include +#include #include #include #include @@ -68,10 +70,6 @@ __FBSDID("$FreeBSD$"); #define KTR_MASK (0) #endif -#ifndef KTR_CPUMASK -#define KTR_CPUMASK (~0) -#endif - #ifndef KTR_TIME #define KTR_TIME get_cyclecount() #endif @@ -84,11 +82,6 @@ FEATURE(ktr, "Kernel support for KTR kernel tracing facility"); SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); -int ktr_cpumask = KTR_CPUMASK; -TUNABLE_INT("debug.ktr.cpumask", &ktr_cpumask); -SYSCTL_INT(_debug_ktr, OID_AUTO, cpumask, CTLFLAG_RW, - &ktr_cpumask, 0, "Bitmask of CPUs on which KTR logging is enabled"); - int ktr_mask = KTR_MASK; TUNABLE_INT("debug.ktr.mask", &ktr_mask); SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RW, @@ -106,6 +99,54 @@ int ktr_version = KTR_VERSION; SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, "Version of the KTR interface"); +cpuset_t ktr_cpumask; +static char ktr_cpumask_str[CPUSETBUFSIZ]; +TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str)); + +static void +ktr_cpumask_initializer(void *dummy __unused) +{ + + CPU_FILL(&ktr_cpumask); +#ifdef KTR_CPUMASK + if (cpusetobj_strscan(&ktr_cpumask, KTR_CPUMASK) == -1) + CPU_FILL(&ktr_cpumask); +#endif + + /* + * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be + * already set, if necessary. + */ + if (ktr_cpumask_str[0] != '\0' && + cpusetobj_strscan(&ktr_cpumask, ktr_cpumask_str) == -1) + CPU_FILL(&ktr_cpumask); +} +SYSINIT(ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, + ktr_cpumask_initializer, NULL); + +static int +sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) +{ + char lktr_cpumask_str[CPUSETBUFSIZ]; + cpuset_t imask; + int error; + + cpusetobj_strprint(lktr_cpumask_str, &ktr_cpumask); + error = sysctl_handle_string(oidp, lktr_cpumask_str, + sizeof(lktr_cpumask_str), req); + if (error != 0 || req->newptr == NULL) + return (error); + if (cpusetobj_strscan(&imask, lktr_cpumask_str) == -1) + return (EINVAL); + CPU_COPY(&imask, &ktr_cpumask); + + return (error); +} +SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask, + CTLFLAG_RW | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, + sysctl_debug_ktr_cpumask, "S", + "Bitmask of CPUs on which KTR logging is enabled"); + volatile int ktr_idx = 0; struct ktr_entry ktr_buf[KTR_ENTRIES]; @@ -213,7 +254,7 @@ ktr_tracepoint(u_int mask, const char *file, int line, const char *format, if ((ktr_mask & mask) == 0) return; cpu = KTR_CPU; - if (((1 << cpu) & ktr_cpumask) == 0) + if (!CPU_ISSET(cpu, &ktr_cpumask)) return; #if defined(KTR_VERBOSE) || defined(KTR_ALQ) td = curthread; diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h index 5948ba29fb3e..2a9966b7ce9c 100644 --- a/sys/sparc64/include/ktr.h +++ b/sys/sparc64/include/ktr.h @@ -85,7 +85,9 @@ l2: add r2, 1, r3 ; \ lduw [PCPU(MID)], r1 ; \ mov 1, r2 ; \ sllx r2, r1, r1 ; \ +#ifdef notyet \ TEST(ktr_cpumask, r1, r2, r3, l3) ; \ +#endif \ ATR(desc, r1, r2, r3, l1, l2) #endif /* LOCORE */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 45252638e15a..030a874bf7d4 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -214,6 +214,7 @@ int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); int cpusetobj_ffs(const cpuset_t *); char *cpusetobj_strprint(char *, const cpuset_t *); +int cpusetobj_strscan(cpuset_t *, const char *); #else __BEGIN_DECLS diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index 3b78101dd1b4..7885b22f4aee 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -97,6 +97,9 @@ #ifndef LOCORE +#include +#include + struct ktr_entry { u_int64_t ktr_timestamp; int ktr_cpu; @@ -107,7 +110,7 @@ struct ktr_entry { u_long ktr_parms[KTR_PARMS]; }; -extern int ktr_cpumask; +extern cpuset_t ktr_cpumask; extern int ktr_mask; extern int ktr_entries; extern int ktr_verbose; From 27825059cd2a1ad6c708ee2089f7e182c12e84b1 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 31 May 2011 20:59:53 +0000 Subject: [PATCH 076/164] Revert r222363, as bde@ pointed out the initial solution was far more correct. --- gnu/usr.bin/gdb/kgdb/kthr.c | 2 +- lib/libkvm/kvm_pcpu.c | 2 +- lib/libmemstat/memstat_uma.c | 2 +- usr.sbin/pmccontrol/pmccontrol.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index 7b39929fa55a..461f408a73d9 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -107,7 +107,7 @@ kgdb_thr_init(void) addr = kgdb_lookup("stopped_cpus"); CPU_ZERO(&stopped_cpus); cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize != -1 && (size_t)cpusetsize <= sizeof(cpuset_t) && + if (cpusetsize != -1 && (u_long)cpusetsize <= sizeof(cpuset_t) && addr != 0) kvm_read(kvm, addr, &stopped_cpus, cpusetsize); diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c index 7e421aeb893c..bc73baff19cc 100644 --- a/lib/libkvm/kvm_pcpu.c +++ b/lib/libkvm/kvm_pcpu.c @@ -131,7 +131,7 @@ kvm_getpcpu(kvm_t *kd, int cpu) } kcpusetsize = sysconf(_SC_CPUSET_SIZE); - if (kcpusetsize == -1 || (size_t)kcpusetsize > sizeof(cpuset_t)) + if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) return ((void *)-1); if (maxcpu == 0) diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index b9bde7d4179c..485a4f279906 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -341,7 +341,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) return (-1); } cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize == -1 || (size_t)cpusetsize > sizeof(cpuset_t)) { + if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL; return (-1); } diff --git a/usr.sbin/pmccontrol/pmccontrol.c b/usr.sbin/pmccontrol/pmccontrol.c index 28f7ab493363..80d4bd7c3dde 100644 --- a/usr.sbin/pmccontrol/pmccontrol.c +++ b/usr.sbin/pmccontrol/pmccontrol.c @@ -148,7 +148,7 @@ pmcc_do_enable_disable(struct pmcc_op_list *op_list) /* Determine the set of active CPUs. */ cpusetsize = sysconf(_SC_CPUSET_SIZE); - if (cpusetsize == -1 || (size_t)cpusetsize > sizeof(cpuset_t)) { + if (cpusetsize == -1 || (u_long)cpusetsize > sizeof(cpuset_t)) { err(EX_OSERR, "ERROR: Cannot determine which CPUs are " "halted"); } From bc4d32e80bd81ea96c4c2544ab36f7e8caa777b7 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 31 May 2011 21:22:44 +0000 Subject: [PATCH 077/164] MFC --- contrib/top/commands.c | 1 + contrib/top/machine.h | 1 + contrib/top/top.X | 22 +- contrib/top/top.c | 24 +- sbin/ifconfig/Makefile | 12 + sbin/ifconfig/af_inet.c | 2 + sbin/ifconfig/af_inet6.c | 3 + sbin/ifconfig/af_nd6.c | 4 + sbin/ifconfig/ifconfig.8 | 10 +- sbin/ifconfig/ifconfig.c | 27 +- sbin/umount/umount.8 | 5 +- sys/contrib/dev/acpica/changes.txt | 129 +++++- sys/contrib/dev/acpica/debugger/dbexec.c | 407 +++++++++++++++++- sys/contrib/dev/acpica/debugger/dbinput.c | 112 ++++- sys/contrib/dev/acpica/debugger/dbutils.c | 7 +- sys/contrib/dev/acpica/debugger/dbxface.c | 8 +- sys/contrib/dev/acpica/include/acconfig.h | 3 +- sys/contrib/dev/acpica/include/acdebug.h | 7 + sys/contrib/dev/acpica/include/acglobal.h | 9 +- sys/contrib/dev/acpica/include/aclocal.h | 2 + sys/contrib/dev/acpica/include/acpiosxf.h | 6 +- sys/contrib/dev/acpica/include/acpixf.h | 2 +- sys/contrib/dev/acpica/include/acpredef.h | 1 + sys/contrib/dev/acpica/osunixxf.c | 24 +- sys/contrib/dev/acpica/tables/tbinstal.c | 26 +- sys/contrib/pf/net/pf.c | 8 + sys/contrib/pf/net/pf_ioctl.c | 5 +- sys/contrib/pf/net/pf_norm.c | 2 + sys/dev/acpica/Osd/OsdDebug.c | 23 +- sys/dev/ipw/if_ipw.c | 2 + sys/dev/iwi/if_iwi.c | 2 + sys/dev/iwn/if_iwn.c | 2 + sys/dev/nfe/if_nfe.c | 2 +- sys/dev/wpi/if_wpi.c | 2 + sys/fs/nfsclient/nfs_clvnops.c | 13 +- sys/i386/pci/pci_cfgreg.c | 2 +- sys/ia64/ia64/machdep.c | 2 +- sys/ia64/ia64/mp_machdep.c | 8 +- sys/ia64/ia64/pmap.c | 2 +- sys/kern/kern_idle.c | 2 +- sys/kern/sched_4bsd.c | 4 +- sys/kern/subr_kdb.c | 2 +- sys/kern/subr_msgbuf.c | 187 +++++++- sys/kern/subr_pcpu.c | 6 +- sys/kern/subr_prf.c | 157 +++++-- sys/mips/mips/mp_machdep.c | 2 +- sys/net/netisr.c | 2 +- sys/powerpc/booke/pmap.c | 4 +- sys/powerpc/powerpc/mp_machdep.c | 6 +- sys/sparc64/sparc64/mp_machdep.c | 2 +- sys/sparc64/sparc64/pmap.c | 2 +- sys/sys/msgbuf.h | 21 +- sys/sys/pcpu.h | 4 +- tools/tools/nanobsd/nanobsd.sh | 2 +- usr.bin/tftp/main.c | 6 +- usr.bin/top/machine.c | 7 + usr.bin/top/top.local.1 | 4 - .../pc-sysinstall/backend-query/enable-net.sh | 57 ++- .../pc-sysinstall/backend-query/test-netup.sh | 25 +- .../backend/functions-networking.sh | 195 ++++++++- 60 files changed, 1394 insertions(+), 232 deletions(-) diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 47f4a2ea05fb..7891068a2517 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -94,6 +94,7 @@ S - toggle the displaying of system processes\n\ a - toggle the displaying of process titles\n\ t - toggle the display of this process\n\ u - display processes for only one user (+ selects all users)\n\ +z - toggle the displaying of the system idle process\n\ \n\ \n", stdout); } diff --git a/contrib/top/machine.h b/contrib/top/machine.h index a09424c19ca2..3e1af1609ece 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -65,6 +65,7 @@ struct process_select int uid; /* only this uid (unless uid == -1) */ int wcpu; /* show weighted cpu */ int jail; /* show jail ID */ + int kidle; /* show per-CPU idle threads */ char *command; /* only this command (unless == NULL) */ }; diff --git a/contrib/top/top.X b/contrib/top/top.X index 830e50dd2346..41c3d78bd67a 100644 --- a/contrib/top/top.X +++ b/contrib/top/top.X @@ -10,7 +10,7 @@ top \- display and update information about the top cpu processes .SH SYNOPSIS .B top [ -.B \-abCHIijnPqStuv +.B \-abCHIijnPqStuvz ] [ .BI \-d count ] [ @@ -89,6 +89,10 @@ Use \*(lqbatch\*(rq mode. In this mode, all input from the terminal is ignored. Interrupt characters (such as ^C and ^\e) still have an effect. This is the default on a dumb terminal, or when the output is not a terminal. .TP +.B \-H +Display each thread for a multithreaded process individually. +By default a single summary line is displayed for each process. +.TP .B \-i Use \*(lqinteractive\*(rq mode. In this mode, any input is immediately read for processing. See the section on \*(lqInteractive Mode\*(rq @@ -142,6 +146,9 @@ Write version number information to stderr then exit immediately. No other processing takes place when this option is used. To see current revision information while top is running, use the help command \*(lq?\*(rq. .TP +.B \-z +Do not display the system idle process. +.TP .BI \-d count Show only .I count @@ -289,6 +296,9 @@ or .BR r enice command. .TP +.B H +Toggle the display of threads. +.TP .B i (or .BR I ) @@ -303,6 +313,9 @@ ID. Toggle the display of the .I top process. +.TP +.B z +Toggle the display of the system idle process. .SH "THE DISPLAY" The actual display varies depending on the specific variant of Unix that the machine is running. This description may not exactly match @@ -352,8 +365,11 @@ the order of the processes, and COMMAND is the name of the command that the process is currently running (if the process is swapped out, this column is marked \*(lq\*(rq). .SH NOTES -The \*(lqABANDONED\*(rq state (known in the kernel as \*(lqSWAIT\*(rq) was -abandoned, thus the name. A process should never end up in this state. +If a process is in the \*(lqSLEEP\*(rq or \*(lqLOCK\*(rq state, +the state column will report the name of the event or lock on which the +process is waiting. +Lock names are prefixed with an asterisk \*(lq*\*(rq while sleep events +are not. .SH AUTHOR William LeFebvre, EECS Department, Northwestern University .SH ENVIRONMENT diff --git a/contrib/top/top.c b/contrib/top/top.c index 762efaa2a723..6673a2768846 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -196,9 +196,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSCajo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajzo"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmSCaj"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCajz"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -224,8 +224,9 @@ char *argv[]; #define CMD_wcputog 19 #define CMD_showargs 20 #define CMD_jidtog 21 +#define CMD_kidletog 22 #ifdef ORDER -#define CMD_order 22 +#define CMD_order 23 #endif /* set the buffer for stdout */ @@ -258,6 +259,7 @@ char *argv[]; ps.thread = No; ps.wcpu = 1; ps.jail = No; + ps.kidle = Yes; ps.command = NULL; /* get preset options from the environment */ @@ -283,7 +285,7 @@ char *argv[]; optind = 1; } - while ((i = getopt(ac, av, "CSIHPabijnquvs:d:U:m:o:t")) != EOF) + while ((i = getopt(ac, av, "CSIHPabijnquvzs:d:U:m:o:t")) != EOF) { switch(i) { @@ -412,10 +414,14 @@ char *argv[]; pcpu_stats = Yes; break; + case 'z': + ps.kidle = !ps.kidle; + break; + default: fprintf(stderr, "Top version %s\n" -"Usage: %s [-abCHIijnPqStuv] [-d count] [-m io | cpu] [-o field] [-s time]\n" +"Usage: %s [-abCHIijnPqStuvz] [-d count] [-m io | cpu] [-o field] [-s time]\n" " [-U username] [number]\n", version_string(), myname); exit(1); @@ -1075,7 +1081,13 @@ char *argv[]; reset_display(); putchar('\r'); break; - + case CMD_kidletog: + ps.kidle = !ps.kidle; + new_message(MT_standout | MT_delayed, + " %sisplaying system idle process.", + ps.kidle ? "D" : "Not d"); + putchar('\r'); + break; default: new_message(MT_standout, " BAD CASE IN SWITCH!"); putchar('\r'); diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 77491f25207f..461de7100487 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -15,10 +15,16 @@ SRCS= ifconfig.c # base support # of the toolchain. # SRCS+= af_link.c # LLC support +.if ${MK_INET_SUPPORT} != "no" SRCS+= af_inet.c # IPv4 support +.endif +.if ${MK_INET6_SUPPORT} != "no" SRCS+= af_inet6.c # IPv6 support +.endif SRCS+= af_atalk.c # AppleTalk support +.if ${MK_INET6_SUPPORT} != "no" SRCS+= af_nd6.c # ND6 support +.endif SRCS+= ifclone.c # clone device support SRCS+= ifmac.c # MAC support @@ -38,6 +44,12 @@ SRCS+= ifpfsync.c # pfsync(4) support SRCS+= ifbridge.c # bridge support SRCS+= iflagg.c # lagg support +.if ${MK_INET6_SUPPORT} != "no" +CFLAGS+= -DINET6 +.endif +.if ${MK_INET_SUPPORT} != "no" +CFLAGS+= -DINET +.endif .if ${MK_IPX_SUPPORT} != "no" && !defined(RELEASE_CRUNCH) SRCS+= af_ipx.c # IPX support DPADD+= ${LIBIPX} diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c index 2e27114af13a..6b4d73576382 100644 --- a/sbin/ifconfig/af_inet.c +++ b/sbin/ifconfig/af_inet.c @@ -200,5 +200,7 @@ static struct afswtch af_inet = { static __constructor void inet_ctor(void) { + if (!feature_present("inet")) + return; af_register(&af_inet); } diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index 8fc143a5571d..2337c345647c 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -541,6 +541,9 @@ inet6_ctor(void) #define N(a) (sizeof(a) / sizeof(a[0])) size_t i; + if (!feature_present("inet6")) + return; + for (i = 0; i < N(inet6_cmds); i++) cmd_register(&inet6_cmds[i]); af_register(&af_inet6); diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c index e6b920af7bd4..5260c505c0d3 100644 --- a/sbin/ifconfig/af_nd6.c +++ b/sbin/ifconfig/af_nd6.c @@ -225,5 +225,9 @@ static struct afswtch af_nd6 = { static __constructor void nd6_ctor(void) { + + if (!feature_present("inet6")) + return; + af_register(&af_nd6); } diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index e28178a4b16b..45cf59b68919 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -28,7 +28,7 @@ .\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94 .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd May 31, 2011 .Dt IFCONFIG 8 .Os .Sh NAME @@ -42,7 +42,7 @@ .Op Fl n .Ar interface .Op Cm create -.Op Ar address_family +.Ar address_family .Oo .Ar address .Op Ar dest_address @@ -165,8 +165,10 @@ and .Dq link . .\" and .\" .Dq ns . -The default is -.Dq inet . +The default if available is +.Dq inet +or otherwise +.Dq link . .Dq ether and .Dq lladdr diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 7c5d3519f224..2963b9f092df 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -220,8 +220,10 @@ main(int argc, char *argv[]) ifindex = 0; if (argc == 1) { afp = af_getbyname(*argv); - if (afp == NULL) + if (afp == NULL) { + warnx("Address family '%s' unknown.", *argv); usage(); + } if (afp->af_name != NULL) argc--, argv++; /* leave with afp non-zero */ @@ -484,7 +486,28 @@ ifconfig(int argc, char *const *argv, int iscreate, const struct afswtch *uafp) int s; strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); - afp = uafp != NULL ? uafp : af_getbyname("inet"); + afp = NULL; + if (uafp != NULL) + afp = uafp; + /* + * This is the historical "accident" allowing users to configure IPv4 + * addresses without the "inet" keyword which while a nice feature has + * proven to complicate other things. We cannot remove this but only + * make sure we will never have a similar implicit default for IPv6 or + * any other address familiy. We need a fallback though for + * ifconfig IF up/down etc. to work without INET support as people + * never used ifconfig IF link up/down, etc. either. + */ +#ifdef INET + if (afp == NULL && feature_present("inet")) + afp = af_getbyname("inet"); +#endif + if (afp == NULL) + afp = af_getbyname("link"); + if (afp == NULL) { + warnx("Please specify an address_family."); + usage(); + } top: ifr.ifr_addr.sa_family = afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ? diff --git a/sbin/umount/umount.8 b/sbin/umount/umount.8 index 91231a78b38c..cb3a97b8ed23 100644 --- a/sbin/umount/umount.8 +++ b/sbin/umount/umount.8 @@ -28,7 +28,7 @@ .\" @(#)umount.8 8.2 (Berkeley) 5/8/95 .\" $FreeBSD$ .\" -.Dd July 18, 2003 +.Dd May 31, 2011 .Dt UMOUNT 8 .Os .Sh NAME @@ -78,6 +78,9 @@ The file system is forcibly unmounted. Active special devices continue to work, but all other files return errors if further accesses are attempted. The root file system cannot be forcibly unmounted. +For NFS, a forced dismount can take up to 1 minute or more to +complete against an unresponsive server and may throw away +data not yet written to the server for this case. .It Fl h Ar host Only file systems mounted from the specified host will be unmounted. diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt index 68dda91e7013..f53fd426da4a 100644 --- a/sys/contrib/dev/acpica/changes.txt +++ b/sys/contrib/dev/acpica/changes.txt @@ -1,31 +1,99 @@ +---------------------------------------- +27 May 2011. Summary of changes for version 20110527: + +This release is available at www.acpica.org/downloads + +1) ACPI CA Core Subsystem: + +ASL Load() operator: Reinstate most restrictions on the incoming ACPI table +signature. Now, only allow SSDT, OEMx, and a null signature. History: + 1) Originally, we checked the table signature for "SSDT" or "PSDT". + (PSDT is now obsolete.) + 2) We added support for OEMx tables, signature "OEM" plus a fourth + "don't care" character. + 3) Valid tables were encountered with a null signature, so we just + gave up on validating the signature, (05/2008). + 4) We encountered non-AML tables such as the MADT, which caused + interpreter errors and kernel faults. So now, we once again allow + only SSDT, OEMx, and now, also a null signature. (05/2011). + +Added the missing _TDL predefined name to the global name list in order to +enable validation. Affects both the core ACPICA code and the iASL compiler. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug +version of the code includes the debug output trace mechanism and has a much +larger code and data size. + + Previous Release (VC 9.0): + Non-Debug Version: 90.0K Code, 23.8K Data, 113.8K Total + Debug Version: 164.5K Code, 68.0K Data, 232.5K Total + Current Release (VC 9.0): + Non-Debug Version: 90.1K Code, 23.9K Data, 114.0K Total + Debug Version: 165.6K Code, 68.4K Data, 234.0K Total + +2) iASL Compiler/Disassembler and Tools: + +Debugger/AcpiExec: Implemented support for "complex" method arguments on the +debugger command line. This adds support beyond simple integers -- including +Strings, Buffers, and Packages. Includes support for nested packages. +Increased the default command line buffer size to accommodate these arguments. +See the ACPICA reference for details and syntax. ACPICA BZ 917. + +Debugger/AcpiExec: Implemented support for "default" method arguments for the +Execute/Debug command. Now, the debugger will always invoke a control method +with the required number of arguments -- even if the command line specifies +none or insufficient arguments. It uses default integer values for any missing +arguments. Also fixes a bug where only six method arguments maximum were +supported instead of the required seven. + +Debugger/AcpiExec: Add a maximum buffer length parameter to AcpiOsGetLine and +also return status in order to prevent buffer overruns. See the ACPICA +reference for details and syntax. ACPICA BZ 921 + +iASL: Cleaned up support for Berkeley yacc. A general cleanup of code and +makefiles to simplify support for the two different but similar parser +generators, bison and yacc. + +Updated the generic unix makefile for gcc 4. The default gcc version is now +expected to be 4 or greater, since options specific to gcc 4 are used. + ---------------------------------------- 13 April 2011. Summary of changes for version 20110413: 1) ACPI CA Core Subsystem: Implemented support to execute a so-called "orphan" _REG method under the EC -device. This change will force the execution of a _REG method underneath the EC +device. This change will force the execution of a _REG method underneath the +EC device even if there is no corresponding operation region of type EmbeddedControl. Fixes a problem seen on some machines and apparently is compatible with Windows behavior. ACPICA BZ 875. Added more predefined methods that are eligible for automatic NULL package -element removal. This change adds another group of predefined names to the list +element removal. This change adds another group of predefined names to the +list of names that can be repaired by having NULL package elements dynamically removed. This group are those methods that return a single variable-length package containing simple data types such as integers, buffers, strings. This -includes: _ALx, _BCL, _CID,_ DOD, _EDL, _FIX, _PCL, _PLD, _PMD, _PRx, _PSL, _Sx, +includes: _ALx, _BCL, _CID,_ DOD, _EDL, _FIX, _PCL, _PLD, _PMD, _PRx, _PSL, +_Sx, and _TZD. ACPICA BZ 914. -Split and segregated all internal global lock functions to a new file, evglock.c. +Split and segregated all internal global lock functions to a new file, +evglock.c. -Updated internal address SpaceID for DataTable regions. Moved this internal space -id in preparation for ACPI 5.0 changes that will include some new space IDs. This +Updated internal address SpaceID for DataTable regions. Moved this internal +space +id in preparation for ACPI 5.0 changes that will include some new space IDs. +This change should not affect user/host code. -Example Code and Data Size: These are the sizes for the OS-independent acpica.lib +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug version of -the code includes the debug output trace mechanism and has a much larger code and +the code includes the debug output trace mechanism and has a much larger code +and data size. Previous Release (VC 9.0): @@ -40,34 +108,44 @@ data size. iASL/DTC: Major update for new grammar features. Allow generic data types in custom ACPI tables. Field names are now optional. Any line can be split to multiple lines using the continuation char (\). Large buffers now use line- -continuation character(s) and no colon on the continuation lines. See the grammar +continuation character(s) and no colon on the continuation lines. See the +grammar update in the iASL compiler reference. ACPI BZ 910,911. Lin Ming, Bob Moore. iASL: Mark ASL "Return()" and the simple "Return" as "Null" return statements. -Since the parser stuffs a "zero" as the return value for these statements (due to +Since the parser stuffs a "zero" as the return value for these statements (due +to the underlying AML grammar), they were seen as "return with value" by the iASL semantic checking. They are now seen correctly as "null" return statements. iASL: Check if a_REG declaration has a corresponding Operation Region. Adds a check for each _REG to ensure that there is in fact a corresponding operation -region declaration in the same scope. If not, the _REG method is not very useful +region declaration in the same scope. If not, the _REG method is not very +useful since it probably won't be executed. ACPICA BZ 915. -iASL/DTC: Finish support for expression evaluation. Added a new expression parser -that implements c-style operator precedence and parenthesization. ACPICA bugzilla +iASL/DTC: Finish support for expression evaluation. Added a new expression +parser +that implements c-style operator precedence and parenthesization. ACPICA +bugzilla 908. -Disassembler/DTC: Remove support for () and <> style comments in data tables. Now -that DTC has full expression support, we don't want to have comment strings that -start with a parentheses or a less-than symbol. Now, only the standard /* and // +Disassembler/DTC: Remove support for () and <> style comments in data tables. +Now +that DTC has full expression support, we don't want to have comment strings +that +start with a parentheses or a less-than symbol. Now, only the standard /* and +// comments are supported, as well as the bracket [] comments. -AcpiXtract: Fix for RSDP and dynamic SSDT extraction. These tables have "unusual" +AcpiXtract: Fix for RSDP and dynamic SSDT extraction. These tables have +"unusual" headers in the acpidump file. Update the header validation to support these tables. Problem introduced in previous AcpiXtract version in the change to support "wrong checksum" error messages emitted by acpidump utility. -iASL: Add a * option to generate all template files (as a synonym for ALL) as in +iASL: Add a * option to generate all template files (as a synonym for ALL) as +in "iasl -T *" or "iasl -T ALL". iASL/DTC: Do not abort compiler on fatal errors. We do not want to completely @@ -81,7 +159,8 @@ invocation. 1) ACPI CA Core Subsystem: Fixed a problem caused by a _PRW method appearing at the namespace root scope -during the setup of wake GPEs. A fault could occur if a _PRW directly under the +during the setup of wake GPEs. A fault could occur if a _PRW directly under +the root object was passed to the AcpiSetupGpeForWake interface. Lin Ming. Implemented support for "spurious" Global Lock interrupts. On some systems, a @@ -89,9 +168,11 @@ global lock interrupt can occur without the pending flag being set. Upon a GL interrupt, we now ensure that a thread is actually waiting for the lock before signaling GL availability. Rafael Wysocki, Bob Moore. -Example Code and Data Size: These are the sizes for the OS-independent acpica.lib +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug version of -the code includes the debug output trace mechanism and has a much larger code and +the code includes the debug output trace mechanism and has a much larger code +and data size. Previous Release (VC 9.0): @@ -108,14 +189,16 @@ header files, disassembler, table compiler, and template generator. Bob Moore, Lin Ming. AcpiXtract: Correctly handle embedded comments and messages from AcpiDump. -Apparently some or all versions of acpidump will occasionally emit a comment like +Apparently some or all versions of acpidump will occasionally emit a comment +like "Wrong checksum", etc., into the dump file. This was causing problems for AcpiXtract. ACPICA BZ 905. iASL: Fix the Linux makefile by removing an inadvertent double file inclusion. ACPICA BZ 913. -AcpiExec: Update installation of operation region handlers. Install one handler +AcpiExec: Update installation of operation region handlers. Install one +handler for a user-defined address space. This is used by the ASL test suite (ASLTS). ---------------------------------------- diff --git a/sys/contrib/dev/acpica/debugger/dbexec.c b/sys/contrib/dev/acpica/debugger/dbexec.c index 3d46335fefa3..eb0dde21dde9 100644 --- a/sys/contrib/dev/acpica/debugger/dbexec.c +++ b/sys/contrib/dev/acpica/debugger/dbexec.c @@ -53,7 +53,8 @@ ACPI_MODULE_NAME ("dbexec") -static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; +static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; +#define DB_DEFAULT_PKG_ELEMENTS 33 /* Local prototypes */ @@ -81,6 +82,348 @@ AcpiDbExecutionWalk ( void *Context, void **ReturnValue); +static ACPI_STATUS +AcpiDbHexCharToValue ( + int HexChar, + UINT8 *ReturnValue); + +static ACPI_STATUS +AcpiDbConvertToPackage ( + char *String, + ACPI_OBJECT *Object); + +static ACPI_STATUS +AcpiDbConvertToObject ( + ACPI_OBJECT_TYPE Type, + char *String, + ACPI_OBJECT *Object); + +static void +AcpiDbDeleteObjects ( + UINT32 Count, + ACPI_OBJECT *Objects); + + +/******************************************************************************* + * + * FUNCTION: AcpiDbHexCharToValue + * + * PARAMETERS: HexChar - Ascii Hex digit, 0-9|a-f|A-F + * ReturnValue - Where the converted value is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbHexCharToValue ( + int HexChar, + UINT8 *ReturnValue) +{ + UINT8 Value; + + + /* Digit must be ascii [0-9a-fA-F] */ + + if (!ACPI_IS_XDIGIT (HexChar)) + { + return (AE_BAD_HEX_CONSTANT); + } + + if (HexChar <= 0x39) + { + Value = (UINT8) (HexChar - 0x30); + } + else + { + Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37); + } + + *ReturnValue = Value; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbHexByteToBinary + * + * PARAMETERS: HexByte - Double hex digit (0x00 - 0xFF) in format: + * HiByte then LoByte. + * ReturnValue - Where the converted value is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255). + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbHexByteToBinary ( + char *HexByte, + UINT8 *ReturnValue) +{ + UINT8 Local0; + UINT8 Local1; + ACPI_STATUS Status; + + + /* High byte */ + + Status = AcpiDbHexCharToValue (HexByte[0], &Local0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Low byte */ + + Status = AcpiDbHexCharToValue (HexByte[1], &Local1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *ReturnValue = (UINT8) ((Local0 << 4) | Local1); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbConvertToBuffer + * + * PARAMETERS: String - Input string to be converted + * Object - Where the buffer object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a string to a buffer object. String is treated a list + * of buffer elements, each separated by a space or comma. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbConvertToBuffer ( + char *String, + ACPI_OBJECT *Object) +{ + UINT32 i; + UINT32 j; + UINT32 Length; + UINT8 *Buffer; + ACPI_STATUS Status; + + + /* Generate the final buffer length */ + + for (i = 0, Length = 0; String[i];) + { + i+=2; + Length++; + + while (String[i] && + ((String[i] == ',') || (String[i] == ' '))) + { + i++; + } + } + + Buffer = ACPI_ALLOCATE (Length); + if (!Buffer) + { + return (AE_NO_MEMORY); + } + + /* Convert the command line bytes to the buffer */ + + for (i = 0, j = 0; String[i];) + { + Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (Buffer); + return (Status); + } + + j++; + i+=2; + while (String[i] && + ((String[i] == ',') || (String[i] == ' '))) + { + i++; + } + } + + Object->Type = ACPI_TYPE_BUFFER; + Object->Buffer.Pointer = Buffer; + Object->Buffer.Length = Length; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbConvertToPackage + * + * PARAMETERS: String - Input string to be converted + * Object - Where the package object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a string to a package object. Handles nested packages + * via recursion with AcpiDbConvertToObject. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbConvertToPackage ( + char *String, + ACPI_OBJECT *Object) +{ + char *This; + char *Next; + UINT32 i; + ACPI_OBJECT_TYPE Type; + ACPI_OBJECT *Elements; + ACPI_STATUS Status; + + + Elements = ACPI_ALLOCATE_ZEROED ( + DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT)); + + This = String; + for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) + { + This = AcpiDbGetNextToken (This, &Next, &Type); + if (!This) + { + break; + } + + /* Recursive call to convert each package element */ + + Status = AcpiDbConvertToObject (Type, This, &Elements[i]); + if (ACPI_FAILURE (Status)) + { + AcpiDbDeleteObjects (i + 1, Elements); + ACPI_FREE (Elements); + return (Status); + } + + This = Next; + } + + Object->Type = ACPI_TYPE_PACKAGE; + Object->Package.Count = i; + Object->Package.Elements = Elements; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbConvertToObject + * + * PARAMETERS: Type - Object type as determined by parser + * String - Input string to be converted + * Object - Where the new object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing: + * 1) String objects were surrounded by quotes. + * 2) Buffer objects were surrounded by parentheses. + * 3) Package objects were surrounded by brackets "[]". + * 4) All standalone tokens are treated as integers. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbConvertToObject ( + ACPI_OBJECT_TYPE Type, + char *String, + ACPI_OBJECT *Object) +{ + ACPI_STATUS Status = AE_OK; + + + switch (Type) + { + case ACPI_TYPE_STRING: + Object->Type = ACPI_TYPE_STRING; + Object->String.Pointer = String; + Object->String.Length = (UINT32) ACPI_STRLEN (String); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiDbConvertToBuffer (String, Object); + break; + + case ACPI_TYPE_PACKAGE: + Status = AcpiDbConvertToPackage (String, Object); + break; + + default: + Object->Type = ACPI_TYPE_INTEGER; + Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value); + break; + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDeleteObjects + * + * PARAMETERS: Count - Count of objects in the list + * Objects - Array of ACPI_OBJECTs to be deleted + * + * RETURN: None + * + * DESCRIPTION: Delete a list of ACPI_OBJECTS. Handles packages and nested + * packages via recursion. + * + ******************************************************************************/ + +static void +AcpiDbDeleteObjects ( + UINT32 Count, + ACPI_OBJECT *Objects) +{ + UINT32 i; + + + for (i = 0; i < Count; i++) + { + switch (Objects[i].Type) + { + case ACPI_TYPE_BUFFER: + ACPI_FREE (Objects[i].Buffer.Pointer); + break; + + case ACPI_TYPE_PACKAGE: + + /* Recursive call to delete package elements */ + + AcpiDbDeleteObjects (Objects[i].Package.Count, + Objects[i].Package.Elements); + + /* Free the elements array */ + + ACPI_FREE (Objects[i].Package.Elements); + break; + + default: + break; + } + } +} + /******************************************************************************* * @@ -104,8 +447,8 @@ AcpiDbExecuteMethod ( ACPI_OBJECT_LIST ParamObjects; ACPI_OBJECT Params[ACPI_METHOD_NUM_ARGS]; ACPI_HANDLE Handle; - UINT32 i; ACPI_DEVICE_INFO *ObjInfo; + UINT32 i; ACPI_FUNCTION_TRACE (DbExecuteMethod); @@ -139,25 +482,37 @@ AcpiDbExecuteMethod ( { /* Are there arguments to the method? */ + i = 0; if (Info->Args && Info->Args[0]) { - for (i = 0; Info->Args[i] && + /* Get arguments passed on the command line */ + + for (; Info->Args[i] && (i < ACPI_METHOD_NUM_ARGS) && (i < ObjInfo->ParamCount); i++) { - Params[i].Type = ACPI_TYPE_INTEGER; - Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); + /* Convert input string (token) to an actual ACPI_OBJECT */ + + Status = AcpiDbConvertToObject (Info->Types[i], + Info->Args[i], &Params[i]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing method arguments")); + goto Cleanup; + } } - - ParamObjects.Pointer = Params; - ParamObjects.Count = i; } - else - { - /* Setup default parameters */ - for (i = 0; i < ObjInfo->ParamCount; i++) + /* Create additional "default" parameters as needed */ + + if (i < ObjInfo->ParamCount) + { + AcpiOsPrintf ("Adding %u arguments containing default values\n", + ObjInfo->ParamCount - i); + + for (; i < ObjInfo->ParamCount; i++) { switch (i) { @@ -181,13 +536,11 @@ AcpiDbExecuteMethod ( break; } } - - ParamObjects.Pointer = Params; - ParamObjects.Count = ObjInfo->ParamCount; } - } - ACPI_FREE (ObjInfo); + ParamObjects.Count = ObjInfo->ParamCount; + ParamObjects.Pointer = Params; + } /* Prepare for a return object of arbitrary size */ @@ -198,7 +551,7 @@ AcpiDbExecuteMethod ( AcpiGbl_MethodExecuting = TRUE; Status = AcpiEvaluateObject (NULL, - Info->Pathname, &ParamObjects, ReturnObj); + Info->Pathname, &ParamObjects, ReturnObj); AcpiGbl_CmSingleStep = FALSE; AcpiGbl_MethodExecuting = FALSE; @@ -206,16 +559,20 @@ AcpiDbExecuteMethod ( if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, - "while executing %s from debugger", Info->Pathname)); + "while executing %s from debugger", Info->Pathname)); if (Status == AE_BUFFER_OVERFLOW) { ACPI_ERROR ((AE_INFO, - "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", + "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)", ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length)); } } +Cleanup: + AcpiDbDeleteObjects (ObjInfo->ParamCount, Params); + ACPI_FREE (ObjInfo); + return_ACPI_STATUS (Status); } @@ -380,6 +737,7 @@ void AcpiDbExecute ( char *Name, char **Args, + ACPI_OBJECT_TYPE *Types, UINT32 Flags) { ACPI_STATUS Status; @@ -417,6 +775,7 @@ AcpiDbExecute ( AcpiUtStrupr (NameString); AcpiGbl_DbMethodInfo.Name = NameString; AcpiGbl_DbMethodInfo.Args = Args; + AcpiGbl_DbMethodInfo.Types = Types; AcpiGbl_DbMethodInfo.Flags = Flags; ReturnObj.Pointer = NULL; @@ -529,6 +888,8 @@ AcpiDbMethodThread ( LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr; LocalInfo.Arguments[3] = NULL; + LocalInfo.Types = LocalInfo.ArgTypes; + (void) AcpiOsSignalSemaphore (Info->InfoGate, 1); for (i = 0; i < Info->NumLoops; i++) @@ -696,6 +1057,12 @@ AcpiDbCreateExecutionThreads ( AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr; AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr; AcpiGbl_DbMethodInfo.Arguments[3] = NULL; + + AcpiGbl_DbMethodInfo.Types = AcpiGbl_DbMethodInfo.ArgTypes; + AcpiGbl_DbMethodInfo.ArgTypes[0] = ACPI_TYPE_INTEGER; + AcpiGbl_DbMethodInfo.ArgTypes[1] = ACPI_TYPE_INTEGER; + AcpiGbl_DbMethodInfo.ArgTypes[2] = ACPI_TYPE_INTEGER; + AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr); AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); diff --git a/sys/contrib/dev/acpica/debugger/dbinput.c b/sys/contrib/dev/acpica/debugger/dbinput.c index 5b8e70a4d007..7d8bbb765740 100644 --- a/sys/contrib/dev/acpica/debugger/dbinput.c +++ b/sys/contrib/dev/acpica/debugger/dbinput.c @@ -54,11 +54,6 @@ /* Local prototypes */ -static char * -AcpiDbGetNextToken ( - char *String, - char **Next); - static UINT32 AcpiDbGetLine ( char *InputBuffer); @@ -285,6 +280,10 @@ AcpiDbDisplayHelp ( AcpiOsPrintf (" Call Run to next control method invocation\n"); AcpiOsPrintf (" Debug [Arguments] Single Step a control method\n"); AcpiOsPrintf (" Execute [Arguments] Execute control method\n"); + AcpiOsPrintf (" Hex Integer Integer method argument\n"); + AcpiOsPrintf (" \"Ascii String\" String method argument\n"); + AcpiOsPrintf (" (Byte List) Buffer method argument\n"); + AcpiOsPrintf (" [Package Element List] Package method argument\n"); AcpiOsPrintf (" Go Allow method to run to completion\n"); AcpiOsPrintf (" Information Display info about the current method\n"); AcpiOsPrintf (" Into Step into (not over) a method call\n"); @@ -318,12 +317,15 @@ AcpiDbDisplayHelp ( * ******************************************************************************/ -static char * +char * AcpiDbGetNextToken ( char *String, - char **Next) + char **Next, + ACPI_OBJECT_TYPE *ReturnType) { char *Start; + UINT32 Depth; + ACPI_OBJECT_TYPE Type = ACPI_TYPE_INTEGER; /* At end of buffer? */ @@ -333,7 +335,7 @@ AcpiDbGetNextToken ( return (NULL); } - /* Get rid of any spaces at the beginning */ + /* Remove any spaces at the beginning */ if (*String == ' ') { @@ -348,22 +350,88 @@ AcpiDbGetNextToken ( } } - if (*String == '"') + switch (*String) { + case '"': + /* This is a quoted string, scan until closing quote */ String++; Start = String; + Type = ACPI_TYPE_STRING; - /* Find end of token */ + /* Find end of string */ while (*String && (*String != '"')) { String++; } - } - else - { + break; + + case '(': + + /* This is the start of a buffer, scan until closing paren */ + + String++; + Start = String; + Type = ACPI_TYPE_BUFFER; + + /* Find end of buffer */ + + while (*String && (*String != ')')) + { + String++; + } + break; + + case '[': + + /* This is the start of a package, scan until closing bracket */ + + String++; + Depth = 1; + Start = String; + Type = ACPI_TYPE_PACKAGE; + + /* Find end of package (closing bracket) */ + + while (*String) + { + /* Handle String package elements */ + + if (*String == '"') + { + /* Find end of string */ + + String++; + while (*String && (*String != '"')) + { + String++; + } + if (!(*String)) + { + break; + } + } + else if (*String == '[') + { + Depth++; /* A nested package declaration */ + } + else if (*String == ']') + { + Depth--; + if (Depth == 0) /* Found final package closing bracket */ + { + break; + } + } + + String++; + } + break; + + default: + Start = String; /* Find end of token */ @@ -372,6 +440,7 @@ AcpiDbGetNextToken ( { String++; } + break; } if (!(*String)) @@ -384,6 +453,7 @@ AcpiDbGetNextToken ( *Next = String + 1; } + *ReturnType = Type; return (Start); } @@ -416,7 +486,8 @@ AcpiDbGetLine ( This = AcpiGbl_DbParsedBuf; for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) { - AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next); + AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next, + &AcpiGbl_DbArgTypes[i]); if (!AcpiGbl_DbArgs[i]) { break; @@ -575,7 +646,8 @@ AcpiDbCommandDispatch ( break; case CMD_DEBUG: - AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP); + AcpiDbExecute (AcpiGbl_DbArgs[1], + &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP); break; case CMD_DISASSEMBLE: @@ -601,7 +673,7 @@ AcpiDbCommandDispatch ( case CMD_EXECUTE: AcpiDbExecute (AcpiGbl_DbArgs[1], - &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); + &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP); break; case CMD_FIND: @@ -961,7 +1033,13 @@ AcpiDbUserCommands ( /* Get the user input line */ - (void) AcpiOsGetLine (AcpiGbl_DbLineBuf); + Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, + ACPI_DB_LINE_BUFFER_SIZE, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + return (Status); + } /* Check for single or multithreaded debug */ diff --git a/sys/contrib/dev/acpica/debugger/dbutils.c b/sys/contrib/dev/acpica/debugger/dbutils.c index 8385fc861411..bed52e6674e9 100644 --- a/sys/contrib/dev/acpica/debugger/dbutils.c +++ b/sys/contrib/dev/acpica/debugger/dbutils.c @@ -382,7 +382,7 @@ AcpiDbUInt32ToHexString ( UINT32 Value, char *Buffer) { - UINT8 i; + int i; if (Value == 0) @@ -391,10 +391,9 @@ AcpiDbUInt32ToHexString ( return; } - ACPI_STRCPY (Buffer, "0x"); - Buffer[10] = '\0'; + Buffer[8] = '\0'; - for (i = 9; i > 1; i--) + for (i = 7; i >= 0; i--) { Buffer[i] = Converter [Value & 0x0F]; Value = Value >> 4; diff --git a/sys/contrib/dev/acpica/debugger/dbxface.c b/sys/contrib/dev/acpica/debugger/dbxface.c index 2f3708ace971..e8602bc34a5a 100644 --- a/sys/contrib/dev/acpica/debugger/dbxface.c +++ b/sys/contrib/dev/acpica/debugger/dbxface.c @@ -137,7 +137,13 @@ AcpiDbStartCommand ( /* Get the user input line */ - (void) AcpiOsGetLine (AcpiGbl_DbLineBuf); + Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, + ACPI_DB_LINE_BUFFER_SIZE, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + return (Status); + } } Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op); diff --git a/sys/contrib/dev/acpica/include/acconfig.h b/sys/contrib/dev/acpica/include/acconfig.h index 4b05ed383105..7a2107aa7699 100644 --- a/sys/contrib/dev/acpica/include/acconfig.h +++ b/sys/contrib/dev/acpica/include/acconfig.h @@ -200,7 +200,8 @@ * *****************************************************************************/ -#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ +#define ACPI_DEBUGGER_MAX_ARGS ACPI_METHOD_NUM_ARGS + 2 /* Max command line arguments */ +#define ACPI_DB_LINE_BUFFER_SIZE 512 #define ACPI_DEBUGGER_COMMAND_PROMPT '-' #define ACPI_DEBUGGER_EXECUTE_PROMPT '%' diff --git a/sys/contrib/dev/acpica/include/acdebug.h b/sys/contrib/dev/acpica/include/acdebug.h index 9b4822d14ae1..2c1fe73429d1 100644 --- a/sys/contrib/dev/acpica/include/acdebug.h +++ b/sys/contrib/dev/acpica/include/acdebug.h @@ -277,6 +277,7 @@ void AcpiDbExecute ( char *Name, char **Args, + ACPI_OBJECT_TYPE *Types, UINT32 Flags); void @@ -357,6 +358,12 @@ AcpiDbUserCommands ( char Prompt, ACPI_PARSE_OBJECT *Op); +char * +AcpiDbGetNextToken ( + char *String, + char **Next, + ACPI_OBJECT_TYPE *ReturnType); + /* * dbstats - Generation and display of ACPI table statistics diff --git a/sys/contrib/dev/acpica/include/acglobal.h b/sys/contrib/dev/acpica/include/acglobal.h index fc20994fea42..ebbae0f59597 100644 --- a/sys/contrib/dev/acpica/include/acglobal.h +++ b/sys/contrib/dev/acpica/include/acglobal.h @@ -425,10 +425,11 @@ ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_NoRegionSupport; ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; -ACPI_EXTERN char AcpiGbl_DbLineBuf[80]; -ACPI_EXTERN char AcpiGbl_DbParsedBuf[80]; -ACPI_EXTERN char AcpiGbl_DbScopeBuf[40]; -ACPI_EXTERN char AcpiGbl_DbDebugFilename[40]; +ACPI_EXTERN ACPI_OBJECT_TYPE AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_EXTERN char AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]; +ACPI_EXTERN char AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]; +ACPI_EXTERN char AcpiGbl_DbScopeBuf[80]; +ACPI_EXTERN char AcpiGbl_DbDebugFilename[80]; ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; ACPI_EXTERN char *AcpiGbl_DbBuffer; ACPI_EXTERN char *AcpiGbl_DbFilename; diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h index bdefb7671f60..2eb6fc21d465 100644 --- a/sys/contrib/dev/acpica/include/aclocal.h +++ b/sys/contrib/dev/acpica/include/aclocal.h @@ -1198,6 +1198,7 @@ typedef struct acpi_db_method_info UINT32 NumLoops; char Pathname[128]; char **Args; + ACPI_OBJECT_TYPE *Types; /* * Arguments to be passed to method for the command @@ -1206,6 +1207,7 @@ typedef struct acpi_db_method_info * Index of current thread inside all them created. */ char InitArgs; + ACPI_OBJECT_TYPE ArgTypes[4]; char *Arguments[4]; char NumThreadsStr[11]; char IdOfThreadStr[11]; diff --git a/sys/contrib/dev/acpica/include/acpiosxf.h b/sys/contrib/dev/acpica/include/acpiosxf.h index 53605ad162d3..43ca582ae3b2 100644 --- a/sys/contrib/dev/acpica/include/acpiosxf.h +++ b/sys/contrib/dev/acpica/include/acpiosxf.h @@ -376,9 +376,11 @@ AcpiOsRedirectOutput ( /* * Debug input */ -UINT32 +ACPI_STATUS AcpiOsGetLine ( - char *Buffer); + char *Buffer, + UINT32 BufferLength, + UINT32 *BytesRead); /* diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h index 891ccf388d8c..17552612ba77 100644 --- a/sys/contrib/dev/acpica/include/acpixf.h +++ b/sys/contrib/dev/acpica/include/acpixf.h @@ -48,7 +48,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20110413 +#define ACPI_CA_VERSION 0x20110527 #include #include diff --git a/sys/contrib/dev/acpica/include/acpredef.h b/sys/contrib/dev/acpica/include/acpredef.h index 884f118043a1..0496767a8675 100644 --- a/sys/contrib/dev/acpica/include/acpredef.h +++ b/sys/contrib/dev/acpica/include/acpredef.h @@ -470,6 +470,7 @@ static const ACPI_PREDEFINED_INFO PredefinedNames[] = {{"_SWS", 0, ACPI_RTYPE_INTEGER}}, {{"_TC1", 0, ACPI_RTYPE_INTEGER}}, {{"_TC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_TDL", 0, ACPI_RTYPE_INTEGER}}, {{"_TIP", 1, ACPI_RTYPE_INTEGER}}, {{"_TIV", 1, ACPI_RTYPE_INTEGER}}, {{"_TMP", 0, ACPI_RTYPE_INTEGER}}, diff --git a/sys/contrib/dev/acpica/osunixxf.c b/sys/contrib/dev/acpica/osunixxf.c index 0983bd4d4ef0..f486c27da2a4 100644 --- a/sys/contrib/dev/acpica/osunixxf.c +++ b/sys/contrib/dev/acpica/osunixxf.c @@ -311,18 +311,21 @@ AcpiOsVprintf ( * * FUNCTION: AcpiOsGetLine * - * PARAMETERS: fmt - Standard printf format - * args - Argument list + * PARAMETERS: Buffer - Where to return the command line + * BufferLength - Maximum length of Buffer + * BytesRead - Where the actual byte count is returned * - * RETURN: Actual bytes read + * RETURN: Status and actual bytes read * * DESCRIPTION: Formatted input with argument list pointer * *****************************************************************************/ -UINT32 +ACPI_STATUS AcpiOsGetLine ( - char *Buffer) + char *Buffer, + UINT32 BufferLength, + UINT32 *BytesRead) { UINT8 Temp; UINT32 i; @@ -330,6 +333,11 @@ AcpiOsGetLine ( for (i = 0; ; i++) { + if (i >= BufferLength) + { + return (AE_BUFFER_OVERFLOW); + } + scanf ("%1c", &Temp); if (!Temp || Temp == '\n') { @@ -345,7 +353,11 @@ AcpiOsGetLine ( /* Return the number of bytes in the string */ - return (i); + if (BytesRead) + { + *BytesRead = i; + } + return (AE_OK); } diff --git a/sys/contrib/dev/acpica/tables/tbinstal.c b/sys/contrib/dev/acpica/tables/tbinstal.c index 8e2199fac7bf..8697fa1a39b4 100644 --- a/sys/contrib/dev/acpica/tables/tbinstal.c +++ b/sys/contrib/dev/acpica/tables/tbinstal.c @@ -144,12 +144,28 @@ AcpiTbAddTable ( } /* - * Originally, we checked the table signature for "SSDT" or "PSDT" here. - * Next, we added support for OEMx tables, signature "OEM". - * Valid tables were encountered with a null signature, so we've just - * given up on validating the signature, since it seems to be a waste - * of code. The original code was removed (05/2008). + * Validate the incoming table signature. + * + * 1) Originally, we checked the table signature for "SSDT" or "PSDT". + * 2) We added support for OEMx tables, signature "OEM". + * 3) Valid tables were encountered with a null signature, so we just + * gave up on validating the signature, (05/2008). + * 4) We encountered non-AML tables such as the MADT, which caused + * interpreter errors and kernel faults. So now, we once again allow + * only "SSDT", "OEMx", and now, also a null signature. (05/2011). */ + if ((TableDesc->Pointer->Signature[0] != 0x00) && + (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) && + (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3))) + { + ACPI_ERROR ((AE_INFO, + "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx", + AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ? + TableDesc->Pointer->Signature : "????", + *(UINT32 *) TableDesc->Pointer->Signature)); + + return_ACPI_STATUS (AE_BAD_SIGNATURE); + } (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); diff --git a/sys/contrib/pf/net/pf.c b/sys/contrib/pf/net/pf.c index 756ad3aa78b9..2ce254f4c4b0 100644 --- a/sys/contrib/pf/net/pf.c +++ b/sys/contrib/pf/net/pf.c @@ -6132,9 +6132,11 @@ pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif) #ifdef __FreeBSD__ /* XXX MRT not always INET */ /* stick with table 0 though */ +#ifdef INET if (af == AF_INET) in_rtalloc_ign((struct route *)&ro, 0, 0); else +#endif rtalloc_ign((struct route *)&ro, 0); #else /* ! __FreeBSD__ */ rtalloc_noclone((struct route *)&ro, NO_CLONING); @@ -6214,9 +6216,11 @@ pf_rtlabel_match(struct pf_addr *addr, sa_family_t af, struct pf_addr_wrap *aw) # ifdef RTF_PRCLONING rtalloc_ign((struct route *)&ro, (RTF_CLONING|RTF_PRCLONING)); # else /* !RTF_PRCLONING */ +#ifdef INET if (af == AF_INET) in_rtalloc_ign((struct route *)&ro, 0, 0); else +#endif rtalloc_ign((struct route *)&ro, 0); # endif #else /* ! __FreeBSD__ */ @@ -6789,11 +6793,13 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, sa_family_t a KMOD_UDPSTAT_INC(udps_badsum); break; } +#ifdef INET case IPPROTO_ICMP: { KMOD_ICMPSTAT_INC(icps_checksum); break; } +#endif #ifdef INET6 case IPPROTO_ICMPV6: { @@ -6889,9 +6895,11 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, case IPPROTO_UDP: KMOD_UDPSTAT_INC(udps_badsum); break; +#ifdef INET case IPPROTO_ICMP: KMOD_ICMPSTAT_INC(icps_checksum); break; +#endif #ifdef INET6 case IPPROTO_ICMPV6: KMOD_ICMP6STAT_INC(icp6s_checksum); diff --git a/sys/contrib/pf/net/pf_ioctl.c b/sys/contrib/pf/net/pf_ioctl.c index 2a66fd8aa8bb..c41fcc6476ca 100644 --- a/sys/contrib/pf/net/pf_ioctl.c +++ b/sys/contrib/pf/net/pf_ioctl.c @@ -3735,9 +3735,12 @@ pf_check6_out(void *arg, struct mbuf **m, struct ifnet *ifp, int dir, */ int chk; - /* We need a proper CSUM befor we start (s. OpenBSD ip_output) */ + /* We need a proper CSUM before we start (s. OpenBSD ip_output) */ if ((*m)->m_pkthdr.csum_flags & CSUM_DELAY_DATA) { +#ifdef INET + /* XXX-BZ copy&paste error from r126261? */ in_delayed_cksum(*m); +#endif (*m)->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } chk = pf_test6(PF_OUT, ifp, m, NULL, inp); diff --git a/sys/contrib/pf/net/pf_norm.c b/sys/contrib/pf/net/pf_norm.c index 32ba9f418a47..cd6d65af082a 100644 --- a/sys/contrib/pf/net/pf_norm.c +++ b/sys/contrib/pf/net/pf_norm.c @@ -949,6 +949,7 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff, return (NULL); } +#ifdef INET int pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kif *kif, u_short *reason, struct pf_pdesc *pd) @@ -1198,6 +1199,7 @@ pf_normalize_ip(struct mbuf **m0, int dir, struct pfi_kif *kif, u_short *reason, return (PF_DROP); } +#endif #ifdef INET6 int diff --git a/sys/dev/acpica/Osd/OsdDebug.c b/sys/dev/acpica/Osd/OsdDebug.c index 84253574cf98..0547f758fcb3 100644 --- a/sys/dev/acpica/Osd/OsdDebug.c +++ b/sys/dev/acpica/Osd/OsdDebug.c @@ -47,20 +47,23 @@ __FBSDID("$FreeBSD$"); #include -UINT32 -AcpiOsGetLine(char *Buffer) +ACPI_STATUS +AcpiOsGetLine(char *Buffer, UINT32 BufferLength, UINT32 *BytesRead) { #ifdef DDB - char *cp; + char *cp; - db_readline(Buffer, 80); - for (cp = Buffer; *cp != 0; cp++) - if (*cp == '\n') - *cp = 0; - return (AE_OK); + cp = Buffer; + if (db_readline(Buffer, BufferLength) > 0) + while (*cp != '\0' && *cp != '\n' && *cp != '\r') + cp++; + *cp = '\0'; + if (BytesRead != NULL) + *BytesRead = cp - Buffer; + return (AE_OK); #else - printf("AcpiOsGetLine called but no input support"); - return (AE_NOT_EXIST); + printf("AcpiOsGetLine called but no input support"); + return (AE_NOT_EXIST); #endif /* DDB */ } diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c index db76bfab27d0..7560430bf8d7 100644 --- a/sys/dev/ipw/if_ipw.c +++ b/sys/dev/ipw/if_ipw.c @@ -199,6 +199,8 @@ static devclass_t ipw_devclass; DRIVER_MODULE(ipw, pci, ipw_driver, ipw_devclass, 0, 0); +MODULE_VERSION(ipw, 1); + static int ipw_probe(device_t dev) { diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c index dc81309b1404..73b861c62cff 100644 --- a/sys/dev/iwi/if_iwi.c +++ b/sys/dev/iwi/if_iwi.c @@ -232,6 +232,8 @@ static devclass_t iwi_devclass; DRIVER_MODULE(iwi, pci, iwi_driver, iwi_devclass, 0, 0); +MODULE_VERSION(iwi, 1); + static __inline uint8_t MEM_READ_1(struct iwi_softc *sc, uint32_t addr) { diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index 29e391f3548c..67e1a449a14b 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -401,6 +401,8 @@ static devclass_t iwn_devclass; DRIVER_MODULE(iwn, pci, iwn_driver, iwn_devclass, 0, 0); +MODULE_VERSION(iwn, 1); + MODULE_DEPEND(iwn, firmware, 1, 1, 1); MODULE_DEPEND(iwn, pci, 1, 1, 1); MODULE_DEPEND(iwn, wlan, 1, 1, 1); diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 6cdfa348808f..28a3c0149f29 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -1889,7 +1889,7 @@ nfe_int_task(void *arg, int pending) if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { NFE_UNLOCK(sc); - nfe_enable_intr(sc); + nfe_disable_intr(sc); return; } diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index e1fffe14214e..38ebb7e4cc8b 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -273,6 +273,8 @@ static devclass_t wpi_devclass; DRIVER_MODULE(wpi, pci, wpi_driver, wpi_devclass, 0, 0); +MODULE_VERSION(wpi, 1); + static const uint8_t wpi_ridx_to_plcp[] = { /* OFDM: IEEE Std 802.11a-1999, pp. 14 Table 80 */ /* R1-R4 (ral/ural is R4-R1) */ diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 3ec12ca37a26..984724d93aed 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3293,7 +3293,13 @@ nfs_pathconf(struct vop_pathconf_args *ap) struct thread *td = curthread; int attrflag, error; - if (NFS_ISV34(vp)) { + if (NFS_ISV4(vp) || (NFS_ISV3(vp) && (ap->a_name == _PC_LINK_MAX || + ap->a_name == _PC_NAME_MAX || ap->a_name == _PC_CHOWN_RESTRICTED || + ap->a_name == _PC_NO_TRUNC))) { + /* + * Since only the above 4 a_names are returned by the NFSv3 + * Pathconf RPC, there is no point in doing it for others. + */ error = nfsrpc_pathconf(vp, &pc, td->td_ucred, td, &nfsva, &attrflag, NULL); if (attrflag != 0) @@ -3302,7 +3308,10 @@ nfs_pathconf(struct vop_pathconf_args *ap) if (error != 0) return (error); } else { - /* For NFSv2, just fake them. */ + /* + * For NFSv2 (or NFSv3 when not one of the above 4 a_names), + * just fake them. + */ pc.pc_linkmax = LINK_MAX; pc.pc_namemax = NFS_MAXNAMLEN; pc.pc_notrunc = 1; diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c index ae56990cd7ba..ac641a808226 100644 --- a/sys/i386/pci/pci_cfgreg.c +++ b/sys/i386/pci/pci_cfgreg.c @@ -553,7 +553,7 @@ pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus) (uintmax_t)base); #ifdef SMP - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) #endif { diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 41d2211bd124..7252865afe7e 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -316,7 +316,7 @@ cpu_startup(void *dummy) /* * Create sysctl tree for per-CPU information. */ - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { snprintf(nodename, sizeof(nodename), "%u", pc->pc_cpuid); sysctl_ctx_init(&pc->pc_md.sysctl_ctx); pc->pc_md.sysctl_tree = SYSCTL_ADD_NODE(&pc->pc_md.sysctl_ctx, diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index e3df54a0286c..15afea030182 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -357,7 +357,7 @@ cpu_mp_start() /* Keep 'em spinning until we unleash them... */ ia64_ap_state.as_spin = 1; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { pc->pc_md.current_pmap = kernel_pmap; pc->pc_other_cpus = all_cpus; CPU_NAND(&pc->pc_other_cpus, &pc->pc_cpumask); @@ -425,7 +425,7 @@ cpu_mp_unleash(void *dummy) cpus = 0; smp_cpus = 0; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { cpus++; if (pc->pc_md.awake) { kproc_create(ia64_store_mca_state, pc, NULL, 0, 0, @@ -463,7 +463,7 @@ ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) ipi_send(pc, ipi); } @@ -487,7 +487,7 @@ ipi_all_but_self(int ipi) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc != pcpup) ipi_send(pc, ipi); } diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 5f10ad6ff79a..411d53a64d83 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -535,7 +535,7 @@ pmap_invalidate_page(vm_offset_t va) critical_enter(); vhpt_ofs = ia64_thash(va) - PCPU_GET(md.vhpt); tag = ia64_ttag(va); - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { pte = (struct ia64_lpte *)(pc->pc_md.vhpt + vhpt_ofs); atomic_cmpset_64(&pte->tag, tag, 1UL << 63); } diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c index af12d7dcf5a9..f412d17f6cc8 100644 --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -60,7 +60,7 @@ idle_setup(void *dummy) p = NULL; /* start with no idle process */ #ifdef SMP - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { #endif #ifdef SMP error = kproc_kthread_add(sched_idletd, NULL, &p, &td, diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 2fad27ce505c..592bb80aff52 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1089,7 +1089,7 @@ forward_wakeup(int cpunum) CPU_OR(&dontuse, &hlt_cpus_mask); CPU_ZERO(&map2); if (forward_wakeup_use_loop) { - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; if (!CPU_OVERLAP(&id, &dontuse) && pc->pc_curthread == pc->pc_idlethread) { @@ -1124,7 +1124,7 @@ forward_wakeup(int cpunum) } if (!CPU_EMPTY(&map)) { forward_wakeups_delivered++; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { id = pc->pc_cpumask; if (!CPU_OVERLAP(&map, &id)) continue; diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index bb78c00a7591..1d67864b1533 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -412,7 +412,7 @@ kdb_thr_ctx(struct thread *thr) return (&kdb_pcb); #if defined(SMP) && defined(KDB_STOPPEDPCB) - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc->pc_curthread == thr && CPU_OVERLAP(&stopped_cpus, &pc->pc_cpumask)) return (KDB_STOPPEDPCB(pc)); diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index 14cd39dd8316..c146ab0900ae 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -31,8 +31,16 @@ #include #include +#include +#include #include +/* + * Maximum number conversion buffer length: uintmax_t in base 2, plus <> + * around the priority, and a terminating NUL. + */ +#define MAXPRIBUF (sizeof(intmax_t) * NBBY + 3) + /* Read/write sequence numbers are modulo a multiple of the buffer size. */ #define SEQMOD(size) ((size) * 16) @@ -51,6 +59,9 @@ msgbuf_init(struct msgbuf *mbp, void *ptr, int size) mbp->msg_seqmod = SEQMOD(size); msgbuf_clear(mbp); mbp->msg_magic = MSG_MAGIC; + mbp->msg_lastpri = -1; + mbp->msg_needsnl = 0; + mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN); } /* @@ -80,6 +91,11 @@ msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size) } msgbuf_clear(mbp); } + + mbp->msg_lastpri = -1; + /* Assume that the old message buffer didn't end in a newline. */ + mbp->msg_needsnl = 1; + mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN); } /* @@ -110,25 +126,140 @@ msgbuf_getcount(struct msgbuf *mbp) } /* - * Append a character to a message buffer. This function can be - * considered fully reentrant so long as the number of concurrent - * callers is less than the number of characters in the buffer. - * However, the message buffer is only guaranteed to be consistent - * for reading when there are no callers in this function. + * Add a character into the message buffer, and update the checksum and + * sequence number. + * + * The caller should hold the message buffer spinlock. + */ +static inline void +msgbuf_do_addchar(struct msgbuf *mbp, u_int *seq, int c) +{ + u_int pos; + + /* Make sure we properly wrap the sequence number. */ + pos = MSGBUF_SEQ_TO_POS(mbp, *seq); + + mbp->msg_cksum += (u_int)c - + (u_int)(u_char)mbp->msg_ptr[pos]; + + mbp->msg_ptr[pos] = c; + + *seq = MSGBUF_SEQNORM(mbp, *seq + 1); +} + +/* + * Append a character to a message buffer. */ void msgbuf_addchar(struct msgbuf *mbp, int c) { - u_int new_seq, pos, seq; + mtx_lock_spin(&mbp->msg_lock); + + msgbuf_do_addchar(mbp, &mbp->msg_wseq, c); + + mtx_unlock_spin(&mbp->msg_lock); +} + +/* + * Append a NUL-terminated string with a priority to a message buffer. + * Filter carriage returns if the caller requests it. + * + * XXX The carriage return filtering behavior is present in the + * msglogchar() API, however testing has shown that we don't seem to send + * carriage returns down this path. So do we still need it? + */ +void +msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int filter_cr) +{ + u_int seq; + size_t len, prefix_len; + char prefix[MAXPRIBUF]; + int nl, i; + + len = strlen(str); + prefix_len = 0; + nl = 0; + + /* If we have a zero-length string, no need to do anything. */ + if (len == 0) + return; + + mtx_lock_spin(&mbp->msg_lock); + + /* + * If this is true, we may need to insert a new priority sequence, + * so prepare the prefix. + */ + if (pri != -1) + prefix_len = sprintf(prefix, "<%d>", pri); + + /* + * Starting write sequence number. + */ + seq = mbp->msg_wseq; + + /* + * Whenever there is a change in priority, we have to insert a + * newline, and a priority prefix if the priority is not -1. Here + * we detect whether there was a priority change, and whether we + * did not end with a newline. If that is the case, we need to + * insert a newline before this string. + */ + if (mbp->msg_lastpri != pri && mbp->msg_needsnl != 0) { + + msgbuf_do_addchar(mbp, &seq, '\n'); + mbp->msg_needsnl = 0; + } + + for (i = 0; i < len; i++) { + /* + * If we just had a newline, and the priority is not -1 + * (and therefore prefix_len != 0), then we need a priority + * prefix for this line. + */ + if (mbp->msg_needsnl == 0 && prefix_len != 0) { + int j; + + for (j = 0; j < prefix_len; j++) + msgbuf_do_addchar(mbp, &seq, prefix[j]); + } + + /* + * Don't copy carriage returns if the caller requested + * filtering. + * + * XXX This matches the behavior of msglogchar(), but is it + * necessary? Testing has shown that we don't seem to get + * carriage returns here. + */ + if ((filter_cr != 0) && (str[i] == '\r')) + continue; + + /* + * Clear this flag if we see a newline. This affects whether + * we need to insert a new prefix or insert a newline later. + */ + if (str[i] == '\n') + mbp->msg_needsnl = 0; + else + mbp->msg_needsnl = 1; + + msgbuf_do_addchar(mbp, &seq, str[i]); + } + /* + * Update the write sequence number for the actual number of + * characters we put in the message buffer. (Depends on whether + * carriage returns are filtered.) + */ + mbp->msg_wseq = seq; + + /* + * Set the last priority. + */ + mbp->msg_lastpri = pri; + + mtx_unlock_spin(&mbp->msg_lock); - do { - seq = mbp->msg_wseq; - new_seq = MSGBUF_SEQNORM(mbp, seq + 1); - } while (atomic_cmpset_rel_int(&mbp->msg_wseq, seq, new_seq) == 0); - pos = MSGBUF_SEQ_TO_POS(mbp, seq); - atomic_add_int(&mbp->msg_cksum, (u_int)(u_char)c - - (u_int)(u_char)mbp->msg_ptr[pos]); - mbp->msg_ptr[pos] = c; } /* @@ -141,14 +272,21 @@ msgbuf_getchar(struct msgbuf *mbp) u_int len, wseq; int c; + mtx_lock_spin(&mbp->msg_lock); + wseq = mbp->msg_wseq; len = MSGBUF_SEQSUB(mbp, wseq, mbp->msg_rseq); - if (len == 0) + if (len == 0) { + mtx_unlock_spin(&mbp->msg_lock); return (-1); + } if (len > mbp->msg_size) mbp->msg_rseq = MSGBUF_SEQNORM(mbp, wseq - mbp->msg_size); c = (u_char)mbp->msg_ptr[MSGBUF_SEQ_TO_POS(mbp, mbp->msg_rseq)]; mbp->msg_rseq = MSGBUF_SEQNORM(mbp, mbp->msg_rseq + 1); + + mtx_unlock_spin(&mbp->msg_lock); + return (c); } @@ -161,10 +299,14 @@ msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen) { u_int len, pos, wseq; + mtx_lock_spin(&mbp->msg_lock); + wseq = mbp->msg_wseq; len = MSGBUF_SEQSUB(mbp, wseq, mbp->msg_rseq); - if (len == 0) + if (len == 0) { + mtx_unlock_spin(&mbp->msg_lock); return (0); + } if (len > mbp->msg_size) { mbp->msg_rseq = MSGBUF_SEQNORM(mbp, wseq - mbp->msg_size); len = mbp->msg_size; @@ -175,6 +317,9 @@ msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen) bcopy(&mbp->msg_ptr[pos], buf, len); mbp->msg_rseq = MSGBUF_SEQNORM(mbp, mbp->msg_rseq + len); + + mtx_unlock_spin(&mbp->msg_lock); + return (len); } @@ -193,16 +338,21 @@ msgbuf_peekbytes(struct msgbuf *mbp, char *buf, int buflen, u_int *seqp) { u_int len, pos, wseq; + mtx_lock_spin(&mbp->msg_lock); + if (buf == NULL) { /* Just initialise *seqp. */ *seqp = MSGBUF_SEQNORM(mbp, mbp->msg_wseq - mbp->msg_size); + mtx_unlock_spin(&mbp->msg_lock); return (0); } wseq = mbp->msg_wseq; len = MSGBUF_SEQSUB(mbp, wseq, *seqp); - if (len == 0) + if (len == 0) { + mtx_unlock_spin(&mbp->msg_lock); return (0); + } if (len > mbp->msg_size) { *seqp = MSGBUF_SEQNORM(mbp, wseq - mbp->msg_size); len = mbp->msg_size; @@ -212,6 +362,9 @@ msgbuf_peekbytes(struct msgbuf *mbp, char *buf, int buflen, u_int *seqp) len = min(len, (u_int)buflen); bcopy(&mbp->msg_ptr[MSGBUF_SEQ_TO_POS(mbp, *seqp)], buf, len); *seqp = MSGBUF_SEQNORM(mbp, *seqp + len); + + mtx_unlock_spin(&mbp->msg_lock); + return (len); } diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c index 9201bb7e8cfc..a6b3ae09defc 100644 --- a/sys/kern/subr_pcpu.c +++ b/sys/kern/subr_pcpu.c @@ -74,7 +74,7 @@ static TAILQ_HEAD(, dpcpu_free) dpcpu_head = TAILQ_HEAD_INITIALIZER(dpcpu_head); static struct sx dpcpu_lock; uintptr_t dpcpu_off[MAXCPU]; struct pcpu *cpuid_to_pcpu[MAXCPU]; -struct cpuhead cpuhead = SLIST_HEAD_INITIALIZER(cpuhead); +struct cpuhead cpuhead = STAILQ_HEAD_INITIALIZER(cpuhead); /* * Initialize the MI portions of a struct pcpu. @@ -89,7 +89,7 @@ pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) pcpu->pc_cpuid = cpuid; CPU_SETOF(cpuid, &pcpu->pc_cpumask); cpuid_to_pcpu[cpuid] = pcpu; - SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu); + STAILQ_INSERT_TAIL(&cpuhead, pcpu, pc_allcpu); cpu_pcpu_init(pcpu, cpuid, size); pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue; pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue; @@ -245,7 +245,7 @@ void pcpu_destroy(struct pcpu *pcpu) { - SLIST_REMOVE(&cpuhead, pcpu, pcpu, pc_allcpu); + STAILQ_REMOVE(&cpuhead, pcpu, pcpu, pc_allcpu); cpuid_to_pcpu[pcpu->pc_cpuid] = NULL; dpcpu_off[pcpu->pc_cpuid] = 0; } diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index d0d2ad7f3614..3334837747f5 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -94,6 +94,7 @@ struct snprintf_arg { extern int log_open; static void msglogchar(int c, int pri); +static void msglogstr(char *str, int pri, int filter_cr); static void putchar(int ch, void *arg); static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len, int upper); static void snprintf_func(int ch, void *arg); @@ -106,6 +107,14 @@ TUNABLE_INT("kern.log_console_output", &log_console_output); SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RW, &log_console_output, 0, "Duplicate console output to the syslog."); +/* + * See the comment in log_console() below for more explanation of this. + */ +static int log_console_add_linefeed = 0; +TUNABLE_INT("kern.log_console_add_linefeed", &log_console_add_linefeed); +SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RW, + &log_console_add_linefeed, 0, "log_console() adds extra newlines."); + static int always_console_output = 0; TUNABLE_INT("kern.always_console_output", &always_console_output); SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RW, @@ -240,16 +249,37 @@ log(int level, const char *fmt, ...) { va_list ap; struct putchar_arg pca; +#ifdef PRINTF_BUFR_SIZE + char bufr[PRINTF_BUFR_SIZE]; +#endif pca.tty = NULL; pca.pri = level; pca.flags = log_open ? TOLOG : TOCONS; +#ifdef PRINTF_BUFR_SIZE + pca.p_bufr = bufr; + pca.p_next = pca.p_bufr; + pca.n_bufr = sizeof(bufr); + pca.remain = sizeof(bufr); + *pca.p_next = '\0'; +#else pca.p_bufr = NULL; +#endif va_start(ap, fmt); kvprintf(fmt, putchar, &pca, 10, ap); va_end(ap); +#ifdef PRINTF_BUFR_SIZE + /* Write any buffered console/log output: */ + if (*pca.p_bufr != '\0') { + if (pca.flags & TOLOG) + msglogstr(pca.p_bufr, level, /*filter_cr*/1); + + if (pca.flags & TOCONS) + cnputs(pca.p_bufr); + } +#endif msgbuftrigger = 1; } @@ -258,7 +288,7 @@ log(int level, const char *fmt, ...) void log_console(struct uio *uio) { - int c, i, error, nl; + int c, error, nl; char *consbuffer; int pri; @@ -271,20 +301,48 @@ log_console(struct uio *uio) nl = 0; while (uio->uio_resid > 0) { - c = imin(uio->uio_resid, CONSCHUNK); + c = imin(uio->uio_resid, CONSCHUNK - 1); error = uiomove(consbuffer, c, uio); if (error != 0) break; - for (i = 0; i < c; i++) { - msglogchar(consbuffer[i], pri); - if (consbuffer[i] == '\n') - nl = 1; - else - nl = 0; - } + /* Make sure we're NUL-terminated */ + consbuffer[c] = '\0'; + if (consbuffer[c - 1] == '\n') + nl = 1; + else + nl = 0; + msglogstr(consbuffer, pri, /*filter_cr*/ 1); + } + /* + * The previous behavior in log_console() is preserved when + * log_console_add_linefeed is non-zero. For that behavior, if an + * individual console write came in that was not terminated with a + * line feed, it would add a line feed. + * + * This results in different data in the message buffer than + * appears on the system console (which doesn't add extra line feed + * characters). + * + * A number of programs and rc scripts write a line feed, or a period + * and a line feed when they have completed their operation. On + * the console, this looks seamless, but when displayed with + * 'dmesg -a', you wind up with output that looks like this: + * + * Updating motd: + * . + * + * On the console, it looks like this: + * Updating motd:. + * + * We could add logic to detect that situation, or just not insert + * the extra newlines. Set the kern.log_console_add_linefeed + * sysctl/tunable variable to get the old behavior. + */ + if (!nl && log_console_add_linefeed) { + consbuffer[0] = '\n'; + consbuffer[1] = '\0'; + msglogstr(consbuffer, pri, /*filter_cr*/ 1); } - if (!nl) - msglogchar('\n', pri); msgbuftrigger = 1; free(uio, M_IOV); free(consbuffer, M_TEMP); @@ -330,9 +388,11 @@ vprintf(const char *fmt, va_list ap) retval = kvprintf(fmt, putchar, &pca, 10, ap); #ifdef PRINTF_BUFR_SIZE - /* Write any buffered console output: */ - if (*pca.p_bufr != '\0') + /* Write any buffered console/log output: */ + if (*pca.p_bufr != '\0') { cnputs(pca.p_bufr); + msglogstr(pca.p_bufr, pca.pri, /*filter_cr*/ 1); + } #endif if (!panicstr) @@ -342,18 +402,18 @@ vprintf(const char *fmt, va_list ap) } static void -putcons(int c, struct putchar_arg *ap) +putbuf(int c, struct putchar_arg *ap) { /* Check if no console output buffer was provided. */ - if (ap->p_bufr == NULL) + if (ap->p_bufr == NULL) { /* Output direct to the console. */ - cnputc(c); - else { + if (ap->flags & TOCONS) + cnputc(c); + + if (ap->flags & TOLOG) + msglogchar(c, ap->pri); + } else { /* Buffer the character: */ - if (c == '\n') { - *ap->p_next++ = '\r'; - ap->remain--; - } *ap->p_next++ = c; ap->remain--; @@ -361,12 +421,35 @@ putcons(int c, struct putchar_arg *ap) *ap->p_next = '\0'; /* Check if the buffer needs to be flushed. */ - if (ap->remain < 3 || c == '\n') { - cnputs(ap->p_bufr); + if (ap->remain == 2 || c == '\n') { + + if (ap->flags & TOLOG) + msglogstr(ap->p_bufr, ap->pri, /*filter_cr*/1); + + if (ap->flags & TOCONS) { + if ((panicstr == NULL) && (constty != NULL)) + msgbuf_addstr(&consmsgbuf, -1, + ap->p_bufr, /*filter_cr*/ 0); + + if ((constty == NULL) ||(always_console_output)) + cnputs(ap->p_bufr); + } + ap->p_next = ap->p_bufr; ap->remain = ap->n_bufr; *ap->p_next = '\0'; } + + /* + * Since we fill the buffer up one character at a time, + * this should not happen. We should always catch it when + * ap->remain == 2 (if not sooner due to a newline), flush + * the buffer and move on. One way this could happen is + * if someone sets PRINTF_BUFR_SIZE to 1 or something + * similarly silly. + */ + KASSERT(ap->remain > 2, ("Bad buffer logic, remain = %zd", + ap->remain)); } } @@ -381,26 +464,25 @@ putchar(int c, void *arg) struct putchar_arg *ap = (struct putchar_arg*) arg; struct tty *tp = ap->tty; int flags = ap->flags; + int putbuf_done = 0; /* Don't use the tty code after a panic or while in ddb. */ if (kdb_active) { if (c != '\0') cnputc(c); - } else if (panicstr || ((flags & TOCONS) && constty == NULL)) { - if (c != '\0') - putcons(c, ap); } else { - if ((flags & TOTTY) && tp != NULL) + if ((panicstr == NULL) && (flags & TOTTY) && (tp != NULL)) tty_putchar(tp, c); + if (flags & TOCONS) { - if (constty != NULL) - msgbuf_addchar(&consmsgbuf, c); - if (always_console_output && c != '\0') - putcons(c, ap); + putbuf(c, ap); + putbuf_done = 1; } } - if ((flags & TOLOG)) - msglogchar(c, ap->pri); + if ((flags & TOLOG) && (putbuf_done == 0)) { + if (c != '\0') + putbuf(c, ap); + } } /* @@ -890,6 +972,15 @@ msglogchar(int c, int pri) } } +static void +msglogstr(char *str, int pri, int filter_cr) +{ + if (!msgbufmapped) + return; + + msgbuf_addstr(msgbufp, pri, str, filter_cr); +} + void msgbufinit(void *ptr, int size) { diff --git a/sys/mips/mips/mp_machdep.c b/sys/mips/mips/mp_machdep.c index 8c93bd134fcc..79a3476a7784 100644 --- a/sys/mips/mips/mp_machdep.c +++ b/sys/mips/mips/mp_machdep.c @@ -85,7 +85,7 @@ ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) { CTR3(KTR_SMP, "%s: pc: %p, ipi: %x\n", __func__, pc, ipi); diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 67ec16014c32..127cf67706f4 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -1221,7 +1221,7 @@ netisr_start(void *arg) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (nws_count >= netisr_maxthreads) break; /* XXXRW: Is skipping absent CPUs still required here? */ diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 81fce092caba..e1cd071db40d 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -391,7 +391,7 @@ tlb_miss_lock(void) if (!smp_started) return; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc != pcpup) { CTR3(KTR_PMAP, "%s: tlb miss LOCK of CPU=%d, " @@ -417,7 +417,7 @@ tlb_miss_unlock(void) if (!smp_started) return; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc != pcpup) { CTR2(KTR_PMAP, "%s: tlb miss UNLOCK of CPU=%d", __func__, pc->pc_cpuid); diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index 2e2fe24c1c13..62a97e925050 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -213,7 +213,7 @@ cpu_mp_unleash(void *dummy) cpus = 0; smp_cpus = 0; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { cpus++; pc->pc_other_cpus = all_cpus; CPU_NAND(&pc->pc_other_cpus, &pc->pc_cpumask); @@ -349,7 +349,7 @@ ipi_selected(cpuset_t cpus, int ipi) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (CPU_OVERLAP(&cpus, &pc->pc_cpumask)) ipi_send(pc, ipi); } @@ -369,7 +369,7 @@ ipi_all_but_self(int ipi) { struct pcpu *pc; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc != pcpup) ipi_send(pc, ipi); } diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 7edc3a33014a..304a0f39d17e 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -386,7 +386,7 @@ cpu_mp_unleash(void *v) ctx_inc = (TLB_CTX_USER_MAX - 1) / mp_ncpus; csa = &cpu_start_args; csa->csa_count = mp_ncpus; - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { pc->pc_tlb_ctx = ctx_min; pc->pc_tlb_ctx_min = ctx_min; pc->pc_tlb_ctx_max = ctx_min + ctx_inc; diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index 49eeae6b6ba6..b01a558c3b24 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -1278,7 +1278,7 @@ pmap_release(pmap_t pm) * to a kernel thread, leaving the pmap pointer unchanged. */ mtx_lock_spin(&sched_lock); - SLIST_FOREACH(pc, &cpuhead, pc_allcpu) + STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) if (pc->pc_pmap == pm) pc->pc_pmap = NULL; mtx_unlock_spin(&sched_lock); diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h index 8435c6874532..67f80a55196a 100644 --- a/sys/sys/msgbuf.h +++ b/sys/sys/msgbuf.h @@ -33,15 +33,21 @@ #ifndef _SYS_MSGBUF_H_ #define _SYS_MSGBUF_H_ +#include +#include + struct msgbuf { - char *msg_ptr; /* pointer to buffer */ + char *msg_ptr; /* pointer to buffer */ #define MSG_MAGIC 0x063062 - u_int msg_magic; - u_int msg_size; /* size of buffer area */ - u_int msg_wseq; /* write sequence number */ - u_int msg_rseq; /* read sequence number */ - u_int msg_cksum; /* checksum of contents */ - u_int msg_seqmod; /* range for sequence numbers */ + u_int msg_magic; + u_int msg_size; /* size of buffer area */ + u_int msg_wseq; /* write sequence number */ + u_int msg_rseq; /* read sequence number */ + u_int msg_cksum; /* checksum of contents */ + u_int msg_seqmod; /* range for sequence numbers */ + int msg_lastpri; /* saved priority value */ + int msg_needsnl; /* set when newline needed */ + struct mtx msg_lock; /* mutex to protect the buffer */ }; /* Normalise a sequence number or a difference between sequence numbers. */ @@ -59,6 +65,7 @@ extern struct mtx msgbuf_lock; void msgbufinit(void *ptr, int size); void msgbuf_addchar(struct msgbuf *mbp, int c); +void msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int filter_cr); void msgbuf_clear(struct msgbuf *mbp); void msgbuf_copy(struct msgbuf *src, struct msgbuf *dst); int msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen); diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index 752d2dfbec0c..e6044a7a57b6 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -163,7 +163,7 @@ struct pcpu { uint64_t pc_switchtime; /* cpu_ticks() at last csw */ int pc_switchticks; /* `ticks' at last csw */ u_int pc_cpuid; /* This cpu number */ - SLIST_ENTRY(pcpu) pc_allcpu; + STAILQ_ENTRY(pcpu) pc_allcpu; struct lock_list_entry *pc_spinlocks; #ifdef KTR char pc_name[PCPU_NAME_LEN]; /* String name for KTR */ @@ -212,7 +212,7 @@ struct pcpu { #ifdef _KERNEL -SLIST_HEAD(cpuhead, pcpu); +STAILQ_HEAD(cpuhead, pcpu); extern struct cpuhead cpuhead; extern struct pcpu *cpuid_to_pcpu[MAXCPU]; diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh index 2d2a4e797a22..c3e96b3f5cdc 100644 --- a/tools/tools/nanobsd/nanobsd.sh +++ b/tools/tools/nanobsd/nanobsd.sh @@ -418,7 +418,7 @@ populate_slice ( ) ( echo "Creating ${dev} with ${dir} (mounting on ${mnt})" newfs_part $dev $mnt $lbl cd ${dir} - find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${mnt} + find . -print | grep -Ev '/(CVS|\.svn)' | cpio -dumpv ${mnt} df -i ${mnt} umount ${mnt} ) diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 989a5ae14d2c..e2954c88a0bf 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -155,7 +155,7 @@ static struct cmd cmdtab[] = { { "options", setoptions, "enable or disable RFC2347 style options" }, { "help", help, "print help information" }, - { "packetdrop", setpacketdrop, "artifical packetloss feature" }, + { "packetdrop", setpacketdrop, "artificial packetloss feature" }, { "?", help, "print help information" }, { NULL, NULL, NULL } }; @@ -955,7 +955,7 @@ setblocksize(int argc, char *argv[]) if (!options_rfc_enabled) printf("RFC2347 style options are not enabled " - "(but proceding anyway)\n"); + "(but proceeding anyway)\n"); if (argc != 1) { int size = atoi(argv[1]); @@ -993,7 +993,7 @@ setblocksize2(int argc, char *argv[]) if (!options_rfc_enabled || !options_extra_enabled) printf( "RFC2347 style or non-RFC defined options are not enabled " - "(but proceding anyway)\n"); + "(but proceeding anyway)\n"); if (argc != 1) { int size = atoi(argv[1]); diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index f98f64eb766b..4c5568249d40 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -624,6 +624,7 @@ get_process_info(struct system_info *si, struct process_select *sel, int show_system; int show_uid; int show_command; + int show_kidle; /* * Save the previous process info. @@ -664,6 +665,7 @@ get_process_info(struct system_info *si, struct process_select *sel, show_system = sel->system; show_uid = sel->uid != -1; show_command = sel->command != NULL; + show_kidle = sel->kidle; /* count up process states and get pointers to interesting procs */ total_procs = 0; @@ -705,6 +707,11 @@ get_process_info(struct system_info *si, struct process_select *sel, /* skip idle or non-running processes */ continue; + if (displaymode == DISP_CPU && !show_kidle && + pp->ki_tdflags & TDF_IDLETD) + /* skip kernel idle process */ + continue; + if (displaymode == DISP_IO && !show_idle && p_io == 0) /* skip processes that aren't doing I/O */ continue; diff --git a/usr.bin/top/top.local.1 b/usr.bin/top/top.local.1 index d7705e8a96c4..015b969b7251 100644 --- a/usr.bin/top/top.local.1 +++ b/usr.bin/top/top.local.1 @@ -1,10 +1,6 @@ .\" $FreeBSD$ .SH "FreeBSD NOTES" -.SH DISPLAY OF THREADS -The '-H' option will toggle the display of kernel visible thread contexts. -At runtime the 'H' key will toggle this mode. The default is OFF. - .SH DESCRIPTION OF MEMORY Mem: 9220K Active, 1M Inact, 3284K Wired, 1M Cache, 2M Buf, 1320K Free Swap: 91M Total, 79M Free, 13% Inuse, 80K In, 104K Out diff --git a/usr.sbin/pc-sysinstall/backend-query/enable-net.sh b/usr.sbin/pc-sysinstall/backend-query/enable-net.sh index 3c73550fa59e..8cd72a1bc5e7 100755 --- a/usr.sbin/pc-sysinstall/backend-query/enable-net.sh +++ b/usr.sbin/pc-sysinstall/backend-query/enable-net.sh @@ -1,6 +1,11 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. All rights reserved. +# Copyright (c) 2011 The FreeBSD Foundation +# All rights reserved. +# +# Portions of this software were developed by Bjoern Zeeb +# under sponsorship from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -40,23 +45,67 @@ NETMASK="$3" DNS="$4" GATEWAY="$5" MIRRORFETCH="$6" +IPV6="$7" +IPV6GATE="$8" +IPV6DNS="$9" if [ -z "${NIC}" ] then - echo "ERROR: Usage enable-net " + echo "ERROR: Usage enable-net " \ + " " exit 150 fi if [ "$NIC" = "AUTO-DHCP" ] then enable_auto_dhcp +elif [ "$NIC" = "IPv6-SLAAC" ] +then + enable_auto_slaac + # In addition, if static values were defined, add them as well. + # We might not get DNS information from RAs, for example. + if [ -n "${IPV6}" ]; then + VAL="" + get_first_wired_nic + if [ -n "${VAL}" ]; then + ifconfig ${VAL} inet6 ${IPV6} alias + fi + fi + # Append only here. + if [ -n "${IPV6DNS}" ]; then + echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf + fi + # Do not + if [ -n "${IPV6GATE}" ]; then + # Check if we have a default route already to not overwrite. + if ! route -n get -inet6 default > /dev/null 2>&1 ; then + route add -inet6 default ${IPV6GATE} + fi + fi else echo "Enabling NIC: $NIC" - ifconfig ${NIC} ${IP} ${NETMASK} + if [ -n "${IP}" ]; then + ifconfig ${NIC} inet ${IP} ${NETMASK} + fi + if [ -n "${IPV6}" ]; then + ifconfig ${NIC} inet6 ${IPV6} alias + fi - echo "nameserver ${DNS}" >/etc/resolv.conf + # Keep default from IPv4-only support times and clear the resolv.conf file. + : > /etc/resolv.conf + if [ -n "${DNS}" ]; then + echo "nameserver ${DNS}" >>/etc/resolv.conf + fi + if [ -n "${IPV6DNS}" ]; then + echo "nameserver ${IPV6DNS}" >>/etc/resolv.conf + fi - route add default ${GATE} + if [ -n "${GATE}" ]; then + route add -inet default ${GATE} + fi + if [ -n "${IPV6GATE}" ]; then + route add -inet6 default ${IPV6GATE} + fi fi case ${MIRRORFETCH} in diff --git a/usr.sbin/pc-sysinstall/backend-query/test-netup.sh b/usr.sbin/pc-sysinstall/backend-query/test-netup.sh index 4c8304ef7416..e0a3ebae0bb6 100755 --- a/usr.sbin/pc-sysinstall/backend-query/test-netup.sh +++ b/usr.sbin/pc-sysinstall/backend-query/test-netup.sh @@ -1,6 +1,11 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. All rights reserved. +# Copyright (c) 2011 The FreeBSD Foundation +# All rights reserved. +# +# Portions of this software were developed by Bjoern Zeeb +# under sponsorship from the FreeBSD Foundation.# # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -26,8 +31,8 @@ # $FreeBSD$ -# Script which tests "fetch" when using a network connection, and saves -# if we are using direct connect, or need FTP passive mode +# Script which tries to ping "home" to see if Internet connectivity is +# available. ############################################################################# rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null @@ -39,12 +44,26 @@ then exit 0 fi +ping6 -c 2 www.pcbsd.org >/dev/null 2>/dev/null +if [ "$?" = "0" ] +then + echo "ftp: Up" + exit 0 +fi + ping -c 2 www.freebsd.org >/dev/null 2>/dev/null if [ "$?" = "0" ] then echo "ftp: Up" exit 0 fi - + +ping6 -c 2 www.freebsd.org >/dev/null 2>/dev/null +if [ "$?" = "0" ] +then + echo "ftp: Up" + exit 0 +fi + echo "ftp: Down" exit 1 diff --git a/usr.sbin/pc-sysinstall/backend/functions-networking.sh b/usr.sbin/pc-sysinstall/backend/functions-networking.sh index d12a9cceb3a0..bdd5a1a84c16 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-networking.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-networking.sh @@ -1,6 +1,11 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. All rights reserved. +# Copyright (c) 2011 The FreeBSD Foundation +# All rights reserved. +# +# Portions of this software were developed by Bjoern Zeeb +# under sponsorship from the FreeBSD Foundation. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -119,6 +124,61 @@ save_auto_dhcp() enable_dhcp_all }; +# Function which simply enables iPv6 SLAAC on all detected nics +enable_slaac_all() +{ + rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null + # start by getting a list of nics on this system + ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist + if [ -e "${TMPDIR}/.niclist" ] + then + echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf + WLANCOUNT="0" + while read line + do + NIC="`echo $line | cut -d ':' -f 1`" + DESC="`echo $line | cut -d ':' -f 2`" + echo_log "Setting $NIC to acceptign RAs on the system." + check_is_wifi ${NIC} + if [ $? -eq 0 ] + then + # We have a wifi device, setup a wlan* entry for it + # Given we cannot have DHCP and SLAAC the same time currently + # it's save to just duplicate. + WLAN="wlan${WLANCOUNT}" + echo "wlans_${NIC}=\"${WLAN}\"" >>${FSMNT}/etc/rc.conf + #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf + echo "ifconfig_${WLAN}=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf + CNIC="${WLAN}" + WLANCOUNT=$((WLANCOUNT+1)) + else + #echo "ifconfig_${NIC}=\"up\"" >>${FSMNT}/etc/rc.conf + echo "ifconfig_${NIC}_ipv6=\"inet6 accept_rtadv\"" >>${FSMNT}/etc/rc.conf + CNIC="${NIC}" + fi + + done < ${TMPDIR}/.niclist + fi + + # Given we cannot yet rely on RAs to provide DNS information as much + # as we can in the DHCP world, we should append a given nameserver. + : > ${FSMNT}/etc/resolv.conf + get_value_from_cfg netSaveIPv6NameServer + NAMESERVER="${VAL}" + if [ -n "${NAMESERVER}" ] + then + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + fi + +}; + + +# Function which detects available nics, and enables IPv6 SLAAC on them +save_auto_slaac() +{ + enable_slaac_all +}; + # Function which saves a manual nic setup to the installed system save_manual_nic() @@ -137,21 +197,41 @@ save_manual_nic() fi # If we get here, we have a manual setup, lets do so now + IFARGS="" + IF6ARGS="" # Set the manual IP - IFARGS="inet ${NETIP}" - - # Check if we have a netmask to set - get_value_from_cfg netSaveMask - NETMASK="${VAL}" - if [ -n "${NETMASK}" ] + if [ -n "${NETIP}" ] then - IFARGS="${IFARGS} netmask ${NETMASK}" + IFARGS="inet ${NETIP}" + + # Check if we have a netmask to set + get_value_from_cfg netSaveMask + NETMASK="${VAL}" + if [ -n "${NETMASK}" ] + then + IFARGS="${IFARGS} netmask ${NETMASK}" + fi fi + get_value_from_cfg netSaveIPv6 + NETIP6="${VAL}" + if [ -n "${NETIP6}" ] + then + # Make sure we have one inet6 prefix. + IF6ARGS=`echo "${NETIP6}" | awk '{ if ("^inet6 ") { print $0; } else + { printf "inet6 %s", $0; } }'` + fi echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf - echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf + if [ -n "${IFARGS}" ] + then + echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf + fi + if [ -n "${IF6ARGS}" ] + then + echo "ifconfig_${NIC}_ipv6=\"${IF6ARGS}\"" >>${FSMNT}/etc/rc.conf + fi # Check if we have a default router to set get_value_from_cfg netSaveDefaultRouter @@ -160,15 +240,28 @@ save_manual_nic() then echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf fi + get_value_from_cfg netSaveIPv6DefaultRouter + NETROUTE="${VAL}" + if [ -n "${NETROUTE}" ] + then + echo "ipv6_defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf + fi # Check if we have a nameserver to enable + : > ${FSMNT}/etc/resolv.conf get_value_from_cfg netSaveNameServer NAMESERVER="${VAL}" if [ -n "${NAMESERVER}" ] then - echo "nameserver ${NAMESERVER}" >${FSMNT}/etc/resolv.conf + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf fi - + get_value_from_cfg netSaveIPv6NameServer + NAMESERVER="${VAL}" + if [ -n "${NAMESERVER}" ] + then + echo "nameserver ${NAMESERVER}" >>${FSMNT}/etc/resolv.conf + fi + }; # Function which determines if a nic is active / up @@ -208,6 +301,31 @@ enable_auto_dhcp() }; +# Function which detects available nics, and runs rtsol on them. +enable_auto_slaac() +{ + + # start by getting a list of nics on this system + ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist + ALLNICS="" + while read line + do + NIC="`echo $line | cut -d ':' -f 1`" + DESC="`echo $line | cut -d ':' -f 2`" + + is_nic_active "${NIC}" + if [ $? -eq 0 ] ; then + echo_log "Will try IPv6 SLAAC on $NIC $DESC" + ifconfig ${NIC} inet6 -ifdisabled accept_rtadv up + ALLNICS="${ALLNICS} ${NIC}" + fi + done < ${TMPDIR}/.niclist + + # XXX once we support it in-tree call /sbin/resovconf here. + echo_log "Running rtsol on ${ALLNICS}" + rtsol -F ${ALLNICS} >/dev/null 2>/dev/null +} + # Get the mac address of a target NIC get_nic_mac() { @@ -236,15 +354,20 @@ enable_manual_nic() # If we get here, we have a manual setup, lets do so now - # Set the manual IP - rc_halt "ifconfig ${NIC} ${NETIP}" + # IPv4: - # Check if we have a netmask to set - get_value_from_cfg netMask - NETMASK="${VAL}" - if [ -n "${NETMASK}" ] + # Set the manual IP + if [ -n "${NETIP}" ] then - rc_halt "ifconfig ${NIC} netmask ${NETMASK}" + # Check if we have a netmask to set + get_value_from_cfg netMask + NETMASK="${VAL}" + if [ -n "${NETMASK}" ] + then + rc_halt "ifconfig inet ${NIC} netmask ${NETMASK}" + else + rc_halt "ifconfig inet ${NIC} ${NETIP}" + fi fi # Check if we have a default router to set @@ -252,18 +375,42 @@ enable_manual_nic() NETROUTE="${VAL}" if [ -n "${NETROUTE}" ] then - rc_halt "route add default ${NETROUTE}" + rc_halt "route add -inet default ${NETROUTE}" + fi + + # IPv6: + + # Set static IPv6 address + get_value_from_cfg netIPv6 + NETIP="${VAL}" + if [ -n ${NETIP} ] + then + rc_halt "ifconfig inet6 ${NIC} ${NETIP} -ifdisabled up" + fi + + # Default router + get_value_from_cfg netIPv6DefaultRouter + NETROUTE="${VAL}" + if [ -n "${NETROUTE}" ] + then + rc_halt "route add -inet6 default ${NETROUTE}" fi # Check if we have a nameserver to enable + : >/etc/resolv.conf get_value_from_cfg netNameServer NAMESERVER="${VAL}" if [ -n "${NAMESERVER}" ] then - echo "nameserver ${NAMESERVER}" >/etc/resolv.conf + echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf fi - - + get_value_from_cfg netIPv6NameServer + NAMESERVER="${VAL}" + if [ -n "${NAMESERVER}" ] + then + echo "nameserver ${NAMESERVER}" >>/etc/resolv.conf + fi + }; @@ -281,6 +428,9 @@ start_networking() if [ "$NETDEV" = "AUTO-DHCP" ] then enable_auto_dhcp + elif [ "$NETDEV" = "IPv6-SLAAC" ] + then + enable_auto_slaac else enable_manual_nic ${NETDEV} fi @@ -304,6 +454,9 @@ save_networking_install() if [ "$NETDEV" = "AUTO-DHCP" ] then save_auto_dhcp + elif [ "$NETDEV" = "IPv6-SLAAC" ] + then + save_auto_slaac else save_manual_nic ${NETDEV} fi From 3b39b1682d02b7a4dd7244c6d9740a5fcedf1bac Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 31 May 2011 21:42:34 +0000 Subject: [PATCH 078/164] Revert mismerge --- tools/build/options/WITH_OFED | 2 +- tools/regression/bin/sh/builtins/set1.0 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build/options/WITH_OFED b/tools/build/options/WITH_OFED index 6d9c0a1908d3..a995fb8cdab8 100644 --- a/tools/build/options/WITH_OFED +++ b/tools/build/options/WITH_OFED @@ -1,4 +1,4 @@ -.\" $FreeBSD: projects/largeSMP/tools/build/options/WITH_OFED 222016 2011-05-17 11:06:41Z ru $ +.\" $FreeBSD$ Set to build the .Dq "OpenFabrics Enterprise Distribution" Infiniband software stack. diff --git a/tools/regression/bin/sh/builtins/set1.0 b/tools/regression/bin/sh/builtins/set1.0 index 0043f45aedd5..fc39fade6270 100644 --- a/tools/regression/bin/sh/builtins/set1.0 +++ b/tools/regression/bin/sh/builtins/set1.0 @@ -1,4 +1,4 @@ -# $FreeBSD: projects/largeSMP/tools/regression/bin/sh/builtins/set1.0 222451 2011-05-29 15:02:10Z jilles $ +# $FreeBSD$ set +C set +f From 9f19c1c64d9f7305791ee510b9aa500748aa0fe8 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 1 Jun 2011 16:54:33 +0000 Subject: [PATCH 079/164] MFC --- .../binutils/ld/emulparams/elf64bmip-defs.sh | 10 +- sys/dev/cxgbe/t4_main.c | 171 +++++++++++++++++- sys/kern/subr_msgbuf.c | 2 + sys/netinet/ipfw/ip_dummynet.c | 10 +- sys/netinet/ipfw/ip_fw_dynamic.c | 3 +- usr.sbin/kbdmap/kbdmap.c | 2 +- 6 files changed, 189 insertions(+), 9 deletions(-) diff --git a/contrib/binutils/ld/emulparams/elf64bmip-defs.sh b/contrib/binutils/ld/emulparams/elf64bmip-defs.sh index 110f8929de1a..73094be08593 100644 --- a/contrib/binutils/ld/emulparams/elf64bmip-defs.sh +++ b/contrib/binutils/ld/emulparams/elf64bmip-defs.sh @@ -1,3 +1,11 @@ . ${srcdir}/emulparams/elf32bmipn32-defs.sh COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -INITIAL_READONLY_SECTIONS=".MIPS.options : { *(.MIPS.options) }" + +# elf32bmipn32-defs.sh use .reginfo, n64 ABI should use .MIPS.options, +# override INITIAL_READONLY_SECTIONS to do this. +INITIAL_READONLY_SECTIONS= +if test -z "${CREATE_SHLIB}"; then + INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" +fi +INITIAL_READONLY_SECTIONS="${INITIAL_READONLY_SECTIONS} + .MIPS.options ${RELOCATING-0} : { *(.MIPS.options) }" diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index ec72d04cdb9e..165a677ee426 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -271,6 +271,7 @@ static void setup_memwin(struct adapter *); static int cfg_itype_and_nqueues(struct adapter *, int, int, struct intrs_and_queues *); static int prep_firmware(struct adapter *); +static int get_devlog_params(struct adapter *, struct devlog_params *); static int get_capabilities(struct adapter *, struct fw_caps_config_cmd *); static int get_params(struct adapter *, struct fw_caps_config_cmd *); static void t4_set_desc(struct adapter *); @@ -297,12 +298,14 @@ static int sysctl_holdoff_pktc_idx(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_rxq(SYSCTL_HANDLER_ARGS); static int sysctl_qsize_txq(SYSCTL_HANDLER_ARGS); static int sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS); +static int sysctl_devlog(SYSCTL_HANDLER_ARGS); static inline void txq_start(struct ifnet *, struct sge_txq *); static uint32_t fconf_to_mode(uint32_t); static uint32_t mode_to_fconf(uint32_t); static uint32_t fspec_to_fconf(struct t4_filter_specification *); static int get_filter_mode(struct adapter *, uint32_t *); static int set_filter_mode(struct adapter *, uint32_t); +static inline uint64_t get_filter_hits(struct adapter *, uint32_t); static int get_filter(struct adapter *, struct t4_filter *); static int set_filter(struct adapter *, struct t4_filter *); static int del_filter(struct adapter *, struct t4_filter *); @@ -402,6 +405,9 @@ t4_attach(device_t dev) if (rc != 0) goto done; /* error message displayed already */ + /* Read firmware devlog parameters */ + (void) get_devlog_params(sc, &sc->params.devlog); + /* Get device capabilities and select which ones we'll use */ rc = get_capabilities(sc, &caps); if (rc != 0) { @@ -1419,6 +1425,34 @@ prep_firmware(struct adapter *sc) return (0); } +static int +get_devlog_params(struct adapter *sc, struct devlog_params *dlog) +{ + struct fw_devlog_cmd devlog_cmd; + uint32_t meminfo; + int rc; + + bzero(&devlog_cmd, sizeof(devlog_cmd)); + devlog_cmd.op_to_write = htobe32(V_FW_CMD_OP(FW_DEVLOG_CMD) | + F_FW_CMD_REQUEST | F_FW_CMD_READ); + devlog_cmd.retval_len16 = htobe32(FW_LEN16(devlog_cmd)); + rc = -t4_wr_mbox(sc, sc->mbox, &devlog_cmd, sizeof(devlog_cmd), + &devlog_cmd); + if (rc != 0) { + device_printf(sc->dev, + "failed to get devlog parameters: %d.\n", rc); + bzero(dlog, sizeof (*dlog)); + return (rc); + } + + meminfo = be32toh(devlog_cmd.memtype_devlog_memaddr16_devlog); + dlog->memtype = G_FW_DEVLOG_CMD_MEMTYPE_DEVLOG(meminfo); + dlog->start = G_FW_DEVLOG_CMD_MEMADDR16_DEVLOG(meminfo) << 4; + dlog->size = be32toh(devlog_cmd.memsize_devlog); + + return (0); +} + static int get_capabilities(struct adapter *sc, struct fw_caps_config_cmd *caps) { @@ -2387,6 +2421,10 @@ t4_sysctls(struct adapter *sc) CTLTYPE_STRING | CTLFLAG_RD, &intr_pktcount, sizeof(intr_pktcount), sysctl_int_array, "A", "interrupt holdoff packet counter values"); + SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "devlog", + CTLTYPE_STRING | CTLFLAG_RD, sc, 0, + sysctl_devlog, "A", "device log"); + return (0); } @@ -2730,6 +2768,120 @@ sysctl_handle_t4_reg64(SYSCTL_HANDLER_ARGS) return (sysctl_handle_64(oidp, &val, 0, req)); } +const char *devlog_level_strings[] = { + [FW_DEVLOG_LEVEL_EMERG] = "EMERG", + [FW_DEVLOG_LEVEL_CRIT] = "CRIT", + [FW_DEVLOG_LEVEL_ERR] = "ERR", + [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE", + [FW_DEVLOG_LEVEL_INFO] = "INFO", + [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG" +}; + +const char *devlog_facility_strings[] = { + [FW_DEVLOG_FACILITY_CORE] = "CORE", + [FW_DEVLOG_FACILITY_SCHED] = "SCHED", + [FW_DEVLOG_FACILITY_TIMER] = "TIMER", + [FW_DEVLOG_FACILITY_RES] = "RES", + [FW_DEVLOG_FACILITY_HW] = "HW", + [FW_DEVLOG_FACILITY_FLR] = "FLR", + [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ", + [FW_DEVLOG_FACILITY_PHY] = "PHY", + [FW_DEVLOG_FACILITY_MAC] = "MAC", + [FW_DEVLOG_FACILITY_PORT] = "PORT", + [FW_DEVLOG_FACILITY_VI] = "VI", + [FW_DEVLOG_FACILITY_FILTER] = "FILTER", + [FW_DEVLOG_FACILITY_ACL] = "ACL", + [FW_DEVLOG_FACILITY_TM] = "TM", + [FW_DEVLOG_FACILITY_QFC] = "QFC", + [FW_DEVLOG_FACILITY_DCB] = "DCB", + [FW_DEVLOG_FACILITY_ETH] = "ETH", + [FW_DEVLOG_FACILITY_OFLD] = "OFLD", + [FW_DEVLOG_FACILITY_RI] = "RI", + [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI", + [FW_DEVLOG_FACILITY_FCOE] = "FCOE", + [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI", + [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE" +}; + +static int +sysctl_devlog(SYSCTL_HANDLER_ARGS) +{ + struct adapter *sc = arg1; + struct devlog_params *dparams = &sc->params.devlog; + struct fw_devlog_e *buf, *e; + int i, j, rc, nentries, first = 0; + struct sbuf *sb; + uint64_t ftstamp = UINT64_MAX; + + if (dparams->start == 0) + return (ENXIO); + + nentries = dparams->size / sizeof(struct fw_devlog_e); + + buf = malloc(dparams->size, M_CXGBE, M_NOWAIT); + if (buf == NULL) + return (ENOMEM); + + rc = -t4_mem_read(sc, dparams->memtype, dparams->start, dparams->size, + (void *)buf); + if (rc != 0) + goto done; + + for (i = 0; i < nentries; i++) { + e = &buf[i]; + + if (e->timestamp == 0) + break; /* end */ + + e->timestamp = be64toh(e->timestamp); + e->seqno = be32toh(e->seqno); + for (j = 0; j < 8; j++) + e->params[j] = be32toh(e->params[j]); + + if (e->timestamp < ftstamp) { + ftstamp = e->timestamp; + first = i; + } + } + + if (buf[first].timestamp == 0) + goto done; /* nothing in the log */ + + rc = sysctl_wire_old_buffer(req, 0); + if (rc != 0) + goto done; + + sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req); + sbuf_printf(sb, "\n%10s %15s %8s %8s %s\n", + "Seq#", "Tstamp", "Level", "Facility", "Message"); + + i = first; + do { + e = &buf[i]; + if (e->timestamp == 0) + break; /* end */ + + sbuf_printf(sb, "%10d %15ju %8s %8s ", + e->seqno, e->timestamp, + (e->level < ARRAY_SIZE(devlog_level_strings) ? + devlog_level_strings[e->level] : "UNKNOWN"), + (e->facility < ARRAY_SIZE(devlog_facility_strings) ? + devlog_facility_strings[e->facility] : "UNKNOWN")); + sbuf_printf(sb, e->fmt, e->params[0], e->params[1], + e->params[2], e->params[3], e->params[4], + e->params[5], e->params[6], e->params[7]); + + if (++i == nentries) + i = 0; + } while (i != first); + + rc = sbuf_finish(sb); + sbuf_delete(sb); +done: + free(buf, M_CXGBE); + return (rc); +} + static inline void txq_start(struct ifnet *ifp, struct sge_txq *txq) { @@ -2913,6 +3065,20 @@ set_filter_mode(struct adapter *sc, uint32_t mode) return (rc); } +static inline uint64_t +get_filter_hits(struct adapter *sc, uint32_t fid) +{ + uint32_t tcb_base = t4_read_reg(sc, A_TP_CMM_TCB_BASE); + uint64_t hits; + + t4_write_reg(sc, PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_OFFSET, 0), + tcb_base + (fid + sc->tids.ftid_base) * TCB_SIZE); + t4_read_reg(sc, PCIE_MEM_ACCESS_REG(A_PCIE_MEM_ACCESS_OFFSET, 0)); + hits = t4_read_reg64(sc, MEMWIN0_BASE + 16); + + return (be64toh(hits)); +} + static int get_filter(struct adapter *sc, struct t4_filter *t) { @@ -2936,7 +3102,10 @@ get_filter(struct adapter *sc, struct t4_filter *t) t->idx = i; t->l2tidx = f->l2t ? f->l2t->idx : 0; t->smtidx = f->smtidx; - t->hits = 0; /* XXX implement */ + if (f->fs.hitcnts) + t->hits = get_filter_hits(sc, t->idx); + else + t->hits = UINT64_MAX; t->fs = f->fs; return (0); diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index c146ab0900ae..cd9c55149775 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -61,6 +61,7 @@ msgbuf_init(struct msgbuf *mbp, void *ptr, int size) mbp->msg_magic = MSG_MAGIC; mbp->msg_lastpri = -1; mbp->msg_needsnl = 0; + bzero(&mbp->msg_lock, sizeof(mbp->msg_lock)); mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN); } @@ -95,6 +96,7 @@ msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size) mbp->msg_lastpri = -1; /* Assume that the old message buffer didn't end in a newline. */ mbp->msg_needsnl = 1; + bzero(&mbp->msg_lock, sizeof(mbp->msg_lock)); mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN); } diff --git a/sys/netinet/ipfw/ip_dummynet.c b/sys/netinet/ipfw/ip_dummynet.c index ba6e89254273..e23ba3afe160 100644 --- a/sys/netinet/ipfw/ip_dummynet.c +++ b/sys/netinet/ipfw/ip_dummynet.c @@ -1045,7 +1045,7 @@ config_red(struct dn_fsk *fs) fs->w_q = fs->fs.w_q; fs->max_p = fs->fs.max_p; - D("called"); + ND("called"); /* Doing stuff that was in userland */ i = fs->sched->link.bandwidth; s = (i <= 0) ? 0 : @@ -1109,7 +1109,7 @@ config_red(struct dn_fsk *fs) if (dn_cfg.red_max_pkt_size < 1) dn_cfg.red_max_pkt_size = 1500; fs->max_pkt_size = dn_cfg.red_max_pkt_size; - D("exit"); + ND("exit"); return 0; } @@ -2176,7 +2176,7 @@ ip_dn_destroy(int last) DN_BH_WLOCK(); if (last) { - printf("%s removing last instance\n", __FUNCTION__); + ND("removing last instance\n"); ip_dn_ctl_ptr = NULL; ip_dn_io_ptr = NULL; } @@ -2256,13 +2256,13 @@ unload_dn_sched(struct dn_alg *s) struct dn_alg *tmp, *r; int err = EINVAL; - D("called for %s", s->name); + ND("called for %s", s->name); DN_BH_WLOCK(); SLIST_FOREACH_SAFE(r, &dn_cfg.schedlist, next, tmp) { if (strcmp(s->name, r->name) != 0) continue; - D("ref_count = %d", r->ref_count); + ND("ref_count = %d", r->ref_count); err = (r->ref_count != 0) ? EBUSY : 0; if (err == 0) SLIST_REMOVE(&dn_cfg.schedlist, r, dn_alg, next); diff --git a/sys/netinet/ipfw/ip_fw_dynamic.c b/sys/netinet/ipfw/ip_fw_dynamic.c index 7f0feb4212fd..0bc4cc112ce2 100644 --- a/sys/netinet/ipfw/ip_fw_dynamic.c +++ b/sys/netinet/ipfw/ip_fw_dynamic.c @@ -753,11 +753,12 @@ ipfw_install_state(struct ip_fw *rule, ipfw_insn_limit *cmd, q = lookup_dyn_rule_locked(&args->f_id, NULL, NULL); if (q != NULL) { /* should never occur */ + DEB( if (last_log != time_uptime) { last_log = time_uptime; printf("ipfw: %s: entry already present, done\n", __func__); - } + }) IPFW_DYN_UNLOCK(); return (0); } diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c index 93c5a08debf2..c9933891c12a 100644 --- a/usr.sbin/kbdmap/kbdmap.c +++ b/usr.sbin/kbdmap/kbdmap.c @@ -226,10 +226,10 @@ get_font(void) } } } + fclose(fp); } else fprintf(stderr, "Could not open %s for reading\n", sysconfig); - fclose(fp); return fnt; } From c8f0bef5361aefeba950c1f660d51e9a146e0094 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 5 Jun 2011 12:46:26 +0000 Subject: [PATCH 080/164] sh: Add already working testcases for $? in here-document. If the here-document is attached to a compound command or subshell, $? already works properly. This is both a workaround for bin/41410 and a requirement for a true fix for bin/41410. PR: bin/41410 MFC after: 1 week --- tools/regression/bin/sh/expansion/heredoc1.0 | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/regression/bin/sh/expansion/heredoc1.0 diff --git a/tools/regression/bin/sh/expansion/heredoc1.0 b/tools/regression/bin/sh/expansion/heredoc1.0 new file mode 100644 index 000000000000..a67b2da2e5f2 --- /dev/null +++ b/tools/regression/bin/sh/expansion/heredoc1.0 @@ -0,0 +1,25 @@ +# $FreeBSD$ + +f() { return $1; } + +[ `f 42; { cat; } < Date: Sun, 5 Jun 2011 14:13:15 +0000 Subject: [PATCH 081/164] sh: Fix $? in heredocs on simple commands. PR: bin/41410 --- bin/sh/eval.c | 3 ++- tools/regression/bin/sh/expansion/heredoc2.0 | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tools/regression/bin/sh/expansion/heredoc2.0 diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 404de3312182..585f91ead32a 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -409,6 +409,7 @@ evalsubshell(union node *n, int flags) struct job *jp; int backgnd = (n->type == NBACKGND); + oexitstatus = exitstatus; expredir(n->nredir.redirect); if ((!backgnd && flags & EV_EXIT && !have_traps()) || forkshell(jp = makejob(n, 1), n, backgnd) == 0) { @@ -436,6 +437,7 @@ evalredir(union node *n, int flags) struct jmploc *savehandler; volatile int in_redirect = 1; + oexitstatus = exitstatus; expredir(n->nredir.redirect); savehandler = handler; if (setjmp(jmploc.loc)) { @@ -478,7 +480,6 @@ expredir(union node *n) for (redir = n ; redir ; redir = redir->nfile.next) { struct arglist fn; fn.lastp = &fn.list; - oexitstatus = exitstatus; switch (redir->type) { case NFROM: case NTO: diff --git a/tools/regression/bin/sh/expansion/heredoc2.0 b/tools/regression/bin/sh/expansion/heredoc2.0 new file mode 100644 index 000000000000..255143296d4a --- /dev/null +++ b/tools/regression/bin/sh/expansion/heredoc2.0 @@ -0,0 +1,15 @@ +# $FreeBSD$ + +f() { return $1; } + +[ `f 42; cat < Date: Sun, 5 Jun 2011 17:31:44 +0000 Subject: [PATCH 082/164] Fix the new NFSv4 client so that it doesn't crash when a mount is done for a VIMAGE kernel. Tested by: glz at hidden-powers dot com Reviewed by: bz MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clport.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 0c3a4c90b07d..6647703327ee 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -943,6 +943,7 @@ nfscl_getmyip(struct nfsmount *nmp, int *isinet6p) sad.sin_family = AF_INET; sad.sin_len = sizeof (struct sockaddr_in); sad.sin_addr.s_addr = sin->sin_addr.s_addr; + CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred)); rt = rtalloc1((struct sockaddr *)&sad, 0, 0UL); if (rt != NULL) { if (rt->rt_ifp != NULL && @@ -956,6 +957,7 @@ nfscl_getmyip(struct nfsmount *nmp, int *isinet6p) } RTFREE_LOCKED(rt); } + CURVNET_RESTORE(); #ifdef INET6 } else if (nmp->nm_nam->sa_family == AF_INET6) { struct sockaddr_in6 sad6, *sin6; @@ -966,6 +968,7 @@ nfscl_getmyip(struct nfsmount *nmp, int *isinet6p) sad6.sin6_family = AF_INET6; sad6.sin6_len = sizeof (struct sockaddr_in6); sad6.sin6_addr = sin6->sin6_addr; + CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred)); rt = rtalloc1((struct sockaddr *)&sad6, 0, 0UL); if (rt != NULL) { if (rt->rt_ifp != NULL && @@ -980,6 +983,7 @@ nfscl_getmyip(struct nfsmount *nmp, int *isinet6p) } RTFREE_LOCKED(rt); } + CURVNET_RESTORE(); #endif } return (retp); From 89d4f3434da83d57cf39b1eeaa97a02ec12808ce Mon Sep 17 00:00:00 2001 From: rmacklem Date: Sun, 5 Jun 2011 18:17:37 +0000 Subject: [PATCH 083/164] The new NFSv4 client was erroneously using "p" instead of "p_leader" for the "id" for POSIX byte range locking. I think this would only have affected processes created by rfork(2) with the RFTHREAD flag specified. This patch fixes that by passing the "id" down through the various functions from nfs_advlock(). MFC after: 2 weeks --- sys/fs/nfs/nfs_var.h | 19 ++++++----- sys/fs/nfsclient/nfs_clport.c | 59 +++++++++++++++------------------ sys/fs/nfsclient/nfs_clrpcops.c | 18 +++++----- sys/fs/nfsclient/nfs_clstate.c | 32 +++++++++--------- sys/fs/nfsclient/nfs_clvnops.c | 5 +-- 5 files changed, 66 insertions(+), 67 deletions(-) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 8ed60a727cc9..5f944b5538f1 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -401,10 +401,10 @@ int nfsrpc_readdirplus(vnode_t, struct uio *, nfsuint64 *, int nfsrpc_commit(vnode_t, u_quad_t, int, struct ucred *, NFSPROC_T *, u_char *, struct nfsvattr *, int *, void *); int nfsrpc_advlock(vnode_t, off_t, int, struct flock *, int, - struct ucred *, NFSPROC_T *); + struct ucred *, NFSPROC_T *, void *, int); int nfsrpc_lockt(struct nfsrv_descript *, vnode_t, struct nfsclclient *, u_int64_t, u_int64_t, struct flock *, - struct ucred *, NFSPROC_T *); + struct ucred *, NFSPROC_T *, void *, int); int nfsrpc_lock(struct nfsrv_descript *, struct nfsmount *, vnode_t, u_int8_t *, int, struct nfscllockowner *, int, int, u_int64_t, u_int64_t, short, struct ucred *, NFSPROC_T *, int); @@ -439,16 +439,16 @@ struct nfsclclient *nfscl_findcl(struct nfsmount *); void nfscl_clientrelease(struct nfsclclient *); void nfscl_freelock(struct nfscllock *, int); int nfscl_getbytelock(vnode_t, u_int64_t, u_int64_t, short, - struct ucred *, NFSPROC_T *, struct nfsclclient *, int, u_int8_t *, - u_int8_t *, struct nfscllockowner **, int *, int *); + struct ucred *, NFSPROC_T *, struct nfsclclient *, int, void *, int, + u_int8_t *, u_int8_t *, struct nfscllockowner **, int *, int *); int nfscl_relbytelock(vnode_t, u_int64_t, u_int64_t, struct ucred *, NFSPROC_T *, int, struct nfsclclient *, - struct nfscllockowner **, int *); + void *, int, struct nfscllockowner **, int *); int nfscl_checkwritelocked(vnode_t, struct flock *, - struct ucred *, NFSPROC_T *); + struct ucred *, NFSPROC_T *, void *, int); void nfscl_lockrelease(struct nfscllockowner *, int, int); void nfscl_fillclid(u_int64_t, char *, u_int8_t *, u_int16_t); -void nfscl_filllockowner(NFSPROC_T *, u_int8_t *); +void nfscl_filllockowner(void *, u_int8_t *, int); void nfscl_freeopen(struct nfsclopen *, int); void nfscl_umount(struct nfsmount *, NFSPROC_T *); void nfscl_renewthread(struct nfsclclient *, NFSPROC_T *); @@ -466,9 +466,10 @@ void nfscl_lockexcl(struct nfsv4lock *, void *); void nfscl_lockunlock(struct nfsv4lock *); void nfscl_lockderef(struct nfsv4lock *); void nfscl_docb(struct nfsrv_descript *, NFSPROC_T *); -void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *); +void nfscl_releasealllocks(struct nfsclclient *, vnode_t, NFSPROC_T *, void *, + int); int nfscl_lockt(vnode_t, struct nfsclclient *, u_int64_t, - u_int64_t, struct flock *, NFSPROC_T *); + u_int64_t, struct flock *, NFSPROC_T *, void *, int); int nfscl_mustflush(vnode_t); int nfscl_nodeleg(vnode_t, int); int nfscl_removedeleg(vnode_t, NFSPROC_T *, nfsv4stateid_t *); diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 6647703327ee..ff2127ba7188 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -500,7 +500,7 @@ nfscl_fillclid(u_int64_t clval, char *uuid, u_int8_t *cp, u_int16_t idlen) * Fill in a lock owner name. For now, pid + the process's creation time. */ void -nfscl_filllockowner(struct thread *td, u_int8_t *cp) +nfscl_filllockowner(void *id, u_int8_t *cp, int flags) { union { u_int32_t lval; @@ -508,37 +508,32 @@ nfscl_filllockowner(struct thread *td, u_int8_t *cp) } tl; struct proc *p; -if (td == NULL) { - printf("NULL td\n"); - bzero(cp, 12); - return; -} - p = td->td_proc; -if (p == NULL) { - printf("NULL pid\n"); - bzero(cp, 12); - return; -} - tl.lval = p->p_pid; - *cp++ = tl.cval[0]; - *cp++ = tl.cval[1]; - *cp++ = tl.cval[2]; - *cp++ = tl.cval[3]; -if (p->p_stats == NULL) { - printf("pstats null\n"); - bzero(cp, 8); - return; -} - tl.lval = p->p_stats->p_start.tv_sec; - *cp++ = tl.cval[0]; - *cp++ = tl.cval[1]; - *cp++ = tl.cval[2]; - *cp++ = tl.cval[3]; - tl.lval = p->p_stats->p_start.tv_usec; - *cp++ = tl.cval[0]; - *cp++ = tl.cval[1]; - *cp++ = tl.cval[2]; - *cp = tl.cval[3]; + if (id == NULL) { + printf("NULL id\n"); + bzero(cp, NFSV4CL_LOCKNAMELEN); + return; + } + if ((flags & F_POSIX) != 0) { + p = (struct proc *)id; + tl.lval = p->p_pid; + *cp++ = tl.cval[0]; + *cp++ = tl.cval[1]; + *cp++ = tl.cval[2]; + *cp++ = tl.cval[3]; + tl.lval = p->p_stats->p_start.tv_sec; + *cp++ = tl.cval[0]; + *cp++ = tl.cval[1]; + *cp++ = tl.cval[2]; + *cp++ = tl.cval[3]; + tl.lval = p->p_stats->p_start.tv_usec; + *cp++ = tl.cval[0]; + *cp++ = tl.cval[1]; + *cp++ = tl.cval[2]; + *cp = tl.cval[3]; + } else { + printf("nfscl_filllockowner: not F_POSIX\n"); + bzero(cp, NFSV4CL_LOCKNAMELEN); + } } /* diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 0fc9bfd1da92..5d83d0bafd25 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -3459,7 +3459,7 @@ nfsrpc_commit(vnode_t vp, u_quad_t offset, int cnt, struct ucred *cred, */ APPLESTATIC int nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, - int reclaim, struct ucred *cred, NFSPROC_T *p) + int reclaim, struct ucred *cred, NFSPROC_T *p, void *id, int flags) { struct nfscllockowner *lp; struct nfsclclient *clp; @@ -3511,11 +3511,11 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, error = nfscl_getcl(vp, cred, p, &clp); if (error) return (error); - error = nfscl_lockt(vp, clp, off, len, fl, p); + error = nfscl_lockt(vp, clp, off, len, fl, p, id, flags); if (!error) { clidrev = clp->nfsc_clientidrev; error = nfsrpc_lockt(nd, vp, clp, off, len, fl, cred, - p); + p, id, flags); } else if (error == -1) { error = 0; } @@ -3530,7 +3530,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, return (error); do { error = nfscl_relbytelock(vp, off, len, cred, p, callcnt, - clp, &lp, &dorpc); + clp, id, flags, &lp, &dorpc); /* * If it returns a NULL lp, we're done. */ @@ -3538,7 +3538,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, if (callcnt == 0) nfscl_clientrelease(clp); else - nfscl_releasealllocks(clp, vp, p); + nfscl_releasealllocks(clp, vp, p, id, flags); return (error); } if (nmp->nm_clp != NULL) @@ -3572,10 +3572,10 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, } callcnt++; } while (error == 0 && nd->nd_repstat == 0); - nfscl_releasealllocks(clp, vp, p); + nfscl_releasealllocks(clp, vp, p, id, flags); } else if (op == F_SETLK) { error = nfscl_getbytelock(vp, off, len, fl->l_type, cred, p, - NULL, 0, NULL, NULL, &lp, &newone, &donelocally); + NULL, 0, id, flags, NULL, NULL, &lp, &newone, &donelocally); if (error || donelocally) { return (error); } @@ -3625,7 +3625,7 @@ nfsrpc_advlock(vnode_t vp, off_t size, int op, struct flock *fl, APPLESTATIC int nfsrpc_lockt(struct nfsrv_descript *nd, vnode_t vp, struct nfsclclient *clp, u_int64_t off, u_int64_t len, struct flock *fl, - struct ucred *cred, NFSPROC_T *p) + struct ucred *cred, NFSPROC_T *p, void *id, int flags) { u_int32_t *tl; int error, type, size; @@ -3643,7 +3643,7 @@ nfsrpc_lockt(struct nfsrv_descript *nd, vnode_t vp, tl += 2; *tl++ = clp->nfsc_clientid.lval[0]; *tl = clp->nfsc_clientid.lval[1]; - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); (void) nfsm_strtom(nd, own, NFSV4CL_LOCKNAMELEN); error = nfscl_request(nd, vp, p, cred, NULL); if (error) diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c index 86d71b66bc9b..aa81437fb2ed 100644 --- a/sys/fs/nfsclient/nfs_clstate.c +++ b/sys/fs/nfsclient/nfs_clstate.c @@ -226,7 +226,7 @@ nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, * If none found, add the new one or return error, depending upon * "create". */ - nfscl_filllockowner(p, own); + nfscl_filllockowner(p->td_proc, own, F_POSIX); NFSLOCKCLSTATE(); dp = NULL; /* First check the delegation list */ @@ -521,7 +521,7 @@ nfscl_getstateid(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t mode, * If p != NULL, we want to search the parentage tree * for a matching OpenOwner and use that. */ - nfscl_filllockowner(p, own); + nfscl_filllockowner(p->td_proc, own, F_POSIX); error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, NULL, p, mode, NULL, &op); if (error == 0) { @@ -596,7 +596,7 @@ nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen, op = NULL; while (op == NULL && (nproc != NULL || rown != NULL)) { if (nproc != NULL) { - nfscl_filllockowner(nproc, own); + nfscl_filllockowner(nproc->td_proc, own, F_POSIX); ownp = own; } else { ownp = rown; @@ -881,7 +881,7 @@ nfscl_clientrelease(struct nfsclclient *clp) APPLESTATIC int nfscl_getbytelock(vnode_t vp, u_int64_t off, u_int64_t len, short type, struct ucred *cred, NFSPROC_T *p, struct nfsclclient *rclp, - int recovery, u_int8_t *rownp, u_int8_t *ropenownp, + int recovery, void *id, int flags, u_int8_t *rownp, u_int8_t *ropenownp, struct nfscllockowner **lpp, int *newonep, int *donelocallyp) { struct nfscllockowner *lp; @@ -942,7 +942,7 @@ nfscl_getbytelock(vnode_t vp, u_int64_t off, u_int64_t len, if (recovery) { ownp = rownp; } else { - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); ownp = own; } if (!recovery) { @@ -1079,7 +1079,8 @@ nfscl_getbytelock(vnode_t vp, u_int64_t off, u_int64_t len, APPLESTATIC int nfscl_relbytelock(vnode_t vp, u_int64_t off, u_int64_t len, __unused struct ucred *cred, NFSPROC_T *p, int callcnt, - struct nfsclclient *clp, struct nfscllockowner **lpp, int *dorpcp) + struct nfsclclient *clp, void *id, int flags, + struct nfscllockowner **lpp, int *dorpcp) { struct nfscllockowner *lp; struct nfsclowner *owp; @@ -1116,7 +1117,7 @@ nfscl_relbytelock(vnode_t vp, u_int64_t off, u_int64_t len, sizeof (struct nfscllock), M_NFSCLLOCK, M_WAITOK); *other_lop = *nlop; } - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); dp = NULL; NFSLOCKCLSTATE(); if (callcnt == 0) @@ -1188,7 +1189,8 @@ nfscl_relbytelock(vnode_t vp, u_int64_t off, u_int64_t len, * Release all lockowners marked in progess for this process and file. */ APPLESTATIC void -nfscl_releasealllocks(struct nfsclclient *clp, vnode_t vp, NFSPROC_T *p) +nfscl_releasealllocks(struct nfsclclient *clp, vnode_t vp, NFSPROC_T *p, + void *id, int flags) { struct nfsclowner *owp; struct nfsclopen *op; @@ -1197,7 +1199,7 @@ nfscl_releasealllocks(struct nfsclclient *clp, vnode_t vp, NFSPROC_T *p) u_int8_t own[NFSV4CL_LOCKNAMELEN]; np = VTONFS(vp); - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); NFSLOCKCLSTATE(); LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { LIST_FOREACH(op, &owp->nfsow_open, nfso_list) { @@ -1226,7 +1228,7 @@ nfscl_releasealllocks(struct nfsclclient *clp, vnode_t vp, NFSPROC_T *p) */ APPLESTATIC int nfscl_checkwritelocked(vnode_t vp, struct flock *fl, - struct ucred *cred, NFSPROC_T *p) + struct ucred *cred, NFSPROC_T *p, void *id, int flags) { struct nfsclowner *owp; struct nfscllockowner *lp; @@ -1266,7 +1268,7 @@ nfscl_checkwritelocked(vnode_t vp, struct flock *fl, error = nfscl_getcl(vp, cred, p, &clp); if (error) return (1); - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); NFSLOCKCLSTATE(); /* @@ -1641,7 +1643,7 @@ nfscl_cleanup(NFSPROC_T *p) if (!nfscl_inited) return; - nfscl_filllockowner(p, own); + nfscl_filllockowner(p->td_proc, own, F_POSIX); NFSLOCKCLSTATE(); /* @@ -3322,7 +3324,7 @@ nfscl_checkconflict(struct nfscllockownerhead *lhp, struct nfscllock *nlop, */ APPLESTATIC int nfscl_lockt(vnode_t vp, struct nfsclclient *clp, u_int64_t off, - u_int64_t len, struct flock *fl, NFSPROC_T *p) + u_int64_t len, struct flock *fl, NFSPROC_T *p, void *id, int flags) { struct nfscllock *lop, nlck; struct nfscldeleg *dp; @@ -3340,7 +3342,7 @@ nfscl_lockt(vnode_t vp, struct nfsclclient *clp, u_int64_t off, return (NFSERR_INVAL); } np = VTONFS(vp); - nfscl_filllockowner(p, own); + nfscl_filllockowner(id, own, flags); NFSLOCKCLSTATE(); dp = nfscl_finddeleg(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len); error = nfscl_localconflict(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len, @@ -3615,7 +3617,7 @@ nfscl_relock(vnode_t vp, struct nfsclclient *clp, struct nfsmount *nmp, off = lop->nfslo_first; len = lop->nfslo_end - lop->nfslo_first; error = nfscl_getbytelock(vp, off, len, lop->nfslo_type, cred, p, - clp, 1, lp->nfsl_owner, lp->nfsl_openowner, &nlp, &newone, + clp, 1, NULL, 0, lp->nfsl_owner, lp->nfsl_openowner, &nlp, &newone, &donelocally); if (error || donelocally) return (error); diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 984724d93aed..9f7ac0e3d639 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -2898,7 +2898,8 @@ nfs_advlock(struct vop_advlock_args *ap) * RFC3530 Sec. 9.3.2. */ if (ap->a_op == F_UNLCK && - nfscl_checkwritelocked(vp, ap->a_fl, cred, td)) + nfscl_checkwritelocked(vp, ap->a_fl, cred, td, ap->a_id, + ap->a_flags)) (void) ncl_flush(vp, MNT_WAIT, cred, td, 1, 0); /* @@ -2907,7 +2908,7 @@ nfs_advlock(struct vop_advlock_args *ap) */ do { ret = nfsrpc_advlock(vp, np->n_size, ap->a_op, - ap->a_fl, 0, cred, td); + ap->a_fl, 0, cred, td, ap->a_id, ap->a_flags); if (ret == NFSERR_DENIED && (ap->a_flags & F_WAIT) && ap->a_op == F_SETLK) { VOP_UNLOCK(vp, 0); From afe8c865a625c68e2388327a10a1d64a02c2afe7 Mon Sep 17 00:00:00 2001 From: avg Date: Sun, 5 Jun 2011 19:20:39 +0000 Subject: [PATCH 084/164] amdsbwd.4: fix spelling of my name Pointed out by: ru MFC after: 3 days --- share/man/man4/amdsbwd.4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/man/man4/amdsbwd.4 b/share/man/man4/amdsbwd.4 index 370cfa8220c0..a28d66123960 100644 --- a/share/man/man4/amdsbwd.4 +++ b/share/man/man4/amdsbwd.4 @@ -67,6 +67,6 @@ driver first appeared in The .Nm driver was written by -.An Andiry Gapon Aq avg@FreeBSD.org . +.An Andriy Gapon Aq avg@FreeBSD.org . This manual page was written by -.An Andiry Gapon Aq avg@FreeBSD.org . +.An Andriy Gapon Aq avg@FreeBSD.org . From 2406f0bc26655d194bc77bf173ae13aaac6dc2c2 Mon Sep 17 00:00:00 2001 From: avg Date: Sun, 5 Jun 2011 19:25:30 +0000 Subject: [PATCH 085/164] amdsbwd.4: fix history to reflect correct releases Pointed out by: ru MFC after: 4 days --- share/man/man4/amdsbwd.4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/man/man4/amdsbwd.4 b/share/man/man4/amdsbwd.4 index a28d66123960..578640b2d9f9 100644 --- a/share/man/man4/amdsbwd.4 +++ b/share/man/man4/amdsbwd.4 @@ -61,7 +61,9 @@ AMD SB600 and SB7xx south bridge chips. The .Nm driver first appeared in -.Fx 9.0 . +.Fx 7.3 +and +.Fx 8.1 . .Sh AUTHORS .An -nosplit The From d631428892f88c72ef632690634462de7ed1303d Mon Sep 17 00:00:00 2001 From: rmacklem Date: Sun, 5 Jun 2011 20:22:56 +0000 Subject: [PATCH 086/164] Add support for flock(2) locks to the new NFSv4 client. I think this should be ok, since the client now delays NFSv4 Close operations until VOP_INACTIVE()/VOP_RECLAIM(). As such, there should be no risk that the NFSv4 Open is closed while an associated byte range lock still exists. Tested by: avg MFC after: 2 weeks --- sys/fs/nfsclient/nfs_clport.c | 5 ++++- sys/fs/nfsclient/nfs_clvnops.c | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index ff2127ba7188..4d88bd27eab9 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -530,8 +530,11 @@ nfscl_filllockowner(void *id, u_int8_t *cp, int flags) *cp++ = tl.cval[1]; *cp++ = tl.cval[2]; *cp = tl.cval[3]; + } else if ((flags & F_FLOCK) != 0) { + bcopy(&id, cp, sizeof(id)); + bzero(&cp[sizeof(id)], NFSV4CL_LOCKNAMELEN - sizeof(id)); } else { - printf("nfscl_filllockowner: not F_POSIX\n"); + printf("nfscl_filllockowner: not F_POSIX or F_FLOCK\n"); bzero(cp, NFSV4CL_LOCKNAMELEN); } } diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 9f7ac0e3d639..3e1c66d1de2d 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -2884,8 +2884,11 @@ nfs_advlock(struct vop_advlock_args *ap) int ret, error = EOPNOTSUPP; u_quad_t size; - if (NFS_ISV4(vp) && (ap->a_flags & F_POSIX)) { - cred = p->p_ucred; + if (NFS_ISV4(vp) && (ap->a_flags & (F_POSIX | F_FLOCK)) != 0) { + if ((ap->a_flags & F_POSIX) != 0) + cred = p->p_ucred; + else + cred = td->td_ucred; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (vp->v_iflag & VI_DOOMED) { VOP_UNLOCK(vp, 0); From d84afa1972d839703ab266da6561f0d78e1bd452 Mon Sep 17 00:00:00 2001 From: avg Date: Sun, 5 Jun 2011 21:01:41 +0000 Subject: [PATCH 087/164] add SNDCTL_DSP_HALT specified by OSS This is really a new name for SNDCTL_DSP_RESET. PR: kern/156874 Submitted by: gerald MFC after: 1 week --- sys/sys/soundcard.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/sys/soundcard.h b/sys/sys/soundcard.h index c4cfc276bdbe..a6817df79d02 100644 --- a/sys/sys/soundcard.h +++ b/sys/sys/soundcard.h @@ -311,7 +311,8 @@ typedef struct _snd_capabilities { * IOCTL Commands for /dev/sequencer */ -#define SNDCTL_SEQ_RESET _IO ('Q', 0) +#define SNDCTL_SEQ_HALT _IO ('Q', 0) +#define SNDCTL_SEQ_RESET SNDCTL_SEQ_HALT /* Historic interface */ #define SNDCTL_SEQ_SYNC _IO ('Q', 1) #define SNDCTL_SYNTH_INFO _IOWR('Q', 2, struct synth_info) #define SNDCTL_SEQ_CTRLRATE _IOWR('Q', 3, int) /* Set/get timer res.(hz) */ From 6e1743e29a10cf5d4dd61f59fa24c367a2e8087b Mon Sep 17 00:00:00 2001 From: mckusick Date: Sun, 5 Jun 2011 22:36:30 +0000 Subject: [PATCH 088/164] Grammer fix in comment. Eliminate one (of several) possible conflicting buffer locks when trying to reclaim blocks. Rest of fix to be incorporated as part of SUJ update by jeff. Pointed out by: Kostik Belousov --- sys/ufs/ffs/ffs_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 5b8f3c837a80..7f5d1b4a6a1d 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -420,13 +420,13 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, flags, cred, bpp) */ if (reclaimed == 0) { reclaimed = 1; - softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); UFS_UNLOCK(ump); if (bp) { brelse(bp); bp = NULL; } UFS_LOCK(ump); + softdep_request_cleanup(fs, vp, cred, FLUSH_BLOCKS_WAIT); goto retry; } UFS_UNLOCK(ump); @@ -2356,8 +2356,8 @@ ffs_fserr(fs, inum, cp) * specified inode by the specified amount. Under normal * operation the count should always go down. Decrementing * the count to zero will cause the inode to be freed. - * adjblkcnt(inode, amt) - adjust the number of blocks used to - * by the specifed amount. + * adjblkcnt(inode, amt) - adjust the number of blocks used by the + * inode by the specified amount. * adjndir, adjbfree, adjifree, adjffree, adjnumclusters(amt) - * adjust the superblock summary. * freedirs(inode, count) - directory inodes [inode..inode + count - 1] From 66b850c8c69006022f94b7cbc65eb47f31bff2dd Mon Sep 17 00:00:00 2001 From: marcel Date: Mon, 6 Jun 2011 01:52:15 +0000 Subject: [PATCH 089/164] Fix ia64 ISO creation: o boot/mfsroot.gz is no more. Copy it only when it exists so as still to be compatible with Makefile.sysinstall. o while here, make ispfw.ko optional as well. o '-b bootimage' is not a valid argument for makefs. What was meant was '-o bootimage'. o create the boot image in the current directory so that makefs can find the file. Previously it had to be created under $BASE because that's how mkisofs wanted it. --- release/ia64/mkisoimages.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/release/ia64/mkisoimages.sh b/release/ia64/mkisoimages.sh index 33ba1927ad61..5dac51ba8de1 100644 --- a/release/ia64/mkisoimages.sh +++ b/release/ia64/mkisoimages.sh @@ -48,28 +48,32 @@ EFIPART=efipart.sys if [ $bootable = yes ]; then EFISZ=65536 MNT=/mnt - dd if=/dev/zero of=$BASE/$EFIPART count=$EFISZ - md=`mdconfig -a -t vnode -f $BASE/$EFIPART` + dd if=/dev/zero of=$EFIPART count=$EFISZ + md=`mdconfig -a -t vnode -f $EFIPART` newfs_msdos -F 12 -S 512 -h 4 -o 0 -s $EFISZ -u 16 $md mount -t msdosfs /dev/$md $MNT mkdir -p $MNT/efi/boot $MNT/boot $MNT/boot/kernel cp -R $BASE/boot/defaults $MNT/boot cp $BASE/boot/kernel/kernel $MNT/boot/kernel - cp $BASE/boot/kernel/ispfw.ko $MNT/boot/kernel + if [ -s $BASE/boot/kernel/ispfw.ko ]; then + cp $BASE/boot/kernel/ispfw.ko $MNT/boot/kernel + fi cp $BASE/boot/device.hints $MNT/boot cp $BASE/boot/loader.* $MNT/boot - cp $BASE/boot/mfsroot.gz $MNT/boot + if [ -s $BASE/boot/mfsroot.gz ]; then + cp $BASE/boot/mfsroot.gz $MNT/boot + fi cp $BASE/boot/support.4th $MNT/boot mv $MNT/boot/loader.efi $MNT/efi/boot/bootia64.efi umount $MNT mdconfig -d -u $md - BOOTOPTS="-b bootimage=i386;$EFIPART -o no-emul-boot" + BOOTOPTS="-o bootimage=i386;$EFIPART -o no-emul-boot" else BOOTOPTS="" fi echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL $NAME $BASE $* -rm -f $BASE/$EFIPART +rm -f $EFIPART rm $1/etc/fstab exit 0 From 4c2206b625bdab00ee5d2cffa967493e02da4e67 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 02:14:23 +0000 Subject: [PATCH 090/164] - Accept Router Advertisement messages even when net.inet6.ip6.forwarding=1. - A new per-interface knob IFF_ND6_NO_RADR and sysctl IPV6CTL_NO_RADR. This controls if accepting a route in an RA message as the default route. The default value for each interface can be set by net.inet6.ip6.no_radr. The system wide default value is 0. - A new sysctl: net.inet6.ip6.norbit_raif. This controls if setting R-bit in NA on RA accepting interfaces. The default is 0 (R-bit is set based on net.inet6.ip6.forwarding). Background: IPv6 host/router model suggests a router sends an RA and a host accepts it for router discovery. Because of that, KAME implementation does not allow accepting RAs when net.inet6.ip6.forwarding=1. Accepting RAs on a router can make the routing table confused since it can change the default router unintentionally. However, in practice there are cases where we cannot distinguish a host from a router clearly. For example, a customer edge router often works as a host against the ISP, and as a router against the LAN at the same time. Another example is a complex network configurations like an L2TP tunnel for IPv6 connection to Internet over an Ethernet link with another native IPv6 subnet. In this case, the physical interface for the native IPv6 subnet works as a host, and the pseudo-interface for L2TP works as the default IP forwarding route. Problem: Disabling processing RA messages when net.inet6.ip6.forwarding=1 and accepting them when net.inet6.ip6.forward=0 cause the following practical issues: - A router cannot perform SLAAC. It becomes a problem if a box has multiple interfaces and you want to use SLAAC on some of them, for example. A customer edge router for IPv6 Internet access service using an IPv6-over-IPv6 tunnel sometimes needs SLAAC on the physical interface for administration purpose; updating firmware and so on (link-local addresses can be used there, but GUAs by SLAAC are often used for scalability). - When a host has multiple IPv6 interfaces and it receives multiple RAs on them, controlling the default route is difficult. Router preferences defined in RFC 4191 works only when the routers on the links are under your control. Details of Implementation Changes: Router Advertisement messages will be accepted even when net.inet6.ip6.forwarding=1. More precisely, the conditions are as follow: (ACCEPT_RTADV && !NO_RADR && !ip6.forwarding) => Normal RA processing on that interface. (as IPv6 host) (ACCEPT_RTADV && (NO_RADR || ip6.forwarding)) => Accept RA but add the router to the defroute list with rtlifetime=0 unconditionally. This effectively prevents from setting the received router address as the box's default route. (!ACCEPT_RTADV) => No RA processing on that interface. ACCEPT_RTADV and NO_RADR are per-interface knob. In short, all interface are classified as "RA-accepting" or not. An RA-accepting interface always processes RA messages regardless of ip6.forwarding. The difference caused by NO_RADR or ip6.forwarding is whether the RA source address is considered as the default router or not. R-bit in NA on the RA accepting interfaces is set based on net.inet6.ip6.forwarding. While RFC 6204 W-1 rule (for CPE case) suggests a router should disable the R-bit completely even when the box has net.inet6.ip6.forwarding=1, I believe there is no technical reason with doing so. This behavior can be set by a new sysctl net.inet6.ip6.norbit_raif (the default is 0). Usage: # ifconfig fxp0 inet6 accept_rtadv => accept RA on fxp0 # ifconfig fxp0 inet6 accept_rtadv no_radr => accept RA on fxp0 but ignore default route information in it. # sysctl net.inet6.ip6.norbit_no_radr=1 => R-bit in NAs on RA accepting interfaces will always be set to 0. --- sbin/ifconfig/af_inet6.c | 2 ++ sbin/ifconfig/af_nd6.c | 2 +- sys/netinet6/in6.h | 5 ++++- sys/netinet6/in6_proto.c | 11 +++++++++++ sys/netinet6/ip6_var.h | 5 +++++ sys/netinet6/nd6.c | 16 ++++++++-------- sys/netinet6/nd6.h | 1 + sys/netinet6/nd6_nbr.c | 14 +++++++++----- sys/netinet6/nd6_rtr.c | 40 ++++++++++++++++++---------------------- 9 files changed, 59 insertions(+), 37 deletions(-) diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c index 93b0e5860975..585be0500923 100644 --- a/sbin/ifconfig/af_inet6.c +++ b/sbin/ifconfig/af_inet6.c @@ -499,6 +499,8 @@ static struct cmd inet6_cmds[] = { DEF_CMD("-autoconf", -IN6_IFF_AUTOCONF, setip6flags), DEF_CMD("accept_rtadv", ND6_IFF_ACCEPT_RTADV, setnd6flags), DEF_CMD("-accept_rtadv",-ND6_IFF_ACCEPT_RTADV, setnd6flags), + DEF_CMD("no_radr", ND6_IFF_NO_RADR, setnd6flags), + DEF_CMD("-no_radr", -ND6_IFF_NO_RADR, setnd6flags), DEF_CMD("defaultif", 1, setnd6defif), DEF_CMD("-defaultif", -1, setnd6defif), DEF_CMD("ifdisabled", ND6_IFF_IFDISABLED, setnd6flags), diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c index 134b825a4425..eed00eaf4044 100644 --- a/sbin/ifconfig/af_nd6.c +++ b/sbin/ifconfig/af_nd6.c @@ -58,7 +58,7 @@ static const char rcsid[] = #define MAX_SYSCTL_TRY 5 #define ND6BITS "\020\001PERFORMNUD\002ACCEPT_RTADV\003PREFER_SOURCE" \ "\004IFDISABLED\005DONT_SET_IFROUTE\006AUTO_LINKLOCAL" \ - "\020DEFAULTIF" + "\007NO_RADR\020DEFAULTIF" static int isnd6defif(int); void setnd6flags(const char *, int, int, const struct afswtch *); diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 32759af99002..ae0da6aa0fff 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -611,7 +611,10 @@ struct ip6_mtuinfo { #define IPV6CTL_STEALTH 45 #define ICMPV6CTL_ND6_ONLINKNSRFC4861 47 -#define IPV6CTL_MAXID 48 +#define IPV6CTL_NO_RADR 48 /* No defroute from RA */ +#define IPV6CTL_NORBIT_RAIF 49 /* Disable R-bit in NA on RA + * receiving IF. */ +#define IPV6CTL_MAXID 50 #endif /* __BSD_VISIBLE */ /* diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index ab54755f02ce..9e78e9a9ab2a 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -409,6 +409,8 @@ VNET_DEFINE(int, ip6_sendredirects) = IPV6_SENDREDIRECTS; VNET_DEFINE(int, ip6_defhlim) = IPV6_DEFHLIM; VNET_DEFINE(int, ip6_defmcasthlim) = IPV6_DEFAULT_MULTICAST_HOPS; VNET_DEFINE(int, ip6_accept_rtadv) = 0; +VNET_DEFINE(int, ip6_no_radr) = 0; +VNET_DEFINE(int, ip6_norbit_raif) = 0; VNET_DEFINE(int, ip6_maxfragpackets); /* initialized in frag6.c:frag6_init() */ VNET_DEFINE(int, ip6_maxfrags); /* initialized in frag6.c:frag6_init() */ VNET_DEFINE(int, ip6_log_interval) = 5; @@ -537,6 +539,15 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, accept_rtadv, CTLFLAG_RW, &VNET_NAME(ip6_accept_rtadv), 0, "Default value of per-interface flag for accepting ICMPv6 Router" "Advertisement messages"); +SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_NO_RADR, no_radr, + CTLFLAG_RW, &VNET_NAME(ip6_no_radr), 0, + "Default value of per-interface flag to control whether routers " + "sending ICMPv6 RA messages on that interface are added into the " + "default router list."); +SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_NORBIT_RAIF, norbit_raif, CTLFLAG_RW, + &VNET_NAME(ip6_norbit_raif), 0, + "Always set 0 to R flag in ICMPv6 NA messages when accepting RA" + " on the interface."); SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, keepfaith, CTLFLAG_RW, &VNET_NAME(ip6_keepfaith), 0, ""); SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, log_interval, diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index 4e44d9f06c7d..dbfba9a0b9e7 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -316,6 +316,9 @@ VNET_DECLARE(int, ip6_maxfragpackets); /* Maximum packets in reassembly VNET_DECLARE(int, ip6_maxfrags); /* Maximum fragments in reassembly * queue */ VNET_DECLARE(int, ip6_accept_rtadv); /* Acts as a host not a router */ +VNET_DECLARE(int, ip6_no_radr); /* No defroute from RA */ +VNET_DECLARE(int, ip6_norbit_raif); /* Disable R-bit in NA on RA + * receiving IF. */ VNET_DECLARE(int, ip6_keepfaith); /* Firewall Aided Internet Translator */ VNET_DECLARE(int, ip6_log_interval); VNET_DECLARE(time_t, ip6_log_time); @@ -327,6 +330,8 @@ VNET_DECLARE(int, ip6_dad_count); /* DupAddrDetectionTransmits */ #define V_ip6_maxfragpackets VNET(ip6_maxfragpackets) #define V_ip6_maxfrags VNET(ip6_maxfrags) #define V_ip6_accept_rtadv VNET(ip6_accept_rtadv) +#define V_ip6_no_radr VNET(ip6_no_radr) +#define V_ip6_norbit_raif VNET(ip6_norbit_raif) #define V_ip6_keepfaith VNET(ip6_keepfaith) #define V_ip6_log_interval VNET(ip6_log_interval) #define V_ip6_log_time VNET(ip6_log_time) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index f1e48ea183f1..b17b5dad1c03 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -193,6 +193,8 @@ nd6_ifattach(struct ifnet *ifp) /* A loopback interface does not need to accept RTADV. */ if (V_ip6_accept_rtadv && !(ifp->if_flags & IFF_LOOPBACK)) nd->flags |= ND6_IFF_ACCEPT_RTADV; + if (V_ip6_no_radr && !(ifp->if_flags & IFF_LOOPBACK)) + nd->flags |= ND6_IFF_NO_RADR; /* XXX: we cannot call nd6_setmtu since ifp is not fully initialized */ nd6_setmtu0(ifp, nd); @@ -825,7 +827,7 @@ nd6_purge(struct ifnet *ifp) if (V_nd6_defifindex == ifp->if_index) nd6_setdefaultiface(0); - if (!V_ip6_forwarding && ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { + if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { /* Refresh default router list. */ defrouter_select(); } @@ -958,10 +960,9 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) /* * If the default router list is empty, all addresses are regarded * as on-link, and thus, as a neighbor. - * XXX: we restrict the condition to hosts, because routers usually do - * not have the "default router list". */ - if (!V_ip6_forwarding && TAILQ_FIRST(&V_nd_defrouter) == NULL && + if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV && + TAILQ_FIRST(&V_nd_defrouter) == NULL && V_nd6_defifindex == ifp->if_index) { return (1); } @@ -1022,8 +1023,7 @@ nd6_free(struct llentry *ln, int gc) ifp = ln->lle_tbl->llt_ifp; - if (!V_ip6_forwarding) { - + if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { dr = defrouter_lookup(&L3_ADDR_SIN6(ln)->sin6_addr, ifp); if (dr != NULL && dr->expire && @@ -1340,7 +1340,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) continue; ia = (struct in6_ifaddr *)ifa; if ((ia->ia6_flags & IN6_IFF_DUPLICATED) && - IN6_IS_ADDR_LINKLOCAL(&ia->ia_addr.sin6_addr)) { + IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { duplicated_linklocal = 1; break; } @@ -1718,7 +1718,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, * for those are not autoconfigured hosts, we explicitly avoid such * cases for safety. */ - if (do_update && router && !V_ip6_forwarding && + if (do_update && router && ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) { /* * guaranteed recursion diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index abcfcb798032..6f6319210b7c 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -85,6 +85,7 @@ struct nd_ifinfo { */ #define ND6_IFF_DONT_SET_IFROUTE 0x10 #define ND6_IFF_AUTO_LINKLOCAL 0x20 +#define ND6_IFF_NO_RADR 0x40 #define ND6_CREATE LLE_CREATE #define ND6_EXCLUSIVE LLE_EXCLUSIVE diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index fd5bcf259af1..fb8e37921283 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -112,10 +112,14 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) int lladdrlen = 0; int anycast = 0, proxy = 0, tentative = 0; int tlladdr; + int rflag; union nd_opts ndopts; struct sockaddr_dl proxydl; char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; + rflag = (V_ip6_forwarding) ? ND_NA_FLAG_ROUTER : 0; + if (ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV && V_ip6_norbit_raif) + rflag = 0; #ifndef PULLDOWN_TEST IP6_EXTHDR_CHECK(m, off, icmp6len,); nd_ns = (struct nd_neighbor_solicit *)((caddr_t)ip6 + off); @@ -339,8 +343,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) goto bad; nd6_na_output(ifp, &in6_all, &taddr6, ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) | - (V_ip6_forwarding ? ND_NA_FLAG_ROUTER : 0), - tlladdr, proxy ? (struct sockaddr *)&proxydl : NULL); + rflag, tlladdr, proxy ? (struct sockaddr *)&proxydl : NULL); goto freeit; } @@ -349,8 +352,8 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) nd6_na_output(ifp, &saddr6, &taddr6, ((anycast || proxy || !tlladdr) ? 0 : ND_NA_FLAG_OVERRIDE) | - (V_ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) | ND_NA_FLAG_SOLICITED, - tlladdr, proxy ? (struct sockaddr *)&proxydl : NULL); + rflag | ND_NA_FLAG_SOLICITED, tlladdr, + proxy ? (struct sockaddr *)&proxydl : NULL); freeit: if (ifa != NULL) ifa_free(ifa); @@ -862,7 +865,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) dr = defrouter_lookup(in6, ln->lle_tbl->llt_ifp); if (dr) defrtrlist_del(dr); - else if (!V_ip6_forwarding) { + else if (ND_IFINFO(ln->lle_tbl->llt_ifp)->flags & + ND6_IFF_ACCEPT_RTADV) { /* * Even if the neighbor is not in the default * router list, the neighbor may be used diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 19ec989fb22d..e791e2e3a7b9 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -127,8 +127,11 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) union nd_opts ndopts; char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; - /* If I'm not a router, ignore it. */ - if (!V_ip6_forwarding) + /* + * Accept RS only when V_ip6_forwarding=1 and the interface has + * no ND6_IFF_ACCEPT_RTADV. + */ + if (!V_ip6_forwarding || ND_IFINFO(ifp)->flags & ND6_IFF_ACCEPT_RTADV) goto freeit; /* Sanity checks */ @@ -213,11 +216,10 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; /* - * We only accept RAs only when - * the node is not a router and - * per-interface variable allows RAs on the receiving interface. + * We only accept RAs only when the per-interface flag + * ND6_IFF_ACCEPT_RTADV is on the receiving interface. */ - if (V_ip6_forwarding || !(ndi->flags & ND6_IFF_ACCEPT_RTADV)) + if (!(ndi->flags & ND6_IFF_ACCEPT_RTADV)) goto freeit; if (ip6->ip6_hlim != 255) { @@ -266,7 +268,15 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) bzero(&dr0, sizeof(dr0)); dr0.rtaddr = saddr6; dr0.flags = nd_ra->nd_ra_flags_reserved; - dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime); + /* + * Effectively-disable the route in the RA packet + * when ND6_IFF_NO_RADR on the receiving interface or + * ip6.forwarding=1. + */ + if (ndi->flags & ND6_IFF_NO_RADR || V_ip6_forwarding) + dr0.rtlifetime = 0; + else + dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime); dr0.expire = time_second + dr0.rtlifetime; dr0.ifp = ifp; /* unspecified or not? (RFC 2461 6.3.4) */ @@ -557,7 +567,7 @@ defrtrlist_del(struct nd_defrouter *dr) * Flush all the routing table entries that use the router * as a next hop. */ - if (!V_ip6_forwarding) + if (ND_IFINFO(dr->ifp)->flags & ND6_IFF_ACCEPT_RTADV) rt6_flush(&dr->rtaddr, dr->ifp); if (dr->installed) { @@ -615,20 +625,6 @@ defrouter_select(void) struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; struct llentry *ln = NULL; - /* - * This function should be called only when acting as an autoconfigured - * host. Although the remaining part of this function is not effective - * if the node is not an autoconfigured host, we explicitly exclude - * such cases here for safety. - */ - if (V_ip6_forwarding) { - nd6log((LOG_WARNING, - "defrouter_select: called unexpectedly (forwarding=%d)\n", - V_ip6_forwarding)); - splx(s); - return; - } - /* * Let's handle easy case (3) first: * If default router list is empty, there's nothing to be done. From acbda2ccc11fcdfe5fa5175c97ac29b4bb729bb5 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 02:37:38 +0000 Subject: [PATCH 091/164] - Make the code more proactively clear an ND6_IFF_IFDISABLED flag when an explicit action for INET6 configuration happens. The changes are: 1. When an ND6 flag is changed via SIOCSIFINFO_FLAGS ioctl, setting ND6_IFF_ACCEPT_RTADV and/or ND6_IFF_AUTO_LINKLOCAL now triggers an attempt to clear the ND6_IFF_IFDISABLED flag. 2. When an AF_INET6 address is added successfully to an interface and it is marked as ND6_IFF_IFDISABLED, an attempt to clear the ND6_IFF_IFDISABLED happens. This simplifies ND6_IFF_IFDISABLED flag manipulation by users via ifconfig(8); in most cases manual configuration is no longer needed. - When ND6_IFF_AUTO_LINKLOCAL is set and no link-local address is assigned to an interface, SIOCSIFINFO_FLAGS ioctl now calls in6_ifattach() to configure a link-local address. This change ensures link-local address configuration when "ifconfig IF inet6" command is invoked. For example, "ifconfig IF inet6 auto_linklocal" now always try to configure an LL addr even if ND6_IFF_AUTO_LINKLOCAL is already set to 1 (i.e. down/up cycle is no longer needed). Reviewed by: bz --- sys/netinet6/in6.c | 26 +++++++++++++++++++++++++- sys/netinet6/nd6.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 9e8e5cd12475..9558d1ba8a1d 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -652,8 +652,32 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, * that is, this address might make other addresses detached. */ pfxlist_onlink_check(); - if (error == 0 && ia) + if (error == 0 && ia) { + if (ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) { + /* + * Try to clear the flag when a new + * IPv6 address is added onto an + * IFDISABLED interface and it + * succeeds. + */ + struct in6_ndireq nd; + + memset(&nd, 0, sizeof(nd)); + nd.ndi.flags = ND_IFINFO(ifp)->flags; + nd.ndi.flags &= ~ND6_IFF_IFDISABLED; + if (nd6_ioctl(SIOCSIFINFO_FLAGS, + (caddr_t)&nd, ifp) < 0) + log(LOG_NOTICE, "SIOCAIFADDR_IN6: " + "SIOCSIFINFO_FLAGS for -ifdisabled " + "failed."); + /* + * Ignore failure of clearing the flag + * intentionally. The failure means + * address duplication was detected. + */ + } EVENTHANDLER_INVOKE(ifaddr_event, ifp); + } break; } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index b17b5dad1c03..231ce94ecbe3 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1322,6 +1322,15 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) struct ifaddr *ifa; struct in6_ifaddr *ia; + /* + * Try to clear ifdisabled flag when enabling + * accept_rtadv or auto_linklocal. + */ + if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && + (ND.flags & (ND6_IFF_ACCEPT_RTADV | + ND6_IFF_AUTO_LINKLOCAL))) + ND.flags &= ~ND6_IFF_IFDISABLED; + if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && !(ND.flags & ND6_IFF_IFDISABLED)) { /* ifdisabled 1->0 transision */ @@ -1379,6 +1388,27 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) /* If no link-local address on ifp, configure */ ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL; in6_ifattach(ifp, NULL); + } else if (ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) { + /* + * When the IF already has + * ND6_IFF_AUTO_LINKLOCAL and no link-local + * address is assigned, try to assign one. + */ + int haslinklocal = 0; + + IF_ADDR_LOCK(ifp); + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + if (ifa->ifa_addr->sa_family != AF_INET6) + continue; + ia = (struct in6_ifaddr *)ifa; + if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { + haslinklocal = 1; + break; + } + } + IF_ADDR_UNLOCK(ifp); + if (!haslinklocal) + in6_ifattach(ifp, NULL); } } ND_IFINFO(ifp)->flags = ND.flags; From 10df0af5a54c03a258caf94e9931b16eec080d79 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 03:06:43 +0000 Subject: [PATCH 092/164] - Implement RDNSS and DNSSL options (RFC 6106, IPv6 Router Advertisement Options for DNS Configuration) into rtadvd(8) and rtsold(8). DNS information received by rtsold(8) will go to resolv.conf(5) by resolvconf(8) script. This is based on work by J.R. Oldroyd (kern/156259) but revised extensively[1]. - rtadvd(8) now supports "noifprefix" to disable gathering on-link prefixes from interfaces when no "addr" is specified[2]. An entry in rtadvd.conf with "noifprefix" + no "addr" generates an RA message with no prefix information option. - rtadvd(8) now supports RTM_IFANNOUNCE message to fix crashes when an interface is added or removed. - Correct bogus ND_OPT_ROUTE_INFO value to one in RFC 4191. Reviewed by: bz[1] PR: kern/156259 [1] PR: bin/152458 [2] --- sys/netinet/icmp6.h | 21 +- usr.sbin/rtadvd/Makefile | 2 +- usr.sbin/rtadvd/advcap.c | 50 +- usr.sbin/rtadvd/config.c | 1020 +++++++++++++++----------- usr.sbin/rtadvd/config.h | 9 +- usr.sbin/rtadvd/dump.c | 217 ++++-- usr.sbin/rtadvd/dump.h | 6 +- usr.sbin/rtadvd/if.c | 113 +-- usr.sbin/rtadvd/if.h | 4 +- usr.sbin/rtadvd/pathnames.h | 5 +- usr.sbin/rtadvd/rrenum.c | 192 ++--- usr.sbin/rtadvd/rrenum.h | 4 +- usr.sbin/rtadvd/rtadvd.8 | 35 +- usr.sbin/rtadvd/rtadvd.c | 1282 +++++++++++++++++++-------------- usr.sbin/rtadvd/rtadvd.conf | 3 +- usr.sbin/rtadvd/rtadvd.conf.5 | 111 ++- usr.sbin/rtadvd/rtadvd.h | 218 ++++-- usr.sbin/rtadvd/timer.c | 126 ++-- usr.sbin/rtadvd/timer.h | 61 +- usr.sbin/rtsold/Makefile | 2 +- usr.sbin/rtsold/dump.c | 40 +- usr.sbin/rtsold/if.c | 58 +- usr.sbin/rtsold/probe.c | 9 +- usr.sbin/rtsold/rtsock.c | 8 +- usr.sbin/rtsold/rtsol.c | 507 +++++++++++-- usr.sbin/rtsold/rtsold.8 | 29 +- usr.sbin/rtsold/rtsold.c | 394 +++++----- usr.sbin/rtsold/rtsold.h | 51 +- 28 files changed, 2862 insertions(+), 1715 deletions(-) diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index 5faae7c1f2d9..c9da86a8b3cd 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -297,8 +297,9 @@ struct nd_opt_hdr { /* Neighbor discovery option header */ #define ND_OPT_PREFIX_INFORMATION 3 #define ND_OPT_REDIRECTED_HEADER 4 #define ND_OPT_MTU 5 - -#define ND_OPT_ROUTE_INFO 200 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */ +#define ND_OPT_ROUTE_INFO 24 /* RFC 4191 */ +#define ND_OPT_RDNSS 25 /* RFC 6016 */ +#define ND_OPT_DNSSL 31 /* RFC 6016 */ struct nd_opt_prefix_info { /* prefix information */ u_int8_t nd_opt_pi_type; @@ -338,6 +339,22 @@ struct nd_opt_route_info { /* route info */ /* prefix follows */ } __packed; +struct nd_opt_rdnss { /* RDNSS option (RFC 6106) */ + u_int8_t nd_opt_rdnss_type; + u_int8_t nd_opt_rdnss_len; + u_int16_t nd_opt_rdnss_reserved; + u_int32_t nd_opt_rdnss_lifetime; + /* followed by list of recursive DNS servers */ +} __packed; + +struct nd_opt_dnssl { /* DNSSL option (RFC 6106) */ + u_int8_t nd_opt_dnssl_type; + u_int8_t nd_opt_dnssl_len; + u_int16_t nd_opt_dnssl_reserved; + u_int32_t nd_opt_dnssl_lifetime; + /* followed by list of DNS search domains */ +} __packed; + /* * icmp6 namelookup */ diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile index 9dbfc997fabc..e34aa3ca1940 100644 --- a/usr.sbin/rtadvd/Makefile +++ b/usr.sbin/rtadvd/Makefile @@ -23,6 +23,6 @@ LDADD= -lutil CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DROUTEINFO -WARNS?= 1 +WARNS?= 6 .include diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c index 792ea27e2463..b0f5ee0f8629 100644 --- a/usr.sbin/rtadvd/advcap.c +++ b/usr.sbin/rtadvd/advcap.c @@ -64,8 +64,6 @@ #define V_TERM "HOST" #endif -char *RM; - /* * termcap - routines for dealing with the terminal capability data base * @@ -83,12 +81,11 @@ char *RM; static char *tbuf; static int hopcount; /* detect infinite loops in termcap, init 0 */ -static char *remotefile; - -extern char *conffile; +static const char *remotefile; +extern const char *conffile; int tgetent(char *, char *); -int getent(char *, char *, char *); +int getent(char *, char *, const char *); int tnchktc(void); int tnamatch(char *); static char *tskip(char *); @@ -103,22 +100,18 @@ static char *tdecode(char *, char **); * we just notice escaped newlines. */ int -tgetent(bp, name) - char *bp, *name; +tgetent(char *bp, char *name) { - char *cp; - - remotefile = cp = conffile ? conffile : _PATH_RTADVDCONF; - return (getent(bp, name, cp)); + return (getent(bp, name, conffile)); } int -getent(bp, name, cp) - char *bp, *name, *cp; +getent(char *bp, char *name, const char *cfile) { int c; int i = 0, cnt = 0; char ibuf[BUFSIZ]; + char *cp; int tf; tbuf = bp; @@ -130,9 +123,9 @@ getent(bp, name, cp) * use so we don't have to read the file. In this case it * has to already have the newlines crunched out. */ - if (cp && *cp) { - tf = open(RM = cp, O_RDONLY); - } + if (cfile && *cfile) + tf = open(cfile, O_RDONLY); + if (tf < 0) { syslog(LOG_INFO, "<%s> open: %s", __func__, strerror(errno)); @@ -184,7 +177,7 @@ getent(bp, name, cp) * Note that this works because of the left to right scan. */ int -tnchktc() +tnchktc(void) { char *p, *q; char tcname[16]; /* name of similar terminal */ @@ -233,8 +226,7 @@ tnchktc() * name (before the first field) stops us. */ int -tnamatch(np) - char *np; +tnamatch(char *np) { char *Np, *Bp; @@ -260,8 +252,7 @@ tnamatch(np) * into the termcap file in octal. */ static char * -tskip(bp) - char *bp; +tskip(char *bp) { int dquote; @@ -305,8 +296,7 @@ tskip(bp) * Note that we handle octal numbers beginning with 0. */ int64_t -tgetnum(id) - char *id; +tgetnum(char *id) { int64_t i; int base; @@ -341,8 +331,7 @@ tgetnum(id) * not given. */ int -tgetflag(id) - char *id; +tgetflag(char *id) { char *bp = tbuf; @@ -369,8 +358,7 @@ tgetflag(id) * No checking on area overflow. */ char * -tgetstr(id, area) - char *id, **area; +tgetstr(char *id, char **area) { char *bp = tbuf; @@ -395,13 +383,11 @@ tgetstr(id, area) * string capability escapes. */ static char * -tdecode(str, area) - char *str; - char **area; +tdecode(char *str, char **area) { char *cp; int c; - char *dp; + const char *dp; int i; char term; diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c index 5eadcc563e06..4c870b9f0596 100644 --- a/usr.sbin/rtadvd/config.c +++ b/usr.sbin/rtadvd/config.c @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -65,29 +65,55 @@ #include "if.h" #include "config.h" +/* label of tcapcode + number + domain name + zero octet */ +static char entbuf[10 + 3 + NI_MAXHOST + 1]; +static char oentbuf[10 + 3 + NI_MAXHOST + 1]; +static char abuf[DNAME_LABELENC_MAXLEN]; + static time_t prefix_timo = (60 * 120); /* 2 hours. * XXX: should be configurable. */ -extern struct rainfo *ralist; static struct rtadvd_timer *prefix_timeout(void *); -static void makeentry(char *, size_t, int, char *); -static int getinet6sysctl(int); +static void makeentry(char *, size_t, int, const char *); +static size_t dname_labelenc(char *, const char *); -void -getconfig(intface) - char *intface; +/* Encode domain name label encoding in RFC 1035 Section 3.1 */ +static size_t +dname_labelenc(char *dst, const char *src) { - int stat, i; - char tbuf[BUFSIZ]; - struct rainfo *tmp; - long val; - int64_t val64; - char buf[BUFSIZ]; - char *bp = buf; - char *addr, *flagstr; - static int forwarding = -1; + char *dst_origin; + char *p; + size_t len; -#define MUSTHAVE(var, cap) \ + dst_origin = dst; + len = strlen(src); + + /* Length fields per 63 octets + '\0' (<= DNAME_LABELENC_MAXLEN) */ + memset(dst, 0, len + len / 64 + 1 + 1); + + syslog(LOG_DEBUG, "<%s> labelenc = %s", __func__, src); + while (src && (len = strlen(src)) != 0) { + /* Put a length field with 63 octet limitation first. */ + p = strchr(src, '.'); + if (p == NULL) + *dst++ = len = MIN(63, len); + else + *dst++ = len = MIN(63, p - src); + /* Copy 63 octets at most. */ + memcpy(dst, src, len); + dst += len; + if (p == NULL) /* the last label */ + break; + src = p + 1; + } + /* Always need a 0-length label at the tail. */ + *dst++ = '\0'; + + syslog(LOG_DEBUG, "<%s> labellen = %d", __func__, dst - dst_origin); + return (dst - dst_origin); +} + +#define MUSTHAVE(var, cap) \ do { \ int64_t t; \ if ((t = agetnum(cap)) < 0) { \ @@ -97,60 +123,158 @@ getconfig(intface) } \ var = t; \ } while (0) -#define MAYHAVE(var, cap, def) \ + +#define MAYHAVE(var, cap, def) \ do { \ if ((var = agetnum(cap)) < 0) \ var = def; \ } while (0) +#define ELM_MALLOC(p,error_action) \ + do { \ + p = malloc(sizeof(*p)); \ + if (p == NULL) { \ + syslog(LOG_ERR, "<%s> malloc failed: %s", \ + __func__, strerror(errno)); \ + error_action; \ + } \ + memset(p, 0, sizeof(*p)); \ + } while(0) + +int +rmconfig(int idx) +{ + struct rainfo *rai; + struct prefix *pfx; + struct soliciter *sol; + struct rdnss *rdn; + struct rdnss_addr *rdna; + struct dnssl *dns; + struct rtinfo *rti; + + rai = if_indextorainfo(idx); + if (rai == NULL) { + syslog(LOG_ERR, "<%s>: rainfo not found (idx=%d)", + __func__, idx); + return (-1); + } + + TAILQ_REMOVE(&railist, rai, rai_next); + syslog(LOG_DEBUG, "<%s>: rainfo (idx=%d) removed.", + __func__, idx); + + /* Free all of allocated memories for this entry. */ + rtadvd_remove_timer(rai->rai_timer); + + if (rai->rai_ra_data != NULL) + free(rai->rai_ra_data); + + if (rai->rai_sdl != NULL) + free(rai->rai_sdl); + + while ((pfx = TAILQ_FIRST(&rai->rai_prefix)) != NULL) { + TAILQ_REMOVE(&rai->rai_prefix, pfx, pfx_next); + free(pfx); + } + while ((sol = TAILQ_FIRST(&rai->rai_soliciter)) != NULL) { + TAILQ_REMOVE(&rai->rai_soliciter, sol, sol_next); + free(sol); + } + while ((rdn = TAILQ_FIRST(&rai->rai_rdnss)) != NULL) { + TAILQ_REMOVE(&rai->rai_rdnss, rdn, rd_next); + while ((rdna = TAILQ_FIRST(&rdn->rd_list)) != NULL) { + TAILQ_REMOVE(&rdn->rd_list, rdna, ra_next); + free(rdna); + } + free(rdn); + } + while ((dns = TAILQ_FIRST(&rai->rai_dnssl)) != NULL) { + TAILQ_REMOVE(&rai->rai_dnssl, dns, dn_next); + free(dns); + } + while ((rti = TAILQ_FIRST(&rai->rai_route)) != NULL) { + TAILQ_REMOVE(&rai->rai_route, rti, rti_next); + free(rti); + } + free(rai); + + return (0); +} + +int +getconfig(int idx) +{ + int stat, i; + char tbuf[BUFSIZ]; + struct rainfo *rai; + long val; + int64_t val64; + char buf[BUFSIZ]; + char *bp = buf; + char *addr, *flagstr; + char intface[IFNAMSIZ]; + + if (if_indextoname(idx, intface) == NULL) { + syslog(LOG_ERR, "<%s> invalid index number (%d)", + __func__, idx); + return (-1); + } + if ((stat = agetent(tbuf, intface)) <= 0) { memset(tbuf, 0, sizeof(tbuf)); syslog(LOG_INFO, - "<%s> %s isn't defined in the configuration file" - " or the configuration file doesn't exist." - " Treat it as default", - __func__, intface); + "<%s> %s isn't defined in the configuration file" + " or the configuration file doesn't exist." + " Treat it as default", + __func__, intface); } - tmp = (struct rainfo *)malloc(sizeof(*ralist)); - if (tmp == NULL) { + rai = malloc(sizeof(*rai)); + if (rai == NULL) { syslog(LOG_INFO, "<%s> %s: can't allocate enough memory", __func__, intface); exit(1); } - memset(tmp, 0, sizeof(*tmp)); - tmp->prefix.next = tmp->prefix.prev = &tmp->prefix; + memset(rai, 0, sizeof(*rai)); + TAILQ_INIT(&rai->rai_prefix); #ifdef ROUTEINFO - tmp->route.next = tmp->route.prev = &tmp->route; + TAILQ_INIT(&rai->rai_route); #endif + TAILQ_INIT(&rai->rai_rdnss); + TAILQ_INIT(&rai->rai_dnssl); + TAILQ_INIT(&rai->rai_soliciter); - /* check if we are allowed to forward packets (if not determined) */ - if (forwarding < 0) { - if ((forwarding = getinet6sysctl(IPV6CTL_FORWARDING)) < 0) - exit(1); - } + /* gather on-link prefixes from the network interfaces. */ + if (agetflag("noifprefix")) + rai->rai_advifprefix = 0; + else + rai->rai_advifprefix = 1; /* get interface information */ if (agetflag("nolladdr")) - tmp->advlinkopt = 0; + rai->rai_advlinkopt = 0; else - tmp->advlinkopt = 1; - if (tmp->advlinkopt) { - if ((tmp->sdl = if_nametosdl(intface)) == NULL) { + rai->rai_advlinkopt = 1; + if (rai->rai_advlinkopt) { + if ((rai->rai_sdl = if_nametosdl(intface)) == NULL) { syslog(LOG_ERR, - "<%s> can't get information of %s", - __func__, intface); - exit(1); + "<%s> can't get information of %s", + __func__, intface); + return (-1); } - tmp->ifindex = tmp->sdl->sdl_index; + rai->rai_ifindex = rai->rai_sdl->sdl_index; } else - tmp->ifindex = if_nametoindex(intface); - strncpy(tmp->ifname, intface, sizeof(tmp->ifname)); - if ((tmp->phymtu = if_getmtu(intface)) == 0) { - tmp->phymtu = IPV6_MMTU; + rai->rai_ifindex = if_nametoindex(intface); + strncpy(rai->rai_ifname, intface, sizeof(rai->rai_ifname)); + syslog(LOG_DEBUG, + "<%s> ifindex = %d on %s", __func__, rai->rai_ifindex, + rai->rai_ifname); + + if ((rai->rai_phymtu = if_getmtu(intface)) == 0) { + rai->rai_phymtu = IPV6_MMTU; syslog(LOG_WARNING, - "<%s> can't get interface mtu of %s. Treat as %d", - __func__, intface, IPV6_MMTU); + "<%s> can't get interface mtu of %s. Treat as %d", + __func__, intface, IPV6_MMTU); } /* @@ -159,25 +283,27 @@ getconfig(intface) MAYHAVE(val, "maxinterval", DEF_MAXRTRADVINTERVAL); if (val < MIN_MAXINTERVAL || val > MAX_MAXINTERVAL) { syslog(LOG_ERR, - "<%s> maxinterval (%ld) on %s is invalid " - "(must be between %u and %u)", __func__, val, - intface, MIN_MAXINTERVAL, MAX_MAXINTERVAL); - exit(1); + "<%s> maxinterval (%ld) on %s is invalid " + "(must be between %u and %u)", __func__, val, + intface, MIN_MAXINTERVAL, MAX_MAXINTERVAL); + return (-1); } - tmp->maxinterval = (u_int)val; - MAYHAVE(val, "mininterval", tmp->maxinterval/3); - if (val < MIN_MININTERVAL || val > (tmp->maxinterval * 3) / 4) { + rai->rai_maxinterval = (u_int)val; + + MAYHAVE(val, "mininterval", rai->rai_maxinterval/3); + if ((u_int)val < MIN_MININTERVAL || + (u_int)val > (rai->rai_maxinterval * 3) / 4) { syslog(LOG_ERR, - "<%s> mininterval (%ld) on %s is invalid " - "(must be between %d and %d)", - __func__, val, intface, MIN_MININTERVAL, - (tmp->maxinterval * 3) / 4); - exit(1); + "<%s> mininterval (%ld) on %s is invalid " + "(must be between %d and %d)", + __func__, val, intface, MIN_MININTERVAL, + (rai->rai_maxinterval * 3) / 4); + return (-1); } - tmp->mininterval = (u_int)val; + rai->rai_mininterval = (u_int)val; MAYHAVE(val, "chlim", DEF_ADVCURHOPLIMIT); - tmp->hoplimit = val & 0xff; + rai->rai_hoplimit = val & 0xff; if ((flagstr = (char *)agetstr("raflags", &bp))) { val = 0; @@ -191,77 +317,61 @@ getconfig(intface) if ((val & ND_RA_FLAG_RTPREF_HIGH)) { syslog(LOG_ERR, "<%s> the \'h\' and \'l\'" " router flags are exclusive", __func__); - exit(1); + return (-1); } val |= ND_RA_FLAG_RTPREF_LOW; } - } else { + } else MAYHAVE(val, "raflags", 0); - } - tmp->managedflg = val & ND_RA_FLAG_MANAGED; - tmp->otherflg = val & ND_RA_FLAG_OTHER; + + rai->rai_managedflg = val & ND_RA_FLAG_MANAGED; + rai->rai_otherflg = val & ND_RA_FLAG_OTHER; #ifndef ND_RA_FLAG_RTPREF_MASK #define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */ #define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */ #endif - tmp->rtpref = val & ND_RA_FLAG_RTPREF_MASK; - if (tmp->rtpref == ND_RA_FLAG_RTPREF_RSV) { + rai->rai_rtpref = val & ND_RA_FLAG_RTPREF_MASK; + if (rai->rai_rtpref == ND_RA_FLAG_RTPREF_RSV) { syslog(LOG_ERR, "<%s> invalid router preference (%02x) on %s", - __func__, tmp->rtpref, intface); - exit(1); + __func__, rai->rai_rtpref, intface); + return (-1); } - MAYHAVE(val, "rltime", tmp->maxinterval * 3); - if (val && (val < tmp->maxinterval || val > MAXROUTERLIFETIME)) { + MAYHAVE(val, "rltime", rai->rai_maxinterval * 3); + if ((u_int)val && ((u_int)val < rai->rai_maxinterval || + (u_int)val > MAXROUTERLIFETIME)) { syslog(LOG_ERR, - "<%s> router lifetime (%ld) on %s is invalid " - "(must be 0 or between %d and %d)", - __func__, val, intface, - tmp->maxinterval, - MAXROUTERLIFETIME); - exit(1); + "<%s> router lifetime (%ld) on %s is invalid " + "(must be 0 or between %d and %d)", + __func__, val, intface, rai->rai_maxinterval, + MAXROUTERLIFETIME); + return (-1); } - /* - * Basically, hosts MUST NOT send Router Advertisement messages at any - * time (RFC 2461, Section 6.2.3). However, it would sometimes be - * useful to allow hosts to advertise some parameters such as prefix - * information and link MTU. Thus, we allow hosts to invoke rtadvd - * only when router lifetime (on every advertising interface) is - * explicitly set zero. (see also the above section) - */ - if (val && forwarding == 0) { - syslog(LOG_ERR, - "<%s> non zero router lifetime is specified for %s, " - "which must not be allowed for hosts. you must " - "change router lifetime or enable IPv6 forwarding.", - __func__, intface); - exit(1); - } - tmp->lifetime = val & 0xffff; + rai->rai_lifetime = val & 0xffff; MAYHAVE(val, "rtime", DEF_ADVREACHABLETIME); if (val < 0 || val > MAXREACHABLETIME) { syslog(LOG_ERR, - "<%s> reachable time (%ld) on %s is invalid " - "(must be no greater than %d)", - __func__, val, intface, MAXREACHABLETIME); - exit(1); + "<%s> reachable time (%ld) on %s is invalid " + "(must be no greater than %d)", + __func__, val, intface, MAXREACHABLETIME); + return (-1); } - tmp->reachabletime = (u_int32_t)val; + rai->rai_reachabletime = (u_int32_t)val; MAYHAVE(val64, "retrans", DEF_ADVRETRANSTIMER); if (val64 < 0 || val64 > 0xffffffff) { syslog(LOG_ERR, "<%s> retrans time (%lld) on %s out of range", - __func__, (long long)val64, intface); - exit(1); + __func__, (long long)val64, intface); + return (-1); } - tmp->retranstimer = (u_int32_t)val64; + rai->rai_retranstimer = (u_int32_t)val64; if (agetnum("hapref") != -1 || agetnum("hatime") != -1) { syslog(LOG_ERR, - "<%s> mobile-ip6 configuration not supported", - __func__); - exit(1); + "<%s> mobile-ip6 configuration not supported", + __func__); + return (-1); } /* prefix information */ @@ -271,12 +381,11 @@ getconfig(intface) * checking consistency of advertised lifetimes. */ MAYHAVE(val, "clockskew", 0); - tmp->clockskew = val; + rai->rai_clockskew = val; - tmp->pfxs = 0; + rai->rai_pfxs = 0; for (i = -1; i < MAXPREFIX; i++) { struct prefix *pfx; - char entbuf[256]; makeentry(entbuf, sizeof(entbuf), i, "addr"); addr = (char *)agetstr(entbuf, &bp); @@ -284,49 +393,41 @@ getconfig(intface) continue; /* allocate memory to store prefix information */ - if ((pfx = malloc(sizeof(struct prefix))) == NULL) { - syslog(LOG_ERR, - "<%s> can't allocate enough memory", - __func__); - exit(1); - } - memset(pfx, 0, sizeof(*pfx)); + ELM_MALLOC(pfx, exit(1)); /* link into chain */ - insque(pfx, &tmp->prefix); - tmp->pfxs++; - pfx->rainfo = tmp; + TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next); + rai->rai_pfxs++; + pfx->pfx_origin = PREFIX_FROM_CONFIG; - pfx->origin = PREFIX_FROM_CONFIG; - - if (inet_pton(AF_INET6, addr, &pfx->prefix) != 1) { + if (inet_pton(AF_INET6, addr, &pfx->pfx_prefix) != 1) { syslog(LOG_ERR, - "<%s> inet_pton failed for %s", - __func__, addr); - exit(1); + "<%s> inet_pton failed for %s", + __func__, addr); + return (-1); } - if (IN6_IS_ADDR_MULTICAST(&pfx->prefix)) { + if (IN6_IS_ADDR_MULTICAST(&pfx->pfx_prefix)) { syslog(LOG_ERR, - "<%s> multicast prefix (%s) must " - "not be advertised on %s", - __func__, addr, intface); - exit(1); + "<%s> multicast prefix (%s) must " + "not be advertised on %s", + __func__, addr, intface); + return (-1); } - if (IN6_IS_ADDR_LINKLOCAL(&pfx->prefix)) + if (IN6_IS_ADDR_LINKLOCAL(&pfx->pfx_prefix)) syslog(LOG_NOTICE, - "<%s> link-local prefix (%s) will be" - " advertised on %s", - __func__, addr, intface); + "<%s> link-local prefix (%s) will be" + " advertised on %s", + __func__, addr, intface); makeentry(entbuf, sizeof(entbuf), i, "prefixlen"); MAYHAVE(val, entbuf, 64); if (val < 0 || val > 128) { syslog(LOG_ERR, "<%s> prefixlen (%ld) for %s " - "on %s out of range", - __func__, val, addr, intface); - exit(1); + "on %s out of range", + __func__, val, addr, intface); + return (-1); } - pfx->prefixlen = (int)val; + pfx->pfx_prefixlen = (int)val; makeentry(entbuf, sizeof(entbuf), i, "pinfoflags"); if ((flagstr = (char *)agetstr(entbuf, &bp))) { @@ -339,8 +440,8 @@ getconfig(intface) MAYHAVE(val, entbuf, (ND_OPT_PI_FLAG_ONLINK|ND_OPT_PI_FLAG_AUTO)); } - pfx->onlinkflg = val & ND_OPT_PI_FLAG_ONLINK; - pfx->autoconfflg = val & ND_OPT_PI_FLAG_AUTO; + pfx->pfx_onlinkflg = val & ND_OPT_PI_FLAG_ONLINK; + pfx->pfx_autoconfflg = val & ND_OPT_PI_FLAG_AUTO; makeentry(entbuf, sizeof(entbuf), i, "vltime"); MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME); @@ -348,17 +449,17 @@ getconfig(intface) syslog(LOG_ERR, "<%s> vltime (%lld) for " "%s/%d on %s is out of range", __func__, (long long)val64, - addr, pfx->prefixlen, intface); - exit(1); + addr, pfx->pfx_prefixlen, intface); + return (-1); } - pfx->validlifetime = (u_int32_t)val64; + pfx->pfx_validlifetime = (u_int32_t)val64; makeentry(entbuf, sizeof(entbuf), i, "vltimedecr"); if (agetflag(entbuf)) { struct timeval now; gettimeofday(&now, 0); - pfx->vltimeexpire = - now.tv_sec + pfx->validlifetime; + pfx->pfx_vltimeexpire = + now.tv_sec + pfx->pfx_validlifetime; } makeentry(entbuf, sizeof(entbuf), i, "pltime"); @@ -368,44 +469,45 @@ getconfig(intface) "<%s> pltime (%lld) for %s/%d on %s " "is out of range", __func__, (long long)val64, - addr, pfx->prefixlen, intface); - exit(1); + addr, pfx->pfx_prefixlen, intface); + return (-1); } - pfx->preflifetime = (u_int32_t)val64; + pfx->pfx_preflifetime = (u_int32_t)val64; makeentry(entbuf, sizeof(entbuf), i, "pltimedecr"); if (agetflag(entbuf)) { struct timeval now; gettimeofday(&now, 0); - pfx->pltimeexpire = - now.tv_sec + pfx->preflifetime; + pfx->pfx_pltimeexpire = + now.tv_sec + pfx->pfx_preflifetime; } } - if (tmp->pfxs == 0) - get_prefix(tmp); + if (rai->rai_advifprefix && rai->rai_pfxs == 0) + get_prefix(rai); MAYHAVE(val, "mtu", 0); - if (val < 0 || val > 0xffffffff) { + if (val < 0 || (u_int)val > 0xffffffff) { syslog(LOG_ERR, - "<%s> mtu (%ld) on %s out of range", - __func__, val, intface); - exit(1); + "<%s> mtu (%ld) on %s out of range", + __func__, val, intface); + return (-1); } - tmp->linkmtu = (u_int32_t)val; - if (tmp->linkmtu == 0) { + rai->rai_linkmtu = (u_int32_t)val; + if (rai->rai_linkmtu == 0) { char *mtustr; if ((mtustr = (char *)agetstr("mtu", &bp)) && strcmp(mtustr, "auto") == 0) - tmp->linkmtu = tmp->phymtu; + rai->rai_linkmtu = rai->rai_phymtu; } - else if (tmp->linkmtu < IPV6_MMTU || tmp->linkmtu > tmp->phymtu) { + else if (rai->rai_linkmtu < IPV6_MMTU || + rai->rai_linkmtu > rai->rai_phymtu) { syslog(LOG_ERR, - "<%s> advertised link mtu (%lu) on %s is invalid (must " - "be between least MTU (%d) and physical link MTU (%d)", - __func__, (unsigned long)tmp->linkmtu, intface, - IPV6_MMTU, tmp->phymtu); - exit(1); + "<%s> advertised link mtu (%lu) on %s is invalid (must " + "be between least MTU (%d) and physical link MTU (%d)", + __func__, (unsigned long)rai->rai_linkmtu, intface, + IPV6_MMTU, rai->rai_phymtu); + return (-1); } #ifdef SIOCSIFINFO_IN6 @@ -415,65 +517,56 @@ getconfig(intface) if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, "<%s> socket: %s", __func__, - strerror(errno)); + strerror(errno)); exit(1); } memset(&ndi, 0, sizeof(ndi)); strncpy(ndi.ifname, intface, IFNAMSIZ); - if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&ndi) < 0) { + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&ndi) < 0) syslog(LOG_INFO, "<%s> ioctl:SIOCGIFINFO_IN6 at %s: %s", - __func__, intface, strerror(errno)); - } + __func__, intface, strerror(errno)); /* reflect the RA info to the host variables in kernel */ - ndi.ndi.chlim = tmp->hoplimit; - ndi.ndi.retrans = tmp->retranstimer; - ndi.ndi.basereachable = tmp->reachabletime; - if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&ndi) < 0) { + ndi.ndi.chlim = rai->rai_hoplimit; + ndi.ndi.retrans = rai->rai_retranstimer; + ndi.ndi.basereachable = rai->rai_reachabletime; + if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&ndi) < 0) syslog(LOG_INFO, "<%s> ioctl:SIOCSIFINFO_IN6 at %s: %s", - __func__, intface, strerror(errno)); - } + __func__, intface, strerror(errno)); + close(s); } #endif /* route information */ #ifdef ROUTEINFO - tmp->routes = 0; + rai->rai_routes = 0; for (i = -1; i < MAXROUTE; i++) { struct rtinfo *rti; - char entbuf[256], oentbuf[256]; makeentry(entbuf, sizeof(entbuf), i, "rtprefix"); addr = (char *)agetstr(entbuf, &bp); if (addr == NULL) { makeentry(oentbuf, sizeof(oentbuf), i, "rtrprefix"); addr = (char *)agetstr(oentbuf, &bp); - if (addr) { + if (addr) fprintf(stderr, "%s was obsoleted. Use %s.\n", - oentbuf, entbuf); - } + oentbuf, entbuf); } if (addr == NULL) continue; /* allocate memory to store prefix information */ - if ((rti = malloc(sizeof(struct rtinfo))) == NULL) { - syslog(LOG_ERR, - "<%s> can't allocate enough memory", - __func__); - exit(1); - } - memset(rti, 0, sizeof(*rti)); + ELM_MALLOC(rti, exit(1)); /* link into chain */ - insque(rti, &tmp->route); - tmp->routes++; + TAILQ_INSERT_TAIL(&rai->rai_route, rti, rti_next); + rai->rai_routes++; - if (inet_pton(AF_INET6, addr, &rti->prefix) != 1) { + if (inet_pton(AF_INET6, addr, &rti->rti_prefix) != 1) { syslog(LOG_ERR, "<%s> inet_pton failed for %s", - __func__, addr); - exit(1); + __func__, addr); + return (-1); } #if 0 /* @@ -485,17 +578,17 @@ getconfig(intface) MAYHAVE(val64, entbuf, DEF_ADVVALIDLIFETIME); if (IN6_IS_ADDR_MULTICAST(&rti->prefix)) { syslog(LOG_ERR, - "<%s> multicast route (%s) must " - "not be advertised on %s", - __func__, addr, intface); - exit(1); + "<%s> multicast route (%s) must " + "not be advertised on %s", + __func__, addr, intface); + return (-1); } if (IN6_IS_ADDR_LINKLOCAL(&rti->prefix)) { syslog(LOG_NOTICE, - "<%s> link-local route (%s) will " - "be advertised on %s", - __func__, addr, intface); - exit(1); + "<%s> link-local route (%s) will " + "be advertised on %s", + __func__, addr, intface); + return (-1); } #endif @@ -505,19 +598,19 @@ getconfig(intface) if (val == 256) { makeentry(oentbuf, sizeof(oentbuf), i, "rtrplen"); MAYHAVE(val, oentbuf, 256); - if (val != 256) { + if (val != 256) fprintf(stderr, "%s was obsoleted. Use %s.\n", - oentbuf, entbuf); - } else + oentbuf, entbuf); + else val = 64; } if (val < 0 || val > 128) { syslog(LOG_ERR, "<%s> prefixlen (%ld) for %s on %s " - "out of range", - __func__, val, addr, intface); - exit(1); + "out of range", + __func__, val, addr, intface); + return (-1); } - rti->prefixlen = (int)val; + rti->rti_prefixlen = (int)val; makeentry(entbuf, sizeof(entbuf), i, "rtflags"); if ((flagstr = (char *)agetstr(entbuf, &bp))) { @@ -541,17 +634,17 @@ getconfig(intface) MAYHAVE(val, oentbuf, 256); if (val != 256) { fprintf(stderr, "%s was obsoleted. Use %s.\n", - oentbuf, entbuf); + oentbuf, entbuf); } else val = 0; } - rti->rtpref = val & ND_RA_FLAG_RTPREF_MASK; - if (rti->rtpref == ND_RA_FLAG_RTPREF_RSV) { + rti->rti_rtpref = val & ND_RA_FLAG_RTPREF_MASK; + if (rti->rti_rtpref == ND_RA_FLAG_RTPREF_RSV) { syslog(LOG_ERR, "<%s> invalid route preference (%02x) " - "for %s/%d on %s", - __func__, rti->rtpref, addr, - rti->prefixlen, intface); - exit(1); + "for %s/%d on %s", + __func__, rti->rti_rtpref, addr, + rti->rti_prefixlen, intface); + return (-1); } /* @@ -565,60 +658,143 @@ getconfig(intface) if (val64 == -1) { makeentry(oentbuf, sizeof(oentbuf), i, "rtrltime"); MAYHAVE(val64, oentbuf, -1); - if (val64 != -1) { + if (val64 != -1) fprintf(stderr, "%s was obsoleted. Use %s.\n", - oentbuf, entbuf); - } else { + oentbuf, entbuf); + else { fprintf(stderr, "%s should be specified " - "for interface %s.\n", - entbuf, intface); - val64 = tmp->lifetime; + "for interface %s.\n", entbuf, intface); + val64 = rai->rai_lifetime; } } if (val64 < 0 || val64 > 0xffffffff) { syslog(LOG_ERR, "<%s> route lifetime (%lld) for " "%s/%d on %s out of range", __func__, - (long long)val64, addr, rti->prefixlen, intface); - exit(1); + (long long)val64, addr, rti->rti_prefixlen, intface); + return (-1); } - rti->ltime = (u_int32_t)val64; + rti->rti_ltime = (u_int32_t)val64; } #endif + /* DNS server and DNS search list information */ + for (i = -1; i < MAXRDNSSENT ; i++) { + struct rdnss *rdn; + struct rdnss_addr *rdna; + char *ap; + int c; - /* okey */ - tmp->next = ralist; - ralist = tmp; + makeentry(entbuf, sizeof(entbuf), i, "rdnss"); + addr = (char *)agetstr(entbuf, &bp); + if (addr == NULL) + break; + ELM_MALLOC(rdn, exit(1)); + TAILQ_INIT(&rdn->rd_list); + + for (ap = addr; ap - addr < (ssize_t)strlen(addr); ap += c+1) { + c = strcspn(ap, ","); + strncpy(abuf, ap, c); + abuf[c] = '\0'; + ELM_MALLOC(rdna, exit(1)); + if (inet_pton(AF_INET6, abuf, &rdna->ra_dns) != 1) { + syslog(LOG_ERR, "<%s> inet_pton failed for %s", + __func__, abuf); + free(rdna); + return (-1); + } + TAILQ_INSERT_TAIL(&rdn->rd_list, rdna, ra_next); + } + + makeentry(entbuf, sizeof(entbuf), i, "rdnssltime"); + MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2)); + if ((u_int)val < rai->rai_maxinterval || + (u_int)val > rai->rai_maxinterval * 2) { + syslog(LOG_ERR, "%s (%ld) on %s is invalid " + "(must be between %d and %d)", + entbuf, val, intface, rai->rai_maxinterval, + rai->rai_maxinterval * 2); + return (-1); + } + rdn->rd_ltime = val; + + /* link into chain */ + TAILQ_INSERT_TAIL(&rai->rai_rdnss, rdn, rd_next); + } + + for (i = -1; i < MAXDNSSLENT ; i++) { + struct dnssl *dns; + struct dnssl_addr *dnsa; + char *ap; + int c; + + makeentry(entbuf, sizeof(entbuf), i, "dnssl"); + addr = (char *)agetstr(entbuf, &bp); + if (addr == NULL) + break; + + ELM_MALLOC(dns, exit(1)); + + TAILQ_INIT(&dns->dn_list); + + for (ap = addr; ap - addr < (ssize_t)strlen(addr); ap += c+1) { + c = strcspn(ap, ","); + strncpy(abuf, ap, c); + abuf[c] = '\0'; + ELM_MALLOC(dnsa, exit(1)); + dnsa->da_len = dname_labelenc(dnsa->da_dom, abuf); + syslog(LOG_DEBUG, "<%s>: dnsa->da_len = %d", __func__, + dnsa->da_len); + TAILQ_INSERT_TAIL(&dns->dn_list, dnsa, da_next); + } + + makeentry(entbuf, sizeof(entbuf), i, "dnsslltime"); + MAYHAVE(val, entbuf, (rai->rai_maxinterval * 3 / 2)); + if ((u_int)val < rai->rai_maxinterval || + (u_int)val > rai->rai_maxinterval * 2) { + syslog(LOG_ERR, "%s (%ld) on %s is invalid " + "(must be between %d and %d)", + entbuf, val, intface, rai->rai_maxinterval, + rai->rai_maxinterval * 2); + return (-1); + } + dns->dn_ltime = val; + + /* link into chain */ + TAILQ_INSERT_TAIL(&rai->rai_dnssl, dns, dn_next); + } /* construct the sending packet */ - make_packet(tmp); + make_packet(rai); + TAILQ_INSERT_TAIL(&railist, rai, rai_next); /* set timer */ - tmp->timer = rtadvd_add_timer(ra_timeout, ra_timer_update, - tmp, tmp); - ra_timer_update((void *)tmp, &tmp->timer->tm); - rtadvd_set_timer(&tmp->timer->tm, tmp->timer); + rai->rai_timer = rtadvd_add_timer(ra_timeout, ra_timer_update, + rai, rai); + ra_timer_update((void *)rai, &rai->rai_timer->rat_tm); + rtadvd_set_timer(&rai->rai_timer->rat_tm, rai->rai_timer); + + return (0); } void get_prefix(struct rainfo *rai) { struct ifaddrs *ifap, *ifa; - struct prefix *pp; + struct prefix *pfx; struct in6_addr *a; u_char *p, *ep, *m, *lim; u_char ntopbuf[INET6_ADDRSTRLEN]; if (getifaddrs(&ifap) < 0) { syslog(LOG_ERR, - "<%s> can't get interface addresses", - __func__); + "<%s> can't get interface addresses", + __func__); exit(1); } for (ifa = ifap; ifa; ifa = ifa->ifa_next) { int plen; - if (strcmp(ifa->ifa_name, rai->ifname) != 0) + if (strcmp(ifa->ifa_name, rai->rai_ifname) != 0) continue; if (ifa->ifa_addr->sa_family != AF_INET6) continue; @@ -631,8 +807,8 @@ get_prefix(struct rainfo *rai) plen = prefixlen(m, lim); if (plen <= 0 || plen > 128) { syslog(LOG_ERR, "<%s> failed to get prefixlen " - "or prefix is invalid", - __func__); + "or prefix is invalid", + __func__); exit(1); } if (plen == 128) /* XXX */ @@ -643,56 +819,46 @@ get_prefix(struct rainfo *rai) } /* allocate memory to store prefix info. */ - if ((pp = malloc(sizeof(*pp))) == NULL) { - syslog(LOG_ERR, - "<%s> can't get allocate buffer for prefix", - __func__); - exit(1); - } - memset(pp, 0, sizeof(*pp)); + ELM_MALLOC(pfx, exit(1)); /* set prefix, sweep bits outside of prefixlen */ - pp->prefixlen = plen; - memcpy(&pp->prefix, a, sizeof(*a)); - p = (u_char *)&pp->prefix; - ep = (u_char *)(&pp->prefix + 1); + pfx->pfx_prefixlen = plen; + memcpy(&pfx->pfx_prefix, a, sizeof(*a)); + p = (u_char *)&pfx->pfx_prefix; + ep = (u_char *)(&pfx->pfx_prefix + 1); while (m < lim && p < ep) *p++ &= *m++; while (p < ep) *p++ = 0x00; - if (!inet_ntop(AF_INET6, &pp->prefix, ntopbuf, + if (!inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, sizeof(ntopbuf))) { syslog(LOG_ERR, "<%s> inet_ntop failed", __func__); exit(1); } syslog(LOG_DEBUG, - "<%s> add %s/%d to prefix list on %s", - __func__, ntopbuf, pp->prefixlen, rai->ifname); + "<%s> add %s/%d to prefix list on %s", + __func__, ntopbuf, pfx->pfx_prefixlen, rai->rai_ifname); /* set other fields with protocol defaults */ - pp->validlifetime = DEF_ADVVALIDLIFETIME; - pp->preflifetime = DEF_ADVPREFERREDLIFETIME; - pp->onlinkflg = 1; - pp->autoconfflg = 1; - pp->origin = PREFIX_FROM_KERNEL; - pp->rainfo = rai; + pfx->pfx_validlifetime = DEF_ADVVALIDLIFETIME; + pfx->pfx_preflifetime = DEF_ADVPREFERREDLIFETIME; + pfx->pfx_onlinkflg = 1; + pfx->pfx_autoconfflg = 1; + pfx->pfx_origin = PREFIX_FROM_KERNEL; + pfx->pfx_rainfo = rai; /* link into chain */ - insque(pp, &rai->prefix); + TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next); /* counter increment */ - rai->pfxs++; + rai->rai_pfxs++; } freeifaddrs(ifap); } static void -makeentry(buf, len, id, string) - char *buf; - size_t len; - int id; - char *string; +makeentry(char *buf, size_t len, int id, const char *string) { if (id < 0) @@ -711,37 +877,28 @@ makeentry(buf, len, id, string) static void add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr) { - struct prefix *prefix; + struct prefix *pfx; u_char ntopbuf[INET6_ADDRSTRLEN]; - if ((prefix = malloc(sizeof(*prefix))) == NULL) { - syslog(LOG_ERR, "<%s> memory allocation failed", - __func__); - return; /* XXX: error or exit? */ - } - memset(prefix, 0, sizeof(*prefix)); - prefix->prefix = ipr->ipr_prefix.sin6_addr; - prefix->prefixlen = ipr->ipr_plen; - prefix->validlifetime = ipr->ipr_vltime; - prefix->preflifetime = ipr->ipr_pltime; - prefix->onlinkflg = ipr->ipr_raf_onlink; - prefix->autoconfflg = ipr->ipr_raf_auto; - prefix->origin = PREFIX_FROM_DYNAMIC; + ELM_MALLOC(pfx, return); + pfx->pfx_prefix = ipr->ipr_prefix.sin6_addr; + pfx->pfx_prefixlen = ipr->ipr_plen; + pfx->pfx_validlifetime = ipr->ipr_vltime; + pfx->pfx_preflifetime = ipr->ipr_pltime; + pfx->pfx_onlinkflg = ipr->ipr_raf_onlink; + pfx->pfx_autoconfflg = ipr->ipr_raf_auto; + pfx->pfx_origin = PREFIX_FROM_DYNAMIC; - insque(prefix, &rai->prefix); - prefix->rainfo = rai; + TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next); + pfx->pfx_rainfo = rai; syslog(LOG_DEBUG, "<%s> new prefix %s/%d was added on %s", - __func__, inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - ipr->ipr_plen, rai->ifname); - - /* free the previous packet */ - free(rai->ra_data); - rai->ra_data = NULL; + __func__, + inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf, + sizeof(ntopbuf)), ipr->ipr_plen, rai->rai_ifname); /* reconstruct the packet */ - rai->pfxs++; + rai->rai_pfxs++; make_packet(rai); } @@ -751,30 +908,33 @@ add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr) * The prefix must be in the list. */ void -delete_prefix(struct prefix *prefix) +delete_prefix(struct prefix *pfx) { u_char ntopbuf[INET6_ADDRSTRLEN]; - struct rainfo *rai = prefix->rainfo; + struct rainfo *rai; - remque(prefix); + rai = pfx->pfx_rainfo; + TAILQ_REMOVE(&rai->rai_prefix, pfx, pfx_next); syslog(LOG_DEBUG, "<%s> prefix %s/%d was deleted on %s", - __func__, inet_ntop(AF_INET6, &prefix->prefix, - ntopbuf, INET6_ADDRSTRLEN), - prefix->prefixlen, rai->ifname); - if (prefix->timer) - rtadvd_remove_timer(&prefix->timer); - free(prefix); - rai->pfxs--; + __func__, + inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_prefixlen, rai->rai_ifname); + if (pfx->pfx_timer) + rtadvd_remove_timer(pfx->pfx_timer); + free(pfx); + rai->rai_pfxs--; + make_packet(rai); } void -invalidate_prefix(struct prefix *prefix) +invalidate_prefix(struct prefix *pfx) { u_char ntopbuf[INET6_ADDRSTRLEN]; struct timeval timo; - struct rainfo *rai = prefix->rainfo; + struct rainfo *rai; - if (prefix->timer) { /* sanity check */ + rai = pfx->pfx_rainfo; + if (pfx->pfx_timer) { /* sanity check */ syslog(LOG_ERR, "<%s> assumption failure: timer already exists", __func__); @@ -783,38 +943,38 @@ invalidate_prefix(struct prefix *prefix) syslog(LOG_DEBUG, "<%s> prefix %s/%d was invalidated on %s, " "will expire in %ld seconds", __func__, - inet_ntop(AF_INET6, &prefix->prefix, ntopbuf, INET6_ADDRSTRLEN), - prefix->prefixlen, rai->ifname, (long)prefix_timo); + inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, sizeof(ntopbuf)), + pfx->pfx_prefixlen, rai->rai_ifname, (long)prefix_timo); /* set the expiration timer */ - prefix->timer = rtadvd_add_timer(prefix_timeout, NULL, prefix, NULL); - if (prefix->timer == NULL) { + pfx->pfx_timer = rtadvd_add_timer(prefix_timeout, NULL, pfx, NULL); + if (pfx->pfx_timer == NULL) { syslog(LOG_ERR, "<%s> failed to add a timer for a prefix. " "remove the prefix", __func__); - delete_prefix(prefix); + delete_prefix(pfx); } timo.tv_sec = prefix_timo; timo.tv_usec = 0; - rtadvd_set_timer(&timo, prefix->timer); + rtadvd_set_timer(&timo, pfx->pfx_timer); } static struct rtadvd_timer * prefix_timeout(void *arg) { - struct prefix *prefix = (struct prefix *)arg; - - delete_prefix(prefix); - return(NULL); + delete_prefix((struct prefix *)arg); + + return (NULL); } void -update_prefix(struct prefix * prefix) +update_prefix(struct prefix *pfx) { u_char ntopbuf[INET6_ADDRSTRLEN]; - struct rainfo *rai = prefix->rainfo; + struct rainfo *rai; - if (prefix->timer == NULL) { /* sanity check */ + rai = pfx->pfx_rainfo; + if (pfx->pfx_timer == NULL) { /* sanity check */ syslog(LOG_ERR, "<%s> assumption failure: timer does not exist", __func__); @@ -822,11 +982,12 @@ update_prefix(struct prefix * prefix) } syslog(LOG_DEBUG, "<%s> prefix %s/%d was re-enabled on %s", - __func__, inet_ntop(AF_INET6, &prefix->prefix, ntopbuf, - INET6_ADDRSTRLEN), prefix->prefixlen, rai->ifname); + __func__, inet_ntop(AF_INET6, &pfx->pfx_prefix, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_prefixlen, rai->rai_ifname); /* stop the expiration timer */ - rtadvd_remove_timer(&prefix->timer); + rtadvd_remove_timer(pfx->pfx_timer); + pfx->pfx_timer = NULL; } /* @@ -842,13 +1003,13 @@ init_prefix(struct in6_prefixreq *ipr) if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, "<%s> socket: %s", __func__, - strerror(errno)); + strerror(errno)); exit(1); } if (ioctl(s, SIOCGIFPREFIX_IN6, (caddr_t)ipr) < 0) { syslog(LOG_INFO, "<%s> ioctl:SIOCGIFPREFIX %s", __func__, - strerror(errno)); + strerror(errno)); ipr->ipr_vltime = DEF_ADVVALIDLIFETIME; ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME; @@ -860,22 +1021,22 @@ init_prefix(struct in6_prefixreq *ipr) u_char ntopbuf[INET6_ADDRSTRLEN]; syslog(LOG_WARNING, "<%s> Added prefix(%s)'s origin %d is" - "lower than PR_ORIG_RR(router renumbering)." - "This should not happen if I am router", __func__, - inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf, - sizeof(ntopbuf)), ipr->ipr_origin); + "lower than PR_ORIG_RR(router renumbering)." + "This should not happen if I am router", __func__, + inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr, ntopbuf, + sizeof(ntopbuf)), ipr->ipr_origin); close(s); - return 1; + return (1); } close(s); - return 0; + return (0); #else ipr->ipr_vltime = DEF_ADVVALIDLIFETIME; ipr->ipr_pltime = DEF_ADVPREFERREDLIFETIME; ipr->ipr_raf_onlink = 1; ipr->ipr_raf_auto = 1; - return 0; + return (0); #endif } @@ -887,8 +1048,8 @@ make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen) memset(&ipr, 0, sizeof(ipr)); if (if_indextoname(ifindex, ipr.ipr_name) == NULL) { syslog(LOG_ERR, "<%s> Prefix added interface No.%d doesn't" - "exist. This should not happen! %s", __func__, - ifindex, strerror(errno)); + "exist. This should not happen! %s", __func__, + ifindex, strerror(errno)); exit(1); } ipr.ipr_prefix.sin6_len = sizeof(ipr.ipr_prefix); @@ -902,7 +1063,7 @@ make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen) } void -make_packet(struct rainfo *rainfo) +make_packet(struct rainfo *rai) { size_t packlen, lladdroptlen = 0; char *buf; @@ -913,45 +1074,68 @@ make_packet(struct rainfo *rainfo) struct nd_opt_route_info *ndopt_rti; struct rtinfo *rti; #endif + struct nd_opt_rdnss *ndopt_rdnss; + struct rdnss *rdn; + struct nd_opt_dnssl *ndopt_dnssl; + struct dnssl *dns; + size_t len; struct prefix *pfx; /* calculate total length */ packlen = sizeof(struct nd_router_advert); - if (rainfo->advlinkopt) { - if ((lladdroptlen = lladdropt_length(rainfo->sdl)) == 0) { + if (rai->rai_advlinkopt) { + if ((lladdroptlen = lladdropt_length(rai->rai_sdl)) == 0) { syslog(LOG_INFO, - "<%s> link-layer address option has" - " null length on %s. Treat as not included.", - __func__, rainfo->ifname); - rainfo->advlinkopt = 0; + "<%s> link-layer address option has" + " null length on %s. Treat as not included.", + __func__, rai->rai_ifname); + rai->rai_advlinkopt = 0; } packlen += lladdroptlen; } - if (rainfo->pfxs) - packlen += sizeof(struct nd_opt_prefix_info) * rainfo->pfxs; - if (rainfo->linkmtu) + if (rai->rai_pfxs) + packlen += sizeof(struct nd_opt_prefix_info) * rai->rai_pfxs; + if (rai->rai_linkmtu) packlen += sizeof(struct nd_opt_mtu); #ifdef ROUTEINFO - for (rti = rainfo->route.next; rti != &rainfo->route; rti = rti->next) - packlen += sizeof(struct nd_opt_route_info) + - ((rti->prefixlen + 0x3f) >> 6) * 8; + TAILQ_FOREACH(rti, &rai->rai_route, rti_next) + packlen += sizeof(struct nd_opt_route_info) + + ((rti->rti_prefixlen + 0x3f) >> 6) * 8; #endif + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { + struct rdnss_addr *rdna; + packlen += sizeof(struct nd_opt_rdnss); + TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next) + packlen += sizeof(rdna->ra_dns); + } + TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) { + struct dnssl_addr *dnsa; + + packlen += sizeof(struct nd_opt_dnssl); + len = 0; + TAILQ_FOREACH(dnsa, &dns->dn_list, da_next) + len += dnsa->da_len; + + /* A zero octet and 8 octet boundary */ + len++; + len += (len % 8) ? 8 - len % 8 : 0; + + packlen += len; + } /* allocate memory for the packet */ if ((buf = malloc(packlen)) == NULL) { syslog(LOG_ERR, - "<%s> can't get enough memory for an RA packet", - __func__); + "<%s> can't get enough memory for an RA packet", + __func__); exit(1); } - if (rainfo->ra_data) { - /* free the previous packet */ - free(rainfo->ra_data); - rainfo->ra_data = NULL; - } - rainfo->ra_data = buf; + memset(buf, 0, packlen); + if (rai->rai_ra_data) /* Free old data if any. */ + free(rai->rai_ra_data); + rai->rai_ra_data = buf; /* XXX: what if packlen > 576? */ - rainfo->ra_datalen = packlen; + rai->rai_ra_datalen = packlen; /* * construct the packet @@ -960,71 +1144,70 @@ make_packet(struct rainfo *rainfo) ra->nd_ra_type = ND_ROUTER_ADVERT; ra->nd_ra_code = 0; ra->nd_ra_cksum = 0; - ra->nd_ra_curhoplimit = (u_int8_t)(0xff & rainfo->hoplimit); + ra->nd_ra_curhoplimit = (u_int8_t)(0xff & rai->rai_hoplimit); ra->nd_ra_flags_reserved = 0; /* just in case */ /* * XXX: the router preference field, which is a 2-bit field, should be * initialized before other fields. */ - ra->nd_ra_flags_reserved = 0xff & rainfo->rtpref; + ra->nd_ra_flags_reserved = 0xff & rai->rai_rtpref; ra->nd_ra_flags_reserved |= - rainfo->managedflg ? ND_RA_FLAG_MANAGED : 0; + rai->rai_managedflg ? ND_RA_FLAG_MANAGED : 0; ra->nd_ra_flags_reserved |= - rainfo->otherflg ? ND_RA_FLAG_OTHER : 0; - ra->nd_ra_router_lifetime = htons(rainfo->lifetime); - ra->nd_ra_reachable = htonl(rainfo->reachabletime); - ra->nd_ra_retransmit = htonl(rainfo->retranstimer); + rai->rai_otherflg ? ND_RA_FLAG_OTHER : 0; + ra->nd_ra_router_lifetime = htons(rai->rai_lifetime); + ra->nd_ra_reachable = htonl(rai->rai_reachabletime); + ra->nd_ra_retransmit = htonl(rai->rai_retranstimer); buf += sizeof(*ra); - if (rainfo->advlinkopt) { - lladdropt_fill(rainfo->sdl, (struct nd_opt_hdr *)buf); + if (rai->rai_advlinkopt) { + lladdropt_fill(rai->rai_sdl, (struct nd_opt_hdr *)buf); buf += lladdroptlen; } - if (rainfo->linkmtu) { + if (rai->rai_linkmtu) { ndopt_mtu = (struct nd_opt_mtu *)buf; ndopt_mtu->nd_opt_mtu_type = ND_OPT_MTU; ndopt_mtu->nd_opt_mtu_len = 1; ndopt_mtu->nd_opt_mtu_reserved = 0; - ndopt_mtu->nd_opt_mtu_mtu = htonl(rainfo->linkmtu); + ndopt_mtu->nd_opt_mtu_mtu = htonl(rai->rai_linkmtu); buf += sizeof(struct nd_opt_mtu); } - for (pfx = rainfo->prefix.next; - pfx != &rainfo->prefix; pfx = pfx->next) { + TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { u_int32_t vltime, pltime; struct timeval now; ndopt_pi = (struct nd_opt_prefix_info *)buf; ndopt_pi->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION; ndopt_pi->nd_opt_pi_len = 4; - ndopt_pi->nd_opt_pi_prefix_len = pfx->prefixlen; + ndopt_pi->nd_opt_pi_prefix_len = pfx->pfx_prefixlen; ndopt_pi->nd_opt_pi_flags_reserved = 0; - if (pfx->onlinkflg) + if (pfx->pfx_onlinkflg) ndopt_pi->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_ONLINK; - if (pfx->autoconfflg) + if (pfx->pfx_autoconfflg) ndopt_pi->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO; - if (pfx->timer) + if (pfx->pfx_timer) vltime = 0; else { - if (pfx->vltimeexpire || pfx->pltimeexpire) + if (pfx->pfx_vltimeexpire || pfx->pfx_pltimeexpire) gettimeofday(&now, NULL); - if (pfx->vltimeexpire == 0) - vltime = pfx->validlifetime; + if (pfx->pfx_vltimeexpire == 0) + vltime = pfx->pfx_validlifetime; else - vltime = (pfx->vltimeexpire > now.tv_sec) ? - pfx->vltimeexpire - now.tv_sec : 0; + vltime = (pfx->pfx_vltimeexpire > now.tv_sec) ? + pfx->pfx_vltimeexpire - now.tv_sec : 0; } - if (pfx->timer) + if (pfx->pfx_timer) pltime = 0; else { - if (pfx->pltimeexpire == 0) - pltime = pfx->preflifetime; + if (pfx->pfx_pltimeexpire == 0) + pltime = pfx->pfx_preflifetime; else - pltime = (pfx->pltimeexpire > now.tv_sec) ? - pfx->pltimeexpire - now.tv_sec : 0; + pltime = (pfx->pfx_pltimeexpire > now.tv_sec) ? + pfx->pfx_pltimeexpire - now.tv_sec : 0; } if (vltime < pltime) { /* @@ -1036,45 +1219,72 @@ make_packet(struct rainfo *rainfo) ndopt_pi->nd_opt_pi_valid_time = htonl(vltime); ndopt_pi->nd_opt_pi_preferred_time = htonl(pltime); ndopt_pi->nd_opt_pi_reserved2 = 0; - ndopt_pi->nd_opt_pi_prefix = pfx->prefix; + ndopt_pi->nd_opt_pi_prefix = pfx->pfx_prefix; buf += sizeof(struct nd_opt_prefix_info); } #ifdef ROUTEINFO - for (rti = rainfo->route.next; rti != &rainfo->route; rti = rti->next) { - u_int8_t psize = (rti->prefixlen + 0x3f) >> 6; + TAILQ_FOREACH(rti, &rai->rai_route, rti_next) { + u_int8_t psize = (rti->rti_prefixlen + 0x3f) >> 6; ndopt_rti = (struct nd_opt_route_info *)buf; ndopt_rti->nd_opt_rti_type = ND_OPT_ROUTE_INFO; ndopt_rti->nd_opt_rti_len = 1 + psize; - ndopt_rti->nd_opt_rti_prefixlen = rti->prefixlen; - ndopt_rti->nd_opt_rti_flags = 0xff & rti->rtpref; - ndopt_rti->nd_opt_rti_lifetime = htonl(rti->ltime); - memcpy(ndopt_rti + 1, &rti->prefix, psize * 8); + ndopt_rti->nd_opt_rti_prefixlen = rti->rti_prefixlen; + ndopt_rti->nd_opt_rti_flags = 0xff & rti->rti_rtpref; + ndopt_rti->nd_opt_rti_lifetime = htonl(rti->rti_ltime); + memcpy(ndopt_rti + 1, &rti->rti_prefix, psize * 8); buf += sizeof(struct nd_opt_route_info) + psize * 8; } #endif + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { + struct rdnss_addr *rdna; + ndopt_rdnss = (struct nd_opt_rdnss *)buf; + ndopt_rdnss->nd_opt_rdnss_type = ND_OPT_RDNSS; + ndopt_rdnss->nd_opt_rdnss_len = 0; + ndopt_rdnss->nd_opt_rdnss_reserved = 0; + ndopt_rdnss->nd_opt_rdnss_lifetime = htonl(rdn->rd_ltime); + buf += sizeof(struct nd_opt_rdnss); + + TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next) { + memcpy(buf, &rdna->ra_dns, sizeof(rdna->ra_dns)); + buf += sizeof(rdna->ra_dns); + } + /* Length field should be in 8 octets */ + ndopt_rdnss->nd_opt_rdnss_len = (buf - (char *)ndopt_rdnss) / 8; + + syslog(LOG_DEBUG, "<%s>: nd_opt_dnss_len = %d", __func__, + ndopt_rdnss->nd_opt_rdnss_len); + } + TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) { + struct dnssl_addr *dnsa; + + ndopt_dnssl = (struct nd_opt_dnssl *)buf; + ndopt_dnssl->nd_opt_dnssl_type = ND_OPT_DNSSL; + ndopt_dnssl->nd_opt_dnssl_len = 0; + ndopt_dnssl->nd_opt_dnssl_reserved = 0; + ndopt_dnssl->nd_opt_dnssl_lifetime = htonl(dns->dn_ltime); + buf += sizeof(*ndopt_dnssl); + + TAILQ_FOREACH(dnsa, &dns->dn_list, da_next) { + memcpy(buf, dnsa->da_dom, dnsa->da_len); + buf += dnsa->da_len; + } + + /* A zero octet after encoded DNS server list. */ + *buf++ = '\0'; + + /* Padding to next 8 octets boundary */ + len = buf - (char *)ndopt_dnssl; + len += (len % 8) ? 8 - len % 8 : 0; + + /* Length field must be in 8 octets */ + ndopt_dnssl->nd_opt_dnssl_len = len / 8; + + syslog(LOG_DEBUG, "<%s>: nd_opt_dnssl_len = %d", __func__, + ndopt_dnssl->nd_opt_dnssl_len); + } return; } - -static int -getinet6sysctl(int code) -{ - int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 }; - int value; - size_t size; - - mib[3] = code; - size = sizeof(value); - if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0) - < 0) { - syslog(LOG_ERR, "<%s>: failed to get ip6 sysctl(%d): %s", - __func__, code, - strerror(errno)); - return(-1); - } - else - return(value); -} diff --git a/usr.sbin/rtadvd/config.h b/usr.sbin/rtadvd/config.h index 2d02b8a57606..38c19b8b422b 100644 --- a/usr.sbin/rtadvd/config.h +++ b/usr.sbin/rtadvd/config.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -30,7 +30,8 @@ * SUCH DAMAGE. */ -extern void getconfig(char *); +extern int getconfig(int); +extern int rmconfig(int); extern void delete_prefix(struct prefix *); extern void invalidate_prefix(struct prefix *); extern void update_prefix(struct prefix *); @@ -45,3 +46,5 @@ extern void get_prefix(struct rainfo *); */ #define MAXPREFIX 100 #define MAXROUTE 100 +#define MAXRDNSSENT 100 +#define MAXDNSSLENT 100 diff --git a/usr.sbin/rtadvd/dump.c b/usr.sbin/rtadvd/dump.c index d37f5db656fc..f79319bd3e36 100644 --- a/usr.sbin/rtadvd/dump.c +++ b/usr.sbin/rtadvd/dump.c @@ -4,7 +4,7 @@ /* * Copyright (C) 2000 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -45,6 +45,7 @@ #include +#include #include #include #include @@ -63,8 +64,9 @@ extern struct rainfo *ralist; static char *ether_str(struct sockaddr_dl *); static void if_dump(void); +static size_t dname_labeldec(char *, size_t, const char *); -static char *rtpref_str[] = { +static const char *rtpref_str[] = { "medium", /* 00 */ "high", /* 01 */ "rsv", /* 10 */ @@ -72,8 +74,7 @@ static char *rtpref_str[] = { }; static char * -ether_str(sdl) - struct sockaddr_dl *sdl; +ether_str(struct sockaddr_dl *sdl) { static char hbuf[32]; u_char *cp; @@ -85,84 +86,86 @@ ether_str(sdl) } else snprintf(hbuf, sizeof(hbuf), "NONE"); - return(hbuf); + return (hbuf); } static void -if_dump() +if_dump(void) { struct rainfo *rai; struct prefix *pfx; #ifdef ROUTEINFO struct rtinfo *rti; #endif + struct rdnss *rdn; + struct dnssl *dns; char prefixbuf[INET6_ADDRSTRLEN]; - int first; struct timeval now; gettimeofday(&now, NULL); /* XXX: unused in most cases */ - for (rai = ralist; rai; rai = rai->next) { - fprintf(fp, "%s:\n", rai->ifname); + TAILQ_FOREACH(rai, &railist, rai_next) { + fprintf(fp, "%s:\n", rai->rai_ifname); fprintf(fp, " Status: %s\n", - (iflist[rai->ifindex]->ifm_flags & IFF_UP) ? "UP" : - "DOWN"); + (iflist[rai->rai_ifindex]->ifm_flags & IFF_UP) ? "UP" : + "DOWN"); /* control information */ - if (rai->lastsent.tv_sec) { + if (rai->rai_lastsent.tv_sec) { /* note that ctime() appends CR by itself */ fprintf(fp, " Last RA sent: %s", - ctime((time_t *)&rai->lastsent.tv_sec)); + ctime((time_t *)&rai->rai_lastsent.tv_sec)); } - if (rai->timer) { + if (rai->rai_timer) fprintf(fp, " Next RA will be sent: %s", - ctime((time_t *)&rai->timer->tm.tv_sec)); - } + ctime((time_t *)&rai->rai_timer->rat_tm.tv_sec)); else fprintf(fp, " RA timer is stopped"); fprintf(fp, " waits: %d, initcount: %d\n", - rai->waiting, rai->initcounter); + rai->rai_waiting, rai->rai_initcounter); /* statistics */ fprintf(fp, " statistics: RA(out/in/inconsistent): " "%llu/%llu/%llu, ", - (unsigned long long)rai->raoutput, - (unsigned long long)rai->rainput, - (unsigned long long)rai->rainconsistent); + (unsigned long long)rai->rai_raoutput, + (unsigned long long)rai->rai_rainput, + (unsigned long long)rai->rai_rainconsistent); fprintf(fp, "RS(input): %llu\n", - (unsigned long long)rai->rsinput); + (unsigned long long)rai->rai_rsinput); /* interface information */ - if (rai->advlinkopt) + if (rai->rai_advlinkopt) fprintf(fp, " Link-layer address: %s\n", - ether_str(rai->sdl)); - fprintf(fp, " MTU: %d\n", rai->phymtu); + ether_str(rai->rai_sdl)); + fprintf(fp, " MTU: %d\n", rai->rai_phymtu); /* Router configuration variables */ fprintf(fp, " DefaultLifetime: %d, MaxAdvInterval: %d, " - "MinAdvInterval: %d\n", rai->lifetime, rai->maxinterval, - rai->mininterval); - fprintf(fp, " Flags: %s%s%s, ", - rai->managedflg ? "M" : "", rai->otherflg ? "O" : "", ""); + "MinAdvInterval: %d\n", rai->rai_lifetime, + rai->rai_maxinterval, rai->rai_mininterval); + fprintf(fp, " Flags: "); + if (rai->rai_managedflg || rai->rai_otherflg) { + fprintf(fp, "%s", rai->rai_managedflg ? "M" : ""); + fprintf(fp, "%s", rai->rai_otherflg ? "O" : ""); + } else + fprintf(fp, ""); + fprintf(fp, ", "); fprintf(fp, "Preference: %s, ", - rtpref_str[(rai->rtpref >> 3) & 0xff]); - fprintf(fp, "MTU: %d\n", rai->linkmtu); + rtpref_str[(rai->rai_rtpref >> 3) & 0xff]); + fprintf(fp, "MTU: %d\n", rai->rai_linkmtu); fprintf(fp, " ReachableTime: %d, RetransTimer: %d, " - "CurHopLimit: %d\n", rai->reachabletime, - rai->retranstimer, rai->hoplimit); - if (rai->clockskew) + "CurHopLimit: %d\n", rai->rai_reachabletime, + rai->rai_retranstimer, rai->rai_hoplimit); + if (rai->rai_clockskew) fprintf(fp, " Clock skew: %ldsec\n", - rai->clockskew); - for (first = 1, pfx = rai->prefix.next; pfx != &rai->prefix; - pfx = pfx->next) { - if (first) { + rai->rai_clockskew); + TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { + if (pfx == TAILQ_FIRST(&rai->rai_prefix)) fprintf(fp, " Prefixes:\n"); - first = 0; - } fprintf(fp, " %s/%d(", - inet_ntop(AF_INET6, &pfx->prefix, prefixbuf, - sizeof(prefixbuf)), pfx->prefixlen); - switch (pfx->origin) { + inet_ntop(AF_INET6, &pfx->pfx_prefix, prefixbuf, + sizeof(prefixbuf)), pfx->pfx_prefixlen); + switch (pfx->pfx_origin) { case PREFIX_FROM_KERNEL: fprintf(fp, "KERNEL, "); break; @@ -173,36 +176,42 @@ if_dump() fprintf(fp, "DYNAMIC, "); break; } - if (pfx->validlifetime == ND6_INFINITE_LIFETIME) + if (pfx->pfx_validlifetime == ND6_INFINITE_LIFETIME) fprintf(fp, "vltime: infinity"); else fprintf(fp, "vltime: %ld", - (long)pfx->validlifetime); - if (pfx->vltimeexpire != 0) - fprintf(fp, "(decr,expire %ld), ", (long) - pfx->vltimeexpire > now.tv_sec ? - pfx->vltimeexpire - now.tv_sec : 0); + (long)pfx->pfx_validlifetime); + if (pfx->pfx_vltimeexpire != 0) + fprintf(fp, "(decr,expire %ld), ", + (long)pfx->pfx_vltimeexpire > now.tv_sec ? + (long)pfx->pfx_vltimeexpire - now.tv_sec : + 0); else fprintf(fp, ", "); - if (pfx->preflifetime == ND6_INFINITE_LIFETIME) + if (pfx->pfx_preflifetime == ND6_INFINITE_LIFETIME) fprintf(fp, "pltime: infinity"); else fprintf(fp, "pltime: %ld", - (long)pfx->preflifetime); - if (pfx->pltimeexpire != 0) - fprintf(fp, "(decr,expire %ld), ", (long) - pfx->pltimeexpire > now.tv_sec ? - pfx->pltimeexpire - now.tv_sec : 0); + (long)pfx->pfx_preflifetime); + if (pfx->pfx_pltimeexpire != 0) + fprintf(fp, "(decr,expire %ld), ", + (long)pfx->pfx_pltimeexpire > now.tv_sec ? + (long)pfx->pfx_pltimeexpire - now.tv_sec : + 0); else fprintf(fp, ", "); - fprintf(fp, "flags: %s%s%s", - pfx->onlinkflg ? "L" : "", - pfx->autoconfflg ? "A" : "", - ""); - if (pfx->timer) { + fprintf(fp, "flags: "); + if (pfx->pfx_onlinkflg || pfx->pfx_autoconfflg) { + fprintf(fp, "%s", + pfx->pfx_onlinkflg ? "L" : ""); + fprintf(fp, "%s", + pfx->pfx_autoconfflg ? "A" : ""); + } else + fprintf(fp, ""); + if (pfx->pfx_timer) { struct timeval *rest; - rest = rtadvd_timer_rest(pfx->timer); + rest = rtadvd_timer_rest(pfx->pfx_timer); if (rest) { /* XXX: what if not? */ fprintf(fp, ", expire in: %ld", (long)rest->tv_sec); @@ -211,31 +220,64 @@ if_dump() fprintf(fp, ")\n"); } #ifdef ROUTEINFO - for (first = 1, rti = rai->route.next; rti != &rai->route; - rti = rti->next) { - if (first) { + TAILQ_FOREACH(rti, &rai->rai_route, rti_next) { + if (rti == TAILQ_FIRST(&rai->rai_route)) fprintf(fp, " Route Information:\n"); - first = 0; - } fprintf(fp, " %s/%d (", - inet_ntop(AF_INET6, &rti->prefix, - prefixbuf, sizeof(prefixbuf)), - rti->prefixlen); + inet_ntop(AF_INET6, &rti->rti_prefix, + prefixbuf, sizeof(prefixbuf)), + rti->rti_prefixlen); fprintf(fp, "preference: %s, ", - rtpref_str[0xff & (rti->rtpref >> 3)]); - if (rti->ltime == ND6_INFINITE_LIFETIME) + rtpref_str[0xff & (rti->rti_rtpref >> 3)]); + if (rti->rti_ltime == ND6_INFINITE_LIFETIME) fprintf(fp, "lifetime: infinity"); else - fprintf(fp, "lifetime: %ld", (long)rti->ltime); + fprintf(fp, "lifetime: %ld", + (long)rti->rti_ltime); fprintf(fp, ")\n"); } #endif + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) { + struct rdnss_addr *rdna; + + if (rdn == TAILQ_FIRST(&rai->rai_rdnss)) + fprintf(fp, " Recursive DNS servers:\n" + " Lifetime\tServers\n"); + + fprintf(fp, " %8u\t", rdn->rd_ltime); + TAILQ_FOREACH(rdna, &rdn->rd_list, ra_next) { + inet_ntop(AF_INET6, &rdna->ra_dns, + prefixbuf, sizeof(prefixbuf)); + + if (rdna != TAILQ_FIRST(&rdn->rd_list)) + fprintf(fp, " \t"); + fprintf(fp, "%s\n", prefixbuf); + } + fprintf(fp, "\n"); + } + + TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) { + struct dnssl_addr *dnsa; + char buf[NI_MAXHOST]; + + if (dns == TAILQ_FIRST(&rai->rai_dnssl)) + fprintf(fp, " DNS search list:\n" + " Lifetime\tDomains\n"); + + fprintf(fp, " %8u\t", dns->dn_ltime); + TAILQ_FOREACH(dnsa, &dns->dn_list, da_next) { + dname_labeldec(buf, sizeof(buf), dnsa->da_dom); + if (dnsa != TAILQ_FIRST(&dns->dn_list)) + fprintf(fp, " \t"); + fprintf(fp, "%s(%d)\n", buf, dnsa->da_len); + } + fprintf(fp, "\n"); + } } } void -rtadvd_dump_file(dumpfile) - char *dumpfile; +rtadvd_dump_file(const char *dumpfile) { syslog(LOG_DEBUG, "<%s> dump current status to %s", __func__, dumpfile); @@ -250,3 +292,30 @@ rtadvd_dump_file(dumpfile) fclose(fp); } + +/* Decode domain name label encoding in RFC 1035 Section 3.1 */ +static size_t +dname_labeldec(char *dst, size_t dlen, const char *src) +{ + size_t len; + const char *src_origin; + const char *src_last; + const char *dst_origin; + + src_origin = src; + src_last = strchr(src, '\0'); + dst_origin = dst; + memset(dst, '\0', dlen); + while (src && (len = (uint8_t)(*src++) & 0x3f) && + (src + len) <= src_last) { + if (dst != dst_origin) + *dst++ = '.'; + syslog(LOG_DEBUG, "<%s> labellen = %d", __func__, len); + memcpy(dst, src, len); + src += len; + dst += len; + } + *dst = '\0'; + + return (src - src_origin); +} diff --git a/usr.sbin/rtadvd/dump.h b/usr.sbin/rtadvd/dump.h index c8a6b22a6dae..8696e1302f9d 100644 --- a/usr.sbin/rtadvd/dump.h +++ b/usr.sbin/rtadvd/dump.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -30,4 +30,4 @@ * SUCH DAMAGE. */ -extern void rtadvd_dump_file(char *); +extern void rtadvd_dump_file(const char *); diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c index d8ed088d8495..302c33447c15 100644 --- a/usr.sbin/rtadvd/if.c +++ b/usr.sbin/rtadvd/if.c @@ -4,7 +4,7 @@ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -44,34 +44,35 @@ #include #include #include +#include #include #include #include #include "rtadvd.h" #include "if.h" -#define ROUNDUP(a, size) \ +#define ROUNDUP(a, size) \ (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a)) -#define NEXT_SA(ap) (ap) = (struct sockaddr *) \ - ((caddr_t)(ap) + ((ap)->sa_len ? ROUNDUP((ap)->sa_len,\ - sizeof(u_long)) :\ - sizeof(u_long))) +#define NEXT_SA(ap) \ + (ap) = (struct sockaddr *)((caddr_t)(ap) + \ + ((ap)->sa_len ? ROUNDUP((ap)->sa_len, sizeof(u_long)) : \ + sizeof(u_long))) struct if_msghdr **iflist; int iflist_init_ok; size_t ifblock_size; char *ifblock; -static void get_iflist(char **buf, size_t *size); -static void parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, - size_t bufsize); +static void get_iflist(char **buf, size_t *size); +static void parse_iflist(struct if_msghdr ***ifmlist_p, + char *buf, size_t bufsize); static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) { int i; - + for (i = 0; i < RTAX_MAX; i++) { if (addrs & (1 << i)) { rti_info[i] = sa; @@ -93,12 +94,12 @@ if_nametosdl(char *name) struct sockaddr_dl *sdl = NULL, *ret_sdl; if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) - return(NULL); + return (NULL); if ((buf = malloc(len)) == NULL) - return(NULL); + return (NULL); if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { free(buf); - return(NULL); + return (NULL); } lim = buf + len; @@ -124,7 +125,7 @@ if_nametosdl(char *name) if (next == lim) { /* search failed */ free(buf); - return(NULL); + return (NULL); } if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) @@ -133,7 +134,7 @@ if_nametosdl(char *name) end: free(buf); - return(ret_sdl); + return (ret_sdl); } int @@ -144,7 +145,7 @@ if_getmtu(char *name) u_long mtu = 0; if (getifaddrs(&ifap) < 0) - return(0); + return (0); for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (strcmp(ifa->ifa_name, name) == 0) { ifd = ifa->ifa_data; @@ -161,14 +162,14 @@ if_getmtu(char *name) int s; if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) - return(0); + return (0); ifr.ifr_addr.sa_family = AF_INET6; strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) < 0) { close(s); - return(0); + return (0); } close(s); @@ -176,7 +177,7 @@ if_getmtu(char *name) } #endif - return(mtu); + return (mtu); } /* give interface index and its old flags, then new flags returned */ @@ -188,14 +189,14 @@ if_getflags(int ifindex, int oifflags) if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, "<%s> socket: %s", __func__, - strerror(errno)); + strerror(errno)); return (oifflags & ~IFF_UP); } if_indextoname(ifindex, ifr.ifr_name); if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { syslog(LOG_ERR, "<%s> ioctl:SIOCGIFFLAGS: failed for %s", - __func__, ifr.ifr_name); + __func__, ifr.ifr_name); close(s); return (oifflags & ~IFF_UP); } @@ -209,9 +210,9 @@ lladdropt_length(struct sockaddr_dl *sdl) { switch (sdl->sdl_type) { case IFT_ETHER: - return(ROUNDUP8(ETHER_ADDR_LEN + 2)); + return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: - return(0); + return (0); } } @@ -238,16 +239,15 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_hdr *ndopt) } int -rtbuf_len() +rtbuf_len(void) { size_t len; - int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET6, NET_RT_DUMP, 0}; if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) - return(-1); + return (-1); - return(len); + return (len); } #define FILTER_MATCH(type, filter) ((0x1 << type) & filter) @@ -267,14 +267,21 @@ get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter) /* just for safety */ if (!rtm->rtm_msglen) { syslog(LOG_WARNING, "<%s> rtm_msglen is 0 " - "(buf=%p lim=%p rtm=%p)", __func__, - buf, lim, rtm); + "(buf=%p lim=%p rtm=%p)", __func__, + buf, lim, rtm); break; } - if (FILTER_MATCH(rtm->rtm_type, filter) == 0) { + if (((struct rt_msghdr *)buf)->rtm_version != RTM_VERSION) { + syslog(LOG_WARNING, + "<%s> routing message version mismatch " + "(buf=%p lim=%p rtm=%p)", __func__, + buf, lim, rtm); continue; } + if (FILTER_MATCH(rtm->rtm_type, filter) == 0) + continue; + switch (rtm->rtm_type) { case RTM_GET: case RTM_ADD: @@ -328,6 +335,7 @@ get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter) return (char *)rtm; /* NOTREACHED */ case RTM_IFINFO: + case RTM_IFANNOUNCE: /* found */ *lenp = rtm->rtm_msglen; return (char *)rtm; @@ -335,7 +343,7 @@ get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter) } } - return (char *)rtm; + return ((char *)rtm); } #undef FILTER_MATCH @@ -348,7 +356,7 @@ get_addr(char *buf) sa = (struct sockaddr *)(rtm + 1); get_rtaddrs(rtm->rtm_addrs, sa, rti_info); - return(&SIN6(rti_info[RTAX_DST])->sin6_addr); + return (&SIN6(rti_info[RTAX_DST])->sin6_addr); } int @@ -360,7 +368,7 @@ get_rtm_ifindex(char *buf) sa = (struct sockaddr *)(rtm + 1); get_rtaddrs(rtm->rtm_addrs, sa, rti_info); - return(((struct sockaddr_dl *)rti_info[RTAX_GATEWAY])->sdl_index); + return (((struct sockaddr_dl *)rti_info[RTAX_GATEWAY])->sdl_index); } int @@ -393,7 +401,7 @@ get_prefixlen(char *buf) struct rt_msghdr *rtm = (struct rt_msghdr *)buf; struct sockaddr *sa, *rti_info[RTAX_MAX]; u_char *p, *lim; - + sa = (struct sockaddr *)(rtm + 1); get_rtaddrs(rtm->rtm_addrs, sa, rti_info); sa = rti_info[RTAX_NETMASK]; @@ -437,11 +445,11 @@ prefixlen(u_char *p, u_char *lim) case 0x00: break; default: - return(-1); + return (-1); } } - return(masklen); + return (masklen); } int @@ -449,7 +457,7 @@ rtmsg_type(char *buf) { struct rt_msghdr *rtm = (struct rt_msghdr *)buf; - return(rtm->rtm_type); + return (rtm->rtm_type); } int @@ -457,7 +465,7 @@ rtmsg_len(char *buf) { struct rt_msghdr *rtm = (struct rt_msghdr *)buf; - return(rtm->rtm_msglen); + return (rtm->rtm_msglen); } int @@ -465,7 +473,7 @@ ifmsg_len(char *buf) { struct if_msghdr *ifm = (struct if_msghdr *)buf; - return(ifm->ifm_msglen); + return (ifm->ifm_msglen); } /* @@ -486,7 +494,7 @@ get_iflist(char **buf, size_t *size) if (sysctl(mib, 6, NULL, size, NULL, 0) < 0) { syslog(LOG_ERR, "<%s> sysctl: iflist size get failed", - __func__); + __func__); exit(1); } if ((*buf = malloc(*size)) == NULL) { @@ -495,7 +503,7 @@ get_iflist(char **buf, size_t *size) } if (sysctl(mib, 6, *buf, size, NULL, 0) < 0) { syslog(LOG_ERR, "<%s> sysctl: iflist get failed", - __func__); + __func__); exit(1); } return; @@ -529,8 +537,8 @@ parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) for (ifm = (struct if_msghdr *)buf; ifm < (struct if_msghdr *)lim;) { if (ifm->ifm_msglen == 0) { syslog(LOG_WARNING, "<%s> ifm_msglen is 0 " - "(buf=%p lim=%p ifm=%p)", __func__, - buf, lim, ifm); + "(buf=%p lim=%p ifm=%p)", __func__, + buf, lim, ifm); return; } @@ -538,10 +546,10 @@ parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) (*ifmlist_p)[ifm->ifm_index] = ifm; } else { syslog(LOG_ERR, "out of sync parsing NET_RT_IFLIST\n" - "expected %d, got %d\n msglen = %d\n" - "buf:%p, ifm:%p, lim:%p\n", - RTM_IFINFO, ifm->ifm_type, ifm->ifm_msglen, - buf, ifm, lim); + "expected %d, got %d\n msglen = %d\n" + "buf:%p, ifm:%p, lim:%p\n", + RTM_IFINFO, ifm->ifm_type, ifm->ifm_msglen, + buf, ifm, lim); exit (1); } for (ifam = (struct ifa_msghdr *) @@ -552,8 +560,8 @@ parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) /* just for safety */ if (!ifam->ifam_msglen) { syslog(LOG_WARNING, "<%s> ifa_msglen is 0 " - "(buf=%p lim=%p ifam=%p)", __func__, - buf, lim, ifam); + "(buf=%p lim=%p ifam=%p)", __func__, + buf, lim, ifam); return; } if (ifam->ifam_type != RTM_NEWADDR) @@ -564,8 +572,11 @@ parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) } void -init_iflist() +init_iflist(void) { + syslog(LOG_DEBUG, + "<%s> generate iflist.", __func__); + if (ifblock) { free(ifblock); ifblock_size = 0; diff --git a/usr.sbin/rtadvd/if.h b/usr.sbin/rtadvd/if.h index 216eaa044ef6..8728e1991fac 100644 --- a/usr.sbin/rtadvd/if.h +++ b/usr.sbin/rtadvd/if.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 diff --git a/usr.sbin/rtadvd/pathnames.h b/usr.sbin/rtadvd/pathnames.h index 3afee55fcc72..13329da347c6 100644 --- a/usr.sbin/rtadvd/pathnames.h +++ b/usr.sbin/rtadvd/pathnames.h @@ -1,4 +1,7 @@ /* $KAME: pathnames.h,v 1.2 2000/05/16 13:34:13 itojun Exp $ */ /* $FreeBSD$ */ -#define _PATH_RTADVDCONF "/etc/rtadvd.conf" +#define _PATH_RTADVDCONF "/etc/rtadvd.conf" +#define _PATH_RTADVDDUMP "/var/run/rtadvd.dump" +#define _PATH_RTADVDPID "/var/run/rtadvd.pid" + diff --git a/usr.sbin/rtadvd/rrenum.c b/usr.sbin/rtadvd/rrenum.c index aafa0f97cdc3..660ed5397bcf 100644 --- a/usr.sbin/rtadvd/rrenum.c +++ b/usr.sbin/rtadvd/rrenum.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -74,7 +75,7 @@ static int s = -1; /* * Check validity of a Prefix Control Operation(PCO). - * Return 0 on success, 1 on failure. + * return 0 on success, 1 on failure. */ static int rr_pco_check(int len, struct rr_pco_match *rpm) @@ -86,8 +87,8 @@ rr_pco_check(int len, struct rr_pco_match *rpm) if ((rpm->rpm_len - 3) < 0 || /* must be at least 3 */ (rpm->rpm_len - 3) & 0x3) { /* must be multiple of 4 */ syslog(LOG_WARNING, "<%s> rpm_len %d is not 4N * 3", - __func__, rpm->rpm_len); - return 1; + __func__, rpm->rpm_len); + return (1); } /* rpm->rpm_code must be valid value */ switch (rpm->rpm_code) { @@ -97,14 +98,14 @@ rr_pco_check(int len, struct rr_pco_match *rpm) break; default: syslog(LOG_WARNING, "<%s> unknown rpm_code %d", __func__, - rpm->rpm_code); - return 1; + rpm->rpm_code); + return (1); } /* rpm->rpm_matchlen must be 0 to 128 inclusive */ if (rpm->rpm_matchlen > 128) { syslog(LOG_WARNING, "<%s> rpm_matchlen %d is over 128", - __func__, rpm->rpm_matchlen); - return 1; + __func__, rpm->rpm_matchlen); + return (1); } /* @@ -126,23 +127,22 @@ rr_pco_check(int len, struct rr_pco_match *rpm) */ if (checklen > 128) { syslog(LOG_WARNING, "<%s> sum of rpu_uselen %d and" - " rpu_keeplen %d is %d(over 128)", - __func__, rpu->rpu_uselen, - rpu->rpu_keeplen, - rpu->rpu_uselen + rpu->rpu_keeplen); - return 1; + " rpu_keeplen %d is %d(over 128)", + __func__, rpu->rpu_uselen, rpu->rpu_keeplen, + rpu->rpu_uselen + rpu->rpu_keeplen); + return (1); } } - return 0; + return (0); } static void do_use_prefix(int len, struct rr_pco_match *rpm, - struct in6_rrenumreq *irr, int ifindex) + struct in6_rrenumreq *irr, int ifindex) { struct rr_pco_use *rpu, *rpulim; struct rainfo *rai; - struct prefix *pp; + struct prefix *pfx; rpu = (struct rr_pco_use *)(rpm + 1); rpulim = (struct rr_pco_use *)((char *)rpm + len); @@ -164,7 +164,7 @@ do_use_prefix(int len, struct rr_pco_match *rpm, if (ioctl(s, rrcmd2pco[rpm->rpm_code], (caddr_t)irr) < 0 && errno != EADDRNOTAVAIL) syslog(LOG_ERR, "<%s> ioctl: %s", __func__, - strerror(errno)); + strerror(errno)); return; } @@ -176,19 +176,23 @@ do_use_prefix(int len, struct rr_pco_match *rpm, irr->irr_u_uselen = rpu->rpu_uselen; irr->irr_u_keeplen = rpu->rpu_keeplen; irr->irr_raf_mask_onlink = - !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK); + !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK); irr->irr_raf_mask_auto = - !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_AUTO); + !!(rpu->rpu_ramask & ICMP6_RR_PCOUSE_RAFLAGS_AUTO); irr->irr_vltime = ntohl(rpu->rpu_vltime); irr->irr_pltime = ntohl(rpu->rpu_pltime); irr->irr_raf_onlink = - (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK) == 0 ? 0 : 1; + (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_ONLINK) == 0 ? + 0 : 1; irr->irr_raf_auto = - (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_AUTO) == 0 ? 0 : 1; + (rpu->rpu_raflags & ICMP6_RR_PCOUSE_RAFLAGS_AUTO) == 0 ? + 0 : 1; irr->irr_rrf_decrvalid = - (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME) == 0 ? 0 : 1; + (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME) == 0 ? + 0 : 1; irr->irr_rrf_decrprefd = - (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME) == 0 ? 0 : 1; + (rpu->rpu_flags & ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME) == 0 ? + 0 : 1; irr->irr_useprefix.sin6_len = sizeof(irr->irr_useprefix); irr->irr_useprefix.sin6_family = AF_INET6; irr->irr_useprefix.sin6_addr = rpu->rpu_prefix; @@ -196,7 +200,7 @@ do_use_prefix(int len, struct rr_pco_match *rpm, if (ioctl(s, rrcmd2pco[rpm->rpm_code], (caddr_t)irr) < 0 && errno != EADDRNOTAVAIL) syslog(LOG_ERR, "<%s> ioctl: %s", __func__, - strerror(errno)); + strerror(errno)); /* very adhoc: should be rewritten */ if (rpm->rpm_code == RPM_PCO_CHANGE && @@ -206,28 +210,31 @@ do_use_prefix(int len, struct rr_pco_match *rpm, if ((rai = if_indextorainfo(ifindex)) == NULL) continue; /* non-advertising IF */ - for (pp = rai->prefix.next; pp != &rai->prefix; - pp = pp->next) { + TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { struct timeval now; - if (prefix_match(&pp->prefix, pp->prefixlen, - &rpm->rpm_prefix, - rpm->rpm_matchlen)) { + if (prefix_match(&pfx->pfx_prefix, + pfx->pfx_prefixlen, &rpm->rpm_prefix, + rpm->rpm_matchlen)) { /* change parameters */ - pp->validlifetime = ntohl(rpu->rpu_vltime); - pp->preflifetime = ntohl(rpu->rpu_pltime); + pfx->pfx_validlifetime = + ntohl(rpu->rpu_vltime); + pfx->pfx_preflifetime = + ntohl(rpu->rpu_pltime); if (irr->irr_rrf_decrvalid) { gettimeofday(&now, 0); - pp->vltimeexpire = - now.tv_sec + pp->validlifetime; + pfx->pfx_vltimeexpire = + now.tv_sec + + pfx->pfx_validlifetime; } else - pp->vltimeexpire = 0; + pfx->pfx_vltimeexpire = 0; if (irr->irr_rrf_decrprefd) { gettimeofday(&now, 0); - pp->pltimeexpire = - now.tv_sec + pp->preflifetime; + pfx->pfx_pltimeexpire = + now.tv_sec + + pfx->pfx_preflifetime; } else - pp->pltimeexpire = 0; + pfx->pfx_pltimeexpire = 0; } } } @@ -245,11 +252,11 @@ do_pco(struct icmp6_router_renum *rr, int len, struct rr_pco_match *rpm) struct in6_rrenumreq irr; if ((rr_pco_check(len, rpm) != 0)) - return 1; + return (1); if (s == -1 && (s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { syslog(LOG_ERR, "<%s> socket: %s", __func__, - strerror(errno)); + strerror(errno)); exit(1); } @@ -264,8 +271,8 @@ do_pco(struct icmp6_router_renum *rr, int len, struct rr_pco_match *rpm) while (if_indextoname(++ifindex, irr.irr_name)) { /* - * if ICMP6_RR_FLAGS_FORCEAPPLY(A flag) is 0 and IFF_UP is off, - * the interface is not applied + * if ICMP6_RR_FLAGS_FORCEAPPLY(A flag) is 0 and + * IFF_UP is off, the interface is not applied */ if ((rr->rr_flags & ICMP6_RR_FLAGS_FORCEAPPLY) == 0 && (iflist[ifindex]->ifm_flags & IFF_UP) == 0) @@ -274,13 +281,13 @@ do_pco(struct icmp6_router_renum *rr, int len, struct rr_pco_match *rpm) do_use_prefix(len, rpm, &irr, ifindex); } if (errno == ENXIO) - return 0; + return (0); else if (errno) { syslog(LOG_ERR, "<%s> if_indextoname: %s", __func__, - strerror(errno)); - return 1; + strerror(errno)); + return (1); } - return 0; + return (0); } /* @@ -305,11 +312,11 @@ do_rr(int len, struct icmp6_router_renum *rr) int rpmlen; rpm = (struct rr_pco_match *)cp; - if (len < sizeof(struct rr_pco_match)) { + if ((size_t)len < sizeof(struct rr_pco_match)) { tooshort: syslog(LOG_ERR, "<%s> pkt too short. left len = %d. " - "gabage at end of pkt?", __func__, len); - return 1; + "gabage at end of pkt?", __func__, len); + return (1); } rpmlen = rpm->rpm_len << 3; if (len < rpmlen) @@ -325,7 +332,7 @@ do_rr(int len, struct icmp6_router_renum *rr) len -= rpmlen; } - return 0; + return (0); } /* @@ -334,46 +341,45 @@ do_rr(int len, struct icmp6_router_renum *rr) */ static int rr_command_check(int len, struct icmp6_router_renum *rr, struct in6_addr *from, - struct in6_addr *dst) + struct in6_addr *dst) { u_char ntopbuf[INET6_ADDRSTRLEN]; /* omit rr minimal length check. hope kernel have done it. */ /* rr_command length check */ - if (len < (sizeof(struct icmp6_router_renum) + - sizeof(struct rr_pco_match))) { + if ((size_t)len < (sizeof(struct icmp6_router_renum) + + sizeof(struct rr_pco_match))) { syslog(LOG_ERR, "<%s> rr_command len %d is too short", - __func__, len); - return 1; + __func__, len); + return (1); } /* destination check. only for multicast. omit unicast check. */ if (IN6_IS_ADDR_MULTICAST(dst) && !IN6_IS_ADDR_MC_LINKLOCAL(dst) && !IN6_IS_ADDR_MC_SITELOCAL(dst)) { syslog(LOG_ERR, "<%s> dst mcast addr %s is illegal", - __func__, - inet_ntop(AF_INET6, dst, ntopbuf, INET6_ADDRSTRLEN)); - return 1; + __func__, + inet_ntop(AF_INET6, dst, ntopbuf, sizeof(ntopbuf))); + return (1); } /* seqnum and segnum check */ if (rro.rro_seqnum > rr->rr_seqnum) { syslog(LOG_WARNING, - "<%s> rcvd old seqnum %d from %s", - __func__, (u_int32_t)ntohl(rr->rr_seqnum), - inet_ntop(AF_INET6, from, ntopbuf, INET6_ADDRSTRLEN)); - return 1; + "<%s> rcvd old seqnum %d from %s", + __func__, (u_int32_t)ntohl(rr->rr_seqnum), + inet_ntop(AF_INET6, from, ntopbuf, sizeof(ntopbuf))); + return (1); } if (rro.rro_seqnum == rr->rr_seqnum && (rr->rr_flags & ICMP6_RR_FLAGS_TEST) == 0 && RR_ISSET_SEGNUM(rro.rro_segnum_bits, rr->rr_segnum)) { if ((rr->rr_flags & ICMP6_RR_FLAGS_REQRESULT) != 0) syslog(LOG_WARNING, - "<%s> rcvd duped segnum %d from %s", - __func__, rr->rr_segnum, - inet_ntop(AF_INET6, from, ntopbuf, - INET6_ADDRSTRLEN)); - return 0; + "<%s> rcvd duped segnum %d from %s", + __func__, rr->rr_segnum, inet_ntop(AF_INET6, from, + ntopbuf, sizeof(ntopbuf))); + return (0); } /* update seqnum */ @@ -382,16 +388,16 @@ rr_command_check(int len, struct icmp6_router_renum *rr, struct in6_addr *from, /* init rro_segnum_bits */ memset(rro.rro_segnum_bits, 0, - sizeof(rro.rro_segnum_bits)); + sizeof(rro.rro_segnum_bits)); } rro.rro_seqnum = rr->rr_seqnum; - return 0; + return (0); } static void rr_command_input(int len, struct icmp6_router_renum *rr, - struct in6_addr *from, struct in6_addr *dst) + struct in6_addr *from, struct in6_addr *dst) { /* rr_command validity check */ if (rr_command_check(len, rr, from, dst)) @@ -401,9 +407,8 @@ rr_command_input(int len, struct icmp6_router_renum *rr, return; /* do router renumbering */ - if (do_rr(len, rr)) { + if (do_rr(len, rr)) goto failed; - } /* update segnum */ RR_SET_SEGNUM(rro.rro_segnum_bits, rr->rr_segnum); @@ -417,27 +422,26 @@ rr_command_input(int len, struct icmp6_router_renum *rr, void rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi, - struct sockaddr_in6 *from, struct in6_addr *dst) + struct sockaddr_in6 *from, struct in6_addr *dst) { u_char ntopbuf[2][INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; syslog(LOG_DEBUG, - "<%s> RR received from %s to %s on %s", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf[0], INET6_ADDRSTRLEN), - inet_ntop(AF_INET6, &dst, ntopbuf[1], INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> RR received from %s to %s on %s", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[0] ,sizeof(ntopbuf[0])), + inet_ntop(AF_INET6, &dst, ntopbuf[1], sizeof(ntopbuf[1])), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); /* packet validation based on Section 4.1 of RFC2894 */ - if (len < sizeof(struct icmp6_router_renum)) { + if ((size_t)len < sizeof(struct icmp6_router_renum)) { syslog(LOG_NOTICE, - "<%s>: RR short message (size %d) from %s to %s on %s", - __func__, len, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf[0], INET6_ADDRSTRLEN), - inet_ntop(AF_INET6, &dst, ntopbuf[1], INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s>: RR short message (size %d) from %s to %s on %s", + __func__, len, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[0], + sizeof(ntopbuf[0])), + inet_ntop(AF_INET6, &dst, ntopbuf[1], sizeof(ntopbuf[1])), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } @@ -449,16 +453,16 @@ rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi, * We rely on the kernel input routine for unicast addresses, and thus * check multicast destinations only. */ - if (IN6_IS_ADDR_MULTICAST(&pi->ipi6_addr) && - !IN6_ARE_ADDR_EQUAL(&in6a_site_allrouters, &pi->ipi6_addr)) { + if (IN6_IS_ADDR_MULTICAST(&pi->ipi6_addr) && !IN6_ARE_ADDR_EQUAL( + &sin6_sitelocal_allrouters.sin6_addr, &pi->ipi6_addr)) { syslog(LOG_NOTICE, - "<%s>: RR message with invalid destination (%s) " - "from %s on %s", - __func__, - inet_ntop(AF_INET6, &dst, ntopbuf[0], INET6_ADDRSTRLEN), - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf[1], INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s>: RR message with invalid destination (%s) " + "from %s on %s", + __func__, + inet_ntop(AF_INET6, &dst, ntopbuf[0], sizeof(ntopbuf[0])), + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[1], + sizeof(ntopbuf[1])), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } @@ -477,7 +481,7 @@ rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi, break; default: syslog(LOG_ERR, "<%s> received unknown code %d", - __func__, rr->rr_code); + __func__, rr->rr_code); break; } diff --git a/usr.sbin/rtadvd/rrenum.h b/usr.sbin/rtadvd/rrenum.h index c358a2b18f59..2b20d595dda7 100644 --- a/usr.sbin/rtadvd/rrenum.h +++ b/usr.sbin/rtadvd/rrenum.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 diff --git a/usr.sbin/rtadvd/rtadvd.8 b/usr.sbin/rtadvd/rtadvd.8 index 7bc30649310b..51596242646f 100644 --- a/usr.sbin/rtadvd/rtadvd.8 +++ b/usr.sbin/rtadvd/rtadvd.8 @@ -37,9 +37,10 @@ .Nd router advertisement daemon .Sh SYNOPSIS .Nm -.Op Fl dDfMRs +.Op Fl dDfRs .Op Fl c Ar configfile .Op Fl F Ar dumpfile +.Op Fl M Ar ifname .Op Fl p Ar pidfile .Ar interface ... .Sh DESCRIPTION @@ -103,7 +104,7 @@ will not watch the routing table and the whole functionality described above will be suppressed. .Pp Basically, hosts MUST NOT send Router Advertisement messages at any -time (RFC 2461, Section 6.2.3). +time (RFC 4861, Section 6.2.3). However, it would sometimes be useful to allow hosts to advertise some parameters such as prefix information and link MTU. Thus, @@ -176,7 +177,7 @@ In this case, .Nm will transmit router advertisement with router lifetime 0 to all the interfaces -.Pq in accordance with RFC2461 6.2.5 . +.Pq in accordance with RFC 4861 6.2.5 . .Sh FILES .Bl -tag -width Pa -compact .It Pa /etc/rtadvd.conf @@ -193,6 +194,34 @@ dumps its internal state. .Sh SEE ALSO .Xr rtadvd.conf 5 , .Xr rtsol 8 +.Rs +.%A Thomas Narten +.%A Erik Nordmark +.%A W. A. Simpson +.%A Hesham Soliman +.%T Neighbor Discovery for IP version 6 (IPv6) +.%R RFC 4861 +.Re +.Rs +.%A Thomas Narten +.%A Erik Nordmark +.%A W. A. Simpson +.%T Neighbor Discovery for IP version 6 (IPv6) +.%R RFC 2461 (obsoleted by RFC 4861) +.Re +.Rs +.%A Richard Draves +.%T Default Router Preferences and More-Specific Routes +.%R draft-ietf-ipngwg-router-selection-xx.txt +.Re +.Rs +.%A J. Jeong +.%A S. Park +.%A L. Beloeil +.%A S. Madanapalli +.%T IPv6 Router Advertisement Options for DNS Configuration +.%R RFC 6106 +.Re .Sh HISTORY The .Nm diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index 02e3dc70af6b..614d109f7596 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -4,7 +4,7 @@ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -31,12 +31,15 @@ */ #include +#include #include #include #include #include +#include #include +#include #include #include #include @@ -46,12 +49,17 @@ #include +#include +#include +#include + #include #include #include #include #include #include +#include #include #include #include @@ -66,6 +74,7 @@ #include "if.h" #include "config.h" #include "dump.h" +#include "pathnames.h" struct msghdr rcvmhdr; static u_char *rcvcmsgbuf; @@ -78,26 +87,27 @@ struct msghdr sndmhdr; struct iovec rcviov[2]; struct iovec sndiov[2]; struct sockaddr_in6 rcvfrom; -struct sockaddr_in6 sin6_allnodes = {sizeof(sin6_allnodes), AF_INET6}; -struct in6_addr in6a_site_allrouters; -static char *dumpfilename = "/var/run/rtadvd.dump"; -static char *pidfilename = "/var/run/rtadvd.pid"; +static const char *dumpfilename = _PATH_RTADVDDUMP; +static const char *pidfilename = _PATH_RTADVDPID; +const char *conffile = _PATH_RTADVDCONF; static struct pidfh *pfh; static char *mcastif; int sock; int rtsock = -1; int accept_rr = 0; int dflag = 0, sflag = 0; +static int ifl_len; +static char **ifl_names; -u_char *conffile = NULL; +struct railist_head_t railist = + TAILQ_HEAD_INITIALIZER(railist); -struct rainfo *ralist = NULL; struct nd_optlist { - struct nd_optlist *next; - struct nd_opt_hdr *opt; + TAILQ_ENTRY(nd_optlist) nol_next; + struct nd_opt_hdr *nol_opt; }; -union nd_opts { - struct nd_opt_hdr *nd_opt_array[9]; +union nd_opt { + struct nd_opt_hdr *opt_array[9]; struct { struct nd_opt_hdr *zero; struct nd_opt_hdr *src_lladdr; @@ -105,51 +115,76 @@ union nd_opts { struct nd_opt_prefix_info *pi; struct nd_opt_rd_hdr *rh; struct nd_opt_mtu *mtu; - struct nd_optlist *list; + TAILQ_HEAD(, nd_optlist) opt_list; } nd_opt_each; }; -#define nd_opts_src_lladdr nd_opt_each.src_lladdr -#define nd_opts_tgt_lladdr nd_opt_each.tgt_lladdr -#define nd_opts_pi nd_opt_each.pi -#define nd_opts_rh nd_opt_each.rh -#define nd_opts_mtu nd_opt_each.mtu -#define nd_opts_list nd_opt_each.list +#define opt_src_lladdr nd_opt_each.src_lladdr +#define opt_tgt_lladdr nd_opt_each.tgt_lladdr +#define opt_pi nd_opt_each.pi +#define opt_rh nd_opt_each.rh +#define opt_mtu nd_opt_each.mtu +#define opt_list nd_opt_each.opt_list -#define NDOPT_FLAG_SRCLINKADDR 0x1 -#define NDOPT_FLAG_TGTLINKADDR 0x2 -#define NDOPT_FLAG_PREFIXINFO 0x4 -#define NDOPT_FLAG_RDHDR 0x8 -#define NDOPT_FLAG_MTU 0x10 +#define NDOPT_FLAG_SRCLINKADDR (1 << 0) +#define NDOPT_FLAG_TGTLINKADDR (1 << 1) +#define NDOPT_FLAG_PREFIXINFO (1 << 2) +#define NDOPT_FLAG_RDHDR (1 << 3) +#define NDOPT_FLAG_MTU (1 << 4) +#define NDOPT_FLAG_RDNSS (1 << 5) +#define NDOPT_FLAG_DNSSL (1 << 6) u_int32_t ndopt_flags[] = { - 0, NDOPT_FLAG_SRCLINKADDR, NDOPT_FLAG_TGTLINKADDR, - NDOPT_FLAG_PREFIXINFO, NDOPT_FLAG_RDHDR, NDOPT_FLAG_MTU, + [ND_OPT_SOURCE_LINKADDR] = NDOPT_FLAG_SRCLINKADDR, + [ND_OPT_TARGET_LINKADDR] = NDOPT_FLAG_TGTLINKADDR, + [ND_OPT_PREFIX_INFORMATION] = NDOPT_FLAG_PREFIXINFO, + [ND_OPT_REDIRECTED_HEADER] = NDOPT_FLAG_RDHDR, + [ND_OPT_MTU] = NDOPT_FLAG_MTU, + [ND_OPT_RDNSS] = NDOPT_FLAG_RDNSS, + [ND_OPT_DNSSL] = NDOPT_FLAG_DNSSL, }; -int main(int, char *[]); -static void set_die(int); -static void die(void); -static void sock_open(void); -static void rtsock_open(void); -static void rtadvd_input(void); -static void rs_input(int, struct nd_router_solicit *, - struct in6_pktinfo *, struct sockaddr_in6 *); -static void ra_input(int, struct nd_router_advert *, - struct in6_pktinfo *, struct sockaddr_in6 *); -static int prefix_check(struct nd_opt_prefix_info *, struct rainfo *, - struct sockaddr_in6 *); -static int nd6_options(struct nd_opt_hdr *, int, - union nd_opts *, u_int32_t); -static void free_ndopts(union nd_opts *); -static void ra_output(struct rainfo *); -static void rtmsg_input(void); -static void rtadvd_set_dump_file(int); -static void set_short_delay(struct rainfo *); +struct sockaddr_in6 sin6_linklocal_allnodes = { + .sin6_len = sizeof(sin6_linklocal_allnodes), + .sin6_family = AF_INET6, + .sin6_addr = IN6ADDR_LINKLOCAL_ALLNODES_INIT, +}; + +struct sockaddr_in6 sin6_linklocal_allrouters = { + .sin6_len = sizeof(sin6_linklocal_allrouters), + .sin6_family = AF_INET6, + .sin6_addr = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT, +}; + +struct sockaddr_in6 sin6_sitelocal_allrouters = { + .sin6_len = sizeof(sin6_sitelocal_allrouters), + .sin6_family = AF_INET6, + .sin6_addr = IN6ADDR_SITELOCAL_ALLROUTERS_INIT, +}; + +static void set_die(int); +static void die(void); +static void sock_open(void); +static void rtsock_open(void); +static void rtadvd_input(void); +static void rs_input(int, struct nd_router_solicit *, + struct in6_pktinfo *, struct sockaddr_in6 *); +static void ra_input(int, struct nd_router_advert *, + struct in6_pktinfo *, struct sockaddr_in6 *); +static int prefix_check(struct nd_opt_prefix_info *, struct rainfo *, + struct sockaddr_in6 *); +static int nd6_options(struct nd_opt_hdr *, int, + union nd_opt *, u_int32_t); +static void free_ndopts(union nd_opt *); +static void ra_output(struct rainfo *); +static void rtmsg_input(void); +static void rtadvd_set_dump_file(int); +static void set_short_delay(struct rainfo *); +static int ifl_lookup(char *, char **, int); +static int check_accept_rtadv(int); +static int getinet6sysctl(int); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { #ifdef HAVE_POLL_H struct pollfd set[2]; @@ -162,18 +197,19 @@ main(argc, argv) int i, ch; int fflag = 0, logopt; pid_t pid, otherpid; + int error; /* get command line options and arguments */ - while ((ch = getopt(argc, argv, "c:dDF:fMp:Rs")) != -1) { + while ((ch = getopt(argc, argv, "c:dDfF:M:p:Rs")) != -1) { switch (ch) { case 'c': conffile = optarg; break; case 'd': - dflag = 1; + dflag++; break; case 'D': - dflag = 2; + dflag += 2; break; case 'f': fflag = 1; @@ -202,8 +238,9 @@ main(argc, argv) argv += optind; if (argc == 0) { fprintf(stderr, - "usage: rtadvd [-dDfMRs] [-c conffile] " - "[-F dumpfile] [-p pidfile] interfaces...\n"); + "usage: rtadvd [-dDfRs] [-c conffile] " + "[-F dumpfile] [-M ifname] " + "[-p pidfile] interfaces...\n"); exit(1); } @@ -213,10 +250,12 @@ main(argc, argv) openlog("rtadvd", logopt, LOG_DAEMON); /* set log level */ - if (dflag == 0) - (void)setlogmask(LOG_UPTO(LOG_ERR)); - if (dflag == 1) + if (dflag > 1) + (void)setlogmask(LOG_UPTO(LOG_DEBUG)); + else if (dflag > 0) (void)setlogmask(LOG_UPTO(LOG_INFO)); + else + (void)setlogmask(LOG_UPTO(LOG_ERR)); /* timer initialization */ rtadvd_timer_init(); @@ -229,16 +268,26 @@ main(argc, argv) srandom((u_long)time(NULL)); #endif #endif - /* get iflist block from kernel */ init_iflist(); + ifl_names = argv; + ifl_len = argc; - while (argc--) - getconfig(*argv++); + for (i = 0; i < ifl_len; i++) { + int idx; - if (inet_pton(AF_INET6, ALLNODES, &sin6_allnodes.sin6_addr) != 1) { - fprintf(stderr, "fatal: inet_pton failed\n"); - exit(1); + idx = if_nametoindex(ifl_names[i]); + if (idx == 0) { + syslog(LOG_INFO, + "<%s> interface %s not found." + "Ignored at this moment.", __func__, ifl_names[i]); + continue; + } + error = getconfig(idx); + if (error) + syslog(LOG_INFO, + "<%s> invalid configuration for %s." + "Ignored at this moment.", __func__, ifl_names[i]); } pfh = pidfile_open(pidfilename, 0600, &otherpid); @@ -292,7 +341,6 @@ main(argc, argv) if (rtsock >= 0) FD_SET(rtsock, fdsetp); #endif - signal(SIGTERM, set_die); signal(SIGUSR1, rtadvd_set_dump_file); @@ -300,7 +348,6 @@ main(argc, argv) #ifndef HAVE_POLL_H memcpy(selectfdp, fdsetp, fdmasks); /* reinitialize */ #endif - if (do_dump) { /* SIGUSR1 */ do_dump = 0; rtadvd_dump_file(dumpfilename); @@ -325,7 +372,6 @@ main(argc, argv) "<%s> there's no timer. waiting for inputs", __func__); } - #ifdef HAVE_POLL_H if ((i = poll(set, 2, timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFTIM)) < 0) @@ -358,75 +404,88 @@ main(argc, argv) exit(0); /* NOTREACHED */ } -static void -rtadvd_set_dump_file(sig) - int sig; +static int +ifl_lookup(char *ifn, char **names, int len) { + while (len--) + if (strncmp(names[len], ifn, IFNAMSIZ) == 0) + return (0); + return (-1); +} + +static void +rtadvd_set_dump_file(int sig __unused) +{ + do_dump = 1; } static void -set_die(sig) - int sig; +set_die(int sig __unused) { + do_die = 1; } static void -die() +die(void) { - struct rainfo *ra; + struct rainfo *rai; + struct rdnss *rdn; + struct dnssl *dns; int i; const int retrans = MAX_FINAL_RTR_ADVERTISEMENTS; - if (dflag > 1) { - syslog(LOG_DEBUG, "<%s> cease to be an advertising router\n", - __func__); - } + syslog(LOG_DEBUG, "<%s> cease to be an advertising router\n", + __func__); - for (ra = ralist; ra; ra = ra->next) { - ra->lifetime = 0; - make_packet(ra); + TAILQ_FOREACH(rai, &railist, rai_next) { + rai->rai_lifetime = 0; + TAILQ_FOREACH(rdn, &rai->rai_rdnss, rd_next) + rdn->rd_ltime = 0; + TAILQ_FOREACH(dns, &rai->rai_dnssl, dn_next) + dns->dn_ltime = 0; + make_packet(rai); } for (i = 0; i < retrans; i++) { - for (ra = ralist; ra; ra = ra->next) - ra_output(ra); + TAILQ_FOREACH(rai, &railist, rai_next) + ra_output(rai); sleep(MIN_DELAY_BETWEEN_RAS); } pidfile_remove(pfh); + exit(0); - /*NOTREACHED*/ } static void -rtmsg_input() +rtmsg_input(void) { int n, type, ifindex = 0, plen; size_t len; char msg[2048], *next, *lim; - u_char ifname[IF_NAMESIZE]; - struct prefix *prefix; + u_char ifname[IFNAMSIZ]; + struct if_announcemsghdr *ifan; + struct prefix *pfx; struct rainfo *rai; struct in6_addr *addr; char addrbuf[INET6_ADDRSTRLEN]; int prefixchange = 0; + int error; n = read(rtsock, msg, sizeof(msg)); - if (dflag > 1) { - syslog(LOG_DEBUG, "<%s> received a routing message " - "(type = %d, len = %d)", __func__, rtmsg_type(msg), n); - } + syslog(LOG_DEBUG, "<%s> received a routing message " + "(type = %d, len = %d)", __func__, rtmsg_type(msg), n); + if (n > rtmsg_len(msg)) { /* - * This usually won't happen for messages received on + * This usually won't happen for messages received on * a routing socket. */ - if (dflag > 1) - syslog(LOG_DEBUG, - "<%s> received data length is larger than " - "1st routing message len. multiple messages? " - "read %d bytes, but 1st msg len = %d", - __func__, n, rtmsg_len(msg)); + syslog(LOG_DEBUG, + "<%s> received data length is larger than " + "1st routing message len. multiple messages? " + "read %d bytes, but 1st msg len = %d", + __func__, n, rtmsg_len(msg)); #if 0 /* adjust length */ n = rtmsg_len(msg); @@ -438,11 +497,12 @@ rtmsg_input() int oldifflags; next = get_next_msg(next, lim, 0, &len, - RTADV_TYPE2BITMASK(RTM_ADD) | - RTADV_TYPE2BITMASK(RTM_DELETE) | - RTADV_TYPE2BITMASK(RTM_NEWADDR) | - RTADV_TYPE2BITMASK(RTM_DELADDR) | - RTADV_TYPE2BITMASK(RTM_IFINFO)); + RTADV_TYPE2BITMASK(RTM_ADD) | + RTADV_TYPE2BITMASK(RTM_DELETE) | + RTADV_TYPE2BITMASK(RTM_NEWADDR) | + RTADV_TYPE2BITMASK(RTM_DELADDR) | + RTADV_TYPE2BITMASK(RTM_IFINFO) | + RTADV_TYPE2BITMASK(RTM_IFANNOUNCE)); if (len == 0) break; type = rtmsg_type(next); @@ -458,25 +518,65 @@ rtmsg_input() case RTM_IFINFO: ifindex = get_ifm_ifindex(next); break; + case RTM_IFANNOUNCE: + ifan = (struct if_announcemsghdr *)next; + switch (ifan->ifan_what) { + case IFAN_ARRIVAL: + case IFAN_DEPARTURE: + break; + default: + syslog(LOG_DEBUG, + "<%s:%d> unknown ifan msg (ifan_what=%d)", + __func__, __LINE__, ifan->ifan_what); + continue; + } + + syslog(LOG_INFO, "<%s>: if_announcemsg (idx=%d:%d)", + __func__, ifan->ifan_index, ifan->ifan_what); + init_iflist(); + error = ifl_lookup(ifan->ifan_name, + ifl_names, ifl_len); + if (error) { + syslog(LOG_INFO, "<%s>: not a target " + "interface (idx=%d)", __func__, + ifan->ifan_index); + continue; + } + + switch (ifan->ifan_what) { + case IFAN_ARRIVAL: + error = getconfig(ifan->ifan_index); + if (error) + syslog(LOG_ERR, + "<%s>: getconfig failed (idx=%d)" + " Ignored.", __func__, + ifan->ifan_index); + break; + case IFAN_DEPARTURE: + error = rmconfig(ifan->ifan_index); + if (error) + syslog(LOG_ERR, + "<%s>: rmconfig failed (idx=%d)" + " Ignored.", __func__, + ifan->ifan_index); + break; + } + continue; default: /* should not reach here */ - if (dflag > 1) { - syslog(LOG_DEBUG, - "<%s:%d> unknown rtmsg %d on %s", - __func__, __LINE__, type, - if_indextoname(ifindex, ifname)); - } + syslog(LOG_DEBUG, + "<%s:%d> unknown rtmsg %d on %s", + __func__, __LINE__, type, + if_indextoname(ifindex, ifname)); continue; } if ((rai = if_indextorainfo(ifindex)) == NULL) { - if (dflag > 1) { - syslog(LOG_DEBUG, - "<%s> route changed on " - "non advertising interface(%s)", - __func__, - if_indextoname(ifindex, ifname)); - } + syslog(LOG_DEBUG, + "<%s> route changed on " + "non advertising interface(%s)", + __func__, + if_indextoname(ifindex, ifname)); continue; } oldifflags = iflist[ifindex]->ifm_flags; @@ -500,25 +600,25 @@ rtmsg_input() __func__, plen); break; } - prefix = find_prefix(rai, addr, plen); - if (prefix) { - if (prefix->timer) { + pfx = find_prefix(rai, addr, plen); + if (pfx) { + if (pfx->pfx_timer) { /* * If the prefix has been invalidated, * make it available again. */ - update_prefix(prefix); + update_prefix(pfx); prefixchange = 1; - } else if (dflag > 1) { + } else syslog(LOG_DEBUG, "<%s> new prefix(%s/%d) " "added on %s, " "but it was already in list", __func__, inet_ntop(AF_INET6, addr, - (char *)addrbuf, INET6_ADDRSTRLEN), - plen, rai->ifname); - } + (char *)addrbuf, + sizeof(addrbuf)), + plen, rai->rai_ifname); break; } make_prefix(rai, ifindex, addr, plen); @@ -543,21 +643,17 @@ rtmsg_input() __func__, plen); break; } - prefix = find_prefix(rai, addr, plen); - if (prefix == NULL) { - if (dflag > 1) { - syslog(LOG_DEBUG, - "<%s> prefix(%s/%d) was " - "deleted on %s, " - "but it was not in list", - __func__, - inet_ntop(AF_INET6, addr, - (char *)addrbuf, INET6_ADDRSTRLEN), - plen, rai->ifname); - } + pfx = find_prefix(rai, addr, plen); + if (pfx == NULL) { + syslog(LOG_DEBUG, + "<%s> prefix(%s/%d) was deleted on %s, " + "but it was not in list", + __func__, inet_ntop(AF_INET6, addr, + (char *)addrbuf, sizeof(addrbuf)), + plen, rai->rai_ifname); break; } - invalidate_prefix(prefix); + invalidate_prefix(pfx); prefixchange = 1; break; case RTM_NEWADDR: @@ -571,12 +667,10 @@ rtmsg_input() break; default: /* should not reach here */ - if (dflag > 1) { - syslog(LOG_DEBUG, - "<%s:%d> unknown rtmsg %d on %s", - __func__, __LINE__, type, - if_indextoname(ifindex, ifname)); - } + syslog(LOG_DEBUG, + "<%s:%d> unknown rtmsg %d on %s", + __func__, __LINE__, type, + if_indextoname(ifindex, ifname)); return; } @@ -585,27 +679,29 @@ rtmsg_input() !(iflist[ifindex]->ifm_flags & IFF_UP)) { syslog(LOG_INFO, "<%s> interface %s becomes down. stop timer.", - __func__, rai->ifname); - rtadvd_remove_timer(&rai->timer); + __func__, rai->rai_ifname); + rtadvd_remove_timer(rai->rai_timer); + rai->rai_timer = NULL; } else if (!(oldifflags & IFF_UP) && /* DOWN to UP */ - (iflist[ifindex]->ifm_flags & IFF_UP)) { + (iflist[ifindex]->ifm_flags & IFF_UP)) { syslog(LOG_INFO, "<%s> interface %s becomes up. restart timer.", - __func__, rai->ifname); + __func__, rai->rai_ifname); - rai->initcounter = 0; /* reset the counter */ - rai->waiting = 0; /* XXX */ - rai->timer = rtadvd_add_timer(ra_timeout, + rai->rai_initcounter = 0; /* reset the counter */ + rai->rai_waiting = 0; /* XXX */ + rai->rai_timer = rtadvd_add_timer(ra_timeout, ra_timer_update, rai, rai); - ra_timer_update((void *)rai, &rai->timer->tm); - rtadvd_set_timer(&rai->timer->tm, rai->timer); + ra_timer_update(rai, &rai->rai_timer->rat_tm); + rtadvd_set_timer(&rai->rai_timer->rat_tm, + rai->rai_timer); } else if (prefixchange && (iflist[ifindex]->ifm_flags & IFF_UP)) { /* * An advertised prefix has been added or invalidated. * Will notice the change in a short delay. */ - rai->initcounter = 0; + rai->rai_initcounter = 0; set_short_delay(rai); } } @@ -614,13 +710,13 @@ rtmsg_input() } void -rtadvd_input() +rtadvd_input(void) { - int i; + ssize_t i; int *hlimp = NULL; #ifdef OLDRAWSOCKET struct ip6_hdr *ip; -#endif +#endif struct icmp6_hdr *icp; int ifindex = 0; struct cmsghdr *cm; @@ -655,14 +751,14 @@ rtadvd_input() } if (ifindex == 0) { syslog(LOG_ERR, - "<%s> failed to get receiving interface", - __func__); + "<%s> failed to get receiving interface", + __func__); return; } if (hlimp == NULL) { syslog(LOG_ERR, - "<%s> failed to get receiving hop limit", - __func__); + "<%s> failed to get receiving hop limit", + __func__); return; } @@ -673,28 +769,28 @@ rtadvd_input() if (iflist[pi->ipi6_ifindex] == NULL || (iflist[pi->ipi6_ifindex]->ifm_flags & IFF_UP) == 0) { syslog(LOG_INFO, - "<%s> received data on a disabled interface (%s)", - __func__, - (iflist[pi->ipi6_ifindex] == NULL) ? "[gone]" : - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> received data on a disabled interface (%s)", + __func__, + (iflist[pi->ipi6_ifindex] == NULL) ? "[gone]" : + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } #ifdef OLDRAWSOCKET - if (i < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) { + if ((size_t)i < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) { syslog(LOG_ERR, - "<%s> packet size(%d) is too short", - __func__, i); + "<%s> packet size(%d) is too short", + __func__, i); return; } ip = (struct ip6_hdr *)rcvmhdr.msg_iov[0].iov_base; icp = (struct icmp6_hdr *)(ip + 1); /* XXX: ext. hdr? */ #else - if (i < sizeof(struct icmp6_hdr)) { + if ((size_t)i < sizeof(struct icmp6_hdr)) { syslog(LOG_ERR, - "<%s> packet size(%d) is too short", - __func__, i); + "<%s> packet size(%d) is too short", + __func__, i); return; } @@ -704,7 +800,7 @@ rtadvd_input() switch (icp->icmp6_type) { case ND_ROUTER_SOLICIT: /* - * Message verification - RFC-2461 6.1.1 + * Message verification - RFC 4861 6.1.1 * XXX: these checks must be done in the kernel as well, * but we can't completely rely on them. */ @@ -714,7 +810,7 @@ rtadvd_input() "received from %s on %s", __func__, *hlimp, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } @@ -724,17 +820,17 @@ rtadvd_input() "received from %s on %s", __func__, icp->icmp6_code, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } - if (i < sizeof(struct nd_router_solicit)) { + if ((size_t)i < sizeof(struct nd_router_solicit)) { syslog(LOG_NOTICE, "<%s> RS from %s on %s does not have enough " "length (len = %d)", __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf), i); return; } @@ -742,16 +838,25 @@ rtadvd_input() break; case ND_ROUTER_ADVERT: /* - * Message verification - RFC-2461 6.1.2 - * XXX: there's a same dilemma as above... + * Message verification - RFC 4861 6.1.2 + * XXX: there's the same dilemma as above... */ + if (!IN6_IS_ADDR_LINKLOCAL(&rcvfrom.sin6_addr)) { + syslog(LOG_NOTICE, + "<%s> RA witn non-linklocal source address " + "received from %s on %s", + __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, + ntopbuf, sizeof(ntopbuf)), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + return; + } if (*hlimp != 255) { syslog(LOG_NOTICE, "<%s> RA with invalid hop limit(%d) " "received from %s on %s", __func__, *hlimp, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } @@ -761,17 +866,17 @@ rtadvd_input() "received from %s on %s", __func__, icp->icmp6_code, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } - if (i < sizeof(struct nd_router_advert)) { + if ((size_t)i < sizeof(struct nd_router_advert)) { syslog(LOG_NOTICE, "<%s> RA from %s on %s does not have enough " "length (len = %d)", __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, - INET6_ADDRSTRLEN), + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf), i); return; } @@ -785,7 +890,7 @@ rtadvd_input() break; } rr_input(i, (struct icmp6_router_renum *)icp, pi, &rcvfrom, - &dst); + &dst); break; default: /* @@ -806,17 +911,17 @@ static void rs_input(int len, struct nd_router_solicit *rs, struct in6_pktinfo *pi, struct sockaddr_in6 *from) { - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - union nd_opts ndopts; - struct rainfo *ra; + u_char ntopbuf[INET6_ADDRSTRLEN]; + u_char ifnamebuf[IFNAMSIZ]; + union nd_opt ndopts; + struct rainfo *rai; struct soliciter *sol; syslog(LOG_DEBUG, - "<%s> RS received from %s on %s", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> RS received from %s on %s", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); /* ND option check */ memset(&ndopts, 0, sizeof(ndopts)); @@ -824,36 +929,33 @@ rs_input(int len, struct nd_router_solicit *rs, len - sizeof(struct nd_router_solicit), &ndopts, NDOPT_FLAG_SRCLINKADDR)) { syslog(LOG_INFO, - "<%s> ND option check failed for an RS from %s on %s", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> ND option check failed for an RS from %s on %s", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } /* * If the IP source address is the unspecified address, there * must be no source link-layer address option in the message. - * (RFC-2461 6.1.1) + * (RFC 4861 6.1.1) */ if (IN6_IS_ADDR_UNSPECIFIED(&from->sin6_addr) && - ndopts.nd_opts_src_lladdr) { + ndopts.opt_src_lladdr) { syslog(LOG_INFO, - "<%s> RS from unspecified src on %s has a link-layer" - " address option", - __func__, - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> RS from unspecified src on %s has a link-layer" + " address option", + __func__, if_indextoname(pi->ipi6_ifindex, ifnamebuf)); goto done; } - ra = ralist; - while (ra != NULL) { - if (pi->ipi6_ifindex == ra->ifindex) + TAILQ_FOREACH(rai, &railist, rai_next) + if (pi->ipi6_ifindex == (unsigned int)rai->rai_ifindex) break; - ra = ra->next; - } - if (ra == NULL) { + + if (rai == NULL) { syslog(LOG_INFO, "<%s> RS received on non advertising interface(%s)", __func__, @@ -861,7 +963,7 @@ rs_input(int len, struct nd_router_solicit *rs, goto done; } - ra->rsinput++; /* increment statistics */ + rai->rai_rsinput++; /* increment statistics */ /* * Decide whether to send RA according to the rate-limit @@ -871,21 +973,20 @@ rs_input(int len, struct nd_router_solicit *rs, /* record sockaddr waiting for RA, if possible */ sol = (struct soliciter *)malloc(sizeof(*sol)); if (sol) { - sol->addr = *from; - /* XXX RFC2553 need clarification on flowinfo */ - sol->addr.sin6_flowinfo = 0; - sol->next = ra->soliciter; - ra->soliciter = sol; + sol->sol_addr = *from; + /* XXX RFC 2553 need clarification on flowinfo */ + sol->sol_addr.sin6_flowinfo = 0; + TAILQ_INSERT_TAIL(&rai->rai_soliciter, sol, sol_next); } /* * If there is already a waiting RS packet, don't * update the timer. */ - if (ra->waiting++) + if (rai->rai_waiting++) goto done; - set_short_delay(ra); + set_short_delay(rai); done: free_ndopts(&ndopts); @@ -893,8 +994,7 @@ rs_input(int len, struct nd_router_solicit *rs, } static void -set_short_delay(rai) - struct rainfo *rai; +set_short_delay(struct rainfo *rai) { long delay; /* must not be greater than 1000000 */ struct timeval interval, now, min_delay, tm_tmp, *rest; @@ -904,7 +1004,7 @@ set_short_delay(rai) * corresponds to a time later than the time the next * multicast RA is scheduled to be sent, ignore the random * delay and send the advertisement at the - * already-scheduled time. RFC-2461 6.2.6 + * already-scheduled time. RFC 4861 6.2.6 */ #ifdef HAVE_ARC4RANDOM delay = arc4random_uniform(MAX_RA_DELAY_TIME); @@ -913,8 +1013,8 @@ set_short_delay(rai) #endif interval.tv_sec = 0; interval.tv_usec = delay; - rest = rtadvd_timer_rest(rai->timer); - if (TIMEVAL_LT(*rest, interval)) { + rest = rtadvd_timer_rest(rai->rai_timer); + if (TIMEVAL_LT(rest, &interval)) { syslog(LOG_DEBUG, "<%s> random delay is larger than " "the rest of the current timer", __func__); interval = *rest; @@ -928,170 +1028,217 @@ set_short_delay(rai) * previous advertisement was sent. */ gettimeofday(&now, NULL); - TIMEVAL_SUB(&now, &rai->lastsent, &tm_tmp); + TIMEVAL_SUB(&now, &rai->rai_lastsent, &tm_tmp); min_delay.tv_sec = MIN_DELAY_BETWEEN_RAS; min_delay.tv_usec = 0; - if (TIMEVAL_LT(tm_tmp, min_delay)) { + if (TIMEVAL_LT(&tm_tmp, &min_delay)) { TIMEVAL_SUB(&min_delay, &tm_tmp, &min_delay); TIMEVAL_ADD(&min_delay, &interval, &interval); } - rtadvd_set_timer(&interval, rai->timer); + rtadvd_set_timer(&interval, rai->rai_timer); +} + +static int +check_accept_rtadv(int idx) +{ + struct in6_ndireq nd; + u_char ifname[IFNAMSIZ]; + int s6; + int error; + + if ((s6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + syslog(LOG_ERR, + "<%s> open socket failed for idx=%d.", + __func__, idx); + return (0); + } + if ((if_indextoname(idx, ifname)) == NULL) { + syslog(LOG_ERR, + "<%s> ifindex->ifname failed (idx=%d).", + __func__, idx); + close(s6); + return (0); + } + memset(&nd, 0, sizeof(nd)); + strncpy(nd.ifname, ifname, sizeof(nd.ifname)); + error = ioctl(s6, SIOCGIFINFO_IN6, &nd); + if (error) { + syslog(LOG_ERR, + "<%s> ioctl(SIOCGIFINFO_IN6) failed for idx=%d.", + __func__, idx); + nd.ndi.flags = 0; + } + close(s6); + + return (nd.ndi.flags & ND6_IFF_ACCEPT_RTADV); +} + +static int +getinet6sysctl(int code) +{ + int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, 0 }; + int value; + size_t size; + + mib[3] = code; + size = sizeof(value); + if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0) + < 0) { + syslog(LOG_ERR, "<%s>: failed to get ip6 sysctl(%d): %s", + __func__, code, + strerror(errno)); + return (-1); + } + else + return (value); } static void -ra_input(int len, struct nd_router_advert *ra, +ra_input(int len, struct nd_router_advert *nra, struct in6_pktinfo *pi, struct sockaddr_in6 *from) { struct rainfo *rai; - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - union nd_opts ndopts; - char *on_off[] = {"OFF", "ON"}; + u_char ntopbuf[INET6_ADDRSTRLEN]; + u_char ifnamebuf[IFNAMSIZ]; + union nd_opt ndopts; + const char *on_off[] = {"OFF", "ON"}; u_int32_t reachabletime, retranstimer, mtu; int inconsistent = 0; + int error; + + syslog(LOG_DEBUG, "<%s> RA received from %s on %s", __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), + if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + + if (!check_accept_rtadv(pi->ipi6_ifindex)) { + syslog(LOG_INFO, + "<%s> An RA from %s on %s ignored (no ACCEPT_RTADV flag).", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, + ifnamebuf)); + return; + } - syslog(LOG_DEBUG, - "<%s> RA received from %s on %s", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); - /* ND option check */ memset(&ndopts, 0, sizeof(ndopts)); - if (nd6_options((struct nd_opt_hdr *)(ra + 1), - len - sizeof(struct nd_router_advert), - &ndopts, NDOPT_FLAG_SRCLINKADDR | - NDOPT_FLAG_PREFIXINFO | NDOPT_FLAG_MTU)) { + error = nd6_options((struct nd_opt_hdr *)(nra + 1), + len - sizeof(struct nd_router_advert), &ndopts, + NDOPT_FLAG_SRCLINKADDR | NDOPT_FLAG_PREFIXINFO | NDOPT_FLAG_MTU | + NDOPT_FLAG_RDNSS | NDOPT_FLAG_DNSSL); + if (error) { syslog(LOG_INFO, - "<%s> ND option check failed for an RA from %s on %s", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> ND option check failed for an RA from %s on %s", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, + ifnamebuf)); return; } /* - * RA consistency check according to RFC-2461 6.2.7 + * RA consistency check according to RFC 4861 6.2.7 */ - if ((rai = if_indextorainfo(pi->ipi6_ifindex)) == 0) { + rai = if_indextorainfo(pi->ipi6_ifindex); + if (rai == NULL) { syslog(LOG_INFO, - "<%s> received RA from %s on non-advertising" - " interface(%s)", - __func__, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(pi->ipi6_ifindex, ifnamebuf)); + "<%s> received RA from %s on non-advertising" + " interface(%s)", + __func__, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, + ifnamebuf)); goto done; } - rai->rainput++; /* increment statistics */ - + rai->rai_rainput++; /* increment statistics */ + /* Cur Hop Limit value */ - if (ra->nd_ra_curhoplimit && rai->hoplimit && - ra->nd_ra_curhoplimit != rai->hoplimit) { + if (nra->nd_ra_curhoplimit && rai->rai_hoplimit && + nra->nd_ra_curhoplimit != rai->rai_hoplimit) { syslog(LOG_INFO, - "<%s> CurHopLimit inconsistent on %s:" - " %d from %s, %d from us", - __func__, - rai->ifname, - ra->nd_ra_curhoplimit, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->hoplimit); + "<%s> CurHopLimit inconsistent on %s:" + " %d from %s, %d from us", + __func__, rai->rai_ifname, nra->nd_ra_curhoplimit, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_hoplimit); inconsistent++; } /* M flag */ - if ((ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) != - rai->managedflg) { + if ((nra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) != + rai->rai_managedflg) { syslog(LOG_INFO, - "<%s> M flag inconsistent on %s:" - " %s from %s, %s from us", - __func__, - rai->ifname, - on_off[!rai->managedflg], - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - on_off[rai->managedflg]); + "<%s> M flag inconsistent on %s:" + " %s from %s, %s from us", + __func__, rai->rai_ifname, on_off[!rai->rai_managedflg], + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), on_off[rai->rai_managedflg]); inconsistent++; } /* O flag */ - if ((ra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER) != - rai->otherflg) { + if ((nra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER) != + rai->rai_otherflg) { syslog(LOG_INFO, - "<%s> O flag inconsistent on %s:" - " %s from %s, %s from us", - __func__, - rai->ifname, - on_off[!rai->otherflg], - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - on_off[rai->otherflg]); + "<%s> O flag inconsistent on %s:" + " %s from %s, %s from us", + __func__, rai->rai_ifname, on_off[!rai->rai_otherflg], + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), on_off[rai->rai_otherflg]); inconsistent++; } /* Reachable Time */ - reachabletime = ntohl(ra->nd_ra_reachable); - if (reachabletime && rai->reachabletime && - reachabletime != rai->reachabletime) { + reachabletime = ntohl(nra->nd_ra_reachable); + if (reachabletime && rai->rai_reachabletime && + reachabletime != rai->rai_reachabletime) { syslog(LOG_INFO, - "<%s> ReachableTime inconsistent on %s:" - " %d from %s, %d from us", - __func__, - rai->ifname, - reachabletime, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->reachabletime); + "<%s> ReachableTime inconsistent on %s:" + " %d from %s, %d from us", + __func__, rai->rai_ifname, reachabletime, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_reachabletime); inconsistent++; } /* Retrans Timer */ - retranstimer = ntohl(ra->nd_ra_retransmit); - if (retranstimer && rai->retranstimer && - retranstimer != rai->retranstimer) { + retranstimer = ntohl(nra->nd_ra_retransmit); + if (retranstimer && rai->rai_retranstimer && + retranstimer != rai->rai_retranstimer) { syslog(LOG_INFO, - "<%s> RetranceTimer inconsistent on %s:" - " %d from %s, %d from us", - __func__, - rai->ifname, - retranstimer, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->retranstimer); + "<%s> RetranceTimer inconsistent on %s:" + " %d from %s, %d from us", + __func__, rai->rai_ifname, retranstimer, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_retranstimer); inconsistent++; } /* Values in the MTU options */ - if (ndopts.nd_opts_mtu) { - mtu = ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu); - if (mtu && rai->linkmtu && mtu != rai->linkmtu) { + if (ndopts.opt_mtu) { + mtu = ntohl(ndopts.opt_mtu->nd_opt_mtu_mtu); + if (mtu && rai->rai_linkmtu && mtu != rai->rai_linkmtu) { syslog(LOG_INFO, - "<%s> MTU option value inconsistent on %s:" - " %d from %s, %d from us", - __func__, - rai->ifname, mtu, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->linkmtu); + "<%s> MTU option value inconsistent on %s:" + " %d from %s, %d from us", + __func__, rai->rai_ifname, mtu, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_linkmtu); inconsistent++; } } /* Preferred and Valid Lifetimes for prefixes */ { - struct nd_optlist *optp = ndopts.nd_opts_list; + struct nd_optlist *nol; - if (ndopts.nd_opts_pi) { - if (prefix_check(ndopts.nd_opts_pi, rai, from)) + if (ndopts.opt_pi) + if (prefix_check(ndopts.opt_pi, rai, from)) inconsistent++; - } - while (optp) { - if (prefix_check((struct nd_opt_prefix_info *)optp->opt, - rai, from)) + + TAILQ_FOREACH(nol, &ndopts.opt_list, nol_next) + if (prefix_check((struct nd_opt_prefix_info *)nol->nol_opt, + rai, from)) inconsistent++; - optp = optp->next; - } } if (inconsistent) - rai->rainconsistent++; - + rai->rai_rainconsistent++; + done: free_ndopts(&ndopts); return; @@ -1100,51 +1247,49 @@ ra_input(int len, struct nd_router_advert *ra, /* return a non-zero value if the received prefix is inconsitent with ours */ static int prefix_check(struct nd_opt_prefix_info *pinfo, - struct rainfo *rai, struct sockaddr_in6 *from) + struct rainfo *rai, struct sockaddr_in6 *from) { u_int32_t preferred_time, valid_time; - struct prefix *pp; + struct prefix *pfx; int inconsistent = 0; - u_char ntopbuf[INET6_ADDRSTRLEN], prefixbuf[INET6_ADDRSTRLEN]; + u_char ntopbuf[INET6_ADDRSTRLEN]; + u_char prefixbuf[INET6_ADDRSTRLEN]; struct timeval now; #if 0 /* impossible */ if (pinfo->nd_opt_pi_type != ND_OPT_PREFIX_INFORMATION) - return(0); + return (0); #endif /* * log if the adveritsed prefix has link-local scope(sanity check?) */ - if (IN6_IS_ADDR_LINKLOCAL(&pinfo->nd_opt_pi_prefix)) { + if (IN6_IS_ADDR_LINKLOCAL(&pinfo->nd_opt_pi_prefix)) syslog(LOG_INFO, - "<%s> link-local prefix %s/%d is advertised " - "from %s on %s", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->ifname); - } + "<%s> link-local prefix %s/%d is advertised " + "from %s on %s", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_ifname); - if ((pp = find_prefix(rai, &pinfo->nd_opt_pi_prefix, - pinfo->nd_opt_pi_prefix_len)) == NULL) { + if ((pfx = find_prefix(rai, &pinfo->nd_opt_pi_prefix, + pinfo->nd_opt_pi_prefix_len)) == NULL) { syslog(LOG_INFO, - "<%s> prefix %s/%d from %s on %s is not in our list", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - rai->ifname); - return(0); + "<%s> prefix %s/%d from %s on %s is not in our list", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), rai->rai_ifname); + return (0); } preferred_time = ntohl(pinfo->nd_opt_pi_preferred_time); - if (pp->pltimeexpire) { + if (pfx->pfx_pltimeexpire) { /* * The lifetime is decremented in real time, so we should * compare the expiration time. @@ -1155,134 +1300,135 @@ prefix_check(struct nd_opt_prefix_info *pinfo, gettimeofday(&now, NULL); preferred_time += now.tv_sec; - if (!pp->timer && rai->clockskew && - abs(preferred_time - pp->pltimeexpire) > rai->clockskew) { + if (!pfx->pfx_timer && rai->rai_clockskew && + abs(preferred_time - pfx->pfx_pltimeexpire) > rai->rai_clockskew) { syslog(LOG_INFO, - "<%s> preferred lifetime for %s/%d" - " (decr. in real time) inconsistent on %s:" - " %d from %s, %ld from us", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - rai->ifname, preferred_time, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - pp->pltimeexpire); + "<%s> preferred lifetime for %s/%d" + " (decr. in real time) inconsistent on %s:" + " %d from %s, %ld from us", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + rai->rai_ifname, preferred_time, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_pltimeexpire); inconsistent++; } - } else if (!pp->timer && preferred_time != pp->preflifetime) { + } else if (!pfx->pfx_timer && preferred_time != pfx->pfx_preflifetime) syslog(LOG_INFO, - "<%s> preferred lifetime for %s/%d" - " inconsistent on %s:" - " %d from %s, %d from us", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - rai->ifname, preferred_time, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - pp->preflifetime); - } + "<%s> preferred lifetime for %s/%d" + " inconsistent on %s:" + " %d from %s, %d from us", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + rai->rai_ifname, preferred_time, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_preflifetime); valid_time = ntohl(pinfo->nd_opt_pi_valid_time); - if (pp->vltimeexpire) { + if (pfx->pfx_vltimeexpire) { gettimeofday(&now, NULL); valid_time += now.tv_sec; - if (!pp->timer && rai->clockskew && - abs(valid_time - pp->vltimeexpire) > rai->clockskew) { + if (!pfx->pfx_timer && rai->rai_clockskew && + abs(valid_time - pfx->pfx_vltimeexpire) > rai->rai_clockskew) { syslog(LOG_INFO, - "<%s> valid lifetime for %s/%d" - " (decr. in real time) inconsistent on %s:" - " %d from %s, %ld from us", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - rai->ifname, preferred_time, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - pp->vltimeexpire); + "<%s> valid lifetime for %s/%d" + " (decr. in real time) inconsistent on %s:" + " %d from %s, %ld from us", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + rai->rai_ifname, preferred_time, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_vltimeexpire); inconsistent++; } - } else if (!pp->timer && valid_time != pp->validlifetime) { + } else if (!pfx->pfx_timer && valid_time != pfx->pfx_validlifetime) { syslog(LOG_INFO, - "<%s> valid lifetime for %s/%d" - " inconsistent on %s:" - " %d from %s, %d from us", - __func__, - inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, - prefixbuf, INET6_ADDRSTRLEN), - pinfo->nd_opt_pi_prefix_len, - rai->ifname, valid_time, - inet_ntop(AF_INET6, &from->sin6_addr, - ntopbuf, INET6_ADDRSTRLEN), - pp->validlifetime); + "<%s> valid lifetime for %s/%d" + " inconsistent on %s:" + " %d from %s, %d from us", + __func__, + inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix, prefixbuf, + sizeof(prefixbuf)), + pinfo->nd_opt_pi_prefix_len, + rai->rai_ifname, valid_time, + inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, + sizeof(ntopbuf)), pfx->pfx_validlifetime); inconsistent++; } - return(inconsistent); + return (inconsistent); } struct prefix * find_prefix(struct rainfo *rai, struct in6_addr *prefix, int plen) { - struct prefix *pp; + struct prefix *pfx; int bytelen, bitlen; u_char bitmask; - for (pp = rai->prefix.next; pp != &rai->prefix; pp = pp->next) { - if (plen != pp->prefixlen) + TAILQ_FOREACH(pfx, &rai->rai_prefix, pfx_next) { + if (plen != pfx->pfx_prefixlen) continue; + bytelen = plen / 8; bitlen = plen % 8; bitmask = 0xff << (8 - bitlen); - if (memcmp((void *)prefix, (void *)&pp->prefix, bytelen)) + + if (memcmp((void *)prefix, (void *)&pfx->pfx_prefix, bytelen)) continue; + if (bitlen == 0 || - ((prefix->s6_addr[bytelen] & bitmask) == - (pp->prefix.s6_addr[bytelen] & bitmask))) { - return(pp); + ((prefix->s6_addr[bytelen] & bitmask) == + (pfx->pfx_prefix.s6_addr[bytelen] & bitmask))) { + return (pfx); } } - return(NULL); + return (NULL); } /* check if p0/plen0 matches p1/plen1; return 1 if matches, otherwise 0. */ int prefix_match(struct in6_addr *p0, int plen0, - struct in6_addr *p1, int plen1) + struct in6_addr *p1, int plen1) { int bytelen, bitlen; u_char bitmask; if (plen0 < plen1) - return(0); + return (0); + bytelen = plen1 / 8; bitlen = plen1 % 8; bitmask = 0xff << (8 - bitlen); + if (memcmp((void *)p0, (void *)p1, bytelen)) - return(0); + return (0); + if (bitlen == 0 || ((p0->s6_addr[bytelen] & bitmask) == (p1->s6_addr[bytelen] & bitmask))) { - return(1); + return (1); } - return(0); + return (0); } static int nd6_options(struct nd_opt_hdr *hdr, int limit, - union nd_opts *ndopts, u_int32_t optflags) + union nd_opt *ndopts, u_int32_t optflags) { int optlen = 0; for (; limit > 0; limit -= optlen) { - if (limit < sizeof(struct nd_opt_hdr)) { + if ((size_t)limit < sizeof(struct nd_opt_hdr)) { syslog(LOG_INFO, "<%s> short option header", __func__); goto bad; } @@ -1300,7 +1446,9 @@ nd6_options(struct nd_opt_hdr *hdr, int limit, goto bad; } - if (hdr->nd_opt_type > ND_OPT_MTU) { + if (hdr->nd_opt_type > ND_OPT_MTU && + hdr->nd_opt_type != ND_OPT_RDNSS && + hdr->nd_opt_type != ND_OPT_DNSSL) { syslog(LOG_INFO, "<%s> unknown ND option(type %d)", __func__, hdr->nd_opt_type); continue; @@ -1316,10 +1464,25 @@ nd6_options(struct nd_opt_hdr *hdr, int limit, * Option length check. Do it here for all fixed-length * options. */ - if ((hdr->nd_opt_type == ND_OPT_MTU && - (optlen != sizeof(struct nd_opt_mtu))) || - ((hdr->nd_opt_type == ND_OPT_PREFIX_INFORMATION && - optlen != sizeof(struct nd_opt_prefix_info)))) { + switch (hdr->nd_opt_type) { + case ND_OPT_MTU: + if (optlen == sizeof(struct nd_opt_mtu)) + break; + goto skip; + case ND_OPT_RDNSS: + if (optlen >= 24 && + (optlen - sizeof(struct nd_opt_rdnss)) % 16 == 0) + break; + goto skip; + case ND_OPT_DNSSL: + if (optlen >= 16 && + (optlen - sizeof(struct nd_opt_dnssl)) % 8 == 0) + break; + goto skip; + case ND_OPT_PREFIX_INFORMATION: + if (optlen == sizeof(struct nd_opt_prefix_info)) + break; +skip: syslog(LOG_INFO, "<%s> invalid option length", __func__); continue; @@ -1328,33 +1491,35 @@ nd6_options(struct nd_opt_hdr *hdr, int limit, switch (hdr->nd_opt_type) { case ND_OPT_TARGET_LINKADDR: case ND_OPT_REDIRECTED_HEADER: + case ND_OPT_RDNSS: + case ND_OPT_DNSSL: break; /* we don't care about these options */ case ND_OPT_SOURCE_LINKADDR: case ND_OPT_MTU: - if (ndopts->nd_opt_array[hdr->nd_opt_type]) { + if (ndopts->opt_array[hdr->nd_opt_type]) { syslog(LOG_INFO, "<%s> duplicated ND option (type = %d)", __func__, hdr->nd_opt_type); } - ndopts->nd_opt_array[hdr->nd_opt_type] = hdr; + ndopts->opt_array[hdr->nd_opt_type] = hdr; break; case ND_OPT_PREFIX_INFORMATION: { - struct nd_optlist *pfxlist; + struct nd_optlist *nol; - if (ndopts->nd_opts_pi == 0) { - ndopts->nd_opts_pi = + if (ndopts->opt_pi == 0) { + ndopts->opt_pi = (struct nd_opt_prefix_info *)hdr; continue; } - if ((pfxlist = malloc(sizeof(*pfxlist))) == NULL) { + nol = malloc(sizeof(*nol)); + if (nol == NULL) { syslog(LOG_ERR, "<%s> can't allocate memory", __func__); goto bad; } - pfxlist->next = ndopts->nd_opts_list; - pfxlist->opt = hdr; - ndopts->nd_opts_list = pfxlist; + nol->nol_opt = hdr; + TAILQ_INSERT_TAIL(&(ndopts->opt_list), nol, nol_next); break; } @@ -1363,46 +1528,45 @@ nd6_options(struct nd_opt_hdr *hdr, int limit, } } - return(0); + return (0); bad: free_ndopts(ndopts); - return(-1); + return (-1); } static void -free_ndopts(union nd_opts *ndopts) +free_ndopts(union nd_opt *ndopts) { - struct nd_optlist *opt = ndopts->nd_opts_list, *next; + struct nd_optlist *nol; - while (opt) { - next = opt->next; - free(opt); - opt = next; + while ((nol = TAILQ_FIRST(&ndopts->opt_list)) != NULL) { + TAILQ_REMOVE(&ndopts->opt_list, nol, nol_next); + free(nol); } } void -sock_open() +sock_open(void) { struct icmp6_filter filt; struct ipv6_mreq mreq; - struct rainfo *ra = ralist; + struct rainfo *rai; int on; /* XXX: should be max MTU attached to the node */ static u_char answer[1500]; rcvcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int)); + CMSG_SPACE(sizeof(int)); rcvcmsgbuf = (u_char *)malloc(rcvcmsgbuflen); if (rcvcmsgbuf == NULL) { syslog(LOG_ERR, "<%s> not enough core", __func__); exit(1); } - sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int)); + sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + + CMSG_SPACE(sizeof(int)); sndcmsgbuf = (u_char *)malloc(sndcmsgbuflen); if (sndcmsgbuf == NULL) { syslog(LOG_ERR, "<%s> not enough core", __func__); @@ -1410,113 +1574,84 @@ sock_open() } if ((sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) { - syslog(LOG_ERR, "<%s> socket: %s", __func__, - strerror(errno)); + syslog(LOG_ERR, "<%s> socket: %s", __func__, strerror(errno)); exit(1); } - /* specify to tell receiving interface */ on = 1; -#ifdef IPV6_RECVPKTINFO if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, - sizeof(on)) < 0) { - syslog(LOG_ERR, "<%s> IPV6_RECVPKTINFO: %s", - __func__, strerror(errno)); + sizeof(on)) < 0) { + syslog(LOG_ERR, "<%s> IPV6_RECVPKTINFO: %s", __func__, + strerror(errno)); exit(1); } -#else /* old adv. API */ - if (setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on, - sizeof(on)) < 0) { - syslog(LOG_ERR, "<%s> IPV6_PKTINFO: %s", - __func__, strerror(errno)); - exit(1); - } -#endif - on = 1; /* specify to tell value of hoplimit field of received IP6 hdr */ -#ifdef IPV6_RECVHOPLIMIT if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, - sizeof(on)) < 0) { - syslog(LOG_ERR, "<%s> IPV6_RECVHOPLIMIT: %s", - __func__, strerror(errno)); + sizeof(on)) < 0) { + syslog(LOG_ERR, "<%s> IPV6_RECVHOPLIMIT: %s", __func__, + strerror(errno)); exit(1); } -#else /* old adv. API */ - if (setsockopt(sock, IPPROTO_IPV6, IPV6_HOPLIMIT, &on, - sizeof(on)) < 0) { - syslog(LOG_ERR, "<%s> IPV6_HOPLIMIT: %s", - __func__, strerror(errno)); - exit(1); - } -#endif - ICMP6_FILTER_SETBLOCKALL(&filt); ICMP6_FILTER_SETPASS(ND_ROUTER_SOLICIT, &filt); ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filt); if (accept_rr) ICMP6_FILTER_SETPASS(ICMP6_ROUTER_RENUMBERING, &filt); + if (setsockopt(sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, - sizeof(filt)) < 0) { + sizeof(filt)) < 0) { syslog(LOG_ERR, "<%s> IICMP6_FILTER: %s", - __func__, strerror(errno)); + __func__, strerror(errno)); exit(1); } /* * join all routers multicast address on each advertising interface. */ - if (inet_pton(AF_INET6, ALLROUTERS_LINK, - &mreq.ipv6mr_multiaddr.s6_addr) - != 1) { - syslog(LOG_ERR, "<%s> inet_pton failed(library bug?)", - __func__); - exit(1); - } - while (ra) { - mreq.ipv6mr_interface = ra->ifindex; + memcpy(&mreq.ipv6mr_multiaddr.s6_addr, + &sin6_linklocal_allrouters.sin6_addr, + sizeof(mreq.ipv6mr_multiaddr.s6_addr)); + TAILQ_FOREACH(rai, &railist, rai_next) { + mreq.ipv6mr_interface = rai->rai_ifindex; if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, - sizeof(mreq)) < 0) { + sizeof(mreq)) < 0) { syslog(LOG_ERR, "<%s> IPV6_JOIN_GROUP(link) on %s: %s", - __func__, ra->ifname, strerror(errno)); + __func__, rai->rai_ifname, strerror(errno)); exit(1); } - ra = ra->next; } /* * When attending router renumbering, join all-routers site-local - * multicast group. + * multicast group. */ if (accept_rr) { - if (inet_pton(AF_INET6, ALLROUTERS_SITE, - &in6a_site_allrouters) != 1) { - syslog(LOG_ERR, "<%s> inet_pton failed(library bug?)", - __func__); - exit(1); - } - mreq.ipv6mr_multiaddr = in6a_site_allrouters; + memcpy(&mreq.ipv6mr_multiaddr.s6_addr, + &sin6_sitelocal_allrouters.sin6_addr, + sizeof(mreq.ipv6mr_multiaddr.s6_addr)); if (mcastif) { if ((mreq.ipv6mr_interface = if_nametoindex(mcastif)) == 0) { syslog(LOG_ERR, - "<%s> invalid interface: %s", - __func__, mcastif); + "<%s> invalid interface: %s", + __func__, mcastif); exit(1); } } else - mreq.ipv6mr_interface = ralist->ifindex; + mreq.ipv6mr_interface = + TAILQ_FIRST(&railist)->rai_ifindex; if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, - &mreq, sizeof(mreq)) < 0) { + &mreq, sizeof(mreq)) < 0) { syslog(LOG_ERR, - "<%s> IPV6_JOIN_GROUP(site) on %s: %s", - __func__, - mcastif ? mcastif : ralist->ifname, - strerror(errno)); + "<%s> IPV6_JOIN_GROUP(site) on %s: %s", __func__, + mcastif ? mcastif : + TAILQ_FIRST(&railist)->rai_ifname, + strerror(errno)); exit(1); } } - + /* initialize msghdr for receiving packets */ rcviov[0].iov_base = (caddr_t)answer; rcviov[0].iov_len = sizeof(answer); @@ -1533,17 +1668,17 @@ sock_open() sndmhdr.msg_iovlen = 1; sndmhdr.msg_control = (caddr_t)sndcmsgbuf; sndmhdr.msg_controllen = sndcmsgbuflen; - + return; } /* open a routing socket to watch the routing table */ static void -rtsock_open() +rtsock_open(void) { if ((rtsock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) { syslog(LOG_ERR, - "<%s> socket: %s", __func__, strerror(errno)); + "<%s> socket: %s", __func__, strerror(errno)); exit(1); } } @@ -1551,36 +1686,72 @@ rtsock_open() struct rainfo * if_indextorainfo(int idx) { - struct rainfo *rai = ralist; + struct rainfo *rai; - for (rai = ralist; rai; rai = rai->next) { - if (rai->ifindex == idx) - return(rai); + TAILQ_FOREACH(rai, &railist, rai_next) { + syslog(LOG_DEBUG, "<%s> rai->rai_ifindex %d == idx %d?", + __func__, rai->rai_ifindex, idx); + if (rai->rai_ifindex == idx) + return (rai); } - return(NULL); /* search failed */ + return (NULL); /* search failed */ } static void -ra_output(rainfo) -struct rainfo *rainfo; +ra_output(struct rainfo *rai) { int i; struct cmsghdr *cm; struct in6_pktinfo *pi; - struct soliciter *sol, *nextsol; + struct soliciter *sol; - if ((iflist[rainfo->ifindex]->ifm_flags & IFF_UP) == 0) { + if ((iflist[rai->rai_ifindex]->ifm_flags & IFF_UP) == 0) { syslog(LOG_DEBUG, "<%s> %s is not up, skip sending RA", - __func__, rainfo->ifname); + __func__, rai->rai_ifname); return; } - make_packet(rainfo); /* XXX: inefficient */ + /* + * Check lifetime, ACCEPT_RTADV flag, and ip6.forwarding. + * + * (lifetime == 0) = output + * (lifetime != 0 && (ACCEPT_RTADV || !ip6.forwarding) = no output + * + * Basically, hosts MUST NOT send Router Advertisement + * messages at any time (RFC 4861, Section 6.2.3). However, it + * would sometimes be useful to allow hosts to advertise some + * parameters such as prefix information and link MTU. Thus, + * we allow hosts to invoke rtadvd only when router lifetime + * (on every advertising interface) is explicitly set + * zero. (see also the above section) + */ + syslog(LOG_DEBUG, + "<%s> check lifetime=%d, ACCEPT_RTADV=%d, ip6.forwarding=%d on %s", + __func__, rai->rai_lifetime, check_accept_rtadv(rai->rai_ifindex), + getinet6sysctl(IPV6CTL_FORWARDING), rai->rai_ifname); + if (rai->rai_lifetime != 0) { + if (check_accept_rtadv(rai->rai_ifindex)) { + syslog(LOG_INFO, + "<%s> non-zero lifetime RA " + "on RA receiving interface %s." + " Ignored.", __func__, rai->rai_ifname); + return; + } + if (getinet6sysctl(IPV6CTL_FORWARDING) == 0) { + syslog(LOG_INFO, + "<%s> non-zero lifetime RA " + "but net.inet6.ip6.forwarding=0. " + "Ignored.", __func__); + return; + } + } - sndmhdr.msg_name = (caddr_t)&sin6_allnodes; - sndmhdr.msg_iov[0].iov_base = (caddr_t)rainfo->ra_data; - sndmhdr.msg_iov[0].iov_len = rainfo->ra_datalen; + make_packet(rai); /* XXX: inefficient */ + + sndmhdr.msg_name = (caddr_t)&sin6_linklocal_allnodes; + sndmhdr.msg_iov[0].iov_base = (caddr_t)rai->rai_ra_data; + sndmhdr.msg_iov[0].iov_len = rai->rai_ra_datalen; cm = CMSG_FIRSTHDR(&sndmhdr); /* specify the outgoing interface */ @@ -1589,7 +1760,7 @@ struct rainfo *rainfo; cm->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); pi = (struct in6_pktinfo *)CMSG_DATA(cm); memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/ - pi->ipi6_ifindex = rainfo->ifindex; + pi->ipi6_ifindex = rai->rai_ifindex; /* specify the hop limit of the packet */ { @@ -1603,80 +1774,79 @@ struct rainfo *rainfo; } syslog(LOG_DEBUG, - "<%s> send RA on %s, # of waitings = %d", - __func__, rainfo->ifname, rainfo->waiting); + "<%s> send RA on %s, # of waitings = %d", + __func__, rai->rai_ifname, rai->rai_waiting); i = sendmsg(sock, &sndmhdr, 0); - if (i < 0 || i != rainfo->ra_datalen) { + if (i < 0 || (size_t)i != rai->rai_ra_datalen) { if (i < 0) { syslog(LOG_ERR, "<%s> sendmsg on %s: %s", - __func__, rainfo->ifname, - strerror(errno)); + __func__, rai->rai_ifname, + strerror(errno)); } } /* update counter */ - if (rainfo->initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS) - rainfo->initcounter++; - rainfo->raoutput++; + if (rai->rai_initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS) + rai->rai_initcounter++; + rai->rai_raoutput++; /* * unicast advertisements * XXX commented out. reason: though spec does not forbit it, unicast * advert does not really help */ - for (sol = rainfo->soliciter; sol; sol = nextsol) { - nextsol = sol->next; - - sol->next = NULL; + while ((sol = TAILQ_FIRST(&rai->rai_soliciter)) != NULL) { + TAILQ_REMOVE(&rai->rai_soliciter, sol, sol_next); free(sol); } - rainfo->soliciter = NULL; /* update timestamp */ - gettimeofday(&rainfo->lastsent, NULL); + gettimeofday(&rai->rai_lastsent, NULL); /* reset waiting conter */ - rainfo->waiting = 0; + rai->rai_waiting = 0; } /* process RA timer */ struct rtadvd_timer * -ra_timeout(void *data) +ra_timeout(void *arg) { - struct rainfo *rai = (struct rainfo *)data; + struct rainfo *rai; #ifdef notyet /* if necessary, reconstruct the packet. */ #endif - - syslog(LOG_DEBUG, - "<%s> RA timer on %s is expired", - __func__, rai->ifname); + rai = (struct rainfo *)arg; + syslog(LOG_DEBUG, "<%s> RA timer on %s is expired", + __func__, rai->rai_ifname); ra_output(rai); - return(rai->timer); + return (rai->rai_timer); } /* update RA timer */ void -ra_timer_update(void *data, struct timeval *tm) +ra_timer_update(void *arg, struct timeval *tm) { - struct rainfo *rai = (struct rainfo *)data; long interval; + struct rainfo *rai; + rai = (struct rainfo *)arg; /* * Whenever a multicast advertisement is sent from an interface, * the timer is reset to a uniformly-distributed random value * between the interface's configured MinRtrAdvInterval and * MaxRtrAdvInterval (RFC2461 6.2.4). */ - interval = rai->mininterval; + interval = rai->rai_mininterval; #ifdef HAVE_ARC4RANDOM - interval += arc4random_uniform(rai->maxinterval - rai->mininterval); + interval += arc4random_uniform(rai->rai_maxinterval - + rai->rai_mininterval); #else - interval += random() % (rai->maxinterval - rai->mininterval); + interval += random() % (rai->rai_maxinterval - + rai->rai_mininterval); #endif /* @@ -1684,9 +1854,9 @@ ra_timer_update(void *data, struct timeval *tm) * MAX_INITIAL_RTR_ADVERTISEMENTS), if the randomly chosen interval * is greater than MAX_INITIAL_RTR_ADVERT_INTERVAL, the timer * SHOULD be set to MAX_INITIAL_RTR_ADVERT_INTERVAL instead. - * (RFC-2461 6.2.4) + * (RFC 4861 6.2.4) */ - if (rai->initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS && + if (rai->rai_initcounter < MAX_INITIAL_RTR_ADVERTISEMENTS && interval > MAX_INITIAL_RTR_ADVERT_INTERVAL) interval = MAX_INITIAL_RTR_ADVERT_INTERVAL; @@ -1694,9 +1864,9 @@ ra_timer_update(void *data, struct timeval *tm) tm->tv_usec = 0; syslog(LOG_DEBUG, - "<%s> RA timer on %s is set to %ld:%ld", - __func__, rai->ifname, - (long int)tm->tv_sec, (long int)tm->tv_usec); + "<%s> RA timer on %s is set to %ld:%ld", + __func__, rai->rai_ifname, + (long int)tm->tv_sec, (long int)tm->tv_usec); return; } diff --git a/usr.sbin/rtadvd/rtadvd.conf b/usr.sbin/rtadvd/rtadvd.conf index 33ab7f3e46bc..1e42c75b75be 100644 --- a/usr.sbin/rtadvd/rtadvd.conf +++ b/usr.sbin/rtadvd/rtadvd.conf @@ -18,4 +18,5 @@ # this part by hand, and then invoke rtadvd with the -s option. #ef0:\ -# :addr="3ffe:501:ffff:1000::":prefixlen#64: +# :addr="2001:db8:ffff:1000::":prefixlen#64:\ +# :rdnss="2001:db8:ffff:1000::1":dnssl="example.com": diff --git a/usr.sbin/rtadvd/rtadvd.conf.5 b/usr.sbin/rtadvd/rtadvd.conf.5 index 81ffa706fa23..ba2f490e79ca 100644 --- a/usr.sbin/rtadvd/rtadvd.conf.5 +++ b/usr.sbin/rtadvd/rtadvd.conf.5 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 17, 1998 +.Dd June 4, 2011 .Dt RTADVD.CONF 5 .Os .Sh NAME @@ -179,10 +179,25 @@ will automatically get appropriate prefixes from the kernel's routing table, and advertise the prefixes with the default parameters. Keywords other than .Cm clockskew +and +.Cm noifprefix can be augmented with a number, like .Dq Li prefix2 , to specify multiple prefixes. .Bl -tag -width indent +.It Cm \&noifprefix +(bool) Specifies no prefix on the network interfaces will be advertised. +By default +.Nm rtadvd +automatically gathers on-link prefixes from all of the network interfaces +and advertise them. +The +.Cm noifprefix +disables that behavior. +If this is specified and no +.Cm addr +keyword is specified, no prefix information option will be included in the +message. .It Cm \&clockskew (num) Time skew to adjust link propagation delays and clock skews between routers on the link @@ -355,6 +370,66 @@ However, keywords that start with .Dq Li rtr have basically been obsoleted, and should not be used any more. .Pp +The following items are for ICMPv6 Recursive DNS Server Option and +DNS Search List Option +.Pq RFC 6106 , +which will be attached to router advertisement header. +These items are optional. +.Bl -tag -width indent +.It Cm \&rdnss +(str) The IPv6 address of one or more recursive DNS servers. +The argument must be inside double quotes. +Multiple DNS servers can be specified in a comma-separated string. +If different lifetimes are needed for different servers, +separate entries can be given by using +.Cm rdnss , +.Cm rdnss0 , +.Cm rdnss1 , +.Cm rdnss2 ... +options with corresponding +.Cm rdnssltime , +.Cm rdnssltime0 , +.Cm rdnssltime1 , +.Cm rdnssltime2 ... +entries. +Note that the maximum number of servers depends on the receiver side. +See also +.Xr resolver 5 +manual page for resolver implementation in +.Fx . +.It Cm \&rdnssltime +The lifetime of the +.Cm rdnss +DNS server entries. +The default value is 3/2 of the interval time. +.It Cm \&dnssl +(str) One or more domain names in a comma-separated string. +These domain names will be used when making DNS queries on a +non-fully-qualified domain name. +If different lifetimes are needed for different domains, separate entries +can be given by using +.Cm dnssl , +.Cm dnssl0 , +.Cm dnssl1 , +.Cm dnssl2 ... +options with corresponding +.Cm dnsslltime , +.Cm dnsslltime0 , +.Cm dnsslltime1 , +.Cm dnsslltime2 ... +entries. +Note that the maximum number of names depends on the receiver side. +See also +.Xr resolver 5 +manual page for resolver implementation in +.Fx . +.It Cm \&dnsslltime +The lifetime of the +.Cm dnssl +DNS search list entries. +The default value is 3/2 of the interval time. +.El +.Pp You can also refer one line from another by using .Cm tc capability. @@ -388,7 +463,18 @@ option to .Xr rtadvd 8 . .Bd -literal -offset ef0:\\ - :addr="3ffe:501:ffff:1000::":prefixlen#64: + :addr="2001:db8:ffff:1000::":prefixlen#64: +.Ed +.Pp +The following example configures the +.Li wlan0 +interface and adds two DNS servers and a DNS domain search options +using the default option lifetime values. +.Bd -literal -offset +wlan0:\\ + :addr="2001:db8:ffff:1000::":prefixlen#64:\\ + :rdnss="2001:db8:ffff::10,2001:db8:ffff::2:43":\\ + :dnssl="example.com": .Ed .Pp The following example presents the default values in an explicit manner. @@ -399,24 +485,41 @@ default:\\ :chlim#64:raflags#0:rltime#1800:rtime#0:retrans#0:\\ :pinfoflags="la":vltime#2592000:pltime#604800:mtu#0: ef0:\\ - :addr="3ffe:501:ffff:1000::":prefixlen#64:tc=default: + :addr="2001:db8:ffff:1000::":prefixlen#64:tc=default: .Ed .Sh SEE ALSO .Xr termcap 5 , +.Xr resolver 5 , .Xr rtadvd 8 , .Xr rtsol 8 .Rs .%A Thomas Narten .%A Erik Nordmark .%A W. A. Simpson +.%A Hesham Soliman .%T Neighbor Discovery for IP version 6 (IPv6) -.%R RFC 2461 +.%R RFC 4861 +.Re +.Rs +.%A Thomas Narten +.%A Erik Nordmark +.%A W. A. Simpson +.%T Neighbor Discovery for IP version 6 (IPv6) +.%R RFC 2461 (obsoleted by RFC 4861) .Re .Rs .%A Richard Draves .%T Default Router Preferences and More-Specific Routes .%R draft-ietf-ipngwg-router-selection-xx.txt .Re +.Rs +.%A J. Jeong +.%A S. Park +.%A L. Beloeil +.%A S. Madanapalli +.%T IPv6 Router Advertisement Options for DNS Configuration +.%R RFC 6106 +.Re .Sh HISTORY The .Xr rtadvd 8 diff --git a/usr.sbin/rtadvd/rtadvd.h b/usr.sbin/rtadvd/rtadvd.h index 828fec6924ab..f65a837a17b0 100644 --- a/usr.sbin/rtadvd/rtadvd.h +++ b/usr.sbin/rtadvd/rtadvd.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -30,11 +30,41 @@ * SUCH DAMAGE. */ -#define ALLNODES "ff02::1" -#define ALLROUTERS_LINK "ff02::2" -#define ALLROUTERS_SITE "ff05::2" -#define ANY "::" -#define RTSOLLEN 8 +#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} + +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} + +#define IN6ADDR_SITELOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} + +extern struct sockaddr_in6 sin6_linklocal_allnodes; +extern struct sockaddr_in6 sin6_linklocal_allrouters; +extern struct sockaddr_in6 sin6_sitelocal_allrouters; + +/* + * RFC 3542 API deprecates IPV6_PKTINFO in favor of + * IPV6_RECVPKTINFO + */ +#ifndef IPV6_RECVPKTINFO +#ifdef IPV6_PKTINFO +#define IPV6_RECVPKTINFO IPV6_PKTINFO +#endif +#endif + +/* + * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of + * IPV6_RECVHOPLIMIT + */ +#ifndef IPV6_RECVHOPLIMIT +#ifdef IPV6_HOPLIMIT +#define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT +#endif +#endif /* protocol constants and default values */ #define DEF_MAXRTRADVINTERVAL 600 @@ -62,100 +92,150 @@ #define PREFIX_FROM_DYNAMIC 3 struct prefix { - struct prefix *next; /* forward link */ - struct prefix *prev; /* previous link */ + TAILQ_ENTRY(prefix) pfx_next; - struct rainfo *rainfo; /* back pointer to the interface */ + struct rainfo *pfx_rainfo; /* back pointer to the interface */ + /* + * Expiration timer. This is used when a prefix derived from + * the kernel is deleted. + */ + struct rtadvd_timer *pfx_timer; - struct rtadvd_timer *timer; /* expiration timer. used when a prefix - * derived from the kernel is deleted. - */ + u_int32_t pfx_validlifetime; /* AdvValidLifetime */ + long pfx_vltimeexpire; /* Expiration of vltime */ + u_int32_t pfx_preflifetime; /* AdvPreferredLifetime */ + long pfx_pltimeexpire; /* Expiration of pltime */ + u_int pfx_onlinkflg; /* bool: AdvOnLinkFlag */ + u_int pfx_autoconfflg; /* bool: AdvAutonomousFlag */ + int pfx_prefixlen; + int pfx_origin; /* From kernel or config */ - u_int32_t validlifetime; /* AdvValidLifetime */ - long vltimeexpire; /* expiration of vltime; decrement case only */ - u_int32_t preflifetime; /* AdvPreferredLifetime */ - long pltimeexpire; /* expiration of pltime; decrement case only */ - u_int onlinkflg; /* bool: AdvOnLinkFlag */ - u_int autoconfflg; /* bool: AdvAutonomousFlag */ - int prefixlen; - int origin; /* from kernel or config */ - struct in6_addr prefix; + struct in6_addr pfx_prefix; }; #ifdef ROUTEINFO struct rtinfo { - struct rtinfo *prev; /* previous link */ - struct rtinfo *next; /* forward link */ + TAILQ_ENTRY(rtinfo) rti_next; - u_int32_t ltime; /* route lifetime */ - u_int rtpref; /* route preference */ - int prefixlen; - struct in6_addr prefix; + u_int32_t rti_ltime; /* route lifetime */ + u_int rti_rtpref; /* route preference */ + int rti_prefixlen; + struct in6_addr rti_prefix; }; #endif +struct rdnss_addr { + TAILQ_ENTRY(rdnss_addr) ra_next; + + struct in6_addr ra_dns; /* DNS server entry */ +}; + +struct rdnss { + TAILQ_ENTRY(rdnss) rd_next; + + TAILQ_HEAD(, rdnss_addr) rd_list; /* list of DNS servers */ + int rd_cnt; /* number of DNS servers */ + u_int32_t rd_ltime; /* number of seconds valid */ +}; + +/* + * The maximum length of a domain name in a DNS search list is calculated + * by a domain name + length fields per 63 octets + a zero octet at + * the tail and adding 8 octet boundary padding. + */ +#define _DNAME_LABELENC_MAXLEN \ + (NI_MAXHOST + (NI_MAXHOST / 64 + 1) + 1) + +#define DNAME_LABELENC_MAXLEN \ + (_DNAME_LABELENC_MAXLEN + 8 - _DNAME_LABELENC_MAXLEN % 8) + +struct dnssl_addr { + TAILQ_ENTRY(dnssl_addr) da_next; + + int da_len; /* length of entry */ + char da_dom[DNAME_LABELENC_MAXLEN]; /* search domain name entry */ +}; + +struct dnssl { + TAILQ_ENTRY(dnssl) dn_next; + + TAILQ_HEAD(, dnssl_addr) dn_list; /* list of search domains */ + u_int32_t dn_ltime; /* number of seconds valid */ +}; + struct soliciter { - struct soliciter *next; - struct sockaddr_in6 addr; + TAILQ_ENTRY(soliciter) sol_next; + + struct sockaddr_in6 sol_addr; }; struct rainfo { /* pointer for list */ - struct rainfo *next; + TAILQ_ENTRY(rainfo) rai_next; /* timer related parameters */ - struct rtadvd_timer *timer; - int initcounter; /* counter for the first few advertisements */ - struct timeval lastsent; /* timestamp when the latest RA was sent */ - int waiting; /* number of RS waiting for RA */ + struct rtadvd_timer *rai_timer; + /* counter for the first few advertisements */ + int rai_initcounter; + /* timestamp when the latest RA was sent */ + struct timeval rai_lastsent; + /* number of RS waiting for RA */ + int rai_waiting; /* interface information */ - int ifindex; - int advlinkopt; /* bool: whether include link-layer addr opt */ - struct sockaddr_dl *sdl; - char ifname[16]; - int phymtu; /* mtu of the physical interface */ + int rai_ifindex; + int rai_advlinkopt; /* bool: whether include link-layer addr opt */ + int rai_advifprefix; /* bool: gather IF prefixes? */ + struct sockaddr_dl *rai_sdl; + char rai_ifname[IFNAMSIZ]; + u_int32_t rai_phymtu; /* mtu of the physical interface */ /* Router configuration variables */ - u_short lifetime; /* AdvDefaultLifetime */ - u_int maxinterval; /* MaxRtrAdvInterval */ - u_int mininterval; /* MinRtrAdvInterval */ - int managedflg; /* AdvManagedFlag */ - int otherflg; /* AdvOtherConfigFlag */ + u_short rai_lifetime; /* AdvDefaultLifetime */ + u_int rai_maxinterval; /* MaxRtrAdvInterval */ + u_int rai_mininterval; /* MinRtrAdvInterval */ + int rai_managedflg; /* AdvManagedFlag */ + int rai_otherflg; /* AdvOtherConfigFlag */ - int rtpref; /* router preference */ - u_int32_t linkmtu; /* AdvLinkMTU */ - u_int32_t reachabletime; /* AdvReachableTime */ - u_int32_t retranstimer; /* AdvRetransTimer */ - u_int hoplimit; /* AdvCurHopLimit */ - struct prefix prefix; /* AdvPrefixList(link head) */ - int pfxs; /* number of prefixes */ - long clockskew; /* used for consisitency check of lifetimes */ + int rai_rtpref; /* router preference */ + u_int32_t rai_linkmtu; /* AdvLinkMTU */ + u_int32_t rai_reachabletime; /* AdvReachableTime */ + u_int32_t rai_retranstimer; /* AdvRetransTimer */ + u_int rai_hoplimit; /* AdvCurHopLimit */ + TAILQ_HEAD(, prefix) rai_prefix;/* AdvPrefixList(link head) */ + int rai_pfxs; /* number of prefixes */ + + long rai_clockskew; /* used for consisitency check of lifetimes */ + + TAILQ_HEAD(, rdnss) rai_rdnss; /* DNS server list */ + TAILQ_HEAD(, dnssl) rai_dnssl; /* search domain list */ #ifdef ROUTEINFO - struct rtinfo route; /* route information option (link head) */ - int routes; /* number of route information options */ + TAILQ_HEAD(, rtinfo) rai_route; /* route information option (link head) */ + int rai_routes; /* number of route information options */ #endif - /* actual RA packet data and its length */ - size_t ra_datalen; - u_char *ra_data; + size_t rai_ra_datalen; + u_char *rai_ra_data; /* statistics */ - u_quad_t raoutput; /* number of RAs sent */ - u_quad_t rainput; /* number of RAs received */ - u_quad_t rainconsistent; /* number of RAs inconsistent with ours */ - u_quad_t rsinput; /* number of RSs received */ + u_quad_t rai_raoutput; /* # of RAs sent */ + u_quad_t rai_rainput; /* # of RAs received */ + u_quad_t rai_rainconsistent; /* # of RAs inconsistent with ours */ + u_quad_t rai_rsinput; /* # of RSs received */ /* info about soliciter */ - struct soliciter *soliciter; /* recent solication source */ + TAILQ_HEAD(, soliciter) rai_soliciter; /* recent solication source */ }; -struct rtadvd_timer *ra_timeout(void *); -void ra_timer_update(void *, struct timeval *); +/* Interface list including RA information */ +extern TAILQ_HEAD(railist_head_t, rainfo) railist; -int prefix_match(struct in6_addr *, int, struct in6_addr *, int); -struct rainfo *if_indextorainfo(int); -struct prefix *find_prefix(struct rainfo *, struct in6_addr *, int); +struct rtadvd_timer *ra_timeout(void *); +void ra_timer_update(void *, struct timeval *); -extern struct in6_addr in6a_site_allrouters; +int prefix_match(struct in6_addr *, int, + struct in6_addr *, int); +struct rainfo *if_indextorainfo(int); +struct prefix *find_prefix(struct rainfo *, + struct in6_addr *, int); diff --git a/usr.sbin/rtadvd/timer.c b/usr.sbin/rtadvd/timer.c index 7fb090258ce7..8cad6ad9a0e8 100644 --- a/usr.sbin/rtadvd/timer.c +++ b/usr.sbin/rtadvd/timer.c @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -31,6 +31,7 @@ */ #include +#include #include #include @@ -39,21 +40,19 @@ #include #include "timer.h" -static struct rtadvd_timer timer_head; - #define MILLION 1000000 -#define TIMEVAL_EQUAL(t1,t2) ((t1)->tv_sec == (t2)->tv_sec &&\ - (t1)->tv_usec == (t2)->tv_usec) -static struct timeval tm_max = {0x7fffffff, 0x7fffffff}; +struct rtadvd_timer_head_t ra_timer = + TAILQ_HEAD_INITIALIZER(ra_timer); +static struct timeval tm_limit = {0x7fffffff, 0x7fffffff}; +static struct timeval tm_max; void -rtadvd_timer_init() +rtadvd_timer_init(void) { - memset(&timer_head, 0, sizeof(timer_head)); - timer_head.next = timer_head.prev = &timer_head; - timer_head.tm = tm_max; + tm_max = tm_limit; + TAILQ_INIT(&ra_timer); } struct rtadvd_timer * @@ -61,54 +60,57 @@ rtadvd_add_timer(struct rtadvd_timer *(*timeout)(void *), void (*update)(void *, struct timeval *), void *timeodata, void *updatedata) { - struct rtadvd_timer *newtimer; - - if ((newtimer = malloc(sizeof(*newtimer))) == NULL) { - syslog(LOG_ERR, - "<%s> can't allocate memory", __func__); - exit(1); - } - - memset(newtimer, 0, sizeof(*newtimer)); + struct rtadvd_timer *rat; if (timeout == NULL) { syslog(LOG_ERR, - "<%s> timeout function unspecified", __func__); + "<%s> timeout function unspecified", __func__); exit(1); } - newtimer->expire = timeout; - newtimer->update = update; - newtimer->expire_data = timeodata; - newtimer->update_data = updatedata; - newtimer->tm = tm_max; + + rat = malloc(sizeof(*rat)); + if (rat == NULL) { + syslog(LOG_ERR, + "<%s> can't allocate memory", __func__); + exit(1); + } + memset(rat, 0, sizeof(*rat)); + + rat->rat_expire = timeout; + rat->rat_update = update; + rat->rat_expire_data = timeodata; + rat->rat_update_data = updatedata; + rat->rat_tm = tm_max; /* link into chain */ - insque(newtimer, &timer_head); + TAILQ_INSERT_TAIL(&ra_timer, rat, rat_next); - return(newtimer); + return (rat); } void -rtadvd_remove_timer(struct rtadvd_timer **timer) +rtadvd_remove_timer(struct rtadvd_timer *rat) { - remque(*timer); - free(*timer); - *timer = NULL; + + if (rat == NULL) + return; + + TAILQ_REMOVE(&ra_timer, rat, rat_next); + free(rat); } void -rtadvd_set_timer(struct timeval *tm, struct rtadvd_timer *timer) +rtadvd_set_timer(struct timeval *tm, struct rtadvd_timer *rat) { struct timeval now; /* reset the timer */ gettimeofday(&now, NULL); - - TIMEVAL_ADD(&now, tm, &timer->tm); + TIMEVAL_ADD(&now, tm, &rat->rat_tm); /* update the next expiration time */ - if (TIMEVAL_LT(timer->tm, timer_head.tm)) - timer_head.tm = timer->tm; + if (TIMEVAL_LT(&rat->rat_tm, &tm_max)) + tm_max = rat->rat_tm; return; } @@ -119,58 +121,52 @@ rtadvd_set_timer(struct timeval *tm, struct rtadvd_timer *timer) * Return the next interval for select() call. */ struct timeval * -rtadvd_check_timer() +rtadvd_check_timer(void) { static struct timeval returnval; struct timeval now; - struct rtadvd_timer *tm = timer_head.next, *tm_next; + struct rtadvd_timer *rat; gettimeofday(&now, NULL); - - timer_head.tm = tm_max; - - for (tm = timer_head.next; tm != &timer_head; tm = tm_next) { - tm_next = tm->next; - - if (TIMEVAL_LEQ(tm->tm, now)) { - if (((*tm->expire)(tm->expire_data) == NULL)) + tm_max = tm_limit; + TAILQ_FOREACH(rat, &ra_timer, rat_next) { + if (TIMEVAL_LEQ(&rat->rat_tm, &now)) { + if (((*rat->rat_expire)(rat->rat_expire_data) == NULL)) continue; /* the timer was removed */ - if (tm->update) - (*tm->update)(tm->update_data, &tm->tm); - TIMEVAL_ADD(&tm->tm, &now, &tm->tm); + if (rat->rat_update) + (*rat->rat_update)(rat->rat_update_data, &rat->rat_tm); + TIMEVAL_ADD(&rat->rat_tm, &now, &rat->rat_tm); } - - if (TIMEVAL_LT(tm->tm, timer_head.tm)) - timer_head.tm = tm->tm; + if (TIMEVAL_LT(&rat->rat_tm, &tm_max)) + tm_max = rat->rat_tm; } - - if (TIMEVAL_EQUAL(&tm_max, &timer_head.tm)) { + if (TIMEVAL_EQUAL(&tm_max, &tm_limit)) { /* no need to timeout */ - return(NULL); - } else if (TIMEVAL_LT(timer_head.tm, now)) { + return (NULL); + } else if (TIMEVAL_LT(&tm_max, &now)) { /* this may occur when the interval is too small */ returnval.tv_sec = returnval.tv_usec = 0; } else - TIMEVAL_SUB(&timer_head.tm, &now, &returnval); - return(&returnval); + TIMEVAL_SUB(&tm_max, &now, &returnval); + return (&returnval); } struct timeval * -rtadvd_timer_rest(struct rtadvd_timer *timer) +rtadvd_timer_rest(struct rtadvd_timer *rat) { static struct timeval returnval, now; gettimeofday(&now, NULL); - if (TIMEVAL_LEQ(timer->tm, now)) { + if (TIMEVAL_LEQ(&rat->rat_tm, &now)) { syslog(LOG_DEBUG, - "<%s> a timer must be expired, but not yet", - __func__); + "<%s> a timer must be expired, but not yet", + __func__); returnval.tv_sec = returnval.tv_usec = 0; } else - TIMEVAL_SUB(&timer->tm, &now, &returnval); + TIMEVAL_SUB(&rat->rat_tm, &now, &returnval); - return(&returnval); + return (&returnval); } /* result = a + b */ diff --git a/usr.sbin/rtadvd/timer.h b/usr.sbin/rtadvd/timer.h index 45261032974e..e2e0c654e1c1 100644 --- a/usr.sbin/rtadvd/timer.h +++ b/usr.sbin/rtadvd/timer.h @@ -4,7 +4,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -16,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -31,35 +31,42 @@ */ /* a < b */ -#define TIMEVAL_LT(a, b) (((a).tv_sec < (b).tv_sec) ||\ - (((a).tv_sec == (b).tv_sec) && \ - ((a).tv_usec < (b).tv_usec))) +#define TIMEVAL_LT(a, b) \ + (((a)->tv_sec < (b)->tv_sec) || \ + (((a)->tv_sec == (b)->tv_sec) && \ + ((a)->tv_usec < (b)->tv_usec))) /* a <= b */ -#define TIMEVAL_LEQ(a, b) (((a).tv_sec < (b).tv_sec) ||\ - (((a).tv_sec == (b).tv_sec) &&\ - ((a).tv_usec <= (b).tv_usec))) +#define TIMEVAL_LEQ(a, b) \ + (((a)->tv_sec < (b)->tv_sec) || \ + (((a)->tv_sec == (b)->tv_sec) && \ + ((a)->tv_usec <= (b)->tv_usec))) +#define TIMEVAL_EQUAL(a,b) \ + (((a)->tv_sec == (b)->tv_sec) && \ + ((a)->tv_usec == (b)->tv_usec)) + +extern TAILQ_HEAD(rtadvd_timer_head_t, rtadvd_timer) ra_timer; struct rtadvd_timer { - struct rtadvd_timer *next; - struct rtadvd_timer *prev; - struct rainfo *rai; - struct timeval tm; + TAILQ_ENTRY(rtadvd_timer) rat_next; - struct rtadvd_timer *(*expire)(void *); /* expiration function */ - void *expire_data; - void (*update)(void *, struct timeval *); /* update function */ - void *update_data; + struct rainfo *rat_rai; + struct timeval rat_tm; + struct rtadvd_timer *(*rat_expire)(void *); + void *rat_expire_data; + void (*rat_update)(void *, struct timeval *); + void *rat_update_data; }; -void rtadvd_timer_init(void); -struct rtadvd_timer *rtadvd_add_timer(struct rtadvd_timer *(*)(void *), - void (*)(void *, struct timeval *), void *, void *); -void rtadvd_set_timer(struct timeval *, struct rtadvd_timer *); -void rtadvd_remove_timer(struct rtadvd_timer **); -struct timeval * rtadvd_check_timer(void); -struct timeval * rtadvd_timer_rest(struct rtadvd_timer *); -void TIMEVAL_ADD(struct timeval *, struct timeval *, - struct timeval *); -void TIMEVAL_SUB(struct timeval *, struct timeval *, - struct timeval *); +void rtadvd_timer_init(void); +struct rtadvd_timer *rtadvd_add_timer(struct rtadvd_timer *(*)(void *), + void (*)(void *, struct timeval *), void *, void *); +void rtadvd_set_timer(struct timeval *, + struct rtadvd_timer *); +void rtadvd_remove_timer(struct rtadvd_timer *); +struct timeval *rtadvd_check_timer(void); +struct timeval *rtadvd_timer_rest(struct rtadvd_timer *); +void TIMEVAL_ADD(struct timeval *, struct timeval *, + struct timeval *); +void TIMEVAL_SUB(struct timeval *, struct timeval *, + struct timeval *); diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile index efc322c673be..9e2b48037307 100644 --- a/usr.sbin/rtsold/Makefile +++ b/usr.sbin/rtsold/Makefile @@ -19,7 +19,7 @@ MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c -WARNS?= 3 +WARNS?= 6 CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H DPADD= ${LIBKVM} LDADD= -lkvm diff --git a/usr.sbin/rtsold/dump.c b/usr.sbin/rtsold/dump.c index 2756b87eeb90..2e6b4caa44ec 100644 --- a/usr.sbin/rtsold/dump.c +++ b/usr.sbin/rtsold/dump.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -58,41 +59,41 @@ static const char * const ifstatstr[] = {"IDLE", "DELAY", "PROBE", "DOWN", "TENT static void dump_interface_status(void) { - struct ifinfo *ifinfo; + struct ifinfo *ifi; struct timeval now; gettimeofday(&now, NULL); - for (ifinfo = iflist; ifinfo; ifinfo = ifinfo->next) { - fprintf(fp, "Interface %s\n", ifinfo->ifname); + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { + fprintf(fp, "Interface %s\n", ifi->ifname); fprintf(fp, " probe interval: "); - if (ifinfo->probeinterval) { - fprintf(fp, "%d\n", ifinfo->probeinterval); - fprintf(fp, " probe timer: %d\n", ifinfo->probetimer); + if (ifi->probeinterval) { + fprintf(fp, "%d\n", ifi->probeinterval); + fprintf(fp, " probe timer: %d\n", ifi->probetimer); } else { fprintf(fp, "infinity\n"); fprintf(fp, " no probe timer\n"); } fprintf(fp, " interface status: %s\n", - ifinfo->active > 0 ? "active" : "inactive"); + ifi->active > 0 ? "active" : "inactive"); fprintf(fp, " other config: %s\n", - ifinfo->otherconfig ? "on" : "off"); - fprintf(fp, " rtsold status: %s\n", ifstatstr[ifinfo->state]); + ifi->otherconfig ? "on" : "off"); + fprintf(fp, " rtsold status: %s\n", ifstatstr[ifi->state]); fprintf(fp, " carrier detection: %s\n", - ifinfo->mediareqok ? "available" : "unavailable"); + ifi->mediareqok ? "available" : "unavailable"); fprintf(fp, " probes: %d, dadcount = %d\n", - ifinfo->probes, ifinfo->dadcount); - if (ifinfo->timer.tv_sec == tm_max.tv_sec && - ifinfo->timer.tv_usec == tm_max.tv_usec) + ifi->probes, ifi->dadcount); + if (ifi->timer.tv_sec == tm_max.tv_sec && + ifi->timer.tv_usec == tm_max.tv_usec) fprintf(fp, " no timer\n"); else { fprintf(fp, " timer: interval=%d:%d, expire=%s\n", - (int)ifinfo->timer.tv_sec, - (int)ifinfo->timer.tv_usec, - (ifinfo->expire.tv_sec < now.tv_sec) ? "expired" - : sec2str(ifinfo->expire.tv_sec - now.tv_sec)); + (int)ifi->timer.tv_sec, + (int)ifi->timer.tv_usec, + (ifi->expire.tv_sec < now.tv_sec) ? "expired" + : sec2str(ifi->expire.tv_sec - now.tv_sec)); } - fprintf(fp, " number of valid RAs: %d\n", ifinfo->racnt); + fprintf(fp, " number of valid RAs: %d\n", ifi->racnt); } } @@ -145,5 +146,6 @@ sec2str(time_t total) p += n; } snprintf(p, ep - p, "%ds", secs); - return(result); + + return (result); } diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index c555d2a8644c..58ec514aa94e 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -91,25 +91,25 @@ interface_up(char *name) if (ioctl(ifsock, SIOCGIFFLAGS, (caddr_t)&ifr) < 0) { warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFFLAGS): %s", strerror(errno)); - return(-1); + return (-1); } if (!(ifr.ifr_flags & IFF_UP)) { ifr.ifr_flags |= IFF_UP; if (ioctl(ifsock, SIOCSIFFLAGS, (caddr_t)&ifr) < 0) warnmsg(LOG_ERR, __func__, "ioctl(SIOCSIFFLAGS): %s", strerror(errno)); - return(-1); + return (-1); } if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { warnmsg(LOG_WARNING, __func__, "socket(AF_INET6, SOCK_DGRAM): %s", strerror(errno)); - return(-1); + return (-1); } if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { warnmsg(LOG_WARNING, __func__, "ioctl(SIOCGIFINFO_IN6): %s", strerror(errno)); close(s); - return(-1); + return (-1); } warnmsg(LOG_DEBUG, __func__, "checking if %s is ready...", name); @@ -122,13 +122,13 @@ interface_up(char *name) "ioctl(SIOCSIFINFO_IN6): %s", strerror(errno)); close(s); - return(-1); + return (-1); } } else { warnmsg(LOG_WARNING, __func__, "%s is disabled.", name); close(s); - return(-1); + return (-1); } } if (!(nd.ndi.flags & ND6_IFF_ACCEPT_RTADV)) { @@ -139,13 +139,13 @@ interface_up(char *name) "ioctl(SIOCSIFINFO_IN6): %s", strerror(errno)); close(s); - return(-1); + return (-1); } } else { warnmsg(LOG_WARNING, __func__, "%s does not accept Router Advertisement.", name); close(s); - return(-1); + return (-1); } } close(s); @@ -154,22 +154,22 @@ interface_up(char *name) if (llflag < 0) { warnmsg(LOG_WARNING, __func__, "get_llflag() failed, anyway I'll try"); - return 0; + return (0); } if (!(llflag & IN6_IFF_NOTREADY)) { warnmsg(LOG_DEBUG, __func__, "%s is ready", name); - return(0); + return (0); } else { if (llflag & IN6_IFF_TENTATIVE) { warnmsg(LOG_DEBUG, __func__, "%s is tentative", name); - return IFS_TENTATIVE; + return (IFS_TENTATIVE); } if (llflag & IN6_IFF_DUPLICATED) warnmsg(LOG_DEBUG, __func__, "%s is duplicated", name); - return -1; + return (-1); } } @@ -186,16 +186,14 @@ interface_status(struct ifinfo *ifinfo) if (ioctl(ifsock, SIOCGIFFLAGS, &ifr) < 0) { warnmsg(LOG_ERR, __func__, "ioctl(SIOCGIFFLAGS) on %s: %s", ifname, strerror(errno)); - return(-1); + return (-1); } /* * if one of UP and RUNNING flags is dropped, * the interface is not active. */ - if ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) { + if ((ifr.ifr_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) goto inactive; - } - /* Next, check carrier on the interface, if possible */ if (!ifinfo->mediareqok) goto active; @@ -232,10 +230,10 @@ interface_status(struct ifinfo *ifinfo) } inactive: - return(0); + return (0); active: - return(1); + return (1); } #define ROUNDUP(a, size) \ @@ -254,9 +252,9 @@ lladdropt_length(struct sockaddr_dl *sdl) #ifdef IFT_IEEE80211 case IFT_IEEE80211: #endif - return(ROUNDUP8(ETHER_ADDR_LEN + 2)); + return (ROUNDUP8(ETHER_ADDR_LEN + 2)); default: - return(0); + return (0); } } @@ -301,7 +299,7 @@ if_nametosdl(char *name) return(NULL); if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { free(buf); - return(NULL); + return (NULL); } lim = buf + len; @@ -327,17 +325,17 @@ if_nametosdl(char *name) if (next == lim) { /* search failed */ free(buf); - return(NULL); + return (NULL); } if ((ret_sdl = malloc(sdl->sdl_len)) == NULL) { free(buf); - return(NULL); + return (NULL); } memcpy((caddr_t)ret_sdl, (caddr_t)sdl, sdl->sdl_len); free(buf); - return(ret_sdl); + return (ret_sdl); } int @@ -350,9 +348,9 @@ getinet6sysctl(int code) mib[3] = code; size = sizeof(value); if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0) < 0) - return -1; + return (-1); else - return value; + return (value); } int @@ -366,9 +364,9 @@ setinet6sysctl(int code, int newval) size = sizeof(value); if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, &newval, sizeof(newval)) < 0) - return -1; + return (-1); else - return value; + return (value); } /*------------------------------------------------------------*/ @@ -414,12 +412,12 @@ get_llflag(const char *name) freeifaddrs(ifap); close(s); - return ifr6.ifr_ifru.ifru_flags6; + return (ifr6.ifr_ifru.ifru_flags6); } freeifaddrs(ifap); close(s); - return -1; + return (-1); } diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c index 6d0ea79fd392..657ae406cdfa 100644 --- a/usr.sbin/rtsold/probe.c +++ b/usr.sbin/rtsold/probe.c @@ -72,18 +72,18 @@ probe_init(void) if (sndcmsgbuf == NULL && (sndcmsgbuf = (u_char *)malloc(scmsglen)) == NULL) { warnmsg(LOG_ERR, __func__, "malloc failed"); - return(-1); + return (-1); } if ((probesock = socket(AF_INET6, SOCK_RAW, IPPROTO_NONE)) < 0) { warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno)); - return(-1); + return (-1); } /* make the socket send-only */ if (shutdown(probesock, 0)) { warnmsg(LOG_ERR, __func__, "shutdown: %s", strerror(errno)); - return(-1); + return (-1); } /* initialize msghdr for sending packets */ @@ -92,7 +92,8 @@ probe_init(void) sndmhdr.msg_iovlen = 1; sndmhdr.msg_control = (caddr_t)sndcmsgbuf; sndmhdr.msg_controllen = scmsglen; - return(0); + + return (0); } /* diff --git a/usr.sbin/rtsold/rtsock.c b/usr.sbin/rtsold/rtsock.c index 726c1e69790f..fe22bc78263a 100644 --- a/usr.sbin/rtsold/rtsock.c +++ b/usr.sbin/rtsold/rtsock.c @@ -83,7 +83,7 @@ int rtsock_open(void) { - return socket(PF_ROUTE, SOCK_RAW, 0); + return (socket(PF_ROUTE, SOCK_RAW, 0)); } int @@ -130,7 +130,7 @@ rtsock_input(int s) } } - return ret; + return (ret); } #ifdef RTM_IFANNOUNCE /*NetBSD 1.5 or later*/ @@ -142,7 +142,7 @@ rtsock_input_ifannounce(int s __unused, struct rt_msghdr *rtm, char *lim) ifan = (struct if_announcemsghdr *)rtm; if ((char *)(ifan + 1) > lim) - return -1; + return (-1); switch (ifan->ifan_what) { case IFAN_ARRIVAL: @@ -170,6 +170,6 @@ rtsock_input_ifannounce(int s __unused, struct rt_msghdr *rtm, char *lim) break; } - return 0; + return (0); } #endif diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index be2a9b8c1777..afa935e72da7 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -2,6 +2,7 @@ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * Copyright (C) 2011 Hiroki Sato * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,13 +44,16 @@ #include #include +#define __BSD_VISIBLE 1 /* IN6ADDR_LINKLOCAL_ALLROUTERS_INIT */ #include +#undef __BSD_VISIBLE #include #include #include #include +#include #include #include #include @@ -61,8 +65,6 @@ #include #include "rtsold.h" -#define ALLROUTER "ff02::2" - static struct msghdr rcvmhdr; static struct msghdr sndmhdr; static struct iovec rcviov[2]; @@ -71,15 +73,40 @@ static struct sockaddr_in6 from; static int rcvcmsglen; int rssock; +struct ifinfo_head_t ifinfo_head = + TAILQ_HEAD_INITIALIZER(ifinfo_head); -static struct sockaddr_in6 sin6_allrouters = { +static const struct sockaddr_in6 sin6_allrouters = { .sin6_len = sizeof(sin6_allrouters), .sin6_family = AF_INET6, + .sin6_addr = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT, }; -static void call_script(char *, char *); +static void call_script(const int, const char *const *, void *); +static size_t dname_labeldec(char *, size_t, const char *); static int safefile(const char *); +#define _ARGS_OTHER otherconf_script, ifi->ifname +#define _ARGS_RESADD resolvconf_script, "-a", ifi->ifname +#define _ARGS_RESDEL resolvconf_script, "-d", ifi->ifname + +#define CALL_SCRIPT(name, sm_head) \ + do { \ + const char *const sarg[] = { _ARGS_##name, NULL }; \ + call_script(sizeof(sarg), sarg, sm_head); \ + } while(0) + +#define ELM_MALLOC(p,error_action) \ + do { \ + p = malloc(sizeof(*p)); \ + if (p == NULL) { \ + warnmsg(LOG_ERR, __func__, "malloc failed: %s", \ + strerror(errno)); \ + error_action; \ + } \ + memset(p, 0, sizeof(*p)); \ + } while(0) + int sockopen(void) { @@ -93,63 +120,35 @@ sockopen(void) if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) { warnmsg(LOG_ERR, __func__, "malloc for receive msghdr failed"); - return(-1); + return (-1); } if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsglen)) == NULL) { warnmsg(LOG_ERR, __func__, "malloc for send msghdr failed"); - return(-1); + return (-1); } - memset(&sin6_allrouters, 0, sizeof(struct sockaddr_in6)); - sin6_allrouters.sin6_family = AF_INET6; - sin6_allrouters.sin6_len = sizeof(sin6_allrouters); - if (inet_pton(AF_INET6, ALLROUTER, - &sin6_allrouters.sin6_addr.s6_addr) != 1) { - warnmsg(LOG_ERR, __func__, "inet_pton failed for %s", - ALLROUTER); - return(-1); - } - if ((rssock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) { warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno)); - return(-1); + return (-1); } /* specify to tell receiving interface */ on = 1; -#ifdef IPV6_RECVPKTINFO if (setsockopt(rssock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on)) < 0) { warnmsg(LOG_ERR, __func__, "IPV6_RECVPKTINFO: %s", strerror(errno)); exit(1); } -#else /* old adv. API */ - if (setsockopt(rssock, IPPROTO_IPV6, IPV6_PKTINFO, &on, - sizeof(on)) < 0) { - warnmsg(LOG_ERR, __func__, "IPV6_PKTINFO: %s", - strerror(errno)); - exit(1); - } -#endif - on = 1; /* specify to tell value of hoplimit field of received IP6 hdr */ -#ifdef IPV6_RECVHOPLIMIT + on = 1; if (setsockopt(rssock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, sizeof(on)) < 0) { warnmsg(LOG_ERR, __func__, "IPV6_RECVHOPLIMIT: %s", strerror(errno)); exit(1); } -#else /* old adv. API */ - if (setsockopt(rssock, IPPROTO_IPV6, IPV6_HOPLIMIT, &on, - sizeof(on)) < 0) { - warnmsg(LOG_ERR, __func__, "IPV6_HOPLIMIT: %s", - strerror(errno)); - exit(1); - } -#endif /* specfiy to accept only router advertisements on the socket */ ICMP6_FILTER_SETBLOCKALL(&filt); @@ -176,11 +175,11 @@ sockopen(void) sndmhdr.msg_control = (caddr_t)sndcmsgbuf; sndmhdr.msg_controllen = sndcmsglen; - return(rssock); + return (rssock); } void -sendpacket(struct ifinfo *ifinfo) +sendpacket(struct ifinfo *ifi) { struct in6_pktinfo *pi; struct cmsghdr *cm; @@ -189,11 +188,11 @@ sendpacket(struct ifinfo *ifinfo) struct sockaddr_in6 dst; dst = sin6_allrouters; - dst.sin6_scope_id = ifinfo->linkid; + dst.sin6_scope_id = ifi->linkid; sndmhdr.msg_name = (caddr_t)&dst; - sndmhdr.msg_iov[0].iov_base = (caddr_t)ifinfo->rs_data; - sndmhdr.msg_iov[0].iov_len = ifinfo->rs_datalen; + sndmhdr.msg_iov[0].iov_base = (caddr_t)ifi->rs_data; + sndmhdr.msg_iov[0].iov_len = ifi->rs_datalen; cm = CMSG_FIRSTHDR(&sndmhdr); /* specify the outgoing interface */ @@ -202,7 +201,7 @@ sendpacket(struct ifinfo *ifinfo) cm->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); pi = (struct in6_pktinfo *)CMSG_DATA(cm); memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/ - pi->ipi6_ifindex = ifinfo->sdl->sdl_index; + pi->ipi6_ifindex = ifi->sdl->sdl_index; /* specify the hop limit of the packet */ cm = CMSG_NXTHDR(&sndmhdr, cm); @@ -213,38 +212,50 @@ sendpacket(struct ifinfo *ifinfo) warnmsg(LOG_DEBUG, __func__, "send RS on %s, whose state is %d", - ifinfo->ifname, ifinfo->state); + ifi->ifname, ifi->state); i = sendmsg(rssock, &sndmhdr, 0); - if (i < 0 || (size_t)i != ifinfo->rs_datalen) { + if (i < 0 || (size_t)i != ifi->rs_datalen) { /* * ENETDOWN is not so serious, especially when using several * network cards on a mobile node. We ignore it. */ if (errno != ENETDOWN || dflag > 0) warnmsg(LOG_ERR, __func__, "sendmsg on %s: %s", - ifinfo->ifname, strerror(errno)); + ifi->ifname, strerror(errno)); } /* update counter */ - ifinfo->probes++; + ifi->probes++; } void rtsol_input(int s) { u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - int ifindex = 0, *hlimp = NULL; - ssize_t i; + int l, ifindex = 0, *hlimp = NULL; + ssize_t msglen; struct in6_pktinfo *pi = NULL; struct ifinfo *ifi = NULL; + struct ra_opt *rao = NULL; struct icmp6_hdr *icp; struct nd_router_advert *nd_ra; struct cmsghdr *cm; + char *raoptp; + char *p; + struct in6_addr *addr; + struct nd_opt_hdr *ndo; + struct nd_opt_rdnss *rdnss; + struct nd_opt_dnssl *dnssl; + size_t len; + char nsbuf[INET6_ADDRSTRLEN + 1 + IFNAMSIZ + 1]; + char dname[NI_MAXHOST]; + struct timeval now; + struct timeval lifetime; /* get message. namelen and controllen must always be initialized. */ rcvmhdr.msg_namelen = sizeof(from); rcvmhdr.msg_controllen = rcvcmsglen; - if ((i = recvmsg(s, &rcvmhdr, 0)) < 0) { + if ((msglen = recvmsg(s, &rcvmhdr, 0)) < 0) { warnmsg(LOG_ERR, __func__, "recvmsg: %s", strerror(errno)); return; } @@ -275,9 +286,9 @@ rtsol_input(int s) return; } - if ((size_t)i < sizeof(struct nd_router_advert)) { + if ((size_t)msglen < sizeof(struct nd_router_advert)) { warnmsg(LOG_INFO, __func__, - "packet size(%zd) is too short", i); + "packet size(%zd) is too short", msglen); return; } @@ -354,9 +365,157 @@ rtsol_input(int s) warnmsg(LOG_DEBUG, __func__, "OtherConfigFlag on %s is turned on", ifi->ifname); ifi->otherconfig = 1; - call_script(otherconf_script, ifi->ifname); + CALL_SCRIPT(OTHER, NULL); } + /* Initialize ra_opt per-interface structure. */ + gettimeofday(&now, NULL); + if (!TAILQ_EMPTY(&ifi->ifi_ra_opt)) + while ((rao = TAILQ_FIRST(&ifi->ifi_ra_opt)) != NULL) { + if (rao->rao_msg != NULL) + free(rao->rao_msg); + TAILQ_REMOVE(&ifi->ifi_ra_opt, rao, rao_next); + free(rao); + } + else + TAILQ_INIT(&ifi->ifi_ra_opt); + +#define RA_OPT_NEXT_HDR(x) (struct nd_opt_hdr *)((char *)x + \ + (((struct nd_opt_hdr *)x)->nd_opt_len * 8)) + + /* Process RA options. */ + warnmsg(LOG_DEBUG, __func__, "Processing RA"); + raoptp = (char *)icp + sizeof(struct nd_router_advert); + while (raoptp < (char *)icp + msglen) { + ndo = (struct nd_opt_hdr *)raoptp; + warnmsg(LOG_DEBUG, __func__, "ndo = %p", raoptp); + warnmsg(LOG_DEBUG, __func__, "ndo->nd_opt_type = %d", + ndo->nd_opt_type); + warnmsg(LOG_DEBUG, __func__, "ndo->nd_opt_len = %d", + ndo->nd_opt_len); + + switch (ndo->nd_opt_type) { + case ND_OPT_RDNSS: + rdnss = (struct nd_opt_rdnss *)raoptp; + + /* Optlen sanity check (Section 5.3.1 in RFC 6106) */ + if (rdnss->nd_opt_rdnss_len < 3) { + warnmsg(LOG_INFO, __func__, + "too short RDNSS option" + "in RA from %s was ignored.", + inet_ntop(AF_INET6, &from.sin6_addr, + ntopbuf, INET6_ADDRSTRLEN)); + break; + } + + addr = (struct in6_addr *)(raoptp + sizeof(*rdnss)); + while ((char *)addr < (char *)RA_OPT_NEXT_HDR(raoptp)) { + if (inet_ntop(AF_INET6, addr, ntopbuf, + INET6_ADDRSTRLEN) == NULL) { + warnmsg(LOG_INFO, __func__, + "an invalid address in RDNSS option" + " in RA from %s was ignored.", + inet_ntop(AF_INET6, &from.sin6_addr, + ntopbuf, INET6_ADDRSTRLEN)); + addr++; + continue; + } + if (IN6_IS_ADDR_LINKLOCAL(addr)) + /* XXX: % has to be escaped here */ + l = snprintf(nsbuf, sizeof(nsbuf), + "%s%c%s", ntopbuf, + SCOPE_DELIMITER, + ifi->ifname); + else + l = snprintf(nsbuf, sizeof(nsbuf), + "%s", ntopbuf); + if (l < 0 || (size_t)l >= sizeof(nsbuf)) { + warnmsg(LOG_ERR, __func__, + "address copying error in " + "RDNSS option: %d.", l); + addr++; + continue; + } + warnmsg(LOG_DEBUG, __func__, "nsbuf = %s", + nsbuf); + + ELM_MALLOC(rao, break); + rao->rao_type = ndo->nd_opt_type; + rao->rao_len = strlen(nsbuf); + rao->rao_msg = strdup(nsbuf); + if (rao->rao_msg == NULL) { + warnmsg(LOG_ERR, __func__, + "strdup failed: %s", + strerror(errno)); + free(rao); + addr++; + continue; + } + /* Set expiration timer */ + memset(&rao->rao_expire, 0, sizeof(rao->rao_expire)); + memset(&lifetime, 0, sizeof(lifetime)); + lifetime.tv_sec = ntohl(rdnss->nd_opt_rdnss_lifetime); + timeradd(&now, &lifetime, &rao->rao_expire); + + TAILQ_INSERT_TAIL(&ifi->ifi_ra_opt, rao, rao_next); + addr++; + } + break; + case ND_OPT_DNSSL: + dnssl = (struct nd_opt_dnssl *)raoptp; + + /* Optlen sanity check (Section 5.3.1 in RFC 6106) */ + if (dnssl->nd_opt_dnssl_len < 2) { + warnmsg(LOG_INFO, __func__, + "too short DNSSL option" + "in RA from %s was ignored.", + inet_ntop(AF_INET6, &from.sin6_addr, + ntopbuf, INET6_ADDRSTRLEN)); + break; + } + + /* + * Ensure NUL-termination in DNSSL in case of + * malformed field. + */ + p = (char *)RA_OPT_NEXT_HDR(raoptp); + *(p - 1) = '\0'; + + p = raoptp + sizeof(*dnssl); + while (1 < (len = dname_labeldec(dname, sizeof(dname), + p))) { + /* length == 1 means empty string */ + warnmsg(LOG_DEBUG, __func__, "dname = %s", + dname); + + ELM_MALLOC(rao, break); + rao->rao_type = ndo->nd_opt_type; + rao->rao_len = strlen(dname); + rao->rao_msg = strdup(dname); + if (rao->rao_msg == NULL) { + warnmsg(LOG_ERR, __func__, + "strdup failed: %s", + strerror(errno)); + free(rao); + break; + } + /* Set expiration timer */ + memset(&rao->rao_expire, 0, sizeof(rao->rao_expire)); + memset(&lifetime, 0, sizeof(lifetime)); + lifetime.tv_sec = ntohl(dnssl->nd_opt_dnssl_lifetime); + timeradd(&now, &lifetime, &rao->rao_expire); + + TAILQ_INSERT_TAIL(&ifi->ifi_ra_opt, rao, rao_next); + p += len; + } + break; + default: + /* nothing to do for other options */ + break; + } + raoptp = (char *)RA_OPT_NEXT_HDR(raoptp); + } + ra_opt_handler(ifi); ifi->racnt++; switch (ifi->state) { @@ -371,23 +530,166 @@ rtsol_input(int s) } } -static void -call_script(char *scriptpath, char *ifname) -{ - pid_t pid, wpid; +static char resstr_ns_prefix[] = "nameserver "; +static char resstr_sh_prefix[] = "search "; +static char resstr_nl[] = "\n"; +static char resstr_sp[] = " "; - if (scriptpath == NULL) +int +ra_opt_handler(struct ifinfo *ifi) +{ + struct ra_opt *rao; + struct script_msg *smp1, *smp2, *smp3; + struct timeval now; + TAILQ_HEAD(, script_msg) sm_rdnss_head = + TAILQ_HEAD_INITIALIZER(sm_rdnss_head); + TAILQ_HEAD(, script_msg) sm_dnssl_head = + TAILQ_HEAD_INITIALIZER(sm_dnssl_head); + int dcount, dlen; + + dcount = 0; + dlen = strlen(resstr_sh_prefix) + strlen(resstr_nl); + gettimeofday(&now, NULL); + TAILQ_FOREACH(rao, &ifi->ifi_ra_opt, rao_next) { + switch (rao->rao_type) { + case ND_OPT_RDNSS: + if (timercmp(&now, &rao->rao_expire, >)) { + warnmsg(LOG_INFO, __func__, + "expired rdnss entry: %s", + (char *)rao->rao_msg); + break; + } + ELM_MALLOC(smp1, continue); + ELM_MALLOC(smp2, goto free1); + ELM_MALLOC(smp3, goto free2); + smp1->sm_msg = resstr_ns_prefix; + TAILQ_INSERT_TAIL(&sm_rdnss_head, smp1, sm_next); + smp2->sm_msg = rao->rao_msg; + TAILQ_INSERT_TAIL(&sm_rdnss_head, smp2, sm_next); + smp3->sm_msg = resstr_nl; + TAILQ_INSERT_TAIL(&sm_rdnss_head, smp3, sm_next); + + break; + case ND_OPT_DNSSL: + if (timercmp(&now, &rao->rao_expire, >)) { + warnmsg(LOG_INFO, __func__, + "expired dnssl entry: %s", + (char *)rao->rao_msg); + break; + } + dcount++; + /* Check resolv.conf(5) restrictions. */ + if (dcount > 6) { + warnmsg(LOG_INFO, __func__, + "dnssl entry exceeding maximum count (%d>6)" + ": %s", dcount, (char *)rao->rao_msg); + break; + } + if (256 < dlen + strlen(rao->rao_msg) + + strlen(resstr_sp)) { + warnmsg(LOG_INFO, __func__, + "dnssl entry exceeding maximum length " + "(>256): %s", (char *)rao->rao_msg); + break; + } + ELM_MALLOC(smp1, continue); + ELM_MALLOC(smp2, goto free1); + if (TAILQ_EMPTY(&sm_dnssl_head)) { + ELM_MALLOC(smp3, goto free2); + smp3->sm_msg = resstr_sh_prefix; + TAILQ_INSERT_TAIL(&sm_dnssl_head, smp3, + sm_next); + } + smp1->sm_msg = rao->rao_msg; + TAILQ_INSERT_TAIL(&sm_dnssl_head, smp1, sm_next); + smp2->sm_msg = resstr_sp; + TAILQ_INSERT_TAIL(&sm_dnssl_head, smp2, sm_next); + dlen += strlen(rao->rao_msg) + strlen(resstr_sp); + break; + default: + break; + } + continue; +free2: + free(smp2); +free1: + free(smp1); + } + /* Add \n for DNSSL list. */ + if (!TAILQ_EMPTY(&sm_dnssl_head)) { + ELM_MALLOC(smp1, goto ra_opt_handler_freeit); + smp1->sm_msg = resstr_nl; + TAILQ_INSERT_TAIL(&sm_dnssl_head, smp1, sm_next); + } + TAILQ_CONCAT(&sm_rdnss_head, &sm_dnssl_head, sm_next); + + if (!TAILQ_EMPTY(&sm_rdnss_head)) + CALL_SCRIPT(RESADD, &sm_rdnss_head); + else + CALL_SCRIPT(RESDEL, NULL); + +ra_opt_handler_freeit: + /* Clear script message queue. */ + if (!TAILQ_EMPTY(&sm_rdnss_head)) { + while ((smp1 = TAILQ_FIRST(&sm_rdnss_head)) != NULL) { + TAILQ_REMOVE(&sm_rdnss_head, smp1, sm_next); + free(smp1); + } + } + return (0); +} + +static void +call_script(const int argc, const char *const argv[], void *head) +{ + const char *scriptpath; + int fd[2]; + int error; + pid_t pid, wpid; + TAILQ_HEAD(, script_msg) *sm_head; + + if ((scriptpath = argv[0]) == NULL) return; + fd[0] = fd[1] = -1; + sm_head = head; + if (sm_head != NULL && !TAILQ_EMPTY(sm_head)) { + error = pipe(fd); + if (error) { + warnmsg(LOG_ERR, __func__, + "failed to create a pipe: %s", strerror(errno)); + return; + } + } + /* launch the script */ pid = fork(); if (pid < 0) { warnmsg(LOG_ERR, __func__, "failed to fork: %s", strerror(errno)); return; - } else if (pid) { + } else if (pid) { /* parent */ int wstatus; + if (fd[0] != -1) { /* Send message to the child if any. */ + ssize_t len; + struct script_msg *smp; + + close(fd[0]); + TAILQ_FOREACH(smp, sm_head, sm_next) { + len = strlen(smp->sm_msg); + warnmsg(LOG_DEBUG, __func__, + "write to child = %s(%zd)", + smp->sm_msg, len); + if (write(fd[1], smp->sm_msg, len) != len) { + warnmsg(LOG_ERR, __func__, + "write to child failed: %s", + strerror(errno)); + break; + } + } + close(fd[1]); + } do { wpid = wait(&wstatus); } while (wpid != pid && wpid > 0); @@ -395,17 +697,12 @@ call_script(char *scriptpath, char *ifname) if (wpid < 0) warnmsg(LOG_ERR, __func__, "wait: %s", strerror(errno)); - else { + else warnmsg(LOG_DEBUG, __func__, "script \"%s\" terminated", scriptpath); - } - } else { - char *argv[3]; - int fd; - - argv[0] = scriptpath; - argv[1] = ifname; - argv[2] = NULL; + } else { /* child */ + int nullfd; + char **_argv; if (safefile(scriptpath)) { warnmsg(LOG_ERR, __func__, @@ -413,20 +710,42 @@ call_script(char *scriptpath, char *ifname) scriptpath); exit(1); } - - if ((fd = open("/dev/null", O_RDWR)) != -1) { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - if (fd > STDERR_FILENO) - close(fd); + nullfd = open("/dev/null", O_RDWR); + if (nullfd < 0) { + warnmsg(LOG_ERR, __func__, + "open /dev/null: %s", strerror(errno)); + exit(1); } + if (fd[0] != -1) { /* Receive message from STDIN if any. */ + close(fd[1]); + if (fd[0] != STDIN_FILENO) { + /* Connect a pipe read-end to child's STDIN. */ + if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO) { + warnmsg(LOG_ERR, __func__, + "dup2 STDIN: %s", strerror(errno)); + exit(1); + } + close(fd[0]); + } + } else + dup2(nullfd, STDIN_FILENO); + + dup2(nullfd, STDOUT_FILENO); + dup2(nullfd, STDERR_FILENO); + if (nullfd > STDERR_FILENO) + close(nullfd); - execv(scriptpath, argv); - + _argv = malloc(sizeof(*_argv) * argc); + if (_argv == NULL) { + warnmsg(LOG_ERR, __func__, + "malloc: %s", strerror(errno)); + exit(1); + } + memcpy(_argv, argv, (size_t)argc); + execv(scriptpath, (char *const *)_argv); warnmsg(LOG_ERR, __func__, "child: exec failed: %s", strerror(errno)); - exit(0); + exit(1); } return; @@ -471,3 +790,37 @@ safefile(const char *path) return (0); } + +/* Decode domain name label encoding in RFC 1035 Section 3.1 */ +static size_t +dname_labeldec(char *dst, size_t dlen, const char *src) +{ + size_t len; + const char *src_origin; + const char *src_last; + const char *dst_origin; + + src_origin = src; + src_last = strchr(src, '\0'); + dst_origin = dst; + memset(dst, '\0', dlen); + while (src && (len = (uint8_t)(*src++) & 0x3f) && + (src + len) <= src_last) { + if (dst != dst_origin) + *dst++ = '.'; + warnmsg(LOG_DEBUG, __func__, "labellen = %zd", len); + memcpy(dst, src, len); + src += len; + dst += len; + } + *dst = '\0'; + + /* + * XXX validate that domain name only contains valid characters + * for two reasons: 1) correctness, 2) we do not want to pass + * possible malicious, unescaped characters like `` to a script + * or program that could be exploited that way. + */ + + return (src - src_origin); +} diff --git a/usr.sbin/rtsold/rtsold.8 b/usr.sbin/rtsold/rtsold.8 index 9ce0bb07d5df..8eb253902994 100644 --- a/usr.sbin/rtsold/rtsold.8 +++ b/usr.sbin/rtsold/rtsold.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 2, 2009 +.Dd May 28, 2011 .Dt RTSOLD 8 .Os .\" @@ -41,18 +41,24 @@ .Nm .Op Fl dDfFm1 .Op Fl O Ar script-name +.Op Fl P Ar pidfile +.Op Fl R Ar script-name .Ar interface ... .Nm .Op Fl dDfFm1 .Op Fl O Ar script-name +.Op Fl P Ar pidfile +.Op Fl R Ar script-name .Fl a .Nm rtsol -.Op Fl dDF +.Op Fl dD .Op Fl O Ar script-name +.Op Fl R Ar script-name .Ar interface ... .Nm rtsol .Op Fl dD .Op Fl O Ar script-name +.Op Fl R Ar script-name .Fl a .\" .Sh DESCRIPTION @@ -221,6 +227,24 @@ configuration. must be the absolute path from root to the script file, be a regular file, and be created by the same owner who runs .Nm . +.It Fl P Ar pidfile +Writes the process ID of +.Nm +to +.Pa pidfile +instead of the default PID file +.Pa /var/run/rtsold.pid . +.It Fl R Ar script-name +Specifies a script to run when router advertisment options +.Dv RDNSS Pq Recursive DNS Server +or +.Dv DNSSL Pq DNS Search List +are encountered. +The information of DNS servers and DNS search domains will be sent to +standard input of this script. +The +.Xr resolvconf 8 +script is used by default. .El .Sh FILES .Bl -tag -width /var/run/rtsold.dump -compact @@ -235,6 +259,7 @@ dumps internal state on. .Ex -std .\" .Sh SEE ALSO +.Xr resolvconf 8 , .Xr rtadvd 8 , .Xr sysctl 8 .\" diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 0db050cc0e98..a8b7ca727cfd 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -63,6 +63,9 @@ #include "rtsold.h" +#define RTSOL_DUMPFILE "/var/run/rtsold.dump"; +#define RTSOL_PIDFILE "/var/run/rtsold.pid"; + struct ifinfo *iflist; struct timeval tm_max = {0x7fffffff, 0x7fffffff}; static int log_upto = 999; @@ -72,7 +75,8 @@ int Fflag = 0; /* force setting sysctl parameters */ int aflag = 0; int dflag = 0; -char *otherconf_script; +const char *otherconf_script; +const char *resolvconf_script = "/sbin/resolvconf"; /* protocol constants */ #define MAX_RTR_SOLICITATION_DELAY 1 /* second */ @@ -85,35 +89,32 @@ char *otherconf_script; */ #define PROBE_INTERVAL 60 -int main(int, char **); - /* static variables and functions */ static int mobile_node = 0; +static const char *pidfilename = RTSOL_PIDFILE; + #ifndef SMALL static int do_dump; -static const char *dumpfilename = "/var/run/rtsold.dump"; /* XXX: should be configurable */ -#endif -#if 1 -static const char *pidfilename = "/var/run/rtsold.pid"; /* should be configurable */ +static const char *dumpfilename = RTSOL_DUMPFILE; #endif #if 0 static int ifreconfig(char *); #endif + static int make_packet(struct ifinfo *); static struct timeval *rtsol_check_timer(void); #ifndef SMALL static void rtsold_set_dump_file(int); #endif -static void usage(char *); +static void usage(void); int main(int argc, char **argv) { int s, ch, once = 0; struct timeval *timeout; - char *argv0; const char *opts; #ifdef HAVE_POLL_H struct pollfd set[2]; @@ -124,19 +125,15 @@ main(int argc, char **argv) #endif int rtsock; - /* - * Initialization - */ - argv0 = argv[0]; - - /* get option */ - if (argv0 && argv0[strlen(argv0) - 1] != 'd') { - fflag = 1; - once = 1; - opts = "adDFO:"; - } else - opts = "adDfFm1O:"; - +#ifndef SMALL + /* rtsold */ + opts = "adDfFm1O:P:R:"; +#else + /* rtsol */ + opts = "adDFO:P:R:"; + fflag = 1; + once = 1; +#endif while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { case 'a': @@ -163,17 +160,23 @@ main(int argc, char **argv) case 'O': otherconf_script = optarg; break; + case 'P': + pidfilename = optarg; + break; + case 'R': + resolvconf_script = optarg; + break; default: - usage(argv0); - /*NOTREACHED*/ + usage(); + exit(1); } } argc -= optind; argv += optind; if ((!aflag && argc == 0) || (aflag && argc != 0)) { - usage(argv0); - /*NOTREACHED*/ + usage(); + exit(1); } /* set log level */ @@ -182,9 +185,9 @@ main(int argc, char **argv) if (!fflag) { char *ident; - ident = strrchr(argv0, '/'); + ident = strrchr(argv[0], '/'); if (!ident) - ident = argv0; + ident = argv[0]; else ident++; openlog(ident, LOG_NDELAY|LOG_PID, LOG_DAEMON); @@ -196,7 +199,14 @@ main(int argc, char **argv) errx(1, "configuration script (%s) must be an absolute path", otherconf_script); } - + if (resolvconf_script && *resolvconf_script != '/') { + errx(1, "configuration script (%s) must be an absolute path", + resolvconf_script); + } + if (pidfilename && *pidfilename != '/') { + errx(1, "pid filename (%s) must be an absolute path", + pidfilename); + } #ifndef HAVE_ARC4RANDOM /* random value initialization */ srandom((u_long)time(NULL)); @@ -226,7 +236,6 @@ main(int argc, char **argv) if ((s = sockopen()) < 0) { warnmsg(LOG_ERR, __func__, "failed to open a socket"); exit(1); - /*NOTREACHED*/ } #ifdef HAVE_POLL_H set[0].fd = s; @@ -242,7 +251,6 @@ main(int argc, char **argv) if ((rtsock = rtsock_open()) < 0) { warnmsg(LOG_ERR, __func__, "failed to open a socket"); exit(1); - /*NOTREACHED*/ } #ifdef HAVE_POLL_H set[1].fd = rtsock; @@ -255,12 +263,12 @@ main(int argc, char **argv) #ifndef HAVE_POLL_H fdmasks = howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask); if ((fdsetp = malloc(fdmasks)) == NULL) { - err(1, "malloc"); - /*NOTREACHED*/ + warnmsg(LOG_ERR, __func__, "malloc"); + exit(1); } if ((selectfdp = malloc(fdmasks)) == NULL) { - err(1, "malloc"); - /*NOTREACHED*/ + warnmsg(LOG_ERR, __func__, "malloc"); + exit(1); } #endif @@ -269,7 +277,6 @@ main(int argc, char **argv) warnmsg(LOG_ERR, __func__, "failed to initialize interfaces"); exit(1); - /*NOTREACHED*/ } if (aflag) argv = autoifprobe(); @@ -278,7 +285,6 @@ main(int argc, char **argv) warnmsg(LOG_ERR, __func__, "failed to initialize %s", *argv); exit(1); - /*NOTREACHED*/ } argv++; } @@ -291,7 +297,6 @@ main(int argc, char **argv) /*NOTREACHED*/ } -#if 1 /* dump the current pid */ if (!once) { pid_t pid = getpid(); @@ -306,8 +311,6 @@ main(int argc, char **argv) fclose(fp); } } -#endif - #ifndef HAVE_POLL_H memset(fdsetp, 0, fdmasks); FD_SET(s, fdsetp); @@ -337,7 +340,7 @@ main(int argc, char **argv) break; /* if all interfaces have got RA packet, we are done */ - for (ifi = iflist; ifi; ifi = ifi->next) { + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { if (ifi->state != IFS_DOWN && ifi->racnt == 0) break; } @@ -373,102 +376,97 @@ main(int argc, char **argv) } /* NOTREACHED */ - return 0; + return (0); } int ifconfig(char *ifname) { - struct ifinfo *ifinfo; + struct ifinfo *ifi; struct sockaddr_dl *sdl; int flags; if ((sdl = if_nametosdl(ifname)) == NULL) { warnmsg(LOG_ERR, __func__, "failed to get link layer information for %s", ifname); - return(-1); + return (-1); } if (find_ifinfo(sdl->sdl_index)) { warnmsg(LOG_ERR, __func__, "interface %s was already configured", ifname); free(sdl); - return(-1); + return (-1); } - if ((ifinfo = malloc(sizeof(*ifinfo))) == NULL) { + if ((ifi = malloc(sizeof(*ifi))) == NULL) { warnmsg(LOG_ERR, __func__, "memory allocation failed"); free(sdl); - return(-1); + return (-1); } - memset(ifinfo, 0, sizeof(*ifinfo)); - ifinfo->sdl = sdl; + memset(ifi, 0, sizeof(*ifi)); + ifi->sdl = sdl; - strlcpy(ifinfo->ifname, ifname, sizeof(ifinfo->ifname)); + strlcpy(ifi->ifname, ifname, sizeof(ifi->ifname)); /* construct a router solicitation message */ - if (make_packet(ifinfo)) + if (make_packet(ifi)) goto bad; /* set link ID of this interface. */ #ifdef HAVE_SCOPELIB - if (inet_zoneid(AF_INET6, 2, ifname, &ifinfo->linkid)) + if (inet_zoneid(AF_INET6, 2, ifname, &ifi->linkid)) goto bad; #else /* XXX: assume interface IDs as link IDs */ - ifinfo->linkid = ifinfo->sdl->sdl_index; + ifi->linkid = ifi->sdl->sdl_index; #endif /* * check if the interface is available. * also check if SIOCGIFMEDIA ioctl is OK on the interface. */ - ifinfo->mediareqok = 1; - ifinfo->active = interface_status(ifinfo); - if (!ifinfo->mediareqok) { + ifi->mediareqok = 1; + ifi->active = interface_status(ifi); + if (!ifi->mediareqok) { /* * probe routers periodically even if the link status * does not change. */ - ifinfo->probeinterval = PROBE_INTERVAL; + ifi->probeinterval = PROBE_INTERVAL; } /* activate interface: interface_up returns 0 on success */ - flags = interface_up(ifinfo->ifname); + flags = interface_up(ifi->ifname); if (flags == 0) - ifinfo->state = IFS_DELAY; + ifi->state = IFS_DELAY; else if (flags == IFS_TENTATIVE) - ifinfo->state = IFS_TENTATIVE; + ifi->state = IFS_TENTATIVE; else - ifinfo->state = IFS_DOWN; + ifi->state = IFS_DOWN; - rtsol_timer_update(ifinfo); + rtsol_timer_update(ifi); - /* link into chain */ - if (iflist) - ifinfo->next = iflist; - iflist = ifinfo; - - return(0); + TAILQ_INSERT_TAIL(&ifinfo_head, ifi, ifi_next); + return (0); bad: - free(ifinfo->sdl); - free(ifinfo); - return(-1); + free(ifi->sdl); + free(ifi); + return (-1); } void iflist_init(void) { - struct ifinfo *ifi, *next; + struct ifinfo *ifi; - for (ifi = iflist; ifi; ifi = next) { - next = ifi->next; - if (ifi->sdl) + while ((ifi = TAILQ_FIRST(&ifinfo_head)) != NULL) { + TAILQ_REMOVE(&ifinfo_head, ifi, ifi_next); + if (ifi->sdl != NULL) free(ifi->sdl); - if (ifi->rs_data) + if (ifi->rs_data != NULL) free(ifi->rs_data); free(ifi); - iflist = NULL; } } @@ -480,7 +478,7 @@ ifreconfig(char *ifname) int rv; prev = NULL; - for (ifi = iflist; ifi; ifi = ifi->next) { + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { if (strncmp(ifi->ifname, ifname, sizeof(ifi->ifname)) == 0) break; prev = ifi; @@ -494,7 +492,8 @@ ifreconfig(char *ifname) free(ifi->rs_data); free(ifi->sdl); free(ifi); - return rv; + + return (rv); } #endif @@ -503,34 +502,35 @@ find_ifinfo(int ifindex) { struct ifinfo *ifi; - for (ifi = iflist; ifi; ifi = ifi->next) + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { if (ifi->sdl->sdl_index == ifindex) - return(ifi); - return(NULL); + return (ifi); + } + return (NULL); } static int -make_packet(struct ifinfo *ifinfo) +make_packet(struct ifinfo *ifi) { size_t packlen = sizeof(struct nd_router_solicit), lladdroptlen = 0; struct nd_router_solicit *rs; char *buf; - if ((lladdroptlen = lladdropt_length(ifinfo->sdl)) == 0) { + if ((lladdroptlen = lladdropt_length(ifi->sdl)) == 0) { warnmsg(LOG_INFO, __func__, "link-layer address option has null length" - " on %s. Treat as not included.", ifinfo->ifname); + " on %s. Treat as not included.", ifi->ifname); } packlen += lladdroptlen; - ifinfo->rs_datalen = packlen; + ifi->rs_datalen = packlen; /* allocate buffer */ if ((buf = malloc(packlen)) == NULL) { warnmsg(LOG_ERR, __func__, - "memory allocation failed for %s", ifinfo->ifname); - return(-1); + "memory allocation failed for %s", ifi->ifname); + return (-1); } - ifinfo->rs_data = buf; + ifi->rs_data = buf; /* fill in the message */ rs = (struct nd_router_solicit *)buf; @@ -542,9 +542,9 @@ make_packet(struct ifinfo *ifinfo) /* fill in source link-layer address option */ if (lladdroptlen) - lladdropt_fill(ifinfo->sdl, (struct nd_opt_hdr *)buf); + lladdropt_fill(ifi->sdl, (struct nd_opt_hdr *)buf); - return(0); + return (0); } static struct timeval * @@ -552,56 +552,64 @@ rtsol_check_timer(void) { static struct timeval returnval; struct timeval now, rtsol_timer; - struct ifinfo *ifinfo; + struct ifinfo *ifi; + struct ra_opt *rao; int flags; gettimeofday(&now, NULL); rtsol_timer = tm_max; - for (ifinfo = iflist; ifinfo; ifinfo = ifinfo->next) { - if (timercmp(&ifinfo->expire, &now, <=)) { + TAILQ_FOREACH(ifi, &ifinfo_head, ifi_next) { + if (timercmp(&ifi->expire, &now, <=)) { if (dflag > 1) warnmsg(LOG_DEBUG, __func__, "timer expiration on %s, " - "state = %d", ifinfo->ifname, - ifinfo->state); + "state = %d", ifi->ifname, + ifi->state); - switch (ifinfo->state) { + /* Remove all RA options. */ + while ((rao = TAILQ_FIRST(&ifi->ifi_ra_opt)) != NULL) { + if (rao->rao_msg != NULL) + free(rao->rao_msg); + TAILQ_REMOVE(&ifi->ifi_ra_opt, rao, rao_next); + free(rao); + } + switch (ifi->state) { case IFS_DOWN: case IFS_TENTATIVE: /* interface_up returns 0 on success */ - flags = interface_up(ifinfo->ifname); + flags = interface_up(ifi->ifname); if (flags == 0) - ifinfo->state = IFS_DELAY; + ifi->state = IFS_DELAY; else if (flags == IFS_TENTATIVE) - ifinfo->state = IFS_TENTATIVE; + ifi->state = IFS_TENTATIVE; else - ifinfo->state = IFS_DOWN; + ifi->state = IFS_DOWN; break; case IFS_IDLE: { - int oldstatus = ifinfo->active; + int oldstatus = ifi->active; int probe = 0; - ifinfo->active = interface_status(ifinfo); + ifi->active = interface_status(ifi); - if (oldstatus != ifinfo->active) { + if (oldstatus != ifi->active) { warnmsg(LOG_DEBUG, __func__, "%s status is changed" " from %d to %d", - ifinfo->ifname, - oldstatus, ifinfo->active); + ifi->ifname, + oldstatus, ifi->active); probe = 1; - ifinfo->state = IFS_DELAY; - } else if (ifinfo->probeinterval && - (ifinfo->probetimer -= - ifinfo->timer.tv_sec) <= 0) { + ifi->state = IFS_DELAY; + } else if (ifi->probeinterval && + (ifi->probetimer -= + ifi->timer.tv_sec) <= 0) { /* probe timer expired */ - ifinfo->probetimer = - ifinfo->probeinterval; + ifi->probetimer = + ifi->probeinterval; probe = 1; - ifinfo->state = IFS_PROBE; + ifi->state = IFS_PROBE; } /* @@ -609,38 +617,58 @@ rtsol_check_timer(void) * status wrt the "other" configuration. */ if (probe) - ifinfo->otherconfig = 0; + ifi->otherconfig = 0; if (probe && mobile_node) - defrouter_probe(ifinfo); + defrouter_probe(ifi); break; } case IFS_DELAY: - ifinfo->state = IFS_PROBE; - sendpacket(ifinfo); + ifi->state = IFS_PROBE; + sendpacket(ifi); break; case IFS_PROBE: - if (ifinfo->probes < MAX_RTR_SOLICITATIONS) - sendpacket(ifinfo); + if (ifi->probes < MAX_RTR_SOLICITATIONS) + sendpacket(ifi); else { warnmsg(LOG_INFO, __func__, "No answer after sending %d RSs", - ifinfo->probes); - ifinfo->probes = 0; - ifinfo->state = IFS_IDLE; + ifi->probes); + ifi->probes = 0; + ifi->state = IFS_IDLE; } break; } - rtsol_timer_update(ifinfo); - } + rtsol_timer_update(ifi); + } else { + /* Expiration check for RA options. */ + struct ra_opt *rao_tmp; + int expire = 0; - if (timercmp(&ifinfo->expire, &rtsol_timer, <)) - rtsol_timer = ifinfo->expire; + TAILQ_FOREACH_SAFE(rao, &ifi->ifi_ra_opt, rao_next, rao_tmp) { + warnmsg(LOG_DEBUG, __func__, + "RA expiration timer: " + "type=%d, msg=%s, timer=%ld:%08ld", + rao->rao_type, (char *)rao->rao_msg, + (long)rao->rao_expire.tv_sec, + (long)rao->rao_expire.tv_usec); + if (timercmp(&now, &rao->rao_expire, >=)) { + warnmsg(LOG_DEBUG, __func__, + "RA expiration timer: expired."); + TAILQ_REMOVE(&ifi->ifi_ra_opt, rao, rao_next); + expire = 1; + } + } + if (expire) + ra_opt_handler(ifi); + } + if (timercmp(&ifi->expire, &rtsol_timer, <)) + rtsol_timer = ifi->expire; } if (timercmp(&rtsol_timer, &tm_max, ==)) { warnmsg(LOG_DEBUG, __func__, "there is no timer"); - return(NULL); + return (NULL); } else if (timercmp(&rtsol_timer, &now, <)) /* this may occur when the interval is too small */ returnval.tv_sec = returnval.tv_usec = 0; @@ -651,35 +679,35 @@ rtsol_check_timer(void) warnmsg(LOG_DEBUG, __func__, "New timer is %ld:%08ld", (long)returnval.tv_sec, (long)returnval.tv_usec); - return(&returnval); + return (&returnval); } void -rtsol_timer_update(struct ifinfo *ifinfo) +rtsol_timer_update(struct ifinfo *ifi) { #define MILLION 1000000 #define DADRETRY 10 /* XXX: adhoc */ long interval; struct timeval now; - bzero(&ifinfo->timer, sizeof(ifinfo->timer)); + bzero(&ifi->timer, sizeof(ifi->timer)); - switch (ifinfo->state) { + switch (ifi->state) { case IFS_DOWN: case IFS_TENTATIVE: - if (++ifinfo->dadcount > DADRETRY) { - ifinfo->dadcount = 0; - ifinfo->timer.tv_sec = PROBE_INTERVAL; + if (++ifi->dadcount > DADRETRY) { + ifi->dadcount = 0; + ifi->timer.tv_sec = PROBE_INTERVAL; } else - ifinfo->timer.tv_sec = 1; + ifi->timer.tv_sec = 1; break; case IFS_IDLE: if (mobile_node) { /* XXX should be configurable */ - ifinfo->timer.tv_sec = 3; + ifi->timer.tv_sec = 3; } else - ifinfo->timer = tm_max; /* stop timer(valid?) */ + ifi->timer = tm_max; /* stop timer(valid?) */ break; case IFS_DELAY: #ifndef HAVE_ARC4RANDOM @@ -687,12 +715,12 @@ rtsol_timer_update(struct ifinfo *ifinfo) #else interval = arc4random_uniform(MAX_RTR_SOLICITATION_DELAY * MILLION); #endif - ifinfo->timer.tv_sec = interval / MILLION; - ifinfo->timer.tv_usec = interval % MILLION; + ifi->timer.tv_sec = interval / MILLION; + ifi->timer.tv_usec = interval % MILLION; break; case IFS_PROBE: - if (ifinfo->probes < MAX_RTR_SOLICITATIONS) - ifinfo->timer.tv_sec = RTR_SOLICITATION_INTERVAL; + if (ifi->probes < MAX_RTR_SOLICITATIONS) + ifi->timer.tv_sec = RTR_SOLICITATION_INTERVAL; else { /* * After sending MAX_RTR_SOLICITATIONS solicitations, @@ -701,30 +729,30 @@ rtsol_timer_update(struct ifinfo *ifinfo) * the timer value to MAX_RTR_SOLICITATION_DELAY based * on RFC 2461, Section 6.3.7. */ - ifinfo->timer.tv_sec = MAX_RTR_SOLICITATION_DELAY; + ifi->timer.tv_sec = MAX_RTR_SOLICITATION_DELAY; } break; default: warnmsg(LOG_ERR, __func__, "illegal interface state(%d) on %s", - ifinfo->state, ifinfo->ifname); + ifi->state, ifi->ifname); return; } /* reset the timer */ - if (timercmp(&ifinfo->timer, &tm_max, ==)) { - ifinfo->expire = tm_max; + if (timercmp(&ifi->timer, &tm_max, ==)) { + ifi->expire = tm_max; warnmsg(LOG_DEBUG, __func__, - "stop timer for %s", ifinfo->ifname); + "stop timer for %s", ifi->ifname); } else { gettimeofday(&now, NULL); - timeradd(&now, &ifinfo->timer, &ifinfo->expire); + timeradd(&now, &ifi->timer, &ifi->expire); if (dflag > 1) warnmsg(LOG_DEBUG, __func__, - "set timer for %s to %d:%d", ifinfo->ifname, - (int)ifinfo->timer.tv_sec, - (int)ifinfo->timer.tv_usec); + "set timer for %s to %d:%d", ifi->ifname, + (int)ifi->timer.tv_sec, + (int)ifi->timer.tv_usec); } #undef MILLION @@ -742,28 +770,23 @@ rtsold_set_dump_file(int sig __unused) #endif static void -usage(char *progname) +usage(void) { - if (progname && progname[strlen(progname) - 1] != 'd') { - fprintf(stderr, "usage: rtsol [-dDF] interfaces...\n"); - fprintf(stderr, "usage: rtsol [-dDF] -a\n"); - } else { - fprintf(stderr, "usage: rtsold [-adDfFm1] interfaces...\n"); - fprintf(stderr, "usage: rtsold [-dDfFm1] -a\n"); - } - exit(1); +#ifndef SMALL + fprintf(stderr, "usage: rtsold [-adDfFm1] [-O script-name] " + "[-P pidfile] [-R script-name] interfaces...\n"); + fprintf(stderr, "usage: rtsold [-dDfFm1] [-O script-name] " + "[-P pidfile] [-R script-name] -a\n"); +#else + fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] " + "[-P pidfile] [-R script-name] interfaces...\n"); + fprintf(stderr, "usage: rtsol [-dDF] [-O script-name] " + "[-P pidfile] [-R script-name] -a\n"); +#endif } void -#if __STDC__ warnmsg(int priority, const char *func, const char *msg, ...) -#else -warnmsg(priority, func, msg, va_alist) - int priority; - const char *func; - const char *msg; - va_dcl -#endif { va_list ap; char buf[BUFSIZ]; @@ -805,11 +828,11 @@ autoifprobe(void) n = 0; if (getifaddrs(&ifap) != 0) - return NULL; + return (NULL); if (!Fflag && (s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { - err(1, "socket"); - /* NOTREACHED */ + warnmsg(LOG_ERR, __func__, "socket"); + exit(1); } target = NULL; @@ -845,8 +868,9 @@ autoifprobe(void) memset(&nd, 0, sizeof(nd)); strlcpy(nd.ifname, ifa->ifa_name, sizeof(nd.ifname)); if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { - err(1, "ioctl(SIOCGIFINFO_IN6)"); - /* NOTREACHED */ + warnmsg(LOG_ERR, __func__, + "ioctl(SIOCGIFINFO_IN6)"); + exit(1); } if ((nd.ndi.flags & ND6_IFF_IFDISABLED)) continue; @@ -856,32 +880,40 @@ autoifprobe(void) /* if we find multiple candidates, just warn. */ if (n != 0 && dflag > 1) - warnx("multiple interfaces found"); + warnmsg(LOG_WARNING, __func__, + "multiple interfaces found"); a = (char **)realloc(argv, (n + 1) * sizeof(char **)); - if (a == NULL) - err(1, "realloc"); + if (a == NULL) { + warnmsg(LOG_ERR, __func__, "realloc"); + exit(1); + } argv = a; argv[n] = strdup(ifa->ifa_name); - if (!argv[n]) - err(1, "malloc"); + if (!argv[n]) { + warnmsg(LOG_ERR, __func__, "malloc"); + exit(1); + } n++; } if (n) { a = (char **)realloc(argv, (n + 1) * sizeof(char **)); - if (a == NULL) - err(1, "realloc"); + if (a == NULL) { + warnmsg(LOG_ERR, __func__, "realloc"); + exit(1); + } argv = a; argv[n] = NULL; if (dflag > 0) { for (i = 0; i < n; i++) - warnx("probing %s", argv[i]); + warnmsg(LOG_WARNING, __func__, "probing %s", + argv[i]); } } if (!Fflag) close(s); freeifaddrs(ifap); - return argv; + return (argv); } diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h index 8aef4902a1f1..1c395d091088 100644 --- a/usr.sbin/rtsold/rtsold.h +++ b/usr.sbin/rtsold/rtsold.h @@ -31,8 +31,23 @@ * $FreeBSD$ */ +struct script_msg { + TAILQ_ENTRY(script_msg) sm_next; + + char *sm_msg; +}; + +struct ra_opt { + TAILQ_ENTRY(ra_opt) rao_next; + + u_int8_t rao_type; + struct timeval rao_expire; + size_t rao_len; + void *rao_msg; +}; + struct ifinfo { - struct ifinfo *next; /* pointer to the next interface */ + TAILQ_ENTRY(ifinfo) ifi_next; /* pointer to the next interface */ struct sockaddr_dl *sdl; /* link-layer address */ char ifname[IF_NAMESIZE]; /* interface name */ @@ -54,6 +69,8 @@ struct ifinfo { size_t rs_datalen; u_char *rs_data; + + TAILQ_HEAD(, ra_opt) ifi_ra_opt; }; /* per interface status */ @@ -63,12 +80,41 @@ struct ifinfo { #define IFS_DOWN 3 #define IFS_TENTATIVE 4 +/* Interface list */ +extern TAILQ_HEAD(ifinfo_head_t, ifinfo) ifinfo_head; + +/* + * RFC 3542 API deprecates IPV6_PKTINFO in favor of + * IPV6_RECVPKTINFO + */ +#ifndef IPV6_RECVPKTINFO +#ifdef IPV6_PKTINFO +#define IPV6_RECVPKTINFO IPV6_PKTINFO +#endif +#endif +/* + * RFC 3542 API deprecates IPV6_HOPLIMIT in favor of + * IPV6_RECVHOPLIMIT + */ +#ifndef IPV6_RECVHOPLIMIT +#ifdef IPV6_HOPLIMIT +#define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT +#endif +#endif + +#ifndef IN6ADDR_LINKLOCAL_ALLROUTERS_INIT +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} +#endif + /* rtsold.c */ extern struct timeval tm_max; extern int dflag; extern int aflag; extern int Fflag; -extern char *otherconf_script; +extern const char *otherconf_script; +extern const char *resolvconf_script; extern int ifconfig(char *); extern void iflist_init(void); struct ifinfo *find_ifinfo(int); @@ -76,6 +122,7 @@ void rtsol_timer_update(struct ifinfo *); extern void warnmsg(int, const char *, const char *, ...) __attribute__((__format__(__printf__, 3, 4))); extern char **autoifprobe(void); +extern int ra_opt_handler(struct ifinfo *); /* if.c */ extern int ifinit(void); From 9c9abb47360b4acc3f7c54ac33eef70f41c40e87 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 03:37:33 +0000 Subject: [PATCH 093/164] Remove "ifconfig IF inet6 -accept_rtadv" when ipv6_gateway_enable=YES because this is no longer needed. --- etc/network.subr | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/etc/network.subr b/etc/network.subr index 64fb0fe65bee..a5bdd67982a5 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -100,25 +100,19 @@ ifconfig_up() # inet6 specific if afexists inet6; then - if ipv6if $1; then - if checkyesno ipv6_gateway_enable; then - _ipv6_opts="-accept_rtadv" - fi + if checkyesno ipv6_activate_all_interfaces; then + _ipv6_opts="-ifdisabled" else - if checkyesno ipv6_activate_all_interfaces; then - _ipv6_opts="-ifdisabled" - else - _ipv6_opts="ifdisabled" - fi - - # backward compatibility: $ipv6_enable - case $ipv6_enable in - [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) - _ipv6_opts="${_ipv6_opts} accept_rtadv" - ;; - esac + _ipv6_opts="ifdisabled" fi + # backward compatibility: $ipv6_enable + case $ipv6_enable in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + _ipv6_opts="${_ipv6_opts} accept_rtadv" + ;; + esac + if [ -n "${_ipv6_opts}" ]; then ifconfig $1 inet6 ${_ipv6_opts} fi From 0ae2d5f6c6887d49bd007ffeefd37ad2299dba74 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 04:12:57 +0000 Subject: [PATCH 094/164] Do not activate automatic LL addr configuration when 0/1->1 transition of ND6_IFF_IFDISABLED flag. --- sys/netinet6/nd6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 231ce94ecbe3..2b51e4379b3b 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1327,6 +1327,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) * accept_rtadv or auto_linklocal. */ if ((ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && + !(ND.flags & ND6_IFF_IFDISABLED) && (ND.flags & (ND6_IFF_ACCEPT_RTADV | ND6_IFF_AUTO_LINKLOCAL))) ND.flags &= ~ND6_IFF_IFDISABLED; @@ -1388,7 +1389,8 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) /* If no link-local address on ifp, configure */ ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL; in6_ifattach(ifp, NULL); - } else if (ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) { + } else if ((ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) && + !(ND.flags & ND6_IFF_IFDISABLED)) { /* * When the IF already has * ND6_IFF_AUTO_LINKLOCAL and no link-local From 0038c5efc1cb0746195e0b3b4797f4cacb18db7e Mon Sep 17 00:00:00 2001 From: ae Date: Mon, 6 Jun 2011 10:39:38 +0000 Subject: [PATCH 095/164] Do not return EINVAL when user does `ipfw set N flush` on an empty set. MFC after: 2 weeks --- sys/netinet/ipfw/ip_fw_sockopt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/netinet/ipfw/ip_fw_sockopt.c b/sys/netinet/ipfw/ip_fw_sockopt.c index f81d57d52869..2347456a8c22 100644 --- a/sys/netinet/ipfw/ip_fw_sockopt.c +++ b/sys/netinet/ipfw/ip_fw_sockopt.c @@ -349,12 +349,13 @@ del_entry(struct ip_fw_chain *chain, uint32_t arg) } if (n == 0) { - /* A flush request (arg == 0) on empty ruleset - * returns with no error. On the contrary, + /* A flush request (arg == 0 or cmd == 1) on empty + * ruleset returns with no error. On the contrary, * if there is no match on a specific request, * we return EINVAL. */ - error = (arg == 0) ? 0 : EINVAL; + if (arg != 0 && cmd != 1) + error = EINVAL; break; } From 5eef59f051bb91af438e00594d53a03903eaa8b4 Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 10:51:00 +0000 Subject: [PATCH 096/164] Fix build on 64-bit arch. Submitted by: dim Pointy hat to: hrs --- usr.sbin/rtadvd/config.c | 2 +- usr.sbin/rtadvd/dump.c | 2 +- usr.sbin/rtadvd/rtadvd.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c index 4c870b9f0596..ff5d90f7a01b 100644 --- a/usr.sbin/rtadvd/config.c +++ b/usr.sbin/rtadvd/config.c @@ -109,7 +109,7 @@ dname_labelenc(char *dst, const char *src) /* Always need a 0-length label at the tail. */ *dst++ = '\0'; - syslog(LOG_DEBUG, "<%s> labellen = %d", __func__, dst - dst_origin); + syslog(LOG_DEBUG, "<%s> labellen = %td", __func__, dst - dst_origin); return (dst - dst_origin); } diff --git a/usr.sbin/rtadvd/dump.c b/usr.sbin/rtadvd/dump.c index f79319bd3e36..fac3fb24de81 100644 --- a/usr.sbin/rtadvd/dump.c +++ b/usr.sbin/rtadvd/dump.c @@ -310,7 +310,7 @@ dname_labeldec(char *dst, size_t dlen, const char *src) (src + len) <= src_last) { if (dst != dst_origin) *dst++ = '.'; - syslog(LOG_DEBUG, "<%s> labellen = %d", __func__, len); + syslog(LOG_DEBUG, "<%s> labellen = %zd", __func__, len); memcpy(dst, src, len); src += len; dst += len; diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c index 614d109f7596..6423e7bf97e4 100644 --- a/usr.sbin/rtadvd/rtadvd.c +++ b/usr.sbin/rtadvd/rtadvd.c @@ -789,7 +789,7 @@ rtadvd_input(void) #else if ((size_t)i < sizeof(struct icmp6_hdr)) { syslog(LOG_ERR, - "<%s> packet size(%d) is too short", + "<%s> packet size(%zd) is too short", __func__, i); return; } @@ -827,7 +827,7 @@ rtadvd_input(void) if ((size_t)i < sizeof(struct nd_router_solicit)) { syslog(LOG_NOTICE, "<%s> RS from %s on %s does not have enough " - "length (len = %d)", + "length (len = %zd)", __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), @@ -873,7 +873,7 @@ rtadvd_input(void) if ((size_t)i < sizeof(struct nd_router_advert)) { syslog(LOG_NOTICE, "<%s> RA from %s on %s does not have enough " - "length (len = %d)", + "length (len = %zd)", __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), From 32b65a86d0b2b966afb97a6694f92ff4f8d4d83f Mon Sep 17 00:00:00 2001 From: ae Date: Mon, 6 Jun 2011 10:52:26 +0000 Subject: [PATCH 097/164] Increase buffer size for the command line. PR: bin/125370 Submitted by: sem MFC after: 2 weeks --- sbin/ipfw/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/main.c b/sbin/ipfw/main.c index fb3f3fbfdfb3..be6c093f303b 100644 --- a/sbin/ipfw/main.c +++ b/sbin/ipfw/main.c @@ -444,7 +444,7 @@ static void ipfw_readfile(int ac, char *av[]) { #define MAX_ARGS 32 - char buf[BUFSIZ]; + char buf[4096]; char *progname = av[0]; /* original program name */ const char *cmd = NULL; /* preprocessor name, if any */ const char *filename = av[ac-1]; /* file to read */ @@ -552,7 +552,7 @@ ipfw_readfile(int ac, char *av[]) } } - while (fgets(buf, BUFSIZ, f)) { /* read commands */ + while (fgets(buf, sizeof(buf), f)) { /* read commands */ char linename[20]; char *args[2]; From 779a2851183dcdf9fcc874c942b9cd64a23e5711 Mon Sep 17 00:00:00 2001 From: ae Date: Mon, 6 Jun 2011 11:10:38 +0000 Subject: [PATCH 098/164] Initialize co.use_set variable before parsing each new rule. PR: bin/134975 MFC after: 2 weeks --- sbin/ipfw/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/ipfw/main.c b/sbin/ipfw/main.c index be6c093f303b..109b62b7de43 100644 --- a/sbin/ipfw/main.c +++ b/sbin/ipfw/main.c @@ -356,6 +356,7 @@ ipfw_main(int oldac, char **oldav) */ co.do_nat = 0; co.do_pipe = 0; + co.use_set = 0; if (!strncmp(*av, "nat", strlen(*av))) co.do_nat = 1; else if (!strncmp(*av, "pipe", strlen(*av))) From de9cf29a6bd4ed92ffb509255494628176882eda Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 11:36:10 +0000 Subject: [PATCH 099/164] Do not mark lo0 as IFDISABLED even if there is no $ifconfig_lo0_ipv6 line. --- etc/network.subr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/network.subr b/etc/network.subr index a5bdd67982a5..ce71b786f307 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -102,7 +102,7 @@ ifconfig_up() if afexists inet6; then if checkyesno ipv6_activate_all_interfaces; then _ipv6_opts="-ifdisabled" - else + elif [ "$1" != "lo0" ]; then _ipv6_opts="ifdisabled" fi From 8faa1a484f6a1763b048ef72c86a6d065a4e9f7e Mon Sep 17 00:00:00 2001 From: bz Date: Mon, 6 Jun 2011 12:21:42 +0000 Subject: [PATCH 100/164] Remove TODO which is not longer needed and the default. --- usr.sbin/bsdinstall/scripts/netconfig_ipv6 | 1 - 1 file changed, 1 deletion(-) diff --git a/usr.sbin/bsdinstall/scripts/netconfig_ipv6 b/usr.sbin/bsdinstall/scripts/netconfig_ipv6 index 70bd203e19d7..8bff816f792b 100755 --- a/usr.sbin/bsdinstall/scripts/netconfig_ipv6 +++ b/usr.sbin/bsdinstall/scripts/netconfig_ipv6 @@ -33,7 +33,6 @@ # # TODO: -# - Add -R /sbin/resolvconf to rtsol once support is in tree. # - Add DHCPv6 support once FreeBSD ships with it. # From 6e29aea1dbf128b84b885f9acc6396c69ab080ce Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 6 Jun 2011 12:55:02 +0000 Subject: [PATCH 101/164] Implement a CPU-affine TCP and UDP connection lookup data structure, struct inpcbgroup. pcbgroups, or "connection groups", supplement the existing inpcbinfo connection hash table, which when pcbgroups are enabled, might now be thought of more usefully as a per-protocol 4-tuple reservation table. Connections are assigned to connection groups base on a hash of their 4-tuple; wildcard sockets require special handling, and are members of all connection groups. During a connection lookup, a per-connection group lock is employed rather than the global pcbinfo lock. By aligning connection groups with input path processing, connection groups take on an effective CPU affinity, especially when aligned with RSS work placement (see a forthcoming commit for details). This eliminates cache line migration associated with global, protocol-layer data structures in steady state TCP and UDP processing (with the exception of protocol-layer statistics; further commit to follow). Elements of this approach were inspired by Willman, Rixner, and Cox's 2006 USENIX paper, "An Evaluation of Network Stack Parallelization Strategies in Modern Operating Systems". However, there are also significant differences: we maintain the inpcb lock, rather than using the connection group lock for per-connection state. Likewise, the focus of this implementation is alignment with NIC packet distribution strategies such as RSS, rather than pure software strategies. Despite that focus, software distribution is supported through the parallel netisr implementation, and works well in configurations where the number of hardware threads is greater than the number of NIC input queues, such as in the RMI XLR threaded MIPS architecture. Another important difference is the continued maintenance of existing hash tables as "reservation tables" -- these are useful both to distinguish the resource allocation aspect of protocol name management and the more common-case lookup aspect. In configurations where connection tables are aligned with hardware hashes, it is desirable to use the traditional lookup tables for loopback or encapsulated traffic rather than take the expense of hardware hashes that are hard to implement efficiently in software (such as RSS Toeplitz). Connection group support is enabled by compiling "options PCBGROUP" into your kernel configuration; for the time being, this is an experimental feature, and hence is not enabled by default. Subject to the limited MFCability of change dependencies in inpcb, and its change to the inpcbinfo init function signature, this change in principle could be merged to FreeBSD 8.x. Reviewed by: bz Sponsored by: Juniper Networks, Inc. --- sys/conf/files | 2 + sys/conf/options | 1 + sys/netinet/in_pcb.c | 229 +++++++++++++++++- sys/netinet/in_pcb.h | 86 ++++++- sys/netinet/in_pcbgroup.c | 457 ++++++++++++++++++++++++++++++++++++ sys/netinet/ip_divert.c | 3 +- sys/netinet/ipfw/ip_fw2.c | 4 + sys/netinet/raw_ip.c | 3 +- sys/netinet/tcp_subr.c | 3 +- sys/netinet/tcp_syncache.c | 9 +- sys/netinet/udp_usrreq.c | 3 +- sys/netinet6/in6_pcb.c | 167 +++++++++++++ sys/netinet6/in6_pcb.h | 10 + sys/netinet6/in6_pcbgroup.c | 103 ++++++++ 14 files changed, 1067 insertions(+), 13 deletions(-) create mode 100644 sys/netinet/in_pcbgroup.c create mode 100644 sys/netinet6/in6_pcbgroup.c diff --git a/sys/conf/files b/sys/conf/files index 59286a5195a0..d654c6f00421 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2748,6 +2748,7 @@ netinet/ip_gre.c optional gre inet netinet/ip_id.c optional inet netinet/in_mcast.c optional inet netinet/in_pcb.c optional inet | inet6 +netinet/in_pcbgroup.c optional inet pcbgroup | inet6 pcbgroup netinet/in_proto.c optional inet | inet6 \ compile-with "${NORMAL_C} -I$S/contrib/pf" netinet/in_rmx.c optional inet @@ -2825,6 +2826,7 @@ netinet6/in6_gif.c optional gif inet6 | netgraph_gif inet6 netinet6/in6_ifattach.c optional inet6 netinet6/in6_mcast.c optional inet6 netinet6/in6_pcb.c optional inet6 +netinet6/in6_pcbgroup.c optional inet6 pcbgroup netinet6/in6_proto.c optional inet6 netinet6/in6_rmx.c optional inet6 netinet6/in6_src.c optional inet6 diff --git a/sys/conf/options b/sys/conf/options index a608d86382f6..ee696a8674d1 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -419,6 +419,7 @@ MROUTING opt_mrouting.h NCP NETATALK opt_atalk.h NFSLOCKD +PCBGROUP opt_pcbgroup.h RADIX_MPATH opt_mpath.h ROUTETABLES opt_route.h SLIP_IFF_OPTS opt_slip.h diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 4aa998f20cb2..4eb309aecde4 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ipsec.h" #include "opt_inet.h" #include "opt_inet6.h" +#include "opt_pcbgroup.h" #include #include @@ -212,7 +213,7 @@ void in_pcbinfo_init(struct inpcbinfo *pcbinfo, const char *name, struct inpcbhead *listhead, int hash_nelements, int porthash_nelements, char *inpcbzone_name, uma_init inpcbzone_init, uma_fini inpcbzone_fini, - uint32_t inpcbzone_flags) + uint32_t inpcbzone_flags, u_int hashfields) { INP_INFO_LOCK_INIT(pcbinfo, name); @@ -227,6 +228,9 @@ in_pcbinfo_init(struct inpcbinfo *pcbinfo, const char *name, &pcbinfo->ipi_hashmask); pcbinfo->ipi_porthashbase = hashinit(porthash_nelements, M_PCB, &pcbinfo->ipi_porthashmask); +#ifdef PCBGROUP + in_pcbgroup_init(pcbinfo, hashfields, hash_nelements); +#endif pcbinfo->ipi_zone = uma_zcreate(inpcbzone_name, sizeof(struct inpcb), NULL, NULL, inpcbzone_init, inpcbzone_fini, UMA_ALIGN_PTR, inpcbzone_flags); @@ -246,6 +250,9 @@ in_pcbinfo_destroy(struct inpcbinfo *pcbinfo) hashdestroy(pcbinfo->ipi_hashbase, M_PCB, pcbinfo->ipi_hashmask); hashdestroy(pcbinfo->ipi_porthashbase, M_PCB, pcbinfo->ipi_porthashmask); +#ifdef PCBGROUP + in_pcbgroup_destroy(pcbinfo); +#endif uma_zdestroy(pcbinfo->ipi_zone); INP_HASH_LOCK_DESTROY(pcbinfo); INP_INFO_LOCK_DESTROY(pcbinfo); @@ -1053,7 +1060,8 @@ in_pcbdetach(struct inpcb *inp) * in_pcbref() bumps the reference count on an inpcb in order to maintain * stability of an inpcb pointer despite the inpcb lock being released. This * is used in TCP when the inpcbinfo lock needs to be acquired or upgraded, - * but where the inpcb lock is already held. + * but where the inpcb lock may already held, or when acquiring a reference + * via a pcbgroup. * * in_pcbref() should be used only to provide brief memory stability, and * must always be followed by a call to INP_WLOCK() and in_pcbrele() to @@ -1223,6 +1231,9 @@ in_pcbdrop(struct inpcb *inp) } INP_HASH_WUNLOCK(inp->inp_pcbinfo); inp->inp_flags &= ~INP_INHASHLIST; +#ifdef PCBGROUP + in_pcbgroup_remove(inp); +#endif } } @@ -1472,6 +1483,148 @@ in_pcblookup_local(struct inpcbinfo *pcbinfo, struct in_addr laddr, } #undef INP_LOOKUP_MAPPED_PCB_COST +#ifdef PCBGROUP +/* + * Lookup PCB in hash list, using pcbgroup tables. + */ +static struct inpcb * +in_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, + struct in_addr faddr, u_int fport_arg, struct in_addr laddr, + u_int lport_arg, int lookupflags, struct ifnet *ifp) +{ + struct inpcbhead *head; + struct inpcb *inp, *tmpinp; + u_short fport = fport_arg, lport = lport_arg; + + /* + * First look for an exact match. + */ + tmpinp = NULL; + INP_GROUP_LOCK(pcbgroup); + head = &pcbgroup->ipg_hashbase[INP_PCBHASH(faddr.s_addr, lport, fport, + pcbgroup->ipg_hashmask)]; + LIST_FOREACH(inp, head, inp_pcbgrouphash) { +#ifdef INET6 + /* XXX inp locking */ + if ((inp->inp_vflag & INP_IPV4) == 0) + continue; +#endif + if (inp->inp_faddr.s_addr == faddr.s_addr && + inp->inp_laddr.s_addr == laddr.s_addr && + inp->inp_fport == fport && + inp->inp_lport == lport) { + /* + * XXX We should be able to directly return + * the inp here, without any checks. + * Well unless both bound with SO_REUSEPORT? + */ + if (prison_flag(inp->inp_cred, PR_IP4)) + goto found; + if (tmpinp == NULL) + tmpinp = inp; + } + } + if (tmpinp != NULL) { + inp = tmpinp; + goto found; + } + + /* + * Then look for a wildcard match, if requested. + */ + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { + struct inpcb *local_wild = NULL, *local_exact = NULL; +#ifdef INET6 + struct inpcb *local_wild_mapped = NULL; +#endif + struct inpcb *jail_wild = NULL; + struct inpcbhead *head; + int injail; + + /* + * Order of socket selection - we always prefer jails. + * 1. jailed, non-wild. + * 2. jailed, wild. + * 3. non-jailed, non-wild. + * 4. non-jailed, wild. + */ + head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, lport, + 0, pcbinfo->ipi_wildmask)]; + LIST_FOREACH(inp, head, inp_pcbgroup_wild) { +#ifdef INET6 + /* XXX inp locking */ + if ((inp->inp_vflag & INP_IPV4) == 0) + continue; +#endif + if (inp->inp_faddr.s_addr != INADDR_ANY || + inp->inp_lport != lport) + continue; + + /* XXX inp locking */ + if (ifp && ifp->if_type == IFT_FAITH && + (inp->inp_flags & INP_FAITH) == 0) + continue; + + injail = prison_flag(inp->inp_cred, PR_IP4); + if (injail) { + if (prison_check_ip4(inp->inp_cred, + &laddr) != 0) + continue; + } else { + if (local_exact != NULL) + continue; + } + + if (inp->inp_laddr.s_addr == laddr.s_addr) { + if (injail) + goto found; + else + local_exact = inp; + } else if (inp->inp_laddr.s_addr == INADDR_ANY) { +#ifdef INET6 + /* XXX inp locking, NULL check */ + if (inp->inp_vflag & INP_IPV6PROTO) + local_wild_mapped = inp; + else +#endif /* INET6 */ + if (injail) + jail_wild = inp; + else + local_wild = inp; + } + } /* LIST_FOREACH */ + inp = jail_wild; + if (inp == NULL) + inp = local_exact; + if (inp == NULL) + inp = local_wild; +#ifdef INET6 + if (inp == NULL) + inp = local_wild_mapped; +#endif /* defined(INET6) */ + if (inp != NULL) + goto found; + } /* if (lookupflags & INPLOOKUP_WILDCARD) */ + INP_GROUP_UNLOCK(pcbgroup); + return (NULL); + +found: + in_pcbref(inp); + INP_GROUP_UNLOCK(pcbgroup); + if (lookupflags & INPLOOKUP_WLOCKPCB) { + INP_WLOCK(inp); + if (in_pcbrele_wlocked(inp)) + return (NULL); + } else if (lookupflags & INPLOOKUP_RLOCKPCB) { + INP_RLOCK(inp); + if (in_pcbrele_rlocked(inp)) + return (NULL); + } else + panic("%s: locking bug", __func__); + return (inp); +} +#endif /* PCBGROUP */ + /* * Lookup PCB in hash list, using pcbinfo tables. This variation assumes * that the caller has locked the hash list, and will not perform any further @@ -1636,17 +1789,30 @@ in_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in_addr faddr, /* * Public inpcb lookup routines, accepting a 4-tuple, and optionally, an mbuf * from which a pre-calculated hash value may be extracted. + * + * Possibly more of this logic should be in in_pcbgroup.c. */ struct inpcb * in_pcblookup(struct inpcbinfo *pcbinfo, struct in_addr faddr, u_int fport, struct in_addr laddr, u_int lport, int lookupflags, struct ifnet *ifp) { +#if defined(PCBGROUP) + struct inpcbgroup *pcbgroup; +#endif KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, ("%s: LOCKPCB not set", __func__)); +#if defined(PCBGROUP) + if (in_pcbgroup_enabled(pcbinfo)) { + pcbgroup = in_pcbgroup_bytuple(pcbinfo, laddr, lport, faddr, + fport); + return (in_pcblookup_group(pcbinfo, pcbgroup, faddr, fport, + laddr, lport, lookupflags, ifp)); + } +#endif return (in_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, lookupflags, ifp)); } @@ -1656,12 +1822,28 @@ in_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in_addr faddr, u_int fport, struct in_addr laddr, u_int lport, int lookupflags, struct ifnet *ifp, struct mbuf *m) { +#ifdef PCBGROUP + struct inpcbgroup *pcbgroup; +#endif KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, ("%s: LOCKPCB not set", __func__)); +#ifdef PCBGROUP + if (in_pcbgroup_enabled(pcbinfo)) { + pcbgroup = in_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), + m->m_pkthdr.flowid); + if (pcbgroup != NULL) + return (in_pcblookup_group(pcbinfo, pcbgroup, faddr, + fport, laddr, lport, lookupflags, ifp)); + pcbgroup = in_pcbgroup_bytuple(pcbinfo, laddr, lport, faddr, + fport); + return (in_pcblookup_group(pcbinfo, pcbgroup, faddr, fport, + laddr, lport, lookupflags, ifp)); + } +#endif return (in_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, lookupflags, ifp)); } @@ -1670,8 +1852,8 @@ in_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in_addr faddr, /* * Insert PCB onto various hash lists. */ -int -in_pcbinshash(struct inpcb *inp) +static int +in_pcbinshash_internal(struct inpcb *inp, int do_pcbgroup_update) { struct inpcbhead *pcbhash; struct inpcbporthead *pcbporthash; @@ -1721,9 +1903,38 @@ in_pcbinshash(struct inpcb *inp) LIST_INSERT_HEAD(&phd->phd_pcblist, inp, inp_portlist); LIST_INSERT_HEAD(pcbhash, inp, inp_hash); inp->inp_flags |= INP_INHASHLIST; +#ifdef PCBGROUP + if (do_pcbgroup_update) + in_pcbgroup_update(inp); +#endif return (0); } +/* + * For now, there are two public interfaces to insert an inpcb into the hash + * lists -- one that does update pcbgroups, and one that doesn't. The latter + * is used only in the TCP syncache, where in_pcbinshash is called before the + * full 4-tuple is set for the inpcb, and we don't want to install in the + * pcbgroup until later. + * + * XXXRW: This seems like a misfeature. in_pcbinshash should always update + * connection groups, and partially initialised inpcbs should not be exposed + * to either reservation hash tables or pcbgroups. + */ +int +in_pcbinshash(struct inpcb *inp) +{ + + return (in_pcbinshash_internal(inp, 1)); +} + +int +in_pcbinshash_nopcbgroup(struct inpcb *inp) +{ + + return (in_pcbinshash_internal(inp, 0)); +} + /* * Move PCB to the proper hash bucket when { faddr, fport } have been * changed. NOTE: This does not handle the case of the lport changing (the @@ -1755,6 +1966,13 @@ in_pcbrehash_mbuf(struct inpcb *inp, struct mbuf *m) LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); + +#ifdef PCBGROUP + if (m != NULL) + in_pcbgroup_update_mbuf(inp, m); + else + in_pcbgroup_update(inp); +#endif } void @@ -1791,6 +2009,9 @@ in_pcbremlists(struct inpcb *inp) } LIST_REMOVE(inp, inp_list); pcbinfo->ipi_count--; +#ifdef PCBGROUP + in_pcbgroup_remove(inp); +#endif } /* diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 809bc0576478..a8524bed8747 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -141,6 +141,7 @@ struct icmp6_filter; * * Key: * (c) - Constant after initialization + * (g) - Protected by the pcbgroup lock * (i) - Protected by the inpcb lock * (p) - Protected by the pcbinfo lock for the inpcb * (s) - Protected by another subsystem's locks @@ -160,9 +161,12 @@ struct icmp6_filter; */ struct inpcb { LIST_ENTRY(inpcb) inp_hash; /* (i/p) hash list */ + LIST_ENTRY(inpcb) inp_pcbgrouphash; /* (g/i) hash list */ LIST_ENTRY(inpcb) inp_list; /* (i/p) list for all PCBs for proto */ void *inp_ppcb; /* (i) pointer to per-protocol pcb */ struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */ + struct inpcbgroup *inp_pcbgroup; /* (g/i) PCB group list */ + LIST_ENTRY(inpcb) inp_pcbgroup_wild; /* (g/i/p) group wildcard entry */ struct socket *inp_socket; /* (i) back pointer to socket */ struct ucred *inp_cred; /* (c) cache of socket cred */ u_int32_t inp_flow; /* (i) IPv6 flow information */ @@ -272,13 +276,14 @@ struct inpcbport { * the former covering mutable global fields (such as the global pcb list), * and the latter covering the hashed lookup tables. The lock order is: * - * ipi_lock (before) inpcb locks (before) ipi_hash_lock + * ipi_lock (before) inpcb locks (before) {ipi_hash_lock, pcbgroup locks} * * Locking key: * * (c) Constant or nearly constant after initialisation * (g) Locked by ipi_lock - * (h) Read using either ipi_hash_lock or inpcb lock; write requires both. + * (h) Read using either ipi_hash_lock or inpcb lock; write requires both + * (p) Protected by one or more pcbgroup locks * (x) Synchronisation properties poorly defined */ struct inpcbinfo { @@ -312,7 +317,16 @@ struct inpcbinfo { struct uma_zone *ipi_zone; /* (c) */ /* - * Global lock protecting hash lookup tables. + * Connection groups associated with this protocol. These fields are + * constant, but pcbgroup structures themselves are protected by + * per-pcbgroup locks. + */ + struct inpcbgroup *ipi_pcbgroups; /* (c) */ + u_int ipi_npcbgroups; /* (c) */ + u_int ipi_hashfields; /* (c) */ + + /* + * Global lock protecting non-pcbgroup hash lookup tables. */ struct rwlock ipi_hash_lock; @@ -329,6 +343,14 @@ struct inpcbinfo { struct inpcbporthead *ipi_porthashbase; /* (h) */ u_long ipi_porthashmask; /* (h) */ + /* + * List of wildcard inpcbs for use with pcbgroups. In the past, was + * per-pcbgroup but is now global. All pcbgroup locks must be held + * to modify the list, so any is sufficient to read it. + */ + struct inpcbhead *ipi_wildbase; /* (p) */ + u_long ipi_wildmask; /* (p) */ + /* * Pointer to network stack instance */ @@ -340,6 +362,31 @@ struct inpcbinfo { void *ipi_pspare[2]; }; +/* + * Connection groups hold sets of connections that have similar CPU/thread + * affinity. Each connection belongs to exactly one connection group. + */ +struct inpcbgroup { + /* + * Per-connection group hash of inpcbs, hashed by local and foreign + * addresses and port numbers. + */ + struct inpcbhead *ipg_hashbase; /* (c) */ + u_long ipg_hashmask; /* (c) */ + + /* + * Notional affinity of this pcbgroup. + */ + u_int ipg_cpu; /* (p) */ + + /* + * Per-connection group lock, not to be confused with ipi_lock. + * Protects the hash table hung off the group, but also the global + * wildcard list in inpcbinfo. + */ + struct mtx ipg_lock; +} __aligned(CACHE_LINE_SIZE); + #define INP_LOCK_INIT(inp, d, t) \ rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE | RW_DUPOK) #define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock) @@ -423,6 +470,14 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, #define INP_HASH_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \ RA_WLOCKED) +#define INP_GROUP_LOCK_INIT(ipg, d) mtx_init(&(ipg)->ipg_lock, (d), NULL, \ + MTX_DEF | MTX_DUPOK) +#define INP_GROUP_LOCK_DESTROY(ipg) mtx_destroy(&(ipg)->ipg_lock) + +#define INP_GROUP_LOCK(ipg) mtx_lock(&(ipg)->ipg_lock) +#define INP_GROUP_LOCK_ASSERT(ipg) mtx_assert(&(ipg)->ipg_lock, MA_OWNED) +#define INP_GROUP_UNLOCK(ipg) mtx_unlock(&(ipg)->ipg_lock) + #define INP_PCBHASH(faddr, lport, fport, mask) \ (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) #define INP_PCBPORTHASH(lport, mask) \ @@ -482,6 +537,7 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, */ #define INP_LLE_VALID 0x00000001 /* cached lle is valid */ #define INP_RT_VALID 0x00000002 /* cached rtentry is valid */ +#define INP_PCBGROUPWILD 0x00000004 /* in pcbgroup wildcard list */ /* * Flags passed to in_pcblookup*() functions. @@ -500,6 +556,13 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af) +/* + * Constants for pcbinfo.ipi_hashfields. + */ +#define IPI_HASHFIELDS_NONE 0 +#define IPI_HASHFIELDS_2TUPLE 1 +#define IPI_HASHFIELDS_4TUPLE 2 + #ifdef _KERNEL VNET_DECLARE(int, ipport_reservedhigh); VNET_DECLARE(int, ipport_reservedlow); @@ -531,7 +594,21 @@ VNET_DECLARE(int, ipport_tcpallocs); void in_pcbinfo_destroy(struct inpcbinfo *); void in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *, - int, int, char *, uma_init, uma_fini, uint32_t); + int, int, char *, uma_init, uma_fini, uint32_t, u_int); + +struct inpcbgroup * + in_pcbgroup_byhash(struct inpcbinfo *, u_int, uint32_t); +struct inpcbgroup * + in_pcbgroup_byinpcb(struct inpcb *); +struct inpcbgroup * + in_pcbgroup_bytuple(struct inpcbinfo *, struct in_addr, u_short, + struct in_addr, u_short); +void in_pcbgroup_destroy(struct inpcbinfo *); +int in_pcbgroup_enabled(struct inpcbinfo *); +void in_pcbgroup_init(struct inpcbinfo *, u_int, int); +void in_pcbgroup_remove(struct inpcb *); +void in_pcbgroup_update(struct inpcb *); +void in_pcbgroup_update_mbuf(struct inpcb *, struct mbuf *); void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); int in_pcballoc(struct socket *, struct inpcbinfo *); @@ -551,6 +628,7 @@ void in_pcbdisconnect(struct inpcb *); void in_pcbdrop(struct inpcb *); void in_pcbfree(struct inpcb *); int in_pcbinshash(struct inpcb *); +int in_pcbinshash_nopcbgroup(struct inpcb *); struct inpcb * in_pcblookup_local(struct inpcbinfo *, struct in_addr, u_short, int, struct ucred *); diff --git a/sys/netinet/in_pcbgroup.c b/sys/netinet/in_pcbgroup.c new file mode 100644 index 000000000000..c9f5c7083136 --- /dev/null +++ b/sys/netinet/in_pcbgroup.c @@ -0,0 +1,457 @@ +/*- + * Copyright (c) 2010-2011 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * 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 + +__FBSDID("$FreeBSD$"); + +#include "opt_inet6.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#ifdef INET6 +#include +#endif /* INET6 */ + +/* + * pcbgroups, or "connection groups" are based on Willman, Rixner, and Cox's + * 2006 USENIX paper, "An Evaluation of Network Stack Parallelization + * Strategies in Modern Operating Systems". This implementation differs + * significantly from that described in the paper, in that it attempts to + * introduce not just notions of affinity for connections and distribute work + * so as to reduce lock contention, but also align those notions with + * hardware work distribution strategies such as RSS. In this construction, + * connection groups supplement, rather than replace, existing reservation + * tables for protocol 4-tuples, offering CPU-affine lookup tables with + * minimal cache line migration and lock contention during steady state + * operation. + * + * Internet protocols, such as UDP and TCP, register to use connection groups + * by providing an ipi_hashfields value other than IPI_HASHFIELDS_NONE; this + * indicates to the connection group code whether a 2-tuple or 4-tuple is + * used as an argument to hashes that assign a connection to a particular + * group. This must be aligned with any hardware offloaded distribution + * model, such as RSS or similar approaches taken in embedded network boards. + * Wildcard sockets require special handling, as in Willman 2006, and are + * shared between connection groups -- while being protected by group-local + * locks. This means that connection establishment and teardown can be + * signficantly more expensive than without connection groups, but that + * steady-state processing can be significantly faster. + * + * Most of the implementation of connection groups is in this file; however, + * connection group lookup is implemented in in_pcb.c alongside reservation + * table lookups -- see in_pcblookup_group(). + * + * TODO: + * + * Implement dynamic rebalancing of buckets with connection groups; when + * load is unevenly distributed, search for more optimal balancing on + * demand. This might require scaling up the number of connection groups + * by <<1. + * + * Provide an IP 2-tuple or 4-tuple netisr m2cpu handler based on connection + * groups for ip_input and ip6_input, allowing non-offloaded work + * distribution. + * + * Expose effective CPU affinity of connections to userspace using socket + * options. + * + * Investigate per-connection affinity overrides based on socket options; an + * option could be set, certainly resulting in work being distributed + * differently in software, and possibly propagated to supporting hardware + * with TCAMs or hardware hash tables. This might require connections to + * exist in more than one connection group at a time. + * + * Hook netisr thread reconfiguration events, and propagate those to RSS so + * that rebalancing can occur when the thread pool grows or shrinks. + * + * Expose per-pcbgroup statistics to userspace monitoring tools such as + * netstat, in order to allow better debugging and profiling. + */ + +void +in_pcbgroup_init(struct inpcbinfo *pcbinfo, u_int hashfields, + int hash_nelements) +{ + struct inpcbgroup *pcbgroup; + u_int numpcbgroups, pgn; + + /* + * Only enable connection groups for a protocol if it has been + * specifically requested. + */ + if (hashfields == IPI_HASHFIELDS_NONE) + return; + + /* + * Connection groups are about multi-processor load distribution, + * lock contention, and connection CPU affinity. As such, no point + * in turning them on for a uniprocessor machine, it only wastes + * memory. + */ + if (mp_ncpus == 1) + return; + + /* + * Use one group per CPU for now. If we decide to do dynamic + * rebalancing a la RSS, we'll need to shift left by at least 1. + */ + numpcbgroups = mp_ncpus; + + pcbinfo->ipi_hashfields = hashfields; + pcbinfo->ipi_pcbgroups = malloc(numpcbgroups * + sizeof(*pcbinfo->ipi_pcbgroups), M_PCB, M_WAITOK | M_ZERO); + pcbinfo->ipi_npcbgroups = numpcbgroups; + pcbinfo->ipi_wildbase = hashinit(hash_nelements, M_PCB, + &pcbinfo->ipi_wildmask); + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) { + pcbgroup = &pcbinfo->ipi_pcbgroups[pgn]; + pcbgroup->ipg_hashbase = hashinit(hash_nelements, M_PCB, + &pcbgroup->ipg_hashmask); + INP_GROUP_LOCK_INIT(pcbgroup, "pcbgroup"); + + /* + * Initialise notional affinity of the pcbgroup -- for RSS, + * we want the same notion of affinity as NICs to be used. + * Just round robin for the time being. + */ + pcbgroup->ipg_cpu = (pgn % mp_ncpus); + } +} + +void +in_pcbgroup_destroy(struct inpcbinfo *pcbinfo) +{ + struct inpcbgroup *pcbgroup; + u_int pgn; + + if (pcbinfo->ipi_npcbgroups == 0) + return; + + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) { + pcbgroup = &pcbinfo->ipi_pcbgroups[pgn]; + KASSERT(LIST_EMPTY(pcbinfo->ipi_listhead), + ("in_pcbinfo_destroy: listhead not empty")); + INP_GROUP_LOCK_DESTROY(pcbgroup); + hashdestroy(pcbgroup->ipg_hashbase, M_PCB, + pcbgroup->ipg_hashmask); + } + hashdestroy(pcbinfo->ipi_wildbase, M_PCB, pcbinfo->ipi_wildmask); + free(pcbinfo->ipi_pcbgroups, M_PCB); + pcbinfo->ipi_pcbgroups = NULL; + pcbinfo->ipi_npcbgroups = 0; + pcbinfo->ipi_hashfields = 0; +} + +/* + * Given a hash of whatever the covered tuple might be, return a pcbgroup + * index. + */ +static __inline u_int +in_pcbgroup_getbucket(struct inpcbinfo *pcbinfo, uint32_t hash) +{ + + return (hash % pcbinfo->ipi_npcbgroups); +} + +/* + * Map a (hashtype, hash) tuple into a connection group, or NULL if the hash + * information is insufficient to identify the pcbgroup. + */ +struct inpcbgroup * +in_pcbgroup_byhash(struct inpcbinfo *pcbinfo, u_int hashtype, uint32_t hash) +{ + + return (NULL); +} + +static struct inpcbgroup * +in_pcbgroup_bymbuf(struct inpcbinfo *pcbinfo, struct mbuf *m) +{ + + return (in_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), + m->m_pkthdr.flowid)); +} + +struct inpcbgroup * +in_pcbgroup_bytuple(struct inpcbinfo *pcbinfo, struct in_addr laddr, + u_short lport, struct in_addr faddr, u_short fport) +{ + uint32_t hash; + + switch (pcbinfo->ipi_hashfields) { + case IPI_HASHFIELDS_4TUPLE: + hash = faddr.s_addr ^ fport; + break; + + case IPI_HASHFIELDS_2TUPLE: + hash = faddr.s_addr ^ laddr.s_addr; + break; + + default: + hash = 0; + } + return (&pcbinfo->ipi_pcbgroups[in_pcbgroup_getbucket(pcbinfo, + hash)]); +} + +struct inpcbgroup * +in_pcbgroup_byinpcb(struct inpcb *inp) +{ + + return (in_pcbgroup_bytuple(inp->inp_pcbinfo, inp->inp_laddr, + inp->inp_lport, inp->inp_faddr, inp->inp_fport)); +} + +static void +in_pcbwild_add(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + struct inpcbhead *head; + u_int pgn; + + INP_WLOCK_ASSERT(inp); + KASSERT(!(inp->inp_flags2 & INP_PCBGROUPWILD), + ("%s: is wild",__func__)); + + pcbinfo = inp->inp_pcbinfo; + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) + INP_GROUP_LOCK(&pcbinfo->ipi_pcbgroups[pgn]); + head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, inp->inp_lport, + 0, pcbinfo->ipi_wildmask)]; + LIST_INSERT_HEAD(head, inp, inp_pcbgroup_wild); + inp->inp_flags2 |= INP_PCBGROUPWILD; + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) + INP_GROUP_UNLOCK(&pcbinfo->ipi_pcbgroups[pgn]); +} + +static void +in_pcbwild_remove(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + u_int pgn; + + INP_WLOCK_ASSERT(inp); + KASSERT((inp->inp_flags2 & INP_PCBGROUPWILD), + ("%s: not wild", __func__)); + + pcbinfo = inp->inp_pcbinfo; + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) + INP_GROUP_LOCK(&pcbinfo->ipi_pcbgroups[pgn]); + LIST_REMOVE(inp, inp_pcbgroup_wild); + for (pgn = 0; pgn < pcbinfo->ipi_npcbgroups; pgn++) + INP_GROUP_UNLOCK(&pcbinfo->ipi_pcbgroups[pgn]); + inp->inp_flags2 &= ~INP_PCBGROUPWILD; +} + +static __inline int +in_pcbwild_needed(struct inpcb *inp) +{ + +#ifdef INET6 + if (inp->inp_vflag & INP_IPV6) + return (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)); + else +#endif + return (inp->inp_faddr.s_addr == htonl(INADDR_ANY)); +} + +static void +in_pcbwild_update_internal(struct inpcb *inp) +{ + int wildcard_needed; + + wildcard_needed = in_pcbwild_needed(inp); + if (wildcard_needed && !(inp->inp_flags2 & INP_PCBGROUPWILD)) + in_pcbwild_add(inp); + else if (!wildcard_needed && (inp->inp_flags2 & INP_PCBGROUPWILD)) + in_pcbwild_remove(inp); +} + +/* + * Update the pcbgroup of an inpcb, which might include removing an old + * pcbgroup reference and/or adding a new one. Wildcard processing is not + * performed here, although ideally we'll never install a pcbgroup for a + * wildcard inpcb (asserted below). + */ +static void +in_pcbgroup_update_internal(struct inpcbinfo *pcbinfo, + struct inpcbgroup *newpcbgroup, struct inpcb *inp) +{ + struct inpcbgroup *oldpcbgroup; + struct inpcbhead *pcbhash; + uint32_t hashkey_faddr; + + INP_WLOCK_ASSERT(inp); + + oldpcbgroup = inp->inp_pcbgroup; + if (oldpcbgroup != NULL && oldpcbgroup != newpcbgroup) { + INP_GROUP_LOCK(oldpcbgroup); + LIST_REMOVE(inp, inp_pcbgrouphash); + inp->inp_pcbgroup = NULL; + INP_GROUP_UNLOCK(oldpcbgroup); + } + if (newpcbgroup != NULL && oldpcbgroup != newpcbgroup) { +#ifdef INET6 + if (inp->inp_vflag & INP_IPV6) + hashkey_faddr = inp->in6p_faddr.s6_addr32[3]; /* XXX */ + else +#endif + hashkey_faddr = inp->inp_faddr.s_addr; + INP_GROUP_LOCK(newpcbgroup); + pcbhash = &newpcbgroup->ipg_hashbase[ + INP_PCBHASH(hashkey_faddr, inp->inp_lport, inp->inp_fport, + newpcbgroup->ipg_hashmask)]; + LIST_INSERT_HEAD(pcbhash, inp, inp_pcbgrouphash); + inp->inp_pcbgroup = newpcbgroup; + INP_GROUP_UNLOCK(newpcbgroup); + } + + KASSERT(!(newpcbgroup != NULL && in_pcbwild_needed(inp)), + ("%s: pcbgroup and wildcard!", __func__)); +} + +/* + * Two update paths: one in which the 4-tuple on an inpcb has been updated + * and therefore connection groups may need to change (or a wildcard entry + * may needed to be installed), and another in which the 4-tuple has been + * set as a result of a packet received, in which case we may be able to use + * the hash on the mbuf to avoid doing a software hash calculation for RSS. + * + * In each case: first, let the wildcard code have a go at placing it as a + * wildcard socket. If it was a wildcard, or if the connection has been + * dropped, then no pcbgroup is required (so potentially clear it); + * otherwise, calculate and update the pcbgroup for the inpcb. + */ +void +in_pcbgroup_update(struct inpcb *inp) +{ + struct inpcbinfo *pcbinfo; + struct inpcbgroup *newpcbgroup; + + INP_WLOCK_ASSERT(inp); + + pcbinfo = inp->inp_pcbinfo; + if (!in_pcbgroup_enabled(pcbinfo)) + return; + + in_pcbwild_update_internal(inp); + if (!(inp->inp_flags2 & INP_PCBGROUPWILD) && + !(inp->inp_flags & INP_DROPPED)) { +#ifdef INET6 + if (inp->inp_vflag & INP_IPV6) + newpcbgroup = in6_pcbgroup_byinpcb(inp); + else +#endif + newpcbgroup = in_pcbgroup_byinpcb(inp); + } else + newpcbgroup = NULL; + in_pcbgroup_update_internal(pcbinfo, newpcbgroup, inp); +} + +void +in_pcbgroup_update_mbuf(struct inpcb *inp, struct mbuf *m) +{ + struct inpcbinfo *pcbinfo; + struct inpcbgroup *newpcbgroup; + + INP_WLOCK_ASSERT(inp); + + pcbinfo = inp->inp_pcbinfo; + if (!in_pcbgroup_enabled(pcbinfo)) + return; + + /* + * Possibly should assert !INP_PCBGROUPWILD rather than testing for + * it; presumably this function should never be called for anything + * other than non-wildcard socket? + */ + in_pcbwild_update_internal(inp); + if (!(inp->inp_flags2 & INP_PCBGROUPWILD) && + !(inp->inp_flags & INP_DROPPED)) { + newpcbgroup = in_pcbgroup_bymbuf(pcbinfo, m); +#ifdef INET6 + if (inp->inp_vflag & INP_IPV6) { + if (newpcbgroup == NULL) + newpcbgroup = in6_pcbgroup_byinpcb(inp); + } else { +#endif + if (newpcbgroup == NULL) + newpcbgroup = in_pcbgroup_byinpcb(inp); +#ifdef INET6 + } +#endif + } else + newpcbgroup = NULL; + in_pcbgroup_update_internal(pcbinfo, newpcbgroup, inp); +} + +/* + * Remove pcbgroup entry and optional pcbgroup wildcard entry for this inpcb. + */ +void +in_pcbgroup_remove(struct inpcb *inp) +{ + struct inpcbgroup *pcbgroup; + + INP_WLOCK_ASSERT(inp); + + if (!in_pcbgroup_enabled(inp->inp_pcbinfo)) + return; + + if (inp->inp_flags2 & INP_PCBGROUPWILD) + in_pcbwild_remove(inp); + + pcbgroup = inp->inp_pcbgroup; + if (pcbgroup != NULL) { + INP_GROUP_LOCK(pcbgroup); + LIST_REMOVE(inp, inp_pcbgrouphash); + inp->inp_pcbgroup = NULL; + INP_GROUP_UNLOCK(pcbgroup); + } +} + +/* + * Query whether or not it is appropriate to use pcbgroups to look up inpcbs + * for a protocol. + */ +int +in_pcbgroup_enabled(struct inpcbinfo *pcbinfo) +{ + + return (pcbinfo->ipi_npcbgroups > 0); +} diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 6f5bce7d4876..527ce5683344 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -153,7 +153,8 @@ div_init(void) * place for hashbase == NULL. */ in_pcbinfo_init(&V_divcbinfo, "div", &V_divcb, 1, 1, "divcb", - div_inpcb_init, div_inpcb_fini, UMA_ZONE_NOFREE); + div_inpcb_init, div_inpcb_fini, UMA_ZONE_NOFREE, + IPI_HASHFIELDS_NONE); } static void diff --git a/sys/netinet/ipfw/ip_fw2.c b/sys/netinet/ipfw/ip_fw2.c index b4d3abbe6959..49c48b9ad03a 100644 --- a/sys/netinet/ipfw/ip_fw2.c +++ b/sys/netinet/ipfw/ip_fw2.c @@ -692,6 +692,10 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif, lookupflags |= INPLOOKUP_RLOCKPCB; match = 0; if (*ugid_lookupp == 0) { + /* + * XXXRW: If we had the mbuf here, could use + * in_pcblookup_mbuf(). + */ pcb = (oif) ? in_pcblookup(pi, dst_ip, htons(dst_port), diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 635f08f3146a..e754b8850382 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -205,7 +205,8 @@ rip_init(void) { in_pcbinfo_init(&V_ripcbinfo, "rip", &V_ripcb, INP_PCBHASH_RAW_SIZE, - 1, "ripcb", rip_inpcb_init, NULL, UMA_ZONE_NOFREE); + 1, "ripcb", rip_inpcb_init, NULL, UMA_ZONE_NOFREE, + IPI_HASHFIELDS_NONE); EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change, NULL, EVENTHANDLER_PRI_ANY); } diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 06854ec4f141..6ed589118d8b 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -300,7 +300,8 @@ tcp_init(void) hashsize = 512; /* safe default */ } in_pcbinfo_init(&V_tcbinfo, "tcp", &V_tcb, hashsize, hashsize, - "tcp_inpcb", tcp_inpcb_init, NULL, UMA_ZONE_NOFREE); + "tcp_inpcb", tcp_inpcb_init, NULL, UMA_ZONE_NOFREE, + IPI_HASHFIELDS_4TUPLE); /* * These have to be type stable for the benefit of the timers. diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 5125134363c0..66e473262035 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" +#include "opt_pcbgroup.h" #include #include @@ -676,8 +677,14 @@ syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) #ifdef INET6 } #endif + + /* + * Install in the reservation hash table for now, but don't yet + * install a connection group since the full 4-tuple isn't yet + * configured. + */ inp->inp_lport = sc->sc_inc.inc_lport; - if ((error = in_pcbinshash(inp)) != 0) { + if ((error = in_pcbinshash_nopcbgroup(inp)) != 0) { /* * Undo the assignments above if we failed to * put the PCB on the hash lists. diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index fd864c097bcb..28eb8fd19f88 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -186,7 +186,8 @@ udp_init(void) { in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE, - "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE); + "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE, + IPI_HASHFIELDS_2TUPLE); V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); uma_zone_set_max(V_udpcb_zone, maxsockets); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index da73f219d71e..d15c605b368e 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipsec.h" +#include "opt_pcbgroup.h" #include #include @@ -827,6 +828,141 @@ in6_rtchange(struct inpcb *inp, int errno) return inp; } +#ifdef PCBGROUP +/* + * Lookup PCB in hash list, using pcbgroup tables. + */ +static struct inpcb * +in6_pcblookup_group(struct inpcbinfo *pcbinfo, struct inpcbgroup *pcbgroup, + struct in6_addr *faddr, u_int fport_arg, struct in6_addr *laddr, + u_int lport_arg, int lookupflags, struct ifnet *ifp) +{ + struct inpcbhead *head; + struct inpcb *inp, *tmpinp; + u_short fport = fport_arg, lport = lport_arg; + int faith; + + if (faithprefix_p != NULL) + faith = (*faithprefix_p)(laddr); + else + faith = 0; + + /* + * First look for an exact match. + */ + tmpinp = NULL; + INP_GROUP_LOCK(pcbgroup); + head = &pcbgroup->ipg_hashbase[ + INP_PCBHASH(faddr->s6_addr32[3] /* XXX */, lport, fport, + pcbgroup->ipg_hashmask)]; + LIST_FOREACH(inp, head, inp_pcbgrouphash) { + /* XXX inp locking */ + if ((inp->inp_vflag & INP_IPV6) == 0) + continue; + if (IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr, faddr) && + IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr) && + inp->inp_fport == fport && + inp->inp_lport == lport) { + /* + * XXX We should be able to directly return + * the inp here, without any checks. + * Well unless both bound with SO_REUSEPORT? + */ + if (prison_flag(inp->inp_cred, PR_IP6)) + goto found; + if (tmpinp == NULL) + tmpinp = inp; + } + } + if (tmpinp != NULL) { + inp = tmpinp; + goto found; + } + + /* + * Then look for a wildcard match, if requested. + */ + if ((lookupflags & INPLOOKUP_WILDCARD) != 0) { + struct inpcb *local_wild = NULL, *local_exact = NULL; + struct inpcb *jail_wild = NULL; + int injail; + + /* + * Order of socket selection - we always prefer jails. + * 1. jailed, non-wild. + * 2. jailed, wild. + * 3. non-jailed, non-wild. + * 4. non-jailed, wild. + */ + head = &pcbinfo->ipi_wildbase[INP_PCBHASH(INADDR_ANY, lport, + 0, pcbinfo->ipi_wildmask)]; + LIST_FOREACH(inp, head, inp_pcbgroup_wild) { + /* XXX inp locking */ + if ((inp->inp_vflag & INP_IPV6) == 0) + continue; + + if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr) || + inp->inp_lport != lport) { + continue; + } + + /* XXX inp locking */ + if (faith && (inp->inp_flags & INP_FAITH) == 0) + continue; + + injail = prison_flag(inp->inp_cred, PR_IP6); + if (injail) { + if (prison_check_ip6(inp->inp_cred, + laddr) != 0) + continue; + } else { + if (local_exact != NULL) + continue; + } + + if (IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr, laddr)) { + if (injail) + goto found; + else + local_exact = inp; + } else if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { + if (injail) + jail_wild = inp; + else + local_wild = inp; + } + } /* LIST_FOREACH */ + + inp = jail_wild; + if (inp == NULL) + inp = jail_wild; + if (inp == NULL) + inp = local_exact; + if (inp == NULL) + inp = local_wild; + if (inp != NULL) + goto found; + } /* if ((lookupflags & INPLOOKUP_WILDCARD) != 0) */ + INP_GROUP_UNLOCK(pcbgroup); + return (NULL); + +found: + in_pcbref(inp); + INP_GROUP_UNLOCK(pcbgroup); + if (lookupflags & INPLOOKUP_WLOCKPCB) { + INP_WLOCK(inp); + if (in_pcbrele_wlocked(inp)) + return (NULL); + } else if (lookupflags & INPLOOKUP_RLOCKPCB) { + INP_RLOCK(inp); + if (in_pcbrele_rlocked(inp)) + return (NULL); + } else + panic("%s: locking buf", __func__); + return (inp); +} +#endif /* PCBGROUP */ + /* * Lookup PCB in hash list. */ @@ -983,16 +1119,30 @@ in6_pcblookup_hash(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, /* * Public inpcb lookup routines, accepting a 4-tuple, and optionally, an mbuf * from which a pre-calculated hash value may be extracted. + * + * Possibly more of this logic should be in in6_pcbgroup.c. */ struct inpcb * in6_pcblookup(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_int fport, struct in6_addr *laddr, u_int lport, int lookupflags, struct ifnet *ifp) { +#if defined(PCBGROUP) + struct inpcbgroup *pcbgroup; +#endif + KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, ("%s: LOCKPCB not set", __func__)); +#if defined(PCBGROUP) + if (in_pcbgroup_enabled(pcbinfo)) { + pcbgroup = in6_pcbgroup_bytuple(pcbinfo, laddr, lport, faddr, + fport); + return (in6_pcblookup_group(pcbinfo, pcbgroup, faddr, fport, + laddr, lport, lookupflags, ifp)); + } +#endif return (in6_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, lookupflags, ifp)); } @@ -1002,11 +1152,28 @@ in6_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_int fport, struct in6_addr *laddr, u_int lport, int lookupflags, struct ifnet *ifp, struct mbuf *m) { +#ifdef PCBGROUP + struct inpcbgroup *pcbgroup; +#endif + KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, ("%s: invalid lookup flags %d", __func__, lookupflags)); KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, ("%s: LOCKPCB not set", __func__)); +#ifdef PCBGROUP + if (in_pcbgroup_enabled(pcbinfo)) { + pcbgroup = in6_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), + m->m_pkthdr.flowid); + if (pcbgroup != NULL) + return (in6_pcblookup_group(pcbinfo, pcbgroup, faddr, + fport, laddr, lport, lookupflags, ifp)); + pcbgroup = in6_pcbgroup_bytuple(pcbinfo, laddr, lport, faddr, + fport); + return (in6_pcblookup_group(pcbinfo, pcbgroup, faddr, fport, + laddr, lport, lookupflags, ifp)); + } +#endif return (in6_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, lookupflags, ifp)); } diff --git a/sys/netinet6/in6_pcb.h b/sys/netinet6/in6_pcb.h index cf247043b507..8398d547dd6b 100644 --- a/sys/netinet6/in6_pcb.h +++ b/sys/netinet6/in6_pcb.h @@ -69,6 +69,16 @@ #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) #define ifatoia6(ifa) ((struct in6_ifaddr *)(ifa)) +struct inpcbgroup * + in6_pcbgroup_byhash(struct inpcbinfo *, u_int, uint32_t); +struct inpcbgroup * + in6_pcbgroup_byinpcb __P((struct inpcb *)); +struct inpcbgroup * + in6_pcbgroup_bymbuf(struct inpcbinfo *, struct mbuf *); +struct inpcbgroup * + in6_pcbgroup_bytuple __P((struct inpcbinfo *, const struct in6_addr *, + u_short, const struct in6_addr *, u_short)); + void in6_pcbpurgeif0 __P((struct inpcbinfo *, struct ifnet *)); void in6_losing __P((struct inpcb *)); int in6_pcbbind __P((struct inpcb *, struct sockaddr *, struct ucred *)); diff --git a/sys/netinet6/in6_pcbgroup.c b/sys/netinet6/in6_pcbgroup.c new file mode 100644 index 000000000000..850d7f471560 --- /dev/null +++ b/sys/netinet6/in6_pcbgroup.c @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2010-2011 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * 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 + +__FBSDID("$FreeBSD$"); + +#include "opt_inet6.h" + +#include +#include + +#include +#include +#ifdef INET6 +#include +#endif /* INET6 */ + +/* + * Given a hash of whatever the covered tuple might be, return a pcbgroup + * index. + */ +static __inline u_int +in6_pcbgroup_getbucket(struct inpcbinfo *pcbinfo, uint32_t hash) +{ + + return (hash % pcbinfo->ipi_npcbgroups); +} + +/* + * Map a (hashtype, hash) tuple into a connection group, or NULL if the hash + * information is insufficient to identify the pcbgroup. + */ +struct inpcbgroup * +in6_pcbgroup_byhash(struct inpcbinfo *pcbinfo, u_int hashtype, uint32_t hash) +{ + + return (NULL); +} + +struct inpcbgroup * +in6_pcbgroup_bymbuf(struct inpcbinfo *pcbinfo, struct mbuf *m) +{ + + return (in6_pcbgroup_byhash(pcbinfo, M_HASHTYPE_GET(m), + m->m_pkthdr.flowid)); +} + +struct inpcbgroup * +in6_pcbgroup_bytuple(struct inpcbinfo *pcbinfo, const struct in6_addr *laddrp, + u_short lport, const struct in6_addr *faddrp, u_short fport) +{ + uint32_t hash; + + switch (pcbinfo->ipi_hashfields) { + case IPI_HASHFIELDS_4TUPLE: + hash = faddrp->s6_addr32[3] ^ fport; + break; + + case IPI_HASHFIELDS_2TUPLE: + hash = faddrp->s6_addr32[3] ^ laddrp->s6_addr32[3]; + break; + + default: + hash = 0; + } + return (&pcbinfo->ipi_pcbgroups[in6_pcbgroup_getbucket(pcbinfo, + hash)]); +} + +struct inpcbgroup * +in6_pcbgroup_byinpcb(struct inpcb *inp) +{ + + return (in6_pcbgroup_bytuple(inp->inp_pcbinfo, &inp->in6p_laddr, + inp->inp_lport, &inp->in6p_faddr, inp->inp_fport)); +} From aa8ddae28045296cfac5aae264a723e7b0664db7 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 6 Jun 2011 13:12:56 +0000 Subject: [PATCH 102/164] Clear the device_t pointer in 'struct resource' when releasing a device as otherwise the sysctl to export rman info can dereference a stale pointer. PR: kern/115371 Submitted by: Arthur Hartwig MFC after: 1 week --- sys/kern/subr_rman.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 3014b1902014..abd72c03df0b 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -839,6 +839,7 @@ int_rman_release_resource(struct rman *rm, struct resource_i *r) * without freeing anything. */ r->r_flags &= ~RF_ALLOCATED; + r->r_dev = NULL; return 0; } From 59b78f51eb84b3cf6e4f53c4b27044c89e96aa3e Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 6 Jun 2011 13:13:48 +0000 Subject: [PATCH 103/164] Document that REQUIRES, PROVIDES and KEYWORDS are alos accepted. This chnage is different to the one suggested in the PR to try to avoid cluttering the man page too much. PR: docs/154494 Submitted by: kilian MFC after: 1 week --- sbin/rcorder/rcorder.8 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sbin/rcorder/rcorder.8 b/sbin/rcorder/rcorder.8 index b17b0a337ca1..16cf117c8508 100644 --- a/sbin/rcorder/rcorder.8 +++ b/sbin/rcorder/rcorder.8 @@ -89,6 +89,12 @@ and lines may appear, but all such lines must appear in a sequence without any intervening lines, as once a line that does not follow the format is reached, parsing stops. +Note that for historical reasons, +.Dq Li REQUIRES , +.Dq Li PROVIDES , +and +.Dq Li KEYWORDS +are also accepted in addition to the above. .Pp The options are as follows: .Bl -tag -width indent From b6df97b17b6ea3b8cc5819e7a3117e28327aa54b Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 6 Jun 2011 13:18:29 +0000 Subject: [PATCH 104/164] Bump .Dd Forgotten by: gavin MFC after: 1 week --- sbin/rcorder/rcorder.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/rcorder/rcorder.8 b/sbin/rcorder/rcorder.8 index 16cf117c8508..a47f01306c33 100644 --- a/sbin/rcorder/rcorder.8 +++ b/sbin/rcorder/rcorder.8 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 9, 2008 +.Dd June 6, 2011 .Dt RCORDER 8 .Os .Sh NAME From 970967dd97cca8ced16a03113dc1e5d3d193cb8b Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 6 Jun 2011 13:21:11 +0000 Subject: [PATCH 105/164] More properly handle Cardbus cards that that store their CIS in a BAR after the recent changes to track BAR state explicitly. The code would now attempt to add the same BAR twice in this case. Instead, change this so that it recognizes this case and only adds it once and do not delete the BAR outright after parsing the CIS. Tested by: bschmidt --- sys/dev/cardbus/cardbus_cis.c | 5 ++--- sys/dev/pci/pci.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/dev/cardbus/cardbus_cis.c b/sys/dev/cardbus/cardbus_cis.c index 2cfea19203f3..3352a56afa29 100644 --- a/sys/dev/cardbus/cardbus_cis.c +++ b/sys/dev/cardbus/cardbus_cis.c @@ -324,7 +324,7 @@ decode_tuple_bar(device_t cbdev, device_t child, int id, * hint when the cardbus bridge is a child of pci0 (the main * bus). The PC Card spec seems to indicate that this should * only be done on x86 based machines, which suggests that on - * non-x86 machines the adddresses can be anywhere. Since the + * non-x86 machines the addresses can be anywhere. Since the * hardware can do it on non-x86 machines, it should be able * to do it on x86 machines too. Therefore, we can and should * ignore this hint. Furthermore, the PC Card spec recommends @@ -430,7 +430,6 @@ cardbus_read_tuple_finish(device_t cbdev, device_t child, int rid, { if (res != CIS_CONFIG_SPACE) { bus_release_resource(child, SYS_RES_MEMORY, rid, res); - bus_delete_resource(child, SYS_RES_MEMORY, rid); } } @@ -467,7 +466,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, } /* allocate the memory space to read CIS */ - res = bus_alloc_resource(child, SYS_RES_MEMORY, rid, 0, ~0, 1, + res = bus_alloc_resource_any(child, SYS_RES_MEMORY, rid, rman_make_alignment_flags(4096) | RF_ACTIVE); if (res == NULL) { device_printf(cbdev, "Unable to allocate resource " diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 22046c1f30f7..9cd5a1c7a1ab 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -2576,6 +2576,17 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, uint16_t cmd; struct resource *res; + /* + * The BAR may already exist if the device is a CardBus card + * whose CIS is stored in this BAR. + */ + pm = pci_find_bar(dev, reg); + if (pm != NULL) { + maprange = pci_maprange(pm->pm_value); + barlen = maprange == 64 ? 2 : 1; + return (barlen); + } + pci_read_bar(dev, reg, &map, &testval); if (PCI_BAR_MEM(map)) { type = SYS_RES_MEMORY; From 248c7ffbdad4e181d2df30faeca35499e28fd060 Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 6 Jun 2011 13:24:54 +0000 Subject: [PATCH 106/164] Add another example to mount(8) on using the "-o" argument. PR: docs/157389 Submitted by: Warren Block MFC after: 1 week --- sbin/mount/mount.8 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sbin/mount/mount.8 b/sbin/mount/mount.8 index 2140b3724b78..fdfd75c031a2 100644 --- a/sbin/mount/mount.8 +++ b/sbin/mount/mount.8 @@ -28,7 +28,7 @@ .\" @(#)mount.8 8.8 (Berkeley) 6/16/94 .\" $FreeBSD$ .\" -.Dd April 28, 2011 +.Dd June 6, 2011 .Dt MOUNT 8 .Os .Sh NAME @@ -348,7 +348,6 @@ option) may be passed as a comma separated list; these options are distinguished by a leading .Dq \&- (dash). -Options that take a value are specified using the syntax -option=value. For example, the .Nm command: @@ -363,6 +362,16 @@ to execute the equivalent of: /sbin/mount_cd9660 -e /dev/cd0 /cdrom .Ed .Pp +Options that take a value are specified using the -option=value syntax: +.Bd -literal -offset indent +mount -t msdosfs -o -u=fred,-g=wheel /dev/da0s1 /mnt +.Ed +.Pp +is equivalent to +.Bd -literal -offset indent +/sbin/mount_msdosfs -u fred -g wheel /dev/da0s1 /mnt +.Ed +.Pp Additional options specific to file system types which are not internally known (see the description of the From 7dc7ed779295dad8446c4d2f5cde121d28b2ff3b Mon Sep 17 00:00:00 2001 From: jh Date: Mon, 6 Jun 2011 13:50:29 +0000 Subject: [PATCH 107/164] Pass correct size to write(2). PR: bin/155915 Submitted by: John Levine MFC after: 2 weeks --- usr.bin/calendar/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index ef98d5da9b5f..eb37eace8bdf 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -346,7 +346,7 @@ closecal(FILE *fp) write(pdes[1], pw->pw_name, strlen(pw->pw_name)); write(pdes[1], ">\nTo: <", 7); write(pdes[1], pw->pw_name, strlen(pw->pw_name)); - write(pdes[1], ">\nSubject: ", 12); + write(pdes[1], ">\nSubject: ", 11); write(pdes[1], dayname, strlen(dayname)); write(pdes[1], "'s Calendar\nPrecedence: bulk\n\n", 30); From 9162612be720dd56acd0c28c65c7bfe154594159 Mon Sep 17 00:00:00 2001 From: avg Date: Mon, 6 Jun 2011 14:23:13 +0000 Subject: [PATCH 108/164] don't use cpuid level 4 in x86 cpu topology detection if it's not supported This regression was introduced in r213323. There are probably no Intel cpus that support amd64 mode, but do not support cpuid level 4, but it's better to keep i386 and amd64 versions of this code in sync. Discovered by: pho Tested by: pho MFC after: 2 weeks --- sys/amd64/amd64/mp_machdep.c | 7 +++++-- sys/i386/i386/mp_machdep.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index 5c900344518b..c53d10ac89e9 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -241,8 +241,11 @@ topo_probe_0x4(void) * logical processors that belong to the same core * as BSP thus deducing number of threads per core. */ - cpuid_count(0x04, 0, p); - max_cores = ((p[0] >> 26) & 0x3f) + 1; + if (cpu_high >= 0x4) { + cpuid_count(0x04, 0, p); + max_cores = ((p[0] >> 26) & 0x3f) + 1; + } else + max_cores = 1; core_id_bits = mask_width(max_logical/max_cores); if (core_id_bits < 0) return; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index a4db4016f8e9..904af80cd1f8 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -289,8 +289,11 @@ topo_probe_0x4(void) * logical processors that belong to the same core * as BSP thus deducing number of threads per core. */ - cpuid_count(0x04, 0, p); - max_cores = ((p[0] >> 26) & 0x3f) + 1; + if (cpu_high >= 0x4) { + cpuid_count(0x04, 0, p); + max_cores = ((p[0] >> 26) & 0x3f) + 1; + } else + max_cores = 1; core_id_bits = mask_width(max_logical/max_cores); if (core_id_bits < 0) return; From d3eac6f07d776e4349bbc61d22d863d12096efec Mon Sep 17 00:00:00 2001 From: mm Date: Mon, 6 Jun 2011 14:46:43 +0000 Subject: [PATCH 109/164] Remove empty #ifndef MFC after: 3 days --- sys/cddl/compat/opensolaris/sys/atomic.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/cddl/compat/opensolaris/sys/atomic.h b/sys/cddl/compat/opensolaris/sys/atomic.h index af9cc5d27e47..f34d77e6f38c 100644 --- a/sys/cddl/compat/opensolaris/sys/atomic.h +++ b/sys/cddl/compat/opensolaris/sys/atomic.h @@ -40,8 +40,6 @@ extern void atomic_add_64(volatile uint64_t *target, int64_t delta); extern void atomic_dec_64(volatile uint64_t *target); #endif -#ifndef __LP64__ -#endif #ifndef __sparc64__ extern uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval); From 32935a5430c426d6c8fb7d0fd8b9706961957ea9 Mon Sep 17 00:00:00 2001 From: gjb Date: Mon, 6 Jun 2011 15:17:55 +0000 Subject: [PATCH 110/164] Document that when running 'su -m -c ', is run within a shell as . PR: 157078 Submitted by: Warren Block MFC after: 5 days --- usr.bin/su/su.1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr.bin/su/su.1 b/usr.bin/su/su.1 index 8b79d41b6cb7..f06ce146ca54 100644 --- a/usr.bin/su/su.1 +++ b/usr.bin/su/su.1 @@ -193,10 +193,10 @@ PAM configuration for .Sh EXAMPLES .Bl -tag -width 5n -compact .It Li "su -m man -c catman" -Runs the command -.Li catman -as user -.Li man . +Starts a shell as user +.Li man , +and runs the command +.Li catman . You will be asked for man's password unless your real UID is 0. Note that the .Fl m From 257b06700106a3f81d0d0bb880b730e2f9468a39 Mon Sep 17 00:00:00 2001 From: gjb Date: Mon, 6 Jun 2011 15:21:53 +0000 Subject: [PATCH 111/164] Bump date from previous commit. :( MFC after: 5 days --- usr.bin/su/su.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/su/su.1 b/usr.bin/su/su.1 index f06ce146ca54..8025a23339cf 100644 --- a/usr.bin/su/su.1 +++ b/usr.bin/su/su.1 @@ -28,7 +28,7 @@ .\" @(#)su.1 8.2 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd July 1, 2008 +.Dd June 6, 2011 .Dt SU 1 .Os .Sh NAME From d046e38f5f20bee3d0f9e3c18f4300724ba9a20f Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 6 Jun 2011 15:33:15 +0000 Subject: [PATCH 112/164] Some style fixes. Submitted by: bde --- sys/dev/puc/pucdata.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dev/puc/pucdata.c b/sys/dev/puc/pucdata.c index a56971e19a0a..2b38d9b171ef 100644 --- a/sys/dev/puc/pucdata.c +++ b/sys/dev/puc/pucdata.c @@ -51,12 +51,12 @@ static puc_config_f puc_config_amc; static puc_config_f puc_config_diva; static puc_config_f puc_config_exar; static puc_config_f puc_config_icbook; +static puc_config_f puc_config_oxford_pcie; static puc_config_f puc_config_quatech; static puc_config_f puc_config_syba; static puc_config_f puc_config_siig; static puc_config_f puc_config_timedia; static puc_config_f puc_config_titan; -static puc_config_f puc_config_oxford_pcie; const struct puc_cfg puc_pci_devices[] = { @@ -1366,14 +1366,12 @@ puc_config_oxford_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, bar = puc_get_bar(sc, cfg->rid); if (bar == NULL) return (ENXIO); - for (idx = 0; idx < sc->sc_nports; idx++) { - value = bus_read_1(bar->b_res, 0x1000 + (idx << 9) - + 0x92); + value = bus_read_1(bar->b_res, 0x1000 + (idx << 9) + + 0x92); bus_write_1(bar->b_res, 0x1000 + (idx << 9) + 0x92, - value | 0x10); + value | 0x10); } - return (0); case PUC_CFG_GET_LEN: *res = 0x200; From 252476437dec30b7b91f809c2d2802cdc2de69cf Mon Sep 17 00:00:00 2001 From: imp Date: Mon, 6 Jun 2011 16:27:38 +0000 Subject: [PATCH 113/164] Make a couple of debug printfs DEVPRINTF. --- sys/dev/pccard/pccard.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 00cd1dc08b60..1de571c8e6c1 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -1405,8 +1405,8 @@ pccard_ccr_read_impl(device_t brdev, device_t child, uint32_t offset, struct pccard_ivar *devi = PCCARD_IVAR(child); *val = pccard_ccr_read(devi->pf, offset); - device_printf(child, "ccr_read of %#x (%#x) is %#x\n", offset, - devi->pf->pf_ccr_offset, *val); + DEVPRINTF((child, "ccr_read of %#x (%#x) is %#x\n", offset, + devi->pf->pf_ccr_offset, *val)); return 0; } @@ -1421,8 +1421,8 @@ pccard_ccr_write_impl(device_t brdev, device_t child, uint32_t offset, * Can't use pccard_ccr_write since client drivers may access * registers not contained in the 'mask' if they are non-standard. */ - device_printf(child, "ccr_write of %#x to %#x (%#x)\n", val, offset, - devi->pf->pf_ccr_offset); + DEVPRINTF((child, "ccr_write of %#x to %#x (%#x)\n", val, offset, + devi->pf->pf_ccr_offset)); bus_space_write_1(pf->pf_ccrt, pf->pf_ccrh, pf->pf_ccr_offset + offset, val); return 0; From 2b4f16d8ca90ab41ab0b01cc24172b2746107ef6 Mon Sep 17 00:00:00 2001 From: bz Date: Mon, 6 Jun 2011 17:07:38 +0000 Subject: [PATCH 114/164] Include param.h for CACHE_LINE_SIZE to unbreak the build. --- usr.sbin/tcpdrop/tcpdrop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c index 6aae85ccb4d1..dce6c6d4be9d 100644 --- a/usr.sbin/tcpdrop/tcpdrop.c +++ b/usr.sbin/tcpdrop/tcpdrop.c @@ -20,12 +20,13 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include #include -#include +#include #include #define TCPSTATES #include From d64e8f190560b3ab8442a3ede043c6b5d8438dbb Mon Sep 17 00:00:00 2001 From: marcel Date: Mon, 6 Jun 2011 18:25:11 +0000 Subject: [PATCH 115/164] Don't clobber the hosts /etc/fstab. $1 is empty at this point. --- release/ia64/mkisoimages.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/ia64/mkisoimages.sh b/release/ia64/mkisoimages.sh index 5dac51ba8de1..f17185b142c8 100644 --- a/release/ia64/mkisoimages.sh +++ b/release/ia64/mkisoimages.sh @@ -72,8 +72,8 @@ else BOOTOPTS="" fi -echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $1/etc/fstab +echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > $BASE/etc/fstab makefs -t cd9660 $BOOTOPTS -o rockridge -o label=$LABEL $NAME $BASE $* +rm $BASE/etc/fstab rm -f $EFIPART -rm $1/etc/fstab exit 0 From d5bd22e229d52e500cb2628346b9ad8deb2ef1c3 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 6 Jun 2011 18:40:01 +0000 Subject: [PATCH 116/164] Allow custom files to be opened and allow sorting by timestamp. While implementing a tool to import lastlog entries into utmpx, I noticed lastlogin doesn't allow custom database files to be opened. Add a -f switch to support this. Also, add -r and -t similar to ls(1), ruptime(1), etc. where you can sort entries by timestamp and reverse them. This allows you to spot active/idle users more easily. --- usr.sbin/lastlogin/lastlogin.8 | 20 ++++++++++-- usr.sbin/lastlogin/lastlogin.c | 58 +++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/usr.sbin/lastlogin/lastlogin.8 b/usr.sbin/lastlogin/lastlogin.8 index 063016399e77..fdbc871dcf17 100644 --- a/usr.sbin/lastlogin/lastlogin.8 +++ b/usr.sbin/lastlogin/lastlogin.8 @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 11, 1996 +.Dd June 6, 2011 .Dt LASTLOGIN 8 .Os .Sh NAME @@ -39,6 +39,8 @@ .Nd indicate last login time of users .Sh SYNOPSIS .Nm +.Op Fl f Ar file +.Op Fl rt .Op Ar user ... .Sh DESCRIPTION The @@ -54,8 +56,8 @@ If more than one .Ar user is given, the session information for each user is printed in the order given on the command line. -Otherwise, information -for all users is printed, sorted by name. +Otherwise, information for all users is printed. +By default, the entries are sorted by user name. .Pp The .Nm @@ -63,6 +65,18 @@ utility differs from .Xr last 1 in that it only prints information regarding the very last login session. The last login database is never turned over or deleted in standard usage. +.Pp +The following options are available: +.Bl -tag -width indent +.It Fl f Ar file +Open last login database +.Ar file +instead of the system-wide database. +.It Fl r +Print the entries in reverse sorted order. +.It Fl t +Sort the elements by last login time, instead of user name. +.El .Sh FILES .Bl -tag -width /var/log/utx.lastlogin -compact .It Pa /var/log/utx.lastlogin diff --git a/usr.sbin/lastlogin/lastlogin.c b/usr.sbin/lastlogin/lastlogin.c index 4c085475ad0b..2f8dd78331e2 100644 --- a/usr.sbin/lastlogin/lastlogin.c +++ b/usr.sbin/lastlogin/lastlogin.c @@ -47,30 +47,59 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998/02/03 04:45:35 perry Exp $"); int main(int, char **); static void output(struct utmpx *); static void usage(void); +static int utcmp_user(const void *, const void *); + +static int order = 1; +static const char *file = NULL; +static int (*utcmp)(const void *, const void *) = utcmp_user; static int -utcmp(const void *u1, const void *u2) +utcmp_user(const void *u1, const void *u2) { - return (strcmp(((const struct utmpx *)u1)->ut_user, + return (order * strcmp(((const struct utmpx *)u1)->ut_user, ((const struct utmpx *)u2)->ut_user)); } +static int +utcmp_time(const void *u1, const void *u2) +{ + time_t t1, t2; + + t1 = ((const struct utmpx *)u1)->ut_tv.tv_sec; + t2 = ((const struct utmpx *)u2)->ut_tv.tv_sec; + return (t1 < t2 ? order : t1 > t2 ? -order : 0); +} + int main(int argc, char *argv[]) { int ch, i, ulistsize; struct utmpx *u, *ulist; - while ((ch = getopt(argc, argv, "")) != -1) { - usage(); + while ((ch = getopt(argc, argv, "f:rt")) != -1) { + switch (ch) { + case 'f': + file = optarg; + break; + case 'r': + order = -1; + break; + case 't': + utcmp = utcmp_time; + break; + default: + usage(); + } } + argc -= optind; + argv += optind; - /* Process usernames given on the command line. */ - if (argc > 1) { - for (i = 1; i < argc; ++i) { - if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) - errx(1, "failed to open lastlog database"); + if (argc > 0) { + /* Process usernames given on the command line. */ + for (i = 0; i < argc; i++) { + if (setutxdb(UTXDB_LASTLOGIN, file) != 0) + err(1, "failed to open lastlog database"); if ((u = getutxuser(argv[i])) == NULL) { warnx("user '%s' not found", argv[i]); continue; @@ -78,11 +107,10 @@ main(int argc, char *argv[]) output(u); endutxent(); } - } - /* Read all lastlog entries, looking for active ones */ - else { - if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) - errx(1, "failed to open lastlog database"); + } else { + /* Read all lastlog entries, looking for active ones. */ + if (setutxdb(UTXDB_LASTLOGIN, file) != 0) + err(1, "failed to open lastlog database"); ulist = NULL; ulistsize = 0; while ((u = getutxent()) != NULL) { @@ -119,6 +147,6 @@ output(struct utmpx *u) static void usage(void) { - fprintf(stderr, "usage: lastlogin [user ...]\n"); + fprintf(stderr, "usage: lastlogin [-f file] [-rt] [user ...]\n"); exit(1); } From 2157ebafe521d9b08c3b5fc99e5f19eac4530377 Mon Sep 17 00:00:00 2001 From: dchagin Date: Mon, 6 Jun 2011 19:00:38 +0000 Subject: [PATCH 117/164] Fix regex for ptraceopname(). PR: bin/157663 Submitted by: jason wright MFC after: 10 days --- usr.bin/kdump/mksubr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index afff24d5fd6b..dbde92b762ec 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -345,7 +345,7 @@ auto_if_type "sockfamilyname" "AF_[[:alnum:]]+[[:space:]]+" "sys/socket.h" auto_if_type "sockipprotoname" "IPPROTO_[[:alnum:]]+[[:space:]]+" "netinet/in.h" auto_switch_type "sockoptname" "SO_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" auto_switch_type "socktypename" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h" -auto_switch_type "ptraceopname" "PT_[[:alnum:]]+[[:space:]]+[0-9]+" "sys/ptrace.h" +auto_switch_type "ptraceopname" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h" cat <<_EOF_ /* From b85f2958405471837cf29da0149697935f47e464 Mon Sep 17 00:00:00 2001 From: marcel Date: Mon, 6 Jun 2011 19:06:15 +0000 Subject: [PATCH 118/164] Improve cpu_idle(): o cpu_idle_hook is expected to be called with interrupts disabled and re-enables interrupts on return. o sync with x86: don't idle when the CPU has runnable tasks o have callers of ia64_call_pal_static() disable interrupts and re-enable interrupts. o add, but compile-out, support for idle mode. This will be enabled at some later time, after proper testing. --- sys/ia64/acpica/acpi_machdep.c | 7 +++++++ sys/ia64/ia64/machdep.c | 33 +++++++++++++++++++++++++++++---- sys/ia64/ia64/pal.S | 25 +++++++++++-------------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/sys/ia64/acpica/acpi_machdep.c b/sys/ia64/acpica/acpi_machdep.c index b7b612fd220e..1466cfe59a98 100644 --- a/sys/ia64/acpica/acpi_machdep.c +++ b/sys/ia64/acpica/acpi_machdep.c @@ -56,7 +56,14 @@ acpi_machdep_quirks(int *quirks) void acpi_cpu_c1() { +#ifdef INVARIANTS + register_t ie; + + ie = intr_disable(); + KASSERT(ie == 0, ("%s called with interrupts enabled\n", __func__)); +#endif ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0); + ia64_enable_intr(); } void * diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 7252865afe7e..fc7df7a95289 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -411,12 +411,34 @@ cpu_halt() void cpu_idle(int busy) { - struct ia64_pal_result res; + register_t ie; - if (cpu_idle_hook != NULL) +#if 0 + if (!busy) { + critical_enter(); + cpu_idleclock(); + } +#endif + + ie = intr_disable(); + KASSERT(ie != 0, ("%s called with interrupts disabled\n", __func__)); + + if (sched_runnable()) + ia64_enable_intr(); + else if (cpu_idle_hook != NULL) { (*cpu_idle_hook)(); - else - res = ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0); + /* The hook must enable interrupts! */ + } else { + ia64_call_pal_static(PAL_HALT_LIGHT, 0, 0, 0); + ia64_enable_intr(); + } + +#if 0 + if (!busy) { + cpu_activeclock(); + critical_exit(); + } +#endif } int @@ -644,9 +666,12 @@ calculate_frequencies(void) { struct ia64_sal_result sal; struct ia64_pal_result pal; + register_t ie; + ie = intr_disable(); sal = ia64_sal_entry(SAL_FREQ_BASE, 0, 0, 0, 0, 0, 0, 0); pal = ia64_call_pal_static(PAL_FREQ_RATIOS, 0, 0, 0); + intr_restore(ie); if (sal.sal_status == 0 && pal.pal_status == 0) { if (bootverbose) { diff --git a/sys/ia64/ia64/pal.S b/sys/ia64/ia64/pal.S index 2f0d0da72e6e..2e3f4cd85ac4 100644 --- a/sys/ia64/ia64/pal.S +++ b/sys/ia64/ia64/pal.S @@ -38,43 +38,40 @@ ia64_pal_entry: .quad 0 * u_int64_t arg1, u_int64_t arg2, u_int64_t arg3) */ ENTRY(ia64_call_pal_static, 4) - - .regstk 4,5,0,0 + + .regstk 4,4,0,0 palret = loc0 entry = loc1 rpsave = loc2 pfssave = loc3 -psrsave = loc4 - alloc pfssave=ar.pfs,4,5,0,0 + alloc pfssave=ar.pfs,4,4,0,0 ;; mov rpsave=rp - movl entry=@gprel(ia64_pal_entry) + 1: mov palret=ip // for return address ;; add entry=entry,gp - mov psrsave=psr + add palret=2f-1b,palret // calculate return address mov r28=in0 // procedure number - ;; - ld8 entry=[entry] // read entry point mov r29=in1 // copy arguments mov r30=in2 mov r31=in3 ;; - mov b6=entry - add palret=2f-1b,palret // calculate return address - ;; + ld8 entry=[entry] // read entry point mov b0=palret - rsm psr.i // disable interrupts + ;; + mov b6=entry ;; br.cond.sptk b6 // call into firmware -2: mov psr.l=psrsave + ;; +2: mov rp=rpsave mov ar.pfs=pfssave ;; - srlz.d br.ret.sptk rp + ;; END(ia64_call_pal_static) /* From 7089418fe7fe633793ea8078bb498b27e0e563c1 Mon Sep 17 00:00:00 2001 From: gjb Date: Mon, 6 Jun 2011 19:33:19 +0000 Subject: [PATCH 119/164] Attempt to clear up some confusion in the following example, by stating the '-c' argument is passed to the shell, not to su(1), which would indicate the login class. 'su -m -c ' Submitted by: Warren Block (followup to 157078) MFC after: 5 days --- usr.bin/su/su.1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr.bin/su/su.1 b/usr.bin/su/su.1 index 8025a23339cf..d9180e37a0be 100644 --- a/usr.bin/su/su.1 +++ b/usr.bin/su/su.1 @@ -203,6 +203,12 @@ Note that the option is required since user .Dq man does not have a valid shell by default. +In this example, +.Fl c +is passed to the shell of the user +.Dq man , +and is not interpreted as an argument to +.Nm . .It Li "su -m man -c 'catman /usr/share/man /usr/local/man'" Same as above, but the target command consists of more than a single word and hence is quoted for use with the From 3f1de98b344828e5a09a22f49c9068f2de8e689d Mon Sep 17 00:00:00 2001 From: hrs Date: Mon, 6 Jun 2011 20:14:50 +0000 Subject: [PATCH 120/164] Set WARNS=1 temporarily to unbreak universe. --- usr.sbin/rtadvd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/rtadvd/Makefile b/usr.sbin/rtadvd/Makefile index e34aa3ca1940..9dbfc997fabc 100644 --- a/usr.sbin/rtadvd/Makefile +++ b/usr.sbin/rtadvd/Makefile @@ -23,6 +23,6 @@ LDADD= -lutil CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DROUTEINFO -WARNS?= 6 +WARNS?= 1 .include From 52acbc4c0a01ae6c8a405c4588f612262bc0a798 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 6 Jun 2011 20:24:17 +0000 Subject: [PATCH 121/164] Remove redundant assignments to WARNS. For these directories, WARNS is already implied to be 6. --- lib/libiconv/Makefile | 1 - sbin/geom/class/sched/Makefile | 2 -- usr.bin/grep/Makefile | 2 -- usr.bin/iconv/Makefile | 2 -- usr.bin/rctl/Makefile | 2 -- usr.sbin/bluetooth/ath3kfw/Makefile | 1 - usr.sbin/bsnmpd/modules/snmp_wlan/Makefile | 2 -- usr.sbin/rtsold/Makefile | 1 - 8 files changed, 13 deletions(-) diff --git a/lib/libiconv/Makefile b/lib/libiconv/Makefile index 078771e9b05b..71c288573256 100644 --- a/lib/libiconv/Makefile +++ b/lib/libiconv/Makefile @@ -19,7 +19,6 @@ SRCS= citrus_bcs.c citrus_bcs_strtol.c citrus_bcs_strtoul.c \ citrus_module.c citrus_none.c citrus_pivot_factory.c \ citrus_prop.c citrus_stdenc.c iconv.c -WARNS?= 6 CFLAGS+= --param max-inline-insns-single=128 -I ${.CURDIR}/../../include -I${.CURDIR}/../libc/include .include diff --git a/sbin/geom/class/sched/Makefile b/sbin/geom/class/sched/Makefile index a6ccd584e217..6f54d3f36f9f 100644 --- a/sbin/geom/class/sched/Makefile +++ b/sbin/geom/class/sched/Makefile @@ -5,6 +5,4 @@ GEOM_CLASS= sched -WARNS?= 6 - .include diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile index 8cd490d9b390..f09a7d6f2e9f 100644 --- a/usr.bin/grep/Makefile +++ b/usr.bin/grep/Makefile @@ -28,8 +28,6 @@ MLINKS= grep.1 egrep.1 \ bsdgrep.1: grep.1 cp ${.ALLSRC} ${.TARGET} -WARNS?= 6 - LDADD= -lz -lbz2 DPADD= ${LIBZ} ${LIBBZ2} diff --git a/usr.bin/iconv/Makefile b/usr.bin/iconv/Makefile index 7e8f6e7613a1..deab0920fbde 100644 --- a/usr.bin/iconv/Makefile +++ b/usr.bin/iconv/Makefile @@ -7,8 +7,6 @@ PROG= iconv #SRCS= iconv.c MAN= iconv.1 -WARNS?= 6 - LDADD+= -lcrypt DPADD+= ${LIBCRYPT} diff --git a/usr.bin/rctl/Makefile b/usr.bin/rctl/Makefile index 1088cf11e9de..c5c32eba52eb 100644 --- a/usr.bin/rctl/Makefile +++ b/usr.bin/rctl/Makefile @@ -6,6 +6,4 @@ MAN= rctl.8 DPADD= ${LIBUTIL} LDADD= -lutil -WARNS?= 6 - .include diff --git a/usr.sbin/bluetooth/ath3kfw/Makefile b/usr.sbin/bluetooth/ath3kfw/Makefile index 0ff010f3394f..373655b210dd 100644 --- a/usr.sbin/bluetooth/ath3kfw/Makefile +++ b/usr.sbin/bluetooth/ath3kfw/Makefile @@ -2,7 +2,6 @@ PROG= ath3kfw MAN= ath3kfw.8 -WARNS?= 6 DPADD+= ${LIBUSB} LDADD+= -lusb diff --git a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile index 9b8628bfc509..6a53d46fb297 100644 --- a/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile +++ b/usr.sbin/bsnmpd/modules/snmp_wlan/Makefile @@ -6,8 +6,6 @@ MOD= wlan SRCS= wlan_snmp.c wlan_sys.c CFLAGS+= -DSNMPTREE_TYPES -WARNS= 6 - XSYM= begemotWlan BMIBS= BEGEMOT-WIRELESS-MIB.txt diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile index 9e2b48037307..c7c93af58bd5 100644 --- a/usr.sbin/rtsold/Makefile +++ b/usr.sbin/rtsold/Makefile @@ -19,7 +19,6 @@ MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c -WARNS?= 6 CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H DPADD= ${LIBKVM} LDADD= -lkvm From c8e197a2037e17686f997232419f8b02d1e61ffc Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 6 Jun 2011 21:02:26 +0000 Subject: [PATCH 122/164] Rework parts of this man page to improve grammar. Inspired by, and parts submitted by... PR: docs/157467 Submitted by: Ben Kaduk MFC after: 2 weeks --- sbin/geom/class/part/gpart.8 | 74 ++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/sbin/geom/class/part/gpart.8 b/sbin/geom/class/part/gpart.8 index 940620c9b5a3..4365d6b8bcfa 100644 --- a/sbin/geom/class/part/gpart.8 +++ b/sbin/geom/class/part/gpart.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 30, 2011 +.Dd June 6, 2011 .Dt GPART 8 .Os .Sh NAME @@ -530,16 +530,17 @@ about its use. .El .\" .Sh PARTITION TYPES +Partition types are identified on disk by particular strings or magic +values. The .Nm -utility uses symbolic names for common partition types to avoid that the -user needs to know what the partitioning scheme in question is and what -the actual number or identification needs to be used for a particular -type. +utility uses symbolic names for common partition types to avoid the +user needing to know these values or other details of the partitioning +scheme in question. The .Nm utility also allows the user to specify scheme-specific partition types -for partition types that do not have symbol names. +for partition types that do not have symbolic names. The symbolic names currently understood are: .Bl -tag -width ".Cm freebsd-vinum" .It Cm bios-boot @@ -740,30 +741,30 @@ action or reverted with the .Cm undo action. .Sh RECOVERING -The GEOM class PART supports recovering of partition tables only for GPT. +The GEOM PART class supports recovering of partition tables only for GPT. The GUID partition table has a primary and secondary (backup) copy of -metadata for redundance. -They are stored in the begining and in the end of device respectively. -Therefore it is acceptable to have some corruptions in the metadata that -are not fatal to work with GPT. -When kernel detects corrupt metadata it marks this table as corrupt and -reports about corruption. -Any changes in corrupt table are prohibited except +metadata for redundance, these are stored at the begining and the end +of the device respectively. +As a result of having two copies, it is acceptable to have some corruption +within the metadata that is not fatal to the working of GPT. +When the kernel detects corrupt metadata it marks this table as corrupt and +reports the corruption. +Any operations on corrupt tables are prohibited except for .Cm destroy and .Cm recover . .Pp -In case when only first sector is corrupt kernel can not detect GPT even -if partition table is not corrupt. -You can write protective MBR with +If the first sector of a provider is corrupt, the kernel can not detect GPT +even if partition table itself is not corrupt. +You can rewrite the protective MBR using the .Xr dd 1 -command to restore ability of GPT detection. -The copy of protective MBR is usually located in the +command, to restore the ability to detect the GPT. +The copy of the protective MBR is usually located in the .Pa /boot/pmbr file. .Pp -In case when some of metadata is corrupt you will get to know about this -from kernel's messages like these: +If one GPT header appears to be corrupt but the other copy remains intact, +the kernel will log the following: .Bd -literal -offset indent GEOM: provider: the primary GPT table is corrupt or invalid. GEOM: provider: using the secondary instead -- recovery strongly advised. @@ -777,32 +778,31 @@ GEOM: provider: using the primary only -- recovery suggested. .Pp Also .Nm -commands like +commands such as .Cm show , status and .Cm list -will report about corrupt table. +will report about corrupt tables. .Pp -In case when the size of device has changed (e.g.\& volume expansion) the -secondary GPT header will become located not in the last sector. +If the size of the device has changed (e.g.\& volume expansion) the +secondary GPT header will no longer be located in the last sector. This is not a metadata corruption, but it is dangerous because any -corruption of the primary GPT will lead to lost of partition table. -Kernel reports about this problem with message: +corruption of the primary GPT will lead to loss of partition table. +This problem is reported by the kernel with the message: .Bd -literal -offset indent GEOM: provider: the secondary GPT header is not in the last LBA. .Ed .Pp -A corrupt table can be recovered with +This situation can be recovered with the .Cm recover command. -This command does reconstruction of corrupt metadata using -known valid metadata. -Also it can relocate secondary GPT to the end of device. +This command reconstructs the corrupt metadata using known valid +metadata and relocates the secondary GPT to the end of the device. .Pp .Em NOTE : -The GEOM class PART can detect the same partition table on different GEOM -providers and some of them will be marked as corrupt. -Be careful when choosing a provider for recovering. +The GEOM PART class can detect the same partition table visible through +different GEOM providers, and some of them will be marked as corrupt. +Be careful when choosing a provider for recovery. If you choose incorrectly you can destroy the metadata of another GEOM class, e.g.\& GEOM MIRROR or GEOM LABEL. .Sh SYSCTL VARIABLES @@ -815,11 +815,11 @@ The default value is shown next to each variable. .Bl -tag -width indent .It Va kern.geom.part.check_integrity : No 1 This variable controls the behaviour of metadata integrity checks. -When integrity checks are enabled +When integrity checks are enabled, the .Nm PART -GEOM class verifies all generic partition parameters that it gets from the +GEOM class verifies all generic partition parameters obtained from the disk metadata. -If some inconsistency is detected, partition table will be +If some inconsistency is detected, the partition table will be rejected with a diagnostic message: .Sy "GEOM_PART: Integrity check failed (provider, scheme)" . .El From 5f55faed0601b0486b09dd7ec3727f5312e33d5d Mon Sep 17 00:00:00 2001 From: hselasky Date: Mon, 6 Jun 2011 21:45:09 +0000 Subject: [PATCH 123/164] Improve enumeration of Low- and Full-speed devices connected through a High-speed USB HUB by resetting the transaction translator (TT) before trying re-enumeration. Also when clear-stall fails multiple times try a re-enumeration. Suggested by: Trevor Blackwell MFC after: 14 days --- sys/dev/usb/usb_device.h | 2 + sys/dev/usb/usb_freebsd.h | 1 + sys/dev/usb/usb_generic.c | 6 +-- sys/dev/usb/usb_hub.c | 27 ++++++++-- sys/dev/usb/usb_request.c | 100 +++++++++++++++++++++++++++++++++++++- sys/dev/usb/usb_request.h | 4 ++ sys/dev/usb/usbdi.h | 1 + 7 files changed, 133 insertions(+), 8 deletions(-) diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h index c8bc5eb95a18..bf412214dd4f 100644 --- a/sys/dev/usb/usb_device.h +++ b/sys/dev/usb/usb_device.h @@ -187,6 +187,8 @@ struct usb_device { struct usb_host_endpoint *linux_endpoint_end; uint16_t devnum; #endif + + uint32_t clear_stall_errors; /* number of clear-stall failures */ }; /* globals */ diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h index a44e53004d91..ae69cdb8926e 100644 --- a/sys/dev/usb/usb_freebsd.h +++ b/sys/dev/usb/usb_freebsd.h @@ -66,6 +66,7 @@ #define USB_HUB_MAX_DEPTH 5 #define USB_EP0_BUFSIZE 1024 /* bytes */ +#define USB_CS_RESET_LIMIT 20 /* failures = 20 * 50 ms = 1sec */ typedef uint32_t usb_timeout_t; /* milliseconds */ typedef uint32_t usb_frlength_t; /* bytes */ diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 714ee6f368d5..d62f8f9466ce 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -966,10 +966,8 @@ ugen_re_enumerate(struct usb_fifo *f) /* ignore any errors */ DPRINTFN(6, "no FIFOs\n"); } - if (udev->re_enumerate_wait == 0) { - udev->re_enumerate_wait = 1; - usb_needs_explore(udev->bus, 0); - } + /* start re-enumeration of device */ + usbd_start_re_enumerate(udev); return (0); } diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index ce8a4a5139f3..351b1343dae5 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -242,9 +242,14 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up) if (child->flags.usb_mode == USB_MODE_HOST) { usbd_enum_lock(child); if (child->re_enumerate_wait) { - err = usbd_set_config_index(child, USB_UNCONFIG_INDEX); - if (err == 0) - err = usbd_req_re_enumerate(child, NULL); + err = usbd_set_config_index(child, + USB_UNCONFIG_INDEX); + if (err != 0) { + DPRINTF("Unconfigure failed: " + "%s: Ignored.\n", + usbd_errstr(err)); + } + err = usbd_req_re_enumerate(child, NULL); if (err == 0) err = usbd_set_config_index(child, 0); if (err == 0) { @@ -2471,3 +2476,19 @@ usbd_filter_power_mode(struct usb_device *udev, uint8_t power_mode) /* use fixed power mode given by hardware driver */ return (temp); } + +/*------------------------------------------------------------------------* + * usbd_start_re_enumerate + * + * This function starts re-enumeration of the given USB device. This + * function does not need to be called BUS-locked. This function does + * not wait until the re-enumeration is completed. + *------------------------------------------------------------------------*/ +void +usbd_start_re_enumerate(struct usb_device *udev) +{ + if (udev->re_enumerate_wait == 0) { + udev->re_enumerate_wait = 1; + usb_needs_explore(udev->bus, 0); + } +} diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index c099e7173e2a..4358ef42030b 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -238,6 +238,10 @@ usb_do_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: + + /* reset error counter */ + udev->clear_stall_errors = 0; + if (ep == NULL) goto tr_setup; /* device was unconfigured */ if (ep->edesc && @@ -289,8 +293,23 @@ usb_do_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) goto tr_setup; default: - if (xfer->error == USB_ERR_CANCELLED) { + if (error == USB_ERR_CANCELLED) break; + + DPRINTF("Clear stall failed.\n"); + if (udev->clear_stall_errors == USB_CS_RESET_LIMIT) + goto tr_setup; + + if (error == USB_ERR_TIMEOUT) { + udev->clear_stall_errors = USB_CS_RESET_LIMIT; + DPRINTF("Trying to re-enumerate.\n"); + usbd_start_re_enumerate(udev); + } else { + udev->clear_stall_errors++; + if (udev->clear_stall_errors == USB_CS_RESET_LIMIT) { + DPRINTF("Trying to re-enumerate.\n"); + usbd_start_re_enumerate(udev); + } } goto tr_setup; } @@ -1936,6 +1955,23 @@ usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx) return (USB_ERR_INVAL); } retry: + /* + * Try to reset the High Speed parent HUB of a LOW- or FULL- + * speed device, if any. + */ + if (udev->parent_hs_hub != NULL && + udev->speed != USB_SPEED_HIGH) { + DPRINTF("Trying to reset parent High Speed TT.\n"); + err = usbd_req_reset_tt(udev->parent_hs_hub, NULL, + udev->hs_port_no); + if (err) { + DPRINTF("Resetting parent High " + "Speed TT failed (%s).\n", + usbd_errstr(err)); + } + } + + /* Try to reset the parent HUB port. */ err = usbd_req_reset_port(parent_hub, mtx, udev->port_no); if (err) { DPRINTFN(0, "addr=%d, port reset failed, %s\n", @@ -2033,3 +2069,65 @@ usbd_req_set_device_feature(struct usb_device *udev, struct mtx *mtx, USETW(req.wLength, 0); return (usbd_do_request(udev, mtx, &req, 0)); } + +/*------------------------------------------------------------------------* + * usbd_req_reset_tt + * + * Returns: + * 0: Success + * Else: Failure + *------------------------------------------------------------------------*/ +usb_error_t +usbd_req_reset_tt(struct usb_device *udev, struct mtx *mtx, + uint8_t port) +{ + struct usb_device_request req; + + /* For single TT HUBs the port should be 1 */ + + if (udev->ddesc.bDeviceClass == UDCLASS_HUB && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBSTT) + port = 1; + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_RESET_TT; + USETW(req.wValue, 0); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + return (usbd_do_request(udev, mtx, &req, 0)); +} + +/*------------------------------------------------------------------------* + * usbd_req_clear_tt_buffer + * + * For single TT HUBs the port should be 1. + * + * Returns: + * 0: Success + * Else: Failure + *------------------------------------------------------------------------*/ +usb_error_t +usbd_req_clear_tt_buffer(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint) +{ + struct usb_device_request req; + uint16_t wValue; + + /* For single TT HUBs the port should be 1 */ + + if (udev->ddesc.bDeviceClass == UDCLASS_HUB && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBSTT) + port = 1; + + wValue = (endpoint & 0xF) | ((addr & 0x7F) << 4) | + ((endpoint & 0x80) << 8) | ((type & 3) << 12); + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_CLEAR_TT_BUFFER; + USETW(req.wValue, wValue); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + return (usbd_do_request(udev, mtx, &req, 0)); +} diff --git a/sys/dev/usb/usb_request.h b/sys/dev/usb/usb_request.h index 12f373d5fa5f..ac7a7c160b6b 100644 --- a/sys/dev/usb/usb_request.h +++ b/sys/dev/usb/usb_request.h @@ -85,5 +85,9 @@ usb_error_t usbd_req_set_hub_u2_timeout(struct usb_device *udev, struct mtx *mtx, uint8_t port, uint8_t timeout); usb_error_t usbd_req_set_hub_depth(struct usb_device *udev, struct mtx *mtx, uint16_t depth); +usb_error_t usbd_req_reset_tt(struct usb_device *udev, struct mtx *mtx, + uint8_t port); +usb_error_t usbd_req_clear_tt_buffer(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint); #endif /* _USB_REQUEST_H_ */ diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 8f6da7c68c81..91cd3fae3aaf 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -542,6 +542,7 @@ void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len); void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len); +void usbd_start_re_enumerate(struct usb_device *udev); int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, From 45c14b9c114b5d1172b078f708d3bfe1f36c516f Mon Sep 17 00:00:00 2001 From: bz Date: Mon, 6 Jun 2011 21:45:32 +0000 Subject: [PATCH 124/164] Unbreak kernels with non-default PCBGROUP included but no WITNESS. Rather than including lock.h in in_pcbgroup.c in right order, fix it for all consumers of in_pcb.h by further header file pollution under #ifdef KERNEL. Reported by: Pan Tsu (inyaoo gmail.com) --- sys/netinet/in_pcb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index a8524bed8747..dfef96348efe 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -44,6 +44,7 @@ #include #ifdef _KERNEL +#include #include #include #include From fcab0a31d2e4d49b5dcb107489d0fcd0f87c8ee6 Mon Sep 17 00:00:00 2001 From: hselasky Date: Mon, 6 Jun 2011 22:03:09 +0000 Subject: [PATCH 125/164] Reset clear-stall error counter before setting up the USB control transfers. MFC after: 14 days --- sys/dev/usb/usb_transfer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 5fd4f5a19a92..d4c2408db7c9 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2927,6 +2927,11 @@ usbd_ctrl_transfer_setup(struct usb_device *udev) */ usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX); + /* + * Reset clear stall error counter. + */ + udev->clear_stall_errors = 0; + /* * Try to setup a new USB transfer for the * default control endpoint: From fa5ff41200519da6b30c30e3ba5e8dcdf171923e Mon Sep 17 00:00:00 2001 From: attilio Date: Mon, 6 Jun 2011 22:06:42 +0000 Subject: [PATCH 126/164] MFC --- sys/dev/usb/usb_device.h | 2 + sys/dev/usb/usb_freebsd.h | 1 + sys/dev/usb/usb_generic.c | 6 +-- sys/dev/usb/usb_hub.c | 27 ++++++++-- sys/dev/usb/usb_request.c | 100 ++++++++++++++++++++++++++++++++++++- sys/dev/usb/usb_request.h | 4 ++ sys/dev/usb/usb_transfer.c | 5 ++ sys/dev/usb/usbdi.h | 1 + sys/netinet/in_pcb.h | 1 + 9 files changed, 139 insertions(+), 8 deletions(-) diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h index c8bc5eb95a18..bf412214dd4f 100644 --- a/sys/dev/usb/usb_device.h +++ b/sys/dev/usb/usb_device.h @@ -187,6 +187,8 @@ struct usb_device { struct usb_host_endpoint *linux_endpoint_end; uint16_t devnum; #endif + + uint32_t clear_stall_errors; /* number of clear-stall failures */ }; /* globals */ diff --git a/sys/dev/usb/usb_freebsd.h b/sys/dev/usb/usb_freebsd.h index a44e53004d91..ae69cdb8926e 100644 --- a/sys/dev/usb/usb_freebsd.h +++ b/sys/dev/usb/usb_freebsd.h @@ -66,6 +66,7 @@ #define USB_HUB_MAX_DEPTH 5 #define USB_EP0_BUFSIZE 1024 /* bytes */ +#define USB_CS_RESET_LIMIT 20 /* failures = 20 * 50 ms = 1sec */ typedef uint32_t usb_timeout_t; /* milliseconds */ typedef uint32_t usb_frlength_t; /* bytes */ diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 714ee6f368d5..d62f8f9466ce 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -966,10 +966,8 @@ ugen_re_enumerate(struct usb_fifo *f) /* ignore any errors */ DPRINTFN(6, "no FIFOs\n"); } - if (udev->re_enumerate_wait == 0) { - udev->re_enumerate_wait = 1; - usb_needs_explore(udev->bus, 0); - } + /* start re-enumeration of device */ + usbd_start_re_enumerate(udev); return (0); } diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index ce8a4a5139f3..351b1343dae5 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -242,9 +242,14 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up) if (child->flags.usb_mode == USB_MODE_HOST) { usbd_enum_lock(child); if (child->re_enumerate_wait) { - err = usbd_set_config_index(child, USB_UNCONFIG_INDEX); - if (err == 0) - err = usbd_req_re_enumerate(child, NULL); + err = usbd_set_config_index(child, + USB_UNCONFIG_INDEX); + if (err != 0) { + DPRINTF("Unconfigure failed: " + "%s: Ignored.\n", + usbd_errstr(err)); + } + err = usbd_req_re_enumerate(child, NULL); if (err == 0) err = usbd_set_config_index(child, 0); if (err == 0) { @@ -2471,3 +2476,19 @@ usbd_filter_power_mode(struct usb_device *udev, uint8_t power_mode) /* use fixed power mode given by hardware driver */ return (temp); } + +/*------------------------------------------------------------------------* + * usbd_start_re_enumerate + * + * This function starts re-enumeration of the given USB device. This + * function does not need to be called BUS-locked. This function does + * not wait until the re-enumeration is completed. + *------------------------------------------------------------------------*/ +void +usbd_start_re_enumerate(struct usb_device *udev) +{ + if (udev->re_enumerate_wait == 0) { + udev->re_enumerate_wait = 1; + usb_needs_explore(udev->bus, 0); + } +} diff --git a/sys/dev/usb/usb_request.c b/sys/dev/usb/usb_request.c index c099e7173e2a..4358ef42030b 100644 --- a/sys/dev/usb/usb_request.c +++ b/sys/dev/usb/usb_request.c @@ -238,6 +238,10 @@ usb_do_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) switch (USB_GET_STATE(xfer)) { case USB_ST_TRANSFERRED: + + /* reset error counter */ + udev->clear_stall_errors = 0; + if (ep == NULL) goto tr_setup; /* device was unconfigured */ if (ep->edesc && @@ -289,8 +293,23 @@ usb_do_clear_stall_callback(struct usb_xfer *xfer, usb_error_t error) goto tr_setup; default: - if (xfer->error == USB_ERR_CANCELLED) { + if (error == USB_ERR_CANCELLED) break; + + DPRINTF("Clear stall failed.\n"); + if (udev->clear_stall_errors == USB_CS_RESET_LIMIT) + goto tr_setup; + + if (error == USB_ERR_TIMEOUT) { + udev->clear_stall_errors = USB_CS_RESET_LIMIT; + DPRINTF("Trying to re-enumerate.\n"); + usbd_start_re_enumerate(udev); + } else { + udev->clear_stall_errors++; + if (udev->clear_stall_errors == USB_CS_RESET_LIMIT) { + DPRINTF("Trying to re-enumerate.\n"); + usbd_start_re_enumerate(udev); + } } goto tr_setup; } @@ -1936,6 +1955,23 @@ usbd_req_re_enumerate(struct usb_device *udev, struct mtx *mtx) return (USB_ERR_INVAL); } retry: + /* + * Try to reset the High Speed parent HUB of a LOW- or FULL- + * speed device, if any. + */ + if (udev->parent_hs_hub != NULL && + udev->speed != USB_SPEED_HIGH) { + DPRINTF("Trying to reset parent High Speed TT.\n"); + err = usbd_req_reset_tt(udev->parent_hs_hub, NULL, + udev->hs_port_no); + if (err) { + DPRINTF("Resetting parent High " + "Speed TT failed (%s).\n", + usbd_errstr(err)); + } + } + + /* Try to reset the parent HUB port. */ err = usbd_req_reset_port(parent_hub, mtx, udev->port_no); if (err) { DPRINTFN(0, "addr=%d, port reset failed, %s\n", @@ -2033,3 +2069,65 @@ usbd_req_set_device_feature(struct usb_device *udev, struct mtx *mtx, USETW(req.wLength, 0); return (usbd_do_request(udev, mtx, &req, 0)); } + +/*------------------------------------------------------------------------* + * usbd_req_reset_tt + * + * Returns: + * 0: Success + * Else: Failure + *------------------------------------------------------------------------*/ +usb_error_t +usbd_req_reset_tt(struct usb_device *udev, struct mtx *mtx, + uint8_t port) +{ + struct usb_device_request req; + + /* For single TT HUBs the port should be 1 */ + + if (udev->ddesc.bDeviceClass == UDCLASS_HUB && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBSTT) + port = 1; + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_RESET_TT; + USETW(req.wValue, 0); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + return (usbd_do_request(udev, mtx, &req, 0)); +} + +/*------------------------------------------------------------------------* + * usbd_req_clear_tt_buffer + * + * For single TT HUBs the port should be 1. + * + * Returns: + * 0: Success + * Else: Failure + *------------------------------------------------------------------------*/ +usb_error_t +usbd_req_clear_tt_buffer(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint) +{ + struct usb_device_request req; + uint16_t wValue; + + /* For single TT HUBs the port should be 1 */ + + if (udev->ddesc.bDeviceClass == UDCLASS_HUB && + udev->ddesc.bDeviceProtocol == UDPROTO_HSHUBSTT) + port = 1; + + wValue = (endpoint & 0xF) | ((addr & 0x7F) << 4) | + ((endpoint & 0x80) << 8) | ((type & 3) << 12); + + req.bmRequestType = UT_WRITE_CLASS_OTHER; + req.bRequest = UR_CLEAR_TT_BUFFER; + USETW(req.wValue, wValue); + req.wIndex[0] = port; + req.wIndex[1] = 0; + USETW(req.wLength, 0); + return (usbd_do_request(udev, mtx, &req, 0)); +} diff --git a/sys/dev/usb/usb_request.h b/sys/dev/usb/usb_request.h index 12f373d5fa5f..ac7a7c160b6b 100644 --- a/sys/dev/usb/usb_request.h +++ b/sys/dev/usb/usb_request.h @@ -85,5 +85,9 @@ usb_error_t usbd_req_set_hub_u2_timeout(struct usb_device *udev, struct mtx *mtx, uint8_t port, uint8_t timeout); usb_error_t usbd_req_set_hub_depth(struct usb_device *udev, struct mtx *mtx, uint16_t depth); +usb_error_t usbd_req_reset_tt(struct usb_device *udev, struct mtx *mtx, + uint8_t port); +usb_error_t usbd_req_clear_tt_buffer(struct usb_device *udev, struct mtx *mtx, + uint8_t port, uint8_t addr, uint8_t type, uint8_t endpoint); #endif /* _USB_REQUEST_H_ */ diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 5fd4f5a19a92..d4c2408db7c9 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2927,6 +2927,11 @@ usbd_ctrl_transfer_setup(struct usb_device *udev) */ usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX); + /* + * Reset clear stall error counter. + */ + udev->clear_stall_errors = 0; + /* * Try to setup a new USB transfer for the * default control endpoint: diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 8f6da7c68c81..91cd3fae3aaf 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -542,6 +542,7 @@ void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, struct mbuf *m, usb_size_t src_offset, usb_frlength_t src_len); void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len); +void usbd_start_re_enumerate(struct usb_device *udev); int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index a8524bed8747..dfef96348efe 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -44,6 +44,7 @@ #include #ifdef _KERNEL +#include #include #include #include From 165e30068eca33d6e882962c2641a8016be2d90a Mon Sep 17 00:00:00 2001 From: jkim Date: Mon, 6 Jun 2011 22:18:40 +0000 Subject: [PATCH 127/164] Revert r222152. The root cause was analysed and better fix is upcoming. Discussed with: delphij --- share/man/man4/atkbd.4 | 7 +------ sys/dev/atkbdc/atkbd.c | 3 --- sys/dev/atkbdc/atkbdreg.h | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/share/man/man4/atkbd.4 b/share/man/man4/atkbd.4 index 0c486e2eefbc..73831c2bb538 100644 --- a/share/man/man4/atkbd.4 +++ b/share/man/man4/atkbd.4 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 20, 2011 +.Dd January 29, 2008 .Dt ATKBD 4 .Os .Sh NAME @@ -176,11 +176,6 @@ When this option is given, the .Nm driver will not test the keyboard port during the probe routine. Some machines hang during boot when this test is performed. -.It bit 4 (PROBE_TYPEMATIC) -When this option is given, the -.Nm -driver will try to probe the keyboard typematic rate on boot. -Some machines hang during boot when this test is performed. .El .\".Sh FILES .Sh EXAMPLES diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 643554d1f4dd..600020fae6de 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -1097,9 +1097,6 @@ get_typematic(keyboard_t *kbd) x86regs_t regs; uint8_t *p; - if (!(kbd->kb_config & KB_CONF_PROBE_TYPEMATIC)) - return (ENODEV); - if (x86bios_get_intr(0x15) == 0 || x86bios_get_intr(0x16) == 0) return (ENODEV); diff --git a/sys/dev/atkbdc/atkbdreg.h b/sys/dev/atkbdc/atkbdreg.h index 3d54b4d70228..cf7ee6b31280 100644 --- a/sys/dev/atkbdc/atkbdreg.h +++ b/sys/dev/atkbdc/atkbdreg.h @@ -36,7 +36,6 @@ #define KB_CONF_NO_RESET (1 << 1) /* don't reset the keyboard */ #define KB_CONF_ALT_SCANCODESET (1 << 2) /* assume the XT type keyboard */ #define KB_CONF_NO_PROBE_TEST (1 << 3) /* don't test keyboard during probe */ -#define KB_CONF_PROBE_TYPEMATIC (1 << 4) /* probe keyboard typematic */ #ifdef _KERNEL From 969ea98a8c5c7a7edcaff07bfa96e0a59950b8f8 Mon Sep 17 00:00:00 2001 From: jkim Date: Mon, 6 Jun 2011 23:03:37 +0000 Subject: [PATCH 128/164] Validate INT 15h and 16h vectors more strictly. Traditionally these entry points are fixed addresses and (U)EFI CSM specification also mandated that. Unfortunately, (U)EFI CSM specification does not specifically mention this is to call service routine via interrupt vector table or to jump directly to the entry point. As a result, some CSM seems to install two routines and acts differently, depending on how it was executed, unfortunately. When INT 15h is used, it calls a function pointer (which is probably a UEFI service function). When it jumps directly to the entry point, it executes a simple and traditional INT 15h service routine. Therefore, actually there are two possible fixes, i. e., this fix or jumping directly to the fixed entry point. However, we chose this fix because a) keyboard typematic support via BIOS is becoming extremely rarer and b) we cannot support random service routine installed by a firmware or a boot loader. This should fix Lenovo X220 laptop, specifically. Reviewed by: delphij MFC after: 3 days --- sys/dev/atkbdc/atkbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index 600020fae6de..b7156cf1a699 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -1097,7 +1097,8 @@ get_typematic(keyboard_t *kbd) x86regs_t regs; uint8_t *p; - if (x86bios_get_intr(0x15) == 0 || x86bios_get_intr(0x16) == 0) + if (x86bios_get_intr(0x15) != 0xf000f859 || + x86bios_get_intr(0x16) != 0xf000e82e) return (ENODEV); /* Is BIOS system configuration table supported? */ From abeb826d0315f8dd4f0788338535b990b453adb6 Mon Sep 17 00:00:00 2001 From: jlaffaye Date: Mon, 6 Jun 2011 23:48:48 +0000 Subject: [PATCH 129/164] Add myself to committers-ports.dot Approved by: tabthorpe@ (mentor) --- share/misc/committers-ports.dot | 1 + 1 file changed, 1 insertion(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index bfe9f4ed9fd4..0bee309a49de 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -97,6 +97,7 @@ itetcu [label="Ion-Mihai Tetcu\nitetcu@FreeBSD.org\n2006/06/07"] jacula [label="Giuseppe Pilichi\njacula@FreeBSD.org\n2010/04/05"] jadawin [label="Philippe Audeoud\njadawin@FreeBSD.org\n2008/03/02"] jkim [label="Jung-uk Kim\njkim@FreeBSD.org\n2007/09/12"] +jlaffaye [label="Julien Laffaye\njlaffaye@FreeBSD.org\n2011/06/06"] jmelo [label="Jean Milanez Melo\njmelo@FreeBSD.org\n2006/03/31"] joerg [label="Joerg Wunsch\njoerg@FreeBSD.org\n1994/08/22"] johans [label="Johan Selst\njohans@FreeBSD.org\n2006/04/01"] From a37f8a9db40bc9fc463b113180b76dceb3589e73 Mon Sep 17 00:00:00 2001 From: marcel Date: Tue, 7 Jun 2011 00:39:15 +0000 Subject: [PATCH 130/164] Add ia64_sync_icache() and use it to make the I-cache coherent after loading the kernel's text segment. The kernel will do the same for loaded modules, so don't worry about that. --- sys/boot/ia64/common/Makefile | 2 +- sys/boot/ia64/common/exec.c | 2 ++ sys/boot/ia64/common/icache.c | 51 ++++++++++++++++++++++++++++++++++ sys/boot/ia64/common/libia64.h | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 sys/boot/ia64/common/icache.c diff --git a/sys/boot/ia64/common/Makefile b/sys/boot/ia64/common/Makefile index f16f13d7b0bc..d90898f71db7 100644 --- a/sys/boot/ia64/common/Makefile +++ b/sys/boot/ia64/common/Makefile @@ -6,7 +6,7 @@ MK_SSP= no LIB= ia64 INTERNALLIB= -SRCS= autoload.c bootinfo.c copy.c devicename.c exec.c +SRCS= autoload.c bootinfo.c copy.c devicename.c exec.c icache.c CFLAGS+= -I${.CURDIR}/../../efi/include CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH} diff --git a/sys/boot/ia64/common/exec.c b/sys/boot/ia64/common/exec.c index dd9c9ba05e63..65886fa87f93 100644 --- a/sys/boot/ia64/common/exec.c +++ b/sys/boot/ia64/common/exec.c @@ -258,6 +258,8 @@ ia64_loadseg(Elf_Ehdr *eh, Elf_Phdr *ph, uint64_t delta) if (ph->p_flags & PF_X) { ia64_text_start = ph->p_vaddr + delta; ia64_text_size = ph->p_memsz; + + ia64_sync_icache(ia64_text_start, ia64_text_size); } else { ia64_data_start = ph->p_vaddr + delta; ia64_data_size = ph->p_memsz; diff --git a/sys/boot/ia64/common/icache.c b/sys/boot/ia64/common/icache.c new file mode 100644 index 000000000000..77a35d705b76 --- /dev/null +++ b/sys/boot/ia64/common/icache.c @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2011 Marcel Moolenaar + * 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 ``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 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 +__FBSDID("$FreeBSD$"); + +#include +#include + +#include "libia64.h" + +void +ia64_sync_icache(vm_offset_t va, size_t sz) +{ + uintptr_t pa; + size_t cnt, max; + + while (sz > 0) { + max = sz; + pa = (uintptr_t)ia64_va2pa(va, &max); + for (cnt = 0; cnt < max; cnt += 32) + ia64_fc_i(pa + cnt); + ia64_sync_i(); + va += max; + sz -= max; + } + ia64_srlz_i(); +} diff --git a/sys/boot/ia64/common/libia64.h b/sys/boot/ia64/common/libia64.h index 29912f52fe1d..4bc76384dc34 100644 --- a/sys/boot/ia64/common/libia64.h +++ b/sys/boot/ia64/common/libia64.h @@ -64,6 +64,7 @@ void ia64_loadseg(void *, void *, uint64_t); ssize_t ia64_copyin(const void *, vm_offset_t, size_t); ssize_t ia64_copyout(vm_offset_t, void *, size_t); +void ia64_sync_icache(vm_offset_t, size_t); ssize_t ia64_readin(int, vm_offset_t, size_t); void *ia64_va2pa(vm_offset_t, size_t *); From 9a4ce80d984022d858758d706b82b9ee8f31455d Mon Sep 17 00:00:00 2001 From: marcel Date: Tue, 7 Jun 2011 00:59:31 +0000 Subject: [PATCH 131/164] o Bump the EFI loader version to 3.1. o Add the about, pbvm and reboot commands. o Trim the banner (suppress maker and date). --- sys/boot/ia64/efi/efimd.c | 32 ++++++++++++++++++++++++++++++++ sys/boot/ia64/efi/main.c | 37 ++++++++++++++++++++++++++++++++++--- sys/boot/ia64/efi/version | 2 ++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/sys/boot/ia64/efi/efimd.c b/sys/boot/ia64/efi/efimd.c index 0f7f02a08374..0b29e1280ce0 100644 --- a/sys/boot/ia64/efi/efimd.c +++ b/sys/boot/ia64/efi/efimd.c @@ -230,3 +230,35 @@ ia64_platform_enter(const char *kernel) return (0); } + +COMMAND_SET(pbvm, "pbvm", "show PBVM details", command_pbvm); + +static int +command_pbvm(int argc, char *argv[]) +{ + uint64_t limit, pg, start; + u_int idx; + + printf("Page table @ %p, size %x\n", ia64_pgtbl, ia64_pgtblsz); + + if (ia64_pgtbl == NULL) + return (0); + + limit = ~0; + start = ~0; + idx = 0; + while (ia64_pgtbl[idx] != 0) { + pg = ia64_pgtbl[idx]; + if (pg != limit) { + if (start != ~0) + printf("%#lx-%#lx\n", start, limit); + start = pg; + } + limit = pg + IA64_PBVM_PAGE_SIZE; + idx++; + } + if (start != ~0) + printf("%#lx-%#lx\n", start, limit); + + return (0); +} diff --git a/sys/boot/ia64/efi/main.c b/sys/boot/ia64/efi/main.c index 485a26d54842..ec12b4266a07 100644 --- a/sys/boot/ia64/efi/main.c +++ b/sys/boot/ia64/efi/main.c @@ -153,9 +153,7 @@ main(int argc, CHAR16 *argv[]) */ cons_probe(); - printf("\n"); - printf("%s, Revision %s\n", bootprog_name, bootprog_rev); - printf("(%s, %s)\n", bootprog_maker, bootprog_date); + printf("\n%s, Revision %s\n", bootprog_name, bootprog_rev); find_pal_proc(); @@ -214,6 +212,18 @@ static int command_quit(int argc, char *argv[]) { exit(0); + /* NOTREACHED */ + return (CMD_OK); +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + + RS->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL); + /* NOTREACHED */ return (CMD_OK); } @@ -585,3 +595,24 @@ command_hcdp(int argc, char *argv[]) printf("\n"); return (CMD_OK); } + +COMMAND_SET(about, "about", "about the loader", command_about); + +extern uint64_t _start_plabel[]; + +static int +command_about(int argc, char *argv[]) +{ + EFI_LOADED_IMAGE *img; + + printf("%s\n", bootprog_name); + printf("revision %s\n", bootprog_rev); + printf("built by %s\n", bootprog_maker); + printf("built on %s\n", bootprog_date); + + printf("\n"); + + BS->HandleProtocol(IH, &imgid, (VOID**)&img); + printf("image loaded at %p\n", img->ImageBase); + printf("entry at %#lx (%#lx)\n", _start_plabel[0], _start_plabel[1]); +} diff --git a/sys/boot/ia64/efi/version b/sys/boot/ia64/efi/version index 3a947c8c5639..17d14ea1c70b 100644 --- a/sys/boot/ia64/efi/version +++ b/sys/boot/ia64/efi/version @@ -3,6 +3,8 @@ $FreeBSD$ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. +3.1: Add the about, reboot and pbvm commands. + I-cache coherency is maintained. 3.0: Add support for PBVM. 2.2: Create direct mapping based on start address instead of mapping first 256M. From 2bf7ed6fc0e8d175dd13da2f68d538ee3facb919 Mon Sep 17 00:00:00 2001 From: marcel Date: Tue, 7 Jun 2011 01:06:49 +0000 Subject: [PATCH 132/164] Call set_cputicker() to have the time counter use the ITC register. Note that the ITC frequency is fixed. --- sys/ia64/ia64/machdep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index fc7df7a95289..1463fb5c327e 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -786,6 +786,8 @@ ia64_init(void) ia64_sal_init(); calculate_frequencies(); + set_cputicker(ia64_get_itc, (u_long)itc_freq * 1000000, 0); + /* * Setup the PCPU data for the bootstrap processor. It is needed * by printf(). Also, since printf() has critical sections, we From 36b8c5d486fa809443a7d522780bf3c5a6f70393 Mon Sep 17 00:00:00 2001 From: marcel Date: Tue, 7 Jun 2011 01:28:12 +0000 Subject: [PATCH 133/164] Fix making kernel dumps from the debugger by creating a command for it. Do not not expect a developer to call doadump(). Calling doadump does not necessarily work when it's declared static. Nor does it necessarily do what was intended in the context of text dumps. The dump command always creates a core dump. Move printing of error messages from doadump to the dump command, now that we don't have to worry about being called from DDB. --- sys/ddb/db_command.c | 24 ++++++++++++++++++++++++ sys/kern/kern_shutdown.c | 30 ++++++++++++++++-------------- sys/sys/conf.h | 1 + 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 21cb7c5940de..f2e2c42accab 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -64,6 +65,7 @@ db_addr_t db_last_addr; db_addr_t db_prev; db_addr_t db_next; +static db_cmdfcn_t db_dump; static db_cmdfcn_t db_fncall; static db_cmdfcn_t db_gdb; static db_cmdfcn_t db_halt; @@ -102,6 +104,7 @@ static struct command db_cmds[] = { { "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 }, { "delete", db_delete_cmd, 0, 0 }, { "d", db_delete_cmd, 0, 0 }, + { "dump", db_dump, 0, 0 }, { "break", db_breakpoint_cmd, 0, 0 }, { "b", db_breakpoint_cmd, 0, 0 }, { "dwatch", db_deletewatch_cmd, 0, 0 }, @@ -526,6 +529,27 @@ db_error(s) kdb_reenter(); } +static void +db_dump(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4) +{ + int error; + + error = doadump(FALSE); + if (error) { + db_printf("Cannot dump: "); + switch (error) { + case EBUSY: + db_printf("debugger got invoked while dumping.\n"); + break; + case ENXIO: + db_printf("no dump device specified.\n"); + break; + default: + db_printf("unknown error (error=%d).\n", error); + break; + } + } +} /* * Call random function: diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 001da3da8449..da041faf99a8 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -233,30 +233,32 @@ print_uptime(void) printf("%lds\n", (long)ts.tv_sec); } -static void -doadump(void) +int +doadump(boolean_t textdump) { + boolean_t coredump; - /* - * Sometimes people have to call this from the kernel debugger. - * (if 'panic' can not dump) - * Give them a clue as to why they can't dump. - */ - if (dumper.dumper == NULL) { - printf("Cannot dump. Device not defined or unavailable.\n"); - return; - } + if (dumping) + return (EBUSY); + if (dumper.dumper == NULL) + return (ENXIO); savectx(&dumppcb); dumptid = curthread->td_tid; dumping++; + + coredump = TRUE; #ifdef DDB - if (textdump_pending) + if (textdump && textdump_pending) { + coredump = FALSE; textdump_dumpsys(&dumper); - else + } #endif + if (coredump) dumpsys(&dumper); + dumping--; + return (0); } static int @@ -425,7 +427,7 @@ kern_reboot(int howto) EVENTHANDLER_INVOKE(shutdown_post_sync, howto); if ((howto & (RB_HALT|RB_DUMP)) == RB_DUMP && !cold && !dumping) - doadump(); + doadump(TRUE); /* Now that we're going to really halt the system... */ EVENTHANDLER_INVOKE(shutdown_final, howto); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 31fd34dc47ab..0c7ed41c3c41 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -332,6 +332,7 @@ struct dumperinfo { int set_dumper(struct dumperinfo *); int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); void dumpsys(struct dumperinfo *); +int doadump(boolean_t); extern int dumping; /* system is dumping */ #endif /* _KERNEL */ From fc6d16c51a63bc3546bee06416e71d6dc1f1e6dd Mon Sep 17 00:00:00 2001 From: davidxu Date: Tue, 7 Jun 2011 02:50:14 +0000 Subject: [PATCH 134/164] Use p4prio_to_tsprio to calculate TS priority instead of using p4prio_to_rtpprio which is for RT priority. PR: kern/157657 Submitted by: krivenok.dmitry at gmail dot com MFC after: 3 days --- sys/kern/ksched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c index 7ee56d50b13b..799b60d1a139 100644 --- a/sys/kern/ksched.c +++ b/sys/kern/ksched.c @@ -206,7 +206,7 @@ ksched_setscheduler(struct ksched *ksched, if (param->sched_priority >= 0 && param->sched_priority <= (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) { rtp.type = RTP_PRIO_NORMAL; - rtp.prio = p4prio_to_rtpprio(param->sched_priority); + rtp.prio = p4prio_to_tsprio(param->sched_priority); rtp_to_pri(&rtp, td); } else e = EINVAL; From e58c149ca2067cb8717e0849b2b37e4791eedb89 Mon Sep 17 00:00:00 2001 From: marcel Date: Tue, 7 Jun 2011 04:38:33 +0000 Subject: [PATCH 135/164] Lower WARNS level to 3 to eliminate alignment warnings related to casting inherent in CMSG_DATA(). --- usr.sbin/rtsold/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile index c7c93af58bd5..efc322c673be 100644 --- a/usr.sbin/rtsold/Makefile +++ b/usr.sbin/rtsold/Makefile @@ -19,6 +19,7 @@ MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c +WARNS?= 3 CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H DPADD= ${LIBKVM} LDADD= -lkvm From 048adb69c7c57c1cc5c423e5118cbc3e1176c3e7 Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 7 Jun 2011 05:04:37 +0000 Subject: [PATCH 136/164] Set pca.p_bufr to NULL when we haven't allocated a buffer. Otherwise, p_bufr is set to garbage on the stack, and if that garbage happens to be non-NULL, and the TOLOG or TOCONS flag is set, putbuf() will get called and attempt to fill the non-existent buffer. This is really only relevant for tprintf() (and only when the priority is not -1), but set it in uprintf() and ttyprintf() for completeness. The next step, to avoid log buffer scrambling, would be to add the PRINTF_BUFR_SIZE code to tprintf(), but this should prevent panics. Submitted by: rmacklem Found by: pho --- sys/kern/subr_prf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 3334837747f5..48f2dd9ce8af 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -163,6 +163,7 @@ uprintf(const char *fmt, ...) goto out; } pca.flags = TOTTY; + pca.p_bufr = NULL; va_start(ap, fmt); tty_lock(pca.tty); retval = kvprintf(fmt, putchar, &pca, 10, ap); @@ -206,6 +207,7 @@ tprintf(struct proc *p, int pri, const char *fmt, ...) pca.pri = pri; pca.tty = tp; pca.flags = flags; + pca.p_bufr = NULL; va_start(ap, fmt); if (pca.tty != NULL) tty_lock(pca.tty); @@ -234,6 +236,7 @@ ttyprintf(struct tty *tp, const char *fmt, ...) va_start(ap, fmt); pca.tty = tp; pca.flags = TOTTY; + pca.p_bufr = NULL; retval = kvprintf(fmt, putchar, &pca, 10, ap); va_end(ap); return (retval); From effca0c0196c2c3b53ca3c7fb6b4cf9999de0f55 Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 7 Jun 2011 06:18:02 +0000 Subject: [PATCH 137/164] amdsbwd: update to support SB8xx southbridges Many thanks to Tino for drawing my attention to this, for doing a lot of testing and providing great feedback. Many thanks to AMD for continuing to release public specifications for their chipsets. PR: kern/157568 Tested by: Tino MFC after: 1 week --- share/man/man4/amdsbwd.4 | 6 +- sys/dev/amdsbwd/amdsbwd.c | 184 ++++++++++++++++++++++++++++---------- 2 files changed, 140 insertions(+), 50 deletions(-) diff --git a/share/man/man4/amdsbwd.4 b/share/man/man4/amdsbwd.4 index 578640b2d9f9..cfb2f79624d8 100644 --- a/share/man/man4/amdsbwd.4 +++ b/share/man/man4/amdsbwd.4 @@ -25,12 +25,12 @@ .\" .\" $FreeBSD$ .\" -.Dd November 30, 2009 +.Dd June 7, 2011 .Dt AMDSBWD 4 .Os .Sh NAME .Nm amdsbwd -.Nd device driver for the AMD SB600/SB700/SB710/SB750 watchdog timer +.Nd device driver for the AMD SB600/SB7xx/SB8xx watchdog timers .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -51,7 +51,7 @@ The driver provides .Xr watchdog 4 support for the watchdog timers present on -AMD SB600 and SB7xx south bridge chips. +AMD SB600, SB7xx and SB8xx southbridges. .Sh SEE ALSO .Xr watchdog 4 , .Xr watchdog 8 , diff --git a/sys/dev/amdsbwd/amdsbwd.c b/sys/dev/amdsbwd/amdsbwd.c index f5f0f879d605..4256381f5312 100644 --- a/sys/dev/amdsbwd/amdsbwd.c +++ b/sys/dev/amdsbwd/amdsbwd.c @@ -25,8 +25,8 @@ */ /* - * This is a driver for watchdog timer present in AMD SB600/SB7xx - * south bridges and other watchdog timers advertised via WDRT ACPI table. + * This is a driver for watchdog timer present in AMD SB600/SB7xx/SB8xx + * southbridges. * Please see the following specifications for the descriptions of the * registers and flags: * - AMD SB600 Register Reference Guide, Public Version, Rev. 3.03 (SB600 RRG) @@ -35,11 +35,13 @@ * http://developer.amd.com/assets/43009_sb7xx_rrg_pub_1.00.pdf * - AMD SB700/710/750 Register Programming Requirements (RPR) * http://developer.amd.com/assets/42413_sb7xx_rpr_pub_1.00.pdf + * - AMD SB800-Series Southbridges Register Reference Guide (RRG) + * http://support.amd.com/us/Embedded_TechDocs/45482.pdf * Please see the following for Watchdog Resource Table specification: * - Watchdog Timer Hardware Requirements for Windows Server 2003 (WDRT) * http://www.microsoft.com/whdc/system/sysinternals/watchdog.mspx - * AMD SB600/SB7xx watchdog hardware seems to conform to the above, - * but my system doesn't provide the table. + * AMD SB600/SB7xx/SB8xx watchdog hardware seems to conform to the above + * specifications, but the table hasn't been spotted in the wild yet. */ #include @@ -59,15 +61,15 @@ __FBSDID("$FreeBSD$"); #include #include -/* RRG 2.3.3.1.1, page 161. */ +/* SB7xx RRG 2.3.3.1.1. */ #define AMDSB_PMIO_INDEX 0xcd6 #define AMDSB_PMIO_DATA (PMIO_INDEX + 1) #define AMDSB_PMIO_WIDTH 2 -/* RRG 2.3.3.2, page 181. */ +/* SB7xx RRG 2.3.3.2. */ #define AMDSB_PM_RESET_STATUS0 0x44 #define AMDSB_PM_RESET_STATUS1 0x45 #define AMDSB_WD_RST_STS 0x02 -/* RRG 2.3.3.2, page 188; RPR 2.36, page 30. */ +/* SB7xx RRG 2.3.3.2, RPR 2.36. */ #define AMDSB_PM_WDT_CTRL 0x69 #define AMDSB_WDT_DISABLE 0x01 #define AMDSB_WDT_RES_MASK (0x02 | 0x04) @@ -77,7 +79,18 @@ __FBSDID("$FreeBSD$"); #define AMDSB_WDT_RES_1S 0x06 #define AMDSB_PM_WDT_BASE_LSB 0x6c #define AMDSB_PM_WDT_BASE_MSB 0x6f -/* RRG 2.3.4, page 223, WDRT. */ +/* SB8xx RRG 2.3.3. */ +#define AMDSB8_PM_WDT_EN 0x48 +#define AMDSB8_WDT_DEC_EN 0x01 +#define AMDSB8_WDT_DISABLE 0x02 +#define AMDSB8_PM_WDT_CTRL 0x4c +#define AMDSB8_WDT_32KHZ 0x00 +#define AMDSB8_WDT_1HZ 0x03 +#define AMDSB8_WDT_RES_MASK 0x03 +#define AMDSB8_PM_RESET_STATUS0 0xC0 +#define AMDSB8_PM_RESET_STATUS1 0xC1 +#define AMDSB8_WD_RST_STS 0x20 +/* SB7xx RRG 2.3.4, WDRT. */ #define AMDSB_WD_CTRL 0x00 #define AMDSB_WD_RUN 0x01 #define AMDSB_WD_FIRED 0x02 @@ -90,8 +103,9 @@ __FBSDID("$FreeBSD$"); #define AMDSB_WDIO_REG_WIDTH 4 /* WDRT */ #define MAXCOUNT_MIN_VALUE 511 -/* RRG 2.3.1.1, page 122; SB600 RRG 2.3.1.1, page 97. */ -#define AMDSB7xx_SMBUS_DEVID 0x43851002 +/* SB7xx RRG 2.3.1.1, SB600 RRG 2.3.1.1, SB8xx RRG 2.3.1. */ +#define AMDSB_SMBUS_DEVID 0x43851002 +#define AMDSB8_SMBUS_REVID 0x40 #define amdsbwd_verbose_printf(dev, ...) \ do { \ @@ -265,7 +279,7 @@ amdsbwd_identify(driver_t *driver, device_t parent) smb_dev = pci_find_bsf(0, 20, 0); if (smb_dev == NULL) return; - if (pci_get_devid(smb_dev) != AMDSB7xx_SMBUS_DEVID) + if (pci_get_devid(smb_dev) != AMDSB_SMBUS_DEVID) return; child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "amdsbwd", -1); @@ -273,15 +287,102 @@ amdsbwd_identify(driver_t *driver, device_t parent) device_printf(parent, "add amdsbwd child failed\n"); } + +static void +amdsbwd_probe_sb7xx(device_t dev, struct resource *pmres, uint32_t *addr) +{ + uint32_t val; + int i; + + /* Report cause of previous reset for user's convenience. */ + val = pmio_read(pmres, AMDSB_PM_RESET_STATUS0); + if (val != 0) + amdsbwd_verbose_printf(dev, "ResetStatus0 = %#04x\n", val); + val = pmio_read(pmres, AMDSB_PM_RESET_STATUS1); + if (val != 0) + amdsbwd_verbose_printf(dev, "ResetStatus1 = %#04x\n", val); + if ((val & AMDSB_WD_RST_STS) != 0) + device_printf(dev, "Previous Reset was caused by Watchdog\n"); + + /* Find base address of memory mapped WDT registers. */ + for (*addr = 0, i = 0; i < 4; i++) { + *addr <<= 8; + *addr |= pmio_read(pmres, AMDSB_PM_WDT_BASE_MSB - i); + } + /* Set watchdog timer tick to 1s. */ + val = pmio_read(pmres, AMDSB_PM_WDT_CTRL); + val &= ~AMDSB_WDT_RES_MASK; + val |= AMDSB_WDT_RES_10MS; + pmio_write(pmres, AMDSB_PM_WDT_CTRL, val); + + /* Enable watchdog device (in stopped state). */ + val = pmio_read(pmres, AMDSB_PM_WDT_CTRL); + val &= ~AMDSB_WDT_DISABLE; + pmio_write(pmres, AMDSB_PM_WDT_CTRL, val); + + /* + * XXX TODO: Ensure that watchdog decode is enabled + * (register 0x41, bit 3). + */ + device_set_desc(dev, "AMD SB600/SB7xx Watchdog Timer"); +} + +static void +amdsbwd_probe_sb8xx(device_t dev, struct resource *pmres, uint32_t *addr) +{ + uint32_t val; + int i; + + /* Report cause of previous reset for user's convenience. */ + val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS0); + if (val != 0) + amdsbwd_verbose_printf(dev, "ResetStatus0 = %#04x\n", val); + val = pmio_read(pmres, AMDSB8_PM_RESET_STATUS1); + if (val != 0) + amdsbwd_verbose_printf(dev, "ResetStatus1 = %#04x\n", val); + if ((val & AMDSB8_WD_RST_STS) != 0) + device_printf(dev, "Previous Reset was caused by Watchdog\n"); + + /* Find base address of memory mapped WDT registers. */ + for (*addr = 0, i = 0; i < 4; i++) { + *addr <<= 8; + *addr |= pmio_read(pmres, AMDSB8_PM_WDT_EN + 3 - i); + } + *addr &= ~0x07u; + + /* Set watchdog timer tick to 1s. */ + val = pmio_read(pmres, AMDSB8_PM_WDT_CTRL); + val &= ~AMDSB8_WDT_RES_MASK; + val |= AMDSB8_WDT_1HZ; + pmio_write(pmres, AMDSB8_PM_WDT_CTRL, val); +#ifdef AMDSBWD_DEBUG + val = pmio_read(pmres, AMDSB8_PM_WDT_CTRL); + amdsbwd_verbose_printf(dev, "AMDSB8_PM_WDT_CTRL value = %#02x\n", val); +#endif + + /* + * Enable watchdog device (in stopped state) + * and decoding of its address. + */ + val = pmio_read(pmres, AMDSB8_PM_WDT_EN); + val &= ~AMDSB8_WDT_DISABLE; + val |= AMDSB8_WDT_DEC_EN; + pmio_write(pmres, AMDSB8_PM_WDT_EN, val); +#ifdef AMDSBWD_DEBUG + val = pmio_read(pmres, AMDSB8_PM_WDT_EN); + device_printf(dev, "AMDSB8_PM_WDT_EN value = %#02x\n", val); +#endif + device_set_desc(dev, "AMD SB8xx Watchdog Timer"); +} + static int amdsbwd_probe(device_t dev) { struct resource *res; + device_t smb_dev; uint32_t addr; - uint32_t val; int rid; int rc; - int i; /* Do not claim some ISA PnP device by accident. */ if (isa_get_logicalid(dev) != 0) @@ -301,21 +402,16 @@ amdsbwd_probe(device_t dev) return (ENXIO); } - /* Report cause of previous reset for user's convenience. */ - val = pmio_read(res, AMDSB_PM_RESET_STATUS0); - if (val != 0) - amdsbwd_verbose_printf(dev, "ResetStatus0 = %#04x\n", val); - val = pmio_read(res, AMDSB_PM_RESET_STATUS1); - if (val != 0) - amdsbwd_verbose_printf(dev, "ResetStatus1 = %#04x\n", val); - if ((val & AMDSB_WD_RST_STS) != 0) - device_printf(dev, "Previous Reset was caused by Watchdog\n"); + smb_dev = pci_find_bsf(0, 20, 0); + KASSERT(smb_dev != NULL, ("can't find SMBus PCI device\n")); + if (pci_get_revid(smb_dev) < AMDSB8_SMBUS_REVID) + amdsbwd_probe_sb7xx(dev, res, &addr); + else + amdsbwd_probe_sb8xx(dev, res, &addr); + + bus_release_resource(dev, SYS_RES_IOPORT, rid, res); + bus_delete_resource(dev, SYS_RES_IOPORT, rid); - /* Find base address of memory mapped WDT registers. */ - for (addr = 0, i = 0; i < 4; i++) { - addr <<= 8; - addr |= pmio_read(res, AMDSB_PM_WDT_BASE_MSB - i); - } amdsbwd_verbose_printf(dev, "memory base address = %#010x\n", addr); rc = bus_set_resource(dev, SYS_RES_MEMORY, 0, addr + AMDSB_WD_CTRL, AMDSB_WDIO_REG_WIDTH); @@ -330,36 +426,25 @@ amdsbwd_probe(device_t dev) return (ENXIO); } - /* Set watchdog timer tick to 10ms. */ - val = pmio_read(res, AMDSB_PM_WDT_CTRL); - val &= ~AMDSB_WDT_RES_MASK; - val |= AMDSB_WDT_RES_10MS; - pmio_write(res, AMDSB_PM_WDT_CTRL, val); - - /* Enable watchdog device (in stopped state). */ - val = pmio_read(res, AMDSB_PM_WDT_CTRL); - val &= ~AMDSB_WDT_DISABLE; - pmio_write(res, AMDSB_PM_WDT_CTRL, val); - - /* - * XXX TODO: Ensure that watchdog decode is enabled - * (register 0x41, bit 3). - */ - bus_release_resource(dev, SYS_RES_IOPORT, rid, res); - bus_delete_resource(dev, SYS_RES_IOPORT, rid); - - device_set_desc(dev, "AMD SB600/SB7xx Watchdog Timer"); return (0); } static int amdsbwd_attach_sb(device_t dev, struct amdsbwd_softc *sc) { + device_t smb_dev; + sc->max_ticks = UINT16_MAX; - sc->ms_per_tick = 10; sc->rid_ctrl = 0; sc->rid_count = 1; + smb_dev = pci_find_bsf(0, 20, 0); + KASSERT(smb_dev != NULL, ("can't find SMBus PCI device\n")); + if (pci_get_revid(smb_dev) < AMDSB8_SMBUS_REVID) + sc->ms_per_tick = 10; + else + sc->ms_per_tick = 1000; + sc->res_ctrl = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid_ctrl, RF_ACTIVE); if (sc->res_ctrl == NULL) { @@ -388,6 +473,11 @@ amdsbwd_attach(device_t dev) if (rc != 0) goto fail; +#ifdef AMDSBWD_DEBUG + device_printf(dev, "wd ctrl = %#04x\n", wdctrl_read(sc)); + device_printf(dev, "wd count = %#04x\n", wdcount_read(sc)); +#endif + /* Setup initial state of Watchdog Control. */ wdctrl_write(sc, AMDSB_WD_FIRED); From fa6e151ccb8412e23311b21d126564de84e84e49 Mon Sep 17 00:00:00 2001 From: ae Date: Tue, 7 Jun 2011 06:42:29 +0000 Subject: [PATCH 138/164] Make a behaviour of the libalias based in-kernel NAT a bit closer to how natd(8) does work. natd(8) drops packets only when libalias returns PKT_ALIAS_IGNORED and "deny_incoming" option is set, but ipfw_nat always did drop packets that were not aliased, even if they should not be aliased and just are going through. PR: kern/122109, kern/129093, kern/157379 Submitted by: Alexander V. Chernikov (previous version) MFC after: 1 month --- sys/netinet/ipfw/ip_fw_nat.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sys/netinet/ipfw/ip_fw_nat.c b/sys/netinet/ipfw/ip_fw_nat.c index f8c3e63ec235..fd6f09afdf88 100644 --- a/sys/netinet/ipfw/ip_fw_nat.c +++ b/sys/netinet/ipfw/ip_fw_nat.c @@ -262,17 +262,27 @@ ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m) else retval = LibAliasOut(t->lib, c, mcl->m_len + M_TRAILINGSPACE(mcl)); - if (retval == PKT_ALIAS_RESPOND) { - m->m_flags |= M_SKIP_FIREWALL; - retval = PKT_ALIAS_OK; - } - if (retval != PKT_ALIAS_OK && - retval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) { + + /* + * We drop packet when: + * 1. libalias returns PKT_ALIAS_ERROR; + * 2. For incoming packets: + * a) for unresolved fragments; + * b) libalias returns PKT_ALIAS_IGNORED and + * PKT_ALIAS_DENY_INCOMING flag is set. + */ + if (retval == PKT_ALIAS_ERROR || + (args->oif == NULL && (retval == PKT_ALIAS_UNRESOLVED_FRAGMENT || + (retval == PKT_ALIAS_IGNORED && + (t->lib->packetAliasMode & PKT_ALIAS_DENY_INCOMING) != 0)))) { /* XXX - should i add some logging? */ m_free(mcl); args->m = NULL; return (IP_FW_DENY); } + + if (retval == PKT_ALIAS_RESPOND) + m->m_flags |= M_SKIP_FIREWALL; mcl->m_pkthdr.len = mcl->m_len = ntohs(ip->ip_len); /* From 05949f8eec0a83977ca38d3d2bf7bd600abbda72 Mon Sep 17 00:00:00 2001 From: ae Date: Tue, 7 Jun 2011 06:48:42 +0000 Subject: [PATCH 139/164] Sync ng_nat with recent (r222806) ipfw_nat changes: Make a behaviour of the libalias based in-kernel NAT a bit closer to how natd(8) does work. natd(8) drops packets only when libalias returns PKT_ALIAS_IGNORED and "deny_incoming" option is set, but ipfw_nat always did drop packets that were not aliased, even if they should not be aliased and just are going through. Also add SCTP support: mark response packets to skip firewall processing. MFC after: 1 month --- sys/netgraph/ng_nat.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c index 84da50057494..59818d9ced83 100644 --- a/sys/netgraph/ng_nat.c +++ b/sys/netgraph/ng_nat.c @@ -43,6 +43,7 @@ #include #include +#include #include #include @@ -696,22 +697,35 @@ ng_nat_rcvdata(hook_p hook, item_p item ) KASSERT(m->m_pkthdr.len == ntohs(ip->ip_len), ("ng_nat: ip_len != m_pkthdr.len")); + /* + * We drop packet when: + * 1. libalias returns PKT_ALIAS_ERROR; + * 2. For incoming packets: + * a) for unresolved fragments; + * b) libalias returns PKT_ALIAS_IGNORED and + * PKT_ALIAS_DENY_INCOMING flag is set. + */ if (hook == priv->in) { rval = LibAliasIn(priv->lib, c, m->m_len + M_TRAILINGSPACE(m)); - if (rval != PKT_ALIAS_OK && - rval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) { + if (rval == PKT_ALIAS_ERROR || + rval == PKT_ALIAS_UNRESOLVED_FRAGMENT || + (rval == PKT_ALIAS_IGNORED && + (priv->lib->packetAliasMode & + PKT_ALIAS_DENY_INCOMING) != 0)) { NG_FREE_ITEM(item); return (EINVAL); } } else if (hook == priv->out) { rval = LibAliasOut(priv->lib, c, m->m_len + M_TRAILINGSPACE(m)); - if (rval != PKT_ALIAS_OK) { + if (rval == PKT_ALIAS_ERROR) { NG_FREE_ITEM(item); return (EINVAL); } } else panic("ng_nat: unknown hook!\n"); + if (rval == PKT_ALIAS_RESPOND) + m->m_flags |= M_SKIP_FIREWALL; m->m_pkthdr.len = m->m_len = ntohs(ip->ip_len); if ((ip->ip_off & htons(IP_OFFMASK)) == 0 && From 6ed4191fed49dda0af9b5b47c3fdd5814082ab72 Mon Sep 17 00:00:00 2001 From: ae Date: Tue, 7 Jun 2011 06:57:22 +0000 Subject: [PATCH 140/164] Fix indentation. --- sys/netinet/libalias/alias_sctp.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/libalias/alias_sctp.h b/sys/netinet/libalias/alias_sctp.h index 80ed96568d4d..99d54cebedb0 100644 --- a/sys/netinet/libalias/alias_sctp.h +++ b/sys/netinet/libalias/alias_sctp.h @@ -135,13 +135,13 @@ struct sctp_nat_assoc { struct in_addr a_addr; /**< alias ip address */ int state; /**< current state of NAT association */ int TableRegister; /**< stores which look up tables association is registered in */ - int exp; /**< timer expiration in seconds from uptime */ + int exp; /**< timer expiration in seconds from uptime */ int exp_loc; /**< current location in timer_Q */ int num_Gaddr; /**< number of global IP addresses in the list */ LIST_HEAD(sctpGlobalAddresshead,sctp_GlobalAddress) Gaddr; /**< List of global addresses */ - LIST_ENTRY (sctp_nat_assoc) list_L; /**< Linked list of pointers for Local table*/ - LIST_ENTRY (sctp_nat_assoc) list_G; /**< Linked list of pointers for Global table */ - LIST_ENTRY (sctp_nat_assoc) timer_Q; /**< Linked list of pointers for timer Q */ + LIST_ENTRY (sctp_nat_assoc) list_L; /**< Linked list of pointers for Local table*/ + LIST_ENTRY (sctp_nat_assoc) list_G; /**< Linked list of pointers for Global table */ + LIST_ENTRY (sctp_nat_assoc) timer_Q; /**< Linked list of pointers for timer Q */ //Using libalias locking }; From 31094255fe572e23d1185fe30c7cb7dd837b7644 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 7 Jun 2011 08:05:23 +0000 Subject: [PATCH 141/164] Bring back the number of CPU to 32. --- sys/amd64/include/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h index 92689bae21ab..9a742f94e9b9 100644 --- a/sys/amd64/include/param.h +++ b/sys/amd64/include/param.h @@ -64,7 +64,7 @@ #endif #if defined(SMP) || defined(KLD_MODULE) -#define MAXCPU 64 +#define MAXCPU 32 #else #define MAXCPU 1 #endif From 26b13e5947d52403de10c549512dc87c0c071568 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 7 Jun 2011 08:07:41 +0000 Subject: [PATCH 142/164] Add an UPDATE entry. --- UPDATING | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UPDATING b/UPDATING index 1ff9e8ffb76d..3fa4c088fb22 100644 --- a/UPDATING +++ b/UPDATING @@ -22,6 +22,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110607: + cpumask_t type is retired and cpuset_t is used in order to describe + a mask of CPUs. + 20110513: Support for sun4v architecture is officially dropped From 93df1e105fd6e42a31566d7a346eb633c693ae89 Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 7 Jun 2011 09:03:28 +0000 Subject: [PATCH 143/164] Flesh out a new HAL method to fetch the radar PHY error frame information. For the AR5211/AR5212, this is apparently a one byte pulse duration counter value. It is only coded up here for the AR5212 as I don't have any AR5211-series hardware to test it on. This information was extracted from the Madwifi DFS branch along with some local additions. Please note - all this does is extract out the radar event duration, it in no way reflects the presence of a radar. Further code is needed to take a set of radar events and filter them to extract out correct radar pulse trains (and ignore other events.) For further information, please see: http://wiki.freebsd.org/dev/ath_hal%284%29/RadarDetection This includes references to the relevant patents which describe what is going on. Obtained from: Madwifi --- sys/dev/ath/ath_hal/ah.h | 14 +++++++ sys/dev/ath/ath_hal/ar5212/ar5212.h | 3 ++ sys/dev/ath/ath_hal/ar5212/ar5212_attach.c | 1 + sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 44 ++++++++++++++++++++++ sys/dev/ath/ath_hal/ar5416/ar5416.h | 3 ++ sys/dev/ath/ath_hal/ar5416/ar5416_attach.c | 1 + sys/dev/ath/ath_hal/ar5416/ar5416_misc.c | 16 ++++++++ sys/dev/ath/if_athvar.h | 2 + 8 files changed, 84 insertions(+) diff --git a/sys/dev/ath/ath_hal/ah.h b/sys/dev/ath/ath_hal/ah.h index 165d919d03d8..7a01be354436 100644 --- a/sys/dev/ath/ath_hal/ah.h +++ b/sys/dev/ath/ath_hal/ah.h @@ -745,6 +745,17 @@ typedef enum { HAL_QUIET_ADD_SWBA_RESP_TIME = 0x4, /* add beacon response time to next_start offset */ } HAL_QUIET_FLAG; +#define HAL_DFS_EVENT_PRICH 0x0000001 + +struct dfs_event { + uint64_t re_full_ts; /* 64-bit full timestamp from interrupt time */ + uint32_t re_ts; /* Original 15 bit recv timestamp */ + uint8_t re_rssi; /* rssi of radar event */ + uint8_t re_dur; /* duration of radar pulse */ + uint32_t re_flags; /* Flags (see above) */ +}; +typedef struct dfs_event HAL_DFS_EVENT; + /* * Hardware Access Layer (HAL) API. * @@ -928,6 +939,9 @@ struct ath_hal { HAL_PHYERR_PARAM *pe); void __ahdecl(*ah_getDfsThresh)(struct ath_hal *ah, HAL_PHYERR_PARAM *pe); + HAL_BOOL __ahdecl(*ah_procRadarEvent)(struct ath_hal *ah, + struct ath_rx_status *rxs, uint64_t fulltsf, + const char *buf, HAL_DFS_EVENT *event); /* Key Cache Functions */ uint32_t __ahdecl(*ah_getKeyCacheSize)(struct ath_hal*); diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212.h b/sys/dev/ath/ath_hal/ar5212/ar5212.h index 16394a396f11..8503a629aa36 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212.h +++ b/sys/dev/ath/ath_hal/ar5212/ar5212.h @@ -622,5 +622,8 @@ extern HAL_BOOL ar5212IsNFCalInProgress(struct ath_hal *ah); extern HAL_BOOL ar5212WaitNFCalComplete(struct ath_hal *ah, int i); extern void ar5212EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe); extern void ar5212GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe); +extern HAL_BOOL ar5212ProcessRadarEvent(struct ath_hal *ah, + struct ath_rx_status *rxs, uint64_t fulltsf, const char *buf, + HAL_DFS_EVENT *event); #endif /* _ATH_AR5212_H_ */ diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c b/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c index 5999a603f9ca..8e7f3cbddf04 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_attach.c @@ -132,6 +132,7 @@ static const struct ath_hal_private ar5212hal = {{ /* DFS Functions */ .ah_enableDfs = ar5212EnableDfs, .ah_getDfsThresh = ar5212GetDfsThresh, + .ah_procRadarEvent = ar5212ProcessRadarEvent, /* Key Cache Functions */ .ah_getKeyCacheSize = ar5212GetKeyCacheSize, diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index 276671d6db33..eb9dc1e85eb3 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -1180,3 +1180,47 @@ ar5212GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe) pe->pe_extchannel = AH_FALSE; } +/* + * Process the radar phy error and extract the pulse duration. + */ +HAL_BOOL +ar5212ProcessRadarEvent(struct ath_hal *ah, struct ath_rx_status *rxs, + uint64_t fulltsf, const char *buf, HAL_DFS_EVENT *event) +{ + uint8_t dur; + uint8_t rssi; + + /* Check whether the given phy error is a radar event */ + if ((rxs->rs_phyerr != HAL_PHYERR_RADAR) && + (rxs->rs_phyerr != HAL_PHYERR_FALSE_RADAR_EXT)) + return AH_FALSE; + + /* + * The first byte is the pulse width - if there's + * no data, simply set the duration to 0 + */ + if (rxs->rs_datalen >= 1) + /* The pulse width is byte 0 of the data */ + dur = ((uint8_t) buf[0]) & 0xff; + else + dur = 0; + + /* Pulse RSSI is the normal reported RSSI */ + rssi = (uint8_t) rxs->rs_rssi; + + /* 0 duration/rssi is not a valid radar event */ + if (dur == 0 && rssi == 0) + return AH_FALSE; + + HALDEBUG(ah, HAL_DEBUG_DFS, "%s: rssi=%d, dur=%d\n", + __func__, rssi, dur); + + /* Record the event */ + event->re_full_ts = fulltsf; + event->re_ts = rxs->rs_tstamp; + event->re_rssi = rssi; + event->re_dur = dur; + event->re_flags = HAL_DFS_EVENT_PRICH; + + return AH_TRUE; +} diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index 510afe0436e0..e5294b0634bb 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -205,6 +205,9 @@ extern HAL_BOOL ar5416SetRifsDelay(struct ath_hal *ah, const struct ieee80211_channel *chan, HAL_BOOL enable); extern void ar5416EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe); extern void ar5416GetDfsThresh(struct ath_hal *ah, HAL_PHYERR_PARAM *pe); +extern HAL_BOOL ar5416ProcessRadarEvent(struct ath_hal *ah, + struct ath_rx_status *rxs, uint64_t fulltsf, const char *buf, + HAL_DFS_EVENT *event); extern HAL_BOOL ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index 22d05ff80ce8..e6363251f8a2 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -147,6 +147,7 @@ ar5416InitState(struct ath_hal_5416 *ahp5416, uint16_t devid, HAL_SOFTC sc, /* DFS Functions */ ah->ah_enableDfs = ar5416EnableDfs; ah->ah_getDfsThresh = ar5416GetDfsThresh; + ah->ah_procRadarEvent = ar5416ProcessRadarEvent; /* Power Management Functions */ ah->ah_setPowerMode = ar5416SetPowerMode; diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c b/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c index 2c08730bbe91..2332656e8f54 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_misc.c @@ -692,3 +692,19 @@ ar5416EnableDfs(struct ath_hal *ah, HAL_PHYERR_PARAM *pe) OS_REG_WRITE(ah, AR_PHY_RADAR_1, val); } } + +/* + * Extract the radar event information from the given phy error. + * + * Returns AH_TRUE if the phy error was actually a phy error, + * AH_FALSE if the phy error wasn't a phy error. + */ +HAL_BOOL +ar5416ProcessRadarEvent(struct ath_hal *ah, struct ath_rx_status *rxs, + uint64_t fulltsf, const char *buf, HAL_DFS_EVENT *event) +{ + /* + * For now, this isn't implemented. + */ + return AH_FALSE; +} diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 97666c55cb87..3bc852266019 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -709,6 +709,8 @@ void ath_intr(void *); ((*(_ah)->ah_enableDfs)((_ah), (_param))) #define ath_hal_getdfsthresh(_ah, _param) \ ((*(_ah)->ah_getDfsThresh)((_ah), (_param))) +#define ath_hal_procradarevent(_ah, _rxs, _fulltsf, _buf, _event) \ + ((*(_ah)->ah_procRadarEvent)((_ah), (_rxs), (_fulltsf), (_buf), (_event))) #define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \ ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type))) From 187eee07df3631bcc10cf4f9863bae83471f8fe4 Mon Sep 17 00:00:00 2001 From: jlaffaye Date: Tue, 7 Jun 2011 09:06:15 +0000 Subject: [PATCH 144/164] - Add myself to calendar.freebsd - Add the forgotten relation to mentors in committers-ports.dot Approved by: bapt@ (mentor) --- share/misc/committers-ports.dot | 3 +++ usr.bin/calendar/calendars/calendar.freebsd | 1 + 2 files changed, 4 insertions(+) diff --git a/share/misc/committers-ports.dot b/share/misc/committers-ports.dot index 0bee309a49de..d97abcc92978 100644 --- a/share/misc/committers-ports.dot +++ b/share/misc/committers-ports.dot @@ -205,6 +205,8 @@ arved -> stefan asami -> obrien +bapt -> jlaffaye + beat -> decke beech -> glarkin @@ -402,6 +404,7 @@ tabthorpe -> dhn tabthorpe -> fluffy tabthorpe -> jacula tabthorpe -> jadawin +tabthorpe -> jlaffaye tabthorpe -> pgj tabthorpe -> rene diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd index a04476a12185..32e13e0f507e 100644 --- a/usr.bin/calendar/calendars/calendar.freebsd +++ b/usr.bin/calendar/calendars/calendar.freebsd @@ -294,6 +294,7 @@ 10/22 Jean-Sebastien Pedron born in Redon, Ille-et-Vilaine, France, 1980 10/23 Mario Sergio Fujikawa Ferreira born in Brasilia, Distrito Federal, Brazil, 1976 10/25 Eric Melville born in Los Gatos, California, United States, 1980 +10/25 Julien Laffaye born in Toulouse, France, 1988 10/26 Philip M. Gollucci born in Silver Spring, Maryland, United States, 1979 10/27 Takanori Watanabe born in Numazu, Shizuoka, Japan, 1972 11/05 M. Warner Losh born in Kansas City, Kansas, United States, 1966 From 81c81d4337809e30229236fb5fa9590d18c541df Mon Sep 17 00:00:00 2001 From: ae Date: Tue, 7 Jun 2011 11:11:11 +0000 Subject: [PATCH 145/164] Do not use LCM from stripesize and user specified alignment value. When user wants have specific alignment - do what user wants. Use stripesize as alignment value in case, when some of gpart's arguments are ommitted for automatic calculation. Suggested by: mav --- sbin/geom/class/part/geom_part.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c index ae9f4b7b4516..55a055e1e21a 100644 --- a/sbin/geom/class/part/geom_part.c +++ b/sbin/geom/class/part/geom_part.c @@ -341,9 +341,10 @@ gpart_autofill_resize(struct gctl_req *req) errc(EXIT_FAILURE, error, "Invalid alignment param"); if (alignment == 0) errx(EXIT_FAILURE, "Invalid alignment param"); + } else { lba = pp->lg_stripesize / pp->lg_sectorsize; if (lba > 0) - alignment = g_lcm(lba, alignment); + alignment = lba; } error = gctl_delete_param(req, "alignment"); if (error) @@ -491,13 +492,9 @@ gpart_autofill(struct gctl_req *req) if (has_size && has_start && !has_alignment) goto done; - /* - * If stripesize is not zero, then recalculate alignment value. - * Use LCM from stripesize and user specified alignment. - */ len = pp->lg_stripesize / pp->lg_sectorsize; - if (len > 0 ) - alignment = g_lcm(len, alignment); + if (len > 0 && !has_alignment) + alignment = len; /* Adjust parameters to stripeoffset */ offset = pp->lg_stripeoffset / pp->lg_sectorsize; From 9f4e3900380b3875aadd339dfbba069e8311d193 Mon Sep 17 00:00:00 2001 From: hrs Date: Tue, 7 Jun 2011 12:00:29 +0000 Subject: [PATCH 146/164] - Use ELM_MALLOC() for struct rainfo. - Fix a missing back pointer assignment in struct prefix to struct rainfo when addr="" is specified. This caused SIGSEGV. - Insert a prefix element to a tail queue after setting parameters. --- usr.sbin/rtadvd/config.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c index ff5d90f7a01b..1b48868692ba 100644 --- a/usr.sbin/rtadvd/config.c +++ b/usr.sbin/rtadvd/config.c @@ -229,13 +229,7 @@ getconfig(int idx) __func__, intface); } - rai = malloc(sizeof(*rai)); - if (rai == NULL) { - syslog(LOG_INFO, "<%s> %s: can't allocate enough memory", - __func__, intface); - exit(1); - } - memset(rai, 0, sizeof(*rai)); + ELM_MALLOC(rai, exit(1)); TAILQ_INIT(&rai->rai_prefix); #ifdef ROUTEINFO TAILQ_INIT(&rai->rai_route); @@ -394,10 +388,7 @@ getconfig(int idx) /* allocate memory to store prefix information */ ELM_MALLOC(pfx, exit(1)); - - /* link into chain */ - TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next); - rai->rai_pfxs++; + pfx->pfx_rainfo = rai; pfx->pfx_origin = PREFIX_FROM_CONFIG; if (inet_pton(AF_INET6, addr, &pfx->pfx_prefix) != 1) { @@ -481,6 +472,9 @@ getconfig(int idx) pfx->pfx_pltimeexpire = now.tv_sec + pfx->pfx_preflifetime; } + /* link into chain */ + TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next); + rai->rai_pfxs++; } if (rai->rai_advifprefix && rai->rai_pfxs == 0) get_prefix(rai); From 161d559c0d81295a9fc7fd493d7071b3ea28c829 Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 7 Jun 2011 14:00:47 +0000 Subject: [PATCH 147/164] Since HAL_PHYERR_* is used in the radar code, always include ah_desc.h. --- sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index eb9dc1e85eb3..3a6019d993fd 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -21,9 +21,7 @@ #include "ah.h" #include "ah_internal.h" #include "ah_devid.h" -#ifdef AH_DEBUG #include "ah_desc.h" /* NB: for HAL_PHYERR* */ -#endif #include "ar5212/ar5212.h" #include "ar5212/ar5212reg.h" From efd82720da80075e33bb4925bb5cb648c2dafad5 Mon Sep 17 00:00:00 2001 From: hrs Date: Tue, 7 Jun 2011 15:40:17 +0000 Subject: [PATCH 148/164] Fix a bug that prevents tc=xxx from working. --- usr.sbin/rtadvd/advcap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr.sbin/rtadvd/advcap.c b/usr.sbin/rtadvd/advcap.c index b0f5ee0f8629..7280f4097d66 100644 --- a/usr.sbin/rtadvd/advcap.c +++ b/usr.sbin/rtadvd/advcap.c @@ -81,7 +81,6 @@ static char *tbuf; static int hopcount; /* detect infinite loops in termcap, init 0 */ -static const char *remotefile; extern const char *conffile; int tgetent(char *, char *); @@ -204,7 +203,7 @@ tnchktc(void) write(STDERR_FILENO, "Infinite tc= loop\n", 18); return (0); } - if (getent(tcbuf, tcname, remotefile) != 1) { + if (getent(tcbuf, tcname, conffile) != 1) { return (0); } for (q = tcbuf; *q++ != ':'; ) From bd3b4363f82a88a7abb776092169f6fadc972246 Mon Sep 17 00:00:00 2001 From: jh Date: Tue, 7 Jun 2011 16:23:27 +0000 Subject: [PATCH 149/164] Remove a gratuitous newline. This should be a non-functional change. PR: bin/153667 Submitted by: Craig Leres MFC after: 1 week --- libexec/comsat/comsat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c index d0ff7a43dbd6..2a0fd3c764a9 100644 --- a/libexec/comsat/comsat.c +++ b/libexec/comsat/comsat.c @@ -180,7 +180,7 @@ notify(struct utmpx *utp, char file[], off_t offset, int folder) dsyslog(LOG_DEBUG, "%s: wrong mode on %s", utp->ut_user, tty); return; } - dsyslog(LOG_DEBUG, "notify %s on %s\n", utp->ut_user, tty); + dsyslog(LOG_DEBUG, "notify %s on %s", utp->ut_user, tty); switch (fork()) { case -1: syslog(LOG_NOTICE, "fork failed (%m)"); From f7c852c88abcebcb25c335b83cf1f5e748e33a1c Mon Sep 17 00:00:00 2001 From: mav Date: Tue, 7 Jun 2011 17:01:52 +0000 Subject: [PATCH 150/164] Make automatic hw.snd.default_unit choice a bit more intelligent. Instead of just setting it to the first registered device, reevaluate it for each device registered, trying to choose best candidate, unless one was forced. For now use such preference order: play&rec, play, rec. As side effect, this should workaround the situation when HDMI audio output of the video card, usually not connected to anything, becomes default, that requires manual user intervention to make sound working. If at some point this won't be enough, we can try to fetch some additional priority flags from the device driver. --- sys/dev/sound/pcm/sound.c | 54 ++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index caa78416e958..958065f3a541 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -51,7 +51,7 @@ int pcm_veto_load = 1; int snd_unit = -1; TUNABLE_INT("hw.snd.default_unit", &snd_unit); -static int snd_unit_auto = 0; +static int snd_unit_auto = -1; TUNABLE_INT("hw.snd.default_auto", &snd_unit_auto); SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RW, &snd_unit_auto, 0, "assign default unit to a newly attached device"); @@ -443,6 +443,7 @@ sysctl_hw_snd_default_unit(SYSCTL_HANDLER_ARGS) if (!PCM_REGISTERED(d) || CHN_EMPTY(d, channels.pcm)) return EINVAL; snd_unit = unit; + snd_unit_auto = 0; } return (error); } @@ -737,6 +738,32 @@ pcm_killchan(device_t dev) return (pcm_chn_destroy(ch)); } +static int +pcm_best_unit(int old) +{ + struct snddev_info *d; + int i, best, bestprio, prio; + + best = -1; + bestprio = -100; + for (i = 0; pcm_devclass != NULL && + i < devclass_get_maxunit(pcm_devclass); i++) { + d = devclass_get_softc(pcm_devclass, i); + if (!PCM_REGISTERED(d)) + continue; + prio = 0; + if (d->playcount == 0) + prio -= 10; + if (d->reccount == 0) + prio -= 2; + if (prio > bestprio || (prio == bestprio && i == old)) { + best = i; + bestprio = prio; + } + } + return (best); +} + int pcm_setstatus(device_t dev, char *str) { @@ -770,8 +797,12 @@ pcm_setstatus(device_t dev, char *str) PCM_UNLOCK(d); - if (snd_unit < 0 || snd_unit_auto != 0) + if (snd_unit_auto < 0) + snd_unit_auto = (snd_unit < 0) ? 1 : 0; + if (snd_unit < 0 || snd_unit_auto > 1) snd_unit = device_get_unit(dev); + else if (snd_unit_auto == 1) + snd_unit = pcm_best_unit(snd_unit); return (0); } @@ -1113,7 +1144,6 @@ pcm_unregister(device_t dev) struct snddev_info *d; struct pcm_channel *ch; struct thread *td; - int i; td = curthread; d = device_get_softc(dev); @@ -1216,21 +1246,9 @@ pcm_unregister(device_t dev) sndstat_release(td); if (snd_unit == device_get_unit(dev)) { - /* - * Reassign default unit to the next available dev, but - * first, reset snd_unit to something ridiculous. - */ - snd_unit = -1; - for (i = 0; pcm_devclass != NULL && - i < devclass_get_maxunit(pcm_devclass); i++) { - if (device_get_unit(dev) == i) - continue; - d = devclass_get_softc(pcm_devclass, i); - if (PCM_REGISTERED(d)) { - snd_unit = i; - break; - } - } + snd_unit = pcm_best_unit(-1); + if (snd_unit_auto == 0) + snd_unit_auto = 1; } return (0); From 3a370ea3a9d5051e1f35c95d2db6af27c37fde70 Mon Sep 17 00:00:00 2001 From: marius Date: Tue, 7 Jun 2011 17:19:14 +0000 Subject: [PATCH 151/164] Fix a problem with r222813; given that we may only operate on interrupt globals here but clobber %y save and restore the latter. --- sys/sparc64/sparc64/mp_exception.S | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/sparc64/sparc64/mp_exception.S b/sys/sparc64/sparc64/mp_exception.S index d378035f01f3..f1b323aeebed 100644 --- a/sys/sparc64/sparc64/mp_exception.S +++ b/sys/sparc64/sparc64/mp_exception.S @@ -38,7 +38,8 @@ __FBSDID("$FreeBSD$"); .register %g2, #ignore .register %g3, #ignore -#define IPI_DONE(r1, r2, r3, r4, r5) \ +#define IPI_DONE(r1, r2, r3, r4, r5, r6) \ + rd %y, r6 ; \ lduw [PCPU(CPUID)], r2 ; \ mov _NCPUBITS, r3 ; \ mov %g0, %y ; \ @@ -50,6 +51,7 @@ __FBSDID("$FreeBSD$"); sub r2, r3, r3 ; \ mov 1, r4 ; \ sllx r4, r3, r4 ; \ + wr r6, %y ; \ ATOMIC_CLEAR_LONG(r1, r2, r3, r4) /* @@ -87,7 +89,7 @@ ENTRY(tl_ipi_spitfire_dcache_page_inval) 2: brgz,pt %g2, 1b sub %g2, %g4, %g2 - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_spitfire_dcache_page_inval) @@ -127,7 +129,7 @@ ENTRY(tl_ipi_spitfire_icache_page_inval) 2: brgz,pt %g2, 1b sub %g2, %g4, %g2 - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_spitfire_icache_page_inval) @@ -158,7 +160,7 @@ ENTRY(tl_ipi_cheetah_dcache_page_inval) blt,a,pt %xcc, 1b nop - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_cheetah_dcache_page_inval) @@ -214,7 +216,7 @@ ENTRY(tl_ipi_tlb_page_demap) stxa %g0, [%g2] ASI_IMMU_DEMAP flush %g3 - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_tlb_page_demap) @@ -257,7 +259,7 @@ ENTRY(tl_ipi_tlb_range_demap) blt,a,pt %xcc, 1b nop - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_tlb_range_demap) @@ -281,7 +283,7 @@ ENTRY(tl_ipi_tlb_context_demap) stxa %g0, [%g1] ASI_IMMU_DEMAP flush %g3 - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_tlb_context_demap) @@ -293,7 +295,7 @@ ENTRY(tl_ipi_stick_rd) rd %asr24, %g2 stx %g2, [%g1] - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_stick_rd) @@ -305,6 +307,6 @@ ENTRY(tl_ipi_tick_rd) rd %tick, %g2 stx %g2, [%g1] - IPI_DONE(%g5, %g1, %g2, %g3, %g4) + IPI_DONE(%g5, %g1, %g2, %g3, %g4, %g6) retry END(tl_ipi_tick_rd) From e727405d750da7fbe6efcf79acc6c3515fe7aeb2 Mon Sep 17 00:00:00 2001 From: marius Date: Tue, 7 Jun 2011 17:33:39 +0000 Subject: [PATCH 152/164] Adapt CATR() to r222813. This is somewhat tricky as we can't afford using more than three temporary register in several places CATR() is used so this code trades instructions in for registers. Actually, this still isn't sufficient and CATR() has the side-effect of clobbering %y. Luckily, with the current uses of CATR() this either doesn't matter or we are able to (save and) restore it. Now that there's only one use of AND() and TEST() left inline these. --- sys/sparc64/include/ktr.h | 44 +++++++++------ sys/sparc64/sparc64/exception.S | 94 ++++++++++++++++++-------------- sys/sparc64/sparc64/mp_locore.S | 8 ++- sys/sparc64/sparc64/mp_machdep.c | 3 - 4 files changed, 88 insertions(+), 61 deletions(-) diff --git a/sys/sparc64/include/ktr.h b/sys/sparc64/include/ktr.h index 2a9966b7ce9c..f13865f1a27e 100644 --- a/sys/sparc64/include/ktr.h +++ b/sys/sparc64/include/ktr.h @@ -40,16 +40,6 @@ #else -#define AND(var, mask, r1, r2) \ - SET(var, r2, r1) ; \ - lduw [r1], r2 ; \ - and r2, mask, r1 - -#define TEST(var, mask, r1, r2, l1) \ - AND(var, mask, r1, r2) ; \ - brz r1, l1 ## f ; \ - nop - /* * XXX could really use another register... */ @@ -79,15 +69,37 @@ l2: add r2, 1, r3 ; \ SET(l1 ## b, r3, r2) ; \ stx r2, [r1 + KTR_DESC] +/* + * NB: this clobbers %y. + */ #define CATR(mask, desc, r1, r2, r3, l1, l2, l3) \ set mask, r1 ; \ - TEST(ktr_mask, r1, r2, r2, l3) ; \ - lduw [PCPU(MID)], r1 ; \ + SET(ktr_mask, r3, r2) ; \ + lduw [r2], r2 ; \ + and r2, r1, r1 ; \ + brz r1, l3 ## f ; \ + nop ; \ + lduw [PCPU(CPUID)], r2 ; \ + mov _NCPUBITS, r3 ; \ + mov %g0, %y ; \ + udiv r2, r3, r2 ; \ + srl r2, 0, r2 ; \ + sllx r2, PTR_SHIFT, r2 ; \ + SET(ktr_cpumask, r3, r1) ; \ + ldx [r1 + r2], r1 ; \ + lduw [PCPU(CPUID)], r2 ; \ + mov _NCPUBITS, r3 ; \ + mov %g0, %y ; \ + udiv r2, r3, r2 ; \ + srl r2, 0, r2 ; \ + smul r2, r3, r3 ; \ + lduw [PCPU(CPUID)], r2 ; \ + sub r2, r3, r3 ; \ mov 1, r2 ; \ - sllx r2, r1, r1 ; \ -#ifdef notyet \ - TEST(ktr_cpumask, r1, r2, r3, l3) ; \ -#endif \ + sllx r2, r3, r2 ; \ + andn r1, r2, r1 ; \ + brz r1, l3 ## f ; \ + nop ; \ ATR(desc, r1, r2, r3, l1, l2) #endif /* LOCORE */ diff --git a/sys/sparc64/sparc64/exception.S b/sys/sparc64/sparc64/exception.S index ed0e3810e259..246f2c244127 100644 --- a/sys/sparc64/sparc64/exception.S +++ b/sys/sparc64/sparc64/exception.S @@ -2615,9 +2615,9 @@ ENTRY(tl0_ret) andn %l4, TSTATE_CWP_MASK, %g2 /* - * Restore %y. Could also be below if we had more alternate globals. + * Save %y in an alternate global. */ - wr %l5, 0, %y + mov %l5, %g4 /* * Setup %wstate for return. We need to restore the user window state @@ -2662,8 +2662,8 @@ tl0_ret_fill: * Fixup %tstate so the saved %cwp points to the current window and * restore it. */ - rdpr %cwp, %g4 - wrpr %g2, %g4, %tstate + rdpr %cwp, %g1 + wrpr %g2, %g1, %tstate /* * Restore the user window state. The transition bit was set above @@ -2673,19 +2673,24 @@ tl0_ret_fill: #if KTR_COMPILE & KTR_TRAP CATR(KTR_TRAP, "tl0_ret: td=%#lx pil=%#lx pc=%#lx npc=%#lx sp=%#lx" - , %g2, %g3, %g4, 7, 8, 9) - ldx [PCPU(CURTHREAD)], %g3 - stx %g3, [%g2 + KTR_PARM1] - rdpr %pil, %g3 - stx %g3, [%g2 + KTR_PARM2] - rdpr %tpc, %g3 - stx %g3, [%g2 + KTR_PARM3] - rdpr %tnpc, %g3 - stx %g3, [%g2 + KTR_PARM4] - stx %sp, [%g2 + KTR_PARM5] + , %g1, %g2, %g3, 7, 8, 9) + ldx [PCPU(CURTHREAD)], %g2 + stx %g2, [%g1 + KTR_PARM1] + rdpr %pil, %g2 + stx %g2, [%g1 + KTR_PARM2] + rdpr %tpc, %g2 + stx %g2, [%g1 + KTR_PARM3] + rdpr %tnpc, %g2 + stx %g2, [%g1 + KTR_PARM4] + stx %sp, [%g1 + KTR_PARM5] 9: #endif + /* + * Restore %y. Note that the CATR above clobbered it. + */ + wr %g4, 0, %y + /* * Return to usermode. */ @@ -2700,6 +2705,11 @@ tl0_ret_fill_end: stx %l5, [%l0 + KTR_PARM2] stx %sp, [%l0 + KTR_PARM3] 9: + + /* + * Restore %y clobbered by the CATR. This was saved in %l5 above. + */ + wr %l5, 0, %y #endif /* @@ -2867,34 +2877,36 @@ ENTRY(tl1_ret) andn %l0, TSTATE_CWP_MASK, %g1 mov %l1, %g2 mov %l2, %g3 + mov %l4, %g4 wrpr %l3, 0, %pil - wr %l4, 0, %y restore wrpr %g0, 2, %tl - rdpr %cwp, %g4 - wrpr %g1, %g4, %tstate wrpr %g2, 0, %tpc wrpr %g3, 0, %tnpc + rdpr %cwp, %g2 + wrpr %g1, %g2, %tstate #if KTR_COMPILE & KTR_TRAP CATR(KTR_TRAP, "tl1_ret: td=%#lx pil=%#lx ts=%#lx pc=%#lx sp=%#lx" - , %g2, %g3, %g4, 7, 8, 9) - ldx [PCPU(CURTHREAD)], %g3 - stx %g3, [%g2 + KTR_PARM1] - rdpr %pil, %g3 - stx %g3, [%g2 + KTR_PARM2] - rdpr %tstate, %g3 - stx %g3, [%g2 + KTR_PARM3] - rdpr %tpc, %g3 - stx %g3, [%g2 + KTR_PARM4] - stx %sp, [%g2 + KTR_PARM5] + , %g1, %g2, %g3, 7, 8, 9) + ldx [PCPU(CURTHREAD)], %g2 + stx %g2, [%g1 + KTR_PARM1] + rdpr %pil, %g2 + stx %g2, [%g1 + KTR_PARM2] + rdpr %tstate, %g2 + stx %g2, [%g1 + KTR_PARM3] + rdpr %tpc, %g2 + stx %g2, [%g1 + KTR_PARM4] + stx %sp, [%g1 + KTR_PARM5] 9: #endif + wr %g4, 0, %y + retry END(tl1_ret) @@ -2995,33 +3007,35 @@ ENTRY(tl1_intr) andn %l0, TSTATE_CWP_MASK, %g1 mov %l1, %g2 mov %l2, %g3 + mov %l4, %g4 wrpr %l3, 0, %pil - wr %l4, 0, %y restore wrpr %g0, 2, %tl - rdpr %cwp, %g4 - wrpr %g1, %g4, %tstate wrpr %g2, 0, %tpc wrpr %g3, 0, %tnpc + rdpr %cwp, %g2 + wrpr %g1, %g2, %tstate #if KTR_COMPILE & KTR_INTR CATR(KTR_INTR, "tl1_intr: td=%#x pil=%#lx ts=%#lx pc=%#lx sp=%#lx" - , %g2, %g3, %g4, 7, 8, 9) - ldx [PCPU(CURTHREAD)], %g3 - stx %g3, [%g2 + KTR_PARM1] - rdpr %pil, %g3 - stx %g3, [%g2 + KTR_PARM2] - rdpr %tstate, %g3 - stx %g3, [%g2 + KTR_PARM3] - rdpr %tpc, %g3 - stx %g3, [%g2 + KTR_PARM4] - stx %sp, [%g2 + KTR_PARM5] + , %g1, %g2, %g3, 7, 8, 9) + ldx [PCPU(CURTHREAD)], %g2 + stx %g2, [%g1 + KTR_PARM1] + rdpr %pil, %g2 + stx %g2, [%g1 + KTR_PARM2] + rdpr %tstate, %g2 + stx %g2, [%g1 + KTR_PARM3] + rdpr %tpc, %g2 + stx %g2, [%g1 + KTR_PARM4] + stx %sp, [%g1 + KTR_PARM5] 9: #endif + wr %g4, 0, %y + retry END(tl1_intr) diff --git a/sys/sparc64/sparc64/mp_locore.S b/sys/sparc64/sparc64/mp_locore.S index fbcb767e0896..fd4357eaec1f 100644 --- a/sys/sparc64/sparc64/mp_locore.S +++ b/sys/sparc64/sparc64/mp_locore.S @@ -269,13 +269,17 @@ ENTRY(mp_startup) add %l1, %l2, %l1 sub %l1, SPOFF + CCFSZ, %sp + /* Initialize global registers. */ + call cpu_setregs + mov %l1, %o0 + #if KTR_COMPILE & KTR_SMP CATR(KTR_SMP, "mp_startup: bootstrap cpuid=%d mid=%d pcpu=%#lx data=%#lx sp=%#lx" , %g1, %g2, %g3, 7, 8, 9) - lduw [%l1 + PC_CPUID], %g2 + lduw [PCPU(CPUID)], %g2 stx %g2, [%g1 + KTR_PARM1] - lduw [%l1 + PC_MID], %g2 + lduw [PCPU(MID)], %g2 stx %g2, [%g1 + KTR_PARM2] stx %l1, [%g1 + KTR_PARM3] stx %sp, [%g1 + KTR_PARM5] diff --git a/sys/sparc64/sparc64/mp_machdep.c b/sys/sparc64/sparc64/mp_machdep.c index 304a0f39d17e..f2e76df2da37 100644 --- a/sys/sparc64/sparc64/mp_machdep.c +++ b/sys/sparc64/sparc64/mp_machdep.c @@ -457,9 +457,6 @@ cpu_mp_bootstrap(struct pcpu *pc) */ tlb_flush_nonlocked(); - /* Initialize global registers. */ - cpu_setregs(pc); - /* * Enable interrupts. * Note that the PIL we be lowered indirectly via sched_throw(NULL) From b5ffa4ca3633fba6cdb0813fa4bd77604503d39b Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 7 Jun 2011 17:40:33 +0000 Subject: [PATCH 153/164] Log the socket address passed as the destination to sendto() and sendmsg() via ktrace. MFC after: 1 week --- sys/kern/uipc_syscalls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index a4bbdba54e5a..19aaee01859a 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -747,6 +747,10 @@ kern_sendit(td, s, mp, flags, control, segflg) return (error); so = (struct socket *)fp->f_data; +#ifdef KTRACE + if (mp->msg_name != NULL && KTRPOINT(td, KTR_STRUCT)) + ktrsockaddr(mp->msg_name); +#endif #ifdef MAC if (mp->msg_name != NULL) { error = mac_socket_check_connect(td->td_ucred, so, From f5a66a355e4cb15c54d65412deda8b6ed640dc07 Mon Sep 17 00:00:00 2001 From: delphij Date: Tue, 7 Jun 2011 18:48:49 +0000 Subject: [PATCH 154/164] Add a special mount option "failok" to indicate that the administrator wants the system to proceed to boot without bailing out into single user mode, even when the file system can not be successfully mounted. This option is implemented in mount(8) and not passed into kernel. MFC after: 1 month --- sbin/mount/mount.c | 16 ++++++++++++++-- share/man/man5/fstab.5 | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c index acded1c24379..2229419bc2ce 100644 --- a/sbin/mount/mount.c +++ b/sbin/mount/mount.c @@ -243,7 +243,7 @@ main(int argc, char *argv[]) const char *mntfromname, **vfslist, *vfstype; struct fstab *fs; struct statfs *mntbuf; - int all, ch, i, init_flags, late, mntsize, rval, have_fstab, ro; + int all, ch, i, init_flags, late, failok, mntsize, rval, have_fstab, ro; char *cp, *ep, *options; all = init_flags = late = 0; @@ -328,6 +328,10 @@ main(int argc, char *argv[]) continue; if (hasopt(fs->fs_mntops, "late") && !late) continue; + if (hasopt(fs->fs_mntops, "failok")) + failok = 1; + else + failok = 0; if (!(init_flags & MNT_UPDATE) && ismounted(fs, mntbuf, mntsize)) continue; @@ -335,7 +339,7 @@ main(int argc, char *argv[]) mntbuf->f_flags); if (mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file, init_flags, options, - fs->fs_mntops)) + fs->fs_mntops) && !failok) rval = 1; } } else if (fstab_style) { @@ -717,6 +721,14 @@ mangle(char *options, struct cpa *a) * before mountd starts. */ continue; + } else if (strcmp(p, "failok") == 0) { + /* + * "failok" is used to prevent certain file + * systems from being causing the system to + * drop into single user mode in the boot + * cycle, and is not a real mount option. + */ + continue; } else if (strncmp(p, "mountprog", 9) == 0) { /* * "mountprog" is used to force the use of diff --git a/share/man/man5/fstab.5 b/share/man/man5/fstab.5 index 1c6f17e40c51..aa50f840c2a0 100644 --- a/share/man/man5/fstab.5 +++ b/share/man/man5/fstab.5 @@ -32,7 +32,7 @@ .\" @(#)fstab.5 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd November 23, 2008 +.Dd June 7, 2011 .Dt FSTAB 5 .Os .Sh NAME @@ -147,6 +147,13 @@ this location can be specified as: userquota=/var/quotas/tmp.user .Ed .Pp +If the option ``failok'' is specified, +the system will ignore any error which happens during the mount of that filesystem, +which would otherwise cause the system to drop into single user mode. +This option is implemented by the +.Xr mount 8 +command and will not be passed to the kernel. +.Pp If the option ``noauto'' is specified, the file system will not be automatically mounted at system startup. Note that, for network file systems From f6cfb7359dc65080027581c9099b39284c5d3d50 Mon Sep 17 00:00:00 2001 From: bz Date: Tue, 7 Jun 2011 19:39:34 +0000 Subject: [PATCH 155/164] For the moment document the possible problem introduced with dynamic address family detection in world, mostly noticed by ifconfig(8), when running with an old kernel. Reported by: Andrzej Tobola (ato iem.pw.edu.pl) Reported by: gcooper --- UPDATING | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UPDATING b/UPDATING index 3fa4c088fb22..6010a96edb58 100644 --- a/UPDATING +++ b/UPDATING @@ -26,6 +26,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: cpumask_t type is retired and cpuset_t is used in order to describe a mask of CPUs. +20110531: + Changes to ifconfig(8) for dynamic address family detection mandate + that you are running a kernel of 20110525 or later. Make sure to + follow the update procedure to boot a new kernel before installing + world. + 20110513: Support for sun4v architecture is officially dropped From 5bdda7f91b10ca46468c2c8773e9f861a6d5e8ad Mon Sep 17 00:00:00 2001 From: zec Date: Tue, 7 Jun 2011 20:46:03 +0000 Subject: [PATCH 156/164] Set curvnet context in a callout-trigerred code path. MFC after: 3 days --- sys/net/bridgestp.c | 5 +++++ sys/net/bridgestp.h | 1 + 2 files changed, 6 insertions(+) diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 2993838ac683..e263b0b23d86 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1860,6 +1860,8 @@ bstp_tick(void *arg) if (bs->bs_running == 0) return; + CURVNET_SET(bs->bs_vnet); + /* slow timer to catch missed link events */ if (bstp_timer_expired(&bs->bs_link_timer)) { LIST_FOREACH(bp, &bs->bs_bplist, bp_next) @@ -1893,6 +1895,8 @@ bstp_tick(void *arg) bp->bp_txcount--; } + CURVNET_RESTORE(); + callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs); } @@ -2126,6 +2130,7 @@ bstp_attach(struct bstp_state *bs, struct bstp_cb_ops *cb) bs->bs_protover = BSTP_PROTO_RSTP; bs->bs_state_cb = cb->bcb_state; bs->bs_rtage_cb = cb->bcb_rtage; + bs->bs_vnet = curvnet; getmicrotime(&bs->bs_last_tc_time); diff --git a/sys/net/bridgestp.h b/sys/net/bridgestp.h index 74086fce478a..fdf16aa6b10f 100644 --- a/sys/net/bridgestp.h +++ b/sys/net/bridgestp.h @@ -358,6 +358,7 @@ struct bstp_state { LIST_HEAD(, bstp_port) bs_bplist; bstp_state_cb_t bs_state_cb; bstp_rtage_cb_t bs_rtage_cb; + struct vnet *bs_vnet; }; #define BSTP_LOCK_INIT(_bs) mtx_init(&(_bs)->bs_mtx, "bstp", NULL, MTX_DEF) From c129cb6c4fa374e0cf38714d1eaa8c1ee9bd6b33 Mon Sep 17 00:00:00 2001 From: mm Date: Tue, 7 Jun 2011 20:46:31 +0000 Subject: [PATCH 157/164] Silence notice on pool creation, import and access. Suggested by: Jeremy Chadwick (freebsd-stable@) Discussed with: pjd MFC after: 1 week --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c index 942636b906ce..130c9180be1c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c @@ -500,9 +500,11 @@ spa_history_log_version(spa_t *spa, history_internal_events_t event) utsname.nodename, utsname.release, utsname.version, utsname.machine); } +#if 0 cmn_err(CE_CONT, "!%s version %llu pool %s using %llu", event == LOG_POOL_IMPORT ? "imported" : event == LOG_POOL_CREATE ? "created" : "accessed", (u_longlong_t)current_vers, spa_name(spa), SPA_VERSION); #endif +#endif } From d2f204966c11d08d0a3955cd9de7554ad364bf29 Mon Sep 17 00:00:00 2001 From: marius Date: Tue, 7 Jun 2011 23:15:21 +0000 Subject: [PATCH 158/164] - For the case when tl1_align(_trap) is used to call rsf_fatal via RSF_FATAL we need to switch to alternate globals for KSTACK_CHECK just like tl1_data_excptn(_trap) does. This is more or less cosmetic because in case RSF_FATAL is called we're already heading south. - Correct an END(). - Read the window state from the correct register for a CATR(). --- sys/sparc64/sparc64/exception.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/sparc64/sparc64/exception.S b/sys/sparc64/sparc64/exception.S index 246f2c244127..0b8a0faf78ce 100644 --- a/sys/sparc64/sparc64/exception.S +++ b/sys/sparc64/sparc64/exception.S @@ -1280,6 +1280,7 @@ ENTRY(tl1_data_excptn_trap) END(tl1_data_excptn_trap) .macro tl1_align + wrpr %g0, PSTATE_ALT, %pstate ba,a %xcc, tl1_align_trap nop .align 32 @@ -1289,7 +1290,7 @@ ENTRY(tl1_align_trap) RESUME_SPILLFILL_ALIGN ba %xcc, tl1_sfsr_trap mov T_MEM_ADDRESS_NOT_ALIGNED | T_KERNEL, %g2 -END(tl1_data_excptn_trap) +END(tl1_align_trap) ENTRY(tl1_sfsr_trap) wr %g0, ASI_DMMU, %asi @@ -2702,7 +2703,7 @@ tl0_ret_fill_end: , %l0, %l1, %l2, 7, 8, 9) rdpr %pstate, %l1 stx %l1, [%l0 + KTR_PARM1] - stx %l5, [%l0 + KTR_PARM2] + stx %l6, [%l0 + KTR_PARM2] stx %sp, [%l0 + KTR_PARM3] 9: From b13895d9ea55e6897b9b5fdd46be2f9bff544d0b Mon Sep 17 00:00:00 2001 From: delphij Date: Wed, 8 Jun 2011 00:31:10 +0000 Subject: [PATCH 159/164] Use .Dq instead of hardcoding `` and ''. Suggested by: gjb --- share/man/man5/fstab.5 | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/share/man/man5/fstab.5 b/share/man/man5/fstab.5 index aa50f840c2a0..adbf48928ef1 100644 --- a/share/man/man5/fstab.5 +++ b/share/man/man5/fstab.5 @@ -70,7 +70,8 @@ remote file system to be mounted. The second field, .Pq Fa fs_file , describes the mount point for the file system. -For swap partitions, this field should be specified as ``none''. +For swap partitions, this field should be specified as +.Dq none . .Pp The third field, .Pq Fa fs_vfstype , @@ -125,7 +126,11 @@ sync,noatime,-m=644,-M=755,-u=foo,-g=bar in the option field of .Nm . .Pp -If the options ``userquota'' and/or ``groupquota'' are specified, +If the options +.Dq userquota +and/or +.Dq groupquota +are specified, the file system is automatically processed by the .Xr quotacheck 8 command, and user and/or group disk quotas are enabled with @@ -147,14 +152,18 @@ this location can be specified as: userquota=/var/quotas/tmp.user .Ed .Pp -If the option ``failok'' is specified, +If the option +.Dq failok +is specified, the system will ignore any error which happens during the mount of that filesystem, which would otherwise cause the system to drop into single user mode. This option is implemented by the .Xr mount 8 command and will not be passed to the kernel. .Pp -If the option ``noauto'' is specified, the file system will not be automatically +If the option +.Dq noauto +is specified, the file system will not be automatically mounted at system startup. Note that, for network file systems of third party types @@ -177,13 +186,19 @@ field (it is not deleted from the field). If .Fa fs_type -is ``rw'' or ``ro'' then the file system whose name is given in the +is +.Dq rw +or +.Dq ro +then the file system whose name is given in the .Fa fs_file field is normally mounted read-write or read-only on the specified special file. If .Fa fs_type -is ``sw'' then the special file is made available as a piece of swap +is +.Dq sw +then the special file is made available as a piece of swap space by the .Xr swapon 8 command at the end of the system reboot procedure. @@ -194,7 +209,9 @@ and are unused. If .Fa fs_type -is specified as ``xx'' the entry is ignored. +is specified as +.Dq xx +the entry is ignored. This is useful to show disk partitions which are currently unused. .Pp The fifth field, From b4b3d062cdd5a507afb962caa1fdd9a3d78abf9c Mon Sep 17 00:00:00 2001 From: bz Date: Wed, 8 Jun 2011 03:02:11 +0000 Subject: [PATCH 160/164] Correct comments and debug logging in ipsec to better match reality. MFC after: 3 days --- sys/netinet/ip_input.c | 2 +- sys/netinet/ip_ipsec.c | 2 +- sys/netinet6/ip6_ipsec.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index ac1c723a0acc..67fcb743a9a5 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -488,7 +488,7 @@ ip_input(struct mbuf *m) } #ifdef IPSEC /* - * Bypass packet filtering for packets from a tunnel (gif). + * Bypass packet filtering for packets previously handled by IPsec. */ if (ip_ipsec_filtertunnel(m)) goto passin; diff --git a/sys/netinet/ip_ipsec.c b/sys/netinet/ip_ipsec.c index 50a6ce44a490..a3c87f5c442a 100644 --- a/sys/netinet/ip_ipsec.c +++ b/sys/netinet/ip_ipsec.c @@ -95,7 +95,7 @@ ip_ipsec_filtertunnel(struct mbuf *m) #if defined(IPSEC) /* - * Bypass packet filtering for packets from a tunnel. + * Bypass packet filtering for packets previously handled by IPsec. */ if (!V_ip4_ipsec_filtertunnel && m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) != NULL) diff --git a/sys/netinet6/ip6_ipsec.c b/sys/netinet6/ip6_ipsec.c index 8731e1261f99..bbbc9c99b1ec 100644 --- a/sys/netinet6/ip6_ipsec.c +++ b/sys/netinet6/ip6_ipsec.c @@ -97,7 +97,7 @@ SYSCTL_VNET_INT(_net_inet6_ipsec6, OID_AUTO, /* * Check if we have to jump over firewall processing for this packet. - * Called from ip_input(). + * Called from ip6_input(). * 1 = jump over firewall, 0 = packet goes through firewall. */ int @@ -106,7 +106,7 @@ ip6_ipsec_filtertunnel(struct mbuf *m) #if defined(IPSEC) /* - * Bypass packet filtering for packets from a tunnel. + * Bypass packet filtering for packets previously handled by IPsec. */ if (!V_ip6_ipsec6_filtertunnel && m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) != NULL) @@ -118,7 +118,7 @@ ip6_ipsec_filtertunnel(struct mbuf *m) /* * Check if this packet has an active SA and needs to be dropped instead * of forwarded. - * Called from ip_input(). + * Called from ip6_input(). * 1 = drop packet, 0 = forward packet. */ int @@ -141,7 +141,7 @@ ip6_ipsec_fwd(struct mbuf *m) if (sp == NULL) { /* NB: can happen if error */ splx(s); /*XXX error stat???*/ - DPRINTF(("ip_input: no SP for forwarding\n")); /*XXX*/ + DPRINTF(("%s: no SP for forwarding\n", __func__)); /*XXX*/ return 1; } @@ -163,7 +163,7 @@ ip6_ipsec_fwd(struct mbuf *m) * Check if protocol type doesn't have a further header and do IPSEC * decryption or reject right now. Protocols with further headers get * their IPSEC treatment within the protocol specific processing. - * Called from ip_input(). + * Called from ip6_input(). * 1 = drop packet, 0 = continue processing packet. */ int @@ -206,7 +206,7 @@ ip6_ipsec_input(struct mbuf *m, int nxt) } else { /* XXX error stat??? */ error = EINVAL; - DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ + DPRINTF(("%s: no SP, packet discarded\n", __func__));/*XXX*/ return 1; } splx(s); From e8152d9ab6630d75c99873893546db5d51f19309 Mon Sep 17 00:00:00 2001 From: hrs Date: Wed, 8 Jun 2011 04:06:56 +0000 Subject: [PATCH 161/164] - Disable "resolvconf -d" temporarily to avoid extra invocations of the script under a certain condition. - Fix argv handling. Spotted by: ume --- usr.sbin/rtsold/rtsol.c | 2 ++ usr.sbin/rtsold/rtsold.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index afa935e72da7..fe8bfaf5d08e 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -625,8 +625,10 @@ ra_opt_handler(struct ifinfo *ifi) if (!TAILQ_EMPTY(&sm_rdnss_head)) CALL_SCRIPT(RESADD, &sm_rdnss_head); +#if 0 else CALL_SCRIPT(RESDEL, NULL); +#endif ra_opt_handler_freeit: /* Clear script message queue. */ diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index a8b7ca727cfd..a0eb5939169a 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -124,6 +124,7 @@ main(int argc, char **argv) int maxfd; #endif int rtsock; + char *argv0; #ifndef SMALL /* rtsold */ @@ -134,6 +135,8 @@ main(int argc, char **argv) fflag = 1; once = 1; #endif + argv0 = argv[0]; + while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { case 'a': @@ -185,9 +188,9 @@ main(int argc, char **argv) if (!fflag) { char *ident; - ident = strrchr(argv[0], '/'); + ident = strrchr(argv0, '/'); if (!ident) - ident = argv[0]; + ident = argv0; else ident++; openlog(ident, LOG_NDELAY|LOG_PID, LOG_DAEMON); From 9c3130fd8beafdb49ce265e2ed95dde63492dac1 Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 8 Jun 2011 08:08:42 +0000 Subject: [PATCH 162/164] Pull up all vendor changes to mdoc(7). This also replaces the local fix in r219209 that made .Ac emit ASCII angle quotes with an official fix. In the official fix, ASCII quotes are output when using the .Aq, .Ao and .Ac calls, but only when nested into the .An macro. PR: gnu/154822 --- contrib/groff/tmac/doc-common | 12 ++++++++++++ contrib/groff/tmac/doc-syms | 4 ++++ contrib/groff/tmac/doc.tmac | 20 ++++++++++++++++---- gnu/usr.bin/groff/tmac/mdoc.local | 2 -- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/contrib/groff/tmac/doc-common b/contrib/groff/tmac/doc-common index 26dcc562f4d7..20d0cab8c875 100644 --- a/contrib/groff/tmac/doc-common +++ b/contrib/groff/tmac/doc-common @@ -543,6 +543,7 @@ .ds doc-operating-system-FreeBSD-7.3 7.3 .ds doc-operating-system-FreeBSD-8.0 8.0 .ds doc-operating-system-FreeBSD-8.1 8.1 +.ds doc-operating-system-FreeBSD-8.2 8.2 . .ds doc-operating-system-Darwin-8.0.0 8.0.0 .ds doc-operating-system-Darwin-8.1.0 8.1.0 @@ -563,6 +564,17 @@ .ds doc-operating-system-Darwin-9.4.0 9.4.0 .ds doc-operating-system-Darwin-9.5.0 9.5.0 .ds doc-operating-system-Darwin-9.6.0 9.6.0 +.ds doc-operating-system-Darwin-9.7.0 9.7.0 +.ds doc-operating-system-Darwin-9.8.0 9.8.0 +.ds doc-operating-system-Darwin-10.6.0 10.6.0 +.ds doc-operating-system-Darwin-10.1.0 10.1.0 +.ds doc-operating-system-Darwin-10.2.0 10.2.0 +.ds doc-operating-system-Darwin-10.3.0 10.3.0 +.ds doc-operating-system-Darwin-10.4.0 10.4.0 +.ds doc-operating-system-Darwin-10.5.0 10.5.0 +.ds doc-operating-system-Darwin-10.6.0 10.6.0 +.ds doc-operating-system-Darwin-10.7.0 10.7.0 +.ds doc-operating-system-Darwin-11.0.0 11.0.0 . .ds doc-operating-system-DragonFly-1.0 1.0 .ds doc-operating-system-DragonFly-1.1 1.1 diff --git a/contrib/groff/tmac/doc-syms b/contrib/groff/tmac/doc-syms index d2a070d6d76e..0e862adb5e90 100644 --- a/contrib/groff/tmac/doc-syms +++ b/contrib/groff/tmac/doc-syms @@ -617,6 +617,8 @@ .\" POSIX Part 1: System API .ds doc-str-St--p1003.1 \*[doc-Tn-font-size]\%IEEE\*[doc-str-St] Std 1003.1 .as doc-str-St--p1003.1 " (\*[Lq]\)\*[Px]\*[doc-str-St].1\*[Rq]) +.ds doc-str-St--p1003.1b \*[doc-Tn-font-size]\%IEEE\*[doc-str-St] Std 1003.1b +.as doc-str-St--p1003.1b " (\*[Lq]\)\*[Px]\*[doc-str-St].1\*[Rq]) .ds doc-str-St--p1003.1-88 \*[doc-Tn-font-size]\%IEEE\*[doc-str-St] Std 1003.1-1988 .as doc-str-St--p1003.1-88 " (\*[Lq]\)\*[Px]\*[doc-str-St].1\*[Rq]) .ds doc-str-St--p1003.1-90 \*[doc-Tn-font-size]ISO/IEC\*[doc-str-St] 9945-1:1990 @@ -754,6 +756,7 @@ . .ds doc-str-Lb-libarm ARM Architecture Library (libarm, \-larm) .ds doc-str-Lb-libarm32 ARM32 Architecture Library (libarm32, \-larm32) +.ds doc-str-Lb-libbsm Basic Security Module Library (libbsm, \-lbsm) .ds doc-str-Lb-libc Standard C\~Library (libc, \-lc) .ds doc-str-Lb-libcdk Curses Development Kit Library (libcdk, \-lcdk) .ds doc-str-Lb-libcompat Compatibility Library (libcompat, \-lcompat) @@ -779,6 +782,7 @@ .ds doc-str-Lb-libpthread \*[Px] \*[doc-str-Lb]Threads Library (libpthread, \-lpthread) .ds doc-str-Lb-libresolv DNS Resolver Library (libresolv, \-lresolv) .ds doc-str-Lb-librt \*[Px] \*[doc-str-Lb]Real-time Library (librt, \-lrt) +.ds doc-str-Lb-libSystem System Library (libSystem, \-lSystem) .ds doc-str-Lb-libtermcap Termcap Access Library (libtermcap, \-ltermcap) .ds doc-str-Lb-libusbhid USB Human Interface Devices Library (libusbhid, \-lusbhid) .ds doc-str-Lb-libutil System Utilities Library (libutil, \-lutil) diff --git a/contrib/groff/tmac/doc.tmac b/contrib/groff/tmac/doc.tmac index 7bdbf325927f..c1c32dc21919 100644 --- a/contrib/groff/tmac/doc.tmac +++ b/contrib/groff/tmac/doc.tmac @@ -1197,8 +1197,14 @@ . if !\n[doc-arg-limit] \ . ds doc-macro-name Aq . -. ds doc-quote-left < -. ds doc-quote-right > +. ie "\*[doc-macro-name]"An" \{\ +. ds doc-quote-left < +. ds doc-quote-right > +. \} +. el \{\ +. ds doc-quote-left \[la] +. ds doc-quote-right \[ra] +. \} . . doc-enclose-string \$@ .. @@ -1527,7 +1533,10 @@ . if !\n[doc-arg-limit] \ . ds doc-macro-name Ao . -. ds doc-quote-left \[la] +. ie "\*[doc-macro-name]"An" \ +. ds doc-quote-left < +. el \ +. ds doc-quote-left \[la] . . doc-enclose-open \$@ .. @@ -1546,7 +1555,10 @@ . if !\n[doc-arg-limit] \ . ds doc-macro-name Ac . -. ds doc-quote-right \[ra] +. ie "\*[doc-macro-name]"An" \ +. ds doc-quote-right > +. el \ +. ds doc-quote-right \[ra] . . doc-enclose-close \$@ .. diff --git a/gnu/usr.bin/groff/tmac/mdoc.local b/gnu/usr.bin/groff/tmac/mdoc.local index d46f5db54f3b..bb26a1ba20b9 100644 --- a/gnu/usr.bin/groff/tmac/mdoc.local +++ b/gnu/usr.bin/groff/tmac/mdoc.local @@ -34,7 +34,6 @@ .\" FreeBSD .Lb values .ds doc-str-Lb-libarchive Streaming Archive Library (libarchive, \-larchive) .ds doc-str-Lb-libbluetooth Bluetooth User Library (libbluetooth, \-lbluetooth) -.ds doc-str-Lb-libbsm Basic Security Module User Library (libbsm, \-lbsm) .ds doc-str-Lb-libc_r Reentrant C\~Library (libc_r, \-lc_r) .ds doc-str-Lb-libcalendar Calendar Arithmetic Library (libcalendar, \-lcalendar) .ds doc-str-Lb-libcam Common Access Method User Library (libcam, \-lcam) @@ -75,7 +74,6 @@ . .\" FreeBSD releases not found in doc-common .ds doc-operating-system-FreeBSD-7.4 7.4 -.ds doc-operating-system-FreeBSD-8.2 8.2 .ds doc-operating-system-FreeBSD-9.0 9.0 . .\" Definitions not (yet) in doc-syms From 74204e61b2bf85d1e0d861efb6350869bef8d5ba Mon Sep 17 00:00:00 2001 From: avg Date: Wed, 8 Jun 2011 08:12:15 +0000 Subject: [PATCH 163/164] remove code for dynamic offlining/onlining of CPUs on x86 The code has definitely been broken for SCHED_ULE, which is a default scheduler. It may have been broken for SCHED_4BSD in more subtle ways, e.g. with manually configured CPU affinities and for interrupt devilery purposes. We still provide a way to disable individual CPUs or all hyperthreading "twin" CPUs before SMP startup. See the UPDATING entry for details. Interaction between building CPU topology and disabling CPUs still remains fuzzy: topology is first built using all availble CPUs and then the disabled CPUs should be "subtracted" from it. That doesn't work well if the resulting topology becomes non-uniform. This work is done in cooperation with Attilio Rao who in addition to reviewing also provided parts of code. PR: kern/145385 Discussed with: gcooper, ambrisko, mdf, sbruno Reviewed by: attilio Tested by: pho, pluknet X-MFC after: never --- UPDATING | 17 ++++ sys/amd64/amd64/machdep.c | 7 +- sys/amd64/amd64/mp_machdep.c | 171 ++--------------------------------- sys/amd64/include/smp.h | 1 - sys/i386/i386/machdep.c | 7 +- sys/i386/i386/mp_machdep.c | 171 ++--------------------------------- sys/i386/include/smp.h | 1 - sys/pc98/pc98/machdep.c | 7 +- 8 files changed, 41 insertions(+), 341 deletions(-) diff --git a/UPDATING b/UPDATING index 6010a96edb58..c8c3582e81e2 100644 --- a/UPDATING +++ b/UPDATING @@ -22,6 +22,23 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110608: + The following sysctls and tunables are retired on x86 platforms: + machdep.hlt_cpus + machdep.hlt_logical_cpus + The following sysctl is retired: + machdep.hyperthreading_allowed + The sysctls were supposed to provide a way to dynamically offline and + online selected CPUs on x86 platforms, but the implementation has not + been reliable especially with SCHED_ULE scheduler. + machdep.hyperthreading_allowed tunable is still available to ignore + hyperthreading CPUs at OS level. + Individual CPUs can be disabled using hint.lapic.X.disabled tunable, + where X is an APIC ID of a CPU. Be advised, though, that disabling + CPUs in non-uniform fashion will result in non-uniform topology and + may lead to sub-optimal system performance with SCHED_ULE, which is + a default scheduler. + 20110607: cpumask_t type is retired and cpuset_t is used in order to describe a mask of CPUs. diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 94b4037c8e20..f90ad03a5917 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include "opt_isa.h" #include "opt_kstack_pages.h" #include "opt_maxmem.h" +#include "opt_mp_watchdog.h" #include "opt_perfmon.h" #include "opt_sched.h" #include "opt_kdtrace.h" @@ -116,6 +117,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -734,9 +736,8 @@ cpu_idle(int busy) CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); -#ifdef SMP - if (mp_grab_cpu_hlt()) - return; +#ifdef MP_WATCHDOG + ap_watchdog(PCPU_GET(cpuid)); #endif /* If we are busy - try to use fast methods. */ if (busy) { diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index d72afd6d939b..53988e985726 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include "opt_cpu.h" #include "opt_kstack_pages.h" -#include "opt_mp_watchdog.h" #include "opt_sched.h" #include "opt_smp.h" @@ -64,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -160,11 +158,8 @@ static int start_all_aps(void); static int start_ap(int apic_id); static void release_aps(void *dummy); -static int hlt_logical_cpus; static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ -static cpuset_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; -static struct sysctl_ctx_list logical_cpu_clist; static u_int bootMP_size; static void @@ -748,11 +743,6 @@ init_secondary(void) if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) CPU_OR(&logical_cpus_mask, &tcpuset); - /* Determine if we are a hyperthread. */ - if (hyperthreading_cpus > 1 && - PCPU_GET(apic_id) % hyperthreading_cpus != 0) - CPU_OR(&hyperthreading_cpus_mask, &tcpuset); - /* Build our map of 'other' CPUs. */ tallcpus = all_cpus; CPU_NAND(&tallcpus, &tcpuset); @@ -843,7 +833,7 @@ assign_cpu_ids(void) if (hyperthreading_cpus > 1 && i % hyperthreading_cpus != 0) { cpu_info[i].cpu_hyperthread = 1; -#if defined(SCHED_ULE) + /* * Don't use HT CPU if it has been disabled by a * tunable. @@ -852,7 +842,6 @@ assign_cpu_ids(void) cpu_info[i].cpu_disabled = 1; continue; } -#endif } /* Don't use this CPU if it has been disabled by a tunable. */ @@ -862,6 +851,11 @@ assign_cpu_ids(void) } } + if (hyperthreading_allowed == 0 && hyperthreading_cpus > 1) { + hyperthreading_cpus = 0; + cpu_logical = 1; + } + /* * Assign CPU IDs to local APIC IDs and disable any CPUs * beyond MAXCPU. CPU 0 is always assigned to the BSP. @@ -1487,159 +1481,6 @@ release_aps(void *dummy __unused) } SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); -static int -sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) -{ - cpuset_t mask; - int error; - - mask = hlt_cpus_mask; - error = sysctl_handle_opaque(oidp, &mask, sizeof(mask), req); - if (error || !req->newptr) - return (error); - - if (!CPU_EMPTY(&logical_cpus_mask) && - CPU_SUBSET(&mask, &logical_cpus_mask)) - hlt_logical_cpus = 1; - else - hlt_logical_cpus = 0; - - if (! hyperthreading_allowed) - CPU_OR(&mask, &hyperthreading_cpus_mask); - - if (CPU_SUBSET(&mask, &all_cpus)) - CPU_CLR(0, &mask); - hlt_cpus_mask = mask; - return (error); -} -SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, - CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_hlt_cpus, "S", - "Bitmap of CPUs to halt. 101 (binary) will halt CPUs 0 and 2."); - -static int -sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) -{ - int disable, error; - - disable = hlt_logical_cpus; - error = sysctl_handle_int(oidp, &disable, 0, req); - if (error || !req->newptr) - return (error); - - if (disable) - CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); - else - CPU_NAND(&hlt_cpus_mask, &logical_cpus_mask); - - if (! hyperthreading_allowed) - CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - - if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) - CPU_CLR(0, &hlt_cpus_mask); - - hlt_logical_cpus = disable; - return (error); -} - -static int -sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) -{ - int allowed, error; - - allowed = hyperthreading_allowed; - error = sysctl_handle_int(oidp, &allowed, 0, req); - if (error || !req->newptr) - return (error); - -#ifdef SCHED_ULE - /* - * SCHED_ULE doesn't allow enabling/disabling HT cores at - * run-time. - */ - if (allowed != hyperthreading_allowed) - return (ENOTSUP); - return (error); -#endif - - if (allowed) - CPU_NAND(&hlt_cpus_mask, &hyperthreading_cpus_mask); - else - CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - - if (!CPU_EMPTY(&logical_cpus_mask) && - CPU_SUBSET(&hlt_cpus_mask, &logical_cpus_mask)) - hlt_logical_cpus = 1; - else - hlt_logical_cpus = 0; - - if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) - CPU_CLR(0, &hlt_cpus_mask); - - hyperthreading_allowed = allowed; - return (error); -} - -static void -cpu_hlt_setup(void *dummy __unused) -{ - - if (!CPU_EMPTY(&logical_cpus_mask)) { - TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", - &hlt_logical_cpus); - sysctl_ctx_init(&logical_cpu_clist); - SYSCTL_ADD_PROC(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "hlt_logical_cpus", CTLTYPE_INT|CTLFLAG_RW, 0, 0, - sysctl_hlt_logical_cpus, "IU", ""); - SYSCTL_ADD_UINT(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "logical_cpus_mask", CTLTYPE_INT|CTLFLAG_RD, - &logical_cpus_mask, 0, ""); - - if (hlt_logical_cpus) - CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); - - /* - * If necessary for security purposes, force - * hyperthreading off, regardless of the value - * of hlt_logical_cpus. - */ - if (!CPU_EMPTY(&hyperthreading_cpus_mask)) { - SYSCTL_ADD_PROC(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, - 0, 0, sysctl_hyperthreading_allowed, "IU", ""); - if (! hyperthreading_allowed) - CPU_OR(&hlt_cpus_mask, - &hyperthreading_cpus_mask); - } - } -} -SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_ANY, cpu_hlt_setup, NULL); - -int -mp_grab_cpu_hlt(void) -{ - cpuset_t mask; -#ifdef MP_WATCHDOG - u_int cpuid; -#endif - int retval; - - mask = PCPU_GET(cpumask); -#ifdef MP_WATCHDOG - cpuid = PCPU_GET(cpuid); - ap_watchdog(cpuid); -#endif - - retval = 0; - while (CPU_OVERLAP(&mask, &hlt_cpus_mask)) { - retval = 1; - __asm __volatile("sti; hlt" : : : "memory"); - } - return (retval); -} - #ifdef COUNT_IPIS /* * Setup interrupt counters for IPI handlers. diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h index a009b35b150e..de686b76a445 100644 --- a/sys/amd64/include/smp.h +++ b/sys/amd64/include/smp.h @@ -65,7 +65,6 @@ void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpuset_t cpus, u_int ipi); u_int mp_bootaddress(u_int); -int mp_grab_cpu_hlt(void); void smp_cache_flush(void); void smp_invlpg(vm_offset_t addr); void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index fbf444a3eb4a..91050c43bee3 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include "opt_isa.h" #include "opt_kstack_pages.h" #include "opt_maxmem.h" +#include "opt_mp_watchdog.h" #include "opt_npx.h" #include "opt_perfmon.h" #include "opt_xbox.h" @@ -118,6 +119,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1357,9 +1359,8 @@ cpu_idle(int busy) CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); -#if defined(SMP) && !defined(XEN) - if (mp_grab_cpu_hlt()) - return; +#if defined(MP_WATCHDOG) && !defined(XEN) + ap_watchdog(PCPU_GET(cpuid)); #endif #ifndef XEN /* If we are busy - try to use fast methods. */ diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index be603eb33606..78c90c0f73c7 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include "opt_apic.h" #include "opt_cpu.h" #include "opt_kstack_pages.h" -#include "opt_mp_watchdog.h" #include "opt_pmap.h" #include "opt_sched.h" #include "opt_smp.h" @@ -78,7 +77,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -209,11 +207,8 @@ static int start_all_aps(void); static int start_ap(int apic_id); static void release_aps(void *dummy); -static int hlt_logical_cpus; static u_int hyperthreading_cpus; /* logical cpus sharing L1 cache */ -static cpuset_t hyperthreading_cpus_mask; static int hyperthreading_allowed = 1; -static struct sysctl_ctx_list logical_cpu_clist; static void mem_range_AP_init(void) @@ -794,11 +789,6 @@ init_secondary(void) /* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */ if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0) CPU_OR(&logical_cpus_mask, &tcpuset); - - /* Determine if we are a hyperthread. */ - if (hyperthreading_cpus > 1 && - PCPU_GET(apic_id) % hyperthreading_cpus != 0) - CPU_OR(&hyperthreading_cpus_mask, &tcpuset); /* Build our map of 'other' CPUs. */ tallcpus = all_cpus; @@ -882,7 +872,7 @@ assign_cpu_ids(void) if (hyperthreading_cpus > 1 && i % hyperthreading_cpus != 0) { cpu_info[i].cpu_hyperthread = 1; -#if defined(SCHED_ULE) + /* * Don't use HT CPU if it has been disabled by a * tunable. @@ -891,7 +881,6 @@ assign_cpu_ids(void) cpu_info[i].cpu_disabled = 1; continue; } -#endif } /* Don't use this CPU if it has been disabled by a tunable. */ @@ -901,6 +890,11 @@ assign_cpu_ids(void) } } + if (hyperthreading_allowed == 0 && hyperthreading_cpus > 1) { + hyperthreading_cpus = 0; + cpu_logical = 1; + } + /* * Assign CPU IDs to local APIC IDs and disable any CPUs * beyond MAXCPU. CPU 0 is always assigned to the BSP. @@ -1550,159 +1544,6 @@ release_aps(void *dummy __unused) } SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL); -static int -sysctl_hlt_cpus(SYSCTL_HANDLER_ARGS) -{ - cpuset_t mask; - int error; - - mask = hlt_cpus_mask; - error = sysctl_handle_opaque(oidp, &mask, sizeof(mask), req); - if (error || !req->newptr) - return (error); - - if (!CPU_EMPTY(&logical_cpus_mask) && - CPU_SUBSET(&mask, &logical_cpus_mask)) - hlt_logical_cpus = 1; - else - hlt_logical_cpus = 0; - - if (! hyperthreading_allowed) - CPU_OR(&mask, &hyperthreading_cpus_mask); - - if (CPU_SUBSET(&mask, &all_cpus)) - CPU_CLR(0, &mask); - hlt_cpus_mask = mask; - return (error); -} -SYSCTL_PROC(_machdep, OID_AUTO, hlt_cpus, - CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_hlt_cpus, "S", - "Bitmap of CPUs to halt. 101 (binary) will halt CPUs 0 and 2."); - -static int -sysctl_hlt_logical_cpus(SYSCTL_HANDLER_ARGS) -{ - int disable, error; - - disable = hlt_logical_cpus; - error = sysctl_handle_int(oidp, &disable, 0, req); - if (error || !req->newptr) - return (error); - - if (disable) - CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); - else - CPU_NAND(&hlt_cpus_mask, &logical_cpus_mask); - - if (! hyperthreading_allowed) - CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - - if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) - CPU_CLR(0, &hlt_cpus_mask); - - hlt_logical_cpus = disable; - return (error); -} - -static int -sysctl_hyperthreading_allowed(SYSCTL_HANDLER_ARGS) -{ - int allowed, error; - - allowed = hyperthreading_allowed; - error = sysctl_handle_int(oidp, &allowed, 0, req); - if (error || !req->newptr) - return (error); - -#ifdef SCHED_ULE - /* - * SCHED_ULE doesn't allow enabling/disabling HT cores at - * run-time. - */ - if (allowed != hyperthreading_allowed) - return (ENOTSUP); - return (error); -#endif - - if (allowed) - CPU_NAND(&hlt_cpus_mask, &hyperthreading_cpus_mask); - else - CPU_OR(&hlt_cpus_mask, &hyperthreading_cpus_mask); - - if (!CPU_EMPTY(&logical_cpus_mask) && - CPU_SUBSET(&hlt_cpus_mask, &logical_cpus_mask)) - hlt_logical_cpus = 1; - else - hlt_logical_cpus = 0; - - if (CPU_SUBSET(&hlt_cpus_mask, &all_cpus)) - CPU_CLR(0, &hlt_cpus_mask); - - hyperthreading_allowed = allowed; - return (error); -} - -static void -cpu_hlt_setup(void *dummy __unused) -{ - - if (!CPU_EMPTY(&logical_cpus_mask)) { - TUNABLE_INT_FETCH("machdep.hlt_logical_cpus", - &hlt_logical_cpus); - sysctl_ctx_init(&logical_cpu_clist); - SYSCTL_ADD_PROC(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "hlt_logical_cpus", CTLTYPE_INT|CTLFLAG_RW, 0, 0, - sysctl_hlt_logical_cpus, "IU", ""); - SYSCTL_ADD_UINT(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "logical_cpus_mask", CTLTYPE_INT|CTLFLAG_RD, - &logical_cpus_mask, 0, ""); - - if (hlt_logical_cpus) - CPU_OR(&hlt_cpus_mask, &logical_cpus_mask); - - /* - * If necessary for security purposes, force - * hyperthreading off, regardless of the value - * of hlt_logical_cpus. - */ - if (!CPU_EMPTY(&hyperthreading_cpus_mask)) { - SYSCTL_ADD_PROC(&logical_cpu_clist, - SYSCTL_STATIC_CHILDREN(_machdep), OID_AUTO, - "hyperthreading_allowed", CTLTYPE_INT|CTLFLAG_RW, - 0, 0, sysctl_hyperthreading_allowed, "IU", ""); - if (! hyperthreading_allowed) - CPU_OR(&hlt_cpus_mask, - &hyperthreading_cpus_mask); - } - } -} -SYSINIT(cpu_hlt, SI_SUB_SMP, SI_ORDER_ANY, cpu_hlt_setup, NULL); - -int -mp_grab_cpu_hlt(void) -{ - cpuset_t mask; -#ifdef MP_WATCHDOG - u_int cpuid; -#endif - int retval; - - mask = PCPU_GET(cpumask); -#ifdef MP_WATCHDOG - cpuid = PCPU_GET(cpuid); - ap_watchdog(cpuid); -#endif - - retval = 0; - while (CPU_OVERLAP(&mask, &hlt_cpus_mask)) { - retval = 1; - __asm __volatile("sti; hlt" : : : "memory"); - } - return (retval); -} - #ifdef COUNT_IPIS /* * Setup interrupt counters for IPI handlers. diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index 33b2578d3a59..04d67c9f2f28 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -68,7 +68,6 @@ void ipi_cpu(int cpu, u_int ipi); int ipi_nmi_handler(void); void ipi_selected(cpuset_t cpus, u_int ipi); u_int mp_bootaddress(u_int); -int mp_grab_cpu_hlt(void); void smp_cache_flush(void); void smp_invlpg(vm_offset_t addr); void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr); diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 853ac69911b2..8bcb618759ac 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include "opt_isa.h" #include "opt_kstack_pages.h" #include "opt_maxmem.h" +#include "opt_mp_watchdog.h" #include "opt_npx.h" #include "opt_perfmon.h" @@ -115,6 +116,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1193,9 +1195,8 @@ cpu_idle(int busy) CTR2(KTR_SPARE2, "cpu_idle(%d) at %d", busy, curcpu); -#ifdef SMP - if (mp_grab_cpu_hlt()) - return; +#ifdef MP_WATCHDOG + ap_watchdog(PCPU_GET(cpuid)); #endif /* If we are busy - try to use fast methods. */ if (busy) { From c828da79d9617611cbdaf46f6c4aa2990560d6f9 Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 8 Jun 2011 08:16:32 +0000 Subject: [PATCH 164/164] Added FreeBSD 8.3. --- gnu/usr.bin/groff/tmac/mdoc.local | 1 + 1 file changed, 1 insertion(+) diff --git a/gnu/usr.bin/groff/tmac/mdoc.local b/gnu/usr.bin/groff/tmac/mdoc.local index bb26a1ba20b9..befc87d3f6a6 100644 --- a/gnu/usr.bin/groff/tmac/mdoc.local +++ b/gnu/usr.bin/groff/tmac/mdoc.local @@ -74,6 +74,7 @@ . .\" FreeBSD releases not found in doc-common .ds doc-operating-system-FreeBSD-7.4 7.4 +.ds doc-operating-system-FreeBSD-8.3 8.3 .ds doc-operating-system-FreeBSD-9.0 9.0 . .\" Definitions not (yet) in doc-syms