Commit Graph

2431 Commits

Author SHA1 Message Date
Pedro F. Giffuni
98fffe4ecb mips: make some use of mallocarray(9).
Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837
2018-01-15 21:13:30 +00:00
Jeff Roberson
6f4acaf4c9 Add support for NUMA domains to bus dma tags. This causes all memory
allocated with a tag to come from the specified domain if it meets the
other constraints provided by the tag.  Automatically create a tag at
the root of each bus specifying the domain local to that bus if
available.

Reviewed by:	jhb, kib
Tested by:	pho
Sponsored by:	Netflix, Dell/EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D13545
2018-01-12 23:34:16 +00:00
Jeff Roberson
ab3185d15e Implement NUMA support in uma(9) and malloc(9). Allocations from specific
domains can be done by the _domain() API variants.  UMA also supports a
first-touch policy via the NUMA zone flag.

The slab layer is now segregated by VM domains and is precise.  It handles
iteration for round-robin directly.  The per-cpu cache layer remains
a mix of domains according to where memory is allocated and freed.  Well
behaved clients can achieve perfect locality with no performance penalty.

The direct domain allocation functions have to visit the slab layer and
so require per-zone locks which come at some expense.

Reviewed by:	Attilio (a slightly older version)
Tested by:	pho
Sponsored by:	Netflix, Dell/EMC Isilon
2018-01-12 23:25:05 +00:00
John Baldwin
a27a25f759 Set the 'FR' bit in the status register for N32 kernels.
This permits N32 hard-float binaries to use 64-bit floating point
registers (which is what N32 binaries expect) matching the N64 ABI.

Reviewed by:	imp, jmallett
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D13830
2018-01-10 21:08:43 +00:00
Warner Losh
7167e16b49 Remove sys/mips/rmi. It's been unmaintained since 2011. This hardware
is now unobtanium. It's only had API changes in the last 7 years, and
is responsible for a very large number of them. In addition, there's a
lot of code that reimplements base FreeBSD functionality, diminishing
the chances it still works. Without hardware to teset it on, or
prospects of obtaining such hardware and without vendor support, it's
time to move on.

Suggested by: kan@ in mips@ retirement discussion
2018-01-01 05:13:03 +00:00
Warner Losh
c3dbef68d5 Remove support for IDT. Only the RouterBoard RB533 used this chip, and
it's at least 5 years out of production. I couldn't find a used one on
ebay and other secondary markets just now, nor when I tried 4 years
ago. It dates from the initial project/mips2 merge 8 years ago, and
hasn't been updated since.

Discussed on: mips@ (with some dissent)
2018-01-01 04:10:36 +00:00
Warner Losh
ada611f6ad Retire old ADM 5120 port. It never grew much beyond the original port.
It came into the tree with the project/mips merge 8 years ago. At the
time, it was hard to find a board with enough RAM to run. Now FreeBSD
requires at least 2x the RAM it did then. No changes have happened to
this port apart from API churn and license tagging since then. It ran
OK at the time it was committed, but no sightings in the wild have
happened since shortly after it was committed.

https://www.linux-mips.org/wiki/Adm5120_devices lists a bunch of
boards that were available 5 years ago (but are no longer
available). The beefiest one had only 64MB of RAM which is too
small. The Mirktik RB1xx never had more than 32MB.

Also remove confusing QEMU config file that never ever worked in QEMU
for mips. MALTA is used for that. Another of my past mistakes, false
starts that never amounted to anything.

Discussed on: mips@ (with some dissent)
2018-01-01 04:10:31 +00:00
Warner Losh
5daa7f27c5 Remove sys/mips/alchemy. It was still-born when I committed it and it
never got better. It never worked on real hardware and is still mostly
stubs after 8 years when I added it. It has had no real update in that
time apart from API churn. It was added just so it didn't get lost in
the project/mips merge, but maybe it should have been lost as nothing
has come of it. It is time to give up the ghost on this one.

Approved by: me, shooting my own dog
Discussed on: mips@
2018-01-01 04:10:25 +00:00
Warner Losh
039f26fab0 Remove sys/mips/rt305x. It's been replaced by sys/mips/mediatek.
OK'd by: Stanislav Galabov (who did both)
Discussed on: mips@
2018-01-01 04:06:24 +00:00
Colin Percival
d5d7606c0c Use the TSLOG framework to record entry/exit timestamps for DELAY and
_vprintf; these functions are called in many places and can contribute
meaningfully to the total time spent booting.
2017-12-31 09:24:41 +00:00
Eitan Adler
caa7e52f3f kernel: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:21 +00:00
Michael Zhilin
ebff39fb9b [mips] fix compilation of TP-WN1043ND kernel configuration
This compilation issue has been found thanks to freebsd-wifi-build:
 - gpioiic requires "gpio_if.h", so "device gpio" is mandatory
 - rtl8366rb works over MDIO interface, so "device mdio" is mandatory

Compilation is checked on FreeBSD 12-CURRENT machine.
2017-12-26 19:50:23 +00:00
Konstantin Belousov
7aea69e54a Remove mips MD atomic_load_64 and atomic_store_64.
The only users of the functions were db_read_bytes() and
db_write_bytes() ddb(4) interfaces.  Replace the calls with direct
reads and writes, which are automatically atomic on 64bits and n32.

Note that removed assembler implementation for mips32 is not atomic
anyway.

Reviewed by:	jhb
Discussed with:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D13586
2017-12-22 23:27:03 +00:00
Konstantin Belousov
37f48d5aba Fix mips build after introduction of MD definitions of atomic_load_64
and atomic_store_64.

The MD definitions are provided for LP64 only, while mips also uses
them for 32bit and n32.  Only define mips variants for 32bit and n32
and change the syntax to match common definitions.

Note that this commit does not fix 32bit asm implementation to follow
new KBI, this will be fixed later.  The functions are only used for 8
byte ddb accesses so the known bug does not prevent normal kernel
operations.

Sponsored by:	The FreeBSD Foundation
2017-12-21 23:39:00 +00:00
Konstantin Belousov
30d4f9e888 Add atomic_load(9) and atomic_store(9) operations.
They provide relaxed-ordered atomic access semantic.  Due to the
FreeBSD memory model, the operations are syntaxical wrappers around
the volatile accesses.  The volatile qualifier is used to ensure that
the access not optimized out and in turn depends on the volatile
semantic as implemented by supported compilers.

The motivation for adding the operation is to help people coming from
other systems or knowing the C11/C++ standards where atomics have
special type and require use of the special access operations.  It is
still the case that FreeBSD requires plain load and stores of aligned
integer types to be atomic.

Suggested by:	jhb
Reviewed by:	alc, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D13534
2017-12-19 09:59:20 +00:00
Landon J. Fuller
566ca880a1 bhnd(4): Include board_devid in the bhnd_board_info structure, and populate
the expected default board_vendor value on MIPS SoCs.

This is required by bwn(4) to differentiate between single-band and
dual-band device variants that otherwise share a common chip ID.

Approved by:	adrian (mentor, implicit)
Sponsored by:	The FreeBSD Foundation
2017-12-14 01:58:05 +00:00
Bruce Evans
fb3cc1c37d Move instantiation of msgbufp from 9 MD files to subr_prf.c.
This variable should be pure MI except possibly for reading it in MD
dump routines.  Its initialization was pure MD in 4.4BSD, but FreeBSD
changed this in r36441 in 1998.  There were many imperfections in
r36441.  This commit fixes only a small one, to simplify fixing the
others 1 arch at a time.  (r47678 added support for
special/early/multiple message buffer initialization which I want in
a more general form, but this was too fragile to use because hacking
on the msgbufp global corrupted it, and was only used for 5 hours in
-current...)
2017-12-07 07:55:38 +00:00
Pedro F. Giffuni
796df753f4 SPDX: Consider code from Carnegie-Mellon University.
Interesting cases, most likely from CMU Mach sources.
2017-11-30 15:48:35 +00:00
Scott Long
c15269ccb8 It's time to retire AHC_REG_PRETTY_PRINT and AHD_REG_PRETTY_PRINT from
the standard kernels.  They are still available as custom compile
options.
2017-11-29 23:41:49 +00:00
Pedro F. Giffuni
19d3b47b92 sys/mips: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 15:07:26 +00:00
Landon J. Fuller
2f909a9f74 bhnd(4): Add a basic ChipCommon GPIO driver sufficient to support bwn(4)
The driver is functional on both BHND Wi-Fi adapters and MIPS SoCs, but
does not currently include support for features not required by bwn(4),
including GPIO interrupt handling.

Approved by:	adrian (mentor, implicit)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12708
2017-11-22 23:10:20 +00:00
Landon J. Fuller
4e96bf3a37 bhnd(4): extend the PMU APIs to support bwn(4)
The bwn(4) driver requires a number of extensions to the bhnd(4) PMU
interface to support external configuration of PLLs, LDOs, and other
parameters that require chipset or PHY-specific workarounds.

These changes add support for:

- Writing raw voltage register values to PHY-specific LDO regulator
  registers (required by LP-PHY).
- Enabling/disabling PHY-specific LDOs (required by LP-PHY)
- Writing to arbitrary PMU chipctrl registers (required for common PHY PLL
  reset support).
- Requesting chipset/PLL-specific spurious signal avoidance modes.
- Querying clock frequency and latency.

Additionally, rather than updating legacy PWRCTL support to conform to the
new PMU interface:

- PWRCTL API is now provided by a bhnd_pwrctl_if.m interface.
- Since PWRCTL is only found in older SSB-based chipsets, translation from
  bhnd(4) bus APIs to corresponding PWRCTL operations is now handled
  entirely within the siba(4) driver.
