Initial import of NetBSD/ews4800mips port,
for NEC's MIPS based EWS4800 workstations. Most porting work was done by UCHIYAMA Yasushi <uch@netbsd> http://mail-index.netbsd.org/port-mips/2004/06/27/0000.html and various cleanup, updating, and fixes have been done by me. Currently only EWS4800/350, 360, 360AD, 360ADII, 360EX and 360SX models are supported.
This commit is contained in:
parent
34c323c9f0
commit
04faabf071
|
@ -0,0 +1,5 @@
|
|||
# $NetBSD: Makefile,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
|
||||
SUBDIR= compile include stand
|
||||
|
||||
.include <bsd.subdir.mk>
|
|
@ -0,0 +1,3 @@
|
|||
# $NetBSD: Makefile,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -0,0 +1,300 @@
|
|||
# $NetBSD: GENERIC,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
# This machine description file is used to generate the default NetBSD
|
||||
# kernel. The generic kernel does not include all options, subsystems
|
||||
# and device drivers, but should be useful for most applications.
|
||||
#
|
||||
# The machine description file can be customised for your specific
|
||||
# machine to reduce the kernel size and improve its performance.
|
||||
#
|
||||
# For further information on compiling NetBSD kernels, see the config(8)
|
||||
# man page.
|
||||
#
|
||||
# For further information on hardware support for this architecture, see
|
||||
# the intro(4) man page. For further information about kernel options
|
||||
# for this architecture, see the options(4) man page. For an explanation
|
||||
# of each device driver in this file see the section 4 man page for the
|
||||
# device.
|
||||
|
||||
#
|
||||
# kernel config file for EWS4800/350, 360AD, 360ADII
|
||||
#
|
||||
|
||||
include "arch/ews4800mips/conf/std.ews4800mips"
|
||||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.1 $"
|
||||
|
||||
maxusers 16
|
||||
|
||||
#options MIPS1 # R2000/R3000
|
||||
options MIPS3 # R4000/R4400
|
||||
|
||||
# MIPS3 on-chip timer interrupt is not used on EWS4800,
|
||||
# but the external timer interrupt line is connected to CPU INT5.
|
||||
options MIPS3_ENABLE_CLOCK_INTR
|
||||
|
||||
# Support for specific models
|
||||
options EWS4800_TR2 # 350
|
||||
options EWS4800_TR2A # 360,360AD,360ADII,360SX,360BX
|
||||
|
||||
# Standard system options
|
||||
options NTP # NTP phase/frequency locked loop
|
||||
|
||||
options KTRACE # system call tracing ktrace(1)
|
||||
options SYSTRACE # system call vetting via systrace(1)
|
||||
|
||||
options SYSVMSG # System V-like message queues
|
||||
options SYSVSEM # System V-like semaphores
|
||||
options SEMMNI=10 # number of semaphore identifiers
|
||||
#options SEMMNS=60 # number of semaphores in system
|
||||
#options SEMUME=10 # max number of undo entries per process
|
||||
#options SEMMNU=30 # number of undo structures in system
|
||||
options SYSVSHM # System V shared memory
|
||||
#options SHMMAXPGS=1024 # 1024 pages is the default
|
||||
options P1003_1B_SEMAPHORE # p1003.1b semaphore support
|
||||
|
||||
options LKM # loadable kernel modules
|
||||
|
||||
options USERCONF # userconf(4) support
|
||||
#options PIPE_SOCKETPAIR # smaller, but slower pipe(2)
|
||||
options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel
|
||||
|
||||
# Enable experimental buffer queue strategy for better responsiveness under
|
||||
# high disk I/O load. Likely stable but not yet the default.
|
||||
#options BUFQ_READPRIO
|
||||
#options BUFQ_PRIOCSCAN
|
||||
|
||||
# Diagnostic/debugging support options
|
||||
#options DIAGNOSTIC # expensive kernel consistency checks
|
||||
#options DEBUG # extra kernel debugging support
|
||||
#options KMEMSTATS # kernel memory statistics (vmstat -m)
|
||||
options DDB # in-kernel debugger
|
||||
#options DDB_ONPANIC=1 # see also sysctl(8): `ddb.onpanic'
|
||||
#options DDB_HISTORY_SIZE=512 # enable history editing in DDB
|
||||
#makeoptions DEBUG="-g" # compile full symbol table
|
||||
|
||||
# Compatibility options
|
||||
#options COMPAT_10 # NetBSD 1.0
|
||||
#options COMPAT_11 # NetBSD 1.1
|
||||
#options COMPAT_12 # NetBSD 1.2
|
||||
options COMPAT_13 # NetBSD 1.3
|
||||
options COMPAT_14 # NetBSD 1.4
|
||||
options COMPAT_16 # NetBSD 1.6
|
||||
options COMPAT_20 # NetBSD 2.0
|
||||
options COMPAT_30 # NetBSD 3.0
|
||||
options COMPAT_43 # 4.3BSD
|
||||
#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.
|
||||
|
||||
#options COMPAT_LINUX # binary compatibility with Linux
|
||||
options COMPAT_BSDPTY # /dev/[pt]ty?? ptys.
|
||||
|
||||
# File systems
|
||||
file-system FFS # fast filesystem with user and group quotas
|
||||
file-system EXT2FS # second extended file system (linux)
|
||||
file-system LFS # log-structured file system
|
||||
file-system MFS # memory file system
|
||||
file-system NFS # Network File System client
|
||||
#file-system NTFS # Windows/NT file system (experimental)
|
||||
file-system CD9660 # ISO 9660 + Rock Ridge file system
|
||||
file-system MSDOSFS # MS-DOS file system
|
||||
file-system FDESC # /dev/fd
|
||||
file-system KERNFS # /kern
|
||||
file-system NULLFS # loopback file system
|
||||
file-system OVERLAY # overlay file system
|
||||
file-system PORTAL # portal file system (still exxperimental)
|
||||
file-system PROCFS # /proc
|
||||
file-system UMAPFS # NULLFS + uid and gid remapping
|
||||
file-system UNION # union file system
|
||||
#file-system CODA # Coda file system; also needs vcoda (below)
|
||||
#file-system SMBFS # experimental - CIFS; also needs nsmb (below)
|
||||
file-system SYSVBFS # System V boot filesystem.
|
||||
file-system PTYFS # /dev/pts/N support
|
||||
#file-system TMPFS # experimental - Efficient memory file-system
|
||||
|
||||
# File system options
|
||||
options QUOTA # UFS quotas
|
||||
#options FFS_EI # FFS Endian Indpendent support
|
||||
options SOFTDEP # FFS soft updates support.
|
||||
#options UFS_DIRHASH # UFS Large Directory Hashing - Experimental
|
||||
options NFSSERVER # Network File System server
|
||||
#options FFS_NO_SNAPSHOT # no FFS snapshot support
|
||||
#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
|
||||
# immutable) behave as system flags.
|
||||
|
||||
# Networking options
|
||||
#options GATEWAY # packet forwarding
|
||||
options INET # IP + ICMP + TCP + UDP
|
||||
options INET6 # IPV6
|
||||
#options IPSEC # IP security
|
||||
#options IPSEC_ESP # IP security (encryption part; define w/IPSEC)
|
||||
#options IPSEC_NAT_T # IPsec NAT traversal (NAT-T)
|
||||
#options IPSEC_DEBUG # debug for IP security
|
||||
#options MROUTING # IP multicast routing
|
||||
#options PIM # Protocol Independent Multicast
|
||||
#options NS # XNS
|
||||
#options NSIP # XNS tunneling over IP
|
||||
#options ISO,TPIP # OSI
|
||||
#options EON # OSI tunneling over IP
|
||||
#options CCITT,LLC,HDLC # X.25
|
||||
options NETATALK # AppleTalk networking protocols
|
||||
options PPP_BSDCOMP # BSD-Compress compression support for PPP
|
||||
options PPP_DEFLATE # Deflate compression support for PPP
|
||||
options PPP_FILTER # Active filter support for PPP (requires bpf)
|
||||
options PFIL_HOOKS # pfil(9) packet filter hooks
|
||||
options IPFILTER_LOG # ipmon(8) log support
|
||||
#options IPFILTER_DEFAULT_BLOCK # block all packets by default
|
||||
#options TCP_DEBUG # Record last TCP_NDEBUG packets with SO_DEBUG
|
||||
|
||||
#options ALTQ # Manipulate network interfaces' output queues
|
||||
#options ALTQ_BLUE # Stochastic Fair Blue
|
||||
#options ALTQ_CBQ # Class-Based Queueing
|
||||
#options ALTQ_CDNR # Diffserv Traffic Conditioner
|
||||
#options ALTQ_FIFOQ # First-In First-Out Queue
|
||||
#options ALTQ_FLOWVALVE # RED/flow-valve (red-penalty-box)
|
||||
#options ALTQ_HFSC # Hierarchical Fair Service Curve
|
||||
#options ALTQ_LOCALQ # Local queueing discipline
|
||||
#options ALTQ_PRIQ # Priority Queueing
|
||||
#options ALTQ_RED # Random Early Detection
|
||||
#options ALTQ_RIO # RED with IN/OUT
|
||||
#options ALTQ_WFQ # Weighted Fair Queueing
|
||||
|
||||
# These options control the verified exec feature
|
||||
#options VERIFIED_EXEC
|
||||
#
|
||||
# Uncomment the fingerprint methods below that are desired. Note that
|
||||
# removing fingerprint methods will have almost no impact on the kernel
|
||||
# code size.
|
||||
#
|
||||
#options VERIFIED_EXEC_FP_RMD160
|
||||
#options VERIFIED_EXEC_FP_SHA256
|
||||
#options VERIFIED_EXEC_FP_SHA384
|
||||
#options VERIFIED_EXEC_FP_SHA512
|
||||
#options VERIFIED_EXEC_FP_SHA1
|
||||
#options VERIFIED_EXEC_FP_MD5
|
||||
|
||||
# These options enable verbose messages for several subsystems.
|
||||
# Warning, these may compile large string tables into the kernel!
|
||||
options SCSIVERBOSE # human readable SCSI error messages
|
||||
|
||||
options NFS_BOOT_DHCP
|
||||
|
||||
|
||||
# workstation console options
|
||||
options WSEMUL_VT100 # VT100 / VT220 emulation
|
||||
options WS_KERNEL_FG=WSCOL_GREEN
|
||||
options WS_KERNEL_BG=WSCOL_BLACK
|
||||
|
||||
options FONT_GALLANT12x22
|
||||
#options FONT_SONY12x24
|
||||
|
||||
config netbsd root on ? type ?
|
||||
|
||||
#
|
||||
# Device configuration
|
||||
#
|
||||
|
||||
mainbus0 at root
|
||||
|
||||
cpu0 at mainbus?
|
||||
|
||||
sbdio0 at mainbus?
|
||||
|
||||
mkclock0 at sbdio?
|
||||
|
||||
#kbms* at sbdo?
|
||||
#wskbd0 at kbms? console ?
|
||||
#wsmouse0 at kbms?
|
||||
|
||||
ewskbd0 at zsc?
|
||||
wskbd* at ewskbd?
|
||||
ewsms0 at zsc?
|
||||
wsmouse* at ewsms?
|
||||
|
||||
fb* at sbdio?
|
||||
wsdisplay* at fb? console ?
|
||||
|
||||
zsc0 at sbdio?
|
||||
zstty0 at zsc0 channel 0 # SIO ch-A
|
||||
zstty1 at zsc0 channel 1 # SIO ch-B
|
||||
|
||||
# Disk
|
||||
osiop* at sbdio? flags 0x0000
|
||||
scsibus* at scsi?
|
||||
|
||||
sd* at scsibus? target ? lun ? # SCSI disk drives
|
||||
st* at scsibus? target ? lun ? # SCSI tape drives
|
||||
cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
|
||||
ch* at scsibus? target ? lun ? # SCSI autochangers
|
||||
ses* at scsibus? target ? lun ? # SCSI Enclosure Services devices
|
||||
ss* at scsibus? target ? lun ? # SCSI scanners
|
||||
uk* at scsibus? target ? lun ? # SCSI unknown
|
||||
|
||||
# Ether
|
||||
iee* at sbdio? # TR2
|
||||
le* at sbdio? # TR2A
|
||||
|
||||
|
||||
# Pseudo-Devices
|
||||
|
||||
# disk/mass strage pseudo-devices
|
||||
pseudo-device ccd 4 # concatenated/striped disk devices
|
||||
#pseudo-device cgd 4 # cryptographic disk devices
|
||||
pseudo-device raid 8 # RAIDframe disk driver
|
||||
options RAID_AUTOCONFIG # auto-configuration of RAID components
|
||||
# Options to enable various other RAIDframe RAID types.
|
||||
#options RF_INCLUDE_EVENODD=1
|
||||
#options RF_INCLUDE_RAID5_RS=1
|
||||
#options RF_INCLUDE_PARITYLOGGING=1
|
||||
#options RF_INCLUDE_CHAINDECLUSTER=1
|
||||
#options RF_INCLUDE_INTERDECLUSTER=1
|
||||
#options RF_INCLUDE_PARITY_DECLUSTERING=1
|
||||
#options RF_INCLUDE_PARITY_DECLUSTERING_DS=1
|
||||
pseudo-device fss 4 # file system snapshot device
|
||||
|
||||
# Vinum
|
||||
#pseudo-device vinum 8 # Vinum
|
||||
#options VINUMDEBUG
|
||||
|
||||
pseudo-device md 1 # memory disk device (ramdisk)
|
||||
pseudo-device vnd 4 # virtual disk ick
|
||||
options VND_COMPRESSION # compressed vnd(4)
|
||||
|
||||
# network pseudo-devices
|
||||
pseudo-device bpfilter 8 # packet filter ports
|
||||
pseudo-device ipfilter # IP filter, NAT
|
||||
pseudo-device loop # network loopback
|
||||
pseudo-device ppp 2 # Point-to-Point Protocol
|
||||
pseudo-device pppoe # PPP over Ethernet (RFC 2516)
|
||||
pseudo-device sl 2 # Serial Line IP
|
||||
pseudo-device strip 2 # Starmode Radio IP (Metricom)
|
||||
#pseudo-device irframetty # IrDA frame line discipline
|
||||
pseudo-device tap # virtual Ethernet
|
||||
pseudo-device tun 2 # network tunneling over tty
|
||||
pseudo-device gre 2 # generic L3 over IP tunnel
|
||||
pseudo-device gif 4 # IPv[46] over IPv[46] tunnel (RFC1933)
|
||||
#pseudo-device faith 1 # IPv[46] tcp relay translation i/f
|
||||
#pseudo-device stf 1 # 6to4 IPv6 over IPv4 encapsulation
|
||||
pseudo-device vlan # IEEE 802.1q encapsulation
|
||||
pseudo-device bridge # simple inter-network bridging
|
||||
#options BRIDGE_IPF # bridge uses IP/IPv6 pfil hooks too
|
||||
#pseudo-device pf # PF packet filter
|
||||
#pseudo-device pflog # PF log if
|
||||
|
||||
# miscellaneous pseudo-devices
|
||||
pseudo-device pty # pseudo-terminals
|
||||
#pseudo-device tb 1 # tablet line discipline
|
||||
pseudo-device rnd # /dev/random and in-kernel generator
|
||||
pseudo-device clockctl # user control of clock subsystem
|
||||
pseudo-device ksyms # /dev/ksyms
|
||||
|
||||
# a pseudo device needed for Coda # also needs CODA (above)
|
||||
#pseudo-device vcoda 4 # coda minicache <-> venus comm.
|
||||
|
||||
# a pseudo device needed for SMBFS
|
||||
#pseudo-device nsmb # experimental - SMB requester
|
||||
|
||||
# wscons pseudo-devices
|
||||
pseudo-device wsmux
|
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# kernel config file for memory(RAM) disk
|
||||
#
|
||||
# $NetBSD: RAMDISK,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
#
|
||||
|
||||
include "arch/ews4800mips/conf/GENERIC"
|
||||
|
||||
# Enable the hooks used for initializing the root memory-disk.
|
||||
options MEMORY_DISK_HOOKS
|
||||
options MEMORY_DISK_IS_ROOT # force root on memory disk
|
||||
options MEMORY_DISK_SERVER=0 # no userspace memory disk support
|
||||
options MEMORY_DISK_ROOT_SIZE=10000 # size of memory disk, in blocks
|
|
@ -0,0 +1,117 @@
|
|||
# $NetBSD: files.ews4800mips,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
|
||||
maxpartitions 16
|
||||
|
||||
maxusers 2 8 64
|
||||
|
||||
include "arch/ews4800mips/conf/majors.ews4800mips"
|
||||
|
||||
file arch/mips/mips/softintr.c
|
||||
|
||||
file arch/ews4800mips/ews4800mips/autoconf.c
|
||||
file arch/ews4800mips/ews4800mips/interrupt.c
|
||||
file arch/ews4800mips/ews4800mips/bus_space.c
|
||||
file arch/ews4800mips/ews4800mips/bus_dma.c
|
||||
file arch/ews4800mips/ews4800mips/clock.c
|
||||
file arch/ews4800mips/ews4800mips/machdep.c
|
||||
file arch/ews4800mips/ews4800mips/disklabel_conv.c disk
|
||||
file arch/ews4800mips/ews4800mips/disksubr.c disk
|
||||
file arch/ews4800mips/ews4800mips/pdinfo.c disk
|
||||
file arch/ews4800mips/ews4800mips/sector.c disk
|
||||
file arch/ews4800mips/ews4800mips/vtoc.c disk
|
||||
|
||||
file arch/ews4800mips/ews4800mips/cons_machdep.c
|
||||
file dev/cons.c
|
||||
|
||||
file dev/md_root.c memory_disk_hooks
|
||||
|
||||
|
||||
# system board
|
||||
defflag opt_sbd.h EWS4800_TR2 # EWS4800/350
|
||||
EWS4800_TR2A # EWS4800/360,360AD,ADII
|
||||
|
||||
file arch/ews4800mips/ews4800mips/sbd.c
|
||||
|
||||
# TR2
|
||||
file arch/ews4800mips/ews4800mips/tr2.c ews4800_tr2
|
||||
file arch/ews4800mips/ews4800mips/tr2_intr.c ews4800_tr2
|
||||
|
||||
# TR2A
|
||||
file arch/ews4800mips/ews4800mips/tr2a.c ews4800_tr2a
|
||||
file arch/ews4800mips/ews4800mips/tr2a_intr.c ews4800_tr2a
|
||||
|
||||
|
||||
device mainbus { }
|
||||
attach mainbus at root
|
||||
file arch/ews4800mips/ews4800mips/mainbus.c mainbus
|
||||
|
||||
device cpu
|
||||
attach cpu at mainbus
|
||||
file arch/ews4800mips/ews4800mips/cpu.c cpu
|
||||
|
||||
#
|
||||
# Workstation Console
|
||||
#
|
||||
include "dev/wscons/files.wscons"
|
||||
include "dev/wsfont/files.wsfont"
|
||||
include "dev/rasops/files.rasops"
|
||||
|
||||
#
|
||||
# Machine-independent SCSI drivers
|
||||
#
|
||||
include "dev/scsipi/files.scsipi"
|
||||
|
||||
#
|
||||
# VME
|
||||
#
|
||||
include "dev/vme/files.vme"
|
||||
|
||||
#
|
||||
# System board I/O device
|
||||
#
|
||||
device sbdio { }
|
||||
attach sbdio at mainbus
|
||||
file arch/ews4800mips/sbd/sbdio.c sbdio
|
||||
|
||||
device zsc { [channel = -1] }
|
||||
file arch/ews4800mips/dev/zs.c zsc needs-count
|
||||
file dev/ic/z8530sc.c zsc
|
||||
|
||||
attach zsc at sbdio with zsc_sbdio
|
||||
file arch/ews4800mips/sbd/zs_sbdio.c zsc_sbdio needs-flag
|
||||
|
||||
device zstty: tty
|
||||
attach zstty at zsc
|
||||
file dev/ic/z8530tty.c zstty needs-count
|
||||
|
||||
device kbms: wskbddev, wsmousedev
|
||||
attach kbms at sbdio with kbms_sbdio
|
||||
file arch/ews4800mips/sbd/kbms_sbdio.c kbms_sbdio needs-flag
|
||||
|
||||
device ewskbd: wskbddev
|
||||
attach ewskbd at zsc with ewskbd_zsc
|
||||
file arch/ews4800mips/dev/ews4800keymap.c ewskbd | kbms
|
||||
file arch/ews4800mips/dev/ewskbd.c ewskbd_zsc needs-flag
|
||||
|
||||
device ewsms: wsmousedev
|
||||
attach ewsms at zsc with ewsms_zsc
|
||||
file arch/ews4800mips/dev/ewsms.c ewsms_zsc
|
||||
|
||||
device mkclock: mk48txx
|
||||
attach mkclock at sbdio with mkclock_sbdio
|
||||
file arch/ews4800mips/sbd/mkclock_sbdio.c mkclock_sbdio
|
||||
|
||||
device iee: ifnet, ether, arp, i82596
|
||||
attach iee at sbdio with iee_sbdio
|
||||
file arch/ews4800mips/sbd/if_iee_sbdio.c iee_sbdio
|
||||
|
||||
attach le at sbdio with le_sbdio: le24
|
||||
file arch/ews4800mips/sbd/if_le_sbdio.c le_sbdio
|
||||
|
||||
attach osiop at sbdio with osiop_sbdio
|
||||
file arch/ews4800mips/sbd/osiop_sbdio.c osiop_sbdio
|
||||
|
||||
device fb: wsemuldisplaydev, rasops8
|
||||
attach fb at sbdio with fb_sbdio
|
||||
file arch/ews4800mips/dev/ga.c fb
|
||||
file arch/ews4800mips/sbd/fb_sbdio.c fb_sbdio needs-flag
|
|
@ -0,0 +1,44 @@
|
|||
# $NetBSD: majors.ews4800mips,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
#
|
||||
# Device majors for ews4800mips
|
||||
#
|
||||
|
||||
device-major mem char 0
|
||||
device-major swap char 1 block 0 vmswap
|
||||
device-major cons char 2
|
||||
device-major ctty char 3
|
||||
device-major filedesc char 4
|
||||
device-major log char 5
|
||||
device-major ptc char 6 pty
|
||||
device-major pts char 7 pty
|
||||
device-major lkm char 8 lkm
|
||||
device-major zstty char 9 zstty
|
||||
|
||||
device-major md char 12 block 6 md
|
||||
device-major ccd char 13 block 7 ccd
|
||||
device-major vnd char 14 block 8 vnd
|
||||
device-major raid char 15 block 9 raid
|
||||
device-major scsibus char 16 scsibus
|
||||
device-major sd char 17 block 3 sd
|
||||
device-major st char 18 block 4 st
|
||||
device-major cd char 19 block 5 cd
|
||||
device-major ch char 20 ch
|
||||
device-major uk char 21 uk
|
||||
device-major ss char 22 ss
|
||||
device-major ipl char 23 ipfilter
|
||||
device-major tun char 24 tun
|
||||
device-major bpf char 25 bpfilter
|
||||
device-major rnd char 26 rnd
|
||||
device-major wsdisplay char 27 wsdisplay
|
||||
device-major wskbd char 28 wskbd
|
||||
device-major wsmouse char 29 wsmouse
|
||||
device-major wsmux char 30 wsmux
|
||||
device-major clockctl char 38 clockctl
|
||||
device-major systrace char 39 systrace
|
||||
device-major cgd char 40 block 10 cgd
|
||||
device-major ksyms char 41 ksyms
|
||||
device-major wsfont char 42 wsfont
|
||||
|
||||
# Majors up to 143 are reserved for machine-dependant drivers.
|
||||
# New machine-independant driver majors are assigned in
|
||||
# sys/conf/majors.
|
|
@ -0,0 +1,12 @@
|
|||
# $NetBSD: std.ews4800mips,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
|
||||
machine ews4800mips mips
|
||||
makeoptions MACHINE_ARCH="mipseb"
|
||||
include "conf/std" # MI standart options
|
||||
|
||||
options EXEC_ELF32 # exec ELF32 binaries
|
||||
options EXEC_SCRIPT # exec #! scripts
|
||||
|
||||
options ENABLE_MIPS3_WIRED_MAP
|
||||
|
||||
makeoptions DEFTEXTADDR="0x80001000"
|
|
@ -0,0 +1,165 @@
|
|||
/* $NetBSD: ews4800keymap.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ews4800keymap.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsksymvar.h>
|
||||
|
||||
#include <ews4800mips/dev/ews4800keymap.h>
|
||||
|
||||
#define KC(n) KS_KEYCODE(n)
|
||||
|
||||
const keysym_t ews4800kbd_keydesc[] = {
|
||||
KC(0x00), KS_0,
|
||||
KC(0x01), KS_1, KS_exclam,
|
||||
KC(0x02), KS_2, KS_quotedbl,
|
||||
KC(0x03), KS_3, KS_numbersign,
|
||||
KC(0x04), KS_4, KS_dollar,
|
||||
KC(0x05), KS_5, KS_percent,
|
||||
KC(0x06), KS_6, KS_ampersand,
|
||||
KC(0x07), KS_7, KS_apostrophe,
|
||||
KC(0x08), KS_8, KS_parenleft,
|
||||
KC(0x09), KS_9, KS_parenright,
|
||||
KC(0x0a), KS_minus, KS_equal,
|
||||
KC(0x0b), KS_asciicircum, KS_grave,
|
||||
KC(0x0c), KS_backslash, KS_bar,
|
||||
KC(0x0d), KS_colon, KS_asterisk,
|
||||
KC(0x0e), KS_period, KS_greater,
|
||||
KC(0x0f), KS_slash, KS_question,
|
||||
KC(0x10), KS_at, KS_asciitilde,
|
||||
KC(0x11), KS_a,
|
||||
KC(0x12), KS_b,
|
||||
KC(0x13), KS_c,
|
||||
KC(0x14), KS_d,
|
||||
KC(0x15), KS_e,
|
||||
KC(0x16), KS_f,
|
||||
KC(0x17), KS_g,
|
||||
KC(0x18), KS_h,
|
||||
KC(0x19), KS_i,
|
||||
KC(0x1a), KS_j,
|
||||
KC(0x1b), KS_k,
|
||||
KC(0x1c), KS_l,
|
||||
KC(0x1d), KS_m,
|
||||
KC(0x1e), KS_n,
|
||||
KC(0x1f), KS_o,
|
||||
KC(0x20), KS_p,
|
||||
KC(0x21), KS_q,
|
||||
KC(0x22), KS_r,
|
||||
KC(0x23), KS_s,
|
||||
KC(0x24), KS_t,
|
||||
KC(0x25), KS_u,
|
||||
KC(0x26), KS_v,
|
||||
KC(0x27), KS_w,
|
||||
KC(0x28), KS_x,
|
||||
KC(0x29), KS_y,
|
||||
KC(0x2a), KS_z,
|
||||
KC(0x2b), KS_bracketleft, KS_braceleft,
|
||||
KC(0x2c), KS_comma, KS_less,
|
||||
KC(0x2d), KS_bracketright, KS_braceright,
|
||||
KC(0x2e), KS_semicolon, KS_plus,
|
||||
KC(0x2f), KS_underscore, KS_underscore,
|
||||
KC(0x30), KS_KP_0,
|
||||
KC(0x31), KS_KP_1,
|
||||
KC(0x32), KS_KP_2,
|
||||
KC(0x33), KS_KP_3,
|
||||
KC(0x34), KS_KP_4,
|
||||
KC(0x35), KS_KP_5,
|
||||
KC(0x36), KS_KP_6,
|
||||
KC(0x37), KS_KP_7,
|
||||
KC(0x38), KS_KP_8,
|
||||
KC(0x39), KS_KP_9,
|
||||
KC(0x40), KS_Return,
|
||||
KC(0x3a), KS_space,
|
||||
KC(0x3b), KS_comma,
|
||||
KC(0x3e), KS_Hiragana_Katakana, /* KANA */
|
||||
KC(0x41), KS_Return,
|
||||
KC(0x42), KS_Prior,
|
||||
KC(0x43), KS_Next,
|
||||
KC(0x44), KS_KP_Enter,
|
||||
KC(0x46), KS_minus,
|
||||
KC(0x47), KS_period,
|
||||
KC(0x48), KS_Left,
|
||||
KC(0x48), KS_Return,
|
||||
KC(0x49), KS_Right,
|
||||
KC(0x50), KS_BackSpace,
|
||||
KC(0x52), KS_Clear, KS_Home,
|
||||
KC(0x53), KS_Delete,
|
||||
KC(0x54), KS_Insert,
|
||||
KC(0x56), KS_Cmd_Screen0, KS_f1,
|
||||
KC(0x57), KS_Cmd_Screen1, KS_f2,
|
||||
KC(0x58), KS_Cmd_Screen2, KS_f3,
|
||||
KC(0x59), KS_Cmd_Screen3, KS_f4,
|
||||
KC(0x5a), KS_Cmd_Screen4, KS_f5,
|
||||
KC(0x5b), KS_Cmd_Screen5, KS_f6,
|
||||
KC(0x5c), KS_Cmd_Screen6, KS_f7,
|
||||
KC(0x5d), KS_Cmd_Screen7, KS_f8,
|
||||
KC(0x5e), KS_Cmd_Screen8, KS_f9,
|
||||
KC(0x5f), KS_Cmd_Screen9, KS_f10,
|
||||
KC(0x60), KS_f11, /* No key top print */
|
||||
KC(0x61), KS_f12, /* No key top print */
|
||||
KC(0x62), KS_f13, /* No key top print */
|
||||
KC(0x63), KS_f14, /* No key top print */
|
||||
KC(0x64), KS_f15, /* No key top print */
|
||||
KC(0x67), KS_Muhenkan, /* NFER */
|
||||
KC(0x68), KS_Henkan, /* XFER */
|
||||
KC(0x6a), KS_Up,
|
||||
KC(0x6b), KS_Down,
|
||||
KC(0x6d), KS_Meta_L, /* GRAPH */
|
||||
KC(0x70), KS_KP_Add,
|
||||
KC(0x71), KS_KP_Multiply,
|
||||
KC(0x72), KS_slash,
|
||||
KC(0x73), KS_Escape,
|
||||
KC(0x74), KS_Help,
|
||||
KC(0x75), KS_KP_Equal,
|
||||
KC(0x76), KS_Tab,
|
||||
KC(0x78), KS_Cmd1, KS_Control_L,
|
||||
KC(0x79), KS_Caps_Lock,
|
||||
KC(0x7b), KS_Shift_L,
|
||||
KC(0x7c), KS_Shift_R,
|
||||
KC(0x7e), KS_Cmd2, KS_Alt_L,
|
||||
KC(0x7f), KS_Cmd_Debugger, KS_Cmd1, /* FNC */
|
||||
};
|
||||
|
||||
const struct wscons_keydesc ews4800kbd_keydesctab[] = {
|
||||
{ KB_JP, 0, sizeof(ews4800kbd_keydesc) / sizeof(keysym_t),
|
||||
ews4800kbd_keydesc, },
|
||||
{ 0, 0, 0, NULL },
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ews4800keymap.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
extern const struct wscons_keydesc ews4800kbd_keydesctab[];
|
|
@ -0,0 +1,570 @@
|
|||
/* $NetBSD: ewskbd.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Izumi Tsutsui
|
||||
* Copyright (c) 2004 Steve Rumble
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* EWS4800 serial keyboard driver attached to zs channel 0 at 4800 bps.
|
||||
* This layer is the parent of wskbd.
|
||||
*
|
||||
* This driver is taken from sgimips.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ewskbd.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wskbdvar.h>
|
||||
#include <dev/wscons/wsksymdef.h>
|
||||
#include <dev/wscons/wsksymvar.h>
|
||||
|
||||
#include <dev/ic/z8530reg.h>
|
||||
#include <machine/z8530var.h>
|
||||
|
||||
#include <ews4800mips/dev/ews4800keymap.h>
|
||||
|
||||
#define EWSKBD_BAUD 4800
|
||||
|
||||
#define EWSKBD_TXQ_LEN 16 /* power of 2 */
|
||||
#define EWSKBD_TXQ_LEN_MASK (EWSKBD_TXQ_LEN - 1)
|
||||
#define EWSKBD_NEXTTXQ(x) (((x) + 1) & EWSKBD_TXQ_LEN_MASK)
|
||||
|
||||
#define EWSKBD_RXQ_LEN 64 /* power of 2 */
|
||||
#define EWSKBD_RXQ_LEN_MASK (EWSKBD_RXQ_LEN - 1)
|
||||
#define EWSKBD_NEXTRXQ(x) (((x) + 1) & EWSKBD_RXQ_LEN_MASK)
|
||||
|
||||
#define EWSKBD_KEY_UP 0x80
|
||||
#define EWSKBD_KEY_MASK 0x7f
|
||||
|
||||
#ifdef EWSKBD_DEBUG
|
||||
int ewskbd_debug = 0;
|
||||
#define DPRINTF(_x) if (ewskbd_debug) printf _x
|
||||
#else
|
||||
#define DPRINTF(_x)
|
||||
#endif
|
||||
|
||||
struct ewskbd_softc {
|
||||
struct device sc_dev;
|
||||
struct ewskbd_devconfig *sc_dc;
|
||||
};
|
||||
|
||||
struct ewskbd_devconfig {
|
||||
/* transmit tail-chasing fifo */
|
||||
uint8_t txq[EWSKBD_TXQ_LEN];
|
||||
u_int txq_head;
|
||||
u_int txq_tail;
|
||||
|
||||
/* receive tail-chasing fifo */
|
||||
uint8_t rxq[EWSKBD_RXQ_LEN];
|
||||
u_int rxq_head;
|
||||
u_int rxq_tail;
|
||||
|
||||
/* state */
|
||||
u_int state;
|
||||
#define TX_READY 0x01
|
||||
|
||||
/* LED status */
|
||||
uint8_t leds;
|
||||
#define EWSKBD_SETLEDS 0x90
|
||||
#define EWSKBD_CAPSLOCK 0x02
|
||||
#define EWSKBD_KANA 0x04
|
||||
|
||||
/* wscons glue */
|
||||
struct device *wskbddev;
|
||||
int enabled;
|
||||
};
|
||||
|
||||
static int ewskbd_zsc_match(struct device *, struct cfdata *, void *);
|
||||
static void ewskbd_zsc_attach(struct device *, struct device *, void *);
|
||||
static int ewskbd_zsc_init(struct zs_chanstate *);
|
||||
static void ewskbd_zsc_rxint(struct zs_chanstate *);
|
||||
static void ewskbd_zsc_stint(struct zs_chanstate *, int);
|
||||
static void ewskbd_zsc_txint(struct zs_chanstate *);
|
||||
static void ewskbd_zsc_softint(struct zs_chanstate *);
|
||||
static void ewskbd_zsc_send(struct zs_chanstate *, uint8_t *, u_int);
|
||||
|
||||
static void ewskbd_wskbd_input(struct zs_chanstate *, u_char);
|
||||
static int ewskbd_wskbd_enable(void *, int);
|
||||
static void ewskbd_wskbd_set_leds(void *, int);
|
||||
static int ewskbd_wskbd_get_leds(void *);
|
||||
static int ewskbd_wskbd_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
||||
|
||||
void ewskbd_zsc_cnattach(uint32_t, uint32_t, int);
|
||||
static void ewskbd_zsc_wskbd_getc(void *, u_int *, int *);
|
||||
static void ewskbd_wskbd_pollc(void *, int);
|
||||
static void ewskbd_wskbd_bell(void *, u_int, u_int, u_int);
|
||||
|
||||
CFATTACH_DECL(ewskbd_zsc, sizeof(struct ewskbd_softc),
|
||||
ewskbd_zsc_match, ewskbd_zsc_attach, NULL, NULL);
|
||||
|
||||
static struct zsops ewskbd_zsops = {
|
||||
ewskbd_zsc_rxint,
|
||||
ewskbd_zsc_stint,
|
||||
ewskbd_zsc_txint,
|
||||
ewskbd_zsc_softint
|
||||
};
|
||||
|
||||
const struct wskbd_mapdata ews4800kbd_wskbd_keymapdata = {
|
||||
ews4800kbd_keydesctab,
|
||||
KB_JP
|
||||
};
|
||||
|
||||
const struct wskbd_accessops ewskbd_wskbd_accessops = {
|
||||
ewskbd_wskbd_enable,
|
||||
ewskbd_wskbd_set_leds,
|
||||
ewskbd_wskbd_ioctl
|
||||
};
|
||||
|
||||
const struct wskbd_consops ewskbd_wskbd_consops = {
|
||||
ewskbd_zsc_wskbd_getc,
|
||||
ewskbd_wskbd_pollc,
|
||||
ewskbd_wskbd_bell
|
||||
};
|
||||
|
||||
static struct ewskbd_devconfig ewskbd_console_dc;
|
||||
static struct zs_chanstate conschan;
|
||||
static int ewskbd_is_console;
|
||||
|
||||
static int
|
||||
ewskbd_zsc_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct zsc_attach_args *zsc_args = aux;
|
||||
struct zsc_softc *zsc = (void *)parent;
|
||||
|
||||
/* keyboard is on channel B */
|
||||
if ((zsc->zsc_flags & 0x0001 /* kbms port */) != 0 &&
|
||||
zsc_args->channel == 1)
|
||||
/* prior to generic zstty(4) */
|
||||
return 3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
struct zs_chanstate *cs;
|
||||
struct zsc_softc *zsc;
|
||||
struct zsc_attach_args *zsc_args;
|
||||
struct wskbddev_attach_args wskaa;
|
||||
int channel;
|
||||
|
||||
zsc = (void *)parent;
|
||||
sc = (void *)self;
|
||||
zsc_args = aux;
|
||||
|
||||
/* Establish ourself with the MD z8530 driver */
|
||||
channel = zsc_args->channel;
|
||||
cs = zsc->zsc_cs[channel];
|
||||
|
||||
if (ewskbd_is_console) {
|
||||
sc->sc_dc = &ewskbd_console_dc;
|
||||
wskaa.console = 1;
|
||||
sc->sc_dc->enabled = 1;
|
||||
} else {
|
||||
wskaa.console = 0;
|
||||
|
||||
sc->sc_dc = malloc(sizeof(struct ewskbd_devconfig), M_DEVBUF,
|
||||
M_WAITOK | M_ZERO);
|
||||
if (sc->sc_dc == NULL) {
|
||||
printf(": can't allocate memory\n");
|
||||
return;
|
||||
}
|
||||
sc->sc_dc->enabled = 0;
|
||||
}
|
||||
cs->cs_defspeed = EWSKBD_BAUD;
|
||||
cs->cs_ops = &ewskbd_zsops;
|
||||
cs->cs_private = sc;
|
||||
|
||||
sc->sc_dc->txq_head = 0;
|
||||
sc->sc_dc->txq_tail = 0;
|
||||
sc->sc_dc->rxq_head = 0;
|
||||
sc->sc_dc->rxq_tail = 0;
|
||||
sc->sc_dc->state = TX_READY;
|
||||
sc->sc_dc->leds = 0;
|
||||
|
||||
ewskbd_zsc_init(cs);
|
||||
|
||||
/* set default LED */
|
||||
ewskbd_wskbd_set_leds(cs, 0);
|
||||
|
||||
printf(": baud rate %d\n", EWSKBD_BAUD);
|
||||
|
||||
/* attach wskbd */
|
||||
wskaa.keymap = &ews4800kbd_wskbd_keymapdata;
|
||||
wskaa.accessops = &ewskbd_wskbd_accessops;
|
||||
wskaa.accesscookie = cs;
|
||||
sc->sc_dc->wskbddev = config_found(self, &wskaa, wskbddevprint);
|
||||
}
|
||||
|
||||
static int
|
||||
ewskbd_zsc_init(struct zs_chanstate *cs)
|
||||
{
|
||||
int s;
|
||||
|
||||
s = splzs();
|
||||
|
||||
zs_write_reg(cs, 9, ZSWR9_B_RESET);
|
||||
DELAY(100);
|
||||
zs_write_reg(cs, 9, ZSWR9_MASTER_IE | ZSWR9_NO_VECTOR);
|
||||
|
||||
cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_TIE;
|
||||
cs->cs_preg[2] = 0;
|
||||
cs->cs_preg[3] = ZSWR3_RX_8 | ZSWR3_RX_ENABLE;
|
||||
cs->cs_preg[4] = ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_PARENB;
|
||||
cs->cs_preg[5] = ZSWR5_TX_8 | ZSWR5_RTS | ZSWR5_TX_ENABLE;
|
||||
cs->cs_preg[6] = 0;
|
||||
cs->cs_preg[7] = 0;
|
||||
cs->cs_preg[8] = 0;
|
||||
cs->cs_preg[9] = ZSWR9_MASTER_IE | ZSWR9_NO_VECTOR;
|
||||
cs->cs_preg[10] = 0;
|
||||
cs->cs_preg[11] = ZSWR11_RXCLK_BAUD | ZSWR11_TXCLK_BAUD |
|
||||
ZSWR11_TRXC_OUT_ENA | ZSWR11_TRXC_BAUD;
|
||||
/* reg[11] and reg[12] are set by zs_set_speed() with cs_brg_clk */
|
||||
zs_set_speed(cs, EWSKBD_BAUD);
|
||||
cs->cs_preg[14] = ZSWR14_BAUD_FROM_PCLK | ZSWR14_BAUD_ENA;
|
||||
cs->cs_preg[15] = 0;
|
||||
|
||||
zs_loadchannelregs(cs);
|
||||
|
||||
splx(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_rxint(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
struct ewskbd_devconfig *dc;
|
||||
uint8_t c, r;
|
||||
|
||||
sc = cs->cs_private;
|
||||
dc = sc->sc_dc;
|
||||
|
||||
/* clear errors */
|
||||
r = zs_read_reg(cs, 1);
|
||||
if (r & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE))
|
||||
zs_write_csr(cs, ZSWR0_RESET_ERRORS);
|
||||
|
||||
/* read byte and append to our queue */
|
||||
c = zs_read_data(cs);
|
||||
|
||||
dc->rxq[dc->rxq_tail] = c;
|
||||
dc->rxq_tail = EWSKBD_NEXTRXQ(dc->rxq_tail);
|
||||
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_stint(struct zs_chanstate *cs, int force)
|
||||
{
|
||||
|
||||
zs_write_csr(cs, ZSWR0_RESET_STATUS);
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_txint(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
|
||||
sc = cs->cs_private;
|
||||
zs_write_reg(cs, 0, ZSWR0_RESET_TXINT);
|
||||
sc->sc_dc->state |= TX_READY;
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_softint(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
struct ewskbd_devconfig *dc;
|
||||
|
||||
sc = cs->cs_private;
|
||||
dc = sc->sc_dc;
|
||||
|
||||
/* handle pending transmissions */
|
||||
if (dc->txq_head != dc->txq_tail && (dc->state & TX_READY)) {
|
||||
int s;
|
||||
|
||||
dc->state &= ~TX_READY;
|
||||
|
||||
s = splzs();
|
||||
zs_write_data(cs, dc->txq[dc->txq_head]);
|
||||
splx(s);
|
||||
|
||||
dc->txq_head = EWSKBD_NEXTTXQ(dc->txq_head);
|
||||
}
|
||||
|
||||
/* don't bother if nobody is listening */
|
||||
if (!dc->enabled) {
|
||||
dc->rxq_head = dc->rxq_tail;
|
||||
return;
|
||||
}
|
||||
|
||||
/* handle incoming keystrokes/config */
|
||||
while (dc->rxq_head != dc->rxq_tail) {
|
||||
uint8_t key = dc->rxq[dc->rxq_head];
|
||||
|
||||
/* toss wskbd a bone */
|
||||
ewskbd_wskbd_input(cs, key);
|
||||
|
||||
dc->rxq_head = EWSKBD_NEXTRXQ(dc->rxq_head);
|
||||
}
|
||||
}
|
||||
|
||||
/* expects to be in splzs() */
|
||||
static void
|
||||
ewskbd_zsc_send(struct zs_chanstate *cs, uint8_t *c, u_int len)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
struct ewskbd_devconfig *dc;
|
||||
int i;
|
||||
|
||||
sc = cs->cs_private;
|
||||
dc = sc->sc_dc;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (dc->state & TX_READY) {
|
||||
zs_write_data(cs, c[i]);
|
||||
dc->state &= ~TX_READY;
|
||||
} else {
|
||||
dc->txq[dc->txq_tail] = c[i];
|
||||
dc->txq_tail = EWSKBD_NEXTTXQ(dc->txq_tail);
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* wskbd glue
|
||||
******************************************************************************/
|
||||
|
||||
static void
|
||||
ewskbd_wskbd_input(struct zs_chanstate *cs, uint8_t key)
|
||||
{
|
||||
struct ewskbd_softc *sc;
|
||||
u_int type;
|
||||
|
||||
sc = cs->cs_private;
|
||||
|
||||
if (key & EWSKBD_KEY_UP)
|
||||
type = WSCONS_EVENT_KEY_UP;
|
||||
else
|
||||
type = WSCONS_EVENT_KEY_DOWN;
|
||||
|
||||
wskbd_input(sc->sc_dc->wskbddev, type, (key & EWSKBD_KEY_MASK));
|
||||
|
||||
DPRINTF(("ewskbd_wskbd_input: inputted key 0x%x\n", key));
|
||||
|
||||
#ifdef WSDISPLAY_COMPAT_RAWKBD
|
||||
wskbd_rawinput(sc->sc_dc->wskbddev, &key, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
ewskbd_wskbd_enable(void *cookie, int on)
|
||||
{
|
||||
struct zs_chanstate *cs;
|
||||
struct ewskbd_softc *sc;
|
||||
|
||||
cs = cookie;
|
||||
sc = cs->cs_private;
|
||||
|
||||
if (on) {
|
||||
if (sc->sc_dc->enabled)
|
||||
return EBUSY;
|
||||
else
|
||||
sc->sc_dc->enabled = 1;
|
||||
} else
|
||||
sc->sc_dc->enabled = 0;
|
||||
|
||||
DPRINTF(("ewskbd_wskbd_enable: %s\n", on ? "enabled" : "disabled"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_wskbd_set_leds(void *cookie, int leds)
|
||||
{
|
||||
struct zs_chanstate *cs;
|
||||
struct ewskbd_softc *sc;
|
||||
int s;
|
||||
uint8_t cmd;
|
||||
|
||||
cs = cookie;
|
||||
sc = cs->cs_private;
|
||||
cmd = 0;
|
||||
|
||||
if (leds & WSKBD_LED_CAPS)
|
||||
cmd |= EWSKBD_CAPSLOCK;
|
||||
|
||||
sc->sc_dc->leds = cmd;
|
||||
|
||||
cmd |= EWSKBD_SETLEDS;
|
||||
|
||||
s = splzs();
|
||||
ewskbd_zsc_send(cs, &cmd, 1);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
static int
|
||||
ewskbd_wskbd_get_leds(void *cookie)
|
||||
{
|
||||
struct zs_chanstate *cs;
|
||||
struct ewskbd_softc *sc;
|
||||
int leds;
|
||||
|
||||
cs = cookie;
|
||||
sc = cs->cs_private;
|
||||
leds = 0;
|
||||
|
||||
if (sc->sc_dc->leds & EWSKBD_CAPSLOCK)
|
||||
leds |= WSKBD_LED_CAPS;
|
||||
|
||||
return leds;
|
||||
}
|
||||
|
||||
static int
|
||||
ewskbd_wskbd_ioctl(void *cookie, u_long cmd, caddr_t data, int flag,
|
||||
struct lwp *l)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case WSKBDIO_GTYPE:
|
||||
*(int *)data = WSKBD_TYPE_EWS4800;
|
||||
break;
|
||||
|
||||
#ifdef notyet
|
||||
case WSKBDIO_BELL:
|
||||
case WSKBDIO_COMPLEXBELL:
|
||||
case WSKBDIO_SETBELL:
|
||||
case WSKBDIO_GETBELL:
|
||||
case WSKBDIO_SETDEFAULTBELL:
|
||||
case WSKBDIO_GETDEFAULTBELL:
|
||||
case WSKBDIO_SETKEYREPEAT:
|
||||
case WSKBDIO_GETKEYREPEAT:
|
||||
case WSKBDIO_SETDEFAULTKEYREPEAT:
|
||||
case WSKBDIO_GETDEFAULTKEYREPEAT:
|
||||
#endif
|
||||
|
||||
case WSKBDIO_SETLEDS:
|
||||
ewskbd_wskbd_set_leds(cookie, *(int *)data);
|
||||
break;
|
||||
|
||||
case WSKBDIO_GETLEDS:
|
||||
*(int *)data = ewskbd_wskbd_get_leds(cookie);
|
||||
break;
|
||||
|
||||
#ifdef notyet
|
||||
case WSKBDIO_GETMAP:
|
||||
case WSKBDIO_SETMAP:
|
||||
case WSKBDIO_GETENCODING:
|
||||
case WSKBDIO_SETENCODING:
|
||||
case WSKBDIO_SETMODE:
|
||||
case WSKBDIO_GETMODE:
|
||||
case WSKBDIO_SETKEYCLICK:
|
||||
case WSKBDIO_GETKEYCLICK:
|
||||
#endif
|
||||
|
||||
default:
|
||||
return EPASSTHROUGH;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* console routines
|
||||
*/
|
||||
void
|
||||
ewskbd_zsc_cnattach(uint32_t csr, uint32_t data, int pclk)
|
||||
{
|
||||
struct zs_chanstate *cs;
|
||||
|
||||
cs = &conschan;
|
||||
|
||||
cs->cs_reg_csr = (void *)csr;
|
||||
cs->cs_reg_data = (void *)data;
|
||||
cs->cs_brg_clk = pclk / 16;
|
||||
cs->cs_defspeed = EWSKBD_BAUD;
|
||||
|
||||
ewskbd_zsc_init(cs);
|
||||
|
||||
zs_putc(cs, EWSKBD_SETLEDS);
|
||||
|
||||
wskbd_cnattach(&ewskbd_wskbd_consops, cs, &ews4800kbd_wskbd_keymapdata);
|
||||
ewskbd_is_console = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_zsc_wskbd_getc(void *cookie, u_int *type, int *data)
|
||||
{
|
||||
int key;
|
||||
|
||||
key = zs_getc(cookie);
|
||||
|
||||
if (key & EWSKBD_KEY_UP)
|
||||
*type = WSCONS_EVENT_KEY_UP;
|
||||
else
|
||||
*type = WSCONS_EVENT_KEY_DOWN;
|
||||
|
||||
*data = key & EWSKBD_KEY_MASK;
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_wskbd_pollc(void *cookie, int on)
|
||||
{
|
||||
|
||||
static boolean_t __polling = FALSE;
|
||||
static int s;
|
||||
|
||||
if (on && !__polling) {
|
||||
/* disable interrupt driven I/O */
|
||||
s = splhigh();
|
||||
} else if (!on && __polling) {
|
||||
/* enable interrupt driven I/O */
|
||||
__polling = FALSE;
|
||||
splx(s);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ewskbd_wskbd_bell(void *cookie, u_int pitch, u_int period, u_int volume)
|
||||
{
|
||||
|
||||
/* nothing */
|
||||
}
|
|
@ -0,0 +1,393 @@
|
|||
/* $NetBSD: ewsms.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Steve Rumble
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* EWS4800 serial mouse driver attached to zs channel 0 at 4800 or 1200bps.
|
||||
* This layer feeds wsmouse.
|
||||
*
|
||||
* 5 byte packets: sync, x1, y1, x2, y2
|
||||
* sync format: binary 10000LMR (left, middle, right) 0 is down
|
||||
*
|
||||
* This driver is taken from sgimips, but ews4800 has the similar protocol.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ewsms.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/wscons/wsconsio.h>
|
||||
#include <dev/wscons/wsmousevar.h>
|
||||
|
||||
#include <dev/ic/z8530reg.h>
|
||||
#include <machine/z8530var.h>
|
||||
|
||||
#define EWSMS_BAUD 1200
|
||||
#define EWSMS_BAUD1 4800
|
||||
|
||||
#define EWSMS_RXQ_LEN 64 /* power of 2 */
|
||||
#define EWSMS_RXQ_LEN_MASK (EWSMS_RXQ_LEN - 1)
|
||||
#define EWSMS_NEXTRXQ(x) (((x) + 1) & EWSMS_RXQ_LEN_MASK)
|
||||
|
||||
/* protocol */
|
||||
#define EWSMS_SYNC0 0x80
|
||||
#define EWSMS_SYNC1 0x88
|
||||
#define EWSMS_SYNC_MASK 0xf8
|
||||
#define EWSMS_SYNC_BTN_R 0x01
|
||||
#define EWSMS_SYNC_BTN_M 0x02
|
||||
#define EWSMS_SYNC_BTN_L 0x04
|
||||
#define EWSMS_SYNC_BTN_MASK \
|
||||
(EWSMS_SYNC_BTN_R|EWSMS_SYNC_BTN_M|EWSMS_SYNC_BTN_L)
|
||||
|
||||
struct ewsms_softc {
|
||||
struct device sc_dev;
|
||||
|
||||
/* tail-chasing fifo */
|
||||
uint8_t sc_rxq[EWSMS_RXQ_LEN];
|
||||
u_int sc_rxq_head;
|
||||
u_int sc_rxq_tail;
|
||||
|
||||
/* 5-byte packet as described above */
|
||||
int8_t sc_packet[5];
|
||||
#define EWSMS_PACKET_SYNC 0
|
||||
#define EWSMS_PACKET_X1 1
|
||||
#define EWSMS_PACKET_Y1 2
|
||||
#define EWSMS_PACKET_X2 3
|
||||
#define EWSMS_PACKET_Y2 4
|
||||
|
||||
u_int sc_state;
|
||||
#define EWSMS_STATE_SYNC 0x01
|
||||
#define EWSMS_STATE_X1 0x02
|
||||
#define EWSMS_STATE_Y1 0x04
|
||||
#define EWSMS_STATE_X2 0x08
|
||||
#define EWSMS_STATE_Y2 0x10
|
||||
|
||||
u_int sc_baud;
|
||||
u_int sc_flags;
|
||||
#define EWSMS_F_FASTBAUD 0x01
|
||||
#define EWSMS_F_RSTCMD 0x02
|
||||
#define EWSMS_F_SWAPBTN 0x04
|
||||
#define EWSMS_F_SYNC1 0x08
|
||||
|
||||
/* wsmouse bits */
|
||||
int sc_enabled;
|
||||
struct device *sc_wsmousedev;
|
||||
};
|
||||
|
||||
static int ewsms_zsc_match(struct device *, struct cfdata *, void *);
|
||||
static void ewsms_zsc_attach(struct device *, struct device *, void *);
|
||||
static int ewsms_zsc_reset(struct zs_chanstate *);
|
||||
static void ewsms_zsc_rxint(struct zs_chanstate *);
|
||||
static void ewsms_zsc_txint(struct zs_chanstate *);
|
||||
static void ewsms_zsc_stint(struct zs_chanstate *, int);
|
||||
static void ewsms_zsc_softint(struct zs_chanstate *);
|
||||
|
||||
static void ewsms_wsmouse_input(struct ewsms_softc *);
|
||||
static int ewsms_wsmouse_enable(void *);
|
||||
static void ewsms_wsmouse_disable(void *);
|
||||
static int ewsms_wsmouse_ioctl(void *, u_long, caddr_t, int, struct lwp *);
|
||||
|
||||
CFATTACH_DECL(ewsms_zsc, sizeof(struct ewsms_softc),
|
||||
ewsms_zsc_match, ewsms_zsc_attach, NULL, NULL);
|
||||
|
||||
static struct zsops ewsms_zsops = {
|
||||
ewsms_zsc_rxint,
|
||||
ewsms_zsc_stint,
|
||||
ewsms_zsc_txint,
|
||||
ewsms_zsc_softint
|
||||
};
|
||||
|
||||
static const struct wsmouse_accessops ewsms_wsmouse_accessops = {
|
||||
ewsms_wsmouse_enable,
|
||||
ewsms_wsmouse_ioctl,
|
||||
ewsms_wsmouse_disable
|
||||
};
|
||||
|
||||
int
|
||||
ewsms_zsc_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct zsc_softc *zsc = (void *)parent;
|
||||
struct zsc_attach_args *zsc_args = aux;
|
||||
|
||||
/* mouse on channel A */
|
||||
if ((zsc->zsc_flags & 0x0001 /* kbms port */) != 0 &&
|
||||
zsc_args->channel == 0)
|
||||
/* prior to generic zstty(4) */
|
||||
return 3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ewsms_zsc_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct zsc_softc *zsc = (void *)parent;
|
||||
struct ewsms_softc *sc = (void *)self;
|
||||
struct zsc_attach_args *zsc_args = aux;
|
||||
struct zs_chanstate *cs;
|
||||
struct wsmousedev_attach_args wsmaa;
|
||||
int channel;
|
||||
|
||||
/* Establish ourself with the MD z8530 driver */
|
||||
channel = zsc_args->channel;
|
||||
cs = zsc->zsc_cs[channel];
|
||||
cs->cs_ops = &ewsms_zsops;
|
||||
cs->cs_private = sc;
|
||||
|
||||
sc->sc_enabled = 0;
|
||||
sc->sc_rxq_head = 0;
|
||||
sc->sc_rxq_tail = 0;
|
||||
sc->sc_state = EWSMS_STATE_SYNC;
|
||||
|
||||
if (zsc->zsc_flags & 0x0002) {
|
||||
sc->sc_flags |= EWSMS_F_RSTCMD;
|
||||
sc->sc_flags |= EWSMS_F_FASTBAUD;
|
||||
sc->sc_flags |= EWSMS_F_SWAPBTN;
|
||||
sc->sc_flags |= EWSMS_F_SYNC1;
|
||||
}
|
||||
|
||||
ewsms_zsc_reset(cs);
|
||||
|
||||
printf(": baud rate %d\n", EWSMS_BAUD);
|
||||
|
||||
/* attach wsmouse */
|
||||
wsmaa.accessops = &ewsms_wsmouse_accessops;
|
||||
wsmaa.accesscookie = sc;
|
||||
sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
|
||||
}
|
||||
|
||||
int
|
||||
ewsms_zsc_reset(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewsms_softc *sc = cs->cs_private;
|
||||
u_int baud;
|
||||
int i, s;
|
||||
const static uint8_t cmd[] =
|
||||
{ 0x02, 0x52, 0x53, 0x3b, 0x4d, 0x54, 0x2c, 0x36, 0x0d };
|
||||
|
||||
s = splzs();
|
||||
zs_write_reg(cs, 9, ZSWR9_A_RESET);
|
||||
cs->cs_preg[1] = ZSWR1_RIE;
|
||||
baud = EWSMS_BAUD;
|
||||
if (sc->sc_flags & EWSMS_F_FASTBAUD)
|
||||
baud = EWSMS_BAUD1;
|
||||
zs_set_speed(cs, baud);
|
||||
zs_loadchannelregs(cs);
|
||||
|
||||
if (sc->sc_flags & EWSMS_F_RSTCMD) {
|
||||
for (i = 0; i < sizeof(cmd); i++)
|
||||
zs_putc(cs, cmd[i]);
|
||||
}
|
||||
|
||||
splx(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ewsms_zsc_rxint(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewsms_softc *sc = cs->cs_private;
|
||||
u_char c, r;
|
||||
|
||||
/* clear errors */
|
||||
r = zs_read_reg(cs, 1);
|
||||
if (r & (ZSRR1_FE | ZSRR1_DO | ZSRR1_PE))
|
||||
zs_write_csr(cs, ZSWR0_RESET_ERRORS);
|
||||
|
||||
/* read byte and append to our queue */
|
||||
c = zs_read_data(cs);
|
||||
|
||||
sc->sc_rxq[sc->sc_rxq_tail] = c;
|
||||
sc->sc_rxq_tail = EWSMS_NEXTRXQ(sc->sc_rxq_tail);
|
||||
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
/* We should never get here. */
|
||||
void
|
||||
ewsms_zsc_txint(struct zs_chanstate *cs)
|
||||
{
|
||||
zs_write_reg(cs, 0, ZSWR0_RESET_TXINT);
|
||||
|
||||
/* seems like the in thing to do */
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
void
|
||||
ewsms_zsc_stint(struct zs_chanstate *cs, int force)
|
||||
{
|
||||
|
||||
zs_write_csr(cs, ZSWR0_RESET_STATUS);
|
||||
cs->cs_softreq = 1;
|
||||
}
|
||||
|
||||
void
|
||||
ewsms_zsc_softint(struct zs_chanstate *cs)
|
||||
{
|
||||
struct ewsms_softc *sc = cs->cs_private;
|
||||
uint8_t sync;
|
||||
|
||||
/* No need to keep score if nobody is listening */
|
||||
if (!sc->sc_enabled) {
|
||||
sc->sc_rxq_head = sc->sc_rxq_tail;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here's the real action. Read a full packet and
|
||||
* then let wsmouse know what has happened.
|
||||
*/
|
||||
while (sc->sc_rxq_head != sc->sc_rxq_tail) {
|
||||
int8_t c = sc->sc_rxq[sc->sc_rxq_head];
|
||||
|
||||
switch (sc->sc_state) {
|
||||
case EWSMS_STATE_SYNC:
|
||||
sync = EWSMS_SYNC0;
|
||||
if (sc->sc_flags & EWSMS_F_SYNC1)
|
||||
sync = EWSMS_SYNC1;
|
||||
if ((c & EWSMS_SYNC_MASK) == sync) {
|
||||
sc->sc_packet[EWSMS_PACKET_SYNC] = c;
|
||||
sc->sc_state = EWSMS_STATE_X1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EWSMS_STATE_X1:
|
||||
sc->sc_packet[EWSMS_PACKET_X1] = c;
|
||||
sc->sc_state = EWSMS_STATE_Y1;
|
||||
break;
|
||||
|
||||
case EWSMS_STATE_Y1:
|
||||
sc->sc_packet[EWSMS_PACKET_Y1] = c;
|
||||
sc->sc_state = EWSMS_STATE_X2;
|
||||
break;
|
||||
|
||||
case EWSMS_STATE_X2:
|
||||
sc->sc_packet[EWSMS_PACKET_X2] = c;
|
||||
sc->sc_state = EWSMS_STATE_Y2;
|
||||
break;
|
||||
|
||||
case EWSMS_STATE_Y2:
|
||||
sc->sc_packet[EWSMS_PACKET_Y2] = c;
|
||||
|
||||
/* tweak wsmouse */
|
||||
ewsms_wsmouse_input(sc);
|
||||
|
||||
sc->sc_state = EWSMS_STATE_SYNC;
|
||||
}
|
||||
|
||||
sc->sc_rxq_head = EWSMS_NEXTRXQ(sc->sc_rxq_head);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* wsmouse glue
|
||||
******************************************************************************/
|
||||
|
||||
static void
|
||||
ewsms_wsmouse_input(struct ewsms_softc *sc)
|
||||
{
|
||||
u_int btns;
|
||||
boolean_t bl, bm, br;
|
||||
int dx, dy;
|
||||
|
||||
btns = (uint8_t)sc->sc_packet[EWSMS_PACKET_SYNC] & EWSMS_SYNC_BTN_MASK;
|
||||
if (sc->sc_flags & EWSMS_F_SWAPBTN) {
|
||||
bl = (btns & EWSMS_SYNC_BTN_R) == 0;
|
||||
bm = (btns & EWSMS_SYNC_BTN_M) == 0;
|
||||
br = (btns & EWSMS_SYNC_BTN_L) == 0;
|
||||
} else {
|
||||
bl = (btns & EWSMS_SYNC_BTN_L) == 0;
|
||||
bm = (btns & EWSMS_SYNC_BTN_M) == 0;
|
||||
br = (btns & EWSMS_SYNC_BTN_R) == 0;
|
||||
}
|
||||
/* for wsmouse(4), 1 is down, 0 is up, most left button is LSB */
|
||||
btns = (bl ? (1 << 0) : 0) | (bm ? (1 << 1) : 0) | (br ? (1 << 2) : 0);
|
||||
|
||||
/* delta values are signed */
|
||||
/* moving left is minus, moving right is plus */
|
||||
dx = (int)sc->sc_packet[EWSMS_PACKET_X1] +
|
||||
(int)sc->sc_packet[EWSMS_PACKET_X2];
|
||||
/* moving back is minus, moving front is plus */
|
||||
dy = (int)sc->sc_packet[EWSMS_PACKET_Y1] +
|
||||
(int)sc->sc_packet[EWSMS_PACKET_Y2];
|
||||
|
||||
wsmouse_input(sc->sc_wsmousedev, btns, dx, dy, 0, WSMOUSE_INPUT_DELTA);
|
||||
}
|
||||
|
||||
static int
|
||||
ewsms_wsmouse_enable(void *cookie)
|
||||
{
|
||||
struct ewsms_softc *sc = cookie;
|
||||
|
||||
if (sc->sc_enabled)
|
||||
return EBUSY;
|
||||
|
||||
sc->sc_state = EWSMS_STATE_SYNC;
|
||||
sc->sc_enabled = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ewsms_wsmouse_disable(void *cookie)
|
||||
{
|
||||
struct ewsms_softc *sc = cookie;
|
||||
|
||||
sc->sc_enabled = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ewsms_wsmouse_ioctl(void *cookie, u_long cmd, caddr_t data, int flag,
|
||||
struct lwp *l)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case WSMOUSEIO_GTYPE:
|
||||
*(u_int *)data = 0;
|
||||
break;
|
||||
|
||||
#ifdef notyet
|
||||
case WSMOUSEIO_SRES:
|
||||
case WSMOUSEIO_SSCALE:
|
||||
case WSMOUSEIO_SRATE:
|
||||
case WSMOUSEIO_SCALIBCOORDS:
|
||||
case WSMOUSEIO_GCALIBCOORDS:
|
||||
case WSMOUSEIO_GETID:
|
||||
#endif
|
||||
|
||||
default:
|
||||
return EPASSTHROUGH;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,444 @@
|
|||
/* $NetBSD: ga.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Graphic Adaptor (350, 360) */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ga.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#ifdef _STANDALONE
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
#include "local.h"
|
||||
#endif
|
||||
#ifdef _KERNEL
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <machine/vmparam.h>
|
||||
#endif
|
||||
#include <machine/gareg.h>
|
||||
#include <machine/gavar.h>
|
||||
|
||||
boolean_t ga_map(struct ga *);
|
||||
void ga_clut_init(struct ga *);
|
||||
void ga_vblank_start(const struct ga *);
|
||||
void ga_bt463_reg(const struct ga *, int);
|
||||
void ga_bt463_data(const struct ga *, int);
|
||||
void ga_bt463_reg_data(const struct ga *, int, int);
|
||||
#ifdef _STANDALONE
|
||||
void ga_dda_busy(const struct ga *);
|
||||
void ga_ovl_init(const struct ga *);
|
||||
void ga_id_init(const struct ga *);
|
||||
void ga_block_clear(const struct ga *);
|
||||
void ga_plane_mask_test(const struct ga *);
|
||||
#endif
|
||||
|
||||
#define ga_reg_write(ga, ofs, val) \
|
||||
(*(volatile uint32_t *)((ga)->reg_addr + (ofs)) = (val))
|
||||
#define ga_reg_read(ga, ofs) \
|
||||
(*(volatile uint32_t *)((ga)->reg_addr + (ofs)))
|
||||
|
||||
boolean_t
|
||||
ga_init(struct ga *ga)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Map GA register and buffers */
|
||||
if (ga->reg_addr == 0 && ga_map(ga) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* This is 350 GA-ROM initialization sequence. */
|
||||
if (ga->flags == 0x0000) {
|
||||
ga_bt463_reg_data(ga, 0x201, 0x40);
|
||||
ga_bt463_reg_data(ga, 0x202, 0x40);
|
||||
ga_bt463_reg_data(ga, 0x203,
|
||||
((ga_reg_read(ga, 0xe00) & 2) << 6) | 0x40);
|
||||
} else if (ga->flags == 0x0001) {
|
||||
ga_bt463_reg_data(ga, 0x201, 0x40);
|
||||
ga_bt463_reg_data(ga, 0x202, 0);
|
||||
ga_bt463_reg_data(ga, 0x203,
|
||||
((ga_reg_read(ga, 0xe00) & 2) << 6) | 0x40);
|
||||
ga_bt463_reg_data(ga, 0x204, 0xff); /* Display ON/OFF ? */
|
||||
ga_bt463_reg_data(ga, 0x206, 0);
|
||||
ga_bt463_reg_data(ga, 0x20a, 0);
|
||||
}
|
||||
|
||||
/* Window type table */
|
||||
ga_bt463_reg(ga, 0x300);
|
||||
for (i = 0; i < 16; i++) {
|
||||
ga_bt463_data(ga, 0x00);
|
||||
ga_bt463_data(ga, 0xe1);
|
||||
ga_bt463_data(ga, 0x01);
|
||||
}
|
||||
|
||||
ga_vblank_start(ga);
|
||||
|
||||
/* ??? */
|
||||
ga_bt463_reg(ga, 0x302);
|
||||
for (i = 0; i < 2; i++) {
|
||||
ga_bt463_data(ga, 0x00);
|
||||
ga_bt463_data(ga, 0xe3);
|
||||
ga_bt463_data(ga, 0x21);
|
||||
}
|
||||
|
||||
/* Read mask P0-P7 */
|
||||
if (ga->flags != 0x0001) {
|
||||
/* TR2A display blinks if this was done.. */
|
||||
ga_bt463_reg(ga, 0x205);
|
||||
for (i = 0; i < 4; i++)
|
||||
ga_bt463_data(ga, 0xff);
|
||||
}
|
||||
|
||||
/* Blink mask P0-P7 */
|
||||
ga_bt463_reg(ga, 0x209);
|
||||
for (i = 0; i < 4; i++)
|
||||
ga_bt463_data(ga, 0x00);
|
||||
|
||||
ga_clut_init(ga);
|
||||
|
||||
/* ??? */
|
||||
ga_bt463_reg(ga, 0x200);
|
||||
for (i = 0; i < 0xff; i++) {
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
}
|
||||
|
||||
if (ga_reg_read(ga, 0xe00) & 2)
|
||||
ga_reg_write(ga, 0xe08, 0x790); /* 71Hz */
|
||||
else
|
||||
ga_reg_write(ga, 0xe08, 0x670); /* 60Hz */
|
||||
#ifdef _STANDALONE
|
||||
ga_block_clear(ga);
|
||||
ga_ovl_init(ga);
|
||||
ga_id_init(ga);
|
||||
#endif
|
||||
/* Cursor RAM clear */
|
||||
ga_reg_write(ga, 0xc90, 0);
|
||||
ga_reg_write(ga, 0xc94, 0);
|
||||
ga_reg_write(ga, 0xca0, 0);
|
||||
ga_reg_write(ga, 0xca4, 0);
|
||||
for (i = 0; i < 512; i++) {
|
||||
ga_reg_write(ga, 0xc98, 0);
|
||||
ga_reg_write(ga, 0xca8, 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
ga_map(struct ga *ga)
|
||||
{
|
||||
#ifdef _STANDALONE
|
||||
/* IPL maps register region using 16Mpage */
|
||||
ga->reg_addr = GA_REG_ADDR;
|
||||
#endif
|
||||
#ifdef _KERNEL
|
||||
paddr_t pa, epa;
|
||||
vaddr_t va, tva;
|
||||
|
||||
pa = (paddr_t)GA_REG_ADDR;
|
||||
epa = pa + GA_REG_SIZE;
|
||||
|
||||
if (!(va = uvm_km_alloc(kernel_map, epa - pa, 0, UVM_KMF_VAONLY))) {
|
||||
printf("can't map GA register.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (tva = va; pa < epa; pa += PAGE_SIZE, tva += PAGE_SIZE)
|
||||
pmap_kenter_pa(tva, pa, VM_PROT_READ | VM_PROT_WRITE);
|
||||
|
||||
pmap_update(pmap_kernel());
|
||||
|
||||
ga->reg_addr = (uint32_t)va;
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ga_vblank_start(const struct ga *ga)
|
||||
{
|
||||
|
||||
while ((ga_reg_read(ga, 0xe00) & 0x1) == 0) /* V-blank */
|
||||
;
|
||||
while ((ga_reg_read(ga, 0xe00) & 0x1) == 1)
|
||||
;
|
||||
/* V-blank start */
|
||||
}
|
||||
|
||||
/* Bt463 utils */
|
||||
void
|
||||
ga_bt463_reg(const struct ga *ga, int r)
|
||||
{
|
||||
|
||||
ga_reg_write(ga, 0xc80, r & 0xff);
|
||||
ga_reg_write(ga, 0xc84, (r >> 8) & 0xff);
|
||||
}
|
||||
|
||||
void
|
||||
ga_bt463_data(const struct ga *ga, int v)
|
||||
{
|
||||
|
||||
ga_reg_write(ga, 0xc88, v & 0xff);
|
||||
}
|
||||
|
||||
void
|
||||
ga_bt463_reg_data(const struct ga *ga, int r, int v)
|
||||
{
|
||||
|
||||
ga_bt463_reg(ga, r);
|
||||
ga_bt463_data(ga, v);
|
||||
}
|
||||
|
||||
/* CLUT */
|
||||
void
|
||||
ga_clut_init(struct ga *ga)
|
||||
{
|
||||
const uint8_t compo6[6] = { 0, 51, 102, 153, 204, 255 };
|
||||
const uint8_t ansi_color[16][3] = {
|
||||
{ 0x00, 0x00, 0x00 },
|
||||
{ 0xff, 0x00, 0x00 },
|
||||
{ 0x00, 0xff, 0x00 },
|
||||
{ 0xff, 0xff, 0x00 },
|
||||
{ 0x00, 0x00, 0xff },
|
||||
{ 0xff, 0x00, 0xff },
|
||||
{ 0x00, 0xff, 0xff },
|
||||
{ 0xff, 0xff, 0xff },
|
||||
{ 0x00, 0x00, 0x00 },
|
||||
{ 0x80, 0x00, 0x00 },
|
||||
{ 0x00, 0x80, 0x00 },
|
||||
{ 0x80, 0x80, 0x00 },
|
||||
{ 0x00, 0x00, 0x80 },
|
||||
{ 0x80, 0x00, 0x80 },
|
||||
{ 0x00, 0x80, 0x80 },
|
||||
{ 0x80, 0x80, 0x80 },
|
||||
};
|
||||
int i, j, r, g, b;
|
||||
|
||||
ga_bt463_reg(ga, 0);
|
||||
/* ANSI escape sequence */
|
||||
for (i = 0; i < 16; i++) {
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][0] = ansi_color[i][0]);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][1] = ansi_color[i][1]);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][2] = ansi_color[i][2]);
|
||||
}
|
||||
|
||||
/* 16 - 31, gray scale */
|
||||
for ( ; i < 32; i++) {
|
||||
j = (i - 16) * 17;
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][0] = j);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][1] = j);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][2] = j);
|
||||
}
|
||||
|
||||
/* 32 - 247, RGB color */
|
||||
for (r = 0; r < 6; r++) {
|
||||
for (g = 0; g < 6; g++) {
|
||||
for (b = 0; b < 6; b++, i++) {
|
||||
ga_reg_write(ga, 0xc8c,
|
||||
ga->clut[i][0] = compo6[r]);
|
||||
ga_reg_write(ga, 0xc8c,
|
||||
ga->clut[i][1] = compo6[g]);
|
||||
ga_reg_write(ga, 0xc8c,
|
||||
ga->clut[i][2] = compo6[b]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 248 - 256, white */
|
||||
for ( ; i < 256; i++) {
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][0] = 0xff);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][1] = 0xff);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][2] = 0xff);
|
||||
}
|
||||
|
||||
/* 257 - 528, black */
|
||||
for ( ; i < 528; i++) {
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
ga_reg_write(ga, 0xc8c, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ga_clut_get(struct ga *ga)
|
||||
{
|
||||
int i;
|
||||
|
||||
ga_bt463_reg(ga, 0);
|
||||
for (i = 0; i < 256; i++) {
|
||||
ga->clut[i][0] = ga_reg_read(ga, 0xc8c);
|
||||
ga->clut[i][1] = ga_reg_read(ga, 0xc8c);
|
||||
ga->clut[i][2] = ga_reg_read(ga, 0xc8c);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ga_clut_set(const struct ga *ga)
|
||||
{
|
||||
int i;
|
||||
|
||||
ga_bt463_reg(ga, 0);
|
||||
for (i = 0; i < 256; i++) {
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][0]);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][1]);
|
||||
ga_reg_write(ga, 0xc8c, ga->clut[i][2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Not yet analyzed. */
|
||||
#ifdef _STANDALONE
|
||||
void
|
||||
ga_dda_busy(const struct ga *ga)
|
||||
{
|
||||
|
||||
while ((ga_reg_read(ga, 0xf00) & 0x8000) == 0)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
ga_ovl_init(const struct ga *ga)
|
||||
{
|
||||
uint32_t *p0, *p1;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0xffffffff);
|
||||
p0 = (uint32_t *)0xf2000000;
|
||||
p1 = (uint32_t *)0xf2200000;
|
||||
while (p0 < p1)
|
||||
*p0++ = 0;
|
||||
}
|
||||
|
||||
void
|
||||
ga_id_init(const struct ga *ga)
|
||||
{
|
||||
uint32_t *p0, *p1;
|
||||
|
||||
p0 = (uint32_t *)0xf3000000;
|
||||
p1 = (uint32_t *)0xf3040000;
|
||||
while (p0 < p1)
|
||||
*p0++ = 0;
|
||||
}
|
||||
|
||||
void
|
||||
ga_block_clear(const struct ga *ga)
|
||||
{
|
||||
uint32_t *p0, *p1;
|
||||
|
||||
ga_reg_write(ga, 0xe80, 0);
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
|
||||
p0 = (uint32_t *)0xf0c00000;
|
||||
p1 = (uint32_t *)0xf0c80000;
|
||||
while (p0 < p1)
|
||||
*p0++ = 0xffffffff;
|
||||
}
|
||||
|
||||
void
|
||||
ga_plane_mask_test(const struct ga *ga)
|
||||
{
|
||||
int i;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
*(volatile uint32_t *)0xf1000000 = 0;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0xaaaaaa);
|
||||
*(volatile uint32_t *)0xf1000000 = 0xffffff;
|
||||
|
||||
if ((*(volatile uint32_t *)0xf1000000 & 0xffffff) != 0xaaaaaa)
|
||||
goto err;
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
*(volatile uint32_t *)0xf1000000 = 0;
|
||||
|
||||
|
||||
*(volatile uint32_t *)0xf1080008 = 0;
|
||||
ga_reg_write(ga, 0x400, 0x555555);
|
||||
*(volatile uint32_t *)0xf1080008 = 0xffffff;
|
||||
if ((*(volatile uint32_t *)0xf1080008 & 0xffffff) != 0x555555)
|
||||
goto err;
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
*(volatile uint32_t *)0xf1080008 = 0;
|
||||
|
||||
*(volatile uint32_t *)0xf1100000 = 0;
|
||||
*(volatile uint32_t *)0xf1100000 = 0xffffff;
|
||||
if ((*(volatile uint32_t *)0xf1100000 & 0xffffff) != 0xffffff)
|
||||
goto err;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0xaaaaaa);
|
||||
*(volatile uint32_t *)0xf1100000 = 0;
|
||||
if ((*(volatile uint32_t *)0xf1100000 & 0xffffff) != 0x555555)
|
||||
goto err;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0);
|
||||
*(volatile uint32_t *)0xf1100000 = 0xffffff;
|
||||
if ((*(volatile uint32_t *)0xf1100000 & 0xffffff) != 0x555555)
|
||||
goto err;
|
||||
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
*(volatile uint32_t *)0xf1100000 = 0;
|
||||
|
||||
ga_reg_write(ga, 0xe80, 0xffffff);
|
||||
ga_reg_write(ga, 0x400, 0xffffff);
|
||||
*(volatile uint32_t *)0xf0c00000 = 0xffffffff;
|
||||
for (i = 0; i < 32; i++)
|
||||
if ((*(volatile uint32_t *)(0xf1000000 + i * 4) & 0xffffff) !=
|
||||
0xffffff)
|
||||
goto err;
|
||||
|
||||
ga_reg_write(ga, 0xe80, 0);
|
||||
ga_reg_write(ga, 0x400, 0xaaaaaa);
|
||||
*(volatile uint32_t *)0xf0c00000 = 0xffffffff;
|
||||
for (i = 0; i < 32; i++)
|
||||
if ((*(volatile uint32_t *)(0xf1000000 + i * 4) & 0xffffff) !=
|
||||
0x555555)
|
||||
goto err;
|
||||
ga_reg_write(ga, 0x400, 0x555555);
|
||||
*(volatile uint32_t *)0xf0c00000 = 0xffffffff;
|
||||
for (i = 0; i < 32; i++)
|
||||
if ((*(volatile uint32_t *)(0xf1000000 + i * 4) & 0xffffff) !=
|
||||
0x0)
|
||||
goto err;
|
||||
|
||||
printf("SUCCESS\n");
|
||||
return;
|
||||
err:
|
||||
printf("ERROR\n");
|
||||
}
|
||||
#endif /* _STANDALONE */
|
|
@ -0,0 +1,347 @@
|
|||
/* $NetBSD: zs.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Gordon W. Ross.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Zilog Z8530 Dual UART driver (machine-dependent part)
|
||||
*
|
||||
* Runs two serial lines per chip using slave drivers.
|
||||
* Plain tty/async lines use the zs_async slave.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/z8530var.h>
|
||||
#include <dev/ic/z8530reg.h>
|
||||
|
||||
#include "ioconf.h"
|
||||
|
||||
/* console status for consinit() */
|
||||
static struct zs_chanstate zs_conscs_store;
|
||||
struct zs_chanstate *zs_conscs = &zs_conscs_store;
|
||||
void *zs_consaddr;
|
||||
|
||||
/*
|
||||
* Some warts needed by z8530tty.c -
|
||||
* The default parity REALLY needs to be the same as the PROM uses,
|
||||
* or you can not see messages done with printf during boot-up...
|
||||
*/
|
||||
int zs_def_cflag = (CREAD | CS8 | HUPCL);
|
||||
|
||||
int
|
||||
zs_print(void *aux, const char *name)
|
||||
{
|
||||
struct zsc_attach_args *args = aux;
|
||||
|
||||
if (name != NULL)
|
||||
aprint_normal("%s: ", name);
|
||||
|
||||
if (args->channel != -1)
|
||||
aprint_normal(" channel %d", args->channel);
|
||||
|
||||
return UNCONF;
|
||||
}
|
||||
|
||||
/*
|
||||
* Our ZS chips all share a common, autovectored interrupt,
|
||||
* so we have to look at all of them on each interrupt.
|
||||
*/
|
||||
int
|
||||
zshard(void *arg)
|
||||
{
|
||||
struct zsc_softc *zsc;
|
||||
int unit, rval, softreq;
|
||||
|
||||
rval = 0;
|
||||
for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
|
||||
zsc = zsc_cd.cd_devs[unit];
|
||||
if (zsc == NULL)
|
||||
continue;
|
||||
rval |= zsc_intr_hard(zsc);
|
||||
softreq = zsc->zsc_cs[0]->cs_softreq;
|
||||
softreq |= zsc->zsc_cs[1]->cs_softreq;
|
||||
if (softreq)
|
||||
softintr_schedule(zsc->zsc_si);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Similar scheme as for zshard (look at all of them)
|
||||
*/
|
||||
void
|
||||
zssoft(void *arg)
|
||||
{
|
||||
struct zsc_softc *zsc;
|
||||
int s, unit;
|
||||
|
||||
/* Make sure we call the tty layer at spltty. */
|
||||
s = spltty();
|
||||
for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
|
||||
zsc = zsc_cd.cd_devs[unit];
|
||||
if (zsc == NULL)
|
||||
continue;
|
||||
(void)zsc_intr_soft(zsc);
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the current baud rate given a ZS channel.
|
||||
*/
|
||||
int
|
||||
zs_get_speed(struct zs_chanstate *cs)
|
||||
{
|
||||
int tconst;
|
||||
|
||||
tconst = zs_read_reg(cs, 12);
|
||||
tconst |= zs_read_reg(cs, 13) << 8;
|
||||
return TCONST_TO_BPS(cs->cs_brg_clk, tconst);
|
||||
}
|
||||
|
||||
/*
|
||||
* MD functions for setting the baud rate and control modes.
|
||||
*/
|
||||
int
|
||||
zs_set_speed(struct zs_chanstate *cs, int bps)
|
||||
{
|
||||
int tconst, real_bps;
|
||||
|
||||
if (bps == 0)
|
||||
return 0;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (cs->cs_brg_clk == 0)
|
||||
panic("zs_set_speed");
|
||||
#endif
|
||||
|
||||
tconst = BPS_TO_TCONST(cs->cs_brg_clk, bps);
|
||||
if (tconst < 0)
|
||||
return EINVAL;
|
||||
|
||||
/* Convert back to make sure we can do it. */
|
||||
real_bps = TCONST_TO_BPS(cs->cs_brg_clk, tconst);
|
||||
|
||||
/* XXX - Allow some tolerance here? */
|
||||
if (real_bps != bps)
|
||||
return EINVAL;
|
||||
|
||||
cs->cs_preg[12] = tconst;
|
||||
cs->cs_preg[13] = tconst >> 8;
|
||||
|
||||
/* Caller will stuff the pending registers. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
zs_set_modes(struct zs_chanstate *cs, int cflag)
|
||||
{
|
||||
int s;
|
||||
|
||||
/*
|
||||
* Output hardware flow control on the chip is horrendous:
|
||||
* if carrier detect drops, the receiver is disabled, and if
|
||||
* CTS drops, the transmitter is stoped IN MID CHARACTER!
|
||||
* Therefore, NEVER set the HFC bit, and instead use the
|
||||
* status interrupt to detect CTS changes.
|
||||
*/
|
||||
s = splserial();
|
||||
cs->cs_rr0_pps = 0;
|
||||
if ((cflag & (CLOCAL | MDMBUF)) != 0) {
|
||||
cs->cs_rr0_dcd = 0;
|
||||
if ((cflag & MDMBUF) == 0)
|
||||
cs->cs_rr0_pps = ZSRR0_DCD;
|
||||
} else
|
||||
cs->cs_rr0_dcd = ZSRR0_DCD;
|
||||
if ((cflag & CRTSCTS) != 0) {
|
||||
cs->cs_wr5_dtr = ZSWR5_DTR;
|
||||
cs->cs_wr5_rts = ZSWR5_RTS;
|
||||
cs->cs_rr0_cts = ZSRR0_CTS;
|
||||
} else if ((cflag & MDMBUF) != 0) {
|
||||
cs->cs_wr5_dtr = 0;
|
||||
cs->cs_wr5_rts = ZSWR5_DTR;
|
||||
cs->cs_rr0_cts = ZSRR0_DCD;
|
||||
} else {
|
||||
cs->cs_wr5_dtr = ZSWR5_DTR | ZSWR5_RTS;
|
||||
cs->cs_wr5_rts = 0;
|
||||
cs->cs_rr0_cts = 0;
|
||||
}
|
||||
splx(s);
|
||||
|
||||
/* Caller will stuff the pending registers. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read or write the chip with suitable delays.
|
||||
*/
|
||||
uint8_t
|
||||
zs_read_reg(struct zs_chanstate *cs, uint8_t reg)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
*cs->cs_reg_csr = reg;
|
||||
|
||||
val = *cs->cs_reg_csr;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
zs_write_reg(struct zs_chanstate *cs, uint8_t reg, uint8_t val)
|
||||
{
|
||||
|
||||
*cs->cs_reg_csr = reg;
|
||||
|
||||
*cs->cs_reg_csr = val;
|
||||
|
||||
}
|
||||
|
||||
uint8_t
|
||||
zs_read_csr(struct zs_chanstate *cs)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
val = *cs->cs_reg_csr;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
zs_write_csr(struct zs_chanstate *cs, uint8_t val)
|
||||
{
|
||||
|
||||
*cs->cs_reg_csr = val;
|
||||
|
||||
}
|
||||
|
||||
uint8_t
|
||||
zs_read_data(struct zs_chanstate *cs)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
val = *cs->cs_reg_data;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
zs_write_data(struct zs_chanstate *cs, uint8_t val)
|
||||
{
|
||||
|
||||
*cs->cs_reg_data = val;
|
||||
}
|
||||
|
||||
void
|
||||
zs_abort(struct zs_chanstate *cs)
|
||||
{
|
||||
|
||||
#ifdef DDB
|
||||
Debugger();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Polled input char.
|
||||
*/
|
||||
int
|
||||
zs_getc(void *arg)
|
||||
{
|
||||
struct zs_chanstate *cs = arg;
|
||||
int s, c, rr0;
|
||||
|
||||
s = splhigh();
|
||||
/* Wait for a character to arrive. */
|
||||
do {
|
||||
rr0 = *cs->cs_reg_csr;
|
||||
ZS_DELAY();
|
||||
} while ((rr0 & ZSRR0_RX_READY) == 0);
|
||||
|
||||
c = *cs->cs_reg_data;
|
||||
ZS_DELAY();
|
||||
splx(s);
|
||||
|
||||
/*
|
||||
* This could be used by the kd driver to read scan codes,
|
||||
* so don't translate '\r' ==> '\n' here...
|
||||
*/
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Polled output char.
|
||||
*/
|
||||
void
|
||||
zs_putc(void *arg, int c)
|
||||
{
|
||||
struct zs_chanstate *cs = arg;
|
||||
int s, rr0;
|
||||
|
||||
s = splhigh();
|
||||
/* Wait for transmitter to become ready. */
|
||||
do {
|
||||
rr0 = *cs->cs_reg_csr;
|
||||
ZS_DELAY();
|
||||
} while ((rr0 & ZSRR0_TX_READY) == 0);
|
||||
|
||||
*cs->cs_reg_data = c;
|
||||
ZS_DELAY();
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
zscngetc(dev_t dev)
|
||||
{
|
||||
|
||||
return zs_getc((void *)zs_conscs);
|
||||
}
|
||||
|
||||
void
|
||||
zscnputc(dev_t dev, int c)
|
||||
{
|
||||
|
||||
zs_putc((void *)zs_conscs, c);
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/* $NetBSD: autoconf.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include "opt_sbd.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <machine/sbdvar.h>
|
||||
#include <machine/disklabel.h>
|
||||
|
||||
char __boot_kernel_name[64];
|
||||
|
||||
void
|
||||
cpu_configure(void)
|
||||
{
|
||||
|
||||
intr_init();
|
||||
|
||||
splhigh();
|
||||
if (config_rootfound("mainbus", NULL) == NULL)
|
||||
panic("no mainbus found");
|
||||
spl0();
|
||||
}
|
||||
|
||||
void
|
||||
cpu_rootconf(void)
|
||||
{
|
||||
struct device *dv;
|
||||
char *p;
|
||||
const char *bootdev_name, *netdev_name;
|
||||
int unit, partition;
|
||||
|
||||
/* Extract boot device */
|
||||
for (p = __boot_kernel_name; *p; p++) {
|
||||
if (*p == ':') {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
p = __boot_kernel_name;
|
||||
|
||||
bootdev_name = 0;
|
||||
unit = 0;
|
||||
|
||||
switch (SBD_INFO->machine) {
|
||||
#ifdef EWS4800_TR2
|
||||
case MACHINE_TR2:
|
||||
netdev_name = "iee0";
|
||||
break;
|
||||
#endif
|
||||
#ifdef EWS4800_TR2A
|
||||
case MACHINE_TR2A:
|
||||
netdev_name = "le0";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
netdev_name = NULL;
|
||||
}
|
||||
partition = 0;
|
||||
|
||||
if (strncmp(p, "sd", 2) == 0) {
|
||||
unit = p[2] - '0';
|
||||
partition = p[3] - 'a';
|
||||
if (unit >= 0 && unit <= 9 && partition >= 0 &&
|
||||
partition < MAXPARTITIONS) {
|
||||
p[3] = '\0';
|
||||
bootdev_name = __boot_kernel_name;
|
||||
}
|
||||
} else if (strncmp(p, "nfs", 3) == 0) {
|
||||
bootdev_name = netdev_name;
|
||||
} else if (strncmp(p, "mem", 3) == 0) {
|
||||
int bootdev = (*platform.ipl_bootdev)();
|
||||
if (bootdev == NVSRAM_BOOTDEV_HARDDISK)
|
||||
bootdev_name = "sd0";
|
||||
else if (bootdev == NVSRAM_BOOTDEV_NETWORK)
|
||||
bootdev_name = netdev_name;
|
||||
else
|
||||
bootdev_name = 0;
|
||||
}
|
||||
|
||||
dv = 0;
|
||||
if (bootdev_name) {
|
||||
for (dv = alldevs.tqh_first; dv; dv = dv->dv_list.tqe_next) {
|
||||
if (strcmp(dv->dv_xname, bootdev_name) == 0) {
|
||||
setroot(dv, partition);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dv == 0)
|
||||
setroot(0, 0);
|
||||
}
|
|
@ -0,0 +1,679 @@
|
|||
/* $NetBSD: bus_dma.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
/* #define BUS_DMA_DEBUG */
|
||||
#include <sys/param.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <mips/cache.h>
|
||||
|
||||
#define _EWS4800MIPS_BUS_DMA_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
extern paddr_t kvtophys(vaddr_t); /* XXX */
|
||||
static int _bus_dmamap_load_buffer(bus_dmamap_t, void *, bus_size_t,
|
||||
struct proc *, int, vaddr_t *, int *, int);
|
||||
|
||||
struct ews4800mips_bus_dma_tag ews4800mips_default_bus_dma_tag = {
|
||||
_bus_dmamap_create,
|
||||
_bus_dmamap_destroy,
|
||||
_bus_dmamap_load,
|
||||
_bus_dmamap_load_mbuf,
|
||||
_bus_dmamap_load_uio,
|
||||
_bus_dmamap_load_raw,
|
||||
_bus_dmamap_unload,
|
||||
_bus_dmamap_sync,
|
||||
_bus_dmamem_alloc,
|
||||
_bus_dmamem_free,
|
||||
_bus_dmamem_map,
|
||||
_bus_dmamem_unmap,
|
||||
_bus_dmamem_mmap,
|
||||
};
|
||||
|
||||
/*
|
||||
* Common function for DMA map creation. May be called by bus-specific
|
||||
* DMA map creation functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
|
||||
bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
|
||||
{
|
||||
struct ews4800mips_bus_dmamap *map;
|
||||
void *mapstore;
|
||||
size_t mapsize;
|
||||
|
||||
/*
|
||||
* Allcoate and initialize the DMA map. The end of the map
|
||||
* is a variable-sized array of segments, so we allocate enough
|
||||
* room for them in one shot.
|
||||
*
|
||||
* Note we don't preserve the WAITOK or NOWAIT flags. Preservation
|
||||
* of ALLOCNOW notifes others that we've reserved these resources,
|
||||
* and they are not to be freed.
|
||||
*
|
||||
* The bus_dmamap_t includes one bus_dma_segment_t, hence
|
||||
* the (nsegments - 1).
|
||||
*/
|
||||
mapsize = sizeof(struct ews4800mips_bus_dmamap) +
|
||||
(sizeof(bus_dma_segment_t) * (nsegments - 1));
|
||||
if ((mapstore = malloc(mapsize, M_DMAMAP,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
memset(mapstore, 0, mapsize);
|
||||
map = (struct ews4800mips_bus_dmamap *)mapstore;
|
||||
map->_dm_size = size;
|
||||
map->_dm_segcnt = nsegments;
|
||||
map->_dm_maxmaxsegsz = maxsegsz;
|
||||
map->_dm_boundary = boundary;
|
||||
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
|
||||
map->dm_maxsegsz = maxsegsz;
|
||||
map->dm_mapsize = 0; /* no valid mappings */
|
||||
map->dm_nsegs = 0;
|
||||
|
||||
*dmamp = map;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for DMA map destruction. May be called by bus-specific
|
||||
* DMA map destruction functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
|
||||
{
|
||||
|
||||
free(map, M_DMAMAP);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Utility function to load a linear buffer. lastaddrp holds state
|
||||
* between invocations (for multiple-buffer loads). segp contains
|
||||
* the starting segment on entrance, and the ending segment on exit.
|
||||
* first indicates if this is the first invocation of this function.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_buffer(bus_dmamap_t map, void *buf, bus_size_t buflen,
|
||||
struct proc *p, int flags, vaddr_t *lastaddrp, int *segp, int first)
|
||||
{
|
||||
bus_size_t sgsize;
|
||||
bus_addr_t curaddr, lastaddr, baddr, bmask;
|
||||
vaddr_t vaddr = (vaddr_t)buf;
|
||||
int seg;
|
||||
|
||||
lastaddr = *lastaddrp;
|
||||
bmask = ~(map->_dm_boundary - 1);
|
||||
|
||||
for (seg = *segp; buflen > 0 ; ) {
|
||||
/*
|
||||
* Get the physical address for this segment.
|
||||
*/
|
||||
if (p != NULL)
|
||||
(void) pmap_extract(p->p_vmspace->vm_map.pmap,
|
||||
vaddr, (paddr_t *)&curaddr);
|
||||
else
|
||||
curaddr = kvtophys(vaddr);
|
||||
|
||||
/*
|
||||
* Compute the segment size, and adjust counts.
|
||||
*/
|
||||
sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
|
||||
if (buflen < sgsize)
|
||||
sgsize = buflen;
|
||||
|
||||
/*
|
||||
* Make sure we don't cross any boundaries.
|
||||
*/
|
||||
if (map->_dm_boundary > 0) {
|
||||
baddr = (curaddr + map->_dm_boundary) & bmask;
|
||||
if (sgsize > (baddr - curaddr))
|
||||
sgsize = (baddr - curaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert chunk into a segment, coalescing with
|
||||
* the previous segment if possible.
|
||||
*/
|
||||
if (first) {
|
||||
map->dm_segs[seg].ds_addr = curaddr;
|
||||
map->dm_segs[seg].ds_len = sgsize;
|
||||
map->dm_segs[seg]._ds_vaddr = vaddr;
|
||||
first = 0;
|
||||
} else {
|
||||
if (curaddr == lastaddr &&
|
||||
(map->dm_segs[seg].ds_len + sgsize) <=
|
||||
map->dm_maxsegsz &&
|
||||
(map->_dm_boundary == 0 ||
|
||||
(map->dm_segs[seg].ds_addr & bmask) ==
|
||||
(curaddr & bmask)))
|
||||
map->dm_segs[seg].ds_len += sgsize;
|
||||
else {
|
||||
if (++seg >= map->_dm_segcnt)
|
||||
break;
|
||||
map->dm_segs[seg].ds_addr = curaddr;
|
||||
map->dm_segs[seg].ds_len = sgsize;
|
||||
map->dm_segs[seg]._ds_vaddr = vaddr;
|
||||
}
|
||||
}
|
||||
|
||||
lastaddr = curaddr + sgsize;
|
||||
vaddr += sgsize;
|
||||
buflen -= sgsize;
|
||||
}
|
||||
|
||||
*segp = seg;
|
||||
*lastaddrp = lastaddr;
|
||||
|
||||
/*
|
||||
* Did we fit?
|
||||
*/
|
||||
if (buflen != 0)
|
||||
return EFBIG; /* XXX Better return value here? */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for loading a direct-mapped DMA map with a linear
|
||||
* buffer.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
||||
bus_size_t buflen, struct proc *p, int flags)
|
||||
{
|
||||
vaddr_t lastaddr;
|
||||
int seg, error;
|
||||
|
||||
/*
|
||||
* Make sure that on error condition we return "no valid mappings".
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
|
||||
|
||||
if (buflen > map->_dm_size)
|
||||
return EINVAL;
|
||||
|
||||
seg = 0;
|
||||
error = _bus_dmamap_load_buffer(map, buf, buflen,
|
||||
p, flags, &lastaddr, &seg, 1);
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = buflen;
|
||||
map->dm_nsegs = seg + 1;
|
||||
|
||||
/*
|
||||
* For linear buffers, we support marking the mapping
|
||||
* as COHERENT.
|
||||
*
|
||||
* XXX Check TLB entries for cache-inhibit bits?
|
||||
*/
|
||||
if (buf >= (void *)MIPS_KSEG1_START &&
|
||||
buf < (void *)MIPS_KSEG2_START)
|
||||
map->_dm_flags |= EWS4800MIPS_DMAMAP_COHERENT;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for mbufs.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
|
||||
int flags)
|
||||
{
|
||||
vaddr_t lastaddr;
|
||||
int seg, error, first;
|
||||
struct mbuf *m;
|
||||
|
||||
/*
|
||||
* Make sure that on error condition we return "no valid mappings."
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((m0->m_flags & M_PKTHDR) == 0)
|
||||
panic("_bus_dmamap_load_mbuf: no packet header");
|
||||
#endif
|
||||
|
||||
if (m0->m_pkthdr.len > map->_dm_size)
|
||||
return EINVAL;
|
||||
|
||||
first = 1;
|
||||
seg = 0;
|
||||
error = 0;
|
||||
for (m = m0; m != NULL && error == 0; m = m->m_next) {
|
||||
error = _bus_dmamap_load_buffer(map,
|
||||
m->m_data, m->m_len, NULL, flags, &lastaddr, &seg, first);
|
||||
first = 0;
|
||||
}
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = m0->m_pkthdr.len;
|
||||
map->dm_nsegs = seg + 1;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for uios.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio,
|
||||
int flags)
|
||||
{
|
||||
vaddr_t lastaddr;
|
||||
int seg, i, error, first;
|
||||
bus_size_t minlen, resid;
|
||||
struct proc *p = NULL;
|
||||
struct iovec *iov;
|
||||
void *addr;
|
||||
|
||||
/*
|
||||
* Make sure that on error condition we return "no valid mappings."
|
||||
*/
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
KASSERT(map->dm_maxsegsz <= map->_dm_maxmaxsegsz);
|
||||
|
||||
resid = uio->uio_resid;
|
||||
iov = uio->uio_iov;
|
||||
|
||||
if (uio->uio_segflg == UIO_USERSPACE) {
|
||||
p = uio->uio_lwp ? uio->uio_lwp->l_proc : NULL;
|
||||
#ifdef DIAGNOSTIC
|
||||
if (p == NULL)
|
||||
panic("_bus_dmamap_load_uio: USERSPACE but no proc");
|
||||
#endif
|
||||
}
|
||||
|
||||
first = 1;
|
||||
seg = 0;
|
||||
error = 0;
|
||||
for (i = 0; i < uio->uio_iovcnt && resid != 0 && error == 0; i++) {
|
||||
/*
|
||||
* Now at the first iovec to load. Load each iovec
|
||||
* until we have exhausted the residual count.
|
||||
*/
|
||||
minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len;
|
||||
addr = (void *)iov[i].iov_base;
|
||||
|
||||
error = _bus_dmamap_load_buffer(map, addr, minlen,
|
||||
p, flags, &lastaddr, &seg, first);
|
||||
first = 0;
|
||||
|
||||
resid -= minlen;
|
||||
}
|
||||
if (error == 0) {
|
||||
map->dm_mapsize = uio->uio_resid;
|
||||
map->dm_nsegs = seg + 1;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Like _bus_dmamap_load(), but for raw memory.
|
||||
*/
|
||||
int
|
||||
_bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map,
|
||||
bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
|
||||
{
|
||||
|
||||
panic("_bus_dmamap_load_raw: not implemented");
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for unloading a DMA map. May be called by
|
||||
* chipset-specific DMA map unload functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
|
||||
{
|
||||
|
||||
/*
|
||||
* No resources to free; just mark the mappings as
|
||||
* invalid.
|
||||
*/
|
||||
map->dm_maxsegsz = map->_dm_maxmaxsegsz;
|
||||
map->dm_mapsize = 0;
|
||||
map->dm_nsegs = 0;
|
||||
map->_dm_flags &= ~EWS4800MIPS_DMAMAP_COHERENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for DMA map synchronization. May be called
|
||||
* by chipset-specific DMA map synchronization functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
|
||||
bus_size_t len, int ops)
|
||||
{
|
||||
bus_size_t minlen;
|
||||
bus_addr_t addr;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Mising PRE and POST operations is not allowed.
|
||||
*/
|
||||
if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 &&
|
||||
(ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0)
|
||||
panic("_bus_dmamap_sync: mix PRE and POST");
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (offset >= map->dm_mapsize)
|
||||
panic("_bus_dmamap_sync: bad offset %lu (map size is %lu)",
|
||||
offset, map->dm_mapsize);
|
||||
if (len == 0 || (offset + len) > map->dm_mapsize)
|
||||
panic("_bus_dmamap_sync: bad length");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flush the write buffer.
|
||||
*/
|
||||
wbflush();
|
||||
|
||||
/*
|
||||
* If the mapping is of COHERENT DMA-safe memory, no cache
|
||||
* flush is necessary.
|
||||
*/
|
||||
if (map->_dm_flags & EWS4800MIPS_DMAMAP_COHERENT)
|
||||
return;
|
||||
|
||||
/*
|
||||
* No cache flushes are necessary if we're only doing
|
||||
* POSTREAD or POSTWRITE (i.e. not doing PREREAD or PREWRITE).
|
||||
*/
|
||||
if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) == 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Flush data cache for PREREAD. This has the side-effect
|
||||
* of invalidating the cache. Done at PREREAD since it
|
||||
* causes the cache line(s) to be written back to memory.
|
||||
*
|
||||
* Flush data cache for PREWRITE, so that the contents of
|
||||
* the data buffer in memory reflect reality.
|
||||
*
|
||||
* Given the test above, we know we're doing one of these
|
||||
* two operations, so no additional tests are necessary.
|
||||
*/
|
||||
|
||||
for (i = 0; i < map->dm_nsegs && len != 0; i++) {
|
||||
/* Find the beginning segment. */
|
||||
if (offset >= map->dm_segs[i].ds_len) {
|
||||
offset -= map->dm_segs[i].ds_len;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now at the first segment to sync; nail
|
||||
* each segment until we have exhausted the
|
||||
* length.
|
||||
*/
|
||||
minlen = len < map->dm_segs[i].ds_len - offset ?
|
||||
len : map->dm_segs[i].ds_len - offset;
|
||||
|
||||
addr = map->dm_segs[i]._ds_vaddr;
|
||||
|
||||
#ifdef BUS_DMA_DEBUG
|
||||
printf("bus_dmamap_sync: flushing segment %d "
|
||||
"(0x%lx..0x%lx) ...", i, addr + offset,
|
||||
addr + offset + minlen - 1);
|
||||
#endif
|
||||
mips_dcache_wbinv_range(addr + offset, minlen);
|
||||
|
||||
#ifdef BUS_DMA_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
offset = 0;
|
||||
len -= minlen;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for DMA-safe memory allocation. May be called
|
||||
* by bus-specific DMA memory allocation functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
|
||||
bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
|
||||
int flags)
|
||||
{
|
||||
extern paddr_t avail_start, avail_end;
|
||||
vaddr_t curaddr, lastaddr;
|
||||
psize_t high;
|
||||
struct vm_page *m;
|
||||
struct pglist mlist;
|
||||
int curseg, error;
|
||||
|
||||
/* Always round the size. */
|
||||
size = round_page(size);
|
||||
|
||||
high = avail_end - PAGE_SIZE;
|
||||
|
||||
/*
|
||||
* Allocate pages from the VM system.
|
||||
*/
|
||||
error = uvm_pglistalloc(size, avail_start, high, alignment, boundary,
|
||||
&mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
/*
|
||||
* Compute the location, size, and number of segments actually
|
||||
* returned by the VM code.
|
||||
*/
|
||||
m = mlist.tqh_first;
|
||||
curseg = 0;
|
||||
lastaddr = segs[curseg].ds_addr = VM_PAGE_TO_PHYS(m);
|
||||
segs[curseg].ds_len = PAGE_SIZE;
|
||||
m = m->pageq.tqe_next;
|
||||
|
||||
for (; m != NULL; m = m->pageq.tqe_next) {
|
||||
curaddr = VM_PAGE_TO_PHYS(m);
|
||||
#ifdef DIAGNOSTIC
|
||||
if (curaddr < avail_start || curaddr >= high) {
|
||||
printf("uvm_pglistalloc returned non-sensical"
|
||||
" address 0x%lx\n", curaddr);
|
||||
panic("_bus_dmamem_alloc");
|
||||
}
|
||||
#endif
|
||||
if (curaddr == (lastaddr + PAGE_SIZE))
|
||||
segs[curseg].ds_len += PAGE_SIZE;
|
||||
else {
|
||||
curseg++;
|
||||
segs[curseg].ds_addr = curaddr;
|
||||
segs[curseg].ds_len = PAGE_SIZE;
|
||||
}
|
||||
lastaddr = curaddr;
|
||||
}
|
||||
|
||||
*rsegs = curseg + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for freeing DMA-safe memory. May be called by
|
||||
* bus-specific DMA memory free functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
|
||||
{
|
||||
struct vm_page *m;
|
||||
bus_addr_t addr;
|
||||
struct pglist mlist;
|
||||
int curseg;
|
||||
|
||||
/*
|
||||
* Build a list of pages to free back to the VM system.
|
||||
*/
|
||||
TAILQ_INIT(&mlist);
|
||||
for (curseg = 0; curseg < nsegs; curseg++) {
|
||||
for (addr = segs[curseg].ds_addr;
|
||||
addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
|
||||
addr += PAGE_SIZE) {
|
||||
m = PHYS_TO_VM_PAGE(addr);
|
||||
TAILQ_INSERT_TAIL(&mlist, m, pageq);
|
||||
}
|
||||
}
|
||||
|
||||
uvm_pglistfree(&mlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for mapping DMA-safe memory. May be called by
|
||||
* bus-specific DMA memory map functions.
|
||||
*/
|
||||
int
|
||||
_bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
size_t size, caddr_t *kvap, int flags)
|
||||
{
|
||||
vaddr_t va;
|
||||
bus_addr_t addr;
|
||||
int curseg;
|
||||
const uvm_flag_t kmflags =
|
||||
(flags & BUS_DMA_NOWAIT) != 0 ? UVM_KMF_NOWAIT : 0;
|
||||
|
||||
/*
|
||||
* If we're only mapping 1 segment, use KSEG0 or KSEG1, to avoid
|
||||
* TLB thrashing.
|
||||
*/
|
||||
if (nsegs == 1) {
|
||||
if (flags & BUS_DMA_COHERENT)
|
||||
*kvap = (void *)MIPS_PHYS_TO_KSEG1(segs[0].ds_addr);
|
||||
else
|
||||
*kvap = (void *)MIPS_PHYS_TO_KSEG0(segs[0].ds_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = round_page(size);
|
||||
|
||||
va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
|
||||
|
||||
if (va == 0)
|
||||
return (ENOMEM);
|
||||
|
||||
*kvap = (void *)va;
|
||||
|
||||
for (curseg = 0; curseg < nsegs; curseg++) {
|
||||
for (addr = segs[curseg].ds_addr;
|
||||
addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
|
||||
addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) {
|
||||
if (size == 0)
|
||||
panic("_bus_dmamem_map: size botch");
|
||||
pmap_enter(pmap_kernel(), va, addr,
|
||||
VM_PROT_READ | VM_PROT_WRITE,
|
||||
VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
|
||||
|
||||
/* XXX Do something about COHERENT here. */
|
||||
}
|
||||
}
|
||||
pmap_update(pmap_kernel());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common function for unmapping DMA-safe memory. May be called by
|
||||
* bus-specific DMA memory unmapping functions.
|
||||
*/
|
||||
void
|
||||
_bus_dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
|
||||
{
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if ((u_long)kva & PGOFSET)
|
||||
panic("_bus_dmamem_unmap");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Nothing to do if we mapped it with KSEG0 or KSEG1 (i.e.
|
||||
* not in KSEG2).
|
||||
*/
|
||||
if (kva >= (caddr_t)MIPS_KSEG0_START &&
|
||||
kva < (caddr_t)MIPS_KSEG2_START)
|
||||
return;
|
||||
|
||||
size = round_page(size);
|
||||
pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size);
|
||||
pmap_update(pmap_kernel());
|
||||
uvm_km_free(kernel_map, (vaddr_t)kva, size, UVM_KMF_VAONLY);
|
||||
}
|
||||
|
||||
/*
|
||||
* Common functin for mmap(2)'ing DMA-safe memory. May be called by
|
||||
* bus-specific DMA mmap(2)'ing functions.
|
||||
*/
|
||||
paddr_t
|
||||
_bus_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
|
||||
off_t off, int prot, int flags)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nsegs; i++) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (off & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: offset unaligned");
|
||||
if (segs[i].ds_addr & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: segment unaligned");
|
||||
if (segs[i].ds_len & PGOFSET)
|
||||
panic("_bus_dmamem_mmap: segment size not multiple"
|
||||
" of page size");
|
||||
#endif
|
||||
if (off >= segs[i].ds_len) {
|
||||
off -= segs[i].ds_len;
|
||||
continue;
|
||||
}
|
||||
|
||||
return mips_btop((caddr_t)segs[i].ds_addr + off);
|
||||
}
|
||||
|
||||
/* Page not found. */
|
||||
return -1;
|
||||
}
|
|
@ -0,0 +1,316 @@
|
|||
/* $NetBSD: bus_space.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/extent.h>
|
||||
|
||||
#define _EWS4800MIPS_BUS_SPACE_PRIVATE
|
||||
#include <machine/bus.h>
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
#ifdef BUS_SPACE_DEBUG
|
||||
int bus_space_debug = 0;
|
||||
#define DPRINTF(fmt, args...) \
|
||||
if (bus_space_debug) \
|
||||
printf("%s: " fmt, __FUNCTION__ , ##args)
|
||||
#define DPRINTFN(n, arg) \
|
||||
if (bus_space_debug > (n)) \
|
||||
printf("%s: " fmt, __FUNCTION__ , ##args)
|
||||
#else
|
||||
#define DPRINTF(arg...) ((void)0)
|
||||
#define DPRINTFN(n, arg...) ((void)0)
|
||||
#endif
|
||||
|
||||
#define VADDR(h, o) (h + o)
|
||||
_BUS_SPACE_READ(_default, 1, 8)
|
||||
_BUS_SPACE_READ(_default, 2, 16)
|
||||
_BUS_SPACE_READ(_default, 4, 32)
|
||||
_BUS_SPACE_READ(_default, 8, 64)
|
||||
_BUS_SPACE_READ_MULTI(_default, 1, 8)
|
||||
_BUS_SPACE_READ_MULTI(_default, 2, 16)
|
||||
_BUS_SPACE_READ_MULTI(_default, 4, 32)
|
||||
_BUS_SPACE_READ_MULTI(_default, 8, 64)
|
||||
_BUS_SPACE_READ_REGION(_default, 1, 8)
|
||||
_BUS_SPACE_READ_REGION(_default, 2, 16)
|
||||
_BUS_SPACE_READ_REGION(_default, 4, 32)
|
||||
_BUS_SPACE_READ_REGION(_default, 8, 64)
|
||||
_BUS_SPACE_WRITE(_default, 1, 8)
|
||||
_BUS_SPACE_WRITE(_default, 2, 16)
|
||||
_BUS_SPACE_WRITE(_default, 4, 32)
|
||||
_BUS_SPACE_WRITE(_default, 8, 64)
|
||||
_BUS_SPACE_WRITE_MULTI(_default, 1, 8)
|
||||
_BUS_SPACE_WRITE_MULTI(_default, 2, 16)
|
||||
_BUS_SPACE_WRITE_MULTI(_default, 4, 32)
|
||||
_BUS_SPACE_WRITE_MULTI(_default, 8, 64)
|
||||
_BUS_SPACE_WRITE_REGION(_default, 1, 8)
|
||||
_BUS_SPACE_WRITE_REGION(_default, 2, 16)
|
||||
_BUS_SPACE_WRITE_REGION(_default, 4, 32)
|
||||
_BUS_SPACE_WRITE_REGION(_default, 8, 64)
|
||||
_BUS_SPACE_SET_MULTI(_default, 1, 8)
|
||||
_BUS_SPACE_SET_MULTI(_default, 2, 16)
|
||||
_BUS_SPACE_SET_MULTI(_default, 4, 32)
|
||||
_BUS_SPACE_SET_MULTI(_default, 8, 64)
|
||||
_BUS_SPACE_SET_REGION(_default, 1, 8)
|
||||
_BUS_SPACE_SET_REGION(_default, 2, 16)
|
||||
_BUS_SPACE_SET_REGION(_default, 4, 32)
|
||||
_BUS_SPACE_SET_REGION(_default, 8, 64)
|
||||
_BUS_SPACE_COPY_REGION(_default, 1, 8)
|
||||
_BUS_SPACE_COPY_REGION(_default, 2, 16)
|
||||
_BUS_SPACE_COPY_REGION(_default, 4, 32)
|
||||
_BUS_SPACE_COPY_REGION(_default, 8, 64)
|
||||
#undef VADDR
|
||||
|
||||
static int _default_map(void *, bus_addr_t, bus_size_t, int,
|
||||
bus_space_handle_t *);
|
||||
static void _default_unmap(void *, bus_space_handle_t, bus_size_t);
|
||||
static int _default_subregion(void *, bus_space_handle_t, bus_size_t,
|
||||
bus_size_t, bus_space_handle_t *);
|
||||
static int _default_alloc(void *, bus_addr_t, bus_addr_t, bus_size_t,
|
||||
bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
|
||||
static void _default_free(void *, bus_space_handle_t, bus_size_t);
|
||||
static void *_default_vaddr(void *, bus_space_handle_t);
|
||||
|
||||
static const struct ews4800mips_bus_space _default_bus_space = {
|
||||
ebs_map : _default_map,
|
||||
ebs_unmap : _default_unmap,
|
||||
ebs_subregion : _default_subregion,
|
||||
ebs_alloc : _default_alloc,
|
||||
ebs_free : _default_free,
|
||||
ebs_vaddr : _default_vaddr,
|
||||
ebs_r_1 : _default_read_1,
|
||||
ebs_r_2 : _default_read_2,
|
||||
ebs_r_4 : _default_read_4,
|
||||
ebs_r_8 : _default_read_8,
|
||||
ebs_rm_1 : _default_read_multi_1,
|
||||
ebs_rm_2 : _default_read_multi_2,
|
||||
ebs_rm_4 : _default_read_multi_4,
|
||||
ebs_rm_8 : _default_read_multi_8,
|
||||
ebs_rr_1 : _default_read_region_1,
|
||||
ebs_rr_2 : _default_read_region_2,
|
||||
ebs_rr_4 : _default_read_region_4,
|
||||
ebs_rr_8 : _default_read_region_8,
|
||||
ebs_w_1 : _default_write_1,
|
||||
ebs_w_2 : _default_write_2,
|
||||
ebs_w_4 : _default_write_4,
|
||||
ebs_w_8 : _default_write_8,
|
||||
ebs_wm_1 : _default_write_multi_1,
|
||||
ebs_wm_2 : _default_write_multi_2,
|
||||
ebs_wm_4 : _default_write_multi_4,
|
||||
ebs_wm_8 : _default_write_multi_8,
|
||||
ebs_wr_1 : _default_write_region_1,
|
||||
ebs_wr_2 : _default_write_region_2,
|
||||
ebs_wr_4 : _default_write_region_4,
|
||||
ebs_wr_8 : _default_write_region_8,
|
||||
ebs_sm_1 : _default_set_multi_1,
|
||||
ebs_sm_2 : _default_set_multi_2,
|
||||
ebs_sm_4 : _default_set_multi_4,
|
||||
ebs_sm_8 : _default_set_multi_8,
|
||||
ebs_sr_1 : _default_set_region_1,
|
||||
ebs_sr_2 : _default_set_region_2,
|
||||
ebs_sr_4 : _default_set_region_4,
|
||||
ebs_sr_8 : _default_set_region_8,
|
||||
ebs_c_1 : _default_copy_region_1,
|
||||
ebs_c_2 : _default_copy_region_2,
|
||||
ebs_c_4 : _default_copy_region_4,
|
||||
ebs_c_8 : _default_copy_region_8
|
||||
};
|
||||
|
||||
/* create default bus_space_tag */
|
||||
int
|
||||
bus_space_create(bus_space_tag_t t, const char *name,
|
||||
bus_addr_t addr, bus_size_t size)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
|
||||
if (ebs == NULL)
|
||||
return EFAULT;
|
||||
|
||||
/* set default method */
|
||||
*ebs = _default_bus_space; /* structure assignment */
|
||||
ebs->ebs_cookie = ebs;
|
||||
|
||||
/* set access region */
|
||||
if (size == 0) {
|
||||
/* no extent */
|
||||
ebs->ebs_base_addr = addr;
|
||||
ebs->ebs_size = size;
|
||||
} else {
|
||||
ebs->ebs_extent = extent_create(name, addr, addr + size - 1,
|
||||
M_DEVBUF, 0, 0, EX_NOWAIT);
|
||||
if (ebs->ebs_extent == NULL) {
|
||||
panic("%s:: unable to create bus_space for "
|
||||
"0x%08lx-%#lx", __FUNCTION__, addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
bus_space_destroy(bus_space_tag_t t)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
struct extent *ex = ebs->ebs_extent;
|
||||
|
||||
if (ex != NULL)
|
||||
extent_destroy(ex);
|
||||
}
|
||||
|
||||
void
|
||||
_bus_space_invalid_access(void)
|
||||
{
|
||||
|
||||
panic("invalid bus space access.");
|
||||
}
|
||||
|
||||
/* default bus_space tag */
|
||||
static int
|
||||
_default_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
struct extent *ex = ebs->ebs_extent;
|
||||
int error;
|
||||
|
||||
if (ex == NULL) {
|
||||
if (bpa + size > ebs->ebs_size)
|
||||
return EFAULT;
|
||||
*bshp = (bus_space_handle_t)(ebs->ebs_base_addr + bpa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bpa += ex->ex_start;
|
||||
error = extent_alloc_region(ex, bpa, size, EX_NOWAIT | EX_MALLOCOK);
|
||||
|
||||
if (error) {
|
||||
DPRINTF("failed.\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
*bshp = (bus_space_handle_t)bpa;
|
||||
|
||||
DPRINTF("success.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_default_subregion(void *t, bus_space_handle_t bsh,
|
||||
bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
|
||||
{
|
||||
|
||||
*nbshp = bsh + offset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_default_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
|
||||
bus_size_t size, bus_size_t alignment, bus_size_t boundary,
|
||||
int flags, bus_addr_t *bpap, bus_space_handle_t *bshp)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
struct extent *ex = ebs->ebs_extent;
|
||||
u_long bpa, base;
|
||||
int error;
|
||||
|
||||
if (ex == NULL) {
|
||||
if (rend > ebs->ebs_size)
|
||||
return EFAULT;
|
||||
*bshp = *bpap = rstart + ebs->ebs_base_addr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
base = ex->ex_start;
|
||||
|
||||
error = extent_alloc_subregion(ex, rstart + base, rend + base, size,
|
||||
alignment, boundary,
|
||||
EX_FAST | EX_NOWAIT | EX_MALLOCOK,
|
||||
&bpa);
|
||||
|
||||
if (error) {
|
||||
DPRINTF("failed.\n");
|
||||
return error;
|
||||
}
|
||||
|
||||
*bshp = (bus_space_handle_t)bpa;
|
||||
|
||||
if (bpap)
|
||||
*bpap = bpa;
|
||||
|
||||
DPRINTF("success.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_default_free(void *t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
struct extent *ex = ebs->ebs_extent;
|
||||
|
||||
if (ex != NULL)
|
||||
_default_unmap(t, bsh, size);
|
||||
}
|
||||
|
||||
static void
|
||||
_default_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
|
||||
{
|
||||
struct ews4800mips_bus_space *ebs = t;
|
||||
struct extent *ex = ebs->ebs_extent;
|
||||
int error;
|
||||
|
||||
if (ex == NULL)
|
||||
return;
|
||||
|
||||
error = extent_free(ex, bsh, size, EX_NOWAIT);
|
||||
|
||||
if (error) {
|
||||
DPRINTF("%#lx-%#lx of %s space lost\n", bsh, bsh + size,
|
||||
ex->ex_name);
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
_default_vaddr(void *t, bus_space_handle_t h)
|
||||
{
|
||||
|
||||
return (void *)h;
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/* $NetBSD: clock.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h> /* time */
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <mips/locore.h> /* mips3_cp0_count_read */
|
||||
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
static todr_chip_handle_t todr_handle;
|
||||
|
||||
#define MINYEAR 2005 /* "today" */
|
||||
|
||||
void
|
||||
cpu_initclocks(void)
|
||||
{
|
||||
|
||||
KASSERT(platform.initclocks);
|
||||
|
||||
(*platform.initclocks)();
|
||||
}
|
||||
|
||||
void
|
||||
setstatclockrate(int arg)
|
||||
{
|
||||
|
||||
/* not yet */
|
||||
}
|
||||
|
||||
/*
|
||||
* Common parts of todclock autoconfiguration.
|
||||
*/
|
||||
void
|
||||
todr_attach(todr_chip_handle_t handle)
|
||||
{
|
||||
|
||||
if (todr_handle)
|
||||
panic("todr_attach: too many todclocks configured");
|
||||
|
||||
todr_handle = handle;
|
||||
}
|
||||
|
||||
void
|
||||
inittodr(time_t base)
|
||||
{
|
||||
int badbase, waszero;
|
||||
|
||||
badbase = 0;
|
||||
waszero = (base == 0);
|
||||
|
||||
if (base < 5 * SECYR) {
|
||||
/*
|
||||
* If base is 0, assume filesystem time is just unknown
|
||||
* in stead of preposterous. Don't bark.
|
||||
*/
|
||||
if (base != 0)
|
||||
printf("WARNING: preposterous time in file system\n");
|
||||
/* not going to use it anyway, if the chip is readable */
|
||||
/* 2005/10/01 12:00:00 */
|
||||
base = 35*SECYR + 273*SECDAY + SECDAY/2;
|
||||
badbase = 1;
|
||||
}
|
||||
|
||||
if (todr_gettime(todr_handle, &time) != 0 || time.tv_sec == 0) {
|
||||
printf("WARNING: bad date in battery clock");
|
||||
/*
|
||||
* Believe the time in the file system for lack of
|
||||
* anything better, resetting the clock.
|
||||
*/
|
||||
time.tv_sec = base;
|
||||
if (!badbase)
|
||||
resettodr();
|
||||
} else {
|
||||
int deltat = time.tv_sec - base;
|
||||
|
||||
if (deltat < 0)
|
||||
deltat = -deltat;
|
||||
if (waszero || deltat < 2 * SECDAY)
|
||||
return;
|
||||
printf("WARNING: clock %s %d days",
|
||||
time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
|
||||
}
|
||||
printf(" -- CHECK AND RESET THE DATE!\n");
|
||||
}
|
||||
|
||||
void
|
||||
resettodr(void)
|
||||
{
|
||||
|
||||
if (time.tv_sec == 0)
|
||||
return;
|
||||
|
||||
if (todr_settime(todr_handle, &time) != 0)
|
||||
printf("resettodr: cannot set time in time-of-day clock\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the best possible estimate of the time in the timeval to
|
||||
* which tv points.
|
||||
*/
|
||||
void
|
||||
microtime(struct timeval *tvp)
|
||||
{
|
||||
int s = splclock();
|
||||
static struct timeval lasttime;
|
||||
|
||||
*tvp = time;
|
||||
if (platform.readclock)
|
||||
tvp->tv_usec += (*platform.readclock)();
|
||||
|
||||
while (tvp->tv_usec >= 1000000) {
|
||||
tvp->tv_sec++;
|
||||
tvp->tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
if (tvp->tv_sec == lasttime.tv_sec &&
|
||||
tvp->tv_usec <= lasttime.tv_usec &&
|
||||
(tvp->tv_usec = lasttime.tv_usec + 1) >= 1000000) {
|
||||
tvp->tv_sec++;
|
||||
tvp->tv_usec -= 1000000;
|
||||
}
|
||||
lasttime = *tvp;
|
||||
splx(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait at least `n' usec.
|
||||
*/
|
||||
void
|
||||
delay(unsigned int n)
|
||||
{
|
||||
uint32_t cur, last, delta, usecs;
|
||||
|
||||
last = mips3_cp0_count_read();
|
||||
delta = usecs = 0;
|
||||
|
||||
while (n > usecs) {
|
||||
cur = mips3_cp0_count_read();
|
||||
|
||||
/* Check to see if the timer has wrapped around. */
|
||||
if (cur < last)
|
||||
delta += ((curcpu()->ci_cycles_per_hz - last) + cur);
|
||||
else
|
||||
delta += (cur - last);
|
||||
|
||||
last = cur;
|
||||
|
||||
if (delta >= curcpu()->ci_divisor_delay) {
|
||||
usecs += delta / curcpu()->ci_divisor_delay;
|
||||
delta %= curcpu()->ci_divisor_delay;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/* $NetBSD: cons_machdep.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cons_machdep.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
#include <ews4800mips/ews4800mips/cons_machdep.h>
|
||||
|
||||
cons_decl(rom_);
|
||||
|
||||
struct cons cons;
|
||||
struct consdev *cn_tab = NULL;
|
||||
struct consdev consdev_rom = {
|
||||
rom_cnprobe,
|
||||
rom_cninit,
|
||||
rom_cngetc,
|
||||
rom_cnputc,
|
||||
rom_cnpollc,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NODEV,
|
||||
CN_DEAD
|
||||
};
|
||||
|
||||
void
|
||||
consinit(void)
|
||||
{
|
||||
static int initted;
|
||||
|
||||
if (initted)
|
||||
return;
|
||||
|
||||
if (platform.consinit) {
|
||||
(*platform.consinit)();
|
||||
initted = 1;
|
||||
} else
|
||||
rom_cons_init(); /* XXX */
|
||||
}
|
||||
|
||||
void
|
||||
rom_cons_init(void)
|
||||
{
|
||||
|
||||
cons.type = CONS_ROM;
|
||||
cn_tab = &consdev_rom;
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
}
|
||||
|
||||
void
|
||||
rom_cnprobe(struct consdev *cn)
|
||||
{
|
||||
|
||||
cn->cn_pri = CN_INTERNAL;
|
||||
}
|
||||
|
||||
void
|
||||
rom_cninit(struct consdev *cn)
|
||||
{
|
||||
static int initted;
|
||||
|
||||
if (initted)
|
||||
return;
|
||||
|
||||
cons.x = X_INIT;
|
||||
#if 0
|
||||
cons.y = Y_INIT;
|
||||
#else
|
||||
cons.y = 20; /* XXX no way to get the previous cursor position */
|
||||
#endif
|
||||
initted = 1;
|
||||
}
|
||||
|
||||
void
|
||||
rom_cnputc(dev_t dev, int c)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (c) {
|
||||
default:
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH, cons.y * ROM_FONT_HEIGHT, c);
|
||||
if (++cons.x == CONS_WIDTH) {
|
||||
cons.x = X_INIT;
|
||||
cons.y++;
|
||||
}
|
||||
break;
|
||||
case '\b':
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH, cons.y * ROM_FONT_HEIGHT, c);
|
||||
cons.x = cons.x == X_INIT ? X_INIT : cons.x - 1;
|
||||
break;
|
||||
case '\t':
|
||||
for (i = cons.x % 8; i < 8; i++) {
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH,
|
||||
cons.y * ROM_FONT_HEIGHT, ' ');
|
||||
if (++cons.x == CONS_WIDTH) {
|
||||
cons.x = X_INIT;
|
||||
if (++cons.y == CONS_HEIGHT)
|
||||
cons.y = Y_INIT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\r':
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH, cons.y * ROM_FONT_HEIGHT, c);
|
||||
cons.x = X_INIT;
|
||||
break;
|
||||
case '\n':
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH, cons.y * ROM_FONT_HEIGHT,
|
||||
'\r');
|
||||
ROM_PUTC(cons.x * ROM_FONT_WIDTH, cons.y * ROM_FONT_HEIGHT, c);
|
||||
cons.x = X_INIT;
|
||||
cons.y++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cons.y == CONS_HEIGHT)
|
||||
cons.y = Y_INIT;
|
||||
}
|
||||
|
||||
int
|
||||
rom_cngetc(dev_t dev)
|
||||
{
|
||||
|
||||
return ROM_GETC();
|
||||
}
|
||||
|
||||
void
|
||||
rom_cnpollc(dev_t dev, int on)
|
||||
{
|
||||
static boolean_t __polling = FALSE;
|
||||
static int s;
|
||||
|
||||
if (on && !__polling) {
|
||||
s = splhigh(); /* Disable interrupt driven I/O */
|
||||
__polling = TRUE;
|
||||
} else if (!on && __polling) {
|
||||
__polling = FALSE;
|
||||
splx(s); /* Enable interrupt driven I/O */
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/* $NetBSD: cons_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define FB_LINEBYTES 2048
|
||||
#define FB_WIDTH 1284
|
||||
#define FB_HEIGHT 1024
|
||||
|
||||
#define CONS_WIDTH (FB_WIDTH / ROM_FONT_WIDTH)
|
||||
#define CONS_HEIGHT (FB_HEIGHT / ROM_FONT_HEIGHT)
|
||||
|
||||
#define X_INIT 0
|
||||
#define Y_INIT 0
|
||||
|
||||
enum console_type {
|
||||
CONS_ROM, /* ROM console I/O */
|
||||
CONS_FB_KSEG2, /* direct fb device access via KSEG2 */
|
||||
CONS_FB_KSEG1, /* direct fb device access via KSEG1 */
|
||||
CONS_SIO1, /* serial console port 1 */
|
||||
CONS_SIO2, /* serial console port 2 */
|
||||
};
|
||||
|
||||
struct cons {
|
||||
enum console_type type;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
extern struct cons cons;
|
||||
|
||||
void rom_cons_init(void);
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: cpu.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
|
||||
#include "ioconf.h"
|
||||
|
||||
int cpumatch(struct device *, struct cfdata *, void *);
|
||||
void cpuattach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(cpu, sizeof (struct device),
|
||||
cpumatch, cpuattach, NULL, NULL);
|
||||
|
||||
static int cpu_attached;
|
||||
|
||||
int
|
||||
cpumatch(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct mainbus_attach_args *ma = aux;
|
||||
|
||||
/* make sure that we're looking for a CPU. */
|
||||
if (strcmp(ma->ma_name, cpu_cd.cd_name) != 0)
|
||||
return 0;
|
||||
|
||||
return !cpu_attached;
|
||||
}
|
||||
|
||||
void
|
||||
cpuattach(struct device *parent, struct device *dev, void *aux)
|
||||
{
|
||||
|
||||
printf(": ");
|
||||
cpu_attached = 1;
|
||||
|
||||
cpu_identify();
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
/* $NetBSD: disklabel_conv.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disklabel_conv.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/systm.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include "local.h"
|
||||
#endif
|
||||
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
/*
|
||||
* NetBSD/ews4800mips EWS-UX compatible disk layout.
|
||||
*
|
||||
* 0============================+ cylinder 0
|
||||
* 1 1stboot program (4KB) |
|
||||
* . .
|
||||
* 7----------------------------+
|
||||
* 8 PDINFO | UX unvisible region.
|
||||
* 9 BSD disklabel | I (uch) decided to locate disklabel here.
|
||||
* . .
|
||||
* . error log (UX) |
|
||||
* +============================+ cylinder 1
|
||||
* | logical_start (UX) |
|
||||
* | VTOC |
|
||||
* . . UX Boot block (partition 7)
|
||||
* . . 100 blocks (default. at least 2 blocks)
|
||||
* . .
|
||||
* . .
|
||||
* +============================+
|
||||
* | BFS |
|
||||
* | boot loader |
|
||||
* . disklabel .
|
||||
* . and etc. . BFS (partition 3)
|
||||
* . .
|
||||
* . .
|
||||
* . .
|
||||
* -----------------------------+
|
||||
*/
|
||||
|
||||
#define _BFS_SIZE 16384 /* 8MB */
|
||||
#define _BOOTBLOCK_SIZE 100 /* UX default */
|
||||
#define _FAKE_TRACKS_PER_CYLINDER 16
|
||||
#define _FAKE_SECTORS_PER_TRACK 1
|
||||
|
||||
void
|
||||
disklabel_set_default(struct disklabel *d)
|
||||
{
|
||||
|
||||
d->d_magic = DISKMAGIC;
|
||||
d->d_magic2 = DISKMAGIC;
|
||||
d->d_secsize = DEV_BSIZE;
|
||||
d->d_npartitions = MAXPARTITIONS;
|
||||
}
|
||||
|
||||
void
|
||||
vtoc_set_default( struct cpu_disklabel *ux, struct disklabel *d)
|
||||
{
|
||||
struct pdinfo_sector *pdinfo = &ux->pdinfo;
|
||||
struct vtoc_sector *vtoc = &ux->vtoc;
|
||||
struct ux_partition *bfs;
|
||||
struct ux_partition *boot;
|
||||
struct ux_partition *bsdraw;
|
||||
int nsectors, logical_sector, cylinder_blocks, res;
|
||||
|
||||
memset(vtoc, 0, sizeof *vtoc);
|
||||
memset(pdinfo, 0, sizeof *pdinfo);
|
||||
if (d)
|
||||
cylinder_blocks = d->d_ntracks * d->d_nsectors;
|
||||
else
|
||||
cylinder_blocks =
|
||||
_FAKE_TRACKS_PER_CYLINDER * _FAKE_SECTORS_PER_TRACK;
|
||||
logical_sector = cylinder_blocks;
|
||||
|
||||
pdinfo->drive_id = 0x5c512000; /* Fake for EWS-UX */
|
||||
pdinfo->magic = PDINFO_MAGIC;
|
||||
pdinfo->version = PDINFO_VERSION;
|
||||
pdinfo->logical_sector = logical_sector;
|
||||
pdinfo->ux.errorlog_sector = logical_sector - 1;
|
||||
pdinfo->ux.errorlog_size_byte = DEV_BSIZE;
|
||||
|
||||
if (d) { /* use drivers disk geometory */
|
||||
pdinfo->geometory.cylinders_per_drive = d->d_ncylinders;
|
||||
pdinfo->geometory.tracks_per_cylinder = d->d_ntracks;
|
||||
pdinfo->geometory.sectors_per_track = d->d_nsectors;
|
||||
pdinfo->geometory.bytes_per_sector = d->d_secsize;
|
||||
nsectors = d->d_ncylinders * d->d_ntracks * d->d_nsectors;
|
||||
} else { /* set fake */
|
||||
pdinfo->geometory.sectors_per_track =
|
||||
_FAKE_SECTORS_PER_TRACK;
|
||||
pdinfo->geometory.tracks_per_cylinder =
|
||||
_FAKE_TRACKS_PER_CYLINDER;
|
||||
pdinfo->geometory.cylinders_per_drive = 0x1fffffff;
|
||||
pdinfo->geometory.bytes_per_sector = DEV_BSIZE;
|
||||
nsectors = 0x1fffffff;
|
||||
}
|
||||
|
||||
/* following magic numbers are required for EWS-UX */
|
||||
pdinfo->device_depend[15] = 0xfb7e10;
|
||||
pdinfo->device_depend[16] = 0x200;
|
||||
pdinfo->device_depend[17] = 0x10;
|
||||
|
||||
vtoc->magic = VTOC_MAGIC;
|
||||
vtoc->version = VTOC_VERSION;
|
||||
vtoc->sector_size_byte = DEV_BSIZE;
|
||||
vtoc->npartitions = VTOC_MAXPARTITIONS;
|
||||
|
||||
boot = &vtoc->partition[7];
|
||||
boot->tag = VTOC_TAG_BOOT;
|
||||
boot->flags = VTOC_FLAG_UNMOUNT;
|
||||
boot->start_sector = 0;
|
||||
boot->nsectors = _BOOTBLOCK_SIZE;
|
||||
|
||||
bfs = &vtoc->partition[3];
|
||||
bfs->tag = VTOC_TAG_STAND;
|
||||
bfs->flags = 0;
|
||||
bfs->start_sector = _BOOTBLOCK_SIZE;
|
||||
|
||||
res = nsectors - bfs->start_sector;
|
||||
bfs->nsectors = res > _BFS_SIZE ? _BFS_SIZE : res;
|
||||
|
||||
bsdraw = &vtoc->partition[RAW_PART];
|
||||
bsdraw->tag = VTOC_TAG_NONAME;
|
||||
bsdraw->flags = VTOC_FLAG_UNMOUNT;
|
||||
bsdraw->start_sector = -pdinfo->logical_sector;
|
||||
bsdraw->nsectors = nsectors;
|
||||
}
|
||||
|
||||
void
|
||||
disklabel_to_vtoc(struct cpu_disklabel *ux, struct disklabel *d)
|
||||
{
|
||||
struct pdinfo_sector *pdinfo = &ux->pdinfo;
|
||||
struct vtoc_sector *vtoc = &ux->vtoc;
|
||||
struct ux_partition *up;
|
||||
struct partition *p;
|
||||
uint32_t offset = pdinfo->logical_sector;
|
||||
int i;
|
||||
|
||||
pdinfo->geometory.cylinders_per_drive = d->d_ncylinders;
|
||||
pdinfo->geometory.tracks_per_cylinder = d->d_ntracks;
|
||||
pdinfo->geometory.sectors_per_track = d->d_nsectors;
|
||||
pdinfo->geometory.bytes_per_sector = d->d_secsize;
|
||||
|
||||
vtoc->npartitions = d->d_npartitions;
|
||||
vtoc->sector_size_byte = d->d_secsize;
|
||||
|
||||
up = vtoc->partition;
|
||||
p = d->d_partitions;
|
||||
for (i = 0; i < vtoc->npartitions; i++, up++, p++) {
|
||||
if ((up->nsectors = p->p_size) != 0)
|
||||
up->start_sector = p->p_offset - offset;
|
||||
else
|
||||
up->start_sector = 0;
|
||||
|
||||
switch (p->p_fstype) {
|
||||
case FS_BOOT:
|
||||
up->tag = VTOC_TAG_BOOT;
|
||||
up->flags = VTOC_FLAG_UNMOUNT;
|
||||
break;
|
||||
case FS_SYSVBFS:
|
||||
up->tag = VTOC_TAG_STAND;
|
||||
break;
|
||||
case FS_SWAP:
|
||||
up->tag = VTOC_TAG_SWAP;
|
||||
up->flags = VTOC_FLAG_UNMOUNT;
|
||||
break;
|
||||
case FS_BSDFFS:
|
||||
up->tag = __VTOC_TAG_BSDFFS;
|
||||
break;
|
||||
case FS_UNUSED:
|
||||
if (i != RAW_PART && p->p_size > 0) {
|
||||
up->tag = VTOC_TAG_RAWDISK;
|
||||
up->flags = VTOC_FLAG_UNMOUNT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vtoc_to_disklabel(struct cpu_disklabel *ux, struct disklabel *d)
|
||||
{
|
||||
struct pdinfo_sector *pdinfo = &ux->pdinfo;
|
||||
struct vtoc_sector *vtoc = &ux->vtoc;
|
||||
struct ux_partition *up;
|
||||
struct partition *p;
|
||||
uint32_t offset = pdinfo->logical_sector;
|
||||
int i;
|
||||
|
||||
d->d_secsize = pdinfo->geometory.bytes_per_sector;
|
||||
d->d_nsectors = pdinfo->geometory.sectors_per_track;
|
||||
d->d_ntracks = pdinfo->geometory.tracks_per_cylinder;
|
||||
d->d_ncylinders = pdinfo->geometory.cylinders_per_drive;
|
||||
d->d_secpercyl = d->d_nsectors * d->d_ntracks;
|
||||
d->d_secperunit = d->d_ncylinders * d->d_secpercyl;
|
||||
|
||||
d->d_npartitions = vtoc->npartitions;
|
||||
d->d_secsize = vtoc->sector_size_byte;
|
||||
|
||||
up = vtoc->partition;
|
||||
p = d->d_partitions;
|
||||
for (i = 0; i < vtoc->npartitions; i++, up++, p++) {
|
||||
|
||||
if ((p->p_size = up->nsectors) != 0)
|
||||
p->p_offset = up->start_sector + offset;
|
||||
else
|
||||
p->p_offset = 0;
|
||||
|
||||
switch (up->tag) {
|
||||
case VTOC_TAG_BOOT:
|
||||
p->p_fstype = FS_BOOT;
|
||||
break;
|
||||
case VTOC_TAG_STAND:
|
||||
p->p_fstype = FS_SYSVBFS;
|
||||
break;
|
||||
case VTOC_TAG_RAWDISK:
|
||||
p->p_fstype = FS_UNUSED;
|
||||
break;
|
||||
case VTOC_TAG_SWAP:
|
||||
p->p_fstype = FS_SWAP;
|
||||
break;
|
||||
case VTOC_TAG_NONAME:
|
||||
case VTOC_TAG_ROOT:
|
||||
case VTOC_TAG_USR:
|
||||
case VTOC_TAG_VAR:
|
||||
case VTOC_TAG_HOME:
|
||||
p->p_fstype = FS_SYSV;
|
||||
break;
|
||||
default:
|
||||
if (up->nsectors != 0)
|
||||
p->p_fstype = FS_SYSV;
|
||||
else
|
||||
p->p_fstype = FS_UNUSED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
d->d_checksum = 0;
|
||||
d->d_checksum = dkcksum(d);
|
||||
}
|
||||
|
||||
boolean_t
|
||||
disklabel_sanity(struct disklabel *d)
|
||||
{
|
||||
|
||||
if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC ||
|
||||
dkcksum(d) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/* $NetBSD: disksubr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
#include <machine/sector.h>
|
||||
|
||||
#define DISKLABEL_DEBUG
|
||||
|
||||
#ifdef DISKLABEL_DEBUG
|
||||
#define DPRINTF(fmt, args...) printf(fmt, ##args)
|
||||
#else
|
||||
#define DPRINTF(arg...) ((void)0)
|
||||
#endif
|
||||
|
||||
const char *
|
||||
readdisklabel(dev_t dev, void (*strategy)(struct buf *), struct disklabel *d,
|
||||
struct cpu_disklabel *ux)
|
||||
{
|
||||
uint8_t buf[DEV_BSIZE];
|
||||
struct pdinfo_sector *pdinfo = &ux->pdinfo;
|
||||
struct vtoc_sector *vtoc = &ux->vtoc;
|
||||
boolean_t disklabel_available = FALSE;
|
||||
boolean_t vtoc_available = FALSE;
|
||||
void *rwops;
|
||||
|
||||
if ((rwops = sector_init(dev, strategy)) == 0)
|
||||
return "can't read/write disk";
|
||||
|
||||
/* Read VTOC */
|
||||
if (!pdinfo_sector(rwops, pdinfo) || !pdinfo_sanity(pdinfo)) {
|
||||
DPRINTF("%s: PDINFO not found.\n", __FUNCTION__);
|
||||
} else if (vtoc_sector(rwops, vtoc, pdinfo->logical_sector) &&
|
||||
vtoc_sanity(vtoc)) {
|
||||
vtoc_available = TRUE;
|
||||
|
||||
/* Read BSD DISKLABEL (if any) */
|
||||
sector_read(rwops, buf, LABELSECTOR);
|
||||
if (disklabel_sanity((struct disklabel *)buf)) {
|
||||
disklabel_available = TRUE;
|
||||
memcpy(d, buf, sizeof(struct disklabel));
|
||||
} else {
|
||||
DPRINTF("%s: no BSD disklabel.\n", __FUNCTION__);
|
||||
}
|
||||
} else {
|
||||
DPRINTF("%s: PDINFO found, but VTOC not found.\n",
|
||||
__FUNCTION__);
|
||||
}
|
||||
sector_fini(rwops);
|
||||
|
||||
/* If there is no BSD disklabel, convert from VTOC */
|
||||
if (!disklabel_available) {
|
||||
if (vtoc_available) {
|
||||
DPRINTF("%s: creating disklabel from VTOC.\n",
|
||||
__FUNCTION__);
|
||||
} else {
|
||||
DPRINTF("%s: no VTOC. creating default disklabel.\n",
|
||||
__FUNCTION__);
|
||||
vtoc_set_default(ux, d);
|
||||
}
|
||||
disklabel_set_default(d);
|
||||
vtoc_to_disklabel(ux, d);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
setdisklabel(struct disklabel *od, struct disklabel *nd, u_long openmask,
|
||||
struct cpu_disklabel *ux)
|
||||
{
|
||||
|
||||
KDASSERT(openmask == 0); /* openmask is obsolete. -uch */
|
||||
|
||||
if (!disklabel_sanity(nd))
|
||||
return EINVAL;
|
||||
|
||||
*od = *nd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
writedisklabel(dev_t dev, void (*strategy)(struct buf *), struct disklabel *d,
|
||||
struct cpu_disklabel *ux)
|
||||
{
|
||||
uint8_t buf[DEV_BSIZE];
|
||||
int err = 0;
|
||||
void *rwops;
|
||||
|
||||
if (!disklabel_sanity(d))
|
||||
return EINVAL;
|
||||
|
||||
/* 1. Update VTOC */
|
||||
disklabel_to_vtoc(ux, d);
|
||||
DPRINTF("%s: logical_sector=%d\n", __FUNCTION__,
|
||||
ux->pdinfo.logical_sector);
|
||||
|
||||
if ((rwops = sector_init(dev, strategy)) == 0)
|
||||
return ENOMEM;
|
||||
pdinfo_sanity(&ux->pdinfo);
|
||||
vtoc_sanity(&ux->vtoc);
|
||||
|
||||
/* 2. Write VTOC to bootblock */
|
||||
sector_write(rwops, (void *)&ux->pdinfo, PDINFO_SECTOR);
|
||||
sector_write(rwops, (void *)&ux->vtoc,
|
||||
ux->pdinfo.logical_sector + VTOC_SECTOR);
|
||||
|
||||
/* 3. Write disklabel to BFS */
|
||||
memset(buf, 0, sizeof buf);
|
||||
memcpy(buf, d, sizeof *d);
|
||||
if (!sector_write(rwops, buf, LABELSECTOR)) {
|
||||
DPRINTF("%s: failed to write disklabel.\n", __FUNCTION__);
|
||||
err = EIO;
|
||||
}
|
||||
sector_fini(rwops);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int
|
||||
bounds_check_with_label(struct disk *dk, struct buf *b, int wlabel)
|
||||
{
|
||||
struct disklabel *d = dk->dk_label;
|
||||
struct partition *p = d->d_partitions + DISKPART(b->b_dev);
|
||||
|
||||
if (!bounds_check_with_mediasize(b, DEV_BSIZE, p->p_size)) {
|
||||
DPRINTF("bounds_check_with_mediasize failed.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
b->b_resid = (b->b_blkno + p->p_offset) / d->d_secpercyl;
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/* $NetBSD: interrupt.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <uvm/uvm_extern.h> /* uvmexp.intrs */
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
const uint32_t *ipl_sr_bits;
|
||||
static void (*platform_intr)(uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
const uint32_t mips_ipl_si_to_sr[_IPL_NSOFT] = {
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */
|
||||
};
|
||||
|
||||
void
|
||||
intr_init(void)
|
||||
{
|
||||
|
||||
softintr_init();
|
||||
|
||||
platform_intr = platform.intr;
|
||||
(*platform.intr_init)();
|
||||
}
|
||||
|
||||
void
|
||||
intr_establish(int irq, int (*func)(void *), void *arg)
|
||||
{
|
||||
|
||||
(*platform.intr_establish)(irq, func, arg);
|
||||
}
|
||||
|
||||
void
|
||||
intr_disestablish(void *arg)
|
||||
{
|
||||
|
||||
(*platform.intr_disestablish)(arg);
|
||||
}
|
||||
|
||||
void
|
||||
cpu_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
|
||||
{
|
||||
|
||||
uvmexp.intrs++;
|
||||
|
||||
(*platform_intr)(status, cause, pc, ipending);
|
||||
|
||||
ipending &= (MIPS_SOFT_INT_MASK_1 | MIPS_SOFT_INT_MASK_0);
|
||||
if (ipending == 0)
|
||||
return;
|
||||
|
||||
_clrsoftintr(ipending);
|
||||
|
||||
softintr_dispatch(ipending);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* $NetBSD: locore_machdep.S,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <mips/asm.h>
|
||||
#include <mips/cpuregs.h>
|
||||
|
||||
.set noreorder
|
||||
/*
|
||||
* EWS4800 NMI entry. (0x200)
|
||||
*/
|
||||
LEAF_NOPROFILE(ews4800mips_nmi_vec)
|
||||
lui sp, 0x2000
|
||||
la k1, nmi_exception
|
||||
or k1, k1, sp /* uncached */
|
||||
la sp, start
|
||||
jr k1
|
||||
nop
|
||||
END(ews4800mips_nmi_vec)
|
||||
|
||||
LEAF_NOPROFILE(nmi_exception)
|
||||
li a0, 0 /* x-pos */
|
||||
2: li a2, 64 /* '@' */
|
||||
lui v0, 0xbfc0
|
||||
ori v0, 0xff60
|
||||
li a1, 0 /* y-pos */
|
||||
jal v0
|
||||
nop
|
||||
b 2b
|
||||
addiu a0, a0, 12
|
||||
/* NOTREACHED */
|
||||
END(nmi_exception)
|
|
@ -0,0 +1,336 @@
|
|||
/* $NetBSD: machdep.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/kcore.h>
|
||||
#include <sys/boot_flag.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bootinfo.h>
|
||||
#include <machine/locore.h>
|
||||
#include <machine/sbdvar.h> /* System board */
|
||||
#include <machine/wired_map.h>
|
||||
|
||||
#include <mips/cache.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <machine/db_machdep.h>
|
||||
#include <ddb/db_sym.h>
|
||||
#include <ddb/db_extern.h>
|
||||
#include <ddb/db_output.h>
|
||||
#ifndef DB_ELFSIZE
|
||||
#error Must define DB_ELFSIZE!
|
||||
#endif
|
||||
#define ELFSIZE DB_ELFSIZE
|
||||
#include <sys/exec_elf.h>
|
||||
#endif
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
#include <ews4800mips/ews4800mips/cons_machdep.h>
|
||||
|
||||
vsize_t kseg2iobufsize; /* to reserve PTEs for KSEG2 I/O space */
|
||||
|
||||
/* our exported CPU info */
|
||||
struct cpu_info cpu_info_store;
|
||||
|
||||
/* maps for VM objects */
|
||||
struct vm_map *exec_map;
|
||||
struct vm_map *mb_map;
|
||||
struct vm_map *phys_map;
|
||||
|
||||
/* for buffer cache, vnode cache estimation */
|
||||
int physmem; /* max supported memory, changes to actual */
|
||||
|
||||
/* referenced by mips_machdep.c:cpu_dump() */
|
||||
int mem_cluster_cnt;
|
||||
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
|
||||
|
||||
void mach_init(int, char *[], struct bootinfo *);
|
||||
void option(int, char *[], struct bootinfo *);
|
||||
/* NMI */
|
||||
void nmi_exception(void);
|
||||
|
||||
void
|
||||
mach_init(int argc, char *argv[], struct bootinfo *bi)
|
||||
{
|
||||
extern char kernel_text[], edata[], end[];
|
||||
extern struct user *proc0paddr;
|
||||
caddr_t v;
|
||||
int i;
|
||||
|
||||
/* Clear BSS */
|
||||
memset(edata, 0, end - edata);
|
||||
|
||||
/* Setup early-console with BIOS ROM routines */
|
||||
rom_cons_init();
|
||||
|
||||
/* Initialize machine dependent System-Board ops. */
|
||||
sbd_init();
|
||||
|
||||
__asm volatile("move %0, $29" : "=r"(v));
|
||||
printf("kernel_text=%p edata=%p end=%p sp=%p\n", kernel_text, edata,
|
||||
end, v);
|
||||
|
||||
option(argc, argv, bi);
|
||||
|
||||
uvm_setpagesize();
|
||||
|
||||
/* Fill mem_clusters and mem_cluster_cnt */
|
||||
(*platform.mem_init)(kernel_text,
|
||||
(bi && bi->bi_nsym) ? (caddr_t)bi->bi_esym : end);
|
||||
|
||||
/*
|
||||
* make sure that we don't call BIOS console from now
|
||||
* because wired mappings set up by BIOS will be discarded
|
||||
* in mips_vector_init().
|
||||
*/
|
||||
cn_tab = NULL;
|
||||
|
||||
mips_vector_init();
|
||||
|
||||
memcpy((void *)0x80000200, ews4800mips_nmi_vec, 32); /* NMI */
|
||||
mips_dcache_wbinv_all();
|
||||
mips_icache_sync_all();
|
||||
|
||||
/* setup cpu_info */
|
||||
curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz;
|
||||
curcpu()->ci_divisor_delay =
|
||||
((curcpu()->ci_cpu_freq + 500000) / 1000000);
|
||||
if (mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT) {
|
||||
curcpu()->ci_cycles_per_hz /= 2;
|
||||
curcpu()->ci_divisor_delay /= 2;
|
||||
}
|
||||
MIPS_SET_CI_RECIPRICAL(curcpu());
|
||||
|
||||
/* Load memory to UVM */
|
||||
for (i = 1; i < mem_cluster_cnt; i++) {
|
||||
phys_ram_seg_t *p;
|
||||
paddr_t start;
|
||||
size_t size;
|
||||
p = &mem_clusters[i];
|
||||
start = p->start;
|
||||
size = p->size;
|
||||
uvm_page_physload(atop(start), atop(start + size),
|
||||
atop(start), atop(start + size), VM_FREELIST_DEFAULT);
|
||||
}
|
||||
|
||||
sprintf(cpu_model, "NEC %s", platform.name);
|
||||
|
||||
mips_init_msgbuf();
|
||||
|
||||
pmap_bootstrap();
|
||||
|
||||
v = (caddr_t)uvm_pageboot_alloc(USPACE); /* proc0 USPACE */
|
||||
lwp0.l_addr = proc0paddr = (struct user *) v;
|
||||
lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
|
||||
curpcb = &lwp0.l_addr->u_pcb;
|
||||
curpcb->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
|
||||
}
|
||||
|
||||
void
|
||||
option(int argc, char *argv[], struct bootinfo *bi)
|
||||
{
|
||||
extern char __boot_kernel_name[];
|
||||
boolean_t boot_device_set;
|
||||
char *p;
|
||||
int i;
|
||||
|
||||
printf("argc=%d argv=%p syminfo=%p\n", argc, argv, bi);
|
||||
printf("version=%d size=%d nsym=%d ssym=%p esym=%p\n",
|
||||
bi->bi_version, bi->bi_size, bi->bi_nsym, bi->bi_ssym, bi->bi_esym);
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
printf("[%d] %s\n", i, argv[i]);
|
||||
|
||||
#ifdef DDB
|
||||
/* Load symbol table */
|
||||
if (bi->bi_nsym)
|
||||
ksyms_init(bi->bi_esym - bi->bi_ssym,
|
||||
(void *)bi->bi_ssym, (void *)bi->bi_esym);
|
||||
#endif
|
||||
/* Parse option */
|
||||
boot_device_set = FALSE;
|
||||
for (i = 2; i < argc; i++) {
|
||||
p = argv[i];
|
||||
/* prompt for root device */
|
||||
if (p[0] == '-' && p[1] == 'a')
|
||||
boot_device_set = TRUE;
|
||||
|
||||
/* root device option. ex) -b=net:netbsd, -b=sd0k:netbsd */
|
||||
if (p[0] == '-' && p[1] == 'b') {
|
||||
boot_device_set = TRUE;
|
||||
strcpy(__boot_kernel_name, p + 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (!boot_device_set)
|
||||
strcpy(__boot_kernel_name, argv[1]);
|
||||
|
||||
/* Memory address infomation from IPL */
|
||||
sbd_memcluster_init(bi->bi_mainfo);
|
||||
}
|
||||
|
||||
void
|
||||
mips_machdep_cache_config(void)
|
||||
{
|
||||
|
||||
/* Set L2-cache size */
|
||||
if (platform.cache_config)
|
||||
(*platform.cache_config)();
|
||||
}
|
||||
|
||||
void
|
||||
cpu_startup(void)
|
||||
{
|
||||
vaddr_t minaddr, maxaddr;
|
||||
char pbuf[9];
|
||||
|
||||
printf("%s%s", copyright, version);
|
||||
printf("%s %dMHz\n", cpu_model, platform.cpu_clock / 1000000);
|
||||
format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
|
||||
printf("total memory = %s\n", pbuf);
|
||||
|
||||
minaddr = 0;
|
||||
/*
|
||||
* Allocate a submap for exec arguments. This map effectively
|
||||
* limits the number of processes exec'ing at any time.
|
||||
*/
|
||||
exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
|
||||
16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL);
|
||||
/*
|
||||
* Allocate a submap for physio.
|
||||
*/
|
||||
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
|
||||
VM_PHYS_SIZE, 0, FALSE, NULL);
|
||||
|
||||
/*
|
||||
* (No need to allocate an mbuf cluster submap. Mbuf clusters
|
||||
* are allocated via the pool allocator, and we use KSEG to
|
||||
* map those pages.)
|
||||
*/
|
||||
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
|
||||
printf("avail memory = %s\n", pbuf);
|
||||
}
|
||||
|
||||
void
|
||||
cpu_reboot(int howto, char *bootstr)
|
||||
{
|
||||
static int waittime = -1;
|
||||
|
||||
/* Take a snapshot before clobbering any registers. */
|
||||
if (curlwp)
|
||||
savectx((struct user *)curpcb);
|
||||
|
||||
if (cold) {
|
||||
howto |= RB_HALT;
|
||||
goto haltsys;
|
||||
}
|
||||
|
||||
/* If "always halt" was specified as a boot flag, obey. */
|
||||
if (boothowto & RB_HALT)
|
||||
howto |= RB_HALT;
|
||||
|
||||
boothowto = howto;
|
||||
if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) {
|
||||
waittime = 0;
|
||||
vfs_shutdown();
|
||||
|
||||
/*
|
||||
* If we've been adjusting the clock, the todr
|
||||
* will be out of synch; adjust it now.
|
||||
*/
|
||||
resettodr();
|
||||
}
|
||||
|
||||
splhigh();
|
||||
|
||||
if (howto & RB_DUMP)
|
||||
dumpsys();
|
||||
|
||||
haltsys:
|
||||
doshutdownhooks();
|
||||
|
||||
if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
|
||||
if (platform.poweroff) {
|
||||
DELAY(1000000);
|
||||
(*platform.poweroff)();
|
||||
}
|
||||
}
|
||||
|
||||
if (howto & RB_HALT) {
|
||||
printf("System halted. Hit any key to reboot.\n\n");
|
||||
(void)cngetc();
|
||||
}
|
||||
|
||||
printf("rebooting...\n");
|
||||
DELAY(1000000);
|
||||
if (platform.reboot)
|
||||
(*platform.reboot)();
|
||||
|
||||
printf("reboot faild.\n");
|
||||
for (;;)
|
||||
;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
void
|
||||
__db_print_symbol(db_expr_t value)
|
||||
{
|
||||
const char *name;
|
||||
db_expr_t offset;
|
||||
|
||||
db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
|
||||
|
||||
if (name != NULL && offset <= db_maxoff && offset != value)
|
||||
db_print_loc_and_inst(value);
|
||||
else
|
||||
db_printf("\n");
|
||||
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,91 @@
|
|||
/* $NetBSD: mainbus.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/sbdvar.h>
|
||||
|
||||
int mainbus_match(struct device *, struct cfdata *, void *);
|
||||
void mainbus_attach(struct device *, struct device *, void *);
|
||||
int mainbus_print(void *, const char *);
|
||||
|
||||
CFATTACH_DECL(mainbus, sizeof(struct device),
|
||||
mainbus_match, mainbus_attach, NULL, NULL);
|
||||
|
||||
static int mainbus_found;
|
||||
|
||||
int
|
||||
mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
|
||||
if (mainbus_found == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
mainbus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mainbus_attach_args ma;
|
||||
const char **p;
|
||||
|
||||
mainbus_found = 1;
|
||||
printf("\n");
|
||||
|
||||
/* CPU */
|
||||
ma.ma_name = "cpu";
|
||||
config_found(self, &ma, mainbus_print);
|
||||
|
||||
/* System Board dependent device busses */
|
||||
if (platform.mainbusdevs != NULL) {
|
||||
for (p = platform.mainbusdevs; *p != NULL; p++) {
|
||||
ma.ma_name = *p;
|
||||
config_found(self, &ma, mainbus_print);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mainbus_print(void *aux, const char *pnp)
|
||||
{
|
||||
|
||||
return pnp ? QUIET : UNCONF;
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/* $NetBSD: pdinfo.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pdinfo.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include "local.h"
|
||||
#endif
|
||||
|
||||
#ifdef PDINFO_DEBUG
|
||||
#define DPRINTF(fmt, args...) printf(fmt, ##args)
|
||||
#else
|
||||
#define DPRINTF(arg...) ((void)0)
|
||||
#endif
|
||||
|
||||
#include <machine/sector.h>
|
||||
#include <machine/pdinfo.h>
|
||||
|
||||
boolean_t
|
||||
pdinfo_sector(void *rwops, struct pdinfo_sector *pdinfo)
|
||||
{
|
||||
|
||||
if (!sector_read(rwops, (void *)pdinfo, PDINFO_SECTOR))
|
||||
return FALSE;
|
||||
|
||||
if (!pdinfo_sanity(pdinfo))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
pdinfo_valid(const struct pdinfo_sector *disk)
|
||||
{
|
||||
|
||||
return disk->magic == PDINFO_MAGIC;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
pdinfo_sanity(const struct pdinfo_sector *disk)
|
||||
{
|
||||
const struct disk_geometory *geom;
|
||||
const struct disk_ux *ux;
|
||||
|
||||
if (!pdinfo_valid(disk)) {
|
||||
DPRINTF("no physical disk info.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
geom = &disk->geometory;
|
||||
ux = &disk->ux;
|
||||
DPRINTF("physical disk sector size %dbyte\n", sizeof *disk);
|
||||
DPRINTF("[disk]\n");
|
||||
DPRINTF("drive_id = %#x\n", disk->drive_id);
|
||||
DPRINTF("magic = %#x\n", disk->magic);
|
||||
DPRINTF("version = %d\n", disk->version);
|
||||
DPRINTF("serial # %s\n", disk->device_serial_number);
|
||||
#define _(x) DPRINTF(#x " = %d\n", geom->x);
|
||||
_(cylinders_per_drive);
|
||||
_(tracks_per_cylinder);
|
||||
_(sectors_per_track);
|
||||
_(bytes_per_sector);
|
||||
#undef _
|
||||
DPRINTF("logical_sector = %d\n", disk->logical_sector);
|
||||
#define _(x) DPRINTF(#x " = %d\n", ux->x);
|
||||
_(errorlog_sector);
|
||||
_(errorlog_size_byte);
|
||||
_(mfg_sector);
|
||||
_(mfg_size_byte);
|
||||
_(defect_sector);
|
||||
_(defect_size_byte);
|
||||
_(n_relocation_area);
|
||||
_(relocation_area_sector);
|
||||
_(relocation_area_size_byte);
|
||||
_(next_relocation_area);
|
||||
_(diag_sector);
|
||||
_(diag_size);
|
||||
_(gap_size);
|
||||
#undef _
|
||||
/* undocumented region */
|
||||
{
|
||||
int i, j;
|
||||
DPRINTF("--reserved--\n");
|
||||
for (i = 0, j = 1; i < 104; i++, j++) {
|
||||
DPRINTF("[%3d]%8x ", i, disk->device_depend[i]);
|
||||
if (j == 8) {
|
||||
DPRINTF("\n");
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
/* $NetBSD: sbd.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sbd.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
/* System board */
|
||||
#include "opt_sbd.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/sbdvar.h>
|
||||
#include <machine/sbd.h>
|
||||
|
||||
struct sbd platform; /* System board itself */
|
||||
|
||||
void
|
||||
sbd_init(void)
|
||||
{
|
||||
|
||||
switch (SBD_INFO->machine) { /* Get model information from ROM */
|
||||
default:
|
||||
printf("This model is not supported.\n");
|
||||
printf("machine [0x%04x] model [0x%04x]\n",
|
||||
SBD_INFO->machine, SBD_INFO->model);
|
||||
for (;;)
|
||||
;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
#ifdef EWS4800_TR2
|
||||
case MACHINE_TR2: /* EWS4800/350 */
|
||||
tr2_init();
|
||||
break;
|
||||
#endif
|
||||
#ifdef EWS4800_TR2A
|
||||
case MACHINE_TR2A:
|
||||
tr2a_init(); /* EWS4800/360 */
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sbd_memcluster_init(uint32_t m)
|
||||
{
|
||||
/* Initialize memory_cluster *** mainfo_type2 only *** */
|
||||
size_t size, total = 0;
|
||||
int i, j, k, n;
|
||||
uint32_t start_addr[] = {
|
||||
__M0_BANK0_ADDR,
|
||||
__M0_BANK1_ADDR,
|
||||
__M1_BANK0_ADDR,
|
||||
__M1_BANK1_ADDR,
|
||||
__M2_BANK0_ADDR,
|
||||
__M2_BANK1_ADDR,
|
||||
};
|
||||
n = sizeof start_addr / sizeof start_addr[0];
|
||||
|
||||
for (i = 0, k = 0, j = 1; i < 8; i++, m >>= 4) {
|
||||
size = m & 0xf ? ((m & 0xf) << 4) : 0;
|
||||
if (size == 0)
|
||||
continue;
|
||||
if (k == n) {
|
||||
/* don't load over 0x20000000 memory */
|
||||
printf("M%d=%dMB(reserved)\n", i, size);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (size) {
|
||||
case 128: /* oooooooo */
|
||||
case 16: /* o....... */
|
||||
mem_clusters[j].size = size * 1024 * 1024;
|
||||
mem_clusters[j].start = start_addr[k];
|
||||
j += 1;
|
||||
k += 2;
|
||||
break;
|
||||
case 32: /* o...o... */
|
||||
mem_clusters[j].size = 16 * 1024 * 1024;
|
||||
mem_clusters[j].start = start_addr[k++];
|
||||
j++;
|
||||
mem_clusters[j].size = 16 * 1024 * 1024;
|
||||
mem_clusters[j].start = start_addr[k++];
|
||||
j++;
|
||||
break;
|
||||
default:
|
||||
printf("UNKNOWN MEMORY CLUSTER SIZE%d\n", size);
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
total += size;
|
||||
printf("M%d=%dMB ", i, size);
|
||||
}
|
||||
printf(" total %dMB\n", total);
|
||||
mem_cluster_cnt = j;
|
||||
mem_clusters[0].size = total << 20;
|
||||
}
|
||||
|
||||
void
|
||||
sbd_memcluster_setup(void *kernstart, void *kernend)
|
||||
{
|
||||
paddr_t start;
|
||||
size_t size;
|
||||
|
||||
physmem = atop(mem_clusters[0].size);
|
||||
|
||||
start = (paddr_t)round_page(MIPS_KSEG0_TO_PHYS(kernend));
|
||||
size = mem_clusters[1].size - start;
|
||||
|
||||
/* kernel itself */
|
||||
mem_clusters[0].start = trunc_page(MIPS_KSEG0_TO_PHYS(kernstart));
|
||||
mem_clusters[0].size = start - mem_clusters[0].start;
|
||||
|
||||
/* heap start */
|
||||
mem_clusters[1].start = start;
|
||||
mem_clusters[1].size = size;
|
||||
}
|
||||
|
||||
void
|
||||
sbd_memcluster_check(void)
|
||||
{
|
||||
uint32_t *m, *mend;
|
||||
phys_ram_seg_t *p;
|
||||
paddr_t start;
|
||||
size_t size;
|
||||
int i, j;
|
||||
|
||||
/* Very slow */
|
||||
for (i = 1; i < mem_cluster_cnt; i++) {
|
||||
p = &mem_clusters[i];
|
||||
start = p->start;
|
||||
size = p->size;
|
||||
printf("[%d] %#lx-%#lx, %#x (%dMB)\n", i, start, start + size,
|
||||
size, size >>20);
|
||||
m = (uint32_t *)MIPS_PHYS_TO_KSEG1(start);
|
||||
mend = (uint32_t *)MIPS_PHYS_TO_KSEG1(start + size);
|
||||
for (; m < mend; m++) {
|
||||
uint32_t pattern[4] =
|
||||
{ 0xffffffff, 0xa5a5a5a5, 0x5a5a5a5a, 0x00000000 };
|
||||
for (j = 0; j < 4; j++) {
|
||||
*m = pattern[j];
|
||||
if (*m != pattern[j])
|
||||
panic("memory error %p\n", m);
|
||||
}
|
||||
}
|
||||
printf("checked.\r");
|
||||
memset((void *)MIPS_PHYS_TO_KSEG0(start), 0, size);
|
||||
printf("cleared.\r");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/* $NetBSD: sector.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sector.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/buf.h>
|
||||
#include <machine/sector.h>
|
||||
|
||||
struct sector_rw {
|
||||
struct buf *buf;
|
||||
void (*strategy)(struct buf *);
|
||||
boolean_t busy;
|
||||
} __context;
|
||||
|
||||
void *
|
||||
sector_init(dev_t dev, void (*strat)(struct buf *))
|
||||
{
|
||||
struct sector_rw *rw =& __context;
|
||||
|
||||
if (rw->busy)
|
||||
return 0;
|
||||
rw->busy = TRUE;
|
||||
rw->strategy = strat;
|
||||
rw->buf = geteblk(DEV_BSIZE);
|
||||
rw->buf->b_dev = dev;
|
||||
|
||||
return rw;
|
||||
}
|
||||
|
||||
void
|
||||
sector_fini(void *self)
|
||||
{
|
||||
struct sector_rw *rw = self;
|
||||
|
||||
brelse(rw->buf);
|
||||
rw->busy = FALSE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
sector_read_n(void *self, uint8_t *buf, daddr_t sector, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!sector_read(self, buf, sector))
|
||||
return FALSE;
|
||||
buf += DEV_BSIZE;
|
||||
sector++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
sector_read(void *self, uint8_t *buf, daddr_t sector)
|
||||
{
|
||||
struct sector_rw *rw = self;
|
||||
struct buf *b = rw->buf;
|
||||
|
||||
b->b_blkno = sector;
|
||||
b->b_cylinder = sector / 100;
|
||||
b->b_bcount = DEV_BSIZE;
|
||||
b->b_flags &= ~(B_DONE);
|
||||
b->b_flags |= B_READ;
|
||||
rw->strategy(b);
|
||||
|
||||
if (biowait(b) != 0)
|
||||
return FALSE;
|
||||
|
||||
memcpy(buf, b->b_data, DEV_BSIZE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
sector_write_n(void *self, uint8_t *buf, daddr_t sector, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!sector_write(self, buf, sector))
|
||||
return FALSE;
|
||||
buf += DEV_BSIZE;
|
||||
sector++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
boolean_t
|
||||
sector_write(void *self, uint8_t *buf, daddr_t sector)
|
||||
{
|
||||
struct sector_rw *rw = self;
|
||||
struct buf *b = rw->buf;
|
||||
|
||||
b->b_blkno = sector;
|
||||
b->b_cylinder = sector / 100;
|
||||
b->b_bcount = DEV_BSIZE;
|
||||
b->b_flags &= ~(B_READ | B_DONE);
|
||||
b->b_flags |= B_WRITE;
|
||||
memcpy(b->b_data, buf, DEV_BSIZE);
|
||||
rw->strategy(b);
|
||||
|
||||
if (biowait(b) != 0)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
/* $NetBSD: tr2.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tr2.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include "fb_sbdio.h"
|
||||
#include "kbms_sbdio.h"
|
||||
#include "zsc_sbdio.h"
|
||||
#include "ewskbd_zsc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <mips/cache.h> /* Set L2-cache size */
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/sbdvar.h>
|
||||
#define _SBD_TR2_PRIVATE
|
||||
#include <machine/sbd_tr2.h>
|
||||
#include <machine/z8530var.h>
|
||||
|
||||
#include <ews4800mips/ews4800mips/cons_machdep.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
SBD_DECL(tr2);
|
||||
|
||||
/* EWS4800/350 mainbus device list */
|
||||
static const char *tr2_mainbusdevs[] =
|
||||
{
|
||||
"sbdio",
|
||||
#ifdef notyet
|
||||
"vme",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
/* EWS4800/350 System board device list */
|
||||
static const struct sbdiodevdesc tr2_sbdiodevs[] = {
|
||||
/* name addr1 addr2 irq flags */
|
||||
#if NEWSKBD_ZSC > 0
|
||||
{ "zsc", 0x1b010000, -1, 0, 0x0003 }, /* Z85C30 */
|
||||
#else
|
||||
{ "zkbms", 0x1b010000, -1, 0, 0x0001 }, /* Z85C30 */
|
||||
#endif
|
||||
{ "zsc", 0x1b011000, -1, 2, 0x0000 }, /* Z85C30 */
|
||||
{ "mkclock", 0x1b020000, -1, -1, 0x0000 }, /* MK48T08 */
|
||||
{ "fdc", 0x1b030000, -1, 7, 0x0000 }, /* uPD72065 */
|
||||
{ "lpt", 0x1b040000, -1, 7, 0x0000 },
|
||||
{ "osiop", 0x1b050000, -1, 5, 0x0000 }, /* 53C710 */
|
||||
{ "iee", 0x1b060000, -1, 6, 0x0000 }, /* i82596CA */
|
||||
/* XXX: fb should be attached at independent bus */
|
||||
{ "fb", 0xf0000000, 0xf5f00000, -1, 0x0000 },
|
||||
{ NULL, -1, -1, -1, -1 } /* terminate */
|
||||
};
|
||||
|
||||
void
|
||||
tr2_init(void)
|
||||
{
|
||||
|
||||
/* EWS4800/350 and EWS4800/350F */
|
||||
platform.machine = MACHINE_TR2;
|
||||
strcpy(platform.name, "EWS4800/350 (TR2)");
|
||||
|
||||
/* 50MHz external clock, 100MHz internal clock */
|
||||
platform.cpu_clock = 100000000;
|
||||
curcpu()->ci_cpu_freq = platform.cpu_clock;
|
||||
|
||||
platform.mainbusdevs = tr2_mainbusdevs;
|
||||
platform.sbdiodevs = tr2_sbdiodevs;
|
||||
|
||||
ipl_sr_bits = tr2_sr_bits;
|
||||
|
||||
kseg2iobufsize = 0x02000000; /* 32MB for VME and framebuffer */
|
||||
|
||||
/* Register system-board specific ops. */
|
||||
_SBD_OPS_REGISTER_ALL(tr2);
|
||||
}
|
||||
|
||||
int
|
||||
tr2_ipl_bootdev(void)
|
||||
{
|
||||
|
||||
return *NVSRAM_BOOTDEV;
|
||||
}
|
||||
|
||||
void
|
||||
tr2_cache_config(void)
|
||||
{
|
||||
|
||||
mips_sdcache_size = 1024 * 1024; /* 1MB L2-cache */
|
||||
}
|
||||
|
||||
void
|
||||
tr2_wbflush(void)
|
||||
{
|
||||
|
||||
*(volatile uint8_t *)MIPS_KSEG1_START;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tr2_consinit(void)
|
||||
{
|
||||
extern struct consdev consdev_zs_sbdio;
|
||||
extern const struct cdevsw zstty_cdevsw;
|
||||
extern int fb_sbdio_cnattach(uint32_t, uint32_t, int);
|
||||
extern void kbd_sbdio_cnattach(uint32_t, uint32_t);
|
||||
extern void ewskbd_zsc_cnattach(uint32_t, uint32_t, int);
|
||||
|
||||
switch (*NVSRAM_CONSTYPE) {
|
||||
#if NFB_SBDIO > 0
|
||||
case 0x00:
|
||||
/* ga */
|
||||
cons.type = CONS_FB_KSEG2;
|
||||
if (fb_sbdio_cnattach(TR2_GAFB_ADDR, TR2_GACTRL_ADDR, 0x0000))
|
||||
break;
|
||||
#if NEWSKBD_ZSC > 0
|
||||
ewskbd_zsc_cnattach(TR2_KBMS_ADDR, TR2_KBMS_ADDR + 4, 4915200);
|
||||
#else
|
||||
#if NKBMS_SBDIO > 0
|
||||
kbd_sbdio_cnattach(TR2_KBMS_ADDR, TR2_KBMS_ADDR + 4);
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
case 0x01:
|
||||
#if NZSC_SBDIO > 0
|
||||
/* sio 1 (zs channel A) */
|
||||
cons.type = CONS_SIO1;
|
||||
zs_consaddr = (void *)(TR2_SIO_ADDR + 8);
|
||||
cn_tab = &consdev_zs_sbdio;
|
||||
cn_tab->cn_pri = CN_REMOTE;
|
||||
cn_tab->cn_dev = makedev(cdevsw_lookup_major(&zstty_cdevsw), 0);
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
return;
|
||||
case 0x02:
|
||||
/* sio 2 (zs channel B) */
|
||||
cons.type = CONS_SIO2;
|
||||
zs_consaddr = (void *)(TR2_SIO_ADDR + 0);
|
||||
cn_tab = &consdev_zs_sbdio;
|
||||
cn_tab->cn_pri = CN_REMOTE;
|
||||
cn_tab->cn_dev = makedev(cdevsw_lookup_major(&zstty_cdevsw), 1);
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rom_cons_init(); /* XXX */
|
||||
}
|
||||
|
||||
void
|
||||
tr2_reboot(void)
|
||||
{
|
||||
|
||||
*SOFTRESET_REG |= 0x10;
|
||||
for (;;)
|
||||
;
|
||||
/*NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
tr2_poweroff(void)
|
||||
{
|
||||
|
||||
for (;;)
|
||||
*POWEROFF_REG = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
tr2_mem_init(void *kernstart, void *kernend)
|
||||
{
|
||||
|
||||
sbd_memcluster_setup(kernstart, kernend);
|
||||
#if 0
|
||||
sbd_memcluster_check();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
tr2_ether_addr(uint8_t *p)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
p[i] = *(NVSRAM_ETHERADDR + i * 4);
|
||||
}
|
||||
|
||||
void tr2_bell(dev_t dev, u_int pitch, u_int period, u_int volue);
|
||||
|
||||
void
|
||||
tr2_bell(dev_t dev, u_int pitch, u_int period, u_int volue)
|
||||
{
|
||||
|
||||
*BUZZER_REG = volue > 0 ? 1 : 0;
|
||||
}
|
|
@ -0,0 +1,341 @@
|
|||
/* $NetBSD: tr2_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tr2_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/locore.h> /* mips3_cp0* */
|
||||
#include <machine/sbdvar.h>
|
||||
#define _SBD_TR2_PRIVATE
|
||||
#include <machine/sbd_tr2.h>
|
||||
|
||||
#include <mips/cpuregs.h>
|
||||
|
||||
SBD_DECL(tr2);
|
||||
|
||||
const uint32_t tr2_sr_bits[_IPL_N] = {
|
||||
0, /* IPL_NONE */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_2, /* IPL_BIO */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_2, /* IPL_NET */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_2|
|
||||
MIPS_INT_MASK_4, /* IPL_{TTY,SERIAL} */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_2|
|
||||
MIPS_INT_MASK_4|
|
||||
MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */
|
||||
/* !!! TEST !!! VME INTERRUPT IS NOT MASKED */
|
||||
};
|
||||
|
||||
#define NIRQ 8
|
||||
struct tr2_intr_handler {
|
||||
int (*func)(void *);
|
||||
void *arg;
|
||||
volatile uint8_t *picnic_reg;
|
||||
uint8_t picnic_mask;
|
||||
struct evcnt evcnt;
|
||||
char evname[32];
|
||||
} tr2_intr_handler[NIRQ] = {
|
||||
[0] = { NULL, NULL, PICNIC_INT4_MASK_REG, PICNIC_INT_KBMS },
|
||||
[2] = { NULL, NULL, PICNIC_INT4_MASK_REG, PICNIC_INT_SERIAL },
|
||||
[5] = { NULL, NULL, PICNIC_INT2_MASK_REG, PICNIC_INT_SCSI },
|
||||
[6] = { NULL, NULL, PICNIC_INT2_MASK_REG, PICNIC_INT_ETHER },
|
||||
[7] = { NULL, NULL, PICNIC_INT0_MASK_REG, PICNIC_INT_FDDLPT },
|
||||
};
|
||||
|
||||
struct evcnt timer_tr2_ev =
|
||||
EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "picnic", "timer");
|
||||
|
||||
static u_long last_clock_intr;
|
||||
|
||||
void
|
||||
tr2_intr_init(void)
|
||||
{
|
||||
uint32_t a = (uint32_t)ews4800mips_nmi_vec;
|
||||
|
||||
/* Install dump button handler address to NVSRAM (jumped from ROM) */
|
||||
*(NVSRAM_CDUMP_ADDR + 0) = (a >> 24) & 0xff;
|
||||
*(NVSRAM_CDUMP_ADDR + 4) = (a >> 16) & 0xff;
|
||||
*(NVSRAM_CDUMP_ADDR + 8) = (a >> 8) & 0xff;
|
||||
*(NVSRAM_CDUMP_ADDR +12) = a & 0xff;
|
||||
|
||||
/* Disable external interrupts */
|
||||
*PICNIC_INT0_MASK_REG = 0;
|
||||
*PICNIC_INT2_MASK_REG = 0;
|
||||
*PICNIC_INT4_MASK_REG = 0;
|
||||
*PICNIC_INT5_MASK_REG = 0;
|
||||
|
||||
evcnt_attach_static(&timer_tr2_ev);
|
||||
}
|
||||
|
||||
void *
|
||||
tr2_intr_establish(int irq, int (*func)(void *), void *arg)
|
||||
{
|
||||
struct tr2_intr_handler *ih = &tr2_intr_handler[irq];
|
||||
int s;
|
||||
|
||||
s = splhigh();
|
||||
ih->func = func;
|
||||
ih->arg = arg;
|
||||
snprintf(ih->evname, sizeof(ih->evname), "irq %d", irq);
|
||||
evcnt_attach_dynamic(&ih->evcnt, EVCNT_TYPE_INTR, NULL,
|
||||
"picnic", ih->evname);
|
||||
|
||||
*ih->picnic_reg |= ih->picnic_mask;
|
||||
splx(s);
|
||||
|
||||
return (void *)irq;
|
||||
}
|
||||
|
||||
void
|
||||
tr2_intr_disestablish(void *arg)
|
||||
{
|
||||
int s, irq = (int)arg;
|
||||
struct tr2_intr_handler *ih = &tr2_intr_handler[irq];
|
||||
|
||||
s = splhigh();
|
||||
*ih->picnic_reg &= ~ih->picnic_mask;
|
||||
ih->func = NULL;
|
||||
ih->arg = NULL;
|
||||
evcnt_detach(&ih->evcnt);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
tr2_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
|
||||
{
|
||||
struct tr2_intr_handler *ih;
|
||||
struct clockframe cf;
|
||||
uint32_t r, cause0;
|
||||
|
||||
cause0 = cause;
|
||||
|
||||
if (ipending & MIPS_INT_MASK_5) { /* CLOCK */
|
||||
last_clock_intr = mips3_cp0_count_read();
|
||||
cf.pc = pc;
|
||||
cf.sr = status;
|
||||
|
||||
*PICNIC_INT5_STATUS_REG = 0;
|
||||
r = *PICNIC_INT5_STATUS_REG;
|
||||
|
||||
if ((status & MIPS_INT_MASK) == MIPS_INT_MASK) {
|
||||
if ((ipending & MIPS_INT_MASK & ~MIPS_INT_MASK_5) ==
|
||||
0) {
|
||||
/*
|
||||
* If all interrupts were enabled and
|
||||
* there isno pending interrupts,
|
||||
* set MIPS_SR_INT_IE so that
|
||||
* spllowerclock() in hardclock()
|
||||
* works properly.
|
||||
*/
|
||||
_splset(MIPS_SR_INT_IE);
|
||||
} else {
|
||||
/*
|
||||
* If there are any pending interrputs,
|
||||
* clear MIPS_SR_INT_IE in cf.sr so that
|
||||
* spllowerclock() in hardclock() will
|
||||
* not happen.
|
||||
*/
|
||||
cf.sr &= ~MIPS_SR_INT_IE;
|
||||
}
|
||||
}
|
||||
hardclock(&cf);
|
||||
timer_tr2_ev.ev_count++;
|
||||
cause &= ~MIPS_INT_MASK_5;
|
||||
}
|
||||
_splset((status & MIPS_INT_MASK_5) | MIPS_SR_INT_IE);
|
||||
|
||||
if (ipending & MIPS_INT_MASK_4) { /* KBD, MOUSE, SERIAL */
|
||||
r = *PICNIC_INT4_STATUS_REG;
|
||||
|
||||
if (r & PICNIC_INT_KBMS) {
|
||||
ih = &tr2_intr_handler[0];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
r &= ~PICNIC_INT_KBMS;
|
||||
}
|
||||
|
||||
if (r & PICNIC_INT_SERIAL) {
|
||||
#if 0
|
||||
printf("SIO interrupt\n");
|
||||
#endif
|
||||
ih = &tr2_intr_handler[2];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
r &= ~PICNIC_INT_SERIAL;
|
||||
}
|
||||
|
||||
cause &= ~MIPS_INT_MASK_4;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if (ipending & MIPS_INT_MASK_3) { /* VME */
|
||||
printf("VME interrupt\n");
|
||||
|
||||
r = *(volatile uint32_t *)0xbfb00018; /* NABI? */
|
||||
if ((r & 0x10) != 0) {
|
||||
/* vme high interrupt */
|
||||
} else if ((r & 0x4) != 0) {
|
||||
/* vme lo interrupt */
|
||||
} else {
|
||||
/* error */
|
||||
}
|
||||
}
|
||||
|
||||
if (ipending & MIPS_INT_MASK_2) { /* ETHER, SCSI */
|
||||
r = *PICNIC_INT2_STATUS_REG;
|
||||
|
||||
if (r & PICNIC_INT_ETHER) {
|
||||
ih = &tr2_intr_handler[6];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
r &= ~PICNIC_INT_ETHER;
|
||||
}
|
||||
|
||||
if (r & PICNIC_INT_SCSI) {
|
||||
ih = &tr2_intr_handler[5];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
r &= ~PICNIC_INT_SCSI;
|
||||
}
|
||||
|
||||
if ((r & PICNIC_INT_FDDLPT) &&
|
||||
((cause0 & status) & MIPS_INT_MASK_5)) {
|
||||
#ifdef DEBUG
|
||||
printf("FDD LPT interrupt\n");
|
||||
#endif
|
||||
ih = &tr2_intr_handler[7];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
r &= ~PICNIC_INT_FDDLPT;
|
||||
}
|
||||
|
||||
cause &= ~MIPS_INT_MASK_2;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if (ipending & MIPS_INT_MASK_1)
|
||||
panic("unknown interrupt INT1\n");
|
||||
|
||||
if (ipending & MIPS_INT_MASK_0) { /* FDD, PRINTER */
|
||||
printf("printer, printer interrupt\n");
|
||||
r = *PICNIC_INT0_STATUS_REG;
|
||||
if (r & PICNIC_INT_FDDLPT) {
|
||||
printf("FDD, Printer interrupt.\n");
|
||||
} else {
|
||||
printf("unknown interrupt INT0\n");
|
||||
}
|
||||
cause &= ~MIPS_INT_MASK_0;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
}
|
||||
|
||||
void
|
||||
tr2_initclocks(void)
|
||||
{
|
||||
|
||||
last_clock_intr = mips3_cp0_count_read();
|
||||
|
||||
/* number of microseconds between interrupts */
|
||||
tick = 1000000 / hz;
|
||||
tickfix = 1000000 - (hz * tick);
|
||||
#ifdef NTP
|
||||
fixtick = tickfix;
|
||||
#endif
|
||||
if (tickfix) {
|
||||
int ftp;
|
||||
|
||||
ftp = min(ffs(tickfix), ffs(hz));
|
||||
tickfix >>= ftp - 1;
|
||||
tickfixinterval = hz >> (ftp - 1);
|
||||
}
|
||||
|
||||
/* Enable clock interrupt */
|
||||
*PICNIC_INT5_MASK_REG |= PICNIC_INT_CLOCK;
|
||||
}
|
||||
|
||||
u_long
|
||||
tr2_readclock(void)
|
||||
{
|
||||
uint32_t res, count;
|
||||
|
||||
/* 32bit wrap-around during subtruction ok here. */
|
||||
count = mips3_cp0_count_read() - last_clock_intr;
|
||||
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
/* $NetBSD: tr2a.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tr2a.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include "fb_sbdio.h"
|
||||
#include "kbms_sbdio.h"
|
||||
#include "zsc_sbdio.h"
|
||||
#include "ewskbd_zsc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <mips/cache.h> /* Set L2-cache size */
|
||||
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/sbdvar.h>
|
||||
#define _SBD_TR2A_PRIVATE
|
||||
#include <machine/sbd_tr2a.h>
|
||||
#include <machine/z8530var.h>
|
||||
|
||||
#include <ews4800mips/ews4800mips/cons_machdep.h>
|
||||
|
||||
#include <dev/cons.h>
|
||||
|
||||
SBD_DECL(tr2a);
|
||||
|
||||
/* EWS4800/360 bus list */
|
||||
static const char *tr2a_mainbusdevs[] = {
|
||||
"sbdio",
|
||||
#ifdef notyet
|
||||
"apbus",
|
||||
"vme",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
/* EWS4800/360 System board device list */
|
||||
static const struct sbdiodevdesc tr2a_sbdiodevs[] = {
|
||||
/* name addr1 addr2 irq flags */
|
||||
{ "lance", 0x1e400000, -1, 0, 0x0000 }, /* AM79C90 */
|
||||
{ "zsc", 0x1e440000, -1, 4, 0x0000 }, /* Z85230 */
|
||||
#if NEWSKBD_ZSC > 0
|
||||
{ "zsc", 0x1e480000, -1, 9, 0x0001 }, /* Z85230 */
|
||||
#else
|
||||
{ "zkbms", 0x1e480000, -1, 9, 0x0000 }, /* Z85230 */
|
||||
#endif
|
||||
{ "mkclock", 0x1e490000, -1, -1, 0x0001 }, /* MK48T18 */
|
||||
{ "osiop", 0x1e500000, -1, 6, 0x0001 }, /* 53C710 */
|
||||
{ "osiop", 0x1e510000, -1, 10, 0x0001 }, /* 53C710 */
|
||||
/* 0xbe46 MUSE */
|
||||
/* 0xbe42 FDC */
|
||||
/* 0xbe43 LPT */
|
||||
/* 0xbe40-0xbe47 LR? */
|
||||
/* 0xbe80 LR4370-> APbus,VME */
|
||||
/* 72069 */
|
||||
/* XXX: maybe fb should be attached at independent bus */
|
||||
{ "fb", 0xf0000000, 0xf5f00000, -1, 0x0001 },
|
||||
{ NULL, -1, -1, -1, 0x0000 } /* terminate */
|
||||
};
|
||||
|
||||
static const struct sbdiodevdesc tr2a_sbdiodevs_nofb[] = {
|
||||
/* name addr1 addr2 irq flags */
|
||||
{ "lance", 0x1e400000, -1, 0, 0x0000 }, /* AM79C90 */
|
||||
{ "zsc", 0x1e440000, -1, 4, 0x0000 }, /* Z85230 */
|
||||
#if NEWSKBD_ZSC > 0
|
||||
{ "zsc", 0x1e480000, -1, 9, 0x0001 }, /* Z85230 */
|
||||
#else
|
||||
{ "zkbms", 0x1e480000, -1, 9, 0x0000 }, /* Z85230 */
|
||||
#endif
|
||||
{ "mkclock", 0x1e490000, -1, -1, 0x0001 }, /* MK48T18 */
|
||||
{ "osiop", 0x1e500000, -1, 6, 0x0001 }, /* 53C710 */
|
||||
{ "osiop", 0x1e510000, -1, 10, 0x0001 }, /* 53C710 */
|
||||
{ NULL, -1, -1, -1, 0x0000 } /* terminate */
|
||||
};
|
||||
|
||||
void
|
||||
tr2a_init(void)
|
||||
{
|
||||
char model_name[32];
|
||||
int have_fb_sbdio;
|
||||
|
||||
have_fb_sbdio = 0;
|
||||
|
||||
platform.machine = MACHINE_TR2A;
|
||||
strlcpy(model_name, SBD_INFO->model_name, sizeof(model_name));
|
||||
if (model_name[0] == '\0') {
|
||||
if (SBD_INFO->model == 0x101f)
|
||||
strcpy(model_name, "EWS4800/360AD");
|
||||
have_fb_sbdio = 1;
|
||||
}
|
||||
|
||||
if (strcmp(model_name, "EWS4800/360ADII") == 0) {
|
||||
platform.cpu_clock = 200000000;
|
||||
have_fb_sbdio = 1;
|
||||
} else if (strcmp(model_name, "EWS4800/360AD") == 0) {
|
||||
platform.cpu_clock = 150000000;
|
||||
have_fb_sbdio = 1;
|
||||
} else if (strcmp(model_name, "EWS4800/360SX") == 0) {
|
||||
/* framebuffer is on APbus */
|
||||
platform.cpu_clock = 200000000;
|
||||
} else if (strcmp(model_name, "EWS4800/360EX") == 0) {
|
||||
/* untested */
|
||||
platform.cpu_clock = 200000000;
|
||||
} else if (strcmp(model_name, "EWS4800/360") == 0) {
|
||||
/* untested */
|
||||
platform.cpu_clock = 133333333;
|
||||
} else {
|
||||
printf("UNKNOWN model %s\n", model_name);
|
||||
platform.cpu_clock = 133333333;
|
||||
}
|
||||
|
||||
curcpu()->ci_cpu_freq = platform.cpu_clock;
|
||||
|
||||
snprintf(platform.name, sizeof(platform.name), "%s (TR2A)", model_name);
|
||||
platform.mainbusdevs = tr2a_mainbusdevs;
|
||||
platform.sbdiodevs = tr2a_sbdiodevs_nofb;
|
||||
if (have_fb_sbdio)
|
||||
platform.sbdiodevs = tr2a_sbdiodevs;
|
||||
|
||||
ipl_sr_bits = tr2a_sr_bits;
|
||||
|
||||
kseg2iobufsize = 0x02000000; /* 32MB for APbus and framebuffer */
|
||||
|
||||
/* Register system-board specific ops. */
|
||||
_SBD_OPS_REGISTER_ALL(tr2a);
|
||||
}
|
||||
|
||||
int
|
||||
tr2a_ipl_bootdev(void)
|
||||
{
|
||||
|
||||
return *NVSRAM_BOOTDEV;
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_cache_config(void)
|
||||
{
|
||||
|
||||
mips_sdcache_size = 1024 * 1024; /* 1MB L2-cache */
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_wbflush(void)
|
||||
{
|
||||
|
||||
*(volatile uint32_t *)0xbe492010;
|
||||
*(volatile uint32_t *)0xbe492010;
|
||||
*(volatile uint32_t *)0xbe492010;
|
||||
*(volatile uint32_t *)0xbe492010;
|
||||
|
||||
#if 0 /* notyet */
|
||||
if (has_apbus)
|
||||
*(volatile uint32_t *)0xbe806000;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_mem_init(void *kernstart, void *kernend)
|
||||
{
|
||||
|
||||
sbd_memcluster_setup(kernstart, kernend);
|
||||
#if 0
|
||||
sbd_memcluster_check();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_consinit(void)
|
||||
{
|
||||
extern struct consdev consdev_zs_sbdio;
|
||||
extern const struct cdevsw zstty_cdevsw;
|
||||
extern int fb_sbdio_cnattach(uint32_t, uint32_t, int);
|
||||
extern void kbd_sbdio_cnattach(uint32_t, uint32_t);
|
||||
extern void ewskbd_zsc_cnattach(uint32_t, uint32_t, int);
|
||||
|
||||
switch (*NVSRAM_CONSTYPE) {
|
||||
#if NFB_SBDIO > 0
|
||||
case 0x80:
|
||||
/* on-board FB on 360AD, 360ADII */
|
||||
cons.type = CONS_FB_KSEG2;
|
||||
if (fb_sbdio_cnattach(TR2A_GAFB_ADDR, TR2A_GAREG_ADDR, 0x0001))
|
||||
break;
|
||||
#if NEWSKBD_ZSC > 0
|
||||
ewskbd_zsc_cnattach(TR2A_KBMS_BASE, TR2A_KBMS_BASE + 4,
|
||||
4915200);
|
||||
#else
|
||||
#if NKBMS_SBDIO > 0
|
||||
kbd_sbdio_cnattach(TR2A_KBMS_BASE, TR2A_KBMS_BASE + 4);
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
#if NZSC_SBDIO > 0
|
||||
case 0x01:
|
||||
/* sio 1 (zs channel A) */
|
||||
cons.type = CONS_SIO1;
|
||||
zs_consaddr = (void *)(TR2A_SIO_BASE + 8);
|
||||
cn_tab = &consdev_zs_sbdio;
|
||||
cn_tab->cn_pri = CN_REMOTE;
|
||||
cn_tab->cn_dev =
|
||||
makedev(cdevsw_lookup_major(&zstty_cdevsw), 0);
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
return;
|
||||
case 0x02:
|
||||
/* sio 2 (zs channel B) */
|
||||
cons.type = CONS_SIO2;
|
||||
zs_consaddr = (void *)(TR2A_SIO_BASE + 0);
|
||||
cn_tab = &consdev_zs_sbdio;
|
||||
cn_tab->cn_pri = CN_REMOTE;
|
||||
cn_tab->cn_dev =
|
||||
makedev(cdevsw_lookup_major(&zstty_cdevsw), 1);
|
||||
(*cn_tab->cn_init)(cn_tab);
|
||||
return;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
rom_cons_init(); /* XXX */
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_reboot(void)
|
||||
{
|
||||
|
||||
*SOFTRESET_FLAG |= 0x80000000;
|
||||
*SOFTRESET_REG = 0x01;
|
||||
*(uint8_t *)0xbfbffffc = 0xff;
|
||||
for (;;)
|
||||
;
|
||||
/*NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_poweroff(void)
|
||||
{
|
||||
|
||||
for (;;)
|
||||
*POWEROFF_REG = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_ether_addr(uint8_t *p)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
p[i] = *(uint8_t *)(NVSRAM_ETHERADDR + i * 4);
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
/* $NetBSD: tr2a_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tr2a_intr.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/locore.h> /* mips3_cp0* */
|
||||
#include <machine/sbdvar.h>
|
||||
#define _SBD_TR2A_PRIVATE
|
||||
#include <machine/sbd_tr2a.h>
|
||||
|
||||
SBD_DECL(tr2a);
|
||||
|
||||
const uint32_t tr2a_sr_bits[_IPL_N] = {
|
||||
0, /* IPL_NONE */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFT */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0, /* IPL_SOFTCLOCK */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTNET */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1, /* IPL_SOFTSERIAL */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_1|
|
||||
MIPS_INT_MASK_2, /* IPL_BIO */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_1|
|
||||
MIPS_INT_MASK_2, /* IPL_NET */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_1|
|
||||
MIPS_INT_MASK_2|
|
||||
MIPS_INT_MASK_3|
|
||||
MIPS_INT_MASK_4, /* IPL_{TTY,SERIAL} */
|
||||
|
||||
MIPS_SOFT_INT_MASK_0|
|
||||
MIPS_SOFT_INT_MASK_1|
|
||||
MIPS_INT_MASK_0|
|
||||
MIPS_INT_MASK_1|
|
||||
MIPS_INT_MASK_2|
|
||||
MIPS_INT_MASK_3|
|
||||
MIPS_INT_MASK_4|
|
||||
MIPS_INT_MASK_5, /* IPL_{CLOCK,HIGH} */
|
||||
};
|
||||
|
||||
#define NIRQ 16
|
||||
enum bustype {
|
||||
ASOBUS,
|
||||
APBUS,
|
||||
};
|
||||
|
||||
/* ASO + APbus interrupt */
|
||||
struct tr2a_intr_handler {
|
||||
int (*func)(void *);
|
||||
void *arg;
|
||||
enum bustype bustype;
|
||||
uint32_t cpu_int;
|
||||
uint32_t aso_mask;
|
||||
struct evcnt evcnt;
|
||||
char evname[32];
|
||||
} tr2a_intr_handler[NIRQ] = {
|
||||
[0] = { NULL, NULL, ASOBUS, 2, 0x00000001 }, /* AM79C90 */
|
||||
[4] = { NULL, NULL, ASOBUS, 4, 0x00300010 }, /* Z85230 (SIO) */
|
||||
[6] = { NULL, NULL, ASOBUS, 2, 0x00000200 }, /* 53C710 SCSI-A */
|
||||
[9] = { NULL, NULL, ASOBUS, 4, 0x00000040 }, /* Z85230 (KBMS) */
|
||||
[10] = { NULL, NULL, ASOBUS, 2, 0x00000100 }, /* 53C710 SCSI-B */
|
||||
};
|
||||
|
||||
/* CPU interrupt */
|
||||
struct tr2a_intc_handler {
|
||||
int ref_cnt;
|
||||
uint32_t mask;
|
||||
} tr2a_intc_handler[6] = {
|
||||
[0] = { 0, 0x00000020 },
|
||||
[1] = { 0, 0x00000800 },
|
||||
[2] = { 0, 0x00010000 },
|
||||
[3] = { 0, 0x00200000 },
|
||||
[4] = { 0, 0x04000000 },
|
||||
[5] = { 0, 0x80000000 }
|
||||
};
|
||||
|
||||
struct evcnt timer_tr2a_ev =
|
||||
EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intc", "timer");
|
||||
|
||||
static uint32_t last_clock_intr;
|
||||
|
||||
void
|
||||
tr2a_intr_init(void)
|
||||
{
|
||||
|
||||
/* Disable all ASObus interrupt */
|
||||
#if 1
|
||||
*ASO_INT_MASK_REG &= ~TR2A_ASO_INTMASK_ALL;
|
||||
#else
|
||||
/* open all interrupt for development. */
|
||||
*ASO_INT_MASK_REG |= TR2A_ASO_INTMASK_ALL;
|
||||
#endif
|
||||
tr2a_wbflush();
|
||||
|
||||
/* set up interval timer clock */
|
||||
*INTC_MASK_REG = 0;
|
||||
*CLOCK_REG = 0x80;
|
||||
tr2a_wbflush();
|
||||
if ((*CLOCK_REG & 0x80) != 0)
|
||||
*ASO_INT_MASK_REG |= 0x8000; /* NMI (what UX does.) -uch */
|
||||
tr2a_wbflush();
|
||||
|
||||
evcnt_attach_static(&timer_tr2a_ev);
|
||||
}
|
||||
|
||||
void *
|
||||
tr2a_intr_establish(int irq, int (*func)(void *), void *arg)
|
||||
{
|
||||
struct tr2a_intr_handler *ih = &tr2a_intr_handler[irq];
|
||||
struct tr2a_intc_handler *ic = &tr2a_intc_handler[ih->cpu_int];
|
||||
int s;
|
||||
|
||||
s = splhigh();
|
||||
ih->func = func;
|
||||
ih->arg = arg;
|
||||
snprintf(ih->evname, sizeof(ih->evname), "irq %d", irq);
|
||||
evcnt_attach_dynamic(&ih->evcnt, EVCNT_TYPE_INTR,
|
||||
NULL, "intc", ih->evname);
|
||||
|
||||
if (ih->bustype == ASOBUS)
|
||||
*ASO_INT_MASK_REG |= ih->aso_mask;
|
||||
|
||||
if (ic->ref_cnt++ == 0)
|
||||
*INTC_MASK_REG |= ic->mask;
|
||||
|
||||
tr2a_wbflush();
|
||||
splx(s);
|
||||
|
||||
return (void *)irq;
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_intr_disestablish(void *arg)
|
||||
{
|
||||
int s, irq = (int)arg;
|
||||
struct tr2a_intr_handler *ih = &tr2a_intr_handler[irq];
|
||||
struct tr2a_intc_handler *ic = &tr2a_intc_handler[ih->cpu_int];
|
||||
|
||||
s = splhigh();
|
||||
if (ih->bustype == ASOBUS)
|
||||
*ASO_INT_MASK_REG &= ~ih->aso_mask;
|
||||
|
||||
if (--ic->ref_cnt == 0)
|
||||
*INTC_MASK_REG &= ~ic->mask;
|
||||
|
||||
ih->func = NULL;
|
||||
ih->arg = NULL;
|
||||
evcnt_detach(&ih->evcnt);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
|
||||
{
|
||||
struct tr2a_intr_handler *ih;
|
||||
struct clockframe cf;
|
||||
uint32_t r, intc_cause;
|
||||
|
||||
intc_cause = *INTC_STATUS_REG & *INTC_MASK_REG;
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_5) && (intc_cause & INTC_INT5)) {
|
||||
last_clock_intr = mips3_cp0_count_read();
|
||||
cf.pc = pc;
|
||||
cf.sr = status;
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x7c;
|
||||
*INTC_STATUS_REG;
|
||||
if ((status & MIPS_INT_MASK) == MIPS_INT_MASK) {
|
||||
if ((ipending & MIPS_INT_MASK & ~MIPS_INT_MASK_5) ==
|
||||
0) {
|
||||
/*
|
||||
* If all interrupts were enabled and
|
||||
* there is no pending interrupts,
|
||||
* set MIPS_SR_INT_IE so that
|
||||
* spllowerclock() in hardclock()
|
||||
* works properly.
|
||||
*/
|
||||
_splset(MIPS_SR_INT_IE);
|
||||
} else {
|
||||
/*
|
||||
* If there are any pending interrputs,
|
||||
* clear MIPS_SR_INT_IE in cf.sr so that
|
||||
* spllowerclock() in hardclock() will
|
||||
* not happen.
|
||||
*/
|
||||
cf.sr &= ~MIPS_SR_INT_IE;
|
||||
}
|
||||
}
|
||||
hardclock(&cf);
|
||||
timer_tr2a_ev.ev_count++;
|
||||
cause &= ~MIPS_INT_MASK_5;
|
||||
}
|
||||
_splset((status & MIPS_INT_MASK_5) | MIPS_SR_INT_IE);
|
||||
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_4) && (intc_cause & INTC_INT4)) {
|
||||
/* KBD, MOUSE, SERIAL */
|
||||
r = *ASO_INT_STATUS_REG;
|
||||
if (r & 0x300010) {
|
||||
ih = &tr2a_intr_handler[4];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
} else if (r & 0x40) {
|
||||
/* kbms */
|
||||
ih = &tr2a_intr_handler[9];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
} else if (r & 0x20) {
|
||||
printf("INT4 (1)\n");
|
||||
} else if (r & 0x00800000) {
|
||||
printf("INT4 (2)\n");
|
||||
} else if (r & 0x00400000) {
|
||||
printf("INT4 (3)\n");
|
||||
} else {
|
||||
printf("not for INT4 %x\n", r);
|
||||
}
|
||||
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x68;
|
||||
*INTC_STATUS_REG;
|
||||
|
||||
cause &= ~MIPS_INT_MASK_4;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_3) && (intc_cause & INTC_INT3)) {
|
||||
/* APbus HI */
|
||||
printf("APbus HI\n");
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x54;
|
||||
*INTC_STATUS_REG;
|
||||
cause &= ~MIPS_INT_MASK_3;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_2) && (intc_cause & INTC_INT2)) {
|
||||
/* SCSI, ETHER */
|
||||
r = *ASO_INT_STATUS_REG;
|
||||
if (r & 0x100) { /* SCSI-A */
|
||||
ih = &tr2a_intr_handler[6];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
} else if (r & 0x200) { /* SCSI-B */
|
||||
ih = &tr2a_intr_handler[10];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
} else if (r & 0x1) { /* LANCE */
|
||||
ih = &tr2a_intr_handler[0];
|
||||
if (ih->func) {
|
||||
ih->func(ih->arg);
|
||||
ih->evcnt.ev_count++;
|
||||
}
|
||||
} else {
|
||||
printf("not for INT2 %x %x\n", r,
|
||||
*ASO_DMAINT_STATUS_REG);
|
||||
}
|
||||
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x40;
|
||||
*INTC_STATUS_REG;
|
||||
cause &= ~MIPS_INT_MASK_2;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_1) && (intc_cause & INTC_INT1)) {
|
||||
/* APbus LO */
|
||||
printf("APbus LO\n");
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x2c;
|
||||
*INTC_STATUS_REG;
|
||||
cause &= ~MIPS_INT_MASK_1;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
|
||||
if ((ipending & MIPS_INT_MASK_0) && (intc_cause & INTC_INT0)) {
|
||||
/* NMI etc. */
|
||||
r = *ASO_INT_STATUS_REG;
|
||||
printf("INT0 %08x\n", r);
|
||||
if (r & 0x8000) {
|
||||
printf("INT0(1) NMI\n");
|
||||
} else if (r & 0x8) {
|
||||
printf("INT0(2)\n");
|
||||
} else if (r & 0x4) {
|
||||
printf("INT0(3)\n");
|
||||
} else {
|
||||
printf("not for INT0 %x\n", r);
|
||||
}
|
||||
tr2a_wbflush();
|
||||
*INTC_CLEAR_REG = 0x14;
|
||||
*INTC_STATUS_REG;
|
||||
cause &= ~MIPS_INT_MASK_0;
|
||||
}
|
||||
_splset(((status & ~cause) & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE);
|
||||
}
|
||||
|
||||
void
|
||||
tr2a_initclocks(void)
|
||||
{
|
||||
|
||||
last_clock_intr = mips3_cp0_count_read();
|
||||
|
||||
/* number of microseconds between interrupts */
|
||||
tick = 1000000 / hz;
|
||||
tickfix = 1000000 - (hz * tick);
|
||||
#ifdef NTP
|
||||
fixtick = tickfix;
|
||||
#endif
|
||||
if (tickfix) {
|
||||
int ftp;
|
||||
|
||||
ftp = min(ffs(tickfix), ffs(hz));
|
||||
tickfix >>= ftp - 1;
|
||||
tickfixinterval = hz >> (ftp - 1);
|
||||
}
|
||||
|
||||
/* Enable INT5 */
|
||||
*INTC_MASK_REG |= INTC_INT5;
|
||||
tr2a_wbflush();
|
||||
}
|
||||
|
||||
u_long
|
||||
tr2a_readclock(void)
|
||||
{
|
||||
uint32_t res, count;
|
||||
|
||||
/* 32bit wrap-around during subtruction ok here. */
|
||||
count = mips3_cp0_count_read() - last_clock_intr;
|
||||
MIPS_COUNT_TO_MHZ(curcpu(), count, res);
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/* $NetBSD: vtoc.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vtoc.c,v 1.1 2005/12/29 15:20:08 tsutsui Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#if !defined(_KERNEL) && defined(_STANDALONE)
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
#ifdef VTOC_DEBUG
|
||||
#define DPRINTF(fmt, args...) printf(fmt, ##args)
|
||||
#else
|
||||
#define DPRINTF(arg...) ((void)0)
|
||||
#endif
|
||||
|
||||
#include <machine/sector.h>
|
||||
#include <machine/vtoc.h>
|
||||
|
||||
#ifdef VTOC_DEBUG
|
||||
void vtoc_print_partition_table(const struct ux_partition *);
|
||||
#endif /* VTOC_DEBUG */
|
||||
|
||||
boolean_t
|
||||
vtoc_sector(void *rwops, struct vtoc_sector *vtoc, int start)
|
||||
{
|
||||
|
||||
if (!sector_read(rwops, (void *)vtoc, start + VTOC_SECTOR))
|
||||
return FALSE;
|
||||
|
||||
if (!vtoc_sanity(vtoc))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const struct ux_partition *
|
||||
vtoc_find_bfs(const struct vtoc_sector *vtoc)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!vtoc_valid(vtoc)) {
|
||||
printf("invalid VTOC\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < vtoc->npartitions; i++)
|
||||
if (vtoc->partition[i].tag == VTOC_TAG_STAND)
|
||||
break;
|
||||
|
||||
if (i == vtoc->npartitions) {
|
||||
printf("no bfs partition found.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return &vtoc->partition[i];
|
||||
}
|
||||
|
||||
boolean_t
|
||||
vtoc_valid(const struct vtoc_sector *vtoc)
|
||||
{
|
||||
|
||||
return (vtoc->magic == VTOC_MAGIC) && (vtoc->version == VTOC_VERSION);
|
||||
}
|
||||
|
||||
boolean_t
|
||||
vtoc_sanity(const struct vtoc_sector *vtoc)
|
||||
{
|
||||
|
||||
if (!vtoc_valid(vtoc)) {
|
||||
DPRINTF("Invalid VTOC.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINTF("[VTOC] (%d byte)\n", sizeof *vtoc);
|
||||
DPRINTF("Bootinfo = %08x %08x %08x\n",
|
||||
vtoc->bootinfo[0], vtoc->bootinfo[1], vtoc->bootinfo[2]);
|
||||
DPRINTF("Magic = %08x\n", vtoc->magic);
|
||||
DPRINTF("Version = %d\n", vtoc->version);
|
||||
DPRINTF("Volume = %s\n", vtoc->volume);
|
||||
DPRINTF("Sector size = %d\n", vtoc->sector_size_byte);
|
||||
DPRINTF("# of partitions = %d\n", vtoc->npartitions);
|
||||
#ifdef VTOC_DEBUG
|
||||
vtoc_print_partition_table(vtoc->partition);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef VTOC_DEBUG
|
||||
void
|
||||
vtoc_print_partition_table(const struct ux_partition *p)
|
||||
{
|
||||
int i;
|
||||
|
||||
DPRINTF(" Partition Tag Flags Start Count Last\n");
|
||||
for (i = 0; i < 16; i++, p++) {
|
||||
DPRINTF(" %x %d %02x %8d %8d %8d\n",
|
||||
i, p->tag, p->flags, p->start_sector, p->nsectors,
|
||||
p->start_sector + p->nsectors - 1);
|
||||
}
|
||||
}
|
||||
#endif /* VTOC_DEBUG */
|
|
@ -0,0 +1,25 @@
|
|||
# $NetBSD: Makefile,v 1.1 2005/12/29 15:20:08 tsutsui Exp $
|
||||
|
||||
INCSDIR= /usr/include/ews4800mips
|
||||
|
||||
INCS= ansi.h aout_machdep.h asm.h \
|
||||
bswap.h \
|
||||
cdefs.h cpu.h \
|
||||
db_machdep.h disklabel.h \
|
||||
ecoff_machdep.h elf_machdep.h endian.h endian_machdep.h \
|
||||
float.h \
|
||||
ieee.h ieeefp.h \
|
||||
int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
|
||||
intr.h \
|
||||
kcore.h kdbparam.h \
|
||||
limits.h lock.h locore.h \
|
||||
math.h mcontext.h mips_opcode.h \
|
||||
param.h pcb.h pdinfo.h pmap.h pmc.h proc.h profile.h psl.h pte.h \
|
||||
ptrace.h \
|
||||
reg.h regdef.h regnum.h reloc.h \
|
||||
setjmp.h signal.h stdarg.h \
|
||||
trap.h types.h \
|
||||
varargs.h vmparam.h vtoc.h \
|
||||
wchar_limits.h
|
||||
|
||||
.include <bsd.kinc.mk>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ansi.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/ansi.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: aout_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/aout_machdep.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: asm.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/asm.h>
|
|
@ -0,0 +1,43 @@
|
|||
/* $NetBSD: autoconf.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_AUTOCONF_H_
|
||||
#define _EWS4800MIPS_AUTOCONF_H_
|
||||
|
||||
struct mainbus_attach_args {
|
||||
const char *ma_name;
|
||||
};
|
||||
|
||||
#endif /* _EWS4800MIPS_AUTOCONF_H_ */
|
|
@ -0,0 +1,49 @@
|
|||
/* $NetBSD: bfs.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_BFS_H_
|
||||
#define _EWS4800MIPS_BFS_H_
|
||||
#include <fs/sysvbfs/bfs.h>
|
||||
#include <machine/pdinfo.h>
|
||||
#include <machine/vtoc.h>
|
||||
|
||||
int bfs_init(struct bfs **);
|
||||
int bfs_create(const struct pdinfo_sector *, const struct vtoc_sector *);
|
||||
int bfs_find(int *);
|
||||
|
||||
#endif /* _EWS4800MIPS_BFS_H_ */
|
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: bootinfo.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_BOOTINFO_H_
|
||||
#define _EWS4800MIPS_BOOTINFO_H_
|
||||
|
||||
struct bootinfo {
|
||||
uint32_t bi_version;
|
||||
size_t bi_size;
|
||||
int bi_nsym;
|
||||
uint8_t *bi_ssym;
|
||||
uint8_t *bi_esym;
|
||||
uint32_t bi_mainfo;
|
||||
};
|
||||
|
||||
#endif /* !_EWS4800MIPS_BOOTINFO_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: bswap.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/bswap.h>
|
|
@ -0,0 +1,866 @@
|
|||
/* $NetBSD: bus.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2000, 2001, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
||||
* NASA Ames Research Center.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_BUS_H_
|
||||
#define _EWS4800MIPS_BUS_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* Turn on BUS_SPACE_DEBUG if the global DEBUG option is enabled.
|
||||
*/
|
||||
#if defined(DEBUG) && !defined(BUS_SPACE_DEBUG)
|
||||
#define BUS_SPACE_DEBUG
|
||||
#endif
|
||||
|
||||
#ifdef BUS_SPACE_DEBUG
|
||||
#include <sys/systm.h> /* for printf() prototype */
|
||||
/*
|
||||
* Macros for checking the aligned-ness of pointers passed to bus
|
||||
* space ops. Strict alignment is required by the MIPS architecture,
|
||||
* and a trap will occur if unaligned access is performed. These
|
||||
* may aid in the debugging of a broken device driver by displaying
|
||||
* useful information about the problem.
|
||||
*/
|
||||
#define __BUS_SPACE_ALIGNED_ADDRESS(p, t) \
|
||||
((((uint32_t)(p)) & (sizeof(t)-1)) == 0)
|
||||
|
||||
#define __BUS_SPACE_ADDRESS_SANITY(p, t, d) \
|
||||
({ \
|
||||
if (__BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \
|
||||
printf("%s 0x%x not aligned to %u bytes %s:%d\n", \
|
||||
d, (uint32_t)(p), (uint32_t)sizeof(t), __FILE__, \
|
||||
__LINE__); \
|
||||
} \
|
||||
(void) 0; \
|
||||
})
|
||||
|
||||
#define BUS_SPACE_ALIGNED_POINTER(p, t) __BUS_SPACE_ALIGNED_ADDRESS(p, t)
|
||||
#else
|
||||
#define __BUS_SPACE_ADDRESS_SANITY(p, t, d) (void) 0
|
||||
#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
|
||||
#endif /* BUS_SPACE_DEBUG */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* Addresses (in bus space).
|
||||
*/
|
||||
typedef long bus_addr_t;
|
||||
typedef long bus_size_t;
|
||||
|
||||
/*
|
||||
* Access methods for bus space.
|
||||
*/
|
||||
typedef struct ews4800mips_bus_space *bus_space_tag_t;
|
||||
typedef bus_addr_t bus_space_handle_t;
|
||||
|
||||
struct extent; /* forward declaration */
|
||||
|
||||
struct ews4800mips_bus_space {
|
||||
struct extent *ebs_extent;
|
||||
bus_addr_t ebs_base_addr;
|
||||
bus_size_t ebs_size;
|
||||
|
||||
/* cookie */
|
||||
void *ebs_cookie;
|
||||
|
||||
/* mapping/unmapping */
|
||||
int (*ebs_map)(void *, bus_addr_t, bus_size_t,
|
||||
int, bus_space_handle_t *);
|
||||
void (*ebs_unmap)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
int (*ebs_subregion)(void *, bus_space_handle_t,
|
||||
bus_size_t, bus_size_t, bus_space_handle_t *);
|
||||
|
||||
/* allocation/deallocation */
|
||||
int (*ebs_alloc)(void *, bus_addr_t, bus_addr_t,
|
||||
bus_size_t, bus_size_t, bus_size_t, int,
|
||||
bus_addr_t *, bus_space_handle_t *);
|
||||
void (*ebs_free)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
|
||||
/* get kernel virtual address */
|
||||
void * (*ebs_vaddr)(void *, bus_space_handle_t);
|
||||
|
||||
/* read (single) */
|
||||
uint8_t (*ebs_r_1)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
uint16_t (*ebs_r_2)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
uint32_t (*ebs_r_4)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
uint64_t (*ebs_r_8)(void *, bus_space_handle_t,
|
||||
bus_size_t);
|
||||
|
||||
/* read multiple */
|
||||
void (*ebs_rm_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint8_t *, bus_size_t);
|
||||
void (*ebs_rm_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint16_t *, bus_size_t);
|
||||
void (*ebs_rm_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint32_t *, bus_size_t);
|
||||
void (*ebs_rm_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint64_t *, bus_size_t);
|
||||
|
||||
/* read region */
|
||||
void (*ebs_rr_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint8_t *, bus_size_t);
|
||||
void (*ebs_rr_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint16_t *, bus_size_t);
|
||||
void (*ebs_rr_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint32_t *, bus_size_t);
|
||||
void (*ebs_rr_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint64_t *, bus_size_t);
|
||||
|
||||
/* write (single) */
|
||||
void (*ebs_w_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint8_t);
|
||||
void (*ebs_w_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint16_t);
|
||||
void (*ebs_w_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint32_t);
|
||||
void (*ebs_w_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint64_t);
|
||||
|
||||
/* write multiple */
|
||||
void (*ebs_wm_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint8_t *, bus_size_t);
|
||||
void (*ebs_wm_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint16_t *, bus_size_t);
|
||||
void (*ebs_wm_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint32_t *, bus_size_t);
|
||||
void (*ebs_wm_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint64_t *, bus_size_t);
|
||||
|
||||
/* write region */
|
||||
void (*ebs_wr_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint8_t *, bus_size_t);
|
||||
void (*ebs_wr_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint16_t *, bus_size_t);
|
||||
void (*ebs_wr_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint32_t *, bus_size_t);
|
||||
void (*ebs_wr_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, const uint64_t *, bus_size_t);
|
||||
|
||||
/* set multiple */
|
||||
void (*ebs_sm_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint8_t, bus_size_t);
|
||||
void (*ebs_sm_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint16_t, bus_size_t);
|
||||
void (*ebs_sm_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint32_t, bus_size_t);
|
||||
void (*ebs_sm_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint64_t, bus_size_t);
|
||||
|
||||
/* set region */
|
||||
void (*ebs_sr_1)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint8_t, bus_size_t);
|
||||
void (*ebs_sr_2)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint16_t, bus_size_t);
|
||||
void (*ebs_sr_4)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint32_t, bus_size_t);
|
||||
void (*ebs_sr_8)(void *, bus_space_handle_t,
|
||||
bus_size_t, uint64_t, bus_size_t);
|
||||
|
||||
/* copy */
|
||||
void (*ebs_c_1)(void *, bus_space_handle_t, bus_size_t,
|
||||
bus_space_handle_t, bus_size_t, bus_size_t);
|
||||
void (*ebs_c_2)(void *, bus_space_handle_t, bus_size_t,
|
||||
bus_space_handle_t, bus_size_t, bus_size_t);
|
||||
void (*ebs_c_4)(void *, bus_space_handle_t, bus_size_t,
|
||||
bus_space_handle_t, bus_size_t, bus_size_t);
|
||||
void (*ebs_c_8)(void *, bus_space_handle_t, bus_size_t,
|
||||
bus_space_handle_t, bus_size_t, bus_size_t);
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* Don't use locore.h wbflush */
|
||||
#undef wbflush
|
||||
#define wbflush() platform.wbflush()
|
||||
#ifdef _EWS4800MIPS_BUS_SPACE_PRIVATE
|
||||
|
||||
#ifndef __read_1
|
||||
#define __read_1(a) (*(volatile uint8_t *)(a))
|
||||
#endif
|
||||
#ifndef __read_2
|
||||
#define __read_2(a) (*(volatile uint16_t *)(a))
|
||||
#endif
|
||||
#ifndef __read_4
|
||||
#define __read_4(a) (*(volatile uint32_t *)(a))
|
||||
#endif
|
||||
#ifndef __read_8
|
||||
#define __read_8(a) (*(volatile uint64_t *)(a))
|
||||
#endif
|
||||
#define __read_16(a) "error. not yet"
|
||||
|
||||
#ifndef __write_1
|
||||
#define __write_1(a, v) { \
|
||||
*(volatile uint8_t *)(a) = (v); \
|
||||
wbflush(); \
|
||||
}
|
||||
#endif
|
||||
#ifndef __write_2
|
||||
#define __write_2(a, v) { \
|
||||
*(volatile uint16_t *)(a) = (v); \
|
||||
wbflush(); \
|
||||
}
|
||||
#endif
|
||||
#ifndef __write_4
|
||||
#define __write_4(a, v) { \
|
||||
*(volatile uint32_t *)(a) = (v); \
|
||||
wbflush(); \
|
||||
}
|
||||
#endif
|
||||
#ifndef __write_8
|
||||
#define __write_8(a, v) { \
|
||||
*(volatile uint64_t *)(a) = (v); \
|
||||
wbflush(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define __TYPENAME(BITS) uint##BITS##_t
|
||||
|
||||
#define _BUS_SPACE_READ(PREFIX, BYTES, BITS) \
|
||||
static __TYPENAME(BITS) \
|
||||
PREFIX##_read_##BYTES(void *, bus_space_handle_t, bus_size_t); \
|
||||
static __TYPENAME(BITS) \
|
||||
PREFIX##_read_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset) \
|
||||
{ \
|
||||
return __read_##BYTES(VADDR(bsh, offset)); \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_READ_MULTI(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_read_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
__TYPENAME(BITS) *, bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_read_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, __TYPENAME(BITS) *addr, bus_size_t count) \
|
||||
{ \
|
||||
bus_addr_t a = VADDR(bsh, offset); \
|
||||
while (count--) \
|
||||
*addr++ = __read_##BYTES(a); \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_READ_REGION(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_read_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
__TYPENAME(BITS) *, bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_read_region_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, __TYPENAME(BITS) *addr, bus_size_t count) \
|
||||
{ \
|
||||
while (count--) { \
|
||||
*addr++ = __read_##BYTES(VADDR(bsh, offset)); \
|
||||
offset += BYTES; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_WRITE(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_write_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
__TYPENAME(BITS)); \
|
||||
static void \
|
||||
PREFIX##_write_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, __TYPENAME(BITS) value) \
|
||||
{ \
|
||||
__write_##BYTES(VADDR(bsh, offset), value); \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_WRITE_MULTI(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_write_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
const __TYPENAME(BITS) *, bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_write_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, const __TYPENAME(BITS) *addr, bus_size_t count) \
|
||||
{ \
|
||||
bus_addr_t a = VADDR(bsh, offset); \
|
||||
while (count--) { \
|
||||
__write_##BYTES(a, *addr++); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_WRITE_REGION(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_write_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
const __TYPENAME(BITS) *, bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_write_region_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, const __TYPENAME(BITS) *addr, bus_size_t count) \
|
||||
{ \
|
||||
while (count--) { \
|
||||
__write_##BYTES(VADDR(bsh, offset), *addr++); \
|
||||
offset += BYTES; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_SET_MULTI(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_set_multi_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
__TYPENAME(BITS), bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_set_multi_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, __TYPENAME(BITS) value, bus_size_t count) \
|
||||
{ \
|
||||
bus_addr_t a = VADDR(bsh, offset); \
|
||||
while (count--) { \
|
||||
__write_##BYTES(a, value); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_SET_REGION(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_set_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
__TYPENAME(BITS), bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_set_region_##BYTES(void *tag, bus_space_handle_t bsh, \
|
||||
bus_size_t offset, __TYPENAME(BITS) value, bus_size_t count) \
|
||||
{ \
|
||||
while (count--) { \
|
||||
__write_##BYTES(VADDR(bsh, offset), value); \
|
||||
offset += BYTES; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_COPY_REGION(PREFIX, BYTES, BITS) \
|
||||
static void \
|
||||
PREFIX##_copy_region_##BYTES(void *, bus_space_handle_t, bus_size_t, \
|
||||
bus_space_handle_t, bus_size_t, bus_size_t); \
|
||||
static void \
|
||||
PREFIX##_copy_region_##BYTES(void *t, bus_space_handle_t h1, \
|
||||
bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, bus_size_t c) \
|
||||
{ \
|
||||
bus_size_t o; \
|
||||
if ((h1 + o1) >= (h2 + o2)) { \
|
||||
/* src after dest: copy forward */ \
|
||||
for (o = 0; c != 0; c--, o += BYTES) \
|
||||
__write_##BYTES(VADDR(h2, o2 + o), \
|
||||
__read_##BYTES(VADDR(h1, o1 + o))); \
|
||||
} else { \
|
||||
/* dest after src: copy backwards */ \
|
||||
for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \
|
||||
__write_##BYTES(VADDR(h2, o2 + o), \
|
||||
__read_##BYTES(VADDR(h1, o1 + o))); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define _BUS_SPACE_NO_MAP \
|
||||
(int (*)(void *, bus_addr_t, bus_size_t, int, \
|
||||
bus_space_handle_t *))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_UNMAP \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t)) \
|
||||
_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_SUBREGION \
|
||||
(int (*)(void *, bus_space_handle_t, bus_size_t, bus_size_t, \
|
||||
bus_space_handle_t *))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_ALLOC \
|
||||
(int (*)(void *, bus_addr_t, bus_addr_t, bus_size_t, bus_size_t,\
|
||||
bus_size_t, int, bus_addr_t *, bus_space_handle_t *)) \
|
||||
_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_FREE \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t)) \
|
||||
_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_VADDR \
|
||||
(void *(*)(void *, bus_space_handle_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_READ(BYTES, BITS) \
|
||||
(uint##BITS##_t (*)(void *, bus_space_handle_t, bus_size_t)) \
|
||||
_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_READ_MULTI(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
uint##BITS##_t *, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_READ_REGION(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
uint##BITS##_t *, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_WRITE(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
uint##BITS##_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_WRITE_MULTI(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
const uint##BITS##_t *, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_WRITE_REGION(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
const uint##BITS##_t *, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_SET_MULTI(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
uint##BITS##_t, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_SET_REGION(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
uint##BITS##_t, bus_size_t))_bus_space_invalid_access
|
||||
#define _BUS_SPACE_NO_COPY_REGION(BYTES, BITS) \
|
||||
(void (*)(void *, bus_space_handle_t, bus_size_t, \
|
||||
bus_space_handle_t, bus_size_t, bus_size_t))_bus_space_invalid_access
|
||||
|
||||
void _bus_space_invalid_access(void);
|
||||
#endif /* _EWS4800MIPS_BUS_SPACE_PRIVATE */
|
||||
|
||||
#define __ebs_c(a,b) __CONCAT(a,b)
|
||||
#define __ebs_opname(op,size) __ebs_c(__ebs_c(__ebs_c(ebs_,op),_),size)
|
||||
|
||||
#define __ebs_rs(sz, tn, t, h, o) \
|
||||
(__BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"), \
|
||||
(*(t)->__ebs_opname(r,sz))((t)->ebs_cookie, h, o))
|
||||
|
||||
#define __ebs_ws(sz, tn, t, h, o, v) \
|
||||
({ \
|
||||
__BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \
|
||||
(*(t)->__ebs_opname(w,sz))((t)->ebs_cookie, h, o, v); \
|
||||
})
|
||||
|
||||
#define __ebs_nonsingle(type, sz, tn, t, h, o, a, c) \
|
||||
({ \
|
||||
__BUS_SPACE_ADDRESS_SANITY((a), tn, "buffer"); \
|
||||
__BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \
|
||||
(*(t)->__ebs_opname(type,sz))((t)->ebs_cookie, h, o, a, c); \
|
||||
})
|
||||
|
||||
#define __ebs_set(type, sz, tn, t, h, o, v, c) \
|
||||
({ \
|
||||
__BUS_SPACE_ADDRESS_SANITY((h) + (o), tn, "bus addr"); \
|
||||
(*(t)->__ebs_opname(type,sz))((t)->ebs_cookie, h, o, v, c); \
|
||||
})
|
||||
|
||||
#define __ebs_copy(sz, tn, t, h1, o1, h2, o2, cnt) \
|
||||
({ \
|
||||
__BUS_SPACE_ADDRESS_SANITY((h1) + (o1), tn, "bus addr 1"); \
|
||||
__BUS_SPACE_ADDRESS_SANITY((h2) + (o2), tn, "bus addr 2"); \
|
||||
(*(t)->__ebs_opname(c,sz))((t)->ebs_cookie, h1, o1, h2, o2, cnt); \
|
||||
})
|
||||
|
||||
/*
|
||||
* Create/destroy default bus_space tag.
|
||||
*/
|
||||
int bus_space_create(bus_space_tag_t, const char *, bus_addr_t, bus_size_t);
|
||||
void bus_space_destroy(bus_space_tag_t);
|
||||
|
||||
/*
|
||||
* Mapping and unmapping operations.
|
||||
*/
|
||||
#define bus_space_map(t, a, s, f, hp) \
|
||||
(*(t)->ebs_map)((t)->ebs_cookie, (a), (s), (f), (hp))
|
||||
#define bus_space_unmap(t, h, s) \
|
||||
(*(t)->ebs_unmap)((t)->ebs_cookie, (h), (s))
|
||||
#define bus_space_subregion(t, h, o, s, hp) \
|
||||
(*(t)->ebs_subregion)((t)->ebs_cookie, (h), (o), (s), (hp))
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#define BUS_SPACE_MAP_CACHEABLE 0x01
|
||||
#define BUS_SPACE_MAP_LINEAR 0x02
|
||||
#define BUS_SPACE_MAP_PREFETCHABLE 0x04
|
||||
|
||||
#ifdef _KERNEL
|
||||
/*
|
||||
* Allocation and deallocation operations.
|
||||
*/
|
||||
#define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \
|
||||
(*(t)->ebs_alloc)((t)->ebs_cookie, (rs), (re), (s), (a), (b), \
|
||||
(f), (ap), (hp))
|
||||
#define bus_space_free(t, h, s) \
|
||||
(*(t)->ebs_free)((t)->ebs_cookie, (h), (s))
|
||||
|
||||
/*
|
||||
* Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR.
|
||||
*/
|
||||
#define bus_space_vaddr(t, h) \
|
||||
(*(t)->ebs_vaddr)((t)->ebs_cookie, (h))
|
||||
|
||||
/*
|
||||
* Bus barrier operations. The ews4800mips does not currently require
|
||||
* barriers, but we must provide the flags to MI code.
|
||||
*/
|
||||
#define bus_space_barrier(t, h, o, l, f) \
|
||||
({ \
|
||||
wbflush(); \
|
||||
})
|
||||
|
||||
|
||||
#define BUS_SPACE_BARRIER_READ 0x01
|
||||
#define BUS_SPACE_BARRIER_WRITE 0x02
|
||||
|
||||
|
||||
/*
|
||||
* Bus read (single) operations.
|
||||
*/
|
||||
#define bus_space_read_1(t, h, o) __ebs_rs(1,uint8_t,(t),(h),(o))
|
||||
#define bus_space_read_2(t, h, o) __ebs_rs(2,uint16_t,(t),(h),(o))
|
||||
#define bus_space_read_4(t, h, o) __ebs_rs(4,uint32_t,(t),(h),(o))
|
||||
#define bus_space_read_8(t, h, o) __ebs_rs(8,uint64_t,(t),(h),(o))
|
||||
|
||||
|
||||
/*
|
||||
* Bus read multiple operations.
|
||||
*/
|
||||
#define bus_space_read_multi_1(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rm,1,uint8_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_multi_2(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rm,2,uint16_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_multi_4(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rm,4,uint32_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_multi_8(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rm,8,uint64_t,(t),(h),(o),(a),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Bus read region operations.
|
||||
*/
|
||||
#define bus_space_read_region_1(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rr,1,uint8_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_region_2(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rr,2,uint16_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_region_4(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rr,4,uint32_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_read_region_8(t, h, o, a, c) \
|
||||
__ebs_nonsingle(rr,8,uint64_t,(t),(h),(o),(a),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Bus write (single) operations.
|
||||
*/
|
||||
#define bus_space_write_1(t, h, o, v) __ebs_ws(1,uint8_t,(t),(h),(o),(v))
|
||||
#define bus_space_write_2(t, h, o, v) __ebs_ws(2,uint16_t,(t),(h),(o),(v))
|
||||
#define bus_space_write_4(t, h, o, v) __ebs_ws(4,uint32_t,(t),(h),(o),(v))
|
||||
#define bus_space_write_8(t, h, o, v) __ebs_ws(8,uint64_t,(t),(h),(o),(v))
|
||||
|
||||
|
||||
/*
|
||||
* Bus write multiple operations.
|
||||
*/
|
||||
#define bus_space_write_multi_1(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wm,1,uint8_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_multi_2(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wm,2,uint16_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_multi_4(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wm,4,uint32_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_multi_8(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wm,8,uint64_t,(t),(h),(o),(a),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Bus write region operations.
|
||||
*/
|
||||
#define bus_space_write_region_1(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wr,1,uint8_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_region_2(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wr,2,uint16_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_region_4(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wr,4,uint32_t,(t),(h),(o),(a),(c))
|
||||
#define bus_space_write_region_8(t, h, o, a, c) \
|
||||
__ebs_nonsingle(wr,8,uint64_t,(t),(h),(o),(a),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Set multiple operations.
|
||||
*/
|
||||
#define bus_space_set_multi_1(t, h, o, v, c) \
|
||||
__ebs_set(sm,1,uint8_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_multi_2(t, h, o, v, c) \
|
||||
__ebs_set(sm,2,uint16_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_multi_4(t, h, o, v, c) \
|
||||
__ebs_set(sm,4,uint32_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_multi_8(t, h, o, v, c) \
|
||||
__ebs_set(sm,8,uint64_t,(t),(h),(o),(v),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Set region operations.
|
||||
*/
|
||||
#define bus_space_set_region_1(t, h, o, v, c) \
|
||||
__ebs_set(sr,1,uint8_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_region_2(t, h, o, v, c) \
|
||||
__ebs_set(sr,2,uint16_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_region_4(t, h, o, v, c) \
|
||||
__ebs_set(sr,4,uint32_t,(t),(h),(o),(v),(c))
|
||||
#define bus_space_set_region_8(t, h, o, v, c) \
|
||||
__ebs_set(sr,8,uint64_t,(t),(h),(o),(v),(c))
|
||||
|
||||
|
||||
/*
|
||||
* Copy region operations.
|
||||
*/
|
||||
#define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
|
||||
__ebs_copy(1, uint8_t, (t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
|
||||
__ebs_copy(2, uint16_t, (t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
|
||||
__ebs_copy(4, uint32_t, (t), (h1), (o1), (h2), (o2), (c))
|
||||
#define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
|
||||
__ebs_copy(8, uint64_t, (t), (h1), (o1), (h2), (o2), (c))
|
||||
|
||||
/*
|
||||
* Bus stream operations--defined in terms of non-stream counterparts
|
||||
*/
|
||||
#define __BUS_SPACE_HAS_STREAM_METHODS 1
|
||||
#define bus_space_read_stream_1 bus_space_read_1
|
||||
#define bus_space_read_stream_2 bus_space_read_2
|
||||
#define bus_space_read_stream_4 bus_space_read_4
|
||||
#define bus_space_read_stream_8 bus_space_read_8
|
||||
#define bus_space_read_multi_stream_1 bus_space_read_multi_1
|
||||
#define bus_space_read_multi_stream_2 bus_space_read_multi_2
|
||||
#define bus_space_read_multi_stream_4 bus_space_read_multi_4
|
||||
#define bus_space_read_multi_stream_8 bus_space_read_multi_8
|
||||
#define bus_space_read_region_stream_1 bus_space_read_region_1
|
||||
#define bus_space_read_region_stream_2 bus_space_read_region_2
|
||||
#define bus_space_read_region_stream_4 bus_space_read_region_4
|
||||
#define bus_space_read_region_stream_8 bus_space_read_region_8
|
||||
#define bus_space_write_stream_1 bus_space_write_1
|
||||
#define bus_space_write_stream_2 bus_space_write_2
|
||||
#define bus_space_write_stream_4 bus_space_write_4
|
||||
#define bus_space_write_stream_8 bus_space_write_8
|
||||
#define bus_space_write_multi_stream_1 bus_space_write_multi_1
|
||||
#define bus_space_write_multi_stream_2 bus_space_write_multi_2
|
||||
#define bus_space_write_multi_stream_4 bus_space_write_multi_4
|
||||
#define bus_space_write_multi_stream_8 bus_space_write_multi_8
|
||||
#define bus_space_write_region_stream_1 bus_space_write_region_1
|
||||
#define bus_space_write_region_stream_2 bus_space_write_region_2
|
||||
#define bus_space_write_region_stream_4 bus_space_write_region_4
|
||||
#define bus_space_write_region_stream_8 bus_space_write_region_8
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
/*
|
||||
* Flags used in various bus DMA methods.
|
||||
*/
|
||||
#define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
|
||||
#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
|
||||
#define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
|
||||
#define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS2 0x020
|
||||
#define BUS_DMA_BUS3 0x040
|
||||
#define BUS_DMA_BUS4 0x080
|
||||
#define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
|
||||
#define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
|
||||
#define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
|
||||
|
||||
#define EWS4800MIPS_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
|
||||
|
||||
/* Forwards needed by prototypes below. */
|
||||
struct mbuf;
|
||||
struct uio;
|
||||
|
||||
/*
|
||||
* Operations performed by bus_dmamap_sync().
|
||||
*/
|
||||
#define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
|
||||
#define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
|
||||
#define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
|
||||
#define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
|
||||
|
||||
typedef struct ews4800mips_bus_dma_tag *bus_dma_tag_t;
|
||||
typedef struct ews4800mips_bus_dmamap *bus_dmamap_t;
|
||||
|
||||
#define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
|
||||
|
||||
/*
|
||||
* bus_dma_segment_t
|
||||
*
|
||||
* Describes a single contiguous DMA transaction. Values
|
||||
* are suitable for programming into DMA registers.
|
||||
*/
|
||||
struct ews4800mips_bus_dma_segment {
|
||||
bus_addr_t ds_addr; /* DMA address */
|
||||
bus_size_t ds_len; /* length of transfer */
|
||||
bus_addr_t _ds_vaddr; /* virtual address, 0 if invalid */
|
||||
};
|
||||
typedef struct ews4800mips_bus_dma_segment bus_dma_segment_t;
|
||||
|
||||
/*
|
||||
* bus_dma_tag_t
|
||||
*
|
||||
* A machine-dependent opaque type describing the implementation of
|
||||
* DMA for a given bus.
|
||||
*/
|
||||
|
||||
struct ews4800mips_bus_dma_tag {
|
||||
/*
|
||||
* DMA mapping methods.
|
||||
*/
|
||||
int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int,
|
||||
bus_size_t, bus_size_t, int, bus_dmamap_t *);
|
||||
void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t);
|
||||
int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *,
|
||||
bus_size_t, struct proc *, int);
|
||||
int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
|
||||
struct mbuf *, int);
|
||||
int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t,
|
||||
struct uio *, int);
|
||||
int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t,
|
||||
bus_dma_segment_t *, int, bus_size_t, int);
|
||||
void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
|
||||
void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
|
||||
bus_addr_t, bus_size_t, int);
|
||||
|
||||
/*
|
||||
* DMA memory utility functions.
|
||||
*/
|
||||
int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t,
|
||||
bus_size_t, bus_dma_segment_t *, int, int *, int);
|
||||
void (*_dmamem_free)(bus_dma_tag_t,
|
||||
bus_dma_segment_t *, int);
|
||||
int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *,
|
||||
int, size_t, caddr_t *, int);
|
||||
void (*_dmamem_unmap)(bus_dma_tag_t, caddr_t, size_t);
|
||||
paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *,
|
||||
int, off_t, int, int);
|
||||
|
||||
/*
|
||||
* DMA controller private.
|
||||
*/
|
||||
void *_dmachip_cookie;
|
||||
};
|
||||
|
||||
#define bus_dmamap_create(t, s, n, m, b, f, p) \
|
||||
(*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
|
||||
#define bus_dmamap_destroy(t, p) \
|
||||
(*(t)->_dmamap_destroy)((t), (p))
|
||||
#define bus_dmamap_load(t, m, b, s, p, f) \
|
||||
(*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
|
||||
#define bus_dmamap_load_mbuf(t, m, b, f) \
|
||||
(*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
|
||||
#define bus_dmamap_load_uio(t, m, u, f) \
|
||||
(*(t)->_dmamap_load_uio)((t), (m), (u), (f))
|
||||
#define bus_dmamap_load_raw(t, m, sg, n, s, f) \
|
||||
(*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
|
||||
#define bus_dmamap_unload(t, p) \
|
||||
(*(t)->_dmamap_unload)((t), (p))
|
||||
#define bus_dmamap_sync(t, p, o, l, ops) \
|
||||
(*(t)->_dmamap_sync)((t), (p), (o), (l), (ops))
|
||||
|
||||
#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
|
||||
(*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
|
||||
#define bus_dmamem_free(t, sg, n) \
|
||||
(*(t)->_dmamem_free)((t), (sg), (n))
|
||||
#define bus_dmamem_map(t, sg, n, s, k, f) \
|
||||
(*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
|
||||
#define bus_dmamem_unmap(t, k, s) \
|
||||
(*(t)->_dmamem_unmap)((t), (k), (s))
|
||||
#define bus_dmamem_mmap(t, sg, n, o, p, f) \
|
||||
(*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
|
||||
|
||||
/*
|
||||
* bus_dmamap_t
|
||||
*
|
||||
* Describes a DMA mapping.
|
||||
*/
|
||||
struct ews4800mips_bus_dmamap {
|
||||
/*
|
||||
* PRIVATE MEMBERS: not for use my machine-independent code.
|
||||
*/
|
||||
bus_size_t _dm_size; /* largest DMA transfer mappable */
|
||||
int _dm_segcnt; /* number of segs this map can map */
|
||||
bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
|
||||
bus_size_t _dm_boundary; /* don't cross this */
|
||||
int _dm_flags; /* misc. flags */
|
||||
|
||||
/*
|
||||
* PUBLIC MEMBERS: these are used by machine-independent code.
|
||||
*/
|
||||
bus_size_t dm_maxsegsz; /* largest possible segment */
|
||||
bus_size_t dm_mapsize; /* size of the mapping */
|
||||
int dm_nsegs; /* # valid segments in mapping */
|
||||
bus_dma_segment_t dm_segs[1]; /* segments; variable length */
|
||||
};
|
||||
|
||||
#ifdef _EWS4800MIPS_BUS_DMA_PRIVATE
|
||||
int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
|
||||
bus_size_t, int, bus_dmamap_t *);
|
||||
void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
|
||||
int _bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
|
||||
bus_size_t, struct proc *, int);
|
||||
int _bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
|
||||
struct mbuf *, int);
|
||||
int _bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
|
||||
struct uio *, int);
|
||||
int _bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
|
||||
bus_dma_segment_t *, int, bus_size_t, int);
|
||||
void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
|
||||
void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
|
||||
bus_size_t, int);
|
||||
|
||||
int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
|
||||
bus_size_t alignment, bus_size_t boundary,
|
||||
bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
|
||||
void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
|
||||
int nsegs);
|
||||
int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
|
||||
int nsegs, size_t size, caddr_t *kvap, int flags);
|
||||
void _bus_dmamem_unmap(bus_dma_tag_t tag, caddr_t kva,
|
||||
size_t size);
|
||||
paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
|
||||
int nsegs, off_t off, int prot, int flags);
|
||||
|
||||
int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
|
||||
bus_size_t alignment, bus_size_t boundary,
|
||||
bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
|
||||
vaddr_t low, vaddr_t high);
|
||||
|
||||
extern struct ews4800mips_bus_dma_tag ews4800mips_default_bus_dma_tag;
|
||||
#endif /* _EWS4800MIPS_BUS_DMA_PRIVATE */
|
||||
|
||||
#endif /* _EWS4800MIPS_BUS_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: cdefs.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/cdefs.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: cpu.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/cpu.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: cpu_counter.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/cpu_counter.h>
|
|
@ -0,0 +1,13 @@
|
|||
/* $NetBSD: db_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/db_machdep.h>
|
||||
|
||||
#define DB_ELF_SYMBOLS
|
||||
#define DB_ELFSIZE 32
|
||||
#ifdef DDB
|
||||
void __db_print_symbol(db_expr_t);
|
||||
#define DB_PRINT_CALLER() \
|
||||
__db_print_symbol((db_expr_t)__builtin_return_address(0))
|
||||
#else
|
||||
#define DB_PRINT_CALLER() ((void)0)
|
||||
#endif
|
|
@ -0,0 +1,85 @@
|
|||
/* $NetBSD: disklabel.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_DISKLABEL_H_
|
||||
#define _EWS4800MIPS_DISKLABEL_H_
|
||||
|
||||
#if HAVE_NBTOOL_CONFIG_H
|
||||
#include <nbinclude/machine/pdinfo.h>
|
||||
#include <nbinclude/machine/vtoc.h>
|
||||
#else
|
||||
#include <machine/pdinfo.h>
|
||||
#include <machine/vtoc.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* UX reserved partition
|
||||
* 0 /
|
||||
* 1 swap
|
||||
* 2 /usr
|
||||
* 3 /stand (bfs)
|
||||
* 6 whole disk
|
||||
* 7 boot block (VTOC)
|
||||
* 8 /var
|
||||
* 9 /home
|
||||
*/
|
||||
|
||||
#define MAXPARTITIONS 16
|
||||
/* 'p'-partition is mostly familiar with EWS-UX */
|
||||
#define RAW_PART 15
|
||||
|
||||
#define LABELSECTOR 9 /* See ews4800mips/disksubr/disksubr_conv.c */
|
||||
#define LABELOFFSET 0
|
||||
|
||||
struct cpu_disklabel {
|
||||
/* EWS-UX native disklabel */
|
||||
struct pdinfo_sector pdinfo;
|
||||
struct vtoc_sector vtoc;
|
||||
};
|
||||
|
||||
#if defined(_KERNEL)
|
||||
/* VTOC <-> disklabel conversion ops. */
|
||||
struct disklabel;
|
||||
void vtoc_set_default(struct cpu_disklabel *, struct disklabel *);
|
||||
void disklabel_to_vtoc(struct cpu_disklabel *, struct disklabel *);
|
||||
void vtoc_to_disklabel(struct cpu_disklabel *, struct disklabel *);
|
||||
void disklabel_set_default(struct disklabel *);
|
||||
boolean_t disklabel_sanity(struct disklabel *);
|
||||
#endif
|
||||
|
||||
#endif /* _EWS4800MIPS_DISKLABEL_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ecoff_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/ecoff_machdep.h>
|
|
@ -0,0 +1,5 @@
|
|||
/* $NetBSD: elf_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/elf_machdep.h>
|
||||
|
||||
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: endian.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <sys/endian.h>
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: endian_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#define _BYTE_ORDER _BIG_ENDIAN
|
||||
#include <mips/endian_machdep.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: float.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/float.h>
|
|
@ -0,0 +1,109 @@
|
|||
/* $NetBSD: gareg.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_GAREG_H_
|
||||
#define _EWS4800MIPS_GAREG_H_
|
||||
/* Graphic adapter */
|
||||
|
||||
#define GA_FRB_ADDR 0xf0000000
|
||||
#define GA_FRB_SIZE 0x08000000
|
||||
#define GA_ROM_ADDR 0xf7e00000 /* 350 */
|
||||
#define GA_BLOCKWRITE_ADDR 0xf0c00000
|
||||
#define GA_PLANEMASK_ADDR 0xf1000000
|
||||
#define GA_OVLMASK_ADDR 0xf2000000
|
||||
#define GA_ID_ADDR 0xf3000000
|
||||
#define GA_REG_ADDR 0xf5f00000
|
||||
#define GA_REG_SIZE 0x4000
|
||||
|
||||
/* Register (offset from GA_REG_ADDR) */
|
||||
|
||||
#define GA_PLANEMASK_REG 0x0400 /* write only */
|
||||
#define GA_PLANEMASK_R 0x0000ff
|
||||
#define GA_PLANEMASK_G 0x00ff00
|
||||
#define GA_PLANEMASK_B 0xff0000
|
||||
|
||||
#define GA_DDA_PATTERN_DRAW_ADDR_LO 0x0900
|
||||
#define GA_DDA_PATTERN_DRAW_ADDR_HI 0x0904
|
||||
#define GA_DDA_PATTERN_DRAW_DATA 0x093c /* data? */
|
||||
|
||||
#define GA_BT463_ADDR_LO 0x0c80
|
||||
#define GA_BT463_ADDR_HI 0x0c84
|
||||
#define GA_BT463_IREG_DATA 0x0c88
|
||||
#define GA_BT463_CLUT_DATA 0x0c8c
|
||||
#define GA_BT431_BADDR_LO 0x0c90
|
||||
#define GA_BT431_BADDR_HI 0x0c94
|
||||
#define GA_BT431_BDATA 0x0c98
|
||||
#define GA_BT431_CADDR_LO 0x0ca0
|
||||
#define GA_BT431_CADDR_HI 0x0ca4
|
||||
#define GA_BT431_CDATA 0x0ca8
|
||||
|
||||
#define GA_STATUS_REG 0x0e00
|
||||
#define GA_STATUS_VSYNC 0x1
|
||||
#define GA_STATUS_CLOCK 0x2
|
||||
#define GA_STATUS_CLOCK_60HZ 0
|
||||
#define GA_STATUS_CLOCK_71HZ 2
|
||||
|
||||
#define GA_CLOCK_REG 0x0e08 /* write only */
|
||||
#define GA_CLOCK_60HZ 0x670
|
||||
#define GA_CLOCK_71HZ 0x790
|
||||
#define GA_BLOCKPLANEMASK_REG 0x0e80
|
||||
|
||||
#define GA_DDA_STATUS_REG 0x0f00
|
||||
|
||||
#if 0
|
||||
#define GA_ROP_ 0x0000
|
||||
#define GA_ROP_ 0x0002
|
||||
#define GA_ROP_ 0x0004
|
||||
#define GA_ROP_ 0x1000
|
||||
#define GA_ROP_ 0x1002
|
||||
#define GA_ROP_ 0x1004
|
||||
#define GA_ROP_ 0x2000
|
||||
#define GA_ROP_ 0x2002
|
||||
#define GA_ROP_ 0x2004
|
||||
|
||||
#define GA_ 0x0006
|
||||
#define GA_ 0x0008
|
||||
#define GA_ 0x000a
|
||||
#define GA_ 0x000c
|
||||
#define GA_ 0x000e
|
||||
#define GA_ 0x0010
|
||||
#define GA_ 0x0012
|
||||
#define GA_ 0x0020
|
||||
#endif
|
||||
|
||||
#endif /* !_EWS4800MIPS_GAREG_H_ */
|
|
@ -0,0 +1,54 @@
|
|||
/* $NetBSD: gavar.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_GAVAR_H_
|
||||
#define _EWS4800MIPS_GAVAR_H_
|
||||
|
||||
struct ga {
|
||||
uint32_t reg_addr;
|
||||
uint32_t reg_paddr;
|
||||
int flags;
|
||||
uint8_t clut[256][3];
|
||||
};
|
||||
boolean_t ga_init(struct ga *);
|
||||
void ga_clut_get(struct ga *);
|
||||
void ga_clut_set(const struct ga *);
|
||||
|
||||
void ga_plane_mask_test(const struct ga *);
|
||||
|
||||
#endif /* _EWS4800MIPS_GAVAR_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ieee.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/ieee.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ieeefp.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/ieeefp.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: int_const.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/int_const.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: int_fmtio.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/int_fmtio.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: int_limits.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/int_limits.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: int_mwgwtypes.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/int_mwgwtypes.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: int_types.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/int_types.h>
|
|
@ -0,0 +1,124 @@
|
|||
/* $NetBSD: intr.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000, 2001, 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jason R. Thorpe.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_INTR_H_
|
||||
#define _EWS4800MIPS_INTR_H_
|
||||
|
||||
#include <sys/device.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define IPL_NONE 0 /* disable only this interrupt */
|
||||
|
||||
#define IPL_SOFT 1 /* generic software interrupts (SI 0) */
|
||||
#define IPL_SOFTCLOCK 2 /* clock software interrupts (SI 0) */
|
||||
#define IPL_SOFTNET 3 /* network software interrupts (SI 1) */
|
||||
#define IPL_SOFTSERIAL 4 /* serial software interrupts (SI 1) */
|
||||
|
||||
#define IPL_BIO 5 /* disable block I/O interrupts */
|
||||
#define IPL_NET 6 /* disable network interrupts */
|
||||
#define IPL_TTY 7 /* disable terminal interrupts */
|
||||
#define IPL_SERIAL 7 /* disable serial interrupts */
|
||||
#define IPL_CLOCK 8 /* disable clock interrupts */
|
||||
#define IPL_HIGH 8 /* disable all interrupts */
|
||||
|
||||
#define _IPL_NSOFT 4
|
||||
#define _IPL_N 9
|
||||
|
||||
#define _IPL_SI0_FIRST IPL_SOFT
|
||||
#define _IPL_SI0_LAST IPL_SOFTCLOCK
|
||||
|
||||
#define _IPL_SI1_FIRST IPL_SOFTNET
|
||||
#define _IPL_SI1_LAST IPL_SOFTSERIAL
|
||||
|
||||
#define IPL_SOFTNAMES { \
|
||||
"misc", \
|
||||
"clock", \
|
||||
"net", \
|
||||
"serial", \
|
||||
}
|
||||
|
||||
#define IST_UNUSABLE -1 /* interrupt cannot be used */
|
||||
#define IST_NONE 0 /* none (dummy) */
|
||||
#define IST_PULSE 1 /* pulsed */
|
||||
#define IST_EDGE 2 /* edge-triggered */
|
||||
#define IST_LEVEL 3 /* level-triggered */
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
extern const uint32_t *ipl_sr_bits;
|
||||
extern const uint32_t ipl_si_to_sr[_IPL_NSOFT];
|
||||
|
||||
extern int _splraise(int);
|
||||
extern int _spllower(int);
|
||||
extern int _splset(int);
|
||||
extern int _splget(int);
|
||||
extern int _splnone(int);
|
||||
extern int _setsoftintr(int);
|
||||
extern int _clrsoftintr(int);
|
||||
|
||||
#define splhigh() _splraise(ipl_sr_bits[IPL_HIGH])
|
||||
#define spl0() (void) _spllower(0)
|
||||
#define splx(s) (void) _splset(s)
|
||||
#define splbio() _splraise(ipl_sr_bits[IPL_BIO])
|
||||
#define splnet() _splraise(ipl_sr_bits[IPL_NET])
|
||||
#define spltty() _splraise(ipl_sr_bits[IPL_TTY])
|
||||
#define splserial() _splraise(ipl_sr_bits[IPL_SERIAL])
|
||||
#define splvm() spltty()
|
||||
#define splclock() _splraise(ipl_sr_bits[IPL_CLOCK])
|
||||
#define splstatclock() splclock()
|
||||
|
||||
#define splsched() splclock()
|
||||
#define spllock() splhigh()
|
||||
#define spllpt() spltty()
|
||||
|
||||
#define splsoft() _splraise(ipl_sr_bits[IPL_SOFT])
|
||||
#define splsoftclock() _splraise(ipl_sr_bits[IPL_SOFTCLOCK])
|
||||
#define splsoftnet() _splraise(ipl_sr_bits[IPL_SOFTNET])
|
||||
#define splsoftserial() _splraise(ipl_sr_bits[IPL_SOFTSERIAL])
|
||||
|
||||
#define spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
|
||||
|
||||
void intr_init(void);
|
||||
void intr_establish(int, int (*)(void *), void *);
|
||||
void intr_disestablish(void *);
|
||||
|
||||
#include <mips/softintr.h>
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_EWS4800MIPS_INTR_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: kcore.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/kcore.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: kdbparam.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/kdbparam.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: limits.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/limits.h>
|
|
@ -0,0 +1,61 @@
|
|||
/* $NetBSD: loadfile_machdep.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_LOADFILE_MACHDEP_H_
|
||||
#define _EWS4800MIPS_LOADFILE_MACHDEP_H_
|
||||
|
||||
#define BOOT_ELF32
|
||||
#define BOOT_ECOFF
|
||||
|
||||
#define LOAD_KERNEL (LOAD_ALL & ~LOAD_TEXTA)
|
||||
#define COUNT_KERNEL (COUNT_ALL & ~COUNT_TEXTA)
|
||||
|
||||
#define LOADADDR(a) (((uint32_t)(a)) + offset)
|
||||
#define ALIGNENTRY(a) ((uint32_t)(a))
|
||||
#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c))
|
||||
#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c))
|
||||
#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c))
|
||||
#define WARN(a) (void)(printf a, \
|
||||
printf((errno ? ": %s\n" : "\n"), \
|
||||
strerror(errno)))
|
||||
#define PROGRESS(a) (void) printf a
|
||||
#define ALLOC(a) alloc(a)
|
||||
#define FREE(a, b) free(a, b)
|
||||
#define OKMAGIC(a) ((a) == OMAGIC)
|
||||
|
||||
#endif /* !_EWS4800MIPS_LOADFILE_MACHDEP_H_ */
|
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: lock.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/* Just use the common mips definition */
|
||||
#include <mips/lock.h>
|
|
@ -0,0 +1,20 @@
|
|||
/* $NetBSD: locore.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#ifndef _EWS4800MIPS_LOCORE_H_
|
||||
#define _EWS4800MIPS_LOCORE_H_
|
||||
|
||||
#include <mips/locore.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifndef _LOCORE
|
||||
void ews4800mips_nmi_vec(void);
|
||||
|
||||
void rom_putc(int, int, int);
|
||||
int rom_getc(void);
|
||||
void rom_ipl(void);
|
||||
void rom_poweroff(void);
|
||||
#endif /* !_LOCORE */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_EWS4800MIPS_LOCORE_H_ */
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: math.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/math.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: mcontext.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/mcontext.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: mips_opcode.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/mips_opcode.h>
|
|
@ -0,0 +1,127 @@
|
|||
/* $NetBSD: param.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department and Ralph Campbell.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1988 University of Utah.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* the Systems Programming Group of the University of Utah Computer
|
||||
* Science Department and Ralph Campbell.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_PARAM_H_
|
||||
#define _EWS4800MIPS_PARAM_H_
|
||||
|
||||
#include <mips/mips_param.h>
|
||||
|
||||
#define _MACHINE_ARCH mipseb
|
||||
#define MACHINE_ARCH "mipseb"
|
||||
#define _MACHINE ews4800mips
|
||||
#define MACHINE "ews4800mips"
|
||||
#define MID_MACHINE MID_MIPS
|
||||
|
||||
#define DEV_BSIZE 512
|
||||
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
|
||||
#define BLKDEV_IOSIZE 2048
|
||||
#define MAXPHYS (64 * 1024) /* Maximum raw I/O transfer size */
|
||||
|
||||
/*
|
||||
* Constants related to network buffer management.
|
||||
* MCLBYTES must be no larger than NBPG (the software page size), and,
|
||||
* on machines that exchange pages of input or output buffers with mbuf
|
||||
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
|
||||
* of the hardware page size.
|
||||
*/
|
||||
#define MSIZE 256 /* size of an mbuf */
|
||||
|
||||
#ifndef MCLSHIFT
|
||||
#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
|
||||
/* 2K cluster can hold Ether frame */
|
||||
#endif /* MCLSHIFT */
|
||||
|
||||
#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
|
||||
|
||||
#ifndef NMBCLUSTERS
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_gateway.h"
|
||||
#endif
|
||||
|
||||
#ifdef GATEWAY
|
||||
#define NMBCLUSTERS 2048 /* Map size, max cluster allocation */
|
||||
#else
|
||||
#define NMBCLUSTERS 1024 /* Map size, max cluster allocation */
|
||||
#endif
|
||||
#endif /* !NMBCLUSTERS */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifndef _LOCORE
|
||||
|
||||
extern void delay(unsigned);
|
||||
#define DELAY(n) delay(n)
|
||||
|
||||
/* provide spl*() */
|
||||
#include <machine/intr.h>
|
||||
|
||||
#endif /* !_LOCORE */
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_EWS4800MIPS_PARAM_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: pcb.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/pcb.h>
|
|
@ -0,0 +1,90 @@
|
|||
/* $NetBSD: pdinfo.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_PDINFO_H_
|
||||
#define _EWS4800MIPS_PDINFO_H_
|
||||
|
||||
/* Phisical Disk INFOrmation */
|
||||
|
||||
#define PDINFO_SECTOR 8 /* sector */
|
||||
#define PDINFO_MAGIC 0xca5e600d
|
||||
#define PDINFO_VERSION 2
|
||||
|
||||
struct disk_geometory {
|
||||
uint32_t cylinders_per_drive; /* 24 */
|
||||
uint32_t tracks_per_cylinder; /* 28 */
|
||||
uint32_t sectors_per_track; /* 32 */
|
||||
uint32_t bytes_per_sector; /* 36 */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* UX internal use */
|
||||
struct disk_ux {
|
||||
uint32_t errorlog_sector; /* 44 */
|
||||
uint32_t errorlog_size_byte; /* 48 */
|
||||
uint32_t mfg_sector; /* 52 */
|
||||
uint32_t mfg_size_byte; /* 56 */
|
||||
uint32_t defect_sector; /* 60 */
|
||||
uint32_t defect_size_byte; /* 64 */
|
||||
uint32_t n_relocation_area; /* 68 */
|
||||
uint32_t relocation_area_sector; /* 72 */
|
||||
uint32_t relocation_area_size_byte; /* 76 */
|
||||
uint32_t next_relocation_area; /* 80 */
|
||||
uint32_t diag_sector; /* 84 */
|
||||
uint32_t diag_size; /* 88 */
|
||||
uint32_t gap_size; /* 92 */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Sector image */
|
||||
struct pdinfo_sector {
|
||||
uint32_t drive_id; /* 0 */
|
||||
uint32_t magic; /* 4 */
|
||||
uint32_t version; /* 8 */
|
||||
int8_t device_serial_number[12]; /* 12 */
|
||||
struct disk_geometory geometory; /* 24 */
|
||||
uint32_t logical_sector; /* 40 */
|
||||
struct disk_ux ux; /* 44 */
|
||||
uint32_t device_depend[104]; /* 96 */
|
||||
} __attribute__((__packed__)); /* 512 byte */
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
boolean_t pdinfo_sector(void *, struct pdinfo_sector *);
|
||||
boolean_t pdinfo_sanity(const struct pdinfo_sector *);
|
||||
boolean_t pdinfo_valid(const struct pdinfo_sector *);
|
||||
#endif
|
||||
|
||||
#endif /* _EWS4800MIPS_PDINFO_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: pmap.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/pmap.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: pmc.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/pmc.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: proc.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/proc.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: profile.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/profile.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: psl.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/psl.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: pte.h,v 1.1 2005/12/29 15:20:08 tsutsui Exp $ */
|
||||
|
||||
#include <mips/pte.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: ptrace.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/ptrace.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: reg.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/reg.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: regdef.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/regdef.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: regnum.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/regnum.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: reloc.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/reloc.h>
|
|
@ -0,0 +1,136 @@
|
|||
/* $NetBSD: sbd.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_SBD_H_
|
||||
#define _EWS4800MIPS_SBD_H_
|
||||
/* System board model independ definition */
|
||||
|
||||
struct sbdinfo {
|
||||
uint32_t machine :16;
|
||||
uint32_t model :16;
|
||||
uint32_t mmu :1;
|
||||
uint32_t cache :1;
|
||||
uint32_t panel :2;
|
||||
uint32_t padding1 :12;
|
||||
uint32_t fdd :8;
|
||||
uint32_t kb :8;
|
||||
uint32_t cpu :4;
|
||||
uint32_t fpp :4;
|
||||
uint32_t fpa :4;
|
||||
uint32_t iop :4;
|
||||
uint32_t padding2 :16; /* ----350---- */
|
||||
uint32_t clock :32;
|
||||
char model_name[20];
|
||||
uint32_t padding3 :24;
|
||||
uint32_t ipl :8;
|
||||
uint32_t cpu_ex :32;
|
||||
uint32_t fpp_ex :32; /* ----360---- */
|
||||
uint32_t padding4 :16;
|
||||
uint32_t kbms :4;
|
||||
uint32_t sio :4;
|
||||
uint32_t battery :8;
|
||||
uint32_t scsi :32;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
enum sbd_machine_type {
|
||||
MACHINE_TR2 = 0x1017, /* EWS4800/350 */
|
||||
MACHINE_TR2A = 0x101f /* EWS4800/360 */
|
||||
};
|
||||
|
||||
/* Model independent ROM entries */
|
||||
#define SBD_INFO ((struct sbdinfo *)0xbfc0fe00)
|
||||
#define ROM_ADDR 0xbfc00000
|
||||
#define ROM_SIZE 0x00080000
|
||||
/* ROM_DK_RW(unit|flag, sector, count, addr) */
|
||||
#define ROM_DK_RW ((int (*)(int, uint32_t, uint32_t, void *))0xbfc0ff30)
|
||||
#define ROM_DK_READ(u, s, c, a) ROM_DK_RW(u, s, c, a)
|
||||
#define ROM_DK_WRITE(u, s, c, a) ROM_DK_RW(u | 0x1000, s, c, a)
|
||||
/* int ROM_GETC(void) */
|
||||
#define ROM_GETC ((int (*)(void))0xbfc0ff50)
|
||||
/* void ROM_PUTC(xpixel, ypixel, c) */
|
||||
#define ROM_PUTC ((void (*)(int, int, int))0xbfc0ff60)
|
||||
/* ROM_FD_RW(unit | flag, cylinder << 16 | side << 8 | sector, count, addr) */
|
||||
#define ROM_FD_RW ((int (*)(int, uint32_t, uint32_t, void *))0xbfc0ff20)
|
||||
#define ROM_FD_READ(u, s, c, a) ROM_FD_RW(u, s, c, a)
|
||||
#define ROM_FD_WRITE(u, s, c, a) ROM_FD_RW(u | 0x1000, s, c, a)
|
||||
|
||||
#define ROM_ETHER_IPL 0xbfc0ff40
|
||||
#define ROM_CGMT_READ 0xbfc0ff48
|
||||
#define ROM_PRINTF 0xbfc0ff58
|
||||
#define ROM_NETIPL 0xbfc0ff68
|
||||
|
||||
#define ROM_MONITOR ((void (*)(void))0xbfc0ff08)
|
||||
#define ROM_CPUITF 0xbfc0ff00 /* machine check */
|
||||
#define ROM_SPP 0xbfc0ff70
|
||||
#define ROM_SPPBP 0xbfc0ff78
|
||||
|
||||
#define ROM_FONT_WIDTH 12
|
||||
#define ROM_FONT_HEIGHT 24
|
||||
|
||||
/* NVSRAM */
|
||||
#define NVSRAM_BOOTDEV_MIN 0
|
||||
#define NVSRAM_BOOTDEV_FLOPPYDISK 0
|
||||
#define NVSRAM_BOOTDEV_HARDDISK 2
|
||||
#define NVSRAM_BOOTDEV_CGMT 4
|
||||
#define NVSRAM_BOOTDEV_NETWORK 6
|
||||
#define NVSRAM_BOOTDEV_NETWORK_T_AND_D 8
|
||||
#define NVSRAM_BOOTDEV_MAX 8
|
||||
|
||||
/* RAM */
|
||||
struct mainfo_type1 {
|
||||
uint32_t reserved:14,
|
||||
m8:2, m7:2, m6:2, m5:2, m4:2, m3:2, m2:2, m1:2, m0:2;
|
||||
};
|
||||
/* TR2, TR2A */
|
||||
struct mainfo_type2 {
|
||||
uint32_t m7:4, m6:4, m5:4, m4:4, m3:4, m2:4, m1:4, m0:4;
|
||||
};
|
||||
#define MA0_ADDR 0x00000000
|
||||
#define __M0_BANK0_ADDR 0x00000000
|
||||
#define __M0_BANK1_ADDR 0x04000000
|
||||
#define MA1_ADDR 0x08000000
|
||||
#define __M1_BANK0_ADDR 0x08000000
|
||||
#define __M1_BANK1_ADDR 0x0c000000
|
||||
#define MA2_ADDR 0x10000000
|
||||
#define __M2_BANK0_ADDR 0x10000000
|
||||
#define __M2_BANK1_ADDR 0x14000000
|
||||
|
||||
#define TR2A_MA3_ADDR 0x20000000
|
||||
#define TR2_MA3_ADDR 0x38000000
|
||||
|
||||
#endif /* !_EWS4800MIPS_SBD_H_ */
|
|
@ -0,0 +1,233 @@
|
|||
/* $NetBSD: sbd_tr2.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SBD_TR2_PRIVATE
|
||||
#error "Don't inlucde this file except for TR2 implemetation"
|
||||
#endif /* !_SBD_TR2_PRIVATE */
|
||||
|
||||
#ifndef _EWS4800MIPS_SBD_TR2_H_
|
||||
#define _EWS4800MIPS_SBD_TR2_H_
|
||||
/*
|
||||
* EWS4800/350 (TR2) specific system board definition
|
||||
*/
|
||||
|
||||
/* ROM */
|
||||
#define TR2_ROM_FONT_ADDR 0xbfc0ec00
|
||||
#define TR2_ROM_FONT_SIZE ((0x7f - 0x20) * 24 * sizeof(int16_t))
|
||||
|
||||
#define TR2_ROM_KEYMAP_NORMAL ((uint8_t *)0xbfc12d6c)
|
||||
#define TR2_ROM_KEYMAP_SHIFTED ((uint8_t *)0xbfc12dec)
|
||||
#define TR2_ROM_KEYMAP_CONTROL ((uint8_t *)0xbfc12e6c)
|
||||
#define TR2_ROM_KEYMAP_CAPSLOCK ((uint8_t *)0xbfc12eec)
|
||||
#define TR2_ROM_KBD_TYPE 0xbfc0fe04 /* [d0 00 00 01] used by kbmskbreset. */
|
||||
|
||||
#define TR2_ROM_PUTC ((void (*)(int, int, int))0xbfc04f28)
|
||||
#define TR2_ROM_GETC ((int (*)(void))0xbfc11fa0)
|
||||
|
||||
/* System board I/O devices */
|
||||
#define TR2_PICNIC_ADDR 0xbb000000
|
||||
#define TR2_KBMS_ADDR 0xbb010000
|
||||
#define TR2_SIO_ADDR 0xbb011000
|
||||
#define TR2_NVSRAM_ADDR 0xbb020000
|
||||
#define TR2_NVSRAM_SIZE 0x00004000
|
||||
#define TR2_FDC_ADDR 0xbb030000
|
||||
#define TR2_LPT_ADDR 0xbb040000
|
||||
#define TR2_SCSI_ADDR 0xbb050000
|
||||
#define TR2_ETHER_ADDR 0xbb060000
|
||||
#define TR2_MEMC_ADDR 0xbfa00000
|
||||
#define TR2_NABI_ADDR 0xbfb00000
|
||||
#define TR2_GAFB_ADDR 0xf0000000
|
||||
#define TR2_GAFB_SIZE 0x08000000
|
||||
#define TR2_GACTRL_ADDR 0xf5f00000
|
||||
#define TR2_GACTRL_SIZE 0x1000
|
||||
|
||||
#define SOFTRESET_REG ((volatile uint32_t *)0xbfb00000)
|
||||
#define POWEROFF_REG ((volatile uint8_t *)0xbb004000)
|
||||
#define UPS_STATUS_REG ((volatile uint8_t *)0xbb004008) /* mask 0xffffffbb, 0x4 */
|
||||
|
||||
#define LED_TF_REG ((volatile uint8_t *)0xbb006000) /* 0/1 (Red)*/
|
||||
#define TF_ERROR_CODE ((volatile uint8_t *)0xbb006004) /* 1-255 */
|
||||
|
||||
#define BUZZER_REG ((volatile uint8_t *)0xbb007000)
|
||||
|
||||
/* NABI */
|
||||
#define NABI0_CTRL_REG ((volatile uint32_t *)0xbfb00000)
|
||||
#define NABI1_CTRL_REG ((volatile uint32_t *)0xbfb00004)
|
||||
#define NABI2_CTRL_REG ((volatile uint32_t *)0xbfb00008)
|
||||
#define NABI0_INTR_REG ((volatile uint32_t *)0xbfb00010)
|
||||
#define NABI1_INTR_REG ((volatile uint32_t *)0xbfb00018) /* VME */
|
||||
#define NABI2_INTR_REG ((volatile uint32_t *)0xbfb0001c)
|
||||
|
||||
/*
|
||||
* PICNIC (interrupt controller)
|
||||
*/
|
||||
#define PICNIC_INT0_STATUS_REG ((volatile uint8_t *)0xbb000000)
|
||||
#define PICNIC_INT2_STATUS_REG ((volatile uint8_t *)0xbb000004)
|
||||
#define PICNIC_INT4_STATUS_REG ((volatile uint8_t *)0xbb000008)
|
||||
#define PICNIC_INT5_STATUS_REG ((volatile uint8_t *)0xbb000010)
|
||||
#define PICNIC_NMI_REG ((volatile uint8_t *)0xbb000014)
|
||||
|
||||
#define PICNIC_INT0_MASK_REG ((volatile uint8_t *)0xbb001000)
|
||||
#define PICNIC_INT2_MASK_REG ((volatile uint8_t *)0xbb001004)
|
||||
#define PICNIC_INT4_MASK_REG ((volatile uint8_t *)0xbb001008)
|
||||
#define PICNIC_INT5_MASK_REG ((volatile uint8_t *)0xbb001010)
|
||||
/* Interrupt source */
|
||||
#define PICNIC_INT_FDDLPT 0x80
|
||||
#define PICNIC_INT_ETHER 0x40
|
||||
#define PICNIC_INT_SCSI 0x20
|
||||
#define PICNIC_INT_SERIAL 0x04
|
||||
#define PICNIC_INT_KBMS 0x01
|
||||
#define PICNIC_INT_CLOCK 0x01
|
||||
/*
|
||||
* 76543210
|
||||
* ||| | +-- keyboard, mouse
|
||||
* ||| +-----serial
|
||||
* ||+--------SCSI
|
||||
* |+---------ether
|
||||
* +----------FDC, printer
|
||||
*0xbb00 UX IPL mips int
|
||||
* 1000 0x80 0x00 7 INT0
|
||||
* 1004 0x60 0x00 65 INT2
|
||||
* 1008 0x05 0x00 2 0 INT4
|
||||
* 1010 0x01 0x01 0 Clock INT5
|
||||
*/
|
||||
|
||||
/* SIO0 Z85C30 */
|
||||
#define KBD_STATUS ((volatile uint8_t *)0xbb010000)
|
||||
#define KBD_DATA ((volatile uint8_t *)0xbb010004)
|
||||
#define MOUSE_STATUS ((volatile uint8_t *)0xbb010008)
|
||||
#define MOUSE_DATA ((volatile uint8_t *)0xbb01000c)
|
||||
/* SIO1 Z85C30 */
|
||||
#define SIOA_STATUS ((volatile uint8_t *)0xbb011008)
|
||||
#define SIOA_RDATA ((volatile uint8_t *)0xbb01100c)
|
||||
#define SIOB_STATUS ((volatile uint8_t *)0xbb011000)
|
||||
#define SIOB_RDATA ((volatile uint8_t *)0xbb011004)
|
||||
|
||||
/* ETHER i82589 */
|
||||
/* read operation invokes channel attention. */
|
||||
#define ETHER_SETADDR_REG ((volatile uint32_t *)0xbb060000)
|
||||
|
||||
/* DCC (DMA controler. Parallel port and FDD use this.) */
|
||||
struct DCC {
|
||||
uint32_t addr; /* DMA address */
|
||||
uint32_t cnt; /* transfer count */
|
||||
uint32_t ctrl; /* DMA status/command */
|
||||
uint32_t drm;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* FDD uPD72065 (80track ready) */
|
||||
#define FDC_DMA ((volatile struct DCC *)0xbb030000)
|
||||
#define FDC_STATUS ((volatile uint8_t *)0xbb030010)
|
||||
#define FDC_DATA ((volatile uint8_t *)0xbb030014)
|
||||
|
||||
/* LPT */
|
||||
#define LPT_DMA (((volatile struct DCC *)0xbb040000)
|
||||
#define LPT_COUNT ((volatile uint8_t *)0xbb040010)
|
||||
#define LPT_STRR ((volatile uint8_t *)0xbb040011)
|
||||
|
||||
/* NVSRAM MK48T08B-15 (word aligned byte access) */
|
||||
/* 0, 4, 8, c */
|
||||
#define NVSRAM_SIGNATURE 0xbb020000
|
||||
/* 10, 14 18 1c */
|
||||
#define NVSRAM_MACHINEID 0xbb020010
|
||||
#define NVSRAM_ETHERADDR ((uint8_t *)0xbb021008)
|
||||
/* 2000, 2004, 2008, 200c */
|
||||
#define NVSRAM_CDUMP_ADDR ((uint8_t *)0xbb022000)
|
||||
#define NVSRAM_DUMPDEV_1XXX 0xbb022020
|
||||
#define NVSRAM_DUMPDEV_2XXX 0xbb022040
|
||||
/* 2050, 2054, 2058, 205c */
|
||||
#define NVSRAM_TF_SCRATCH_ADDR 0xbb022050
|
||||
#if 0
|
||||
/* kbd */
|
||||
#define NVSRAM_KBD??? 0xbb0220a0 /* 0x90 */
|
||||
#endif
|
||||
#define NVSRAM_TF_TESTDATA1 0xbb023000
|
||||
#define NVSRAM_TF_TESTDATA2 0xbb023004
|
||||
#define NVSRAM_KEYMAP ((uint8_t *)0xbb023014) /* scratch */
|
||||
#define NVSRAM_TF_PROGRESS ((uint8_t *)0xbb02301c)
|
||||
#define NVSRAM_BEV_ROM 32 /* Exception from ROM routine */
|
||||
|
||||
#define NVSRAM_KBDCONNECT ((uint8_t *)0xbb023010)
|
||||
#define HAS_KBD() (*NVSRAM_KBDCONNECT != 255)
|
||||
#define NVSRAM_CONSTYPE ((uint8_t *)0xbb023020)
|
||||
#define IS_FBCONS() (*NVSRAM_CONSTYPE == 0)
|
||||
#define NVSRAM_GA 0xbb023008
|
||||
#define HAS_GA 0
|
||||
#define NVSRAM_TF_RESULT_HI 0xbb023024
|
||||
#define NVSRAM_TF_RESULT_LO 0xbb023028
|
||||
#define NVSRAM_IPLMODE ((uint8_t *)0xbb02302c)
|
||||
/*
|
||||
* 0: Normal mode
|
||||
* 1: ERROR continue mode
|
||||
* 2: Details mode
|
||||
* 3: LOOP mode
|
||||
*/
|
||||
#define NVSRAM_BOOTDEV ((uint8_t *)0xbb023030)
|
||||
#define NVSRAM_BOOTUNIT ((uint8_t *)0xbb023034)
|
||||
|
||||
/* V1 is memory area information */
|
||||
#define NVSRAM_1STBOOT_ARG_V1_3 ((uint8_t *)0xbb023048) /* 24-31 */
|
||||
#define NVSRAM_1STBOOT_ARG_V1_2 ((uint8_t *)0xbb02304c) /* 16-23 */
|
||||
#define NVSRAM_1STBOOT_ARG_V1_1 ((uint8_t *)0xbb023050) /* 8 -15 */
|
||||
#define NVSRAM_1STBOOT_ARG_V1_0 ((uint8_t *)0xbb023054) /* 0 - 7 */
|
||||
#define NVSRAM_1STBOOT_ARG_V0 ((uint8_t *)0xbb023058)
|
||||
|
||||
#define NVSRAM_SIMM_3_2 ((uint8_t *)0xbb023050)
|
||||
#define NVSRAM_SIMM_1_0 ((uint8_t *)0xbb023054)
|
||||
#define SIMM_16M 0x1
|
||||
#define SIMM_32M 0x2
|
||||
|
||||
#define NVSRAM_RTCADDR ((uint8_t *)0xbb027fe0)
|
||||
|
||||
/* Graphic adapter */
|
||||
#include <machine/gareg.h>
|
||||
|
||||
/*
|
||||
* VME (350/380)
|
||||
*/
|
||||
#define VME_ADDR 0xf8000000
|
||||
#define VME_32_ADDR 0xf8000000
|
||||
#define VME_32_SIZE 0x07000000
|
||||
#define VME_BUFFER_ADDR 0xff000000
|
||||
#define VME_BUFFER_SIZE 0x00800000
|
||||
#define VME_24_ADDR 0xff800000
|
||||
#define VME_24_SIZE 0x007f0000
|
||||
#define VME_SHORTIO_ADDR 0xffff0000
|
||||
#define VME_SHORTIO_SIZE 0x00010000
|
||||
|
||||
#endif /* !_EWS4800MIPS_SBD_TR2_H_ */
|
|
@ -0,0 +1,198 @@
|
|||
/* $NetBSD: sbd_tr2a.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SBD_TR2A_PRIVATE
|
||||
#error "Don't inlucde this file except for TR2A implemetation"
|
||||
#endif /* !_SBD_TR2A_PRIVATE */
|
||||
|
||||
#ifndef _EWS4800MIPS_SBD_TR2A_H_
|
||||
#define _EWS4800MIPS_SBD_TR2A_H_
|
||||
/*
|
||||
* EWS4800/360 (TR2A) specific system board definition
|
||||
*/
|
||||
/*
|
||||
* [interrupt overview]
|
||||
*
|
||||
* +-----+
|
||||
* | CPU |
|
||||
* +--+--+
|
||||
* |
|
||||
* +----+----+-+--+----+----+
|
||||
* INT5 INT4 INT3 INT2 INT1 INT0
|
||||
* | | | | | |
|
||||
* +-+----+----+----+----+----+-+
|
||||
* | INTC |
|
||||
* | mask: 0xbe000008 |
|
||||
* | status: 0xbe000004 |
|
||||
* | clear: 0xbe000000 | +-------------------+
|
||||
* +-+----+----+----+----+----+-+ | APbus |
|
||||
* | | | | +----+---------+Lo |
|
||||
* CLOCK---+ | +----+---------+---------+Hi |
|
||||
* 0xbe4a0008 | | | | |
|
||||
* (0x80) +-+---------+---------+-+ +-------------------+
|
||||
* | ASObus |
|
||||
* | mask: 0xbe40a00c |
|
||||
* | status: 0xbe40a010 |
|
||||
* | DMA int:0xbe408000 |
|
||||
* +-+---------+---------+-+
|
||||
* | | |
|
||||
* 0xbe440000 ZS-+ | |
|
||||
* 0xbe480000 KBMS | |
|
||||
* | |
|
||||
* 0xbe500000 SCSI-A-------+ |
|
||||
* 0xbe510000 SCSI-B-------+ |
|
||||
* 0xbe400000 LANCE--------+ |
|
||||
* |
|
||||
* NMI-------------------------+
|
||||
*
|
||||
* [INTC interrupt mask] 0xbe000008
|
||||
* 0x80000000 INT5
|
||||
* 0x04000000 INT4
|
||||
* 0x00200000 INT3
|
||||
* 0x00010000 INT2
|
||||
* 0x00000800 INT1
|
||||
* 0x00000020 INT0
|
||||
*
|
||||
* [ASObus interrupt mask] 0xbe40a00c
|
||||
* TR2A
|
||||
* 0x00800000 INT4 -
|
||||
* 0x00400000 INT4 -
|
||||
* 0x00300010 INT4 ZS
|
||||
* 0x00000040 INT4 KBMS
|
||||
* 0x00000020 INT4 -
|
||||
* 0x00000100 INT2 simd2 A
|
||||
* 0x00000200 INT2 simd2 B
|
||||
* 0x00000001 INT2 limd2
|
||||
* 0x00008000 INT0 NMI
|
||||
* 0x00000008 INT0 -
|
||||
* 0x00000004 INT0 -
|
||||
* 0x00f0837d 0x00300351
|
||||
*/
|
||||
|
||||
/* ROM */
|
||||
#define TR2A_ROM_FONT_ADDR 0xbfc0ec00
|
||||
#define TR2A_SCSIROM_ADDR 0xbfc80000
|
||||
#define TR2A_GAROM_ADDR 0xbfc82000
|
||||
|
||||
#define TR2A_ROM_KEYMAP_NORMAL ((uint8_t *)0xbfc39140)
|
||||
#define TR2A_ROM_KEYMAP_SHIFTED ((uint8_t *)0xbfc38e40)
|
||||
#define TR2A_ROM_KEYMAP_CONTROL ((uint8_t *)0xbfc38ec0)
|
||||
#define TR2A_ROM_KEYMAP_CAPSLOCK ((uint8_t *)0xbfc39040)
|
||||
|
||||
/* System board I/O devices */
|
||||
#define TR2A_IOBASE_ADDR 0xbe000000
|
||||
#define TR2A_LANCE_BASE 0xbe400000 /* Ether AM79C90 */
|
||||
#define TR2A_SIO_BASE 0xbe440000 /* SIO1 85230 */
|
||||
#define TR2A_KBMS_BASE 0xbe480000 /* SIO0 85230 */
|
||||
#define TR2A_NVSRAM_BASE 0xbe490000 /* NVSRAM */
|
||||
#define TR2A_SCSIA_BASE 0xbe500000 /* SCSI-A NCR53C710 */
|
||||
#define TR2A_SCSIB_BASE 0xbe510000 /* SCSI-B NCR53C710 */
|
||||
#if 0
|
||||
#define TR2A_FDC_BASE 0xbe420000
|
||||
#define TR2A_LPT_BASE 0xbe430000
|
||||
#define TR2A_APBUS_INTC_MASK 0xbe806000
|
||||
#define TR2A_VMECHK 0xbe000040
|
||||
#define TR2A_CLK 0xbe000024
|
||||
#endif
|
||||
|
||||
/* APbus */
|
||||
#define TR2A_APBUS_ADDR 0xe0000000
|
||||
#define TR2A_APBUS_SIZE 0x18000000
|
||||
|
||||
/* NVSRAM */
|
||||
#define TR2A_NVSRAM_ADDR 0xbe490000
|
||||
#define NVSRAM_SIGNATURE 0xbe490000
|
||||
#define NVSRAM_MACHINEID 0xbe490010
|
||||
#define NVSRAM_ETHERADDR 0xbe491008
|
||||
#define NVSRAM_TF_PROGRESS 0xbe493010
|
||||
#define NVSRAM_TF_ERROR 0xbe493028
|
||||
#define NVSRAM_BOOTDEV ((uint8_t *)0xbe493030)
|
||||
#define NVSRAM_CONSTYPE ((uint8_t *)0xbe4932a0)
|
||||
#define NVSRAM_BOOTUNIT 0xbe493414
|
||||
#define NVSRAM_SBDINIT_0 0xbe493450
|
||||
#define NVSRAM_SBDINIT_1 0xbe493454
|
||||
#define NVSRAM_SBDINIT_2 0xbe493458
|
||||
#define NVSRAM_SBDINIT_3 0xbe49345c
|
||||
|
||||
/* Frame buffer */
|
||||
#define TR2A_GAFB_ADDR 0xf0000000
|
||||
#define TR2A_GAFB_SIZE 0x04000000
|
||||
#define TR2A_GAREG_ADDR 0xf5f00000
|
||||
#define TR2A_GAREG_SIZE 0x00001000
|
||||
|
||||
#define SOFTRESET_REG ((volatile uint8_t *)0xba000004)
|
||||
#define SOFTRESET_FLAG ((volatile uint32_t *)0xbe000064)
|
||||
|
||||
#define CLOCK_REG ((volatile uint8_t *)0xbe4a0008)
|
||||
#define POWEROFF_REG ((volatile uint8_t *)0xbe4a0030)
|
||||
#define LED_TF_REG ((volatile uint8_t *)0xbe4a0040)
|
||||
#define LED_TF_ON 1
|
||||
#define LED_TF_OFF 0
|
||||
#define TF_ERROR_CODE ((volatile uint8_t *)0xbe4a0044)
|
||||
#define BUZZER_REG ((volatile uint8_t *)0xbe4a0050)
|
||||
|
||||
/* Keyboard/Mouse Z85230 */
|
||||
#define KBD_STATUS ((volatile uint8_t *)0xbe480000)
|
||||
#define KBD_DATA ((volatile uint8_t *)0xbe480004)
|
||||
|
||||
/* RTC */
|
||||
#define RTC_MK48T18_ADDR ((volatile uint8_t *)0xbe493fe0)
|
||||
#define RTC_MK48T18_NVSRAM_ADDR 0xbe490000
|
||||
|
||||
/* INTC */
|
||||
#define INTC_CLEAR_REG ((volatile uint32_t *)0xbe000000)
|
||||
#define INTC_STATUS_REG ((volatile uint32_t *)0xbe000004)
|
||||
#define INTC_MASK_REG ((volatile uint32_t *)0xbe000008)
|
||||
#define INTC_INT5 0x80000000
|
||||
#define INTC_INT4 0x04000000
|
||||
#define INTC_INT3 0x00200000
|
||||
#define INTC_INT2 0x00010000
|
||||
#define INTC_INT1 0x00000800
|
||||
#define INTC_INT0 0x00000020
|
||||
|
||||
/* ASO */
|
||||
#define ASO_DMAINT_STATUS_REG ((volatile uint32_t *)0xbe408000)
|
||||
#define ASO_INT_MASK_REG ((volatile uint32_t *)0xbe40a00c)
|
||||
#define ASO_INT_STATUS_REG ((volatile uint32_t *)0xbe40a010)
|
||||
|
||||
#define TR2A_ASO_INTMASK_ALL 0x00f0837d
|
||||
|
||||
/* Graphic adapter */
|
||||
#include <machine/gareg.h>
|
||||
|
||||
#endif /* !_EWS4800MIPS_SBD_TR2_H_ */
|
|
@ -0,0 +1,63 @@
|
|||
/* $NetBSD: sbdiovar.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_SBDIOVAR_H_
|
||||
#define _EWS4800MIPS_SBDIOVAR_H_
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
struct sbdiodevdesc {
|
||||
const char *sd_name;
|
||||
paddr_t sd_addr1;
|
||||
paddr_t sd_addr2;
|
||||
int sd_irq;
|
||||
int sd_flags;
|
||||
};
|
||||
|
||||
struct sbdio_attach_args {
|
||||
const char *sa_name;
|
||||
bus_space_tag_t sa_bust;
|
||||
bus_dma_tag_t sa_dmat;
|
||||
paddr_t sa_addr1;
|
||||
paddr_t sa_addr2;
|
||||
int sa_irq; /* PICNIC or NABI? */
|
||||
int sa_flags;
|
||||
};
|
||||
|
||||
#endif /* !_EWS4800MIPS_SBDIOVAR_H_ */
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/* $NetBSD: sbdvar.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004, 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_SBDVAR_H_
|
||||
#define _EWS4800MIPS_SBDVAR_H_
|
||||
|
||||
#include <sys/kcore.h> /* phys_ram_seg_t */
|
||||
|
||||
#include <machine/autoconf.h> /* mainbus_attach_args */
|
||||
#include <machine/vmparam.h> /* VM_PHYSSEG_MAX */
|
||||
#include <machine/sbd.h> /* enum sbd_machine_type */
|
||||
#include <machine/sbdiovar.h> /* sbdio_attach_args */
|
||||
|
||||
/* Software representation of system board */
|
||||
struct sbd {
|
||||
/* Machine identification */
|
||||
enum sbd_machine_type machine;
|
||||
char name[32];
|
||||
int cpu_clock;
|
||||
|
||||
/* mainbus node table */
|
||||
const char **mainbusdevs;
|
||||
|
||||
/* System Board I/O device table */
|
||||
const struct sbdiodevdesc *sbdiodevs;
|
||||
|
||||
/* Memory */
|
||||
phys_ram_seg_t mem_clseters[VM_PHYSSEG_MAX];
|
||||
size_t mem_size; /* total size of memory */
|
||||
|
||||
void (*mem_init)(void *, void *);
|
||||
|
||||
/* Cache configuration (determine L2-cache size) */
|
||||
void (*cache_config)(void);
|
||||
|
||||
/* Write buffer */
|
||||
void (*wbflush)(void);
|
||||
|
||||
/* Interrupt services */
|
||||
void (*intr_init)(void);
|
||||
void *(*intr_establish)(int, int (*)(void *), void *);
|
||||
void (*intr_disestablish)(void *);
|
||||
void (*intr)(uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
/* Interval timer helper routines */
|
||||
void (*initclocks)(void);
|
||||
u_long (*readclock)(void);
|
||||
|
||||
/* Miscellaneous */
|
||||
void (*consinit)(void);
|
||||
int (*ipl_bootdev)(void);
|
||||
void (*reboot)(void);
|
||||
void (*poweroff)(void);
|
||||
void (*ether_addr)(uint8_t *);
|
||||
};
|
||||
|
||||
#define SBD_DECL(x) \
|
||||
void x ## _cache_config(void); \
|
||||
void x ## _wbflush(void); \
|
||||
void x ## _mem_init(void *, void *); \
|
||||
void x ## _intr_init(void); \
|
||||
void * x ## _intr_establish(int, int (*)(void *), void *); \
|
||||
void x ## _intr_disestablish(void *); \
|
||||
void x ## _intr(uint32_t, uint32_t, uint32_t, uint32_t); \
|
||||
void x ## _initclocks(void); \
|
||||
u_long x ## _readclock(void); \
|
||||
void x ## _consinit(void); \
|
||||
int x ## _ipl_bootdev(void); \
|
||||
void x ## _reboot(void); \
|
||||
void x ## _poweroff(void); \
|
||||
void x ## _ether_addr(uint8_t *); \
|
||||
extern const uint32_t x ## _sr_bits[]
|
||||
|
||||
#define _SBD_OPS_SET(m, x) platform . x = m ## _ ## x
|
||||
|
||||
#define _SBD_OPS_REGISTER_ALL(m) \
|
||||
_SBD_OPS_SET(m, cache_config); \
|
||||
_SBD_OPS_SET(m, wbflush); \
|
||||
_SBD_OPS_SET(m, mem_init); \
|
||||
_SBD_OPS_SET(m, intr_init); \
|
||||
_SBD_OPS_SET(m, intr_establish); \
|
||||
_SBD_OPS_SET(m, intr_disestablish); \
|
||||
_SBD_OPS_SET(m, intr); \
|
||||
_SBD_OPS_SET(m, initclocks); \
|
||||
_SBD_OPS_SET(m, readclock); \
|
||||
_SBD_OPS_SET(m, consinit); \
|
||||
_SBD_OPS_SET(m, ipl_bootdev); \
|
||||
_SBD_OPS_SET(m, reboot); \
|
||||
_SBD_OPS_SET(m, poweroff); \
|
||||
_SBD_OPS_SET(m, ether_addr); \
|
||||
|
||||
|
||||
extern struct sbd platform;
|
||||
|
||||
extern int mem_cluster_cnt;
|
||||
extern phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
|
||||
|
||||
void sbd_init(void);
|
||||
void sbd_set_mainfo(uint32_t);
|
||||
|
||||
void sbd_memcluster_init(uint32_t);
|
||||
void sbd_memcluster_setup(void *, void *);
|
||||
void sbd_memcluster_check(void);
|
||||
|
||||
void tr2_init(void);
|
||||
void tr2a_init(void);
|
||||
|
||||
#endif /* !_EWS4800MIPS_SBDVAR_H_ */
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/* $NetBSD: sector.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_SECTOR_H_
|
||||
#define _EWS4800MIPS_SECTOR_H_
|
||||
#ifdef _KERNEL
|
||||
void *sector_init(dev_t, void (*)(struct buf *));
|
||||
#endif
|
||||
void sector_fini(void *);
|
||||
boolean_t sector_read_n(void *, uint8_t *, daddr_t, int);
|
||||
boolean_t sector_read(void *, uint8_t *, daddr_t);
|
||||
boolean_t sector_write_n(void *, uint8_t *, daddr_t, int);
|
||||
boolean_t sector_write(void *, uint8_t *, daddr_t);
|
||||
|
||||
#define ROUND_SECTOR(x) (((x) + 511) & ~511)
|
||||
#define TRUNC_SECTOR(x) ((x) & ~511)
|
||||
|
||||
#endif /* _EWS4800MIPS_SECTOR_H_ */
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: setjmp.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/setjmp.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: signal.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/signal.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: stdarg.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/stdarg.h>
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: trap.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/trap.h>
|
|
@ -0,0 +1,10 @@
|
|||
/* $NetBSD: types.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/types.h>
|
||||
|
||||
#define __HAVE_NWSCONS
|
||||
#define __HAVE_GENERIC_SOFT_INTERRUPTS
|
||||
|
||||
/* MIPS specific options */
|
||||
#define __HAVE_MIPS_MACHDEP_CACHE_CONFIG
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: varargs.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#include <mips/varargs.h>
|
|
@ -0,0 +1,26 @@
|
|||
/* $NetBSD: vmparam.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
#ifndef _EWS4800MIPS_VMPARAM_H_
|
||||
#define _EWS4800MIPS_VMPARAM_H_
|
||||
|
||||
#include <mips/vmparam.h>
|
||||
|
||||
/* VA 0xf0000000-0xffffffff is used for wired_map TLB entries. */
|
||||
#undef VM_MAX_KERNEL_ADDRESS
|
||||
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xF0000000)
|
||||
|
||||
#define VM_MIN_WIRED_MAP_ADDRESS ((vaddr_t)0xF0000000)
|
||||
#define VM_MAX_WIRED_MAP_ADDRESS ((vaddr_t)0xFFFFC000)
|
||||
|
||||
#define VM_PHYSSEG_MAX 9 /* M0-M8 */
|
||||
|
||||
#define VM_NFREELIST 1
|
||||
#define VM_FREELIST_DEFAULT 0
|
||||
|
||||
#ifndef KSEG2IOBUFSIZE
|
||||
/* reserve PTEs for KSEG2 I/O space */
|
||||
#define KSEG2IOBUFSIZE kseg2iobufsize
|
||||
#endif
|
||||
extern vsize_t kseg2iobufsize;
|
||||
|
||||
#endif /* !_EWS4800MIPS_VMPARAM_H_ */
|
|
@ -0,0 +1,96 @@
|
|||
/* $NetBSD: vtoc.h,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by UCHIYAMA Yasushi.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _EWS4800MIPS_VTOC_H_
|
||||
#define _EWS4800MIPS_VTOC_H_
|
||||
|
||||
/* Volume Table Of Contents */
|
||||
|
||||
#define VTOC_MAXPARTITIONS 16
|
||||
#define VTOC_SECTOR 1 /* sector */
|
||||
#define VTOC_MINSIZE 16 /* sector */
|
||||
|
||||
#define VTOC_MAGIC 0x600ddeee
|
||||
#define VTOC_VERSION 1
|
||||
|
||||
#define VTOC_TAG_NONAME 0x00
|
||||
#define VTOC_TAG_BOOT 0x01
|
||||
#define VTOC_TAG_ROOT 0x02
|
||||
#define VTOC_TAG_SWAP 0x03
|
||||
#define VTOC_TAG_USR 0x04
|
||||
#define VTOC_TAG_RAWDISK 0x05
|
||||
#define VTOC_TAG_STAND 0x06 /* bfs */
|
||||
#define VTOC_TAG_VAR 0x07
|
||||
#define VTOC_TAG_HOME 0x08
|
||||
#define __VTOC_TAG_BSDFFS 0xff /* ews4800mips port original define */
|
||||
|
||||
#define VTOC_FLAG_UNMOUNT 0x01
|
||||
#define VTOC_FLAG_RDONLY 0x10
|
||||
|
||||
struct ux_partition {
|
||||
uint16_t tag; /* 0 */
|
||||
uint16_t flags; /* 2 */
|
||||
uint32_t start_sector; /* 4 */
|
||||
int32_t nsectors; /* 8 */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Sector image */
|
||||
struct vtoc_sector {
|
||||
uint32_t bootinfo[3]; /* 0 */
|
||||
uint32_t magic; /* 12 */
|
||||
uint32_t version; /* 16 */
|
||||
int8_t volume[8]; /* 20 */
|
||||
uint16_t sector_size_byte; /* 28 */
|
||||
uint16_t npartitions; /* 30 */
|
||||
uint32_t reserved[10]; /* 32 */
|
||||
struct ux_partition partition[VTOC_MAXPARTITIONS]; /* 72 */
|
||||
uint32_t timestamp[VTOC_MAXPARTITIONS]; /* 264 */
|
||||
int32_t padding[46]; /* 328 */
|
||||
} __attribute__((__packed__)); /* 512 byte */
|
||||
|
||||
struct pdinfo_sector;
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
boolean_t vtoc_sector(void *, struct vtoc_sector *, int);
|
||||
boolean_t vtoc_valid(const struct vtoc_sector *);
|
||||
boolean_t vtoc_sanity(const struct vtoc_sector *);
|
||||
const struct ux_partition *vtoc_find_bfs(const struct vtoc_sector *);
|
||||
boolean_t vtoc_write(struct vtoc_sector *, struct pdinfo_sector *);
|
||||
#endif
|
||||
|
||||
#endif /* _EWS4800MIPS_VTOC_H_ */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue