Commit Graph

2392 Commits

Author SHA1 Message Date
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
Warner Losh
b2a7ac4802 Fix building on i386 and arm. But 'public domain' headers on the files
with no creative content. Include "lost" changes from git:
o Use /dev/efi instead of /dev/efidev
o Remove redundant NULL checks.

Submitted by: kib@, dim@, zbb@, emaste@
2016-10-13 06:56:23 +00:00
Ed Maste
de1cac0d4b Add COMPAT_FREEBSD10 to the MIPS ERL kernel config
As of r302092, pipe is a wrapper around pipe2 and the pipe syscall is no
longer used. It is included only with the COMPAT_FREEBSD10 kernel option.
Add the compat option to support upgrades from systems with an earlier
userland.

MFC after:	1 week
2016-10-12 18:49:30 +00:00
Oleksandr Tymoshenko
c38fb7809f INTRNG: Propagate IRQ activation error to API consumer
Keep resource state consistent with INTRNG state - if intr_activate_irq
fails - deactivate resource and propagate error to calling function

Reviewed by:	mmel
2016-10-12 17:10:59 +00:00
Jonathan T. Looney
bd79708dbf In the TCP stack, the hhook(9) framework provides hooks for kernel modules
to add actions that run when a TCP frame is sent or received on a TCP
session in the ESTABLISHED state. In the base tree, this functionality is
only used for the h_ertt module, which is used by the cc_cdg, cc_chd, cc_hd,
and cc_vegas congestion control modules.

Presently, we incur overhead to check for hooks each time a TCP frame is
sent or received on an ESTABLISHED TCP session.

This change adds a new compile-time option (TCP_HHOOK) to determine whether
to include the hhook(9) framework for TCP. To retain backwards
compatibility, I added the TCP_HHOOK option to every configuration file that
already defined "options INET". (Therefore, this patch introduces no
functional change. In order to see a functional difference, you need to
compile a custom kernel without the TCP_HHOOK option.) This change will
allow users to easily exclude this functionality from their kernel, should
they wish to do so.

Note that any users who use a custom kernel configuration and use one of the
congestion control modules listed above will need to add the TCP_HHOOK
option to their kernel configuration.

Reviewed by:	rrs, lstewart, hiren (previous version), sjg (makefiles only)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D8185
2016-10-12 02:16:42 +00:00
Warner Losh
943ac2b07e Include stubs even on the platforms we don't support so libsysdecode
continues to build.
2016-10-11 22:54:29 +00:00
Adrian Chadd
ce4333da79 [ar531x] add default configs for AR531x ports.
Submitted by:	Mori Hiroki <yamori813@yahoo.co.jp>
Differential Revision:	https://reviews.freebsd.org/D7237
2016-10-06 20:37:23 +00:00
Adrian Chadd
7c12b677f5 [ar531x] add initial port for the AR231x/531x series of SoCs.
These are older MIPS4kc parts from Atheros.  They typically ran at
sub-200MHz and have 11bg, 11a, or 11abg wifi MAC/PHYs integrated.

This port is the initial non-wifi pieces required to bring up the
chip.  I'll commit the redboot and other pieces later, and then
hopefully(!) wifi support will follow.

Submitted by:   Mori Hiroki <yamori813@yahoo.co.jp>
Differential Revision:  https://reviews.freebsd.org/D7237
2016-10-04 16:27:36 +00:00
Ruslan Bukin
3af5cc2e50 Use SIGSEGV signal for memory protection failures from userspace on MIPS.
(same as ARMv8, RISC-V and other architectures do).
This makes mmap tests happy.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-28 14:13:41 +00:00
Ruslan Bukin
2d1c384470 Fill all the siginfo so we have si_value set as well.
This fixes timer_create(2) tests.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-28 12:23:46 +00:00
Ruslan Bukin
617a841d4a Set the standard freebsd brand note for ELF binaries on MIPS,
so binaries now get correct osreldate.

