Commit Graph

333 Commits

Author SHA1 Message Date
scw 99fec1b346 Minor pmap rototil:
- Track unmanaged mappings of RAM more closely by allocating a pvo
   for them. This allows us to check more accurately for multiple
   cache-mode-incompatible mappings.

 - As part of the above, implement pmap_steal_memory(). This has the
   beneficial side-effect of moving a fair chunk of kernel data
   structures into KSEG0.
2002-10-04 09:17:57 +00:00
scw c859106ab8 Gee, this file is showing its origins... cpu_swapout() may invoke
panic() on MIPS, but really shouldn't do the same on SH5.
2002-10-02 16:19:59 +00:00
thorpej 89bf5a8f8e Add trailing ; to CFATTACH_DECL. 2002-10-02 15:52:22 +00:00
scw b13817324e Fix the initial cacheline alignment case. This gets my PCI ex(4) card
pretty much working, at least for non-NFS use.

With NFS, it fails under pressure probably due to operand cache aliases
between KSEG0 and regular 4KB mappings elsewhere. Sigh.
2002-10-02 14:40:27 +00:00
scw 9e1133a710 In pmap_page_is_cacheable(), add an explicit check for KSEG0 addresses.
They don't show up in the page tables, so the default "not cacheable"
status is wrong.

This finally gets my ex(4) working on the Cayman's PCIbus.
2002-10-02 12:19:38 +00:00
scw 4c12ca2bdc Don't clear the original contents of r0 in sigreturn(). We're returning
to the interrupted context, not the sigreturn syscall stub.
2002-10-02 08:13:09 +00:00
scw 240029a2aa NetBSD/sh5 post-dates the old "signal trampoline" delivery mechanism,
so don't bother even pretending it exists.
2002-10-02 08:10:34 +00:00
scw c4efa0ddba Change IPL_SOFTNET to 3. 2002-10-01 21:07:31 +00:00
scw 0e3aa70138 Count all soft interrupt events per level, rather than just
the first one per call to softintr_dispatch().
2002-10-01 21:04:59 +00:00
scw 92c80efadc Fix a soft interrupt botch which prevented softints being dispatched
on exit from regular h/w interrupts.
2002-10-01 20:41:52 +00:00
thorpej 3b6eef8108 Use CFATTACH_DECL(). 2002-10-01 19:24:47 +00:00
scw 2ce95435ad One of the last pieces of the SH5 pmap jigsaw; detect and deal with
operand cache synonyms and paradoxes for shared mappings:

 - Writable mappings are cache-inhibited if the underlying physical
   page is mapped at two or more *different* VAs.

   This means that read-only mappings at different VAs are still
   cacheable. While this could lead to operand cache synonyms, it
   won't cause data loss. At worst, we'd have the same read-only
   data in several cache-lines.

 - If a new cache-inhibited mapping is added for a page which has
   existing cacheable mappings, all the existing mappings must be
   made cache-inhibited.

 - Conversely, if a new cacheable mapping is added for a page which
   has existing cache-inhibited mappings, the new mapping must also
   be made cache-ibhibited.

 - When a mapping is removed, see if we can upgrade any of the
   underlying physical page's remaining mappings to cacheable.

TODO: Deal with operand cache aliases (if necessary).
2002-10-01 15:01:48 +00:00
scw 1e4acb4d20 Another temporary fix until I write a bootloader: run the kernel
through dbsym(8).
2002-10-01 07:56:45 +00:00
scw 5a512e6285 Flesh out bus_dmamap_sync(). 2002-10-01 07:55:17 +00:00
scw 02301c13c5 Add a #define for the SH5's cacheline size. 2002-10-01 07:50:36 +00:00
scw a5ea619bef In pmap_extract() deal with KVAs in KSEG0 (which can be passed by the
bus_dma(9) code) instead of panicing.
2002-10-01 07:49:46 +00:00
scw 7a61cafd1e After the kernel is built, run it through objcopy to change the LMA
of the loadable sections to correspond to the physical address of
RAM in the Cayman. This is so sh5gdb uploads the image to the correct
place. (Should've done this ages ago instead of manually running a
script...)

