Commit Graph

2140 Commits

Author SHA1 Message Date
kib
014daa8f25 MFC r275616:
Thread waiting for the vfork(2)-ed child to exec or exit, must allow
for the suspension.

MFC r275683 (by andreast):
Fix build for powerpc(32|64) kernels.

MFC r275686 (by andreast):
Fix kernel build for booke.

r275639 (by andrew) is not merged, since arm/arm/syscall.c is not
present on the stable/10 branch, and arm/arm/trap.c already includes
sys/kernel.h.
2014-12-15 10:46:07 +00:00
kib
e4b2ee7e2b Merge the fueword(9) and casueword(9). In particular,
MFC r273783:
Add fueword(9) and casueword(9) functions.
MFC note: ia64 is handled like arm, with NO_FUEWORD define.

MFC r273784:
Replace some calls to fuword() by fueword() with proper error checking.

MFC r273785:
Convert kern_umtx.c to use fueword() and casueword().
MFC note: the sys__umtx_lock and sys__umtx_unlock syscalls are not
converted, they are removed from HEAD, and not used.  The do_sem2*()
family is not yet merged to stable/10, corresponding chunk will be
merged after do_sem2* are committed.

MFC r273788 (by jkim):
Actually install casuword(9) to fix build.

MFC r273911:
Add type qualifier volatile to the base (userspace) address argument
of fuword(9) and suword(9).
2014-11-18 12:53:32 +00:00
hselasky
1f41d295fb MFC r263710, r273377, r273378, r273423 and r273455:
- De-vnet hash sizes and hash masks.
- Fix multiple issues related to arguments passed to SYSCTL macros.

Sponsored by:	Mellanox Technologies
2014-10-27 14:38:00 +00:00
ian
8526d66c63 MFC r272109, r272181:
Replace multiple nearly-identical copies of code to walk through an FDT
  node's interrupts=<...> property creating resource list entries with a
  single common implementation.  This change makes ofw_bus_intr_to_rl() the
  one true copy of that code and removes the copies of it from other places.

  This also adds handling of the interrupts-extended property.
2014-10-26 04:01:57 +00:00
ian
1c8cde378e MFC r270945:
Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().
2014-10-26 01:30:46 +00:00
dumbbell
4ed3581a36 vt(4): Merge several bug fixes and improvements
SVN revisions in this MFC:
  269779 270705 270706 271180 271250 271253 271682 271684

Detailed commit list:

r269779:
  fbd: Fix a bug where vt_fb_attach() success would be considered a failure

  vt_fb_attach() currently always returns 0, but it could return a code
  defined in errno.h. However, it doesn't return a CN_* code. So checking
  its return value against CN_DEAD (which is 0) is incorrect, and in this
  case, a success becomes a failure.

  The consequence was unimportant, because the caller (drm_fb_helper.c)
  would only log an error message in this case. The console would still
  work.

  Approved by:	nwhitehorn

r270705:
  vt(4): Add cngrab() and cnungrab() callbacks

  They are used when a panic occurs or when entering a DDB session for
  instance.

  cngrab() forces a vt-switch to the console window, no matter if the
  original window is another terminal or an X session. However, cnungrab()
  doesn't vt-switch back to the original window currently.

r270706:
  drm: Don't "taskqueue" vt-switch if under DDB/panic situation

  If DDB is active, we can't use a taskqueue thread to switch away from
  the X window, because this thread can't run.

  Reviewed by:	ray@
  Approved by:	ray@

r271180:
  vt_vga: vd_setpixel_t and vd_drawrect_t are noop in text mode

r271250:
  vt(4): Change the terminal and buffer sizes, even without a font

  This fixes a bug where scroll lock would not work for tty #0 when using
  vt_vga's textmode. The reason was that this window is created with a
  static 256x100 buffer, larger than the real size of 80x25.

  Now, in vt_change_font() and vt_compute_drawable_area(), we still
  perform operations even of the window has no font loaded (this is the
  case in textmode here vw->vw_font == NULL). One of these operation
  resizes the buffer accordingly.

  In vt_compute_drawable_area(), we take the terminal size as is (ie.
  80x25) for the drawable area.

  The font argument to vt_set_border() is removed (it was never used) and
  the code now uses the computed drawable area instead of re-doing its own
  calculation.

  Reported by:	Harald Schmalzbauer <h.schmalzbauer_omnilan.de>
  Tested by:	Harald Schmalzbauer <h.schmalzbauer_omnilan.de>

r271253:
  pause_sbt(): Take the cold path (ie. use DELAY()) if KDB is active

  This fixes a panic in the i915 driver when one uses debug.kdb.enter=1
  under vt(4).

  PR:		193269
  Reported by:	emaste@
  Submitted by:	avg@

r271682:
  vt(4): Fix a LOR which occurs during a call to vt_upgrade()

  Reported by:	kib@
  Review:		https://reviews.freebsd.org/D785
  Reviewed by:	ray@
  Approved by:	ray@

r271684:
  vt(4): Use vt_fb_drawrect() and vt_fb_setpixel() in all vt_fb-derivative

  Review:		https://reviews.freebsd.org/D789
  Reviewed by:	nwhitehorn
  Approved by:	nwhitehorn

