Merge ^/head r319480 through r319547.
This commit is contained in:
commit
a14eb6db99
@ -2019,6 +2019,7 @@ native-xtools: .PHONY
|
||||
${_gcc_tools} \
|
||||
${_clang_libs} \
|
||||
${_clang} \
|
||||
${_lld} \
|
||||
sbin/md5 \
|
||||
sbin/sysctl \
|
||||
usr.bin/diff \
|
||||
|
@ -150,6 +150,8 @@ OLD_FILES+=usr/lib/clang/4.0.0/lib/freebsd/libclang_rt.ubsan_standalone_cxx-x86_
|
||||
OLD_DIRS+=usr/lib/clang/4.0.0/lib/freebsd
|
||||
OLD_DIRS+=usr/lib/clang/4.0.0/lib
|
||||
OLD_DIRS+=usr/lib/clang/4.0.0
|
||||
# 20170601: remove stale manpage
|
||||
OLD_FILES+=usr/share/man/man2/cap_rights_get.2.gz
|
||||
# 20170601: old libifconfig and libifc
|
||||
OLD_FILES+=usr/lib/libifc.a
|
||||
OLD_FILES+=usr/lib/libifc_p.a
|
||||
|
@ -27,10 +27,14 @@
|
||||
|
||||
|
||||
atf_test_case seek_overflow
|
||||
seek_overflow_head() {
|
||||
seek_overflow_head()
|
||||
{
|
||||
atf_set "descr" "dd(1) should reject too-large seek values"
|
||||
}
|
||||
seek_overflow_body() {
|
||||
seek_overflow_body()
|
||||
{
|
||||
atf_expect_fail "fails with 'dd: truncating f.out: File too large' - bug 219757"
|
||||
|
||||
touch f.in
|
||||
# Positive tests
|
||||
seek=`echo "2^63 / 4096 - 1" | bc`
|
||||
|
@ -252,7 +252,7 @@ __sigsetjmp:
|
||||
CFI_ENDPROC
|
||||
.size __sigsetjmp, .-__sigsetjmp
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__FreeBSD__) || defined(__linux__)
|
||||
/* We do not need executable stack. */
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
#endif
|
||||
|
@ -299,6 +299,6 @@ LZMA_CRC32:
|
||||
* use __linux__ here, but I don't know a way to detect when
|
||||
* we are using GNU assembler.
|
||||
*/
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
#if defined(__ELF__) && (defined(__FreeBSD__) || defined(__linux__))
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
#endif
|
||||
|
@ -282,6 +282,6 @@ LZMA_CRC64:
|
||||
* use __linux__ here, but I don't know a way to detect when
|
||||
* we are using GNU assembler.
|
||||
*/
|
||||
#if defined(__ELF__) && defined(__linux__)
|
||||
#if defined(__ELF__) && (defined(__FreeBSD__) || defined(__linux__))
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
#endif
|
||||
|
@ -350,7 +350,6 @@ MLINKS+=brk.2 sbrk.2
|
||||
MLINKS+=cap_enter.2 cap_getmode.2
|
||||
MLINKS+=cap_fcntls_limit.2 cap_fcntls_get.2
|
||||
MLINKS+=cap_ioctls_limit.2 cap_ioctls_get.2
|
||||
MLINKS+=cap_rights_limit.2 cap_rights_get.2
|
||||
MLINKS+=chdir.2 fchdir.2
|
||||
MLINKS+=chflags.2 chflagsat.2 \
|
||||
chflags.2 fchflags.2 \
|
||||
|
@ -32,6 +32,7 @@ MLINKS+=sysdecode_enum.3 sysdecode_acltype.3 \
|
||||
sysdecode_enum.3 sysdecode_fadvice.3 \
|
||||
sysdecode_enum.3 sysdecode_fcntl_cmd.3 \
|
||||
sysdecode_enum.3 sysdecode_getfsstat_mode.3 \
|
||||
sysdecode_enum.3 sysdecode_getrusage_who.3 \
|
||||
sysdecode_enum.3 sysdecode_idtype.3 \
|
||||
sysdecode_enum.3 sysdecode_ipproto.3 \
|
||||
sysdecode_enum.3 sysdecode_kldsym_cmd.3 \
|
||||
|
@ -486,6 +486,13 @@ sysdecode_getfsstat_mode(int mode)
|
||||
return (lookup_value(getfsstatmode, mode));
|
||||
}
|
||||
|
||||
const char *
|
||||
sysdecode_getrusage_who(int who)
|
||||
{
|
||||
|
||||
return (lookup_value(rusage, who));
|
||||
}
|
||||
|
||||
const char *
|
||||
sysdecode_kldsym_cmd(int cmd)
|
||||
{
|
||||
|
@ -114,6 +114,7 @@ gen_table "quotactlcmds" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/
|
||||
gen_table "rebootopt" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
|
||||
gen_table "rforkflags" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
|
||||
gen_table "rlimit" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
|
||||
gen_table "rusage" "RUSAGE_[A-Z]+[[:space:]]+[-0-9]+" "sys/resource.h"
|
||||
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
|
||||
gen_table "sendfileflags" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
|
||||
gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 17, 2016
|
||||
.Dd June 3, 2017
|
||||
.Dt SYSDECODE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -76,6 +76,7 @@ A placeholder for use when the ABI is not known.
|
||||
.Xr sysdecode_mask 3 ,
|
||||
.Xr sysdecode_quotactl_cmd 3 ,
|
||||
.Xr sysdecode_sigcode 3 ,
|
||||
.Xr sysdecode_socket_protocol 3 ,
|
||||
.Xr sysdecode_sockopt_name 3 ,
|
||||
.Xr sysdecode_syscallnames 3 ,
|
||||
.Xr sysdecode_utrace 3
|
||||
|
@ -55,6 +55,7 @@ bool sysdecode_filemode(FILE *_fp, int _mode, int *_rem);
|
||||
bool sysdecode_flock_operation(FILE *_fp, int _operation, int *_rem);
|
||||
int sysdecode_freebsd_to_abi_errno(enum sysdecode_abi _abi, int _error);
|
||||
const char *sysdecode_getfsstat_mode(int _mode);
|
||||
const char *sysdecode_getrusage_who(int _who);
|
||||
const char *sysdecode_idtype(int _idtype);
|
||||
const char *sysdecode_ioctlname(unsigned long _val);
|
||||
const char *sysdecode_ipproto(int _protocol);
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 2, 2017
|
||||
.Dd June 3, 2017
|
||||
.Dt sysdecode_enum 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -36,6 +36,7 @@
|
||||
.Nm sysdecode_fadvice ,
|
||||
.Nm sysdecode_fcntl_cmd ,
|
||||
.Nm sysdecode_getfsstat_mode ,
|
||||
.Nm sysdecode_getrusage_who ,
|
||||
.Nm sysdecode_idtype ,
|
||||
.Nm sysdecode_ipproto ,
|
||||
.Nm sysdecode_kldsym_cmd ,
|
||||
@ -89,6 +90,8 @@
|
||||
.Ft const char *
|
||||
.Fn sysdecode_getfsstat_mode "int mode"
|
||||
.Ft const char *
|
||||
.Fn sysdecode_getrusage_who "int who"
|
||||
.Ft const char *
|
||||
.Fn sysdecode_idtype "int idtype"
|
||||
.Ft const char *
|
||||
.Fn sysdecode_ipproto "int protocol"
|
||||
@ -188,6 +191,7 @@ Most of these functions decode an argument passed to a system call:
|
||||
.It Fn sysdecode_ptrace_request Ta Xr ptrace 2 Ta Fa request
|
||||
.It Fn sysdecode_rlimit Ta Xr getrlimit 2 Ta Fa resource
|
||||
.It Fn sysdecode_rtprio_function Ta Xr rtprio 2 Ta Fa function
|
||||
.It Fn sysdecode_getrusage_who Ta Xr getrusage 2 Ta Fa who
|
||||
.It Fn sysdecode_scheduler_policy Ta Xr sched_setscheduler 2 Ta Fa policy
|
||||
.It Fn sysdecode_semctl_cmd Ta Xr semctl 2 Ta Fa cmd
|
||||
.It Fn sysdecode_shmctl_cmd Ta Xr shmctl 2 Ta Fa cmd
|
||||
|
@ -64,9 +64,9 @@ The
|
||||
set:
|
||||
.Bd -literal -offset left
|
||||
00 NUL 01 SOH 02 STX 03 ETX 04 EOT 05 ENQ 06 ACK 07 BEL
|
||||
08 BS 09 HT 0A LF 0B VT 0C FF 0D CR 0E SO 0F SI
|
||||
08 BS 09 HT 0a LF 0b VT 0c FF 0d CR 0e SO 0f SI
|
||||
10 DLE 11 DC1 12 DC2 13 DC3 14 DC4 15 NAK 16 SYN 17 ETB
|
||||
18 CAN 19 EM 1A SUB 1B ESC 1C FS 1D GS 1E RS 1F US
|
||||
18 CAN 19 EM 1a SUB 1b ESC 1c FS 1d GS 1e RS 1f US
|
||||
20 SP 21 ! 22 " 23 # 24 $ 25 % 26 & 27 '
|
||||
28 ( 29 ) 2a * 2b + 2c , 2d - 2e . 2f /
|
||||
30 0 31 1 32 2 33 3 34 4 35 5 36 6 37 7
|
||||
|
@ -283,6 +283,3 @@ META_MODE+= missing-meta=yes
|
||||
.if empty(META_MODE:Mnofilemon)
|
||||
META_MODE+= missing-filemon=yes
|
||||
.endif
|
||||
# We do not want everything out-of-date just because
|
||||
# some unrelated shared lib updated this.
|
||||
.MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d
|
||||
|
@ -91,7 +91,11 @@ META_MODE?= normal
|
||||
/usr/share \
|
||||
|
||||
.endif
|
||||
|
||||
.if !empty(.MAKE.MODE:Mmeta)
|
||||
# We do not want everything out-of-date just because
|
||||
# some unrelated shared lib updated this.
|
||||
.MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d
|
||||
.endif
|
||||
|
||||
.if ${MK_AUTO_OBJ} == "yes"
|
||||
# This needs to be done early - before .PATH is computed
|
||||
|
@ -4313,6 +4313,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
|
||||
pv_entry_t pv;
|
||||
vm_paddr_t opa, pa;
|
||||
vm_page_t mpte, om;
|
||||
int rv;
|
||||
boolean_t nosleep;
|
||||
|
||||
PG_A = pmap_accessed_bit(pmap);
|
||||
@ -4387,10 +4388,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
|
||||
mpte = _pmap_allocpte(pmap, pmap_pde_pindex(va),
|
||||
nosleep ? NULL : &lock);
|
||||
if (mpte == NULL && nosleep) {
|
||||
if (lock != NULL)
|
||||
rw_wunlock(lock);
|
||||
PMAP_UNLOCK(pmap);
|
||||
return (KERN_RESOURCE_SHORTAGE);
|
||||
rv = KERN_RESOURCE_SHORTAGE;
|
||||
goto out;
|
||||
}
|
||||
goto retry;
|
||||
} else
|
||||
@ -4516,10 +4515,12 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
|
||||
vm_reserv_level_iffullpop(m) == 0)
|
||||
pmap_promote_pde(pmap, pde, va, &lock);
|
||||
|
||||
rv = KERN_SUCCESS;
|
||||
out:
|
||||
if (lock != NULL)
|
||||
rw_wunlock(lock);
|
||||
PMAP_UNLOCK(pmap);
|
||||
return (KERN_SUCCESS);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3,7 +3,6 @@
|
||||
kern/kern_clocksource.c standard
|
||||
|
||||
arm/versatile/sp804.c standard
|
||||
arm/versatile/versatile_timer.c standard
|
||||
dev/uart/uart_dev_ns8250.c optional uart
|
||||
|
||||
arm/annapurna/alpine/common.c standard
|
||||
|
@ -103,6 +103,10 @@ __FBSDID("$FreeBSD$");
|
||||
#error FreeBSD/arm doesn't provide compatibility with releases prior to 10
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH >= 6 && !defined(INTRNG)
|
||||
#error armv6 requires INTRNG
|
||||
#endif
|
||||
|
||||
struct pcpu __pcpu[MAXCPU];
|
||||
struct pcpu *pcpup = &__pcpu[0];
|
||||
|
||||
@ -297,6 +301,7 @@ cpu_idle_wakeup(int cpu)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef NO_EVENTTIMERS
|
||||
/*
|
||||
* Most ARM platforms don't need to do anything special to init their clocks
|
||||
* (they get intialized during normal device attachment), and by not defining a
|
||||
@ -307,8 +312,14 @@ cpu_idle_wakeup(int cpu)
|
||||
void
|
||||
arm_generic_initclocks(void)
|
||||
{
|
||||
}
|
||||
__weak_reference(arm_generic_initclocks, cpu_initclocks);
|
||||
|
||||
#else
|
||||
void
|
||||
cpu_initclocks(void)
|
||||
{
|
||||
|
||||
#ifndef NO_EVENTTIMERS
|
||||
#ifdef SMP
|
||||
if (PCPU_GET(cpuid) == 0)
|
||||
cpu_initclocks_bsp();
|
||||
@ -317,9 +328,8 @@ arm_generic_initclocks(void)
|
||||
#else
|
||||
cpu_initclocks_bsp();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
__weak_reference(arm_generic_initclocks, cpu_initclocks);
|
||||
#endif
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
void
|
||||
|
@ -59,6 +59,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
#include <machine/machdep.h> /* For arm_set_delay */
|
||||
#endif
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
@ -115,6 +119,8 @@ static boolean_t arm_tmr_freq_varies;
|
||||
#define tmr_gbl_read_4(sc, reg) bus_read_4((sc)->gbl_mem, reg)
|
||||
#define tmr_gbl_write_4(sc, reg, val) bus_write_4((sc)->gbl_mem, reg, val)
|
||||
|
||||
static void arm_tmr_delay(int, void *);
|
||||
|
||||
static timecounter_get_t arm_tmr_get_timecount;
|
||||
|
||||
static struct timecounter arm_tmr_timecount = {
|
||||
@ -431,6 +437,11 @@ arm_tmr_attach(device_t dev)
|
||||
if (tc_err != 0 && et_err != 0) {
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
arm_set_delay(arm_tmr_delay, sc);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -482,37 +493,14 @@ arm_tmr_change_frequency(uint64_t newfreq)
|
||||
et_change_frequency(arm_tmr_et, newfreq);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELAY - Delay for at least usec microseconds.
|
||||
* @usec: number of microseconds to delay by
|
||||
*
|
||||
* This function is called all over the kernel and is suppose to provide a
|
||||
* consistent delay. This function may also be called before the console
|
||||
* is setup so no printf's can be called here.
|
||||
*
|
||||
* RETURNS:
|
||||
* nothing
|
||||
*/
|
||||
static void __used /* Must emit function code for the weak ref below. */
|
||||
arm_tmr_DELAY(int usec)
|
||||
static void
|
||||
arm_tmr_delay(int usec, void *arg)
|
||||
{
|
||||
struct arm_tmr_softc *sc;
|
||||
struct arm_tmr_softc *sc = arg;
|
||||
int32_t counts_per_usec;
|
||||
int32_t counts;
|
||||
uint32_t first, last;
|
||||
|
||||
/* Check the timers are setup, if not just use a for loop for the meantime */
|
||||
if (arm_tmr_tc == NULL || arm_tmr_timecount.tc_frequency == 0) {
|
||||
for (; usec > 0; usec--)
|
||||
for (counts = 200; counts > 0; counts--)
|
||||
cpufunc_nullop(); /* Prevent gcc from optimizing
|
||||
* out the loop
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
sc = arm_tmr_tc->tc_priv;
|
||||
|
||||
/* Get the number of times to count */
|
||||
counts_per_usec = ((arm_tmr_timecount.tc_frequency / 1000000) + 1);
|
||||
|
||||
@ -536,10 +524,34 @@ arm_tmr_DELAY(int usec)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Supply a DELAY() implementation via weak linkage. A platform may want to use
|
||||
* the mpcore per-cpu eventtimers but provide its own DELAY() routine,
|
||||
* especially when the core frequency can change on the fly.
|
||||
#ifndef MULTIDELAY
|
||||
/**
|
||||
* DELAY - Delay for at least usec microseconds.
|
||||
* @usec: number of microseconds to delay by
|
||||
*
|
||||
* This function is called all over the kernel and is suppose to provide a
|
||||
* consistent delay. This function may also be called before the console
|
||||
* is setup so no printf's can be called here.
|
||||
*
|
||||
* RETURNS:
|
||||
* nothing
|
||||
*/
|
||||
__weak_reference(arm_tmr_DELAY, DELAY);
|
||||
void
|
||||
DELAY(int usec)
|
||||
{
|
||||
struct arm_tmr_softc *sc;
|
||||
int32_t counts;
|
||||
|
||||
/* Check the timers are setup, if not just use a for loop for the meantime */
|
||||
if (arm_tmr_tc == NULL || arm_tmr_timecount.tc_frequency == 0) {
|
||||
for (; usec > 0; usec--)
|
||||
for (counts = 200; counts > 0; counts--)
|
||||
cpufunc_nullop(); /* Prevent gcc from optimizing
|
||||
* out the loop
|
||||
*/
|
||||
} else {
|
||||
sc = arm_tmr_tc->tc_priv;
|
||||
arm_tmr_delay(usec, sc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -18,6 +18,9 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
# TODO: Port to INTRNG
|
||||
#NO_UNIVERSE
|
||||
|
||||
ident AML8726
|
||||
|
||||
include "std.armv6"
|
||||
|
@ -18,6 +18,9 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
# TODO: Port to INTRNG
|
||||
#NO_UNIVERSE
|
||||
|
||||
ident MV-88F78XX0
|
||||
|
||||
include "std.armv6"
|
||||
|
@ -29,6 +29,7 @@ include "../ti/am335x/std.am335x"
|
||||
makeoptions MODULES_EXTRA="dtb/am335x am335x_dmtpps"
|
||||
|
||||
options INTRNG
|
||||
options MULTIDELAY
|
||||
|
||||
options SCHED_4BSD # 4BSD scheduler
|
||||
options PLATFORM
|
||||
|
@ -31,6 +31,7 @@ options SCHED_4BSD # 4BSD scheduler
|
||||
#options MD_ROOT # MD is a potential root device
|
||||
#options NFSD # Network Filesystem Server
|
||||
options PLATFORM
|
||||
options MULTIDELAY
|
||||
options INCLUDE_CONFIG_FILE # Include this file in kernel
|
||||
|
||||
# NFS root from boopt/dhcp
|
||||
|
@ -28,6 +28,7 @@ options SOC_IMX53
|
||||
options SCHED_4BSD # 4BSD scheduler
|
||||
#options NFSD # Network Filesystem Server
|
||||
options PLATFORM
|
||||
options MULTIDELAY
|
||||
options INCLUDE_CONFIG_FILE # Include this file in kernel
|
||||
|
||||
# kernel/memory size reduction
|
||||
|
@ -3,6 +3,8 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
# TODO: This fails to build under universe, irnore it until it's fixed
|
||||
#NO_UNIVERSE
|
||||
|
||||
ident RT1310
|
||||
include "std.arm"
|
||||
|
@ -99,4 +99,4 @@ static platform_method_t imx51_methods[] = {
|
||||
PLATFORMMETHOD_END,
|
||||
};
|
||||
|
||||
FDT_PLATFORM_DEF(imx51, "i.MX51", 0, "fsl,imx51", 0);
|
||||
FDT_PLATFORM_DEF(imx51, "i.MX51", 0, "fsl,imx51", 100);
|
||||
|
@ -95,5 +95,4 @@ static platform_method_t imx53_methods[] = {
|
||||
PLATFORMMETHOD_END,
|
||||
};
|
||||
|
||||
FDT_PLATFORM_DEF(imx53, "i.MX53", 0, "fsl,imx53", 0);
|
||||
|
||||
FDT_PLATFORM_DEF(imx53, "i.MX53", 0, "fsl,imx53", 100);
|
||||
|
@ -8,6 +8,5 @@ arm/versatile/versatile_common.c standard
|
||||
arm/versatile/versatile_pci.c optional pci
|
||||
arm/versatile/versatile_scm.c standard
|
||||
arm/versatile/versatile_sic.c standard
|
||||
arm/versatile/versatile_timer.c standard
|
||||
|
||||
kern/kern_clocksource.c standard
|
||||
|
@ -42,6 +42,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
#include <machine/machdep.h> /* For arm_set_delay */
|
||||
#endif
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
@ -109,6 +113,7 @@ struct sp804_timer_softc {
|
||||
bus_space_write_4(sc->bst, sc->bsh, reg, val)
|
||||
|
||||
static unsigned sp804_timer_tc_get_timecount(struct timecounter *);
|
||||
static void sp804_timer_delay(int, void *);
|
||||
|
||||
static unsigned
|
||||
sp804_timer_tc_get_timecount(struct timecounter *tc)
|
||||
@ -287,6 +292,10 @@ sp804_timer_attach(device_t dev)
|
||||
(sp804_timer_tc_read_4(SP804_PRIMECELL_ID0 + i*4) & 0xff);
|
||||
}
|
||||
|
||||
#ifdef MULTIDELAY
|
||||
arm_set_delay(sp804_timer_delay, sc);
|
||||
#endif
|
||||
|
||||
device_printf(dev, "PrimeCell ID: %08x\n", id);
|
||||
|
||||
sc->timer_initialized = 1;
|
||||
@ -310,11 +319,36 @@ static devclass_t sp804_timer_devclass;
|
||||
|
||||
DRIVER_MODULE(sp804_timer, simplebus, sp804_timer_driver, sp804_timer_devclass, 0, 0);
|
||||
|
||||
static void
|
||||
sp804_timer_delay(int usec, void *arg)
|
||||
{
|
||||
struct sp804_timer_softc *sc = arg;
|
||||
int32_t counts;
|
||||
uint32_t first, last;
|
||||
|
||||
/* Get the number of times to count */
|
||||
counts = usec * ((sc->tc.tc_frequency / 1000000) + 1);
|
||||
|
||||
first = sp804_timer_tc_get_timecount(&sc->tc);
|
||||
|
||||
while (counts > 0) {
|
||||
last = sp804_timer_tc_get_timecount(&sc->tc);
|
||||
if (last == first)
|
||||
continue;
|
||||
if (last > first) {
|
||||
counts -= (int32_t)(last - first);
|
||||
} else {
|
||||
counts -= (int32_t)((0xFFFFFFFF - first) + last);
|
||||
}
|
||||
first = last;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MULTIDELAY
|
||||
void
|
||||
DELAY(int usec)
|
||||
{
|
||||
int32_t counts;
|
||||
uint32_t first, last;
|
||||
device_t timer_dev;
|
||||
struct sp804_timer_softc *sc;
|
||||
int timer_initialized = 0;
|
||||
@ -336,23 +370,8 @@ DELAY(int usec)
|
||||
for (counts = 200; counts > 0; counts--)
|
||||
/* Prevent gcc from optimizing out the loop */
|
||||
cpufunc_nullop();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the number of times to count */
|
||||
counts = usec * ((sc->tc.tc_frequency / 1000000) + 1);
|
||||
|
||||
first = sp804_timer_tc_get_timecount(&sc->tc);
|
||||
|
||||
while (counts > 0) {
|
||||
last = sp804_timer_tc_get_timecount(&sc->tc);
|
||||
if (last == first)
|
||||
continue;
|
||||
if (last>first) {
|
||||
counts -= (int32_t)(last - first);
|
||||
} else {
|
||||
counts -= (int32_t)((0xFFFFFFFF - first) + last);
|
||||
}
|
||||
first = last;
|
||||
} else {
|
||||
sp804_timer_delay(usec, sc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@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 <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/timeet.h>
|
||||
#include <sys/timetc.h>
|
||||
#include <sys/watchdog.h>
|
||||
#include <machine/bus.h>
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
void
|
||||
cpu_initclocks(void)
|
||||
{
|
||||
cpu_initclocks_bsp();
|
||||
}
|
||||
|
||||
|
@ -494,14 +494,6 @@ pmap_get_tables(pmap_t pmap, vm_offset_t va, pd_entry_t **l0, pd_entry_t **l1,
|
||||
return (true);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
pmap_is_current(pmap_t pmap)
|
||||
{
|
||||
|
||||
return ((pmap == pmap_kernel()) ||
|
||||
(pmap == curthread->td_proc->p_vmspace->vm_map.pmap));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
pmap_l3_valid(pt_entry_t l3)
|
||||
{
|
||||
@ -510,23 +502,7 @@ pmap_l3_valid(pt_entry_t l3)
|
||||
}
|
||||
|
||||
|
||||
/* Is a level 1 or 2entry a valid block and cacheable */
|
||||
CTASSERT(L1_BLOCK == L2_BLOCK);
|
||||
static __inline int
|
||||
pmap_pte_valid_cacheable(pt_entry_t pte)
|
||||
{
|
||||
|
||||
return (((pte & ATTR_DESCR_MASK) == L1_BLOCK) &&
|
||||
((pte & ATTR_IDX_MASK) == ATTR_IDX(CACHED_MEMORY)));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
pmap_l3_valid_cacheable(pt_entry_t l3)
|
||||
{
|
||||
|
||||
return (((l3 & ATTR_DESCR_MASK) == L3_PAGE) &&
|
||||
((l3 & ATTR_IDX_MASK) == ATTR_IDX(CACHED_MEMORY)));
|
||||
}
|
||||
|
||||
#define PTE_SYNC(pte) cpu_dcache_wb_range((vm_offset_t)pte, sizeof(*pte))
|
||||
|
||||
@ -1180,8 +1156,6 @@ pmap_kremove(vm_offset_t va)
|
||||
KASSERT(pte != NULL, ("pmap_kremove: Invalid address"));
|
||||
KASSERT(lvl == 3, ("pmap_kremove: Invalid pte level %d", lvl));
|
||||
|
||||
if (pmap_l3_valid_cacheable(pmap_load(pte)))
|
||||
cpu_dcache_wb_range(va, L3_SIZE);
|
||||
pmap_load_clear(pte);
|
||||
PTE_SYNC(pte);
|
||||
pmap_invalidate_page(kernel_pmap, va);
|
||||
@ -1292,8 +1266,6 @@ pmap_qremove(vm_offset_t sva, int count)
|
||||
KASSERT(lvl == 3,
|
||||
("Invalid device pagetable level: %d != 3", lvl));
|
||||
if (pte != NULL) {
|
||||
if (pmap_l3_valid_cacheable(pmap_load(pte)))
|
||||
cpu_dcache_wb_range(va, L3_SIZE);
|
||||
pmap_load_clear(pte);
|
||||
PTE_SYNC(pte);
|
||||
}
|
||||
@ -2295,8 +2267,6 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_t va,
|
||||
vm_page_t m;
|
||||
|
||||
PMAP_LOCK_ASSERT(pmap, MA_OWNED);
|
||||
if (pmap_is_current(pmap) && pmap_l3_valid_cacheable(pmap_load(l3)))
|
||||
cpu_dcache_wb_range(va, L3_SIZE);
|
||||
old_l3 = pmap_load_clear(l3);
|
||||
PTE_SYNC(l3);
|
||||
pmap_invalidate_page(pmap, va);
|
||||
@ -2518,9 +2488,6 @@ pmap_remove_all(vm_page_t m)
|
||||
|
||||
pte = pmap_l2_to_l3(pde, pv->pv_va);
|
||||
tpte = pmap_load(pte);
|
||||
if (pmap_is_current(pmap) &&
|
||||
pmap_l3_valid_cacheable(tpte))
|
||||
cpu_dcache_wb_range(pv->pv_va, L3_SIZE);
|
||||
pmap_load_clear(pte);
|
||||
PTE_SYNC(pte);
|
||||
pmap_invalidate_page(pmap, pv->pv_va);
|
||||
@ -3004,10 +2971,6 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
|
||||
}
|
||||
goto validate;
|
||||
}
|
||||
|
||||
/* Flush the cache, there might be uncommitted data in it */
|
||||
if (pmap_is_current(pmap) && pmap_l3_valid_cacheable(orig_l3))
|
||||
cpu_dcache_wb_range(va, L3_SIZE);
|
||||
} else {
|
||||
/*
|
||||
* Increment the counters.
|
||||
@ -3673,20 +3636,8 @@ pmap_remove_pages(pmap_t pmap)
|
||||
("pmap_remove_pages: bad pte %#jx",
|
||||
(uintmax_t)tpte));
|
||||
|
||||
if (pmap_is_current(pmap)) {
|
||||
if (lvl == 2 &&
|
||||
pmap_l3_valid_cacheable(tpte)) {
|
||||
cpu_dcache_wb_range(pv->pv_va,
|
||||
L3_SIZE);
|
||||
} else if (lvl == 1 &&
|
||||
pmap_pte_valid_cacheable(tpte)) {
|
||||
cpu_dcache_wb_range(pv->pv_va,
|
||||
L2_SIZE);
|
||||
}
|
||||
}
|
||||
pmap_load_clear(pte);
|
||||
PTE_SYNC(pte);
|
||||
pmap_invalidate_page(pmap, pv->pv_va);
|
||||
|
||||
/*
|
||||
* Update the vm_page_t clean/reference bits.
|
||||
|
@ -438,7 +438,7 @@ linux_kq_lock_unowned(void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
linux_dev_kqfilter_poll(struct linux_file *);
|
||||
linux_dev_kqfilter_poll(struct linux_file *, int);
|
||||
|
||||
struct linux_file *
|
||||
linux_file_alloc(void)
|
||||
@ -826,6 +826,10 @@ linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
|
||||
return (error);
|
||||
filp->f_flags = file->f_flag;
|
||||
|
||||
/* the LinuxKPI supports blocking and non-blocking I/O */
|
||||
if (cmd == FIONBIO || cmd == FIOASYNC)
|
||||
return (0);
|
||||
|
||||
linux_set_current(td);
|
||||
size = IOCPARM_LEN(cmd);
|
||||
/* refer to logic in sys_ioctl() */
|
||||
@ -852,9 +856,11 @@ linux_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
|
||||
current->bsd_ioctl_len = 0;
|
||||
}
|
||||
|
||||
if (error == EWOULDBLOCK)
|
||||
linux_dev_kqfilter_poll(filp);
|
||||
else if (error == ERESTARTSYS)
|
||||
if (error == EWOULDBLOCK) {
|
||||
/* update kqfilter status, if any */
|
||||
linux_dev_kqfilter_poll(filp,
|
||||
LINUX_KQ_FLAG_HAS_READ | LINUX_KQ_FLAG_HAS_WRITE);
|
||||
} else if (error == ERESTARTSYS)
|
||||
error = ERESTART;
|
||||
return (error);
|
||||
}
|
||||
@ -889,14 +895,15 @@ linux_dev_read(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
uio->uio_resid -= bytes;
|
||||
} else {
|
||||
error = -bytes;
|
||||
if (error == EWOULDBLOCK)
|
||||
linux_dev_kqfilter_poll(filp);
|
||||
else if (error == ERESTARTSYS)
|
||||
if (error == ERESTARTSYS)
|
||||
error = ERESTART;
|
||||
}
|
||||
} else
|
||||
error = ENXIO;
|
||||
|
||||
/* update kqfilter status, if any */
|
||||
linux_dev_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_READ);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -930,14 +937,15 @@ linux_dev_write(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
uio->uio_resid -= bytes;
|
||||
} else {
|
||||
error = -bytes;
|
||||
if (error == EWOULDBLOCK)
|
||||
linux_dev_kqfilter_poll(filp);
|
||||
else if (error == ERESTARTSYS)
|
||||
if (error == ERESTARTSYS)
|
||||
error = ERESTART;
|
||||
}
|
||||
} else
|
||||
error = ENXIO;
|
||||
|
||||
/* update kqfilter status, if any */
|
||||
linux_dev_kqfilter_poll(filp, LINUX_KQ_FLAG_HAS_WRITE);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1028,21 +1036,20 @@ static struct filterops linux_dev_kqfiltops_write = {
|
||||
};
|
||||
|
||||
static void
|
||||
linux_dev_kqfilter_poll(struct linux_file *filp)
|
||||
linux_dev_kqfilter_poll(struct linux_file *filp, int kqflags)
|
||||
{
|
||||
int temp;
|
||||
|
||||
spin_lock(&filp->f_kqlock);
|
||||
temp = (filp->f_kqflags & (LINUX_KQ_FLAG_HAS_READ | LINUX_KQ_FLAG_HAS_WRITE));
|
||||
filp->f_kqflags &= ~(LINUX_KQ_FLAG_NEED_READ | LINUX_KQ_FLAG_NEED_WRITE);
|
||||
spin_unlock(&filp->f_kqlock);
|
||||
|
||||
if (temp != 0) {
|
||||
if (filp->f_kqflags & kqflags) {
|
||||
/* get the latest polling state */
|
||||
temp = filp->f_op->poll(filp, NULL);
|
||||
|
||||
spin_lock(&filp->f_kqlock);
|
||||
/* clear kqflags */
|
||||
filp->f_kqflags &= ~(LINUX_KQ_FLAG_NEED_READ |
|
||||
LINUX_KQ_FLAG_NEED_WRITE);
|
||||
/* update kqflags */
|
||||
if (temp & (POLLIN | POLLOUT)) {
|
||||
spin_lock(&filp->f_kqlock);
|
||||
if (temp & POLLIN)
|
||||
filp->f_kqflags |= LINUX_KQ_FLAG_NEED_READ;
|
||||
if (temp & POLLOUT)
|
||||
@ -1050,8 +1057,8 @@ linux_dev_kqfilter_poll(struct linux_file *filp)
|
||||
|
||||
/* make sure the "knote" gets woken up */
|
||||
KNOTE_LOCKED(&filp->f_selinfo.si_note, 0);
|
||||
spin_unlock(&filp->f_kqlock);
|
||||
}
|
||||
spin_unlock(&filp->f_kqlock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1095,7 +1102,10 @@ linux_dev_kqfilter(struct cdev *dev, struct knote *kn)
|
||||
|
||||
if (error == 0) {
|
||||
linux_set_current(td);
|
||||
linux_dev_kqfilter_poll(filp);
|
||||
|
||||
/* update kqfilter status, if any */
|
||||
linux_dev_kqfilter_poll(filp,
|
||||
LINUX_KQ_FLAG_HAS_READ | LINUX_KQ_FLAG_HAS_WRITE);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ linux32_assym.h optional compat_linux32 \
|
||||
#
|
||||
linux32_locore.o optional compat_linux32 \
|
||||
dependency "linux32_assym.h $S/amd64/linux32/linux32_locore.s" \
|
||||
compile-with "${CC} -x assembler-with-cpp -DLOCORE -m32 -shared -s -pipe -I. -I$S -Werror -Wall -fno-common -nostdinc -nostdlib -Wl,-T$S/amd64/linux32/linux32_vdso.lds.s -Wl,-soname=linux32_vdso.so,--eh-frame-hdr,-fPIC,-warn-common ${.IMPSRC} -o ${.TARGET}" \
|
||||
compile-with "${CC} -x assembler-with-cpp -DLOCORE -m32 -shared -s -pipe -I. -I$S -Werror -Wall -fPIC -fno-common -nostdinc -nostdlib -Wl,-T$S/amd64/linux32/linux32_vdso.lds.s -Wl,-soname=linux32_vdso.so,--eh-frame-hdr,-warn-common ${.IMPSRC} -o ${.TARGET}" \
|
||||
no-obj no-implicit-rule \
|
||||
clean "linux32_locore.o"
|
||||
#
|
||||
|
@ -33,7 +33,7 @@ linux_assym.h optional compat_linux \
|
||||
#
|
||||
linux_locore.o optional compat_linux \
|
||||
dependency "linux_assym.h $S/i386/linux/linux_locore.s" \
|
||||
compile-with "${CC} -x assembler-with-cpp -DLOCORE -shared -s -pipe -I. -I$S -Werror -Wall -fno-common -nostdinc -nostdlib -Wl,-T$S/i386/linux/linux_vdso.lds.s -Wl,-soname=linux_vdso.so,--eh-frame-hdr,-fPIC,-warn-common ${.IMPSRC} -o ${.TARGET}" \
|
||||
compile-with "${CC} -x assembler-with-cpp -DLOCORE -shared -s -pipe -I. -I$S -Werror -Wall -fPIC -fno-common -nostdinc -nostdlib -Wl,-T$S/i386/linux/linux_vdso.lds.s -Wl,-soname=linux_vdso.so,--eh-frame-hdr,-warn-common ${.IMPSRC} -o ${.TARGET}" \
|
||||
no-obj no-implicit-rule \
|
||||
clean "linux_locore.o"
|
||||
#
|
||||
|
@ -4581,12 +4581,8 @@ write_txpkts_wr(struct sge_txq *txq, struct fw_eth_tx_pkts_wr *wr,
|
||||
if (checkwrap &&
|
||||
(uintptr_t)cpl == (uintptr_t)&eq->desc[eq->sidx])
|
||||
cpl = (void *)&eq->desc[0];
|
||||
txq->txpkts0_pkts += txp->npkt;
|
||||
txq->txpkts0_wrs++;
|
||||
} else {
|
||||
cpl = flitp;
|
||||
txq->txpkts1_pkts += txp->npkt;
|
||||
txq->txpkts1_wrs++;
|
||||
}
|
||||
|
||||
/* Checksum offload */
|
||||
@ -4621,6 +4617,14 @@ write_txpkts_wr(struct sge_txq *txq, struct fw_eth_tx_pkts_wr *wr,
|
||||
|
||||
}
|
||||
|
||||
if (txp->wr_type == 0) {
|
||||
txq->txpkts0_pkts += txp->npkt;
|
||||
txq->txpkts0_wrs++;
|
||||
} else {
|
||||
txq->txpkts1_pkts += txp->npkt;
|
||||
txq->txpkts1_wrs++;
|
||||
}
|
||||
|
||||
txsd = &txq->sdesc[eq->pidx];
|
||||
txsd->m = m0;
|
||||
txsd->desc_used = ndesc;
|
||||
|
@ -28,40 +28,25 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_media.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
|
||||
#include <arm/mv/mvwin.h>
|
||||
#include <arm/mv/mvreg.h>
|
||||
#include <arm/mv/mvvar.h>
|
||||
|
||||
#include <dev/etherswitch/etherswitch.h>
|
||||
#include <dev/mdio/mdio.h>
|
||||
#include <dev/mii/mii.h>
|
||||
#include <dev/mii/miivar.h>
|
||||
#include <dev/mge/if_mgevar.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#include "e6000swreg.h"
|
||||
#include "etherswitch_if.h"
|
||||
@ -71,14 +56,10 @@ __FBSDID("$FreeBSD$");
|
||||
MALLOC_DECLARE(M_E6000SW);
|
||||
MALLOC_DEFINE(M_E6000SW, "e6000sw", "e6000sw switch");
|
||||
|
||||
#define E6000SW_LOCK(_sc) \
|
||||
sx_xlock(&(_sc)->sx)
|
||||
#define E6000SW_UNLOCK(_sc) \
|
||||
sx_unlock(&(_sc)->sx)
|
||||
#define E6000SW_LOCK_ASSERT(_sc, _what) \
|
||||
sx_assert(&(_sc)->sx, (_what))
|
||||
#define E6000SW_TRYLOCK(_sc) \
|
||||
sx_tryxlock(&(_sc)->sx)
|
||||
#define E6000SW_LOCK(_sc) sx_xlock(&(_sc)->sx)
|
||||
#define E6000SW_UNLOCK(_sc) sx_unlock(&(_sc)->sx)
|
||||
#define E6000SW_LOCK_ASSERT(_sc, _what) sx_assert(&(_sc)->sx, (_what))
|
||||
#define E6000SW_TRYLOCK(_sc) sx_tryxlock(&(_sc)->sx)
|
||||
|
||||
typedef struct e6000sw_softc {
|
||||
device_t dev;
|
||||
@ -108,46 +89,43 @@ static etherswitch_info_t etherswitch_info = {
|
||||
.es_name = "Marvell 6000 series switch"
|
||||
};
|
||||
|
||||
static void e6000sw_identify(driver_t *driver, device_t parent);
|
||||
static int e6000sw_probe(device_t dev);
|
||||
static int e6000sw_attach(device_t dev);
|
||||
static int e6000sw_detach(device_t dev);
|
||||
static int e6000sw_readphy(device_t dev, int phy, int reg);
|
||||
static int e6000sw_writephy(device_t dev, int phy, int reg, int data);
|
||||
static etherswitch_info_t* e6000sw_getinfo(device_t dev);
|
||||
static void e6000sw_lock(device_t dev);
|
||||
static void e6000sw_unlock(device_t dev);
|
||||
static int e6000sw_getport(device_t dev, etherswitch_port_t *p);
|
||||
static int e6000sw_setport(device_t dev, etherswitch_port_t *p);
|
||||
static int e6000sw_readreg_wrapper(device_t dev, int addr_reg);
|
||||
static int e6000sw_writereg_wrapper(device_t dev, int addr_reg, int val);
|
||||
static int e6000sw_readphy_wrapper(device_t dev, int phy, int reg);
|
||||
static int e6000sw_writephy_wrapper(device_t dev, int phy, int reg, int data);
|
||||
static int e6000sw_getvgroup_wrapper(device_t dev, etherswitch_vlangroup_t *vg);
|
||||
static int e6000sw_setvgroup_wrapper(device_t dev, etherswitch_vlangroup_t *vg);
|
||||
static int e6000sw_setvgroup(device_t dev, etherswitch_vlangroup_t *vg);
|
||||
static int e6000sw_getvgroup(device_t dev, etherswitch_vlangroup_t *vg);
|
||||
static void e6000sw_setup(device_t dev, e6000sw_softc_t *sc);
|
||||
static void e6000sw_port_vlan_conf(e6000sw_softc_t *sc);
|
||||
static void e6000sw_tick(void *arg);
|
||||
static void e6000sw_set_atustat(device_t dev, e6000sw_softc_t *sc, int bin,
|
||||
int flag);
|
||||
static int e6000sw_atu_flush(device_t dev, e6000sw_softc_t *sc, int flag);
|
||||
static __inline void e6000sw_writereg(e6000sw_softc_t *sc, int addr, int reg,
|
||||
int val);
|
||||
static __inline uint32_t e6000sw_readreg(e6000sw_softc_t *sc, int addr,
|
||||
int reg);
|
||||
static int e6000sw_ifmedia_upd(struct ifnet *ifp);
|
||||
static void e6000sw_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
|
||||
static int e6000sw_atu_mac_table(device_t dev, e6000sw_softc_t *sc, struct
|
||||
atu_opt *atu, int flag);
|
||||
static int e6000sw_get_pvid(e6000sw_softc_t *sc, int port, int *pvid);
|
||||
static int e6000sw_set_pvid(e6000sw_softc_t *sc, int port, int pvid);
|
||||
static __inline int e6000sw_is_cpuport(e6000sw_softc_t *sc, int port);
|
||||
static __inline int e6000sw_is_fixedport(e6000sw_softc_t *sc, int port);
|
||||
static __inline int e6000sw_is_phyport(e6000sw_softc_t *sc, int port);
|
||||
static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *sc,
|
||||
unsigned int phy);
|
||||
static void e6000sw_identify(driver_t *, device_t);
|
||||
static int e6000sw_probe(device_t);
|
||||
static int e6000sw_attach(device_t);
|
||||
static int e6000sw_detach(device_t);
|
||||
static int e6000sw_readphy(device_t, int, int);
|
||||
static int e6000sw_writephy(device_t, int, int, int);
|
||||
static etherswitch_info_t* e6000sw_getinfo(device_t);
|
||||
static void e6000sw_lock(device_t);
|
||||
static void e6000sw_unlock(device_t);
|
||||
static int e6000sw_getport(device_t, etherswitch_port_t *);
|
||||
static int e6000sw_setport(device_t, etherswitch_port_t *);
|
||||
static int e6000sw_readreg_wrapper(device_t, int);
|
||||
static int e6000sw_writereg_wrapper(device_t, int, int);
|
||||
static int e6000sw_readphy_wrapper(device_t, int, int);
|
||||
static int e6000sw_writephy_wrapper(device_t, int, int, int);
|
||||
static int e6000sw_getvgroup_wrapper(device_t, etherswitch_vlangroup_t *);
|
||||
static int e6000sw_setvgroup_wrapper(device_t, etherswitch_vlangroup_t *);
|
||||
static int e6000sw_setvgroup(device_t, etherswitch_vlangroup_t *);
|
||||
static int e6000sw_getvgroup(device_t, etherswitch_vlangroup_t *);
|
||||
static void e6000sw_setup(device_t, e6000sw_softc_t *);
|
||||
static void e6000sw_port_vlan_conf(e6000sw_softc_t *);
|
||||
static void e6000sw_tick(void *);
|
||||
static void e6000sw_set_atustat(device_t, e6000sw_softc_t *, int, int);
|
||||
static int e6000sw_atu_flush(device_t, e6000sw_softc_t *, int);
|
||||
static __inline void e6000sw_writereg(e6000sw_softc_t *, int, int, int);
|
||||
static __inline uint32_t e6000sw_readreg(e6000sw_softc_t *, int, int);
|
||||
static int e6000sw_ifmedia_upd(struct ifnet *);
|
||||
static void e6000sw_ifmedia_sts(struct ifnet *, struct ifmediareq *);
|
||||
static int e6000sw_atu_mac_table(device_t, e6000sw_softc_t *, struct atu_opt *,
|
||||
int);
|
||||
static int e6000sw_get_pvid(e6000sw_softc_t *, int, int *);
|
||||
static int e6000sw_set_pvid(e6000sw_softc_t *, int, int);
|
||||
static __inline int e6000sw_is_cpuport(e6000sw_softc_t *, int);
|
||||
static __inline int e6000sw_is_fixedport(e6000sw_softc_t *, int);
|
||||
static __inline int e6000sw_is_phyport(e6000sw_softc_t *, int);
|
||||
static __inline struct mii_data *e6000sw_miiforphy(e6000sw_softc_t *,
|
||||
unsigned int);
|
||||
|
||||
static device_method_t e6000sw_methods[] = {
|
||||
/* device interface */
|
||||
@ -190,14 +168,17 @@ DRIVER_MODULE(etherswitch, e6000sw, etherswitch_driver, etherswitch_devclass, 0,
|
||||
DRIVER_MODULE(miibus, e6000sw, miibus_driver, miibus_devclass, 0, 0);
|
||||
MODULE_DEPEND(e6000sw, mdio, 1, 1, 1);
|
||||
|
||||
#define SMI_CMD 0
|
||||
#define SMI_CMD_BUSY (1<<15)
|
||||
#define SMI_CMD_OP_READ ((2<<10)|SMI_CMD_BUSY|(1<<12))
|
||||
#define SMI_CMD_OP_WRITE ((1<<10)|SMI_CMD_BUSY|(1<<12))
|
||||
#define SMI_DATA 1
|
||||
#define SMI_CMD 0
|
||||
#define SMI_CMD_BUSY (1 << 15)
|
||||
#define SMI_CMD_OP_READ ((2 << 10) | SMI_CMD_BUSY | (1 << 12))
|
||||
#define SMI_CMD_OP_WRITE ((1 << 10) | SMI_CMD_BUSY | (1 << 12))
|
||||
#define SMI_DATA 1
|
||||
|
||||
#define MDIO_READ(dev, addr, reg) \
|
||||
MDIO_READREG(device_get_parent(dev), (addr), (reg))
|
||||
#define MDIO_WRITE(dev, addr, reg, val) \
|
||||
MDIO_WRITEREG(device_get_parent(dev), (addr), (reg), (val))
|
||||
|
||||
#define MDIO_READ(dev, addr, reg) MDIO_READREG(device_get_parent(dev), (addr), (reg))
|
||||
#define MDIO_WRITE(dev, addr, reg, val) MDIO_WRITEREG(device_get_parent(dev), (addr), (reg), (val))
|
||||
static void
|
||||
e6000sw_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
@ -211,8 +192,8 @@ e6000sw_probe(device_t dev)
|
||||
{
|
||||
e6000sw_softc_t *sc;
|
||||
const char *description;
|
||||
unsigned int id;
|
||||
phandle_t dsa_node, switch_node;
|
||||
uint32_t id;
|
||||
|
||||
dsa_node = fdt_find_compatible(OF_finddevice("/"),
|
||||
"marvell,dsa", 0);
|
||||
@ -235,8 +216,8 @@ e6000sw_probe(device_t dev)
|
||||
/* Lock is necessary due to assertions. */
|
||||
sx_init(&sc->sx, "e6000sw");
|
||||
E6000SW_LOCK(sc);
|
||||
|
||||
id = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID);
|
||||
E6000SW_UNLOCK(sc);
|
||||
|
||||
switch (id & 0xfff0) {
|
||||
case 0x3520:
|
||||
@ -249,7 +230,6 @@ e6000sw_probe(device_t dev)
|
||||
description = "Marvell 88E6176";
|
||||
break;
|
||||
default:
|
||||
E6000SW_UNLOCK(sc);
|
||||
sx_destroy(&sc->sx);
|
||||
device_printf(dev, "Unrecognized device, id 0x%x.\n", id);
|
||||
return (ENXIO);
|
||||
@ -257,8 +237,6 @@ e6000sw_probe(device_t dev)
|
||||
|
||||
device_set_desc(dev, description);
|
||||
|
||||
E6000SW_UNLOCK(sc);
|
||||
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
@ -433,9 +411,9 @@ e6000sw_poll_done(e6000sw_softc_t *sc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (i = 0; i < E6000SW_SMI_TIMEOUT; i++) {
|
||||
|
||||
if (!(e6000sw_readreg(sc, REG_GLOBAL2, PHY_CMD) &
|
||||
if (!(e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG) &
|
||||
(1 << PHY_CMD_SMI_BUSY)))
|
||||
return (0);
|
||||
|
||||
@ -457,8 +435,6 @@ e6000sw_readphy(device_t dev, int phy, int reg)
|
||||
int err;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
val = 0;
|
||||
|
||||
if (!e6000sw_is_phyport(sc, phy) || reg >= E6000SW_NUM_PHY_REGS) {
|
||||
device_printf(dev, "Wrong register address.\n");
|
||||
return (EINVAL);
|
||||
@ -472,7 +448,7 @@ e6000sw_readphy(device_t dev, int phy, int reg)
|
||||
return (err);
|
||||
}
|
||||
|
||||
val |= 1 << PHY_CMD_SMI_BUSY;
|
||||
val = 1 << PHY_CMD_SMI_BUSY;
|
||||
val |= PHY_CMD_MODE_MDIO << PHY_CMD_MODE;
|
||||
val |= PHY_CMD_OPCODE_READ << PHY_CMD_OPCODE;
|
||||
val |= (reg << PHY_CMD_REG_ADDR) & PHY_CMD_REG_ADDR_MASK;
|
||||
@ -485,10 +461,9 @@ e6000sw_readphy(device_t dev, int phy, int reg)
|
||||
return (err);
|
||||
}
|
||||
|
||||
val = e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_DATA_REG)
|
||||
& PHY_DATA_MASK;
|
||||
val = e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_DATA_REG);
|
||||
|
||||
return (val);
|
||||
return (val & PHY_DATA_MASK);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -499,8 +474,6 @@ e6000sw_writephy(device_t dev, int phy, int reg, int data)
|
||||
int err;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
val = 0;
|
||||
|
||||
if (!e6000sw_is_phyport(sc, phy) || reg >= E6000SW_NUM_PHY_REGS) {
|
||||
device_printf(dev, "Wrong register address.\n");
|
||||
return (EINVAL);
|
||||
@ -514,22 +487,20 @@ e6000sw_writephy(device_t dev, int phy, int reg, int data)
|
||||
return (err);
|
||||
}
|
||||
|
||||
val = 1 << PHY_CMD_SMI_BUSY;
|
||||
val |= PHY_CMD_MODE_MDIO << PHY_CMD_MODE;
|
||||
val |= 1 << PHY_CMD_SMI_BUSY;
|
||||
val |= PHY_CMD_OPCODE_WRITE << PHY_CMD_OPCODE;
|
||||
val |= (reg << PHY_CMD_REG_ADDR) & PHY_CMD_REG_ADDR_MASK;
|
||||
val |= (phy << PHY_CMD_DEV_ADDR) & PHY_CMD_DEV_ADDR_MASK;
|
||||
e6000sw_writereg(sc, REG_GLOBAL2, SMI_PHY_DATA_REG,
|
||||
data & PHY_DATA_MASK);
|
||||
data & PHY_DATA_MASK);
|
||||
e6000sw_writereg(sc, REG_GLOBAL2, SMI_PHY_CMD_REG, val);
|
||||
|
||||
err = e6000sw_poll_done(sc);
|
||||
if (err != 0) {
|
||||
if (err != 0)
|
||||
device_printf(dev, "Timeout while waiting for switch\n");
|
||||
return (err);
|
||||
}
|
||||
|
||||
return (0);
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -589,18 +560,14 @@ e6000sw_getport(device_t dev, etherswitch_port_t *p)
|
||||
int err;
|
||||
struct ifmediareq *ifmr;
|
||||
|
||||
err = 0;
|
||||
e6000sw_softc_t *sc = device_get_softc(dev);
|
||||
E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
|
||||
|
||||
if (p->es_port >= sc->num_ports || p->es_port < 0)
|
||||
return (EINVAL);
|
||||
|
||||
err = 0;
|
||||
E6000SW_LOCK(sc);
|
||||
|
||||
if (p->es_port >= sc->num_ports ||
|
||||
p->es_port < 0) {
|
||||
err = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
e6000sw_get_pvid(sc, p->es_port, &p->es_pvid);
|
||||
|
||||
if (e6000sw_is_cpuport(sc, p->es_port)) {
|
||||
@ -623,9 +590,8 @@ e6000sw_getport(device_t dev, etherswitch_port_t *p)
|
||||
err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr,
|
||||
&mii->mii_media, SIOCGIFMEDIA);
|
||||
}
|
||||
|
||||
out:
|
||||
E6000SW_UNLOCK(sc);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
@ -636,18 +602,14 @@ e6000sw_setport(device_t dev, etherswitch_port_t *p)
|
||||
int err;
|
||||
struct mii_data *mii;
|
||||
|
||||
err = 0;
|
||||
sc = device_get_softc(dev);
|
||||
E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
|
||||
|
||||
if (p->es_port >= sc->num_ports || p->es_port < 0)
|
||||
return (EINVAL);
|
||||
|
||||
err = 0;
|
||||
E6000SW_LOCK(sc);
|
||||
|
||||
if (p->es_port >= sc->num_ports ||
|
||||
p->es_port < 0) {
|
||||
err = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (p->es_pvid != 0)
|
||||
e6000sw_set_pvid(sc, p->es_port, p->es_pvid);
|
||||
if (!e6000sw_is_cpuport(sc, p->es_port)) {
|
||||
@ -655,9 +617,8 @@ e6000sw_setport(device_t dev, etherswitch_port_t *p)
|
||||
err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr, &mii->mii_media,
|
||||
SIOCSIFMEDIA);
|
||||
}
|
||||
|
||||
out:
|
||||
E6000SW_UNLOCK(sc);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
@ -773,12 +734,10 @@ e6000sw_flush_port(e6000sw_softc_t *sc, int port)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = e6000sw_readreg(sc, REG_PORT(port),
|
||||
PORT_VLAN_MAP);
|
||||
reg = e6000sw_readreg(sc, REG_PORT(port), PORT_VLAN_MAP);
|
||||
reg &= ~PORT_VLAN_MAP_TABLE_MASK;
|
||||
reg &= ~PORT_VLAN_MAP_FID_MASK;
|
||||
e6000sw_writereg(sc, REG_PORT(port),
|
||||
PORT_VLAN_MAP, reg);
|
||||
e6000sw_writereg(sc, REG_PORT(port), PORT_VLAN_MAP, reg);
|
||||
if (sc->vgroup[port] != E6000SW_PORT_NO_VGROUP) {
|
||||
/*
|
||||
* If port belonged somewhere, owner-group
|
||||
@ -795,14 +754,12 @@ e6000sw_port_assign_vgroup(e6000sw_softc_t *sc, int port, int fid, int vgroup,
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = e6000sw_readreg(sc, REG_PORT(port),
|
||||
PORT_VLAN_MAP);
|
||||
reg = e6000sw_readreg(sc, REG_PORT(port), PORT_VLAN_MAP);
|
||||
reg &= ~PORT_VLAN_MAP_TABLE_MASK;
|
||||
reg &= ~PORT_VLAN_MAP_FID_MASK;
|
||||
reg |= members & ~(1 << port);
|
||||
reg |= (fid << PORT_VLAN_MAP_FID) & PORT_VLAN_MAP_FID_MASK;
|
||||
e6000sw_writereg(sc, REG_PORT(port), PORT_VLAN_MAP,
|
||||
reg);
|
||||
e6000sw_writereg(sc, REG_PORT(port), PORT_VLAN_MAP, reg);
|
||||
sc->vgroup[port] = vgroup;
|
||||
}
|
||||
|
||||
@ -897,19 +854,18 @@ e6000sw_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
||||
ifmr->ifm_status = mii->mii_media_status;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
e6000sw_smi_waitready(e6000sw_softc_t *sc, int phy)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < E6000SW_SMI_TIMEOUT; i++) {
|
||||
if ((MDIO_READ(sc->dev, phy, SMI_CMD)
|
||||
& SMI_CMD_BUSY) == 0)
|
||||
return 0;
|
||||
if ((MDIO_READ(sc->dev, phy, SMI_CMD) & SMI_CMD_BUSY) == 0)
|
||||
return (0);
|
||||
DELAY(1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
@ -925,8 +881,8 @@ e6000sw_readreg(e6000sw_softc_t *sc, int addr, int reg)
|
||||
printf("e6000sw: readreg timeout\n");
|
||||
return (0xffff);
|
||||
}
|
||||
MDIO_WRITE(sc->dev, sc->sw_addr, SMI_CMD, SMI_CMD_OP_READ |
|
||||
(addr << 5) | reg);
|
||||
MDIO_WRITE(sc->dev, sc->sw_addr, SMI_CMD,
|
||||
SMI_CMD_OP_READ | (addr << 5) | reg);
|
||||
if (e6000sw_smi_waitready(sc, sc->sw_addr)) {
|
||||
printf("e6000sw: readreg timeout\n");
|
||||
return (0xffff);
|
||||
@ -951,14 +907,12 @@ e6000sw_writereg(e6000sw_softc_t *sc, int addr, int reg, int val)
|
||||
return;
|
||||
}
|
||||
MDIO_WRITE(sc->dev, sc->sw_addr, SMI_DATA, val);
|
||||
MDIO_WRITE(sc->dev, sc->sw_addr, SMI_CMD, SMI_CMD_OP_WRITE |
|
||||
(addr << 5) | reg);
|
||||
MDIO_WRITE(sc->dev, sc->sw_addr, SMI_CMD,
|
||||
SMI_CMD_OP_WRITE | (addr << 5) | reg);
|
||||
if (e6000sw_smi_waitready(sc, sc->sw_addr)) {
|
||||
printf("e6000sw: readreg timeout\n");
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline int
|
||||
|
@ -155,8 +155,6 @@ struct atu_opt {
|
||||
#define SMI_PHY_CMD_REG 0x18
|
||||
#define SMI_PHY_DATA_REG 0x19
|
||||
|
||||
#define PHY_CMD 0x18
|
||||
#define PHY_DATA 0x19
|
||||
#define PHY_DATA_MASK 0xffff
|
||||
|
||||
#define PHY_CMD_SMI_BUSY 15
|
||||
|
@ -117,9 +117,18 @@ static int
|
||||
phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node)
|
||||
{
|
||||
char buf[64];
|
||||
char *sep;
|
||||
|
||||
if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0)
|
||||
return (ENXIO);
|
||||
/*
|
||||
* stdout-path may have a ':' to separate the device from the
|
||||
* connection settings. Split the string so we just pass the former
|
||||
* to OF_finddevice.
|
||||
*/
|
||||
sep = strchr(buf, ':');
|
||||
if (sep != NULL)
|
||||
*sep = '\0';
|
||||
if ((*node = OF_finddevice(buf)) == -1)
|
||||
return (ENXIO);
|
||||
|
||||
|
@ -1767,6 +1767,9 @@ xn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
#endif
|
||||
break;
|
||||
case SIOCSIFMTU:
|
||||
if (ifp->if_mtu == ifr->ifr_mtu)
|
||||
break;
|
||||
|
||||
ifp->if_mtu = ifr->ifr_mtu;
|
||||
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
xn_ifinit(sc);
|
||||
|
@ -179,7 +179,7 @@ struct denode {
|
||||
#define DE_INTERNALIZE32(dep, dp) \
|
||||
((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16)
|
||||
#define DE_INTERNALIZE(dep, dp) \
|
||||
(bcopy((dp)->deName, (dep)->de_Name, 11), \
|
||||
(memcpy((dep)->de_Name, (dp)->deName, 11), \
|
||||
(dep)->de_Attributes = (dp)->deAttributes, \
|
||||
(dep)->de_LowerCase = (dp)->deLowerCase, \
|
||||
(dep)->de_CHun = (dp)->deCHundredth, \
|
||||
@ -193,7 +193,7 @@ struct denode {
|
||||
(FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0))
|
||||
|
||||
#define DE_EXTERNALIZE(dp, dep) \
|
||||
(bcopy((dep)->de_Name, (dp)->deName, 11), \
|
||||
(memcpy((dp)->deName, (dep)->de_Name, 11), \
|
||||
(dp)->deAttributes = (dep)->de_Attributes, \
|
||||
(dp)->deLowerCase = (dep)->de_LowerCase, \
|
||||
(dp)->deCHundredth = (dep)->de_CHun, \
|
||||
|
@ -536,7 +536,7 @@ unix2winfn(const u_char *un, size_t unlen, struct winentry *wep, int cnt,
|
||||
/*
|
||||
* Initialize winentry to some useful default
|
||||
*/
|
||||
for (wcp = (uint8_t *)wep, i = sizeof(*wep); --i >= 0; *wcp++ = 0xff);
|
||||
memset(wep, 0xff, sizeof(*wep));
|
||||
wep->weCnt = cnt;
|
||||
wep->weAttributes = ATTR_WIN95;
|
||||
wep->weReserved1 = 0;
|
||||
@ -1043,11 +1043,11 @@ mbnambuf_write(struct mbnambuf *nbp, char *name, int id)
|
||||
sizeof(nbp->nb_buf))
|
||||
return (ENAMETOOLONG);
|
||||
|
||||
bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len);
|
||||
memmove(slot + count, slot + WIN_CHARS, nbp->nb_len);
|
||||
}
|
||||
|
||||
/* Copy in the substring to its slot and update length so far. */
|
||||
bcopy(name, slot, count);
|
||||
memcpy(slot, name, count);
|
||||
nbp->nb_len = newlen;
|
||||
nbp->nb_last_id = id;
|
||||
|
||||
@ -1069,7 +1069,7 @@ mbnambuf_flush(struct mbnambuf *nbp, struct dirent *dp)
|
||||
mbnambuf_init(nbp);
|
||||
return (NULL);
|
||||
}
|
||||
bcopy(&nbp->nb_buf[0], dp->d_name, nbp->nb_len);
|
||||
memcpy(dp->d_name, &nbp->nb_buf[0], nbp->nb_len);
|
||||
dp->d_name[nbp->nb_len] = '\0';
|
||||
dp->d_namlen = nbp->nb_len;
|
||||
|
||||
|
@ -410,7 +410,7 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
bzero(bp->b_data + boff, pmp->pm_bpcluster - boff);
|
||||
memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
|
||||
if (flags & IO_SYNC)
|
||||
bwrite(bp);
|
||||
else
|
||||
|
@ -335,7 +335,7 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
|
||||
/* getblk() never fails */
|
||||
bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount,
|
||||
0, 0, 0);
|
||||
bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
|
||||
memcpy(bpn->b_data, bp->b_data, bp->b_bcount);
|
||||
/* Force the clean bit on in the other copies. */
|
||||
if (cleanfat == 16)
|
||||
((uint8_t *)bpn->b_data)[3] |= 0x80;
|
||||
|
@ -165,7 +165,7 @@ msdosfs_create(struct vop_create_args *ap)
|
||||
if ((cnp->cn_flags & HASBUF) == 0)
|
||||
panic("msdosfs_create: no name");
|
||||
#endif
|
||||
bzero(&ndirent, sizeof(ndirent));
|
||||
memset(&ndirent, 0, sizeof(ndirent));
|
||||
error = uniqdosname(pdep, cnp, ndirent.de_Name);
|
||||
if (error)
|
||||
goto bad;
|
||||
@ -1156,13 +1156,13 @@ msdosfs_rename(struct vop_rename_args *ap)
|
||||
* we moved a directory, then update its .. entry to point
|
||||
* to the new parent directory.
|
||||
*/
|
||||
bcopy(ip->de_Name, oldname, 11);
|
||||
bcopy(toname, ip->de_Name, 11); /* update denode */
|
||||
memcpy(oldname, ip->de_Name, 11);
|
||||
memcpy(ip->de_Name, toname, 11); /* update denode */
|
||||
dp->de_fndoffset = to_diroffset;
|
||||
dp->de_fndcnt = to_count;
|
||||
error = createde(ip, dp, (struct denode **)0, tcnp);
|
||||
if (error) {
|
||||
bcopy(oldname, ip->de_Name, 11);
|
||||
memcpy(ip->de_Name, oldname, 11);
|
||||
if (newparent)
|
||||
VOP_UNLOCK(fdvp, 0);
|
||||
VOP_UNLOCK(fvp, 0);
|
||||
@ -1178,7 +1178,7 @@ msdosfs_rename(struct vop_rename_args *ap)
|
||||
* to pass the correct name to createde(). Undo this.
|
||||
*/
|
||||
if ((ip->de_Attributes & ATTR_DIRECTORY) != 0)
|
||||
bcopy(oldname, ip->de_Name, 11);
|
||||
memcpy(ip->de_Name, oldname, 11);
|
||||
ip->de_refcnt++;
|
||||
zp->de_fndoffset = from_diroffset;
|
||||
error = removede(zp, ip);
|
||||
@ -1324,7 +1324,7 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
|
||||
if (error)
|
||||
goto bad2;
|
||||
|
||||
bzero(&ndirent, sizeof(ndirent));
|
||||
memset(&ndirent, 0, sizeof(ndirent));
|
||||
ndirent.de_pmp = pmp;
|
||||
ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
|
||||
getnanotime(&ts);
|
||||
@ -1338,8 +1338,8 @@ msdosfs_mkdir(struct vop_mkdir_args *ap)
|
||||
bn = cntobn(pmp, newcluster);
|
||||
/* always succeeds */
|
||||
bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0, 0);
|
||||
bzero(bp->b_data, pmp->pm_bpcluster);
|
||||
bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
|
||||
memset(bp->b_data, 0, pmp->pm_bpcluster);
|
||||
memcpy(bp->b_data, &dosdirtemplate, sizeof dosdirtemplate);
|
||||
denp = (struct direntry *)bp->b_data;
|
||||
putushort(denp[0].deStartCluster, newcluster);
|
||||
putushort(denp[0].deCDate, ndirent.de_CDate);
|
||||
@ -1504,7 +1504,7 @@ msdosfs_readdir(struct vop_readdir_args *ap)
|
||||
/*
|
||||
* To be safe, initialize dirbuf
|
||||
*/
|
||||
bzero(dirbuf.d_name, sizeof(dirbuf.d_name));
|
||||
memset(dirbuf.d_name, 0, sizeof(dirbuf.d_name));
|
||||
|
||||
/*
|
||||
* If the user buffer is smaller than the size of one dos directory
|
||||
|
@ -226,6 +226,8 @@ proc_dtor(void *mem, int size, void *arg)
|
||||
#endif
|
||||
/* Free all OSD associated to this thread. */
|
||||
osd_thread_exit(td);
|
||||
td_softdep_cleanup(td);
|
||||
MPASS(td->td_su == NULL);
|
||||
|
||||
/* Make sure all thread destructors are executed */
|
||||
EVENTHANDLER_INVOKE(thread_dtor, td);
|
||||
|
@ -207,12 +207,12 @@ xfsize(int i, int n, off_t off, off_t len)
|
||||
/*
|
||||
* Helper function to get offset within object for i page.
|
||||
*/
|
||||
static inline vm_offset_t
|
||||
static inline vm_ooffset_t
|
||||
vmoff(int i, off_t off)
|
||||
{
|
||||
|
||||
if (i == 0)
|
||||
return ((vm_offset_t)off);
|
||||
return ((vm_ooffset_t)off);
|
||||
|
||||
return (trunc_page(off + i * PAGE_SIZE));
|
||||
}
|
||||
|
@ -130,8 +130,7 @@ accept_filt_generic_mod_event(module_t mod, int event, void *data)
|
||||
|
||||
switch (event) {
|
||||
case MOD_LOAD:
|
||||
p = malloc(sizeof(*p), M_ACCF,
|
||||
M_WAITOK);
|
||||
p = malloc(sizeof(*p), M_ACCF, M_WAITOK);
|
||||
bcopy(accfp, p, sizeof(*p));
|
||||
error = accept_filt_add(p);
|
||||
break;
|
||||
@ -162,14 +161,13 @@ accept_filt_generic_mod_event(module_t mod, int event, void *data)
|
||||
}
|
||||
|
||||
int
|
||||
do_getopt_accept_filter(struct socket *so, struct sockopt *sopt)
|
||||
accept_filt_getopt(struct socket *so, struct sockopt *sopt)
|
||||
{
|
||||
struct accept_filter_arg *afap;
|
||||
int error;
|
||||
|
||||
error = 0;
|
||||
afap = malloc(sizeof(*afap), M_TEMP,
|
||||
M_WAITOK | M_ZERO);
|
||||
afap = malloc(sizeof(*afap), M_TEMP, M_WAITOK | M_ZERO);
|
||||
SOCK_LOCK(so);
|
||||
if ((so->so_options & SO_ACCEPTCONN) == 0) {
|
||||
error = EINVAL;
|
||||
@ -191,7 +189,7 @@ do_getopt_accept_filter(struct socket *so, struct sockopt *sopt)
|
||||
}
|
||||
|
||||
int
|
||||
do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
|
||||
accept_filt_setopt(struct socket *so, struct sockopt *sopt)
|
||||
{
|
||||
struct accept_filter_arg *afap;
|
||||
struct accept_filter *afp;
|
||||
@ -227,8 +225,7 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
|
||||
* Pre-allocate any memory we may need later to avoid blocking at
|
||||
* untimely moments. This does not optimize for invalid arguments.
|
||||
*/
|
||||
afap = malloc(sizeof(*afap), M_TEMP,
|
||||
M_WAITOK);
|
||||
afap = malloc(sizeof(*afap), M_TEMP, M_WAITOK);
|
||||
error = sooptcopyin(sopt, afap, sizeof *afap, sizeof *afap);
|
||||
afap->af_name[sizeof(afap->af_name)-1] = '\0';
|
||||
afap->af_arg[sizeof(afap->af_arg)-1] = '\0';
|
||||
@ -247,12 +244,10 @@ do_setopt_accept_filter(struct socket *so, struct sockopt *sopt)
|
||||
* attached properly, 'newaf' is NULLed to avoid a free()
|
||||
* while in use.
|
||||
*/
|
||||
newaf = malloc(sizeof(*newaf), M_ACCF, M_WAITOK |
|
||||
M_ZERO);
|
||||
newaf = malloc(sizeof(*newaf), M_ACCF, M_WAITOK | M_ZERO);
|
||||
if (afp->accf_create != NULL && afap->af_name[0] != '\0') {
|
||||
size_t len = strlen(afap->af_name) + 1;
|
||||
newaf->so_accept_filter_str = malloc(len, M_ACCF,
|
||||
M_WAITOK);
|
||||
newaf->so_accept_filter_str = malloc(len, M_ACCF, M_WAITOK);
|
||||
strcpy(newaf->so_accept_filter_str, afap->af_name);
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ sodealloc(struct socket *so)
|
||||
&so->so_snd.sb_hiwat, 0, RLIM_INFINITY);
|
||||
/* remove accept filter if one is present. */
|
||||
if (so->so_accf != NULL)
|
||||
do_setopt_accept_filter(so, NULL);
|
||||
accept_filt_setopt(so, NULL);
|
||||
#ifdef MAC
|
||||
mac_socket_destroy(so);
|
||||
#endif
|
||||
@ -2526,7 +2526,7 @@ sosetopt(struct socket *so, struct sockopt *sopt)
|
||||
} else {
|
||||
switch (sopt->sopt_name) {
|
||||
case SO_ACCEPTFILTER:
|
||||
error = do_setopt_accept_filter(so, sopt);
|
||||
error = accept_filt_setopt(so, sopt);
|
||||
if (error)
|
||||
goto bad;
|
||||
break;
|
||||
@ -2784,7 +2784,7 @@ sogetopt(struct socket *so, struct sockopt *sopt)
|
||||
} else {
|
||||
switch (sopt->sopt_name) {
|
||||
case SO_ACCEPTFILTER:
|
||||
error = do_getopt_accept_filter(so, sopt);
|
||||
error = accept_filt_getopt(so, sopt);
|
||||
break;
|
||||
|
||||
case SO_LINGER:
|
||||
|
@ -552,7 +552,7 @@ uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
|
||||
UNP_LINK_WLOCK();
|
||||
UNP_PCB_LOCK(unp);
|
||||
VOP_UNP_BIND(vp, unp->unp_socket);
|
||||
VOP_UNP_BIND(vp, unp);
|
||||
unp->unp_vnode = vp;
|
||||
unp->unp_addr = soun;
|
||||
unp->unp_flags &= ~UNP_BINDING;
|
||||
@ -670,9 +670,6 @@ uipc_detach(struct socket *so)
|
||||
UNP_LINK_WLOCK();
|
||||
UNP_PCB_LOCK(unp);
|
||||
|
||||
/*
|
||||
* XXXRW: Should assert vp->v_socket == so.
|
||||
*/
|
||||
if ((vp = unp->unp_vnode) != NULL) {
|
||||
VOP_UNP_DETACH(vp);
|
||||
unp->unp_vnode = NULL;
|
||||
@ -761,7 +758,6 @@ uipc_listen(struct socket *so, int backlog, struct thread *td)
|
||||
error = solisten_proto_check(so);
|
||||
if (error == 0) {
|
||||
cru2x(td->td_ucred, &unp->unp_peercred);
|
||||
unp->unp_flags |= UNP_HAVEPCCACHED;
|
||||
solisten_proto(so, backlog);
|
||||
}
|
||||
SOCK_UNLOCK(so);
|
||||
@ -1386,11 +1382,12 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
|
||||
* and to protect simultaneous locking of multiple pcbs.
|
||||
*/
|
||||
UNP_LINK_WLOCK();
|
||||
VOP_UNP_CONNECT(vp, &so2);
|
||||
if (so2 == NULL) {
|
||||
VOP_UNP_CONNECT(vp, &unp2);
|
||||
if (unp2 == NULL) {
|
||||
error = ECONNREFUSED;
|
||||
goto bad2;
|
||||
}
|
||||
so2 = unp2->unp_socket;
|
||||
if (so->so_type != so2->so_type) {
|
||||
error = EPROTOTYPE;
|
||||
goto bad2;
|
||||
@ -1431,8 +1428,6 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
|
||||
* listen(); uipc_listen() cached that process's credentials
|
||||
* at that time so we can use them now.
|
||||
*/
|
||||
KASSERT(unp2->unp_flags & UNP_HAVEPCCACHED,
|
||||
("unp_connect: listener without cached peercred"));
|
||||
memcpy(&unp->unp_peercred, &unp2->unp_peercred,
|
||||
sizeof(unp->unp_peercred));
|
||||
unp->unp_flags |= UNP_HAVEPC;
|
||||
@ -2454,7 +2449,6 @@ unp_scan(struct mbuf *m0, void (*op)(struct filedescent **, int))
|
||||
void
|
||||
vfs_unp_reclaim(struct vnode *vp)
|
||||
{
|
||||
struct socket *so;
|
||||
struct unpcb *unp;
|
||||
int active;
|
||||
|
||||
@ -2464,10 +2458,7 @@ vfs_unp_reclaim(struct vnode *vp)
|
||||
|
||||
active = 0;
|
||||
UNP_LINK_WLOCK();
|
||||
VOP_UNP_CONNECT(vp, &so);
|
||||
if (so == NULL)
|
||||
goto done;
|
||||
unp = sotounpcb(so);
|
||||
VOP_UNP_CONNECT(vp, &unp);
|
||||
if (unp == NULL)
|
||||
goto done;
|
||||
UNP_PCB_LOCK(unp);
|
||||
@ -2503,10 +2494,6 @@ db_print_unpflags(int unp_flags)
|
||||
db_printf("%sUNP_HAVEPC", comma ? ", " : "");
|
||||
comma = 1;
|
||||
}
|
||||
if (unp_flags & UNP_HAVEPCCACHED) {
|
||||
db_printf("%sUNP_HAVEPCCACHED", comma ? ", " : "");
|
||||
comma = 1;
|
||||
}
|
||||
if (unp_flags & UNP_WANTCRED) {
|
||||
db_printf("%sUNP_WANTCRED", comma ? ", " : "");
|
||||
comma = 1;
|
||||
|
@ -1128,7 +1128,7 @@ int
|
||||
vop_stdunp_bind(struct vop_unp_bind_args *ap)
|
||||
{
|
||||
|
||||
ap->a_vp->v_socket = ap->a_socket;
|
||||
ap->a_vp->v_unpcb = ap->a_unpcb;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1136,7 +1136,7 @@ int
|
||||
vop_stdunp_connect(struct vop_unp_connect_args *ap)
|
||||
{
|
||||
|
||||
*ap->a_socket = ap->a_vp->v_socket;
|
||||
*ap->a_unpcb = ap->a_vp->v_unpcb;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -1144,7 +1144,7 @@ int
|
||||
vop_stdunp_detach(struct vop_unp_detach_args *ap)
|
||||
{
|
||||
|
||||
ap->a_vp->v_socket = NULL;
|
||||
ap->a_vp->v_unpcb = NULL;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -2994,7 +2994,10 @@ _vdrop(struct vnode *vp, bool locked)
|
||||
/* XXX Elsewhere we detect an already freed vnode via NULL v_op. */
|
||||
vp->v_op = NULL;
|
||||
#endif
|
||||
bzero(&vp->v_un, sizeof(vp->v_un));
|
||||
vp->v_mountedhere = NULL;
|
||||
vp->v_unpcb = NULL;
|
||||
vp->v_rdev = NULL;
|
||||
vp->v_fifoinfo = NULL;
|
||||
vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0;
|
||||
vp->v_iflag = 0;
|
||||
vp->v_vflag = 0;
|
||||
|
@ -662,7 +662,7 @@ vop_advise {
|
||||
|
||||
vop_unp_bind {
|
||||
IN struct vnode *vp;
|
||||
IN struct socket *socket;
|
||||
IN struct unpcb *unpcb;
|
||||
};
|
||||
|
||||
|
||||
@ -670,7 +670,7 @@ vop_unp_bind {
|
||||
|
||||
vop_unp_connect {
|
||||
IN struct vnode *vp;
|
||||
OUT struct socket **socket;
|
||||
OUT struct unpcb **unpcb;
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,8 +64,8 @@ int sooptcopyout(struct sockopt *sopt, const void *buf, size_t len);
|
||||
int soopt_getm(struct sockopt *sopt, struct mbuf **mp);
|
||||
int soopt_mcopyin(struct sockopt *sopt, struct mbuf *m);
|
||||
int soopt_mcopyout(struct sockopt *sopt, struct mbuf *m);
|
||||
int do_getopt_accept_filter(struct socket *so, struct sockopt *sopt);
|
||||
int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt);
|
||||
int accept_filt_getopt(struct socket *, struct sockopt *);
|
||||
int accept_filt_setopt(struct socket *, struct sockopt *);
|
||||
int so_setsockopt(struct socket *so, int level, int optname,
|
||||
void *optval, size_t optlen);
|
||||
|
||||
|
@ -92,14 +92,8 @@ struct unpcb {
|
||||
* and is really the credentials of the connected peer. This is used
|
||||
* to determine whether the contents should be sent to the user or
|
||||
* not.
|
||||
*
|
||||
* UNP_HAVEPCCACHED - indicates that the unp_peercred member is filled
|
||||
* in, but does *not* contain the credentials of the connected peer
|
||||
* (there may not even be a peer). This is set in unp_listen() when
|
||||
* it fills in unp_peercred for later consumption by unp_connect().
|
||||
*/
|
||||
#define UNP_HAVEPC 0x001
|
||||
#define UNP_HAVEPCCACHED 0x002
|
||||
#define UNP_WANTCRED 0x004 /* credentials wanted */
|
||||
#define UNP_CONNWAIT 0x008 /* connect blocks until accepted */
|
||||
|
||||
|
@ -112,14 +112,13 @@ struct vnode {
|
||||
|
||||
/*
|
||||
* Type specific fields, only one applies to any given vnode.
|
||||
* See #defines below for renaming to v_* namespace.
|
||||
*/
|
||||
union {
|
||||
struct mount *vu_mount; /* v ptr to mountpoint (VDIR) */
|
||||
struct socket *vu_socket; /* v unix domain net (VSOCK) */
|
||||
struct cdev *vu_cdev; /* v device (VCHR, VBLK) */
|
||||
struct fifoinfo *vu_fifoinfo; /* v fifo (VFIFO) */
|
||||
} v_un;
|
||||
struct mount *v_mountedhere; /* v ptr to mountpoint (VDIR) */
|
||||
struct unpcb *v_unpcb; /* v unix domain net (VSOCK) */
|
||||
struct cdev *v_rdev; /* v device (VCHR, VBLK) */
|
||||
struct fifoinfo *v_fifoinfo; /* v fifo (VFIFO) */
|
||||
};
|
||||
|
||||
/*
|
||||
* vfs_hash: (mount + inode) -> vnode hash. The hash value
|
||||
@ -175,11 +174,6 @@ struct vnode {
|
||||
|
||||
#endif /* defined(_KERNEL) || defined(_KVM_VNODE) */
|
||||
|
||||
#define v_mountedhere v_un.vu_mount
|
||||
#define v_socket v_un.vu_socket
|
||||
#define v_rdev v_un.vu_cdev
|
||||
#define v_fifoinfo v_un.vu_fifoinfo
|
||||
|
||||
#define bo2vnode(bo) __containerof((bo), struct vnode, v_bufobj)
|
||||
|
||||
/* XXX: These are temporary to avoid a source sweep at this time */
|
||||
@ -200,7 +194,7 @@ struct xvnode {
|
||||
long xv_numoutput; /* num of writes in progress */
|
||||
enum vtype xv_type; /* vnode type */
|
||||
union {
|
||||
void *xvu_socket; /* socket, if VSOCK */
|
||||
void *xvu_socket; /* unpcb, if VSOCK */
|
||||
void *xvu_fifo; /* fifo, if VFIFO */
|
||||
dev_t xvu_rdev; /* maj/min, if VBLK/VCHR */
|
||||
struct {
|
||||
|
@ -901,6 +901,7 @@ static int pagedep_find(struct pagedep_hashhead *, ino_t, ufs_lbn_t,
|
||||
struct pagedep **);
|
||||
static void pause_timer(void *);
|
||||
static int request_cleanup(struct mount *, int);
|
||||
static int softdep_request_cleanup_flush(struct mount *, struct ufsmount *);
|
||||
static void schedule_cleanup(struct mount *);
|
||||
static void softdep_ast_cleanup_proc(struct thread *);
|
||||
static int process_worklist_item(struct mount *, int, int);
|
||||
@ -13274,10 +13275,9 @@ softdep_request_cleanup(fs, vp, cred, resource)
|
||||
{
|
||||
struct ufsmount *ump;
|
||||
struct mount *mp;
|
||||
struct vnode *lvp, *mvp;
|
||||
long starttime;
|
||||
ufs2_daddr_t needed;
|
||||
int error;
|
||||
int error, failed_vnode;
|
||||
|
||||
/*
|
||||
* If we are being called because of a process doing a
|
||||
@ -13368,41 +13368,88 @@ softdep_request_cleanup(fs, vp, cred, resource)
|
||||
* to the worklist that we can then process to reap addition
|
||||
* resources. We walk the vnodes associated with the mount point
|
||||
* until we get the needed worklist requests that we can reap.
|
||||
*
|
||||
* If there are several threads all needing to clean the same
|
||||
* mount point, only one is allowed to walk the mount list.
|
||||
* When several threads all try to walk the same mount list,
|
||||
* they end up competing with each other and often end up in
|
||||
* livelock. This approach ensures that forward progress is
|
||||
* made at the cost of occational ENOSPC errors being returned
|
||||
* that might otherwise have been avoided.
|
||||
*/
|
||||
error = 1;
|
||||
if ((resource == FLUSH_BLOCKS_WAIT &&
|
||||
fs->fs_cstotal.cs_nbfree <= needed) ||
|
||||
(resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 &&
|
||||
fs->fs_cstotal.cs_nifree <= needed)) {
|
||||
MNT_VNODE_FOREACH_ALL(lvp, mp, mvp) {
|
||||
if (TAILQ_FIRST(&lvp->v_bufobj.bo_dirty.bv_hd) == 0) {
|
||||
VI_UNLOCK(lvp);
|
||||
continue;
|
||||
ACQUIRE_LOCK(ump);
|
||||
if ((ump->um_softdep->sd_flags & FLUSH_RC_ACTIVE) == 0) {
|
||||
ump->um_softdep->sd_flags |= FLUSH_RC_ACTIVE;
|
||||
FREE_LOCK(ump);
|
||||
failed_vnode = softdep_request_cleanup_flush(mp, ump);
|
||||
ACQUIRE_LOCK(ump);
|
||||
ump->um_softdep->sd_flags &= ~FLUSH_RC_ACTIVE;
|
||||
FREE_LOCK(ump);
|
||||
if (ump->softdep_on_worklist > 0) {
|
||||
stat_cleanup_retries += 1;
|
||||
if (!failed_vnode)
|
||||
goto retry;
|
||||
}
|
||||
if (vget(lvp, LK_EXCLUSIVE | LK_INTERLOCK | LK_NOWAIT,
|
||||
curthread))
|
||||
continue;
|
||||
if (lvp->v_vflag & VV_NOSYNC) { /* unlinked */
|
||||
vput(lvp);
|
||||
continue;
|
||||
}
|
||||
(void) ffs_syncvnode(lvp, MNT_NOWAIT, 0);
|
||||
vput(lvp);
|
||||
}
|
||||
lvp = ump->um_devvp;
|
||||
if (vn_lock(lvp, LK_EXCLUSIVE | LK_NOWAIT) == 0) {
|
||||
VOP_FSYNC(lvp, MNT_NOWAIT, curthread);
|
||||
VOP_UNLOCK(lvp, 0);
|
||||
}
|
||||
if (ump->softdep_on_worklist > 0) {
|
||||
stat_cleanup_retries += 1;
|
||||
goto retry;
|
||||
} else {
|
||||
FREE_LOCK(ump);
|
||||
error = 0;
|
||||
}
|
||||
stat_cleanup_failures += 1;
|
||||
}
|
||||
if (time_second - starttime > stat_cleanup_high_delay)
|
||||
stat_cleanup_high_delay = time_second - starttime;
|
||||
UFS_LOCK(ump);
|
||||
return (1);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the vnodes for the specified mount point flushing out any
|
||||
* vnodes that can be locked without waiting. Finally, try to flush
|
||||
* the device associated with the mount point if it can be locked
|
||||
* without waiting.
|
||||
*
|
||||
* We return 0 if we were able to lock every vnode in our scan.
|
||||
* If we had to skip one or more vnodes, we return 1.
|
||||
*/
|
||||
static int
|
||||
softdep_request_cleanup_flush(mp, ump)
|
||||
struct mount *mp;
|
||||
struct ufsmount *ump;
|
||||
{
|
||||
struct thread *td;
|
||||
struct vnode *lvp, *mvp;
|
||||
int failed_vnode;
|
||||
|
||||
failed_vnode = 0;
|
||||
td = curthread;
|
||||
MNT_VNODE_FOREACH_ALL(lvp, mp, mvp) {
|
||||
if (TAILQ_FIRST(&lvp->v_bufobj.bo_dirty.bv_hd) == 0) {
|
||||
VI_UNLOCK(lvp);
|
||||
continue;
|
||||
}
|
||||
if (vget(lvp, LK_EXCLUSIVE | LK_INTERLOCK | LK_NOWAIT,
|
||||
td) != 0) {
|
||||
failed_vnode = 1;
|
||||
continue;
|
||||
}
|
||||
if (lvp->v_vflag & VV_NOSYNC) { /* unlinked */
|
||||
vput(lvp);
|
||||
continue;
|
||||
}
|
||||
(void) ffs_syncvnode(lvp, MNT_NOWAIT, 0);
|
||||
vput(lvp);
|
||||
}
|
||||
lvp = ump->um_devvp;
|
||||
if (vn_lock(lvp, LK_EXCLUSIVE | LK_NOWAIT) == 0) {
|
||||
VOP_FSYNC(lvp, MNT_NOWAIT, td);
|
||||
VOP_UNLOCK(lvp, 0);
|
||||
}
|
||||
return (failed_vnode);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -1319,6 +1319,10 @@ ffs_unmount(mp, mntflags)
|
||||
MNT_ILOCK(mp);
|
||||
mp->mnt_flag &= ~MNT_LOCAL;
|
||||
MNT_IUNLOCK(mp);
|
||||
if (td->td_su == mp) {
|
||||
td->td_su = NULL;
|
||||
vfs_rel(mp);
|
||||
}
|
||||
return (error);
|
||||
|
||||
fail:
|
||||
|
@ -1065,6 +1065,7 @@ struct mount_softdeps {
|
||||
#define FLUSH_EXIT 0x0001 /* time to exit */
|
||||
#define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */
|
||||
#define FLUSH_STARTING 0x0004 /* flush thread not yet started */
|
||||
#define FLUSH_RC_ACTIVE 0x0008 /* a thread is flushing the mount point */
|
||||
|
||||
/*
|
||||
* Keep the old names from when these were in the ufsmount structure.
|
||||
|
@ -46,7 +46,7 @@ struct stat stb1, stb2;
|
||||
struct excludes *excludes_list;
|
||||
regex_t ignore_re;
|
||||
|
||||
#define OPTIONS "0123456789aBbC:cdD:efhI:iL:lnNPpqrS:sTtU:uwX:x:"
|
||||
#define OPTIONS "0123456789aBbC:cdD:efHhI:iL:lnNPpqrS:sTtU:uwX:x:"
|
||||
enum {
|
||||
OPT_TSIZE = CHAR_MAX + 1,
|
||||
OPT_STRIPCR,
|
||||
@ -54,7 +54,6 @@ enum {
|
||||
OPT_NO_IGN_FN_CASE,
|
||||
OPT_NORMAL,
|
||||
OPT_HORIZON_LINES,
|
||||
OPT_SPEED_LARGE_FILES,
|
||||
OPT_CHANGED_GROUP_FORMAT,
|
||||
};
|
||||
|
||||
@ -66,6 +65,7 @@ static struct option longopts[] = {
|
||||
{ "minimal", no_argument, 0, 'd' },
|
||||
{ "ed", no_argument, 0, 'e' },
|
||||
{ "forward-ed", no_argument, 0, 'f' },
|
||||
{ "speed-large-files", no_argument, NULL, 'H' },
|
||||
{ "ignore-matching-lines", required_argument, 0, 'I' },
|
||||
{ "ignore-case", no_argument, 0, 'i' },
|
||||
{ "paginate", no_argument, NULL, 'l' },
|
||||
@ -88,7 +88,6 @@ static struct option longopts[] = {
|
||||
{ "horizon-lines", required_argument, NULL, OPT_HORIZON_LINES },
|
||||
{ "no-ignore-file-name-case", no_argument, NULL, OPT_NO_IGN_FN_CASE },
|
||||
{ "normal", no_argument, NULL, OPT_NORMAL },
|
||||
{ "speed-large-files", no_argument, NULL, OPT_SPEED_LARGE_FILES},
|
||||
{ "strip-trailing-cr", no_argument, NULL, OPT_STRIPCR },
|
||||
{ "tabsize", optional_argument, NULL, OPT_TSIZE },
|
||||
{ "changed-group-format", required_argument, NULL, OPT_CHANGED_GROUP_FORMAT},
|
||||
@ -159,6 +158,9 @@ main(int argc, char **argv)
|
||||
case 'f':
|
||||
diff_format = D_REVERSE;
|
||||
break;
|
||||
case 'H':
|
||||
/* ignore but needed for compatibility with GNU diff */
|
||||
break;
|
||||
case 'h':
|
||||
/* silently ignore for backwards compatibility */
|
||||
break;
|
||||
@ -252,8 +254,6 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case OPT_SPEED_LARGE_FILES:
|
||||
break; /* ignore but needed for compatibility with GNU diff */
|
||||
case OPT_STRIPCR:
|
||||
dflags |= D_STRIPCR;
|
||||
break;
|
||||
|
@ -1190,6 +1190,13 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
|
||||
narg--;
|
||||
c = ',';
|
||||
break;
|
||||
case SYS_getrusage:
|
||||
putchar('(');
|
||||
print_integer_arg(sysdecode_getrusage_who, *ip);
|
||||
ip++;
|
||||
narg--;
|
||||
c = ',';
|
||||
break;
|
||||
case SYS_quotactl:
|
||||
print_number(ip, narg, c);
|
||||
putchar(',');
|
||||
|
@ -243,7 +243,7 @@ wtmp(void)
|
||||
/* Display them in reverse order. */
|
||||
while (amount > 0)
|
||||
doentry(&buf[--amount]);
|
||||
|
||||
free(buf);
|
||||
tm = localtime(&t);
|
||||
(void) strftime(ct, sizeof(ct), "%+", tm);
|
||||
printf("\n%s begins %s\n", ((file == NULL) ? "utx.log" : file), ct);
|
||||
|
@ -28,6 +28,7 @@
|
||||
* Kevent -- a pointer to an array of struct kevents. Prints all elements.
|
||||
* Pathconf -- the 2nd argument of pathconf().
|
||||
* Utrace -- utrace(2) buffer.
|
||||
* CapRights -- a pointer to a cap_rights_t. Prints all set capabilities.
|
||||
*
|
||||
* In addition, the pointer types (String, Ptr) may have OUT masked in --
|
||||
* this means that the data is set on *return* from the system call -- or
|
||||
@ -41,13 +42,13 @@ enum Argtype { None = 1, Hex, Octal, Int, UInt, LongHex, Name, Ptr, Stat, Ioctl,
|
||||
Quad, Signal, Sockaddr, StringArray, Timespec, Timeval, Itimerval,
|
||||
Pollfd, Fd_set, Sigaction, Fcntl, Mprot, Mmapflags, Whence, Readlinkres,
|
||||
Sigset, Sigprocmask, StatFs, Kevent, Sockdomain, Socktype, Open,
|
||||
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
|
||||
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
|
||||
Fcntlflag, Rusage, RusageWho, BinString, Shutdown, Resource, Rlimit,
|
||||
Timeval2, Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
|
||||
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
|
||||
Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex, Utrace, IntArray, Pipe2,
|
||||
CapFcntlRights, Fadvice, FileFlags, Flockop, Getfsstatmode, Kldsymcmd,
|
||||
Kldunloadflags, Sizet, Madvice, Socklent, Sockprotocol, Sockoptlevel,
|
||||
Sockoptname, Msgflags,
|
||||
Sockoptname, Msgflags, CapRights, PUInt,
|
||||
|
||||
CloudABIAdvice, CloudABIClockID, ClouduABIFDSFlags,
|
||||
CloudABIFDStat, CloudABIFileStat, CloudABIFileType,
|
||||
|
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
* arguments.
|
||||
*/
|
||||
|
||||
#include <sys/capsicum.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/event.h>
|
||||
#include <sys/ioccom.h>
|
||||
@ -76,6 +77,8 @@ __FBSDID("$FreeBSD$");
|
||||
*/
|
||||
static struct syscall decoded_syscalls[] = {
|
||||
/* Native ABI */
|
||||
{ .name = "__cap_rights_get", .ret_type = 1, .nargs = 3,
|
||||
.args = { { Int, 0 }, { Int, 1 }, { CapRights | OUT, 2 } } },
|
||||
{ .name = "__getcwd", .ret_type = 1, .nargs = 2,
|
||||
.args = { { Name | OUT, 0 }, { Int, 1 } } },
|
||||
{ .name = "_umtx_op", .ret_type = 1, .nargs = 5,
|
||||
@ -96,6 +99,10 @@ static struct syscall decoded_syscalls[] = {
|
||||
.args = { { Int, 0 }, { CapFcntlRights | OUT, 1 } } },
|
||||
{ .name = "cap_fcntls_limit", .ret_type = 1, .nargs = 2,
|
||||
.args = { { Int, 0 }, { CapFcntlRights, 1 } } },
|
||||
{ .name = "cap_getmode", .ret_type = 1, .nargs = 1,
|
||||
.args = { { PUInt | OUT, 0 } } },
|
||||
{ .name = "cap_rights_limit", .ret_type = 1, .nargs = 2,
|
||||
.args = { { Int, 0 }, { CapRights, 1 } } },
|
||||
{ .name = "chdir", .ret_type = 1, .nargs = 1,
|
||||
.args = { { Name, 0 } } },
|
||||
{ .name = "chflags", .ret_type = 1, .nargs = 2,
|
||||
@ -169,7 +176,7 @@ static struct syscall decoded_syscalls[] = {
|
||||
{ .name = "getrlimit", .ret_type = 1, .nargs = 2,
|
||||
.args = { { Resource, 0 }, { Rlimit | OUT, 1 } } },
|
||||
{ .name = "getrusage", .ret_type = 1, .nargs = 2,
|
||||
.args = { { Int, 0 }, { Rusage | OUT, 1 } } },
|
||||
.args = { { RusageWho, 0 }, { Rusage | OUT, 1 } } },
|
||||
{ .name = "getsid", .ret_type = 1, .nargs = 1,
|
||||
.args = { { Int, 0 } } },
|
||||
{ .name = "getsockname", .ret_type = 1, .nargs = 3,
|
||||
@ -1185,6 +1192,16 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
|
||||
case UInt:
|
||||
fprintf(fp, "%u", (unsigned int)args[sc->offset]);
|
||||
break;
|
||||
case PUInt: {
|
||||
unsigned int val;
|
||||
|
||||
if (get_struct(pid, (void *)args[sc->offset], &val,
|
||||
sizeof(val)) == 0)
|
||||
fprintf(fp, "{ %u }", val);
|
||||
else
|
||||
fprintf(fp, "0x%lx", args[sc->offset]);
|
||||
break;
|
||||
}
|
||||
case LongHex:
|
||||
fprintf(fp, "0x%lx", args[sc->offset]);
|
||||
break;
|
||||
@ -1579,6 +1596,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
|
||||
case Resource:
|
||||
print_integer_arg(sysdecode_rlimit, fp, args[sc->offset]);
|
||||
break;
|
||||
case RusageWho:
|
||||
print_integer_arg(sysdecode_getrusage_who, fp, args[sc->offset]);
|
||||
break;
|
||||
case Pathconf:
|
||||
fputs(xlookup(pathconf_arg, args[sc->offset]), fp);
|
||||
break;
|
||||
@ -1976,6 +1996,18 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
|
||||
case Msgflags:
|
||||
print_mask_arg(sysdecode_msg_flags, fp, args[sc->offset]);
|
||||
break;
|
||||
case CapRights: {
|
||||
cap_rights_t rights;
|
||||
|
||||
if (get_struct(pid, (void *)args[sc->offset], &rights,
|
||||
sizeof(rights)) != -1) {
|
||||
fputs("{ ", fp);
|
||||
sysdecode_cap_rights(fp, &rights);
|
||||
fputs(" }", fp);
|
||||
} else
|
||||
fprintf(fp, "0x%lx", args[sc->offset]);
|
||||
break;
|
||||
}
|
||||
|
||||
case CloudABIAdvice:
|
||||
fputs(xlookup(cloudabi_advice, args[sc->offset]), fp);
|
||||
|
@ -2,6 +2,8 @@
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
.include <src.opts.mk>
|
||||
|
||||
PROG= bhyve
|
||||
PACKAGE= bhyve
|
||||
|
||||
@ -63,6 +65,12 @@ SRCS+= vmm_instruction_emul.c
|
||||
|
||||
LIBADD= vmmapi md pthread z
|
||||
|
||||
.if ${MK_OPENSSL} == "no"
|
||||
CFLAGS+=-DNO_OPENSSL
|
||||
.else
|
||||
LIBADD+= crypto
|
||||
.endif
|
||||
|
||||
CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/e1000
|
||||
CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/mii
|
||||
CFLAGS+= -I${BHYVE_SYSDIR}/sys/dev/usb/controller
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 3, 2017
|
||||
.Dd June 2, 2017
|
||||
.Dt BHYVE 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -309,7 +309,7 @@ Emergency write is advertised, but no-op at present.
|
||||
.Pp
|
||||
Framebuffer devices:
|
||||
.Bl -tag -width 10n
|
||||
.It Oo rfb= Ns Oo Ar IP: Oc Ns Ar port Oc Ns Oo ,w= Ns Ar width Oc Ns Oo ,h= Ns Ar height Oc Ns Oo ,vga= Ns Ar vgaconf Oc Ns Oo Ns ,wait Oc
|
||||
.It Oo rfb= Ns Oo Ar IP: Oc Ns Ar port Oc Ns Oo ,w= Ns Ar width Oc Ns Oo ,h= Ns Ar height Oc Ns Oo ,vga= Ns Ar vgaconf Oc Ns Oo Ns ,wait Oc Ns Oo ,password= Ns Ar password Oc
|
||||
.Bl -tag -width 8n
|
||||
.It Ar IP:port
|
||||
An
|
||||
@ -368,6 +368,11 @@ Instruct
|
||||
to only boot upon the initiation of a VNC connection, simplifying the installation
|
||||
of operating systems that require immediate keyboard input.
|
||||
This can be removed for post-installation use.
|
||||
.It password
|
||||
This type of authentication is known to be cryptographically weak and is not
|
||||
intended for use on untrusted networks.
|
||||
Many implementations will want to use stronger security, such as running
|
||||
the session over an encrypted channel provided by IPsec or SSH.
|
||||
.El
|
||||
.El
|
||||
.Pp
|
||||
|
@ -93,6 +93,7 @@ struct pci_fbuf_softc {
|
||||
|
||||
/* rfb server */
|
||||
char *rfb_host;
|
||||
char *rfb_password;
|
||||
int rfb_port;
|
||||
int rfb_wait;
|
||||
int vga_enabled;
|
||||
@ -285,7 +286,8 @@ pci_fbuf_parse_opts(struct pci_fbuf_softc *sc, char *opts)
|
||||
goto done;
|
||||
} else if (sc->memregs.height == 0)
|
||||
sc->memregs.height = 1080;
|
||||
|
||||
} else if (!strcmp(xopts, "password")) {
|
||||
sc->rfb_password = config;
|
||||
} else {
|
||||
pci_fbuf_usage(xopts);
|
||||
ret = -1;
|
||||
@ -407,7 +409,7 @@ pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
|
||||
|
||||
memset((void *)sc->fb_base, 0, FB_SIZE);
|
||||
|
||||
error = rfb_init(sc->rfb_host, sc->rfb_port, sc->rfb_wait);
|
||||
error = rfb_init(sc->rfb_host, sc->rfb_port, sc->rfb_wait, sc->rfb_password);
|
||||
done:
|
||||
if (error)
|
||||
free(sc);
|
||||
|
@ -60,10 +60,23 @@ __FBSDID("$FreeBSD$");
|
||||
#include "rfb.h"
|
||||
#include "sockstream.h"
|
||||
|
||||
#ifndef NO_OPENSSL
|
||||
#include <openssl/des.h>
|
||||
#endif
|
||||
|
||||
static int rfb_debug = 0;
|
||||
#define DPRINTF(params) if (rfb_debug) printf params
|
||||
#define WPRINTF(params) printf params
|
||||
|
||||
#define AUTH_LENGTH 16
|
||||
#define PASSWD_LENGTH 8
|
||||
|
||||
#define SECURITY_TYPE_NONE 1
|
||||
#define SECURITY_TYPE_VNC_AUTH 2
|
||||
|
||||
#define AUTH_FAILED_UNAUTH 1
|
||||
#define AUTH_FAILED_ERROR 2
|
||||
|
||||
struct rfb_softc {
|
||||
int sfd;
|
||||
pthread_t tid;
|
||||
@ -72,9 +85,11 @@ struct rfb_softc {
|
||||
|
||||
int width, height;
|
||||
|
||||
bool enc_raw_ok;
|
||||
bool enc_zlib_ok;
|
||||
bool enc_resize_ok;
|
||||
char *password;
|
||||
|
||||
bool enc_raw_ok;
|
||||
bool enc_zlib_ok;
|
||||
bool enc_resize_ok;
|
||||
|
||||
z_stream zstream;
|
||||
uint8_t *zbuf;
|
||||
@ -208,7 +223,7 @@ static void
|
||||
rfb_send_resize_update_msg(struct rfb_softc *rc, int cfd)
|
||||
{
|
||||
struct rfb_srvr_updt_msg supdt_msg;
|
||||
struct rfb_srvr_rect_hdr srect_hdr;
|
||||
struct rfb_srvr_rect_hdr srect_hdr;
|
||||
|
||||
/* Number of rectangles: 1 */
|
||||
supdt_msg.type = 0;
|
||||
@ -739,8 +754,19 @@ rfb_handle(struct rfb_softc *rc, int cfd)
|
||||
{
|
||||
const char *vbuf = "RFB 003.008\n";
|
||||
unsigned char buf[80];
|
||||
unsigned char *message;
|
||||
|
||||
#ifndef NO_OPENSSL
|
||||
unsigned char challenge[AUTH_LENGTH];
|
||||
unsigned char keystr[PASSWD_LENGTH];
|
||||
unsigned char crypt_expected[AUTH_LENGTH];
|
||||
|
||||
DES_key_schedule ks;
|
||||
int i;
|
||||
#endif
|
||||
|
||||
pthread_t tid;
|
||||
uint32_t sres;
|
||||
uint32_t sres;
|
||||
int len;
|
||||
|
||||
rc->cfd = cfd;
|
||||
@ -751,19 +777,91 @@ rfb_handle(struct rfb_softc *rc, int cfd)
|
||||
/* 1b. Read client version */
|
||||
len = read(cfd, buf, sizeof(buf));
|
||||
|
||||
/* 2a. Send security type 'none' */
|
||||
/* 2a. Send security type */
|
||||
buf[0] = 1;
|
||||
buf[1] = 1; /* none */
|
||||
stream_write(cfd, buf, 2);
|
||||
#ifndef NO_OPENSSL
|
||||
if (rc->password)
|
||||
buf[1] = SECURITY_TYPE_VNC_AUTH;
|
||||
else
|
||||
buf[1] = SECURITY_TYPE_NONE;
|
||||
#else
|
||||
buf[1] = SECURITY_TYPE_NONE;
|
||||
#endif
|
||||
|
||||
stream_write(cfd, buf, 2);
|
||||
|
||||
/* 2b. Read agreed security type */
|
||||
len = stream_read(cfd, buf, 1);
|
||||
|
||||
/* 2c. Write back a status of 0 */
|
||||
sres = 0;
|
||||
/* 2c. Do VNC authentication */
|
||||
switch (buf[0]) {
|
||||
case SECURITY_TYPE_NONE:
|
||||
sres = 0;
|
||||
break;
|
||||
case SECURITY_TYPE_VNC_AUTH:
|
||||
/*
|
||||
* The client encrypts the challenge with DES, using a password
|
||||
* supplied by the user as the key.
|
||||
* To form the key, the password is truncated to
|
||||
* eight characters, or padded with null bytes on the right.
|
||||
* The client then sends the resulting 16-bytes response.
|
||||
*/
|
||||
#ifndef NO_OPENSSL
|
||||
strncpy(keystr, rc->password, PASSWD_LENGTH);
|
||||
|
||||
/* VNC clients encrypts the challenge with all the bit fields
|
||||
* in each byte of the password mirrored.
|
||||
* Here we flip each byte of the keystr.
|
||||
*/
|
||||
for (i = 0; i < PASSWD_LENGTH; i++) {
|
||||
keystr[i] = (keystr[i] & 0xF0) >> 4
|
||||
| (keystr[i] & 0x0F) << 4;
|
||||
keystr[i] = (keystr[i] & 0xCC) >> 2
|
||||
| (keystr[i] & 0x33) << 2;
|
||||
keystr[i] = (keystr[i] & 0xAA) >> 1
|
||||
| (keystr[i] & 0x55) << 1;
|
||||
}
|
||||
|
||||
/* Initialize a 16-byte random challenge */
|
||||
arc4random_buf(challenge, sizeof(challenge));
|
||||
stream_write(cfd, challenge, AUTH_LENGTH);
|
||||
|
||||
/* Receive the 16-byte challenge response */
|
||||
stream_read(cfd, buf, AUTH_LENGTH);
|
||||
|
||||
memcpy(crypt_expected, challenge, AUTH_LENGTH);
|
||||
|
||||
/* Encrypt the Challenge with DES */
|
||||
DES_set_key((C_Block *)keystr, &ks);
|
||||
DES_ecb_encrypt((C_Block *)challenge,
|
||||
(C_Block *)crypt_expected, &ks, DES_ENCRYPT);
|
||||
DES_ecb_encrypt((C_Block *)(challenge + PASSWD_LENGTH),
|
||||
(C_Block *)(crypt_expected + PASSWD_LENGTH),
|
||||
&ks, DES_ENCRYPT);
|
||||
|
||||
if (memcmp(crypt_expected, buf, AUTH_LENGTH) != 0) {
|
||||
message = "Auth Failed: Invalid Password.";
|
||||
sres = htonl(1);
|
||||
} else
|
||||
sres = 0;
|
||||
#else
|
||||
sres = 0;
|
||||
WPRINTF(("Auth not supported, no OpenSSL in your system"));
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* 2d. Write back a status */
|
||||
stream_write(cfd, &sres, 4);
|
||||
|
||||
if (sres) {
|
||||
*((uint32_t *) buf) = htonl(strlen(message));
|
||||
stream_write(cfd, buf, 4);
|
||||
stream_write(cfd, message, strlen(message));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* 3a. Read client shared-flag byte */
|
||||
len = stream_read(cfd, buf, 1);
|
||||
|
||||
@ -869,7 +967,7 @@ sse42_supported(void)
|
||||
}
|
||||
|
||||
int
|
||||
rfb_init(char *hostname, int port, int wait)
|
||||
rfb_init(char *hostname, int port, int wait, char *password)
|
||||
{
|
||||
struct rfb_softc *rc;
|
||||
struct sockaddr_in sin;
|
||||
@ -887,6 +985,8 @@ rfb_init(char *hostname, int port, int wait)
|
||||
rc->crc_width = RFB_MAX_WIDTH;
|
||||
rc->crc_height = RFB_MAX_HEIGHT;
|
||||
|
||||
rc->password = password;
|
||||
|
||||
rc->sfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (rc->sfd < 0) {
|
||||
perror("socket");
|
||||
|
@ -31,6 +31,6 @@
|
||||
|
||||
#define RFB_PORT 5900
|
||||
|
||||
int rfb_init(char *hostname, int port, int wait);
|
||||
int rfb_init(char *hostname, int port, int wait, char *password);
|
||||
|
||||
#endif /* _RFB_H_ */
|
||||
|
@ -60,7 +60,7 @@ bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
|
||||
{
|
||||
off_t offset;
|
||||
ssize_t rv;
|
||||
fsinfo_t *fsinfo = vp->fs;
|
||||
fsinfo_t *fs = vp->fs;
|
||||
|
||||
assert (bpp != NULL);
|
||||
|
||||
@ -68,7 +68,7 @@ bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused,
|
||||
printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
|
||||
size);
|
||||
*bpp = getblk(vp, blkno, size, 0, 0, 0);
|
||||
offset = (*bpp)->b_blkno * fsinfo->sectorsize + fsinfo->offset;
|
||||
offset = (*bpp)->b_blkno * fs->sectorsize + fs->offset;
|
||||
if (debug & DEBUG_BUF_BREAD)
|
||||
printf("%s: blkno %lld offset %lld bcount %ld\n", __func__,
|
||||
(long long)(*bpp)->b_blkno, (long long) offset,
|
||||
|
@ -380,7 +380,6 @@ tests_time_rotate() {
|
||||
|
||||
sleep 1.1
|
||||
|
||||
(
|
||||
TODO="rotate time 2-4 fail today; bug 212160"
|
||||
|
||||
begin "rotate time 2 ${name_postfix}"
|
||||
@ -404,7 +403,7 @@ tests_time_rotate() {
|
||||
ckfe ${LOGFNAME}
|
||||
chkfcnt 3 ${dir}${LOGFNAME}.*${ext}
|
||||
end
|
||||
)
|
||||
unset TODO
|
||||
|
||||
begin "noaction ${name_postfix}"
|
||||
ofiles=`ls -1 ${dir}${LOGFNAME}.*${ext} | tr -d '\n'`
|
||||
@ -455,7 +454,7 @@ tests_rfc5424() {
|
||||
tmpdir_clean
|
||||
}
|
||||
|
||||
echo 1..126
|
||||
echo 1..128
|
||||
mkdir -p ${TMPDIR}
|
||||
cd ${TMPDIR}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user