- The PWRCTL-specific host bridge clock gating APIs in bhnd_bus_if.m have
  been lifted out into a standalone bhnd_pwrctl_hostb_if.m interface.

Approved by:	adrian (mentor, implicit)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12664
2017-11-22 20:27:46 +00:00
Landon J. Fuller
9ed453245b bhnd(4): Add support for querying DMA address translation parameters
BHND Wi-Fi chipsets and SoCs share a common DMA engine, operating within
backplane address space. To support host DMA on Wi-Fi chipsets, the bridge
core maps host address space onto the backplane; any host addresses must
be translated to their corresponding backplane address.


- Defines a new bhnd_get_dma_translation(9) API to support querying DMA
  address translation parameters from the bhnd(4) bus.
- Extends bhndb(4) to provide DMA translation descriptors from a DMA
  address translation table defined in the host bridge-specific
  bhndb_hwcfg.
- Defines bhndb(4) DMA address translation tables for all supported host
  bridge cores.
- Extends mips/broadcom's bhnd_nexus driver to return an identity (no-op)
  DMA translation descriptor; no translation is required when addressing
  the SoC backplane.

Approved by:	adrian (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12582
2017-11-21 23:25:22 +00:00
Landon J. Fuller
caeff9a3c2 bhnd(4): implement MIPS and PCI(e) interrupt support
On BHND MIPS SoCs, this replaces the use of hard-coded MIPS IRQ#s in the
common bhnd(4) core drivers; we now register an INTRNG child PIC that
handles routing of backplane interrupt vectors via the MIPS core.

On BHND PCI devices, backplane interrupt vectors are now routed to the
PCI/PCIe host bridge core when bus_setup_intr() is called, where they are
dispatched by the PCI core via a host interrupt (e.g. INTx/MSI).

The bhndb(4) bridge driver tracks registered interrupt handlers for the
bridged bhnd(4) devices and manages backplane interrupt routing, while
delegating actual bus interrupt setup/teardown to the parent bus on behalf
of the bridged cores.

Approved by:	adrian (mentor, implicit)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12518
2017-11-21 23:15:20 +00:00
Landon J. Fuller
e60ff6a3b4 Preemptively map MIPS INTRNG interrupts on non-FDT MIPS targets
This replaces a partial workaround introduced in r305527 that was
incompatible with nested INTRNG interrupt controllers if not also using
FDT.

On non-FDT MIPS INTRNG targets, we now preemptively produce a set of fixed
mappings for the MIPS IRQ range during nexus attach. On FDT targets,
OFW_BUS_MAP_INTR() remains responsible for mapping the MIPS IRQs.

Approved by:	adrian (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12385
2017-11-21 01:54:48 +00:00
Brooks Davis
114aedb30e Remove a couple variables that are unused after r325790.
Reported by:	rpokala
2017-11-20 22:18:24 +00:00
Pedro F. Giffuni
51369649b0 sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:43:44 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Justin Hibbits
ce7fd13aff Convert BERI to use ofw_parse_bootargs()
Summary:
ofw_parse_bootargs() was added in r306065 as an attempt to unify the
various copies of the same code.  This simply migrates BERI to use it.

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D12962
2017-11-14 03:23:46 +00:00
Jeff Roberson
8d6fbbb867 Replace manyinstances of VM_WAIT with blocking page allocation flags
similar to the kernel memory allocator.

This simplifies NUMA allocation because the domain will be known at wait
time and races between failure and sleeping are eliminated.  This also
reduces boilerplate code and simplifies callers.

A wait primitive is supplied for uma zones for similar reasons.  This
eliminates some non-specific VM_WAIT calls in favor of more explicit
sleeps that may be satisfied without new pages.

Reviewed by:	alc, kib, markj
Tested by:	pho
Sponsored by:	Netflix, Dell/EMC Isilon
2017-11-08 02:39:37 +00:00
Konstantin Belousov
93b09f581a Remove badsect(8).
Failure modes of the modern (that is, produced in the last 25 years)
hard drives and SSDs made the utility outdated.  Since the kernel
interface to support it was removed in r324853, cut the userspace
remnants as well.

Discussed with:	bde (who does not like the removal)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2017-11-05 22:00:54 +00:00
Michael Zhilin
26cb32ad01 [mips] Pin control configuration for MediaTek RT2880
RT2880 is MIPS4Kc SoC used in many SOHO routers. This commits adds GPIO pin
control configuration of RT2880.

Submitted by:	Hiroki Mori <yamori83@yahoo.co.jp>
Reviewed by:	mizhka, sgalabov
Differential Revision:	https://reviews.freebsd.org/D12648
2017-10-31 11:29:16 +00:00
Eitan Adler
a2aef24aa3 Update several more URLs
- Primarily http -> https
- Primarily FreeBSD project URLs
2017-10-29 08:17:03 +00:00
Michal Meloun
904d8c492f Add AT_HWCAP2 ELF auxiliary vector.
- allocate value for new AT_HWCAP2 auxiliary vector on all platforms.
 - expand 'struct sysentvec' by new 'u_long *sv_hwcap2', in exactly
   same way as for AT_HWCAP.

MFC after:	1 month
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D12699
2017-10-21 12:05:01 +00:00
Bjoern A. Zeeb
8e94025b41 With r181803 on 2008-08-17 23:27:27Z the first VIMAGE commit went into
HEAD.  Enable VIMAGE in GENERIC kernels and some others (where GENERIC does
not exist) on HEAD.

Disable building LINT-VIMAGE with VIMAGE being default.

This should give it a lot more exposure in the run-up to 12 to help
us evaluate whether to keep it on by default or not.
We are also hoping to get better performance testing.
The feature can be disabled using nooptions.

Requested by:		many
Reviewed by:		kristof, emaste, hiren
X-MFC after:		never
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D12639
2017-10-20 21:40:59 +00:00
John Baldwin
d8371cb18e Remove CPU_HAVEFPU.
Instead, use a runtime decision to handle COP1 traps.  If floating point
support is present in the current CPU, enable saving of the floating point
state.  If support is not present, fail with SIGILL.

Reviewed by:	imp, br
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D12707
2017-10-18 17:23:16 +00:00
Mark Johnston
46fcd1af63 Move kernel dump offset tracking into MI code.
All of the kernel dump implementations keep track of the current offset
("dumplo") within the dump device. However, except for textdumps, they
all write the dump sequentially, so we can reduce code duplication by
having the MI code keep track of the current offset. The new
dump_append() API can be used to write at the current offset.

This is needed to implement support for kernel dump compression in the
MI kernel dump code.

Also simplify dump_encrypted_write() somewhat: use dump_write() instead
of duplicating its bounds checks, and get rid of the redundant offset
tracking.

Reviewed by:	cem
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D11722
2017-10-18 15:38:05 +00:00
Landon J. Fuller
89294a783a bhnd: Add support for supplying bus I/O callbacks when initializing an EROM
parser.

This allows us to use the EROM parser API in cases where the standard bus
space I/O APIs are unsuitable. In particular, this will allow us to parse
the device enumeration table directly from bhndb(4) drivers, prior to
full attach and configuration of the bridge.

Approved by:	adrian (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12510
2017-09-27 19:48:34 +00:00
Landon J. Fuller
8e35bf8319 bhnd: Implement bhnd(4) platform device registration.
Add bhnd(4) API for explicitly registering BHND platform devices (ChipCommon,
PMU, NVRAM, etc) with the bus, rather than walking the newbus hierarchy to
discover platform devices. These devices are now also refcounted; attempting
to deregister an actively used platform device will return EBUSY.

This resolves a lock ordering incompatibility with bwn(4)'s firmware loading
threads; previously it was necessary to acquire Giant to protect newbus access
when locating and querying the NVRAM device.

Approved by:	adrian (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12392
2017-09-27 19:44:23 +00:00
Landon J. Fuller
011e84e0a7 Add MIPS32/64 Rev2 CP0 intctl register definitions.
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D12300
2017-09-15 19:56:21 +00:00
John Baldwin
c2f37b9245 Add AT_HWCAP and AT_EHDRFLAGS on all platforms.
A new 'u_long *sv_hwcap' field is added to 'struct sysentvec'.  A
process ABI can set this field to point to a value holding a mask of
architecture-specific CPU feature flags.  If an ABI does not wish to
supply AT_HWCAP to processes the field can be left as NULL.

The support code for AT_EHDRFLAGS was already present on all systems,
just the #define was not present.  This is a step towards unifying the
AT_* constants across platforms.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D12290
2017-09-14 14:26:55 +00:00
Gordon Tetlow
4572fb3faf Deorbit catman. The tradeoff of disk for performance has long since tipped
in favor of just rendering the manpage instead of relying on pre-formatted
catpages. Note, this does not impede the ability to use existing catpages,
it just removes the utility to generate them.

Reviewed by:	imp, allanjude
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D12317
2017-09-13 16:35:16 +00:00
Kurt Lidl
a8273e4371 Enable dtrace support for mips64 and the ERL kernel config
Turn on the required options in the ERL config file, and ensure
that the fbt module is listed as a dependency for mips in
the modules/dtrace/dtraceall/dtraceall.c file.

PR: 		220346
Reviewed by:	gnn, markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D12227
2017-09-06 03:19:52 +00:00
Kurt Lidl
77e430c686 Fix whitespace on "options" to be <space><tab>, no functional change 2017-09-04 20:10:34 +00:00
Ed Maste
118ee8bdea xls_ehci: eliminate 'format string is not a string literal' warning
Reported by:	Clang
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2017-08-30 22:58:11 +00:00
Ed Maste
7a8d38a717 octeon_ebt3000_cf: eliminate 'format string is not a string literal' warning
Reported by:	Clang
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2017-08-30 22:54:11 +00:00
John Baldwin
b8b3a64000 Apply 64k padding to stack pointer for 32-bit processes.
In particular, MIPS now has COMPAT_FREEBSD32 for n64 kernels so this
cannot be ignored for n64.  On the other hand, it is unneeded for o32
MIPS kernels as the issue is only present when using 64-bit registers,
so remove the workaround from o32 kernels.

Reviewed by:	jmallett
Sponsored by:	DARPA / AFRL
2017-08-30 19:21:11 +00:00
Ed Maste
3460f018f9 arge: correct bzero sizeof (pointed-to object, not pointer)
Reported by:	Clang
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2017-08-30 17:38:55 +00:00
John Baldwin
cccc713394 Allow execution of FreeBSD/mips shared objects.
This was applied to all other FreeBSD architectures in r169846 but wasn't
included in the intial MIPS import.

Sponsored by:	DARPA / AFRL
2017-08-30 00:14:36 +00:00
Conrad Meyer
70dd00d6c0 Fix limits.h constants to have correct type on MIPS
Use correctly typed constants to avoid bogus errors like
https://lists.freebsd.org/pipermail/svn-src-all/2017-August/150400.html
(like x86 _limits.h).

Reported by:	bde, asomers
Reviewed by:	mjoras, tinderbox
Sponsored by:	Dell EMC Isilon
2017-08-26 03:21:12 +00:00
John Baldwin
3c0e63a4c4 Enable hardfloat CPU instructions in the FP exception handler.
This permits compiling with clang's integrated assembler.

Sponsored by:	DARPA / AFRL
2017-08-21 21:48:24 +00:00
Bruce Evans
7692d200c1 Use better hard-coded defaults for the cursor shape, and remove nearby
redundant initializations.

Hard-code base = 0, height = (approx. 1/8 of the boot-time font height)
in all cases, and remove the BIOS/MD support for setting these values.
This asks for an underline cursor sized for the boot-time font instead
of various less hard-coded but worse values.  I used that think that
the x86 BIOS always gave the same values as the above hard-coding, but
on 1 of my systems it gives the wrong value of base = 1.

The remaining BIOS fields are shift_state and bell_pitch.  These are now
consistently not explicitly reinitialized to 0.  All sc_get_bios_value()
functions except x86's are now empty, and the only useful thing that x86
returns is shift_state.  This really belongs in atkbdc, but heavier
use of the BIOS to read the more useful typematic rate has been removed
there.  fb still makes much heavier use of the BIOS.
2017-08-19 19:33:16 +00:00
Mark Johnston
01938d3666 Rename mkdumpheader() and group EKCD functions in kern_shutdown.c.
This helps simplify the code in kern_shutdown.c and reduces the number
of globally visible functions.

No functional change intended.

Reviewed by:	cem, def
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D11603
2017-08-18 04:04:09 +00:00
Mark Johnston
50ef60dabe Factor out duplicated kernel dump code into dump_{start,finish}().
dump_start() and dump_finish() are responsible for writing kernel dump
headers, optionally writing the key when encryption is enabled, and
initializing the initial offset into the dump device.

Also remove the unused dump_pad(), and make some functions static now that
they're only called from kern_shutdown.c.

No functional change intended.

Reviewed by:	cem, def
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D11584
2017-08-18 03:52:35 +00:00
Xin LI
e6f9d1ce45 Plug memory leak in arge_encap().
Reported by:	Ilja Van Sprundel <ivansprundel ioactive.com>
Submitted by:	Domagoj Stolfa <domagoj.stolfa gmail.com>
Reviewed by:	adrian
MFC after:	3 days
2017-08-15 06:01:36 +00:00
Ian Lepore
90cff13c3c Remove the old ds1374 driver and use the ds13rtc driver instead. Adjust
several mips config files accordingly.
2017-08-13 22:07:42 +00:00
Adrian Chadd
ff0c85fcaf [ar71xx] get rid of ath_pci - it's built as a module now. 2017-07-28 01:17:38 +00:00
Adrian Chadd
56e91aa977 [ar933x] make carambola2 work again!
* Add in the hints needed for AR933x ath(4) support - this is the nicer way
  that allows ath to be a module;
* ATH_EEPROM_FIRMWARE is also required for all AR933x chipsets.

Tested:

* Carambola2, AR933x
2017-07-23 07:10:41 +00:00
Adrian Chadd
1656a5b991 [ar933x] re-add the ar71xx_apb device for AR933x.
This prevents the console from working!

Tested:

* carambola2, AR933x
2017-07-23 07:02:10 +00:00
Edward Tomasz Napierala
a71f4ea813 Make ddb(4) disassembler (x/i) use n32 register names.
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-07-06 15:08:51 +00:00
Adrian Chadd
e9c4d0912a [ar724x] put in explicit memory barriers now that read/write register no longer
implicitly do them.

They were removed as part of my "fix this to actually work" a few commits
ago in this file.

Tested:

* AP93, AR7240 + AR9280 PCI
2017-07-06 04:56:23 +00:00
Adrian Chadd
1f6ca76bc0 [ar71xx] Start migrating the AR934x based boards over to the new world order.
This unifies the PCI hints with the AHB/NOR hint syntax.

Tested:

* DIR825C1, AR9344 SoC / 2x2 2G + AR9580 PCI 2x2 5G
2017-07-06 04:06:25 +00:00
Jason A. Harmening
eb36b1d0bc Clean up MD pollution of bus_dma.h:
--Remove special-case handling of sparc64 bus_dmamap* functions.
  Replace with a more generic mechanism that allows MD busdma
  implementations to generate inline mapping functions by
  defining WANT_INLINE_DMAMAP in <machine/bus_dma.h>.  This
  is currently useful for sparc64, x86, and arm64, which all
  implement non-load dmamap operations as simple wrappers
  around map objects which may be bus- or device-specific.

--Remove NULL-checked bus_dmamap macros.  Implement the
  equivalent NULL checks in the inlined x86 implementation.
  For non-x86 platforms, these checks are a minor pessimization
  as those platforms do not currently allow NULL maps.  NULL
  maps were originally allowed on arm64, which appears to have
  been the motivation behind adding arm[64]-specific barriers
  to bus_dma.h, but that support was removed in r299463.

--Simplify the internal interface used by the bus_dmamap_load*
  variants and move it to bus_dma_internal.h

--Fix some drivers that directly include sys/bus_dma.h
  despite the recommendations of bus_dma(9)

Reviewed by:	kib (previous revision), marius
Differential Revision:	https://reviews.freebsd.org/D10729
2017-07-01 05:35:29 +00:00
Adrian Chadd
b6c4248397 [mips] [ar71xx] Since the wlan/ath drivers use ALQ, ensure we build the module
here otherwise we can't load said module.
2017-06-29 03:58:01 +00:00
Adrian Chadd
05e89dd3a1 [mips] make this compile again after all of the config changes. 2017-06-29 03:57:22 +00:00
Kurt Lidl
58deaaf128 Add IPSEC support to mips ERL kernel config file 2017-06-26 18:28:00 +00:00
Adrian Chadd
da150e22ac [ar71xx] migrate all of the duplicate configuration out into a shared config file.
This brings the default configurations (drivers, net80211 settings, etc) and some
of the shared configuration into std.AR_MIPS_BASE.  I haven't yet moved the
-current settings (witness, memguard, etc) into it.

This should simplify building a lot of the same test images for my MIPS AP board
development and testing.

This is a work in progress; it's not designed to be perfect!
2017-06-16 00:44:23 +00:00
Konstantin Belousov
2d88da2f06 Move struct syscall_args syscall arguments parameters container into
struct thread.

For all architectures, the syscall trap handlers have to allocate the
structure on the stack.  The structure takes 88 bytes on 64bit arches
which is not negligible.  Also, it cannot be easily found by other
code, which e.g. caused duplication of some members of the structure
to struct thread already.  The change removes td_dbg_sc_code and
td_dbg_sc_nargs which were directly copied from syscall_args.

The structure is put into the copied on fork part of the struct thread
to make the syscall arguments information correct in the child after
fork.

This move will also allow several more uses shortly.

Reviewed by:	jhb (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
X-Differential revision:	https://reviews.freebsd.org/D11080
2017-06-12 21:03:23 +00:00
Konstantin Belousov
43f41dd393 Make struct syscall_args visible to userspace compilation environment
from machine/proc.h, consistently on all architectures.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks
X-Differential revision:	https://reviews.freebsd.org/D11080
2017-06-12 20:53:44 +00:00
Edward Tomasz Napierala
77c97f893a Remove unused tlb_write_random().
Sponsored by:	DARPA, AFRL
2017-06-05 11:04:22 +00:00
Edward Tomasz Napierala
ab1318b7ed Remove extraneous parentheses.
Sponsored by:	DARPA, AFRL
2017-06-05 10:59:47 +00:00
Adrian Chadd
bf3bb1b028 [ar71xx] rename AR724X_BASE -> std.AR724X 2017-05-31 16:32:33 +00:00
Adrian Chadd
bba819843e [AP93] fix up the arge0/arge1 hints. 2017-05-29 07:57:01 +00:00
Adrian Chadd
21ba140453 [ar71xx] [ar724x] update to work
* add EARLY_PRINTF for debugging
* update module list to be much larger
* add random, otherwise well, stuff doesn't work.
* IPFIREWALL_DEFAULT_TO_ACCEPT

Tested:

* AP93 (AR7240 + AR9280)

TODO:

* rename to std.AR724X
* unify the built module list between all of the mips24k/mips74k atheros config files -
  now that the HAL, hwpmc, USB, etc are per-chip/per-arch modules it is easy to just
  compile them all and only include the ones you care about.
2017-05-29 07:30:07 +00:00
Adrian Chadd
56e4110f8e Update AP93 support to the new world order.
* Map change: create a combined kernel+rootfs image.  The instructions I'll post
  on the wiki (which will be for a very outdated dev board, but at least will
  explain the what/why for posterity) will include how to reset the boot command.

Tested:

* AP93 dev board (AR7240 + AR9280)
2017-05-29 07:27:08 +00:00
Michael Zhilin
97721228b8 [mips] [bhnd] Support of old PMU for BMIPS and siba SoC
- Fix typo of PLL Type 4
 - Don't panic of frequency getters

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Differential Revision:	https://reviews.freebsd.org/D10967
2017-05-28 12:05:16 +00:00
Adrian Chadd
2e986d170b [ar71xx] undo read-after-write to flush; some bus devices dislike this.
This broke the PCI fixup on at least the AR7240 + AR9280 reference design
board that I have.

Tested:

* Atheros AP93 reference design - AR7240 + AR9280
2017-05-28 07:44:55 +00:00
Edward Tomasz Napierala
0e742f2d84 Remove superfluous parentheses.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-05-23 12:00:08 +00:00
Adrian Chadd
7a0466bc2b [ar71xx] remove dead code! 2017-05-23 06:20:24 +00:00
Adrian Chadd
57b8f9ca1d [ar71xx] add a very simple early boot driver called "caldata" to commit cross-layer atrocities.
The (eventually) upcoming ath(4) changes will include being able to load
ath(4) devices on the AHB bus (ie the on-die wifi part of the SoC)
as modules.

In order for this to happen, a copy of the calibration data needs to be
copied away before the SPI driver runs or the memory map access hack
won't work.

Now, ideally (!) there'd be some driver that can come up after the MTD
pieces (eg, SPI, NAND, etc) and load into a firmware chunk the calibration
data.

(Or, really really nicely, would be an actual async firmware API that
would lead itself to having a driver schedule a file read - or a raw device
read - to get to the calibration data.)

Now, until all of the above is done - I'm going to perpetuate the layer
breaking atrocity here by simply doing the PCI bus fixup EEPROM/calibration
data hack here.  This will work for any AR71xx (and later on, AR231x/AR531x)
device, as well as the handful of QCA MIPS + QCA9880v2 802.11ac boards with
NOR flash.

To use, this goes into the kernel config:

# Enable EEPROM hacks
options AR71XX_ATH_EEPROM
device ar71xx_caldata
device firmware

# This enables the ath_ahb driver (when I commit the change!) to
# pull data out of the firmware hack.
options ATH_EEPROM_FIRMWARE

In the hints file:

# ART calibration data mapping device
hint.ar71xx_caldata.0.at="nexus0"
hint.ar71xx_caldata.0.order=0

# Where the ART is - last 64k in the first 8MB of flash
hint.ar71xx_caldata.0.map.0.ath_fixup_addr=0x1fff0000
hint.ar71xx_caldata.0.map.0.ath_fixup_size=16384

# And now tell the ath(4) driver where to look!
hint.ath.0.eeprom_firmware="ar71xx_caldata.0.map.0.eeprom_firmware"

Tested:

* carambola2, AR933x SoC, using a set of ath and ath_hal modules to load

TODO:

* unify this bit of firmware loading code, as I will definitely need
  to include both the PCI bus firmware version (for PCI ID fixups too!)
  as well as AHB/on-chip calibration data.

* Commit the ath_ahb bus code

* Convert .. everything over.  That'll take the majority of the time.
2017-05-23 06:20:06 +00:00
Adrian Chadd
9f329febcb [ar71xx] fix up dump space a la what jhb@ did elsewhere a while ago. 2017-05-21 23:55:58 +00:00
Ed Maste
3e85b721d6 Remove register keyword from sys/ and ANSIfy prototypes
A long long time ago the register keyword told the compiler to store
the corresponding variable in a CPU register, but it is not relevant
for any compiler used in the FreeBSD world today.

ANSIfy related prototypes while here.

Reviewed by:	cem, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D10193
2017-05-17 00:34:34 +00:00
Hans Petter Selasky
65b017b420 Avoid use of contiguous memory allocations in busdma when possible.
This patch improves the boundary checks in busdma to allow more cases
using the regular page based kernel memory allocator. Especially in
the case of having a non-zero boundary in the parent DMA tag. For
example AMD64 based platforms set the PCI DMA tag boundary to
PCI_DMA_BOUNDARY, 4GB, which before this patch caused contiguous
memory allocations to be preferred when allocating more than PAGE_SIZE
bytes. Even if the required alignment was less than PAGE_SIZE bytes.

This patch also fixes the nsegments check for using kmem_alloc_attr()
when the maximum segment size is less than PAGE_SIZE bytes.

Updated some comments describing the code in question.

Differential Revision:	https://reviews.freebsd.org/D10645
Reviewed by:		kib, jhb, gallatin, scottl
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2017-05-16 14:21:37 +00:00
John Baldwin
4a0f7f1c10 Add initial support for the floating point implementation register.
- Save the current FIR in the global 'cpuinfo' structure in a new
  'fpu_id' member.
- Decode flags in the FIR when displaying other CPU flags during boot.
- Use the existing "dummy" slot in the floating point register structure
  to export the FIR in process core dumps and via ptrace().  Note that
  while the FIR register is not volatile, this practice of storing the FIR
  in the floating-point register set is used in other OS's.

Reviewed by:	kan
MFC after:	1 month
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D10617
2017-05-09 17:35:16 +00:00
Adrian Chadd
5d3ae74635 [mediatek] [gpio] add PPS / interrupt support.
Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	mizhka
Differential Revision:	https://reviews.freebsd.org/D9784
2017-05-06 06:22:14 +00:00
Adrian Chadd
01c914420d [mips] [rt2880] Add oldest Ralink MIPS SOC RT2880 support code.
* Target module have ic plus etherswitch ip175c.
* Also add etherswitch support code on rt driver.

Reviewed by:	mizhka
Differential Revision:	https://reviews.freebsd.org/D10336
2017-05-06 06:20:34 +00:00
Adrian Chadd
7e2f67b973 [ar934x] do an ethernet analog reset; apparently some boards don't.
Tested:

* on IOData WN-G300R. may be same as Sitecom WLR-2100.

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Differential Revision:	https://reviews.freebsd.org/D10621
2017-05-06 06:09:50 +00:00
Adrian Chadd
a10430e0a3 [ar531x] [if_are] Fix if_are behaviour under high load traffic
* use ifqmaxlen
* handle (inefficiently for now) meeting padding and alignment requirements for
  transmit mbufs.
* change how TX ring handling is done

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Differential Revision:	https://reviews.freebsd.org/D10557
2017-05-06 06:06:11 +00:00
Adrian Chadd
b0168423b6 [mips] default AR933x/AR934x to include mips24k hwpmc and limit umtx chain memory wastage.
Tested:

* AR933x SoC (Carambola2)
* AR934x SoC (TP-Link WDR3600)
2017-05-03 05:45:43 +00:00
Landon J. Fuller
eb23aa8008 Add support for dumping bcma/siba EROM tables to the console via a new
BHND_EROM_DUMP() method.

Dump the EROM tables to the coneole on mips/broadcom devices if bootverbose
is enabled; this functionality is primarily useful when debugging SoC EROM
parsing and device matching issues during early boot.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Sponsored by:	Plausible Labs
Differential Revision:	https://reviews.freebsd.org/D10122
2017-04-24 18:35:25 +00:00
Ruslan Bukin
31cfa79fab Switch BERI Programmable Interrupt Controller to INTRNG.
Sponsored by:	DARPA, AFRL
2017-04-18 17:20:03 +00:00
Gleb Smirnoff
83c9dea1ba - Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place.  To do per-cpu stats, convert all fields that previously were
  maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
  before we have set up UMA and we can do counter_u64_alloc(), provide an
  early counter mechanism:
  o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
  o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
    so that at early stages of boot, before counters are allocated we already
    point to a counter that can be safely written to.
  o For sparc64 that required a whole dummy pcpu[MAXCPU] array.

Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
  to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.

This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html

Reviewed by:	kib, gallatin, marius, lidl
Differential Revision:	https://reviews.freebsd.org/D10156
2017-04-17 17:34:47 +00:00
Gleb Smirnoff
9ed01c32e0 All these files need sys/vmmeter.h, but now they got it implicitly
included via sys/pcpu.h.
2017-04-17 17:07:00 +00:00
Olivier Houchard
4176bf15d4 This file is also used in libcompiler_rt, so bring in stdbool.h if we're not
in the kernel.
2017-04-11 13:31:27 +00:00
Olivier Houchard
e459212853 Provide some kind of __sync_bool_compare_and_swap_4(), as it is used by CK,
and our gcc is too ancient to provide it.
This should fix the build on mips.
2017-04-10 21:44:13 +00:00
Patrick Kelsey
67d955aab4 Corrected misspelled versions of rendezvous.
The MFC will include a compat definition of smp_no_rendevous_barrier()
that calls smp_no_rendezvous_barrier().

Reviewed by:	gnn, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D10313
2017-04-09 02:00:03 +00:00
Edward Tomasz Napierala
c1c0b62d87 Remove dead code/ifdef.
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2017-04-04 08:17:03 +00:00
Michael Zhilin
cb99e844b4 [etherswitch] simplify kernconf for recently added etherswitch drivers
This simple patch adds e6060sw, adm6996fc and ksz8995ma into conf/files.

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	adrian, mizhka
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9255
2017-03-27 19:26:09 +00:00
Bruce Evans
f434f3515b Fix printing of negative offsets (typically from frame pointers) again.
I fixed this in 1997, but the fix was over-engineered and fragile and
was broken in 2003 if not before.  i386 parameters were copied to 8
other arches verbatim, mostly after they stopped working on i386, and
mostly without the large comment saying how the values were chosen on
i386.  powerpc has a non-verbatim copy which just changes the uncritical
parameter and seems to add a sign extension bug to it.

Just treat negative offsets as offsets if they are no more negative than
-db_offset_max (default -64K), and remove all the broken parameters.

-64K is not very negative, but it is enough for frame and stack pointer
offsets since kernel stacks are small.

The over-engineering was mainly to go more negative than -64K for the
negative offset format, without affecting printing for more than a
single address.

Addresses in the top 64K of a (full 32-bit or 64-bit) address space
are now printed less well, but there aren't many interesting ones.
For arches that have many interesting ones very near the top (e.g.,
68k has interrupt vectors there), there would be no good limit for
the negative offset format and -64K is a good as anything.
2017-03-26 18:46:35 +00:00
Landon J. Fuller
591e79bc76 [mips/broadcom]: Early boot NVRAM support
Add support for early boot access to NVRAM variables, using a new
bhnd_nvram_data_getvar_direct() API to support zero-allocation direct
reading of NVRAM variables from a bhnd_nvram_io instance backed by the
CFE NVRAM device.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D9913
2017-03-23 19:29:12 +00:00
Landon J. Fuller
b86f80276b Add MIPS boot support for the BCM4706/Northstar ChipCommon core.
This adds support for matching against a core lookup table when performing
early boot core lookup, and includes the BCM4706/Northstar-specific
ChipCommon core ID in the set of supported ChipCommon cores.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D10033
2017-03-17 22:02:02 +00:00
Alexander Kabaev
bb99420132 Add cavium octeon 'bootoctlinux' boot argument support
While there, parse u-boot provided command line arguments
for supported switches and update boothowto appropriately.
Also support setting kenv variables from the kernel comman
line.

PR:	216831 (modified)
2017-03-16 00:49:59 +00:00
Emmanuel Vadot
2a92bd2d38 Use 'options EXT_RESOURCES' instead of 'device ext_resources' for FDT enabled
MIPS kernel config.
2017-03-12 07:09:50 +00:00
Marius Strobl
55dae242e6 Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
as kernel drivers and their dependency onto mmc(4); this allows for
incrementing the mmc(4) module version but also for entire omission
of these bridge declarations for mmccam(4) in a single place, i. e.
in dev/mmc/bridge.h.
2017-03-07 22:42:44 +00:00
Marius Strobl
b440e965da o Another round fixes for mmc(4), mmcsd(4) and sdhci(4) regarding
comments, marking unused parameters as such, style(9), whitespace,
  etc.
o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
  - Remove redundant assignments of the default bus_generic_print_child
    device method (I've whipped these out of the tree as part of r227843
    once, but they keep coming back ...),
  - use DEVMETHOD_END,
  - use NULL instead of 0 for pointers.
o Trim/adjust includes.
2017-03-06 23:47:59 +00:00
Ruslan Bukin
6fa2cb00ec Fix build: include machine/bus.h before uart.h
Reported by:	emaste
Sponsored by:	DARPA, AFRL
2017-03-02 17:09:14 +00:00
Warner Losh
1d3e57669e Add kernel support for the TP-LINK MR3040.
Submitted by:	Chris Christensen <cchristensen@llnw.com>
Pull Request:	https://github.com/freebsd/freebsd/pull/38
2017-03-01 05:53:53 +00:00
Warner Losh
43b96a4eb5 Revert prior commit to restore the files mangled by my "fixing" merge
conflicts for a git rebase I tried to do.
2017-03-01 02:10:40 +00:00
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Warner Losh
3fc79998ea Add Ubiquiti Rocket M support
Updated to use geom_uzip

Submitted by:   Michael Vale <m.vale@live.com.au>
Pull Request:   https://github.com/freebsd/freebsd/pull/16
2017-02-28 22:49:45 +00:00
Warner Losh
e7eec274e1 Fix arge0 mdio bus
This makes arge0 phy's attach.

Submitted by:	Michael Vale <m.vale@live.com.au>
Pull Request:	https://github.com/freebsd/freebsd/pull/16
2017-02-28 21:39:08 +00:00
Warner Losh
64aa3f3046 Update PICOSTATION_M2HP
Make the random number generator work so we can do WPA encryption on the AP's.

Submitted by:	Michael Vale <m.vale@live.com.au>
Pull Request:	https://github.com/freebsd/freebsd/pull/16
2017-02-28 21:39:00 +00:00
Ruslan Bukin
c214a270f5 Allow setting access-width for UART registers.
This is required for FDT's standard "reg-io-width" property
(similar to "reg-shift" property) found in many DTS files.

This fixes operation on Altera Arria 10 SOC Development Kit,
where standard ns8250 uart allows 4-byte access only.

Reviewed by:	kan, marcel
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9785
2017-02-27 20:08:42 +00:00
Warner Losh
55157631f1 Include pcib_private.h for prototypes.
Noticed by: rpokala@
Sponsored by: Netflix
2017-02-26 21:33:18 +00:00
Warner Losh
28586889c2 Convert PCIe Hot Plug to using pci_request_feature
Convert PCIe hot plug support over to asking the firmware, if any, for
permission to use the HotPlug hardware. Implement pci_request_feature
for ACPI. All other host pci connections to allowing all valid feature
requests.

Sponsored by: Netflix
2017-02-25 06:11:59 +00:00
Brooks Davis
b853277efc Fix and shorten BERI kernel builds during universe.
Stop building BERI_DE4_BASE and BERI_SIM_BASE, they aren't particularly
valid as they don't have a root dev.  Do build BERI_DE4_SDROOT which
does so devices get coverage.

Remove ident from BERI_DE4_BASE for the reasons above which will cause
it to fail to build.  BERI_SIM_BASE was already this way and broke
universe.[0]

Reported by:	rpokala
Sponsored by:	DARPA, AFRL
2017-02-23 20:41:55 +00:00
Pedro F. Giffuni
e099b90b80 sys: Replace zero with NULL for pointers.
Found with:	devel/coccinelle
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D9694
2017-02-22 02:35:59 +00:00
Brooks Davis
9fa34a2b0c Rename BERI_TEMPLATE to std.BERI to be more like other configs.
Sponsored by:	DARPA, AFRL
2017-02-21 17:34:27 +00:00
Jason A. Harmening
e2a8d17887 Bring back r313037, with fixes for mips:
Implement get_pcpu() for amd64/sparc64/mips/powerpc, and use it to
replace pcpu_find(curcpu) in MI code.

Reviewed by:	andreast, kan, lidl
Tested by:	lidl(mips, sparc64), andreast(powerpc)
Differential Revision:	https://reviews.freebsd.org/D9587
2017-02-19 02:03:09 +00:00
Brooks Davis
621c56330d Enable capsicum on MALTA kernels.
This adds less that 10K to the kernel and should probably be done in the
other std.* configs.
2017-02-17 21:25:24 +00:00
Landon J. Fuller
8f3bba2d35 [mips/broadcom] Move MIPS-specific bhnd(4) nexus drivers to
sys/mips/broadcom, and add MIPS/BCM4706-specific workaround to
bhnd_nexus_is_hw_disabled() -- the BCM4706 low-cost package leaves
secondary GMAC cores floating.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D9499
2017-02-13 19:58:55 +00:00
Allan Jude
6053fa9683 Add I2C device hints for Onion Omega
This allows you to control up to 8 relay expansions from FreeBSD

https://github.com/freebsd/freebsd-wifi-build/wiki/Onion-Omega#controlling-the-relay-expansion

Reviewed by:	adrian, mizhka
MFC after:	1 week
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D9503
2017-02-09 15:16:08 +00:00
Alexander Kabaev
7b6d9d0c3a Use 64bit store instruction in atomic_fcmpset_64.
Reported by: br
2017-02-06 14:00:28 +00:00
Konstantin Belousov
9fb10d635e Define the vm_ooffset_t and vm_pindex_t types as machine-independend.
The types are for the byte offset and page index in vm object.  They
are similar to off_t, which is defined as 64bit MI integer.  Using MI
definitions will allow to provide consistent MD values of vm
object-related maximum sizes.

Reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-02-04 12:26:38 +00:00
Jason A. Harmening
ad62ba6e96 Revert r313037
The switch to get_pcpu() in MI code seems to cause hangs on MIPS.
Back out until we can get a better idea of what's happening there.

Reported by:	kan, lidl
2017-02-04 06:24:49 +00:00
Alexander Kabaev
2733239f37 Add atomic_fcmpset_*() inlines for MIPS
atomic_fcmpset_*() is analogous to atomic_cmpset(), but saves off the
read value from the target memory location into the 'old' pointer.

Reviewed by:	imp, brooks
Requested by:	mjg
Differential Revision:	https://reviews.freebsd.org/D9391
2017-02-01 05:00:34 +00:00
Jason A. Harmening
65ed483615 Implement get_pcpu() for the remaining architectures and use it to
replace pcpu_find(curcpu) in MI code.
2017-02-01 03:32:49 +00:00
Robert Watson
d166e6c63f As with GENERIC on other architectures, include COMPAT_FREEBSD10 and
COMPAT_FREEBSD11 in the generic BERI kernel configuration template.

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-01-28 11:38:51 +00:00
Ed Maste
978f10562f ERL: set -march=octeon+ for use with external toolchain
Upstream GCC and devel/mips64-gcc use "octeon+" as the CPU setting for
the Octeon processor in the EdgeRouter Lite. As of r312899 the base
system GCC 4.2.1 accepts octeon+ as an alias for the Octeon support
added in r208737 for the same CPU.

Sponsored by:	The FreeBSD Foundation
2017-01-28 00:00:10 +00:00
Kurt Lidl
df980daf35 Remove 'options NO_SWAPPING' from ERL configuration file 2017-01-26 20:45:04 +00:00
Ed Maste
ee80cc1b1c Enable modules in the MIPS ERL kernel config
As reported by cperciva[1], modules are beneficial for typical
Edgerouter Lite use cases.

[1] http://www.daemonology.net/blog/2016-01-10-FreeBSD-EdgeRouter-Lite.html
2017-01-26 18:18:35 +00:00
Brooks Davis
e0f076ceea Enable TMPFS on MALTA so we can use it on minimalist disk images without
modules.

Sponsored by:	DARPA, AFRL
2017-01-21 09:08:27 +00:00
Adrian Chadd
a8d1e02f85 [ar71xx] add EARLY_PRINTF support for the rest of the non-AR933x SoCs.
Tested:

* AR934x SoC
2017-01-15 06:35:00 +00:00
Michael Zhilin
e1f21017a3 [mips/onionomega] WiFi & gpio kernel configuration bits
This patch adds missing hints for ath0 (eepromaddr) and GPIO (mask & leds).
ath0 doesn't work without eeprom hints, so this commit should make wifi
works on Onion Omega.

GPIO mask is required if you want to use gpiobus and GPIO pins on your
board. Onion Omega has several leds connected to gpio pins (one on board,
one color on dock).
This commit adds mask for gpiobus and allow you to turn off/on leds via
/dev/leds/{board,blue,green,red} (on by default).

Tested on Onion Omega 1.

Reviewed by:	adrian
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D9107
2017-01-14 22:56:20 +00:00
John Baldwin
e2c14d90df Trim a few comments on platforms that did not implement mmap of /dev/kmem.
After r307332, no platforms implement mmap for /dev/kmem, so the lack of
it for these platforms is no longer unique.
2017-01-13 21:52:53 +00:00
Sean Bruno
f2d6ace4a6 Migrate e1000 to the IFLIB framework:
- em(4) igb(4) and lem(4)
- deprecate the igb device from kernel configurations
- create a symbolic link in /boot/kernel from if_em.ko to if_igb.ko

Devices tested:
- 82574L
- I218-LM
- 82546GB
- 82579LM
- I350
- I217

Please report problems to freebsd-net@freebsd.org

Partial review from jhb and suggestions on how to *not* brick folks who
originally would have lost their igbX device.

Submitted by:	mmacy@nextbsd.org
MFC after:	2 weeks
Relnotes:	yes
Sponsored by:	Limelight Networks and Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8299
2017-01-10 03:23:22 +00:00
John Baldwin
69b4d461be Enable /usr/lib32 for o32 binaries on mips64.
Build and install an o32 set of libraries on mips64 suitable for
running o32 binaries via COMPAT_FREEBSD32. Enable COMPAT_FREEBSD32 in
MALTA64.

Reviewed by:	jmallett, imp
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D9032
2017-01-06 23:30:54 +00:00
John Baldwin
9f0968c616 Add uintmax_t casts to silence printf format warnings.
The format strings weren't checked when stacksave_subr() used a function
pointer for printf instead of directly using db_printf().

Reported by:	kib
Sponsored by:	DARPA / AFRL
2017-01-06 00:41:30 +00:00
Alexander Kabaev
631f432b0d Remove redundant cache initialization in JZ4780 SMP startup code
This was done out of pure paranoia when hunting for bugs in cache
and is not really required.
2017-01-06 00:07:36 +00:00
John Baldwin
58ffa42f64 Use db_printsym() to display function names in stack traces.
Previously, the stack unwinder tried to locate the start of the function
in each frame by walking backwards until it found an instruction that
modified the stack pointer and then assumed that was the first instruction
in a function.  The unwinder would only print a function name if the
starting instruction's address was an exact match for a symbol name.
However, not all functions generated by modern compilers start off functions
with that instruction.  For those functions, the unwinder would fail to
find a matching function name.  As a result, most frames in a stack
trace would be printed as raw hex PC's instead of a function name.

Stop depending on this incorrect assumption and just use db_printsym()
like other platforms to display the function name and offset for each
frame.  This generates a far more useful stack trace.

While here, don't print out curproc's pid at the end of the trace.  The
pid was always from curproc even if tracing some other process.

In addition, remove some rotted comments about hardcoded constants that
are no longer hardcoded.

Sponsored by:	DARPA / AFRL
2017-01-05 00:59:53 +00:00
John Baldwin
da53b41194 Only call stacktrace_subr() from DDB.
There was a single call to stacktrace() under an #ifdef DEBUG to obtain
a stack trace during a fault that resulted in a function pointer to a
printf function being passed to stacktrace_subr() in db_trace.c.  The
kernel now has existing interfaces for obtaining a stack trace outside
of DDB (kdb_backtrace(), or the stack_*() API) that should be used instead.
Rather than fix the one call however, remove it since the kernel will
dump a trace anyway once it panics.

Make stacktrace_subr() static, remove the function pointer and change it
to use db_printf() explicitly.

Discussed with:	kan
Sponsored by:	DARPA / AFRL
2017-01-05 00:08:04 +00:00
John Baldwin
887cc8f480 Further refine MIPS stack traces across trapframes.
Use the trapframe unwinder recently added for kernel stack overflow
panics for frames crossing MipsKernGenException and MipsKernIntr.
This provides more reliably unwinding across nested interrupts and
exceptions in the kernel.

While here, dump the value of the CAUSE and BADVADDR registers when
crossing a trapframe.

Submitted by:	rwatson (original version)
Obtained from:	CheriBSD
Sponsored by:	DARPA / AFRL
2017-01-04 21:13:21 +00:00
Alexander Kabaev
e39ff5dd0b Remove duplicate iic and iicbus devices from JZ4780 kernel 2017-01-04 18:36:30 +00:00
Alexander Kabaev
f369aff32d Support mips[*]hf variants in config files
Recognize new MACHINE_ARCH names now as we have added hardfloat support.
Switch JZ4780 to mipselhf and remove all uses of TARGET_ARCH in kernel
.mk files.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8989
2016-12-30 00:34:52 +00:00
Alexander Kabaev
8e7c7e4ed7 Use mips_dcache_wbinv_range instead of mips_dcache_wb_range on CPU_XBURST
Ingenic CPUs treat plain cache writeback as local-only operation and do
nothing if that is a remote CPU that holds the dirty cache line. They
do broadcast invalidate and write-and-invalidate to other cores though,
so take advantage of that and use wbinv in place of wb as this still gives
us required busdma semantics. Otherwise we'd have to do IPI to remote CPU
ourselves.
2016-12-29 20:11:50 +00:00
Adrian Chadd
0013dd123f [ar71xx] add EARLY_PRINTF support for the AR933x (Hornet) UART.
Tested:

* Carambola 2
2016-12-29 17:31:38 +00:00
Adrian Chadd
ccfb1ab87c [ar71xx] put in an implicit read-after-write to flush things out.
Note: I may need to revisit this for mips74k.
2016-12-29 17:31:07 +00:00
Jared McNeill
7fd348080f The JZ4780 I2S can feed either the internal audio codec or the HDMI
transmitter, but not both at the same time. This patch:

 - Adds a dev.pcm.0.internal_codec sysctl node for selecting between
   internal and external codec
 - Changes playback sample rate from 96 kHz to 48 kHz for HDMI compatibility
 - Enables i2s clock on codec access

Reviewed by:		br
Differential Revision:	https://reviews.freebsd.org/D8960
2016-12-29 14:00:10 +00:00
Alexander Kabaev
47abdb10a0 Do not use read-modify-write on MSC control register.
The register is write-only, so just write only bits we want.

Submitted by:	jmcneill
2016-12-28 19:40:59 +00:00
Alexander Kabaev
1b664b2eea Be more conservative when enabling write-combining on MIPS
Some MIPS revisions do implement uncached-accelerate caching
attribute, but place extra requirement on access, such as
partial-word or out-of-sequence writes potentially having an
“unpredictable” effects.
2016-12-28 13:48:00 +00:00
Alexander Kabaev
a0e41d3784 Implement pmap_change_attr and related APIs on MIPS
On platforms that have uncached-accelerate cache attribute, map it
to VM_MEMATTR_WRITE_COMBINING. Otherwise, leave write comining
undefined.

Reviewed by:	adrian, jhb (glance)
Differential Revision:	https://reviews.freebsd.org/D8894
2016-12-28 02:55:26 +00:00
Alexander Kabaev
72565e644e Add driver for JZ4780 RTC device.
Only support basic timekeeping for now.
2016-12-24 02:31:26 +00:00
Alexander Kabaev
9e9262139c Pass memattrs to fb device so that user mappings can inherit them
Reviewed by:	jmcneill
2016-12-23 19:30:14 +00:00
John Baldwin
7212e5d8bf Teach DDB how to unwind across a kernel stack overflow.
Kernel stack overflows in MIPS call panic() directly from an assembly
handler after storing the interrupted context's registers in a
trapframe.  Rather than inferring the location of ra, sp, and pc from
the instruction stream, recognize the pc of a kernel stack overflow
and pull the registers from the trapframe.

Sponsored by:	DARPA / AFRL
2016-12-23 03:27:11 +00:00
John Baldwin
7a6d450d66 MFamd64: Various fixes for MIPS minidumps.
- Honor PG_NODUMP by not dumping pages with this flag set.
- Pat the watchdog during dumps to avoid a watchdog reset while writing
  out a dump.
- Reformat the output during a dump to update every 10% done rather than
  every 2MB dumped.
- Include UMA small pages and pages holding PV entries in minidumps.

Sponsored by:	DARPA / AFRL
2016-12-23 03:20:34 +00:00
John Baldwin
f2f9011e6c Fix dump_avail[] for MALTA platforms to include the kernel.
dump_avail[] is supposed to be a superset of phys_avail[] that
describes all of the memory ranges that should be included in a full
dump.  minidumps don't consider pages described by dump_avail[] to be
valid and thus they are excluded via the is_dumpable() function.  Most
MIPS platforms (including MALTA) set dump_avail[] to be identical to
phys_avail[].  In particular, phys_avail[] doesn't include the kernel
itself, so pages for the kernel and it's global variables are not
considered dumpable and not included in the dump.  Fix this by setting
dump_avail[0] to the first memory address (0) rather than the end of
the kernel.

Several other MIPS platforms have the same bug, though I am only able
to test malta in qemu.  The correct fix is to set dump_avail[] to
describe RAM and in particular to not set dump_avail[0] to the end of
the kernel (kernel_kseg0_end).

Sponsored by:	DARPA / AFRL
2016-12-22 20:28:06 +00:00
Ruslan Bukin
46ac5f081d o Unmute headphones on Imgtec CI20 board.
o Add some delay between codec initialization procedures.

Sponsored by:	DARPA, AFRL
2016-12-20 18:47:02 +00:00
Ruslan Bukin
b6a250518a Add jz4780 AIC (Audio Interface Controller) driver.
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D8808
2016-12-20 18:27:53 +00:00
Ruslan Bukin
85b6e3b227 Add jz4780 PDMA controller driver.
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D8817
2016-12-20 18:09:59 +00:00
Jared McNeill
964670595f Add support for Ingenic JZ4780 LCD controller and enable framebuffer
console support.

Reviewed by:		kan
Differential Revision:	https://reviews.freebsd.org/D8827
2016-12-20 01:51:09 +00:00
Jared McNeill
8ee54cadae Choose the closes matching divider instead of one that results in a
frequency >= target. Fix inverted rounding logic for CLK_SET_ROUND_UP/DOWN.

Reviewed by:		kan
Differential Revision:	https://reviews.freebsd.org/D8784
2016-12-20 01:37:00 +00:00
Landon J. Fuller
58efe68622 bhnd(4): minor style(9) fixes
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D8755
2016-12-19 20:07:58 +00:00
Emmanuel Vadot
7073d12c4d ofw_spi: Parse property for the SPI mode and CS polarity.
As cs is stored in a uint32_t, use the last bit to store the
active high flag as it's unlikely that we will have that much CS.

Reviewed by:	loos
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8614
2016-12-18 14:54:20 +00:00
Jared McNeill
a7514a4925 Add support for Ingenic JZ4780 SMBus controller.
Reviewed by:		kan
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D8793
2016-12-16 20:04:56 +00:00
Adrian Chadd
26eae5c681 [ar933x] don't waste memory/flash; drop the UMTX_CHAINS count down to 16. 2016-12-16 00:04:32 +00:00
John Baldwin
a24563566a Add 'const' to fn_name's return type to remove a cast. 2016-12-14 00:21:06 +00:00
John Baldwin
2aa82aeacc Fix stack traces in DDB for the debugger thread.
When the kernel debugger is entered, makectx() is called to store
appropriate state from the trapframe for the debugger into a global
kdb_pcb used as the thread context of the thread entering the
debugger.  Stack unwinders for DDB called via db_trace_thread() are
supposed to then use this saved context so that the stack trace for
the current thread starts at the location of the event that triggered
debugger entry.

MIPS was instead starting the stack trace of the current thread from
the context of db_trace_thread itself and unwinding back out through
the debugger to the original frame.  Fix a couple of things to bring
MIPS inline with other platforms:
- Fix makectx() to store the PC, SP, and RA in the right portion of
  the PCB used by db_trace_thread().
- Fix db_trace_thread() to always use kdb_thr_ctx() (and thus kdb_pcb
  for the debugger thread).
- Move the logic for tracing curthread from within the current
  function into db_trace_self() to match other architectures.

Sponsored by:	DARPA / AFRL
2016-12-13 22:30:48 +00:00
John Baldwin
ca311cf72b Use register_t instead of uintptr_t for register values in backtraces.
This fixes backtraces from DDB in n32 kernels as uintptr_t is only a
uint32_t.  In particular, the upper 32-bits of each register value were
treated as the register's value breaking both the output of register
values, but also the values of 'ra' and 'sp' required to walk up to the
previous frame.

Sponsored by:	DARPA / AFRL
2016-12-13 19:36:05 +00:00
John Baldwin
6c941e4724 Fix remove_userlocal_code() for n32.
n32 kernels use a 64-bit store to the TLS register rather than a 32-bit
store.

Sponsored by:	DARPA / AFRL
2016-12-13 19:27:31 +00:00
Michael Zhilin
167a228d79 [spi] reformat message and ar5315_spi minor fix
This commit corrects print of nomatch (newline was too early) and fix
unit number for new child in ar5315_spi (was 0, now is -1 to calculate it
according to actual system state)

Submitted by:	Hiroki Mori <yamori813@yahoo.co.jp>
Reviewed by:	ray, loos, mizhka
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8749
2016-12-13 09:53:43 +00:00
Emmanuel Vadot
adff859ba2 Use the spibus accessor when applicable.
MFC after:	3 days
2016-12-12 20:04:31 +00:00
Ruslan Bukin
f3c658a869 Apply clear_mask correctly.
Reviewed by:	jmcneill, kan
Sponsored by:	DARPA, AFRL
2016-12-12 17:08:52 +00:00
Konrad Witaszczyk
480f31c214 Add support for encrypted kernel crash dumps.
Changes include modifications in kernel crash dump routines, dumpon(8) and
savecore(8). A new tool called decryptcore(8) was added.

A new DIOCSKERNELDUMP I/O control was added to send a kernel crash dump
configuration in the diocskerneldump_arg structure to the kernel.
The old DIOCSKERNELDUMP I/O control was renamed to DIOCSKERNELDUMP_FREEBSD11 for
backward ABI compatibility.

dumpon(8) generates an one-time random symmetric key and encrypts it using
an RSA public key in capability mode. Currently only AES-256-CBC is supported
but EKCD was designed to implement support for other algorithms in the future.
The public key is chosen using the -k flag. The dumpon rc(8) script can do this
automatically during startup using the dumppubkey rc.conf(5) variable.  Once the
keys are calculated dumpon sends them to the kernel via DIOCSKERNELDUMP I/O
control.

When the kernel receives the DIOCSKERNELDUMP I/O control it generates a random
IV and sets up the key schedule for the specified algorithm. Each time the
kernel tries to write a crash dump to the dump device, the IV is replaced by
a SHA-256 hash of the previous value. This is intended to make a possible
differential cryptanalysis harder since it is possible to write multiple crash
dumps without reboot by repeating the following commands:
# sysctl debug.kdb.enter=1
db> call doadump(0)
db> continue
# savecore

A kernel dump key consists of an algorithm identifier, an IV and an encrypted
symmetric key. The kernel dump key size is included in a kernel dump header.
The size is an unsigned 32-bit integer and it is aligned to a block size.
The header structure has 512 bytes to match the block size so it was required to
make a panic string 4 bytes shorter to add a new field to the header structure.
If the kernel dump key size in the header is nonzero it is assumed that the
kernel dump key is placed after the first header on the dump device and the core
dump is encrypted.

Separate functions were implemented to write the kernel dump header and the
kernel dump key as they need to be unencrypted. The dump_write function encrypts
data if the kernel was compiled with the EKCD option. Encrypted kernel textdumps
are not supported due to the way they are constructed which makes it impossible
to use the CBC mode for encryption. It should be also noted that textdumps don't
contain sensitive data by design as a user decides what information should be
dumped.

savecore(8) writes the kernel dump key to a key.# file if its size in the header
is nonzero. # is the number of the current core dump.

decryptcore(8) decrypts the core dump using a private RSA key and the kernel
dump key. This is performed by a child process in capability mode.
If the decryption was not successful the parent process removes a partially
decrypted core dump.

Description on how to encrypt crash dumps was added to the decryptcore(8),
dumpon(8), rc.conf(5) and savecore(8) manual pages.

EKCD was tested on amd64 using bhyve and i386, mipsel and sparc64 using QEMU.
The feature still has to be tested on arm and arm64 as it wasn't possible to run
FreeBSD due to the problems with QEMU emulation and lack of hardware.

Designed by:	def, pjd
Reviewed by:	cem, oshogbo, pjd
Partial review:	delphij, emaste, jhb, kib
Approved by:	pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4712
2016-12-10 16:20:39 +00:00
Mark Johnston
7f68a896dc Add a COMPAT_FREEBSD11 kernel option.
Use it wherever COMPAT_FREEBSD10 is currently specified.

Reviewed by:	glebius, imp, jhb
Differential Revision:	https://reviews.freebsd.org/D8736
2016-12-09 18:54:12 +00:00
Ruslan Bukin
d9121bf564 Add registers for jz4780 audio and PDMA controllers.
Sponsored by:	DARPA, AFRL
2016-12-09 17:16:09 +00:00
Ruslan Bukin
4b3fae2c2d Add jz4780 internal codec initialization driver.
Sponsored by:	DARPA, AFRL
2016-12-08 16:28:34 +00:00
Landon J. Fuller
77cb4d3e50 bhnd(4): Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding.
- Defined an abstract NVRAM I/O API (bhnd_nvram_io), decoupling NVRAM/SPROM
  parsing from the actual underlying NVRAM data provider (e.g. CFE firmware
  devices).
- Defined an abstract NVRAM data API (bhnd_nvram_data), decoupling
  higher-level NVRAM operations (indexed lookup, data conversion, etc) from
  the underlying NVRAM file format parsing/serialization.
- Implemented a new high-level bhnd_nvram_store API, providing indexed
  variable lookup, pending write tracking, etc on top of an arbitrary
  bhnd_nvram_data instance.
- Migrated all bhnd(4) NVRAM device drivers to the common bhnd_nvram_store
  API.
- Implemented a common bhnd_nvram_val API for parsing/encoding NVRAM
  variable values, including applying format-specific behavior when
  converting to/from the NVRAM string representations.
- Dropped the now unnecessary bhnd_nvram driver, and moved the
  broadcom/mips-specific CFE NVRAM driver out into sys/mips/broadcom.
- Implemented a new nvram_map file format:
        - Variable definitions are now defined separately from the SPROM
          layout. This will also allow us to define CIS tuple NVRAM
          mappings referencing the common NVRAM variable definitions.
        - Variables can now be defined within arbitrary named groups.
        - Textual descriptions and help information can be defined inline
          for both variables and variable groups.
        - Implemented a new, compact encoding of SPROM image layout
          offsets.
- Source-level (but not build system) support for building the NVRAM file
  format APIs (bhnd_nvram_io, bhnd_nvram_data, bhnd_nvram_store) as a
  userspace library.

The new compact SPROM image layout encoding is loosely modeled on Apple
dyld compressed LINKEDIT symbol binding opcodes; it provides a compact
state-machine encoding of the mapping between NVRAM variables and the SPROM
image offset, mask, and shift instructions necessary to decode or encode
the SPROM variable data.

The compact encoding reduces the size of the generated SPROM layout data
from roughly 60KB to 3KB. The sequential nature SPROM layout opcode tables
also simplify iteration of the SPROM variables, as it's no longer
neccessary to iterate the full NVRAM variable definition table, but
instead simply scan the SPROM revision's layout opcode table.

Approved by:    adrian (mentor)
Differential Revision:  https://reviews.freebsd.org/D8645
2016-11-26 23:22:32 +00:00
Ruslan Bukin
6873df70b2 Don't build Ingenic kernels until we have non-static FDT support
for them.

Sponsored by:	DARPA, AFRL
2016-11-26 10:20:33 +00:00
Ruslan Bukin
3ace382ab0 Split MALTA board config to big and little endian versions.
This fixes compilation after r308807 ("Pass MACHINE_ARCH on
command line for MIPS kernels.")

Sponsored by:	DARPA, AFRL
2016-11-23 11:56:22 +00:00
Ruslan Bukin
62993bb71e Increase pcpu size to 512 so it become both denominator
of PAGE_SIZE and aligned to CACHE_LINE_SIZE.

This fixes CTASSERT.

Sponsored by:	DARPA, AFRL
2016-11-23 11:30:40 +00:00
Ruslan Bukin
fbe94797ea Add PDMA controller registers.
Obtained from:	X1000 IoT Application Processor Programming Manual
Sponsored by:	DARPA, AFRL
2016-11-21 15:42:54 +00:00
Ruslan Bukin
38079cf572 Move FDT option to the main SoC file and mark boards config
as NO_UNIVERSE.

Pointed out by:	andrew
Sponsored by:	DARPA, AFRL
2016-11-21 15:35:56 +00:00
Alexander Kabaev
0f2bb99d43 Use ofw_gpiobus instead of plain gpiobus for CI20
Requesed by: mmel
2016-11-20 01:59:22 +00:00
Ruslan Bukin
4943459ce3 Enable SMP on Ingenic JZ4780.
It is required to proceed full cache flush before we can use wait
instruction on multicore, so use nop instead for now.

Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-19 18:03:46 +00:00
Ruslan Bukin
9a8f61fb5b Bring in support for Ingenic XBurst JZ4780 and
X1000 systems on chips.

Imgtec CI20 and Ingenic CANNA boards supported.

Submitted by:	Alexander Kabaev <kan@FreeBSD.org>
Reviewed by:	Ruslan Bukin <br@FreeBSD.org>
Sponsored by:	DARPA, AFRL
2016-11-19 17:46:18 +00:00
Ruslan Bukin
91f70e00c4 Move intrng includes to the main MIPS includes file.
Sponsored by:	DARPA, AFRL
2016-11-19 17:01:06 +00:00
Ruslan Bukin
d509eaf204 Account for bigger secondary data cache line size.
Secondary data cache line size can be bigger than
primary data cache line size, so use biggest value
as a minimum alignment.

Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-19 16:36:38 +00:00
Ruslan Bukin
92fd9fe2b7 Add Ingenic XBurst coprocessor 0 extra bits.
Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-19 15:38:13 +00:00
Ruslan Bukin
bf214121f8 Identify Ingenic CPUs.
Submitted by:	kan
Sponsored by:	DARPA, AFRL
2016-11-19 15:10:10 +00:00
Alexander Kabaev
63a16ecab1 Subject: [PATCH] Pass MACHINE_ARCH on command line for MIPS kernels.
While there, make param.h guess proper MACHINE_ARCH on hardfloat targets
correctly as well, so tools like bmake can get their defaults right.
This does not help the kernel case, since we compile them with forced
-msoft-float and need to override an incorrect guess by param.h.

Reviewed by: br
Differential Revision:	https://reviews.freebsd.org/D8574
2016-11-18 16:23:31 +00:00
Michael Zhilin
34cd8ebdcf [mips/ar531x] code cleanup, non-INTRNG support
This commit improves code styles like:
 - removing commented code
 - format comments as C-style
 - add spaces after #define-s

It also bring ability to build kernel without INTRNG and remove RedBoot dependency.

Tested on FON2201

Submitted by:	Hiroki Sato <yamori813@yahoo.co.jp>
Reviewed by:	adrian, mizhka
Approved by:	adrian(mentor)
Differential Revision:	https://reviews.freebsd.org/D8557
2016-11-18 14:06:29 +00:00
Michael Zhilin
4dfc28b7e8 [MIPS] Fix Config3[ULRI] printing
Bit identifier of printf %b is octal integer, but not decimal. ULRI bit is
13-th bit (starting with 0) according to MIPS Architecture Volume III v.6.
In this case the bit identifier (starts with 1) should be \16.

Reviewed by:    gonzo
Approved by:	adrian(mentor)
Differential Revision:	https://reviews.freebsd.org/D8516
2016-11-15 20:44:19 +00:00
John Baldwin
08dc89a621 Sync instruction cache's after writing user breakpoints on MIPS.
Add an implementation for pmaps_sync_icache() on MIPS that sync's the
instruction cache on all CPUs via smp_rendezvous() after a debugger
inserts a breakpoint via ptrace(PT_IO).

Tested by:	kan (on Creator CI20 running Ingenic JZ4780 SOC)
MFC after:	2 weeks
Sponsored by:	DARPA / AFRL
2016-11-15 17:01:48 +00:00
Michael Zhilin
679761c0e0 [MIPS] Print Config7 on boot for several MIPS architectures
Config7 contains useful fields, for instance, field AR indicating that the D-cache is configured to avoid cache aliases. This patch brings printing of config7 for MIPS 24K, 74K, 1004K.

Reviewed by:	adrian
Approved by:	adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D8514
2016-11-14 21:38:36 +00:00
Andrew Turner
a61804c095 Use the new ofw_bus_node_is_compatible function in the mips code.
Sponsored by:	ABT Systems Ltd
2016-11-13 09:33:41 +00:00
Ruslan Bukin
a2aa0aae07 Use correct signal number for floating point exceptions.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-10-31 15:49:41 +00:00
Ruslan Bukin
5bca221511 Add full softfloat and hardfloat support for MIPS.
This adds new target architectures for hardfloat:
mipselhf mipshf mips64elhf mips64hf.

Tested in QEMU only.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D8376
2016-10-31 15:33:58 +00:00
John Baldwin
ed3abcbb0d Correct definition of 'struct sigcontext' on MIPS.
Add missing fields ('sr' and 'mc_tls') to 'struct sigcontext'.

The kernel doesn't use 'struct sigcontext' but instead uses 'ucontext_t'
which includes 'mcontext_t' in 'struct sigframe' to build the signal frame.
As a result, this change is not an ABI change but simply making
'struct sigcontext' correct.  Note that 'struct sigcontext' is only used
for "Traditional BSD style" signal handlers.

While here, rename the 'xxx' field to '__spare__' to match 'mcontext_t'.

Sponsored by:	DARPA, AFRL
2016-10-26 17:37:08 +00:00
Andriy Voskoboinyk
7453645f2a rtwn(4), urtwn(4): merge common code, add support for 11ac devices.
All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
 * for RTL8821AU: 2 VAPs at the same time;
 * other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
 * bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
 * common (if_rtwn*)
 * chip-specific (rtl*/*)
- various other bugfixes.

Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn  rtwnfw  -> rtwn rtwn_pci rtwnfw

Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.

Tested by:	kevlo, garga,
		Peter Garshtja <peter.garshtja@ambient-md.com>,
		Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
		Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
		<otacilio.neto@bsd.com.br>
Relnotes:	yes
2016-10-17 20:38:24 +00:00
Hans Petter Selasky
d3bf5efc1f Fix device delete child function.
When detaching device trees parent devices must be detached prior to
detaching its children. This is because parent devices can have
pointers to the child devices in their softcs which are not
invalidated by device_delete_child(). This can cause use after free
issues and panic().

Device drivers implementing trees, must ensure its detach function
detaches or deletes all its children before returning.

While at it remove now redundant device_detach() calls before
device_delete_child() and device_delete_children(), mostly in
the USB controller drivers.

Tested by:		Jan Henrik Sylvester <me@janh.de>
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D8070
MFC after:		2 weeks
2016-10-17 10:20:38 +00:00