Approved by:	re (gjb)
2014-09-18 14:38:18 +00:00
jhibbits
f971f9cd08 MFC r269701:
Set the si_code appropriately for exception-caused signals.

LLDB checks the si_code, and aborts if a code isn't known.

Approved by:	re (gjb)
Relnotes:	yes
2014-09-06 22:37:47 +00:00
jhibbits
021e2fad89 MFC r259657,r264205,r264207:
r259657:

Add suspend/resume capabilities to the ATI backlight ppc driver.

With this, also shut off the display (DPMS-style) and disable the
clocking when the backlight level is set to 0.  This is taken from the
radeonkms driver (radeon_legacy_encoders.c) which doesn't yet support
PowerPC.

r264205,r264207:

Fix the ATI backlight driver off/on handling.  Now this driver works
correctly with the ATI Radeon 9700 in the PowerBook G4 1.67GHz.

Code shamelessly taken in spirit from the radeonkms driver, which I
hope will make this driver redundant in the future.

Approved by:	re (marius)
Relnotes:	yes (not suspend/resume, but the rest)
2014-09-06 19:38:40 +00:00
jhibbits
7d1fd313b1 MFC r261095,r263464,r263752,r264189
r263464,r263752,r275189:

Mask out SRR1 bits that aren't exported to the MSR.

This appears to fix a strange condition with X on 32-bit PowerBooks I
observed, caused by one of these bits getting set in the mcontext, but
not set in the thread, which is a symptom of another problem, more
difficult to diagnose.  Since these bits aren't exported anyway, this
change makes it more explicit that the bits aren't MSR-related in SRR1.

r261095:

Fix 32-bit signal handling on ppc64.  This was broken when the
PSL_USERSTATIC macro was changed.  Since copying 64-bit srr1 into
32-bit srr1 drops the upper 32 bits, any bits set in the context were
dropped, meaning the context check fails.  Since 32-bit set_context()
can't change those bits anyway, copy the ones from the current context
(td->td_frame) before calling set_context().

Approved by:	re
Relnotes:	yes (Affects 10-stable, but not 10.0-release)
2014-09-05 15:13:41 +00:00
jhibbits
ddbdadae3d MFC r258078,258079
Increase the stack size for ppc64 from 4 pages to 8.

I found a stack overflow when a coredump was taken onto a ZFS volume with
heavy network activity.  2 DSI traps, plus one DECR trap, along with several
function calls in the stack, overflowed the 4 pages.  8 page stack fixes this.

Discussed with: nwhitehorn
Approved by:	re
Relnotes:	yes
2014-09-05 05:07:38 +00:00
emaste
1a3d3113bf MFC vt(4) improvements / sync with HEAD
These are largely dumbbell@'s changes.  Most significantly they address
the extreme performance degradation with VGA hardware.

SVN revisions in this MFC:
  269471 270290 270293 270322 270324 270329 270331 270336 270338 270340
  270341 270342 270343 270388 270390 270404 270411 270412 270413 270431
  270446 270448 270485 270587 270589 270613 270618 270620 270667 270702
  270707 270708 270720 270721 270785 270786

Detailed commit list:

r270290: Test if the cursor is shown only once

  Later, we just see if the "struct mouse_cursor" pointer is set. This
  avoids the need to mess with all the conditions several times; this
  has been error prone.

  While here, rename the variable "m" to a more meaningful "cursor",
  like it's done elsewhere in the code.

r270293: Rename the "mouse_cursor" structure to "vt_mouse_cursor"

  At the same time, "w" and "h" members are now called "width" and
  "height". The goal is to have a more "public" structure, because it
  will soon be passed as argument to a new callback, replacing
  vd_bitbltchr_t.

r269471 (ray):

  Fix vt_vga driver to draw not-8-bit-aligned fonts correctly.
  Still one bug here: mouse left some gaps on track when moving left.

r270322:

  Add new vd_bitblt_text_t callback, and implement it for vt_vga

  Compared to the deprecated vd_bitbltchr_t callback, vd_bitblt_text_t
  receives:
    o  the whole text buffer
    o  the dirty area
    o  the mouse cursor (map, position, colors)

  This allows the backend to perform optimization on how to draw things.
  The goal is to remove vd_bitbltchr_t and vd_putchar_t, once all driver
  are converted (only vt_vga is included in this commit).

  In vt_vga, this allows to draw the text and the cursor in one pass,
  without ever reading from video memory (because it has all the context).
  The main benefit is the speed improvement: no more slideshow during
  boot!

  Other bugs fixed in vt_vga are:
    o  left-most characters are drawn properly (the left-most pixels were
       missing with bold characters and some wide letters such as 'm')
    o  no more black square around the cursor
    o  no cursor flickering when the text is scrolling

  There are still many problems to fix: the known issues are marked with
  "FIXME" inside the code.

r270411:

  vt_fb: Implement vd_bitblt_text_t for vt_fb and derivatives

r270412:

  creator_fb: Implement vd_bitblt_text_t

r270413: ofwfb: Implement vd_bitblt_text_t