Reviewed by:	jhb
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D7899
2016-09-22 12:48:01 +00:00
Landon J. Fuller
f75615f26f Split bcm_mipscore.c into bcm_bmips (BMIPS32/BMIPS3300) and bcm_mips74k
drivers.

The BMIPS32/BMIPS3300 cores use a register layout distinct from the MIPS74K
core, and are only found on siba(4) devices.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7791
2016-09-18 21:28:09 +00:00
Brooks Davis
79816bbe94 The TLS offset is a property of the process ABI.
Move to a per-proc TLS offset rather than incorrectly keying off the
presense of freebsd32 compability in the kernel.

Reviewed by:	adrian, sbruno
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D7843
2016-09-15 17:25:52 +00:00
Ruslan Bukin
693b6aeede Add SMP support for MTI Malta 34kf CPU.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-12 16:38:51 +00:00
Ruslan Bukin
930b6b4dce Add support for SMP on MIPS Malta platform.
Tested in QEMU on Malta32, Malta64.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-09-09 14:50:44 +00:00
Ruslan Bukin
84aec472fc Allow the use of soft-interrupts for sending IPIs.
This will be required for SMP support on MIPS Malta platform.

Reviewed by:	adrian
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D7835
2016-09-08 17:37:13 +00:00
Stanislav Galabov
2b99b9f3d2 Fix MIPS INTRNG (both FDT and non-FDT) behaviour broken by r304459
More changes to MIPS may be required, as commented in D7692, but this
revision aims to restore MIPS INTRNG functionality so we can move on
with working interrupts.

Reported by:	yamori813@yahoo.co.jp
Tested by:	mizhka (on BCM), sgalabov (on Mediatek)
Reviewed by:	adrian, nwhitehorn (older version)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D7692
2016-09-07 09:31:10 +00:00
Michael Zhilin
29d492ace1 [BHND/USB] Port of EHCI/OHCI support from ZRouter
This patch adds driver implementation for BHND USB core. Driver has been
imported from ZRouter project with small adaptions for FreeBSD 11.

Also it's enabled for BroadCom MIPS74k boards by default. It's fully tested
on Asus boards (RT-N16: external USB, RT-N53: USB bus between SoC and WiFi
chips).

Reviewed by:    adrian (mentor), ray
Approved by:	adrian (mentor)
Obtained from:	ZRouter
Differential Revision:  https://reviews.freebsd.org/D7781
2016-09-05 16:06:52 +00:00
Landon J. Fuller
111d7cb2e3 Migrate bhndb(4) to the new bhnd_erom API.
Adds support for probing and initializing bhndb(4) bridge state using
the bhnd_erom API, ensuring that full bridge configuration is available
*prior* to actually attaching and enumerating the bhnd(4) child device,
allowing us to safely allocate bus-level agent/device resources during
bhnd(4) bus enumeration.

- Add a bhnd_erom_probe() method usable by bhndb(4). This is an analogue
  to the existing bhnd_erom_probe_static() method, and allows the bhndb
  bridge to discover the best available erom parser class prior to newbus
  probing of its children.
- Add support for supplying identification hints when probing erom
  devices. This is required on early EXTIF-only chipsets, where chip
  identification registers are not available.
- Migrate bhndb over to the new bhnd_erom API, using bhnd_core_info
  records rather than bridged bhnd(4) device_t references to determine
  the bridged chipsets' capability/bridge configuration.
- The bhndb parent (e.g. if_bwn) is now required to supply a hardware
  priority table to the bridge. The default table is currently sufficient
  for our supported devices.
- Drop the two-pass attach approach we used for compatibility with bhndb(4) in
  the bhnd(4) bus drivers, and instead perform bus enumeration immediately,
  and allocate bridged per-child bus-level resources during that enumeration.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7768