This can be removed when I get a native bootloader written.
2002-09-28 18:35:38 +00:00
thorpej 8f6cdec6af Make _C_LABEL() pay attention to __NO_LEADING_UNDERSCORES__. 2002-09-28 15:50:37 +00:00
scw d26f394149 Add audio(4). 2002-09-28 13:13:23 +00:00
scw a7be636d26 Rename the SH5 PCI attachment to "sh5pci" instead of abusing the "pcibus"
config definition. The new config world order is more picky about such things.
2002-09-28 13:08:22 +00:00
scw 3e955d2331 PCI is pretty much done. 2002-09-28 13:06:49 +00:00
scw 94b4198ec9 Bump the scif console priority to CN_REMOTE for now. 2002-09-28 13:03:22 +00:00
scw 1c9cfe70b6 Const'ify the cfattach structure. 2002-09-28 11:18:01 +00:00
scw 251ba05b3f Support for the SH5 on-chip PCI bridge, and support for its deployment
in the Cayman board.
2002-09-28 11:16:36 +00:00
scw 171b08b4b9 Set the new process' FPSCR.DN bit so that denormalised FP numbers are
quietly flushed to zero before they're used.

While this isn't perfect, it seems to mimic the behaviour on i386 at least.
2002-09-28 11:11:01 +00:00
scw 3d776f64cf These hackish changes have been sitting around for a while. Commit
them so they don't get lost. This driver will be overhauled later
on anyway to make it shareable between sh[3-5].
2002-09-28 11:08:13 +00:00
scw 02787a17bc Wrap some expensive sanity checks in "ifdef PORTMASTER". 2002-09-28 11:04:26 +00:00
scw 4d809d551d The FP status register is 32-bits wide, so don't use register_t in
the various state frames.
2002-09-28 11:03:08 +00:00
scw 58931592a1 Honour BUS_DMA_COHERENT flag in bus_dmamem_map(), and g/c some dead code.
XXX: Still need to flesh out bus_dmamap_sync().
2002-09-28 10:57:44 +00:00
scw 05e55efada - Add pmap_page_is_cacheable() to allow the bus_dma code to query the
cacheable attribute of a mapping.
- Honour PMAP_NC in pmap_enter() using NOCACHE, instead of DEVICE.
- No longer need to re-fetch the ptel in pmap_pa_unmap_kva() as
  syncing the cache no longer risks causing a TLB miss.
2002-09-28 10:53:57 +00:00
scw 902d684338 - Add BUS_SPACE_MAP_PREFETCHABLE
- Re-define bus_size_t and bus_addr_t to be u_int32_t.
  While this may well lose for future silicon with NEFFBITS > 32, the
  original u_long was a waste on current designs (especially for _LP64).
2002-09-28 10:49:10 +00:00
scw e168d3e25c SH5's on-chip PCI bridge is attached as "pcibus", not "pchb". 2002-09-28 10:44:40 +00:00
scw 9c10dff0fb Print the intevt code in hex. 2002-09-28 10:43:36 +00:00
scw e578ac6fc3 Slight tweak to the linker emulation name now that I'm using ld(1)
from binutils-current.

Bump compiler optimisation to -O1.
2002-09-28 10:42:54 +00:00
thorpej 543bc9a286 The native compiler defines __NO_LEADING_UNDERSCORES__, so key off
that to determine if __LEADING_UNDERSCORE is necessary.
2002-09-28 02:27:03 +00:00
thorpej f818766afe Declare all cfattach structures const. 2002-09-27 20:31:45 +00:00
thorpej 6c88de3b53 Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller.  Use it
rather than invoking cfattach->ca_match directly.
2002-09-27 03:17:40 +00:00
scw 9393fbe941 Belated commit of code to calculate the delay constant used by delay(). 2002-09-22 20:57:23 +00:00
scw f9c02a8bd0 An initial NetBSD/sh5 TODO list. 2002-09-22 20:54:33 +00:00
scw 84b2ccee63 Add sh5_nmi_clear(), a board-specific hook for clearing the NMI one-shot. 2002-09-22 20:48:09 +00:00
scw aab9041eea In validate_kipt(), cacheable TLB entries are now legal. 2002-09-22 20:46:32 +00:00
scw badd3d5d65 Performance tweak to the copy_page/zero_page asm code.
Allocate/Prefetch one cache-line ahead of the one we're about to deal with.

This reduces the chances of the cpu stalling while waiting for the cache
to flush a dirty line in order to satisfy the Allocate/Prefetch request.
2002-09-22 20:45:31 +00:00
scw 5a529aa332 - Add a /e option to db_stack_trace_print() which dumps the saved
registers in any trap/interrupt exception frame found.

- Slight tweak to more accurately detect the correct call-site when
  looking for a function's prologue.