r270324: vt_vga: Clip the draw area to never draw offscreen

  This fixes a bug when two windows use different fonts, but a longer-
  term solution is required. The dirty area should be stored as pixels,
  not character cells, because such coordinates don't have the same
  meaning in all windows, when using different fonts.

r270329: Mark new mouse position as dirty only when it's actually displayed

r270331: Store cursor bitmap & colors in struct vt_device

  This removes the need to specify them to each call to vd_bitblt_text_t
  and, therefore, simplifies the API.

r270336: Give the window to vd_bitblt_text_t callback

  ... instead of both the buffer and the font. Again, this simplifies
  the API.

r270338: The offset to center the text area is per-window now

  The previous global offset, based on the last loaded font, had no
  meaning for other windows. This caused a shifted text area, often
  partly out-of-screen.

r270341:  vt_vga: Remove a "FIXME" comment; the issue was solved in r270338

r270340: Don't run vt_set_border() and vt_flush() concurrently

  In the case of vt_vga, the two concurrent calls were writing to the
  same VGA registers, causing incorrect refresh of the screen.

r270342: Use the actual size of the mouse when marking its position as dirty

  This fixes a bug where part of the cursor was not erased.

r270343: Remove "FIXME" about multiple locking of vt_buf in vt_flush()

  After some testing, it appears that acquiring the lock once and keeping
  it longer is slower than taking it multiple times.

  While here, fix a typo in another comment.

r270388: vt_vga: Give only the character part of term_char_t to vga_get_cp437()

  This fixes a bug where vga_get_cp437() was called with an invalid
  argument. The screen was then filled with '?' instead of the actual
  character.

r270390: Fix a crash in vt_mark_mouse_position_as_dirty() when in textmode

  In textmode, no font is loaded, thus the page fault in
  vt_mark_mouse_position_as_dirty() when it wants the font width/height.

  For now, create a fake area for the textmode. This needs to be
  modified if vt_vga gains mouse support in textmode.

  While here, fix a build failure when SC_NO_CUTPASTE is defined:
  vt_mark_mouse_position_as_dirty() must not be included in this case.

r270404: Fix cursor handling in vt_flush()

  There were situations where the cursor was not erased/redrawn or its
  position was marked as dirty even though it's not displayed. The code
  is now more straightforward.

  At the same, add a function to determine if the cursor covers a given
  area. This is used by backends to know if they need to draw the
  cursor.

  This new function should be paired with a new state in struct
  vt_device, called vd_mshown, which indicates if the cursor should be
  displayed.  This again simplifies vd_bitblt_text_t callback's API.

r270431: vt(4): Add vd_bitblt_bmp_t callback

  The code was already there in all backends, we just expose it. This is
  used to display the splash screen.

r270446: Remove vd_bitbltchr_t

  It's replaced by vd_bitblt_text_t, which gives more context to the
  backend and allows it to perform more efficiently when redrawing a
  given area.

r270448: Fix order of arguments (x <-> y) when showing the splash screen

r270485: vt_vga: Fix the display of the splash screen

r270587: Take font offset into account in vt_is_cursor_in_area()

  This fixes a "General protection fault" in vt_vga, where
  vt_is_cursor_in_area() erroneously reported that the cursor was over
  the text. This led to negative integers stored in "unsigned int" and
  chaos.

r270589: The cursor coordinates are relative to the drawn area

  ... not the whole screen. Don't use font offsets in
  vt_mark_mouse_position_as_dirty().

  This fixes a bug where the mouse position wasn't marked as dirty when
  approaching the borders of the drawn area.

r270613: Store a rectangle for the drawable area, not just the top-left corner

  This allows backends to verify they do not draw outside of this area.
  This fixes a bug in vt_vga where the text was happily drawn over the
  right and bottom margins, when using the Gallant font.

r270618: Intialize drawable area rectangle each time a font is loaded

  This also fixes a problem where early in boot, the area was zero,
  leading to nothing displayed for a few seconds.

r270620: vt_vga: Use Write Mode 0 to draw group of 8 pixels using 3 or more colors

  This replaces the method based on Write Mode 3, which required reads
  from the video memory to load the latches.

r270667: When creating a window buffer, fill it entirely

  ... not just the visible part.

  This fixes a bug where, when switching from eg. vt_vga to vt_fb (ie.
  the resolution goes up), the originally hidden, uninitialized area of
  the buffer is displayed on the screen. This leads to a missing text
  cursor when it's over an unitialized area.

  This was also visible when selecting text: the uninitialized area was
  not highlighted.

  Internally, this area was zeroed: characters were all 0x00000000,
  meaning the foreground and background color was black. Now, everything
  is filled with a space with a gray foreground color, like the visible
  area.

  While here, remove the check for the mute flag and always use
  TERMINAL_NORM_ATTR as the character attribute (ie. gray foreground,
  black background).

r270702: Implement basic support for KDSETMODE ioctl

  With the current implementation, this allows an X11 server to tell
  the console it switches a particular window in "graphics mode". This
  information is used by the mouse handling code to ignore sysmouse events
  in the window taken by the X server: only him should receive those
  events.

r270707: Pause the vt_flush() timer when the screen is up-to-date

  The timer is restarted whenever a window buffer is marked as dirty or
  the mouse cursor moves.

  There's still room for improvement. For instance, we should not mark a
  window buffer as dirty when this window isn't displayed.

