Commit Graph

1192 Commits

Author SHA1 Message Date
Scott Long
5974e5c71c Refactor the bus_dma header files so that the interface is described in
sys/bus_dma.h instead of being copied in every single arch.  This slightly
reorders a flag that was specific to AXP and thus changes the ABI there.
The interface still relies on bus_space definitions found in <machine/bus.h>
so it cannot be included on its own yet, but that will be fixed at a later
date.  Add an MD <machine/bus_dma.h> for ever arch for consistency and to
allow for future MD augmentation of the API.  sparc64 makes heavy use of
this right now due to its different bus_dma implemenation.
2005-03-14 16:46:28 +00:00
Alan Cox
fe4fbe5515 Declare as volatile the memory location referenced by a pointer rather than
the pointer's value.
2005-03-06 20:57:08 +00:00
Marius Strobl
c90ff9ce5a - sparc64/fhc/fhc.c:
Change fhc(4) to use IRQ numbers instead of RIDs for allocating the
  IRQs of children. This works similar to e.g. sbus(4), i.e. add the
  IRQ resources as fully specified to the resource lists of the children,
  allocate them like normal. When establishing the interrupt search the
  interrupt maps of the children for a matching INO to determine which
  map we need to write the fully specified interrupt number to and to
  enable the mapping (before the RID was used to indicate which interrupt
  map to use).

- dev/puc/puc.c:
  Revert rev. 1.38, with the above change fhc(4) no longer needs special
  treatment for allocating IRQs.

Thanks to:	joerg for providing access to an E3500
2005-03-04 22:23:21 +00:00
Marius Strobl
98c4649792 Let central(4) manage the resources of its children so they don't need
to fiddle with OFW themselves.

Thanks to:	joerg for providing access to an E3500
2005-03-04 22:21:11 +00:00
Joerg Wunsch
85a4207bf1 Addendum to netchild's C compiler abstraction mega-patch which somehow
have been forgotten in my previous commit.

Submitted by:	netchild
2005-03-04 21:26:07 +00:00
Marius Strobl
8e1ff29d07 Minor changes:
- Use FBSDID.
- Remove unused macro.
- Use auto-generated typedefs for the prototypes of the bus and device
  interface functions.
- Terminate the output of device_printf(9) with a newline char.
- Honour the return values of malloc(), OF_getprop(), etc.
- Use __func__ instead of hardcoded function names.
- Print the physical slot number and the board model on attach.

MFC after:	1 month
2005-03-04 16:01:57 +00:00
Marius Strobl
30e5ca5340 Minor changes:
- Use FBSDID.
- Remove an unused include.
- Use auto-generated typedefs for the prototypes of the device interface
  functions.
- Terminate the output of device_printf(9) with a newline char.
- Honour the return value of malloc(3).

MFC after:	1 month
2005-03-04 15:17:05 +00:00
Marius Strobl
52a1e57048 Remove the transition aid for the change of the sparc64 default system
call vector which was added in rev. 1.52. This change was done way before
sparc64 switched to a 64-bit time_t so all binaries are expected to have
been recompiled by now.
2005-03-03 01:26:40 +00:00
Marius Strobl
aa01bce81a Remove COMPAT_FREEBSD4 again. It was added in rev. 1.41 as a transition
aid for ABI breakages caused by system call changes. These changes were
done way before sparc64 switched to a 64-bit time_t so all binaries are
expected to have been recompiled by now.
2005-03-03 01:25:33 +00:00
Joerg Wunsch
a5f50ef9e4 netchild's mega-patch to isolate compiler dependencies into a central
place.

This moves the dependency on GCC's and other compiler's features into
the central sys/cdefs.h file, while the individual source files can
then refer to #ifdef __COMPILER_FEATURE_FOO where they by now used to
refer to #if __GNUC__ > 3.1415 && __BARC__ <= 42.

By now, GCC and ICC (the Intel compiler) have been actively tested on
IA32 platforms by netchild.  Extension to other compilers is supposed
to be possible, of course.

Submitted by:	netchild
Reviewed by:	various developers on arch@, some time ago
2005-03-02 21:33:29 +00:00
Marius Strobl
559bf8bc95 - Allow multiple INTR_FAST handlers for the same source. The motivation
for this are the on-board SCCs and UARTs that use a shared IRQ. [1]
- Rework the interrupt counting code to account for shared interrupts. [1]
- In case ithread_add_handler() failed in inthand_add() just return with
  the error code instead of setting up a non-fast handler regardless or
  setting up a non-fast handler instead of a fast handler. I can't think
  of a situation where the former behaviour would do the right thing.

Reviewed by:	marcel [1]
Based on:	sys/i386/i386/intr_machdep.c [1]
2005-03-02 11:27:13 +00:00
Marius Strobl
50f68ecad0 Assorted style fixes and minor changes:
- Use FBSDID.
- Use uintXX_t instead of u_intXX_t.
- Be consistent with white-space.
- Mark some globals as static.
- Add a missing prototype.
- Remove a unused variable.
- etc.
2005-03-02 10:55:56 +00:00
Wes Peters
95e2054492 Attempt to doff the pointy hat: implement 'hw.realmem' on remaining
architectures.  Pointed out by O'Brien, ScottL via email.

Reviewed by:	obrien (various)
2005-03-01 21:55:27 +00:00
Alan Cox
10891191fd Use the kernel pmap's lock to guarantee that only one thread at a time is
using either pmap_temp_map_1 or pmap_temp_map_2.