2002-09-22 20:31:18 +00:00
simonb 63096043b3 Use "#define\t" instead of "#define ". 2002-09-22 08:30:56 +00:00
chs c081614ea2 it really helps to get the stub right before cutting + pasting it 27 times.
alas, I did not.  doh.
2002-09-22 07:53:39 +00:00
chs 55e1f79335 add pmap_remove_all() hook (empty on most platforms so far). 2002-09-22 07:17:08 +00:00
gmcgarry dca80f08fd Add __HAVE_MD_RUNQUEUE flag for MD code to override MI run queue primitives. 2002-09-22 04:11:32 +00:00
scw e5b9e76f43 Start the search for a function's prologue by using the current PC - 4.
This ensures we start from the actual call site, not the return address.
The latter may actually be in the next consecutive function if the current
function has the __noreturn__ attribute and the alignment is Just Right.
2002-09-19 15:47:33 +00:00
scw c87975f571 - Tweak the output format slightly to show the frame address first.
- When dealing with an exception frame, we might as well print some
   useful details while we're passing through.
2002-09-19 13:04:02 +00:00
scw 87048d2661 Don't check the callers expected stack base against the saved frame
pointer, in case the caller grew its stack dynamically.

Also beef up the checks to catch cases where the call stack passes
through the exception handling code in locore. In this case, the
frame pointer and program counter are in the trapframe/intrframe.
2002-09-19 11:25:13 +00:00
scw 910c7664b3 Finally add full stack trace support by grovelling function prologues to
determine the call stack. (I was sick of doing this manually)
2002-09-19 10:05:25 +00:00
scw 47e178df57 Move opcode_t typedef into db_machdep.h. 2002-09-19 10:03:11 +00:00
scw a9c1bc6c83 Add code to deal with the "Cache Purge/Invalidate can cause TLB Miss"
problem, such that a TLB miss no longer occurs.

With the above, it is now safe to enable write-back caching for userland
mappings.

TODO: Deal with cache issues for shared mappings with different VAs.
2002-09-12 12:44:13 +00:00
scw 7e0aa6fcfc sh5_setasid() now returns the original ASID value. 2002-09-12 12:39:34 +00:00
scw a73ea332f6 Adapt to new cacheops requirements. 2002-09-12 12:38:42 +00:00
scw 22569e09ed The cacheops functions now need the physical address of the region
to be purged/invalidated.
2002-09-12 12:37:49 +00:00
scw b0ecf76dd4 sh5_setasid() now returns the value of the previous ASID. 2002-09-12 12:35:00 +00:00
scw 08dfbb4305 - Be more consistent about using ptel_t where it matters.
- Add event counters for some key pmap events (similar to mpc6xx pmap).

 - Use the cache-friendly, optimised copy/zero page functions.

 - Add the necessary cache management code to enable WriteBack caching
   of KSEG1 mappings. Seems to work fine so far.
2002-09-11 11:08:45 +00:00
scw ecb4124668 - Add cache-friendly, optimised copypage/zeropage functions for use by
the pmap module.

- Add {,e}intrnames and {,e}intrcnt to keep kernel-symbol grovelling
  tools like vmstat(8) happy.
2002-09-11 11:03:08 +00:00
scw b08dae4d46 Tweak the interrupt names to properly match reality. 2002-09-11 10:57:50 +00:00
scw e47c955f01 Get the correct evcnt structure and ipl number when initialising softints. 2002-09-11 10:56:43 +00:00
scw 2b0c53084c Slight tweak to save one instruction in the pteg TLB miss case. 2002-09-11 10:55:05 +00:00
scw bd0dd2e2e1 Add "machine fpr" command. This dumps the FPU registers for the current,
or a specified, process.
2002-09-10 12:44:38 +00:00
scw fe2f8acf65 Another big round of pmap fixes/cleanup:
- Use the PMAP_ASID_* constants from pmap.h

 - Track pmap_pvo_{enter,remove}() depth in the same way as mpc6xx's pmap
   (on which this pmap was originally based).

 - Some misc. tidying up and added commentary.

 - Use the VA/KVA to select whether to use the IPT or PTEG instead of
   checking which pmap is being operated on.

 - Add a handy DDB-callable function which will scan the kernel IPT
   looking for inconsitencies.

 - Finally, when unmapping a pool page, purge the data cache for the
   page. This permits write-back caching to be enabled for kernel
   text/data.
2002-09-10 12:42:03 +00:00
scw bcf9491257 Always save/restore the FPSCR into/from the sigcontext. 2002-09-10 12:33:44 +00:00
scw 1a8208566d - Remove the RESVEC vector table (panic/debug traps). It's now in
machine-specific code.

 - Re-work the code which detects a nested critical section event.
   We can now determine who is the owner of the critical section, and
   what event occurred while it was owned.

 - Work-around a silicon bug which can cause a nested critical event.
   In the _EXCEPTION_ENTRY() macro (which sets up the critical section),
   if there is a pending hardware interrupt which has a higher priority
   than the current IMASK, then the "putcon" which supposedly clears SR.BL
   and sets SR.IMASK to 0xf is not atomic. The pending hardware interrupt
   will be taken, causing a nested critical section event. The work-around
   is to update SR.BL and SR.IMASK separately using two "putcon" insns.