r270708: vt(4): Recompute the drawable area when the resolution changes

  This was only done when the font changed.

r270720: vt(4): Fix mouse cursor handling in vt_fb/creator_vt/ofwfb

  There were two issues:
    1. The area given to vt_is_cursor_in_area() was adding the drawable
       area offset, something already handled by this function.
    2. The cursor was shifted on the screen by the offset of this area
       and thus was misplaced or not erased. Furthermore, when reaching
       the bottom or right borders, the cursor was either totally
       removed or not erased correctly.

r270721: vt(4): If the terminal shrinks, make sure the mouse is inside
   the new area

r270785: vt(4): Change vb_history_size from "int" to "unsigned int"

  CID:		1230002, 1230003

r270786: Indicate that KDSETRAD case falls through the next case

  CID:		1229953

Relnotes:	Yes
2014-09-04 20:18:08 +00:00
emaste
f4cd1af86e MFC r269685 (nwhitehorn): Retire vd_maskbitbltchr.
The same functionality can be obtained by testing for mask != NULL in
  vd_bitbltchr, which all implementations of vd_bitbltchr() were doing
  anyway.

Sponsored by:	The FreeBSD Foundation
2014-09-04 19:13:07 +00:00
emaste
d3502c5201 MFC fbd(4) and vt_fb disentanglement:
r268472 (ray):

  Should check fb_read method presence instead of double check for fb_write.

r269620 (nwhitehorn):

  Retire various intertwined bits of fbd(4) and vt_fb, in particular the
  pixel modification indirection. No actual drivers use it and those
  that might (e.g. creatorfb) use custom implementations of
  vd_bitbltchr().

Relnotes:	No
Sponsored by:	The FreeBSD Foundation
2014-09-04 18:43:40 +00:00
nwhitehorn
d02b558c93 MFC r265883,268898:
Repair bitrot in PS3 memory and interrupt allocation.
2014-09-04 18:28:30 +00:00
nwhitehorn
ff75003b88 MFC r268880:
Allow mappings of memory not previously direct-mapped by the kernel when
calling mmap on /dev/mem and add a handler for the possible userland
machine checks that may result. Remove some pointless and wrong copy/paste
that has been in here for a decade as well.

This results in a /dev/mem with identical semantics to the x86 version.
2014-09-04 18:24:47 +00:00
emaste
cc4c44cb58 MFC PS3 vt(4) console support
r265871 (nwhitehorn):

  Move the PS3 framebuffer console to use vt instead of syscons and
  adjust GENERIC64 for PowerPC to use vt with it.

  Much to my chagrin, PS3 support seems to have bitrotted somewhat since
  the last time I tried it. ehci panics on attach and interrupt handling
  seems to be faulty. This should be fixed soon...

r269783 (dumbbell):

  Fix two files forgotten in r269783 (vt_generate_cons_palette)

r268895 (nwhitehorn):

  Enable X11 via xf86-video-scfb on the Playstation 3. This commit made
  from an xterm running for the first time on said Playstation.

Approved by:	nwhitehorn
Relnotes:	yes
2014-09-04 18:15:36 +00:00
kib
798eea1614 Fix a leak of the wired pages when unwiring of the PROT_NONE-mapped
wired region.  Rework the handling of unwire to do the it in batch,
both at pmap and object level.

All commits below are by alc.

MFC r268327:
Introduce pmap_unwire().

MFC r268591:
Implement pmap_unwire() for powerpc.

MFC r268776:
Implement pmap_unwire() for arm.

MFC r268806:
pmap_unwire(9) man page.

MFC r269134:
When unwiring a region of an address space, do not assume that the
underlying physical pages are mapped by the pmap.  This fixes a leak
of the wired pages on the unwiring of the region mapped with no access
allowed.

MFC r269339:
In the implementation of the new function pmap_unwire(), the call to
MOEA64_PVO_TO_PTE() must be performed before any changes are made to the
PVO. Otherwise, MOEA64_PVO_TO_PTE() will panic.

MFC r269365:
Correct a long-standing problem in moea{,64}_pvo_enter() that was revealed
by the combination of r268591 and r269134: When we attempt to add the
wired attribute to an existing mapping, moea{,64}_pvo_enter() do nothing.
(They only set the wired attribute on newly created mappings.)

MFC r269433:
Handle wiring failures in vm_map_wire() with the new functions
pmap_unwire() and vm_object_unwire().
Retire vm_fault_{un,}wire(), since they are no longer used.

MFC r269438:
Rewrite a loop in vm_map_wire() so that gcc doesn't think that the variable
"rv" is uninitialized.

MFC r269485:
Retire pmap_change_wiring().

Reviewed by:	alc
2014-09-01 07:58:15 +00:00
kib
25782a7fab Merge the changes to pmap_enter(9) for sleep-less operation (requested
by flag).  The ia64 pmap.c changes are direct commit, since ia64 is
removed on head.

MFC r269368 (by alc):
Retire PVO_EXECUTABLE.

MFC r269728:
Change pmap_enter(9) interface to take flags parameter and superpage
mapping size (currently unused).