2016-09-04 00:58:19 +00:00
Landon J. Fuller
664a749708 Implement a generic bhnd(4) device enumeration table API.
This defines a new bhnd_erom_if API, providing a common interface to device
enumeration on siba(4) and bcma(4) devices, for use both in the bhndb bridge
and SoC early boot contexts, and migrates mips/broadcom over to the new API.

This also replaces the previous adhoc device enumeration support implemented
for mips/broadcom.

Migration of bhndb to the new API will be implemented in a follow-up commit.


- Defined new bhnd_erom_if interface for bhnd(4) device enumeration, along
  with bcma(4) and siba(4)-specific implementations.
- Fixed a minor bug in bhndb that logged an error when we attempted to map the
  full siba(4) bus space (18000000-17FFFFFF) in the siba EROM parser.
- Reverted use of the resource's start address as the ChipCommon enum_addr in
  bhnd_read_chipid(). When called from bhndb, this address is found within the
  host address space, resulting in an invalid bridged enum_addr.
- Added support for falling back on standard bus_activate_resource() in
  bhnd_bus_generic_activate_resource(), enabling allocation of the bhnd_erom's
  bhnd_resource directly from a nexus-attached bhnd(4) device.
- Removed BHND_BUS_GET_CORE_TABLE(); it has been replaced by the erom API.
- Added support for statically initializing bhnd_erom instances, for use prior
  to malloc availability. The statically allocated buffer size is verified both
  at runtime, and via a compile-time assertion (see BHND_EROM_STATIC_BYTES).
- bhnd_erom classes are registered within a module via a linker set, allowing
  mips/broadcom to probe available EROM parser instances without creating a
  strong reference to bcma/siba-specific symbols.
- Migrated mips/broadcom to bhnd_erom_if, replacing the previous MIPS-specific
  device enumeration implementation.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7748
2016-09-03 23:57:17 +00:00
Mark Johnston
dbbaf04f1e Remove support for idle page zeroing.
Idle page zeroing has been disabled by default on all architectures since
r170816 and has some bugs that make it seemingly unusable. Specifically,
the idle-priority pagezero thread exacerbates contention for the free page
lock, and yields the CPU without releasing it in non-preemptive kernels. The
pagezero thread also does not behave correctly when superpage reservations
are enabled: its target is a function of v_free_count, which includes
reserved-but-free pages, but it is only able to zero pages belonging to the
physical memory allocator.

Reviewed by:	alc, imp, kib
Differential Revision:	https://reviews.freebsd.org/D7714
2016-09-03 20:38:13 +00:00
Adrian Chadd
c401c72b48 [mips] move AR91XX_BASE to std.AR91XX. 2016-08-28 04:10:23 +00:00
Adrian Chadd
c3f27beebb [mips] migrate the QCA955X_BASE file to std.QCA955X, to bring this in line with
other board defaults.
2016-08-28 04:08:26 +00:00
Adrian Chadd
473a0e619a Use ALT_BREAK_TO_DEBUGGER as well. 2016-08-28 04:08:04 +00:00
Adrian Chadd
5554db5d6e .. and since others are using wdr3600/wdr4300 right now and are having
arge issues with spammed interrupts / link issues, flip on ARGE_DEBUG too.
2016-08-28 04:07:34 +00:00
Adrian Chadd
974351045b Since i'm using carambola 2 for more debugging, enable ARGE_DEBUG by default. 2016-08-28 04:06:57 +00:00
Adrian Chadd
9a0e8f3cec [mips] make AR933X boards use ALT_BREAK_TO_DEBUGGER like the rest of the Atheros boards. 2016-08-28 04:06:36 +00:00
Adrian Chadd
054da15ecc [mips] QCA955x config file changes to bring things into alignment with the other atheros config files.
* ALT_BREAK_TO_DEBUGGER, because we get random breaks when unplugging USB
  to serial adapters
* Build more modules!
2016-08-28 04:03:52 +00:00
Landon J. Fuller
eb175e8bfb [mips/broadcom]: Replace static frequency table with generic PMU clock
handling.