2002-09-10 12:27:21 +00:00
scw cd4797ccfa - Give a process a SIGFPE if it gets an FPU exception.
- Make it possible to at least *try* to resume execution if we
   get an NMI.
 - Major clean-up of the panic/critical section trap handlers.
   The dumped state is now much more accurate.
2002-09-10 12:15:39 +00:00
scw 5359676ddc - Add some comments,
- Fully initialise the FPU state (if enabled),
 - Implement delay() in assembly code.
2002-09-10 12:11:03 +00:00
scw c65ee4aa71 Add the critical section types, and cache mode values.
Delete a couple of unused struct cpu_info fields.
2002-09-10 12:08:49 +00:00
scw d9d434b5ed Always save/restore the FP status/control register across a context switch
(If the FPU is enabled).

Add a DEBUG check to ensure the incoming context's SR is sane.
2002-09-10 12:06:49 +00:00
scw d7e84a627e - Remove the version of delay() which used the cycle counter register.
There were some problems related to wrap-around which lead to
   delaying much longer than requested.
 - Cacheops additions.
2002-09-10 11:59:50 +00:00
scw 0d7cafd74b Add a few more cpu-specific cacheop functions. 2002-09-10 11:56:32 +00:00
scw fdd9155a03 Manifest constants for errors pertaining to recursive critical section
handling.
2002-09-10 11:51:01 +00:00
scw d2336580d6 Manifest constants for ASID values. 2002-09-10 11:11:44 +00:00
scw 8cd70003d7 Add external reference for _sh5_delay_constant. 2002-09-10 11:11:12 +00:00
scw 7af71ec12b Some tidying up, and a fix for an event counter array overrun
which was responsible for corrupting the kernel IPT.
2002-09-07 20:43:32 +00:00
scw b5ad0bee9e Numerous fixes, and some more debug instrumentation.
NetBSD/sh5 now reaches multi-user, although there is still
an occasional wedging problem after a wee while of running.
2002-09-06 16:20:48 +00:00
scw e7281ceb93 - When casting void * to register_t, go via intptr_t instead of uintptr_t
so the register is correctly sign-extended.

 - Some comment fixes.

 - Restore the FP state from the sigcontext if FP regs were saved.

 - Fix up r0 for the benefit of the syscall stub.
2002-09-06 15:48:51 +00:00
scw 3644ff25b2 Small optimisation and tweak to copy{,in,out}str() to make them
work as advertised for corner cases.
2002-09-06 15:41:07 +00:00
scw ed033ad71d Restore the branch-target registers from the correct place... 2002-09-06 15:39:16 +00:00
scw 905138641a Add the User Status Register to db_regs[]. 2002-09-06 15:37:14 +00:00
scw 690813872b Account for the clock interrupt itself in CLKF_INTR(). 2002-09-06 15:36:16 +00:00
scw 12968d78e9 Double-precision FP regs use a single register_t, despite the FP number
being a multiple of two. Correct for this in the _JB_DR macro.
2002-09-06 15:35:41 +00:00
gehenna 77a6b82b27 Merge the gehenna-devsw branch into the trunk.
This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

	device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
  by using this grammer.

- Added the new naming convention.
  The name of the device switch must be <prefix>_[bc]devsw for auto-generation
  of device switch tables.

- The backward compatibility of loading block/character device
  switch by LKM framework is broken. This is necessary to convert
  from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
  We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
  the LKM framework will refer it to assign device major number dynamically.
2002-09-06 13:18:43 +00:00
scw 45eb1758c0 Clean this up somewhat, and correct some bad offsets. 2002-09-05 09:53:17 +00:00
scw 570420748b Need opt_kernel_ipt.h here. 2002-09-04 15:31:06 +00:00
scw dd3511071d Mondo pmap fixes, including a bunch of DEBUG stuff.
This still needs a bunch of work, but is good enough to get
us to single-user mode.