MFC r269759 (by alc):
Update the text of a KASSERT() to reflect the changes in r269728.

MFC r269822 (by alc):
Change {_,}pmap_allocpte() so that they look for the flag
PMAP_ENTER_NOSLEEP instead of M_NOWAIT/M_WAITOK when deciding whether
to sleep on page table page allocation.

MFC r270151 (by alc):
Replace KASSERT that no PV list locks are held with a conditional
unlock.

Reviewed by:	alc
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
2014-08-24 07:53:15 +00:00
markj
57990c0ba4 MFC r266826, r266827
Move some duplicated hook definitions from machine-dependent files to
kern_dtrace.c.
2014-08-09 14:05:01 +00:00
nwhitehorn
722f33f118 MFC r266778:
Repair nested signal handling on PowerPC. The signal trampoline code
was not allocating space for the parameter save area in the stack frame.
If the compiler chose to save the argument to the signal handler on the
stack, it would overwrite the first 32 bits of the sigaction struct with
it, corrupting it for a subsequent invocation.

PR:		powerpc/183040
2014-06-04 06:21:54 +00:00
nwhitehorn
bd6a1fd1cd MFC r265900:
Repair some races in IPI handling:
1. Make sure IPI mask is set before sending the IPI
2. Operate atomically on PS3 PIC outstanding interrupt list
3. Make sure IPIs are EOI'ed before, not after, processing. Without this,
   a second IPI could be sent partway through processing the first one,
   get erroneously acknowledge by the EOI to the first, and be lost. In
   particular in the case of smp_rendezvous(), this can be fatal.

In combination, this makes the PS3 boot SMP again. It probably also fixes
some latent bugs elsewhere.
2014-05-26 01:37:43 +00:00
jhibbits
e699c2d438 MFC r266116,r266136
A page mask size is 12-bits, not 11.
2014-05-22 05:20:21 +00:00
ian
4c5f4bdec5 MFC 263301
In kernel config files, it is supposed to be 'options<space><tab>' not
  'options<tab><tab>', per long standing (but recently not so strictly
  enforced) convention.
2014-05-17 17:34:37 +00:00
ian
ee5c0f266a MFC 261357, 261358, 261421:
Enable SCHED_ULE for ppc book-e.

  Add driver for the ADT7460/ADT7467 fan controller found in
  later PowerBooks and iBooks.
2014-05-17 17:18:35 +00:00
ian
3724a25461 MFC 263036, 263059: delete advertising clause in licenses, renumber. 2014-05-17 13:59:11 +00:00
ian
8e2dd9b5e3 MFC r257854 (discussed with alc@)
As of r257209, all architectures have defined
  VM_KMEM_SIZE_SCALE.  In other words, every architecture is now
  auto-sizing the kmem arena.  This revision changes kmeminit() so
  that the definition of VM_KMEM_SIZE_SCALE becomes mandatory and
  the definition of VM_KMEM_SIZE becomes optional.

  Replace or eliminate all existing definitions of VM_KMEM_SIZE.
  With auto-sizing enabled, VM_KMEM_SIZE effectively became an
  alternate spelling for VM_KMEM_SIZE_MIN on most architectures.
  Use VM_KMEM_SIZE_MIN for clarity.
2014-05-16 01:30:30 +00:00
ian
1e3130abad MFC r261423, r261424, r261516, r261513, r261562, r261563, r261564, r261565,
r261596, r261606

  Add the imx sdhci controller.

  Move Open Firmware device root on PowerPC, ARM, and MIPS systems to
  a sub-node of nexus (ofwbus) rather than direct attach under nexus. This
  fixes FDT on x86 and will make coexistence with ACPI on ARM systems easier.
  SPARC is unchanged.

  Add the missing ')' at end of sentence.  Reword it to use a more common idiom.

  Pass the kernel physical address to initarm through the boot param struct.

  Make functions only used in vfp.c static, and remove vfp_enable.

  Fix __syscall on armeb EABI. As it returns a 64-bit value it needs to
  place 32-bit data in r1, not r0. 64-bit data is already packed correctly.

  Use abp_physaddr for the physical address over KERNPHYSADDR. This helps us
  remove the need to load the kernel at a fixed address.

  Remove references to PHYSADDR where it's used only in debugging output.

  Dynamically generate the page table. This will allow us to detect the
  physical address we are loaded at to change the mapping.
2014-05-15 17:30:16 +00:00
ian
27f0a13f0a MFC r261351, r261352, r261355, r261396, r261397, r261398, r261403, r261404,
r261405

  Open Firmware interrupt specifiers can consist of arbitrary-length byte
  strings and include arbitrary information (IRQ line/domain/sense). When the
  ofw_bus_map_intr() API was introduced, it assumed that, as on most systems,
  these were either 1 cell, containing an interrupt line, or 2, containing
  a line number plus a sense code. It turns out a non-negligible number of
  ARM systems use 3 (or even 4!) cells for interrupts, so make this more
  general.

  Provide a simpler and more standards-compliant simplebus implementation to
  get the Routerboard 800 up and running with the vendor device tree. This
  does not implement some BERI-specific features (which hopefully won't be
  necessary soon), so move the old code to mips/beri, with a higher attach
  priority when built, until MIPS interrupt domain support is rearranged.

  Allow nesting of simplebuses.

  Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
  process "status" properties of OF nodes.

  Fix one remnant endian flaw in nexus.