- Extended PWRCTL/PMU APIs to support querying clock frequency during very
  early boot, prior to bus attach.
- Implement generic PMU-based calculation of UART rclk values.
- Replaced use of static frequency tables (bcm_socinfo) with
  runtime-determined values.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7552
2016-08-27 00:06:20 +00:00
Landon J. Fuller
f90f4b6532 bhnd(4): Initial PMU/PWRCTL power and clock management support.
- Added bhnd_pmu driver implementations for PMU and PWRCTL chipsets,
  derived from Broadcom's ISC-licensed HND code.
- Added bhnd bus-level support for routing per-core clock and resource
  power requests to the PMU device.
- Lift ChipCommon support out into the bhnd module, dropping
  bhnd_chipc.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7492
2016-08-27 00:03:02 +00:00
Landon J. Fuller
cb4abe62ba [mips/broadcom] Generic platform_reset() support.
This adds support for performing platform_reset() on all supported
devices, using early boot enumeration of chipc capabilities and
available cores.


- Added Broadcom-specific MIPS CP0 register definitions used by
  BCM4785-specific reset handling.
- Added a bcm_platform structure for tracking chipc/pmu/cfe platform
  data.
- Extended the BCMA EROM API to support early boot lookup of core info
  (including port/region mappings).
- Extended platform_reset() to support PMU, PMU+AOB, and non-PMU
  devices.

Reviewed by:	mizhka
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7539
2016-08-26 20:16:02 +00:00
Adrian Chadd
1a71a7f2a4 [mips] add support for the "creative" GNU extensions and IRIX hilarity around MIPS LO16/HI16 relocations.
This was .. an interesting headache.

There are two halves:

* The earlier IRIX stuff (yes, early) occasionally would do dead
  code removal and generate multiple consecutive LO16 entries.
  If this is done for REL entries then it's fine - there's no
  state kept between them.  But gcc 5.x seems to do this for
  RELA entries.

eg:

HI1 LO1 HI2 LO2 LO3 HI4 LO4

.. in this instance, LO2 should affect HI2, but LO3 doesn't at all
affect anything.  The matching HI3 was in code that was deleted
as "dead code".

Then, the next one:

* A "GCC extension" allows for multiple HI entries before a LO entry;
  and all of those HI entries use the first LO entry as their basis
  for RELA offset calculations.

It does this so GCC can also do dead code deletion without necessarily
having to geneate fake relocation entries for balanced HI/LO RELA
entries.

eg:

HI1 LO1 HI2 HI3 HI4 LO4 LO5 HI6 LO6 LO7

in this instance, HI{2,3,4} are the same relocation as LO4 (eg .bss)
and need to be buffered until LO4 - then the RELA offset is applied
from LO4 to HI{2,3,4} calculations.

/And/, the AHL from HI4 is used during the LO4 relocation calculation,
just like in the normal (ie, before this commit) implementation.

Then, LO5 doesn't trigger anything - the HI "buffer" is empty,
so there are no HI relocations to flush out.

HI6/LO6 are normal, and LO7 doesn't trigger any HI updates.

Tested:

* AR9344 SoC, kernel modules, using gcc-5.3 (mips-gcc-5.3.0 package)

Notes:

* Yes, I do feel dirty having written this code.

Reviewed by:	imp (after a handful of "this should be on fire" moments wrt gcc and this code)
2016-08-21 00:48:41 +00:00
Michal Meloun
895c8b1c39 INTRNG: Rework handling with resources. Partially revert r301453.
- Read interrupt properties at bus enumeration time and store
   it into global mapping table.
 - At bus_activate_resource() time, given mapping entry is resolved and
   connected to real interrupt source. A copy of mapping entry is attached
   to given resource.
 - At bus_setup_intr() time, mapping entry stored in resource is used
   for delivery of requested interrupt configuration.
 - For MSI/MSIX interrupts, mapping entry is created within
   pci_alloc_msi()/pci_alloc_msix() call.
 - For legacy PCI interrupts, mapping entry must be created within
   pcib_route_interrupt() by pcib driver itself.