To paraphrase a quote from Short Circuit: "NetBSD/sh5 is alive!".
2002-09-04 15:30:12 +00:00
scw 94d1813039 Don't inlcude "opt_kernel_ipt.h" here.
Move KERNEL_IPT_SIZE inside _KERNEL check.
2002-09-04 15:26:29 +00:00
scw ad5e71606f Don't claim we can support a stat clock at this time; I still need to
sort out some clocking issues.
2002-09-04 15:18:14 +00:00
scw c5c693afff Oops, free bus space via uvm_km_free() instead of pmap_kremove(). 2002-09-04 14:39:56 +00:00
scw 7f0cd9b561 Some bug fixes:
- in _EXCEPTION_EXIT, copy the current ASID to the pre-exception
    context before we switch.
  - fix the pteg hash generation code and EPN masking in the tlb
    miss handler.

Sprinkle some DIAGNOSTIC checks.
2002-09-04 14:37:53 +00:00
scw 8f18047310 Fix a couple of bugs:
- a && which should have been a &
 - advance the PC to the next insn before dealing with a syscall (trapa)

Sprinkle some DEBUG/DIAGNOSTIC code.
2002-09-04 14:34:01 +00:00
scw 5496168b35 In setregs(), set SF_FLAGS_CALLEE_SAVED in the new process' trapframe
to ensure the callee-saved set will be restored when we switch to it.
(It doesn't actually matter to the new process; it just inherits some
crud in those registers from the kernel if we don't set the bit).

Also ensure the strings pointer in r7 is sign-extended.
2002-09-04 14:13:28 +00:00
scw 99355049c8 Zap a couple of bugs caused by finger-trouble during initial development. 2002-09-04 14:04:28 +00:00
scw e6913f183b Ditch the 2*sizeof(void *) padding when setting up the child's kernel stack. 2002-09-04 14:02:47 +00:00
scw 348a751bf7 A bunch of fixes/simplifications to copyin/out and friends.
XXX: These are still the interim, unoptimised versions.
2002-09-04 14:01:24 +00:00
scw adaa2cbf20 Don't bother setting SR.BL before double-checking a TLB entry. It's
sufficient just to set SR.IMASK to 0xf (which also allows single-
stepping through the code).
2002-09-04 13:58:36 +00:00
scw 987c8cb69b When tracking movi/shori, don't discard the upper 32-bits before
printing in ILP32 mode. They still contain useful information.
2002-09-04 13:56:09 +00:00
scw 57ec33c922 s/==/!=/ when checking for counter wrap-around. 2002-09-02 20:04:25 +00:00
scw f9ab2f4618 g/c a bit of DEBUG code which crept into the last commit. 2002-09-02 14:03:22 +00:00
scw c3eb6d5b68 Add a function which dumps the machine state following a nested
critical section fault.

Also, in the regular trap() handler, use &proc0 if curproc is NULL.
2002-09-02 14:02:03 +00:00
scw 693ffb8185 Catch the case where a synchronous exception occurs during the critical
section of another exception. This is likely to happen if the kernel
stack is misaligned, has dropped off the bottom of the PCB, or has
otherwise gone into orbit.

In this case, switch to a safe stack, save as much of the machine
state as possible and dump it to the console.
2002-09-02 14:00:25 +00:00
scw f9fe8e4707 Go to splhigh() before enterring ddb(9). 2002-09-02 13:55:03 +00:00
scw 2a7a3cc2f8 In the _EXCEPTION_EXIT macro, don't use r24 until we've finished
accessing the kernel stack, since a TLB miss on the kernel stack
will result in r24 being trashed.
Also clear the ES_CRITICAL flag just before returning to the
previous context.
2002-09-02 08:41:56 +00:00
scw b02c328efd Track adjacent movi/shori instructions with the same destination register
so we can print the accumulated value.

Print symbols, if possible, when decoding "pta" branch targets, and
"movi"/"shori" accumulated values.
2002-09-01 22:39:56 +00:00
scw f387921c31 Move registers r10-r13 over to the Caller-saved set, at least as far
as intrframe and trapframe are concerned.

According to the ABI, only the low 32-bits of these registers are
guaranteed to be preserved by the callee. Therefore, we need to
preserve all 64-bits of them in the interrupt trampoline.
2002-09-01 11:40:54 +00:00
scw 75c81c5275 Blah, some of the larger operands could overflow the "opstr" buffer.
Bump the size of all of them to be on the safe side.
2002-09-01 10:07:25 +00:00
scw d73a178b6b Output a new-line character after disassembling the opcode. 2002-09-01 09:18:52 +00:00
scw 5938c04bbe Yay, single-step now works.
Also do a wee bit tidying up.
2002-09-01 09:01:33 +00:00
scw 1398cd2898 Verify that the lowest 4 bits of the opcode are zero before disassembling.
According to the docs, opcode 0x6ff4fff0 is gauranteed to generate
a RESINST exception on all implementations, so disassemble it as "illegal".
2002-09-01 09:00:35 +00:00
scw 4c7d945594 A full SHmedia disassembler for ddb(9).
ToDo:
 - Symbol support (can't test as yet, due to lack of symbols),
 - Take notice of adjacent "movi/shori" instructions in order to display
   the resulting 32/64-bit value, with symbol lookup if possible.
2002-08-31 22:21:39 +00:00
scw 63fee282ed Always panic in the default/dopanic case, even if kdb_trap() returns. 2002-08-31 09:41:05 +00:00
scw da6c509ffa Pick a better T_NMI code. The previous one clashed with T_AST|T_USER. 2002-08-31 09:25:53 +00:00
scw c2aa4b74c8 Don't use "Branch Likely" for the NMI case. 2002-08-31 09:25:24 +00:00
scw 9a6575c7df Add T_NMI. 2002-08-31 09:12:59 +00:00
scw d7dbb0862d Deal with NMIs by jumping through the normal trap() code path.
At the very least, this will dump the machine state. At best,
we get into ddb().

This provides a useful way to regain control using an NMI button
if the cpu decides to spin at a high ipl.
2002-08-31 09:11:56 +00:00
scw 17746914f0 Small simplification to the splx() code path when dealing with soft
interrupts, and fix a couple of nits in the generic soft interrupt code.

Soft interrupts now work.
2002-08-31 08:42:00 +00:00
scw 60bff6ed9c Make sure to sign-extend PTEH/PTEL values before writing to the TLBs.
Make sure to zero-extend PTEH/PTEL values before comparing with TLB entries.
Don't use the two LSBs of CTC when choosing a "random" TLB entry to replace;
seems like these bits are always zero on this CPU.
2002-08-30 13:54:16 +00:00
scw ec32f137a2 Add byte_swap.h 2002-08-30 10:50:55 +00:00
scw 5bb390ef0d Re-arrange the endian/byteswap headers a bit by splitting off the
byte swap code into a separate file and renaming them.
Fix a typo which prevented ntohX and htonX macros DTRT for
little-endian mode.
2002-08-30 10:50:06 +00:00
scw 7958409b89 If running on the simulator, use a much lower buzz-loop count when
waiting for ACKs from the DTF host, otherwise the simulator waits
way too long for the initial open-ACK (which never seems to arrive,
even though things work fine afterwards).
2002-08-30 10:45:31 +00:00
scw 986af15320 Setup the IRL[0-3] mode according to what the kernel config file specifies. 2002-08-30 10:41:24 +00:00
scw 14b4efaf64 If running on the simulator, skip the pbridge probe. 2002-08-30 10:39:26 +00:00
scw f8f7664ef6 Defflag/param some options for:
- selecting Simulator/ST50 Debugger targets,
  - hard-coding the cpu speed instead of using the speed detection code,
  - changing the default kernel IPT size,
  - selecting the IRL[0-3] mode to configure in the interrupt controller.
2002-08-30 10:29:35 +00:00
scw 1256340461 Add the frame pointer (r14) to the list of registers to save in
the pcb during a context switch.
2002-08-29 16:04:10 +00:00
scw 9af86f9bf3 Oops, got the source operands for an "andc" reversed.
This gets the hardware interrupt event handler working.
2002-08-28 21:05:25 +00:00
scw f6e3925495 Set the appropriate Timer Start bit after setting it all up. 2002-08-26 10:48:17 +00:00
scw aba39b410c Don't forget to initialise 'sc' on entry to the attach function ... 2002-08-26 10:45:55 +00:00
scw a1ed033a09 Hardcode FEMI base and top addresses, at least until I figure out
how to interpet VCR.MB_TOP and VCR.MB_BOT in some reasonable way.
2002-08-26 10:43:44 +00:00
scw 3ad3b8c856 Add MD ddb(4) files. 2002-08-26 10:39:43 +00:00
scw a57d38854c Save SSR and SPC while in the critical section of an exception. The
previous behaviour of storing them with SR.BL clear was in breach
of the SH5 documentation.

Make an effort to catch PANIC traps and dump machine state to the console.
2002-08-26 10:38:52 +00:00
scw 40f78dcc13 Use pmap_map_device() to map device registers. 2002-08-26 10:35:40 +00:00
scw 8bd3eb387d Don't block exceptions in the initial SR value. 2002-08-26 10:34:43 +00:00
scw 10ce1fc51b s/pmap_bootstrap_mapping/pmap_map_device/ 2002-08-26 10:33:33 +00:00
scw abc568b5e1 In cpu_fork(), if p1 == curproc, call sh5_savectx() to ensure the
pcb contains valid state before copying it to p2's pcb.
Previously, we just lazy-sync the fpu state. This wasn't quite good
enough if p1 had not previously slept.
2002-08-26 10:32:55 +00:00
scw 0a00df79a0 Initialise to zero the memory allocated for interrupt handles. 2002-08-26 10:26:28 +00:00
scw d2c90421b8 Enable h/w interrupts before returning from cpu_configure(). 2002-08-26 10:24:57 +00:00
scw bc8042954a - Add a debug check for SR.BL being set on entry to cpu_switch().
- Add sh5_savectx()
- Fix a branch target register botch in sh5_fpsave() and sh5_fprestore().
2002-08-26 10:23:56 +00:00
scw 7bd8b94a66 Wrap dump_kipt() in #ifdef DDB. 2002-08-26 10:21:54 +00:00
scw d8f6a57b15 Re-work pmap_bootstrap_mapping() to pmap_map_device() to provide a
way for bus_space(9) to efficiently map device memory. (Although at
the moment, it doesn't quite work as efficiently as it will down
the line ...)

Fix a pool_init() botch.

Add a debug aid: dump_kipt(). This can be called from ddb(4) in order
to (partially) dump the contents of the kernel IPT.
2002-08-26 10:21:04 +00:00
scw 2774f9d77b Basic ddb(4) support.
Still to do:
 - disassembly
 - breakpoints
 - single-step
 - stack trace
2002-08-26 10:16:44 +00:00
scw 16ba45622a - Drop to ddb(4) on kernel traps.
- Dump more machine state on kernel traps (for when ddb isn't an option).
- Add rudimentary support for PANIC exceptions.
2002-08-26 10:14:02 +00:00
scw d454acf190 Disable the checks for unsupported hz values for now. At least until I
can fix the peripheral bridge's PLL1 clock ratio.
2002-08-26 10:10:22 +00:00
scw b5273356dc - Invalidate insn/operand caches before setting up the mmu for the first time.
- Clear SR.FD to enable the FPU. Seems like it starts up disabled. If the
  core has no FPU, this is a nop.

- Preserve the debug bits (step/watch) in an attempt to appease the debugger.
2002-08-26 10:08:02 +00:00
scw 911776caaf Impose a limit on the time we spin waiting for the DTF host to ack
our packet. Seems like the ack for the initial posix console "open"
packet never arrives, even though it completes successfully.
2002-08-26 10:04:05 +00:00
briggs 0b956d0b8b Implement pmc(9) -- An interface to hardware performance monitoring
counters.  These counters do not exist on all CPUs, but where they
do exist, can be used for counting events such as dcache misses that
would otherwise be difficult or impossible to instrument by code
inspection or hardware simulation.

pmc(9) is meant to be a general interface.  Initially, the Intel XScale
counters are the only ones supported.
2002-08-07 05:14:47 +00:00
scw a486314d8a Apply thorpej's recent All-Ports conf.c change. Seems SH5 slipped
through the net the first time around. Here's the relevant snippet
of the original commit message:

Rename cdev_systrace_init() to cdev_clonemisc_init(), so it can
be properly used by any misc. cloning device.
2002-07-19 18:53:15 +00:00
scw d911ae5d57 SH5 systrace(5) glue. 2002-07-12 20:43:12 +00:00
scw 6daca7f652 Ditch the "simulated clock" hack. It would never really have worked,
and the latest simulator won't need it anyway.
2002-07-12 19:52:21 +00:00
scw e9688612da Make it so kernels can be compiled for 32-bit or 64-bit with a
simple config file option.

Also, don't hard code the endian setting in a header file. Rely instead
on the compiler defining __LITTLE_ENDIAN__ and DTRT as appropriate.
2002-07-12 19:33:27 +00:00
scw 3a5b311011 Cast a pointer to uintptr_t before comparing with a long int. 2002-07-12 19:27:32 +00:00
scw c02c1c7cd2 Clean up <sh5/asm.h> to be more 64-bit friendly.
Clean up the kernel asm files to be less 32-bit dependent.
2002-07-12 15:42:27 +00:00
scw 1664941b2c Blah, missed a comma. 2002-07-12 13:37:32 +00:00
scw 2675306718 Add IEEE FP mode control functions and definitions for SH5. 2002-07-12 12:20:24 +00:00
scw 67ea1085eb Add MD procfs stub for SH5. 2002-07-12 11:20:12 +00:00
scw 270555326f More SH5 toolchain hacks: Don't define _BSD_WCHAR_T if compiling C++. 2002-07-12 11:19:08 +00:00
scw 60fb656ee5 Validate the branch target registers and saved PC using the
appropriate macro.
2002-07-11 21:23:30 +00:00
scw 14013f679d Add a macro which verifies that a 64-bit value is a valid effective
address as defined by the cpu's Implemented Effective Address bits.
2002-07-11 21:21:58 +00:00
scw d08670adc8 Sync with reality. 2002-07-11 21:20:23 +00:00
scw 0d0a6374ef Some cleanups for the MACHINE_ARCH endian suffix change. 2002-07-11 14:42:55 +00:00
scw d55184012a Cleanup the sigcontext structure, and sync {,sig}jmp_buf size and
offsets with it.
2002-07-11 14:16:42 +00:00
scw 5c90e3c0d6 In sys___sigreturn14(), validate the saved branch target registers and
program counter to avoid a possible kernel-mode IADDERR exception when
we try to restore the trapframe on return to user-mode.
2002-07-11 14:15:32 +00:00
scw 384b76c19b Install <sh5/pte.h> for the benefit of cpu.h. 2002-07-11 14:11:18 +00:00
scw e0e8310758 Include <machine/frame.h>, not <sh5/frame.h> 2002-07-11 14:10:39 +00:00
scw 026df6bf33 Cleanup the frame link/unlink macroes. 2002-07-11 14:09:34 +00:00
scw b234c1aa10 Moved MID_MACHINE definition from <machine/param.h> 2002-07-11 14:08:45 +00:00
scw 52876ee77d First cut of the kernel side support for sh5 signals. 2002-07-10 15:55:01 +00:00
scw 528a743ee9 Update sh5_fpsave() prototype to match reality. 2002-07-10 15:53:57 +00:00
scw a30ba3dd9a Need <sys/types.h> 2002-07-10 15:52:49 +00:00
scw f78244feaf Before returning to userland, clear the FPU regs saved flag. 2002-07-10 15:52:07 +00:00
scw 0f3678d589 Track FPU register save status. 2002-07-10 15:49:33 +00:00
scw 51f3f8ff9c More superh toolchain hacks. This time, it expects wchar_t to be a short. 2002-07-10 12:23:08 +00:00
scw 187f1ae3a1 Some hacks which will go away when we switch to a native NetBSD toolchain.
The SuperH compiler erroneously prepends underscores to global syms...
2002-07-10 11:36:23 +00:00
scw 5f0c27f158 Missed some semi-colons. 2002-07-10 11:31:25 +00:00
scw 0b074fa253 SH5 floating point support, based on sh3. 2002-07-10 10:38:22 +00:00
scw f616928985 Doh, missed a #endif 2002-07-10 10:30:19 +00:00
scw ea38860915 SH5 profiling support. 2002-07-10 10:24:16 +00:00
scw c7510b3b78 Fix FP reg names 2002-07-10 10:22:43 +00:00
scw 293298968a Descend into include subdirs and install relevant headers. 2002-07-10 08:56:11 +00:00
scw 8324df7cf0 Sync the ktrsyscall() arguments with -current reality. 2002-07-05 14:05:58 +00:00
scw 63fd77b84b Sync the sendsig() argument list with -current reality. 2002-07-05 14:04:00 +00:00
scw 8aecaeac04 Roll our own CWARNFLAGS. There are some things in MI code which the
SuperH version of gcc barfs over.
2002-07-05 14:02:31 +00:00
scw 59474a8c82 NetBSD, meet the SH-5 cpu.
SH-5, meet NetBSD.

Let's hope this is the start of a long and fruitful relationship. :-)

This code, funded by Wasabi Systems, adds initial support for the
Hitachi SuperH(tm) SH-5 cpu architecture to NetBSD.

At the present time, NetBSD/evbsh5 only runs on a SH-5 core simulator
which has no simulated devices other than a simple console. However, it
is good enough to get to the "root device: " prompt.

Device driver support for Real SH-5 Hardware is in place, particularly for
supporting the up-coming Cayman evaluation board, and should be quite
easy to get running when the hardware is available.

There is no in-tree toolchain for this port at this time. Gcc-current has
rudimentary SH-5 support but it is known to be buggy. A working toolchain
was obtained from SuperH to facilitate this port. Gcc-current will be
fixed in due course.

The SH-5 architecture is fully 64-bit capable, although NetBSD/evbsh5 has
currently only been tested in 32-bit mode. It is bi-endian, via a boot-
time option and it also has an "SHcompact" mode in which it will execute
SH-[34] user-land instructions.

For more information on the SH-5, see www.superh.com. Suffice to say it
is *not* just another respin of the SH-[34].
2002-07-05 13:31:28 +00:00