2014-05-15 14:26:11 +00:00
ian
057c745287 MFC r257738, r259202, r258410, r260288, r260292, r260294, r260320, r260323,
r260326, r260327, r260331, r260333, r260340, r260371, r260372, r260373,
    r260374, r260375

  Add common bus_space tag definition shared for most supported ARMv6/v7 SoCs.
  Correct license statements to reflect the fact that these files were all
  derived from sys/arm/mv/bus_space.c.

  In pmap_unmapdev(), remember the size, and use that as an argument to
  kva_free(), or we'd end up always passing it a size of 0

  In pmap_mapdev(), first check whether a static mapping exists,

  Convert TI static device mapping to use the new arm_devmap_add_entry(),

  Use the common armv6 fdt_bus_tag defintion for tegra instead of a local copy.

  Eliminate use of fdt_immr_addr(), it's not needed for tegra

  Convert lpc from using fdt_immr style to arm_devmap_add_entry() to make
  static device mappings.

  Retire machine/fdt.h as a header used by MI code, as its function is now
  obsolete. This involves the following pieces:
  - Remove it entirely on PowerPC, where it is not used by MD code either
  - Remove all references to machine/fdt.h in non-architecture-specific code
    (aside from uart_cpu_fdt.c, shared by ARM and MIPS, and so is somewhat
    non-arch-specific).
  - Fix code relying on header pollution from machine/fdt.h includes
  - Legacy fdtbus.c (still used on x86 FDT systems) now passes resource
    requests to its parent (nexus). This allows x86 FDT devices to allocate
    both memory and IO requests and removes the last notionally MI use of
    fdtbus_bs_tag.
  - On those architectures that retain a machine/fdt.h, unused bits like
    FDT_MAP_IRQ and FDT_INTR_MAX have been removed.

  Add #include <machine/fdt.h> to a few files that used to get it via pollution

  Enable the mv cesa security/crypto device by providing the required property
  in the dts source, and adding the right devices to the kernel config.

  Remove dev/fdt/fdt_pci.c, which was code specific to Marvell ARM SoCs,
  related to setting up static device mappings.  Since it was only used by
  arm/mv/mv_pci.c, it's now just static functions within that file, plus
  one public function that gets called only from arm/mv/mv_machdep.c.

  Switch RPi to using arm_devmap_add_entry() to set up static device mapping.

  Allow 'no static device mappings' to potentially work.

  Don't try to find a static mapping before calling pmap_mapdev(), that logic
  is now part of pmap_mapdev() and doesn't need to be duplicated here.

 Switch a10 to using arm_devmap_add_entry() to set up static device mapping.
2014-05-14 19:18:58 +00:00
ian
1baea4807a MFC r258800, r258802, r258805, r258806, r258807, r258851, r258857,
r259199, r259484, r259513, r259514, r259516

  The kernel stack guard pages are only below the stack pointer, not above.

  Remove unnecessary double-setting of the thread's onfault state in
  copyinstr().

  Open Firmware mandates that certain cross-references, in particular those
  in /chosen, be ihandles. The ePAPR spec makes those cross-reference phandles,
  since FDT has no concept of ihandles. Have the OF FDT CI module interpret
  queries about ihandles as cross-reference phandles.

  Real OF systems have an ihandle under /chosen/stdout, not a phandle. Use
  the right type.

  Rearchitect platform memory map parsing to make it less
  Open Firmware-centric.

  Remove fdtbus_bs_tag definition, which is now obsolete. The remainder of
  this file is also slated for future demolition.

  Return the correct IEEE 1275 code for "nextprop".

  Use the common Open Firmware PCI interrupt routing code instead of the
  duplicate version in dev/fdt.

  Configure interrupt sense based on device tree information.

  Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
  internally instead of requiring the caller to allocate it.
2014-05-14 14:17:51 +00:00
ian
796f2c87ad MFC r258268, r258271, r258272, r258274, r258275, r258427, r258694, r258696,
r258697, r258757

  Do not assume a value for #address-cells when parsing the OF translations
  map. This allows the kernel to get farther with OpenBIOS on 64-bit CPUs.

  Actually look up #address-cells instead of assuming it is correlated with
  the Uninorth version number.

  #interrupt-cells belongs to the iparent, not the device parent.

  Add a sysctl to allow disabling resetting the OF syscons.

  For PCI<->PCI bridges, #address-cells may be 3.

  Make RTAS calls, which call setfault() to recover from machine checks,
  preserve any existing fault buffer.

  badaddr() is used only in the grackle PCI driver, so move its definition
  there. Clean up a spurious setfault() declaration as well.

  This [phyp_console] driver doesn't need the /options node, so don't check
  for it.

  Use the Open Firmware-based CPU frequency determination as a generic
  fallback if we can't measure CPU frequency. This is also useful on a
  variety of embedded systems using FDT.