Tested by: kris@
2005-03-01 05:06:52 +00:00
Marius Strobl
d74b306146 The zs(4) driver is superseded by uart(4) and broken in -CURRENT. Remove
it from the sparc64 kernel config files and delete its fhc(4) and sbus(4)
front-end.

Agreed with:	marcel
2005-02-27 15:23:58 +00:00
Marius Strobl
7b50d90fde Silence witness warnings about duplicate pmap lock emitted since
rev. 1.145 of sys/sparc64/sparc64/pmap.c.

Submitted by:	alc
2005-02-18 15:37:34 +00:00
Marius Strobl
eab1708c9e UltraSparc II[e,i] based systems come up with the tick compare register
loaded, the tick interrupt enabled and a handler that resets the tick
counter on every tick interrupt. While this isn't documented this can
cause DELAY() to wait for a value the tick counter will not reach when
used in early boot, i.e. before cpu_initclocks() is called, depending
on when in the cycle DELAY() is called, the delay value and the value
the tick compare register is set to. The excessive use of DELAY() in
uart(4) when probing Sun keyboards seems to always manage to trigger
this, resulting in a hang during boot.
Disable the tick interrupt in tick_init(), which is called early in
sparc64_init(), until the interrupt is enabled again in tick_start(),
called by cpu_initclocks(), with our own handler. This fixes the hang
during probing Sun keyboards on AXi boards and Ultra 10, with other
machines like Ultra 5 probably being affected but not tested.

Additional testing by:	Matthias Muthmann
MFC after:		1 week
2005-02-17 00:13:49 +00:00
Marius Strobl
2b2250b149 - Re-write OF_decode_addr() with a bus-neutral approach, adding support
for nodes hanging off of Central (untested), FireHose (untested) and
  PCI (tested) busses.
- Add an additional parameter to OF_decode_addr() which specifies the
  index of the register bank to decode.

These should allow to eventually add support for the Z8530 hanging off of
FireHose to uart(4) and to write support for PCI-based graphics adapters.