Reviewed by: nwhitehorn, andrew
Differential Revision: https://reviews.freebsd.org/D7493
2016-08-19 10:52:39 +00:00
Landon J. Fuller
e15461c7e9 mips/broadcom: Implement CFE-based EARLY_PRINTF support.
This adds support for EARLY_PRINTF via the CFE console; the aim is to
provide a fix for the otherwise cyclic dependency between PMU discovery
and console printf/DELAY:

- We need to parse the bhnd(4) core table to determine the address (and
  type) of the PMU/PLL registers and calculate the CPU clock frequency.
- The core table parsing code will emit a printf() if a parse error is
  hit.
- Safely calling printf() without EARLY_PRINTF requires a working
  DELAY+cninit, which means we need the PMU.

Errors in core table parsing shouldn't happen, but lack of EARLY_PRINTF
makes debugging more difficult.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7498
2016-08-17 20:24:14 +00:00
Landon J. Fuller
1728aef23d bhnd(4): Implement NVRAM support required for PMU bring-up.
- Added a generic bhnd_nvram_parser API, with support for the TLV format
  used on WGT634U devices, the standard BCM NVRAM format used on most
  modern devices, and the "board text file" format used on some hardware
  to supply external NVRAM data at runtime (e.g. via an EFI variable).

- Extended the bhnd_bus_if and bhnd_nvram_if interfaces to support both
  string-based and primitive data type variable access, required for
  common behavior across both SPROM and NVRAM data sources.
- Extended the existing SPROM implementation to support the new
  string-based NVRAM APIs.

- Added an abstract bhnd_nvram driver, implementing the bhnd_nvram_if
  atop the bhnd_nvram_parser API.
- Added a CFE-based bhnd_nvram driver to provide read-only access to
  NVRAM data on MIPS SoCs, pending implementation of a flash-aware
  bhnd_nvram driver.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D7489
2016-08-16 21:32:05 +00:00
Adrian Chadd
b0754a31cf [mips] fix use-before-initialised.
Found by: gcc-5.3
2016-08-16 07:51:05 +00:00
Jean-Sébastien Pédron
bd937497ea Consistently use device_t
Several files use the internal name of `struct device` instead of
`device_t` which is part of the public API. This patch changes all
`struct device *` to `device_t`.

The remaining occurrences of `struct device` are those referring to the
Linux or OpenBSD version of the structure, or the code is not built on
FreeBSD and it's unclear what to do.

Submitted by:	Matthew Macy <mmacy@nextbsd.org> (previous version)
Approved by:	emaste, jhibbits, sbruno
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D7447
2016-08-09 19:32:06 +00:00
Brooks Davis
df28d191fa Use a more conventional spelling of "breakpoint". 2016-08-07 09:02:54 +00:00
Adrian Chadd
b812fe4d6b [mips] add support for using the MIPS user register for TLS data.
This work, originally from Stacey Son, uses the MIPS UserReg for
reading the TLS data, and will fall back to the normal syscall path
when it isn't supported.

This code dynamically patches cpu_switch() to bypass the UserReg
instruction so to avoid generating a machine exception.

Thanks to sson for the original work, and to Dan Nelson for
bringing it to date and testing it on MIPS32 with me.

Tested:

* mips64 (sson)
* mips74k (dnelson_1901@yahoo.com) - AR9344 SoC, UserReg support
* mips24k (adrian) - AR9331 SoC, no UserReg support

Obtained from:	sson, dnelson_1901@yahoo.com
2016-08-07 01:29:55 +00:00
Adrian Chadd
921d7118e1 [ar934x] add tap/tun as modules, for people who wish to use VPNs. 2016-08-05 17:17:36 +00:00