2014-05-14 14:08:45 +00:00
ian
4a602a8957 MFC r258259, r258798, r259010
Unify handling of illegal instruction faults between AIM and Book-E.

  Make uart_cpu_powerpc work on both FDT and OFW systems.

  Fix debug printfs in FPU_EMU to compile on powerpc64 and enable it for
  powerpc64.
2014-05-14 04:57:55 +00:00
ian
9277bb1a2b MFC r258247, r258250, r258257
Remove a pointless #ifdef AIM. This is just PPC64 specific, including
  64-bit Book-E.

  Make single precision floating point arithmetic actually work

  Split the function of the PCB_FPU flags into two: PCB_FPU now indicates that
  the actual FPU is enabled, while PCB_FPREGS indicates that the FPU state
  structure in the PCB is valid.
2014-05-14 04:42:38 +00:00
ian
d168d59495 MFC r257995, r258244, r258246,
Rename the "bare" platform "mpc85xx"
 Also turn "bare" into a truly bare platform

 Move CCSR discovery into the platform module

 There is no reason Book-E needs to save XER and CTR on context switches.
2014-05-14 04:14:58 +00:00
ian
f7cf17218e MFC r258002, r258024, r258027, r258051, r258052, r258243, r258244, r258002,
r258024, r258027, r258051, r258052, r258243,

  Follow up r223485, which made AIM use the ABI thread pointer instead of
  PCPU fields for curthread, by doing the same to Book-E.

  Use the same implementation of copyinout.c for both AIM and Book-E.

  Actually add IOMMU domain to the list of known mappings.

  Following the approach with ACPI DMAR on x86, split IOMMU handling into
  a variant PCI bus instead of trying to shoehorn it into the PCI host bridge
  adapter.

  Make sure that TLB1 mappings are aligned correctly.
2014-05-14 03:09:37 +00:00
ian
14106897a1 MFC r257702, r257745, r257746, r257747, r257751, r257791, r257793,
r257794, r257795, r257992

  Teach nexus(4) about Open Firmware (e.g. FDT) on ARM and MIPS, retiring
  fdtbus in most cases.

  Make OF_nextprop() work correctly for FDT by using the libfdt
  fdt_next_property_offset() API.

  Do not panic if pmap_mincore() is called.

  An addendum: it is possible, though of questionable utility, for a node
  to have no properties at all.
  Add definition for the Atheros 8021 gigabit PHY.

  Consolidate Apple firmware hacks and improve them by switching on the
  presence of mac-io devices in the tree, which uniquely identifies Apple
  hardware.

  Allow OF_decode_addr() to also be able to map resources on big-endian
  devices.

  Make tsec work with the device tree present on the RB800.

  Be more flexible about which compatible strings to accept.  This brings up
  the PCI Express bus on the RB800 using the firmware device tree.

  Rename the "bare" platform "mpc85xx", which is what it actually is, and
  add actual platform probing based on PVR.
2014-05-14 01:53:20 +00:00
ian
ae2bbb5100 MFC r257334, r257336, r257337, r257338, r257341, r257342, r257343, r257370,
r257368, r257416

  Hints-only devices should return BUS_PROBE_NOWILDCARD from their probe
  methods.
2014-05-14 01:35:43 +00:00
ian
147aa314a7 MFC r257180, r257195, r257196, r257198, r257209, r257295
Add some extra sanity checking and checks to printf format specifiers.

 Try even harder to find a console before giving up.

 Make devices with registers into the KVA region work reliably.

 Turn on VM_KMEM_SIZE_SCALE on 32-bit as well as 64-bit PowerPC.

 Return NOKEY instead of 0 if there are no more key presses queued.
2014-05-14 01:16:05 +00:00
ian
2963fd0dfb MFC r257161, r257169, r257178, r257190, r257191
Add pmap_mapdev_attr() and pmap_kenter_attr() interfaces.

 Fix concurrency issues with TLB1 updates and make pmap_kextract() search
 TLB1 mappings as well

  Interrelated improvements to early boot mappings:
  - Remove explicit requirement that the SOC registers be found except as an
    optimization (although the MPC85XX LAW drivers still require they be found
    externally, which should change).
  - Remove magic CCSRBAR_VA value.
  - Allow bus_machdep.c's early-boot code to handle non 1:1 mappings and
    systems not in real-mode or global 1:1 maps in early boot.
  - Allow pmap_mapdev() on Book-E to reissue previous addresses if the
    area is already mapped. Additionally have it check all mappings, not
    just the CCSR area.

 Add some extra sanity checking and checks to printf format specifiers.

 Bump initial TLB size. The kernel is not necessarily less than 16 MB

 Handle (in a slightly ugly way) ePAPR-type loaders that just place a
 device tree into r3.
2014-05-14 00:51:26 +00:00
ian
8bff46167d MFC r257162, r257175
The old trap.h (then trap_aim.h) actually had trap ID codes for Book-E CPUs.
  Use it universally. Book-E traps may also need revisiting due to the
  introduction of fixed-offset traps and the deprecation of IVORs in POWER
  ISA 2.06, but that's very much an issue for another day.