Suggested by:	tmm (back in '03)
2005-02-12 19:13:51 +00:00
Alan Cox
b85a2011c1 Add lock assertion.
Tested by: jhb
2005-02-12 03:48:54 +00:00
Poul-Henning Kamp
0c3c54da63 Since we are quite unlikely to ever face another platform which
uses the i8237 without trying to emulate the PC architecture move
the register definitions for the i8237 chip into the central include
file for the chip, except for the PC98 case which is magic.

Add new isa_dmatc() function which tells us as cheaply as possible
if the terminal count has been reached for a given channel.
2005-02-06 13:46:39 +00:00
Nate Lawson
3888a87205 Finish the job of sorting all includes and fix the build by including
malloc.h before proc.h on sparc64.  Noticed by das@

Compiled on:	alpha, amd64, i386, pc98, sparc64
2005-02-06 01:55:08 +00:00
Alan Cox
ab42aa145d Acquire the source pmap's lock in pmap_copy(). 2005-02-05 22:06:47 +00:00
Nate Lawson
a287c0ffaf Sort includes a little so that bus.h comes before cpu.h (for device_t). 2005-02-04 06:58:09 +00:00
Nate Lawson
4c4381e288 Add an implementation of cpu_est_clockrate(9). This function estimates the
current clock frequency for the given CPU id in units of Hz.
2005-02-04 05:32:56 +00:00
Scott Long
bad60c0db6 Yikes! Fix a typo in a function name that managed to occur twice.
Submitted by: yongari
2005-01-31 07:28:04 +00:00
Marcel Moolenaar
d3477e8f82 o Enable puc(4) and uart(4).
o  Disable ofw_console(4), sab(4) and zs(4).

sab(4) and zs(4) are disabled because the hardware controlled by
them is handled by uart(4)+puc(4) and the latter combination is
functionally complete and up to date.

ofw_console(4) is disabled because it doesn't claim the device it
controls (through OFW) and thus interferes with puc(4)+uart(4),
which has sufficient knowledge to extract the necessary information
from OFW to setup the console. Put differently, ofw_console(4) is
not a proper device driver and can only do harm. Its functionality
is completely handled by uart(4).

This commit makes uart(4) the default driver for serial ports.

MFC after: 2 weeks
2005-01-30 09:27:49 +00:00
Ruslan Ermilov
3e17be06d6 Hopefully unbreak modules build. 2005-01-29 21:43:34 +00:00
Marius Strobl
606de9ed4d At least on some U30 there's a spurious duplicate device node of an EBus
bridge in the device tree which lacks the mandatory (also by the OFW PCI
bus binding spec) "reg" property. Change the code to just ignore nodes
missing the "reg" property instead of panicing when encountering such a
node. Also ignore nodes without a "name" property (guaranteed by the OFW
PCI bus binding spec). This brings the behaviour of the MD OFW PCI code
regarding such incomplete nodes in line with the EBus and the SBus code.

Tested by:	Cyril Tikhomiroff <tikho@anor.net>
MFC after:	1 month
2005-01-20 13:29:31 +00:00
John Baldwin
7d9ace1d46 Add a small API to manage the MD user trap structures. Specifically, we
now use a pool mutex to manage the reference counts.  This fixes races
resulting in use-after-free.

Tested by:	kris, David Cornejo dave at dogwood dot com
Reported by:	bmilekic's MemGuard
MFC after:	1 week
2005-01-19 18:24:07 +00:00
Scott Long
cfe08ee602 Add the bus_dmamap_load_mbuf_sg() function to sparc64. 2005-01-15 09:20:47 +00:00
Ruslan Ermilov
da089c0f51 Fixed sparc64 LINT build. 2005-01-14 13:16:13 +00:00
Marcel Moolenaar
ce05a617a9 Don't panic when we're asked to allocate a resource type that we know
won't exist for EBus. Just fail the allocation by returning NULL.
Now drivers that are MI can try resources that the driver knows may
be used by the device.
2005-01-09 18:58:08 +00:00
Warner Losh
60727d8b86 /* -> /*- for license, minor formatting changes 2005-01-07 02:29:27 +00:00
John Baldwin
944039bc08 Minor sync to alpha and i386:
- Add ADAPTIVE_GIANT and AHC_REG_PRETTY_PRINT.
- Indent SMP to match other options.
2004-12-30 18:31:53 +00:00
Scott Long
c628825b30 Identify USIIIi processors.
Submitted by: Gavin Atkinson
PR: 75468
2004-12-24 16:21:46 +00:00
Alan Cox
1f70d62298 Modify pmap_enter_quick() so that it expects the page queues to be locked
on entry and it assumes the responsibility for releasing the page queues
lock if it must sleep.

Remove a bogus comment from pmap_enter_quick().

Using the first change, modify vm_map_pmap_enter() so that the page queues
lock is acquired and released once, rather than each time that a page
is mapped.
2004-12-23 20:16:11 +00:00
Alan Cox
85f5b24573 In the common case, pmap_enter_quick() completes without sleeping.
In such cases, the busying of the page and the unlocking of the
containing object by vm_map_pmap_enter() and vm_fault_prefault() is
unnecessary overhead.  To eliminate this overhead, this change
modifies pmap_enter_quick() so that it expects the object to be locked
on entry and it assumes the responsibility for busying the page and
unlocking the object if it must sleep.  Note: alpha, amd64, i386 and
ia64 are the only implementations optimized by this change; arm,
powerpc, and sparc64 still conservatively busy the page and unlock the
object within every pmap_enter_quick() call.

Additionally, this change is the first case where we synchronize
access to the page's PG_BUSY flag and busy field using the containing
object's lock rather than the global page queues lock.  (Modifications
to the page's PG_BUSY flag and busy field have asserted both locks for
several weeks, enabling an incremental transition.)
2004-12-15 19:55:05 +00:00
Alan Cox
5031dd39f0 Pass VM_ALLOC_NOBUSY to vm_page_grab() so that we don't have to call
vm_page_flag_clear(PG_BUSY).  The object lock is held the entire time.
Thus, whether or not the PG_BUSY flag is set is invisible to others.
2004-12-11 22:35:16 +00:00
Warner Losh
993fd0c509 PNP BIOS devices are fundamentally different than ISA PNP devices.
These devices should be probed first because they are at fixed
locations and cannot be turned off.  ISA PNP devices, on the other
hand, can be turned off and often can be flexible in the resources
they use.  Probe them last, as always.
2004-12-07 05:30:02 +00:00
Marcel Moolenaar
bcc5241c43 Change gdb_cpu_setreg() to not take the value to which to set the
specified register, but a pointer to the in-memory representation of
that value. The reason for this is twofold:
1. Not all registers can be represented by a register_t. In particular
   FP registers fall in that category. Passing the new register value
   by reference instead of by value makes this point moot.
2. When we receive a G or P packet, both are for writing a register,
   the packet will have the register value in target-byte order and
   in the memory representation (modulo the fact that bytes are sent
   as 2 printable hexadecimal numbers of course). We only need to
   decode the packet to have a pointer to the register value.

This change fixes the bug of extracting the register value of the P
packet as a hexadecimal number instead of as a bit array. The quick
(and dirty) fix to bswap the register value in gdb_cpu_setreg() as
it has been added on i386 and amd64 can therefore be removed and has
in fact been that.

Tested on: alpha, amd64, i386, ia64, sparc64
2004-12-01 06:40:35 +00:00
David Schultz
6004362e66 Don't include sys/user.h merely for its side-effect of recursively
including other headers.
2004-11-27 06:51:39 +00:00
David Schultz
6484fde022 Remove references to U area and garbage collect includes.
Reviewed by:	arch@
2004-11-20 02:30:59 +00:00
David Schultz
ab44ebf537 Remove UAREA_PAGES.
Reviewed by:	arch@
2004-11-20 02:29:50 +00:00
David Schultz
11111b709f U areas are going away, so don't allocate one for process 0.
Reviewed by:	arch@
2004-11-20 02:29:25 +00:00
Marius Strobl
906ca21abe Add a front-end for the `rtc' device which is a MC146818 compatible
clock found on the ISA bus (some USIIe, USIIi and USIIIi models) and
EBus (USIII models) instead of a MK48Txx clock.

Testet by:	Matthew T. Lager" <freebsd@trinetworks.com> on Sun Fire V100,
		Xavier Beaudouin <kiwi@oav.net> on Netra X1 (initial version)
2004-11-17 16:41:42 +00:00
Marius Strobl
8ff995cc5f o sparc64/isa/isa.c:
- The claim in the commit log of rev. 1.11 of dev/uart/uart_cpu_sparc64.c
    etc. that UARTs are the only relevant ISA devices on sparc64 turned out
    to be false. While there are sparc64 models where UARTs are the only
    devices on the ISA bus there are in fact also low-cost models where all
    devices traditionally found on the EBus are hooked up to the ISA bus.
    There are also models that use a mix between EBus and ISA devices with
    things like an AT keyboard controller and other rather interesting
    devices that we might want to support in the futute hook up to the ISA
    bus.
    In order to not need to add sparc64 specific device_identify methods to
    all of the respective ISA drivers and also not add OFW specific code to
    the common ISA code make the sparc64 ISA bus code fake up PnP devices so
    most ISA drivers probe their devices without further changes.
    Unfortunately Sun doesn't adhere to the ISA bindings defined in IEEE
    1275-1994 for the properties of most of the ISA devices which would
    allow to obtain the vendor and logical IDs from their properties. So we
    we just use a simple table which maps the name properties to PnP IDs.
    This could be done in a more sophisticated way but I courrently don't
    see the need for this. [1]
  - Add the children with fully mapped and specified resources (in the OFW
    sense) similar to what is done in the EBus code for the IRQ resources
    of the children as adjusting the resources and the resource list entries
    respectively in isa_alloc_resource() as done perviously causes trouble
    with drivers which use rman_get_start(), pass-through or allocate and
    release resources multiple times, etc.
    Adjusting the resources might be better off in a bus_activate_resource
    method but the common ISA code currently doesn't allow for an
    isa_activate_resource(). [2]
    With this change:
    - ppbus(4) and lpt(4) attach and work (modulo ECP mode, which requires
      real ISADMA code but it currently only consists of stubs on sparc64).
    - atkbdc(4) and atkbdc(4) attach, no further testing done.
    - fdc(4) itself attaches but causes a hang while attaching fd0 also
      when is DMA disabled, further work in fdc(4) is required here as e.g.
      fd0 uses the address of fd1 on sparc64 (not sure if sparc64 supports
      more than one floppy drive at all).
    All of these drivers previously caused panics in the sparc64 ISA code.
  - Minor changes, e.g. use __FBSDID, remove a dupe word in a comment and
    declare one global variable which isn't used outside of isa.c static.
o dev/uart/uart_cpu_sparc64.c and modules/uart/Makefile:
  - Remove the code for registering the UARTs on the ISA bus from the
    sparc64 uart_cpu_identify() again and rely on probing them via PnP.

Original idea by:	tmm [1]
No objections by:	tmm [1], [2]
2004-11-17 14:44:10 +00:00
Marius Strobl
f3cb1d7863 Shorten the description of the mk48txx driver to just say that it supports
MK48Txx clocks, there are now to many models supported to list them all here.
2004-11-17 12:57:24 +00:00
Marius Strobl
2d86abb059 o Sync with the NetBSD mk48txx driver (the result simplyfies some changes
I have in mind for the genclock interface):
  - Recognize the MK48T18 as well (differs from the MK48T08 only in
    packaging options and voltages).
  - Allow MD code to provide functions for reading/writing NVRAM/RTC
    locations.
    If passed NULL, the old behaviour using bus_space_{read,write}_1() is
    used. Otherwise, all access to the chip goes via the MD functions.
    This is necessary for mvmeppc boards where the mk48txx NVRAM/RTC is
    not directly addressable.
  - Cleanup MI mk48txx(4) todclock driver:
    - Prepare mk48txxvar.h and leave only register definitions in
      mk48txxreg.h.
    - Define struct mk48txx_softc as usual devices and allocate necessary
      members in it.
    - Change mk48txx_attach() to only take a device_t.
o While converting the sparc64 eeprom driver to the above changes:
  - Remove some dead code and stale comments.
  - Use the NVRAM size provided by the mk48txx driver instead of hardcoding
    it as suggested by a comment.
  - Add a comment about why it doesn't make much sense to read the hostid
    directly from the NVRAM except for displaying it when attaching.
  - Don't print the hostid if it reads all zero because it's stored
    elsewhere.
2004-11-17 12:54:12 +00:00
Marius Strobl
ac20cbd343 Catch up with version 600000 of config(8), quotes around device names
containing digits are no longer required.
2004-11-17 12:07:14 +00:00
Tom Rhodes
acad338196 Fix paths after repocopies done by scottl
Reviewed by:	marius
OK'ed by:	scottl
2004-11-10 14:09:52 +00:00
Alan Cox
12ef9d214b Correct a typo in the previous revision. 2004-11-08 06:01:39 +00:00
Alan Cox
d3cb0d99e0 Introduce two new options, "CPU private" and "no wait", to sf_buf_alloc().
Change the spelling of the "catch" option to be consistent with the new
options.  Implement the "no wait" option.  An implementation of the "CPU
private" for i386 will be committed at a later date.
2004-11-08 00:43:46 +00:00
Alan Cox
d19ef81437 The synchronization provided by vm object locking has eliminated the
need for most calls to vm_page_busy().  Specifically, most calls to
vm_page_busy() occur immediately prior to a call to vm_page_remove().
In such cases, the containing vm object is locked across both calls.
Consequently, the setting of the vm page's PG_BUSY flag is not even
visible to other threads that are following the synchronization
protocol.

This change (1) eliminates the calls to vm_page_busy() that
immediately precede a call to vm_page_remove() or functions, such as
vm_page_free() and vm_page_rename(), that call it and (2) relaxes the
requirement in vm_page_remove() that the vm page's PG_BUSY flag is
set.  Now, the vm page's PG_BUSY flag is set only when the vm object
lock is released while the vm page is still in transition.  Typically,
this is when it is undergoing I/O.
2004-11-03 20:17:31 +00:00
Andre Oppermann
32672ba88d Reduce annoying SCSI probing delay from 15 to 5 seconds in all GENRIC kernels.
Discussed on:	-current
2004-11-02 20:57:20 +00:00
John Baldwin
d39d4a6e64 - Change the ddb paging "support" to use a variable (db_lines_per_page) to
control the number of lines per page rather than a constant.  The variable
  can be examined and changed in ddb as '$lines'.  Setting the variable to
  0 will effectively turn off paging.
- Change db_putchar() to force out pending whitespace before outputting
  newlines and carriage returns so that one can rub out content on the
  current line via '\r     \r' type strings.
- Change the simple pager to rub out the --More-- prompt explicitly when
  the routine exits.
- Add some aliases to the simple pager to make it more compatible with
  more(1): 'e' and 'j' do a single line.  'd' does half a page, and
  'f' does a full page.

MFC after:	1 month
Inspired by:	kris
2004-11-01 22:15:15 +00:00
Pyun YongHyeon
7a7386a3e2 Device driver for onboard CS4231 audio controller which is found
on UltraSPARC workstations. The driver is based on OpenBSD's SBus
cs4231 driver and heavily modified to incorporate into sound(4)
infrastructure. Due to the lack of APCDMA documentation, the DMA
code of SBus cs4231 came from OpenBSD's driver.
The driver runs without Giant lock and supports both SBus and EBus
based CS4231 audio controller. Special thanks to marius for providing
feedbacks during the driver writing. His feedback made it possible
to write hiccup free playback code under high system loads.

Approved by:	jake (mentor)
Reviewed by:	marius (initial version)
Tested by:	marius, kwm, Julian C. Dunn(jdunn AT opentrend DOT net)
2004-10-25 10:29:57 +00:00
Ken Smith
27dd55ed35 Flush the register windows before we start changing the context.
Submitted by:	Andrew Belashov <bel (at) orel.ru> (slightly modified)
Reviewed by:	jake
2004-10-09 16:42:09 +00:00
Pyun YongHyeon
e60fc88fa6 Port NetBSD auxio driver. The driver was modified to use led(4) and can
be used to announce various system activity.
The auxio device provides auxiliary I/O functions and is found on various
SBus/EBus UltraSPARC models. At present, only front panel LED is
controlled by this driver.

Approved by:    jake (mentor)
Reviewed by:    joerg
Tested by:      joerg
2004-10-09 07:31:03 +00:00
Ken Smith
e946ee1355 This along with v1.6 of counter.c fixes some timecounter issues on
MP machines (hopefully).  CPU timers are OK on UP machines but we
don't keep the timers in sync on MP machines so if the CPU's timer
is chosen as the primary timecounter it's possible for time to
not be monotonically increasing because different CPU's counters
may be used at different times.  But the CPU's counters are otherwise
one of the higher quality counters available.  So, on UP machines
we'll use a relatively high quality value but on MP machines we'll
use a quality that should prevent the CPU's counters from being chosen.

Requested by:	green (who did the first version of the patch)
Reviewed by:	marius, green
MFC after:	1 week
2004-09-30 14:38:59 +00:00
Ken Smith
9886f01b6f Set the tc_quality field of the struct before calling tc_init(), since
the structure space had been obtained from malloc() its contents is
random garbage.  The choice of value being set is part of a larger effort
to solve some timecounter issues on MP machines (while working on that
we noticed this problem).

Noticed by:	marius
Reviewed by:	marius, green
MFC after:	3 days
2004-09-30 14:30:29 +00:00
Ken Smith
009b028629 We seem to have occasions where sending an IPI takes significantly
longer than 'normal'.  The cause is still being tracked down but
in the meantime there are machines where raising IPI_RETRIES does
help - it's not just a case of the machine staying locked up longer
and then panic-ing anyway.  Several helpful folks on sparc64@ tried
a patch that helped figure out what to raise this number to.

Discussed on:	sparc64@
MFC after:	3 days
2004-09-29 21:39:36 +00:00
Ken Smith
fc449eb47a Add an assertion that the pcb_nsaved field of the pcb be less than
MAXWIN to the register window manipulation functions - rwindow_load()
calls rwindow_save() so this one addition should take care of both.
This should help find places that pcb_nsaved doesn't get initialized
properly.

Suggested by:	jake
2004-09-28 16:36:58 +00:00
Ken Smith
e400e0825a Some minor print/panic message cleanups. 2004-09-27 16:06:38 +00:00
Ken Smith
705ea0213d Initialize the count of saved register windows to 0 in the pcb created
for the new thread.  The rest of the fields in the pcb wind up being
written to before they're read as a normal part of the pcb usage but
this field may be read upon return to userland, having it be uninitialized
garbage is bad.

Submitted by:	Andrew Belashov (bel at orel dot ru)
Reviewed by:	jake
MFC after:	3 days
2004-09-27 12:34:47 +00:00
John Baldwin
76764432e4 - Add support for "paging" in stack trace output. That is, when you do
a stack trace from ddb, the output will pause with a '--More--' prompt
  every 18 lines.  If you hit Enter, it will print another line and prompt
  again.  If you hit space it will output another page and then prompt.
  If you hit 'q' or 'x' it will abort the rest of the stack trace.
- Fix the sparc64 userland stack trace to honor the total count of lines
  to print.  This is useful if your trace happens to walk back onto
  0xdeadc0de and gets stuck in an endless loop.

MFC after:	1 month
Tested on:	i386, alpha, sparc64
2004-09-20 19:05:32 +00:00
Marcel Moolenaar
e4793b0eda Better fix the busdma problem exposed by ATA. With the CMD 646 for
example the maximum segment size is 64K while the boundary is set
to 8K due to controller limitations. It is impossible to NOT cross
the boundary for any segment size that's larger than the boundary.
So, once we inherited the boundary from the parent tag, make sure
to reduce the maximum segment size to the boundary if it was larger.

MT5 candidate.
2004-09-10 07:00:28 +00:00
Scott Long
698e3209dc sparc64 is not ready for PREEMPTION, so turn it off for now. 2004-09-09 17:03:53 +00:00
Scott Long
50736a153b Fix a problem with tag->boundary inheritence that has existed since day one
and was propagated to nearly every platform.  The boundary of the child needs
to consider the boundary of the parent and pick the minimum of the two, not
the maximum.  However, if either is 0 then pick the appropriate one.
This bug was exposed by a recent change to ATA, which should now be fixed by
this change.  The alignment and maxsegsz tag attributes likely also need
a similar review in the near future.

This is a MT5 candidate.

Reviewed by: marcel
Submitted by: sos (in part)
2004-09-08 04:54:19 +00:00
Scott Long
444ba94513 Switch the default scheduler to 4BSD to match what will go into RELENG_5 soon.
It can be switched back once 5.3 is tested and released.  Also turn on
PREEMPTION as many of the stability problems with it have been fixed.

MT5: 3 days.
2004-09-07 22:37:43 +00:00
Julian Elischer
ed062c8d66 Refactor a bunch of scheduler code to give basically the same behaviour
but with slightly cleaned up interfaces.

The KSE structure has become the same as the "per thread scheduler
private data" structure. In order to not make the diffs too great
one is #defined as the other at this time.

The KSE (or td_sched) structure is  now allocated per thread and has no
allocation code of its own.

Concurrency for a KSEGRP is now kept track of via a simple pair of counters
rather than using KSE structures as tokens.

Since the KSE structure is different in each scheduler, kern_switch.c
is now included at the end of each scheduler. Nothing outside the
scheduler knows the contents of the KSE (aka td_sched) structure.

The fields in the ksegrp structure that are to do with the scheduler's
queueing mechanisms are now moved to the kg_sched structure.
(per ksegrp scheduler private data structure). In other words how the
scheduler queues and keeps track of threads is no-one's business except
the scheduler's. This should allow people to write experimental
schedulers with completely different internal structuring.

A scheduler call sched_set_concurrency(kg, N) has been added that
notifies teh scheduler that no more than N threads from that ksegrp
should be allowed to be on concurrently scheduled. This is also
used to enforce 'fainess' at this time so that a ksegrp with
10000 threads can not swamp a the run queue and force out a process
with 1 thread, since the current code will not set the concurrency above
NCPU, and both schedulers will not allow more than that many
onto the system run queue at a time. Each scheduler should eventualy develop
their own methods to do this now that they are effectively separated.

Rejig libthr's kernel interface to follow the same code paths as
linkse for scope system threads. This has slightly hurt libthr's performance
but I will work to recover as much of it as I can.

Thread exit code has been cleaned up greatly.
exit and exec code now transitions a process back to
'standard non-threaded mode' before taking the next step.
Reviewed by:	scottl, peter
MFC after:	1 week
2004-09-05 02:09:54 +00:00
Julian Elischer
5995adc206 Remove an unneeded argument..
The removed argument could trivially be derived from the remaining one.
That in turn should be the same as curthread, but it is possible that curthread could be expensive to derive on some syste,s so leave it as an argument.
Having both proc and thread as an argumen tjust gives an opportunity for
them to get out sync.

MFC after:	3 days
2004-08-31 07:34:54 +00:00
Julian Elischer
99e9dcb817 Remove sched_free_thread() which was only used
in diagnostics. It has outlived its usefulness and has started
causing panics for people who turn on DIAGNOSTIC, in what is otherwise
good code.

MFC after:	2 days
2004-08-31 06:12:13 +00:00
Marcel Moolenaar
0f2fe153bc Move the kernel-specific logic to adjust frompc from MI to MD. For
these two reasons:
1. On ia64 a function pointer does not hold the address of the first
   instruction of a functions implementation. It holds the address
   of a function descriptor. Hence the user(), btrap(), eintr() and
   bintr() prototypes are wrong for getting the actual code address.
2. The logic forces interrupt, trap and exception entry points to
   be layed-out contiguously. This can not be achieved on ia64 and is
   generally just bad programming.

The MCOUNT_FROMPC_USER macro is used to set the frompc argument to
some kernel address which represents any frompc that falls outside
the kernel text range. The macro can expand to ~0U to bail out in
that case.
The MCOUNT_FROMPC_INTR macro is used to set the frompc argument to
some kernel address to represent a call to a trap or interrupt
handler. This to avoid that the trap or interrupt handler appear to
be called from everywhere in the call graph. The macro can expand
to ~0U to prevent adjusting frompc. Note that the argument is selfpc,
not frompc.

This commit defines the macros on all architectures equivalently to
the original code in sys/libkern/mcount.c. People can take it from
here...

Compile-tested on: alpha, amd64, i386, ia64 and sparc64
Boot-tested on: i386
2004-08-27 19:42:35 +00:00
Andre Oppermann
c21fd23260 Always compile PFIL_HOOKS into the kernel and remove the associated kernel
compile option.  All FreeBSD packet filters now use the PFIL_HOOKS API and
thus it becomes a standard part of the network stack.

If no hooks are connected the entire packet filter hooks section and related
activities are jumped over.  This removes any performance impact if no hooks
are active.

Both OpenBSD and DragonFlyBSD have integrated PFIL_HOOKS permanently as well.
2004-08-27 15:16:24 +00:00
Alan Cox
0b6a0b955a Properly free the temporary sf_buf in uiomove_fromphys() if a copyin or
copyout fails.

Obtained from: DragonFlyBSD
2004-08-21 18:50:34 +00:00
Marius Strobl
34c8a85fc8 - Sync whitespace and comments with i386 GENERIC.
- Add some commented out NICs from i386 GENERIC. Most of them look like they
  would work but I'm not sure if they are endian-clean and can't test. There
  was a report that sk(4) works on sparc64 but it doesn't look like it would
  because it doesn't use busdma.
- Improve some of the descriptions of sparc64 specific devices.

There's no functional change, i.e. no added or deleted uncommented devices or
options, in this commit.
2004-08-16 23:23:21 +00:00
Marius Strobl
df774a6b16 Try to catch up with reality:
- Chase the split of pcm(4). This unbreaks LINT compiles.
- sc(4) basically works and a lot of its options should be supported.
- Add the creator and ofw_console drivers.
- vinum(4) should work, at least its module was turned on for sparc64 a while
  ago.
- Don't build sio(4). Its EBus front-end was removed a while ago and the ISA
  one hardly works. Use uart(4) instead, it's not perfect yet but works much
  better.
2004-08-16 23:21:06 +00:00
Marius Strobl
39513fa664 Instead of "OpenFirmware", "openfirmware", etc. use the official spelling
"Open Firmware" from IEEE 1275 and OpenFirmware.org (no pun intended).

Ok'ed by:	tmm
2004-08-16 15:45:27 +00:00
Marius Strobl
775f3c3c28 Correct some uses of the wrong members of the *min()/*max()-familiy, e.g.
min() on unsigned long. None of these are believed to have been fatal though.

Reviewed by:	tmm
2004-08-15 21:37:52 +00:00
Marius Strobl
b7b6c9e6fa - Make OF_getetheraddr() honour the "local-mac-address?" system config
variable. If set to "true" OF_getetheraddr() will now return the unique
  MAC address stored in the "local-mac-address" property of the device's
  OFW node if present and the host address/system default MAC address if
  the node doesn't doesn't have such a property. If set to "false" the
  host address will be returned for all devices like before this change.
  This brings the behaviour of device drivers for NICs with OFW support/
  FCode, i.e. dc(4) for on-board DM9102A on Sun machines, gem(4) and hme(4),
  regarding "local-mac-address?" in line with NetBSD and Solaris.
  The man pages of the respective drivers will be updated separately to
  reflect this change.
- Remove OF_getetheraddr2() which was used as a stopgap in dc(4). Its
  functionality is now part of OF_getetheraddr().
2004-08-14 21:43:37 +00:00
Alan Cox
edf181d07e Add pmap locking to pmap_remove_all(). 2004-08-13 18:54:21 +00:00
Marius Strobl
26280d88d7 - Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
  properties in drivers for devices on Open Firmware supported busses. The
  standard properties "reg", "interrupts" und "address" are not covered by
  this interface because they are only of interest in the respective bridge
  code. There's a remaining standard property "status" which is unclear how
  to support properly but which also isn't used in FreeBSD at present.
  This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
  ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
  vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
  This in turn allows to simplify and remove code-duplication in drivers for
  devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
  drivers for their children to use the ofw_bus kobj-interface. The IVAR-
  interfaces of the Central, EBus and FHC are entirely replaced by this. The
  PCI bus driver used its own kobj-interface and now also uses the ofw_bus
  one. The IVARs special to the SBus, e.g. for retrieving the burst size,
  remain.
  Beware: this causes an ABI-breakage for modules of drivers which used the
  IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
  recompiled.
  The style-inconsistencies introduced in some of the bus drivers will be
  fixed by tmm@ in a generic clean-up of the respective drivers later (he
  requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
  use the ofw_bus kobj-interface. This invloves removing the IVARs related
  to the "reg" property which were unused and a leftover from the NetBSD
  origini of the code. There's no ABI-breakage caused by this because none
  of these driver are currently built as modules.
  There are other powerpc bus drivers which can be converted to the ofw_bus
  kobj-interface, e.g. the PCI bus driver, which should be done together
  with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
  advantage of the ofw_bus kobj-interface and simplify them a bit.

Reviewed by:	grehan, tmm
Approved by:	re (scottl)
Discussed with:	tmm
Tested with:	Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
Marcel Moolenaar
4da47b2fec Add __elfN(dump_thread). This function is called from __elfN(coredump)
to allow dumping per-thread machine specific notes. On ia64 we use this
function to flush the dirty registers onto the backingstore before we
write out the PRSTATUS notes.

Tested on: alpha, amd64, i386, ia64 & sparc64
Not tested on: arm, powerpc
2004-08-11 02:35:06 +00:00
Alan Cox
2c0680e659 Add pmap locking to many of the functions.
Implement the protection check required by the pmap_extract_and_hold()
specification.

Remove the acquisition and release of Giant from pmap_extract_and_hold() and
pmap_protect().

Many thanks to Ken Smith for resolving a sparc64-specific initialization
problem in my original patch.

Tested by: kensmith@
2004-08-10 20:53:26 +00:00
Alan Cox
684a62b7bf - Push down the acquisition and release of Giant into pmap_enter_quick()
on those architectures without pmap locking.
 - Eliminate the acquisition and release of Giant in vm_map_pmap_enter().
2004-08-04 22:03:16 +00:00
Mark Murray
d23a262fc5 Making a loadable null.ko for /dev/(null|zero) proved rather
unpopular, so remove this (mis)feature.

Encouragement provided by:	jhb (and others)
2004-08-03 19:24:54 +00:00
Maxime Henrion
9f1b87f106 Instead of calling ia32_pause() conditionally on __i386__ or __amd64__
being defined, define and use a new MD macro, cpu_spinwait().  It only
expands to something on i386 and amd64, so the compiled code should be
identical.

Name of the macro found by:	jhb
Reviewed by:	jhb
2004-08-03 18:44:27 +00:00
Mark Murray
8ab2f5ecc5 Break out the MI part of the /dev/[k]mem and /dev/io drivers into
their own directory and module, leaving the MD parts in the MD
area (the MD parts _are_ part of the modules). /dev/mem and /dev/io
are now loadable modules, thus taking us one step further towards
a kernel created entirely out of modules. Of course, there is nothing
preventing the kernel from having these statically compiled.
2004-08-01 11:40:54 +00:00
Alan Cox
9bb0e06861 - Push down the acquisition and release of Giant into pmap_protect() on
those architectures without pmap locking.
 - Eliminate the acquisition and release of Giant from vm_map_protect().

(Translation: mprotect(2) runs to completion without touching Giant on
alpha, amd64, i386 and ia64.)
2004-07-30 20:38:30 +00:00
Robert Watson
1a8cfbc450 Pass a thread argument into cpu_critical_{enter,exit}() rather than
dereference curthread.  It is called only from critical_{enter,exit}(),
which already dereferences curthread.  This doesn't seem to affect SMP
performance in my benchmarks, but improves MySQL transaction throughput
by about 1% on UP on my Xeon.

Head nodding:	jhb, bmilekic
2004-07-27 16:41:01 +00:00
Alan Cox
bfdf81ac47 Use kmem_alloc_nofault() rather than kmem_alloc_pageable() for allocating
KVA for explicitly managed mappings, i.e., mappings created with
pmap_qenter().
2004-07-23 06:49:49 +00:00
Marcel Moolenaar
fd32d93b97 Unify db_stack_trace_cmd(). All it did was look up the thread given
the thread ID and call db_trace_thread().
Since arm has all the logic in db_stack_trace_cmd(), rename the
new DB_COMMAND function to db_stack_trace to avoid conflicts on
arm.
While here, have db_stack_trace parse its own arguments so that
we can use a more natural radix for IDs. If the ID is not a thread
ID, or more precisely when no thread exists with the ID, try if
there's a process with that ID and return the first thread in it.
This makes it easier to print stack traces from the ps output.

requested by: rwatson@
tested on: amd64, i386, ia64
2004-07-21 05:07:09 +00:00
Maxim Konovalov
aa355a2679 In -CURRENT pseudo devices are not statically assigned at compile time,
remove a stale comment.

PR:		kern/62285
2004-07-18 09:03:12 +00:00
Alan Cox
3d2e54c317 Push down the acquisition and release of the page queues lock into
pmap_protect() and pmap_remove().  In general, they require the lock in
order to modify a page's pv list or flags.  In some cases, however,
pmap_protect() can avoid acquiring the lock.
2004-07-15 18:00:43 +00:00
David Xu
53dbf30349 Add ptrace_clear_single_step(), alpha already has it for years, the function
will be used by ptrace to clear a thread's single step state.
2004-07-13 07:22:56 +00:00
Marcel Moolenaar
e8d5eed9c1 The SC_DISABLE_DDBKEY options has been renamed to SC_DISABLE_KDBKEY. 2004-07-11 03:21:24 +00:00
Marcel Moolenaar
8bcb1e9e84 Add options KDB and GDB. KDB takes on the function of what DDB used
to be. Both DDB and GDB specify which KDB backends to include.
2004-07-11 03:20:09 +00:00
Marcel Moolenaar
37224cd3fc Mega update for the KDB framework: turn DDB into a KDB backend.
Most of the changes are a direct result of adding thread awareness.
Typically, DDB_REGS is gone. All registers are taken from the
trapframe and backtraces use the PCB based contexts. DDB_REGS was
defined to be a trapframe on all platforms anyway.
Thread awareness introduces the following new commands:
	thread X	switch to thread X (where X is the TID),
	show threads	list all threads.

The backtrace code has been made more flexible so that one can
create backtraces for any thread by giving the thread ID as an
argument to trace.

With this change, ia64 has support for breakpoints.
2004-07-10 23:47:20 +00:00
Marcel Moolenaar
a5a3d76272 Update for the KDB framework:
o  Make debugging code conditional upon KDB instead of DDB.
o  Call kdb_enter() instead of Debugger().
o  Remove implementation of Debugger().
o  Check kdb_active instead of db_active.
o  Call kdb_trap() according to the new world order.
2004-07-10 23:10:07 +00:00
Marcel Moolenaar
eda20064f9 Update for the KDB framework:
o  Call kdb_enter() instead of Debugger().
2004-07-10 23:06:41 +00:00