2014-05-13 19:12:53 +00:00
ian
7efcec8976 MFC r257115, r257116, r257117
Remove dead and duplicated code.
2014-05-13 18:24:02 +00:00
ian
0c0ccc18b5 MFC r257093:
Be a little more suspicious of thermal sensors, which can have single
  crazy readings occasionally. One wild reading should not be enough to
  trigger a shutdown, so instead wait for several concerning readings in
  a row.
2014-05-13 18:08:15 +00:00
ian
399f183366 MFC r256994, r257016, r257055, r257059, r257060, r257075
Add two new interfaces to ofw_bus:
  - ofw_bus_map_intr()
    Maps an (iparent, IRQ) tuple to a system-global interrupt number in some
    platform dependent way. This is meant to be implemented as a replacement
    for [FDT_]MAP_IRQ() that is an MI interface that knows about the bus
    hierarchy.
  - ofw_bus_config_intr()
    Configures an interrupt (previously mapped) based on firmware sense flags.
    This replaces manual interpretation of the sense field in bus drivers and
    will, in a follow-up, allow that interpretation to be redirected to the PIC
    drivers where it belongs. This will eventually replace the tables in
    /sys/dev/fdt/fdt_ARCH.c

  The PowerPC/AIM code has been converted to use these globally, with an
  implementation in terms of MAP_IRQ() and powerpc_config_intr(), assuming
  OpenPIC, at the bus root in nexus(4). The ofw_bus_config_intr() will shortly
  be integrated into pic_if.m and bounced through nexus into the PIC tree.

  Factor out MI portions of the PowerPC nexus device into /sys/dev/ofw. The
  sparc64 driver will be modified to use this shortly.

  Allow PIC drivers to translate firmware sense codes for themselves. This
  is designed to replace the tables in dev/fdt/fdt_ARCH.c, but will not
  happen quite yet.

  Do not map IRQs twice. This fixes PowerPC/FDT systems with multiple PICs,
  which would try to treat the previously-mapped interrupts from
  fdt_decode_intr() as interrupt line numbers on the same parent PIC.

  Remove some of the code required for supporting ssm(4) on SPARC in favor
  of a more PowerPC/FDT-focused design. Whenever SPARC64 is integrated
  into this rework, this should be (trivially) revisited.
2014-05-13 18:06:26 +00:00
ian
41e4178a5b MFC r256973, r256974
If the device tree directly contains the timebase frequency, use it. This
 property is required by ePAPR, but maintain the fallback to bus-frequency
 for compatibility.  Allow 32 or 64 bits.
2014-05-13 18:00:41 +00:00
ian
4c1631c2b1 MFC r256932, r256938, r256966, r256953, r256967, r256969, r257015:
Add a new function (OF_getencprop()) that undoes the transformation applied
  by encode-int. Specifically, it takes a set of 32-bit cell values and
  changes them to host byte order. Most non-string instances of OF_getprop()
  should be using this function, which is a no-op on big-endian platforms.

  Use the new function all over the place.
2014-05-13 17:59:17 +00:00
ian
7353aa0b49 MFC r256901, r256914 (by nwhitehorn):
Catch up on 6 years of improvements in Open Firmware nexus devices by
  importing the sparc64 one. At least 90% of this code is MI and will be
  moved into /sys/dev/ofw at some point in the future.

  Ignore registers on devices where the reg property is malformed. Issue a
  warning if this happens under bootverbose. This prevents some
  strange-looking entries in dmesg for SMU devices on Apple G5 systems.
2014-05-13 17:18:48 +00:00
ian
42a63a26cf MFC r256870, r256898, r256899, r256900 (by nwhitehorn):
Standards-conformance and code deduplication:
  - Use bus reference phandles in place of FDT offsets as IRQ domain keys
  - Unify the identical macio/fdt/mambo OpenPIC drivers into one
  - Be more forgiving (following ePAPR) about what we need from the device
    tree to identify an OpenPIC
  - Correctly map all IRQs into an interrupt domain
  - Set IRQ_*_CONFORM for interrupts on an unknown PIC type instead of
    failing attachment for that device.

  Allow lots of interrupts (useful on multi-domain platforms) and do not
  set device_quiet() on all devices attached under nexus(4).
2014-05-13 17:12:07 +00:00
ian
3d20d204d8 MFC r256814, r256816, r256818, r256846, r256855, r256864 (by nwhitehorn):
- Handle 2GB of ram
 - Allow the OFW interrupt mapping code to work with PCI devices not
   enumerated by Open Firmware, as in the case of FDT.
 - Provide an interface for PCI bus drivers that need some of ofw_pci's
   metadata during attach.
 - Use standard ofw_bus helpers instead of reinventing the wheel.
 - Make hard-wired TLB allocations be at minimum one page.
2014-05-13 16:59:50 +00:00
ian
a7a560a760 MFC r256792, r256793, r256799 (by nwhitehorn): Unify AIM and booke code. 2014-05-13 16:50:10 +00:00
scottl
96be897ce1 Merge r264984
Retire smp_active.  It was racey and caused demonstrated problems with
the cpufreq code.  Replace its use with smp_started.  There's at least
one userland tool that still looks at the kern.smp.active sysctl, so
preserve it but point it to smp_started as well.

Obtained from:	Netflix, Inc.
2014-05-07 20:28:27 +00:00