'kernel_org-linux-2_6_9'.
+++ /dev/null
-Kernel Low-Level PCMCIA Interface Documentation
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-John G Dorsey <john+@cs.cmu.edu>
-Updated: 30 June, 2000
-
-
-Note: this interface has not been finalized!
-See also: http://www.cs.cmu.edu/~wearable/software/pcmcia-arm.html
-
-
-Introduction
-
-Early versions of PCMCIA Card Services for StrongARM were designed to
-permit a single socket driver to run on a variety of SA-1100 boards by
-using a userland configuration process. During the conversion to the 2.3
-kernel series, all of the configuration has moved into sub-drivers in the
-kernel proper (see linux/drivers/pcmcia/sa1100*). This document describes
-the low-level interface between those sub-drivers and the sa1100 socket
-driver module.
-
-Presently, there are six operations which must be provided by the
-board-specific code. Only functions whose implementation is likely to
-differ across board designs are required at this level. Some examples
-include:
-
- - configuring card detect lines to generate interrupts
- - sensing the legal voltage levels for inserted cards
- - asserting the reset signal for a card
-
-Functions which are assumed to be the same across all designs are
-performed within the generic socket driver itself. Some examples of these
-kinds of operations include:
-
- - configuring memory access times based on the core clock frequency
- - reads/writes on memory, byte swizzling, ...
-
-The current implementation allows the specific per-board set of low-level
-operations to be determined at run time. For each specific board, the
-following structure should be filled in:
-
- struct pcmcia_low_level {
- int (*init)(struct pcmcia_init *);
- int (*shutdown)(void);
- int (*socket_state)(struct pcmcia_state_array *);
- int (*get_irq_info)(struct pcmcia_irq_info *);
- int (*configure_socket)(const struct pcmcia_configure *);
- };
-
-The component functions are described in detail below. Using the
-machine_is_*() tests, the pointer `pcmcia_low_level' should be assigned to
-the location of the table for your board.
-
-
-0. init(struct pcmcia_init *init)
-
-This operation has three responsibilities:
-
- - perform any board-specific initialization tasks
- - associate the given handler with any interrupt-generating signals
- such as card detection, or battery voltage detection
- - set up any necessary edge detection for card ready signals
-
-Argument passing for this operation is implemented by the following
-structure:
-
- struct pcmcia_init {
- void (*handler)(int irq, void *dev, struct pt_regs *regs);
- struct pcmcia_maps *maps;
- };
-
-Here, `handler' is provided by the socket driver, and `maps' must be
-modified if the default mapping isn't appropriate. This operation should
-return one of two values:
-
- - the highest-numbered socket available, plus one
- - a negative number, indicating an error in configuration
-
-Note that the former case is _not_ the same as "the number of sockets
-available." In particular, if your design uses SA-1100 slot "one" but
-not slot "zero," you MUST report "2" to the socket driver.
-
-
-1. shutdown(void)
-
-This operation takes no arguments, and will be called during cleanup for
-the socket driver module. Any state associated with the socket controller,
-including allocated data structures, reserved IRQs, etc. should be
-released in this routine.
-
-The return value for this operation is not examined.
-
-
-2. socket_state(struct pcmcia_state_array *state_array)
-
-This operation will be invoked from the interrupt handler which was set up
-in the earlier call to init(). Note, however, that it should not include
-any side effects which would be inappropriate if the operation were to
-occur when no interrupt is pending. (An extra invocation of this operation
-currently takes place to initialize state in the socket driver.)
-
-Argument passing for this operation is handled by a structure which
-contains an array of the following type:
-
- struct pcmcia_state {
- unsigned detect: 1,
- ready: 1,
- bvd1: 1,
- bvd2: 1,
- wrprot: 1,
- vs_3v: 1,
- vs_Xv: 1;
- };
-
-Upon return from the operation, a struct pcmcia_state should be filled in
-for each socket available in the hardware. For every array element (up to
-`size' in the struct pcmcia_state_saarray) which does not correspond to an
-available socket, zero the element bits. (This includes element [0] if
-socket zero is not used.)
-
-Regardless of how the various signals are routed to the SA-1100, the bits
-in struct pcmcia_state always have the following semantics:
-
- detect - 1 if a card is fully inserted, 0 otherwise
- ready - 1 if the card ready signal is asserted, 0 otherwise
- bvd1 - the value of the Battery Voltage Detect 1 signal
- bvd2 - the value of the Battery Voltage Detect 2 signal
- wrprot - 1 if the card is write-protected, 0 otherwise
- vs_3v - 1 if the card must be operated at 3.3V, 0 otherwise
- vs_Xv - 1 if the card must be operated at X.XV, 0 otherwise
-
-A note about the BVD signals: if your board does not make both lines
-directly observable to the processor, just return reasonable values. The
-standard interpretation of the BVD signals is:
-
- BVD1 BVD2
-
- 0 x battery is dead
- 1 0 battery warning
- 1 1 battery ok
-
-Regarding the voltage sense flags (vs_3v, vs_Xv), these bits should be set
-based on a sampling of the Voltage Sense pins, if available. The standard
-interpretation of the VS signals (for a "low-voltage" socket) is:
-
- VS1 VS2
-
- 0 0 X.XV, else 3.3V, else none
- 0 1 3.3V, else none
- 1 0 X.XV, else none
- 1 1 5V, else none
-
-More information about the BVD and VS conventions is available in chapter
-5 of "PCMCIA System Architecture," 2nd ed., by Don Anderson.
-
-This operation should return 1 if an IRQ is actually pending for the
-socket controller, 0 if no IRQ is pending (but no error condition exists,
-such as an undersized state array), or -1 on any error.
-
-
-3. get_irq_info(struct pcmcia_irq_info *info)
-
-This operation obtains the IRQ assignment which is legal for the given
-socket. An argument of the following type is passed:
-
- struct pcmcia_irq_info {
- unsigned int sock;
- unsigned int irq ;
- };
-
-The `sock' field contains the socket index being queried. The `irq' field
-should contain the IRQ number corresponding to the card ready signal from
-the device.
-
-This operation should return 0 on success, or -1 on any error.
-
-
-4. configure_socket(const struct pcmcia_configure *configure)
-
-This operation allows the caller to apply power to the socket, issue a
-reset, or enable various outputs. The argument is of the following type:
-
- struct pcmcia_configure {
- unsigned sock: 8,
- vcc: 8,
- vpp: 8,
- output: 1,
- speaker: 1,
- reset: 1;
- };
-
-The `sock' field contains the index of the socket to be configured. The
-`vcc' and `vpp' fields contain the voltages to be applied for Vcc and Vpp,
-respectively, in units of 0.1V. (Note that vpp==120 indicates that
-programming voltage should be applied.)
-
-The two output enables, `output' and `speaker', refer to the card data
-signal enable and the card speaker enable, respectively. The `reset' bit,
-when set, indicates that the card reset should be asserted.
-
-This operation should return 0 on success, or -1 on any error.
-
-
-Board-Specific Notes
-
-The following information is known about various SA-11x0 board designs
-which may be used as reference while adding support to the kernel.
-
-
-Carnegie Mellon Itsy/Cue (http://www.cs.cmu.edu/~wearable/itsy/)
-
- Itsy Chip Select 3 (CS3) Interface
- ("ITSY MEMORY/PCMCIA ADD-ON BOARD with BATTERY and CHARGER CIRCUITRY,"
- memo dated 5-20-99, from Tim Manns to Richard Martin, et. al)
-
- Read:
- ABVD2 (SS)D0 A slot, Battery Voltage Detect
- ABVD1 (SS)D1
- AVSS2 (SS)D2 A slot, Voltage Sense
- AVSS1 (SS)D3
- GND (SS)D4
- GND (SS)D5
- GND (SS)D6
- GND (SS)D7
-
- BBVD2 (SS)D8 B slot, Battery Voltage Detect
- BBVD1 (SS)D9
- BVSS2 (SS)D10 B slot, Voltage Sense
- BVSS1 (SS)D11
- GND (SS)D12
- GND (SS)D13
- GND (SS)D14
- GND (SS)D15
-
- Write:
- (SS)D0 A_VPP_VCC LTC1472 VPPEN1
- (SS)D1 A_VPP_PGM LTC1472 VPPEN0
- (SS)D2 A_VCC_3 LTC1472 VCCEN0
- (SS)D3 A_VCC_5 LTC1472 VCCEN1
- (SS)D4 RESET (A SLOT)
- (SS)D5 GND
- (SS)D6 GND
- (SS)D7 GND
-
- (SS)D8 B_VPP_VCC LTC1472 VPPEN1
- (SS)D9 B_VPP_PGM LTC1472 VPPEN0
- (SS)D10 B_VCC_3 LTC1472 VCCEN0
- (SS)D11 B_VCC_5 LTC1472 VCCEN1
- (SS)D12 RESET (B SLOT)
- (SS)D13 GND
- (SS)D14 GND
- (SS)D15 GND
-
- GPIO pin assignments are as follows: (from schematics)
-
- GPIO 10 Slot 0 Card Detect
- GPIO 11 Slot 1 Card Detect
- GPIO 12 Slot 0 Ready/Interrupt
- GPIO 13 Slot 1 Ready/Interrupt
-
-
-
-Intel SA-1100 Multimedia Board (http://developer.intel.com/design/strong/)
-
- CPLD Registers
- SA-1100 Multimedia Development Board with Companion SA-1101 Development
- Board User's Guide, p.4-42
-
- This SA-1100/1101 development package uses only one GPIO pin (24) to
- signal changes in card status, and requires software to inspect a
- PCMCIA status register to determine the source.
-
- Read: (PCMCIA Power Sense Register - 0x19400000)
- S0VS1 0 Slot 0 voltage sense
- S0VS2 1
- S0BVD1 2 Slot 0 battery voltage sense
- S0BVD2 3
- S1VS1 4 Slot 1 voltage sense
- S1VS2 5
- S1BVD1 6 Slot 1 battery voltage sense
- S1BVD2 7
-
- Read/Write: (PCMCIA Power Control Register - 0x19400002)
- S0VPP0 0 Slot 0 Vpp
- S0VPP1 1
- S0VCC0 2 Slot 0 Vcc
- S0VCC1 3
- S1VPP0 4 Slot 1 Vpp
- S1VPP1 5
- S1VCC0 6 Slot 1 Vcc
- S1VCC1 7
-
- Read: (PCMCIA Status Register - 0x19400004)
- S0CD1 0 Slot 0 Card Detect 1
- S0RDY 1 Slot 0 Ready/Interrupt
- S0STSCHG 2 Slot 0 Status Change
- S0Reset 3 Slot 0 Reset (RW)
- S1CD1 4 Slot 1 Card Detect 1
- S1RDY 5 Slot 1 Ready/Interrupt
- S1STSCHG 6 Slot 1 Status Change
- S1Reset 7 Slot 1 Reset (RW)
-
-
-
-Intel SA-1100 Evaluation Platform (http://developer.intel.com/design/strong/)
-
- Brutus I/O Pins and Chipselect Register
- pcmcia-brutus.c, by Ivo Clarysse
- (What's the official reference for this info?)
-
- This SA-1100 development board uses more GPIO pins than say, the Itsy
- or the SA-1100/1101 multimedia package. The pin assignments are as
- follows:
-
- GPIO 2 Slot 0 Battery Voltage Detect 1
- GPIO 3 Slot 0 Ready/Interrupt
- GPIO 4 Slot 0 Card Detect
- GPIO 5 Slot 1 Battery Voltage Detect 1
- GPIO 6 Slot 1 Ready/Interrupt
- GPIO 7 Slot 1 Card Detect
-
- Like the Itsy, Brutus uses a chipselect register in static memory
- bank 3 for the other signals, such as voltage sense or reset:
-
- Read:
- P0_VS1 8 Slot 0 Voltage Sense
- P0_VS2 9
- P0_STSCHG 10 Slot 0 Status Change
- P1_VS1 12 Slot 1 Voltage Sense
- P1_VS2 13
- P1_STSCHG 14 Slot 1 Status Change
-
- Read/Write:
- P0_ 16 Slot 0 MAX1600EAI control line
- P0_ 17 Slot 0 MAX1600EAI control line
- P0_ 18 Slot 0 MAX1600EAI control line
- P0_ 19 Slot 0 MAX1600EAI control line
- P0_ 20 Slot 0 12V
- P0_ 21 Slot 0 Vpp to Vcc (CONFIRM?)
- P0_ 22 Slot 0 enable fan-out drivers & xcvrs
- P0_SW_RST 23 Slot 0 Reset
- P1_ 24 Slot 1 MAX1600EAI control line
- P1_ 25 Slot 1 MAX1600EAI control line
- P1_ 26 Slot 1 MAX1600EAI control line
- P1_ 27 Slot 1 MAX1600EAI control line
- P1_ 28 Slot 1 12V
- P1_ 29 Slot 1 Vpp to Vcc (CONFIRM?)
- P1_ 30 Slot 1 enable fan-out drivers & xcvrs
- P1_SW_RST 31 Slot 1 Reset
-
- For each slot, the bits labelled "MAX1600EAI" should (apparently)
- be written with the value 0101 for Vcc 3.3V, and 1001 for Vcc 5V.
-
-
-
-Intel SA-1110 Development Platform (http://developer.intel.com/design/strong/)
-
- GPIO Pin Descriptions and Board Control Register
- SA-1110 Microprocessor Development Board User's Guide, p.4-7, 4-10
-
- The Assabet board contains only a single Compact Flash slot,
- attached to slot 1 on the SA-1110. Card detect, ready, and BVD
- signals are routed through GPIO, with power and reset placed in a
- control register. Note that the CF bus must be enabled before use.
-
- GPIO 21 Slot 1 Compact Flash interrupt
- GPIO 22 Slot 1 card detect (CD1 NOR CD2)
- GPIO 24 Slot 1 Battery Voltage Detect 2
- GPIO 25 Slot 1 Battery Voltage Detect 1
-
- Write-only: (Board Control Register - 0x12000000)
- CF_PWR 0 CF bus power (3.3V)
- CF_RST 1 CF reset
- CF_Bus_On 7 CF bus enable
-
+++ /dev/null
-
-Board Overview
------------------------------
-
-This is an beta release of the Xscale Linux port to the ADI 80200EVB
-evaluation board.
-
-The 80200EVB is an evaluation platform for ADI Engineering's high-performance
-80200FCC chipset for the Intel 80200 XScale CPU. The 80200FCC is an open
-source FPGA based system that contains a PCI unit and a high performance
-memory controller.
-
-In addition to the 80200FCC, the board also contains a 16C550 UART, and 4MB
-of flash.
-
-The board is still under development and currently only the UART is functional
-as the PCI bits have not been programmed into the FPGA.
-
-For more information on the board, see http://www.adiengineering.com
-
-Port Status
------------------------------
-
-Supported:
-
-- Onboard UART (Polled operation only)
-- Cache/TLB locking on 80200 CPU
-
-TODO:
-
-- PCI when hardware supports it
-
-Building the Kernel
------------------------------
-change Linux makefile
-make adi_evb_config
-make oldconfig
-make zImage
-
-Loading Linux
------------------------------
-
-Before you can use Linux on the ADI board, you need to grab the following:
-
-ADI 80200EVB Monitor:
- ftp://source.mvista.com/pub/xscale/ADI_EVB/monitor.srec
-
-ADI JFFS2 Image:
- ftp://source.mvista.com/pub/xscale/ADI_EVB/adi.jffs2
-
-Once you've got the Cygnus prompt, type in the following command:
-
- load
-
-On another terminal window:
-
- cat monitor.srec > /dev/ttyS0
-
-(replace ttyS0 with the serial port you are using)
-
-Once completed, just type 'go' at the cygmon prompt and you should see:
-
- MontaVista IQ80310 Monitor Version 0.1
- monitor>
-
-Type 'b 115200' at the prompt and change your terminal speed to 115200
-
-The first thing to do is to upload and burn the jffs2 filesystem image
-onto the boards 4MB of flash:
-
- monitor> u c1000000
- Uploading file at 0xc1000000
- Now send file with ymodem
-
-Do as the monitor says and transfer the file adi.jffs2. Once complete,
-the following will copy the jffs2 image to location 0x80000 in the flash.
-
- monitor> f 8000 c1000000 200000
- Erasing sector 0x00080000
- Writing sector 0x00080000 with data at 0xC1000000
- Erasing sector 0x000A0000
- Writing sector 0x000A0000 with data at 0xC1020000
- Erasing sector 0x000C0000
- ...
-
-Now use the same command as above to upload your zImage to location c1000000.
-When you've done that, type 'j c1000000' to run Linux. Login as
-root and you're all set to go.
-
-Misc Notes
------------------------------
-
-The current version of the HW does not have an onboard timer, so the 80200
-PMU is not available for general use as it is being used for a timer source.
-
-By default, the MTD driver reserves the first 512K for bootloaders and
-the remaining 3.5MB for the filesystem. You can edit drivers/mtd/map/adi_evb.c
-to change this as needed for your application.
-
-Contributors
------------------------------
-
-Thanks to ADI Engineering for providing the hardware for development
-
-Deepak Saxena <dsaxena@mvista.com> - Initial port
-
------------------------------
-Enjoy. If you have any problem please contact Deepak Saxena
-dsaxena@mvista.com
-
+++ /dev/null
-
-Board Overview
------------------------------
-
-The Cyclone IQ80310 board is an evaluation platform for Intel's 80200 Xscale
-CPU and 80312 Intelligent I/O chipset (collectively called IOP310 chipset).
-
-The 80312 contains dual PCI hoses (called the ATUs), a PCI-to-PCI bridge,
-three DMA channels (1 on secondary PCI, one on primary PCI ), I2C, I2O
-messaging unit, XOR unit for RAID operations, a bus performance monitoring
-unit, and a memory controller with ECC features.
-
-For more information on the board, see http://developer.intel.com/iio
-
-Port Status
------------------------------
-
-Supported:
-
-- MTD/JFFS/JFFS2
-- NFS root
-- RAMDISK root
-- 2ndary PCI slots
-- Onboard ethernet
-- Serial ports (ttyS0/S1)
-- Cache/TLB locking on 80200 CPU
-- Performance monitoring unit on 80200 CPU
-- 80200 Performance Monitoring Unit
-- Acting as a system controller on Cyclone 80303BP PCI backplane
-- DMA engines (EXPERIMENTAL)
-- 80312 Bus Performance Monitor (EXPERIMENTAL)
-- Application Accelerator Unit (XOR engine for RAID) (EXPERIMENTAL)
-- Messaging Unit (EXPERIMENTAL)
-
-TODO:
-- I2C
-
-Building the Kernel
------------------------------
-make iq80310_config
-make oldconfig
-make zImage
-
-This will build an image setup for BOOTP/NFS root support. To change this,
-just run make menuconfig and disable nfs root or add a "root=" option.
-
-Preparing the Hardware
------------------------------
-
-This document assumes you're using a Rev D or newer board running
-Redboot as the bootloader. Note that the version of RedBoot provided
-with the boards has a major issue and you need to replace it with the
-latest RedBoot. You can grab the source from the ECOS CVS or you can
-get a prebuilt image and burn it in using FRU at:
-
- ftp://source.mvista.com/pub/xscale/iq80310/redboot.bin
-
-Make sure you do an 'fis init' command once you boot with the new
-RedBoot image.
-
-
-
-Downloading Linux
------------------------------
-
-Assuming you have your development system setup to act as a bootp/dhcp
-server and running tftp:
-
- RedBoot> load -r -b 0xa1008000 /tftpboot/zImage.xs
- Raw file loaded 0xa1008000-0xa1094bd8
-
-If you're not using dhcp/tftp, you can use y-modem instead:
-
- RedBoot> load -r -b 0xa1008000 -m y
-
-Note that on Rev D. of the board, tftp does not work due to intermittent
-interrupt issues, so you need to download using ymodem.
-
-Once the download is completed:
-
- RedBoot> go 0xa1008000
-
-Root Devices
------------------------------
-
-A kernel is not useful without a root filesystem, and you have several
-choices with this board: NFS root, RAMDISK, or JFFS/JFFS2. For development
-purposes, it is suggested that you use NFS root for easy access to various
-tools. Once you're ready to deploy, probably want to utilize JFFS/JFFS2 on
-the flash device.
-
-MTD on the IQ80310
------------------------------
-
-Linux on the IQ80310 supports RedBoot FIS paritioning if it is enabled.
-Out of the box, once you've done 'fis init' on RedBoot, you will get
-the following partitioning scheme:
-
- root@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 0075f000 00020000 "unallocated space"
- mtd3: 00001000 00020000 "RedBoot config"
- mtd4: 00020000 00020000 "FIS directory"
-
-To create an FIS directory, you need to use the fis command in RedBoot.
-As an example, you can burn the kernel into the flash once it's downloaded:
-
- RedBoot> fis create -b 0xa1008000 -l 0x8CBAC -r 0xa1008000 -f 0x80000 kernel
- ... Erase from 0x00080000-0x00120000: .....
- ... Program from 0xa1008000-0xa1094bac at 0x00080000: .....
- ... Unlock from 0x007e0000-0x00800000: .
- ... Erase from 0x007e0000-0x00800000: .
- ... Program from 0xa1fdf000-0xa1fff000 at 0x007e0000: .
- ... Lock from 0x007e0000-0x00800000: .
-
- RedBoot> fis list
- Name FLASH addr Mem addr Length Entry point
- RedBoot 0x00000000 0x00000000 0x00040000 0x00000000
- RedBoot[backup] 0x00040000 0x00040000 0x00040000 0x00000000
- RedBoot config 0x007DF000 0x007DF000 0x00001000 0x00000000
- FIS directory 0x007E0000 0x007E0000 0x00020000 0x00000000
- kernel 0x00080000 0xA1008000 0x000A0000 0x00000000
-
-This leads to the following Linux MTD setup:
-
- mtroot@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 000a0000 00020000 "kernel"
- mtd3: 006bf000 00020000 "unallocated space"
- mtd4: 00001000 00020000 "RedBoot config"
- mtd5: 00020000 00020000 "FIS directory"
-
-Note that there is not a 1:1 mapping to the number of RedBoot paritions to
-MTD partitions as unused space also gets allocated into MTD partitions.
-
-As an aside, the -r option when creating the Kernel entry allows you to
-simply do an 'fis load kernel' to copy the image from flash into memory.
-You can then do an 'fis go 0xa1008000' to start Linux.
-
-If you choose to use static partitioning instead of the RedBoot partioning:
-
- /dev/mtd0 0x00000000 - 0x0007ffff: Boot Monitor (512k)
- /dev/mtd1 0x00080000 - 0x0011ffff: Kernel Image (640K)
- /dev/mtd2 0x00120000 - 0x0071ffff: File System (6M)
- /dev/mtd3 0x00720000 - 0x00800000: RedBoot Reserved (896K)
-
-To use a JFFS1/2 root FS, you need to donwload the JFFS image using either
-tftp or ymodem, and then copy it to flash:
-
- RedBoot> load -r -b 0xa1000000 /tftpboot/jffs.img
- Raw file loaded 0xa1000000-0xa1600000
- RedBoot> fis create -b 0xa1000000 -l 0x600000 -f 0x120000 jffs
- ... Erase from 0x00120000-0x00720000: ..................................
- ... Program from 0xa1000000-0xa1600000 at 0x00120000: ..................
- ......................
- ... Unlock from 0x007e0000-0x00800000: .
- ... Erase from 0x007e0000-0x00800000: .
- ... Program from 0xa1fdf000-0xa1fff000 at 0x007e0000: .
- ... Lock from 0x007e0000-0x00800000: .
- RedBoot> fis list
- Name FLASH addr Mem addr Length Entry point
- RedBoot 0x00000000 0x00000000 0x00040000 0x00000000
- RedBoot[backup] 0x00040000 0x00040000 0x00040000 0x00000000
- RedBoot config 0x007DF000 0x007DF000 0x00001000 0x00000000
- FIS directory 0x007E0000 0x007E0000 0x00020000 0x00000000
- kernel 0x00080000 0xA1008000 0x000A0000 0xA1008000
- jffs 0x00120000 0x00120000 0x00600000 0x00000000
-
-This looks like this in Linux:
-
- root@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 000a0000 00020000 "kernel"
- mtd3: 00600000 00020000 "jffs"
- mtd4: 000bf000 00020000 "unallocated space"
- mtd5: 00001000 00020000 "RedBoot config"
- mtd6: 00020000 00020000 "FIS directory"
-
-You need to boot the kernel once and watch the boot messages to see how the
-JFFS RedBoot partition mapped into the MTD partition scheme.
-
-You can grab a pre-built JFFS image to use as a root file system at:
-
- ftp://source.mvista.com/pub/xscale/iq80310/jffs.img
-
-For detailed info on using MTD and creating a JFFS image go to:
-
- http://www.linux-mtd.infradead.org.
-
-For details on using RedBoot's FIS commands, type 'fis help' or consult
-your RedBoot manual.
-
-Contributors
------------------------------
-
-Thanks to Intel Corporation for providing the hardware.
-
-John Clark <jclark@teamasa.com> - Initial discovery of RedBoot issues
-Dave Jiang <dave.jiang@intel.com> - IRQ demux fixes, AAU, DMA, MU
-Nicolas Pitre <nico@cam.org> - Initial port, cleanup, debugging
-Matt Porter <mporter@mvista.com> - PCI subsystem development, debugging
-Tim Sanders <tsanders@sanders.org> - Initial PCI code
-Mark Salter <msalter@redhat.com> - RedBoot fixes
-Deepak Saxena <dsaxena@mvista.com> - Cleanup, debug, cache lock, PMU
-
------------------------------
-Enjoy.
-
-If you have any problems please contact Deepak Saxena <dsaxena@mvista.com>
-
-A few notes from rmk
------------------------------
-
-These are notes of my initial experience getting the IQ80310 Rev D up and
-running. In total, it has taken many hours to work out what's going on...
-The version of redboot used is:
-
- RedBoot(tm) bootstrap and debug environment, version UNKNOWN - built 14:58:21, Aug 15 2001
-
-
-1. I've had a corrupted download of the redboot.bin file from Montavista's
- FTP site. It would be a good idea if there were md5sums, sum or gpg
- signatures available to ensure the integrity of the downloaded files.
- The result of this was an apparantly 100% dead card.
-
-2. RedBoot Intel EtherExpress Pro 100 driver seems to be very unstable -
- I've had it take out the whole of a 100mbit network for several minutes.
- The Hub indiates ZERO activity, despite machines attempting to communicate.
- Further to this, while tftping the kernel, the transfer will stall regularly,
- and might even drop the link LED.
-
-3. There appears to be a bug in the Intel Documentation Pack that comes with
- the IQ80310 board. Serial port 1, which is the socket next to the LEDs
- is address 0xfe810000, not 0xfe800000.
-
- Note that RedBoot uses either serial port 1 OR serial port 2, so if you
- have your console connected to the wrong port, you'll see redboot messages
- but not kernel boot messages.
-
-4. Trying to use fconfig to setup a boot script fails - it hangs when trying
- to erase the flash.
+++ /dev/null
-
-Board Overview
------------------------------
-
-The Worcester IQ80321 board is an evaluation platform for Intel's 80321 Xscale
-CPU (sometimes called IOP321 chipset).
-
-The 80321 contains a single PCI hose (called the ATUs), a PCI-to-PCI bridge,
-two DMA channels, I2C, I2O messaging unit, XOR unit for RAID operations,
-a bus performance monitoring unit, and a memory controller with ECC features.
-
-For more information on the board, see http://developer.intel.com/iio
-
-Port Status
------------------------------
-
-Supported:
-
-- MTD/JFFS/JFFS2 root
-- NFS root
-- RAMDISK root
-- Serial port (ttyS0)
-- Cache/TLB locking on 80321 CPU
-- Performance monitoring unit on 80321 CPU
-
-TODO:
-
-- DMA engines
-- I2C
-- 80321 Bus Performance Monitor
-- Application Accelerator Unit (XOR engine for RAID)
-- I2O Messaging Unit
-- I2C unit
-- SSP
-
-Building the Kernel
------------------------------
-make iq80321_config
-make oldconfig
-make zImage
-
-This will build an image setup for BOOTP/NFS root support. To change this,
-just run make menuconfig and disable nfs root or add a "root=" option.
-
-Preparing the Hardware
------------------------------
-
-Make sure you do an 'fis init' command once you boot with the new
-RedBoot image.
-
-Downloading Linux
------------------------------
-
-Assuming you have your development system setup to act as a bootp/dhcp
-server and running tftp:
-
-NOTE: The 80321 board uses a different default memory map than the 80310.
-
- RedBoot> load -r -b 0x01008000 -m y
-
-Once the download is completed:
-
- RedBoot> go 0x01008000
-
-There is a version of RedBoot floating around that has DHCP support, but
-I've never been able to cleanly transfer a kernel image and have it run.
-
-Root Devices
------------------------------
-
-A kernel is not useful without a root filesystem, and you have several
-choices with this board: NFS root, RAMDISK, or JFFS/JFFS2. For development
-purposes, it is suggested that you use NFS root for easy access to various
-tools. Once you're ready to deploy, probably want to utilize JFFS/JFFS2 on
-the flash device.
-
-MTD on the IQ80321
------------------------------
-
-Linux on the IQ80321 supports RedBoot FIS paritioning if it is enabled.
-Out of the box, once you've done 'fis init' on RedBoot, you will get
-the following partitioning scheme:
-
- root@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 0075f000 00020000 "unallocated space"
- mtd3: 00001000 00020000 "RedBoot config"
- mtd4: 00020000 00020000 "FIS directory"
-
-To create an FIS directory, you need to use the fis command in RedBoot.
-As an example, you can burn the kernel into the flash once it's downloaded:
-
- RedBoot> fis create -b 0x01008000 -l 0x8CBAC -r 0x01008000 -f 0x80000 kernel
- ... Erase from 0x00080000-0x00120000: .....
- ... Program from 0x01008000-0x01094bac at 0x00080000: .....
- ... Unlock from 0x007e0000-0x00800000: .
- ... Erase from 0x007e0000-0x00800000: .
- ... Program from 0x01fdf000-0x01fff000 at 0x007e0000: .
- ... Lock from 0x007e0000-0x00800000: .
-
- RedBoot> fis list
- Name FLASH addr Mem addr Length Entry point
- RedBoot 0x00000000 0x00000000 0x00040000 0x00000000
- RedBoot[backup] 0x00040000 0x00040000 0x00040000 0x00000000
- RedBoot config 0x007DF000 0x007DF000 0x00001000 0x00000000
- FIS directory 0x007E0000 0x007E0000 0x00020000 0x00000000
- kernel 0x00080000 0x01008000 0x000A0000 0x00000000
-
-This leads to the following Linux MTD setup:
-
- mtroot@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 000a0000 00020000 "kernel"
- mtd3: 006bf000 00020000 "unallocated space"
- mtd4: 00001000 00020000 "RedBoot config"
- mtd5: 00020000 00020000 "FIS directory"
-
-Note that there is not a 1:1 mapping to the number of RedBoot paritions to
-MTD partitions as unused space also gets allocated into MTD partitions.
-
-As an aside, the -r option when creating the Kernel entry allows you to
-simply do an 'fis load kernel' to copy the image from flash into memory.
-You can then do an 'fis go 0x01008000' to start Linux.
-
-If you choose to use static partitioning instead of the RedBoot partioning:
-
- /dev/mtd0 0x00000000 - 0x0007ffff: Boot Monitor (512k)
- /dev/mtd1 0x00080000 - 0x0011ffff: Kernel Image (640K)
- /dev/mtd2 0x00120000 - 0x0071ffff: File System (6M)
- /dev/mtd3 0x00720000 - 0x00800000: RedBoot Reserved (896K)
-
-To use a JFFS1/2 root FS, you need to donwload the JFFS image using either
-tftp or ymodem, and then copy it to flash:
-
- RedBoot> load -r -b 0x01000000 /tftpboot/jffs.img
- Raw file loaded 0x01000000-0x01600000
- RedBoot> fis create -b 0x01000000 -l 0x600000 -f 0x120000 jffs
- ... Erase from 0x00120000-0x00720000: ..................................
- ... Program from 0x01000000-0x01600000 at 0x00120000: ..................
- ......................
- ... Unlock from 0x007e0000-0x00800000: .
- ... Erase from 0x007e0000-0x00800000: .
- ... Program from 0x01fdf000-0x01fff000 at 0x007e0000: .
- ... Lock from 0x007e0000-0x00800000: .
- RedBoot> fis list
- Name FLASH addr Mem addr Length Entry point
- RedBoot 0x00000000 0x00000000 0x00040000 0x00000000
- RedBoot[backup] 0x00040000 0x00040000 0x00040000 0x00000000
- RedBoot config 0x007DF000 0x007DF000 0x00001000 0x00000000
- FIS directory 0x007E0000 0x007E0000 0x00020000 0x00000000
- kernel 0x00080000 0x01008000 0x000A0000 0x01008000
- jffs 0x00120000 0x00120000 0x00600000 0x00000000
-
-This looks like this in Linux:
-
- root@192.168.0.14:~# cat /proc/mtd
- dev: size erasesize name
- mtd0: 00040000 00020000 "RedBoot"
- mtd1: 00040000 00020000 "RedBoot[backup]"
- mtd2: 000a0000 00020000 "kernel"
- mtd3: 00600000 00020000 "jffs"
- mtd4: 000bf000 00020000 "unallocated space"
- mtd5: 00001000 00020000 "RedBoot config"
- mtd6: 00020000 00020000 "FIS directory"
-
-You need to boot the kernel once and watch the boot messages to see how the
-JFFS RedBoot partition mapped into the MTD partition scheme.
-
-You can grab a pre-built JFFS image to use as a root file system at:
-
- ftp://source.mvista.com/pub/xscale/iq80310/jffs.img
-
-For detailed info on using MTD and creating a JFFS image go to:
-
- http://www.linux-mtd.infradead.org.
-
-For details on using RedBoot's FIS commands, type 'fis help' or consult
-your RedBoot manual.
-
-BUGS and ISSUES
------------------------------
-
-* As shipped from Intel, pre-production boards have two issues:
-
-- The on board ethernet is disabled S8E1-2 is off. You will need to turn it on.
-
-- The PCIXCAPs are configured for a 100Mhz clock, but the clock selected is
- actually only 66Mhz. This causes the wrong PPL multiplier to be used and the
- board only runs at 400Mhz instead of 600Mhz. The way to observe this is to
- use a independent clock to time a "sleep 10" command from the prompt. If it
- takes 15 seconds instead of 10, you are running at 400Mhz.
-
-- The experimental IOP310 drivers for the AAU, DMA, etc. are not supported yet.
-
-Contributors
------------------------------
-The port to the IQ80321 was performed by:
-
-Rory Bolt <rorybolt@pacbell.net> - Initial port, debugging.
-
-This port was based on the IQ80310 port with the following contributors:
-
-Nicolas Pitre <nico@cam.org> - Initial port, cleanup, debugging
-Matt Porter <mporter@mvista.com> - PCI subsystem development, debugging
-Tim Sanders <tsanders@sanders.org> - Initial PCI code
-Deepak Saxena <dsaxena@mvista.com> - Cleanup, debug, cache lock, PMU
-
-The port is currently maintained by Deepak Saxena <dsaxena@mvista.com>
-
------------------------------
-Enjoy.
+++ /dev/null
-Support functions for the Intel 80310 AAU
-===========================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 09/18/2001
-
-The Intel 80312 companion chip in the 80310 chipset contains an AAU. The
-AAU is capable of processing up to 8 data block sources and perform XOR
-operations on them. This unit is typically used to accelerated XOR
-operations utilized by RAID storage device drivers such as RAID 5. This
-API is designed to provide a set of functions to take adventage of the
-AAU. The AAU can also be used to transfer data blocks and used as a memory
-copier. The AAU transfer the memory faster than the operation performed by
-using CPU copy therefore it is recommended to use the AAU for memory copy.
-
-------------------
-int aau_request(u32 *aau_context, const char *device_id);
-This function allows the user the acquire the control of the the AAU. The
-function will return a context of AAU to the user and allocate
-an interrupt for the AAU. The user must pass the context as a parameter to
-various AAU API calls.
-
-int aau_queue_buffer(u32 aau_context, aau_head_t *listhead);
-This function starts the AAU operation. The user must create a SGL
-header with a SGL attached. The format is presented below. The SGL is
-built from kernel memory.
-
-/* hardware descriptor */
-typedef struct _aau_desc
-{
- u32 NDA; /* next descriptor address [READONLY] */
- u32 SAR[AAU_SAR_GROUP]; /* src addrs */
- u32 DAR; /* destination addr */
- u32 BC; /* byte count */
- u32 DC; /* descriptor control */
- u32 SARE[AAU_SAR_GROUP]; /* extended src addrs */
-} aau_desc_t;
-
-/* user SGL format */
-typedef struct _aau_sgl
-{
- aau_desc_t aau_desc; /* AAU HW Desc */
- u32 status; /* status of SGL [READONLY] */
- struct _aau_sgl *next; /* pointer to next SG [READONLY] */
- void *dest; /* destination addr */
- void *src[AAU_SAR_GROUP]; /* source addr[4] */
- void *ext_src[AAU_SAR_GROUP]; /* ext src addr[4] */
- u32 total_src; /* total number of source */
-} aau_sgl_t;
-
-/* header for user SGL */
-typedef struct _aau_head
-{
- u32 total; /* total descriptors allocated */
- u32 status; /* SGL status */
- aau_sgl_t *list; /* ptr to head of list */
- aau_callback_t callback; /* callback func ptr */
-} aau_head_t;
-
-
-The function will call aau_start() and start the AAU after it queues
-the SGL to the processing queue. When the function will either
-a. Sleep on the wait queue aau->wait_q if no callback has been provided, or
-b. Continue and then call the provided callback function when DMA interrupt
- has been triggered.
-
-int aau_suspend(u32 aau_context);
-Stops/Suspends the AAU operation
-
-int aau_free(u32 aau_context);
-Frees the ownership of AAU. Called when no longer need AAU service.
-
-aau_sgl_t * aau_get_buffer(u32 aau_context, int num_buf);
-This function obtains an AAU SGL for the user. User must specify the number
-of descriptors to be allocated in the chain that is returned.
-
-void aau_return_buffer(u32 aau_context, aau_sgl_t *list);
-This function returns all SGL back to the API after user is done.
-
-int aau_memcpy(void *dest, void *src, u32 size);
-This function is a short cut for user to do memory copy utilizing the AAU for
-better large block memory copy vs using the CPU. This is similar to using
-typical memcpy() call.
-
-* User is responsible for the source address(es) and the destination address.
- The source and destination should all be cached memory.
-
-
-
-void aau_test()
-{
- u32 aau;
- char dev_id[] = "AAU";
- int size = 2;
- int err = 0;
- aau_head_t *head;
- aau_sgl_t *list;
- u32 i;
- u32 result = 0;
- void *src, *dest;
-
- printk("Starting AAU test\n");
- if((err = aau_request(&aau, dev_id))<0)
- {
- printk("test - AAU request failed: %d\n", err);
- return;
- }
- else
- {
- printk("test - AAU request successful\n");
- }
-
- head = kmalloc(sizeof(aau_head_t), GFP_KERNEL);
- head->total = size;
- head->status = 0;
- head->callback = NULL;
-
- list = aau_get_buffer(aau, size);
- if(!list)
- {
- printk("Can't get buffers\n");
- return;
- }
- head->list = list;
-
- src = kmalloc(1024, GFP_KERNEL);
- dest = kmalloc(1024, GFP_KERNEL);
-
- while(list)
- {
- list->status = 0;
- list->aau_desc->SAR[0] = (u32)src;
- list->aau_desc->DAR = (u32)dest;
- list->aau_desc->BC = 1024;
-
- /* see iop310-aau.h for more DCR commands */
- list->aau_desc->DC = AAU_DCR_WRITE | AAU_DCR_BLKCTRL_1_DF;
- if(!list->next)
- {
- list->aau_desc->DC = AAU_DCR_IE;
- break;
- }
- list = list->next;
- }
-
- printk("test- Queueing buffer for AAU operation\n");
- err = aau_queue_buffer(aau, head);
- if(err >= 0)
- {
- printk("AAU Queue Buffer is done...\n");
- }
- else
- {
- printk("AAU Queue Buffer failed...: %d\n", err);
- }
-
-
-
-#if 1
- printk("freeing the AAU\n");
- aau_return_buffer(aau, head->list);
- aau_free(aau);
- kfree(src);
- kfree(dest);
- kfree((void *)head);
-#endif
-}
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible if anything goes wrong. =)
-
-
-TODO
-____
-* Testing
-* Do zero-size AAU transfer/channel at init
- so all we have to do is chainining
-
+++ /dev/null
-Support functions forthe Intel 80310 DMA channels
-==================================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 09/18/2001
-
-The Intel 80310 XScale chipset provides 3 DMA channels via the 80312 I/O
-companion chip. Two of them resides on the primary PCI bus and one on the
-secondary PCI bus.
-
-The DMA API provided is not compatible with the generic interface in the
-ARM tree unfortunately due to how the 80312 DMACs work. Hopefully some time
-in the near future a software interface can be done to bridge the differences.
-The DMA API has been modeled after Nicholas Pitre's SA11x0 DMA API therefore
-they will look somewhat similar.
-
-
-80310 DMA API
--------------
-
-int dma_request(dmach_t channel, const char *device_id);
-
-This function will attempt to allocate the channel depending on what the
-user requests:
-
-IOP310_DMA_P0: PCI Primary 1
-IOP310_DMA_P1: PCI Primary 2
-IOP310_DMA_S0: PCI Secondary 1
-/*EOF*/
-
-Once the user allocates the DMA channel it is owned until released. Although
-other users can also use the same DMA channel, but no new resources will be
-allocated. The function will return the allocated channel number if successful.
-
-int dma_queue_buffer(dmach_t channel, dma_sghead_t *listhead);
-
-The user will construct a SGL in the form of below:
-/*
- * Scattered Gather DMA List for user
- */
-typedef struct _dma_desc
-{
- u32 NDAR; /* next descriptor adress [READONLY] */
- u32 PDAR; /* PCI address */
- u32 PUADR; /* upper PCI address */
- u32 LADR; /* local address */
- u32 BC; /* byte count */
- u32 DC; /* descriptor control */
-} dma_desc_t;
-
-typedef struct _dma_sgl
-{
- dma_desc_t dma_desc; /* DMA descriptor */
- u32 status; /* descriptor status [READONLY] */
- u32 data; /* user defined data */
- struct _dma_sgl *next; /* next descriptor [READONLY] */
-} dma_sgl_t;
-
-/* dma sgl head */
-typedef struct _dma_head
-{
- u32 total; /* total elements in SGL */
- u32 status; /* status of sgl */
- u32 mode; /* read or write mode */
- dma_sgl_t *list; /* pointer to list */
- dma_callback_t callback; /* callback function */
-} dma_head_t;
-
-
-The user shall allocate user SGL elements by calling the function:
-dma_get_buffer(). This function will give the user an SGL element. The user
-is responsible for creating the SGL head however. The user is also
-responsible for allocating the memory for DMA data. The following code segment
-shows how a DMA operation can be performed:
-
-#include <asm/arch/iop310-dma.h>
-
-void dma_test(void)
-{
- char dev_id[] = "Primary 0";
- dma_head_t *sgl_head = NULL;
- dma_sgl_t *sgl = NULL;
- int err = 0;
- int channel = -1;
- u32 *test_ptr = 0;
- DECLARE_WAIT_QUEUE_HEAD(wait_q);
-
-
- *(IOP310_ATUCR) = (IOP310_ATUCR_PRIM_OUT_ENAB |
- IOP310_ATUCR_DIR_ADDR_ENAB);
-
- channel = dma_request(IOP310_DMA_P0, dev_id);
-
- sgl_head = (dma_head_t *)kmalloc(sizeof(dma_head_t), GFP_KERNEL);
- sgl_head->callback = NULL; /* no callback created */
- sgl_head->total = 2; /* allocating 2 DMA descriptors */
- sgl_head->mode = (DMA_MOD_WRITE);
- sgl_head->status = 0;
-
- /* now we get the two descriptors */
- sgl = dma_get_buffer(channel, 2);
-
- /* we set the header to point to the list we allocated */
- sgl_head->list = sgl;
-
- /* allocate 1k of DMA data */
- sgl->data = (u32)kmalloc(1024, GFP_KERNEL);
-
- /* Local address is physical */
- sgl->dma_desc.LADR = (u32)virt_to_phys(sgl->data);
-
- /* write to arbitrary location over the PCI bus */
- sgl->dma_desc.PDAR = 0x00600000;
- sgl->dma_desc.PUADR = 0;
- sgl->dma_desc.BC = 1024;
-
- /* set write & invalidate PCI command */
- sgl->dma_desc.DC = DMA_DCR_PCI_MWI;
- sgl->status = 0;
-
- /* set a pattern */
- memset(sgl->data, 0xFF, 1024);
-
- /* User's responsibility to keep buffers cached coherent */
- cpu_dcache_clean(sgl->data, sgl->data + 1024);
-
- sgl = sgl->next;
-
- sgl->data = (u32)kmalloc(1024, GFP_KERNEL);
- sgl->dma_desc.LADR = (u32)virt_to_phys(sgl->data);
- sgl->dma_desc.PDAR = 0x00610000;
- sgl->dma_desc.PUADR = 0;
- sgl->dma_desc.BC = 1024;
-
- /* second descriptor has interrupt flag enabled */
- sgl->dma_desc.DC = (DMA_DCR_PCI_MWI | DMA_DCR_IE);
-
- /* must set end of chain flag */
- sgl->status = DMA_END_CHAIN; /* DO NOT FORGET THIS!!!! */
-
- memset(sgl->data, 0x0f, 1024);
- /* User's responsibility to keep buffers cached coherent */
- cpu_dcache_clean(sgl->data, sgl->data + 1024);
-
- /* queuing the buffer, this function will sleep since no callback */
- err = dma_queue_buffer(channel, sgl_head);
-
- /* now we are woken from DMA complete */
-
- /* do data operations here */
-
- /* free DMA data if necessary */
-
- /* return the descriptors */
- dma_return_buffer(channel, sgl_head->list);
-
- /* free the DMA */
- dma_free(channel);
-
- kfree((void *)sgl_head);
-}
-
-
-dma_sgl_t * dma_get_buffer(dmach_t channel, int buf_num);
-
-This call allocates DMA descriptors for the user.
-
-
-void dma_return_buffer(dmach_t channel, dma_sgl_t *list);
-
-This call returns the allocated descriptors back to the API.
-
-
-int dma_suspend(dmach_t channel);
-
-This call suspends any DMA transfer on the given channel.
-
-
-
-int dma_resume(dmach_t channel);
-
-This call resumes a DMA transfer which would have been stopped through
-dma_suspend().
-
-
-int dma_flush_all(dmach_t channel);
-
-This completely flushes all queued buffers and on-going DMA transfers on a
-given channel. This is called when DMA channel errors have occurred.
-
-
-void dma_free(dmach_t channel);
-
-This clears all activities on a given DMA channel and releases it for future
-requests.
-
-
-
-Buffer Allocation
------------------
-It is the user's responsibility to allocate, free, and keep track of the
-allocated DMA data memory. Upon calling dma_queue_buffer() the user must
-relinquish the control of the buffers to the kernel and not change the
-state of the buffers that it has passed to the kernel. The user will regain
-the control of the buffers when it has been woken up by the bottom half of
-the DMA interrupt handler. The user can allocate cached buffers or non-cached
-via pci_alloc_consistent(). It is the user's responsibility to ensure that
-the data is cache coherent.
-
-*Reminder*
-The user is responsble to ensure the ATU is setup properly for DMA transfers.
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible ifanything goes wrong.
+++ /dev/null
-Support functions for the Intel 80310 MU
-===========================================
-
-Dave Jiang <dave.jiang@intel.com>
-Last updated: 10/11/2001
-
-The messaging unit of the IOP310 contains 4 components and is utilized for
-passing messages between the PCI agents on the primary bus and the Intel(R)
-80200 CPU. The four components are:
-Messaging Component
-Doorbell Component
-Circular Queues Component
-Index Registers Component
-
-Messaging Component:
-Contains 4 32bit registers, 2 in and 2 out. Writing to the registers assert
-interrupt on the PCI bus or to the 80200 depend on incoming or outgoing.
-
-int mu_msg_request(u32 *mu_context);
-Request the usage of Messaging Component. mu_context is written back by the
-API. The MU context is passed to other Messaging calls as a parameter.
-
-int mu_msg_set_callback(u32 mu_context, u8 reg, mu_msg_cb_t func);
-Setup the callback function for incoming messages. Callback can be setup for
-outbound 0, 1, or both outbound registers.
-
-int mu_msg_post(u32 mu_context, u32 val, u8 reg);
-Posting a message in the val parameter. The reg parameter denotes whether
-to use register 0, 1.
-
-int mu_msg_free(u32 mu_context, u8 mode);
-Free the usage of messaging component. mode can be specified soft or hard. In
-hardmode all resources are unallocated.
-
-Doorbell Component:
-The doorbell registers contains 1 inbound and 1 outbound. Depending on the bits
-being set different interrupts are asserted.
-
-int mu_db_request(u32 *mu_context);
-Request the usage of the doorbell register.
-
-int mu_db_set_callback(u32 mu_context, mu_db_cb_t func);
-Setting up the inbound callback.
-
-void mu_db_ring(u32 mu_context, u32 mask);
-Write to the outbound db register with mask.
-
-int mu_db_free(u32 mu_context);
-Free the usage of doorbell component.
-
-Circular Queues Component:
-The circular queue component has 4 circular queues. Inbound post, inbound free,
-outbound post, outbound free. These queues are used to pass messages.
-
-int mu_cq_request(u32 *mu_context, u32 q_size);
-Request the usage of the queue. See code comment header for q_size. It tells
-the API how big of queues to setup.
-
-int mu_cq_inbound_init(u32 mu_context, mfa_list_t *list, u32 size,
- mu_cq_cb_t func);
-Init inbound queues. The user must provide a list of free message frames to
-be put in inbound free queue and the callback function to handle the inbound
-messages.
-
-int mu_cq_enable(u32 mu_context);
-Enables the circular queues mechanism. Called once all the setup functions
-are called.
-
-u32 mu_cq_get_frame(u32 mu_context);
-Obtain the address of an outbound free frame for the user.
-
-int mu_cq_post_frame(u32 mu_context, u32 mfa);
-The user can post the frame once getting the frame and put information in the
-frame.
-
-int mu_cq_free(u32 mu_context);
-Free the usage of circular queues mechanism.
-
-Index Registers Component:
-The index register provides the mechanism to receive inbound messages.
-
-int mu_ir_request(u32 *mu_context);
-Request of Index Register component usage.
-
-int mu_ir_set_callback(u32 mu_context, mu_ir_cb_t callback);
-Setting up callback for inbound messages. The callback will receive the
-value of the register that IAR offsets to.
-
-int mu_ir_free(u32 mu_context);
-Free the usage of Index Registers component.
-
-void mu_set_irq_threshold(u32 mu_context, int thresh);
-Setup the IRQ threshold before relinquish processing in IRQ space. Default
-is set at 10 loops.
-
-
-*NOTE: Example of host driver that utilize the MU can be found in the Linux I2O
-driver. Specifically i2o_pci and some functions of i2o_core. The I2O driver
-only utilize the circular queues mechanism. The other 3 components are simple
-enough that they can be easily setup. The MU API provides no flow control for
-the messaging mechanism. Flow control of the messaging needs to be established
-by a higher layer of software on the IOP or the host driver.
-
-All Disclaimers apply. Use this at your own discretion. Neither Intel nor I
-will be responsible if anything goes wrong. =)
-
-
-TODO
-____
-
+++ /dev/null
-
-Intel's XScale Microarchitecture 80312 companion processor provides a
-Performance Monitoring Unit (PMON) that can be utilized to provide
-information that can be useful for fine tuning of code. This text
-file describes the API that's been developed for use by Linux kernel
-programmers. Note that to get the most usage out of the PMON,
-I highly reccomend getting the XScale reference manual from Intel[1]
-and looking at chapter 12.
-
-To use the PMON, you must #include <asm-arm/arch-iop310/pmon.h> in your
-source file.
-
-Since there's only one PMON, only one user can currently use the PMON
-at a given time. To claim the PMON for usage, call iop310_pmon_claim() which
-returns an identifier. When you are done using the PMON, call
-iop310_pmon_release() with the id you were given earlier.
-
-The PMON consists of 14 registers that can be used for performance measurements.
-By combining different statistics, you can derive complex performance metrics.
-
-To start the PMON, just call iop310_pmon_start(mode). Mode tells the PMON what
-statistics to capture and can each be one of:
-
- IOP310_PMU_MODE0
- Performance Monitoring Disabled
-
- IOP310_PMU_MODE1
- Primary PCI bus and internal agents (bridge, dma Ch0, dam Ch1, patu)
-
- IOP310_PMU_MODE2
- Secondary PCI bus and internal agents (bridge, dma Ch0, dam Ch1, patu)
-
- IOP310_PMU_MODE3
- Secondary PCI bus and internal agents (external masters 0..2 and Intel
- 80312 I/O companion chip)
-
- IOP310_PMU_MODE4
- Secondary PCI bus and internal agents (external masters 3..5 and Intel
- 80312 I/O companion chip)
-
- IOP310_PMU_MODE5
- Intel 80312 I/O companion chip internal bus, DMA Channels and Application
- Accelerator
-
- IOP310_PMU_MODE6
- Intel 80312 I/O companion chip internal bus, PATU, SATU and Intel 80200
- processor
-
- IOP310_PMU_MODE7
- Intel 80312 I/O companion chip internal bus, Primary PCI bus, Secondary
- PCI bus and Secondary PCI agents (external masters 0..5 & Intel 80312 I/O
- companion chip)
-
-To get the results back, call iop310_pmon_stop(&results) where results is
-defined as follows:
-
-typedef struct _iop310_pmon_result
-{
- u32 timestamp; /* Global Time Stamp Register */
- u32 timestamp_overflow; /* Time Stamp overflow count */
- u32 event_count[14]; /* Programmable Event Counter
- Registers 1-14 */
- u32 event_overflow[14]; /* Overflow counter for PECR1-14 */
-} iop310_pmon_res_t;
-
-
---
-This code is still under development, so please feel free to send patches,
-questions, comments, etc to me.
-
-Deepak Saxena <dsaxena@mvista.com>
+++ /dev/null
-
-Intel's XScale Microarchitecture provides support for locking of data
-and instructions into the appropriate caches. This file provides
-an overview of the API that has been developed to take advantage of this
-feature from kernel space. Note that there is NO support for user space
-cache locking.
-
-For example usage of this code, grab:
-
- ftp://source.mvista.com/pub/xscale/cache-test.c
-
-If you have any questions, comments, patches, etc, please contact me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
-API DESCRIPTION
-
-
-I. Header File
-
- #include <asm/xscale-lock.h>
-
-II. Cache Capability Discovery
-
- SYNOPSIS
-
- int cache_query(u8 cache_type,
- struct cache_capabilities *pcache);
-
- struct cache_capabilities
- {
- u32 flags; /* Flags defining capabilities */
- u32 cache_size; /* Cache size in K (1024 bytes) */
- u32 max_lock; /* Maximum lockable region in K */
- }
-
- /*
- * Flags
- */
-
- /*
- * Bit 0: Cache lockability
- * Bits 1-31: Reserved for future use
- */
- #define CACHE_LOCKABLE 0x00000001 /* Cache can be locked */
-
- /*
- * Cache Types
- */
- #define ICACHE 0x00
- #define DCACHE 0x01
-
- DESCRIPTION
-
- This function fills out the pcache capability identifier for the
- requested cache. cache_type is either DCACHE or ICACHE. This
- function is not very useful at the moment as all XScale CPU's
- have the same size Cache, but is is provided for future XScale
- based processors that may have larger cache sizes.
-
- RETURN VALUE
-
- This function returns 0 if no error occurs, otherwise it returns
- a negative, errno compatible value.
-
- -EIO Unknown hardware error
-
-III. Cache Locking
-
- SYNOPSIS
-
- int cache_lock(void *addr, u32 len, u8 cache_type, const char *desc);
-
- DESCRIPTION
-
- This function locks a physically contigous portion of memory starting
- at the virtual address pointed to by addr into the cache referenced
- by cache_type.
-
- The address of the data/instruction that is to be locked must be
- aligned on a cache line boundary (L1_CACHE_ALIGNEMENT).
-
- The desc parameter is an optional (pass NULL if not used) human readable
- descriptor of the locked memory region that is used by the cache
- management code to build the /proc/cache_locks table.
-
- Note that this function does not check whether the address is valid
- or not before locking it into the cache. That duty is up to the
- caller. Also, it does not check for duplicate or overlaping
- entries.
-
- RETURN VALUE
-
- If the function is successful in locking the entry into cache, a
- zero is returned.
-
- If an error occurs, an appropriate error value is returned.
-
- -EINVAL The memory address provided was not cache line aligned
- -ENOMEM Could not allocate memory to complete operation
- -ENOSPC Not enough space left on cache to lock in requested region
- -EIO Unknown error
-
-III. Cache Unlocking
-
- SYNOPSIS
-
- int cache_unlock(void *addr)
-
- DESCRIPTION
-
- This function unlocks a portion of memory that was previously locked
- into either the I or D cache.
-
- RETURN VALUE
-
- If the entry is cleanly unlocked from the cache, a 0 is returned.
- In the case of an error, an appropriate error is returned.
-
- -ENOENT No entry with given address associated with this cache
- -EIO Unknown error
-
-
+++ /dev/null
-
-Intel's XScale Microarchitecture processors provide a Performance
-Monitoring Unit (PMU) that can be utilized to provide information
-that can be useful for fine tuning of code. This text file describes
-the API that's been developed for use by Linux kernel programmers.
-When I have some extra time on my hand, I will extend the code to
-provide support for user mode performance monitoring (which is
-probably much more useful). Note that to get the most usage out
-of the PMU, I highly reccomend getting the XScale reference manual
-from Intel and looking at chapter 12.
-
-To use the PMU, you must #include <asm/xscale-pmu.h> in your source file.
-
-Since there's only one PMU, only one user can currently use the PMU
-at a given time. To claim the PMU for usage, call pmu_claim() which
-returns an identifier. When you are done using the PMU, call
-pmu_release() with the identifier that you were given by pmu_claim.
-
-In addition, the PMU can only be used on XScale based systems that
-provide an external timer. Systems that the PMU is currently supported
-on are:
-
- - Cyclone IQ80310
-
-Before delving into how to use the PMU code, let's do a quick overview
-of the PMU itself. The PMU consists of three registers that can be
-used for performance measurements. The first is the CCNT register with
-provides the number of clock cycles elapsed since the PMU was started.
-The next two register, PMN0 and PMN1, are eace user programmable to
-provide 1 of 20 different performance statistics. By combining different
-statistics, you can derive complex performance metrics.
-
-To start the PMU, just call pmu_start(pm0, pmn1). pmn0 and pmn1 tell
-the PMU what statistics to capture and can each be one of:
-
-EVT_ICACHE_MISS
- Instruction fetches requiring access to external memory
-
-EVT_ICACHE_NO_DELIVER
- Instruction cache could not deliver an instruction. Either an
- ICACHE miss or an instruction TLB miss.
-
-EVT_ICACHE_DATA_STALL
- Stall in execution due to a data dependency. This counter is
- incremented each cycle in which the condition is present.
-
-EVT_ITLB_MISS
- Instruction TLB miss
-
-EVT_DTLB_MISS
- Data TLB miss
-
-EVT_BRANCH
- A branch instruction was executed and it may or may not have
- changed program flow
-
-EVT_BRANCH_MISS
- A branch (B or BL instructions only) was mispredicted
-
-EVT_INSTRUCTION
- An instruction was executed
-
-EVT_DCACHE_FULL_STALL
- Stall because data cache buffers are full. Incremented on every
- cycle in which condition is present.
-
-EVT_DCACHE_FULL_STALL_CONTIG
- Stall because data cache buffers are full. Incremented on every
- cycle in which condition is contigous.
-
-EVT_DCACHE_ACCESS
- Data cache access (data fetch)
-
-EVT_DCACHE_MISS
- Data cache miss
-
-EVT_DCACHE_WRITE_BACK
- Data cache write back. This counter is incremented for every
- 1/2 line (four words) that are written back.
-
-EVT_PC_CHANGED
- Software changed the PC. This is incremented only when the
- software changes the PC and there is no mode change. For example,
- a MOV instruction that targets the PC would increment the counter.
- An SWI would not as it triggers a mode change.
-
-EVT_BCU_REQUEST
- The Bus Control Unit(BCU) received a request from the core
-
-EVT_BCU_FULL
- The BCU request queue if full. A high value for this event means
- that the BCU is often waiting for to complete on the external bus.
-
-EVT_BCU_DRAIN
- The BCU queues were drained due to either a Drain Write Buffer
- command or an I/O transaction for a page that was marked as
- uncacheable and unbufferable.
-
-EVT_BCU_ECC_NO_ELOG
- The BCU detected an ECC error on the memory bus but noe ELOG
- register was available to to log the errors.
-
-EVT_BCU_1_BIT_ERR
- The BCU detected a 1-bit error while reading from the bus.
-
-EVT_RMW
- An RMW cycle occurred due to narrow write on ECC protected memory.
-
-To get the results back, call pmu_stop(&results) where results is defined
-as a struct pmu_results:
-
- struct pmu_results
- {
- u32 ccnt; /* Clock Counter Register */
- u32 ccnt_of; /
- u32 pmn0; /* Performance Counter Register 0 */
- u32 pmn0_of;
- u32 pmn1; /* Performance Counter Register 1 */
- u32 pmn1_of;
- };
-
-Pretty simple huh? Following are some examples of how to get some commonly
-wanted numbers out of the PMU data. Note that since you will be dividing
-things, this isn't super useful from the kernel and you need to printk the
-data out to syslog. See [1] for more examples.
-
-Instruction Cache Efficiency
-
- pmu_start(EVT_INSTRUCTION, EVT_ICACHE_MISS);
- ...
- pmu_stop(&results);
-
- icache_miss_rage = results.pmn1 / results.pmn0;
- cycles_per_instruction = results.ccnt / results.pmn0;
-
-Data Cache Efficiency
-
- pmu_start(EVT_DCACHE_ACCESS, EVT_DCACHE_MISS);
- ...
- pmu_stop(&results);
-
- dcache_miss_rage = results.pmn1 / results.pmn0;
-
-Instruction Fetch Latency
-
- pmu_start(EVT_ICACHE_NO_DELIVER, EVT_ICACHE_MISS);
- ...
- pmu_stop(&results);
-
- average_stall_waiting_for_instruction_fetch =
- results.pmn0 / results.pmn1;
-
- percent_stall_cycles_due_to_instruction_fetch =
- results.pmn0 / results.ccnt;
-
-
-ToDo:
-
-- Add support for usermode PMU usage. This might require hooking into
- the scheduler so that we pause the PMU when the task that requested
- statistics is scheduled out.
-
---
-This code is still under development, so please feel free to send patches,
-questions, comments, etc to me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
+++ /dev/null
-
-Intel's XScale Microarchitecture provides support for locking of TLB
-entries in both the instruction and data TLBs. This file provides
-an overview of the API that has been developed to take advantage of this
-feature from kernel space. Note that there is NO support for user space.
-
-In general, this feature should be used in conjunction with locking
-data or instructions into the appropriate caches. See the file
-cache-lock.txt in this directory.
-
-If you have any questions, comments, patches, etc, please contact me.
-
-Deepak Saxena <dsaxena@mvista.com>
-
-
-API DESCRIPTION
-
-I. Header file
-
- #include <asm/xscale-lock.h>
-
-II. Locking an entry into the TLB
-
- SYNOPSIS
-
- xscale_tlb_lock(u8 tlb_type, u32 addr);
-
- /*
- * TLB types
- */
- #define ITLB 0x0
- #define DTLB 0x1
-
- DESCRIPTION
-
- This function locks the virtual to physical mapping for virtual
- address addr into the requested TLB.
-
- RETURN VALUE
-
- If the entry is properly locked into the TLB, a 0 is returned.
- In case of an error, an appropriate error is returned.
-
- -ENOSPC No more entries left in the TLB
- -EIO Unknown error
-
-III. Unlocking an entry from a TLB
-
- SYNOPSIS
-
- xscale_tlb_unlock(u8 tlb_type, u32 addr);
-
- DESCRIPTION
-
- This function unlocks the entry for virtual address addr from the
- specified cache.
-
- RETURN VALUE
-
- If the TLB entry is properly unlocked, a 0 is returned.
- In case of an error, an appropriate error is returned.
-
- -ENOENT No entry for given address in specified TLB
-
+++ /dev/null
-Anticipatory IO scheduler
--------------------------
-Nick Piggin <piggin@cyberone.com.au> 13 Sep 2003
-
-Attention! Database servers, especially those using "TCQ" disks should
-investigate performance with the 'deadline' IO scheduler. Any system with high
-disk performance requirements should do so, in fact.
-
-If you see unusual performance characteristics of your disk systems, or you
-see big performance regressions versus the deadline scheduler, please email
-me. Database users don't bother unless you're willing to test a lot of patches
-from me ;) its a known issue.
-
-Also, users with hardware RAID controllers, doing striping, may find
-highly variable performance results with using the as-iosched. The
-as-iosched anticipatory implementation is based on the notion that a disk
-device has only one physical seeking head. A striped RAID controller
-actually has a head for each physical device in the logical RAID device.
-
-However, setting the antic_expire (see tunable parameters below) produces
-very similar behavior to the deadline IO scheduler.
-
-
-Selecting IO schedulers
------------------------
-To choose IO schedulers at boot time, use the argument 'elevator=deadline'.
-'noop' and 'as' (the default) are also available. IO schedulers are assigned
-globally at boot time only presently.
-
-
-Anticipatory IO scheduler Policies
-----------------------------------
-The as-iosched implementation implements several layers of policies
-to determine when an IO request is dispatched to the disk controller.
-Here are the policies outlined, in order of application.
-
-1. one-way Elevator algorithm.
-
-The elevator algorithm is similar to that used in deadline scheduler, with
-the addition that it allows limited backward movement of the elevator
-(i.e. seeks backwards). A seek backwards can occur when choosing between
-two IO requests where one is behind the elevator's current position, and
-the other is in front of the elevator's position. If the seek distance to
-the request in back of the elevator is less than half the seek distance to
-the request in front of the elevator, then the request in back can be chosen.
-Backward seeks are also limited to a maximum of MAXBACK (1024*1024) sectors.
-This favors forward movement of the elevator, while allowing opportunistic
-"short" backward seeks.
-
-2. FIFO expiration times for reads and for writes.
-
-This is again very similar to the deadline IO scheduler. The expiration
-times for requests on these lists is tunable using the parameters read_expire
-and write_expire discussed below. When a read or a write expires in this way,
-the IO scheduler will interrupt its current elevator sweep or read anticipation
-to service the expired request.
-
-3. Read and write request batching
-
-A batch is a collection of read requests or a collection of write
-requests. The as scheduler alternates dispatching read and write batches
-to the driver. In the case a read batch, the scheduler submits read
-requests to the driver as long as there are read requests to submit, and
-the read batch time limit has not been exceeded (read_batch_expire).
-The read batch time limit begins counting down only when there are
-competing write requests pending.
-
-In the case of a write batch, the scheduler submits write requests to
-the driver as long as there are write requests available, and the
-write batch time limit has not been exceeded (write_batch_expire).
-However, the length of write batches will be gradually shortened
-when read batches frequently exceed their time limit.
-
-When changing between batch types, the scheduler waits for all requests
-from the previous batch to complete before scheduling requests for the
-next batch.
-
-The read and write fifo expiration times described in policy 2 above
-are checked only when in scheduling IO of a batch for the corresponding
-(read/write) type. So for example, the read FIFO timeout values are
-tested only during read batches. Likewise, the write FIFO timeout
-values are tested only during write batches. For this reason,
-it is generally not recommended for the read batch time
-to be longer than the write expiration time, nor for the write batch
-time to exceed the read expiration time (see tunable parameters below).
-
-When the IO scheduler changes from a read to a write batch,
-it begins the elevator from the request that is on the head of the
-write expiration FIFO. Likewise, when changing from a write batch to
-a read batch, scheduler begins the elevator from the first entry
-on the read expiration FIFO.
-
-4. Read anticipation.
-
-Read anticipation occurs only when scheduling a read batch.
-This implementation of read anticipation allows only one read request
-to be dispatched to the disk controller at a time. In
-contrast, many write requests may be dispatched to the disk controller
-at a time during a write batch. It is this characteristic that can make
-the anticipatory scheduler perform anomalously with controllers supporting
-TCQ, or with hardware striped RAID devices. Setting the antic_expire
-queue paramter (see below) to zero disables this behavior, and the anticipatory
-scheduler behaves essentially like the deadline scheduler.
-
-When read anticipation is enabled (antic_expire is not zero), reads
-are dispatched to the disk controller one at a time.
-At the end of each read request, the IO scheduler examines its next
-candidate read request from its sorted read list. If that next request
-is from the same process as the request that just completed,
-or if the next request in the queue is "very close" to the
-just completed request, it is dispatched immediately. Otherwise,
-statistics (average think time, average seek distance) on the process
-that submitted the just completed request are examined. If it seems
-likely that that process will submit another request soon, and that
-request is likely to be near the just completed request, then the IO
-scheduler will stop dispatching more read requests for up time (antic_expire)
-milliseconds, hoping that process will submit a new request near the one
-that just completed. If such a request is made, then it is dispatched
-immediately. If the antic_expire wait time expires, then the IO scheduler
-will dispatch the next read request from the sorted read queue.
-
-To decide whether an anticipatory wait is worthwhile, the scheduler
-maintains statistics for each process that can be used to compute
-mean "think time" (the time between read requests), and mean seek
-distance for that process. One observation is that these statistics
-are associated with each process, but those statistics are not associated
-with a specific IO device. So for example, if a process is doing IO
-on several file systems on separate devices, the statistics will be
-a combination of IO behavior from all those devices.
-
-
-Tuning the anticipatory IO scheduler
-------------------------------------
-When using 'as', the anticipatory IO scheduler there are 5 parameters under
-/sys/block/*/iosched/. All are units of milliseconds.
-
-The parameters are:
-* read_expire
- Controls how long until a read request becomes "expired". It also controls the
- interval between which expired requests are served, so set to 50, a request
- might take anywhere < 100ms to be serviced _if_ it is the next on the
- expired list. Obviously request expiration strategies won't make the disk
- go faster. The result basically equates to the timeslice a single reader
- gets in the presence of other IO. 100*((seek time / read_expire) + 1) is
- very roughly the % streaming read efficiency your disk should get with
- multiple readers.
-
-* read_batch_expire
- Controls how much time a batch of reads is given before pending writes are
- served. A higher value is more efficient. This might be set below read_expire
- if writes are to be given higher priority than reads, but reads are to be
- as efficient as possible when there are no writes. Generally though, it
- should be some multiple of read_expire.
-
-* write_expire, and
-* write_batch_expire are equivalent to the above, for writes.
-
-* antic_expire
- Controls the maximum amount of time we can anticipate a good read (one
- with a short seek distance from the most recently completed request) before
- giving up. Many other factors may cause anticipation to be stopped early,
- or some processes will not be "anticipated" at all. Should be a bit higher
- for big seek time devices though not a linear correspondence - most
- processes have only a few ms thinktime.
-
+++ /dev/null
-Primitive parallel port is driver for i2c bus, which exploits
-features of modern bidirectional parallel ports.
-
-Bidirectional ports have particular bits connected in following way:
-
- |
- /-----| R
- --o| |-----|
- read \-----| /------- Out pin
- |/
- - -|\
- write V
- |
- ---
-
-
-It means when output is set to 1 we can read the port. Therefore
-we can use 2 pins of parallel port as SDA and SCL for i2c bus. It
-is not necessary to add any external - additional parts, we can
-read and write the same port simultaneously.
- I only use register base+2 so it is possible to use all
-8 data bits of parallel port for other applications (I have
-connected EEPROM and LCD display). I do not use bit Enable Bi-directional
- Port. The only disadvantage is we can only support 5V chips.
-
-Layout:
-
-Cannon 25 pin
-
-SDA - connect to pin 14 (Auto Linefeed)
-SCL - connect to pin 16 (Initialize Printer)
-GND - connect to pin 18-25
-+5V - use external supply (I use 5V from 3.5" floppy connector)
-
-no pullups requied
-
-Module parameters:
-
-base = 0xXXX
-XXX - 278 or 378
-
-That's all.
-
-Daniel Smolik
-marvin@sitour.cz
+++ /dev/null
-i2c-velleman driver
--------------------
-This is a driver for i2c-hw access for Velleman K8000 and other adapters.
-
-Useful links
-------------
-Velleman:
- http://www.velleman.be/
-
-Velleman K8000 Howto:
- http://howto.htlw16.ac.at/k8000-howto.html
-
-K8000 and K8005 libraries
--------------------------
-The project has lead to new libs for the Velleman K8000 and K8005:
-LIBK8000 v1.99.1 and LIBK8005 v0.21
-
-With these libs, you can control the K8000 interface card and the K8005
-stepper motor card with the simple commands which are in the original
-Velleman software, like SetIOchannel, ReadADchannel, SendStepCCWFull and
-many more, using /dev/velleman.
-
-The libs can be found on http://groups.yahoo.com/group/k8000/files/linux/
+++ /dev/null
-This file contains some additional information for the Philips and OEM webcams.
-E-mail: webcam@smcc.demon.nl Last updated: 2004-01-19
-Site: http://www.smcc.demon.nl/webcam/
-
-As of this moment, the following cameras are supported:
- * Philips PCA645
- * Philips PCA646
- * Philips PCVC675
- * Philips PCVC680
- * Philips PCVC690
- * Philips PCVC720/40
- * Philips PCVC730
- * Philips PCVC740
- * Philips PCVC750
- * Askey VC010
- * Creative Labs Webcam 5
- * Creative Labs Webcam Pro Ex
- * Logitech QuickCam 3000 Pro
- * Logitech QuickCam 4000 Pro
- * Logitech QuickCam Notebook Pro
- * Logitech QuickCam Zoom
- * Logitech QuickCam Orbit
- * Logitech QuickCam Sphere
- * Samsung MPC-C10
- * Samsung MPC-C30
- * Sotec Afina Eye
- * AME CU-001
- * Visionite VCS-UM100
- * Visionite VCS-UC300
-
-The main webpage for the Philips driver is at the address above. It contains
-a lot of extra information, a FAQ, and the binary plugin 'PWCX'. This plugin
-contains decompression routines that allow you to use higher image sizes and
-framerates; in addition the webcam uses less bandwidth on the USB bus (handy
-if you want to run more than 1 camera simultaneously). These routines fall
-under a NDA, and may therefor not be distributed as source; however, its use
-is completely optional.
-
-You can build this code either into your kernel, or as a module. I recommend
-the latter, since it makes troubleshooting a lot easier. The built-in
-microphone is supported through the USB Audio class.
-
-When you load the module you can set some default settings for the
-camera; some programs depend on a particular image-size or -format and
-don't know how to set it properly in the driver. The options are:
-
-size
- Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or
- 'vga', for an image size of resp. 128x96, 160x120, 176x144,
- 320x240, 352x288 and 640x480 (of course, only for those cameras that
- support these resolutions).
-
-fps
- Specifies the desired framerate. Is an integer in the range of 4-30.
-
-fbufs
- This paramter specifies the number of internal buffers to use for storing
- frames from the cam. This will help if the process that reads images from
- the cam is a bit slow or momentarely busy. However, on slow machines it
- only introduces lag, so choose carefully. The default is 3, which is
- reasonable. You can set it between 2 and 5.
-
-mbufs
- This is an integer between 1 and 10. It will tell the module the number of
- buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
- The default is 2, which is adequate for most applications (double
- buffering).
-
- Should you experience a lot of 'Dumping frame...' messages during
- grabbing with a tool that uses mmap(), you might want to increase if.
- However, it doesn't really buffer images, it just gives you a bit more
- slack when your program is behind. But you need a multi-threaded or
- forked program to really take advantage of these buffers.
-
- The absolute maximum is 10, but don't set it too high! Every buffer takes
- up 460 KB of RAM, so unless you have a lot of memory setting this to
- something more than 4 is an absolute waste. This memory is only
- allocated during open(), so nothing is wasted when the camera is not in
- use.
-
-power_save
- When power_save is enabled (set to 1), the module will try to shut down
- the cam on close() and re-activate on open(). This will save power and
- turn off the LED. Not all cameras support this though (the 645 and 646
- don't have power saving at all), and some models don't work either (they
- will shut down, but never wake up). Consider this experimental. By
- default this option is disabled.
-
-compression (only useful with the plugin)
- With this option you can control the compression factor that the camera
- uses to squeeze the image through the USB bus. You can set the
- parameter between 0 and 3:
- 0 = prefer uncompressed images; if the requested mode is not available
- in an uncompressed format, the driver will silently switch to low
- compression.
- 1 = low compression.
- 2 = medium compression.
- 3 = high compression.
-
- High compression takes less bandwidth of course, but it could also
- introduce some unwanted artefacts. The default is 2, medium compression.
- See the FAQ on the website for an overview of which modes require
- compression.
-
- The compression parameter does not apply to the 645 and 646 cameras
- and OEM models derived from those (only a few). Most cams honour this
- parameter.
-
-leds
- This settings takes 2 integers, that define the on/off time for the LED
- (in milliseconds). One of the interesting things that you can do with
- this is let the LED blink while the camera is in use. This:
-
- leds=500,500
-
- will blink the LED once every second. But with:
-
- leds=0,0
-
- the LED never goes on, making it suitable for silent surveillance.
-
- By default the camera's LED is on solid while in use, and turned off
- when the camera is not used anymore.
-
- This parameter works only with the ToUCam range of cameras (720, 730, 740,
- 750) and OEMs. For other cameras this command is silently ignored, and
- the LED cannot be controlled.
-
- Finally: this parameters does not take effect UNTIL the first time you
- open the camera device. Until then, the LED remains on.
-
-dev_hint
- A long standing problem with USB devices is their dynamic nature: you
- never know what device a camera gets assigned; it depends on module load
- order, the hub configuration, the order in which devices are plugged in,
- and the phase of the moon (i.e. it can be random). With this option you
- can give the driver a hint as to what video device node (/dev/videoX) it
- should use with a specific camera. This is also handy if you have two
- cameras of the same model.
-
- A camera is specified by its type (the number from the camera model,
- like PCA645, PCVC750VC, etc) and optionally the serial number (visible
- in /proc/bus/usb/devices). A hint consists of a string with the following
- format:
-
- [type[.serialnumber]:]node
-
- The square brackets mean that both the type and the serialnumber are
- optional, but a serialnumber cannot be specified without a type (which
- would be rather pointless). The serialnumber is separated from the type
- by a '.'; the node number by a ':'.
-
- This somewhat cryptic syntax is best explained by a few examples:
-
- dev_hint=3,5 The first detected cam gets assigned
- /dev/video3, the second /dev/video5. Any
- other cameras will get the first free
- available slot (see below).
-
- dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
- and a PCVC680 /dev/video2.
-
- dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
- 0123 goes to /dev/video3, the same
- camera model with the 4567 serial
- gets /dev/video0.
-
- dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
- next 3 Philips cams will use /dev/video4
- through /dev/video6.
-
- Some points worth knowing:
- - Serialnumbers are case sensitive and must be written full, including
- leading zeroes (it's treated as a string).
- - If a device node is already occupied, registration will fail and
- the webcam is not available.
- - You can have up to 64 video devices; be sure to make enough device
- nodes in /dev if you want to spread the numbers (this does not apply
- to devfs). After /dev/video9 comes /dev/video10 (not /dev/videoA).
- - If a camera does not match any dev_hint, it will simply get assigned
- the first available device node, just as it used to be.
-
-trace
- In order to better detect problems, it is now possible to turn on a
- 'trace' of some of the calls the module makes; it logs all items in your
- kernel log at debug level.
-
- The trace variable is a bitmask; each bit represents a certain feature.
- If you want to trace something, look up the bit value(s) in the table
- below, add the values together and supply that to the trace variable.
-
- Value Value Description Default
- (dec) (hex)
- 1 0x1 Module initialization; this will log messages On
- while loading and unloading the module
-
- 2 0x2 probe() and disconnect() traces On
-
- 4 0x4 Trace open() and close() calls Off
-
- 8 0x8 read(), mmap() and associated ioctl() calls Off
-
- 16 0x10 Memory allocation of buffers, etc. Off
-
- 32 0x20 Showing underflow, overflow and Dumping frame On
- messages
-
- 64 0x40 Show viewport and image sizes Off
-
- 128 0x80 PWCX debugging Off
-
- For example, to trace the open() & read() fuctions, sum 8 + 4 = 12,
- so you would supply trace=12 during insmod or modprobe. If
- you want to turn the initialization and probing tracing off, set trace=0.
- The default value for trace is 35 (0x23).
-
-
-
-Example:
-
- # modprobe pwc size=cif fps=15 power_save=1
-
-The fbufs, mbufs and trace parameters are global and apply to all connected
-cameras. Each camera has its own set of buffers.
-
-size and fps only specify defaults when you open() the device; this is to
-accommodate some tools that don't set the size. You can change these
-settings after open() with the Video4Linux ioctl() calls. The default of
-defaults is QCIF size at 10 fps.
-
-The compression parameter is semiglobal; it sets the initial compression
-preference for all camera's, but this parameter can be set per camera with
-the VIDIOCPWCSCQUAL ioctl() call.
-
-All parameters are optional.
-
+++ /dev/null
-/*
- * Alpha IO and memory functions.. Just expand the inlines in the header
- * files..
- */
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/string.h>
-
-#include <asm/io.h>
-
-u8 _inb(unsigned long addr)
-{
- return __inb(addr);
-}
-
-u16 _inw(unsigned long addr)
-{
- return __inw(addr);
-}
-
-u32 _inl(unsigned long addr)
-{
- return __inl(addr);
-}
-
-
-void _outb(u8 b, unsigned long addr)
-{
- __outb(b, addr);
-}
-
-void _outw(u16 b, unsigned long addr)
-{
- __outw(b, addr);
-}
-
-void _outl(u32 b, unsigned long addr)
-{
- __outl(b, addr);
-}
-
-u8 ___raw_readb(unsigned long addr)
-{
- return __readb(addr);
-}
-
-u16 ___raw_readw(unsigned long addr)
-{
- return __readw(addr);
-}
-
-u32 ___raw_readl(unsigned long addr)
-{
- return __readl(addr);
-}
-
-u64 ___raw_readq(unsigned long addr)
-{
- return __readq(addr);
-}
-
-u8 _readb(unsigned long addr)
-{
- unsigned long r = __readb(addr);
- mb();
- return r;
-}
-
-u16 _readw(unsigned long addr)
-{
- unsigned long r = __readw(addr);
- mb();
- return r;
-}
-
-u32 _readl(unsigned long addr)
-{
- unsigned long r = __readl(addr);
- mb();
- return r;
-}
-
-u64 _readq(unsigned long addr)
-{
- unsigned long r = __readq(addr);
- mb();
- return r;
-}
-
-void ___raw_writeb(u8 b, unsigned long addr)
-{
- __writeb(b, addr);
-}
-
-void ___raw_writew(u16 b, unsigned long addr)
-{
- __writew(b, addr);
-}
-
-void ___raw_writel(u32 b, unsigned long addr)
-{
- __writel(b, addr);
-}
-
-void ___raw_writeq(u64 b, unsigned long addr)
-{
- __writeq(b, addr);
-}
-
-void _writeb(u8 b, unsigned long addr)
-{
- __writeb(b, addr);
- mb();
-}
-
-void _writew(u16 b, unsigned long addr)
-{
- __writew(b, addr);
- mb();
-}
-
-void _writel(u32 b, unsigned long addr)
-{
- __writel(b, addr);
- mb();
-}
-
-void _writeq(u64 b, unsigned long addr)
-{
- __writeq(b, addr);
- mb();
-}
-
-/*
- * Read COUNT 8-bit bytes from port PORT into memory starting at
- * SRC.
- */
-void insb (unsigned long port, void *dst, unsigned long count)
-{
- while (((unsigned long)dst) & 0x3) {
- if (!count)
- return;
- count--;
- *(unsigned char *) dst = inb(port);
- dst += 1;
- }
-
- while (count >= 4) {
- unsigned int w;
- count -= 4;
- w = inb(port);
- w |= inb(port) << 8;
- w |= inb(port) << 16;
- w |= inb(port) << 24;
- *(unsigned int *) dst = w;
- dst += 4;
- }
-
- while (count) {
- --count;
- *(unsigned char *) dst = inb(port);
- dst += 1;
- }
-}
-
-
-/*
- * Read COUNT 16-bit words from port PORT into memory starting at
- * SRC. SRC must be at least short aligned. This is used by the
- * IDE driver to read disk sectors. Performance is important, but
- * the interfaces seems to be slow: just using the inlined version
- * of the inw() breaks things.
- */
-void insw (unsigned long port, void *dst, unsigned long count)
-{
- if (((unsigned long)dst) & 0x3) {
- if (((unsigned long)dst) & 0x1) {
- panic("insw: memory not short aligned");
- }
- if (!count)
- return;
- count--;
- *(unsigned short *) dst = inw(port);
- dst += 2;
- }
-
- while (count >= 2) {
- unsigned int w;
- count -= 2;
- w = inw(port);
- w |= inw(port) << 16;
- *(unsigned int *) dst = w;
- dst += 4;
- }
-
- if (count) {
- *(unsigned short*) dst = inw(port);
- }
-}
-
-
-/*
- * Read COUNT 32-bit words from port PORT into memory starting at
- * SRC. Now works with any alignment in SRC. Performance is important,
- * but the interfaces seems to be slow: just using the inlined version
- * of the inl() breaks things.
- */
-void insl (unsigned long port, void *dst, unsigned long count)
-{
- unsigned int l = 0, l2;
-
- if (!count)
- return;
-
- switch (((unsigned long) dst) & 0x3)
- {
- case 0x00: /* Buffer 32-bit aligned */
- while (count--)
- {
- *(unsigned int *) dst = inl(port);
- dst += 4;
- }
- break;
-
- /* Assuming little endian Alphas in cases 0x01 -- 0x03 ... */
-
- case 0x02: /* Buffer 16-bit aligned */
- --count;
-
- l = inl(port);
- *(unsigned short *) dst = l;
- dst += 2;
-
- while (count--)
- {
- l2 = inl(port);
- *(unsigned int *) dst = l >> 16 | l2 << 16;
- dst += 4;
- l = l2;
- }
- *(unsigned short *) dst = l >> 16;
- break;
-
- case 0x01: /* Buffer 8-bit aligned */
- --count;
-
- l = inl(port);
- *(unsigned char *) dst = l;
- dst += 1;
- *(unsigned short *) dst = l >> 8;
- dst += 2;
- while (count--)
- {
- l2 = inl(port);
- *(unsigned int *) dst = l >> 24 | l2 << 8;
- dst += 4;
- l = l2;
- }
- *(unsigned char *) dst = l >> 24;
- break;
-
- case 0x03: /* Buffer 8-bit aligned */
- --count;
-
- l = inl(port);
- *(unsigned char *) dst = l;
- dst += 1;
- while (count--)
- {
- l2 = inl(port);
- *(unsigned int *) dst = l << 24 | l2 >> 8;
- dst += 4;
- l = l2;
- }
- *(unsigned short *) dst = l >> 8;
- dst += 2;
- *(unsigned char *) dst = l >> 24;
- break;
- }
-}
-
-
-/*
- * Like insb but in the opposite direction.
- * Don't worry as much about doing aligned memory transfers:
- * doing byte reads the "slow" way isn't nearly as slow as
- * doing byte writes the slow way (no r-m-w cycle).
- */
-void outsb(unsigned long port, const void * src, unsigned long count)
-{
- while (count) {
- count--;
- outb(*(char *)src, port);
- src += 1;
- }
-}
-
-/*
- * Like insw but in the opposite direction. This is used by the IDE
- * driver to write disk sectors. Performance is important, but the
- * interfaces seems to be slow: just using the inlined version of the
- * outw() breaks things.
- */
-void outsw (unsigned long port, const void *src, unsigned long count)
-{
- if (((unsigned long)src) & 0x3) {
- if (((unsigned long)src) & 0x1) {
- panic("outsw: memory not short aligned");
- }
- outw(*(unsigned short*)src, port);
- src += 2;
- --count;
- }
-
- while (count >= 2) {
- unsigned int w;
- count -= 2;
- w = *(unsigned int *) src;
- src += 4;
- outw(w >> 0, port);
- outw(w >> 16, port);
- }
-
- if (count) {
- outw(*(unsigned short *) src, port);
- }
-}
-
-
-/*
- * Like insl but in the opposite direction. This is used by the IDE
- * driver to write disk sectors. Works with any alignment in SRC.
- * Performance is important, but the interfaces seems to be slow:
- * just using the inlined version of the outl() breaks things.
- */
-void outsl (unsigned long port, const void *src, unsigned long count)
-{
- unsigned int l = 0, l2;
-
- if (!count)
- return;
-
- switch (((unsigned long) src) & 0x3)
- {
- case 0x00: /* Buffer 32-bit aligned */
- while (count--)
- {
- outl(*(unsigned int *) src, port);
- src += 4;
- }
- break;
-
- case 0x02: /* Buffer 16-bit aligned */
- --count;
-
- l = *(unsigned short *) src << 16;
- src += 2;
-
- while (count--)
- {
- l2 = *(unsigned int *) src;
- src += 4;
- outl (l >> 16 | l2 << 16, port);
- l = l2;
- }
- l2 = *(unsigned short *) src;
- outl (l >> 16 | l2 << 16, port);
- break;
-
- case 0x01: /* Buffer 8-bit aligned */
- --count;
-
- l = *(unsigned char *) src << 8;
- src += 1;
- l |= *(unsigned short *) src << 16;
- src += 2;
- while (count--)
- {
- l2 = *(unsigned int *) src;
- src += 4;
- outl (l >> 8 | l2 << 24, port);
- l = l2;
- }
- l2 = *(unsigned char *) src;
- outl (l >> 8 | l2 << 24, port);
- break;
-
- case 0x03: /* Buffer 8-bit aligned */
- --count;
-
- l = *(unsigned char *) src << 24;
- src += 1;
- while (count--)
- {
- l2 = *(unsigned int *) src;
- src += 4;
- outl (l >> 24 | l2 << 8, port);
- l = l2;
- }
- l2 = *(unsigned short *) src;
- src += 2;
- l2 |= *(unsigned char *) src << 16;
- outl (l >> 24 | l2 << 8, port);
- break;
- }
-}
-
-
-/*
- * Copy data from IO memory space to "real" memory space.
- * This needs to be optimized.
- */
-void _memcpy_fromio(void * to, unsigned long from, long count)
-{
- /* Optimize co-aligned transfers. Everything else gets handled
- a byte at a time. */
-
- if (count >= 8 && ((unsigned long)to & 7) == (from & 7)) {
- count -= 8;
- do {
- *(u64 *)to = __raw_readq(from);
- count -= 8;
- to += 8;
- from += 8;
- } while (count >= 0);
- count += 8;
- }
-
- if (count >= 4 && ((unsigned long)to & 3) == (from & 3)) {
- count -= 4;
- do {
- *(u32 *)to = __raw_readl(from);
- count -= 4;
- to += 4;
- from += 4;
- } while (count >= 0);
- count += 4;
- }
-
- if (count >= 2 && ((unsigned long)to & 1) == (from & 1)) {
- count -= 2;
- do {
- *(u16 *)to = __raw_readw(from);
- count -= 2;
- to += 2;
- from += 2;
- } while (count >= 0);
- count += 2;
- }
-
- while (count > 0) {
- *(u8 *) to = __raw_readb(from);
- count--;
- to++;
- from++;
- }
-}
-
-/*
- * Copy data from "real" memory space to IO memory space.
- * This needs to be optimized.
- */
-void _memcpy_toio(unsigned long to, const void * from, long count)
-{
- /* Optimize co-aligned transfers. Everything else gets handled
- a byte at a time. */
- /* FIXME -- align FROM. */
-
- if (count >= 8 && (to & 7) == ((unsigned long)from & 7)) {
- count -= 8;
- do {
- __raw_writeq(*(const u64 *)from, to);
- count -= 8;
- to += 8;
- from += 8;
- } while (count >= 0);
- count += 8;
- }
-
- if (count >= 4 && (to & 3) == ((unsigned long)from & 3)) {
- count -= 4;
- do {
- __raw_writel(*(const u32 *)from, to);
- count -= 4;
- to += 4;
- from += 4;
- } while (count >= 0);
- count += 4;
- }
-
- if (count >= 2 && (to & 1) == ((unsigned long)from & 1)) {
- count -= 2;
- do {
- __raw_writew(*(const u16 *)from, to);
- count -= 2;
- to += 2;
- from += 2;
- } while (count >= 0);
- count += 2;
- }
-
- while (count > 0) {
- __raw_writeb(*(const u8 *) from, to);
- count--;
- to++;
- from++;
- }
- mb();
-}
-
-/*
- * "memset" on IO memory space.
- */
-void _memset_c_io(unsigned long to, unsigned long c, long count)
-{
- /* Handle any initial odd byte */
- if (count > 0 && (to & 1)) {
- __raw_writeb(c, to);
- to++;
- count--;
- }
-
- /* Handle any initial odd halfword */
- if (count >= 2 && (to & 2)) {
- __raw_writew(c, to);
- to += 2;
- count -= 2;
- }
-
- /* Handle any initial odd word */
- if (count >= 4 && (to & 4)) {
- __raw_writel(c, to);
- to += 4;
- count -= 4;
- }
-
- /* Handle all full-sized quadwords: we're aligned
- (or have a small count) */
- count -= 8;
- if (count >= 0) {
- do {
- __raw_writeq(c, to);
- to += 8;
- count -= 8;
- } while (count >= 0);
- }
- count += 8;
-
- /* The tail is word-aligned if we still have count >= 4 */
- if (count >= 4) {
- __raw_writel(c, to);
- to += 4;
- count -= 4;
- }
-
- /* The tail is half-word aligned if we have count >= 2 */
- if (count >= 2) {
- __raw_writew(c, to);
- to += 2;
- count -= 2;
- }
-
- /* And finally, one last byte.. */
- if (count) {
- __raw_writeb(c, to);
- }
- mb();
-}
-
-void
-scr_memcpyw(u16 *d, const u16 *s, unsigned int count)
-{
- if (! __is_ioaddr((unsigned long) s)) {
- /* Source is memory. */
- if (! __is_ioaddr((unsigned long) d))
- memcpy(d, s, count);
- else
- memcpy_toio(d, s, count);
- } else {
- /* Source is screen. */
- if (! __is_ioaddr((unsigned long) d))
- memcpy_fromio(d, s, count);
- else {
- /* FIXME: Should handle unaligned ops and
- operation widening. */
- count /= 2;
- while (count--) {
- u16 tmp = __raw_readw((unsigned long)(s++));
- __raw_writew(tmp, (unsigned long)(d++));
- }
- }
- }
-}
+++ /dev/null
-/*
- * linux/arch/arm/boot/compressed/head-ftvpci.S
- *
- * Copyright (C) 2000 FutureTV Labs Ltd.
- *
- * Special startup code for FTV PCI board.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
- .section ".start", "ax"
-ftv_start:
- mcr p15, 0, r0, c7, c5, 0 @ flush I cache
- mrc p15, 0, r0, c1, c0
- orr r0, r0, #1 << 12
- mcr p15, 0, r0, c1, c0 @ enable I cache
- mov r0, #0
- mcreq p15, 0, r0, c15, c1, 2 @ enable clock switching
-
- /* check to see if the kernel must be relocated */
- ldr ip, =ftv_start
- adr sl, ftv_start
- teq ip, sl
- beq 2f @ no need to copy
-
- /* in the wrong place -> presumably, executing out of ROM */
- sub ip, ip, sl @ displacement
- ldr lr, =_start @ destination
- sub sp, lr, ip @ source
- ldr fp, =_edata @ end of copied area
-1: ldmia sp!, {r0, r1, r2, r3, r4, r5, r6, r10}
- stmia lr!, {r0, r1, r2, r3, r4, r5, r6, r10}
- cmp lr, fp
- ble 1b
-
-2:
- mov r8, #0
- mov r7, #3
- b 1f
-.ltorg
-1:
- /* fall back into head.S */
+++ /dev/null
-#include <linux/ioport.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-int __init platform_add_device(struct platform_device *dev)
-{
- int i;
-
- for (i = 0; i < dev->num_resources; i++) {
- struct resource *r = &dev->resource[i];
-
- r->name = dev->dev.bus_id;
-
- if (r->flags & IORESOURCE_MEM &&
- request_resource(&iomem_resource, r)) {
- printk(KERN_ERR
- "%s%d: failed to claim resource %d\n",
- dev->name, dev->id, i);
- break;
- }
- }
- if (i == dev->num_resources)
- platform_device_register(dev);
- return 0;
-}
-
-int __init platform_add_devices(struct platform_device **devs, int num)
-{
- int i;
-
- for (i = 0; i < num; i++)
- platform_add_device(devs[i]);
-
- return 0;
-}
+++ /dev/null
-/*
- * Driver for PLX Technology PCI9000-series host bridge.
- *
- * Copyright (C) 1997, 1998, 1999, 2000 FutureTV Labs Ltd
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/ptrace.h>
-#include <asm/irq.h>
-#include <asm/mach/pci.h>
-
-/*
- * Since the following functions are all very similar, the common parts
- * are pulled out into these macros.
- */
-
-#define PLX_CLEAR_CONFIG \
- __raw_writel(0, PLX_BASE + 0xac); \
- local_irq_restore(flags); }
-
-#define PLX_SET_CONFIG \
- { unsigned long flags; \
- local_irq_save(flags); \
- __raw_writel((1<<31 | (bus->number << 16) \
- | (devfn << 8) | (where & ~3) \
- | ((bus->number == 0)?0:1)), PLX_BASE + 0xac); \
-
-#define PLX_CONFIG_WRITE(size) \
- PLX_SET_CONFIG \
- __raw_write##size(value, PCIO_BASE + (where & 3)); \
- if (__raw_readw(PLX_BASE + 0x6) & 0x2000) \
- __raw_writew(0x2000, PLX_BASE + 0x6); \
- PLX_CLEAR_CONFIG \
- return PCIBIOS_SUCCESSFUL;
-
-#define PLX_CONFIG_READ(size) \
- PLX_SET_CONFIG \
- *value = __raw_read##size(PCIO_BASE + (where & 3)); \
- if (__raw_readw(PLX_BASE + 0x6) & 0x2000) { \
- __raw_writew(0x2000, PLX_BASE + 0x6); \
- *value = 0xffffffffUL; \
- } \
- PLX_CLEAR_CONFIG \
- return PCIBIOS_SUCCESSFUL;
-
-/* Configuration space access routines */
-
-static int
-plx90x0_read_config (struct pci_bus *bus, unsigned int devfn, int where,
- int where, int size, u32 *value)
-{
- switch (size) {
- case 1:
- PLX_CONFIG_READ(b)
- break;
- case 2:
- PLX_CONFIG_READ(w)
- break;
- case 4:
- PLX_CONFIG_READ(l)
- break;
- }
- return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-plx90x0_write_config (struct pci_bus *bus, unsigned int devfn, int where,
- int where, int size, u32 value)
-{
- switch (size) {
- case 1:
- PLX_CONFIG_WRITE(b)
- break;
- case 2:
- PLX_CONFIG_WRITE(w)
- break;
- case 4:
- PLX_CONFIG_WRITE(l)
- break;
- }
- return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops plx90x0_ops =
-{
- .read = plx90x0_read_config,
- .write = plx90x0_write_config,
-};
-
-static void
-plx_syserr_handler(int irq, void *handle, struct pt_regs *regs)
-{
- printk("PLX90x0: machine check %04x (pc=%08lx)\n",
- readw(PLX_BASE + 6), regs->ARM_pc);
- __raw_writew(0xf000, PLX_BASE + 6);
-}
-
-/*
- * Initialise the PCI system.
- */
-
-void __init
-plx90x0_init(struct arm_sysdata *sysdata)
-{
- static const unsigned long int base = PLX_BASE;
- char *what;
- unsigned long bar = (unsigned long)virt_to_bus((void *)PAGE_OFFSET);
-
- /* Have a sniff around and see which PLX device is present. */
- unsigned long id = __raw_readl(base + 0xf0);
-
-#if 0
- /* This check was a good idea, but can fail. The PLX9060 puts no
- default value in these registers unless NB# is asserted (which it
- isn't on these cards). */
- if ((id & 0xffff) != PCI_VENDOR_ID_PLX)
- return; /* Nothing found */
-#endif
-
- /* Found one - now work out what it is. */
- switch (id >> 16) {
- case 0: /* PCI_DEVICE_ID_PLX_9060 */
- what = "PCI9060";
- break;
- case PCI_DEVICE_ID_PLX_9060ES:
- what = "PCI9060ES";
- break;
- case PCI_DEVICE_ID_PLX_9060SD:
- what = "PCI9060SD"; /* uhuhh.. */
- break;
- case PCI_DEVICE_ID_PLX_9080:
- what = "PCI9080";
- break;
- default:
- printk("PCI: Unknown PLX device %04lx found -- ignored.\n",
- id >> 16);
- return;
- }
-
- printk("PCI: PLX Technology %s host bridge found.\n", what);
-
- /* Now set it up for both master and slave accesses. */
- __raw_writel(0xffff0147, base + 0x4);
- __raw_writeb(32, base + 0xd);
- __raw_writel(0x8 | bar, base + 0x18);
- __raw_writel(0xf8000008, base + 0x80);
- __raw_writel(0x40000001, base + 0x84);
- __raw_writel(0, base + 0x88);
- __raw_writel(0, base + 0x8c);
- __raw_writel(0x11, base + 0x94);
- __raw_writel(0xC3 + (4 << 28)
- + (8 << 11) + (1 << 10)
- + (1 << 24), base + 0x98);
- __raw_writel(0xC0000000, base + 0x9c);
- __raw_writel(PLX_MEM_START, base + 0xa0);
- __raw_writel(PLX_IO_START, base + 0xa4);
- __raw_writel(0x3, base + 0xa8);
- __raw_writel(0, base + 0xac);
- __raw_writel(0x10001, base + 0xe8);
- __raw_writel(0x8000767e, base + 0xec);
-
- request_irq(IRQ_SYSERR, plx_syserr_handler, 0,
- "system error", NULL);
-
- pci_scan_bus(0, &plx90x0_ops, sysdata);
-}
+++ /dev/null
-#
-# Automatically generated by make menuconfig: don't edit
-#
-CONFIG_ARM=y
-# CONFIG_EISA is not set
-# CONFIG_SBUS is not set
-# CONFIG_MCA is not set
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
-# CONFIG_GENERIC_BUST_SPINLOCK is not set
-# CONFIG_GENERIC_ISA_DMA is not set
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-# CONFIG_OBSOLETE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_KMOD is not set
-
-#
-# System Type
-#
-CONFIG_ARCH_ADIFCC=y
-# CONFIG_ARCH_ARCA5K is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP310 is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_SHARK is not set
-
-#
-# Archimedes/A5000 Implementations
-#
-# CONFIG_ARCH_ARC is not set
-# CONFIG_ARCH_A5K is not set
-
-#
-# Footbridge Implementations
-#
-# CONFIG_ARCH_CATS is not set
-# CONFIG_ARCH_PERSONAL_SERVER is not set
-# CONFIG_ARCH_EBSA285_ADDIN is not set
-# CONFIG_ARCH_EBSA285_HOST is not set
-# CONFIG_ARCH_NETWINDER is not set
-
-#
-# SA11x0 Implementations
-#
-# CONFIG_SA1100_ASSABET is not set
-# CONFIG_ASSABET_NEPONSET is not set
-# CONFIG_SA1100_ADSBITSY is not set
-# CONFIG_SA1100_BRUTUS is not set
-# CONFIG_SA1100_CERF is not set
-# CONFIG_SA1100_H3600 is not set
-# CONFIG_SA1100_EXTENEX1 is not set
-# CONFIG_SA1100_FLEXANET is not set
-# CONFIG_SA1100_FREEBIRD is not set
-# CONFIG_SA1100_GRAPHICSCLIENT is not set
-# CONFIG_SA1100_GRAPHICSMASTER is not set
-# CONFIG_SA1100_JORNADA720 is not set
-# CONFIG_SA1100_HUW_WEBPANEL is not set
-# CONFIG_SA1100_ITSY is not set
-# CONFIG_SA1100_LART is not set
-# CONFIG_SA1100_NANOENGINE is not set
-# CONFIG_SA1100_OMNIMETER is not set
-# CONFIG_SA1100_PANGOLIN is not set
-# CONFIG_SA1100_PLEB is not set
-# CONFIG_SA1100_SHERMAN is not set
-# CONFIG_SA1100_SIMPAD is not set
-# CONFIG_SA1100_PFS168 is not set
-# CONFIG_SA1100_VICTOR is not set
-# CONFIG_SA1100_XP860 is not set
-# CONFIG_SA1100_YOPY is not set
-# CONFIG_SA1100_USB is not set
-# CONFIG_SA1100_USB_NETLINK is not set
-# CONFIG_SA1100_USB_CHAR is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-# CONFIG_ARCH_CDB89712 is not set
-# CONFIG_ARCH_CLEP7312 is not set
-# CONFIG_ARCH_EDB7211 is not set
-# CONFIG_ARCH_P720T is not set
-# CONFIG_ARCH_EP7211 is not set
-# CONFIG_ARCH_EP7212 is not set
-CONFIG_ARCH_ADI_EVB=y
-CONFIG_XSCALE_PMU_TIMER=y
-# CONFIG_ARCH_ACORN is not set
-# CONFIG_FOOTBRIDGE is not set
-# CONFIG_FOOTBRIDGE_HOST is not set
-# CONFIG_FOOTBRIDGE_ADDIN is not set
-CONFIG_CPU_32=y
-# CONFIG_CPU_26 is not set
-# CONFIG_CPU_32v3 is not set
-# CONFIG_CPU_32v4 is not set
-# CONFIG_CPU_ARM610 is not set
-# CONFIG_CPU_ARM710 is not set
-# CONFIG_CPU_ARM720T is not set
-# CONFIG_CPU_ARM920T is not set
-# CONFIG_CPU_ARM926T is not set
-# CONFIG_CPU_ARM1020 is not set
-# CONFIG_CPU_SA110 is not set
-# CONFIG_CPU_SA1100 is not set
-CONFIG_CPU_32v4=y
-CONFIG_CPU_XSCALE=y
-CONFIG_ARM_THUMB=y
-# CONFIG_XSCALE_TOOLS is not set
-CONFIG_XSCALE_WRITE_ALLOC=y
-CONFIG_XSCALE_PMU=y
-CONFIG_ARM_THUMB=y
-# CONFIG_DISCONTIGMEM is not set
-
-#
-# General setup
-#
-# CONFIG_PCI is not set
-# CONFIG_ISA is not set
-# CONFIG_ISA_DMA is not set
-# CONFIG_HOTPLUG is not set
-# CONFIG_PCMCIA is not set
-CONFIG_NET=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 mem=32M initrd=0xc0800000,3M"
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_BOOTLDR_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_AMDSTD is not set
-# CONFIG_MTD_SHARP is not set
-# CONFIG_MTD_JEDEC is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_NORA is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-# CONFIG_MTD_CDB89712 is not set
-# CONFIG_MTD_SA1100 is not set
-# CONFIG_MTD_DC21285 is not set
-# CONFIG_MTD_IQ80310 is not set
-CONFIG_MTD_ADI_EVB=y
-# CONFIG_MTD_PCI is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# CONFIG_MTD_DOC1000 is not set
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOCPROBE is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play configuration
-#
-# CONFIG_PNP is not set
-# CONFIG_ISAPNP is not set
-# CONFIG_PNPBIOS is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_DEV_XD is not set
-# CONFIG_PARIDE is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_CISS_SCSI_TAPE is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-# CONFIG_BLK_DEV_MD is not set
-# CONFIG_MD_LINEAR is not set
-# CONFIG_MD_RAID0 is not set
-# CONFIG_MD_RAID1 is not set
-# CONFIG_MD_RAID5 is not set
-# CONFIG_MD_MULTIPATH is not set
-# CONFIG_BLK_DEV_LVM is not set
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-CONFIG_NETLINK=y
-CONFIG_RTNETLINK=y
-# CONFIG_NETLINK_DEV is not set
-# CONFIG_NETFILTER is not set
-# CONFIG_FILTER is not set
-CONFIG_UNIX=y
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_IPV6 is not set
-# CONFIG_KHTTPD is not set
-# CONFIG_ATM is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_LLC is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_ARM_AM79C961A is not set
-# CONFIG_SUNLANCE is not set
-# CONFIG_SUNBMAC is not set
-# CONFIG_SUNQE is not set
-# CONFIG_SUNLANCE is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_LANCE is not set
-# CONFIG_NET_VENDOR_SMC is not set
-# CONFIG_NET_VENDOR_RACAL is not set
-# CONFIG_NET_ISA is not set
-# CONFIG_NET_PCI is not set
-# CONFIG_NET_POCKET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_MYRI_SBUS is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PLIP is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-# CONFIG_NET_FC is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# ATA/IDE/MFM/RLL support
-#
-# CONFIG_IDE is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI support
-#
-# CONFIG_SCSI is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-# CONFIG_I2O_BLOCK is not set
-# CONFIG_I2O_LAN is not set
-# CONFIG_I2O_SCSI is not set
-# CONFIG_I2O_PROC is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input core support
-#
-# CONFIG_INPUT is not set
-# CONFIG_INPUT_KEYBDEV is not set
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-CONFIG_SERIAL=y
-CONFIG_SERIAL_CONSOLE=y
-# CONFIG_SERIAL_EXTENDED is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_AMBA is not set
-# CONFIG_SERIAL_AMBA_CONSOLE is not set
-# CONFIG_SERIAL_CLPS711X is not set
-# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
-# CONFIG_SERIAL_21285 is not set
-# CONFIG_SERIAL_21285_OLD is not set
-# CONFIG_SERIAL_21285_CONSOLE is not set
-# CONFIG_SERIAL_UART00 is not set
-# CONFIG_SERIAL_UART00_CONSOLE is not set
-# CONFIG_SERIAL_SA1100 is not set
-# CONFIG_SERIAL_SA1100_CONSOLE is not set
-# CONFIG_SERIAL_8250 is not set
-# CONFIG_SERIAL_8250_CONSOLE is not set
-# CONFIG_SERIAL_8250_EXTENDED is not set
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-# CONFIG_SERIAL_8250_SHARE_IRQ is not set
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_MULTIPORT is not set
-# CONFIG_SERIAL_8250_HUB6 is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-# CONFIG_L3_ALGOBIT is not set
-# CONFIG_L3_BIT_SA1100_GPIO is not set
-# CONFIG_L3_SA1111 is not set
-# CONFIG_BIT_SA1100_GPIO is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-CONFIG_MOUSE=y
-CONFIG_PSMOUSE=y
-# CONFIG_82C710_MOUSE is not set
-# CONFIG_PC110_PAD is not set
-
-#
-# Joysticks
-#
-# CONFIG_INPUT_GAMEPORT is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_INTEL_RNG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# File systems
-#
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_REISERFS_CHECK is not set
-# CONFIG_ADFS_FS is not set
-# CONFIG_ADFS_FS_RW is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_CMS_FS is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_JBD_DEBUG is not set
-# CONFIG_FAT_FS is not set
-# CONFIG_MSDOS_FS is not set
-# CONFIG_UMSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_CRAMFS is not set
-# CONFIG_TMPFS is not set
-CONFIG_RAMFS=y
-# CONFIG_ISO9660_FS is not set
-# CONFIG_JOLIET is not set
-# CONFIG_ZISOFS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_FREEVXFS_FS is not set
-# CONFIG_NTFS_FS is not set
-# CONFIG_NTFS_DEBUG is not set
-# CONFIG_NTFS_RW is not set
-# CONFIG_HPFS_FS is not set
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-# CONFIG_DEVFS_MOUNT is not set
-# CONFIG_DEVFS_DEBUG is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_QNX4FS_RW is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_EXT2_FS=y
-# CONFIG_SYSV_FS is not set
-# CONFIG_UDF_FS is not set
-# CONFIG_UDF_RW is not set
-# CONFIG_UFS_FS is not set
-# CONFIG_UFS_FS_WRITE is not set
-
-#
-# Network File Systems
-#
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_NFS_FS is not set
-# CONFIG_NFS_V3 is not set
-# CONFIG_ROOT_NFS is not set
-# CONFIG_NFSD is not set
-# CONFIG_NFSD_V3 is not set
-# CONFIG_SUNRPC is not set
-# CONFIG_LOCKD is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_NCPFS_PACKET_SIGNING is not set
-# CONFIG_NCPFS_IOCTL_LOCKING is not set
-# CONFIG_NCPFS_STRONG is not set
-# CONFIG_NCPFS_NFS_NS is not set
-# CONFIG_NCPFS_OS2_NS is not set
-# CONFIG_NCPFS_SMALLDOS is not set
-# CONFIG_NCPFS_NLS is not set
-# CONFIG_NCPFS_EXTRAS is not set
-# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-# CONFIG_MSDOS_PARTITION is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_SMB_NLS is not set
-# CONFIG_NLS is not set
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-# CONFIG_MCP_SA1100 is not set
-# CONFIG_MCP_UCB1200 is not set
-# CONFIG_MCP_UCB1200_AUDIO is not set
-# CONFIG_MCP_UCB1200_TS is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_UHCI is not set
-# CONFIG_USB_UHCI_ALT is not set
-# CONFIG_USB_OHCI is not set
-# CONFIG_USB_OHCI_SA1111 is not set
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_BLUETOOTH is not set
-# CONFIG_USB_STORAGE is not set
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-# CONFIG_USB_STORAGE_FREECOM is not set
-# CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_HP8200e is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-# CONFIG_USB_DC2XX is not set
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_SCANNER is not set
-# CONFIG_USB_MICROTEK is not set
-# CONFIG_USB_HPUSBSCSI is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_CDCETHER is not set
-# CONFIG_USB_USBNET is not set
-# CONFIG_USB_USS720 is not set
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-# CONFIG_USB_SERIAL_GENERIC is not set
-# CONFIG_USB_SERIAL_BELKIN is not set
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
-# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
-# CONFIG_USB_SERIAL_EMPEG is not set
-# CONFIG_USB_SERIAL_FTDI_SIO is not set
-# CONFIG_USB_SERIAL_VISOR is not set
-# CONFIG_USB_SERIAL_IR is not set
-# CONFIG_USB_SERIAL_EDGEPORT is not set
-# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
-# CONFIG_USB_SERIAL_KEYSPAN is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
-# CONFIG_USB_SERIAL_MCT_U232 is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_ID75 is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_SLAB=y
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_NO_PGT_CACHE is not set
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_DC21285_PORT is not set
-# CONFIG_DEBUG_CLPS711X_UART2 is not set
+++ /dev/null
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_EMBEDDED is not set
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-# CONFIG_MODULE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-CONFIG_KMOD=y
-
-#
-# System Type
-#
-# CONFIG_ARCH_ADIFCC is not set
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-CONFIG_ARCH_IOP3XX=y
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_SHARK is not set
-
-#
-# CLPS711X/EP721X Implementations
-#
-
-#
-# Epxa10db
-#
-
-#
-# Footbridge Implementations
-#
-
-#
-# IOP3xx Implementation Options
-#
-CONFIG_ARCH_IQ80310=y
-# CONFIG_ARCH_IQ80321 is not set
-CONFIG_ARCH_IOP310=y
-# CONFIG_ARCH_IOP321 is not set
-
-#
-# IOP3xx Chipset Features
-#
-# CONFIG_IOP3XX_AAU is not set
-# CONFIG_IOP3XX_DMA is not set
-# CONFIG_IOP3XX_MU is not set
-# CONFIG_IOP3XX_PMON is not set
-
-#
-# ADIFCC Implementation Options
-#
-
-#
-# ADI Board Types
-#
-
-#
-# Intel PXA250/210 Implementations
-#
-
-#
-# SA11x0 Implementations
-#
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_XS80200=y
-CONFIG_CPU_32v5=y
-
-#
-# Processor Features
-#
-CONFIG_ARM_THUMB=y
-CONFIG_XSCALE_PMU=y
-
-#
-# General setup
-#
-CONFIG_PCI=y
-# CONFIG_ZBOOT_ROM is not set
-CONFIG_ZBOOT_ROM_TEXT=0x00060000
-CONFIG_ZBOOT_ROM_BSS=0xa1008000
-# CONFIG_PCI_LEGACY_PROC is not set
-CONFIG_PCI_NAMES=y
-# CONFIG_HOTPLUG is not set
-
-#
-# MMC/SD Card support
-#
-# CONFIG_MMC is not set
-
-#
-# At least one math emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-# CONFIG_FPE_NWFPE_XP is not set
-# CONFIG_FPE_FASTFPE is not set
-CONFIG_KCORE_ELF=y
-# CONFIG_KCORE_AOUT is not set
-CONFIG_BINFMT_AOUT=y
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_PM is not set
-# CONFIG_PREEMPT is not set
-# CONFIG_ARTHUR is not set
-CONFIG_CMDLINE="console=ttyS0,115200 ip=bootp mem=32M root=/dev/nfs initrd=0xc0800000,4M"
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_REDBOOT_PARTS=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IQ80310=y
-# CONFIG_MTD_EDB7312 is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNP is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_PACKET is not set
-# CONFIG_NETLINK_DEV is not set
-CONFIG_NETFILTER=y
-# CONFIG_NETFILTER_DEBUG is not set
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_INET_ECN is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-
-#
-# IP: Netfilter Configuration
-#
-# CONFIG_IP_NF_CONNTRACK is not set
-# CONFIG_IP_NF_QUEUE is not set
-# CONFIG_IP_NF_IPTABLES is not set
-# CONFIG_IP_NF_ARPTABLES is not set
-# CONFIG_IP_NF_COMPAT_IPCHAINS is not set
-# CONFIG_IP_NF_COMPAT_IPFWADM is not set
-
-#
-# IP: Virtual Server Configuration
-#
-# CONFIG_IP_VS is not set
-# CONFIG_IPV6 is not set
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-CONFIG_IPV6_SCTP__=y
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_LLC is not set
-# CONFIG_DECNET is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-CONFIG_NETDEVICES=y
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_SMC91X is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_EEPRO100_PIO is not set
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Token Ring devices (depends on LLC=y)
-#
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-
-#
-# IrDA (infrared) support
-#
-# CONFIG_IRDA is not set
-
-#
-# Amateur Radio support
-#
-# CONFIG_HAMRADIO is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-
-#
-# IDE, ATA and ATAPI Block devices
-#
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-# CONFIG_BLK_DEV_HD is not set
-CONFIG_BLK_DEV_IDEDISK=y
-# CONFIG_IDEDISK_MULTI_MODE is not set
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECD=y
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-# CONFIG_IDE_TASKFILE_IO is not set
-
-#
-# IDE chipset support/bugfixes
-#
-# CONFIG_BLK_DEV_IDEPCI is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# IEEE 1394 (FireWire) support (EXPERIMENTAL)
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN_BOOL is not set
-
-#
-# Input device support
-#
-# CONFIG_INPUT is not set
-
-#
-# Userland interfaces
-#
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-# CONFIG_SERIO is not set
-
-#
-# Input Device Drivers
-#
-
-#
-# Character devices
-#
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-# CONFIG_SERIAL_DZ is not set
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_UNIX98_PTY_COUNT=256
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# I2C Hardware Sensors Mainboard support
-#
-
-#
-# I2C Hardware Sensors Chip support
-#
-# CONFIG_I2C_SENSOR is not set
-
-#
-# L3 serial bus support
-#
-# CONFIG_L3 is not set
-
-#
-# Mice
-#
-# CONFIG_BUSMOUSE is not set
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-# CONFIG_WATCHDOG is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_HANGCHECK_TIMER is not set
-
-#
-# Multimedia devices
-#
-CONFIG_VIDEO_DEV=y
-
-#
-# Video For Linux
-#
-# CONFIG_VIDEO_PROC_FS is not set
-
-#
-# Video Adapters
-#
-# CONFIG_VIDEO_PMS is not set
-# CONFIG_VIDEO_CPIA is not set
-# CONFIG_VIDEO_STRADIS is not set
-# CONFIG_VIDEO_HEXIUM_ORION is not set
-# CONFIG_VIDEO_HEXIUM_GEMINI is not set
-
-#
-# Radio Adapters
-#
-# CONFIG_RADIO_GEMTEK_PCI is not set
-# CONFIG_RADIO_MAXIRADIO is not set
-# CONFIG_RADIO_MAESTRO is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-CONFIG_DVB=y
-CONFIG_DVB_CORE=y
-
-#
-# Supported Frontend Modules
-#
-# CONFIG_DVB_STV0299 is not set
-# CONFIG_DVB_ALPS_BSRV2 is not set
-# CONFIG_DVB_ALPS_TDLB7 is not set
-# CONFIG_DVB_ALPS_TDMB7 is not set
-# CONFIG_DVB_ATMEL_AT76C651 is not set
-# CONFIG_DVB_CX24110 is not set
-# CONFIG_DVB_GRUNDIG_29504_491 is not set
-# CONFIG_DVB_GRUNDIG_29504_401 is not set
-# CONFIG_DVB_MT312 is not set
-# CONFIG_DVB_VES1820 is not set
-# CONFIG_DVB_TDA1004X is not set
-
-#
-# Supported SAA7146 based PCI Adapters
-#
-# CONFIG_DVB_AV7110 is not set
-# CONFIG_DVB_BUDGET is not set
-
-#
-# Supported FlexCopII (B2C2) Adapters
-#
-# CONFIG_DVB_B2C2_SKYSTAR is not set
-# CONFIG_VIDEO_BTCX is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS=y
-# CONFIG_DEVPTS_FS_XATTR is not set
-CONFIG_TMPFS=y
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-# CONFIG_EXPORTFS is not set
-CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_GSS is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_NEC98_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia Capabilities Port drivers
-#
-# CONFIG_MCP is not set
-
-#
-# Console Switches
-#
-# CONFIG_SWITCHES is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-# CONFIG_USB_GADGET is not set
-
-#
-# Bluetooth support
-#
-# CONFIG_BT is not set
-
-#
-# Kernel hacking
-#
-CONFIG_FRAME_POINTER=y
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_INFO is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Library routines
-#
-# CONFIG_CRC32 is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
+++ /dev/null
-/*
- * linux/arch/arm/kernel/time-acorn.c
- *
- * Copyright (c) 1996-2000 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 24-Sep-1996 RMK Created
- * 10-Oct-1996 RMK Brought up to date with arch-sa110eval
- * 04-Dec-1997 RMK Updated for new arch/arm/time.c
- */
-#include <linux/timex.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/hardware/ioc.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-static unsigned long ioctime_gettimeoffset(void)
-{
- unsigned int count1, count2, status;
- long offset;
-
- ioc_writeb (0, IOC_T0LATCH);
- barrier ();
- count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
- barrier ();
- status = ioc_readb(IOC_IRQREQA);
- barrier ();
- ioc_writeb (0, IOC_T0LATCH);
- barrier ();
- count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
-
- offset = count2;
- if (count2 < count1) {
- /*
- * We have not had an interrupt between reading count1
- * and count2.
- */
- if (status & (1 << 5))
- offset -= LATCH;
- } else if (count2 > count1) {
- /*
- * We have just had another interrupt between reading
- * count1 and count2.
- */
- offset -= LATCH;
- }
-
- offset = (LATCH - offset) * (tick_nsec / 1000);
- return (offset + LATCH/2) / LATCH;
-}
-
-void __init ioctime_init(void)
-{
- ioc_writeb(LATCH & 255, IOC_T0LTCHL);
- ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
- ioc_writeb(0, IOC_T0GO);
-
- gettimeoffset = ioctime_gettimeoffset;
-}
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y := arch.o irq.o mm.o
-obj-m :=
-obj-n :=
-obj- :=
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-adifcc/arch.c
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/major.h>
-#include <linux/fs.h>
-
-#include <asm/setup.h>
-#include <asm/memory.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-
-extern void adifcc_map_io(void);
-extern void adifcc_init_irq(void);
-
-#ifdef CONFIG_ARCH_ADI_EVB
-MACHINE_START(ADI_EVB, "ADI 80200FCC Evaluation Board")
- MAINTAINER("MontaVista Software Inc.")
- BOOT_MEM(0xc0000000, 0x00400000, 0xff400000)
- MAPIO(adifcc_map_io)
- INITIRQ(adifcc_init_irq)
-MACHINE_END
-#endif
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-xscale/irq.c
- *
- * Author: Deepak Saxena
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Based on IOP80310 code. Currently there's nothing more than the
- * 80200 on chip interrupts. That'll change once the hardware adds
- * support for PCI though.
- */
-#include <linux/init.h>
-#include <linux/interrupt.h>
-
-#include <asm/mach/irq.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-
-static void xs80200_irq_mask (unsigned int irq)
-{
- long INTCTL;
- asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (INTCTL));
- switch (irq) {
- case IRQ_XS80200_BCU: INTCTL &= ~(1<<3); break;
- case IRQ_XS80200_PMU: INTCTL &= ~(1<<2); break;
- case IRQ_XS80200_EXTIRQ: INTCTL &= ~(1<<1); break;
- case IRQ_XS80200_EXTFIQ: INTCTL &= ~(1<<0); break;
- }
- asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (INTCTL));
-}
-
-static void xs80200_irq_unmask (unsigned int irq)
-{
- long INTCTL;
- asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (INTCTL));
- switch (irq) {
- case IRQ_XS80200_BCU: INTCTL |= (1<<3); break;
- case IRQ_XS80200_PMU: INTCTL |= (1<<2); break;
- case IRQ_XS80200_EXTIRQ: INTCTL |= (1<<1); break;
- case IRQ_XS80200_EXTFIQ: INTCTL |= (1<<0); break;
- }
- asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (INTCTL));
-}
-
-void __init adifcc_init_irq(void)
-{
- int i;
-
- for (i = 0; i < NR_XS80200_IRQS; i++) {
- irq_desc[i].valid = 1;
- irq_desc[i].probe_ok = 0;
- irq_desc[i].mask_ack = xs80200_irq_mask;
- irq_desc[i].mask = xs80200_irq_mask;
- irq_desc[i].unmask = xs80200_irq_unmask;
- }
-}
-
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-xscale/mm.c
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-
-
-static struct map_desc adifcc_io_desc[] __initdata = {
- /* on-board devices */
- { 0xff400000, 0x00400000, 0x00300000, MT_DEVICE }
-};
-
-void __init adifcc_map_io(void)
-{
- iotable_init(adifcc_io_desc, ARRAY_SIZE(adifcc_io_desc));
-}
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y := core.o
-obj-m :=
-obj-n :=
-obj- :=
-
-obj-$(CONFIG_PCI) += pci.o
-obj-$(CONFIG_LEDS) += leds.o
+++ /dev/null
-/*
- * linux/arch/arm/mach-ftvpci/core.c
- *
- * Architecture specific fixups.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/setup.h>
-#include <asm/mach-types.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-extern unsigned long soft_irq_mask;
-
-static const unsigned char irq_cmd[] =
-{
- INTCONT_IRQ_DUART,
- INTCONT_IRQ_PLX,
- INTCONT_IRQ_D,
- INTCONT_IRQ_C,
- INTCONT_IRQ_B,
- INTCONT_IRQ_A,
- INTCONT_IRQ_SYSERR
-};
-
-static void ftvpci_mask_irq(unsigned int irq)
-{
- __raw_writel(irq_cmd[irq], INTCONT_BASE);
- soft_irq_mask &= ~(1<<irq);
-}
-
-static void ftvpci_unmask_irq(unsigned int irq)
-{
- soft_irq_mask |= (1<<irq);
- __raw_writel(irq_cmd[irq] | 1, INTCONT_BASE);
-}
-
-static void __init ftvpci_init_irq(void)
-{
- unsigned int i;
-
- /* Mask all FIQs */
- __raw_writel(INTCONT_FIQ_PLX, INTCONT_BASE);
- __raw_writel(INTCONT_FIQ_D, INTCONT_BASE);
- __raw_writel(INTCONT_FIQ_C, INTCONT_BASE);
- __raw_writel(INTCONT_FIQ_B, INTCONT_BASE);
- __raw_writel(INTCONT_FIQ_A, INTCONT_BASE);
- __raw_writel(INTCONT_FIQ_SYSERR, INTCONT_BASE);
-
- /* Disable all interrupts initially. */
- for (i = 0; i < NR_IRQS; i++) {
- if (i >= FIRST_IRQ && i <= LAST_IRQ) {
- irq_desc[i].valid = 1;
- irq_desc[i].probe_ok = 1;
- irq_desc[i].mask_ack = ftvpci_mask_irq;
- irq_desc[i].mask = ftvpci_mask_irq;
- irq_desc[i].unmask = ftvpci_unmask_irq;
- ftvpci_mask_irq(i);
- } else {
- irq_desc[i].valid = 0;
- irq_desc[i].probe_ok = 0;
- }
- }
-}
-
-static struct map_desc ftvpci_io_desc[] __initdata = {
- { INTCONT_BASE, INTCONT_START, 0x00001000, MT_DEVICE },
- { PLX_BASE, PLX_START, 0x00001000, MT_DEVICE },
- { PCIO_BASE, PLX_IO_START, 0x00100000, MT_DEVICE },
- { DUART_BASE, DUART_START, 0x00001000, MT_DEVICE },
- { STATUS_BASE, STATUS_START, 0x00001000, MT_DEVICE }
-};
-
-static void __init ftvpci_map_io(void)
-{
- iotable_init(ftvpci_io_desc, ARRAY_SIZE(ftvpci_io_desc));
-}
-
-MACHINE_START(NEXUSPCI, "FTV/PCI")
- MAINTAINER("Philip Blundell")
- BOOT_MEM(0x40000000, 0x10000000, 0xe0000000)
- MAPIO(ftvpci_map_io)
- INITIRQ(ftvpci_init_irq)
-MACHINE_END
+++ /dev/null
-/*
- * linux/arch/arm/kernel/leds-ftvpci.c
- *
- * Copyright (C) 1999 FutureTV Labs Ltd
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-#include <asm/io.h>
-
-static void ftvpci_leds_event(led_event_t ledevt)
-{
- static int led_state = 0;
-
- switch(ledevt) {
- case led_timer:
- led_state ^= 1;
- raw_writeb(0x1a | led_state, INTCONT_BASE);
- break;
-
- default:
- break;
- }
-}
-
-static int __init ftvpci_leds_init(void)
-{
- leds_event = ftvpci_leds_event;
- return 0;
-}
-
-arch_initcall(ftvpci_leds_init);
+++ /dev/null
-/*
- * linux/arch/arm/kernel/ftv-pci.c
- *
- * PCI bios-type initialisation for PCI machines
- *
- * Bits taken from various places.
- */
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/irq.h>
-#include <asm/mach/pci.h>
-#include <asm/mach-types.h>
-
-/*
- * Owing to a PCB cockup, issue A backplanes are wired thus:
- *
- * Slot 1 2 3 4 5 Bridge S1 S2 S3 S4
- * IRQ D C B A A C B A D
- * A D C B B D C B A
- * B A D C C A D C B
- * C B A D D B A D C
- *
- * ID A31 A30 A29 A28 A27 A26 DEV4 DEV5 DEV6 DEV7
- *
- * Actually, this isn't too bad, because with the processor card
- * in slot 5 on the primary bus, the IRQs rotate on both sides
- * as you'd expect.
- */
-
-static int irqmap_ftv[] __initdata = { IRQ_PCI_D, IRQ_PCI_C, IRQ_PCI_B, IRQ_PCI_A };
-
-static int __init ftv_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
- if (slot > 0x10)
- slot--;
- return irqmap_ftv[(slot - pin) & 3];
-}
-
-static u8 __init ftv_swizzle(struct pci_dev *dev, u8 *pin)
-{
- return PCI_SLOT(dev->devfn);
-}
-
-/* ftv host-specific stuff */
-static struct hw_pci ftv_pci __initdata = {
- .init = plx90x0_init,
- .swizzle = ftv_swizzle,
- .map_irq = ftv_map_irq,
-};
-
-static int __init ftv_pci_init(void)
-{
- if (machine_is_ftvpci())
- pci_common_init(&ftv_pci);
- return 0;
-}
-
-subsys_initcall(ftv_pci_init);
+++ /dev/null
-/*
- * linux/arch/arm/mach-iop3xx/iop310-irq.c
- *
- * Generic IOP310 IRQ handling functionality
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Added IOP310 chipset and IQ80310 board demuxing, masking code. - DS
- *
- */
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/list.h>
-
-#include <asm/mach/irq.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-
-extern void xs80200_irq_mask(unsigned int);
-extern void xs80200_irq_unmask(unsigned int);
-extern void xs80200_init_irq(void);
-
-extern void do_IRQ(int, struct pt_regs *);
-
-static u32 iop310_mask /* = 0 */;
-
-static void iop310_irq_mask (unsigned int irq)
-{
- iop310_mask ++;
-
- /*
- * No mask bits on the 80312, so we have to
- * mask everything from the outside!
- */
- if (iop310_mask == 1) {
- disable_irq(IRQ_XS80200_EXTIRQ);
- irq_desc[IRQ_XS80200_EXTIRQ].chip->mask(IRQ_XS80200_EXTIRQ);
- }
-}
-
-static void iop310_irq_unmask (unsigned int irq)
-{
- if (iop310_mask)
- iop310_mask --;
-
- /*
- * Check if all 80312 sources are unmasked now
- */
- if (iop310_mask == 0)
- enable_irq(IRQ_XS80200_EXTIRQ);
-}
-
-struct irqchip ext_chip = {
- .ack = iop310_irq_mask,
- .mask = iop310_irq_mask,
- .unmask = iop310_irq_unmask,
-};
-
-void
-iop310_irq_demux(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
-{
- u32 fiq1isr = *((volatile u32*)IOP310_FIQ1ISR);
- u32 fiq2isr = *((volatile u32*)IOP310_FIQ2ISR);
- struct irqdesc *d;
- unsigned int irqno = 0;
-
- if(fiq1isr)
- {
- if(fiq1isr & 0x1)
- irqno = IRQ_IOP310_DMA0;
- if(fiq1isr & 0x2)
- irqno = IRQ_IOP310_DMA1;
- if(fiq1isr & 0x4)
- irqno = IRQ_IOP310_DMA2;
- if(fiq1isr & 0x10)
- irqno = IRQ_IOP310_PMON;
- if(fiq1isr & 0x20)
- irqno = IRQ_IOP310_AAU;
- }
- else
- {
- if(fiq2isr & 0x2)
- irqno = IRQ_IOP310_I2C;
- if(fiq2isr & 0x4)
- irqno = IRQ_IOP310_MU;
- }
-
- if (irqno) {
- d = irq_desc + irqno;
- d->handle(irqno, d, regs);
- }
-}
-
-void __init iop310_init_irq(void)
-{
- unsigned int i;
-
- for(i = IOP310_IRQ_OFS; i < NR_IOP310_IRQS; i++)
- {
- set_irq_chip(i, &ext_chip);
- set_irq_handler(i, do_level_IRQ);
- set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
- }
-
- xs80200_init_irq();
-}
+++ /dev/null
-/*
- * arch/arm/mach-iop3xx/iop310-pci.c
- *
- * PCI support for the Intel IOP310 chipset
- *
- * Matt Porter <mporter@mvista.com>
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-#include <asm/hardware.h>
-#include <asm/mach/pci.h>
-
-#include <asm/arch/iop310.h>
-
-/*
- * *** Special note - why the IOP310 should NOT be used ***
- *
- * The PCI ATU is a brain dead implementation, only allowing 32-bit
- * accesses to PCI configuration space. This is especially brain
- * dead for writes to this space. A simple for-instance:
- *
- * You want to modify the command register *without* corrupting the
- * status register.
- *
- * To perform this, you need to read *32* bits of data from offset 4,
- * mask off the low 16, replace them with the new data, and write *32*
- * bits back.
- *
- * Writing the status register at offset 6 with status bits set *clears*
- * the status.
- *
- * Hello? Could we have a *SANE* implementation of a PCI ATU some day
- * *PLEASE*?
- */
-#undef DEBUG
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...) do { } while (0)
-#endif
-
-/*
- * Calculate the address, etc from the bus, devfn and register
- * offset. Note that we have two root buses, so we need some
- * method to determine whether we need config type 0 or 1 cycles.
- * We use a root bus number in our bus->sysdata structure for this.
- */
-static u32 iop310_cfg_address(struct pci_bus *bus, int devfn, int where)
-{
- struct pci_sys_data *sys = bus->sysdata;
- u32 addr;
-
- if (sys->busnr == bus->number)
- addr = 1 << (PCI_SLOT(devfn) + 16);
- else
- addr = bus->number << 16 | PCI_SLOT(devfn) << 11 | 1;
-
- addr |= PCI_FUNC(devfn) << 8 | (where & ~3);
-
- return addr;
-}
-
-/*
- * Primary PCI interface support.
- */
-static int iop310_pri_pci_status(void)
-{
- unsigned int status;
- int ret = 0;
-
- status = *IOP310_PATUSR;
- if (status & 0xf900) {
- *IOP310_PATUSR = status & 0xf900;
- ret = 1;
- }
- status = *IOP310_PATUISR;
- if (status & 0x0000018f) {
- *IOP310_PATUISR = status & 0x0000018f;
- ret = 1;
- }
- status = *IOP310_PSR;
- if (status & 0xf900) {
- *IOP310_PSR = status & 0xf900;
- ret = 1;
- }
- status = *IOP310_PBISR;
- if (status & 0x003f) {
- *IOP310_PBISR = status & 0x003f;
- ret = 1;
- }
- return ret;
-}
-
-/*
- * Simply write the address register and read the configuration
- * data. Note that the 4 nop's ensure that we are able to handle
- * a delayed abort (in theory.)
- */
-static inline u32 iop310_pri_read(unsigned long addr)
-{
- u32 val;
-
- __asm__ __volatile__(
- "str %1, [%2]\n\t"
- "ldr %0, [%3]\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- : "=r" (val)
- : "r" (addr), "r" (IOP310_POCCAR), "r" (IOP310_POCCDR));
-
- return val;
-}
-
-static int
-iop310_pri_read_config(struct pci_bus *bus, unsigned int devfn, int where,
- int size, u32 *value)
-{
- unsigned long addr = iop310_cfg_address(bus, devfn, where);
- u32 val = iop310_pri_read(addr) >> ((where & 3) * 8);
-
- if (iop310_pri_pci_status())
- val = 0xffffffff;
-
- *value = val;
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-iop310_pri_write_config(struct pci_bus *bus, unsigned int devfn, int where,
- int size, u32 value)
-{
- unsigned long addr = iop310_cfg_address(bus, devfn, where);
- u32 val;
-
- if (size != 4) {
- val = iop310_pri_read(addr);
- if (!iop310_pri_pci_status() == 0)
- return PCIBIOS_SUCCESSFUL;
-
- where = (where & 3) * 8;
-
- if (size == 1)
- val &= ~(0xff << where);
- else
- val &= ~(0xffff << where);
-
- *IOP310_POCCDR = val | value << where;
- } else {
- asm volatile(
- "str %1, [%2]\n\t"
- "str %0, [%3]\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- :
- : "r" (value), "r" (addr),
- "r" (IOP310_POCCAR), "r" (IOP310_POCCDR));
- }
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops iop310_primary_ops = {
- .read = iop310_pri_read_config,
- .write = iop310_pri_write_config,
-};
-
-/*
- * Secondary PCI interface support.
- */
-static int iop310_sec_pci_status(void)
-{
- unsigned int usr, uisr;
- int ret = 0;
-
- usr = *IOP310_SATUSR;
- uisr = *IOP310_SATUISR;
- if (usr & 0xf900) {
- *IOP310_SATUSR = usr & 0xf900;
- ret = 1;
- }
- if (uisr & 0x0000069f) {
- *IOP310_SATUISR = uisr & 0x0000069f;
- ret = 1;
- }
- if (ret)
- DBG("ERROR (%08x %08x)", usr, uisr);
- return ret;
-}
-
-/*
- * Simply write the address register and read the configuration
- * data. Note that the 4 nop's ensure that we are able to handle
- * a delayed abort (in theory.)
- */
-static inline u32 iop310_sec_read(unsigned long addr)
-{
- u32 val;
-
- __asm__ __volatile__(
- "str %1, [%2]\n\t"
- "ldr %0, [%3]\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- : "=r" (val)
- : "r" (addr), "r" (IOP310_SOCCAR), "r" (IOP310_SOCCDR));
-
- return val;
-}
-
-static int
-iop310_sec_read_config(struct pci_bus *bus, unsigned int devfn, int where,
- int size, u32 *value)
-{
- unsigned long addr = iop310_cfg_address(bus, devfn, where);
- u32 val = iop310_sec_read(addr) >> ((where & 3) * 8);
-
- if (iop310_sec_pci_status())
- val = 0xffffffff;
-
- *value = val;
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-iop310_sec_write_config(struct pci_bus *bus, unsigned int devfn, int where,
- int size, u32 value)
-{
- unsigned long addr = iop310_cfg_address(bus, devfn, where);
- u32 val;
-
- if (size != 4) {
- val = iop310_sec_read(addr);
-
- if (!iop310_sec_pci_status() == 0)
- return PCIBIOS_SUCCESSFUL;
-
- where = (where & 3) * 8;
-
- if (size == 1)
- val &= ~(0xff << where);
- else
- val &= ~(0xffff << where);
-
- *IOP310_SOCCDR = val | value << where;
- } else {
- asm volatile(
- "str %1, [%2]\n\t"
- "str %0, [%3]\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- :
- : "r" (value), "r" (addr),
- "r" (IOP310_SOCCAR), "r" (IOP310_SOCCDR));
- }
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops iop310_secondary_ops = {
- .read = iop310_sec_read_config,
- .write = iop310_sec_write_config,
-};
-
-/*
- * When a PCI device does not exist during config cycles, the 80200 gets
- * an external abort instead of returning 0xffffffff. If it was an
- * imprecise abort, we need to correct the return address to point after
- * the instruction. Also note that the Xscale manual says:
- *
- * "if a stall-until-complete LD or ST instruction triggers an
- * imprecise fault, then that fault will be seen by the program
- * within 3 instructions."
- *
- * This does not appear to be the case. With 8 NOPs after the load, we
- * see the imprecise abort occurring on the STM of iop310_sec_pci_status()
- * which is about 10 instructions away.
- *
- * Always trust reality!
- */
-static int
-iop310_pci_abort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
-{
- DBG("PCI abort: address = 0x%08lx fsr = 0x%03x PC = 0x%08lx LR = 0x%08lx\n",
- addr, fsr, regs->ARM_pc, regs->ARM_lr);
-
- /*
- * If it was an imprecise abort, then we need to correct the
- * return address to be _after_ the instruction.
- */
- if (fsr & (1 << 10))
- regs->ARM_pc += 4;
-
- return 0;
-}
-
-/*
- * Scan an IOP310 PCI bus. sys->bus defines which bus we scan.
- */
-struct pci_bus *iop310_scan_bus(int nr, struct pci_sys_data *sys)
-{
- struct pci_ops *ops;
-
- if (nr)
- ops = &iop310_secondary_ops;
- else
- ops = &iop310_primary_ops;
-
- return pci_scan_bus(sys->busnr, ops, sys);
-}
-
-/*
- * Setup the system data for controller 'nr'. Return 0 if none found,
- * 1 if found, or negative error.
- *
- * We can alter:
- * io_offset - offset between IO resources and PCI bus BARs
- * mem_offset - offset between mem resources and PCI bus BARs
- * resource[0] - parent IO resource
- * resource[1] - parent non-prefetchable memory resource
- * resource[2] - parent prefetchable memory resource
- * swizzle - bridge swizzling function
- * map_irq - irq mapping function
- *
- * Note that 'io_offset' and 'mem_offset' are left as zero since
- * the IOP310 doesn't attempt to perform any address translation
- * on accesses from the host to the bus.
- */
-int iop310_setup(int nr, struct pci_sys_data *sys)
-{
- struct resource *res;
-
- if (nr >= 2)
- return 0;
-
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
- if (!res)
- panic("PCI: unable to alloc resources");
-
- memset(res, 0, sizeof(struct resource) * 2);
-
- switch (nr) {
- case 0:
- res[0].start = IOP310_PCIPRI_LOWER_IO + 0x6e000000;
- res[0].end = IOP310_PCIPRI_LOWER_IO + 0x6e00ffff;
- res[0].name = "PCI IO Primary";
- res[0].flags = IORESOURCE_IO;
-
- res[1].start = IOP310_PCIPRI_LOWER_MEM;
- res[1].end = IOP310_PCIPRI_LOWER_MEM + IOP310_PCI_WINDOW_SIZE;
- res[1].name = "PCI Memory Primary";
- res[1].flags = IORESOURCE_MEM;
- break;
-
- case 1:
- res[0].start = IOP310_PCISEC_LOWER_IO + 0x6e000000;
- res[0].end = IOP310_PCISEC_LOWER_IO + 0x6e00ffff;
- res[0].name = "PCI IO Secondary";
- res[0].flags = IORESOURCE_IO;
-
- res[1].start = IOP310_PCISEC_LOWER_MEM;
- res[1].end = IOP310_PCISEC_LOWER_MEM + IOP310_PCI_WINDOW_SIZE;
- res[1].name = "PCI Memory Secondary";
- res[1].flags = IORESOURCE_MEM;
- break;
- }
-
- request_resource(&ioport_resource, &res[0]);
- request_resource(&iomem_resource, &res[1]);
-
- sys->resource[0] = &res[0];
- sys->resource[1] = &res[1];
- sys->resource[2] = NULL;
- sys->io_offset = 0x6e000000;
-
- return 1;
-}
-
-void iop310_init(void)
-{
- DBG("PCI: Intel 80312 PCI-to-PCI init code.\n");
- DBG(" ATU secondary: ATUCR =0x%08x\n", *IOP310_ATUCR);
- DBG(" ATU secondary: SOMWVR=0x%08x SOIOWVR=0x%08x\n",
- *IOP310_SOMWVR, *IOP310_SOIOWVR);
- DBG(" ATU secondary: SIABAR=0x%08x SIALR =0x%08x SIATVR=%08x\n",
- *IOP310_SIABAR, *IOP310_SIALR, *IOP310_SIATVR);
- DBG(" ATU primary: POMWVR=0x%08x POIOWVR=0x%08x\n",
- *IOP310_POMWVR, *IOP310_POIOWVR);
- DBG(" ATU primary: PIABAR=0x%08x PIALR =0x%08x PIATVR=%08x\n",
- *IOP310_PIABAR, *IOP310_PIALR, *IOP310_PIATVR);
- DBG(" P2P: PCR=0x%04x BCR=0x%04x EBCR=0x%04x\n",
- *IOP310_PCR, *IOP310_BCR, *IOP310_EBCR);
-
- /*
- * Windows have to be carefully opened via a nice set of calls
- * here or just some direct register fiddling in the board
- * specific init when we want transactions to occur between the
- * two PCI hoses.
- *
- * To do this, we will have manage RETRY assertion between the
- * firmware and the kernel. This will ensure that the host
- * system's enumeration code is held off until we have tweaked
- * the interrupt routing and public/private IDSELs.
- *
- * For now we will simply default to disabling the integrated type
- * 81 P2P bridge.
- */
- *IOP310_PCR &= 0xfff8;
-
- hook_fault_code(16+6, iop310_pci_abort, SIGBUS, "imprecise external abort");
-}
+++ /dev/null
-/*
- * linux/arch/arm/mach-iop3xx/iq80310-irq.c
- *
- * IRQ hadling/demuxing for IQ80310 board
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * 2.4.7-rmk1-iop310.1
- * Moved demux from asm to C - DS
- * Fixes for various revision boards - DS
- */
-#include <linux/init.h>
-#include <linux/list.h>
-
-#include <asm/irq.h>
-#include <asm/mach/irq.h>
-#include <asm/hardware.h>
-#include <asm/system.h>
-
-extern void iop310_init_irq(void);
-extern void iop310_irq_demux(unsigned int, struct irqdesc *, struct pt_regs *);
-
-static void iq80310_irq_mask(unsigned int irq)
-{
- *(volatile char *)IQ80310_INT_MASK |= (1 << (irq - IQ80310_IRQ_OFS));
-}
-
-static void iq80310_irq_unmask(unsigned int irq)
-{
- *(volatile char *)IQ80310_INT_MASK &= ~(1 << (irq - IQ80310_IRQ_OFS));
-}
-
-static struct irqchip iq80310_irq_chip = {
- .ack = iq80310_irq_mask,
- .mask = iq80310_irq_mask,
- .unmask = iq80310_irq_unmask,
-};
-
-extern struct irqchip ext_chip;
-
-static void
-iq80310_cpld_irq_handler(unsigned int irq, struct irqdesc *desc,
- struct pt_regs *regs)
-{
- unsigned int irq_stat = *(volatile u8*)IQ80310_INT_STAT;
- unsigned int irq_mask = *(volatile u8*)IQ80310_INT_MASK;
- unsigned int i, handled = 0;
- struct irqdesc *d;
-
- desc->chip->ack(irq);
-
- /*
- * Mask out the interrupts which aren't enabled.
- */
- irq_stat &= 0x1f & ~irq_mask;
-
- /*
- * Test each IQ80310 CPLD interrupt
- */
- for (i = IRQ_IQ80310_TIMER, d = irq_desc + IRQ_IQ80310_TIMER;
- irq_stat; i++, d++, irq_stat >>= 1)
- if (irq_stat & 1) {
- d->handle(i, d, regs);
- handled++;
- }
-
- /*
- * If running on a board later than REV D.1, we can
- * decode the PCI interrupt status.
- */
- if (system_rev) {
- irq_stat = *((volatile u8*)IQ80310_PCI_INT_STAT) & 7;
-
- for (i = IRQ_IQ80310_INTA, d = irq_desc + IRQ_IQ80310_INTA;
- irq_stat; i++, d++, irq_stat >>= 1)
- if (irq_stat & 0x1) {
- d->handle(i, d, regs);
- handled++;
- }
- }
-
- /*
- * If on a REV D.1 or lower board, we just assumed INTA
- * since PCI is not routed, and it may actually be an
- * on-chip interrupt.
- *
- * Note that we're giving on-chip interrupts slightly
- * higher priority than PCI by handling them first.
- *
- * On boards later than REV D.1, if we didn't read a
- * CPLD interrupt, we assume it's from a device on the
- * chipset itself.
- */
- if (system_rev == 0 || handled == 0)
- iop310_irq_demux(irq, desc, regs);
-
- desc->chip->unmask(irq);
-}
-
-void __init iq80310_init_irq(void)
-{
- volatile char *mask = (volatile char *)IQ80310_INT_MASK;
- unsigned int i;
-
- iop310_init_irq();
-
- /*
- * Setup PIRSR to route PCI interrupts into xs80200
- */
- *IOP310_PIRSR = 0xff;
-
- /*
- * Setup the IRQs in the FE820000/FE860000 registers
- */
- for (i = IQ80310_IRQ_OFS; i <= IRQ_IQ80310_INTD; i++) {
- set_irq_chip(i, &iq80310_irq_chip);
- set_irq_handler(i, do_level_IRQ);
- set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
- }
-
- /*
- * Setup the PCI IRQs
- */
- for (i = IRQ_IQ80310_INTA; i < IRQ_IQ80310_INTC; i++) {
- set_irq_chip(i, &ext_chip);
- set_irq_handler(i, do_level_IRQ);
- set_irq_flags(i, IRQF_VALID);
- }
-
- *mask = 0xff; /* mask all sources */
-
- set_irq_chained_handler(IRQ_XS80200_EXTIRQ,
- &iq80310_cpld_irq_handler);
-}
+++ /dev/null
-/*
- * arch/arm/mach-iop3xx/iq80310-pci.c
- *
- * PCI support for the Intel IQ80310 reference board
- *
- * Matt Porter <mporter@mvista.com>
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/hardware.h>
-#include <asm/irq.h>
-#include <asm/mach/pci.h>
-#include <asm/mach-types.h>
-
-/*
- * The following macro is used to lookup irqs in a standard table
- * format for those systems that do not already have PCI
- * interrupts properly routed. We assume 1 <= pin <= 4
- */
-#define PCI_IRQ_TABLE_LOOKUP(minid,maxid) \
-({ int _ctl_ = -1; \
- unsigned int _idsel = idsel - minid; \
- if (_idsel <= maxid) \
- _ctl_ = pci_irq_table[_idsel][pin-1]; \
- _ctl_; })
-
-#define INTA IRQ_IQ80310_INTA
-#define INTB IRQ_IQ80310_INTB
-#define INTC IRQ_IQ80310_INTC
-#define INTD IRQ_IQ80310_INTD
-
-#define INTE IRQ_IQ80310_I82559
-
-typedef u8 irq_table[4];
-
-/*
- * IRQ tables for primary bus.
- *
- * On a Rev D.1 and older board, INT A-C are not routed, so we
- * just fake it as INTA and than we take care of handling it
- * correctly in the IRQ demux routine.
- */
-static irq_table pci_pri_d_irq_table[] = {
-/* Pin: A B C D */
- { INTA, INTD, INTA, INTA }, /* PCI Slot J3 */
- { INTD, INTA, INTA, INTA }, /* PCI Slot J4 */
-};
-
-static irq_table pci_pri_f_irq_table[] = {
-/* Pin: A B C D */
- { INTC, INTD, INTA, INTB }, /* PCI Slot J3 */
- { INTD, INTA, INTB, INTC }, /* PCI Slot J4 */
-};
-
-static int __init
-iq80310_pri_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
-{
- irq_table *pci_irq_table;
-
- BUG_ON(pin < 1 || pin > 4);
-
- if (!system_rev) {
- pci_irq_table = pci_pri_d_irq_table;
- } else {
- pci_irq_table = pci_pri_f_irq_table;
- }
-
- return PCI_IRQ_TABLE_LOOKUP(2, 3);
-}
-
-/*
- * IRQ tables for secondary bus.
- *
- * On a Rev D.1 and older board, INT A-C are not routed, so we
- * just fake it as INTA and than we take care of handling it
- * correctly in the IRQ demux routine.
- */
-static irq_table pci_sec_d_irq_table[] = {
-/* Pin: A B C D */
- { INTA, INTA, INTA, INTD }, /* PCI Slot J1 */
- { INTA, INTA, INTD, INTA }, /* PCI Slot J5 */
- { INTE, INTE, INTE, INTE }, /* P2P Bridge */
-};
-
-static irq_table pci_sec_f_irq_table[] = {
-/* Pin: A B C D */
- { INTA, INTB, INTC, INTD }, /* PCI Slot J1 */
- { INTB, INTC, INTD, INTA }, /* PCI Slot J5 */
- { INTE, INTE, INTE, INTE }, /* P2P Bridge */
-};
-
-static int __init
-iq80310_sec_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
-{
- irq_table *pci_irq_table;
-
- BUG_ON(pin < 1 || pin > 4);
-
- if (!system_rev) {
- pci_irq_table = pci_sec_d_irq_table;
- } else {
- pci_irq_table = pci_sec_f_irq_table;
- }
-
- return PCI_IRQ_TABLE_LOOKUP(0, 2);
-}
-
-static int iq80310_pri_host;
-
-static int iq80310_setup(int nr, struct pci_sys_data *sys)
-{
- switch (nr) {
- case 0:
- if (!iq80310_pri_host)
- return 0;
-
- sys->map_irq = iq80310_pri_map_irq;
- break;
-
- case 1:
- sys->map_irq = iq80310_sec_map_irq;
- break;
-
- default:
- return 0;
- }
-
- return iop310_setup(nr, sys);
-}
-
-static void iq80310_preinit(void)
-{
- iq80310_pri_host = *(volatile u32 *)IQ80310_BACKPLANE & 1;
-
- printk(KERN_INFO "PCI: IQ80310 is a%s\n",
- iq80310_pri_host ? " system controller" : "n agent");
-
- iop310_init();
-}
-
-static struct hw_pci iq80310_pci __initdata = {
- .swizzle = pci_std_swizzle,
- .nr_controllers = 2,
- .setup = iq80310_setup,
- .scan = iop310_scan_bus,
- .preinit = iq80310_preinit,
-};
-
-static int __init iq80310_pci_init(void)
-{
- if (machine_is_iq80310())
- pci_common_init(&iq80310_pci);
- return 0;
-}
-
-subsys_initcall(iq80310_pci_init);
+++ /dev/null
-/*
- * linux/arch/arm/mach-iop3xx/time-iq80310.c
- *
- * Timer functions for IQ80310 onboard timer
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-#include <linux/time.h>
-#include <linux/init.h>
-#include <linux/timex.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/mach/irq.h>
-
-static void iq80310_write_timer (u_long val)
-{
- volatile u_char *la0 = (volatile u_char *)IQ80310_TIMER_LA0;
- volatile u_char *la1 = (volatile u_char *)IQ80310_TIMER_LA1;
- volatile u_char *la2 = (volatile u_char *)IQ80310_TIMER_LA2;
-
- *la0 = val;
- *la1 = val >> 8;
- *la2 = (val >> 16) & 0x3f;
-}
-
-static u_long iq80310_read_timer (void)
-{
- volatile u_char *la0 = (volatile u_char *)IQ80310_TIMER_LA0;
- volatile u_char *la1 = (volatile u_char *)IQ80310_TIMER_LA1;
- volatile u_char *la2 = (volatile u_char *)IQ80310_TIMER_LA2;
- volatile u_char *la3 = (volatile u_char *)IQ80310_TIMER_LA3;
- u_long b0, b1, b2, b3, val;
-
- b0 = *la0; b1 = *la1; b2 = *la2; b3 = *la3;
- b0 = (((b0 & 0x40) >> 1) | (b0 & 0x1f));
- b1 = (((b1 & 0x40) >> 1) | (b1 & 0x1f));
- b2 = (((b2 & 0x40) >> 1) | (b2 & 0x1f));
- b3 = (b3 & 0x0f);
- val = ((b0 << 0) | (b1 << 6) | (b2 << 12) | (b3 << 18));
- return val;
-}
-
-/*
- * IRQs are disabled before entering here from do_gettimeofday().
- * Note that the counter may wrap. When it does, 'elapsed' will
- * be small, but we will have a pending interrupt.
- */
-static unsigned long iq80310_gettimeoffset (void)
-{
- unsigned long elapsed, usec;
- unsigned int stat1, stat2;
-
- stat1 = *(volatile u8 *)IQ80310_INT_STAT;
- elapsed = iq80310_read_timer();
- stat2 = *(volatile u8 *)IQ80310_INT_STAT;
-
- /*
- * If an interrupt was pending before we read the timer,
- * we've already wrapped. Factor this into the time.
- * If an interrupt was pending after we read the timer,
- * it may have wrapped between checking the interrupt
- * status and reading the timer. Re-read the timer to
- * be sure its value is after the wrap.
- */
- if (stat1 & 1)
- elapsed += LATCH;
- else if (stat2 & 1)
- elapsed = LATCH + iq80310_read_timer();
-
- /*
- * Now convert them to usec.
- */
- usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
-
- return usec;
-}
-
-
-static irqreturn_t
-iq80310_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
-
- /* clear timer interrupt */
- *timer_en &= ~2;
- *timer_en |= 2;
-
- do_timer(regs);
-
- return IRQ_HANDLED;
-}
-
-extern unsigned long (*gettimeoffset)(void);
-
-static struct irqaction timer_irq = {
- .name = "timer",
- .handler = iq80310_timer_interrupt,
-};
-
-
-void __init time_init(void)
-{
- volatile u_char *timer_en = (volatile u_char *)IQ80310_TIMER_EN;
-
- gettimeoffset = iq80310_gettimeoffset;
-
- setup_irq(IRQ_IQ80310_TIMER, &timer_irq);
-
- *timer_en = 0;
- iq80310_write_timer(LATCH);
- *timer_en |= 2;
- *timer_en |= 1;
-}
+++ /dev/null
-/*
- * linux/arch/arm/mach-iop3xx/mm.c
- *
- * Low level memory initialization for IOP310 based systems
- *
- * Author: Nicolas Pitre <npitre@mvista.com>
- *
- * Copyright 2000-2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- */
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/map.h>
-
-#ifdef CONFIG_IOP310_MU
-#include "message.h"
-#endif
-
-/*
- * Standard IO mapping for all IOP310 based systems
- */
-static struct map_desc iop80310_std_desc[] __initdata = {
- /* virtual physical length type */
- // IOP310 Memory Mapped Registers
- { 0xe8001000, 0x00001000, 0x00001000, MT_DEVICE },
- // PCI I/O Space
- { 0xfe000000, 0x90000000, 0x00020000, MT_DEVICE }
-};
-
-void __init iop310_map_io(void)
-{
- iotable_init(iop80310_std_desc, ARRAY_SIZE(iop80310_std_desc));
-}
-
-/*
- * IQ80310 specific IO mappings
- */
-#ifdef CONFIG_ARCH_IQ80310
-static struct map_desc iq80310_io_desc[] __initdata = {
- /* virtual physical length type */
- // IQ80310 On-Board Devices
- { 0xfe800000, 0xfe800000, 0x00100000, MT_DEVICE }
-};
-
-void __init iq80310_map_io(void)
-{
-#ifdef CONFIG_IOP310_MU
- /* acquiring 1MB of memory aligned on 1MB boundary for MU */
- mu_mem = __alloc_bootmem(0x100000, 0x100000, 0);
-#endif
-
- iop310_map_io();
-
- iotable_init(iq80310_io_desc, ARRAY_SIZE(iq80310_io_desc));
-}
-#endif // CONFIG_ARCH_IQ80310
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-iop3xx/xs80200-irq.c
- *
- * Generic IRQ handling for the XS80200 XScale core.
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/init.h>
-#include <linux/list.h>
-
-#include <asm/mach/irq.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-
-static void xs80200_irq_mask (unsigned int irq)
-{
- unsigned long intctl;
- asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (intctl));
- switch (irq) {
- case IRQ_XS80200_BCU: intctl &= ~(1<<3); break;
- case IRQ_XS80200_PMU: intctl &= ~(1<<2); break;
- case IRQ_XS80200_EXTIRQ: intctl &= ~(1<<1); break;
- case IRQ_XS80200_EXTFIQ: intctl &= ~(1<<0); break;
- }
- asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (intctl));
-}
-
-static void xs80200_irq_unmask (unsigned int irq)
-{
- unsigned long intctl;
- asm ("mrc p13, 0, %0, c0, c0, 0" : "=r" (intctl));
- switch (irq) {
- case IRQ_XS80200_BCU: intctl |= (1<<3); break;
- case IRQ_XS80200_PMU: intctl |= (1<<2); break;
- case IRQ_XS80200_EXTIRQ: intctl |= (1<<1); break;
- case IRQ_XS80200_EXTFIQ: intctl |= (1<<0); break;
- }
- asm ("mcr p13, 0, %0, c0, c0, 0" : : "r" (intctl));
-}
-
-static struct irqchip xs80200_chip = {
- .ack = xs80200_irq_mask,
- .mask = xs80200_irq_mask,
- .unmask = xs80200_irq_unmask,
-};
-
-void __init xs80200_init_irq(void)
-{
- unsigned int i;
-
- asm("mcr p13, 0, %0, c0, c0, 0" : : "r" (0));
-
- for (i = 0; i < NR_XS80200_IRQS; i++) {
- set_irq_chip(i, &xs80200_chip);
- set_irq_handler(i, do_level_IRQ);
- set_irq_flags(i, IRQF_VALID);
- }
-}
+++ /dev/null
-/*
- * linux/arch/arm/lib/lh7a400-fiqhandler.S
- * Copyright (C) 2002, Lineo, Inc.
- * based on linux/arch/arm/lib/floppydma.S, which is
- * Copyright (C) 1995, 1996 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/linkage.h>
-#include <asm/assembler.h>
- .text
-
- .global fiqhandler_end
-
- @ register usage:
- @ r8 &interrupt controller registers
- @ r9 &gpio registers
- @ r11 work
- @ r12 work
-
-ENTRY(fiqhandler)
-
- @ read the status register to find out which FIQ this is
-
- ldr r12, [r8] @ intc->status
- and r12, r12, #0xf @ only interested in low-order 4 bits
-
- @ translate FIQ 0:3 to IRQ 23:26
- @ disable this FIQ and enable the corresponding IRQ
-
- str r12, [r8, #0xc] @ disable this FIQ
- mov r12, r12, lsl #23 @ get the corresopnding IRQ bit
- str r12, [r8, #0x8] @ enable that IRQ
-
- subs pc, lr, #4
-fiqhandler_end:
-
+++ /dev/null
-/* arch/arm/mach-lh7a40x/ide-lpd7a40x.c
- *
- * Copyright (C) 2004 Logic Product Development
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- */
-
-
-#include <linux/config.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-
-#define IOBARRIER_READ readl (IOBARRIER_VIRT)
-
-static u8 lpd7a40x_ide_inb (unsigned long port)
-{
- u16 v = (u16) readw (port & ~0x1);
- IOBARRIER_READ;
- if (port & 0x1)
- v >>= 8;
- return v & 0xff;
-}
-
-static u16 lpd7a40x_ide_inw (unsigned long port)
-{
- u16 v = (u16) readw (port);
- IOBARRIER_READ;
- return v;
-}
-
-static void lpd7a40x_ide_insw (unsigned long port, void *addr, u32 count)
-{
- while (count--) {
- *((u16*) addr)++ = (u16) readw (port);
- IOBARRIER_READ;
- }
-}
-
-static u32 lpd7a40x_ide_inl (unsigned long port)
-{
- u32 v = (u16) readw (port);
- IOBARRIER_READ;
- v |= (u16) readw (port + 2);
- IOBARRIER_READ;
-
- return v;
-}
-
-static void lpd7a40x_ide_insl (unsigned long port, void *addr, u32 count)
-{
- while (count--) {
- *((u16*) addr)++ = (u16) readw (port);
- IOBARRIER_READ;
- *((u16*) addr)++ = (u16) readw (port + 2);
- IOBARRIER_READ;
- }
-}
-
-/* lpd7a40x_ide_outb -- this function is complicated by the fact that
- * the user wants to be able to do byte IO and the hardware cannot.
- * In order to write the high byte, we need to write a short. So, we
- * read before writing in order to maintain the register values that
- * shouldn't change. This isn't a good idea for the data IO registers
- * since reading from them will not return the current value. We
- * expect that this function handles the control register adequately.
-*/
-
-static void lpd7a40x_ide_outb (u8 valueUser, unsigned long port)
-{
- /* Block writes to SELECT register. Draconian, but the only
- * way to cope with this hardware configuration without
- * modifying the SELECT_DRIVE call in the ide driver. */
- if ((port & 0xf) == 0x6)
- return;
-
- if (port & 0x1) { /* Perform read before write. Only
- * the COMMAND register needs
- * this. */
- u16 value = (u16) readw (port & ~0x1);
- IOBARRIER_READ;
- value = (value & 0x00ff) | (valueUser << 8);
- writew (value, port & ~0x1);
- IOBARRIER_READ;
- }
- else { /* Allow low-byte writes which seem to
- * be OK. */
- writeb (valueUser, port);
- IOBARRIER_READ;
- }
-}
-
-static void lpd7a40x_ide_outbsync (ide_drive_t *drive, u8 value,
- unsigned long port)
-{
- lpd7a40x_ide_outb (value, port);
-}
-
-static void lpd7a40x_ide_outw (u16 value, unsigned long port)
-{
- writew (value, port);
- IOBARRIER_READ;
-}
-
-static void lpd7a40x_ide_outsw (unsigned long port, void *addr, u32 count)
-{
- while (count-- > 0) {
- writew (*((u16*) addr)++, port);
- IOBARRIER_READ;
- }
-}
-
-static void lpd7a40x_ide_outl (u32 value, unsigned long port)
-{
- writel (value, port);
- IOBARRIER_READ;
-}
-
-static void lpd7a40x_ide_outsl (unsigned long port, void *addr, u32 count)
-{
- while (count-- > 0) {
- writel (*((u32*) addr)++, port);
- IOBARRIER_READ;
- }
-}
-
-void lpd7a40x_SELECT_DRIVE (ide_drive_t *drive)
-{
- unsigned jifStart = jiffies;
-#define WAIT_TIME (30*HZ/1000)
-
- /* Check for readiness. */
- while ((HWIF(drive)->INB(IDE_STATUS_REG) & 0x40) == 0)
- if (jifStart <= jiffies + WAIT_TIME)
- return;
-
- /* Only allow one drive.
- For more information, see Documentation/arm/Sharp-LH/ */
- if (drive->select.all & (1<<4))
- return;
-
- /* OUTW so that the IDLE_IMMEDIATE (and not NOP) command is sent. */
- HWIF(drive)->OUTW(drive->select.all | 0xe100, IDE_SELECT_REG);
-}
-
-void lpd7a40x_hwif_ioops (ide_hwif_t *hwif)
-{
- hwif->mmio = 2; /* Just for show */
- hwif->irq = IDE_NO_IRQ; /* Stop this probing */
-
- hwif->OUTB = lpd7a40x_ide_outb;
- hwif->OUTBSYNC = lpd7a40x_ide_outbsync;
- hwif->OUTW = lpd7a40x_ide_outw;
- hwif->OUTL = lpd7a40x_ide_outl;
- hwif->OUTSW = lpd7a40x_ide_outsw;
- hwif->OUTSL = lpd7a40x_ide_outsl;
- hwif->INB = lpd7a40x_ide_inb;
- hwif->INW = lpd7a40x_ide_inw;
- hwif->INL = lpd7a40x_ide_inl;
- hwif->INSW = lpd7a40x_ide_insw;
- hwif->INSL = lpd7a40x_ide_insl;
- hwif->selectproc = lpd7a40x_SELECT_DRIVE;
-}
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/bus.c
- *
- * Virtual bus for OMAP. Allows better power management, such as managing
- * shared clocks, and mapping of bus addresses to Local Bus addresses.
- *
- * See drivers/usb/host/ohci-omap.c or drivers/video/omap/omapfb.c for
- * examples on how to register drivers to this bus.
- *
- * Copyright (C) 2003 - 2004 Nokia Corporation
- * Written by Tony Lindgren <tony@atomide.com>
- * Portions of code based on sa1111.c.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/ptrace.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/mach/irq.h>
-
-#include <asm/arch/bus.h>
-
-static int omap_bus_match(struct device *_dev, struct device_driver *_drv);
-static int omap_bus_suspend(struct device *dev, u32 state);
-static int omap_bus_resume(struct device *dev);
-
-/*
- * OMAP bus definitions
- *
- * NOTE: Most devices should use TIPB. LBUS does automatic address mapping
- * to Local Bus addresses, and should only be used for Local Bus devices.
- * We may add new buses later on for power management reasons. Basically
- * we want to be able to turn off any bus if it's not used by device
- * drivers.
- */
-static struct device omap_bus_devices[OMAP_NR_BUSES] = {
- {
- .bus_id = OMAP_BUS_NAME_TIPB
- }, {
- .bus_id = OMAP_BUS_NAME_LBUS
- },
-};
-
-static struct bus_type omap_bus_types[OMAP_NR_BUSES] = {
- {
- .name = OMAP_BUS_NAME_TIPB,
- .match = omap_bus_match,
- .suspend = omap_bus_suspend,
- .resume = omap_bus_resume,
- }, {
- .name = OMAP_BUS_NAME_LBUS, /* Local bus on 1510 */
- .match = omap_bus_match,
- .suspend = omap_bus_suspend,
- .resume = omap_bus_resume,
- },
-};
-
-static int omap_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct omap_dev *omapdev = OMAP_DEV(dev);
- struct omap_driver *omapdrv = OMAP_DRV(drv);
-
- return omapdev->devid == omapdrv->devid;
-}
-
-static int omap_bus_suspend(struct device *dev, u32 state)
-{
- struct omap_dev *omapdev = OMAP_DEV(dev);
- struct omap_driver *omapdrv = OMAP_DRV(dev->driver);
- int ret = 0;
-
- if (omapdrv && omapdrv->suspend)
- ret = omapdrv->suspend(omapdev, state);
- return ret;
-}
-
-static int omap_bus_resume(struct device *dev)
-{
- struct omap_dev *omapdev = OMAP_DEV(dev);
- struct omap_driver *omapdrv = OMAP_DRV(dev->driver);
- int ret = 0;
-
- if (omapdrv && omapdrv->resume)
- ret = omapdrv->resume(omapdev);
- return ret;
-}
-
-static int omap_device_probe(struct device *dev)
-{
- struct omap_dev *omapdev = OMAP_DEV(dev);
- struct omap_driver *omapdrv = OMAP_DRV(dev->driver);
- int ret = -ENODEV;
-
- if (omapdrv && omapdrv->probe)
- ret = omapdrv->probe(omapdev);
-
- return ret;
-}
-
-static int omap_device_remove(struct device *dev)
-{
- struct omap_dev *omapdev = OMAP_DEV(dev);
- struct omap_driver *omapdrv = OMAP_DRV(dev->driver);
- int ret = 0;
-
- if (omapdrv && omapdrv->remove)
- ret = omapdrv->remove(omapdev);
- return ret;
-}
-
-int omap_device_register(struct omap_dev *odev)
-{
- if (!odev)
- return -EINVAL;
-
- if (odev->busid < 0 || odev->busid >= OMAP_NR_BUSES) {
- printk(KERN_ERR "%s: busid invalid: %s: bus: %i\n",
- __FUNCTION__, odev->name, odev->busid);
- return -EINVAL;
- }
-
- odev->dev.parent = &omap_bus_devices[odev->busid];
- odev->dev.bus = &omap_bus_types[odev->busid];
-
- /* This is needed for USB OHCI to work */
- if (odev->dma_mask)
- odev->dev.dma_mask = odev->dma_mask;
-
- if (odev->coherent_dma_mask)
- odev->dev.coherent_dma_mask = odev->coherent_dma_mask;
-
- snprintf(odev->dev.bus_id, BUS_ID_SIZE, "%s%u",
- odev->name, odev->devid);
-
- printk("Registering OMAP device '%s'. Parent at %s\n",
- odev->dev.bus_id, odev->dev.parent->bus_id);
-
- return device_register(&odev->dev);
-}
-
-void omap_device_unregister(struct omap_dev *odev)
-{
- if (odev)
- device_unregister(&odev->dev);
-}
-
-int omap_driver_register(struct omap_driver *driver)
-{
- int ret;
-
- if (driver->busid < 0 || driver->busid >= OMAP_NR_BUSES) {
- printk(KERN_ERR "%s: busid invalid: bus: %i device: %i\n",
- __FUNCTION__, driver->busid, driver->devid);
- return -EINVAL;
- }
-
- driver->drv.probe = omap_device_probe;
- driver->drv.remove = omap_device_remove;
- driver->drv.bus = &omap_bus_types[driver->busid];
-
- /*
- * driver_register calls bus_add_driver
- */
- ret = driver_register(&driver->drv);
-
- return ret;
-}
-
-void omap_driver_unregister(struct omap_driver *driver)
-{
- driver_unregister(&driver->drv);
-}
-
-static int __init omap_bus_init(void)
-{
- int i, ret;
-
- /* Initialize all OMAP virtual buses */
- for (i = 0; i < OMAP_NR_BUSES; i++) {
- ret = device_register(&omap_bus_devices[i]);
- if (ret != 0) {
- printk(KERN_ERR "Unable to register bus device %s\n",
- omap_bus_devices[i].bus_id);
- continue;
- }
- ret = bus_register(&omap_bus_types[i]);
- if (ret != 0) {
- printk(KERN_ERR "Unable to register bus %s\n",
- omap_bus_types[i].name);
- device_unregister(&omap_bus_devices[i]);
- }
- }
- printk("OMAP virtual buses initialized\n");
-
- return ret;
-}
-
-static void __exit omap_bus_exit(void)
-{
- int i;
-
- /* Unregister all OMAP virtual buses */
- for (i = 0; i < OMAP_NR_BUSES; i++) {
- bus_unregister(&omap_bus_types[i]);
- device_unregister(&omap_bus_devices[i]);
- }
-}
-
-postcore_initcall(omap_bus_init);
-module_exit(omap_bus_exit);
-
-MODULE_DESCRIPTION("Virtual bus for OMAP");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(omap_bus_types);
-EXPORT_SYMBOL(omap_driver_register);
-EXPORT_SYMBOL(omap_driver_unregister);
-EXPORT_SYMBOL(omap_device_register);
-EXPORT_SYMBOL(omap_device_unregister);
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/innovator1510.c
- *
- * Board specific inits for OMAP-1510 Innovator
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * Copyright (C) 2002 MontaVista Software, Inc.
- *
- * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
- * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/fpga.h>
-
-#include "common.h"
-
-extern int omap_gpio_init(void);
-
-void innovator_init_irq(void)
-{
- omap_init_irq();
- omap_gpio_init();
- fpga_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
- [0] = {
- .start = OMAP1510P1_FPGA_ETHR_START, /* Physical */
- .end = OMAP1510P1_FPGA_ETHR_START + 16,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = INT_ETHER,
- .end = INT_ETHER,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device smc91x_device = {
- .name = "smc91x",
- .id = 0,
- .num_resources = ARRAY_SIZE(smc91x_resources),
- .resource = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
- &smc91x_device,
-};
-
-static void __init innovator_init(void)
-{
- if (!machine_is_innovator())
- return;
-
- (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-/* Only FPGA needs to be mapped here. All others are done with ioremap */
-static struct map_desc innovator_io_desc[] __initdata = {
-{ OMAP1510P1_FPGA_BASE, OMAP1510P1_FPGA_START, OMAP1510P1_FPGA_SIZE,
- MT_DEVICE },
-};
-
-static void __init innovator_map_io(void)
-{
- omap_map_io();
- iotable_init(innovator_io_desc, ARRAY_SIZE(innovator_io_desc));
-
- /* Dump the Innovator FPGA rev early - useful info for support. */
- printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
- fpga_read(OMAP1510P1_FPGA_REV_HIGH),
- fpga_read(OMAP1510P1_FPGA_REV_LOW),
- fpga_read(OMAP1510P1_FPGA_BOARD_REV));
-}
-
-MACHINE_START(INNOVATOR, "TI-Innovator/OMAP1510")
- MAINTAINER("MontaVista Software, Inc.")
- BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
- BOOT_PARAMS(0x10000100)
- MAPIO(innovator_map_io)
- INITIRQ(innovator_init_irq)
- INIT_MACHINE(innovator_init)
-MACHINE_END
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/innovator1610.c
- *
- * This file contains Innovator-specific code.
- *
- * Copyright (C) 2002 MontaVista Software, Inc.
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/major.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/errno.h>
-
-#include <asm/setup.h>
-#include <asm/page.h>
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-#include <asm/arch/irqs.h>
-
-#include "common.h"
-
-void
-innovator_init_irq(void)
-{
- omap_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
- [0] = {
- .start = OMAP1610_ETHR_START, /* Physical */
- .end = OMAP1610_ETHR_START + SZ_4K,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = 0, /* Really GPIO 0 */
- .end = 0,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device smc91x_device = {
- .name = "smc91x",
- .id = 0,
- .num_resources = ARRAY_SIZE(smc91x_resources),
- .resource = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
- &smc91x_device,
-};
-
-static void __init innovator_init(void)
-{
- if (!machine_is_innovator())
- return;
-
- (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-static struct map_desc innovator_io_desc[] __initdata = {
-{ OMAP1610_ETHR_BASE, OMAP1610_ETHR_START, OMAP1610_ETHR_SIZE,MT_DEVICE },
-{ OMAP1610_NOR_FLASH_BASE, OMAP1610_NOR_FLASH_START, OMAP1610_NOR_FLASH_SIZE,
- MT_DEVICE },
-};
-
-static void __init innovator_map_io(void)
-{
- omap_map_io();
- iotable_init(innovator_io_desc, ARRAY_SIZE(innovator_io_desc));
-}
-
-MACHINE_START(INNOVATOR, "TI-Innovator/OMAP1610")
- MAINTAINER("MontaVista Software, Inc.")
- BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
- BOOT_PARAMS(0x10000100)
- MAPIO(innovator_map_io)
- INITIRQ(innovator_init_irq)
- INIT_MACHINE(innovator_init)
-MACHINE_END
-
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/irq.h
- *
- * OMAP specific interrupt bank definitions
- *
- * Copyright (C) 2004 Nokia Corporation
- * Written by Tony Lindgren <tony@atomide.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define OMAP_IRQ_TYPE710 1
-#define OMAP_IRQ_TYPE730 2
-#define OMAP_IRQ_TYPE1510 3
-#define OMAP_IRQ_TYPE1610 4
-#define OMAP_IRQ_TYPE1710 5
-
-#define MAX_NR_IRQ_BANKS 4
-
-#define BANK_NR_IRQS 32
-
-struct omap_irq_desc {
- unsigned int cpu_type;
- unsigned int start_irq;
- unsigned long level_map;
- unsigned long base_reg;
- unsigned long mask_reg;
- unsigned long ack_reg;
- struct irqchip *handler;
-};
-
-struct omap_irq_bank {
- unsigned int start_irq;
- unsigned long level_map;
- unsigned long base_reg;
- unsigned long mask_reg;
- unsigned long ack_reg;
- struct irqchip *handler;
-};
-
-static void omap_offset_ack_irq(unsigned int irq);
-static void omap_offset_mask_irq(unsigned int irq);
-static void omap_offset_unmask_irq(unsigned int irq);
-static void omap_offset_mask_ack_irq(unsigned int irq);
-
-/* NOTE: These will not work if irq bank offset != 0x100 */
-#define IRQ_TO_BANK(irq) (irq >> 5)
-#define IRQ_BIT(irq) (irq & 0x1f)
-#define BANK_OFFSET(bank) ((bank - 1) * 0x100)
-
-static struct irqchip omap_offset_irq = {
- .ack = omap_offset_mask_ack_irq,
- .mask = omap_offset_mask_irq,
- .unmask = omap_offset_unmask_irq,
-};
-
-/*
- * OMAP-730 interrupt banks
- */
-static struct omap_irq_desc omap730_bank0_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE730,
- .start_irq = 0,
- .level_map = 0xb3f8e22f,
- .base_reg = OMAP_IH1_BASE,
- .mask_reg = OMAP_IH1_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH1_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap730_bank1_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE730,
- .start_irq = 32,
- .level_map = 0xfdb9c1f2,
- .base_reg = OMAP_IH2_BASE,
- .mask_reg = OMAP_IH2_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap730_bank2_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE730,
- .start_irq = 64,
- .level_map = 0x800040f3,
- .base_reg = OMAP_IH2_BASE + 0x100,
- .mask_reg = OMAP_IH2_BASE + 0x100 + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-/*
- * OMAP-1510 interrupt banks
- */
-static struct omap_irq_desc omap1510_bank0_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1510,
- .start_irq = 0,
- .level_map = 0xb3febfff,
- .base_reg = OMAP_IH1_BASE,
- .mask_reg = OMAP_IH1_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH1_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1510_bank1_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1510,
- .start_irq = 32,
- .level_map = 0xffbfffed,
- .base_reg = OMAP_IH2_BASE,
- .mask_reg = OMAP_IH2_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-/*
- * OMAP-1610 interrupt banks
- */
-static struct omap_irq_desc omap1610_bank0_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1610,
- .start_irq = 0,
- .level_map = 0xb3fefe8f,
- .base_reg = OMAP_IH1_BASE,
- .mask_reg = OMAP_IH1_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH1_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank1_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1610,
- .start_irq = 32,
- .level_map = 0xfffff7ff,
- .base_reg = OMAP_IH2_BASE,
- .mask_reg = OMAP_IH2_BASE + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG,
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank2_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1610,
- .start_irq = 64,
- .level_map = 0xffffffff,
- .base_reg = OMAP_IH2_BASE + 0x100,
- .mask_reg = OMAP_IH2_BASE + 0x100 + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
-
-static struct omap_irq_desc omap1610_bank3_irqs __initdata = {
- .cpu_type = OMAP_IRQ_TYPE1610,
- .start_irq = 96,
- .level_map = 0xffffffff,
- .base_reg = OMAP_IH2_BASE + 0x200,
- .mask_reg = OMAP_IH2_BASE + 0x200 + IRQ_MIR,
- .ack_reg = OMAP_IH2_BASE + IRQ_CONTROL_REG, /* Not replicated */
- .handler = &omap_offset_irq, /* IH2 regs at 0x100 offsets */
-};
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/leds-perseus2.c
- *
- * Copyright 2003 by Texas Instruments Incorporated
- *
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/kernel_stat.h>
-#include <linux/sched.h>
-#include <linux/version.h>
-
-#include <asm/io.h>
-#include <asm/hardware.h>
-#include <asm/leds.h>
-#include <asm/system.h>
-
-#include "leds.h"
-
-void perseus2_leds_event(led_event_t evt)
-{
- unsigned long flags;
- static unsigned long hw_led_state = 0;
-
- local_irq_save(flags);
-
- switch (evt) {
- case led_start:
- hw_led_state |= OMAP730_FPGA_LED_STARTSTOP;
- break;
-
- case led_stop:
- hw_led_state &= ~OMAP730_FPGA_LED_STARTSTOP;
- break;
-
- case led_claim:
- hw_led_state |= OMAP730_FPGA_LED_CLAIMRELEASE;
- break;
-
- case led_release:
- hw_led_state &= ~OMAP730_FPGA_LED_CLAIMRELEASE;
- break;
-
-#ifdef CONFIG_LEDS_TIMER
- case led_timer:
- /*
- * Toggle Timer LED
- */
- if (hw_led_state & OMAP730_FPGA_LED_TIMER)
- hw_led_state &= ~OMAP730_FPGA_LED_TIMER;
- else
- hw_led_state |= OMAP730_FPGA_LED_TIMER;
- break;
-#endif
-
-#ifdef CONFIG_LEDS_CPU
- case led_idle_start:
- hw_led_state |= OMAP730_FPGA_LED_IDLE;
- break;
-
- case led_idle_end:
- hw_led_state &= ~OMAP730_FPGA_LED_IDLE;
- break;
-#endif
-
- case led_halted:
- if (hw_led_state & OMAP730_FPGA_LED_HALTED)
- hw_led_state &= ~OMAP730_FPGA_LED_HALTED;
- else
- hw_led_state |= OMAP730_FPGA_LED_HALTED;
- break;
-
- case led_green_on:
- break;
-
- case led_green_off:
- break;
-
- case led_amber_on:
- break;
-
- case led_amber_off:
- break;
-
- case led_red_on:
- break;
-
- case led_red_off:
- break;
-
- default:
- break;
- }
-
-
- /*
- * Actually burn the LEDs
- */
- __raw_writew(~hw_led_state & 0xffff, OMAP730_FPGA_LEDS);
-
- local_irq_restore(flags);
-}
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/generic.c
- *
- * Modified from innovator.c
- *
- * Code for generic OMAP board. Should work on many OMAP systems where
- * the device drivers take care of all the necessary hardware initialization.
- * Do not put any board specific code to this file; create a new machine
- * type if you need custom low-level initializations.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/mux.h>
-
-#include "common.h"
-
-static void __init omap_generic_init_irq(void)
-{
- omap_init_irq();
-}
-
-/*
- * Muxes the serial ports on
- */
-static void __init omap_early_serial_init(void)
-{
- omap_cfg_reg(UART1_TX);
- omap_cfg_reg(UART1_RTS);
-
- omap_cfg_reg(UART2_TX);
- omap_cfg_reg(UART2_RTS);
-
- omap_cfg_reg(UART3_TX);
- omap_cfg_reg(UART3_RX);
-}
-
-static void __init omap_generic_init(void)
-{
- if (!machine_is_omap_generic())
- return;
-
- /*
- * Make sure the serial ports are muxed on at this point.
- * You have to mux them off in device drivers later on
- * if not needed.
- */
- if (cpu_is_omap1510()) {
- omap_early_serial_init();
- }
-}
-
-static void __init omap_generic_map_io(void)
-{
- omap_map_io();
-}
-
-MACHINE_START(OMAP_GENERIC, "Generic OMAP-1510/1610")
- MAINTAINER("Tony Lindgren <tony@atomide.com>")
- BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
- BOOT_PARAMS(0x10000100)
- MAPIO(omap_generic_map_io)
- INITIRQ(omap_generic_init_irq)
- INIT_MACHINE(omap_generic_init)
-MACHINE_END
+++ /dev/null
-/*
- * linux/arch/arm/mach-omap/omap-perseus2.c
- *
- * Modified from omap-generic.c
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-
-#include <asm/hardware.h>
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-#include <asm/arch/clocks.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/mux.h>
-
-#include <asm/arch/omap-perseus2.h>
-
-#include "common.h"
-
-void omap_perseus2_init_irq(void)
-{
- omap_init_irq();
-}
-
-static struct resource smc91x_resources[] = {
- [0] = {
- .start = OMAP730_FPGA_ETHR_START, /* Physical */
- .end = OMAP730_FPGA_ETHR_START + SZ_4K,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = 0,
- .end = 0,
- .flags = INT_ETHER,
- },
-};
-
-static struct platform_device smc91x_device = {
- .name = "smc91x",
- .id = 0,
- .num_resources = ARRAY_SIZE(smc91x_resources),
- .resource = smc91x_resources,
-};
-
-static struct platform_device *devices[] __initdata = {
- &smc91x_device,
-};
-
-static void __init omap_perseus2_init(void)
-{
- if (!machine_is_omap_perseus2())
- return;
-
- (void) platform_add_devices(devices, ARRAY_SIZE(devices));
-}
-
-/* Only FPGA needs to be mapped here. All others are done with ioremap */
-static struct map_desc omap_perseus2_io_desc[] __initdata = {
- {OMAP730_FPGA_BASE, OMAP730_FPGA_START, OMAP730_FPGA_SIZE,
- MT_DEVICE},
-};
-
-static void __init omap_perseus2_map_io(void)
-{
- omap_map_io();
- iotable_init(omap_perseus2_io_desc,
- ARRAY_SIZE(omap_perseus2_io_desc));
-
- /* Early, board-dependent init */
-
- /*
- * Hold GSM Reset until needed
- */
- *DSP_M_CTL &= ~1;
-
- /*
- * UARTs -> done automagically by 8250 driver
- */
-
- /*
- * CSx timings, GPIO Mux ... setup
- */
-
- /* Flash: CS0 timings setup */
- *((volatile __u32 *) OMAP_FLASH_CFG_0) = 0x0000fff3;
- *((volatile __u32 *) OMAP_FLASH_ACFG_0) = 0x00000088;
-
- /*
- * Ethernet support trough the debug board
- * CS1 timings setup
- */
- *((volatile __u32 *) OMAP_FLASH_CFG_1) = 0x0000fff3;
- *((volatile __u32 *) OMAP_FLASH_ACFG_1) = 0x00000000;
-
- /*
- * Configure MPU_EXT_NIRQ IO in IO_CONF9 register,
- * It is used as the Ethernet controller interrupt
- */
- *((volatile __u32 *) PERSEUS2_IO_CONF_9) &= 0x1FFFFFFF;
-}
-
-MACHINE_START(OMAP_PERSEUS2, "OMAP730 Perseus2")
- MAINTAINER("Kevin Hilman <k-hilman@ti.com>")
- BOOT_MEM(0x10000000, 0xe0000000, 0xe0000000)
- BOOT_PARAMS(0x10000100)
- MAPIO(omap_perseus2_map_io)
- INITIRQ(omap_perseus2_init_irq)
- INIT_MACHINE(omap_perseus2_init)
-MACHINE_END
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-# Object file lists.
-
-obj-y := core.o
-obj-m :=
-obj-n :=
-obj- :=
-
+++ /dev/null
-/*
- * linux/arch/arm/mm/mm-tbox.c
- *
- * Copyright (C) 1998, 1999, 2000 Phil Blundell
- * Copyright (C) 1998-1999 Russell King
- *
- * Extra MM routines for the Tbox architecture
- */
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-
-#include <asm/elf.h>
-#include <asm/setup.h>
-#include <asm/mach-types.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-
-#include <asm/mach/arch.h>
-#include <asm/mach/map.h>
-
-extern unsigned long soft_irq_mask;
-
-static void tbox_mask_irq(unsigned int irq)
-{
- __raw_writel(0, INTCONT + (irq << 2));
- soft_irq_mask &= ~(1<<irq);
-}
-
-static void tbox_unmask_irq(unsigned int irq)
-{
- soft_irq_mask |= (1<<irq);
- __raw_writel(1, INTCONT + (irq << 2));
-}
-
-static void tbox_init_irq(void)
-{
- unsigned int i;
-
- /* Disable all interrupts initially. */
- for (i = 0; i < NR_IRQS; i++) {
- if (i <= 10 || (i >= 12 && i <= 13)) {
- irq_desc[i].valid = 1;
- irq_desc[i].probe_ok = 0;
- irq_desc[i].mask_ack = tbox_mask_irq;
- irq_desc[i].mask = tbox_mask_irq;
- irq_desc[i].unmask = tbox_unmask_irq;
- tbox_mask_irq(i);
- } else {
- irq_desc[i].valid = 0;
- irq_desc[i].probe_ok = 0;
- }
- }
-}
-
-static struct map_desc tbox_io_desc[] __initdata = {
- /* See hardware.h for details */
- { IO_BASE, IO_START, 0x00100000, MT_DEVICE }
-};
-
-static void __init tbox_map_io(void)
-{
- iotable_init(tbox_io_desc, ARRAY_SIZE(tbox_io_desc));
-}
-
-MACHINE_START(TBOX, "unknown-TBOX")
- MAINTAINER("Philip Blundell")
- BOOT_MEM(0x80000000, 0x00400000, 0xe0000000)
- MAPIO(tbox_map_io)
- INITIRQ(tbox_init_irq)
-MACHINE_END
-
+++ /dev/null
-#include <stdio.h>
-
-
-void main()
-{
- int c;
- int comma=0;
- int count=0;
- while((c=getchar())!=EOF)
- {
- unsigned char x=c;
- if(comma)
- printf(",");
- else
- comma=1;
- if(count==8)
- {
- count=0;
- printf("\n");
- }
- if(count==0)
- printf("\t");
- printf("0x%02X",c);
- count++;
- }
- if(count)
- printf("\n");
- exit(0);
-}
-
-
+++ /dev/null
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/user.h>
-#include <linux/elfcore.h>
-#include <linux/sched.h>
-#include <linux/in6.h>
-#include <linux/interrupt.h>
-#include <linux/smp_lock.h>
-#include <linux/pm.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/tty.h>
-
-#include <asm/semaphore.h>
-#include <asm/processor.h>
-#include <asm/uaccess.h>
-#include <asm/checksum.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/delay.h>
-#include <asm/irq.h>
-#include <asm/pgtable.h>
-
-extern void dump_thread(struct pt_regs *, struct user *);
-extern unsigned long get_cmos_time(void);
-extern void __Udiv(void);
-extern void __Umod(void);
-extern void __Div(void);
-extern void __Mod(void);
-extern void __ashrdi3(void);
-extern void iounmap(void *addr);
-
-/* Platform dependent support */
-EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(enable_irq);
-EXPORT_SYMBOL(disable_irq);
-EXPORT_SYMBOL(kernel_thread);
-EXPORT_SYMBOL(get_cmos_time);
-EXPORT_SYMBOL(loops_per_usec);
-
-/* String functions */
-EXPORT_SYMBOL(memcmp);
-EXPORT_SYMBOL(memmove);
-EXPORT_SYMBOL(strpbrk);
-EXPORT_SYMBOL(strstr);
-EXPORT_SYMBOL(strcpy);
-EXPORT_SYMBOL(strchr);
-EXPORT_SYMBOL(strcmp);
-EXPORT_SYMBOL(strlen);
-EXPORT_SYMBOL(strcat);
-EXPORT_SYMBOL(strncat);
-EXPORT_SYMBOL(strncmp);
-EXPORT_SYMBOL(strncpy);
-
-/* Math functions */
-EXPORT_SYMBOL(__Udiv);
-EXPORT_SYMBOL(__Umod);
-EXPORT_SYMBOL(__Div);
-EXPORT_SYMBOL(__Mod);
-EXPORT_SYMBOL(__ashrdi3);
-
-/* Memory functions */
-EXPORT_SYMBOL(__ioremap);
-EXPORT_SYMBOL(iounmap);
-
-/* Semaphore functions */
-EXPORT_SYMBOL(__up);
-EXPORT_SYMBOL(__down);
-EXPORT_SYMBOL(__down_interruptible);
-EXPORT_SYMBOL(__down_trylock);
-
-/* Export shadow registers for the CPU I/O pins */
-EXPORT_SYMBOL(genconfig_shadow);
-EXPORT_SYMBOL(port_pa_data_shadow);
-EXPORT_SYMBOL(port_pa_dir_shadow);
-EXPORT_SYMBOL(port_pb_data_shadow);
-EXPORT_SYMBOL(port_pb_dir_shadow);
-EXPORT_SYMBOL(port_pb_config_shadow);
-EXPORT_SYMBOL(port_g_data_shadow);
-
-/* Userspace access functions */
-EXPORT_SYMBOL(__copy_user_zeroing);
-EXPORT_SYMBOL(__copy_user);
-
-/* Cache flush functions */
-EXPORT_SYMBOL(flush_etrax_cache);
-EXPORT_SYMBOL(prepare_rx_descriptor);
-
-#undef memcpy
-#undef memset
-extern void * memset(void *, int, __kernel_size_t);
-extern void * memcpy(void *, const void *, __kernel_size_t);
-EXPORT_SYMBOL_NOVERS(memcpy);
-EXPORT_SYMBOL_NOVERS(memset);
-
-
+++ /dev/null
-#
-# arch/i386/boot/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1994 by Linus Torvalds
-#
-
-# ROOT_DEV specifies the default root-device when making the image.
-# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
-# the default of FLOPPY is used by 'build'.
-
-ROOT_DEV := CURRENT
-
-# If you want to preset the SVGA mode, uncomment the next line and
-# set SVGA_MODE to whatever number you want.
-# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
-# The number is the same as you would ordinarily press at bootup.
-
-SVGA_MODE := -DSVGA_MODE=NORMAL_VGA
-
-# If you want the RAM disk device, define this to be the size in blocks.
-
-#RAMDISK := -DRAMDISK=512
-
-targets := vmlinux.bin bootsect bootsect.o setup setup.o \
- zImage bzImage
-subdir- := compressed
-
-host-progs := tools/build
-
-# ---------------------------------------------------------------------------
-
-$(obj)/zImage: IMAGE_OFFSET := 0x1000
-$(obj)/zImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK)
-$(obj)/bzImage: IMAGE_OFFSET := 0x100000
-$(obj)/bzImage: EXTRA_AFLAGS := -traditional $(SVGA_MODE) $(RAMDISK) -D__BIG_KERNEL__
-$(obj)/bzImage: BUILDFLAGS := -b
-
-quiet_cmd_image = BUILD $@
-cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
- $(obj)/vmlinux.bin $(ROOT_DEV) > $@
-
-$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
- $(obj)/vmlinux.bin $(obj)/tools/build FORCE
- $(call if_changed,image)
- @echo 'Kernel: $@ is ready'
-
-$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
- $(call if_changed,objcopy)
-
-LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary
-LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext
-
-$(obj)/setup $(obj)/bootsect: %: %.o FORCE
- $(call if_changed,ld)
-
-$(obj)/compressed/vmlinux: FORCE
- $(Q)$(MAKE) $(build)=$(obj)/compressed IMAGE_OFFSET=$(IMAGE_OFFSET) $@
-
-# Set this if you want to pass append arguments to the zdisk/fdimage kernel
-FDARGS =
-
-$(obj)/mtools.conf: $(src)/mtools.conf.in
- sed -e 's|@OBJ@|$(obj)|g' < $< > $@
-
-# This requires write access to /dev/fd0
-zdisk: $(BOOTIMAGE) $(obj)/mtools.conf
- MTOOLSRC=$(obj)/mtools.conf mformat a: ; sync
- syslinux /dev/fd0 ; sync
- echo 'default linux $(FDARGS)' | \
- MTOOLSRC=$(src)/mtools.conf mcopy - a:syslinux.cfg
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) a:linux ; sync
-
-# These require being root or having syslinux 2.02 or higher installed
-fdimage fdimage144: $(BOOTIMAGE) $(obj)/mtools.conf
- dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=1440
- MTOOLSRC=$(obj)/mtools.conf mformat v: ; sync
- syslinux $(obj)/fdimage ; sync
- echo 'default linux $(FDARGS)' | \
- MTOOLSRC=$(obj)/mtools.conf mcopy - v:syslinux.cfg
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) v:linux ; sync
-
-fdimage288: $(BOOTIMAGE) $(obj)/mtools.conf
- dd if=/dev/zero of=$(obj)/fdimage bs=1024 count=2880
- MTOOLSRC=$(obj)/mtools.conf mformat w: ; sync
- syslinux $(obj)/fdimage ; sync
- echo 'default linux $(FDARGS)' | \
- MTOOLSRC=$(obj)/mtools.conf mcopy - w:syslinux.cfg
- MTOOLSRC=$(obj)/mtools.conf mcopy $(BOOTIMAGE) w:linux ; sync
-
-zlilo: $(BOOTIMAGE)
- if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
- if [ -f $(INSTALL_PATH)/System.map ]; then mv $(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi
- cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz
- cp System.map $(INSTALL_PATH)/
- if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
-
-install: $(BOOTIMAGE)
- sh $(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
+++ /dev/null
-/*
- * bootsect.S - boot sector for NEC PC-9800 series
- *
- * Linux/98 project at Kyoto University Microcomputer Club (KMC)
- * FUJITA Norimasa, TAKAI Kousuke 1997-1998
- * rewritten by TAKAI Kousuke (as86 -> gas), Nov 1999
- *
- * Based on:
- * bootsect.S Copyright (C) 1991, 1992 Linus Torvalds
- * modified by Drew Eckhardt
- * modified by Bruce Evans (bde)
- *
- * bootsect.S is loaded at 0x1FC00 or 0x1FE00 by the bios-startup routines,
- * and moves itself out of the way to address 0x90000, and jumps there.
- *
- * It then loads 'setup' directly after itself (0x90200), and the system
- * at 0x10000, using BIOS interrupts.
- *
- * NOTE! currently system is at most (8*65536-4096) bytes long. This should
- * be no problem, even in the future. I want to keep it simple. This 508 kB
- * kernel size should be enough, especially as this doesn't contain the
- * buffer cache as in minix (and especially now that the kernel is
- * compressed :-)
- *
- * The loader has been made as simple as possible, and continuous
- * read errors will result in a unbreakable loop. Reboot by hand. It
- * loads pretty fast by getting whole tracks at a time whenever possible.
- */
-
-#include <linux/config.h> /* for CONFIG_ROOT_RDONLY */
-#include <asm/boot.h>
-
-SETUPSECTS = 4 /* default nr of setup-sectors */
-BOOTSEG = 0x1FC0 /* original address of boot-sector */
-INITSEG = DEF_INITSEG /* we move boot here - out of the way */
-SETUPSEG = DEF_SETUPSEG /* setup starts here */
-SYSSEG = DEF_SYSSEG /* system loaded at 0x10000 (65536) */
-SYSSIZE = DEF_SYSSIZE /* system size: # of 16-byte clicks */
- /* to be loaded */
-ROOT_DEV = 0 /* ROOT_DEV is now written by "build" */
-SWAP_DEV = 0 /* SWAP_DEV is now written by "build" */
-
-#ifndef SVGA_MODE
-#define SVGA_MODE ASK_VGA
-#endif
-
-#ifndef RAMDISK
-#define RAMDISK 0
-#endif
-
-#ifndef ROOT_RDONLY
-#define ROOT_RDONLY 1
-#endif
-
-/* normal/hireso text VRAM segments */
-#define NORMAL_TEXT 0xa000
-#define HIRESO_TEXT 0xe000
-
-/* bios work area addresses */
-#define EXPMMSZ 0x0401
-#define BIOS_FLAG 0x0501
-#define DISK_BOOT 0x0584
-
-.code16
-.text
-
-.global _start
-_start:
-
-#if 0 /* hook for debugger, harmless unless BIOS is fussy (old HP) */
- int $0x3
-#endif
- jmp real_start
- .ascii "Linux 98"
- .word 0
-real_start:
- xorw %di, %di /* %di = 0 */
- movw %di, %ss /* %ss = 0 */
- movw $0x03F0, %sp
- pushw %cx /* for hint */
-
- movw $0x0A00, %ax /* normal mode defaults (80x25) */
-
- testb $0x08, %ss:BIOS_FLAG /* check hi-reso bit */
- jnz set_crt_mode
-/*
- * Hi-Reso (high-resolution) machine.
- *
- * Some hi-reso machines have no RAMs on bank 8/A (0x080000 - 0x0BFFFF).
- * On such machines we get two RAM banks from top of protect menory and
- * map them on bank 8/A.
- * These work-around must be done before moving myself on INITSEG (0x090000-).
- */
- movw $(HIRESO_TEXT >> 8), %cs:(vram + 1) /* text VRAM segment */
-
- /* set memory window */
- movb $0x08, %al
- outb %al, $0x91 /* map native RAM (if any) */
- movb $0x0A, %al
- outb %al, $0x93
-
- /* check bank ram A */
- pushw $0xA500
- popw %ds
- movw (%di), %cx /* %si == 0 from entry */
- notw %cx
- movw %cx, (%di)
-
- movw $0x43F, %dx /* cache flush for 486 and up. */
- movb $0xA0, %al
- outb %al, %dx
-
- cmpw %cx, (%di)
- je hireso_done
-
- /*
- * Write test failed; we have no native RAM on 080000h - 0BFFFFh.
- * Take 256KB of RAM from top of protected memory.
- */
- movb %ss:EXPMMSZ, %al
- subb $2, %al /* reduce 2 x 128KB */
- movb %al, %ss:EXPMMSZ
- addb %al, %al
- addb $0x10, %al
- outb %al, $0x91
- addb $2, %al
- outb %al, $0x93
-
-hireso_done:
- movb $0x10, %al /* CRT mode 80x31, %ah still 0Ah */
-
-set_crt_mode:
- int $0x18 /* set CRT mode */
-
- movb $0x0C, %ah /* turn on text displaying */
- int $0x18
-
- xorw %dx, %dx /* position cursor to home */
- movb $0x13, %ah
- int $0x18
-
- movb $0x11, %ah /* turn cursor displaying on */
- int $0x18
-
- /* move 1 kilobytes from [BOOTSEG:0000h] to [INITSEG:0000h] */
- cld
- xorw %si, %si
- pushw $INITSEG
- popw %es
- movw $512, %cx /* %di == 0 from entry */
- rep
- cs
- movsw
-
- ljmp $INITSEG, $go
-
-go:
- pushw %cs
- popw %ds /* %ds = %cs */
-
- popw %dx /* %dh = saved %ch passed from BIOS */
- movb %ss:DISK_BOOT, %al
- andb $0xf0, %al /* %al = Device Address */
- movb $18, %ch /* 18 secs/track, 512 b/sec (1440 KB) */
- cmpb $0x30, %al
- je try512
- cmpb $0x90, %al /* 1 MB I/F, 1 MB floppy */
- je try1.2M
- cmpb $0xf0, %al /* 640 KB I/F, 1 MB floppy */
- je try1.2M
- movb $9, %ch /* 9 secs/track, 512 b/sec ( 720 KB) */
- cmpb $0x10, %al /* 1 MB I/F, 640 KB floppy */
- je try512
- cmpb $0x70, %al /* 640 KB I/F, 640 KB floppy */
- jne error /* unknown device? */
-
- /* XXX: Does it make sense to support 8 secs/track, 512 b/sec
- (640 KB) floppy? */
-
-try512: movb $2, %cl /* 512 b/sec */
-lasttry:call tryload
-/*
- * Display error message and halt
- */
-error: movw $error_msg, %si
- call print
-wait_reboot:
- movb $0x0, %ah
- int $0x18 /* wait keyboard input */
-1: movb $0, %al
- outb %al, $0xF0 /* reset CPU */
- jmp 1b /* just in case... */
-
-try1.2M:cmpb $2, %dh
- je try2HC
- movw $0x0803, %cx /* 8 secs/track, 1024 b/sec (1232 KB) */
- call tryload
- movb $15, %ch /* 15 secs/track, 512 b/sec (1200 KB) */
- jmp try512
-try2HC: movw $0x0F02, %cx /* 15 secs/track, 512 b/sec (1200 KB) */
- call tryload
- movw $0x0803, %cx /* 8 secs/track, 1024 b/sec (1232 KB) */
- jmp lasttry
-
-/*
- * Try to load SETUP and SYSTEM provided geometry information in %cx.
- * This routine *will not* return on successful load...
- */
-tryload:
- movw %cx, sectlen
- movb %ss:DISK_BOOT, %al
- movb $0x7, %ah /* recalibrate the drive */
- int $0x1b
- jc error /* recalibration should succeed */
-
- /*
- * Load SETUP into memory. It is assumed that SETUP fits into
- * first cylinder (2 tracks, 9KB on 2DD, 15-18KB on 2HD).
- */
- movb $0, %bl
- movb setup_sects, %bh
- incb %bh
- shlw %bx /* %bx = (setup_sects + 1) * 512 */
- movw $128, %bp
- shlw %cl, %bp /* %bp = <sector size> */
- subw %bp, %bx /* length to load */
- movw $0x0002, %dx /* head 0, sector 2 */
- movb %cl, %ch /* `N' for sector address */
- movb $0, %cl /* cylinder 0 */
- pushw %cs
- popw %es /* %es = %cs (= INITSEG) */
- movb $0xd6, %ah /* read, multi-track, MFM */
- int $0x1b /* load it! */
- jc read_error
-
- movw $loading_msg, %si
- call print
-
- movw $SYSSEG, %ax
- movw %ax, %es /* %es = SYSSEG */
-
-/*
- * This routine loads the system at address 0x10000, making sure
- * no 64kB boundaries are crossed. We try to load it as fast as
- * possible, loading whole tracks whenever we can.
- *
- * in: es - starting address segment (normally 0x1000)
- */
- movb %ch, %cl
- addb $7, %cl /* %cl = log2 <sector_size> */
- shrw %cl, %bx /* %bx = # of phys. sectors in SETUP */
- addb %bl, %dl /* %dl = start sector # of SYSTEM */
- decb %dl /* %dl is 0-based in below loop */
-
-rp_read_newseg:
- xorw %bp, %bp /* = starting address within segment */
-#ifdef __BIG_KERNEL__
- bootsect_kludge = 0x220 /* 0x200 (size of bootsector) + 0x20 (offset */
- lcall *bootsect_kludge /* of bootsect_kludge in setup.S */
-#else
- movw %es, %ax
- subw $SYSSEG, %ax
-#endif
- cmpw syssize, %ax
- ja boot /* done! */
-
-rp_read:
- movb sectors, %al
- addb %al, %al
- movb %al, %ch /* # of sectors on both surface */
- subb %dl, %al /* # of sectors left on this track */
- movb $0, %ah
- shlw %cl, %ax /* # of bytes left on this track */
- movw %ax, %bx /* transfer length */
- addw %bp, %ax /* cross 64K boundary? */
- jnc 1f /* ok. */
- jz 1f /* also ok. */
- /*
- * Oops, we are crossing 64K boundary...
- * Adjust transfer length to make transfer fit in the boundary.
- *
- * Note: sector size is assumed to be a measure of 65536.
- */
- xorw %bx, %bx
- subw %bp, %bx
-1: pushw %dx
- movw $dot_msg, %si /* give progress message */
- call print
- xchgw %ax, %dx
- movb $0, %ah
- divb sectors
- xchgb %al, %ah
- xchgw %ax, %dx /* %dh = head # / %dl = sector # */
- incb %dl /* fix %dl to 1-based */
- pushw %cx
- movw cylinder, %cx
- movb $0xd6, %ah /* read, multi-track, seek, MFM */
- movb %ss:DISK_BOOT, %al
- int $0x1b
- popw %cx
- popw %dx
- jc read_error
- movw %bx, %ax /* # of bytes just read */
- shrw %cl, %ax /* %ax = # of sectors just read */
- addb %al, %dl /* advance sector # */
- cmpb %ch, %dl /* %ch = # of sectors/cylinder */
- jb 2f
- incb cylinder /* next cylinder */
- xorb %dl, %dl /* sector 0 */
-2: addw %bx, %bp /* advance offset pointer */
- jnc rp_read
- /* offset pointer wrapped; advance segment pointer. */
- movw %es, %ax
- addw $0x1000, %ax
- movw %ax, %es
- jmp rp_read_newseg
-
-read_error:
- ret
-
-boot: movw %cs, %ax /* = INITSEG */
- /* movw %ax, %ds */
- movw %ax, %ss
- movw $0x4000, %sp /* 0x4000 is arbitrary value >=
- * length of bootsect + length of
- * setup + room for stack;
- * PC-9800 never have BIOS workareas
- * on high memory.
- */
-/*
- * After that we check which root-device to use. If the device is
- * not defined, /dev/fd0 (2, 0) will be used.
- */
- cmpw $0, root_dev
- jne 3f
- movb $2, root_dev+1
-3:
-
-/*
- * After that (everything loaded), we jump to the setup-routine
- * loaded directly after the bootblock:
- */
- ljmp $SETUPSEG, $0
-
-/*
- * Subroutine for print string on console.
- * %cs:%si - pointer to message
- */
-print:
- pushaw
- pushw %ds
- pushw %es
- pushw %cs
- popw %ds
- lesw curpos, %di /* %es:%di = current text VRAM addr. */
-1: xorw %ax, %ax
- lodsb
- testb %al, %al
- jz 2f /* end of string */
- stosw /* character code */
- movb $0xE1, %es:0x2000-2(%di) /* character attribute */
- jmp 1b
-2: movw %di, %dx
- movb $0x13, %ah
- int $0x18 /* move cursor to current point */
- popw %es
- popw %ds
- popaw
- ret
-
-loading_msg:
- .string "Loading"
-dot_msg:
- .string "."
-error_msg:
- .string "Read Error!"
-
- .org 490
-
-curpos: .word 160 /* current cursor position */
-vram: .word NORMAL_TEXT /* text VRAM segment */
-
-cylinder: .byte 0 /* current cylinder (lower byte) */
-sectlen: .byte 0 /* (log2 of <sector size>) - 7 */
-sectors: .byte 0x0F /* default is 2HD (15 sector/track) */
-
-# XXX: This is a fairly snug fit.
-
-.org 497
-setup_sects: .byte SETUPSECTS
-root_flags: .word ROOT_RDONLY
-syssize: .word SYSSIZE
-swap_dev: .word SWAP_DEV
-ram_size: .word RAMDISK
-vid_mode: .word SVGA_MODE
-root_dev: .word ROOT_DEV
-boot_flag: .word 0xAA55
+++ /dev/null
-#
-# linux/arch/i386/boot/compressed/Makefile
-#
-# create a compressed vmlinux image from the original vmlinux
-#
-
-targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
-EXTRA_AFLAGS := -traditional
-
-LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32
-
-$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
- $(call if_changed,ld)
- @:
-
-$(obj)/vmlinux.bin: vmlinux FORCE
- $(call if_changed,objcopy)
-
-$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
- $(call if_changed,gzip)
-
-LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
-
-$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
- $(call if_changed,ld)
+++ /dev/null
-/*
- * linux/boot/head.S
- *
- * Copyright (C) 1991, 1992, 1993 Linus Torvalds
- */
-
-/*
- * head.S contains the 32-bit startup code.
- *
- * NOTE!!! Startup happens at absolute address 0x00001000, which is also where
- * the page directory will exist. The startup code will be overwritten by
- * the page directory. [According to comments etc elsewhere on a compressed
- * kernel it will end up at 0x1000 + 1Mb I hope so as I assume this. - AC]
- *
- * Page 0 is deliberately kept safe, since System Management Mode code in
- * laptops may need to access the BIOS data stored there. This is also
- * useful for future device drivers that either access the BIOS via VM86
- * mode.
- */
-
-/*
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-.text
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-
- .globl startup_32
-
-startup_32:
- cld
- cli
- movl $(__BOOT_DS),%eax
- movl %eax,%ds
- movl %eax,%es
- movl %eax,%fs
- movl %eax,%gs
-
- lss stack_start,%esp
- xorl %eax,%eax
-1: incl %eax # check that A20 really IS enabled
- movl %eax,0x000000 # loop forever if it isn't
- cmpl %eax,0x100000
- je 1b
-
-/*
- * Initialize eflags. Some BIOS's leave bits like NT set. This would
- * confuse the debugger if this code is traced.
- * XXX - best to initialize before switching to protected mode.
- */
- pushl $0
- popfl
-/*
- * Clear BSS
- */
- xorl %eax,%eax
- movl $_edata,%edi
- movl $_end,%ecx
- subl %edi,%ecx
- cld
- rep
- stosb
-/*
- * Do the decompression, and jump to the new kernel..
- */
- subl $16,%esp # place for structure on the stack
- movl %esp,%eax
- pushl %esi # real mode pointer as second arg
- pushl %eax # address of structure as first arg
- call decompress_kernel
- orl %eax,%eax
- jnz 3f
- popl %esi # discard address
- popl %esi # real mode pointer
- xorl %ebx,%ebx
- ljmp $(__BOOT_CS), $0x100000
-
-/*
- * We come here, if we were loaded high.
- * We need to move the move-in-place routine down to 0x1000
- * and then start it with the buffer addresses in registers,
- * which we got from the stack.
- */
-3:
- movl $move_routine_start,%esi
- movl $0x1000,%edi
- movl $move_routine_end,%ecx
- subl %esi,%ecx
- addl $3,%ecx
- shrl $2,%ecx
- cld
- rep
- movsl
-
- popl %esi # discard the address
- popl %ebx # real mode pointer
- popl %esi # low_buffer_start
- popl %ecx # lcount
- popl %edx # high_buffer_start
- popl %eax # hcount
- movl $0x100000,%edi
- cli # make sure we don't get interrupted
- ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine
-
-/*
- * Routine (template) for moving the decompressed kernel in place,
- * if we were high loaded. This _must_ PIC-code !
- */
-move_routine_start:
- movl %ecx,%ebp
- shrl $2,%ecx
- rep
- movsl
- movl %ebp,%ecx
- andl $3,%ecx
- rep
- movsb
- movl %edx,%esi
- movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
- addl $3,%ecx
- shrl $2,%ecx
- rep
- movsl
- movl %ebx,%esi # Restore setup pointer
- xorl %ebx,%ebx
- ljmp $(__BOOT_CS), $0x100000
-move_routine_end:
+++ /dev/null
-/*
- * misc.c
- *
- * This is a collection of several routines from gzip-1.0.3
- * adapted for Linux.
- *
- * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
- * puts by Nick Holloway 1993, better puts by Martin Mares 1995
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- */
-
-#include <linux/linkage.h>
-#include <linux/vmalloc.h>
-#include <linux/tty.h>
-#include <asm/io.h>
-#ifdef STANDARD_MEMORY_BIOS_CALL
-#undef STANDARD_MEMORY_BIOS_CALL
-#endif
-
-/*
- * gzip declarations
- */
-
-#define OF(args) args
-#define STATIC static
-
-#undef memset
-#undef memcpy
-
-/*
- * Why do we do this? Don't ask me..
- *
- * Incomprehensible are the ways of bootloaders.
- */
-static void* memset(void *, int, size_t);
-static void* memcpy(void *, __const void *, size_t);
-#define memzero(s, n) memset ((s), 0, (n))
-
-typedef unsigned char uch;
-typedef unsigned short ush;
-typedef unsigned long ulg;
-
-#define WSIZE 0x8000 /* Window size must be at least 32k, */
- /* and a power of two */
-
-static uch *inbuf; /* input buffer */
-static uch window[WSIZE]; /* Sliding window buffer */
-
-static unsigned insize = 0; /* valid bytes in inbuf */
-static unsigned inptr = 0; /* index of next byte to be processed in inbuf */
-static unsigned outcnt = 0; /* bytes in output buffer */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
-#define RESERVED 0xC0 /* bit 6,7: reserved */
-
-#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) error(msg);}
-# define Trace(x) fprintf x
-# define Tracev(x) {if (verbose) fprintf x ;}
-# define Tracevv(x) {if (verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-static int fill_inbuf(void);
-static void flush_window(void);
-static void error(char *m);
-static void gzip_mark(void **);
-static void gzip_release(void **);
-
-/*
- * This is set up by the setup-routine at boot-time
- */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define EXT_MEM_K (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define ALT_MEM_K (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define SCREEN_INFO (*(struct screen_info *)(real_mode+0))
-
-extern char input_data[];
-extern int input_len;
-
-static long bytes_out = 0;
-static uch *output_data;
-static unsigned long output_ptr = 0;
-
-static void *malloc(int size);
-static void free(void *where);
-
-static void puts(const char *);
-
-extern int end;
-static long free_mem_ptr = (long)&end;
-static long free_mem_end_ptr;
-
-#define INPLACE_MOVE_ROUTINE 0x1000
-#define LOW_BUFFER_START 0x2000
-#define LOW_BUFFER_MAX 0x90000
-#define HEAP_SIZE 0x3000
-static unsigned int low_buffer_end, low_buffer_size;
-static int high_loaded =0;
-static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
-
-static char *vidmem = (char *)0xa0000;
-static int lines, cols;
-
-#ifdef CONFIG_X86_NUMAQ
-static void * xquad_portio = NULL;
-#endif
-
-#include "../../../../lib/inflate.c"
-
-static void *malloc(int size)
-{
- void *p;
-
- if (size <0) error("Malloc error");
- if (free_mem_ptr <= 0) error("Memory error");
-
- free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
-
- p = (void *)free_mem_ptr;
- free_mem_ptr += size;
-
- if (free_mem_ptr >= free_mem_end_ptr)
- error("Out of memory");
-
- return p;
-}
-
-static void free(void *where)
-{ /* Don't care */
-}
-
-static void gzip_mark(void **ptr)
-{
- *ptr = (void *) free_mem_ptr;
-}
-
-static void gzip_release(void **ptr)
-{
- free_mem_ptr = (long) *ptr;
-}
-
-static void scroll(void)
-{
- int i;
-
- memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 );
- for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 )
- vidmem[i] = ' ';
-}
-
-static void puts(const char *s)
-{
- int x,y,pos;
- char c;
-
- x = SCREEN_INFO.orig_x;
- y = SCREEN_INFO.orig_y;
-
- while ( ( c = *s++ ) != '\0' ) {
- if ( c == '\n' ) {
- x = 0;
- if ( ++y >= lines ) {
- scroll();
- y--;
- }
- } else {
- vidmem [ ( x + cols * y ) * 2 ] = c;
- if ( ++x >= cols ) {
- x = 0;
- if ( ++y >= lines ) {
- scroll();
- y--;
- }
- }
- }
- }
-
- SCREEN_INFO.orig_x = x;
- SCREEN_INFO.orig_y = y;
-
- pos = x + cols * y; /* Update cursor position */
- while (!(inb_p(0x60) & 4));
- outb_p(0x49, 0x62);
- outb_p(pos & 0xff, 0x60);
- outb_p((pos >> 8) & 0xff, 0x60);
-}
-
-static void* memset(void* s, int c, size_t n)
-{
- int i;
- char *ss = (char*)s;
-
- for (i=0;i<n;i++) ss[i] = c;
- return s;
-}
-
-static void* memcpy(void* __dest, __const void* __src,
- size_t __n)
-{
- int i;
- char *d = (char *)__dest, *s = (char *)__src;
-
- for (i=0;i<__n;i++) d[i] = s[i];
- return __dest;
-}
-
-/* ===========================================================================
- * Fill the input buffer. This is called only when the buffer is empty
- * and at least one byte is really needed.
- */
-static int fill_inbuf(void)
-{
- if (insize != 0) {
- error("ran out of input data");
- }
-
- inbuf = input_data;
- insize = input_len;
- inptr = 1;
- return inbuf[0];
-}
-
-/* ===========================================================================
- * Write the output window window[0..outcnt-1] and update crc and bytes_out.
- * (Used for the decompressed data only.)
- */
-static void flush_window_low(void)
-{
- ulg c = crc; /* temporary variable */
- unsigned n;
- uch *in, *out, ch;
-
- in = window;
- out = &output_data[output_ptr];
- for (n = 0; n < outcnt; n++) {
- ch = *out++ = *in++;
- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
- }
- crc = c;
- bytes_out += (ulg)outcnt;
- output_ptr += (ulg)outcnt;
- outcnt = 0;
-}
-
-static void flush_window_high(void)
-{
- ulg c = crc; /* temporary variable */
- unsigned n;
- uch *in, ch;
- in = window;
- for (n = 0; n < outcnt; n++) {
- ch = *output_data++ = *in++;
- if ((ulg)output_data == low_buffer_end) output_data=high_buffer_start;
- c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
- }
- crc = c;
- bytes_out += (ulg)outcnt;
- outcnt = 0;
-}
-
-static void flush_window(void)
-{
- if (high_loaded) flush_window_high();
- else flush_window_low();
-}
-
-static void error(char *x)
-{
- puts("\n\n");
- puts(x);
- puts("\n\n -- System halted");
-
- while(1); /* Halt */
-}
-
-#define STACK_SIZE (4096)
-
-long user_stack [STACK_SIZE];
-
-struct {
- long * a;
- short b;
- } stack_start = { & user_stack [STACK_SIZE] , __BOOT_DS };
-
-static void setup_normal_output_buffer(void)
-{
-#ifdef STANDARD_MEMORY_BIOS_CALL
- if (EXT_MEM_K < 1024) error("Less than 2MB of memory");
-#else
- if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < 1024) error("Less than 2MB of memory");
-#endif
- output_data = (char *)0x100000; /* Points to 1M */
- free_mem_end_ptr = (long)real_mode;
-}
-
-struct moveparams {
- uch *low_buffer_start; int lcount;
- uch *high_buffer_start; int hcount;
-};
-
-static void setup_output_buffer_if_we_run_high(struct moveparams *mv)
-{
- high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE);
-#ifdef STANDARD_MEMORY_BIOS_CALL
- if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
-#else
- if ((ALT_MEM_K > EXT_MEM_K ? ALT_MEM_K : EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
-#endif
- mv->low_buffer_start = output_data = (char *)LOW_BUFFER_START;
- low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
- ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff;
- low_buffer_size = low_buffer_end - LOW_BUFFER_START;
- high_loaded = 1;
- free_mem_end_ptr = (long)high_buffer_start;
- if ( (0x100000 + low_buffer_size) > ((ulg)high_buffer_start)) {
- high_buffer_start = (uch *)(0x100000 + low_buffer_size);
- mv->hcount = 0; /* say: we need not to move high_buffer */
- }
- else mv->hcount = -1;
- mv->high_buffer_start = high_buffer_start;
-}
-
-static void close_output_buffer_if_we_run_high(struct moveparams *mv)
-{
- if (bytes_out > low_buffer_size) {
- mv->lcount = low_buffer_size;
- if (mv->hcount)
- mv->hcount = bytes_out - low_buffer_size;
- } else {
- mv->lcount = bytes_out;
- mv->hcount = 0;
- }
-}
-
-
-asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
-{
- real_mode = rmode;
-
- vidmem = (char *)(((unsigned int)SCREEN_INFO.orig_video_page) << 4);
-
- lines = SCREEN_INFO.orig_video_lines;
- cols = SCREEN_INFO.orig_video_cols;
-
- if (free_mem_ptr < 0x100000) setup_normal_output_buffer();
- else setup_output_buffer_if_we_run_high(mv);
-
- makecrc();
- puts("Uncompressing Linux... ");
- gunzip();
- puts("Ok, booting the kernel.\n");
- if (high_loaded) close_output_buffer_if_we_run_high(mv);
- return high_loaded;
-}
-
-/* We don't actually check for stack overflows this early. */
-__asm__(".globl mcount ; mcount: ret\n");
-
+++ /dev/null
-SECTIONS
-{
- .data : {
- input_len = .;
- LONG(input_data_end - input_data) input_data = .;
- *(.data)
- input_data_end = .;
- }
-}
+++ /dev/null
-#!/bin/sh
-#
-# arch/i386/boot/install.sh
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for i386 architecture
-#
-# Arguments:
-# $1 - kernel version
-# $2 - kernel image file
-# $3 - kernel map file
-# $4 - default install path (blank if root directory)
-#
-
-# User may have a custom install script
-
-if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
-if [ -x /sbin/installkernel ]; then exec /sbin/installkernel "$@"; fi
-
-# Default install - same as make zlilo
-
-if [ -f $4/vmlinuz ]; then
- mv $4/vmlinuz $4/vmlinuz.old
-fi
-
-if [ -f $4/System.map ]; then
- mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
-
-if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
+++ /dev/null
-#
-# mtools configuration file for "make (b)zdisk"
-#
-
-# Actual floppy drive
-drive a:
- file="/dev/fd0"
-
-# 1.44 MB floppy disk image
-drive v:
- file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=18 filter
-
-# 2.88 MB floppy disk image (mostly for virtual uses)
-drive w:
- file="@OBJ@/fdimage" cylinders=80 heads=2 sectors=36 filter
-
-
+++ /dev/null
-/*
- * setup.S Copyright (C) 1991, 1992 Linus Torvalds
- *
- * setup.s is responsible for getting the system data from the BIOS,
- * and putting them into the appropriate places in system memory.
- * both setup.s and system has been loaded by the bootblock.
- *
- * This code asks the bios for memory/disk/other parameters, and
- * puts them in a "safe" place: 0x90000-0x901FF, ie where the
- * boot-block used to be. It is then up to the protected mode
- * system to read them from there before the area is overwritten
- * for buffer-blocks.
- *
- * Move PS/2 aux init code to psaux.c
- * (troyer@saifr00.cfsat.Honeywell.COM) 03Oct92
- *
- * some changes and additional features by Christoph Niemann,
- * March 1993/June 1994 (Christoph.Niemann@linux.org)
- *
- * add APM BIOS checking by Stephen Rothwell, May 1994
- * (sfr@canb.auug.org.au)
- *
- * High load stuff, initrd support and position independency
- * by Hans Lermen & Werner Almesberger, February 1996
- * <lermen@elserv.ffm.fgan.de>, <almesber@lrc.epfl.ch>
- *
- * Video handling moved to video.S by Martin Mares, March 1996
- * <mj@k332.feld.cvut.cz>
- *
- * Extended memory detection scheme retwiddled by orc@pell.chi.il.us (david
- * parsons) to avoid loadlin confusion, July 1997
- *
- * Transcribed from Intel (as86) -> AT&T (gas) by Chris Noe, May 1999.
- * <stiker@northlink.com>
- *
- * Fix to work around buggy BIOSes which dont use carry bit correctly
- * and/or report extended memory in CX/DX for e801h memory size detection
- * call. As a result the kernel got wrong figures. The int15/e801h docs
- * from Ralf Brown interrupt list seem to indicate AX/BX should be used
- * anyway. So to avoid breaking many machines (presumably there was a reason
- * to orginally use CX/DX instead of AX/BX), we do a kludge to see
- * if CX/DX have been changed in the e801 call and if so use AX/BX .
- * Michael Miller, April 2001 <michaelm@mjmm.org>
- *
- * New A20 code ported from SYSLINUX by H. Peter Anvin. AMD Elan bugfixes
- * by Robert Schwebel, December 2001 <robert@schwebel.de>
- *
- * Heavily modified for NEC PC-9800 series by Kyoto University Microcomputer
- * Club (KMC) Linux/98 project <seraphim@kmc.kyoto-u.ac.jp>, 1997-1999
- */
-
-#include <linux/config.h>
-#include <asm/segment.h>
-#include <linux/version.h>
-#include <linux/compile.h>
-#include <asm/boot.h>
-#include <asm/e820.h>
-#include <asm/page.h>
-
-/* Signature words to ensure LILO loaded us right */
-#define SIG1 0xAA55
-#define SIG2 0x5A5A
-
-#define HIRESO_TEXT 0xe000
-#define NORMAL_TEXT 0xa000
-
-#define BIOS_FLAG2 0x0400
-#define BIOS_FLAG5 0x0458
-#define RDISK_EQUIP 0x0488
-#define BIOS_FLAG 0x0501
-#define KB_SHFT_STS 0x053a
-#define DISK_EQUIP 0x055c
-
-INITSEG = DEF_INITSEG # 0x9000, we move boot here, out of the way
-SYSSEG = DEF_SYSSEG # 0x1000, system loaded at 0x10000 (65536).
-SETUPSEG = DEF_SETUPSEG # 0x9020, this is the current segment
- # ... and the former contents of CS
-
-DELTA_INITSEG = SETUPSEG - INITSEG # 0x0020
-
-.code16
-.globl begtext, begdata, begbss, endtext, enddata, endbss
-
-.text
-begtext:
-.data
-begdata:
-.bss
-begbss:
-.text
-
-start:
- jmp trampoline
-
-# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
-
- .ascii "HdrS" # header signature
- .word 0x0203 # header version number (>= 0x0105)
- # or else old loadlin-1.5 will fail)
-realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
-start_sys_seg: .word SYSSEG
- .word kernel_version # pointing to kernel version string
- # above section of header is compatible
- # with loadlin-1.5 (header v1.5). Don't
- # change it.
-
-type_of_loader: .byte 0 # = 0, old one (LILO, Loadlin,
- # Bootlin, SYSLX, bootsect...)
- # See Documentation/i386/boot.txt for
- # assigned ids
-
-# flags, unused bits must be zero (RFU) bit within loadflags
-loadflags:
-LOADED_HIGH = 1 # If set, the kernel is loaded high
-CAN_USE_HEAP = 0x80 # If set, the loader also has set
- # heap_end_ptr to tell how much
- # space behind setup.S can be used for
- # heap purposes.
- # Only the loader knows what is free
-#ifndef __BIG_KERNEL__
- .byte 0
-#else
- .byte LOADED_HIGH
-#endif
-
-setup_move_size: .word 0x8000 # size to move, when setup is not
- # loaded at 0x90000. We will move setup
- # to 0x90000 then just before jumping
- # into the kernel. However, only the
- # loader knows how much data behind
- # us also needs to be loaded.
-
-code32_start: # here loaders can put a different
- # start address for 32-bit code.
-#ifndef __BIG_KERNEL__
- .long 0x1000 # 0x1000 = default for zImage
-#else
- .long 0x100000 # 0x100000 = default for big kernel
-#endif
-
-ramdisk_image: .long 0 # address of loaded ramdisk image
- # Here the loader puts the 32-bit
- # address where it loaded the image.
- # This only will be read by the kernel.
-
-ramdisk_size: .long 0 # its size in bytes
-
-bootsect_kludge:
- .long 0 # obsolete
-
-heap_end_ptr: .word modelist+1024 # (Header version 0x0201 or later)
- # space from here (exclusive) down to
- # end of setup code can be used by setup
- # for local heap purposes.
-
-pad1: .word 0
-cmd_line_ptr: .long 0 # (Header version 0x0202 or later)
- # If nonzero, a 32-bit pointer
- # to the kernel command line.
- # The command line should be
- # located between the start of
- # setup and the end of low
- # memory (0xa0000), or it may
- # get overwritten before it
- # gets read. If this field is
- # used, there is no longer
- # anything magical about the
- # 0x90000 segment; the setup
- # can be located anywhere in
- # low memory 0x10000 or higher.
-
-ramdisk_max: .long MAXMEM-1 # (Header version 0x0203 or later)
- # The highest safe address for
- # the contents of an initrd
-
-trampoline: call start_of_setup
- .space 1024
-# End of setup header #####################################################
-
-start_of_setup:
-# Set %ds = %cs, we know that SETUPSEG = %cs at this point
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
-# Check signature at end of setup
- cmpw $SIG1, setup_sig1
- jne bad_sig
-
- cmpw $SIG2, setup_sig2
- jne bad_sig
-
- jmp good_sig1
-
-# Routine to print asciiz string at ds:si
-prtstr:
- lodsb
- andb %al, %al
- jz fin
-
- call prtchr
- jmp prtstr
-
-fin: ret
-
-no_sig_mess: .string "No setup signature found ..."
-
-good_sig1:
- jmp good_sig
-
-# We now have to find the rest of the setup code/data
-bad_sig:
- movw %cs, %ax # SETUPSEG
- subw $DELTA_INITSEG, %ax # INITSEG
- movw %ax, %ds
- xorb %bh, %bh
- movb (497), %bl # get setup sect from bootsect
- subw $4, %bx # LILO loads 4 sectors of setup
- shlw $8, %bx # convert to words (1sect=2^8 words)
- movw %bx, %cx
- shrw $3, %bx # convert to segment
- addw $SYSSEG, %bx
- movw %bx, %cs:start_sys_seg
-# Move rest of setup code/data to here
- movw $2048, %di # four sectors loaded by LILO
- subw %si, %si
- pushw %cs
- popw %es
- movw $SYSSEG, %ax
- movw %ax, %ds
- rep
- movsw
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
- cmpw $SIG1, setup_sig1
- jne no_sig
-
- cmpw $SIG2, setup_sig2
- jne no_sig
-
- jmp good_sig
-
-no_sig:
- lea no_sig_mess, %si
- call prtstr
-
-no_sig_loop:
- hlt
- jmp no_sig_loop
-
-good_sig:
- movw %cs, %ax # aka SETUPSEG
- subw $DELTA_INITSEG, %ax # aka INITSEG
- movw %ax, %ds
-# Check if an old loader tries to load a big-kernel
- testb $LOADED_HIGH, %cs:loadflags # Do we have a big kernel?
- jz loader_ok # No, no danger for old loaders.
-
- cmpb $0, %cs:type_of_loader # Do we have a loader that
- # can deal with us?
- jnz loader_ok # Yes, continue.
-
- pushw %cs # No, we have an old loader,
- popw %ds # die.
- lea loader_panic_mess, %si
- call prtstr
-
- jmp no_sig_loop
-
-loader_panic_mess: .string "Wrong loader, giving up..."
-
-loader_ok:
-# Get memory size (extended mem, kB)
-
-# On PC-9800, memory size detection is done completely in 32-bit
-# kernel initialize code (kernel/setup.c).
- pushw %es
- xorl %eax, %eax
- movw %ax, %es
- movb %al, (E820NR) # PC-9800 has no E820
- movb %es:(0x401), %al
- shll $7, %eax
- addw $1024, %ax
- movw %ax, (2)
- movl %eax, (0x1e0)
- movw %es:(0x594), %ax
- shll $10, %eax
- addl %eax, (0x1e0)
- popw %es
-
-# Check for video adapter and its parameters and allow the
-# user to browse video modes.
- call video # NOTE: we need %ds pointing
- # to bootsector
-
-# Get text video mode
- movb $0x0B, %ah
- int $0x18 # CRT mode sense
- movw $(20 << 8) + 40, %cx
- testb $0x10, %al
- jnz 3f
- movb $20, %ch
- testb $0x01, %al
- jnz 1f
- movb $25, %ch
- jmp 1f
-3: # If bit 4 was 1, it means either 1) 31 lines for hi-reso mode,
- # or 2) 30 lines for PC-9821.
- movb $31, %ch # hireso mode value
- pushw $0
- popw %es
- testb $0x08, %es:BIOS_FLAG
- jnz 1f
- movb $30, %ch
-1: # Now we got # of rows in %ch
- movb %ch, (14)
-
- testb $0x02, %al
- jnz 2f
- movb $80, %cl
-2: # Now we got # of columns in %cl
- movb %cl, (7)
-
- # Next, get horizontal frequency if supported
- movw $0x3100, %ax
- int $0x18 # Call CRT bios
- movb %al, (6) # If 31h is unsupported, %al remains 0
-
-# Get hd0-3 data...
- pushw %ds # aka INITSEG
- popw %es
- xorw %ax, %ax
- movw %ax, %ds
- cld
- movw $0x0080, %di
- movb DISK_EQUIP+1, %ah
- movb $0x80, %al
-
-get_hd_info:
- shrb %ah
- pushw %ax
- jnc 1f
- movb $0x84, %ah
- int $0x1b
- jnc 2f # Success
-1: xorw %cx, %cx # `0 cylinders' means no drive
-2: # Attention! Work area (drive_info) is arranged for PC-9800.
- movw %cx, %ax # # of cylinders
- stosw
- movw %dx, %ax # # of sectors / # of heads
- stosw
- movw %bx, %ax # sector size in bytes
- stosw
- popw %ax
- incb %al
- cmpb $0x84, %al
- jb get_hd_info
-
-# Get fd data...
- movw DISK_EQUIP, %ax
- andw $0xf00f, %ax
- orb %al, %ah
- movb RDISK_EQUIP, %al
- notb %al
- andb %al, %ah # ignore all `RAM drive'
-
- movb $0x30, %al
-
-get_fd_info:
- shrb %ah
- pushw %ax
- jnc 1f
- movb $0xc4, %ah
- int $0x1b
- movb %ah, %al
- andb $4, %al # 1.44MB support flag
- shrb %al
- addb $2, %al # %al = 2 (1.2MB) or 4 (1.44MB)
- jmp 2f
-1: movb $0, %al # no drive
-2: stosb
- popw %ax
- incb %al
- testb $0x04, %al
- jz get_fd_info
-
- addb $(0xb0 - 0x34), %al
- jnc get_fd_info # check FDs on 640KB I/F
-
- pushw %es
- popw %ds # %ds got bootsector again
-#if 0
- mov $0, (0x1ff) # default is no pointing device
-#endif
-
-#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
-# Then check for an APM BIOS...
- # %ds points to the bootsector
- movw $0, 0x40 # version = 0 means no APM BIOS
- movw $0x09a00, %ax # APM BIOS installation check
- xorw %bx, %bx
- int $0x1f
- jc done_apm_bios # Nope, no APM BIOS
-
- cmpw $0x0504d, %bx # Check for "PM" signature
- jne done_apm_bios # No signature, no APM BIOS
-
- testb $0x02, %cl # Is 32 bit supported?
- je done_apm_bios # No 32-bit, no (good) APM BIOS
-
- movw $0x09a04, %ax # Disconnect first just in case
- xorw %bx, %bx
- int $0x1f # ignore return code
- movw $0x09a03, %ax # 32 bit connect
- xorl %ebx, %ebx
- int $0x1f
- jc no_32_apm_bios # Ack, error.
-
- movw %ax, (66) # BIOS code segment
- movl %ebx, (68) # BIOS entry point offset
- movw %cx, (72) # BIOS 16 bit code segment
- movw %dx, (74) # BIOS data segment
- movl %esi, (78) # BIOS code segment length
- movw %di, (82) # BIOS data segment length
-# Redo the installation check as the 32 bit connect
-# modifies the flags returned on some BIOSs
- movw $0x09a00, %ax # APM BIOS installation check
- xorw %bx, %bx
- int $0x1f
- jc apm_disconnect # error -> shouldn't happen
-
- cmpw $0x0504d, %bx # check for "PM" signature
- jne apm_disconnect # no sig -> shouldn't happen
-
- movw %ax, (64) # record the APM BIOS version
- movw %cx, (76) # and flags
- jmp done_apm_bios
-
-apm_disconnect: # Tidy up
- movw $0x09a04, %ax # Disconnect
- xorw %bx, %bx
- int $0x1f # ignore return code
-
- jmp done_apm_bios
-
-no_32_apm_bios:
- andw $0xfffd, (76) # remove 32 bit support bit
-done_apm_bios:
-#endif
-
-# Pass cursor position to kernel...
- movw %cs:cursor_address, %ax
- shrw %ax # cursor_address is 2 bytes unit
- movb $80, %cl
- divb %cl
- xchgb %al, %ah # (0) = %al = X, (1) = %ah = Y
- movw %ax, (0)
-
-#if 0
- movw $msg_cpos, %si
- call prtstr_cs
- call prthex
- call prtstr_cs
- movw %ds, %ax
- call prthex
- call prtstr_cs
- movb $0x11, %ah
- int $0x18
- movb $0, %ah
- int $0x18
- .section .rodata, "a"
-msg_cpos: .string "Cursor position: 0x"
- .string ", %ds:0x"
- .string "\r\n"
- .previous
-#endif
-
-# Now we want to move to protected mode ...
- cmpw $0, %cs:realmode_swtch
- jz rmodeswtch_normal
-
- lcall *%cs:realmode_swtch
-
- jmp rmodeswtch_end
-
-rmodeswtch_normal:
- pushw %cs
- call default_switch
-
-rmodeswtch_end:
-# we get the code32 start address and modify the below 'jmpi'
-# (loader may have changed it)
- movl %cs:code32_start, %eax
- movl %eax, %cs:code32
-
-# Now we move the system to its rightful place ... but we check if we have a
-# big-kernel. In that case we *must* not move it ...
- testb $LOADED_HIGH, %cs:loadflags
- jz do_move0 # .. then we have a normal low
- # loaded zImage
- # .. or else we have a high
- # loaded bzImage
- jmp end_move # ... and we skip moving
-
-do_move0:
- movw $0x100, %ax # start of destination segment
- movw %cs, %bp # aka SETUPSEG
- subw $DELTA_INITSEG, %bp # aka INITSEG
- movw %cs:start_sys_seg, %bx # start of source segment
- cld
-do_move:
- movw %ax, %es # destination segment
- incb %ah # instead of add ax,#0x100
- movw %bx, %ds # source segment
- addw $0x100, %bx
- subw %di, %di
- subw %si, %si
- movw $0x800, %cx
- rep
- movsw
- cmpw %bp, %bx # assume start_sys_seg > 0x200,
- # so we will perhaps read one
- # page more than needed, but
- # never overwrite INITSEG
- # because destination is a
- # minimum one page below source
- jb do_move
-
-end_move:
-# then we load the segment descriptors
- movw %cs, %ax # aka SETUPSEG
- movw %ax, %ds
-
-# Check whether we need to be downward compatible with version <=201
- cmpl $0, cmd_line_ptr
- jne end_move_self # loader uses version >=202 features
- cmpb $0x20, type_of_loader
- je end_move_self # bootsect loader, we know of it
-
-# Boot loader does not support boot protocol version 2.02.
-# If we have our code not at 0x90000, we need to move it there now.
-# We also then need to move the params behind it (commandline)
-# Because we would overwrite the code on the current IP, we move
-# it in two steps, jumping high after the first one.
- movw %cs, %ax
- cmpw $SETUPSEG, %ax
- je end_move_self
-
- cli # make sure we really have
- # interrupts disabled !
- # because after this the stack
- # should not be used
- subw $DELTA_INITSEG, %ax # aka INITSEG
- movw %ss, %dx
- cmpw %ax, %dx
- jb move_self_1
-
- addw $INITSEG, %dx
- subw %ax, %dx # this will go into %ss after
- # the move
-move_self_1:
- movw %ax, %ds
- movw $INITSEG, %ax # real INITSEG
- movw %ax, %es
- movw %cs:setup_move_size, %cx
- std # we have to move up, so we use
- # direction down because the
- # areas may overlap
- movw %cx, %di
- decw %di
- movw %di, %si
- subw $move_self_here+0x200, %cx
- rep
- movsb
- ljmp $SETUPSEG, $move_self_here
-
-move_self_here:
- movw $move_self_here+0x200, %cx
- rep
- movsb
- movw $SETUPSEG, %ax
- movw %ax, %ds
- movw %dx, %ss
-
-end_move_self: # now we are at the right place
- lidt idt_48 # load idt with 0,0
- xorl %eax, %eax # Compute gdt_base
- movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
- shll $4, %eax
- addl $gdt, %eax
- movl %eax, (gdt_48+2)
- lgdt gdt_48 # load gdt with whatever is
- # appropriate
-
-# that was painless, now we enable A20
-
- outb %al, $0xf2 # A20 on
- movb $0x02, %al
- outb %al, $0xf6 # also A20 on; making ITF's
- # way our model
-
- # PC-9800 seems to enable A20 at the moment of `outb';
- # so we don't wait unlike IBM PCs (see ../setup.S).
-
-# enable DMA to access memory over 0x100000 (1MB).
-
- movw $0x439, %dx
- inb %dx, %al
- andb $(~4), %al
- outb %al, %dx
-
-# Set DMA to increment its bank address automatically at 16MB boundary.
-# Initial setting is 64KB boundary mode so that we can't run DMA crossing
-# physical address 0xXXXXFFFF.
-
- movb $0x0c, %al
- outb %al, $0x29 # ch. 0
- movb $0x0d, %al
- outb %al, $0x29 # ch. 1
- movb $0x0e, %al
- outb %al, $0x29 # ch. 2
- movb $0x0f, %al
- outb %al, $0x29 # ch. 3
- movb $0x50, %al
- outb %al, $0x11 # reinitialize DMAC
-
-# make sure any possible coprocessor is properly reset..
- movb $0, %al
- outb %al, $0xf8
- outb %al, $0x5f # delay
-
-# well, that went ok, I hope. Now we mask all interrupts - the rest
-# is done in init_IRQ().
- movb $0xFF, %al # mask all interrupts for now
- outb %al, $0x0A
- outb %al, $0x5f # delay
-
- movb $0x7F, %al # mask all irq's but irq7 which
- outb %al, $0x02 # is cascaded
-
-# Well, that certainly wasn't fun :-(. Hopefully it works, and we don't
-# need no steenking BIOS anyway (except for the initial loading :-).
-# The BIOS-routine wants lots of unnecessary data, and it's less
-# "interesting" anyway. This is how REAL programmers do it.
-#
-# Well, now's the time to actually move into protected mode. To make
-# things as simple as possible, we do no register set-up or anything,
-# we let the gnu-compiled 32-bit programs do that. We just jump to
-# absolute address 0x1000 (or the loader supplied one),
-# in 32-bit protected mode.
-#
-# Note that the short jump isn't strictly needed, although there are
-# reasons why it might be a good idea. It won't hurt in any case.
- movw $1, %ax # protected mode (PE) bit
- lmsw %ax # This is it!
- jmp flush_instr
-
-flush_instr:
- xorw %bx, %bx # Flag to indicate a boot
- xorl %esi, %esi # Pointer to real-mode code
- movw %cs, %si
- subw $DELTA_INITSEG, %si
- shll $4, %esi # Convert to 32-bit pointer
-# NOTE: For high loaded big kernels we need a
-# jmpi 0x100000,__BOOT_CS
-#
-# but we yet haven't reloaded the CS register, so the default size
-# of the target offset still is 16 bit.
-# However, using an operand prefix (0x66), the CPU will properly
-# take our 48 bit far pointer. (INTeL 80386 Programmer's Reference
-# Manual, Mixing 16-bit and 32-bit code, page 16-6)
-
- .byte 0x66, 0xea # prefix + jmpi-opcode
-code32: .long 0x1000 # will be set to 0x100000
- # for big kernels
- .word __BOOT_CS
-
-# Here's a bunch of information about your current kernel..
-kernel_version: .ascii UTS_RELEASE
- .ascii " ("
- .ascii LINUX_COMPILE_BY
- .ascii "@"
- .ascii LINUX_COMPILE_HOST
- .ascii ") "
- .ascii UTS_VERSION
- .byte 0
-
-# This is the default real mode switch routine.
-# to be called just before protected mode transition
-default_switch:
- cli # no interrupts allowed !
- outb %al, $0x50 # disable NMI for bootup
- # sequence
- lret
-
-
-# This routine prints one character (in %al) on console.
-# PC-9800 doesn't have BIOS-function to do it like IBM PC's INT 10h - 0Eh,
-# so we hardcode `prtchr' subroutine here.
-prtchr:
- pushaw
- pushw %es
- cmpb $0, %cs:prtchr_initialized
- jnz prtchr_ok
- xorw %cx, %cx
- movw %cx, %es
- testb $0x8, %es:BIOS_FLAG
- jz 1f
- movb $(HIRESO_TEXT >> 8), %cs:cursor_address+3
- movw $(80 * 31 * 2), %cs:max_cursor_offset
-1: pushw %ax
- call get_cursor_position
- movw %ax, %cs:cursor_address
- popw %ax
- movb $1, %cs:prtchr_initialized
-prtchr_ok:
- lesw %cs:cursor_address, %di
- movw $160, %bx
- movb $0, %ah
- cmpb $13, %al
- je do_cr
- cmpb $10, %al
- je do_lf
-
- # normal (printable) character
- stosw
- movb $0xe1, %es:0x2000-2(%di)
- jmp 1f
-
-do_cr: movw %di, %ax
- divb %bl # %al = Y, %ah = X * 2
- mulb %bl
- movw %ax, %dx
- jmp 2f
-
-do_lf: addw %bx, %di
-1: movw %cs:max_cursor_offset, %cx
- cmpw %cx, %di
- movw %di, %dx
- jb 2f
- # cursor reaches bottom of screen; scroll it
- subw %bx, %dx
- xorw %di, %di
- movw %bx, %si
- cld
- subw %bx, %cx
- shrw %cx
- pushw %cx
- rep; es; movsw
- movb $32, %al # clear bottom line characters
- movb $80, %cl
- rep; stosw
- movw $0x2000, %di
- popw %cx
- leaw (%bx,%di), %si
- rep; es; movsw
- movb $0xe1, %al # clear bottom line attributes
- movb $80, %cl
- rep; stosw
-2: movw %dx, %cs:cursor_address
- movb $0x13, %ah # move cursor to right position
- int $0x18
- popw %es
- popaw
- ret
-
-cursor_address:
- .word 0
- .word NORMAL_TEXT
-max_cursor_offset:
- .word 80 * 25 * 2 # for normal 80x25 mode
-
-# putstr may called without running through start_of_setup (via bootsect_panic)
-# so we should initialize ourselves on demand.
-prtchr_initialized:
- .byte 0
-
-# This routine queries GDC (graphic display controller) for current cursor
-# position. Cursor position is returned in %ax (CPU offset address).
-get_cursor_position:
-1: inb $0x60, %al
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- testb $0x04, %al # Is FIFO empty?
- jz 1b # no -> wait until empty
-
- movb $0xe0, %al # CSRR command
- outb %al, $0x62 # command write
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
-
-2: inb $0x60, %al
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- testb $0x01, %al # Is DATA READY?
- jz 2b # no -> wait until ready
-
- inb $0x62, %al # read xAD (L)
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- movb %al, %ah
- inb $0x62, %al # read xAD (H)
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- xchgb %al, %ah # correct byte order
- pushw %ax
- inb $0x62, %al # read yAD (L)
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- inb $0x62, %al # read yAD (M)
- outb %al, $0x5f # delay
- outb %al, $0x5f # delay
- inb $0x62, %al # read yAD (H)
- # yAD is not our interest,
- # so discard it.
- popw %ax
- addw %ax, %ax # convert to CPU address
- ret
-
-# Descriptor tables
-#
-# NOTE: The intel manual says gdt should be sixteen bytes aligned for
-# efficiency reasons. However, there are machines which are known not
-# to boot with misaligned GDTs, so alter this at your peril! If you alter
-# GDT_ENTRY_BOOT_CS (in asm/segment.h) remember to leave at least two
-# empty GDT entries (one for NULL and one reserved).
-#
-# NOTE: On some CPUs, the GDT must be 8 byte aligned. This is
-# true for the Voyager Quad CPU card which will not boot without
-# This directive. 16 byte aligment is recommended by intel.
-#
- .align 16
-gdt:
- .fill GDT_ENTRY_BOOT_CS,8,0
-
- .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
- .word 0 # base address = 0
- .word 0x9A00 # code read/exec
- .word 0x00CF # granularity = 4096, 386
- # (+5th nibble of limit)
-
- .word 0xFFFF # 4Gb - (0x100000*0x1000 = 4Gb)
- .word 0 # base address = 0
- .word 0x9200 # data read/write
- .word 0x00CF # granularity = 4096, 386
- # (+5th nibble of limit)
-gdt_end:
- .align 4
-
- .word 0 # alignment byte
-idt_48:
- .word 0 # idt limit = 0
- .word 0, 0 # idt base = 0L
-
- .word 0 # alignment byte
-gdt_48:
- .word gdt_end - gdt - 1 # gdt limit
- .word 0, 0 # gdt base (filled in later)
-
-# Include video setup & detection code
-
-#include "video.S"
-
-# Setup signature -- must be last
-setup_sig1: .word SIG1
-setup_sig2: .word SIG2
-
-# After this point, there is some free space which is used by the video mode
-# handling code to store the temporary mode table (not used by the kernel).
-
-modelist:
-
-.text
-endtext:
-.data
-enddata:
-.bss
-endbss:
+++ /dev/null
-/*
- * $Id: build.c,v 1.5 1997/05/19 12:29:58 mj Exp $
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright (C) 1997 Martin Mares
- */
-
-/*
- * This file builds a disk-image from three different files:
- *
- * - bootsect: exactly 512 bytes of 8086 machine code, loads the rest
- * - setup: 8086 machine code, sets up system parm
- * - system: 80386 code for actual system
- *
- * It does some checking that all files are of the correct type, and
- * just writes the result to stdout, removing headers and padding to
- * the right amount. It also writes some system data to stderr.
- */
-
-/*
- * Changes by tytso to allow root device specification
- * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
- * Cross compiling fixes by Gertjan van Wingerde, July 1996
- * Rewritten by Martin Mares, April 1997
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <asm/boot.h>
-
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned long u32;
-
-#define DEFAULT_MAJOR_ROOT 0
-#define DEFAULT_MINOR_ROOT 0
-
-/* Minimal number of setup sectors (see also bootsect.S) */
-#define SETUP_SECTS 4
-
-byte buf[1024];
-int fd;
-int is_big_kernel;
-
-void die(const char * str, ...)
-{
- va_list args;
- va_start(args, str);
- vfprintf(stderr, str, args);
- fputc('\n', stderr);
- exit(1);
-}
-
-void file_open(const char *name)
-{
- if ((fd = open(name, O_RDONLY, 0)) < 0)
- die("Unable to open `%s': %m", name);
-}
-
-void usage(void)
-{
- die("Usage: build [-b] bootsect setup system [rootdev] [> image]");
-}
-
-int main(int argc, char ** argv)
-{
- unsigned int i, c, sz, setup_sectors;
- u32 sys_size;
- byte major_root, minor_root;
- struct stat sb;
-
- if (argc > 2 && !strcmp(argv[1], "-b"))
- {
- is_big_kernel = 1;
- argc--, argv++;
- }
- if ((argc < 4) || (argc > 5))
- usage();
- if (argc > 4) {
- if (!strcmp(argv[4], "CURRENT")) {
- if (stat("/", &sb)) {
- perror("/");
- die("Couldn't stat /");
- }
- major_root = major(sb.st_dev);
- minor_root = minor(sb.st_dev);
- } else if (strcmp(argv[4], "FLOPPY")) {
- if (stat(argv[4], &sb)) {
- perror(argv[4]);
- die("Couldn't stat root device.");
- }
- major_root = major(sb.st_rdev);
- minor_root = minor(sb.st_rdev);
- } else {
- major_root = 0;
- minor_root = 0;
- }
- } else {
- major_root = DEFAULT_MAJOR_ROOT;
- minor_root = DEFAULT_MINOR_ROOT;
- }
- fprintf(stderr, "Root device is (%d, %d)\n", major_root, minor_root);
-
- file_open(argv[1]);
- i = read(fd, buf, sizeof(buf));
- fprintf(stderr,"Boot sector %d bytes.\n",i);
- if (i != 512)
- die("Boot block must be exactly 512 bytes");
- if (buf[510] != 0x55 || buf[511] != 0xaa)
- die("Boot block hasn't got boot flag (0xAA55)");
- buf[508] = minor_root;
- buf[509] = major_root;
- if (write(1, buf, 512) != 512)
- die("Write call failed");
- close (fd);
-
- file_open(argv[2]); /* Copy the setup code */
- for (i=0 ; (c=read(fd, buf, sizeof(buf)))>0 ; i+=c )
- if (write(1, buf, c) != c)
- die("Write call failed");
- if (c != 0)
- die("read-error on `setup'");
- close (fd);
-
- setup_sectors = (i + 511) / 512; /* Pad unused space with zeros */
- if (!(setup_sectors & 1))
- setup_sectors++; /* setup_sectors must be odd on NEC PC-9800 */
- fprintf(stderr, "Setup is %d bytes.\n", i);
- memset(buf, 0, sizeof(buf));
- while (i < setup_sectors * 512) {
- c = setup_sectors * 512 - i;
- if (c > sizeof(buf))
- c = sizeof(buf);
- if (write(1, buf, c) != c)
- die("Write call failed");
- i += c;
- }
-
- file_open(argv[3]);
- if (fstat (fd, &sb))
- die("Unable to stat `%s': %m", argv[3]);
- sz = sb.st_size;
- fprintf (stderr, "System is %d kB\n", sz/1024);
- sys_size = (sz + 15) / 16;
- /* 0x40000*16 = 4.0 MB, reasonable estimate for the current maximum */
- if (sys_size > (is_big_kernel ? 0x40000 : DEF_SYSSIZE))
- die("System is too big. Try using %smodules.",
- is_big_kernel ? "" : "bzImage or ");
- while (sz > 0) {
- int l, n;
-
- l = (sz > sizeof(buf)) ? sizeof(buf) : sz;
- if ((n=read(fd, buf, l)) != l) {
- if (n < 0)
- die("Error reading %s: %m", argv[3]);
- else
- die("%s: Unexpected EOF", argv[3]);
- }
- if (write(1, buf, l) != l)
- die("Write failed");
- sz -= l;
- }
- close(fd);
-
- if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
- die("Output: seek failed");
- buf[0] = setup_sectors;
- if (write(1, buf, 1) != 1)
- die("Write of setup sector count failed");
- if (lseek(1, 500, SEEK_SET) != 500)
- die("Output: seek failed");
- buf[0] = (sys_size & 0xff);
- buf[1] = ((sys_size >> 8) & 0xff);
- if (write(1, buf, 2) != 2)
- die("Write of image length failed");
-
- return 0; /* Everything is OK */
-}
+++ /dev/null
-/* video.S
- *
- * Video mode setup, etc. for NEC PC-9800 series.
- *
- * Copyright (C) 1997,98,99 Linux/98 project <seraphim@kmc.kyoto-u.ac.jp>
- *
- * Based on the video.S for IBM PC:
- * copyright (C) Martin Mares <mj@atrey.karlin.mff.cuni.cz>
- */
-
-/* Positions of various video parameters passed to the kernel */
-/* (see also include/linux/tty.h) */
-#define PARAM_CURSOR_POS 0x00
-#define PARAM_VIDEO_PAGE 0x04
-#define PARAM_VIDEO_MODE 0x06
-#define PARAM_VIDEO_COLS 0x07
-#define PARAM_VIDEO_EGA_BX 0x0a
-#define PARAM_VIDEO_LINES 0x0e
-#define PARAM_HAVE_VGA 0x0f
-#define PARAM_FONT_POINTS 0x10
-
-#define PARAM_VIDEO98_COMPAT 0x0a
-#define PARAM_VIDEO98_HIRESO 0x0b
-#define PARAM_VIDEO98_MACHTYPE 0x0c
-#define PARAM_VIDEO98_LINES 0x0e
-#define PARAM_VIDEO98_COLS 0x0f
-
-# PARAM_LFB_* and PARAM_VESAPM_* are unused on PC-9800.
-
-# This is the main entry point called by setup.S
-# %ds *must* be pointing to the bootsector
-video: xorw %ax, %ax
- movw %ax, %es # %es = 0
-
- movb %es:BIOS_FLAG, %al
- movb %al, PARAM_VIDEO_MODE
-
- movb $0, PARAM_VIDEO98_HIRESO # 0 = normal
- movw $NORMAL_TEXT, PARAM_VIDEO_PAGE
- testb $0x8, %al
- movw $(80 * 256 + 25), %ax
- jz 1f
- # hireso machine.
- movb $1, PARAM_VIDEO98_HIRESO # !0 = hi-reso
- movb $(HIRESO_TEXT >> 8), PARAM_VIDEO_PAGE + 1
- movw $(80 * 256 + 31), %ax
-1: movw %ax, PARAM_VIDEO98_LINES # also sets VIDEO98_COLS
-
- movb $0xc0, %ch # 400-line graphic mode
- movb $0x42, %ah
- int $0x18
-
- movw $80, PARAM_VIDEO_COLS
-
- movw $msg_probing, %si
- call prtstr_cs
-
-# Check vendor from font pattern of `A'...
-
-1: inb $0x60, %al # wait V-sync
- testb $0x20, %al
- jnz 1b
-2: inb $0x60, %al
- testb $0x20, %al
- jz 2b
-
- movb $0x00, %al # select font of `A'
- outb %al, $0xa1
- movb $0x41, %al
- outb %al, $0xa3
-
- movw $8, %cx
- movw PARAM_VIDEO_PAGE, %ax
- cmpw $NORMAL_TEXT, %ax
- je 3f
- movb $24, %cl # for hi-reso machine
-3: addw $0x400, %ax # %ax = CG window segment
- pushw %ds
- movw %ax, %ds
- xorw %dx, %dx # get sum of `A' pattern...
- xorw %si, %si
-4: lodsw
- addw %ax, %dx
- loop 4b
- popw %ds
-
- movw %dx, %ax
- movw $msg_nec, %si
- xorw %bx, %bx # vendor info will go into %bx
- testb $8, %es:BIOS_FLAG
- jnz check_hireso_vendor
- cmpw $0xc7f8, %ax
- je 5f
- jmp 6f
-check_hireso_vendor:
- cmpw $0x9639, %ax # XXX: NOT VERIFIED!!!
- je 5f
-6: incw %bx # compatible machine
- movw $msg_compat, %si
-5: movb %bl, PARAM_VIDEO98_COMPAT
- call prtstr_cs
-
- movw $msg_fontdata, %si
- call prtstr_cs # " (CG sum of A = 0x"
- movw %dx, %ax
- call prthex
- call prtstr_cs # ") PC-98"
-
- movb $'0', %al
- pushw %ds
- pushw $0xf8e8
- popw %ds
- cmpw $0x2198, (0)
- popw %ds
- jne 7f
- movb $'2', %al
-7: call prtchr
- call prtstr_cs # "1 "
-
- movb $0, PARAM_VIDEO98_MACHTYPE
-#if 0 /* XXX - This check is bogus? [0000:BIOS_FLAG2]-bit7 does NOT
- indicate whether it is a note machine, but merely indicates
- whether it has ``RAM drive''. */
-# check note machine
- testb $0x80, %es:BIOS_FLAG2
- jnz is_note
- pushw %ds
- pushw $0xfd80
- popw %ds
- movb (4), %al
- popw %ds
- cmpb $0x20, %al # EPSON note A
- je epson_note
- cmpb $0x22, %al # EPSON note W
- je epson_note
- cmpb $0x27, %al # EPSON note AE
- je epson_note
- cmpb $0x2a, %al # EPSON note WR
- jne note_done
-epson_note:
- movb $1, PARAM_VIDEO98_MACHTYPE
- movw $msg_note, %si
- call prtstr_cs
-note_done:
-#endif
-
-# print h98 ? (only NEC)
- cmpb $0, PARAM_VIDEO98_COMPAT
- jnz 8f # not NEC -> not H98
-
- testb $0x80, %es:BIOS_FLAG5
- jz 8f # have NESA bus -> H98
- movw $msg_h98, %si
- call prtstr_cs
- orb $2, PARAM_VIDEO98_MACHTYPE
-8: testb $0x40, %es:BIOS_FLAG5
- jz 9f
- movw $msg_gs, %si
- call prtstr_cs # only prints it :-)
-9:
- movw $msg_normal, %si # "normal"
- testb $0x8, %es:BIOS_FLAG
- jz 1f
- movw $msg_hireso, %si
-1: call prtstr_cs
-
- movw $msg_sysclk, %si
- call prtstr_cs
- movb $'5', %al
- testb $0x80, %es:BIOS_FLAG
- jz 2f
- movb $'8', %al
-2: call prtchr
- call prtstr_cs
-
-#if 0
- testb $0x40, %es:(0x45c)
- jz no_30line # no 30-line support
-
- movb %es:KB_SHFT_STS, %al
- testb $0x01, %al # is SHIFT key pressed?
- jz no_30line
-
- testb $0x10, %al # is CTRL key pressed?
- jnz line40
-
- # switch to 30-line mode
- movb $30, PARAM_VIDEO98_LINES
- movw $msg_30line, %si
- jmp 3f
-
-line40:
- movb $37, PARAM_VIDEO98_LINES
- movw $40, PARAM_VIDEO_LINES
- movw $msg_40line, %si
-3: call prtstr_cs
-
- movb $0x32, %bh
- movw $0x300c, %ax
- int $0x18 # switch video mode
- movb $0x0c, %ah
- int $0x18 # turn on text plane
- movw %cs:cursor_address, %dx
- movb $0x13, %ah
- int $0x18 # move cursor to correct place
- mov $0x11, %ah
- int $0x18 # turn on text plane
-
- call prtstr_cs # "Ok.\r\n"
-no_30line:
-#endif
- ret
-
-prtstr_cs:
- pushw %ds
- pushw %cs
- popw %ds
- call prtstr
- popw %ds
- ret
-
-# prthex is for debugging purposes, and prints %ax in hexadecimal.
-prthex: pushw %cx
- movw $4, %cx
-1: rolw $4, %ax
- pushw %ax
- andb $0xf, %al
- cmpb $10, %al
- sbbb $0x69, %al
- das
- call prtchr
- popw %ax
- loop 1b
- popw %cx
- ret
-
-msg_probing: .string "Probing machine: "
-
-msg_nec: .string "NEC"
-msg_compat: .string "compatible"
-
-msg_fontdata: .string " (CG sum of A = 0x"
- .string ") PC-98"
- .string "1 "
-
-msg_gs: .string "(GS) "
-msg_h98: .string "(H98) "
-
-msg_normal: .string "normal"
-msg_hireso: .string "Hi-reso"
-
-msg_sysclk: .string " mode, system clock "
- .string "MHz\r\n"
-
-#if 0
-msg_40line: # cpp will concat following lines, so the assembler can deal.
- .ascii "\
-Video mode will be adjusted to 37-line (so-called ``40-line'') mode later.\r\n\
-THIS MODE MAY DAMAGE YOUR MONITOR PHYSICALLY. USE AT YOUR OWN RISK.\r\n"
-msg_30line: .string "Switching video mode to 30-line (640x480) mode... "
- .string "Ok.\r\n"
-#endif
+++ /dev/null
-/*
- * Machine specific resource allocation for generic.
- */
-
-#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/std_resources.h>
-
-#define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
-
-static struct resource system_rom_resource = {
- .name = "System ROM",
- .start = 0xf0000,
- .end = 0xfffff,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource extension_rom_resource = {
- .name = "Extension ROM",
- .start = 0xe0000,
- .end = 0xeffff,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource adapter_rom_resources[] = { {
- .name = "Adapter ROM",
- .start = 0xc8000,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
- .name = "Adapter ROM",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
- .name = "Adapter ROM",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
- .name = "Adapter ROM",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
- .name = "Adapter ROM",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
- .name = "Adapter ROM",
- .start = 0,
- .end = 0,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-} };
-
-#define ADAPTER_ROM_RESOURCES \
- (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
-
-static struct resource video_rom_resource = {
- .name = "Video ROM",
- .start = 0xc0000,
- .end = 0xc7fff,
- .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource vram_resource = {
- .name = "Video RAM area",
- .start = 0xa0000,
- .end = 0xbffff,
- .flags = IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-static struct resource standard_io_resources[] = { {
- .name = "dma1",
- .start = 0x0000,
- .end = 0x001f,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "pic1",
- .start = 0x0020,
- .end = 0x0021,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "timer",
- .start = 0x0040,
- .end = 0x005f,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "keyboard",
- .start = 0x0060,
- .end = 0x006f,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "dma page reg",
- .start = 0x0080,
- .end = 0x008f,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "pic2",
- .start = 0x00a0,
- .end = 0x00a1,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "dma2",
- .start = 0x00c0,
- .end = 0x00df,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-}, {
- .name = "fpu",
- .start = 0x00f0,
- .end = 0x00ff,
- .flags = IORESOURCE_BUSY | IORESOURCE_IO
-} };
-
-#define STANDARD_IO_RESOURCES \
- (sizeof standard_io_resources / sizeof standard_io_resources[0])
-
-static int __init checksum(unsigned char *rom, unsigned long length)
-{
- unsigned char *p, sum = 0;
-
- for (p = rom; p < rom + length; p++)
- sum += *p;
- return sum == 0;
-}
-
-void __init probe_roms(void)
-{
- unsigned long start, length, upper;
- unsigned char *rom;
- int i;
-
- /* video rom */
- upper = adapter_rom_resources[0].start;
- for (start = video_rom_resource.start; start < upper; start += 2048) {
- rom = isa_bus_to_virt(start);
- if (!romsignature(rom))
- continue;
-
- video_rom_resource.start = start;
-
- /* 0 < length <= 0x7f * 512, historically */
- length = rom[2] * 512;
-
- /* if checksum okay, trust length byte */
- if (length && checksum(rom, length))
- video_rom_resource.end = start + length - 1;
-
- request_resource(&iomem_resource, &video_rom_resource);
- break;
- }
-
- start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
- if (start < upper)
- start = upper;
-
- /* system rom */
- request_resource(&iomem_resource, &system_rom_resource);
- upper = system_rom_resource.start;
-
- /* check for extension rom (ignore length byte!) */
- rom = isa_bus_to_virt(extension_rom_resource.start);
- if (romsignature(rom)) {
- length = extension_rom_resource.end - extension_rom_resource.start + 1;
- if (checksum(rom, length)) {
- request_resource(&iomem_resource, &extension_rom_resource);
- upper = extension_rom_resource.start;
- }
- }
-
- /* check for adapter roms on 2k boundaries */
- for (i = 0; i < ADAPTER_ROM_RESOURCES && start < upper; start += 2048) {
- rom = isa_bus_to_virt(start);
- if (!romsignature(rom))
- continue;
-
- /* 0 < length <= 0x7f * 512, historically */
- length = rom[2] * 512;
-
- /* but accept any length that fits if checksum okay */
- if (!length || start + length > upper || !checksum(rom, length))
- continue;
-
- adapter_rom_resources[i].start = start;
- adapter_rom_resources[i].end = start + length - 1;
- request_resource(&iomem_resource, &adapter_rom_resources[i]);
-
- start = adapter_rom_resources[i++].end & ~2047UL;
- }
-}
-
-void __init request_graphics_resource(void)
-{
- request_resource(&iomem_resource, &vram_resource);
-}
-
-void __init request_standard_io_resources(void)
-{
- int i;
-
- for (i = 0; i < STANDARD_IO_RESOURCES; i++)
- request_resource(&ioport_resource, &standard_io_resources[i]);
-}
+++ /dev/null
-/*
- * Linker script for vsyscall DSO. The vsyscall page is an ELF shared
- * object prelinked to its virtual address, and with only one read-only
- * segment (that fits in one page). This script controls its layout.
- */
-
-/* This must match <asm/fixmap.h>. */
-VSYSCALL_BASE = 0xffffe000;
-
-SECTIONS
-{
- . = VSYSCALL_BASE + SIZEOF_HEADERS;
-
- .hash : { *(.hash) } :text
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
-
- /* This linker script is used both with -r and with -shared.
- For the layouts to match, we need to skip more than enough
- space for the dynamic symbol table et al. If this amount
- is insufficient, ld -shared will barf. Just increase it here. */
- . = VSYSCALL_BASE + 0x400;
-
- .text : { *(.text) } :text =0x90909090
-
- .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
- .eh_frame : { KEEP (*(.eh_frame)) } :text
- .dynamic : { *(.dynamic) } :text :dynamic
- .useless : {
- *(.got.plt) *(.got)
- *(.data .data.* .gnu.linkonce.d.*)
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- } :text
-}
-
-/*
- * We must supply the ELF program headers explicitly to get just one
- * PT_LOAD segment, and set the flags explicitly to make segments read-only.
- */
-PHDRS
-{
- text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
- dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
- eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
-}
-
-/*
- * This controls what symbols we export from the DSO.
- */
-VERSION
-{
- LINUX_2.5 {
- global:
- __kernel_vsyscall;
- __kernel_sigreturn;
- __kernel_rt_sigreturn;
-
- local: *;
- };
-}
-
-/* The ELF entry point can be used to set the AT_SYSINFO value. */
-ENTRY(__kernel_vsyscall);
+++ /dev/null
-/*
- * Written by: Garry Forsgren, Unisys Corporation
- * Natalie Protasevich, Unisys Corporation
- * This file contains the code to configure and interface
- * with Unisys ES7000 series hardware system manager.
- *
- * Copyright (c) 2003 Unisys Corporation. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Unisys Corporation, Township Line & Union Meeting
- * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
- *
- * http://www.unisys.com
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
-#include <linux/errno.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/acpi.h>
-#include <asm/io.h>
-#include <asm/nmi.h>
-#include <asm/smp.h>
-#include <asm/apicdef.h>
-#include "es7000.h"
-
-/*
- * ES7000 Globals
- */
-
-volatile unsigned long *psai = NULL;
-struct mip_reg *mip_reg;
-struct mip_reg *host_reg;
-int mip_port;
-unsigned long mip_addr, host_addr;
-
-/*
- * Parse the OEM Table
- */
-
-void __init
-parse_unisys_oem (char *oemptr, int oem_entries)
-{
- int i;
- int success = 0;
- unsigned char type, size;
- unsigned long val;
- char *tp = NULL;
- struct psai *psaip = NULL;
- struct mip_reg_info *mi;
- struct mip_reg *host, *mip;
-
- tp = oemptr;
-
- tp += 8;
-
- for (i=0; i <= oem_entries; i++) {
- type = *tp++;
- size = *tp++;
- tp -= 2;
- switch (type) {
- case MIP_REG:
- mi = (struct mip_reg_info *)tp;
- val = MIP_RD_LO(mi->host_reg);
- host_addr = val;
- host = (struct mip_reg *)val;
- host_reg = __va(host);
- val = MIP_RD_LO(mi->mip_reg);
- mip_addr = val;
- mip = (struct mip_reg *)val;
- mip_reg = __va(mip);
- Dprintk("es7000_mipcfg: host_reg = 0x%lx \n",
- (unsigned long)host_reg);
- Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n",
- (unsigned long)mip_reg);
- success++;
- break;
- case MIP_PSAI_REG:
- psaip = (struct psai *)tp;
- if (tp != NULL) {
- if (psaip->addr)
- psai = __va(psaip->addr);
- else
- psai = NULL;
- success++;
- }
- break;
- default:
- break;
- }
- if (i == 6) break;
- tp += size;
- }
-
- if (success < 2) {
- printk("\nNo ES7000 found.\n");
- es7000_plat = 0;
- } else {
- printk("\nEnabling ES7000 specific features...\n");
- es7000_plat = 1;
- }
- return;
-}
-
-int __init
-find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
-{
- struct acpi_table_rsdp *rsdp = NULL;
- unsigned long rsdp_phys = 0;
- struct acpi_table_header *header = NULL;
- int i;
- struct acpi_table_sdt sdt;
-
- rsdp_phys = acpi_find_rsdp();
- rsdp = __va(rsdp_phys);
- if (rsdp->rsdt_address) {
- struct acpi_table_rsdt *mapped_rsdt = NULL;
- sdt.pa = rsdp->rsdt_address;
-
- header = (struct acpi_table_header *)
- __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
- if (!header)
- return -ENODEV;
-
- sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
- mapped_rsdt = (struct acpi_table_rsdt *)
- __acpi_map_table(sdt.pa, header->length);
- if (!mapped_rsdt)
- return -ENODEV;
-
- header = &mapped_rsdt->header;
-
- for (i = 0; i < sdt.count; i++)
- sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
- };
- for (i = 0; i < sdt.count; i++) {
-
- header = (struct acpi_table_header *)
- __acpi_map_table(sdt.entry[i].pa,
- sizeof(struct acpi_table_header));
- if (!header)
- continue;
- if (!strncmp((char *) &header->signature, "OEM1", 4)) {
- if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
- void *addr;
- struct oem_table *t;
- acpi_table_print(header, sdt.entry[i].pa);
- t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
- addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
- *length = header->length;
- *oem_addr = (unsigned long) addr;
- return 0;
- }
- }
- }
- printk("ES7000: did not find Unisys ACPI OEM table!\n");
- return -1;
-}
-
-static void
-es7000_spin(int n)
-{
- int i = 0;
-
- while (i++ < n)
- rep_nop();
-}
-
-static int __init
-es7000_mip_write(struct mip_reg *mip_reg)
-{
- int status = 0;
- int spin;
-
- spin = MIP_SPIN;
- while (((unsigned long long)host_reg->off_38 &
- (unsigned long long)MIP_VALID) != 0) {
- if (--spin <= 0) {
- printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
- return -1;
- }
- es7000_spin(MIP_SPIN);
- }
-
- memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
- outb(1, mip_port);
-
- spin = MIP_SPIN;
-
- while (((unsigned long long)mip_reg->off_38 &
- (unsigned long long)MIP_VALID) == 0) {
- if (--spin <= 0) {
- printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
- return -1;
- }
- es7000_spin(MIP_SPIN);
- }
-
- status = ((unsigned long long)mip_reg->off_0 &
- (unsigned long long)0xffff0000000000) >> 48;
- mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
- (unsigned long long)~MIP_VALID);
- return status;
-}
-
-int
-es7000_start_cpu(int cpu, unsigned long eip)
-{
- unsigned long vect = 0, psaival = 0;
-
- if (psai == NULL)
- return -1;
-
- vect = ((unsigned long)__pa(eip)/0x1000) << 16;
- psaival = (0x1000000 | vect | cpu);
-
- while (*psai & 0x1000000)
- ;
-
- *psai = psaival;
-
- return 0;
-
-}
-
-int
-es7000_stop_cpu(int cpu)
-{
- int startup;
-
- if (psai == NULL)
- return -1;
-
- startup= (0x1000000 | cpu);
-
- while ((*psai & 0xff00ffff) != startup)
- ;
-
- startup = (*psai & 0xff0000) >> 16;
- *psai &= 0xffffff;
-
- return 0;
-
-}
-
-void __init
-es7000_sw_apic()
-{
- if (es7000_plat) {
- int mip_status;
- struct mip_reg es7000_mip_reg;
-
- printk("ES7000: Enabling APIC mode.\n");
- memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
- es7000_mip_reg.off_0 = MIP_SW_APIC;
- es7000_mip_reg.off_38 = (MIP_VALID);
- while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
- printk("es7000_sw_apic: command failed, status = %x\n",
- mip_status);
- return;
- }
-}
+++ /dev/null
-/*
- * Machine specific setup for es7000
- */
-
-#include <linux/config.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <asm/acpi.h>
-#include <asm/arch_hooks.h>
-
-/**
- * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
- *
- * Description:
- * Perform any necessary interrupt initialisation prior to setting up
- * the "ordinary" interrupt call gates. For legacy reasons, the ISA
- * interrupts should be initialised here if the machine emulates a PC
- * in any way.
- **/void __init pre_intr_init_hook(void)
-{
- init_ISA_irqs();
-}
-
-/*
- * IRQ2 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq2 = { no_action, 0, 0, "cascade", NULL, NULL};
-
-/**
- * intr_init_hook - post gate setup interrupt initialisation
- *
- * Description:
- * Fill in any interrupts that may have been left out by the general
- * init_IRQ() routine. interrupts having to do with the machine rather
- * than the devices on the I/O bus (like APIC interrupts in intel MP
- * systems) are started here.
- **/
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
- apic_intr_init();
-#endif
-
- if (!acpi_ioapic)
- setup_irq(2, &irq2);
-}
-
-/**
- * pre_setup_arch_hook - hook called prior to any setup_arch() execution
- *
- * Description:
- * generally used to activate any machine specific identification
- * routines that may be needed before setup_arch() runs. On VISWS
- * this is used to get the board revision and type.
- **/
-void __init pre_setup_arch_hook(void)
-{
-}
-
-/**
- * trap_init_hook - initialise system specific traps
- *
- * Description:
- * Called as the final act of trap_init(). Used in VISWS to initialise
- * the various board specific APIC traps.
- **/
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0 = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL};
-
-/**
- * time_init_hook - do any specific initialisations for the system timer.
- *
- * Description:
- * Must plug the system timer interrupt source at HZ into the IRQ listed
- * in irq_vectors.h:TIMER_IRQ
- **/
-void __init time_init_hook(void)
-{
- setup_irq(0, &irq0);
-}
-
-#ifdef CONFIG_MCA
-/**
- * mca_nmi_hook - hook into MCA specific NMI chain
- *
- * Description:
- * The MCA (Microchannel Arcitecture) has an NMI chain for NMI sources
- * along the MCA bus. Use this to hook into that chain if you will need
- * it.
- **/
-void __init mca_nmi_hook(void)
-{
- /* If I recall correctly, there's a whole bunch of other things that
- * we can do to check for NMI problems, but that's all I know about
- * at the moment.
- */
-
- printk("NMI generated from unknown source!\n");
-}
-
-#endif
+++ /dev/null
-/*
- * arch/i386/mach-generic/topology.c - Populate driverfs with topology information
- *
- * Written by: Matthew Dobson, IBM Corporation
- * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL
- *
- * Copyright (C) 2002, IBM Corp.
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <colpatch@us.ibm.com>
- */
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <asm/cpu.h>
-
-struct i386_cpu cpu_devices[NR_CPUS];
-
-#ifdef CONFIG_NUMA
-#include <linux/mmzone.h>
-#include <asm/node.h>
-
-struct i386_node node_devices[MAX_NUMNODES];
-
-static int __init topology_init(void)
-{
- int i;
-
- for (i = 0; i < num_online_nodes(); i++)
- arch_register_node(i);
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_possible(i)) arch_register_cpu(i);
- return 0;
-}
-
-#else /* !CONFIG_NUMA */
-
-static int __init topology_init(void)
-{
- int i;
-
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_possible(i)) arch_register_cpu(i);
- return 0;
-}
-
-#endif /* CONFIG_NUMA */
-
-subsys_initcall(topology_init);
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-obj-y := setup.o topology.o std_resources.o
+++ /dev/null
-/*
- * Machine specific setup for pc9800
- */
-
-#include <linux/config.h>
-#include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-#include <linux/apm_bios.h>
-#include <asm/setup.h>
-#include <asm/arch_hooks.h>
-
-struct sys_desc_table_struct {
- unsigned short length;
- unsigned char table[0];
-};
-
-/**
- * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
- *
- * Description:
- * Perform any necessary interrupt initialisation prior to setting up
- * the "ordinary" interrupt call gates. For legacy reasons, the ISA
- * interrupts should be initialised here if the machine emulates a PC
- * in any way.
- **/
-void __init pre_intr_init_hook(void)
-{
- init_ISA_irqs();
-}
-
-/*
- * IRQ7 is cascade interrupt to second interrupt controller
- */
-static struct irqaction irq7 = { no_action, 0, 0, "cascade", NULL, NULL};
-
-/**
- * intr_init_hook - post gate setup interrupt initialisation
- *
- * Description:
- * Fill in any interrupts that may have been left out by the general
- * init_IRQ() routine. interrupts having to do with the machine rather
- * than the devices on the I/O bus (like APIC interrupts in intel MP
- * systems) are started here.
- **/
-void __init intr_init_hook(void)
-{
-#ifdef CONFIG_X86_LOCAL_APIC
- apic_intr_init();
-#endif
-
- setup_irq(7, &irq7);
-}
-
-/**
- * pre_setup_arch_hook - hook called prior to any setup_arch() execution
- *
- * Description:
- * generally used to activate any machine specific identification
- * routines that may be needed before setup_arch() runs. On VISWS
- * this is used to get the board revision and type.
- **/
-void __init pre_setup_arch_hook(void)
-{
- SYS_DESC_TABLE.length = 0;
- MCA_bus = 0;
- /* In PC-9800, APM BIOS version is written in BCD...?? */
- APM_BIOS_INFO.version = (APM_BIOS_INFO.version & 0xff00)
- | ((APM_BIOS_INFO.version & 0x00f0) >> 4);
-}
-
-/**
- * trap_init_hook - initialise system specific traps
- *
- * Description:
- * Called as the final act of trap_init(). Used in VISWS to initialise
- * the various board specific APIC traps.
- **/
-void __init trap_init_hook(void)
-{
-}
-
-static struct irqaction irq0 = { timer_interrupt, SA_INTERRUPT, 0, "timer", NULL, NULL};
-
-/**
- * time_init_hook - do any specific initialisations for the system timer.
- *
- * Description:
- * Must plug the system timer interrupt source at HZ into the IRQ listed
- * in irq_vectors.h:TIMER_IRQ
- **/
-void __init time_init_hook(void)
-{
- setup_irq(0, &irq0);
-}
-
-#ifdef CONFIG_MCA
-/**
- * mca_nmi_hook - hook into MCA specific NMI chain
- *
- * Description:
- * The MCA (Microchannel Architecture) has an NMI chain for NMI sources
- * along the MCA bus. Use this to hook into that chain if you will need
- * it.
- **/
-void __init mca_nmi_hook(void)
-{
- /* If I recall correctly, there's a whole bunch of other things that
- * we can do to check for NMI problems, but that's all I know about
- * at the moment.
- */
-
- printk("NMI generated from unknown source!\n");
-}
-#endif
+++ /dev/null
-/*
- * Machine specific resource allocation for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-
-#include <linux/ioport.h>
-#include <asm/io.h>
-#include <asm/std_resources.h>
-
-static char str_pic1[] = "pic1";
-static char str_dma[] = "dma";
-static char str_pic2[] = "pic2";
-static char str_calender_clock[] = "calender clock";
-static char str_system[] = "system";
-static char str_nmi_control[] = "nmi control";
-static char str_kanji_rom[] = "kanji rom";
-static char str_keyboard[] = "keyboard";
-static char str_text_gdc[] = "text gdc";
-static char str_crtc[] = "crtc";
-static char str_timer[] = "timer";
-static char str_graphic_gdc[] = "graphic gdc";
-static char str_dma_ex_bank[] = "dma ex. bank";
-static char str_beep_freq[] = "beep freq.";
-static char str_mouse_pio[] = "mouse pio";
-struct resource standard_io_resources[] = {
- { str_pic1, 0x00, 0x00, IORESOURCE_BUSY },
- { str_dma, 0x01, 0x01, IORESOURCE_BUSY },
- { str_pic1, 0x02, 0x02, IORESOURCE_BUSY },
- { str_dma, 0x03, 0x03, IORESOURCE_BUSY },
- { str_dma, 0x05, 0x05, IORESOURCE_BUSY },
- { str_dma, 0x07, 0x07, IORESOURCE_BUSY },
- { str_pic2, 0x08, 0x08, IORESOURCE_BUSY },
- { str_dma, 0x09, 0x09, IORESOURCE_BUSY },
- { str_pic2, 0x0a, 0x0a, IORESOURCE_BUSY },
- { str_dma, 0x0b, 0x0b, IORESOURCE_BUSY },
- { str_dma, 0x0d, 0x0d, IORESOURCE_BUSY },
- { str_dma, 0x0f, 0x0f, IORESOURCE_BUSY },
- { str_dma, 0x11, 0x11, IORESOURCE_BUSY },
- { str_dma, 0x13, 0x13, IORESOURCE_BUSY },
- { str_dma, 0x15, 0x15, IORESOURCE_BUSY },
- { str_dma, 0x17, 0x17, IORESOURCE_BUSY },
- { str_dma, 0x19, 0x19, IORESOURCE_BUSY },
- { str_dma, 0x1b, 0x1b, IORESOURCE_BUSY },
- { str_dma, 0x1d, 0x1d, IORESOURCE_BUSY },
- { str_dma, 0x1f, 0x1f, IORESOURCE_BUSY },
- { str_calender_clock, 0x20, 0x20, 0 },
- { str_dma, 0x21, 0x21, IORESOURCE_BUSY },
- { str_calender_clock, 0x22, 0x22, 0 },
- { str_dma, 0x23, 0x23, IORESOURCE_BUSY },
- { str_dma, 0x25, 0x25, IORESOURCE_BUSY },
- { str_dma, 0x27, 0x27, IORESOURCE_BUSY },
- { str_dma, 0x29, 0x29, IORESOURCE_BUSY },
- { str_dma, 0x2b, 0x2b, IORESOURCE_BUSY },
- { str_dma, 0x2d, 0x2d, IORESOURCE_BUSY },
- { str_system, 0x31, 0x31, IORESOURCE_BUSY },
- { str_system, 0x33, 0x33, IORESOURCE_BUSY },
- { str_system, 0x35, 0x35, IORESOURCE_BUSY },
- { str_system, 0x37, 0x37, IORESOURCE_BUSY },
- { str_nmi_control, 0x50, 0x50, IORESOURCE_BUSY },
- { str_nmi_control, 0x52, 0x52, IORESOURCE_BUSY },
- { "time stamp", 0x5c, 0x5f, IORESOURCE_BUSY },
- { str_kanji_rom, 0xa1, 0xa1, IORESOURCE_BUSY },
- { str_kanji_rom, 0xa3, 0xa3, IORESOURCE_BUSY },
- { str_kanji_rom, 0xa5, 0xa5, IORESOURCE_BUSY },
- { str_kanji_rom, 0xa7, 0xa7, IORESOURCE_BUSY },
- { str_kanji_rom, 0xa9, 0xa9, IORESOURCE_BUSY },
- { str_keyboard, 0x41, 0x41, IORESOURCE_BUSY },
- { str_keyboard, 0x43, 0x43, IORESOURCE_BUSY },
- { str_text_gdc, 0x60, 0x60, IORESOURCE_BUSY },
- { str_text_gdc, 0x62, 0x62, IORESOURCE_BUSY },
- { str_text_gdc, 0x64, 0x64, IORESOURCE_BUSY },
- { str_text_gdc, 0x66, 0x66, IORESOURCE_BUSY },
- { str_text_gdc, 0x68, 0x68, IORESOURCE_BUSY },
- { str_text_gdc, 0x6a, 0x6a, IORESOURCE_BUSY },
- { str_text_gdc, 0x6c, 0x6c, IORESOURCE_BUSY },
- { str_text_gdc, 0x6e, 0x6e, IORESOURCE_BUSY },
- { str_crtc, 0x70, 0x70, IORESOURCE_BUSY },
- { str_crtc, 0x72, 0x72, IORESOURCE_BUSY },
- { str_crtc, 0x74, 0x74, IORESOURCE_BUSY },
- { str_crtc, 0x74, 0x74, IORESOURCE_BUSY },
- { str_crtc, 0x76, 0x76, IORESOURCE_BUSY },
- { str_crtc, 0x78, 0x78, IORESOURCE_BUSY },
- { str_crtc, 0x7a, 0x7a, IORESOURCE_BUSY },
- { str_timer, 0x71, 0x71, IORESOURCE_BUSY },
- { str_timer, 0x73, 0x73, IORESOURCE_BUSY },
- { str_timer, 0x75, 0x75, IORESOURCE_BUSY },
- { str_timer, 0x77, 0x77, IORESOURCE_BUSY },
- { str_graphic_gdc, 0xa0, 0xa0, IORESOURCE_BUSY },
- { str_graphic_gdc, 0xa2, 0xa2, IORESOURCE_BUSY },
- { str_graphic_gdc, 0xa4, 0xa4, IORESOURCE_BUSY },
- { str_graphic_gdc, 0xa6, 0xa6, IORESOURCE_BUSY },
- { "cpu", 0xf0, 0xf7, IORESOURCE_BUSY },
- { "fpu", 0xf8, 0xff, IORESOURCE_BUSY },
- { str_dma_ex_bank, 0x0e05, 0x0e05, 0 },
- { str_dma_ex_bank, 0x0e07, 0x0e07, 0 },
- { str_dma_ex_bank, 0x0e09, 0x0e09, 0 },
- { str_dma_ex_bank, 0x0e0b, 0x0e0b, 0 },
- { str_beep_freq, 0x3fd9, 0x3fd9, IORESOURCE_BUSY },
- { str_beep_freq, 0x3fdb, 0x3fdb, IORESOURCE_BUSY },
- { str_beep_freq, 0x3fdd, 0x3fdd, IORESOURCE_BUSY },
- { str_beep_freq, 0x3fdf, 0x3fdf, IORESOURCE_BUSY },
- /* All PC-9800 have (exactly) one mouse interface. */
- { str_mouse_pio, 0x7fd9, 0x7fd9, 0 },
- { str_mouse_pio, 0x7fdb, 0x7fdb, 0 },
- { str_mouse_pio, 0x7fdd, 0x7fdd, 0 },
- { str_mouse_pio, 0x7fdf, 0x7fdf, 0 },
- { "mouse timer", 0xbfdb, 0xbfdb, 0 },
- { "mouse irq", 0x98d7, 0x98d7, 0 },
-};
-
-#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
-
-static struct resource tvram_resource = { "Text VRAM/CG window", 0xa0000, 0xa4fff, IORESOURCE_BUSY };
-static struct resource gvram_brg_resource = { "Graphic VRAM (B/R/G)", 0xa8000, 0xbffff, IORESOURCE_BUSY };
-static struct resource gvram_e_resource = { "Graphic VRAM (E)", 0xe0000, 0xe7fff, IORESOURCE_BUSY };
-
-/* System ROM resources */
-#define MAXROMS 6
-static struct resource rom_resources[MAXROMS] = {
- { "System ROM", 0xe8000, 0xfffff, IORESOURCE_BUSY }
-};
-
-void __init probe_roms(void)
-{
- int i;
- __u8 *xrom_id;
- int roms = 1;
-
- request_resource(&iomem_resource, rom_resources+0);
-
- xrom_id = (__u8 *) isa_bus_to_virt(PC9800SCA_XROM_ID + 0x10);
-
- for (i = 0; i < 16; i++) {
- if (xrom_id[i] & 0x80) {
- int j;
-
- for (j = i + 1; j < 16 && (xrom_id[j] & 0x80); j++)
- ;
- rom_resources[roms].start = 0x0d0000 + i * 0x001000;
- rom_resources[roms].end = 0x0d0000 + j * 0x001000 - 1;
- rom_resources[roms].name = "Extension ROM";
- rom_resources[roms].flags = IORESOURCE_BUSY;
-
- request_resource(&iomem_resource,
- rom_resources + roms);
- if (++roms >= MAXROMS)
- return;
- }
- }
-}
-
-void __init request_graphics_resource(void)
-{
- int i;
-
- if (PC9800_HIGHRESO_P()) {
- tvram_resource.start = 0xe0000;
- tvram_resource.end = 0xe4fff;
- gvram_brg_resource.name = "Graphic VRAM";
- gvram_brg_resource.start = 0xc0000;
- gvram_brg_resource.end = 0xdffff;
- }
-
- request_resource(&iomem_resource, &tvram_resource);
- request_resource(&iomem_resource, &gvram_brg_resource);
- if (!PC9800_HIGHRESO_P())
- request_resource(&iomem_resource, &gvram_e_resource);
-
- if (PC9800_HIGHRESO_P() || PC9800_9821_P()) {
- static char graphics[] = "graphics";
- static struct resource graphics_resources[] = {
- { graphics, 0x9a0, 0x9a0, 0 },
- { graphics, 0x9a2, 0x9a2, 0 },
- { graphics, 0x9a4, 0x9a4, 0 },
- { graphics, 0x9a6, 0x9a6, 0 },
- { graphics, 0x9a8, 0x9a8, 0 },
- { graphics, 0x9aa, 0x9aa, 0 },
- { graphics, 0x9ac, 0x9ac, 0 },
- { graphics, 0x9ae, 0x9ae, 0 },
- };
-
-#define GRAPHICS_RESOURCES (sizeof(graphics_resources)/sizeof(struct resource))
-
- for (i = 0; i < GRAPHICS_RESOURCES; i++)
- request_resource(&ioport_resource, graphics_resources + i);
- }
-}
-
-void __init request_standard_io_resources(void)
-{
- int i;
-
- for (i = 0; i < STANDARD_IO_RESOURCES; i++)
- request_resource(&ioport_resource, standard_io_resources+i);
-}
+++ /dev/null
-/*
- * arch/i386/mach-pc9800/topology.c - Populate driverfs with topology information
- *
- * Written by: Matthew Dobson, IBM Corporation
- * Original Code: Paul Dorwin, IBM Corporation, Patrick Mochel, OSDL
- *
- * Copyright (C) 2002, IBM Corp.
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Modify for PC-9800 by Osamu Tomita <tomita@cinet.co.jp>
- *
- */
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <asm/cpu.h>
-
-struct i386_cpu cpu_devices[NR_CPUS];
-
-static int __init topology_init(void)
-{
- int i;
-
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_possible(i)) arch_register_cpu(i);
- return 0;
-}
-
-subsys_initcall(topology_init);
+++ /dev/null
-/* Originally gcc generated, modified by hand */
-
-#include <linux/linkage.h>
-#include <asm/segment.h>
-#include <asm/page.h>
-
- .text
-
-ENTRY(pmdisk_arch_suspend)
- cmpl $0,4(%esp)
- jne .L1450
-
- movl %esp, saved_context_esp
- movl %ebx, saved_context_ebx
- movl %ebp, saved_context_ebp
- movl %esi, saved_context_esi
- movl %edi, saved_context_edi
- pushfl ; popl saved_context_eflags
-
- call pmdisk_suspend
- jmp .L1449
- .p2align 4,,7
-.L1450:
- movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
- movl %ecx,%cr3
-
- movl pm_pagedir_nosave,%ebx
- xorl %eax, %eax
- xorl %edx, %edx
- .p2align 4,,7
-.L1455:
- movl 4(%ebx,%edx),%edi
- movl (%ebx,%edx),%esi
-
- movl $1024, %ecx
- rep
- movsl
-
- movl %cr3, %ecx;
- movl %ecx, %cr3; # flush TLB
-
- incl %eax
- addl $16, %edx
- cmpl pmdisk_pages,%eax
- jb .L1455
- .p2align 4,,7
-.L1453:
- movl saved_context_esp, %esp
- movl saved_context_ebp, %ebp
- movl saved_context_ebx, %ebx
- movl saved_context_esi, %esi
- movl saved_context_edi, %edi
- pushl saved_context_eflags ; popfl
- call pmdisk_resume
-.L1449:
- ret
+++ /dev/null
-/*
- * This file contains the HP SKI Simulator PMU register description tables
- * and pmc checkers used by perfmon.c.
- *
- * Copyright (C) 2002-2003 Hewlett Packard Co
- * Stephane Eranian <eranian@hpl.hp.com>
- *
- * File mostly contributed by Ian Wienand <ianw@gelato.unsw.edu.au>
- *
- * This file is included as a dummy template so the kernel does not
- * try to initalize registers the simulator can't handle.
- *
- * Note the simulator does not (currently) implement these registers, i.e.,
- * they do not count anything. But you can read/write them.
- */
-
-#define RDEP(x) (1UL<<(x))
-
-#ifndef CONFIG_IA64_HP_SIM
-#error "This file should only be included for the HP Simulator"
-#endif
-
-static pfm_reg_desc_t pfm_hpsim_pmc_desc[PMU_MAX_PMCS]={
-/* pmc0 */ { PFM_REG_CONTROL , 0, 0x1UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc1 */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc2 */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc3 */ { PFM_REG_CONTROL , 0, 0x0UL, -1UL, NULL, NULL, {0UL, 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc4 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(4), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc5 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(5), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc6 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(6), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc7 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(7), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc8 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(8), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc9 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(9), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc10 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(10), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc11 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(11), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc12 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(12), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc13 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(13), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc14 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(14), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmc15 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {RDEP(15), 0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
- { PFM_REG_END , 0, 0x0UL, -1UL, NULL, NULL, {0,}, {0,}}, /* end marker */
-};
-
-static pfm_reg_desc_t pfm_hpsim_pmd_desc[PMU_MAX_PMDS]={
-/* pmd0 */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd1 */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd2 */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd3 */ { PFM_REG_BUFFER, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {0UL,0UL, 0UL, 0UL}},
-/* pmd4 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(4),0UL, 0UL, 0UL}},
-/* pmd5 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(5),0UL, 0UL, 0UL}},
-/* pmd6 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(6),0UL, 0UL, 0UL}},
-/* pmd7 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(7),0UL, 0UL, 0UL}},
-/* pmd8 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(8),0UL, 0UL, 0UL}},
-/* pmd9 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(9),0UL, 0UL, 0UL}},
-/* pmd10 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(10),0UL, 0UL, 0UL}},
-/* pmd11 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(11),0UL, 0UL, 0UL}},
-/* pmd12 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(12),0UL, 0UL, 0UL}},
-/* pmd13 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(13),0UL, 0UL, 0UL}},
-/* pmd14 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(14),0UL, 0UL, 0UL}},
-/* pmd15 */ { PFM_REG_COUNTING, 0, 0x0UL, -1UL, NULL, NULL, {0UL,0UL, 0UL, 0UL}, {RDEP(15),0UL, 0UL, 0UL}},
- { PFM_REG_END , 0, 0x0UL, -1UL, NULL, NULL, {0,}, {0,}}, /* end marker */
-};
-
-/*
- * impl_pmcs, impl_pmds are computed at runtime to minimize errors!
- */
-static pmu_config_t pmu_conf={
- .pmu_name = "hpsim",
- .pmu_family = 0x7, /* ski emulator reports as Itanium */
- .enabled = 0,
- .ovfl_val = (1UL << 32) - 1,
- .num_ibrs = 0, /* does not use */
- .num_dbrs = 0, /* does not use */
- .pmd_desc = pfm_hpsim_pmd_desc,
- .pmc_desc = pfm_hpsim_pmc_desc
-};
+++ /dev/null
-# arch/ia64/sn/fakeprom/Makefile
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (c) 2000-2003 Silicon Graphics, Inc. All rights reserved.
-#
-# Medusa fake PROM support
-#
-
-EXTRA_TARGETS := fpromasm.o main.o fw-emu.o fpmem.o klgraph_init.o \
- fprom vmlinux.sym
-
-OBJS := $(obj)/fpromasm.o $(obj)/main.o $(obj)/fw-emu.o $(obj)/fpmem.o \
- $(obj)/klgraph_init.o
-
-LDFLAGS_fprom = -static -T
-
-.PHONY: fprom
-
-fprom: $(obj)/fprom
-
-$(obj)/fprom: $(src)/fprom.lds $(OBJS) arch/ia64/lib/lib.a FORCE
- $(call if_changed,ld)
-
-$(obj)/vmlinux.sym: $(src)/make_textsym System.map
- $(src)/make_textsym vmlinux > vmlinux.sym
- $(call cmd,cptotop)
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 2002-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-
-This directory contains the files required to build
-the fake PROM image that is currently being used to
-boot IA64 kernels running under the SGI Medusa kernel.
-
-The FPROM currently provides the following functions:
-
- - PAL emulation for all PAL calls we've made so far.
- - SAL emulation for all SAL calls we've made so far.
- - EFI emulation for all EFI calls we've made so far.
- - builds the "ia64_bootparam" structure that is
- passed to the kernel from SAL. This structure
- shows the cpu & memory configurations.
- - supports medusa boottime options for changing
- the number of cpus present
- - supports medusa boottime options for changing
- the memory configuration.
-
-
-
-At some point, this fake PROM will be replaced by the
-real PROM.
-
-
-
-
-To build a fake PROM, cd to this directory & type:
-
- make
-
-This will (or should) build a fake PROM named "fprom".
-
-
-
-
-Use this fprom image when booting the Medusa simulator. The
-control file used to boot Medusa should include the
-following lines:
-
- load fprom
- load vmlinux
- sr pc 0x100000
- sr g 9 <address of kernel _start function> #(currently 0xe000000000520000)
-
-NOTE: There is a script "runsim" in this directory that can be used to
-simplify setting up an environment for running under Medusa.
-
-
-
-
-The following parameters may be passed to the fake PROM to
-control the PAL/SAL/EFI parameters passed to the kernel:
-
- GR[8] = # of cpus
- GR[9] = address of primary entry point into the kernel
- GR[20] = memory configuration for node 0
- GR[21] = memory configuration for node 1
- GR[22] = memory configuration for node 2
- GR[23] = memory configuration for node 3
-
-
-Registers GR[20] - GR[23] contain information to specify the
-amount of memory present on nodes 0-3.
-
- - if nothing is specified (all registers are 0), the configuration
- defaults to 8 MB on node 0.
-
- - a mem config entry for node N is passed in GR[20+N]
-
- - a mem config entry consists of 8 hex digits. Each digit gives the
- amount of physical memory available on the node starting at
- 1GB*<dn>, where dn is the digit number. The amount of memory
- is 8MB*2**<d>. (If <d> = 0, the memory size is 0).
-
- SN1 doesn't support dimms this small but small memory systems
- boot faster on Medusa.
-
-
-
-An example helps a lot. The following specifies that node 0 has
-physical memory 0 to 8MB and 1GB to 1GB+32MB, and that node 1 has
-64MB starting at address 0 of the node which is 8GB.
-
- gr[20] = 0x21 # 0 to 8MB, 1GB to 1GB+32MB
- gr[21] = 0x4 # 8GB to 8GB+64MB
-
+++ /dev/null
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-
-/*
- * FPROM EFI memory descriptor build routines
- *
- * - Routines to build the EFI memory descriptor map
- * - Should also be usable by the SGI prom to convert
- * klconfig to efi_memmap
- */
-
-#include <linux/config.h>
-#include <linux/efi.h>
-#include "fpmem.h"
-
-/*
- * args points to a layout in memory like this
- *
- * 32 bit 32 bit
- *
- * numnodes numcpus
- *
- * 16 bit 16 bit 32 bit
- * nasid0 cpuconf membankdesc0
- * nasid1 cpuconf membankdesc1
- * .
- * .
- * .
- * .
- * .
- */
-
-sn_memmap_t *sn_memmap ;
-sn_config_t *sn_config ;
-
-/*
- * There is a hole in the node 0 address space. Dont put it
- * in the memory map
- */
-#define NODE0_HOLE_SIZE (20*MB)
-#define NODE0_HOLE_END (4UL*GB)
-
-#define MB (1024*1024)
-#define GB (1024*MB)
-#define KERNEL_SIZE (4*MB)
-#define PROMRESERVED_SIZE (1*MB)
-
-#ifdef SGI_SN2
-#define PHYS_ADDRESS(_n, _x) (((long)_n<<38) | (long)_x | 0x3000000000UL)
-#define MD_BANK_SHFT 34
-#endif
-
-/*
- * For SN, this may not take an arg and gets the numnodes from
- * the prom variable or by traversing klcfg or promcfg
- */
-int
-GetNumNodes(void)
-{
- return sn_config->nodes;
-}
-
-int
-GetNumCpus(void)
-{
- return sn_config->cpus;
-}
-
-/* For SN, get the index th nasid */
-
-int
-GetNasid(int index)
-{
- return sn_memmap[index].nasid ;
-}
-
-node_memmap_t
-GetMemBankInfo(int index)
-{
- return sn_memmap[index].node_memmap ;
-}
-
-int
-IsCpuPresent(int cnode, int cpu)
-{
- return sn_memmap[cnode].cpuconfig & (1UL<<cpu);
-}
-
-
-/*
- * Made this into an explicit case statement so that
- * we can assign specific properties to banks like bank0
- * actually disabled etc.
- */
-
-#ifdef SGI_SN2
-int
-IsBankPresent(int index, node_memmap_t nmemmap)
-{
- switch (index) {
- case 0:return BankPresent(nmemmap.b0size);
- case 1:return BankPresent(nmemmap.b1size);
- case 2:return BankPresent(nmemmap.b2size);
- case 3:return BankPresent(nmemmap.b3size);
- default:return -1 ;
- }
-}
-
-int
-GetBankSize(int index, node_memmap_t nmemmap)
-{
- /*
- * Add 2 because there are 4 dimms per bank.
- */
- switch (index) {
- case 0:return 2 + ((long)nmemmap.b0size + nmemmap.b0dou);
- case 1:return 2 + ((long)nmemmap.b1size + nmemmap.b1dou);
- case 2:return 2 + ((long)nmemmap.b2size + nmemmap.b2dou);
- case 3:return 2 + ((long)nmemmap.b3size + nmemmap.b3dou);
- default:return -1 ;
- }
-}
-
-#endif
-
-void
-build_mem_desc(efi_memory_desc_t *md, int type, long paddr, long numbytes, long attr)
-{
- md->type = type;
- md->phys_addr = paddr;
- md->virt_addr = 0;
- md->num_pages = numbytes >> 12;
- md->attribute = attr;
-}
-
-int
-build_efi_memmap(void *md, int mdsize)
-{
- int numnodes = GetNumNodes() ;
- int cnode,bank ;
- int nasid ;
- node_memmap_t membank_info ;
- int bsize;
- int count = 0 ;
- long paddr, hole, numbytes;
-
-
- for (cnode=0;cnode<numnodes;cnode++) {
- nasid = GetNasid(cnode) ;
- membank_info = GetMemBankInfo(cnode) ;
- for (bank=0;bank<MD_BANKS_PER_NODE;bank++) {
- if (IsBankPresent(bank, membank_info)) {
- bsize = GetBankSize(bank, membank_info) ;
- paddr = PHYS_ADDRESS(nasid, (long)bank<<MD_BANK_SHFT);
- numbytes = BankSizeBytes(bsize);
-#ifdef SGI_SN2
- /*
- * Ignore directory.
- * Shorten memory chunk by 1 page - makes a better
- * testcase & is more like the real PROM.
- */
- numbytes = numbytes * 31 / 32;
-#endif
- /*
- * Only emulate the memory prom grabs
- * if we have lots of memory, to allow
- * us to simulate smaller memory configs than
- * we can actually run on h/w. Otherwise,
- * linux throws away a whole "granule".
- */
- if (cnode == 0 && bank == 0 &&
- numbytes > 128*1024*1024) {
- numbytes -= 1000;
- }
-
- /*
- * Check for the node 0 hole. Since banks cant
- * span the hole, we only need to check if the end of
- * the range is the end of the hole.
- */
- if (paddr+numbytes == NODE0_HOLE_END)
- numbytes -= NODE0_HOLE_SIZE;
- /*
- * UGLY hack - we must skip overr the kernel and
- * PROM runtime services but we dont exactly where it is.
- * So lets just reserve:
- * node 0
- * 0-1MB for PAL
- * 1-4MB for SAL
- * node 1-N
- * 0-1 for SAL
- */
- if (bank == 0) {
- if (cnode == 0) {
- hole = 2*1024*1024;
- build_mem_desc(md, EFI_PAL_CODE, paddr, hole, EFI_MEMORY_WB|EFI_MEMORY_WB);
- numbytes -= hole;
- paddr += hole;
- count++ ;
- md += mdsize;
- hole = 1*1024*1024;
- build_mem_desc(md, EFI_CONVENTIONAL_MEMORY, paddr, hole, EFI_MEMORY_UC);
- numbytes -= hole;
- paddr += hole;
- count++ ;
- md += mdsize;
- hole = 1*1024*1024;
- build_mem_desc(md, EFI_RUNTIME_SERVICES_DATA, paddr, hole, EFI_MEMORY_WB|EFI_MEMORY_WB);
- numbytes -= hole;
- paddr += hole;
- count++ ;
- md += mdsize;
- } else {
- hole = 2*1024*1024;
- build_mem_desc(md, EFI_RUNTIME_SERVICES_DATA, paddr, hole, EFI_MEMORY_WB|EFI_MEMORY_WB);
- numbytes -= hole;
- paddr += hole;
- count++ ;
- md += mdsize;
- hole = 2*1024*1024;
- build_mem_desc(md, EFI_RUNTIME_SERVICES_DATA, paddr, hole, EFI_MEMORY_UC);
- numbytes -= hole;
- paddr += hole;
- count++ ;
- md += mdsize;
- }
- }
- build_mem_desc(md, EFI_CONVENTIONAL_MEMORY, paddr, numbytes, EFI_MEMORY_WB|EFI_MEMORY_WB);
-
- md += mdsize ;
- count++ ;
- }
- }
- }
- return count ;
-}
-
-void
-build_init(unsigned long args)
-{
- sn_config = (sn_config_t *) (args);
- sn_memmap = (sn_memmap_t *)(args + 8) ; /* SN equiv for this is */
- /* init to klconfig start */
-}
+++ /dev/null
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/config.h>
-
-/*
- * Structure of the mem config of the node as a SN MI reg
- * Medusa supports this reg config.
- *
- * BankSize nibble to bank size mapping
- *
- * 1 - 64 MB
- * 2 - 128 MB
- * 3 - 256 MB
- * 4 - 512 MB
- * 5 - 1024 MB (1GB)
- */
-
-#define MBSHIFT 20
-
-#ifdef SGI_SN2
-typedef struct node_memmap_s
-{
- unsigned int b0size :3, /* 0-2 bank 0 size */
- b0dou :1, /* 3 bank 0 is 2-sided */
- ena0 :1, /* 4 bank 0 enabled */
- r0 :3, /* 5-7 reserved */
- b1size :3, /* 8-10 bank 1 size */
- b1dou :1, /* 11 bank 1 is 2-sided */
- ena1 :1, /* 12 bank 1 enabled */
- r1 :3, /* 13-15 reserved */
- b2size :3, /* 16-18 bank 2 size */
- b2dou :1, /* 19 bank 1 is 2-sided */
- ena2 :1, /* 20 bank 2 enabled */
- r2 :3, /* 21-23 reserved */
- b3size :3, /* 24-26 bank 3 size */
- b3dou :1, /* 27 bank 3 is 2-sided */
- ena3 :1, /* 28 bank 3 enabled */
- r3 :3; /* 29-31 reserved */
-} node_memmap_t ;
-
-#define SN2_BANK_SIZE_SHIFT (MBSHIFT+6) /* 64 MB */
-#define BankPresent(bsize) (bsize<6)
-#define BankSizeBytes(bsize) (BankPresent(bsize) ? 1UL<<((bsize)+SN2_BANK_SIZE_SHIFT) : 0)
-#define MD_BANKS_PER_NODE 4
-#define MD_BANKSIZE (1UL << 34)
-#endif
-
-typedef struct sn_memmap_s
-{
- short nasid ;
- short cpuconfig;
- node_memmap_t node_memmap ;
-} sn_memmap_t ;
-
-typedef struct sn_config_s
-{
- int cpus;
- int nodes;
- sn_memmap_t memmap[1]; /* start of array */
-} sn_config_t;
-
-
-
-extern void build_init(unsigned long);
-extern int build_efi_memmap(void *, int);
-extern int GetNumNodes(void);
-extern int GetNumCpus(void);
-extern int IsCpuPresent(int, int);
-extern int GetNasid(int);
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (c) 2002-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-
-OUTPUT_FORMAT("elf64-ia64-little")
-OUTPUT_ARCH(ia64)
-ENTRY(_start)
-SECTIONS
-{
- v = 0x0000000000000000 ; /* this symbol is here to make debugging with kdb easier... */
-
- . = (0x000000000000000 + 0x100000) ;
-
- _text = .;
- .text : AT(ADDR(.text) - 0x0000000000000000 )
- {
- *(__ivt_section)
- /* these are not really text pages, but the zero page needs to be in a fixed location: */
- *(__special_page_section)
- __start_gate_section = .;
- *(__gate_section)
- __stop_gate_section = .;
- *(.text)
- }
-
- /* Global data */
- _data = .;
-
- .rodata : AT(ADDR(.rodata) - 0x0000000000000000 )
- { *(.rodata) *(.rodata.*) }
- .opd : AT(ADDR(.opd) - 0x0000000000000000 )
- { *(.opd) }
- .data : AT(ADDR(.data) - 0x0000000000000000 )
- { *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS }
-
- __gp = ALIGN (8) + 0x200000;
-
- .got : AT(ADDR(.got) - 0x0000000000000000 )
- { *(.got.plt) *(.got) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : AT(ADDR(.sdata) - 0x0000000000000000 )
- { *(.sdata) }
- _edata = .;
- _bss = .;
- .sbss : AT(ADDR(.sbss) - 0x0000000000000000 )
- { *(.sbss) *(.scommon) }
- .bss : AT(ADDR(.bss) - 0x0000000000000000 )
- { *(.bss) *(COMMON) }
- . = ALIGN(64 / 8);
- _end = .;
-
- /* Sections to be discarded */
- /DISCARD/ : {
- *(.text.exit)
- *(.data.exit)
- }
-
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
- /* These must appear regardless of . */
- /* Discard them for now since Intel SoftSDV cannot handle them.
- .comment 0 : { *(.comment) }
- .note 0 : { *(.note) }
- */
- /DISCARD/ : { *(.comment) }
- /DISCARD/ : { *(.note) }
-}
+++ /dev/null
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * (Code copied from or=ther files)
- * Copyright (C) 1998-2000 Hewlett-Packard Co
- * Copyright (C) 1998-2000 David Mosberger-Tang <davidm@hpl.hp.com>
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-
-#define __ASSEMBLY__ 1
-#include <linux/config.h>
-#include <asm/processor.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/sn2/shub_mmr.h>
-
-/*
- * This file contains additional set up code that is needed to get going on
- * Medusa. This code should disappear once real hw is available.
- *
- * On entry to this routine, the following register values are assumed:
- *
- * gr[8] - BSP cpu
- * pr[9] - kernel entry address
- * pr[10] - cpu number on the node
- *
- * NOTE:
- * This FPROM may be loaded/executed at an address different from the
- * address that it was linked at. The FPROM is linked to run on node 0
- * at address 0x100000. If the code in loaded into another node, it
- * must be loaded at offset 0x100000 of the node. In addition, the
- * FPROM does the following things:
- * - determine the base address of the node it is loaded on
- * - add the node base to _gp.
- * - add the node base to all addresses derived from "movl"
- * instructions. (I couldnt get GPREL addressing to work)
- * (maybe newer versions of the tools will support this)
- * - scan the .got section and add the node base to all
- * pointers in this section.
- * - add the node base to all physical addresses in the
- * SAL/PAL/EFI table built by the C code. (This is done
- * in the C code - not here)
- * - add the node base to the TLB entries for vmlinux
- */
-
-#define KERNEL_BASE 0xe000000000000000
-#define BOOT_PARAM_ADDR 0x40000
-
-
-/*
- * ar.k0 gets set to IOPB_PA value, on 460gx chipset it should
- * be 0x00000ffffc000000, but on snia we use the (inverse swizzled)
- * IOSPEC_BASE value
- */
-#ifdef SGI_SN2
-#define IOPB_PA 0xc000000fcc000000
-#endif
-
-#define RR_RID 8
-
-
-
-// ====================================================================================
- .text
- .align 16
- .global _start
- .proc _start
-_start:
-
-// Setup psr and rse for system init
- mov psr.l = r0;;
- srlz.d;;
- invala
- mov ar.rsc = r0;;
- loadrs
- ;;
-
-// Isolate node number we are running on.
- mov r6 = ip;;
-#ifdef SGI_SN2
- shr r5 = r6,38 // r5 = node number
- dep r6 = 0,r6,0,36 // r6 = base memory address of node
-
-#endif
-
-
-// Set & relocate gp.
- movl r1= __gp;; // Add base memory address
- or r1 = r1,r6 // Relocate to boot node
-
-// Lets figure out who we are & put it in the LID register.
-#ifdef SGI_SN2
-// On SN2, we (currently) pass the cpu number in r10 at boot
- and r25=3,r10;;
- movl r16=0x8000008110000400 // Allow IPIs
- mov r17=-1;;
- st8 [r16]=r17
- movl r16=0x8000008110060580;; // SHUB_ID
- ld8 r27=[r16];;
- extr.u r27=r27,32,11;;
- shl r26=r25,28;; // Align local cpu# to lid.eid
- shl r27=r27,16;; // Align NASID to lid.id
- or r26=r26,r27;; // build the LID
-#else
-// The BR_PI_SELF_CPU_NUM register gives us a value of 0-3.
-// This identifies the cpu on the node.
-// Merge the cpu number with the NASID to generate the LID.
- movl r24=0x80000a0001000020;; // BR_PI_SELF_CPU_NUM
- ld8 r25=[r24] // Fetch PI_SELF
- movl r27=0x80000a0001600000;; // Fetch REVID to get local NASID
- ld8 r27=[r27];;
- extr.u r27=r27,32,8;;
- shl r26=r25,16;; // Align local cpu# to lid.eid
- shl r27=r27,24;; // Align NASID to lid.id
- or r26=r26,r27;; // build the LID
-#endif
- mov cr.lid=r26 // Now put in in the LID register
-
- movl r2=FPSR_DEFAULT;;
- mov ar.fpsr=r2
- movl sp = bootstacke-16;;
- or sp = sp,r6 // Relocate to boot node
-
-// Save the NASID that we are loaded on.
- movl r2=base_nasid;; // Save base_nasid for C code
- or r2 = r2,r6;; // Relocate to boot node
- st8 [r2]=r5 // Uncond st8 - same on all cpus
-
-// Save the kernel entry address. It is passed in r9 on one of
-// the cpus.
- movl r2=bsp_entry_pc
- cmp.ne p6,p0=r9,r0;;
- or r2 = r2,r6;; // Relocate to boot node
-(p6) st8 [r2]=r9 // Uncond st8 - same on all cpus
-
-
-// The following can ONLY be done by 1 cpu. Lets set a lock - the
-// cpu that gets it does the initilization. The rest just spin waiting
-// til initilization is complete.
- movl r22 = initlock;;
- or r22 = r22,r6 // Relocate to boot node
- mov r23 = 1;;
- xchg8 r23 = [r22],r23;;
- cmp.eq p6,p0 = 0,r23
-(p6) br.cond.spnt.few init
-1: ld4 r23 = [r22];;
- cmp.eq p6,p0 = 1,r23
-(p6) br.cond.sptk 1b
- br initx
-
-// Add base address of node memory to each pointer in the .got section.
-init: movl r16 = _GLOBAL_OFFSET_TABLE_;;
- or r16 = r16,r6;; // Relocate to boot node
-1: ld8 r17 = [r16];;
- cmp.eq p6,p7=0,r17
-(p6) br.cond.sptk.few.clr 2f;;
- or r17 = r17,r6;; // Relocate to boot node
- st8 [r16] = r17,8
- br 1b
-2:
- mov r23 = 2;; // All done, release the spinning cpus
- st4 [r22] = r23
-initx:
-
-//
-// I/O-port space base address:
-//
- movl r2 = IOPB_PA;;
- mov ar.k0 = r2
-
-
-// Now call main & pass it the current LID value.
- alloc r2=ar.pfs,0,0,2,0
- mov r32=r26
- mov r33=r8;;
- br.call.sptk.few rp=fmain
-
-// Initialize Region Registers
-//
- mov r10 = r0
- mov r2 = (13<<2)
- mov r3 = r0;;
-1: cmp4.gtu p6,p7 = 7, r3
- dep r10 = r3, r10, 61, 3
- dep r2 = r3, r2, RR_RID, 4;;
-(p7) dep r2 = 0, r2, 0, 1;;
-(p6) dep r2 = -1, r2, 0, 1;;
- mov rr[r10] = r2
- add r3 = 1, r3;;
- srlz.d;;
- cmp4.gtu p6,p0 = 8, r3
-(p6) br.cond.sptk.few.clr 1b
-
-//
-// Return value indicates if we are the BSP or AP.
-// 1 = BSP, 0 = AP
- mov cr.tpr=r0;;
- cmp.eq p6,p0=r8,r0
-(p6) br.cond.spnt slave
-
-//
-// Go to kernel C startup routines
-// Need to do a "rfi" in order set "it" and "ed" bits in the PSR.
-// This is the only way to set them.
-
- movl r28=BOOT_PARAM_ADDR
- movl r2=bsp_entry_pc;;
- or r28 = r28,r6;; // Relocate to boot node
- or r2 = r2,r6;; // Relocate to boot node
- ld8 r2=[r2];;
- or r2=r2,r6;;
- dep r2=0,r2,61,3;; // convert to phys mode
-
-//
-// Turn on address translation, interrupt collection, psr.ed, protection key.
-// Interrupts (PSR.i) are still off here.
-//
-
- movl r3 = ( IA64_PSR_BN | \
- IA64_PSR_AC | \
- IA64_PSR_DB | \
- IA64_PSR_DA | \
- IA64_PSR_IC \
- )
- ;;
- mov cr.ipsr = r3
-
-//
-// Go to kernel C startup routines
-// Need to do a "rfi" in order set "it" and "ed" bits in the PSR.
-// This is the only way to set them.
-
- mov r8=r28;;
- bsw.1 ;;
- mov r28=r8;;
- bsw.0 ;;
- mov cr.iip = r2
- srlz.d;;
- rfi;;
-
- .endp _start
-
-
-
-// Slave processors come here to spin til they get an interrupt. Then they launch themselves to
-// the place ap_entry points. No initialization is necessary - the kernel makes no
-// assumptions about state on this entry.
-// Note: should verify that the interrupt we got was really the ap_wakeup
-// interrupt but this should not be an issue on medusa
-slave:
- nop.i 0x8beef // Medusa - put cpu to sleep til interrupt occurs
- mov r8=cr.irr0;; // Check for interrupt pending.
- cmp.eq p6,p0=r8,r0
-(p6) br.cond.sptk slave;;
-
- mov r8=cr.ivr;; // Got one. Must read ivr to accept it
- srlz.d;;
- mov cr.eoi=r0;; // must write eoi to clear
- movl r8=ap_entry;; // now jump to kernel entry
- or r8 = r8,r6;; // Relocate to boot node
- ld8 r9=[r8],8;;
- ld8 r1=[r8]
- mov b0=r9;;
- br b0
-
-// Here is the kernel stack used for the fake PROM
- .bss
- .align 16384
-bootstack:
- .skip 16384
-bootstacke:
-initlock:
- data4
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////////////////////////
-// This code emulates the PAL. Only essential interfaces are emulated.
-
-
- .text
- .global pal_emulator
- .proc pal_emulator
-pal_emulator:
- mov r8=-1
-
- mov r9=256
- ;;
- cmp.gtu p6,p7=r9,r28 /* r28 <= 255? */
-(p6) br.cond.sptk.few static
- ;;
- mov r9=512
- ;;
- cmp.gtu p6,p7=r9,r28
-(p6) br.cond.sptk.few stacked
- ;;
-
-static: cmp.eq p6,p7=6,r28 /* PAL_PTCE_INFO */
-(p7) br.cond.sptk.few 1f
- movl r8=0 /* status = 0 */
- movl r9=0x100000000 /* tc.base */
- movl r10=0x0000000200000003 /* count[0], count[1] */
- movl r11=0x1000000000002000 /* stride[0], stride[1] */
- ;;
-
-1: cmp.eq p6,p7=14,r28 /* PAL_FREQ_RATIOS */
-(p7) br.cond.sptk.few 1f
- movl r8=0 /* status = 0 */
- movl r9 =0x100000064 /* proc_ratio (1/100) */
- movl r10=0x100000100 /* bus_ratio<<32 (1/256) */
- movl r11=0x10000000a /* itc_ratio<<32 (1/100) */
- ;;
-
-1: cmp.eq p6,p7=8,r28 /* PAL_VM_SUMMARY */
-(p7) br.cond.sptk.few 1f
- movl r8=0
-#ifdef SGI_SN2
- movl r9=0x0203083001151065
- movl r10=0x183f
-#endif
- movl r11=0
- ;;
-
-1: cmp.eq p6,p7=19,r28 /* PAL_RSE_INFO */
-(p7) br.cond.sptk.few 1f
- movl r8=0
- movl r9=0x60
- movl r10=0x0
- movl r11=0
- ;;
-
-1: cmp.eq p6,p7=15,r28 /* PAL_PERF_MON_INFO */
-(p7) br.cond.sptk.few 1f
- movl r8=0
- movl r9=0x08122004
- movl r10=0x0
- movl r11=0
- mov r2=ar.lc
- mov r3=16;;
- mov ar.lc=r3
- mov r3=r29;;
-5: st8 [r3]=r0,8
- br.cloop.sptk.few 5b;;
- mov ar.lc=r2
- mov r3=r29
- movl r2=0x1fff;; /* PMC regs */
- st8 [r3]=r2
- add r3=32,r3
- movl r2=0x3ffff;; /* PMD regs */
- st8 [r3]=r2
- add r3=32,r3
- movl r2=0xf0;; /* cycle regs */
- st8 [r3]=r2
- add r3=32,r3
- movl r2=0x10;; /* retired regs */
- st8 [r3]=r2
- ;;
-
-1: cmp.eq p6,p7=19,r28 /* PAL_RSE_INFO */
-(p7) br.cond.sptk.few 1f
- movl r8=0 /* status = 0 */
- movl r9=96 /* num phys stacked */
- movl r10=0 /* hints */
- movl r11=0
- ;;
-
-1: cmp.eq p6,p7=1,r28 /* PAL_CACHE_FLUSH */
-(p7) br.cond.sptk.few 1f
- mov r9=ar.lc
- movl r8=524288 /* flush 512k million cache lines (16MB) */
- ;;
- mov ar.lc=r8
- movl r8=0xe000000000000000
- ;;
-.loop: fc r8
- add r8=32,r8
- br.cloop.sptk.few .loop
- sync.i
- ;;
- srlz.i
- ;;
- mov ar.lc=r9
- mov r8=r0
-1: br.cond.sptk.few rp
-
-stacked:
- br.ret.sptk.few rp
-
- .endp pal_emulator
-
+++ /dev/null
-/*
- * PAL & SAL emulation.
- *
- * Copyright (C) 1998-2000 Hewlett-Packard Co
- * Copyright (C) 1998-2000 David Mosberger-Tang <davidm@hpl.hp.com>
- *
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExplan
- */
-#include <linux/config.h>
-#include <linux/efi.h>
-#include <linux/kernel.h>
-#include <asm/pal.h>
-#include <asm/sal.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/processor.h>
-#include <asm/sn/sn_cpuid.h>
-#ifdef SGI_SN2
-#include <asm/sn/sn2/addrs.h>
-#include <asm/sn/sn2/shub_mmr.h>
-#endif
-#include <linux/acpi.h>
-#include "fpmem.h"
-
-#define RSDP_NAME "RSDP"
-#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
-#define APIC_SIG "APIC" /* Multiple APIC Description Table */
-#define DSDT_SIG "DSDT" /* Differentiated System Description Table */
-#define FADT_SIG "FACP" /* Fixed ACPI Description Table */
-#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */
-#define PSDT_SIG "PSDT" /* Persistent System Description Table */
-#define RSDT_SIG "RSDT" /* Root System Description Table */
-#define XSDT_SIG "XSDT" /* Extended System Description Table */
-#define SSDT_SIG "SSDT" /* Secondary System Description Table */
-#define SBST_SIG "SBST" /* Smart Battery Specification Table */
-#define SPIC_SIG "SPIC" /* IOSAPIC table */
-#define SRAT_SIG "SRAT" /* SRAT table */
-#define SLIT_SIG "SLIT" /* SLIT table */
-#define BOOT_SIG "BOOT" /* Boot table */
-#define ACPI_SRAT_REVISION 1
-#define ACPI_SLIT_REVISION 1
-
-#define OEMID "SGI"
-#ifdef SGI_SN2
-#define PRODUCT "SN2"
-#define PROXIMITY_DOMAIN(nasid) (((nasid)>>1) & 255)
-#endif
-
-#define MB (1024*1024UL)
-#define GB (MB*1024UL)
-#define BOOT_PARAM_ADDR 0x40000
-#define MAX(i,j) ((i) > (j) ? (i) : (j))
-#define MIN(i,j) ((i) < (j) ? (i) : (j))
-#define ALIGN8(p) (((long)(p) +7) & ~7)
-
-#define FPROM_BUG() do {while (1);} while (0)
-#define MAX_SN_NODES 128
-#define MAX_LSAPICS 512
-#define MAX_CPUS 512
-#define MAX_CPUS_NODE 4
-#define CPUS_PER_NODE 4
-#define CPUS_PER_FSB 2
-#define CPUS_PER_FSB_MASK (CPUS_PER_FSB-1)
-
-#define NUM_EFI_DESCS 2
-
-#define RSDP_CHECKSUM_LENGTH 20
-
-typedef union ia64_nasid_va {
- struct {
-#if defined(SGI_SN2)
- unsigned long off : 36; /* intra-region offset */
- unsigned long attr : 2;
- unsigned long nasid : 11; /* NASID */
- unsigned long off2 : 12; /* fill */
- unsigned long reg : 3; /* region number */
-#endif
- } f;
- unsigned long l;
- void *p;
-} ia64_nasid_va;
-
-typedef struct {
- unsigned long pc;
- unsigned long gp;
-} func_ptr_t;
-
-#define IS_VIRTUAL_MODE() ({struct ia64_psr psr; asm("mov %0=psr" : "=r"(psr)); psr.dt;})
-#define ADDR_OF(p) (IS_VIRTUAL_MODE() ? ((void*)((long)(p)+PAGE_OFFSET)) : ((void*) (p)))
-
-#if defined(SGI_SN2)
-#define __fwtab_pa(n,x) ({ia64_nasid_va _v; _v.l = (long) (x); _v.f.nasid = (x) ? (n) : 0; _v.f.reg = 0; _v.f.attr = 3; _v.l;})
-#endif
-
-/*
- * The following variables are passed thru registersfrom the configuration file and
- * are set via the _start function.
- */
-long base_nasid;
-long num_cpus;
-long bsp_entry_pc=0;
-long num_nodes;
-long app_entry_pc;
-int bsp_lid;
-func_ptr_t ap_entry;
-
-
-extern void pal_emulator(void);
-static efi_runtime_services_t *efi_runtime_p;
-static char fw_mem[( sizeof(efi_system_table_t)
- + sizeof(efi_runtime_services_t)
- + NUM_EFI_DESCS*sizeof(efi_config_table_t)
- + sizeof(struct ia64_sal_systab)
- + sizeof(struct ia64_sal_desc_entry_point)
- + sizeof(struct ia64_sal_desc_ap_wakeup)
- + sizeof(struct acpi20_table_rsdp)
- + sizeof(struct acpi_table_xsdt)
- + sizeof(struct acpi_table_slit)
- + MAX_SN_NODES*MAX_SN_NODES+8
- + sizeof(struct acpi_table_madt)
- + 16*MAX_CPUS
- + (1+8*MAX_SN_NODES)*(sizeof(efi_memory_desc_t))
- + sizeof(struct acpi_table_srat)
- + MAX_CPUS*sizeof(struct acpi_table_processor_affinity)
- + MAX_SN_NODES*sizeof(struct acpi_table_memory_affinity)
- + sizeof(ia64_sal_desc_ptc_t) +
- + MAX_SN_NODES*sizeof(ia64_sal_ptc_domain_info_t) +
- + MAX_CPUS*sizeof(ia64_sal_ptc_domain_proc_entry_t) +
- + 1024)] __attribute__ ((aligned (8)));
-
-
-static efi_status_t
-efi_get_time (efi_time_t *tm, efi_time_cap_t *tc)
-{
- if (tm) {
- memset(tm, 0, sizeof(*tm));
- tm->year = 2000;
- tm->month = 2;
- tm->day = 13;
- tm->hour = 10;
- tm->minute = 11;
- tm->second = 12;
- }
-
- if (tc) {
- tc->resolution = 10;
- tc->accuracy = 12;
- tc->sets_to_zero = 1;
- }
-
- return EFI_SUCCESS;
-}
-
-static void
-efi_reset_system (int reset_type, efi_status_t status, unsigned long data_size, efi_char16_t *data)
-{
- while(1); /* Is there a pseudo-op to stop medusa */
-}
-
-static efi_status_t
-efi_success (void)
-{
- return EFI_SUCCESS;
-}
-
-static efi_status_t
-efi_unimplemented (void)
-{
- return EFI_UNSUPPORTED;
-}
-
-#ifdef SGI_SN2
-
-#undef cpu_physical_id
-#define cpu_physical_id(cpuid) ((ia64_getreg(_IA64_REG_CR_LID) >> 16) & 0xffff)
-
-void
-fprom_send_cpei(void) {
- long *p, val;
- long physid;
- long nasid, slice;
-
- physid = cpu_physical_id(0);
- nasid = cpu_physical_id_to_nasid(physid);
- slice = cpu_physical_id_to_slice(physid);
-
- p = (long*)GLOBAL_MMR_ADDR(nasid, SH_IPI_INT);
- val = (1UL<<SH_IPI_INT_SEND_SHFT) |
- (physid<<SH_IPI_INT_PID_SHFT) |
- ((long)0<<SH_IPI_INT_TYPE_SHFT) |
- ((long)0x1e<<SH_IPI_INT_IDX_SHFT) |
- (0x000feeUL<<SH_IPI_INT_BASE_SHFT);
- *p = val;
-
-}
-#endif
-
-
-static struct sal_ret_values
-sal_emulator (long index, unsigned long in1, unsigned long in2,
- unsigned long in3, unsigned long in4, unsigned long in5,
- unsigned long in6, unsigned long in7)
-{
- long r9 = 0;
- long r10 = 0;
- long r11 = 0;
- long status;
-
- /*
- * Don't do a "switch" here since that gives us code that
- * isn't self-relocatable.
- */
- status = 0;
- if (index == SAL_FREQ_BASE) {
- switch (in1) {
- case SAL_FREQ_BASE_PLATFORM:
- r9 = 500000000;
- break;
-
- case SAL_FREQ_BASE_INTERVAL_TIMER:
- /*
- * Is this supposed to be the cr.itc frequency
- * or something platform specific? The SAL
- * doc ain't exactly clear on this...
- */
- r9 = 700000000;
- break;
-
- case SAL_FREQ_BASE_REALTIME_CLOCK:
- r9 = 50000000;
- break;
-
- default:
- status = -1;
- break;
- }
- } else if (index == SAL_SET_VECTORS) {
- if (in1 == SAL_VECTOR_OS_BOOT_RENDEZ) {
- func_ptr_t *fp;
- fp = ADDR_OF(&ap_entry);
- fp->pc = in2;
- fp->gp = in3;
- } else if (in1 == SAL_VECTOR_OS_MCA || in1 == SAL_VECTOR_OS_INIT) {
- } else {
- status = -1;
- }
- ;
- } else if (index == SAL_GET_STATE_INFO) {
- ;
- } else if (index == SAL_GET_STATE_INFO_SIZE) {
- r9 = 10000;
- ;
- } else if (index == SAL_CLEAR_STATE_INFO) {
- ;
- } else if (index == SAL_MC_RENDEZ) {
- ;
- } else if (index == SAL_MC_SET_PARAMS) {
- ;
- } else if (index == SAL_CACHE_FLUSH) {
- ;
- } else if (index == SAL_CACHE_INIT) {
- ;
- } else if (index == SAL_UPDATE_PAL) {
- ;
-#ifdef SGI_SN2
- } else if (index == SN_SAL_LOG_CE) {
-#ifdef ajmtestcpei
- fprom_send_cpei();
-#else /* ajmtestcpei */
- ;
-#endif /* ajmtestcpei */
-#endif
- } else if (index == SN_SAL_PROBE) {
- r9 = 0UL;
- if (in2 == 4) {
- r9 = *(unsigned *)in1;
- if (r9 == -1) {
- status = 1;
- }
- } else if (in2 == 2) {
- r9 = *(unsigned short *)in1;
- if (r9 == -1) {
- status = 1;
- }
- } else if (in2 == 1) {
- r9 = *(unsigned char *)in1;
- if (r9 == -1) {
- status = 1;
- }
- } else if (in2 == 8) {
- r9 = *(unsigned long *)in1;
- if (r9 == -1) {
- status = 1;
- }
- } else {
- status = 2;
- }
- } else if (index == SN_SAL_GET_KLCONFIG_ADDR) {
- r9 = 0x30000;
- } else if (index == SN_SAL_CONSOLE_PUTC) {
- status = -1;
- } else if (index == SN_SAL_CONSOLE_GETC) {
- status = -1;
- } else if (index == SN_SAL_CONSOLE_POLL) {
- status = -1;
- } else if (index == SN_SAL_SYSCTL_IOBRICK_MODULE_GET) {
- status = -1;
- } else {
- status = -1;
- }
-
- asm volatile ("" :: "r"(r9), "r"(r10), "r"(r11));
- return ((struct sal_ret_values) {status, r9, r10, r11});
-}
-
-
-/*
- * This is here to work around a bug in egcs-1.1.1b that causes the
- * compiler to crash (seems like a bug in the new alias analysis code.
- */
-void *
-id (long addr)
-{
- return (void *) addr;
-}
-
-
-/*
- * Fix the addresses in a function pointer by adding base node address
- * to pc & gp.
- */
-void
-fix_function_pointer(void *fp)
-{
- func_ptr_t *_fp;
-
- _fp = fp;
- _fp->pc = __fwtab_pa(base_nasid, _fp->pc);
- _fp->gp = __fwtab_pa(base_nasid, _fp->gp);
-}
-
-void
-fix_virt_function_pointer(void **fptr)
-{
- func_ptr_t *fp;
- long *p;
-
- p = (long*)fptr;
- fp = *fptr;
- fp->pc = fp->pc | PAGE_OFFSET;
- fp->gp = fp->gp | PAGE_OFFSET;
- *p |= PAGE_OFFSET;
-}
-
-
-int
-efi_set_virtual_address_map(void)
-{
- efi_runtime_services_t *runtime;
-
- runtime = efi_runtime_p;
- fix_virt_function_pointer((void**)&runtime->get_time);
- fix_virt_function_pointer((void**)&runtime->set_time);
- fix_virt_function_pointer((void**)&runtime->get_wakeup_time);
- fix_virt_function_pointer((void**)&runtime->set_wakeup_time);
- fix_virt_function_pointer((void**)&runtime->set_virtual_address_map);
- fix_virt_function_pointer((void**)&runtime->get_variable);
- fix_virt_function_pointer((void**)&runtime->get_next_variable);
- fix_virt_function_pointer((void**)&runtime->set_variable);
- fix_virt_function_pointer((void**)&runtime->get_next_high_mono_count);
- fix_virt_function_pointer((void**)&runtime->reset_system);
- return EFI_SUCCESS;
-}
-
-void
-acpi_table_initx(struct acpi_table_header *p, char *sig, int siglen, int revision, int oem_revision)
-{
- memcpy(p->signature, sig, siglen);
- memcpy(p->oem_id, OEMID, 6);
- memcpy(p->oem_table_id, sig, 4);
- memcpy(p->oem_table_id+4, PRODUCT, 4);
- p->revision = revision;
- p->oem_revision = (revision<<16) + oem_revision;
- memcpy(p->asl_compiler_id, "FPRM", 4);
- p->asl_compiler_revision = 1;
-}
-
-void
-acpi_checksum(struct acpi_table_header *p, int length)
-{
- u8 *cp, *cpe, checksum;
-
- p->checksum = 0;
- p->length = length;
- checksum = 0;
- for (cp=(u8*)p, cpe=cp+p->length; cp<cpe; cp++)
- checksum += *cp;
- p->checksum = -checksum;
-}
-
-void
-acpi_checksum_rsdp20(struct acpi20_table_rsdp *p, int length)
-{
- u8 *cp, *cpe, checksum;
-
- p->checksum = 0;
- p->ext_checksum = 0;
- p->length = length;
- checksum = 0;
- for (cp=(u8*)p, cpe=cp+20; cp<cpe; cp++)
- checksum += *cp;
- p->checksum = -checksum;
-
- checksum = 0;
- for (cp=(u8*)p, cpe=cp+length; cp<cpe; cp++)
- checksum += *cp;
- p->ext_checksum = -checksum;
-}
-
-int
-nasid_present(int nasid)
-{
- int cnode;
- for (cnode=0; cnode<num_nodes; cnode++)
- if (GetNasid(cnode) == nasid)
- return 1;
- return 0;
-}
-
-void
-sys_fw_init (const char *args, int arglen, int bsp)
-{
- /*
- * Use static variables to keep from overflowing the RSE stack
- */
- static efi_system_table_t *efi_systab;
- static efi_runtime_services_t *efi_runtime;
- static efi_config_table_t *efi_tables;
- static ia64_sal_desc_ptc_t *sal_ptc;
- static ia64_sal_ptc_domain_info_t *sal_ptcdi;
- static ia64_sal_ptc_domain_proc_entry_t *sal_ptclid;
- static struct acpi20_table_rsdp *acpi20_rsdp;
- static struct acpi_table_xsdt *acpi_xsdt;
- static struct acpi_table_slit *acpi_slit;
- static struct acpi_table_madt *acpi_madt;
- static struct acpi_table_lsapic *lsapic20;
- static struct ia64_sal_systab *sal_systab;
- static struct acpi_table_srat *acpi_srat;
- static struct acpi_table_processor_affinity *srat_cpu_affinity;
- static struct acpi_table_memory_affinity *srat_memory_affinity;
- static efi_memory_desc_t *efi_memmap, *md;
- static unsigned long *pal_desc, *sal_desc;
- static struct ia64_sal_desc_entry_point *sal_ed;
- static struct ia64_boot_param *bp;
- static struct ia64_sal_desc_ap_wakeup *sal_apwake;
- static unsigned char checksum;
- static char *cp, *cmd_line, *vendor;
- static void *ptr;
- static int mdsize, domain, last_domain ;
- static int i, j, cnode, max_nasid, nasid, cpu, num_memmd, cpus_found;
-
- /*
- * Pass the parameter base address to the build_efi_xxx routines.
- */
-#if defined(SGI_SN2)
- build_init(0x3000000000UL | ((long)base_nasid<<38));
-#endif
-
- num_nodes = GetNumNodes();
- num_cpus = GetNumCpus();
- for (max_nasid=0, cnode=0; cnode<num_nodes; cnode++)
- max_nasid = MAX(max_nasid, GetNasid(cnode));
-
-
- memset(fw_mem, 0, sizeof(fw_mem));
-
- pal_desc = (unsigned long *) &pal_emulator;
- sal_desc = (unsigned long *) &sal_emulator;
- fix_function_pointer(&pal_emulator);
- fix_function_pointer(&sal_emulator);
-
- /* Align this to 16 bytes, probably EFI does this */
- mdsize = (sizeof(efi_memory_desc_t) + 15) & ~15 ;
-
- cp = fw_mem;
- efi_systab = (void *) cp; cp += ALIGN8(sizeof(*efi_systab));
- efi_runtime_p = efi_runtime = (void *) cp; cp += ALIGN8(sizeof(*efi_runtime));
- efi_tables = (void *) cp; cp += ALIGN8(NUM_EFI_DESCS*sizeof(*efi_tables));
- sal_systab = (void *) cp; cp += ALIGN8(sizeof(*sal_systab));
- sal_ed = (void *) cp; cp += ALIGN8(sizeof(*sal_ed));
- sal_ptc = (void *) cp; cp += ALIGN8(sizeof(*sal_ptc));
- sal_apwake = (void *) cp; cp += ALIGN8(sizeof(*sal_apwake));
- acpi20_rsdp = (void *) cp; cp += ALIGN8(sizeof(*acpi20_rsdp));
- acpi_xsdt = (void *) cp; cp += ALIGN8(sizeof(*acpi_xsdt) + 64);
- /* save space for more OS defined table pointers. */
-
- acpi_slit = (void *) cp; cp += ALIGN8(sizeof(*acpi_slit) + 8 + (max_nasid+1)*(max_nasid+1));
- acpi_madt = (void *) cp; cp += ALIGN8(sizeof(*acpi_madt) + sizeof(struct acpi_table_lsapic) * (num_cpus+1));
- acpi_srat = (void *) cp; cp += ALIGN8(sizeof(struct acpi_table_srat));
- cp += sizeof(struct acpi_table_processor_affinity)*num_cpus + sizeof(struct acpi_table_memory_affinity)*num_nodes;
- vendor = (char *) cp; cp += ALIGN8(40);
- efi_memmap = (void *) cp; cp += ALIGN8(8*32*sizeof(*efi_memmap));
- sal_ptcdi = (void *) cp; cp += ALIGN8(CPUS_PER_FSB*(1+num_nodes)*sizeof(*sal_ptcdi));
- sal_ptclid = (void *) cp; cp += ALIGN8(((3+num_cpus)*sizeof(*sal_ptclid)+7)/8*8);
- cmd_line = (void *) cp;
-
- if (args) {
- if (arglen >= 1024)
- arglen = 1023;
- memcpy(cmd_line, args, arglen);
- } else {
- arglen = 0;
- }
- cmd_line[arglen] = '\0';
- /*
- * For now, just bring up bash.
- * If you want to execute all the startup scripts, delete the "init=..".
- * You can also edit this line to pass other arguments to the kernel.
- * Note: disable kernel text replication.
- */
- strcpy(cmd_line, "init=/bin/bash console=ttyS0");
-
- memset(efi_systab, 0, sizeof(efi_systab));
- efi_systab->hdr.signature = EFI_SYSTEM_TABLE_SIGNATURE;
- efi_systab->hdr.revision = EFI_SYSTEM_TABLE_REVISION;
- efi_systab->hdr.headersize = sizeof(efi_systab->hdr);
- efi_systab->fw_vendor = __fwtab_pa(base_nasid, vendor);
- efi_systab->fw_revision = 1;
- efi_systab->runtime = __fwtab_pa(base_nasid, efi_runtime);
- efi_systab->nr_tables = 2;
- efi_systab->tables = __fwtab_pa(base_nasid, efi_tables);
- memcpy(vendor, "S\0i\0l\0i\0c\0o\0n\0-\0G\0r\0a\0p\0h\0i\0c\0s\0\0", 40);
-
- efi_runtime->hdr.signature = EFI_RUNTIME_SERVICES_SIGNATURE;
- efi_runtime->hdr.revision = EFI_RUNTIME_SERVICES_REVISION;
- efi_runtime->hdr.headersize = sizeof(efi_runtime->hdr);
- efi_runtime->get_time = __fwtab_pa(base_nasid, &efi_get_time);
- efi_runtime->set_time = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->get_wakeup_time = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->set_wakeup_time = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->set_virtual_address_map = __fwtab_pa(base_nasid, &efi_set_virtual_address_map);
- efi_runtime->get_variable = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->get_next_variable = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->set_variable = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->get_next_high_mono_count = __fwtab_pa(base_nasid, &efi_unimplemented);
- efi_runtime->reset_system = __fwtab_pa(base_nasid, &efi_reset_system);
-
- efi_tables->guid = SAL_SYSTEM_TABLE_GUID;
- efi_tables->table = __fwtab_pa(base_nasid, sal_systab);
- efi_tables++;
- efi_tables->guid = ACPI_20_TABLE_GUID;
- efi_tables->table = __fwtab_pa(base_nasid, acpi20_rsdp);
- efi_tables++;
-
- fix_function_pointer(&efi_unimplemented);
- fix_function_pointer(&efi_get_time);
- fix_function_pointer(&efi_success);
- fix_function_pointer(&efi_reset_system);
- fix_function_pointer(&efi_set_virtual_address_map);
-
-
- /* fill in the ACPI20 system table - has a pointer to the ACPI table header */
- memcpy(acpi20_rsdp->signature, "RSD PTR ", 8);
- acpi20_rsdp->xsdt_address = (u64)__fwtab_pa(base_nasid, acpi_xsdt);
- acpi20_rsdp->revision = 2;
- acpi_checksum_rsdp20(acpi20_rsdp, sizeof(struct acpi20_table_rsdp));
-
- /* Set up the XSDT table - contains pointers to the other ACPI tables */
- acpi_table_initx(&acpi_xsdt->header, XSDT_SIG, 4, 1, 1);
- acpi_xsdt->entry[0] = __fwtab_pa(base_nasid, acpi_madt);
- acpi_xsdt->entry[1] = __fwtab_pa(base_nasid, acpi_slit);
- acpi_xsdt->entry[2] = __fwtab_pa(base_nasid, acpi_srat);
- acpi_checksum(&acpi_xsdt->header, sizeof(struct acpi_table_xsdt) + 16);
-
- /* Set up the APIC table */
- acpi_table_initx(&acpi_madt->header, APIC_SIG, 4, 1, 1);
- lsapic20 = (struct acpi_table_lsapic*) (acpi_madt + 1);
- for (cnode=0; cnode<num_nodes; cnode++) {
- nasid = GetNasid(cnode);
- for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
- if (!IsCpuPresent(cnode, cpu))
- continue;
- lsapic20->header.type = ACPI_MADT_LSAPIC;
- lsapic20->header.length = sizeof(struct acpi_table_lsapic);
- lsapic20->acpi_id = cnode*4+cpu;
- lsapic20->flags.enabled = 1;
-#if defined(SGI_SN2)
- lsapic20->eid = nasid&0xffff;
- lsapic20->id = (cpu<<4) | (nasid>>16);
-#endif
- lsapic20 = (struct acpi_table_lsapic*) ((long)lsapic20+sizeof(struct acpi_table_lsapic));
- }
- }
- acpi_checksum(&acpi_madt->header, (char*)lsapic20 - (char*)acpi_madt);
-
- /* Set up the SRAT table */
- acpi_table_initx(&acpi_srat->header, SRAT_SIG, 4, ACPI_SRAT_REVISION, 1);
- ptr = acpi_srat+1;
- for (cnode=0; cnode<num_nodes; cnode++) {
- nasid = GetNasid(cnode);
- srat_memory_affinity = ptr;
- ptr = srat_memory_affinity+1;
- srat_memory_affinity->header.type = ACPI_SRAT_MEMORY_AFFINITY;
- srat_memory_affinity->header.length = sizeof(struct acpi_table_memory_affinity);
- srat_memory_affinity->proximity_domain = PROXIMITY_DOMAIN(nasid);
- srat_memory_affinity->base_addr_lo = 0;
- srat_memory_affinity->length_lo = 0;
-#if defined(SGI_SN2)
- srat_memory_affinity->base_addr_hi = (nasid<<6) | (3<<4);
- srat_memory_affinity->length_hi = (MD_BANKSIZE*MD_BANKS_PER_NODE)>>32;
-#endif
- srat_memory_affinity->memory_type = ACPI_ADDRESS_RANGE_MEMORY;
- srat_memory_affinity->flags.enabled = 1;
- }
-
- for (cnode=0; cnode<num_nodes; cnode++) {
- nasid = GetNasid(cnode);
- for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
- if (!IsCpuPresent(cnode, cpu))
- continue;
- srat_cpu_affinity = ptr;
- ptr = srat_cpu_affinity + 1;
- srat_cpu_affinity->header.type = ACPI_SRAT_PROCESSOR_AFFINITY;
- srat_cpu_affinity->header.length = sizeof(struct acpi_table_processor_affinity);
- srat_cpu_affinity->proximity_domain = PROXIMITY_DOMAIN(nasid);
- srat_cpu_affinity->flags.enabled = 1;
-#if defined(SGI_SN2)
- srat_cpu_affinity->lsapic_eid = nasid&0xffff;
- srat_cpu_affinity->apic_id = (cpu<<4) | (nasid>>16);
-#endif
- }
- }
- acpi_checksum(&acpi_srat->header, (char*)ptr - (char*)acpi_srat);
-
-
- /* Set up the SLIT table */
- acpi_table_initx(&acpi_slit->header, SLIT_SIG, 4, ACPI_SLIT_REVISION, 1);
- acpi_slit->localities = PROXIMITY_DOMAIN(max_nasid)+1;
- cp=acpi_slit->entry;
- memset(cp, 255, acpi_slit->localities*acpi_slit->localities);
-
- for (i=0; i<=max_nasid; i++)
- for (j=0; j<=max_nasid; j++)
- if (nasid_present(i) && nasid_present(j))
- *(cp+PROXIMITY_DOMAIN(i)*acpi_slit->localities+PROXIMITY_DOMAIN(j)) = 10 + MIN(254, 5*abs(i-j));
-
- cp = acpi_slit->entry + acpi_slit->localities*acpi_slit->localities;
- acpi_checksum(&acpi_slit->header, cp - (char*)acpi_slit);
-
-
- /* fill in the SAL system table: */
- memcpy(sal_systab->signature, "SST_", 4);
- sal_systab->size = sizeof(*sal_systab);
- sal_systab->sal_rev_minor = 1;
- sal_systab->sal_rev_major = 0;
- sal_systab->entry_count = 3;
- sal_systab->sal_b_rev_major = 0x1; /* set the SN SAL rev to */
- sal_systab->sal_b_rev_minor = 0x0; /* 1.00 */
-
- strcpy(sal_systab->oem_id, "SGI");
- strcpy(sal_systab->product_id, "SN2");
-
- /* fill in an entry point: */
- sal_ed->type = SAL_DESC_ENTRY_POINT;
- sal_ed->pal_proc = __fwtab_pa(base_nasid, pal_desc[0]);
- sal_ed->sal_proc = __fwtab_pa(base_nasid, sal_desc[0]);
- sal_ed->gp = __fwtab_pa(base_nasid, sal_desc[1]);
-
- /* kludge the PTC domain info */
- sal_ptc->type = SAL_DESC_PTC;
- sal_ptc->num_domains = 0;
- sal_ptc->domain_info = __fwtab_pa(base_nasid, sal_ptcdi);
- cpus_found = 0;
- last_domain = -1;
- sal_ptcdi--;
- for (cnode=0; cnode<num_nodes; cnode++) {
- nasid = GetNasid(cnode);
- for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
- if (IsCpuPresent(cnode, cpu)) {
- domain = cnode*CPUS_PER_NODE + cpu/CPUS_PER_FSB;
- if (domain != last_domain) {
- sal_ptc->num_domains++;
- sal_ptcdi++;
- sal_ptcdi->proc_count = 0;
- sal_ptcdi->proc_list = __fwtab_pa(base_nasid, sal_ptclid);
- last_domain = domain;
- }
- sal_ptcdi->proc_count++;
- sal_ptclid->id = nasid;
- sal_ptclid->eid = cpu;
- sal_ptclid++;
- cpus_found++;
- }
- }
- }
-
- if (cpus_found != num_cpus)
- FPROM_BUG();
-
- /* Make the AP WAKEUP entry */
- sal_apwake->type = SAL_DESC_AP_WAKEUP;
- sal_apwake->mechanism = IA64_SAL_AP_EXTERNAL_INT;
- sal_apwake->vector = 18;
-
- for (checksum=0, cp=(char*)sal_systab; cp < (char *)efi_memmap; ++cp)
- checksum += *cp;
- sal_systab->checksum = -checksum;
-
- /* If the checksum is correct, the kernel tries to use the
- * table. We dont build enough table & the kernel aborts.
- * Note that the PROM hasd thhhe same problem!!
- */
-
- md = &efi_memmap[0];
- num_memmd = build_efi_memmap((void *)md, mdsize) ;
-
- bp = (struct ia64_boot_param*) __fwtab_pa(base_nasid, BOOT_PARAM_ADDR);
- bp->efi_systab = __fwtab_pa(base_nasid, &fw_mem);
- bp->efi_memmap = __fwtab_pa(base_nasid, efi_memmap);
- bp->efi_memmap_size = num_memmd*mdsize;
- bp->efi_memdesc_size = mdsize;
- bp->efi_memdesc_version = 0x101;
- bp->command_line = __fwtab_pa(base_nasid, cmd_line);
- bp->console_info.num_cols = 80;
- bp->console_info.num_rows = 25;
- bp->console_info.orig_x = 0;
- bp->console_info.orig_y = 24;
- bp->fpswa = 0;
-
- /*
- * Now pick the BSP & store it LID value in
- * a global variable. Note if BSP is greater than last cpu,
- * pick the last cpu.
- */
- for (cnode=0; cnode<num_nodes; cnode++) {
- for(cpu=0; cpu<CPUS_PER_NODE; cpu++) {
- if (!IsCpuPresent(cnode, cpu))
- continue;
-#ifdef SGI_SN2
- bsp_lid = (GetNasid(cnode)<<16) | (cpu<<28);
-#endif
- if (bsp-- > 0)
- continue;
- return;
- }
- }
-}
+++ /dev/null
-/* $Id: klgraph_init.c,v 1.1 2002/02/28 17:31:25 marcelo Exp $
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- */
-
-
-/*
- * This is a temporary file that statically initializes the expected
- * initial klgraph information that is normally provided by prom.
- */
-
-#include <linux/types.h>
-#include <linux/config.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/io.h>
-#include <asm/sn/driver.h>
-#include <asm/sn/iograph.h>
-#include <asm/param.h>
-#include <asm/sn/pio.h>
-#include <asm/sn/xtalk/xwidget.h>
-#include <asm/sn/sn_private.h>
-#include <asm/sn/addrs.h>
-#include <asm/sn/invent.h>
-#include <asm/sn/hcl.h>
-#include <asm/sn/hcl_util.h>
-#include <asm/sn/intr.h>
-#include <asm/sn/xtalk/xtalkaddrs.h>
-#include <asm/sn/klconfig.h>
-
-#define SYNERGY_WIDGET ((char *)0xc0000e0000000000)
-#define SYNERGY_SWIZZLE ((char *)0xc0000e0000000400)
-#define HUBREG ((char *)0xc0000a0001e00000)
-#define WIDGET0 ((char *)0xc0000a0000000000)
-#define WIDGET4 ((char *)0xc0000a0000000004)
-
-#define SYNERGY_WIDGET ((char *)0xc0000e0000000000)
-#define SYNERGY_SWIZZLE ((char *)0xc0000e0000000400)
-#define HUBREG ((char *)0xc0000a0001e00000)
-#define WIDGET0 ((char *)0xc0000a0000000000)
-
-#define convert(a,b,c) temp = (u64 *)a; *temp = b; temp++; *temp = c
-void
-klgraph_init(void)
-{
-
- u64 *temp;
- /*
- * Initialize some hub/xbow registers that allows access to
- * Xbridge etc. These are normally done in PROM.
- */
-
- /* Write IOERR clear to clear the CRAZY bit in the status */
- *(volatile uint64_t *)0xc000000801c001f8 = (uint64_t)0xffffffff;
-
- /* set widget control register...setting bedrock widget id to a */
- *(volatile uint64_t *)0xc000000801c00020 = (uint64_t)0x801a;
-
- /* set io outbound widget access...allow all */
- *(volatile uint64_t *)0xc000000801c00110 = (uint64_t)0xff01;
-
- /* set io inbound widget access...allow all */
- *(volatile uint64_t *)0xc000000801c00118 = (uint64_t)0xff01;
-
- /* set io crb timeout to max */
- *(volatile uint64_t *)0xc000000801c003c0 = (uint64_t)0xffffff;
- *(volatile uint64_t *)0xc000000801c003c0 = (uint64_t)0xffffff;
-
- /* set local block io permission...allow all */
-// [LB] *(volatile uint64_t *)0xc000000801e04010 = (uint64_t)0xfffffffffffffff;
-
- /* clear any errors */
- /* clear_ii_error(); medusa should have cleared these */
-
- /* set default read response buffers in bridge */
-// [PI] *(volatile u32 *)0xc00000080f000280L = 0xba98;
-// [PI] *(volatile u32 *)0xc00000080f000288L = 0xba98;
-
- /*
- * klconfig entries initialization - mankato
- */
- convert(0xe000003000030000, 0x00000000beedbabe, 0x0000004800000000);
- convert(0xe000003000030010, 0x0003007000000018, 0x800002000f820178);
- convert(0xe000003000030020, 0x80000a000f024000, 0x800002000f800000);
- convert(0xe000003000030030, 0x0300fafa00012580, 0x00000000040f0000);
- convert(0xe000003000030040, 0x0000000000000000, 0x0003097000030070);
- convert(0xe000003000030050, 0x00030970000303b0, 0x0003181000033f70);
- convert(0xe000003000030060, 0x0003d51000037570, 0x0000000000038330);
- convert(0xe000003000030070, 0x0203110100030140, 0x0001000000000101);
- convert(0xe000003000030080, 0x0900000000000000, 0x000000004e465e67);
- convert(0xe000003000030090, 0x0003097000000000, 0x00030b1000030a40);
- convert(0xe0000030000300a0, 0x00030cb000030be0, 0x000315a0000314d0);
- convert(0xe0000030000300b0, 0x0003174000031670, 0x0000000000000000);
- convert(0xe000003000030100, 0x000000000000001a, 0x3350490000000000);
- convert(0xe000003000030110, 0x0000000000000037, 0x0000000000000000);
- convert(0xe000003000030140, 0x0002420100030210, 0x0001000000000101);
- convert(0xe000003000030150, 0x0100000000000000, 0xffffffffffffffff);
- convert(0xe000003000030160, 0x00030d8000000000, 0x0000000000030e50);
- convert(0xe0000030000301c0, 0x0000000000000000, 0x0000000000030070);
- convert(0xe0000030000301d0, 0x0000000000000025, 0x424f490000000000);
- convert(0xe0000030000301e0, 0x000000004b434952, 0x0000000000000000);
- convert(0xe000003000030210, 0x00027101000302e0, 0x00010000000e4101);
- convert(0xe000003000030220, 0x0200000000000000, 0xffffffffffffffff);
- convert(0xe000003000030230, 0x00030f2000000000, 0x0000000000030ff0);
- convert(0xe000003000030290, 0x0000000000000000, 0x0000000000030140);
- convert(0xe0000030000302a0, 0x0000000000000026, 0x7262490000000000);
- convert(0xe0000030000302b0, 0x00000000006b6369, 0x0000000000000000);
- convert(0xe0000030000302e0, 0x0002710100000000, 0x00010000000f3101);
- convert(0xe0000030000302f0, 0x0500000000000000, 0xffffffffffffffff);
- convert(0xe000003000030300, 0x000310c000000000, 0x0003126000031190);
- convert(0xe000003000030310, 0x0003140000031330, 0x0000000000000000);
- convert(0xe000003000030360, 0x0000000000000000, 0x0000000000030140);
- convert(0xe000003000030370, 0x0000000000000029, 0x7262490000000000);
- convert(0xe000003000030380, 0x00000000006b6369, 0x0000000000000000);
- convert(0xe000003000030970, 0x0000000002010102, 0x0000000000000000);
- convert(0xe000003000030980, 0x000000004e465e67, 0xffffffff00000000);
- /* convert(0x00000000000309a0, 0x0000000000037570, 0x0000000100000000); */
- convert(0xe0000030000309a0, 0x0000000000037570, 0xffffffff00000000);
- convert(0xe0000030000309b0, 0x0000000000030070, 0x0000000000000000);
- convert(0xe0000030000309c0, 0x000000000003f420, 0x0000000000000000);
- convert(0xe000003000030a40, 0x0000000002010125, 0x0000000000000000);
- convert(0xe000003000030a50, 0xffffffffffffffff, 0xffffffff00000000);
- convert(0xe000003000030a70, 0x0000000000037b78, 0x0000000000000000);
- convert(0xe000003000030b10, 0x0000000002010125, 0x0000000000000000);
- convert(0xe000003000030b20, 0xffffffffffffffff, 0xffffffff00000000);
- convert(0xe000003000030b40, 0x0000000000037d30, 0x0000000000000001);
- convert(0xe000003000030be0, 0x00000000ff010203, 0x0000000000000000);
- convert(0xe000003000030bf0, 0xffffffffffffffff, 0xffffffff000000ff);
- convert(0xe000003000030c10, 0x0000000000037ee8, 0x0100010000000200);
- convert(0xe000003000030cb0, 0x00000000ff310111, 0x0000000000000000);
- convert(0xe000003000030cc0, 0xffffffffffffffff, 0x0000000000000000);
- convert(0xe000003000030d80, 0x0000000002010104, 0x0000000000000000);
- convert(0xe000003000030d90, 0xffffffffffffffff, 0x00000000000000ff);
- convert(0xe000003000030db0, 0x0000000000037f18, 0x0000000000000000);
- convert(0xe000003000030dc0, 0x0000000000000000, 0x0003007000060000);
- convert(0xe000003000030de0, 0x0000000000000000, 0x0003021000050000);
- convert(0xe000003000030df0, 0x000302e000050000, 0x0000000000000000);
- convert(0xe000003000030e30, 0x0000000000000000, 0x000000000000000a);
- convert(0xe000003000030e50, 0x00000000ff00011a, 0x0000000000000000);
- convert(0xe000003000030e60, 0xffffffffffffffff, 0x0000000000000000);
- convert(0xe000003000030e80, 0x0000000000037fe0, 0x9e6e9e9e9e9e9e9e);
- convert(0xe000003000030e90, 0x000000000000bc6e, 0x0000000000000000);
- convert(0xe000003000030f20, 0x0000000002010205, 0x00000000d0020000);
- convert(0xe000003000030f30, 0xffffffffffffffff, 0x0000000e0000000e);
- convert(0xe000003000030f40, 0x000000000000000e, 0x0000000000000000);
- convert(0xe000003000030f50, 0x0000000000038010, 0x00000000000007ff);
- convert(0xe000003000030f70, 0x0000000000000000, 0x0000000022001077);
- convert(0xe000003000030fa0, 0x0000000000000000, 0x000000000003f4a8);
- convert(0xe000003000030ff0, 0x0000000000310120, 0x0000000000000000);
- convert(0xe000003000031000, 0xffffffffffffffff, 0xffffffff00000002);
- convert(0xe000003000031010, 0x000000000000000e, 0x0000000000000000);
- convert(0xe000003000031020, 0x0000000000038088, 0x0000000000000000);
- convert(0xe0000030000310c0, 0x0000000002010205, 0x00000000d0020000);
- convert(0xe0000030000310d0, 0xffffffffffffffff, 0x0000000f0000000f);
- convert(0xe0000030000310e0, 0x000000000000000f, 0x0000000000000000);
- convert(0xe0000030000310f0, 0x00000000000380b8, 0x00000000000007ff);
- convert(0xe000003000031120, 0x0000000022001077, 0x00000000000310a9);
- convert(0xe000003000031130, 0x00000000580211c1, 0x000000008009104c);
- convert(0xe000003000031140, 0x0000000000000000, 0x000000000003f4c0);
- convert(0xe000003000031190, 0x0000000000310120, 0x0000000000000000);
- convert(0xe0000030000311a0, 0xffffffffffffffff, 0xffffffff00000003);
- convert(0xe0000030000311b0, 0x000000000000000f, 0x0000000000000000);
- convert(0xe0000030000311c0, 0x0000000000038130, 0x0000000000000000);
- convert(0xe000003000031260, 0x0000000000110106, 0x0000000000000000);
- convert(0xe000003000031270, 0xffffffffffffffff, 0xffffffff00000004);
- convert(0xe000003000031270, 0xffffffffffffffff, 0xffffffff00000004);
- convert(0xe000003000031280, 0x000000000000000f, 0x0000000000000000);
- convert(0xe0000030000312a0, 0x00000000ff110013, 0x0000000000000000);
- convert(0xe0000030000312b0, 0xffffffffffffffff, 0xffffffff00000000);
- convert(0xe0000030000312c0, 0x000000000000000f, 0x0000000000000000);
- convert(0xe0000030000312e0, 0x0000000000110012, 0x0000000000000000);
- convert(0xe0000030000312f0, 0xffffffffffffffff, 0xffffffff00000000);
- convert(0xe000003000031300, 0x000000000000000f, 0x0000000000000000);
- convert(0xe000003000031310, 0x0000000000038160, 0x0000000000000000);
- convert(0xe000003000031330, 0x00000000ff310122, 0x0000000000000000);
- convert(0xe000003000031340, 0xffffffffffffffff, 0xffffffff00000005);
- convert(0xe000003000031350, 0x000000000000000f, 0x0000000000000000);
- convert(0xe000003000031360, 0x0000000000038190, 0x0000000000000000);
- convert(0xe000003000031400, 0x0000000000310121, 0x0000000000000000);
- convert(0xe000003000031400, 0x0000000000310121, 0x0000000000000000);
- convert(0xe000003000031410, 0xffffffffffffffff, 0xffffffff00000006);
- convert(0xe000003000031420, 0x000000000000000f, 0x0000000000000000);
- convert(0xe000003000031430, 0x00000000000381c0, 0x0000000000000000);
- convert(0xe0000030000314d0, 0x00000000ff010201, 0x0000000000000000);
- convert(0xe0000030000314e0, 0xffffffffffffffff, 0xffffffff00000000);
- convert(0xe000003000031500, 0x00000000000381f0, 0x000030430000ffff);
- convert(0xe000003000031510, 0x000000000000ffff, 0x0000000000000000);
- convert(0xe0000030000315a0, 0x00000020ff000201, 0x0000000000000000);
- convert(0xe0000030000315b0, 0xffffffffffffffff, 0xffffffff00000001);
- convert(0xe0000030000315d0, 0x0000000000038240, 0x00003f3f0000ffff);
- convert(0xe0000030000315e0, 0x000000000000ffff, 0x0000000000000000);
- convert(0xe000003000031670, 0x00000000ff010201, 0x0000000000000000);
- convert(0xe000003000031680, 0xffffffffffffffff, 0x0000000100000002);
- convert(0xe0000030000316a0, 0x0000000000038290, 0x000030430000ffff);
- convert(0xe0000030000316b0, 0x000000000000ffff, 0x0000000000000000);
- convert(0xe000003000031740, 0x00000020ff000201, 0x0000000000000000);
- convert(0xe000003000031750, 0xffffffffffffffff, 0x0000000500000003);
- convert(0xe000003000031770, 0x00000000000382e0, 0x00003f3f0000ffff);
- convert(0xe000003000031780, 0x000000000000ffff, 0x0000000000000000);
-}
+++ /dev/null
-/*
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <asm/bitops.h>
-
-extern void klgraph_init(void);
-void bedrock_init(int);
-void synergy_init(int, int);
-void sys_fw_init (const char *args, int arglen, int bsp);
-
-volatile int bootmaster=0; /* Used to pick bootmaster */
-volatile int nasidmaster[128]={0}; /* Used to pick node/synergy masters */
-int init_done=0;
-extern int bsp_lid;
-
-#define get_bit(b,p) (((*p)>>(b))&1)
-
-int
-fmain(int lid, int bsp) {
- int syn, nasid, cpu;
-
- /*
- * First lets figure out who we are. This is done from the
- * LID passed to us.
- */
- nasid = (lid>>16)&0xfff;
- cpu = (lid>>28)&3;
- syn = 0;
-
- /*
- * Now pick a nasid master to initialize Bedrock registers.
- */
- if (test_and_set_bit(8, &nasidmaster[nasid]) == 0) {
- bedrock_init(nasid);
- test_and_set_bit(9, &nasidmaster[nasid]);
- } else
- while (get_bit(9, &nasidmaster[nasid]) == 0);
-
-
- /*
- * Now pick a BSP & finish init.
- */
- if (test_and_set_bit(0, &bootmaster) == 0) {
- sys_fw_init(0, 0, bsp);
- test_and_set_bit(1, &bootmaster);
- } else
- while (get_bit(1, &bootmaster) == 0);
-
- return (lid == bsp_lid);
-}
-
-
-void
-bedrock_init(int nasid)
-{
- nasid = nasid; /* to quiet gcc */
-#if 0
- /*
- * Undef if you need fprom to generate a 1 node klgraph
- * information .. only works for 1 node for nasid 0.
- */
- klgraph_init();
-#endif
-}
-
-
-void
-synergy_init(int nasid, int syn)
-{
- long *base;
- long off;
-
- /*
- * Enable all FSB flashed interrupts.
- * I'd really like defines for this......
- */
- base = (long*)0x80000e0000000000LL; /* base of synergy regs */
- for (off = 0x2a0; off < 0x2e0; off+=8) /* offset for VEC_MASK_{0-3}_A/B */
- *(base+off/8) = -1LL;
-
- /*
- * Set the NASID in the FSB_CONFIG register.
- */
- base = (long*)0x80000e0000000450LL;
- *base = (long)((nasid<<16)|(syn<<9));
-}
-
-
-/* Why isnt there a bcopy/memcpy in lib64.a */
-
-void*
-memcpy(void * dest, const void *src, size_t count)
-{
- char *s, *se, *d;
-
- for(d=dest, s=(char*)src, se=s+count; s<se; s++, d++)
- *d = *s;
- return dest;
-}
+++ /dev/null
-#!/bin/sh
-#
-# Build a textsym file for use in the Arium ITP probe.
-#
-#
-# This file is subject to the terms and conditions of the GNU General Public
-# License. See the file "COPYING" in the main directory of this archive
-# for more details.
-#
-# Copyright (c) 2001-2003 Silicon Graphics, Inc. All rights reserved.
-#
-
-help() {
-cat <<END
-Build a WinDD "symtxt" file for use with the Arium ECM-30 probe.
-
- Usage: $0 [<vmlinux file> [<output file>]]
- If no input file is specified, it defaults to vmlinux.
- If no output file name is specified, it defaults to "textsym".
-END
-exit 1
-}
-
-err () {
- echo "ERROR - $*" >&2
- exit 1
-}
-
-
-OPTS="H"
-while getopts "$OPTS" c ; do
- case $c in
- H) help;;
- \?) help;;
- esac
-
-done
-shift `expr $OPTIND - 1`
-
-#OBJDUMP=/usr/bin/ia64-linux-objdump
-LINUX=${1:-vmlinux}
-TEXTSYM=${2:-${LINUX}.sym}
-TMPSYM=${2:-${LINUX}.sym.tmp}
-trap "/bin/rm -f $TMPSYM" 0
-
-[ -f $VMLINUX ] || help
-
-$OBJDUMP -t $LINUX | egrep -v '__ks' | sort > $TMPSYM
-SN1=`egrep "dig_setup|Synergy_da_indr" $TMPSYM|wc -l`
-
-# Dataprefix and textprefix correspond to the VGLOBAL_BASE and VPERNODE_BASE.
-# Eventually, these values should be:
-# dataprefix ffffffff
-# textprefix fffffffe
-# but right now they're still changing, so make them dynamic.
-dataprefix=`awk ' / \.data / { print substr($1, 0, 8) ; exit ; }' $TMPSYM`
-textprefix=`awk ' / \.text / { print substr($1, 0, 8) ; exit ; }' $TMPSYM`
-
-# pipe everything thru sort
-echo "TEXTSYM V1.0"
-(cat <<END
-GLOBAL | ${textprefix}00000000 | CODE | VEC_VHPT_Translation_0000
-GLOBAL | ${textprefix}00000400 | CODE | VEC_ITLB_0400
-GLOBAL | ${textprefix}00000800 | CODE | VEC_DTLB_0800
-GLOBAL | ${textprefix}00000c00 | CODE | VEC_Alt_ITLB_0c00
-GLOBAL | ${textprefix}00001000 | CODE | VEC_Alt_DTLB_1000
-GLOBAL | ${textprefix}00001400 | CODE | VEC_Data_nested_TLB_1400
-GLOBAL | ${textprefix}00001800 | CODE | VEC_Instruction_Key_Miss_1800
-GLOBAL | ${textprefix}00001c00 | CODE | VEC_Data_Key_Miss_1c00
-GLOBAL | ${textprefix}00002000 | CODE | VEC_Dirty-bit_2000
-GLOBAL | ${textprefix}00002400 | CODE | VEC_Instruction_Access-bit_2400
-GLOBAL | ${textprefix}00002800 | CODE | VEC_Data_Access-bit_2800
-GLOBAL | ${textprefix}00002c00 | CODE | VEC_Break_instruction_2c00
-GLOBAL | ${textprefix}00003000 | CODE | VEC_External_Interrupt_3000
-GLOBAL | ${textprefix}00003400 | CODE | VEC_Reserved_3400
-GLOBAL | ${textprefix}00003800 | CODE | VEC_Reserved_3800
-GLOBAL | ${textprefix}00003c00 | CODE | VEC_Reserved_3c00
-GLOBAL | ${textprefix}00004000 | CODE | VEC_Reserved_4000
-GLOBAL | ${textprefix}00004400 | CODE | VEC_Reserved_4400
-GLOBAL | ${textprefix}00004800 | CODE | VEC_Reserved_4800
-GLOBAL | ${textprefix}00004c00 | CODE | VEC_Reserved_4c00
-GLOBAL | ${textprefix}00005000 | CODE | VEC_Page_Not_Present_5000
-GLOBAL | ${textprefix}00005100 | CODE | VEC_Key_Permission_5100
-GLOBAL | ${textprefix}00005200 | CODE | VEC_Instruction_Access_Rights_5200
-GLOBAL | ${textprefix}00005300 | CODE | VEC_Data_Access_Rights_5300
-GLOBAL | ${textprefix}00005400 | CODE | VEC_General_Exception_5400
-GLOBAL | ${textprefix}00005500 | CODE | VEC_Disabled_FP-Register_5500
-GLOBAL | ${textprefix}00005600 | CODE | VEC_Nat_Consumption_5600
-GLOBAL | ${textprefix}00005700 | CODE | VEC_Speculation_5700
-GLOBAL | ${textprefix}00005800 | CODE | VEC_Reserved_5800
-GLOBAL | ${textprefix}00005900 | CODE | VEC_Debug_5900
-GLOBAL | ${textprefix}00005a00 | CODE | VEC_Unaligned_Reference_5a00
-GLOBAL | ${textprefix}00005b00 | CODE | VEC_Unsupported_Data_Reference_5b00
-GLOBAL | ${textprefix}00005c00 | CODE | VEC_Floating-Point_Fault_5c00
-GLOBAL | ${textprefix}00005d00 | CODE | VEC_Floating_Point_Trap_5d00
-GLOBAL | ${textprefix}00005e00 | CODE | VEC_Lower_Privilege_Tranfer_Trap_5e00
-GLOBAL | ${textprefix}00005f00 | CODE | VEC_Taken_Branch_Trap_5f00
-GLOBAL | ${textprefix}00006000 | CODE | VEC_Single_Step_Trap_6000
-GLOBAL | ${textprefix}00006100 | CODE | VEC_Reserved_6100
-GLOBAL | ${textprefix}00006200 | CODE | VEC_Reserved_6200
-GLOBAL | ${textprefix}00006300 | CODE | VEC_Reserved_6300
-GLOBAL | ${textprefix}00006400 | CODE | VEC_Reserved_6400
-GLOBAL | ${textprefix}00006500 | CODE | VEC_Reserved_6500
-GLOBAL | ${textprefix}00006600 | CODE | VEC_Reserved_6600
-GLOBAL | ${textprefix}00006700 | CODE | VEC_Reserved_6700
-GLOBAL | ${textprefix}00006800 | CODE | VEC_Reserved_6800
-GLOBAL | ${textprefix}00006900 | CODE | VEC_IA-32_Exeception_6900
-GLOBAL | ${textprefix}00006a00 | CODE | VEC_IA-32_Intercept_6a00
-GLOBAL | ${textprefix}00006b00 | CODE | VEC_IA-32_Interrupt_6b00
-GLOBAL | ${textprefix}00006c00 | CODE | VEC_Reserved_6c00
-GLOBAL | ${textprefix}00006d00 | CODE | VEC_Reserved_6d00
-GLOBAL | ${textprefix}00006e00 | CODE | VEC_Reserved_6e00
-GLOBAL | ${textprefix}00006f00 | CODE | VEC_Reserved_6f00
-GLOBAL | ${textprefix}00007000 | CODE | VEC_Reserved_7000
-GLOBAL | ${textprefix}00007100 | CODE | VEC_Reserved_7100
-GLOBAL | ${textprefix}00007200 | CODE | VEC_Reserved_7200
-GLOBAL | ${textprefix}00007300 | CODE | VEC_Reserved_7300
-GLOBAL | ${textprefix}00007400 | CODE | VEC_Reserved_7400
-GLOBAL | ${textprefix}00007500 | CODE | VEC_Reserved_7500
-GLOBAL | ${textprefix}00007600 | CODE | VEC_Reserved_7600
-GLOBAL | ${textprefix}00007700 | CODE | VEC_Reserved_7700
-GLOBAL | ${textprefix}00007800 | CODE | VEC_Reserved_7800
-GLOBAL | ${textprefix}00007900 | CODE | VEC_Reserved_7900
-GLOBAL | ${textprefix}00007a00 | CODE | VEC_Reserved_7a00
-GLOBAL | ${textprefix}00007b00 | CODE | VEC_Reserved_7b00
-GLOBAL | ${textprefix}00007c00 | CODE | VEC_Reserved_7c00
-GLOBAL | ${textprefix}00007d00 | CODE | VEC_Reserved_7d00
-GLOBAL | ${textprefix}00007e00 | CODE | VEC_Reserved_7e00
-GLOBAL | ${textprefix}00007f00 | CODE | VEC_Reserved_7f00
-END
-
-
-awk '
-/ _start$/ {start=1}
-/ start_ap$/ {start=1}
-/__start_gate_section/ {start=1}
-/^'${dataprefix}\|${textprefix}'/ {
- if ($4 == ".kdb")
- next
- if (start && substr($NF,1,1) != "0") {
- type = substr($0,26,5)
- if (type == ".text")
- printf "GLOBAL | %s | CODE | %s\n", $1, $NF
- else {
- n = 0
- s = $(NF-1)
- while (length(s) > 0) {
- n = n*16 + (index("0123456789abcdef", substr(s,1,1)) - 1)
- s = substr(s,2)
- }
- printf "GLOBAL | %s | DATA | %s | %d\n", $1, $NF, n
- }
- }
- if($NF == "_end")
- exit
-
-}
-' $TMPSYM ) | egrep -v " __device| __vendor" | awk -v sn1="$SN1" '
-/GLOBAL/ {
- print $0
- if (sn1 != 0) {
- /* 32 bits of sn1 physical addrs, */
- print substr($0,1,9) "04" substr($0,20,16) "Phy_" substr($0,36)
- } else {
- /* 38 bits of sn2 physical addrs, need addr space bits */
- print substr($0,1,9) "3004" substr($0,20,16) "Phy_" substr($0,36)
- }
-
-} ' | sort -k3
-
-N=`wc -l $TEXTSYM|awk '{print $1}'`
-echo "Generated TEXTSYM file" >&2
-echo " $LINUX --> $TEXTSYM" >&2
-echo " Found $N symbols" >&2
+++ /dev/null
-#!/bin/sh
-
-# Script for running PROMs and LINUX kernwls on medusa.
-# Type "sim -H" for instructions.
-
-MEDUSA=${MEDUSA:-/home/rickc/official_medusa/medusa}
-
-# ------------------ err -----------------------
-err() {
- echo "ERROR - $1"
- exit 1
-}
-
-# ---------------- help ----------------------
-help() {
-cat <<END
-Script for running a PROM or LINUX kernel under medusa.
-This script creates a control file, creates links to the appropriate
-linux/prom files, and/or calls medusa to make simulation runs.
-
-Usage:
- Initial setup:
- sim [-c <config_file>] <-p> | <-k> [<work_dir>]
- -p Create PROM control file & links
- -k Create LINUX control file & links
- -c<cf> Control file name [Default: cf]
- <work_dir> Path to directory that contains the linux or PROM files.
- The directory can be any of the following:
- (linux simulations)
- worktree
- worktree/linux
- any directory with vmlinux, vmlinux.sym & fprom files
- (prom simulations)
- worktree
- worktree/stand/arcs/IP37prom/dev
- any directory with fw.bin & fw.sim files
-
- Simulations:
- sim [-X <n>] [-o <output>] [-M] [<config_file>]
- -c<cf> Control file name [Default: cf]
- -M Pipe output thru fmtmedusa
- -o Output filename (copy of all commands/output) [Default: simout]
- -X Specifies number of instructions to execute [Default: 0]
- (Used only in auto test mode - not described here)
-
-Examples:
- sim -p <promtree> # create control file (cf) & links for prom simulations
- sim -k <linuxtree> # create control file (cf) & links for linux simulations
- sim -p -c cfprom # create a prom control file (cfprom) only. No links are made.
-
- sim # run medusa using previously created links &
- # control file (cf).
-END
-exit 1
-}
-
-# ----------------------- create control file header --------------------
-create_cf_header() {
-cat <<END >>$CF
-#
-# Template for a control file for running linux kernels under medusa.
-# You probably want to make mods here but this is a good starting point.
-#
-
-# Preferences
-setenv cpu_stepping A
-setenv exceptionPrint off
-setenv interrupt_messages off
-setenv lastPCsize 100000
-setenv low_power_mode on
-setenv partialIntelChipSet on
-setenv printIntelMessages off
-setenv prom_write_action halt
-setenv prom_write_messages on
-setenv step_quantum 100
-setenv swizzling on
-setenv tsconsole on
-setenv uart_echo on
-symbols on
-
-# IDE disk params
-setenv diskCylinders 611
-setenv bootDrive C
-setenv diskHeads 16
-setenv diskPath idedisk
-setenv diskPresent 1
-setenv diskSpt 63
-
-# Hardware config
-setenv coherency_type nasid
-setenv cpu_cache_type default
-setenv synergy_cache_type syn_cac_64m_8w
-setenv l4_uc_snoop off
-
-# Numalink config
-setenv route_enable on
-setenv network_type router # Select [xbar|router]
-setenv network_warning 0xff
-
-END
-}
-
-
-# ------------------ create control file entries for linux simulations -------------
-create_cf_linux() {
-cat <<END >>$CF
-# Kernel specific options
-setenv calias_size 0
-setenv mca_on_memory_failure off
-setenv LOADPC 0x00100000 # FPROM load address/entry point (8 digits!)
-setenv symbol_table vmlinux.sym
-load fprom
-load vmlinux
-
-# Useful breakpoints to always have set. Add more if desired.
-break 0xe000000000505e00 all # dispatch_to_fault_handler
-break panic all # stop on panic
-break die_if_kernel all # may as well stop
-
-END
-}
-
-# ------------------ create control file entries for prom simulations ---------------
-create_cf_prom() {
- SYM2=""
- ADDR="0x80000000ff800000"
- [ "$EMBEDDED_LINUX" != "0" ] || SYM2="setenv symbol_table2 vmlinux.sym"
- [ "$SIZE" = "8MB" ] || ADDR="0x80000000ffc00000"
- cat <<END >>$CF
-# PROM specific options
-setenv mca_on_memory_failure on
-setenv LOADPC 0x80000000ffffffb0
-setenv promFile fw.bin
-setenv promAddr $ADDR
-setenv symbol_table fw.sym
-$SYM2
-
-# Useful breakpoints to always have set. Add more if desired.
-break ivt_gexx all
-break ivt_brk all
-break PROM_Panic_Spin all
-break PROM_Panic all
-break PROM_C_Panic all
-break fled_die all
-break ResetNow all
-break zzzbkpt all
-
-END
-}
-
-
-# ------------------ create control file entries for memory configuration -------------
-create_cf_memory() {
-cat <<END >>$CF
-# CPU/Memory map format:
-# setenv nodeN_memory_config 0xBSBSBSBS
-# B=banksize (0=unused, 1=64M, 2=128M, .., 5-1G, c=8M, d=16M, e=32M)
-# S=bank enable (0=both disable, 3=both enable, 2=bank1 enable, 1=bank0 enable)
-# rightmost digits are for bank 0, the lowest address.
-# setenv nodeN_nasid <nasid>
-# specifies the NASID for the node. This is used ONLY if booting the kernel.
-# On PROM configurations, set to 0 - PROM will change it later.
-# setenv nodeN_cpu_config <cpu_mask>
-# Set bit number N to 1 to enable cpu N. Ex., a value of 5 enables cpu 0 & 2.
-#
-# Repeat the above 3 commands for each node.
-#
-# For kernel, default to 32MB. Although this is not a valid hardware configuration,
-# it runs faster on medusa. For PROM, 64MB is smallest allowed value.
-
-setenv node0_cpu_config 0x1 # Enable only cpu 0 on the node
-END
-
-if [ $LINUX -eq 1 ] ; then
-cat <<END >>$CF
-setenv node0_nasid 0 # cnode 0 has NASID 0
-setenv node0_memory_config 0xe1 # 32MB
-END
-else
-cat <<END >>$CF
-setenv node0_memory_config 0x31 # 256MB
-END
-fi
-}
-
-# -------------------- set links to linux files -------------------------
-set_linux_links() {
- if [ -d $D/linux/arch ] ; then
- D=$D/linux
- elif [ -d $D/arch -o -e vmlinux.sym -o -e $D/vmlinux ] ; then
- D=$D
- else
- err "cant determine directory for linux binaries"
- fi
- rm -rf vmlinux vmlinux.sym fprom
- ln -s $D/vmlinux vmlinux
- if [ -f $D/vmlinux.sym ] ; then
- ln -s $D/vmlinux.sym vmlinux.sym
- elif [ -f $D/System.map ] ; then
- ln -s $D/System.map vmlinux.sym
- fi
- if [ -d $D/arch ] ; then
- ln -s $D/arch/ia64/sn/fprom/fprom fprom
- else
- ln -s $D/fprom fprom
- fi
- echo " .. Created links to linux files"
-}
-
-# -------------------- set links to prom files -------------------------
-set_prom_links() {
- if [ -d $D/stand ] ; then
- D=$D/stand/arcs/IP37prom/dev
- elif [ -d $D/sal ] ; then
- D=$D
- else
- err "cant determine directory for PROM binaries"
- fi
- SETUP="/tmp/tmp.$$"
- rm -r -f $SETUP
- sed 's/export/setenv/' < $D/../../../../.setup | sed 's/=/ /' >$SETUP
- egrep -q '^ *setenv *PROMSIZE *8MB|^ *export' $SETUP
- if [ $? -eq 0 ] ; then
- SIZE="8MB"
- else
- SIZE="4MB"
- fi
- grep -q '^ *setenv *LAUNCH_VMLINUX' $SETUP
- EMBEDDED_LINUX=$?
- PRODUCT=`grep '^ *setenv *PRODUCT' $SETUP | cut -d" " -f3`
- rm -f fw.bin fw.map fw.sym vmlinux vmlinux.sym fprom $SETUP
- SDIR="${PRODUCT}${SIZE}.O"
- BIN="${PRODUCT}ip37prom${SIZE}"
- ln -s $D/$SDIR/$BIN.bin fw.bin
- ln -s $D/$SDIR/$BIN.map fw.map
- ln -s $D/$SDIR/$BIN.sym fw.sym
- echo " .. Created links to $SIZE prom files"
- if [ $EMBEDDED_LINUX -eq 0 ] ; then
- ln -s $D/linux/vmlinux vmlinux
- ln -s $D/linux/vmlinux.sym vmlinux.sym
- if [ -d linux/arch ] ; then
- ln -s $D/linux/arch/ia64/sn/fprom/fprom fprom
- else
- ln -s $D/linux/fprom fprom
- fi
- echo " .. Created links to embedded linux files in prom tree"
- fi
-}
-
-# --------------- start of shell script --------------------------------
-OUT="simout"
-FMTMED=0
-STEPCNT=0
-PROM=0
-LINUX=0
-NCF="cf"
-while getopts "HMX:c:o:pk" c ; do
- case ${c} in
- H) help;;
- M) FMTMED=1;;
- X) STEPCNT=${OPTARG};;
- c) NCF=${OPTARG};;
- k) PROM=0;LINUX=1;;
- p) PROM=1;LINUX=0;;
- o) OUT=${OPTARG};;
- \?) exit 1;;
- esac
-done
-shift `expr ${OPTIND} - 1`
-
-# Check if command is for creating control file and/or links to images.
-if [ $PROM -eq 1 -o $LINUX -eq 1 ] ; then
- CF=$NCF
- [ ! -f $CF ] || err "wont overwrite an existing control file ($CF)"
- if [ $# -gt 0 ] ; then
- D=$1
- [ -d $D ] || err "cannot find directory $D"
- [ $PROM -eq 0 ] || set_prom_links
- [ $LINUX -eq 0 ] || set_linux_links
- fi
- create_cf_header
- [ $PROM -eq 0 ] || create_cf_prom
- [ $LINUX -eq 0 ] || create_cf_linux
- [ ! -f ../idedisk ] || ln -s ../idedisk .
- create_cf_memory
- echo " .. Basic control file created (in $CF). You might want to edit"
- echo " this file (at least, look at it)."
- exit 0
-fi
-
-# Verify that the control file exists
-CF=${1:-$NCF}
-[ -f $CF ] || err "No control file exists. For help, type: $0 -H"
-
-# Build the .cf files from the user control file. The .cf file is
-# identical except that the actual start & load addresses are inserted
-# into the file. In addition, the FPROM commands for configuring memory
-# and LIDs are generated.
-
-rm -f .cf .cf1 .cf2
-awk '
-function strtonum(n) {
- if (substr(n,1,2) != "0x")
- return int(n)
- n = substr(n,3)
- r=0
- while (length(n) > 0) {
- r = r*16+(index("0123456789abcdef", substr(n,1,1))-1)
- n = substr(n,2)
- }
- return r
- }
-/^#/ {next}
-/^$/ {next}
-/^setenv *LOADPC/ {loadpc = $3; next}
-/^setenv *node.._cpu_config/ {n=int(substr($2,5,2)); cpuconf[n] = strtonum($3); print; next}
-/^setenv *node.._memory_config/ {n=int(substr($2,5,2)); memconf[n] = strtonum($3); print; next}
-/^setenv *node.._nasid/ {n=int(substr($2,5,2)); nasid[n] = strtonum($3); print; next}
-/^setenv *node._cpu_config/ {n=int(substr($2,5,1)); cpuconf[n] = strtonum($3); print; next}
-/^setenv *node._memory_config/ {n=int(substr($2,5,1)); memconf[n] = strtonum($3); print; next}
-/^setenv *node._nasid/ {n=int(substr($2,5,1)); nasid[n] = strtonum($3); print; next}
- {print}
-END {
- # Generate the memmap info that starts at the beginning of
- # the node the kernel was loaded on.
- loadnasid = nasid[0]
- cnode = 0
- for (i=0; i<128; i++) {
- if (memconf[i] != "") {
- printf "sm 0x%x%08x 0x%x%04x%04x\n",
- 2*loadnasid, 8*cnodes+8, memconf[i], cpuconf[i], nasid[i]
- cnodes++
- cpus += substr("0112122312232334", cpuconf[i]+1,1)
- }
- }
- printf "sm 0x%x00000000 0x%x%08x\n", 2*loadnasid, cnodes, cpus
- printf "setenv number_of_nodes %d\n", cnodes
-
- # Now set the starting PC for each cpu.
- cnode = 0
- lowcpu=-1
- for (i=0; i<128; i++) {
- if (memconf[i] != "") {
- printf "setnode %d\n", cnode
- conf = cpuconf[i]
- for (j=0; j<4; j++) {
- if (conf != int(conf/2)*2) {
- printf "setcpu %d\n", j
- if (length(loadpc) == 18)
- printf "sr pc %s\n", loadpc
- else
- printf "sr pc 0x%x%s\n", 2*loadnasid, substr(loadpc,3)
- if (lowcpu == -1)
- lowcpu = j
- }
- conf = int(conf/2)
- }
- cnode++
- }
- }
- printf "setnode 0\n"
- printf "setcpu %d\n", lowcpu
- }
-' <$CF >.cf
-
-# Now build the .cf1 & .cf2 control files.
-CF2_LINES="^sm |^break |^run |^si |^quit |^symbols "
-egrep "$CF2_LINES" .cf >.cf2
-egrep -v "$CF2_LINES" .cf >.cf1
-if [ $STEPCNT -ne 0 ] ; then
- echo "s $STEPCNT" >>.cf2
- echo "lastpc 1000" >>.cf2
- echo "q" >>.cf2
-fi
-if [ -f vmlinux.sym ] ; then
- awk '/ _start$/ {print "sr g 9 0x" $3}' < vmlinux.sym >> .cf2
-fi
-echo "script-on $OUT" >>.cf2
-
-# Now start medusa....
-if [ $FMTMED -ne 0 ] ; then
- $MEDUSA -system mpsn1 -c .cf1 -i .cf2 | fmtmedusa
-elif [ $STEPCNT -eq 0 ] ; then
- $MEDUSA -system mpsn1 -c .cf1 -i .cf2
-else
- $MEDUSA -system mpsn1 -c .cf1 -i .cf2 2>&1
-fi
+++ /dev/null
-#
-# Automatically generated make config: don't edit
-#
-CONFIG_MIPS=y
-# CONFIG_MIPS64 is not set
-# CONFIG_64BIT is not set
-CONFIG_MIPS32=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_STANDALONE=y
-CONFIG_BROKEN_ON_SMP=y
-
-#
-# General setup
-#
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_HOTPLUG=y
-# CONFIG_IKCONFIG is not set
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-CONFIG_MODVERSIONS=y
-CONFIG_KMOD=y
-
-#
-# Machine selection
-#
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_BAGET_MIPS is not set
-CONFIG_MACH_VR41XX=y
-# CONFIG_CASIO_E55 is not set
-# CONFIG_IBM_WORKPAD is not set
-CONFIG_NEC_EAGLE=y
-# CONFIG_TANBAC_TB0226 is not set
-# CONFIG_TANBAC_TB0229 is not set
-# CONFIG_VICTOR_MPC30X is not set
-# CONFIG_ZAO_CAPCELLA is not set
-CONFIG_VRC4173=y
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MIPS_EV64120 is not set
-# CONFIG_MIPS_EV96100 is not set
-# CONFIG_MIPS_IVR is not set
-# CONFIG_LASAT is not set
-# CONFIG_MIPS_ITE8172 is not set
-# CONFIG_MIPS_ATLAS is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_MIPS_SEAD is not set
-# CONFIG_MOMENCO_OCELOT is not set
-# CONFIG_MOMENCO_OCELOT_G is not set
-# CONFIG_MOMENCO_OCELOT_C is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_DDB5074 is not set
-# CONFIG_DDB5476 is not set
-# CONFIG_DDB5477 is not set
-# CONFIG_NEC_OSPREY is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SOC_AU1X00 is not set
-# CONFIG_SIBYTE_SB1xxx_SOC is not set
-# CONFIG_SNI_RM200_PCI is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_HAVE_DEC_LOCK=y
-CONFIG_DMA_NONCOHERENT=y
-CONFIG_CPU_LITTLE_ENDIAN=y
-CONFIG_IRQ_CPU=y
-CONFIG_DUMMY_KEYB=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-# CONFIG_FB is not set
-
-#
-# CPU selection
-#
-# CONFIG_CPU_MIPS32 is not set
-# CONFIG_CPU_MIPS64 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-CONFIG_CPU_VR41XX=y
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-# CONFIG_CPU_RM9000 is not set
-# CONFIG_CPU_SB1 is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-# CONFIG_CPU_ADVANCED is not set
-CONFIG_CPU_HAS_SYNC=y
-# CONFIG_PREEMPT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-CONFIG_PCI_NAMES=y
-CONFIG_MMU=y
-
-#
-# PCMCIA/CardBus support
-#
-CONFIG_PCMCIA=y
-# CONFIG_PCMCIA_DEBUG is not set
-# CONFIG_YENTA is not set
-# CONFIG_I82092 is not set
-# CONFIG_TCIC is not set
-# CONFIG_PCMCIA_VRC4173 is not set
-
-#
-# PCI Hotplug Support
-#
-# CONFIG_HOTPLUG_PCI is not set
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-# CONFIG_FW_LOADER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_PARTITIONS is not set
-# CONFIG_MTD_CONCAT is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-CONFIG_MTD_CFI_ADV_OPTIONS=y
-CONFIG_MTD_CFI_NOSWAP=y
-# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
-# CONFIG_MTD_CFI_GEOMETRY is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x1c000000
-CONFIG_MTD_PHYSMAP_LEN=0x2000000
-CONFIG_MTD_PHYSMAP_BUSWIDTH=4
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_DEV_FD is not set
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_LOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_CARMEL is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_LBD is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-CONFIG_IDE=y
-CONFIG_BLK_DEV_IDE=y
-
-#
-# Please see Documentation/ide.txt for help/info on IDE drives
-#
-CONFIG_BLK_DEV_IDEDISK=y
-CONFIG_IDEDISK_MULTI_MODE=y
-# CONFIG_IDEDISK_STROKE is not set
-CONFIG_BLK_DEV_IDECS=y
-# CONFIG_BLK_DEV_IDECD is not set
-# CONFIG_BLK_DEV_IDETAPE is not set
-# CONFIG_BLK_DEV_IDEFLOPPY is not set
-# CONFIG_IDE_TASK_IOCTL is not set
-CONFIG_IDE_TASKFILE_IO=y
-
-#
-# IDE chipset support/bugfixes
-#
-CONFIG_IDE_GENERIC=y
-# CONFIG_BLK_DEV_IDEPCI is not set
-# CONFIG_BLK_DEV_IDEDMA is not set
-# CONFIG_IDEDMA_AUTO is not set
-# CONFIG_BLK_DEV_HD is not set
-
-#
-# SCSI device support
-#
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Networking support
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_NETLINK_DEV=y
-CONFIG_UNIX=y
-CONFIG_NET_KEY=y
-CONFIG_INET=y
-CONFIG_IP_MULTICAST=y
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_PNP=y
-# CONFIG_IP_PNP_DHCP is not set
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_IP_MROUTE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_NET_FASTROUTE is not set
-# CONFIG_NET_HW_FLOWCONTROL is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_ETHERTAP is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-# CONFIG_MII is not set
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_NET_VENDOR_3COM is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-# CONFIG_NET_PCI is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# PCMCIA network device support
-#
-CONFIG_NET_PCMCIA=y
-# CONFIG_PCMCIA_3C589 is not set
-# CONFIG_PCMCIA_3C574 is not set
-CONFIG_PCMCIA_FMVJ18X=y
-CONFIG_PCMCIA_PCNET=m
-# CONFIG_PCMCIA_NMCLAN is not set
-# CONFIG_PCMCIA_SMC91C92 is not set
-# CONFIG_PCMCIA_XIRC2PS is not set
-# CONFIG_PCMCIA_AXNET is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_RCPCI is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input I/O drivers
-#
-# CONFIG_GAMEPORT is not set
-CONFIG_SOUND_GAMEPORT=y
-CONFIG_SERIO=y
-CONFIG_SERIO_I8042=y
-CONFIG_SERIO_SERPORT=y
-# CONFIG_SERIO_CT82C710 is not set
-# CONFIG_SERIO_PCIPS2 is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-# CONFIG_SERIAL_8250_CS is not set
-CONFIG_SERIAL_8250_NR_UARTS=4
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-# CONFIG_QIC02_TAPE is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_FTAPE is not set
-# CONFIG_AGP is not set
-# CONFIG_DRM is not set
-
-#
-# PCMCIA character devices
-#
-# CONFIG_SYNCLINK_CS is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-# CONFIG_MDA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-# CONFIG_USB is not set
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_QUOTA is not set
-CONFIG_AUTOFS_FS=y
-CONFIG_AUTOFS4_FS=y
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_FAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_SYSFS=y
-# CONFIG_DEVFS_FS is not set
-CONFIG_DEVPTS_FS_XATTR=y
-CONFIG_DEVPTS_FS_SECURITY=y
-# CONFIG_TMPFS is not set
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS_FS=y
-CONFIG_JFFS_FS_VERBOSE=0
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-# CONFIG_JFFS2_FS_NAND is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-# CONFIG_NFS_V3 is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=y
-# CONFIG_NFSD_V3 is not set
-# CONFIG_NFSD_TCP is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_EXPORTFS=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_INTERMEZZO_FS is not set
-# CONFIG_AFS_FS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Kernel hacking
-#
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-# CONFIG_DEBUG_KERNEL is not set
-
-#
-# Security options
-#
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_NULL=y
-# CONFIG_CRYPTO_MD4 is not set
-# CONFIG_CRYPTO_MD5 is not set
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-CONFIG_CRYPTO_SHA512=y
-# CONFIG_CRYPTO_DES is not set
-# CONFIG_CRYPTO_BLOWFISH is not set
-CONFIG_CRYPTO_TWOFISH=y
-# CONFIG_CRYPTO_SERPENT is not set
-CONFIG_CRYPTO_AES=y
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_ARC4 is not set
-CONFIG_CRYPTO_DEFLATE=y
-CONFIG_CRYPTO_MICHAEL_MIC=y
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Library routines
-#
-CONFIG_CRC32=y
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
+++ /dev/null
-#
-# Makefile for the Linux/MIPS-specific parts of the memory manager.
-#
-
-obj-$(CONFIG_CPU_TX49XX) += tlbex-r4k.o
-obj-$(CONFIG_CPU_R4300) += tlbex-r4k.o
-obj-$(CONFIG_CPU_R4X00) += tlbex-r4k.o
-obj-$(CONFIG_CPU_VR41XX) += tlbex-r4k.o
-obj-$(CONFIG_CPU_R5000) += tlbex-r4k.o
-obj-$(CONFIG_CPU_NEVADA) += tlbex-r4k.o
-obj-$(CONFIG_CPU_R5432) += tlbex-r4k.o
-obj-$(CONFIG_CPU_RM7000) += tlbex-r4k.o
-obj-$(CONFIG_CPU_RM9000) += tlbex-r4k.o
-obj-$(CONFIG_CPU_R10000) += tlbex-r4k.o
-obj-$(CONFIG_CPU_MIPS32) += tlbex-r4k.o
-obj-$(CONFIG_CPU_MIPS64) += tlbex-r4k.o
-obj-$(CONFIG_CPU_SB1) += tlbex-r4k.o
-
-EXTRA_AFLAGS := $(CFLAGS)
+++ /dev/null
-/*
- * TLB exception handling code for r4k.
- *
- * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
- *
- * Multi-cpu abstraction and reworking:
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- *
- * Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
- */
-#include <linux/init.h>
-#include <linux/config.h>
-
-#include <asm/asm.h>
-#include <asm/offset.h>
-#include <asm/cachectl.h>
-#include <asm/fpregdef.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/pgtable-bits.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-#define TLB_OPTIMIZE /* If you are paranoid, disable this. */
-
-#ifdef CONFIG_64BIT_PHYS_ADDR
-#define PTE_L ld
-#define PTE_S sd
-#define PTE_SRL dsrl
-#define P_MTC0 dmtc0
-#define PTE_SIZE 8
-#define PTEP_INDX_MSK 0xff0
-#define PTE_INDX_MSK 0xff8
-#define PTE_INDX_SHIFT 9
-#else
-#define PTE_L lw
-#define PTE_S sw
-#define PTE_SRL srl
-#define P_MTC0 mtc0
-#define PTE_SIZE 4
-#define PTEP_INDX_MSK 0xff8
-#define PTE_INDX_MSK 0xffc
-#define PTE_INDX_SHIFT 10
-#endif
-
-/*
- * ABUSE of CPP macros 101.
- *
- * After this macro runs, the pte faulted on is
- * in register PTE, a ptr into the table in which
- * the pte belongs is in PTR.
- */
-
-#ifdef CONFIG_SMP
-#define GET_PGD(scratch, ptr) \
- mfc0 ptr, CP0_CONTEXT; \
- la scratch, pgd_current;\
- srl ptr, 23; \
- sll ptr, 2; \
- addu ptr, scratch, ptr; \
- lw ptr, (ptr);
-#else
-#define GET_PGD(scratch, ptr) \
- lw ptr, pgd_current;
-#endif
-
-#define LOAD_PTE(pte, ptr) \
- GET_PGD(pte, ptr) \
- mfc0 pte, CP0_BADVADDR; \
- srl pte, pte, _PGDIR_SHIFT; \
- sll pte, pte, 2; \
- addu ptr, ptr, pte; \
- mfc0 pte, CP0_BADVADDR; \
- lw ptr, (ptr); \
- srl pte, pte, PTE_INDX_SHIFT; \
- and pte, pte, PTE_INDX_MSK; \
- addu ptr, ptr, pte; \
- PTE_L pte, (ptr);
-
- /* This places the even/odd pte pair in the page
- * table at PTR into ENTRYLO0 and ENTRYLO1 using
- * TMP as a scratch register.
- */
-#define PTE_RELOAD(ptr, tmp) \
- ori ptr, ptr, PTE_SIZE; \
- xori ptr, ptr, PTE_SIZE; \
- PTE_L tmp, PTE_SIZE(ptr); \
- PTE_L ptr, 0(ptr); \
- PTE_SRL tmp, tmp, 6; \
- P_MTC0 tmp, CP0_ENTRYLO1; \
- PTE_SRL ptr, ptr, 6; \
- P_MTC0 ptr, CP0_ENTRYLO0;
-
-#define DO_FAULT(write) \
- .set noat; \
- SAVE_ALL; \
- mfc0 a2, CP0_BADVADDR; \
- KMODE; \
- .set at; \
- move a0, sp; \
- jal do_page_fault; \
- li a1, write; \
- j ret_from_exception; \
- nop; \
- .set noat;
-
- /* Check is PTE is present, if not then jump to LABEL.
- * PTR points to the page table where this PTE is located,
- * when the macro is done executing PTE will be restored
- * with it's original value.
- */
-#define PTE_PRESENT(pte, ptr, label) \
- andi pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
- xori pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
- bnez pte, label; \
- PTE_L pte, (ptr);
-
- /* Make PTE valid, store result in PTR. */
-#define PTE_MAKEVALID(pte, ptr) \
- ori pte, pte, (_PAGE_VALID | _PAGE_ACCESSED); \
- PTE_S pte, (ptr);
-
- /* Check if PTE can be written to, if not branch to LABEL.
- * Regardless restore PTE with value from PTR when done.
- */
-#define PTE_WRITABLE(pte, ptr, label) \
- andi pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
- xori pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
- bnez pte, label; \
- PTE_L pte, (ptr);
-
- /* Make PTE writable, update software status bits as well,
- * then store at PTR.
- */
-#define PTE_MAKEWRITE(pte, ptr) \
- ori pte, pte, (_PAGE_ACCESSED | _PAGE_MODIFIED | \
- _PAGE_VALID | _PAGE_DIRTY); \
- PTE_S pte, (ptr);
-
- __INIT
-
-#ifdef CONFIG_64BIT_PHYS_ADDR
-#define GET_PTE_OFF(reg)
-#elif CONFIG_CPU_VR41XX
-#define GET_PTE_OFF(reg) srl reg, reg, 3
-#else
-#define GET_PTE_OFF(reg) srl reg, reg, 1
-#endif
-
-/*
- * These handlers much be written in a relocatable manner
- * because based upon the cpu type an arbitrary one of the
- * following pieces of code will be copied to the KSEG0
- * vector location.
- */
- /* TLB refill, EXL == 0, R4xx0, non-R4600 version */
- .set noreorder
- .set noat
- LEAF(except_vec0_r4000)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR # Get faulting address
- srl k0, k0, _PGDIR_SHIFT # get pgd only bits
-
- sll k0, k0, 2
- addu k1, k1, k0 # add in pgd offset
- mfc0 k0, CP0_CONTEXT # get context reg
- lw k1, (k1)
- GET_PTE_OFF(k0) # get pte offset
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0 # add in offset
- PTE_L k0, 0(k1) # get even pte
- PTE_L k1, PTE_SIZE(k1) # get odd pte
- PTE_SRL k0, k0, 6 # convert to entrylo0
- P_MTC0 k0, CP0_ENTRYLO0 # load it
- PTE_SRL k1, k1, 6 # convert to entrylo1
- P_MTC0 k1, CP0_ENTRYLO1 # load it
- mtc0_tlbw_hazard
- tlbwr # write random tlb entry
- tlbw_eret_hazard
- eret # return from trap
- END(except_vec0_r4000)
-
- /* TLB refill, EXL == 0, R4600 version */
- LEAF(except_vec0_r4600)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR
- srl k0, k0, _PGDIR_SHIFT
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
- GET_PTE_OFF(k0) # get pte offset
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0
- PTE_L k0, 0(k1)
- PTE_L k1, PTE_SIZE(k1)
- PTE_SRL k0, k0, 6
- P_MTC0 k0, CP0_ENTRYLO0
- PTE_SRL k1, k1, 6
- P_MTC0 k1, CP0_ENTRYLO1
- nop
- tlbwr
- nop
- eret
- END(except_vec0_r4600)
-
- /* TLB refill, EXL == 0, R52x0 "Nevada" version */
- /*
- * This version has a bug workaround for the Nevada. It seems
- * as if under certain circumstances the move from cp0_context
- * might produce a bogus result when the mfc0 instruction and
- * it's consumer are in a different cacheline or a load instruction,
- * probably any memory reference, is between them. This is
- * potencially slower than the R4000 version, so we use this
- * special version.
- */
- .set noreorder
- .set noat
- LEAF(except_vec0_nevada)
- .set mips3
- mfc0 k0, CP0_BADVADDR # Get faulting address
- srl k0, k0, _PGDIR_SHIFT # get pgd only bits
- lw k1, pgd_current # get pgd pointer
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0 # add in pgd offset
- lw k1, (k1)
- mfc0 k0, CP0_CONTEXT # get context reg
- GET_PTE_OFF(k0) # get pte offset
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0 # add in offset
- PTE_L k0, 0(k1) # get even pte
- PTE_L k1, PTE_SIZE(k1) # get odd pte
- PTE_SRL k0, k0, 6 # convert to entrylo0
- P_MTC0 k0, CP0_ENTRYLO0 # load it
- PTE_SRL k1, k1, 6 # convert to entrylo1
- P_MTC0 k1, CP0_ENTRYLO1 # load it
- nop # QED specified nops
- nop
- tlbwr # write random tlb entry
- nop # traditional nop
- eret # return from trap
- END(except_vec0_nevada)
-
- /* TLB refill, EXL == 0, SB1 with M3 errata handling version */
- LEAF(except_vec0_sb1)
-#if BCM1250_M3_WAR
- mfc0 k0, CP0_BADVADDR
- mfc0 k1, CP0_ENTRYHI
- xor k0, k1
- srl k0, k0, PAGE_SHIFT+1
- bnez k0, 1f
-#endif
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR # Get faulting address
- srl k0, k0, _PGDIR_SHIFT # get pgd only bits
- sll k0, k0, 2
- addu k1, k1, k0 # add in pgd offset
- mfc0 k0, CP0_CONTEXT # get context reg
- lw k1, (k1)
- GET_PTE_OFF(k0) # get pte offset
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0 # add in offset
- PTE_L k0, 0(k1) # get even pte
- PTE_L k1, PTE_SIZE(k1) # get odd pte
- PTE_SRL k0, k0, 6 # convert to entrylo0
- P_MTC0 k0, CP0_ENTRYLO0 # load it
- PTE_SRL k1, k1, 6 # convert to entrylo1
- P_MTC0 k1, CP0_ENTRYLO1 # load it
- tlbwr # write random tlb entry
-1: eret # return from trap
- END(except_vec0_sb1)
-
- /* TLB refill, EXL == 0, R4[40]00/R5000 badvaddr hwbug version */
- LEAF(except_vec0_r45k_bvahwbug)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR
- srl k0, k0, _PGDIR_SHIFT
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
- srl k0, k0, 1
-#endif
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0
- PTE_L k0, 0(k1)
- PTE_L k1, PTE_SIZE(k1)
- nop /* XXX */
- tlbp
- PTE_SRL k0, k0, 6
- P_MTC0 k0, CP0_ENTRYLO0
- PTE_SRL k1, k1, 6
- mfc0 k0, CP0_INDEX
- P_MTC0 k1, CP0_ENTRYLO1
- bltzl k0, 1f
- tlbwr
-1:
- nop
- eret
- END(except_vec0_r45k_bvahwbug)
-
-#ifdef CONFIG_SMP
- /* TLB refill, EXL == 0, R4000 MP badvaddr hwbug version */
- LEAF(except_vec0_r4k_mphwbug)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR
- srl k0, k0, _PGDIR_SHIFT
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
- srl k0, k0, 1
-#endif
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0
- PTE_L k0, 0(k1)
- PTE_L k1, PTE_SIZE(k1)
- nop /* XXX */
- tlbp
- PTE_SRL k0, k0, 6
- P_MTC0 k0, CP0_ENTRYLO0
- PTE_SRL k1, k1, 6
- mfc0 k0, CP0_INDEX
- P_MTC0 k1, CP0_ENTRYLO1
- bltzl k0, 1f
- tlbwr
-1:
- nop
- eret
- END(except_vec0_r4k_mphwbug)
-#endif
-
- /* TLB refill, EXL == 0, R4000 UP 250MHZ entrylo[01] hwbug version */
- LEAF(except_vec0_r4k_250MHZhwbug)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR
- srl k0, k0, _PGDIR_SHIFT
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
- srl k0, k0, 1
-#endif
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0
- PTE_L k0, 0(k1)
- PTE_L k1, PTE_SIZE(k1)
- PTE_SRL k0, k0, 6
- P_MTC0 zero, CP0_ENTRYLO0
- P_MTC0 k0, CP0_ENTRYLO0
- PTE_SRL k1, k1, 6
- P_MTC0 zero, CP0_ENTRYLO1
- P_MTC0 k1, CP0_ENTRYLO1
- b 1f
- tlbwr
-1:
- nop
- eret
- END(except_vec0_r4k_250MHZhwbug)
-
-#ifdef CONFIG_SMP
- /* TLB refill, EXL == 0, R4000 MP 250MHZ entrylo[01]+badvaddr bug version */
- LEAF(except_vec0_r4k_MP250MHZhwbug)
- .set mips3
- GET_PGD(k0, k1) # get pgd pointer
- mfc0 k0, CP0_BADVADDR
- srl k0, k0, _PGDIR_SHIFT
- sll k0, k0, 2 # log2(sizeof(pgd_t)
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
-#ifndef CONFIG_64BIT_PHYS_ADDR
- srl k0, k0, 1
-#endif
- and k0, k0, PTEP_INDX_MSK
- addu k1, k1, k0
- PTE_L k0, 0(k1)
- PTE_L k1, PTE_SIZE(k1)
- nop /* XXX */
- tlbp
- PTE_SRL k0, k0, 6
- P_MTC0 zero, CP0_ENTRYLO0
- P_MTC0 k0, CP0_ENTRYLO0
- mfc0 k0, CP0_INDEX
- PTE_SRL k1, k1, 6
- P_MTC0 zero, CP0_ENTRYLO1
- P_MTC0 k1, CP0_ENTRYLO1
- bltzl k0, 1f
- tlbwr
-1:
- nop
- eret
- END(except_vec0_r4k_MP250MHZhwbug)
-#endif
-
- __FINIT
-
- .set noreorder
-
-/*
- * From the IDT errata for the QED RM5230 (Nevada), processor revision 1.0:
- * 2. A timing hazard exists for the TLBP instruction.
- *
- * stalling_instruction
- * TLBP
- *
- * The JTLB is being read for the TLBP throughout the stall generated by the
- * previous instruction. This is not really correct as the stalling instruction
- * can modify the address used to access the JTLB. The failure symptom is that
- * the TLBP instruction will use an address created for the stalling instruction
- * and not the address held in C0_ENHI and thus report the wrong results.
- *
- * The software work-around is to not allow the instruction preceding the TLBP
- * to stall - make it an NOP or some other instruction guaranteed not to stall.
- *
- * Errata 2 will not be fixed. This errata is also on the R5000.
- *
- * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
- */
-#define R5K_HAZARD nop
-
- /*
- * Note for many R4k variants tlb probes cannot be executed out
- * of the instruction cache else you get bogus results.
- */
- .align 5
- NESTED(handle_tlbl, PT_SIZE, sp)
- .set noat
-#if BCM1250_M3_WAR
- mfc0 k0, CP0_BADVADDR
- mfc0 k1, CP0_ENTRYHI
- xor k0, k1
- srl k0, k0, PAGE_SHIFT+1
- beqz k0, 1f
- nop
- .set mips3
- eret
- .set mips0
-1:
-#endif
-invalid_tlbl:
-#ifdef TLB_OPTIMIZE
- .set mips3
- /* Test present bit in entry. */
- LOAD_PTE(k0, k1)
- R5K_HAZARD
- tlbp
- PTE_PRESENT(k0, k1, nopage_tlbl)
- PTE_MAKEVALID(k0, k1)
- PTE_RELOAD(k1, k0)
- mtc0_tlbw_hazard
- tlbwi
- tlbw_eret_hazard
- .set mips3
- eret
- .set mips0
-#endif
-
-nopage_tlbl:
- DO_FAULT(0)
- END(handle_tlbl)
-
- .align 5
- NESTED(handle_tlbs, PT_SIZE, sp)
- .set noat
-#ifdef TLB_OPTIMIZE
- .set mips3
- li k0,0
- LOAD_PTE(k0, k1)
- R5K_HAZARD
- tlbp # find faulting entry
- PTE_WRITABLE(k0, k1, nopage_tlbs)
- PTE_MAKEWRITE(k0, k1)
- PTE_RELOAD(k1, k0)
- mtc0_tlbw_hazard
- tlbwi
- tlbw_eret_hazard
- .set mips3
- eret
- .set mips0
-#endif
-
-nopage_tlbs:
- DO_FAULT(1)
- END(handle_tlbs)
-
- .align 5
- NESTED(handle_mod, PT_SIZE, sp)
- .set noat
-#ifdef TLB_OPTIMIZE
- .set mips3
- LOAD_PTE(k0, k1)
- R5K_HAZARD
- tlbp # find faulting entry
- andi k0, k0, _PAGE_WRITE
- beqz k0, nowrite_mod
- PTE_L k0, (k1)
-
- /* Present and writable bits set, set accessed and dirty bits. */
- PTE_MAKEWRITE(k0, k1)
-
- /* Now reload the entry into the tlb. */
- PTE_RELOAD(k1, k0)
- mtc0_tlbw_hazard
- tlbwi
- tlbw_eret_hazard
- .set mips3
- eret
- .set mips0
-#endif
-
-nowrite_mod:
- DO_FAULT(1)
- END(handle_mod)
+++ /dev/null
-#
-# Makefile for the Linux/MIPS-specific parts of the memory manager.
-#
-
-obj-y := tlbex-r4k.o
-
-obj-$(CONFIG_CPU_R4300) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R4X00) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R5000) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_NEVADA) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R5432) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_RM7000) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_RM9000) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_R10000) += tlb-glue-r4k.o
-obj-$(CONFIG_CPU_SB1) += tlb-glue-sb1.o
-obj-$(CONFIG_CPU_MIPS64) += tlb-glue-r4k.o
-
-#
-# Debug TLB exception handler, currently unused
-#
-#obj-y += tlb-dbg-r4k.o
-
-AFLAGS_tlb-glue-r4k.o := -P
-
-EXTRA_AFLAGS := $(CFLAGS)
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- *
- * TLB debugging routines. These perform horribly slow but can easily be
- * modified for debugging purposes.
- */
-#include <linux/linkage.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/ptrace.h>
-#include <asm/system.h>
-
-asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
- unsigned long address);
-
-asmlinkage void tlb_refill_debug(struct pt_regs regs)
-{
- show_regs(®s);
- panic("%s called. This Does Not Happen (TM).", __FUNCTION__);
-}
-
-asmlinkage void xtlb_refill_debug(struct pt_regs *regs)
-{
- unsigned long addr;
- pgd_t *pgd;
- pmd_t *pmd;
- pte_t *pte;
-
- addr = regs->cp0_badvaddr & ~((PAGE_SIZE << 1) - 1);
- pgd = pgd_offset(current->active_mm, addr);
- pmd = pmd_offset(pgd, addr);
- pte = pte_offset(pmd, addr);
-
- write_c0_entrylo0(pte_val(pte[0]) >> 6);
- write_c0_entrylo1(pte_val(pte[1]) >> 6);
- __asm__ __volatile__("nop;nop;nop");
-
- tlb_write_random();
-}
-
-asmlinkage void xtlb_mod_debug(struct pt_regs *regs)
-{
- unsigned long addr;
-
- addr = regs->cp0_badvaddr;
- do_page_fault(regs, 1, addr);
-}
-
-asmlinkage void xtlb_tlbl_debug(struct pt_regs *regs)
-{
- unsigned long addr;
-
- addr = regs->cp0_badvaddr;
- do_page_fault(regs, 0, addr);
-}
-
-asmlinkage void xtlb_tlbs_debug(struct pt_regs *regs)
-{
- unsigned long addr;
-
- addr = regs->cp0_badvaddr;
- do_page_fault(regs, 1, addr);
-}
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#include <linux/init.h>
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
- .macro __BUILD_cli
- CLI
- .endm
-
- .macro __BUILD_sti
- STI
- .endm
-
- .macro __BUILD_kmode
- KMODE
- .endm
-
- .macro tlb_handler name interruptible writebit
- NESTED(__\name, PT_SIZE, sp)
- SAVE_ALL
- dmfc0 a2, CP0_BADVADDR
- __BUILD_\interruptible
- li a1, \writebit
- sd a2, PT_BVADDR(sp)
- move a0, sp
- jal do_page_fault
- j ret_from_exception
- END(__\name)
- .endm
-
- tlb_handler xtlb_mod kmode 1
- tlb_handler xtlb_tlbl kmode 0
- tlb_handler xtlb_tlbs kmode 1
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#include <linux/init.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
- .macro __BUILD_cli
- CLI
- .endm
-
- .macro __BUILD_sti
- STI
- .endm
-
- .macro __BUILD_kmode
- KMODE
- .endm
-
- .macro tlb_handler name interruptible writebit
- NESTED(__\name, PT_SIZE, sp)
- SAVE_ALL
- dmfc0 a2, CP0_BADVADDR
- __BUILD_\interruptible
- li a1, \writebit
- sd a2, PT_BVADDR(sp)
- move a0, sp
- jal do_page_fault
- j ret_from_exception
- END(__\name)
- .endm
-
- .macro tlb_handler_m3 name interruptible writebit
- NESTED(__\name, PT_SIZE, sp)
- dmfc0 k0, CP0_BADVADDR
- dmfc0 k1, CP0_ENTRYHI
- xor k0, k1
- dsrl k0, k0, PAGE_SHIFT + 1
- bnez k0, 1f
- SAVE_ALL
- dmfc0 a2, CP0_BADVADDR
- __BUILD_\interruptible
- li a1, \writebit
- sd a2, PT_BVADDR(sp)
- move a0, sp
- jal do_page_fault
-1:
- j ret_from_exception
- END(__\name)
- .endm
-
- tlb_handler xtlb_mod kmode 1
-#if BCM1250_M3_WAR
- tlb_handler_m3 xtlb_tlbl kmode 0
-#else
- tlb_handler xtlb_tlbl kmode 0
-#endif
- tlb_handler xtlb_tlbs kmode 1
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2000 Silicon Graphics, Inc.
- * Written by Ulf Carlsson (ulfc@engr.sgi.com)
- * Copyright (C) 2002 Maciej W. Rozycki
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/threads.h>
-
-#include <asm/asm.h>
-#include <asm/hazards.h>
-#include <asm/regdef.h>
-#include <asm/mipsregs.h>
-#include <asm/stackframe.h>
-#include <asm/war.h>
-
-#define _VMALLOC_START 0xc000000000000000
-
- /*
- * After this macro runs we have a pointer to the pte of the address
- * that caused the fault in PTR.
- */
- .macro LOAD_PTE2, ptr, tmp, kaddr
-#ifdef CONFIG_SMP
- dmfc0 \ptr, CP0_CONTEXT
- dmfc0 \tmp, CP0_BADVADDR
- dsra \ptr, 23 # get pgd_current[cpu]
-#else
- dmfc0 \tmp, CP0_BADVADDR
- dla \ptr, pgd_current
-#endif
- bltz \tmp, \kaddr
- ld \ptr, (\ptr)
- dsrl \tmp, (_PGDIR_SHIFT-3) # get pgd offset in bytes
- andi \tmp, ((_PTRS_PER_PGD - 1)<<3)
- daddu \ptr, \tmp # add in pgd offset
- dmfc0 \tmp, CP0_BADVADDR
- ld \ptr, (\ptr) # get pmd pointer
- dsrl \tmp, (_PMD_SHIFT-3) # get pmd offset in bytes
- andi \tmp, ((_PTRS_PER_PMD - 1)<<3)
- daddu \ptr, \tmp # add in pmd offset
- dmfc0 \tmp, CP0_XCONTEXT
- ld \ptr, (\ptr) # get pte pointer
- andi \tmp, 0xff0 # get pte offset
- daddu \ptr, \tmp
- .endm
-
-
- /*
- * Ditto for the kernel table.
- */
- .macro LOAD_KPTE2, ptr, tmp, not_vmalloc
- /*
- * First, determine that the address is in/above vmalloc range.
- */
- dmfc0 \tmp, CP0_BADVADDR
- dli \ptr, _VMALLOC_START
-
- /*
- * Now find offset into kptbl.
- */
- dsubu \tmp, \tmp, \ptr
- dla \ptr, kptbl
- dsrl \tmp, (_PAGE_SHIFT+1) # get vpn2
- dsll \tmp, 4 # byte offset of pte
- daddu \ptr, \ptr, \tmp
-
- /*
- * Determine that fault address is within vmalloc range.
- */
- dla \tmp, ekptbl
- slt \tmp, \ptr, \tmp
- beqz \tmp, \not_vmalloc # not vmalloc
- nop
- .endm
-
-
- /*
- * This places the even/odd pte pair in the page table at the pte
- * entry pointed to by PTE into ENTRYLO0 and ENTRYLO1.
- */
- .macro PTE_RELOAD, pte0, pte1
- dsrl \pte0, 6 # convert to entrylo0
- dmtc0 \pte0, CP0_ENTRYLO0 # load it
- dsrl \pte1, 6 # convert to entrylo1
- dmtc0 \pte1, CP0_ENTRYLO1 # load it
- .endm
-
-
- .text
- .set noreorder
- .set mips3
-
- __INIT
-
- /*
- * TLB refill handlers for the R4000 and SB1.
- * Attention: We may only use 32 instructions / 128 bytes.
- */
- .align 5
-LEAF(except_vec1_r4k)
- .set noat
- dla k0, handle_vec1_r4k
- jr k0
- nop
-END(except_vec1_r4k)
-
-LEAF(except_vec1_sb1)
-#if BCM1250_M3_WAR
- dmfc0 k0, CP0_BADVADDR
- dmfc0 k1, CP0_ENTRYHI
- xor k0, k1
- dsrl k0, k0, _PAGE_SHIFT+1
- bnez k0, 1f
-#endif
- .set noat
- dla k0, handle_vec1_r4k
- jr k0
- nop
-
-1: eret
- nop
-END(except_vec1_sb1)
-
- __FINIT
-
- .align 5
-LEAF(handle_vec1_r4k)
- .set noat
- LOAD_PTE2 k1 k0 9f
- ld k0, 0(k1) # get even pte
- ld k1, 8(k1) # get odd pte
- PTE_RELOAD k0 k1
- mtc0_tlbw_hazard
- tlbwr
- tlbw_eret_hazard
- eret
-
-9: # handle the vmalloc range
- LOAD_KPTE2 k1 k0 invalid_vmalloc_address
- ld k0, 0(k1) # get even pte
- ld k1, 8(k1) # get odd pte
- PTE_RELOAD k0 k1
- mtc0_tlbw_hazard
- tlbwr
- tlbw_eret_hazard
- eret
-END(handle_vec1_r4k)
-
-
- __INIT
-
- /*
- * TLB refill handler for the R10000.
- * Attention: We may only use 32 instructions / 128 bytes.
- */
- .align 5
-LEAF(except_vec1_r10k)
- .set noat
- dla k0, handle_vec1_r10k
- jr k0
- nop
-END(except_vec1_r10k)
-
- __FINIT
-
- .align 5
-LEAF(handle_vec1_r10k)
- .set noat
- LOAD_PTE2 k1 k0 9f
- ld k0, 0(k1) # get even pte
- ld k1, 8(k1) # get odd pte
- PTE_RELOAD k0 k1
- nop
- tlbwr
- eret
-
-9: # handle the vmalloc range
- LOAD_KPTE2 k1 k0 invalid_vmalloc_address
- ld k0, 0(k1) # get even pte
- ld k1, 8(k1) # get odd pte
- PTE_RELOAD k0 k1
- nop
- tlbwr
- eret
-END(handle_vec1_r10k)
-
-
- .align 5
-LEAF(invalid_vmalloc_address)
- .set noat
- SAVE_ALL
- CLI
- dmfc0 t0, CP0_BADVADDR
- sd t0, PT_BVADDR(sp)
- move a0, sp
- jal show_regs
- PANIC("Invalid kernel address")
-END(invalid_vmalloc_address)
+++ /dev/null
-/*
- * TLB exception handling code for R2000/R3000.
- *
- * Copyright (C) 1994, 1995, 1996 by Ralf Baechle and Andreas Busse
- *
- * Multi-CPU abstraction reworking:
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- *
- * Further modifications to make this work:
- * Copyright (c) 1998 Harald Koerfgen
- * Copyright (c) 1998, 1999 Gleb Raiko & Vladimir Roganov
- * Copyright (c) 2001 Ralf Baechle
- * Copyright (c) 2001 MIPS Technologies, Inc.
- */
-#include <linux/init.h>
-#include <asm/asm.h>
-#include <asm/cachectl.h>
-#include <asm/fpregdef.h>
-#include <asm/mipsregs.h>
-#include <asm/page.h>
-#include <asm/pgtable-bits.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
-#define TLB_OPTIMIZE /* If you are paranoid, disable this. */
-
- .text
- .set mips1
- .set noreorder
-
- __INIT
-
- /* TLB refill, R[23]00 version */
- LEAF(except_vec0_r2300)
- .set noat
- .set mips1
- mfc0 k0, CP0_BADVADDR
- lw k1, pgd_current # get pgd pointer
- srl k0, k0, 22
- sll k0, k0, 2
- addu k1, k1, k0
- mfc0 k0, CP0_CONTEXT
- lw k1, (k1)
- and k0, k0, 0xffc
- addu k1, k1, k0
- lw k0, (k1)
- nop
- mtc0 k0, CP0_ENTRYLO0
- mfc0 k1, CP0_EPC
- tlbwr
- jr k1
- rfe
- END(except_vec0_r2300)
-
- __FINIT
-
- /* ABUSE of CPP macros 101. */
-
- /* After this macro runs, the pte faulted on is
- * in register PTE, a ptr into the table in which
- * the pte belongs is in PTR.
- */
-#define LOAD_PTE(pte, ptr) \
- mfc0 pte, CP0_BADVADDR; \
- lw ptr, pgd_current; \
- srl pte, pte, 22; \
- sll pte, pte, 2; \
- addu ptr, ptr, pte; \
- mfc0 pte, CP0_CONTEXT; \
- lw ptr, (ptr); \
- andi pte, pte, 0xffc; \
- addu ptr, ptr, pte; \
- lw pte, (ptr); \
- nop;
-
- /* This places the even/odd pte pair in the page
- * table at PTR into ENTRYLO0 and ENTRYLO1 using
- * TMP as a scratch register.
- */
-#define PTE_RELOAD(ptr) \
- lw ptr, (ptr) ; \
- nop ; \
- mtc0 ptr, CP0_ENTRYLO0; \
- nop;
-
-#define DO_FAULT(write) \
- .set noat; \
- .set macro; \
- SAVE_ALL; \
- mfc0 a2, CP0_BADVADDR; \
- KMODE; \
- .set at; \
- move a0, sp; \
- jal do_page_fault; \
- li a1, write; \
- j ret_from_exception; \
- nop; \
- .set noat; \
- .set nomacro;
-
- /* Check is PTE is present, if not then jump to LABEL.
- * PTR points to the page table where this PTE is located,
- * when the macro is done executing PTE will be restored
- * with it's original value.
- */
-#define PTE_PRESENT(pte, ptr, label) \
- andi pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
- xori pte, pte, (_PAGE_PRESENT | _PAGE_READ); \
- bnez pte, label; \
- .set push; \
- .set reorder; \
- lw pte, (ptr); \
- .set pop;
-
- /* Make PTE valid, store result in PTR. */
-#define PTE_MAKEVALID(pte, ptr) \
- ori pte, pte, (_PAGE_VALID | _PAGE_ACCESSED); \
- sw pte, (ptr);
-
- /* Check if PTE can be written to, if not branch to LABEL.
- * Regardless restore PTE with value from PTR when done.
- */
-#define PTE_WRITABLE(pte, ptr, label) \
- andi pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
- xori pte, pte, (_PAGE_PRESENT | _PAGE_WRITE); \
- bnez pte, label; \
- .set push; \
- .set reorder; \
- lw pte, (ptr); \
- .set pop;
-
-
- /* Make PTE writable, update software status bits as well,
- * then store at PTR.
- */
-#define PTE_MAKEWRITE(pte, ptr) \
- ori pte, pte, (_PAGE_ACCESSED | _PAGE_MODIFIED | \
- _PAGE_VALID | _PAGE_DIRTY); \
- sw pte, (ptr);
-
-/*
- * The index register may have the probe fail bit set,
- * because we would trap on access kseg2, i.e. without refill.
- */
-#define TLB_WRITE(reg) \
- mfc0 reg, CP0_INDEX; \
- nop; \
- bltz reg, 1f; \
- nop; \
- tlbwi; \
- j 2f; \
- nop; \
-1: tlbwr; \
-2:
-
-#define RET(reg) \
- mfc0 reg, CP0_EPC; \
- nop; \
- jr reg; \
- rfe
-
- .set noreorder
-
- .align 5
-NESTED(handle_tlbl, PT_SIZE, sp)
- .set noat
-
-#ifdef TLB_OPTIMIZE
- /* Test present bit in entry. */
- LOAD_PTE(k0, k1)
- tlbp
- PTE_PRESENT(k0, k1, nopage_tlbl)
- PTE_MAKEVALID(k0, k1)
- PTE_RELOAD(k1)
- TLB_WRITE(k0)
- RET(k0)
-nopage_tlbl:
-#endif
-
- DO_FAULT(0)
-END(handle_tlbl)
-
-NESTED(handle_tlbs, PT_SIZE, sp)
- .set noat
-
-#ifdef TLB_OPTIMIZE
- LOAD_PTE(k0, k1)
- tlbp # find faulting entry
- PTE_WRITABLE(k0, k1, nopage_tlbs)
- PTE_MAKEWRITE(k0, k1)
- PTE_RELOAD(k1)
- TLB_WRITE(k0)
- RET(k0)
-nopage_tlbs:
-#endif
-
- DO_FAULT(1)
-END(handle_tlbs)
-
- .align 5
-NESTED(handle_mod, PT_SIZE, sp)
- .set noat
-#ifdef TLB_OPTIMIZE
- LOAD_PTE(k0, k1)
- tlbp # find faulting entry
- andi k0, k0, _PAGE_WRITE
- beqz k0, nowrite_mod
- .set push
- .set reorder
- lw k0, (k1)
- .set pop
-
- /* Present and writable bits set, set accessed and dirty bits. */
- PTE_MAKEWRITE(k0, k1)
-
- /* Now reload the entry into the tlb. */
- PTE_RELOAD(k1)
- tlbwi
- RET(k0)
-#endif
-
-nowrite_mod:
- DO_FAULT(1)
-END(handle_mod)
+++ /dev/null
-/*
- * Copyright 2002 Momentum Computer Inc.
- * Author: Matthew Dharm <mdharm@momenco.com>
- *
- * Based on work for the Linux port to the Ocelot board, which is
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/momentum/ocelot_g/pci.c
- * Board-specific PCI routines for mv64340 controller.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/pci.h>
-
-
-void __init mv64340_board_pcibios_fixup_bus(struct pci_bus *bus)
-{
- struct pci_bus *current_bus = bus;
- struct pci_dev *devices;
- struct list_head *devices_link;
- u16 cmd;
-
- /* loop over all known devices on this bus */
- list_for_each(devices_link, &(current_bus->devices)) {
-
- devices = pci_dev_b(devices_link);
- if (devices == NULL)
- continue;
-
- if ((current_bus->number == 0) &&
- (PCI_SLOT(devices->devfn) == 1) &&
- (PCI_FUNC(devices->devfn) == 0)) {
- /* LSI 53C10101R SCSI (A) */
- devices->irq = 2;
- } else if ((current_bus->number == 0) &&
- (PCI_SLOT(devices->devfn) == 1) &&
- (PCI_FUNC(devices->devfn) == 1)) {
- /* LSI 53C10101R SCSI (B) */
- devices->irq = 2;
- } else if ((current_bus->number == 1) &&
- (PCI_SLOT(devices->devfn) == 1)) {
- /* Intel 21555 bridge */
- devices->irq = 12;
- } else if ((current_bus->number == 1) &&
- (PCI_SLOT(devices->devfn) == 2)) {
- /* PMC Slot */
- devices->irq = 4;
- } else {
- /* We don't have assign interrupts for other devices. */
- devices->irq = 0xff;
- }
-
- /* Assign an interrupt number for the device */
- bus->ops->write_byte(devices, PCI_INTERRUPT_LINE, devices->irq);
-
- /* enable master for everything but the MV-64340 */
- if (((current_bus->number != 0) && (current_bus->number != 1))
- || (PCI_SLOT(devices->devfn) != 0)) {
- bus->ops->read_word(devices, PCI_COMMAND, &cmd);
- cmd |= PCI_COMMAND_MASTER;
- bus->ops->write_word(devices, PCI_COMMAND, cmd);
- }
- }
-}
+++ /dev/null
-/* gt64240r.h - GT-64240 Internal registers definition file */
-
-/* Copyright - Galileo technology. */
-
-#ifndef __INCgt64240rh
-#define __INCgt64240rh
-
-#define GTREG(v) (((v) & 0xff) << 24) | (((v) & 0xff00) << 8) | \
- (((v) >> 24) & 0xff) | (((v) >> 8) & 0xff00)
-
-#if 0
-#define GTREG_SHORT(X) (((X) << 8) | ((X) >> 8))
-
-#define LONG_GTREG(X) ((l64) \
- (((X)&0x00000000000000ffULL) << 56) | \
- (((X)&0x000000000000ff00ULL) << 40) | \
- (((X)&0x0000000000ff0000ULL) << 24) | \
- (((X)&0x00000000ff000000ULL) << 8) | \
- (((X)&0x000000ff00000000ULL) >> 8) | \
- (((X)&0x0000ff0000000000ULL) >> 24) | \
- (((X)&0x00ff000000000000ULL) >> 40) | \
- (((X)&0xff00000000000000ULL) >> 56))
-#endif
-
-#include "gt64240_dep.h"
-
-/****************************************/
-/* CPU Control Registers */
-/****************************************/
-
-#define CPU_CONFIGURATION 0x000
-#define CPU_MODE 0x120
-#define CPU_READ_RESPONSE_CROSSBAR_LOW 0x170
-#define CPU_READ_RESPONSE_CROSSBAR_HIGH 0x178
-
-/****************************************/
-/* Processor Address Space */
-/****************************************/
-
-/* Sdram's BAR'S */
-#define SCS_0_LOW_DECODE_ADDRESS 0x008
-#define SCS_0_HIGH_DECODE_ADDRESS 0x010
-#define SCS_1_LOW_DECODE_ADDRESS 0x208
-#define SCS_1_HIGH_DECODE_ADDRESS 0x210
-#define SCS_2_LOW_DECODE_ADDRESS 0x018
-#define SCS_2_HIGH_DECODE_ADDRESS 0x020
-#define SCS_3_LOW_DECODE_ADDRESS 0x218
-#define SCS_3_HIGH_DECODE_ADDRESS 0x220
-/* Devices BAR'S */
-#define CS_0_LOW_DECODE_ADDRESS 0x028
-#define CS_0_HIGH_DECODE_ADDRESS 0x030
-#define CS_1_LOW_DECODE_ADDRESS 0x228
-#define CS_1_HIGH_DECODE_ADDRESS 0x230
-#define CS_2_LOW_DECODE_ADDRESS 0x248
-#define CS_2_HIGH_DECODE_ADDRESS 0x250
-#define CS_3_LOW_DECODE_ADDRESS 0x038
-#define CS_3_HIGH_DECODE_ADDRESS 0x040
-#define BOOTCS_LOW_DECODE_ADDRESS 0x238
-#define BOOTCS_HIGH_DECODE_ADDRESS 0x240
-
-#define PCI_0I_O_LOW_DECODE_ADDRESS 0x048
-#define PCI_0I_O_HIGH_DECODE_ADDRESS 0x050
-#define PCI_0MEMORY0_LOW_DECODE_ADDRESS 0x058
-#define PCI_0MEMORY0_HIGH_DECODE_ADDRESS 0x060
-#define PCI_0MEMORY1_LOW_DECODE_ADDRESS 0x080
-#define PCI_0MEMORY1_HIGH_DECODE_ADDRESS 0x088
-#define PCI_0MEMORY2_LOW_DECODE_ADDRESS 0x258
-#define PCI_0MEMORY2_HIGH_DECODE_ADDRESS 0x260
-#define PCI_0MEMORY3_LOW_DECODE_ADDRESS 0x280
-#define PCI_0MEMORY3_HIGH_DECODE_ADDRESS 0x288
-
-#define PCI_1I_O_LOW_DECODE_ADDRESS 0x090
-#define PCI_1I_O_HIGH_DECODE_ADDRESS 0x098
-#define PCI_1MEMORY0_LOW_DECODE_ADDRESS 0x0a0
-#define PCI_1MEMORY0_HIGH_DECODE_ADDRESS 0x0a8
-#define PCI_1MEMORY1_LOW_DECODE_ADDRESS 0x0b0
-#define PCI_1MEMORY1_HIGH_DECODE_ADDRESS 0x0b8
-#define PCI_1MEMORY2_LOW_DECODE_ADDRESS 0x2a0
-#define PCI_1MEMORY2_HIGH_DECODE_ADDRESS 0x2a8
-#define PCI_1MEMORY3_LOW_DECODE_ADDRESS 0x2b0
-#define PCI_1MEMORY3_HIGH_DECODE_ADDRESS 0x2b8
-
-#define INTERNAL_SPACE_DECODE 0x068
-
-#define CPU_0_LOW_DECODE_ADDRESS 0x290
-#define CPU_0_HIGH_DECODE_ADDRESS 0x298
-#define CPU_1_LOW_DECODE_ADDRESS 0x2c0
-#define CPU_1_HIGH_DECODE_ADDRESS 0x2c8
-
-#define PCI_0I_O_ADDRESS_REMAP 0x0f0
-#define PCI_0MEMORY0_ADDRESS_REMAP 0x0f8
-#define PCI_0MEMORY0_HIGH_ADDRESS_REMAP 0x320
-#define PCI_0MEMORY1_ADDRESS_REMAP 0x100
-#define PCI_0MEMORY1_HIGH_ADDRESS_REMAP 0x328
-#define PCI_0MEMORY2_ADDRESS_REMAP 0x2f8
-#define PCI_0MEMORY2_HIGH_ADDRESS_REMAP 0x330
-#define PCI_0MEMORY3_ADDRESS_REMAP 0x300
-#define PCI_0MEMORY3_HIGH_ADDRESS_REMAP 0x338
-
-#define PCI_1I_O_ADDRESS_REMAP 0x108
-#define PCI_1MEMORY0_ADDRESS_REMAP 0x110
-#define PCI_1MEMORY0_HIGH_ADDRESS_REMAP 0x340
-#define PCI_1MEMORY1_ADDRESS_REMAP 0x118
-#define PCI_1MEMORY1_HIGH_ADDRESS_REMAP 0x348
-#define PCI_1MEMORY2_ADDRESS_REMAP 0x310
-#define PCI_1MEMORY2_HIGH_ADDRESS_REMAP 0x350
-#define PCI_1MEMORY3_ADDRESS_REMAP 0x318
-#define PCI_1MEMORY3_HIGH_ADDRESS_REMAP 0x358
-
-/****************************************/
-/* CPU Sync Barrier */
-/****************************************/
-
-#define PCI_0SYNC_BARIER_VIRTUAL_REGISTER 0x0c0
-#define PCI_1SYNC_BARIER_VIRTUAL_REGISTER 0x0c8
-
-
-/****************************************/
-/* CPU Access Protect */
-/****************************************/
-
-#define CPU_LOW_PROTECT_ADDRESS_0 0X180
-#define CPU_HIGH_PROTECT_ADDRESS_0 0X188
-#define CPU_LOW_PROTECT_ADDRESS_1 0X190
-#define CPU_HIGH_PROTECT_ADDRESS_1 0X198
-#define CPU_LOW_PROTECT_ADDRESS_2 0X1a0
-#define CPU_HIGH_PROTECT_ADDRESS_2 0X1a8
-#define CPU_LOW_PROTECT_ADDRESS_3 0X1b0
-#define CPU_HIGH_PROTECT_ADDRESS_3 0X1b8
-#define CPU_LOW_PROTECT_ADDRESS_4 0X1c0
-#define CPU_HIGH_PROTECT_ADDRESS_4 0X1c8
-#define CPU_LOW_PROTECT_ADDRESS_5 0X1d0
-#define CPU_HIGH_PROTECT_ADDRESS_5 0X1d8
-#define CPU_LOW_PROTECT_ADDRESS_6 0X1e0
-#define CPU_HIGH_PROTECT_ADDRESS_6 0X1e8
-#define CPU_LOW_PROTECT_ADDRESS_7 0X1f0
-#define CPU_HIGH_PROTECT_ADDRESS_7 0X1f8
-
-
-/****************************************/
-/* Snoop Control */
-/****************************************/
-
-#define SNOOP_BASE_ADDRESS_0 0x380
-#define SNOOP_TOP_ADDRESS_0 0x388
-#define SNOOP_BASE_ADDRESS_1 0x390
-#define SNOOP_TOP_ADDRESS_1 0x398
-#define SNOOP_BASE_ADDRESS_2 0x3a0
-#define SNOOP_TOP_ADDRESS_2 0x3a8
-#define SNOOP_BASE_ADDRESS_3 0x3b0
-#define SNOOP_TOP_ADDRESS_3 0x3b8
-
-/****************************************/
-/* CPU Error Report */
-/****************************************/
-
-#define CPU_ERROR_ADDRESS_LOW 0x070
-#define CPU_ERROR_ADDRESS_HIGH 0x078
-#define CPU_ERROR_DATA_LOW 0x128
-#define CPU_ERROR_DATA_HIGH 0x130
-#define CPU_ERROR_PARITY 0x138
-#define CPU_ERROR_CAUSE 0x140
-#define CPU_ERROR_MASK 0x148
-
-/****************************************/
-/* Pslave Debug */
-/****************************************/
-
-#define X_0_ADDRESS 0x360
-#define X_0_COMMAND_ID 0x368
-#define X_1_ADDRESS 0x370
-#define X_1_COMMAND_ID 0x378
-#define WRITE_DATA_LOW 0x3c0
-#define WRITE_DATA_HIGH 0x3c8
-#define WRITE_BYTE_ENABLE 0X3e0
-#define READ_DATA_LOW 0x3d0
-#define READ_DATA_HIGH 0x3d8
-#define READ_ID 0x3e8
-
-
-/****************************************/
-/* SDRAM and Device Address Space */
-/****************************************/
-
-
-/****************************************/
-/* SDRAM Configuration */
-/****************************************/
-
-#define SDRAM_CONFIGURATION 0x448
-#define SDRAM_OPERATION_MODE 0x474
-#define SDRAM_ADDRESS_DECODE 0x47C
-#define SDRAM_TIMING_PARAMETERS 0x4b4
-#define SDRAM_UMA_CONTROL 0x4a4
-#define SDRAM_CROSS_BAR_CONTROL_LOW 0x4a8
-#define SDRAM_CROSS_BAR_CONTROL_HIGH 0x4ac
-#define SDRAM_CROSS_BAR_TIMEOUT 0x4b0
-
-
-/****************************************/
-/* SDRAM Parameters */
-/****************************************/
-
-#define SDRAM_BANK0PARAMETERS 0x44C
-#define SDRAM_BANK1PARAMETERS 0x450
-#define SDRAM_BANK2PARAMETERS 0x454
-#define SDRAM_BANK3PARAMETERS 0x458
-
-
-/****************************************/
-/* SDRAM Error Report */
-/****************************************/
-
-#define SDRAM_ERROR_DATA_LOW 0x484
-#define SDRAM_ERROR_DATA_HIGH 0x480
-#define SDRAM_AND_DEVICE_ERROR_ADDRESS 0x490
-#define SDRAM_RECEIVED_ECC 0x488
-#define SDRAM_CALCULATED_ECC 0x48c
-#define SDRAM_ECC_CONTROL 0x494
-#define SDRAM_ECC_ERROR_COUNTER 0x498
-
-
-/****************************************/
-/* SDunit Debug (for internal use) */
-/****************************************/
-
-#define X0_ADDRESS 0x500
-#define X0_COMMAND_AND_ID 0x504
-#define X0_WRITE_DATA_LOW 0x508
-#define X0_WRITE_DATA_HIGH 0x50c
-#define X0_WRITE_BYTE_ENABLE 0x518
-#define X0_READ_DATA_LOW 0x510
-#define X0_READ_DATA_HIGH 0x514
-#define X0_READ_ID 0x51c
-#define X1_ADDRESS 0x520
-#define X1_COMMAND_AND_ID 0x524
-#define X1_WRITE_DATA_LOW 0x528
-#define X1_WRITE_DATA_HIGH 0x52c
-#define X1_WRITE_BYTE_ENABLE 0x538
-#define X1_READ_DATA_LOW 0x530
-#define X1_READ_DATA_HIGH 0x534
-#define X1_READ_ID 0x53c
-#define X0_SNOOP_ADDRESS 0x540
-#define X0_SNOOP_COMMAND 0x544
-#define X1_SNOOP_ADDRESS 0x548
-#define X1_SNOOP_COMMAND 0x54c
-
-
-/****************************************/
-/* Device Parameters */
-/****************************************/
-
-#define DEVICE_BANK0PARAMETERS 0x45c
-#define DEVICE_BANK1PARAMETERS 0x460
-#define DEVICE_BANK2PARAMETERS 0x464
-#define DEVICE_BANK3PARAMETERS 0x468
-#define DEVICE_BOOT_BANK_PARAMETERS 0x46c
-#define DEVICE_CONTROL 0x4c0
-#define DEVICE_CROSS_BAR_CONTROL_LOW 0x4c8
-#define DEVICE_CROSS_BAR_CONTROL_HIGH 0x4cc
-#define DEVICE_CROSS_BAR_TIMEOUT 0x4c4
-
-
-/****************************************/
-/* Device Interrupt */
-/****************************************/
-
-#define DEVICE_INTERRUPT_CAUSE 0x4d0
-#define DEVICE_INTERRUPT_MASK 0x4d4
-#define DEVICE_ERROR_ADDRESS 0x4d8
-
-/****************************************/
-/* DMA Record */
-/****************************************/
-
-#define CHANNEL0_DMA_BYTE_COUNT 0x800
-#define CHANNEL1_DMA_BYTE_COUNT 0x804
-#define CHANNEL2_DMA_BYTE_COUNT 0x808
-#define CHANNEL3_DMA_BYTE_COUNT 0x80C
-#define CHANNEL4_DMA_BYTE_COUNT 0x900
-#define CHANNEL5_DMA_BYTE_COUNT 0x904
-#define CHANNEL6_DMA_BYTE_COUNT 0x908
-#define CHANNEL7_DMA_BYTE_COUNT 0x90C
-#define CHANNEL0_DMA_SOURCE_ADDRESS 0x810
-#define CHANNEL1_DMA_SOURCE_ADDRESS 0x814
-#define CHANNEL2_DMA_SOURCE_ADDRESS 0x818
-#define CHANNEL3_DMA_SOURCE_ADDRESS 0x81C
-#define CHANNEL4_DMA_SOURCE_ADDRESS 0x910
-#define CHANNEL5_DMA_SOURCE_ADDRESS 0x914
-#define CHANNEL6_DMA_SOURCE_ADDRESS 0x918
-#define CHANNEL7_DMA_SOURCE_ADDRESS 0x91C
-#define CHANNEL0_DMA_DESTINATION_ADDRESS 0x820
-#define CHANNEL1_DMA_DESTINATION_ADDRESS 0x824
-#define CHANNEL2_DMA_DESTINATION_ADDRESS 0x828
-#define CHANNEL3_DMA_DESTINATION_ADDRESS 0x82C
-#define CHANNEL4_DMA_DESTINATION_ADDRESS 0x920
-#define CHANNEL5_DMA_DESTINATION_ADDRESS 0x924
-#define CHANNEL6_DMA_DESTINATION_ADDRESS 0x928
-#define CHANNEL7_DMA_DESTINATION_ADDRESS 0x92C
-#define CHANNEL0NEXT_RECORD_POINTER 0x830
-#define CHANNEL1NEXT_RECORD_POINTER 0x834
-#define CHANNEL2NEXT_RECORD_POINTER 0x838
-#define CHANNEL3NEXT_RECORD_POINTER 0x83C
-#define CHANNEL4NEXT_RECORD_POINTER 0x930
-#define CHANNEL5NEXT_RECORD_POINTER 0x934
-#define CHANNEL6NEXT_RECORD_POINTER 0x938
-#define CHANNEL7NEXT_RECORD_POINTER 0x93C
-#define CHANNEL0CURRENT_DESCRIPTOR_POINTER 0x870
-#define CHANNEL1CURRENT_DESCRIPTOR_POINTER 0x874
-#define CHANNEL2CURRENT_DESCRIPTOR_POINTER 0x878
-#define CHANNEL3CURRENT_DESCRIPTOR_POINTER 0x87C
-#define CHANNEL4CURRENT_DESCRIPTOR_POINTER 0x970
-#define CHANNEL5CURRENT_DESCRIPTOR_POINTER 0x974
-#define CHANNEL6CURRENT_DESCRIPTOR_POINTER 0x978
-#define CHANNEL7CURRENT_DESCRIPTOR_POINTER 0x97C
-#define CHANNEL0_DMA_SOURCE_HIGH_PCI_ADDRESS 0x890
-#define CHANNEL1_DMA_SOURCE_HIGH_PCI_ADDRESS 0x894
-#define CHANNEL2_DMA_SOURCE_HIGH_PCI_ADDRESS 0x898
-#define CHANNEL3_DMA_SOURCE_HIGH_PCI_ADDRESS 0x89c
-#define CHANNEL4_DMA_SOURCE_HIGH_PCI_ADDRESS 0x990
-#define CHANNEL5_DMA_SOURCE_HIGH_PCI_ADDRESS 0x994
-#define CHANNEL6_DMA_SOURCE_HIGH_PCI_ADDRESS 0x998
-#define CHANNEL7_DMA_SOURCE_HIGH_PCI_ADDRESS 0x99c
-#define CHANNEL0_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x8a0
-#define CHANNEL1_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x8a4
-#define CHANNEL2_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x8a8
-#define CHANNEL3_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x8ac
-#define CHANNEL4_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x9a0
-#define CHANNEL5_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x9a4
-#define CHANNEL6_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x9a8
-#define CHANNEL7_DMA_DESTINATION_HIGH_PCI_ADDRESS 0x9ac
-#define CHANNEL0_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x8b0
-#define CHANNEL1_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x8b4
-#define CHANNEL2_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x8b8
-#define CHANNEL3_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x8bc
-#define CHANNEL4_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x9b0
-#define CHANNEL5_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x9b4
-#define CHANNEL6_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x9b8
-#define CHANNEL7_DMA_NEXT_RECORD_POINTER_HIGH_PCI_ADDRESS 0x9bc
-
-/****************************************/
-/* DMA Channel Control */
-/****************************************/
-
-#define CHANNEL0CONTROL 0x840
-#define CHANNEL0CONTROL_HIGH 0x880
-
-#define CHANNEL1CONTROL 0x844
-#define CHANNEL1CONTROL_HIGH 0x884
-
-#define CHANNEL2CONTROL 0x848
-#define CHANNEL2CONTROL_HIGH 0x888
-
-#define CHANNEL3CONTROL 0x84C
-#define CHANNEL3CONTROL_HIGH 0x88C
-
-#define CHANNEL4CONTROL 0x940
-#define CHANNEL4CONTROL_HIGH 0x980
-
-#define CHANNEL5CONTROL 0x944
-#define CHANNEL5CONTROL_HIGH 0x984
-
-#define CHANNEL6CONTROL 0x948
-#define CHANNEL6CONTROL_HIGH 0x988
-
-#define CHANNEL7CONTROL 0x94C
-#define CHANNEL7CONTROL_HIGH 0x98C
-
-
-/****************************************/
-/* DMA Arbiter */
-/****************************************/
-
-#define ARBITER_CONTROL_0_3 0x860
-#define ARBITER_CONTROL_4_7 0x960
-
-
-/****************************************/
-/* DMA Interrupt */
-/****************************************/
-
-#define CHANELS0_3_INTERRUPT_CAUSE 0x8c0
-#define CHANELS0_3_INTERRUPT_MASK 0x8c4
-#define CHANELS0_3_ERROR_ADDRESS 0x8c8
-#define CHANELS0_3_ERROR_SELECT 0x8cc
-#define CHANELS4_7_INTERRUPT_CAUSE 0x9c0
-#define CHANELS4_7_INTERRUPT_MASK 0x9c4
-#define CHANELS4_7_ERROR_ADDRESS 0x9c8
-#define CHANELS4_7_ERROR_SELECT 0x9cc
-
-
-/****************************************/
-/* DMA Debug (for internal use) */
-/****************************************/
-
-#define DMA_X0_ADDRESS 0x8e0
-#define DMA_X0_COMMAND_AND_ID 0x8e4
-#define DMA_X0_WRITE_DATA_LOW 0x8e8
-#define DMA_X0_WRITE_DATA_HIGH 0x8ec
-#define DMA_X0_WRITE_BYTE_ENABLE 0x8f8
-#define DMA_X0_READ_DATA_LOW 0x8f0
-#define DMA_X0_READ_DATA_HIGH 0x8f4
-#define DMA_X0_READ_ID 0x8fc
-#define DMA_X1_ADDRESS 0x9e0
-#define DMA_X1_COMMAND_AND_ID 0x9e4
-#define DMA_X1_WRITE_DATA_LOW 0x9e8
-#define DMA_X1_WRITE_DATA_HIGH 0x9ec
-#define DMA_X1_WRITE_BYTE_ENABLE 0x9f8
-#define DMA_X1_READ_DATA_LOW 0x9f0
-#define DMA_X1_READ_DATA_HIGH 0x9f4
-#define DMA_X1_READ_ID 0x9fc
-
-/****************************************/
-/* Timer_Counter */
-/****************************************/
-
-#define TIMER_COUNTER0 0x850
-#define TIMER_COUNTER1 0x854
-#define TIMER_COUNTER2 0x858
-#define TIMER_COUNTER3 0x85C
-#define TIMER_COUNTER_0_3_CONTROL 0x864
-#define TIMER_COUNTER_0_3_INTERRUPT_CAUSE 0x868
-#define TIMER_COUNTER_0_3_INTERRUPT_MASK 0x86c
-#define TIMER_COUNTER4 0x950
-#define TIMER_COUNTER5 0x954
-#define TIMER_COUNTER6 0x958
-#define TIMER_COUNTER7 0x95C
-#define TIMER_COUNTER_4_7_CONTROL 0x964
-#define TIMER_COUNTER_4_7_INTERRUPT_CAUSE 0x968
-#define TIMER_COUNTER_4_7_INTERRUPT_MASK 0x96c
-
-/****************************************/
-/* PCI Slave Address Decoding */
-/****************************************/
-
-#define PCI_0SCS_0_BANK_SIZE 0xc08
-#define PCI_1SCS_0_BANK_SIZE 0xc88
-#define PCI_0SCS_1_BANK_SIZE 0xd08
-#define PCI_1SCS_1_BANK_SIZE 0xd88
-#define PCI_0SCS_2_BANK_SIZE 0xc0c
-#define PCI_1SCS_2_BANK_SIZE 0xc8c
-#define PCI_0SCS_3_BANK_SIZE 0xd0c
-#define PCI_1SCS_3_BANK_SIZE 0xd8c
-#define PCI_0CS_0_BANK_SIZE 0xc10
-#define PCI_1CS_0_BANK_SIZE 0xc90
-#define PCI_0CS_1_BANK_SIZE 0xd10
-#define PCI_1CS_1_BANK_SIZE 0xd90
-#define PCI_0CS_2_BANK_SIZE 0xd18
-#define PCI_1CS_2_BANK_SIZE 0xd98
-#define PCI_0CS_3_BANK_SIZE 0xc14
-#define PCI_1CS_3_BANK_SIZE 0xc94
-#define PCI_0CS_BOOT_BANK_SIZE 0xd14
-#define PCI_1CS_BOOT_BANK_SIZE 0xd94
-#define PCI_0P2P_MEM0_BAR_SIZE 0xd1c
-#define PCI_1P2P_MEM0_BAR_SIZE 0xd9c
-#define PCI_0P2P_MEM1_BAR_SIZE 0xd20
-#define PCI_1P2P_MEM1_BAR_SIZE 0xda0
-#define PCI_0P2P_I_O_BAR_SIZE 0xd24
-#define PCI_1P2P_I_O_BAR_SIZE 0xda4
-#define PCI_0CPU_BAR_SIZE 0xd28
-#define PCI_1CPU_BAR_SIZE 0xda8
-#define PCI_0DAC_SCS_0_BANK_SIZE 0xe00
-#define PCI_1DAC_SCS_0_BANK_SIZE 0xe80
-#define PCI_0DAC_SCS_1_BANK_SIZE 0xe04
-#define PCI_1DAC_SCS_1_BANK_SIZE 0xe84
-#define PCI_0DAC_SCS_2_BANK_SIZE 0xe08
-#define PCI_1DAC_SCS_2_BANK_SIZE 0xe88
-#define PCI_0DAC_SCS_3_BANK_SIZE 0xe0c
-#define PCI_1DAC_SCS_3_BANK_SIZE 0xe8c
-#define PCI_0DAC_CS_0_BANK_SIZE 0xe10
-#define PCI_1DAC_CS_0_BANK_SIZE 0xe90
-#define PCI_0DAC_CS_1_BANK_SIZE 0xe14
-#define PCI_1DAC_CS_1_BANK_SIZE 0xe94
-#define PCI_0DAC_CS_2_BANK_SIZE 0xe18
-#define PCI_1DAC_CS_2_BANK_SIZE 0xe98
-#define PCI_0DAC_CS_3_BANK_SIZE 0xe1c
-#define PCI_1DAC_CS_3_BANK_SIZE 0xe9c
-#define PCI_0DAC_BOOTCS_BANK_SIZE 0xe20
-#define PCI_1DAC_BOOTCS_BANK_SIZE 0xea0
-#define PCI_0DAC_P2P_MEM0_BAR_SIZE 0xe24
-#define PCI_1DAC_P2P_MEM0_BAR_SIZE 0xea4
-#define PCI_0DAC_P2P_MEM1_BAR_SIZE 0xe28
-#define PCI_1DAC_P2P_MEM1_BAR_SIZE 0xea8
-#define PCI_0DAC_CPU_BAR_SIZE 0xe2c
-#define PCI_1DAC_CPU_BAR_SIZE 0xeac
-#define PCI_0EXPANSION_ROM_BAR_SIZE 0xd2c
-#define PCI_1EXPANSION_ROM_BAR_SIZE 0xdac
-#define PCI_0BASE_ADDRESS_REGISTERS_ENABLE 0xc3c
-#define PCI_1BASE_ADDRESS_REGISTERS_ENABLE 0xcbc
-#define PCI_0SCS_0_BASE_ADDRESS_REMAP 0xc48
-#define PCI_1SCS_0_BASE_ADDRESS_REMAP 0xcc8
-#define PCI_0SCS_1_BASE_ADDRESS_REMAP 0xd48
-#define PCI_1SCS_1_BASE_ADDRESS_REMAP 0xdc8
-#define PCI_0SCS_2_BASE_ADDRESS_REMAP 0xc4c
-#define PCI_1SCS_2_BASE_ADDRESS_REMAP 0xccc
-#define PCI_0SCS_3_BASE_ADDRESS_REMAP 0xd4c
-#define PCI_1SCS_3_BASE_ADDRESS_REMAP 0xdcc
-#define PCI_0CS_0_BASE_ADDRESS_REMAP 0xc50
-#define PCI_1CS_0_BASE_ADDRESS_REMAP 0xcd0
-#define PCI_0CS_1_BASE_ADDRESS_REMAP 0xd50
-#define PCI_1CS_1_BASE_ADDRESS_REMAP 0xdd0
-#define PCI_0CS_2_BASE_ADDRESS_REMAP 0xd58
-#define PCI_1CS_2_BASE_ADDRESS_REMAP 0xdd8
-#define PCI_0CS_3_BASE_ADDRESS_REMAP 0xc54
-#define PCI_1CS_3_BASE_ADDRESS_REMAP 0xcd4
-#define PCI_0CS_BOOTCS_BASE_ADDRESS_REMAP 0xd54
-#define PCI_1CS_BOOTCS_BASE_ADDRESS_REMAP 0xdd4
-#define PCI_0P2P_MEM0_BASE_ADDRESS_REMAP_LOW 0xd5c
-#define PCI_1P2P_MEM0_BASE_ADDRESS_REMAP_LOW 0xddc
-#define PCI_0P2P_MEM0_BASE_ADDRESS_REMAP_HIGH 0xd60
-#define PCI_1P2P_MEM0_BASE_ADDRESS_REMAP_HIGH 0xde0
-#define PCI_0P2P_MEM1_BASE_ADDRESS_REMAP_LOW 0xd64
-#define PCI_1P2P_MEM1_BASE_ADDRESS_REMAP_LOW 0xde4
-#define PCI_0P2P_MEM1_BASE_ADDRESS_REMAP_HIGH 0xd68
-#define PCI_1P2P_MEM1_BASE_ADDRESS_REMAP_HIGH 0xde8
-#define PCI_0P2P_I_O_BASE_ADDRESS_REMAP 0xd6c
-#define PCI_1P2P_I_O_BASE_ADDRESS_REMAP 0xdec
-#define PCI_0CPU_BASE_ADDRESS_REMAP 0xd70
-#define PCI_1CPU_BASE_ADDRESS_REMAP 0xdf0
-#define PCI_0DAC_SCS_0_BASE_ADDRESS_REMAP 0xf00
-#define PCI_1DAC_SCS_0_BASE_ADDRESS_REMAP 0xff0
-#define PCI_0DAC_SCS_1_BASE_ADDRESS_REMAP 0xf04
-#define PCI_1DAC_SCS_1_BASE_ADDRESS_REMAP 0xf84
-#define PCI_0DAC_SCS_2_BASE_ADDRESS_REMAP 0xf08
-#define PCI_1DAC_SCS_2_BASE_ADDRESS_REMAP 0xf88
-#define PCI_0DAC_SCS_3_BASE_ADDRESS_REMAP 0xf0c
-#define PCI_1DAC_SCS_3_BASE_ADDRESS_REMAP 0xf8c
-#define PCI_0DAC_CS_0_BASE_ADDRESS_REMAP 0xf10
-#define PCI_1DAC_CS_0_BASE_ADDRESS_REMAP 0xf90
-#define PCI_0DAC_CS_1_BASE_ADDRESS_REMAP 0xf14
-#define PCI_1DAC_CS_1_BASE_ADDRESS_REMAP 0xf94
-#define PCI_0DAC_CS_2_BASE_ADDRESS_REMAP 0xf18
-#define PCI_1DAC_CS_2_BASE_ADDRESS_REMAP 0xf98
-#define PCI_0DAC_CS_3_BASE_ADDRESS_REMAP 0xf1c
-#define PCI_1DAC_CS_3_BASE_ADDRESS_REMAP 0xf9c
-#define PCI_0DAC_BOOTCS_BASE_ADDRESS_REMAP 0xf20
-#define PCI_1DAC_BOOTCS_BASE_ADDRESS_REMAP 0xfa0
-#define PCI_0DAC_P2P_MEM0_BASE_ADDRESS_REMAP_LOW 0xf24
-#define PCI_1DAC_P2P_MEM0_BASE_ADDRESS_REMAP_LOW 0xfa4
-#define PCI_0DAC_P2P_MEM0_BASE_ADDRESS_REMAP_HIGH 0xf28
-#define PCI_1DAC_P2P_MEM0_BASE_ADDRESS_REMAP_HIGH 0xfa8
-#define PCI_0DAC_P2P_MEM1_BASE_ADDRESS_REMAP_LOW 0xf2c
-#define PCI_1DAC_P2P_MEM1_BASE_ADDRESS_REMAP_LOW 0xfac
-#define PCI_0DAC_P2P_MEM1_BASE_ADDRESS_REMAP_HIGH 0xf30
-#define PCI_1DAC_P2P_MEM1_BASE_ADDRESS_REMAP_HIGH 0xfb0
-#define PCI_0DAC_CPU_BASE_ADDRESS_REMAP 0xf34
-#define PCI_1DAC_CPU_BASE_ADDRESS_REMAP 0xfb4
-#define PCI_0EXPANSION_ROM_BASE_ADDRESS_REMAP 0xf38
-#define PCI_1EXPANSION_ROM_BASE_ADDRESS_REMAP 0xfb8
-#define PCI_0ADDRESS_DECODE_CONTROL 0xd3c
-#define PCI_1ADDRESS_DECODE_CONTROL 0xdbc
-
-/****************************************/
-/* PCI Control */
-/****************************************/
-
-#define PCI_0COMMAND 0xc00
-#define PCI_1COMMAND 0xc80
-#define PCI_0MODE 0xd00
-#define PCI_1MODE 0xd80
-#define PCI_0TIMEOUT_RETRY 0xc04
-#define PCI_1TIMEOUT_RETRY 0xc84
-#define PCI_0READ_BUFFER_DISCARD_TIMER 0xd04
-#define PCI_1READ_BUFFER_DISCARD_TIMER 0xd84
-#define MSI_0TRIGGER_TIMER 0xc38
-#define MSI_1TRIGGER_TIMER 0xcb8
-#define PCI_0ARBITER_CONTROL 0x1d00
-#define PCI_1ARBITER_CONTROL 0x1d80
-/* changing untill here */
-#define PCI_0CROSS_BAR_CONTROL_LOW 0x1d08
-#define PCI_0CROSS_BAR_CONTROL_HIGH 0x1d0c
-#define PCI_0CROSS_BAR_TIMEOUT 0x1d04
-#define PCI_0READ_RESPONSE_CROSS_BAR_CONTROL_LOW 0x1d18
-#define PCI_0READ_RESPONSE_CROSS_BAR_CONTROL_HIGH 0x1d1c
-#define PCI_0SYNC_BARRIER_VIRTUAL_REGISTER 0x1d10
-#define PCI_0P2P_CONFIGURATION 0x1d14
-#define PCI_0ACCESS_CONTROL_BASE_0_LOW 0x1e00
-#define PCI_0ACCESS_CONTROL_BASE_0_HIGH 0x1e04
-#define PCI_0ACCESS_CONTROL_TOP_0 0x1e08
-#define PCI_0ACCESS_CONTROL_BASE_1_LOW 0c1e10
-#define PCI_0ACCESS_CONTROL_BASE_1_HIGH 0x1e14
-#define PCI_0ACCESS_CONTROL_TOP_1 0x1e18
-#define PCI_0ACCESS_CONTROL_BASE_2_LOW 0c1e20
-#define PCI_0ACCESS_CONTROL_BASE_2_HIGH 0x1e24
-#define PCI_0ACCESS_CONTROL_TOP_2 0x1e28
-#define PCI_0ACCESS_CONTROL_BASE_3_LOW 0c1e30
-#define PCI_0ACCESS_CONTROL_BASE_3_HIGH 0x1e34
-#define PCI_0ACCESS_CONTROL_TOP_3 0x1e38
-#define PCI_0ACCESS_CONTROL_BASE_4_LOW 0c1e40
-#define PCI_0ACCESS_CONTROL_BASE_4_HIGH 0x1e44
-#define PCI_0ACCESS_CONTROL_TOP_4 0x1e48
-#define PCI_0ACCESS_CONTROL_BASE_5_LOW 0c1e50
-#define PCI_0ACCESS_CONTROL_BASE_5_HIGH 0x1e54
-#define PCI_0ACCESS_CONTROL_TOP_5 0x1e58
-#define PCI_0ACCESS_CONTROL_BASE_6_LOW 0c1e60
-#define PCI_0ACCESS_CONTROL_BASE_6_HIGH 0x1e64
-#define PCI_0ACCESS_CONTROL_TOP_6 0x1e68
-#define PCI_0ACCESS_CONTROL_BASE_7_LOW 0c1e70
-#define PCI_0ACCESS_CONTROL_BASE_7_HIGH 0x1e74
-#define PCI_0ACCESS_CONTROL_TOP_7 0x1e78
-#define PCI_1CROSS_BAR_CONTROL_LOW 0x1d88
-#define PCI_1CROSS_BAR_CONTROL_HIGH 0x1d8c
-#define PCI_1CROSS_BAR_TIMEOUT 0x1d84
-#define PCI_1READ_RESPONSE_CROSS_BAR_CONTROL_LOW 0x1d98
-#define PCI_1READ_RESPONSE_CROSS_BAR_CONTROL_HIGH 0x1d9c
-#define PCI_1SYNC_BARRIER_VIRTUAL_REGISTER 0x1d90
-#define PCI_1P2P_CONFIGURATION 0x1d94
-#define PCI_1ACCESS_CONTROL_BASE_0_LOW 0x1e80
-#define PCI_1ACCESS_CONTROL_BASE_0_HIGH 0x1e84
-#define PCI_1ACCESS_CONTROL_TOP_0 0x1e88
-#define PCI_1ACCESS_CONTROL_BASE_1_LOW 0c1e90
-#define PCI_1ACCESS_CONTROL_BASE_1_HIGH 0x1e94
-#define PCI_1ACCESS_CONTROL_TOP_1 0x1e98
-#define PCI_1ACCESS_CONTROL_BASE_2_LOW 0c1ea0
-#define PCI_1ACCESS_CONTROL_BASE_2_HIGH 0x1ea4
-#define PCI_1ACCESS_CONTROL_TOP_2 0x1ea8
-#define PCI_1ACCESS_CONTROL_BASE_3_LOW 0c1eb0
-#define PCI_1ACCESS_CONTROL_BASE_3_HIGH 0x1eb4
-#define PCI_1ACCESS_CONTROL_TOP_3 0x1eb8
-#define PCI_1ACCESS_CONTROL_BASE_4_LOW 0c1ec0
-#define PCI_1ACCESS_CONTROL_BASE_4_HIGH 0x1ec4
-#define PCI_1ACCESS_CONTROL_TOP_4 0x1ec8
-#define PCI_1ACCESS_CONTROL_BASE_5_LOW 0c1ed0
-#define PCI_1ACCESS_CONTROL_BASE_5_HIGH 0x1ed4
-#define PCI_1ACCESS_CONTROL_TOP_5 0x1ed8
-#define PCI_1ACCESS_CONTROL_BASE_6_LOW 0c1ee0
-#define PCI_1ACCESS_CONTROL_BASE_6_HIGH 0x1ee4
-#define PCI_1ACCESS_CONTROL_TOP_6 0x1ee8
-#define PCI_1ACCESS_CONTROL_BASE_7_LOW 0c1ef0
-#define PCI_1ACCESS_CONTROL_BASE_7_HIGH 0x1ef4
-#define PCI_1ACCESS_CONTROL_TOP_7 0x1ef8
-
-/****************************************/
-/* PCI Snoop Control */
-/****************************************/
-
-#define PCI_0SNOOP_CONTROL_BASE_0_LOW 0x1f00
-#define PCI_0SNOOP_CONTROL_BASE_0_HIGH 0x1f04
-#define PCI_0SNOOP_CONTROL_TOP_0 0x1f08
-#define PCI_0SNOOP_CONTROL_BASE_1_0_LOW 0x1f10
-#define PCI_0SNOOP_CONTROL_BASE_1_0_HIGH 0x1f14
-#define PCI_0SNOOP_CONTROL_TOP_1 0x1f18
-#define PCI_0SNOOP_CONTROL_BASE_2_0_LOW 0x1f20
-#define PCI_0SNOOP_CONTROL_BASE_2_0_HIGH 0x1f24
-#define PCI_0SNOOP_CONTROL_TOP_2 0x1f28
-#define PCI_0SNOOP_CONTROL_BASE_3_0_LOW 0x1f30
-#define PCI_0SNOOP_CONTROL_BASE_3_0_HIGH 0x1f34
-#define PCI_0SNOOP_CONTROL_TOP_3 0x1f38
-#define PCI_1SNOOP_CONTROL_BASE_0_LOW 0x1f80
-#define PCI_1SNOOP_CONTROL_BASE_0_HIGH 0x1f84
-#define PCI_1SNOOP_CONTROL_TOP_0 0x1f88
-#define PCI_1SNOOP_CONTROL_BASE_1_0_LOW 0x1f90
-#define PCI_1SNOOP_CONTROL_BASE_1_0_HIGH 0x1f94
-#define PCI_1SNOOP_CONTROL_TOP_1 0x1f98
-#define PCI_1SNOOP_CONTROL_BASE_2_0_LOW 0x1fa0
-#define PCI_1SNOOP_CONTROL_BASE_2_0_HIGH 0x1fa4
-#define PCI_1SNOOP_CONTROL_TOP_2 0x1fa8
-#define PCI_1SNOOP_CONTROL_BASE_3_0_LOW 0x1fb0
-#define PCI_1SNOOP_CONTROL_BASE_3_0_HIGH 0x1fb4
-#define PCI_1SNOOP_CONTROL_TOP_3 0x1fb8
-
-/****************************************/
-/* PCI Configuration Address */
-/****************************************/
-
-#define PCI_0CONFIGURATION_ADDRESS 0xcf8
-#define PCI_0CONFIGURATION_DATA_VIRTUAL_REGISTER 0xcfc
-#define PCI_1CONFIGURATION_ADDRESS 0xc78
-#define PCI_1CONFIGURATION_DATA_VIRTUAL_REGISTER 0xc7c
-#define PCI_0INTERRUPT_ACKNOWLEDGE_VIRTUAL_REGISTER 0xc34
-#define PCI_1INTERRUPT_ACKNOWLEDGE_VIRTUAL_REGISTER 0xcb4
-
-/****************************************/
-/* PCI Error Report */
-/****************************************/
-
-#define PCI_0SERR_MASK 0xc28
-#define PCI_0ERROR_ADDRESS_LOW 0x1d40
-#define PCI_0ERROR_ADDRESS_HIGH 0x1d44
-#define PCI_0ERROR_DATA_LOW 0x1d48
-#define PCI_0ERROR_DATA_HIGH 0x1d4c
-#define PCI_0ERROR_COMMAND 0x1d50
-#define PCI_0ERROR_CAUSE 0x1d58
-#define PCI_0ERROR_MASK 0x1d5c
-
-#define PCI_1SERR_MASK 0xca8
-#define PCI_1ERROR_ADDRESS_LOW 0x1dc0
-#define PCI_1ERROR_ADDRESS_HIGH 0x1dc4
-#define PCI_1ERROR_DATA_LOW 0x1dc8
-#define PCI_1ERROR_DATA_HIGH 0x1dcc
-#define PCI_1ERROR_COMMAND 0x1dd0
-#define PCI_1ERROR_CAUSE 0x1dd8
-#define PCI_1ERROR_MASK 0x1ddc
-
-
-/****************************************/
-/* Lslave Debug (for internal use) */
-/****************************************/
-
-#define L_SLAVE_X0_ADDRESS 0x1d20
-#define L_SLAVE_X0_COMMAND_AND_ID 0x1d24
-#define L_SLAVE_X1_ADDRESS 0x1d28
-#define L_SLAVE_X1_COMMAND_AND_ID 0x1d2c
-#define L_SLAVE_WRITE_DATA_LOW 0x1d30
-#define L_SLAVE_WRITE_DATA_HIGH 0x1d34
-#define L_SLAVE_WRITE_BYTE_ENABLE 0x1d60
-#define L_SLAVE_READ_DATA_LOW 0x1d38
-#define L_SLAVE_READ_DATA_HIGH 0x1d3c
-#define L_SLAVE_READ_ID 0x1d64
-
-/****************************************/
-/* PCI Configuration Function 0 */
-/****************************************/
-
-#define PCI_DEVICE_AND_VENDOR_ID 0x000
-#define PCI_STATUS_AND_COMMAND 0x004
-#define PCI_CLASS_CODE_AND_REVISION_ID 0x008
-#define PCI_BIST_HEADER_TYPE_LATENCY_TIMER_CACHE_LINE 0x00C
-#define PCI_SCS_0_BASE_ADDRESS 0x010
-#define PCI_SCS_1_BASE_ADDRESS 0x014
-#define PCI_SCS_2_BASE_ADDRESS 0x018
-#define PCI_SCS_3_BASE_ADDRESS 0x01C
-#define PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS 0x020
-#define PCI_INTERNAL_REGISTERS_I_OMAPPED_BASE_ADDRESS 0x024
-#define PCI_SUBSYSTEM_ID_AND_SUBSYSTEM_VENDOR_ID 0x02C
-#define PCI_EXPANSION_ROM_BASE_ADDRESS_REGISTER 0x030
-#define PCI_CAPABILTY_LIST_POINTER 0x034
-#define PCI_INTERRUPT_PIN_AND_LINE 0x03C
-#define PCI_POWER_MANAGEMENT_CAPABILITY 0x040
-#define PCI_POWER_MANAGEMENT_STATUS_AND_CONTROL 0x044
-#define PCI_VPD_ADDRESS 0x048
-#define PCI_VPD_DATA 0X04c
-#define PCI_MSI_MESSAGE_CONTROL 0x050
-#define PCI_MSI_MESSAGE_ADDRESS 0x054
-#define PCI_MSI_MESSAGE_UPPER_ADDRESS 0x058
-#define PCI_MSI_MESSAGE_DATA 0x05c
-#define PCI_COMPACT_PCI_HOT_SWAP_CAPABILITY 0x058
-
-/****************************************/
-/* PCI Configuration Function 1 */
-/****************************************/
-
-#define PCI_CS_0_BASE_ADDRESS 0x110
-#define PCI_CS_1_BASE_ADDRESS 0x114
-#define PCI_CS_2_BASE_ADDRESS 0x118
-#define PCI_CS_3_BASE_ADDRESS 0x11c
-#define PCI_BOOTCS_BASE_ADDRESS 0x120
-
-/****************************************/
-/* PCI Configuration Function 2 */
-/****************************************/
-
-#define PCI_P2P_MEM0_BASE_ADDRESS 0x210
-#define PCI_P2P_MEM1_BASE_ADDRESS 0x214
-#define PCI_P2P_I_O_BASE_ADDRESS 0x218
-#define PCI_CPU_BASE_ADDRESS 0x21c
-
-/****************************************/
-/* PCI Configuration Function 4 */
-/****************************************/
-
-#define PCI_DAC_SCS_0_BASE_ADDRESS_LOW 0x410
-#define PCI_DAC_SCS_0_BASE_ADDRESS_HIGH 0x414
-#define PCI_DAC_SCS_1_BASE_ADDRESS_LOW 0x418
-#define PCI_DAC_SCS_1_BASE_ADDRESS_HIGH 0x41c
-#define PCI_DAC_P2P_MEM0_BASE_ADDRESS_LOW 0x420
-#define PCI_DAC_P2P_MEM0_BASE_ADDRESS_HIGH 0x424
-
-
-/****************************************/
-/* PCI Configuration Function 5 */
-/****************************************/
-
-#define PCI_DAC_SCS_2_BASE_ADDRESS_LOW 0x510
-#define PCI_DAC_SCS_2_BASE_ADDRESS_HIGH 0x514
-#define PCI_DAC_SCS_3_BASE_ADDRESS_LOW 0x518
-#define PCI_DAC_SCS_3_BASE_ADDRESS_HIGH 0x51c
-#define PCI_DAC_P2P_MEM1_BASE_ADDRESS_LOW 0x520
-#define PCI_DAC_P2P_MEM1_BASE_ADDRESS_HIGH 0x524
-
-
-/****************************************/
-/* PCI Configuration Function 6 */
-/****************************************/
-
-#define PCI_DAC_CS_0_BASE_ADDRESS_LOW 0x610
-#define PCI_DAC_CS_0_BASE_ADDRESS_HIGH 0x614
-#define PCI_DAC_CS_1_BASE_ADDRESS_LOW 0x618
-#define PCI_DAC_CS_1_BASE_ADDRESS_HIGH 0x61c
-#define PCI_DAC_CS_2_BASE_ADDRESS_LOW 0x620
-#define PCI_DAC_CS_2_BASE_ADDRESS_HIGH 0x624
-
-/****************************************/
-/* PCI Configuration Function 7 */
-/****************************************/
-
-#define PCI_DAC_CS_3_BASE_ADDRESS_LOW 0x710
-#define PCI_DAC_CS_3_BASE_ADDRESS_HIGH 0x714
-#define PCI_DAC_BOOTCS_BASE_ADDRESS_LOW 0x718
-#define PCI_DAC_BOOTCS_BASE_ADDRESS_HIGH 0x71c
-#define PCI_DAC_CPU_BASE_ADDRESS_LOW 0x720
-#define PCI_DAC_CPU_BASE_ADDRESS_HIGH 0x724
-
-/****************************************/
-/* Interrupts */
-/****************************************/
-
-#define LOW_INTERRUPT_CAUSE_REGISTER 0xc18
-#define HIGH_INTERRUPT_CAUSE_REGISTER 0xc68
-#define CPU_INTERRUPT_MASK_REGISTER_LOW 0xc1c
-#define CPU_INTERRUPT_MASK_REGISTER_HIGH 0xc6c
-#define CPU_SELECT_CAUSE_REGISTER 0xc70
-#define PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW 0xc24
-#define PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH 0xc64
-#define PCI_0SELECT_CAUSE 0xc74
-#define PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW 0xca4
-#define PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH 0xce4
-#define PCI_1SELECT_CAUSE 0xcf4
-#define CPU_INT_0_MASK 0xe60
-#define CPU_INT_1_MASK 0xe64
-#define CPU_INT_2_MASK 0xe68
-#define CPU_INT_3_MASK 0xe6c
-
-/****************************************/
-/* I20 Support registers */
-/****************************************/
-
-#define INBOUND_MESSAGE_REGISTER0_PCI0_SIDE 0x010
-#define INBOUND_MESSAGE_REGISTER1_PCI0_SIDE 0x014
-#define OUTBOUND_MESSAGE_REGISTER0_PCI0_SIDE 0x018
-#define OUTBOUND_MESSAGE_REGISTER1_PCI0_SIDE 0x01C
-#define INBOUND_DOORBELL_REGISTER_PCI0_SIDE 0x020
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_PCI0_SIDE 0x024
-#define INBOUND_INTERRUPT_MASK_REGISTER_PCI0_SIDE 0x028
-#define OUTBOUND_DOORBELL_REGISTER_PCI0_SIDE 0x02C
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_PCI0_SIDE 0x030
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_PCI0_SIDE 0x034
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI0_SIDE 0x040
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI0_SIDE 0x044
-#define QUEUE_CONTROL_REGISTER_PCI0_SIDE 0x050
-#define QUEUE_BASE_ADDRESS_REGISTER_PCI0_SIDE 0x054
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_PCI0_SIDE 0x060
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_PCI0_SIDE 0x064
-#define INBOUND_POST_HEAD_POINTER_REGISTER_PCI0_SIDE 0x068
-#define INBOUND_POST_TAIL_POINTER_REGISTER_PCI0_SIDE 0x06C
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_PCI0_SIDE 0x070
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_PCI0_SIDE 0x074
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_PCI0_SIDE 0x0F8
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_PCI0_SIDE 0x0FC
-
-#define INBOUND_MESSAGE_REGISTER0_PCI1_SIDE 0x090
-#define INBOUND_MESSAGE_REGISTER1_PCI1_SIDE 0x094
-#define OUTBOUND_MESSAGE_REGISTER0_PCI1_SIDE 0x098
-#define OUTBOUND_MESSAGE_REGISTER1_PCI1_SIDE 0x09C
-#define INBOUND_DOORBELL_REGISTER_PCI1_SIDE 0x0A0
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_PCI1_SIDE 0x0A4
-#define INBOUND_INTERRUPT_MASK_REGISTER_PCI1_SIDE 0x0A8
-#define OUTBOUND_DOORBELL_REGISTER_PCI1_SIDE 0x0AC
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_PCI1_SIDE 0x0B0
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_PCI1_SIDE 0x0B4
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI1_SIDE 0x0C0
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_PCI1_SIDE 0x0C4
-#define QUEUE_CONTROL_REGISTER_PCI1_SIDE 0x0D0
-#define QUEUE_BASE_ADDRESS_REGISTER_PCI1_SIDE 0x0D4
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_PCI1_SIDE 0x0E0
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_PCI1_SIDE 0x0E4
-#define INBOUND_POST_HEAD_POINTER_REGISTER_PCI1_SIDE 0x0E8
-#define INBOUND_POST_TAIL_POINTER_REGISTER_PCI1_SIDE 0x0EC
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_PCI1_SIDE 0x0F0
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_PCI1_SIDE 0x0F4
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_PCI1_SIDE 0x078
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_PCI1_SIDE 0x07C
-
-#define INBOUND_MESSAGE_REGISTER0_CPU0_SIDE 0X1C10
-#define INBOUND_MESSAGE_REGISTER1_CPU0_SIDE 0X1C14
-#define OUTBOUND_MESSAGE_REGISTER0_CPU0_SIDE 0X1C18
-#define OUTBOUND_MESSAGE_REGISTER1_CPU0_SIDE 0X1C1C
-#define INBOUND_DOORBELL_REGISTER_CPU0_SIDE 0X1C20
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_CPU0_SIDE 0X1C24
-#define INBOUND_INTERRUPT_MASK_REGISTER_CPU0_SIDE 0X1C28
-#define OUTBOUND_DOORBELL_REGISTER_CPU0_SIDE 0X1C2C
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_CPU0_SIDE 0X1C30
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_CPU0_SIDE 0X1C34
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU0_SIDE 0X1C40
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU0_SIDE 0X1C44
-#define QUEUE_CONTROL_REGISTER_CPU0_SIDE 0X1C50
-#define QUEUE_BASE_ADDRESS_REGISTER_CPU0_SIDE 0X1C54
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_CPU0_SIDE 0X1C60
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_CPU0_SIDE 0X1C64
-#define INBOUND_POST_HEAD_POINTER_REGISTER_CPU0_SIDE 0X1C68
-#define INBOUND_POST_TAIL_POINTER_REGISTER_CPU0_SIDE 0X1C6C
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_CPU0_SIDE 0X1C70
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_CPU0_SIDE 0X1C74
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_CPU0_SIDE 0X1CF8
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_CPU0_SIDE 0X1CFC
-
-#define INBOUND_MESSAGE_REGISTER0_CPU1_SIDE 0X1C90
-#define INBOUND_MESSAGE_REGISTER1_CPU1_SIDE 0X1C94
-#define OUTBOUND_MESSAGE_REGISTER0_CPU1_SIDE 0X1C98
-#define OUTBOUND_MESSAGE_REGISTER1_CPU1_SIDE 0X1C9C
-#define INBOUND_DOORBELL_REGISTER_CPU1_SIDE 0X1CA0
-#define INBOUND_INTERRUPT_CAUSE_REGISTER_CPU1_SIDE 0X1CA4
-#define INBOUND_INTERRUPT_MASK_REGISTER_CPU1_SIDE 0X1CA8
-#define OUTBOUND_DOORBELL_REGISTER_CPU1_SIDE 0X1CAC
-#define OUTBOUND_INTERRUPT_CAUSE_REGISTER_CPU1_SIDE 0X1CB0
-#define OUTBOUND_INTERRUPT_MASK_REGISTER_CPU1_SIDE 0X1CB4
-#define INBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU1_SIDE 0X1CC0
-#define OUTBOUND_QUEUE_PORT_VIRTUAL_REGISTER_CPU1_SIDE 0X1CC4
-#define QUEUE_CONTROL_REGISTER_CPU1_SIDE 0X1CD0
-#define QUEUE_BASE_ADDRESS_REGISTER_CPU1_SIDE 0X1CD4
-#define INBOUND_FREE_HEAD_POINTER_REGISTER_CPU1_SIDE 0X1CE0
-#define INBOUND_FREE_TAIL_POINTER_REGISTER_CPU1_SIDE 0X1CE4
-#define INBOUND_POST_HEAD_POINTER_REGISTER_CPU1_SIDE 0X1CE8
-#define INBOUND_POST_TAIL_POINTER_REGISTER_CPU1_SIDE 0X1CEC
-#define OUTBOUND_FREE_HEAD_POINTER_REGISTER_CPU1_SIDE 0X1CF0
-#define OUTBOUND_FREE_TAIL_POINTER_REGISTER_CPU1_SIDE 0X1CF4
-#define OUTBOUND_POST_HEAD_POINTER_REGISTER_CPU1_SIDE 0X1C78
-#define OUTBOUND_POST_TAIL_POINTER_REGISTER_CPU1_SIDE 0X1C7C
-
-/****************************************/
-/* Communication Unit Registers */
-/****************************************/
-
-#define ETHERNET_0_ADDRESS_CONTROL_LOW
-#define ETHERNET_0_ADDRESS_CONTROL_HIGH 0xf204
-#define ETHERNET_0_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf208
-#define ETHERNET_0_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf20c
-#define ETHERNET_0_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf210
-#define ETHERNET_0_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf214
-#define ETHERNET_0_HASH_TABLE_PCI_HIGH_ADDRESS 0xf218
-#define ETHERNET_1_ADDRESS_CONTROL_LOW 0xf220
-#define ETHERNET_1_ADDRESS_CONTROL_HIGH 0xf224
-#define ETHERNET_1_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf228
-#define ETHERNET_1_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf22c
-#define ETHERNET_1_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf230
-#define ETHERNET_1_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf234
-#define ETHERNET_1_HASH_TABLE_PCI_HIGH_ADDRESS 0xf238
-#define ETHERNET_2_ADDRESS_CONTROL_LOW 0xf240
-#define ETHERNET_2_ADDRESS_CONTROL_HIGH 0xf244
-#define ETHERNET_2_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf248
-#define ETHERNET_2_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf24c
-#define ETHERNET_2_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf250
-#define ETHERNET_2_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf254
-#define ETHERNET_2_HASH_TABLE_PCI_HIGH_ADDRESS 0xf258
-#define MPSC_0_ADDRESS_CONTROL_LOW 0xf280
-#define MPSC_0_ADDRESS_CONTROL_HIGH 0xf284
-#define MPSC_0_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf288
-#define MPSC_0_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf28c
-#define MPSC_0_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf290
-#define MPSC_0_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf294
-#define MPSC_1_ADDRESS_CONTROL_LOW 0xf2a0
-#define MPSC_1_ADDRESS_CONTROL_HIGH 0xf2a4
-#define MPSC_1_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf2a8
-#define MPSC_1_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf2ac
-#define MPSC_1_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf2b0
-#define MPSC_1_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf2b4
-#define MPSC_2_ADDRESS_CONTROL_LOW 0xf2c0
-#define MPSC_2_ADDRESS_CONTROL_HIGH 0xf2c4
-#define MPSC_2_RECEIVE_BUFFER_PCI_HIGH_ADDRESS 0xf2c8
-#define MPSC_2_TRANSMIT_BUFFER_PCI_HIGH_ADDRESS 0xf2cc
-#define MPSC_2_RECEIVE_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf2d0
-#define MPSC_2_TRANSMIT_DESCRIPTOR_PCI_HIGH_ADDRESS 0xf2d4
-#define SERIAL_INIT_PCI_HIGH_ADDRESS 0xf320
-#define SERIAL_INIT_LAST_DATA 0xf324
-#define SERIAL_INIT_STATUS_AND_CONTROL 0xf328
-#define COMM_UNIT_ARBITER_CONTROL 0xf300
-#define COMM_UNIT_CROSS_BAR_TIMEOUT 0xf304
-#define COMM_UNIT_INTERRUPT_CAUSE 0xf310
-#define COMM_UNIT_INTERRUPT_MASK 0xf314
-#define COMM_UNIT_ERROR_ADDRESS 0xf314
-
-/****************************************/
-/* Cunit Debug (for internal use) */
-/****************************************/
-
-#define CUNIT_ADDRESS 0xf340
-#define CUNIT_COMMAND_AND_ID 0xf344
-#define CUNIT_WRITE_DATA_LOW 0xf348
-#define CUNIT_WRITE_DATA_HIGH 0xf34c
-#define CUNIT_WRITE_BYTE_ENABLE 0xf358
-#define CUNIT_READ_DATA_LOW 0xf350
-#define CUNIT_READ_DATA_HIGH 0xf354
-#define CUNIT_READ_ID 0xf35c
-
-/****************************************/
-/* Fast Ethernet Unit Registers */
-/****************************************/
-
-/* Ethernet */
-
-#define ETHERNET_PHY_ADDRESS_REGISTER 0x2000
-#define ETHERNET_SMI_REGISTER 0x2010
-
-/* Ethernet 0 */
-
-#define ETHERNET0_PORT_CONFIGURATION_REGISTER 0x2400
-#define ETHERNET0_PORT_CONFIGURATION_EXTEND_REGISTER 0x2408
-#define ETHERNET0_PORT_COMMAND_REGISTER 0x2410
-#define ETHERNET0_PORT_STATUS_REGISTER 0x2418
-#define ETHERNET0_SERIAL_PARAMETRS_REGISTER 0x2420
-#define ETHERNET0_HASH_TABLE_POINTER_REGISTER 0x2428
-#define ETHERNET0_FLOW_CONTROL_SOURCE_ADDRESS_LOW 0x2430
-#define ETHERNET0_FLOW_CONTROL_SOURCE_ADDRESS_HIGH 0x2438
-#define ETHERNET0_SDMA_CONFIGURATION_REGISTER 0x2440
-#define ETHERNET0_SDMA_COMMAND_REGISTER 0x2448
-#define ETHERNET0_INTERRUPT_CAUSE_REGISTER 0x2450
-#define ETHERNET0_INTERRUPT_MASK_REGISTER 0x2458
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER0 0x2480
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER1 0x2484
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER2 0x2488
-#define ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER3 0x248c
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER0 0x24a0
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER1 0x24a4
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER2 0x24a8
-#define ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER3 0x24ac
-#define ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER0 0x24e0
-#define ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER1 0x24e4
-#define ETHERNET0_MIB_COUNTER_BASE 0x2500
-
-/* Ethernet 1 */
-
-#define ETHERNET1_PORT_CONFIGURATION_REGISTER 0x2800
-#define ETHERNET1_PORT_CONFIGURATION_EXTEND_REGISTER 0x2808
-#define ETHERNET1_PORT_COMMAND_REGISTER 0x2810
-#define ETHERNET1_PORT_STATUS_REGISTER 0x2818
-#define ETHERNET1_SERIAL_PARAMETRS_REGISTER 0x2820
-#define ETHERNET1_HASH_TABLE_POINTER_REGISTER 0x2828
-#define ETHERNET1_FLOW_CONTROL_SOURCE_ADDRESS_LOW 0x2830
-#define ETHERNET1_FLOW_CONTROL_SOURCE_ADDRESS_HIGH 0x2838
-#define ETHERNET1_SDMA_CONFIGURATION_REGISTER 0x2840
-#define ETHERNET1_SDMA_COMMAND_REGISTER 0x2848
-#define ETHERNET1_INTERRUPT_CAUSE_REGISTER 0x2850
-#define ETHERNET1_INTERRUPT_MASK_REGISTER 0x2858
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER0 0x2880
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER1 0x2884
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER2 0x2888
-#define ETHERNET1_FIRST_RX_DESCRIPTOR_POINTER3 0x288c
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER0 0x28a0
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER1 0x28a4
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER2 0x28a8
-#define ETHERNET1_CURRENT_RX_DESCRIPTOR_POINTER3 0x28ac
-#define ETHERNET1_CURRENT_TX_DESCRIPTOR_POINTER0 0x28e0
-#define ETHERNET1_CURRENT_TX_DESCRIPTOR_POINTER1 0x28e4
-#define ETHERNET1_MIB_COUNTER_BASE 0x2900
-
-/* Ethernet 2 */
-
-#define ETHERNET2_PORT_CONFIGURATION_REGISTER 0x2c00
-#define ETHERNET2_PORT_CONFIGURATION_EXTEND_REGISTER 0x2c08
-#define ETHERNET2_PORT_COMMAND_REGISTER 0x2c10
-#define ETHERNET2_PORT_STATUS_REGISTER 0x2c18
-#define ETHERNET2_SERIAL_PARAMETRS_REGISTER 0x2c20
-#define ETHERNET2_HASH_TABLE_POINTER_REGISTER 0x2c28
-#define ETHERNET2_FLOW_CONTROL_SOURCE_ADDRESS_LOW 0x2c30
-#define ETHERNET2_FLOW_CONTROL_SOURCE_ADDRESS_HIGH 0x2c38
-#define ETHERNET2_SDMA_CONFIGURATION_REGISTER 0x2c40
-#define ETHERNET2_SDMA_COMMAND_REGISTER 0x2c48
-#define ETHERNET2_INTERRUPT_CAUSE_REGISTER 0x2c50
-#define ETHERNET2_INTERRUPT_MASK_REGISTER 0x2c58
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER0 0x2c80
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER1 0x2c84
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER2 0x2c88
-#define ETHERNET2_FIRST_RX_DESCRIPTOR_POINTER3 0x2c8c
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER0 0x2ca0
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER1 0x2ca4
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER2 0x2ca8
-#define ETHERNET2_CURRENT_RX_DESCRIPTOR_POINTER3 0x2cac
-#define ETHERNET2_CURRENT_TX_DESCRIPTOR_POINTER0 0x2ce0
-#define ETHERNET2_CURRENT_TX_DESCRIPTOR_POINTER1 0x2ce4
-#define ETHERNET2_MIB_COUNTER_BASE 0x2d00
-
-/****************************************/
-/* SDMA Registers */
-/****************************************/
-
-#define SDMA_GROUP_CONFIGURATION_REGISTER 0xb1f0
-#define CHANNEL0_CONFIGURATION_REGISTER 0x4000
-#define CHANNEL0_COMMAND_REGISTER 0x4008
-#define CHANNEL0_RX_CMD_STATUS 0x4800
-#define CHANNEL0_RX_PACKET_AND_BUFFER_SIZES 0x4804
-#define CHANNEL0_RX_BUFFER_POINTER 0x4808
-#define CHANNEL0_RX_NEXT_POINTER 0x480c
-#define CHANNEL0_CURRENT_RX_DESCRIPTOR_POINTER 0x4810
-#define CHANNEL0_TX_CMD_STATUS 0x4C00
-#define CHANNEL0_TX_PACKET_SIZE 0x4C04
-#define CHANNEL0_TX_BUFFER_POINTER 0x4C08
-#define CHANNEL0_TX_NEXT_POINTER 0x4C0c
-#define CHANNEL0_CURRENT_TX_DESCRIPTOR_POINTER 0x4c10
-#define CHANNEL0_FIRST_TX_DESCRIPTOR_POINTER 0x4c14
-#define CHANNEL1_CONFIGURATION_REGISTER 0x6000
-#define CHANNEL1_COMMAND_REGISTER 0x6008
-#define CHANNEL1_RX_CMD_STATUS 0x6800
-#define CHANNEL1_RX_PACKET_AND_BUFFER_SIZES 0x6804
-#define CHANNEL1_RX_BUFFER_POINTER 0x6808
-#define CHANNEL1_RX_NEXT_POINTER 0x680c
-#define CHANNEL1_CURRENT_RX_DESCRIPTOR_POINTER 0x6810
-#define CHANNEL1_TX_CMD_STATUS 0x6C00
-#define CHANNEL1_TX_PACKET_SIZE 0x6C04
-#define CHANNEL1_TX_BUFFER_POINTER 0x6C08
-#define CHANNEL1_TX_NEXT_POINTER 0x6C0c
-#define CHANNEL1_CURRENT_RX_DESCRIPTOR_POINTER 0x6810
-#define CHANNEL1_CURRENT_TX_DESCRIPTOR_POINTER 0x6c10
-#define CHANNEL1_FIRST_TX_DESCRIPTOR_POINTER 0x6c14
-
-/* SDMA Interrupt */
-
-#define SDMA_CAUSE 0xb820
-#define SDMA_MASK 0xb8a0
-
-
-/****************************************/
-/* Baude Rate Generators Registers */
-/****************************************/
-
-/* BRG 0 */
-
-#define BRG0_CONFIGURATION_REGISTER 0xb200
-#define BRG0_BAUDE_TUNING_REGISTER 0xb204
-
-/* BRG 1 */
-
-#define BRG1_CONFIGURATION_REGISTER 0xb208
-#define BRG1_BAUDE_TUNING_REGISTER 0xb20c
-
-/* BRG 2 */
-
-#define BRG2_CONFIGURATION_REGISTER 0xb210
-#define BRG2_BAUDE_TUNING_REGISTER 0xb214
-
-/* BRG Interrupts */
-
-#define BRG_CAUSE_REGISTER 0xb834
-#define BRG_MASK_REGISTER 0xb8b4
-
-/* MISC */
-
-#define MAIN_ROUTING_REGISTER 0xb400
-#define RECEIVE_CLOCK_ROUTING_REGISTER 0xb404
-#define TRANSMIT_CLOCK_ROUTING_REGISTER 0xb408
-#define COMM_UNIT_ARBITER_CONFIGURATION_REGISTER 0xb40c
-#define WATCHDOG_CONFIGURATION_REGISTER 0xb410
-#define WATCHDOG_VALUE_REGISTER 0xb414
-
-
-/****************************************/
-/* Flex TDM Registers */
-/****************************************/
-
-/* FTDM Port */
-
-#define FLEXTDM_TRANSMIT_READ_POINTER 0xa800
-#define FLEXTDM_RECEIVE_READ_POINTER 0xa804
-#define FLEXTDM_CONFIGURATION_REGISTER 0xa808
-#define FLEXTDM_AUX_CHANNELA_TX_REGISTER 0xa80c
-#define FLEXTDM_AUX_CHANNELA_RX_REGISTER 0xa810
-#define FLEXTDM_AUX_CHANNELB_TX_REGISTER 0xa814
-#define FLEXTDM_AUX_CHANNELB_RX_REGISTER 0xa818
-
-/* FTDM Interrupts */
-
-#define FTDM_CAUSE_REGISTER 0xb830
-#define FTDM_MASK_REGISTER 0xb8b0
-
-
-/****************************************/
-/* GPP Interface Registers */
-/****************************************/
-
-#define GPP_IO_CONTROL 0xf100
-#define GPP_LEVEL_CONTROL 0xf110
-#define GPP_VALUE 0xf104
-#define GPP_INTERRUPT_CAUSE 0xf108
-#define GPP_INTERRUPT_MASK 0xf10c
-
-#define MPP_CONTROL0 0xf000
-#define MPP_CONTROL1 0xf004
-#define MPP_CONTROL2 0xf008
-#define MPP_CONTROL3 0xf00c
-#define DEBUG_PORT_MULTIPLEX 0xf014
-#define SERIAL_PORT_MULTIPLEX 0xf010
-
-/****************************************/
-/* I2C Registers */
-/****************************************/
-
-#define I2C_SLAVE_ADDRESS 0xc000
-#define I2C_EXTENDED_SLAVE_ADDRESS 0xc040
-#define I2C_DATA 0xc004
-#define I2C_CONTROL 0xc008
-#define I2C_STATUS_BAUDE_RATE 0xc00C
-#define I2C_SOFT_RESET 0xc01c
-
-/****************************************/
-/* MPSC Registers */
-/****************************************/
-
-/* MPSC0 */
-
-#define MPSC0_MAIN_CONFIGURATION_LOW 0x8000
-#define MPSC0_MAIN_CONFIGURATION_HIGH 0x8004
-#define MPSC0_PROTOCOL_CONFIGURATION 0x8008
-#define CHANNEL0_REGISTER1 0x800c
-#define CHANNEL0_REGISTER2 0x8010
-#define CHANNEL0_REGISTER3 0x8014
-#define CHANNEL0_REGISTER4 0x8018
-#define CHANNEL0_REGISTER5 0x801c
-#define CHANNEL0_REGISTER6 0x8020
-#define CHANNEL0_REGISTER7 0x8024
-#define CHANNEL0_REGISTER8 0x8028
-#define CHANNEL0_REGISTER9 0x802c
-#define CHANNEL0_REGISTER10 0x8030
-#define CHANNEL0_REGISTER11 0x8034
-
-/* MPSC1 */
-
-#define MPSC1_MAIN_CONFIGURATION_LOW 0x9000
-#define MPSC1_MAIN_CONFIGURATION_HIGH 0x9004
-#define MPSC1_PROTOCOL_CONFIGURATION 0x9008
-#define CHANNEL1_REGISTER1 0x900c
-#define CHANNEL1_REGISTER2 0x9010
-#define CHANNEL1_REGISTER3 0x9014
-#define CHANNEL1_REGISTER4 0x9018
-#define CHANNEL1_REGISTER5 0x901c
-#define CHANNEL1_REGISTER6 0x9020
-#define CHANNEL1_REGISTER7 0x9024
-#define CHANNEL1_REGISTER8 0x9028
-#define CHANNEL1_REGISTER9 0x902c
-#define CHANNEL1_REGISTER10 0x9030
-#define CHANNEL1_REGISTER11 0x9034
-
-/* MPSCs Interupts */
-
-#define MPSC0_CAUSE 0xb804
-#define MPSC0_MASK 0xb884
-#define MPSC1_CAUSE 0xb80c
-#define MPSC1_MASK 0xb88c
-
-#endif /* __INCgt64240rh */
+++ /dev/null
-/***********************************************************************
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/gt64240/gt64240-dep.h
- * Board-dependent definitions for GT-64120 chip.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- ***********************************************************************
- */
-
-#ifndef _ASM_GT64240_DEP_H
-#define _ASM_GT64240_DEP_H
-
-#include <asm/addrspace.h> /* for KSEG1ADDR() */
-#include <asm/byteorder.h> /* for cpu_to_le32() */
-
-/*
- * PCI address allocation
- */
-#if 0
-#define GT_PCI_MEM_BASE (0x22000000)
-#define GT_PCI_MEM_SIZE GT_DEF_PCI0_MEM0_SIZE
-#define GT_PCI_IO_BASE (0x20000000)
-#define GT_PCI_IO_SIZE GT_DEF_PCI0_IO_SIZE
-#endif
-
-extern unsigned long gt64240_base;
-
-#define GT64240_BASE (gt64240_base)
-
-/*
- * Because of an error/peculiarity in the Galileo chip, we need to swap the
- * bytes when running bigendian.
- */
-
-#define GT_WRITE(ofs, data) \
- *(volatile u32 *)(GT64240_BASE+(ofs)) = cpu_to_le32(data)
-#define GT_READ(ofs, data) \
- *(data) = le32_to_cpu(*(volatile u32 *)(GT64240_BASE+(ofs)))
-#define GT_READ_DATA(ofs) \
- le32_to_cpu(*(volatile u32 *)(GT64240_BASE+(ofs)))
-
-#define GT_WRITE_16(ofs, data) \
- *(volatile u16 *)(GT64240_BASE+(ofs)) = cpu_to_le16(data)
-#define GT_READ_16(ofs, data) \
- *(data) = le16_to_cpu(*(volatile u16 *)(GT64240_BASE+(ofs)))
-
-#define GT_WRITE_8(ofs, data) \
- *(volatile u8 *)(GT64240_BASE+(ofs)) = data
-#define GT_READ_8(ofs, data) \
- *(data) = *(volatile u8 *)(GT64240_BASE+(ofs))
-
-#endif /* _ASM_GT64120_MOMENCO_OCELOT_GT64120_DEP_H */
+++ /dev/null
-/*
- * Copyright 2002 Momentum Computer Inc.
- * Author: Matthew Dharm <mdharm@momenco.com>
- *
- * Based on work for the Linux port to the Ocelot board, which is
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- *
- * arch/mips/momentum/ocelot_g/pci.c
- * Board-specific PCI routines for gt64240 controller.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <asm/pci.h>
-
-
-void __devinit gt64240_board_pcibios_fixup_bus(struct pci_bus *bus)
-{
- struct pci_bus *current_bus = bus;
- struct pci_dev *devices;
- struct list_head *devices_link;
- u16 cmd;
-
- /* loop over all known devices on this bus */
- list_for_each(devices_link, &(current_bus->devices)) {
-
- devices = pci_dev_b(devices_link);
- if (devices == NULL)
- continue;
-
- if ((current_bus->number == 0) &&
- PCI_SLOT(devices->devfn) == 1) {
- /* Intel 82543 Gigabit MAC */
- devices->irq = 2; /* irq_nr is 2 for INT0 */
- } else if ((current_bus->number == 0) &&
- PCI_SLOT(devices->devfn) == 2) {
- /* Intel 82543 Gigabit MAC */
- devices->irq = 3; /* irq_nr is 3 for INT1 */
- } else if ((current_bus->number == 1) &&
- PCI_SLOT(devices->devfn) == 3) {
- /* Intel 21555 bridge */
- devices->irq = 5; /* irq_nr is 8 for INT6 */
- } else if ((current_bus->number == 1) &&
- PCI_SLOT(devices->devfn) == 4) {
- /* PMC Slot */
- devices->irq = 9; /* irq_nr is 9 for INT7 */
- } else {
- /* We don't have assign interrupts for other devices. */
- devices->irq = 0xff;
- }
-
- /* Assign an interrupt number for the device */
- bus->ops->write(current_bus, devices,
- PCI_INTERRUPT_LINE, 1, devices->irq);
-
- /* enable master for everything but the GT-64240 */
- if (((current_bus->number != 0) && (current_bus->number != 1))
- || (PCI_SLOT(devices->devfn) != 0)) {
- bus->ops->read(current_bus, devices,
- PCI_COMMAND, 2, &cmd);
- cmd |= PCI_COMMAND_MASTER;
- bus->ops->write(current_bus, devices,
- PCI_COMMAND, 2, cmd);
- }
- }
-}
+++ /dev/null
-/*
- * arch/mips/vr41xx/nec-eagle/pci_fixup.c
- *
- * The NEC Eagle/Hawk Board specific PCI fixups.
- *
- * Author: Yoichi Yuasa <you@mvista.com, or source@mvista.com>
- *
- * 2001-2002,2004 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/eagle.h>
-#include <asm/vr41xx/vrc4173.h>
-
-/*
- * Shortcuts
- */
-#define INTA CP_INTA_IRQ
-#define INTB CP_INTB_IRQ
-#define INTC CP_INTC_IRQ
-#define INTD CP_INTD_IRQ
-#define PCMCIA1 VRC4173_PCMCIA1_IRQ
-#define PCMCIA2 VRC4173_PCMCIA2_IRQ
-#define LAN LANINTA_IRQ
-#define SLOT PCISLOT_IRQ
-
-static char irq_tab_eagle[][5] __initdata = {
- [ 8] = { 0, INTA, INTB, INTC, INTD },
- [ 9] = { 0, INTD, INTA, INTB, INTC },
- [10] = { 0, INTC, INTD, INTA, INTB },
- [12] = { 0, PCMCIA1, 0, 0, 0 },
- [13] = { 0, PCMCIA2, 0, 0, 0 },
- [28] = { 0, LAN, 0, 0, 0 },
- [29] = { 0, SLOT, INTB, INTC, INTD },
-};
-
-/*
- * This is a multifunction device.
- */
-static char irq_func_tab[] __initdata = {
- VRC4173_CASCADE_IRQ,
- VRC4173_AC97_IRQ,
- VRC4173_USB_IRQ
-};
-
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
- if (slot == 30)
- return irq_func_tab[PCI_FUNC(dev->devfn)];
-
- return irq_tab_eagle[slot][pin];
-}
-
-struct pci_fixup pcibios_fixups[] __initdata = {
- { .pass = 0, },
-};
+++ /dev/null
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Marvell MV64340 interrupt fixup code.
- *
- * Marvell wants an NDA for their docs so this was written without
- * documentation. You've been warned.
- *
- * Copyright (C) 2004 Ralf Baechle
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/mipsregs.h>
-#include <asm/pci_channel.h>
-
-/*
- * WARNING: Example of how _NOT_ to do it.
- */
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
- int bus = dev->bus->number;
-
- if (bus == 0 && slot == 1)
- return 3; /* PCI-X A */
- if (bus == 0 && slot == 2)
- return 4; /* PCI-X B */
- if (bus == 1 && slot == 1)
- return 5; /* PCI A */
- if (bus == 1 && slot == 2)
- return 6; /* PCI B */
-
-return 0;
- panic("Whooops in pcibios_map_irq");
-}
-
-struct pci_fixup pcibios_fixups[] = {
- {0}
-};
+++ /dev/null
-/*
- * FILE NAME
- * arch/mips/vr41xx/tanbac-tb0229/pci_fixup.c
- *
- * BRIEF MODULE DESCRIPTION
- * The TANBAC TB0229(VR4131DIMM) specific PCI fixups.
- *
- * Copyright 2003 Megasolution Inc.
- * matsu@megasolution.jp
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/tb0229.h>
-
-void __init pcibios_fixup_irqs(void)
-{
-#ifdef CONFIG_TANBAC_TB0219
- struct pci_dev *dev = NULL;
- u8 slot;
-
- while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
- slot = PCI_SLOT(dev->devfn);
- dev->irq = 0;
-
- switch (slot) {
- case 12:
- vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN,
- TRIGGER_LEVEL,
- SIGNAL_THROUGH);
- vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN,
- LEVEL_LOW);
- dev->irq = TB0219_PCI_SLOT1_IRQ;
- break;
- case 13:
- vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN,
- TRIGGER_LEVEL,
- SIGNAL_THROUGH);
- vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN,
- LEVEL_LOW);
- dev->irq = TB0219_PCI_SLOT2_IRQ;
- break;
- case 14:
- vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN,
- TRIGGER_LEVEL,
- SIGNAL_THROUGH);
- vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN,
- LEVEL_LOW);
- dev->irq = TB0219_PCI_SLOT3_IRQ;
- break;
- default:
- break;
- }
-
- pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
- }
-#endif
-}
+++ /dev/null
-/*
- * FILE NAME
- * arch/mips/vr41xx/victor-mpc30x/pci_fixup.c
- *
- * BRIEF MODULE DESCRIPTION
- * The Victor MP-C303/304 specific PCI fixups.
- *
- * Copyright 2002 Yoichi Yuasa
- * yuasa@hh.iij4u.or.jp
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/vr41xx/vrc4173.h>
-#include <asm/vr41xx/mpc30x.h>
-
-/*
- * Shortcuts
- */
-#define PCMCIA1 VRC4173_PCMCIA1_IRQ
-#define PCMCIA2 VRC4173_PCMCIA2_IRQ
-#define MQ MQ200_IRQ
-
-static const int internal_func_irqs[8] __initdata = {
- VRC4173_CASCADE_IRQ,
- VRC4173_AC97_IRQ,
- VRC4173_USB_IRQ,
-
-};
-
-static char irq_tab_mpc30x[][5] __initdata = {
- [12] = { PCMCIA1, PCMCIA1, 0, 0 },
- [13] = { PCMCIA2, PCMCIA2, 0, 0 },
- [29] = { MQ, MQ, 0, 0 }, /* mediaQ MQ-200 */
-};
-
-int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
-{
- if (slot == 30)
- return internal_func_irqs[PCI_FUNC(dev->devfn)];
-
- return irq_tab_mpc30x[slot][pin];
-}
+++ /dev/null
-/*
- * Copyright 2002 Momentum Computer
- * Author: Matthew Dharm <mdharm@momenco.com>
- *
- * Copyright (C) 2003, 2004 Ralf Baechle (ralf@linux-mips.org)
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <asm/mv64340.h>
-
-/*
- * galileo_pcibios_(read/write)_config_(dword/word/byte) -
- *
- * reads/write a dword/word/byte register from the configuration space
- * of a device.
- *
- * Note that bus 0 and bus 1 are local, and we assume all other busses are
- * bridged from bus 1. This is a safe assumption, since any other
- * configuration will require major modifications to the CP7000G
- *
- * Inputs :
- * bus - bus number
- * dev - device number
- * offset - register offset in the configuration space
- * val - value to be written / read
- *
- * Outputs :
- * PCIBIOS_SUCCESSFUL when operation was succesfull
- * PCIBIOS_DEVICE_NOT_FOUND when the bus or dev is errorneous
- * PCIBIOS_BAD_REGISTER_NUMBER when accessing non aligned
- */
-
-static int mv64340_read_config(struct pci_bus *bus, unsigned int devfn, int reg,
- int size, u32 * val, u32 address_reg, u32 data_reg)
-{
- u32 address;
-
- /* Accessing device 31 crashes the MV-64340. */
- if (PCI_SLOT(devfn) > 5)
- return PCIBIOS_DEVICE_NOT_FOUND;
-
- address = (bus->number << 16) | (devfn << 8) |
- (reg & 0xfc) | 0x80000000;
-
- /* start the configuration cycle */
- MV_WRITE(address_reg, address);
-
- switch (size) {
- case 1:
- *val = MV_READ_8(data_reg + (reg & 0x3));
- break;
-
- case 2:
- *val = MV_READ_16(data_reg + (reg & 0x3));
- break;
-
- case 4:
- *val = MV_READ(data_reg);
- break;
- }
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-static int mv64340_write_config(struct pci_bus *bus, unsigned int devfn,
- int reg, int size, u32 val, u32 address_reg, u32 data_reg)
-{
- u32 address;
-
- /* Accessing device 31 crashes the MV-64340. */
- if (PCI_SLOT(devfn) > 5)
- return PCIBIOS_DEVICE_NOT_FOUND;
-
- address = (bus->number << 16) | (devfn << 8) |
- (reg & 0xfc) | 0x80000000;
-
- /* start the configuration cycle */
- MV_WRITE(address_reg, address);
-
- switch (size) {
- case 1:
- /* write the data */
- MV_WRITE_8(data_reg + (reg & 0x3), val);
- break;
-
- case 2:
- /* write the data */
- MV_WRITE_16(data_reg + (reg & 0x3), val);
- break;
-
- case 4:
- /* write the data */
- MV_WRITE(data_reg, val);
- break;
- }
-
- return PCIBIOS_SUCCESSFUL;
-}
-
-#define BUILD_PCI_OPS(host) \
- \
-static int mv64340_bus ## host ## _read_config(struct pci_bus *bus, \
- unsigned int devfn, int reg, int size, u32 * val) \
-{ \
- return mv64340_read_config(bus, devfn, reg, size, val, \
- MV64340_PCI_ ## host ## _CONFIG_ADDR, \
- MV64340_PCI_ ## host ## _CONFIG_DATA_VIRTUAL_REG); \
-} \
- \
-static int mv64340_bus ## host ## _write_config(struct pci_bus *bus, \
- unsigned int devfn, int reg, int size, u32 val) \
-{ \
- return mv64340_write_config(bus, devfn, reg, size, val, \
- MV64340_PCI_ ## host ## _CONFIG_ADDR, \
- MV64340_PCI_ ## host ## _CONFIG_DATA_VIRTUAL_REG); \
-} \
- \
-struct pci_ops mv64340_bus ## host ## _pci_ops = { \
- .read = mv64340_bus ## host ## _read_config, \
- .write = mv64340_bus ## host ## _write_config \
-};
-
-BUILD_PCI_OPS(0)
-BUILD_PCI_OPS(1)
+++ /dev/null
-/*
- * FILE NAME
- * arch/mips/vr41xx/nec-eagle/vrc4173.c
- *
- * BRIEF MODULE DESCRIPTION
- * Pre-setup for NEC VRC4173.
- *
- * Author: Yoichi Yuasa
- * yyuasa@mvista.com or source@mvista.com
- *
- * Copyright 2001,2002 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/module.h>
-
-#include <asm/io.h>
-#include <asm/vr41xx/eagle.h>
-#include <asm/vr41xx/vrc4173.h>
-
-#define PCI_CONFIG_ADDR KSEG1ADDR(0x0f000c18)
-#define PCI_CONFIG_DATA KSEG1ADDR(0x0f000c14)
-
-static inline void config_writeb(u8 reg, u8 val)
-{
- u32 data;
- int shift;
-
- writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR);
- data = readl(PCI_CONFIG_DATA);
-
- shift = (reg & 3) << 3;
- data &= ~(0xff << shift);
- data |= (((u32) val) << shift);
-
- writel(data, PCI_CONFIG_DATA);
-}
-
-static inline u16 config_readw(u8 reg)
-{
- u32 data;
-
- writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR);
- data = readl(PCI_CONFIG_DATA);
-
- return (u16) (data >> ((reg & 2) << 3));
-}
-
-static inline u32 config_readl(u8 reg)
-{
- writel(((1UL << 30) | (reg & 0xfc)), PCI_CONFIG_ADDR);
-
- return readl(PCI_CONFIG_DATA);
-}
-
-static inline void config_writel(u8 reg, u32 val)
-{
- writel((1UL << 0x1e) | (reg & 0xfc), PCI_CONFIG_ADDR);
- writel(val, PCI_CONFIG_DATA);
-}
-
-void __init vrc4173_preinit(void)
-{
- u32 cmdsts, base;
- u16 cmu_mask;
-
-
- if ((config_readw(PCI_VENDOR_ID) == PCI_VENDOR_ID_NEC) &&
- (config_readw(PCI_DEVICE_ID) == PCI_DEVICE_ID_NEC_VRC4173)) {
- /*
- * Initialized NEC VRC4173 Bus Control Unit
- */
- cmdsts = config_readl(PCI_COMMAND);
- config_writel(PCI_COMMAND,
- cmdsts |
- PCI_COMMAND_IO |
- PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
-
- config_writeb(PCI_LATENCY_TIMER, 0x80);
-
- config_writel(PCI_BASE_ADDRESS_0, VR41XX_PCI_IO_START);
- base = config_readl(PCI_BASE_ADDRESS_0);
- base &= PCI_BASE_ADDRESS_IO_MASK;
- config_writeb(0x40, 0x01);
-
- /* CARDU1 IDSEL = AD12, CARDU2 IDSEL = AD13 */
- config_writeb(0x41, 0);
-
- cmu_mask = 0x1000;
- outw(cmu_mask, base + 0x040);
- cmu_mask |= 0x0800;
- outw(cmu_mask, base + 0x040);
-
- outw(0x000f, base + 0x042); /* Soft reset of CMU */
- cmu_mask |= 0x05e0;
- outw(cmu_mask, base + 0x040);
- cmu_mask = inw(base + 0x040); /* dummy read */
- outw(0x0000, base + 0x042);
- }
-}
+++ /dev/null
-#
-# Makefile for the NEC Eagle/Hawk specific parts of the kernel
-#
-# Author: Yoichi Yuasa
-# yyuasa@mvista.com or source@mvista.com
-#
-# Copyright 2001,2002 MontaVista Software Inc.
-#
-
-obj-y += irq.o setup.o
+++ /dev/null
-/*
- * irq.c, Interrupt routines for the NEC Eagle/Hawk board.
- *
- * Copyright (C) 2002 MontaVista Software, Inc.
- * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
- * Copyright (C) 2004 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*
- * Changes:
- * MontaVista Software Inc. <yyuasa@mvista.com> or <source@mvista.com>
- * - New creation, NEC Eagle is supported.
- * - Added support for NEC Hawk.
- *
- * Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
- * - Changed from board_irq_init to driver module.
- */
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-
-#include <asm/io.h>
-#include <asm/vr41xx/eagle.h>
-
-MODULE_DESCRIPTION("IRQ module driver for NEC Eagle/Hawk");
-MODULE_AUTHOR("Yoichi Yuasa <yyuasa@mvista.com>");
-MODULE_LICENSE("GPL");
-
-static void enable_pciint_irq(unsigned int irq)
-{
- uint8_t val;
-
- val = readb(NEC_EAGLE_PCIINTMSKREG);
- val |= (uint8_t)1 << (irq - PCIINT_IRQ_BASE);
- writeb(val, NEC_EAGLE_PCIINTMSKREG);
-}
-
-static void disable_pciint_irq(unsigned int irq)
-{
- uint8_t val;
-
- val = readb(NEC_EAGLE_PCIINTMSKREG);
- val &= ~((uint8_t)1 << (irq - PCIINT_IRQ_BASE));
- writeb(val, NEC_EAGLE_PCIINTMSKREG);
-}
-
-static unsigned int startup_pciint_irq(unsigned int irq)
-{
- enable_pciint_irq(irq);
- return 0; /* never anything pending */
-}
-
-#define shutdown_pciint_irq disable_pciint_irq
-#define ack_pciint_irq disable_pciint_irq
-
-static void end_pciint_irq(unsigned int irq)
-{
- if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
- enable_pciint_irq(irq);
-}
-
-static struct hw_interrupt_type pciint_irq_type = {
- .typename = "PCIINT",
- .startup = startup_pciint_irq,
- .shutdown = shutdown_pciint_irq,
- .enable = enable_pciint_irq,
- .disable = disable_pciint_irq,
- .ack = ack_pciint_irq,
- .end = end_pciint_irq,
-};
-
-static void enable_sdbint_irq(unsigned int irq)
-{
- uint8_t val;
-
- val = readb(NEC_EAGLE_SDBINTMSK);
- val |= (uint8_t)1 << (irq - SDBINT_IRQ_BASE);
- writeb(val, NEC_EAGLE_SDBINTMSK);
-}
-
-static void disable_sdbint_irq(unsigned int irq)
-{
- uint8_t val;
-
- val = readb(NEC_EAGLE_SDBINTMSK);
- val &= ~((uint8_t)1 << (irq - SDBINT_IRQ_BASE));
- writeb(val, NEC_EAGLE_SDBINTMSK);
-}
-
-static unsigned int startup_sdbint_irq(unsigned int irq)
-{
- enable_sdbint_irq(irq);
- return 0; /* never anything pending */
-}
-
-#define shutdown_sdbint_irq disable_sdbint_irq
-#define ack_sdbint_irq disable_sdbint_irq
-
-static void end_sdbint_irq(unsigned int irq)
-{
- if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
- enable_sdbint_irq(irq);
-}
-
-static struct hw_interrupt_type sdbint_irq_type = {
- .typename = "SDBINT",
- .startup = startup_sdbint_irq,
- .shutdown = shutdown_sdbint_irq,
- .enable = enable_sdbint_irq,
- .disable = disable_sdbint_irq,
- .ack = ack_sdbint_irq,
- .end = end_sdbint_irq,
-};
-
-static int eagle_get_irq_number(int irq)
-{
- uint8_t sdbint, pciint;
- int i;
-
- sdbint = readb(NEC_EAGLE_SDBINT);
- sdbint &= (NEC_EAGLE_SDBINT_DEG | NEC_EAGLE_SDBINT_ENUM |
- NEC_EAGLE_SDBINT_SIO1INT | NEC_EAGLE_SDBINT_SIO2INT |
- NEC_EAGLE_SDBINT_PARINT);
- pciint = readb(NEC_EAGLE_PCIINTREG);
- pciint &= (NEC_EAGLE_PCIINT_CP_INTA | NEC_EAGLE_PCIINT_CP_INTB |
- NEC_EAGLE_PCIINT_CP_INTC | NEC_EAGLE_PCIINT_CP_INTD |
- NEC_EAGLE_PCIINT_LANINT);
-
- for (i = 1; i < 6; i++)
- if (sdbint & (0x01 << i))
- return SDBINT_IRQ_BASE + i;
-
- for (i = 0; i < 5; i++)
- if (pciint & (0x01 << i))
- return PCIINT_IRQ_BASE + i;
-
- return -EINVAL;
-}
-
-static int __devinit eagle_irq_init(void)
-{
- int i, retval;
-
- writeb(0, NEC_EAGLE_SDBINTMSK);
- writeb(0, NEC_EAGLE_PCIINTMSKREG);
-
- vr41xx_set_irq_trigger(PCISLOT_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
- vr41xx_set_irq_level(PCISLOT_PIN, LEVEL_HIGH);
-
- vr41xx_set_irq_trigger(FPGA_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
- vr41xx_set_irq_level(FPGA_PIN, LEVEL_HIGH);
-
- vr41xx_set_irq_trigger(DCD_PIN, TRIGGER_EDGE, SIGNAL_HOLD);
- vr41xx_set_irq_level(DCD_PIN, LEVEL_LOW);
-
- for (i = SDBINT_IRQ_BASE; i <= SDBINT_IRQ_LAST; i++)
- irq_desc[i].handler = &sdbint_irq_type;
-
- for (i = PCIINT_IRQ_BASE; i <= PCIINT_IRQ_LAST; i++)
- irq_desc[i].handler = &pciint_irq_type;
-
- retval = vr41xx_cascade_irq(FPGA_CASCADE_IRQ, eagle_get_irq_number);
- if (retval != 0)
- printk(KERN_ERR "eagle: Cannot cascade IRQ %d\n", FPGA_CASCADE_IRQ);
-
- return retval;
-}
-
-static void __devexit eagle_irq_exit(void)
-{
- free_irq(FPGA_CASCADE_IRQ, NULL);
-}
-
-module_init(eagle_irq_init);
-module_exit(eagle_irq_exit);
+++ /dev/null
-/*
- * arch/mips/vr41xx/nec-eagle/setup.c
- *
- * Setup for the NEC Eagle/Hawk board.
- *
- * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com>
- *
- * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/config.h>
-#include <linux/ioport.h>
-
-#include <asm/io.h>
-#include <asm/pci_channel.h>
-#include <asm/vr41xx/eagle.h>
-
-#ifdef CONFIG_PCI
-
-extern void vrc4173_preinit(void);
-
-static struct resource vr41xx_pci_io_resource = {
- "PCI I/O space",
- VR41XX_PCI_IO_START,
- VR41XX_PCI_IO_END,
- IORESOURCE_IO
-};
-
-static struct resource vr41xx_pci_mem_resource = {
- "PCI memory space",
- VR41XX_PCI_MEM_START,
- VR41XX_PCI_MEM_END,
- IORESOURCE_MEM
-};
-
-extern struct pci_ops vr41xx_pci_ops;
-
-struct pci_controller vr41xx_controller = {
- .pci_ops = &vr41xx_pci_ops,
- .io_resource = &vr41xx_pci_io_resource,
- .mem_resource = &vr41xx_pci_mem_resource,
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_mem1 = {
- VR41XX_PCI_MEM1_BASE,
- VR41XX_PCI_MEM1_MASK,
- IO_MEM1_RESOURCE_START
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_mem2 = {
- VR41XX_PCI_MEM2_BASE,
- VR41XX_PCI_MEM2_MASK,
- IO_MEM2_RESOURCE_START
-};
-
-struct vr41xx_pci_address_space vr41xx_pci_io = {
- VR41XX_PCI_IO_BASE,
- VR41XX_PCI_IO_MASK,
- IO_PORT_RESOURCE_START
-};
-
-static struct vr41xx_pci_address_map pci_address_map = {
- &vr41xx_pci_mem1,
- &vr41xx_pci_mem2,
- &vr41xx_pci_io
-};
-#endif
-
-const char *get_system_type(void)
-{
- return "NEC SDB-VR4122/VR4131(Eagle/Hawk)";
-}
-
-static int nec_eagle_setup(void)
-{
- set_io_port_base(IO_PORT_BASE);
- ioport_resource.start = IO_PORT_RESOURCE_START;
- ioport_resource.end = IO_PORT_RESOURCE_END;
-
-#ifdef CONFIG_SERIAL_8250
- vr41xx_select_siu_interface(SIU_RS232C, IRDA_NONE);
- vr41xx_siu_init();
- vr41xx_dsiu_init();
-#endif
-
-#ifdef CONFIG_PCI
- vr41xx_pciu_init(&pci_address_map);
-
- vrc4173_preinit();
-#endif
-
- return 0;
-}
-
-early_initcall(nec_eagle_setup);
+++ /dev/null
-/*
- * FILE NAME
- * arch/mips/vr41xx/tanbac-tb0229/reboot.c
- *
- * BRIEF MODULE DESCRIPTION
- * Depending on TANBAC TB0229(VR4131DIMM) of reboot system call.
- *
- * Copyright 2003 Megasolution Inc.
- * matsu@megasolution.jp
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#include <linux/config.h>
-#include <asm/io.h>
-#include <asm/vr41xx/tb0229.h>
-
-#define tb0229_hard_reset() writew(0, TB0219_RESET_REGS)
-
-void tanbac_tb0229_restart(char *command)
-{
- local_irq_disable();
- tb0229_hard_reset();
- while (1);
-}
+++ /dev/null
-/*
- * General Purpose functions for the global management of the
- * 8260 Communication Processor Module.
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- * Copyright (c) 2000 MontaVista Software, Inc (source@mvista.com)
- * 2.3.99 Updates
- *
- * In addition to the individual control of the communication
- * channels, there are a few functions that globally affect the
- * communication processor.
- *
- * Buffer descriptors must be allocated from the dual ported memory
- * space. The allocator for that is here. When the communication
- * process is reset, we reclaim the memory available. There is
- * currently no deallocator for this memory.
- */
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/param.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/bootmem.h>
-#include <asm/irq.h>
-#include <asm/mpc8260.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/immap_8260.h>
-#include <asm/cpm_8260.h>
-
-static uint dp_alloc_base; /* Starting offset in DP ram */
-static uint dp_alloc_top; /* Max offset + 1 */
-static uint host_buffer; /* One page of host buffer */
-static uint host_end; /* end + 1 */
-cpm8260_t *cpmp; /* Pointer to comm processor space */
-
-/* We allocate this here because it is used almost exclusively for
- * the communication processor devices.
- */
-immap_t *immr;
-
-void
-m8260_cpm_reset(void)
-{
- volatile immap_t *imp;
- volatile cpm8260_t *commproc;
- uint vpgaddr;
-
- immr = imp = (volatile immap_t *)IMAP_ADDR;
- commproc = &imp->im_cpm;
-
- /* Reclaim the DP memory for our use.
- */
- dp_alloc_base = CPM_DATAONLY_BASE;
- dp_alloc_top = dp_alloc_base + CPM_DATAONLY_SIZE;
-
- /* Set the host page for allocation.
- */
- host_buffer =
- (uint) alloc_bootmem_pages(PAGE_SIZE * NUM_CPM_HOST_PAGES);
- host_end = host_buffer + (PAGE_SIZE * NUM_CPM_HOST_PAGES);
-
- vpgaddr = host_buffer;
-
- /* Tell everyone where the comm processor resides.
- */
- cpmp = (cpm8260_t *)commproc;
-}
-
-/* Allocate some memory from the dual ported ram.
- * To help protocols with object alignment restrictions, we do that
- * if they ask.
- */
-uint
-m8260_cpm_dpalloc(uint size, uint align)
-{
- uint retloc;
- uint align_mask, off;
- uint savebase;
-
- align_mask = align - 1;
- savebase = dp_alloc_base;
-
- if ((off = (dp_alloc_base & align_mask)) != 0)
- dp_alloc_base += (align - off);
-
- if ((dp_alloc_base + size) >= dp_alloc_top) {
- dp_alloc_base = savebase;
- return(CPM_DP_NOSPACE);
- }
-
- retloc = dp_alloc_base;
- dp_alloc_base += size;
-
- return(retloc);
-}
-
-/* We also own one page of host buffer space for the allocation of
- * UART "fifos" and the like.
- */
-uint
-m8260_cpm_hostalloc(uint size, uint align)
-{
- uint retloc;
- uint align_mask, off;
- uint savebase;
-
- align_mask = align - 1;
- savebase = host_buffer;
-
- if ((off = (host_buffer & align_mask)) != 0)
- host_buffer += (align - off);
-
- if ((host_buffer + size) >= host_end) {
- host_buffer = savebase;
- return(0);
- }
-
- retloc = host_buffer;
- host_buffer += size;
-
- return(retloc);
-}
-
-/* Set a baud rate generator. This needs lots of work. There are
- * eight BRGs, which can be connected to the CPM channels or output
- * as clocks. The BRGs are in two different block of internal
- * memory mapped space.
- * The baud rate clock is the system clock divided by something.
- * It was set up long ago during the initial boot phase and is
- * is given to us.
- * Baud rate clocks are zero-based in the driver code (as that maps
- * to port numbers). Documentation uses 1-based numbering.
- */
-#define BRG_INT_CLK (((bd_t *)__res)->bi_brgfreq)
-#define BRG_UART_CLK (BRG_INT_CLK/16)
-
-/* This function is used by UARTS, or anything else that uses a 16x
- * oversampled clock.
- */
-void
-m8260_cpm_setbrg(uint brg, uint rate)
-{
- volatile uint *bp;
-
- /* This is good enough to get SMCs running.....
- */
- if (brg < 4) {
- bp = (uint *)&immr->im_brgc1;
- }
- else {
- bp = (uint *)&immr->im_brgc5;
- brg -= 4;
- }
- bp += brg;
- *bp = ((BRG_UART_CLK / rate) << 1) | CPM_BRG_EN;
-}
-
-/* This function is used to set high speed synchronous baud rate
- * clocks.
- */
-void
-m8260_cpm_fastbrg(uint brg, uint rate, int div16)
-{
- volatile uint *bp;
-
- if (brg < 4) {
- bp = (uint *)&immr->im_brgc1;
- }
- else {
- bp = (uint *)&immr->im_brgc5;
- brg -= 4;
- }
- bp += brg;
- *bp = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN;
- if (div16)
- *bp |= CPM_BRG_DIV16;
-}
+++ /dev/null
-/*
- * UART driver for MPC8260 CPM SCC or SMC
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- * Copyright (c) 2000 MontaVista Software, Inc. (source@mvista.com)
- * 2.3.99 updates
- * Copyright (c) 2002 Allen Curtis, Ones and Zeros, Inc. (acurtis@onz.com)
- * 2.5.50 updates
- * Fix the console driver to be registered with initcalls and some minor fixup
- * for 2.6.2, by Petter Larsen, moreCom as (petter.larsen@morecom.no) and
- * Miguel Valero, AxxessIT ASA (miguel.valero@axxessit.no)
- *
- * I used the 8xx uart.c driver as the framework for this driver.
- * The original code was written for the EST8260 board. I tried to make
- * it generic, but there may be some assumptions in the structures that
- * have to be fixed later.
- *
- * The 8xx and 8260 are similar, but not identical. Over time we
- * could probably merge these two drivers.
- * To save porting time, I did not bother to change any object names
- * that are not accessed outside of this file.
- * It still needs lots of work........When it was easy, I included code
- * to support the SCCs.
- * Only the SCCs support modem control, so that is not complete either.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/uaccess.h>
-#include <asm/immap_8260.h>
-#include <asm/mpc8260.h>
-#include <asm/cpm_8260.h>
-#include <asm/irq.h>
-
-#ifdef CONFIG_MAGIC_SYSRQ
-#include <linux/sysrq.h>
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-#include <linux/console.h>
-
-/* SCC Console configuration. Not quite finished. The SCC_CONSOLE
- * should be the number of the SCC to use, but only SCC1 will
- * work at this time.
- */
-#ifdef CONFIG_SCC_CONSOLE
-#define SCC_CONSOLE 1
-#endif
-
-/* this defines the index into rs_table for the port to use
-*/
-#ifndef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT 0
-#endif
-#endif
-#define CONFIG_SERIAL_CONSOLE_PORT 0
-
-#define TX_WAKEUP ASYNC_SHARE_IRQ
-
-static char *serial_name = "CPM UART driver";
-static char *serial_version = "0.02";
-
-static struct tty_driver *serial_driver;
-static int __init serial_console_setup( struct console *co, char *options);
-static void serial_console_write(struct console *c, const char *s,
- unsigned count);
-
-static struct tty_driver *serial_console_device(struct console *c, int *index);
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-static unsigned long break_pressed; /* break, really ... */
-#endif
-
-/*
- * Serial driver configuration section. Here are the various options:
- */
-#define SERIAL_PARANOIA_CHECK
-#define CONFIG_SERIAL_NOPAUSE_IO
-#define SERIAL_DO_RESTART
-
-/* Set of debugging defines */
-
-#undef SERIAL_DEBUG_INTR
-#undef SERIAL_DEBUG_OPEN
-#undef SERIAL_DEBUG_FLOW
-#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-
-#define _INLINE_ inline
-
-#define DBG_CNT(s)
-
-/* We overload some of the items in the data structure to meet our
- * needs. For example, the port address is the CPM parameter ram
- * offset for the SCC or SMC. The maximum number of ports is 4 SCCs and
- * 2 SMCs. The "hub6" field is used to indicate the channel number, with
- * 0 and 1 indicating the SMCs and 2, 3, 4, and 5 are the SCCs.
- * Since these ports are so versatile, I don't yet have a strategy for
- * their management. For example, SCC1 is used for Ethernet. Right
- * now, just don't put them in the table. Of course, right now I just
- * want the SMC to work as a uart :-)..
- * The "type" field is currently set to 0, for PORT_UNKNOWN. It is
- * not currently used. I should probably use it to indicate the port
- * type of CMS or SCC.
- * The SMCs do not support any modem control signals.
- */
-#define smc_scc_num hub6
-
-/* The choice of serial port to use for KGDB. If the system has
- * two ports, you can use one for console and one for KGDB (which
- * doesn't make sense to me, but people asked for it).
- */
-#ifdef CONFIG_KGDB_TTYS1
-#define KGDB_SER_IDX 1 /* SCC2/SMC2 */
-#else
-#define KGDB_SER_IDX 0 /* SCC1/SMC1 */
-#endif
-
-#ifndef SCC_CONSOLE
-
-/* SMC2 is sometimes used for low performance TDM interfaces. Define
- * this as 1 if you want SMC2 as a serial port UART managed by this driver.
- * Define this as 0 if you wish to use SMC2 for something else.
- */
-#define USE_SMC2 1
-
-/* Define SCC to ttySx mapping.
-*/
-#define SCC_NUM_BASE (USE_SMC2 + 1) /* SCC base tty "number" */
-
-/* Define which SCC is the first one to use for a serial port. These
- * are 0-based numbers, i.e. this assumes the first SCC (SCC1) is used
- * for Ethernet, and the first available SCC for serial UART is SCC2.
- * NOTE: IF YOU CHANGE THIS, you have to change the PROFF_xxx and
- * interrupt vectors in the table below to match.
- */
-#define SCC_IDX_BASE 1 /* table index */
-
-static struct serial_state rs_table[] = {
- /* UART CLK PORT IRQ FLAGS NUM */
- { 0, 0, PROFF_SMC1, SIU_INT_SMC1, 0, 0 }, /* SMC1 ttyS0 */
-#ifdef USE_SMC2
- { 0, 0, PROFF_SMC2, SIU_INT_SMC2, 0, 1 }, /* SMC2 ttyS1 */
-#endif
-#ifndef CONFIG_SCC1_ENET
- { 0, 0, PROFF_SCC1, SIU_INT_SCC1, 0, SCC_NUM_BASE}, /* SCC1 ttyS2 */
-#endif
-#if !defined(CONFIG_SBC82xx) && !defined(CONFIG_SCC2_ENET)
- { 0, 0, PROFF_SCC2, SIU_INT_SCC2, 0, SCC_NUM_BASE + 1}, /* SCC2 ttyS3 */
-#endif
-};
-
-#else /* SCC_CONSOLE */
-#define SCC_NUM_BASE 0 /* SCC base tty "number" */
-#define SCC_IDX_BASE 0 /* table index */
-static struct serial_state rs_table[] = {
- /* UART CLK PORT IRQ FLAGS NUM */
- { 0, 0, PROFF_SCC1, SIU_INT_SCC1, 0, SCC_NUM_BASE}, /* SCC1 ttyS2 */
- { 0, 0, PROFF_SCC2, SIU_INT_SCC2, 0, SCC_NUM_BASE + 1}, /* SCC2 ttyS3 */
-};
-#endif /* SCC_CONSOLE */
-
-#define PORT_NUM(P) (((P) < (SCC_NUM_BASE)) ? (P) : (P)-(SCC_NUM_BASE))
-
-#define NR_PORTS (sizeof(rs_table)/sizeof(struct serial_state))
-
-/* The number of buffer descriptors and their sizes.
-*/
-#define RX_NUM_FIFO 4
-#define RX_BUF_SIZE 32
-#define TX_NUM_FIFO 4
-#define TX_BUF_SIZE 32
-
-/* The async_struct in serial.h does not really give us what we
- * need, so define our own here.
- */
-typedef struct serial_info {
- int magic;
- int flags;
- struct serial_state *state;
- struct tty_struct *tty;
- int read_status_mask;
- int ignore_status_mask;
- int timeout;
- int line;
- int x_char; /* xon/xoff character */
- int close_delay;
- unsigned short closing_wait;
- unsigned short closing_wait2;
- unsigned long event;
- unsigned long last_active;
- int blocked_open; /* # of blocked opens */
- struct work_struct tqueue;
- struct work_struct tqueue_hangup;
- wait_queue_head_t open_wait;
- wait_queue_head_t close_wait;
-
- /* CPM Buffer Descriptor pointers.
- */
- cbd_t *rx_bd_base;
- cbd_t *rx_cur;
- cbd_t *tx_bd_base;
- cbd_t *tx_cur;
-} ser_info_t;
-
-static struct console sercons = {
- .name = "ttyS",
- .write = serial_console_write,
- .device = serial_console_device,
- .setup = serial_console_setup,
- .flags = CON_PRINTBUFFER,
- .index = CONFIG_SERIAL_CONSOLE_PORT,
-};
-
-static void change_speed(ser_info_t *info);
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout);
-
-static inline int serial_paranoia_check(ser_info_t *info,
- char *name, const char *routine)
-{
-#ifdef SERIAL_PARANOIA_CHECK
- static const char *badmagic =
- "Warning: bad magic number for serial struct (%s) in %s\n";
- static const char *badinfo =
- "Warning: null async_struct for (%s) in %s\n";
-
- if (!info) {
- printk(badinfo, name, routine);
- return 1;
- }
- if (info->magic != SERIAL_MAGIC) {
- printk(badmagic, name, routine);
- return 1;
- }
-#endif
- return 0;
-}
-
-/*
- * This is used to figure out the divisor speeds and the timeouts,
- * indexed by the termio value. The generic CPM functions are responsible
- * for setting and assigning baud rate generators for us.
- */
-static int baud_table[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
-
-
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter interrupts, as necessary.
- * ------------------------------------------------------------
- */
-static void rs_8xx_stop(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int idx;
- unsigned long flags;
- volatile scc_t *sccp;
- volatile smc_t *smcp;
-
- if (serial_paranoia_check(info, tty->name, "rs_stop"))
- return;
-
- save_flags(flags); cli();
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
- smcp->smc_smcm &= ~SMCM_TX;
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- sccp->scc_sccm &= ~UART_SCCM_TX;
- }
- restore_flags(flags);
-}
-
-static void rs_8xx_start(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int idx;
- unsigned long flags;
- volatile scc_t *sccp;
- volatile smc_t *smcp;
-
- if (serial_paranoia_check(info, tty->name, "rs_stop"))
- return;
-
- save_flags(flags); cli();
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
- smcp->smc_smcm |= SMCM_TX;
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- sccp->scc_sccm |= UART_SCCM_TX;
- }
- restore_flags(flags);
-}
-
-/*
- * ----------------------------------------------------------------------
- *
- * Here starts the interrupt handling routines. All of the following
- * subroutines are declared as inline and are folded into
- * rs_interrupt(). They were separated out for readability's sake.
- *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off. People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible. After you are done making modifications, it is not a bad
- * idea to do:
- *
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- * - Ted Ts'o (tytso@mit.edu), 7-Mar-93
- * -----------------------------------------------------------------------
- */
-
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static _INLINE_ void rs_sched_event(ser_info_t *info,
- int event)
-{
- info->event |= 1 << event;
- schedule_work(&info->tqueue);
-}
-
-static _INLINE_ void receive_chars(ser_info_t *info, struct pt_regs *regs)
-{
- struct tty_struct *tty = info->tty;
- unsigned char ch, *cp;
- /*int ignored = 0;*/
- int i;
- ushort status;
- struct async_icount *icount;
- volatile cbd_t *bdp;
-
- icount = &info->state->icount;
-
- /* Just loop through the closed BDs and copy the characters into
- * the buffer.
- */
- bdp = info->rx_cur;
- for (;;) {
- if (bdp->cbd_sc & BD_SC_EMPTY) /* If this one is empty */
- break; /* we are all done */
-
- /* The read status mask tell us what we should do with
- * incoming characters, especially if errors occur.
- * One special case is the use of BD_SC_EMPTY. If
- * this is not set, we are supposed to be ignoring
- * inputs. In this case, just mark the buffer empty and
- * continue.
- if (!(info->read_status_mask & BD_SC_EMPTY)) {
- bdp->cbd_sc |= BD_SC_EMPTY;
- bdp->cbd_sc &=
- ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = info->rx_bd_base;
- else
- bdp++;
- continue;
- }
- */
-
- /* Get the number of characters and the buffer pointer.
- */
- i = bdp->cbd_datlen;
- cp = (unsigned char *)__va(bdp->cbd_bufaddr);
- status = bdp->cbd_sc;
-#ifdef CONFIG_KGDB
- if (info->state->smc_scc_num == KGDB_SER_IDX) {
- if (*cp == 0x03 || *cp == '$')
- breakpoint();
- return;
- }
-#endif
-
- /* Check to see if there is room in the tty buffer for
- * the characters in our BD buffer. If not, we exit
- * now, leaving the BD with the characters. We'll pick
- * them up again on the next receive interrupt (which could
- * be a timeout).
- */
- if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE)
- break;
-
- while (i-- > 0) {
- ch = *cp++;
- *tty->flip.char_buf_ptr = ch;
- icount->rx++;
-
-#ifdef SERIAL_DEBUG_INTR
- printk("DR%02x:%02x...", ch, *status);
-#endif
- *tty->flip.flag_buf_ptr = 0;
- if (status & (BD_SC_BR | BD_SC_FR |
- BD_SC_PR | BD_SC_OV)) {
- /*
- * For statistics only
- */
- if (status & BD_SC_BR)
- icount->brk++;
- else if (status & BD_SC_PR)
- icount->parity++;
- else if (status & BD_SC_FR)
- icount->frame++;
- if (status & BD_SC_OV)
- icount->overrun++;
-
- /*
- * Now check to see if character should be
- * ignored, and mask off conditions which
- * should be ignored.
- if (status & info->ignore_status_mask) {
- if (++ignored > 100)
- break;
- continue;
- }
- */
- status &= info->read_status_mask;
-
- if (status & (BD_SC_BR)) {
-#ifdef SERIAL_DEBUG_INTR
- printk("handling break....");
-#endif
- *tty->flip.flag_buf_ptr = TTY_BREAK;
- if (info->flags & ASYNC_SAK)
- do_SAK(tty);
- } else if (status & BD_SC_PR)
- *tty->flip.flag_buf_ptr = TTY_PARITY;
- else if (status & BD_SC_FR)
- *tty->flip.flag_buf_ptr = TTY_FRAME;
- if (status & BD_SC_OV) {
- /*
- * Overrun is special, since it's
- * reported immediately, and doesn't
- * affect the current character
- */
- if (tty->flip.count < TTY_FLIPBUF_SIZE) {
- tty->flip.count++;
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- *tty->flip.flag_buf_ptr =
- TTY_OVERRUN;
- }
- }
- }
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- if (break_pressed && info->line == sercons.index) {
- if (ch != 0 && time_before(jiffies,
- break_pressed + HZ*5)) {
- handle_sysrq(ch, regs, NULL);
- break_pressed = 0;
- goto ignore_char;
- } else
- break_pressed = 0;
- }
-#endif
-
- if (tty->flip.count >= TTY_FLIPBUF_SIZE)
- break;
-
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- tty->flip.count++;
- }
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- ignore_char:
-#endif
-
- /* This BD is ready to be used again. Clear status.
- * Get next BD.
- */
- bdp->cbd_sc |= BD_SC_EMPTY;
- bdp->cbd_sc &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = info->rx_bd_base;
- else
- bdp++;
- }
-
- info->rx_cur = (cbd_t *)bdp;
-
- schedule_delayed_work(&tty->flip.work, 1);
-}
-
-static _INLINE_ void receive_break(ser_info_t *info, struct pt_regs *regs)
-{
- struct tty_struct *tty = info->tty;
-
- info->state->icount.brk++;
-
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- if (info->line == sercons.index) {
- if (!break_pressed) {
- break_pressed = jiffies;
- return;
- } else
- break_pressed = 0;
- }
-#endif
-
- /* Check to see if there is room in the tty buffer for
- * the break. If not, we exit now, losing the break. FIXME
- */
- if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE)
- return;
- *(tty->flip.flag_buf_ptr++) = TTY_BREAK;
- *(tty->flip.char_buf_ptr++) = 0;
- tty->flip.count++;
-}
-
-
-static _INLINE_ void transmit_chars(ser_info_t *info, struct pt_regs *regs)
-{
-
- if (info->flags & TX_WAKEUP) {
- rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
- }
-
-#ifdef SERIAL_DEBUG_INTR
- printk("THRE...");
-#endif
-}
-
-#ifdef notdef
- /* I need to do this for the SCCs, so it is left as a reminder.
- */
-static _INLINE_ void check_modem_status(struct async_struct *info)
-{
- int status;
- struct async_icount *icount;
-
- status = serial_in(info, UART_MSR);
-
- if (status & UART_MSR_ANY_DELTA) {
- icount = &info->state->icount;
- /* update input line counters */
- if (status & UART_MSR_TERI)
- icount->rng++;
- if (status & UART_MSR_DDSR)
- icount->dsr++;
- if (status & UART_MSR_DDCD) {
- icount->dcd++;
-#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
- (status & UART_MSR_DCD))
- hardpps();
-#endif
- }
- if (status & UART_MSR_DCTS)
- icount->cts++;
- wake_up_interruptible(&info->delta_msr_wait);
- }
-
- if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
-#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
- printk("ttys%d CD now %s...", info->line,
- (status & UART_MSR_DCD) ? "on" : "off");
-#endif
- if (status & UART_MSR_DCD)
- wake_up_interruptible(&info->open_wait);
- else {
-#ifdef SERIAL_DEBUG_OPEN
- printk("scheduling hangup...");
-#endif
- schedule_work(&info->tqueue_hangup);
- }
- }
- if (info->flags & ASYNC_CTS_FLOW) {
- if (info->tty->hw_stopped) {
- if (status & UART_MSR_CTS) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
- printk("CTS tx start...");
-#endif
- info->tty->hw_stopped = 0;
- info->IER |= UART_IER_THRI;
- serial_out(info, UART_IER, info->IER);
- rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
- return;
- }
- } else {
- if (!(status & UART_MSR_CTS)) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
- printk("CTS tx stop...");
-#endif
- info->tty->hw_stopped = 1;
- info->IER &= ~UART_IER_THRI;
- serial_out(info, UART_IER, info->IER);
- }
- }
- }
-}
-#endif
-
-/*
- * This is the serial driver's interrupt routine for a single port
- */
-static irqreturn_t rs_8xx_interrupt(int irq, void * dev_id, struct pt_regs * regs)
-{
- u_char events;
- int idx;
- ser_info_t *info;
- volatile smc_t *smcp;
- volatile scc_t *sccp;
-
- info = (ser_info_t *)dev_id;
-
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
- events = smcp->smc_smce;
- if (events & SMCM_BRKE)
- receive_break(info, regs);
- if (events & SMCM_RX)
- receive_chars(info, regs);
- if (events & SMCM_TX)
- transmit_chars(info, regs);
- smcp->smc_smce = events;
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- events = sccp->scc_scce;
- if (events & SMCM_BRKE)
- receive_break(info, regs);
- if (events & SCCM_RX)
- receive_chars(info, regs);
- if (events & SCCM_TX)
- transmit_chars(info, regs);
- sccp->scc_scce = events;
- }
-
-#ifdef SERIAL_DEBUG_INTR
- printk("rs_interrupt_single(%d, %x)...",
- info->state->smc_scc_num, events);
-#endif
-#ifdef modem_control
- check_modem_status(info);
-#endif
- info->last_active = jiffies;
-#ifdef SERIAL_DEBUG_INTR
- printk("end.\n");
-#endif
- return IRQ_HANDLED;
-}
-
-
-/*
- * -------------------------------------------------------------------
- * Here ends the serial interrupt routines.
- * -------------------------------------------------------------------
- */
-
-/*
- * This routine is used to handle the "bottom half" processing for the
- * serial driver, known also the "software interrupt" processing.
- * This processing is done at the kernel interrupt level, after the
- * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This
- * is where time-consuming activities which can not be done in the
- * interrupt driver proper are done; the interrupt driver schedules
- * them using rs_sched_event(), and they get done here.
- */
-static void do_softint(void *private_)
-{
- ser_info_t *info = (ser_info_t *) private_;
- struct tty_struct *tty;
-
- tty = info->tty;
- if (!tty)
- return;
-
- if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
- wake_up_interruptible(&tty->write_wait);
- }
-}
-
-/*
- * This routine is called from the scheduler work queue when the interrupt
- * routine has signalled that a hangup has occurred. The path of
- * hangup processing is:
- *
- * serial interrupt routine -> (scheduler tqueue) ->
- * do_serial_hangup() -> tty->hangup() -> rs_hangup()
- *
- */
-static void do_serial_hangup(void *private_)
-{
- struct async_struct *info = (struct async_struct *) private_;
- struct tty_struct *tty;
-
- tty = info->tty;
- if (tty)
- tty_hangup(tty);
-}
-
-/*static void rs_8xx_timer(void)
-{
- printk("rs_8xx_timer\n");
-}*/
-
-
-static int startup(ser_info_t *info)
-{
- unsigned long flags;
- int retval=0;
- int idx;
- struct serial_state *state= info->state;
- volatile smc_t *smcp;
- volatile scc_t *sccp;
- volatile smc_uart_t *up;
- volatile scc_uart_t *scup;
-
-
- save_flags(flags); cli();
-
- if (info->flags & ASYNC_INITIALIZED) {
- goto errout;
- }
-
-#ifdef maybe
- if (!state->port || !state->type) {
- if (info->tty)
- set_bit(TTY_IO_ERROR, &info->tty->flags);
- goto errout;
- }
-#endif
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("starting up ttys%d (irq %d)...", info->line, state->irq);
-#endif
-
-
-#ifdef modem_control
- info->MCR = 0;
- if (info->tty->termios->c_cflag & CBAUD)
- info->MCR = UART_MCR_DTR | UART_MCR_RTS;
-#endif
-
- if (info->tty)
- clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
- /*
- * and set the speed of the serial port
- */
- change_speed(info);
-
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
-
- /* Enable interrupts and I/O.
- */
- smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
- smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
-
- /* We can tune the buffer length and idle characters
- * to take advantage of the entire incoming buffer size.
- * If mrblr is something other than 1, maxidl has to be
- * non-zero or we never get an interrupt. The maxidl
- * is the number of character times we wait after reception
- * of the last character before we decide no more characters
- * are coming.
- */
- up = (smc_uart_t *)&immr->im_dprambase[state->port];
-#if 0
- up->smc_mrblr = 1; /* receive buffer length */
- up->smc_maxidl = 0; /* wait forever for next char */
-#else
- up->smc_mrblr = RX_BUF_SIZE;
- up->smc_maxidl = RX_BUF_SIZE;
-#endif
- up->smc_brkcr = 1; /* number of break chars */
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- scup = (scc_uart_t *)&immr->im_dprambase[state->port];
-#if 0
- scup->scc_genscc.scc_mrblr = 1; /* receive buffer length */
- scup->scc_maxidl = 0; /* wait forever for next char */
-#else
- scup->scc_genscc.scc_mrblr = RX_BUF_SIZE;
- scup->scc_maxidl = RX_BUF_SIZE;
-#endif
-
- sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
- sccp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
- }
-
- info->flags |= ASYNC_INITIALIZED;
- restore_flags(flags);
- return 0;
-
-errout:
- restore_flags(flags);
- return retval;
-}
-
-/*
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- */
-static void shutdown(ser_info_t * info)
-{
- unsigned long flags;
- struct serial_state *state;
- int idx;
- volatile smc_t *smcp;
- volatile scc_t *sccp;
-
- if (!(info->flags & ASYNC_INITIALIZED))
- return;
-
- state = info->state;
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("Shutting down serial port %d (irq %d)....", info->line,
- state->irq);
-#endif
-
- save_flags(flags); cli(); /* Disable interrupts */
-
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
-
- /* Disable interrupts and I/O.
- */
- smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-#ifdef CONFIG_SERIAL_CONSOLE
- /* We can't disable the transmitter if this is the
- * system console.
- */
- if (idx != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
- smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
-#ifdef CONFIG_SERIAL_CONSOLE
- if (idx != CONFIG_SERIAL_CONSOLE_PORT)
- sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#endif
- }
-
- if (info->tty)
- set_bit(TTY_IO_ERROR, &info->tty->flags);
-
- info->flags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
-}
-
-/*
- * This routine is called to set the UART divisor registers to match
- * the specified baud rate for a serial port.
- */
-static void change_speed(ser_info_t *info)
-{
- int baud_rate;
- unsigned cflag, cval, scval, prev_mode;
- int i, bits, sbits, idx;
- unsigned long flags;
- volatile smc_t *smcp;
- volatile scc_t *sccp;
-
- if (!info->tty || !info->tty->termios)
- return;
- cflag = info->tty->termios->c_cflag;
-
- /* Character length programmed into the mode register is the
- * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
- * 1 or 2 stop bits, minus 1.
- * The value 'bits' counts this for us.
- */
- cval = 0;
- scval = 0;
-
- /* byte size and parity */
- switch (cflag & CSIZE) {
- case CS5: bits = 5; break;
- case CS6: bits = 6; break;
- case CS7: bits = 7; break;
- case CS8: bits = 8; break;
- /* Never happens, but GCC is too dumb to figure it out */
- default: bits = 8; break;
- }
- sbits = bits - 5;
-
- if (cflag & CSTOPB) {
- cval |= SMCMR_SL; /* Two stops */
- scval |= SCU_PMSR_SL;
- bits++;
- }
- if (cflag & PARENB) {
- cval |= SMCMR_PEN;
- scval |= SCU_PMSR_PEN;
- bits++;
- }
- if (!(cflag & PARODD)) {
- cval |= SMCMR_PM_EVEN;
- scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
- }
-
- /* Determine divisor based on baud rate */
- i = cflag & CBAUD;
- if (i >= (sizeof(baud_table)/sizeof(int)))
- baud_rate = 9600;
- else
- baud_rate = baud_table[i];
-
- info->timeout = (TX_BUF_SIZE*HZ*bits);
- info->timeout += HZ/50; /* Add .02 seconds of slop */
-
-#ifdef modem_control
- /* CTS flow control flag and modem status interrupts */
- info->IER &= ~UART_IER_MSI;
- if (info->flags & ASYNC_HARDPPS_CD)
- info->IER |= UART_IER_MSI;
- if (cflag & CRTSCTS) {
- info->flags |= ASYNC_CTS_FLOW;
- info->IER |= UART_IER_MSI;
- } else
- info->flags &= ~ASYNC_CTS_FLOW;
- if (cflag & CLOCAL)
- info->flags &= ~ASYNC_CHECK_CD;
- else {
- info->flags |= ASYNC_CHECK_CD;
- info->IER |= UART_IER_MSI;
- }
- serial_out(info, UART_IER, info->IER);
-#endif
-
- /*
- * Set up parity check flag
- */
-#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
- info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
- if (I_INPCK(info->tty))
- info->read_status_mask |= BD_SC_FR | BD_SC_PR;
- if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
- info->read_status_mask |= BD_SC_BR;
-
- /*
- * Characters to ignore
- */
- info->ignore_status_mask = 0;
- if (I_IGNPAR(info->tty))
- info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
- if (I_IGNBRK(info->tty)) {
- info->ignore_status_mask |= BD_SC_BR;
- /*
- * If we're ignore parity and break indicators, ignore
- * overruns too. (For real raw support).
- */
- if (I_IGNPAR(info->tty))
- info->ignore_status_mask |= BD_SC_OV;
- }
- /*
- * !!! ignore all characters if CREAD is not set
- */
- if ((cflag & CREAD) == 0)
- info->read_status_mask &= ~BD_SC_EMPTY;
- save_flags(flags); cli();
-
- /* Start bit has not been added (so don't, because we would just
- * subtract it later), and we need to add one for the number of
- * stops bits (there is always at least one).
- */
- bits++;
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
-
- /* Set the mode register. We want to keep a copy of the
- * enables, because we want to put them back if they were
- * present.
- */
- prev_mode = smcp->smc_smcmr;
- smcp->smc_smcmr = smcr_mk_clen(bits) | cval | SMCMR_SM_UART;
- smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- sccp->scc_pmsr = (sbits << 12) | scval;
- }
-
- m8260_cpm_setbrg(info->state->smc_scc_num, baud_rate);
-
- restore_flags(flags);
-}
-
-static void rs_8xx_put_char(struct tty_struct *tty, unsigned char ch)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- volatile cbd_t *bdp;
-
- if (serial_paranoia_check(info, tty->name, "rs_put_char"))
- return;
-
- if (!tty)
- return;
-
- bdp = info->tx_cur;
- while (bdp->cbd_sc & BD_SC_READY);
-
- *((char *)__va(bdp->cbd_bufaddr)) = ch;
- bdp->cbd_datlen = 1;
- bdp->cbd_sc |= BD_SC_READY;
-
- /* Get next BD.
- */
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
-
- info->tx_cur = (cbd_t *)bdp;
-
-}
-
-static int rs_8xx_write(struct tty_struct * tty, int from_user,
- const unsigned char *buf, int count)
-{
- int c, ret = 0;
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- volatile cbd_t *bdp;
-
- if (serial_paranoia_check(info, tty->name, "rs_write"))
- return 0;
-
- if (!tty)
- return 0;
-
- bdp = info->tx_cur;
-
- while (1) {
- c = min(count, TX_BUF_SIZE);
-
- if (c <= 0)
- break;
-
- if (bdp->cbd_sc & BD_SC_READY) {
- info->flags |= TX_WAKEUP;
- break;
- }
-
- if (from_user) {
- if (copy_from_user(__va(bdp->cbd_bufaddr), buf, c)) {
- if (!ret)
- ret = -EFAULT;
- break;
- }
- } else {
- memcpy(__va(bdp->cbd_bufaddr), buf, c);
- }
-
- bdp->cbd_datlen = c;
- bdp->cbd_sc |= BD_SC_READY;
-
- buf += c;
- count -= c;
- ret += c;
-
- /* Get next BD.
- */
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
- info->tx_cur = (cbd_t *)bdp;
- }
- return ret;
-}
-
-static int rs_8xx_write_room(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int ret;
-
- if (serial_paranoia_check(info, tty->name, "rs_write_room"))
- return 0;
-
- if ((info->tx_cur->cbd_sc & BD_SC_READY) == 0) {
- info->flags &= ~TX_WAKEUP;
- ret = TX_BUF_SIZE;
- }
- else {
- info->flags |= TX_WAKEUP;
- ret = 0;
- }
- return ret;
-}
-
-/* I could track this with transmit counters....maybe later.
-*/
-static int rs_8xx_chars_in_buffer(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
- return 0;
- return 0;
-}
-
-static void rs_8xx_flush_buffer(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
- return;
-
- /* There is nothing to "flush", whatever we gave the CPM
- * is on its way out.
- */
- wake_up_interruptible(&tty->write_wait);
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
- info->flags &= ~TX_WAKEUP;
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void rs_8xx_send_xchar(struct tty_struct *tty, char ch)
-{
- volatile cbd_t *bdp;
-
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_send_char"))
- return;
-
- bdp = info->tx_cur;
- while (bdp->cbd_sc & BD_SC_READY);
-
- *((char *)__va(bdp->cbd_bufaddr)) = ch;
- bdp->cbd_datlen = 1;
- bdp->cbd_sc |= BD_SC_READY;
-
- /* Get next BD.
- */
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
-
- info->tx_cur = (cbd_t *)bdp;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_throttle()
- *
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- * ------------------------------------------------------------
- */
-static void rs_8xx_throttle(struct tty_struct * tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
- char buf[64];
-
- printk("throttle %s: %d....\n", _tty_name(tty, buf),
- tty->ldisc.chars_in_buffer(tty));
-#endif
-
- if (serial_paranoia_check(info, tty->name, "rs_throttle"))
- return;
-
- if (I_IXOFF(tty))
- rs_8xx_send_xchar(tty, STOP_CHAR(tty));
-
-#ifdef modem_control
- if (tty->termios->c_cflag & CRTSCTS)
- info->MCR &= ~UART_MCR_RTS;
-
- cli();
- serial_out(info, UART_MCR, info->MCR);
- sti();
-#endif
-}
-
-static void rs_8xx_unthrottle(struct tty_struct * tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
- char buf[64];
-
- printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
- tty->ldisc.chars_in_buffer(tty));
-#endif
-
- if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
- return;
-
- if (I_IXOFF(tty)) {
- if (info->x_char)
- info->x_char = 0;
- else
- rs_8xx_send_xchar(tty, START_CHAR(tty));
- }
-#ifdef modem_control
- if (tty->termios->c_cflag & CRTSCTS)
- info->MCR |= UART_MCR_RTS;
- cli();
- serial_out(info, UART_MCR, info->MCR);
- sti();
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-#ifdef maybe
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- * is emptied. On bus types like RS485, the transmitter must
- * release the bus after transmitting. This must be done when
- * the transmit shift register is empty, not be done when the
- * transmit holding register is empty. This functionality
- * allows an RS485 driver to be written in user space.
- */
-static int get_lsr_info(struct async_struct * info, unsigned int *value)
-{
- unsigned char status;
- unsigned int result;
-
- cli();
- status = serial_in(info, UART_LSR);
- sti();
- result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
- return put_user(result,value);
-}
-#endif
-
-static int get_modem_info(ser_info_t *info, unsigned int *value)
-{
- unsigned int result = 0;
-#ifdef modem_control
- unsigned char control, status;
-
- control = info->MCR;
- cli();
- status = serial_in(info, UART_MSR);
- sti();
- result = ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
- | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
-#ifdef TIOCM_OUT1
- | ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
- | ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
-#endif
- | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
- | ((status & UART_MSR_RI) ? TIOCM_RNG : 0)
- | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0)
- | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
-#endif
- return put_user(result,value);
-}
-
-static int set_modem_info(ser_info_t *info, unsigned int cmd,
- unsigned int *value)
-{
- int error;
- unsigned int arg;
-
- error = get_user(arg, value);
- if (error)
- return error;
-#ifdef modem_control
- switch (cmd) {
- case TIOCMBIS:
- if (arg & TIOCM_RTS)
- info->MCR |= UART_MCR_RTS;
- if (arg & TIOCM_DTR)
- info->MCR |= UART_MCR_DTR;
-#ifdef TIOCM_OUT1
- if (arg & TIOCM_OUT1)
- info->MCR |= UART_MCR_OUT1;
- if (arg & TIOCM_OUT2)
- info->MCR |= UART_MCR_OUT2;
-#endif
- break;
- case TIOCMBIC:
- if (arg & TIOCM_RTS)
- info->MCR &= ~UART_MCR_RTS;
- if (arg & TIOCM_DTR)
- info->MCR &= ~UART_MCR_DTR;
-#ifdef TIOCM_OUT1
- if (arg & TIOCM_OUT1)
- info->MCR &= ~UART_MCR_OUT1;
- if (arg & TIOCM_OUT2)
- info->MCR &= ~UART_MCR_OUT2;
-#endif
- break;
- case TIOCMSET:
- info->MCR = ((info->MCR & ~(UART_MCR_RTS |
-#ifdef TIOCM_OUT1
- UART_MCR_OUT1 |
- UART_MCR_OUT2 |
-#endif
- UART_MCR_DTR))
- | ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0)
-#ifdef TIOCM_OUT1
- | ((arg & TIOCM_OUT1) ? UART_MCR_OUT1 : 0)
- | ((arg & TIOCM_OUT2) ? UART_MCR_OUT2 : 0)
-#endif
- | ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0));
- break;
- default:
- return -EINVAL;
- }
- cli();
- serial_out(info, UART_MCR, info->MCR);
- sti();
-#endif
- return 0;
-}
-
-/* Sending a break is a two step process on the SMC/SCC. It is accomplished
- * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
- * command. We take advantage of the begin/end functions to make this
- * happen.
- */
-static void begin_break(ser_info_t *info)
-{
- volatile cpm8260_t *cp;
- uint page, sblock;
- int num;
-
- cp = cpmp;
-
- if ((num = info->state->smc_scc_num) < SCC_NUM_BASE) {
- if (num == 0) {
- page = CPM_CR_SMC1_PAGE;
- sblock = CPM_CR_SMC1_SBLOCK;
- }
- else {
- page = CPM_CR_SMC2_PAGE;
- sblock = CPM_CR_SMC2_SBLOCK;
- }
- }
- else {
- num -= SCC_NUM_BASE;
- switch (num) {
- case 0:
- page = CPM_CR_SCC1_PAGE;
- sblock = CPM_CR_SCC1_SBLOCK;
- break;
- case 1:
- page = CPM_CR_SCC2_PAGE;
- sblock = CPM_CR_SCC2_SBLOCK;
- break;
- case 2:
- page = CPM_CR_SCC3_PAGE;
- sblock = CPM_CR_SCC3_SBLOCK;
- break;
- case 3:
- page = CPM_CR_SCC4_PAGE;
- sblock = CPM_CR_SCC4_SBLOCK;
- break;
- default: return;
- }
- }
- cp->cp_cpcr = mk_cr_cmd(page, sblock, 0, CPM_CR_STOP_TX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-static void end_break(ser_info_t *info)
-{
- volatile cpm8260_t *cp;
- uint page, sblock;
- int num;
-
- cp = cpmp;
-
- if ((num = info->state->smc_scc_num) < SCC_NUM_BASE) {
- if (num == 0) {
- page = CPM_CR_SMC1_PAGE;
- sblock = CPM_CR_SMC1_SBLOCK;
- }
- else {
- page = CPM_CR_SMC2_PAGE;
- sblock = CPM_CR_SMC2_SBLOCK;
- }
- }
- else {
- num -= SCC_NUM_BASE;
- switch (num) {
- case 0:
- page = CPM_CR_SCC1_PAGE;
- sblock = CPM_CR_SCC1_SBLOCK;
- break;
- case 1:
- page = CPM_CR_SCC2_PAGE;
- sblock = CPM_CR_SCC2_SBLOCK;
- break;
- case 2:
- page = CPM_CR_SCC3_PAGE;
- sblock = CPM_CR_SCC3_SBLOCK;
- break;
- case 3:
- page = CPM_CR_SCC4_PAGE;
- sblock = CPM_CR_SCC4_SBLOCK;
- break;
- default: return;
- }
- }
- cp->cp_cpcr = mk_cr_cmd(page, sblock, 0, CPM_CR_RESTART_TX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break(ser_info_t *info, int duration)
-{
- current->state = TASK_INTERRUPTIBLE;
-#ifdef SERIAL_DEBUG_SEND_BREAK
- printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
-#endif
- begin_break(info);
- schedule_timeout(duration);
- end_break(info);
-#ifdef SERIAL_DEBUG_SEND_BREAK
- printk("done jiffies=%lu\n", jiffies);
-#endif
-}
-
-
-static int rs_8xx_ioctl(struct tty_struct *tty, struct file * file,
- unsigned int cmd, unsigned long arg)
-{
- int error;
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int retval;
- struct async_icount cnow; /* kernel counter temps */
- struct serial_icounter_struct *p_cuser; /* user space */
-
- if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
- return -ENODEV;
-
- if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
- }
-
- switch (cmd) {
- case TCSBRK: /* SVID version: non-zero arg --> no break */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- if (signal_pending(current))
- return -EINTR;
- if (!arg) {
- send_break(info, HZ/4); /* 1/4 second */
- if (signal_pending(current))
- return -EINTR;
- }
- return 0;
- case TCSBRKP: /* support for POSIX tcsendbreak() */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- if (signal_pending(current))
- return -EINTR;
- send_break(info, arg ? arg*(HZ/10) : HZ/4);
- if (signal_pending(current))
- return -EINTR;
- return 0;
- case TIOCSBRK:
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- begin_break(info);
- return 0;
- case TIOCCBRK:
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- end_break(info);
- return 0;
- case TIOCGSOFTCAR:
- return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
- case TIOCSSOFTCAR:
- error = get_user(arg, (unsigned int *) arg);
- if (error)
- return error;
- tty->termios->c_cflag =
- ((tty->termios->c_cflag & ~CLOCAL) |
- (arg ? CLOCAL : 0));
- return 0;
- case TIOCMGET:
- return get_modem_info(info, (unsigned int *) arg);
- case TIOCMBIS:
- case TIOCMBIC:
- case TIOCMSET:
- return set_modem_info(info, cmd, (unsigned int *) arg);
-#ifdef maybe
- case TIOCSERGETLSR: /* Get line status register */
- return get_lsr_info(info, (unsigned int *) arg);
-#endif
- /*
- * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
- * - mask passed in arg for lines of interest
- * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
- * Caller should use TIOCGICOUNT to see which one it was
- */
- case TIOCMIWAIT:
-#ifdef modem_control
- cli();
- /* note the counters on entry */
- cprev = info->state->icount;
- sti();
- while (1) {
- interruptible_sleep_on(&info->delta_msr_wait);
- /* see if a signal did it */
- if (signal_pending(current))
- return -ERESTARTSYS;
- cli();
- cnow = info->state->icount; /* atomic copy */
- sti();
- if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
- cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
- return -EIO; /* no change => error */
- if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
- ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
- ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
- ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
- return 0;
- }
- cprev = cnow;
- }
- /* NOTREACHED */
-#else
- return 0;
-#endif
-
- /*
- * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
- * Return: write counters to the user passed counter struct
- * NB: both 1->0 and 0->1 transitions are counted except for
- * RI where only 0->1 is counted.
- */
- case TIOCGICOUNT:
- cli();
- cnow = info->state->icount;
- sti();
- p_cuser = (struct serial_icounter_struct *) arg;
- error = put_user(cnow.cts, &p_cuser->cts);
- if (error) return error;
- error = put_user(cnow.dsr, &p_cuser->dsr);
- if (error) return error;
- error = put_user(cnow.rng, &p_cuser->rng);
- if (error) return error;
- error = put_user(cnow.dcd, &p_cuser->dcd);
- if (error) return error;
- return 0;
-
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-/* FIX UP modem control here someday......
-*/
-static void rs_8xx_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if ( (tty->termios->c_cflag == old_termios->c_cflag)
- && ( RELEVANT_IFLAG(tty->termios->c_iflag)
- == RELEVANT_IFLAG(old_termios->c_iflag)))
- return;
-
- change_speed(info);
-
-#ifdef modem_control
- /* Handle transition to B0 status */
- if ((old_termios->c_cflag & CBAUD) &&
- !(tty->termios->c_cflag & CBAUD)) {
- info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
- cli();
- serial_out(info, UART_MCR, info->MCR);
- sti();
- }
-
- /* Handle transition away from B0 status */
- if (!(old_termios->c_cflag & CBAUD) &&
- (tty->termios->c_cflag & CBAUD)) {
- info->MCR |= UART_MCR_DTR;
- if (!tty->hw_stopped ||
- !(tty->termios->c_cflag & CRTSCTS)) {
- info->MCR |= UART_MCR_RTS;
- }
- cli();
- serial_out(info, UART_MCR, info->MCR);
- sti();
- }
-
- /* Handle turning off CRTSCTS */
- if ((old_termios->c_cflag & CRTSCTS) &&
- !(tty->termios->c_cflag & CRTSCTS)) {
- tty->hw_stopped = 0;
- rs_8xx_start(tty);
- }
-#endif
-
-#if 0
- /*
- * No need to wake up processes in open wait, since they
- * sample the CLOCAL flag once, and don't recheck it.
- * XXX It's not clear whether the current behavior is correct
- * or not. Hence, this may change.....
- */
- if (!(old_termios->c_cflag & CLOCAL) &&
- (tty->termios->c_cflag & CLOCAL))
- wake_up_interruptible(&info->open_wait);
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_close()
- *
- * This routine is called when the serial port gets closed. First, we
- * wait for the last remaining data to be sent. Then, we unlink its
- * async structure from the interrupt chain if necessary, and we free
- * that IRQ if nothing is left in the chain.
- * ------------------------------------------------------------
- */
-static void rs_8xx_close(struct tty_struct *tty, struct file * filp)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- struct serial_state *state;
- unsigned long flags;
- int idx;
- volatile smc_t *smcp;
- volatile scc_t *sccp;
-
- if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
- return;
-
- state = info->state;
-
- save_flags(flags); cli();
-
- if (tty_hung_up_p(filp)) {
- DBG_CNT("before DEC-hung");
- restore_flags(flags);
- return;
- }
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", info->line, state->count);
-#endif
- if ((tty->count == 1) && (state->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk("rs_close: bad serial port count; tty->count is 1, "
- "state->count is %d\n", state->count);
- state->count = 1;
- }
- if (--state->count < 0) {
- printk("rs_close: bad serial port count for ttys%d: %d\n",
- info->line, state->count);
- state->count = 0;
- }
- if (state->count) {
- DBG_CNT("before DEC-2");
- restore_flags(flags);
- return;
- }
- info->flags |= ASYNC_CLOSING;
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
- if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, info->closing_wait);
- /*
- * At this point we stop accepting input. To do this, we
- * disable the receive line status interrupts, and tell the
- * interrupt driver to stop checking the data ready bit in the
- * line status register.
- */
- info->read_status_mask &= ~BD_SC_EMPTY;
- if (info->flags & ASYNC_INITIALIZED) {
- if ((idx = info->state->smc_scc_num) < SCC_NUM_BASE) {
- smcp = &immr->im_smc[idx];
- smcp->smc_smcm &= ~SMCM_RX;
- smcp->smc_smcmr &= ~SMCMR_REN;
- }
- else {
- sccp = &immr->im_scc[idx - SCC_IDX_BASE];
- sccp->scc_sccm &= ~UART_SCCM_RX;
- sccp->scc_gsmrl &= ~SCC_GSMRL_ENR;
- }
- /*
- * Before we drop DTR, make sure the UART transmitter
- * has completely drained; this is especially
- * important if there is a transmit FIFO!
- */
- rs_8xx_wait_until_sent(tty, info->timeout);
- }
- shutdown(info);
- if (tty->driver->flush_buffer)
- tty->driver->flush_buffer(tty);
- if (tty->ldisc.flush_buffer)
- tty->ldisc.flush_buffer(tty);
- tty->closing = 0;
- info->event = 0;
- info->tty = 0;
- if (info->blocked_open) {
- if (info->close_delay) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(info->close_delay);
- }
- wake_up_interruptible(&info->open_wait);
- }
- info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&info->close_wait);
- restore_flags(flags);
-}
-
-/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_8xx_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- unsigned long orig_jiffies, char_time;
- /*int lsr;*/
- volatile cbd_t *bdp;
-
- if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
- return;
-
-#ifdef maybe
- if (info->state->type == PORT_UNKNOWN)
- return;
-#endif
-
- orig_jiffies = jiffies;
- /*
- * Set the check interval to be 1/5 of the estimated time to
- * send a single character, and make it at least 1. The check
- * interval should also be less than the timeout.
- *
- * Note: we have to use pretty tight timings here to satisfy
- * the NIST-PCTS.
- */
- char_time = 1;
- if (timeout)
- char_time = min(char_time, (unsigned long)timeout);
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
- printk("jiff=%lu...", jiffies);
-#endif
-
- /* We go through the loop at least once because we can't tell
- * exactly when the last character exits the shifter. There can
- * be at least two characters waiting to be sent after the buffers
- * are empty.
- */
- do {
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
-#endif
- current->state = TASK_INTERRUPTIBLE;
-/* current->dyn_prio = 0; make us low-priority */
- schedule_timeout(char_time);
- if (signal_pending(current))
- break;
- if (timeout && time_after(jiffies, orig_jiffies + timeout))
- break;
- bdp = info->tx_cur;
- } while (bdp->cbd_sc & BD_SC_READY);
- current->state = TASK_RUNNING;
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
-#endif
-}
-
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
-static void rs_8xx_hangup(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- struct serial_state *state = info->state;
-
- if (serial_paranoia_check(info, tty->name, "rs_hangup"))
- return;
-
- state = info->state;
-
- rs_8xx_flush_buffer(tty);
- shutdown(info);
- info->event = 0;
- state->count = 0;
- info->flags &= ~ASYNC_NORMAL_ACTIVE;
- info->tty = 0;
- wake_up_interruptible(&info->open_wait);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file * filp,
- ser_info_t *info)
-{
-#ifdef DO_THIS_LATER
- DECLARE_WAITQUEUE(wait, current);
- struct serial_state *state = info->state;
-#endif
- int retval;
- int do_clocal = 0;
-
- /*
- * If the device is in the middle of being closed, then block
- * until it's done, and then try again.
- */
- if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
-#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
- return -EAGAIN;
- else
- return -ERESTARTSYS;
-#else
- return -EAGAIN;
-#endif
- }
-
- /*
- * If non-blocking mode is set, or the port is not enabled,
- * then make the check up front and then exit.
- * If this is an SMC port, we don't have modem control to wait
- * for, so just get out here.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR)) ||
- (info->state->smc_scc_num < SCC_NUM_BASE)) {
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
-
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
-
- /*
- * Block waiting for the carrier detect and the line to become
- * free (i.e., not in use by the callout). While we are in
- * this loop, state->count is dropped by one, so that
- * rs_close() knows when to free things. We restore it upon
- * exit, either normal or abnormal.
- */
- retval = 0;
-#ifdef DO_THIS_LATER
- add_wait_queue(&info->open_wait, &wait);
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready before block: ttys%d, count = %d\n",
- state->line, state->count);
-#endif
- cli();
- if (!tty_hung_up_p(filp))
- state->count--;
- sti();
- info->blocked_open++;
- while (1) {
- cli();
- if (tty->termios->c_cflag & CBAUD)
- serial_out(info, UART_MCR,
- serial_inp(info, UART_MCR) |
- (UART_MCR_DTR | UART_MCR_RTS));
- sti();
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(info->flags & ASYNC_INITIALIZED)) {
-#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
-#else
- retval = -EAGAIN;
-#endif
- break;
- }
- if (!(info->flags & ASYNC_CLOSING) &&
- (do_clocal || (serial_in(info, UART_MSR) &
- UART_MSR_DCD)))
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, state->count);
-#endif
- schedule();
- }
- current->state = TASK_RUNNING;
- remove_wait_queue(&info->open_wait, &wait);
- if (!tty_hung_up_p(filp))
- state->count++;
- info->blocked_open--;
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, state->count);
-#endif
-#endif /* DO_THIS_LATER */
- if (retval)
- return retval;
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
-}
-
-static int get_async_struct(int line, ser_info_t **ret_info)
-{
- struct serial_state *sstate;
-
- sstate = rs_table + line;
- if (sstate->info) {
- sstate->count++;
- *ret_info = (ser_info_t *)sstate->info;
- return 0;
- }
- else {
- return -ENOMEM;
- }
-}
-
-/*
- * This routine is called whenever a serial port is opened. It
- * enables interrupts for a serial port, linking in its async structure into
- * the IRQ chain. It also performs the serial-specific
- * initialization for the tty structure.
- */
-static int rs_8xx_open(struct tty_struct *tty, struct file * filp)
-{
- ser_info_t *info;
- int retval, line;
-
- line = tty->index;
- if ((line < 0) || (line >= NR_PORTS))
- return -ENODEV;
- retval = get_async_struct(line, &info);
- if (retval)
- return retval;
- if (serial_paranoia_check(info, tty->name, "rs_open"))
- return -ENODEV;
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s, count = %d\n", tty->name, info->state->count);
-#endif
- tty->driver_data = info;
- info->tty = tty;
-
- /*
- * Start up serial port
- */
- retval = startup(info);
- if (retval)
- return retval;
-
- retval = block_til_ready(tty, filp, info);
- if (retval) {
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open returning after block_til_ready with %d\n",
- retval);
-#endif
- return retval;
- }
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s successful...", line);
-#endif
- return 0;
-}
-
-/*
- * /proc fs routines....
- */
-
-static inline int line_info(char *buf, struct serial_state *state)
-{
-#ifdef notdef
- struct async_struct *info = state->info, scr_info;
- char stat_buf[30], control, status;
-#endif
- int ret;
-
- ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
- state->line,
- (state->smc_scc_num < SCC_NUM_BASE) ? "SMC" : "SCC",
- (unsigned int)(state->port), state->irq);
-
- if (!state->port || (state->type == PORT_UNKNOWN)) {
- ret += sprintf(buf+ret, "\n");
- return ret;
- }
-
-#ifdef notdef
- /*
- * Figure out the current RS-232 lines
- */
- if (!info) {
- info = &scr_info; /* This is just for serial_{in,out} */
-
- info->magic = SERIAL_MAGIC;
- info->port = state->port;
- info->flags = state->flags;
- info->quot = 0;
- info->tty = 0;
- }
- cli();
- status = serial_in(info, UART_MSR);
- control = info ? info->MCR : serial_in(info, UART_MCR);
- sti();
-
- stat_buf[0] = 0;
- stat_buf[1] = 0;
- if (control & UART_MCR_RTS)
- strcat(stat_buf, "|RTS");
- if (status & UART_MSR_CTS)
- strcat(stat_buf, "|CTS");
- if (control & UART_MCR_DTR)
- strcat(stat_buf, "|DTR");
- if (status & UART_MSR_DSR)
- strcat(stat_buf, "|DSR");
- if (status & UART_MSR_DCD)
- strcat(stat_buf, "|CD");
- if (status & UART_MSR_RI)
- strcat(stat_buf, "|RI");
-
- if (info->quot) {
- ret += sprintf(buf+ret, " baud:%d",
- state->baud_base / info->quot);
- }
-
- ret += sprintf(buf+ret, " tx:%d rx:%d",
- state->icount.tx, state->icount.rx);
-
- if (state->icount.frame)
- ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
-
- if (state->icount.parity)
- ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
-
- if (state->icount.brk)
- ret += sprintf(buf+ret, " brk:%d", state->icount.brk);
-
- if (state->icount.overrun)
- ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
-
- /*
- * Last thing is the RS-232 status lines
- */
- ret += sprintf(buf+ret, " %s\n", stat_buf+1);
-#endif
- return ret;
-}
-
-int rs_8xx_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- int i, len = 0;
- off_t begin = 0;
-
- len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
- for (i = 0; i < NR_PORTS && len < 4000; i++) {
- len += line_info(page + len, &rs_table[i]);
- if (len+begin > off+count)
- goto done;
- if (len+begin < off) {
- begin += len;
- len = 0;
- }
- }
- *eof = 1;
-done:
- if (off >= len+begin)
- return 0;
- *start = page + (begin-off);
- return ((count < begin+len-off) ? count : begin+len-off);
-}
-
-/*
- * ---------------------------------------------------------------------
- * rs_init() and friends
- *
- * rs_init() is called at boot-time to initialize the serial driver.
- * ---------------------------------------------------------------------
- */
-
-/*
- * This routine prints out the appropriate serial driver version
- * number, and identifies which options were configured into this
- * driver.
- */
-static _INLINE_ void show_serial_version(void)
-{
- printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
-}
-
-
-/*
- * The serial console driver used during boot. Note that these names
- * clash with those found in "serial.c", so we currently can't support
- * the 16xxx uarts and these at the same time. I will fix this to become
- * an indirect function call from tty_io.c (or something).
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-/*
- * Print a string to the serial port trying not to disturb any possible
- * real use of the port...
- * These funcitons work equally well for SCC, even though they are
- * designed for SMC. Our only interests are the transmit/receive
- * buffers, which are identically mapped for either the SCC or SMC.
- */
-static void my_console_write(int idx, const char *s,
- unsigned count)
-{
- struct serial_state *ser;
- ser_info_t *info;
- unsigned i;
- volatile cbd_t *bdp, *bdbase;
- volatile smc_uart_t *up;
- volatile u_char *cp;
-
- ser = rs_table + idx;
-
- /* If the port has been initialized for general use, we have
- * to use the buffer descriptors allocated there. Otherwise,
- * we simply use the single buffer allocated.
- */
- if ((info = (ser_info_t *)ser->info) != NULL) {
- bdp = info->tx_cur;
- bdbase = info->tx_bd_base;
- }
- else {
- /* Pointer to UART in parameter ram.
- */
- up = (smc_uart_t *)&immr->im_dprambase[ser->port];
-
- /* Get the address of the host memory buffer.
- */
- bdp = bdbase = (cbd_t *)&immr->im_dprambase[up->smc_tbase];
- }
-
- /*
- * We need to gracefully shut down the transmitter, disable
- * interrupts, then send our bytes out.
- */
-
- /*
- * Now, do each character. This is not as bad as it looks
- * since this is a holding FIFO and not a transmitting FIFO.
- * We could add the complexity of filling the entire transmit
- * buffer, but we would just wait longer between accesses......
- */
- for (i = 0; i < count; i++, s++) {
- /* Wait for transmitter fifo to empty.
- * Ready indicates output is ready, and xmt is doing
- * that, not that it is ready for us to send.
- */
- while (bdp->cbd_sc & BD_SC_READY);
-
- /* Send the character out.
- * If the buffer address is in the CPM DPRAM, don't
- * convert it.
- */
- if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
- cp = (u_char *)(bdp->cbd_bufaddr);
- else
- cp = __va(bdp->cbd_bufaddr);
- *cp = *s;
-
- bdp->cbd_datlen = 1;
- bdp->cbd_sc |= BD_SC_READY;
-
- if (bdp->cbd_sc & BD_SC_WRAP)
- bdp = bdbase;
- else
- bdp++;
-
- /* if a LF, also do CR... */
- if (*s == 10) {
- while (bdp->cbd_sc & BD_SC_READY);
- cp = __va(bdp->cbd_bufaddr);
- *cp = 13;
- bdp->cbd_datlen = 1;
- bdp->cbd_sc |= BD_SC_READY;
-
- if (bdp->cbd_sc & BD_SC_WRAP) {
- bdp = bdbase;
- }
- else {
- bdp++;
- }
- }
- }
-
- /*
- * Finally, Wait for transmitter & holding register to empty
- * and restore the IER
- */
- while (bdp->cbd_sc & BD_SC_READY);
-
- if (info)
- info->tx_cur = (cbd_t *)bdp;
-}
-
-static void serial_console_write(struct console *c, const char *s,
- unsigned count)
-{
-#if defined(CONFIG_KGDB_CONSOLE) && !defined(CONFIG_USE_SERIAL2_KGDB)
- /* Try to let stub handle output. Returns true if it did. */
- if (kgdb_output_string(s, count))
- return;
-#endif
- my_console_write(c->index, s, count);
-}
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_write(const char *s, unsigned count)
-{
- my_console_write(KGDB_SER_IDX, s, count);
- return(count);
-}
-#endif
-
-#ifdef CONFIG_KGDB
-void
-putDebugChar(char ch)
-{
- my_console_write(KGDB_SER_IDX, &ch, 1);
-}
-#endif
-
-#if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
-/*
- * Receive character from the serial port. This only works well
- * before the port is initialize for real use.
- */
-static int my_console_wait_key(int idx, int xmon, char *obuf)
-{
- struct serial_state *ser;
- u_char c, *cp;
- ser_info_t *info;
- volatile cbd_t *bdp;
- volatile smc_uart_t *up;
- int i;
-
- ser = rs_table + idx;
-
- /* Pointer to UART in parameter ram.
- */
- up = (smc_uart_t *)&immr->im_dprambase[ser->port];
-
- /* Get the address of the host memory buffer.
- * If the port has been initialized for general use, we must
- * use information from the port structure.
- */
- if ((info = (ser_info_t *)ser->info))
- bdp = info->rx_cur;
- else
- bdp = (cbd_t *)&immr->im_dprambase[up->smc_rbase];
-
- /*
- * We need to gracefully shut down the receiver, disable
- * interrupts, then read the input.
- * XMON just wants a poll. If no character, return -1, else
- * return the character.
- */
- if (!xmon) {
- while (bdp->cbd_sc & BD_SC_EMPTY);
- }
- else {
- if (bdp->cbd_sc & BD_SC_EMPTY)
- return -1;
- }
-
- /* If the buffer address is in the CPM DPRAM, don't
- * convert it.
- */
- if ((uint)(bdp->cbd_bufaddr) > (uint)IMAP_ADDR)
- cp = (u_char *)(bdp->cbd_bufaddr);
- else
- cp = __va(bdp->cbd_bufaddr);
-
- if (obuf) {
- i = c = bdp->cbd_datlen;
- while (i-- > 0)
- *obuf++ = *cp++;
- }
- else {
- c = *cp;
- }
- bdp->cbd_sc |= BD_SC_EMPTY;
-
- if (info) {
- if (bdp->cbd_sc & BD_SC_WRAP) {
- bdp = info->rx_bd_base;
- }
- else {
- bdp++;
- }
- info->rx_cur = (cbd_t *)bdp;
- }
-
- return((int)c);
-}
-#endif /* CONFIG_XMON || CONFIG_KGDB */
-
-#ifdef CONFIG_XMON
-int
-xmon_8xx_read_poll(void)
-{
- return(my_console_wait_key(KGDB_SER_IDX, 1, NULL));
-}
-
-int
-xmon_8xx_read_char(void)
-{
- return(my_console_wait_key(KGDB_SER_IDX, 0, NULL));
-}
-#endif
-
-#ifdef CONFIG_KGDB
-static char kgdb_buf[RX_BUF_SIZE], *kgdp;
-static int kgdb_chars;
-
-char
-getDebugChar(void)
-{
- if (kgdb_chars <= 0) {
- kgdb_chars = my_console_wait_key(KGDB_SER_IDX, 0, kgdb_buf);
- kgdp = kgdb_buf;
- }
- kgdb_chars--;
-
- return(*kgdp++);
-}
-
-void kgdb_interruptible(int yes)
-{
- volatile smc_t *smcp;
-
- smcp = &immr->im_smc[KGDB_SER_IDX];
-
- if (yes == 1)
- smcp->smc_smcm |= SMCM_RX;
- else
- smcp->smc_smcm &= ~SMCM_RX;
-}
-
-void kgdb_map_scc(void)
-{
- ushort serbase;
- uint mem_addr;
- volatile cbd_t *bdp;
- volatile smc_uart_t *up;
-
- /* The serial port has already been initialized before
- * we get here. We have to assign some pointers needed by
- * the kernel, and grab a memory location in the CPM that will
- * work until the driver is really initialized.
- */
- immr = (immap_t *)IMAP_ADDR;
-
- /* Right now, assume we are using SMCs.
- */
-#ifdef USE_KGDB_SMC2
- *(ushort *)(&immr->im_dprambase[PROFF_SMC2_BASE]) = serbase = PROFF_SMC2;
-#else
- *(ushort *)(&immr->im_dprambase[PROFF_SMC1_BASE]) = serbase = PROFF_SMC1;
-#endif
- up = (smc_uart_t *)&immr->im_dprambase[serbase];
-
- /* Allocate space for an input FIFO, plus a few bytes for output.
- * Allocate bytes to maintain word alignment.
- */
- mem_addr = (uint)(&immr->im_dprambase[0x1000]);
-
- /* Set the physical address of the host memory buffers in
- * the buffer descriptors.
- */
- bdp = (cbd_t *)&immr->im_dprambase[up->smc_rbase];
- bdp->cbd_bufaddr = mem_addr;
-
- bdp = (cbd_t *)&immr->im_dprambase[up->smc_tbase];
- bdp->cbd_bufaddr = mem_addr+RX_BUF_SIZE;
-
- up->smc_mrblr = RX_BUF_SIZE; /* receive buffer length */
- up->smc_maxidl = RX_BUF_SIZE;
-}
-#endif
-
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-{
- *index = c->index;
- return serial_driver;
-}
-
-/*
- * Register console.
- */
-static int __init console_8xx_init(void)
-{
- register_console(&sercons);
- return 0;
-}
-
-console_initcall(console_8xx_init);
-
-#endif
-
-/* Default console baud rate as determined by the board information
- * structure.
- */
-static int baud_idx;
-
-static struct tty_operations rs_8xx_ops = {
- .open = rs_8xx_open,
- .close = rs_8xx_close,
- .write = rs_8xx_write,
- .put_char = rs_8xx_put_char,
- .write_room = rs_8xx_write_room,
- .chars_in_buffer = rs_8xx_chars_in_buffer,
- .flush_buffer = rs_8xx_flush_buffer,
- .ioctl = rs_8xx_ioctl,
- .throttle = rs_8xx_throttle,
- .unthrottle = rs_8xx_unthrottle,
- .send_xchar = rs_8xx_send_xchar,
- .set_termios = rs_8xx_set_termios,
- .stop = rs_8xx_stop,
- .start = rs_8xx_start,
- .hangup = rs_8xx_hangup,
- .wait_until_sent = rs_8xx_wait_until_sent,
- .read_proc = rs_8xx_read_proc,
-};
-
-/*
- * The serial driver boot-time initialization code!
- */
-static int __init rs_8xx_init(void)
-{
- struct serial_state * state;
- ser_info_t *info;
- uint mem_addr, dp_addr;
- int i, j, idx;
- uint page, sblock;
- volatile cbd_t *bdp;
- volatile cpm8260_t *cp;
- volatile smc_t *sp;
- volatile smc_uart_t *up;
- volatile scc_t *scp;
- volatile scc_uart_t *sup;
- volatile immap_t *immap;
- volatile iop8260_t *io;
-
- serial_driver = alloc_tty_driver(NR_PORTS);
- if (!serial_driver)
- return -ENOMEM;
-
- show_serial_version();
-
- /* Initialize the tty_driver structure */
-
- serial_driver->owner = THIS_MODULE;
- serial_driver->driver_name = "serial";
- serial_driver->devfs_name = "tts/";
- serial_driver->name = "ttyS";
- serial_driver->major = TTY_MAJOR;
- serial_driver->minor_start = 64;
- serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
- serial_driver->subtype = SERIAL_TYPE_NORMAL;
- serial_driver->init_termios = tty_std_termios;
- serial_driver->init_termios.c_cflag =
- baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
- serial_driver->flags = TTY_DRIVER_REAL_RAW;
- tty_set_operations(serial_driver, &rs_8xx_ops);
- if (tty_register_driver(serial_driver))
- panic("Couldn't register serial driver\n");
-
- immap = immr;
- cp = &immap->im_cpm;
- io = &immap->im_ioport;
-
- /* This should have been done long ago by the early boot code,
- * but do it again to make sure.
- */
- *(ushort *)(&immap->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1;
- *(ushort *)(&immap->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2;
-
- /* Geeze, here we go....Picking I/O port bits....Lots of
- * choices. If you don't like mine, pick your own.
- * Configure SMCs Tx/Rx. SMC1 is only on Port D, SMC2 is
- * only on Port A. You either pick 'em, or not.
- */
-#ifndef SCC_CONSOLE
- io->iop_ppard |= 0x00c00000;
- io->iop_pdird |= 0x00400000;
- io->iop_pdird &= ~0x00800000;
- io->iop_psord &= ~0x00c00000;
-#ifdef USE_SMC2
- io->iop_ppara |= 0x00c00000;
- io->iop_pdira |= 0x00400000;
- io->iop_pdira &= ~0x00800000;
- io->iop_psora &= ~0x00c00000;
-#endif
-
- /* Configure SCC2 and SCC3. Be careful about the fine print.
- * Secondary options are only available when you take away
- * the primary option. Unless the pins are used for something
- * else, SCC2 and SCC3 are on Port B.
- * Port B, 8 - SCC3 TxD
- * Port B, 12 - SCC2 TxD
- * Port B, 14 - SCC3 RxD
- * Port B, 15 - SCC2 RxD
- */
- io->iop_pparb |= 0x008b0000;
- io->iop_pdirb |= 0x00880000;
- io->iop_psorb |= 0x00880000;
- io->iop_pdirb &= ~0x00030000;
- io->iop_psorb &= ~0x00030000;
-
- /* Wire BRG1 to SMC1 and BRG2 to SMC2.
- */
- immap->im_cpmux.cmx_smr = 0;
-
- /* Connect SCC2 and SCC3 to NMSI. Connect BRG3 to SCC2 and
- * BRG4 to SCC3.
- */
- immap->im_cpmux.cmx_scr &= ~0x00ffff00;
- immap->im_cpmux.cmx_scr |= 0x00121b00;
-#else
- io->iop_pparb |= 0x008b0000;
- io->iop_pdirb |= 0x00880000;
- io->iop_psorb |= 0x00880000;
- io->iop_pdirb &= ~0x00030000;
- io->iop_psorb &= ~0x00030000;
-
- /* Use Port D for SCC1 instead of other functions.
- */
- io->iop_ppard |= 0x00000003;
- io->iop_psord &= ~0x00000001; /* Rx */
- io->iop_psord |= 0x00000002; /* Tx */
- io->iop_pdird &= ~0x00000001; /* Rx */
- io->iop_pdird |= 0x00000002; /* Tx */
-
- /* Connect SCC1, SCC2, SCC3 to NMSI. Connect BRG1 to SCC1,
- * BRG2 to SCC2, BRG3 to SCC3.
- */
- immap->im_cpmux.cmx_scr &= ~0xffffff00;
- immap->im_cpmux.cmx_scr |= 0x00091200;
-#endif
-
- for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
- state->magic = SSTATE_MAGIC;
- state->line = i;
- state->type = PORT_UNKNOWN;
- state->custom_divisor = 0;
- state->close_delay = 5*HZ/10;
- state->closing_wait = 30*HZ;
- state->icount.cts = state->icount.dsr =
- state->icount.rng = state->icount.dcd = 0;
- state->icount.rx = state->icount.tx = 0;
- state->icount.frame = state->icount.parity = 0;
- state->icount.overrun = state->icount.brk = 0;
- printk (KERN_INFO "ttyS%d on %s%d at 0x%04x, BRG%d\n",
- i,
- (state->smc_scc_num < SCC_NUM_BASE) ? "SMC" : "SCC",
- PORT_NUM(state->smc_scc_num) + 1,
- (unsigned int)(state->port),
- state->smc_scc_num + 1);
-#ifdef CONFIG_SERIAL_CONSOLE
- /* If we just printed the message on the console port, and
- * we are about to initialize it for general use, we have
- * to wait a couple of character times for the CR/NL to
- * make it out of the transmit buffer.
- */
- if (i == CONFIG_SERIAL_CONSOLE_PORT)
- mdelay(300);
-#endif
- info = kmalloc(sizeof(ser_info_t), GFP_KERNEL);
- if (info) {
- /*memset(info, 0, sizeof(ser_info_t));*/
- __clear_user(info,sizeof(ser_info_t));
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- info->magic = SERIAL_MAGIC;
- info->flags = state->flags;
- INIT_WORK(&info->tqueue, do_softint, info);
- INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
- info->line = i;
- info->state = state;
- state->info = (struct async_struct *)info;
-
- /* We need to allocate a transmit and receive buffer
- * descriptors from dual port ram, and a character
- * buffer area from host mem.
- */
- dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * RX_NUM_FIFO, 8);
-
- /* Allocate space for FIFOs in the host memory.
- */
- mem_addr = m8260_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE, 1);
-
- /* Set the physical address of the host memory
- * buffers in the buffer descriptors, and the
- * virtual address for us to work with.
- */
- bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
- info->rx_cur = info->rx_bd_base = (cbd_t *)bdp;
-
- for (j=0; j<(RX_NUM_FIFO-1); j++) {
- bdp->cbd_bufaddr = __pa(mem_addr);
- bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT;
- mem_addr += RX_BUF_SIZE;
- bdp++;
- }
- bdp->cbd_bufaddr = __pa(mem_addr);
- bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
- if ((idx = state->smc_scc_num) < SCC_NUM_BASE) {
- sp = &immap->im_smc[idx];
- up = (smc_uart_t *)&immap->im_dprambase[state->port];
- up->smc_rbase = dp_addr;
- }
- else {
- scp = &immap->im_scc[idx - SCC_IDX_BASE];
- sup = (scc_uart_t *)&immap->im_dprambase[state->port];
- scp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
- sup->scc_genscc.scc_rbase = dp_addr;
- }
-
- dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * TX_NUM_FIFO, 8);
-
- /* Allocate space for FIFOs in the host memory.
- */
- mem_addr = m8260_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE, 1);
-
- /* Set the physical address of the host memory
- * buffers in the buffer descriptors, and the
- * virtual address for us to work with.
- */
- bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
- info->tx_cur = info->tx_bd_base = (cbd_t *)bdp;
-
- for (j=0; j<(TX_NUM_FIFO-1); j++) {
- bdp->cbd_bufaddr = __pa(mem_addr);
- bdp->cbd_sc = BD_SC_INTRPT;
- mem_addr += TX_BUF_SIZE;
- bdp++;
- }
- bdp->cbd_bufaddr = __pa(mem_addr);
- bdp->cbd_sc = (BD_SC_WRAP | BD_SC_INTRPT);
-
- if (idx < SCC_NUM_BASE) {
- up->smc_tbase = dp_addr;
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- up->smc_rfcr = CPMFCR_GBL | CPMFCR_EB;
- up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
- /* Set this to 1 for now, so we get single
- * character interrupts. Using idle charater
- * time requires some additional tuning.
- */
- up->smc_mrblr = 1;
- up->smc_maxidl = 0;
- up->smc_brkcr = 1;
-
- /* Send the CPM an initialize command.
- */
- if (state->smc_scc_num == 0) {
- page = CPM_CR_SMC1_PAGE;
- sblock = CPM_CR_SMC1_SBLOCK;
- }
- else {
- page = CPM_CR_SMC2_PAGE;
- sblock = CPM_CR_SMC2_SBLOCK;
- }
-
- cp->cp_cpcr = mk_cr_cmd(page, sblock, 0,
- CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- sp->smc_smcm = 0;
- sp->smc_smce = 0xff;
- }
- else {
- sup->scc_genscc.scc_tbase = dp_addr;
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- sup->scc_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
- sup->scc_genscc.scc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
- /* Set this to 1 for now, so we get single
- * character interrupts. Using idle charater
- * time requires some additional tuning.
- */
- sup->scc_genscc.scc_mrblr = 1;
- sup->scc_maxidl = 0;
- sup->scc_brkcr = 1;
- sup->scc_parec = 0;
- sup->scc_frmec = 0;
- sup->scc_nosec = 0;
- sup->scc_brkec = 0;
- sup->scc_uaddr1 = 0;
- sup->scc_uaddr2 = 0;
- sup->scc_toseq = 0;
- sup->scc_char1 = 0x8000;
- sup->scc_char2 = 0x8000;
- sup->scc_char3 = 0x8000;
- sup->scc_char4 = 0x8000;
- sup->scc_char5 = 0x8000;
- sup->scc_char6 = 0x8000;
- sup->scc_char7 = 0x8000;
- sup->scc_char8 = 0x8000;
- sup->scc_rccm = 0xc0ff;
-
- /* Send the CPM an initialize command.
- */
-#ifdef SCC_CONSOLE
- switch (state->smc_scc_num) {
- case 0:
- page = CPM_CR_SCC1_PAGE;
- sblock = CPM_CR_SCC1_SBLOCK;
- break;
- case 1:
- page = CPM_CR_SCC2_PAGE;
- sblock = CPM_CR_SCC2_SBLOCK;
- break;
- case 2:
- page = CPM_CR_SCC3_PAGE;
- sblock = CPM_CR_SCC3_SBLOCK;
- break;
- }
-#else
- if (state->smc_scc_num == 2) {
- page = CPM_CR_SCC2_PAGE;
- sblock = CPM_CR_SCC2_SBLOCK;
- }
- else {
- page = CPM_CR_SCC3_PAGE;
- sblock = CPM_CR_SCC3_SBLOCK;
- }
-#endif
-
- cp->cp_cpcr = mk_cr_cmd(page, sblock, 0,
- CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- scp->scc_gsmrh = 0;
- scp->scc_gsmrl =
- (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- scp->scc_sccm = 0;
- scp->scc_scce = 0xffff;
- scp->scc_dsr = 0x7e7e;
- scp->scc_pmsr = 0x3000;
- }
-
- /* Install interrupt handler.
- */
- request_irq(state->irq, rs_8xx_interrupt, 0, "uart", info);
-
- /* Set up the baud rate generator.
- */
- m8260_cpm_setbrg(state->smc_scc_num,
- baud_table[baud_idx]);
-
- /* If the port is the console, enable Rx and Tx.
- */
-#ifdef CONFIG_SERIAL_CONSOLE
- if (i == CONFIG_SERIAL_CONSOLE_PORT) {
- if (idx < SCC_NUM_BASE)
- sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
- else
- scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
- }
-#endif
- }
- }
- return 0;
-}
-module_init(rs_8xx_init);
-
-/* This must always be called before the rs_8xx_init() function, otherwise
- * it blows away the port control information.
-*/
-static int __init serial_console_setup(struct console *co, char *options)
-{
- struct serial_state *ser;
- uint mem_addr, dp_addr, bidx;
- volatile cbd_t *bdp;
- volatile cpm8260_t *cp;
- volatile immap_t *immap;
-#ifndef SCC_CONSOLE
- volatile smc_t *sp;
- volatile smc_uart_t *up;
-#endif
-#ifdef SCC_CONSOLE
- volatile scc_t *scp;
- volatile scc_uart_t *sup;
-#endif
- volatile iop8260_t *io;
- bd_t *bd;
-
- bd = (bd_t *)__res;
-
- for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
- if (bd->bi_baudrate == baud_table[bidx])
- break;
-
- co->cflag = CREAD|CLOCAL|bidx|CS8;
- baud_idx = bidx;
-
- ser = rs_table + co->index;
-
- immap = immr;
- cp = &immap->im_cpm;
- io = &immap->im_ioport;
-
-#ifdef SCC_CONSOLE
- scp = (scc_t *)&(immap->im_scc[SCC_CONSOLE-1]);
- sup = (scc_uart_t *)&immap->im_dprambase[PROFF_SCC1 + ((SCC_CONSOLE-1) << 8)];
- scp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
- scp->scc_gsmrl &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
- /* Use Port D for SCC1 instead of other functions.
- */
- io->iop_ppard |= 0x00000003;
- io->iop_psord &= ~0x00000001; /* Rx */
- io->iop_psord |= 0x00000002; /* Tx */
- io->iop_pdird &= ~0x00000001; /* Rx */
- io->iop_pdird |= 0x00000002; /* Tx */
-
-#else
- /* This should have been done long ago by the early boot code,
- * but do it again to make sure.
- */
- *(ushort *)(&immap->im_dprambase[PROFF_SMC1_BASE]) = PROFF_SMC1;
- *(ushort *)(&immap->im_dprambase[PROFF_SMC2_BASE]) = PROFF_SMC2;
-
- /* Right now, assume we are using SMCs.
- */
- sp = &immap->im_smc[ser->smc_scc_num];
-
- /* When we get here, the CPM has been reset, so we need
- * to configure the port.
- * We need to allocate a transmit and receive buffer descriptor
- * from dual port ram, and a character buffer area from host mem.
- */
- up = (smc_uart_t *)&immap->im_dprambase[ser->port];
-
- /* Disable transmitter/receiver.
- */
- sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
-
- /* Use Port D for SMC1 instead of other functions.
- */
- io->iop_ppard |= 0x00c00000;
- io->iop_pdird |= 0x00400000;
- io->iop_pdird &= ~0x00800000;
- io->iop_psord &= ~0x00c00000;
-#endif
-
- /* Allocate space for two buffer descriptors in the DP ram.
- */
- dp_addr = m8260_cpm_dpalloc(sizeof(cbd_t) * 2, 8);
-
- /* Allocate space for two 2 byte FIFOs in the host memory.
- */
- mem_addr = m8260_cpm_hostalloc(4, 1);
-
- /* Set the physical address of the host memory buffers in
- * the buffer descriptors.
- */
- bdp = (cbd_t *)&immap->im_dprambase[dp_addr];
- bdp->cbd_bufaddr = __pa(mem_addr);
- (bdp+1)->cbd_bufaddr = __pa(mem_addr+2);
-
- /* For the receive, set empty and wrap.
- * For transmit, set wrap.
- */
- bdp->cbd_sc = BD_SC_EMPTY | BD_SC_WRAP;
- (bdp+1)->cbd_sc = BD_SC_WRAP;
-
- /* Set up the uart parameters in the parameter ram.
- */
-#ifdef SCC_CONSOLE
- sup->scc_genscc.scc_rbase = dp_addr;
- sup->scc_genscc.scc_tbase = dp_addr + sizeof(cbd_t);
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- sup->scc_genscc.scc_rfcr = CPMFCR_GBL | CPMFCR_EB;
- sup->scc_genscc.scc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
- sup->scc_genscc.scc_mrblr = 1;
- sup->scc_maxidl = 0;
- sup->scc_brkcr = 1;
- sup->scc_parec = 0;
- sup->scc_frmec = 0;
- sup->scc_nosec = 0;
- sup->scc_brkec = 0;
- sup->scc_uaddr1 = 0;
- sup->scc_uaddr2 = 0;
- sup->scc_toseq = 0;
- sup->scc_char1 = 0x8000;
- sup->scc_char2 = 0x8000;
- sup->scc_char3 = 0x8000;
- sup->scc_char4 = 0x8000;
- sup->scc_char5 = 0x8000;
- sup->scc_char6 = 0x8000;
- sup->scc_char7 = 0x8000;
- sup->scc_char8 = 0x8000;
- sup->scc_rccm = 0xc0ff;
-
- /* Send the CPM an initialize command.
- */
- cp->cp_cpcr = mk_cr_cmd(CPM_CR_SCC1_PAGE, CPM_CR_SCC1_SBLOCK, 0,
- CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- scp->scc_gsmrh = 0;
- scp->scc_gsmrl =
- (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- scp->scc_sccm = 0;
- scp->scc_scce = 0xffff;
- scp->scc_dsr = 0x7e7e;
- scp->scc_pmsr = 0x3000;
-
- /* Wire BRG1 to SCC1. The serial init will take care of
- * others.
- */
- immap->im_cpmux.cmx_scr = 0;
-
- /* Set up the baud rate generator.
- */
- m8260_cpm_setbrg(ser->smc_scc_num, bd->bi_baudrate);
-
- scp->scc_gsmrl |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#else
- up->smc_rbase = dp_addr; /* Base of receive buffer desc. */
- up->smc_tbase = dp_addr+sizeof(cbd_t); /* Base of xmt buffer desc. */
- up->smc_rfcr = CPMFCR_GBL | CPMFCR_EB;
- up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB;
-
- /* Set this to 1 for now, so we get single character interrupts.
- */
- up->smc_mrblr = 1; /* receive buffer length */
- up->smc_maxidl = 0; /* wait forever for next char */
-
- /* Send the CPM an initialize command.
- */
- cp->cp_cpcr = mk_cr_cmd(CPM_CR_SMC1_PAGE, CPM_CR_SMC1_SBLOCK, 0,
- CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cpcr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
- /* Set up the baud rate generator.
- */
- m8260_cpm_setbrg(ser->smc_scc_num, bd->bi_baudrate);
-
- /* And finally, enable Rx and Tx.
- */
- sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-#endif
-
- return 0;
-}
+++ /dev/null
-/*
- * This file is derived from zlib.h and zconf.h from the zlib-0.95
- * distribution by Jean-loup Gailly and Mark Adler, with some additions
- * by Paul Mackerras to aid in implementing Deflate compression and
- * decompression for PPP packets.
- */
-
-/*
- * ==FILEVERSION 960122==
- *
- * This marker is used by the Linux installation script to determine
- * whether an up-to-date version of this file is already installed.
- */
-
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 0.95, Aug 16th, 1995.
-
- Copyright (C) 1995 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- gzip@prep.ai.mit.edu madler@alumni.caltech.edu
- */
-
-#ifndef _ZLIB_H
-#define _ZLIB_H
-
-/* #include "zconf.h" */ /* included directly here */
-
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp */
-
-/*
- The library does not install any signal handler. It is recommended to
- add at least a handler for SIGSEGV when decompressing; the library checks
- the consistency of the input data whenever possible but may go nuts
- for some forms of corrupted input.
- */
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- * Compile with -DUNALIGNED_OK if it is OK to access shorts or ints
- * at addresses which are not a multiple of their size.
- * Under DOS, -DFAR=far or -DFAR=__far may be needed.
- */
-
-#ifndef STDC
-# if defined(MSDOS) || defined(__STDC__) || defined(__cplusplus)
-# define STDC
-# endif
-#endif
-
-#ifdef __MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */
-# include <unix.h>
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- 1 << (windowBits+2) + 1 << (memLevel+9)
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-typedef unsigned char Byte; /* 8 bits */
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-typedef Byte FAR Bytef;
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-/* end of original zconf.h */
-
-#define ZLIB_VERSION "0.95P"
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms may be added later and will have the same
- stream interface.
-
- For compression the application must provide the output buffer and
- may optionally provide the input buffer for optimization. For decompression,
- the application must provide the input buffer and may optionally provide
- the output buffer for optimization.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt nbytes));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidp opaque; /* private data object passed to zalloc and zfree */
-
- Byte data_type; /* best guess about the data type: ascii or binary */
-
-} z_stream;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1
-#define Z_FULL_FLUSH 2
-#define Z_SYNC_FLUSH 3 /* experimental: partial_flush + byte align */
-#define Z_FINISH 4
-#define Z_PACKET_FLUSH 5
-/* See deflate() below for the usage of these constants */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-/* error codes for the compression/decompression functions */
-
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_DEFAULT_STRATEGY 0
-
-#define Z_BINARY 0
-#define Z_ASCII 1
-#define Z_UNKNOWN 2
-/* Used to set the data_type field */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-extern char *zlib_version;
-/* The application can compare zlib_version and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- */
-
- /* basic functions */
-
-extern int inflateInit OF((z_stream *strm));
-/*
- Initializes the internal stream state for decompression. The fields
- zalloc and zfree must be initialized before by the caller. If zalloc and
- zfree are set to Z_NULL, inflateInit updates them to use default allocation
- functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory. msg is set to null if there is no error message.
- inflateInit does not perform any decompression: this will be done by
- inflate().
-*/
-
-
-extern int inflate OF((z_stream *strm, int flush));
-/*
- Performs one or both of the following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() always provides as much output as possible
- (until there is no more input data or no more space in the output buffer).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate().
-
- If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH,
- inflate flushes as much output as possible to the output buffer. The
- flushing behavior of inflate is not specified for values of the flush
- parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the
- current implementation actually flushes as much output as possible
- anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data
- has been consumed, it is expecting to see the length field of a stored
- block; if not, it returns Z_DATA_ERROR.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster routine
- may be used for the single inflate() call.
-
- inflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if the end of the
- compressed data has been reached and all uncompressed output has been
- produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if
- the stream structure was inconsistent (for example if next_in or next_out
- was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no
- progress is possible or if there was not enough room in the output buffer
- when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then
- call inflateSync to look for a good compression block. */
-
-
-extern int inflateEnd OF((z_stream *strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* advanced functions */
-
-extern int inflateInit2 OF((z_stream *strm,
- int windowBits));
-/*
- This is another version of inflateInit with more compression options. The
- fields next_out, zalloc and zfree must be initialized before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library (the value 16 will be allowed soon). The
- default value is 15 if inflateInit is used instead. If a compressed stream
- with a larger window size is given as input, inflate() will return with
- the error code Z_DATA_ERROR instead of trying to allocate a larger window.
-
- If next_out is not null, the library will use this buffer for the history
- buffer; the buffer must either be large enough to hold the entire output
- data, or have at least 1<<windowBits bytes. If next_out is null, the
- library will allocate its own buffer (and leave next_out null). next_in
- need not be provided here but must be provided by the application for the
- next call of inflate().
-
- If the history buffer is provided by the application, next_out must
- never be changed by the application since the decompressor maintains
- history information inside this buffer from call to call; the application
- can only reset next_out to the beginning of the history buffer when
- avail_out is zero and all output has been consumed.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was
- not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as
- windowBits < 8). msg is set to null if there is no error message.
- inflateInit2 does not perform any decompression: this will be done by
- inflate().
-*/
-
-extern int inflateSync OF((z_stream *strm));
-/*
- Skips invalid compressed data until the special marker (see deflate()
- above) can be found, or until all available input is skipped. No output
- is provided.
-
- inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no marker has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-extern int inflateReset OF((z_stream *strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-extern int inflateIncomp OF((z_stream *strm));
-/*
- This function adds the data at next_in (avail_in bytes) to the output
- history without performing any output. There must be no pending output,
- and the decompressor must be expecting to see the start of a block.
- Calling this function is equivalent to decompressing a stored block
- containing the data at next_in (except that the data is not output).
-*/
-
- /* checksum functions */
-
-/*
- This function is not related to compression but is exported
- anyway because it might be useful in applications using the
- compression library.
-*/
-
-extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len));
-
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-#ifndef _Z_UTIL_H
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-#endif /* _ZLIB_H */
+++ /dev/null
-/*
- * This file is derived from various .h and .c files from the zlib-0.95
- * distribution by Jean-loup Gailly and Mark Adler, with some additions
- * by Paul Mackerras to aid in implementing Deflate compression and
- * decompression for PPP packets. See zlib.h for conditions of
- * distribution and use.
- *
- * Changes that have been made include:
- * - changed functions not used outside this file to "local"
- * - added minCompression parameter to deflateInit2
- * - added Z_PACKET_FLUSH (see zlib.h for details)
- * - added inflateIncomp
- *
- */
-
-/*+++++*/
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* From: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp */
-
-#define _Z_UTIL_H
-
-#include "zlib.h"
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-#define FAR
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern char *z_errmsg[]; /* indexed by 1-zlib_error */
-
-#define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err)
-/* To be used only when the state is known to be valid */
-
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
- /* common constants */
-
-#define DEFLATED 8
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
- /* functions */
-
-#include <linux/string.h>
-#define zmemcpy memcpy
-#define zmemzero(dest, len) memset(dest, 0, len)
-
-/* Diagnostic functions */
-#ifdef DEBUG_ZLIB
-# include <stdio.h>
-# ifndef verbose
-# define verbose 0
-# endif
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) fprintf x
-# define Tracev(x) {if (verbose) fprintf x ;}
-# define Tracevv(x) {if (verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len));
-
-/* voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); */
-/* void zcfree OF((voidpf opaque, voidpf ptr)); */
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr, size) \
- (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), (size))
-#define TRY_FREE(s, p, n) {if (p) ZFREE(s, p, n);}
-
-/* deflate.h -- internal compression state
- * Copyright (C) 1995 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/*+++++*/
-/* infblock.h -- header to use infblock.c
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_blocks_state;
-typedef struct inflate_blocks_state FAR inflate_blocks_statef;
-
-local inflate_blocks_statef * inflate_blocks_new OF((
- z_stream *z,
- check_func c, /* check function */
- uInt w)); /* window size */
-
-local int inflate_blocks OF((
- inflate_blocks_statef *,
- z_stream *,
- int)); /* initial return code */
-
-local void inflate_blocks_reset OF((
- inflate_blocks_statef *,
- z_stream *,
- uLongf *)); /* check value on output */
-
-local int inflate_blocks_free OF((
- inflate_blocks_statef *,
- z_stream *,
- uLongf *)); /* check value on output */
-
-local int inflate_addhistory OF((
- inflate_blocks_statef *,
- z_stream *));
-
-local int inflate_packet_flush OF((
- inflate_blocks_statef *));
-
-/*+++++*/
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Huffman code lookup table entry--this entry is four bytes for machines
- that have 16-bit pointers (e.g. PC's in the small or medium model). */
-
-typedef struct inflate_huft_s FAR inflate_huft;
-
-struct inflate_huft_s {
- union {
- struct {
- Byte Exop; /* number of extra bits or operation */
- Byte Bits; /* number of bits in this code or subcode */
- } what;
- uInt Nalloc; /* number of these allocated here */
- Bytef *pad; /* pad structure to a power of 2 (4 bytes for */
- } word; /* 16-bit, 8 bytes for 32-bit machines) */
- union {
- uInt Base; /* literal, length base, or distance base */
- inflate_huft *Next; /* pointer to next level of table */
- } more;
-};
-
-#ifdef DEBUG_ZLIB
- local uInt inflate_hufts;
-#endif
-
-local int inflate_trees_bits OF((
- uIntf *, /* 19 code lengths */
- uIntf *, /* bits tree desired/actual depth */
- inflate_huft * FAR *, /* bits tree result */
- z_stream *)); /* for zalloc, zfree functions */
-
-local int inflate_trees_dynamic OF((
- uInt, /* number of literal/length codes */
- uInt, /* number of distance codes */
- uIntf *, /* that many (total) code lengths */
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *, /* distance tree result */
- z_stream *)); /* for zalloc, zfree functions */
-
-local int inflate_trees_fixed OF((
- uIntf *, /* literal desired/actual bit depth */
- uIntf *, /* distance desired/actual bit depth */
- inflate_huft * FAR *, /* literal/length tree result */
- inflate_huft * FAR *)); /* distance tree result */
-
-local int inflate_trees_free OF((
- inflate_huft *, /* tables to free */
- z_stream *)); /* for zfree function */
-
-
-/*+++++*/
-/* infcodes.h -- header to use infcodes.c
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-struct inflate_codes_state;
-typedef struct inflate_codes_state FAR inflate_codes_statef;
-
-local inflate_codes_statef *inflate_codes_new OF((
- uInt, uInt,
- inflate_huft *, inflate_huft *,
- z_stream *));
-
-local int inflate_codes OF((
- inflate_blocks_statef *,
- z_stream *,
- int));
-
-local void inflate_codes_free OF((
- inflate_codes_statef *,
- z_stream *));
-
-
-/*+++++*/
-/* inflate.c -- zlib interface to inflate modules
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* inflate private state */
-struct internal_state {
-
- /* mode */
- enum {
- METHOD, /* waiting for method byte */
- FLAG, /* waiting for flag byte */
- BLOCKS, /* decompressing blocks */
- CHECK4, /* four check bytes to go */
- CHECK3, /* three check bytes to go */
- CHECK2, /* two check bytes to go */
- CHECK1, /* one check byte to go */
- DONE, /* finished check, done */
- BAD} /* got an error--stay here */
- mode; /* current inflate mode */
-
- /* mode dependent information */
- union {
- uInt method; /* if FLAGS, method byte */
- struct {
- uLong was; /* computed check value */
- uLong need; /* stream check value */
- } check; /* if CHECK, check values to compare */
- uInt marker; /* if BAD, inflateSync's marker bytes count */
- } sub; /* submode */
-
- /* mode independent information */
- int nowrap; /* flag for no wrapper */
- uInt wbits; /* log2(window size) (8..15, defaults to 15) */
- inflate_blocks_statef
- *blocks; /* current inflate_blocks state */
-
-};
-
-
-int inflateReset(
- z_stream *z
-)
-{
- uLong c;
-
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- z->total_in = z->total_out = 0;
- z->msg = Z_NULL;
- z->state->mode = z->state->nowrap ? BLOCKS : METHOD;
- inflate_blocks_reset(z->state->blocks, z, &c);
- Trace((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-
-int inflateEnd(
- z_stream *z
-)
-{
- uLong c;
-
- if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->blocks != Z_NULL)
- inflate_blocks_free(z->state->blocks, z, &c);
- ZFREE(z, z->state, sizeof(struct internal_state));
- z->state = Z_NULL;
- Trace((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-
-int inflateInit2(
- z_stream *z,
- int w
-)
-{
- /* initialize state */
- if (z == Z_NULL)
- return Z_STREAM_ERROR;
-/* if (z->zalloc == Z_NULL) z->zalloc = zcalloc; */
-/* if (z->zfree == Z_NULL) z->zfree = zcfree; */
- if ((z->state = (struct internal_state FAR *)
- ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL)
- return Z_MEM_ERROR;
- z->state->blocks = Z_NULL;
-
- /* handle undocumented nowrap option (no zlib header or check) */
- z->state->nowrap = 0;
- if (w < 0)
- {
- w = - w;
- z->state->nowrap = 1;
- }
-
- /* set window size */
- if (w < 8 || w > 15)
- {
- inflateEnd(z);
- return Z_STREAM_ERROR;
- }
- z->state->wbits = (uInt)w;
-
- /* create inflate_blocks state */
- if ((z->state->blocks =
- inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, 1 << w))
- == Z_NULL)
- {
- inflateEnd(z);
- return Z_MEM_ERROR;
- }
- Trace((stderr, "inflate: allocated\n"));
-
- /* reset state */
- inflateReset(z);
- return Z_OK;
-}
-
-
-int inflateInit(
- z_stream *z
-)
-{
- return inflateInit2(z, DEF_WBITS);
-}
-
-
-#define NEEDBYTE {if(z->avail_in==0)goto empty;r=Z_OK;}
-#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
-
-int inflate(
- z_stream *z,
- int f
-)
-{
- int r;
- uInt b;
-
- if (z == Z_NULL || z->next_in == Z_NULL)
- return Z_STREAM_ERROR;
- r = Z_BUF_ERROR;
- while (1) switch (z->state->mode)
- {
- case METHOD:
- NEEDBYTE
- if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED)
- {
- z->state->mode = BAD;
- z->msg = "unknown compression method";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- if ((z->state->sub.method >> 4) + 8 > z->state->wbits)
- {
- z->state->mode = BAD;
- z->msg = "invalid window size";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- z->state->mode = FLAG;
- case FLAG:
- NEEDBYTE
- if ((b = NEXTBYTE) & 0x20)
- {
- z->state->mode = BAD;
- z->msg = "invalid reserved bit";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- if (((z->state->sub.method << 8) + b) % 31)
- {
- z->state->mode = BAD;
- z->msg = "incorrect header check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Trace((stderr, "inflate: zlib header ok\n"));
- z->state->mode = BLOCKS;
- case BLOCKS:
- r = inflate_blocks(z->state->blocks, z, r);
- if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0)
- r = inflate_packet_flush(z->state->blocks);
- if (r == Z_DATA_ERROR)
- {
- z->state->mode = BAD;
- z->state->sub.marker = 0; /* can try inflateSync */
- break;
- }
- if (r != Z_STREAM_END)
- return r;
- r = Z_OK;
- inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was);
- if (z->state->nowrap)
- {
- z->state->mode = DONE;
- break;
- }
- z->state->mode = CHECK4;
- case CHECK4:
- NEEDBYTE
- z->state->sub.check.need = (uLong)NEXTBYTE << 24;
- z->state->mode = CHECK3;
- case CHECK3:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 16;
- z->state->mode = CHECK2;
- case CHECK2:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE << 8;
- z->state->mode = CHECK1;
- case CHECK1:
- NEEDBYTE
- z->state->sub.check.need += (uLong)NEXTBYTE;
-
- if (z->state->sub.check.was != z->state->sub.check.need)
- {
- z->state->mode = BAD;
- z->msg = "incorrect data check";
- z->state->sub.marker = 5; /* can't try inflateSync */
- break;
- }
- Trace((stderr, "inflate: zlib check ok\n"));
- z->state->mode = DONE;
- case DONE:
- return Z_STREAM_END;
- case BAD:
- return Z_DATA_ERROR;
- default:
- return Z_STREAM_ERROR;
- }
-
- empty:
- if (f != Z_PACKET_FLUSH)
- return r;
- z->state->mode = BAD;
- z->state->sub.marker = 0; /* can try inflateSync */
- return Z_DATA_ERROR;
-}
-
-/*
- * This subroutine adds the data at next_in/avail_in to the output history
- * without performing any output. The output buffer must be "caught up";
- * i.e. no pending output (hence s->read equals s->write), and the state must
- * be BLOCKS (i.e. we should be willing to see the start of a series of
- * BLOCKS). On exit, the output will also be caught up, and the checksum
- * will have been updated if need be.
- */
-
-int inflateIncomp(
- z_stream *z
-)
-{
- if (z->state->mode != BLOCKS)
- return Z_DATA_ERROR;
- return inflate_addhistory(z->state->blocks, z);
-}
-
-
-int inflateSync(
- z_stream *z
-)
-{
- uInt n; /* number of bytes to look at */
- Bytef *p; /* pointer to bytes */
- uInt m; /* number of marker bytes found in a row */
- uLong r, w; /* temporaries to save total_in and total_out */
-
- /* set up */
- if (z == Z_NULL || z->state == Z_NULL)
- return Z_STREAM_ERROR;
- if (z->state->mode != BAD)
- {
- z->state->mode = BAD;
- z->state->sub.marker = 0;
- }
- if ((n = z->avail_in) == 0)
- return Z_BUF_ERROR;
- p = z->next_in;
- m = z->state->sub.marker;
-
- /* search */
- while (n && m < 4)
- {
- if (*p == (Byte)(m < 2 ? 0 : 0xff))
- m++;
- else if (*p)
- m = 0;
- else
- m = 4 - m;
- p++, n--;
- }
-
- /* restore */
- z->total_in += p - z->next_in;
- z->next_in = p;
- z->avail_in = n;
- z->state->sub.marker = m;
-
- /* return no joy or set up to restart on a new block */
- if (m != 4)
- return Z_DATA_ERROR;
- r = z->total_in; w = z->total_out;
- inflateReset(z);
- z->total_in = r; z->total_out = w;
- z->state->mode = BLOCKS;
- return Z_OK;
-}
-
-#undef NEEDBYTE
-#undef NEXTBYTE
-
-/*+++++*/
-/* infutil.h -- types and macros common to blocks and codes
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* inflate blocks semi-private state */
-struct inflate_blocks_state {
-
- /* mode */
- enum {
- TYPE, /* get type bits (3, including end bit) */
- LENS, /* get lengths for stored */
- STORED, /* processing stored block */
- TABLE, /* get table lengths */
- BTREE, /* get bit lengths tree for a dynamic block */
- DTREE, /* get length, distance trees for a dynamic block */
- CODES, /* processing fixed or dynamic block */
- DRY, /* output remaining window bytes */
- DONEB, /* finished last block, done */
- BADB} /* got a data error--stuck here */
- mode; /* current inflate_block mode */
-
- /* mode dependent information */
- union {
- uInt left; /* if STORED, bytes left to copy */
- struct {
- uInt table; /* table lengths (14 bits) */
- uInt index; /* index into blens (or border) */
- uIntf *blens; /* bit lengths of codes */
- uInt bb; /* bit length tree depth */
- inflate_huft *tb; /* bit length decoding tree */
- int nblens; /* # elements allocated at blens */
- } trees; /* if DTREE, decoding info for trees */
- struct {
- inflate_huft *tl, *td; /* trees to free */
- inflate_codes_statef
- *codes;
- } decode; /* if CODES, current state */
- } sub; /* submode */
- uInt last; /* true if this block is the last block */
-
- /* mode independent information */
- uInt bitk; /* bits in bit buffer */
- uLong bitb; /* bit buffer */
- Bytef *window; /* sliding window */
- Bytef *end; /* one byte after sliding window */
- Bytef *read; /* window read pointer */
- Bytef *write; /* window write pointer */
- check_func checkfn; /* check function */
- uLong check; /* check on output */
-
-};
-
-
-/* defines for inflate input/output */
-/* update pointers and return */
-#define UPDBITS {s->bitb=b;s->bitk=k;}
-#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;}
-#define UPDOUT {s->write=q;}
-#define UPDATE {UPDBITS UPDIN UPDOUT}
-#define LEAVE {UPDATE return inflate_flush(s,z,r);}
-/* get bytes and bits */
-#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
-#define NEEDBYTE {if(n)r=Z_OK;else LEAVE}
-#define NEXTBYTE (n--,*p++)
-#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define DUMPBITS(j) {b>>=(j);k-=(j);}
-/* output bytes */
-#define WAVAIL (q<s->read?s->read-q-1:s->end-q)
-#define LOADOUT {q=s->write;m=WAVAIL;}
-#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}}
-#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT}
-#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;}
-#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
-/* load local pointers */
-#define LOAD {LOADIN LOADOUT}
-
-/* And'ing with mask[n] masks the lower n bits */
-local uInt inflate_mask[] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-/* copy as much as possible from the sliding window to the output area */
-local int inflate_flush OF((
- inflate_blocks_statef *,
- z_stream *,
- int));
-
-/*+++++*/
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-local int inflate_fast OF((
- uInt,
- uInt,
- inflate_huft *,
- inflate_huft *,
- inflate_blocks_statef *,
- z_stream *));
-
-
-/*+++++*/
-/* infblock.c -- interpret and process block types to last block
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* Table for deflate from PKZIP's appnote.txt. */
-local uInt border[] = { /* Order of the bit length code lengths */
- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
-/*
- Notes beyond the 1.93a appnote.txt:
-
- 1. Distance pointers never point before the beginning of the output
- stream.
- 2. Distance pointers can point back across blocks, up to 32k away.
- 3. There is an implied maximum of 7 bits for the bit length table and
- 15 bits for the actual data.
- 4. If only one code exists, then it is encoded using one bit. (Zero
- would be more efficient, but perhaps a little confusing.) If two
- codes exist, they are coded using one bit each (0 and 1).
- 5. There is no way of sending zero distance codes--a dummy must be
- sent if there are none. (History: a pre 2.0 version of PKZIP would
- store blocks with no distance codes, but this was discovered to be
- too harsh a criterion.) Valid only for 1.93a. 2.04c does allow
- zero distance codes, which is sent as one code of zero bits in
- length.
- 6. There are up to 286 literal/length codes. Code 256 represents the
- end-of-block. Note however that the static length tree defines
- 288 codes just to fill out the Huffman codes. Codes 286 and 287
- cannot be used though, since there is no length base or extra bits
- defined for them. Similarily, there are up to 30 distance codes.
- However, static trees define 32 codes (all 5 bits) to fill out the
- Huffman codes, but the last two had better not show up in the data.
- 7. Unzip can check dynamic Huffman blocks for complete code sets.
- The exception is that a single code would not be complete (see #4).
- 8. The five bits following the block type is really the number of
- literal codes sent minus 257.
- 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits
- (1+6+6). Therefore, to output three times the length, you output
- three codes (1+1+1), whereas to output four times the same length,
- you only need two codes (1+3). Hmm.
- 10. In the tree reconstruction algorithm, Code = Code + Increment
- only if BitLength(i) is not zero. (Pretty obvious.)
- 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19)
- 12. Note: length code 284 can represent 227-258, but length code 285
- really is 258. The last length deserves its own, short code
- since it gets used a lot in very redundant files. The length
- 258 is special since 258 - 3 (the min match length) is 255.
- 13. The literal/length and distance code bit lengths are read as a
- single stream of lengths. It is possible (and advantageous) for
- a repeat code (16, 17, or 18) to go across the boundary between
- the two sets of lengths.
- */
-
-
-local void inflate_blocks_reset(
- inflate_blocks_statef *s,
- z_stream *z,
- uLongf *c
-)
-{
- if (s->checkfn != Z_NULL)
- *c = s->check;
- if (s->mode == BTREE || s->mode == DTREE)
- ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
- if (s->mode == CODES)
- {
- inflate_codes_free(s->sub.decode.codes, z);
- inflate_trees_free(s->sub.decode.td, z);
- inflate_trees_free(s->sub.decode.tl, z);
- }
- s->mode = TYPE;
- s->bitk = 0;
- s->bitb = 0;
- s->read = s->write = s->window;
- if (s->checkfn != Z_NULL)
- s->check = (*s->checkfn)(0L, Z_NULL, 0);
- Trace((stderr, "inflate: blocks reset\n"));
-}
-
-
-local inflate_blocks_statef *inflate_blocks_new(
- z_stream *z,
- check_func c,
- uInt w
-)
-{
- inflate_blocks_statef *s;
-
- if ((s = (inflate_blocks_statef *)ZALLOC
- (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
- return s;
- if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL)
- {
- ZFREE(z, s, sizeof(struct inflate_blocks_state));
- return Z_NULL;
- }
- s->end = s->window + w;
- s->checkfn = c;
- s->mode = TYPE;
- Trace((stderr, "inflate: blocks allocated\n"));
- inflate_blocks_reset(s, z, &s->check);
- return s;
-}
-
-
-local int inflate_blocks(
- inflate_blocks_statef *s,
- z_stream *z,
- int r
-)
-{
- uInt t; /* temporary storage */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input based on current state */
- while (1) switch (s->mode)
- {
- case TYPE:
- NEEDBITS(3)
- t = (uInt)b & 7;
- s->last = t & 1;
- switch (t >> 1)
- {
- case 0: /* stored */
- Trace((stderr, "inflate: stored block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- t = k & 7; /* go to byte boundary */
- DUMPBITS(t)
- s->mode = LENS; /* get length of stored block */
- break;
- case 1: /* fixed */
- Trace((stderr, "inflate: fixed codes block%s\n",
- s->last ? " (last)" : ""));
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
-
- inflate_trees_fixed(&bl, &bd, &tl, &td);
- s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z);
- if (s->sub.decode.codes == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- s->sub.decode.tl = Z_NULL; /* don't try to free these */
- s->sub.decode.td = Z_NULL;
- }
- DUMPBITS(3)
- s->mode = CODES;
- break;
- case 2: /* dynamic */
- Trace((stderr, "inflate: dynamic codes block%s\n",
- s->last ? " (last)" : ""));
- DUMPBITS(3)
- s->mode = TABLE;
- break;
- case 3: /* illegal */
- DUMPBITS(3)
- s->mode = BADB;
- z->msg = "invalid block type";
- r = Z_DATA_ERROR;
- LEAVE
- }
- break;
- case LENS:
- NEEDBITS(32)
- if (((~b) >> 16) != (b & 0xffff))
- {
- s->mode = BADB;
- z->msg = "invalid stored block lengths";
- r = Z_DATA_ERROR;
- LEAVE
- }
- s->sub.left = (uInt)b & 0xffff;
- b = k = 0; /* dump bits */
- Tracev((stderr, "inflate: stored length %u\n", s->sub.left));
- s->mode = s->sub.left ? STORED : TYPE;
- break;
- case STORED:
- if (n == 0)
- LEAVE
- NEEDOUT
- t = s->sub.left;
- if (t > n) t = n;
- if (t > m) t = m;
- zmemcpy(q, p, t);
- p += t; n -= t;
- q += t; m -= t;
- if ((s->sub.left -= t) != 0)
- break;
- Tracev((stderr, "inflate: stored end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- s->mode = s->last ? DRY : TYPE;
- break;
- case TABLE:
- NEEDBITS(14)
- s->sub.trees.table = t = (uInt)b & 0x3fff;
-#ifndef PKZIP_BUG_WORKAROUND
- if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
- {
- s->mode = BADB;
- z->msg = "too many length or distance symbols";
- r = Z_DATA_ERROR;
- LEAVE
- }
-#endif
- t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
- if (t < 19)
- t = 19;
- if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL)
- {
- r = Z_MEM_ERROR;
- LEAVE
- }
- s->sub.trees.nblens = t;
- DUMPBITS(14)
- s->sub.trees.index = 0;
- Tracev((stderr, "inflate: table sizes ok\n"));
- s->mode = BTREE;
- case BTREE:
- while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
- {
- NEEDBITS(3)
- s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7;
- DUMPBITS(3)
- }
- while (s->sub.trees.index < 19)
- s->sub.trees.blens[border[s->sub.trees.index++]] = 0;
- s->sub.trees.bb = 7;
- t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb,
- &s->sub.trees.tb, z);
- if (t != Z_OK)
- {
- r = t;
- if (r == Z_DATA_ERROR)
- s->mode = BADB;
- LEAVE
- }
- s->sub.trees.index = 0;
- Tracev((stderr, "inflate: bits tree ok\n"));
- s->mode = DTREE;
- case DTREE:
- while (t = s->sub.trees.table,
- s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
- {
- inflate_huft *h;
- uInt i, j, c;
-
- t = s->sub.trees.bb;
- NEEDBITS(t)
- h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]);
- t = h->word.what.Bits;
- c = h->more.Base;
- if (c < 16)
- {
- DUMPBITS(t)
- s->sub.trees.blens[s->sub.trees.index++] = c;
- }
- else /* c == 16..18 */
- {
- i = c == 18 ? 7 : c - 14;
- j = c == 18 ? 11 : 3;
- NEEDBITS(t + i)
- DUMPBITS(t)
- j += (uInt)b & inflate_mask[i];
- DUMPBITS(i)
- i = s->sub.trees.index;
- t = s->sub.trees.table;
- if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
- (c == 16 && i < 1))
- {
- s->mode = BADB;
- z->msg = "invalid bit length repeat";
- r = Z_DATA_ERROR;
- LEAVE
- }
- c = c == 16 ? s->sub.trees.blens[i - 1] : 0;
- do {
- s->sub.trees.blens[i++] = c;
- } while (--j);
- s->sub.trees.index = i;
- }
- }
- inflate_trees_free(s->sub.trees.tb, z);
- s->sub.trees.tb = Z_NULL;
- {
- uInt bl, bd;
- inflate_huft *tl, *td;
- inflate_codes_statef *c;
-
- bl = 9; /* must be <= 9 for lookahead assumptions */
- bd = 6; /* must be <= 9 for lookahead assumptions */
- t = s->sub.trees.table;
- t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f),
- s->sub.trees.blens, &bl, &bd, &tl, &td, z);
- if (t != Z_OK)
- {
- if (t == (uInt)Z_DATA_ERROR)
- s->mode = BADB;
- r = t;
- LEAVE
- }
- Tracev((stderr, "inflate: trees ok\n"));
- if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL)
- {
- inflate_trees_free(td, z);
- inflate_trees_free(tl, z);
- r = Z_MEM_ERROR;
- LEAVE
- }
- ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
- s->sub.decode.codes = c;
- s->sub.decode.tl = tl;
- s->sub.decode.td = td;
- }
- s->mode = CODES;
- case CODES:
- UPDATE
- if ((r = inflate_codes(s, z, r)) != Z_STREAM_END)
- return inflate_flush(s, z, r);
- r = Z_OK;
- inflate_codes_free(s->sub.decode.codes, z);
- inflate_trees_free(s->sub.decode.td, z);
- inflate_trees_free(s->sub.decode.tl, z);
- LOAD
- Tracev((stderr, "inflate: codes end, %lu total out\n",
- z->total_out + (q >= s->read ? q - s->read :
- (s->end - s->read) + (q - s->window))));
- if (!s->last)
- {
- s->mode = TYPE;
- break;
- }
- if (k > 7) /* return unused byte, if any */
- {
- Assert(k < 16, "inflate_codes grabbed too many bytes")
- k -= 8;
- n++;
- p--; /* can always return one */
- }
- s->mode = DRY;
- case DRY:
- FLUSH
- if (s->read != s->write)
- LEAVE
- s->mode = DONEB;
- case DONEB:
- r = Z_STREAM_END;
- LEAVE
- case BADB:
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-}
-
-
-local int inflate_blocks_free(
- inflate_blocks_statef *s,
- z_stream *z,
- uLongf *c
-)
-{
- inflate_blocks_reset(s, z, c);
- ZFREE(z, s->window, s->end - s->window);
- ZFREE(z, s, sizeof(struct inflate_blocks_state));
- Trace((stderr, "inflate: blocks freed\n"));
- return Z_OK;
-}
-
-/*
- * This subroutine adds the data at next_in/avail_in to the output history
- * without performing any output. The output buffer must be "caught up";
- * i.e. no pending output (hence s->read equals s->write), and the state must
- * be BLOCKS (i.e. we should be willing to see the start of a series of
- * BLOCKS). On exit, the output will also be caught up, and the checksum
- * will have been updated if need be.
- */
-local int inflate_addhistory(
- inflate_blocks_statef *s,
- z_stream *z
-)
-{
- uLong b; /* bit buffer */ /* NOT USED HERE */
- uInt k; /* bits in bit buffer */ /* NOT USED HERE */
- uInt t; /* temporary storage */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
-
- if (s->read != s->write)
- return Z_STREAM_ERROR;
- if (s->mode != TYPE)
- return Z_DATA_ERROR;
-
- /* we're ready to rock */
- LOAD
- /* while there is input ready, copy to output buffer, moving
- * pointers as needed.
- */
- while (n) {
- t = n; /* how many to do */
- /* is there room until end of buffer? */
- if (t > m) t = m;
- /* update check information */
- if (s->checkfn != Z_NULL)
- s->check = (*s->checkfn)(s->check, q, t);
- zmemcpy(q, p, t);
- q += t;
- p += t;
- n -= t;
- z->total_out += t;
- s->read = q; /* drag read pointer forward */
-/* WRAP */ /* expand WRAP macro by hand to handle s->read */
- if (q == s->end) {
- s->read = q = s->window;
- m = WAVAIL;
- }
- }
- UPDATE
- return Z_OK;
-}
-
-
-/*
- * At the end of a Deflate-compressed PPP packet, we expect to have seen
- * a `stored' block type value but not the (zero) length bytes.
- */
-local int inflate_packet_flush(
- inflate_blocks_statef *s
-)
-{
- if (s->mode != LENS)
- return Z_DATA_ERROR;
- s->mode = TYPE;
- return Z_OK;
-}
-
-
-/*+++++*/
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-
-local int huft_build OF((
- uIntf *, /* code lengths in bits */
- uInt, /* number of codes */
- uInt, /* number of "simple" codes */
- uIntf *, /* list of base values for non-simple codes */
- uIntf *, /* list of extra bits for non-simple codes */
- inflate_huft * FAR*,/* result: starting table */
- uIntf *, /* maximum lookup bits (returns actual) */
- z_stream *)); /* for zalloc function */
-
-local voidpf falloc OF((
- voidpf, /* opaque pointer (not used) */
- uInt, /* number of items */
- uInt)); /* size of item */
-
-local void ffree OF((
- voidpf q, /* opaque pointer (not used) */
- voidpf p, /* what to free (not used) */
- uInt n)); /* number of bytes (not used) */
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- /* actually lengths - 2; also see note #13 above about 258 */
-local uInt cplext[] = { /* Extra bits for literal codes 257..285 */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */
-local uInt cpdist[] = { /* Copy offsets for distance codes 0..29 */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577};
-local uInt cpdext[] = { /* Extra bits for distance codes */
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
- 12, 12, 13, 13};
-
-/*
- Huffman code decoding is performed using a multi-level table lookup.
- The fastest way to decode is to simply build a lookup table whose
- size is determined by the longest code. However, the time it takes
- to build this table can also be a factor if the data being decoded
- is not very long. The most common codes are necessarily the
- shortest codes, so those codes dominate the decoding time, and hence
- the speed. The idea is you can have a shorter table that decodes the
- shorter, more probable codes, and then point to subsidiary tables for
- the longer codes. The time it costs to decode the longer codes is
- then traded against the time it takes to make longer tables.
-
- This results of this trade are in the variables lbits and dbits
- below. lbits is the number of bits the first level table for literal/
- length codes can decode in one step, and dbits is the same thing for
- the distance codes. Subsequent tables are also less than or equal to
- those sizes. These values may be adjusted either when all of the
- codes are shorter than that, in which case the longest code length in
- bits is used, or when the shortest code is *longer* than the requested
- table size, in which case the length of the shortest code in bits is
- used.
-
- There are two different values for the two tables, since they code a
- different number of possibilities each. The literal/length table
- codes 286 possible values, or in a flat code, a little over eight
- bits. The distance table codes 30 possible values, or a little less
- than five bits, flat. The optimum values for speed end up being
- about one bit more than those, so lbits is 8+1 and dbits is 5+1.
- The optimum values may differ though from machine to machine, and
- possibly even between compilers. Your mileage may vary.
- */
-
-
-/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
-#define BMAX 15 /* maximum bit length of any code */
-#define N_MAX 288 /* maximum number of codes in any set */
-
-#ifdef DEBUG_ZLIB
- uInt inflate_hufts;
-#endif
-
-local int huft_build(
- uIntf *b, /* code lengths in bits (all assumed <= BMAX) */
- uInt n, /* number of codes (assumed <= N_MAX) */
- uInt s, /* number of simple-valued codes (0..s-1) */
- uIntf *d, /* list of base values for non-simple codes */
- uIntf *e, /* list of extra bits for non-simple codes */
- inflate_huft * FAR *t, /* result: starting table */
- uIntf *m, /* maximum lookup bits, returns actual */
- z_stream *zs /* for zalloc function */
-)
-/* Given a list of code lengths and a maximum table size, make a set of
- tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
- if the given code set is incomplete (the tables are still built in this
- case), Z_DATA_ERROR if the input is invalid (all zero length codes or an
- over-subscribed set of lengths), or Z_MEM_ERROR if not enough memory. */
-{
-
- uInt a; /* counter for codes of length k */
- uInt c[BMAX+1]; /* bit length count table */
- uInt f; /* i repeats in table every f entries */
- int g; /* maximum code length */
- int h; /* table level */
- register uInt i; /* counter, current code */
- register uInt j; /* counter */
- register int k; /* number of bits in current code */
- int l; /* bits per table (returned in m) */
- register uIntf *p; /* pointer into c[], b[], or v[] */
- inflate_huft *q; /* points to current table */
- struct inflate_huft_s r; /* table entry for structure assignment */
- inflate_huft *u[BMAX]; /* table stack */
- uInt v[N_MAX]; /* values in order of bit length */
- register int w; /* bits before this table == (l * h) */
- uInt x[BMAX+1]; /* bit offsets, then code stack */
- uIntf *xp; /* pointer into x */
- int y; /* number of dummy codes added */
- uInt z; /* number of entries in current table */
-
-
- /* Generate counts for each bit length */
- p = c;
-#define C0 *p++ = 0;
-#define C2 C0 C0 C0 C0
-#define C4 C2 C2 C2 C2
- C4 /* clear c[]--assume BMAX+1 is 16 */
- p = b; i = n;
- do {
- c[*p++]++; /* assume all entries <= BMAX */
- } while (--i);
- if (c[0] == n) /* null input--all zero length codes */
- {
- *t = (inflate_huft *)Z_NULL;
- *m = 0;
- return Z_OK;
- }
-
-
- /* Find minimum and maximum length, bound *m by those */
- l = *m;
- for (j = 1; j <= BMAX; j++)
- if (c[j])
- break;
- k = j; /* minimum code length */
- if ((uInt)l < j)
- l = j;
- for (i = BMAX; i; i--)
- if (c[i])
- break;
- g = i; /* maximum code length */
- if ((uInt)l > i)
- l = i;
- *m = l;
-
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= c[j]) < 0)
- return Z_DATA_ERROR;
- if ((y -= c[i]) < 0)
- return Z_DATA_ERROR;
- c[i] += y;
-
-
- /* Generate starting offsets into the value table for each length */
- x[1] = j = 0;
- p = c + 1; xp = x + 2;
- while (--i) { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
-
- /* Make a table of values in order of bit lengths */
- p = b; i = 0;
- do {
- if ((j = *p++) != 0)
- v[x[j]++] = i;
- } while (++i < n);
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- x[0] = i = 0; /* first Huffman code is zero */
- p = v; /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = -l; /* bits decoded == (l * h) */
- u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
- q = (inflate_huft *)Z_NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = c[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l)
- {
- h++;
- w += l; /* previous table always l bits */
-
- /* compute minimum size table less than or equal to l bits */
- z = (z = g - w) > (uInt)l ? l : z; /* table size upper limit */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = c + k;
- if (j < z)
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- z = 1 << j; /* table entries for j-bit table */
-
- /* allocate and link in new table */
- if ((q = (inflate_huft *)ZALLOC
- (zs,z + 1,sizeof(inflate_huft))) == Z_NULL)
- {
- if (h)
- inflate_trees_free(u[0], zs);
- return Z_MEM_ERROR; /* not enough memory */
- }
- q->word.Nalloc = z + 1;
-#ifdef DEBUG_ZLIB
- inflate_hufts += z + 1;
-#endif
- *t = q + 1; /* link to list for huft_free() */
- *(t = &(q->next)) = Z_NULL;
- u[h] = ++q; /* table starts after link */
-
- /* connect to last table, if there is one */
- if (h)
- {
- x[h] = i; /* save pattern for backing up */
- r.bits = (Byte)l; /* bits to dump before this table */
- r.exop = (Byte)j; /* bits in this table */
- r.next = q; /* pointer to this table */
- j = i >> (w - l); /* (get around Turbo C bug) */
- u[h-1][j] = r; /* connect to last table */
- }
- }
-
- /* set up table entry in r */
- r.bits = (Byte)(k - w);
- if (p >= v + n)
- r.exop = 128 + 64; /* out of values--invalid code */
- else if (*p < s)
- {
- r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
- r.base = *p++; /* simple code is just the value */
- }
- else
- {
- r.exop = (Byte)e[*p - s] + 16 + 64; /* non-simple--look up in lists */
- r.base = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- while ((i & ((1 << w) - 1)) != x[h])
- {
- h--; /* don't need to update q */
- w -= l;
- }
- }
- }
-
-
- /* Return Z_BUF_ERROR if we were given an incomplete table */
- return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
-}
-
-
-local int inflate_trees_bits(
- uIntf *c, /* 19 code lengths */
- uIntf *bb, /* bits tree desired/actual depth */
- inflate_huft * FAR *tb, /* bits tree result */
- z_stream *z /* for zfree function */
-)
-{
- int r;
-
- r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
- if (r == Z_DATA_ERROR)
- z->msg = "oversubscribed dynamic bit lengths tree";
- else if (r == Z_BUF_ERROR)
- {
- inflate_trees_free(*tb, z);
- z->msg = "incomplete dynamic bit lengths tree";
- r = Z_DATA_ERROR;
- }
- return r;
-}
-
-
-local int inflate_trees_dynamic(
- uInt nl, /* number of literal/length codes */
- uInt nd, /* number of distance codes */
- uIntf *c, /* that many (total) code lengths */
- uIntf *bl, /* literal desired/actual bit depth */
- uIntf *bd, /* distance desired/actual bit depth */
- inflate_huft * FAR *tl, /* literal/length tree result */
- inflate_huft * FAR *td, /* distance tree result */
- z_stream *z /* for zfree function */
-)
-{
- int r;
-
- /* build literal/length tree */
- if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK)
- {
- if (r == Z_DATA_ERROR)
- z->msg = "oversubscribed literal/length tree";
- else if (r == Z_BUF_ERROR)
- {
- inflate_trees_free(*tl, z);
- z->msg = "incomplete literal/length tree";
- r = Z_DATA_ERROR;
- }
- return r;
- }
-
- /* build distance tree */
- if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK)
- {
- if (r == Z_DATA_ERROR)
- z->msg = "oversubscribed literal/length tree";
- else if (r == Z_BUF_ERROR) {
-#ifdef PKZIP_BUG_WORKAROUND
- r = Z_OK;
- }
-#else
- inflate_trees_free(*td, z);
- z->msg = "incomplete literal/length tree";
- r = Z_DATA_ERROR;
- }
- inflate_trees_free(*tl, z);
- return r;
-#endif
- }
-
- /* done */
- return Z_OK;
-}
-
-
-/* build fixed tables only once--keep them here */
-local int fixed_lock = 0;
-local int fixed_built = 0;
-#define FIXEDH 530 /* number of hufts used by fixed tables */
-local uInt fixed_left = FIXEDH;
-local inflate_huft fixed_mem[FIXEDH];
-local uInt fixed_bl;
-local uInt fixed_bd;
-local inflate_huft *fixed_tl;
-local inflate_huft *fixed_td;
-
-
-local voidpf falloc(q, n, s)
-voidpf q; /* opaque pointer (not used) */
-uInt n; /* number of items */
-uInt s; /* size of item */
-{
- Assert(s == sizeof(inflate_huft) && n <= fixed_left,
- "inflate_trees falloc overflow");
- if (q) s++; /* to make some compilers happy */
- fixed_left -= n;
- return (voidpf)(fixed_mem + fixed_left);
-}
-
-
-local void ffree(q, p, n)
-voidpf q;
-voidpf p;
-uInt n;
-{
- Assert(0, "inflate_trees ffree called!");
- if (q) q = p; /* to make some compilers happy */
-}
-
-
-local int inflate_trees_fixed(
- uIntf *bl, /* literal desired/actual bit depth */
- uIntf *bd, /* distance desired/actual bit depth */
- inflate_huft * FAR *tl, /* literal/length tree result */
- inflate_huft * FAR *td /* distance tree result */
-)
-{
- /* build fixed tables if not built already--lock out other instances */
- while (++fixed_lock > 1)
- fixed_lock--;
- if (!fixed_built)
- {
- int k; /* temporary variable */
- unsigned c[288]; /* length list for huft_build */
- z_stream z; /* for falloc function */
-
- /* set up fake z_stream for memory routines */
- z.zalloc = falloc;
- z.zfree = ffree;
- z.opaque = Z_NULL;
-
- /* literal table */
- for (k = 0; k < 144; k++)
- c[k] = 8;
- for (; k < 256; k++)
- c[k] = 9;
- for (; k < 280; k++)
- c[k] = 7;
- for (; k < 288; k++)
- c[k] = 8;
- fixed_bl = 7;
- huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z);
-
- /* distance table */
- for (k = 0; k < 30; k++)
- c[k] = 5;
- fixed_bd = 5;
- huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z);
-
- /* done */
- fixed_built = 1;
- }
- fixed_lock--;
- *bl = fixed_bl;
- *bd = fixed_bd;
- *tl = fixed_tl;
- *td = fixed_td;
- return Z_OK;
-}
-
-
-local int inflate_trees_free(
- inflate_huft *t, /* table to free */
- z_stream *z /* for zfree function */
-)
-/* Free the malloc'ed tables built by huft_build(), which makes a linked
- list of the tables it made, with the links in a dummy first entry of
- each table. */
-{
- register inflate_huft *p, *q;
-
- /* Go through linked list, freeing from the malloced (t[-1]) address. */
- p = t;
- while (p != Z_NULL)
- {
- q = (--p)->next;
- ZFREE(z, p, p->word.Nalloc * sizeof(inflate_huft));
- p = q;
- }
- return Z_OK;
-}
-
-/*+++++*/
-/* infcodes.c -- process literals and length/distance pairs
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* inflate codes private state */
-struct inflate_codes_state {
-
- /* mode */
- enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- START, /* x: set up for LEN */
- LEN, /* i: get length/literal/eob next */
- LENEXT, /* i: getting length extra (have base) */
- DIST, /* i: get distance next */
- DISTEXT, /* i: getting distance extra */
- COPY, /* o: copying bytes in window, waiting for space */
- LIT, /* o: got literal, waiting for output space */
- WASH, /* o: got eob, possibly still output waiting */
- END, /* x: got eob and all data flushed */
- BADCODE} /* x: got error */
- mode; /* current inflate_codes mode */
-
- /* mode dependent information */
- uInt len;
- union {
- struct {
- inflate_huft *tree; /* pointer into tree */
- uInt need; /* bits needed */
- } code; /* if LEN or DIST, where in tree */
- uInt lit; /* if LIT, literal */
- struct {
- uInt get; /* bits to get for extra */
- uInt dist; /* distance back to copy from */
- } copy; /* if EXT or COPY, where and how much */
- } sub; /* submode */
-
- /* mode independent information */
- Byte lbits; /* ltree bits decoded per branch */
- Byte dbits; /* dtree bits decoder per branch */
- inflate_huft *ltree; /* literal/length/eob tree */
- inflate_huft *dtree; /* distance tree */
-
-};
-
-
-local inflate_codes_statef *inflate_codes_new(
- uInt bl,
- uInt bd,
- inflate_huft *tl,
- inflate_huft *td,
- z_stream *z
-)
-{
- inflate_codes_statef *c;
-
- if ((c = (inflate_codes_statef *)
- ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL)
- {
- c->mode = START;
- c->lbits = (Byte)bl;
- c->dbits = (Byte)bd;
- c->ltree = tl;
- c->dtree = td;
- Tracev((stderr, "inflate: codes new\n"));
- }
- return c;
-}
-
-
-local int inflate_codes(
- inflate_blocks_statef *s,
- z_stream *z,
- int r
-)
-{
- uInt j; /* temporary storage */
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- Bytef *f; /* pointer to copy strings from */
- inflate_codes_statef *c = s->sub.decode.codes; /* codes state */
-
- /* copy input/output information to locals (UPDATE macro restores) */
- LOAD
-
- /* process input and output based on current state */
- while (1) switch (c->mode)
- { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
- case START: /* x: set up for LEN */
-#ifndef SLOW
- if (m >= 258 && n >= 10)
- {
- UPDATE
- r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z);
- LOAD
- if (r != Z_OK)
- {
- c->mode = r == Z_STREAM_END ? WASH : BADCODE;
- break;
- }
- }
-#endif /* !SLOW */
- c->sub.code.need = c->lbits;
- c->sub.code.tree = c->ltree;
- c->mode = LEN;
- case LEN: /* i: get length/literal/eob next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e == 0) /* literal */
- {
- c->sub.lit = t->base;
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", t->base));
- c->mode = LIT;
- break;
- }
- if (e & 16) /* length */
- {
- c->sub.copy.get = e & 15;
- c->len = t->base;
- c->mode = LENEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t->next;
- break;
- }
- if (e & 32) /* end of block */
- {
- Tracevv((stderr, "inflate: end of block\n"));
- c->mode = WASH;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = "invalid literal/length code";
- r = Z_DATA_ERROR;
- LEAVE
- case LENEXT: /* i: getting length extra (have base) */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->len += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- c->sub.code.need = c->dbits;
- c->sub.code.tree = c->dtree;
- Tracevv((stderr, "inflate: length %u\n", c->len));
- c->mode = DIST;
- case DIST: /* i: get distance next */
- j = c->sub.code.need;
- NEEDBITS(j)
- t = c->sub.code.tree + ((uInt)b & inflate_mask[j]);
- DUMPBITS(t->bits)
- e = (uInt)(t->exop);
- if (e & 16) /* distance */
- {
- c->sub.copy.get = e & 15;
- c->sub.copy.dist = t->base;
- c->mode = DISTEXT;
- break;
- }
- if ((e & 64) == 0) /* next table */
- {
- c->sub.code.need = e;
- c->sub.code.tree = t->next;
- break;
- }
- c->mode = BADCODE; /* invalid code */
- z->msg = "invalid distance code";
- r = Z_DATA_ERROR;
- LEAVE
- case DISTEXT: /* i: getting distance extra */
- j = c->sub.copy.get;
- NEEDBITS(j)
- c->sub.copy.dist += (uInt)b & inflate_mask[j];
- DUMPBITS(j)
- Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist));
- c->mode = COPY;
- case COPY: /* o: copying bytes in window, waiting for space */
-#ifndef __TURBOC__ /* Turbo C bug for following expression */
- f = (uInt)(q - s->window) < c->sub.copy.dist ?
- s->end - (c->sub.copy.dist - (q - s->window)) :
- q - c->sub.copy.dist;
-#else
- f = q - c->sub.copy.dist;
- if ((uInt)(q - s->window) < c->sub.copy.dist)
- f = s->end - (c->sub.copy.dist - (q - s->window));
-#endif
- while (c->len)
- {
- NEEDOUT
- OUTBYTE(*f++)
- if (f == s->end)
- f = s->window;
- c->len--;
- }
- c->mode = START;
- break;
- case LIT: /* o: got literal, waiting for output space */
- NEEDOUT
- OUTBYTE(c->sub.lit)
- c->mode = START;
- break;
- case WASH: /* o: got eob, possibly more output */
- FLUSH
- if (s->read != s->write)
- LEAVE
- c->mode = END;
- case END:
- r = Z_STREAM_END;
- LEAVE
- case BADCODE: /* x: got error */
- r = Z_DATA_ERROR;
- LEAVE
- default:
- r = Z_STREAM_ERROR;
- LEAVE
- }
-}
-
-
-local void inflate_codes_free(
- inflate_codes_statef *c,
- z_stream *z
-)
-{
- ZFREE(z, c, sizeof(struct inflate_codes_state));
- Tracev((stderr, "inflate: codes free\n"));
-}
-
-/*+++++*/
-/* inflate_util.c -- data and routines common to blocks and codes
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* copy as much as possible from the sliding window to the output area */
-local int inflate_flush(
- inflate_blocks_statef *s,
- z_stream *z,
- int r
-)
-{
- uInt n;
- Bytef *p, *q;
-
- /* local copies of source and destination pointers */
- p = z->next_out;
- q = s->read;
-
- /* compute number of bytes to copy as far as end of window */
- n = (uInt)((q <= s->write ? s->write : s->end) - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy as far as end of window */
- zmemcpy(p, q, n);
- p += n;
- q += n;
-
- /* see if more to copy at beginning of window */
- if (q == s->end)
- {
- /* wrap pointers */
- q = s->window;
- if (s->write == s->end)
- s->write = s->window;
-
- /* compute bytes to copy */
- n = (uInt)(s->write - q);
- if (n > z->avail_out) n = z->avail_out;
- if (n && r == Z_BUF_ERROR) r = Z_OK;
-
- /* update counters */
- z->avail_out -= n;
- z->total_out += n;
-
- /* update check information */
- if (s->checkfn != Z_NULL)
- s->check = (*s->checkfn)(s->check, q, n);
-
- /* copy */
- zmemcpy(p, q, n);
- p += n;
- q += n;
- }
-
- /* update pointers */
- z->next_out = p;
- s->read = q;
-
- /* done */
- return r;
-}
-
-
-/*+++++*/
-/* inffast.c -- process literals and length/distance pairs fast
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* simplify the use of the inflate_huft type with some defines */
-#define base more.Base
-#define next more.Next
-#define exop word.what.Exop
-#define bits word.what.Bits
-
-/* macros for bit input with no checking and for returning unused bytes */
-#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
-#define UNGRAB {n+=(c=k>>3);p-=c;k&=7;}
-
-/* Called with number of bytes left to write in window at least 258
- (the maximum string length) and number of input bytes available
- at least ten. The ten bytes are six bytes for the longest length/
- distance pair plus four bytes for overloading the bit buffer. */
-
-local int inflate_fast(
- uInt bl,
- uInt bd,
- inflate_huft *tl,
- inflate_huft *td,
- inflate_blocks_statef *s,
- z_stream *z
-)
-{
- inflate_huft *t; /* temporary pointer */
- uInt e; /* extra bits or operation */
- uLong b; /* bit buffer */
- uInt k; /* bits in bit buffer */
- Bytef *p; /* input data pointer */
- uInt n; /* bytes available there */
- Bytef *q; /* output window write pointer */
- uInt m; /* bytes to end of window or read pointer */
- uInt ml; /* mask for literal/length tree */
- uInt md; /* mask for distance tree */
- uInt c; /* bytes to copy */
- uInt d; /* distance back to copy from */
- Bytef *r; /* copy source pointer */
-
- /* load input, output, bit values */
- LOAD
-
- /* initialize masks */
- ml = inflate_mask[bl];
- md = inflate_mask[bd];
-
- /* do until not enough input or output space for fast loop */
- do { /* assume called with m >= 258 && n >= 10 */
- /* get literal/length code */
- GRABBITS(20) /* max bits for literal/length code */
- if ((e = (t = tl + ((uInt)b & ml))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- continue;
- }
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits for length */
- e &= 15;
- c = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * length %u\n", c));
-
- /* decode distance base of block to copy */
- GRABBITS(15); /* max bits for distance code */
- e = (t = td + ((uInt)b & md))->exop;
- do {
- DUMPBITS(t->bits)
- if (e & 16)
- {
- /* get extra bits to add to distance base */
- e &= 15;
- GRABBITS(e) /* get extra bits (up to 13) */
- d = t->base + ((uInt)b & inflate_mask[e]);
- DUMPBITS(e)
- Tracevv((stderr, "inflate: * distance %u\n", d));
-
- /* do the copy */
- m -= c;
- if ((uInt)(q - s->window) >= d) /* offset before dest */
- { /* just copy */
- r = q - d;
- *q++ = *r++; c--; /* minimum count is three, */
- *q++ = *r++; c--; /* so unroll loop a little */
- }
- else /* else offset after destination */
- {
- e = d - (q - s->window); /* bytes from offset to end */
- r = s->end - e; /* pointer to offset */
- if (c > e) /* if source crosses, */
- {
- c -= e; /* copy to end of window */
- do {
- *q++ = *r++;
- } while (--e);
- r = s->window; /* copy rest from start of window */
- }
- }
- do { /* copy all or what's left */
- *q++ = *r++;
- } while (--c);
- break;
- }
- else if ((e & 64) == 0)
- e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop;
- else
- {
- z->msg = "invalid distance code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- break;
- }
- if ((e & 64) == 0)
- {
- if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0)
- {
- DUMPBITS(t->bits)
- Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ?
- "inflate: * literal '%c'\n" :
- "inflate: * literal 0x%02x\n", t->base));
- *q++ = (Byte)t->base;
- m--;
- break;
- }
- }
- else if (e & 32)
- {
- Tracevv((stderr, "inflate: * end of block\n"));
- UNGRAB
- UPDATE
- return Z_STREAM_END;
- }
- else
- {
- z->msg = "invalid literal/length code";
- UNGRAB
- UPDATE
- return Z_DATA_ERROR;
- }
- } while (1);
- } while (m >= 258 && n >= 10);
-
- /* not enough input or output--restore pointers and return */
- UNGRAB
- UPDATE
- return Z_OK;
-}
-
-
-/*+++++*/
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp */
-
-char *zlib_version = ZLIB_VERSION;
-
-char *z_errmsg[] = {
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-""};
-
-
-/*+++++*/
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* From: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp */
-
-#define BASE 65521L /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf) {s1 += *buf++; s2 += s1;}
-#define DO2(buf) DO1(buf); DO1(buf);
-#define DO4(buf) DO2(buf); DO2(buf);
-#define DO8(buf) DO4(buf); DO4(buf);
-#define DO16(buf) DO8(buf); DO8(buf);
-
-/* ========================================================================= */
-uLong adler32(adler, buf, len)
- uLong adler;
- Bytef *buf;
- uInt len;
-{
- unsigned long s1 = adler & 0xffff;
- unsigned long s2 = (adler >> 16) & 0xffff;
- int k;
-
- if (buf == Z_NULL) return 1L;
-
- while (len > 0) {
- k = len < NMAX ? len : NMAX;
- len -= k;
- while (k >= 16) {
- DO16(buf);
- k -= 16;
- }
- if (k != 0) do {
- DO1(buf);
- } while (--k);
- s1 %= BASE;
- s2 %= BASE;
- }
- return (s2 << 16) | s1;
-}
+++ /dev/null
-/*
- * arch/ppc/boot/simple/chrpmap.S
- *
- * Author: Tom Rini <trini@mvista.com>
- *
- * This will go and setup ISA_io to 0xFE00000 and return.
- */
-
-#include <asm/ppc_asm.h>
-
- .text
-
- .globl serial_fixups
-serial_fixups:
- lis r3,ISA_io@h /* Load ISA_io */
- ori r3,r3,ISA_io@l
- lis r4,0xFE00 /* Load the value, 0xFE00000 */
- stw r4,0(r3) /* store */
- blr
+++ /dev/null
-/*
- * arch/ppc/boot/simple/legacy.S
- *
- * Author: Tom Rini <trini@mvista.com>
- *
- * This will go and setup ISA_io to 0x8000000 and return.
- */
-
-#include <asm/ppc_asm.h>
-
- .text
-
- .globl serial_fixups
-serial_fixups:
- lis r3,ISA_io@h /* Load ISA_io */
- ori r3,r3,ISA_io@l
- lis r4,0x8000 /* Load the value, 0x8000000 */
- stw r4,0(r3) /* store */
- blr
+++ /dev/null
-/*
- * arch/ppc/boot/simple/misc-mv64x60.S
- *
- * Code to change the base address of the host bridges and call board specific
- * init routine.
- *
- * Author: Mark Greer <mgreer@mvista.com>
- *
- * 2002 (c) MontaVista, Software, Inc. This file is licensed under the terms
- * of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <asm/ppc_asm.h>
-#include <asm/processor.h>
-#include <asm/cache.h>
-#include <asm/mv64x60_defs.h>
-
- .globl mv64x60_init
-mv64x60_init:
- mflr r27
-
-#if (CONFIG_MV64X60_NEW_BASE != CONFIG_MV64X60_BASE)
- bl move_base
-#endif
- bl mv64x60_board_init
-
- mtlr r27
- blr
-
-#if (CONFIG_MV64X60_NEW_BASE != CONFIG_MV64X60_BASE)
-move_base:
- li r20,0
- li r23,20
-
- /* Relocate bridge's regs */
- addis r25,0,CONFIG_MV64X60_BASE@h
- ori r25,r25,MV64x60_INTERNAL_SPACE_DECODE
- lwbrx r26,0,(r25)
- lis r24,0xffff
- and r26,r26,r24
- addis r24,0,CONFIG_MV64X60_NEW_BASE@h
- srw r24,r24,r23
- or r26,r26,r24
- stwbrx r26,0,(r25)
- sync
-
- /* Wait for write to take effect */
- addis r25,0,CONFIG_MV64X60_NEW_BASE@h
- ori r25,r25,MV64x60_INTERNAL_SPACE_DECODE
-1: lwbrx r24,0,(r25)
- cmpw r24,r26
- bne 1b
-
- blr
-#endif
+++ /dev/null
-/*
- * arch/ppc/boot/simple/mv64x60_stub.c
- *
- * Stub for board_init() routine called from mv64x60_init().
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2002 (c) MontaVista, Software, Inc. This file is licensed under the terms
- * of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-long mv64x60_console_baud = 9600; /* Default baud: 9600 */
-long mv64x60_mpsc_clk_src = 8; /* Default clk src: TCLK */
-long mv64x60_mpsc_clk_freq = 100000000; /* Default clk freq: 100 MHz */
-
-void
-mv64x60_board_init(void)
-{
-}
+++ /dev/null
-/*
- * arch/ppc/boot/simple/mv64x60_tty.c
- *
- * Bootloader version of the embedded MPSC/UART driver for the Marvell 64x60.
- * Note: Due to a GT64260A erratum, DMA will be used for UART input (via SDMA).
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * Copyright 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-/* This code assumes that the data cache has been disabled (L1, L2, L3). */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/serial_reg.h>
-#include <asm/serial.h>
-#include <asm/mv64x60_defs.h>
-#include "../../../../drivers/serial/mpsc/mpsc_defs.h"
-
-extern void udelay(long);
-static void stop_dma(int chan);
-
-static u32 mv64x60_base = CONFIG_MV64X60_NEW_BASE;
-
-inline unsigned
-mv64x60_in_le32(volatile unsigned *addr)
-{
- unsigned ret;
-
- __asm__ __volatile__("lwbrx %0,0,%1; eieio" : "=r" (ret) :
- "r" (addr), "m" (*addr));
- return ret;
-}
-
-inline void
-mv64x60_out_le32(volatile unsigned *addr, int val)
-{
- __asm__ __volatile__("stwbrx %1,0,%2; eieio" : "=m" (*addr) :
- "r" (val), "r" (addr));
-}
-
-#define MV64x60_REG_READ(offs) \
- (mv64x60_in_le32((volatile uint *)(mv64x60_base + (offs))))
-#define MV64x60_REG_WRITE(offs, d) \
- (mv64x60_out_le32((volatile uint *)(mv64x60_base + (offs)), (int)(d)))
-
-
-typedef struct {
- u32 sdc;
- u32 sdcm;
- u32 rx_desc;
- u32 rx_buf_ptr;
- u32 scrdp;
- u32 tx_desc;
- u32 sctdp;
- u32 sftdp;
-} sdma_regs_t;
-
-static sdma_regs_t sdma_regs[2];
-
-#define SDMA_REGS_INIT(s, reg_base) { \
- (s)->sdc = (reg_base) + SDMA_SDC; \
- (s)->sdcm = (reg_base) + SDMA_SDCM; \
- (s)->rx_desc = (reg_base) + SDMA_RX_DESC; \
- (s)->rx_buf_ptr = (reg_base) + SDMA_RX_BUF_PTR; \
- (s)->scrdp = (reg_base) + SDMA_SCRDP; \
- (s)->tx_desc = (reg_base) + SDMA_TX_DESC; \
- (s)->sctdp = (reg_base) + SDMA_SCTDP; \
- (s)->sftdp = (reg_base) + SDMA_SFTDP; \
-}
-
-typedef struct {
- volatile u16 bufsize;
- volatile u16 bytecnt;
- volatile u32 cmd_stat;
- volatile u32 next_desc_ptr;
- volatile u32 buffer;
-} mv64x60_rx_desc_t;
-
-typedef struct {
- volatile u16 bytecnt;
- volatile u16 shadow;
- volatile u32 cmd_stat;
- volatile u32 next_desc_ptr;
- volatile u32 buffer;
-} mv64x60_tx_desc_t;
-
-#define MAX_RESET_WAIT 10000
-#define MAX_TX_WAIT 10000
-
-#define RX_NUM_DESC 2
-#define TX_NUM_DESC 2
-
-#define RX_BUF_SIZE 16
-#define TX_BUF_SIZE 16
-
-static mv64x60_rx_desc_t rd[2][RX_NUM_DESC] __attribute__ ((aligned(32)));
-static mv64x60_tx_desc_t td[2][TX_NUM_DESC] __attribute__ ((aligned(32)));
-
-static char rx_buf[2][RX_NUM_DESC * RX_BUF_SIZE] __attribute__ ((aligned(32)));
-static char tx_buf[2][TX_NUM_DESC * TX_BUF_SIZE] __attribute__ ((aligned(32)));
-
-static int cur_rd[2] = { 0, 0 };
-static int cur_td[2] = { 0, 0 };
-
-static char chan_initialized[2] = { 0, 0 };
-
-
-#define RX_INIT_RDP(rdp) { \
- (rdp)->bufsize = 2; \
- (rdp)->bytecnt = 0; \
- (rdp)->cmd_stat = SDMA_DESC_CMDSTAT_L | \
- SDMA_DESC_CMDSTAT_F | \
- SDMA_DESC_CMDSTAT_O; \
-}
-
-unsigned long
-serial_init(int chan, void *ignored)
-{
- u32 mpsc_base, mpsc_routing_base, sdma_base, brg_bcr, cdv;
- int i;
- extern long mv64x60_console_baud;
- extern long mv64x60_mpsc_clk_src;
- extern long mv64x60_mpsc_clk_freq;
-
- chan = (chan == 1); /* default to chan 0 if anything but 1 */
-
- if (chan_initialized[chan]) return chan;
-
- chan_initialized[chan] = 1;
-
- if (chan == 0) {
- mpsc_base = MV64x60_MPSC_0_OFFSET;
- sdma_base = MV64x60_SDMA_0_OFFSET;
- brg_bcr = MV64x60_BRG_0_OFFSET + BRG_BCR;
- SDMA_REGS_INIT(&sdma_regs[0], MV64x60_SDMA_0_OFFSET);
- }
- else {
- mpsc_base = MV64x60_MPSC_1_OFFSET;
- sdma_base = MV64x60_SDMA_1_OFFSET;
- brg_bcr = MV64x60_BRG_1_OFFSET + BRG_BCR;
- SDMA_REGS_INIT(&sdma_regs[0], MV64x60_SDMA_1_OFFSET);
- }
-
- mpsc_routing_base = MV64x60_MPSC_ROUTING_OFFSET;
-
- stop_dma(chan);
-
- /* Set up ring buffers */
- for (i=0; i<RX_NUM_DESC; i++) {
- RX_INIT_RDP(&rd[chan][i]);
- rd[chan][i].buffer = (u32)&rx_buf[chan][i * RX_BUF_SIZE];
- rd[chan][i].next_desc_ptr = (u32)&rd[chan][i+1];
- }
- rd[chan][RX_NUM_DESC - 1].next_desc_ptr = (u32)&rd[chan][0];
-
- for (i=0; i<TX_NUM_DESC; i++) {
- td[chan][i].bytecnt = 0;
- td[chan][i].shadow = 0;
- td[chan][i].buffer = (u32)&tx_buf[chan][i * TX_BUF_SIZE];
- td[chan][i].cmd_stat = SDMA_DESC_CMDSTAT_F|SDMA_DESC_CMDSTAT_L;
- td[chan][i].next_desc_ptr = (u32)&td[chan][i+1];
- }
- td[chan][TX_NUM_DESC - 1].next_desc_ptr = (u32)&td[chan][0];
-
- /* Set MPSC Routing */
- MV64x60_REG_WRITE(mpsc_routing_base + MPSC_MRR, 0x3ffffe38);
-
-/* XXXX Not for 64360 XXXX*/
- MV64x60_REG_WRITE(GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102);
-
- /* MPSC 0/1 Rx & Tx get clocks BRG0/1 */
- MV64x60_REG_WRITE(mpsc_routing_base + MPSC_RCRR, 0x00000100);
- MV64x60_REG_WRITE(mpsc_routing_base + MPSC_TCRR, 0x00000100);
-
- /* clear pending interrupts */
- MV64x60_REG_WRITE(MV64x60_SDMA_INTR_OFFSET + SDMA_INTR_MASK, 0);
-
- MV64x60_REG_WRITE(SDMA_SCRDP + sdma_base, &rd[chan][0]);
- MV64x60_REG_WRITE(SDMA_SCTDP + sdma_base, &td[chan][TX_NUM_DESC - 1]);
- MV64x60_REG_WRITE(SDMA_SFTDP + sdma_base, &td[chan][TX_NUM_DESC - 1]);
-
- MV64x60_REG_WRITE(SDMA_SDC + sdma_base,
- SDMA_SDC_RFT | SDMA_SDC_SFM | SDMA_SDC_BLMR | SDMA_SDC_BLMT |
- (3 << 12));
-
- cdv = ((mv64x60_mpsc_clk_freq/(32*mv64x60_console_baud))-1);
- MV64x60_REG_WRITE(brg_bcr,
- ((mv64x60_mpsc_clk_src << 18) | (1 << 16) | cdv));
-
- /* Put MPSC into UART mode, no null modem, 16x clock mode */
- MV64x60_REG_WRITE(MPSC_MMCRL + mpsc_base, 0x000004c4);
- MV64x60_REG_WRITE(MPSC_MMCRH + mpsc_base, 0x04400400);
-
- MV64x60_REG_WRITE(MPSC_CHR_1 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_9 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_10 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_3 + mpsc_base, 4);
- MV64x60_REG_WRITE(MPSC_CHR_4 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_5 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_6 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_7 + mpsc_base, 0);
- MV64x60_REG_WRITE(MPSC_CHR_8 + mpsc_base, 0);
-
- /* 8 data bits, 1 stop bit */
- MV64x60_REG_WRITE(MPSC_MPCR + mpsc_base, (3 << 12));
- MV64x60_REG_WRITE(SDMA_SDCM + sdma_base, SDMA_SDCM_ERD);
- MV64x60_REG_WRITE(MPSC_CHR_2 + mpsc_base, MPSC_CHR_2_EH);
-
- udelay(100);
-
- return chan;
-}
-
-static void
-stop_dma(int chan)
-{
- int i;
-
- /* Abort SDMA Rx, Tx */
- MV64x60_REG_WRITE(sdma_regs[chan].sdcm, SDMA_SDCM_AR | SDMA_SDCM_STD);
-
- for (i=0; i<MAX_RESET_WAIT; i++) {
- if ((MV64x60_REG_READ(sdma_regs[chan].sdcm) &
- (SDMA_SDCM_AR | SDMA_SDCM_AT)) == 0) {
- break;
- }
- udelay(100);
- }
-
- return;
-}
-
-static int
-wait_for_ownership(int chan)
-{
- int i;
-
- for (i=0; i<MAX_TX_WAIT; i++) {
- if ((MV64x60_REG_READ(sdma_regs[chan].sdcm) &
- SDMA_SDCM_TXD) == 0)
- break;
- udelay(1000);
- }
-
- return (i < MAX_TX_WAIT);
-}
-
-void
-serial_putc(unsigned long com_port, unsigned char c)
-{
- mv64x60_tx_desc_t *tdp;
-
- if (wait_for_ownership(com_port) == 0) return;
-
- tdp = &td[com_port][cur_td[com_port]];
- if (++cur_td[com_port] >= TX_NUM_DESC) cur_td[com_port] = 0;
-
- *(unchar *)(tdp->buffer ^ 7) = c;
- tdp->bytecnt = 1;
- tdp->shadow = 1;
- tdp->cmd_stat = SDMA_DESC_CMDSTAT_L | SDMA_DESC_CMDSTAT_F |
- SDMA_DESC_CMDSTAT_O;
-
- MV64x60_REG_WRITE(sdma_regs[com_port].sctdp, tdp);
- MV64x60_REG_WRITE(sdma_regs[com_port].sftdp, tdp);
- MV64x60_REG_WRITE(sdma_regs[com_port].sdcm,
- MV64x60_REG_READ(sdma_regs[com_port].sdcm) | SDMA_SDCM_TXD);
-
- return;
-}
-
-unsigned char
-serial_getc(unsigned long com_port)
-{
- mv64x60_rx_desc_t *rdp;
- unchar c = '\0';
-
- rdp = &rd[com_port][cur_rd[com_port]];
-
- if ((rdp->cmd_stat & (SDMA_DESC_CMDSTAT_O|SDMA_DESC_CMDSTAT_ES)) == 0) {
- c = *(unchar *)(rdp->buffer ^ 7);
- RX_INIT_RDP(rdp);
- if (++cur_rd[com_port] >= RX_NUM_DESC) cur_rd[com_port] = 0;
- }
-
- return c;
-}
-
-int
-serial_tstc(unsigned long com_port)
-{
- mv64x60_rx_desc_t *rdp;
- int loop_count = 0;
- int rc = 0;
-
- rdp = &rd[com_port][cur_rd[com_port]];
-
- /* Go thru rcv desc's until empty looking for one with data (no error)*/
- while (((rdp->cmd_stat & SDMA_DESC_CMDSTAT_O) == 0) &&
- (loop_count++ < RX_NUM_DESC)) {
-
- /* If there was an error, reinit the desc & continue */
- if ((rdp->cmd_stat & SDMA_DESC_CMDSTAT_ES) != 0) {
- RX_INIT_RDP(rdp);
- if (++cur_rd[com_port] >= RX_NUM_DESC) {
- cur_rd[com_port] = 0;
- }
- rdp = (mv64x60_rx_desc_t *)rdp->next_desc_ptr;
- }
- else {
- rc = 1;
- break;
- }
- }
-
- return rc;
-}
-
-void
-serial_close(unsigned long com_port)
-{
- stop_dma(com_port);
- return;
-}
+++ /dev/null
-/*
- * Copyright (C) 2000 Ani Joshi <ajoshi@unixbox.com>
- *
- *
- * Dynamic DMA mapping support.
- *
- * swiped from i386
- *
- */
-
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-
-void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
- dma_addr_t *dma_handle)
-{
- void *ret;
- int gfp = GFP_ATOMIC;
-
- if (hwdev == NULL || hwdev->dma_mask != 0xffffffff)
- gfp |= GFP_DMA;
-
-#ifdef CONFIG_NOT_COHERENT_CACHE
- ret = consistent_alloc(gfp, size, dma_handle);
-#else
- ret = (void *)__get_free_pages(gfp, get_order(size));
-#endif
-
- if (ret != NULL) {
- memset(ret, 0, size);
-#ifndef CONFIG_NOT_COHERENT_CACHE
- *dma_handle = virt_to_bus(ret);
-#endif
- }
- return ret;
-}
-
-void pci_free_consistent(struct pci_dev *hwdev, size_t size,
- void *vaddr, dma_addr_t dma_handle)
-{
-#ifdef CONFIG_NOT_COHERENT_CACHE
- consistent_free(vaddr);
-#else
- free_pages((unsigned long)vaddr, get_order(size));
-#endif
-}
+++ /dev/null
-/*
- * PowerPC version derived from arch/arm/mm/consistent.c
- * Copyright (C) 2001 Dan Malek (dmalek@jlc.net)
- *
- * arch/ppc/mm/cachemap.c
- *
- * Copyright (C) 2000 Russell King
- *
- * Consistent memory allocators. Used for DMA devices that want to
- * share uncached memory with the processor core. The function return
- * is the virtual address and 'dma_handle' is the physical address.
- * Mostly stolen from the ARM port, with some changes for PowerPC.
- * -- Dan
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/stddef.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/bootmem.h>
-#include <linux/highmem.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/pgalloc.h>
-#include <asm/prom.h>
-#include <asm/io.h>
-#include <asm/hardirq.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/machdep.h>
-
-int map_page(unsigned long va, phys_addr_t pa, int flags);
-
-/* This function will allocate the requested contiguous pages and
- * map them into the kernel's vmalloc() space. This is done so we
- * get unique mapping for these pages, outside of the kernel's 1:1
- * virtual:physical mapping. This is necessary so we can cover large
- * portions of the kernel with single large page TLB entries, and
- * still get unique uncached pages for consistent DMA.
- */
-void *consistent_alloc(int gfp, size_t size, dma_addr_t *dma_handle)
-{
- int order, err;
- struct page *page, *free, *end;
- phys_addr_t pa;
- unsigned long flags, offset;
- struct vm_struct *area = NULL;
- unsigned long va = 0;
-
- BUG_ON(in_interrupt());
-
- /* Only allocate page size areas */
- size = PAGE_ALIGN(size);
- order = get_order(size);
-
- free = page = alloc_pages(gfp, order);
- if (! page)
- return NULL;
-
- pa = page_to_phys(page);
- *dma_handle = page_to_bus(page);
- end = page + (1 << order);
-
- /*
- * we need to ensure that there are no cachelines in use,
- * or worse dirty in this area.
- */
- invalidate_dcache_range((unsigned long)page_address(page),
- (unsigned long)page_address(page) + size);
-
- /*
- * alloc_pages() expects the block to be handled as a unit, so
- * it only sets the page count on the first page. We set the
- * counts on each page so they can be freed individually
- */
- for (; page < end; page++)
- set_page_count(page, 1);
-
-
- /* Allocate some common virtual space to map the new pages*/
- area = get_vm_area(size, VM_ALLOC);
- if (! area)
- goto out;
-
- va = (unsigned long) area->addr;
-
- flags = _PAGE_KERNEL | _PAGE_NO_CACHE;
-
- for (offset = 0; offset < size; offset += PAGE_SIZE) {
- err = map_page(va+offset, pa+offset, flags);
- if (err) {
- vfree((void *)va);
- va = 0;
- goto out;
- }
-
- free++;
- }
-
- out:
- /* Free pages which weren't mapped */
- for (; free < end; free++) {
- __free_page(free);
- }
-
- return (void *)va;
-}
-
-/*
- * free page(s) as defined by the above mapping.
- */
-void consistent_free(void *vaddr)
-{
- BUG_ON(in_interrupt());
- vfree(vaddr);
-}
-
-/*
- * make an area consistent.
- */
-void consistent_sync(void *vaddr, size_t size, int direction)
-{
- unsigned long start = (unsigned long)vaddr;
- unsigned long end = start + size;
-
- switch (direction) {
- case DMA_NONE:
- BUG();
- case DMA_FROM_DEVICE: /* invalidate only */
- invalidate_dcache_range(start, end);
- break;
- case DMA_TO_DEVICE: /* writeback only */
- clean_dcache_range(start, end);
- break;
- case DMA_BIDIRECTIONAL: /* writeback and invalidate */
- flush_dcache_range(start, end);
- break;
- }
-}
-
-/*
- * consistent_sync_page make a page are consistent. identical
- * to consistent_sync, but takes a struct page instead of a virtual address
- */
-
-void consistent_sync_page(struct page *page, unsigned long offset,
- size_t size, int direction)
-{
- unsigned long start;
-
- start = (unsigned long)page_address(page) + offset;
- consistent_sync((void *)start, size, direction);
-}
-
-EXPORT_SYMBOL(consistent_sync_page);
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-obj-y := ocp.o ocp-driver.o ocp-probe.o
-
+++ /dev/null
-/*
- * FILE NAME: ocp-driver.c
- *
- * BRIEF MODULE DESCRIPTION:
- * driver callback, id matching and registration
- * Based on drivers/pci/pci-driver, Copyright (c) 1997--1999 Martin Mares
- *
- * Maintained by: Armin <akuster@mvista.com>
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <asm/ocp.h>
-#include <linux/module.h>
-#include <linux/init.h>
-
-/*
- * Registration of OCP drivers and handling of hot-pluggable devices.
- */
-
-static int
-ocp_device_probe(struct device *dev)
-{
- int error = 0;
- struct ocp_driver *drv;
- struct ocp_device *ocp_dev;
-
- drv = to_ocp_driver(dev->driver);
- ocp_dev = to_ocp_dev(dev);
-
- if (drv->probe) {
- error = drv->probe(ocp_dev);
- DBG("probe return code %d\n", error);
- if (error >= 0) {
- ocp_dev->driver = drv;
- error = 0;
- }
- }
- return error;
-}
-
-static int
-ocp_device_remove(struct device *dev)
-{
- struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
- if (ocp_dev->driver) {
- if (ocp_dev->driver->remove)
- ocp_dev->driver->remove(ocp_dev);
- ocp_dev->driver = NULL;
- }
- return 0;
-}
-
-static int
-ocp_device_suspend(struct device *dev, u32 state, u32 level)
-{
- struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
- int error = 0;
-
- if (ocp_dev->driver) {
- if (level == SUSPEND_SAVE_STATE && ocp_dev->driver->save_state)
- error = ocp_dev->driver->save_state(ocp_dev, state);
- else if (level == SUSPEND_POWER_DOWN
- && ocp_dev->driver->suspend)
- error = ocp_dev->driver->suspend(ocp_dev, state);
- }
- return error;
-}
-
-static int
-ocp_device_resume(struct device *dev, u32 level)
-{
- struct ocp_device *ocp_dev = to_ocp_dev(dev);
-
- if (ocp_dev->driver) {
- if (level == RESUME_POWER_ON && ocp_dev->driver->resume)
- ocp_dev->driver->resume(ocp_dev);
- }
- return 0;
-}
-
-/**
- * ocp_bus_match - Works out whether an OCP device matches any
- * of the IDs listed for a given OCP driver.
- * @dev: the generic device struct for the OCP device
- * @drv: the generic driver struct for the OCP driver
- *
- * Used by a driver to check whether a OCP device present in the
- * system is in its list of supported devices. Returns 1 for a
- * match, or 0 if there is no match.
- */
-static int
-ocp_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct ocp_device *ocp_dev = to_ocp_dev(dev);
- struct ocp_driver *ocp_drv = to_ocp_driver(drv);
- const struct ocp_device_id *ids = ocp_drv->id_table;
-
- if (!ids)
- return 0;
-
- while (ids->vendor || ids->device) {
- if ((ids->vendor == OCP_ANY_ID
- || ids->vendor == ocp_dev->vendor)
- && (ids->device == OCP_ANY_ID
- || ids->device == ocp_dev->device)) {
- DBG("Bus match -vendor:%x device:%x\n", ids->vendor,
- ids->device);
- return 1;
- }
- ids++;
- }
- return 0;
-}
-
-struct bus_type ocp_bus_type = {
- .name = "ocp",
- .match = ocp_bus_match,
-};
-
-static int __init
-ocp_driver_init(void)
-{
- return bus_register(&ocp_bus_type);
-}
-
-postcore_initcall(ocp_driver_init);
-
-/**
- * ocp_register_driver - register a new ocp driver
- * @drv: the driver structure to register
- *
- * Adds the driver structure to the list of registered drivers
- * Returns the number of ocp devices which were claimed by the driver
- * during registration. The driver remains registered even if the
- * return value is zero.
- */
-int
-ocp_register_driver(struct ocp_driver *drv)
-{
- int count = 0;
-
- /* initialize common driver fields */
- drv->driver.name = drv->name;
- drv->driver.bus = &ocp_bus_type;
- drv->driver.probe = ocp_device_probe;
- drv->driver.resume = ocp_device_resume;
- drv->driver.suspend = ocp_device_suspend;
- drv->driver.remove = ocp_device_remove;
-
- /* register with core */
- count = driver_register(&drv->driver);
- return count ? count : 1;
-}
-
-/**
- * ocp_unregister_driver - unregister a ocp driver
- * @drv: the driver structure to unregister
- *
- * Deletes the driver structure from the list of registered OCP drivers,
- * gives it a chance to clean up by calling its remove() function for
- * each device it was responsible for, and marks those devices as
- * driverless.
- */
-
-void
-ocp_unregister_driver(struct ocp_driver *drv)
-{
- driver_unregister(&drv->driver);
-}
-
-EXPORT_SYMBOL(ocp_register_driver);
-EXPORT_SYMBOL(ocp_unregister_driver);
-EXPORT_SYMBOL(ocp_bus_type);
+++ /dev/null
-/*
- * FILE NAME: ocp-probe.c
- *
- * BRIEF MODULE DESCRIPTION:
- * Device scanning & bus set routines
- * Based on drivers/pci/probe, Copyright (c) 1997--1999 Martin Mares
- *
- * Maintained by: Armin <akuster@mvista.com>
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <asm/ocp.h>
-
-LIST_HEAD(ocp_devices);
-struct device *ocp_bus;
-
-static struct ocp_device * __devinit
-ocp_setup_dev(struct ocp_def *odef, unsigned int index)
-{
- struct ocp_device *dev;
-
- dev = kmalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev)
- return NULL;
- memset(dev, 0, sizeof(*dev));
-
- dev->vendor = odef->vendor;
- dev->device = odef->device;
- dev->num = ocp_get_num(dev->device);
- dev->paddr = odef->paddr;
- dev->irq = odef->irq;
- dev->pm = odef->pm;
- dev->current_state = 4;
-
- sprintf(dev->name, "OCP device %04x:%04x", dev->vendor, dev->device);
-
- DBG("%s %s 0x%lx irq:%d pm:0x%lx \n", dev->slot_name, dev->name,
- (unsigned long) dev->paddr, dev->irq, dev->pm);
-
- /* now put in global tree */
- sprintf(dev->dev.bus_id, "%d", index);
- dev->dev.parent = ocp_bus;
- dev->dev.bus = &ocp_bus_type;
- device_register(&dev->dev);
-
- return dev;
-}
-
-static struct device * __devinit ocp_alloc_primary_bus(void)
-{
- struct device *b;
-
- b = kmalloc(sizeof(struct device), GFP_KERNEL);
- if (b == NULL)
- return NULL;
- memset(b, 0, sizeof(struct device));
- strcpy(b->bus_id, "ocp");
-
- device_register(b);
-
- return b;
-}
-
-void __devinit ocp_setup_devices(struct ocp_def *odef)
-{
- int index;
- struct ocp_device *dev;
-
- if (ocp_bus == NULL)
- ocp_bus = ocp_alloc_primary_bus();
- for (index = 0; odef->vendor != OCP_VENDOR_INVALID; ++index, ++odef) {
- dev = ocp_setup_dev(odef, index);
- if (dev != NULL)
- list_add_tail(&dev->global_list, &ocp_devices);
- }
-}
-
-extern struct ocp_def core_ocp[];
-
-static int __init
-ocparch_init(void)
-{
- ocp_setup_devices(core_ocp);
- return 0;
-}
-
-subsys_initcall(ocparch_init);
-
-EXPORT_SYMBOL(ocp_devices);
+++ /dev/null
-/*
- * ocp.c
- *
- * The is drived from pci.c
- *
- * Current Maintainer
- * Armin Kuster akuster@dslextreme.com
- * Jan, 2002
- *
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/list.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <asm/io.h>
-#include <asm/ocp.h>
-#include <asm/errno.h>
-
-/**
- * ocp_get_num - This determines how many OCP devices of a given
- * device are registered
- * @device: OCP device such as HOST, PCI, GPT, UART, OPB, IIC, GPIO, EMAC, ZMII,
- *
- * The routine returns the number that devices which is registered
- */
-unsigned int ocp_get_num(unsigned int device)
-{
- unsigned int count = 0;
- struct ocp_device *ocp;
- struct list_head *ocp_l;
-
- list_for_each(ocp_l, &ocp_devices) {
- ocp = list_entry(ocp_l, struct ocp_device, global_list);
- if (device == ocp->device)
- count++;
- }
- return count;
-}
-
-/**
- * ocp_get_dev - get ocp driver pointer for ocp device and instance of it
- * @device: OCP device such as PCI, GPT, UART, OPB, IIC, GPIO, EMAC, ZMII
- * @dev_num: ocp device number whos paddr you want
- *
- * The routine returns ocp device pointer
- * in list based on device and instance of that device
- *
- */
-struct ocp_device *
-ocp_get_dev(unsigned int device, int dev_num)
-{
- struct ocp_device *ocp;
- struct list_head *ocp_l;
- int count = 0;
-
- list_for_each(ocp_l, &ocp_devices) {
- ocp = list_entry(ocp_l, struct ocp_device, global_list);
- if (device == ocp->device) {
- if (dev_num == count)
- return ocp;
- count++;
- }
- }
- return NULL;
-}
-
-EXPORT_SYMBOL(ocp_get_dev);
-EXPORT_SYMBOL(ocp_get_num);
-
-#ifdef CONFIG_PM
-int ocp_generic_suspend(struct ocp_device *pdev, u32 state)
-{
- ocp_force_power_off(pdev);
- return 0;
-}
-
-int ocp_generic_resume(struct ocp_device *pdev)
-{
- ocp_force_power_on(pdev);
-}
-
-EXPORT_SYMBOL(ocp_generic_suspend);
-EXPORT_SYMBOL(ocp_generic_resume);
-#endif /* CONFIG_PM */
+++ /dev/null
-/*
- * arch/ppc/kernel/error_log.c
- *
- * Copyright (c) 2000 Tilmann Bitterberg
- * (tilmann@bitterberg.de)
- *
- * Error processing of errors found by rtas even-scan routine
- * which is done with every heartbeat. (chrp_setup.c)
- */
-
-#include <linux/sched.h>
-
-#include <asm/prom.h>
-
-#include "error_log.h"
-
-/* ****************************************************************** */
-/*
- * EVENT-SCAN
- * The whole stuff below here doesn't take any action when it found
- * an error, it just prints as much information as possible and
- * then its up to the user to decide what to do.
- *
- * Returns 0 if no errors were found
- * Returns 1 if there may be more errors
- */
-int ppc_rtas_errorlog_scan(void)
-{
-const char *_errlog_severity[] = {
-#ifdef VERBOSE_ERRORS
- "No Error\n\t\
-Should require no further information",
- "Event\n\t\
-This is not really an error, it is an event. I use events\n\t\
-to communicate with RTAS back and forth.",
- "Warning\n\t\
-Indicates a non-state-losing error, either fully recovered\n\t\
-by RTAS or not needing recovery. Ignore it.",
- "Error sync\n\t\
-May only be fatal to a certain program or thread. Recovery\n\t\
-and continuation is possible, if I only had a handler for\n\t\
-this. Less serious",
- "Error\n\t\
-Less serious, but still causing a loss of data and state.\n\t\
-I can't tell you exactly what to do, You have to decide\n\t\
-with help from the target and initiator field, what kind\n\t\
-of further actions may take place.",
- "Fatal\n\t\
-Represent a permanent hardware failure and I believe this\n\t\
-affects my overall performance and behaviour. I would not\n\t\
-attempt to continue normal operation."
-#else
- "No Error",
- "Event",
- "Warning",
- "Error sync",
- "Error",
- "Fatal"
-#endif /* VERBOSE_ERRORS */
-};
-
-#if 0 /* unused?? */
-const char *_errlog_disposition[] = {
-#ifdef VERBOSE_ERRORS
- "Fully recovered\n\t\
-There was an error, but it is fully recovered by RTAS.",
- "Limited recovery\n\t\
-RTAS was able to recover the state of the machine, but some\n\t\
-feature of the machine has been disabled or lost (for example\n\t\
-error checking) or performance may suffer.",
- "Not recovered\n\t\
-Whether RTAS did not try to recover anything or recovery failed:\n\t\
-HOUSTON, WE HAVE A PROBLEM!"
-#else
- "Fully recovered",
- "Limited recovery",
- "Not recovered"
-#endif /* VERBOSE_ERRORS */
-};
-#endif
-
-const char *_errlog_extended[] = {
-#ifdef VERBOSE_ERRORS
- "Not present\n\t\
-Sad, the RTAS call didn't return an extended error log.",
- "Present\n\t\
-The extended log is present and hopefully it contains a lot of\n\t\
-useful information, which leads to the solution of the problem."
-#else
- "Not present",
- "Present"
-#endif /* VERBOSE_ERRORS */
-};
-
-const char *_errlog_initiator[] = {
- "Unknown or not applicable",
- "CPU",
- "PCI",
- "ISA",
- "Memory",
- "Power management"
-};
-
-const char *_errlog_target[] = {
- "Unknown or not applicable",
- "CPU",
- "PCI",
- "ISA",
- "Memory",
- "Power management"
-};
- rtas_error_log error_log;
- char logdata[1024];
- int error;
-#if 0 /* unused?? */
- int retries = 0; /* if HW error, try 10 times */
-#endif
-
- error = call_rtas ("event-scan", 4, 1, (unsigned long *)&error_log,
- INTERNAL_ERROR | EPOW_WARNING,
- 0, __pa(logdata), 1024);
-
- if (error == 1) /* no errors found */
- return 0;
-
- if (error == -1) {
- printk(KERN_ERR "Unable to get errors. Do you a favor and throw this box away\n");
- return 0;
- }
- if (error_log.version != 1)
- printk(KERN_WARNING "Unknown version (%d), please implement me\n",
- error_log.version);
-
- switch (error_log.disposition) {
- case DISP_FULLY_RECOVERED:
- /* there was an error, but everything is fine now */
- return 0;
- case DISP_NOT_RECOVERED:
- printk("We have a really serious Problem!\n");
- case DISP_LIMITED_RECOVERY:
- printk("Error classification\n");
- printk("Severity : %s\n",
- ppc_rtas_errorlog_check_severity (error_log));
- printk("Initiator : %s\n",
- ppc_rtas_errorlog_check_initiator (error_log));
- printk("Target : %s\n",
- ppc_rtas_errorlog_check_target (error_log));
- printk("Type : %s\n",
- ppc_rtas_errorlog_check_type (error_log));
- printk("Ext. log : %s\n",
- ppc_rtas_errorlog_check_extended (error_log));
- if (error_log.extended)
- ppc_rtas_errorlog_disect_extended (logdata);
- return 1;
- default:
- /* nothing */
- break;
- }
- return 0;
-}
-/* ****************************************************************** */
-const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log)
-{
- const char *_errlog_type[] = {
- "unknown type",
- "too many tries failed",
- "TCE error",
- "RTAS device failed",
- "target timed out",
- "parity error on data", /* 5 */
- "parity error on address",
- "parity error on external cache",
- "access to invalid address",
- "uncorrectable ECC error",
- "corrected ECC error" /* 10 */
- };
- if (error_log.type == TYPE_EPOW)
- return "EPOW";
- if (error_log.type >= TYPE_PMGM_POWER_SW_ON)
- return "PowerMGM Event (not handled right now)";
- return _errlog_type[error_log.type];
-}
-
+++ /dev/null
-#ifndef __ERROR_LOG_H__
-#define __ERROR_LOG_H__
-
-#define VERBOSE_ERRORS 1 /* Maybe I enlarge the kernel too much */
-#undef VERBOSE_ERRORS
-
-/* Event classes */
-/* XXX: Endianess correct? NOW*/
-#define INTERNAL_ERROR 0x80000000 /* set bit 0 */
-#define EPOW_WARNING 0x40000000 /* set bit 1 */
-#define POWERMGM_EVENTS 0x20000000 /* set bit 2 */
-
-/* event-scan returns */
-#define SEVERITY_FATAL 0x5
-#define SEVERITY_ERROR 0x4
-#define SEVERITY_ERROR_SYNC 0x3
-#define SEVERITY_WARNING 0x2
-#define SEVERITY_EVENT 0x1
-#define SEVERITY_NO_ERROR 0x0
-#define DISP_FULLY_RECOVERED 0x0
-#define DISP_LIMITED_RECOVERY 0x1
-#define DISP_NOT_RECOVERED 0x2
-#define PART_PRESENT 0x0
-#define PART_NOT_PRESENT 0x1
-#define INITIATOR_UNKNOWN 0x0
-#define INITIATOR_CPU 0x1
-#define INITIATOR_PCI 0x2
-#define INITIATOR_ISA 0x3
-#define INITIATOR_MEMORY 0x4
-#define INITIATOR_POWERMGM 0x5
-#define TARGET_UNKNOWN 0x0
-#define TARGET_CPU 0x1
-#define TARGET_PCI 0x2
-#define TARGET_ISA 0x3
-#define TARGET_MEMORY 0x4
-#define TARGET_POWERMGM 0x5
-#define TYPE_RETRY 0x01
-#define TYPE_TCE_ERR 0x02
-#define TYPE_INTERN_DEV_FAIL 0x03
-#define TYPE_TIMEOUT 0x04
-#define TYPE_DATA_PARITY 0x05
-#define TYPE_ADDR_PARITY 0x06
-#define TYPE_CACHE_PARITY 0x07
-#define TYPE_ADDR_INVALID 0x08
-#define TYPE_ECC_UNCORR 0x09
-#define TYPE_ECC_CORR 0x0a
-#define TYPE_EPOW 0x40
-/* I don't add PowerMGM events right now, this is a different topic */
-#define TYPE_PMGM_POWER_SW_ON 0x60
-#define TYPE_PMGM_POWER_SW_OFF 0x61
-#define TYPE_PMGM_LID_OPEN 0x62
-#define TYPE_PMGM_LID_CLOSE 0x63
-#define TYPE_PMGM_SLEEP_BTN 0x64
-#define TYPE_PMGM_WAKE_BTN 0x65
-#define TYPE_PMGM_BATTERY_WARN 0x66
-#define TYPE_PMGM_BATTERY_CRIT 0x67
-#define TYPE_PMGM_SWITCH_TO_BAT 0x68
-#define TYPE_PMGM_SWITCH_TO_AC 0x69
-#define TYPE_PMGM_KBD_OR_MOUSE 0x6a
-#define TYPE_PMGM_ENCLOS_OPEN 0x6b
-#define TYPE_PMGM_ENCLOS_CLOSED 0x6c
-#define TYPE_PMGM_RING_INDICATE 0x6d
-#define TYPE_PMGM_LAN_ATTENTION 0x6e
-#define TYPE_PMGM_TIME_ALARM 0x6f
-#define TYPE_PMGM_CONFIG_CHANGE 0x70
-#define TYPE_PMGM_SERVICE_PROC 0x71
-
-typedef struct _rtas_error_log {
- unsigned long version:8; /* Architectural version */
- unsigned long severity:3; /* Severity level of error */
- unsigned long disposition:2; /* Degree of recovery */
- unsigned long extended:1; /* extended log present? */
- unsigned long /* reserved */ :2; /* Reserved for future use */
- unsigned long initiator:4; /* Initiator of event */
- unsigned long target:4; /* Target of failed operation */
- unsigned long type:8; /* General event or error*/
- unsigned long extended_log_length:32; /* length in bytes */
-} rtas_error_log;
-
-/* ****************************************************************** */
-#define ppc_rtas_errorlog_check_severity(x) \
- (_errlog_severity[x.severity])
-#define ppc_rtas_errorlog_check_target(x) \
- (_errlog_target[x.target])
-#define ppc_rtas_errorlog_check_initiator(x) \
- (_errlog_initiator[x.initiator])
-#define ppc_rtas_errorlog_check_extended(x) \
- (_errlog_extended[x.extended])
-#define ppc_rtas_errorlog_disect_extended(x) \
- do { /* implement me */ } while(0)
-extern const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log);
-extern int ppc_rtas_errorlog_scan(void);
-
-
-#endif /* __ERROR_LOG_H__ */
+++ /dev/null
-/*
- * arch/ppc/platforms/est8260_setup.c
- *
- * EST8260 platform support
- *
- * Author: Allen Curtis <acurtis@onz.com>
- * Derived from: m8260_setup.c by Dan Malek, MVista
- *
- * Copyright 2002 Ones and Zeros, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/seq_file.h>
-
-#include <asm/mpc8260.h>
-#include <asm/machdep.h>
-
-static void (*callback_setup_arch)(void);
-
-extern unsigned char __res[sizeof(bd_t)];
-
-extern void m8260_init(unsigned long r3, unsigned long r4,
- unsigned long r5, unsigned long r6, unsigned long r7);
-
-static int
-est8260_show_cpuinfo(struct seq_file *m)
-{
- bd_t *binfo = (bd_t *)__res;
-
- seq_printf(m, "vendor\t\t: EST Corporation\n"
- "machine\t\t: SBC8260 PowerPC\n"
- "\n"
- "mem size\t\t: 0x%08x\n"
- "console baud\t\t: %d\n"
- "\n",
- binfo->bi_memsize,
- binfo->bi_baudrate);
- return 0;
-}
-
-static void __init
-est8260_setup_arch(void)
-{
- printk("EST SBC8260 Port\n");
- callback_setup_arch();
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- /* Generic 8260 platform initialization */
- m8260_init(r3, r4, r5, r6, r7);
-
- /* Anything special for this platform */
- ppc_md.show_cpuinfo = est8260_show_cpuinfo;
-
- callback_setup_arch = ppc_md.setup_arch;
- ppc_md.setup_arch = est8260_setup_arch;
-}
+++ /dev/null
-/*
- * arch/ppc/platforms/ev64260.c
- *
- * Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-/*
- * The EV-64260-BP port is the result of hard work from many people from
- * many companies. In particular, employees of Marvell/Galileo, Mission
- * Critical Linux, Xyterra, and MontaVista Software were heavily involved.
- *
- * Note: I have not been able to get *all* PCI slots to work reliably
- * at 66 MHz. I recommend setting jumpers J15 & J16 to short pins 1&2
- * so that 33 MHz is used. --MAG
- * Note: The 750CXe and 7450 are not stable with a 125MHz or 133MHz TCLK/SYSCLK.
- * At 100MHz, they are solid.
- */
-#include <linux/config.h>
-
-#include <linux/delay.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-#include <linux/irq.h>
-#include <linux/fs.h>
-#include <linux/seq_file.h>
-#include <linux/console.h>
-#include <linux/initrd.h>
-#include <linux/root_dev.h>
-#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-#include <linux/serial.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-#endif
-#include <asm/bootinfo.h>
-#include <asm/machdep.h>
-#include <asm/mv64x60.h>
-#include <asm/ppcboot.h>
-#include <asm/todc.h>
-#include <asm/time.h>
-#include <asm/ocp.h>
-
-#include <platforms/ev64260.h>
-
-#define BOARD_VENDOR "Marvell/Galileo"
-#define BOARD_MACHINE "EV-64260-BP"
-
-/* Set IDE controllers into Native mode? */
-/* XXXX
-#define SET_PCI_IDE_NATIVE
-*/
-
-ulong ev64260_mem_size = 0;
-bd_t ppcboot_bd;
-int ppcboot_bd_valid=0;
-
-static mv64x60_handle_t bh;
-
-#if !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-extern void gen550_progress(char *, unsigned short);
-extern void gen550_init(int, struct serial_struct *);
-#endif
-
-static const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */
- 18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
-};
-static const unsigned int cpu_745x[2][16] = { /* PLL_EXT 0 & 1 */
- { 1, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0 },
- { 0, 30, 0, 2, 0, 26, 0, 18, 0, 22, 20, 24, 28, 32, 0, 0 }
-};
-
-
-TODC_ALLOC();
-
-static int
-ev64260_get_bus_speed(void)
-{
- int speed;
-
- if (ppcboot_bd_valid) {
- speed = ppcboot_bd.bi_busfreq;
- }
- else {
- speed = 100000000; /* Only 100MHz is stable */
- }
-
- return speed;
-}
-
-static int
-ev64260_get_cpu_speed(void)
-{
- unsigned long pvr, hid1, pll_ext;
-
- pvr = PVR_VER(mfspr(PVR));
-
- if (pvr != PVR_VER(PVR_7450)) {
- hid1 = mfspr(HID1) >> 28;
- return ev64260_get_bus_speed() * cpu_7xx[hid1]/2;
- }
- else {
- hid1 = (mfspr(HID1) & 0x0001e000) >> 13;
- pll_ext = 0; /* No way to read; must get from schematic */
- return ev64260_get_bus_speed() * cpu_745x[pll_ext][hid1]/2;
- }
-}
-
-unsigned long __init
-ev64260_find_end_of_memory(void)
-{
- if(!ppcboot_bd_valid) {
- return mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
- MV64x60_TYPE_GT64260A);
- }
- return ppcboot_bd.bi_memsize;
-}
-
-#if 0 /* XXXX */
-#ifdef SET_PCI_IDE_NATIVE
-static void __init
-set_pci_native_mode(void)
-{
- struct pci_dev *dev;
-
- /* Better way of doing this ??? */
- pci_for_each_dev(dev) {
- int class = dev->class >> 8;
-
- /* enable pci native mode */
- if (class == PCI_CLASS_STORAGE_IDE) {
- u8 reg;
-
- pci_read_config_byte(dev, 0x9, ®);
- if (reg == 0x8a) {
- printk("PCI: Enabling PCI IDE native mode on %s\n", dev->slot_name);
- pci_write_config_byte(dev, 0x9, 0x8f);
-
- /* let the pci code set this device up after we change it */
- pci_setup_device(dev);
- } else if (reg != 0x8f) {
- printk("PCI: IDE chip in unknown mode 0x%02x on %s", reg, dev->slot_name);
- }
- }
- }
-}
-#endif
-#endif
-
-static void __init
-ev64260_pci_fixups(void)
-{
-#ifdef SET_PCI_IDE_NATIVE
- set_pci_native_mode();
-#endif
-}
-
-
-/*
- * Marvell/Galileo EV-64260-BP Evaluation Board PCI interrupt routing.
- * Note: By playing with J8 and JP1-4, you can get 2 IRQ's from the first
- * PCI bus (in which cast, INTPIN B would be EV64260_PCI_1_IRQ).
- * This is the most IRQs you can get from one bus with this board, though.
- */
-static int __init
-ev64260_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
- struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
-
- if (hose->index == 0) {
- static char pci_irq_table[][4] =
- /*
- * PCI IDSEL/INTPIN->INTLINE
- * A B C D
- */
- {
- {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 0 */
- {EV64260_PCI_0_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 0 */
- };
-
- const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
- return PCI_IRQ_TABLE_LOOKUP;
- }
- else {
- static char pci_irq_table[][4] =
- /*
- * PCI IDSEL/INTPIN->INTLINE
- * A B C D
- */
- {
- { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 7 - PCI bus 1 */
- { EV64260_PCI_1_IRQ,0,0,0}, /* IDSEL 8 - PCI bus 1 */
- };
-
- const long min_idsel = 7, max_idsel = 8, irqs_per_slot = 4;
- return PCI_IRQ_TABLE_LOOKUP;
- }
-}
-
-static void __init
-ev64260_setup_peripherals(void)
-{
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
- EV64260_EMB_FLASH_BASE, EV64260_EMB_FLASH_SIZE, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN,
- EV64260_EXT_SRAM_BASE, EV64260_EXT_SRAM_SIZE, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN,
- EV64260_TODC_BASE, EV64260_TODC_SIZE, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN,
- EV64260_UART_BASE, EV64260_UART_SIZE, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN,
- EV64260_EXT_FLASH_BASE, EV64260_EXT_FLASH_SIZE, 0);
-
- TODC_INIT(TODC_TYPE_DS1501, 0, 0,
- ioremap(EV64260_TODC_BASE, EV64260_TODC_SIZE), 8);
-
- mv64x60_clr_bits(&bh, MV64x60_CPU_CONFIG, ((1<<28) | (1<<29)));
- mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<27));
-
- if (ev64260_get_bus_speed() > 100000000) {
- mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1<<23));
- }
-
- mv64x60_set_bits(&bh, MV64x60_PCI0_PCI_DECODE_CNTL,((1<<0) | (1<<3)));
- mv64x60_set_bits(&bh, MV64x60_PCI1_PCI_DECODE_CNTL,((1<<0) | (1<<3)));
-
- /*
- * Enabling of PCI internal-vs-external arbitration
- * is a platform- and errata-dependent decision.
- */
- if (bh.type == MV64x60_TYPE_GT64260A ) {
- mv64x60_set_bits(&bh, MV64x60_PCI0_ARBITER_CNTL, (1<<31));
- mv64x60_set_bits(&bh, MV64x60_PCI1_ARBITER_CNTL, (1<<31));
- }
-
- mv64x60_set_bits(&bh, MV64x60_CPU_MASTER_CNTL, (1<<9)); /* Only 1 cpu */
-
- /*
- * The EV-64260-BP uses several Multi-Purpose Pins (MPP) on the 64260
- * bridge as interrupt inputs (via the General Purpose Ports (GPP)
- * register). Need to route the MPP inputs to the GPP and set the
- * polarity correctly.
- *
- * In MPP Control 2 Register
- * MPP 21 -> GPP 21 (DUART channel A intr) bits 20-23 -> 0
- * MPP 22 -> GPP 22 (DUART channel B intr) bits 24-27 -> 0
- */
- mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_2, (0xf<<20) | (0xf<<24) );
-
- /*
- * In MPP Control 3 Register
- * MPP 26 -> GPP 26 (RTC INT) bits 8-11 -> 0
- * MPP 27 -> GPP 27 (PCI 0 INTA) bits 12-15 -> 0
- * MPP 29 -> GPP 29 (PCI 1 INTA) bits 20-23 -> 0
- */
- mv64x60_clr_bits(&bh, MV64x60_MPP_CNTL_3,
- (0xf<<8) | (0xf<<12) | (0xf<<20));
-
-#define GPP_EXTERNAL_INTERRUPTS \
- ((1<<21) | (1<<22) | (1<<26) | (1<<27) | (1<<29))
- /* DUART & PCI interrupts are inputs */
- mv64x60_clr_bits(&bh, MV64x60_GPP_IO_CNTL, GPP_EXTERNAL_INTERRUPTS);
- /* DUART & PCI interrupts are active low */
- mv64x60_set_bits(&bh, MV64x60_GPP_LEVEL_CNTL, GPP_EXTERNAL_INTERRUPTS);
-
- /* Clear any pending interrupts for these inputs and enable them. */
- mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, ~GPP_EXTERNAL_INTERRUPTS);
- mv64x60_set_bits(&bh, MV64x60_GPP_INTR_MASK, GPP_EXTERNAL_INTERRUPTS);
-
- /*
- * Set MPSC Multiplex RMII
- * NOTE: ethernet driver modifies bit 0 and 1
- */
- mv64x60_write(&bh, GT64260_MPP_SERIAL_PORTS_MULTIPLEX, 0x00001102);
- return;
-}
-
-
-static void __init
-ev64260_setup_bridge(void)
-{
- mv64x60_setup_info_t si;
- int i;
-
- memset(&si, 0, sizeof(si));
-
- si.phys_reg_base = CONFIG_MV64X60_NEW_BASE;
- si.map_irq = ev64260_map_irq;
-
- si.pci_0.enable_bus = 1;
- si.pci_0.enumerate_bus = 1;
- si.pci_0.pci_io.cpu_base = 0xa0000000;
- si.pci_0.pci_io.pci_base_hi = 0;
- si.pci_0.pci_io.pci_base_lo = 0;
- si.pci_0.pci_io.size = 0x01000000;
- si.pci_0.pci_io.swap = 0x01000000; /* XXXX No swapping */
- si.pci_0.pci_mem[0].cpu_base = 0x80000000;
- si.pci_0.pci_mem[0].pci_base_hi = 0;
- si.pci_0.pci_mem[0].pci_base_lo = 0x80000000;
- si.pci_0.pci_mem[0].size = 0x10000000;
- si.pci_0.pci_mem[0].swap = 0x01000000; /* XXXX No swapping */
- si.pci_0.pci_mem[1].cpu_base = 0;
- si.pci_0.pci_mem[1].pci_base_hi = 0;
- si.pci_0.pci_mem[1].pci_base_lo = 0;
- si.pci_0.pci_mem[1].size = 0; /* Don't use this window */
- si.pci_0.pci_mem[1].swap = 0;
- si.pci_0.pci_mem[2].cpu_base = 0;
- si.pci_0.pci_mem[2].pci_base_hi = 0;
- si.pci_0.pci_mem[2].pci_base_lo = 0;
- si.pci_0.pci_mem[2].size = 0; /* Don't use this window */
- si.pci_0.pci_mem[1].swap = 0;
- si.pci_0.pci_cmd_bits = 0;
- si.pci_0.latency_timer = 0x8;
-
- si.pci_1.enable_bus = 1;
- si.pci_1.enumerate_bus = 1;
- si.pci_1.pci_io.cpu_base = 0xa1000000;
- si.pci_1.pci_io.pci_base_hi = 0;
- si.pci_1.pci_io.pci_base_lo = 0x01000000;
- si.pci_1.pci_io.size = 0x01000000;
- si.pci_1.pci_io.swap = 0x01000000; /* XXXX No swapping */
- si.pci_1.pci_mem[0].cpu_base = 0x90000000;
- si.pci_1.pci_mem[0].pci_base_hi = 0;
- si.pci_1.pci_mem[0].pci_base_lo = 0x90000000;
- si.pci_1.pci_mem[0].size = 0x10000000;
- si.pci_1.pci_mem[0].swap = 0x01000000; /* XXXX No swapping */
- si.pci_1.pci_mem[1].cpu_base = 0;
- si.pci_1.pci_mem[1].pci_base_hi = 0;
- si.pci_1.pci_mem[1].pci_base_lo = 0;
- si.pci_1.pci_mem[1].size = 0; /* Don't use this window */
- si.pci_1.pci_mem[1].swap = 0;
- si.pci_1.pci_mem[2].cpu_base = 0;
- si.pci_1.pci_mem[2].pci_base_hi = 0;
- si.pci_1.pci_mem[2].pci_base_lo = 0;
- si.pci_1.pci_mem[2].size = 0; /* Don't use this window */
- si.pci_1.pci_mem[1].swap = 0;
- si.pci_1.pci_cmd_bits = 0;
- si.pci_1.latency_timer = 0x8;
- si.pci_1.pci_cmd_bits = 0;
- si.pci_1.latency_timer = 0x8;
-
- for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
- si.cpu_prot_options[i] = 0;
- si.cpu_snoop_options[i] = GT64260_CPU_SNOOP_WB;
- si.pci_0.acc_cntl_options[i] =
- /* Breaks PCI (especially slot 4)
- GT64260_PCI_ACC_CNTL_PREFETCHEN |
- */
- GT64260_PCI_ACC_CNTL_DREADEN |
- GT64260_PCI_ACC_CNTL_RDPREFETCH |
- GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
- GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
- GT64260_PCI_ACC_CNTL_SWAP_NONE |
- GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
- si.pci_0.snoop_options[i] = GT64260_PCI_SNOOP_WB;
- si.pci_1.acc_cntl_options[i] =
- /* Breaks PCI (especially slot 4)
- GT64260_PCI_ACC_CNTL_PREFETCHEN |
- */
- GT64260_PCI_ACC_CNTL_DREADEN |
- GT64260_PCI_ACC_CNTL_RDPREFETCH |
- GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |
- GT64260_PCI_ACC_CNTL_RDMULPREFETCH |
- GT64260_PCI_ACC_CNTL_SWAP_NONE |
- GT64260_PCI_ACC_CNTL_MBURST_32_BTYES;
- si.pci_1.snoop_options[i] = GT64260_PCI_SNOOP_WB;
- }
-
- /* Lookup PCI host bridges */
- if (mv64x60_init(&bh, &si)) {
- printk("Bridge initialization failed.\n");
- }
-
- return;
-}
-
-#if defined(CONFIG_SERIAL_8250) && !defined(CONFIG_SERIAL_MPSC_CONSOLE)
-static void __init
-ev64260_early_serial_map(void)
-{
- struct uart_port port;
- static char first_time = 1;
-
- if (first_time) {
- memset(&port, 0, sizeof(port));
-
- port.membase = ioremap(EV64260_SERIAL_0, EV64260_UART_SIZE);
- port.irq = EV64260_UART_0_IRQ;
- port.uartclk = BASE_BAUD * 16;
- port.regshift = 2;
- port.iotype = SERIAL_IO_MEM;
- port.flags = STD_COM_FLAGS;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
- gen550_init(0, &port);
-#endif
-
- if (early_serial_setup(&port) != 0) {
- printk("Early serial init of port 0 failed\n");
- }
-
-#if 0 /* XXXX */
- /* Assume early_serial_setup() doesn't modify port */
- port.membase = ioremap(EV64260_SERIAL_1, EV64260_UART_SIZE);
- port.irq = EV64260_UART_1_IRQ;
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
- gen550_init(1, &port);
-#endif
-
- if (early_serial_setup(&port) != 0) {
- printk("Early serial init of port 1 failed\n");
- }
-#endif
-
- first_time = 0;
- }
-
- return;
-}
-#elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
-static void __init
-ev64260_early_serial_map(void)
-{
-#ifdef CONFIG_KGDB
- static char first_time = 1;
-
-
-#if defined(CONFIG_KGDB_TTYS0)
-#define KGDB_PORT 0
-#elif defined(CONFIG_KGDB_TTYS1)
-#define KGDB_PORT 1
-#else
-#error "Invalid kgdb_tty port"
-#endif
-
- if (first_time) {
- gt_early_mpsc_init(KGDB_PORT, B9600|CS8|CREAD|HUPCL|CLOCAL);
- first_time = 0;
- }
-
- return;
-#endif
-}
-#endif
-
-static void __init
-ev64260_fixup_ocp(void)
-{
-#if defined(CONFIG_SERIAL_MPSC)
- struct ocp_device *dev;
- mv64x60_ocp_mpsc_data_t *dp;
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
- != NULL) {
- dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-
- dp->max_idle = 40; /* XXXX what should this be? */
- dp->default_baud = EV64260_DEFAULT_BAUD;
- dp->brg_clk_src = EV64260_MPSC_CLK_SRC;
- dp->brg_clk_freq = EV64260_MPSC_CLK_FREQ;
- }
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
- != NULL) {
- dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
-
- dp->max_idle = 40; /* XXXX what should this be? */
- dp->default_baud = 9600; /* XXXX */
- dp->brg_clk_src = EV64260_MPSC_CLK_SRC;
- dp->brg_clk_freq = EV64260_MPSC_CLK_FREQ;
- }
-#endif
-
- return;
-}
-
-static void __init
-ev64260_setup_arch(void)
-{
- if ( ppc_md.progress )
- ppc_md.progress("ev64260_setup_arch: enter", 0);
-
-#ifdef CONFIG_BLK_DEV_INITRD
- if (initrd_start)
- ROOT_DEV = Root_RAM0;
- else
-#endif
-#ifdef CONFIG_ROOT_NFS
- ROOT_DEV = Root_NFS;
-#else
- ROOT_DEV = Root_SDA2;
-#endif
-
- if ( ppc_md.progress )
- ppc_md.progress("ev64260_setup_arch: Enabling L2 cache", 0);
-
- /* Enable L2 and L3 caches (if 745x) */
- _set_L2CR(_get_L2CR() | L2CR_L2E);
- _set_L3CR(_get_L3CR() | L3CR_L3E);
-
- if ( ppc_md.progress )
- ppc_md.progress("ev64260_setup_arch: Initializing bridge", 0);
-
- ev64260_setup_bridge(); /* set up PCI bridge(s) */
- ev64260_setup_peripherals(); /* set up chip selects/GPP/MPP etc */
-
- if ( ppc_md.progress )
- ppc_md.progress("ev64260_setup_arch: bridge init complete", 0);
-
- /* Set OCP values to reflect this board's setup */
- ev64260_fixup_ocp();
-
-#ifdef CONFIG_DUMMY_CONSOLE
- conswitchp = &dummy_con;
-#endif
-#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_MPSC_CONSOLE)
- ev64260_early_serial_map();
-#endif
-
- printk(BOARD_VENDOR " " BOARD_MACHINE "\n");
- printk("EV-64260-BP port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
-
- if ( ppc_md.progress )
- ppc_md.progress("ev64260_setup_arch: exit", 0);
-
- return;
-}
-
-static void
-ev64260_reset_board(void *addr)
-{
- local_irq_disable();
-
- /* disable and invalidate the L2 cache */
- _set_L2CR(0);
- _set_L2CR(0x200000);
-
- /* flush and disable L1 I/D cache */
- __asm__ __volatile__
- ("mfspr 3,1008\n\t"
- "ori 5,5,0xcc00\n\t"
- "ori 4,3,0xc00\n\t"
- "andc 5,3,5\n\t"
- "sync\n\t"
- "mtspr 1008,4\n\t"
- "isync\n\t"
- "sync\n\t"
- "mtspr 1008,5\n\t"
- "isync\n\t"
- "sync\n\t");
-
- /* unmap any other random cs's that might overlap with bootcs */
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, 0, 0, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, 0, 0, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_2_WIN, 0, 0, 0);
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_3_WIN, 0, 0, 0);
-
- /* map bootrom back in to gt @ reset defaults */
- mv64x60_set_32bit_window(&bh, MV64x60_CPU2BOOT_WIN,
- 0xff800000, 8*1024*1024, 0);
-
- /* move gt reg base back to default, setup default pci0 swapping
- * config... */
- mv64x60_write(&bh, MV64x60_INTERNAL_SPACE_DECODE,
- (1<<24) | MV64x60_INTERNAL_SPACE_DEFAULT_ADDR>>20);
-
- /* NOTE: FROM NOW ON no more GT_REGS accesses.. 0x1 is not mapped
- * via BAT or MMU, and MSR IR/DR is ON */
-#if 0
- /* BROKEN... IR/DR is still on !! won't work!! */
- /* Set exception prefix high - to the firmware */
- _nmask_and_or_msr(0, MSR_IP);
-
- out_8((u_char *)EV64260_BOARD_MODRST_REG, 0x01);
-#else
- /* SRR0 has system reset vector, SRR1 has default MSR value */
- /* rfi restores MSR from SRR1 and sets the PC to the SRR0 value */
- /* NOTE: assumes reset vector is at 0xfff00100 */
- __asm__ __volatile__
- ("mtspr 26, %0\n\t"
- "li 4,(1<<6)\n\t"
- "mtspr 27,4\n\t"
- "rfi\n\t"
- :: "r" (addr):"r4");
-#endif
- return;
-}
-
-static void
-ev64260_restart(char *cmd)
-{
- volatile ulong i = 10000000;
-
- ev64260_reset_board((void *)0xfff00100);
-
- while (i-- > 0);
- panic("restart failed\n");
-}
-
-static void
-ev64260_halt(void)
-{
- local_irq_disable();
- while (1);
- /* NOTREACHED */
-}
-
-static void
-ev64260_power_off(void)
-{
- ev64260_halt();
- /* NOTREACHED */
-}
-
-static int
-ev64260_show_cpuinfo(struct seq_file *m)
-{
- uint pvid;
-
- pvid = mfspr(PVR);
- seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
- seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
- seq_printf(m, "cpu MHz\t\t: %d\n", ev64260_get_cpu_speed()/1000/1000);
- seq_printf(m, "bus MHz\t\t: %d\n", ev64260_get_bus_speed()/1000/1000);
-
- return 0;
-}
-
-/* DS1501 RTC has too much variation to use RTC for calibration */
-static void __init
-ev64260_calibrate_decr(void)
-{
- ulong freq;
-
- freq = ev64260_get_bus_speed()/4;
-
- printk("time_init: decrementer frequency = %lu.%.6lu MHz\n",
- freq/1000000, freq%1000000);
-
- tb_ticks_per_jiffy = freq / HZ;
- tb_to_us = mulhwu_scale_factor(freq, 1000000);
-
- return;
-}
-
-#if 0 /* XXXX */
-#ifdef CONFIG_USE_PPCBOOT
-static void parse_ppcbootinfo(unsigned long r3,
- unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- bd_t *bd=NULL;
- char *cmdline_start=NULL;
- int cmdline_len=0;
-
- if(r3) {
- if((r3 & 0xf0000000) == 0) r3 += KERNELBASE;
- if((r3 & 0xf0000000) == KERNELBASE) {
- bd=(void *)r3;
-
- /* hack for ppcboot loaders that report freqs in Mhz */
- if(bd->bi_intfreq<1000000) bd->bi_intfreq*=1000000;
- if(bd->bi_busfreq<1000000) bd->bi_busfreq*=1000000;
-
- memcpy(&ppcboot_bd,bd,sizeof(ppcboot_bd));
- ppcboot_bd_valid=1;
- }
- }
-
-#ifdef CONFIG_BLK_DEV_INITRD
- if(r4 && r5 && r5>r4) {
- if((r4 & 0xf0000000) == 0) r4 += KERNELBASE;
- if((r5 & 0xf0000000) == 0) r5 += KERNELBASE;
- if((r4 & 0xf0000000) == KERNELBASE) {
- initrd_start=r4;
- initrd_end=r5;
- initrd_below_start_ok = 1;
- }
- }
-#endif /* CONFIG_BLK_DEV_INITRD */
-
- if(r6 && r7 && r7>r6) {
- if((r6 & 0xf0000000) == 0) r6 += KERNELBASE;
- if((r7 & 0xf0000000) == 0) r7 += KERNELBASE;
- if((r6 & 0xf0000000) == KERNELBASE) {
- cmdline_start=(void *)r6;
- cmdline_len=(r7-r6);
- strncpy(cmd_line,cmdline_start,cmdline_len);
- }
- }
-
- if(ppcboot_bd_valid) {
- printk("found bd_t @%p\n", bd);
- printk("memstart=%08lx\n", bd->bi_memstart);
- printk("memsize=%08lx\n", bd->bi_memsize);
- printk("enetaddr=%02x%02x%02x%02x%02x%02x\n",
- bd->bi_enetaddr[0],
- bd->bi_enetaddr[1],
- bd->bi_enetaddr[2],
- bd->bi_enetaddr[3],
- bd->bi_enetaddr[4],
- bd->bi_enetaddr[5]
- );
- printk("intfreq=%ld\n", bd->bi_intfreq);
- printk("busfreq=%ld\n", bd->bi_busfreq);
- printk("baudrate=%ld\n", bd->bi_baudrate);
- }
-
-#ifdef CONFIG_BLK_DEV_INITRD
- if(initrd_start) {
- printk("found initrd @%lx-%lx\n", initrd_start, initrd_end);
- }
-#endif /* CONFIG_BLK_DEV_INITRD */
-
- if(cmdline_start && cmdline_len) {
- printk("found cmdline: '%s'\n", cmd_line);
- }
-}
-#endif /* USE PPC_BOOT */
-#endif
-
-#if 0 /* XXXX */
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-static int
-ev64260_ide_check_region(ide_ioreg_t from, unsigned int extent)
-{
- return check_region(from, extent);
-}
-
-static void
-ev64260_ide_request_region(ide_ioreg_t from,
- unsigned int extent,
- const char *name)
-{
- request_region(from, extent, name);
- return;
-}
-
-static void
-ev64260_ide_release_region(ide_ioreg_t from,
- unsigned int extent)
-{
- release_region(from, extent);
- return;
-}
-
-static void __init
-ev64260_ide_pci_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port,
- ide_ioreg_t ctrl_port, int *irq)
-{
- struct pci_dev *dev;
-#if 1 /* NTL */
- int i;
-
- //printk("regs %d to %d @ 0x%x\n", IDE_DATA_OFFSET, IDE_STATUS_OFFSET, data_port);
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = data_port;
- data_port++;
- }
-
- //printk("ctrl %d @ 0x%x\n", IDE_CONTROL_OFFSET, ctrl_port);
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-#endif
-
- pci_for_each_dev(dev) {
- if (((dev->class >> 8) == PCI_CLASS_STORAGE_IDE) ||
- ((dev->class >> 8) == PCI_CLASS_STORAGE_RAID)) {
- hw->irq = dev->irq;
-
- if (irq != NULL) {
- *irq = dev->irq;
- }
- }
- }
-
- return;
-}
-#endif
-#endif
-
-#if !defined(CONFIG_USE_PPCBOOT)
-/*
- * Set BAT 3 to map 0xfb000000 to 0xfc000000 of physical memory space.
- */
-static __inline__ void
-ev64260_set_bat(void)
-{
- mb();
- mtspr(DBAT1U, 0xfb0001fe);
- mtspr(DBAT1L, 0xfb00002a);
- mb();
-
- return;
-}
-#endif
-
-#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
-static void __init
-ev64260_map_io(void)
-{
- io_block_mapping(0xfb000000, 0xfb000000, 0x01000000, _PAGE_IO);
-}
-#endif
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
-#ifdef CONFIG_BLK_DEV_INITRD
- extern int initrd_below_start_ok;
-
- initrd_start=initrd_end=0;
- initrd_below_start_ok=0;
-#endif /* CONFIG_BLK_DEV_INITRD */
-
- ppcboot_bd_valid=0;
- memset(&ppcboot_bd,0,sizeof(ppcboot_bd));
-
-#ifdef CONFIG_USE_PPCBOOT
- parse_ppcbootinfo(r3, r4, r5, r6, r7);
-#else
- parse_bootinfo(find_bootinfo());
-#endif
-
- isa_mem_base = 0;
- isa_io_base = 0xa0000000; /* XXXX */
- pci_dram_offset = 0x80000000; /* XXXX */
-
- loops_per_jiffy = ev64260_get_cpu_speed() / HZ;
-
- ppc_md.setup_arch = ev64260_setup_arch;
- ppc_md.show_cpuinfo = ev64260_show_cpuinfo;
- ppc_md.init_IRQ = gt64260_init_irq;
- ppc_md.get_irq = gt64260_get_irq;
-
- ppc_md.pcibios_fixup = ev64260_pci_fixups;
-
- ppc_md.restart = ev64260_restart;
- ppc_md.power_off = ev64260_power_off;
- ppc_md.halt = ev64260_halt;
-
- ppc_md.find_end_of_memory = ev64260_find_end_of_memory;
-
- ppc_md.init = NULL;
-
- ppc_md.time_init = todc_time_init;
- ppc_md.set_rtc_time = todc_set_rtc_time;
- ppc_md.get_rtc_time = todc_get_rtc_time;
-
- ppc_md.nvram_read_val = todc_direct_read_val;
- ppc_md.nvram_write_val = todc_direct_write_val;
-
- ppc_md.calibrate_decr = ev64260_calibrate_decr;
-
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
- ppc_ide_md.ide_init_hwif = ev64260_ide_pci_init_hwif_ports;
-#endif
-
- bh.p_base = CONFIG_MV64X60_NEW_BASE;
-
-#if !defined(CONFIG_USE_PPCBOOT)
- ev64260_set_bat();
-#endif
-
-#ifdef CONFIG_SERIAL_8250
-#if defined(CONFIG_SERIAL_TEXT_DEBUG)
- ppc_md.setup_io_mappings = ev64260_map_io;
- ppc_md.progress = gen550_progress;
-#endif
-#if defined(CONFIG_KGDB)
- ppc_md.setup_io_mappings = ev64260_map_io;
- ppc_md.early_serial_map = ev64260_early_serial_map;
-#endif
-#elif defined(CONFIG_SERIAL_MPSC_CONSOLE)
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
- ppc_md.setup_io_mappings = ev64260_map_io;
- ppc_md.progress = gt64260_mpsc_progress;
-#endif /* CONFIG_SERIAL_TEXT_DEBUG */
-#ifdef CONFIG_KGDB
- ppc_md.setup_io_mappings = ev64260_map_io;
- ppc_md.early_serial_map = ev64260_early_serial_map;
-#endif /* CONFIG_KGDB */
-
-#endif
-
- return;
-}
+++ /dev/null
-/*
- * arch/ppc/platforms/lopec_pci.c
- *
- * PCI setup routines for the Motorola LoPEC.
- *
- * Author: Dan Cox
- * danc@mvista.com (or, alternately, source@mvista.com)
- *
- * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#include <linux/init.h>
-#include <linux/pci.h>
-
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc10x.h>
-
-static inline int __init
-lopec_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
- int irq;
- static char pci_irq_table[][4] = {
- {16, 0, 0, 0}, /* ID 11 - Winbond */
- {22, 0, 0, 0}, /* ID 12 - SCSI */
- {0, 0, 0, 0}, /* ID 13 - nothing */
- {17, 0, 0, 0}, /* ID 14 - 82559 Ethernet */
- {27, 0, 0, 0}, /* ID 15 - USB */
- {23, 0, 0, 0}, /* ID 16 - PMC slot 1 */
- {24, 0, 0, 0}, /* ID 17 - PMC slot 2 */
- {25, 0, 0, 0}, /* ID 18 - PCI slot */
- {0, 0, 0, 0}, /* ID 19 - nothing */
- {0, 0, 0, 0}, /* ID 20 - nothing */
- {0, 0, 0, 0}, /* ID 21 - nothing */
- {0, 0, 0, 0}, /* ID 22 - nothing */
- {0, 0, 0, 0}, /* ID 23 - nothing */
- {0, 0, 0, 0}, /* ID 24 - PMC slot 1b */
- {0, 0, 0, 0}, /* ID 25 - nothing */
- {0, 0, 0, 0} /* ID 26 - PMC Slot 2b */
- };
- const long min_idsel = 11, max_idsel = 26, irqs_per_slot = 4;
-
- irq = PCI_IRQ_TABLE_LOOKUP;
- if (!irq)
- return 0;
-
- return irq;
-}
-
-void __init
-lopec_setup_winbond_83553(struct pci_controller *hose)
-{
- int devfn;
-
- devfn = PCI_DEVFN(11,0);
-
- /* IDE interrupt routing (primary 14, secondary 15) */
- early_write_config_byte(hose, 0, devfn, 0x43, 0xef);
- /* PCI interrupt routing */
- early_write_config_word(hose, 0, devfn, 0x44, 0x0000);
-
- /* ISA-PCI address decoder */
- early_write_config_byte(hose, 0, devfn, 0x48, 0xf0);
-
- /* RTC, kb, not used in PPC */
- early_write_config_byte(hose, 0, devfn, 0x4d, 0x00);
- early_write_config_byte(hose, 0, devfn, 0x4e, 0x04);
- devfn = PCI_DEVFN(11, 1);
- early_write_config_byte(hose, 0, devfn, 0x09, 0x8f);
- early_write_config_dword(hose, 0, devfn, 0x40, 0x00ff0011);
-}
-
-void __init
-lopec_find_bridges(void)
-{
- struct pci_controller *hose;
-
- hose = pcibios_alloc_controller();
- if (!hose)
- return;
-
- hose->first_busno = 0;
- hose->last_busno = 0xff;
-
- if (mpc10x_bridge_init(hose,
- MPC10X_MEM_MAP_B,
- MPC10X_MEM_MAP_B,
- MPC10X_MAPB_EUMB_BASE) == 0) {
-
- hose->mem_resources[0].end = 0xffffffff;
- lopec_setup_winbond_83553(hose);
- hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
- ppc_md.pci_swizzle = common_swizzle;
- ppc_md.pci_map_irq = lopec_map_irq;
- }
-}
+++ /dev/null
-/*
- * include/asm-ppc/lopec_serial.h
- *
- * Definitions for Motorola LoPEC board.
- *
- * Author: Dan Cox
- * danc@mvista.com (or, alternately, source@mvista.com)
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __H_LOPEC_SERIAL
-#define __H_LOPEC_SERIAL
-
-#define RS_TABLE_SIZE 3
-
-#define BASE_BAUD (1843200 / 16)
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-#define SERIAL_PORT_DFNS \
- { 0, BASE_BAUD, 0xffe10000, 29, STD_COM_FLAGS, \
- iomem_base: (u8 *) 0xffe10000, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, 0xffe11000, 20, STD_COM_FLAGS, \
- iomem_base: (u8 *) 0xffe11000, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, 0xffe12000, 21, STD_COM_FLAGS, \
- iomem_base: (u8 *) 0xffe12000, \
- io_type: SERIAL_IO_MEM }
-
-#endif
+++ /dev/null
-/*
- * arch/ppc/platforms/lopec_setup.c
- *
- * Setup routines for the Motorola LoPEC.
- *
- * Author: Dan Cox
- * danc@mvista.com
- *
- * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/pci_ids.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/ide.h>
-#include <linux/seq_file.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/root_dev.h>
-
-#include <asm/io.h>
-#include <asm/open_pic.h>
-#include <asm/i8259.h>
-#include <asm/todc.h>
-#include <asm/bootinfo.h>
-#include <asm/mpc10x.h>
-#include <asm/hw_irq.h>
-#include <asm/prep_nvram.h>
-
-extern void lopec_find_bridges(void);
-
-/*
- * Define all of the IRQ senses and polarities. Taken from the
- * LoPEC Programmer's Reference Guide.
- */
-static u_char lopec_openpic_initsenses[16] __initdata = {
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 0 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 1 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 2 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 3 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 4 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 5 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 6 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 7 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 8 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 9 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 10 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 11 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* IRQ 12 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* IRQ 13 */
- (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE), /* IRQ 14 */
- (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE) /* IRQ 15 */
-};
-
-static int
-lopec_show_cpuinfo(struct seq_file *m)
-{
- seq_printf(m, "machine\t\t: Motorola LoPEC\n");
- return 0;
-}
-
-static u32
-lopec_irq_canonicalize(u32 irq)
-{
- if (irq == 2)
- return 9;
- else
- return irq;
-}
-
-static void
-lopec_restart(char *cmd)
-{
-#define LOPEC_SYSSTAT1 0xffe00000
- /* force a hard reset, if possible */
- unsigned char reg = *((unsigned char *) LOPEC_SYSSTAT1);
- reg |= 0x80;
- *((unsigned char *) LOPEC_SYSSTAT1) = reg;
-
- local_irq_disable();
- while(1);
-#undef LOPEC_SYSSTAT1
-}
-
-static void
-lopec_halt(void)
-{
- local_irq_disable();
- while(1);
-}
-
-static void
-lopec_power_off(void)
-{
- lopec_halt();
-}
-
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-int lopec_ide_ports_known = 0;
-static unsigned long lopec_ide_regbase[MAX_HWIFS];
-static unsigned long lopec_ide_ctl_regbase[MAX_HWIFS];
-static unsigned long lopec_idedma_regbase;
-
-static void
-lopec_ide_probe(void)
-{
- struct pci_dev *dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
- PCI_DEVICE_ID_WINBOND_82C105,
- NULL);
- lopec_ide_ports_known = 1;
-
- if (dev) {
- lopec_ide_regbase[0] = dev->resource[0].start;
- lopec_ide_regbase[1] = dev->resource[2].start;
- lopec_ide_ctl_regbase[0] = dev->resource[1].start;
- lopec_ide_ctl_regbase[1] = dev->resource[3].start;
- lopec_idedma_regbase = dev->resource[4].start;
- }
-}
-
-static int
-lopec_ide_default_irq(unsigned long base)
-{
- if (lopec_ide_ports_known == 0)
- lopec_ide_probe();
-
- if (base == lopec_ide_regbase[0])
- return 14;
- else if (base == lopec_ide_regbase[1])
- return 15;
- else
- return 0;
-}
-
-static unsigned long
-lopec_ide_default_io_base(int index)
-{
- if (lopec_ide_ports_known == 0)
- lopec_ide_probe();
- return lopec_ide_regbase[index];
-}
-
-static void __init
-lopec_ide_init_hwif_ports(hw_regs_t *hw, unsigned long data,
- unsigned long ctl, int *irq)
-{
- unsigned long reg = data;
- uint alt_status_base;
- int i;
-
- for(i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
- hw->io_ports[i] = reg++;
-
- if (data == lopec_ide_regbase[0]) {
- alt_status_base = lopec_ide_ctl_regbase[0] + 2;
- hw->irq = 14;
- }
- else if (data == lopec_ide_regbase[1]) {
- alt_status_base = lopec_ide_ctl_regbase[1] + 2;
- hw->irq = 15;
- }
- else {
- alt_status_base = 0;
- hw->irq = 0;
- }
-
- if (ctl)
- hw->io_ports[IDE_CONTROL_OFFSET] = ctl;
- else
- hw->io_ports[IDE_CONTROL_OFFSET] = alt_status_base;
-
- if (irq != NULL)
- *irq = hw->irq;
-
-}
-#endif /* BLK_DEV_IDE */
-
-static void __init
-lopec_init_IRQ(void)
-{
- int i;
-
- /*
- * Provide the open_pic code with the correct table of interrupts.
- */
- OpenPIC_InitSenses = lopec_openpic_initsenses;
- OpenPIC_NumInitSenses = sizeof(lopec_openpic_initsenses);
-
- mpc10x_set_openpic();
-
- /* We have a cascade on OpenPIC IRQ 0, Linux IRQ 16 */
- openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
- &i8259_irq);
-
- /* Map i8259 interrupts */
- for(i = 0; i < NUM_8259_INTERRUPTS; i++)
- irq_desc[i].handler = &i8259_pic;
-
- /*
- * The EPIC allows for a read in the range of 0xFEF00000 ->
- * 0xFEFFFFFF to generate a PCI interrupt-acknowledge transaction.
- */
- i8259_init(0xfef00000);
-}
-
-static int __init
-lopec_request_io(void)
-{
- outb(0x00, 0x4d0);
- outb(0xc0, 0x4d1);
-
- request_region(0x00, 0x20, "dma1");
- request_region(0x20, 0x20, "pic1");
- request_region(0x40, 0x20, "timer");
- request_region(0x80, 0x10, "dma page reg");
- request_region(0xa0, 0x20, "pic2");
- request_region(0xc0, 0x20, "dma2");
-
- return 0;
-}
-
-device_initcall(lopec_request_io);
-
-static void __init
-lopec_map_io(void)
-{
- io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO);
- io_block_mapping(0xb0000000, 0xb0000000, 0x10000000, _PAGE_IO);
-}
-
-static void __init
-lopec_set_bat(void)
-{
- unsigned long batu, batl;
-
- __asm__ __volatile__(
- "lis %0,0xf800\n \
- ori %1,%0,0x002a\n \
- ori %0,%0,0x0ffe\n \
- mtspr 0x21e,%0\n \
- mtspr 0x21f,%1\n \
- isync\n \
- sync "
- : "=r" (batu), "=r" (batl));
-}
-
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <linux/serial_reg.h>
-#include <asm/serial.h>
-
-static struct serial_state rs_table[RS_TABLE_SIZE] = {
- SERIAL_PORT_DFNS /* Defined in <asm/serial.h> */
-};
-
-volatile unsigned char *com_port;
-volatile unsigned char *com_port_lsr;
-
-static void
-serial_writechar(char c)
-{
- while ((*com_port_lsr & UART_LSR_THRE) == 0)
- ;
- *com_port = c;
-}
-
-void
-lopec_progress(char *s, unsigned short hex)
-{
- volatile char c;
-
- com_port = (volatile unsigned char *) rs_table[0].port;
- com_port_lsr = com_port + UART_LSR;
-
- while ((c = *s++) != 0)
- serial_writechar(c);
-
- /* Most messages don't have a newline in them */
- serial_writechar('\n');
- serial_writechar('\r');
-}
-#endif /* CONFIG_SERIAL_TEXT_DEBUG */
-
-TODC_ALLOC();
-
-static void __init
-lopec_setup_arch(void)
-{
-
- TODC_INIT(TODC_TYPE_MK48T37, 0, 0,
- ioremap(0xffe80000, 0x8000), 8);
-
- loops_per_jiffy = 100000000/HZ;
-
- lopec_find_bridges();
-
-#ifdef CONFIG_BLK_DEV_INITRD
- if (initrd_start)
- ROOT_DEV = Root_RAM0;
- else
-#elif defined(CONFIG_ROOT_NFS)
- ROOT_DEV = Root_NFS;
-#elif defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
- ROOT_DEV = Root_HDA1;
-#else
- ROOT_DEV = Root_SDA1;
-#endif
-
-#ifdef CONFIG_VT
- conswitchp = &dummy_con;
-#endif
-#ifdef CONFIG_PPCBUG_NVRAM
- /* Read in NVRAM data */
- init_prep_nvram();
-
- /* if no bootargs, look in NVRAM */
- if ( cmd_line[0] == '\0' ) {
- char *bootargs;
- bootargs = prep_nvram_get_var("bootargs");
- if (bootargs != NULL) {
- strcpy(cmd_line, bootargs);
- /* again.. */
- strcpy(saved_command_line, cmd_line);
- }
- }
-#endif
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- parse_bootinfo(find_bootinfo());
- lopec_set_bat();
-
- isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
- isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
- pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
- ISA_DMA_THRESHOLD = 0x00ffffff;
- DMA_MODE_READ = 0x44;
- DMA_MODE_WRITE = 0x48;
-
- ppc_md.setup_arch = lopec_setup_arch;
- ppc_md.show_cpuinfo = lopec_show_cpuinfo;
- ppc_md.irq_canonicalize = lopec_irq_canonicalize;
- ppc_md.init_IRQ = lopec_init_IRQ;
- ppc_md.get_irq = openpic_get_irq;
-
- ppc_md.restart = lopec_restart;
- ppc_md.power_off = lopec_power_off;
- ppc_md.halt = lopec_halt;
-
- ppc_md.setup_io_mappings = lopec_map_io;
-
- ppc_md.time_init = todc_time_init;
- ppc_md.set_rtc_time = todc_set_rtc_time;
- ppc_md.get_rtc_time = todc_get_rtc_time;
- ppc_md.calibrate_decr = todc_calibrate_decr;
-
- ppc_md.nvram_read_val = todc_direct_read_val;
- ppc_md.nvram_write_val = todc_direct_write_val;
-
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
- ppc_ide_md.default_irq = lopec_ide_default_irq;
- ppc_ide_md.default_io_base = lopec_ide_default_io_base;
- ppc_ide_md.ide_init_hwif = lopec_ide_init_hwif_ports;
-#endif
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
- ppc_md.progress = lopec_progress;
-#endif
-}
+++ /dev/null
-/*
- * include/asm-ppc/mcpn765_serial.h
- *
- * Definitions for Motorola MCG MCPN765 cPCI board support
- *
- * Author: Mark A. Greer
- * mgreer@mvista.com
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __ASMPPC_MCPN765_SERIAL_H
-#define __ASMPPC_MCPN765_SERIAL_H
-
-#include <linux/config.h>
-
-/* Define the UART base addresses */
-#define MCPN765_SERIAL_1 0xfef88000
-#define MCPN765_SERIAL_2 0xfef88200
-#define MCPN765_SERIAL_3 0xfef88400
-#define MCPN765_SERIAL_4 0xfef88600
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE 64
-#else
-#define RS_TABLE_SIZE 4
-#endif
-
-/* Rate for the 1.8432 Mhz clock for the onboard serial chip */
-#define BASE_BAUD ( 1843200 / 16 )
-#define UART_CLK 1843200
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-/* All UART IRQ's are wire-OR'd to IRQ 17 */
-#define STD_SERIAL_PORT_DFNS \
- { 0, BASE_BAUD, MCPN765_SERIAL_1, 17, STD_COM_FLAGS, /* ttyS0 */\
- iomem_base: (u8 *)MCPN765_SERIAL_1, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, MCPN765_SERIAL_2, 17, STD_COM_FLAGS, /* ttyS1 */\
- iomem_base: (u8 *)MCPN765_SERIAL_2, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, MCPN765_SERIAL_3, 17, STD_COM_FLAGS, /* ttyS2 */\
- iomem_base: (u8 *)MCPN765_SERIAL_3, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, MCPN765_SERIAL_4, 17, STD_COM_FLAGS, /* ttyS3 */\
- iomem_base: (u8 *)MCPN765_SERIAL_4, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM },
-
-#define SERIAL_PORT_DFNS \
- STD_SERIAL_PORT_DFNS
-
-#endif /* __ASMPPC_MCPN765_SERIAL_H */
+++ /dev/null
-/*
- * arch/ppc/platforms/mvme5100_pci.c
- *
- * PCI setup routines for the Motorola MVME5100.
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <platforms/mvme5100.h>
-#include <asm/pplus.h>
-
-static inline int
-mvme5100_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
-{
- int irq;
-
- static char pci_irq_table[][4] =
- /*
- * PCI IDSEL/INTPIN->INTLINE
- * A B C D
- */
- {
- { 0, 0, 0, 0 }, /* IDSEL 11 - Winbond */
- { 0, 0, 0, 0 }, /* IDSEL 12 - unused */
- { 21, 22, 23, 24 }, /* IDSEL 13 - Universe II */
- { 18, 0, 0, 0 }, /* IDSEL 14 - Enet 1 */
- { 0, 0, 0, 0 }, /* IDSEL 15 - unused */
- { 25, 26, 27, 28 }, /* IDSEL 16 - PMC Slot 1 */
- { 28, 25, 26, 27 }, /* IDSEL 17 - PMC Slot 2 */
- { 0, 0, 0, 0 }, /* IDSEL 18 - unused */
- { 29, 0, 0, 0 }, /* IDSEL 19 - Enet 2 */
- { 0, 0, 0, 0 }, /* IDSEL 20 - PMCSPAN */
- };
-
- const long min_idsel = 11, max_idsel = 20, irqs_per_slot = 4;
- irq = PCI_IRQ_TABLE_LOOKUP;
- /* If lookup is zero, always return 0 */
- if (!irq)
- return 0;
- else
-#ifdef CONFIG_MVME5100_IPMC761_PRESENT
- /* If IPMC761 present, return table value */
- return irq;
-#else
- /* If IPMC761 not present, we don't have an i8259 so adjust */
- return (irq - NUM_8259_INTERRUPTS);
-#endif
-}
-
-static void
-mvme5100_pcibios_fixup_resources(struct pci_dev *dev)
-{
- int i;
-
- if ((dev->vendor == PCI_VENDOR_ID_MOTOROLA) &&
- (dev->device == PCI_DEVICE_ID_MOTOROLA_HAWK))
- for (i=0; i<DEVICE_COUNT_RESOURCE; i++)
- {
- dev->resource[i].start = 0;
- dev->resource[i].end = 0;
- }
-}
-
-void __init
-mvme5100_setup_bridge(void)
-{
- struct pci_controller* hose;
-
- hose = pcibios_alloc_controller();
-
- if (!hose)
- return;
-
- hose->first_busno = 0;
- hose->last_busno = 0xff;
- hose->pci_mem_offset = MVME5100_PCI_MEM_OFFSET;
-
- pci_init_resource(&hose->io_resource,
- MVME5100_PCI_LOWER_IO,
- MVME5100_PCI_UPPER_IO,
- IORESOURCE_IO,
- "PCI host bridge");
-
- pci_init_resource(&hose->mem_resources[0],
- MVME5100_PCI_LOWER_MEM,
- MVME5100_PCI_UPPER_MEM,
- IORESOURCE_MEM,
- "PCI host bridge");
-
- hose->io_space.start = MVME5100_PCI_LOWER_IO;
- hose->io_space.end = MVME5100_PCI_UPPER_IO;
- hose->mem_space.start = MVME5100_PCI_LOWER_MEM;
- hose->mem_space.end = MVME5100_PCI_UPPER_MEM;
- hose->io_base_virt = (void *)MVME5100_ISA_IO_BASE;
-
- /* Use indirect method of Hawk */
- setup_indirect_pci(hose,
- MVME5100_PCI_CONFIG_ADDR,
- MVME5100_PCI_CONFIG_DATA);
-
- hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
-
- ppc_md.pcibios_fixup_resources = mvme5100_pcibios_fixup_resources;
- ppc_md.pci_swizzle = common_swizzle;
- ppc_md.pci_map_irq = mvme5100_map_irq;
-}
+++ /dev/null
-/*
- * include/asm-ppc/mvme5100_serial.h
- *
- * Definitions for Motorola MVME5100 support
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_MVME5100_SERIAL_H__
-#define __ASM_MVME5100_SERIAL_H__
-
-#include <linux/config.h>
-#include <platforms/mvme5100.h>
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE 64
-#else
-#define RS_TABLE_SIZE 4
-#endif
-
-#define BASE_BAUD ( MVME5100_BASE_BAUD / 16 )
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-/* All UART IRQ's are wire-OR'd to one MPIC IRQ */
-#define STD_SERIAL_PORT_DFNS \
- { 0, BASE_BAUD, MVME5100_SERIAL_1, \
- MVME5100_SERIAL_IRQ, \
- STD_COM_FLAGS, /* ttyS0 */ \
- iomem_base: (unsigned char *)MVME5100_SERIAL_1, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM }, \
- { 0, BASE_BAUD, MVME5100_SERIAL_2, \
- MVME5100_SERIAL_IRQ, \
- STD_COM_FLAGS, /* ttyS1 */ \
- iomem_base: (unsigned char *)MVME5100_SERIAL_2, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM },
-
-#define SERIAL_PORT_DFNS \
- STD_SERIAL_PORT_DFNS
-
-#endif /* __ASM_MVME5100_SERIAL_H__ */
-#endif /* __KERNEL__ */
+++ /dev/null
-/*
- * arch/ppc/platforms/mvme5100_setup.c
- *
- * Board setup routines for the Motorola MVME5100.
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/initrd.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/ide.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <asm/time.h>
-#include <asm/dma.h>
-#include <asm/io.h>
-#include <asm/machdep.h>
-#include <asm/prom.h>
-#include <asm/smp.h>
-#include <asm/open_pic.h>
-#include <asm/i8259.h>
-#include <platforms/mvme5100.h>
-#include <asm/todc.h>
-#include <asm/pci-bridge.h>
-#include <asm/bootinfo.h>
-#include <asm/pplus.h>
-
-extern char cmd_line[];
-
-static u_char mvme5100_openpic_initsenses[] __initdata = {
- 0, /* 16: i8259 cascade (active high) */
- 1, /* 17: TL16C550 UART 1,2 */
- 1, /* 18: Enet 1 (front panel or P2) */
- 1, /* 19: Hawk Watchdog 1,2 */
- 1, /* 20: DS1621 thermal alarm */
- 1, /* 21: Universe II LINT0# */
- 1, /* 22: Universe II LINT1# */
- 1, /* 23: Universe II LINT2# */
- 1, /* 24: Universe II LINT3# */
- 1, /* 25: PMC1 INTA#, PMC2 INTB# */
- 1, /* 26: PMC1 INTB#, PMC2 INTC# */
- 1, /* 27: PMC1 INTC#, PMC2 INTD# */
- 1, /* 28: PMC1 INTD#, PMC2 INTA# */
- 1, /* 29: Enet 2 (front panel) */
- 1, /* 30: Abort Switch */
- 1, /* 31: RTC Alarm */
-};
-
-static void __init
-mvme5100_setup_arch(void)
-{
- if ( ppc_md.progress )
- ppc_md.progress("mvme5100_setup_arch: enter", 0);
-
- loops_per_jiffy = 50000000 / HZ;
-
-#ifdef CONFIG_BLK_DEV_INITRD
- if (initrd_start)
- ROOT_DEV = Root_RAM0;
- else
-#endif
-#ifdef CONFIG_ROOT_NFS
- ROOT_DEV = Root_NFS;
-#else
- ROOT_DEV = Root_SDA2;
-#endif
-
-#ifdef CONFIG_DUMMY_CONSOLE
- conswitchp = &dummy_con;
-#endif
-
- if ( ppc_md.progress )
- ppc_md.progress("mvme5100_setup_arch: find_bridges", 0);
-
- /* Setup PCI host bridge */
- mvme5100_setup_bridge();
-
- /* Find and map our OpenPIC */
- pplus_mpic_init(MVME5100_PCI_MEM_OFFSET);
- OpenPIC_InitSenses = mvme5100_openpic_initsenses;
- OpenPIC_NumInitSenses = sizeof(mvme5100_openpic_initsenses);
-
- printk("MVME5100 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
-
- if ( ppc_md.progress )
- ppc_md.progress("mvme5100_setup_arch: exit", 0);
-
- return;
-}
-
-static void __init
-mvme5100_init2(void)
-{
-#ifdef CONFIG_MVME5100_IPMC761_PRESENT
- request_region(0x00,0x20,"dma1");
- request_region(0x20,0x20,"pic1");
- request_region(0x40,0x20,"timer");
- request_region(0x80,0x10,"dma page reg");
- request_region(0xa0,0x20,"pic2");
- request_region(0xc0,0x20,"dma2");
-#endif
- return;
-}
-
-/*
- * Interrupt setup and service.
- * Have MPIC on HAWK and cascaded 8259s on Winbond cascaded to MPIC.
- */
-static void __init
-mvme5100_init_IRQ(void)
-{
-#ifdef CONFIG_MVME5100_IPMC761_PRESENT
- int i;
-#endif
-
- if ( ppc_md.progress )
- ppc_md.progress("init_irq: enter", 0);
-
-#ifdef CONFIG_MVME5100_IPMC761_PRESENT
- openpic_init(1, NUM_8259_INTERRUPTS, NULL, -1);
- openpic_hookup_cascade(NUM_8259_INTERRUPTS,"82c59 cascade",&i8259_irq);
-
- for(i=0; i < NUM_8259_INTERRUPTS; i++)
- irq_desc[i].handler = &i8259_pic;
-
- i8259_init(NULL);
-#else
- openpic_init(1, 0, NULL, -1);
-#endif
-
- if ( ppc_md.progress )
- ppc_md.progress("init_irq: exit", 0);
-
- return;
-}
-
-/*
- * Set BAT 3 to map 0xf0000000 to end of physical memory space.
- */
-static __inline__ void
-mvme5100_set_bat(void)
-{
- unsigned long bat3u, bat3l;
- static int mapping_set = 0;
-
- if (!mapping_set) {
-
- __asm__ __volatile__(
- " lis %0,0xf000\n \
- ori %1,%0,0x002a\n \
- ori %0,%0,0x1ffe\n \
- mtspr 0x21e,%0\n \
- mtspr 0x21f,%1\n \
- isync\n \
- sync "
- : "=r" (bat3u), "=r" (bat3l));
-
- mapping_set = 1;
- }
-
- return;
-}
-
-static unsigned long __init
-mvme5100_find_end_of_memory(void)
-{
- mvme5100_set_bat();
- return pplus_get_mem_size(MVME5100_HAWK_SMC_BASE);
-}
-
-static void __init
-mvme5100_map_io(void)
-{
- io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
- ioremap_base = 0xfe000000;
-}
-
-static void
-mvme5100_reset_board(void)
-{
- local_irq_disable();
-
- /* Set exception prefix high - to the firmware */
- _nmask_and_or_msr(0, MSR_IP);
-
- out_8((u_char *)MVME5100_BOARD_MODRST_REG, 0x01);
-
- return;
-}
-
-static void
-mvme5100_restart(char *cmd)
-{
- volatile ulong i = 10000000;
-
- mvme5100_reset_board();
-
- while (i-- > 0);
- panic("restart failed\n");
-}
-
-static void
-mvme5100_halt(void)
-{
- local_irq_disable();
- while (1);
-}
-
-static void
-mvme5100_power_off(void)
-{
- mvme5100_halt();
-}
-
-static int
-mvme5100_show_cpuinfo(struct seq_file *m)
-{
- seq_printf(m, "vendor\t\t: Motorola\n");
- seq_printf(m, "machine\t\t: MVME5100\n");
-
- return 0;
-}
-
-TODC_ALLOC();
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- parse_bootinfo(find_bootinfo());
-
- isa_io_base = MVME5100_ISA_IO_BASE;
- isa_mem_base = MVME5100_ISA_MEM_BASE;
- pci_dram_offset = MVME5100_PCI_DRAM_OFFSET;
-
- ppc_md.setup_arch = mvme5100_setup_arch;
- ppc_md.show_cpuinfo = mvme5100_show_cpuinfo;
- ppc_md.init_IRQ = mvme5100_init_IRQ;
- ppc_md.get_irq = openpic_get_irq;
- ppc_md.init = mvme5100_init2;
-
- ppc_md.restart = mvme5100_restart;
- ppc_md.power_off = mvme5100_power_off;
- ppc_md.halt = mvme5100_halt;
-
- ppc_md.find_end_of_memory = mvme5100_find_end_of_memory;
- ppc_md.setup_io_mappings = mvme5100_map_io;
-
- TODC_INIT(TODC_TYPE_MK48T37,
- MVME5100_NVRAM_AS0,
- MVME5100_NVRAM_AS1,
- MVME5100_NVRAM_DATA,
- 8);
-
- ppc_md.time_init = todc_time_init;
- ppc_md.set_rtc_time = todc_set_rtc_time;
- ppc_md.get_rtc_time = todc_get_rtc_time;
- ppc_md.calibrate_decr = todc_calibrate_decr;
-
- ppc_md.nvram_read_val = todc_m48txx_read_val;
- ppc_md.nvram_write_val = todc_m48txx_write_val;
-
- ppc_md.progress = NULL;
-}
+++ /dev/null
-/*
- * include/asm-ppc/platforms/powerpmc250_serial.h
- *
- * Motorola PrPMC750 serial support
- *
- * Author: Troy Benjegerdes <tbenjegerdes@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASMPPC_POWERPMC250_SERIAL_H
-#define __ASMPPC_POWERPMC250_SERIAL_H
-
-#include <linux/config.h>
-#include <platforms/powerpmc250.h>
-
-#define RS_TABLE_SIZE 1
-
-#define BASE_BAUD (POWERPMC250_BASE_BAUD / 16)
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF)
-#endif
-
-#define SERIAL_PORT_DFNS \
-{ 0, BASE_BAUD, POWERPMC250_SERIAL, POWERPMC250_SERIAL_IRQ, STD_COM_FLAGS, /* ttyS0 */\
- iomem_base: (u8 *)POWERPMC250_SERIAL, \
- iomem_reg_shift: 0, \
- io_type: SERIAL_IO_MEM }
-
-#endif
-#endif /* __KERNEL__ */
+++ /dev/null
-/*
- * arch/ppc/platforms/pq2ads_setup.c
- *
- * PQ2ADS platform support
- *
- * Author: Kumar Gala <kumar.gala@freescale.com>
- * Derived from: est8260_setup.c by Allen Curtis
- *
- * Copyright 2004 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/seq_file.h>
-
-#include <asm/mpc8260.h>
-#include <asm/machdep.h>
-
-static void (*callback_setup_arch)(void);
-
-extern unsigned char __res[sizeof(bd_t)];
-
-extern void m8260_init(unsigned long r3, unsigned long r4,
- unsigned long r5, unsigned long r6, unsigned long r7);
-
-static int
-pq2ads_show_cpuinfo(struct seq_file *m)
-{
- bd_t *binfo = (bd_t *)__res;
-
- seq_printf(m, "vendor\t\t: Motorola\n"
- "machine\t\t: PQ2 ADS PowerPC\n"
- "\n"
- "mem size\t\t: 0x%08lx\n"
- "console baud\t\t: %ld\n"
- "\n",
- binfo->bi_memsize,
- binfo->bi_baudrate);
- return 0;
-}
-
-static void __init
-pq2ads_setup_arch(void)
-{
- printk("PQ2 ADS Port\n");
- callback_setup_arch();
- *(volatile uint *)(BCSR_ADDR + 4) &= ~BCSR1_RS232_EN2;
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- /* Generic 8260 platform initialization */
- m8260_init(r3, r4, r5, r6, r7);
-
- /* Anything special for this platform */
- ppc_md.show_cpuinfo = pq2ads_show_cpuinfo;
-
- callback_setup_arch = ppc_md.setup_arch;
- ppc_md.setup_arch = pq2ads_setup_arch;
-}
+++ /dev/null
-/*
- * arch/ppc/platforms/proc_rtas.c
- * Copyright (C) 2000 Tilmann Bitterberg
- * (tilmann@bitterberg.de)
- *
- * RTAS (Runtime Abstraction Services) stuff
- * Intention is to provide a clean user interface
- * to use the RTAS.
- *
- * TODO:
- * Split off a header file and maybe move it to a different
- * location. Write Documentation on what the /proc/rtas/ entries
- * actually do.
- */
-
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/proc_fs.h>
-#include <linux/stat.h>
-#include <linux/ctype.h>
-#include <linux/time.h>
-#include <linux/string.h>
-#include <linux/init.h>
-
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
-#include <asm/processor.h>
-#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/machdep.h> /* for ppc_md */
-#include <asm/time.h>
-
-/* Token for Sensors */
-#define KEY_SWITCH 0x0001
-#define ENCLOSURE_SWITCH 0x0002
-#define THERMAL_SENSOR 0x0003
-#define LID_STATUS 0x0004
-#define POWER_SOURCE 0x0005
-#define BATTERY_VOLTAGE 0x0006
-#define BATTERY_REMAINING 0x0007
-#define BATTERY_PERCENTAGE 0x0008
-#define EPOW_SENSOR 0x0009
-#define BATTERY_CYCLESTATE 0x000a
-#define BATTERY_CHARGING 0x000b
-
-/* IBM specific sensors */
-#define IBM_SURVEILLANCE 0x2328 /* 9000 */
-#define IBM_FANRPM 0x2329 /* 9001 */
-#define IBM_VOLTAGE 0x232a /* 9002 */
-#define IBM_DRCONNECTOR 0x232b /* 9003 */
-#define IBM_POWERSUPPLY 0x232c /* 9004 */
-#define IBM_INTQUEUE 0x232d /* 9005 */
-
-/* Status return values */
-#define SENSOR_CRITICAL_HIGH 13
-#define SENSOR_WARNING_HIGH 12
-#define SENSOR_NORMAL 11
-#define SENSOR_WARNING_LOW 10
-#define SENSOR_CRITICAL_LOW 9
-#define SENSOR_SUCCESS 0
-#define SENSOR_HW_ERROR -1
-#define SENSOR_BUSY -2
-#define SENSOR_NOT_EXIST -3
-#define SENSOR_DR_ENTITY -9000
-
-/* Location Codes */
-#define LOC_SCSI_DEV_ADDR 'A'
-#define LOC_SCSI_DEV_LOC 'B'
-#define LOC_CPU 'C'
-#define LOC_DISKETTE 'D'
-#define LOC_ETHERNET 'E'
-#define LOC_FAN 'F'
-#define LOC_GRAPHICS 'G'
-/* reserved / not used 'H' */
-#define LOC_IO_ADAPTER 'I'
-/* reserved / not used 'J' */
-#define LOC_KEYBOARD 'K'
-#define LOC_LCD 'L'
-#define LOC_MEMORY 'M'
-#define LOC_NV_MEMORY 'N'
-#define LOC_MOUSE 'O'
-#define LOC_PLANAR 'P'
-#define LOC_OTHER_IO 'Q'
-#define LOC_PARALLEL 'R'
-#define LOC_SERIAL 'S'
-#define LOC_DEAD_RING 'T'
-#define LOC_RACKMOUNTED 'U' /* for _u_nit is rack mounted */
-#define LOC_VOLTAGE 'V'
-#define LOC_SWITCH_ADAPTER 'W'
-#define LOC_OTHER 'X'
-#define LOC_FIRMWARE 'Y'
-#define LOC_SCSI 'Z'
-
-/* Tokens for indicators */
-#define TONE_FREQUENCY 0x0001 /* 0 - 1000 (HZ)*/
-#define TONE_VOLUME 0x0002 /* 0 - 100 (%) */
-#define SYSTEM_POWER_STATE 0x0003
-#define WARNING_LIGHT 0x0004
-#define DISK_ACTIVITY_LIGHT 0x0005
-#define HEX_DISPLAY_UNIT 0x0006
-#define BATTERY_WARNING_TIME 0x0007
-#define CONDITION_CYCLE_REQUEST 0x0008
-#define SURVEILLANCE_INDICATOR 0x2328 /* 9000 */
-#define DR_ACTION 0x2329 /* 9001 */
-#define DR_INDICATOR 0x232a /* 9002 */
-/* 9003 - 9004: Vendor specific */
-#define GLOBAL_INTERRUPT_QUEUE 0x232d /* 9005 */
-/* 9006 - 9999: Vendor specific */
-
-/* other */
-#define MAX_SENSORS 17 /* I only know of 17 sensors */
-#define MAX_LINELENGTH 256
-#define SENSOR_PREFIX "ibm,sensor-"
-#define cel_to_fahr(x) ((x*9/5)+32)
-
-
-/* Globals */
-static struct proc_dir_entry *proc_rtas;
-static struct rtas_sensors sensors;
-static struct device_node *rtas;
-static unsigned long power_on_time = 0; /* Save the time the user set */
-static char progress_led[MAX_LINELENGTH];
-
-static unsigned long rtas_tone_frequency = 1000;
-static unsigned long rtas_tone_volume = 0;
-
-/* ****************STRUCTS******************************************* */
-struct individual_sensor {
- unsigned int token;
- unsigned int quant;
-};
-
-struct rtas_sensors {
- struct individual_sensor sensor[MAX_SENSORS];
- unsigned int quant;
-};
-
-/* ****************************************************************** */
-/* Declarations */
-static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
- int count, int *eof, void *data);
-static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos);
-
-static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos);
-static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
- size_t count, loff_t *ppos);
-
-struct file_operations ppc_rtas_poweron_operations = {
- .read = ppc_rtas_poweron_read,
- .write = ppc_rtas_poweron_write
-};
-struct file_operations ppc_rtas_progress_operations = {
- .read = ppc_rtas_progress_read,
- .write = ppc_rtas_progress_write
-};
-
-struct file_operations ppc_rtas_clock_operations = {
- .read = ppc_rtas_clock_read,
- .write = ppc_rtas_clock_write
-};
-
-struct file_operations ppc_rtas_tone_freq_operations = {
- .read = ppc_rtas_tone_freq_read,
- .write = ppc_rtas_tone_freq_write
-};
-struct file_operations ppc_rtas_tone_volume_operations = {
- .read = ppc_rtas_tone_volume_read,
- .write = ppc_rtas_tone_volume_write
-};
-
-int ppc_rtas_find_all_sensors (void);
-int ppc_rtas_process_sensor(struct individual_sensor s, int state,
- int error, char * buf);
-char * ppc_rtas_process_error(int error);
-int get_location_code(struct individual_sensor s, char * buf);
-int check_location_string (char *c, char * buf);
-int check_location (char *c, int idx, char * buf);
-
-/* ****************************************************************** */
-/* MAIN */
-/* ****************************************************************** */
-static int __init proc_rtas_init(void)
-{
- struct proc_dir_entry *entry;
-
- rtas = find_devices("rtas");
- if ((rtas == 0) || (_machine != _MACH_chrp)) {
- return 1;
- }
-
- proc_rtas = proc_mkdir("rtas", 0);
- if (proc_rtas == 0)
- return 1;
-
- /* /proc/rtas entries */
-
- entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_rtas);
- if (entry) entry->proc_fops = &ppc_rtas_progress_operations;
-
- entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_rtas);
- if (entry) entry->proc_fops = &ppc_rtas_clock_operations;
-
- entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_rtas);
- if (entry) entry->proc_fops = &ppc_rtas_poweron_operations;
-
- create_proc_read_entry("sensors", S_IRUGO, proc_rtas,
- ppc_rtas_sensor_read, NULL);
-
- entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_rtas);
- if (entry) entry->proc_fops = &ppc_rtas_tone_freq_operations;
-
- entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_rtas);
- if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
-
- return 0;
-}
-__initcall(proc_rtas_init);
-
-/* ****************************************************************** */
-/* POWER-ON-TIME */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- struct rtc_time tm;
- unsigned long nowtime;
- char *dest;
- int error;
-
- nowtime = simple_strtoul(buf, &dest, 10);
- if (*dest != '\0' && *dest != '\n') {
- printk("ppc_rtas_poweron_write: Invalid time\n");
- return count;
- }
- power_on_time = nowtime; /* save the time */
-
- to_tm(nowtime, &tm);
-
- error = call_rtas("set-time-for-power-on", 7, 1, NULL,
- tm.tm_year, tm.tm_mon, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
- if (error != 0)
- printk(KERN_WARNING "error: setting poweron time returned: %s\n",
- ppc_rtas_process_error(error));
- return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
- size_t count, loff_t *ppos)
-{
- int n;
- if (power_on_time == 0)
- n = sprintf(buf, "Power on time not set\n");
- else
- n = sprintf(buf, "%lu\n", power_on_time);
-
- if (*ppos >= strlen(buf))
- return 0;
- if (n > strlen(buf) - *ppos)
- n = strlen(buf) - *ppos;
- if (n > count)
- n = count;
- *ppos += n;
- return n;
-}
-
-/* ****************************************************************** */
-/* PROGRESS */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- unsigned long hex;
-
- strcpy(progress_led, buf); /* save the string */
- /* Lets see if the user passed hexdigits */
- hex = simple_strtoul(buf, NULL, 10);
-
- ppc_md.progress ((char *)buf, hex);
- return count;
-
- /* clear the line */ /* ppc_md.progress(" ", 0xffff);*/
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
- size_t count, loff_t *ppos)
-{
- int n = 0;
- if (progress_led != NULL)
- n = sprintf (buf, "%s\n", progress_led);
- if (*ppos >= strlen(buf))
- return 0;
- if (n > strlen(buf) - *ppos)
- n = strlen(buf) - *ppos;
- if (n > count)
- n = count;
- *ppos += n;
- return n;
-}
-
-/* ****************************************************************** */
-/* CLOCK */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- struct rtc_time tm;
- unsigned long nowtime;
- char *dest;
- int error;
-
- nowtime = simple_strtoul(buf, &dest, 10);
- if (*dest != '\0' && *dest != '\n') {
- printk("ppc_rtas_clock_write: Invalid time\n");
- return count;
- }
-
- to_tm(nowtime, &tm);
- error = call_rtas("set-time-of-day", 7, 1, NULL,
- tm.tm_year, tm.tm_mon, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
- if (error != 0)
- printk(KERN_WARNING "error: setting the clock returned: %s\n",
- ppc_rtas_process_error(error));
- return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
- size_t count, loff_t *ppos)
-{
- unsigned int year, mon, day, hour, min, sec;
- unsigned long *ret = kmalloc(4*8, GFP_KERNEL);
- int n, error;
-
- error = call_rtas("get-time-of-day", 0, 8, ret);
-
- year = ret[0]; mon = ret[1]; day = ret[2];
- hour = ret[3]; min = ret[4]; sec = ret[5];
-
- if (error != 0){
- printk(KERN_WARNING "error: reading the clock returned: %s\n",
- ppc_rtas_process_error(error));
- n = sprintf (buf, "0");
- } else {
- n = sprintf (buf, "%lu\n", mktime(year, mon, day, hour, min, sec));
- }
- kfree(ret);
-
- if (*ppos >= strlen(buf))
- return 0;
- if (n > strlen(buf) - *ppos)
- n = strlen(buf) - *ppos;
- if (n > count)
- n = count;
- *ppos += n;
- return n;
-}
-
-/* ****************************************************************** */
-/* SENSOR STUFF */
-/* ****************************************************************** */
-static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
- int count, int *eof, void *data)
-{
- int i,j,n;
- unsigned long ret;
- int state, error;
- char buffer[MAX_LINELENGTH*MAX_SENSORS]; /* May not be enough */
-
- if (count < 0)
- return -EINVAL;
-
- n = sprintf ( buffer , "RTAS (RunTime Abstraction Services) Sensor Information\n");
- n += sprintf ( buffer+n, "Sensor\t\tValue\t\tCondition\tLocation\n");
- n += sprintf ( buffer+n, "********************************************************\n");
-
- if (ppc_rtas_find_all_sensors() != 0) {
- n += sprintf ( buffer+n, "\nNo sensors are available\n");
- goto return_string;
- }
-
- for (i=0; i<sensors.quant; i++) {
- j = sensors.sensor[i].quant;
- /* A sensor may have multiple instances */
- while (j >= 0) {
- error = call_rtas("get-sensor-state", 2, 2, &ret,
- sensors.sensor[i].token, sensors.sensor[i].quant-j);
- state = (int) ret;
- n += ppc_rtas_process_sensor(sensors.sensor[i], state, error, buffer+n );
- n += sprintf (buffer+n, "\n");
- j--;
- } /* while */
- } /* for */
-
-return_string:
- if (off >= strlen(buffer)) {
- *eof = 1;
- return 0;
- }
- if (n > strlen(buffer) - off)
- n = strlen(buffer) - off;
- if (n > count)
- n = count;
- else
- *eof = 1;
- memcpy(buf, buffer + off, n);
- *start = buf;
- return n;
-}
-
-/* ****************************************************************** */
-
-int ppc_rtas_find_all_sensors (void)
-{
- unsigned long *utmp;
- int len, i, j;
-
- utmp = (unsigned long *) get_property(rtas, "rtas-sensors", &len);
- if (utmp == NULL) {
- printk (KERN_ERR "error: could not get rtas-sensors\n");
- return 1;
- }
-
- sensors.quant = len / 8; /* int + int */
-
- for (i=0, j=0; j<sensors.quant; i+=2, j++) {
- sensors.sensor[j].token = utmp[i];
- sensors.sensor[j].quant = utmp[i+1];
- }
- return 0;
-}
-
-/* ****************************************************************** */
-/*
- * Builds a string of what rtas returned
- */
-char * ppc_rtas_process_error(int error)
-{
- switch (error) {
- case SENSOR_CRITICAL_HIGH:
- return "(critical high)";
- case SENSOR_WARNING_HIGH:
- return "(warning high)";
- case SENSOR_NORMAL:
- return "(normal)";
- case SENSOR_WARNING_LOW:
- return "(warning low)";
- case SENSOR_CRITICAL_LOW:
- return "(critical low)";
- case SENSOR_SUCCESS:
- return "(read ok)";
- case SENSOR_HW_ERROR:
- return "(hardware error)";
- case SENSOR_BUSY:
- return "(busy)";
- case SENSOR_NOT_EXIST:
- return "(non existant)";
- case SENSOR_DR_ENTITY:
- return "(dr entity removed)";
- default:
- return "(UNKNOWN)";
- }
-}
-
-/* ****************************************************************** */
-/*
- * Builds a string out of what the sensor said
- */
-
-int ppc_rtas_process_sensor(struct individual_sensor s, int state,
- int error, char * buf)
-{
- /* Defined return vales */
- const char * key_switch[] = { "Off\t", "Normal\t", "Secure\t", "Mainenance" };
- const char * enclosure_switch[] = { "Closed", "Open" };
- const char * lid_status[] = { " ", "Open", "Closed" };
- const char * power_source[] = { "AC\t", "Battery", "AC & Battery" };
- const char * battery_remaining[] = { "Very Low", "Low", "Mid", "High" };
- const char * epow_sensor[] = {
- "EPOW Reset", "Cooling warning", "Power warning",
- "System shutdown", "System halt", "EPOW main enclosure",
- "EPOW power off" };
- const char * battery_cyclestate[] = { "None", "In progress", "Requested" };
- const char * battery_charging[] = { "Charging", "Discharching", "No current flow" };
- const char * ibm_drconnector[] = { "Empty", "Present" };
- const char * ibm_intqueue[] = { "Disabled", "Enabled" };
-
- int have_strings = 0;
- int temperature = 0;
- int unknown = 0;
- int n = 0;
-
- /* What kind of sensor do we have here? */
- switch (s.token) {
- case KEY_SWITCH:
- n += sprintf(buf+n, "Key switch:\t");
- n += sprintf(buf+n, "%s\t", key_switch[state]);
- have_strings = 1;
- break;
- case ENCLOSURE_SWITCH:
- n += sprintf(buf+n, "Enclosure switch:\t");
- n += sprintf(buf+n, "%s\t", enclosure_switch[state]);
- have_strings = 1;
- break;
- case THERMAL_SENSOR:
- n += sprintf(buf+n, "Temp. (°C/°F):\t");
- temperature = 1;
- break;
- case LID_STATUS:
- n += sprintf(buf+n, "Lid status:\t");
- n += sprintf(buf+n, "%s\t", lid_status[state]);
- have_strings = 1;
- break;
- case POWER_SOURCE:
- n += sprintf(buf+n, "Power source:\t");
- n += sprintf(buf+n, "%s\t", power_source[state]);
- have_strings = 1;
- break;
- case BATTERY_VOLTAGE:
- n += sprintf(buf+n, "Battery voltage:\t");
- break;
- case BATTERY_REMAINING:
- n += sprintf(buf+n, "Battery remaining:\t");
- n += sprintf(buf+n, "%s\t", battery_remaining[state]);
- have_strings = 1;
- break;
- case BATTERY_PERCENTAGE:
- n += sprintf(buf+n, "Battery percentage:\t");
- break;
- case EPOW_SENSOR:
- n += sprintf(buf+n, "EPOW Sensor:\t");
- n += sprintf(buf+n, "%s\t", epow_sensor[state]);
- have_strings = 1;
- break;
- case BATTERY_CYCLESTATE:
- n += sprintf(buf+n, "Battery cyclestate:\t");
- n += sprintf(buf+n, "%s\t", battery_cyclestate[state]);
- have_strings = 1;
- break;
- case BATTERY_CHARGING:
- n += sprintf(buf+n, "Battery Charging:\t");
- n += sprintf(buf+n, "%s\t", battery_charging[state]);
- have_strings = 1;
- break;
- case IBM_SURVEILLANCE:
- n += sprintf(buf+n, "Surveillance:\t");
- break;
- case IBM_FANRPM:
- n += sprintf(buf+n, "Fan (rpm):\t");
- break;
- case IBM_VOLTAGE:
- n += sprintf(buf+n, "Voltage (mv):\t");
- break;
- case IBM_DRCONNECTOR:
- n += sprintf(buf+n, "DR connector:\t");
- n += sprintf(buf+n, "%s\t", ibm_drconnector[state]);
- have_strings = 1;
- break;
- case IBM_POWERSUPPLY:
- n += sprintf(buf+n, "Powersupply:\t");
- break;
- case IBM_INTQUEUE:
- n += sprintf(buf+n, "Interrupt queue:\t");
- n += sprintf(buf+n, "%s\t", ibm_intqueue[state]);
- have_strings = 1;
- break;
- default:
- n += sprintf(buf+n, "Unkown sensor (type %d), ignoring it\n",
- s.token);
- unknown = 1;
- have_strings = 1;
- break;
- }
- if (have_strings == 0) {
- if (temperature) {
- n += sprintf(buf+n, "%4d /%4d\t", state, cel_to_fahr(state));
- } else
- n += sprintf(buf+n, "%10d\t", state);
- }
- if (unknown == 0) {
- n += sprintf ( buf+n, "%s\t", ppc_rtas_process_error(error));
- n += get_location_code(s, buf+n);
- }
- return n;
-}
-
-/* ****************************************************************** */
-
-int check_location (char *c, int idx, char * buf)
-{
- int n = 0;
-
- switch (*(c+idx)) {
- case LOC_PLANAR:
- n += sprintf ( buf, "Planar #%c", *(c+idx+1));
- break;
- case LOC_CPU:
- n += sprintf ( buf, "CPU #%c", *(c+idx+1));
- break;
- case LOC_FAN:
- n += sprintf ( buf, "Fan #%c", *(c+idx+1));
- break;
- case LOC_RACKMOUNTED:
- n += sprintf ( buf, "Rack #%c", *(c+idx+1));
- break;
- case LOC_VOLTAGE:
- n += sprintf ( buf, "Voltage #%c", *(c+idx+1));
- break;
- case LOC_LCD:
- n += sprintf ( buf, "LCD #%c", *(c+idx+1));
- break;
- case '.':
- n += sprintf ( buf, "- %c", *(c+idx+1));
- default:
- n += sprintf ( buf, "Unknown location");
- break;
- }
- return n;
-}
-
-
-/* ****************************************************************** */
-/*
- * Format:
- * ${LETTER}${NUMBER}[[-/]${LETTER}${NUMBER} [ ... ] ]
- * the '.' may be an abbrevation
- */
-int check_location_string (char *c, char *buf)
-{
- int n=0,i=0;
-
- while (c[i]) {
- if (isalpha(c[i]) || c[i] == '.') {
- n += check_location(c, i, buf+n);
- }
- else if (c[i] == '/' || c[i] == '-')
- n += sprintf(buf+n, " at ");
- i++;
- }
- return n;
-}
-
-
-/* ****************************************************************** */
-
-int get_location_code(struct individual_sensor s, char * buffer)
-{
- char rstr[512], tmp[10], tmp2[10];
- int n=0, i=0, llen, len;
- /* char *buf = kmalloc(MAX_LINELENGTH, GFP_KERNEL); */
- char *ret;
-
- static int pos = 0; /* remember position where buffer was */
-
- /* construct the sensor number like 0003 */
- /* fill with zeros */
- n = sprintf(tmp, "%d", s.token);
- len = strlen(tmp);
- while (strlen(tmp) < 4)
- n += sprintf (tmp+n, "0");
-
- /* invert the string */
- while (tmp[i]) {
- if (i<len)
- tmp2[4-len+i] = tmp[i];
- else
- tmp2[3-i] = tmp[i];
- i++;
- }
- tmp2[4] = '\0';
-
- sprintf (rstr, SENSOR_PREFIX"%s", tmp2);
-
- ret = (char *) get_property(rtas, rstr, &llen);
-
- n=0;
- if (ret[0] == '\0')
- n += sprintf ( buffer+n, "--- ");/* does not have a location */
- else {
- char t[50];
- ret += pos;
-
- n += check_location_string(ret, buffer + n);
- n += sprintf ( buffer+n, " ");
- /* see how many characters we have printed */
- sprintf ( t, "%s ", ret);
-
- pos += strlen(t);
- if (pos >= llen) pos=0;
- }
- return n;
-}
-/* ****************************************************************** */
-/* INDICATORS - Tone Frequency */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- unsigned long freq;
- char *dest;
- int error;
- freq = simple_strtoul(buf, &dest, 10);
- if (*dest != '\0' && *dest != '\n') {
- printk("ppc_rtas_tone_freq_write: Invalid tone freqency\n");
- return count;
- }
- if (freq < 0) freq = 0;
- rtas_tone_frequency = freq; /* save it for later */
- error = call_rtas("set-indicator", 3, 1, NULL,
- TONE_FREQUENCY, 0, freq);
- if (error != 0)
- printk(KERN_WARNING "error: setting tone frequency returned: %s\n",
- ppc_rtas_process_error(error));
- return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
- size_t count, loff_t *ppos)
-{
- int n;
- n = sprintf(buf, "%lu\n", rtas_tone_frequency);
-
- if (*ppos >= strlen(buf))
- return 0;
- if (n > strlen(buf) - *ppos)
- n = strlen(buf) - *ppos;
- if (n > count)
- n = count;
- *ppos += n;
- return n;
-}
-/* ****************************************************************** */
-/* INDICATORS - Tone Volume */
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
- size_t count, loff_t *ppos)
-{
- unsigned long volume;
- char *dest;
- int error;
- volume = simple_strtoul(buf, &dest, 10);
- if (*dest != '\0' && *dest != '\n') {
- printk("ppc_rtas_tone_volume_write: Invalid tone volume\n");
- return count;
- }
- if (volume < 0) volume = 0;
- if (volume > 100) volume = 100;
-
- rtas_tone_volume = volume; /* save it for later */
- error = call_rtas("set-indicator", 3, 1, NULL,
- TONE_VOLUME, 0, volume);
- if (error != 0)
- printk(KERN_WARNING "error: setting tone volume returned: %s\n",
- ppc_rtas_process_error(error));
- return count;
-}
-/* ****************************************************************** */
-static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
- size_t count, loff_t *ppos)
-{
- int n;
- n = sprintf(buf, "%lu\n", rtas_tone_volume);
-
- if (*ppos >= strlen(buf))
- return 0;
- if (n > strlen(buf) - *ppos)
- n = strlen(buf) - *ppos;
- if (n > count)
- n = count;
- *ppos += n;
- return n;
-}
+++ /dev/null
-/*
- * include/asm-ppc/platforms/prpmc750_serial.h
- *
- * Motorola PrPMC750 serial support
- *
- * Author: Matt Porter <mporter@mvista.com>
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_PRPMC750_SERIAL_H__
-#define __ASM_PRPMC750_SERIAL_H__
-
-#include <linux/config.h>
-#include <platforms/prpmc750.h>
-
-#define RS_TABLE_SIZE 4
-
-/* Rate for the 1.8432 Mhz clock for the onboard serial chip */
-#define BASE_BAUD (PRPMC750_BASE_BAUD / 16)
-
-#ifndef SERIAL_MAGIC_KEY
-#define kernel_debugger ppc_kernel_debug
-#endif
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-#define SERIAL_PORT_DFNS \
- { 0, BASE_BAUD, PRPMC750_SERIAL_0, 1, STD_COM_FLAGS, \
- iomem_base: (unsigned char *)PRPMC750_SERIAL_0, \
- iomem_reg_shift: 4, \
- io_type: SERIAL_IO_MEM } /* ttyS0 */
-
-#endif /* __ASM_PRPMC750_SERIAL_H__ */
-#endif /* __KERNEL__ */
+++ /dev/null
-/*
- * arch/ppc/platforms/prpmc800_serial.h
- *
- * Definitions for Motorola MCG PRPMC800 cPCI board support
- *
- * Author: Dale Farnsworth dale.farnsworth@mvista.com
- *
- * 2001 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __ASMPPC_PRPMC800_SERIAL_H
-#define __ASMPPC_PRPMC800_SERIAL_H
-
-#include <linux/config.h>
-#include <platforms/prpmc800.h>
-
-#ifdef CONFIG_SERIAL_MANY_PORTS
-#define RS_TABLE_SIZE 64
-#else
-#define RS_TABLE_SIZE 4
-#endif
-
-/* Rate for the 1.8432 Mhz clock for the onboard serial chip */
-#define BASE_BAUD (PRPMC800_BASE_BAUD / 16)
-
-#ifndef SERIAL_MAGIC_KEY
-#define kernel_debugger ppc_kernel_debug
-#endif
-
-#ifdef CONFIG_SERIAL_DETECT_IRQ
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ)
-#else
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
-#endif
-
-/* UARTS are at IRQ 16 */
-#define STD_SERIAL_PORT_DFNS \
- { 0, BASE_BAUD, PRPMC800_SERIAL_1, 16, STD_COM_FLAGS, /* ttyS0 */\
- iomem_base: (unsigned char *)PRPMC800_SERIAL_1, \
- iomem_reg_shift: 0, \
- io_type: SERIAL_IO_MEM },
-
-#define SERIAL_PORT_DFNS \
- STD_SERIAL_PORT_DFNS
-
-#endif /* __ASMPPC_PRPMC800_SERIAL_H */
+++ /dev/null
-/*
- * arch/ppc/platforms/rpx8260.c
- *
- * RPC EP8260 platform support
- *
- * Author: Dan Malek <dan@embeddededge.com>
- * Derived from: pq2ads_setup.c by Kumar
- *
- * Copyright 2004 Embedded Edge, LLC
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/seq_file.h>
-
-#include <asm/mpc8260.h>
-#include <asm/machdep.h>
-
-static void (*callback_setup_arch)(void);
-
-extern unsigned char __res[sizeof(bd_t)];
-
-extern void m8260_init(unsigned long r3, unsigned long r4,
- unsigned long r5, unsigned long r6, unsigned long r7);
-
-static int
-ep8260_show_cpuinfo(struct seq_file *m)
-{
- bd_t *binfo = (bd_t *)__res;
-
- seq_printf(m, "vendor\t\t: RPC\n"
- "machine\t\t: EP8260 PPC\n"
- "\n"
- "mem size\t\t: 0x%08x\n"
- "console baud\t\t: %d\n"
- "\n",
- binfo->bi_memsize,
- binfo->bi_baudrate);
- return 0;
-}
-
-static void __init
-ep8260_setup_arch(void)
-{
- printk("RPC EP8260 Port\n");
- callback_setup_arch();
-}
-
-void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- /* Generic 8260 platform initialization */
- m8260_init(r3, r4, r5, r6, r7);
-
- /* Anything special for this platform */
- ppc_md.show_cpuinfo = ep8260_show_cpuinfo;
-
- callback_setup_arch = ppc_md.setup_arch;
- ppc_md.setup_arch = ep8260_setup_arch;
-}
+++ /dev/null
-/*
- * A collection of structures, addresses, and values associated with
- * the Embedded Planet RPX6 (or RPX Super) MPC8260 board.
- * Copied from the RPX-Classic and SBS8260 stuff.
- *
- * Copyright (c) 2001 Dan Malek <dan@embeddededge.com>
- */
-#ifdef __KERNEL__
-#ifndef __ASM_PLATFORMS_RPXSUPER_H__
-#define __ASM_PLATFORMS_RPXSUPER_H__
-
-/* A Board Information structure that is given to a program when
- * prom starts it up.
- */
-typedef struct bd_info {
- unsigned int bi_memstart; /* Memory start address */
- unsigned int bi_memsize; /* Memory (end) size in bytes */
- unsigned int bi_nvsize; /* NVRAM size in bytes (can be 0) */
- unsigned int bi_intfreq; /* Internal Freq, in Hz */
- unsigned int bi_busfreq; /* Bus Freq, in MHz */
- unsigned int bi_cpmfreq; /* CPM Freq, in MHz */
- unsigned int bi_brgfreq; /* BRG Freq, in MHz */
- unsigned int bi_vco; /* VCO Out from PLL */
- unsigned int bi_baudrate; /* Default console baud rate */
- unsigned int bi_immr; /* IMMR when called from boot rom */
- unsigned char bi_enetaddr[6];
-} bd_t;
-
-extern bd_t m8xx_board_info;
-
-/* Memory map is configured by the PROM startup.
- * We just map a few things we need. The CSR is actually 4 byte-wide
- * registers that can be accessed as 8-, 16-, or 32-bit values.
- */
-#define IMAP_ADDR ((uint)0xf0000000)
-#define RPX_CSR_ADDR ((uint)0xfa000000)
-#define RPX_CSR_SIZE ((uint)(512 * 1024))
-#define RPX_NVRTC_ADDR ((uint)0xfa080000)
-#define RPX_NVRTC_SIZE ((uint)(512 * 1024))
-
-/* The RPX6 has 16, byte wide control/status registers.
- * Not all are used (yet).
- */
-extern volatile u_char *rpx6_csr_addr;
-
-/* Things of interest in the CSR.
-*/
-#define BCSR0_ID_MASK ((u_char)0xf0) /* Read only */
-#define BCSR0_SWITCH_MASK ((u_char)0x0f) /* Read only */
-#define BCSR1_XCVR_SMC1 ((u_char)0x80)
-#define BCSR1_XCVR_SMC2 ((u_char)0x40)
-#define BCSR2_FLASH_WENABLE ((u_char)0x20)
-#define BCSR2_NVRAM_ENABLE ((u_char)0x10)
-#define BCSR2_ALT_IRQ2 ((u_char)0x08)
-#define BCSR2_ALT_IRQ3 ((u_char)0x04)
-#define BCSR2_PRST ((u_char)0x02) /* Force reset */
-#define BCSR2_ENPRST ((u_char)0x01) /* Enable POR */
-#define BCSR3_MODCLK_MASK ((u_char)0xe0)
-#define BCSR3_ENCLKHDR ((u_char)0x10)
-#define BCSR3_LED5 ((u_char)0x04) /* 0 == on */
-#define BCSR3_LED6 ((u_char)0x02) /* 0 == on */
-#define BCSR3_LED7 ((u_char)0x01) /* 0 == on */
-#define BCSR4_EN_PHY ((u_char)0x80) /* Enable PHY */
-#define BCSR4_EN_MII ((u_char)0x40) /* Enable PHY */
-#define BCSR4_MII_READ ((u_char)0x04)
-#define BCSR4_MII_MDC ((u_char)0x02)
-#define BCSR4_MII_MDIO ((u_char)0x02)
-#define BCSR13_FETH_IRQMASK ((u_char)0xf0)
-#define BCSR15_FETH_IRQ ((u_char)0x20)
-
-#endif /* __ASM_PLATFORMS_RPXSUPER_H__ */
-#endif /* __KERNEL__ */
+++ /dev/null
-/*
- * arch/ppc/kernel/mv64360_pic.c
- *
- * Interrupt controller support for Marvell's MV64360.
- *
- * Author: Rabeeh Khoury <rabeeh@galileo.co.il>
- * Based on MV64360 PIC written by
- * Chris Zankel <chris@mvista.com>
- * Mark A. Greer <mgreer@mvista.com>
- *
- * Copyright 2004 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-/*
- * This file contains the specific functions to support the MV64360
- * interrupt controller.
- *
- * The MV64360 has two main interrupt registers (high and low) that
- * summarizes the interrupts generated by the units of the MV64360.
- * Each bit is assigned to an interrupt number, where the low register
- * are assigned from IRQ0 to IRQ31 and the high cause register
- * from IRQ32 to IRQ63
- * The GPP (General Purpose Pins) interrupts are assigned from IRQ64 (GPP0)
- * to IRQ95 (GPP31).
- * get_irq() returns the lowest interrupt number that is currently asserted.
- *
- * Note:
- * - This driver does not initialize the GPP when used as an interrupt
- * input.
- */
-
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/stddef.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/interrupt.h>
-
-#include <asm/io.h>
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/irq.h>
-#include <asm/ocp.h>
-#include <asm/mv64x60.h>
-
-#ifdef CONFIG_IRQ_ALL_CPUS
-#error "The mv64360 does not support yet distribution of IRQs on all CPUs"
-#endif
-/* ========================== forward declaration ========================== */
-
-static void mv64360_unmask_irq(unsigned int);
-static void mv64360_mask_irq(unsigned int);
-static irqreturn_t mv64360_cpu_error_int_handler(int, void *, struct pt_regs *);
-static irqreturn_t mv64360_sram_error_int_handler(int, void *, struct pt_regs *);
-static irqreturn_t mv64360_pci_error_int_handler(int, void *, struct pt_regs *);
-
-/* ========================== local declarations =========================== */
-
-struct hw_interrupt_type mv64360_pic = {
- .typename = " MV64360_PIC ", /* typename */
- .enable = mv64360_unmask_irq, /* enable */
- .disable = mv64360_mask_irq, /* disable */
- .ack = mv64360_mask_irq, /* ack */
-};
-
-#define CPU_INTR_STR "MV64360 CPU interface error"
-#define SRAM_INTR_STR "MV64360 internal sram error"
-#define PCI0_INTR_STR "MV64360 PCI 0 error"
-#define PCI1_INTR_STR "MV64360 PCI 1 error"
-
-static mv64x60_handle_t base_bh;
-
-u32 mv64360_irq_base = 0; /* MV64360 handles the next 96 IRQs from here */
-
-/* mv64360_init_irq()
- *
- * This function initializes the interrupt controller. It assigns
- * all interrupts from IRQ0 to IRQ95 to the mv64360 interrupt controller.
- *
- * Input Variable(s):
- * None.
- *
- * Outpu. Variable(s):
- * None.
- *
- * Returns:
- * void
- *
- * Note:
- * We register all GPP inputs as interrupt source, but disable them.
- */
-
-__init void
-mv64360_init_irq(void)
-{
- struct ocp_def *def;
- int i;
-
- if (ppc_md.progress)
- ppc_md.progress("mv64360_init_irq: enter", 0x0);
-
- if ( ppc_md.progress ) ppc_md.progress("mv64360_init_irq: enter", 0x0);
-
- if ((def = ocp_get_one_device(OCP_VENDOR_MARVELL, OCP_FUNC_HB,
- OCP_ANY_INDEX)) == NULL) {
- /* XXXX SCREAM */
- return;
- }
- base_bh.v_base = (unsigned long)ioremap(def->paddr, 0x1000);
-
- ppc_cached_irq_mask[0] = 0;
- ppc_cached_irq_mask[1] = 0x0f000000; /* Enable GPP intrs */
- ppc_cached_irq_mask[2] = 0;
-
- /* disable all interrupts and clear current interrupts */
- mv64x60_write(&base_bh, MV64x60_GPP_INTR_CAUSE, 0);
- mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
- ppc_cached_irq_mask[2]);
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
- ppc_cached_irq_mask[0]);
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
- ppc_cached_irq_mask[1]);
-
- /* use the mv64360 for all (possible) interrupt sources */
- for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) {
- /* All interrupts are level interrupts */
- irq_desc[i].status |= IRQ_LEVEL;
- irq_desc[i].handler = &mv64360_pic;
- }
-
- /* Register CPU interface error interrupt handler */
- request_irq(MV64x60_IRQ_CPU_ERR, mv64360_cpu_error_int_handler,
- SA_INTERRUPT, CPU_INTR_STR, 0);
- mv64x60_write(&base_bh, MV64x60_CPU_ERR_MASK, 0x000000ff);
-
- /* Register internal SRAM error interrupt handler */
- request_irq(MV64360_IRQ_SRAM_PAR_ERR, mv64360_sram_error_int_handler,
- SA_INTERRUPT, SRAM_INTR_STR, 0);
-
- /* Register PCI 0 error interrupt handler */
- request_irq(MV64360_IRQ_PCI0, mv64360_pci_error_int_handler,
- SA_INTERRUPT, PCI0_INTR_STR, (void *) 0);
- mv64x60_write(&base_bh, MV64x60_PCI0_ERR_MASK, 0x00a50c25);
-
- /* Register PCI 1 error interrupt handler */
- request_irq(MV64360_IRQ_PCI1, mv64360_pci_error_int_handler,
- SA_INTERRUPT, PCI1_INTR_STR, (void *) 1);
- mv64x60_write(&base_bh, MV64x60_PCI1_ERR_MASK, 0x00a50c25);
-
- if (ppc_md.progress)
- ppc_md.progress("mv64360_init_irq: exit", 0x0);
-}
-
-
-/* mv64360_get_irq()
- *
- * This function returns the lowest interrupt number of all interrupts that
- * are currently asserted.
- *
- * Input Variable(s):
- * struct pt_regs* not used
- *
- * Output Variable(s):
- * None.
- *
- * Returns:
- * int <interrupt number> or -2 (bogus interrupt)
- *
- */
-int
-mv64360_get_irq(struct pt_regs *regs)
-{
- int irq;
- int irq_gpp;
-
-#ifdef CONFIG_SMP
-#define BIT28 (1<<28)
- /*
- * Second CPU gets only doorbell (message) interrupts.
- * The doorbell interrupt is BIT28 in the main interrupt low cause reg.
- */
- int cpu_nr = smp_processor_id();
- if (cpu_nr == 1) {
- irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_LO);
- if (!(irq & BIT28))
- return -1;
- return 28;
- }
-#endif
-
- irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_LO);
- irq = __ilog2((irq & 0x3dfffffe) & ppc_cached_irq_mask[0]);
- if (irq == -1) {
- irq = mv64x60_read(&base_bh, MV64360_IC_MAIN_CAUSE_HI);
- irq = __ilog2((irq & 0x1f0003f7) & ppc_cached_irq_mask[1]);
- if (irq == -1) {
- irq = -2; /* bogus interrupt, should never happen */
- } else {
- if ((irq >= 24) && (irq < 28)) {
- irq_gpp =
- mv64x60_read(&base_bh,
- MV64x60_GPP_INTR_CAUSE);
- irq_gpp =
- __ilog2(irq_gpp &
- ppc_cached_irq_mask[2]);
-
- if (irq_gpp == -1) {
- irq = -2;
- } else {
- irq = irq_gpp + 64;
- mv64x60_write(&base_bh,
- MV64x60_GPP_INTR_CAUSE,
- ~(1 << (irq - 64)));
- }
- } else {
- irq += 32;
- }
- }
- }
-
- if (irq < 0) {
- return (irq);
- } else {
- return (mv64360_irq_base + irq);
- }
-}
-
-/* mv64360_unmask_irq()
- *
- * This function enables an interrupt.
- *
- * Input Variable(s):
- * unsigned int interrupt number (IRQ0...IRQ95).
- *
- * Output Variable(s):
- * None.
- *
- * Returns:
- * void
- */
-
-static void
-mv64360_unmask_irq(unsigned int irq)
-{
-#ifdef CONFIG_SMP
- /* second CPU gets only doorbell interrupts */
- if ((irq - mv64360_irq_base) == 28) {
- mv64x60_set_bits(&base_bh, MV64360_IC_CPU1_INTR_MASK_LO, BIT28);
- return;
- }
-#endif
- irq -= mv64360_irq_base;
- if (irq > 31) {
- if (irq > 63) {
- /* unmask GPP irq */
- mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
- ppc_cached_irq_mask[2] |= (1 << (irq - 64)));
- } else {
- /* mask high interrupt register */
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
- ppc_cached_irq_mask[1] |= (1 << (irq - 32)));
- }
- } else {
- /* mask low interrupt register */
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
- ppc_cached_irq_mask[0] |= (1 << irq));
- }
-}
-
-
-/* mv64360_mask_irq()
- *
- * This function disables the requested interrupt.
- *
- * Input Variable(s):
- * unsigned int interrupt number (IRQ0...IRQ95).
- *
- * Output Variable(s):
- * None.
- *
- * Returns:
- * void
- */
-
-static void
-mv64360_mask_irq(unsigned int irq)
-{
-#ifdef CONFIG_SMP
- if ((irq - mv64360_irq_base) == 28) {
- mv64x60_clr_bits(&base_bh, MV64360_IC_CPU1_INTR_MASK_LO, BIT28);
- return;
- }
-#endif
- irq -= mv64360_irq_base;
- if (irq > 31) {
- if (irq > 63) {
- /* mask GPP irq */
- mv64x60_write(&base_bh, MV64x60_GPP_INTR_MASK,
- ppc_cached_irq_mask[2] &= ~(1 << (irq - 64)));
- } else {
- /* mask high interrupt register */
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_HI,
- ppc_cached_irq_mask[1] &= ~(1 << (irq - 32)));
- }
- } else {
- /* mask low interrupt register */
- mv64x60_write(&base_bh, MV64360_IC_CPU0_INTR_MASK_LO,
- ppc_cached_irq_mask[0] &= ~(1 << irq));
- }
-
-}
-
-static irqreturn_t
-mv64360_cpu_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- u32 val;
- val = mv64x60_read(&base_bh, MV64x60_CPU_ERR_CAUSE);
- printk(KERN_ERR
- "mv64360_cpu_error_int_handler: Error on CPU interface - Cause regiser 0x%08x\n",
- val);
- printk(KERN_ERR "\tCPU error register dump:\n");
- printk(KERN_ERR "\tAddress low 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_CPU_ERR_ADDR_LO));
- printk(KERN_ERR "\tAddress high 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_CPU_ERR_ADDR_HI));
- printk(KERN_ERR "\tData low 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_CPU_ERR_DATA_LO));
- printk(KERN_ERR "\tData high 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_CPU_ERR_DATA_HI));
- printk(KERN_ERR "\tParity 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_CPU_ERR_PARITY));
- mv64x60_write(&base_bh, MV64x60_CPU_ERR_CAUSE, 0);
- return IRQ_HANDLED;
-}
-
-static irqreturn_t
-mv64360_sram_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- printk(KERN_ERR
- "mv64360_sram_error_int_handler: Error in internal SRAM - Cause register 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_CAUSE));
- printk(KERN_ERR "\tSRAM error register dump:\n");
- printk(KERN_ERR "\tAddress Low 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_ADDR_LO));
- printk(KERN_ERR "\tAddress High 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_ADDR_HI));
- printk(KERN_ERR "\tData Low 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_DATA_LO));
- printk(KERN_ERR "\tData High 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_DATA_HI));
- printk(KERN_ERR "\tParity 0x%08x\n",
- mv64x60_read(&base_bh, MV64360_SRAM_ERR_PARITY));
- mv64x60_write(&base_bh, MV64360_SRAM_ERR_CAUSE, 0);
- return IRQ_HANDLED;
-}
-
-static irqreturn_t
-mv64360_pci_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
-{
- u32 val;
- unsigned int pci_bus = (unsigned int) dev_id;
- if (pci_bus == 0) { /* Error on PCI 0 */
- val = mv64x60_read(&base_bh, MV64x60_PCI0_ERR_CAUSE);
- printk(KERN_ERR
- "mv64360_pci_error_int_handler: Error in PCI %d Interface\n",
- pci_bus);
- printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
- printk(KERN_ERR "\tCause register 0x%08x\n", val);
- printk(KERN_ERR "\tAddress Low 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI0_ERR_ADDR_LO));
- printk(KERN_ERR "\tAddress High 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI0_ERR_ADDR_HI));
- printk(KERN_ERR "\tAttribute 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI0_ERR_DATA_LO));
- printk(KERN_ERR "\tCommand 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI0_ERR_CMD));
- mv64x60_write(&base_bh, MV64x60_PCI0_ERR_CAUSE, ~val);
- }
- if (pci_bus == 1) { /* Error on PCI 1 */
- val = mv64x60_read(&base_bh, MV64x60_PCI1_ERR_CAUSE);
- printk(KERN_ERR
- "mv64360_pci_error_int_handler: Error in PCI %d Interface\n",
- pci_bus);
- printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
- printk(KERN_ERR "\tCause register 0x%08x\n", val);
- printk(KERN_ERR "\tAddress Low 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI1_ERR_ADDR_LO));
- printk(KERN_ERR "\tAddress High 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI1_ERR_ADDR_HI));
- printk(KERN_ERR "\tAttribute 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI1_ERR_DATA_LO));
- printk(KERN_ERR "\tCommand 0x%08x\n",
- mv64x60_read(&base_bh, MV64x60_PCI1_ERR_CMD));
- mv64x60_write(&base_bh, MV64x60_PCI1_ERR_CAUSE, ~val);
- }
- return IRQ_HANDLED;
-}
+++ /dev/null
-/*
- * arch/ppc/syslib/mv64x60.c
- *
- * Common routines for the Marvell/Galileo Discovery line of host bridges
- * (e.g, gt64260 and mv64360).
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- * Rabeeh Khoury <rabeeh@galileo.co.il>
- *
- * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mv64x60.h>
-#include <asm/delay.h>
-#include <asm/ocp.h>
-
-
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif /* DEBUG */
-
-
-static u32 mv64x60_mask(u32 val, u32 num_bits);
-static u32 mv64x60_shift_left(u32 val, u32 num_bits);
-static u32 mv64x60_shift_right(u32 val, u32 num_bits);
-static void mv64x60_early_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static int mv64x60_get_type(mv64x60_handle_t *bh);
-static int mv64x60_setup_for_chip(mv64x60_handle_t *bh);
-static void mv64x60_get_mem_windows(mv64x60_handle_t *bh,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static u32 mv64x60_calc_mem_size(mv64x60_handle_t *bh,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_config_cpu2mem_windows(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si, u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_config_cpu2pci_windows(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static void mv64x60_set_cpu2pci_window(mv64x60_handle_t *bh,
- mv64x60_pci_info_t *pi, u32 *win_tab, u32 *remap_tab);
-static void mv64x60_config_pci2mem_windows(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si, u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
-static void mv64x60_alloc_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static void mv64x60_init_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-static void mv64x60_init_resources(struct pci_controller *hose,
- mv64x60_pci_info_t *pi, u32 io_base);
-static void mv64x60_set_pci_params(struct pci_controller *hose,
- mv64x60_pci_info_t *pi);
-static void mv64x60_enumerate_buses(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static int mv64x60_pci_exclude_device(u8 bus, u8 devfn);
-static void mv64x60_fixup_ocp(struct ocp_device *, void *arg);
-
-static u32 gt64260_translate_size(u32 base, u32 size, u32 num_bits);
-static u32 gt64260_untranslate_size(u32 base, u32 size, u32 num_bits);
-static void gt64260_set_pci2mem_window(struct pci_controller *hose,
- u32 window, u32 base);
-static u32 gt64260_is_enabled_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_enable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_enable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void gt64260_disable_all_windows(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static void gt64260a_chip_specific_init(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static void gt64260b_chip_specific_init(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-
-static u32 mv64360_translate_size(u32 base_addr, u32 size, u32 num_bits);
-static u32 mv64360_untranslate_size(u32 base_addr, u32 size, u32 num_bits);
-static void mv64360_set_pci2mem_window(struct pci_controller *hose,
- u32 window, u32 base);
-static u32 mv64360_is_enabled_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_enable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_window_32bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_enable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_window_64bit(mv64x60_handle_t *bh, u32 window);
-static void mv64360_disable_all_windows(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static void mv64360_chip_specific_init(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-static void mv64460_chip_specific_init(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-
-
-u8 mv64x60_pci_exclude_bridge = TRUE;
-
-spinlock_t mv64x60_lock = SPIN_LOCK_UNLOCKED;
-spinlock_t mv64x60_rmw_lock = SPIN_LOCK_UNLOCKED;
-
-static mv64x60_32bit_window_t gt64260_32bit_windows[] __initdata = {
- /* CPU->MEM Windows */
- [MV64x60_CPU2MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2MEM_0_BASE,
- .size_reg = MV64x60_CPU2MEM_0_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2MEM_1_BASE,
- .size_reg = MV64x60_CPU2MEM_1_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2MEM_2_BASE,
- .size_reg = MV64x60_CPU2MEM_2_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2MEM_3_BASE,
- .size_reg = MV64x60_CPU2MEM_3_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->Device Windows */
- [MV64x60_CPU2DEV_0_WIN] = {
- .base_reg = MV64x60_CPU2DEV_0_BASE,
- .size_reg = MV64x60_CPU2DEV_0_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2DEV_1_WIN] = {
- .base_reg = MV64x60_CPU2DEV_1_BASE,
- .size_reg = MV64x60_CPU2DEV_1_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2DEV_2_WIN] = {
- .base_reg = MV64x60_CPU2DEV_2_BASE,
- .size_reg = MV64x60_CPU2DEV_2_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2DEV_3_WIN] = {
- .base_reg = MV64x60_CPU2DEV_3_BASE,
- .size_reg = MV64x60_CPU2DEV_3_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->Boot Window */
- [MV64x60_CPU2BOOT_WIN] = {
- .base_reg = MV64x60_CPU2BOOT_0_BASE,
- .size_reg = MV64x60_CPU2BOOT_0_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 0 Windows */
- [MV64x60_CPU2PCI0_IO_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_IO_BASE,
- .size_reg = MV64x60_CPU2PCI0_IO_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_0_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_0_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_1_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_1_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_2_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_2_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_3_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_3_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 1 Windows */
- [MV64x60_CPU2PCI1_IO_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_IO_BASE,
- .size_reg = MV64x60_CPU2PCI1_IO_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_0_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_0_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_1_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_1_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_2_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_2_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_3_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_3_SIZE,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->SRAM Window (64260 has no integrated SRAM) */
- /* CPU->PCI 0 Remap I/O Window */
- [MV64x60_CPU2PCI0_IO_REMAP_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_IO_REMAP,
- .size_reg = 0,
- .base_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 1 Remap I/O Window */
- [MV64x60_CPU2PCI1_IO_REMAP_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_IO_REMAP,
- .size_reg = 0,
- .base_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU Memory Protection Windows */
- [MV64x60_CPU_PROT_0_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_0,
- .size_reg = MV64x60_CPU_PROT_SIZE_0,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_PROT_1_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_1,
- .size_reg = MV64x60_CPU_PROT_SIZE_1,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_PROT_2_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_2,
- .size_reg = MV64x60_CPU_PROT_SIZE_2,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_PROT_3_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_3,
- .size_reg = MV64x60_CPU_PROT_SIZE_3,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU Snoop Windows */
- [MV64x60_CPU_SNOOP_0_WIN] = {
- .base_reg = GT64260_CPU_SNOOP_BASE_0,
- .size_reg = GT64260_CPU_SNOOP_SIZE_0,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_SNOOP_1_WIN] = {
- .base_reg = GT64260_CPU_SNOOP_BASE_1,
- .size_reg = GT64260_CPU_SNOOP_SIZE_1,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_SNOOP_2_WIN] = {
- .base_reg = GT64260_CPU_SNOOP_BASE_2,
- .size_reg = GT64260_CPU_SNOOP_SIZE_2,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU_SNOOP_3_WIN] = {
- .base_reg = GT64260_CPU_SNOOP_BASE_3,
- .size_reg = GT64260_CPU_SNOOP_SIZE_3,
- .base_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 0->System Memory Remap Windows */
- [MV64x60_PCI02MEM_REMAP_0_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_0_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_1_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_2_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_3_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- /* PCI 1->System Memory Remap Windows */
- [MV64x60_PCI12MEM_REMAP_0_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_0_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_1_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_2_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_3_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 20,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
-};
-
-static mv64x60_64bit_window_t gt64260_64bit_windows[] __initdata = {
- /* CPU->PCI 0 MEM Remap Windows */
- [MV64x60_CPU2PCI0_MEM_0_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_0_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_0_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_1_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_1_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_1_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_2_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_2_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_2_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_3_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_3_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_3_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 1 MEM Remap Windows */
- [MV64x60_CPU2PCI1_MEM_0_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_0_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_0_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_1_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_1_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_1_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_2_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_2_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_2_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_3_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_3_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_3_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 12,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 0->MEM Access Control Windows */
- [MV64x60_PCI02MEM_ACC_CNTL_0_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_0_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_0_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_0_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_1_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_1_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_1_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_1_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_2_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_2_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_2_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_2_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_3_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_3_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_3_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_3_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 1->MEM Access Control Windows */
- [MV64x60_PCI12MEM_ACC_CNTL_0_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_0_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_0_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_0_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_1_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_1_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_1_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_1_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_2_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_2_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_2_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_2_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_3_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_3_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_3_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_3_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 0->MEM Snoop Windows */
- [MV64x60_PCI02MEM_SNOOP_0_WIN] = {
- .base_hi_reg = GT64260_PCI0_SNOOP_0_BASE_HI,
- .base_lo_reg = GT64260_PCI0_SNOOP_0_BASE_LO,
- .size_reg = GT64260_PCI0_SNOOP_0_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_SNOOP_1_WIN] = {
- .base_hi_reg = GT64260_PCI0_SNOOP_1_BASE_HI,
- .base_lo_reg = GT64260_PCI0_SNOOP_1_BASE_LO,
- .size_reg = GT64260_PCI0_SNOOP_1_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_SNOOP_2_WIN] = {
- .base_hi_reg = GT64260_PCI0_SNOOP_2_BASE_HI,
- .base_lo_reg = GT64260_PCI0_SNOOP_2_BASE_LO,
- .size_reg = GT64260_PCI0_SNOOP_2_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI02MEM_SNOOP_3_WIN] = {
- .base_hi_reg = GT64260_PCI0_SNOOP_3_BASE_HI,
- .base_lo_reg = GT64260_PCI0_SNOOP_3_BASE_LO,
- .size_reg = GT64260_PCI0_SNOOP_3_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 1->MEM Snoop Windows */
- [MV64x60_PCI12MEM_SNOOP_0_WIN] = {
- .base_hi_reg = GT64260_PCI1_SNOOP_0_BASE_HI,
- .base_lo_reg = GT64260_PCI1_SNOOP_0_BASE_LO,
- .size_reg = GT64260_PCI1_SNOOP_0_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_SNOOP_1_WIN] = {
- .base_hi_reg = GT64260_PCI1_SNOOP_1_BASE_HI,
- .base_lo_reg = GT64260_PCI1_SNOOP_1_BASE_LO,
- .size_reg = GT64260_PCI1_SNOOP_1_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_SNOOP_2_WIN] = {
- .base_hi_reg = GT64260_PCI1_SNOOP_2_BASE_HI,
- .base_lo_reg = GT64260_PCI1_SNOOP_2_BASE_LO,
- .size_reg = GT64260_PCI1_SNOOP_2_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_PCI12MEM_SNOOP_3_WIN] = {
- .base_hi_reg = GT64260_PCI1_SNOOP_3_BASE_HI,
- .base_lo_reg = GT64260_PCI1_SNOOP_3_BASE_LO,
- .size_reg = GT64260_PCI1_SNOOP_3_SIZE,
- .base_lo_bits = 12,
- .size_bits = 12,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
-};
-
-static mv64x60_chip_info_t gt64260a_ci __initdata = {
- .translate_size = gt64260_translate_size,
- .untranslate_size = gt64260_untranslate_size,
- .set_pci2mem_window = gt64260_set_pci2mem_window,
- .is_enabled_32bit = gt64260_is_enabled_32bit,
- .enable_window_32bit = gt64260_enable_window_32bit,
- .disable_window_32bit = gt64260_disable_window_32bit,
- .enable_window_64bit = gt64260_enable_window_64bit,
- .disable_window_64bit = gt64260_disable_window_64bit,
- .disable_all_windows = gt64260_disable_all_windows,
- .chip_specific_init = gt64260a_chip_specific_init,
- .window_tab_32bit = gt64260_32bit_windows,
- .window_tab_64bit = gt64260_64bit_windows,
-};
-
-static mv64x60_chip_info_t gt64260b_ci __initdata = {
- .translate_size = gt64260_translate_size,
- .untranslate_size = gt64260_untranslate_size,
- .set_pci2mem_window = gt64260_set_pci2mem_window,
- .is_enabled_32bit = gt64260_is_enabled_32bit,
- .enable_window_32bit = gt64260_enable_window_32bit,
- .disable_window_32bit = gt64260_disable_window_32bit,
- .enable_window_64bit = gt64260_enable_window_64bit,
- .disable_window_64bit = gt64260_disable_window_64bit,
- .disable_all_windows = gt64260_disable_all_windows,
- .chip_specific_init = gt64260b_chip_specific_init,
- .window_tab_32bit = gt64260_32bit_windows,
- .window_tab_64bit = gt64260_64bit_windows,
-};
-
-
-static mv64x60_32bit_window_t mv64360_32bit_windows[] __initdata = {
- /* CPU->MEM Windows */
- [MV64x60_CPU2MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2MEM_0_BASE,
- .size_reg = MV64x60_CPU2MEM_0_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2MEM_1_BASE,
- .size_reg = MV64x60_CPU2MEM_1_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 1 },
- [MV64x60_CPU2MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2MEM_2_BASE,
- .size_reg = MV64x60_CPU2MEM_2_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 2 },
- [MV64x60_CPU2MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2MEM_3_BASE,
- .size_reg = MV64x60_CPU2MEM_3_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 3 },
- /* CPU->Device Windows */
- [MV64x60_CPU2DEV_0_WIN] = {
- .base_reg = MV64x60_CPU2DEV_0_BASE,
- .size_reg = MV64x60_CPU2DEV_0_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 4 },
- [MV64x60_CPU2DEV_1_WIN] = {
- .base_reg = MV64x60_CPU2DEV_1_BASE,
- .size_reg = MV64x60_CPU2DEV_1_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 5 },
- [MV64x60_CPU2DEV_2_WIN] = {
- .base_reg = MV64x60_CPU2DEV_2_BASE,
- .size_reg = MV64x60_CPU2DEV_2_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 6 },
- [MV64x60_CPU2DEV_3_WIN] = {
- .base_reg = MV64x60_CPU2DEV_3_BASE,
- .size_reg = MV64x60_CPU2DEV_3_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 7 },
- /* CPU->Boot Window */
- [MV64x60_CPU2BOOT_WIN] = {
- .base_reg = MV64x60_CPU2BOOT_0_BASE,
- .size_reg = MV64x60_CPU2BOOT_0_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 8 },
- /* CPU->PCI 0 Windows */
- [MV64x60_CPU2PCI0_IO_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_IO_BASE,
- .size_reg = MV64x60_CPU2PCI0_IO_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 9 },
- [MV64x60_CPU2PCI0_MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_0_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_0_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 10 },
- [MV64x60_CPU2PCI0_MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_1_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_1_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 11 },
- [MV64x60_CPU2PCI0_MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_2_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_2_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 12 },
- [MV64x60_CPU2PCI0_MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_MEM_3_BASE,
- .size_reg = MV64x60_CPU2PCI0_MEM_3_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 13 },
- /* CPU->PCI 1 Windows */
- [MV64x60_CPU2PCI1_IO_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_IO_BASE,
- .size_reg = MV64x60_CPU2PCI1_IO_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 14 },
- [MV64x60_CPU2PCI1_MEM_0_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_0_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_0_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 15 },
- [MV64x60_CPU2PCI1_MEM_1_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_1_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_1_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 16 },
- [MV64x60_CPU2PCI1_MEM_2_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_2_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_2_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 17 },
- [MV64x60_CPU2PCI1_MEM_3_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_MEM_3_BASE,
- .size_reg = MV64x60_CPU2PCI1_MEM_3_SIZE,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 18 },
- /* CPU->SRAM Window */
- [MV64x60_CPU2SRAM_WIN] = {
- .base_reg = MV64360_CPU2SRAM_BASE,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 19 },
- /* CPU->PCI 0 Remap I/O Window */
- [MV64x60_CPU2PCI0_IO_REMAP_WIN] = {
- .base_reg = MV64x60_CPU2PCI0_IO_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 1 Remap I/O Window */
- [MV64x60_CPU2PCI1_IO_REMAP_WIN] = {
- .base_reg = MV64x60_CPU2PCI1_IO_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU Memory Protection Windows */
- [MV64x60_CPU_PROT_0_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_0,
- .size_reg = MV64x60_CPU_PROT_SIZE_0,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0x80000000 | 31 },
- [MV64x60_CPU_PROT_1_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_1,
- .size_reg = MV64x60_CPU_PROT_SIZE_1,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0x80000000 | 31 },
- [MV64x60_CPU_PROT_2_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_2,
- .size_reg = MV64x60_CPU_PROT_SIZE_2,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0x80000000 | 31 },
- [MV64x60_CPU_PROT_3_WIN] = {
- .base_reg = MV64x60_CPU_PROT_BASE_3,
- .size_reg = MV64x60_CPU_PROT_SIZE_3,
- .base_bits = 16,
- .size_bits = 16,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0x80000000 | 31 },
- /* CPU Snoop Windows -- don't exist on 64360 */
- /* PCI 0->System Memory Remap Windows */
- [MV64x60_PCI02MEM_REMAP_0_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_0_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_1_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_2_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI02MEM_REMAP_3_WIN] = {
- .base_reg = MV64x60_PCI0_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- /* PCI 1->System Memory Remap Windows */
- [MV64x60_PCI12MEM_REMAP_0_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_0_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_1_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_2_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
- [MV64x60_PCI12MEM_REMAP_3_WIN] = {
- .base_reg = MV64x60_PCI1_SLAVE_MEM_1_REMAP,
- .size_reg = 0,
- .base_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0 },
-};
-
-static mv64x60_64bit_window_t mv64360_64bit_windows[MV64x60_64BIT_WIN_COUNT]
- __initdata = {
- /* CPU->PCI 0 MEM Remap Windows */
- [MV64x60_CPU2PCI0_MEM_0_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_0_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_0_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_1_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_1_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_1_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_2_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_2_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_2_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI0_MEM_3_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI0_MEM_3_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI0_MEM_3_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* CPU->PCI 1 MEM Remap Windows */
- [MV64x60_CPU2PCI1_MEM_0_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_0_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_0_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_1_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_1_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_1_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_2_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_2_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_2_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- [MV64x60_CPU2PCI1_MEM_3_REMAP_WIN] = {
- .base_hi_reg = MV64x60_CPU2PCI1_MEM_3_REMAP_HI,
- .base_lo_reg = MV64x60_CPU2PCI1_MEM_3_REMAP_LO,
- .size_reg = 0,
- .base_lo_bits = 16,
- .size_bits = 0,
- .get_from_field = mv64x60_shift_left,
- .map_to_field = mv64x60_shift_right,
- .extra = 0 },
- /* PCI 0->MEM Access Control Windows */
- [MV64x60_PCI02MEM_ACC_CNTL_0_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_0_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_0_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_0_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_1_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_1_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_1_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_1_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_2_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_2_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_2_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_2_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI02MEM_ACC_CNTL_3_WIN] = {
- .base_hi_reg = MV64x60_PCI0_ACC_CNTL_3_BASE_HI,
- .base_lo_reg = MV64x60_PCI0_ACC_CNTL_3_BASE_LO,
- .size_reg = MV64x60_PCI0_ACC_CNTL_3_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- /* PCI 1->MEM Access Control Windows */
- [MV64x60_PCI12MEM_ACC_CNTL_0_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_0_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_0_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_0_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_1_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_1_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_1_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_1_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_2_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_2_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_2_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_2_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- [MV64x60_PCI12MEM_ACC_CNTL_3_WIN] = {
- .base_hi_reg = MV64x60_PCI1_ACC_CNTL_3_BASE_HI,
- .base_lo_reg = MV64x60_PCI1_ACC_CNTL_3_BASE_LO,
- .size_reg = MV64x60_PCI1_ACC_CNTL_3_SIZE,
- .base_lo_bits = 20,
- .size_bits = 20,
- .get_from_field = mv64x60_mask,
- .map_to_field = mv64x60_mask,
- .extra = 0x80000000 | 0 },
- /* PCI 0->MEM Snoop Windows -- don't exist on 64360 */
- /* PCI 1->MEM Snoop Windows -- don't exist on 64360 */
-};
-
-static mv64x60_chip_info_t mv64360_ci __initdata = {
- .translate_size = mv64360_translate_size,
- .untranslate_size = mv64360_untranslate_size,
- .set_pci2mem_window = mv64360_set_pci2mem_window,
- .is_enabled_32bit = mv64360_is_enabled_32bit,
- .enable_window_32bit = mv64360_enable_window_32bit,
- .disable_window_32bit = mv64360_disable_window_32bit,
- .enable_window_64bit = mv64360_enable_window_64bit,
- .disable_window_64bit = mv64360_disable_window_64bit,
- .disable_all_windows = mv64360_disable_all_windows,
- .chip_specific_init = mv64360_chip_specific_init,
- .window_tab_32bit = mv64360_32bit_windows,
- .window_tab_64bit = mv64360_64bit_windows,
-};
-
-static mv64x60_chip_info_t mv64460_ci __initdata = {
- .translate_size = mv64360_translate_size,
- .untranslate_size = mv64360_untranslate_size,
- .set_pci2mem_window = mv64360_set_pci2mem_window,
- .is_enabled_32bit = mv64360_is_enabled_32bit,
- .enable_window_32bit = mv64360_enable_window_32bit,
- .disable_window_32bit = mv64360_disable_window_32bit,
- .enable_window_64bit = mv64360_enable_window_64bit,
- .disable_window_64bit = mv64360_disable_window_64bit,
- .disable_all_windows = mv64360_disable_all_windows,
- .chip_specific_init = mv64460_chip_specific_init,
- .window_tab_32bit = mv64360_32bit_windows,
- .window_tab_64bit = mv64360_64bit_windows,
-};
-
-
-/*
- *****************************************************************************
- *
- * Bridge Initialization Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_init()
- *
- * Initialze the bridge based on setting passed in via 'si'. The bridge
- * handle, 'bh', will be set so that it can be used to make subsequent
- * calls to routines in this file.
- */
-int __init
-mv64x60_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2];
- int rc = 0;
-
- if (ppc_md.progress)
- ppc_md.progress("mv64x60_init: Enter", 0x0);
-
- mv64x60_early_init(bh, si);
- mv64x60_alloc_hoses(bh, si); /* Allocate pci hose structures */
- if (mv64x60_get_type(bh))
- return -1;
-
- if (mv64x60_setup_for_chip(bh) != 0) {
- iounmap((void *)bh->v_base);
-
- if (ppc_md.progress)
- ppc_md.progress("mv64x60_init: Exit--error", 0x0);
- return -1;
- }
-
- bh->ci->disable_all_windows(bh, si); /* Disable windows except mem ctlr */
- mv64x60_config_cpu2pci_windows(bh, si); /* Init CPU->PCI windows */
- mv64x60_get_mem_windows(bh, mem_windows); /* Read mem ctlr regs */
- mv64x60_config_cpu2mem_windows(bh, si, mem_windows); /* CPU->MEM setup*/
- mv64x60_config_pci2mem_windows(bh, si, mem_windows); /* PCI->Sys MEM */
- mv64x60_init_hoses(bh, si); /* Init hose structs & PCI params */
- bh->ci->chip_specific_init(bh, si);
- mv64x60_enumerate_buses(bh, si); /* Enumerate PCI buses */
- ocp_for_each_device(mv64x60_fixup_ocp, (void *)bh);
-
- if (ppc_md.progress)
- ppc_md.progress("mv64x60_init: Exit", 0x0);
-
- return rc;
-} /* mv64x60_init() */
-
-/*
- *****************************************************************************
- *
- * Pre-Bridge-Init Routines (Externally Visible)
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_mem_size()
- *
- * Calculate the amount of memory that the memory controller is set up for.
- * This should only be used by board-specific code if there is no other
- * way to determine the amount of memory in the system.
- */
-u32 __init
-mv64x60_get_mem_size(u32 bridge_base, u32 chip_type)
-{
- mv64x60_handle_t bh;
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2];
-
- memset(&bh, 0, sizeof(bh));
-
- bh.type = chip_type;
- bh.p_base = bridge_base;
- bh.v_base = bridge_base;
-
- (void)mv64x60_setup_for_chip(&bh);
- mv64x60_get_mem_windows(&bh, mem_windows);
- return mv64x60_calc_mem_size(&bh, mem_windows);
-}
-
-/*
- *****************************************************************************
- *
- * Window Config Routines (Externally Visible)
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_32bit_window()
- *
- * Determine the base address and size of a 32-bit window on the bridge.
- */
-void __init
-mv64x60_get_32bit_window(mv64x60_handle_t *bh, u32 window, u32 *base, u32 *size)
-{
- u32 val, base_reg, size_reg, base_bits, size_bits;
- u32 (*get_from_field)(u32 val, u32 num_bits);
-
- base_reg = bh->ci->window_tab_32bit[window].base_reg;
-
- if (base_reg != 0) {
- size_reg = bh->ci->window_tab_32bit[window].size_reg;
- base_bits = bh->ci->window_tab_32bit[window].base_bits;
- size_bits = bh->ci->window_tab_32bit[window].size_bits;
- get_from_field= bh->ci->window_tab_32bit[window].get_from_field;
-
- val = mv64x60_read(bh, base_reg);
- *base = get_from_field(val, base_bits);
-
- if (size_reg != 0) {
- val = mv64x60_read(bh, size_reg);
- val = get_from_field(val, size_bits);
- *size = bh->ci->untranslate_size(*base, val, size_bits);
- }
- else {
- *size = 0;
- }
- }
- else {
- *base = 0;
- *size = 0;
- }
-
- DBG("get 32bit window: %d, base: 0x%x, size: 0x%x\n",
- window, *base, *size);
-
- return;
-}
-
-/*
- * mv64x60_set_32bit_window()
- *
- * Set the base address and size of a 32-bit window on the bridge.
- */
-void __init
-mv64x60_set_32bit_window(mv64x60_handle_t *bh, u32 window, u32 base, u32 size,
- u32 other_bits)
-{
- u32 val, base_reg, size_reg, base_bits, size_bits;
- u32 (*map_to_field)(u32 val, u32 num_bits);
-
- DBG("set 32bit window: %d, base: 0x%x, size: 0x%x, other: 0x%x\n",
- window, base, size, other_bits);
-
- base_reg = bh->ci->window_tab_32bit[window].base_reg;
-
- if (base_reg != 0) {
- size_reg = bh->ci->window_tab_32bit[window].size_reg;
- base_bits = bh->ci->window_tab_32bit[window].base_bits;
- size_bits = bh->ci->window_tab_32bit[window].size_bits;
- map_to_field = bh->ci->window_tab_32bit[window].map_to_field;
-
- val = map_to_field(base, base_bits) | other_bits;
- mv64x60_write(bh, base_reg, val);
-
- if (size_reg != 0) {
- val = bh->ci->translate_size(base, size, size_bits);
- val = map_to_field(val, size_bits);
- mv64x60_write(bh, size_reg, val);
- }
- (void)mv64x60_read(bh, base_reg); /* Flush FIFO */
- }
-
- return;
-}
-
-/*
- * mv64x60_get_64bit_window()
- *
- * Determine the base address and size of a 64-bit window on the bridge.
- */
-void __init
-mv64x60_get_64bit_window(mv64x60_handle_t *bh, u32 window, u32 *base_hi,
- u32 *base_lo, u32 *size)
-{
- u32 val, base_lo_reg, size_reg, base_lo_bits, size_bits;
- u32 (*get_from_field)(u32 val, u32 num_bits);
-
- base_lo_reg = bh->ci->window_tab_64bit[window].base_lo_reg;
-
- if (base_lo_reg != 0) {
- size_reg = bh->ci->window_tab_64bit[window].size_reg;
- base_lo_bits = bh->ci->window_tab_64bit[window].base_lo_bits;
- size_bits = bh->ci->window_tab_64bit[window].size_bits;
- get_from_field= bh->ci->window_tab_64bit[window].get_from_field;
-
- *base_hi = mv64x60_read(bh,
- bh->ci->window_tab_64bit[window].base_hi_reg);
-
- val = mv64x60_read(bh, base_lo_reg);
- *base_lo = get_from_field(val, base_lo_bits);
-
- if (size_reg != 0) {
- val = mv64x60_read(bh, size_reg);
- val = get_from_field(val, size_bits);
- *size = bh->ci->untranslate_size(*base_lo, val,
- size_bits);
- }
- else {
- *size = 0;
- }
- }
- else {
- *base_hi = 0;
- *base_lo = 0;
- *size = 0;
- }
-
- DBG("get 64bit window: %d, base hi: 0x%x, base lo: 0x%x, size: 0x%x\n",
- window, *base_hi, *base_lo, *size);
-
- return;
-}
-
-/*
- * mv64x60_set_64bit_window()
- *
- * Set the base address and size of a 64-bit window on the bridge.
- */
-void __init
-mv64x60_set_64bit_window(mv64x60_handle_t *bh, u32 window,
- u32 base_hi, u32 base_lo, u32 size, u32 other_bits)
-{
- u32 val, base_lo_reg, size_reg, base_lo_bits, size_bits;
- u32 (*map_to_field)(u32 val, u32 num_bits);
-
- DBG("set 64bit window: %d, base hi: 0x%x, base lo: 0x%x, " \
- "size: 0x%x, other: 0x%x\n",
- window, base_hi, base_lo, size, other_bits);
-
- base_lo_reg = bh->ci->window_tab_64bit[window].base_lo_reg;
-
- if (base_lo_reg != 0) {
- size_reg = bh->ci->window_tab_64bit[window].size_reg;
- base_lo_bits = bh->ci->window_tab_64bit[window].base_lo_bits;
- size_bits = bh->ci->window_tab_64bit[window].size_bits;
- map_to_field = bh->ci->window_tab_64bit[window].map_to_field;
-
- mv64x60_write(bh, bh->ci->window_tab_64bit[window].base_hi_reg,
- base_hi);
-
- val = map_to_field(base_lo, base_lo_bits) | other_bits;
- mv64x60_write(bh, base_lo_reg, val);
-
- if (size_reg != 0) {
- val = bh->ci->translate_size(base_lo, size, size_bits);
- val = map_to_field(val, size_bits);
- mv64x60_write(bh, size_reg, val);
- }
-
- (void)mv64x60_read(bh, base_lo_reg); /* Flush FIFO */
- }
-
- return;
-}
-
-/*
- * mv64x60_mask()
- *
- * Take the high-order 'num_bits' of 'val' & mask off low bits.
- */
-static u32 __init
-mv64x60_mask(u32 val, u32 num_bits)
-{
- DBG("mask val: 0x%x, num_bits: %d == 0x%x\n", val,
- num_bits, val & (0xffffffff << (32 - num_bits)));
-
- return val & (0xffffffff << (32 - num_bits));
-}
-
-/*
- * mv64x60_mask_shift_left()
- *
- * Take the low-order 'num_bits' of 'val', shift left to align at bit 31 (MSB).
- */
-static u32 __init
-mv64x60_shift_left(u32 val, u32 num_bits)
-{
- DBG("shift left val: 0x%x, num_bits: %d == 0x%x\n", val,
- num_bits, val << (32 - num_bits));
-
- return val << (32 - num_bits);
-}
-
-/*
- * mv64x60_shift_right()
- *
- * Take the high-order 'num_bits' of 'val', shift right to align at bit 0 (LSB).
- */
-static u32 __init
-mv64x60_shift_right(u32 val, u32 num_bits)
-{
- DBG("shift right val: 0x%x, num_bits: %d == 0x%x\n", val, num_bits,
- val >> (32 - num_bits));
-
- return val >> (32 - num_bits);
-}
-
-/*
- *****************************************************************************
- *
- * Early Init Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_early_init()
- *
- * Do some bridge work that must take place before we start messing with
- * the bridge for real.
- */
-static void __init
-mv64x60_early_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- memset(bh, 0, sizeof(*bh));
-
- bh->p_base = si->phys_reg_base;
- bh->v_base = (u32)ioremap(bh->p_base, MV64x60_INTERNAL_SPACE_SIZE);
- bh->base_irq = si->base_irq;
-
- /* Bit 12 MUST be 0; set bit 27--don't auto-update cpu remap regs */
- mv64x60_clr_bits(bh, MV64x60_CPU_CONFIG, (1<<12));
- mv64x60_set_bits(bh, MV64x60_CPU_CONFIG, (1<<27));
-
- /*
- * Turn off timer/counters. Not turning off watchdog timer because
- * can't read its reg on the 64260A so don't know if we'll be enabling
- * or disabling.
- */
- mv64x60_clr_bits(bh, MV64x60_TIMR_CNTR_0_3_CNTL,
- ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
-
-#ifdef CONFIG_GT64260
- mv64x60_clr_bits(bh, GT64260_TIMR_CNTR_4_7_CNTL,
- ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
-#endif
-
-#if 0
-XXXX Put in PCI_x_RETRY adjustment XXXX
-#endif
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * Chip Identification Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_type()
- *
- * Determine the type of bridge chip we have.
- */
-static int __init mv64x60_get_type(struct mv64x60_handle *bh)
-{
- struct pci_controller *hose = bh->hose_a;
- int pcidev;
- int devfn;
- u16 val;
- u8 save_exclude;
-
- pcidev = (mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG) >> 24) & 0xf;
- devfn = PCI_DEVFN(pcidev, 0);
-
- save_exclude = mv64x60_pci_exclude_bridge;
- mv64x60_pci_exclude_bridge = FALSE;
-
- /* Sanity check of bridge's Vendor ID */
- early_read_config_word(hose, 0, devfn, PCI_VENDOR_ID, &val);
-
- if (val != PCI_VENDOR_ID_MARVELL)
- return -1;
-
- /* Figure out the type of Marvell bridge it is */
- early_read_config_word(hose, 0, devfn, PCI_DEVICE_ID, &val);
-
- switch (val) {
- case PCI_DEVICE_ID_MARVELL_GT64260:
- early_read_config_word(hose, 0, devfn,
- PCI_CLASS_REVISION, &val);
-
- switch (val & 0xff) {
- case GT64260_REV_A:
- bh->type = MV64x60_TYPE_GT64260A;
- break;
- case GT64260_REV_B:
- bh->type = MV64x60_TYPE_GT64260B;
- break;
- }
- break;
-
- case PCI_DEVICE_ID_MARVELL_MV64360:
- /* Marvell won't tell me how to distinguish a 64361 & 64362 */
- bh->type = MV64x60_TYPE_MV64360;
- break;
-
- case PCI_DEVICE_ID_MARVELL_MV64460:
- bh->type = MV64x60_TYPE_MV64460;
- break;
-
- default:
- printk(KERN_CRIT "Unknown Marvell bridge type %04x\n", val);
- return -1;
- }
-
- mv64x60_pci_exclude_bridge = save_exclude;
- return 0;
-}
-
-/*
- * mv64x60_setup_for_chip()
- *
- * Set 'bh' to use the proper set of routine for the bridge chip that we have.
- */
-static int __init
-mv64x60_setup_for_chip(mv64x60_handle_t *bh)
-{
- int rc = 0;
-
- /* Set up chip-specific info based on the chip/bridge type */
- switch(bh->type) {
- case MV64x60_TYPE_GT64260A:
- bh->ci = >64260a_ci;
- break;
-
- case MV64x60_TYPE_GT64260B:
- bh->ci = >64260b_ci;
- break;
-
- case MV64x60_TYPE_MV64360:
- bh->ci = &mv64360_ci;
- break;
-
-#if 0 /* Marvell won't tell me how to distinguish--MAG */
- case MV64x60_TYPE_MV64361:
- case MV64x60_TYPE_MV64362:
-#endif
- case MV64x60_TYPE_MV64460:
- bh->ci = &mv64460_ci;
- break;
-
- case MV64x60_TYPE_INVALID:
- default:
- if (ppc_md.progress)
- ppc_md.progress("mv64x60: Unsupported bridge",
- 0x0);
- printk("mv64x60: Unsupported bridge\n");
- rc = -1;
- }
-
- return rc;
-}
-
-/*
- *****************************************************************************
- *
- * System Memory Window Related Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_get_mem_windows()
- *
- * Get the values in the memory controller & return in the 'mem_windows' array.
- */
-static void __init
-mv64x60_get_mem_windows(mv64x60_handle_t *bh,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
- u32 i;
- u32 windows[] = { MV64x60_CPU2MEM_0_WIN, MV64x60_CPU2MEM_1_WIN,
- MV64x60_CPU2MEM_2_WIN, MV64x60_CPU2MEM_3_WIN };
-
- for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
- if (bh->ci->is_enabled_32bit(bh, i)) {
- mv64x60_get_32bit_window(bh, windows[i],
- &mem_windows[i][0], &mem_windows[i][1]);
- }
- else {
- mem_windows[i][0] = 0;
- mem_windows[i][1] = 0;
- }
- }
-
- return;
-}
-
-/*
- * mv64x60_calc_mem_size()
- *
- * Using the memory controller register values in 'mem_windows', determine
- * how much memory it is set up for.
- */
-static u32 __init
-mv64x60_calc_mem_size(mv64x60_handle_t *bh,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
- u32 i, total = 0;
-
- for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
- total += mem_windows[i][1];
- }
-
- return total;
-}
-
-/*
- *****************************************************************************
- *
- * CPU->System MEM Config Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_config_cpu2mem_windows()
- *
- * Configure CPU->Memory windows on the bridge.
- */
-static void __init
-mv64x60_config_cpu2mem_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
- u32 i;
- u32 prot_windows[] = {
- MV64x60_CPU_PROT_0_WIN, MV64x60_CPU_PROT_1_WIN,
- MV64x60_CPU_PROT_2_WIN, MV64x60_CPU_PROT_3_WIN };
- u32 cpu_snoop_windows[] = {
- MV64x60_CPU_SNOOP_0_WIN, MV64x60_CPU_SNOOP_1_WIN,
- MV64x60_CPU_SNOOP_2_WIN, MV64x60_CPU_SNOOP_3_WIN };
-
- /* Set CPU protection & snoop windows */
- for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
- if (bh->ci->is_enabled_32bit(bh, i)) {
- mv64x60_set_32bit_window(bh, prot_windows[i],
- mem_windows[i][0], mem_windows[i][1],
- si->cpu_prot_options[i]);
- bh->ci->enable_window_32bit(bh, prot_windows[i]);
-
- if (bh->ci->window_tab_32bit[cpu_snoop_windows[i]].
- base_reg != 0) {
- mv64x60_set_32bit_window(bh,
- cpu_snoop_windows[i], mem_windows[i][0],
- mem_windows[i][1],
- si->cpu_snoop_options[i]);
- bh->ci->enable_window_32bit(bh,
- cpu_snoop_windows[i]);
- }
-
- }
- }
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * CPU->PCI Config Routines
- *
- *****************************************************************************
- */
-
-/*
- * mv64x60_config_cpu2pci_windows()
- *
- * Configure the CPU->PCI windows on the bridge.
- */
-static void __init
-mv64x60_config_cpu2pci_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- if (ppc_md.progress)
- ppc_md.progress("mv64x60_config_bridge: Enter", 0x0);
-
- /*
- * Set up various parts of the bridge including CPU->PCI windows.
- * Depending on the board, there may be only one hose that needs to
- * be set up.
- */
- if (si->pci_0.enable_bus) {
- u32 win_tab[] = { MV64x60_CPU2PCI0_IO_WIN,
- MV64x60_CPU2PCI0_MEM_0_WIN,
- MV64x60_CPU2PCI0_MEM_1_WIN,
- MV64x60_CPU2PCI0_MEM_2_WIN };
- u32 remap_tab[] = { MV64x60_CPU2PCI0_IO_REMAP_WIN,
- MV64x60_CPU2PCI0_MEM_0_REMAP_WIN,
- MV64x60_CPU2PCI0_MEM_1_REMAP_WIN,
- MV64x60_CPU2PCI0_MEM_2_REMAP_WIN };
-
- mv64x60_set_cpu2pci_window(bh, &si->pci_0, win_tab, remap_tab);
- }
-
- if (si->pci_1.enable_bus) {
- u32 win_tab[] = { MV64x60_CPU2PCI1_IO_WIN,
- MV64x60_CPU2PCI1_MEM_0_WIN,
- MV64x60_CPU2PCI1_MEM_1_WIN,
- MV64x60_CPU2PCI1_MEM_2_WIN };
- u32 remap_tab[] = { MV64x60_CPU2PCI1_IO_REMAP_WIN,
- MV64x60_CPU2PCI1_MEM_0_REMAP_WIN,
- MV64x60_CPU2PCI1_MEM_1_REMAP_WIN,
- MV64x60_CPU2PCI1_MEM_2_REMAP_WIN };
-
- mv64x60_set_cpu2pci_window(bh, &si->pci_1, win_tab, remap_tab);
- }
-
- return;
-} /* mv64x60_config_bridge() */
-
-/*
- * mv64x60_set_cpu2pci_window()
- *
- * Configure the CPU->PCI windows for one of the PCI buses.
- */
-static void __init
-mv64x60_set_cpu2pci_window(mv64x60_handle_t *bh, mv64x60_pci_info_t *pi,
- u32 *win_tab, u32 *remap_tab)
-{
- int i;
-
- if (pi->pci_io.size > 0) {
- mv64x60_set_32bit_window(bh, win_tab[0], pi->pci_io.cpu_base,
- pi->pci_io.size, pi->pci_io.swap);
- mv64x60_set_32bit_window(bh, remap_tab[0],
- pi->pci_io.pci_base_lo, 0, 0);
- bh->ci->enable_window_32bit(bh, win_tab[0]);
- }
- else { /* Actually, the window should already be disabled */
- bh->ci->disable_window_32bit(bh, win_tab[0]);
- }
-
- for (i=0; i<3; i++) {
- if (pi->pci_mem[i].size > 0) {
- mv64x60_set_32bit_window(bh, win_tab[i+1],
- pi->pci_mem[i].cpu_base, pi->pci_mem[i].size,
- pi->pci_mem[i].swap);
- mv64x60_set_64bit_window(bh, remap_tab[i+1],
- pi->pci_mem[i].pci_base_hi,
- pi->pci_mem[i].pci_base_lo, 0, 0);
- bh->ci->enable_window_32bit(bh, win_tab[i+1]);
- }
- else { /* Actually, the window should already be disabled */
- bh->ci->disable_window_32bit(bh, win_tab[i+1]);
- }
- }
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * PCI->System MEM Config Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_config_pci2mem_windows()
- *
- * Configure the PCI->Memory windows on the bridge.
- */
-static void __init
-mv64x60_config_pci2mem_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si,
- u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2])
-{
- u32 i;
- u32 pci_0_acc_windows[] = {
- MV64x60_PCI02MEM_ACC_CNTL_0_WIN,
- MV64x60_PCI02MEM_ACC_CNTL_1_WIN,
- MV64x60_PCI02MEM_ACC_CNTL_2_WIN,
- MV64x60_PCI02MEM_ACC_CNTL_3_WIN };
- u32 pci_1_acc_windows[] = {
- MV64x60_PCI12MEM_ACC_CNTL_0_WIN,
- MV64x60_PCI12MEM_ACC_CNTL_1_WIN,
- MV64x60_PCI12MEM_ACC_CNTL_2_WIN,
- MV64x60_PCI12MEM_ACC_CNTL_3_WIN };
- u32 pci_0_snoop_windows[] = {
- MV64x60_PCI02MEM_SNOOP_0_WIN,
- MV64x60_PCI02MEM_SNOOP_1_WIN,
- MV64x60_PCI02MEM_SNOOP_2_WIN,
- MV64x60_PCI02MEM_SNOOP_3_WIN };
- u32 pci_1_snoop_windows[] = {
- MV64x60_PCI12MEM_SNOOP_0_WIN,
- MV64x60_PCI12MEM_SNOOP_1_WIN,
- MV64x60_PCI12MEM_SNOOP_2_WIN,
- MV64x60_PCI12MEM_SNOOP_3_WIN };
- u32 pci_0_size[] = {
- MV64x60_PCI0_MEM_0_SIZE, MV64x60_PCI0_MEM_1_SIZE,
- MV64x60_PCI0_MEM_2_SIZE, MV64x60_PCI0_MEM_3_SIZE };
- u32 pci_1_size[] = {
- MV64x60_PCI1_MEM_0_SIZE, MV64x60_PCI1_MEM_1_SIZE,
- MV64x60_PCI1_MEM_2_SIZE, MV64x60_PCI1_MEM_3_SIZE };
-
- /* Clear bit 0 of PCI addr decode control so PCI->CPU remap 1:1 */
- mv64x60_clr_bits(bh, MV64x60_PCI0_PCI_DECODE_CNTL, 0x00000001);
- mv64x60_clr_bits(bh, MV64x60_PCI1_PCI_DECODE_CNTL, 0x00000001);
-
- /*
- * Set the access control, snoop, BAR size, and window base addresses.
- * PCI->MEM windows base addresses will match exactly what the
- * CPU->MEM windows are.
- */
- for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
- if (bh->ci->is_enabled_32bit(bh, i)) {
- if (si->pci_0.enable_bus) {
- mv64x60_set_64bit_window(bh,
- pci_0_acc_windows[i], 0,
- mem_windows[i][0], mem_windows[i][1],
- si->pci_0.acc_cntl_options[i]);
- bh->ci->enable_window_64bit(bh,
- pci_0_acc_windows[i]);
-
- if (bh->ci->window_tab_64bit[
- pci_0_snoop_windows[i]].base_lo_reg
- != 0) {
- mv64x60_set_64bit_window(bh,
- pci_0_snoop_windows[i], 0,
- mem_windows[i][0],
- mem_windows[i][1],
- si->pci_0.snoop_options[i]);
- bh->ci->enable_window_64bit(bh,
- pci_0_snoop_windows[i]);
- }
-
- bh->ci->set_pci2mem_window(bh->hose_a, i,
- mem_windows[i][0]);
- mv64x60_write(bh, pci_0_size[i],
- mv64x60_mask(mem_windows[i][1] -1, 20));
-
- /* Enable the window */
- mv64x60_clr_bits(bh, MV64x60_PCI0_BAR_ENABLE,
- 1 << i);
- }
- if (si->pci_1.enable_bus) {
- mv64x60_set_64bit_window(bh,
- pci_1_acc_windows[i], 0,
- mem_windows[i][0], mem_windows[i][1],
- si->pci_1.acc_cntl_options[i]);
- bh->ci->enable_window_64bit(bh,
- pci_1_acc_windows[i]);
-
- if (bh->ci->window_tab_64bit[
- pci_1_snoop_windows[i]].base_lo_reg
- != 0) {
- mv64x60_set_64bit_window(bh,
- pci_1_snoop_windows[i], 0,
- mem_windows[i][0],
- mem_windows[i][1],
- si->pci_1.snoop_options[i]);
- bh->ci->enable_window_64bit(bh,
- pci_1_snoop_windows[i]);
- }
-
- bh->ci->set_pci2mem_window(bh->hose_b, i,
- mem_windows[i][0]);
- mv64x60_write(bh, pci_1_size[i],
- mv64x60_mask(mem_windows[i][1] -1, 20));
-
- /* Enable the window */
- mv64x60_clr_bits(bh, MV64x60_PCI1_BAR_ENABLE,
- 1 << i);
- }
- }
- }
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * Hose & Resource Alloc/Init Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_alloc_hoses()
- *
- * Allocate the PCI hose structures for the bridge's PCI buses.
- */
-static void __init
-mv64x60_alloc_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- /*
- * Alloc first hose struct even when its not to be configured b/c the
- * chip identification routines need to use it.
- */
- bh->hose_a = pcibios_alloc_controller();
- setup_indirect_pci(bh->hose_a,
- bh->p_base + MV64x60_PCI0_CONFIG_ADDR,
- bh->p_base + MV64x60_PCI0_CONFIG_DATA);
-
- if (si->pci_1.enable_bus) {
- bh->hose_b = pcibios_alloc_controller();
- setup_indirect_pci(bh->hose_b,
- bh->p_base + MV64x60_PCI1_CONFIG_ADDR,
- bh->p_base + MV64x60_PCI1_CONFIG_DATA);
- }
-
- return;
-}
-
-/*
- * mv64x60_init_hoses()
- *
- * Initialize the PCI hose structures for the bridge's PCI hoses.
- */
-static void __init
-mv64x60_init_hoses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- if (si->pci_1.enable_bus) {
- bh->io_base_b = (u32)ioremap(si->pci_1.pci_io.cpu_base,
- si->pci_1.pci_io.size);
- isa_io_base = bh->io_base_b;
- }
-
- if (si->pci_0.enable_bus) {
- bh->io_base_a = (u32)ioremap(si->pci_0.pci_io.cpu_base,
- si->pci_0.pci_io.size);
- isa_io_base = bh->io_base_a;
-
- mv64x60_init_resources(bh->hose_a, &si->pci_0, bh->io_base_a);
- mv64x60_set_pci_params(bh->hose_a, &si->pci_0);
- }
-
- /* Must do here so proper isa_io_base is used in calculations */
- if (si->pci_1.enable_bus) {
- mv64x60_init_resources(bh->hose_b, &si->pci_1, bh->io_base_b);
- mv64x60_set_pci_params(bh->hose_b, &si->pci_1);
- }
-
- return;
-}
-
-/*
- * mv64x60_init_resources()
- *
- * Calculate the offsets, etc. for the hose structures to reflect all of
- * the address remapping that happens as you go from CPU->PCI and PCI->MEM.
- */
-static void __init
-mv64x60_init_resources(struct pci_controller *hose, mv64x60_pci_info_t *pi,
- u32 io_base)
-{
- int i;
- /* 2 hoses; 4 resources/hose; sting <= 64 bytes; not work if > 1 chip */
- static char s[2][4][64];
-
- if (pi->pci_io.size != 0) {
- sprintf(s[hose->index][0], "PCI hose %d I/O Space",
- hose->index);
- pci_init_resource(&hose->io_resource, io_base - isa_io_base,
- io_base - isa_io_base + pi->pci_io.size - 1,
- IORESOURCE_IO, s[hose->index][0]);
- hose->io_space.start = pi->pci_io.pci_base_lo;
- hose->io_space.end = pi->pci_io.pci_base_lo + pi->pci_io.size-1;
- hose->io_base_virt = (void *)isa_io_base;
- }
-
- for (i=0; i<3; i++) {
- if (pi->pci_mem[i].size != 0) {
- sprintf(s[hose->index][i+1], "PCI hose %d MEM Space %d",
- hose->index, i);
- pci_init_resource(&hose->mem_resources[i],
- pi->pci_mem[i].cpu_base,
- pi->pci_mem[i].cpu_base + pi->pci_mem[i].size-1,
- IORESOURCE_MEM, s[hose->index][i+1]);
- }
- }
-
- hose->mem_space.end = pi->pci_mem[0].pci_base_lo +
- pi->pci_mem[0].size - 1;
- hose->pci_mem_offset = pi->pci_mem[0].cpu_base -
- pi->pci_mem[0].pci_base_lo;
-
- return;
-} /* mv64x60_init_resources() */
-
-/*
- * mv64x60_set_pci_params()
- *
- * Configure a hose's PCI config space parameters.
- */
-static void __init
-mv64x60_set_pci_params(struct pci_controller *hose, mv64x60_pci_info_t *pi)
-{
- u32 devfn;
- u16 u16_val;
- u8 save_exclude;
-
- devfn = PCI_DEVFN(0,0);
-
- save_exclude = mv64x60_pci_exclude_bridge;
- mv64x60_pci_exclude_bridge = FALSE;
-
- /* Set class code to indicate host bridge */
- u16_val = PCI_CLASS_BRIDGE_HOST; /* 0x0600 (host bridge) */
- early_write_config_word(hose, 0, devfn, PCI_CLASS_DEVICE, u16_val);
-
- /* Enable 64260 to be PCI master & respond to PCI MEM cycles */
- early_read_config_word(hose, 0, devfn, PCI_COMMAND, &u16_val);
- u16_val &= ~(PCI_COMMAND_IO | PCI_COMMAND_INVALIDATE |
- PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_FAST_BACK);
- u16_val |= pi->pci_cmd_bits | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
- early_write_config_word(hose, 0, devfn, PCI_COMMAND, u16_val);
-
- /* Set latency timer, cache line size, clear BIST */
- u16_val = (pi->latency_timer << 8) | (L1_CACHE_LINE_SIZE >> 2);
- early_write_config_word(hose, 0, devfn, PCI_CACHE_LINE_SIZE, u16_val);
-
- mv64x60_pci_exclude_bridge = save_exclude;
- return;
-}
-
-/*
- *****************************************************************************
- *
- * PCI Related Routine
- *
- *****************************************************************************
- */
-/*
- * mv64x60_enumerate_buses()
- *
- * If requested, enumerate the PCI buses and set the appropriate
- * info in the hose structures.
- */
-static void __init
-mv64x60_enumerate_buses(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- u32 val;
-
- pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */
-
- ppc_md.pci_exclude_device = mv64x60_pci_exclude_device;
- ppc_md.pci_swizzle = common_swizzle;
- ppc_md.pci_map_irq = si->map_irq;
-
- /* Now that the bridge is set up, its safe to scan the PCI buses */
- if (si->pci_0.enable_bus) {
- if (si->pci_0.enumerate_bus) {
- /* Set bus number for PCI 0 to 0 */
- val = mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
- val &= 0xe0000000;
- val |= 0x000000ff;
- mv64x60_write(bh, MV64x60_PCI0_P2P_CONFIG, val);
- /* Flush FIFO*/
- (void)mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
-
-#if 0
-XXXX Different if in PCI-X mode (look at mv64360_find_bridges()) XXXX
-#endif
-
- bh->hose_a->first_busno = 0;
- bh->hose_a->last_busno = 0xff;
-
- bh->hose_a->last_busno = pciauto_bus_scan(bh->hose_a,
- bh->hose_a->first_busno);
- }
- else {
- /* Assume bridge set up correctly by someone else */
- val = mv64x60_read(bh, MV64x60_PCI0_P2P_CONFIG);
- bh->hose_a->first_busno = (val & 0x00ff0000) >> 16;
- }
- }
-
- if (si->pci_1.enable_bus) {
- if (si->pci_1.enumerate_bus) {
- if (si->pci_0.enable_bus) {
- bh->hose_b->first_busno =
- bh->hose_a->last_busno + 1;
-
- /* Set bus number for PCI 1 hose */
- val = mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
- val &= 0xe0000000;
- val |= (bh->hose_b->first_busno << 16) | 0xff;
- mv64x60_write(bh, MV64x60_PCI1_P2P_CONFIG, val);
- /* Flush FIFO */
- (void)mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
- }
- else {
- bh->hose_b->first_busno = 0;
- }
-
- bh->hose_b->last_busno = 0xff;
- bh->hose_b->last_busno = pciauto_bus_scan(bh->hose_b,
- bh->hose_b->first_busno);
- }
- else {
- /* Assume bridge set up correctly by someone else */
- val = mv64x60_read(bh, MV64x60_PCI1_P2P_CONFIG);
- bh->hose_b->first_busno = (val & 0x00ff0000) >> 16;
- bh->hose_b->last_busno = 0xff; /* No way to know */
- }
- }
-
- if (si->pci_0.enable_bus && !si->pci_0.enumerate_bus) {
- if (si->pci_1.enable_bus) {
- bh->hose_a->last_busno = bh->hose_b->first_busno - 1;
- }
- else {
- bh->hose_a->last_busno = 0xff; /* No way to know */
- }
- }
-
- return;
-}
-
-/*
- * mv64x60_exclude_pci_device()
- *
- * This routine is used to make the bridge not appear when the
- * PCI subsystem is accessing PCI devices (in PCI config space).
- */
-static int
-mv64x60_pci_exclude_device(u8 bus, u8 devfn)
-{
- struct pci_controller *hose;
-
- hose = pci_bus_to_hose(bus);
-
- /* Skip slot 0 on both hoses */
- if ((mv64x60_pci_exclude_bridge == TRUE) &&
- (PCI_SLOT(devfn) == 0) &&
- (hose->first_busno == bus)) {
- return PCIBIOS_DEVICE_NOT_FOUND;
- }
- else {
- return PCIBIOS_SUCCESSFUL;
- }
-} /* mv64x60_pci_exclude_device() */
-
-/*
- *****************************************************************************
- *
- * OCP Fixup Routines
- *
- *****************************************************************************
- */
-/*
- * mv64x60_fixup_ocp()
- *
- * Adjust the 'paddr' field in the bridge's OCP entries to reflect where they
- * really are in the physical address space.
- */
-static void __init
-mv64x60_fixup_ocp(struct ocp_device *dev, void *arg)
-{
- mv64x60_handle_t *bh = (mv64x60_handle_t *)arg;
-
- if (dev->def->vendor == OCP_VENDOR_MARVELL) {
- dev->def->paddr += bh->p_base;
- }
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * GT64260-Specific Routines
- *
- *****************************************************************************
- */
-/*
- * gt64260_translate_size()
- *
- * On the GT64260, the size register is really the "top" address of the window.
- */
-static u32 __init
-gt64260_translate_size(u32 base, u32 size, u32 num_bits)
-{
- return base + mv64x60_mask(size - 1, num_bits);
-}
-
-/*
- * gt64260_untranslate_size()
- *
- * Translate the top address of a window into a window size.
- */
-static u32 __init
-gt64260_untranslate_size(u32 base, u32 size, u32 num_bits)
-{
- if (size >= base) {
- size = size - base + (1 << (32 - num_bits));
- }
- else {
- size = 0;
- }
-
- return size;
-}
-
-/*
- * gt64260_set_pci2mem_window()
- *
- * The PCI->MEM window registers are actually in PCI config space so need
- * to set them by setting the correct config space BARs.
- */
-static void __init
-gt64260_set_pci2mem_window(struct pci_controller *hose, u32 window, u32 base)
-{
- u32 reg_addrs[] = { 0x10, 0x14, 0x18, 0x1c };
-
- DBG("set pci->mem window: %d, hose: %d, base: 0x%x\n", window,
- hose->index, base);
-
- early_write_config_dword(hose, hose->first_busno,
- PCI_DEVFN(0, 0), reg_addrs[window],
- mv64x60_mask(base, 20) | 0x8);
- return;
-}
-
-/*
- * gt64260_is_enabled_32bit()
- *
- * On a GT64260, a window is enabled iff its top address is >= to its base
- * address.
- */
-static u32 __init
-gt64260_is_enabled_32bit(mv64x60_handle_t *bh, u32 window)
-{
- u32 rc = 0;
-
- if ((gt64260_32bit_windows[window].base_reg != 0) &&
- (gt64260_32bit_windows[window].size_reg != 0) &&
- ((mv64x60_read(bh, gt64260_32bit_windows[window].size_reg) &
- ((1 << gt64260_32bit_windows[window].size_bits) - 1)) >=
- (mv64x60_read(bh, gt64260_32bit_windows[window].base_reg) &
- ((1 << gt64260_32bit_windows[window].base_bits) - 1)))){
-
- rc = 1;
- }
-
- if (rc) {
- DBG("32bit window %d is enabled\n", window);
- }
- else {
- DBG("32bit window %d is disabled\n", window);
- }
-
- return rc;
-}
-
-/*
- * gt64260_enable_window_32bit()
- *
- * On the GT64260, a window is enabled iff the top address is >= to the base
- * address of the window. Since the window has already been configured by
- * the time this routine is called, we have nothing to do here.
- */
-static void __init
-gt64260_enable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("enable 32bit window: %d\n", window);
- return;
-}
-
-/*
- * gt64260_disable_window_32bit()
- *
- * On a GT64260, you disable a window by setting its top address to be less
- * than its base address.
- */
-static void __init
-gt64260_disable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("disable 32bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
- window, gt64260_32bit_windows[window].base_reg,
- gt64260_32bit_windows[window].size_reg);
-
- if ((gt64260_32bit_windows[window].base_reg != 0) &&
- (gt64260_32bit_windows[window].size_reg != 0)) {
-
- /* To disable, make bottom reg higher than top reg */
- mv64x60_write(bh, gt64260_32bit_windows[window].base_reg,0xfff);
- mv64x60_write(bh, gt64260_32bit_windows[window].size_reg, 0);
- }
-
- return;
-}
-
-/*
- * gt64260_enable_window_64bit()
- *
- * On the GT64260, a window is enabled iff the top address is >= to the base
- * address of the window. Since the window has already been configured by
- * the time this routine is called, we have nothing to do here.
- */
-static void __init
-gt64260_enable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("enable 64bit window: %d\n", window);
- return; /* Enabled when window configured (i.e., when top >= base) */
-}
-
-/*
- * gt64260_disable_window_64bit()
- *
- * On a GT64260, you disable a window by setting its top address to be less
- * than its base address.
- */
-static void __init
-gt64260_disable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("disable 64bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
- window, gt64260_64bit_windows[window].base_lo_reg,
- gt64260_64bit_windows[window].size_reg);
-
- if ((gt64260_64bit_windows[window].base_lo_reg != 0) &&
- (gt64260_64bit_windows[window].size_reg != 0)) {
-
- /* To disable, make bottom reg higher than top reg */
- mv64x60_write(bh, gt64260_64bit_windows[window].base_lo_reg,
- 0xfff);
- mv64x60_write(bh, gt64260_64bit_windows[window].base_hi_reg, 0);
- mv64x60_write(bh, gt64260_64bit_windows[window].size_reg, 0);
- }
-
- return;
-}
-
-/*
- * gt64260_disable_all_windows()
- *
- * The GT64260 has several windows that aren't represented in the table of
- * windows at the top of this file. This routine turns all of them off
- * except for the memory controller windows, of course.
- */
-static void __init
-gt64260_disable_all_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- u32 i;
-
- /* Disable 32bit windows (don't disable cpu->mem windows) */
- for (i=MV64x60_CPU2DEV_0_WIN; i<MV64x60_32BIT_WIN_COUNT; i++) {
- if (!(si->window_preserve_mask_32 & (1<<i)))
- gt64260_disable_window_32bit(bh, i);
- }
-
- /* Disable 64bit windows */
- for (i=0; i<MV64x60_64BIT_WIN_COUNT; i++) {
- if (!(si->window_preserve_mask_64 & (1<<i)))
- gt64260_disable_window_64bit(bh, i);
- }
-
- /* Turn off cpu protection windows not in gt64260_32bit_windows[] */
- mv64x60_write(bh, GT64260_CPU_PROT_BASE_4, 0xfff);
- mv64x60_write(bh, GT64260_CPU_PROT_SIZE_4, 0);
- mv64x60_write(bh, GT64260_CPU_PROT_BASE_5, 0xfff);
- mv64x60_write(bh, GT64260_CPU_PROT_SIZE_5, 0);
- mv64x60_write(bh, GT64260_CPU_PROT_BASE_6, 0xfff);
- mv64x60_write(bh, GT64260_CPU_PROT_SIZE_6, 0);
- mv64x60_write(bh, GT64260_CPU_PROT_BASE_7, 0xfff);
- mv64x60_write(bh, GT64260_CPU_PROT_SIZE_7, 0);
-
- /* Turn off PCI->MEM access cntl wins not in gt64260_64bit_windows[] */
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_LO, 0xfff);
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_HI, 0);
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_4_SIZE, 0);
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_LO, 0xfff);
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_HI, 0);
- mv64x60_write(bh, MV64x60_PCI0_ACC_CNTL_5_SIZE, 0);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_BASE_LO, 0xfff);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_BASE_HI, 0);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_6_SIZE, 0);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_BASE_LO, 0xfff);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_BASE_HI, 0);
- mv64x60_write(bh, GT64260_PCI0_ACC_CNTL_7_SIZE, 0);
-
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_LO, 0xfff);
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_HI, 0);
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_4_SIZE, 0);
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_LO, 0xfff);
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_HI, 0);
- mv64x60_write(bh, MV64x60_PCI1_ACC_CNTL_5_SIZE, 0);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_BASE_LO, 0xfff);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_BASE_HI, 0);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_6_SIZE, 0);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_BASE_LO, 0xfff);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_BASE_HI, 0);
- mv64x60_write(bh, GT64260_PCI1_ACC_CNTL_7_SIZE, 0);
-
- /* Disable all PCI-><whatever> windows */
- mv64x60_set_bits(bh, MV64x60_PCI0_BAR_ENABLE, 0x07ffffff);
- mv64x60_set_bits(bh, MV64x60_PCI1_BAR_ENABLE, 0x07ffffff);
-
- return;
-}
-
-/*
- * gt64260a_chip_specific_init()
- *
- * Implement errata work arounds for the GT64260A.
- */
-static void
-gt64260a_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- struct ocp_device *dev;
- mv64x60_ocp_mpsc_data_t *mpsc_dp;
- u8 save_exclude;
- u32 val;
-
- /* R#18 */
- /* cpu read buffer to buffer 1 (reg 0x0448) */
- mv64x60_set_bits(bh, GT64260_SDRAM_CONFIG, (1<<26));
-
- /* No longer errata so turn on */
- /* Enable pci read/write combine, master write trigger,
- * disable slave sync barrier
- * readmultiple (reg 0x0c00 and 0x0c80)
- */
- if (si->pci_0.enable_bus) {
- mv64x60_set_bits(bh, MV64x60_PCI0_CMD,
- ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
- }
-
- if (si->pci_1.enable_bus) {
- mv64x60_set_bits(bh, MV64x60_PCI1_CMD,
- ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
- }
-
-#if 1 /* XXXX */
- /*
- * Dave Wilhardt found that bit 4 in the PCI Command registers must
- * be set if you are using cache coherency.
- *
- * Note: he also said that bit 4 must be on in all PCI devices but
- * that has not been implemented yet.
- */
- save_exclude = mv64x60_pci_exclude_bridge;
- mv64x60_pci_exclude_bridge = FALSE;
-
- early_read_config_dword(bh->hose_a,
- bh->hose_a->first_busno,
- PCI_DEVFN(0,0),
- PCI_COMMAND,
- &val);
- val |= PCI_COMMAND_INVALIDATE;
- early_write_config_dword(bh->hose_a,
- bh->hose_a->first_busno,
- PCI_DEVFN(0,0),
- PCI_COMMAND,
- val);
-
- early_read_config_dword(bh->hose_b,
- bh->hose_b->first_busno,
- PCI_DEVFN(0,0),
- PCI_COMMAND,
- &val);
- val |= PCI_COMMAND_INVALIDATE;
- early_write_config_dword(bh->hose_b,
- bh->hose_b->first_busno,
- PCI_DEVFN(0,0),
- PCI_COMMAND,
- val);
-
- mv64x60_pci_exclude_bridge = save_exclude;
-#endif
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->mirror_regs = 1;
- mpsc_dp->cache_mgmt = 1;
- }
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->mirror_regs = 1;
- mpsc_dp->cache_mgmt = 1;
- }
-
- return;
-}
-
-/*
- * gt64260b_chip_specific_init()
- *
- * Implement errata work arounds for the GT64260B.
- */
-static void
-gt64260b_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- struct ocp_device *dev;
- mv64x60_ocp_mpsc_data_t *mpsc_dp;
-
- /* R#18 */
- /* cpu read buffer to buffer 1 (reg 0x0448) */
- mv64x60_set_bits(bh, GT64260_SDRAM_CONFIG, (1<<26));
-
- /* No longer errata so turn on */
- /* Enable pci read/write combine, master write trigger,
- * disable slave sync barrier
- * readmultiple (reg 0x0c00 and 0x0c80)
- */
- if (si->pci_0.enable_bus) {
- mv64x60_set_bits(bh, MV64x60_PCI0_CMD,
- ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
- }
-
- if (si->pci_1.enable_bus) {
- mv64x60_set_bits(bh, MV64x60_PCI1_CMD,
- ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
- }
-
- mv64x60_set_bits(bh, GT64260_CPU_WB_PRIORITY_BUFFER_DEPTH, 0xf);
-
- /*
- * The 64260B is not supposed to have the bug where the MPSC & ENET
- * can't access cache coherent regions. However, testing has shown
- * that the MPSC, at least, still has this bug.
- */
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->cache_mgmt = 1;
- }
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->cache_mgmt = 1;
- }
-
- return;
-}
-
-/*
- *****************************************************************************
- *
- * MV64360-Specific Routines
- *
- *****************************************************************************
- */
-/*
- * mv64360_translate_size()
- *
- * On the MV64360, the size register is set similar to the size you get
- * from a pci config space BAR register. That is, programmed from LSB to MSB
- * as a sequence of 1's followed by a sequence of 0's. IOW, "size -1" with the
- * assumption that the size is a power of 2.
- */
-static u32 __init
-mv64360_translate_size(u32 base_addr, u32 size, u32 num_bits)
-{
- return mv64x60_mask(size - 1, num_bits);
-}
-
-/*
- * mv64360_untranslate_size()
- *
- * Translate the size register value of a window into a window size.
- */
-static u32 __init
-mv64360_untranslate_size(u32 base_addr, u32 size, u32 num_bits)
-{
- if (size > 0) {
- size >>= (32 - num_bits);
- size++;
- size <<= (32 - num_bits);
- }
-
- return size;
-}
-
-/*
- * mv64360_set_pci2mem_window()
- *
- * The PCI->MEM window registers are actually in PCI config space so need
- * to set them by setting the correct config space BARs.
- */
-static void __init
-mv64360_set_pci2mem_window(struct pci_controller *hose, u32 window, u32 base)
-{
- struct {
- u32 fcn;
- u32 base_hi_bar;
- u32 base_lo_bar;
- } reg_addrs[] = {{ 0, 0x14, 0x10 }, { 0, 0x1c, 0x18 },
- { 1, 0x14, 0x10 }, { 1, 0x1c, 0x18 }};
-
- DBG("set pci->mem window: %d, hose: %d, base: 0x%x\n", window,
- hose->index, base);
-
- early_write_config_dword(hose, hose->first_busno,
- PCI_DEVFN(0, reg_addrs[window].fcn),
- reg_addrs[window].base_hi_bar, 0);
- early_write_config_dword(hose, hose->first_busno,
- PCI_DEVFN(0, reg_addrs[window].fcn),
- reg_addrs[window].base_lo_bar,
- mv64x60_mask(base, 20) | 0xc);
- return;
-}
-
-/*
- * mv64360_is_enabled_32bit()
- *
- * On a MV64360, a window is enabled by either clearing a bit in the
- * CPU BAR Enable reg or setting a bit in the window's base reg.
- * Note that this doesn't work for windows on the PCI slave side but we don't
- * check those so its okay.
- */
-static u32 __init
-mv64360_is_enabled_32bit(mv64x60_handle_t *bh, u32 window)
-{
- u32 rc = 0;
-
- if ((mv64360_32bit_windows[window].base_reg != 0) &&
- (mv64360_32bit_windows[window].size_reg != 0)) {
-
- if (mv64360_32bit_windows[window].extra & 0x80000000) {
- rc = (mv64x60_read(bh,
- mv64360_32bit_windows[window].base_reg) &
- (1 << (mv64360_32bit_windows[window].extra &
- 0xff))) != 0;
- }
- else {
- rc = (mv64x60_read(bh, MV64360_CPU_BAR_ENABLE) &
- (1 << mv64360_32bit_windows[window].extra)) ==0;
- }
- }
-
- if (rc) {
- DBG("32bit window %d is enabled\n", window);
- }
- else {
- DBG("32bit window %d is disabled\n", window);
- }
-
- return rc;
-}
-
-/*
- * mv64360_enable_window_32bit()
- *
- * On a MV64360, a window is enabled by either clearing a bit in the
- * CPU BAR Enable reg or setting a bit in the window's base reg.
- */
-static void __init
-mv64360_enable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("enable 32bit window: %d\n", window);
-
- if ((mv64360_32bit_windows[window].base_reg != 0) &&
- (mv64360_32bit_windows[window].size_reg != 0)) {
-
- if (mv64360_32bit_windows[window].extra & 0x80000000) {
- mv64x60_set_bits(bh,
- mv64360_32bit_windows[window].base_reg,
- (1 << (mv64360_32bit_windows[window].extra &
- 0xff)));
- }
- else {
- mv64x60_clr_bits(bh, MV64360_CPU_BAR_ENABLE,
- (1 << mv64360_32bit_windows[window].extra));
- }
- }
-
- return;
-}
-
-/*
- * mv64360_disable_window_32bit()
- *
- * On a MV64360, a window is disabled by either setting a bit in the
- * CPU BAR Enable reg or clearing a bit in the window's base reg.
- */
-static void __init
-mv64360_disable_window_32bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("disable 32bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
- window, mv64360_32bit_windows[window].base_reg,
- mv64360_32bit_windows[window].size_reg);
-
- if ((mv64360_32bit_windows[window].base_reg != 0) &&
- (mv64360_32bit_windows[window].size_reg != 0)) {
-
- if (mv64360_32bit_windows[window].extra & 0x80000000) {
- mv64x60_clr_bits(bh,
- mv64360_32bit_windows[window].base_reg,
- (1 << (mv64360_32bit_windows[window].extra &
- 0xff)));
- }
- else {
- mv64x60_set_bits(bh, MV64360_CPU_BAR_ENABLE,
- (1 << mv64360_32bit_windows[window].extra));
- }
- }
-
- return;
-}
-
-/*
- * mv64360_enable_window_64bit()
- *
- * On the MV64360, a 64-bit window is enabled by setting a bit in the window's
- * base reg.
- */
-static void __init
-mv64360_enable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("enable 64bit window: %d\n", window);
-
- /* For 64360, 'extra' field holds bit that enables the window */
- if ((mv64360_64bit_windows[window].base_lo_reg!= 0) &&
- (mv64360_64bit_windows[window].size_reg != 0)) {
-
- if (mv64360_64bit_windows[window].extra & 0x80000000) {
- mv64x60_set_bits(bh,
- mv64360_64bit_windows[window].base_lo_reg,
- (1 << (mv64360_64bit_windows[window].extra &
- 0xff)));
- } /* Should be no 'else' ones */
- }
-
- return;
-}
-
-/*
- * mv64360_disable_window_64bit()
- *
- * On a MV64360, a 64-bit window is disabled by clearing a bit in the window's
- * base reg.
- */
-static void __init
-mv64360_disable_window_64bit(mv64x60_handle_t *bh, u32 window)
-{
- DBG("disable 64bit window: %d, base_reg: 0x%x, size_reg: 0x%x\n",
- window, mv64360_64bit_windows[window].base_lo_reg,
- mv64360_64bit_windows[window].size_reg);
-
- if ((mv64360_64bit_windows[window].base_lo_reg != 0) &&
- (mv64360_64bit_windows[window].size_reg != 0)) {
-
- if (mv64360_64bit_windows[window].extra & 0x80000000) {
- mv64x60_clr_bits(bh,
- mv64360_64bit_windows[window].base_lo_reg,
- (1 << (mv64360_64bit_windows[window].extra &
- 0xff)));
- } /* Should be no 'else' ones */
- }
-
- return;
-}
-
-/*
- * mv64360_disable_all_windows()
- *
- * The MV64360 has a few windows that aren't represented in the table of
- * windows at the top of this file. This routine turns all of them off
- * except for the memory controller windows, of course.
- */
-static void __init
-mv64360_disable_all_windows(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- u32 i;
-
- /* Disable 32bit windows (don't disable cpu->mem windows) */
- for (i=MV64x60_CPU2DEV_0_WIN; i<MV64x60_32BIT_WIN_COUNT; i++) {
- if (!(si->window_preserve_mask_32 & (1<<i)))
- mv64360_disable_window_32bit(bh, i);
- }
-
- /* Disable 64bit windows */
- for (i=0; i<MV64x60_64BIT_WIN_COUNT; i++) {
- if (!(si->window_preserve_mask_64 & (1<<i)))
- mv64360_disable_window_64bit(bh, i);
- }
-
- /* Turn off PCI->MEM access cntl wins not in mv64360_64bit_windows[] */
- mv64x60_clr_bits(bh, MV64x60_PCI0_ACC_CNTL_4_BASE_LO, 0);
- mv64x60_clr_bits(bh, MV64x60_PCI0_ACC_CNTL_5_BASE_LO, 0);
- mv64x60_clr_bits(bh, MV64x60_PCI1_ACC_CNTL_4_BASE_LO, 0);
- mv64x60_clr_bits(bh, MV64x60_PCI1_ACC_CNTL_5_BASE_LO, 0);
-
- /* Disable all PCI-><whatever> windows */
- mv64x60_set_bits(bh, MV64x60_PCI0_BAR_ENABLE, 0x0000f9ff);
- mv64x60_set_bits(bh, MV64x60_PCI1_BAR_ENABLE, 0x0000f9ff);
-
- return;
-}
-
-/*
- * mv64360_chip_specific_init()
- *
- * No errata work arounds for the MV64360 implemented at this point.
- */
-static void
-mv64360_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- struct ocp_device *dev;
- mv64x60_ocp_mpsc_data_t *mpsc_dp;
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 0))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->brg_can_tune = 1;
- }
-
- if ((dev = ocp_find_device(OCP_VENDOR_MARVELL, OCP_FUNC_MPSC, 1))
- != NULL) {
- mpsc_dp = (mv64x60_ocp_mpsc_data_t *)dev->def->additions;
- mpsc_dp->brg_can_tune = 1;
- }
-
- return;
-}
-
-/*
- * mv64460_chip_specific_init()
- *
- * No errata work arounds for the MV64460 implemented at this point.
- */
-static void
-mv64460_chip_specific_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si)
-{
- mv64360_chip_specific_init(bh, si); /* XXXX check errata */
- return;
-}
+++ /dev/null
-#include <linux/stddef.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <asm/irq.h>
-#include <asm/immap_8260.h>
-#include <asm/mpc8260.h>
-#include "ppc8260_pic.h"
-
-/* The 8260 internal interrupt controller. It is usually
- * the only interrupt controller.
- * There are two 32-bit registers (high/low) for up to 64
- * possible interrupts.
- *
- * Now, the fun starts.....Interrupt Numbers DO NOT MAP
- * in a simple arithmetic fashion to mask or pending registers.
- * That is, interrupt 4 does not map to bit position 4.
- * We create two tables, indexed by vector number, to indicate
- * which register to use and which bit in the register to use.
- */
-static u_char irq_to_siureg[] = {
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-static u_char irq_to_siubit[] = {
- 31, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30,
- 29, 30, 16, 17, 18, 19, 20, 21,
- 22, 23, 24, 25, 26, 27, 28, 31,
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 15, 14, 13, 12, 11, 10, 9, 8,
- 7, 6, 5, 4, 3, 2, 1, 0
-};
-
-static void m8260_mask_irq(unsigned int irq_nr)
-{
- int bit, word;
- volatile uint *simr;
-
- bit = irq_to_siubit[irq_nr];
- word = irq_to_siureg[irq_nr];
-
- simr = &(immr->im_intctl.ic_simrh);
- ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
- simr[word] = ppc_cached_irq_mask[word];
-}
-
-static void m8260_unmask_irq(unsigned int irq_nr)
-{
- int bit, word;
- volatile uint *simr;
-
- bit = irq_to_siubit[irq_nr];
- word = irq_to_siureg[irq_nr];
-
- simr = &(immr->im_intctl.ic_simrh);
- ppc_cached_irq_mask[word] |= (1 << (31 - bit));
- simr[word] = ppc_cached_irq_mask[word];
-}
-
-static void m8260_mask_and_ack(unsigned int irq_nr)
-{
- int bit, word;
- volatile uint *simr, *sipnr;
-
- bit = irq_to_siubit[irq_nr];
- word = irq_to_siureg[irq_nr];
-
- simr = &(immr->im_intctl.ic_simrh);
- sipnr = &(immr->im_intctl.ic_sipnrh);
- ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
- simr[word] = ppc_cached_irq_mask[word];
- sipnr[word] = 1 << (31 - bit);
-}
-
-static void m8260_end_irq(unsigned int irq_nr)
-{
- int bit, word;
- volatile uint *simr;
-
- if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))
- && irq_desc[irq_nr].action) {
-
- bit = irq_to_siubit[irq_nr];
- word = irq_to_siureg[irq_nr];
-
- simr = &(immr->im_intctl.ic_simrh);
- ppc_cached_irq_mask[word] |= (1 << (31 - bit));
- simr[word] = ppc_cached_irq_mask[word];
- }
-}
-
-struct hw_interrupt_type ppc8260_pic = {
- " 8260 SIU ",
- NULL,
- NULL,
- m8260_unmask_irq,
- m8260_mask_irq,
- m8260_mask_and_ack,
- m8260_end_irq,
- 0
-};
-
-
-int
-m8260_get_irq(struct pt_regs *regs)
-{
- int irq;
- unsigned long bits;
-
- /* For MPC8260, read the SIVEC register and shift the bits down
- * to get the irq number. */
- bits = immr->im_intctl.ic_sivec;
- irq = bits >> 26;
-
- if (irq == 0)
- return(-1);
-#if 0
- irq += ppc8260_pic.irq_offset;
-#endif
- return irq;
-}
-
+++ /dev/null
-#ifndef _PPC_KERNEL_PPC8260_H
-#define _PPC_KERNEL_PPC8260_H
-
-#include <linux/irq.h>
-
-extern struct hw_interrupt_type ppc8260_pic;
-
-void m8260_pic_init(void);
-void m8260_do_IRQ(struct pt_regs *regs,
- int cpu);
-int m8260_get_irq(struct pt_regs *regs);
-
-#endif /* _PPC_KERNEL_PPC8260_H */
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <byteswap.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-
-void xlate( char * inb, char * trb, unsigned len )
-{
- unsigned i;
- for ( i=0; i<len; ++i )
- {
- char c = *inb++;
- char c1 = c >> 4;
- char c2 = c & 0xf;
- if ( c1 > 9 )
- c1 = c1 + 'A' - 10;
- else
- c1 = c1 + '0';
- if ( c2 > 9 )
- c2 = c2 + 'A' - 10;
- else
- c2 = c2 + '0';
- *trb++ = c1;
- *trb++ = c2;
- }
- *trb = 0;
-}
-
-#define ElfHeaderSize (64 * 1024)
-#define ElfPages (ElfHeaderSize / 4096)
-
-void get4k( /*istream *inf*/FILE *file, char *buf )
-{
- unsigned j;
- unsigned num = fread(buf, 1, 4096, file);
- for ( j=num; j<4096; ++j )
- buf[j] = 0;
-}
-
-void put4k( /*ostream *outf*/FILE *file, char *buf )
-{
- fwrite(buf, 1, 4096, file);
-}
-
-int main(int argc, char **argv)
-{
- char inbuf[4096];
- FILE *sysmap = NULL;
- char* ptr_end = NULL;
- FILE *inputVmlinux = NULL;
- FILE *outputVmlinux = NULL;
- long i = 0;
- unsigned long sysmapFileLen = 0;
- unsigned long sysmapLen = 0;
- unsigned long roundR = 0;
- unsigned long kernelLen = 0;
- unsigned long actualKernelLen = 0;
- unsigned long round = 0;
- unsigned long roundedKernelLen = 0;
- unsigned long sysmapStartOffs = 0;
- unsigned long sysmapPages = 0;
- unsigned long roundedKernelPages = 0;
- long padPages = 0;
- if ( argc < 2 )
- {
- fprintf(stderr, "Name of System Map file missing.\n");
- exit(1);
- }
-
- if ( argc < 3 )
- {
- fprintf(stderr, "Name of vmlinux file missing.\n");
- exit(1);
- }
-
- if ( argc < 4 )
- {
- fprintf(stderr, "Name of vmlinux output file missing.\n");
- exit(1);
- }
-
- sysmap = fopen(argv[1], "r");
- if ( ! sysmap )
- {
- fprintf(stderr, "System Map file \"%s\" failed to open.\n", argv[1]);
- exit(1);
- }
- inputVmlinux = fopen(argv[2], "r");
- if ( ! inputVmlinux )
- {
- fprintf(stderr, "vmlinux file \"%s\" failed to open.\n", argv[2]);
- exit(1);
- }
- outputVmlinux = fopen(argv[3], "w");
- if ( ! outputVmlinux )
- {
- fprintf(stderr, "output vmlinux file \"%s\" failed to open.\n", argv[3]);
- exit(1);
- }
-
-
-
- fseek(inputVmlinux, 0, SEEK_END);
- kernelLen = ftell(inputVmlinux);
- fseek(inputVmlinux, 0, SEEK_SET);
- printf("kernel file size = %ld\n", kernelLen);
- if ( kernelLen == 0 )
- {
- fprintf(stderr, "You must have a linux kernel specified as argv[2]\n");
- exit(1);
- }
-
-
- actualKernelLen = kernelLen - ElfHeaderSize;
-
- printf("actual kernel length (minus ELF header) = %ld/%lxx \n", actualKernelLen, actualKernelLen);
-
- round = actualKernelLen % 4096;
- roundedKernelLen = actualKernelLen;
- if ( round )
- roundedKernelLen += (4096 - round);
-
- printf("Kernel length rounded up to a 4k multiple = %ld/%lxx \n", roundedKernelLen, roundedKernelLen);
- roundedKernelPages = roundedKernelLen / 4096;
- printf("Kernel pages to copy = %ld/%lxx\n", roundedKernelPages, roundedKernelPages);
-
-
-
- /* Sysmap file */
- fseek(sysmap, 0, SEEK_END);
- sysmapFileLen = ftell(sysmap);
- fseek(sysmap, 0, SEEK_SET);
- printf("%s file size = %ld\n", argv[1], sysmapFileLen);
-
- sysmapLen = sysmapFileLen;
-
- roundR = 4096 - (sysmapLen % 4096);
- if (roundR)
- {
- printf("Rounding System Map file up to a multiple of 4096, adding %ld\n", roundR);
- sysmapLen += roundR;
- }
- printf("Rounded System Map size is %ld\n", sysmapLen);
-
- /* Process the Sysmap file to determine the true end of the kernel */
- sysmapPages = sysmapLen / 4096;
- printf("System map pages to copy = %ld\n", sysmapPages);
- /* read the whole file line by line, expect that it doesn't fail */
- while ( fgets(inbuf, 4096, sysmap) ) ;
- /* search for _end in the last page of the system map */
- ptr_end = strstr(inbuf, " _end");
- if (!ptr_end)
- {
- fprintf(stderr, "Unable to find _end in the sysmap file \n");
- fprintf(stderr, "inbuf: \n");
- fprintf(stderr, "%s \n", inbuf);
- exit(1);
- }
- printf("Found _end in the last page of the sysmap - backing up 10 characters it looks like %s", ptr_end-10);
- sysmapStartOffs = (unsigned int)strtol(ptr_end-10, NULL, 16);
- /* calc how many pages we need to insert between the vmlinux and the start of the sysmap */
- padPages = sysmapStartOffs/4096 - roundedKernelPages;
-
- /* Check and see if the vmlinux is larger than _end in System.map */
- if (padPages < 0)
- { /* vmlinux is larger than _end - adjust the offset to start the embedded system map */
- sysmapStartOffs = roundedKernelLen;
- printf("vmlinux is larger than _end indicates it needs to be - sysmapStartOffs = %lx \n", sysmapStartOffs);
- padPages = 0;
- printf("will insert %lx pages between the vmlinux and the start of the sysmap \n", padPages);
- }
- else
- { /* _end is larger than vmlinux - use the sysmapStartOffs we calculated from the system map */
- printf("vmlinux is smaller than _end indicates is needed - sysmapStartOffs = %lx \n", sysmapStartOffs);
- printf("will insert %lx pages between the vmlinux and the start of the sysmap \n", padPages);
- }
-
-
-
-
- /* Copy 64K ELF header */
- for (i=0; i<(ElfPages); ++i)
- {
- get4k( inputVmlinux, inbuf );
- put4k( outputVmlinux, inbuf );
- }
-
-
- /* Copy the vmlinux (as full pages). */
- fseek(inputVmlinux, ElfHeaderSize, SEEK_SET);
- for ( i=0; i<roundedKernelPages; ++i )
- {
- get4k( inputVmlinux, inbuf );
-
- /* Set the offsets (of the start and end) of the embedded sysmap so it is set in the vmlinux.sm */
- if ( i == 0 )
- {
- unsigned long * p;
- printf("Storing embedded_sysmap_start at 0x3c\n");
- p = (unsigned long *)(inbuf + 0x3c);
-
-#if (BYTE_ORDER == __BIG_ENDIAN)
- *p = sysmapStartOffs;
-#else
- *p = bswap_32(sysmapStartOffs);
-#endif
-
- printf("Storing embedded_sysmap_end at 0x44\n");
- p = (unsigned long *)(inbuf + 0x44);
-
-#if (BYTE_ORDER == __BIG_ENDIAN)
- *p = sysmapStartOffs + sysmapFileLen;
-#else
- *p = bswap_32(sysmapStartOffs + sysmapFileLen);
-#endif
- }
-
- put4k( outputVmlinux, inbuf );
- }
-
-
- /* Insert any pad pages between the end of the vmlinux and where the system map needs to be. */
- for (i=0; i<padPages; ++i)
- {
- memset(inbuf, 0, 4096);
- put4k(outputVmlinux, inbuf);
- }
-
-
- /* Copy the system map (as full pages). */
- fseek(sysmap, 0, SEEK_SET); /* start reading from begining of the system map */
- for ( i=0; i<sysmapPages; ++i )
- {
- get4k( sysmap, inbuf );
- put4k( outputVmlinux, inbuf );
- }
-
-
- fclose(sysmap);
- fclose(inputVmlinux);
- fclose(outputVmlinux);
- /* Set permission to executable */
- chmod(argv[3], S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
-
- return 0;
-}
-
+++ /dev/null
-/*
- * linux/arch/ppc/kernel/setup.c
- *
- * Copyright (C) 1995 Linus Torvalds
- * Adapted from 'alpha' version by Gary Thomas
- * Modified by Cort Dougan (cort@cs.nmt.edu)
- * Modified by PPC64 Team, IBM Corp
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * bootup setup stuff..
- */
-
-#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/stddef.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/user.h>
-#include <linux/a.out.h>
-#include <linux/tty.h>
-#include <linux/major.h>
-#include <linux/interrupt.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/console.h>
-#include <linux/pci.h>
-#include <linux/version.h>
-#include <linux/adb.h>
-#include <linux/module.h>
-#include <linux/delay.h>
-
-#include <linux/irq.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-
-#include <asm/mmu.h>
-#include <asm/processor.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/prom.h>
-#include <asm/rtas.h>
-#include <asm/pci-bridge.h>
-#include <asm/iommu.h>
-#include <asm/dma.h>
-#include <asm/machdep.h>
-#include <asm/irq.h>
-#include <asm/naca.h>
-#include <asm/time.h>
-#include <asm/nvram.h>
-
-#include "i8259.h"
-#include "open_pic.h"
-#include <asm/xics.h>
-#include <asm/ppcdebug.h>
-#include <asm/cputable.h>
-
-void chrp_progress(char *, unsigned short);
-
-extern void pSeries_init_openpic(void);
-
-extern void find_and_init_phbs(void);
-extern void pSeries_final_fixup(void);
-
-extern void pSeries_get_boot_time(struct rtc_time *rtc_time);
-extern void pSeries_get_rtc_time(struct rtc_time *rtc_time);
-extern int pSeries_set_rtc_time(struct rtc_time *rtc_time);
-void pSeries_calibrate_decr(void);
-void fwnmi_init(void);
-extern void SystemReset_FWNMI(void), MachineCheck_FWNMI(void); /* from head.S */
-int fwnmi_active; /* TRUE if an FWNMI handler is present */
-
-dev_t boot_dev;
-unsigned long virtPython0Facilities = 0; // python0 facility area (memory mapped io) (64-bit format) VIRTUAL address.
-
-extern unsigned long loops_per_jiffy;
-
-extern unsigned long ppc_proc_freq;
-extern unsigned long ppc_tb_freq;
-
-void chrp_get_cpuinfo(struct seq_file *m)
-{
- struct device_node *root;
- const char *model = "";
-
- root = of_find_node_by_path("/");
- if (root)
- model = get_property(root, "model", NULL);
- seq_printf(m, "machine\t\t: CHRP %s\n", model);
- of_node_put(root);
-}
-
-#define I8042_DATA_REG 0x60
-
-void __init chrp_request_regions(void)
-{
- struct device_node *i8042;
-
- request_region(0x20,0x20,"pic1");
- request_region(0xa0,0x20,"pic2");
- request_region(0x00,0x20,"dma1");
- request_region(0x40,0x20,"timer");
- request_region(0x80,0x10,"dma page reg");
- request_region(0xc0,0x20,"dma2");
-
- /*
- * Some machines have an unterminated i8042 so check the device
- * tree and reserve the region if it does not appear. Later on
- * the i8042 code will try and reserve this region and fail.
- */
- if (!(i8042 = of_find_node_by_type(NULL, "8042")))
- request_region(I8042_DATA_REG, 16, "reserved (no i8042)");
- of_node_put(i8042);
-}
-
-void __init
-chrp_setup_arch(void)
-{
- struct device_node *root;
- unsigned int *opprop;
-
- /* openpic global configuration register (64-bit format). */
- /* openpic Interrupt Source Unit pointer (64-bit format). */
- /* python0 facility area (mmio) (64-bit format) REAL address. */
-
- /* init to some ~sane value until calibrate_delay() runs */
- loops_per_jiffy = 50000000;
-
- if (ROOT_DEV == 0) {
- printk("No ramdisk, default root is /dev/sda2\n");
- ROOT_DEV = Root_SDA2;
- }
-
- printk("Boot arguments: %s\n", cmd_line);
-
- fwnmi_init();
-
-#ifndef CONFIG_PPC_ISERIES
- /* Find and initialize PCI host bridges */
- /* iSeries needs to be done much later. */
- eeh_init();
- find_and_init_phbs();
-#endif
-
- /* Find the Open PIC if present */
- root = of_find_node_by_path("/");
- opprop = (unsigned int *) get_property(root,
- "platform-open-pic", NULL);
- if (opprop != 0) {
- int n = prom_n_addr_cells(root);
- unsigned long openpic;
-
- for (openpic = 0; n > 0; --n)
- openpic = (openpic << 32) + *opprop++;
- printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic);
- OpenPIC_Addr = __ioremap(openpic, 0x40000, _PAGE_NO_CACHE);
- }
- of_node_put(root);
-
-#ifdef CONFIG_DUMMY_CONSOLE
- conswitchp = &dummy_con;
-#endif
-
-#ifdef CONFIG_PPC_PSERIES
- pSeries_nvram_init();
-#endif
-}
-
-void __init
-chrp_init2(void)
-{
- /* Manually leave the kernel version on the panel. */
- ppc_md.progress("Linux ppc64\n", 0);
- ppc_md.progress(UTS_RELEASE, 0);
-}
-
-/* Initialize firmware assisted non-maskable interrupts if
- * the firmware supports this feature.
- *
- */
-void __init fwnmi_init(void)
-{
- int ret;
- int ibm_nmi_register = rtas_token("ibm,nmi-register");
- if (ibm_nmi_register == RTAS_UNKNOWN_SERVICE)
- return;
- ret = rtas_call(ibm_nmi_register, 2, 1, NULL,
- __pa((unsigned long)SystemReset_FWNMI),
- __pa((unsigned long)MachineCheck_FWNMI));
- if (ret == 0)
- fwnmi_active = 1;
-}
-
-/* Early initialization. Relocation is on but do not reference unbolted pages */
-void __init pSeries_init_early(void)
-{
- void *comport;
-
- hpte_init_pSeries();
-
- if (ppc64_iommu_off)
- pci_dma_init_direct();
- else
- tce_init_pSeries();
-
-#ifdef CONFIG_SMP
- smp_init_pSeries();
-#endif
-
- /* Map the uart for udbg. */
- comport = (void *)__ioremap(naca->serialPortAddr, 16, _PAGE_NO_CACHE);
- udbg_init_uart(comport);
-
- ppc_md.udbg_putc = udbg_putc;
- ppc_md.udbg_getc = udbg_getc;
- ppc_md.udbg_getc_poll = udbg_getc_poll;
-}
-
-void __init
-chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7)
-{
- struct device_node * dn;
- char * hypertas;
- unsigned int len;
-
- ppc_md.setup_arch = chrp_setup_arch;
- ppc_md.get_cpuinfo = chrp_get_cpuinfo;
- if (naca->interrupt_controller == IC_OPEN_PIC) {
- ppc_md.init_IRQ = pSeries_init_openpic;
- ppc_md.get_irq = openpic_get_irq;
- } else {
- ppc_md.init_IRQ = xics_init_IRQ;
- ppc_md.get_irq = xics_get_irq;
- }
-
- ppc_md.log_error = pSeries_log_error;
-
- ppc_md.init = chrp_init2;
-
- ppc_md.pcibios_fixup = pSeries_final_fixup;
-
- ppc_md.restart = rtas_restart;
- ppc_md.power_off = rtas_power_off;
- ppc_md.halt = rtas_halt;
- ppc_md.panic = rtas_os_term;
-
- ppc_md.get_boot_time = pSeries_get_boot_time;
- ppc_md.get_rtc_time = pSeries_get_rtc_time;
- ppc_md.set_rtc_time = pSeries_set_rtc_time;
- ppc_md.calibrate_decr = pSeries_calibrate_decr;
-
- ppc_md.progress = chrp_progress;
-
- /* Build up the firmware_features bitmask field
- * using contents of device-tree/ibm,hypertas-functions.
- * Ultimately this functionality may be moved into prom.c prom_init().
- */
- cur_cpu_spec->firmware_features = 0;
- dn = of_find_node_by_path("/rtas");
- if (dn == NULL) {
- printk(KERN_ERR "WARNING ! Cannot find RTAS in device-tree !\n");
- goto no_rtas;
- }
-
- hypertas = get_property(dn, "ibm,hypertas-functions", &len);
- if (hypertas) {
- while (len > 0){
- int i, hypertas_len;
- /* check value against table of strings */
- for(i=0; i < FIRMWARE_MAX_FEATURES ;i++) {
- if ((firmware_features_table[i].name) &&
- (strcmp(firmware_features_table[i].name,hypertas))==0) {
- /* we have a match */
- cur_cpu_spec->firmware_features |=
- (firmware_features_table[i].val);
- break;
- }
- }
- hypertas_len = strlen(hypertas);
- len -= hypertas_len +1;
- hypertas+= hypertas_len +1;
- }
- }
-
- of_node_put(dn);
- no_rtas:
- printk(KERN_INFO "firmware_features = 0x%lx\n",
- cur_cpu_spec->firmware_features);
-}
-
-void chrp_progress(char *s, unsigned short hex)
-{
- struct device_node *root;
- int width, *p;
- char *os;
- static int display_character, set_indicator;
- static int max_width;
- static spinlock_t progress_lock = SPIN_LOCK_UNLOCKED;
- static int pending_newline = 0; /* did last write end with unprinted newline? */
-
- if (!rtas.base)
- return;
-
- if (max_width == 0) {
- if ((root = find_path_device("/rtas")) &&
- (p = (unsigned int *)get_property(root,
- "ibm,display-line-length",
- NULL)))
- max_width = *p;
- else
- max_width = 0x10;
- display_character = rtas_token("display-character");
- set_indicator = rtas_token("set-indicator");
- }
-
- if (display_character == RTAS_UNKNOWN_SERVICE) {
- /* use hex display if available */
- if (set_indicator != RTAS_UNKNOWN_SERVICE)
- rtas_call(set_indicator, 3, 1, NULL, 6, 0, hex);
- return;
- }
-
- spin_lock(&progress_lock);
-
- /*
- * Last write ended with newline, but we didn't print it since
- * it would just clear the bottom line of output. Print it now
- * instead.
- *
- * If no newline is pending, print a CR to start output at the
- * beginning of the line.
- */
- if (pending_newline) {
- rtas_call(display_character, 1, 1, NULL, '\r');
- rtas_call(display_character, 1, 1, NULL, '\n');
- pending_newline = 0;
- } else {
- rtas_call(display_character, 1, 1, NULL, '\r');
- }
-
- width = max_width;
- os = s;
- while (*os) {
- if (*os == '\n' || *os == '\r') {
- /* Blank to end of line. */
- while (width-- > 0)
- rtas_call(display_character, 1, 1, NULL, ' ');
-
- /* If newline is the last character, save it
- * until next call to avoid bumping up the
- * display output.
- */
- if (*os == '\n' && !os[1]) {
- pending_newline = 1;
- spin_unlock(&progress_lock);
- return;
- }
-
- /* RTAS wants CR-LF, not just LF */
-
- if (*os == '\n') {
- rtas_call(display_character, 1, 1, NULL, '\r');
- rtas_call(display_character, 1, 1, NULL, '\n');
- } else {
- /* CR might be used to re-draw a line, so we'll
- * leave it alone and not add LF.
- */
- rtas_call(display_character, 1, 1, NULL, *os);
- }
-
- width = max_width;
- } else {
- width--;
- rtas_call(display_character, 1, 1, NULL, *os);
- }
-
- os++;
-
- /* if we overwrite the screen length */
- if (width <= 0)
- while ((*os != 0) && (*os != '\n') && (*os != '\r'))
- os++;
- }
-
- /* Blank to end of line. */
- while (width-- > 0)
- rtas_call(display_character, 1, 1, NULL, ' ');
-
- spin_unlock(&progress_lock);
-}
-
-extern void setup_default_decr(void);
-
-/* Some sane defaults: 125 MHz timebase, 1GHz processor */
-#define DEFAULT_TB_FREQ 125000000UL
-#define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8)
-
-void __init pSeries_calibrate_decr(void)
-{
- struct device_node *cpu;
- struct div_result divres;
- unsigned int *fp;
- int node_found;
-
- /*
- * The cpu node should have a timebase-frequency property
- * to tell us the rate at which the decrementer counts.
- */
- cpu = of_find_node_by_type(NULL, "cpu");
-
- ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
- node_found = 0;
- if (cpu != 0) {
- fp = (unsigned int *)get_property(cpu, "timebase-frequency",
- NULL);
- if (fp != 0) {
- node_found = 1;
- ppc_tb_freq = *fp;
- }
- }
- if (!node_found)
- printk(KERN_ERR "WARNING: Estimating decrementer frequency "
- "(not found)\n");
-
- ppc_proc_freq = DEFAULT_PROC_FREQ;
- node_found = 0;
- if (cpu != 0) {
- fp = (unsigned int *)get_property(cpu, "clock-frequency",
- NULL);
- if (fp != 0) {
- node_found = 1;
- ppc_proc_freq = *fp;
- }
- }
- if (!node_found)
- printk(KERN_ERR "WARNING: Estimating processor frequency "
- "(not found)\n");
-
- of_node_put(cpu);
-
- printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
- ppc_tb_freq/1000000, ppc_tb_freq%1000000);
- printk(KERN_INFO "time_init: processor frequency = %lu.%.6lu MHz\n",
- ppc_proc_freq/1000000, ppc_proc_freq%1000000);
-
- tb_ticks_per_jiffy = ppc_tb_freq / HZ;
- tb_ticks_per_sec = tb_ticks_per_jiffy * HZ;
- tb_ticks_per_usec = ppc_tb_freq / 1000000;
- tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
- div128_by_32(1024*1024, 0, tb_ticks_per_sec, &divres);
- tb_to_xs = divres.result_low;
-
- setup_default_decr();
-}
+++ /dev/null
-/*
- * pSeries hashtable management.
- *
- * SMP scalability work:
- * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <linux/spinlock.h>
-#include <linux/bitops.h>
-#include <linux/threads.h>
-#include <linux/smp.h>
-
-#include <asm/abs_addr.h>
-#include <asm/machdep.h>
-#include <asm/mmu.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
-#include <asm/tlbflush.h>
-#include <asm/tlb.h>
-#include <asm/cputable.h>
-
-#define HPTE_LOCK_BIT 3
-
-static inline void pSeries_lock_hpte(HPTE *hptep)
-{
- unsigned long *word = &hptep->dw0.dword0;
-
- while (1) {
- if (!test_and_set_bit(HPTE_LOCK_BIT, word))
- break;
- while(test_bit(HPTE_LOCK_BIT, word))
- cpu_relax();
- }
-}
-
-static inline void pSeries_unlock_hpte(HPTE *hptep)
-{
- unsigned long *word = &hptep->dw0.dword0;
-
- asm volatile("lwsync":::"memory");
- clear_bit(HPTE_LOCK_BIT, word);
-}
-
-static spinlock_t pSeries_tlbie_lock = SPIN_LOCK_UNLOCKED;
-
-long pSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
- unsigned long prpn, int secondary,
- unsigned long hpteflags, int bolted, int large)
-{
- unsigned long arpn = physRpn_to_absRpn(prpn);
- HPTE *hptep = htab_data.htab + hpte_group;
- Hpte_dword0 dw0;
- HPTE lhpte;
- int i;
-
- for (i = 0; i < HPTES_PER_GROUP; i++) {
- dw0 = hptep->dw0.dw0;
-
- if (!dw0.v) {
- /* retry with lock held */
- pSeries_lock_hpte(hptep);
- dw0 = hptep->dw0.dw0;
- if (!dw0.v)
- break;
- pSeries_unlock_hpte(hptep);
- }
-
- hptep++;
- }
-
- if (i == HPTES_PER_GROUP)
- return -1;
-
- lhpte.dw1.dword1 = 0;
- lhpte.dw1.dw1.rpn = arpn;
- lhpte.dw1.flags.flags = hpteflags;
-
- lhpte.dw0.dword0 = 0;
- lhpte.dw0.dw0.avpn = va >> 23;
- lhpte.dw0.dw0.h = secondary;
- lhpte.dw0.dw0.bolted = bolted;
- lhpte.dw0.dw0.v = 1;
-
- if (large) {
- lhpte.dw0.dw0.l = 1;
- lhpte.dw0.dw0.avpn &= ~0x1UL;
- }
-
- hptep->dw1.dword1 = lhpte.dw1.dword1;
-
- /* Guarantee the second dword is visible before the valid bit */
- __asm__ __volatile__ ("eieio" : : : "memory");
-
- /*
- * Now set the first dword including the valid bit
- * NOTE: this also unlocks the hpte
- */
- hptep->dw0.dword0 = lhpte.dw0.dword0;
-
- __asm__ __volatile__ ("ptesync" : : : "memory");
-
- return i | (secondary << 3);
-}
-
-static long pSeries_hpte_remove(unsigned long hpte_group)
-{
- HPTE *hptep;
- Hpte_dword0 dw0;
- int i;
- int slot_offset;
-
- /* pick a random entry to start at */
- slot_offset = mftb() & 0x7;
-
- for (i = 0; i < HPTES_PER_GROUP; i++) {
- hptep = htab_data.htab + hpte_group + slot_offset;
- dw0 = hptep->dw0.dw0;
-
- if (dw0.v && !dw0.bolted) {
- /* retry with lock held */
- pSeries_lock_hpte(hptep);
- dw0 = hptep->dw0.dw0;
- if (dw0.v && !dw0.bolted)
- break;
- pSeries_unlock_hpte(hptep);
- }
-
- slot_offset++;
- slot_offset &= 0x7;
- }
-
- if (i == HPTES_PER_GROUP)
- return -1;
-
- /* Invalidate the hpte. NOTE: this also unlocks it */
- hptep->dw0.dword0 = 0;
-
- return i;
-}
-
-static inline void set_pp_bit(unsigned long pp, HPTE *addr)
-{
- unsigned long old;
- unsigned long *p = &addr->dw1.dword1;
-
- __asm__ __volatile__(
- "1: ldarx %0,0,%3\n\
- rldimi %0,%2,0,61\n\
- stdcx. %0,0,%3\n\
- bne 1b"
- : "=&r" (old), "=m" (*p)
- : "r" (pp), "r" (p), "m" (*p)
- : "cc");
-}
-
-/*
- * Only works on small pages. Yes its ugly to have to check each slot in
- * the group but we only use this during bootup.
- */
-static long pSeries_hpte_find(unsigned long vpn)
-{
- HPTE *hptep;
- unsigned long hash;
- unsigned long i, j;
- long slot;
- Hpte_dword0 dw0;
-
- hash = hpt_hash(vpn, 0);
-
- for (j = 0; j < 2; j++) {
- slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
- for (i = 0; i < HPTES_PER_GROUP; i++) {
- hptep = htab_data.htab + slot;
- dw0 = hptep->dw0.dw0;
-
- if ((dw0.avpn == (vpn >> 11)) && dw0.v &&
- (dw0.h == j)) {
- /* HPTE matches */
- if (j)
- slot = -slot;
- return slot;
- }
- ++slot;
- }
- hash = ~hash;
- }
-
- return -1;
-}
-
-static long pSeries_hpte_updatepp(unsigned long slot, unsigned long newpp,
- unsigned long va, int large, int local)
-{
- HPTE *hptep = htab_data.htab + slot;
- Hpte_dword0 dw0;
- unsigned long avpn = va >> 23;
- int ret = 0;
-
- if (large)
- avpn &= ~0x1UL;
-
- pSeries_lock_hpte(hptep);
-
- dw0 = hptep->dw0.dw0;
-
- /* Even if we miss, we need to invalidate the TLB */
- if ((dw0.avpn != avpn) || !dw0.v) {
- pSeries_unlock_hpte(hptep);
- ret = -1;
- } else {
- set_pp_bit(newpp, hptep);
- pSeries_unlock_hpte(hptep);
- }
-
- /* Ensure it is out of the tlb too */
- if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
- tlbiel(va);
- } else {
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_lock(&pSeries_tlbie_lock);
- tlbie(va, large);
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_unlock(&pSeries_tlbie_lock);
- }
-
- return ret;
-}
-
-/*
- * Update the page protection bits. Intended to be used to create
- * guard pages for kernel data structures on pages which are bolted
- * in the HPT. Assumes pages being operated on will not be stolen.
- * Does not work on large pages.
- *
- * No need to lock here because we should be the only user.
- */
-static void pSeries_hpte_updateboltedpp(unsigned long newpp, unsigned long ea)
-{
- unsigned long vsid, va, vpn, flags;
- long slot;
- HPTE *hptep;
-
- vsid = get_kernel_vsid(ea);
- va = (vsid << 28) | (ea & 0x0fffffff);
- vpn = va >> PAGE_SHIFT;
-
- slot = pSeries_hpte_find(vpn);
- if (slot == -1)
- panic("could not find page to bolt\n");
- hptep = htab_data.htab + slot;
-
- set_pp_bit(newpp, hptep);
-
- /* Ensure it is out of the tlb too */
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_lock_irqsave(&pSeries_tlbie_lock, flags);
- tlbie(va, 0);
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_unlock_irqrestore(&pSeries_tlbie_lock, flags);
-}
-
-static void pSeries_hpte_invalidate(unsigned long slot, unsigned long va,
- int large, int local)
-{
- HPTE *hptep = htab_data.htab + slot;
- Hpte_dword0 dw0;
- unsigned long avpn = va >> 23;
- unsigned long flags;
-
- if (large)
- avpn &= ~0x1UL;
-
- local_irq_save(flags);
- pSeries_lock_hpte(hptep);
-
- dw0 = hptep->dw0.dw0;
-
- /* Even if we miss, we need to invalidate the TLB */
- if ((dw0.avpn != avpn) || !dw0.v) {
- pSeries_unlock_hpte(hptep);
- } else {
- /* Invalidate the hpte. NOTE: this also unlocks it */
- hptep->dw0.dword0 = 0;
- }
-
- /* Invalidate the tlb */
- if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
- tlbiel(va);
- } else {
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_lock(&pSeries_tlbie_lock);
- tlbie(va, large);
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_unlock(&pSeries_tlbie_lock);
- }
- local_irq_restore(flags);
-}
-
-static void pSeries_flush_hash_range(unsigned long context,
- unsigned long number, int local)
-{
- unsigned long vsid, vpn, va, hash, secondary, slot, flags, avpn;
- int i, j;
- HPTE *hptep;
- Hpte_dword0 dw0;
- struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
-
- /* XXX fix for large ptes */
- unsigned long large = 0;
-
- local_irq_save(flags);
-
- j = 0;
- for (i = 0; i < number; i++) {
- if ((batch->addr[i] >= USER_START) &&
- (batch->addr[i] <= USER_END))
- vsid = get_vsid(context, batch->addr[i]);
- else
- vsid = get_kernel_vsid(batch->addr[i]);
-
- va = (vsid << 28) | (batch->addr[i] & 0x0fffffff);
- batch->vaddr[j] = va;
- if (large)
- vpn = va >> LARGE_PAGE_SHIFT;
- else
- vpn = va >> PAGE_SHIFT;
- hash = hpt_hash(vpn, large);
- secondary = (pte_val(batch->pte[i]) & _PAGE_SECONDARY) >> 15;
- if (secondary)
- hash = ~hash;
- slot = (hash & htab_data.htab_hash_mask) * HPTES_PER_GROUP;
- slot += (pte_val(batch->pte[i]) & _PAGE_GROUP_IX) >> 12;
-
- hptep = htab_data.htab + slot;
-
- avpn = va >> 23;
- if (large)
- avpn &= ~0x1UL;
-
- pSeries_lock_hpte(hptep);
-
- dw0 = hptep->dw0.dw0;
-
- /* Even if we miss, we need to invalidate the TLB */
- if ((dw0.avpn != avpn) || !dw0.v) {
- pSeries_unlock_hpte(hptep);
- } else {
- /* Invalidate the hpte. NOTE: this also unlocks it */
- hptep->dw0.dword0 = 0;
- }
-
- j++;
- }
-
- if ((cur_cpu_spec->cpu_features & CPU_FTR_TLBIEL) && !large && local) {
- asm volatile("ptesync":::"memory");
-
- for (i = 0; i < j; i++)
- __tlbiel(batch->vaddr[i]);
-
- asm volatile("ptesync":::"memory");
- } else {
- /* XXX double check that it is safe to take this late */
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_lock(&pSeries_tlbie_lock);
-
- asm volatile("ptesync":::"memory");
-
- for (i = 0; i < j; i++)
- __tlbie(batch->vaddr[i], 0);
-
- asm volatile("eieio; tlbsync; ptesync":::"memory");
-
- if (!(cur_cpu_spec->cpu_features & CPU_FTR_LOCKLESS_TLBIE))
- spin_unlock(&pSeries_tlbie_lock);
- }
-
- local_irq_restore(flags);
-}
-
-void hpte_init_pSeries(void)
-{
- struct device_node *root;
- const char *model;
-
- ppc_md.hpte_invalidate = pSeries_hpte_invalidate;
- ppc_md.hpte_updatepp = pSeries_hpte_updatepp;
- ppc_md.hpte_updateboltedpp = pSeries_hpte_updateboltedpp;
- ppc_md.hpte_insert = pSeries_hpte_insert;
- ppc_md.hpte_remove = pSeries_hpte_remove;
-
- /* Disable TLB batching on nighthawk */
- root = of_find_node_by_path("/");
- if (root) {
- model = get_property(root, "model", NULL);
- if (!strcmp(model, "CHRP IBM,9076-N81")) {
- of_node_put(root);
- return;
- }
- of_node_put(root);
- }
-
- ppc_md.flush_hash_range = pSeries_flush_hash_range;
-}
+++ /dev/null
-/*
- * arch/ppc64/kernel/pmac_iommu.c
- *
- * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation
- *
- * Based on pSeries_iommu.c:
- * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
- * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation
- *
- * Dynamic DMA mapping support, PowerMac G5 (DART)-specific parts.
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#include <linux/vmalloc.h>
-#include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/rtas.h>
-#include <asm/ppcdebug.h>
-#include <asm/iommu.h>
-#include <asm/pci-bridge.h>
-#include <asm/machdep.h>
-#include <asm/abs_addr.h>
-#include <asm/cacheflush.h>
-#include "pci.h"
-
-
-/* physical base of DART registers */
-#define DART_BASE 0xf8033000UL
-
-/* Offset from base to control register */
-#define DARTCNTL 0
-/* Offset from base to exception register */
-#define DARTEXCP 0x10
-/* Offset from base to TLB tag registers */
-#define DARTTAG 0x1000
-
-
-/* Control Register fields */
-
-/* base address of table (pfn) */
-#define DARTCNTL_BASE_MASK 0xfffff
-#define DARTCNTL_BASE_SHIFT 12
-
-#define DARTCNTL_FLUSHTLB 0x400
-#define DARTCNTL_ENABLE 0x200
-
-/* size of table in pages */
-#define DARTCNTL_SIZE_MASK 0x1ff
-#define DARTCNTL_SIZE_SHIFT 0
-
-/* DART table fields */
-#define DARTMAP_VALID 0x80000000
-#define DARTMAP_RPNMASK 0x00ffffff
-
-/* Physical base address and size of the DART table */
-unsigned long dart_tablebase;
-unsigned long dart_tablesize;
-
-/* Virtual base address of the DART table */
-static u32 *dart_vbase;
-
-/* Mapped base address for the dart */
-static unsigned int *dart;
-
-/* Dummy val that entries are set to when unused */
-static unsigned int dart_emptyval;
-
-static struct iommu_table iommu_table_pmac;
-static int dart_dirty;
-
-#define DBG(...)
-
-static inline void dart_tlb_invalidate_all(void)
-{
- unsigned long l = 0;
- unsigned int reg;
- unsigned long limit;
-
- DBG("dart: flush\n");
-
- /* To invalidate the DART, set the DARTCNTL_FLUSHTLB bit in the
- * control register and wait for it to clear.
- *
- * Gotcha: Sometimes, the DART won't detect that the bit gets
- * set. If so, clear it and set it again.
- */
-
- limit = 0;
-
-retry:
- reg = in_be32((unsigned int *)dart+DARTCNTL);
- reg |= DARTCNTL_FLUSHTLB;
- out_be32((unsigned int *)dart+DARTCNTL, reg);
-
- l = 0;
- while ((in_be32((unsigned int *)dart+DARTCNTL) & DARTCNTL_FLUSHTLB) &&
- l < (1L<<limit)) {
- l++;
- }
- if (l == (1L<<limit)) {
- if (limit < 4) {
- limit++;
- reg = in_be32((unsigned int *)dart+DARTCNTL);
- reg &= ~DARTCNTL_FLUSHTLB;
- out_be32((unsigned int *)dart+DARTCNTL, reg);
- goto retry;
- } else
- panic("U3-DART: TLB did not flush after waiting a long "
- "time. Buggy U3 ?");
- }
-}
-
-static void dart_flush(struct iommu_table *tbl)
-{
- if (dart_dirty)
- dart_tlb_invalidate_all();
- dart_dirty = 0;
-}
-
-static void dart_build_pmac(struct iommu_table *tbl, long index,
- long npages, unsigned long uaddr,
- enum dma_data_direction direction)
-{
- unsigned int *dp;
- unsigned int rpn;
-
- DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr);
-
- dp = ((unsigned int*)tbl->it_base) + index;
-
- /* On pmac, all memory is contigous, so we can move this
- * out of the loop.
- */
- while (npages--) {
- rpn = virt_to_abs(uaddr) >> PAGE_SHIFT;
-
- *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK);
-
- rpn++;
- uaddr += PAGE_SIZE;
- }
-
- dart_dirty = 1;
-}
-
-
-static void dart_free_pmac(struct iommu_table *tbl, long index, long npages)
-{
- unsigned int *dp;
-
- /* We don't worry about flushing the TLB cache. The only drawback of
- * not doing it is that we won't catch buggy device drivers doing
- * bad DMAs, but then no 32-bit architecture ever does either.
- */
-
- DBG("dart: free at: %lx, %lx\n", index, npages);
-
- dp = ((unsigned int *)tbl->it_base) + index;
-
- while (npages--)
- *(dp++) = dart_emptyval;
-}
-
-
-static int dart_init(struct device_node *dart_node)
-{
- unsigned int regword;
- unsigned int i;
- unsigned long tmp;
- struct page *p;
-
- if (dart_tablebase == 0 || dart_tablesize == 0) {
- printk(KERN_INFO "U3-DART: table not allocated, using direct DMA\n");
- return -ENODEV;
- }
-
- /* Make sure nothing from the DART range remains in the CPU cache
- * from a previous mapping that existed before the kernel took
- * over
- */
- flush_dcache_phys_range(dart_tablebase, dart_tablebase + dart_tablesize);
-
- /* Allocate a spare page to map all invalid DART pages. We need to do
- * that to work around what looks like a problem with the HT bridge
- * prefetching into invalid pages and corrupting data
- */
- tmp = __get_free_pages(GFP_ATOMIC, 1);
- if (tmp == 0)
- panic("U3-DART: Cannot allocate spare page !");
- dart_emptyval = DARTMAP_VALID |
- ((virt_to_abs(tmp) >> PAGE_SHIFT) & DARTMAP_RPNMASK);
-
- /* Map in DART registers. FIXME: Use device node to get base address */
- dart = ioremap(DART_BASE, 0x7000);
- if (dart == NULL)
- panic("U3-DART: Cannot map registers !");
-
- /* Set initial control register contents: table base,
- * table size and enable bit
- */
- regword = DARTCNTL_ENABLE |
- ((dart_tablebase >> PAGE_SHIFT) << DARTCNTL_BASE_SHIFT) |
- (((dart_tablesize >> PAGE_SHIFT) & DARTCNTL_SIZE_MASK)
- << DARTCNTL_SIZE_SHIFT);
- p = virt_to_page(dart_tablebase);
- dart_vbase = ioremap(virt_to_abs(dart_tablebase), dart_tablesize);
-
- /* Fill initial table */
- for (i = 0; i < dart_tablesize/4; i++)
- dart_vbase[i] = dart_emptyval;
-
- /* Initialize DART with table base and enable it. */
- out_be32((unsigned int *)dart, regword);
-
- /* Invalidate DART to get rid of possible stale TLBs */
- dart_tlb_invalidate_all();
-
- iommu_table_pmac.it_busno = 0;
-
- /* Units of tce entries */
- iommu_table_pmac.it_offset = 0;
-
- /* Set the tce table size - measured in pages */
- iommu_table_pmac.it_size = dart_tablesize >> PAGE_SHIFT;
-
- /* Initialize the common IOMMU code */
- iommu_table_pmac.it_base = (unsigned long)dart_vbase;
- iommu_table_pmac.it_index = 0;
- iommu_table_pmac.it_blocksize = 1;
- iommu_table_pmac.it_entrysize = sizeof(u32);
- iommu_init_table(&iommu_table_pmac);
-
- /* Reserve the last page of the DART to avoid possible prefetch
- * past the DART mapped area
- */
- set_bit(iommu_table_pmac.it_mapsize - 1, iommu_table_pmac.it_map);
-
- printk(KERN_INFO "U3-DART IOMMU initialized\n");
-
- return 0;
-}
-
-
-void iommu_setup_pmac(void)
-{
- struct pci_dev *dev = NULL;
- struct device_node *dn;
-
- /* Find the DART in the device-tree */
- dn = of_find_compatible_node(NULL, "dart", "u3-dart");
- if (dn == NULL)
- return;
-
- /* Setup low level TCE operations for the core IOMMU code */
- ppc_md.tce_build = dart_build_pmac;
- ppc_md.tce_free = dart_free_pmac;
- ppc_md.tce_flush = dart_flush;
-
- /* Initialize the DART HW */
- if (dart_init(dn))
- return;
-
- /* Setup pci_dma ops */
- pci_iommu_init();
-
- /* We only have one iommu table on the mac for now, which makes
- * things simple. Setup all PCI devices to point to this table
- */
- while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
- /* We must use pci_device_to_OF_node() to make sure that
- * we get the real "final" pointer to the device in the
- * pci_dev sysdata and not the temporary PHB one
- */
- struct device_node *dn = pci_device_to_OF_node(dev);
- if (dn)
- dn->iommu_table = &iommu_table_pmac;
- }
-}
-
-
-
-
+++ /dev/null
-/*
- * PowerPC64 Segment Translation Support.
- *
- * Dave Engebretsen and Mike Corrigan {engebret|mikejc}@us.ibm.com
- * Copyright (c) 2001 Dave Engebretsen
- *
- * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <asm/pgtable.h>
-#include <asm/mmu.h>
-#include <asm/mmu_context.h>
-#include <asm/paca.h>
-#include <asm/naca.h>
-#include <asm/cputable.h>
-
-static int make_ste(unsigned long stab, unsigned long esid,
- unsigned long vsid);
-
-void slb_initialize(void);
-
-/*
- * Build an entry for the base kernel segment and put it into
- * the segment table or SLB. All other segment table or SLB
- * entries are faulted in.
- */
-void stab_initialize(unsigned long stab)
-{
- unsigned long vsid = get_kernel_vsid(KERNELBASE);
-
- if (cur_cpu_spec->cpu_features & CPU_FTR_SLB) {
- slb_initialize();
- } else {
- asm volatile("isync; slbia; isync":::"memory");
- make_ste(stab, GET_ESID(KERNELBASE), vsid);
-
- /* Order update */
- asm volatile("sync":::"memory");
- }
-}
-
-/* Both the segment table and SLB code uses the following cache */
-#define NR_STAB_CACHE_ENTRIES 8
-DEFINE_PER_CPU(long, stab_cache_ptr);
-DEFINE_PER_CPU(long, stab_cache[NR_STAB_CACHE_ENTRIES]);
-
-/*
- * Segment table stuff
- */
-
-/*
- * Create a segment table entry for the given esid/vsid pair.
- */
-static int make_ste(unsigned long stab, unsigned long esid, unsigned long vsid)
-{
- unsigned long entry, group, old_esid, castout_entry, i;
- unsigned int global_entry;
- STE *ste, *castout_ste;
- unsigned long kernel_segment = (REGION_ID(esid << SID_SHIFT) !=
- USER_REGION_ID);
-
- /* Search the primary group first. */
- global_entry = (esid & 0x1f) << 3;
- ste = (STE *)(stab | ((esid & 0x1f) << 7));
-
- /* Find an empty entry, if one exists. */
- for (group = 0; group < 2; group++) {
- for (entry = 0; entry < 8; entry++, ste++) {
- if (!(ste->dw0.dw0.v)) {
- ste->dw0.dword0 = 0;
- ste->dw1.dword1 = 0;
- ste->dw1.dw1.vsid = vsid;
- ste->dw0.dw0.esid = esid;
- ste->dw0.dw0.kp = 1;
- if (!kernel_segment)
- ste->dw0.dw0.ks = 1;
- asm volatile("eieio":::"memory");
- ste->dw0.dw0.v = 1;
- return (global_entry | entry);
- }
- }
- /* Now search the secondary group. */
- global_entry = ((~esid) & 0x1f) << 3;
- ste = (STE *)(stab | (((~esid) & 0x1f) << 7));
- }
-
- /*
- * Could not find empty entry, pick one with a round robin selection.
- * Search all entries in the two groups.
- */
- castout_entry = get_paca()->stab_rr;
- for (i = 0; i < 16; i++) {
- if (castout_entry < 8) {
- global_entry = (esid & 0x1f) << 3;
- ste = (STE *)(stab | ((esid & 0x1f) << 7));
- castout_ste = ste + castout_entry;
- } else {
- global_entry = ((~esid) & 0x1f) << 3;
- ste = (STE *)(stab | (((~esid) & 0x1f) << 7));
- castout_ste = ste + (castout_entry - 8);
- }
-
- /* Dont cast out the first kernel segment */
- if (castout_ste->dw0.dw0.esid != GET_ESID(KERNELBASE))
- break;
-
- castout_entry = (castout_entry + 1) & 0xf;
- }
-
- get_paca()->stab_rr = (castout_entry + 1) & 0xf;
-
- /* Modify the old entry to the new value. */
-
- /* Force previous translations to complete. DRENG */
- asm volatile("isync" : : : "memory");
-
- castout_ste->dw0.dw0.v = 0;
- asm volatile("sync" : : : "memory"); /* Order update */
-
- castout_ste->dw0.dword0 = 0;
- castout_ste->dw1.dword1 = 0;
- castout_ste->dw1.dw1.vsid = vsid;
- old_esid = castout_ste->dw0.dw0.esid;
- castout_ste->dw0.dw0.esid = esid;
- castout_ste->dw0.dw0.kp = 1;
- if (!kernel_segment)
- castout_ste->dw0.dw0.ks = 1;
- asm volatile("eieio" : : : "memory"); /* Order update */
- castout_ste->dw0.dw0.v = 1;
- asm volatile("slbie %0" : : "r" (old_esid << SID_SHIFT));
- /* Ensure completion of slbie */
- asm volatile("sync" : : : "memory");
-
- return (global_entry | (castout_entry & 0x7));
-}
-
-static inline void __ste_allocate(unsigned long esid, unsigned long vsid)
-{
- unsigned char stab_entry;
- unsigned long offset;
- int region_id = REGION_ID(esid << SID_SHIFT);
-
- stab_entry = make_ste(get_paca()->stab_addr, esid, vsid);
-
- if (region_id != USER_REGION_ID)
- return;
-
- offset = __get_cpu_var(stab_cache_ptr);
- if (offset < NR_STAB_CACHE_ENTRIES)
- __get_cpu_var(stab_cache[offset++]) = stab_entry;
- else
- offset = NR_STAB_CACHE_ENTRIES+1;
- __get_cpu_var(stab_cache_ptr) = offset;
-}
-
-/*
- * Allocate a segment table entry for the given ea.
- */
-int ste_allocate(unsigned long ea)
-{
- unsigned long vsid, esid;
- mm_context_t context;
-
- /* Check for invalid effective addresses. */
- if (!IS_VALID_EA(ea))
- return 1;
-
- /* Kernel or user address? */
- if (REGION_ID(ea) >= KERNEL_REGION_ID) {
- vsid = get_kernel_vsid(ea);
- context = KERNEL_CONTEXT(ea);
- } else {
- if (!current->mm)
- return 1;
-
- context = current->mm->context;
- vsid = get_vsid(context.id, ea);
- }
-
- esid = GET_ESID(ea);
- __ste_allocate(esid, vsid);
- /* Order update */
- asm volatile("sync":::"memory");
-
- return 0;
-}
-
-/*
- * preload some userspace segments into the segment table.
- */
-static void preload_stab(struct task_struct *tsk, struct mm_struct *mm)
-{
- unsigned long pc = KSTK_EIP(tsk);
- unsigned long stack = KSTK_ESP(tsk);
- unsigned long unmapped_base;
- unsigned long pc_esid = GET_ESID(pc);
- unsigned long stack_esid = GET_ESID(stack);
- unsigned long unmapped_base_esid;
- unsigned long vsid;
-
- if (test_tsk_thread_flag(tsk, TIF_32BIT))
- unmapped_base = TASK_UNMAPPED_BASE_USER32;
- else
- unmapped_base = TASK_UNMAPPED_BASE_USER64;
-
- unmapped_base_esid = GET_ESID(unmapped_base);
-
- if (!IS_VALID_EA(pc) || (REGION_ID(pc) >= KERNEL_REGION_ID))
- return;
- vsid = get_vsid(mm->context.id, pc);
- __ste_allocate(pc_esid, vsid);
-
- if (pc_esid == stack_esid)
- return;
-
- if (!IS_VALID_EA(stack) || (REGION_ID(stack) >= KERNEL_REGION_ID))
- return;
- vsid = get_vsid(mm->context.id, stack);
- __ste_allocate(stack_esid, vsid);
-
- if (pc_esid == unmapped_base_esid || stack_esid == unmapped_base_esid)
- return;
-
- if (!IS_VALID_EA(unmapped_base) ||
- (REGION_ID(unmapped_base) >= KERNEL_REGION_ID))
- return;
- vsid = get_vsid(mm->context.id, unmapped_base);
- __ste_allocate(unmapped_base_esid, vsid);
-
- /* Order update */
- asm volatile("sync" : : : "memory");
-}
-
-/* Flush all user entries from the segment table of the current processor. */
-void flush_stab(struct task_struct *tsk, struct mm_struct *mm)
-{
- STE *stab = (STE *) get_paca()->stab_addr;
- STE *ste;
- unsigned long offset = __get_cpu_var(stab_cache_ptr);
-
- /* Force previous translations to complete. DRENG */
- asm volatile("isync" : : : "memory");
-
- if (offset <= NR_STAB_CACHE_ENTRIES) {
- int i;
-
- for (i = 0; i < offset; i++) {
- ste = stab + __get_cpu_var(stab_cache[i]);
- ste->dw0.dw0.v = 0;
- }
- } else {
- unsigned long entry;
-
- /* Invalidate all entries. */
- ste = stab;
-
- /* Never flush the first entry. */
- ste += 1;
- for (entry = 1;
- entry < (PAGE_SIZE / sizeof(STE));
- entry++, ste++) {
- unsigned long ea;
- ea = ste->dw0.dw0.esid << SID_SHIFT;
- if (ea < KERNELBASE) {
- ste->dw0.dw0.v = 0;
- }
- }
- }
-
- asm volatile("sync; slbia; sync":::"memory");
-
- __get_cpu_var(stab_cache_ptr) = 0;
-
- preload_stab(tsk, mm);
-}
+++ /dev/null
-/*
- * arch/s390/lib/memset.S
- * S390 fast memset routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address to memory area
- * R3 = byte to fill memory with
- * R4 = number of bytes to fill
- */
- .globl memset
-memset:
- LTR 4,4
- JZ memset_end
- LR 0,2 # save pointer to memory area
- LR 1,3 # move pad byte to R1
- LR 3,4
- SR 4,4 # no source for MVCLE, only a pad byte
- SR 5,5
- MVCLE 2,4,0(1) # thats it, MVCLE is your friend
- JO .-4
- LR 2,0 # return pointer to mem.
-memset_end:
- BR 14
-
-
+++ /dev/null
-/*
- * arch/s390/lib/memset.S
- * S390 fast memset routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address to memory area
- * R3 = byte to fill memory with
- * R4 = number of bytes to fill
- */
- .globl memset
-memset:
- LTGR 4,4
- JZ memset_end
- LGR 0,2 # save pointer to memory area
- LGR 1,3 # move pad byte to R1
- LGR 3,4
- SGR 4,4 # no source for MVCLE, only a pad byte
- SGR 5,5
- MVCLE 2,4,0(1) # thats it, MVCLE is your friend
- JO .-4
- LGR 2,0 # return pointer to mem.
-memset_end:
- BR 14
-
-
+++ /dev/null
-/*
- * arch/s390/lib/strcmp.S
- * S390 strcmp routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of compare string
- * R3 = address of test string
- */
- .globl strcmp
-strcmp:
- SR 0,0
- SR 1,1
- CLST 2,3
- JO .-4
- JE strcmp_equal
- IC 0,0(3)
- IC 1,0(2)
- SR 1,0
-strcmp_equal:
- LR 2,1
- BR 14
-
+++ /dev/null
-/*
- * arch/s390/lib/strcmp.S
- * S390 strcmp routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of compare string
- * R3 = address of test string
- */
- .globl strcmp
-strcmp:
- SGR 0,0
- SGR 1,1
- CLST 2,3
- JO .-4
- JE strcmp_equal
- IC 0,0(3)
- IC 1,0(2)
- SGR 1,0
-strcmp_equal:
- LGR 2,1
- BR 14
-
+++ /dev/null
-/*
- * arch/s390/kernel/strcpy.S
- * S390 strcpy routine
- *
- * S390 version
- * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- */
- .globl strcpy
-strcpy:
- sr %r0,%r0
-0: mvst %r2,%r3
- jo 0b
- br %r14
-
+++ /dev/null
-/*
- * arch/s390/kernel/strcpy.S
- * S390 strcpy routine
- *
- * S390 version
- * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- */
- .globl strcpy
-strcpy:
- sgr %r0,%r0
-0: mvst %r2,%r3
- jo 0b
- br %r14
-
+++ /dev/null
-/*
- * arch/s390/kernel/strncpy.S
- * S390 strncpy routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- * R4 = max number of bytes to copy
- */
- .globl strncpy
-strncpy:
- LR 1,2 # don't touch address in R2
- LTR 4,4
- JZ strncpy_exit # 0 bytes -> nothing to do
- SR 0,0
-strncpy_loop:
- ICM 0,1,0(3) # ICM sets the cc, IC does not
- LA 3,1(3)
- STC 0,0(1)
- LA 1,1(1)
- JZ strncpy_pad # ICM inserted a 0x00
- BRCT 4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0
-strncpy_exit:
- BR 14
-strncpy_clear:
- STC 0,0(1)
- LA 1,1(1)
-strncpy_pad:
- BRCT 4,strncpy_clear
- BR 14
+++ /dev/null
-/*
- * arch/s390/kernel/strncpy.S
- * S390 strncpy routine
- *
- * S390 version
- * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
- * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
- */
-
-/*
- * R2 = address of destination
- * R3 = address of source string
- * R4 = max number of bytes to copy
- */
- .globl strncpy
-strncpy:
- LGR 1,2 # don't touch address in R2
- LTR 4,4
- JZ strncpy_exit # 0 bytes -> nothing to do
- SGR 0,0
-strncpy_loop:
- ICM 0,1,0(3) # ICM sets the cc, IC does not
- LA 3,1(3)
- STC 0,0(1)
- LA 1,1(1)
- JZ strncpy_pad # ICM inserted a 0x00
- BRCTG 4,strncpy_loop # R4 -= 1, jump to strncpy_loop if > 0
-strncpy_exit:
- BR 14
-strncpy_clear:
- STC 0,0(1)
- LA 1,1(1)
-strncpy_pad:
- BRCTG 4,strncpy_clear
- BR 14
+++ /dev/null
-#
-# Makefile for the SystemH specific parts of the kernel
-#
-
-obj-y := setup.o irq.o io.o
-
-# XXX: This wants to be consolidated in arch/sh/drivers/pci, and more
-# importantly, with the generic sh7751_pcic_init() code. For now, we'll
-# just abuse the hell out of kbuild, because we can..
-
-obj-$(CONFIG_PCI) += pci.o
-pci-y := ../se/7751/pci.o
-
+++ /dev/null
-/*
- * linux/arch/sh/boards/systemh/io.c
- *
- * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
- * Based largely on io_se.c.
- *
- * I/O routine for Hitachi 7751 Systemh.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <asm/systemh/7751systemh.h>
-#include <asm/addrspace.h>
-#include <asm/io.h>
-
-#include <linux/pci.h>
-#include "../../drivers/pci/pci-sh7751.h"
-
-/*
- * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
- * of the 7751 processor, and has a SuperIO accessible on its memory
- * bus.
- */
-
-#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
-#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
-#define PCI_IO_AREA SH7751_PCI_IO_BASE
-#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
-
-#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
-#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
- of smc lan chip*/
-
-#define maybebadio(name,port) \
- printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
- #name, (port), (__u32) __builtin_return_address(0))
-
-static inline void delay(void)
-{
- ctrl_inw(0xa0000000);
-}
-
-static inline volatile __u16 *
-port2adr(unsigned int port)
-{
- if (port >= 0x2000)
- return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
-#if 0
- else
- return (volatile __u16 *) (PA_SUPERIO + (port << 1));
-#endif
- maybebadio(name,(unsigned long)port);
- return (volatile __u16*)port;
-}
-
-/* In case someone configures the kernel w/o PCI support: in that */
-/* scenario, don't ever bother to check for PCI-window addresses */
-
-/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
-#if defined(CONFIG_PCI)
-#define CHECK_SH7751_PCIIO(port) \
- ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
-#else
-#define CHECK_SH7751_PCIIO(port) (0)
-#endif
-
-/*
- * General outline: remap really low stuff [eventually] to SuperIO,
- * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
- * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
- * should be way beyond the window, and is used w/o translation for
- * compatibility.
- */
-unsigned char sh7751systemh_inb(unsigned long port)
-{
- if (PXSEG(port))
- return *(volatile unsigned char *)port;
- else if (CHECK_SH7751_PCIIO(port))
- return *(volatile unsigned char *)PCI_IOMAP(port);
- else if (port <= 0x3F1)
- return *(volatile unsigned char *)ETHER_IOMAP(port);
- else
- return (*port2adr(port))&0xff;
-}
-
-unsigned char sh7751systemh_inb_p(unsigned long port)
-{
- unsigned char v;
-
- if (PXSEG(port))
- v = *(volatile unsigned char *)port;
- else if (CHECK_SH7751_PCIIO(port))
- v = *(volatile unsigned char *)PCI_IOMAP(port);
- else if (port <= 0x3F1)
- v = *(volatile unsigned char *)ETHER_IOMAP(port);
- else
- v = (*port2adr(port))&0xff;
- delay();
- return v;
-}
-
-unsigned short sh7751systemh_inw(unsigned long port)
-{
- if (PXSEG(port))
- return *(volatile unsigned short *)port;
- else if (CHECK_SH7751_PCIIO(port))
- return *(volatile unsigned short *)PCI_IOMAP(port);
- else if (port >= 0x2000)
- return *port2adr(port);
- else if (port <= 0x3F1)
- return *(volatile unsigned int *)ETHER_IOMAP(port);
- else
- maybebadio(inw, port);
- return 0;
-}
-
-unsigned int sh7751systemh_inl(unsigned long port)
-{
- if (PXSEG(port))
- return *(volatile unsigned long *)port;
- else if (CHECK_SH7751_PCIIO(port))
- return *(volatile unsigned int *)PCI_IOMAP(port);
- else if (port >= 0x2000)
- return *port2adr(port);
- else if (port <= 0x3F1)
- return *(volatile unsigned int *)ETHER_IOMAP(port);
- else
- maybebadio(inl, port);
- return 0;
-}
-
-void sh7751systemh_outb(unsigned char value, unsigned long port)
-{
-
- if (PXSEG(port))
- *(volatile unsigned char *)port = value;
- else if (CHECK_SH7751_PCIIO(port))
- *((unsigned char*)PCI_IOMAP(port)) = value;
- else if (port <= 0x3F1)
- *(volatile unsigned char *)ETHER_IOMAP(port) = value;
- else
- *(port2adr(port)) = value;
-}
-
-void sh7751systemh_outb_p(unsigned char value, unsigned long port)
-{
- if (PXSEG(port))
- *(volatile unsigned char *)port = value;
- else if (CHECK_SH7751_PCIIO(port))
- *((unsigned char*)PCI_IOMAP(port)) = value;
- else if (port <= 0x3F1)
- *(volatile unsigned char *)ETHER_IOMAP(port) = value;
- else
- *(port2adr(port)) = value;
- delay();
-}
-
-void sh7751systemh_outw(unsigned short value, unsigned long port)
-{
- if (PXSEG(port))
- *(volatile unsigned short *)port = value;
- else if (CHECK_SH7751_PCIIO(port))
- *((unsigned short *)PCI_IOMAP(port)) = value;
- else if (port >= 0x2000)
- *port2adr(port) = value;
- else if (port <= 0x3F1)
- *(volatile unsigned short *)ETHER_IOMAP(port) = value;
- else
- maybebadio(outw, port);
-}
-
-void sh7751systemh_outl(unsigned int value, unsigned long port)
-{
- if (PXSEG(port))
- *(volatile unsigned long *)port = value;
- else if (CHECK_SH7751_PCIIO(port))
- *((unsigned long*)PCI_IOMAP(port)) = value;
- else
- maybebadio(outl, port);
-}
-
-void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
-{
- unsigned char *p = addr;
- while (count--) *p++ = sh7751systemh_inb(port);
-}
-
-void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
-{
- unsigned short *p = addr;
- while (count--) *p++ = sh7751systemh_inw(port);
-}
-
-void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
-{
- maybebadio(insl, port);
-}
-
-void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
-{
- unsigned char *p = (unsigned char*)addr;
- while (count--) sh7751systemh_outb(*p++, port);
-}
-
-void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count)
-{
- unsigned short *p = (unsigned short*)addr;
- while (count--) sh7751systemh_outw(*p++, port);
-}
-
-void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
-{
- maybebadio(outsw, port);
-}
-
-/* For read/write calls, just copy generic (pass-thru); PCIMBR is */
-/* already set up. For a larger memory space, these would need to */
-/* reset PCIMBR as needed on a per-call basis... */
-
-unsigned char sh7751systemh_readb(unsigned long addr)
-{
- return *(volatile unsigned char*)addr;
-}
-
-unsigned short sh7751systemh_readw(unsigned long addr)
-{
- return *(volatile unsigned short*)addr;
-}
-
-unsigned int sh7751systemh_readl(unsigned long addr)
-{
- return *(volatile unsigned long*)addr;
-}
-
-void sh7751systemh_writeb(unsigned char b, unsigned long addr)
-{
- *(volatile unsigned char*)addr = b;
-}
-
-void sh7751systemh_writew(unsigned short b, unsigned long addr)
-{
- *(volatile unsigned short*)addr = b;
-}
-
-void sh7751systemh_writel(unsigned int b, unsigned long addr)
-{
- *(volatile unsigned long*)addr = b;
-}
-
-\f
-
-/* Map ISA bus address to the real address. Only for PCMCIA. */
-
-/* ISA page descriptor. */
-static __u32 sh_isa_memmap[256];
-
-#if 0
-static int
-sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
-{
- int idx;
-
- if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
- return -1;
-
- idx = start >> 12;
- sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
- printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
- start, length, offset, idx, sh_isa_memmap[idx]);
- return 0;
-}
-#endif
-
-unsigned long
-sh7751systemh_isa_port2addr(unsigned long offset)
-{
- int idx;
-
- idx = (offset >> 12) & 0xff;
- offset &= 0xfff;
- return sh_isa_memmap[idx] + offset;
-}
+++ /dev/null
-/*
- * linux/arch/sh/boards/systemh/irq.c
- *
- * Copyright (C) 2000 Kazumoto Kojima
- *
- * Hitachi SystemH Support.
- *
- * Modified for 7751 SystemH by
- * Jonathan Short.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <linux/irq.h>
-
-#include <linux/hdreg.h>
-#include <linux/ide.h>
-#include <asm/io.h>
-#include <asm/mach/7751systemh.h>
-#include <asm/smc37c93x.h>
-
-/* address of external interrupt mask register
- * address must be set prior to use these (maybe in init_XXX_irq())
- * XXX : is it better to use .config than specifying it in code? */
-static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
-static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
-
-/* forward declaration */
-static unsigned int startup_systemh_irq(unsigned int irq);
-static void shutdown_systemh_irq(unsigned int irq);
-static void enable_systemh_irq(unsigned int irq);
-static void disable_systemh_irq(unsigned int irq);
-static void mask_and_ack_systemh(unsigned int);
-static void end_systemh_irq(unsigned int irq);
-
-/* hw_interrupt_type */
-static struct hw_interrupt_type systemh_irq_type = {
- " SystemH Register",
- startup_systemh_irq,
- shutdown_systemh_irq,
- enable_systemh_irq,
- disable_systemh_irq,
- mask_and_ack_systemh,
- end_systemh_irq
-};
-
-static unsigned int startup_systemh_irq(unsigned int irq)
-{
- enable_systemh_irq(irq);
- return 0; /* never anything pending */
-}
-
-static void shutdown_systemh_irq(unsigned int irq)
-{
- disable_systemh_irq(irq);
-}
-
-static void disable_systemh_irq(unsigned int irq)
-{
- if (systemh_irq_mask_register) {
- unsigned long flags;
- unsigned long val, mask = 0x01 << 1;
-
- /* Clear the "irq"th bit in the mask and set it in the request */
- local_irq_save(flags);
-
- val = ctrl_inl((unsigned long)systemh_irq_mask_register);
- val &= ~mask;
- ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
-
- val = ctrl_inl((unsigned long)systemh_irq_request_register);
- val |= mask;
- ctrl_outl(val, (unsigned long)systemh_irq_request_register);
-
- local_irq_restore(flags);
- }
-}
-
-static void enable_systemh_irq(unsigned int irq)
-{
- if (systemh_irq_mask_register) {
- unsigned long flags;
- unsigned long val, mask = 0x01 << 1;
-
- /* Set "irq"th bit in the mask register */
- local_irq_save(flags);
- val = ctrl_inl((unsigned long)systemh_irq_mask_register);
- val |= mask;
- ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
- local_irq_restore(flags);
- }
-}
-
-static void mask_and_ack_systemh(unsigned int irq)
-{
- disable_systemh_irq(irq);
-}
-
-static void end_systemh_irq(unsigned int irq)
-{
- if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
- enable_systemh_irq(irq);
-}
-
-void make_systemh_irq(unsigned int irq)
-{
- disable_irq_nosync(irq);
- irq_desc[irq].handler = &systemh_irq_type;
- disable_systemh_irq(irq);
-}
-
+++ /dev/null
-/*
- * linux/arch/sh/boards/systemh/setup.c
- *
- * Copyright (C) 2000 Kazumoto Kojima
- * Copyright (C) 2003 Paul Mundt
- *
- * Hitachi SystemH Support.
- *
- * Modified for 7751 SystemH by Jonathan Short.
- *
- * Rewritten for 2.6 by Paul Mundt.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-#include <linux/init.h>
-#include <asm/mach/7751systemh.h>
-#include <asm/mach/io.h>
-#include <asm/machvec.h>
-
-extern void make_systemh_irq(unsigned int irq);
-
-const char *get_system_type(void)
-{
- return "7751 SystemH";
-}
-
-/*
- * Initialize IRQ setting
- */
-void __init init_7751systemh_IRQ(void)
-{
-/* make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); LAN */
-/* make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-4); */
- make_systemh_irq(0xb); /* Ethernet interrupt */
-}
-
-struct sh_machine_vector mv_7751systemh __initmv = {
- .mv_nr_irqs = 72,
-
- .mv_inb = sh7751systemh_inb,
- .mv_inw = sh7751systemh_inw,
- .mv_inl = sh7751systemh_inl,
- .mv_outb = sh7751systemh_outb,
- .mv_outw = sh7751systemh_outw,
- .mv_outl = sh7751systemh_outl,
-
- .mv_inb_p = sh7751systemh_inb_p,
- .mv_inw_p = sh7751systemh_inw,
- .mv_inl_p = sh7751systemh_inl,
- .mv_outb_p = sh7751systemh_outb_p,
- .mv_outw_p = sh7751systemh_outw,
- .mv_outl_p = sh7751systemh_outl,
-
- .mv_insb = sh7751systemh_insb,
- .mv_insw = sh7751systemh_insw,
- .mv_insl = sh7751systemh_insl,
- .mv_outsb = sh7751systemh_outsb,
- .mv_outsw = sh7751systemh_outsw,
- .mv_outsl = sh7751systemh_outsl,
-
- .mv_readb = sh7751systemh_readb,
- .mv_readw = sh7751systemh_readw,
- .mv_readl = sh7751systemh_readl,
- .mv_writeb = sh7751systemh_writeb,
- .mv_writew = sh7751systemh_writew,
- .mv_writel = sh7751systemh_writel,
-
- .mv_isa_port2addr = sh7751systemh_isa_port2addr,
-
- .mv_init_irq = init_7751systemh_IRQ,
-};
-ALIAS_MV(7751systemh)
-
-int __init platform_setup(void)
-{
- return 0;
-}
-
+++ /dev/null
-/* U3copy_in_user.S: UltraSparc-III optimized memcpy.
- *
- * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
- */
-
-#include <asm/visasm.h>
-#include <asm/asi.h>
-#include <asm/dcu.h>
-#include <asm/spitfire.h>
-
-#define XCC xcc
-
-#define EXNV(x,y,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: retl; \
- a, b, %o0; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-#define EXNV1(x,y,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: a, b, %o0; \
- retl; \
- add %o0, 1, %o0; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-#define EXNV4(x,y,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: a, b, %o0; \
- retl; \
- add %o0, 4, %o0; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-#define EXNV8(x,y,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: a, b, %o0; \
- retl; \
- add %o0, 8, %o0; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-
- .register %g2,#scratch
- .register %g3,#scratch
-
- .text
- .align 32
-
- /* Don't try to get too fancy here, just nice and
- * simple. This is predominantly used for well aligned
- * small copies in the compat layer. It is also used
- * to copy register windows around during thread cloning.
- */
-
- .globl U3copy_in_user
-U3copy_in_user: /* %o0=dst, %o1=src, %o2=len */
- /* Writing to %asi is _expensive_ so we hardcode it.
- * Reading %asi to check for KERNEL_DS is comparatively
- * cheap.
- */
- rd %asi, %g1
- cmp %g1, ASI_AIUS
- bne,pn %icc, U3memcpy_user_stub
- nop
-
- cmp %o2, 0
- be,pn %XCC, out
- or %o0, %o1, %o3
- cmp %o2, 16
- bleu,a,pn %XCC, small_copy
- or %o3, %o2, %o3
-
-medium_copy: /* 16 < len <= 64 */
- andcc %o3, 0x7, %g0
- bne,pn %XCC, small_copy_unaligned
- sub %o0, %o1, %o3
-
-medium_copy_aligned:
- andn %o2, 0x7, %o4
- and %o2, 0x7, %o2
-1: subcc %o4, 0x8, %o4
- EXNV8(ldxa [%o1] %asi, %o5, add %o4, %o2)
- EXNV8(stxa %o5, [%o1 + %o3] ASI_AIUS, add %o4, %o2)
- bgu,pt %XCC, 1b
- add %o1, 0x8, %o1
- andcc %o2, 0x4, %g0
- be,pt %XCC, 1f
- nop
- sub %o2, 0x4, %o2
- EXNV4(lduwa [%o1] %asi, %o5, add %o4, %o2)
- EXNV4(stwa %o5, [%o1 + %o3] ASI_AIUS, add %o4, %o2)
- add %o1, 0x4, %o1
-1: cmp %o2, 0
- be,pt %XCC, out
- nop
- ba,pt %xcc, small_copy_unaligned
- nop
-
-small_copy: /* 0 < len <= 16 */
- andcc %o3, 0x3, %g0
- bne,pn %XCC, small_copy_unaligned
- sub %o0, %o1, %o3
-
-small_copy_aligned:
- subcc %o2, 4, %o2
- EXNV4(lduwa [%o1] %asi, %g1, add %o2, %g0)
- EXNV4(stwa %g1, [%o1 + %o3] ASI_AIUS, add %o2, %g0)
- bgu,pt %XCC, small_copy_aligned
- add %o1, 4, %o1
-
-out: retl
- clr %o0
-
- .align 32
-small_copy_unaligned:
- subcc %o2, 1, %o2
- EXNV1(lduba [%o1] %asi, %g1, add %o2, %g0)
- EXNV1(stba %g1, [%o1 + %o3] ASI_AIUS, add %o2, %g0)
- bgu,pt %XCC, small_copy_unaligned
- add %o1, 1, %o1
- retl
- clr %o0
+++ /dev/null
-/* $Id: VIScopy.S,v 1.27 2002/02/09 19:49:30 davem Exp $
- * VIScopy.S: High speed copy operations utilizing the UltraSparc
- * Visual Instruction Set.
- *
- * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
- * Copyright (C) 1996, 1997, 1998, 1999 Jakub Jelinek (jj@ultra.linux.cz)
- */
-
-#include "VIS.h"
-
- /* VIS code can be used for numerous copy/set operation variants.
- * It can be made to work in the kernel, one single instance,
- * for all of memcpy, copy_to_user, and copy_from_user by setting
- * the ASI src/dest globals correctly. Furthermore it can
- * be used for kernel-->kernel page copies as well, a hook label
- * is put in here just for this purpose.
- *
- * For userland, compiling this without __KERNEL__ defined makes
- * it work just fine as a generic libc bcopy and memcpy.
- * If for userland it is compiled with a 32bit gcc (but you need
- * -Wa,-Av9a for as), the code will just rely on lower 32bits of
- * IEU registers, if you compile it with 64bit gcc (ie. define
- * __sparc_v9__), the code will use full 64bit.
- */
-
-#ifdef __KERNEL__
-
-#include <asm/visasm.h>
-#include <asm/thread_info.h>
-
-#define FPU_CLEAN_RETL \
- ldub [%g6 + TI_CURRENT_DS], %o1; \
- VISExit \
- clr %o0; \
- retl; \
- wr %o1, %g0, %asi;
-#define FPU_RETL \
- ldub [%g6 + TI_CURRENT_DS], %o1; \
- VISExit \
- clr %o0; \
- retl; \
- wr %o1, %g0, %asi;
-#define NORMAL_RETL \
- ldub [%g6 + TI_CURRENT_DS], %o1; \
- clr %o0; \
- retl; \
- wr %o1, %g0, %asi;
-#define EX(x,y,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: ba VIScopyfixup_ret; \
- a, b, %o1; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-#define EX2(x,y,c,d,e,a,b) \
-98: x,y; \
- .section .fixup; \
- .align 4; \
-99: c, d, e; \
- ba VIScopyfixup_ret; \
- a, b, %o1; \
- .section __ex_table; \
- .align 4; \
- .word 98b, 99b; \
- .text; \
- .align 4;
-#define EXO2(x,y) \
-98: x,y; \
- .section __ex_table; \
- .align 4; \
- .word 98b, VIScopyfixup_reto2; \
- .text; \
- .align 4;
-#define EXVISN(x,y,n) \
-98: x,y; \
- .section __ex_table; \
- .align 4; \
- .word 98b, VIScopyfixup_vis##n; \
- .text; \
- .align 4;
-#define EXT(start,end,handler) \
- .section __ex_table; \
- .align 4; \
- .word start, 0, end, handler; \
- .text; \
- .align 4;
-#else
-#ifdef REGS_64BIT
-#define FPU_CLEAN_RETL \
- retl; \
- mov %g6, %o0;
-#define FPU_RETL \
- retl; \
- mov %g6, %o0;
-#else
-#define FPU_CLEAN_RETL \
- wr %g0, FPRS_FEF, %fprs; \
- retl; \
- mov %g6, %o0;
-#define FPU_RETL \
- wr %g0, FPRS_FEF, %fprs; \
- retl; \
- mov %g6, %o0;
-#endif
-#define NORMAL_RETL \
- retl; \
- mov %g6, %o0;
-#define EX(x,y,a,b) x,y
-#define EX2(x,y,c,d,e,a,b) x,y
-#define EXO2(x,y) x,y
-#define EXVISN(x,y,n) x,y
-#define EXT(a,b,c)
-#endif
-#define EXVIS(x,y) EXVISN(x,y,0)
-#define EXVIS1(x,y) EXVISN(x,y,1)
-#define EXVIS2(x,y) EXVISN(x,y,2)
-#define EXVIS3(x,y) EXVISN(x,y,3)
-#define EXVIS4(x,y) EXVISN(x,y,4)
-
-#define FREG_FROB(f1, f2, f3, f4, f5, f6, f7, f8, f9) \
- faligndata %f1, %f2, %f48; \
- faligndata %f2, %f3, %f50; \
- faligndata %f3, %f4, %f52; \
- faligndata %f4, %f5, %f54; \
- faligndata %f5, %f6, %f56; \
- faligndata %f6, %f7, %f58; \
- faligndata %f7, %f8, %f60; \
- faligndata %f8, %f9, %f62;
-
-#define MAIN_LOOP_CHUNK(src, dest, fdest, fsrc, len, jmptgt) \
- EXVIS(LDBLK [%src] ASIBLK, %fdest); \
- ASI_SETDST_BLK \
- EXVIS(STBLK %fsrc, [%dest] ASIBLK); \
- add %src, 0x40, %src; \
- subcc %len, 0x40, %len; \
- be,pn %xcc, jmptgt; \
- add %dest, 0x40, %dest; \
- ASI_SETSRC_BLK
-
-#define LOOP_CHUNK1(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f0, f48, len, branch_dest)
-#define LOOP_CHUNK2(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f16, f48, len, branch_dest)
-#define LOOP_CHUNK3(src, dest, len, branch_dest) \
- MAIN_LOOP_CHUNK(src, dest, f32, f48, len, branch_dest)
-
-#define STORE_SYNC(dest, fsrc) \
- EXVIS(STBLK %fsrc, [%dest] ASIBLK); \
- add %dest, 0x40, %dest;
-
-#ifdef __KERNEL__
-#define STORE_JUMP(dest, fsrc, target) \
- srl asi_dest, 3, %g5; \
- EXVIS2(STBLK %fsrc, [%dest] ASIBLK); \
- xor asi_dest, ASI_BLK_XOR1, asi_dest;\
- add %dest, 0x40, %dest; \
- xor asi_dest, %g5, asi_dest; \
- ba,pt %xcc, target;
-#else
-#define STORE_JUMP(dest, fsrc, target) \
- EXVIS2(STBLK %fsrc, [%dest] ASIBLK); \
- add %dest, 0x40, %dest; \
- ba,pt %xcc, target;
-#endif
-
-#ifndef __KERNEL__
-#define VISLOOP_PAD nop; nop; nop; nop; \
- nop; nop; nop; nop; \
- nop; nop; nop; nop; \
- nop; nop; nop;
-#else
-#define VISLOOP_PAD
-#endif
-
-#define FINISH_VISCHUNK(dest, f0, f1, left) \
- ASI_SETDST_NOBLK \
- subcc %left, 8, %left; \
- bl,pn %xcc, vis_out; \
- faligndata %f0, %f1, %f48; \
- EXVIS3(STDF %f48, [%dest] ASINORMAL); \
- add %dest, 8, %dest;
-
-#define UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
- subcc %left, 8, %left; \
- bl,pn %xcc, vis_out; \
- fsrc1 %f0, %f1;
-#define UNEVEN_VISCHUNK(dest, f0, f1, left) \
- UNEVEN_VISCHUNK_LAST(dest, f0, f1, left) \
- ba,a,pt %xcc, vis_out_slk;
-
- /* Macros for non-VIS memcpy code. */
-#ifdef REGS_64BIT
-
-#define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ASI_SETSRC_NOBLK \
- LDX [%src + offset + 0x00] ASINORMAL, %t0; \
- LDX [%src + offset + 0x08] ASINORMAL, %t1; \
- LDX [%src + offset + 0x10] ASINORMAL, %t2; \
- LDX [%src + offset + 0x18] ASINORMAL, %t3; \
- ASI_SETDST_NOBLK \
- STW %t0, [%dst + offset + 0x04] ASINORMAL; \
- srlx %t0, 32, %t0; \
- STW %t0, [%dst + offset + 0x00] ASINORMAL; \
- STW %t1, [%dst + offset + 0x0c] ASINORMAL; \
- srlx %t1, 32, %t1; \
- STW %t1, [%dst + offset + 0x08] ASINORMAL; \
- STW %t2, [%dst + offset + 0x14] ASINORMAL; \
- srlx %t2, 32, %t2; \
- STW %t2, [%dst + offset + 0x10] ASINORMAL; \
- STW %t3, [%dst + offset + 0x1c] ASINORMAL; \
- srlx %t3, 32, %t3; \
- STW %t3, [%dst + offset + 0x18] ASINORMAL;
-
-#define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ASI_SETSRC_NOBLK \
- LDX [%src + offset + 0x00] ASINORMAL, %t0; \
- LDX [%src + offset + 0x08] ASINORMAL, %t1; \
- LDX [%src + offset + 0x10] ASINORMAL, %t2; \
- LDX [%src + offset + 0x18] ASINORMAL, %t3; \
- ASI_SETDST_NOBLK \
- STX %t0, [%dst + offset + 0x00] ASINORMAL; \
- STX %t1, [%dst + offset + 0x08] ASINORMAL; \
- STX %t2, [%dst + offset + 0x10] ASINORMAL; \
- STX %t3, [%dst + offset + 0x18] ASINORMAL; \
- ASI_SETSRC_NOBLK \
- LDX [%src + offset + 0x20] ASINORMAL, %t0; \
- LDX [%src + offset + 0x28] ASINORMAL, %t1; \
- LDX [%src + offset + 0x30] ASINORMAL, %t2; \
- LDX [%src + offset + 0x38] ASINORMAL, %t3; \
- ASI_SETDST_NOBLK \
- STX %t0, [%dst + offset + 0x20] ASINORMAL; \
- STX %t1, [%dst + offset + 0x28] ASINORMAL; \
- STX %t2, [%dst + offset + 0x30] ASINORMAL; \
- STX %t3, [%dst + offset + 0x38] ASINORMAL;
-
-#define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
- ASI_SETSRC_NOBLK \
- LDX [%src - offset - 0x10] ASINORMAL, %t0; \
- LDX [%src - offset - 0x08] ASINORMAL, %t1; \
- ASI_SETDST_NOBLK \
- STW %t0, [%dst - offset - 0x0c] ASINORMAL; \
- srlx %t0, 32, %t2; \
- STW %t2, [%dst - offset - 0x10] ASINORMAL; \
- STW %t1, [%dst - offset - 0x04] ASINORMAL; \
- srlx %t1, 32, %t3; \
- STW %t3, [%dst - offset - 0x08] ASINORMAL;
-
-#define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1) \
- ASI_SETSRC_NOBLK \
- LDX [%src - offset - 0x10] ASINORMAL, %t0; \
- LDX [%src - offset - 0x08] ASINORMAL, %t1; \
- ASI_SETDST_NOBLK \
- STX %t0, [%dst - offset - 0x10] ASINORMAL; \
- STX %t1, [%dst - offset - 0x08] ASINORMAL;
-
-#else /* !REGS_64BIT */
-
-#define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3) \
- lduw [%src + offset + 0x00], %t0; \
- lduw [%src + offset + 0x04], %t1; \
- lduw [%src + offset + 0x08], %t2; \
- lduw [%src + offset + 0x0c], %t3; \
- stw %t0, [%dst + offset + 0x00]; \
- stw %t1, [%dst + offset + 0x04]; \
- stw %t2, [%dst + offset + 0x08]; \
- stw %t3, [%dst + offset + 0x0c]; \
- lduw [%src + offset + 0x10], %t0; \
- lduw [%src + offset + 0x14], %t1; \
- lduw [%src + offset + 0x18], %t2; \
- lduw [%src + offset + 0x1c], %t3; \
- stw %t0, [%dst + offset + 0x10]; \
- stw %t1, [%dst + offset + 0x14]; \
- stw %t2, [%dst + offset + 0x18]; \
- stw %t3, [%dst + offset + 0x1c];
-
-#define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
- lduw [%src - offset - 0x10], %t0; \
- lduw [%src - offset - 0x0c], %t1; \
- lduw [%src - offset - 0x08], %t2; \
- lduw [%src - offset - 0x04], %t3; \
- stw %t0, [%dst - offset - 0x10]; \
- stw %t1, [%dst - offset - 0x0c]; \
- stw %t2, [%dst - offset - 0x08]; \
- stw %t3, [%dst - offset - 0x04];
-
-#endif /* !REGS_64BIT */
-
-#ifdef __KERNEL__
- .section __ex_table,#alloc
- .section .fixup,#alloc,#execinstr
-#endif
-
- .text
- .align 32
- .globl memcpy
- .type memcpy,@function
-
- .globl bcopy
- .type bcopy,@function
-
-#ifdef __KERNEL__
-memcpy_private:
-memcpy: mov ASI_P, asi_src ! IEU0 Group
- brnz,pt %o2, __memcpy_entry ! CTI
- mov ASI_P, asi_dest ! IEU1
- retl
- clr %o0
-
- .align 32
- .globl __copy_from_user
- .type __copy_from_user,@function
-__copy_from_user:rd %asi, asi_src ! IEU0 Group
- brnz,pt %o2, __memcpy_entry ! CTI
- mov ASI_P, asi_dest ! IEU1
-
- .globl __copy_to_user
- .type __copy_to_user,@function
-__copy_to_user: mov ASI_P, asi_src ! IEU0 Group
- brnz,pt %o2, __memcpy_entry ! CTI
- rd %asi, asi_dest ! IEU1
- retl ! CTI Group
- clr %o0 ! IEU0 Group
-
- .globl __copy_in_user
- .type __copy_in_user,@function
-__copy_in_user: rd %asi, asi_src ! IEU0 Group
- brnz,pt %o2, __memcpy_entry ! CTI
- mov asi_src, asi_dest ! IEU1
- retl ! CTI Group
- clr %o0 ! IEU0 Group
-#endif
-
-bcopy: or %o0, 0, %g3 ! IEU0 Group
- addcc %o1, 0, %o0 ! IEU1
- brgez,pt %o2, memcpy_private ! CTI
- or %g3, 0, %o1 ! IEU0 Group
- retl ! CTI Group brk forced
- clr %o0 ! IEU0
-
-
-#ifdef __KERNEL__
-#define BRANCH_ALWAYS 0x10680000
-#define NOP 0x01000000
-#define ULTRA3_DO_PATCH(OLD, NEW) \
- sethi %hi(NEW), %g1; \
- or %g1, %lo(NEW), %g1; \
- sethi %hi(OLD), %g2; \
- or %g2, %lo(OLD), %g2; \
- sub %g1, %g2, %g1; \
- sethi %hi(BRANCH_ALWAYS), %g3; \
- srl %g1, 2, %g1; \
- or %g3, %lo(BRANCH_ALWAYS), %g3; \
- or %g3, %g1, %g3; \
- stw %g3, [%g2]; \
- sethi %hi(NOP), %g3; \
- or %g3, %lo(NOP), %g3; \
- stw %g3, [%g2 + 0x4]; \
- flush %g2;
-
- .globl cheetah_patch_copyops
-cheetah_patch_copyops:
- ULTRA3_DO_PATCH(memcpy, U3memcpy)
- ULTRA3_DO_PATCH(__copy_from_user, U3copy_from_user)
- ULTRA3_DO_PATCH(__copy_to_user, U3copy_to_user)
- ULTRA3_DO_PATCH(__copy_in_user, U3copy_in_user)
- retl
- nop
-#undef BRANCH_ALWAYS
-#undef NOP
-#undef ULTRA3_DO_PATCH
-#endif /* __KERNEL__ */
-
- .align 32
-#ifdef __KERNEL__
- andcc %o0, 7, %g2 ! IEU1 Group
-#endif
-VIS_enter:
- be,pt %xcc, dest_is_8byte_aligned ! CTI
-#ifdef __KERNEL__
- nop ! IEU0 Group
-#else
- andcc %o0, 0x38, %g5 ! IEU1 Group
-#endif
-do_dest_8byte_align:
- mov 8, %g1 ! IEU0
- sub %g1, %g2, %g2 ! IEU0 Group
- andcc %o0, 1, %g0 ! IEU1
- be,pt %icc, 2f ! CTI
- sub %o2, %g2, %o2 ! IEU0 Group
-1: ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUB [%o1] ASINORMAL, %o5,
- add %o2, %g2) ! Load Group
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- subcc %g2, 1, %g2 ! IEU1 Group
- be,pn %xcc, 3f ! CTI
- EX2(STB %o5, [%o0 - 1] ASINORMAL,
- add %g2, 1, %g2,
- add %o2, %g2) ! Store
-2: ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUB [%o1] ASINORMAL, %o5,
- add %o2, %g2) ! Load Group
- add %o0, 2, %o0 ! IEU0
- EX2(LDUB [%o1 + 1] ASINORMAL, %g3,
- sub %o0, 2, %o0,
- add %o2, %g2) ! Load Group
- ASI_SETDST_NOBLK ! LSU Group
- subcc %g2, 2, %g2 ! IEU1 Group
- EX2(STB %o5, [%o0 - 2] ASINORMAL,
- add %g2, 2, %g2,
- add %o2, %g2) ! Store
- add %o1, 2, %o1 ! IEU0
- bne,pt %xcc, 2b ! CTI Group
- EX2(STB %g3, [%o0 - 1] ASINORMAL,
- add %g2, 1, %g2,
- add %o2, %g2) ! Store
-#ifdef __KERNEL__
-3:
-dest_is_8byte_aligned:
- VISEntry
- andcc %o0, 0x38, %g5 ! IEU1 Group
-#else
-3: andcc %o0, 0x38, %g5 ! IEU1 Group
-dest_is_8byte_aligned:
-#endif
- be,pt %icc, dest_is_64byte_aligned ! CTI
- mov 64, %g1 ! IEU0
- fmovd %f0, %f2 ! FPU
- sub %g1, %g5, %g5 ! IEU0 Group
- ASI_SETSRC_NOBLK ! LSU Group
- alignaddr %o1, %g0, %g1 ! GRU Group
- EXO2(LDDF [%g1] ASINORMAL, %f4) ! Load Group
- sub %o2, %g5, %o2 ! IEU0
-1: EX(LDDF [%g1 + 0x8] ASINORMAL, %f6,
- add %o2, %g5) ! Load Group
- add %g1, 0x8, %g1 ! IEU0 Group
- subcc %g5, 8, %g5 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f4, %f6, %f0 ! GRU Group
- EX2(STDF %f0, [%o0] ASINORMAL,
- add %g5, 8, %g5,
- add %o2, %g5) ! Store
- add %o1, 8, %o1 ! IEU0 Group
- be,pn %xcc, dest_is_64byte_aligned ! CTI
- add %o0, 8, %o0 ! IEU1
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDDF [%g1 + 0x8] ASINORMAL, %f4,
- add %o2, %g5) ! Load Group
- add %g1, 8, %g1 ! IEU0
- subcc %g5, 8, %g5 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f6, %f4, %f0 ! GRU Group
- EX2(STDF %f0, [%o0] ASINORMAL,
- add %g5, 8, %g5,
- add %o2, %g5) ! Store
- add %o1, 8, %o1 ! IEU0
- ASI_SETSRC_NOBLK ! LSU Group
- bne,pt %xcc, 1b ! CTI Group
- add %o0, 8, %o0 ! IEU0
-dest_is_64byte_aligned:
- membar #LoadStore | #StoreStore | #StoreLoad ! LSU Group
-#ifndef __KERNEL__
- wr %g0, ASI_BLK_P, %asi ! LSU Group
-#endif
- subcc %o2, 0x40, %g7 ! IEU1 Group
- mov %o1, %g1 ! IEU0
- andncc %g7, (0x40 - 1), %g7 ! IEU1 Group
- srl %g1, 3, %g2 ! IEU0
- sub %o2, %g7, %g3 ! IEU0 Group
- andn %o1, (0x40 - 1), %o1 ! IEU1
- and %g2, 7, %g2 ! IEU0 Group
- andncc %g3, 0x7, %g3 ! IEU1
- fmovd %f0, %f2 ! FPU
- sub %g3, 0x10, %g3 ! IEU0 Group
- sub %o2, %g7, %o2 ! IEU1
-#ifdef __KERNEL__
- or asi_src, ASI_BLK_OR, asi_src ! IEU0 Group
- or asi_dest, ASI_BLK_OR, asi_dest ! IEU1
-#endif
- alignaddr %g1, %g0, %g0 ! GRU Group
- add %g1, %g7, %g1 ! IEU0 Group
- subcc %o2, %g3, %o2 ! IEU1
- ASI_SETSRC_BLK ! LSU Group
- EXVIS1(LDBLK [%o1 + 0x00] ASIBLK, %f0) ! LSU Group
- add %g1, %g3, %g1 ! IEU0
- EXVIS1(LDBLK [%o1 + 0x40] ASIBLK, %f16) ! LSU Group
- sub %g7, 0x80, %g7 ! IEU0
- EXVIS(LDBLK [%o1 + 0x80] ASIBLK, %f32) ! LSU Group
-#ifdef __KERNEL__
-vispc: sll %g2, 9, %g2 ! IEU0 Group
- sethi %hi(vis00), %g5 ! IEU1
- or %g5, %lo(vis00), %g5 ! IEU0 Group
- jmpl %g5 + %g2, %g0 ! CTI Group brk forced
- addcc %o1, 0xc0, %o1 ! IEU1 Group
-#else
- ! Clk1 Group 8-(
- ! Clk2 Group 8-(
- ! Clk3 Group 8-(
- ! Clk4 Group 8-(
-vispc: rd %pc, %g5 ! PDU Group 8-(
- addcc %g5, %lo(vis00 - vispc), %g5 ! IEU1 Group
- sll %g2, 9, %g2 ! IEU0
- jmpl %g5 + %g2, %g0 ! CTI Group brk forced
- addcc %o1, 0xc0, %o1 ! IEU1 Group
-#endif
- .align 512 /* OK, here comes the fun part... */
-vis00:FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) LOOP_CHUNK1(o1, o0, g7, vis01)
- FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) LOOP_CHUNK2(o1, o0, g7, vis02)
- FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) LOOP_CHUNK3(o1, o0, g7, vis03)
- b,pt %xcc, vis00+4; faligndata %f0, %f2, %f48
-vis01:FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_JUMP(o0, f48, finish_f0) membar #Sync
-vis02:FREG_FROB(f32,f34,f36,f38,f40,f42,f44,f46,f0) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_JUMP(o0, f48, finish_f16) membar #Sync
-vis03:FREG_FROB(f0, f2, f4, f6, f8, f10,f12,f14,f16) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f16,f18,f20,f22,f24,f26,f28,f30,f32) STORE_JUMP(o0, f48, finish_f32) membar #Sync
- VISLOOP_PAD
-vis10:FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) LOOP_CHUNK1(o1, o0, g7, vis11)
- FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) LOOP_CHUNK2(o1, o0, g7, vis12)
- FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) LOOP_CHUNK3(o1, o0, g7, vis13)
- b,pt %xcc, vis10+4; faligndata %f2, %f4, %f48
-vis11:FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_JUMP(o0, f48, finish_f2) membar #Sync
-vis12:FREG_FROB(f34,f36,f38,f40,f42,f44,f46,f0, f2) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_JUMP(o0, f48, finish_f18) membar #Sync
-vis13:FREG_FROB(f2, f4, f6, f8, f10,f12,f14,f16,f18) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f18,f20,f22,f24,f26,f28,f30,f32,f34) STORE_JUMP(o0, f48, finish_f34) membar #Sync
- VISLOOP_PAD
-vis20:FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) LOOP_CHUNK1(o1, o0, g7, vis21)
- FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) LOOP_CHUNK2(o1, o0, g7, vis22)
- FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) LOOP_CHUNK3(o1, o0, g7, vis23)
- b,pt %xcc, vis20+4; faligndata %f4, %f6, %f48
-vis21:FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_JUMP(o0, f48, finish_f4) membar #Sync
-vis22:FREG_FROB(f36,f38,f40,f42,f44,f46,f0, f2, f4) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_JUMP(o0, f48, finish_f20) membar #Sync
-vis23:FREG_FROB(f4, f6, f8, f10,f12,f14,f16,f18,f20) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f20,f22,f24,f26,f28,f30,f32,f34,f36) STORE_JUMP(o0, f48, finish_f36) membar #Sync
- VISLOOP_PAD
-vis30:FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) LOOP_CHUNK1(o1, o0, g7, vis31)
- FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) LOOP_CHUNK2(o1, o0, g7, vis32)
- FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) LOOP_CHUNK3(o1, o0, g7, vis33)
- b,pt %xcc, vis30+4; faligndata %f6, %f8, %f48
-vis31:FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_JUMP(o0, f48, finish_f6) membar #Sync
-vis32:FREG_FROB(f38,f40,f42,f44,f46,f0, f2, f4, f6) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_JUMP(o0, f48, finish_f22) membar #Sync
-vis33:FREG_FROB(f6, f8, f10,f12,f14,f16,f18,f20,f22) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f22,f24,f26,f28,f30,f32,f34,f36,f38) STORE_JUMP(o0, f48, finish_f38) membar #Sync
- VISLOOP_PAD
-vis40:FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) LOOP_CHUNK1(o1, o0, g7, vis41)
- FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) LOOP_CHUNK2(o1, o0, g7, vis42)
- FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) LOOP_CHUNK3(o1, o0, g7, vis43)
- b,pt %xcc, vis40+4; faligndata %f8, %f10, %f48
-vis41:FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_JUMP(o0, f48, finish_f8) membar #Sync
-vis42:FREG_FROB(f40,f42,f44,f46,f0, f2, f4, f6, f8) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_JUMP(o0, f48, finish_f24) membar #Sync
-vis43:FREG_FROB(f8, f10,f12,f14,f16,f18,f20,f22,f24) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f24,f26,f28,f30,f32,f34,f36,f38,f40) STORE_JUMP(o0, f48, finish_f40) membar #Sync
- VISLOOP_PAD
-vis50:FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) LOOP_CHUNK1(o1, o0, g7, vis51)
- FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) LOOP_CHUNK2(o1, o0, g7, vis52)
- FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) LOOP_CHUNK3(o1, o0, g7, vis53)
- b,pt %xcc, vis50+4; faligndata %f10, %f12, %f48
-vis51:FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_JUMP(o0, f48, finish_f10) membar #Sync
-vis52:FREG_FROB(f42,f44,f46,f0, f2, f4, f6, f8, f10) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_JUMP(o0, f48, finish_f26) membar #Sync
-vis53:FREG_FROB(f10,f12,f14,f16,f18,f20,f22,f24,f26) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f26,f28,f30,f32,f34,f36,f38,f40,f42) STORE_JUMP(o0, f48, finish_f42) membar #Sync
- VISLOOP_PAD
-vis60:FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) LOOP_CHUNK1(o1, o0, g7, vis61)
- FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) LOOP_CHUNK2(o1, o0, g7, vis62)
- FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) LOOP_CHUNK3(o1, o0, g7, vis63)
- b,pt %xcc, vis60+4; faligndata %f12, %f14, %f48
-vis61:FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_JUMP(o0, f48, finish_f12) membar #Sync
-vis62:FREG_FROB(f44,f46,f0, f2, f4, f6, f8, f10,f12) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_JUMP(o0, f48, finish_f28) membar #Sync
-vis63:FREG_FROB(f12,f14,f16,f18,f20,f22,f24,f26,f28) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f28,f30,f32,f34,f36,f38,f40,f42,f44) STORE_JUMP(o0, f48, finish_f44) membar #Sync
- VISLOOP_PAD
-vis70:FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) LOOP_CHUNK1(o1, o0, g7, vis71)
- FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) LOOP_CHUNK2(o1, o0, g7, vis72)
- FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) LOOP_CHUNK3(o1, o0, g7, vis73)
- b,pt %xcc, vis70+4; faligndata %f14, %f16, %f48
-vis71:FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_JUMP(o0, f48, finish_f14) membar #Sync
-vis72:FREG_FROB(f46,f0, f2, f4, f6, f8, f10,f12,f14) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_JUMP(o0, f48, finish_f30) membar #Sync
-vis73:FREG_FROB(f14,f16,f18,f20,f22,f24,f26,f28,f30) STORE_SYNC(o0, f48) membar #Sync
- FREG_FROB(f30,f32,f34,f36,f38,f40,f42,f44,f46) STORE_JUMP(o0, f48, finish_f46) membar #Sync
- VISLOOP_PAD
-finish_f0: FINISH_VISCHUNK(o0, f0, f2, g3)
-finish_f2: FINISH_VISCHUNK(o0, f2, f4, g3)
-finish_f4: FINISH_VISCHUNK(o0, f4, f6, g3)
-finish_f6: FINISH_VISCHUNK(o0, f6, f8, g3)
-finish_f8: FINISH_VISCHUNK(o0, f8, f10, g3)
-finish_f10: FINISH_VISCHUNK(o0, f10, f12, g3)
-finish_f12: FINISH_VISCHUNK(o0, f12, f14, g3)
-finish_f14: UNEVEN_VISCHUNK(o0, f14, f0, g3)
-finish_f16: FINISH_VISCHUNK(o0, f16, f18, g3)
-finish_f18: FINISH_VISCHUNK(o0, f18, f20, g3)
-finish_f20: FINISH_VISCHUNK(o0, f20, f22, g3)
-finish_f22: FINISH_VISCHUNK(o0, f22, f24, g3)
-finish_f24: FINISH_VISCHUNK(o0, f24, f26, g3)
-finish_f26: FINISH_VISCHUNK(o0, f26, f28, g3)
-finish_f28: FINISH_VISCHUNK(o0, f28, f30, g3)
-finish_f30: UNEVEN_VISCHUNK(o0, f30, f0, g3)
-finish_f32: FINISH_VISCHUNK(o0, f32, f34, g3)
-finish_f34: FINISH_VISCHUNK(o0, f34, f36, g3)
-finish_f36: FINISH_VISCHUNK(o0, f36, f38, g3)
-finish_f38: FINISH_VISCHUNK(o0, f38, f40, g3)
-finish_f40: FINISH_VISCHUNK(o0, f40, f42, g3)
-finish_f42: FINISH_VISCHUNK(o0, f42, f44, g3)
-finish_f44: FINISH_VISCHUNK(o0, f44, f46, g3)
-finish_f46: UNEVEN_VISCHUNK_LAST(o0, f46, f0, g3)
-vis_out_slk:
-#ifdef __KERNEL__
- srl asi_src, 3, %g5 ! IEU0 Group
- xor asi_src, ASI_BLK_XOR1, asi_src ! IEU1
- xor asi_src, %g5, asi_src ! IEU0 Group
-#endif
-vis_slk:ASI_SETSRC_NOBLK ! LSU Group
- EXVIS3(LDDF [%o1] ASINORMAL, %f2) ! Load Group
- add %o1, 8, %o1 ! IEU0
- subcc %g3, 8, %g3 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f0, %f2, %f8 ! GRU Group
- EXVIS4(STDF %f8, [%o0] ASINORMAL) ! Store
- bl,pn %xcc, vis_out_slp ! CTI
- add %o0, 8, %o0 ! IEU0 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EXVIS3(LDDF [%o1] ASINORMAL, %f0) ! Load Group
- add %o1, 8, %o1 ! IEU0
- subcc %g3, 8, %g3 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f2, %f0, %f8 ! GRU Group
- EXVIS4(STDF %f8, [%o0] ASINORMAL) ! Store
- bge,pt %xcc, vis_slk ! CTI
- add %o0, 8, %o0 ! IEU0 Group
-vis_out_slp:
-#ifdef __KERNEL__
- brz,pt %o2, vis_ret ! CTI Group
- mov %g1, %o1 ! IEU0
- ba,pt %xcc, vis_slp+4 ! CTI Group
- ASI_SETSRC_NOBLK ! LSU Group
-#endif
-vis_out:brz,pt %o2, vis_ret ! CTI Group
- mov %g1, %o1 ! IEU0
-#ifdef __KERNEL__
- srl asi_src, 3, %g5 ! IEU0 Group
- xor asi_src, ASI_BLK_XOR1, asi_src ! IEU1
- xor asi_src, %g5, asi_src ! IEU0 Group
-#endif
-vis_slp:ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUB [%o1] ASINORMAL, %g5) ! LOAD
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- subcc %o2, 1, %o2 ! IEU1
- bne,pt %xcc, vis_slp ! CTI
- EX(STB %g5, [%o0 - 1] ASINORMAL,
- add %o2, 1) ! Store Group
-vis_ret:membar #StoreLoad | #StoreStore ! LSU Group
- FPU_CLEAN_RETL
-
-
-__memcpy_short:
- andcc %o2, 1, %g0 ! IEU1 Group
- be,pt %icc, 2f ! CTI
-1: ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUB [%o1] ASINORMAL, %g5) ! LOAD Group
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- subcc %o2, 1, %o2 ! IEU1 Group
- be,pn %xcc, short_ret ! CTI
- EX(STB %g5, [%o0 - 1] ASINORMAL,
- add %o2, 1) ! Store
-2: ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUB [%o1] ASINORMAL, %g5) ! LOAD Group
- add %o0, 2, %o0 ! IEU0
- EX2(LDUB [%o1 + 1] ASINORMAL, %o5,
- sub %o0, 2, %o0,
- add %o2, %g0) ! LOAD Group
- add %o1, 2, %o1 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- subcc %o2, 2, %o2 ! IEU1 Group
- EX(STB %g5, [%o0 - 2] ASINORMAL,
- add %o2, 2) ! Store
- bne,pt %xcc, 2b ! CTI
- EX(STB %o5, [%o0 - 1] ASINORMAL,
- add %o2, 1) ! Store
-short_ret:
- NORMAL_RETL
-
-#ifndef __KERNEL__
-memcpy_private:
-memcpy:
-#ifndef REGS_64BIT
- srl %o2, 0, %o2 ! IEU1 Group
-#endif
- brz,pn %o2, short_ret ! CTI Group
- mov %o0, %g6 ! IEU0
-#endif
-__memcpy_entry:
- cmp %o2, 15 ! IEU1 Group
- bleu,pn %xcc, __memcpy_short ! CTI
- cmp %o2, (64 * 6) ! IEU1 Group
- bgeu,pn %xcc, VIS_enter ! CTI
- andcc %o0, 7, %g2 ! IEU1 Group
- sub %o0, %o1, %g5 ! IEU0
- andcc %g5, 3, %o5 ! IEU1 Group
- bne,pn %xcc, memcpy_noVIS_misaligned ! CTI
- andcc %o1, 3, %g0 ! IEU1 Group
-#ifdef REGS_64BIT
- be,a,pt %xcc, 3f ! CTI
- andcc %o1, 4, %g0 ! IEU1 Group
- andcc %o1, 1, %g0 ! IEU1 Group
-#else /* !REGS_64BIT */
- be,pt %xcc, 5f ! CTI
- andcc %o1, 1, %g0 ! IEU1 Group
-#endif /* !REGS_64BIT */
- be,pn %xcc, 4f ! CTI
- andcc %o1, 2, %g0 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUB [%o1] ASINORMAL, %g2) ! Load Group
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- sub %o2, 1, %o2 ! IEU0 Group
- ASI_SETDST_NOBLK ! LSU Group
- bne,pn %xcc, 5f ! CTI Group
- EX(STB %g2, [%o0 - 1] ASINORMAL,
- add %o2, 1) ! Store
-4: ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUH [%o1] ASINORMAL, %g2) ! Load Group
- add %o1, 2, %o1 ! IEU0
- add %o0, 2, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- sub %o2, 2, %o2 ! IEU0
- EX(STH %g2, [%o0 - 2] ASINORMAL,
- add %o2, 2) ! Store Group + bubble
-#ifdef REGS_64BIT
-5: andcc %o1, 4, %g0 ! IEU1
-3: be,a,pn %xcc, 2f ! CTI
- andcc %o2, -128, %g7 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EXO2(LDUW [%o1] ASINORMAL, %g5) ! Load Group
- add %o1, 4, %o1 ! IEU0
- add %o0, 4, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- sub %o2, 4, %o2 ! IEU0 Group
- EX(STW %g5, [%o0 - 4] ASINORMAL,
- add %o2, 4) ! Store
- andcc %o2, -128, %g7 ! IEU1 Group
-2: be,pn %xcc, 3f ! CTI
- andcc %o0, 4, %g0 ! IEU1 Group
- be,pn %xcc, 82f + 4 ! CTI Group
-#else /* !REGS_64BIT */
-5: andcc %o2, -128, %g7 ! IEU1
- be,a,pn %xcc, 41f ! CTI
- andcc %o2, 0x70, %g7 ! IEU1 Group
-#endif /* !REGS_64BIT */
-5: MOVE_BIGCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x20, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- MOVE_BIGCHUNK(o1, o0, 0x60, g1, g3, g5, o5)
- EXT(5b,35f,VIScopyfixup1)
-35: subcc %g7, 128, %g7 ! IEU1 Group
- add %o1, 128, %o1 ! IEU0
- bne,pt %xcc, 5b ! CTI
- add %o0, 128, %o0 ! IEU0 Group
-3: andcc %o2, 0x70, %g7 ! IEU1 Group
-41: be,pn %xcc, 80f ! CTI
- andcc %o2, 8, %g0 ! IEU1 Group
-#ifdef __KERNEL__
-79: sethi %hi(80f), %o5 ! IEU0
- sll %g7, 1, %g5 ! IEU0 Group
- add %o1, %g7, %o1 ! IEU1
- srl %g7, 1, %g2 ! IEU0 Group
- sub %o5, %g5, %o5 ! IEU1
- sub %o5, %g2, %o5 ! IEU0 Group
- jmpl %o5 + %lo(80f), %g0 ! CTI Group brk forced
- add %o0, %g7, %o0 ! IEU0 Group
-#else
- ! Clk1 8-(
- ! Clk2 8-(
- ! Clk3 8-(
- ! Clk4 8-(
-79: rd %pc, %o5 ! PDU Group
- sll %g7, 1, %g5 ! IEU0 Group
- add %o1, %g7, %o1 ! IEU1
- sub %o5, %g5, %o5 ! IEU0 Group
- jmpl %o5 + %lo(80f - 79b), %g0 ! CTI Group brk forced
- add %o0, %g7, %o0 ! IEU0 Group
-#endif
-36: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g5, o5)
- MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g5, o5)
- EXT(36b,80f,VIScopyfixup2)
-80: be,pt %xcc, 81f ! CTI
- andcc %o2, 4, %g0 ! IEU1
-#ifdef REGS_64BIT
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDX [%o1] ASINORMAL, %g2,
- and %o2, 0xf) ! Load Group
- add %o0, 8, %o0 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- EX(STW %g2, [%o0 - 0x4] ASINORMAL,
- and %o2, 0xf) ! Store Group
- add %o1, 8, %o1 ! IEU1
- srlx %g2, 32, %g2 ! IEU0 Group
- EX2(STW %g2, [%o0 - 0x8] ASINORMAL,
- and %o2, 0xf, %o2,
- sub %o2, 4) ! Store
-#else /* !REGS_64BIT */
- lduw [%o1], %g2 ! Load Group
- add %o0, 8, %o0 ! IEU0
- lduw [%o1 + 0x4], %g3 ! Load Group
- add %o1, 8, %o1 ! IEU0
- stw %g2, [%o0 - 0x8] ! Store Group
- stw %g3, [%o0 - 0x4] ! Store Group
-#endif /* !REGS_64BIT */
-81: be,pt %xcc, 1f ! CTI
- andcc %o2, 2, %g0 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUW [%o1] ASINORMAL, %g2,
- and %o2, 0x7) ! Load Group
- add %o1, 4, %o1 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- EX(STW %g2, [%o0] ASINORMAL,
- and %o2, 0x7) ! Store Group
- add %o0, 4, %o0 ! IEU0
-1: be,pt %xcc, 1f ! CTI
- andcc %o2, 1, %g0 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUH [%o1] ASINORMAL, %g2,
- and %o2, 0x3) ! Load Group
- add %o1, 2, %o1 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- EX(STH %g2, [%o0] ASINORMAL,
- and %o2, 0x3) ! Store Group
- add %o0, 2, %o0 ! IEU0
-1: be,pt %xcc, normal_retl ! CTI
- nop ! IEU1
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUB [%o1] ASINORMAL, %g2,
- add %g0, 1) ! Load Group
- ASI_SETDST_NOBLK ! LSU Group
- EX(STB %g2, [%o0] ASINORMAL,
- add %g0, 1) ! Store Group + bubble
-normal_retl:
- NORMAL_RETL
-
-#ifdef REGS_64BIT
-82: MOVE_BIGALIGNCHUNK(o1, o0, 0x00, g1, g3, g5, o5)
- MOVE_BIGALIGNCHUNK(o1, o0, 0x40, g1, g3, g5, o5)
- EXT(82b,37f,VIScopyfixup3)
-37: subcc %g7, 128, %g7 ! IEU1 Group
- add %o1, 128, %o1 ! IEU0
- bne,pt %xcc, 82b ! CTI
- add %o0, 128, %o0 ! IEU0 Group
- andcc %o2, 0x70, %g7 ! IEU1
- be,pn %xcc, 84f ! CTI
- andcc %o2, 8, %g0 ! IEU1 Group
-#ifdef __KERNEL__
-83: srl %g7, 1, %g5 ! IEU0
- sethi %hi(84f), %o5 ! IEU0 Group
- add %g7, %g5, %g5 ! IEU1
- add %o1, %g7, %o1 ! IEU0 Group
- sub %o5, %g5, %o5 ! IEU1
- jmpl %o5 + %lo(84f), %g0 ! CTI Group brk forced
- add %o0, %g7, %o0 ! IEU0 Group
-#else
- ! Clk1 8-(
- ! Clk2 8-(
- ! Clk3 8-(
- ! Clk4 8-(
-83: rd %pc, %o5 ! PDU Group
- add %o1, %g7, %o1 ! IEU0 Group
- sub %o5, %g7, %o5 ! IEU1
- jmpl %o5 + %lo(84f - 83b), %g0 ! CTI Group brk forced
- add %o0, %g7, %o0 ! IEU0 Group
-#endif
-38: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3)
- MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3)
- EXT(38b,84f,VIScopyfixup4)
-84: be,pt %xcc, 85f ! CTI Group
- andcc %o2, 4, %g0 ! IEU1
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDX [%o1] ASINORMAL, %g2,
- and %o2, 0xf) ! Load Group
- add %o0, 8, %o0 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- add %o1, 8, %o1 ! IEU0 Group
- EX(STX %g2, [%o0 - 0x8] ASINORMAL,
- and %o2, 0xf) ! Store
-85: be,pt %xcc, 1f ! CTI
- andcc %o2, 2, %g0 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUW [%o1] ASINORMAL, %g2,
- and %o2, 0x7) ! Load Group
- add %o0, 4, %o0 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- add %o1, 4, %o1 ! IEU0 Group
- EX(STW %g2, [%o0 - 0x4] ASINORMAL,
- and %o2, 0x7) ! Store
-1: be,pt %xcc, 1f ! CTI
- andcc %o2, 1, %g0 ! IEU1 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUH [%o1] ASINORMAL, %g2,
- and %o2, 0x3) ! Load Group
- add %o0, 2, %o0 ! IEU0
- ASI_SETDST_NOBLK ! LSU Group
- add %o1, 2, %o1 ! IEU0 Group
- EX(STH %g2, [%o0 - 0x2] ASINORMAL,
- and %o2, 0x3) ! Store
-1: be,pt %xcc, 1f ! CTI
- nop ! IEU0 Group
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUB [%o1] ASINORMAL, %g2,
- add %g0, 1) ! Load Group
- ASI_SETDST_NOBLK ! LSU Group
- EX(STB %g2, [%o0] ASINORMAL,
- add %g0, 1) ! Store Group + bubble
-1: NORMAL_RETL
-#endif /* REGS_64BIT */
-
-memcpy_noVIS_misaligned:
- brz,pt %g2, 2f ! CTI Group
- mov 8, %g1 ! IEU0
- sub %g1, %g2, %g2 ! IEU0 Group
- sub %o2, %g2, %o2 ! IEU0 Group
-1: ASI_SETSRC_NOBLK ! LSU Group
- EX(LDUB [%o1] ASINORMAL, %g5,
- add %o2, %g2) ! Load Group
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- subcc %g2, 1, %g2 ! IEU1 Group
- bne,pt %xcc, 1b ! CTI
- EX2(STB %g5, [%o0 - 1] ASINORMAL,
- add %o2, %g2, %o2,
- add %o2, 1) ! Store
-2:
-#ifdef __KERNEL__
- VISEntry
-#endif
- andn %o2, 7, %g5 ! IEU0 Group
- and %o2, 7, %o2 ! IEU1
- fmovd %f0, %f2 ! FPU
- ASI_SETSRC_NOBLK ! LSU Group
- alignaddr %o1, %g0, %g1 ! GRU Group
- EXO2(LDDF [%g1] ASINORMAL, %f4) ! Load Group
-1: EX(LDDF [%g1 + 0x8] ASINORMAL, %f6,
- add %o2, %g5) ! Load Group
- add %g1, 0x8, %g1 ! IEU0 Group
- subcc %g5, 8, %g5 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f4, %f6, %f0 ! GRU Group
- EX2(STDF %f0, [%o0] ASINORMAL,
- add %o2, %g5, %o2,
- add %o2, 8) ! Store
- add %o1, 8, %o1 ! IEU0 Group
- be,pn %xcc, end_cruft ! CTI
- add %o0, 8, %o0 ! IEU1
- ASI_SETSRC_NOBLK ! LSU Group
- EX(LDDF [%g1 + 0x8] ASINORMAL, %f4,
- add %o2, %g5) ! Load Group
- add %g1, 8, %g1 ! IEU0
- subcc %g5, 8, %g5 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- faligndata %f6, %f4, %f0 ! GRU Group
- EX2(STDF %f0, [%o0] ASINORMAL,
- add %o2, %g5, %o2,
- add %o2, 8) ! Store
- add %o1, 8, %o1 ! IEU0
- ASI_SETSRC_NOBLK ! LSU Group
- bne,pn %xcc, 1b ! CTI Group
- add %o0, 8, %o0 ! IEU0
-end_cruft:
- brz,pn %o2, fpu_retl ! CTI Group
-#ifndef __KERNEL__
- nop ! IEU0
-#else
- ASI_SETSRC_NOBLK ! LSU Group
-#endif
- EXO2(LDUB [%o1] ASINORMAL, %g5) ! LOAD
- add %o1, 1, %o1 ! IEU0
- add %o0, 1, %o0 ! IEU1
- ASI_SETDST_NOBLK ! LSU Group
- subcc %o2, 1, %o2 ! IEU1
- bne,pt %xcc, vis_slp ! CTI
- EX(STB %g5, [%o0 - 1] ASINORMAL,
- add %o2, 1) ! Store Group
-fpu_retl:
- FPU_RETL
-
-#ifdef __KERNEL__
- .section .fixup
- .align 4
-VIScopyfixup_reto2:
- mov %o2, %o1
-VIScopyfixup_ret:
- /* If this is copy_from_user(), zero out the rest of the
- * kernel buffer.
- */
- ldub [%g6 + TI_CURRENT_DS], %o4
- andcc asi_src, 0x1, %g0
- be,pt %icc, 1f
- VISExit
- andcc asi_dest, 0x1, %g0
- bne,pn %icc, 1f
- nop
- save %sp, -160, %sp
- mov %i0, %o0
- call __bzero
- mov %i1, %o1
- restore
-1: mov %o1, %o0
- retl
- wr %o4, %g0, %asi
-VIScopyfixup1: subcc %g2, 18, %g2
- add %o0, 32, %o0
- bgeu,a,pt %icc, VIScopyfixup1
- sub %g7, 32, %g7
- sub %o0, 32, %o0
- rd %pc, %g5
- add %g2, (18 + 16), %g2
- ldub [%g5 + %g2], %g2
- ba,a,pt %xcc, 2f
-.byte 0, 0, 0, 0, 0, 0, 0, 4, 4, 8, 12, 12, 16, 20, 20, 24, 28, 28
- .align 4
-VIScopyfixup2: mov (7 * 16), %g7
-1: subcc %g2, 10, %g2
- bgeu,a,pt %icc, 1b
- sub %g7, 16, %g7
- sub %o0, %g7, %o0
- rd %pc, %g5
- add %g2, (10 + 16), %g2
- ldub [%g5 + %g2], %g2
- ba,a,pt %xcc, 4f
-.byte 0, 0, 0, 0, 0, 4, 4, 8, 12, 12
- .align 4
-VIScopyfixup3: subcc %g2, 10, %g2
- add %o0, 32, %o0
- bgeu,a,pt %icc, VIScopyfixup3
- sub %g7, 32, %g7
- sub %o0, 32, %o0
- rd %pc, %g5
- add %g2, (10 + 16), %g2
- ldub [%g5 + %g2], %g2
- ba,a,pt %xcc, 2f
-.byte 0, 0, 0, 0, 0, 0, 0, 8, 16, 24
- .align 4
-2: and %o2, 0x7f, %o2
- sub %g7, %g2, %g7
- ba,pt %xcc, VIScopyfixup_ret
- add %g7, %o2, %o1
-VIScopyfixup4: mov (7 * 16), %g7
-3: subcc %g2, 6, %g2
- bgeu,a,pt %icc, 3b
- sub %g7, 16, %g7
- sub %o0, %g7, %o0
- rd %pc, %g5
- add %g2, (6 + 16), %g2
- ldub [%g5 + %g2], %g2
- ba,a,pt %xcc, 4f
-.byte 0, 0, 0, 0, 0, 8
- .align 4
-4: and %o2, 0xf, %o2
- sub %g7, %g2, %g7
- ba,pt %xcc, VIScopyfixup_ret
- add %g7, %o2, %o1
-VIScopyfixup_vis2:
- sub %o2, 0x40, %o2
-VIScopyfixup_vis0:
- add %o2, 0x80, %o2
-VIScopyfixup_vis1:
- add %g7, %g3, %g7
- ba,pt %xcc, VIScopyfixup_ret
- add %o2, %g7, %o1
-VIScopyfixup_vis4:
- add %g3, 8, %g3
-VIScopyfixup_vis3:
- add %g3, 8, %g3
- ba,pt %xcc, VIScopyfixup_ret
- add %o2, %g3, %o1
-#endif
-
-#ifdef __KERNEL__
- .text
- .align 32
-
- .globl __memmove
- .type __memmove,@function
-
- .globl memmove
- .type memmove,@function
-
-memmove:
-__memmove: cmp %o0, %o1
- blu,pt %xcc, memcpy_private
- sub %o0, %o1, %g5
- add %o1, %o2, %g3
- cmp %g3, %o0
- bleu,pt %xcc, memcpy_private
- add %o1, %o2, %g5
- add %o0, %o2, %o5
-
- sub %g5, 1, %o1
- sub %o5, 1, %o0
-1: ldub [%o1], %g5
- subcc %o2, 1, %o2
- sub %o1, 1, %o1
- stb %g5, [%o0]
- bne,pt %icc, 1b
- sub %o0, 1, %o0
-
- retl
- clr %o0
-#endif
+++ /dev/null
-/* $Id: blockops.S,v 1.42 2002/02/09 19:49:30 davem Exp $
- * blockops.S: UltraSparc block zero optimized routines.
- *
- * Copyright (C) 1996, 1998, 1999, 2000 David S. Miller (davem@redhat.com)
- * Copyright (C) 1997 Jakub Jelinek (jakub@redhat.com)
- */
-
-#include "VIS.h"
-#include <asm/visasm.h>
-#include <asm/thread_info.h>
-#include <asm/page.h>
-#include <asm/dcu.h>
-#include <asm/spitfire.h>
-#include <asm/pgtable.h>
-
-#define TOUCH(reg0, reg1, reg2, reg3, reg4, reg5, reg6, reg7) \
- fmovd %reg0, %f48; fmovd %reg1, %f50; \
- fmovd %reg2, %f52; fmovd %reg3, %f54; \
- fmovd %reg4, %f56; fmovd %reg5, %f58; \
- fmovd %reg6, %f60; fmovd %reg7, %f62;
-
-#define DCACHE_SIZE (PAGE_SIZE * 2)
-#define TLBTEMP_ENT1 (60 << 3)
-#define TLBTEMP_ENT2 (61 << 3)
-#define TLBTEMP_ENTSZ (1 << 3)
-
-#if (PAGE_SHIFT == 13) || (PAGE_SHIFT == 19)
-#define PAGE_SIZE_REM 0x80
-#elif (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
-#define PAGE_SIZE_REM 0x100
-#else
-#error Wrong PAGE_SHIFT specified
-#endif
-
- .text
-
- .align 32
- .globl copy_user_page
- .type copy_user_page,@function
-copy_user_page: /* %o0=dest, %o1=src, %o2=vaddr */
- VISEntry
- sethi %hi(PAGE_SIZE), %g3
- sethi %uhi(PAGE_OFFSET), %g2
- sllx %g2, 32, %g2
- sub %o0, %g2, %g1
- and %o2, %g3, %o0
- sethi %hi(TLBTEMP_BASE), %o3
- sethi %uhi(_PAGE_VALID | _PAGE_SZBITS), %g3
- sub %o1, %g2, %g2
- sllx %g3, 32, %g3
- mov TLB_TAG_ACCESS, %o2
- or %g3, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W), %g3
- sethi %hi(DCACHE_SIZE), %o1
- or %g1, %g3, %g1
- or %g2, %g3, %g2
- add %o0, %o3, %o0
- add %o0, %o1, %o1
-#define FIX_INSN_1 0x96102060 /* mov (12 << 3), %o3 */
-cheetah_patch_1:
- mov TLBTEMP_ENT1, %o3
- rdpr %pstate, %g3
- wrpr %g3, PSTATE_IE, %pstate
-
- /* Do this now, before loading the fixed TLB entries for copying,
- * so we do not risk a multiple TLB match condition later when
- * restoring those entries.
- */
- ldx [%g6 + TI_FLAGS], %g3
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %o4
- stxa %g0, [%o4] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_TAG_READ, %o4
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %o5
- stxa %g0, [%o5] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %o5
- stxa %o0, [%o2] ASI_DMMU
- stxa %g1, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
- add %o3, (TLBTEMP_ENTSZ), %o3
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %g5
- stxa %g0, [%g5] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_TAG_READ, %g5
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %g7
- stxa %g0, [%g7] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g7
- stxa %o1, [%o2] ASI_DMMU
- stxa %g2, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
-
- andcc %g3, _TIF_BLKCOMMIT, %g0
- bne,pn %xcc, copy_page_using_blkcommit
- nop
-
- BRANCH_IF_ANY_CHEETAH(g3,o2,cheetah_copy_user_page)
- ba,pt %xcc, spitfire_copy_user_page
- nop
-
-cheetah_copy_user_page:
- .globl cheetah_copy_user_page_nop_1_6
-cheetah_copy_user_page_nop_1_6:
- ldxa [%g0] ASI_DCU_CONTROL_REG, %g3
- sethi %uhi(DCU_PE), %o2
- sllx %o2, 32, %o2
- or %g3, %o2, %o2
- stxa %o2, [%g0] ASI_DCU_CONTROL_REG ! Enable P-cache
- membar #Sync
-
- sethi %hi((PAGE_SIZE/64)-7), %o2 ! A0 Group
- prefetch [%o1 + 0x000], #one_read ! MS
- or %o2, %lo((PAGE_SIZE/64)-7), %o2 ! A1 Group
- prefetch [%o1 + 0x040], #one_read ! MS
- prefetch [%o1 + 0x080], #one_read ! MS Group
- prefetch [%o1 + 0x0c0], #one_read ! MS Group
- ldd [%o1 + 0x000], %f0 ! MS Group
- prefetch [%o1 + 0x100], #one_read ! MS Group
- ldd [%o1 + 0x008], %f2 ! AX
- prefetch [%o1 + 0x140], #one_read ! MS Group
- ldd [%o1 + 0x010], %f4 ! AX
- prefetch [%o1 + 0x180], #one_read ! MS Group
- fmovd %f0, %f32 ! FGA Group
- ldd [%o1 + 0x018], %f6 ! AX
- fmovd %f2, %f34 ! FGA Group
- ldd [%o1 + 0x020], %f8 ! MS
- fmovd %f4, %f36 ! FGA Group
- ldd [%o1 + 0x028], %f10 ! AX
- membar #StoreStore ! MS
- fmovd %f6, %f38 ! FGA Group
- ldd [%o1 + 0x030], %f12 ! MS
- fmovd %f8, %f40 ! FGA Group
- ldd [%o1 + 0x038], %f14 ! AX
- fmovd %f10, %f42 ! FGA Group
- ldd [%o1 + 0x040], %f16 ! MS
-1: ldd [%o1 + 0x048], %f2 ! AX (Group)
- fmovd %f12, %f44 ! FGA
- ldd [%o1 + 0x050], %f4 ! MS
- fmovd %f14, %f46 ! FGA Group
- stda %f32, [%o0] ASI_BLK_P ! MS
- ldd [%o1 + 0x058], %f6 ! AX
- fmovd %f16, %f32 ! FGA Group (8-cycle stall)
- ldd [%o1 + 0x060], %f8 ! MS
- fmovd %f2, %f34 ! FGA Group
- ldd [%o1 + 0x068], %f10 ! AX
- fmovd %f4, %f36 ! FGA Group
- ldd [%o1 + 0x070], %f12 ! MS
- fmovd %f6, %f38 ! FGA Group
- ldd [%o1 + 0x078], %f14 ! AX
- fmovd %f8, %f40 ! FGA Group
- ldd [%o1 + 0x080], %f16 ! AX
- prefetch [%o1 + 0x180], #one_read ! MS
- fmovd %f10, %f42 ! FGA Group
- subcc %o2, 1, %o2 ! A0
- add %o0, 0x40, %o0 ! A1
- bne,pt %xcc, 1b ! BR
- add %o1, 0x40, %o1 ! A0 Group
-
- mov 5, %o2 ! A0 Group
-1: ldd [%o1 + 0x048], %f2 ! AX
- fmovd %f12, %f44 ! FGA
- ldd [%o1 + 0x050], %f4 ! MS
- fmovd %f14, %f46 ! FGA Group
- stda %f32, [%o0] ASI_BLK_P ! MS
- ldd [%o1 + 0x058], %f6 ! AX
- fmovd %f16, %f32 ! FGA Group (8-cycle stall)
- ldd [%o1 + 0x060], %f8 ! MS
- fmovd %f2, %f34 ! FGA Group
- ldd [%o1 + 0x068], %f10 ! AX
- fmovd %f4, %f36 ! FGA Group
- ldd [%o1 + 0x070], %f12 ! MS
- fmovd %f6, %f38 ! FGA Group
- ldd [%o1 + 0x078], %f14 ! AX
- fmovd %f8, %f40 ! FGA Group
- ldd [%o1 + 0x080], %f16 ! MS
- fmovd %f10, %f42 ! FGA Group
- subcc %o2, 1, %o2 ! A0
- add %o0, 0x40, %o0 ! A1
- bne,pt %xcc, 1b ! BR
- add %o1, 0x40, %o1 ! A0 Group
-
- ldd [%o1 + 0x048], %f2 ! AX
- fmovd %f12, %f44 ! FGA
- ldd [%o1 + 0x050], %f4 ! MS
- fmovd %f14, %f46 ! FGA Group
- stda %f32, [%o0] ASI_BLK_P ! MS
- ldd [%o1 + 0x058], %f6 ! AX
- fmovd %f16, %f32 ! FGA Group (8-cycle stall)
- ldd [%o1 + 0x060], %f8 ! MS
- fmovd %f2, %f34 ! FGA Group
- ldd [%o1 + 0x068], %f10 ! AX
- fmovd %f4, %f36 ! FGA Group
- ldd [%o1 + 0x070], %f12 ! MS
- fmovd %f6, %f38 ! FGA Group
- add %o0, 0x40, %o0 ! A0
- ldd [%o1 + 0x078], %f14 ! AX
- fmovd %f8, %f40 ! FGA Group
- fmovd %f10, %f42 ! FGA Group
- fmovd %f12, %f44 ! FGA Group
- fmovd %f14, %f46 ! FGA Group
- stda %f32, [%o0] ASI_BLK_P ! MS
- .globl cheetah_copy_user_page_nop_2_3
-cheetah_copy_user_page_nop_2_3:
- mov PRIMARY_CONTEXT, %o2
- stxa %g0, [%o2] ASI_DMMU ! Flush P-cache
- stxa %g3, [%g0] ASI_DCU_CONTROL_REG ! Disable P-cache
- ba,a,pt %xcc, copy_user_page_continue
-
-spitfire_copy_user_page:
- ldda [%o1] ASI_BLK_P, %f0
- add %o1, 0x40, %o1
- ldda [%o1] ASI_BLK_P, %f16
- add %o1, 0x40, %o1
- sethi %hi(PAGE_SIZE), %o2
-1: TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
- ldda [%o1] ASI_BLK_P, %f32
- stda %f48, [%o0] ASI_BLK_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
- ldda [%o1] ASI_BLK_P, %f0
- stda %f48, [%o0] ASI_BLK_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f32, f34, f36, f38, f40, f42, f44, f46)
- ldda [%o1] ASI_BLK_P, %f16
- stda %f48, [%o0] ASI_BLK_P
- sub %o2, 0x40, %o2
- add %o1, 0x40, %o1
- cmp %o2, PAGE_SIZE_REM
- bne,pt %xcc, 1b
- add %o0, 0x40, %o0
-#if (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
- TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
- ldda [%o1] ASI_BLK_P, %f32
- stda %f48, [%o0] ASI_BLK_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
- ldda [%o1] ASI_BLK_P, %f0
- stda %f48, [%o0] ASI_BLK_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- membar #Sync
- stda %f32, [%o0] ASI_BLK_P
- add %o0, 0x40, %o0
- stda %f0, [%o0] ASI_BLK_P
-#else
- membar #Sync
- stda %f0, [%o0] ASI_BLK_P
- add %o0, 0x40, %o0
- stda %f16, [%o0] ASI_BLK_P
-#endif
-copy_user_page_continue:
- membar #Sync
- VISExit
-
- mov TLB_TAG_ACCESS, %o2
- stxa %g5, [%o2] ASI_DMMU
- stxa %g7, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
- sub %o3, (TLBTEMP_ENTSZ), %o3
- stxa %o4, [%o2] ASI_DMMU
- stxa %o5, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
- rdpr %pstate, %g3
- jmpl %o7 + 0x8, %g0
- wrpr %g3, PSTATE_IE, %pstate
-
-copy_page_using_blkcommit:
- membar #LoadStore | #StoreStore | #StoreLoad
- ldda [%o1] ASI_BLK_P, %f0
- add %o1, 0x40, %o1
- ldda [%o1] ASI_BLK_P, %f16
- add %o1, 0x40, %o1
- sethi %hi(PAGE_SIZE), %o2
-1: TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
- ldda [%o1] ASI_BLK_P, %f32
- stda %f48, [%o0] ASI_BLK_COMMIT_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
- ldda [%o1] ASI_BLK_P, %f0
- stda %f48, [%o0] ASI_BLK_COMMIT_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f32, f34, f36, f38, f40, f42, f44, f46)
- ldda [%o1] ASI_BLK_P, %f16
- stda %f48, [%o0] ASI_BLK_COMMIT_P
- sub %o2, 0x40, %o2
- add %o1, 0x40, %o1
- cmp %o2, PAGE_SIZE_REM
- bne,pt %xcc, 1b
- add %o0, 0x40, %o0
-#if (PAGE_SHIFT == 16) || (PAGE_SHIFT == 22)
- TOUCH(f0, f2, f4, f6, f8, f10, f12, f14)
- ldda [%o1] ASI_BLK_P, %f32
- stda %f48, [%o0] ASI_BLK_COMMIT_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- TOUCH(f16, f18, f20, f22, f24, f26, f28, f30)
- ldda [%o1] ASI_BLK_P, %f0
- stda %f48, [%o0] ASI_BLK_COMMIT_P
- add %o1, 0x40, %o1
- sub %o2, 0x40, %o2
- add %o0, 0x40, %o0
- membar #Sync
- stda %f32, [%o0] ASI_BLK_COMMIT_P
- add %o0, 0x40, %o0
- ba,pt %xcc, copy_user_page_continue
- stda %f0, [%o0] ASI_BLK_COMMIT_P
-#else
- membar #Sync
- stda %f0, [%o0] ASI_BLK_COMMIT_P
- add %o0, 0x40, %o0
- ba,pt %xcc, copy_user_page_continue
- stda %f16, [%o0] ASI_BLK_COMMIT_P
-#endif
-
- .align 32
- .globl _clear_page
- .type _clear_page,@function
-_clear_page: /* %o0=dest */
- VISEntryHalf
- ba,pt %xcc, clear_page_common
- clr %o4
-
- .align 32
- .globl clear_user_page
- .type clear_user_page,@function
-clear_user_page: /* %o0=dest, %o1=vaddr */
- VISEntryHalf
- sethi %hi(PAGE_SIZE), %g3
- sethi %uhi(PAGE_OFFSET), %g2
- sllx %g2, 32, %g2
- sub %o0, %g2, %g1
- and %o1, %g3, %o0
- mov TLB_TAG_ACCESS, %o2
- sethi %uhi(_PAGE_VALID | _PAGE_SZBITS), %g3
- sethi %hi(TLBTEMP_BASE), %o3
- sllx %g3, 32, %g3
- or %g3, (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_L | _PAGE_W), %g3
- or %g1, %g3, %g1
- add %o0, %o3, %o0
-#define FIX_INSN_2 0x96102068 /* mov (13 << 3), %o3 */
-cheetah_patch_2:
- mov TLBTEMP_ENT2, %o3
- rdpr %pstate, %g3
- wrpr %g3, PSTATE_IE, %pstate
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %g5
- stxa %g0, [%g5] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_TAG_READ, %g5
-
- /* Spitfire Errata #32 workaround */
- mov PRIMARY_CONTEXT, %g7
- stxa %g0, [%g7] ASI_DMMU
- membar #Sync
-
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g0
- ldxa [%o3] ASI_DTLB_DATA_ACCESS, %g7
- stxa %o0, [%o2] ASI_DMMU
- stxa %g1, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
-
- mov 1, %o4
-
-clear_page_common:
- membar #StoreLoad | #StoreStore | #LoadStore ! LSU Group
- fzero %f0 ! FPA Group
- sethi %hi(PAGE_SIZE/256), %o1 ! IEU0
- fzero %f2 ! FPA Group
- or %o1, %lo(PAGE_SIZE/256), %o1 ! IEU0
- faddd %f0, %f2, %f4 ! FPA Group
- fmuld %f0, %f2, %f6 ! FPM
- faddd %f0, %f2, %f8 ! FPA Group
- fmuld %f0, %f2, %f10 ! FPM
-
- faddd %f0, %f2, %f12 ! FPA Group
- fmuld %f0, %f2, %f14 ! FPM
-1: stda %f0, [%o0 + %g0] ASI_BLK_P ! Store Group
- add %o0, 0x40, %o0 ! IEU0
- stda %f0, [%o0 + %g0] ASI_BLK_P ! Store Group
- add %o0, 0x40, %o0 ! IEU0
- stda %f0, [%o0 + %g0] ASI_BLK_P ! Store Group
-
- add %o0, 0x40, %o0 ! IEU0 Group
- stda %f0, [%o0 + %g0] ASI_BLK_P ! Store Group
- subcc %o1, 1, %o1 ! IEU1
- bne,pt %icc, 1b ! CTI
- add %o0, 0x40, %o0 ! IEU0 Group
- membar #Sync ! LSU Group
- VISExitHalf
-
- brnz,pt %o4, 1f
- nop
-
- retl
- nop
-
-1:
- stxa %g5, [%o2] ASI_DMMU
- stxa %g7, [%o3] ASI_DTLB_DATA_ACCESS
- membar #Sync
- jmpl %o7 + 0x8, %g0
- wrpr %g3, 0x0, %pstate
-
- .globl cheetah_patch_pgcopyops
-cheetah_patch_pgcopyops:
- sethi %hi(FIX_INSN_1), %g1
- or %g1, %lo(FIX_INSN_1), %g1
- sethi %hi(cheetah_patch_1), %g2
- or %g2, %lo(cheetah_patch_1), %g2
- stw %g1, [%g2]
- flush %g2
- sethi %hi(FIX_INSN_2), %g1
- or %g1, %lo(FIX_INSN_2), %g1
- sethi %hi(cheetah_patch_2), %g2
- or %g2, %lo(cheetah_patch_2), %g2
- stw %g1, [%g2]
- flush %g2
- retl
- nop
-
-#undef FIX_INSN1
-#undef FIX_INSN2
-#undef PAGE_SIZE_REM
+++ /dev/null
-/* $Id: rwlock.S,v 1.4 2000/09/09 00:00:34 davem Exp $
- * rwlocks.S: These things are too big to do inline.
- *
- * Copyright (C) 1999 David S. Miller (davem@redhat.com)
- */
-
- .text
- .align 64
-
- /* The non-contention read lock usage is 2 cache lines. */
-
- .globl __read_lock, __read_unlock
-__read_lock: /* %o0 = lock_ptr */
- ldsw [%o0], %g5
- brlz,pn %g5, __read_wait_for_writer
-4: add %g5, 1, %g7
- cas [%o0], %g5, %g7
- cmp %g5, %g7
- bne,pn %icc, __read_lock
- membar #StoreLoad | #StoreStore
-99: retl
- nop
-__read_unlock: /* %o0 = lock_ptr */
- lduw [%o0], %g5
- sub %g5, 1, %g7
- cas [%o0], %g5, %g7
- cmp %g5, %g7
- be,pt %xcc, 99b
- membar #StoreLoad | #StoreStore
- ba,a,pt %xcc, __read_unlock
-
-__read_wait_for_writer:
- ldsw [%o0], %g5
- brlz,pt %g5, __read_wait_for_writer
- membar #LoadLoad
- ba,a,pt %xcc, 4b
-__write_wait_for_any:
- lduw [%o0], %g5
- brnz,pt %g5, __write_wait_for_any
- membar #LoadLoad
- ba,a,pt %xcc, 4f
-
- .align 64
- .globl __write_unlock
-__write_unlock: /* %o0 = lock_ptr */
- membar #LoadStore | #StoreStore
- retl
- stw %g0, [%o0]
-
- .globl __write_lock
-__write_lock: /* %o0 = lock_ptr */
- sethi %hi(0x80000000), %g2
-
-1: lduw [%o0], %g5
- brnz,pn %g5, __write_wait_for_any
-4: or %g5, %g2, %g7
- cas [%o0], %g5, %g7
-
- cmp %g5, %g7
- be,pt %icc, 99b
- membar #StoreLoad | #StoreStore
- ba,a,pt %xcc, 1b
-
- .globl __write_trylock
-__write_trylock: /* %o0 = lock_ptr */
- sethi %hi(0x80000000), %g2
-1: lduw [%o0], %g5
- brnz,pn %g5, __write_trylock_fail
-4: or %g5, %g2, %g7
-
- cas [%o0], %g5, %g7
- cmp %g5, %g7
- be,pt %icc, __write_trylock_succeed
- membar #StoreLoad | #StoreStore
-
- ba,pt %xcc, 1b
- nop
-__write_trylock_succeed:
- retl
- mov 1, %o0
-
-__write_trylock_fail:
- retl
- mov 0, %o0
-
+++ /dev/null
-/* splock.S: Spinlock primitives too large to inline.
- *
- * Copyright (C) 2004 David S. Miller (davem@redhat.com)
- */
-
- .text
- .align 64
-
- .globl _raw_spin_lock
-_raw_spin_lock: /* %o0 = lock_ptr */
-1: ldstub [%o0], %g7
- brnz,pn %g7, 2f
- membar #StoreLoad | #StoreStore
- retl
- nop
-2: ldub [%o0], %g7
- brnz,pt %g7, 2b
- membar #LoadLoad
- ba,a,pt %xcc, 1b
-
- .globl _raw_spin_lock_flags
-_raw_spin_lock_flags: /* %o0 = lock_ptr, %o1 = irq_flags */
-1: ldstub [%o0], %g7
- brnz,pn %g7, 2f
- membar #StoreLoad | #StoreStore
- retl
- nop
-
-2: rdpr %pil, %g2 ! Save PIL
- wrpr %o1, %pil ! Set previous PIL
-3: ldub [%o0], %g7 ! Spin on lock set
- brnz,pt %g7, 3b
- membar #LoadLoad
- ba,pt %xcc, 1b ! Retry lock acquire
- wrpr %g2, %pil ! Restore PIL
+++ /dev/null
-/*
- * Copyright (C) 2002 Steve Schmidtke
- * Licensed under the GPL
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include "hostaudio.h"
-#include "user_util.h"
-#include "kern_util.h"
-#include "user.h"
-#include "os.h"
-
-/* /dev/dsp file operations */
-
-ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer,
- size_t count, loff_t *ppos)
-{
- ssize_t ret;
-
-#ifdef DEBUG
- printk("hostaudio: read_user called, count = %d\n", count);
-#endif
-
- ret = read(state->fd, buffer, count);
-
- if(ret < 0) return(-errno);
- return(ret);
-}
-
-ssize_t hostaudio_write_user(struct hostaudio_state *state, const char *buffer,
- size_t count, loff_t *ppos)
-{
- ssize_t ret;
-
-#ifdef DEBUG
- printk("hostaudio: write_user called, count = %d\n", count);
-#endif
-
- ret = write(state->fd, buffer, count);
-
- if(ret < 0) return(-errno);
- return(ret);
-}
-
-int hostaudio_ioctl_user(struct hostaudio_state *state, unsigned int cmd,
- unsigned long arg)
-{
- int ret;
-#ifdef DEBUG
- printk("hostaudio: ioctl_user called, cmd = %u\n", cmd);
-#endif
-
- ret = ioctl(state->fd, cmd, arg);
-
- if(ret < 0) return(-errno);
- return(ret);
-}
-
-int hostaudio_open_user(struct hostaudio_state *state, int r, int w, char *dsp)
-{
-#ifdef DEBUG
- printk("hostaudio: open_user called\n");
-#endif
-
- state->fd = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-
- if(state->fd >= 0) return(0);
-
- printk("hostaudio_open_user failed to open '%s', errno = %d\n",
- dsp, errno);
-
- return(-errno);
-}
-
-int hostaudio_release_user(struct hostaudio_state *state)
-{
-#ifdef DEBUG
- printk("hostaudio: release called\n");
-#endif
- if(state->fd >= 0){
- close(state->fd);
- state->fd=-1;
- }
-
- return(0);
-}
-
-/* /dev/mixer file operations */
-
-int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state,
- unsigned int cmd, unsigned long arg)
-{
- int ret;
-#ifdef DEBUG
- printk("hostmixer: ioctl_user called cmd = %u\n",cmd);
-#endif
-
- ret = ioctl(state->fd, cmd, arg);
- if(ret < 0)
- return(-errno);
- return(ret);
-}
-
-int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r, int w,
- char *mixer)
-{
-#ifdef DEBUG
- printk("hostmixer: open_user called\n");
-#endif
-
- state->fd = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
-
- if(state->fd >= 0) return(0);
-
- printk("hostaudio_open_mixdev_user failed to open '%s', errno = %d\n",
- mixer, errno);
-
- return(-errno);
-}
-
-int hostmixer_release_mixdev_user(struct hostmixer_state *state)
-{
-#ifdef DEBUG
- printk("hostmixer: release_user called\n");
-#endif
-
- if(state->fd >= 0){
- close(state->fd);
- state->fd = -1;
- }
-
- return 0;
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-OUTPUT_FORMAT(ELF_FORMAT)
-OUTPUT_ARCH(ELF_ARCH)
-ENTRY(_start)
-jiffies = jiffies_64;
-
-SEARCH_DIR("/usr/local/i686-pc-linux-gnu/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
-/* Do we need any of these for elf?
- __DYNAMIC = 0; */
-SECTIONS
-{
- . = START + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- . = ALIGN(4096);
- __binary_start = .;
- . = ALIGN(4096); /* Init code and data */
- _stext = .;
- __init_begin = .;
- .text.init : { *(.text.init) }
-
- . = ALIGN(4096);
-
- /* Read-only sections, merged into text segment: */
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.init : { *(.rel.init) }
- .rela.init : { *(.rela.init) }
- .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
- .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
- .rel.fini : { *(.rel.fini) }
- .rela.fini : { *(.rela.fini) }
- .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
- .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
- .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
- .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
- .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
- .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
- .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
- .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
- .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : {
- KEEP (*(.init))
- } =0x90909090
- .plt : { *(.plt) }
- .text : {
- *(.text .stub .text.* .gnu.linkonce.t.*)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- } =0x90909090
- .fini : {
- KEEP (*(.fini))
- } =0x90909090
-
- .kstrtab : { *(.kstrtab) }
-
- #include "asm/common.lds.S"
-
- .data.init : { *(.data.init) }
-
- /* Ensure the __preinit_array_start label is properly aligned. We
- could instead move the label definition inside the section, but
- the linker would then create the section even if it turns out to
- be empty, which isn't pretty. */
- . = ALIGN(32 / 8);
- .preinit_array : { *(.preinit_array) }
- .init_array : { *(.init_array) }
- .fini_array : { *(.fini_array) }
- .data : {
- . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
- *(.data.init_task)
- *(.data .data.* .gnu.linkonce.d.*)
- SORT(CONSTRUCTORS)
- }
- .data1 : { *(.data1) }
- .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
- .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
- .eh_frame : { KEEP (*(.eh_frame)) }
- .gcc_except_table : { *(.gcc_except_table) }
- .dynamic : { *(.dynamic) }
- .ctors : {
- /* gcc uses crtbegin.o to find the start of
- the constructors, so we make sure it is
- first. Because this is a wildcard, it
- doesn't matter if the user does not
- actually link against crtbegin.o; the
- linker won't look for a file to match a
- wildcard. The wildcard also means that it
- doesn't matter which directory crtbegin.o
- is in. */
- KEEP (*crtbegin.o(.ctors))
- /* We don't want to include the .ctor section from
- from the crtend.o file until after the sorted ctors.
- The .ctor section from the crtend file contains the
- end of ctors marker and it must be last */
- KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*(.ctors))
- }
- .dtors : {
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*(.dtors))
- }
- .jcr : { KEEP (*(.jcr)) }
- .got : { *(.got.plt) *(.got) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- .bss : {
- *(.dynbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- /* Align here to ensure that the .bss section occupies space up to
- _end. Align after .bss to ensure correct alignment even if the
- .bss section disappears because there are no input sections. */
- . = ALIGN(32 / 8);
- . = ALIGN(32 / 8);
- }
- _end = .;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-}
+++ /dev/null
-all : sc.h
-
-sc.h : ../util/mk_sc
- ../util/mk_sc > $@
-
-../util/mk_sc :
- $(MAKE) -C ../util mk_sc
+++ /dev/null
-/*
- * Copyright (C) 2002 Steve Schmidtke
- * Licensed under the GPL
- */
-
-#ifndef HOSTAUDIO_H
-#define HOSTAUDIO_H
-
-#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
-#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
-
-struct hostaudio_state {
- int fd;
-};
-
-struct hostmixer_state {
- int fd;
-};
-
-/* UML user-side protoypes */
-extern ssize_t hostaudio_read_user(struct hostaudio_state *state, char *buffer,
- size_t count, loff_t *ppos);
-extern ssize_t hostaudio_write_user(struct hostaudio_state *state,
- const char *buffer, size_t count,
- loff_t *ppos);
-extern int hostaudio_ioctl_user(struct hostaudio_state *state,
- unsigned int cmd, unsigned long arg);
-extern int hostaudio_open_user(struct hostaudio_state *state, int r, int w,
- char *dsp);
-extern int hostaudio_release_user(struct hostaudio_state *state);
-extern int hostmixer_ioctl_mixdev_user(struct hostmixer_state *state,
- unsigned int cmd, unsigned long arg);
-extern int hostmixer_open_mixdev_user(struct hostmixer_state *state, int r,
- int w, char *mixer);
-extern int hostmixer_release_mixdev_user(struct hostmixer_state *state);
-
-#endif /* HOSTAUDIO_H */
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-#ifndef __MPROT_H__
-#define __MPROT_H__
-
-extern void no_access(unsigned long addr, unsigned int len);
-
-#endif
+++ /dev/null
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <utime.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/vfs.h>
-#include <sys/ioctl.h>
-#include "user_util.h"
-#include "mem_user.h"
-#include "uml-config.h"
-
-/* Had to steal this from linux/module.h because that file can't be included
- * since this includes various user-level headers.
- */
-
-struct module_symbol
-{
- unsigned long value;
- const char *name;
-};
-
-/* Indirect stringification. */
-
-#define __MODULE_STRING_1(x) #x
-#define __MODULE_STRING(x) __MODULE_STRING_1(x)
-
-#if !defined(__AUTOCONF_INCLUDED__)
-
-#define __EXPORT_SYMBOL(sym,str) error config_must_be_included_before_module
-#define EXPORT_SYMBOL(var) error config_must_be_included_before_module
-#define EXPORT_SYMBOL_NOVERS(var) error config_must_be_included_before_module
-
-#elif !defined(UML_CONFIG_MODULES)
-
-#define __EXPORT_SYMBOL(sym,str)
-#define EXPORT_SYMBOL(var)
-#define EXPORT_SYMBOL_NOVERS(var)
-
-#else
-
-#define __EXPORT_SYMBOL(sym, str) \
-const char __kstrtab_##sym[] \
-__attribute__((section(".kstrtab"))) = str; \
-const struct module_symbol __ksymtab_##sym \
-__attribute__((section("__ksymtab"))) = \
-{ (unsigned long)&sym, __kstrtab_##sym }
-
-#if defined(__MODVERSIONS__) || !defined(UML_CONFIG_MODVERSIONS)
-#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
-#else
-#define EXPORT_SYMBOL(var) __EXPORT_SYMBOL(var, __MODULE_STRING(__VERSIONED_SYMBOL(var)))
-#endif
-
-#define EXPORT_SYMBOL_NOVERS(var) __EXPORT_SYMBOL(var, __MODULE_STRING(var))
-
-#endif
-
-EXPORT_SYMBOL(__errno_location);
-
-EXPORT_SYMBOL(access);
-EXPORT_SYMBOL(open);
-EXPORT_SYMBOL(open64);
-EXPORT_SYMBOL(close);
-EXPORT_SYMBOL(read);
-EXPORT_SYMBOL(write);
-EXPORT_SYMBOL(dup2);
-EXPORT_SYMBOL(__xstat);
-EXPORT_SYMBOL(__lxstat);
-EXPORT_SYMBOL(__lxstat64);
-EXPORT_SYMBOL(lseek);
-EXPORT_SYMBOL(lseek64);
-EXPORT_SYMBOL(chown);
-EXPORT_SYMBOL(truncate);
-EXPORT_SYMBOL(utime);
-EXPORT_SYMBOL(chmod);
-EXPORT_SYMBOL(rename);
-EXPORT_SYMBOL(__xmknod);
-
-EXPORT_SYMBOL(symlink);
-EXPORT_SYMBOL(link);
-EXPORT_SYMBOL(unlink);
-EXPORT_SYMBOL(readlink);
-
-EXPORT_SYMBOL(mkdir);
-EXPORT_SYMBOL(rmdir);
-EXPORT_SYMBOL(opendir);
-EXPORT_SYMBOL(readdir);
-EXPORT_SYMBOL(closedir);
-EXPORT_SYMBOL(seekdir);
-EXPORT_SYMBOL(telldir);
-
-EXPORT_SYMBOL(ioctl);
-
-extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
- __off64_t __offset);
-extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
- __off64_t __offset);
-EXPORT_SYMBOL(pread64);
-EXPORT_SYMBOL(pwrite64);
-
-EXPORT_SYMBOL(statfs);
-EXPORT_SYMBOL(statfs64);
-
-EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(getuid);
-
-EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(strstr);
-
-EXPORT_SYMBOL(find_iomem);
+++ /dev/null
-#include <asm-generic/vmlinux.lds.h>
-
-OUTPUT_FORMAT(ELF_FORMAT)
-OUTPUT_ARCH(ELF_ARCH)
-ENTRY(_start)
-jiffies = jiffies_64;
-
-SECTIONS
-{
-#include "asm/common.lds.S"
-}
+++ /dev/null
-/*
- * Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com)
- * Licensed under the GPL
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/resource.h>
-#include <sys/mman.h>
-#include <sys/user.h>
-#include <asm/page.h>
-#include "user_util.h"
-#include "kern_util.h"
-#include "mem_user.h"
-#include "signal_user.h"
-#include "user.h"
-#include "init.h"
-#include "mode.h"
-#include "choose-mode.h"
-#include "uml-config.h"
-
-/* Set in set_stklim, which is called from main and __wrap_malloc.
- * __wrap_malloc only calls it if main hasn't started.
- */
-unsigned long stacksizelim;
-
-/* Set in main */
-char *linux_prog;
-
-#define PGD_BOUND (4 * 1024 * 1024)
-#define STACKSIZE (8 * 1024 * 1024)
-#define THREAD_NAME_LEN (256)
-
-static void set_stklim(void)
-{
- struct rlimit lim;
-
- if(getrlimit(RLIMIT_STACK, &lim) < 0){
- perror("getrlimit");
- exit(1);
- }
- if((lim.rlim_cur == RLIM_INFINITY) || (lim.rlim_cur > STACKSIZE)){
- lim.rlim_cur = STACKSIZE;
- if(setrlimit(RLIMIT_STACK, &lim) < 0){
- perror("setrlimit");
- exit(1);
- }
- }
- stacksizelim = (lim.rlim_cur + PGD_BOUND - 1) & ~(PGD_BOUND - 1);
-}
-
-static __init void do_uml_initcalls(void)
-{
- initcall_t *call;
-
- call = &__uml_initcall_start;
- while (call < &__uml_initcall_end){;
- (*call)();
- call++;
- }
-}
-
-static void last_ditch_exit(int sig)
-{
- CHOOSE_MODE(kmalloc_ok = 0, (void) 0);
- signal(SIGINT, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
- uml_cleanup();
- exit(1);
-}
-
-extern int uml_exitcode;
-
-int main(int argc, char **argv, char **envp)
-{
- char **new_argv;
- sigset_t mask;
- int ret, i;
-
- /* Enable all signals except SIGIO - in some environments, we can
- * enter with some signals blocked
- */
-
- sigemptyset(&mask);
- sigaddset(&mask, SIGIO);
- if(sigprocmask(SIG_SETMASK, &mask, NULL) < 0){
- perror("sigprocmask");
- exit(1);
- }
-
-#ifdef UML_CONFIG_MODE_TT
- /* Allocate memory for thread command lines */
- if(argc < 2 || strlen(argv[1]) < THREAD_NAME_LEN - 1){
-
- char padding[THREAD_NAME_LEN] = {
- [ 0 ... THREAD_NAME_LEN - 2] = ' ', '\0'
- };
-
- new_argv = malloc((argc + 2) * sizeof(char*));
- if(!new_argv) {
- perror("Allocating extended argv");
- exit(1);
- }
-
- new_argv[0] = argv[0];
- new_argv[1] = padding;
-
- for(i = 2; i <= argc; i++)
- new_argv[i] = argv[i - 1];
- new_argv[argc + 1] = NULL;
-
- execvp(new_argv[0], new_argv);
- perror("execing with extended args");
- exit(1);
- }
-#endif
-
- linux_prog = argv[0];
-
- set_stklim();
-
- if((new_argv = malloc((argc + 1) * sizeof(char *))) == NULL){
- perror("Mallocing argv");
- exit(1);
- }
- for(i=0;i<argc;i++){
- if((new_argv[i] = strdup(argv[i])) == NULL){
- perror("Mallocing an arg");
- exit(1);
- }
- }
- new_argv[argc] = NULL;
-
- set_handler(SIGINT, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
- set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
- set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
-
- do_uml_initcalls();
- ret = linux_main(argc, argv);
-
- /* Reboot */
- if(ret){
- printf("\n");
- execvp(new_argv[0], new_argv);
- perror("Failed to exec kernel");
- ret = 1;
- }
- printf("\n");
- return(uml_exitcode);
-}
-
-#define CAN_KMALLOC() \
- (kmalloc_ok && CHOOSE_MODE((getpid() != tracing_pid), 1))
-
-extern void *__real_malloc(int);
-
-void *__wrap_malloc(int size)
-{
- if(CAN_KMALLOC())
- return(um_kmalloc(size));
- else
- return(__real_malloc(size));
-}
-
-void *__wrap_calloc(int n, int size)
-{
- void *ptr = __wrap_malloc(n * size);
-
- if(ptr == NULL) return(NULL);
- memset(ptr, 0, n * size);
- return(ptr);
-}
-
-extern void __real_free(void *);
-
-void __wrap_free(void *ptr)
-{
- if(CAN_KMALLOC()) kfree(ptr);
- else __real_free(ptr);
-}
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
+++ /dev/null
-/*
- * linux/arch/i386/mm/extable.c
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <asm/uaccess.h>
-
-/* Simple binary search */
-const struct exception_table_entry *
-search_extable(const struct exception_table_entry *first,
- const struct exception_table_entry *last,
- unsigned long value)
-{
- while (first <= last) {
- const struct exception_table_entry *mid;
- long diff;
-
- mid = (last - first) / 2 + first;
- diff = mid->insn - value;
- if (diff == 0)
- return mid;
- else if (diff < 0)
- first = mid+1;
- else
- last = mid-1;
- }
- return NULL;
-}
+++ /dev/null
-#include <asm-generic/vmlinux.lds.h>
-
-OUTPUT_FORMAT(ELF_FORMAT)
-OUTPUT_ARCH(ELF_ARCH)
-ENTRY(_start)
-jiffies = jiffies_64;
-
-SECTIONS
-{
- . = START + SIZEOF_HEADERS;
-
- . = ALIGN(4096);
- __binary_start = .;
-#ifdef MODE_TT
- .thread_private : {
- __start_thread_private = .;
- errno = .;
- . += 4;
- arch/um/kernel/tt/unmap_fin.o (.data)
- __end_thread_private = .;
- }
- . = ALIGN(4096);
- .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
-#endif
-
- . = ALIGN(4096); /* Init code and data */
- _stext = .;
- __init_begin = .;
- .text.init : { *(.text.init) }
- . = ALIGN(4096);
- .text :
- {
- *(.text)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- }
-
- #include "asm/common.lds.S"
-
- .data.init : { *(.data.init) }
- .data :
- {
- . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
- *(.data.init_task)
- *(.data)
- *(.gnu.linkonce.d*)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .ctors :
- {
- *(.ctors)
- }
- .dtors :
- {
- *(.dtors)
- }
-
- .got : { *(.got.plt) *(.got) }
- .dynamic : { *(.dynamic) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : { *(.sdata) }
- _edata = .;
- PROVIDE (edata = .);
- . = ALIGN(0x1000);
- .sbss :
- {
- __bss_start = .;
- PROVIDE(_bss_start = .);
- *(.sbss)
- *(.scommon)
- }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
- _end = . ;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
-}
+++ /dev/null
-#
-# Makefile for the linux kernel.
-#
-
-extra-y := head.o head64.o init_task.o vmlinux.lds.s
-EXTRA_AFLAGS := -traditional
-obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
- ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_x86_64.o \
- x8664_ksyms.o i387.o syscall.o vsyscall.o \
- setup64.o bootflag.o e820.o reboot.o warmreboot.o
-obj-y += mce.o
-
-obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/
-obj-$(CONFIG_ACPI_BOOT) += acpi/
-obj-$(CONFIG_X86_MSR) += msr.o
-obj-$(CONFIG_MICROCODE) += microcode.o
-obj-$(CONFIG_X86_CPUID) += cpuid.o
-obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o
-obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o
-obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o
-obj-$(CONFIG_PM) += suspend.o
-obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o
-obj-$(CONFIG_CPU_FREQ) += cpufreq/
-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
-obj-$(CONFIG_GART_IOMMU) += pci-gart.o aperture.o
-obj-$(CONFIG_DUMMY_IOMMU) += pci-nommu.o pci-dma.o
-obj-$(CONFIG_SWIOTLB) += swiotlb.o
-obj-$(CONFIG_SCHED_SMT) += domain.o
-
-obj-$(CONFIG_MODULES) += module.o
-
-obj-y += topology.o
-
-bootflag-y += ../../i386/kernel/bootflag.o
-cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o
-topology-y += ../../i386/mach-default/topology.o
-swiotlb-$(CONFIG_SWIOTLB) += ../../ia64/lib/swiotlb.o
-microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o
+++ /dev/null
-#include <linux/init.h>
-#include <linux/sched.h>
-
-/* Don't do any NUMA setup on Opteron right now. They seem to be
- better off with flat scheduling. This is just for SMT. */
-
-#ifdef CONFIG_SCHED_SMT
-
-static struct sched_group sched_group_cpus[NR_CPUS];
-static struct sched_group sched_group_phys[NR_CPUS];
-static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
-static DEFINE_PER_CPU(struct sched_domain, phys_domains);
-__init void arch_init_sched_domains(void)
-{
- int i;
- struct sched_group *first = NULL, *last = NULL;
-
- /* Set up domains */
- for_each_cpu(i) {
- struct sched_domain *cpu_domain = &per_cpu(cpu_domains, i);
- struct sched_domain *phys_domain = &per_cpu(phys_domains, i);
-
- *cpu_domain = SD_SIBLING_INIT;
- /* Disable SMT NICE for CMP */
- /* RED-PEN use a generic flag */
- if (cpu_data[i].x86_vendor == X86_VENDOR_AMD)
- cpu_domain->flags &= ~SD_SHARE_CPUPOWER;
- cpu_domain->span = cpu_sibling_map[i];
- cpu_domain->parent = phys_domain;
- cpu_domain->groups = &sched_group_cpus[i];
-
- *phys_domain = SD_CPU_INIT;
- phys_domain->span = cpu_possible_map;
- phys_domain->groups = &sched_group_phys[first_cpu(cpu_domain->span)];
- }
-
- /* Set up CPU (sibling) groups */
- for_each_cpu(i) {
- struct sched_domain *cpu_domain = &per_cpu(cpu_domains, i);
- int j;
- first = last = NULL;
-
- if (i != first_cpu(cpu_domain->span))
- continue;
-
- for_each_cpu_mask(j, cpu_domain->span) {
- struct sched_group *cpu = &sched_group_cpus[j];
-
- cpus_clear(cpu->cpumask);
- cpu_set(j, cpu->cpumask);
- cpu->cpu_power = SCHED_LOAD_SCALE;
-
- if (!first)
- first = cpu;
- if (last)
- last->next = cpu;
- last = cpu;
- }
- last->next = first;
- }
-
- first = last = NULL;
- /* Set up physical groups */
- for_each_cpu(i) {
- struct sched_domain *cpu_domain = &per_cpu(cpu_domains, i);
- struct sched_group *cpu = &sched_group_phys[i];
-
- if (i != first_cpu(cpu_domain->span))
- continue;
-
- cpu->cpumask = cpu_domain->span;
- /*
- * Make each extra sibling increase power by 10% of
- * the basic CPU. This is very arbitrary.
- */
- cpu->cpu_power = SCHED_LOAD_SCALE + SCHED_LOAD_SCALE*(cpus_weight(cpu->cpumask)-1) / 10;
-
- if (!first)
- first = cpu;
- if (last)
- last->next = cpu;
- last = cpu;
- }
- last->next = first;
-
- mb();
- for_each_cpu(i) {
- struct sched_domain *cpu_domain = &per_cpu(cpu_domains, i);
- cpu_attach_domain(cpu_domain, i);
- }
-}
-
-#endif
+++ /dev/null
-/*
- * carmel.c: Driver for Promise SATA SX8 looks-like-I2O hardware
- *
- * Copyright 2004 Red Hat, Inc.
- *
- * Author/maintainer: Jeff Garzik <jgarzik@pobox.com>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/blkdev.h>
-#include <linux/sched.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/interrupt.h>
-#include <linux/compiler.h>
-#include <linux/workqueue.h>
-#include <linux/bitops.h>
-#include <linux/delay.h>
-#include <linux/time.h>
-#include <linux/hdreg.h>
-#include <asm/io.h>
-#include <asm/semaphore.h>
-#include <asm/uaccess.h>
-
-MODULE_AUTHOR("Jeff Garzik");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Promise SATA SX8 (carmel) block driver");
-
-#if 0
-#define CARM_DEBUG
-#define CARM_VERBOSE_DEBUG
-#else
-#undef CARM_DEBUG
-#undef CARM_VERBOSE_DEBUG
-#endif
-#undef CARM_NDEBUG
-
-#define DRV_NAME "carmel"
-#define DRV_VERSION "0.8"
-#define PFX DRV_NAME ": "
-
-#define NEXT_RESP(idx) ((idx + 1) % RMSG_Q_LEN)
-
-/* 0xf is just arbitrary, non-zero noise; this is sorta like poisoning */
-#define TAG_ENCODE(tag) (((tag) << 16) | 0xf)
-#define TAG_DECODE(tag) (((tag) >> 16) & 0x1f)
-#define TAG_VALID(tag) ((((tag) & 0xf) == 0xf) && (TAG_DECODE(tag) < 32))
-
-/* note: prints function name for you */
-#ifdef CARM_DEBUG
-#define DPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
-#ifdef CARM_VERBOSE_DEBUG
-#define VPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
-#else
-#define VPRINTK(fmt, args...)
-#endif /* CARM_VERBOSE_DEBUG */
-#else
-#define DPRINTK(fmt, args...)
-#define VPRINTK(fmt, args...)
-#endif /* CARM_DEBUG */
-
-#ifdef CARM_NDEBUG
-#define assert(expr)
-#else
-#define assert(expr) \
- if(unlikely(!(expr))) { \
- printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
- #expr,__FILE__,__FUNCTION__,__LINE__); \
- }
-#endif
-
-/* defines only for the constants which don't work well as enums */
-struct carm_host;
-
-enum {
- /* adapter-wide limits */
- CARM_MAX_PORTS = 8,
- CARM_SHM_SIZE = (4096 << 7),
- CARM_MINORS_PER_MAJOR = 256 / CARM_MAX_PORTS,
- CARM_MAX_WAIT_Q = CARM_MAX_PORTS + 1,
-
- /* command message queue limits */
- CARM_MAX_REQ = 64, /* max command msgs per host */
- CARM_MAX_Q = 1, /* one command at a time */
- CARM_MSG_LOW_WATER = (CARM_MAX_REQ / 4), /* refill mark */
-
- /* S/G limits, host-wide and per-request */
- CARM_MAX_REQ_SG = 32, /* max s/g entries per request */
- CARM_SG_BOUNDARY = 0xffffUL, /* s/g segment boundary */
- CARM_MAX_HOST_SG = 600, /* max s/g entries per host */
- CARM_SG_LOW_WATER = (CARM_MAX_HOST_SG / 4), /* re-fill mark */
-
- /* hardware registers */
- CARM_IHQP = 0x1c,
- CARM_INT_STAT = 0x10, /* interrupt status */
- CARM_INT_MASK = 0x14, /* interrupt mask */
- CARM_HMUC = 0x18, /* host message unit control */
- RBUF_ADDR_LO = 0x20, /* response msg DMA buf low 32 bits */
- RBUF_ADDR_HI = 0x24, /* response msg DMA buf high 32 bits */
- RBUF_BYTE_SZ = 0x28,
- CARM_RESP_IDX = 0x2c,
- CARM_CMS0 = 0x30, /* command message size reg 0 */
- CARM_LMUC = 0x48,
- CARM_HMPHA = 0x6c,
- CARM_INITC = 0xb5,
-
- /* bits in CARM_INT_{STAT,MASK} */
- INT_RESERVED = 0xfffffff0,
- INT_WATCHDOG = (1 << 3), /* watchdog timer */
- INT_Q_OVERFLOW = (1 << 2), /* cmd msg q overflow */
- INT_Q_AVAILABLE = (1 << 1), /* cmd msg q has free space */
- INT_RESPONSE = (1 << 0), /* response msg available */
- INT_ACK_MASK = INT_WATCHDOG | INT_Q_OVERFLOW,
- INT_DEF_MASK = INT_RESERVED | INT_Q_OVERFLOW |
- INT_RESPONSE,
-
- /* command messages, and related register bits */
- CARM_HAVE_RESP = 0x01,
- CARM_MSG_READ = 1,
- CARM_MSG_WRITE = 2,
- CARM_MSG_VERIFY = 3,
- CARM_MSG_GET_CAPACITY = 4,
- CARM_MSG_FLUSH = 5,
- CARM_MSG_IOCTL = 6,
- CARM_MSG_ARRAY = 8,
- CARM_MSG_MISC = 9,
- CARM_CME = (1 << 2),
- CARM_RME = (1 << 1),
- CARM_WZBC = (1 << 0),
- CARM_RMI = (1 << 0),
- CARM_Q_FULL = (1 << 3),
- CARM_MSG_SIZE = 288,
- CARM_Q_LEN = 48,
-
- /* CARM_MSG_IOCTL messages */
- CARM_IOC_SCAN_CHAN = 5, /* scan channels for devices */
- CARM_IOC_GET_TCQ = 13, /* get tcq/ncq depth */
- CARM_IOC_SET_TCQ = 14, /* set tcq/ncq depth */
-
- IOC_SCAN_CHAN_NODEV = 0x1f,
- IOC_SCAN_CHAN_OFFSET = 0x40,
-
- /* CARM_MSG_ARRAY messages */
- CARM_ARRAY_INFO = 0,
-
- ARRAY_NO_EXIST = (1 << 31),
-
- /* response messages */
- RMSG_SZ = 8, /* sizeof(struct carm_response) */
- RMSG_Q_LEN = 48, /* resp. msg list length */
- RMSG_OK = 1, /* bit indicating msg was successful */
- /* length of entire resp. msg buffer */
- RBUF_LEN = RMSG_SZ * RMSG_Q_LEN,
-
- PDC_SHM_SIZE = (4096 << 7), /* length of entire h/w buffer */
-
- /* CARM_MSG_MISC messages */
- MISC_GET_FW_VER = 2,
- MISC_ALLOC_MEM = 3,
- MISC_SET_TIME = 5,
-
- /* MISC_GET_FW_VER feature bits */
- FW_VER_4PORT = (1 << 2), /* 1=4 ports, 0=8 ports */
- FW_VER_NON_RAID = (1 << 1), /* 1=non-RAID firmware, 0=RAID */
- FW_VER_ZCR = (1 << 0), /* zero channel RAID (whatever that is) */
-
- /* carm_host flags */
- FL_NON_RAID = FW_VER_NON_RAID,
- FL_4PORT = FW_VER_4PORT,
- FL_FW_VER_MASK = (FW_VER_NON_RAID | FW_VER_4PORT),
- FL_DAC = (1 << 16),
- FL_DYN_MAJOR = (1 << 17),
-};
-
-enum scatter_gather_types {
- SGT_32BIT = 0,
- SGT_64BIT = 1,
-};
-
-enum host_states {
- HST_INVALID, /* invalid state; never used */
- HST_ALLOC_BUF, /* setting up master SHM area */
- HST_ERROR, /* we never leave here */
- HST_PORT_SCAN, /* start dev scan */
- HST_DEV_SCAN_START, /* start per-device probe */
- HST_DEV_SCAN, /* continue per-device probe */
- HST_DEV_ACTIVATE, /* activate devices we found */
- HST_PROBE_FINISHED, /* probe is complete */
- HST_PROBE_START, /* initiate probe */
- HST_SYNC_TIME, /* tell firmware what time it is */
- HST_GET_FW_VER, /* get firmware version, adapter port cnt */
-};
-
-#ifdef CARM_DEBUG
-static const char *state_name[] = {
- "HST_INVALID",
- "HST_ALLOC_BUF",
- "HST_ERROR",
- "HST_PORT_SCAN",
- "HST_DEV_SCAN_START",
- "HST_DEV_SCAN",
- "HST_DEV_ACTIVATE",
- "HST_PROBE_FINISHED",
- "HST_PROBE_START",
- "HST_SYNC_TIME",
- "HST_GET_FW_VER",
-};
-#endif
-
-struct carm_port {
- unsigned int port_no;
- unsigned int n_queued;
- struct gendisk *disk;
- struct carm_host *host;
-
- /* attached device characteristics */
- u64 capacity;
- char name[41];
- u16 dev_geom_head;
- u16 dev_geom_sect;
- u16 dev_geom_cyl;
-};
-
-struct carm_request {
- unsigned int tag;
- int n_elem;
- unsigned int msg_type;
- unsigned int msg_subtype;
- unsigned int msg_bucket;
- struct request *rq;
- struct carm_port *port;
- struct scatterlist sg[CARM_MAX_REQ_SG];
-};
-
-struct carm_host {
- unsigned long flags;
- void *mmio;
- void *shm;
- dma_addr_t shm_dma;
-
- int major;
- int id;
- char name[32];
-
- spinlock_t lock;
- struct pci_dev *pdev;
- unsigned int state;
- u32 fw_ver;
-
- request_queue_t *oob_q;
- unsigned int n_oob;
-
- unsigned int hw_sg_used;
-
- unsigned int resp_idx;
-
- unsigned int wait_q_prod;
- unsigned int wait_q_cons;
- request_queue_t *wait_q[CARM_MAX_WAIT_Q];
-
- unsigned int n_msgs;
- u64 msg_alloc;
- struct carm_request req[CARM_MAX_REQ];
- void *msg_base;
- dma_addr_t msg_dma;
-
- int cur_scan_dev;
- unsigned long dev_active;
- unsigned long dev_present;
- struct carm_port port[CARM_MAX_PORTS];
-
- struct work_struct fsm_task;
-
- struct semaphore probe_sem;
-};
-
-struct carm_response {
- u32 ret_handle;
- u32 status;
-} __attribute__((packed));
-
-struct carm_msg_sg {
- u32 start;
- u32 len;
-} __attribute__((packed));
-
-struct carm_msg_rw {
- u8 type;
- u8 id;
- u8 sg_count;
- u8 sg_type;
- u32 handle;
- u32 lba;
- u16 lba_count;
- u16 lba_high;
- struct carm_msg_sg sg[32];
-} __attribute__((packed));
-
-struct carm_msg_allocbuf {
- u8 type;
- u8 subtype;
- u8 n_sg;
- u8 sg_type;
- u32 handle;
- u32 addr;
- u32 len;
- u32 evt_pool;
- u32 n_evt;
- u32 rbuf_pool;
- u32 n_rbuf;
- u32 msg_pool;
- u32 n_msg;
- struct carm_msg_sg sg[8];
-} __attribute__((packed));
-
-struct carm_msg_ioctl {
- u8 type;
- u8 subtype;
- u8 array_id;
- u8 reserved1;
- u32 handle;
- u32 data_addr;
- u32 reserved2;
-} __attribute__((packed));
-
-struct carm_msg_sync_time {
- u8 type;
- u8 subtype;
- u16 reserved1;
- u32 handle;
- u32 reserved2;
- u32 timestamp;
-} __attribute__((packed));
-
-struct carm_msg_get_fw_ver {
- u8 type;
- u8 subtype;
- u16 reserved1;
- u32 handle;
- u32 data_addr;
- u32 reserved2;
-} __attribute__((packed));
-
-struct carm_fw_ver {
- u32 version;
- u8 features;
- u8 reserved1;
- u16 reserved2;
-} __attribute__((packed));
-
-struct carm_array_info {
- u32 size;
-
- u16 size_hi;
- u16 stripe_size;
-
- u32 mode;
-
- u16 stripe_blk_sz;
- u16 reserved1;
-
- u16 cyl;
- u16 head;
-
- u16 sect;
- u8 array_id;
- u8 reserved2;
-
- char name[40];
-
- u32 array_status;
-
- /* device list continues beyond this point? */
-} __attribute__((packed));
-
-static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
-static void carm_remove_one (struct pci_dev *pdev);
-static int carm_bdev_ioctl(struct inode *ino, struct file *fil,
- unsigned int cmd, unsigned long arg);
-
-static struct pci_device_id carm_pci_tbl[] = {
- { PCI_VENDOR_ID_PROMISE, 0x8000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
- { PCI_VENDOR_ID_PROMISE, 0x8002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
- { } /* terminate list */
-};
-MODULE_DEVICE_TABLE(pci, carm_pci_tbl);
-
-static struct pci_driver carm_driver = {
- .name = DRV_NAME,
- .id_table = carm_pci_tbl,
- .probe = carm_init_one,
- .remove = carm_remove_one,
-};
-
-static struct block_device_operations carm_bd_ops = {
- .owner = THIS_MODULE,
- .ioctl = carm_bdev_ioctl,
-};
-
-static unsigned int carm_host_id;
-static unsigned long carm_major_alloc;
-
-
-
-static int carm_bdev_ioctl(struct inode *ino, struct file *fil,
- unsigned int cmd, unsigned long arg)
-{
- void __user *usermem = (void __user *) arg;
- struct carm_port *port = ino->i_bdev->bd_disk->private_data;
- struct hd_geometry geom;
-
- switch (cmd) {
- case HDIO_GETGEO:
- if (!usermem)
- return -EINVAL;
-
- geom.heads = (u8) port->dev_geom_head;
- geom.sectors = (u8) port->dev_geom_sect;
- geom.cylinders = port->dev_geom_cyl;
- geom.start = get_start_sect(ino->i_bdev);
-
- if (copy_to_user(usermem, &geom, sizeof(geom)))
- return -EFAULT;
- return 0;
-
- default:
- break;
- }
-
- return -EOPNOTSUPP;
-}
-
-static const u32 msg_sizes[] = { 32, 64, 128, CARM_MSG_SIZE };
-
-static inline int carm_lookup_bucket(u32 msg_size)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(msg_sizes); i++)
- if (msg_size <= msg_sizes[i])
- return i;
-
- return -ENOENT;
-}
-
-static void carm_init_buckets(void *mmio)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(msg_sizes); i++)
- writel(msg_sizes[i], mmio + CARM_CMS0 + (4 * i));
-}
-
-static inline void *carm_ref_msg(struct carm_host *host,
- unsigned int msg_idx)
-{
- return host->msg_base + (msg_idx * CARM_MSG_SIZE);
-}
-
-static inline dma_addr_t carm_ref_msg_dma(struct carm_host *host,
- unsigned int msg_idx)
-{
- return host->msg_dma + (msg_idx * CARM_MSG_SIZE);
-}
-
-static int carm_send_msg(struct carm_host *host,
- struct carm_request *crq)
-{
- void *mmio = host->mmio;
- u32 msg = (u32) carm_ref_msg_dma(host, crq->tag);
- u32 cm_bucket = crq->msg_bucket;
- u32 tmp;
- int rc = 0;
-
- VPRINTK("ENTER\n");
-
- tmp = readl(mmio + CARM_HMUC);
- if (tmp & CARM_Q_FULL) {
-#if 0
- tmp = readl(mmio + CARM_INT_MASK);
- tmp |= INT_Q_AVAILABLE;
- writel(tmp, mmio + CARM_INT_MASK);
- readl(mmio + CARM_INT_MASK); /* flush */
-#endif
- DPRINTK("host msg queue full\n");
- rc = -EBUSY;
- } else {
- writel(msg | (cm_bucket << 1), mmio + CARM_IHQP);
- readl(mmio + CARM_IHQP); /* flush */
- }
-
- return rc;
-}
-
-static struct carm_request *carm_get_request(struct carm_host *host)
-{
- unsigned int i;
-
- /* obey global hardware limit on S/G entries */
- if (host->hw_sg_used >= (CARM_MAX_HOST_SG - CARM_MAX_REQ_SG))
- return NULL;
-
- for (i = 0; i < CARM_MAX_Q; i++)
- if ((host->msg_alloc & (1ULL << i)) == 0) {
- struct carm_request *crq = &host->req[i];
- crq->port = NULL;
- crq->n_elem = 0;
-
- host->msg_alloc |= (1ULL << i);
- host->n_msgs++;
-
- assert(host->n_msgs <= CARM_MAX_REQ);
- return crq;
- }
-
- DPRINTK("no request available, returning NULL\n");
- return NULL;
-}
-
-static int carm_put_request(struct carm_host *host, struct carm_request *crq)
-{
- assert(crq->tag < CARM_MAX_Q);
-
- if (unlikely((host->msg_alloc & (1ULL << crq->tag)) == 0))
- return -EINVAL; /* tried to clear a tag that was not active */
-
- assert(host->hw_sg_used >= crq->n_elem);
-
- host->msg_alloc &= ~(1ULL << crq->tag);
- host->hw_sg_used -= crq->n_elem;
- host->n_msgs--;
-
- return 0;
-}
-
-static struct carm_request *carm_get_special(struct carm_host *host)
-{
- unsigned long flags;
- struct carm_request *crq = NULL;
- struct request *rq;
- int tries = 5000;
-
- while (tries-- > 0) {
- spin_lock_irqsave(&host->lock, flags);
- crq = carm_get_request(host);
- spin_unlock_irqrestore(&host->lock, flags);
-
- if (crq)
- break;
- msleep(10);
- }
-
- if (!crq)
- return NULL;
-
- rq = blk_get_request(host->oob_q, WRITE /* bogus */, GFP_KERNEL);
- if (!rq) {
- spin_lock_irqsave(&host->lock, flags);
- carm_put_request(host, crq);
- spin_unlock_irqrestore(&host->lock, flags);
- return NULL;
- }
-
- crq->rq = rq;
- return crq;
-}
-
-static int carm_array_info (struct carm_host *host, unsigned int array_idx)
-{
- struct carm_msg_ioctl *ioc;
- unsigned int idx;
- u32 msg_data;
- dma_addr_t msg_dma;
- struct carm_request *crq;
- int rc;
-
- crq = carm_get_special(host);
- if (!crq) {
- rc = -ENOMEM;
- goto err_out;
- }
-
- idx = crq->tag;
-
- ioc = carm_ref_msg(host, idx);
- msg_dma = carm_ref_msg_dma(host, idx);
- msg_data = (u32) (msg_dma + sizeof(struct carm_array_info));
-
- crq->msg_type = CARM_MSG_ARRAY;
- crq->msg_subtype = CARM_ARRAY_INFO;
- rc = carm_lookup_bucket(sizeof(struct carm_msg_ioctl) +
- sizeof(struct carm_array_info));
- BUG_ON(rc < 0);
- crq->msg_bucket = (u32) rc;
-
- memset(ioc, 0, sizeof(*ioc));
- ioc->type = CARM_MSG_ARRAY;
- ioc->subtype = CARM_ARRAY_INFO;
- ioc->array_id = (u8) array_idx;
- ioc->handle = cpu_to_le32(TAG_ENCODE(idx));
- ioc->data_addr = cpu_to_le32(msg_data);
-
- spin_lock_irq(&host->lock);
- assert(host->state == HST_DEV_SCAN_START ||
- host->state == HST_DEV_SCAN);
- spin_unlock_irq(&host->lock);
-
- DPRINTK("blk_insert_request, tag == %u\n", idx);
- blk_insert_request(host->oob_q, crq->rq, 1, crq, 0);
-
- return 0;
-
-err_out:
- spin_lock_irq(&host->lock);
- host->state = HST_ERROR;
- spin_unlock_irq(&host->lock);
- return rc;
-}
-
-typedef unsigned int (*carm_sspc_t)(struct carm_host *, unsigned int, void *);
-
-static int carm_send_special (struct carm_host *host, carm_sspc_t func)
-{
- struct carm_request *crq;
- struct carm_msg_ioctl *ioc;
- void *mem;
- unsigned int idx, msg_size;
- int rc;
-
- crq = carm_get_special(host);
- if (!crq)
- return -ENOMEM;
-
- idx = crq->tag;
-
- mem = carm_ref_msg(host, idx);
-
- msg_size = func(host, idx, mem);
-
- ioc = mem;
- crq->msg_type = ioc->type;
- crq->msg_subtype = ioc->subtype;
- rc = carm_lookup_bucket(msg_size);
- BUG_ON(rc < 0);
- crq->msg_bucket = (u32) rc;
-
- DPRINTK("blk_insert_request, tag == %u\n", idx);
- blk_insert_request(host->oob_q, crq->rq, 1, crq, 0);
-
- return 0;
-}
-
-static unsigned int carm_fill_sync_time(struct carm_host *host,
- unsigned int idx, void *mem)
-{
- struct timeval tv;
- struct carm_msg_sync_time *st = mem;
-
- do_gettimeofday(&tv);
-
- memset(st, 0, sizeof(*st));
- st->type = CARM_MSG_MISC;
- st->subtype = MISC_SET_TIME;
- st->handle = cpu_to_le32(TAG_ENCODE(idx));
- st->timestamp = cpu_to_le32(tv.tv_sec);
-
- return sizeof(struct carm_msg_sync_time);
-}
-
-static unsigned int carm_fill_alloc_buf(struct carm_host *host,
- unsigned int idx, void *mem)
-{
- struct carm_msg_allocbuf *ab = mem;
-
- memset(ab, 0, sizeof(*ab));
- ab->type = CARM_MSG_MISC;
- ab->subtype = MISC_ALLOC_MEM;
- ab->handle = cpu_to_le32(TAG_ENCODE(idx));
- ab->n_sg = 1;
- ab->sg_type = SGT_32BIT;
- ab->addr = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1));
- ab->len = cpu_to_le32(PDC_SHM_SIZE >> 1);
- ab->evt_pool = cpu_to_le32(host->shm_dma + (16 * 1024));
- ab->n_evt = cpu_to_le32(1024);
- ab->rbuf_pool = cpu_to_le32(host->shm_dma);
- ab->n_rbuf = cpu_to_le32(RMSG_Q_LEN);
- ab->msg_pool = cpu_to_le32(host->shm_dma + RBUF_LEN);
- ab->n_msg = cpu_to_le32(CARM_Q_LEN);
- ab->sg[0].start = cpu_to_le32(host->shm_dma + (PDC_SHM_SIZE >> 1));
- ab->sg[0].len = cpu_to_le32(65536);
-
- return sizeof(struct carm_msg_allocbuf);
-}
-
-static unsigned int carm_fill_scan_channels(struct carm_host *host,
- unsigned int idx, void *mem)
-{
- struct carm_msg_ioctl *ioc = mem;
- u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) +
- IOC_SCAN_CHAN_OFFSET);
-
- memset(ioc, 0, sizeof(*ioc));
- ioc->type = CARM_MSG_IOCTL;
- ioc->subtype = CARM_IOC_SCAN_CHAN;
- ioc->handle = cpu_to_le32(TAG_ENCODE(idx));
- ioc->data_addr = cpu_to_le32(msg_data);
-
- /* fill output data area with "no device" default values */
- mem += IOC_SCAN_CHAN_OFFSET;
- memset(mem, IOC_SCAN_CHAN_NODEV, CARM_MAX_PORTS);
-
- return IOC_SCAN_CHAN_OFFSET + CARM_MAX_PORTS;
-}
-
-static unsigned int carm_fill_get_fw_ver(struct carm_host *host,
- unsigned int idx, void *mem)
-{
- struct carm_msg_get_fw_ver *ioc = mem;
- u32 msg_data = (u32) (carm_ref_msg_dma(host, idx) + sizeof(*ioc));
-
- memset(ioc, 0, sizeof(*ioc));
- ioc->type = CARM_MSG_MISC;
- ioc->subtype = MISC_GET_FW_VER;
- ioc->handle = cpu_to_le32(TAG_ENCODE(idx));
- ioc->data_addr = cpu_to_le32(msg_data);
-
- return sizeof(struct carm_msg_get_fw_ver) +
- sizeof(struct carm_fw_ver);
-}
-
-static inline void carm_end_request_queued(struct carm_host *host,
- struct carm_request *crq,
- int uptodate)
-{
- struct request *req = crq->rq;
- int rc;
-
- rc = end_that_request_first(req, uptodate, req->hard_nr_sectors);
- assert(rc == 0);
-
- end_that_request_last(req);
-
- rc = carm_put_request(host, crq);
- assert(rc == 0);
-}
-
-static inline void carm_push_q (struct carm_host *host, request_queue_t *q)
-{
- unsigned int idx = host->wait_q_prod % CARM_MAX_WAIT_Q;
-
- blk_stop_queue(q);
- VPRINTK("STOPPED QUEUE %p\n", q);
-
- host->wait_q[idx] = q;
- host->wait_q_prod++;
- BUG_ON(host->wait_q_prod == host->wait_q_cons); /* overrun */
-}
-
-static inline request_queue_t *carm_pop_q(struct carm_host *host)
-{
- unsigned int idx;
-
- if (host->wait_q_prod == host->wait_q_cons)
- return NULL;
-
- idx = host->wait_q_cons % CARM_MAX_WAIT_Q;
- host->wait_q_cons++;
-
- return host->wait_q[idx];
-}
-
-static inline void carm_round_robin(struct carm_host *host)
-{
- request_queue_t *q = carm_pop_q(host);
- if (q) {
- blk_start_queue(q);
- VPRINTK("STARTED QUEUE %p\n", q);
- }
-}
-
-static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq,
- int is_ok)
-{
- carm_end_request_queued(host, crq, is_ok);
- if (CARM_MAX_Q == 1)
- carm_round_robin(host);
- else if ((host->n_msgs <= CARM_MSG_LOW_WATER) &&
- (host->hw_sg_used <= CARM_SG_LOW_WATER)) {
- carm_round_robin(host);
- }
-}
-
-static void carm_oob_rq_fn(request_queue_t *q)
-{
- struct carm_host *host = q->queuedata;
- struct carm_request *crq;
- struct request *rq;
- int rc;
-
- while (1) {
- DPRINTK("get req\n");
- rq = elv_next_request(q);
- if (!rq)
- break;
-
- blkdev_dequeue_request(rq);
-
- crq = rq->special;
- assert(crq != NULL);
- assert(crq->rq == rq);
-
- crq->n_elem = 0;
-
- DPRINTK("send req\n");
- rc = carm_send_msg(host, crq);
- if (rc) {
- blk_requeue_request(q, rq);
- carm_push_q(host, q);
- return; /* call us again later, eventually */
- }
- }
-}
-
-static void carm_rq_fn(request_queue_t *q)
-{
- struct carm_port *port = q->queuedata;
- struct carm_host *host = port->host;
- struct carm_msg_rw *msg;
- struct carm_request *crq;
- struct request *rq;
- struct scatterlist *sg;
- int writing = 0, pci_dir, i, n_elem, rc;
- u32 tmp;
- unsigned int msg_size;
-
-queue_one_request:
- VPRINTK("get req\n");
- rq = elv_next_request(q);
- if (!rq)
- return;
-
- crq = carm_get_request(host);
- if (!crq) {
- carm_push_q(host, q);
- return; /* call us again later, eventually */
- }
- crq->rq = rq;
-
- blkdev_dequeue_request(rq);
-
- if (rq_data_dir(rq) == WRITE) {
- writing = 1;
- pci_dir = PCI_DMA_TODEVICE;
- } else {
- pci_dir = PCI_DMA_FROMDEVICE;
- }
-
- /* get scatterlist from block layer */
- sg = &crq->sg[0];
- n_elem = blk_rq_map_sg(q, rq, sg);
- if (n_elem <= 0) {
- carm_end_rq(host, crq, 0);
- return; /* request with no s/g entries? */
- }
-
- /* map scatterlist to PCI bus addresses */
- n_elem = pci_map_sg(host->pdev, sg, n_elem, pci_dir);
- if (n_elem <= 0) {
- carm_end_rq(host, crq, 0);
- return; /* request with no s/g entries? */
- }
- crq->n_elem = n_elem;
- crq->port = port;
- host->hw_sg_used += n_elem;
-
- /*
- * build read/write message
- */
-
- VPRINTK("build msg\n");
- msg = (struct carm_msg_rw *) carm_ref_msg(host, crq->tag);
-
- if (writing) {
- msg->type = CARM_MSG_WRITE;
- crq->msg_type = CARM_MSG_WRITE;
- } else {
- msg->type = CARM_MSG_READ;
- crq->msg_type = CARM_MSG_READ;
- }
-
- msg->id = port->port_no;
- msg->sg_count = n_elem;
- msg->sg_type = SGT_32BIT;
- msg->handle = cpu_to_le32(TAG_ENCODE(crq->tag));
- msg->lba = cpu_to_le32(rq->sector & 0xffffffff);
- tmp = (rq->sector >> 16) >> 16;
- msg->lba_high = cpu_to_le16( (u16) tmp );
- msg->lba_count = cpu_to_le16(rq->nr_sectors);
-
- msg_size = sizeof(struct carm_msg_rw) - sizeof(msg->sg);
- for (i = 0; i < n_elem; i++) {
- struct carm_msg_sg *carm_sg = &msg->sg[i];
- carm_sg->start = cpu_to_le32(sg_dma_address(&crq->sg[i]));
- carm_sg->len = cpu_to_le32(sg_dma_len(&crq->sg[i]));
- msg_size += sizeof(struct carm_msg_sg);
- }
-
- rc = carm_lookup_bucket(msg_size);
- BUG_ON(rc < 0);
- crq->msg_bucket = (u32) rc;
-
- /*
- * queue read/write message to hardware
- */
-
- VPRINTK("send msg, tag == %u\n", crq->tag);
- rc = carm_send_msg(host, crq);
- if (rc) {
- carm_put_request(host, crq);
- blk_requeue_request(q, rq);
- carm_push_q(host, q);
- return; /* call us again later, eventually */
- }
-
- goto queue_one_request;
-}
-
-static void carm_handle_array_info(struct carm_host *host,
- struct carm_request *crq, u8 *mem,
- int is_ok)
-{
- struct carm_port *port;
- u8 *msg_data = mem + sizeof(struct carm_array_info);
- struct carm_array_info *desc = (struct carm_array_info *) msg_data;
- u64 lo, hi;
- int cur_port;
- size_t slen;
-
- DPRINTK("ENTER\n");
-
- carm_end_rq(host, crq, is_ok);
-
- if (!is_ok)
- goto out;
- if (le32_to_cpu(desc->array_status) & ARRAY_NO_EXIST)
- goto out;
-
- cur_port = host->cur_scan_dev;
-
- /* should never occur */
- if ((cur_port < 0) || (cur_port >= CARM_MAX_PORTS)) {
- printk(KERN_ERR PFX "BUG: cur_scan_dev==%d, array_id==%d\n",
- cur_port, (int) desc->array_id);
- goto out;
- }
-
- port = &host->port[cur_port];
-
- lo = (u64) le32_to_cpu(desc->size);
- hi = (u64) le32_to_cpu(desc->size_hi);
-
- port->capacity = lo | (hi << 32);
- port->dev_geom_head = le16_to_cpu(desc->head);
- port->dev_geom_sect = le16_to_cpu(desc->sect);
- port->dev_geom_cyl = le16_to_cpu(desc->cyl);
-
- host->dev_active |= (1 << cur_port);
-
- strncpy(port->name, desc->name, sizeof(port->name));
- port->name[sizeof(port->name) - 1] = 0;
- slen = strlen(port->name);
- while (slen && (port->name[slen - 1] == ' ')) {
- port->name[slen - 1] = 0;
- slen--;
- }
-
- printk(KERN_INFO DRV_NAME "(%s): port %u device %Lu sectors\n",
- pci_name(host->pdev), port->port_no,
- (unsigned long long) port->capacity);
- printk(KERN_INFO DRV_NAME "(%s): port %u device \"%s\"\n",
- pci_name(host->pdev), port->port_no, port->name);
-
-out:
- assert(host->state == HST_DEV_SCAN);
- schedule_work(&host->fsm_task);
-}
-
-static void carm_handle_scan_chan(struct carm_host *host,
- struct carm_request *crq, u8 *mem,
- int is_ok)
-{
- u8 *msg_data = mem + IOC_SCAN_CHAN_OFFSET;
- unsigned int i, dev_count = 0;
- int new_state = HST_DEV_SCAN_START;
-
- DPRINTK("ENTER\n");
-
- carm_end_rq(host, crq, is_ok);
-
- if (!is_ok) {
- new_state = HST_ERROR;
- goto out;
- }
-
- /* TODO: scan and support non-disk devices */
- for (i = 0; i < 8; i++)
- if (msg_data[i] == 0) { /* direct-access device (disk) */
- host->dev_present |= (1 << i);
- dev_count++;
- }
-
- printk(KERN_INFO DRV_NAME "(%s): found %u interesting devices\n",
- pci_name(host->pdev), dev_count);
-
-out:
- assert(host->state == HST_PORT_SCAN);
- host->state = new_state;
- schedule_work(&host->fsm_task);
-}
-
-static void carm_handle_generic(struct carm_host *host,
- struct carm_request *crq, int is_ok,
- int cur_state, int next_state)
-{
- DPRINTK("ENTER\n");
-
- carm_end_rq(host, crq, is_ok);
-
- assert(host->state == cur_state);
- if (is_ok)
- host->state = next_state;
- else
- host->state = HST_ERROR;
- schedule_work(&host->fsm_task);
-}
-
-static inline void carm_handle_rw(struct carm_host *host,
- struct carm_request *crq, int is_ok)
-{
- int pci_dir;
-
- VPRINTK("ENTER\n");
-
- if (rq_data_dir(crq->rq) == WRITE)
- pci_dir = PCI_DMA_TODEVICE;
- else
- pci_dir = PCI_DMA_FROMDEVICE;
-
- pci_unmap_sg(host->pdev, &crq->sg[0], crq->n_elem, pci_dir);
-
- carm_end_rq(host, crq, is_ok);
-}
-
-static inline void carm_handle_resp(struct carm_host *host,
- u32 ret_handle_le, u32 status)
-{
- u32 handle = le32_to_cpu(ret_handle_le);
- unsigned int msg_idx;
- struct carm_request *crq;
- int is_ok = (status == RMSG_OK);
- u8 *mem;
-
- VPRINTK("ENTER, handle == 0x%x\n", handle);
-
- if (unlikely(!TAG_VALID(handle))) {
- printk(KERN_ERR DRV_NAME "(%s): BUG: invalid tag 0x%x\n",
- pci_name(host->pdev), handle);
- return;
- }
-
- msg_idx = TAG_DECODE(handle);
- VPRINTK("tag == %u\n", msg_idx);
-
- crq = &host->req[msg_idx];
-
- /* fast path */
- if (likely(crq->msg_type == CARM_MSG_READ ||
- crq->msg_type == CARM_MSG_WRITE)) {
- carm_handle_rw(host, crq, is_ok);
- return;
- }
-
- mem = carm_ref_msg(host, msg_idx);
-
- switch (crq->msg_type) {
- case CARM_MSG_IOCTL: {
- switch (crq->msg_subtype) {
- case CARM_IOC_SCAN_CHAN:
- carm_handle_scan_chan(host, crq, mem, is_ok);
- break;
- default:
- /* unknown / invalid response */
- goto err_out;
- }
- break;
- }
-
- case CARM_MSG_MISC: {
- switch (crq->msg_subtype) {
- case MISC_ALLOC_MEM:
- carm_handle_generic(host, crq, is_ok,
- HST_ALLOC_BUF, HST_SYNC_TIME);
- break;
- case MISC_SET_TIME:
- carm_handle_generic(host, crq, is_ok,
- HST_SYNC_TIME, HST_GET_FW_VER);
- break;
- case MISC_GET_FW_VER: {
- struct carm_fw_ver *ver = (struct carm_fw_ver *)
- mem + sizeof(struct carm_msg_get_fw_ver);
- if (is_ok) {
- host->fw_ver = le32_to_cpu(ver->version);
- host->flags |= (ver->features & FL_FW_VER_MASK);
- }
- carm_handle_generic(host, crq, is_ok,
- HST_GET_FW_VER, HST_PORT_SCAN);
- break;
- }
- default:
- /* unknown / invalid response */
- goto err_out;
- }
- break;
- }
-
- case CARM_MSG_ARRAY: {
- switch (crq->msg_subtype) {
- case CARM_ARRAY_INFO:
- carm_handle_array_info(host, crq, mem, is_ok);
- break;
- default:
- /* unknown / invalid response */
- goto err_out;
- }
- break;
- }
-
- default:
- /* unknown / invalid response */
- goto err_out;
- }
-
- return;
-
-err_out:
- printk(KERN_WARNING DRV_NAME "(%s): BUG: unhandled message type %d/%d\n",
- pci_name(host->pdev), crq->msg_type, crq->msg_subtype);
- carm_end_rq(host, crq, 0);
-}
-
-static inline void carm_handle_responses(struct carm_host *host)
-{
- void *mmio = host->mmio;
- struct carm_response *resp = (struct carm_response *) host->shm;
- unsigned int work = 0;
- unsigned int idx = host->resp_idx % RMSG_Q_LEN;
-
- while (1) {
- u32 status = le32_to_cpu(resp[idx].status);
-
- if (status == 0xffffffff) {
- VPRINTK("ending response on index %u\n", idx);
- writel(idx << 3, mmio + CARM_RESP_IDX);
- break;
- }
-
- /* response to a message we sent */
- else if ((status & (1 << 31)) == 0) {
- VPRINTK("handling msg response on index %u\n", idx);
- carm_handle_resp(host, resp[idx].ret_handle, status);
- resp[idx].status = 0xffffffff;
- }
-
- /* asynchronous events the hardware throws our way */
- else if ((status & 0xff000000) == (1 << 31)) {
- u8 *evt_type_ptr = (u8 *) &resp[idx];
- u8 evt_type = *evt_type_ptr;
- printk(KERN_WARNING DRV_NAME "(%s): unhandled event type %d\n",
- pci_name(host->pdev), (int) evt_type);
- resp[idx].status = 0xffffffff;
- }
-
- idx = NEXT_RESP(idx);
- work++;
- }
-
- VPRINTK("EXIT, work==%u\n", work);
- host->resp_idx += work;
-}
-
-static irqreturn_t carm_interrupt(int irq, void *__host, struct pt_regs *regs)
-{
- struct carm_host *host = __host;
- void *mmio;
- u32 mask;
- int handled = 0;
- unsigned long flags;
-
- if (!host) {
- VPRINTK("no host\n");
- return IRQ_NONE;
- }
-
- spin_lock_irqsave(&host->lock, flags);
-
- mmio = host->mmio;
-
- /* reading should also clear interrupts */
- mask = readl(mmio + CARM_INT_STAT);
-
- if (mask == 0 || mask == 0xffffffff) {
- VPRINTK("no work, mask == 0x%x\n", mask);
- goto out;
- }
-
- if (mask & INT_ACK_MASK)
- writel(mask, mmio + CARM_INT_STAT);
-
- if (unlikely(host->state == HST_INVALID)) {
- VPRINTK("not initialized yet, mask = 0x%x\n", mask);
- goto out;
- }
-
- if (mask & CARM_HAVE_RESP) {
- handled = 1;
- carm_handle_responses(host);
- }
-
-out:
- spin_unlock_irqrestore(&host->lock, flags);
- VPRINTK("EXIT\n");
- return IRQ_RETVAL(handled);
-}
-
-static void carm_fsm_task (void *_data)
-{
- struct carm_host *host = _data;
- unsigned long flags;
- unsigned int state;
- int rc, i, next_dev;
- int reschedule = 0;
- int new_state = HST_INVALID;
-
- spin_lock_irqsave(&host->lock, flags);
- state = host->state;
- spin_unlock_irqrestore(&host->lock, flags);
-
- DPRINTK("ENTER, state == %s\n", state_name[state]);
-
- switch (state) {
- case HST_PROBE_START:
- new_state = HST_ALLOC_BUF;
- reschedule = 1;
- break;
-
- case HST_ALLOC_BUF:
- rc = carm_send_special(host, carm_fill_alloc_buf);
- if (rc) {
- new_state = HST_ERROR;
- reschedule = 1;
- }
- break;
-
- case HST_SYNC_TIME:
- rc = carm_send_special(host, carm_fill_sync_time);
- if (rc) {
- new_state = HST_ERROR;
- reschedule = 1;
- }
- break;
-
- case HST_GET_FW_VER:
- rc = carm_send_special(host, carm_fill_get_fw_ver);
- if (rc) {
- new_state = HST_ERROR;
- reschedule = 1;
- }
- break;
-
- case HST_PORT_SCAN:
- rc = carm_send_special(host, carm_fill_scan_channels);
- if (rc) {
- new_state = HST_ERROR;
- reschedule = 1;
- }
- break;
-
- case HST_DEV_SCAN_START:
- host->cur_scan_dev = -1;
- new_state = HST_DEV_SCAN;
- reschedule = 1;
- break;
-
- case HST_DEV_SCAN:
- next_dev = -1;
- for (i = host->cur_scan_dev + 1; i < CARM_MAX_PORTS; i++)
- if (host->dev_present & (1 << i)) {
- next_dev = i;
- break;
- }
-
- if (next_dev >= 0) {
- host->cur_scan_dev = next_dev;
- rc = carm_array_info(host, next_dev);
- if (rc) {
- new_state = HST_ERROR;
- reschedule = 1;
- }
- } else {
- new_state = HST_DEV_ACTIVATE;
- reschedule = 1;
- }
- break;
-
- case HST_DEV_ACTIVATE: {
- int activated = 0;
- for (i = 0; i < CARM_MAX_PORTS; i++)
- if (host->dev_active & (1 << i)) {
- struct carm_port *port = &host->port[i];
- struct gendisk *disk = port->disk;
-
- set_capacity(disk, port->capacity);
- add_disk(disk);
- activated++;
- }
-
- printk(KERN_INFO DRV_NAME "(%s): %d ports activated\n",
- pci_name(host->pdev), activated);
-
- new_state = HST_PROBE_FINISHED;
- reschedule = 1;
- break;
- }
-
- case HST_PROBE_FINISHED:
- up(&host->probe_sem);
- break;
-
- case HST_ERROR:
- /* FIXME: TODO */
- break;
-
- default:
- /* should never occur */
- printk(KERN_ERR PFX "BUG: unknown state %d\n", state);
- assert(0);
- break;
- }
-
- if (new_state != HST_INVALID) {
- spin_lock_irqsave(&host->lock, flags);
- host->state = new_state;
- spin_unlock_irqrestore(&host->lock, flags);
- }
- if (reschedule)
- schedule_work(&host->fsm_task);
-}
-
-static int carm_init_wait(void *mmio, u32 bits, unsigned int test_bit)
-{
- unsigned int i;
-
- for (i = 0; i < 50000; i++) {
- u32 tmp = readl(mmio + CARM_LMUC);
- udelay(100);
-
- if (test_bit) {
- if ((tmp & bits) == bits)
- return 0;
- } else {
- if ((tmp & bits) == 0)
- return 0;
- }
-
- cond_resched();
- }
-
- printk(KERN_ERR PFX "carm_init_wait timeout, bits == 0x%x, test_bit == %s\n",
- bits, test_bit ? "yes" : "no");
- return -EBUSY;
-}
-
-static void carm_init_responses(struct carm_host *host)
-{
- void *mmio = host->mmio;
- unsigned int i;
- struct carm_response *resp = (struct carm_response *) host->shm;
-
- for (i = 0; i < RMSG_Q_LEN; i++)
- resp[i].status = 0xffffffff;
-
- writel(0, mmio + CARM_RESP_IDX);
-}
-
-static int carm_init_host(struct carm_host *host)
-{
- void *mmio = host->mmio;
- u32 tmp;
- u8 tmp8;
- int rc;
-
- DPRINTK("ENTER\n");
-
- writel(0, mmio + CARM_INT_MASK);
-
- tmp8 = readb(mmio + CARM_INITC);
- if (tmp8 & 0x01) {
- tmp8 &= ~0x01;
- writeb(tmp8, CARM_INITC);
- readb(mmio + CARM_INITC); /* flush */
-
- DPRINTK("snooze...\n");
- msleep(5000);
- }
-
- tmp = readl(mmio + CARM_HMUC);
- if (tmp & CARM_CME) {
- DPRINTK("CME bit present, waiting\n");
- rc = carm_init_wait(mmio, CARM_CME, 1);
- if (rc) {
- DPRINTK("EXIT, carm_init_wait 1 failed\n");
- return rc;
- }
- }
- if (tmp & CARM_RME) {
- DPRINTK("RME bit present, waiting\n");
- rc = carm_init_wait(mmio, CARM_RME, 1);
- if (rc) {
- DPRINTK("EXIT, carm_init_wait 2 failed\n");
- return rc;
- }
- }
-
- tmp &= ~(CARM_RME | CARM_CME);
- writel(tmp, mmio + CARM_HMUC);
- readl(mmio + CARM_HMUC); /* flush */
-
- rc = carm_init_wait(mmio, CARM_RME | CARM_CME, 0);
- if (rc) {
- DPRINTK("EXIT, carm_init_wait 3 failed\n");
- return rc;
- }
-
- carm_init_buckets(mmio);
-
- writel(host->shm_dma & 0xffffffff, mmio + RBUF_ADDR_LO);
- writel((host->shm_dma >> 16) >> 16, mmio + RBUF_ADDR_HI);
- writel(RBUF_LEN, mmio + RBUF_BYTE_SZ);
-
- tmp = readl(mmio + CARM_HMUC);
- tmp |= (CARM_RME | CARM_CME | CARM_WZBC);
- writel(tmp, mmio + CARM_HMUC);
- readl(mmio + CARM_HMUC); /* flush */
-
- rc = carm_init_wait(mmio, CARM_RME | CARM_CME, 1);
- if (rc) {
- DPRINTK("EXIT, carm_init_wait 4 failed\n");
- return rc;
- }
-
- writel(0, mmio + CARM_HMPHA);
- writel(INT_DEF_MASK, mmio + CARM_INT_MASK);
-
- carm_init_responses(host);
-
- /* start initialization, probing state machine */
- spin_lock_irq(&host->lock);
- assert(host->state == HST_INVALID);
- host->state = HST_PROBE_START;
- spin_unlock_irq(&host->lock);
- schedule_work(&host->fsm_task);
-
- DPRINTK("EXIT\n");
- return 0;
-}
-
-static int carm_init_disks(struct carm_host *host)
-{
- unsigned int i;
- int rc = 0;
-
- for (i = 0; i < CARM_MAX_PORTS; i++) {
- struct gendisk *disk;
- request_queue_t *q;
- struct carm_port *port;
-
- port = &host->port[i];
- port->host = host;
- port->port_no = i;
-
- disk = alloc_disk(CARM_MINORS_PER_MAJOR);
- if (!disk) {
- rc = -ENOMEM;
- break;
- }
-
- port->disk = disk;
- sprintf(disk->disk_name, DRV_NAME "%u_%u", host->id, i);
- sprintf(disk->devfs_name, DRV_NAME "/%u_%u", host->id, i);
- disk->major = host->major;
- disk->first_minor = i * CARM_MINORS_PER_MAJOR;
- disk->fops = &carm_bd_ops;
- disk->private_data = port;
-
- q = blk_init_queue(carm_rq_fn, &host->lock);
- if (!q) {
- rc = -ENOMEM;
- break;
- }
- disk->queue = q;
- blk_queue_max_hw_segments(q, CARM_MAX_REQ_SG);
- blk_queue_max_phys_segments(q, CARM_MAX_REQ_SG);
- blk_queue_segment_boundary(q, CARM_SG_BOUNDARY);
-
- q->queuedata = port;
- }
-
- return rc;
-}
-
-static void carm_free_disks(struct carm_host *host)
-{
- unsigned int i;
-
- for (i = 0; i < CARM_MAX_PORTS; i++) {
- struct gendisk *disk = host->port[i].disk;
- if (disk) {
- request_queue_t *q = disk->queue;
-
- if (disk->flags & GENHD_FL_UP)
- del_gendisk(disk);
- if (q)
- blk_cleanup_queue(q);
- put_disk(disk);
- }
- }
-}
-
-static int carm_init_shm(struct carm_host *host)
-{
- host->shm = pci_alloc_consistent(host->pdev, CARM_SHM_SIZE,
- &host->shm_dma);
- if (!host->shm)
- return -ENOMEM;
-
- host->msg_base = host->shm + RBUF_LEN;
- host->msg_dma = host->shm_dma + RBUF_LEN;
-
- memset(host->shm, 0xff, RBUF_LEN);
- memset(host->msg_base, 0, PDC_SHM_SIZE - RBUF_LEN);
-
- return 0;
-}
-
-static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- static unsigned int printed_version;
- struct carm_host *host;
- unsigned int pci_dac;
- int rc;
- request_queue_t *q;
- unsigned int i;
-
- if (!printed_version++)
- printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
-
- rc = pci_enable_device(pdev);
- if (rc)
- return rc;
-
- rc = pci_request_regions(pdev, DRV_NAME);
- if (rc)
- goto err_out;
-
-#if IF_64BIT_DMA_IS_POSSIBLE /* grrrr... */
- rc = pci_set_dma_mask(pdev, 0xffffffffffffffffULL);
- if (!rc) {
- rc = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL);
- if (rc) {
- printk(KERN_ERR DRV_NAME "(%s): consistent DMA mask failure\n",
- pci_name(pdev));
- goto err_out_regions;
- }
- pci_dac = 1;
- } else {
-#endif
- rc = pci_set_dma_mask(pdev, 0xffffffffULL);
- if (rc) {
- printk(KERN_ERR DRV_NAME "(%s): DMA mask failure\n",
- pci_name(pdev));
- goto err_out_regions;
- }
- pci_dac = 0;
-#if IF_64BIT_DMA_IS_POSSIBLE /* grrrr... */
- }
-#endif
-
- host = kmalloc(sizeof(*host), GFP_KERNEL);
- if (!host) {
- printk(KERN_ERR DRV_NAME "(%s): memory alloc failure\n",
- pci_name(pdev));
- rc = -ENOMEM;
- goto err_out_regions;
- }
-
- memset(host, 0, sizeof(*host));
- host->pdev = pdev;
- host->flags = pci_dac ? FL_DAC : 0;
- spin_lock_init(&host->lock);
- INIT_WORK(&host->fsm_task, carm_fsm_task, host);
- init_MUTEX_LOCKED(&host->probe_sem);
-
- for (i = 0; i < ARRAY_SIZE(host->req); i++)
- host->req[i].tag = i;
-
- host->mmio = ioremap(pci_resource_start(pdev, 0),
- pci_resource_len(pdev, 0));
- if (!host->mmio) {
- printk(KERN_ERR DRV_NAME "(%s): MMIO alloc failure\n",
- pci_name(pdev));
- rc = -ENOMEM;
- goto err_out_kfree;
- }
-
- rc = carm_init_shm(host);
- if (rc) {
- printk(KERN_ERR DRV_NAME "(%s): DMA SHM alloc failure\n",
- pci_name(pdev));
- goto err_out_iounmap;
- }
-
- q = blk_init_queue(carm_oob_rq_fn, &host->lock);
- if (!q) {
- printk(KERN_ERR DRV_NAME "(%s): OOB queue alloc failure\n",
- pci_name(pdev));
- rc = -ENOMEM;
- goto err_out_pci_free;
- }
- host->oob_q = q;
- q->queuedata = host;
-
- /*
- * Figure out which major to use: 160, 161, or dynamic
- */
- if (!test_and_set_bit(0, &carm_major_alloc))
- host->major = 160;
- else if (!test_and_set_bit(1, &carm_major_alloc))
- host->major = 161;
- else
- host->flags |= FL_DYN_MAJOR;
-
- host->id = carm_host_id;
- sprintf(host->name, DRV_NAME "%d", carm_host_id);
-
- rc = register_blkdev(host->major, host->name);
- if (rc < 0)
- goto err_out_free_majors;
- if (host->flags & FL_DYN_MAJOR)
- host->major = rc;
-
- devfs_mk_dir(DRV_NAME);
-
- rc = carm_init_disks(host);
- if (rc)
- goto err_out_blkdev_disks;
-
- pci_set_master(pdev);
-
- rc = request_irq(pdev->irq, carm_interrupt, SA_SHIRQ, DRV_NAME, host);
- if (rc) {
- printk(KERN_ERR DRV_NAME "(%s): irq alloc failure\n",
- pci_name(pdev));
- goto err_out_blkdev_disks;
- }
-
- rc = carm_init_host(host);
- if (rc)
- goto err_out_free_irq;
-
- DPRINTK("waiting for probe_sem\n");
- down(&host->probe_sem);
-
- printk(KERN_INFO "%s: pci %s, ports %d, io %lx, irq %u, major %d\n",
- host->name, pci_name(pdev), (int) CARM_MAX_PORTS,
- pci_resource_start(pdev, 0), pdev->irq, host->major);
-
- carm_host_id++;
- pci_set_drvdata(pdev, host);
- return 0;
-
-err_out_free_irq:
- free_irq(pdev->irq, host);
-err_out_blkdev_disks:
- carm_free_disks(host);
- unregister_blkdev(host->major, host->name);
-err_out_free_majors:
- if (host->major == 160)
- clear_bit(0, &carm_major_alloc);
- else if (host->major == 161)
- clear_bit(1, &carm_major_alloc);
- blk_cleanup_queue(host->oob_q);
-err_out_pci_free:
- pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma);
-err_out_iounmap:
- iounmap(host->mmio);
-err_out_kfree:
- kfree(host);
-err_out_regions:
- pci_release_regions(pdev);
-err_out:
- pci_disable_device(pdev);
- return rc;
-}
-
-static void carm_remove_one (struct pci_dev *pdev)
-{
- struct carm_host *host = pci_get_drvdata(pdev);
-
- if (!host) {
- printk(KERN_ERR PFX "BUG: no host data for PCI(%s)\n",
- pci_name(pdev));
- return;
- }
-
- free_irq(pdev->irq, host);
- carm_free_disks(host);
- devfs_remove(DRV_NAME);
- unregister_blkdev(host->major, host->name);
- if (host->major == 160)
- clear_bit(0, &carm_major_alloc);
- else if (host->major == 161)
- clear_bit(1, &carm_major_alloc);
- blk_cleanup_queue(host->oob_q);
- pci_free_consistent(pdev, CARM_SHM_SIZE, host->shm, host->shm_dma);
- iounmap(host->mmio);
- kfree(host);
- pci_release_regions(pdev);
- pci_disable_device(pdev);
- pci_set_drvdata(pdev, NULL);
-}
-
-static int __init carm_init(void)
-{
- return pci_module_init(&carm_driver);
-}
-
-static void __exit carm_exit(void)
-{
- pci_unregister_driver(&carm_driver);
-}
-
-module_init(carm_init);
-module_exit(carm_exit);
-
-
+++ /dev/null
-/*
- * linux/drivers/block/floppy.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- * Copyright (C) 1993, 1994 Alain Knaff
- * Copyright (C) 1998 Alan Cox
- */
-/*
- * 02.12.91 - Changed to static variables to indicate need for reset
- * and recalibrate. This makes some things easier (output_byte reset
- * checking etc), and means less interrupt jumping in case of errors,
- * so the code is hopefully easier to understand.
- */
-
-/*
- * This file is certainly a mess. I've tried my best to get it working,
- * but I don't like programming floppies, and I have only one anyway.
- * Urgel. I should check for more errors, and do more graceful error
- * recovery. Seems there are problems with several drives. I've tried to
- * correct them. No promises.
- */
-
-/*
- * As with hd.c, all routines within this file can (and will) be called
- * by interrupts, so extreme caution is needed. A hardware interrupt
- * handler may not sleep, or a kernel panic will happen. Thus I cannot
- * call "floppy-on" directly, but have to set a special timer interrupt
- * etc.
- */
-
-/*
- * 28.02.92 - made track-buffering routines, based on the routines written
- * by entropy@wintermute.wpi.edu (Lawrence Foard). Linus.
- */
-
-/*
- * Automatic floppy-detection and formatting written by Werner Almesberger
- * (almesber@nessie.cs.id.ethz.ch), who also corrected some problems with
- * the floppy-change signal detection.
- */
-
-/*
- * 1992/7/22 -- Hennus Bergman: Added better error reporting, fixed
- * FDC data overrun bug, added some preliminary stuff for vertical
- * recording support.
- *
- * 1992/9/17: Added DMA allocation & DMA functions. -- hhb.
- *
- * TODO: Errors are still not counted properly.
- */
-
-/* 1992/9/20
- * Modifications for ``Sector Shifting'' by Rob Hooft (hooft@chem.ruu.nl)
- * modeled after the freeware MS-DOS program fdformat/88 V1.8 by
- * Christoph H. Hochst\"atter.
- * I have fixed the shift values to the ones I always use. Maybe a new
- * ioctl() should be created to be able to modify them.
- * There is a bug in the driver that makes it impossible to format a
- * floppy as the first thing after bootup.
- */
-
-/*
- * 1993/4/29 -- Linus -- cleaned up the timer handling in the kernel, and
- * this helped the floppy driver as well. Much cleaner, and still seems to
- * work.
- */
-
-/* 1994/6/24 --bbroad-- added the floppy table entries and made
- * minor modifications to allow 2.88 floppies to be run.
- */
-
-/* 1994/7/13 -- Paul Vojta -- modified the probing code to allow three or more
- * disk types.
- */
-
-/*
- * 1994/8/8 -- Alain Knaff -- Switched to fdpatch driver: Support for bigger
- * format bug fixes, but unfortunately some new bugs too...
- */
-
-/* 1994/9/17 -- Koen Holtman -- added logging of physical floppy write
- * errors to allow safe writing by specialized programs.
- */
-
-/* 1995/4/24 -- Dan Fandrich -- added support for Commodore 1581 3.5" disks
- * by defining bit 1 of the "stretch" parameter to mean put sectors on the
- * opposite side of the disk, leaving the sector IDs alone (i.e. Commodore's
- * drives are "upside-down").
- */
-
-/*
- * 1995/8/26 -- Andreas Busse -- added Mips support.
- */
-
-/*
- * 1995/10/18 -- Ralf Baechle -- Portability cleanup; move machine dependent
- * features to asm/floppy.h.
- */
-
-/*
- * 1998/05/07 -- Russell King -- More portability cleanups; moved definition of
- * interrupt and dma channel to asm/floppy.h. Cleaned up some formatting &
- * use of '0' for NULL.
- */
-
-/*
- * 1998/06/07 -- Alan Cox -- Merged the 2.0.34 fixes for resource allocation
- * failures.
- */
-
-/*
- * 1998/09/20 -- David Weinehall -- Added slow-down code for buggy PS/2-drives.
- */
-
-/*
- * 1999/01/19 -- N.Fujita & Linux/98 Project -- Added code for NEC PC-9800
- * series.
- */
-
-/*
- * 1999/08/13 -- Paul Slootman -- floppy stopped working on Alpha after 24
- * days, 6 hours, 32 minutes and 32 seconds (i.e. MAXINT jiffies; ints were
- * being used to store jiffies, which are unsigned longs).
- */
-
-/*
- * 2000/08/28 -- Arnaldo Carvalho de Melo <acme@conectiva.com.br>
- * - get rid of check_region
- * - s/suser/capable/
- */
-
-/*
- * 2001/08/26 -- Paul Gortmaker - fix insmod oops on machines with no
- * floppy controller (lingering task on list after module is gone... boom.)
- */
-
-/*
- * 2002/02/07 -- Anton Altaparmakov - Fix io ports reservation to correct range
- * (0x3f2-0x3f5, 0x3f7). This fix is a bit of a hack but the proper fix
- * requires many non-obvious changes in arch dependent code.
- */
-
-/*
- * 2002/10/12 -- Osamu Tomita <tomita@cinet.co.jp>
- * split code from floppy.c
- * support NEC PC-9800 only
- */
-
-#define FLOPPY_SANITY_CHECK
-#undef FLOPPY_SILENT_DCL_CLEAR
-
-/*
-#define PC9800_DEBUG_FLOPPY
-#define PC9800_DEBUG_FLOPPY2
-*/
-
-#define REALLY_SLOW_IO
-
-#define DEBUGT 2
-#define DCL_DEBUG /* debug disk change line */
-
-/* do print messages for unexpected interrupts */
-static int print_unex=1;
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-#include <linux/version.h>
-#include <linux/fdreg.h>
-#include <linux/blkdev.h>
-#include <linux/blkpg.h>
-#include <linux/cdrom.h> /* for the compatibility eject ioctl */
-#include <linux/completion.h>
-
-/*
- * 1998/1/21 -- Richard Gooch <rgooch@atnf.csiro.au> -- devfs support
- */
-
-
-#include <linux/fd.h>
-#define FLOPPY98_MOTOR_MASK 0x08
-
-#include <linux/hdreg.h>
-#define FD98_STATUS (0 + FD_IOPORT )
-#define FD98_DATA (2 + FD_IOPORT )
-#define FD_MODE (4 + FD_IOPORT )
-#define FD_MODE_CHANGE 0xbe
-#define FD_EMODE_CHANGE 0x4be
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/bio.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/mc146818rtc.h> /* CMOS defines */
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/device.h>
-#include <linux/buffer_head.h> /* for invalidate_buffers() */
-
-/*
- * PS/2 floppies have much slower step rates than regular floppies.
- * It's been recommended that take about 1/4 of the default speed
- * in some more extreme cases.
- */
-static int slow_floppy;
-
-#include <asm/dma.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#ifndef DEFAULT_FLOPPY_IRQ
-# define DEFAULT_FLOPPY_IRQ 11
-#endif
-#ifndef DEFAULT_FLOPPY_DMA
-# define DEFAULT_FLOPPY_DMA 2
-#endif
-
-static int FLOPPY_IRQ=DEFAULT_FLOPPY_IRQ;
-static int FLOPPY_DMA=DEFAULT_FLOPPY_DMA;
-static int can_use_virtual_dma=2;
-static int auto_detect_mode = 0;
-static int retry_auto_detect = 0;
-#define FD_AFTER_RESET_DELAY 1000
-
-/* =======
- * can use virtual DMA:
- * 0 = use of virtual DMA disallowed by config
- * 1 = use of virtual DMA prescribed by config
- * 2 = no virtual DMA preference configured. By default try hard DMA,
- * but fall back on virtual DMA when not enough memory available
- */
-
-static int use_virtual_dma;
-/* =======
- * use virtual DMA
- * 0 using hard DMA
- * 1 using virtual DMA
- * This variable is set to virtual when a DMA mem problem arises, and
- * reset back in floppy_grab_irq_and_dma.
- * It is not safe to reset it in other circumstances, because the floppy
- * driver may have several buffers in use at once, and we do currently not
- * record each buffers capabilities
- */
-
-static spinlock_t floppy_lock = SPIN_LOCK_UNLOCKED;
-static struct completion device_release;
-
-static unsigned short virtual_dma_port=0x3f0;
-irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs);
-static int set_mode(char mask, char data);
-static void register_devfs_entries (int drive) __init;
-
-#define K_64 0x10000 /* 64KB */
-
-/* the following is the mask of allowed drives. By default units 2 and
- * 3 of both floppy controllers are disabled, because switching on the
- * motor of these drives causes system hangs on some PCI computers. drive
- * 0 is the low bit (0x1), and drive 7 is the high bit (0x80). Bits are on if
- * a drive is allowed.
- *
- * NOTE: This must come before we include the arch floppy header because
- * some ports reference this variable from there. -DaveM
- */
-
-static int allowed_drive_mask = 0x0f;
-
-#include <asm/floppy.h>
-
-static int irqdma_allocated;
-
-#define LOCAL_END_REQUEST
-#define DEVICE_NAME "floppy"
-
-#include <linux/blkpg.h>
-#include <linux/cdrom.h> /* for the compatibility eject ioctl */
-#include <linux/completion.h>
-
-static struct request *current_req;
-static struct request_queue *floppy_queue;
-
-#ifndef fd_get_dma_residue
-#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
-#endif
-
-/* Dma Memory related stuff */
-
-#ifndef fd_dma_mem_free
-#define fd_dma_mem_free(addr, size) free_pages(addr, get_order(size))
-#endif
-
-#ifndef fd_dma_mem_alloc
-#define fd_dma_mem_alloc(size) __get_dma_pages(GFP_KERNEL,get_order(size))
-#endif
-
-static inline void fallback_on_nodma_alloc(char **addr, size_t l)
-{
-#ifdef FLOPPY_CAN_FALLBACK_ON_NODMA
- if (*addr)
- return; /* we have the memory */
- if (can_use_virtual_dma != 2)
- return; /* no fallback allowed */
- printk("DMA memory shortage. Temporarily falling back on virtual DMA\n");
- *addr = (char *) nodma_mem_alloc(l);
-#else
- return;
-#endif
-}
-
-/* End dma memory related stuff */
-
-static unsigned long fake_change;
-static int initialising=1;
-
-#define ITYPE(x) (((x)>>2) & 0x1f)
-#define TOMINOR(x) ((x & 3) | ((x & 4) << 5))
-#define UNIT(x) ((x) & 0x03) /* drive on fdc */
-#define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */
-#define REVDRIVE(fdc, unit) ((unit) + ((fdc) << 2))
- /* reverse mapping from unit and fdc to drive */
-#define DP (&drive_params[current_drive])
-#define DRS (&drive_state[current_drive])
-#define DRWE (&write_errors[current_drive])
-#define FDCS (&fdc_state[fdc])
-#define CLEARF(x) (clear_bit(x##_BIT, &DRS->flags))
-#define SETF(x) (set_bit(x##_BIT, &DRS->flags))
-#define TESTF(x) (test_bit(x##_BIT, &DRS->flags))
-
-#define UDP (&drive_params[drive])
-#define UDRS (&drive_state[drive])
-#define UDRWE (&write_errors[drive])
-#define UFDCS (&fdc_state[FDC(drive)])
-#define UCLEARF(x) (clear_bit(x##_BIT, &UDRS->flags))
-#define USETF(x) (set_bit(x##_BIT, &UDRS->flags))
-#define UTESTF(x) (test_bit(x##_BIT, &UDRS->flags))
-
-#define DPRINT(format, args...) printk(DEVICE_NAME "%d: " format, current_drive , ## args)
-
-#define PH_HEAD(floppy,head) (((((floppy)->stretch & 2) >>1) ^ head) << 2)
-#define STRETCH(floppy) ((floppy)->stretch & FD_STRETCH)
-
-#define CLEARSTRUCT(x) memset((x), 0, sizeof(*(x)))
-
-/* read/write */
-#define COMMAND raw_cmd->cmd[0]
-#define DR_SELECT raw_cmd->cmd[1]
-#define TRACK raw_cmd->cmd[2]
-#define HEAD raw_cmd->cmd[3]
-#define SECTOR raw_cmd->cmd[4]
-#define SIZECODE raw_cmd->cmd[5]
-#define SECT_PER_TRACK raw_cmd->cmd[6]
-#define GAP raw_cmd->cmd[7]
-#define SIZECODE2 raw_cmd->cmd[8]
-#define NR_RW 9
-
-/* format */
-#define F_SIZECODE raw_cmd->cmd[2]
-#define F_SECT_PER_TRACK raw_cmd->cmd[3]
-#define F_GAP raw_cmd->cmd[4]
-#define F_FILL raw_cmd->cmd[5]
-#define NR_F 6
-
-/*
- * Maximum disk size (in kilobytes). This default is used whenever the
- * current disk size is unknown.
- * [Now it is rather a minimum]
- */
-#define MAX_DISK_SIZE 4 /* 3984*/
-
-
-/*
- * globals used by 'result()'
- */
-#define MAX_REPLIES 16
-static unsigned char reply_buffer[MAX_REPLIES];
-static int inr; /* size of reply buffer, when called from interrupt */
-#define ST0 (reply_buffer[0])
-#define ST1 (reply_buffer[1])
-#define ST2 (reply_buffer[2])
-#define ST3 (reply_buffer[0]) /* result of GETSTATUS */
-#define R_TRACK (reply_buffer[3])
-#define R_HEAD (reply_buffer[4])
-#define R_SECTOR (reply_buffer[5])
-#define R_SIZECODE (reply_buffer[6])
-
-#define SEL_DLY (2*HZ/100)
-
-/*
- * this struct defines the different floppy drive types.
- */
-static struct {
- struct floppy_drive_params params;
- const char *name; /* name printed while booting */
-} default_drive_params[]= {
-/* NOTE: the time values in jiffies should be in msec!
- CMOS drive type
- | Maximum data rate supported by drive type
- | | Head load time, msec
- | | | Head unload time, msec (not used)
- | | | | Step rate interval, usec
- | | | | | Time needed for spinup time (jiffies)
- | | | | | | Timeout for spinning down (jiffies)
- | | | | | | | Spindown offset (where disk stops)
- | | | | | | | | Select delay
- | | | | | | | | | RPS
- | | | | | | | | | | Max number of tracks
- | | | | | | | | | | | Interrupt timeout
- | | | | | | | | | | | | Max nonintlv. sectors
- | | | | | | | | | | | | | -Max Errors- flags */
-{{0, 500, 16, 16, 8000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 80, 3*HZ, 20, {3,1,2,0,2}, 0,
- 0, { 7, 4, 8, 2, 1, 5, 3,10}, 3*HZ/2, 0 }, "unknown" },
-
-{{1, 300, 16, 16, 8000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 40, 3*HZ, 17, {3,1,2,0,2}, 0,
- 0, { 1, 0, 0, 0, 0, 0, 0, 0}, 3*HZ/2, 1 }, "360K PC" }, /*5 1/4 360 KB PC*/
-
-{{2, 500, 16, 16, 6000, 4*HZ/10, 3*HZ, 14, SEL_DLY, 6, 83, 3*HZ, 17, {3,1,2,0,2}, 0,
- 0, { 2, 6, 4, 0, 0, 0, 0, 0}, 3*HZ/2, 2 }, "1.2M" }, /*5 1/4 HD AT*/
-
-{{3, 250, 16, 16, 3000, 1*HZ, 3*HZ, 0, SEL_DLY, 5, 83, 3*HZ, 20, {3,1,2,0,2}, 0,
- 0, { 4, 6, 0, 0, 0, 0, 0, 0}, 3*HZ/2, 4 }, "720k" }, /*3 1/2 DD*/
-
-{{4, 500, 16, 16, 4000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 20, {3,1,2,0,2}, 0,
- 0, { 7,10, 2, 4, 6, 0, 0, 0}, 3*HZ/2, 7 }, "1.44M" }, /*3 1/2 HD*/
-
-{{5, 1000, 15, 8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 40, {3,1,2,0,2}, 0,
- 0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M AMI BIOS" }, /*3 1/2 ED*/
-
-{{6, 1000, 15, 8, 3000, 4*HZ/10, 3*HZ, 10, SEL_DLY, 5, 83, 3*HZ, 40, {3,1,2,0,2}, 0,
- 0, { 7, 8, 4,25,28,22,31,21}, 3*HZ/2, 8 }, "2.88M" } /*3 1/2 ED*/
-/* | --autodetected formats--- | | |
- * read_track | | Name printed when booting
- * | Native format
- * Frequency of disk change checks */
-};
-
-static struct floppy_drive_params drive_params[N_DRIVE];
-static struct floppy_drive_struct drive_state[N_DRIVE];
-static struct floppy_write_errors write_errors[N_DRIVE];
-static struct timer_list motor_off_timer[N_DRIVE];
-static struct gendisk *disks[N_DRIVE];
-static struct block_device *opened_bdev[N_DRIVE];
-static DECLARE_MUTEX(open_lock);
-static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
-
-/*
- * This struct defines the different floppy types.
- *
- * Bit 0 of 'stretch' tells if the tracks need to be doubled for some
- * types (e.g. 360kB diskette in 1.2MB drive, etc.). Bit 1 of 'stretch'
- * tells if the disk is in Commodore 1581 format, which means side 0 sectors
- * are located on side 1 of the disk but with a side 0 ID, and vice-versa.
- * This is the same as the Sharp MZ-80 5.25" CP/M disk format, except that the
- * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical
- * side 0 is on physical side 0 (but with the misnamed sector IDs).
- * 'stretch' should probably be renamed to something more general, like
- * 'options'. Other parameters should be self-explanatory (see also
- * setfdprm(8)).
- */
-/*
- Size
- | Sectors per track
- | | Head
- | | | Tracks
- | | | | Stretch
- | | | | | Gap 1 size
- | | | | | | Data rate, | 0x40 for perp
- | | | | | | | Spec1 (stepping rate, head unload
- | | | | | | | | /fmt gap (gap2) */
-static struct floppy_struct floppy_type[32] = {
- { 0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL }, /* 0 no testing */
-#if 0
- { 720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"d360" }, /* 1 360KB PC */
-#else
- { 2464,16,2,77,0,0x35,0x48,0xDF,0x74,"d360" }, /* 1 1.25MB 98 */
-#endif
- { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"h1200" }, /* 2 1.2MB AT */
- { 720, 9,1,80,0,0x2A,0x02,0xDF,0x50,"D360" }, /* 3 360KB SS 3.5" */
- { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"D720" }, /* 4 720KB 3.5" */
- { 720, 9,2,40,1,0x23,0x01,0xDF,0x50,"h360" }, /* 5 360KB AT */
- { 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,"h720" }, /* 6 720KB AT */
- { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"H1440" }, /* 7 1.44MB 3.5" */
- { 5760,36,2,80,0,0x1B,0x43,0xAF,0x54,"E2880" }, /* 8 2.88MB 3.5" */
- { 6240,39,2,80,0,0x1B,0x43,0xAF,0x28,"E3120" }, /* 9 3.12MB 3.5" */
-
- { 2880,18,2,80,0,0x25,0x00,0xDF,0x02,"h1440" }, /* 10 1.44MB 5.25" */
- { 3360,21,2,80,0,0x1C,0x00,0xCF,0x0C,"H1680" }, /* 11 1.68MB 3.5" */
- { 820,10,2,41,1,0x25,0x01,0xDF,0x2E,"h410" }, /* 12 410KB 5.25" */
- { 1640,10,2,82,0,0x25,0x02,0xDF,0x2E,"H820" }, /* 13 820KB 3.5" */
- { 2952,18,2,82,0,0x25,0x00,0xDF,0x02,"h1476" }, /* 14 1.48MB 5.25" */
- { 3444,21,2,82,0,0x25,0x00,0xDF,0x0C,"H1722" }, /* 15 1.72MB 3.5" */
- { 840,10,2,42,1,0x25,0x01,0xDF,0x2E,"h420" }, /* 16 420KB 5.25" */
- { 1660,10,2,83,0,0x25,0x02,0xDF,0x2E,"H830" }, /* 17 830KB 3.5" */
- { 2988,18,2,83,0,0x25,0x00,0xDF,0x02,"h1494" }, /* 18 1.49MB 5.25" */
- { 3486,21,2,83,0,0x25,0x00,0xDF,0x0C,"H1743" }, /* 19 1.74 MB 3.5" */
-
- { 1760,11,2,80,0,0x1C,0x09,0xCF,0x00,"h880" }, /* 20 880KB 5.25" */
- { 2080,13,2,80,0,0x1C,0x01,0xCF,0x00,"D1040" }, /* 21 1.04MB 3.5" */
- { 2240,14,2,80,0,0x1C,0x19,0xCF,0x00,"D1120" }, /* 22 1.12MB 3.5" */
- { 3200,20,2,80,0,0x1C,0x20,0xCF,0x2C,"h1600" }, /* 23 1.6MB 5.25" */
- { 3520,22,2,80,0,0x1C,0x08,0xCF,0x2e,"H1760" }, /* 24 1.76MB 3.5" */
- { 3840,24,2,80,0,0x1C,0x20,0xCF,0x00,"H1920" }, /* 25 1.92MB 3.5" */
- { 6400,40,2,80,0,0x25,0x5B,0xCF,0x00,"E3200" }, /* 26 3.20MB 3.5" */
- { 7040,44,2,80,0,0x25,0x5B,0xCF,0x00,"E3520" }, /* 27 3.52MB 3.5" */
- { 7680,48,2,80,0,0x25,0x63,0xCF,0x00,"E3840" }, /* 28 3.84MB 3.5" */
-
- { 3680,23,2,80,0,0x1C,0x10,0xCF,0x00,"H1840" }, /* 29 1.84MB 3.5" */
- { 1600,10,2,80,0,0x25,0x02,0xDF,0x2E,"D800" }, /* 30 800KB 3.5" */
- { 3200,20,2,80,0,0x1C,0x00,0xCF,0x2C,"H1600" }, /* 31 1.6MB 3.5" */
-};
-
-#define NUMBER(x) (sizeof(x) / sizeof(*(x)))
-#define SECTSIZE (_FD_SECTSIZE(*floppy))
-
-/* Auto-detection: Disk type used until the next media change occurs. */
-static struct floppy_struct *current_type[N_DRIVE];
-
-/*
- * User-provided type information. current_type points to
- * the respective entry of this array.
- */
-static struct floppy_struct user_params[N_DRIVE];
-
-static sector_t floppy_sizes[256];
-
-/*
- * The driver is trying to determine the correct media format
- * while probing is set. rw_interrupt() clears it after a
- * successful access.
- */
-static int probing;
-
-/* Synchronization of FDC access. */
-#define FD_COMMAND_NONE -1
-#define FD_COMMAND_ERROR 2
-#define FD_COMMAND_OKAY 3
-
-static volatile int command_status = FD_COMMAND_NONE;
-static unsigned long fdc_busy;
-static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
-static DECLARE_WAIT_QUEUE_HEAD(command_done);
-
-#define NO_SIGNAL (!interruptible || !signal_pending(current))
-#define CALL(x) if ((x) == -EINTR) return -EINTR
-#define ECALL(x) if ((ret = (x))) return ret;
-#define _WAIT(x,i) CALL(ret=wait_til_done((x),i))
-#define WAIT(x) _WAIT((x),interruptible)
-#define IWAIT(x) _WAIT((x),1)
-
-/* Errors during formatting are counted here. */
-static int format_errors;
-
-/* Format request descriptor. */
-static struct format_descr format_req;
-
-/*
- * Rate is 0 for 500kb/s, 1 for 300kbps, 2 for 250kbps
- * Spec1 is 0xSH, where S is stepping rate (F=1ms, E=2ms, D=3ms etc),
- * H is head unload time (1=16ms, 2=32ms, etc)
- */
-
-/*
- * Track buffer
- * Because these are written to by the DMA controller, they must
- * not contain a 64k byte boundary crossing, or data will be
- * corrupted/lost.
- */
-static char *floppy_track_buffer;
-static int max_buffer_sectors;
-
-static int *errors;
-typedef void (*done_f)(int);
-static struct cont_t {
- void (*interrupt)(void); /* this is called after the interrupt of the
- * main command */
- void (*redo)(void); /* this is called to retry the operation */
- void (*error)(void); /* this is called to tally an error */
- done_f done; /* this is called to say if the operation has
- * succeeded/failed */
-} *cont;
-
-static void floppy_ready(void);
-static void floppy_start(void);
-static void process_fd_request(void);
-static void recalibrate_floppy(void);
-static void floppy_shutdown(unsigned long);
-
-static int floppy_grab_irq_and_dma(void);
-static void floppy_release_irq_and_dma(void);
-
-/*
- * The "reset" variable should be tested whenever an interrupt is scheduled,
- * after the commands have been sent. This is to ensure that the driver doesn't
- * get wedged when the interrupt doesn't come because of a failed command.
- * reset doesn't need to be tested before sending commands, because
- * output_byte is automatically disabled when reset is set.
- */
-#define CHECK_RESET { if (FDCS->reset){ reset_fdc(); return; } }
-static void reset_fdc(void);
-
-/*
- * These are global variables, as that's the easiest way to give
- * information to interrupts. They are the data used for the current
- * request.
- */
-#define NO_TRACK -1
-#define NEED_1_RECAL -2
-#define NEED_2_RECAL -3
-
-static int usage_count;
-
-/* buffer related variables */
-static int buffer_track = -1;
-static int buffer_drive = -1;
-static int buffer_min = -1;
-static int buffer_max = -1;
-
-/* fdc related variables, should end up in a struct */
-static struct floppy_fdc_state fdc_state[N_FDC];
-static int fdc; /* current fdc */
-
-static struct floppy_struct *_floppy = floppy_type;
-static unsigned char current_drive;
-static long current_count_sectors;
-static unsigned char fsector_t; /* sector in track */
-static unsigned char in_sector_offset; /* offset within physical sector,
- * expressed in units of 512 bytes */
-
-#ifndef fd_eject
-static inline int fd_eject(int drive)
-{
- return -EINVAL;
-}
-#endif
-
-#ifdef DEBUGT
-static long unsigned debugtimer;
-#endif
-
-/*
- * Debugging
- * =========
- */
-static inline void set_debugt(void)
-{
-#ifdef DEBUGT
- debugtimer = jiffies;
-#endif
-}
-
-static inline void debugt(const char *message)
-{
-#ifdef DEBUGT
- if (DP->flags & DEBUGT)
- printk("%s dtime=%lu\n", message, jiffies-debugtimer);
-#endif
-}
-
-typedef void (*timeout_fn)(unsigned long);
-static struct timer_list fd_timeout = TIMER_INITIALIZER(floppy_shutdown, 0, 0);
-
-static const char *timeout_message;
-
-#ifdef FLOPPY_SANITY_CHECK
-static void is_alive(const char *message)
-{
- /* this routine checks whether the floppy driver is "alive" */
- if (fdc_busy && command_status < 2 && !timer_pending(&fd_timeout)){
- DPRINT("timeout handler died: %s\n",message);
- }
-}
-#endif
-
-static void (*do_floppy)(void) = NULL;
-
-#ifdef FLOPPY_SANITY_CHECK
-
-#define OLOGSIZE 20
-
-static void (*lasthandler)(void);
-static unsigned long interruptjiffies;
-static unsigned long resultjiffies;
-static int resultsize;
-static unsigned long lastredo;
-
-static struct output_log {
- unsigned char data;
- unsigned char status;
- unsigned long jiffies;
-} output_log[OLOGSIZE];
-
-static int output_log_pos;
-#endif
-
-#define current_reqD -1
-#define MAXTIMEOUT -2
-
-static void reschedule_timeout(int drive, const char *message, int marg)
-{
- unsigned long delay;
-
- if (drive == current_reqD)
- drive = current_drive;
- if (drive < 0 || drive > N_DRIVE) {
- delay = 20UL*HZ;
- drive=0;
- } else
- delay = UDP->timeout;
- mod_timer(&fd_timeout, delay + jiffies);
- if (UDP->flags & FD_DEBUG){
- DPRINT("reschedule timeout ");
- printk(message, marg);
- printk("\n");
- }
- timeout_message = message;
-}
-
-static int maximum(int a, int b)
-{
- if (a > b)
- return a;
- else
- return b;
-}
-#define INFBOUND(a,b) (a)=maximum((a),(b));
-
-static int minimum(int a, int b)
-{
- if (a < b)
- return a;
- else
- return b;
-}
-#define SUPBOUND(a,b) (a)=minimum((a),(b));
-
-
-/*
- * Bottom half floppy driver.
- * ==========================
- *
- * This part of the file contains the code talking directly to the hardware,
- * and also the main service loop (seek-configure-spinup-command)
- */
-
-/*
- * disk change.
- * This routine is responsible for maintaining the FD_DISK_CHANGE flag,
- * and the last_checked date.
- *
- * last_checked is the date of the last check which showed 'no disk change'
- * FD_DISK_CHANGE is set under two conditions:
- * 1. The floppy has been changed after some i/o to that floppy already
- * took place.
- * 2. No floppy disk is in the drive. This is done in order to ensure that
- * requests are quickly flushed in case there is no disk in the drive. It
- * follows that FD_DISK_CHANGE can only be cleared if there is a disk in
- * the drive.
- *
- * For 1., maxblock is observed. Maxblock is 0 if no i/o has taken place yet.
- * For 2., FD_DISK_NEWCHANGE is watched. FD_DISK_NEWCHANGE is cleared on
- * each seek. If a disk is present, the disk change line should also be
- * cleared on each seek. Thus, if FD_DISK_NEWCHANGE is clear, but the disk
- * change line is set, this means either that no disk is in the drive, or
- * that it has been removed since the last seek.
- *
- * This means that we really have a third possibility too:
- * The floppy has been changed after the last seek.
- */
-
-static int disk_change(int drive)
-{
- return UTESTF(FD_DISK_CHANGED);
-}
-
-static int set_mode(char mask, char data)
-{
- register unsigned char newdor, olddor;
-
- olddor = FDCS->dor;
- newdor = (olddor & mask) | data;
- if (newdor != olddor) {
- FDCS->dor = newdor;
- fd_outb(newdor, FD_MODE);
- }
-
- if (newdor & FLOPPY98_MOTOR_MASK)
- floppy_grab_irq_and_dma();
-
- if (olddor & FLOPPY98_MOTOR_MASK)
- floppy_release_irq_and_dma();
-
- return olddor;
-}
-
-static void twaddle(void)
-{
- if (DP->select_delay)
- return;
-
- fd_outb(FDCS->dor & 0xf7, FD_MODE);
- fd_outb(FDCS->dor, FD_MODE);
- DRS->select_date = jiffies;
-}
-
-/* reset all driver information about the current fdc. This is needed after
- * a reset, and after a raw command. */
-static void reset_fdc_info(int mode)
-{
- int drive;
-
- FDCS->spec1 = FDCS->spec2 = -1;
- FDCS->need_configure = 1;
- FDCS->perp_mode = 1;
- FDCS->rawcmd = 0;
- for (drive = 0; drive < N_DRIVE; drive++)
- if (FDC(drive) == fdc &&
- (mode || UDRS->track != NEED_1_RECAL))
- UDRS->track = NEED_2_RECAL;
-}
-
-/* selects the fdc and drive, and enables the fdc's input/dma. */
-static void set_fdc(int drive)
-{
- fdc = 0;
- current_drive = drive;
- set_mode(~0, 0x10);
- if (FDCS->rawcmd == 2)
- reset_fdc_info(1);
-
- if (fd_inb(FD98_STATUS) != STATUS_READY)
- FDCS->reset = 1;
-}
-
-/* locks the driver */
-static int _lock_fdc(int drive, int interruptible, int line)
-{
- if (!usage_count){
- printk(KERN_ERR "Trying to lock fdc while usage count=0 at line %d\n", line);
- return -1;
- }
- if(floppy_grab_irq_and_dma()==-1)
- return -EBUSY;
-
- if (test_and_set_bit(0, &fdc_busy)) {
- DECLARE_WAITQUEUE(wait, current);
- add_wait_queue(&fdc_wait, &wait);
-
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
-
- if (!test_and_set_bit(0, &fdc_busy))
- break;
-
- schedule();
-
- if (!NO_SIGNAL) {
- remove_wait_queue(&fdc_wait, &wait);
- return -EINTR;
- }
- }
-
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&fdc_wait, &wait);
- }
- command_status = FD_COMMAND_NONE;
-
- reschedule_timeout(drive, "lock fdc", 0);
- set_fdc(drive);
- return 0;
-}
-
-#define lock_fdc(drive,interruptible) _lock_fdc(drive,interruptible, __LINE__)
-
-#define LOCK_FDC(drive,interruptible) \
-if (lock_fdc(drive,interruptible)) return -EINTR;
-
-
-/* unlocks the driver */
-static inline void unlock_fdc(void)
-{
- raw_cmd = 0;
- if (!fdc_busy)
- DPRINT("FDC access conflict!\n");
-
- if (do_floppy)
- DPRINT("device interrupt still active at FDC release: %p!\n",
- do_floppy);
- command_status = FD_COMMAND_NONE;
- del_timer(&fd_timeout);
- cont = NULL;
- clear_bit(0, &fdc_busy);
- floppy_release_irq_and_dma();
- wake_up(&fdc_wait);
-}
-
-#ifndef CONFIG_PC9800_MOTOR_OFF /* tomita */
-
-/* switches the motor off after a given timeout */
-static void motor_off_callback(unsigned long nr)
-{
- printk(KERN_DEBUG "fdc%lu: turn off motor\n", nr);
-}
-
-/* schedules motor off */
-static void floppy_off(unsigned int drive)
-{
-}
-
-#else /* CONFIG_PC9800_MOTOR_OFF */
-
-/* switches the motor off after a given timeout */
-static void motor_off_callback(unsigned long fdc)
-{
- printk(KERN_DEBUG "fdc%u: turn off motor\n", (unsigned int) fdc);
-
- fd_outb(0, FD_MODE); /* MTON = 0 */
-}
-
-static struct timer_list motor_off_timer[N_FDC] = {
- { data: 0, function: motor_off_callback },
-#if N_FDC > 1
- { data: 1, function: motor_off_callback },
-#endif
-#if N_FDC > 2
-# error "N_FDC > 2; please fix initializer for motor_off_timer[]"
-#endif
-};
-
-/* schedules motor off */
-static void floppy_off(unsigned int drive)
-{
- unsigned long volatile delta;
- register int fdc = FDC(drive);
-
- if (!(FDCS->dor & (0x10 << UNIT(drive))))
- return;
-
- del_timer(motor_off_timer + fdc);
-
-#if 0
- /* make spindle stop in a position which minimizes spinup time
- * next time */
- if (UDP->rps){
- delta = jiffies - UDRS->first_read_date + HZ -
- UDP->spindown_offset;
- delta = ((delta * UDP->rps) % HZ) / UDP->rps;
- motor_off_timer[drive].expires = jiffies + UDP->spindown - delta;
- }
-#else
- if (UDP->rps)
- motor_off_timer[drive].expires = jiffies + UDP->spindown;
-#endif
-
- add_timer(motor_off_timer + fdc);
-}
-
-#endif /* CONFIG_PC9800_MOTOR_OFF */
-
-/*
- * cycle through all N_DRIVE floppy drives, for disk change testing.
- * stopping at current drive. This is done before any long operation, to
- * be sure to have up to date disk change information.
- */
-static void scandrives(void)
-{
- int i, drive, saved_drive;
-
- if (DP->select_delay)
- return;
-
- saved_drive = current_drive;
- for (i=0; i < N_DRIVE; i++){
- drive = (saved_drive + i + 1) % N_DRIVE;
- if (UDRS->fd_ref == 0 || UDP->select_delay != 0)
- continue; /* skip closed drives */
- set_fdc(drive);
- }
- set_fdc(saved_drive);
-}
-
-static void empty(void)
-{
-}
-
-static DECLARE_WORK(floppy_work, NULL, NULL);
-
-static void schedule_bh(void (*handler) (void))
-{
- PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
- schedule_work(&floppy_work);
-}
-
-static struct timer_list fd_timer = TIMER_INITIALIZER(NULL, 0, 0);
-
-static void cancel_activity(void)
-{
- do_floppy = NULL;
- PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL);
- del_timer(&fd_timer);
-}
-
-/* this function makes sure that the disk stays in the drive during the
- * transfer */
-static void fd_watchdog(void)
-{
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("calling disk change from watchdog\n");
- }
-#endif
-
- if (disk_change(current_drive)){
- DPRINT("disk removed during i/o\n");
- cancel_activity();
- cont->done(0);
- reset_fdc();
- } else {
- del_timer(&fd_timer);
- fd_timer.function = (timeout_fn) fd_watchdog;
- fd_timer.expires = jiffies + HZ / 10;
- add_timer(&fd_timer);
- }
-}
-
-static void main_command_interrupt(void)
-{
- del_timer(&fd_timer);
- cont->interrupt();
-}
-
-/* waits for a delay (spinup or select) to pass */
-static int fd_wait_for_completion(unsigned long delay, timeout_fn function)
-{
- if (FDCS->reset){
- reset_fdc(); /* do the reset during sleep to win time
- * if we don't need to sleep, it's a good
- * occasion anyways */
- return 1;
- }
-
- if ((signed) (jiffies - delay) < 0){
- del_timer(&fd_timer);
- fd_timer.function = function;
- fd_timer.expires = delay;
- add_timer(&fd_timer);
- return 1;
- }
- return 0;
-}
-
-static spinlock_t floppy_hlt_lock = SPIN_LOCK_UNLOCKED;
-static int hlt_disabled;
-static void floppy_disable_hlt(void)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&floppy_hlt_lock, flags);
- if (!hlt_disabled) {
- hlt_disabled=1;
-#ifdef HAVE_DISABLE_HLT
- disable_hlt();
-#endif
- }
- spin_unlock_irqrestore(&floppy_hlt_lock, flags);
-}
-
-static void floppy_enable_hlt(void)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&floppy_hlt_lock, flags);
- if (hlt_disabled){
- hlt_disabled=0;
-#ifdef HAVE_DISABLE_HLT
- enable_hlt();
-#endif
- }
- spin_unlock_irqrestore(&floppy_hlt_lock, flags);
-}
-
-
-static void setup_DMA(void)
-{
- unsigned long f;
-
-#ifdef FLOPPY_SANITY_CHECK
- if (raw_cmd->length == 0){
- int i;
-
- printk("zero dma transfer size:");
- for (i=0; i < raw_cmd->cmd_count; i++)
- printk("%x,", raw_cmd->cmd[i]);
- printk("\n");
- cont->done(0);
- FDCS->reset = 1;
- return;
- }
- if (((unsigned long) raw_cmd->kernel_data) % 512){
- printk("non aligned address: %p\n", raw_cmd->kernel_data);
- cont->done(0);
- FDCS->reset=1;
- return;
- }
-#endif
- f=claim_dma_lock();
- fd_disable_dma();
-#ifdef fd_dma_setup
- if (fd_dma_setup(raw_cmd->kernel_data, raw_cmd->length,
- (raw_cmd->flags & FD_RAW_READ)?
- DMA_MODE_READ : DMA_MODE_WRITE,
- FDCS->address) < 0) {
- release_dma_lock(f);
- cont->done(0);
- FDCS->reset=1;
- return;
- }
- release_dma_lock(f);
-#else
- fd_clear_dma_ff();
- fd_cacheflush(raw_cmd->kernel_data, raw_cmd->length);
- fd_set_dma_mode((raw_cmd->flags & FD_RAW_READ)?
- DMA_MODE_READ : DMA_MODE_WRITE);
- fd_set_dma_addr(raw_cmd->kernel_data);
- fd_set_dma_count(raw_cmd->length);
- virtual_dma_port = FDCS->address;
- fd_enable_dma();
- release_dma_lock(f);
-#endif
- floppy_disable_hlt();
-}
-
-static void show_floppy(void);
-
-/* waits until the fdc becomes ready */
-
-#ifdef PC9800_DEBUG_FLOPPY
-#define READY_DELAY 10000000
-#else
-#define READY_DELAY 100000
-#endif
-
-static int wait_til_ready(void)
-{
- int counter, status;
- if (FDCS->reset)
- return -1;
- for (counter = 0; counter < READY_DELAY; counter++) {
- status = fd_inb(FD98_STATUS);
- if (status & STATUS_READY)
- return status;
- }
- if (!initialising) {
- DPRINT("Getstatus times out (%x) on fdc %d\n",
- status, fdc);
- show_floppy();
- }
- FDCS->reset = 1;
- return -1;
-}
-
-/* sends a command byte to the fdc */
-static int output_byte(char byte)
-{
- int status;
-
- if ((status = wait_til_ready()) < 0)
- return -1;
- if ((status & (STATUS_READY|STATUS_DIR|STATUS_DMA)) == STATUS_READY){
- fd_outb(byte,FD98_DATA);
-#ifdef FLOPPY_SANITY_CHECK
- output_log[output_log_pos].data = byte;
- output_log[output_log_pos].status = status;
- output_log[output_log_pos].jiffies = jiffies;
- output_log_pos = (output_log_pos + 1) % OLOGSIZE;
-#endif
- return 0;
- }
- FDCS->reset = 1;
- if (!initialising) {
- DPRINT("Unable to send byte %x to FDC. Fdc=%x Status=%x\n",
- byte, fdc, status);
- show_floppy();
- }
- return -1;
-}
-#define LAST_OUT(x) if (output_byte(x)<0){ reset_fdc();return;}
-
-/* gets the response from the fdc */
-static int result(void)
-{
- int i, status=0;
-
- for(i=0; i < MAX_REPLIES; i++) {
- if ((status = wait_til_ready()) < 0)
- break;
- status &= STATUS_DIR|STATUS_READY|STATUS_BUSY|STATUS_DMA;
- if ((status & ~STATUS_BUSY) == STATUS_READY){
-#ifdef FLOPPY_SANITY_CHECK
- resultjiffies = jiffies;
- resultsize = i;
-#endif
- return i;
- }
- if (status == (STATUS_DIR|STATUS_READY|STATUS_BUSY))
- reply_buffer[i] = fd_inb(FD98_DATA);
- else
- break;
- }
- if (!initialising) {
- DPRINT("get result error. Fdc=%d Last status=%x Read bytes=%d\n",
- fdc, status, i);
- show_floppy();
- }
- FDCS->reset = 1;
- return -1;
-}
-
-static int fifo_depth = 0xa;
-static int no_fifo;
-
-#define NOMINAL_DTR 500
-
-/* Issue a "SPECIFY" command to set the step rate time, head unload time,
- * head load time, and DMA disable flag to values needed by floppy.
- *
- * The value "dtr" is the data transfer rate in Kbps. It is needed
- * to account for the data rate-based scaling done by the 82072 and 82077
- * FDC types. This parameter is ignored for other types of FDCs (i.e.
- * 8272a).
- *
- * Note that changing the data transfer rate has a (probably deleterious)
- * effect on the parameters subject to scaling for 82072/82077 FDCs, so
- * fdc_specify is called again after each data transfer rate
- * change.
- *
- * srt: 1000 to 16000 in microseconds
- * hut: 16 to 240 milliseconds
- * hlt: 2 to 254 milliseconds
- *
- * These values are rounded up to the next highest available delay time.
- */
-static void fdc_specify(void)
-{
- output_byte(FD_SPECIFY);
- output_byte(FDCS->spec1 = 0xdf);
- output_byte(FDCS->spec2 = 0x24);
-}
-
-static void tell_sector(void)
-{
- printk(": track %d, head %d, sector %d, size %d",
- R_TRACK, R_HEAD, R_SECTOR, R_SIZECODE);
-} /* tell_sector */
-
-static int auto_detect_mode_pc9800(void)
-{
-#ifdef PC9800_DEBUG_FLOPPY
- printk("auto_detect_mode_pc9800: retry_auto_detect=%d\n",
- retry_auto_detect);
-#endif
- if (retry_auto_detect > 4) {
- retry_auto_detect = 0;
- return 1;
- }
-
- switch ((int)(_floppy - floppy_type)) {
- case 2:
- _floppy = floppy_type + 4;
- break;
-
- case 4:
- case 6:
- _floppy = floppy_type + 7;
- break;
-
- case 7:
- case 10:
- _floppy = floppy_type + 2;
- break;
-
- default:
- _floppy = floppy_type + 7;
- }
-
- retry_auto_detect++;
- return 0;
-}
-
-static void access_mode_change_pc9800(void);
-
-/*
- * OK, this error interpreting routine is called after a
- * DMA read/write has succeeded
- * or failed, so we check the results, and copy any buffers.
- * hhb: Added better error reporting.
- * ak: Made this into a separate routine.
- */
-static int interpret_errors(void)
-{
- char bad;
-
- if (inr!=7) {
- DPRINT("-- FDC reply error");
- FDCS->reset = 1;
- return 1;
- }
-
- /* check IC to find cause of interrupt */
- switch (ST0 & ST0_INTR) {
- case 0x40: /* error occurred during command execution */
- if (ST1 & ST1_EOC)
- return 0; /* occurs with pseudo-DMA */
- bad = 1;
- if (ST1 & ST1_WP) {
- DPRINT("Drive is write protected\n");
- CLEARF(FD_DISK_WRITABLE);
- cont->done(0);
- bad = 2;
- } else if (ST1 & ST1_ND) {
- SETF(FD_NEED_TWADDLE);
- } else if (ST1 & ST1_OR) {
- if (DP->flags & FTD_MSG)
- DPRINT("Over/Underrun - retrying\n");
- bad = 0;
- }else if (*errors >= DP->max_errors.reporting){
- if (ST0 & ST0_ECE) {
- printk("Recalibrate failed!");
- } else if (ST2 & ST2_CRC) {
- printk("data CRC error");
- tell_sector();
- } else if (ST1 & ST1_CRC) {
- printk("CRC error");
- tell_sector();
- } else if ((ST1 & (ST1_MAM|ST1_ND)) || (ST2 & ST2_MAM)) {
- if (auto_detect_mode) {
- bad = (char)auto_detect_mode_pc9800();
- access_mode_change_pc9800();
- }
-
- if (bad) {
- printk("floppy error: MA: _floppy - floppy_type=%d\n", (int)(_floppy - floppy_type));
- printk("bad=%d\n", (int)bad);
- if (!probing) {
- printk("sector not found");
- tell_sector();
- } else
- printk("probe failed...");
- }
- } else if (ST2 & ST2_WC) { /* seek error */
- printk("wrong cylinder");
- } else if (ST2 & ST2_BC) { /* cylinder marked as bad */
- printk("bad cylinder");
- } else {
- printk("unknown error. ST[0..2] are: 0x%x 0x%x 0x%x", ST0, ST1, ST2);
- tell_sector();
- }
- printk("\n");
-
- }
- if (ST2 & ST2_WC || ST2 & ST2_BC)
- /* wrong cylinder => recal */
- DRS->track = NEED_2_RECAL;
- return bad;
- case 0x80: /* invalid command given */
- DPRINT("Invalid FDC command given!\n");
- cont->done(0);
- return 2;
- case 0xc0:
- SETF(FD_DISK_CHANGED);
- SETF(FD_DISK_WRITABLE);
- DPRINT("Abnormal termination caused by polling\n");
- cont->error();
- return 2;
- default: /* (0) Normal command termination */
- auto_detect_mode = 0;
- return 0;
- }
-}
-
-/*
- * This routine is called when everything should be correctly set up
- * for the transfer (i.e. floppy motor is on, the correct floppy is
- * selected, and the head is sitting on the right track).
- */
-static void setup_rw_floppy(void)
-{
- int i,r, flags,dflags;
- unsigned long ready_date;
- timeout_fn function;
-
- access_mode_change_pc9800();
- flags = raw_cmd->flags;
- if (flags & (FD_RAW_READ | FD_RAW_WRITE))
- flags |= FD_RAW_INTR;
-
- if ((flags & FD_RAW_SPIN) && !(flags & FD_RAW_NO_MOTOR)){
- ready_date = DRS->spinup_date + DP->spinup;
- /* If spinup will take a long time, rerun scandrives
- * again just before spinup completion. Beware that
- * after scandrives, we must again wait for selection.
- */
- if ((signed) (ready_date - jiffies) > DP->select_delay){
- ready_date -= DP->select_delay;
- function = (timeout_fn) floppy_start;
- } else
- function = (timeout_fn) setup_rw_floppy;
-
- /* wait until the floppy is spinning fast enough */
- if (fd_wait_for_completion(ready_date,function))
- return;
- }
- dflags = DRS->flags;
-
- if ((flags & FD_RAW_READ) || (flags & FD_RAW_WRITE))
- setup_DMA();
-
- if (flags & FD_RAW_INTR)
- do_floppy = main_command_interrupt;
-
- r=0;
- for (i=0; i< raw_cmd->cmd_count; i++)
- r|=output_byte(raw_cmd->cmd[i]);
-
-#ifdef DEBUGT
- debugt("rw_command: ");
-#endif
- if (r){
- cont->error();
- reset_fdc();
- return;
- }
-
- if (!(flags & FD_RAW_INTR)){
- inr = result();
- cont->interrupt();
- } else if (flags & FD_RAW_NEED_DISK)
- fd_watchdog();
-}
-
-static int blind_seek;
-
-/*
- * This is the routine called after every seek (or recalibrate) interrupt
- * from the floppy controller.
- */
-static void seek_interrupt(void)
-{
-#ifdef DEBUGT
- debugt("seek interrupt:");
-#endif
- if (inr != 2 || (ST0 & 0xF8) != 0x20) {
- DRS->track = NEED_2_RECAL;
- cont->error();
- cont->redo();
- return;
- }
- if (DRS->track >= 0 && DRS->track != ST1 && !blind_seek){
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("clearing NEWCHANGE flag because of effective seek\n");
- DPRINT("jiffies=%lu\n", jiffies);
- }
-#endif
- CLEARF(FD_DISK_NEWCHANGE); /* effective seek */
- CLEARF(FD_DISK_CHANGED); /* effective seek */
- DRS->select_date = jiffies;
- }
- DRS->track = ST1;
- floppy_ready();
-}
-
-static void check_wp(void)
-{
- if (TESTF(FD_VERIFY)) {
- /* check write protection */
- output_byte(FD_GETSTATUS);
- output_byte(UNIT(current_drive));
- if (result() != 1){
- FDCS->reset = 1;
- return;
- }
- CLEARF(FD_VERIFY);
- CLEARF(FD_NEED_TWADDLE);
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("checking whether disk is write protected\n");
- DPRINT("wp=%x\n",ST3 & 0x40);
- }
-#endif
- if (!(ST3 & 0x40))
- SETF(FD_DISK_WRITABLE);
- else
- CLEARF(FD_DISK_WRITABLE);
- }
-}
-
-static void seek_floppy(void)
-{
- int track;
-
- blind_seek=0;
-
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("calling disk change from seek\n");
- }
-#endif
-
- if (!TESTF(FD_DISK_NEWCHANGE) &&
- disk_change(current_drive) &&
- (raw_cmd->flags & FD_RAW_NEED_DISK)){
- /* the media changed flag should be cleared after the seek.
- * If it isn't, this means that there is really no disk in
- * the drive.
- */
- SETF(FD_DISK_CHANGED);
- cont->done(0);
- cont->redo();
- return;
- }
- if (DRS->track <= NEED_1_RECAL){
- recalibrate_floppy();
- return;
- } else if (TESTF(FD_DISK_NEWCHANGE) &&
- (raw_cmd->flags & FD_RAW_NEED_DISK) &&
- (DRS->track <= NO_TRACK || DRS->track == raw_cmd->track)) {
- /* we seek to clear the media-changed condition. Does anybody
- * know a more elegant way, which works on all drives? */
- if (raw_cmd->track)
- track = raw_cmd->track - 1;
- else {
- if (DP->flags & FD_SILENT_DCL_CLEAR){
- blind_seek = 1;
- raw_cmd->flags |= FD_RAW_NEED_SEEK;
- }
- track = 1;
- }
- } else {
- check_wp();
- if (raw_cmd->track != DRS->track &&
- (raw_cmd->flags & FD_RAW_NEED_SEEK))
- track = raw_cmd->track;
- else {
- setup_rw_floppy();
- return;
- }
- }
-
- do_floppy = seek_interrupt;
- output_byte(FD_SEEK);
- output_byte(UNIT(current_drive));
- LAST_OUT(track);
-#ifdef DEBUGT
- debugt("seek command:");
-#endif
-}
-
-static void recal_interrupt(void)
-{
-#ifdef DEBUGT
- debugt("recal interrupt:");
-#endif
- if (inr !=2)
- FDCS->reset = 1;
- else if (ST0 & ST0_ECE) {
- switch(DRS->track){
- case NEED_1_RECAL:
-#ifdef DEBUGT
- debugt("recal interrupt need 1 recal:");
-#endif
- /* after a second recalibrate, we still haven't
- * reached track 0. Probably no drive. Raise an
- * error, as failing immediately might upset
- * computers possessed by the Devil :-) */
- cont->error();
- cont->redo();
- return;
- case NEED_2_RECAL:
-#ifdef DEBUGT
- debugt("recal interrupt need 2 recal:");
-#endif
- /* If we already did a recalibrate,
- * and we are not at track 0, this
- * means we have moved. (The only way
- * not to move at recalibration is to
- * be already at track 0.) Clear the
- * new change flag */
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("clearing NEWCHANGE flag because of second recalibrate\n");
- }
-#endif
-
- CLEARF(FD_DISK_NEWCHANGE);
- DRS->select_date = jiffies;
- /* fall through */
- default:
-#ifdef DEBUGT
- debugt("recal interrupt default:");
-#endif
- /* Recalibrate moves the head by at
- * most 80 steps. If after one
- * recalibrate we don't have reached
- * track 0, this might mean that we
- * started beyond track 80. Try
- * again. */
- DRS->track = NEED_1_RECAL;
- break;
- }
- } else
- DRS->track = ST1;
- floppy_ready();
-}
-
-static void print_result(char *message, int inr)
-{
- int i;
-
- DPRINT("%s ", message);
- if (inr >= 0)
- for (i=0; i<inr; i++)
- printk("repl[%d]=%x ", i, reply_buffer[i]);
- printk("\n");
-}
-
-/* interrupt handler. Note that this can be called externally on the Sparc */
-irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
-{
- void (*handler)(void) = do_floppy;
- int do_print;
- unsigned long f;
-
- lasthandler = handler;
- interruptjiffies = jiffies;
-
- f=claim_dma_lock();
- fd_disable_dma();
- release_dma_lock(f);
-
- floppy_enable_hlt();
- do_floppy = NULL;
- if (fdc >= N_FDC || FDCS->address == -1){
- /* we don't even know which FDC is the culprit */
- printk("DOR0=%x\n", fdc_state[0].dor);
- printk("floppy interrupt on bizarre fdc %d\n",fdc);
- printk("handler=%p\n", handler);
- is_alive("bizarre fdc");
- return IRQ_NONE;
- }
-
- FDCS->reset = 0;
- /* We have to clear the reset flag here, because apparently on boxes
- * with level triggered interrupts (PS/2, Sparc, ...), it is needed to
- * emit SENSEI's to clear the interrupt line. And FDCS->reset blocks the
- * emission of the SENSEI's.
- * It is OK to emit floppy commands because we are in an interrupt
- * handler here, and thus we have to fear no interference of other
- * activity.
- */
-
- do_print = !handler && print_unex && !initialising;
-
- inr = result();
- if (inr && do_print)
- print_result("unexpected interrupt", inr);
- if (inr == 0){
- do {
- output_byte(FD_SENSEI);
- inr = result();
- if ((ST0 & ST0_INTR) == 0xC0) {
- int drive = ST0 & ST0_DS;
-
- /* Attention Interrupt. */
- if (ST0 & ST0_NR) {
-#ifdef PC9800_DEBUG_FLOPPY
- if (do_print)
- printk(KERN_DEBUG
- "floppy debug: floppy ejected (drive %d)\n",
- drive);
-#endif
- USETF(FD_DISK_CHANGED);
- USETF(FD_VERIFY);
- } else {
-#ifdef PC9800_DEBUG_FLOPPY
- if (do_print)
- printk(KERN_DEBUG
- "floppy debug: floppy inserted (drive %d)\n",
- drive);
-#endif
- }
- } /* Attention Interrupt */
-#ifdef PC9800_DEBUG_FLOPPY
- else {
- printk(KERN_DEBUG
- "floppy debug : unknown interrupt\n");
- }
-#endif
- } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2);
- }
- if (handler) {
- schedule_bh(handler);
- } else {
-#if 0
- FDCS->reset = 1;
-#endif
- }
- is_alive("normal interrupt end");
-
- /* FIXME! Was it really for us? */
- return IRQ_HANDLED;
-}
-
-static void recalibrate_floppy(void)
-{
-#ifdef DEBUGT
- debugt("recalibrate floppy:");
-#endif
- do_floppy = recal_interrupt;
- output_byte(FD_RECALIBRATE);
- LAST_OUT(UNIT(current_drive));
-}
-
-/*
- * Must do 4 FD_SENSEIs after reset because of ``drive polling''.
- */
-static void reset_interrupt(void)
-{
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy debug: reset interrupt\n");
-#endif
-#ifdef DEBUGT
- debugt("reset interrupt:");
-#endif
- result(); /* get the status ready for set_fdc */
- if (FDCS->reset) {
- printk("reset set in interrupt, calling %p\n", cont->error);
- cont->error(); /* a reset just after a reset. BAD! */
- }
- cont->redo();
-}
-
-/*
- * reset is done by pulling bit 2 of DOR low for a while (old FDCs),
- * or by setting the self clearing bit 7 of STATUS (newer FDCs)
- */
-static void reset_fdc(void)
-{
- unsigned long flags;
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy debug: reset_fdc\n");
-#endif
-
- do_floppy = reset_interrupt;
- FDCS->reset = 0;
- reset_fdc_info(0);
-
- /* Pseudo-DMA may intercept 'reset finished' interrupt. */
- /* Irrelevant for systems with true DMA (i386). */
-
- flags=claim_dma_lock();
- fd_disable_dma();
- release_dma_lock(flags);
-
- fd_outb(FDCS->dor | 0x80, FD_MODE);
- udelay(FD_RESET_DELAY);
- fd_outb(FDCS->dor, FD_MODE);
- udelay(FD_AFTER_RESET_DELAY);
-}
-
-static void show_floppy(void)
-{
- int i;
-
- printk("\n");
- printk("floppy driver state\n");
- printk("-------------------\n");
- printk("now=%lu last interrupt=%lu diff=%lu last called handler=%p\n",
- jiffies, interruptjiffies, jiffies-interruptjiffies, lasthandler);
-
-
-#ifdef FLOPPY_SANITY_CHECK
- printk("timeout_message=%s\n", timeout_message);
- printk("last output bytes:\n");
- for (i=0; i < OLOGSIZE; i++)
- printk("%2x %2x %lu\n",
- output_log[(i+output_log_pos) % OLOGSIZE].data,
- output_log[(i+output_log_pos) % OLOGSIZE].status,
- output_log[(i+output_log_pos) % OLOGSIZE].jiffies);
- printk("last result at %lu\n", resultjiffies);
- printk("last redo_fd_request at %lu\n", lastredo);
- for (i=0; i<resultsize; i++){
- printk("%2x ", reply_buffer[i]);
- }
- printk("\n");
-#endif
-
- printk("status=%x\n", fd_inb(FD98_STATUS));
- printk("fdc_busy=%lu\n", fdc_busy);
- if (do_floppy)
- printk("do_floppy=%p\n", do_floppy);
- if (floppy_work.pending)
- printk("floppy_work.func=%p\n", floppy_work.func);
- if (timer_pending(&fd_timer))
- printk("fd_timer.function=%p\n", fd_timer.function);
- if (timer_pending(&fd_timeout)){
- printk("timer_function=%p\n",fd_timeout.function);
- printk("expires=%lu\n",fd_timeout.expires-jiffies);
- printk("now=%lu\n",jiffies);
- }
- printk("cont=%p\n", cont);
- printk("current_req=%p\n", current_req);
- printk("command_status=%d\n", command_status);
- printk("\n");
-}
-
-static void floppy_shutdown(unsigned long data)
-{
- unsigned long flags;
-
- if (!initialising)
- show_floppy();
- cancel_activity();
-
- floppy_enable_hlt();
-
- flags=claim_dma_lock();
- fd_disable_dma();
- release_dma_lock(flags);
-
- /* avoid dma going to a random drive after shutdown */
-
- if (!initialising)
- DPRINT("floppy timeout called\n");
- FDCS->reset = 1;
- if (cont){
- cont->done(0);
- cont->redo(); /* this will recall reset when needed */
- } else {
- printk("no cont in shutdown!\n");
- process_fd_request();
- }
- is_alive("floppy shutdown");
-}
-/*typedef void (*timeout_fn)(unsigned long);*/
-
-static void access_mode_change_pc9800(void)
-{
- static int access_mode, mode_change_now, old_mode, new_set = 1;
-#ifdef PC9800_DEBUG_FLOPPY2
- printk("enter access_mode_change\n");
-#endif
- access_mode = mode_change_now = 0;
- if (DP->cmos==4) {
- switch ((int)(_floppy - &floppy_type[0])) {
- case 1:
- case 2:
- new_set = 1;
- access_mode = 2;
- break;
-
- case 4:
- case 6:
- new_set = 1;
- access_mode = 3;
- break;
-
- case 7:
- case 10:
- new_set = 1;
- access_mode = 1;
- break;
-
- default:
- access_mode = 1;
- break;
- }
-
- old_mode = fd_inb(FD_MODE_CHANGE) & 3;
-
- switch (access_mode) {
- case 1:
- if ((old_mode & 2) == 0) {
- fd_outb(old_mode | 2, FD_MODE_CHANGE);
- mode_change_now = 1;
- } else {
- fd_outb(current_drive << 5, FD_EMODE_CHANGE);
- if (fd_inb(FD_EMODE_CHANGE) == 0xff)
- return;
- }
-
- fd_outb((current_drive << 5) | 0x11, FD_EMODE_CHANGE);
- mode_change_now = 1;
- break;
-
- case 2:
- if ((old_mode & 2) == 0) {
- fd_outb(old_mode | 2, FD_MODE_CHANGE);
- mode_change_now = 1;
- } else {
- fd_outb(current_drive << 5, FD_EMODE_CHANGE);
- if ((fd_inb(FD_EMODE_CHANGE) & 1) == 0)
- return;
- fd_outb((current_drive << 5) | 0x10, FD_EMODE_CHANGE);
- mode_change_now = 1;
- }
-
- break;
-
- case 3:
- if ((old_mode & 2) == 0)
- return;
- fd_outb(current_drive << 5, FD_EMODE_CHANGE);
- if (fd_inb(FD_EMODE_CHANGE) & 1)
- fd_outb((current_drive << 5) | 0x10, FD_EMODE_CHANGE);
- fd_outb(old_mode & 0xfd, FD_MODE_CHANGE);
- mode_change_now = 1;
- break;
-
- default:
- break;
- }
- } else {
- switch ((int)(_floppy - &floppy_type[0])) {
- case 1:
- case 2:
- new_set = 1;
- access_mode = 2;
- break;
-
- case 4:
- case 6:
- new_set = 1;
- access_mode = 3;
- break;
-
- default:
- switch (DP->cmos) {
- case 2:
- access_mode = 2;
- break;
-
- case 3:
- access_mode = 3;
- break;
-
- default:
- break;
- }
-
- break;
- }
-
- old_mode = fd_inb(FD_MODE_CHANGE) & 3;
-
- switch (access_mode) {
- case 2:
- if ((old_mode & 2) == 0) {
- fd_outb(old_mode | 2, FD_MODE_CHANGE);
- mode_change_now = 1;
- }
-
- break;
-
- case 3:
- if (old_mode & 2) {
- fd_outb(old_mode & 0xfd, FD_MODE_CHANGE);
- mode_change_now = 1;
- }
-
- break;
-
- default:
- break;
- }
- }
-#ifdef PC9800_DEBUG_FLOPPY2
- printk("floppy debug: DP->cmos=%d\n", DP->cmos);
- printk("floppy debug: mode_change_now=%d\n", mode_change_now);
- printk("floppy debug: access_mode=%d\n", access_mode);
- printk("floppy debug: old_mode=%d\n", old_mode);
- printk("floppy debug: _floppy - &floppy_type[0]=%d\n", (int)(_floppy - &floppy_type[0]));
-#endif /* PC9800_DEBUG_FLOPPY2 */
- if(mode_change_now)
- reset_fdc();
-}
-
-/* start motor, check media-changed condition and write protection */
-static int start_motor(void (*function)(void) )
-{
- access_mode_change_pc9800();
- set_mode(~0, 0x8);
-
- /* wait_for_completion also schedules reset if needed. */
- return(fd_wait_for_completion(DRS->select_date+DP->select_delay,
- (timeout_fn) function));
-}
-
-static void floppy_ready(void)
-{
- CHECK_RESET;
- if (start_motor(floppy_ready)) return;
-
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("calling disk change from floppy_ready\n");
- }
-#endif
- if (!(raw_cmd->flags & FD_RAW_NO_MOTOR) &&
- disk_change(current_drive) &&
- !DP->select_delay)
- twaddle(); /* this clears the dcl on certain drive/controller
- * combinations */
-
-#ifdef fd_chose_dma_mode
- if ((raw_cmd->flags & FD_RAW_READ) ||
- (raw_cmd->flags & FD_RAW_WRITE))
- {
- unsigned long flags = claim_dma_lock();
- fd_chose_dma_mode(raw_cmd->kernel_data,
- raw_cmd->length);
- release_dma_lock(flags);
- }
-#endif
-
-#if 0
- access_mode_change_pc9800();
-#endif
- if (raw_cmd->flags & (FD_RAW_NEED_SEEK | FD_RAW_NEED_DISK)){
- fdc_specify(); /* must be done here because of hut, hlt ... */
- seek_floppy();
- } else {
- if ((raw_cmd->flags & FD_RAW_READ) ||
- (raw_cmd->flags & FD_RAW_WRITE))
- fdc_specify();
- setup_rw_floppy();
- }
-}
-
-static void floppy_start(void)
-{
- reschedule_timeout(current_reqD, "floppy start", 0);
-
- scandrives();
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("setting NEWCHANGE in floppy_start\n");
- }
-#endif
- SETF(FD_DISK_NEWCHANGE);
- floppy_ready();
-}
-
-/*
- * ========================================================================
- * here ends the bottom half. Exported routines are:
- * floppy_start, floppy_off, floppy_ready, lock_fdc, unlock_fdc, set_fdc,
- * start_motor, reset_fdc, reset_fdc_info, interpret_errors.
- * Initialization also uses output_byte, result, set_dor, floppy_interrupt
- * and set_dor.
- * ========================================================================
- */
-/*
- * General purpose continuations.
- * ==============================
- */
-
-static void do_wakeup(void)
-{
- reschedule_timeout(MAXTIMEOUT, "do wakeup", 0);
- cont = 0;
- command_status += 2;
- wake_up(&command_done);
-}
-
-static struct cont_t wakeup_cont={
- empty,
- do_wakeup,
- empty,
- (done_f)empty
-};
-
-
-static struct cont_t intr_cont={
- empty,
- process_fd_request,
- empty,
- (done_f) empty
-};
-
-static int wait_til_done(void (*handler)(void), int interruptible)
-{
- int ret;
-
- schedule_bh((void *)(void *)handler);
-
- if (command_status < 2 && NO_SIGNAL) {
- DECLARE_WAITQUEUE(wait, current);
-
- add_wait_queue(&command_done, &wait);
- for (;;) {
- set_current_state(interruptible?
- TASK_INTERRUPTIBLE:
- TASK_UNINTERRUPTIBLE);
-
- if (command_status >= 2 || !NO_SIGNAL)
- break;
-
- is_alive("wait_til_done");
-
- schedule();
- }
-
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&command_done, &wait);
- }
-
- if (command_status < 2){
- cancel_activity();
- cont = &intr_cont;
- reset_fdc();
- return -EINTR;
- }
-
-#ifdef PC9800_DEBUG_FLOPPY
- if (command_status != FD_COMMAND_OKAY)
- printk("floppy check: wait_til_done out:%d\n", command_status);
-#endif
- if (FDCS->reset)
- command_status = FD_COMMAND_ERROR;
- if (command_status == FD_COMMAND_OKAY)
- ret=0;
- else
- ret=-EIO;
- command_status = FD_COMMAND_NONE;
- return ret;
-}
-
-static void generic_done(int result)
-{
- command_status = result;
- cont = &wakeup_cont;
-}
-
-static void generic_success(void)
-{
- cont->done(1);
-}
-
-static void generic_failure(void)
-{
- cont->done(0);
-}
-
-static void success_and_wakeup(void)
-{
- generic_success();
- cont->redo();
-}
-
-
-/*
- * formatting and rw support.
- * ==========================
- */
-
-static int next_valid_format(void)
-{
- int probed_format;
-
- probed_format = DRS->probed_format;
- while(1){
- if (probed_format >= 8 ||
- !DP->autodetect[probed_format]){
- DRS->probed_format = 0;
- return 1;
- }
- if (floppy_type[DP->autodetect[probed_format]].sect){
- DRS->probed_format = probed_format;
- return 0;
- }
- probed_format++;
- }
-}
-
-static void bad_flp_intr(void)
-{
- if (probing){
- DRS->probed_format++;
- if (!next_valid_format())
- return;
- }
- (*errors)++;
- INFBOUND(DRWE->badness, *errors);
- if (*errors > DP->max_errors.abort)
- cont->done(0);
- if (*errors > DP->max_errors.reset)
- FDCS->reset = 1;
- else if (*errors > DP->max_errors.recal)
- DRS->track = NEED_2_RECAL;
-}
-
-static void set_floppy(int drive)
-{
- int type = ITYPE(UDRS->fd_device);
- if (type) {
- auto_detect_mode = 0;
- _floppy = floppy_type + type;
- } else if (auto_detect_mode == 0) {
- auto_detect_mode = 1;
- retry_auto_detect = 0;
- _floppy = current_type[drive];
- }
-#ifdef PC9800_DEBUG_FLOPPY2
- printk("set_floppy: set floppy type=%d\n", (int)(_floppy - floppy_type));
-#endif
-}
-
-/*
- * formatting support.
- * ===================
- */
-static void format_interrupt(void)
-{
- switch (interpret_errors()){
- case 1:
- cont->error();
- case 2:
- break;
- case 0:
- cont->done(1);
- }
- cont->redo();
-}
-
-#define CODE2SIZE (ssize = ((1 << SIZECODE) + 3) >> 2)
-#define FM_MODE(x,y) ((y) & ~(((x)->rate & 0x80) >>1))
-#define CT(x) ((x) | 0xc0)
-static void setup_format_params(int track)
-{
- struct fparm {
- unsigned char track,head,sect,size;
- } *here = (struct fparm *)floppy_track_buffer;
- int il,n;
- int count,head_shift,track_shift;
-
- raw_cmd = &default_raw_cmd;
- raw_cmd->track = track;
-
- raw_cmd->flags = FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN |
- FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK;
- raw_cmd->rate = _floppy->rate & 0x43;
- raw_cmd->cmd_count = NR_F;
- COMMAND = FM_MODE(_floppy,FD_FORMAT);
- DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy,format_req.head);
- F_SIZECODE = FD_SIZECODE(_floppy);
- F_SECT_PER_TRACK = _floppy->sect << 2 >> F_SIZECODE;
- F_GAP = _floppy->fmt_gap;
- F_FILL = FD_FILL_BYTE;
-
- raw_cmd->kernel_data = floppy_track_buffer;
- raw_cmd->length = 4 * F_SECT_PER_TRACK;
-
- /* allow for about 30ms for data transport per track */
- head_shift = (F_SECT_PER_TRACK + 5) / 6;
-
- /* a ``cylinder'' is two tracks plus a little stepping time */
- track_shift = 2 * head_shift + 3;
-
- /* position of logical sector 1 on this track */
- n = (track_shift * format_req.track + head_shift * format_req.head)
- % F_SECT_PER_TRACK;
-
- /* determine interleave */
- il = 1;
- if (_floppy->fmt_gap < 0x22)
- il++;
-
- /* initialize field */
- for (count = 0; count < F_SECT_PER_TRACK; ++count) {
- here[count].track = format_req.track;
- here[count].head = format_req.head;
- here[count].sect = 0;
- here[count].size = F_SIZECODE;
- }
- /* place logical sectors */
- for (count = 1; count <= F_SECT_PER_TRACK; ++count) {
- here[n].sect = count;
- n = (n+il) % F_SECT_PER_TRACK;
- if (here[n].sect) { /* sector busy, find next free sector */
- ++n;
- if (n>= F_SECT_PER_TRACK) {
- n-=F_SECT_PER_TRACK;
- while (here[n].sect) ++n;
- }
- }
- }
-}
-
-static void redo_format(void)
-{
- buffer_track = -1;
- setup_format_params(format_req.track << STRETCH(_floppy));
- floppy_start();
-#ifdef DEBUGT
- debugt("queue format request");
-#endif
-}
-
-static struct cont_t format_cont={
- format_interrupt,
- redo_format,
- bad_flp_intr,
- generic_done };
-
-static int do_format(int drive, struct format_descr *tmp_format_req)
-{
- int ret;
-
- LOCK_FDC(drive,1);
- set_floppy(drive);
- if (!_floppy ||
- _floppy->track > DP->tracks ||
- tmp_format_req->track >= _floppy->track ||
- tmp_format_req->head >= _floppy->head ||
- (_floppy->sect << 2) % (1 << FD_SIZECODE(_floppy)) ||
- !_floppy->fmt_gap) {
- process_fd_request();
- return -EINVAL;
- }
- format_req = *tmp_format_req;
- format_errors = 0;
- cont = &format_cont;
- errors = &format_errors;
- IWAIT(redo_format);
- process_fd_request();
- return ret;
-}
-
-/*
- * Buffer read/write and support
- * =============================
- */
-
-static void floppy_end_request(struct request *req, int uptodate)
-{
- if (end_that_request_first(req, uptodate, current_count_sectors))
- return;
- add_disk_randomness(req->rq_disk);
- floppy_off((long)req->rq_disk->private_data);
- blkdev_dequeue_request(req);
- end_that_request_last(req);
-
- /* We're done with the request */
- current_req = NULL;
-}
-
-
-/* new request_done. Can handle physical sectors which are smaller than a
- * logical buffer */
-static void request_done(int uptodate)
-{
- struct request_queue *q = floppy_queue;
- struct request *req = current_req;
- unsigned long flags;
- int block;
-
- probing = 0;
- reschedule_timeout(MAXTIMEOUT, "request done %d", uptodate);
-
- if (!req) {
- printk("floppy.c: no request in request_done\n");
- return;
- }
-
- if (uptodate){
- /* maintain values for invalidation on geometry
- * change */
- block = current_count_sectors + req->sector;
- INFBOUND(DRS->maxblock, block);
- if (block > _floppy->sect)
- DRS->maxtrack = 1;
-
- /* unlock chained buffers */
- spin_lock_irqsave(q->queue_lock, flags);
- floppy_end_request(req, 1);
- spin_unlock_irqrestore(q->queue_lock, flags);
- } else {
- if (rq_data_dir(req) == WRITE) {
- /* record write error information */
- DRWE->write_errors++;
- if (DRWE->write_errors == 1) {
- DRWE->first_error_sector = req->sector;
- DRWE->first_error_generation = DRS->generation;
- }
- DRWE->last_error_sector = req->sector;
- DRWE->last_error_generation = DRS->generation;
- }
- spin_lock_irqsave(q->queue_lock, flags);
- floppy_end_request(req, 0);
- spin_unlock_irqrestore(q->queue_lock, flags);
- }
-}
-
-/* Interrupt handler evaluating the result of the r/w operation */
-static void rw_interrupt(void)
-{
- int nr_sectors, ssize, eoc, heads;
-
- if (R_HEAD >= 2) {
- /* some Toshiba floppy controllers occasionnally seem to
- * return bogus interrupts after read/write operations, which
- * can be recognized by a bad head number (>= 2) */
- return;
- }
-
- if (!DRS->first_read_date)
- DRS->first_read_date = jiffies;
-
- nr_sectors = 0;
- CODE2SIZE;
-
- if (ST1 & ST1_EOC)
- eoc = 1;
- else
- eoc = 0;
-
- if (COMMAND & 0x80)
- heads = 2;
- else
- heads = 1;
-
- nr_sectors = (((R_TRACK-TRACK) * heads +
- R_HEAD-HEAD) * SECT_PER_TRACK +
- R_SECTOR-SECTOR + eoc) << SIZECODE >> 2;
-
-#ifdef FLOPPY_SANITY_CHECK
- if (nr_sectors / ssize >
- (in_sector_offset + current_count_sectors + ssize - 1) / ssize) {
- DPRINT("long rw: %x instead of %lx\n",
- nr_sectors, current_count_sectors);
- printk("rs=%d s=%d\n", R_SECTOR, SECTOR);
- printk("rh=%d h=%d\n", R_HEAD, HEAD);
- printk("rt=%d t=%d\n", R_TRACK, TRACK);
- printk("heads=%d eoc=%d\n", heads, eoc);
- printk("spt=%d st=%d ss=%d\n", SECT_PER_TRACK,
- fsector_t, ssize);
- printk("in_sector_offset=%d\n", in_sector_offset);
- }
-#endif
-
- nr_sectors -= in_sector_offset;
- INFBOUND(nr_sectors,0);
- SUPBOUND(current_count_sectors, nr_sectors);
-
- switch (interpret_errors()){
- case 2:
- cont->redo();
- return;
- case 1:
- if (!current_count_sectors){
- cont->error();
- cont->redo();
- return;
- }
- break;
- case 0:
- if (!current_count_sectors){
- cont->redo();
- return;
- }
- current_type[current_drive] = _floppy;
- floppy_sizes[TOMINOR(current_drive) ]= _floppy->size;
- break;
- }
-
- if (probing) {
- if (DP->flags & FTD_MSG)
- DPRINT("Auto-detected floppy type %s in fd%d\n",
- _floppy->name,current_drive);
- current_type[current_drive] = _floppy;
- floppy_sizes[TOMINOR(current_drive)] = _floppy->size;
- probing = 0;
- }
-
- if (CT(COMMAND) != FD_READ ||
- raw_cmd->kernel_data == current_req->buffer){
- /* transfer directly from buffer */
- cont->done(1);
- } else if (CT(COMMAND) == FD_READ){
- buffer_track = raw_cmd->track;
- buffer_drive = current_drive;
- INFBOUND(buffer_max, nr_sectors + fsector_t);
- }
- cont->redo();
-}
-
-/* Compute maximal contiguous buffer size. */
-static int buffer_chain_size(void)
-{
- struct bio *bio;
- struct bio_vec *bv;
- int size, i;
- char *base;
-
- base = bio_data(current_req->bio);
- size = 0;
-
- rq_for_each_bio(bio, current_req) {
- bio_for_each_segment(bv, bio, i) {
- if (page_address(bv->bv_page) + bv->bv_offset != base + size)
- break;
-
- size += bv->bv_len;
- }
- }
-
- return size >> 9;
-}
-
-/* Compute the maximal transfer size */
-static int transfer_size(int ssize, int max_sector, int max_size)
-{
- SUPBOUND(max_sector, fsector_t + max_size);
-
- /* alignment */
- max_sector -= (max_sector % _floppy->sect) % ssize;
-
- /* transfer size, beginning not aligned */
- current_count_sectors = max_sector - fsector_t ;
-
- return max_sector;
-}
-
-/*
- * Move data from/to the track buffer to/from the buffer cache.
- */
-static void copy_buffer(int ssize, int max_sector, int max_sector_2)
-{
- int remaining; /* number of transferred 512-byte sectors */
- struct bio_vec *bv;
- struct bio *bio;
- char *buffer, *dma_buffer;
- int size, i;
-
- max_sector = transfer_size(ssize,
- minimum(max_sector, max_sector_2),
- current_req->nr_sectors);
-
- if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
- buffer_max > fsector_t + current_req->nr_sectors)
- current_count_sectors = minimum(buffer_max - fsector_t,
- current_req->nr_sectors);
-
- remaining = current_count_sectors << 9;
-#ifdef FLOPPY_SANITY_CHECK
- if ((remaining >> 9) > current_req->nr_sectors &&
- CT(COMMAND) == FD_WRITE){
- DPRINT("in copy buffer\n");
- printk("current_count_sectors=%ld\n", current_count_sectors);
- printk("remaining=%d\n", remaining >> 9);
- printk("current_req->nr_sectors=%ld\n",current_req->nr_sectors);
- printk("current_req->current_nr_sectors=%u\n",
- current_req->current_nr_sectors);
- printk("max_sector=%d\n", max_sector);
- printk("ssize=%d\n", ssize);
- }
-#endif
-
- buffer_max = maximum(max_sector, buffer_max);
-
- dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
-
- size = current_req->current_nr_sectors << 9;
-
- rq_for_each_bio(bio, current_req) {
- bio_for_each_segment(bv, bio, i) {
- if (!remaining)
- break;
-
- size = bv->bv_len;
- SUPBOUND(size, remaining);
-
- buffer = page_address(bv->bv_page) + bv->bv_offset;
-#ifdef FLOPPY_SANITY_CHECK
- if (dma_buffer + size >
- floppy_track_buffer + (max_buffer_sectors << 10) ||
- dma_buffer < floppy_track_buffer){
- DPRINT("buffer overrun in copy buffer %d\n",
- (int) ((floppy_track_buffer - dma_buffer) >>9));
- printk("fsector_t=%d buffer_min=%d\n",
- fsector_t, buffer_min);
- printk("current_count_sectors=%ld\n",
- current_count_sectors);
- if (CT(COMMAND) == FD_READ)
- printk("read\n");
- if (CT(COMMAND) == FD_WRITE)
- printk("write\n");
- break;
- }
- if (((unsigned long)buffer) % 512)
- DPRINT("%p buffer not aligned\n", buffer);
-#endif
- if (CT(COMMAND) == FD_READ)
- memcpy(buffer, dma_buffer, size);
- else
- memcpy(dma_buffer, buffer, size);
-
- remaining -= size;
- dma_buffer += size;
- }
- }
-#ifdef FLOPPY_SANITY_CHECK
- if (remaining){
- if (remaining > 0)
- max_sector -= remaining >> 9;
- DPRINT("weirdness: remaining %d\n", remaining>>9);
- }
-#endif
-}
-
-#if 0
-static inline int check_dma_crossing(char *start,
- unsigned long length, char *message)
-{
- if (CROSS_64KB(start, length)) {
- printk("DMA xfer crosses 64KB boundary in %s %p-%p\n",
- message, start, start+length);
- return 1;
- } else
- return 0;
-}
-#endif
-
-/* work around a bug in pseudo DMA
- * (on some FDCs) pseudo DMA does not stop when the CPU stops
- * sending data. Hence we need a different way to signal the
- * transfer length: We use SECT_PER_TRACK. Unfortunately, this
- * does not work with MT, hence we can only transfer one head at
- * a time
- */
-static void virtualdmabug_workaround(void)
-{
- int hard_sectors, end_sector;
-
- if(CT(COMMAND) == FD_WRITE) {
- COMMAND &= ~0x80; /* switch off multiple track mode */
-
- hard_sectors = raw_cmd->length >> (7 + SIZECODE);
- end_sector = SECTOR + hard_sectors - 1;
-#ifdef FLOPPY_SANITY_CHECK
- if(end_sector > SECT_PER_TRACK) {
- printk("too many sectors %d > %d\n",
- end_sector, SECT_PER_TRACK);
- return;
- }
-#endif
- SECT_PER_TRACK = end_sector; /* make sure SECT_PER_TRACK points
- * to end of transfer */
- }
-}
-
-/*
- * Formulate a read/write request.
- * this routine decides where to load the data (directly to buffer, or to
- * tmp floppy area), how much data to load (the size of the buffer, the whole
- * track, or a single sector)
- * All floppy_track_buffer handling goes in here. If we ever add track buffer
- * allocation on the fly, it should be done here. No other part should need
- * modification.
- */
-
-static int make_raw_rw_request(void)
-{
- int aligned_sector_t;
- int max_sector, max_size, tracksize, ssize;
-
- if(max_buffer_sectors == 0) {
- printk("VFS: Block I/O scheduled on unopened device\n");
- return 0;
- }
-
- set_fdc((long)current_req->rq_disk->private_data);
-
- raw_cmd = &default_raw_cmd;
- raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_DISK |
- FD_RAW_NEED_SEEK;
- raw_cmd->cmd_count = NR_RW;
- if (rq_data_dir(current_req) == READ) {
- raw_cmd->flags |= FD_RAW_READ;
- COMMAND = FM_MODE(_floppy,FD_READ);
- } else if (rq_data_dir(current_req) == WRITE){
- raw_cmd->flags |= FD_RAW_WRITE;
- COMMAND = FM_MODE(_floppy,FD_WRITE);
- } else {
- DPRINT("make_raw_rw_request: unknown command\n");
- return 0;
- }
-
- max_sector = _floppy->sect * _floppy->head;
-
- TRACK = (int)current_req->sector / max_sector;
- fsector_t = (int)current_req->sector % max_sector;
- if (_floppy->track && TRACK >= _floppy->track) {
- if (current_req->current_nr_sectors & 1) {
- current_count_sectors = 1;
- return 1;
- } else
- return 0;
- }
- HEAD = fsector_t / _floppy->sect;
-
- if (((_floppy->stretch & FD_SWAPSIDES) || TESTF(FD_NEED_TWADDLE)) &&
- fsector_t < _floppy->sect)
- max_sector = _floppy->sect;
-
- /* 2M disks have phantom sectors on the first track */
- if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
- max_sector = 2 * _floppy->sect / 3;
- if (fsector_t >= max_sector){
- current_count_sectors = minimum(_floppy->sect - fsector_t,
- current_req->nr_sectors);
- return 1;
- }
- SIZECODE = 2;
- } else
- SIZECODE = FD_SIZECODE(_floppy);
- raw_cmd->rate = _floppy->rate & 0x43;
- if ((_floppy->rate & FD_2M) &&
- (TRACK || HEAD) &&
- raw_cmd->rate == 2)
- raw_cmd->rate = 1;
-
- if (SIZECODE)
- SIZECODE2 = 0xff;
- else
- SIZECODE2 = 0x80;
- raw_cmd->track = TRACK << STRETCH(_floppy);
- DR_SELECT = UNIT(current_drive) + PH_HEAD(_floppy,HEAD);
- GAP = _floppy->gap;
- CODE2SIZE;
- SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE;
- SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + 1;
-
- /* tracksize describes the size which can be filled up with sectors
- * of size ssize.
- */
- tracksize = _floppy->sect - _floppy->sect % ssize;
- if (tracksize < _floppy->sect){
- SECT_PER_TRACK ++;
- if (tracksize <= fsector_t % _floppy->sect)
- SECTOR--;
-
- /* if we are beyond tracksize, fill up using smaller sectors */
- while (tracksize <= fsector_t % _floppy->sect){
- while(tracksize + ssize > _floppy->sect){
- SIZECODE--;
- ssize >>= 1;
- }
- SECTOR++; SECT_PER_TRACK ++;
- tracksize += ssize;
- }
- max_sector = HEAD * _floppy->sect + tracksize;
- } else if (!TRACK && !HEAD && !(_floppy->rate & FD_2M) && probing) {
- max_sector = _floppy->sect;
- } else if (!HEAD && CT(COMMAND) == FD_WRITE) {
- /* for virtual DMA bug workaround */
- max_sector = _floppy->sect;
- }
-
- in_sector_offset = (fsector_t % _floppy->sect) % ssize;
- aligned_sector_t = fsector_t - in_sector_offset;
- max_size = current_req->nr_sectors;
- if ((raw_cmd->track == buffer_track) &&
- (current_drive == buffer_drive) &&
- (fsector_t >= buffer_min) && (fsector_t < buffer_max)) {
- /* data already in track buffer */
- if (CT(COMMAND) == FD_READ) {
- copy_buffer(1, max_sector, buffer_max);
- return 1;
- }
- } else if (in_sector_offset || current_req->nr_sectors < ssize){
- if (CT(COMMAND) == FD_WRITE){
- if (fsector_t + current_req->nr_sectors > ssize &&
- fsector_t + current_req->nr_sectors < ssize + ssize)
- max_size = ssize + ssize;
- else
- max_size = ssize;
- }
- raw_cmd->flags &= ~FD_RAW_WRITE;
- raw_cmd->flags |= FD_RAW_READ;
- COMMAND = FM_MODE(_floppy,FD_READ);
- } else if ((unsigned long)current_req->buffer < MAX_DMA_ADDRESS) {
- unsigned long dma_limit;
- int direct, indirect;
-
- indirect= transfer_size(ssize,max_sector,max_buffer_sectors*2) -
- fsector_t;
-
- /*
- * Do NOT use minimum() here---MAX_DMA_ADDRESS is 64 bits wide
- * on a 64 bit machine!
- */
- max_size = buffer_chain_size();
- dma_limit = (MAX_DMA_ADDRESS - ((unsigned long) current_req->buffer)) >> 9;
- if ((unsigned long) max_size > dma_limit) {
- max_size = dma_limit;
- }
- /* 64 kb boundaries */
- if (CROSS_64KB(current_req->buffer, max_size << 9))
- max_size = (K_64 -
- ((unsigned long)current_req->buffer) % K_64)>>9;
- direct = transfer_size(ssize,max_sector,max_size) - fsector_t;
- /*
- * We try to read tracks, but if we get too many errors, we
- * go back to reading just one sector at a time.
- *
- * This means we should be able to read a sector even if there
- * are other bad sectors on this track.
- */
- if (!direct ||
- (indirect * 2 > direct * 3 &&
- *errors < DP->max_errors.read_track &&
- /*!TESTF(FD_NEED_TWADDLE) &&*/
- ((!probing || (DP->read_track&(1<<DRS->probed_format)))))){
- max_size = current_req->nr_sectors;
- } else {
- raw_cmd->kernel_data = current_req->buffer;
- raw_cmd->length = current_count_sectors << 9;
- if (raw_cmd->length == 0){
- DPRINT("zero dma transfer attempted from make_raw_request\n");
- DPRINT("indirect=%d direct=%d fsector_t=%d",
- indirect, direct, fsector_t);
- return 0;
- }
-/* check_dma_crossing(raw_cmd->kernel_data,
- raw_cmd->length,
- "end of make_raw_request [1]");*/
-
- virtualdmabug_workaround();
- return 2;
- }
- }
-
- if (CT(COMMAND) == FD_READ)
- max_size = max_sector; /* unbounded */
-
- /* claim buffer track if needed */
- if (buffer_track != raw_cmd->track || /* bad track */
- buffer_drive !=current_drive || /* bad drive */
- fsector_t > buffer_max ||
- fsector_t < buffer_min ||
- ((CT(COMMAND) == FD_READ ||
- (!in_sector_offset && current_req->nr_sectors >= ssize))&&
- max_sector > 2 * max_buffer_sectors + buffer_min &&
- max_size + fsector_t > 2 * max_buffer_sectors + buffer_min)
- /* not enough space */){
- buffer_track = -1;
- buffer_drive = current_drive;
- buffer_max = buffer_min = aligned_sector_t;
- }
- raw_cmd->kernel_data = floppy_track_buffer +
- ((aligned_sector_t-buffer_min)<<9);
-
- if (CT(COMMAND) == FD_WRITE){
- /* copy write buffer to track buffer.
- * if we get here, we know that the write
- * is either aligned or the data already in the buffer
- * (buffer will be overwritten) */
-#ifdef FLOPPY_SANITY_CHECK
- if (in_sector_offset && buffer_track == -1)
- DPRINT("internal error offset !=0 on write\n");
-#endif
- buffer_track = raw_cmd->track;
- buffer_drive = current_drive;
- copy_buffer(ssize, max_sector, 2*max_buffer_sectors+buffer_min);
- } else
- transfer_size(ssize, max_sector,
- 2*max_buffer_sectors+buffer_min-aligned_sector_t);
-
- /* round up current_count_sectors to get dma xfer size */
- raw_cmd->length = in_sector_offset+current_count_sectors;
- raw_cmd->length = ((raw_cmd->length -1)|(ssize-1))+1;
- raw_cmd->length <<= 9;
-#ifdef FLOPPY_SANITY_CHECK
- /*check_dma_crossing(raw_cmd->kernel_data, raw_cmd->length,
- "end of make_raw_request");*/
- if ((raw_cmd->length < current_count_sectors << 9) ||
- (raw_cmd->kernel_data != current_req->buffer &&
- CT(COMMAND) == FD_WRITE &&
- (aligned_sector_t + (raw_cmd->length >> 9) > buffer_max ||
- aligned_sector_t < buffer_min)) ||
- raw_cmd->length % (128 << SIZECODE) ||
- raw_cmd->length <= 0 || current_count_sectors <= 0){
- DPRINT("fractionary current count b=%lx s=%lx\n",
- raw_cmd->length, current_count_sectors);
- if (raw_cmd->kernel_data != current_req->buffer)
- printk("addr=%d, length=%ld\n",
- (int) ((raw_cmd->kernel_data -
- floppy_track_buffer) >> 9),
- current_count_sectors);
- printk("st=%d ast=%d mse=%d msi=%d\n",
- fsector_t, aligned_sector_t, max_sector, max_size);
- printk("ssize=%x SIZECODE=%d\n", ssize, SIZECODE);
- printk("command=%x SECTOR=%d HEAD=%d, TRACK=%d\n",
- COMMAND, SECTOR, HEAD, TRACK);
- printk("buffer drive=%d\n", buffer_drive);
- printk("buffer track=%d\n", buffer_track);
- printk("buffer_min=%d\n", buffer_min);
- printk("buffer_max=%d\n", buffer_max);
- return 0;
- }
-
- if (raw_cmd->kernel_data != current_req->buffer){
- if (raw_cmd->kernel_data < floppy_track_buffer ||
- current_count_sectors < 0 ||
- raw_cmd->length < 0 ||
- raw_cmd->kernel_data + raw_cmd->length >
- floppy_track_buffer + (max_buffer_sectors << 10)){
- DPRINT("buffer overrun in schedule dma\n");
- printk("fsector_t=%d buffer_min=%d current_count=%ld\n",
- fsector_t, buffer_min,
- raw_cmd->length >> 9);
- printk("current_count_sectors=%ld\n",
- current_count_sectors);
- if (CT(COMMAND) == FD_READ)
- printk("read\n");
- if (CT(COMMAND) == FD_WRITE)
- printk("write\n");
- return 0;
- }
- } else if (raw_cmd->length > current_req->nr_sectors << 9 ||
- current_count_sectors > current_req->nr_sectors){
- DPRINT("buffer overrun in direct transfer\n");
- return 0;
- } else if (raw_cmd->length < current_count_sectors << 9){
- DPRINT("more sectors than bytes\n");
- printk("bytes=%ld\n", raw_cmd->length >> 9);
- printk("sectors=%ld\n", current_count_sectors);
- }
- if (raw_cmd->length == 0){
- DPRINT("zero dma transfer attempted from make_raw_request\n");
- return 0;
- }
-#endif
-
- virtualdmabug_workaround();
- return 2;
-}
-
-static void redo_fd_request(void)
-{
-#define REPEAT {request_done(0); continue; }
- int drive;
- int tmp;
-
- lastredo = jiffies;
- if (current_drive < N_DRIVE)
- floppy_off(current_drive);
-
- for (;;) {
- if (!current_req) {
- struct request *req;
-
- spin_lock_irq(floppy_queue->queue_lock);
- req = elv_next_request(floppy_queue);
- spin_unlock_irq(floppy_queue->queue_lock);
- if (!req) {
- do_floppy = NULL;
- unlock_fdc();
- return;
- }
- current_req = req;
- }
- drive = (long)current_req->rq_disk->private_data;
- set_fdc(drive);
- reschedule_timeout(current_reqD, "redo fd request", 0);
-
- set_floppy(drive);
- raw_cmd = & default_raw_cmd;
- raw_cmd->flags = 0;
- if (start_motor(redo_fd_request)) return;
- disk_change(current_drive);
- if (test_bit(current_drive, &fake_change) ||
- TESTF(FD_DISK_CHANGED)){
- DPRINT("disk absent or changed during operation\n");
- REPEAT;
- }
- if (!_floppy) { /* Autodetection */
- if (!probing){
- DRS->probed_format = 0;
- if (next_valid_format()){
- DPRINT("no autodetectable formats\n");
- _floppy = NULL;
- REPEAT;
- }
- }
- probing = 1;
- _floppy = floppy_type+DP->autodetect[DRS->probed_format];
- } else
- probing = 0;
- errors = & (current_req->errors);
- tmp = make_raw_rw_request();
- if (tmp < 2){
- request_done(tmp);
- continue;
- }
-
- if (TESTF(FD_NEED_TWADDLE))
- twaddle();
- schedule_bh( (void *)(void *) floppy_start);
-#ifdef DEBUGT
- debugt("queue fd request");
-#endif
- return;
- }
-#undef REPEAT
-}
-
-static struct cont_t rw_cont={
- rw_interrupt,
- redo_fd_request,
- bad_flp_intr,
- request_done };
-
-static void process_fd_request(void)
-{
- cont = &rw_cont;
- schedule_bh( (void *)(void *) redo_fd_request);
-}
-
-static void do_fd_request(request_queue_t * q)
-{
- if(max_buffer_sectors == 0) {
- printk("VFS: do_fd_request called on non-open device\n");
- return;
- }
-
- if (usage_count == 0) {
- printk("warning: usage count=0, current_req=%p exiting\n", current_req);
- printk("sect=%ld flags=%lx\n", (long)current_req->sector, current_req->flags);
- return;
- }
- if (fdc_busy){
- /* fdc busy, this new request will be treated when the
- current one is done */
- is_alive("do fd request, old request running");
- return;
- }
- lock_fdc(MAXTIMEOUT,0);
- process_fd_request();
- is_alive("do fd request");
-}
-
-static struct cont_t poll_cont={
- success_and_wakeup,
- floppy_ready,
- generic_failure,
- generic_done };
-
-static int poll_drive(int interruptible, int flag)
-{
- int ret;
- /* no auto-sense, just clear dcl */
- raw_cmd = &default_raw_cmd;
- raw_cmd->flags= flag;
- raw_cmd->track=0;
- raw_cmd->cmd_count=0;
- cont = &poll_cont;
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("setting NEWCHANGE in poll_drive\n");
- }
-#endif
- SETF(FD_DISK_NEWCHANGE);
- WAIT(floppy_ready);
- return ret;
-}
-
-/*
- * User triggered reset
- * ====================
- */
-
-static void reset_intr(void)
-{
- printk("weird, reset interrupt called\n");
-}
-
-static struct cont_t reset_cont={
- reset_intr,
- success_and_wakeup,
- generic_failure,
- generic_done };
-
-static int user_reset_fdc(int drive, int arg, int interruptible)
-{
- int ret;
-
- ret=0;
- LOCK_FDC(drive,interruptible);
- if (arg == FD_RESET_ALWAYS)
- FDCS->reset=1;
- if (FDCS->reset){
- cont = &reset_cont;
- WAIT(reset_fdc);
- }
- process_fd_request();
- return ret;
-}
-
-/*
- * Misc Ioctl's and support
- * ========================
- */
-static inline int fd_copyout(void *param, const void *address, unsigned long size)
-{
- return copy_to_user(param,address, size) ? -EFAULT : 0;
-}
-
-static inline int fd_copyin(void *param, void *address, unsigned long size)
-{
- return copy_from_user(address, param, size) ? -EFAULT : 0;
-}
-
-#define _COPYOUT(x) (copy_to_user((void *)param, &(x), sizeof(x)) ? -EFAULT : 0)
-#define _COPYIN(x) (copy_from_user(&(x), (void *)param, sizeof(x)) ? -EFAULT : 0)
-
-#define COPYOUT(x) ECALL(_COPYOUT(x))
-#define COPYIN(x) ECALL(_COPYIN(x))
-
-static inline const char *drive_name(int type, int drive)
-{
- struct floppy_struct *floppy;
-
- if (type)
- floppy = floppy_type + type;
- else {
- if (UDP->native_format)
- floppy = floppy_type + UDP->native_format;
- else
- return "(null)";
- }
- if (floppy->name)
- return floppy->name;
- else
- return "(null)";
-}
-
-
-/* raw commands */
-static void raw_cmd_done(int flag)
-{
- int i;
-
- if (!flag) {
- raw_cmd->flags |= FD_RAW_FAILURE;
- raw_cmd->flags |= FD_RAW_HARDFAILURE;
- } else {
- raw_cmd->reply_count = inr;
- if (raw_cmd->reply_count > MAX_REPLIES)
- raw_cmd->reply_count=0;
- for (i=0; i< raw_cmd->reply_count; i++)
- raw_cmd->reply[i] = reply_buffer[i];
-
- if (raw_cmd->flags & (FD_RAW_READ | FD_RAW_WRITE))
- {
- unsigned long flags;
- flags=claim_dma_lock();
- raw_cmd->length = fd_get_dma_residue();
- release_dma_lock(flags);
- }
-
- if ((raw_cmd->flags & FD_RAW_SOFTFAILURE) &&
- (!raw_cmd->reply_count || (raw_cmd->reply[0] & 0xc0)))
- raw_cmd->flags |= FD_RAW_FAILURE;
-
- if (disk_change(current_drive))
- raw_cmd->flags |= FD_RAW_DISK_CHANGE;
- else
- raw_cmd->flags &= ~FD_RAW_DISK_CHANGE;
- if (raw_cmd->flags & FD_RAW_NO_MOTOR_AFTER)
- motor_off_callback(current_drive);
-
- if (raw_cmd->next &&
- (!(raw_cmd->flags & FD_RAW_FAILURE) ||
- !(raw_cmd->flags & FD_RAW_STOP_IF_FAILURE)) &&
- ((raw_cmd->flags & FD_RAW_FAILURE) ||
- !(raw_cmd->flags &FD_RAW_STOP_IF_SUCCESS))) {
- raw_cmd = raw_cmd->next;
- return;
- }
- }
- generic_done(flag);
-}
-
-
-static struct cont_t raw_cmd_cont={
- success_and_wakeup,
- floppy_start,
- generic_failure,
- raw_cmd_done
-};
-
-static inline int raw_cmd_copyout(int cmd, char *param,
- struct floppy_raw_cmd *ptr)
-{
- int ret;
-
- while(ptr) {
- COPYOUT(*ptr);
- param += sizeof(struct floppy_raw_cmd);
- if ((ptr->flags & FD_RAW_READ) && ptr->buffer_length){
- if (ptr->length>=0 && ptr->length<=ptr->buffer_length)
- ECALL(fd_copyout(ptr->data,
- ptr->kernel_data,
- ptr->buffer_length -
- ptr->length));
- }
- ptr = ptr->next;
- }
- return 0;
-}
-
-
-static void raw_cmd_free(struct floppy_raw_cmd **ptr)
-{
- struct floppy_raw_cmd *next,*this;
-
- this = *ptr;
- *ptr = 0;
- while(this) {
- if (this->buffer_length) {
- fd_dma_mem_free((unsigned long)this->kernel_data,
- this->buffer_length);
- this->buffer_length = 0;
- }
- next = this->next;
- kfree(this);
- this = next;
- }
-}
-
-
-static inline int raw_cmd_copyin(int cmd, char *param,
- struct floppy_raw_cmd **rcmd)
-{
- struct floppy_raw_cmd *ptr;
- int ret;
- int i;
-
- *rcmd = 0;
- while(1) {
- ptr = (struct floppy_raw_cmd *)
- kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER);
- if (!ptr)
- return -ENOMEM;
- *rcmd = ptr;
- COPYIN(*ptr);
- ptr->next = 0;
- ptr->buffer_length = 0;
- param += sizeof(struct floppy_raw_cmd);
- if (ptr->cmd_count > 33)
- /* the command may now also take up the space
- * initially intended for the reply & the
- * reply count. Needed for long 82078 commands
- * such as RESTORE, which takes ... 17 command
- * bytes. Murphy's law #137: When you reserve
- * 16 bytes for a structure, you'll one day
- * discover that you really need 17...
- */
- return -EINVAL;
-
- for (i=0; i< 16; i++)
- ptr->reply[i] = 0;
- ptr->resultcode = 0;
- ptr->kernel_data = 0;
-
- if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
- if (ptr->length <= 0)
- return -EINVAL;
- ptr->kernel_data =(char*)fd_dma_mem_alloc(ptr->length);
- fallback_on_nodma_alloc(&ptr->kernel_data,
- ptr->length);
- if (!ptr->kernel_data)
- return -ENOMEM;
- ptr->buffer_length = ptr->length;
- }
- if (ptr->flags & FD_RAW_WRITE)
- ECALL(fd_copyin(ptr->data, ptr->kernel_data,
- ptr->length));
- rcmd = & (ptr->next);
- if (!(ptr->flags & FD_RAW_MORE))
- return 0;
- ptr->rate &= 0x43;
- }
-}
-
-
-static int raw_cmd_ioctl(int cmd, void *param)
-{
- int drive, ret, ret2;
- struct floppy_raw_cmd *my_raw_cmd;
-
- if (FDCS->rawcmd <= 1)
- FDCS->rawcmd = 1;
- for (drive= 0; drive < N_DRIVE; drive++){
- if (FDC(drive) != fdc)
- continue;
- if (drive == current_drive){
- if (UDRS->fd_ref > 1){
- FDCS->rawcmd = 2;
- break;
- }
- } else if (UDRS->fd_ref){
- FDCS->rawcmd = 2;
- break;
- }
- }
-
- if (FDCS->reset)
- return -EIO;
-
- ret = raw_cmd_copyin(cmd, param, &my_raw_cmd);
- if (ret) {
- raw_cmd_free(&my_raw_cmd);
- return ret;
- }
-
- raw_cmd = my_raw_cmd;
- cont = &raw_cmd_cont;
- ret=wait_til_done(floppy_start,1);
-#ifdef DCL_DEBUG
- if (DP->flags & FD_DEBUG){
- DPRINT("calling disk change from raw_cmd ioctl\n");
- }
-#endif
-
- if (ret != -EINTR && FDCS->reset)
- ret = -EIO;
-
- DRS->track = NO_TRACK;
-
- ret2 = raw_cmd_copyout(cmd, param, my_raw_cmd);
- if (!ret)
- ret = ret2;
- raw_cmd_free(&my_raw_cmd);
- return ret;
-}
-
-static int invalidate_drive(struct block_device *bdev)
-{
- /* invalidate the buffer track to force a reread */
- set_bit((long)bdev->bd_disk->private_data, &fake_change);
- process_fd_request();
- check_disk_change(bdev);
- return 0;
-}
-
-
-static inline void clear_write_error(int drive)
-{
- CLEARSTRUCT(UDRWE);
-}
-
-static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
- int drive, int type, struct block_device *bdev)
-{
- int cnt;
-
- /* sanity checking for parameters.*/
- if (g->sect <= 0 ||
- g->head <= 0 ||
- g->track <= 0 ||
- g->track > UDP->tracks>>STRETCH(g) ||
- /* check if reserved bits are set */
- (g->stretch&~(FD_STRETCH|FD_SWAPSIDES)) != 0)
- return -EINVAL;
- if (type){
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
- down(&open_lock);
- LOCK_FDC(drive,1);
- floppy_type[type] = *g;
- floppy_type[type].name="user format";
- for (cnt = type << 2; cnt < (type << 2) + 4; cnt++)
- floppy_sizes[cnt]= floppy_sizes[cnt+0x80]=
- floppy_type[type].size+1;
- process_fd_request();
- for (cnt = 0; cnt < N_DRIVE; cnt++) {
- struct block_device *bdev = opened_bdev[cnt];
- if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
- continue;
- __invalidate_device(bdev, 0);
- }
- up(&open_lock);
- } else {
- LOCK_FDC(drive,1);
- if (cmd != FDDEFPRM)
- /* notice a disk change immediately, else
- * we lose our settings immediately*/
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- user_params[drive] = *g;
- if (buffer_drive == drive)
- SUPBOUND(buffer_max, user_params[drive].sect);
- current_type[drive] = &user_params[drive];
- floppy_sizes[drive] = user_params[drive].size;
- if (cmd == FDDEFPRM)
- DRS->keep_data = -1;
- else
- DRS->keep_data = 1;
- /* invalidation. Invalidate only when needed, i.e.
- * when there are already sectors in the buffer cache
- * whose number will change. This is useful, because
- * mtools often changes the geometry of the disk after
- * looking at the boot block */
- if (DRS->maxblock > user_params[drive].sect || DRS->maxtrack)
- invalidate_drive(bdev);
- else
- process_fd_request();
- }
- return 0;
-}
-
-/* handle obsolete ioctl's */
-static int ioctl_table[]= {
- FDCLRPRM,
- FDSETPRM,
- FDDEFPRM,
- FDGETPRM,
- FDMSGON,
- FDMSGOFF,
- FDFMTBEG,
- FDFMTTRK,
- FDFMTEND,
- FDSETEMSGTRESH,
- FDFLUSH,
- FDSETMAXERRS,
- FDGETMAXERRS,
- FDGETDRVTYP,
- FDSETDRVPRM,
- FDGETDRVPRM,
- FDGETDRVSTAT,
- FDPOLLDRVSTAT,
- FDRESET,
- FDGETFDCSTAT,
- FDWERRORCLR,
- FDWERRORGET,
- FDRAWCMD,
- FDEJECT,
- FDTWADDLE
-};
-
-static inline int normalize_ioctl(int *cmd, int *size)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(ioctl_table); i++) {
- if ((*cmd & 0xffff) == (ioctl_table[i] & 0xffff)){
- *size = _IOC_SIZE(*cmd);
- *cmd = ioctl_table[i];
- if (*size > _IOC_SIZE(*cmd)) {
- printk("ioctl not yet supported\n");
- return -EFAULT;
- }
- return 0;
- }
- }
- return -EINVAL;
-}
-
-static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
-{
- if (type)
- *g = &floppy_type[type];
- else {
- LOCK_FDC(drive,0);
- CALL(poll_drive(0,0));
- process_fd_request();
- *g = current_type[drive];
- }
- if (!*g)
- return -ENODEV;
- return 0;
-}
-
-static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long param)
-{
-#define FD_IOCTL_ALLOWED ((filp) && (filp)->private_data)
-#define OUT(c,x) case c: outparam = (const char *) (x); break
-#define IN(c,x,tag) case c: *(x) = inparam. tag ; return 0
-
- int drive = (long)inode->i_bdev->bd_disk->private_data;
- int i, type = ITYPE(UDRS->fd_device);
- int ret;
- int size;
- union inparam {
- struct floppy_struct g; /* geometry */
- struct format_descr f;
- struct floppy_max_errors max_errors;
- struct floppy_drive_params dp;
- } inparam; /* parameters coming from user space */
- const char *outparam; /* parameters passed back to user space */
-
- /* convert compatibility eject ioctls into floppy eject ioctl.
- * We do this in order to provide a means to eject floppy disks before
- * installing the new fdutils package */
- if (cmd == CDROMEJECT || /* CD-ROM eject */
- cmd == 0x6470 /* SunOS floppy eject */) {
- DPRINT("obsolete eject ioctl\n");
- DPRINT("please use floppycontrol --eject\n");
- cmd = FDEJECT;
- }
-
- /* generic block device ioctls */
- switch(cmd) {
- /* the following have been inspired by the corresponding
- * code for other block devices. */
- struct floppy_struct *g;
- case HDIO_GETGEO:
- {
- struct hd_geometry loc;
- ECALL(get_floppy_geometry(drive, type, &g));
- loc.heads = g->head;
- loc.sectors = g->sect;
- loc.cylinders = g->track;
- loc.start = 0;
- return _COPYOUT(loc);
- }
- }
-
- /* convert the old style command into a new style command */
- if ((cmd & 0xff00) == 0x0200) {
- ECALL(normalize_ioctl(&cmd, &size));
- } else
- return -EINVAL;
-
- /* permission checks */
- if (((cmd & 0x40) && !FD_IOCTL_ALLOWED) ||
- ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
- return -EPERM;
-
- /* copyin */
- CLEARSTRUCT(&inparam);
- if (_IOC_DIR(cmd) & _IOC_WRITE)
- ECALL(fd_copyin((void *)param, &inparam, size))
-
- switch (cmd) {
- case FDEJECT:
- if (UDRS->fd_ref != 1)
- /* somebody else has this drive open */
- return -EBUSY;
- LOCK_FDC(drive,1);
-
- /* do the actual eject. Fails on
- * non-Sparc architectures */
- ret=fd_eject(UNIT(drive));
-
- USETF(FD_DISK_CHANGED);
- USETF(FD_VERIFY);
- process_fd_request();
- return ret;
- case FDCLRPRM:
- LOCK_FDC(drive,1);
- current_type[drive] = NULL;
- floppy_sizes[drive] = MAX_DISK_SIZE << 1;
- UDRS->keep_data = 0;
- return invalidate_drive(inode->i_bdev);
- case FDSETPRM:
- case FDDEFPRM:
- return set_geometry(cmd, & inparam.g,
- drive, type, inode->i_bdev);
- case FDGETPRM:
- ECALL(get_floppy_geometry(drive, type,
- (struct floppy_struct**)
- &outparam));
- break;
-
- case FDMSGON:
- UDP->flags |= FTD_MSG;
- return 0;
- case FDMSGOFF:
- UDP->flags &= ~FTD_MSG;
- return 0;
-
- case FDFMTBEG:
- LOCK_FDC(drive,1);
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- if (ret & FD_VERIFY) {
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- }
-
- if (ret & FD_VERIFY) {
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- }
-
- if (ret & FD_VERIFY) {
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- }
-
- if (ret & FD_VERIFY) {
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- }
-
- if(ret & FD_VERIFY){
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- ret = UDRS->flags;
- }
- process_fd_request();
- if (ret & FD_VERIFY)
- return -ENODEV;
- if (!(ret & FD_DISK_WRITABLE))
- return -EROFS;
- return 0;
- case FDFMTTRK:
- if (UDRS->fd_ref != 1)
- return -EBUSY;
- return do_format(drive, &inparam.f);
- case FDFMTEND:
- case FDFLUSH:
- LOCK_FDC(drive,1);
- return invalidate_drive(inode->i_bdev);
-
- case FDSETEMSGTRESH:
- UDP->max_errors.reporting =
- (unsigned short) (param & 0x0f);
- return 0;
- OUT(FDGETMAXERRS, &UDP->max_errors);
- IN(FDSETMAXERRS, &UDP->max_errors, max_errors);
-
- case FDGETDRVTYP:
- outparam = drive_name(type,drive);
- SUPBOUND(size,strlen(outparam)+1);
- break;
-
- IN(FDSETDRVPRM, UDP, dp);
- OUT(FDGETDRVPRM, UDP);
-
- case FDPOLLDRVSTAT:
- LOCK_FDC(drive,1);
- CALL(poll_drive(1, FD_RAW_NEED_DISK));
- process_fd_request();
- /* fall through */
- OUT(FDGETDRVSTAT, UDRS);
-
- case FDRESET:
- return user_reset_fdc(drive, (int)param, 1);
-
- OUT(FDGETFDCSTAT,UFDCS);
-
- case FDWERRORCLR:
- CLEARSTRUCT(UDRWE);
- return 0;
- OUT(FDWERRORGET,UDRWE);
-
- case FDRAWCMD:
- if (type)
- return -EINVAL;
- LOCK_FDC(drive,1);
- set_floppy(drive);
- CALL(i = raw_cmd_ioctl(cmd,(void *) param));
- process_fd_request();
- return i;
-
- case FDTWADDLE:
- LOCK_FDC(drive,1);
- twaddle();
- process_fd_request();
- return 0;
-
- default:
- return -EINVAL;
- }
-
- if (_IOC_DIR(cmd) & _IOC_READ)
- return fd_copyout((void *)param, outparam, size);
- else
- return 0;
-#undef OUT
-#undef IN
-}
-
-static void __init config_types(void)
-{
- int first=1;
- int drive;
- extern struct fd_info {
- unsigned char dummy[4 * 6];
- unsigned char fd_types[8];
- } drive_info;
-
- for (drive = 0; drive < 4; drive++)
- UDP->cmos = drive_info.fd_types[drive];
-
- /* XXX */
- /* additional physical CMOS drive detection should go here */
-
- for (drive=0; drive < N_DRIVE; drive++){
- unsigned int type = UDP->cmos;
- struct floppy_drive_params *params;
- const char *name = NULL;
- static char temparea[32];
-
- if (type < NUMBER(default_drive_params)) {
- params = &default_drive_params[type].params;
- if (type) {
- name = default_drive_params[type].name;
- allowed_drive_mask |= 1 << drive;
- }
- else
- allowed_drive_mask &= ~(1 << drive);
- } else {
- params = &default_drive_params[0].params;
- sprintf(temparea, "unknown type %d (usb?)", type);
- name = temparea;
- }
- if (name) {
- const char * prepend = ",";
- if (first) {
- prepend = KERN_INFO "Floppy drive(s):";
- first = 0;
- }
- printk("%s fd%d is %s", prepend, drive, name);
- register_devfs_entries (drive);
- }
- *UDP = *params;
- }
- if (!first)
- printk("\n");
-}
-
-static int floppy_release(struct inode * inode, struct file * filp)
-{
- int drive = (long)inode->i_bdev->bd_disk->private_data;
-
- down(&open_lock);
- if (UDRS->fd_ref < 0)
- UDRS->fd_ref=0;
- else if (!UDRS->fd_ref--) {
- DPRINT("floppy_release with fd_ref == 0");
- UDRS->fd_ref = 0;
- }
- if (!UDRS->fd_ref)
- opened_bdev[drive] = NULL;
- floppy_release_irq_and_dma();
- up(&open_lock);
- return 0;
-}
-
-/*
- * floppy_open check for aliasing (/dev/fd0 can be the same as
- * /dev/PS0 etc), and disallows simultaneous access to the same
- * drive with different device numbers.
- */
-#define RETERR(x) do{floppy_release(inode,filp); return -(x);}while(0)
-
-static int floppy_open(struct inode * inode, struct file * filp)
-{
- int drive = (long)inode->i_bdev->bd_disk->private_data;
- int old_dev;
- int try;
- int res = -EBUSY;
- char *tmp;
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy open: start\n");
-#endif
- filp->private_data = (void*) 0;
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy open: drive=%d, current_drive=%d, UDP->cmos=%d\n"
- "floppy open: FDCS={spec1=%d, spec2=%d, dtr=%d, version=%d, dor=%d, address=%lu}\n",
- drive, current_drive, UDP->cmos, FDCS->spec1, FDCS->spec2,
- FDCS->dtr, FDCS->version, FDCS->dor, FDCS->address);
- if (_floppy) {
- printk("floppy open: _floppy={size=%d, sect=%d, head=%d, track=%d, spec1=%d}\n",
- _floppy->size, _floppy->sect, _floppy->head,
- _floppy->track, _floppy->spec1);
- } else {
- printk("floppy open: _floppy=NULL\n");
- }
-#endif /* PC9800_DEBUG_FLOPPY */
-
- down(&open_lock);
- old_dev = UDRS->fd_device;
- if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
- goto out2;
-
- if (!UDRS->fd_ref && (UDP->flags & FD_BROKEN_DCL)){
- USETF(FD_DISK_CHANGED);
- USETF(FD_VERIFY);
- }
-
- if (UDRS->fd_ref == -1 ||
- (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
- goto out2;
-
- if (floppy_grab_irq_and_dma())
- goto out2;
-
- if (filp->f_flags & O_EXCL)
- UDRS->fd_ref = -1;
- else
- UDRS->fd_ref++;
-
- opened_bdev[drive] = inode->i_bdev;
-
- res = -ENXIO;
-
- if (!floppy_track_buffer){
- /* if opening an ED drive, reserve a big buffer,
- * else reserve a small one */
- if ((UDP->cmos == 6) || (UDP->cmos == 5))
- try = 64; /* Only 48 actually useful */
- else
- try = 32; /* Only 24 actually useful */
-
- tmp=(char *)fd_dma_mem_alloc(1024 * try);
- if (!tmp && !floppy_track_buffer) {
- try >>= 1; /* buffer only one side */
- INFBOUND(try, 16);
- tmp= (char *)fd_dma_mem_alloc(1024*try);
- }
- if (!tmp && !floppy_track_buffer) {
- fallback_on_nodma_alloc(&tmp, 2048 * try);
- }
- if (!tmp && !floppy_track_buffer) {
- DPRINT("Unable to allocate DMA memory\n");
- goto out;
- }
- if (floppy_track_buffer) {
- if (tmp)
- fd_dma_mem_free((unsigned long)tmp,try*1024);
- } else {
- buffer_min = buffer_max = -1;
- floppy_track_buffer = tmp;
- max_buffer_sectors = try;
- }
- }
-
- UDRS->fd_device = iminor(inode);
- set_capacity(disks[drive], floppy_sizes[iminor(inode)]);
- if (old_dev != -1 && old_dev != iminor(inode)) {
- if (buffer_drive == drive)
- buffer_track = -1;
- }
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy open: floppy.c:%d passed\n", __LINE__);
-#endif
-
-
- /* Allow ioctls if we have write-permissions even if read-only open.
- * Needed so that programs such as fdrawcmd still can work on write
- * protected disks */
- if (filp->f_mode & 2 || permission(filp->f_dentry->d_inode,2,NULL) == 0)
- filp->private_data = (void*) 8;
-
- if (UFDCS->rawcmd == 1)
- UFDCS->rawcmd = 2;
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy open: floppy.c:%d passed\n", __LINE__);
-#endif
-
- if (!(filp->f_flags & O_NDELAY)) {
- if (filp->f_mode & 3) {
- UDRS->last_checked = 0;
- check_disk_change(inode->i_bdev);
- if (UTESTF(FD_DISK_CHANGED))
- goto out;
- }
- res = -EROFS;
- if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
- goto out;
-#ifdef PC9800_DEBUG_FLOPPY
- printk("floppy open: end normally\n");
-#endif
- }
- up(&open_lock);
- return 0;
-out:
- if (UDRS->fd_ref < 0)
- UDRS->fd_ref=0;
- else
- UDRS->fd_ref--;
- if (!UDRS->fd_ref)
- opened_bdev[drive] = NULL;
- floppy_release_irq_and_dma();
-out2:
- up(&open_lock);
- return res;
-}
-
-/*
- * Check if the disk has been changed or if a change has been faked.
- */
-static int check_floppy_change(struct gendisk *disk)
-{
- int drive = (long)disk->private_data;
-
-#ifdef PC9800_DEBUG_FLOPPY
- printk("check_floppy_change: MINOR=%d\n", minor(dev));
-#endif
-
- if (UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY))
- return 1;
-
- if (UDP->checkfreq < (int)(jiffies - UDRS->last_checked)) {
- if(floppy_grab_irq_and_dma()) {
- return 1;
- }
-
- lock_fdc(drive,0);
- poll_drive(0,0);
- process_fd_request();
- floppy_release_irq_and_dma();
- }
-
- if (UTESTF(FD_DISK_CHANGED) ||
- UTESTF(FD_VERIFY) ||
- test_bit(drive, &fake_change) ||
- (!ITYPE(UDRS->fd_device) && !current_type[drive]))
- return 1;
- return 0;
-}
-
-/*
- * This implements "read block 0" for floppy_revalidate().
- * Needed for format autodetection, checking whether there is
- * a disk in the drive, and whether that disk is writable.
- */
-
-static int floppy_rb0_complete(struct bio *bio, unsigned int bytes_done, int err)
-{
- if (bio->bi_size)
- return 1;
-
- complete((struct completion*)bio->bi_private);
- return 0;
-}
-
-static int __floppy_read_block_0(struct block_device *bdev)
-{
- struct bio bio;
- struct bio_vec bio_vec;
- struct completion complete;
- struct page *page;
- size_t size;
-
- page = alloc_page(GFP_NOIO);
- if (!page) {
- process_fd_request();
- return -ENOMEM;
- }
-
- size = bdev->bd_block_size;
- if (!size)
- size = 1024;
-
- bio_init(&bio);
- bio.bi_io_vec = &bio_vec;
- bio_vec.bv_page = page;
- bio_vec.bv_len = size;
- bio_vec.bv_offset = 0;
- bio.bi_vcnt = 1;
- bio.bi_idx = 0;
- bio.bi_size = size;
- bio.bi_bdev = bdev;
- bio.bi_sector = 0;
- init_completion(&complete);
- bio.bi_private = &complete;
- bio.bi_end_io = floppy_rb0_complete;
-
- submit_bio(READ, &bio);
- generic_unplug_device(bdev_get_queue(bdev));
- process_fd_request();
- wait_for_completion(&complete);
-
- __free_page(page);
-
- return 0;
-}
-
-/* revalidate the floppy disk, i.e. trigger format autodetection by reading
- * the bootblock (block 0). "Autodetection" is also needed to check whether
- * there is a disk in the drive at all... Thus we also do it for fixed
- * geometry formats */
-static int floppy_revalidate(struct gendisk *disk)
-{
- int drive=(long)disk->private_data;
-#define NO_GEOM (!current_type[drive] && !ITYPE(UDRS->fd_device))
- int cf;
- int res = 0;
-
- if (UTESTF(FD_DISK_CHANGED) ||
- UTESTF(FD_VERIFY) ||
- test_bit(drive, &fake_change) ||
- NO_GEOM){
- if(usage_count == 0) {
- printk("VFS: revalidate called on non-open device.\n");
- return -EFAULT;
- }
- lock_fdc(drive,0);
- cf = UTESTF(FD_DISK_CHANGED) || UTESTF(FD_VERIFY);
- if (!(cf || test_bit(drive, &fake_change) || NO_GEOM)){
- process_fd_request(); /*already done by another thread*/
- return 0;
- }
- UDRS->maxblock = 0;
- UDRS->maxtrack = 0;
- if (buffer_drive == drive)
- buffer_track = -1;
- clear_bit(drive, &fake_change);
- UCLEARF(FD_DISK_CHANGED);
- if (cf)
- UDRS->generation++;
- if (NO_GEOM){
- /* auto-sensing */
- res = __floppy_read_block_0(opened_bdev[drive]);
- } else {
- if (cf)
- poll_drive(0, FD_RAW_NEED_DISK);
- process_fd_request();
- }
- }
- set_capacity(disk, floppy_sizes[UDRS->fd_device]);
- return res;
-}
-
-static struct block_device_operations floppy_fops = {
- .owner = THIS_MODULE,
- .open = floppy_open,
- .release = floppy_release,
- .ioctl = fd_ioctl,
- .media_changed = check_floppy_change,
- .revalidate_disk= floppy_revalidate,
-};
-
-static char *table[] =
-{"",
-#if 0
- "d360",
-#else
- "h1232",
-#endif
- "h1200", "u360", "u720", "h360", "h720",
- "u1440", "u2880", "CompaQ", "h1440", "u1680", "h410",
- "u820", "h1476", "u1722", "h420", "u830", "h1494", "u1743",
- "h880", "u1040", "u1120", "h1600", "u1760", "u1920",
- "u3200", "u3520", "u3840", "u1840", "u800", "u1600",
-NULL
-};
-
-static int t360[] = {
- 1,0
-};
-static int t1200[] = {
- 2,5,6,10,12,14,16,18,20,23,0
-};
-static int t3in[] = {
- 8, 9,26,27,28, 7,11,15,19,24,25,
- 29,31, 3, 4,13,17,21,22,30, 0
-};
-
-static int *table_sup[] = {
- NULL, t360, t1200, t3in+5+8, t3in+5, t3in, t3in
-};
-
-static void __init register_devfs_entries (int drive)
-{
- int base_minor = (drive < 4) ? drive : (124 + drive);
-
- if (UDP->cmos < NUMBER(default_drive_params)) {
- int i = 0;
- do {
- int minor = base_minor + (table_sup[UDP->cmos][i] << 2);
-
- devfs_mk_bdev(MKDEV(FLOPPY_MAJOR, minor),
- S_IFBLK|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP,
- "floppy/%d%s",
- drive, table[table_sup[UDP->cmos][i]]);
- } while (table_sup[UDP->cmos][i++]);
- }
-}
-
-/*
- * Floppy Driver initialization
- * =============================
- */
-
-static inline char __init get_fdc_version(void)
-{
- return FDC_8272A;
-}
-
-/* lilo configuration */
-
-static void __init floppy_set_flags(int *ints,int param, int param2)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(default_drive_params); i++){
- if (param)
- default_drive_params[i].params.flags |= param2;
- else
- default_drive_params[i].params.flags &= ~param2;
- }
- DPRINT("%s flag 0x%x\n", param2 ? "Setting" : "Clearing", param);
-}
-
-static void __init daring(int *ints,int param, int param2)
-{
- int i;
-
- for (i=0; i < ARRAY_SIZE(default_drive_params); i++){
- if (param){
- default_drive_params[i].params.select_delay = 0;
- default_drive_params[i].params.flags |= FD_SILENT_DCL_CLEAR;
- } else {
- default_drive_params[i].params.select_delay = 2*HZ/100;
- default_drive_params[i].params.flags &= ~FD_SILENT_DCL_CLEAR;
- }
- }
- DPRINT("Assuming %s floppy hardware\n", param ? "standard" : "broken");
-}
-
-static void __init set_cmos(int *ints, int dummy, int dummy2)
-{
- int current_drive=0;
-
- if (ints[0] != 2){
- DPRINT("wrong number of parameters for CMOS\n");
- return;
- }
- current_drive = ints[1];
- if (current_drive < 0 || current_drive >= 8){
- DPRINT("bad drive for set_cmos\n");
- return;
- }
-#if N_FDC > 1
- if (current_drive >= 4 && !FDC2)
- FDC2 = 0x370;
-#endif
- DP->cmos = ints[2];
- DPRINT("setting CMOS code to %d\n", ints[2]);
-}
-
-static struct param_table {
- const char *name;
- void (*fn)(int *ints, int param, int param2);
- int *var;
- int def_param;
- int param2;
-} config_params[]={
- { "allowed_drive_mask", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */
- { "all_drives", 0, &allowed_drive_mask, 0xff, 0 }, /* obsolete */
- { "irq", 0, &FLOPPY_IRQ, DEFAULT_FLOPPY_IRQ, 0 },
- { "dma", 0, &FLOPPY_DMA, DEFAULT_FLOPPY_DMA, 0 },
-
- { "daring", daring, 0, 1, 0},
-#if N_FDC > 1
- { "two_fdc", 0, &FDC2, 0x370, 0 },
- { "one_fdc", 0, &FDC2, 0, 0 },
-#endif
- { "broken_dcl", floppy_set_flags, 0, 1, FD_BROKEN_DCL },
- { "messages", floppy_set_flags, 0, 1, FTD_MSG },
- { "silent_dcl_clear", floppy_set_flags, 0, 1, FD_SILENT_DCL_CLEAR },
- { "debug", floppy_set_flags, 0, 1, FD_DEBUG },
-
- { "nodma", 0, &can_use_virtual_dma, 1, 0 },
- { "yesdma", 0, &can_use_virtual_dma, 0, 0 },
-
- { "fifo_depth", 0, &fifo_depth, 0xa, 0 },
- { "nofifo", 0, &no_fifo, 0x20, 0 },
- { "usefifo", 0, &no_fifo, 0, 0 },
-
- { "cmos", set_cmos, 0, 0, 0 },
- { "slow", 0, &slow_floppy, 1, 0 },
-
- { "unexpected_interrupts", 0, &print_unex, 1, 0 },
- { "no_unexpected_interrupts", 0, &print_unex, 0, 0 },
-
- EXTRA_FLOPPY_PARAMS
-};
-
-static int __init floppy_setup(char *str)
-{
- int i;
- int param;
- int ints[11];
-
- str = get_options(str,ARRAY_SIZE(ints),ints);
- if (str) {
- for (i=0; i< ARRAY_SIZE(config_params); i++){
- if (strcmp(str,config_params[i].name) == 0){
- if (ints[0])
- param = ints[1];
- else
- param = config_params[i].def_param;
- if (config_params[i].fn)
- config_params[i].
- fn(ints,param,
- config_params[i].param2);
- if (config_params[i].var) {
- DPRINT("%s=%d\n", str, param);
- *config_params[i].var = param;
- }
- return 1;
- }
- }
- }
- if (str) {
- DPRINT("unknown floppy option [%s]\n", str);
-
- DPRINT("allowed options are:");
- for (i=0; i< ARRAY_SIZE(config_params); i++)
- printk(" %s",config_params[i].name);
- printk("\n");
- } else
- DPRINT("botched floppy option\n");
- DPRINT("Read linux/Documentation/floppy.txt\n");
- return 0;
-}
-
-static int have_no_fdc= -ENODEV;
-
-static void floppy_device_release(struct device *dev)
-{
- complete(&device_release);
-}
-
-static struct platform_device floppy_device = {
- .name = "floppy",
- .id = 0,
- .dev = {
- .release = floppy_device_release,
- },
-};
-
-static struct kobject *floppy_find(dev_t dev, int *part, void *data)
-{
- int drive = (*part&3) | ((*part&0x80) >> 5);
- if (drive >= N_DRIVE ||
- !(allowed_drive_mask & (1 << drive)) ||
- fdc_state[FDC(drive)].version == FDC_NONE)
- return NULL;
- if (((*part>>2) & 0x1f) >= NUMBER(floppy_type))
- return NULL;
- *part = 0;
- return get_disk(disks[drive]);
-}
-
-int __init floppy_init(void)
-{
- int i,unit,drive;
- int err;
-
- raw_cmd = NULL;
- FDC1 = 0x90;
-
- for (i=0; i<N_DRIVE; i++) {
- disks[i] = alloc_disk(1);
- if (!disks[i])
- goto Enomem;
- }
-
- devfs_mk_dir (NULL, "floppy", NULL);
- if ((err = register_blkdev(FLOPPY_MAJOR,"fd")))
- goto out;
-
- for (i=0; i<N_DRIVE; i++) {
- disks[i]->major = FLOPPY_MAJOR;
- disks[i]->first_minor = TOMINOR(i);
- disks[i]->fops = &floppy_fops;
- sprintf(disks[i]->disk_name, "fd%d", i);
- }
-
- blk_register_region(MKDEV(FLOPPY_MAJOR, 0), 256, THIS_MODULE,
- floppy_find, NULL, NULL);
-
- for (i=0; i<256; i++)
- if (ITYPE(i))
- floppy_sizes[i] = floppy_type[ITYPE(i)].size;
- else
- floppy_sizes[i] = MAX_DISK_SIZE << 1;
-
- floppy_queue = blk_init_queue(do_fd_request, &floppy_lock);
- if (!floppy_queue)
- goto out_queue;
-
- reschedule_timeout(MAXTIMEOUT, "floppy init", MAXTIMEOUT);
- config_types();
-
- for (i = 0; i < N_FDC; i++) {
- fdc = i;
- CLEARSTRUCT(FDCS);
- FDCS->dtr = -1;
- FDCS->dor = 0;
- }
-
- if ((fd_inb(FD_MODE_CHANGE) & 1) == 0)
- FDC1 = 0xc8;
-
- use_virtual_dma = can_use_virtual_dma & 1;
- fdc_state[0].address = FDC1;
- if (fdc_state[0].address == -1) {
- err = -ENODEV;
- goto out1;
- }
-#if N_FDC > 1
- fdc_state[1].address = FDC2;
-#endif
-
- fdc = 0; /* reset fdc in case of unexpected interrupt */
- if (floppy_grab_irq_and_dma()){
- err = -EBUSY;
- goto out1;
- }
-
- /* initialise drive state */
- for (drive = 0; drive < N_DRIVE; drive++) {
- CLEARSTRUCT(UDRS);
- CLEARSTRUCT(UDRWE);
- USETF(FD_DISK_NEWCHANGE);
- USETF(FD_DISK_CHANGED);
- USETF(FD_VERIFY);
- UDRS->fd_device = -1;
- floppy_track_buffer = NULL;
- max_buffer_sectors = 0;
- }
-
- for (i = 0; i < N_FDC; i++) {
- fdc = i;
- FDCS->driver_version = FD_DRIVER_VERSION;
- for (unit=0; unit<4; unit++)
- FDCS->track[unit] = 0;
- if (FDCS->address == -1)
- continue;
- FDCS->rawcmd = 2;
- user_reset_fdc(-1, FD_RESET_ALWAYS, 0);
-
- /* Try to determine the floppy controller type */
- FDCS->version = get_fdc_version();
- if (FDCS->version == FDC_NONE){
- /* free ioports reserved by floppy_grab_irq_and_dma() */
- release_region(FDCS->address, 1);
- release_region(FDCS->address + 2, 1);
- release_region(FDCS->address + 4, 1);
- release_region(0xbe, 1);
- release_region(0x4be, 1);
- FDCS->address = -1;
- continue;
- }
- if (can_use_virtual_dma == 2 && FDCS->version < FDC_82072A)
- can_use_virtual_dma = 0;
-
- have_no_fdc = 0;
- /* Not all FDCs seem to be able to handle the version command
- * properly, so force a reset for the standard FDC clones,
- * to avoid interrupt garbage.
- */
- user_reset_fdc(-1,FD_RESET_ALWAYS,0);
- }
- fdc=0;
- del_timer(&fd_timeout);
- current_drive = 0;
- floppy_release_irq_and_dma();
-#if 0 /* no message */
- initialising=0;
-#endif
- if (have_no_fdc) {
- DPRINT("no floppy controllers found\n");
- flush_scheduled_work();
- if (usage_count)
- floppy_release_irq_and_dma();
- err = have_no_fdc;
- goto out2;
- }
-
- for (drive = 0; drive < N_DRIVE; drive++) {
- init_timer(&motor_off_timer[drive]);
- motor_off_timer[drive].data = drive;
- motor_off_timer[drive].function = motor_off_callback;
- if (!(allowed_drive_mask & (1 << drive)))
- continue;
- if (fdc_state[FDC(drive)].version == FDC_NONE)
- continue;
- /* to be cleaned up... */
- disks[drive]->private_data = (void*)(long)drive;
- disks[drive]->queue = floppy_queue;
- add_disk(disks[drive]);
- }
-
- platform_device_register(&floppy_device);
- return 0;
-
-out1:
- del_timer_sync(&fd_timeout);
-out2:
- blk_cleanup_queue(floppy_queue);
-out_queue:
- blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
- unregister_blkdev(FLOPPY_MAJOR,"fd");
-out:
- for (i=0; i<N_DRIVE; i++)
- put_disk(disks[i]);
- return err;
-
-Enomem:
- while (i--)
- put_disk(disks[i]);
- return -ENOMEM;
-}
-
-static spinlock_t floppy_usage_lock = SPIN_LOCK_UNLOCKED;
-
-static int floppy_grab_irq_and_dma(void)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&floppy_usage_lock, flags);
- if (usage_count++){
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- return 0;
- }
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- if (fd_request_irq()) {
- DPRINT("Unable to grab IRQ%d for the floppy driver\n",
- FLOPPY_IRQ);
- spin_lock_irqsave(&floppy_usage_lock, flags);
- usage_count--;
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- return -1;
- }
- if (fd_request_dma()) {
- DPRINT("Unable to grab DMA%d for the floppy driver\n",
- FLOPPY_DMA);
- fd_free_irq();
- spin_lock_irqsave(&floppy_usage_lock, flags);
- usage_count--;
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- return -1;
- }
-
- for (fdc=0; fdc< N_FDC; fdc++){
- if (FDCS->address != -1){
- static char floppy[] = "floppy";
- if (!request_region(FDCS->address, 1, floppy))
- goto cleanup0;
-
- if (!request_region(FDCS->address + 2, 1, floppy)) {
- release_region(FDCS->address, 1);
- goto cleanup0;
- }
-
- if (!request_region(FDCS->address + 4, 1, floppy)) {
- release_region(FDCS->address, 1);
- release_region(FDCS->address + 2, 1);
- goto cleanup0;
- }
-
- if (fdc == 0) { /* internal FDC */
- if (request_region(0xbe, 1, "floppy mode change")) {
- if (request_region(0x4be, 1, "floppy ex. mode change"))
- continue;
- else
- DPRINT("Floppy io-port 0x4be in use\n");
-
- release_region(0xbe, 1);
- } else
- DPRINT("Floppy io-port 0xbe in use\n");
-
- release_region(FDCS->address, 1);
- release_region(FDCS->address + 2, 1);
- release_region(FDCS->address + 4, 1);
- }
-
- goto cleanup1;
- }
- }
- for (fdc=0; fdc< N_FDC; fdc++){
- if (FDCS->address != -1){
- reset_fdc_info(1);
- fd_outb(FDCS->dor, FD_MODE);
- }
- }
- fdc = 0;
- fd_outb((FDCS->dor & 8), FD_MODE);
-
- for (fdc = 0; fdc < N_FDC; fdc++)
- if (FDCS->address != -1)
- fd_outb(FDCS->dor, FD_MODE);
- /*
- * The driver will try and free resources and relies on us
- * to know if they were allocated or not.
- */
- fdc = 0;
- irqdma_allocated = 1;
- return 0;
-
-cleanup0:
- DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address);
-cleanup1:
- fd_free_irq();
- fd_free_dma();
- while(--fdc >= 0) {
- release_region(FDCS->address, 1);
- release_region(FDCS->address + 2, 1);
- release_region(FDCS->address + 4, 1);
- if (fdc == 0) {
- release_region(0x00be, 1);
- release_region(0x04be, 1);
- }
- }
- spin_lock_irqsave(&floppy_usage_lock, flags);
- usage_count--;
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- return -1;
-}
-
-static void floppy_release_irq_and_dma(void)
-{
- int old_fdc;
-#ifdef FLOPPY_SANITY_CHECK
- int drive;
-#endif
- long tmpsize;
- unsigned long tmpaddr;
- unsigned long flags;
-
- spin_lock_irqsave(&floppy_usage_lock, flags);
- if (--usage_count){
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- return;
- }
- spin_unlock_irqrestore(&floppy_usage_lock, flags);
- if(irqdma_allocated)
- {
- fd_disable_dma();
- fd_free_dma();
- fd_free_irq();
- irqdma_allocated=0;
- }
- fd_outb(0, FD_MODE);
- floppy_enable_hlt();
-
- if (floppy_track_buffer && max_buffer_sectors) {
- tmpsize = max_buffer_sectors*1024;
- tmpaddr = (unsigned long)floppy_track_buffer;
- floppy_track_buffer = NULL;
- max_buffer_sectors = 0;
- buffer_min = buffer_max = -1;
- fd_dma_mem_free(tmpaddr, tmpsize);
- }
-
-#ifdef FLOPPY_SANITY_CHECK
- for (drive=0; drive < N_FDC * 4; drive++)
- if (timer_pending(motor_off_timer + drive))
- printk("motor off timer %d still active\n", drive);
-
- if (timer_pending(&fd_timeout))
- printk("floppy timer still active:%s\n", timeout_message);
- if (timer_pending(&fd_timer))
- printk("auxiliary floppy timer still active\n");
- if (floppy_work.pending)
- printk("work still pending\n");
-#endif
- old_fdc = fdc;
- for (fdc = 0; fdc < N_FDC; fdc++)
- if (FDCS->address != -1) {
- release_region(FDCS->address, 1);
- release_region(FDCS->address + 2, 1);
- release_region(FDCS->address + 4, 1);
- if (fdc == 0) {
- release_region(0xbe, 1);
- release_region(0x4be, 1);
- }
- }
- fdc = old_fdc;
-}
-
-
-#ifdef MODULE
-
-char *floppy;
-
-static void unregister_devfs_entries (int drive)
-{
- int i;
-
- if (UDP->cmos < NUMBER(default_drive_params)) {
- i = 0;
- do {
- devfs_remove("floppy/%d%s", drive, table[table_sup[UDP->cmos][i]]);
- } while (table_sup[UDP->cmos][i++]);
- }
-}
-
-static void __init parse_floppy_cfg_string(char *cfg)
-{
- char *ptr;
-
- while(*cfg) {
- for(ptr = cfg;*cfg && *cfg != ' ' && *cfg != '\t'; cfg++);
- if (*cfg) {
- *cfg = '\0';
- cfg++;
- }
- if (*ptr)
- floppy_setup(ptr);
- }
-}
-
-int init_module(void)
-{
- printk(KERN_INFO "inserting floppy driver for " UTS_RELEASE "\n");
-
- if (floppy)
- parse_floppy_cfg_string(floppy);
- return floppy_init();
-}
-
-void cleanup_module(void)
-{
- int drive;
-
- init_completion(&device_release);
- platform_device_unregister(&floppy_device);
- blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
- unregister_blkdev(FLOPPY_MAJOR, "fd");
-
- for (drive = 0; drive < N_DRIVE; drive++) {
- del_timer_sync(&motor_off_timer[drive]);
-
- if ((allowed_drive_mask & (1 << drive)) &&
- fdc_state[FDC(drive)].version != FDC_NONE) {
- del_gendisk(disks[drive]);
- unregister_devfs_entries(drive);
- }
- put_disk(disks[drive]);
- }
- devfs_remove("floppy");
-
- del_timer_sync(&fd_timeout);
- del_timer_sync(&fd_timer);
- blk_cleanup_queue(floppy_queue);
-
- if (usage_count)
- floppy_release_irq_and_dma();
-
- /* eject disk, if any */
- fd_eject(0);
-
- wait_for_completion(&device_release);
-}
-
-MODULE_PARM(floppy,"s");
-MODULE_PARM(FLOPPY_IRQ,"i");
-MODULE_PARM(FLOPPY_DMA,"i");
-MODULE_AUTHOR("Osamu Tomita");
-MODULE_SUPPORTED_DEVICE("fd");
-MODULE_LICENSE("GPL");
-
-#else
-
-__setup ("floppy=", floppy_setup);
-module_init(floppy_init)
-#endif
+++ /dev/null
-/*
- * linux/drivers/char/busmouse.c
- *
- * Copyright (C) 1995 - 1998 Russell King <linux@arm.linux.org.uk>
- * Protocol taken from original busmouse.c
- * read() waiting taken from psaux.c
- *
- * Medium-level interface for quadrature or bus mice.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/mm.h>
-#include <linux/poll.h>
-#include <linux/miscdevice.h>
-#include <linux/random.h>
-#include <linux/init.h>
-#include <linux/smp_lock.h>
-
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include "busmouse.h"
-
-/* Uncomment this if your mouse drivers expect the kernel to
- * return with EAGAIN if the mouse does not have any events
- * available, even if the mouse is opened in blocking mode.
- * Please report use of this "feature" to the author using the
- * above address.
- */
-/*#define BROKEN_MOUSE*/
-
-struct busmouse_data {
- struct miscdevice miscdev;
- struct busmouse *ops;
- spinlock_t lock;
-
- wait_queue_head_t wait;
- struct fasync_struct *fasyncptr;
- char active;
- char buttons;
- char ready;
- int dxpos;
- int dypos;
-};
-
-#define NR_MICE 15
-#define FIRST_MOUSE 0
-#define DEV_TO_MOUSE(inode) MINOR_TO_MOUSE(iminor(inode))
-#define MINOR_TO_MOUSE(minor) ((minor) - FIRST_MOUSE)
-
-/*
- * List of mice and guarding semaphore. You must take the semaphore
- * before you take the misc device semaphore if you need both
- */
-
-static struct busmouse_data *busmouse_data[NR_MICE];
-static DECLARE_MUTEX(mouse_sem);
-
-/**
- * busmouse_add_movement - notification of a change of mouse position
- * @mousedev: mouse number
- * @dx: delta X movement
- * @dy: delta Y movement
- * @buttons: new button state
- *
- * Updates the mouse position and button information. The mousedev
- * parameter is the value returned from register_busmouse. The
- * movement information is updated, and the new button state is
- * saved. A waiting user thread is woken.
- */
-
-void busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons)
-{
- struct busmouse_data *mse = busmouse_data[mousedev];
- int changed;
-
- spin_lock(&mse->lock);
- changed = (dx != 0 || dy != 0 || mse->buttons != buttons);
-
- if (changed) {
- add_mouse_randomness((buttons << 16) + (dy << 8) + dx);
-
- mse->buttons = buttons;
- mse->dxpos += dx;
- mse->dypos += dy;
- mse->ready = 1;
-
- /*
- * keep dx/dy reasonable, but still able to track when X (or
- * whatever) must page or is busy (i.e. long waits between
- * reads)
- */
- if (mse->dxpos < -2048)
- mse->dxpos = -2048;
- if (mse->dxpos > 2048)
- mse->dxpos = 2048;
- if (mse->dypos < -2048)
- mse->dypos = -2048;
- if (mse->dypos > 2048)
- mse->dypos = 2048;
- }
-
- spin_unlock(&mse->lock);
-
- if (changed) {
- wake_up(&mse->wait);
-
- kill_fasync(&mse->fasyncptr, SIGIO, POLL_IN);
- }
-}
-
-/**
- * busmouse_add_movement - notification of a change of mouse position
- * @mousedev: mouse number
- * @dx: delta X movement
- * @dy: delta Y movement
- *
- * Updates the mouse position. The mousedev parameter is the value
- * returned from register_busmouse. The movement information is
- * updated, and a waiting user thread is woken.
- */
-
-void busmouse_add_movement(int mousedev, int dx, int dy)
-{
- struct busmouse_data *mse = busmouse_data[mousedev];
-
- busmouse_add_movementbuttons(mousedev, dx, dy, mse->buttons);
-}
-
-/**
- * busmouse_add_buttons - notification of a change of button state
- * @mousedev: mouse number
- * @clear: mask of buttons to clear
- * @eor: mask of buttons to change
- *
- * Updates the button state. The mousedev parameter is the value
- * returned from register_busmouse. The buttons are updated by:
- * new_state = (old_state & ~clear) ^ eor
- * A waiting user thread is woken up.
- */
-
-void busmouse_add_buttons(int mousedev, int clear, int eor)
-{
- struct busmouse_data *mse = busmouse_data[mousedev];
-
- busmouse_add_movementbuttons(mousedev, 0, 0, (mse->buttons & ~clear) ^ eor);
-}
-
-static int busmouse_fasync(int fd, struct file *filp, int on)
-{
- struct busmouse_data *mse = (struct busmouse_data *)filp->private_data;
- int retval;
-
- retval = fasync_helper(fd, filp, on, &mse->fasyncptr);
- if (retval < 0)
- return retval;
- return 0;
-}
-
-static int busmouse_release(struct inode *inode, struct file *file)
-{
- struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
- int ret = 0;
-
- lock_kernel();
- busmouse_fasync(-1, file, 0);
-
- down(&mouse_sem); /* to protect mse->active */
- if (--mse->active == 0) {
- if (mse->ops->release)
- ret = mse->ops->release(inode, file);
- module_put(mse->ops->owner);
- mse->ready = 0;
- }
- unlock_kernel();
- up( &mouse_sem);
-
- return ret;
-}
-
-static int busmouse_open(struct inode *inode, struct file *file)
-{
- struct busmouse_data *mse;
- unsigned int mousedev;
- int ret;
-
- mousedev = DEV_TO_MOUSE(inode);
- if (mousedev >= NR_MICE)
- return -EINVAL;
-
- down(&mouse_sem);
- mse = busmouse_data[mousedev];
- ret = -ENODEV;
- if (!mse || !mse->ops) /* shouldn't happen, but... */
- goto end;
-
- if (!try_module_get(mse->ops->owner))
- goto end;
-
- ret = 0;
- if (mse->ops->open) {
- ret = mse->ops->open(inode, file);
- if (ret)
- module_put(mse->ops->owner);
- }
-
- if (ret)
- goto end;
-
- file->private_data = mse;
-
- if (mse->active++)
- goto end;
-
- spin_lock_irq(&mse->lock);
-
- mse->ready = 0;
- mse->dxpos = 0;
- mse->dypos = 0;
- mse->buttons = mse->ops->init_button_state;
-
- spin_unlock_irq(&mse->lock);
-end:
- up(&mouse_sem);
- return ret;
-}
-
-static ssize_t busmouse_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
-{
- return -EINVAL;
-}
-
-static ssize_t busmouse_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
-{
- struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
- DECLARE_WAITQUEUE(wait, current);
- int dxpos, dypos, buttons;
-
- if (count < 3)
- return -EINVAL;
-
- spin_lock_irq(&mse->lock);
-
- if (!mse->ready) {
-#ifdef BROKEN_MOUSE
- spin_unlock_irq(&mse->lock);
- return -EAGAIN;
-#else
- if (file->f_flags & O_NONBLOCK) {
- spin_unlock_irq(&mse->lock);
- return -EAGAIN;
- }
-
- add_wait_queue(&mse->wait, &wait);
-repeat:
- set_current_state(TASK_INTERRUPTIBLE);
- if (!mse->ready && !signal_pending(current)) {
- spin_unlock_irq(&mse->lock);
- schedule();
- spin_lock_irq(&mse->lock);
- goto repeat;
- }
-
- current->state = TASK_RUNNING;
- remove_wait_queue(&mse->wait, &wait);
-
- if (signal_pending(current)) {
- spin_unlock_irq(&mse->lock);
- return -ERESTARTSYS;
- }
-#endif
- }
-
- dxpos = mse->dxpos;
- dypos = mse->dypos;
- buttons = mse->buttons;
-
- if (dxpos < -127)
- dxpos =- 127;
- if (dxpos > 127)
- dxpos = 127;
- if (dypos < -127)
- dypos =- 127;
- if (dypos > 127)
- dypos = 127;
-
- mse->dxpos -= dxpos;
- mse->dypos -= dypos;
-
- /* This is something that many drivers have apparantly
- * forgotten... If the X and Y positions still contain
- * information, we still have some info ready for the
- * user program...
- */
- mse->ready = mse->dxpos || mse->dypos;
-
- spin_unlock_irq(&mse->lock);
-
- /* Write out data to the user. Format is:
- * byte 0 - identifer (0x80) and (inverted) mouse buttons
- * byte 1 - X delta position +/- 127
- * byte 2 - Y delta position +/- 127
- */
- if (put_user((char)buttons | 128, buffer) ||
- put_user((char)dxpos, buffer + 1) ||
- put_user((char)dypos, buffer + 2))
- return -EFAULT;
-
- if (count > 3 && clear_user(buffer + 3, count - 3))
- return -EFAULT;
-
- file->f_dentry->d_inode->i_atime = CURRENT_TIME;
-
- return count;
-}
-
-/* No kernel lock held - fine */
-static unsigned int busmouse_poll(struct file *file, poll_table *wait)
-{
- struct busmouse_data *mse = (struct busmouse_data *)file->private_data;
-
- poll_wait(file, &mse->wait, wait);
-
- if (mse->ready)
- return POLLIN | POLLRDNORM;
-
- return 0;
-}
-
-struct file_operations busmouse_fops=
-{
- .owner = THIS_MODULE,
- .read = busmouse_read,
- .write = busmouse_write,
- .poll = busmouse_poll,
- .open = busmouse_open,
- .release = busmouse_release,
- .fasync = busmouse_fasync,
-};
-
-/**
- * register_busmouse - register a bus mouse interface
- * @ops: busmouse structure for the mouse
- *
- * Registers a mouse with the driver. The return is mouse number on
- * success and a negative errno code on an error. The passed ops
- * structure most not be freed until the mouser is unregistered
- */
-
-int register_busmouse(struct busmouse *ops)
-{
- unsigned int msedev = MINOR_TO_MOUSE(ops->minor);
- struct busmouse_data *mse;
- int ret = -EINVAL;
-
- if (msedev >= NR_MICE) {
- printk(KERN_ERR "busmouse: trying to allocate mouse on minor %d\n",
- ops->minor);
- goto out;
- }
-
- ret = -ENOMEM;
- mse = kmalloc(sizeof(*mse), GFP_KERNEL);
- if (!mse)
- goto out;
-
- down(&mouse_sem);
- ret = -EBUSY;
- if (busmouse_data[msedev])
- goto freemem;
-
- memset(mse, 0, sizeof(*mse));
-
- mse->miscdev.minor = ops->minor;
- mse->miscdev.name = ops->name;
- mse->miscdev.fops = &busmouse_fops;
- mse->ops = ops;
- mse->lock = (spinlock_t)SPIN_LOCK_UNLOCKED;
- init_waitqueue_head(&mse->wait);
-
-
- ret = misc_register(&mse->miscdev);
-
- if (ret < 0)
- goto freemem;
-
- busmouse_data[msedev] = mse;
- ret = msedev;
-out:
- up(&mouse_sem);
- return ret;
-
-
-freemem:
- kfree(mse);
- goto out;
-}
-
-/**
- * unregister_busmouse - unregister a bus mouse interface
- * @mousedev: Mouse number to release
- *
- * Unregister a previously installed mouse handler. The mousedev
- * passed is the return code from a previous call to register_busmouse
- */
-
-
-int unregister_busmouse(int mousedev)
-{
- int err = -EINVAL;
-
- if (mousedev < 0)
- return 0;
- if (mousedev >= NR_MICE) {
- printk(KERN_ERR "busmouse: trying to free mouse on"
- " mousedev %d\n", mousedev);
- return -EINVAL;
- }
-
- down(&mouse_sem);
-
- if (!busmouse_data[mousedev]) {
- printk(KERN_WARNING "busmouse: trying to free free mouse"
- " on mousedev %d\n", mousedev);
- goto fail;
- }
-
- if (busmouse_data[mousedev]->active) {
- printk(KERN_ERR "busmouse: trying to free active mouse"
- " on mousedev %d\n", mousedev);
- goto fail;
- }
-
- err = misc_deregister(&busmouse_data[mousedev]->miscdev);
-
- kfree(busmouse_data[mousedev]);
- busmouse_data[mousedev] = NULL;
-fail:
- up(&mouse_sem);
- return err;
-}
-
-EXPORT_SYMBOL(busmouse_add_movementbuttons);
-EXPORT_SYMBOL(busmouse_add_movement);
-EXPORT_SYMBOL(busmouse_add_buttons);
-EXPORT_SYMBOL(register_busmouse);
-EXPORT_SYMBOL(unregister_busmouse);
-
-MODULE_ALIAS_MISCDEV(BUSMOUSE_MINOR);
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * linux/drivers/char/busmouse.h
- *
- * Copyright (C) 1995 - 1998 Russell King
- *
- * Prototypes for generic busmouse interface
- */
-#ifndef BUSMOUSE_H
-#define BUSMOUSE_H
-
-struct busmouse {
- int minor;
- const char *name;
- struct module *owner;
- int (*open)(struct inode * inode, struct file * file);
- int (*release)(struct inode * inode, struct file * file);
- int init_button_state;
-};
-
-extern void busmouse_add_movementbuttons(int mousedev, int dx, int dy, int buttons);
-extern void busmouse_add_movement(int mousedev, int dx, int dy);
-extern void busmouse_add_buttons(int mousedev, int clear, int eor);
-
-extern int register_busmouse(struct busmouse *ops);
-extern int unregister_busmouse(int mousedev);
-
-#endif
+++ /dev/null
-/*
- * dz.c: Serial port driver for DECStations equiped
- * with the DZ chipset.
- *
- * Copyright (C) 1998 Olivier A. D. Lebaillif
- *
- * Email: olivier.lebaillif@ifrsys.com
- *
- * [31-AUG-98] triemer
- * Changed IRQ to use Harald's dec internals interrupts.h
- * removed base_addr code - moving address assignment to setup.c
- * Changed name of dz_init to rs_init to be consistent with tc code
- * [13-NOV-98] triemer fixed code to receive characters
- * after patches by harald to irq code.
- * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
- * field from "current" - somewhere between 2.1.121 and 2.1.131
-Qua Jun 27 15:02:26 BRT 2001
- * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
- *
- * Parts (C) 1999 David Airlie, airlied@linux.ie
- * [07-SEP-99] Bugfixes
- */
-
-/* #define DEBUG_DZ 1 */
-
-#include <linux/module.h>
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/mm.h>
-#include <linux/major.h>
-#include <linux/param.h>
-#include <linux/interrupt.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <asm-mips/wbflush.h>
-#include <asm/dec/interrupts.h> /* for definition of SERIAL */
-
-/* for definition of struct console */
-#ifdef CONFIG_SERIAL_CONSOLE
-#define CONSOLE_LINE (3)
-#endif /* ifdef CONFIG_SERIAL_CONSOLE */
-#if defined(CONFIG_SERIAL_CONSOLE) || defined(DEBUG_DZ)
-#include <linux/console.h>
-#endif /* if defined(CONFIG_SERIAL_CONSOLE) || defined(DEBUG_DZ) */
-
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-
-#include <asm/uaccess.h>
-#include <asm/irq.h>
-#include <asm/dec/machtype.h>
-#include <asm/dec/kn01.h>
-#include <asm/dec/kn02.h>
-
-#ifdef DEBUG_DZ
-#include <linux/ptrace.h>
-#include <linux/fs.h>
-#include <asm/bootinfo.h>
-
-extern int (*prom_printf) (char *,...);
-#endif
-
-
-
-#include "dz.h"
-
-#define DZ_INTR_DEBUG 1
-
-DECLARE_TASK_QUEUE(tq_serial);
-
-static struct dz_serial *lines[4];
-static unsigned char tmp_buffer[256];
-
-
-
-#ifdef DEBUG_DZ
-/*
- * debugging code to send out chars via prom
- */
-static void debug_console( const char *s,int count)
-{
- unsigned i;
-
- for (i = 0; i < count; i++) {
- if (*s == 10)
- prom_printf("%c", 13);
- prom_printf("%c", *s++);
- }
-}
-#endif
-
-/*
- * ------------------------------------------------------------
- * dz_in () and dz_out ()
- *
- * These routines are used to access the registers of the DZ
- * chip, hiding relocation differences between implementation.
- * ------------------------------------------------------------
- */
-
-static inline unsigned short dz_in (struct dz_serial *info, unsigned offset)
-{
- volatile u16 *addr = (volatile u16 *)(info->port + offset);
-
- return *addr;
-}
-
-static inline void dz_out (struct dz_serial *info, unsigned offset,
- unsigned short value)
-{
- volatile u16 *addr = (volatile u16 *)(info->port + offset);
- *addr = value;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_stop () and rs_start ()
- *
- * These routines are called before setting or resetting
- * tty->stopped. They enable or disable transmitter interrupts,
- * as necessary.
- * ------------------------------------------------------------
- */
-
-static void dz_stop (struct tty_struct *tty)
-{
- struct dz_serial *info;
- unsigned short mask, tmp;
-
- if (!tty)
- return;
-
- info = (struct dz_serial *)tty->driver_data;
-
- mask = 1 << info->line;
- tmp = dz_in (info, DZ_TCR); /* read the TX flag */
-
- tmp &= ~mask; /* clear the TX flag */
- dz_out (info, DZ_TCR, tmp);
-}
-
-static void dz_start (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
- unsigned short mask, tmp;
-
- mask = 1 << info->line;
- tmp = dz_in (info, DZ_TCR); /* read the TX flag */
-
- tmp |= mask; /* set the TX flag */
- dz_out (info, DZ_TCR, tmp);
-}
-
-/*
- * ------------------------------------------------------------
- * Here starts the interrupt handling routines. All of the
- * following subroutines are declared as inline and are folded
- * into dz_interrupt. They were separated out for readability's
- * sake.
- *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off. People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible. After you are done making modifications, it is not a bad
- * idea to do:
- *
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer dz.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- * ------------------------------------------------------------
- */
-
-/*
- * ------------------------------------------------------------
- * dz_sched_event ()
- *
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- * ------------------------------------------------------------
- */
-static inline void dz_sched_event (struct dz_serial *info, int event)
-{
- info->event |= 1 << event;
- queue_task(&info->tqueue, &tq_serial);
- mark_bh(SERIAL_BH);
-}
-
-/*
- * ------------------------------------------------------------
- * receive_char ()
- *
- * This routine deals with inputs from any lines.
- * ------------------------------------------------------------
- */
-static inline void receive_chars (struct dz_serial *info_in)
-{
- struct dz_serial *info;
- struct tty_struct *tty = 0;
- struct async_icount *icount;
- int ignore = 0;
- unsigned short status, tmp;
- unsigned char ch;
-
- /*
- * This code is going to be a problem... the call to tty_flip_buffer
- * is going to need to be rethought...
- */
- do {
- status = dz_in (info_in, DZ_RBUF);
- info = lines[LINE(status)];
-
- /* punt so we don't get duplicate characters */
- if (!(status & DZ_DVAL))
- goto ignore_char;
-
- ch = UCHAR(status); /* grab the char */
-
-#if 0
- if (info->is_console) {
- if (ch == 0)
- return; /* it's a break ... */
- }
-#endif
-
- tty = info->tty; /* now tty points to the proper dev */
- icount = &info->icount;
-
- if (!tty)
- break;
- if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
-
- *tty->flip.char_buf_ptr = ch;
- *tty->flip.flag_buf_ptr = 0;
- icount->rx++;
-
- /* keep track of the statistics */
- if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) {
- if (status & DZ_PERR) /* parity error */
- icount->parity++;
- else if (status & DZ_FERR) /* frame error */
- icount->frame++;
- if (status & DZ_OERR) /* overrun error */
- icount->overrun++;
-
- /*
- * Check to see if we should ignore the character and
- * mask off conditions that should be ignored
- */
-
- if (status & info->ignore_status_mask) {
- if (++ignore > 100)
- break;
- goto ignore_char;
- }
-
- /* mask off the error conditions we want to ignore */
- tmp = status & info->read_status_mask;
-
- if (tmp & DZ_PERR) {
- *tty->flip.flag_buf_ptr = TTY_PARITY;
-#ifdef DEBUG_DZ
- debug_console("PERR\n",5);
-#endif /* DEBUG_DZ */
- } else if (tmp & DZ_FERR) {
- *tty->flip.flag_buf_ptr = TTY_FRAME;
-#ifdef DEBUG_DZ
- debug_console("FERR\n",5);
-#endif /* DEBUG_DZ */
- } if (tmp & DZ_OERR) {
-#ifdef DEBUG_DZ
- debug_console("OERR\n",5);
-#endif /* DEBUG_DZ */
- if (tty->flip.count < TTY_FLIPBUF_SIZE) {
- tty->flip.count++;
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- *tty->flip.flag_buf_ptr = TTY_OVERRUN;
- }
- }
- }
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- tty->flip.count++;
-ignore_char:
- ;
- } while (status & DZ_DVAL);
-
- if (tty)
- tty_flip_buffer_push(tty);
-}
-
-/*
- * ------------------------------------------------------------
- * transmit_char ()
- *
- * This routine deals with outputs to any lines.
- * ------------------------------------------------------------
- */
-static inline void transmit_chars (struct dz_serial *info)
-{
- unsigned char tmp;
-
- if (info->x_char) { /* XON/XOFF chars */
- dz_out(info, DZ_TDR, info->x_char);
- info->icount.tx++;
- info->x_char = 0;
- return;
- }
-
- /* if nothing to do or stopped or hardware stopped */
- if ((info->xmit_cnt <= 0) || info->tty->stopped ||
- info->tty->hw_stopped) {
- dz_stop(info->tty);
- return;
- }
-
- /*
- * If something to do ... (rember the dz has no output fifo so we go
- * one char at a time :-<
- */
- tmp = (unsigned short) info->xmit_buf[info->xmit_tail++];
- dz_out(info, DZ_TDR, tmp);
- info->xmit_tail = info->xmit_tail & (DZ_XMIT_SIZE - 1);
- info->icount.tx++;
-
- if (--info->xmit_cnt < WAKEUP_CHARS)
- dz_sched_event(info, DZ_EVENT_WRITE_WAKEUP);
-
- /* Are we done */
- if (info->xmit_cnt <= 0)
- dz_stop(info->tty);
-}
-
-/*
- * ------------------------------------------------------------
- * check_modem_status ()
- *
- * Only valid for the MODEM line duh !
- * ------------------------------------------------------------
- */
-static inline void check_modem_status (struct dz_serial *info)
-{
- unsigned short status;
-
- /* if not ne modem line just return */
- if (info->line != DZ_MODEM)
- return;
-
- status = dz_in(info, DZ_MSR);
-
- /* it's easy, since DSR2 is the only bit in the register */
- if (status)
- info->icount.dsr++;
-}
-
-/*
- * ------------------------------------------------------------
- * dz_interrupt ()
- *
- * this is the main interrupt routine for the DZ chip.
- * It deals with the multiple ports.
- * ------------------------------------------------------------
- */
-static void dz_interrupt (int irq, void *dev, struct pt_regs *regs)
-{
- struct dz_serial *info;
- unsigned short status;
-
- /* get the reason why we just got an irq */
- status = dz_in((struct dz_serial *)dev, DZ_CSR);
- info = lines[LINE(status)]; /* re-arrange info the proper port */
-
- if (status & DZ_RDONE)
- receive_chars(info); /* the receive function */
-
- if (status & DZ_TRDY)
- transmit_chars (info);
-}
-
-/*
- * -------------------------------------------------------------------
- * Here ends the DZ interrupt routines.
- * -------------------------------------------------------------------
- */
-
-/*
- * This routine is used to handle the "bottom half" processing for the
- * serial driver, known also the "software interrupt" processing.
- * This processing is done at the kernel interrupt level, after the
- * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON. This
- * is where time-consuming activities which can not be done in the
- * interrupt driver proper are done; the interrupt driver schedules
- * them using rs_sched_event(), and they get done here.
- */
-static void do_serial_bh (void)
-{
- run_task_queue (&tq_serial);
-}
-
-static void do_softint (void *private_data)
-{
- struct dz_serial *info = (struct dz_serial *) private_data;
- struct tty_struct *tty = info->tty;
-
- if (!tty)
- return;
-
- if (test_and_clear_bit(DZ_EVENT_WRITE_WAKEUP, &info->event)) {
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup) (tty);
- wake_up_interruptible (&tty->write_wait);
- }
-}
-
-/*
- * -------------------------------------------------------------------
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred. The path of
- * hangup processing is:
- *
- * serial interrupt routine -> (scheduler tqueue) ->
- * do_serial_hangup() -> tty->hangup() -> rs_hangup()
- * -------------------------------------------------------------------
- */
-static void do_serial_hangup (void *private_data)
-{
- struct dz_serial *info = (struct dz_serial *) private_data;
- struct tty_struct *tty = info->tty;
-
- if (!tty)
- return;
-
- tty_hangup(tty);
-}
-
-/*
- * -------------------------------------------------------------------
- * startup ()
- *
- * various initialization tasks
- * -------------------------------------------------------------------
- */
-static int startup (struct dz_serial *info)
-{
- unsigned long page, flags;
- unsigned short tmp;
-
- if (info->is_initialized)
- return 0;
-
- save_and_cli(flags);
-
- if (!info->port) {
- if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
- restore_flags(flags);
- return -ENODEV;
- }
-
- if (!info->xmit_buf) {
- page = get_zeroed_page(GFP_KERNEL);
- if (!page) {
- restore_flags (flags);
- return -ENOMEM;
- }
- info->xmit_buf = (unsigned char *)page;
- }
-
- if (info->tty)
- clear_bit(TTY_IO_ERROR, &info->tty->flags);
-
- /* enable the interrupt and the scanning */
- tmp = dz_in(info, DZ_CSR);
- tmp |= (DZ_RIE | DZ_TIE | DZ_MSE);
- dz_out(info, DZ_CSR, tmp);
-
- info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-
- change_speed(info); /* set up the speed */
-
- /*
- * Clear the line transmitter buffer I can't figure out why I need to
- * do this - but its necessary - in order for the console portion and
- * the interrupt portion to live happily side by side.
- */
-
- info->is_initialized = 1;
-
- restore_flags(flags);
-
- return 0;
-}
-
-/*
- * -------------------------------------------------------------------
- * shutdown ()
- *
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- * -------------------------------------------------------------------
- */
-static void shutdown (struct dz_serial *info)
-{
- unsigned long flags;
- unsigned short tmp;
-
- if (!info->is_initialized)
- return;
-
- save_and_cli(flags);
-
- dz_stop (info->tty);
-
- info->cflags &= ~DZ_CREAD; /* turn off receive enable flag */
- dz_out(info, DZ_LPR, info->cflags);
-
- if (info->xmit_buf) { /* free Tx buffer */
- free_page((unsigned long)info->xmit_buf);
- info->xmit_buf = 0;
- }
-
- if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
- tmp = dz_in(info, DZ_TCR);
- if (tmp & DZ_MODEM_DTR) {
- tmp &= ~DZ_MODEM_DTR;
- dz_out(info, DZ_TCR, tmp);
- }
- }
-
- if (info->tty)
- set_bit (TTY_IO_ERROR, &info->tty->flags);
-
- info->is_initialized = 0;
-
- restore_flags (flags);
-}
-
-/*
- * -------------------------------------------------------------------
- * change_speed ()
- *
- * set the baud rate.
- * -------------------------------------------------------------------
- */
-static void change_speed (struct dz_serial *info)
-{
- unsigned long flags;
- unsigned cflag;
- int baud;
-
- if (!info->tty || !info->tty->termios)
- return;
-
- save_and_cli(flags);
-
- info->cflags = info->line;
-
- cflag = info->tty->termios->c_cflag;
-
- switch (cflag & CSIZE) {
- case CS5:
- info->cflags |= DZ_CS5;
- break;
- case CS6:
- info->cflags |= DZ_CS6;
- break;
- case CS7:
- info->cflags |= DZ_CS7;
- break;
- case CS8:
- default:
- info->cflags |= DZ_CS8;
- }
-
- if (cflag & CSTOPB)
- info->cflags |= DZ_CSTOPB;
- if (cflag & PARENB)
- info->cflags |= DZ_PARENB;
- if (cflag & PARODD)
- info->cflags |= DZ_PARODD;
-
- baud = tty_get_baud_rate(info->tty);
- switch (baud) {
- case 50:
- info->cflags |= DZ_B50;
- break;
- case 75:
- info->cflags |= DZ_B75;
- break;
- case 110:
- info->cflags |= DZ_B110;
- break;
- case 134:
- info->cflags |= DZ_B134;
- break;
- case 150:
- info->cflags |= DZ_B150;
- break;
- case 300:
- info->cflags |= DZ_B300;
- break;
- case 600:
- info->cflags |= DZ_B600;
- break;
- case 1200:
- info->cflags |= DZ_B1200;
- break;
- case 1800:
- info->cflags |= DZ_B1800;
- break;
- case 2000:
- info->cflags |= DZ_B2000;
- break;
- case 2400:
- info->cflags |= DZ_B2400;
- break;
- case 3600:
- info->cflags |= DZ_B3600;
- break;
- case 4800:
- info->cflags |= DZ_B4800;
- break;
- case 7200:
- info->cflags |= DZ_B7200;
- break;
- case 9600:
- default:
- info->cflags |= DZ_B9600;
- }
-
- info->cflags |= DZ_RXENAB;
- dz_out(info, DZ_LPR, info->cflags);
-
- /* setup accept flag */
- info->read_status_mask = DZ_OERR;
- if (I_INPCK(info->tty))
- info->read_status_mask |= (DZ_FERR | DZ_PERR);
-
- /* characters to ignore */
- info->ignore_status_mask = 0;
- if (I_IGNPAR(info->tty))
- info->ignore_status_mask |= (DZ_FERR | DZ_PERR);
-
- restore_flags(flags);
-}
-
-/*
- * -------------------------------------------------------------------
- * dz_flush_char ()
- *
- * Flush the buffer.
- * -------------------------------------------------------------------
- */
-static void dz_flush_chars (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
- unsigned long flags;
-
- if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
- !info->xmit_buf)
- return;
-
- save_and_cli(flags);
- dz_start (info->tty);
- restore_flags(flags);
-}
-
-
-/*
- * -------------------------------------------------------------------
- * dz_write ()
- *
- * main output routine.
- * -------------------------------------------------------------------
- */
-static int dz_write (struct tty_struct *tty, int from_user,
- const unsigned char *buf, int count)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
- unsigned long flags;
- int c, ret = 0;
-
- if (!tty )
- return ret;
- if (!info->xmit_buf)
- return ret;
- if (!tmp_buf)
- tmp_buf = tmp_buffer;
-
- if (from_user) {
- down (&tmp_buf_sem);
- while (1) {
- c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
- DZ_XMIT_SIZE - info->xmit_head));
- if (c <= 0)
- break;
-
- c -= copy_from_user (tmp_buf, buf, c);
- if (!c) {
- if (!ret)
- ret = -EFAULT;
- break;
- }
-
- save_and_cli(flags);
-
- c = MIN(c, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
- DZ_XMIT_SIZE - info->xmit_head));
- memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
- info->xmit_head = ((info->xmit_head + c) &
- (DZ_XMIT_SIZE - 1));
- info->xmit_cnt += c;
- restore_flags(flags);
-
- buf += c;
- count -= c;
- ret += c;
- }
- up(&tmp_buf_sem);
- } else {
- while (1) {
- save_and_cli(flags);
-
- c = MIN(count, MIN(DZ_XMIT_SIZE - info->xmit_cnt - 1,
- DZ_XMIT_SIZE - info->xmit_head));
- if (c <= 0) {
- restore_flags (flags);
- break;
- }
- memcpy(info->xmit_buf + info->xmit_head, buf, c);
- info->xmit_head = ((info->xmit_head + c) &
- (DZ_XMIT_SIZE-1));
- info->xmit_cnt += c;
- restore_flags(flags);
-
- buf += c;
- count -= c;
- ret += c;
- }
- }
-
- if (info->xmit_cnt) {
- if (!tty->stopped) {
- if (!tty->hw_stopped) {
- dz_start (info->tty);
- }
- }
- }
-
- return ret;
-}
-
-/*
- * -------------------------------------------------------------------
- * dz_write_room ()
- *
- * compute the amount of space available for writing.
- * -------------------------------------------------------------------
- */
-static int dz_write_room (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
- int ret;
-
- ret = DZ_XMIT_SIZE - info->xmit_cnt - 1;
- if (ret < 0)
- ret = 0;
-
- return ret;
-}
-
-/*
- * -------------------------------------------------------------------
- * dz_chars_in_buffer ()
- *
- * compute the amount of char left to be transmitted
- * -------------------------------------------------------------------
- */
-static int dz_chars_in_buffer (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- return info->xmit_cnt;
-}
-
-/*
- * -------------------------------------------------------------------
- * dz_flush_buffer ()
- *
- * Empty the output buffer
- * -------------------------------------------------------------------
- */
-static void dz_flush_buffer (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- cli();
- info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
- sti();
-
- wake_up_interruptible (&tty->write_wait);
-
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- tty->ldisc.write_wakeup(tty);
-}
-
-/*
- * ------------------------------------------------------------
- * dz_throttle () and dz_unthrottle ()
- *
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled (or not).
- * ------------------------------------------------------------
- */
-static void dz_throttle (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- if (I_IXOFF(tty))
- info->x_char = STOP_CHAR(tty);
-}
-
-static void dz_unthrottle (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- if (I_IXOFF(tty)) {
- if (info->x_char)
- info->x_char = 0;
- else
- info->x_char = START_CHAR(tty);
- }
-}
-
-static void dz_send_xchar (struct tty_struct *tty, char ch)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- info->x_char = ch;
-
- if (ch)
- dz_start(info->tty);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl () and friends
- * ------------------------------------------------------------
- */
-static int get_serial_info(struct dz_serial *info,
- struct serial_struct *retinfo)
-{
- struct serial_struct tmp;
-
- if (!retinfo)
- return -EFAULT;
-
- memset (&tmp, 0, sizeof(tmp));
-
- tmp.type = info->type;
- tmp.line = info->line;
- tmp.port = info->port;
- tmp.irq = SERIAL;
- tmp.flags = info->flags;
- tmp.baud_base = info->baud_base;
- tmp.close_delay = info->close_delay;
- tmp.closing_wait = info->closing_wait;
-
- return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
-}
-
-static int set_serial_info (struct dz_serial *info,
- struct serial_struct *new_info)
-{
- struct serial_struct new_serial;
- struct dz_serial old_info;
- int retval = 0;
-
- if (!new_info)
- return -EFAULT;
-
- if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
- return -EFAULT;
-
- old_info = *info;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (info->count > 1)
- return -EBUSY;
-
- /*
- * OK, past this point, all the error checking has been done.
- * At this point, we start making changes.....
- */
-
- info->baud_base = new_serial.baud_base;
- info->type = new_serial.type;
- info->close_delay = new_serial.close_delay;
- info->closing_wait = new_serial.closing_wait;
-
- retval = startup(info);
-
- return retval;
-}
-
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- * is emptied. On bus types like RS485, the transmitter must
- * release the bus after transmitting. This must be done when
- * the transmit shift register is empty, not be done when the
- * transmit holding register is empty. This functionality
- * allows an RS485 driver to be written in user space.
- */
-static int get_lsr_info (struct dz_serial *info, unsigned int *value)
-{
- unsigned short status = dz_in (info, DZ_LPR);
-
- return put_user (status, value);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break (struct dz_serial *info, int duration)
-{
- unsigned long flags;
- unsigned short tmp, mask;
-
- if (!info->port)
- return;
-
- mask = 1 << info->line;
- tmp = dz_in (info, DZ_TCR);
- tmp |= mask;
-
- current->state = TASK_INTERRUPTIBLE;
-
- save_and_cli(flags);
- dz_out(info, DZ_TCR, tmp);
- schedule_timeout(duration);
- tmp &= ~mask;
- dz_out(info, DZ_TCR, tmp);
- restore_flags(flags);
-}
-
-static int dz_ioctl(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- int error;
- struct dz_serial * info = (struct dz_serial *)tty->driver_data;
- int retval;
-
- if (cmd != TIOCGSERIAL && cmd != TIOCSSERIAL &&
- cmd != TIOCSERCONFIG && cmd != TIOCSERGWILD &&
- cmd != TIOCSERSWILD && cmd != TIOCSERGSTRUCT) {
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
- }
-
- switch (cmd) {
- case TCSBRK: /* SVID version: non-zero arg --> no break */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- if (!arg)
- send_break(info, HZ/4); /* 1/4 second */
- return 0;
-
- case TCSBRKP: /* support for POSIX tcsendbreak() */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- send_break(info, arg ? arg*(HZ/10) : HZ/4);
- return 0;
-
- case TIOCGSOFTCAR:
- return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *)arg);
-
- case TIOCSSOFTCAR:
- if (get_user (arg, (unsigned long *)arg))
- return -EFAULT;
-
- tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) |
- (arg ? CLOCAL : 0);
- return 0;
-
- case TIOCGSERIAL:
- return get_serial_info(info, (struct serial_struct *)arg);
-
- case TIOCSSERIAL:
- return set_serial_info(info, (struct serial_struct *) arg);
-
- case TIOCSERGETLSR: /* Get line status register */
- return get_lsr_info (info, (unsigned int *)arg);
-
- case TIOCSERGSTRUCT:
- return copy_to_user((struct dz_serial *)arg, info,
- sizeof(struct dz_serial)) ? -EFAULT : 0;
-
- default:
- return -ENOIOCTLCMD;
- }
-
- return 0;
-}
-
-static void dz_set_termios (struct tty_struct *tty,
- struct termios *old_termios)
-{
- struct dz_serial *info = (struct dz_serial *)tty->driver_data;
-
- if (tty->termios->c_cflag == old_termios->c_cflag)
- return;
-
- change_speed (info);
-
- if ((old_termios->c_cflag & CRTSCTS) &&
- !(tty->termios->c_cflag & CRTSCTS)) {
- tty->hw_stopped = 0;
- dz_start(tty);
- }
-}
-
-/*
- * ------------------------------------------------------------
- * dz_close()
- *
- * This routine is called when the serial port gets closed. First, we
- * wait for the last remaining data to be sent. Then, we turn off
- * the transmit enable and receive enable flags.
- * ------------------------------------------------------------
- */
-static void dz_close(struct tty_struct *tty, struct file *filp)
-{
- struct dz_serial * info = (struct dz_serial *)tty->driver_data;
- unsigned long flags;
-
- if (!info)
- return;
-
- save_and_cli(flags);
-
- if (tty_hung_up_p(filp)) {
- restore_flags(flags);
- return;
- }
-
- if ((tty->count == 1) && (info->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty structure
- * will be freed. Info->count should always be one in these
- * conditions. If it's greater than one, we've got real
- * problems, since it means the serial port won't be shutdown.
- */
- printk("dz_close: bad serial port count; tty->count is 1, "
- "info->count is %d\n", info->count);
- info->count = 1;
- }
-
- if (--info->count < 0) {
- printk("ds_close: bad serial port count for ttyS%02d: %d\n",
- info->line, info->count);
- info->count = 0;
- }
-
- if (info->count) {
- restore_flags(flags);
- return;
- }
- info->flags |= DZ_CLOSING;
- /*
- * Now we wait for the transmit buffer to clear; and we notify the line
- * discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
-
- if (info->closing_wait != DZ_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, info->closing_wait);
-
- /*
- * At this point we stop accepting input. To do this, we disable the
- * receive line status interrupts.
- */
- shutdown(info);
-
- if (tty->driver->flush_buffer)
- tty->driver->flush_buffer (tty);
- if (tty->ldisc.flush_buffer)
- tty->ldisc.flush_buffer (tty);
- tty->closing = 0;
- info->event = 0;
- info->tty = 0;
-
- if (tty->ldisc.num != ldiscs[N_TTY].num) {
- if (tty->ldisc.close)
- tty->ldisc.close(tty);
- tty->ldisc = ldiscs[N_TTY];
- tty->termios->c_line = N_TTY;
- if (tty->ldisc.open)
- tty->ldisc.open(tty);
- }
- if (info->blocked_open) {
- if (info->close_delay) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(info->close_delay);
- }
- wake_up_interruptible(&info->open_wait);
- }
-
- info->flags &= ~(DZ_NORMAL_ACTIVE | DZ_CLOSING);
- wake_up_interruptible(&info->close_wait);
-
- restore_flags(flags);
-}
-
-/*
- * dz_hangup () --- called by tty_hangup() when a hangup is signaled.
- */
-static void dz_hangup (struct tty_struct *tty)
-{
- struct dz_serial *info = (struct dz_serial *) tty->driver_data;
-
- dz_flush_buffer(tty);
- shutdown(info);
- info->event = 0;
- info->count = 0;
- info->flags &= ~DZ_NORMAL_ACTIVE;
- info->tty = 0;
- wake_up_interruptible(&info->open_wait);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file *filp,
- struct dz_serial *info)
-{
- DECLARE_WAITQUEUE(wait, current);
- int retval;
- int do_clocal = 0;
-
- /*
- * If the device is in the middle of being closed, then block
- * until it's done, and then try again.
- */
- if (info->flags & DZ_CLOSING) {
- interruptible_sleep_on(&info->close_wait);
- return -EAGAIN;
- }
-
- /*
- * If non-blocking mode is set, or the port is not enabled, then make
- * the check up front and then exit.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR))) {
- info->flags |= DZ_NORMAL_ACTIVE;
-
- return 0;
- }
-
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
-
- /*
- * Block waiting for the carrier detect and the line to become free
- * (i.e., not in use by the callout). While we are in this loop,
- * info->count is dropped by one, so that dz_close() knows when to free
- * things. We restore it upon exit, either normal or abnormal.
- */
- retval = 0;
- add_wait_queue(&info->open_wait, &wait);
-
- info->count--;
- info->blocked_open++;
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p (filp) || !(info->is_initialized)) {
- retval = -EAGAIN;
- break;
- }
- if (!(info->flags & DZ_CLOSING) && do_clocal)
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
- schedule();
- }
-
- current->state = TASK_RUNNING;
- remove_wait_queue (&info->open_wait, &wait);
- if (!tty_hung_up_p(filp))
- info->count++;
- info->blocked_open--;
-
- if (retval)
- return retval;
- info->flags |= DZ_NORMAL_ACTIVE;
- return 0;
-}
-
-/*
- * This routine is called whenever a serial port is opened. It
- * enables interrupts for a serial port. It also performs the
- * serial-specific initialization for the tty structure.
- */
-static int dz_open (struct tty_struct *tty, struct file *filp)
-{
- struct dz_serial *info;
- int retval, line;
-
- line = tty->index;
-
- /*
- * The dz lines for the mouse/keyboard must be opened using their
- * respective drivers.
- */
- if ((line < 0) || (line >= DZ_NB_PORT))
- return -ENODEV;
-
- if ((line == DZ_KEYBOARD) || (line == DZ_MOUSE))
- return -ENODEV;
-
- info = lines[line];
- info->count++;
-
- tty->driver_data = info;
- info->tty = tty;
-
- /*
- * Start up serial port
- */
- retval = startup (info);
- if (retval)
- return retval;
-
- retval = block_til_ready (tty, filp, info);
- if (retval)
- return retval;
-
- return 0;
-}
-
-static void show_serial_version (void)
-{
- printk("%s%s\n", dz_name, dz_version);
-}
-
-static struct tty_driver *serial_driver;
-
-static struct tty_operations serial_ops = {
- .open = dz_open,
- .close = dz_close,
- .write = dz_write,
- .flush_chars = dz_flush_chars,
- .write_room = dz_write_room,
- .chars_in_buffer = dz_chars_in_buffer,
- .flush_buffer = dz_flush_buffer,
- .ioctl = dz_ioctl,
- .throttle = dz_throttle,
- .unthrottle = dz_unthrottle,
- .send_xchar = dz_send_xchar,
- .set_termios = dz_set_termios,
- .stop = dz_stop,
- .start = dz_start,
- .hangup = dz_hangup,
-};
-
-int __init dz_init(void)
-{
- int i, flags;
- struct dz_serial *info;
-
- serial_driver = alloc_tty_driver(DZ_NB_PORT);
- if (!serial_driver)
- return -ENOMEM;
-
- /* Setup base handler, and timer table. */
- init_bh(SERIAL_BH, do_serial_bh);
-
- show_serial_version();
-
- serial_driver->owner = THIS_MODULE;
- serial_driver->devfs_name = "tts/";
- serial_driver->name = "ttyS";
- serial_driver->major = TTY_MAJOR;
- serial_driver->minor_start = 64;
- serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
- serial_driver->subtype = SERIAL_TYPE_NORMAL;
- serial_driver->init_termios = tty_std_termios;
- serial_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL |
- CLOCAL;
- serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
- tty_set_operations(serial_driver, &serial_ops);
-
- if (tty_register_driver(serial_driver))
- panic("Couldn't register serial driver\n");
-
- save_flags(flags); cli();
- for (i=0; i < DZ_NB_PORT; i++) {
- info = &multi[i];
- lines[i] = info;
- info->magic = SERIAL_MAGIC;
-
- if ((mips_machtype == MACH_DS23100) ||
- (mips_machtype == MACH_DS5100))
- info->port = (unsigned long) KN01_DZ11_BASE;
- else
- info->port = (unsigned long) KN02_DZ11_BASE;
-
- info->line = i;
- info->tty = 0;
- info->close_delay = 50;
- info->closing_wait = 3000;
- info->x_char = 0;
- info->event = 0;
- info->count = 0;
- info->blocked_open = 0;
- info->tqueue.routine = do_softint;
- info->tqueue.data = info;
- info->tqueue_hangup.routine = do_serial_hangup;
- info->tqueue_hangup.data = info;
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
-
- /*
- * If we are pointing to address zero then punt - not correctly
- * set up in setup.c to handle this.
- */
- if (! info->port)
- return 0;
-
- printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line,
- info->port, SERIAL);
-
- tty_register_device(serial_driver, info->line, NULL);
- }
-
- /* Reset the chip */
-#ifndef CONFIG_SERIAL_CONSOLE
- {
- int tmp;
- dz_out(info, DZ_CSR, DZ_CLR);
- while ((tmp = dz_in(info,DZ_CSR)) & DZ_CLR);
- wbflush();
-
- /* Enable scanning */
- dz_out(info, DZ_CSR, DZ_MSE);
- }
-#endif
-
- /*
- * Order matters here... the trick is that flags is updated... in
- * request_irq - to immediatedly obliterate it is unwise.
- */
- restore_flags(flags);
-
- if (request_irq(SERIAL, dz_interrupt, SA_INTERRUPT, "DZ", lines[0]))
- panic("Unable to register DZ interrupt\n");
-
- return 0;
-}
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void dz_console_put_char (unsigned char ch)
-{
- unsigned long flags;
- int loops = 2500;
- unsigned short tmp = ch;
- /*
- * this code sends stuff out to serial device - spinning its wheels and
- * waiting.
- */
-
- /* force the issue - point it at lines[3]*/
- dz_console = &multi[CONSOLE_LINE];
-
- save_and_cli(flags);
-
- /* spin our wheels */
- while (((dz_in(dz_console, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--)
- ;
-
- /* Actually transmit the character. */
- dz_out(dz_console, DZ_TDR, tmp);
-
- restore_flags(flags);
-}
-
-/*
- * -------------------------------------------------------------------
- * dz_console_print ()
- *
- * dz_console_print is registered for printk.
- * The console must be locked when we get here.
- * -------------------------------------------------------------------
- */
-static void dz_console_print (struct console *cons,
- const char *str,
- unsigned int count)
-{
-#ifdef DEBUG_DZ
- prom_printf((char *)str);
-#endif
- while (count--) {
- if (*str == '\n')
- dz_console_put_char('\r');
- dz_console_put_char(*str++);
- }
-}
-
-static struct tty_driver *dz_console_device(struct console *c, int *index)
-{
- *index = c->index;
- return serial_driver;
-}
-
-static int __init dz_console_setup(struct console *co, char *options)
-{
- int baud = 9600;
- int bits = 8;
- int parity = 'n';
- int cflag = CREAD | HUPCL | CLOCAL;
- char *s;
- unsigned short mask,tmp;
-
- if (options) {
- baud = simple_strtoul(options, NULL, 10);
- s = options;
- while (*s >= '0' && *s <= '9')
- s++;
- if (*s)
- parity = *s++;
- if (*s)
- bits = *s - '0';
- }
-
- /*
- * Now construct a cflag setting.
- */
- switch (baud) {
- case 1200:
- cflag |= DZ_B1200;
- break;
- case 2400:
- cflag |= DZ_B2400;
- break;
- case 4800:
- cflag |= DZ_B4800;
- break;
- case 9600:
- default:
- cflag |= DZ_B9600;
- break;
- }
- switch (bits) {
- case 7:
- cflag |= DZ_CS7;
- break;
- default:
- case 8:
- cflag |= DZ_CS8;
- break;
- }
- switch (parity) {
- case 'o':
- case 'O':
- cflag |= DZ_PARODD;
- break;
- case 'e':
- case 'E':
- cflag |= DZ_PARENB;
- break;
- }
- co->cflag = cflag;
-
- /* TOFIX: force to console line */
- dz_console = &multi[CONSOLE_LINE];
- if ((mips_machtype == MACH_DS23100) || (mips_machtype == MACH_DS5100))
- dz_console->port = KN01_DZ11_BASE;
- else
- dz_console->port = KN02_DZ11_BASE;
- dz_console->line = CONSOLE_LINE;
-
- dz_out(dz_console, DZ_CSR, DZ_CLR);
- while ((tmp = dz_in(dz_console,DZ_CSR)) & DZ_CLR)
- ;
-
- /* enable scanning */
- dz_out(dz_console, DZ_CSR, DZ_MSE);
-
- /* Set up flags... */
- dz_console->cflags = 0;
- dz_console->cflags |= DZ_B9600;
- dz_console->cflags |= DZ_CS8;
- dz_console->cflags |= DZ_PARENB;
- dz_out(dz_console, DZ_LPR, dz_console->cflags);
-
- mask = 1 << dz_console->line;
- tmp = dz_in (dz_console, DZ_TCR); /* read the TX flag */
- if (!(tmp & mask)) {
- tmp |= mask; /* set the TX flag */
- dz_out (dz_console, DZ_TCR, tmp);
- }
-
- return 0;
-}
-
-static struct console dz_sercons = {
- .name = "ttyS",
- .write = dz_console_print,
- .device = dz_console_device,
- .setup = dz_console_setup,
- .flags = CON_CONSDEV | CON_PRINTBUFFER,
- .index = CONSOLE_LINE,
-};
-
-void __init dz_serial_console_init(void)
-{
- register_console(&dz_sercons);
-}
-
-#endif /* ifdef CONFIG_SERIAL_CONSOLE */
-
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * dz.h: Serial port driver for DECStations equiped
- * with the DZ chipset.
- *
- * Copyright (C) 1998 Olivier A. D. Lebaillif
- *
- * Email: olivier.lebaillif@ifrsys.com
- *
- */
-#ifndef DZ_SERIAL_H
-#define DZ_SERIAL_H
-
-/*
- * Definitions for the Control and Status Received.
- */
-#define DZ_TRDY 0x8000 /* Transmitter empty */
-#define DZ_TIE 0x4000 /* Transmitter Interrupt Enable */
-#define DZ_RDONE 0x0080 /* Receiver data ready */
-#define DZ_RIE 0x0040 /* Receive Interrupt Enable */
-#define DZ_MSE 0x0020 /* Master Scan Enable */
-#define DZ_CLR 0x0010 /* Master reset */
-#define DZ_MAINT 0x0008 /* Loop Back Mode */
-
-/*
- * Definitions for the Received buffer.
- */
-#define DZ_RBUF_MASK 0x00FF /* Data Mask in the Receive Buffer */
-#define DZ_LINE_MASK 0x0300 /* Line Mask in the Receive Buffer */
-#define DZ_DVAL 0x8000 /* Valid Data indicator */
-#define DZ_OERR 0x4000 /* Overrun error indicator */
-#define DZ_FERR 0x2000 /* Frame error indicator */
-#define DZ_PERR 0x1000 /* Parity error indicator */
-
-#define LINE(x) (x & DZ_LINE_MASK) >> 8 /* Get the line number from the input buffer */
-#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK)
-
-/*
- * Definitions for the Transmit Register.
- */
-#define DZ_LINE_KEYBOARD 0x0001
-#define DZ_LINE_MOUSE 0x0002
-#define DZ_LINE_MODEM 0x0004
-#define DZ_LINE_PRINTER 0x0008
-
-#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */
-
-/*
- * Definitions for the Modem Status Register.
- */
-#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */
-
-/*
- * Definitions for the Transmit Data Register.
- */
-#define DZ_BRK0 0x0100 /* Break assertion for line 0 */
-#define DZ_BRK1 0x0200 /* Break assertion for line 1 */
-#define DZ_BRK2 0x0400 /* Break assertion for line 2 */
-#define DZ_BRK3 0x0800 /* Break assertion for line 3 */
-
-/*
- * Definitions for the Line Parameter Register.
- */
-#define DZ_KEYBOARD 0x0000 /* line 0 = keyboard */
-#define DZ_MOUSE 0x0001 /* line 1 = mouse */
-#define DZ_MODEM 0x0002 /* line 2 = modem */
-#define DZ_PRINTER 0x0003 /* line 3 = printer */
-
-#define DZ_CSIZE 0x0018 /* Number of bits per byte (mask) */
-#define DZ_CS5 0x0000 /* 5 bits per byte */
-#define DZ_CS6 0x0008 /* 6 bits per byte */
-#define DZ_CS7 0x0010 /* 7 bits per byte */
-#define DZ_CS8 0x0018 /* 8 bits per byte */
-
-#define DZ_CSTOPB 0x0020 /* 2 stop bits instead of one */
-
-#define DZ_PARENB 0x0040 /* Parity enable */
-#define DZ_PARODD 0x0080 /* Odd parity instead of even */
-
-#define DZ_CBAUD 0x0E00 /* Baud Rate (mask) */
-#define DZ_B50 0x0000
-#define DZ_B75 0x0100
-#define DZ_B110 0x0200
-#define DZ_B134 0x0300
-#define DZ_B150 0x0400
-#define DZ_B300 0x0500
-#define DZ_B600 0x0600
-#define DZ_B1200 0x0700
-#define DZ_B1800 0x0800
-#define DZ_B2000 0x0900
-#define DZ_B2400 0x0A00
-#define DZ_B3600 0x0B00
-#define DZ_B4800 0x0C00
-#define DZ_B7200 0x0D00
-#define DZ_B9600 0x0E00
-
-#define DZ_CREAD 0x1000 /* Enable receiver */
-#define DZ_RXENAB 0x1000 /* enable receive char */
-/*
- * Addresses for the DZ registers
- */
-#define DZ_CSR 0x00 /* Control and Status Register */
-#define DZ_RBUF 0x08 /* Receive Buffer */
-#define DZ_LPR 0x08 /* Line Parameters Register */
-#define DZ_TCR 0x10 /* Transmitter Control Register */
-#define DZ_MSR 0x18 /* Modem Status Register */
-#define DZ_TDR 0x18 /* Transmit Data Register */
-
-
-#define DZ_NB_PORT 4
-
-#define DZ_XMIT_SIZE 4096 /* buffer size */
-#define WAKEUP_CHARS DZ_XMIT_SIZE/4
-
-#define DZ_EVENT_WRITE_WAKEUP 0
-
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-
-#define DZ_INITIALIZED 0x80000000 /* Serial port was initialized */
-#define DZ_CALLOUT_ACTIVE 0x40000000 /* Call out device is active */
-#define DZ_NORMAL_ACTIVE 0x20000000 /* Normal device is active */
-#define DZ_BOOT_AUTOCONF 0x10000000 /* Autoconfigure port on bootup */
-#define DZ_CLOSING 0x08000000 /* Serial port is closing */
-#define DZ_CTS_FLOW 0x04000000 /* Do CTS flow control */
-#define DZ_CHECK_CD 0x02000000 /* i.e., CLOCAL */
-
-#define DZ_CLOSING_WAIT_INF 0
-#define DZ_CLOSING_WAIT_NONE 65535
-
-#define DZ_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */
-#define DZ_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
-#define DZ_PGRP_LOCKOUT 0x0200 /* Lock out cua opens based on pgrp */
-
-struct dz_serial {
- unsigned port; /* base address for the port */
- int type;
- int flags;
- int baud_base;
- int blocked_open;
- unsigned short close_delay;
- unsigned short closing_wait;
- unsigned short line; /* port/line number */
- unsigned short cflags; /* line configuration flag */
- unsigned short x_char; /* xon/xoff character */
- unsigned short read_status_mask; /* mask for read condition */
- unsigned short ignore_status_mask; /* mask for ignore condition */
- unsigned long event; /* mask used in BH */
- unsigned char *xmit_buf; /* Transmit buffer */
- int xmit_head; /* Position of the head */
- int xmit_tail; /* Position of the tail */
- int xmit_cnt; /* Count of the chars in the buffer */
- int count; /* indicates how many times it has been opened */
- int magic;
-
- struct async_icount icount; /* keep track of things ... */
- struct tty_struct *tty; /* tty associated */
- struct tq_struct tqueue; /* Queue for BH */
- struct tq_struct tqueue_hangup;
- wait_queue_head_t open_wait;
- wait_queue_head_t close_wait;
-
- unsigned char is_console; /* flag indicating a serial console */
- unsigned char is_initialized;
-};
-
-static struct dz_serial multi[DZ_NB_PORT]; /* Four serial lines in the DZ chip */
-static struct dz_serial *dz_console;
-
-/*
- * tmp_buf is used as a temporary buffer by serial_write. We need to
- * lock it in case the copy_from_user blocks while swapping in a page,
- * and some other program tries to do a serial write at the same time.
- * Since the lock will only come under contention when the system is
- * swapping and available memory is low, it makes sense to share one
- * buffer across all the serial ports, since it significantly saves
- * memory if large numbers of serial ports are open.
- */
-static unsigned char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
-
-static char *dz_name = "DECstation DZ serial driver version ";
-static char *dz_version = "1.02";
-
-static inline unsigned short dz_in (struct dz_serial *, unsigned);
-static inline void dz_out (struct dz_serial *, unsigned, unsigned short);
-
-static inline void dz_sched_event (struct dz_serial *, int);
-static inline void receive_chars (struct dz_serial *);
-static inline void transmit_chars (struct dz_serial *);
-static inline void check_modem_status (struct dz_serial *);
-
-static void dz_stop (struct tty_struct *);
-static void dz_start (struct tty_struct *);
-static void dz_interrupt (int, void *, struct pt_regs *);
-static void do_serial_bh (void);
-static void do_softint (void *);
-static void do_serial_hangup (void *);
-static void change_speed (struct dz_serial *);
-static void dz_flush_chars (struct tty_struct *);
-static void dz_console_print (struct console *, const char *, unsigned int);
-static void dz_flush_buffer (struct tty_struct *);
-static void dz_throttle (struct tty_struct *);
-static void dz_unthrottle (struct tty_struct *);
-static void dz_send_xchar (struct tty_struct *, char);
-static void shutdown (struct dz_serial *);
-static void send_break (struct dz_serial *, int);
-static void dz_set_termios (struct tty_struct *, struct termios *);
-static void dz_close (struct tty_struct *, struct file *);
-static void dz_hangup (struct tty_struct *);
-static void show_serial_version (void);
-
-static int dz_write (struct tty_struct *, int, const unsigned char *, int);
-static int dz_write_room (struct tty_struct *);
-static int dz_chars_in_buffer (struct tty_struct *);
-static int startup (struct dz_serial *);
-static int get_serial_info (struct dz_serial *, struct serial_struct *);
-static int set_serial_info (struct dz_serial *, struct serial_struct *);
-static int get_lsr_info (struct dz_serial *, unsigned int *);
-static int dz_ioctl (struct tty_struct *, struct file *, unsigned int, unsigned long);
-static int block_til_ready (struct tty_struct *, struct file *, struct dz_serial *);
-static int dz_open (struct tty_struct *, struct file *);
-
-#ifdef MODULE
-int init_module (void)
-void cleanup_module (void)
-#endif
-
-#endif
-
-#endif /* DZ_SERIAL_H */
+++ /dev/null
-/*
- * Hitachi H8/337 Microcontroller driver
- *
- * The H8 is used to deal with the power and thermal environment
- * of a system.
- *
- * Fixes:
- * June 1999, AV added releasing /proc/driver/h8
- * Feb 2000, Borislav Deianov
- * changed queues to use list.h instead of lists.h
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/timer.h>
-#include <linux/fcntl.h>
-#include <linux/linkage.h>
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/list.h>
-#include <linux/ioport.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-
-#include "h8.h"
-
-#define DEBUG_H8
-
-#ifdef DEBUG_H8
-#define Dprintk printk
-#else
-#define Dprintk
-#endif
-
-#define XDprintk if(h8_debug==-1)printk
-
-/*
- * The h8 device is one of the misc char devices.
- */
-#define H8_MINOR_DEV 140
-
-/*
- * Forward declarations.
- */
-static int h8_init(void);
-static int h8_display_blank(void);
-static int h8_display_unblank(void);
-
-static void h8_intr(int irq, void *dev_id, struct pt_regs *regs);
-
-static int h8_get_info(char *, char **, off_t, int);
-
-/*
- * Support Routines.
- */
-static void h8_hw_init(void);
-static void h8_start_new_cmd(void);
-static void h8_send_next_cmd_byte(void);
-static void h8_read_event_status(void);
-static void h8_sync(void);
-static void h8_q_cmd(u_char *, int, int);
-static void h8_cmd_done(h8_cmd_q_t *qp);
-static int h8_alloc_queues(void);
-
-static u_long h8_get_cpu_speed(void);
-static int h8_get_curr_temp(u_char curr_temp[]);
-static void h8_get_max_temp(void);
-static void h8_get_upper_therm_thold(void);
-static void h8_set_upper_therm_thold(int);
-static int h8_get_ext_status(u_char stat_word[]);
-
-static int h8_monitor_thread(void *);
-
-static int h8_manage_therm(void);
-static void h8_set_cpu_speed(int speed_divisor);
-
-static void h8_start_monitor_timer(unsigned long secs);
-static void h8_activate_monitor(unsigned long unused);
-
-/* in arch/alpha/kernel/lca.c */
-extern void lca_clock_print(void);
-extern int lca_get_clock(void);
-extern void lca_clock_fiddle(int);
-
-static void h8_set_event_mask(int);
-static void h8_clear_event_mask(int);
-
-/*
- * Driver structures
- */
-
-static struct timer_list h8_monitor_timer;
-static int h8_monitor_timer_active = 0;
-
-static char driver_version[] = "X0.0";/* no spaces */
-
-static union intr_buf intrbuf;
-static int intr_buf_ptr;
-static union intr_buf xx;
-static u_char last_temp;
-
-/*
- * I/O Macros for register reads and writes.
- */
-#define H8_READ(a) inb((a))
-#define H8_WRITE(d,a) outb((d),(a))
-
-#define H8_GET_STATUS H8_READ((h8_base) + H8_STATUS_REG_OFF)
-#define H8_READ_DATA H8_READ((h8_base) + H8_DATA_REG_OFF)
-#define WRITE_DATA(d) H8_WRITE((d), h8_base + H8_DATA_REG_OFF)
-#define WRITE_CMD(d) H8_WRITE((d), h8_base + H8_CMD_REG_OFF)
-
-static unsigned int h8_base = H8_BASE_ADDR;
-static unsigned int h8_irq = H8_IRQ;
-static unsigned int h8_state = H8_IDLE;
-static unsigned int h8_index = -1;
-static unsigned int h8_enabled = 0;
-
-static LIST_HEAD(h8_actq);
-static LIST_HEAD(h8_cmdq);
-static LIST_HEAD(h8_freeq);
-
-/*
- * Globals used in thermal control of Alphabook1.
- */
-static int cpu_speed_divisor = -1;
-static int h8_event_mask = 0;
-static DECLARE_WAIT_QUEUE_HEAD(h8_monitor_wait);
-static unsigned int h8_command_mask = 0;
-static int h8_uthermal_threshold = DEFAULT_UTHERMAL_THRESHOLD;
-static int h8_uthermal_window = UTH_HYSTERESIS;
-static int h8_debug = 0xfffffdfc;
-static int h8_ldamp = MHZ_115;
-static int h8_udamp = MHZ_57;
-static u_char h8_current_temp = 0;
-static u_char h8_system_temp = 0;
-static int h8_sync_channel = 0;
-static DECLARE_WAIT_QUEUE_HEAD(h8_sync_wait);
-static int h8_init_performed;
-
-/* CPU speeds and clock divisor values */
-static int speed_tab[6] = {230, 153, 115, 57, 28, 14};
-
-/*
- * H8 interrupt handler
- */
-static void h8_intr(int irq, void *dev_id, struct pt_regs *regs)
-{
- u_char stat_reg, data_reg;
- h8_cmd_q_t *qp = list_entry(h8_actq.next, h8_cmd_q_t, link);
-
- stat_reg = H8_GET_STATUS;
- data_reg = H8_READ_DATA;
-
- XDprintk("h8_intr: state %d status 0x%x data 0x%x\n", h8_state, stat_reg, data_reg);
-
- switch (h8_state) {
- /* Response to an asynchronous event. */
- case H8_IDLE: { /* H8_IDLE */
- if (stat_reg & H8_OFULL) {
- if (data_reg == H8_INTR) {
- h8_state = H8_INTR_MODE;
- /* Executing a command to determine what happened. */
- WRITE_CMD(H8_RD_EVENT_STATUS);
- intr_buf_ptr = 1;
- WRITE_CMD(H8_RD_EVENT_STATUS);
- } else {
- Dprintk("h8_intr: idle stat 0x%x data 0x%x\n",
- stat_reg, data_reg);
- }
- } else {
- Dprintk("h8_intr: bogus interrupt\n");
- }
- break;
- }
- case H8_INTR_MODE: { /* H8_INTR_MODE */
- XDprintk("H8 intr/intr_mode\n");
- if (data_reg == H8_BYTE_LEVEL_ACK) {
- return;
- } else if (data_reg == H8_CMD_ACK) {
- return;
- } else {
- intrbuf.byte[intr_buf_ptr] = data_reg;
- if(!intr_buf_ptr) {
- h8_state = H8_IDLE;
- h8_read_event_status();
- }
- intr_buf_ptr--;
- }
- break;
- }
- /* Placed in this state by h8_start_new_cmd(). */
- case H8_XMIT: { /* H8_XMIT */
- XDprintk("H8 intr/xmit\n");
- /* If a byte level acknowledgement has been received */
- if (data_reg == H8_BYTE_LEVEL_ACK) {
- XDprintk("H8 intr/xmit BYTE ACK\n");
- qp->nacks++;
- if (qp->nacks > qp->ncmd)
- if(h8_debug & 0x1)
- Dprintk("h8intr: bogus # of acks!\n");
- /*
- * If the number of bytes sent is less than the total
- * number of bytes in the command.
- */
- if (qp->cnt < qp->ncmd) {
- h8_send_next_cmd_byte();
- }
- return;
- /* If the complete command has produced an acknowledgement. */
- } else if (data_reg == H8_CMD_ACK) {
- XDprintk("H8 intr/xmit CMD ACK\n");
- /* If there are response bytes */
- if (qp->nrsp)
- h8_state = H8_RCV;
- else
- h8_state = H8_IDLE;
- qp->cnt = 0;
- return;
- /* Error, need to start over with a clean slate. */
- } else if (data_reg == H8_NACK) {
- XDprintk("h8_intr: NACK received restarting command\n");
- qp->nacks = 0;
- qp->cnt = 0;
- h8_state = H8_IDLE;
- WRITE_CMD(H8_SYNC);
- return;
- } else {
- Dprintk ("h8intr: xmit unknown data 0x%x \n", data_reg);
- return;
- }
- break;
- }
- case H8_RESYNC: { /* H8_RESYNC */
- XDprintk("H8 intr/resync\n");
- if (data_reg == H8_BYTE_LEVEL_ACK) {
- return;
- } else if (data_reg == H8_SYNC_BYTE) {
- h8_state = H8_IDLE;
- if (!list_empty(&h8_actq))
- h8_send_next_cmd_byte();
- } else {
- Dprintk ("h8_intr: resync unknown data 0x%x \n", data_reg);
- return;
- }
- break;
- }
- case H8_RCV: { /* H8_RCV */
- XDprintk("H8 intr/rcv\n");
- if (qp->cnt < qp->nrsp) {
- qp->rcvbuf[qp->cnt] = data_reg;
- qp->cnt++;
- /* If command reception finished. */
- if (qp->cnt == qp->nrsp) {
- h8_state = H8_IDLE;
- list_del(&qp->link);
- h8_cmd_done (qp);
- /* More commands to send over? */
- if (!list_empty(&h8_cmdq))
- h8_start_new_cmd();
- }
- return;
- } else {
- Dprintk ("h8intr: rcv overflow cmd 0x%x\n", qp->cmdbuf[0]);
- }
- break;
- }
- default: /* default */
- Dprintk("H8 intr/unknown\n");
- break;
- }
- return;
-}
-
-static void __exit h8_cleanup (void)
-{
- remove_proc_entry("driver/h8", NULL);
- release_region(h8_base, 8);
- free_irq(h8_irq, NULL);
-}
-
-static int __init h8_init(void)
-{
- if(request_irq(h8_irq, h8_intr, SA_INTERRUPT, "h8", NULL))
- {
- printk(KERN_ERR "H8: error: IRQ %d is not free\n", h8_irq);
- return -EIO;
- }
- printk(KERN_INFO "H8 at 0x%x IRQ %d\n", h8_base, h8_irq);
-
- if (!request_region(h8_base, 8, "h8"))
- {
- free_irq(h8_irq, NULL);
- return -EIO;
- }
-
- create_proc_info_entry("driver/h8", 0, NULL, h8_get_info);
-
- h8_alloc_queues();
-
- h8_hw_init();
-
- kernel_thread(h8_monitor_thread, NULL, 0);
-
- return 0;
-}
-
-module_init(h8_init);
-module_exit(h8_cleanup);
-
-static void __init h8_hw_init(void)
-{
- u_char buf[H8_MAX_CMD_SIZE];
-
- /* set CPU speed to max for booting */
- h8_set_cpu_speed(MHZ_230);
-
- /*
- * Initialize the H8
- */
- h8_sync(); /* activate interrupts */
-
- /* To clear conditions left by console */
- h8_read_event_status();
-
- /* Perform a conditioning read */
- buf[0] = H8_DEVICE_CONTROL;
- buf[1] = 0xff;
- buf[2] = 0x0;
- h8_q_cmd(buf, 3, 1);
-
- /* Turn on built-in and external mice, capture power switch */
- buf[0] = H8_DEVICE_CONTROL;
- buf[1] = 0x0;
- buf[2] = H8_ENAB_INT_PTR | H8_ENAB_EXT_PTR |
- /*H8_DISAB_PWR_OFF_SW |*/ H8_ENAB_LOW_SPD_IND;
- h8_q_cmd(buf, 3, 1);
-
- h8_enabled = 1;
- return;
-}
-
-static int h8_get_info(char *buf, char **start, off_t fpos, int length)
-{
-#ifdef CONFIG_PROC_FS
- char *p;
-
- if (!h8_enabled)
- return 0;
- p = buf;
-
-
- /*
- 0) Linux driver version (this will change if format changes)
- 1)
- 2)
- 3)
- 4)
- */
-
- p += sprintf(p, "%s \n",
- driver_version
- );
-
- return p - buf;
-#else
- return 0;
-#endif
-}
-
-/* Called from console driver -- must make sure h8_enabled. */
-static int h8_display_blank(void)
-{
-#ifdef CONFIG_H8_DISPLAY_BLANK
- int error;
-
- if (!h8_enabled)
- return 0;
- error = h8_set_display_power_state(H8_STATE_STANDBY);
- if (error == H8_SUCCESS)
- return 1;
- h8_error("set display standby", error);
-#endif
- return 0;
-}
-
-/* Called from console driver -- must make sure h8_enabled. */
-static int h8_display_unblank(void)
-{
-#ifdef CONFIG_H8_DISPLAY_BLANK
- int error;
-
- if (!h8_enabled)
- return 0;
- error = h8_set_display_power_state(H8_STATE_READY);
- if (error == H8_SUCCESS)
- return 1;
- h8_error("set display ready", error);
-#endif
- return 0;
-}
-
-static int h8_alloc_queues(void)
-{
- h8_cmd_q_t *qp;
- unsigned long flags;
- int i;
-
- qp = (h8_cmd_q_t *)kmalloc((sizeof (h8_cmd_q_t) * H8_Q_ALLOC_AMOUNT),
- GFP_KERNEL);
-
- if (!qp) {
- printk(KERN_ERR "H8: could not allocate memory for command queue\n");
- return(0);
- }
- /* add to the free queue */
- save_flags(flags); cli();
- for (i = 0; i < H8_Q_ALLOC_AMOUNT; i++) {
- /* place each at front of freeq */
- list_add(&qp[i].link, &h8_freeq);
- }
- restore_flags(flags);
- return (1);
-}
-
-/*
- * Basic means by which commands are sent to the H8.
- */
-void
-h8_q_cmd(u_char *cmd, int cmd_size, int resp_size)
-{
- h8_cmd_q_t *qp;
- unsigned long flags;
- int i;
-
- /* get cmd buf */
- save_flags(flags); cli();
- while (list_empty(&h8_freeq)) {
- Dprintk("H8: need to allocate more cmd buffers\n");
- restore_flags(flags);
- h8_alloc_queues();
- save_flags(flags); cli();
- }
- /* get first element from queue */
- qp = list_entry(h8_freeq.next, h8_cmd_q_t, link);
- list_del(&qp->link);
-
- restore_flags(flags);
-
- /* fill it in */
- for (i = 0; i < cmd_size; i++)
- qp->cmdbuf[i] = cmd[i];
- qp->ncmd = cmd_size;
- qp->nrsp = resp_size;
-
- /* queue it at the end of the cmd queue */
- save_flags(flags); cli();
-
- /* XXX this actually puts it at the start of cmd queue, bug? */
- list_add(&qp->link, &h8_cmdq);
-
- restore_flags(flags);
-
- h8_start_new_cmd();
-}
-
-void
-h8_start_new_cmd(void)
-{
- unsigned long flags;
- h8_cmd_q_t *qp;
-
- save_flags(flags); cli();
- if (h8_state != H8_IDLE) {
- if (h8_debug & 0x1)
- Dprintk("h8_start_new_cmd: not idle\n");
- restore_flags(flags);
- return;
- }
-
- if (!list_empty(&h8_actq)) {
- Dprintk("h8_start_new_cmd: inconsistency: IDLE with non-empty active queue!\n");
- restore_flags(flags);
- return;
- }
-
- if (list_empty(&h8_cmdq)) {
- Dprintk("h8_start_new_cmd: no command to dequeue\n");
- restore_flags(flags);
- return;
- }
- /*
- * Take first command off of the command queue and put
- * it on the active queue.
- */
- qp = list_entry(h8_cmdq.next, h8_cmd_q_t, link);
- list_del(&qp->link);
- /* XXX should this go to the end of the active queue? */
- list_add(&qp->link, &h8_actq);
- h8_state = H8_XMIT;
- if (h8_debug & 0x1)
- Dprintk("h8_start_new_cmd: Starting a command\n");
-
- qp->cnt = 1;
- WRITE_CMD(qp->cmdbuf[0]); /* Kick it off */
-
- restore_flags(flags);
- return;
-}
-
-void
-h8_send_next_cmd_byte(void)
-{
- h8_cmd_q_t *qp = list_entry(h8_actq.next, h8_cmd_q_t, link);
- int cnt;
-
- cnt = qp->cnt;
- qp->cnt++;
-
- if (h8_debug & 0x1)
- Dprintk("h8 sending next cmd byte 0x%x (0x%x)\n",
- cnt, qp->cmdbuf[cnt]);
-
- if (cnt) {
- WRITE_DATA(qp->cmdbuf[cnt]);
- } else {
- WRITE_CMD(qp->cmdbuf[cnt]);
- }
- return;
-}
-
-/*
- * Synchronize H8 communications channel for command transmission.
- */
-void
-h8_sync(void)
-{
- u_char buf[H8_MAX_CMD_SIZE];
-
- buf[0] = H8_SYNC;
- buf[1] = H8_SYNC_BYTE;
- h8_q_cmd(buf, 2, 1);
-}
-
-/*
- * Responds to external interrupt. Reads event status word and
- * decodes type of interrupt.
- */
-void
-h8_read_event_status(void)
-{
-
- if(h8_debug & 0x200)
- printk(KERN_DEBUG "h8_read_event_status: value 0x%x\n", intrbuf.word);
-
- /*
- * Power related items
- */
- if (intrbuf.word & H8_DC_CHANGE) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: DC_CHANGE\n");
- /* see if dc added or removed, set batt/dc flag, send event */
-
- h8_set_event_mask(H8_MANAGE_BATTERY);
- wake_up(&h8_monitor_wait);
- }
-
- if (intrbuf.word & H8_POWER_BUTTON) {
- printk(KERN_CRIT "Power switch pressed - please wait - preparing to power
-off\n");
- h8_set_event_mask(H8_POWER_BUTTON);
- wake_up(&h8_monitor_wait);
- }
-
- /*
- * Thermal related items
- */
- if (intrbuf.word & H8_THERMAL_THRESHOLD) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: THERMAL_THRESHOLD\n");
- h8_set_event_mask(H8_MANAGE_UTHERM);
- wake_up(&h8_monitor_wait);
- }
-
- /*
- * nops -for now
- */
- if (intrbuf.word & H8_DOCKING_STATION_STATUS) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: DOCKING_STATION_STATUS\n");
- /* read_ext_status */
- }
- if (intrbuf.word & H8_EXT_BATT_STATUS) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_STATUS\n");
-
- }
- if (intrbuf.word & H8_EXT_BATT_CHARGE_STATE) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_CHARGE_STATE\n");
-
- }
- if (intrbuf.word & H8_BATT_CHANGE_OVER) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: BATT_CHANGE_OVER\n");
-
- }
- if (intrbuf.word & H8_WATCHDOG) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: WATCHDOG\n");
- /* nop */
- }
- if (intrbuf.word & H8_SHUTDOWN) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: SHUTDOWN\n");
- /* nop */
- }
- if (intrbuf.word & H8_KEYBOARD) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: KEYBOARD\n");
- /* nop */
- }
- if (intrbuf.word & H8_EXT_MOUSE_OR_CASE_SWITCH) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: EXT_MOUSE_OR_CASE_SWITCH\n");
- /* read_ext_status*/
- }
- if (intrbuf.word & H8_INT_BATT_LOW) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: INT_BATT_LOW\n"); post
- /* event, warn user */
- }
- if (intrbuf.word & H8_INT_BATT_CHARGE_STATE) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: INT_BATT_CHARGE_STATE\n");
- /* nop - happens often */
- }
- if (intrbuf.word & H8_INT_BATT_STATUS) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: INT_BATT_STATUS\n");
-
- }
- if (intrbuf.word & H8_INT_BATT_CHARGE_THRESHOLD) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: INT_BATT_CHARGE_THRESHOLD\n");
- /* nop - happens often */
- }
- if (intrbuf.word & H8_EXT_BATT_LOW) {
- if(h8_debug & 0x4)
- printk(KERN_DEBUG "h8_read_event_status: EXT_BATT_LOW\n");
- /*if no internal, post event, warn user */
- /* else nop */
- }
-
- return;
-}
-
-/*
- * Function called when H8 has performed requested command.
- */
-static void
-h8_cmd_done(h8_cmd_q_t *qp)
-{
-
- /* what to do */
- switch (qp->cmdbuf[0]) {
- case H8_SYNC:
- if (h8_debug & 0x40000)
- printk(KERN_DEBUG "H8: Sync command done - byte returned was 0x%x\n",
- qp->rcvbuf[0]);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_SN:
- case H8_RD_ENET_ADDR:
- printk(KERN_DEBUG "H8: read Ethernet address: command done - address: %x - %x - %x - %x - %x - %x \n",
- qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2],
- qp->rcvbuf[3], qp->rcvbuf[4], qp->rcvbuf[5]);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_HW_VER:
- case H8_RD_MIC_VER:
- case H8_RD_MAX_TEMP:
- printk(KERN_DEBUG "H8: Max recorded CPU temp %d, Sys temp %d\n",
- qp->rcvbuf[0], qp->rcvbuf[1]);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_MIN_TEMP:
- printk(KERN_DEBUG "H8: Min recorded CPU temp %d, Sys temp %d\n",
- qp->rcvbuf[0], qp->rcvbuf[1]);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_CURR_TEMP:
- h8_sync_channel |= H8_RD_CURR_TEMP;
- xx.byte[0] = qp->rcvbuf[0];
- xx.byte[1] = qp->rcvbuf[1];
- wake_up(&h8_sync_wait);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_SYS_VARIENT:
- case H8_RD_PWR_ON_CYCLES:
- printk(KERN_DEBUG " H8: RD_PWR_ON_CYCLES command done\n");
- break;
-
- case H8_RD_PWR_ON_SECS:
- printk(KERN_DEBUG "H8: RD_PWR_ON_SECS command done\n");
- break;
-
- case H8_RD_RESET_STATUS:
- case H8_RD_PWR_DN_STATUS:
- case H8_RD_EVENT_STATUS:
- case H8_RD_ROM_CKSM:
- case H8_RD_EXT_STATUS:
- xx.byte[1] = qp->rcvbuf[0];
- xx.byte[0] = qp->rcvbuf[1];
- h8_sync_channel |= H8_GET_EXT_STATUS;
- wake_up(&h8_sync_wait);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_USER_CFG:
- case H8_RD_INT_BATT_VOLT:
- case H8_RD_DC_INPUT_VOLT:
- case H8_RD_HORIZ_PTR_VOLT:
- case H8_RD_VERT_PTR_VOLT:
- case H8_RD_EEPROM_STATUS:
- case H8_RD_ERR_STATUS:
- case H8_RD_NEW_BUSY_SPEED:
- case H8_RD_CONFIG_INTERFACE:
- case H8_RD_INT_BATT_STATUS:
- printk(KERN_DEBUG "H8: Read int batt status cmd done - returned was %x %x %x\n",
- qp->rcvbuf[0], qp->rcvbuf[1], qp->rcvbuf[2]);
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_RD_EXT_BATT_STATUS:
- case H8_RD_PWR_UP_STATUS:
- case H8_RD_EVENT_STATUS_MASK:
- case H8_CTL_EMU_BITPORT:
- case H8_DEVICE_CONTROL:
- if(h8_debug & 0x20000) {
- printk(KERN_DEBUG "H8: Device control cmd done - byte returned was 0x%x\n",
- qp->rcvbuf[0]);
- }
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_CTL_TFT_BRT_DC:
- case H8_CTL_WATCHDOG:
- case H8_CTL_MIC_PROT:
- case H8_CTL_INT_BATT_CHG:
- case H8_CTL_EXT_BATT_CHG:
- case H8_CTL_MARK_SPACE:
- case H8_CTL_MOUSE_SENSITIVITY:
- case H8_CTL_DIAG_MODE:
- case H8_CTL_IDLE_AND_BUSY_SPDS:
- printk(KERN_DEBUG "H8: Idle and busy speed command done\n");
- break;
-
- case H8_CTL_TFT_BRT_BATT:
- case H8_CTL_UPPER_TEMP:
- if(h8_debug & 0x10) {
- XDprintk("H8: ctl upper thermal thresh cmd done - returned was %d\n",
- qp->rcvbuf[0]);
- }
- list_add(&qp->link, &h8_freeq);
- break;
-
- case H8_CTL_LOWER_TEMP:
- case H8_CTL_TEMP_CUTOUT:
- case H8_CTL_WAKEUP:
- case H8_CTL_CHG_THRESHOLD:
- case H8_CTL_TURBO_MODE:
- case H8_SET_DIAG_STATUS:
- case H8_SOFTWARE_RESET:
- case H8_RECAL_PTR:
- case H8_SET_INT_BATT_PERCENT:
- case H8_WRT_CFG_INTERFACE_REG:
- case H8_WRT_EVENT_STATUS_MASK:
- case H8_ENTER_POST_MODE:
- case H8_EXIT_POST_MODE:
- case H8_RD_EEPROM:
- case H8_WRT_EEPROM:
- case H8_WRT_TO_STATUS_DISP:
- printk("H8: Write IO status display command done\n");
- break;
-
- case H8_DEFINE_SPC_CHAR:
- case H8_DEFINE_TABLE_STRING_ENTRY:
- case H8_PERFORM_EMU_CMD:
- case H8_EMU_RD_REG:
- case H8_EMU_WRT_REG:
- case H8_EMU_RD_RAM:
- case H8_EMU_WRT_RAM:
- case H8_BQ_RD_REG:
- case H8_BQ_WRT_REG:
- case H8_PWR_OFF:
- printk (KERN_DEBUG "H8: misc command completed\n");
- break;
- }
- return;
-}
-
-/*
- * Retrieve the current CPU temperature and case temperature. Provides
- * the feedback for the thermal control algorithm. Synchcronized via
- * sleep() for priority so that no other actions in the process will take
- * place before the data becomes available.
- */
-int
-h8_get_curr_temp(u_char curr_temp[])
-{
- u_char buf[H8_MAX_CMD_SIZE];
- unsigned long flags;
-
- memset(buf, 0, H8_MAX_CMD_SIZE);
- buf[0] = H8_RD_CURR_TEMP;
-
- h8_q_cmd(buf, 1, 2);
-
- save_flags(flags); cli();
-
- while((h8_sync_channel & H8_RD_CURR_TEMP) == 0)
- sleep_on(&h8_sync_wait);
-
- restore_flags(flags);
-
- h8_sync_channel &= ~H8_RD_CURR_TEMP;
- curr_temp[0] = xx.byte[0];
- curr_temp[1] = xx.byte[1];
- xx.word = 0;
-
- if(h8_debug & 0x8)
- printk("H8: curr CPU temp %d, Sys temp %d\n",
- curr_temp[0], curr_temp[1]);
- return 0;
-}
-
-static void
-h8_get_max_temp(void)
-{
- u_char buf[H8_MAX_CMD_SIZE];
-
- buf[0] = H8_RD_MAX_TEMP;
- h8_q_cmd(buf, 1, 2);
-}
-
-/*
- * Assigns an upper limit to the value of the H8 thermal interrupt.
- * As an example setting a value of 115 F here will cause the
- * interrupt to trigger when the CPU temperature reaches 115 F.
- */
-static void
-h8_set_upper_therm_thold(int thold)
-{
- u_char buf[H8_MAX_CMD_SIZE];
-
- /* write 0 to reinitialize interrupt */
- buf[0] = H8_CTL_UPPER_TEMP;
- buf[1] = 0x0;
- buf[2] = 0x0;
- h8_q_cmd(buf, 3, 1);
-
- /* Do it for real */
- buf[0] = H8_CTL_UPPER_TEMP;
- buf[1] = 0x0;
- buf[2] = thold;
- h8_q_cmd(buf, 3, 1);
-}
-
-static void
-h8_get_upper_therm_thold(void)
-{
- u_char buf[H8_MAX_CMD_SIZE];
-
- buf[0] = H8_CTL_UPPER_TEMP;
- buf[1] = 0xff;
- buf[2] = 0;
- h8_q_cmd(buf, 3, 1);
-}
-
-/*
- * The external status word contains information on keyboard controller,
- * power button, changes in external batt status, change in DC state,
- * docking station, etc. General purpose querying use.
- */
-int
-h8_get_ext_status(u_char stat_word[])
-{
- u_char buf[H8_MAX_CMD_SIZE];
- unsigned long flags;
-
- memset(buf, 0, H8_MAX_CMD_SIZE);
- buf[0] = H8_RD_EXT_STATUS;
-
- h8_q_cmd(buf, 1, 2);
-
- save_flags(flags); cli();
-
- while((h8_sync_channel & H8_GET_EXT_STATUS) == 0)
- sleep_on(&h8_sync_wait);
-
- restore_flags(flags);
-
- h8_sync_channel &= ~H8_GET_EXT_STATUS;
- stat_word[0] = xx.byte[0];
- stat_word[1] = xx.byte[1];
- xx.word = 0;
-
- if(h8_debug & 0x8)
- printk("H8: curr ext status %x, %x\n",
- stat_word[0], stat_word[1]);
-
- return 0;
-}
-
-/*
- * Thread attached to task 0 manages thermal/physcial state of Alphabook.
- * When a condition is detected by the interrupt service routine, the
- * isr does a wakeup() on h8_monitor_wait. The mask value is then
- * screened for the appropriate action.
- */
-
-int
-h8_monitor_thread(void * unused)
-{
- u_char curr_temp[2];
-
- /*
- * Need a logic based safety valve here. During boot when this thread is
- * started and the thermal interrupt is not yet initialized this logic
- * checks the temperature and acts accordingly. When this path is acted
- * upon system boot is painfully slow, however, the priority associated
- * with overheating is high enough to warrant this action.
- */
- h8_get_curr_temp(curr_temp);
-
- printk(KERN_INFO "H8: Initial CPU temp: %d\n", curr_temp[0]);
-
- if(curr_temp[0] >= h8_uthermal_threshold) {
- h8_set_event_mask(H8_MANAGE_UTHERM);
- h8_manage_therm();
- } else {
- /*
- * Arm the upper thermal limit of the H8 so that any temp in
- * excess will trigger the thermal control mechanism.
- */
- h8_set_upper_therm_thold(h8_uthermal_threshold);
- }
-
- for(;;) {
- sleep_on(&h8_monitor_wait);
-
- if(h8_debug & 0x2)
- printk(KERN_DEBUG "h8_monitor_thread awakened, mask:%x\n",
- h8_event_mask);
-
- if (h8_event_mask & (H8_MANAGE_UTHERM|H8_MANAGE_LTHERM)) {
- h8_manage_therm();
- }
-
-#if 0
- if (h8_event_mask & H8_POWER_BUTTON) {
- h8_system_down();
- }
-
- /*
- * If an external DC supply is removed or added make
- * appropriate CPU speed adjustments.
- */
- if (h8_event_mask & H8_MANAGE_BATTERY) {
- h8_run_level_3_manage(H8_RUN);
- h8_clear_event_mask(H8_MANAGE_BATTERY);
- }
-#endif
- }
-}
-
-/*
- * Function implements the following policy. When the machine is booted
- * the system is set to run at full clock speed. When the upper thermal
- * threshold is reached as a result of full clock a damping factor is
- * applied to cool off the cpu. The default value is one quarter clock
- * (57 Mhz). When as a result of this cooling a temperature lower by
- * hmc_uthermal_window is reached, the machine is reset to a higher
- * speed, one half clock (115 Mhz). One half clock is maintained until
- * the upper thermal threshold is again reached restarting the cycle.
- */
-
-int
-h8_manage_therm(void)
-{
- u_char curr_temp[2];
-
- if(h8_event_mask & H8_MANAGE_UTHERM) {
- /* Upper thermal interrupt received, need to cool down. */
- if(h8_debug & 0x10)
- printk(KERN_WARNING "H8: Thermal threshold %d F reached\n",
- h8_uthermal_threshold);
- h8_set_cpu_speed(h8_udamp);
- h8_clear_event_mask(H8_MANAGE_UTHERM);
- h8_set_event_mask(H8_MANAGE_LTHERM);
- /* Check again in 30 seconds for CPU temperature */
- h8_start_monitor_timer(H8_TIMEOUT_INTERVAL);
- } else if (h8_event_mask & H8_MANAGE_LTHERM) {
- /* See how cool the system has become as a result
- of the reduction in speed. */
- h8_get_curr_temp(curr_temp);
- last_temp = curr_temp[0];
- if (curr_temp[0] < (h8_uthermal_threshold - h8_uthermal_window))
- {
- /* System cooling has progressed to a point
- that the CPU may be sped up. */
- h8_set_upper_therm_thold(h8_uthermal_threshold);
- h8_set_cpu_speed(h8_ldamp); /* adjustable */
- if(h8_debug & 0x10)
- printk(KERN_WARNING "H8: CPU cool, applying cpu_divisor: %d \n",
- h8_ldamp);
- h8_clear_event_mask(H8_MANAGE_LTHERM);
- }
- else /* Not cool enough yet, check again in 30 seconds. */
- h8_start_monitor_timer(H8_TIMEOUT_INTERVAL);
- } else {
-
- }
- return 0;
-}
-
-/*
- * Function conditions the value of global_rpb_counter before
- * calling the primitive which causes the actual speed change.
- */
-void
-h8_set_cpu_speed(int speed_divisor)
-{
-
-#ifdef NOT_YET
-/*
- * global_rpb_counter is consumed by alpha_delay() in determining just
- * how much time to delay. It is necessary that the number of microseconds
- * in DELAY(n) be kept consistent over a variety of CPU clock speeds.
- * To that end global_rpb_counter is here adjusted.
- */
-
- switch (speed_divisor) {
- case 0:
- global_rpb_counter = rpb->rpb_counter * 2L;
- break;
- case 1:
- global_rpb_counter = rpb->rpb_counter * 4L / 3L ;
- break;
- case 3:
- global_rpb_counter = rpb->rpb_counter / 2L;
- break;
- case 4:
- global_rpb_counter = rpb->rpb_counter / 4L;
- break;
- case 5:
- global_rpb_counter = rpb->rpb_counter / 8L;
- break;
- /*
- * This case most commonly needed for cpu_speed_divisor
- * of 2 which is the value assigned by the firmware.
- */
- default:
- global_rpb_counter = rpb->rpb_counter;
- break;
- }
-#endif /* NOT_YET */
-
- if(h8_debug & 0x8)
- printk(KERN_DEBUG "H8: Setting CPU speed to %d MHz\n",
- speed_tab[speed_divisor]);
-
- /* Make the actual speed change */
- lca_clock_fiddle(speed_divisor);
-}
-
-/*
- * Gets value stored in rpb representing CPU clock speed and adjusts this
- * value based on the current clock speed divisor.
- */
-u_long
-h8_get_cpu_speed(void)
-{
- u_long speed = 0;
- u_long counter;
-
-#ifdef NOT_YET
- counter = rpb->rpb_counter / 1000000L;
-
- switch (alphabook_get_clock()) {
- case 0:
- speed = counter * 2L;
- break;
- case 1:
- speed = counter * 4L / 3L ;
- break;
- case 2:
- speed = counter;
- break;
- case 3:
- speed = counter / 2L;
- break;
- case 4:
- speed = counter / 4L;
- break;
- case 5:
- speed = counter / 8L;
- break;
- default:
- break;
- }
- if(h8_debug & 0x8)
- printk(KERN_DEBUG "H8: CPU speed current setting: %d MHz\n", speed);
-#endif /* NOT_YET */
- return speed;
-}
-
-static void
-h8_activate_monitor(unsigned long unused)
-{
- unsigned long flags;
-
- save_flags(flags); cli();
- h8_monitor_timer_active = 0;
- restore_flags(flags);
-
- wake_up(&h8_monitor_wait);
-}
-
-static void
-h8_start_monitor_timer(unsigned long secs)
-{
- unsigned long flags;
-
- if (h8_monitor_timer_active)
- return;
-
- save_flags(flags); cli();
- h8_monitor_timer_active = 1;
- restore_flags(flags);
-
- init_timer(&h8_monitor_timer);
- h8_monitor_timer.function = h8_activate_monitor;
- h8_monitor_timer.expires = secs * HZ + jiffies;
- add_timer(&h8_monitor_timer);
-}
-
-static void h8_set_event_mask(int mask)
-{
- unsigned long flags;
-
- save_flags(flags); cli();
- h8_event_mask |= mask;
- restore_flags(flags);
-}
-
-static void h8_clear_event_mask(int mask)
-{
- unsigned long flags;
-
- save_flags(flags); cli();
- h8_event_mask &= (~mask);
- restore_flags(flags);
-}
-
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- */
-
-#ifndef __H8_H__
-#define __H8_H__
-
-/*
- * Register address and offsets
- */
-#define H8_BASE_ADDR 0x170 /* default */
-#define H8_IRQ 9 /* default */
-#define H8_STATUS_REG_OFF 0x4
-#define H8_CMD_REG_OFF 0x4
-#define H8_DATA_REG_OFF 0x0
-
-
-/* H8 register bit definitions */
-/* status register */
-#define H8_OFULL 0x1 /* output data register full */
-#define H8_IFULL 0x2 /* input data register full */
-#define H8_CMD 0x8 /* command / not data */
-
-#define H8_INTR 0xfa
-#define H8_NACK 0xfc
-#define H8_BYTE_LEVEL_ACK 0xfd
-#define H8_CMD_ACK 0xfe
-#define H8_SYNC_BYTE 0x99
-
-/*
- * H8 command definitions
- */
-/* System info commands */
-#define H8_SYNC 0x0
-#define H8_RD_SN 0x1
-#define H8_RD_ENET_ADDR 0x2
-#define H8_RD_HW_VER 0x3
-#define H8_RD_MIC_VER 0x4
-#define H8_RD_MAX_TEMP 0x5
-#define H8_RD_MIN_TEMP 0x6
-#define H8_RD_CURR_TEMP 0x7
-#define H8_RD_SYS_VARIENT 0x8
-#define H8_RD_PWR_ON_CYCLES 0x9
-#define H8_RD_PWR_ON_SECS 0xa
-#define H8_RD_RESET_STATUS 0xb
-#define H8_RD_PWR_DN_STATUS 0xc
-#define H8_RD_EVENT_STATUS 0xd
-#define H8_RD_ROM_CKSM 0xe
-#define H8_RD_EXT_STATUS 0xf
-#define H8_RD_USER_CFG 0x10
-#define H8_RD_INT_BATT_VOLT 0x11
-#define H8_RD_DC_INPUT_VOLT 0x12
-#define H8_RD_HORIZ_PTR_VOLT 0x13
-#define H8_RD_VERT_PTR_VOLT 0x14
-#define H8_RD_EEPROM_STATUS 0x15
-#define H8_RD_ERR_STATUS 0x16
-#define H8_RD_NEW_BUSY_SPEED 0x17
-#define H8_RD_CONFIG_INTERFACE 0x18
-#define H8_RD_INT_BATT_STATUS 0x19
-#define H8_RD_EXT_BATT_STATUS 0x1a
-#define H8_RD_PWR_UP_STATUS 0x1b
-#define H8_RD_EVENT_STATUS_MASK 0x56
-
-/* Read/write/modify commands */
-#define H8_CTL_EMU_BITPORT 0x32
-#define H8_DEVICE_CONTROL 0x21
-#define H8_CTL_TFT_BRT_DC 0x22
-#define H8_CTL_WATCHDOG 0x23
-#define H8_CTL_MIC_PROT 0x24
-#define H8_CTL_INT_BATT_CHG 0x25
-#define H8_CTL_EXT_BATT_CHG 0x26
-#define H8_CTL_MARK_SPACE 0x27
-#define H8_CTL_MOUSE_SENSITIVITY 0x28
-#define H8_CTL_DIAG_MODE 0x29
-#define H8_CTL_IDLE_AND_BUSY_SPDS 0x2a
-#define H8_CTL_TFT_BRT_BATT 0x2b
-#define H8_CTL_UPPER_TEMP 0x2c
-#define H8_CTL_LOWER_TEMP 0x2d
-#define H8_CTL_TEMP_CUTOUT 0x2e
-#define H8_CTL_WAKEUP 0x2f
-#define H8_CTL_CHG_THRESHOLD 0x30
-#define H8_CTL_TURBO_MODE 0x31
-#define H8_SET_DIAG_STATUS 0x40
-#define H8_SOFTWARE_RESET 0x41
-#define H8_RECAL_PTR 0x42
-#define H8_SET_INT_BATT_PERCENT 0x43
-#define H8_WRT_CFG_INTERFACE_REG 0x45
-#define H8_WRT_EVENT_STATUS_MASK 0x57
-#define H8_ENTER_POST_MODE 0x46
-#define H8_EXIT_POST_MODE 0x47
-
-/* Block transfer commands */
-#define H8_RD_EEPROM 0x50
-#define H8_WRT_EEPROM 0x51
-#define H8_WRT_TO_STATUS_DISP 0x52
-#define H8_DEFINE_SPC_CHAR 0x53
-
-/* Generic commands */
-#define H8_DEFINE_TABLE_STRING_ENTRY 0x60
-
-/* Battery control commands */
-#define H8_PERFORM_EMU_CMD 0x70
-#define H8_EMU_RD_REG 0x71
-#define H8_EMU_WRT_REG 0x72
-#define H8_EMU_RD_RAM 0x73
-#define H8_EMU_WRT_RAM 0x74
-#define H8_BQ_RD_REG 0x75
-#define H8_BQ_WRT_REG 0x76
-
-/* System admin commands */
-#define H8_PWR_OFF 0x80
-
-/*
- * H8 command related definitions
- */
-
-/* device control argument bits */
-#define H8_ENAB_EXTSMI 0x1
-#define H8_DISAB_IRQ 0x2
-#define H8_ENAB_FLASH_WRT 0x4
-#define H8_ENAB_THERM 0x8
-#define H8_ENAB_INT_PTR 0x10
-#define H8_ENAB_LOW_SPD_IND 0x20
-#define H8_ENAB_EXT_PTR 0x40
-#define H8_DISAB_PWR_OFF_SW 0x80
-#define H8_POWER_OFF 0x80
-
-/* H8 read event status bits */
-#define H8_DC_CHANGE 0x1
-#define H8_INT_BATT_LOW 0x2
-#define H8_INT_BATT_CHARGE_THRESHOLD 0x4
-#define H8_INT_BATT_CHARGE_STATE 0x8
-#define H8_INT_BATT_STATUS 0x10
-#define H8_EXT_BATT_CHARGE_STATE 0x20
-#define H8_EXT_BATT_LOW 0x40
-#define H8_EXT_BATT_STATUS 0x80
-#define H8_THERMAL_THRESHOLD 0x100
-#define H8_WATCHDOG 0x200
-#define H8_DOCKING_STATION_STATUS 0x400
-#define H8_EXT_MOUSE_OR_CASE_SWITCH 0x800
-#define H8_KEYBOARD 0x1000
-#define H8_BATT_CHANGE_OVER 0x2000
-#define H8_POWER_BUTTON 0x4000
-#define H8_SHUTDOWN 0x8000
-
-/* H8 control idle and busy speeds */
-#define H8_SPEED_LOW 0x1
-#define H8_SPEED_MED 0x2
-#define H8_SPEED_HI 0x3
-#define H8_SPEED_LOCKED 0x80
-
-#define H8_MAX_CMD_SIZE 18
-#define H8_Q_ALLOC_AMOUNT 10
-
-/* H8 state field values */
-#define H8_IDLE 1
-#define H8_XMIT 2
-#define H8_RCV 3
-#define H8_RESYNC 4
-#define H8_INTR_MODE 5
-
-/* Mask values for control functions */
-#define UTH_HYSTERESIS 5
-#define DEFAULT_UTHERMAL_THRESHOLD 115
-#define H8_TIMEOUT_INTERVAL 30
-#define H8_RUN 4
-
-#define H8_GET_MAX_TEMP 0x1
-#define H8_GET_CURR_TEMP 0x2
-#define H8_GET_UPPR_THRMAL_THOLD 0x4
-#define H8_GET_ETHERNET_ADDR 0x8
-#define H8_SYNC_OP 0x10
-#define H8_SET_UPPR_THRMAL_THOLD 0x20
-#define H8_GET_INT_BATT_STAT 0x40
-#define H8_GET_CPU_SPD 0x80
-#define H8_MANAGE_UTHERM 0x100
-#define H8_MANAGE_LTHERM 0x200
-#define H8_HALT 0x400
-#define H8_CRASH 0x800
-#define H8_GET_EXT_STATUS 0x10000
-#define H8_MANAGE_QUIET 0x20000
-#define H8_MANAGE_SPEEDUP 0x40000
-#define H8_MANAGE_BATTERY 0x80000
-#define H8_SYSTEM_DELAY_TEST 0x100000
-#define H8_POWER_SWITCH_TEST 0x200000
-
-/* CPU speeds and clock divisor values */
-#define MHZ_14 5
-#define MHZ_28 4
-#define MHZ_57 3
-#define MHZ_115 2
-#define MHZ_230 0
-
-/*
- * H8 data
- */
-struct h8_data {
- u_int ser_num;
- u_char ether_add[6];
- u_short hw_ver;
- u_short mic_ver;
- u_short max_tmp;
- u_short min_tmp;
- u_short cur_tmp;
- u_int sys_var;
- u_int pow_on;
- u_int pow_on_secs;
- u_char reset_status;
- u_char pwr_dn_status;
- u_short event_status;
- u_short rom_cksm;
- u_short ext_status;
- u_short u_cfg;
- u_char ibatt_volt;
- u_char dc_volt;
- u_char ptr_horiz;
- u_char ptr_vert;
- u_char eeprom_status;
- u_char error_status;
- u_char new_busy_speed;
- u_char cfg_interface;
- u_short int_batt_status;
- u_short ext_batt_status;
- u_char pow_up_status;
- u_char event_status_mask;
-};
-
-
-/*
- * H8 command buffers
- */
-typedef struct h8_cmd_q {
- struct list_head link; /* double linked list */
- int ncmd; /* number of bytes in command */
- int nrsp; /* number of bytes in response */
- int cnt; /* number of bytes sent/received */
- int nacks; /* number of byte level acks */
- u_char cmdbuf[H8_MAX_CMD_SIZE]; /* buffer to store command */
- u_char rcvbuf[H8_MAX_CMD_SIZE]; /* buffer to store response */
-} h8_cmd_q_t;
-
-union intr_buf {
- u_char byte[2];
- u_int word;
-};
-
-#endif /* __H8_H_ */
+++ /dev/null
-/*
- * linux/drivers/char/lp_old98.c
- *
- * printer port driver for ancient PC-9800s with no bidirectional port support
- *
- * Copyright (C) 1998,99 Kousuke Takai <tak@kmc.kyoto-u.ac.jp>,
- * Kyoto University Microcomputer Club
- *
- * This driver is based on and has compatibility with `lp.c',
- * generic PC printer port driver.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/config.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/console.h>
-#include <linux/fs.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/lp.h>
-
-/*
- * I/O port numbers
- */
-#define LP_PORT_DATA 0x40
-#define LP_PORT_STATUS (LP_PORT_DATA + 2)
-#define LP_PORT_STROBE (LP_PORT_DATA + 4)
-#define LP_PORT_CONTROL (LP_PORT_DATA + 6)
-
-#define LP_PORT_H98MODE 0x0448
-#define LP_PORT_EXTMODE 0x0149
-
-/*
- * bit mask for I/O
- */
-#define LP_MASK_nBUSY (1 << 2)
-#define LP_MASK_nSTROBE (1 << 7)
-
-#define LP_CONTROL_ASSERT_STROBE (0x0e)
-#define LP_CONTROL_NEGATE_STROBE (0x0f)
-
-/*
- * Acceptable maximum value for non-privileged user for LPCHARS ioctl.
- */
-#define LP_CHARS_NOPRIV_MAX 65535
-
-#define DC1 '\x11'
-#define DC3 '\x13'
-
-/* PC-9800s have at least and at most one old-style printer port. */
-static struct lp_struct lp = {
- .flags = LP_EXIST | LP_ABORTOPEN,
- .chars = LP_INIT_CHAR,
- .time = LP_INIT_TIME,
- .wait = LP_INIT_WAIT,
-};
-
-static int dc1_check;
-static spinlock_t lp_old98_lock = SPIN_LOCK_UNLOCKED;
-
-
-#undef LP_OLD98_DEBUG
-
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-static struct console lp_old98_console; /* defined later */
-static short saved_console_flags;
-#endif
-
-static DECLARE_WAIT_QUEUE_HEAD (lp_old98_waitq);
-
-static void lp_old98_timer_function(unsigned long data)
-{
- if (inb(LP_PORT_STATUS) & LP_MASK_nBUSY)
- wake_up_interruptible(&lp_old98_waitq);
- else {
- struct timer_list *t = (struct timer_list *) data;
-
- t->expires = jiffies + 1;
- add_timer(t);
- }
-}
-
-static inline int lp_old98_wait_ready(void)
-{
- struct timer_list timer;
-
- init_timer(&timer);
- timer.function = lp_old98_timer_function;
- timer.expires = jiffies + 1;
- timer.data = (unsigned long)&timer;
- add_timer(&timer);
- interruptible_sleep_on(&lp_old98_waitq);
- del_timer(&timer);
- return signal_pending(current);
-}
-
-static inline int lp_old98_char(char lpchar)
-{
- unsigned long count = 0;
-#ifdef LP_STATS
- int tmp;
-#endif
-
- while (!(inb(LP_PORT_STATUS) & LP_MASK_nBUSY)) {
- count++;
- if (count >= lp.chars)
- return 0;
- }
-
- outb(lpchar, LP_PORT_DATA);
-
-#ifdef LP_STATS
- /*
- * Update lp statsistics here (and between next two outb()'s).
- * Time to compute it is part of storobe delay.
- */
- if (count > lp.stats.maxwait) {
-#ifdef LP_OLD98_DEBUG
- printk(KERN_DEBUG "lp_old98: success after %d counts.\n",
- count);
-#endif
- lp.stats.maxwait = count;
- }
- count *= 256;
- tmp = count - lp.stats.meanwait;
- if (tmp < 0)
- tmp = -tmp;
-#endif
- ndelay(lp.wait);
-
- /* negate PSTB# (activate strobe) */
- outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
-
-#ifdef LP_STATS
- lp.stats.meanwait = (255 * lp.stats.meanwait + count + 128) / 256;
- lp.stats.mdev = (127 * lp.stats.mdev + tmp + 64) / 128;
- lp.stats.chars ++;
-#endif
-
- ndelay(lp.wait);
-
- /* assert PSTB# (deactivate strobe) */
- outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
-
- return 1;
-}
-
-static ssize_t lp_old98_write(struct file * file,
- const char * buf, size_t count,
- loff_t *dummy)
-{
- unsigned long total_bytes_written = 0;
-
- if (!access_ok(VERIFY_READ, buf, count))
- return -EFAULT;
-
-#ifdef LP_STATS
- if (jiffies - lp.lastcall > lp.time)
- lp.runchars = 0;
- lp.lastcall = jiffies;
-#endif
-
- do {
- unsigned long bytes_written = 0;
- unsigned long copy_size
- = (count < LP_BUFFER_SIZE ? count : LP_BUFFER_SIZE);
-
- if (__copy_from_user(lp.lp_buffer, buf, copy_size))
- return -EFAULT;
-
- while (bytes_written < copy_size) {
- if (lp_old98_char(lp.lp_buffer[bytes_written]))
- bytes_written ++;
- else {
-#ifdef LP_STATS
- int rc = lp.runchars + bytes_written;
-
- if (rc > lp.stats.maxrun)
- lp.stats.maxrun = rc;
-
- lp.stats.sleeps ++;
-#endif
-#ifdef LP_OLD98_DEBUG
- printk(KERN_DEBUG
- "lp_old98: sleeping at %d characters"
- " for %d jiffies\n",
- lp.runchars, lp.time);
- lp.runchars = 0;
-#endif
- if (lp_old98_wait_ready())
- return ((total_bytes_written
- + bytes_written)
- ? : -EINTR);
- }
- }
- total_bytes_written += bytes_written;
- buf += bytes_written;
-#ifdef LP_STATS
- lp.runchars += bytes_written;
-#endif
- count -= bytes_written;
- } while (count > 0);
-
- return total_bytes_written;
-}
-
-static int lp_old98_open(struct inode * inode, struct file * file)
-{
- if (iminor(inode) != 0)
- return -ENXIO;
-
- if (lp.flags & LP_BUSY)
- return -EBUSY;
-
- if (dc1_check && (lp.flags & LP_ABORTOPEN)
- && !(file->f_flags & O_NONBLOCK)) {
- /*
- * Check whether printer is on-line.
- * PC-9800's old style port have only BUSY# as status input,
- * so that it is impossible to distinguish that the printer is
- * ready and that the printer is off-line or not connected
- * (in both case BUSY# is in the same state). So:
- *
- * (1) output DC1 (0x11) to printer port and do strobe.
- * (2) watch BUSY# line for a while. If BUSY# is pulled
- * down, the printer will be ready. Otherwise,
- * it will be off-line (or not connected, or power-off,
- * ...).
- *
- * The source of this procedure:
- * Terumasa KODAKA, Kazufumi SHIMIZU, Yu HAYAMI:
- * `PC-9801 Super Technique', Ascii, 1992.
- */
- int count;
- unsigned long flags;
-
- /* interrupts while check is fairly bad */
- spin_lock_irqsave(&lp_old98_lock, flags);
-
- if (!lp_old98_char(DC1)) {
- spin_unlock_irqrestore(&lp_old98_lock, flags);
- return -EBUSY;
- }
- count = (unsigned int)dc1_check > 10000 ? 10000 : dc1_check;
- while (inb(LP_PORT_STATUS) & LP_MASK_nBUSY) {
- if (--count == 0) {
- spin_unlock_irqrestore(&lp_old98_lock, flags);
- return -ENODEV;
- }
- }
- spin_unlock_irqrestore(&lp_old98_lock, flags);
- }
-
- if ((lp.lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL)) == NULL)
- return -ENOMEM;
-
- lp.flags |= LP_BUSY;
-
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
- saved_console_flags = lp_old98_console.flags;
- lp_old98_console.flags &= ~CON_ENABLED;
-#endif
- return 0;
-}
-
-static int lp_old98_release(struct inode * inode, struct file * file)
-{
- kfree(lp.lp_buffer);
- lp.lp_buffer = NULL;
- lp.flags &= ~LP_BUSY;
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
- lp_old98_console.flags = saved_console_flags;
-#endif
- return 0;
-}
-
-static int lp_old98_init_device(void)
-{
- unsigned char data;
-
- if ((data = inb(LP_PORT_EXTMODE)) != 0xFF && (data & 0x10)) {
- printk(KERN_INFO
- "lp_old98: shutting down extended parallel port mode...\n");
- outb(data & ~0x10, LP_PORT_EXTMODE);
- }
-#ifdef PC98_HW_H98
- if ((pc98_hw_flags & PC98_HW_H98)
- && ((data = inb(LP_PORT_H98MODE)) & 0x01)) {
- printk(KERN_INFO
- "lp_old98: shutting down H98 full centronics mode...\n");
- outb(data & ~0x01, LP_PORT_H98MODE);
- }
-#endif
- return 0;
-}
-
-static int lp_old98_ioctl(struct inode *inode, struct file *file,
- unsigned int command, unsigned long arg)
-{
- int retval = 0;
-
- switch (command) {
- case LPTIME:
- lp.time = arg * HZ/100;
- break;
- case LPCHAR:
- lp.chars = arg;
- break;
- case LPABORT:
- if (arg)
- lp.flags |= LP_ABORT;
- else
- lp.flags &= ~LP_ABORT;
- break;
- case LPABORTOPEN:
- if (arg)
- lp.flags |= LP_ABORTOPEN;
- else
- lp.flags &= ~LP_ABORTOPEN;
- break;
- case LPCAREFUL:
- /* do nothing */
- break;
- case LPWAIT:
- lp.wait = arg;
- break;
- case LPGETIRQ:
- retval = put_user(0, (int *)arg);
- break;
- case LPGETSTATUS:
- /*
- * convert PC-9800's status to IBM PC's one, so that tunelp(8)
- * works in the same way on this driver.
- */
- retval = put_user((inb(LP_PORT_STATUS) & LP_MASK_nBUSY)
- ? (LP_PBUSY | LP_PERRORP) : LP_PERRORP,
- (int *)arg);
- break;
- case LPRESET:
- retval = lp_old98_init_device();
- break;
-#ifdef LP_STATS
- case LPGETSTATS:
- if (copy_to_user((struct lp_stats *)arg, &lp.stats,
- sizeof(struct lp_stats)))
- retval = -EFAULT;
- else if (suser())
- memset(&lp.stats, 0, sizeof(struct lp_stats));
- break;
-#endif
- case LPGETFLAGS:
- retval = put_user(lp.flags, (int *)arg);
- break;
- case LPSETIRQ:
- default:
- retval = -EINVAL;
- }
- return retval;
-}
-
-static struct file_operations lp_old98_fops = {
- .owner = THIS_MODULE,
- .write = lp_old98_write,
- .ioctl = lp_old98_ioctl,
- .open = lp_old98_open,
- .release = lp_old98_release,
-};
-
-/*
- * Support for console on lp_old98
- */
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
-
-static inline void io_delay(void)
-{
- unsigned char dummy; /* actually not output */
-
- asm volatile ("out%B0 %0,%1" : "=a"(dummy) : "N"(0x5f));
-}
-
-static void lp_old98_console_write(struct console *console,
- const char *s, unsigned int count)
-{
- int i;
- static unsigned int timeout_run = 0;
-
- while (count) {
- /* wait approx 1.2 seconds */
- for (i = 2000000; !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY);
- io_delay())
- if (!--i) {
- if (++timeout_run >= 10)
- /* disable forever... */
- console->flags &= ~CON_ENABLED;
- return;
- }
-
- timeout_run = 0;
-
- if (*s == '\n') {
- outb('\r', LP_PORT_DATA);
- io_delay();
- io_delay();
- outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
- io_delay();
- io_delay();
- outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
- io_delay();
- io_delay();
- for (i = 1000000;
- !(inb(LP_PORT_STATUS) & LP_MASK_nBUSY);
- io_delay())
- if (!--i)
- return;
- }
-
- outb(*s++, LP_PORT_DATA);
- io_delay();
- io_delay();
- outb(LP_CONTROL_ASSERT_STROBE, LP_PORT_CONTROL);
- io_delay();
- io_delay();
- outb(LP_CONTROL_NEGATE_STROBE, LP_PORT_CONTROL);
- io_delay();
- io_delay();
-
- --count;
- }
-}
-
-static struct console lp_old98_console = {
- .name = "lp_old98",
- .write = lp_old98_console_write,
- .flags = CON_PRINTBUFFER,
- .index = -1,
-};
-
-#endif /* console on lp_old98 */
-
-static int __init lp_old98_init(void)
-{
- char *errmsg = "I/O ports already occupied, giving up.";
-
-#ifdef PC98_HW_H98
- if (pc98_hw_flags & PC98_HW_H98)
- if (!request_region(LP_PORT_H98MODE, 1, "lp_old98")
- goto err1;
-#endif
- if (!request_region(LP_PORT_DATA, 1, "lp_old98"))
- goto err2;
- if (!request_region(LP_PORT_STATUS, 1, "lp_old98"))
- goto err3;
- if (!request_region(LP_PORT_STROBE, 1, "lp_old98"))
- goto err4;
- if (!request_region(LP_PORT_EXTMODE, 1, "lp_old98"))
- goto err5;
- if (!register_chrdev(LP_MAJOR, "lp", &lp_old98_fops)) {
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
- register_console(&lp_old98_console);
- printk(KERN_INFO "lp_old98: console ready\n");
-#endif
- /*
- * rest are not needed by this driver,
- * but for locking out other printer drivers...
- */
- lp_old98_init_device();
- return 0;
- } else
- errmsg = "unable to register device";
-
- release_region(LP_PORT_EXTMODE, 1);
-err5:
- release_region(LP_PORT_STROBE, 1);
-err4:
- release_region(LP_PORT_STATUS, 1);
-err3:
- release_region(LP_PORT_DATA, 1);
-err2:
-#ifdef PC98_HW_H98
- if (pc98_hw_flags & PC98_HW_H98)
- release_region(LP_PORT_H98MODE, 1);
-
-err1:
-#endif
- printk(KERN_ERR "lp_old98: %s\n", errmsg);
- return -EBUSY;
-}
-
-static void __exit lp_old98_exit(void)
-{
-#ifdef CONFIG_PC9800_OLDLP_CONSOLE
- unregister_console(&lp_old98_console);
-#endif
- unregister_chrdev(LP_MAJOR, "lp");
-
- release_region(LP_PORT_DATA, 1);
- release_region(LP_PORT_STATUS, 1);
- release_region(LP_PORT_STROBE, 1);
-#ifdef PC98_HW_H98
- if (pc98_hw_flags & PC98_HW_H98)
- release_region(LP_PORT_H98MODE, 1);
-#endif
- release_region(LP_PORT_EXTMODE, 1);
-}
-
-#ifndef MODULE
-static int __init lp_old98_setup(char *str)
-{
- int ints[4];
-
- str = get_options(str, ARRAY_SIZE(ints), ints);
- if (ints[0] > 0)
- dc1_check = ints[1];
- return 1;
-}
-__setup("lp_old98_dc1_check=", lp_old98_setup);
-#endif
-
-MODULE_PARM(dc1_check, "i");
-MODULE_AUTHOR("Kousuke Takai <tak@kmc.kyoto-u.ac.jp>");
-MODULE_DESCRIPTION("PC-9800 old printer port driver");
-MODULE_LICENSE("GPL");
-
-module_init(lp_old98_init);
-module_exit(lp_old98_exit);
+++ /dev/null
-/* $Id: sh-sci.c,v 1.16 2004/02/10 17:04:17 lethal Exp $
- *
- * linux/drivers/char/sh-sci.c
- *
- * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
- * Copyright (C) 1999, 2000 Niibe Yutaka
- * Copyright (C) 2000 Sugioka Toshinobu
- * Modified to support multiple serial ports. Stuart Menefy (May 2000).
- * Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
- * Modified to support H8/300 Series. Yoshinori Sato (Feb 2004).
- *
- * TTY code is based on sx.c (Specialix SX driver) by:
- *
- * (C) 1998 R.E.Wolff@BitWizard.nl
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#if defined(CONFIG_SERIAL_CONSOLE) || defined(CONFIG_SH_KGDB_CONSOLE)
-#include <linux/console.h>
-#endif
-#ifdef CONFIG_CPU_FREQ
-#include <linux/notifier.h>
-#include <linux/cpufreq.h>
-#endif
-
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
-
-#include <linux/generic_serial.h>
-
-#ifdef CONFIG_SH_STANDARD_BIOS
-#include <asm/sh_bios.h>
-#endif
-
-#include "sh-sci.h"
-
-#ifdef CONFIG_SH_KGDB
-#include <asm/kgdb.h>
-
-int kgdb_sci_setup(void);
-static int kgdb_get_char(struct sci_port *port);
-static void kgdb_put_char(struct sci_port *port, char c);
-static void kgdb_handle_error(struct sci_port *port);
-static struct sci_port *kgdb_sci_port;
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
-static struct console kgdbcons;
-void __init kgdb_console_init(void);
-#endif /* CONFIG_SH_KGDB_CONSOLE */
-
-#endif /* CONFIG_SH_KGDB */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static struct console sercons;
-static struct sci_port* sercons_port=0;
-static int sercons_baud;
-#ifdef CONFIG_MAGIC_SYSRQ
-#include <linux/sysrq.h>
-static int break_pressed;
-#endif /* CONFIG_MAGIC_SYSRQ */
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-/* Function prototypes */
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag);
-#ifndef SCI_ONLY
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag);
-#if defined(CONFIG_CPU_SH3)
-static void sci_init_pins_irda(struct sci_port* port, unsigned int cflag);
-#endif
-#endif
-static void sci_disable_tx_interrupts(void *ptr);
-static void sci_enable_tx_interrupts(void *ptr);
-static void sci_disable_rx_interrupts(void *ptr);
-static void sci_enable_rx_interrupts(void *ptr);
-static int sci_get_CD(void *ptr);
-static void sci_shutdown_port(void *ptr);
-static int sci_set_real_termios(void *ptr);
-static void sci_hungup(void *ptr);
-static void sci_close(void *ptr);
-static int sci_chars_in_buffer(void *ptr);
-static int sci_request_irq(struct sci_port *port);
-static void sci_free_irq(struct sci_port *port);
-static int sci_init_drivers(void);
-
-static struct tty_driver *sci_driver;
-
-static struct sci_port sci_ports[SCI_NPORTS] = SCI_INIT;
-
-static int sci_debug = 0;
-
-#ifdef MODULE
-MODULE_PARM(sci_debug, "i");
-#endif
-
-#define dprintk(x...) do { if (sci_debug) printk(x); } while(0)
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void put_char(struct sci_port *port, char c)
-{
- unsigned long flags;
- unsigned short status;
-
- local_irq_save(flags);
-
- do
- status = sci_in(port, SCxSR);
- while (!(status & SCxSR_TDxE(port)));
-
- sci_out(port, SCxTDR, c);
- sci_in(port, SCxSR); /* Dummy read */
- sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-
- local_irq_restore(flags);
-}
-#endif
-
-#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
-
-static void handle_error(struct sci_port *port)
-{ /* Clear error flags */
- sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
-}
-
-static int get_char(struct sci_port *port)
-{
- unsigned long flags;
- unsigned short status;
- int c;
-
- local_irq_save(flags);
- do {
- status = sci_in(port, SCxSR);
- if (status & SCxSR_ERRORS(port)) {
- handle_error(port);
- continue;
- }
- } while (!(status & SCxSR_RDxF(port)));
- c = sci_in(port, SCxRDR);
- sci_in(port, SCxSR); /* Dummy read */
- sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
- local_irq_restore(flags);
-
- return c;
-}
-
-/* Taken from sh-stub.c of GDB 4.18 */
-static const char hexchars[] = "0123456789abcdef";
-
-static __inline__ char highhex(int x)
-{
- return hexchars[(x >> 4) & 0xf];
-}
-
-static __inline__ char lowhex(int x)
-{
- return hexchars[x & 0xf];
-}
-
-#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
-
-/*
- * Send the packet in buffer. The host gets one chance to read it.
- * This routine does not wait for a positive acknowledge.
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-static void put_string(struct sci_port *port, const char *buffer, int count)
-{
- int i;
- const unsigned char *p = buffer;
-
-#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
- int checksum;
- int usegdb=0;
-
-#ifdef CONFIG_SH_STANDARD_BIOS
- /* This call only does a trap the first time it is
- * called, and so is safe to do here unconditionally
- */
- usegdb |= sh_bios_in_gdb_mode();
-#endif
-#ifdef CONFIG_SH_KGDB
- usegdb |= (kgdb_in_gdb_mode && (port == kgdb_sci_port));
-#endif
-
- if (usegdb) {
- /* $<packet info>#<checksum>. */
- do {
- unsigned char c;
- put_char(port, '$');
- put_char(port, 'O'); /* 'O'utput to console */
- checksum = 'O';
-
- for (i=0; i<count; i++) { /* Don't use run length encoding */
- int h, l;
-
- c = *p++;
- h = highhex(c);
- l = lowhex(c);
- put_char(port, h);
- put_char(port, l);
- checksum += h + l;
- }
- put_char(port, '#');
- put_char(port, highhex(checksum));
- put_char(port, lowhex(checksum));
- } while (get_char(port) != '+');
- } else
-#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
- for (i=0; i<count; i++) {
- if (*p == 10)
- put_char(port, '\r');
- put_char(port, *p++);
- }
-}
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-
-#ifdef CONFIG_SH_KGDB
-
-/* Is the SCI ready, ie is there a char waiting? */
-static int kgdb_is_char_ready(struct sci_port *port)
-{
- unsigned short status = sci_in(port, SCxSR);
-
- if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
- kgdb_handle_error(port);
-
- return (status & SCxSR_RDxF(port));
-}
-
-/* Write a char */
-static void kgdb_put_char(struct sci_port *port, char c)
-{
- unsigned short status;
-
- do
- status = sci_in(port, SCxSR);
- while (!(status & SCxSR_TDxE(port)));
-
- sci_out(port, SCxTDR, c);
- sci_in(port, SCxSR); /* Dummy read */
- sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-}
-
-/* Get a char if there is one, else ret -1 */
-static int kgdb_get_char(struct sci_port *port)
-{
- int c;
-
- if (kgdb_is_char_ready(port) == 0)
- c = -1;
- else {
- c = sci_in(port, SCxRDR);
- sci_in(port, SCxSR); /* Dummy read */
- sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
- }
-
- return c;
-}
-
-/* Called from kgdbstub.c to get a character, i.e. is blocking */
-static int kgdb_sci_getchar(void)
-{
- volatile int c;
-
- /* Keep trying to read a character, this could be neater */
- while ((c = kgdb_get_char(kgdb_sci_port)) < 0);
-
- return c;
-}
-
-/* Called from kgdbstub.c to put a character, just a wrapper */
-static void kgdb_sci_putchar(int c)
-{
-
- kgdb_put_char(kgdb_sci_port, c);
-}
-
-/* Clear any errors on the SCI */
-static void kgdb_handle_error(struct sci_port *port)
-{
- sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); /* Clear error flags */
-}
-
-/* Breakpoint if there's a break sent on the serial port */
-static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
- struct sci_port *port = ptr;
- unsigned short status = sci_in(port, SCxSR);
-
- if (status & SCxSR_BRK(port)) {
-
- /* Break into the debugger if a break is detected */
- BREAKPOINT();
-
- /* Clear */
- sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
- return;
- }
-}
-
-#endif /* CONFIG_SH_KGDB */
-
-static struct real_driver sci_real_driver = {
- sci_disable_tx_interrupts,
- sci_enable_tx_interrupts,
- sci_disable_rx_interrupts,
- sci_enable_rx_interrupts,
- sci_get_CD,
- sci_shutdown_port,
- sci_set_real_termios,
- sci_chars_in_buffer,
- sci_close,
- sci_hungup,
- NULL
-};
-
-#if !defined(__H8300H__) && !defined(__H8300S__)
-#if defined(SCI_ONLY) || defined(SCI_AND_SCIF)
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag)
-{
-}
-#endif
-
-#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
-#if defined(CONFIG_CPU_SH3)
-/* For SH7707, SH7709, SH7709A, SH7729 */
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag)
-{
- unsigned int fcr_val = 0;
-
- {
- unsigned short data;
-
- /* We need to set SCPCR to enable RTS/CTS */
- data = ctrl_inw(SCPCR);
- /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
- ctrl_outw(data&0x0cff, SCPCR);
- }
- if (cflag & CRTSCTS)
- fcr_val |= SCFCR_MCE;
- else {
- unsigned short data;
-
- /* We need to set SCPCR to enable RTS/CTS */
- data = ctrl_inw(SCPCR);
- /* Clear out SCP7MD1,0, SCP4MD1,0,
- Set SCP6MD1,0 = {01} (output) */
- ctrl_outw((data&0x0cff)|0x1000, SCPCR);
-
- data = ctrl_inb(SCPDR);
- /* Set /RTS2 (bit6) = 0 */
- ctrl_outb(data&0xbf, SCPDR);
- }
- sci_out(port, SCFCR, fcr_val);
-}
-
-static void sci_init_pins_irda(struct sci_port* port, unsigned int cflag)
-{
- unsigned int fcr_val = 0;
-
- if (cflag & CRTSCTS)
- fcr_val |= SCFCR_MCE;
-
- sci_out(port, SCFCR, fcr_val);
-}
-
-#else
-
-/* For SH7750 */
-static void sci_init_pins_scif(struct sci_port* port, unsigned int cflag)
-{
- unsigned int fcr_val = 0;
-
- if (cflag & CRTSCTS) {
- fcr_val |= SCFCR_MCE;
- } else {
- ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */
- }
- sci_out(port, SCFCR, fcr_val);
-}
-
-#endif
-#endif /* SCIF_ONLY || SCI_AND_SCIF */
-#else /* !defined(__H8300H__) && !defined(__H8300S__) */
-static void sci_init_pins_sci(struct sci_port* port, unsigned int cflag)
-{
- int ch = (port->base - SMR0) >> 3;
- /* set DDR regs */
- H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].rx,H8300_GPIO_INPUT);
- H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].tx,H8300_GPIO_OUTPUT);
- /* tx mark output*/
- H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
-}
-
-#if defined(__H8300S__)
-enum {sci_disable,sci_enable};
-
-static void h8300_sci_enable(struct sci_port* port, unsigned int ctrl)
-{
- volatile unsigned char *mstpcrl=(volatile unsigned char *)MSTPCRL;
- int ch = (port->base - SMR0) >> 3;
- unsigned char mask = 1 << (ch+1);
- if (ctrl == sci_disable)
- *mstpcrl |= mask;
- else
- *mstpcrl &= ~mask;
-}
-#endif
-#endif
-
-static void sci_setsignals(struct sci_port *port, int dtr, int rts)
-{
- /* This routine is used for seting signals of: DTR, DCD, CTS/RTS */
- /* We use SCIF's hardware for CTS/RTS, so don't need any for that. */
- /* If you have signals for DTR and DCD, please implement here. */
- ;
-}
-
-static int sci_getsignals(struct sci_port *port)
-{
- /* This routine is used for geting signals of: DTR, DCD, DSR, RI,
- and CTS/RTS */
-
- return TIOCM_DTR|TIOCM_RTS|TIOCM_DSR;
-/*
- (((o_stat & OP_DTR)?TIOCM_DTR:0) |
- ((o_stat & OP_RTS)?TIOCM_RTS:0) |
- ((i_stat & IP_CTS)?TIOCM_CTS:0) |
- ((i_stat & IP_DCD)?TIOCM_CAR:0) |
- ((i_stat & IP_DSR)?TIOCM_DSR:0) |
- ((i_stat & IP_RI) ?TIOCM_RNG:0)
-*/
-}
-
-static void sci_set_baud(struct sci_port *port, int baud)
-{
- int t;
-
- switch (baud) {
- case 0:
- t = -1;
- break;
- case 2400:
- t = BPS_2400;
- break;
- case 4800:
- t = BPS_4800;
- break;
- case 9600:
- t = BPS_9600;
- break;
- case 19200:
- t = BPS_19200;
- break;
- case 38400:
- t = BPS_38400;
- break;
- case 57600:
- t = BPS_57600;
- break;
- default:
- printk(KERN_INFO "sci: unsupported baud rate: %d, using 115200 instead.\n", baud);
- case 115200:
- t = BPS_115200;
- break;
- }
-
- if (t > 0) {
- sci_setsignals (port, 1, -1);
- if(t >= 256) {
- sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1);
- t >>= 2;
- } else {
- sci_out(port, SCSMR, sci_in(port, SCSMR) & ~3);
- }
- sci_out(port, SCBRR, t);
- udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
- } else {
- sci_setsignals (port, 0, -1);
- }
-}
-
-static void sci_set_termios_cflag(struct sci_port *port, int cflag, int baud)
-{
- unsigned int status;
- unsigned int smr_val;
-
- do
- status = sci_in(port, SCxSR);
- while (!(status & SCxSR_TEND(port)));
-
- sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
-
-#if !defined(SCI_ONLY)
- if (port->type == PORT_SCIF) {
- sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
- }
-#endif
-
- smr_val = sci_in(port, SCSMR) & 3;
- if ((cflag & CSIZE) == CS7)
- smr_val |= 0x40;
- if (cflag & PARENB)
- smr_val |= 0x20;
- if (cflag & PARODD)
- smr_val |= 0x30;
- if (cflag & CSTOPB)
- smr_val |= 0x08;
- sci_out(port, SCSMR, smr_val);
- sci_set_baud(port, baud);
-
- port->init_pins(port, cflag);
- sci_out(port, SCSCR, SCSCR_INIT(port));
-}
-
-static int sci_set_real_termios(void *ptr)
-{
- struct sci_port *port = ptr;
-
- if (port->old_cflag != port->gs.tty->termios->c_cflag) {
- port->old_cflag = port->gs.tty->termios->c_cflag;
- sci_set_termios_cflag(port, port->old_cflag, port->gs.baud);
- sci_enable_rx_interrupts(port);
- }
-
- return 0;
-}
-
-/* ********************************************************************** *
- * the interrupt related routines *
- * ********************************************************************** */
-
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static inline void sci_sched_event(struct sci_port *port, int event)
-{
- port->event |= 1 << event;
- schedule_work(&port->tqueue);
-}
-
-static void sci_transmit_chars(struct sci_port *port)
-{
- int count, i;
- int txroom;
- unsigned long flags;
- unsigned short status;
- unsigned short ctrl;
- unsigned char c;
-
- status = sci_in(port, SCxSR);
- if (!(status & SCxSR_TDxE(port))) {
- local_irq_save(flags);
- ctrl = sci_in(port, SCSCR);
- if (port->gs.xmit_cnt == 0) {
- ctrl &= ~SCI_CTRL_FLAGS_TIE;
- port->gs.flags &= ~GS_TX_INTEN;
- } else
- ctrl |= SCI_CTRL_FLAGS_TIE;
- sci_out(port, SCSCR, ctrl);
- local_irq_restore(flags);
- return;
- }
-
- while (1) {
- count = port->gs.xmit_cnt;
-#if !defined(SCI_ONLY)
- if (port->type == PORT_SCIF) {
- txroom = 16 - (sci_in(port, SCFDR)>>8);
- } else {
- txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
- }
-#else
- txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
-#endif
- if (count > txroom)
- count = txroom;
-
- /* Don't copy past the end of the source buffer */
- if (count > SERIAL_XMIT_SIZE - port->gs.xmit_tail)
- count = SERIAL_XMIT_SIZE - port->gs.xmit_tail;
-
- /* If for one reason or another, we can't copy more data, we're done! */
- if (count == 0)
- break;
-
- for (i=0; i<count; i++) {
- c = port->gs.xmit_buf[port->gs.xmit_tail + i];
- sci_out(port, SCxTDR, c);
- }
- sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
-
- port->icount.tx += count;
-
- /* Update the kernel buffer end */
- port->gs.xmit_tail = (port->gs.xmit_tail + count) & (SERIAL_XMIT_SIZE-1);
-
- /* This one last. (this is essential)
- It would allow others to start putting more data into the buffer! */
- port->gs.xmit_cnt -= count;
- }
-
- if (port->gs.xmit_cnt <= port->gs.wakeup_chars)
- sci_sched_event(port, SCI_EVENT_WRITE_WAKEUP);
-
- local_irq_save(flags);
- ctrl = sci_in(port, SCSCR);
- if (port->gs.xmit_cnt == 0) {
- ctrl &= ~SCI_CTRL_FLAGS_TIE;
- port->gs.flags &= ~GS_TX_INTEN;
- } else {
-#if !defined(SCI_ONLY)
- if (port->type == PORT_SCIF) {
- sci_in(port, SCxSR); /* Dummy read */
- sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
- }
-#endif
- ctrl |= SCI_CTRL_FLAGS_TIE;
- }
- sci_out(port, SCSCR, ctrl);
- local_irq_restore(flags);
-}
-
-/* On SH3, SCIF may read end-of-break as a space->mark char */
-#define STEPFN(c) ({int __c=(c); (((__c-1)|(__c)) == -1); })
-
-static inline void sci_receive_chars(struct sci_port *port,
- struct pt_regs *regs)
-{
- int i, count;
- struct tty_struct *tty;
- int copied=0;
- unsigned short status;
-
- status = sci_in(port, SCxSR);
- if (!(status & SCxSR_RDxF(port)))
- return;
-
- tty = port->gs.tty;
- while (1) {
-#if !defined(SCI_ONLY)
- if (port->type == PORT_SCIF) {
- count = sci_in(port, SCFDR)&0x001f;
- } else {
- count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
- }
-#else
- count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
-#endif
-
- /* Don't copy more bytes than there is room for in the buffer */
- if (tty->flip.count + count > TTY_FLIPBUF_SIZE)
- count = TTY_FLIPBUF_SIZE - tty->flip.count;
-
- /* If for any reason we can't copy more data, we're done! */
- if (count == 0)
- break;
-
- if (port->type == PORT_SCI) {
- tty->flip.char_buf_ptr[0] = sci_in(port, SCxRDR);
- tty->flip.flag_buf_ptr[0] = TTY_NORMAL;
- } else {
- for (i=0; i<count; i++) {
- char c = sci_in(port, SCxRDR);
- status = sci_in(port, SCxSR);
-#if defined(__SH3__)
- /* Skip "chars" during break */
- if (port->break_flag) {
- if ((c == 0) &&
- (status & SCxSR_FER(port))) {
- count--; i--;
- continue;
- }
- /* Nonzero => end-of-break */
- dprintk("scif: debounce<%02x>\n", c);
- port->break_flag = 0;
- if (STEPFN(c)) {
- count--; i--;
- continue;
- }
- }
-#endif /* __SH3__ */
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- if (break_pressed && (port == sercons_port)) {
- if (c != 0 &&
- time_before(jiffies,
- break_pressed + HZ*5)) {
- handle_sysrq(c, regs, NULL);
- break_pressed = 0;
- count--; i--;
- continue;
- } else if (c != 0) {
- break_pressed = 0;
- }
- }
-#endif /* CONFIG_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
- /* Store data and status */
- tty->flip.char_buf_ptr[i] = c;
- if (status&SCxSR_FER(port)) {
- tty->flip.flag_buf_ptr[i] = TTY_FRAME;
- dprintk("sci: frame error\n");
- } else if (status&SCxSR_PER(port)) {
- tty->flip.flag_buf_ptr[i] = TTY_PARITY;
- dprintk("sci: parity error\n");
- } else {
- tty->flip.flag_buf_ptr[i] = TTY_NORMAL;
- }
- }
- }
-
- sci_in(port, SCxSR); /* dummy read */
- sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
-
- /* Update the kernel buffer end */
- tty->flip.count += count;
- tty->flip.char_buf_ptr += count;
- tty->flip.flag_buf_ptr += count;
-
- copied += count;
- port->icount.rx += count;
- }
-
- if (copied)
- /* Tell the rest of the system the news. New characters! */
- tty_flip_buffer_push(tty);
- else {
- sci_in(port, SCxSR); /* dummy read */
- sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
- }
-}
-
-static inline int sci_handle_errors(struct sci_port *port)
-{
- int copied = 0;
- unsigned short status = sci_in(port, SCxSR);
- struct tty_struct *tty = port->gs.tty;
-
- if (status&SCxSR_ORER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
- /* overrun error */
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
- dprintk("sci: overrun error\n");
- }
-
- if (status&SCxSR_FER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
- if (sci_rxd_in(port) == 0) {
- /* Notify of BREAK */
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_BREAK;
- dprintk("sci: BREAK detected\n");
- }
- else {
- /* frame error */
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_FRAME;
- dprintk("sci: frame error\n");
- }
- }
-
- if (status&SCxSR_PER(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
- /* parity error */
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_PARITY;
- dprintk("sci: parity error\n");
- }
-
- if (copied) {
- tty->flip.count += copied;
- tty_flip_buffer_push(tty);
- }
-
- return copied;
-}
-
-static inline int sci_handle_breaks(struct sci_port *port)
-{
- int copied = 0;
- unsigned short status = sci_in(port, SCxSR);
- struct tty_struct *tty = port->gs.tty;
-
- if (status&SCxSR_BRK(port) && tty->flip.count<TTY_FLIPBUF_SIZE) {
-#if defined(__SH3__)
- /* Debounce break */
- if (port->break_flag)
- goto break_continue;
- port->break_flag = 1;
-#endif
-#if defined(CONFIG_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- if (port == sercons_port) {
- if (break_pressed == 0) {
- break_pressed = jiffies;
- dprintk("sci: implied sysrq\n");
- goto break_continue;
- }
- /* Double break implies a real break */
- break_pressed = 0;
- }
-#endif
- /* Notify of BREAK */
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_BREAK;
- dprintk("sci: BREAK detected\n");
- }
- break_continue:
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_ST40STB1) || \
- defined(CONFIG_CPU_SUBTYPE_SH7760)
- /* XXX: Handle SCIF overrun error */
- if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
- sci_out(port, SCLSR, 0);
- if(tty->flip.count<TTY_FLIPBUF_SIZE) {
- copied++;
- *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
- dprintk("sci: overrun error\n");
- }
- }
-#endif
-
- if (copied) {
- tty->flip.count += copied;
- tty_flip_buffer_push(tty);
- }
-
- return copied;
-}
-
-static irqreturn_t sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
- struct sci_port *port = ptr;
-
- if (port->gs.flags & GS_ACTIVE)
- if (!(port->gs.flags & SCI_RX_THROTTLE)) {
- sci_receive_chars(port, regs);
- return IRQ_HANDLED;
-
- }
- sci_disable_rx_interrupts(port);
-
- return IRQ_HANDLED;
-}
-
-static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
- struct sci_port *port = ptr;
-
- if (port->gs.flags & GS_ACTIVE)
- sci_transmit_chars(port);
- else {
- sci_disable_tx_interrupts(port);
- }
-
- return IRQ_HANDLED;
-}
-
-static irqreturn_t sci_er_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
- struct sci_port *port = ptr;
-
- /* Handle errors */
- if (port->type == PORT_SCI) {
- if(sci_handle_errors(port)) {
- /* discard character in rx buffer */
- sci_in(port, SCxSR);
- sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
- }
- }
- else
- sci_rx_interrupt(irq, ptr, regs);
-
- sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
-
- /* Kick the transmission */
- sci_tx_interrupt(irq, ptr, regs);
-
- return IRQ_HANDLED;
-}
-
-#if !defined(SCI_ONLY)
-static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs)
-{
- struct sci_port *port = ptr;
-
- /* Handle BREAKs */
- sci_handle_breaks(port);
- sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
-
- return IRQ_HANDLED;
-}
-#endif
-
-static void do_softint(void *private_)
-{
- struct sci_port *port = (struct sci_port *) private_;
- struct tty_struct *tty;
-
- tty = port->gs.tty;
- if (!tty)
- return;
-
- if (test_and_clear_bit(SCI_EVENT_WRITE_WAKEUP, &port->event)) {
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
- wake_up_interruptible(&tty->write_wait);
- }
-}
-
-/* ********************************************************************** *
- * Here are the routines that actually *
- * interface with the generic_serial driver *
- * ********************************************************************** */
-
-static void sci_disable_tx_interrupts(void *ptr)
-{
- struct sci_port *port = ptr;
- unsigned long flags;
- unsigned short ctrl;
-
- /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
- local_irq_save(flags);
- ctrl = sci_in(port, SCSCR);
- ctrl &= ~SCI_CTRL_FLAGS_TIE;
- sci_out(port, SCSCR, ctrl);
- local_irq_restore(flags);
-}
-
-static void sci_enable_tx_interrupts(void *ptr)
-{
- struct sci_port *port = ptr;
-
- disable_irq(port->irqs[SCIx_TXI_IRQ]);
- sci_transmit_chars(port);
- enable_irq(port->irqs[SCIx_TXI_IRQ]);
-}
-
-static void sci_disable_rx_interrupts(void * ptr)
-{
- struct sci_port *port = ptr;
- unsigned long flags;
- unsigned short ctrl;
-
- /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */
- local_irq_save(flags);
- ctrl = sci_in(port, SCSCR);
- ctrl &= ~SCI_CTRL_FLAGS_RIE;
- sci_out(port, SCSCR, ctrl);
- local_irq_restore(flags);
-}
-
-static void sci_enable_rx_interrupts(void * ptr)
-{
- struct sci_port *port = ptr;
- unsigned long flags;
- unsigned short ctrl;
-
- /* Set RIE (Receive Interrupt Enable) bit in SCSCR */
- local_irq_save(flags);
- ctrl = sci_in(port, SCSCR);
- ctrl |= SCI_CTRL_FLAGS_RIE;
- sci_out(port, SCSCR, ctrl);
- local_irq_restore(flags);
-}
-
-static int sci_get_CD(void * ptr)
-{
- /* If you have signal for CD (Carrier Detect), please change here. */
- return 1;
-}
-
-static int sci_chars_in_buffer(void * ptr)
-{
- struct sci_port *port = ptr;
-
-#if !defined(SCI_ONLY)
- if (port->type == PORT_SCIF) {
- return (sci_in(port, SCFDR) >> 8) + ((sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1);
- } else {
- return (sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1;
- }
-#else
- return (sci_in(port, SCxSR) & SCxSR_TEND(port))? 0: 1;
-#endif
-}
-
-static void sci_shutdown_port(void * ptr)
-{
- struct sci_port *port = ptr;
-
- port->gs.flags &= ~ GS_ACTIVE;
- if (port->gs.tty && port->gs.tty->termios->c_cflag & HUPCL)
- sci_setsignals(port, 0, 0);
- sci_free_irq(port);
-#if defined(__H8300S__)
- h8300_sci_enable(port,sci_disable);
-#endif
-}
-
-/* ********************************************************************** *
- * Here are the routines that actually *
- * interface with the rest of the system *
- * ********************************************************************** */
-
-static int sci_open(struct tty_struct * tty, struct file * filp)
-{
- struct sci_port *port;
- int retval, line;
-
- line = tty->index;
-
- if ((line < 0) || (line >= SCI_NPORTS))
- return -ENODEV;
-
- port = &sci_ports[line];
-
- tty->driver_data = port;
- port->gs.tty = tty;
- port->gs.count++;
-
- port->event = 0;
- INIT_WORK(&port->tqueue, do_softint, port);
-
-#if defined(__H8300S__)
- h8300_sci_enable(port,sci_enable);
-#endif
-
- /*
- * Start up serial port
- */
- retval = gs_init_port(&port->gs);
- if (retval) {
- goto failed_1;
- }
-
- port->gs.flags |= GS_ACTIVE;
- sci_setsignals(port, 1,1);
-
- if (port->gs.count == 1) {
- retval = sci_request_irq(port);
- }
-
- retval = gs_block_til_ready(port, filp);
-
- if (retval) {
- goto failed_3;
- }
-
-#ifdef CONFIG_SERIAL_CONSOLE
- if (sercons.cflag && sercons.index == line) {
- tty->termios->c_cflag = sercons.cflag;
- port->gs.baud = sercons_baud;
- sercons.cflag = 0;
- sci_set_real_termios(port);
- }
-#endif
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
- if (kgdbcons.cflag && kgdbcons.index == line) {
- tty->termios->c_cflag = kgdbcons.cflag;
- port->gs.baud = kgdb_baud;
- sercons.cflag = 0;
- sci_set_real_termios(port);
- }
-#endif
-
- sci_enable_rx_interrupts(port);
-
- return 0;
-
-failed_3:
- sci_free_irq(port);
-failed_1:
- port->gs.count--;
- return retval;
-}
-
-static void sci_hungup(void *ptr)
-{
- return;
-}
-
-static void sci_close(void *ptr)
-{
- return;
-}
-
-static int sci_tiocmget(struct tty_struct *tty, struct file *file)
-{
- struct sci_port *port = tty->driver_data;
- return sci_getsignals(port);
-}
-
-static int sci_tiocmset(struct tty_struct *tty, struct file *file,
- unsigned int set, unsigned int clear)
-{
- struct sci_port *port = tty->driver_data;
- int rts = -1, dtr = -1;
-
- if (set & TIOCM_RTS)
- rts = 1;
- if (set & TIOCM_DTR)
- dtr = 1;
- if (clear & TIOCM_RTS)
- rts = 0;
- if (clear & TIOCM_DTR)
- dtr = 0;
-
- sci_setsignals(port, dtr, rts);
- return 0;
-}
-
-static int sci_ioctl(struct tty_struct * tty, struct file * filp,
- unsigned int cmd, unsigned long arg)
-{
- int rc;
- struct sci_port *port = tty->driver_data;
- int ival;
-
- rc = 0;
- switch (cmd) {
- case TIOCGSOFTCAR:
- rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
- (unsigned int __user *) arg);
- break;
- case TIOCSSOFTCAR:
- if ((rc = get_user(ival, (unsigned int __user *) arg)) == 0)
- tty->termios->c_cflag =
- (tty->termios->c_cflag & ~CLOCAL) |
- (ival ? CLOCAL : 0);
- break;
- case TIOCGSERIAL:
- if ((rc = verify_area(VERIFY_WRITE, (void __user *) arg,
- sizeof(struct serial_struct))) == 0)
- rc = gs_getserial(&port->gs, (struct serial_struct *) arg);
- break;
- case TIOCSSERIAL:
- if ((rc = verify_area(VERIFY_READ, (void __user *) arg,
- sizeof(struct serial_struct))) == 0)
- rc = gs_setserial(&port->gs,
- (struct serial_struct *) arg);
- break;
- default:
- rc = -ENOIOCTLCMD;
- break;
- }
-
- return rc;
-}
-
-static void sci_throttle(struct tty_struct * tty)
-{
- struct sci_port *port = (struct sci_port *)tty->driver_data;
-
- /* If the port is using any type of input flow
- * control then throttle the port.
- */
- if ((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) )
- port->gs.flags |= SCI_RX_THROTTLE;
-}
-
-static void sci_unthrottle(struct tty_struct * tty)
-{
- struct sci_port *port = (struct sci_port *)tty->driver_data;
-
- /* Always unthrottle even if flow control is not enabled on
- * this port in case we disabled flow control while the port
- * was throttled
- */
- port->gs.flags &= ~SCI_RX_THROTTLE;
- sci_enable_rx_interrupts(port);
- return;
-}
-
-#ifdef CONFIG_PROC_FS
-static int sci_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- int i;
- struct sci_port *port;
- int len = 0;
-
- len += sprintf(page, "sciinfo:0.1\n");
- for (i = 0; i < SCI_NPORTS && len < 4000; i++) {
- port = &sci_ports[i];
- len += sprintf(page+len, "%d: uart:%s address: %08x", i,
- (port->type == PORT_SCI) ? "SCI" : "SCIF",
- port->base);
- len += sprintf(page+len, " baud:%d", port->gs.baud);
- len += sprintf(page+len, " tx:%d rx:%d",
- port->icount.tx, port->icount.rx);
-
- if (port->icount.frame)
- len += sprintf(page+len, " fe:%d", port->icount.frame);
- if (port->icount.parity)
- len += sprintf(page+len, " pe:%d", port->icount.parity);
- if (port->icount.brk)
- len += sprintf(page+len, " brk:%d", port->icount.brk);
- if (port->icount.overrun)
- len += sprintf(page+len, " oe:%d", port->icount.overrun);
- len += sprintf(page+len, "\n");
- }
- return len;
-}
-#endif
-
-#ifdef CONFIG_CPU_FREQ
-/*
- * Here we define a transistion notifier so that we can update all of our
- * ports' baud rate when the peripheral clock changes.
- */
-
-static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p)
-{
- struct cpufreq_freqs *freqs = p;
- int i;
-
- if (phase == CPUFREQ_POSTCHANGE) {
- for (i = 0; i < SCI_NPORTS; i++) {
- /*
- * This will force a baud rate change in hardware.
- */
- if (sci_ports[i].gs.tty != NULL) {
- sci_set_baud(&sci_ports[i], sci_ports[i].gs.baud);
- }
- }
- printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n",
- __FUNCTION__, freqs->cpu, freqs->old, freqs->new);
- }
-
- return NOTIFY_OK;
-}
-
-static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
-#endif /* CONFIG_CPU_FREQ */
-
-static struct tty_operations sci_ops = {
- .open = sci_open,
- .close = gs_close,
- .write = gs_write,
- .put_char = gs_put_char,
- .flush_chars = gs_flush_chars,
- .write_room = gs_write_room,
- .chars_in_buffer = gs_chars_in_buffer,
- .flush_buffer = gs_flush_buffer,
- .ioctl = sci_ioctl,
- .throttle = sci_throttle,
- .unthrottle = sci_unthrottle,
- .set_termios = gs_set_termios,
- .stop = gs_stop,
- .start = gs_start,
- .hangup = gs_hangup,
-#ifdef CONFIG_PROC_FS
- .read_proc = sci_read_proc,
-#endif
- .tiocmget = sci_tiocmget,
- .tiocmset = sci_tiocmset,
-};
-
-/* ********************************************************************** *
- * Here are the initialization routines. *
- * ********************************************************************** */
-
-static int sci_init_drivers(void)
-{
- int error;
- struct sci_port *port;
- sci_driver = alloc_tty_driver(SCI_NPORTS);
- if (!sci_driver)
- return -ENOMEM;
-
- sci_driver->owner = THIS_MODULE;
- sci_driver->driver_name = "sci";
- sci_driver->name = "ttySC";
- sci_driver->devfs_name = "ttsc/";
- sci_driver->major = SCI_MAJOR;
- sci_driver->minor_start = SCI_MINOR_START;
- sci_driver->type = TTY_DRIVER_TYPE_SERIAL;
- sci_driver->subtype = SERIAL_TYPE_NORMAL;
- sci_driver->init_termios = tty_std_termios;
- sci_driver->init_termios.c_cflag =
- B9600 | CS8 | CREAD | HUPCL | CLOCAL | CRTSCTS;
- sci_driver->flags = TTY_DRIVER_REAL_RAW;
- tty_set_operations(sci_driver, &sci_ops);
- if ((error = tty_register_driver(sci_driver))) {
- printk(KERN_ERR "sci: Couldn't register SCI driver, error = %d\n",
- error);
- put_tty_driver(sci_driver);
- return 1;
- }
-
- for (port = &sci_ports[0]; port < &sci_ports[SCI_NPORTS]; port++) {
- port->gs.magic = SCI_MAGIC;
- port->gs.close_delay = HZ/2;
- port->gs.closing_wait = 30 * HZ;
- port->gs.rd = &sci_real_driver;
- init_waitqueue_head(&port->gs.open_wait);
- init_waitqueue_head(&port->gs.close_wait);
- port->old_cflag = 0;
- port->icount.cts = port->icount.dsr =
- port->icount.rng = port->icount.dcd = 0;
- port->icount.rx = port->icount.tx = 0;
- port->icount.frame = port->icount.parity = 0;
- port->icount.overrun = port->icount.brk = 0;
- }
-
-#ifdef CONFIG_CPU_FREQ
- /* Setup transition notifier */
- if (cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER) < 0) {
- printk(KERN_ERR "sci: Unable to register CPU frequency notifier\n");
- return 1;
- }
- printk("sci: CPU frequency notifier registered\n");
-#endif
- return 0;
-}
-
-static int sci_request_irq(struct sci_port *port)
-{
- int i;
-#if !defined(SCI_ONLY)
- irqreturn_t (*handlers[4])(int irq, void *p, struct pt_regs *regs) = {
- sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt,
- sci_br_interrupt,
- };
-#else
- void (*handlers[3])(int irq, void *ptr, struct pt_regs *regs) = {
- sci_er_interrupt, sci_rx_interrupt, sci_tx_interrupt,
- };
-#endif
- for (i=0; i<(sizeof(handlers)/sizeof(handlers[0])); i++) {
- if (!port->irqs[i]) continue;
- if (request_irq(port->irqs[i], handlers[i], SA_INTERRUPT,
- "sci", port)) {
- printk(KERN_ERR "sci: Cannot allocate irq.\n");
- return -ENODEV;
- }
- }
- return 0;
-}
-
-static void sci_free_irq(struct sci_port *port)
-{
- int i;
-
- for (i=0; i<4; i++) {
- if (!port->irqs[i]) continue;
- free_irq(port->irqs[i], port);
- }
-}
-
-static char banner[] __initdata =
- KERN_INFO "SuperH SCI(F) driver initialized\n";
-
-int __init sci_init(void)
-{
- struct sci_port *port;
- int j;
-
- printk("%s", banner);
-
- for (j=0; j<SCI_NPORTS; j++) {
- port = &sci_ports[j];
- printk(KERN_INFO "ttySC%d at 0x%08x is a %s\n", j, port->base,
- (port->type == PORT_SCI) ? "SCI" : "SCIF");
- }
-
- sci_init_drivers();
-
-#ifdef CONFIG_SH_STANDARD_BIOS
- sh_bios_gdb_detach();
-#endif
- return 0; /* Return -EIO when not detected */
-}
-
-module_init(sci_init);
-
-#ifdef MODULE
-#undef func_enter
-#undef func_exit
-
-void cleanup_module(void)
-{
- tty_unregister_driver(sci_driver);
- put_tty_driver(sci_driver);
-}
-
-#include "generic_serial.c"
-#endif
-
-#ifdef CONFIG_SERIAL_CONSOLE
-/*
- * Print a string to the serial port trying not to disturb
- * any possible real use of the port...
- */
-static void serial_console_write(struct console *co, const char *s,
- unsigned count)
-{
- put_string(sercons_port, s, count);
-}
-
-static struct tty_driver *serial_console_device(struct console *c, int *index)
-{
- *index = c->index;
- return sci_driver;
-}
-
-/*
- * Setup initial baud/bits/parity. We do two things here:
- * - construct a cflag setting for the first rs_open()
- * - initialize the serial port
- * Return non-zero if we didn't find a serial port.
- */
-static int __init serial_console_setup(struct console *co, char *options)
-{
- int baud = 9600;
- int bits = 8;
- int parity = 'n';
- int cflag = CREAD | HUPCL | CLOCAL;
- char *s;
-
- sercons_port = &sci_ports[co->index];
-
- if (options) {
- baud = simple_strtoul(options, NULL, 10);
- s = options;
- while(*s >= '0' && *s <= '9')
- s++;
- if (*s) parity = *s++;
- if (*s) bits = *s - '0';
- }
-
- /*
- * Now construct a cflag setting.
- */
- switch (baud) {
- case 19200:
- cflag |= B19200;
- break;
- case 38400:
- cflag |= B38400;
- break;
- case 57600:
- cflag |= B57600;
- break;
- case 115200:
- cflag |= B115200;
- break;
- case 9600:
- default:
- cflag |= B9600;
- baud = 9600;
- break;
- }
- switch (bits) {
- case 7:
- cflag |= CS7;
- break;
- default:
- case 8:
- cflag |= CS8;
- break;
- }
- switch (parity) {
- case 'o': case 'O':
- cflag |= PARODD;
- break;
- case 'e': case 'E':
- cflag |= PARENB;
- break;
- }
-
- co->cflag = cflag;
- sercons_baud = baud;
-
-#if defined(__H8300S__)
- h8300_sci_enable(sercons_port,sci_enable);
-#endif
- sci_set_termios_cflag(sercons_port, cflag, baud);
- sercons_port->old_cflag = cflag;
-
- return 0;
-}
-
-static struct console sercons = {
- .name = "ttySC",
- .write = serial_console_write,
- .device = serial_console_device,
- .setup = serial_console_setup,
- .flags = CON_PRINTBUFFER,
- .index = -1,
-};
-
-/*
- * Register console.
- */
-
-#ifdef CONFIG_SH_EARLY_PRINTK
-extern void sh_console_unregister (void);
-#endif
-
-static int __init sci_console_init(void)
-{
- register_console(&sercons);
-#ifdef CONFIG_SH_EARLY_PRINTK
- /* Now that the real console is available, unregister the one we
- * used while first booting.
- */
- sh_console_unregister();
-#endif
- return 0;
-}
-console_initcall(sci_console_init);
-
-#endif /* CONFIG_SERIAL_CONSOLE */
-
-
-#ifdef CONFIG_SH_KGDB
-
-/* Initialise the KGDB serial port */
-int kgdb_sci_setup(void)
-{
- int cflag = CREAD | HUPCL | CLOCAL;
-
- if ((kgdb_portnum < 0) || (kgdb_portnum >= SCI_NPORTS))
- return -1;
-
- kgdb_sci_port = &sci_ports[kgdb_portnum];
-
- switch (kgdb_baud) {
- case 115200:
- cflag |= B115200;
- break;
- case 57600:
- cflag |= B57600;
- break;
- case 38400:
- cflag |= B38400;
- break;
- case 19200:
- cflag |= B19200;
- break;
- case 9600:
- default:
- cflag |= B9600;
- kgdb_baud = 9600;
- break;
- }
-
- switch (kgdb_bits) {
- case '7':
- cflag |= CS7;
- break;
- default:
- case '8':
- cflag |= CS8;
- break;
- }
-
- switch (kgdb_parity) {
- case 'O':
- cflag |= PARODD;
- break;
- case 'E':
- cflag |= PARENB;
- break;
- }
-
- kgdb_cflag = cflag;
- sci_set_termios_cflag(kgdb_sci_port, kgdb_cflag, kgdb_baud);
-
- /* Set up the interrupt for BREAK from GDB */
- /* Commented out for now since it may not be possible yet...
- request_irq(kgdb_sci_port->irqs[0], kgdb_break_interrupt,
- SA_INTERRUPT, "sci", kgdb_sci_port);
- sci_enable_rx_interrupts(kgdb_sci_port);
- */
-
- /* Setup complete: initialize function pointers */
- kgdb_getchar = kgdb_sci_getchar;
- kgdb_putchar = kgdb_sci_putchar;
-
- return 0;
-}
-
-#ifdef CONFIG_SH_KGDB_CONSOLE
-
-/* Create a console device */
-static kdev_t kgdb_console_device(struct console *c)
-{
- return MKDEV(SCI_MAJOR, SCI_MINOR_START + c->index);
-}
-
-/* Set up the KGDB console */
-static int __init kgdb_console_setup(struct console *co, char *options)
-{
- /* NB we ignore 'options' because we've already done the setup */
- co->cflag = kgdb_cflag;
-
- return 0;
-}
-
-/* Register the KGDB console so we get messages (d'oh!) */
-void __init kgdb_console_init(void)
-{
- register_console(&kgdbcons);
-}
-
-/* The console structure for KGDB */
-static struct console kgdbcons = {
- name:"ttySC",
- write:kgdb_console_write,
- device:kgdb_console_device,
- wait_key:serial_console_wait_key,
- setup:kgdb_console_setup,
- flags:CON_PRINTBUFFER | CON_ENABLED,
- index:-1,
-};
-
-#endif /* CONFIG_SH_KGDB_CONSOLE */
-
-#endif /* CONFIG_SH_KGDB */
+++ /dev/null
-/* $Id: sh-sci.h,v 1.7 2004/02/10 17:04:17 lethal Exp $
- *
- * linux/drivers/char/sh-sci.h
- *
- * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
- * Copyright (C) 1999, 2000 Niibe Yutaka
- * Copyright (C) 2000 Greg Banks
- * Modified to support multiple serial ports. Stuart Menefy (May 2000).
- * Modified to support SH7760 SCIF. Paul Mundt (Oct 2003).
- * Modified to support H8/300 Serise Yoshinori Sato (Feb 2004).
- *
- */
-#include <linux/config.h>
-
-#if defined(__H8300H__) || defined(__H8300S__)
-#include <asm/gpio.h>
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
-#include <asm/regs306x.h>
-#endif
-#if defined(CONFIG_H8S2678)
-#include <asm/regs267x.h>
-#endif
-#endif
-
-/* Values for sci_port->type */
-#define PORT_SCI 0
-#define PORT_SCIF 1
-#define PORT_IRDA 1 /* XXX: temporary assignment */
-
-/* Offsets into the sci_port->irqs array */
-#define SCIx_ERI_IRQ 0
-#define SCIx_RXI_IRQ 1
-#define SCIx_TXI_IRQ 2
-
-/* ERI, RXI, TXI, BRI */
-#define SCI_IRQS { 23, 24, 25, 0 }
-#define SH3_SCIF_IRQS { 56, 57, 59, 58 }
-#define SH3_IRDA_IRQS { 52, 53, 55, 54 }
-#define SH4_SCIF_IRQS { 40, 41, 43, 42 }
-#define STB1_SCIF1_IRQS {23, 24, 26, 25 }
-#define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }
-#define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
-#define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
-#define H8300H_SCI_IRQS0 {52, 53, 54, 0 }
-#define H8300H_SCI_IRQS1 {56, 57, 58, 0 }
-#define H8300H_SCI_IRQS2 {60, 61, 62, 0 }
-#define H8S_SCI_IRQS0 {88, 89, 90, 0 }
-#define H8S_SCI_IRQS1 {92, 93, 94, 0 }
-#define H8S_SCI_IRQS2 {96, 97, 98, 0 }
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7708)
-# define SCI_NPORTS 1
-# define SCI_INIT { \
- { {}, PORT_SCI, 0xfffffe80, SCI_IRQS, sci_init_pins_sci } \
-}
-# define SCSPTR 0xffffff7c /* 8 bit */
-# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
- { {}, PORT_SCI, 0xfffffe80, SCI_IRQS, sci_init_pins_sci }, \
- { {}, PORT_SCIF, 0xA4000150, SH3_SCIF_IRQS, sci_init_pins_scif }, \
- { {}, PORT_SCIF, 0xA4000140, SH3_IRDA_IRQS, sci_init_pins_irda } \
-}
-# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
-# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
-# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_AND_SCIF
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
-# define SCI_NPORTS 2
-# define SCI_INIT { \
- { {}, PORT_SCI, 0xffe00000, SCI_IRQS, sci_init_pins_sci }, \
- { {}, PORT_SCIF, 0xFFE80000, SH4_SCIF_IRQS, sci_init_pins_scif } \
-}
-# define SCSPTR1 0xffe0001c /* 8 bit SCI */
-# define SCSPTR2 0xFFE80020 /* 16 bit SCIF */
-# define SCIF_ORER 0x0001 /* overrun error bit */
-# define SCSCR_INIT(port) (((port)->type == PORT_SCI) ? \
- 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
- 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
-# define SCI_AND_SCIF
-#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
- { {}, PORT_SCIF, 0xfe600000, SH7760_SCIF0_IRQS, sci_init_pins_scif }, \
- { {}, PORT_SCIF, 0xfe610000, SH7760_SCIF1_IRQS, sci_init_pins_scif }, \
- { {}, PORT_SCIF, 0xfe620000, SH7760_SCIF2_IRQS, sci_init_pins_scif } \
-}
-# define SCSPTR0 0xfe600024 /* 16 bit SCIF */
-# define SCSPTR1 0xfe610024 /* 16 bit SCIF */
-# define SCSPTR2 0xfe620024 /* 16 bit SCIF */
-# define SCIF_ORDER 0x0001 /* overrun error bit */
-# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
-# define SCIF_ONLY
-#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-# define SCI_NPORTS 2
-# define SCI_INIT { \
- { {}, PORT_SCIF, 0xffe00000, STB1_SCIF1_IRQS, sci_init_pins_scif }, \
- { {}, PORT_SCIF, 0xffe80000, SH4_SCIF_IRQS, sci_init_pins_scif } \
-}
-# define SCSPTR1 0xffe00020 /* 16 bit SCIF */
-# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
-# define SCIF_ORER 0x0001 /* overrun error bit */
-# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
-# define SCIF_ONLY
-#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
- { {}, PORT_SCI, 0x00ffffb0, H8300H_SCI_IRQS0, sci_init_pins_sci }, \
- { {}, PORT_SCI, 0x00ffffb8, H8300H_SCI_IRQS1, sci_init_pins_sci }, \
- { {}, PORT_SCI, 0x00ffffc0, H8300H_SCI_IRQS2, sci_init_pins_sci } \
-}
-# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
-#elif defined(CONFIG_H8S2678)
-# define SCI_NPORTS 3
-# define SCI_INIT { \
- { {}, PORT_SCI, 0x00ffff78, H8S_SCI_IRQS0, sci_init_pins_sci }, \
- { {}, PORT_SCI, 0x00ffff80, H8S_SCI_IRQS1, sci_init_pins_sci }, \
- { {}, PORT_SCI, 0x00ffff88, H8S_SCI_IRQS2, sci_init_pins_sci } \
-}
-# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
-# define SCI_ONLY
-# define H8300_SCI_DR(ch) *(volatile char *)(P1DR + h8300_sci_pins[ch].port)
-#else
-# error CPU subtype not defined
-#endif
-
-/* SCSCR */
-#define SCI_CTRL_FLAGS_TIE 0x80 /* all */
-#define SCI_CTRL_FLAGS_RIE 0x40 /* all */
-#define SCI_CTRL_FLAGS_TE 0x20 /* all */
-#define SCI_CTRL_FLAGS_RE 0x10 /* all */
-/* SCI_CTRL_FLAGS_REIE 0x08 * 7750 SCIF */
-/* SCI_CTRL_FLAGS_MPIE 0x08 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/* SCI_CTRL_FLAGS_TEIE 0x04 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/* SCI_CTRL_FLAGS_CKE1 0x02 * all */
-/* SCI_CTRL_FLAGS_CKE0 0x01 * 7707 SCI/SCIF, 7708 SCI, 7709 SCI/SCIF, 7750 SCI */
-
-/* SCxSR SCI */
-#define SCI_TDRE 0x80 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_RDRF 0x40 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_ORER 0x20 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_FER 0x10 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_PER 0x08 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-#define SCI_TEND 0x04 /* 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/* SCI_MPB 0x02 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-/* SCI_MPBT 0x01 * 7707 SCI, 7708 SCI, 7709 SCI, 7750 SCI */
-
-#define SCI_ERRORS ( SCI_PER | SCI_FER | SCI_ORER)
-
-/* SCxSR SCIF */
-#define SCIF_ER 0x0080 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TEND 0x0040 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_TDFE 0x0020 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_BRK 0x0010 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_FER 0x0008 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_PER 0x0004 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_RDF 0x0002 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-#define SCIF_DR 0x0001 /* 7707 SCIF, 7709 SCIF, 7750 SCIF */
-
-#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
-
-#if defined(SCI_ONLY)
-# define SCxSR_TEND(port) SCI_TEND
-# define SCxSR_ERRORS(port) SCI_ERRORS
-# define SCxSR_RDxF(port) SCI_RDRF
-# define SCxSR_TDxE(port) SCI_TDRE
-# define SCxSR_ORER(port) SCI_ORER
-# define SCxSR_FER(port) SCI_FER
-# define SCxSR_PER(port) SCI_PER
-# define SCxSR_BRK(port) 0x00
-# define SCxSR_RDxF_CLEAR(port) 0xbc
-# define SCxSR_ERROR_CLEAR(port) 0xc4
-# define SCxSR_TDxE_CLEAR(port) 0x78
-# define SCxSR_BREAK_CLEAR(port) 0xc4
-#elif defined(SCIF_ONLY)
-# define SCxSR_TEND(port) SCIF_TEND
-# define SCxSR_ERRORS(port) SCIF_ERRORS
-# define SCxSR_RDxF(port) SCIF_RDF
-# define SCxSR_TDxE(port) SCIF_TDFE
-# define SCxSR_ORER(port) 0x0000
-# define SCxSR_FER(port) SCIF_FER
-# define SCxSR_PER(port) SCIF_PER
-# define SCxSR_BRK(port) SCIF_BRK
-# define SCxSR_RDxF_CLEAR(port) 0x00fc
-# define SCxSR_ERROR_CLEAR(port) 0x0073
-# define SCxSR_TDxE_CLEAR(port) 0x00df
-# define SCxSR_BREAK_CLEAR(port) 0x00e3
-#else
-# define SCxSR_TEND(port) (((port)->type == PORT_SCI) ? SCI_TEND : SCIF_TEND)
-# define SCxSR_ERRORS(port) (((port)->type == PORT_SCI) ? SCI_ERRORS : SCIF_ERRORS)
-# define SCxSR_RDxF(port) (((port)->type == PORT_SCI) ? SCI_RDRF : SCIF_RDF)
-# define SCxSR_TDxE(port) (((port)->type == PORT_SCI) ? SCI_TDRE : SCIF_TDFE)
-# define SCxSR_ORER(port) (((port)->type == PORT_SCI) ? SCI_ORER : 0x0000)
-# define SCxSR_FER(port) (((port)->type == PORT_SCI) ? SCI_FER : SCIF_FER)
-# define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
-# define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
-# define SCxSR_RDxF_CLEAR(port) (((port)->type == PORT_SCI) ? 0xbc : 0x00fc)
-# define SCxSR_ERROR_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x0073)
-# define SCxSR_TDxE_CLEAR(port) (((port)->type == PORT_SCI) ? 0x78 : 0x00df)
-# define SCxSR_BREAK_CLEAR(port) (((port)->type == PORT_SCI) ? 0xc4 : 0x00e3)
-#endif
-
-/* SCFCR */
-#define SCFCR_RFRST 0x0002
-#define SCFCR_TFRST 0x0004
-#define SCFCR_MCE 0x0008
-
-#define SCI_MAJOR 204
-#define SCI_MINOR_START 8
-
-/* Generic serial flags */
-#define SCI_RX_THROTTLE 0x0000001
-
-#define SCI_MAGIC 0xbabeface
-
-/*
- * Events are used to schedule things to happen at timer-interrupt
- * time, instead of at rs interrupt time.
- */
-#define SCI_EVENT_WRITE_WAKEUP 0
-
-struct sci_port {
- struct gs_port gs;
- int type;
- unsigned int base;
- unsigned char irqs[4]; /* ERI, RXI, TXI, BRI */
- void (*init_pins)(struct sci_port* port, unsigned int cflag);
- unsigned int old_cflag;
- struct async_icount icount;
- struct work_struct tqueue;
- unsigned long event;
- int break_flag;
-};
-
-#define SCI_IN(size, offset) \
- unsigned int addr = port->base + (offset); \
- if ((size) == 8) { \
- return ctrl_inb(addr); \
- } else { \
- return ctrl_inw(addr); \
- }
-#define SCI_OUT(size, offset, value) \
- unsigned int addr = port->base + (offset); \
- if ((size) == 8) { \
- ctrl_outb(value, addr); \
- } else { \
- ctrl_outw(value, addr); \
- }
-
-#define CPU_SCIx_FNS(name, sci_offset, sci_size, scif_offset, scif_size)\
- static inline unsigned int sci_##name##_in(struct sci_port* port) \
- { \
- if (port->type == PORT_SCI) { \
- SCI_IN(sci_size, sci_offset) \
- } else { \
- SCI_IN(scif_size, scif_offset); \
- } \
- } \
- static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
- { \
- if (port->type == PORT_SCI) { \
- SCI_OUT(sci_size, sci_offset, value) \
- } else { \
- SCI_OUT(scif_size, scif_offset, value); \
- } \
- }
-
-#define CPU_SCIF_FNS(name, scif_offset, scif_size) \
- static inline unsigned int sci_##name##_in(struct sci_port* port) \
- { \
- SCI_IN(scif_size, scif_offset); \
- } \
- static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
- { \
- SCI_OUT(scif_size, scif_offset, value); \
- }
-
-#define CPU_SCI_FNS(name, sci_offset, sci_size) \
- static inline unsigned int sci_##name##_in(struct sci_port* port) \
- { \
- SCI_IN(sci_size, sci_offset); \
- } \
- static inline void sci_##name##_out(struct sci_port* port, unsigned int value) \
- { \
- SCI_OUT(sci_size, sci_offset, value); \
- }
-
-#ifdef CONFIG_CPU_SH3
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
- sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
- h8_sci_offset, h8_sci_size) \
- CPU_SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh3_scif_offset, sh3_scif_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
- CPU_SCIF_FNS(name, sh3_scif_offset, sh3_scif_size)
-#elif defined(__H8300H__) || defined(__H8300S__)
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
- sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
- h8_sci_offset, h8_sci_size) \
- CPU_SCI_FNS(name, h8_sci_offset, h8_sci_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size)
-#else
-#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
- sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
- h8_sci_offset, h8_sci_size) \
- CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
-#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
- CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
-#endif
-
-/* reg SCI/SH3 SCI/SH4 SCIF/SH3 SCIF/SH4 SCI/H8*/
-/* name off sz off sz off sz off sz off sz*/
-SCIx_FNS(SCSMR, 0x00, 8, 0x00, 8, 0x00, 8, 0x00, 16, 0x00, 8)
-SCIx_FNS(SCBRR, 0x02, 8, 0x04, 8, 0x02, 8, 0x04, 8, 0x01, 8)
-SCIx_FNS(SCSCR, 0x04, 8, 0x08, 8, 0x04, 8, 0x08, 16, 0x02, 8)
-SCIx_FNS(SCxTDR, 0x06, 8, 0x0c, 8, 0x06, 8, 0x0C, 8, 0x03, 8)
-SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
-SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
-SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
-SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
-SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
-
-#define sci_in(port, reg) sci_##reg##_in(port)
-#define sci_out(port, reg, value) sci_##reg##_out(port, value)
-
-/* H8/300 series SCI pins assignment */
-#if defined(__H8300H__) || defined(__H8300S__)
-static const struct __attribute__((packed))
-{
- int port; /* GPIO port no */
- unsigned short rx,tx; /* GPIO bit no */
-} h8300_sci_pins[] =
-{
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068)
- { /* SCI0 */
- .port = H8300_GPIO_P9,
- .rx = H8300_GPIO_B2,
- .tx = H8300_GPIO_B0,
- },
- { /* SCI1 */
- .port = H8300_GPIO_P9,
- .rx = H8300_GPIO_B3,
- .tx = H8300_GPIO_B1,
- },
- { /* SCI2 */
- .port = H8300_GPIO_PB,
- .rx = H8300_GPIO_B7,
- .tx = H8300_GPIO_B6,
- }
-#elif defined(CONFIG_H8S2678)
- { /* SCI0 */
- .port = H8300_GPIO_P3,
- .rx = H8300_GPIO_B2,
- .tx = H8300_GPIO_B0,
- },
- { /* SCI1 */
- .port = H8300_GPIO_P3,
- .rx = H8300_GPIO_B3,
- .tx = H8300_GPIO_B1,
- },
- { /* SCI2 */
- .port = H8300_GPIO_P5,
- .rx = H8300_GPIO_B1,
- .tx = H8300_GPIO_B0,
- }
-#endif
-};
-#endif
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7708)
-static inline int sci_rxd_in(struct sci_port *port)
-{
- if (port->base == 0xfffffe80)
- return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */
- return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
-static inline int sci_rxd_in(struct sci_port *port)
-{
- if (port->base == 0xfffffe80)
- return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
- if (port->base == 0xa4000150)
- return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
- if (port->base == 0xa4000140)
- return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
- return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
-static inline int sci_rxd_in(struct sci_port *port)
-{
-#ifndef SCIF_ONLY
- if (port->base == 0xffe00000)
- return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
-#endif
-#ifndef SCI_ONLY
- if (port->base == 0xffe80000)
- return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-#endif
- return 1;
-}
-#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
-static inline int sci_rxd_in(struct sci_port *port)
-{
- if (port->base == 0xfe600000)
- return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
- if (port->base == 0xfe610000)
- return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
- if (port->base == 0xfe620000)
- return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
-}
-#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
-static inline int sci_rxd_in(struct sci_port *port)
-{
- if (port->base == 0xffe00000)
- return ctrl_inw(SCSPTR1)&0x0001 ? 1 : 0; /* SCIF */
- else
- return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
-
-}
-#elif defined(__H8300H__) || defined(__H8300S__)
-static inline int sci_rxd_in(struct sci_port *port)
-{
- int ch = (port->base - SMR0) >> 3;
- return (H8300_SCI_DR(ch) & h8300_sci_pins[ch].rx) ? 1 : 0;
-}
-#endif
-
-/*
- * Values for the BitRate Register (SCBRR)
- *
- * The values are actually divisors for a frequency which can
- * be internal to the SH3 (14.7456MHz) or derived from an external
- * clock source. This driver assumes the internal clock is used;
- * to support using an external clock source, config options or
- * possibly command-line options would need to be added.
- *
- * Also, to support speeds below 2400 (why?) the lower 2 bits of
- * the SCSMR register would also need to be set to non-zero values.
- *
- * -- Greg Banks 27Feb2000
- *
- * Answer: The SCBRR register is only eight bits, and the value in
- * it gets larger with lower baud rates. At around 2400 (depending on
- * the peripherial module clock) you run out of bits. However the
- * lower two bits of SCSMR allow the module clock to be divided down,
- * scaling the value which is needed in SCBRR.
- *
- * -- Stuart Menefy - 23 May 2000
- *
- * I meant, why would anyone bother with bitrates below 2400.
- *
- * -- Greg Banks - 7Jul2000
- *
- * You "speedist"! How will I use my 110bps ASR-33 teletype with paper
- * tape reader as a console!
- *
- * -- Mitch Davis - 15 Jul 2000
- */
-
-#define PCLK (current_cpu_data.module_clock)
-
-#if !defined(__H8300H__) && !defined(__H8300S__)
-#define SCBRR_VALUE(bps) ((PCLK+16*bps)/(32*bps)-1)
-#else
-#define SCBRR_VALUE(bps) (((CONFIG_CPU_CLOCK*1000/32)/bps)-1)
-#endif
-#define BPS_2400 SCBRR_VALUE(2400)
-#define BPS_4800 SCBRR_VALUE(4800)
-#define BPS_9600 SCBRR_VALUE(9600)
-#define BPS_19200 SCBRR_VALUE(19200)
-#define BPS_38400 SCBRR_VALUE(38400)
-#define BPS_57600 SCBRR_VALUE(57600)
-#define BPS_115200 SCBRR_VALUE(115200)
-#define BPS_230400 SCBRR_VALUE(230400)
-
+++ /dev/null
-/*
- * C-Brick Serial Port (and console) driver for SGI Altix machines.
- *
- * This driver is NOT suitable for talking to the l1-controller for
- * anything other than 'console activities' --- please use the l1
- * driver for that.
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2003 Silicon Graphics, Inc. All rights reserved.
- */
-
-#include <linux/config.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/module.h>
-#include <linux/sysrq.h>
-#include <linux/circ_buf.h>
-#include <linux/serial_reg.h>
-#include <asm/uaccess.h>
-#include <asm/sn/sgi.h>
-#include <asm/sn/sn_sal.h>
-#include <asm/sn/pci/pciio.h>
-#include <asm/sn/simulator.h>
-#include <asm/sn/sn2/sn_private.h>
-
-#if defined(CONFIG_SGI_L1_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-static char sysrq_serial_str[] = "\eSYS";
-static char *sysrq_serial_ptr = sysrq_serial_str;
-static unsigned long sysrq_requested;
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
-/* minor device number */
-#define SN_SAL_MINOR 64
-
-/* number of characters left in xmit buffer before we ask for more */
-#define WAKEUP_CHARS 128
-
-/* number of characters we can transmit to the SAL console at a time */
-#define SN_SAL_MAX_CHARS 120
-
-#define SN_SAL_EVENT_WRITE_WAKEUP 0
-
-/* 64K, when we're asynch, it must be at least printk's LOG_BUF_LEN to
- * avoid losing chars, (always has to be a power of 2) */
-#define SN_SAL_BUFFER_SIZE (64 * (1 << 10))
-
-#define SN_SAL_UART_FIFO_DEPTH 16
-#define SN_SAL_UART_FIFO_SPEED_CPS 9600/10
-
-/* we don't kmalloc/get_free_page these as we want them available
- * before either of those are initialized */
-static char sn_xmit_buff_mem[SN_SAL_BUFFER_SIZE];
-
-struct volatile_circ_buf {
- char *cb_buf;
- int cb_head;
- int cb_tail;
-};
-
-static struct volatile_circ_buf xmit = { .cb_buf = sn_xmit_buff_mem };
-static char sn_tmp_buffer[SN_SAL_BUFFER_SIZE];
-
-static struct tty_struct *sn_sal_tty;
-
-static struct timer_list sn_sal_timer;
-static int sn_sal_event; /* event type for task queue */
-
-static int sn_sal_is_asynch;
-static int sn_sal_irq;
-static spinlock_t sn_sal_lock = SPIN_LOCK_UNLOCKED;
-static int sn_total_tx_count;
-static int sn_total_rx_count;
-
-static void sn_sal_tasklet_action(unsigned long data);
-static DECLARE_TASKLET(sn_sal_tasklet, sn_sal_tasklet_action, 0);
-
-static unsigned long sn_interrupt_timeout;
-
-extern u64 master_node_bedrock_address;
-
-#undef DEBUG
-#ifdef DEBUG
-static int sn_debug_printf(const char *fmt, ...);
-#define DPRINTF(x...) sn_debug_printf(x)
-#else
-#define DPRINTF(x...) do { } while (0)
-#endif
-
-struct sn_sal_ops {
- int (*sal_puts)(const char *s, int len);
- int (*sal_getc)(void);
- int (*sal_input_pending)(void);
- void (*sal_wakeup_transmit)(void);
-};
-
-/* This is the pointer used. It is assigned to point to one of
- * the tables below.
- */
-static struct sn_sal_ops *sn_func;
-
-/* Prototypes */
-static int snt_hw_puts(const char *, int);
-static int snt_poll_getc(void);
-static int snt_poll_input_pending(void);
-static int snt_sim_puts(const char *, int);
-static int snt_sim_getc(void);
-static int snt_sim_input_pending(void);
-static int snt_intr_getc(void);
-static int snt_intr_input_pending(void);
-static void sn_intr_transmit_chars(void);
-
-/* A table for polling */
-static struct sn_sal_ops poll_ops = {
- .sal_puts = snt_hw_puts,
- .sal_getc = snt_poll_getc,
- .sal_input_pending = snt_poll_input_pending
-};
-
-/* A table for the simulator */
-static struct sn_sal_ops sim_ops = {
- .sal_puts = snt_sim_puts,
- .sal_getc = snt_sim_getc,
- .sal_input_pending = snt_sim_input_pending
-};
-
-/* A table for interrupts enabled */
-static struct sn_sal_ops intr_ops = {
- .sal_puts = snt_hw_puts,
- .sal_getc = snt_intr_getc,
- .sal_input_pending = snt_intr_input_pending,
- .sal_wakeup_transmit = sn_intr_transmit_chars
-};
-
-
-/* the console does output in two distinctly different ways:
- * synchronous and asynchronous (buffered). initally, early_printk
- * does synchronous output. any data written goes directly to the SAL
- * to be output (incidentally, it is internally buffered by the SAL)
- * after interrupts and timers are initialized and available for use,
- * the console init code switches to asynchronous output. this is
- * also the earliest opportunity to begin polling for console input.
- * after console initialization, console output and tty (serial port)
- * output is buffered and sent to the SAL asynchronously (either by
- * timer callback or by UART interrupt) */
-
-
-/* routines for running the console in polling mode */
-
-static int
-snt_hw_puts(const char *s, int len)
-{
- /* looking at the PROM source code, putb calls the flush
- * routine, so if we send characters in FIFO sized chunks, it
- * should go out by the next time the timer gets called */
- return ia64_sn_console_putb(s, len);
-}
-
-static int
-snt_poll_getc(void)
-{
- int ch;
- ia64_sn_console_getc(&ch);
- return ch;
-}
-
-static int
-snt_poll_input_pending(void)
-{
- int status, input;
-
- status = ia64_sn_console_check(&input);
- return !status && input;
-}
-
-
-/* routines for running the console on the simulator */
-
-static int
-snt_sim_puts(const char *str, int count)
-{
- int counter = count;
-
-#ifdef FLAG_DIRECT_CONSOLE_WRITES
- /* This is an easy way to pre-pend the output to know whether the output
- * was done via sal or directly */
- writeb('[', master_node_bedrock_address + (UART_TX << 3));
- writeb('+', master_node_bedrock_address + (UART_TX << 3));
- writeb(']', master_node_bedrock_address + (UART_TX << 3));
- writeb(' ', master_node_bedrock_address + (UART_TX << 3));
-#endif /* FLAG_DIRECT_CONSOLE_WRITES */
- while (counter > 0) {
- writeb(*str, master_node_bedrock_address + (UART_TX << 3));
- counter--;
- str++;
- }
-
- return count;
-}
-
-static int
-snt_sim_getc(void)
-{
- return readb(master_node_bedrock_address + (UART_RX << 3));
-}
-
-static int
-snt_sim_input_pending(void)
-{
- return readb(master_node_bedrock_address + (UART_LSR << 3)) & UART_LSR_DR;
-}
-
-
-/* routines for an interrupt driven console (normal) */
-
-static int
-snt_intr_getc(void)
-{
- return ia64_sn_console_readc();
-}
-
-static int
-snt_intr_input_pending(void)
-{
- return ia64_sn_console_intr_status() & SAL_CONSOLE_INTR_RECV;
-}
-
-/* The early printk (possible setup) and function call */
-
-void
-early_printk_sn_sal(const char *s, unsigned count)
-{
- extern void early_sn_setup(void);
-
- if (!sn_func) {
- if (IS_RUNNING_ON_SIMULATOR())
- sn_func = &sim_ops;
- else
- sn_func = &poll_ops;
-
- early_sn_setup();
- }
- sn_func->sal_puts(s, count);
-}
-
-#ifdef DEBUG
-/* this is as "close to the metal" as we can get, used when the driver
- * itself may be broken */
-static int
-sn_debug_printf(const char *fmt, ...)
-{
- static char printk_buf[1024];
- int printed_len;
- va_list args;
-
- va_start(args, fmt);
- printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args);
- early_printk_sn_sal(printk_buf, printed_len);
- va_end(args);
- return printed_len;
-}
-#endif /* DEBUG */
-
-/*
- * Interrupt handling routines.
- */
-
-static void
-sn_sal_sched_event(int event)
-{
- sn_sal_event |= (1 << event);
- tasklet_schedule(&sn_sal_tasklet);
-}
-
-/* sn_receive_chars can be called before sn_sal_tty is initialized. in
- * that case, its only use is to trigger sysrq and kdb */
-static void
-sn_receive_chars(struct pt_regs *regs, unsigned long *flags)
-{
- int ch;
-
- while (sn_func->sal_input_pending()) {
- ch = sn_func->sal_getc();
- if (ch < 0) {
- printk(KERN_ERR "sn_serial: An error occured while "
- "obtaining data from the console (0x%0x)\n", ch);
- break;
- }
-#if defined(CONFIG_SGI_L1_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
- if (sysrq_requested) {
- unsigned long sysrq_timeout = sysrq_requested + HZ*5;
-
- sysrq_requested = 0;
- if (ch && time_before(jiffies, sysrq_timeout)) {
- spin_unlock_irqrestore(&sn_sal_lock, *flags);
- handle_sysrq(ch, regs, NULL);
- spin_lock_irqsave(&sn_sal_lock, *flags);
- /* don't record this char */
- continue;
- }
- }
- if (ch == *sysrq_serial_ptr) {
- if (!(*++sysrq_serial_ptr)) {
- sysrq_requested = jiffies;
- sysrq_serial_ptr = sysrq_serial_str;
- }
- }
- else
- sysrq_serial_ptr = sysrq_serial_str;
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE && CONFIG_MAGIC_SYSRQ */
-
- /* record the character to pass up to the tty layer */
- if (sn_sal_tty) {
- *sn_sal_tty->flip.char_buf_ptr = ch;
- sn_sal_tty->flip.char_buf_ptr++;
- sn_sal_tty->flip.count++;
- if (sn_sal_tty->flip.count == TTY_FLIPBUF_SIZE)
- break;
- }
- sn_total_rx_count++;
- }
-
- if (sn_sal_tty)
- tty_flip_buffer_push((struct tty_struct *)sn_sal_tty);
-}
-
-
-/* synch_flush_xmit must be called with sn_sal_lock */
-static void
-synch_flush_xmit(void)
-{
- int xmit_count, tail, head, loops, ii;
- int result;
- char *start;
-
- if (xmit.cb_head == xmit.cb_tail)
- return; /* Nothing to do. */
-
- head = xmit.cb_head;
- tail = xmit.cb_tail;
- start = &xmit.cb_buf[tail];
-
- /* twice around gets the tail to the end of the buffer and
- * then to the head, if needed */
- loops = (head < tail) ? 2 : 1;
-
- for (ii = 0; ii < loops; ii++) {
- xmit_count = (head < tail) ? (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
- if (xmit_count > 0) {
- result = sn_func->sal_puts((char *)start, xmit_count);
- if (!result)
- DPRINTF("\n*** synch_flush_xmit failed to flush\n");
- if (result > 0) {
- xmit_count -= result;
- sn_total_tx_count += result;
- tail += result;
- tail &= SN_SAL_BUFFER_SIZE - 1;
- xmit.cb_tail = tail;
- start = (char *)&xmit.cb_buf[tail];
- }
- }
- }
-}
-
-/* must be called with a lock protecting the circular buffer and
- * sn_sal_tty */
-static void
-sn_poll_transmit_chars(void)
-{
- int xmit_count, tail, head;
- int result;
- char *start;
-
- BUG_ON(!sn_sal_is_asynch);
-
- if (xmit.cb_head == xmit.cb_tail ||
- (sn_sal_tty && (sn_sal_tty->stopped || sn_sal_tty->hw_stopped))) {
- /* Nothing to do. */
- return;
- }
-
- head = xmit.cb_head;
- tail = xmit.cb_tail;
- start = &xmit.cb_buf[tail];
-
- xmit_count = (head < tail) ? (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
- if (xmit_count == 0)
- DPRINTF("\n*** empty xmit_count\n");
-
- /* use the ops, as we could be on the simulator */
- result = sn_func->sal_puts((char *)start, xmit_count);
- if (!result)
- DPRINTF("\n*** error in synchronous sal_puts\n");
- /* XXX chadt clean this up */
- if (result > 0) {
- xmit_count -= result;
- sn_total_tx_count += result;
- tail += result;
- tail &= SN_SAL_BUFFER_SIZE - 1;
- xmit.cb_tail = tail;
- start = &xmit.cb_buf[tail];
- }
-
- /* if there's few enough characters left in the xmit buffer
- * that we could stand for the upper layer to send us some
- * more, ask for it. */
- if (sn_sal_tty)
- if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
- sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
-}
-
-
-/* must be called with a lock protecting the circular buffer and
- * sn_sal_tty */
-static void
-sn_intr_transmit_chars(void)
-{
- int xmit_count, tail, head, loops, ii;
- int result;
- char *start;
-
- BUG_ON(!sn_sal_is_asynch);
-
- if (xmit.cb_head == xmit.cb_tail ||
- (sn_sal_tty && (sn_sal_tty->stopped || sn_sal_tty->hw_stopped))) {
- /* Nothing to do. */
- return;
- }
-
- head = xmit.cb_head;
- tail = xmit.cb_tail;
- start = &xmit.cb_buf[tail];
-
- /* twice around gets the tail to the end of the buffer and
- * then to the head, if needed */
- loops = (head < tail) ? 2 : 1;
-
- for (ii = 0; ii < loops; ii++) {
- xmit_count = (head < tail) ?
- (SN_SAL_BUFFER_SIZE - tail) : (head - tail);
-
- if (xmit_count > 0) {
- result = ia64_sn_console_xmit_chars((char *)start, xmit_count);
-#ifdef DEBUG
- if (!result)
- DPRINTF("`");
-#endif
- if (result > 0) {
- xmit_count -= result;
- sn_total_tx_count += result;
- tail += result;
- tail &= SN_SAL_BUFFER_SIZE - 1;
- xmit.cb_tail = tail;
- start = &xmit.cb_buf[tail];
- }
- }
- }
-
- /* if there's few enough characters left in the xmit buffer
- * that we could stand for the upper layer to send us some
- * more, ask for it. */
- if (sn_sal_tty)
- if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
- sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
-}
-
-
-static irqreturn_t
-sn_sal_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- /* this call is necessary to pass the interrupt back to the
- * SAL, since it doesn't intercept the UART interrupts
- * itself */
- int status = ia64_sn_console_intr_status();
- unsigned long flags;
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (status & SAL_CONSOLE_INTR_RECV)
- sn_receive_chars(regs, &flags);
- if (status & SAL_CONSOLE_INTR_XMIT)
- sn_intr_transmit_chars();
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- return IRQ_HANDLED;
-}
-
-
-/* returns the console irq if interrupt is successfully registered,
- * else 0 */
-static int
-sn_sal_connect_interrupt(void)
-{
- cpuid_t intr_cpuid;
- unsigned int intr_cpuloc;
- nasid_t console_nasid;
- unsigned int console_irq;
- int result;
-
- console_nasid = ia64_sn_get_console_nasid();
- intr_cpuid = first_cpu(node_to_cpumask(nasid_to_cnodeid(console_nasid)));
- intr_cpuloc = cpu_physical_id(intr_cpuid);
- console_irq = CPU_VECTOR_TO_IRQ(intr_cpuloc, SGI_UART_VECTOR);
-
- result = intr_connect_level(intr_cpuid, SGI_UART_VECTOR);
- BUG_ON(result != SGI_UART_VECTOR);
-
- result = request_irq(console_irq, sn_sal_interrupt, SA_INTERRUPT, "SAL console driver", &sn_sal_tty);
- if (result >= 0)
- return console_irq;
-
- printk(KERN_WARNING "sn_serial: console proceeding in polled mode\n");
- return 0;
-}
-
-static void
-sn_sal_tasklet_action(unsigned long data)
-{
- unsigned long flags;
-
- if (sn_sal_tty) {
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (sn_sal_tty) {
- if (test_and_clear_bit(SN_SAL_EVENT_WRITE_WAKEUP, &sn_sal_event)) {
- if ((sn_sal_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && sn_sal_tty->ldisc.write_wakeup)
- (sn_sal_tty->ldisc.write_wakeup)((struct tty_struct *)sn_sal_tty);
- wake_up_interruptible((wait_queue_head_t *)&sn_sal_tty->write_wait);
- }
- }
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- }
-}
-
-
-/*
- * This function handles polled mode.
- */
-static void
-sn_sal_timer_poll(unsigned long dummy)
-{
- unsigned long flags;
-
- if (!sn_sal_irq) {
- spin_lock_irqsave(&sn_sal_lock, flags);
- sn_receive_chars(NULL, &flags);
- sn_poll_transmit_chars();
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- mod_timer(&sn_sal_timer, jiffies + sn_interrupt_timeout);
- }
-}
-
-
-/*
- * User-level console routines
- */
-
-static int
-sn_sal_open(struct tty_struct *tty, struct file *filp)
-{
- unsigned long flags;
-
- DPRINTF("sn_sal_open: sn_sal_tty = %p, tty = %p, filp = %p\n",
- sn_sal_tty, tty, filp);
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (!sn_sal_tty)
- sn_sal_tty = tty;
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-
- return 0;
-}
-
-
-/* We're keeping all our resources. We're keeping interrupts turned
- * on. Maybe just let the tty layer finish its stuff...? GMSH
- */
-static void
-sn_sal_close(struct tty_struct *tty, struct file * filp)
-{
- if (tty->count == 1) {
- unsigned long flags;
- tty->closing = 1;
- if (tty->driver->flush_buffer)
- tty->driver->flush_buffer(tty);
- if (tty->ldisc.flush_buffer)
- tty->ldisc.flush_buffer(tty);
- tty->closing = 0;
- spin_lock_irqsave(&sn_sal_lock, flags);
- sn_sal_tty = NULL;
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- }
-}
-
-
-static int
-sn_sal_write(struct tty_struct *tty, int from_user,
- const unsigned char *buf, int count)
-{
- int c, ret = 0;
- unsigned long flags;
-
- if (from_user) {
- while (1) {
- int c1;
- c = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail,
- SN_SAL_BUFFER_SIZE);
-
- if (count < c)
- c = count;
- if (c <= 0)
- break;
-
- c -= copy_from_user(sn_tmp_buffer, buf, c);
- if (!c) {
- if (!ret)
- ret = -EFAULT;
- break;
- }
-
- /* Turn off interrupts and see if the xmit buffer has
- * moved since the last time we looked.
- */
- spin_lock_irqsave(&sn_sal_lock, flags);
- c1 = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-
- if (c1 < c)
- c = c1;
-
- memcpy(xmit.cb_buf + xmit.cb_head, sn_tmp_buffer, c);
- xmit.cb_head = ((xmit.cb_head + c) & (SN_SAL_BUFFER_SIZE - 1));
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-
- buf += c;
- count -= c;
- ret += c;
- }
- }
- else {
- /* The buffer passed in isn't coming from userland,
- * so cut out the middleman (sn_tmp_buffer).
- */
- spin_lock_irqsave(&sn_sal_lock, flags);
- while (1) {
- c = CIRC_SPACE_TO_END(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
-
- if (count < c)
- c = count;
- if (c <= 0) {
- break;
- }
- memcpy(xmit.cb_buf + xmit.cb_head, buf, c);
- xmit.cb_head = ((xmit.cb_head + c) & (SN_SAL_BUFFER_SIZE - 1));
- buf += c;
- count -= c;
- ret += c;
- }
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- }
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (xmit.cb_head != xmit.cb_tail && !(tty && (tty->stopped || tty->hw_stopped)))
- if (sn_func->sal_wakeup_transmit)
- sn_func->sal_wakeup_transmit();
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-
- return ret;
-}
-
-
-static void
-sn_sal_put_char(struct tty_struct *tty, unsigned char ch)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (CIRC_SPACE(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) != 0) {
- xmit.cb_buf[xmit.cb_head] = ch;
- xmit.cb_head = (xmit.cb_head + 1) & (SN_SAL_BUFFER_SIZE-1);
- if ( sn_func->sal_wakeup_transmit )
- sn_func->sal_wakeup_transmit();
- }
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-
-static void
-sn_sal_flush_chars(struct tty_struct *tty)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE))
- if (sn_func->sal_wakeup_transmit)
- sn_func->sal_wakeup_transmit();
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-
-static int
-sn_sal_write_room(struct tty_struct *tty)
-{
- unsigned long flags;
- int space;
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- space = CIRC_SPACE(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- return space;
-}
-
-
-static int
-sn_sal_chars_in_buffer(struct tty_struct *tty)
-{
- unsigned long flags;
- int space;
-
- spin_lock_irqsave(&sn_sal_lock, flags);
- space = CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE);
- DPRINTF("<%d>", space);
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- return space;
-}
-
-
-static void
-sn_sal_flush_buffer(struct tty_struct *tty)
-{
- unsigned long flags;
-
- /* drop everything */
- spin_lock_irqsave(&sn_sal_lock, flags);
- xmit.cb_head = xmit.cb_tail = 0;
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-
- /* wake up tty level */
- wake_up_interruptible(&tty->write_wait);
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
-}
-
-
-static void
-sn_sal_hangup(struct tty_struct *tty)
-{
- sn_sal_flush_buffer(tty);
-}
-
-
-static void
-sn_sal_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- /* this is SAL's problem */
- DPRINTF("<sn_serial: should wait until sent>");
-}
-
-
-/*
- * sn_sal_read_proc
- *
- * Console /proc interface
- */
-
-static int
-sn_sal_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- int len = 0;
- off_t begin = 0;
-
- len += sprintf(page, "sn_serial: nasid:%ld irq:%d tx:%d rx:%d\n",
- ia64_sn_get_console_nasid(), sn_sal_irq,
- sn_total_tx_count, sn_total_rx_count);
- *eof = 1;
-
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
-
- return count < begin+len-off ? count : begin+len-off;
-}
-
-
-static struct tty_operations sn_sal_driver_ops = {
- .open = sn_sal_open,
- .close = sn_sal_close,
- .write = sn_sal_write,
- .put_char = sn_sal_put_char,
- .flush_chars = sn_sal_flush_chars,
- .write_room = sn_sal_write_room,
- .chars_in_buffer = sn_sal_chars_in_buffer,
- .hangup = sn_sal_hangup,
- .wait_until_sent = sn_sal_wait_until_sent,
- .read_proc = sn_sal_read_proc,
-};
-static struct tty_driver *sn_sal_driver;
-
-/* sn_sal_init wishlist:
- * - allocate sn_tmp_buffer
- * - fix up the tty_driver struct
- * - turn on receive interrupts
- * - do any termios twiddling once and for all
- */
-
-/*
- * Boot-time initialization code
- */
-
-static void __init
-sn_sal_switch_to_asynch(void)
-{
- unsigned long flags;
-
- /* without early_printk, we may be invoked late enough to race
- * with other cpus doing console IO at this point, however
- * console interrupts will never be enabled */
- spin_lock_irqsave(&sn_sal_lock, flags);
-
- if (sn_sal_is_asynch) {
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- return;
- }
-
- DPRINTF("sn_serial: switch to asynchronous console\n");
-
- /* early_printk invocation may have done this for us */
- if (!sn_func) {
- if (IS_RUNNING_ON_SIMULATOR())
- sn_func = &sim_ops;
- else
- sn_func = &poll_ops;
- }
-
- /* we can't turn on the console interrupt (as request_irq
- * calls kmalloc, which isn't set up yet), so we rely on a
- * timer to poll for input and push data from the console
- * buffer.
- */
- init_timer(&sn_sal_timer);
- sn_sal_timer.function = sn_sal_timer_poll;
-
- if (IS_RUNNING_ON_SIMULATOR())
- sn_interrupt_timeout = 6;
- else {
- /* 960cps / 16 char FIFO = 60HZ
- * HZ / (SN_SAL_FIFO_SPEED_CPS / SN_SAL_FIFO_DEPTH) */
- sn_interrupt_timeout = HZ * SN_SAL_UART_FIFO_DEPTH / SN_SAL_UART_FIFO_SPEED_CPS;
- }
- mod_timer(&sn_sal_timer, jiffies + sn_interrupt_timeout);
-
- sn_sal_is_asynch = 1;
- spin_unlock_irqrestore(&sn_sal_lock, flags);
-}
-
-static void __init
-sn_sal_switch_to_interrupts(void)
-{
- int irq;
-
- DPRINTF("sn_serial: switching to interrupt driven console\n");
-
- irq = sn_sal_connect_interrupt();
- if (irq) {
- unsigned long flags;
- spin_lock_irqsave(&sn_sal_lock, flags);
-
- /* sn_sal_irq is a global variable. When it's set to
- * a non-zero value, we stop polling for input (since
- * interrupts should now be enabled). */
- sn_sal_irq = irq;
- sn_func = &intr_ops;
-
- /* turn on receive interrupts */
- ia64_sn_console_intr_enable(SAL_CONSOLE_INTR_RECV);
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- }
-}
-
-static int __init
-sn_sal_module_init(void)
-{
- int retval;
-
- DPRINTF("sn_serial: sn_sal_module_init\n");
-
- if (!ia64_platform_is("sn2"))
- return -ENODEV;
-
- sn_sal_driver = alloc_tty_driver(1);
- if ( !sn_sal_driver )
- return -ENOMEM;
-
- sn_sal_driver->owner = THIS_MODULE;
- sn_sal_driver->driver_name = "sn_serial";
- sn_sal_driver->name = "ttyS";
- sn_sal_driver->major = TTY_MAJOR;
- sn_sal_driver->minor_start = SN_SAL_MINOR;
- sn_sal_driver->type = TTY_DRIVER_TYPE_SERIAL;
- sn_sal_driver->subtype = SERIAL_TYPE_NORMAL;
- sn_sal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
-
- tty_set_operations(sn_sal_driver, &sn_sal_driver_ops);
-
- /* when this driver is compiled in, the console initialization
- * will have already switched us into asynchronous operation
- * before we get here through the module initcalls */
- sn_sal_switch_to_asynch();
-
- /* at this point (module_init) we can try to turn on interrupts */
- if (!IS_RUNNING_ON_SIMULATOR())
- sn_sal_switch_to_interrupts();
-
- sn_sal_driver->init_termios = tty_std_termios;
- sn_sal_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
-
- if ((retval = tty_register_driver(sn_sal_driver))) {
- printk(KERN_ERR "sn_serial: Unable to register tty driver\n");
- return retval;
- }
- return 0;
-}
-
-
-static void __exit
-sn_sal_module_exit(void)
-{
- del_timer_sync(&sn_sal_timer);
- tty_unregister_driver(sn_sal_driver);
- put_tty_driver(sn_sal_driver);
-}
-
-module_init(sn_sal_module_init);
-module_exit(sn_sal_module_exit);
-
-/*
- * Kernel console definitions
- */
-
-#ifdef CONFIG_SGI_L1_SERIAL_CONSOLE
-/*
- * Print a string to the SAL console. The console_lock must be held
- * when we get here.
- */
-static void
-sn_sal_console_write(struct console *co, const char *s, unsigned count)
-{
- unsigned long flags;
- const char *s1;
-
- BUG_ON(!sn_sal_is_asynch);
-
- /* somebody really wants this output, might be an
- * oops, kdb, panic, etc. make sure they get it. */
- if (spin_is_locked(&sn_sal_lock)) {
- synch_flush_xmit();
- /* Output '\r' before each '\n' */
- while ((s1 = memchr(s, '\n', count)) != NULL) {
- sn_func->sal_puts(s, s1 - s);
- sn_func->sal_puts("\r\n", 2);
- count -= s1 + 1 - s;
- s = s1 + 1;
- }
- sn_func->sal_puts(s, count);
- }
- else if (in_interrupt()) {
- spin_lock_irqsave(&sn_sal_lock, flags);
- synch_flush_xmit();
- spin_unlock_irqrestore(&sn_sal_lock, flags);
- /* Output '\r' before each '\n' */
- while ((s1 = memchr(s, '\n', count)) != NULL) {
- sn_func->sal_puts(s, s1 - s);
- sn_func->sal_puts("\r\n", 2);
- count -= s1 + 1 - s;
- s = s1 + 1;
- }
- sn_func->sal_puts(s, count);
- }
- else {
- /* Output '\r' before each '\n' */
- while ((s1 = memchr(s, '\n', count)) != NULL) {
- sn_sal_write(NULL, 0, s, s1 - s);
- sn_sal_write(NULL, 0, "\r\n", 2);
- count -= s1 + 1 - s;
- s = s1 + 1;
- }
- sn_sal_write(NULL, 0, s, count);
- }
-}
-
-static struct tty_driver *
-sn_sal_console_device(struct console *c, int *index)
-{
- *index = c->index;
- return sn_sal_driver;
-}
-
-static int __init
-sn_sal_console_setup(struct console *co, char *options)
-{
- return 0;
-}
-
-
-static struct console sal_console = {
- .name = "ttyS",
- .write = sn_sal_console_write,
- .device = sn_sal_console_device,
- .setup = sn_sal_console_setup,
- .index = -1
-};
-
-static int __init
-sn_sal_serial_console_init(void)
-{
- if (ia64_platform_is("sn2")) {
- sn_sal_switch_to_asynch();
- DPRINTF("sn_sal_serial_console_init : register console\n");
- register_console(&sal_console);
- }
- return 0;
-}
-console_initcall(sn_sal_serial_console_init);
-
-#endif /* CONFIG_SGI_L1_SERIAL_CONSOLE */
+++ /dev/null
-/*
- * NEC PC-9800 Real Time Clock interface for Linux
- *
- * Copyright (C) 1997-2001 Linux/98 project,
- * Kyoto University Microcomputer Club.
- *
- * Based on:
- * drivers/char/rtc.c by Paul Gortmaker
- *
- * Changes:
- * 2001-02-09 Call check_region on rtc_init and do not request I/O 0033h.
- * Call del_timer and release_region on rtc_exit. -- tak
- * 2001-07-14 Rewrite <linux/upd4990a.h> and split to <linux/upd4990a.h>
- * and <asm-i386/upd4990a.h>.
- * Introduce a lot of spin_lock/unlock (&rtc_lock).
- */
-
-#define RTC98_VERSION "1.2"
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/miscdevice.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/rtc.h>
-#include <linux/bcd.h>
-#include <linux/upd4990a.h>
-#include <linux/init.h>
-#include <linux/poll.h>
-#include <linux/proc_fs.h>
-#include <linux/spinlock.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-/*
- * We sponge a minor off of the misc major. No need slurping
- * up another valuable major dev number for this. If you add
- * an ioctl, make sure you don't conflict with SPARC's RTC
- * ioctls.
- */
-
-static struct fasync_struct *rtc_async_queue;
-
-static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
-
-static struct timer_list rtc_uie_timer;
-static u8 old_refclk;
-
-static int rtc_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
-
-static int rtc_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data);
-
-/*
- * Bits in rtc_status. (5 bits of room for future expansion)
- */
-
-#define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */
-#define RTC_TIMER_ON 0x02 /* not used */
-#define RTC_UIE_TIMER_ON 0x04 /* UIE emulation timer is active */
-
-/*
- * rtc_status is never changed by rtc_interrupt, and ioctl/open/close is
- * protected by the big kernel lock. However, ioctl can still disable the timer
- * in rtc_status and then with del_timer after the interrupt has read
- * rtc_status but before mod_timer is called, which would then reenable the
- * timer (but you would need to have an awful timing before you'd trip on it)
- */
-static unsigned char rtc_status; /* bitmapped status byte. */
-static unsigned long rtc_irq_data; /* our output to the world */
-
-static const unsigned char days_in_mo[] =
-{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-
-extern spinlock_t rtc_lock; /* defined in arch/i386/kernel/time.c */
-
-static void rtc_uie_intr(unsigned long data)
-{
- u8 refclk, tmp;
-
- /* Kernel timer does del_timer internally before calling
- each timer entry, so this is unnecessary.
- del_timer(&rtc_uie_timer); */
- spin_lock(&rtc_lock);
-
- /* Detect rising edge of 1Hz reference clock. */
- refclk = UPD4990A_READ_DATA();
- tmp = old_refclk & refclk;
- old_refclk = ~refclk;
- if (!(tmp & 1))
- rtc_irq_data += 0x100;
-
- spin_unlock(&rtc_lock);
-
- if (!(tmp & 1)) {
- /* Now do the rest of the actions */
- wake_up_interruptible(&rtc_wait);
- kill_fasync(&rtc_async_queue, SIGIO, POLL_IN);
- }
-
- rtc_uie_timer.expires = jiffies + 1;
- add_timer(&rtc_uie_timer);
-}
-
-/*
- * Now all the various file operations that we export.
- */
-
-static ssize_t rtc_read(struct file *file, char *buf,
- size_t count, loff_t *ppos)
-{
- DECLARE_WAITQUEUE(wait, current);
- unsigned long data;
- ssize_t retval = 0;
-
- if (count < sizeof(unsigned long))
- return -EINVAL;
-
- add_wait_queue(&rtc_wait, &wait);
-
- set_current_state(TASK_INTERRUPTIBLE);
-
- do {
- /* First make it right. Then make it fast. Putting this whole
- * block within the parentheses of a while would be too
- * confusing. And no, xchg() is not the answer. */
- spin_lock_irq(&rtc_lock);
- data = rtc_irq_data;
- rtc_irq_data = 0;
- spin_unlock_irq(&rtc_lock);
-
- if (data != 0)
- break;
- if (file->f_flags & O_NONBLOCK) {
- retval = -EAGAIN;
- goto out;
- }
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- goto out;
- }
- schedule();
- } while (1);
-
- retval = put_user(data, (unsigned long *)buf);
- if (!retval)
- retval = sizeof(unsigned long);
- out:
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&rtc_wait, &wait);
-
- return retval;
-}
-
-static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- struct rtc_time wtime;
- struct upd4990a_raw_data raw;
-
- switch (cmd) {
- case RTC_UIE_OFF: /* Mask ints from RTC updates. */
- spin_lock_irq(&rtc_lock);
- if (rtc_status & RTC_UIE_TIMER_ON) {
- rtc_status &= ~RTC_UIE_TIMER_ON;
- del_timer(&rtc_uie_timer);
- }
- spin_unlock_irq(&rtc_lock);
- return 0;
-
- case RTC_UIE_ON: /* Allow ints for RTC updates. */
- spin_lock_irq(&rtc_lock);
- rtc_irq_data = 0;
- if (!(rtc_status & RTC_UIE_TIMER_ON)) {
- rtc_status |= RTC_UIE_TIMER_ON;
- rtc_uie_timer.expires = jiffies + 1;
- add_timer(&rtc_uie_timer);
- }
- /* Just in case... */
- upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
- old_refclk = ~UPD4990A_READ_DATA();
- spin_unlock_irq(&rtc_lock);
- return 0;
-
- case RTC_RD_TIME: /* Read the time/date from RTC */
- spin_lock_irq(&rtc_lock);
- upd4990a_get_time(&raw, 0);
- spin_unlock_irq(&rtc_lock);
-
- wtime.tm_sec = BCD2BIN(raw.sec);
- wtime.tm_min = BCD2BIN(raw.min);
- wtime.tm_hour = BCD2BIN(raw.hour);
- wtime.tm_mday = BCD2BIN(raw.mday);
- wtime.tm_mon = raw.mon - 1; /* convert to 0-base */
- wtime.tm_wday = raw.wday;
-
- /*
- * Account for differences between how the RTC uses the values
- * and how they are defined in a struct rtc_time;
- */
- if ((wtime.tm_year = BCD2BIN(raw.year)) < 95)
- wtime.tm_year += 100;
-
- wtime.tm_isdst = 0;
- break;
-
- case RTC_SET_TIME: /* Set the RTC */
- {
- int leap_yr;
-
- if (!capable(CAP_SYS_TIME))
- return -EACCES;
-
- if (copy_from_user(&wtime, (struct rtc_time *) arg,
- sizeof (struct rtc_time)))
- return -EFAULT;
-
- /* Valid year is 1995 - 2094, inclusive. */
- if (wtime.tm_year < 95 || wtime.tm_year > 194)
- return -EINVAL;
-
- if (wtime.tm_mon > 11 || wtime.tm_mday == 0)
- return -EINVAL;
-
- /* For acceptable year domain (1995 - 2094),
- this IS sufficient. */
- leap_yr = !(wtime.tm_year % 4);
-
- if (wtime.tm_mday > (days_in_mo[wtime.tm_mon]
- + (wtime.tm_mon == 2 && leap_yr)))
- return -EINVAL;
-
- if (wtime.tm_hour >= 24
- || wtime.tm_min >= 60 || wtime.tm_sec >= 60)
- return -EINVAL;
-
- if (wtime.tm_wday > 6)
- return -EINVAL;
-
- raw.sec = BIN2BCD(wtime.tm_sec);
- raw.min = BIN2BCD(wtime.tm_min);
- raw.hour = BIN2BCD(wtime.tm_hour);
- raw.mday = BIN2BCD(wtime.tm_mday);
- raw.mon = wtime.tm_mon + 1;
- raw.wday = wtime.tm_wday;
- raw.year = BIN2BCD(wtime.tm_year % 100);
-
- spin_lock_irq(&rtc_lock);
- upd4990a_set_time(&raw, 0);
- spin_unlock_irq(&rtc_lock);
-
- return 0;
- }
- default:
- return -EINVAL;
- }
- return copy_to_user((void *)arg, &wtime, sizeof wtime) ? -EFAULT : 0;
-}
-
-/*
- * We enforce only one user at a time here with the open/close.
- * Also clear the previous interrupt data on an open, and clean
- * up things on a close.
- */
-
-static int rtc_open(struct inode *inode, struct file *file)
-{
- spin_lock_irq(&rtc_lock);
-
- if(rtc_status & RTC_IS_OPEN)
- goto out_busy;
-
- rtc_status |= RTC_IS_OPEN;
-
- rtc_irq_data = 0;
- spin_unlock_irq(&rtc_lock);
- return 0;
-
- out_busy:
- spin_unlock_irq(&rtc_lock);
- return -EBUSY;
-}
-
-static int rtc_fasync(int fd, struct file *filp, int on)
-{
- return fasync_helper(fd, filp, on, &rtc_async_queue);
-}
-
-static int rtc_release(struct inode *inode, struct file *file)
-{
- del_timer(&rtc_uie_timer);
-
- if (file->f_flags & FASYNC)
- rtc_fasync(-1, file, 0);
-
- rtc_irq_data = 0;
-
- /* No need for locking -- nobody else can do anything until this rmw is
- * committed, and no timer is running. */
- rtc_status &= ~(RTC_IS_OPEN | RTC_UIE_TIMER_ON);
- return 0;
-}
-
-static unsigned int rtc_poll(struct file *file, poll_table *wait)
-{
- unsigned long l;
-
- poll_wait(file, &rtc_wait, wait);
-
- spin_lock_irq(&rtc_lock);
- l = rtc_irq_data;
- spin_unlock_irq(&rtc_lock);
-
- if (l != 0)
- return POLLIN | POLLRDNORM;
- return 0;
-}
-
-/*
- * The various file operations we support.
- */
-
-static struct file_operations rtc_fops = {
- .owner = THIS_MODULE,
- .read = rtc_read,
- .poll = rtc_poll,
- .ioctl = rtc_ioctl,
- .open = rtc_open,
- .release = rtc_release,
- .fasync = rtc_fasync,
-};
-
-static struct miscdevice rtc_dev=
-{
- .minor = RTC_MINOR,
- .name = "rtc",
- .fops = &rtc_fops,
-};
-
-static int __init rtc_init(void)
-{
- int err = 0;
-
- if (!request_region(UPD4990A_IO, 1, "rtc")) {
- printk(KERN_ERR "upd4990a: could not acquire I/O port %#x\n",
- UPD4990A_IO);
- return -EBUSY;
- }
-
- err = misc_register(&rtc_dev);
- if (err) {
- printk(KERN_ERR "upd4990a: can't misc_register() on minor=%d\n",
- RTC_MINOR);
- release_region(UPD4990A_IO, 1);
- return err;
- }
-
-#if 0
- printk(KERN_INFO "\xB6\xDA\xDD\xC0\xDE \xC4\xDE\xB9\xB2 Driver\n"); /* Calender Clock Driver */
-#else
- printk(KERN_INFO
- "Real Time Clock driver for NEC PC-9800 v" RTC98_VERSION "\n");
-#endif
- create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, NULL);
-
- init_timer(&rtc_uie_timer);
- rtc_uie_timer.function = rtc_uie_intr;
-
- return 0;
-}
-
-module_init (rtc_init);
-
-static void __exit rtc_exit(void)
-{
- del_timer(&rtc_uie_timer);
- release_region(UPD4990A_IO, 1);
- remove_proc_entry("driver/rtc", NULL);
- misc_deregister(&rtc_dev);
-}
-
-module_exit (rtc_exit);
-
-/*
- * Info exported via "/proc/driver/rtc".
- */
-
-static inline int rtc_get_status(char *buf)
-{
- char *p;
- unsigned int year;
- struct upd4990a_raw_data data;
-
- p = buf;
-
- upd4990a_get_time(&data, 0);
-
- /*
- * There is no way to tell if the luser has the RTC set for local
- * time or for Universal Standard Time (GMT). Probably local though.
- */
- if ((year = BCD2BIN(data.year) + 1900) < 1995)
- year += 100;
- p += sprintf(p,
- "rtc_time\t: %02d:%02d:%02d\n"
- "rtc_date\t: %04d-%02d-%02d\n",
- BCD2BIN(data.hour), BCD2BIN(data.min),
- BCD2BIN(data.sec),
- year, data.mon, BCD2BIN(data.mday));
-
- return p - buf;
-}
-
-static int rtc_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len = rtc_get_status(page);
-
- if (len <= off + count)
- *eof = 1;
- *start = page + off;
- len -= off;
- if (len > count)
- len = count;
- if (len < 0)
- len = 0;
- return len;
-}
+++ /dev/null
-/*
- * drivers/i2c/i2c-adap-ixp42x.c
- *
- * Intel's IXP42x XScale NPU chipsets (IXP420, 421, 422, 425) do not have
- * an on board I2C controller but provide 16 GPIO pins that are often
- * used to create an I2C bus. This driver provides an i2c_adapter
- * interface that plugs in under algo_bit and drives the GPIO pins
- * as instructed by the alogorithm driver.
- *
- * Author: Deepak Saxena <dsaxena@plexity.net>
- *
- * Copyright (c) 2003-2004 MontaVista Software Inc.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
- *
- * NOTE: Since different platforms will use different GPIO pins for
- * I2C, this driver uses an IXP42x-specific platform_data
- * pointer to pass the GPIO numbers to the driver. This
- * allows us to support all the different IXP42x platforms
- * w/o having to put #ifdefs in this driver.
- *
- * See arch/arm/mach-ixp42x/ixdp425.c for an example of building a
- * device list and filling in the ixp42x_i2c_pins data structure
- * that is passed as the platform_data to this driver.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/i2c.h>
-
-#include <asm/hardware.h> /* Pick up IXP42x-specific bits */
-
-static inline int ixp42x_scl_pin(void *data)
-{
- return ((struct ixp42x_i2c_pins*)data)->scl_pin;
-}
-
-static inline int ixp42x_sda_pin(void *data)
-{
- return ((struct ixp42x_i2c_pins*)data)->sda_pin;
-}
-
-static void ixp42x_bit_setscl(void *data, int val)
-{
- gpio_line_set(ixp42x_scl_pin(data), 0);
- gpio_line_config(ixp42x_scl_pin(data),
- val ? IXP425_GPIO_IN : IXP425_GPIO_OUT );
-}
-
-static void ixp42x_bit_setsda(void *data, int val)
-{
- gpio_line_set(ixp42x_sda_pin(data), 0);
- gpio_line_config(ixp42x_sda_pin(data),
- val ? IXP425_GPIO_IN : IXP425_GPIO_OUT );
-}
-
-static int ixp42x_bit_getscl(void *data)
-{
- int scl;
-
- gpio_line_config(ixp42x_scl_pin(data), IXP425_GPIO_IN );
- gpio_line_get(ixp42x_scl_pin(data), &scl);
-
- return scl;
-}
-
-static int ixp42x_bit_getsda(void *data)
-{
- int sda;
-
- gpio_line_config(ixp42x_sda_pin(data), IXP425_GPIO_IN );
- gpio_line_get(ixp42x_sda_pin(data), &sda);
-
- return sda;
-}
-
-struct ixp42x_i2c_data {
- struct ixp42x_i2c_pins *gpio_pins;
- struct i2c_adapter adapter;
- struct i2c_algo_bit_data algo_data;
-};
-
-static int ixp42x_i2c_remove(struct device *dev)
-{
- struct platform_device *plat_dev = to_platform_device(dev);
- struct ixp42x_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
-
- dev_set_drvdata(&plat_dev->dev, NULL);
-
- i2c_bit_del_bus(&drv_data->adapter);
-
- kfree(drv_data);
-
- return 0;
-}
-
-static int ixp42x_i2c_probe(struct device *dev)
-{
- int err;
- struct platform_device *plat_dev = to_platform_device(dev);
- struct ixp42x_i2c_pins *gpio = plat_dev->dev.platform_data;
- struct ixp42x_i2c_data *drv_data =
- kmalloc(sizeof(struct ixp42x_i2c_data), GFP_KERNEL);
-
- if(!drv_data)
- return -ENOMEM;
-
- memzero(drv_data, sizeof(struct ixp42x_i2c_data));
- drv_data->gpio_pins = gpio;
-
- /*
- * We could make a lot of these structures static, but
- * certain platforms may have multiple GPIO-based I2C
- * buses for various device domains, so we need per-device
- * algo_data->data.
- */
- drv_data->algo_data.data = gpio;
- drv_data->algo_data.setsda = ixp42x_bit_setsda;
- drv_data->algo_data.setscl = ixp42x_bit_setscl;
- drv_data->algo_data.getsda = ixp42x_bit_getsda;
- drv_data->algo_data.getscl = ixp42x_bit_getscl;
- drv_data->algo_data.udelay = 10;
- drv_data->algo_data.mdelay = 10;
- drv_data->algo_data.timeout = 100;
-
- drv_data->adapter.id = I2C_HW_B_IXP425,
- drv_data->adapter.algo_data = &drv_data->algo_data,
-
- drv_data->adapter.dev.parent = &plat_dev->dev;
-
- gpio_line_config(gpio->scl_pin, IXP425_GPIO_IN);
- gpio_line_config(gpio->sda_pin, IXP425_GPIO_IN);
- gpio_line_set(gpio->scl_pin, 0);
- gpio_line_set(gpio->sda_pin, 0);
-
- if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) {
- printk(KERN_ERR "ERROR: Could not install %s\n", dev->bus_id);
-
- kfree(drv_data);
- return err;
- }
-
- dev_set_drvdata(&plat_dev->dev, drv_data);
-
- return 0;
-}
-
-static struct device_driver ixp42x_i2c_driver = {
- .name = "IXP42X-I2C",
- .bus = &platform_bus_type,
- .probe = ixp42x_i2c_probe,
- .remove = ixp42x_i2c_remove,
-};
-
-static int __init ixp42x_i2c_init(void)
-{
- return driver_register(&ixp42x_i2c_driver);
-}
-
-static void __exit ixp42x_i2c_exit(void)
-{
- driver_unregister(&ixp42x_i2c_driver);
-}
-
-module_init(ixp42x_i2c_init);
-module_exit(ixp42x_i2c_exit);
-
-MODULE_DESCRIPTION("GPIO-based I2C driver for IXP42x systems");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
-
+++ /dev/null
-/*
- i2c-sensor.c - Part of lm_sensors, Linux kernel modules for hardware
- monitoring
- Copyright (c) 1998 - 2001 Frodo Looijaard <frodol@dds.nl> and
- Mark D. Studebaker <mdsxyz123@yahoo.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/ctype.h>
-#include <linux/sysctl.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/i2c.h>
-#include <linux/i2c-sensor.h>
-#include <asm/uaccess.h>
-
-
-/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */
-int i2c_detect(struct i2c_adapter *adapter,
- struct i2c_address_data *address_data,
- int (*found_proc) (struct i2c_adapter *, int, int))
-{
- int addr, i, found, j, err;
- struct i2c_force_data *this_force;
- int is_isa = i2c_is_isa_adapter(adapter);
- int adapter_id =
- is_isa ? ANY_I2C_ISA_BUS : i2c_adapter_id(adapter);
-
- /* Forget it if we can't probe using SMBUS_QUICK */
- if ((!is_isa) &&
- !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK))
- return -1;
-
- for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) {
- if (!is_isa && i2c_check_addr(adapter, addr))
- continue;
-
- /* If it is in one of the force entries, we don't do any
- detection at all */
- found = 0;
- for (i = 0; !found && (this_force = address_data->forces + i, this_force->force); i++) {
- for (j = 0; !found && (this_force->force[j] != I2C_CLIENT_END); j += 2) {
- if ( ((adapter_id == this_force->force[j]) ||
- ((this_force->force[j] == ANY_I2C_BUS) && !is_isa)) &&
- (addr == this_force->force[j + 1]) ) {
- dev_dbg(&adapter->dev, "found force parameter for adapter %d, addr %04x\n", adapter_id, addr);
- if ((err = found_proc(adapter, addr, this_force->kind)))
- return err;
- found = 1;
- }
- }
- }
- if (found)
- continue;
-
- /* If this address is in one of the ignores, we can forget about it
- right now */
- for (i = 0; !found && (address_data->ignore[i] != I2C_CLIENT_END); i += 2) {
- if ( ((adapter_id == address_data->ignore[i]) ||
- ((address_data->ignore[i] == ANY_I2C_BUS) &&
- !is_isa)) &&
- (addr == address_data->ignore[i + 1])) {
- dev_dbg(&adapter->dev, "found ignore parameter for adapter %d, addr %04x\n", adapter_id, addr);
- found = 1;
- }
- }
- for (i = 0; !found && (address_data->ignore_range[i] != I2C_CLIENT_END); i += 3) {
- if ( ((adapter_id == address_data->ignore_range[i]) ||
- ((address_data-> ignore_range[i] == ANY_I2C_BUS) &
- !is_isa)) &&
- (addr >= address_data->ignore_range[i + 1]) &&
- (addr <= address_data->ignore_range[i + 2])) {
- dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
- found = 1;
- }
- }
- if (found)
- continue;
-
- /* Now, we will do a detection, but only if it is in the normal or
- probe entries */
- if (is_isa) {
- for (i = 0; !found && (address_data->normal_isa[i] != I2C_CLIENT_ISA_END); i += 1) {
- if (addr == address_data->normal_isa[i]) {
- dev_dbg(&adapter->dev, "found normal isa entry for adapter %d, addr %04x\n", adapter_id, addr);
- found = 1;
- }
- }
- for (i = 0; !found && (address_data->normal_isa_range[i] != I2C_CLIENT_ISA_END); i += 3) {
- if ((addr >= address_data->normal_isa_range[i]) &&
- (addr <= address_data->normal_isa_range[i + 1]) &&
- ((addr - address_data->normal_isa_range[i]) % address_data->normal_isa_range[i + 2] == 0)) {
- dev_dbg(&adapter->dev, "found normal isa_range entry for adapter %d, addr %04x", adapter_id, addr);
- found = 1;
- }
- }
- } else {
- for (i = 0; !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); i += 1) {
- if (addr == address_data->normal_i2c[i]) {
- found = 1;
- dev_dbg(&adapter->dev, "found normal i2c entry for adapter %d, addr %02x", adapter_id, addr);
- }
- }
- for (i = 0; !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); i += 2) {
- if ((addr >= address_data->normal_i2c_range[i]) &&
- (addr <= address_data->normal_i2c_range[i + 1])) {
- dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, addr %04x\n", adapter_id, addr);
- found = 1;
- }
- }
- }
-
- for (i = 0;
- !found && (address_data->probe[i] != I2C_CLIENT_END);
- i += 2) {
- if (((adapter_id == address_data->probe[i]) ||
- ((address_data->
- probe[i] == ANY_I2C_BUS) && !is_isa))
- && (addr == address_data->probe[i + 1])) {
- dev_dbg(&adapter->dev, "found probe parameter for adapter %d, addr %04x\n", adapter_id, addr);
- found = 1;
- }
- }
- for (i = 0; !found && (address_data->probe_range[i] != I2C_CLIENT_END); i += 3) {
- if ( ((adapter_id == address_data->probe_range[i]) ||
- ((address_data->probe_range[i] == ANY_I2C_BUS) && !is_isa)) &&
- (addr >= address_data->probe_range[i + 1]) &&
- (addr <= address_data->probe_range[i + 2])) {
- found = 1;
- dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, addr %04x\n", adapter_id, addr);
- }
- }
- if (!found)
- continue;
-
- /* OK, so we really should examine this address. First check
- whether there is some client here at all! */
- if (is_isa ||
- (i2c_smbus_xfer (adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) >= 0))
- if ((err = found_proc(adapter, addr, -1)))
- return err;
- }
- return 0;
-}
-
-EXPORT_SYMBOL(i2c_detect);
-
-MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>");
-MODULE_DESCRIPTION("i2c-sensor driver");
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * Copyright (C) 2001, 2002 Jens Axboe <axboe@suse.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Support for the DMA queued protocol, which enables ATA disk drives to
- * use tagged command queueing.
- */
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-#include <asm/delay.h>
-
-/*
- * warning: it will be _very_ verbose if defined
- */
-#undef IDE_TCQ_DEBUG
-
-#ifdef IDE_TCQ_DEBUG
-#define TCQ_PRINTK printk
-#else
-#define TCQ_PRINTK(x...)
-#endif
-
-/*
- * use nIEN or not
- */
-#undef IDE_TCQ_NIEN
-
-/*
- * we are leaving the SERVICE interrupt alone, IBM drives have it
- * on per default and it can't be turned off. Doesn't matter, this
- * is the sane config.
- */
-#undef IDE_TCQ_FIDDLE_SI
-
-/*
- * bad drive blacklist, for drives that raport tcq capability but don't
- * work reliably with the default config. initially from freebsd table.
- */
-struct ide_tcq_blacklist {
- char *model;
- char works;
- unsigned int max_sectors;
-};
-
-static struct ide_tcq_blacklist ide_tcq_blacklist[] = {
- {
- .model = "IBM-DTTA",
- .works = 1,
- .max_sectors = 128,
- },
- {
- .model = "IBM-DJNA",
- .works = 0,
- },
- {
- .model = "WDC AC",
- .works = 0,
- },
- {
- .model = NULL,
- },
-};
-
-ide_startstop_t ide_dmaq_intr(ide_drive_t *drive);
-ide_startstop_t ide_service(ide_drive_t *drive);
-
-static struct ide_tcq_blacklist *ide_find_drive_blacklist(ide_drive_t *drive)
-{
- struct ide_tcq_blacklist *itb;
- int i = 0;
-
- do {
- itb = &ide_tcq_blacklist[i];
-
- if (!itb->model)
- break;
-
- if (!strncmp(drive->id->model, itb->model, strlen(itb->model)))
- return itb;
-
- i++;
- } while (1);
-
- return NULL;
-}
-
-static inline void drive_ctl_nien(ide_drive_t *drive, int set)
-{
-#ifdef IDE_TCQ_NIEN
- if (IDE_CONTROL_REG) {
- int mask = set ? 0x02 : 0x00;
-
- hwif->OUTB(drive->ctl | mask, IDE_CONTROL_REG);
- }
-#endif
-}
-
-static ide_startstop_t ide_tcq_nop_handler(ide_drive_t *drive)
-{
- ide_task_t *args = HWGROUP(drive)->rq->special;
- ide_hwif_t *hwif = HWIF(drive);
- int auto_poll_check = 0;
- u8 stat, err;
-
- if (args->tfRegister[IDE_FEATURE_OFFSET] & 0x01)
- auto_poll_check = 1;
-
- local_irq_enable();
-
- stat = hwif->INB(IDE_STATUS_REG);
- err = hwif->INB(IDE_ERROR_REG);
- ide_end_drive_cmd(drive, stat, err);
-
- /*
- * do taskfile and check ABRT bit -- intelligent adapters will not
- * pass NOP with sub-code 0x01 to device, so the command will not
- * fail there
- */
- if (auto_poll_check) {
- if (!(args->tfRegister[IDE_FEATURE_OFFSET] & ABRT_ERR)) {
- HWIF(drive)->auto_poll = 1;
- printk("%s: NOP Auto-poll enabled\n",HWIF(drive)->name);
- }
- }
-
- kfree(args);
- return ide_stopped;
-}
-
-/*
- * if we encounter _any_ error doing I/O to one of the tags, we must
- * invalidate the pending queue. clear the software busy queue and requeue
- * on the request queue for restart. issue a WIN_NOP to clear hardware queue
- */
-static void ide_tcq_invalidate_queue(ide_drive_t *drive)
-{
- ide_hwgroup_t *hwgroup = HWGROUP(drive);
- request_queue_t *q = drive->queue;
- struct request *rq;
- unsigned long flags;
-
- printk("%s: invalidating tag queue (%d commands)\n", drive->name, ata_pending_commands(drive));
-
- /*
- * first kill timer and block queue
- */
- spin_lock_irqsave(&ide_lock, flags);
-
- del_timer(&hwgroup->timer);
-
- if (HWIF(drive)->dma)
- HWIF(drive)->ide_dma_end(drive);
-
- blk_queue_invalidate_tags(q);
-
- drive->using_tcq = 0;
- drive->queue_depth = 1;
- hwgroup->busy = 0;
- hwgroup->handler = NULL;
-
- spin_unlock_irqrestore(&ide_lock, flags);
-
- /*
- * now kill hardware queue with a NOP
- */
- rq = &hwgroup->wrq;
- ide_init_drive_cmd(rq);
- rq->buffer = hwgroup->cmd_buf;
- memset(rq->buffer, 0, sizeof(hwgroup->cmd_buf));
- rq->buffer[0] = WIN_NOP;
- ide_do_drive_cmd(drive, rq, ide_preempt);
-}
-
-void ide_tcq_intr_timeout(unsigned long data)
-{
- ide_drive_t *drive = (ide_drive_t *) data;
- ide_hwgroup_t *hwgroup = HWGROUP(drive);
- ide_hwif_t *hwif = HWIF(drive);
- unsigned long flags;
-
- printk(KERN_ERR "ide_tcq_intr_timeout: timeout waiting for %s interrupt\n", hwgroup->rq ? "completion" : "service");
-
- spin_lock_irqsave(&ide_lock, flags);
-
- if (!hwgroup->busy)
- printk(KERN_ERR "ide_tcq_intr_timeout: hwgroup not busy\n");
- if (hwgroup->handler == NULL)
- printk(KERN_ERR "ide_tcq_intr_timeout: missing isr!\n");
-
- hwgroup->busy = 1;
- spin_unlock_irqrestore(&ide_lock, flags);
-
- /*
- * if pending commands, try service before giving up
- */
- if (ata_pending_commands(drive)) {
- u8 stat = hwif->INB(IDE_STATUS_REG);
-
- if ((stat & SRV_STAT) && (ide_service(drive) == ide_started))
- return;
- }
-
- if (drive)
- ide_tcq_invalidate_queue(drive);
-}
-
-void __ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
-{
- /*
- * always just bump the timer for now, the timeout handling will
- * have to be changed to be per-command
- */
- hwgroup->timer.function = ide_tcq_intr_timeout;
- hwgroup->timer.data = (unsigned long) hwgroup->drive;
- mod_timer(&hwgroup->timer, jiffies + 5 * HZ);
-
- hwgroup->handler = handler;
-}
-
-void ide_tcq_set_intr(ide_hwgroup_t *hwgroup, ide_handler_t *handler)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&ide_lock, flags);
- __ide_tcq_set_intr(hwgroup, handler);
- spin_unlock_irqrestore(&ide_lock, flags);
-}
-
-/*
- * wait 400ns, then poll for busy_mask to clear from alt status
- */
-#define IDE_TCQ_WAIT (10000)
-int ide_tcq_wait_altstat(ide_drive_t *drive, byte *stat, byte busy_mask)
-{
- ide_hwif_t *hwif = HWIF(drive);
- int i = 0;
-
- udelay(1);
-
- do {
- *stat = hwif->INB(IDE_ALTSTATUS_REG);
-
- if (!(*stat & busy_mask))
- break;
-
- if (unlikely(i++ > IDE_TCQ_WAIT))
- return 1;
-
- udelay(10);
- } while (1);
-
- return 0;
-}
-
-/*
- * issue SERVICE command to drive -- drive must have been selected first,
- * and it must have reported a need for service (status has SRV_STAT set)
- *
- * Also, nIEN must be set as not to need protection against ide_dmaq_intr
- */
-ide_startstop_t ide_service(ide_drive_t *drive)
-{
- ide_hwif_t *hwif = HWIF(drive);
- unsigned long flags;
- struct request *rq;
- byte feat, stat;
- int tag;
-
- TCQ_PRINTK("%s: started service\n", drive->name);
-
- /*
- * could be called with IDE_DMA in-progress from invalidate
- * handler, refuse to do anything
- */
- if (hwif->dma)
- return ide_stopped;
-
- /*
- * need to select the right drive first...
- */
- if (drive != HWGROUP(drive)->drive) {
- SELECT_DRIVE(drive);
- udelay(10);
- }
-
- drive_ctl_nien(drive, 1);
-
- /*
- * send SERVICE, wait 400ns, wait for BUSY_STAT to clear
- */
- hwif->OUTB(WIN_QUEUED_SERVICE, IDE_COMMAND_REG);
-
- if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
- printk(KERN_ERR "ide_service: BUSY clear took too long\n");
- ide_dump_status(drive, "ide_service", stat);
- ide_tcq_invalidate_queue(drive);
- return ide_stopped;
- }
-
- drive_ctl_nien(drive, 0);
-
- /*
- * FIXME, invalidate queue
- */
- if (stat & ERR_STAT) {
- ide_dump_status(drive, "ide_service", stat);
- ide_tcq_invalidate_queue(drive);
- return ide_stopped;
- }
-
- /*
- * should not happen, a buggy device could introduce loop
- */
- feat = hwif->INB(IDE_NSECTOR_REG);
- if (feat & REL) {
- HWGROUP(drive)->rq = NULL;
- printk(KERN_ERR "%s: release in service\n", drive->name);
- return ide_stopped;
- }
-
- tag = feat >> 3;
-
- TCQ_PRINTK("ide_service: stat %x, feat %x\n", stat, feat);
-
- spin_lock_irqsave(&ide_lock, flags);
-
- if ((rq = blk_queue_find_tag(drive->queue, tag))) {
- HWGROUP(drive)->rq = rq;
-
- /*
- * we'll start a dma read or write, device will trigger
- * interrupt to indicate end of transfer, release is not
- * allowed
- */
- TCQ_PRINTK("ide_service: starting command, stat=%x\n", stat);
- spin_unlock_irqrestore(&ide_lock, flags);
- return __ide_dma_queued_start(drive);
- }
-
- printk(KERN_ERR "ide_service: missing request for tag %d\n", tag);
- spin_unlock_irqrestore(&ide_lock, flags);
- return ide_stopped;
-}
-
-ide_startstop_t ide_check_service(ide_drive_t *drive)
-{
- ide_hwif_t *hwif = HWIF(drive);
- byte stat;
-
- TCQ_PRINTK("%s: ide_check_service\n", drive->name);
-
- if (!ata_pending_commands(drive))
- return ide_stopped;
-
- stat = hwif->INB(IDE_STATUS_REG);
- if (stat & SRV_STAT)
- return ide_service(drive);
-
- /*
- * we have pending commands, wait for interrupt
- */
- TCQ_PRINTK("%s: wait for service interrupt\n", drive->name);
- ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
- return ide_started;
-}
-
-ide_startstop_t ide_dmaq_complete(ide_drive_t *drive, struct request *rq, byte stat)
-{
- byte dma_stat;
-
- /*
- * transfer was in progress, stop DMA engine
- */
- dma_stat = HWIF(drive)->ide_dma_end(drive);
-
- /*
- * must be end of I/O, check status and complete as necessary
- */
- if (unlikely(!OK_STAT(stat, READY_STAT, drive->bad_wstat | DRQ_STAT))) {
- printk(KERN_ERR "ide_dmaq_intr: %s: error status %x\n",drive->name,stat);
- ide_dump_status(drive, "ide_dmaq_complete", stat);
- ide_tcq_invalidate_queue(drive);
- return ide_stopped;
- }
-
- if (dma_stat)
- printk(KERN_WARNING "%s: bad DMA status (dma_stat=%x)\n", drive->name, dma_stat);
-
- TCQ_PRINTK("ide_dmaq_complete: ending %p, tag %d\n", rq, rq->tag);
- ide_end_request(drive, 1, rq->nr_sectors);
-
- /*
- * we completed this command, check if we can service a new command
- */
- return ide_check_service(drive);
-}
-
-/*
- * intr handler for queued dma operations. this can be entered for two
- * reasons:
- *
- * 1) device has completed dma transfer
- * 2) service request to start a command
- *
- * if the drive has an active tag, we first complete that request before
- * processing any pending SERVICE.
- */
-ide_startstop_t ide_dmaq_intr(ide_drive_t *drive)
-{
- struct request *rq = HWGROUP(drive)->rq;
- ide_hwif_t *hwif = HWIF(drive);
- byte stat = hwif->INB(IDE_STATUS_REG);
-
- TCQ_PRINTK("ide_dmaq_intr: stat=%x\n", stat);
-
- /*
- * if a command completion interrupt is pending, do that first and
- * check service afterwards
- */
- if (rq) {
- TCQ_PRINTK("ide_dmaq_intr: completion\n");
- return ide_dmaq_complete(drive, rq, stat);
- }
-
- /*
- * service interrupt
- */
- if (stat & SRV_STAT) {
- TCQ_PRINTK("ide_dmaq_intr: SERV (stat=%x)\n", stat);
- return ide_service(drive);
- }
-
- printk("ide_dmaq_intr: stat=%x, not expected\n", stat);
- return ide_check_service(drive);
-}
-
-/*
- * check if the ata adapter this drive is attached to supports the
- * NOP auto-poll for multiple tcq enabled drives on one channel
- */
-static int ide_tcq_check_autopoll(ide_drive_t *drive)
-{
- ide_task_t *args;
- int i, drives;
-
- /*
- * only need to probe if both drives on a channel support tcq
- */
- for (i = 0, drives = 0; i < MAX_DRIVES; i++)
- if (HWIF(drive)->drives[i].present && drive->media == ide_disk)
- drives++;
-
- if (drives <= 1)
- return 0;
-
- /*
- * what a mess...
- */
- args = kmalloc(sizeof(*args), GFP_ATOMIC);
- if (!args)
- return 1;
-
- memset(args, 0, sizeof(*args));
-
- args->tfRegister[IDE_FEATURE_OFFSET] = 0x01;
- args->tfRegister[IDE_COMMAND_OFFSET] = WIN_NOP;
- args->command_type = IDE_DRIVE_TASK_NO_DATA;
- args->handler = ide_tcq_nop_handler;
- return ide_raw_taskfile(drive, args, NULL);
-}
-
-/*
- * configure the drive for tcq
- */
-static int ide_tcq_configure(ide_drive_t *drive)
-{
- int tcq_mask = 1 << 1 | 1 << 14;
- int tcq_bits = tcq_mask | 1 << 15;
- ide_task_t *args;
-
- /*
- * bit 14 and 1 must be set in word 83 of the device id to indicate
- * support for dma queued protocol, and bit 15 must be cleared
- */
- if ((drive->id->command_set_2 & tcq_bits) ^ tcq_mask) {
- printk(KERN_INFO "%s: TCQ not supported\n", drive->name);
- return -EIO;
- }
-
- args = kmalloc(sizeof(*args), GFP_ATOMIC);
- if (!args)
- return -ENOMEM;
-
- memset(args, 0, sizeof(ide_task_t));
- args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
- args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_WCACHE;
- args->command_type = IDE_DRIVE_TASK_NO_DATA;
- args->handler = &task_no_data_intr;
-
- if (ide_raw_taskfile(drive, args, NULL)) {
- printk(KERN_WARNING "%s: failed to enable write cache\n", drive->name);
- goto err;
- }
-
- /*
- * disable RELease interrupt, it's quicker to poll this after
- * having sent the command opcode
- */
- memset(args, 0, sizeof(ide_task_t));
- args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
- args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_DIS_RI;
- args->command_type = IDE_DRIVE_TASK_NO_DATA;
- args->handler = &task_no_data_intr;
-
- if (ide_raw_taskfile(drive, args, NULL)) {
- printk(KERN_ERR "%s: disabling release interrupt fail\n", drive->name);
- goto err;
- }
-
-#ifdef IDE_TCQ_FIDDLE_SI
- /*
- * enable SERVICE interrupt
- */
- memset(args, 0, sizeof(ide_task_t));
- args->tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
- args->tfRegister[IDE_FEATURE_OFFSET] = SETFEATURES_EN_SI;
- args->command_type = IDE_DRIVE_TASK_NO_DATA;
- args->handler = &task_no_data_intr;
-
- if (ide_raw_taskfile(drive, args, NULL)) {
- printk(KERN_ERR "%s: enabling service interrupt fail\n", drive->name);
- goto err;
- }
-#endif
-
- kfree(args);
- return 0;
-err:
- kfree(args);
- return -EIO;
-}
-
-/*
- * for now assume that command list is always as big as we need and don't
- * attempt to shrink it on tcq disable
- */
-static int ide_enable_queued(ide_drive_t *drive, int on)
-{
- struct ide_tcq_blacklist *itb;
- int depth = drive->using_tcq ? drive->queue_depth : 0;
-
- /*
- * disable or adjust queue depth
- */
- if (!on) {
- if (drive->using_tcq)
- printk(KERN_INFO "%s: TCQ disabled\n", drive->name);
-
- drive->using_tcq = 0;
- return 0;
- }
-
- if (ide_tcq_configure(drive)) {
- drive->using_tcq = 0;
- return 1;
- }
-
- /*
- * some drives need limited transfer size in tcq
- */
- itb = ide_find_drive_blacklist(drive);
- if (itb && itb->max_sectors) {
- if (itb->max_sectors > HWIF(drive)->rqsize)
- itb->max_sectors = HWIF(drive)->rqsize;
-
- blk_queue_max_sectors(drive->queue, itb->max_sectors);
- }
-
- /*
- * enable block tagging
- */
- if (!blk_queue_tagged(drive->queue))
- blk_queue_init_tags(drive->queue, IDE_MAX_TAG, NULL);
-
- /*
- * check auto-poll support
- */
- ide_tcq_check_autopoll(drive);
-
- if (depth != drive->queue_depth)
- printk(KERN_INFO "%s: tagged command queueing enabled, command queue depth %d\n", drive->name, drive->queue_depth);
-
- drive->using_tcq = 1;
- return 0;
-}
-
-int ide_tcq_wait_dataphase(ide_drive_t *drive)
-{
- ide_hwif_t *hwif = HWIF(drive);
- byte stat;
- int i;
-
- do {
- stat = hwif->INB(IDE_STATUS_REG);
- if (!(stat & BUSY_STAT))
- break;
-
- udelay(10);
- } while (1);
-
- if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
- return 0;
-
- i = 0;
- udelay(1);
- do {
- stat = hwif->INB(IDE_STATUS_REG);
-
- if (OK_STAT(stat, READY_STAT | DRQ_STAT, drive->bad_wstat))
- break;
-
- ++i;
- if (unlikely(i >= IDE_TCQ_WAIT))
- return 1;
-
- udelay(10);
- } while (1);
-
- return 0;
-}
-
-static int ide_tcq_check_blacklist(ide_drive_t *drive)
-{
- struct ide_tcq_blacklist *itb = ide_find_drive_blacklist(drive);
-
- if (!itb)
- return 0;
-
- return !itb->works;
-}
-
-int __ide_dma_queued_on(ide_drive_t *drive)
-{
- ide_hwif_t *hwif = HWIF(drive);
-
- if (drive->media != ide_disk)
- return 1;
- if (!drive->using_dma)
- return 1;
- if (hwif->chipset == ide_pdc4030)
- return 1;
- if (ide_tcq_check_blacklist(drive)) {
- printk(KERN_WARNING "%s: tcq forbidden by blacklist\n",
- drive->name);
- return 1;
- }
- if (hwif->drives[0].present && hwif->drives[1].present) {
- printk(KERN_WARNING "%s: only one drive on a channel supported"
- " for tcq\n", drive->name);
- return 1;
- }
- if (ata_pending_commands(drive)) {
- printk(KERN_WARNING "ide-tcq; can't toggle tcq feature on "
- "busy drive\n");
- return 1;
- }
-
- return ide_enable_queued(drive, 1);
-}
-
-int __ide_dma_queued_off(ide_drive_t *drive)
-{
- if (drive->media != ide_disk)
- return 1;
- if (ata_pending_commands(drive)) {
- printk("ide-tcq; can't toggle tcq feature on busy drive\n");
- return 1;
- }
-
- return ide_enable_queued(drive, 0);
-}
-
-static ide_startstop_t ide_dma_queued_rw(ide_drive_t *drive, u8 command)
-{
- ide_hwif_t *hwif = HWIF(drive);
- unsigned long flags;
- byte stat, feat;
-
- TCQ_PRINTK("%s: starting tag\n", drive->name);
-
- /*
- * set nIEN, tag start operation will enable again when
- * it is safe
- */
- drive_ctl_nien(drive, 1);
-
- TCQ_PRINTK("%s: sending cmd=%x\n", drive->name, command);
- hwif->OUTB(command, IDE_COMMAND_REG);
-
- if (ide_tcq_wait_altstat(drive, &stat, BUSY_STAT)) {
- printk("%s: alt stat timeout\n", drive->name);
- goto err;
- }
-
- drive_ctl_nien(drive, 0);
-
- if (stat & ERR_STAT)
- goto err;
-
- /*
- * bus not released, start dma
- */
- feat = hwif->INB(IDE_NSECTOR_REG);
- if (!(feat & REL)) {
- TCQ_PRINTK("IMMED in queued_start, feat=%x\n", feat);
- return __ide_dma_queued_start(drive);
- }
-
- /*
- * drive released the bus, clear active request and check for service
- */
- spin_lock_irqsave(&ide_lock, flags);
- HWGROUP(drive)->rq = NULL;
- __ide_tcq_set_intr(HWGROUP(drive), ide_dmaq_intr);
- spin_unlock_irqrestore(&ide_lock, flags);
-
- TCQ_PRINTK("REL in queued_start\n");
-
- stat = hwif->INB(IDE_STATUS_REG);
- if (stat & SRV_STAT)
- return ide_service(drive);
-
- return ide_released;
-err:
- ide_dump_status(drive, "rw_queued", stat);
- ide_tcq_invalidate_queue(drive);
- return ide_stopped;
-}
-
-ide_startstop_t __ide_dma_queued_read(ide_drive_t *drive)
-{
- u8 command = WIN_READDMA_QUEUED;
-
- if (drive->addressing == 1)
- command = WIN_READDMA_QUEUED_EXT;
-
- return ide_dma_queued_rw(drive, command);
-}
-
-ide_startstop_t __ide_dma_queued_write(ide_drive_t *drive)
-{
- u8 command = WIN_WRITEDMA_QUEUED;
-
- if (drive->addressing == 1)
- command = WIN_WRITEDMA_QUEUED_EXT;
-
- return ide_dma_queued_rw(drive, command);
-}
-
-ide_startstop_t __ide_dma_queued_start(ide_drive_t *drive)
-{
- ide_hwgroup_t *hwgroup = HWGROUP(drive);
- struct request *rq = hwgroup->rq;
- ide_hwif_t *hwif = HWIF(drive);
- unsigned int reading = 0;
-
- TCQ_PRINTK("ide_dma: setting up queued tag=%d\n", rq->tag);
-
- if (!hwgroup->busy)
- printk(KERN_ERR "queued_rw: hwgroup not busy\n");
-
- if (ide_tcq_wait_dataphase(drive)) {
- printk(KERN_WARNING "timeout waiting for data phase\n");
- return ide_stopped;
- }
-
- if (rq_data_dir(rq) == READ)
- reading = 1 << 3;
-
- if (ide_start_dma(hwif, drive, reading))
- return ide_stopped;
-
- ide_tcq_set_intr(hwgroup, ide_dmaq_intr);
-
- if (!hwif->ide_dma_begin(drive))
- return ide_started;
-
- return ide_stopped;
-}
+++ /dev/null
-/*
- * Copyright (C) 1991, 1992 Linus Torvalds
- *
- * This is the low-level hd interrupt support. It traverses the
- * request-list, using interrupts to jump between functions. As
- * all the functions are called within interrupts, we may not
- * sleep. Special care is recommended.
- *
- * modified by Drew Eckhardt to check nr of hd's from the CMOS.
- *
- * Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug
- * in the early extended-partition checks and added DM partitions
- *
- * IRQ-unmask, drive-id, multiple-mode, support for ">16 heads",
- * and general streamlining by Mark Lord.
- *
- * Removed 99% of above. Use Mark's ide driver for those options.
- * This is now a lightweight ST-506 driver. (Paul Gortmaker)
- *
- * Modified 1995 Russell King for ARM processor.
- *
- * Bugfix: max_sectors must be <= 255 or the wheels tend to come
- * off in a hurry once you queue things up - Paul G. 02/2001
- */
-
-/* Uncomment the following if you want verbose error reports. */
-/* #define VERBOSE_ERRORS */
-
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/genhd.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/ioport.h>
-#include <linux/mc146818rtc.h> /* CMOS defines */
-#include <linux/init.h>
-#include <linux/blkpg.h>
-#include <linux/hdreg.h>
-
-#define REALLY_SLOW_IO
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#include "io_ports.h"
-
-#ifdef __arm__
-#undef HD_IRQ
-#endif
-#include <asm/irq.h>
-#ifdef __arm__
-#define HD_IRQ IRQ_HARDDISK
-#endif
-
-/* Hd controller regster ports */
-
-#define HD_DATA 0x640 /* _CTL when writing */
-#define HD_ERROR 0x642 /* see err-bits */
-#define HD_NSECTOR 0x644 /* nr of sectors to read/write */
-#define HD_SECTOR 0x646 /* starting sector */
-#define HD_LCYL 0x648 /* starting cylinder */
-#define HD_HCYL 0x64a /* high byte of starting cyl */
-#define HD_CURRENT 0x64c /* 101dhhhh , d=drive, hhhh=head */
-#define HD_STATUS 0x64e /* see status-bits */
-#define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */
-#define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */
-#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */
-
-#define HD_CMD 0x74c /* used for resets */
-#define HD_ALTSTATUS 0x74c /* same as HD_STATUS but doesn't clear irq */
-
-/* Bits of HD_STATUS */
-#define ERR_STAT 0x01
-#define INDEX_STAT 0x02
-#define ECC_STAT 0x04 /* Corrected error */
-#define DRQ_STAT 0x08
-#define SEEK_STAT 0x10
-#define SERVICE_STAT SEEK_STAT
-#define WRERR_STAT 0x20
-#define READY_STAT 0x40
-#define BUSY_STAT 0x80
-
-/* Bits for HD_ERROR */
-#define MARK_ERR 0x01 /* Bad address mark */
-#define TRK0_ERR 0x02 /* couldn't find track 0 */
-#define ABRT_ERR 0x04 /* Command aborted */
-#define MCR_ERR 0x08 /* media change request */
-#define ID_ERR 0x10 /* ID field not found */
-#define MC_ERR 0x20 /* media changed */
-#define ECC_ERR 0x40 /* Uncorrectable ECC error */
-#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
-#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
-
-static spinlock_t hd_lock = SPIN_LOCK_UNLOCKED;
-static struct request_queue *hd_queue;
-
-#define CURRENT elv_next_request(hd_queue)
-
-#define TIMEOUT_VALUE (6*HZ)
-#define HD_DELAY 0
-
-#define MAX_ERRORS 16 /* Max read/write errors/sector */
-#define RESET_FREQ 8 /* Reset controller every 8th retry */
-#define RECAL_FREQ 4 /* Recalibrate every 4th retry */
-#define MAX_HD 2
-
-#define STAT_OK (READY_STAT|SEEK_STAT)
-#define OK_STATUS(s) (((s)&(STAT_OK|(BUSY_STAT|WRERR_STAT|ERR_STAT)))==STAT_OK)
-
-static void recal_intr(void);
-static void bad_rw_intr(void);
-
-static int reset;
-static int hd_error;
-
-/*
- * This struct defines the HD's and their types.
- */
-struct hd_i_struct {
- unsigned int head,sect,cyl,wpcom,lzone,ctl;
- int unit;
- int recalibrate;
- int special_op;
-};
-
-#ifdef HD_TYPE
-static struct hd_i_struct hd_info[] = { HD_TYPE };
-static int NR_HD = ((sizeof (hd_info))/(sizeof (struct hd_i_struct)));
-#else
-static struct hd_i_struct hd_info[MAX_HD];
-static int NR_HD;
-#endif
-
-static struct gendisk *hd_gendisk[MAX_HD];
-
-static struct timer_list device_timer;
-
-#define TIMEOUT_VALUE (6*HZ)
-
-#define SET_TIMER \
- do { \
- mod_timer(&device_timer, jiffies + TIMEOUT_VALUE); \
- } while (0)
-
-static void (*do_hd)(void) = NULL;
-#define SET_HANDLER(x) \
-if ((do_hd = (x)) != NULL) \
- SET_TIMER; \
-else \
- del_timer(&device_timer);
-
-
-#if (HD_DELAY > 0)
-unsigned long last_req;
-
-unsigned long read_timer(void)
-{
- extern spinlock_t i8253_lock;
- unsigned long t, flags;
- int i;
-
- spin_lock_irqsave(&i8253_lock, flags);
- t = jiffies * 11932;
- outb_p(0, PIT_MODE);
- i = inb_p(PIT_CH0);
- i |= inb(PIT_CH0) << 8;
- spin_unlock_irqrestore(&i8253_lock, flags);
- return(t - i);
-}
-#endif
-
-void __init hd_setup(char *str, int *ints)
-{
- int hdind = 0;
-
- if (ints[0] != 3)
- return;
- if (hd_info[0].head != 0)
- hdind=1;
- hd_info[hdind].head = ints[2];
- hd_info[hdind].sect = ints[3];
- hd_info[hdind].cyl = ints[1];
- hd_info[hdind].wpcom = 0;
- hd_info[hdind].lzone = ints[1];
- hd_info[hdind].ctl = (ints[2] > 8 ? 8 : 0);
- NR_HD = hdind+1;
-}
-
-static void dump_status (const char *msg, unsigned int stat)
-{
- char *name = CURRENT ?
- CURRENT->rq_dev->bd_disk->disk_name :
- "hd?";
-#ifdef VERBOSE_ERRORS
- printk("%s: %s: status=0x%02x { ", name, msg, stat & 0xff);
- if (stat & BUSY_STAT) printk("Busy ");
- if (stat & READY_STAT) printk("DriveReady ");
- if (stat & WRERR_STAT) printk("WriteFault ");
- if (stat & SEEK_STAT) printk("SeekComplete ");
- if (stat & DRQ_STAT) printk("DataRequest ");
- if (stat & ECC_STAT) printk("CorrectedError ");
- if (stat & INDEX_STAT) printk("Index ");
- if (stat & ERR_STAT) printk("Error ");
- printk("}\n");
- if ((stat & ERR_STAT) == 0) {
- hd_error = 0;
- } else {
- hd_error = inb(HD_ERROR);
- printk("%s: %s: error=0x%02x { ", name, msg, hd_error & 0xff);
- if (hd_error & BBD_ERR) printk("BadSector ");
- if (hd_error & ECC_ERR) printk("UncorrectableError ");
- if (hd_error & ID_ERR) printk("SectorIdNotFound ");
- if (hd_error & ABRT_ERR) printk("DriveStatusError ");
- if (hd_error & TRK0_ERR) printk("TrackZeroNotFound ");
- if (hd_error & MARK_ERR) printk("AddrMarkNotFound ");
- printk("}");
- if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) {
- printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL),
- inb(HD_CURRENT) & 0xf, inb(HD_SECTOR));
- if (CURRENT)
- printk(", sector=%ld", CURRENT->sector);
- }
- printk("\n");
- }
-#else
- printk("%s: %s: status=0x%02x.\n", name, msg, stat & 0xff);
- if ((stat & ERR_STAT) == 0) {
- hd_error = 0;
- } else {
- hd_error = inb(HD_ERROR);
- printk("%s: %s: error=0x%02x.\n", name, msg, hd_error & 0xff);
- }
-#endif
-}
-
-void check_status(void)
-{
- int i = inb(HD_STATUS);
-
- if (!OK_STATUS(i)) {
- dump_status("check_status", i);
- bad_rw_intr();
- }
-}
-
-static int controller_busy(void)
-{
- int retries = 100000;
- unsigned char status;
-
- do {
- status = inb(HD_STATUS);
- } while ((status & BUSY_STAT) && --retries);
- return status;
-}
-
-static int status_ok(void)
-{
- unsigned char status = inb(HD_STATUS);
-
- if (status & BUSY_STAT)
- return 1; /* Ancient, but does it make sense??? */
- if (status & WRERR_STAT)
- return 0;
- if (!(status & READY_STAT))
- return 0;
- if (!(status & SEEK_STAT))
- return 0;
- return 1;
-}
-
-static int controller_ready(unsigned int drive, unsigned int head)
-{
- int retry = 100;
-
- do {
- if (controller_busy() & BUSY_STAT)
- return 0;
- outb(0xA0 | (drive<<4) | head, HD_CURRENT);
- if (status_ok())
- return 1;
- } while (--retry);
- return 0;
-}
-
-static void hd_out(struct hd_i_struct *disk,
- unsigned int nsect,
- unsigned int sect,
- unsigned int head,
- unsigned int cyl,
- unsigned int cmd,
- void (*intr_addr)(void))
-{
- unsigned short port;
-
-#if (HD_DELAY > 0)
- while (read_timer() - last_req < HD_DELAY)
- /* nothing */;
-#endif
- if (reset)
- return;
- if (!controller_ready(disk->unit, head)) {
- reset = 1;
- return;
- }
- SET_HANDLER(intr_addr);
- outb(disk->ctl,HD_CMD);
- port=HD_DATA + 2;
- outb(disk->wpcom>>2, port); port += 2;
- outb(nsect, port); port += 2;
- outb(sect, port); port += 2;
- outb(cyl, port); port += 2;
- outb(cyl>>8, port); port += 2;
- outb(0xA0|(disk->unit<<4)|head, port); port += 2;
- outb(cmd, port);
-}
-
-static void hd_request (void);
-
-static int drive_busy(void)
-{
- unsigned int i;
- unsigned char c;
-
- for (i = 0; i < 500000 ; i++) {
- c = inb(HD_STATUS);
- if ((c & (BUSY_STAT | READY_STAT | SEEK_STAT)) == STAT_OK)
- return 0;
- }
- dump_status("reset timed out", c);
- return 1;
-}
-
-static void reset_controller(void)
-{
- int i;
-
- outb(4,HD_CMD);
- for(i = 0; i < 1000; i++) barrier();
- outb(hd_info[0].ctl & 0x0f,HD_CMD);
- for(i = 0; i < 1000; i++) barrier();
- if (drive_busy())
- printk("hd: controller still busy\n");
- else if ((hd_error = inb(HD_ERROR)) != 1)
- printk("hd: controller reset failed: %02x\n",hd_error);
-}
-
-static void reset_hd(void)
-{
- static int i;
-
-repeat:
- if (reset) {
- reset = 0;
- i = -1;
- reset_controller();
- } else {
- check_status();
- if (reset)
- goto repeat;
- }
- if (++i < NR_HD) {
- struct hd_i_struct *disk = &hd_info[i];
- disk->special_op = disk->recalibrate = 1;
- hd_out(disk, disk->sect, disk->sect, disk->head-1,
- disk->cyl, WIN_SPECIFY, &reset_hd);
- if (reset)
- goto repeat;
- } else
- hd_request();
-}
-
-/*
- * Ok, don't know what to do with the unexpected interrupts: on some machines
- * doing a reset and a retry seems to result in an eternal loop. Right now I
- * ignore it, and just set the timeout.
- *
- * On laptops (and "green" PCs), an unexpected interrupt occurs whenever the
- * drive enters "idle", "standby", or "sleep" mode, so if the status looks
- * "good", we just ignore the interrupt completely.
- */
-void unexpected_hd_interrupt(void)
-{
- unsigned int stat = inb(HD_STATUS);
-
- if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) {
- dump_status ("unexpected interrupt", stat);
- SET_TIMER;
- }
-}
-
-/*
- * bad_rw_intr() now tries to be a bit smarter and does things
- * according to the error returned by the controller.
- * -Mika Liljeberg (liljeber@cs.Helsinki.FI)
- */
-static void bad_rw_intr(void)
-{
- struct request *req = CURRENT;
- struct hd_i_struct *disk;
-
- if (!req)
- return;
- disk = req->rq_disk->private_data;
- if (++req->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) {
- end_request(req, 0);
- disk->special_op = disk->recalibrate = 1;
- } else if (req->errors % RESET_FREQ == 0)
- reset = 1;
- else if ((hd_error & TRK0_ERR) || req->errors % RECAL_FREQ == 0)
- disk->special_op = disk->recalibrate = 1;
- /* Otherwise just retry */
-}
-
-static inline int wait_DRQ(void)
-{
- int retries = 100000, stat;
-
- while (--retries > 0)
- if ((stat = inb(HD_STATUS)) & DRQ_STAT)
- return 0;
- dump_status("wait_DRQ", stat);
- return -1;
-}
-
-static void read_intr(void)
-{
- int i, retries = 100000;
- struct request *req;
-
- do {
- i = (unsigned) inb(HD_STATUS);
- if (i & BUSY_STAT)
- continue;
- if (!OK_STATUS(i))
- break;
- if (i & DRQ_STAT)
- goto ok_to_read;
- } while (--retries > 0);
- dump_status("read_intr", i);
- bad_rw_intr();
- hd_request();
- return;
-ok_to_read:
- req = CURRENT;
- insw(HD_DATA,req->buffer,256);
- req->sector++;
- req->buffer += 512;
- req->errors = 0;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
-#ifdef DEBUG
- printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
- req->rq_disk->disk_name, req->sector, req->nr_sectors,
- req->buffer+512);
-#endif
- if (req->current_nr_sectors <= 0)
- end_request(req, 1);
- if (i > 0) {
- SET_HANDLER(&read_intr);
- return;
- }
- (void) inb(HD_STATUS);
-#if (HD_DELAY > 0)
- last_req = read_timer();
-#endif
- if (CURRENT)
- hd_request();
- return;
-}
-
-static void write_intr(void)
-{
- int i;
- int retries = 100000;
- struct request *req = CURRENT;
-
- do {
- i = (unsigned) inb(HD_STATUS);
- if (i & BUSY_STAT)
- continue;
- if (!OK_STATUS(i))
- break;
- if ((req->nr_sectors <= 1) || (i & DRQ_STAT))
- goto ok_to_write;
- } while (--retries > 0);
- dump_status("write_intr", i);
- bad_rw_intr();
- hd_request();
- return;
-ok_to_write:
- req->sector++;
- i = --req->nr_sectors;
- --req->current_nr_sectors;
- req->buffer += 512;
- if (!i || (req->bio && req->current_nr_sectors < 1))
- end_request(req, 1);
- if (i > 0) {
- SET_HANDLER(&write_intr);
- outsw(HD_DATA,req->buffer,256);
- local_irq_enable();
- } else {
-#if (HD_DELAY > 0)
- last_req = read_timer();
-#endif
- hd_request();
- }
- return;
-}
-
-static void recal_intr(void)
-{
- check_status();
-#if (HD_DELAY > 0)
- last_req = read_timer();
-#endif
- hd_request();
-}
-
-/*
- * This is another of the error-routines I don't know what to do with. The
- * best idea seems to just set reset, and start all over again.
- */
-static void hd_times_out(unsigned long dummy)
-{
- do_hd = NULL;
-
- if (!CURRENT)
- return;
-
- disable_irq(HD_IRQ);
- local_irq_enable();
- reset = 1;
- printk("%s: timeout\n", CURRENT->rq_disk->disk_name);
- if (++CURRENT->errors >= MAX_ERRORS) {
-#ifdef DEBUG
- printk("%s: too many errors\n", CURRENT->rq_disk->disk_name);
-#endif
- end_request(CURRENT, 0);
- }
- local_irq_disable();
- hd_request();
- enable_irq(HD_IRQ);
-}
-
-int do_special_op(struct hd_i_struct *disk, struct request *req)
-{
- if (disk->recalibrate) {
- disk->recalibrate = 0;
- hd_out(disk, disk->sect,0,0,0,WIN_RESTORE,&recal_intr);
- return reset;
- }
- if (disk->head > 16) {
- printk ("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name);
- end_request(req, 0);
- }
- disk->special_op = 0;
- return 1;
-}
-
-/*
- * The driver enables interrupts as much as possible. In order to do this,
- * (a) the device-interrupt is disabled before entering hd_request(),
- * and (b) the timeout-interrupt is disabled before the sti().
- *
- * Interrupts are still masked (by default) whenever we are exchanging
- * data/cmds with a drive, because some drives seem to have very poor
- * tolerance for latency during I/O. The IDE driver has support to unmask
- * interrupts for non-broken hardware, so use that driver if required.
- */
-static void hd_request(void)
-{
- unsigned int block, nsect, sec, track, head, cyl;
- struct hd_i_struct *disk;
- struct request *req;
-
- if (do_hd)
- return;
-repeat:
- del_timer(&device_timer);
- local_irq_enable();
-
- if (!CURRENT) {
- do_hd = NULL;
- return;
- }
- req = CURRENT;
-
- if (reset) {
- local_irq_disable();
- reset_hd();
- return;
- }
- disk = req->rq_disk->private_data;
- block = req->sector;
- nsect = req->nr_sectors;
- if (block >= get_capacity(req->rq_disk) ||
- ((block+nsect) > get_capacity(req->rq_disk))) {
- printk("%s: bad access: block=%d, count=%d\n",
- req->rq_disk->disk_name, block, nsect);
- end_request(req, 0);
- goto repeat;
- }
-
- if (disk->special_op) {
- if (do_special_op(disk, req))
- goto repeat;
- return;
- }
- sec = block % disk->sect + 1;
- track = block / disk->sect;
- head = track % disk->head;
- cyl = track / disk->head;
-#ifdef DEBUG
- printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n",
- req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ",
- cyl, head, sec, nsect, req->buffer);
-#endif
- if (req->flags & REQ_CMD) {
- switch (rq_data_dir(req)) {
- case READ:
- hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr);
- if (reset)
- goto repeat;
- break;
- case WRITE:
- hd_out(disk,nsect,sec,head,cyl,WIN_WRITE,&write_intr);
- if (reset)
- goto repeat;
- if (wait_DRQ()) {
- bad_rw_intr();
- goto repeat;
- }
- outsw(HD_DATA,req->buffer,256);
- break;
- default:
- printk("unknown hd-command\n");
- end_request(req, 0);
- break;
- }
- }
-}
-
-static void do_hd_request (request_queue_t * q)
-{
- disable_irq(HD_IRQ);
- hd_request();
- enable_irq(HD_IRQ);
-}
-
-static int hd_ioctl(struct inode * inode, struct file * file,
- unsigned int cmd, unsigned long arg)
-{
- struct hd_i_struct *disk = inode->i_bdev->bd_disk->private_data;
- struct hd_geometry *loc = (struct hd_geometry *) arg;
- struct hd_geometry g;
-
- if (cmd != HDIO_GETGEO)
- return -EINVAL;
- if (!loc)
- return -EINVAL;
- g.heads = disk->head;
- g.sectors = disk->sect;
- g.cylinders = disk->cyl;
- g.start = get_start_sect(inode->i_bdev);
- return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0;
-}
-
-/*
- * Releasing a block device means we sync() it, so that it can safely
- * be forgotten about...
- */
-
-static void hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- void (*handler)(void) = do_hd;
-
- do_hd = NULL;
- del_timer(&device_timer);
- if (!handler)
- handler = unexpected_hd_interrupt;
- handler();
- local_irq_enable();
-}
-
-static struct block_device_operations hd_fops = {
- .ioctl = hd_ioctl,
-};
-
-/*
- * This is the hard disk IRQ description. The SA_INTERRUPT in sa_flags
- * means we run the IRQ-handler with interrupts disabled: this is bad for
- * interrupt latency, but anything else has led to problems on some
- * machines.
- *
- * We enable interrupts in some of the routines after making sure it's
- * safe.
- */
-
-static int __init hd_init(void)
-{
- int drive;
- if (register_blkdev(HD_MAJOR,"hd")) {
- printk("hd: unable to get major %d for hard disk\n",HD_MAJOR);
- return -1;
- }
- hd_queue = blk_init_queue(do_hd_request, &hd_lock);
- if (!hd_queue) {
- unregister_blkdev(HD_MAJOR,"hd");
- return -1;
- }
- blk_queue_max_sectors(hd_queue, 255);
- init_timer(&device_timer);
- device_timer.function = hd_times_out;
- blk_queue_hardsect_size(hd_queue, 512);
-
-#ifdef __i386__
- if (!NR_HD) {
- extern struct drive_info drive_info;
- unsigned char *BIOS = (unsigned char *) &drive_info;
- unsigned long flags;
-#ifndef CONFIG_X86_PC9800
- int cmos_disks;
-#endif
-
- for (drive=0 ; drive<2 ; drive++) {
- hd_info[drive].cyl = *(unsigned short *) BIOS;
- hd_info[drive].head = *(3+BIOS);
- hd_info[drive].sect = *(2+BIOS);
- hd_info[drive].wpcom = 0;
- hd_info[drive].ctl = *(3+BIOS) > 8 ? 8 : 0;
- hd_info[drive].lzone = *(unsigned short *) BIOS;
- if (hd_info[drive].cyl && NR_HD == drive)
- NR_HD++;
- BIOS += 6;
- }
-
- }
-#endif /* __i386__ */
-#ifdef __arm__
- if (!NR_HD) {
- /* We don't know anything about the drive. This means
- * that you *MUST* specify the drive parameters to the
- * kernel yourself.
- */
- printk("hd: no drives specified - use hd=cyl,head,sectors"
- " on kernel command line\n");
- }
-#endif
- if (!NR_HD)
- goto out;
-
- for (drive=0 ; drive < NR_HD ; drive++) {
- struct gendisk *disk = alloc_disk(64);
- struct hd_i_struct *p = &hd_info[drive];
- if (!disk)
- goto Enomem;
- disk->major = HD_MAJOR;
- disk->first_minor = drive << 6;
- disk->fops = &hd_fops;
- sprintf(disk->disk_name, "hd%c", 'a'+drive);
- disk->private_data = p;
- set_capacity(disk, p->head * p->sect * p->cyl);
- disk->queue = hd_queue;
- p->unit = drive;
- hd_gendisk[drive] = disk;
- printk ("%s: %luMB, CHS=%d/%d/%d\n",
- disk->disk_name, (unsigned long)get_capacity(disk)/2048,
- p->cyl, p->head, p->sect);
- }
-
- if (request_irq(HD_IRQ, hd_interrupt, SA_INTERRUPT, "hd", NULL)) {
- printk("hd: unable to get IRQ%d for the hard disk driver\n",
- HD_IRQ);
- goto out1;
- }
-
- if (!request_region(HD_DATA, 2, "hd(data)")) {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- NR_HD = 0;
- free_irq(HD_IRQ, NULL);
- return;
- }
-
- if (!request_region(HD_DATA + 2, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out2;
- }
-
- if (!request_region(HD_DATA + 4, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out3;
- }
-
- if (!request_region(HD_DATA + 6, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out4;
- }
-
- if (!request_region(HD_DATA + 8, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out5;
- }
-
- if (!request_region(HD_DATA + 10, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out6;
- }
-
- if (!request_region(HD_DATA + 12, 1, "hd"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA);
- goto out7;
- }
-
- if (!request_region(HD_CMD, 1, "hd(cmd)"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD);
- goto out8;
- }
-
- if (!request_region(HD_CMD + 2, 1, "hd(cmd)"))
- {
- printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD);
- goto out9;
- }
-
- for(drive=0; drive < NR_HD; drive++)
- add_disk(hd_gendisk[drive]);
- return 0;
-
-out9:
- release_region(HD_CMD, 1);
-out8:
- release_region(HD_DATA + 12, 1);
-out7:
- release_region(HD_DATA + 10, 1);
-out6:
- release_region(HD_DATA + 8, 1);
-out5:
- release_region(HD_DATA + 6, 1);
-out4:
- release_region(HD_DATA + 4, 1);
-out3:
- release_region(HD_DATA + 2, 1);
-out2:
- release_region(HD_DATA, 2);
- free_irq(HD_IRQ, NULL);
-out1:
- for (drive = 0; drive < NR_HD; drive++)
- put_disk(hd_gendisk[drive]);
- NR_HD = 0;
-out:
- del_timer(&device_timer);
- unregister_blkdev(HD_MAJOR,"hd");
- blk_cleanup_queue(hd_queue);
- return -1;
-Enomem:
- while (drive--)
- put_disk(hd_gendisk[drive]);
- goto out;
-}
-
-static int parse_hd_setup (char *line) {
- int ints[6];
-
- (void) get_options(line, ARRAY_SIZE(ints), ints);
- hd_setup(NULL, ints);
-
- return 1;
-}
-__setup("hd=", parse_hd_setup);
-
-module_init(hd_init);
+++ /dev/null
-/*
- * ide_pc9800.c
- *
- * Copyright (C) 1997-2000 Linux/98 project,
- * Kyoto University Microcomputer Club.
- */
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-#include <linux/ide.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/pc9800.h>
-
-#define PC9800_IDE_BANKSELECT 0x432
-
-#undef PC9800_IDE_DEBUG
-
-static void pc9800_select(ide_drive_t *drive)
-{
-#ifdef PC9800_IDE_DEBUG
- byte old;
-
- /* Too noisy: */
- /* printk(KERN_DEBUG "pc9800_select(%s)\n", drive->name); */
-
- outb(0x80, PC9800_IDE_BANKSELECT);
- old = inb(PC9800_IDE_BANKSELECT);
- if (old != HWIF(drive)->index)
- printk(KERN_DEBUG "ide-pc9800: switching bank #%d -> #%d\n",
- old, HWIF(drive)->index);
-#endif
- outb(HWIF(drive)->index, PC9800_IDE_BANKSELECT);
-}
-
-void __init ide_probe_for_pc9800(void)
-{
- u8 saved_bank;
-
- if (!PC9800_9821_P() /* || !PC9821_IDEIF_DOUBLE_P() */)
- return;
-
- if (!request_region(PC9800_IDE_BANKSELECT, 1, "ide0/1 bank")) {
- printk(KERN_ERR
- "ide: bank select port (%#x) is already occupied!\n",
- PC9800_IDE_BANKSELECT);
- return;
- }
-
- /* Do actual probing. */
- if ((saved_bank = inb(PC9800_IDE_BANKSELECT)) == (u8) ~0
- || (outb(saved_bank ^ 1, PC9800_IDE_BANKSELECT),
- /* Next outb is dummy for reading status. */
- outb(0x80, PC9800_IDE_BANKSELECT),
- inb(PC9800_IDE_BANKSELECT) != (saved_bank ^ 1))) {
- printk(KERN_INFO
- "ide: pc9800 type bank selecting port not found\n");
- release_region(PC9800_IDE_BANKSELECT, 1);
- return;
- }
-
- /* Restore original value, just in case. */
- outb(saved_bank, PC9800_IDE_BANKSELECT);
-
- /* These ports are reseved by IDE I/F. */
- if (!request_region(0x430, 1, "ide") ||
- !request_region(0x435, 1, "ide")) {
- printk(KERN_WARNING
- "ide: IO port 0x430 and 0x435 are reserved for IDE"
- " the card using these ports may not work\n");
- }
-
- if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET] == HD_DATA &&
- ide_hwifs[1].io_ports[IDE_DATA_OFFSET] == HD_DATA) {
- ide_hwifs[0].chipset = ide_pc9800;
- ide_hwifs[0].mate = &ide_hwifs[1];
- ide_hwifs[0].selectproc = pc9800_select;
- ide_hwifs[1].chipset = ide_pc9800;
- ide_hwifs[1].mate = &ide_hwifs[0];
- ide_hwifs[1].selectproc = pc9800_select;
- }
-}
+++ /dev/null
-#ifndef ALI15X3_H
-#define ALI15X3_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_ALI_TIMINGS
-
-static unsigned int init_chipset_ali15x3(struct pci_dev *, const char *);
-static void init_hwif_common_ali15x3(ide_hwif_t *);
-static void init_hwif_ali15x3(ide_hwif_t *);
-static void init_dma_ali15x3(ide_hwif_t *, unsigned long);
-
-static ide_pci_device_t ali15x3_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_AL,
- .device = PCI_DEVICE_ID_AL_M5229,
- .name = "ALI15X3",
- .init_chipset = init_chipset_ali15x3,
- .init_iops = NULL,
- .init_hwif = init_hwif_ali15x3,
- .init_dma = init_dma_ali15x3,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* ALI15X3 */
+++ /dev/null
-#ifndef AMD74XX_H
-#define AMD74XX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_AMD_TIMINGS
-
-static unsigned int init_chipset_amd74xx(struct pci_dev *, const char *);
-static void init_hwif_amd74xx(ide_hwif_t *);
-
-static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_AMD,
- .device = PCI_DEVICE_ID_AMD_COBRA_7401,
- .name = "AMD7401",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0
- },{ /* 1 */
- .vendor = PCI_VENDOR_ID_AMD,
- .device = PCI_DEVICE_ID_AMD_VIPER_7409,
- .name = "AMD7409",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0
- },{ /* 2 */
- .vendor = PCI_VENDOR_ID_AMD,
- .device = PCI_DEVICE_ID_AMD_VIPER_7411,
- .name = "AMD7411",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0
- },{ /* 3 */
- .vendor = PCI_VENDOR_ID_AMD,
- .device = PCI_DEVICE_ID_AMD_OPUS_7441,
- .name = "AMD7441",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0
- },{ /* 4 */
- .vendor = PCI_VENDOR_ID_AMD,
- .device = PCI_DEVICE_ID_AMD_8111_IDE,
- .name = "AMD8111",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .autodma = AUTODMA,
- .channels = 2,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0
- },
- { /* 5 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE_IDE,
- .name = "NFORCE",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0,
- },
- { /* 6 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE,
- .name = "NFORCE2",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0,
- },
- { /* 7 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE,
- .name = "NFORCE2S",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- { /* 8 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
- .name = "NFORCE2S-SATA",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- { /* 9 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE,
- .name = "NFORCE3",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- { /* 10 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE,
- .name = "NFORCE3S",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- { /* 11 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
- .name = "NFORCE3S-SATA",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- { /* 12 */
- .vendor = PCI_VENDOR_ID_NVIDIA,
- .device = PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2,
- .name = "NFORCE3S-SATA2",
- .init_chipset = init_chipset_amd74xx,
- .init_hwif = init_hwif_amd74xx,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}},
- .bootable = ON_BOARD,
- },
- {
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* AMD74XX_H */
+++ /dev/null
-#ifndef CMD640_H
-#define CMD640_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define IDE_IGNORE ((void *)-1)
-
-static ide_pci_device_t cmd640_chipsets[] __initdata = {
- {
- .vendor = PCI_VENDOR_ID_CMD,
- .device = PCI_DEVICE_ID_CMD_640,
- .name = "CMD640",
- .init_setup = NULL,
- .init_chipset = NULL,
- .init_iops = NULL,
- .init_hwif = IDE_IGNORE,
- .init_dma = NULL,
- .channels = 2,
- .autodma = NODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0
- },{
- .vendor = 0,
- .device = 0,
- .bootable = EOL,
- }
-}
-
-#endif /* CMD640_H */
+++ /dev/null
-#ifndef CS5520_H
-#define CS5520_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_CS5520_TIMINGS
-
-static unsigned int init_chipset_cs5520(struct pci_dev *, const char *);
-static void init_hwif_cs5520(ide_hwif_t *);
-static void cs5520_init_setup_dma(struct pci_dev *dev, struct ide_pci_device_s *d, ide_hwif_t *hwif);
-
-static ide_pci_device_t cyrix_chipsets[] __devinitdata = {
- {
- .vendor = PCI_VENDOR_ID_CYRIX,
- .device = PCI_DEVICE_ID_CYRIX_5510,
- .name = "Cyrix 5510",
- .init_chipset = init_chipset_cs5520,
- .init_setup_dma = cs5520_init_setup_dma,
- .init_iops = NULL,
- .init_hwif = init_hwif_cs5520,
- .isa_ports = 1,
- .channels = 2,
- .autodma = AUTODMA,
- .bootable = ON_BOARD,
- .extra = 0,
- },
- {
- .vendor = PCI_VENDOR_ID_CYRIX,
- .device = PCI_DEVICE_ID_CYRIX_5520,
- .name = "Cyrix 5520",
- .init_chipset = init_chipset_cs5520,
- .init_setup_dma = cs5520_init_setup_dma,
- .init_iops = NULL,
- .init_hwif = init_hwif_cs5520,
- .isa_ports = 1,
- .channels = 2,
- .autodma = AUTODMA,
- .bootable = ON_BOARD,
- .extra = 0,
- }
-};
-
-
-#endif /* CS5520_H */
-
-
+++ /dev/null
-#ifndef CS5530_H
-#define CS5530_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_CS5530_TIMINGS
-
-static unsigned int init_chipset_cs5530(struct pci_dev *, const char *);
-static void init_hwif_cs5530(ide_hwif_t *);
-
-static ide_pci_device_t cs5530_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_CYRIX,
- .device = PCI_DEVICE_ID_CYRIX_5530_IDE,
- .name = "CS5530",
- .init_chipset = init_chipset_cs5530,
- .init_iops = NULL,
- .init_hwif = init_hwif_cs5530,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* CS5530_H */
+++ /dev/null
-#ifndef NS87415_H
-#define NS87415_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static void init_hwif_ns87415(ide_hwif_t *);
-
-static ide_pci_device_t ns87415_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_NS,
- .device = PCI_DEVICE_ID_NS_87415,
- .name = "NS87415",
- .init_chipset = NULL,
- .init_iops = NULL,
- .init_hwif = init_hwif_ns87415,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* NS87415_H */
+++ /dev/null
-#ifndef RZ100X_H
-#define RZ100X_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static void init_hwif_rz1000(ide_hwif_t *);
-
-static ide_pci_device_t rz1000_chipsets[] __devinitdata = {
-{
- .vendor = PCI_VENDOR_ID_PCTECH,
- .device = PCI_DEVICE_ID_PCTECH_RZ1000,
- .name = "RZ1000",
- .init_chipset = NULL,
- .init_iops = NULL,
- .init_hwif = init_hwif_rz1000,
- .init_dma = NULL,
- .channels = 2,
- .autodma = NODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = PCI_VENDOR_ID_PCTECH,
- .device = PCI_DEVICE_ID_PCTECH_RZ1001,
- .name = "RZ1001",
- .init_chipset = NULL,
- .init_iops = NULL,
- .init_hwif = init_hwif_rz1000,
- .init_dma = NULL,
- .channels = 2,
- .autodma = NODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* RZ100X_H */
+++ /dev/null
-#ifndef SC1200_H
-#define SC1200_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SC1200_TIMINGS
-
-static unsigned int init_chipset_sc1200(struct pci_dev *, const char *);
-static void init_hwif_sc1200(ide_hwif_t *);
-
-static ide_pci_device_t sc1200_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_NS,
- .device = PCI_DEVICE_ID_NS_SCx200_IDE,
- .name = "SC1200",
- .init_chipset = init_chipset_sc1200,
- .init_iops = NULL,
- .init_hwif = init_hwif_sc1200,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* SC1200_H */
+++ /dev/null
-#ifndef SIIMAGE_H
-#define SIIMAGE_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#include <asm/io.h>
-
-#define DISPLAY_SIIMAGE_TIMINGS
-
-#undef SIIMAGE_VIRTUAL_DMAPIO
-#undef SIIMAGE_BUFFERED_TASKFILE
-#undef SIIMAGE_LARGE_DMA
-
-#define SII_DEBUG 0
-
-#if SII_DEBUG
-#define siiprintk(x...) printk(x)
-#else
-#define siiprintk(x...)
-#endif
-
-static unsigned int init_chipset_siimage(struct pci_dev *, const char *);
-static void init_iops_siimage(ide_hwif_t *);
-static void init_hwif_siimage(ide_hwif_t *);
-
-static ide_pci_device_t siimage_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_CMD,
- .device = PCI_DEVICE_ID_SII_680,
- .name = "SiI680",
- .init_chipset = init_chipset_siimage,
- .init_iops = init_iops_siimage,
- .init_hwif = init_hwif_siimage,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{ /* 1 */
- .vendor = PCI_VENDOR_ID_CMD,
- .device = PCI_DEVICE_ID_SII_3112,
- .name = "SiI3112 Serial ATA",
- .init_chipset = init_chipset_siimage,
- .init_iops = init_iops_siimage,
- .init_hwif = init_hwif_siimage,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{ /* 2 */
- .vendor = PCI_VENDOR_ID_CMD,
- .device = PCI_DEVICE_ID_SII_1210SA,
- .name = "Adaptec AAR-1210SA",
- .init_chipset = init_chipset_siimage,
- .init_iops = init_iops_siimage,
- .init_hwif = init_hwif_siimage,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* SIIMAGE_H */
+++ /dev/null
-#ifndef SIS5513_H
-#define SIS5513_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SIS_TIMINGS
-
-static unsigned int init_chipset_sis5513(struct pci_dev *, const char *);
-static void init_hwif_sis5513(ide_hwif_t *);
-
-static ide_pci_device_t sis5513_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_SI,
- .device = PCI_DEVICE_ID_SI_5513,
- .name = "SIS5513",
- .init_chipset = init_chipset_sis5513,
- .init_iops = NULL,
- .init_hwif = init_hwif_sis5513,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
- .bootable = ON_BOARD,
- .extra = 0
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* SIS5513_H */
+++ /dev/null
-#ifndef W82C105_H
-#define W82C105_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static unsigned int init_chipset_sl82c105(struct pci_dev *, const char *);
-static void init_hwif_sl82c105(ide_hwif_t *);
-static void init_dma_sl82c105(ide_hwif_t *, unsigned long);
-
-static ide_pci_device_t sl82c105_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_WINBOND,
- .device = PCI_DEVICE_ID_WINBOND_82C105,
- .name = "W82C105",
- .init_chipset = init_chipset_sl82c105,
- .init_iops = NULL,
- .init_hwif = init_hwif_sl82c105,
- .init_dma = init_dma_sl82c105,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* W82C105_H */
+++ /dev/null
-#ifndef SLC90E66_H
-#define SLC90E66_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_SLC90E66_TIMINGS
-
-#define SLC90E66_DEBUG_DRIVE_INFO 0
-
-static unsigned int init_chipset_slc90e66(struct pci_dev *, const char *);
-static void init_hwif_slc90e66(ide_hwif_t *);
-
-static ide_pci_device_t slc90e66_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_EFAR,
- .device = PCI_DEVICE_ID_EFAR_SLC90E66_1,
- .name = "SLC90E66",
- .init_chipset = init_chipset_slc90e66,
- .init_iops = NULL,
- .init_hwif = init_hwif_slc90e66,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* SLC90E66_H */
+++ /dev/null
-/*
- * triflex.h
- *
- * Copyright (C) 2002 Hewlett-Packard Development Group, L.P.
- * Author: Torben Mathiasen <torben.mathiasen@hp.com>
- *
- */
-#ifndef TRIFLEX_H
-#define TRIFLEX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-static unsigned int __devinit init_chipset_triflex(struct pci_dev *, const char *);
-static void init_hwif_triflex(ide_hwif_t *);
-
-static ide_pci_device_t triflex_devices[] __devinitdata = {
- {
- .vendor = PCI_VENDOR_ID_COMPAQ,
- .device = PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE,
- .name = "TRIFLEX",
- .init_chipset = init_chipset_triflex,
- .init_iops = NULL,
- .init_hwif = init_hwif_triflex,
- .channels = 2,
- .autodma = AUTODMA,
- .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
- .bootable = ON_BOARD,
- },{
- .bootable = EOL,
- }
-};
-
-static struct pci_device_id triflex_pci_tbl[] = {
- { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, PCI_ANY_ID,
- PCI_ANY_ID, 0, 0, 0 },
- { 0, },
-};
-MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
-
-#endif /* TRIFLEX_H */
+++ /dev/null
-#ifndef TRM290_H
-#define TRM290_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-extern void init_hwif_trm290(ide_hwif_t *);
-
-static ide_pci_device_t trm290_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_TEKRAM,
- .device = PCI_DEVICE_ID_TEKRAM_DC290,
- .name = "TRM290",
- .init_chipset = NULL,
- .init_iops = NULL,
- .init_hwif = init_hwif_trm290,
- .init_dma = NULL,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* TRM290_H */
+++ /dev/null
-#ifndef VIA82CXXX_H
-#define VIA82CXXX_H
-
-#include <linux/config.h>
-#include <linux/pci.h>
-#include <linux/ide.h>
-
-#define DISPLAY_VIA_TIMINGS
-
-static unsigned int init_chipset_via82cxxx(struct pci_dev *, const char *);
-static void init_hwif_via82cxxx(ide_hwif_t *);
-
-static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
- { /* 0 */
- .vendor = PCI_VENDOR_ID_VIA,
- .device = PCI_DEVICE_ID_VIA_82C576_1,
- .name = "VP_IDE",
- .init_chipset = init_chipset_via82cxxx,
- .init_hwif = init_hwif_via82cxxx,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{ /* 1 */
- .vendor = PCI_VENDOR_ID_VIA,
- .device = PCI_DEVICE_ID_VIA_82C586_1,
- .name = "VP_IDE",
- .init_chipset = init_chipset_via82cxxx,
- .init_hwif = init_hwif_via82cxxx,
- .channels = 2,
- .autodma = NOAUTODMA,
- .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
- .bootable = ON_BOARD,
- .extra = 0,
- },{
- .vendor = 0,
- .device = 0,
- .channels = 0,
- .bootable = EOL,
- }
-};
-
-#endif /* VIA82CXXX_H */
+++ /dev/null
-/*
- * Copyright (C) 2001 Broadcom Corporation
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* Derived loosely from ide-pmac.c, so:
- *
- * Copyright (C) 1998 Paul Mackerras.
- * Copyright (C) 1995-1998 Mark Lord
- */
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/ide.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/sibyte/sb1250_int.h>
-
-#define __IDE_SWARM_C
-
-#include <asm/sibyte/swarm_ide.h>
-
-void __init swarm_ide_probe(void)
-{
- int i;
- ide_hwif_t *hwif;
- /*
- * Find the first untaken slot in hwifs
- */
- for (i = 0; i < MAX_HWIFS; i++) {
- if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET]) {
- break;
- }
- }
- if (i == MAX_HWIFS) {
- printk("No space for SWARM onboard IDE driver in ide_hwifs[]. Not enabled.\n");
- return;
- }
-
- /* Set up our stuff */
- hwif = &ide_hwifs[i];
- hwif->hw.io_ports[IDE_DATA_OFFSET] = SWARM_IDE_REG(0x1f0);
- hwif->hw.io_ports[IDE_ERROR_OFFSET] = SWARM_IDE_REG(0x1f1);
- hwif->hw.io_ports[IDE_NSECTOR_OFFSET] = SWARM_IDE_REG(0x1f2);
- hwif->hw.io_ports[IDE_SECTOR_OFFSET] = SWARM_IDE_REG(0x1f3);
- hwif->hw.io_ports[IDE_LCYL_OFFSET] = SWARM_IDE_REG(0x1f4);
- hwif->hw.io_ports[IDE_HCYL_OFFSET] = SWARM_IDE_REG(0x1f5);
- hwif->hw.io_ports[IDE_SELECT_OFFSET] = SWARM_IDE_REG(0x1f6);
- hwif->hw.io_ports[IDE_STATUS_OFFSET] = SWARM_IDE_REG(0x1f7);
- hwif->hw.io_ports[IDE_CONTROL_OFFSET] = SWARM_IDE_REG(0x3f6);
- hwif->hw.io_ports[IDE_IRQ_OFFSET] = SWARM_IDE_REG(0x3f7);
-// hwif->hw->ack_intr = swarm_ide_ack_intr;
- hwif->hw.irq = SWARM_IDE_INT;
-#if 0
- hwif->iops = swarm_iops;
-#else
- hwif->OUTB = hwif->OUTBP = swarm_outb;
- hwif->OUTW = hwif->OUTWP = swarm_outw;
- hwif->OUTL = hwif->OUTLP = swarm_outl;
- hwif->OUTSW = hwif->OUTSWP = swarm_outsw;
- hwif->OUTSL = hwif->OUTSLP = swarm_outsl;
- hwif->INB = hwif->INBP = swarm_inb;
- hwif->INW = hwif->INWP = swarm_inw;
- hwif->INL = hwif->INLP = swarm_inl;
- hwif->INSW = hwif->INSWP = swarm_insw;
- hwif->INSL = hwif->INSLP = swarm_insl;
-#endif
-#if 0
- hwif->pioops = swarm_pio_ops;
-#else
- hwif->ata_input_data = swarm_ata_input_data;
- hwif->ata_output_data = swarm_ata_output_data;
- hwif->atapi_input_bytes = swarm_atapi_input_bytes;
- hwif->atapi_output_bytes = swarm_atapi_output_bytes;
-#endif
- memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
- hwif->irq = hwif->hw.irq;
- printk("SWARM onboard IDE configured as device %i\n", i);
-
-#ifndef HWIF_PROBE_CLASSIC_METHOD
- probe_hwif_init(hwif->index);
-#endif /* HWIF_PROBE_CLASSIC_METHOD */
-
-}
-
+++ /dev/null
-/*
- * drivers/input/keyboard/98kbd.c
- *
- * PC-9801 keyboard driver for Linux
- *
- * Based on atkbd.c and xtkbd.c written by Vojtech Pavlik
- *
- * Copyright (c) 2002 Osamu Tomita
- * Copyright (c) 1999-2001 Vojtech Pavlik
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/input.h>
-#include <linux/init.h>
-#include <linux/serio.h>
-
-#include <asm/io.h>
-#include <asm/pc9800.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 keyboard driver");
-MODULE_LICENSE("GPL");
-
-#define KBD98_KEY 0x7f
-#define KBD98_RELEASE 0x80
-
-static unsigned char kbd98_keycode[256] = {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 43, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 41, 26, 28, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 27, 44, 45, 46, 47, 48, 49, 50,
- 51, 52, 53, 12, 57, 92,109,104,110,111,103,105,106,108,102,107,
- 74, 98, 71, 72, 73, 55, 75, 76, 77, 78, 79, 80, 81,117, 82,121,
- 83, 94, 87, 88,183,184,185, 0, 0, 0, 0, 0, 0, 0,102, 0,
- 99,133, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 0, 0, 0, 0,
- 54, 58, 42, 56, 29
-};
-
-struct jis_kbd_conv {
- unsigned char scancode;
- struct {
- unsigned char shift;
- unsigned char keycode;
- } emul[2];
-};
-
-static struct jis_kbd_conv kbd98_jis[] = {
- {0x02, {{0, 3}, {1, 40}}},
- {0x06, {{0, 7}, {1, 8}}},
- {0x07, {{0, 8}, {0, 40}}},
- {0x08, {{0, 9}, {1, 10}}},
- {0x09, {{0, 10}, {1, 11}}},
- {0x0a, {{0, 11}, {1, 255}}},
- {0x0b, {{0, 12}, {0, 13}}},
- {0x0c, {{1, 7}, {0, 41}}},
- {0x1a, {{1, 3}, {1, 41}}},
- {0x26, {{0, 39}, {1, 13}}},
- {0x27, {{1, 39}, {1, 9}}},
- {0x33, {{0, 255}, {1, 12}}},
- {0xff, {{0, 255}, {1, 255}}} /* terminater */
-};
-
-#define KBD98_CMD_SETEXKEY 0x1095 /* Enable/Disable Windows, Appli key */
-#define KBD98_CMD_SETRATE 0x109c /* Set typematic rate */
-#define KBD98_CMD_SETLEDS 0x109d /* Set keyboard leds */
-#define KBD98_CMD_GETLEDS 0x119d /* Get keyboard leds */
-#define KBD98_CMD_GETID 0x019f
-
-#define KBD98_RET_ACK 0xfa
-#define KBD98_RET_NAK 0xfc /* Command NACK, send the cmd again */
-
-#define KBD98_KEY_JIS_EMUL 253
-#define KBD98_KEY_UNKNOWN 254
-#define KBD98_KEY_NULL 255
-
-static char *kbd98_name = "PC-9801 Keyboard";
-
-struct kbd98 {
- unsigned char keycode[256];
- struct input_dev dev;
- struct serio *serio;
- char phys[32];
- unsigned char cmdbuf[4];
- unsigned char cmdcnt;
- signed char ack;
- unsigned char shift;
- struct {
- unsigned char scancode;
- unsigned char keycode;
- } emul;
- struct jis_kbd_conv jis[16];
-};
-
-irqreturn_t kbd98_interrupt(struct serio *serio, unsigned char data,
- unsigned int flags, struct pt_regs *regs)
-{
- struct kbd98 *kbd98 = serio->private;
- unsigned char scancode, keycode;
- int press, i;
-
- switch (data) {
- case KBD98_RET_ACK:
- kbd98->ack = 1;
- goto out;
- case KBD98_RET_NAK:
- kbd98->ack = -1;
- goto out;
- }
-
- if (kbd98->cmdcnt) {
- kbd98->cmdbuf[--kbd98->cmdcnt] = data;
- goto out;
- }
-
- scancode = data & KBD98_KEY;
- keycode = kbd98->keycode[scancode];
- press = !(data & KBD98_RELEASE);
- if (kbd98->emul.scancode != KBD98_KEY_UNKNOWN
- && scancode != kbd98->emul.scancode) {
- input_report_key(&kbd98->dev, kbd98->emul.keycode, 0);
- kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
- }
-
- if (keycode == KEY_RIGHTSHIFT)
- kbd98->shift = press;
-
- switch (keycode) {
- case KEY_2:
- case KEY_6:
- case KEY_7:
- case KEY_8:
- case KEY_9:
- case KEY_0:
- case KEY_MINUS:
- case KEY_EQUAL:
- case KEY_GRAVE:
- case KEY_SEMICOLON:
- case KEY_APOSTROPHE:
- /* emulation: JIS keyboard to US101 keyboard */
- i = 0;
- while (kbd98->jis[i].scancode != 0xff) {
- if (scancode == kbd98->jis[i].scancode)
- break;
- i ++;
- }
-
- keycode = kbd98->jis[i].emul[kbd98->shift].keycode;
- if (keycode == KBD98_KEY_NULL)
- break;
-
- if (press) {
- kbd98->emul.scancode = scancode;
- kbd98->emul.keycode = keycode;
- if (kbd98->jis[i].emul[kbd98->shift].shift
- != kbd98->shift)
- input_report_key(&kbd98->dev,
- KEY_RIGHTSHIFT,
- !(kbd98->shift));
- }
-
- input_report_key(&kbd98->dev, keycode, press);
- if (!press) {
- if (kbd98->jis[i].emul[kbd98->shift].shift
- != kbd98->shift)
- input_report_key(&kbd98->dev,
- KEY_RIGHTSHIFT,
- kbd98->shift);
- kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
- }
-
- input_sync(&kbd98->dev);
- break;
-
- case KEY_CAPSLOCK:
- input_report_key(&kbd98->dev, keycode, 1);
- input_sync(&kbd98->dev);
- input_report_key(&kbd98->dev, keycode, 0);
- input_sync(&kbd98->dev);
- break;
-
- case KBD98_KEY_NULL:
- break;
-
- case 0:
- printk(KERN_WARNING "kbd98.c: Unknown key (scancode %#x) %s.\n",
- data & KBD98_KEY, data & KBD98_RELEASE ? "released" : "pressed");
- break;
-
- default:
- input_report_key(&kbd98->dev, keycode, press);
- input_sync(&kbd98->dev);
- break;
- }
-
-out:
- return IRQ_HANDLED;
-}
-
-/*
- * kbd98_sendbyte() sends a byte to the keyboard, and waits for
- * acknowledge. It doesn't handle resends according to the keyboard
- * protocol specs, because if these are needed, the keyboard needs
- * replacement anyway, and they only make a mess in the protocol.
- */
-
-static int kbd98_sendbyte(struct kbd98 *kbd98, unsigned char byte)
-{
- int timeout = 10000; /* 100 msec */
- kbd98->ack = 0;
-
- if (serio_write(kbd98->serio, byte))
- return -1;
-
- while (!kbd98->ack && timeout--) udelay(10);
-
- return -(kbd98->ack <= 0);
-}
-
-/*
- * kbd98_command() sends a command, and its parameters to the keyboard,
- * then waits for the response and puts it in the param array.
- */
-
-static int kbd98_command(struct kbd98 *kbd98, unsigned char *param, int command)
-{
- int timeout = 50000; /* 500 msec */
- int send = (command >> 12) & 0xf;
- int receive = (command >> 8) & 0xf;
- int i;
-
- kbd98->cmdcnt = receive;
-
- if (command & 0xff)
- if (kbd98_sendbyte(kbd98, command & 0xff))
- return (kbd98->cmdcnt = 0) - 1;
-
- for (i = 0; i < send; i++)
- if (kbd98_sendbyte(kbd98, param[i]))
- return (kbd98->cmdcnt = 0) - 1;
-
- while (kbd98->cmdcnt && timeout--) udelay(10);
-
- if (param)
- for (i = 0; i < receive; i++)
- param[i] = kbd98->cmdbuf[(receive - 1) - i];
-
- if (kbd98->cmdcnt)
- return (kbd98->cmdcnt = 0) - 1;
-
- return 0;
-}
-
-/*
- * Event callback from the input module. Events that change the state of
- * the hardware are processed here.
- */
-
-static int kbd98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
- struct kbd98 *kbd98 = dev->private;
- char param[2];
-
- switch (type) {
-
- case EV_LED:
-
- if (__PC9800SCA_TEST_BIT(0x481, 3)) {
- /* 98note with Num Lock key */
- /* keep Num Lock status */
- *param = 0x60;
- if (kbd98_command(kbd98, param,
- KBD98_CMD_GETLEDS))
- printk(KERN_DEBUG
- "kbd98: Get keyboard LED"
- " status Error\n");
-
- *param &= 1;
- } else {
- /* desktop PC-9801 */
- *param = 1; /* Always set Num Lock */
- }
-
- *param |= 0x70
- | (test_bit(LED_CAPSL, dev->led) ? 4 : 0)
- | (test_bit(LED_KANA, dev->led) ? 8 : 0);
- kbd98_command(kbd98, param, KBD98_CMD_SETLEDS);
-
- return 0;
- }
-
- return -1;
-}
-
-void kbd98_connect(struct serio *serio, struct serio_dev *dev)
-{
- struct kbd98 *kbd98;
- int i;
-
- if ((serio->type & SERIO_TYPE) != SERIO_PC9800)
- return;
-
- if (!(kbd98 = kmalloc(sizeof(struct kbd98), GFP_KERNEL)))
- return;
-
- memset(kbd98, 0, sizeof(struct kbd98));
- kbd98->emul.scancode = KBD98_KEY_UNKNOWN;
-
- kbd98->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
- kbd98->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_KANA);
-
- kbd98->serio = serio;
-
- init_input_dev(&kbd98->dev);
- kbd98->dev.keycode = kbd98->keycode;
- kbd98->dev.keycodesize = sizeof(unsigned char);
- kbd98->dev.keycodemax = ARRAY_SIZE(kbd98_keycode);
- kbd98->dev.event = kbd98_event;
- kbd98->dev.private = kbd98;
-
- serio->private = kbd98;
-
- if (serio_open(serio, dev)) {
- kfree(kbd98);
- return;
- }
-
- memcpy(kbd98->jis, kbd98_jis, sizeof(kbd98_jis));
- memcpy(kbd98->keycode, kbd98_keycode, sizeof(kbd98->keycode));
- for (i = 0; i < 255; i++)
- set_bit(kbd98->keycode[i], kbd98->dev.keybit);
- clear_bit(0, kbd98->dev.keybit);
-
- sprintf(kbd98->phys, "%s/input0", serio->phys);
-
- kbd98->dev.name = kbd98_name;
- kbd98->dev.phys = kbd98->phys;
- kbd98->dev.id.bustype = BUS_XTKBD;
- kbd98->dev.id.vendor = 0x0002;
- kbd98->dev.id.product = 0x0001;
- kbd98->dev.id.version = 0x0100;
-
- input_register_device(&kbd98->dev);
-
- printk(KERN_INFO "input: %s on %s\n", kbd98_name, serio->phys);
-}
-
-void kbd98_disconnect(struct serio *serio)
-{
- struct kbd98 *kbd98 = serio->private;
- input_unregister_device(&kbd98->dev);
- serio_close(serio);
- kfree(kbd98);
-}
-
-struct serio_dev kbd98_dev = {
- .interrupt = kbd98_interrupt,
- .connect = kbd98_connect,
- .disconnect = kbd98_disconnect
-};
-
-int __init kbd98_init(void)
-{
- serio_register_device(&kbd98_dev);
- return 0;
-}
-
-void __exit kbd98_exit(void)
-{
- serio_unregister_device(&kbd98_dev);
-}
-
-module_init(kbd98_init);
-module_exit(kbd98_exit);
+++ /dev/null
-/*
- * PC-9800 Speaker beeper driver for Linux
- *
- * Copyright (c) 2002 Osamu Tomita
- * Copyright (c) 2002 Vojtech Pavlik
- * Copyright (c) 1992 Orest Zborowski
- *
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <asm/8253pit.h>
-#include <asm/io.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9800 Speaker beeper driver");
-MODULE_LICENSE("GPL");
-
-static char spkr98_name[] = "PC-9801 Speaker";
-static char spkr98_phys[] = "isa3fdb/input0";
-static struct input_dev spkr98_dev;
-
-spinlock_t i8253_beep_lock = SPIN_LOCK_UNLOCKED;
-
-static int spkr98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
-{
- unsigned int count = 0;
- unsigned long flags;
-
- if (type != EV_SND)
- return -1;
-
- switch (code) {
- case SND_BELL: if (value) value = 1000;
- case SND_TONE: break;
- default: return -1;
- }
-
- if (value > 20 && value < 32767)
- count = PIT_TICK_RATE / value;
-
- spin_lock_irqsave(&i8253_beep_lock, flags);
-
- if (count) {
- outb(0x76, 0x3fdf);
- outb(0, 0x5f);
- outb(count & 0xff, 0x3fdb);
- outb(0, 0x5f);
- outb((count >> 8) & 0xff, 0x3fdb);
- /* beep on */
- outb(6, 0x37);
- } else {
- /* beep off */
- outb(7, 0x37);
- }
-
- spin_unlock_irqrestore(&i8253_beep_lock, flags);
-
- return 0;
-}
-
-static int __init spkr98_init(void)
-{
- spkr98_dev.evbit[0] = BIT(EV_SND);
- spkr98_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
- spkr98_dev.event = spkr98_event;
-
- spkr98_dev.name = spkr98_name;
- spkr98_dev.phys = spkr98_phys;
- spkr98_dev.id.bustype = BUS_ISA;
- spkr98_dev.id.vendor = 0x001f;
- spkr98_dev.id.product = 0x0001;
- spkr98_dev.id.version = 0x0100;
-
- input_register_device(&spkr98_dev);
-
- printk(KERN_INFO "input: %s\n", spkr98_name);
-
- return 0;
-}
-
-static void __exit spkr98_exit(void)
-{
- input_unregister_device(&spkr98_dev);
-}
-
-module_init(spkr98_init);
-module_exit(spkr98_exit);
+++ /dev/null
-/*
- *
- * Copyright (c) 2002 Osamu Tomita
- *
- * Based on the work of:
- * James Banks Matthew Dillon
- * David Giller Nathan Laredo
- * Linus Torvalds Johan Myreen
- * Cliff Matthews Philip Blundell
- * Russell King Vojtech Pavlik
- */
-
-/*
- * NEC PC-9801 Bus Mouse Driver for Linux
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/delay.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/input.h>
-#include <linux/interrupt.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 busmouse driver");
-MODULE_LICENSE("GPL");
-
-#define PC98BM_BASE 0x7fd9
-#define PC98BM_DATA_PORT PC98BM_BASE + 0
-/* PC98BM_SIGNATURE_PORT does not exist */
-#define PC98BM_CONTROL_PORT PC98BM_BASE + 4
-/* PC98BM_INTERRUPT_PORT does not exist */
-#define PC98BM_CONFIG_PORT PC98BM_BASE + 6
-
-#define PC98BM_ENABLE_IRQ 0x00
-#define PC98BM_DISABLE_IRQ 0x10
-#define PC98BM_READ_X_LOW 0x80
-#define PC98BM_READ_X_HIGH 0xa0
-#define PC98BM_READ_Y_LOW 0xc0
-#define PC98BM_READ_Y_HIGH 0xe0
-
-#define PC98BM_DEFAULT_MODE 0x93
-/* PC98BM_CONFIG_BYTE is not used */
-/* PC98BM_SIGNATURE_BYTE is not used */
-
-#define PC98BM_TIMER_PORT 0xbfdb
-#define PC98BM_DEFAULT_TIMER_VAL 0x00
-
-#define PC98BM_IRQ 13
-
-static int pc98bm_irq = PC98BM_IRQ;
-module_param_named(irq, pc98bm_irq, uint, 0);
-MODULE_PARM_DESC(irq, "IRQ number (13=default)");
-
-__obsolete_setup("pc98bm_irq=");
-
-static int pc98bm_used = 0;
-
-static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static int pc98bm_open(struct input_dev *dev)
-{
- if (pc98bm_used++)
- return 0;
- if (request_irq(pc98bm_irq, pc98bm_interrupt, 0, "98busmouse", NULL)) {
- pc98bm_used--;
- printk(KERN_ERR "98busmouse.c: Can't allocate irq %d\n", pc98bm_irq);
- return -EBUSY;
- }
- outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT);
- return 0;
-}
-
-static void pc98bm_close(struct input_dev *dev)
-{
- if (--pc98bm_used)
- return;
- outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT);
- free_irq(pc98bm_irq, NULL);
-}
-
-static struct input_dev pc98bm_dev = {
- .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
- .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
- .relbit = { BIT(REL_X) | BIT(REL_Y) },
- .open = pc98bm_open,
- .close = pc98bm_close,
- .name = "PC-9801 bus mouse",
- .phys = "isa7fd9/input0",
- .id = {
- .bustype = BUS_ISA,
- .vendor = 0x0004,
- .product = 0x0001,
- .version = 0x0100,
- },
-};
-
-static irqreturn_t pc98bm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- char dx, dy;
- unsigned char buttons;
-
- outb(PC98BM_READ_X_LOW, PC98BM_CONTROL_PORT);
- dx = (inb(PC98BM_DATA_PORT) & 0xf);
- outb(PC98BM_READ_X_HIGH, PC98BM_CONTROL_PORT);
- dx |= (inb(PC98BM_DATA_PORT) & 0xf) << 4;
- outb(PC98BM_READ_Y_LOW, PC98BM_CONTROL_PORT);
- dy = (inb(PC98BM_DATA_PORT) & 0xf);
- outb(PC98BM_READ_Y_HIGH, PC98BM_CONTROL_PORT);
- buttons = inb(PC98BM_DATA_PORT);
- dy |= (buttons & 0xf) << 4;
- buttons = ~buttons >> 5;
-
- input_report_rel(&pc98bm_dev, REL_X, dx);
- input_report_rel(&pc98bm_dev, REL_Y, dy);
- input_report_key(&pc98bm_dev, BTN_RIGHT, buttons & 1);
- input_report_key(&pc98bm_dev, BTN_MIDDLE, buttons & 2);
- input_report_key(&pc98bm_dev, BTN_LEFT, buttons & 4);
- input_sync(&pc98bm_dev);
-
- outb(PC98BM_ENABLE_IRQ, PC98BM_CONTROL_PORT);
-
- return IRQ_HANDLED;
-}
-
-static int __init pc98bm_init(void)
-{
- int i;
-
- for (i = 0; i <= 6; i += 2) {
- if (!request_region(PC98BM_BASE + i, 1, "98busmouse")) {
- printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_BASE + i);
- while (i > 0) {
- i -= 2;
- release_region(PC98BM_BASE + i, 1);
- }
-
- return -EBUSY;
- }
-
- }
-
- if (!request_region(PC98BM_TIMER_PORT, 1, "98busmouse")) {
- printk(KERN_ERR "98busmouse.c: Can't allocate ports at %#x\n", PC98BM_TIMER_PORT);
- for (i = 0; i <= 6; i += 2)
- release_region(PC98BM_BASE + i, 1);
-
- return -EBUSY;
- }
-
- outb(PC98BM_DEFAULT_MODE, PC98BM_CONFIG_PORT);
- outb(PC98BM_DISABLE_IRQ, PC98BM_CONTROL_PORT);
-
- outb(PC98BM_DEFAULT_TIMER_VAL, PC98BM_TIMER_PORT);
-
- input_register_device(&pc98bm_dev);
-
- printk(KERN_INFO "input: PC-9801 bus mouse at %#x irq %d\n", PC98BM_BASE, pc98bm_irq);
-
- return 0;
-}
-
-static void __exit pc98bm_exit(void)
-{
- int i;
-
- input_unregister_device(&pc98bm_dev);
- for (i = 0; i <= 6; i += 2)
- release_region(PC98BM_BASE + i, 1);
-
- release_region(PC98BM_TIMER_PORT, 1);
-}
-
-module_init(pc98bm_init);
-module_exit(pc98bm_exit);
+++ /dev/null
-/*
- * NEC PC-9801 keyboard controller driver for Linux
- *
- * Copyright (c) 1999-2002 Osamu Tomita <tomita@cinet.co.jp>
- * Based on i8042.c written by Vojtech Pavlik
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#include <linux/config.h>
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serio.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("NEC PC-9801 keyboard controller driver");
-MODULE_LICENSE("GPL");
-
-/*
- * Names.
- */
-
-#define KBD98_PHYS_DESC "isa0041/serio0"
-
-/*
- * IRQs.
- */
-
-#define KBD98_IRQ 1
-
-/*
- * Register numbers.
- */
-
-#define KBD98_COMMAND_REG 0x43
-#define KBD98_STATUS_REG 0x43
-#define KBD98_DATA_REG 0x41
-
-spinlock_t kbd98io_lock = SPIN_LOCK_UNLOCKED;
-
-static struct serio kbd98_port;
-extern struct pt_regs *kbd_pt_regs;
-
-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-/*
- * kbd98_flush() flushes all data that may be in the keyboard buffers
- */
-
-static int kbd98_flush(void)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&kbd98io_lock, flags);
-
- while (inb(KBD98_STATUS_REG) & 0x02) /* RxRDY */
- inb(KBD98_DATA_REG);
-
- if (inb(KBD98_STATUS_REG) & 0x38)
- printk("98kbd-io: Keyboard error!\n");
-
- spin_unlock_irqrestore(&kbd98io_lock, flags);
-
- return 0;
-}
-
-/*
- * kbd98_write() sends a byte out through the keyboard interface.
- */
-
-static int kbd98_write(struct serio *port, unsigned char c)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&kbd98io_lock, flags);
-
- outb(0, 0x5f); /* wait */
- outb(0x17, KBD98_COMMAND_REG); /* enable send command */
- outb(0, 0x5f); /* wait */
- outb(c, KBD98_DATA_REG);
- outb(0, 0x5f); /* wait */
- outb(0x16, KBD98_COMMAND_REG); /* disable send command */
- outb(0, 0x5f); /* wait */
-
- spin_unlock_irqrestore(&kbd98io_lock, flags);
-
- return 0;
-}
-
-/*
- * kbd98_open() is called when a port is open by the higher layer.
- * It allocates the interrupt and enables in in the chip.
- */
-
-static int kbd98_open(struct serio *port)
-{
- kbd98_flush();
-
- if (request_irq(KBD98_IRQ, kbd98io_interrupt, 0, "kbd98", NULL)) {
- printk(KERN_ERR "98kbd-io.c: Can't get irq %d for %s, unregistering the port.\n", KBD98_IRQ, "KBD");
- serio_unregister_port(port);
- return -1;
- }
-
- return 0;
-}
-
-static void kbd98_close(struct serio *port)
-{
- free_irq(KBD98_IRQ, NULL);
-
- kbd98_flush();
-}
-
-/*
- * Structures for registering the devices in the serio.c module.
- */
-
-static struct serio kbd98_port =
-{
- .type = SERIO_PC9800,
- .write = kbd98_write,
- .open = kbd98_open,
- .close = kbd98_close,
- .driver = NULL,
- .name = "PC-9801 Kbd Port",
- .phys = KBD98_PHYS_DESC,
-};
-
-/*
- * kbd98io_interrupt() is the most important function in this driver -
- * it handles the interrupts from keyboard, and sends incoming bytes
- * to the upper layers.
- */
-
-static irqreturn_t kbd98io_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- unsigned long flags;
- unsigned char data;
-
- spin_lock_irqsave(&kbd98io_lock, flags);
-
- data = inb(KBD98_DATA_REG);
- spin_unlock_irqrestore(&kbd98io_lock, flags);
- serio_interrupt(&kbd98_port, data, 0, regs);
-
- return IRQ_HANDLED;
-}
-
-int __init kbd98io_init(void)
-{
- serio_register_port(&kbd98_port);
-
- printk(KERN_INFO "serio: PC-9801 %s port at %#lx,%#lx irq %d\n",
- "KBD",
- (unsigned long) KBD98_DATA_REG,
- (unsigned long) KBD98_COMMAND_REG,
- KBD98_IRQ);
-
- return 0;
-}
-
-void __exit kbd98io_exit(void)
-{
- serio_unregister_port(&kbd98_port);
-}
-
-module_init(kbd98io_init);
-module_exit(kbd98io_exit);
+++ /dev/null
-#ifndef SCSI_ASCQ_TBL_C_INCLUDED
-#define SCSI_ASCQ_TBL_C_INCLUDED
-
-/* AuToMaGiCaLlY generated from: "t10.org/asc-num.txt"
- *******************************************************************************
- * File: ASC-NUM.TXT
- *
- * SCSI ASC/ASCQ Assignments
- * Numeric Sorted Listing
- * as of 5/18/00
- *
- * D - DIRECT ACCESS DEVICE (SBC-2) device column key
- * .T - SEQUENTIAL ACCESS DEVICE (SSC) -------------------
- * . L - PRINTER DEVICE (SSC) blank = reserved
- * . P - PROCESSOR DEVICE (SPC) not blank = allowed
- * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2)
- * . . R - CD DEVICE (MMC)
- * . . S - SCANNER DEVICE (SCSI-2)
- * . . .O - OPTICAL MEMORY DEVICE (SBC-2)
- * . . . M - MEDIA CHANGER DEVICE (SMC)
- * . . . C - COMMUNICATION DEVICE (SCSI-2)
- * . . . .A - STORAGE ARRAY DEVICE (SCC)
- * . . . . E - ENCLOSURE SERVICES DEVICE (SES)
- * . . . . B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
- * . . . . .K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
- * ASC/ASCQ DTLPWRSOMCAEBK Description
- * ------- -------------- ----------------------------------------------------
- */
-
-static char SenseDevTypes001[] = "DTLPWRSOMCAEBK";
-static char SenseDevTypes002[] = ".T............";
-static char SenseDevTypes003[] = ".T....S.......";
-static char SenseDevTypes004[] = ".TL...S.......";
-static char SenseDevTypes005[] = ".....R........";
-static char SenseDevTypes006[] = "DTL.WRSOM.AEBK";
-static char SenseDevTypes007[] = "D...W..O....BK";
-static char SenseDevTypes008[] = "D...WR.OM...BK";
-static char SenseDevTypes009[] = "DTL.W.SO....BK";
-static char SenseDevTypes010[] = "DTL..R.O....B.";
-static char SenseDevTypes011[] = "DT..W..OMCA.BK";
-static char SenseDevTypes012[] = "..............";
-static char SenseDevTypes013[] = "DTL.WRSOMCAEBK";
-static char SenseDevTypes014[] = "DTL.WRSOM...BK";
-static char SenseDevTypes015[] = "DT...R.OM...BK";
-static char SenseDevTypes016[] = "DTLPWRSO.C...K";
-static char SenseDevTypes017[] = "DT..WR.O....B.";
-static char SenseDevTypes018[] = "....WR.O.....K";
-static char SenseDevTypes019[] = "....WR.O......";
-static char SenseDevTypes020[] = ".T...RS.......";
-static char SenseDevTypes021[] = ".............K";
-static char SenseDevTypes022[] = "DT..W..O....B.";
-static char SenseDevTypes023[] = "DT..WRSO....BK";
-static char SenseDevTypes024[] = "DT..W.SO....BK";
-static char SenseDevTypes025[] = "....WR.O....B.";
-static char SenseDevTypes026[] = "....W..O....B.";
-static char SenseDevTypes027[] = "DT.....O....BK";
-static char SenseDevTypes028[] = "DTL.WRSO....BK";
-static char SenseDevTypes029[] = "DT..WR.O....BK";
-static char SenseDevTypes030[] = "DT..W..O....BK";
-static char SenseDevTypes031[] = "D...WR.O....BK";
-static char SenseDevTypes032[] = "D......O.....K";
-static char SenseDevTypes033[] = "D......O....BK";
-static char SenseDevTypes034[] = "DT..WR.OM...BK";
-static char SenseDevTypes035[] = "D.............";
-static char SenseDevTypes036[] = "DTLPWRSOMCAE.K";
-static char SenseDevTypes037[] = "DTLPWRSOMCA.BK";
-static char SenseDevTypes038[] = ".T...R........";
-static char SenseDevTypes039[] = "DT..WR.OM...B.";
-static char SenseDevTypes040[] = "DTL.WRSOMCAE.K";
-static char SenseDevTypes041[] = "DTLPWRSOMCAE..";
-static char SenseDevTypes042[] = "......S.......";
-static char SenseDevTypes043[] = "............B.";
-static char SenseDevTypes044[] = "DTLPWRSO.CA..K";
-static char SenseDevTypes045[] = "DT...R.......K";
-static char SenseDevTypes046[] = "D.L..R.O....B.";
-static char SenseDevTypes047[] = "..L...........";
-static char SenseDevTypes048[] = ".TL...........";
-static char SenseDevTypes049[] = "DTLPWRSOMC..BK";
-static char SenseDevTypes050[] = "DT..WR.OMCAEBK";
-static char SenseDevTypes051[] = "DT..WR.OMCAEB.";
-static char SenseDevTypes052[] = ".T...R.O......";
-static char SenseDevTypes053[] = "...P..........";
-static char SenseDevTypes054[] = "DTLPWRSOM.AE.K";
-static char SenseDevTypes055[] = "DTLPWRSOM.AE..";
-static char SenseDevTypes056[] = ".......O......";
-static char SenseDevTypes057[] = "DTLPWRSOM...BK";
-static char SenseDevTypes058[] = "DT..WR.O..A.BK";
-static char SenseDevTypes059[] = "DTLPWRSOM....K";
-static char SenseDevTypes060[] = "D......O......";
-static char SenseDevTypes061[] = ".....R......B.";
-static char SenseDevTypes062[] = "D...........B.";
-static char SenseDevTypes063[] = "............BK";
-static char SenseDevTypes064[] = "..........A...";
-
-static ASCQ_Table_t ASCQ_Table[] = {
- {
- 0x00, 0x00,
- SenseDevTypes001,
- "NO ADDITIONAL SENSE INFORMATION"
- },
- {
- 0x00, 0x01,
- SenseDevTypes002,
- "FILEMARK DETECTED"
- },
- {
- 0x00, 0x02,
- SenseDevTypes003,
- "END-OF-PARTITION/MEDIUM DETECTED"
- },
- {
- 0x00, 0x03,
- SenseDevTypes002,
- "SETMARK DETECTED"
- },
- {
- 0x00, 0x04,
- SenseDevTypes003,
- "BEGINNING-OF-PARTITION/MEDIUM DETECTED"
- },
- {
- 0x00, 0x05,
- SenseDevTypes004,
- "END-OF-DATA DETECTED"
- },
- {
- 0x00, 0x06,
- SenseDevTypes001,
- "I/O PROCESS TERMINATED"
- },
- {
- 0x00, 0x11,
- SenseDevTypes005,
- "AUDIO PLAY OPERATION IN PROGRESS"
- },
- {
- 0x00, 0x12,
- SenseDevTypes005,
- "AUDIO PLAY OPERATION PAUSED"
- },
- {
- 0x00, 0x13,
- SenseDevTypes005,
- "AUDIO PLAY OPERATION SUCCESSFULLY COMPLETED"
- },
- {
- 0x00, 0x14,
- SenseDevTypes005,
- "AUDIO PLAY OPERATION STOPPED DUE TO ERROR"
- },
- {
- 0x00, 0x15,
- SenseDevTypes005,
- "NO CURRENT AUDIO STATUS TO RETURN"
- },
- {
- 0x00, 0x16,
- SenseDevTypes001,
- "OPERATION IN PROGRESS"
- },
- {
- 0x00, 0x17,
- SenseDevTypes006,
- "CLEANING REQUESTED"
- },
- {
- 0x01, 0x00,
- SenseDevTypes007,
- "NO INDEX/SECTOR SIGNAL"
- },
- {
- 0x02, 0x00,
- SenseDevTypes008,
- "NO SEEK COMPLETE"
- },
- {
- 0x03, 0x00,
- SenseDevTypes009,
- "PERIPHERAL DEVICE WRITE FAULT"
- },
- {
- 0x03, 0x01,
- SenseDevTypes002,
- "NO WRITE CURRENT"
- },
- {
- 0x03, 0x02,
- SenseDevTypes002,
- "EXCESSIVE WRITE ERRORS"
- },
- {
- 0x04, 0x00,
- SenseDevTypes001,
- "LOGICAL UNIT NOT READY, CAUSE NOT REPORTABLE"
- },
- {
- 0x04, 0x01,
- SenseDevTypes001,
- "LOGICAL UNIT IS IN PROCESS OF BECOMING READY"
- },
- {
- 0x04, 0x02,
- SenseDevTypes001,
- "LOGICAL UNIT NOT READY, INITIALIZING CMD. REQUIRED"
- },
- {
- 0x04, 0x03,
- SenseDevTypes001,
- "LOGICAL UNIT NOT READY, MANUAL INTERVENTION REQUIRED"
- },
- {
- 0x04, 0x04,
- SenseDevTypes010,
- "LOGICAL UNIT NOT READY, FORMAT IN PROGRESS"
- },
- {
- 0x04, 0x05,
- SenseDevTypes011,
- "LOGICAL UNIT NOT READY, REBUILD IN PROGRESS"
- },
- {
- 0x04, 0x06,
- SenseDevTypes011,
- "LOGICAL UNIT NOT READY, RECALCULATION IN PROGRESS"
- },
- {
- 0x04, 0x07,
- SenseDevTypes001,
- "LOGICAL UNIT NOT READY, OPERATION IN PROGRESS"
- },
- {
- 0x04, 0x08,
- SenseDevTypes005,
- "LOGICAL UNIT NOT READY, LONG WRITE IN PROGRESS"
- },
- {
- 0x04, 0x09,
- SenseDevTypes001,
- "LOGICAL UNIT NOT READY, SELF-TEST IN PROGRESS"
- },
- {
- 0x04, 0x10,
- SenseDevTypes012,
- "auxiliary memory code 2 (99-148) [proposed]"
- },
- {
- 0x05, 0x00,
- SenseDevTypes013,
- "LOGICAL UNIT DOES NOT RESPOND TO SELECTION"
- },
- {
- 0x06, 0x00,
- SenseDevTypes008,
- "NO REFERENCE POSITION FOUND"
- },
- {
- 0x07, 0x00,
- SenseDevTypes014,
- "MULTIPLE PERIPHERAL DEVICES SELECTED"
- },
- {
- 0x08, 0x00,
- SenseDevTypes013,
- "LOGICAL UNIT COMMUNICATION FAILURE"
- },
- {
- 0x08, 0x01,
- SenseDevTypes013,
- "LOGICAL UNIT COMMUNICATION TIME-OUT"
- },
- {
- 0x08, 0x02,
- SenseDevTypes013,
- "LOGICAL UNIT COMMUNICATION PARITY ERROR"
- },
- {
- 0x08, 0x03,
- SenseDevTypes015,
- "LOGICAL UNIT COMMUNICATION CRC ERROR (ULTRA-DMA/32)"
- },
- {
- 0x08, 0x04,
- SenseDevTypes016,
- "UNREACHABLE COPY TARGET"
- },
- {
- 0x09, 0x00,
- SenseDevTypes017,
- "TRACK FOLLOWING ERROR"
- },
- {
- 0x09, 0x01,
- SenseDevTypes018,
- "TRACKING SERVO FAILURE"
- },
- {
- 0x09, 0x02,
- SenseDevTypes018,
- "FOCUS SERVO FAILURE"
- },
- {
- 0x09, 0x03,
- SenseDevTypes019,
- "SPINDLE SERVO FAILURE"
- },
- {
- 0x09, 0x04,
- SenseDevTypes017,
- "HEAD SELECT FAULT"
- },
- {
- 0x0A, 0x00,
- SenseDevTypes001,
- "ERROR LOG OVERFLOW"
- },
- {
- 0x0B, 0x00,
- SenseDevTypes001,
- "WARNING"
- },
- {
- 0x0B, 0x01,
- SenseDevTypes001,
- "WARNING - SPECIFIED TEMPERATURE EXCEEDED"
- },
- {
- 0x0B, 0x02,
- SenseDevTypes001,
- "WARNING - ENCLOSURE DEGRADED"
- },
- {
- 0x0C, 0x00,
- SenseDevTypes020,
- "WRITE ERROR"
- },
- {
- 0x0C, 0x01,
- SenseDevTypes021,
- "WRITE ERROR - RECOVERED WITH AUTO REALLOCATION"
- },
- {
- 0x0C, 0x02,
- SenseDevTypes007,
- "WRITE ERROR - AUTO REALLOCATION FAILED"
- },
- {
- 0x0C, 0x03,
- SenseDevTypes007,
- "WRITE ERROR - RECOMMEND REASSIGNMENT"
- },
- {
- 0x0C, 0x04,
- SenseDevTypes022,
- "COMPRESSION CHECK MISCOMPARE ERROR"
- },
- {
- 0x0C, 0x05,
- SenseDevTypes022,
- "DATA EXPANSION OCCURRED DURING COMPRESSION"
- },
- {
- 0x0C, 0x06,
- SenseDevTypes022,
- "BLOCK NOT COMPRESSIBLE"
- },
- {
- 0x0C, 0x07,
- SenseDevTypes005,
- "WRITE ERROR - RECOVERY NEEDED"
- },
- {
- 0x0C, 0x08,
- SenseDevTypes005,
- "WRITE ERROR - RECOVERY FAILED"
- },
- {
- 0x0C, 0x09,
- SenseDevTypes005,
- "WRITE ERROR - LOSS OF STREAMING"
- },
- {
- 0x0C, 0x0A,
- SenseDevTypes005,
- "WRITE ERROR - PADDING BLOCKS ADDED"
- },
- {
- 0x0C, 0x0B,
- SenseDevTypes012,
- "auxiliary memory code 4 (99-148) [proposed]"
- },
- {
- 0x10, 0x00,
- SenseDevTypes007,
- "ID CRC OR ECC ERROR"
- },
- {
- 0x11, 0x00,
- SenseDevTypes023,
- "UNRECOVERED READ ERROR"
- },
- {
- 0x11, 0x01,
- SenseDevTypes023,
- "READ RETRIES EXHAUSTED"
- },
- {
- 0x11, 0x02,
- SenseDevTypes023,
- "ERROR TOO LONG TO CORRECT"
- },
- {
- 0x11, 0x03,
- SenseDevTypes024,
- "MULTIPLE READ ERRORS"
- },
- {
- 0x11, 0x04,
- SenseDevTypes007,
- "UNRECOVERED READ ERROR - AUTO REALLOCATE FAILED"
- },
- {
- 0x11, 0x05,
- SenseDevTypes025,
- "L-EC UNCORRECTABLE ERROR"
- },
- {
- 0x11, 0x06,
- SenseDevTypes025,
- "CIRC UNRECOVERED ERROR"
- },
- {
- 0x11, 0x07,
- SenseDevTypes026,
- "DATA RE-SYNCHRONIZATION ERROR"
- },
- {
- 0x11, 0x08,
- SenseDevTypes002,
- "INCOMPLETE BLOCK READ"
- },
- {
- 0x11, 0x09,
- SenseDevTypes002,
- "NO GAP FOUND"
- },
- {
- 0x11, 0x0A,
- SenseDevTypes027,
- "MISCORRECTED ERROR"
- },
- {
- 0x11, 0x0B,
- SenseDevTypes007,
- "UNRECOVERED READ ERROR - RECOMMEND REASSIGNMENT"
- },
- {
- 0x11, 0x0C,
- SenseDevTypes007,
- "UNRECOVERED READ ERROR - RECOMMEND REWRITE THE DATA"
- },
- {
- 0x11, 0x0D,
- SenseDevTypes017,
- "DE-COMPRESSION CRC ERROR"
- },
- {
- 0x11, 0x0E,
- SenseDevTypes017,
- "CANNOT DECOMPRESS USING DECLARED ALGORITHM"
- },
- {
- 0x11, 0x0F,
- SenseDevTypes005,
- "ERROR READING UPC/EAN NUMBER"
- },
- {
- 0x11, 0x10,
- SenseDevTypes005,
- "ERROR READING ISRC NUMBER"
- },
- {
- 0x11, 0x11,
- SenseDevTypes005,
- "READ ERROR - LOSS OF STREAMING"
- },
- {
- 0x11, 0x12,
- SenseDevTypes012,
- "auxiliary memory code 3 (99-148) [proposed]"
- },
- {
- 0x12, 0x00,
- SenseDevTypes007,
- "ADDRESS MARK NOT FOUND FOR ID FIELD"
- },
- {
- 0x13, 0x00,
- SenseDevTypes007,
- "ADDRESS MARK NOT FOUND FOR DATA FIELD"
- },
- {
- 0x14, 0x00,
- SenseDevTypes028,
- "RECORDED ENTITY NOT FOUND"
- },
- {
- 0x14, 0x01,
- SenseDevTypes029,
- "RECORD NOT FOUND"
- },
- {
- 0x14, 0x02,
- SenseDevTypes002,
- "FILEMARK OR SETMARK NOT FOUND"
- },
- {
- 0x14, 0x03,
- SenseDevTypes002,
- "END-OF-DATA NOT FOUND"
- },
- {
- 0x14, 0x04,
- SenseDevTypes002,
- "BLOCK SEQUENCE ERROR"
- },
- {
- 0x14, 0x05,
- SenseDevTypes030,
- "RECORD NOT FOUND - RECOMMEND REASSIGNMENT"
- },
- {
- 0x14, 0x06,
- SenseDevTypes030,
- "RECORD NOT FOUND - DATA AUTO-REALLOCATED"
- },
- {
- 0x15, 0x00,
- SenseDevTypes014,
- "RANDOM POSITIONING ERROR"
- },
- {
- 0x15, 0x01,
- SenseDevTypes014,
- "MECHANICAL POSITIONING ERROR"
- },
- {
- 0x15, 0x02,
- SenseDevTypes029,
- "POSITIONING ERROR DETECTED BY READ OF MEDIUM"
- },
- {
- 0x16, 0x00,
- SenseDevTypes007,
- "DATA SYNCHRONIZATION MARK ERROR"
- },
- {
- 0x16, 0x01,
- SenseDevTypes007,
- "DATA SYNC ERROR - DATA REWRITTEN"
- },
- {
- 0x16, 0x02,
- SenseDevTypes007,
- "DATA SYNC ERROR - RECOMMEND REWRITE"
- },
- {
- 0x16, 0x03,
- SenseDevTypes007,
- "DATA SYNC ERROR - DATA AUTO-REALLOCATED"
- },
- {
- 0x16, 0x04,
- SenseDevTypes007,
- "DATA SYNC ERROR - RECOMMEND REASSIGNMENT"
- },
- {
- 0x17, 0x00,
- SenseDevTypes023,
- "RECOVERED DATA WITH NO ERROR CORRECTION APPLIED"
- },
- {
- 0x17, 0x01,
- SenseDevTypes023,
- "RECOVERED DATA WITH RETRIES"
- },
- {
- 0x17, 0x02,
- SenseDevTypes029,
- "RECOVERED DATA WITH POSITIVE HEAD OFFSET"
- },
- {
- 0x17, 0x03,
- SenseDevTypes029,
- "RECOVERED DATA WITH NEGATIVE HEAD OFFSET"
- },
- {
- 0x17, 0x04,
- SenseDevTypes025,
- "RECOVERED DATA WITH RETRIES AND/OR CIRC APPLIED"
- },
- {
- 0x17, 0x05,
- SenseDevTypes031,
- "RECOVERED DATA USING PREVIOUS SECTOR ID"
- },
- {
- 0x17, 0x06,
- SenseDevTypes007,
- "RECOVERED DATA WITHOUT ECC - DATA AUTO-REALLOCATED"
- },
- {
- 0x17, 0x07,
- SenseDevTypes031,
- "RECOVERED DATA WITHOUT ECC - RECOMMEND REASSIGNMENT"
- },
- {
- 0x17, 0x08,
- SenseDevTypes031,
- "RECOVERED DATA WITHOUT ECC - RECOMMEND REWRITE"
- },
- {
- 0x17, 0x09,
- SenseDevTypes031,
- "RECOVERED DATA WITHOUT ECC - DATA REWRITTEN"
- },
- {
- 0x18, 0x00,
- SenseDevTypes029,
- "RECOVERED DATA WITH ERROR CORRECTION APPLIED"
- },
- {
- 0x18, 0x01,
- SenseDevTypes031,
- "RECOVERED DATA WITH ERROR CORR. & RETRIES APPLIED"
- },
- {
- 0x18, 0x02,
- SenseDevTypes031,
- "RECOVERED DATA - DATA AUTO-REALLOCATED"
- },
- {
- 0x18, 0x03,
- SenseDevTypes005,
- "RECOVERED DATA WITH CIRC"
- },
- {
- 0x18, 0x04,
- SenseDevTypes005,
- "RECOVERED DATA WITH L-EC"
- },
- {
- 0x18, 0x05,
- SenseDevTypes031,
- "RECOVERED DATA - RECOMMEND REASSIGNMENT"
- },
- {
- 0x18, 0x06,
- SenseDevTypes031,
- "RECOVERED DATA - RECOMMEND REWRITE"
- },
- {
- 0x18, 0x07,
- SenseDevTypes007,
- "RECOVERED DATA WITH ECC - DATA REWRITTEN"
- },
- {
- 0x19, 0x00,
- SenseDevTypes032,
- "DEFECT LIST ERROR"
- },
- {
- 0x19, 0x01,
- SenseDevTypes032,
- "DEFECT LIST NOT AVAILABLE"
- },
- {
- 0x19, 0x02,
- SenseDevTypes032,
- "DEFECT LIST ERROR IN PRIMARY LIST"
- },
- {
- 0x19, 0x03,
- SenseDevTypes032,
- "DEFECT LIST ERROR IN GROWN LIST"
- },
- {
- 0x1A, 0x00,
- SenseDevTypes001,
- "PARAMETER LIST LENGTH ERROR"
- },
- {
- 0x1B, 0x00,
- SenseDevTypes001,
- "SYNCHRONOUS DATA TRANSFER ERROR"
- },
- {
- 0x1C, 0x00,
- SenseDevTypes033,
- "DEFECT LIST NOT FOUND"
- },
- {
- 0x1C, 0x01,
- SenseDevTypes033,
- "PRIMARY DEFECT LIST NOT FOUND"
- },
- {
- 0x1C, 0x02,
- SenseDevTypes033,
- "GROWN DEFECT LIST NOT FOUND"
- },
- {
- 0x1D, 0x00,
- SenseDevTypes029,
- "MISCOMPARE DURING VERIFY OPERATION"
- },
- {
- 0x1E, 0x00,
- SenseDevTypes007,
- "RECOVERED ID WITH ECC CORRECTION"
- },
- {
- 0x1F, 0x00,
- SenseDevTypes032,
- "PARTIAL DEFECT LIST TRANSFER"
- },
- {
- 0x20, 0x00,
- SenseDevTypes001,
- "INVALID COMMAND OPERATION CODE"
- },
- {
- 0x20, 0x01,
- SenseDevTypes012,
- "access controls code 1 (99-314) [proposed]"
- },
- {
- 0x20, 0x02,
- SenseDevTypes012,
- "access controls code 2 (99-314) [proposed]"
- },
- {
- 0x20, 0x03,
- SenseDevTypes012,
- "access controls code 3 (99-314) [proposed]"
- },
- {
- 0x21, 0x00,
- SenseDevTypes034,
- "LOGICAL BLOCK ADDRESS OUT OF RANGE"
- },
- {
- 0x21, 0x01,
- SenseDevTypes034,
- "INVALID ELEMENT ADDRESS"
- },
- {
- 0x22, 0x00,
- SenseDevTypes035,
- "ILLEGAL FUNCTION (USE 20 00, 24 00, OR 26 00)"
- },
- {
- 0x24, 0x00,
- SenseDevTypes001,
- "INVALID FIELD IN CDB"
- },
- {
- 0x24, 0x01,
- SenseDevTypes001,
- "CDB DECRYPTION ERROR"
- },
- {
- 0x25, 0x00,
- SenseDevTypes001,
- "LOGICAL UNIT NOT SUPPORTED"
- },
- {
- 0x26, 0x00,
- SenseDevTypes001,
- "INVALID FIELD IN PARAMETER LIST"
- },
- {
- 0x26, 0x01,
- SenseDevTypes001,
- "PARAMETER NOT SUPPORTED"
- },
- {
- 0x26, 0x02,
- SenseDevTypes001,
- "PARAMETER VALUE INVALID"
- },
- {
- 0x26, 0x03,
- SenseDevTypes036,
- "THRESHOLD PARAMETERS NOT SUPPORTED"
- },
- {
- 0x26, 0x04,
- SenseDevTypes001,
- "INVALID RELEASE OF PERSISTENT RESERVATION"
- },
- {
- 0x26, 0x05,
- SenseDevTypes037,
- "DATA DECRYPTION ERROR"
- },
- {
- 0x26, 0x06,
- SenseDevTypes016,
- "TOO MANY TARGET DESCRIPTORS"
- },
- {
- 0x26, 0x07,
- SenseDevTypes016,
- "UNSUPPORTED TARGET DESCRIPTOR TYPE CODE"
- },
- {
- 0x26, 0x08,
- SenseDevTypes016,
- "TOO MANY SEGMENT DESCRIPTORS"
- },
- {
- 0x26, 0x09,
- SenseDevTypes016,
- "UNSUPPORTED SEGMENT DESCRIPTOR TYPE CODE"
- },
- {
- 0x26, 0x0A,
- SenseDevTypes016,
- "UNEXPECTED INEXACT SEGMENT"
- },
- {
- 0x26, 0x0B,
- SenseDevTypes016,
- "INLINE DATA LENGTH EXCEEDED"
- },
- {
- 0x26, 0x0C,
- SenseDevTypes016,
- "INVALID OPERATION FOR COPY SOURCE OR DESTINATION"
- },
- {
- 0x26, 0x0D,
- SenseDevTypes016,
- "COPY SEGMENT GRANULARITY VIOLATION"
- },
- {
- 0x27, 0x00,
- SenseDevTypes029,
- "WRITE PROTECTED"
- },
- {
- 0x27, 0x01,
- SenseDevTypes029,
- "HARDWARE WRITE PROTECTED"
- },
- {
- 0x27, 0x02,
- SenseDevTypes029,
- "LOGICAL UNIT SOFTWARE WRITE PROTECTED"
- },
- {
- 0x27, 0x03,
- SenseDevTypes038,
- "ASSOCIATED WRITE PROTECT"
- },
- {
- 0x27, 0x04,
- SenseDevTypes038,
- "PERSISTENT WRITE PROTECT"
- },
- {
- 0x27, 0x05,
- SenseDevTypes038,
- "PERMANENT WRITE PROTECT"
- },
- {
- 0x28, 0x00,
- SenseDevTypes001,
- "NOT READY TO READY CHANGE, MEDIUM MAY HAVE CHANGED"
- },
- {
- 0x28, 0x01,
- SenseDevTypes039,
- "IMPORT OR EXPORT ELEMENT ACCESSED"
- },
- {
- 0x29, 0x00,
- SenseDevTypes001,
- "POWER ON, RESET, OR BUS DEVICE RESET OCCURRED"
- },
- {
- 0x29, 0x01,
- SenseDevTypes001,
- "POWER ON OCCURRED"
- },
- {
- 0x29, 0x02,
- SenseDevTypes001,
- "SCSI BUS RESET OCCURRED"
- },
- {
- 0x29, 0x03,
- SenseDevTypes001,
- "BUS DEVICE RESET FUNCTION OCCURRED"
- },
- {
- 0x29, 0x04,
- SenseDevTypes001,
- "DEVICE INTERNAL RESET"
- },
- {
- 0x29, 0x05,
- SenseDevTypes001,
- "TRANSCEIVER MODE CHANGED TO SINGLE-ENDED"
- },
- {
- 0x29, 0x06,
- SenseDevTypes001,
- "TRANSCEIVER MODE CHANGED TO LVD"
- },
- {
- 0x2A, 0x00,
- SenseDevTypes013,
- "PARAMETERS CHANGED"
- },
- {
- 0x2A, 0x01,
- SenseDevTypes013,
- "MODE PARAMETERS CHANGED"
- },
- {
- 0x2A, 0x02,
- SenseDevTypes040,
- "LOG PARAMETERS CHANGED"
- },
- {
- 0x2A, 0x03,
- SenseDevTypes036,
- "RESERVATIONS PREEMPTED"
- },
- {
- 0x2A, 0x04,
- SenseDevTypes041,
- "RESERVATIONS RELEASED"
- },
- {
- 0x2A, 0x05,
- SenseDevTypes041,
- "REGISTRATIONS PREEMPTED"
- },
- {
- 0x2B, 0x00,
- SenseDevTypes016,
- "COPY CANNOT EXECUTE SINCE HOST CANNOT DISCONNECT"
- },
- {
- 0x2C, 0x00,
- SenseDevTypes001,
- "COMMAND SEQUENCE ERROR"
- },
- {
- 0x2C, 0x01,
- SenseDevTypes042,
- "TOO MANY WINDOWS SPECIFIED"
- },
- {
- 0x2C, 0x02,
- SenseDevTypes042,
- "INVALID COMBINATION OF WINDOWS SPECIFIED"
- },
- {
- 0x2C, 0x03,
- SenseDevTypes005,
- "CURRENT PROGRAM AREA IS NOT EMPTY"
- },
- {
- 0x2C, 0x04,
- SenseDevTypes005,
- "CURRENT PROGRAM AREA IS EMPTY"
- },
- {
- 0x2C, 0x05,
- SenseDevTypes043,
- "ILLEGAL POWER CONDITION REQUEST"
- },
- {
- 0x2D, 0x00,
- SenseDevTypes002,
- "OVERWRITE ERROR ON UPDATE IN PLACE"
- },
- {
- 0x2E, 0x00,
- SenseDevTypes044,
- "ERROR DETECTED BY THIRD PARTY TEMPORARY INITIATOR"
- },
- {
- 0x2E, 0x01,
- SenseDevTypes044,
- "THIRD PARTY DEVICE FAILURE"
- },
- {
- 0x2E, 0x02,
- SenseDevTypes044,
- "COPY TARGET DEVICE NOT REACHABLE"
- },
- {
- 0x2E, 0x03,
- SenseDevTypes044,
- "INCORRECT COPY TARGET DEVICE TYPE"
- },
- {
- 0x2E, 0x04,
- SenseDevTypes044,
- "COPY TARGET DEVICE DATA UNDERRUN"
- },
- {
- 0x2E, 0x05,
- SenseDevTypes044,
- "COPY TARGET DEVICE DATA OVERRUN"
- },
- {
- 0x2F, 0x00,
- SenseDevTypes001,
- "COMMANDS CLEARED BY ANOTHER INITIATOR"
- },
- {
- 0x30, 0x00,
- SenseDevTypes034,
- "INCOMPATIBLE MEDIUM INSTALLED"
- },
- {
- 0x30, 0x01,
- SenseDevTypes029,
- "CANNOT READ MEDIUM - UNKNOWN FORMAT"
- },
- {
- 0x30, 0x02,
- SenseDevTypes029,
- "CANNOT READ MEDIUM - INCOMPATIBLE FORMAT"
- },
- {
- 0x30, 0x03,
- SenseDevTypes045,
- "CLEANING CARTRIDGE INSTALLED"
- },
- {
- 0x30, 0x04,
- SenseDevTypes029,
- "CANNOT WRITE MEDIUM - UNKNOWN FORMAT"
- },
- {
- 0x30, 0x05,
- SenseDevTypes029,
- "CANNOT WRITE MEDIUM - INCOMPATIBLE FORMAT"
- },
- {
- 0x30, 0x06,
- SenseDevTypes017,
- "CANNOT FORMAT MEDIUM - INCOMPATIBLE MEDIUM"
- },
- {
- 0x30, 0x07,
- SenseDevTypes006,
- "CLEANING FAILURE"
- },
- {
- 0x30, 0x08,
- SenseDevTypes005,
- "CANNOT WRITE - APPLICATION CODE MISMATCH"
- },
- {
- 0x30, 0x09,
- SenseDevTypes005,
- "CURRENT SESSION NOT FIXATED FOR APPEND"
- },
- {
- 0x31, 0x00,
- SenseDevTypes029,
- "MEDIUM FORMAT CORRUPTED"
- },
- {
- 0x31, 0x01,
- SenseDevTypes046,
- "FORMAT COMMAND FAILED"
- },
- {
- 0x32, 0x00,
- SenseDevTypes007,
- "NO DEFECT SPARE LOCATION AVAILABLE"
- },
- {
- 0x32, 0x01,
- SenseDevTypes007,
- "DEFECT LIST UPDATE FAILURE"
- },
- {
- 0x33, 0x00,
- SenseDevTypes002,
- "TAPE LENGTH ERROR"
- },
- {
- 0x34, 0x00,
- SenseDevTypes001,
- "ENCLOSURE FAILURE"
- },
- {
- 0x35, 0x00,
- SenseDevTypes001,
- "ENCLOSURE SERVICES FAILURE"
- },
- {
- 0x35, 0x01,
- SenseDevTypes001,
- "UNSUPPORTED ENCLOSURE FUNCTION"
- },
- {
- 0x35, 0x02,
- SenseDevTypes001,
- "ENCLOSURE SERVICES UNAVAILABLE"
- },
- {
- 0x35, 0x03,
- SenseDevTypes001,
- "ENCLOSURE SERVICES TRANSFER FAILURE"
- },
- {
- 0x35, 0x04,
- SenseDevTypes001,
- "ENCLOSURE SERVICES TRANSFER REFUSED"
- },
- {
- 0x36, 0x00,
- SenseDevTypes047,
- "RIBBON, INK, OR TONER FAILURE"
- },
- {
- 0x37, 0x00,
- SenseDevTypes013,
- "ROUNDED PARAMETER"
- },
- {
- 0x38, 0x00,
- SenseDevTypes043,
- "EVENT STATUS NOTIFICATION"
- },
- {
- 0x38, 0x02,
- SenseDevTypes043,
- "ESN - POWER MANAGEMENT CLASS EVENT"
- },
- {
- 0x38, 0x04,
- SenseDevTypes043,
- "ESN - MEDIA CLASS EVENT"
- },
- {
- 0x38, 0x06,
- SenseDevTypes043,
- "ESN - DEVICE BUSY CLASS EVENT"
- },
- {
- 0x39, 0x00,
- SenseDevTypes040,
- "SAVING PARAMETERS NOT SUPPORTED"
- },
- {
- 0x3A, 0x00,
- SenseDevTypes014,
- "MEDIUM NOT PRESENT"
- },
- {
- 0x3A, 0x01,
- SenseDevTypes034,
- "MEDIUM NOT PRESENT - TRAY CLOSED"
- },
- {
- 0x3A, 0x02,
- SenseDevTypes034,
- "MEDIUM NOT PRESENT - TRAY OPEN"
- },
- {
- 0x3A, 0x03,
- SenseDevTypes039,
- "MEDIUM NOT PRESENT - LOADABLE"
- },
- {
- 0x3A, 0x04,
- SenseDevTypes039,
- "MEDIUM NOT PRESENT - MEDIUM AUXILIARY MEMORY ACCESSIBLE"
- },
- {
- 0x3B, 0x00,
- SenseDevTypes048,
- "SEQUENTIAL POSITIONING ERROR"
- },
- {
- 0x3B, 0x01,
- SenseDevTypes002,
- "TAPE POSITION ERROR AT BEGINNING-OF-MEDIUM"
- },
- {
- 0x3B, 0x02,
- SenseDevTypes002,
- "TAPE POSITION ERROR AT END-OF-MEDIUM"
- },
- {
- 0x3B, 0x03,
- SenseDevTypes047,
- "TAPE OR ELECTRONIC VERTICAL FORMS UNIT NOT READY"
- },
- {
- 0x3B, 0x04,
- SenseDevTypes047,
- "SLEW FAILURE"
- },
- {
- 0x3B, 0x05,
- SenseDevTypes047,
- "PAPER JAM"
- },
- {
- 0x3B, 0x06,
- SenseDevTypes047,
- "FAILED TO SENSE TOP-OF-FORM"
- },
- {
- 0x3B, 0x07,
- SenseDevTypes047,
- "FAILED TO SENSE BOTTOM-OF-FORM"
- },
- {
- 0x3B, 0x08,
- SenseDevTypes002,
- "REPOSITION ERROR"
- },
- {
- 0x3B, 0x09,
- SenseDevTypes042,
- "READ PAST END OF MEDIUM"
- },
- {
- 0x3B, 0x0A,
- SenseDevTypes042,
- "READ PAST BEGINNING OF MEDIUM"
- },
- {
- 0x3B, 0x0B,
- SenseDevTypes042,
- "POSITION PAST END OF MEDIUM"
- },
- {
- 0x3B, 0x0C,
- SenseDevTypes003,
- "POSITION PAST BEGINNING OF MEDIUM"
- },
- {
- 0x3B, 0x0D,
- SenseDevTypes034,
- "MEDIUM DESTINATION ELEMENT FULL"
- },
- {
- 0x3B, 0x0E,
- SenseDevTypes034,
- "MEDIUM SOURCE ELEMENT EMPTY"
- },
- {
- 0x3B, 0x0F,
- SenseDevTypes005,
- "END OF MEDIUM REACHED"
- },
- {
- 0x3B, 0x11,
- SenseDevTypes034,
- "MEDIUM MAGAZINE NOT ACCESSIBLE"
- },
- {
- 0x3B, 0x12,
- SenseDevTypes034,
- "MEDIUM MAGAZINE REMOVED"
- },
- {
- 0x3B, 0x13,
- SenseDevTypes034,
- "MEDIUM MAGAZINE INSERTED"
- },
- {
- 0x3B, 0x14,
- SenseDevTypes034,
- "MEDIUM MAGAZINE LOCKED"
- },
- {
- 0x3B, 0x15,
- SenseDevTypes034,
- "MEDIUM MAGAZINE UNLOCKED"
- },
- {
- 0x3B, 0x16,
- SenseDevTypes005,
- "MECHANICAL POSITIONING OR CHANGER ERROR"
- },
- {
- 0x3D, 0x00,
- SenseDevTypes036,
- "INVALID BITS IN IDENTIFY MESSAGE"
- },
- {
- 0x3E, 0x00,
- SenseDevTypes001,
- "LOGICAL UNIT HAS NOT SELF-CONFIGURED YET"
- },
- {
- 0x3E, 0x01,
- SenseDevTypes001,
- "LOGICAL UNIT FAILURE"
- },
- {
- 0x3E, 0x02,
- SenseDevTypes001,
- "TIMEOUT ON LOGICAL UNIT"
- },
- {
- 0x3E, 0x03,
- SenseDevTypes001,
- "LOGICAL UNIT FAILED SELF-TEST"
- },
- {
- 0x3E, 0x04,
- SenseDevTypes001,
- "LOGICAL UNIT UNABLE TO UPDATE SELF-TEST LOG"
- },
- {
- 0x3F, 0x00,
- SenseDevTypes001,
- "TARGET OPERATING CONDITIONS HAVE CHANGED"
- },
- {
- 0x3F, 0x01,
- SenseDevTypes001,
- "MICROCODE HAS BEEN CHANGED"
- },
- {
- 0x3F, 0x02,
- SenseDevTypes049,
- "CHANGED OPERATING DEFINITION"
- },
- {
- 0x3F, 0x03,
- SenseDevTypes001,
- "INQUIRY DATA HAS CHANGED"
- },
- {
- 0x3F, 0x04,
- SenseDevTypes050,
- "COMPONENT DEVICE ATTACHED"
- },
- {
- 0x3F, 0x05,
- SenseDevTypes050,
- "DEVICE IDENTIFIER CHANGED"
- },
- {
- 0x3F, 0x06,
- SenseDevTypes051,
- "REDUNDANCY GROUP CREATED OR MODIFIED"
- },
- {
- 0x3F, 0x07,
- SenseDevTypes051,
- "REDUNDANCY GROUP DELETED"
- },
- {
- 0x3F, 0x08,
- SenseDevTypes051,
- "SPARE CREATED OR MODIFIED"
- },
- {
- 0x3F, 0x09,
- SenseDevTypes051,
- "SPARE DELETED"
- },
- {
- 0x3F, 0x0A,
- SenseDevTypes050,
- "VOLUME SET CREATED OR MODIFIED"
- },
- {
- 0x3F, 0x0B,
- SenseDevTypes050,
- "VOLUME SET DELETED"
- },
- {
- 0x3F, 0x0C,
- SenseDevTypes050,
- "VOLUME SET DEASSIGNED"
- },
- {
- 0x3F, 0x0D,
- SenseDevTypes050,
- "VOLUME SET REASSIGNED"
- },
- {
- 0x3F, 0x0E,
- SenseDevTypes041,
- "REPORTED LUNS DATA HAS CHANGED"
- },
- {
- 0x3F, 0x0F,
- SenseDevTypes001,
- "ECHO BUFFER OVERWRITTEN"
- },
- {
- 0x3F, 0x10,
- SenseDevTypes039,
- "MEDIUM LOADABLE"
- },
- {
- 0x3F, 0x11,
- SenseDevTypes039,
- "MEDIUM AUXILIARY MEMORY ACCESSIBLE"
- },
- {
- 0x40, 0x00,
- SenseDevTypes035,
- "RAM FAILURE (SHOULD USE 40 NN)"
- },
- {
- 0x40, 0xFF,
- SenseDevTypes001,
- "DIAGNOSTIC FAILURE ON COMPONENT NN (80H-FFH)"
- },
- {
- 0x41, 0x00,
- SenseDevTypes035,
- "DATA PATH FAILURE (SHOULD USE 40 NN)"
- },
- {
- 0x42, 0x00,
- SenseDevTypes035,
- "POWER-ON OR SELF-TEST FAILURE (SHOULD USE 40 NN)"
- },
- {
- 0x43, 0x00,
- SenseDevTypes001,
- "MESSAGE ERROR"
- },
- {
- 0x44, 0x00,
- SenseDevTypes001,
- "INTERNAL TARGET FAILURE"
- },
- {
- 0x45, 0x00,
- SenseDevTypes001,
- "SELECT OR RESELECT FAILURE"
- },
- {
- 0x46, 0x00,
- SenseDevTypes049,
- "UNSUCCESSFUL SOFT RESET"
- },
- {
- 0x47, 0x00,
- SenseDevTypes001,
- "SCSI PARITY ERROR"
- },
- {
- 0x47, 0x01,
- SenseDevTypes001,
- "DATA PHASE CRC ERROR DETECTED"
- },
- {
- 0x47, 0x02,
- SenseDevTypes001,
- "SCSI PARITY ERROR DETECTED DURING ST DATA PHASE"
- },
- {
- 0x47, 0x03,
- SenseDevTypes001,
- "INFORMATION UNIT CRC ERROR DETECTED"
- },
- {
- 0x47, 0x04,
- SenseDevTypes001,
- "ASYNCHRONOUS INFORMATION PROTECTION ERROR DETECTED"
- },
- {
- 0x48, 0x00,
- SenseDevTypes001,
- "INITIATOR DETECTED ERROR MESSAGE RECEIVED"
- },
- {
- 0x49, 0x00,
- SenseDevTypes001,
- "INVALID MESSAGE ERROR"
- },
- {
- 0x4A, 0x00,
- SenseDevTypes001,
- "COMMAND PHASE ERROR"
- },
- {
- 0x4B, 0x00,
- SenseDevTypes001,
- "DATA PHASE ERROR"
- },
- {
- 0x4C, 0x00,
- SenseDevTypes001,
- "LOGICAL UNIT FAILED SELF-CONFIGURATION"
- },
- {
- 0x4D, 0xFF,
- SenseDevTypes001,
- "TAGGED OVERLAPPED COMMANDS (NN = QUEUE TAG)"
- },
- {
- 0x4E, 0x00,
- SenseDevTypes001,
- "OVERLAPPED COMMANDS ATTEMPTED"
- },
- {
- 0x50, 0x00,
- SenseDevTypes002,
- "WRITE APPEND ERROR"
- },
- {
- 0x50, 0x01,
- SenseDevTypes002,
- "WRITE APPEND POSITION ERROR"
- },
- {
- 0x50, 0x02,
- SenseDevTypes002,
- "POSITION ERROR RELATED TO TIMING"
- },
- {
- 0x51, 0x00,
- SenseDevTypes052,
- "ERASE FAILURE"
- },
- {
- 0x52, 0x00,
- SenseDevTypes002,
- "CARTRIDGE FAULT"
- },
- {
- 0x53, 0x00,
- SenseDevTypes014,
- "MEDIA LOAD OR EJECT FAILED"
- },
- {
- 0x53, 0x01,
- SenseDevTypes002,
- "UNLOAD TAPE FAILURE"
- },
- {
- 0x53, 0x02,
- SenseDevTypes034,
- "MEDIUM REMOVAL PREVENTED"
- },
- {
- 0x54, 0x00,
- SenseDevTypes053,
- "SCSI TO HOST SYSTEM INTERFACE FAILURE"
- },
- {
- 0x55, 0x00,
- SenseDevTypes053,
- "SYSTEM RESOURCE FAILURE"
- },
- {
- 0x55, 0x01,
- SenseDevTypes033,
- "SYSTEM BUFFER FULL"
- },
- {
- 0x55, 0x02,
- SenseDevTypes054,
- "INSUFFICIENT RESERVATION RESOURCES"
- },
- {
- 0x55, 0x03,
- SenseDevTypes041,
- "INSUFFICIENT RESOURCES"
- },
- {
- 0x55, 0x04,
- SenseDevTypes055,
- "INSUFFICIENT REGISTRATION RESOURCES"
- },
- {
- 0x55, 0x05,
- SenseDevTypes012,
- "access controls code 4 (99-314) [proposed]"
- },
- {
- 0x55, 0x06,
- SenseDevTypes012,
- "auxiliary memory code 1 (99-148) [proposed]"
- },
- {
- 0x57, 0x00,
- SenseDevTypes005,
- "UNABLE TO RECOVER TABLE-OF-CONTENTS"
- },
- {
- 0x58, 0x00,
- SenseDevTypes056,
- "GENERATION DOES NOT EXIST"
- },
- {
- 0x59, 0x00,
- SenseDevTypes056,
- "UPDATED BLOCK READ"
- },
- {
- 0x5A, 0x00,
- SenseDevTypes057,
- "OPERATOR REQUEST OR STATE CHANGE INPUT"
- },
- {
- 0x5A, 0x01,
- SenseDevTypes034,
- "OPERATOR MEDIUM REMOVAL REQUEST"
- },
- {
- 0x5A, 0x02,
- SenseDevTypes058,
- "OPERATOR SELECTED WRITE PROTECT"
- },
- {
- 0x5A, 0x03,
- SenseDevTypes058,
- "OPERATOR SELECTED WRITE PERMIT"
- },
- {
- 0x5B, 0x00,
- SenseDevTypes059,
- "LOG EXCEPTION"
- },
- {
- 0x5B, 0x01,
- SenseDevTypes059,
- "THRESHOLD CONDITION MET"
- },
- {
- 0x5B, 0x02,
- SenseDevTypes059,
- "LOG COUNTER AT MAXIMUM"
- },
- {
- 0x5B, 0x03,
- SenseDevTypes059,
- "LOG LIST CODES EXHAUSTED"
- },
- {
- 0x5C, 0x00,
- SenseDevTypes060,
- "RPL STATUS CHANGE"
- },
- {
- 0x5C, 0x01,
- SenseDevTypes060,
- "SPINDLES SYNCHRONIZED"
- },
- {
- 0x5C, 0x02,
- SenseDevTypes060,
- "SPINDLES NOT SYNCHRONIZED"
- },
- {
- 0x5D, 0x00,
- SenseDevTypes001,
- "FAILURE PREDICTION THRESHOLD EXCEEDED"
- },
- {
- 0x5D, 0x01,
- SenseDevTypes061,
- "MEDIA FAILURE PREDICTION THRESHOLD EXCEEDED"
- },
- {
- 0x5D, 0x02,
- SenseDevTypes005,
- "LOGICAL UNIT FAILURE PREDICTION THRESHOLD EXCEEDED"
- },
- {
- 0x5D, 0x10,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x11,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x12,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x13,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x14,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x15,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x16,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x17,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x18,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x19,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x1A,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x1B,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x1C,
- SenseDevTypes062,
- "HARDWARE IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0x20,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x21,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x22,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x23,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x24,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x25,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x26,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x27,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x28,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x29,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x2A,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x2B,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x2C,
- SenseDevTypes062,
- "CONTROLLER IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0x30,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x31,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x32,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x33,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x34,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x35,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x36,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x37,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x38,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x39,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x3A,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x3B,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x3C,
- SenseDevTypes062,
- "DATA CHANNEL IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0x40,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x41,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x42,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x43,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x44,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x45,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x46,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x47,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x48,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x49,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x4A,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x4B,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x4C,
- SenseDevTypes062,
- "SERVO IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0x50,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x51,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x52,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x53,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x54,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x55,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x56,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x57,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x58,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x59,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x5A,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x5B,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x5C,
- SenseDevTypes062,
- "SPINDLE IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0x60,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE GENERAL HARD DRIVE FAILURE"
- },
- {
- 0x5D, 0x61,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE DRIVE ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x62,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE DATA ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x63,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE SEEK ERROR RATE TOO HIGH"
- },
- {
- 0x5D, 0x64,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE TOO MANY BLOCK REASSIGNS"
- },
- {
- 0x5D, 0x65,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE ACCESS TIMES TOO HIGH"
- },
- {
- 0x5D, 0x66,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE START UNIT TIMES TOO HIGH"
- },
- {
- 0x5D, 0x67,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE CHANNEL PARAMETRICS"
- },
- {
- 0x5D, 0x68,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE CONTROLLER DETECTED"
- },
- {
- 0x5D, 0x69,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE THROUGHPUT PERFORMANCE"
- },
- {
- 0x5D, 0x6A,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE SEEK TIME PERFORMANCE"
- },
- {
- 0x5D, 0x6B,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE SPIN-UP RETRY COUNT"
- },
- {
- 0x5D, 0x6C,
- SenseDevTypes062,
- "FIRMWARE IMPENDING FAILURE DRIVE CALIBRATION RETRY COUNT"
- },
- {
- 0x5D, 0xFF,
- SenseDevTypes001,
- "FAILURE PREDICTION THRESHOLD EXCEEDED (FALSE)"
- },
- {
- 0x5E, 0x00,
- SenseDevTypes044,
- "LOW POWER CONDITION ON"
- },
- {
- 0x5E, 0x01,
- SenseDevTypes044,
- "IDLE CONDITION ACTIVATED BY TIMER"
- },
- {
- 0x5E, 0x02,
- SenseDevTypes044,
- "STANDBY CONDITION ACTIVATED BY TIMER"
- },
- {
- 0x5E, 0x03,
- SenseDevTypes044,
- "IDLE CONDITION ACTIVATED BY COMMAND"
- },
- {
- 0x5E, 0x04,
- SenseDevTypes044,
- "STANDBY CONDITION ACTIVATED BY COMMAND"
- },
- {
- 0x5E, 0x41,
- SenseDevTypes043,
- "POWER STATE CHANGE TO ACTIVE"
- },
- {
- 0x5E, 0x42,
- SenseDevTypes043,
- "POWER STATE CHANGE TO IDLE"
- },
- {
- 0x5E, 0x43,
- SenseDevTypes043,
- "POWER STATE CHANGE TO STANDBY"
- },
- {
- 0x5E, 0x45,
- SenseDevTypes043,
- "POWER STATE CHANGE TO SLEEP"
- },
- {
- 0x5E, 0x47,
- SenseDevTypes063,
- "POWER STATE CHANGE TO DEVICE CONTROL"
- },
- {
- 0x60, 0x00,
- SenseDevTypes042,
- "LAMP FAILURE"
- },
- {
- 0x61, 0x00,
- SenseDevTypes042,
- "VIDEO ACQUISITION ERROR"
- },
- {
- 0x61, 0x01,
- SenseDevTypes042,
- "UNABLE TO ACQUIRE VIDEO"
- },
- {
- 0x61, 0x02,
- SenseDevTypes042,
- "OUT OF FOCUS"
- },
- {
- 0x62, 0x00,
- SenseDevTypes042,
- "SCAN HEAD POSITIONING ERROR"
- },
- {
- 0x63, 0x00,
- SenseDevTypes005,
- "END OF USER AREA ENCOUNTERED ON THIS TRACK"
- },
- {
- 0x63, 0x01,
- SenseDevTypes005,
- "PACKET DOES NOT FIT IN AVAILABLE SPACE"
- },
- {
- 0x64, 0x00,
- SenseDevTypes005,
- "ILLEGAL MODE FOR THIS TRACK"
- },
- {
- 0x64, 0x01,
- SenseDevTypes005,
- "INVALID PACKET SIZE"
- },
- {
- 0x65, 0x00,
- SenseDevTypes001,
- "VOLTAGE FAULT"
- },
- {
- 0x66, 0x00,
- SenseDevTypes042,
- "AUTOMATIC DOCUMENT FEEDER COVER UP"
- },
- {
- 0x66, 0x01,
- SenseDevTypes042,
- "AUTOMATIC DOCUMENT FEEDER LIFT UP"
- },
- {
- 0x66, 0x02,
- SenseDevTypes042,
- "DOCUMENT JAM IN AUTOMATIC DOCUMENT FEEDER"
- },
- {
- 0x66, 0x03,
- SenseDevTypes042,
- "DOCUMENT MISS FEED AUTOMATIC IN DOCUMENT FEEDER"
- },
- {
- 0x67, 0x00,
- SenseDevTypes064,
- "CONFIGURATION FAILURE"
- },
- {
- 0x67, 0x01,
- SenseDevTypes064,
- "CONFIGURATION OF INCAPABLE LOGICAL UNITS FAILED"
- },
- {
- 0x67, 0x02,
- SenseDevTypes064,
- "ADD LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x03,
- SenseDevTypes064,
- "MODIFICATION OF LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x04,
- SenseDevTypes064,
- "EXCHANGE OF LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x05,
- SenseDevTypes064,
- "REMOVE OF LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x06,
- SenseDevTypes064,
- "ATTACHMENT OF LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x07,
- SenseDevTypes064,
- "CREATION OF LOGICAL UNIT FAILED"
- },
- {
- 0x67, 0x08,
- SenseDevTypes064,
- "ASSIGN FAILURE OCCURRED"
- },
- {
- 0x67, 0x09,
- SenseDevTypes064,
- "MULTIPLY ASSIGNED LOGICAL UNIT"
- },
- {
- 0x68, 0x00,
- SenseDevTypes064,
- "LOGICAL UNIT NOT CONFIGURED"
- },
- {
- 0x69, 0x00,
- SenseDevTypes064,
- "DATA LOSS ON LOGICAL UNIT"
- },
- {
- 0x69, 0x01,
- SenseDevTypes064,
- "MULTIPLE LOGICAL UNIT FAILURES"
- },
- {
- 0x69, 0x02,
- SenseDevTypes064,
- "PARITY/DATA MISMATCH"
- },
- {
- 0x6A, 0x00,
- SenseDevTypes064,
- "INFORMATIONAL, REFER TO LOG"
- },
- {
- 0x6B, 0x00,
- SenseDevTypes064,
- "STATE CHANGE HAS OCCURRED"
- },
- {
- 0x6B, 0x01,
- SenseDevTypes064,
- "REDUNDANCY LEVEL GOT BETTER"
- },
- {
- 0x6B, 0x02,
- SenseDevTypes064,
- "REDUNDANCY LEVEL GOT WORSE"
- },
- {
- 0x6C, 0x00,
- SenseDevTypes064,
- "REBUILD FAILURE OCCURRED"
- },
- {
- 0x6D, 0x00,
- SenseDevTypes064,
- "RECALCULATE FAILURE OCCURRED"
- },
- {
- 0x6E, 0x00,
- SenseDevTypes064,
- "COMMAND TO LOGICAL UNIT FAILED"
- },
- {
- 0x6F, 0x00,
- SenseDevTypes005,
- "COPY PROTECTION KEY EXCHANGE FAILURE - AUTHENTICATION FAILURE"
- },
- {
- 0x6F, 0x01,
- SenseDevTypes005,
- "COPY PROTECTION KEY EXCHANGE FAILURE - KEY NOT PRESENT"
- },
- {
- 0x6F, 0x02,
- SenseDevTypes005,
- "COPY PROTECTION KEY EXCHANGE FAILURE - KEY NOT ESTABLISHED"
- },
- {
- 0x6F, 0x03,
- SenseDevTypes005,
- "READ OF SCRAMBLED SECTOR WITHOUT AUTHENTICATION"
- },
- {
- 0x6F, 0x04,
- SenseDevTypes005,
- "MEDIA REGION CODE IS MISMATCHED TO LOGICAL UNIT REGION"
- },
- {
- 0x6F, 0x05,
- SenseDevTypes005,
- "DRIVE REGION MUST BE PERMANENT/REGION RESET COUNT ERROR"
- },
- {
- 0x70, 0xFF,
- SenseDevTypes002,
- "DECOMPRESSION EXCEPTION SHORT ALGORITHM ID OF NN"
- },
- {
- 0x71, 0x00,
- SenseDevTypes002,
- "DECOMPRESSION EXCEPTION LONG ALGORITHM ID"
- },
- {
- 0x72, 0x00,
- SenseDevTypes005,
- "SESSION FIXATION ERROR"
- },
- {
- 0x72, 0x01,
- SenseDevTypes005,
- "SESSION FIXATION ERROR WRITING LEAD-IN"
- },
- {
- 0x72, 0x02,
- SenseDevTypes005,
- "SESSION FIXATION ERROR WRITING LEAD-OUT"
- },
- {
- 0x72, 0x03,
- SenseDevTypes005,
- "SESSION FIXATION ERROR - INCOMPLETE TRACK IN SESSION"
- },
- {
- 0x72, 0x04,
- SenseDevTypes005,
- "EMPTY OR PARTIALLY WRITTEN RESERVED TRACK"
- },
- {
- 0x72, 0x05,
- SenseDevTypes005,
- "NO MORE TRACK RESERVATIONS ALLOWED"
- },
- {
- 0x73, 0x00,
- SenseDevTypes005,
- "CD CONTROL ERROR"
- },
- {
- 0x73, 0x01,
- SenseDevTypes005,
- "POWER CALIBRATION AREA ALMOST FULL"
- },
- {
- 0x73, 0x02,
- SenseDevTypes005,
- "POWER CALIBRATION AREA IS FULL"
- },
- {
- 0x73, 0x03,
- SenseDevTypes005,
- "POWER CALIBRATION AREA ERROR"
- },
- {
- 0x73, 0x04,
- SenseDevTypes005,
- "PROGRAM MEMORY AREA UPDATE FAILURE"
- },
- {
- 0x73, 0x05,
- SenseDevTypes005,
- "PROGRAM MEMORY AREA IS FULL"
- },
- {
- 0x73, 0x06,
- SenseDevTypes005,
- "RMA/PMA IS FULL"
- },
-};
-
-static int ASCQ_TableSize = 463;
-
-
-#endif
+++ /dev/null
-#!/bin/sh
-#
-# ascq_tbl.sh - Translate SCSI t10.org's "asc-num.txt" file of
-# SCSI Additional Sense Code & Qualifiers (ASC/ASCQ's)
-# into something useful in C, creating "ascq_tbl.c" file.
-#
-#*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*#
-
-PREF_INFILE="t10.org/asc-num.txt" # From SCSI t10.org
-PREF_OUTFILE="ascq_tbl.c"
-
-#*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*#
-
-xlate_ascq() {
- cat | awk '
- BEGIN {
- DQ = "\042";
- OUTFILE = "'"${PREF_OUTFILE}"'";
- TRUE = 1;
- FALSE = 0;
- #debug = TRUE;
-
- # read and discard all lines up to and including the one that begins
- # with the "magic token" of "------- -------------- ---"...
- headers_gone = FALSE;
- while (!headers_gone) {
- if (getline <= 0)
- exit 1;
- header_line[++hdrs] = $0;
- if (debug)
- printf("header_line[%d] = :%s:\n", ++hdrs, $0);
- if ($0 ~ /^------- -------------- ---/) {
- headers_gone = TRUE;
- }
- }
- outcount = 0;
- }
-
- (NF > 1) {
- ++outcount;
- if (debug)
- printf( "DBG: %s\n", $0 );
- ASC[outcount] = substr($0,1,2);
- ASCQ[outcount] = substr($0,5,2);
- devtypes = substr($0,10,14);
- gsub(/ /, ".", devtypes);
- DESCRIP[outcount] = substr($0,26);
-
- if (!(devtypes in DevTypesVoodoo)) {
- DevTypesVoodoo[devtypes] = ++voodoo;
- DevTypesIdx[voodoo] = devtypes;
- }
- DEVTYPES[outcount] = DevTypesVoodoo[devtypes];
-
- # Handle 0xNN exception stuff...
- if (ASCQ[outcount] == "NN" || ASCQ[outcount] == "nn")
- ASCQ[outcount] = "FF";
- }
-
- END {
- printf("#ifndef SCSI_ASCQ_TBL_C_INCLUDED\n") > OUTFILE;
- printf("#define SCSI_ASCQ_TBL_C_INCLUDED\n") >> OUTFILE;
-
- printf("\n/* AuToMaGiCaLlY generated from: %s'"${FIN}"'%s\n", DQ, DQ) >> OUTFILE;
- printf(" *******************************************************************************\n") >> OUTFILE;
- for (i=1; i<=hdrs; i++) {
- printf(" * %s\n", header_line[i]) >> OUTFILE;
- }
- printf(" */\n") >> OUTFILE;
-
- printf("\n") >> OUTFILE;
- for (i=1; i<=voodoo; i++) {
- printf("static char SenseDevTypes%03d[] = %s%s%s;\n", i, DQ, DevTypesIdx[i], DQ) >> OUTFILE;
- }
-
- printf("\nstatic ASCQ_Table_t ASCQ_Table[] = {\n") >> OUTFILE;
- for (i=1; i<=outcount; i++) {
- printf(" {\n") >> OUTFILE;
- printf(" 0x%s, 0x%s,\n", ASC[i], ASCQ[i]) >> OUTFILE;
- printf(" SenseDevTypes%03d,\n", DEVTYPES[i]) >> OUTFILE;
- printf(" %s%s%s\n", DQ, DESCRIP[i], DQ) >> OUTFILE;
- printf(" },\n") >> OUTFILE;
- }
- printf( "};\n\n" ) >> OUTFILE;
-
- printf( "static int ASCQ_TableSize = %d;\n\n", outcount ) >> OUTFILE;
- printf( "Total of %d ASC/ASCQ records generated\n", outcount );
- printf("\n#endif\n") >> OUTFILE;
- close(OUTFILE);
- }'
- return
-}
-
-#*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*#
-
-# main()
-if [ $# -lt 1 ]; then
- echo "INFO: No input filename supplied - using: $PREF_INFILE" >&2
- FIN=$PREF_INFILE
-else
- FIN="$1"
- if [ "$FIN" != "$PREF_INFILE" ]; then
- echo "INFO: Ok, I'll try chewing on '$FIN' for SCSI ASC/ASCQ combos..." >&2
- fi
- shift
-fi
-
-cat $FIN | xlate_ascq
-exit 0
+++ /dev/null
-/*
- * linux/drivers/message/fusion/isense.c
- * Little linux driver / shim that interfaces with the Fusion MPT
- * Linux base driver to provide english readable strings in SCSI
- * Error Report logging output. This module implements SCSI-3
- * Opcode lookup and a sorted table of SCSI-3 ASC/ASCQ strings.
- *
- * Copyright (c) 1991-2004 Steven J. Ralston
- * Written By: Steven J. Ralston
- * (yes I wrote some of the orig. code back in 1991!)
- * (mailto:sjralston1@netscape.net)
- * (mailto:mpt_linux_developer@lsil.com)
- *
- * $Id: isense.c,v 1.33 2002/02/27 18:44:19 sralston Exp $
- */
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- NO WARRANTY
- THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
- LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
- solely responsible for determining the appropriateness of using and
- distributing the Program and assumes all risks associated with its
- exercise of rights under this Agreement, including but not limited to
- the risks and costs of program errors, damage to or loss of data,
- programs or equipment, and unavailability or interruption of operations.
-
- DISCLAIMER OF LIABILITY
- NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
- HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-
-#include <linux/version.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <asm/io.h>
-
-#define MODULEAUTHOR "Steven J. Ralston"
-#define COPYRIGHT "Copyright (c) 2001-2004 " MODULEAUTHOR
-#include "mptbase.h"
-
-#include "isense.h"
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- * Private data...
- */
-
-/*
- * YIKES! I don't usually #include C source files, but..
- * The following #include's pulls in our needed ASCQ_Table[] array,
- * ASCQ_TableSz integer, and ScsiOpcodeString[] array!
- */
-#include "ascq_tbl.c"
-#include "scsiops.c"
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-#define my_NAME "SCSI-3 Opcodes & ASC/ASCQ Strings"
-#define my_VERSION MPT_LINUX_VERSION_COMMON
-#define MYNAM "isense"
-
-MODULE_AUTHOR(MODULEAUTHOR);
-MODULE_DESCRIPTION(my_NAME);
-MODULE_LICENSE("GPL");
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-int __init isense_init(void)
-{
- show_mptmod_ver(my_NAME, my_VERSION);
-
- /*
- * Install our handler
- */
- if (mpt_register_ascqops_strings(&ASCQ_Table[0], ASCQ_TableSize, ScsiOpcodeString) != 1)
- {
- printk(KERN_ERR MYNAM ": ERROR: Can't register with Fusion MPT base driver!\n");
- return -EBUSY;
- }
- printk(KERN_INFO MYNAM ": Registered SCSI-3 Opcodes & ASC/ASCQ Strings\n");
- return 0;
-}
-
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-static void isense_exit(void)
-{
-#ifdef MODULE
- mpt_deregister_ascqops_strings();
-#endif
- printk(KERN_INFO MYNAM ": Deregistered SCSI-3 Opcodes & ASC/ASCQ Strings\n");
-}
-
-module_init(isense_init);
-module_exit(isense_exit);
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-
+++ /dev/null
-#ifndef ISENSE_H_INCLUDED
-#define ISENSE_H_INCLUDED
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-
-#ifdef __KERNEL__
-#include <linux/types.h> /* needed for u8, etc. */
-#include <linux/string.h> /* needed for strcat */
-#include <linux/kernel.h> /* needed for sprintf */
-#else
- #ifndef U_STUFF_DEFINED
- #define U_STUFF_DEFINED
- typedef unsigned char u8;
- typedef unsigned short u16;
- typedef unsigned int u32;
- #endif
-#endif
-
-#include "scsi3.h" /* needed for all things SCSI */
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- * Defines and typedefs...
- */
-
-#ifdef __KERNEL__
-#define PrintF(x) printk x
-#else
-#define PrintF(x) printf x
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#define RETRY_STATUS ((int) 1)
-#define PUT_STATUS ((int) 0)
-
-/*
- * A generic structure to hold info about IO request that caused
- * a Request Sense to be performed, and the resulting Sense Data.
- */
-typedef struct IO_Info
-{
- char *DevIDStr; /* String of chars which identifies the device. */
- u8 *cdbPtr; /* Pointer (Virtual/Logical addr) to CDB bytes of
- IO request that caused ContAllegianceCond. */
- u8 *sensePtr; /* Pointer (Virtual/Logical addr) to Sense Data
- returned by Request Sense operation. */
- u8 *dataPtr; /* Pointer (Virtual/Logical addr) to Data buffer
- of IO request caused ContAllegianceCondition. */
- u8 *inqPtr; /* Pointer (Virtual/Logical addr) to Inquiry Data for
- IO *Device* that caused ContAllegianceCondition. */
- u8 SCSIStatus; /* SCSI status byte of IO request that caused
- Contingent Allegiance Condition. */
- u8 DoDisplay; /* Shall we display any messages? */
- u16 rsvd_align1;
- u32 ComplCode; /* Four-byte OS-dependent completion code. */
- u32 NotifyL; /* Four-byte OS-dependent notification field. */
-} IO_Info_t;
-
-/*
- * SCSI Additional Sense Code and Additional Sense Code Qualifier table.
- */
-typedef struct ASCQ_Table
-{
- u8 ASC;
- u8 ASCQ;
- char *DevTypes;
- char *Description;
-} ASCQ_Table_t;
-
-#if 0
-/*
- * SCSI Opcodes table.
- */
-typedef struct SCSI_OPS_Table
-{
- u8 OpCode;
- char *DevTypes;
- char *ScsiCmndStr;
-} SCSI_OPS_Table_t;
-#endif
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-/*
- * Public entry point prototypes
- */
-
-/* in scsiherr.c, needed by mptscsih.c */
-extern int mpt_ScsiHost_ErrorReport(IO_Info_t *ioop);
-
-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-#endif
-
+++ /dev/null
-/*
- * linux/drivers/message/fusion/scsi3.h
- * SCSI-3 definitions and macros.
- * (Ultimately) SCSI-3 definitions; for now, inheriting
- * SCSI-2 definitions.
- *
- * Copyright (c) 1996-2004 Steven J. Ralston
- * Written By: Steven J. Ralston (19960517)
- * (mailto:sjralston1@netscape.net)
- * (mailto:mpt_linux_developer@lsil.com)
- *
- * $Id: scsi3.h,v 1.9 2002/02/27 18:45:02 sralston Exp $
- */
-
-#ifndef SCSI3_H_INCLUDED
-#define SCSI3_H_INCLUDED
-/***************************************************************************/
-
-/****************************************************************************
- *
- * Includes
- */
-#ifdef __KERNEL__
-#include <linux/types.h>
-#else
- #ifndef U_STUFF_DEFINED
- #define U_STUFF_DEFINED
- typedef unsigned char u8;
- typedef unsigned short u16;
- typedef unsigned int u32;
- #endif
-#endif
-
-/****************************************************************************
- *
- * Defines
- */
-
-/*
- * SCSI Commands
- */
-#define CMD_TestUnitReady 0x00
-#define CMD_RezeroUnit 0x01 /* direct-access devices */
-#define CMD_Rewind 0x01 /* sequential-access devices */
-#define CMD_RequestSense 0x03
-#define CMD_FormatUnit 0x04
-#define CMD_ReassignBlock 0x07
-#define CMD_Read6 0x08
-#define CMD_Write6 0x0A
-#define CMD_WriteFilemark 0x10
-#define CMD_Space 0x11
-#define CMD_Inquiry 0x12
-#define CMD_ModeSelect6 0x15
-#define CMD_ModeSense6 0x1A
-#define CMD_Reserve6 0x16
-#define CMD_Release6 0x17
-#define CMD_Erase 0x19
-#define CMD_StartStopUnit 0x1b /* direct-access devices */
-#define CMD_LoadUnload 0x1b /* sequential-access devices */
-#define CMD_ReceiveDiagnostic 0x1C
-#define CMD_SendDiagnostic 0x1D
-#define CMD_ReadCapacity 0x25
-#define CMD_Read10 0x28
-#define CMD_Write10 0x2A
-#define CMD_WriteVerify 0x2E
-#define CMD_Verify 0x2F
-#define CMD_SynchronizeCache 0x35
-#define CMD_ReadDefectData 0x37
-#define CMD_WriteBuffer 0x3B
-#define CMD_ReadBuffer 0x3C
-#define CMD_ReadLong 0x3E
-#define CMD_LogSelect 0x4C
-#define CMD_LogSense 0x4D
-#define CMD_ModeSelect10 0x55
-#define CMD_Reserve10 0x56
-#define CMD_Release10 0x57
-#define CMD_ModeSense10 0x5A
-#define CMD_PersistReserveIn 0x5E
-#define CMD_PersistReserveOut 0x5F
-#define CMD_ReportLuns 0xA0
-
-/*
- * Control byte field
- */
-#define CONTROL_BYTE_NACA_BIT 0x04
-#define CONTROL_BYTE_Flag_BIT 0x02
-#define CONTROL_BYTE_Link_BIT 0x01
-
-/*
- * SCSI Messages
- */
-#define MSG_COMPLETE 0x00
-#define MSG_EXTENDED 0x01
-#define MSG_SAVE_POINTERS 0x02
-#define MSG_RESTORE_POINTERS 0x03
-#define MSG_DISCONNECT 0x04
-#define MSG_IDERROR 0x05
-#define MSG_ABORT 0x06
-#define MSG_REJECT 0x07
-#define MSG_NOP 0x08
-#define MSG_PARITY_ERROR 0x09
-#define MSG_LINKED_CMD_COMPLETE 0x0a
-#define MSG_LCMD_COMPLETE_W_FLG 0x0b
-#define MSG_BUS_DEVICE_RESET 0x0c
-#define MSG_ABORT_TAG 0x0d
-#define MSG_CLEAR_QUEUE 0x0e
-#define MSG_INITIATE_RECOVERY 0x0f
-
-#define MSG_RELEASE_RECOVRY 0x10
-#define MSG_TERMINATE_IO 0x11
-
-#define MSG_SIMPLE_QUEUE 0x20
-#define MSG_HEAD_OF_QUEUE 0x21
-#define MSG_ORDERED_QUEUE 0x22
-#define MSG_IGNORE_WIDE_RESIDUE 0x23
-
-#define MSG_IDENTIFY 0x80
-#define MSG_IDENTIFY_W_DISC 0xc0
-
-/*
- * SCSI Phases
- */
-#define PHS_DATA_OUT 0x00
-#define PHS_DATA_IN 0x01
-#define PHS_COMMAND 0x02
-#define PHS_STATUS 0x03
-#define PHS_MSG_OUT 0x06
-#define PHS_MSG_IN 0x07
-
-/*
- * Statuses
- */
-#define STS_GOOD 0x00
-#define STS_CHECK_CONDITION 0x02
-#define STS_CONDITION_MET 0x04
-#define STS_BUSY 0x08
-#define STS_INTERMEDIATE 0x10
-#define STS_INTERMEDIATE_CONDITION_MET 0x14
-#define STS_RESERVATION_CONFLICT 0x18
-#define STS_COMMAND_TERMINATED 0x22
-#define STS_TASK_SET_FULL 0x28
-#define STS_QUEUE_FULL 0x28
-#define STS_ACA_ACTIVE 0x30
-
-#define STS_VALID_MASK 0x3e
-
-#define SCSI_STATUS(x) ((x) & STS_VALID_MASK)
-
-/*
- * SCSI QTag Types
- */
-#define QTAG_SIMPLE 0x20
-#define QTAG_HEAD_OF_Q 0x21
-#define QTAG_ORDERED 0x22
-
-/*
- * SCSI Sense Key Definitons
- */
-#define SK_NO_SENSE 0x00
-#define SK_RECOVERED_ERROR 0x01
-#define SK_NOT_READY 0x02
-#define SK_MEDIUM_ERROR 0x03
-#define SK_HARDWARE_ERROR 0x04
-#define SK_ILLEGAL_REQUEST 0x05
-#define SK_UNIT_ATTENTION 0x06
-#define SK_DATA_PROTECT 0x07
-#define SK_BLANK_CHECK 0x08
-#define SK_VENDOR_SPECIFIC 0x09
-#define SK_COPY_ABORTED 0x0a
-#define SK_ABORTED_COMMAND 0x0b
-#define SK_EQUAL 0x0c
-#define SK_VOLUME_OVERFLOW 0x0d
-#define SK_MISCOMPARE 0x0e
-#define SK_RESERVED 0x0f
-
-
-
-#define SCSI_MAX_INQUIRY_BYTES 96
-#define SCSI_STD_INQUIRY_BYTES 36
-
-#undef USE_SCSI_COMPLETE_INQDATA
-/*
- * Structure definition for SCSI Inquiry Data
- *
- * NOTE: The following structure is 96 bytes in size
- * iff USE_SCSI_COMPLETE_INQDATA IS defined above (i.e. w/ "#define").
- * If USE_SCSI_COMPLETE_INQDATA is NOT defined above (i.e. w/ "#undef")
- * then the following structure is only 36 bytes in size.
- * THE CHOICE IS YOURS!
- */
-typedef struct SCSI_Inquiry_Data
-{
-#ifdef USE_SCSI_COMPLETE_INQDATA
- u8 InqByte[SCSI_MAX_INQUIRY_BYTES];
-#else
- u8 InqByte[SCSI_STD_INQUIRY_BYTES];
-#endif
-
-/*
- * the following structure works only for little-endian (Intel,
- * LSB first (1234) byte order) systems with 4-byte ints.
- *
- u32 Periph_Device_Type : 5,
- Periph_Qualifier : 3,
- Device_Type_Modifier : 7,
- Removable_Media : 1,
- ANSI_Version : 3,
- ECMA_Version : 3,
- ISO_Version : 2,
- Response_Data_Format : 4,
- reserved_0 : 3,
- AERC : 1 ;
- u32 Additional_Length : 8,
- reserved_1 :16,
- SftReset : 1,
- CmdQue : 1,
- reserved_2 : 1,
- Linked : 1,
- Sync : 1,
- WBus16 : 1,
- WBus32 : 1,
- RelAdr : 1 ;
- u8 Vendor_ID[8];
- u8 Product_ID[16];
- u8 Revision_Level [4];
-#ifdef USE_SCSI_COMPLETE_INQDATA
- u8 Vendor_Specific[20];
- u8 reserved_3[40];
-#endif
- *
- */
-
-} SCSI_Inquiry_Data_t;
-
-#define INQ_PERIPHINFO_BYTE 0
-#define INQ_Periph_Qualifier_MASK 0xe0
-#define INQ_Periph_Device_Type_MASK 0x1f
-
-#define INQ_Peripheral_Qualifier(inqp) \
- (int)((*((u8*)(inqp)+INQ_PERIPHINFO_BYTE) & INQ_Periph_Qualifier_MASK) >> 5)
-#define INQ_Peripheral_Device_Type(inqp) \
- (int)(*((u8*)(inqp)+INQ_PERIPHINFO_BYTE) & INQ_Periph_Device_Type_MASK)
-
-
-#define INQ_DEVTYPEMOD_BYTE 1
-#define INQ_RMB_BIT 0x80
-#define INQ_Device_Type_Modifier_MASK 0x7f
-
-#define INQ_Removable_Medium(inqp) \
- (int)(*((u8*)(inqp)+INQ_DEVTYPEMOD_BYTE) & INQ_RMB_BIT)
-#define INQ_Device_Type_Modifier(inqp) \
- (int)(*((u8*)(inqp)+INQ_DEVTYPEMOD_BYTE) & INQ_Device_Type_Modifier_MASK)
-
-
-#define INQ_VERSIONINFO_BYTE 2
-#define INQ_ISO_Version_MASK 0xc0
-#define INQ_ECMA_Version_MASK 0x38
-#define INQ_ANSI_Version_MASK 0x07
-
-#define INQ_ISO_Version(inqp) \
- (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ISO_Version_MASK)
-#define INQ_ECMA_Version(inqp) \
- (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ECMA_Version_MASK)
-#define INQ_ANSI_Version(inqp) \
- (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ANSI_Version_MASK)
-
-
-#define INQ_BYTE3 3
-#define INQ_AERC_BIT 0x80
-#define INQ_TrmTsk_BIT 0x40
-#define INQ_NormACA_BIT 0x20
-#define INQ_RDF_MASK 0x0F
-
-#define INQ_AER_Capable(inqp) \
- (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_AERC_BIT)
-#define INQ_TrmTsk(inqp) \
- (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_TrmTsk_BIT)
-#define INQ_NormACA(inqp) \
- (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_NormACA_BIT)
-#define INQ_Response_Data_Format(inqp) \
- (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_RDF_MASK)
-
-
-#define INQ_CAPABILITY_BYTE 7
-#define INQ_RelAdr_BIT 0x80
-#define INQ_WBus32_BIT 0x40
-#define INQ_WBus16_BIT 0x20
-#define INQ_Sync_BIT 0x10
-#define INQ_Linked_BIT 0x08
- /* INQ_Reserved BIT 0x40 */
-#define INQ_CmdQue_BIT 0x02
-#define INQ_SftRe_BIT 0x01
-
-#define IS_RelAdr_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_RelAdr_BIT)
-#define IS_WBus32_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_WBus32_BIT)
-#define IS_WBus16_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_WBus16_BIT)
-#define IS_Sync_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Sync_BIT)
-#define IS_Linked_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Linked_BIT)
-#define IS_CmdQue_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_CmdQue_BIT)
-#define IS_SftRe_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_SftRe_BIT)
-
-#define INQ_Width_BITS \
- (INQ_WBus32_BIT | INQ_WBus16_BIT)
-#define IS_Wide_DEV(inqp) \
- (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Width_BITS)
-
-
-/*
- * SCSI peripheral device types
- */
-#define SCSI_TYPE_DAD 0x00 /* Direct Access Device */
-#define SCSI_TYPE_SAD 0x01 /* Sequential Access Device */
-#define SCSI_TYPE_TAPE SCSI_TYPE_SAD
-#define SCSI_TYPE_PRT 0x02 /* Printer */
-#define SCSI_TYPE_PROC 0x03 /* Processor */
-#define SCSI_TYPE_WORM 0x04
-#define SCSI_TYPE_CDROM 0x05
-#define SCSI_TYPE_SCAN 0x06 /* Scanner */
-#define SCSI_TYPE_OPTICAL 0x07 /* Magneto/Optical */
-#define SCSI_TYPE_CHANGER 0x08
-#define SCSI_TYPE_COMM 0x09 /* Communications device */
-#define SCSI_TYPE_UNKNOWN 0x1f
-#define SCSI_TYPE_UNCONFIGURED_LUN 0x7f
-
-#define SCSI_TYPE_MAX_KNOWN SCSI_TYPE_COMM
-
-/*
- * Peripheral Qualifiers
- */
-#define DEVICE_PRESENT 0x00
-#define LUN_NOT_PRESENT 0x01
-#define LUN_NOT_SUPPORTED 0x03
-
-/*
- * ANSI Versions
- */
-#ifndef SCSI_1
-#define SCSI_1 0x01
-#endif
-#ifndef SCSI_2
-#define SCSI_2 0x02
-#endif
-#ifndef SCSI_3
-#define SCSI_3 0x03
-#endif
-
-
-#define SCSI_MAX_SENSE_BYTES 255
-#define SCSI_STD_SENSE_BYTES 18
-#define SCSI_PAD_SENSE_BYTES (SCSI_MAX_SENSE_BYTES - SCSI_STD_SENSE_BYTES)
-
-#undef USE_SCSI_COMPLETE_SENSE
-/*
- * Structure definition for SCSI Sense Data
- *
- * NOTE: The following structure is 255 bytes in size
- * iiff USE_SCSI_COMPLETE_SENSE IS defined above (i.e. w/ "#define").
- * If USE_SCSI_COMPLETE_SENSE is NOT defined above (i.e. w/ "#undef")
- * then the following structure is only 19 bytes in size.
- * THE CHOICE IS YOURS!
- *
- */
-typedef struct SCSI_Sense_Data
-{
-#ifdef USE_SCSI_COMPLETE_SENSE
- u8 SenseByte[SCSI_MAX_SENSE_BYTES];
-#else
- u8 SenseByte[SCSI_STD_SENSE_BYTES];
-#endif
-
-/*
- * the following structure works only for little-endian (Intel,
- * LSB first (1234) byte order) systems with 4-byte ints.
- *
- u8 Error_Code :4, // 0x00
- Error_Class :3,
- Valid :1
- ;
- u8 Segment_Number // 0x01
- ;
- u8 Sense_Key :4, // 0x02
- Reserved :1,
- Incorrect_Length_Indicator:1,
- End_Of_Media :1,
- Filemark :1
- ;
- u8 Information_MSB; // 0x03
- u8 Information_Byte2; // 0x04
- u8 Information_Byte1; // 0x05
- u8 Information_LSB; // 0x06
- u8 Additional_Length; // 0x07
-
- u32 Command_Specific_Information; // 0x08 - 0x0b
-
- u8 Additional_Sense_Code; // 0x0c
- u8 Additional_Sense_Code_Qualifier; // 0x0d
- u8 Field_Replaceable_Unit_Code; // 0x0e
- u8 Illegal_Req_Bit_Pointer :3, // 0x0f
- Illegal_Req_Bit_Valid :1,
- Illegal_Req_Reserved :2,
- Illegal_Req_Cmd_Data :1,
- Sense_Key_Specific_Valid :1
- ;
- u16 Sense_Key_Specific_Data; // 0x10 - 0x11
-
-#ifdef USE_SCSI_COMPLETE_SENSE
- u8 Additional_Sense_Data[SCSI_PAD_SENSE_BYTES];
-#else
- u8 Additional_Sense_Data[1];
-#endif
- *
- */
-
-} SCSI_Sense_Data_t;
-
-
-#define SD_ERRCODE_BYTE 0
-#define SD_Valid_BIT 0x80
-#define SD_Error_Code_MASK 0x7f
-#define SD_Valid(sdp) \
- (int)(*((u8*)(sdp)+SD_ERRCODE_BYTE) & SD_Valid_BIT)
-#define SD_Error_Code(sdp) \
- (int)(*((u8*)(sdp)+SD_ERRCODE_BYTE) & SD_Error_Code_MASK)
-
-
-#define SD_SEGNUM_BYTE 1
-#define SD_Segment_Number(sdp) (int)(*((u8*)(sdp)+SD_SEGNUM_BYTE))
-
-
-#define SD_SENSEKEY_BYTE 2
-#define SD_Filemark_BIT 0x80
-#define SD_EOM_BIT 0x40
-#define SD_ILI_BIT 0x20
-#define SD_Sense_Key_MASK 0x0f
-#define SD_Filemark(sdp) \
- (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_Filemark_BIT)
-#define SD_EOM(sdp) \
- (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_EOM_BIT)
-#define SD_ILI(sdp) \
- (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_ILI_BIT)
-#define SD_Sense_Key(sdp) \
- (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_Sense_Key_MASK)
-
-
-#define SD_INFO3_BYTE 3
-#define SD_INFO2_BYTE 4
-#define SD_INFO1_BYTE 5
-#define SD_INFO0_BYTE 6
-#define SD_Information3(sdp) (int)(*((u8*)(sdp)+SD_INFO3_BYTE))
-#define SD_Information2(sdp) (int)(*((u8*)(sdp)+SD_INFO2_BYTE))
-#define SD_Information1(sdp) (int)(*((u8*)(sdp)+SD_INFO1_BYTE))
-#define SD_Information0(sdp) (int)(*((u8*)(sdp)+SD_INFO0_BYTE))
-
-
-#define SD_ADDL_LEN_BYTE 7
-#define SD_Additional_Sense_Length(sdp) \
- (int)(*((u8*)(sdp)+SD_ADDL_LEN_BYTE))
-#define SD_Addl_Sense_Len SD_Additional_Sense_Length
-
-
-#define SD_CMD_SPECIFIC3_BYTE 8
-#define SD_CMD_SPECIFIC2_BYTE 9
-#define SD_CMD_SPECIFIC1_BYTE 10
-#define SD_CMD_SPECIFIC0_BYTE 11
-#define SD_Cmd_Specific_Info3(sdp) (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC3_BYTE))
-#define SD_Cmd_Specific_Info2(sdp) (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC2_BYTE))
-#define SD_Cmd_Specific_Info1(sdp) (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC1_BYTE))
-#define SD_Cmd_Specific_Info0(sdp) (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC0_BYTE))
-
-
-#define SD_ADDL_SENSE_CODE_BYTE 12
-#define SD_Additional_Sense_Code(sdp) \
- (int)(*((u8*)(sdp)+SD_ADDL_SENSE_CODE_BYTE))
-#define SD_Addl_Sense_Code SD_Additional_Sense_Code
-#define SD_ASC SD_Additional_Sense_Code
-
-
-#define SD_ADDL_SENSE_CODE_QUAL_BYTE 13
-#define SD_Additional_Sense_Code_Qualifier(sdp) \
- (int)(*((u8*)(sdp)+SD_ADDL_SENSE_CODE_QUAL_BYTE))
-#define SD_Addl_Sense_Code_Qual SD_Additional_Sense_Code_Qualifier
-#define SD_ASCQ SD_Additional_Sense_Code_Qualifier
-
-
-#define SD_FIELD_REPL_UNIT_CODE_BYTE 14
-#define SD_Field_Replaceable_Unit_Code(sdp) \
- (int)(*((u8*)(sdp)+SD_FIELD_REPL_UNIT_CODE_BYTE))
-#define SD_Field_Repl_Unit_Code SD_Field_Replaceable_Unit_Code
-#define SD_FRUC SD_Field_Replaceable_Unit_Code
-#define SD_FRU SD_Field_Replaceable_Unit_Code
-
-
-/*
- * Sense-Key Specific offsets and macros.
- */
-#define SD_SKS2_BYTE 15
-#define SD_SKS_Valid_BIT 0x80
-#define SD_SKS_Cmd_Data_BIT 0x40
-#define SD_SKS_Bit_Ptr_Valid_BIT 0x08
-#define SD_SKS_Bit_Ptr_MASK 0x07
-#define SD_SKS1_BYTE 16
-#define SD_SKS0_BYTE 17
-#define SD_Sense_Key_Specific_Valid(sdp) \
- (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Valid_BIT)
-#define SD_SKS_Valid SD_Sense_Key_Specific_Valid
-#define SD_SKS_CDB_Error(sdp) \
- (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Cmd_Data_BIT)
-#define SD_Was_Illegal_Request SD_SKS_CDB_Error
-#define SD_SKS_Bit_Pointer_Valid(sdp) \
- (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Bit_Ptr_Valid_BIT)
-#define SD_SKS_Bit_Pointer(sdp) \
- (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Bit_Ptr_MASK)
-#define SD_Field_Pointer(sdp) \
- (int)( ((u16)(*((u8*)(sdp)+SD_SKS1_BYTE)) << 8) \
- + *((u8*)(sdp)+SD_SKS0_BYTE) )
-#define SD_Bad_Byte SD_Field_Pointer
-#define SD_Actual_Retry_Count SD_Field_Pointer
-#define SD_Progress_Indication SD_Field_Pointer
-
-/*
- * Mode Sense Write Protect Mask
- */
-#define WRITE_PROTECT_MASK 0X80
-
-/*
- * Medium Type Codes
- */
-#define OPTICAL_DEFAULT 0x00
-#define OPTICAL_READ_ONLY_MEDIUM 0x01
-#define OPTICAL_WRITE_ONCE_MEDIUM 0x02
-#define OPTICAL_READ_WRITABLE_MEDIUM 0x03
-#define OPTICAL_RO_OR_WO_MEDIUM 0x04
-#define OPTICAL_RO_OR_RW_MEDIUM 0x05
-#define OPTICAL_WO_OR_RW_MEDIUM 0x06
-
-
-
-/*
- * Structure definition for READ6, WRITE6 (6-byte CDB)
- */
-typedef struct SCSI_RW6_CDB
-{
- u32 OpCode :8,
- LBA_HI :5, /* 5 MSBit's of the LBA */
- Lun :3,
- LBA_MID :8, /* NOTE: total of 21 bits in LBA */
- LBA_LO :8 ; /* Max LBA = 0x001fffff */
- u8 BlockCount;
- u8 Control;
-} SCSI_RW6_t;
-
-#define MAX_RW6_LBA ((u32)0x001fffff)
-
-/*
- * Structure definition for READ10, WRITE10 (10-byte CDB)
- *
- * NOTE: ParityCheck bit is applicable only for VERIFY and WRITE VERIFY for
- * the ADP-92 DAC only. In the SCSI2 spec. this same bit is defined as a
- * FUA (forced unit access) bit for READs and WRITEs. Since this driver
- * does not use the FUA, this bit is defined as it is used by the ADP-92.
- * Also, for READ CAPACITY, only the OpCode field is used.
- */
-typedef struct SCSI_RW10_CDB
-{
- u8 OpCode;
- u8 Reserved1;
- u32 LBA;
- u8 Reserved2;
- u16 BlockCount;
- u8 Control;
-} SCSI_RW10_t;
-
-#define PARITY_CHECK 0x08 /* parity check bit - byte[1], bit 3 */
-
- /*
- * Structure definition for data returned by READ CAPACITY cmd;
- * READ CAPACITY data
- */
- typedef struct READ_CAP_DATA
- {
- u32 MaxLBA;
- u32 BlockBytes;
- } SCSI_READ_CAP_DATA_t, *pSCSI_READ_CAP_DATA_t;
-
-
-/*
- * Structure definition for FORMAT UNIT CDB (6-byte CDB)
- */
-typedef struct _SCSI_FORMAT_UNIT
-{
- u8 OpCode;
- u8 Reserved1;
- u8 VendorSpecific;
- u16 Interleave;
- u8 Control;
-} SCSI_FORMAT_UNIT_t;
-
-/*
- * Structure definition for REQUEST SENSE (6-byte CDB)
- */
-typedef struct _SCSI_REQUEST_SENSE
-{
- u8 OpCode;
- u8 Reserved1;
- u8 Reserved2;
- u8 Reserved3;
- u8 AllocLength;
- u8 Control;
-} SCSI_REQ_SENSE_t;
-
-/*
- * Structure definition for REPORT LUNS (12-byte CDB)
- */
-typedef struct _SCSI_REPORT_LUNS
-{
- u8 OpCode;
- u8 Reserved1[5];
- u32 AllocationLength;
- u8 Reserved2;
- u8 Control;
-} SCSI_REPORT_LUNS_t, *pSCSI_REPORT_LUNS_t;
-
- /*
- * (per-level) LUN information bytes
- */
-/*
- * Following doesn't work on ARMCC compiler
- * [apparently] because it pads every struct
- * to be multiple of 4 bytes!
- * So SCSI_LUN_LEVELS_t winds up being 16
- * bytes instead of 8!
- *
- typedef struct LUN_INFO
- {
- u8 AddrMethod_plus_LunOrBusNumber;
- u8 LunOrTarget;
- } SCSI_LUN_INFO_t, *pSCSI_LUN_INFO_t;
-
- typedef struct LUN_LEVELS
- {
- SCSI_LUN_INFO_t LUN_0;
- SCSI_LUN_INFO_t LUN_1;
- SCSI_LUN_INFO_t LUN_2;
- SCSI_LUN_INFO_t LUN_3;
- } SCSI_LUN_LEVELS_t, *pSCSI_LUN_LEVELS_t;
-*/
- /*
- * All 4 levels (8 bytes) of LUN information
- */
- typedef struct LUN_LEVELS
- {
- u8 LVL1_AddrMethod_plus_LunOrBusNumber;
- u8 LVL1_LunOrTarget;
- u8 LVL2_AddrMethod_plus_LunOrBusNumber;
- u8 LVL2_LunOrTarget;
- u8 LVL3_AddrMethod_plus_LunOrBusNumber;
- u8 LVL3_LunOrTarget;
- u8 LVL4_AddrMethod_plus_LunOrBusNumber;
- u8 LVL4_LunOrTarget;
- } SCSI_LUN_LEVELS_t, *pSCSI_LUN_LEVELS_t;
-
- /*
- * Structure definition for data returned by REPORT LUNS cmd;
- * LUN reporting parameter list format
- */
- typedef struct LUN_REPORT
- {
- u32 LunListLength;
- u32 Reserved;
- SCSI_LUN_LEVELS_t LunInfo[1];
- } SCSI_LUN_REPORT_t, *pSCSI_LUN_REPORT_t;
-
-/****************************************************************************
- *
- * Externals
- */
-
-/****************************************************************************
- *
- * Public Typedefs & Related Defines
- */
-
-/****************************************************************************
- *
- * Macros (embedded, above)
- */
-
-/****************************************************************************
- *
- * Public Variables
- */
-
-/****************************************************************************
- *
- * Public Prototypes (module entry points)
- */
-
-
-/***************************************************************************/
-#endif
+++ /dev/null
-
-static const char *ScsiOpcodeString[256] = {
- "TEST UNIT READY\0\01", /* 00h */
- "REWIND\0\002"
- "\001REZERO UNIT", /* 01h */
- "\0\0", /* 02h */
- "REQUEST SENSE\0\01", /* 03h */
- "FORMAT UNIT\0\03"
- "\001FORMAT MEDIUM\0"
- "\002FORMAT", /* 04h */
- "READ BLOCK LIMITS\0\1", /* 05h */
- "\0\0", /* 06h */
- "REASSIGN BLOCKS\0\02"
- "\010INITIALIZE ELEMENT STATUS", /* 07h */
- "READ(06)\0\04"
- "\001READ\0"
- "\003RECEIVE\0"
- "\011GET MESSAGE(06)", /* 08h */
- "\0\0", /* 09h */
- "WRITE(06)\0\05"
- "\001WRITE\0"
- "\002PRINT\0"
- "\003SEND(6)\0"
- "\011SEND MESSAGE(06)", /* 0Ah */
- "SEEK(06)\0\02"
- "\003SLEW AND PRINT", /* 0Bh */
- "\0\0", /* 0Ch */
- "\0\0", /* 0Dh */
- "\0\0", /* 0Eh */
- "READ REVERSE\0\01", /* 0Fh */
- "WRITE FILEMARKS\0\02"
- "\003SYNCRONIZE BUFFER", /* 10h */
- "SPACE(6)\0\01", /* 11h */
- "INQUIRY\0\01", /* 12h */
- "VERIFY\0\01", /* 13h */
- "RECOVER BUFFERED DATA\0\01", /* 14h */
- "MODE SELECT(06)\0\01", /* 15h */
- "RESERVE(06)\0\02"
- "\010RESERVE ELEMENT(06)", /* 16h */
- "RELEASE(06)\0\02"
- "\010RELEASE ELEMENT(06)", /* 17h */
- "COPY\0\01", /* 18h */
- "ERASE\0\01", /* 19h */
- "MODE SENSE(06)\0\01", /* 1Ah */
- "STOP START UNIT\0\04"
- "\001LOAD UNLOAD\0"
- "\002STOP PRINT\0"
- "\006SCAN\0\002", /* 1Bh */
- "RECEIVE DIAGNOSTIC RESULTS\0\01", /* 1Ch */
- "SEND DIAGNOSTIC\0\01", /* 1Dh */
- "PREVENT ALLOW MEDIUM REMOVAL\0\01", /* 1Eh */
- "\0\0", /* 1Fh */
- "\0\0", /* 20h */
- "\0\0", /* 21h */
- "\0\0", /* 22h */
- "READ FORMAT CAPACITIES\0\01", /* 23h */
- "SET WINDOW\0\01", /* 24h */
- "READ CAPACITY\0\03"
- "\006GET WINDOW\0"
- "\037FREAD CARD CAPACITY", /* 25h */
- "\0\0", /* 26h */
- "\0\0", /* 27h */
- "READ(10)\0\02"
- "\011GET MESSAGE(10)", /* 28h */
- "READ GENERATION\0\01", /* 29h */
- "WRITE(10)\0\03"
- "\011SEND(10)\0"
- "\011SEND MESSAGE(10)", /* 2Ah */
- "SEEK(10)\0\03"
- "LOCATE(10)\0"
- "POSITION TO ELEMENT", /* 2Bh */
- "ERASE(10)\0\01", /* 2Ch */
- "READ UPDATED BLOCK\0\01", /* 2Dh */
- "WRITE AND VERIFY(10)\0\01", /* 2Eh */
- "VERIFY(10)\0\01", /* 2Fh */
- "SEARCH DATA HIGH(10)\0\01", /* 30h */
- "SEARCH DATA EQUAL(10)\0\02"
- "OBJECT POSITION", /* 31h */
- "SEARCH DATA LOW(10)\0\01", /* 32h */
- "SET LIMITS(10)\0\01", /* 33h */
- "PRE-FETCH(10)\0\03"
- "READ POSITION\0"
- "GET DATA BUFFER STATUS", /* 34h */
- "SYNCHRONIZE CACHE(10)\0\01", /* 35h */
- "LOCK UNLOCK CACHE(10)\0\01", /* 36h */
- "READ DEFECT DATA(10)\0\01", /* 37h */
- "MEDIUM SCAN\0\01", /* 38h */
- "COMPARE\0\01", /* 39h */
- "COPY AND VERIFY\0\01", /* 3Ah */
- "WRITE BUFFER\0\01", /* 3Bh */
- "READ BUFFER\0\01", /* 3Ch */
- "UPDATE BLOCK\0\01", /* 3Dh */
- "READ LONG\0\01", /* 3Eh */
- "WRITE LONG\0\01", /* 3Fh */
- "CHANGE DEFINITION\0\01", /* 40h */
- "WRITE SAME(10)\0\01", /* 41h */
- "READ SUB-CHANNEL\0\01", /* 42h */
- "READ TOC/PMA/ATIP\0\01", /* 43h */
- "REPORT DENSITY SUPPORT\0\01", /* 44h */
- "READ HEADER\0\01", /* 44h */
- "PLAY AUDIO(10)\0\01", /* 45h */
- "GET CONFIGURATION\0\01", /* 46h */
- "PLAY AUDIO MSF\0\01", /* 47h */
- "PLAY AUDIO TRACK INDEX\0\01", /* 48h */
- "PLAY TRACK RELATIVE(10)\0\01", /* 49h */
- "GET EVENT STATUS NOTIFICATION\0\01", /* 4Ah */
- "PAUSE/RESUME\0\01", /* 4Bh */
- "LOG SELECT\0\01", /* 4Ch */
- "LOG SENSE\0\01", /* 4Dh */
- "STOP PLAY/SCAN\0\01", /* 4Eh */
- "\0\0", /* 4Fh */
- "XDWRITE(10)\0\01", /* 50h */
- "XPWRITE(10)\0\02"
- "READ DISC INFORMATION", /* 51h */
- "XDREAD(10)\0\01"
- "READ TRACK INFORMATION", /* 52h */
- "RESERVE TRACK\0\01", /* 53h */
- "SEND OPC INFORMATION\0\01", /* 54h */
- "MODE SELECT(10)\0\01", /* 55h */
- "RESERVE(10)\0\02"
- "RESERVE ELEMENT(10)", /* 56h */
- "RELEASE(10)\0\02"
- "RELEASE ELEMENT(10)", /* 57h */
- "REPAIR TRACK\0\01", /* 58h */
- "READ MASTER CUE\0\01", /* 59h */
- "MODE SENSE(10)\0\01", /* 5Ah */
- "CLOSE TRACK/SESSION\0\01", /* 5Bh */
- "READ BUFFER CAPACITY\0\01", /* 5Ch */
- "SEND CUE SHEET\0\01", /* 5Dh */
- "PERSISTENT RESERVE IN\0\01", /* 5Eh */
- "PERSISTENT RESERVE OUT\0\01", /* 5Fh */
- "\0\0", /* 60h */
- "\0\0", /* 61h */
- "\0\0", /* 62h */
- "\0\0", /* 63h */
- "\0\0", /* 64h */
- "\0\0", /* 65h */
- "\0\0", /* 66h */
- "\0\0", /* 67h */
- "\0\0", /* 68h */
- "\0\0", /* 69h */
- "\0\0", /* 6Ah */
- "\0\0", /* 6Bh */
- "\0\0", /* 6Ch */
- "\0\0", /* 6Dh */
- "\0\0", /* 6Eh */
- "\0\0", /* 6Fh */
- "\0\0", /* 70h */
- "\0\0", /* 71h */
- "\0\0", /* 72h */
- "\0\0", /* 73h */
- "\0\0", /* 74h */
- "\0\0", /* 75h */
- "\0\0", /* 76h */
- "\0\0", /* 77h */
- "\0\0", /* 78h */
- "\0\0", /* 79h */
- "\0\0", /* 7Ah */
- "\0\0", /* 7Bh */
- "\0\0", /* 7Ch */
- "\0\0", /* 7Eh */
- "\0\0", /* 7Eh */
- "\0\0", /* 7Fh */
- "XDWRITE EXTENDED(16)\0\01", /* 80h */
- "REBUILD(16)\0\01", /* 81h */
- "REGENERATE(16)\0\01", /* 82h */
- "EXTENDED COPY\0\01", /* 83h */
- "RECEIVE COPY RESULTS\0\01", /* 84h */
- "ACCESS CONTROL IN [proposed]\0\01", /* 86h */
- "ACCESS CONTROL OUT [proposed]\0\01", /* 87h */
- "READ(16)\0\01", /* 88h */
- "DEVICE LOCKS [proposed]\0\01", /* 89h */
- "WRITE(16)\0\01", /* 8Ah */
- "\0\0", /* 8Bh */
- "READ ATTRIBUTES [proposed]\0\01", /* 8Ch */
- "WRITE ATTRIBUTES [proposed]\0\01", /* 8Dh */
- "WRITE AND VERIFY(16)\0\01", /* 8Eh */
- "VERIFY(16)\0\01", /* 8Fh */
- "PRE-FETCH(16)\0\01", /* 90h */
- "SYNCHRONIZE CACHE(16)\0\02"
- "SPACE(16) [1]", /* 91h */
- "LOCK UNLOCK CACHE(16)\0\02"
- "LOCATE(16) [1]", /* 92h */
- "WRITE SAME(16)\0\01", /* 93h */
- "[usage proposed by SCSI Socket Services project]\0\01", /* 94h */
- "[usage proposed by SCSI Socket Services project]\0\01", /* 95h */
- "[usage proposed by SCSI Socket Services project]\0\01", /* 96h */
- "[usage proposed by SCSI Socket Services project]\0\01", /* 97h */
- "MARGIN CONTROL [proposed]\0\01", /* 98h */
- "\0\0", /* 99h */
- "\0\0", /* 9Ah */
- "\0\0", /* 9Bh */
- "\0\0", /* 9Ch */
- "\0\0", /* 9Dh */
- "SERVICE ACTION IN [proposed]\0\01", /* 9Eh */
- "SERVICE ACTION OUT [proposed]\0\01", /* 9Fh */
- "REPORT LUNS\0\01", /* A0h */
- "BLANK\0\01", /* A1h */
- "SEND EVENT\0\01", /* A2h */
- "MAINTENANCE (IN)\0\02"
- "SEND KEY", /* A3h */
- "MAINTENANCE (OUT)\0\02"
- "REPORT KEY", /* A4h */
- "MOVE MEDIUM\0\02"
- "PLAY AUDIO(12)", /* A5h */
- "EXCHANGE MEDIUM\0\02"
- "LOAD/UNLOAD C/DVD", /* A6h */
- "MOVE MEDIUM ATTACHED\0\02"
- "SET READ AHEAD\0\01", /* A7h */
- "READ(12)\0\02"
- "GET MESSAGE(12)", /* A8h */
- "PLAY TRACK RELATIVE(12)\0\01", /* A9h */
- "WRITE(12)\0\02"
- "SEND MESSAGE(12)", /* AAh */
- "\0\0", /* ABh */
- "ERASE(12)\0\02"
- "GET PERFORMANCE", /* ACh */
- "READ DVD STRUCTURE\0\01", /* ADh */
- "WRITE AND VERIFY(12)\0\01", /* AEh */
- "VERIFY(12)\0\01", /* AFh */
- "SEARCH DATA HIGH(12)\0\01", /* B0h */
- "SEARCH DATA EQUAL(12)\0\01", /* B1h */
- "SEARCH DATA LOW(12)\0\01", /* B2h */
- "SET LIMITS(12)\0\01", /* B3h */
- "READ ELEMENT STATUS ATTACHED\0\01", /* B4h */
- "REQUEST VOLUME ELEMENT ADDRESS\0\01", /* B5h */
- "SEND VOLUME TAG\0\02"
- "SET STREAMING", /* B6h */
- "READ DEFECT DATA(12)\0\01", /* B7h */
- "READ ELEMENT STATUS\0\01", /* B8h */
- "READ CD MSF\0\01", /* B9h */
- "REDUNDANCY GROUP (IN)\0\02"
- "SCAN", /* BAh */
- "REDUNDANCY GROUP (OUT)\0\02"
- "SET CD-ROM SPEED", /* BBh */
- "SPARE (IN)\0\02"
- "PLAY CD", /* BCh */
- "SPARE (OUT)\0\02"
- "MECHANISM STATUS", /* BDh */
- "VOLUME SET (IN)\0\02"
- "READ CD", /* BEh */
- "VOLUME SET (OUT)\0\0\02"
- "SEND DVD STRUCTURE", /* BFh */
- "\0\0", /* C0h */
- "\0\0", /* C1h */
- "\0\0", /* C2h */
- "\0\0", /* C3h */
- "\0\0", /* C4h */
- "\0\0", /* C5h */
- "\0\0", /* C6h */
- "\0\0", /* C7h */
- "\0\0", /* C8h */
- "\0\0", /* C9h */
- "\0\0", /* CAh */
- "\0\0", /* CBh */
- "\0\0", /* CCh */
- "\0\0", /* CDh */
- "\0\0", /* CEh */
- "\0\0", /* CFh */
- "\0\0", /* D0h */
- "\0\0", /* D1h */
- "\0\0", /* D2h */
- "\0\0", /* D3h */
- "\0\0", /* D4h */
- "\0\0", /* D5h */
- "\0\0", /* D6h */
- "\0\0", /* D7h */
- "\0\0", /* D8h */
- "\0\0", /* D9h */
- "\0\0", /* DAh */
- "\0\0", /* DBh */
- "\0\0", /* DCh */
- "\0\0", /* DEh */
- "\0\0", /* DEh */
- "\0\0", /* DFh */
- "\0\0", /* E0h */
- "\0\0", /* E1h */
- "\0\0", /* E2h */
- "\0\0", /* E3h */
- "\0\0", /* E4h */
- "\0\0", /* E5h */
- "\0\0", /* E6h */
- "\0\0", /* E7h */
- "\0\0", /* E8h */
- "\0\0", /* E9h */
- "\0\0", /* EAh */
- "\0\0", /* EBh */
- "\0\0", /* ECh */
- "\0\0", /* EDh */
- "\0\0", /* EEh */
- "\0\0", /* EFh */
- "\0\0", /* F0h */
- "\0\0", /* F1h */
- "\0\0", /* F2h */
- "\0\0", /* F3h */
- "\0\0", /* F4h */
- "\0\0", /* F5h */
- "\0\0", /* F6h */
- "\0\0", /* F7h */
- "\0\0", /* F8h */
- "\0\0", /* F9h */
- "\0\0", /* FAh */
- "\0\0", /* FBh */
- "\0\0", /* FEh */
- "\0\0", /* FEh */
- "\0\0", /* FEh */
- "\0\0" /* FFh */
-};
-
+++ /dev/null
-/*
- * Core I2O structure management
- *
- * (C) Copyright 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * A lot of the I2O message side code from this is taken from the
- * Red Creek RCPCI45 adapter driver by Red Creek Communications
- *
- * Fixes/additions:
- * Philipp Rumpf
- * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
- * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
- * Deepak Saxena <deepak@plexity.net>
- * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- * Alan Cox <alan@redhat.com>:
- * Ported to Linux 2.5.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor fixes for 2.6.
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-
-#include <linux/i2o.h>
-
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
-
-#include <linux/bitops.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/sched.h>
-#include <asm/semaphore.h>
-#include <linux/completion.h>
-#include <linux/workqueue.h>
-
-#include <asm/io.h>
-#include <linux/reboot.h>
-#ifdef CONFIG_MTRR
-#include <asm/mtrr.h>
-#endif // CONFIG_MTRR
-
-#include "i2o_lan.h"
-
-//#define DRIVERDEBUG
-
-#ifdef DRIVERDEBUG
-#define dprintk(s, args...) printk(s, ## args)
-#else
-#define dprintk(s, args...)
-#endif
-
-/* OSM table */
-static struct i2o_handler *i2o_handlers[MAX_I2O_MODULES];
-
-/* Controller list */
-static struct i2o_controller *i2o_controllers[MAX_I2O_CONTROLLERS];
-struct i2o_controller *i2o_controller_chain;
-int i2o_num_controllers;
-
-/* Initiator Context for Core message */
-static int core_context;
-
-/* Initialization && shutdown functions */
-void i2o_sys_init(void);
-static void i2o_sys_shutdown(void);
-static int i2o_reset_controller(struct i2o_controller *);
-static int i2o_reboot_event(struct notifier_block *, unsigned long , void *);
-static int i2o_online_controller(struct i2o_controller *);
-static int i2o_init_outbound_q(struct i2o_controller *);
-static int i2o_post_outbound_messages(struct i2o_controller *);
-
-/* Reply handler */
-static void i2o_core_reply(struct i2o_handler *, struct i2o_controller *,
- struct i2o_message *);
-
-/* Various helper functions */
-static int i2o_lct_get(struct i2o_controller *);
-static int i2o_lct_notify(struct i2o_controller *);
-static int i2o_hrt_get(struct i2o_controller *);
-
-static int i2o_build_sys_table(void);
-static int i2o_systab_send(struct i2o_controller *c);
-
-/* I2O core event handler */
-static int i2o_core_evt(void *);
-static int evt_pid;
-static int evt_running;
-
-/* Dynamic LCT update handler */
-static int i2o_dyn_lct(void *);
-
-void i2o_report_controller_unit(struct i2o_controller *, struct i2o_device *);
-
-static void i2o_pci_dispose(struct i2o_controller *c);
-
-/*
- * I2O System Table. Contains information about
- * all the IOPs in the system. Used to inform IOPs
- * about each other's existence.
- *
- * sys_tbl_ver is the CurrentChangeIndicator that is
- * used by IOPs to track changes.
- */
-static struct i2o_sys_tbl *sys_tbl;
-static int sys_tbl_ind;
-static int sys_tbl_len;
-
-/*
- * This spin lock is used to keep a device from being
- * added and deleted concurrently across CPUs or interrupts.
- * This can occur when a user creates a device and immediatelly
- * deletes it before the new_dev_notify() handler is called.
- */
-static spinlock_t i2o_dev_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Structures and definitions for synchronous message posting.
- * See i2o_post_wait() for description.
- */
-struct i2o_post_wait_data
-{
- int *status; /* Pointer to status block on caller stack */
- int *complete; /* Pointer to completion flag on caller stack */
- u32 id; /* Unique identifier */
- wait_queue_head_t *wq; /* Wake up for caller (NULL for dead) */
- struct i2o_post_wait_data *next; /* Chain */
- void *mem[2]; /* Memory blocks to recover on failure path */
- dma_addr_t phys[2]; /* Physical address of blocks to recover */
- u32 size[2]; /* Size of blocks to recover */
-};
-
-static struct i2o_post_wait_data *post_wait_queue;
-static u32 post_wait_id; // Unique ID for each post_wait
-static spinlock_t post_wait_lock = SPIN_LOCK_UNLOCKED;
-static void i2o_post_wait_complete(struct i2o_controller *, u32, int);
-
-/* OSM descriptor handler */
-static struct i2o_handler i2o_core_handler =
-{
- (void *)i2o_core_reply,
- NULL,
- NULL,
- NULL,
- "I2O core layer",
- 0,
- I2O_CLASS_EXECUTIVE
-};
-
-/*
- * Used when queueing a reply to be handled later
- */
-
-struct reply_info
-{
- struct i2o_controller *iop;
- u32 msg[MSG_FRAME_SIZE];
-};
-static struct reply_info evt_reply;
-static struct reply_info events[I2O_EVT_Q_LEN];
-static int evt_in;
-static int evt_out;
-static int evt_q_len;
-#define MODINC(x,y) ((x) = ((x) + 1) % (y))
-
-/*
- * I2O configuration spinlock. This isnt a big deal for contention
- * so we have one only
- */
-
-static DECLARE_MUTEX(i2o_configuration_lock);
-
-/*
- * Event spinlock. Used to keep event queue sane and from
- * handling multiple events simultaneously.
- */
-static spinlock_t i2o_evt_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Semaphore used to synchronize event handling thread with
- * interrupt handler.
- */
-
-static DECLARE_MUTEX(evt_sem);
-static DECLARE_COMPLETION(evt_dead);
-static DECLARE_WAIT_QUEUE_HEAD(evt_wait);
-
-static struct notifier_block i2o_reboot_notifier =
-{
- i2o_reboot_event,
- NULL,
- 0
-};
-
-/*
- * Config options
- */
-
-static int verbose;
-
-#if BITS_PER_LONG == 64
-/**
- * i2o_context_list_add - append an ptr to the context list and return a
- * matching context id.
- * @ptr: pointer to add to the context list
- * @c: controller to which the context list belong
- * returns context id, which could be used in the transaction context
- * field.
- *
- * Because the context field in I2O is only 32-bit large, on 64-bit the
- * pointer is to large to fit in the context field. The i2o_context_list
- * functiones map pointers to context fields.
- */
-u32 i2o_context_list_add(void *ptr, struct i2o_controller *c) {
- u32 context = 1;
- struct i2o_context_list_element **entry = &c->context_list;
- struct i2o_context_list_element *element;
- unsigned long flags;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- while(*entry && ((*entry)->flags & I2O_CONTEXT_LIST_USED)) {
- if((*entry)->context >= context)
- context = (*entry)->context + 1;
- entry = &((*entry)->next);
- }
-
- if(!*entry) {
- if(unlikely(!context)) {
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- printk(KERN_EMERG "i2o_core: context list overflow\n");
- return 0;
- }
-
- element = kmalloc(sizeof(struct i2o_context_list_element), GFP_KERNEL);
- if(!element) {
- printk(KERN_EMERG "i2o_core: could not allocate memory for context list element\n");
- return 0;
- }
- element->context = context;
- element->next = NULL;
- *entry = element;
- } else
- element = *entry;
-
- element->ptr = ptr;
- element->flags = I2O_CONTEXT_LIST_USED;
-
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- dprintk(KERN_DEBUG "i2o_core: add context to list %p -> %d\n", ptr, context);
- return context;
-}
-
-/**
- * i2o_context_list_remove - remove a ptr from the context list and return
- * the matching context id.
- * @ptr: pointer to be removed from the context list
- * @c: controller to which the context list belong
- * returns context id, which could be used in the transaction context
- * field.
- */
-u32 i2o_context_list_remove(void *ptr, struct i2o_controller *c) {
- struct i2o_context_list_element **entry = &c->context_list;
- struct i2o_context_list_element *element;
- u32 context;
- unsigned long flags;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- while(*entry && ((*entry)->ptr != ptr))
- entry = &((*entry)->next);
-
- if(unlikely(!*entry)) {
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- printk(KERN_WARNING "i2o_core: could not remove nonexistent ptr %p\n", ptr);
- return 0;
- }
-
- element = *entry;
-
- context = element->context;
- element->ptr = NULL;
- element->flags |= I2O_CONTEXT_LIST_DELETED;
-
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- dprintk(KERN_DEBUG "i2o_core: markt as deleted in context list %p -> %d\n", ptr, context);
- return context;
-}
-
-/**
- * i2o_context_list_get - get a ptr from the context list and remove it
- * from the list.
- * @context: context id to which the pointer belong
- * @c: controller to which the context list belong
- * returns pointer to the matching context id
- */
-void *i2o_context_list_get(u32 context, struct i2o_controller *c) {
- struct i2o_context_list_element **entry = &c->context_list;
- struct i2o_context_list_element *element;
- void *ptr;
- int count = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- while(*entry && ((*entry)->context != context)) {
- entry = &((*entry)->next);
- count ++;
- }
-
- if(unlikely(!*entry)) {
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- printk(KERN_WARNING "i2o_core: context id %d not found\n", context);
- return NULL;
- }
-
- element = *entry;
- ptr = element->ptr;
- if(count >= I2O_CONTEXT_LIST_MIN_LENGTH) {
- *entry = (*entry)->next;
- kfree(element);
- } else {
- element->ptr = NULL;
- element->flags &= !I2O_CONTEXT_LIST_USED;
- }
-
- spin_unlock_irqrestore(&c->context_list_lock, flags);
- dprintk(KERN_DEBUG "i2o_core: get ptr from context list %d -> %p\n", context, ptr);
- return ptr;
-}
-#endif
-
-/*
- * I2O Core reply handler
- */
-static void i2o_core_reply(struct i2o_handler *h, struct i2o_controller *c,
- struct i2o_message *m)
-{
- u32 *msg=(u32 *)m;
- u32 status;
- u32 context = msg[2];
-
- if (msg[0] & MSG_FAIL) // Fail bit is set
- {
- u32 *preserved_msg = (u32*)(c->msg_virt + msg[7]);
-
- i2o_report_status(KERN_INFO, "i2o_core", msg);
- i2o_dump_message(preserved_msg);
-
- /* If the failed request needs special treatment,
- * it should be done here. */
-
- /* Release the preserved msg by resubmitting it as a NOP */
-
- preserved_msg[0] = cpu_to_le32(THREE_WORD_MSG_SIZE | SGL_OFFSET_0);
- preserved_msg[1] = cpu_to_le32(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | 0);
- preserved_msg[2] = 0;
- i2o_post_message(c, msg[7]);
-
- /* If reply to i2o_post_wait failed, return causes a timeout */
-
- return;
- }
-
-#ifdef DRIVERDEBUG
- i2o_report_status(KERN_INFO, "i2o_core", msg);
-#endif
-
- if(msg[2]&0x80000000) // Post wait message
- {
- if (msg[4] >> 24)
- status = (msg[4] & 0xFFFF);
- else
- status = I2O_POST_WAIT_OK;
-
- i2o_post_wait_complete(c, context, status);
- return;
- }
-
- if(m->function == I2O_CMD_UTIL_EVT_REGISTER)
- {
- memcpy(events[evt_in].msg, msg, (msg[0]>>16)<<2);
- events[evt_in].iop = c;
-
- spin_lock(&i2o_evt_lock);
- MODINC(evt_in, I2O_EVT_Q_LEN);
- if(evt_q_len == I2O_EVT_Q_LEN)
- MODINC(evt_out, I2O_EVT_Q_LEN);
- else
- evt_q_len++;
- spin_unlock(&i2o_evt_lock);
-
- up(&evt_sem);
- wake_up_interruptible(&evt_wait);
- return;
- }
-
- if(m->function == I2O_CMD_LCT_NOTIFY)
- {
- up(&c->lct_sem);
- return;
- }
-
- /*
- * If this happens, we want to dump the message to the syslog so
- * it can be sent back to the card manufacturer by the end user
- * to aid in debugging.
- *
- */
- printk(KERN_WARNING "%s: Unsolicited message reply sent to core!"
- "Message dumped to syslog\n",
- c->name);
- i2o_dump_message(msg);
-
- return;
-}
-
-/**
- * i2o_install_handler - install a message handler
- * @h: Handler structure
- *
- * Install an I2O handler - these handle the asynchronous messaging
- * from the card once it has initialised. If the table of handlers is
- * full then -ENOSPC is returned. On a success 0 is returned and the
- * context field is set by the function. The structure is part of the
- * system from this time onwards. It must not be freed until it has
- * been uninstalled
- */
-
-int i2o_install_handler(struct i2o_handler *h)
-{
- int i;
- down(&i2o_configuration_lock);
- for(i=0;i<MAX_I2O_MODULES;i++)
- {
- if(i2o_handlers[i]==NULL)
- {
- h->context = i;
- i2o_handlers[i]=h;
- up(&i2o_configuration_lock);
- return 0;
- }
- }
- up(&i2o_configuration_lock);
- return -ENOSPC;
-}
-
-/**
- * i2o_remove_handler - remove an i2o message handler
- * @h: handler
- *
- * Remove a message handler previously installed with i2o_install_handler.
- * After this function returns the handler object can be freed or re-used
- */
-
-int i2o_remove_handler(struct i2o_handler *h)
-{
- i2o_handlers[h->context]=NULL;
- return 0;
-}
-
-
-/*
- * Each I2O controller has a chain of devices on it.
- * Each device has a pointer to its LCT entry to be used
- * for fun purposes.
- */
-
-/**
- * i2o_install_device - attach a device to a controller
- * @c: controller
- * @d: device
- *
- * Add a new device to an i2o controller. This can be called from
- * non interrupt contexts only. It adds the device and marks it as
- * unclaimed. The device memory becomes part of the kernel and must
- * be uninstalled before being freed or reused. Zero is returned
- * on success.
- */
-
-int i2o_install_device(struct i2o_controller *c, struct i2o_device *d)
-{
- int i;
-
- down(&i2o_configuration_lock);
- d->controller=c;
- d->owner=NULL;
- d->next=c->devices;
- d->prev=NULL;
- if (c->devices != NULL)
- c->devices->prev=d;
- c->devices=d;
- *d->dev_name = 0;
-
- for(i = 0; i < I2O_MAX_MANAGERS; i++)
- d->managers[i] = NULL;
-
- up(&i2o_configuration_lock);
- return 0;
-}
-
-/* we need this version to call out of i2o_delete_controller */
-
-int __i2o_delete_device(struct i2o_device *d)
-{
- struct i2o_device **p;
- int i;
-
- p=&(d->controller->devices);
-
- /*
- * Hey we have a driver!
- * Check to see if the driver wants us to notify it of
- * device deletion. If it doesn't we assume that it
- * is unsafe to delete a device with an owner and
- * fail.
- */
- if(d->owner)
- {
- if(d->owner->dev_del_notify)
- {
- dprintk(KERN_INFO "Device has owner, notifying\n");
- d->owner->dev_del_notify(d->controller, d);
- if(d->owner)
- {
- printk(KERN_WARNING
- "Driver \"%s\" did not release device!\n", d->owner->name);
- return -EBUSY;
- }
- }
- else
- return -EBUSY;
- }
-
- /*
- * Tell any other users who are talking to this device
- * that it's going away. We assume that everything works.
- */
- for(i=0; i < I2O_MAX_MANAGERS; i++)
- {
- if(d->managers[i] && d->managers[i]->dev_del_notify)
- d->managers[i]->dev_del_notify(d->controller, d);
- }
-
- while(*p!=NULL)
- {
- if(*p==d)
- {
- /*
- * Destroy
- */
- *p=d->next;
- kfree(d);
- return 0;
- }
- p=&((*p)->next);
- }
- printk(KERN_ERR "i2o_delete_device: passed invalid device.\n");
- return -EINVAL;
-}
-
-/**
- * i2o_delete_device - remove an i2o device
- * @d: device to remove
- *
- * This function unhooks a device from a controller. The device
- * will not be unhooked if it has an owner who does not wish to free
- * it, or if the owner lacks a dev_del_notify function. In that case
- * -EBUSY is returned. On success 0 is returned. Other errors cause
- * negative errno values to be returned
- */
-
-int i2o_delete_device(struct i2o_device *d)
-{
- int ret;
-
- down(&i2o_configuration_lock);
-
- /*
- * Seek, locate
- */
-
- ret = __i2o_delete_device(d);
-
- up(&i2o_configuration_lock);
-
- return ret;
-}
-
-/**
- * i2o_install_controller - attach a controller
- * @c: controller
- *
- * Add a new controller to the i2o layer. This can be called from
- * non interrupt contexts only. It adds the controller and marks it as
- * unused with no devices. If the tables are full or memory allocations
- * fail then a negative errno code is returned. On success zero is
- * returned and the controller is bound to the system. The structure
- * must not be freed or reused until being uninstalled.
- */
-
-int i2o_install_controller(struct i2o_controller *c)
-{
- int i;
- down(&i2o_configuration_lock);
- for(i=0;i<MAX_I2O_CONTROLLERS;i++)
- {
- if(i2o_controllers[i]==NULL)
- {
- c->dlct = (i2o_lct*)pci_alloc_consistent(c->pdev, 8192, &c->dlct_phys);
- if(c->dlct==NULL)
- {
- up(&i2o_configuration_lock);
- return -ENOMEM;
- }
- i2o_controllers[i]=c;
- c->devices = NULL;
- c->next=i2o_controller_chain;
- i2o_controller_chain=c;
- c->unit = i;
- c->page_frame = NULL;
- c->hrt = NULL;
- c->hrt_len = 0;
- c->lct = NULL;
- c->status_block = NULL;
- sprintf(c->name, "i2o/iop%d", i);
- i2o_num_controllers++;
- init_MUTEX_LOCKED(&c->lct_sem);
- up(&i2o_configuration_lock);
- return 0;
- }
- }
- printk(KERN_ERR "No free i2o controller slots.\n");
- up(&i2o_configuration_lock);
- return -EBUSY;
-}
-
-/**
- * i2o_delete_controller - delete a controller
- * @c: controller
- *
- * Remove an i2o controller from the system. If the controller or its
- * devices are busy then -EBUSY is returned. On a failure a negative
- * errno code is returned. On success zero is returned.
- */
-
-int i2o_delete_controller(struct i2o_controller *c)
-{
- struct i2o_controller **p;
- int users;
- char name[16];
- int stat;
-
- dprintk(KERN_INFO "Deleting controller %s\n", c->name);
-
- /*
- * Clear event registration as this can cause weird behavior
- */
- if(c->status_block->iop_state == ADAPTER_STATE_OPERATIONAL)
- i2o_event_register(c, core_context, 0, 0, 0);
-
- down(&i2o_configuration_lock);
- if((users=atomic_read(&c->users)))
- {
- dprintk(KERN_INFO "I2O: %d users for controller %s\n", users,
- c->name);
- up(&i2o_configuration_lock);
- return -EBUSY;
- }
- while(c->devices)
- {
- if(__i2o_delete_device(c->devices)<0)
- {
- /* Shouldnt happen */
- I2O_IRQ_WRITE32(c, 0xFFFFFFFF);
- c->enabled = 0;
- up(&i2o_configuration_lock);
- return -EBUSY;
- }
- }
-
- /*
- * If this is shutdown time, the thread's already been killed
- */
- if(c->lct_running) {
- stat = kill_proc(c->lct_pid, SIGKILL, 1);
- if(!stat) {
- int count = 10 * 100;
- while(c->lct_running && --count) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(1);
- }
-
- if(!count)
- printk(KERN_ERR
- "%s: LCT thread still running!\n",
- c->name);
- }
- }
-
- p=&i2o_controller_chain;
-
- while(*p)
- {
- if(*p==c)
- {
- /* Ask the IOP to switch to RESET state */
- i2o_reset_controller(c);
-
- /* Release IRQ */
- i2o_pci_dispose(c);
-
- *p=c->next;
- up(&i2o_configuration_lock);
-
- if(c->page_frame)
- {
- pci_unmap_single(c->pdev, c->page_frame_map, MSG_POOL_SIZE, PCI_DMA_FROMDEVICE);
- kfree(c->page_frame);
- }
- if(c->hrt)
- pci_free_consistent(c->pdev, c->hrt_len, c->hrt, c->hrt_phys);
- if(c->lct)
- pci_free_consistent(c->pdev, c->lct->table_size << 2, c->lct, c->lct_phys);
- if(c->status_block)
- pci_free_consistent(c->pdev, sizeof(i2o_status_block), c->status_block, c->status_block_phys);
- if(c->dlct)
- pci_free_consistent(c->pdev, 8192, c->dlct, c->dlct_phys);
-
- i2o_controllers[c->unit]=NULL;
- memcpy(name, c->name, strlen(c->name)+1);
- kfree(c);
- dprintk(KERN_INFO "%s: Deleted from controller chain.\n", name);
-
- i2o_num_controllers--;
- return 0;
- }
- p=&((*p)->next);
- }
- up(&i2o_configuration_lock);
- printk(KERN_ERR "i2o_delete_controller: bad pointer!\n");
- return -ENOENT;
-}
-
-/**
- * i2o_unlock_controller - unlock a controller
- * @c: controller to unlock
- *
- * Take a lock on an i2o controller. This prevents it being deleted.
- * i2o controllers are not refcounted so a deletion of an in use device
- * will fail, not take affect on the last dereference.
- */
-
-void i2o_unlock_controller(struct i2o_controller *c)
-{
- atomic_dec(&c->users);
-}
-
-/**
- * i2o_find_controller - return a locked controller
- * @n: controller number
- *
- * Returns a pointer to the controller object. The controller is locked
- * on return. NULL is returned if the controller is not found.
- */
-
-struct i2o_controller *i2o_find_controller(int n)
-{
- struct i2o_controller *c;
-
- if(n<0 || n>=MAX_I2O_CONTROLLERS)
- return NULL;
-
- down(&i2o_configuration_lock);
- c=i2o_controllers[n];
- if(c!=NULL)
- atomic_inc(&c->users);
- up(&i2o_configuration_lock);
- return c;
-}
-
-/**
- * i2o_issue_claim - claim or release a device
- * @cmd: command
- * @c: controller to claim for
- * @tid: i2o task id
- * @type: type of claim
- *
- * Issue I2O UTIL_CLAIM and UTIL_RELEASE messages. The message to be sent
- * is set by cmd. The tid is the task id of the object to claim and the
- * type is the claim type (see the i2o standard)
- *
- * Zero is returned on success.
- */
-
-static int i2o_issue_claim(u32 cmd, struct i2o_controller *c, int tid, u32 type)
-{
- u32 msg[5];
-
- msg[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
- msg[1] = cmd << 24 | HOST_TID<<12 | tid;
- msg[3] = 0;
- msg[4] = type;
-
- return i2o_post_wait(c, msg, sizeof(msg), 60);
-}
-
-/*
- * i2o_claim_device - claim a device for use by an OSM
- * @d: device to claim
- * @h: handler for this device
- *
- * Do the leg work to assign a device to a given OSM on Linux. The
- * kernel updates the internal handler data for the device and then
- * performs an I2O claim for the device, attempting to claim the
- * device as primary. If the attempt fails a negative errno code
- * is returned. On success zero is returned.
- */
-
-int i2o_claim_device(struct i2o_device *d, struct i2o_handler *h)
-{
- int ret = 0;
-
- down(&i2o_configuration_lock);
- if (d->owner) {
- printk(KERN_INFO "Device claim called, but dev already owned by %s!",
- h->name);
- ret = -EBUSY;
- goto out;
- }
- d->owner=h;
-
- if(i2o_issue_claim(I2O_CMD_UTIL_CLAIM ,d->controller,d->lct_data.tid,
- I2O_CLAIM_PRIMARY))
- {
- d->owner = NULL;
- ret = -EBUSY;
- }
-out:
- up(&i2o_configuration_lock);
- return ret;
-}
-
-/**
- * i2o_release_device - release a device that the OSM is using
- * @d: device to claim
- * @h: handler for this device
- *
- * Drop a claim by an OSM on a given I2O device. The handler is cleared
- * and 0 is returned on success.
- *
- * AC - some devices seem to want to refuse an unclaim until they have
- * finished internal processing. It makes sense since you don't want a
- * new device to go reconfiguring the entire system until you are done.
- * Thus we are prepared to wait briefly.
- */
-
-int i2o_release_device(struct i2o_device *d, struct i2o_handler *h)
-{
- int err = 0;
- int tries;
-
- down(&i2o_configuration_lock);
- if (d->owner != h) {
- printk(KERN_INFO "Claim release called, but not owned by %s!\n",
- h->name);
- up(&i2o_configuration_lock);
- return -ENOENT;
- }
-
- for(tries=0;tries<10;tries++)
- {
- d->owner = NULL;
-
- /*
- * If the controller takes a nonblocking approach to
- * releases we have to sleep/poll for a few times.
- */
-
- if((err=i2o_issue_claim(I2O_CMD_UTIL_RELEASE, d->controller, d->lct_data.tid, I2O_CLAIM_PRIMARY)) )
- {
- err = -ENXIO;
- current->state = TASK_UNINTERRUPTIBLE;
- schedule_timeout(HZ);
- }
- else
- {
- err=0;
- break;
- }
- }
- up(&i2o_configuration_lock);
- return err;
-}
-
-/**
- * i2o_device_notify_on - Enable deletion notifiers
- * @d: device for notification
- * @h: handler to install
- *
- * Called by OSMs to let the core know that they want to be
- * notified if the given device is deleted from the system.
- */
-
-int i2o_device_notify_on(struct i2o_device *d, struct i2o_handler *h)
-{
- int i;
-
- if(d->num_managers == I2O_MAX_MANAGERS)
- return -ENOSPC;
-
- for(i = 0; i < I2O_MAX_MANAGERS; i++)
- {
- if(!d->managers[i])
- {
- d->managers[i] = h;
- break;
- }
- }
-
- d->num_managers++;
-
- return 0;
-}
-
-/**
- * i2o_device_notify_off - Remove deletion notifiers
- * @d: device for notification
- * @h: handler to remove
- *
- * Called by OSMs to let the core know that they no longer
- * are interested in the fate of the given device.
- */
-int i2o_device_notify_off(struct i2o_device *d, struct i2o_handler *h)
-{
- int i;
-
- for(i=0; i < I2O_MAX_MANAGERS; i++)
- {
- if(d->managers[i] == h)
- {
- d->managers[i] = NULL;
- d->num_managers--;
- return 0;
- }
- }
-
- return -ENOENT;
-}
-
-/**
- * i2o_event_register - register interest in an event
- * @c: Controller to register interest with
- * @tid: I2O task id
- * @init_context: initiator context to use with this notifier
- * @tr_context: transaction context to use with this notifier
- * @evt_mask: mask of events
- *
- * Create and posts an event registration message to the task. No reply
- * is waited for, or expected. Errors in posting will be reported.
- */
-
-int i2o_event_register(struct i2o_controller *c, u32 tid,
- u32 init_context, u32 tr_context, u32 evt_mask)
-{
- u32 msg[5]; // Not performance critical, so we just
- // i2o_post_this it instead of building it
- // in IOP memory
-
- msg[0] = FIVE_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1] = I2O_CMD_UTIL_EVT_REGISTER<<24 | HOST_TID<<12 | tid;
- msg[2] = init_context;
- msg[3] = tr_context;
- msg[4] = evt_mask;
-
- return i2o_post_this(c, msg, sizeof(msg));
-}
-
-/*
- * i2o_event_ack - acknowledge an event
- * @c: controller
- * @msg: pointer to the UTIL_EVENT_REGISTER reply we received
- *
- * We just take a pointer to the original UTIL_EVENT_REGISTER reply
- * message and change the function code since that's what spec
- * describes an EventAck message looking like.
- */
-
-int i2o_event_ack(struct i2o_controller *c, u32 *msg)
-{
- struct i2o_message *m = (struct i2o_message *)msg;
-
- m->function = I2O_CMD_UTIL_EVT_ACK;
-
- return i2o_post_wait(c, msg, m->size * 4, 2);
-}
-
-/*
- * Core event handler. Runs as a separate thread and is woken
- * up whenever there is an Executive class event.
- */
-static int i2o_core_evt(void *reply_data)
-{
- struct reply_info *reply = (struct reply_info *) reply_data;
- u32 *msg = reply->msg;
- struct i2o_controller *c = NULL;
- unsigned long flags;
-
- daemonize("i2oevtd");
- allow_signal(SIGKILL);
-
- evt_running = 1;
-
- while(1)
- {
- if(down_interruptible(&evt_sem))
- {
- dprintk(KERN_INFO "I2O event thread dead\n");
- printk("exiting...");
- evt_running = 0;
- complete_and_exit(&evt_dead, 0);
- }
-
- /*
- * Copy the data out of the queue so that we don't have to lock
- * around the whole function and just around the qlen update
- */
- spin_lock_irqsave(&i2o_evt_lock, flags);
- memcpy(reply, &events[evt_out], sizeof(struct reply_info));
- MODINC(evt_out, I2O_EVT_Q_LEN);
- evt_q_len--;
- spin_unlock_irqrestore(&i2o_evt_lock, flags);
-
- c = reply->iop;
- dprintk(KERN_INFO "I2O IRTOS EVENT: iop%d, event %#10x\n", c->unit, msg[4]);
-
- /*
- * We do not attempt to delete/quiesce/etc. the controller if
- * some sort of error indidication occurs. We may want to do
- * so in the future, but for now we just let the user deal with
- * it. One reason for this is that what to do with an error
- * or when to send what ærror is not really agreed on, so
- * we get errors that may not be fatal but just look like they
- * are...so let the user deal with it.
- */
- switch(msg[4])
- {
- case I2O_EVT_IND_EXEC_RESOURCE_LIMITS:
- printk(KERN_ERR "%s: Out of resources\n", c->name);
- break;
-
- case I2O_EVT_IND_EXEC_POWER_FAIL:
- printk(KERN_ERR "%s: Power failure\n", c->name);
- break;
-
- case I2O_EVT_IND_EXEC_HW_FAIL:
- {
- char *fail[] =
- {
- "Unknown Error",
- "Power Lost",
- "Code Violation",
- "Parity Error",
- "Code Execution Exception",
- "Watchdog Timer Expired"
- };
-
- if(msg[5] <= 6)
- printk(KERN_ERR "%s: Hardware Failure: %s\n",
- c->name, fail[msg[5]]);
- else
- printk(KERN_ERR "%s: Unknown Hardware Failure\n", c->name);
-
- break;
- }
-
- /*
- * New device created
- * - Create a new i2o_device entry
- * - Inform all interested drivers about this device's existence
- */
- case I2O_EVT_IND_EXEC_NEW_LCT_ENTRY:
- {
- struct i2o_device *d = (struct i2o_device *)
- kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
- int i;
-
- if (d == NULL) {
- printk(KERN_EMERG "i2oevtd: out of memory\n");
- break;
- }
- memcpy(&d->lct_data, &msg[5], sizeof(i2o_lct_entry));
-
- d->next = NULL;
- d->controller = c;
- d->flags = 0;
-
- i2o_report_controller_unit(c, d);
- i2o_install_device(c,d);
-
- for(i = 0; i < MAX_I2O_MODULES; i++)
- {
- if(i2o_handlers[i] &&
- i2o_handlers[i]->new_dev_notify &&
- (i2o_handlers[i]->class&d->lct_data.class_id))
- {
- spin_lock(&i2o_dev_lock);
- i2o_handlers[i]->new_dev_notify(c,d);
- spin_unlock(&i2o_dev_lock);
- }
- }
-
- break;
- }
-
- /*
- * LCT entry for a device has been modified, so update it
- * internally.
- */
- case I2O_EVT_IND_EXEC_MODIFIED_LCT:
- {
- struct i2o_device *d;
- i2o_lct_entry *new_lct = (i2o_lct_entry *)&msg[5];
-
- for(d = c->devices; d; d = d->next)
- {
- if(d->lct_data.tid == new_lct->tid)
- {
- memcpy(&d->lct_data, new_lct, sizeof(i2o_lct_entry));
- break;
- }
- }
- break;
- }
-
- case I2O_EVT_IND_CONFIGURATION_FLAG:
- printk(KERN_WARNING "%s requires user configuration\n", c->name);
- break;
-
- case I2O_EVT_IND_GENERAL_WARNING:
- printk(KERN_WARNING "%s: Warning notification received!"
- "Check configuration for errors!\n", c->name);
- break;
-
- case I2O_EVT_IND_EVT_MASK_MODIFIED:
- /* Well I guess that was us hey .. */
- break;
-
- default:
- printk(KERN_WARNING "%s: No handler for event (0x%08x)\n", c->name, msg[4]);
- break;
- }
- }
-
- return 0;
-}
-
-/*
- * Dynamic LCT update. This compares the LCT with the currently
- * installed devices to check for device deletions..this needed b/c there
- * is no DELETED_LCT_ENTRY EventIndicator for the Executive class so
- * we can't just have the event handler do this...annoying
- *
- * This is a hole in the spec that will hopefully be fixed someday.
- */
-static int i2o_dyn_lct(void *foo)
-{
- struct i2o_controller *c = (struct i2o_controller *)foo;
- struct i2o_device *d = NULL;
- struct i2o_device *d1 = NULL;
- int i = 0;
- int found = 0;
- int entries;
- void *tmp;
-
- daemonize("iop%d_lctd", c->unit);
- allow_signal(SIGKILL);
-
- c->lct_running = 1;
-
- while(1)
- {
- down_interruptible(&c->lct_sem);
- if(signal_pending(current))
- {
- dprintk(KERN_ERR "%s: LCT thread dead\n", c->name);
- c->lct_running = 0;
- return 0;
- }
-
- entries = c->dlct->table_size;
- entries -= 3;
- entries /= 9;
-
- dprintk(KERN_INFO "%s: Dynamic LCT Update\n",c->name);
- dprintk(KERN_INFO "%s: Dynamic LCT contains %d entries\n", c->name, entries);
-
- if(!entries)
- {
- printk(KERN_INFO "%s: Empty LCT???\n", c->name);
- continue;
- }
-
- /*
- * Loop through all the devices on the IOP looking for their
- * LCT data in the LCT. We assume that TIDs are not repeated.
- * as that is the only way to really tell. It's been confirmed
- * by the IRTOS vendor(s?) that TIDs are not reused until they
- * wrap arround(4096), and I doubt a system will up long enough
- * to create/delete that many devices.
- */
- for(d = c->devices; d; )
- {
- found = 0;
- d1 = d->next;
-
- for(i = 0; i < entries; i++)
- {
- if(d->lct_data.tid == c->dlct->lct_entry[i].tid)
- {
- found = 1;
- break;
- }
- }
- if(!found)
- {
- dprintk(KERN_INFO "i2o_core: Deleted device!\n");
- spin_lock(&i2o_dev_lock);
- i2o_delete_device(d);
- spin_unlock(&i2o_dev_lock);
- }
- d = d1;
- }
-
- /*
- * Tell LCT to renotify us next time there is a change
- */
- i2o_lct_notify(c);
-
- /*
- * Copy new LCT into public LCT
- *
- * Possible race if someone is reading LCT while we are copying
- * over it. If this happens, we'll fix it then. but I doubt that
- * the LCT will get updated often enough or will get read by
- * a user often enough to worry.
- */
- if(c->lct->table_size < c->dlct->table_size)
- {
- dma_addr_t phys;
- tmp = c->lct;
- c->lct = pci_alloc_consistent(c->pdev, c->dlct->table_size<<2, &phys);
- if(!c->lct)
- {
- printk(KERN_ERR "%s: No memory for LCT!\n", c->name);
- c->lct = tmp;
- continue;
- }
- pci_free_consistent(tmp, c->lct->table_size << 2, c->lct, c->lct_phys);
- c->lct_phys = phys;
- }
- memcpy(c->lct, c->dlct, c->dlct->table_size<<2);
- }
-
- return 0;
-}
-
-/**
- * i2o_run_queue - process pending events on a controller
- * @c: controller to process
- *
- * This is called by the bus specific driver layer when an interrupt
- * or poll of this card interface is desired.
- */
-
-void i2o_run_queue(struct i2o_controller *c)
-{
- struct i2o_message *m;
- u32 mv;
- u32 *msg;
-
- /*
- * Old 960 steppings had a bug in the I2O unit that caused
- * the queue to appear empty when it wasn't.
- */
- if((mv=I2O_REPLY_READ32(c))==0xFFFFFFFF)
- mv=I2O_REPLY_READ32(c);
-
- while(mv!=0xFFFFFFFF)
- {
- struct i2o_handler *i;
- /* Map the message from the page frame map to kernel virtual */
- /* m=(struct i2o_message *)(mv - (unsigned long)c->page_frame_map + (unsigned long)c->page_frame); */
- m=(struct i2o_message *)bus_to_virt(mv);
- msg=(u32*)m;
-
- /*
- * Ensure this message is seen coherently but cachably by
- * the processor
- */
-
- pci_dma_sync_single_for_cpu(c->pdev, c->page_frame_map, MSG_FRAME_SIZE, PCI_DMA_FROMDEVICE);
-
- /*
- * Despatch it
- */
-
- i=i2o_handlers[m->initiator_context&(MAX_I2O_MODULES-1)];
- if(i && i->reply)
- i->reply(i,c,m);
- else
- {
- printk(KERN_WARNING "I2O: Spurious reply to handler %d\n",
- m->initiator_context&(MAX_I2O_MODULES-1));
- }
- i2o_flush_reply(c,mv);
- mb();
-
- /* That 960 bug again... */
- if((mv=I2O_REPLY_READ32(c))==0xFFFFFFFF)
- mv=I2O_REPLY_READ32(c);
- }
-}
-
-
-/**
- * i2o_get_class_name - do i2o class name lookup
- * @class: class number
- *
- * Return a descriptive string for an i2o class
- */
-
-const char *i2o_get_class_name(int class)
-{
- int idx = 16;
- static char *i2o_class_name[] = {
- "Executive",
- "Device Driver Module",
- "Block Device",
- "Tape Device",
- "LAN Interface",
- "WAN Interface",
- "Fibre Channel Port",
- "Fibre Channel Device",
- "SCSI Device",
- "ATE Port",
- "ATE Device",
- "Floppy Controller",
- "Floppy Device",
- "Secondary Bus Port",
- "Peer Transport Agent",
- "Peer Transport",
- "Unknown"
- };
-
- switch(class&0xFFF)
- {
- case I2O_CLASS_EXECUTIVE:
- idx = 0; break;
- case I2O_CLASS_DDM:
- idx = 1; break;
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- idx = 2; break;
- case I2O_CLASS_SEQUENTIAL_STORAGE:
- idx = 3; break;
- case I2O_CLASS_LAN:
- idx = 4; break;
- case I2O_CLASS_WAN:
- idx = 5; break;
- case I2O_CLASS_FIBRE_CHANNEL_PORT:
- idx = 6; break;
- case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
- idx = 7; break;
- case I2O_CLASS_SCSI_PERIPHERAL:
- idx = 8; break;
- case I2O_CLASS_ATE_PORT:
- idx = 9; break;
- case I2O_CLASS_ATE_PERIPHERAL:
- idx = 10; break;
- case I2O_CLASS_FLOPPY_CONTROLLER:
- idx = 11; break;
- case I2O_CLASS_FLOPPY_DEVICE:
- idx = 12; break;
- case I2O_CLASS_BUS_ADAPTER_PORT:
- idx = 13; break;
- case I2O_CLASS_PEER_TRANSPORT_AGENT:
- idx = 14; break;
- case I2O_CLASS_PEER_TRANSPORT:
- idx = 15; break;
- }
-
- return i2o_class_name[idx];
-}
-
-
-/**
- * i2o_wait_message - obtain an i2o message from the IOP
- * @c: controller
- * @why: explanation
- *
- * This function waits up to 5 seconds for a message slot to be
- * available. If no message is available it prints an error message
- * that is expected to be what the message will be used for (eg
- * "get_status"). 0xFFFFFFFF is returned on a failure.
- *
- * On a success the message is returned. This is the physical page
- * frame offset address from the read port. (See the i2o spec)
- */
-
-u32 i2o_wait_message(struct i2o_controller *c, char *why)
-{
- long time=jiffies;
- u32 m;
- while((m=I2O_POST_READ32(c))==0xFFFFFFFF)
- {
- if((jiffies-time)>=5*HZ)
- {
- dprintk(KERN_ERR "%s: Timeout waiting for message frame to send %s.\n",
- c->name, why);
- return 0xFFFFFFFF;
- }
- schedule();
- barrier();
- }
- return m;
-}
-
-/**
- * i2o_report_controller_unit - print information about a tid
- * @c: controller
- * @d: device
- *
- * Dump an information block associated with a given unit (TID). The
- * tables are read and a block of text is output to printk that is
- * formatted intended for the user.
- */
-
-void i2o_report_controller_unit(struct i2o_controller *c, struct i2o_device *d)
-{
- char buf[64];
- char str[22];
- int ret;
- int unit = d->lct_data.tid;
-
- if(verbose==0)
- return;
-
- printk(KERN_INFO "Target ID %d.\n", unit);
- if((ret=i2o_query_scalar(c, unit, 0xF100, 3, buf, 16))>=0)
- {
- buf[16]=0;
- printk(KERN_INFO " Vendor: %s\n", buf);
- }
- if((ret=i2o_query_scalar(c, unit, 0xF100, 4, buf, 16))>=0)
- {
- buf[16]=0;
- printk(KERN_INFO " Device: %s\n", buf);
- }
- if(i2o_query_scalar(c, unit, 0xF100, 5, buf, 16)>=0)
- {
- buf[16]=0;
- printk(KERN_INFO " Description: %s\n", buf);
- }
- if((ret=i2o_query_scalar(c, unit, 0xF100, 6, buf, 8))>=0)
- {
- buf[8]=0;
- printk(KERN_INFO " Rev: %s\n", buf);
- }
-
- printk(KERN_INFO " Class: ");
- sprintf(str, "%-21s", i2o_get_class_name(d->lct_data.class_id));
- printk("%s\n", str);
-
- printk(KERN_INFO " Subclass: 0x%04X\n", d->lct_data.sub_class);
- printk(KERN_INFO " Flags: ");
-
- if(d->lct_data.device_flags&(1<<0))
- printk("C"); // ConfigDialog requested
- if(d->lct_data.device_flags&(1<<1))
- printk("U"); // Multi-user capable
- if(!(d->lct_data.device_flags&(1<<4)))
- printk("P"); // Peer service enabled!
- if(!(d->lct_data.device_flags&(1<<5)))
- printk("M"); // Mgmt service enabled!
- printk("\n");
-
-}
-
-
-/*
- * Parse the hardware resource table. Right now we print it out
- * and don't do a lot with it. We should collate these and then
- * interact with the Linux resource allocation block.
- *
- * Lets prove we can read it first eh ?
- *
- * This is full of endianisms!
- */
-
-static int i2o_parse_hrt(struct i2o_controller *c)
-{
-#ifdef DRIVERDEBUG
- u32 *rows=(u32*)c->hrt;
- u8 *p=(u8 *)c->hrt;
- u8 *d;
- int count;
- int length;
- int i;
- int state;
-
- if(p[3]!=0)
- {
- printk(KERN_ERR "%s: HRT table for controller is too new a version.\n",
- c->name);
- return -1;
- }
-
- count=p[0]|(p[1]<<8);
- length = p[2];
-
- printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
- c->name, count, length<<2);
-
- rows+=2;
-
- for(i=0;i<count;i++)
- {
- printk(KERN_INFO "Adapter %08X: ", rows[0]);
- p=(u8 *)(rows+1);
- d=(u8 *)(rows+2);
- state=p[1]<<8|p[0];
-
- printk("TID %04X:[", state&0xFFF);
- state>>=12;
- if(state&(1<<0))
- printk("H"); /* Hidden */
- if(state&(1<<2))
- {
- printk("P"); /* Present */
- if(state&(1<<1))
- printk("C"); /* Controlled */
- }
- if(state>9)
- printk("*"); /* Hard */
-
- printk("]:");
-
- switch(p[3]&0xFFFF)
- {
- case 0:
- /* Adapter private bus - easy */
- printk("Local bus %d: I/O at 0x%04X Mem 0x%08X",
- p[2], d[1]<<8|d[0], *(u32 *)(d+4));
- break;
- case 1:
- /* ISA bus */
- printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X",
- p[2], d[2], d[1]<<8|d[0], *(u32 *)(d+4));
- break;
-
- case 2: /* EISA bus */
- printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
- p[2], d[3], d[1]<<8|d[0], *(u32 *)(d+4));
- break;
-
- case 3: /* MCA bus */
- printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
- p[2], d[3], d[1]<<8|d[0], *(u32 *)(d+4));
- break;
-
- case 4: /* PCI bus */
- printk("PCI %d: Bus %d Device %d Function %d",
- p[2], d[2], d[1], d[0]);
- break;
-
- case 0x80: /* Other */
- default:
- printk("Unsupported bus type.");
- break;
- }
- printk("\n");
- rows+=length;
- }
-#endif
- return 0;
-}
-
-/*
- * The logical configuration table tells us what we can talk to
- * on the board. Most of the stuff isn't interesting to us.
- */
-
-static int i2o_parse_lct(struct i2o_controller *c)
-{
- int i;
- int max;
- int tid;
- struct i2o_device *d;
- i2o_lct *lct = c->lct;
-
- if (lct == NULL) {
- printk(KERN_ERR "%s: LCT is empty???\n", c->name);
- return -1;
- }
-
- max = lct->table_size;
- max -= 3;
- max /= 9;
-
- printk(KERN_INFO "%s: LCT has %d entries.\n", c->name, max);
-
- if(lct->iop_flags&(1<<0))
- printk(KERN_WARNING "%s: Configuration dialog desired.\n", c->name);
-
- for(i=0;i<max;i++)
- {
- d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
- if(d==NULL)
- {
- printk(KERN_CRIT "i2o_core: Out of memory for I2O device data.\n");
- return -ENOMEM;
- }
-
- d->controller = c;
- d->next = NULL;
-
- memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
-
- d->flags = 0;
- tid = d->lct_data.tid;
-
- i2o_report_controller_unit(c, d);
-
- i2o_install_device(c, d);
- }
- return 0;
-}
-
-
-/**
- * i2o_quiesce_controller - quiesce controller
- * @c: controller
- *
- * Quiesce an IOP. Causes IOP to make external operation quiescent
- * (i2o 'READY' state). Internal operation of the IOP continues normally.
- */
-
-int i2o_quiesce_controller(struct i2o_controller *c)
-{
- u32 msg[4];
- int ret;
-
- i2o_status_get(c);
-
- /* SysQuiesce discarded if IOP not in READY or OPERATIONAL state */
-
- if ((c->status_block->iop_state != ADAPTER_STATE_READY) &&
- (c->status_block->iop_state != ADAPTER_STATE_OPERATIONAL))
- {
- return 0;
- }
-
- msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1] = I2O_CMD_SYS_QUIESCE<<24|HOST_TID<<12|ADAPTER_TID;
- msg[3] = 0;
-
- /* Long timeout needed for quiesce if lots of devices */
-
- if ((ret = i2o_post_wait(c, msg, sizeof(msg), 240)))
- printk(KERN_INFO "%s: Unable to quiesce (status=%#x).\n",
- c->name, -ret);
- else
- dprintk(KERN_INFO "%s: Quiesced.\n", c->name);
-
- i2o_status_get(c); // Entered READY state
- return ret;
-}
-
-/**
- * i2o_enable_controller - move controller from ready to operational
- * @c: controller
- *
- * Enable IOP. This allows the IOP to resume external operations and
- * reverses the effect of a quiesce. In the event of an error a negative
- * errno code is returned.
- */
-
-int i2o_enable_controller(struct i2o_controller *c)
-{
- u32 msg[4];
- int ret;
-
- i2o_status_get(c);
-
- /* Enable only allowed on READY state */
- if(c->status_block->iop_state != ADAPTER_STATE_READY)
- return -EINVAL;
-
- msg[0]=FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_SYS_ENABLE<<24|HOST_TID<<12|ADAPTER_TID;
-
- /* How long of a timeout do we need? */
-
- if ((ret = i2o_post_wait(c, msg, sizeof(msg), 240)))
- printk(KERN_ERR "%s: Could not enable (status=%#x).\n",
- c->name, -ret);
- else
- dprintk(KERN_INFO "%s: Enabled.\n", c->name);
-
- i2o_status_get(c); // entered OPERATIONAL state
-
- return ret;
-}
-
-/**
- * i2o_clear_controller - clear a controller
- * @c: controller
- *
- * Clear an IOP to HOLD state, ie. terminate external operations, clear all
- * input queues and prepare for a system restart. IOP's internal operation
- * continues normally and the outbound queue is alive.
- * The IOP is not expected to rebuild its LCT.
- */
-
-int i2o_clear_controller(struct i2o_controller *c)
-{
- struct i2o_controller *iop;
- u32 msg[4];
- int ret;
-
- /* Quiesce all IOPs first */
-
- for (iop = i2o_controller_chain; iop; iop = iop->next)
- i2o_quiesce_controller(iop);
-
- msg[0]=FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_ADAPTER_CLEAR<<24|HOST_TID<<12|ADAPTER_TID;
- msg[3]=0;
-
- if ((ret=i2o_post_wait(c, msg, sizeof(msg), 30)))
- printk(KERN_INFO "%s: Unable to clear (status=%#x).\n",
- c->name, -ret);
- else
- dprintk(KERN_INFO "%s: Cleared.\n",c->name);
-
- i2o_status_get(c);
-
- /* Enable other IOPs */
-
- for (iop = i2o_controller_chain; iop; iop = iop->next)
- if (iop != c)
- i2o_enable_controller(iop);
-
- return ret;
-}
-
-
-/**
- * i2o_reset_controller - reset an IOP
- * @c: controller to reset
- *
- * Reset the IOP into INIT state and wait until IOP gets into RESET state.
- * Terminate all external operations, clear IOP's inbound and outbound
- * queues, terminate all DDMs, and reload the IOP's operating environment
- * and all local DDMs. The IOP rebuilds its LCT.
- */
-
-static int i2o_reset_controller(struct i2o_controller *c)
-{
- struct i2o_controller *iop;
- u32 m;
- u8 *status;
- dma_addr_t status_phys;
- u32 *msg;
- long time;
-
- /* Quiesce all IOPs first */
-
- for (iop = i2o_controller_chain; iop; iop = iop->next)
- {
- if(!iop->dpt)
- i2o_quiesce_controller(iop);
- }
-
- m=i2o_wait_message(c, "AdapterReset");
- if(m==0xFFFFFFFF)
- return -ETIMEDOUT;
- msg=(u32 *)(c->msg_virt+m);
-
- status = pci_alloc_consistent(c->pdev, 4, &status_phys);
- if(status == NULL) {
- printk(KERN_ERR "IOP reset failed - no free memory.\n");
- return -ENOMEM;
- }
- memset(status, 0, 4);
-
- msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID;
- msg[2]=core_context;
- msg[3]=0;
- msg[4]=0;
- msg[5]=0;
- msg[6]=status_phys;
- msg[7]=0; /* 64bit host FIXME */
-
- i2o_post_message(c,m);
-
- /* Wait for a reply */
- time=jiffies;
- while(*status==0)
- {
- if((jiffies-time)>=20*HZ)
- {
- printk(KERN_ERR "IOP reset timeout.\n");
- /* The controller still may respond and overwrite
- * status_phys, LEAK it to prevent memory corruption.
- */
- return -ETIMEDOUT;
- }
- schedule();
- barrier();
- }
-
- if (*status==I2O_CMD_IN_PROGRESS)
- {
- /*
- * Once the reset is sent, the IOP goes into the INIT state
- * which is indeterminate. We need to wait until the IOP
- * has rebooted before we can let the system talk to
- * it. We read the inbound Free_List until a message is
- * available. If we can't read one in the given ammount of
- * time, we assume the IOP could not reboot properly.
- */
-
- dprintk(KERN_INFO "%s: Reset in progress, waiting for reboot...\n",
- c->name);
-
- time = jiffies;
- m = I2O_POST_READ32(c);
- while(m == 0XFFFFFFFF)
- {
- if((jiffies-time) >= 30*HZ)
- {
- printk(KERN_ERR "%s: Timeout waiting for IOP reset.\n",
- c->name);
- /* The controller still may respond and
- * overwrite status_phys, LEAK it to prevent
- * memory corruption.
- */
- return -ETIMEDOUT;
- }
- schedule();
- barrier();
- m = I2O_POST_READ32(c);
- }
- i2o_flush_reply(c,m);
- }
-
- /* If IopReset was rejected or didn't perform reset, try IopClear */
-
- i2o_status_get(c);
- if (status[0] == I2O_CMD_REJECTED ||
- c->status_block->iop_state != ADAPTER_STATE_RESET)
- {
- printk(KERN_WARNING "%s: Reset rejected, trying to clear\n",c->name);
- i2o_clear_controller(c);
- }
- else
- dprintk(KERN_INFO "%s: Reset completed.\n", c->name);
-
- /* Enable other IOPs */
-
- for (iop = i2o_controller_chain; iop; iop = iop->next)
- if (iop != c)
- i2o_enable_controller(iop);
-
- pci_free_consistent(c->pdev, 4, status, status_phys);
- return 0;
-}
-
-
-/**
- * i2o_status_get - get the status block for the IOP
- * @c: controller
- *
- * Issue a status query on the controller. This updates the
- * attached status_block. If the controller fails to reply or an
- * error occurs then a negative errno code is returned. On success
- * zero is returned and the status_blok is updated.
- */
-
-int i2o_status_get(struct i2o_controller *c)
-{
- long time;
- u32 m;
- u32 *msg;
- u8 *status_block;
-
- if (c->status_block == NULL)
- {
- c->status_block = (i2o_status_block *)
- pci_alloc_consistent(c->pdev, sizeof(i2o_status_block), &c->status_block_phys);
- if (c->status_block == NULL)
- {
- printk(KERN_CRIT "%s: Get Status Block failed; Out of memory.\n",
- c->name);
- return -ENOMEM;
- }
- }
-
- status_block = (u8*)c->status_block;
- memset(c->status_block,0,sizeof(i2o_status_block));
-
- m=i2o_wait_message(c, "StatusGet");
- if(m==0xFFFFFFFF)
- return -ETIMEDOUT;
- msg=(u32 *)(c->msg_virt+m);
-
- msg[0]=NINE_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID;
- msg[2]=core_context;
- msg[3]=0;
- msg[4]=0;
- msg[5]=0;
- msg[6]=c->status_block_phys;
- msg[7]=0; /* 64bit host FIXME */
- msg[8]=sizeof(i2o_status_block); /* always 88 bytes */
-
- i2o_post_message(c,m);
-
- /* Wait for a reply */
-
- time=jiffies;
- while(status_block[87]!=0xFF)
- {
- if((jiffies-time)>=5*HZ)
- {
- printk(KERN_ERR "%s: Get status timeout.\n",c->name);
- return -ETIMEDOUT;
- }
- yield();
- barrier();
- }
-
-#ifdef DRIVERDEBUG
- printk(KERN_INFO "%s: State = ", c->name);
- switch (c->status_block->iop_state) {
- case 0x01:
- printk("INIT\n");
- break;
- case 0x02:
- printk("RESET\n");
- break;
- case 0x04:
- printk("HOLD\n");
- break;
- case 0x05:
- printk("READY\n");
- break;
- case 0x08:
- printk("OPERATIONAL\n");
- break;
- case 0x10:
- printk("FAILED\n");
- break;
- case 0x11:
- printk("FAULTED\n");
- break;
- default:
- printk("%x (unknown !!)\n",c->status_block->iop_state);
-}
-#endif
-
- return 0;
-}
-
-/*
- * Get the Hardware Resource Table for the device.
- * The HRT contains information about possible hidden devices
- * but is mostly useless to us
- */
-int i2o_hrt_get(struct i2o_controller *c)
-{
- u32 msg[6];
- int ret, size = sizeof(i2o_hrt);
- int loops = 3; /* we only try 3 times to get the HRT, this should be
- more then enough. Worst case should be 2 times.*/
-
- /* First read just the header to figure out the real size */
-
- do {
- /* first we allocate the memory for the HRT */
- if (c->hrt == NULL) {
- c->hrt=pci_alloc_consistent(c->pdev, size, &c->hrt_phys);
- if (c->hrt == NULL) {
- printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", c->name);
- return -ENOMEM;
- }
- c->hrt_len = size;
- }
-
- msg[0]= SIX_WORD_MSG_SIZE| SGL_OFFSET_4;
- msg[1]= I2O_CMD_HRT_GET<<24 | HOST_TID<<12 | ADAPTER_TID;
- msg[3]= 0;
- msg[4]= (0xD0000000 | c->hrt_len); /* Simple transaction */
- msg[5]= c->hrt_phys; /* Dump it here */
-
- ret = i2o_post_wait_mem(c, msg, sizeof(msg), 20, c->hrt, NULL, c->hrt_phys, 0, c->hrt_len, 0);
-
- if(ret == -ETIMEDOUT)
- {
- /* The HRT block we used is in limbo somewhere. When the iop wakes up
- we will recover it */
- c->hrt = NULL;
- c->hrt_len = 0;
- return ret;
- }
-
- if(ret<0)
- {
- printk(KERN_ERR "%s: Unable to get HRT (status=%#x)\n",
- c->name, -ret);
- return ret;
- }
-
- if (c->hrt->num_entries * c->hrt->entry_len << 2 > c->hrt_len) {
- size = c->hrt->num_entries * c->hrt->entry_len << 2;
- pci_free_consistent(c->pdev, c->hrt_len, c->hrt, c->hrt_phys);
- c->hrt_len = 0;
- c->hrt = NULL;
- }
- loops --;
- } while (c->hrt == NULL && loops > 0);
-
- if(c->hrt == NULL)
- {
- printk(KERN_ERR "%s: Unable to get HRT after three tries, giving up\n", c->name);
- return -1;
- }
-
- i2o_parse_hrt(c); // just for debugging
-
- return 0;
-}
-
-/*
- * Send the I2O System Table to the specified IOP
- *
- * The system table contains information about all the IOPs in the
- * system. It is build and then sent to each IOP so that IOPs can
- * establish connections between each other.
- *
- */
-static int i2o_systab_send(struct i2o_controller *iop)
-{
- u32 msg[12];
- dma_addr_t sys_tbl_phys;
- int ret;
- struct resource *root;
- u32 *privbuf = kmalloc(16, GFP_KERNEL);
- if(privbuf == NULL)
- return -ENOMEM;
-
-
- if(iop->status_block->current_mem_size < iop->status_block->desired_mem_size)
- {
- struct resource *res = &iop->mem_resource;
- res->name = iop->pdev->bus->name;
- res->flags = IORESOURCE_MEM;
- res->start = 0;
- res->end = 0;
- printk("%s: requires private memory resources.\n", iop->name);
- root = pci_find_parent_resource(iop->pdev, res);
- if(root==NULL)
- printk("Can't find parent resource!\n");
- if(root && allocate_resource(root, res,
- iop->status_block->desired_mem_size,
- iop->status_block->desired_mem_size,
- iop->status_block->desired_mem_size,
- 1<<20, /* Unspecified, so use 1Mb and play safe */
- NULL,
- NULL)>=0)
- {
- iop->mem_alloc = 1;
- iop->status_block->current_mem_size = 1 + res->end - res->start;
- iop->status_block->current_mem_base = res->start;
- printk(KERN_INFO "%s: allocated %ld bytes of PCI memory at 0x%08lX.\n",
- iop->name, 1+res->end-res->start, res->start);
- }
- }
- if(iop->status_block->current_io_size < iop->status_block->desired_io_size)
- {
- struct resource *res = &iop->io_resource;
- res->name = iop->pdev->bus->name;
- res->flags = IORESOURCE_IO;
- res->start = 0;
- res->end = 0;
- printk("%s: requires private memory resources.\n", iop->name);
- root = pci_find_parent_resource(iop->pdev, res);
- if(root==NULL)
- printk("Can't find parent resource!\n");
- if(root && allocate_resource(root, res,
- iop->status_block->desired_io_size,
- iop->status_block->desired_io_size,
- iop->status_block->desired_io_size,
- 1<<20, /* Unspecified, so use 1Mb and play safe */
- NULL,
- NULL)>=0)
- {
- iop->io_alloc = 1;
- iop->status_block->current_io_size = 1 + res->end - res->start;
- iop->status_block->current_mem_base = res->start;
- printk(KERN_INFO "%s: allocated %ld bytes of PCI I/O at 0x%08lX.\n",
- iop->name, 1+res->end-res->start, res->start);
- }
- }
- else
- {
- privbuf[0] = iop->status_block->current_mem_base;
- privbuf[1] = iop->status_block->current_mem_size;
- privbuf[2] = iop->status_block->current_io_base;
- privbuf[3] = iop->status_block->current_io_size;
- }
-
- msg[0] = I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6;
- msg[1] = I2O_CMD_SYS_TAB_SET<<24 | HOST_TID<<12 | ADAPTER_TID;
- msg[3] = 0;
- msg[4] = (0<<16) | ((iop->unit+2) ); /* Host 0 IOP ID (unit + 2) */
- msg[5] = 0; /* Segment 0 */
-
- /*
- * Provide three SGL-elements:
- * System table (SysTab), Private memory space declaration and
- * Private i/o space declaration
- *
- * Nasty one here. We can't use pci_alloc_consistent to send the
- * same table to everyone. We have to go remap it for them all
- */
-
- sys_tbl_phys = pci_map_single(iop->pdev, sys_tbl, sys_tbl_len, PCI_DMA_TODEVICE);
- msg[6] = 0x54000000 | sys_tbl_phys;
-
- msg[7] = sys_tbl_phys;
- msg[8] = 0x54000000 | privbuf[1];
- msg[9] = privbuf[0];
- msg[10] = 0xD4000000 | privbuf[3];
- msg[11] = privbuf[2];
-
- ret=i2o_post_wait(iop, msg, sizeof(msg), 120);
-
- pci_unmap_single(iop->pdev, sys_tbl_phys, sys_tbl_len, PCI_DMA_TODEVICE);
-
- if(ret==-ETIMEDOUT)
- {
- printk(KERN_ERR "%s: SysTab setup timed out.\n", iop->name);
- }
- else if(ret<0)
- {
- printk(KERN_ERR "%s: Unable to set SysTab (status=%#x).\n",
- iop->name, -ret);
- }
- else
- {
- dprintk(KERN_INFO "%s: SysTab set.\n", iop->name);
- }
- i2o_status_get(iop); // Entered READY state
-
- kfree(privbuf);
- return ret;
-
- }
-
-/*
- * Initialize I2O subsystem.
- */
-void __init i2o_sys_init(void)
-{
- struct i2o_controller *iop, *niop = NULL;
-
- printk(KERN_INFO "Activating I2O controllers...\n");
- printk(KERN_INFO "This may take a few minutes if there are many devices\n");
-
- /* In INIT state, Activate IOPs */
- for (iop = i2o_controller_chain; iop; iop = niop) {
- dprintk(KERN_INFO "Calling i2o_activate_controller for %s...\n",
- iop->name);
- niop = iop->next;
- if (i2o_activate_controller(iop) < 0)
- i2o_delete_controller(iop);
- }
-
- /* Active IOPs in HOLD state */
-
-rebuild_sys_tab:
- if (i2o_controller_chain == NULL)
- return;
-
- /*
- * If build_sys_table fails, we kill everything and bail
- * as we can't init the IOPs w/o a system table
- */
- dprintk(KERN_INFO "i2o_core: Calling i2o_build_sys_table...\n");
- if (i2o_build_sys_table() < 0) {
- i2o_sys_shutdown();
- return;
- }
-
- /* If IOP don't get online, we need to rebuild the System table */
- for (iop = i2o_controller_chain; iop; iop = niop) {
- niop = iop->next;
- dprintk(KERN_INFO "Calling i2o_online_controller for %s...\n", iop->name);
- if (i2o_online_controller(iop) < 0) {
- i2o_delete_controller(iop);
- goto rebuild_sys_tab;
- }
- }
-
- /* Active IOPs now in OPERATIONAL state */
-
- /*
- * Register for status updates from all IOPs
- */
- for(iop = i2o_controller_chain; iop; iop=iop->next) {
-
- /* Create a kernel thread to deal with dynamic LCT updates */
- iop->lct_pid = kernel_thread(i2o_dyn_lct, iop, CLONE_SIGHAND);
-
- /* Update change ind on DLCT */
- iop->dlct->change_ind = iop->lct->change_ind;
-
- /* Start dynamic LCT updates */
- i2o_lct_notify(iop);
-
- /* Register for all events from IRTOS */
- i2o_event_register(iop, core_context, 0, 0, 0xFFFFFFFF);
- }
-}
-
-/**
- * i2o_sys_shutdown - shutdown I2O system
- *
- * Bring down each i2o controller and then return. Each controller
- * is taken through an orderly shutdown
- */
-
-static void i2o_sys_shutdown(void)
-{
- struct i2o_controller *iop, *niop;
-
- /* Delete all IOPs from the controller chain */
- /* that will reset all IOPs too */
-
- for (iop = i2o_controller_chain; iop; iop = niop) {
- niop = iop->next;
- i2o_delete_controller(iop);
- }
-}
-
-/**
- * i2o_activate_controller - bring controller up to HOLD
- * @iop: controller
- *
- * This function brings an I2O controller into HOLD state. The adapter
- * is reset if necessary and then the queues and resource table
- * are read. -1 is returned on a failure, 0 on success.
- *
- */
-
-int i2o_activate_controller(struct i2o_controller *iop)
-{
- /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */
- /* In READY state, Get status */
-
- if (i2o_status_get(iop) < 0) {
- printk(KERN_INFO "Unable to obtain status of %s, "
- "attempting a reset.\n", iop->name);
- if (i2o_reset_controller(iop) < 0)
- return -1;
- }
-
- if(iop->status_block->iop_state == ADAPTER_STATE_FAULTED) {
- printk(KERN_CRIT "%s: hardware fault\n", iop->name);
- return -1;
- }
-
- if (iop->status_block->i2o_version > I2OVER15) {
- printk(KERN_ERR "%s: Not running vrs. 1.5. of the I2O Specification.\n",
- iop->name);
- return -1;
- }
-
- if (iop->status_block->iop_state == ADAPTER_STATE_READY ||
- iop->status_block->iop_state == ADAPTER_STATE_OPERATIONAL ||
- iop->status_block->iop_state == ADAPTER_STATE_HOLD ||
- iop->status_block->iop_state == ADAPTER_STATE_FAILED)
- {
- dprintk(KERN_INFO "%s: Already running, trying to reset...\n",
- iop->name);
- if (i2o_reset_controller(iop) < 0)
- return -1;
- }
-
- if (i2o_init_outbound_q(iop) < 0)
- return -1;
-
- if (i2o_post_outbound_messages(iop))
- return -1;
-
- /* In HOLD state */
-
- if (i2o_hrt_get(iop) < 0)
- return -1;
-
- return 0;
-}
-
-
-/**
- * i2o_init_outbound_queue - setup the outbound queue
- * @c: controller
- *
- * Clear and (re)initialize IOP's outbound queue. Returns 0 on
- * success or a negative errno code on a failure.
- */
-
-int i2o_init_outbound_q(struct i2o_controller *c)
-{
- u8 *status;
- dma_addr_t status_phys;
- u32 m;
- u32 *msg;
- u32 time;
-
- dprintk(KERN_INFO "%s: Initializing Outbound Queue...\n", c->name);
- m=i2o_wait_message(c, "OutboundInit");
- if(m==0xFFFFFFFF)
- return -ETIMEDOUT;
- msg=(u32 *)(c->msg_virt+m);
-
- status = pci_alloc_consistent(c->pdev, 4, &status_phys);
- if (status==NULL) {
- printk(KERN_ERR "%s: Outbound Queue initialization failed - no free memory.\n",
- c->name);
- return -ENOMEM;
- }
- memset(status, 0, 4);
-
- msg[0]= EIGHT_WORD_MSG_SIZE| TRL_OFFSET_6;
- msg[1]= I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID;
- msg[2]= core_context;
- msg[3]= 0x0106; /* Transaction context */
- msg[4]= 4096; /* Host page frame size */
- /* Frame size is in words. 256 bytes a frame for now */
- msg[5]= MSG_FRAME_SIZE<<16|0x80; /* Outbound msg frame size in words and Initcode */
- msg[6]= 0xD0000004; /* Simple SG LE, EOB */
- msg[7]= status_phys;
-
- i2o_post_message(c,m);
-
- barrier();
- time=jiffies;
- while(status[0] < I2O_CMD_REJECTED)
- {
- if((jiffies-time)>=30*HZ)
- {
- if(status[0]==0x00)
- printk(KERN_ERR "%s: Ignored queue initialize request.\n",
- c->name);
- else
- printk(KERN_ERR "%s: Outbound queue initialize timeout.\n",
- c->name);
- pci_free_consistent(c->pdev, 4, status, status_phys);
- return -ETIMEDOUT;
- }
- yield();
- barrier();
- }
-
- if(status[0] != I2O_CMD_COMPLETED)
- {
- printk(KERN_ERR "%s: IOP outbound initialise failed.\n", c->name);
- pci_free_consistent(c->pdev, 4, status, status_phys);
- return -ETIMEDOUT;
- }
- pci_free_consistent(c->pdev, 4, status, status_phys);
- return 0;
-}
-
-/**
- * i2o_post_outbound_messages - fill message queue
- * @c: controller
- *
- * Allocate a message frame and load the messages into the IOP. The
- * function returns zero on success or a negative errno code on
- * failure.
- */
-
-int i2o_post_outbound_messages(struct i2o_controller *c)
-{
- int i;
- u32 m;
- /* Alloc space for IOP's outbound queue message frames */
-
- c->page_frame = kmalloc(MSG_POOL_SIZE, GFP_KERNEL);
- if(c->page_frame==NULL) {
- printk(KERN_ERR "%s: Outbound Q initialize failed; out of memory.\n",
- c->name);
- return -ENOMEM;
- }
-
- c->page_frame_map = pci_map_single(c->pdev, c->page_frame, MSG_POOL_SIZE, PCI_DMA_FROMDEVICE);
-
- if(c->page_frame_map == 0)
- {
- kfree(c->page_frame);
- printk(KERN_ERR "%s: Unable to map outbound queue.\n", c->name);
- return -ENOMEM;
- }
-
- m = c->page_frame_map;
-
- /* Post frames */
-
- for(i=0; i< NMBR_MSG_FRAMES; i++) {
- I2O_REPLY_WRITE32(c,m);
- mb();
- m += (MSG_FRAME_SIZE << 2);
- }
-
- return 0;
-}
-
-/*
- * Get the IOP's Logical Configuration Table
- */
-int i2o_lct_get(struct i2o_controller *c)
-{
- u32 msg[8];
- int ret, size = c->status_block->expected_lct_size;
-
- do {
- if (c->lct == NULL) {
- c->lct = pci_alloc_consistent(c->pdev, size, &c->lct_phys);
- if(c->lct == NULL) {
- printk(KERN_CRIT "%s: Lct Get failed. Out of memory.\n",
- c->name);
- return -ENOMEM;
- }
- }
- memset(c->lct, 0, size);
-
- msg[0] = EIGHT_WORD_MSG_SIZE|SGL_OFFSET_6;
- msg[1] = I2O_CMD_LCT_NOTIFY<<24 | HOST_TID<<12 | ADAPTER_TID;
- /* msg[2] filled in i2o_post_wait */
- msg[3] = 0;
- msg[4] = 0xFFFFFFFF; /* All devices */
- msg[5] = 0x00000000; /* Report now */
- msg[6] = 0xD0000000|size;
- msg[7] = c->lct_phys;
-
- ret=i2o_post_wait_mem(c, msg, sizeof(msg), 120, c->lct, NULL, c->lct_phys, 0, size, 0);
-
- if(ret == -ETIMEDOUT)
- {
- c->lct = NULL;
- return ret;
- }
-
- if(ret<0)
- {
- printk(KERN_ERR "%s: LCT Get failed (status=%#x.\n",
- c->name, -ret);
- return ret;
- }
-
- if (c->lct->table_size << 2 > size) {
- int new_size = c->lct->table_size << 2;
- pci_free_consistent(c->pdev, size, c->lct, c->lct_phys);
- size = new_size;
- c->lct = NULL;
- }
- } while (c->lct == NULL);
-
- if ((ret=i2o_parse_lct(c)) < 0)
- return ret;
-
- return 0;
-}
-
-/*
- * Like above, but used for async notification. The main
- * difference is that we keep track of the CurrentChangeIndiicator
- * so that we only get updates when it actually changes.
- *
- */
-int i2o_lct_notify(struct i2o_controller *c)
-{
- u32 msg[8];
-
- msg[0] = EIGHT_WORD_MSG_SIZE|SGL_OFFSET_6;
- msg[1] = I2O_CMD_LCT_NOTIFY<<24 | HOST_TID<<12 | ADAPTER_TID;
- msg[2] = core_context;
- msg[3] = 0xDEADBEEF;
- msg[4] = 0xFFFFFFFF; /* All devices */
- msg[5] = c->dlct->change_ind+1; /* Next change */
- msg[6] = 0xD0000000|8192;
- msg[7] = c->dlct_phys;
-
- return i2o_post_this(c, msg, sizeof(msg));
-}
-
-/*
- * Bring a controller online into OPERATIONAL state.
- */
-
-int i2o_online_controller(struct i2o_controller *iop)
-{
- u32 v;
-
- if (i2o_systab_send(iop) < 0)
- return -1;
-
- /* In READY state */
-
- dprintk(KERN_INFO "%s: Attempting to enable...\n", iop->name);
- if (i2o_enable_controller(iop) < 0)
- return -1;
-
- /* In OPERATIONAL state */
-
- dprintk(KERN_INFO "%s: Attempting to get/parse lct...\n", iop->name);
- if (i2o_lct_get(iop) < 0)
- return -1;
-
- /* Check battery status */
-
- iop->battery = 0;
- if(i2o_query_scalar(iop, ADAPTER_TID, 0x0000, 4, &v, 4)>=0)
- {
- if(v&16)
- iop->battery = 1;
- }
-
- return 0;
-}
-
-/*
- * Build system table
- *
- * The system table contains information about all the IOPs in the
- * system (duh) and is used by the Executives on the IOPs to establish
- * peer2peer connections. We're not supporting peer2peer at the moment,
- * but this will be needed down the road for things like lan2lan forwarding.
- */
-static int i2o_build_sys_table(void)
-{
- struct i2o_controller *iop = NULL;
- struct i2o_controller *niop = NULL;
- int count = 0;
-
- sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs
- (i2o_num_controllers) *
- sizeof(struct i2o_sys_tbl_entry);
-
- if(sys_tbl)
- kfree(sys_tbl);
-
- sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL);
- if(!sys_tbl) {
- printk(KERN_CRIT "SysTab Set failed. Out of memory.\n");
- return -ENOMEM;
- }
- memset((void*)sys_tbl, 0, sys_tbl_len);
-
- sys_tbl->num_entries = i2o_num_controllers;
- sys_tbl->version = I2OVERSION; /* TODO: Version 2.0 */
- sys_tbl->change_ind = sys_tbl_ind++;
-
- for(iop = i2o_controller_chain; iop; iop = niop)
- {
- niop = iop->next;
-
- /*
- * Get updated IOP state so we have the latest information
- *
- * We should delete the controller at this point if it
- * doesn't respond since if it's not on the system table
- * it is techninically not part of the I2O subsyßtem...
- */
- if(i2o_status_get(iop)) {
- printk(KERN_ERR "%s: Deleting b/c could not get status while"
- "attempting to build system table\n", iop->name);
- i2o_delete_controller(iop);
- sys_tbl->num_entries--;
- continue; // try the next one
- }
-
- sys_tbl->iops[count].org_id = iop->status_block->org_id;
- sys_tbl->iops[count].iop_id = iop->unit + 2;
- sys_tbl->iops[count].seg_num = 0;
- sys_tbl->iops[count].i2o_version =
- iop->status_block->i2o_version;
- sys_tbl->iops[count].iop_state =
- iop->status_block->iop_state;
- sys_tbl->iops[count].msg_type =
- iop->status_block->msg_type;
- sys_tbl->iops[count].frame_size =
- iop->status_block->inbound_frame_size;
- sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ??
- sys_tbl->iops[count].iop_capabilities =
- iop->status_block->iop_capabilities;
- sys_tbl->iops[count].inbound_low = (u32)iop->post_port;
- sys_tbl->iops[count].inbound_high = 0; // FIXME: 64-bit support
-
- count++;
- }
-
-#ifdef DRIVERDEBUG
-{
- u32 *table;
- table = (u32*)sys_tbl;
- for(count = 0; count < (sys_tbl_len >>2); count++)
- printk(KERN_INFO "sys_tbl[%d] = %0#10x\n", count, table[count]);
-}
-#endif
-
- return 0;
-}
-
-
-/*
- * Run time support routines
- */
-
-/*
- * Generic "post and forget" helpers. This is less efficient - we do
- * a memcpy for example that isnt strictly needed, but for most uses
- * this is simply not worth optimising
- */
-
-int i2o_post_this(struct i2o_controller *c, u32 *data, int len)
-{
- u32 m;
- u32 *msg;
- unsigned long t=jiffies;
-
- do
- {
- mb();
- m = I2O_POST_READ32(c);
- }
- while(m==0xFFFFFFFF && (jiffies-t)<HZ);
-
- if(m==0xFFFFFFFF)
- {
- printk(KERN_ERR "%s: Timeout waiting for message frame!\n",
- c->name);
- return -ETIMEDOUT;
- }
- msg = (u32 *)(c->msg_virt + m);
- memcpy_toio(msg, data, len);
- i2o_post_message(c,m);
- return 0;
-}
-
-/**
- * i2o_post_wait_mem - I2O query/reply with DMA buffers
- * @c: controller
- * @msg: message to send
- * @len: length of message
- * @timeout: time in seconds to wait
- * @mem1: attached memory buffer 1
- * @mem2: attached memory buffer 2
- * @phys1: physical address of buffer 1
- * @phys2: physical address of buffer 2
- * @size1: size of buffer 1
- * @size2: size of buffer 2
- *
- * This core API allows an OSM to post a message and then be told whether
- * or not the system received a successful reply.
- *
- * If the message times out then the value '-ETIMEDOUT' is returned. This
- * is a special case. In this situation the message may (should) complete
- * at an indefinite time in the future. When it completes it will use the
- * memory buffers attached to the request. If -ETIMEDOUT is returned then
- * the memory buffers must not be freed. Instead the event completion will
- * free them for you. In all other cases the buffers are your problem.
- *
- * Pass NULL for unneeded buffers.
- */
-
-int i2o_post_wait_mem(struct i2o_controller *c, u32 *msg, int len, int timeout, void *mem1, void *mem2, dma_addr_t phys1, dma_addr_t phys2, int size1, int size2)
-{
- DECLARE_WAIT_QUEUE_HEAD(wq_i2o_post);
- DECLARE_WAITQUEUE(wait, current);
- int complete = 0;
- int status;
- unsigned long flags = 0;
- struct i2o_post_wait_data *wait_data =
- kmalloc(sizeof(struct i2o_post_wait_data), GFP_KERNEL);
-
- if(!wait_data)
- return -ENOMEM;
-
- /*
- * Create a new notification object
- */
- wait_data->status = &status;
- wait_data->complete = &complete;
- wait_data->mem[0] = mem1;
- wait_data->mem[1] = mem2;
- wait_data->phys[0] = phys1;
- wait_data->phys[1] = phys2;
- wait_data->size[0] = size1;
- wait_data->size[1] = size2;
-
- /*
- * Queue the event with its unique id
- */
- spin_lock_irqsave(&post_wait_lock, flags);
-
- wait_data->next = post_wait_queue;
- post_wait_queue = wait_data;
- wait_data->id = (++post_wait_id) & 0x7fff;
- wait_data->wq = &wq_i2o_post;
-
- spin_unlock_irqrestore(&post_wait_lock, flags);
-
- /*
- * Fill in the message id
- */
-
- msg[2] = 0x80000000|(u32)core_context|((u32)wait_data->id<<16);
-
- /*
- * Post the message to the controller. At some point later it
- * will return. If we time out before it returns then
- * complete will be zero. From the point post_this returns
- * the wait_data may have been deleted.
- */
-
- add_wait_queue(&wq_i2o_post, &wait);
- set_current_state(TASK_INTERRUPTIBLE);
- if ((status = i2o_post_this(c, msg, len))==0) {
- schedule_timeout(HZ * timeout);
- }
- else
- {
- remove_wait_queue(&wq_i2o_post, &wait);
- return -EIO;
- }
- remove_wait_queue(&wq_i2o_post, &wait);
-
- if(signal_pending(current))
- status = -EINTR;
-
- spin_lock_irqsave(&post_wait_lock, flags);
- barrier(); /* Be sure we see complete as it is locked */
- if(!complete)
- {
- /*
- * Mark the entry dead. We cannot remove it. This is important.
- * When it does terminate (which it must do if the controller hasnt
- * died..) then it will otherwise scribble on stuff.
- * !complete lets us safely check if the entry is still
- * allocated and thus we can write into it
- */
- wait_data->wq = NULL;
- status = -ETIMEDOUT;
- }
- else
- {
- /* Debugging check - remove me soon */
- if(status == -ETIMEDOUT)
- {
- printk("TIMEDOUT BUG!\n");
- status = -EIO;
- }
- }
- /* And the wait_data is not leaked either! */
- spin_unlock_irqrestore(&post_wait_lock, flags);
- return status;
-}
-
-/**
- * i2o_post_wait - I2O query/reply
- * @c: controller
- * @msg: message to send
- * @len: length of message
- * @timeout: time in seconds to wait
- *
- * This core API allows an OSM to post a message and then be told whether
- * or not the system received a successful reply.
- */
-
-int i2o_post_wait(struct i2o_controller *c, u32 *msg, int len, int timeout)
-{
- return i2o_post_wait_mem(c, msg, len, timeout, NULL, NULL, 0, 0, 0, 0);
-}
-
-/*
- * i2o_post_wait is completed and we want to wake up the
- * sleeping proccess. Called by core's reply handler.
- */
-
-static void i2o_post_wait_complete(struct i2o_controller *c, u32 context, int status)
-{
- struct i2o_post_wait_data **p1, *q;
- unsigned long flags;
-
- /*
- * We need to search through the post_wait
- * queue to see if the given message is still
- * outstanding. If not, it means that the IOP
- * took longer to respond to the message than we
- * had allowed and timer has already expired.
- * Not much we can do about that except log
- * it for debug purposes, increase timeout, and recompile
- *
- * Lock needed to keep anyone from moving queue pointers
- * around while we're looking through them.
- */
-
- spin_lock_irqsave(&post_wait_lock, flags);
-
- for(p1 = &post_wait_queue; *p1!=NULL; p1 = &((*p1)->next))
- {
- q = (*p1);
- if(q->id == ((context >> 16) & 0x7fff)) {
- /*
- * Delete it
- */
-
- *p1 = q->next;
-
- /*
- * Live or dead ?
- */
-
- if(q->wq)
- {
- /* Live entry - wakeup and set status */
- *q->status = status;
- *q->complete = 1;
- wake_up(q->wq);
- }
- else
- {
- /*
- * Free resources. Caller is dead
- */
-
- if(q->mem[0])
- pci_free_consistent(c->pdev, q->size[0], q->mem[0], q->phys[0]);
- if(q->mem[1])
- pci_free_consistent(c->pdev, q->size[1], q->mem[1], q->phys[1]);
-
- printk(KERN_WARNING "i2o_post_wait event completed after timeout.\n");
- }
- kfree(q);
- spin_unlock(&post_wait_lock);
- return;
- }
- }
- spin_unlock(&post_wait_lock);
-
- printk(KERN_DEBUG "i2o_post_wait: Bogus reply!\n");
-}
-
-/* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
- *
- * This function can be used for all UtilParamsGet/Set operations.
- * The OperationList is given in oplist-buffer,
- * and results are returned in reslist-buffer.
- * Note that the minimum sized reslist is 8 bytes and contains
- * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
- */
-
-int i2o_issue_params(int cmd, struct i2o_controller *iop, int tid,
- void *oplist, int oplen, void *reslist, int reslen)
-{
- u32 msg[9];
- u32 *res32 = (u32*)reslist;
- u32 *restmp = (u32*)reslist;
- int len = 0;
- int i = 0;
- int wait_status;
- u32 *opmem, *resmem;
- dma_addr_t opmem_phys, resmem_phys;
-
- /* Get DMAable memory */
- opmem = pci_alloc_consistent(iop->pdev, oplen, &opmem_phys);
- if(opmem == NULL)
- return -ENOMEM;
- memcpy(opmem, oplist, oplen);
-
- resmem = pci_alloc_consistent(iop->pdev, reslen, &resmem_phys);
- if(resmem == NULL)
- {
- pci_free_consistent(iop->pdev, oplen, opmem, opmem_phys);
- return -ENOMEM;
- }
-
- msg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_5;
- msg[1] = cmd << 24 | HOST_TID << 12 | tid;
- msg[3] = 0;
- msg[4] = 0;
- msg[5] = 0x54000000 | oplen; /* OperationList */
- msg[6] = opmem_phys;
- msg[7] = 0xD0000000 | reslen; /* ResultList */
- msg[8] = resmem_phys;
-
- wait_status = i2o_post_wait_mem(iop, msg, sizeof(msg), 10, opmem, resmem, opmem_phys, resmem_phys, oplen, reslen);
-
- /*
- * This only looks like a memory leak - don't "fix" it.
- */
- if(wait_status == -ETIMEDOUT)
- return wait_status;
-
- memcpy(reslist, resmem, reslen);
- pci_free_consistent(iop->pdev, reslen, resmem, resmem_phys);
- pci_free_consistent(iop->pdev, oplen, opmem, opmem_phys);
-
- /* Query failed */
- if(wait_status != 0)
- return wait_status;
- /*
- * Calculate number of bytes of Result LIST
- * We need to loop through each Result BLOCK and grab the length
- */
- restmp = res32 + 1;
- len = 1;
- for(i = 0; i < (res32[0]&0X0000FFFF); i++)
- {
- if(restmp[0]&0x00FF0000) /* BlockStatus != SUCCESS */
- {
- printk(KERN_WARNING "%s - Error:\n ErrorInfoSize = 0x%02x, "
- "BlockStatus = 0x%02x, BlockSize = 0x%04x\n",
- (cmd == I2O_CMD_UTIL_PARAMS_SET) ? "PARAMS_SET"
- : "PARAMS_GET",
- res32[1]>>24, (res32[1]>>16)&0xFF, res32[1]&0xFFFF);
-
- /*
- * If this is the only request,than we return an error
- */
- if((res32[0]&0x0000FFFF) == 1)
- {
- return -((res32[1] >> 16) & 0xFF); /* -BlockStatus */
- }
- }
- len += restmp[0] & 0x0000FFFF; /* Length of res BLOCK */
- restmp += restmp[0] & 0x0000FFFF; /* Skip to next BLOCK */
- }
- return (len << 2); /* bytes used by result list */
-}
-
-/*
- * Query one scalar group value or a whole scalar group.
- */
-int i2o_query_scalar(struct i2o_controller *iop, int tid,
- int group, int field, void *buf, int buflen)
-{
- u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field };
- u8 resblk[8+buflen]; /* 8 bytes for header */
- int size;
-
- if (field == -1) /* whole group */
- opblk[4] = -1;
-
- size = i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, iop, tid,
- opblk, sizeof(opblk), resblk, sizeof(resblk));
-
- memcpy(buf, resblk+8, buflen); /* cut off header */
-
- if(size>buflen)
- return buflen;
- return size;
-}
-
-/*
- * Set a scalar group value or a whole group.
- */
-int i2o_set_scalar(struct i2o_controller *iop, int tid,
- int group, int field, void *buf, int buflen)
-{
- u16 *opblk;
- u8 resblk[8+buflen]; /* 8 bytes for header */
- int size;
-
- opblk = kmalloc(buflen+64, GFP_KERNEL);
- if (opblk == NULL)
- {
- printk(KERN_ERR "i2o: no memory for operation buffer.\n");
- return -ENOMEM;
- }
-
- opblk[0] = 1; /* operation count */
- opblk[1] = 0; /* pad */
- opblk[2] = I2O_PARAMS_FIELD_SET;
- opblk[3] = group;
-
- if(field == -1) { /* whole group */
- opblk[4] = -1;
- memcpy(opblk+5, buf, buflen);
- }
- else /* single field */
- {
- opblk[4] = 1;
- opblk[5] = field;
- memcpy(opblk+6, buf, buflen);
- }
-
- size = i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET, iop, tid,
- opblk, 12+buflen, resblk, sizeof(resblk));
-
- kfree(opblk);
- if(size>buflen)
- return buflen;
- return size;
-}
-
-/*
- * if oper == I2O_PARAMS_TABLE_GET, get from all rows
- * if fieldcount == -1 return all fields
- * ibuf and ibuflen are unused (use NULL, 0)
- * else return specific fields
- * ibuf contains fieldindexes
- *
- * if oper == I2O_PARAMS_LIST_GET, get from specific rows
- * if fieldcount == -1 return all fields
- * ibuf contains rowcount, keyvalues
- * else return specific fields
- * fieldcount is # of fieldindexes
- * ibuf contains fieldindexes, rowcount, keyvalues
- *
- * You could also use directly function i2o_issue_params().
- */
-int i2o_query_table(int oper, struct i2o_controller *iop, int tid, int group,
- int fieldcount, void *ibuf, int ibuflen,
- void *resblk, int reslen)
-{
- u16 *opblk;
- int size;
-
- opblk = kmalloc(10 + ibuflen, GFP_KERNEL);
- if (opblk == NULL)
- {
- printk(KERN_ERR "i2o: no memory for query buffer.\n");
- return -ENOMEM;
- }
-
- opblk[0] = 1; /* operation count */
- opblk[1] = 0; /* pad */
- opblk[2] = oper;
- opblk[3] = group;
- opblk[4] = fieldcount;
- memcpy(opblk+5, ibuf, ibuflen); /* other params */
-
- size = i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET,iop, tid,
- opblk, 10+ibuflen, resblk, reslen);
-
- kfree(opblk);
- if(size>reslen)
- return reslen;
- return size;
-}
-
-/*
- * Clear table group, i.e. delete all rows.
- */
-int i2o_clear_table(struct i2o_controller *iop, int tid, int group)
-{
- u16 opblk[] = { 1, 0, I2O_PARAMS_TABLE_CLEAR, group };
- u8 resblk[32]; /* min 8 bytes for result header */
-
- return i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET, iop, tid,
- opblk, sizeof(opblk), resblk, sizeof(resblk));
-}
-
-/*
- * Add a new row into a table group.
- *
- * if fieldcount==-1 then we add whole rows
- * buf contains rowcount, keyvalues
- * else just specific fields are given, rest use defaults
- * buf contains fieldindexes, rowcount, keyvalues
- */
-int i2o_row_add_table(struct i2o_controller *iop, int tid,
- int group, int fieldcount, void *buf, int buflen)
-{
- u16 *opblk;
- u8 resblk[32]; /* min 8 bytes for header */
- int size;
-
- opblk = kmalloc(buflen+64, GFP_KERNEL);
- if (opblk == NULL)
- {
- printk(KERN_ERR "i2o: no memory for operation buffer.\n");
- return -ENOMEM;
- }
-
- opblk[0] = 1; /* operation count */
- opblk[1] = 0; /* pad */
- opblk[2] = I2O_PARAMS_ROW_ADD;
- opblk[3] = group;
- opblk[4] = fieldcount;
- memcpy(opblk+5, buf, buflen);
-
- size = i2o_issue_params(I2O_CMD_UTIL_PARAMS_SET, iop, tid,
- opblk, 10+buflen, resblk, sizeof(resblk));
-
- kfree(opblk);
- if(size>buflen)
- return buflen;
- return size;
-}
-
-
-/*
- * Used for error reporting/debugging purposes.
- * Following fail status are common to all classes.
- * The preserved message must be handled in the reply handler.
- */
-void i2o_report_fail_status(u8 req_status, u32* msg)
-{
- static char *FAIL_STATUS[] = {
- "0x80", /* not used */
- "SERVICE_SUSPENDED", /* 0x81 */
- "SERVICE_TERMINATED", /* 0x82 */
- "CONGESTION",
- "FAILURE",
- "STATE_ERROR",
- "TIME_OUT",
- "ROUTING_FAILURE",
- "INVALID_VERSION",
- "INVALID_OFFSET",
- "INVALID_MSG_FLAGS",
- "FRAME_TOO_SMALL",
- "FRAME_TOO_LARGE",
- "INVALID_TARGET_ID",
- "INVALID_INITIATOR_ID",
- "INVALID_INITIATOR_CONTEX", /* 0x8F */
- "UNKNOWN_FAILURE" /* 0xFF */
- };
-
- if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
- printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x)\n.", req_status);
- else
- printk("TRANSPORT_%s.\n", FAIL_STATUS[req_status & 0x0F]);
-
- /* Dump some details */
-
- printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
- (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
- printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
- (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
- printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
- msg[5] >> 16, msg[5] & 0xFFF);
-
- printk(KERN_ERR " Severity: 0x%02X ", (msg[4] >> 16) & 0xFF);
- if (msg[4] & (1<<16))
- printk("(FormatError), "
- "this msg can never be delivered/processed.\n");
- if (msg[4] & (1<<17))
- printk("(PathError), "
- "this msg can no longer be delivered/processed.\n");
- if (msg[4] & (1<<18))
- printk("(PathState), "
- "the system state does not allow delivery.\n");
- if (msg[4] & (1<<19))
- printk("(Congestion), resources temporarily not available;"
- "do not retry immediately.\n");
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Following reply status are common to all classes.
- */
-void i2o_report_common_status(u8 req_status)
-{
- static char *REPLY_STATUS[] = {
- "SUCCESS",
- "ABORT_DIRTY",
- "ABORT_NO_DATA_TRANSFER",
- "ABORT_PARTIAL_TRANSFER",
- "ERROR_DIRTY",
- "ERROR_NO_DATA_TRANSFER",
- "ERROR_PARTIAL_TRANSFER",
- "PROCESS_ABORT_DIRTY",
- "PROCESS_ABORT_NO_DATA_TRANSFER",
- "PROCESS_ABORT_PARTIAL_TRANSFER",
- "TRANSACTION_ERROR",
- "PROGRESS_REPORT"
- };
-
- if (req_status >= ARRAY_SIZE(REPLY_STATUS))
- printk("RequestStatus = %0#2x", req_status);
- else
- printk("%s", REPLY_STATUS[req_status]);
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Following detailed status are valid for executive class,
- * utility class, DDM class and for transaction error replies.
- */
-static void i2o_report_common_dsc(u16 detailed_status)
-{
- static char *COMMON_DSC[] = {
- "SUCCESS",
- "0x01", // not used
- "BAD_KEY",
- "TCL_ERROR",
- "REPLY_BUFFER_FULL",
- "NO_SUCH_PAGE",
- "INSUFFICIENT_RESOURCE_SOFT",
- "INSUFFICIENT_RESOURCE_HARD",
- "0x08", // not used
- "CHAIN_BUFFER_TOO_LARGE",
- "UNSUPPORTED_FUNCTION",
- "DEVICE_LOCKED",
- "DEVICE_RESET",
- "INAPPROPRIATE_FUNCTION",
- "INVALID_INITIATOR_ADDRESS",
- "INVALID_MESSAGE_FLAGS",
- "INVALID_OFFSET",
- "INVALID_PARAMETER",
- "INVALID_REQUEST",
- "INVALID_TARGET_ADDRESS",
- "MESSAGE_TOO_LARGE",
- "MESSAGE_TOO_SMALL",
- "MISSING_PARAMETER",
- "TIMEOUT",
- "UNKNOWN_ERROR",
- "UNKNOWN_FUNCTION",
- "UNSUPPORTED_VERSION",
- "DEVICE_BUSY",
- "DEVICE_NOT_AVAILABLE"
- };
-
- if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
- printk(" / DetailedStatus = %0#4x.\n", detailed_status);
- else
- printk(" / %s.\n", COMMON_DSC[detailed_status]);
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_lan_dsc(u16 detailed_status)
-{
- static char *LAN_DSC[] = { // Lan detailed status code strings
- "SUCCESS",
- "DEVICE_FAILURE",
- "DESTINATION_NOT_FOUND",
- "TRANSMIT_ERROR",
- "TRANSMIT_ABORTED",
- "RECEIVE_ERROR",
- "RECEIVE_ABORTED",
- "DMA_ERROR",
- "BAD_PACKET_DETECTED",
- "OUT_OF_MEMORY",
- "BUCKET_OVERRUN",
- "IOP_INTERNAL_ERROR",
- "CANCELED",
- "INVALID_TRANSACTION_CONTEXT",
- "DEST_ADDRESS_DETECTED",
- "DEST_ADDRESS_OMITTED",
- "PARTIAL_PACKET_RETURNED",
- "TEMP_SUSPENDED_STATE", // last Lan detailed status code
- "INVALID_REQUEST" // general detailed status code
- };
-
- if (detailed_status > I2O_DSC_INVALID_REQUEST)
- printk(" / %0#4x.\n", detailed_status);
- else
- printk(" / %s.\n", LAN_DSC[detailed_status]);
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_util_cmd(u8 cmd)
-{
- switch (cmd) {
- case I2O_CMD_UTIL_NOP:
- printk("UTIL_NOP, ");
- break;
- case I2O_CMD_UTIL_ABORT:
- printk("UTIL_ABORT, ");
- break;
- case I2O_CMD_UTIL_CLAIM:
- printk("UTIL_CLAIM, ");
- break;
- case I2O_CMD_UTIL_RELEASE:
- printk("UTIL_CLAIM_RELEASE, ");
- break;
- case I2O_CMD_UTIL_CONFIG_DIALOG:
- printk("UTIL_CONFIG_DIALOG, ");
- break;
- case I2O_CMD_UTIL_DEVICE_RESERVE:
- printk("UTIL_DEVICE_RESERVE, ");
- break;
- case I2O_CMD_UTIL_DEVICE_RELEASE:
- printk("UTIL_DEVICE_RELEASE, ");
- break;
- case I2O_CMD_UTIL_EVT_ACK:
- printk("UTIL_EVENT_ACKNOWLEDGE, ");
- break;
- case I2O_CMD_UTIL_EVT_REGISTER:
- printk("UTIL_EVENT_REGISTER, ");
- break;
- case I2O_CMD_UTIL_LOCK:
- printk("UTIL_LOCK, ");
- break;
- case I2O_CMD_UTIL_LOCK_RELEASE:
- printk("UTIL_LOCK_RELEASE, ");
- break;
- case I2O_CMD_UTIL_PARAMS_GET:
- printk("UTIL_PARAMS_GET, ");
- break;
- case I2O_CMD_UTIL_PARAMS_SET:
- printk("UTIL_PARAMS_SET, ");
- break;
- case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
- printk("UTIL_REPLY_FAULT_NOTIFY, ");
- break;
- default:
- printk("Cmd = %0#2x, ",cmd);
- }
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_exec_cmd(u8 cmd)
-{
- switch (cmd) {
- case I2O_CMD_ADAPTER_ASSIGN:
- printk("EXEC_ADAPTER_ASSIGN, ");
- break;
- case I2O_CMD_ADAPTER_READ:
- printk("EXEC_ADAPTER_READ, ");
- break;
- case I2O_CMD_ADAPTER_RELEASE:
- printk("EXEC_ADAPTER_RELEASE, ");
- break;
- case I2O_CMD_BIOS_INFO_SET:
- printk("EXEC_BIOS_INFO_SET, ");
- break;
- case I2O_CMD_BOOT_DEVICE_SET:
- printk("EXEC_BOOT_DEVICE_SET, ");
- break;
- case I2O_CMD_CONFIG_VALIDATE:
- printk("EXEC_CONFIG_VALIDATE, ");
- break;
- case I2O_CMD_CONN_SETUP:
- printk("EXEC_CONN_SETUP, ");
- break;
- case I2O_CMD_DDM_DESTROY:
- printk("EXEC_DDM_DESTROY, ");
- break;
- case I2O_CMD_DDM_ENABLE:
- printk("EXEC_DDM_ENABLE, ");
- break;
- case I2O_CMD_DDM_QUIESCE:
- printk("EXEC_DDM_QUIESCE, ");
- break;
- case I2O_CMD_DDM_RESET:
- printk("EXEC_DDM_RESET, ");
- break;
- case I2O_CMD_DDM_SUSPEND:
- printk("EXEC_DDM_SUSPEND, ");
- break;
- case I2O_CMD_DEVICE_ASSIGN:
- printk("EXEC_DEVICE_ASSIGN, ");
- break;
- case I2O_CMD_DEVICE_RELEASE:
- printk("EXEC_DEVICE_RELEASE, ");
- break;
- case I2O_CMD_HRT_GET:
- printk("EXEC_HRT_GET, ");
- break;
- case I2O_CMD_ADAPTER_CLEAR:
- printk("EXEC_IOP_CLEAR, ");
- break;
- case I2O_CMD_ADAPTER_CONNECT:
- printk("EXEC_IOP_CONNECT, ");
- break;
- case I2O_CMD_ADAPTER_RESET:
- printk("EXEC_IOP_RESET, ");
- break;
- case I2O_CMD_LCT_NOTIFY:
- printk("EXEC_LCT_NOTIFY, ");
- break;
- case I2O_CMD_OUTBOUND_INIT:
- printk("EXEC_OUTBOUND_INIT, ");
- break;
- case I2O_CMD_PATH_ENABLE:
- printk("EXEC_PATH_ENABLE, ");
- break;
- case I2O_CMD_PATH_QUIESCE:
- printk("EXEC_PATH_QUIESCE, ");
- break;
- case I2O_CMD_PATH_RESET:
- printk("EXEC_PATH_RESET, ");
- break;
- case I2O_CMD_STATIC_MF_CREATE:
- printk("EXEC_STATIC_MF_CREATE, ");
- break;
- case I2O_CMD_STATIC_MF_RELEASE:
- printk("EXEC_STATIC_MF_RELEASE, ");
- break;
- case I2O_CMD_STATUS_GET:
- printk("EXEC_STATUS_GET, ");
- break;
- case I2O_CMD_SW_DOWNLOAD:
- printk("EXEC_SW_DOWNLOAD, ");
- break;
- case I2O_CMD_SW_UPLOAD:
- printk("EXEC_SW_UPLOAD, ");
- break;
- case I2O_CMD_SW_REMOVE:
- printk("EXEC_SW_REMOVE, ");
- break;
- case I2O_CMD_SYS_ENABLE:
- printk("EXEC_SYS_ENABLE, ");
- break;
- case I2O_CMD_SYS_MODIFY:
- printk("EXEC_SYS_MODIFY, ");
- break;
- case I2O_CMD_SYS_QUIESCE:
- printk("EXEC_SYS_QUIESCE, ");
- break;
- case I2O_CMD_SYS_TAB_SET:
- printk("EXEC_SYS_TAB_SET, ");
- break;
- default:
- printk("Cmd = %#02x, ",cmd);
- }
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_lan_cmd(u8 cmd)
-{
- switch (cmd) {
- case LAN_PACKET_SEND:
- printk("LAN_PACKET_SEND, ");
- break;
- case LAN_SDU_SEND:
- printk("LAN_SDU_SEND, ");
- break;
- case LAN_RECEIVE_POST:
- printk("LAN_RECEIVE_POST, ");
- break;
- case LAN_RESET:
- printk("LAN_RESET, ");
- break;
- case LAN_SUSPEND:
- printk("LAN_SUSPEND, ");
- break;
- default:
- printk("Cmd = %0#2x, ",cmd);
- }
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Report Cmd name, Request status, Detailed Status.
- */
-void i2o_report_status(const char *severity, const char *str, u32 *msg)
-{
- u8 cmd = (msg[1]>>24)&0xFF;
- u8 req_status = (msg[4]>>24)&0xFF;
- u16 detailed_status = msg[4]&0xFFFF;
- struct i2o_handler *h = i2o_handlers[msg[2] & (MAX_I2O_MODULES-1)];
-
- if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
- return; // No status in this reply
-
- printk("%s%s: ", severity, str);
-
- if (cmd < 0x1F) // Utility cmd
- i2o_report_util_cmd(cmd);
-
- else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
- i2o_report_exec_cmd(cmd);
-
- else if (h->class == I2O_CLASS_LAN && cmd >= 0x30 && cmd <= 0x3F)
- i2o_report_lan_cmd(cmd); // LAN cmd
- else
- printk("Cmd = %0#2x, ", cmd); // Other cmds
-
- if (msg[0] & MSG_FAIL) {
- i2o_report_fail_status(req_status, msg);
- return;
- }
-
- i2o_report_common_status(req_status);
-
- if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
- i2o_report_common_dsc(detailed_status);
- else if (h->class == I2O_CLASS_LAN && cmd >= 0x30 && cmd <= 0x3F)
- i2o_report_lan_dsc(detailed_status);
- else
- printk(" / DetailedStatus = %0#4x.\n", detailed_status);
-}
-
-/* Used to dump a message to syslog during debugging */
-void i2o_dump_message(u32 *msg)
-{
-#ifdef DRIVERDEBUG
- int i;
- printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
- msg[0]>>16&0xffff, msg);
- for(i = 0; i < ((msg[0]>>16)&0xffff); i++)
- printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
-#endif
-}
-
-/*
- * I2O reboot/shutdown notification.
- *
- * - Call each OSM's reboot notifier (if one exists)
- * - Quiesce each IOP in the system
- *
- * Each IOP has to be quiesced before we can ensure that the system
- * can be properly shutdown as a transaction that has already been
- * acknowledged still needs to be placed in permanent store on the IOP.
- * The SysQuiesce causes the IOP to force all HDMs to complete their
- * transactions before returning, so only at that point is it safe
- *
- */
-static int i2o_reboot_event(struct notifier_block *n, unsigned long code, void
-*p)
-{
- int i = 0;
- struct i2o_controller *c = NULL;
-
- if(code != SYS_RESTART && code != SYS_HALT && code != SYS_POWER_OFF)
- return NOTIFY_DONE;
-
- printk(KERN_INFO "Shutting down I2O system.\n");
- printk(KERN_INFO
- " This could take a few minutes if there are many devices attached\n");
-
- for(i = 0; i < MAX_I2O_MODULES; i++)
- {
- if(i2o_handlers[i] && i2o_handlers[i]->reboot_notify)
- i2o_handlers[i]->reboot_notify();
- }
-
- for(c = i2o_controller_chain; c; c = c->next)
- {
- if(i2o_quiesce_controller(c))
- {
- printk(KERN_WARNING "i2o: Could not quiesce %s.\n"
- "Verify setup on next system power up.\n",
- c->name);
- }
- }
-
- printk(KERN_INFO "I2O system down.\n");
- return NOTIFY_DONE;
-}
-
-
-
-
-/**
- * i2o_pci_dispose - Free bus specific resources
- * @c: I2O controller
- *
- * Disable interrupts and then free interrupt, I/O and mtrr resources
- * used by this controller. Called by the I2O core on unload.
- */
-
-static void i2o_pci_dispose(struct i2o_controller *c)
-{
- I2O_IRQ_WRITE32(c,0xFFFFFFFF);
- if(c->irq > 0)
- free_irq(c->irq, c);
- iounmap(c->base_virt);
- if(c->raptor)
- iounmap(c->msg_virt);
-
-#ifdef CONFIG_MTRR
- if(c->mtrr_reg0 > 0)
- mtrr_del(c->mtrr_reg0, 0, 0);
- if(c->mtrr_reg1 > 0)
- mtrr_del(c->mtrr_reg1, 0, 0);
-#endif
-}
-
-/**
- * i2o_pci_interrupt - Bus specific interrupt handler
- * @irq: interrupt line
- * @dev_id: cookie
- *
- * Handle an interrupt from a PCI based I2O controller. This turns out
- * to be rather simple. We keep the controller pointer in the cookie.
- */
-
-static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r)
-{
- struct i2o_controller *c = dev_id;
- i2o_run_queue(c);
- return IRQ_HANDLED;
-}
-
-/**
- * i2o_pci_install - Install a PCI i2o controller
- * @dev: PCI device of the I2O controller
- *
- * Install a PCI (or in theory AGP) i2o controller. Devices are
- * initialized, configured and registered with the i2o core subsystem. Be
- * very careful with ordering. There may be pending interrupts.
- *
- * To Do: Add support for polled controllers
- */
-
-int __init i2o_pci_install(struct pci_dev *dev)
-{
- struct i2o_controller *c=kmalloc(sizeof(struct i2o_controller),
- GFP_KERNEL);
- void *bar0_virt;
- void *bar1_virt;
- unsigned long bar0_phys = 0;
- unsigned long bar1_phys = 0;
- unsigned long bar0_size = 0;
- unsigned long bar1_size = 0;
-
- int i;
-
- if(c==NULL)
- {
- printk(KERN_ERR "i2o: Insufficient memory to add controller.\n");
- return -ENOMEM;
- }
- memset(c, 0, sizeof(*c));
-
- c->irq = -1;
- c->dpt = 0;
- c->raptor = 0;
- c->short_req = 0;
- c->pdev = dev;
-
-#if BITS_PER_LONG == 64
- c->context_list_lock = SPIN_LOCK_UNLOCKED;
-#endif
-
- /*
- * Cards that fall apart if you hit them with large I/O
- * loads...
- */
-
- if(dev->vendor == PCI_VENDOR_ID_NCR && dev->device == 0x0630)
- {
- c->short_req = 1;
- printk(KERN_INFO "I2O: Symbios FC920 workarounds activated.\n");
- }
-
- if(dev->subsystem_vendor == PCI_VENDOR_ID_PROMISE)
- {
- c->promise = 1;
- printk(KERN_INFO "I2O: Promise workarounds activated.\n");
- }
-
- /*
- * Cards that go bananas if you quiesce them before you reset
- * them
- */
-
- if(dev->vendor == PCI_VENDOR_ID_DPT) {
- c->dpt=1;
- if(dev->device == 0xA511)
- c->raptor=1;
- }
-
- for(i=0; i<6; i++)
- {
- /* Skip I/O spaces */
- if(!(pci_resource_flags(dev, i) & IORESOURCE_IO))
- {
- if(!bar0_phys)
- {
- bar0_phys = pci_resource_start(dev, i);
- bar0_size = pci_resource_len(dev, i);
- if(!c->raptor)
- break;
- }
- else
- {
- bar1_phys = pci_resource_start(dev, i);
- bar1_size = pci_resource_len(dev, i);
- break;
- }
- }
- }
-
- if(i==6)
- {
- printk(KERN_ERR "i2o: I2O controller has no memory regions defined.\n");
- kfree(c);
- return -EINVAL;
- }
-
-
- /* Map the I2O controller */
- if(!c->raptor)
- printk(KERN_INFO "i2o: PCI I2O controller at %08lX size=%ld\n", bar0_phys, bar0_size);
- else
- printk(KERN_INFO "i2o: PCI I2O controller\n BAR0 at 0x%08lX size=%ld\n BAR1 at 0x%08lX size=%ld\n", bar0_phys, bar0_size, bar1_phys, bar1_size);
-
- bar0_virt = ioremap(bar0_phys, bar0_size);
- if(bar0_virt==0)
- {
- printk(KERN_ERR "i2o: Unable to map controller.\n");
- kfree(c);
- return -EINVAL;
- }
-
- if(c->raptor)
- {
- bar1_virt = ioremap(bar1_phys, bar1_size);
- if(bar1_virt==0)
- {
- printk(KERN_ERR "i2o: Unable to map controller.\n");
- kfree(c);
- iounmap(bar0_virt);
- return -EINVAL;
- }
- } else {
- bar1_virt = bar0_virt;
- bar1_phys = bar0_phys;
- bar1_size = bar0_size;
- }
-
- c->irq_mask = bar0_virt+0x34;
- c->post_port = bar0_virt+0x40;
- c->reply_port = bar0_virt+0x44;
-
- c->base_phys = bar0_phys;
- c->base_virt = bar0_virt;
- c->msg_phys = bar1_phys;
- c->msg_virt = bar1_virt;
-
- /*
- * Enable Write Combining MTRR for IOP's memory region
- */
-#ifdef CONFIG_MTRR
- c->mtrr_reg0 = mtrr_add(c->base_phys, bar0_size, MTRR_TYPE_WRCOMB, 1);
- /*
- * If it is an INTEL i960 I/O processor then set the first 64K to
- * Uncacheable since the region contains the Messaging unit which
- * shouldn't be cached.
- */
- c->mtrr_reg1 = -1;
- if(dev->vendor == PCI_VENDOR_ID_INTEL || dev->vendor == PCI_VENDOR_ID_DPT)
- {
- printk(KERN_INFO "I2O: MTRR workaround for Intel i960 processor\n");
- c->mtrr_reg1 = mtrr_add(c->base_phys, 65536, MTRR_TYPE_UNCACHABLE, 1);
- if(c->mtrr_reg1< 0)
- {
- printk(KERN_INFO "i2o_pci: Error in setting MTRR_TYPE_UNCACHABLE\n");
- mtrr_del(c->mtrr_reg0, c->msg_phys, bar1_size);
- c->mtrr_reg0 = -1;
- }
- }
- if(c->raptor)
- c->mtrr_reg1 = mtrr_add(c->msg_phys, bar1_size, MTRR_TYPE_WRCOMB, 1);
-
-#endif
-
- I2O_IRQ_WRITE32(c,0xFFFFFFFF);
-
- i = i2o_install_controller(c);
-
- if(i<0)
- {
- printk(KERN_ERR "i2o: Unable to install controller.\n");
- kfree(c);
- iounmap(bar0_virt);
- if(c->raptor)
- iounmap(bar1_virt);
- return i;
- }
-
- c->irq = dev->irq;
- if(c->irq)
- {
- i=request_irq(dev->irq, i2o_pci_interrupt, SA_SHIRQ,
- c->name, c);
- if(i<0)
- {
- printk(KERN_ERR "%s: unable to allocate interrupt %d.\n",
- c->name, dev->irq);
- c->irq = -1;
- i2o_delete_controller(c);
- iounmap(bar0_virt);
- if(c->raptor)
- iounmap(bar1_virt);
- return -EBUSY;
- }
- }
-
- printk(KERN_INFO "%s: Installed at IRQ%d\n", c->name, dev->irq);
- I2O_IRQ_WRITE32(c,0x0);
- c->enabled = 1;
- return 0;
-}
-
-/**
- * i2o_pci_scan - Scan the pci bus for controllers
- *
- * Scan the PCI devices on the system looking for any device which is a
- * memory of the Intelligent, I2O class. We attempt to set up each such device
- * and register it with the core.
- *
- * Returns the number of controllers registered
- *
- * Note; Do not change this to a hot plug interface. I2O 1.5 itself
- * does not support hot plugging.
- */
-
-int __init i2o_pci_scan(void)
-{
- struct pci_dev *dev = NULL;
- int count=0;
-
- printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
-
- while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL)
- {
- if((dev->class>>8)!=PCI_CLASS_INTELLIGENT_I2O &&
- (dev->vendor!=PCI_VENDOR_ID_DPT || dev->device!=0xA511))
- continue;
-
- if((dev->class>>8)==PCI_CLASS_INTELLIGENT_I2O &&
- (dev->class&0xFF)>1)
- {
- printk(KERN_INFO "i2o: I2O Controller found but does not support I2O 1.5 (skipping).\n");
- continue;
- }
- if (pci_enable_device(dev))
- continue;
- printk(KERN_INFO "i2o: I2O controller on bus %d at %d.\n",
- dev->bus->number, dev->devfn);
- if(pci_set_dma_mask(dev, 0xffffffff))
- {
- printk(KERN_WARNING "I2O controller on bus %d at %d : No suitable DMA available\n", dev->bus->number, dev->devfn);
- continue;
- }
- pci_set_master(dev);
- if(i2o_pci_install(dev)==0)
- count++;
- }
- if(count)
- printk(KERN_INFO "i2o: %d I2O controller%s found and installed.\n", count,
- count==1?"":"s");
- return count?count:-ENODEV;
-}
-
-static int i2o_core_init(void)
-{
- printk(KERN_INFO "I2O Core - (C) Copyright 1999 Red Hat Software\n");
- if (i2o_install_handler(&i2o_core_handler) < 0)
- {
- printk(KERN_ERR "i2o_core: Unable to install core handler.\nI2O stack not loaded!");
- return 0;
- }
-
- core_context = i2o_core_handler.context;
-
- /*
- * Initialize event handling thread
- */
-
- init_MUTEX_LOCKED(&evt_sem);
- evt_pid = kernel_thread(i2o_core_evt, &evt_reply, CLONE_SIGHAND);
- if(evt_pid < 0)
- {
- printk(KERN_ERR "I2O: Could not create event handler kernel thread\n");
- i2o_remove_handler(&i2o_core_handler);
- return 0;
- }
- else
- printk(KERN_INFO "I2O: Event thread created as pid %d\n", evt_pid);
-
- i2o_pci_scan();
- if(i2o_num_controllers)
- i2o_sys_init();
-
- register_reboot_notifier(&i2o_reboot_notifier);
-
- return 0;
-}
-
-static void i2o_core_exit(void)
-{
- int stat;
-
- unregister_reboot_notifier(&i2o_reboot_notifier);
-
- if(i2o_num_controllers)
- i2o_sys_shutdown();
-
- /*
- * If this is shutdown time, the thread has already been killed
- */
- if(evt_running) {
- printk("Terminating i2o threads...");
- stat = kill_proc(evt_pid, SIGKILL, 1);
- if(!stat) {
- printk("waiting...\n");
- wait_for_completion(&evt_dead);
- }
- printk("done.\n");
- }
- i2o_remove_handler(&i2o_core_handler);
-}
-
-module_init(i2o_core_init);
-module_exit(i2o_core_exit);
-
-MODULE_PARM(verbose, "i");
-MODULE_PARM_DESC(verbose, "Verbose diagnostics");
-
-MODULE_AUTHOR("Red Hat Software");
-MODULE_DESCRIPTION("I2O Core");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(i2o_controller_chain);
-EXPORT_SYMBOL(i2o_num_controllers);
-EXPORT_SYMBOL(i2o_find_controller);
-EXPORT_SYMBOL(i2o_unlock_controller);
-EXPORT_SYMBOL(i2o_status_get);
-EXPORT_SYMBOL(i2o_install_handler);
-EXPORT_SYMBOL(i2o_remove_handler);
-EXPORT_SYMBOL(i2o_install_controller);
-EXPORT_SYMBOL(i2o_delete_controller);
-EXPORT_SYMBOL(i2o_run_queue);
-EXPORT_SYMBOL(i2o_claim_device);
-EXPORT_SYMBOL(i2o_release_device);
-EXPORT_SYMBOL(i2o_device_notify_on);
-EXPORT_SYMBOL(i2o_device_notify_off);
-EXPORT_SYMBOL(i2o_post_this);
-EXPORT_SYMBOL(i2o_post_wait);
-EXPORT_SYMBOL(i2o_post_wait_mem);
-EXPORT_SYMBOL(i2o_query_scalar);
-EXPORT_SYMBOL(i2o_set_scalar);
-EXPORT_SYMBOL(i2o_query_table);
-EXPORT_SYMBOL(i2o_clear_table);
-EXPORT_SYMBOL(i2o_row_add_table);
-EXPORT_SYMBOL(i2o_issue_params);
-EXPORT_SYMBOL(i2o_event_register);
-EXPORT_SYMBOL(i2o_event_ack);
-EXPORT_SYMBOL(i2o_report_status);
-EXPORT_SYMBOL(i2o_dump_message);
-EXPORT_SYMBOL(i2o_get_class_name);
-EXPORT_SYMBOL(i2o_context_list_add);
-EXPORT_SYMBOL(i2o_context_list_get);
-EXPORT_SYMBOL(i2o_context_list_remove);
+++ /dev/null
-/*
- * drivers/mtd/nand.c
- *
- * Overview:
- * This is the generic MTD driver for NAND flash devices. It should be
- * capable of working with almost all NAND chips currently available.
- *
- * Additional technical information is available on
- * http://www.linux-mtd.infradead.org/tech/nand.html
- *
- * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
- * 2002 Thomas Gleixner (tglx@linutronix.de)
- *
- * 10-29-2001 Thomas Gleixner (tglx@linutronix.de)
- * - Changed nand_chip structure for controlline function to
- * support different hardware structures (Access to
- * controllines ALE,CLE,NCE via hardware specific function.
- * - exit out of "failed erase block" changed, to avoid
- * driver hangup
- * - init_waitqueue_head added in function nand_scan !!
- *
- * 01-30-2002 Thomas Gleixner (tglx@linutronix.de)
- * change in nand_writev to block invalid vecs entries
- *
- * 02-11-2002 Thomas Gleixner (tglx@linutronix.de)
- * - major rewrite to avoid duplicated code
- * common nand_write_page function
- * common get_chip function
- * - added oob_config structure for out of band layouts
- * - write_oob changed for partial programming
- * - read cache for faster access for subsequent reads
- * from the same page.
- * - support for different read/write address
- * - support for device ready/busy line
- * - read oob for more than one page enabled
- *
- * 02-27-2002 Thomas Gleixner (tglx@linutronix.de)
- * - command-delay can be programmed
- * - fixed exit from erase with callback-function enabled
- *
- * 03-21-2002 Thomas Gleixner (tglx@linutronix.de)
- * - DEBUG improvements provided by Elizabeth Clarke
- * (eclarke@aminocom.com)
- * - added zero check for this->chip_delay
- *
- * 04-03-2002 Thomas Gleixner (tglx@linutronix.de)
- * - added added hw-driver supplied command and wait functions
- * - changed blocking for erase (erase suspend enabled)
- * - check pointers before accessing flash provided by
- * John Hall (john.hall@optionexist.co.uk)
- *
- * 04-09-2002 Thomas Gleixner (tglx@linutronix.de)
- * - nand_wait repaired
- *
- * 04-28-2002 Thomas Gleixner (tglx@linutronix.de)
- * - OOB config defines moved to nand.h
- *
- * 08-01-2002 Thomas Gleixner (tglx@linutronix.de)
- * - changed my mailaddress, added pointer to tech/nand.html
- *
- * 08-07-2002 Thomas Gleixner (tglx@linutronix.de)
- * forced bad block location to byte 5 of OOB, even if
- * CONFIG_MTD_NAND_ECC_JFFS2 is not set, to prevent
- * erase /dev/mtdX from erasing bad blocks and destroying
- * bad block info
- *
- * 08-10-2002 Thomas Gleixner (tglx@linutronix.de)
- * Fixed writing tail of data. Thanks to Alice Hennessy
- * <ahennessy@mvista.com>.
- *
- * 08-10-2002 Thomas Gleixner (tglx@linutronix.de)
- * nand_read_ecc and nand_write_page restructured to support
- * hardware ECC. Thanks to Steven Hein (ssh@sgi.com)
- * for basic implementation and suggestions.
- * 3 new pointers in nand_chip structure:
- * calculate_ecc, correct_data, enabled_hwecc
- * forcing all hw-drivers to support page cache
- * eccvalid_pos is now mandatory
- *
- * 08-17-2002 tglx: fixed signed/unsigned missmatch in write.c
- * Thanks to Ken Offer <koffer@arlut.utexas.edu>
- *
- * 08-29-2002 tglx: use buffered read/write only for non pagealigned
- * access, speed up the aligned path by using the fs-buffer
- * reset chip removed from nand_select(), implicit done
- * only, when erase is interrupted
- * waitfuntion use yield, instead of schedule_timeout
- * support for 6byte/512byte hardware ECC
- * read_ecc, write_ecc extended for different oob-layout
- * selections: Implemented NAND_NONE_OOB, NAND_JFFS2_OOB,
- * NAND_YAFFS_OOB. fs-driver gives one of these constants
- * to select the oob-layout fitting the filesystem.
- * oobdata can be read together with the raw data, when
- * the fs-driver supplies a big enough buffer.
- * size = 12 * number of pages to read (256B pagesize)
- * 24 * number of pages to read (512B pagesize)
- * the buffer contains 8/16 byte oobdata and 4/8 byte
- * returncode from calculate_ecc
- * oobdata can be given from filesystem to program them
- * in one go together with the raw data. ECC codes are
- * filled in at the place selected by oobsel.
- *
- * 09-04-2002 tglx: fixed write_verify (John Hall (john.hall@optionexist.co.uk))
- *
- * 11-11-2002 tglx: fixed debug output in nand_write_page
- * (John Hall (john.hall@optionexist.co.uk))
- *
- * 11-25-2002 tglx: Moved device ID/ manufacturer ID from nand_ids.h
- * Splitted device ID and manufacturer ID table.
- * Removed CONFIG_MTD_NAND_ECC, as it defaults to ECC_NONE for
- * mtd->read / mtd->write and is controllable by the fs driver
- * for mtd->read_ecc / mtd->write_ecc
- * some minor cleanups
- *
- * 12-05-2002 tglx: Dave Ellis (DGE@sixnetio) provided the fix for
- * WRITE_VERIFY long time ago. Thanks for remembering me.
- *
- * 02-14-2003 tglx: Reject non page aligned writes
- * Fixed ecc select in nand_write_page to match semantics.
- *
- * 02-18-2003 tglx: Changed oobsel to pointer. Added a default oob-selector
- *
- * 02-18-2003 tglx: Implemented oobsel again. Now it uses a pointer to
- + a structure, which will be supplied by a filesystem driver
- * If NULL is given, then the defaults (none or defaults
- * supplied by ioctl (MEMSETOOBSEL) are used.
- * For partitions the partition defaults are used (mtdpart.c)
- *
- * 06-04-2003 tglx: fix compile errors and fix write verify problem for
- * some chips, which need either a delay between the readback
- * and the next write command or have the CE removed. The
- * CE disable/enable is much faster than a 20us delay and
- * it should work on all available chips.
- *
- * $Id: nand.c,v 1.46 2003/06/04 17:10:36 gleixner Exp $
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/nand_ecc.h>
-#include <linux/mtd/compatmac.h>
-#include <linux/interrupt.h>
-#include <asm/io.h>
-
-/*
- * Macros for low-level register control
- */
-#define nand_select() this->hwcontrol(NAND_CTL_SETNCE);
-#define nand_deselect() this->hwcontrol(NAND_CTL_CLRNCE);
-
-/*
- * NAND low-level MTD interface functions
- */
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
- size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf);
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf);
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
- size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel);
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf);
-static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs,
- unsigned long count, loff_t to, size_t * retlen);
-static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs,
- unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr);
-static void nand_sync (struct mtd_info *mtd);
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, struct nand_oobinfo *oobsel);
-
-
-/*
- * Send command to NAND device
- */
-static void nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
-{
- register struct nand_chip *this = mtd->priv;
- register unsigned long NAND_IO_ADDR = this->IO_ADDR_W;
-
- /* Begin command latch cycle */
- this->hwcontrol (NAND_CTL_SETCLE);
- /*
- * Write out the command to the device.
- */
- if (command != NAND_CMD_SEQIN)
- writeb (command, NAND_IO_ADDR);
- else {
- if (mtd->oobblock == 256 && column >= 256) {
- column -= 256;
- writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
- writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
- } else if (mtd->oobblock == 512 && column >= 256) {
- if (column < 512) {
- column -= 256;
- writeb (NAND_CMD_READ1, NAND_IO_ADDR);
- writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
- } else {
- column -= 512;
- writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
- writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
- }
- } else {
- writeb (NAND_CMD_READ0, NAND_IO_ADDR);
- writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
- }
- }
-
- /* Set ALE and clear CLE to start address cycle */
- this->hwcontrol (NAND_CTL_CLRCLE);
-
- if (column != -1 || page_addr != -1) {
- this->hwcontrol (NAND_CTL_SETALE);
-
- /* Serially input address */
- if (column != -1)
- writeb (column, NAND_IO_ADDR);
- if (page_addr != -1) {
- writeb ((unsigned char) (page_addr & 0xff), NAND_IO_ADDR);
- writeb ((unsigned char) ((page_addr >> 8) & 0xff), NAND_IO_ADDR);
- /* One more address cycle for higher density devices */
- if (mtd->size & 0x0c000000)
- writeb ((unsigned char) ((page_addr >> 16) & 0x0f), NAND_IO_ADDR);
- }
- /* Latch in address */
- this->hwcontrol (NAND_CTL_CLRALE);
- }
-
- /*
- * program and erase have their own busy handlers
- * status and sequential in needs no delay
- */
- switch (command) {
-
- case NAND_CMD_PAGEPROG:
- case NAND_CMD_ERASE1:
- case NAND_CMD_ERASE2:
- case NAND_CMD_SEQIN:
- case NAND_CMD_STATUS:
- return;
-
- case NAND_CMD_RESET:
- if (this->dev_ready)
- break;
- this->hwcontrol (NAND_CTL_SETCLE);
- writeb (NAND_CMD_STATUS, NAND_IO_ADDR);
- this->hwcontrol (NAND_CTL_CLRCLE);
- while ( !(readb (this->IO_ADDR_R) & 0x40));
- return;
-
- /* This applies to read commands */
- default:
- /*
- * If we don't have access to the busy pin, we apply the given
- * command delay
- */
- if (!this->dev_ready) {
- udelay (this->chip_delay);
- return;
- }
- }
-
- /* wait until command is processed */
- while (!this->dev_ready());
-}
-
-/*
- * Get chip for selected access
- */
-static inline void nand_get_chip (struct nand_chip *this, struct mtd_info *mtd, int new_state, int *erase_state)
-{
-
- DECLARE_WAITQUEUE (wait, current);
-
- /*
- * Grab the lock and see if the device is available
- * For erasing, we keep the spinlock until the
- * erase command is written.
- */
-retry:
- spin_lock_bh (&this->chip_lock);
-
- if (this->state == FL_READY) {
- this->state = new_state;
- if (new_state != FL_ERASING)
- spin_unlock_bh (&this->chip_lock);
- return;
- }
-
- if (this->state == FL_ERASING) {
- if (new_state != FL_ERASING) {
- this->state = new_state;
- spin_unlock_bh (&this->chip_lock);
- nand_select (); /* select in any case */
- this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
- return;
- }
- }
-
- set_current_state (TASK_UNINTERRUPTIBLE);
- add_wait_queue (&this->wq, &wait);
- spin_unlock_bh (&this->chip_lock);
- schedule ();
- remove_wait_queue (&this->wq, &wait);
- goto retry;
-}
-
-/*
- * Wait for command done. This applies to erase and program only
- * Erase can take up to 400ms and program up to 20ms according to
- * general NAND and SmartMedia specs
- *
-*/
-static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state)
-{
-
- unsigned long timeo = jiffies;
- int status;
-
- if (state == FL_ERASING)
- timeo += (HZ * 400) / 1000;
- else
- timeo += (HZ * 20) / 1000;
-
- spin_lock_bh (&this->chip_lock);
- this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
-
- while (time_before(jiffies, timeo)) {
- /* Check, if we were interrupted */
- if (this->state != state) {
- spin_unlock_bh (&this->chip_lock);
- return 0;
- }
- if (this->dev_ready) {
- if (this->dev_ready ())
- break;
- }
- if (readb (this->IO_ADDR_R) & 0x40)
- break;
-
- spin_unlock_bh (&this->chip_lock);
- yield ();
- spin_lock_bh (&this->chip_lock);
- }
- status = (int) readb (this->IO_ADDR_R);
- spin_unlock_bh (&this->chip_lock);
-
- return status;
-}
-
-/*
- * Nand_page_program function is used for write and writev !
- * This function will always program a full page of data
- * If you call it with a non page aligned buffer, you're lost :)
- */
-static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, struct nand_oobinfo *oobsel)
-{
- int i, status;
- u_char ecc_code[6], *oob_data;
- int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
- int *oob_config = oobsel->eccpos;
-
- /* pad oob area, if we have no oob buffer from fs-driver */
- if (!oob_buf) {
- oob_data = &this->data_buf[mtd->oobblock];
- for (i = 0; i < mtd->oobsize; i++)
- oob_data[i] = 0xff;
- } else
- oob_data = oob_buf;
-
- /* Send command to begin auto page programming */
- this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page);
-
- /* Write out complete page of data, take care of eccmode */
- switch (eccmode) {
- /* No ecc and software ecc 3/256, write all */
- case NAND_ECC_NONE:
- printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n");
- for (i = 0; i < mtd->oobblock; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
- break;
- case NAND_ECC_SOFT:
- this->calculate_ecc (&this->data_poi[0], &(ecc_code[0]));
- for (i = 0; i < 3; i++)
- oob_data[oob_config[i]] = ecc_code[i];
- /* Calculate and write the second ECC for 512 Byte page size */
- if (mtd->oobblock == 512) {
- this->calculate_ecc (&this->data_poi[256], &(ecc_code[3]));
- for (i = 3; i < 6; i++)
- oob_data[oob_config[i]] = ecc_code[i];
- }
- for (i = 0; i < mtd->oobblock; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
- break;
-
- /* Hardware ecc 3 byte / 256 data, write first half, get ecc, then second, if 512 byte pagesize */
- case NAND_ECC_HW3_256:
- this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic for write */
- for (i = 0; i < mtd->eccsize; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
-
- this->calculate_ecc (NULL, &(ecc_code[0]));
- for (i = 0; i < 3; i++)
- oob_data[oob_config[i]] = ecc_code[i];
-
- if (mtd->oobblock == 512) {
- this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic for write*/
- for (i = mtd->eccsize; i < mtd->oobblock; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
- this->calculate_ecc (NULL, &(ecc_code[3]));
- for (i = 3; i < 6; i++)
- oob_data[oob_config[i]] = ecc_code[i];
- }
- break;
-
- /* Hardware ecc 3 byte / 512 byte data, write full page */
- case NAND_ECC_HW3_512:
- this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic */
- for (i = 0; i < mtd->oobblock; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
- this->calculate_ecc (NULL, &(ecc_code[0]));
- for (i = 0; i < 3; i++)
- oob_data[oob_config[i]] = ecc_code[i];
- break;
-
- /* Hardware ecc 6 byte / 512 byte data, write full page */
- case NAND_ECC_HW6_512:
- this->enable_hwecc (NAND_ECC_WRITE); /* enable hardware ecc logic */
- for (i = 0; i < mtd->oobblock; i++)
- writeb ( this->data_poi[i] , this->IO_ADDR_W);
- this->calculate_ecc (NULL, &(ecc_code[0]));
- for (i = 0; i < 6; i++)
- oob_data[oob_config[i]] = ecc_code[i];
- break;
-
- default:
- printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
- BUG();
- }
-
- /* Write out OOB data */
- for (i = 0; i < mtd->oobsize; i++)
- writeb ( oob_data[i] , this->IO_ADDR_W);
-
- /* Send command to actually program the data */
- this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1);
-
- /* call wait ready function */
- status = this->waitfunc (mtd, this, FL_WRITING);
-
- /* See if device thinks it succeeded */
- if (status & 0x01) {
- DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page);
- return -EIO;
- }
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
- /*
- * The NAND device assumes that it is always writing to
- * a cleanly erased page. Hence, it performs its internal
- * write verification only on bits that transitioned from
- * 1 to 0. The device does NOT verify the whole page on a
- * byte by byte basis. It is possible that the page was
- * not completely erased or the page is becoming unusable
- * due to wear. The read with ECC would catch the error
- * later when the ECC page check fails, but we would rather
- * catch it early in the page write stage. Better to write
- * no data than invalid data.
- */
-
- /* Send command to read back the page */
- this->cmdfunc (mtd, NAND_CMD_READ0, 0, page);
- /* Loop through and verify the data */
- for (i = 0; i < mtd->oobblock; i++) {
- if (this->data_poi[i] != readb (this->IO_ADDR_R)) {
- DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
- return -EIO;
- }
- }
-
- /* check, if we have a fs-supplied oob-buffer */
- if (oob_buf) {
- for (i = 0; i < mtd->oobsize; i++) {
- if (oob_data[i] != readb (this->IO_ADDR_R)) {
- DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page);
- return -EIO;
- }
- }
- } else {
- if (eccmode != NAND_ECC_NONE) {
- int ecc_bytes = 0;
-
- switch (this->eccmode) {
- case NAND_ECC_SOFT:
- case NAND_ECC_HW3_256: ecc_bytes = (mtd->oobblock == 512) ? 6 : 3; break;
- case NAND_ECC_HW3_512: ecc_bytes = 3; break;
- case NAND_ECC_HW6_512: ecc_bytes = 6; break;
- }
-
- for (i = 0; i < mtd->oobsize; i++)
- oob_data[i] = readb (this->IO_ADDR_R);
-
- for (i = 0; i < ecc_bytes; i++) {
- if (oob_data[oob_config[i]] != ecc_code[i]) {
- DEBUG (MTD_DEBUG_LEVEL0,
- "%s: Failed ECC write "
- "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i);
- return -EIO;
- }
- }
- }
- }
- /*
- * Terminate the read command. This is faster than sending a reset command or
- * applying a 20us delay before issuing the next programm sequence.
- * This is not a problem for all chips, but I have found a bunch of them.
- */
- nand_deselect();
- nand_select();
-#endif
- return 0;
-}
-
-/*
-* Use NAND read ECC
-*/
-static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
- return (nand_read_ecc (mtd, from, len, retlen, buf, NULL, NULL));
-}
-
-
-/*
- * NAND read with ECC
- */
-static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
- size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel)
-{
- int j, col, page, end, ecc;
- int erase_state = 0;
- int read = 0, oob = 0, ecc_status = 0, ecc_failed = 0;
- struct nand_chip *this = mtd->priv;
- u_char *data_poi, *oob_data = oob_buf;
- u_char ecc_calc[6];
- u_char ecc_code[6];
- int eccmode;
- int *oob_config;
-
- // use chip default if zero
- if (oobsel == NULL)
- oobsel = &mtd->oobinfo;
-
- eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE;
- oob_config = oobsel->eccpos;
-
- DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
- /* Do not allow reads past end of device */
- if ((from + len) > mtd->size) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n");
- *retlen = 0;
- return -EINVAL;
- }
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd ,FL_READING, &erase_state);
-
- /* Select the NAND device */
- nand_select ();
-
- /* First we calculate the starting page */
- page = from >> this->page_shift;
-
- /* Get raw starting column */
- col = from & (mtd->oobblock - 1);
-
- end = mtd->oobblock;
- ecc = mtd->eccsize;
-
- /* Send the read command */
- this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page);
-
- /* Loop until all data read */
- while (read < len) {
-
- /* If we have consequent page reads, apply delay or wait for ready/busy pin */
- if (read) {
- if (!this->dev_ready)
- udelay (this->chip_delay);
- else
- while (!this->dev_ready());
- }
-
- /*
- * If the read is not page aligned, we have to read into data buffer
- * due to ecc, else we read into return buffer direct
- */
- if (!col && (len - read) >= end)
- data_poi = &buf[read];
- else
- data_poi = this->data_buf;
-
- /* get oob area, if we have no oob buffer from fs-driver */
- if (!oob_buf) {
- oob_data = &this->data_buf[end];
- oob = 0;
- }
-
- j = 0;
- switch (eccmode) {
- case NAND_ECC_NONE: /* No ECC, Read in a page */
- printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n");
- while (j < end)
- data_poi[j++] = readb (this->IO_ADDR_R);
- break;
-
- case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */
- while (j < end)
- data_poi[j++] = readb (this->IO_ADDR_R);
- this->calculate_ecc (&data_poi[0], &ecc_calc[0]);
- if (mtd->oobblock == 512)
- this->calculate_ecc (&data_poi[256], &ecc_calc[3]);
- break;
-
- case NAND_ECC_HW3_256: /* Hardware ECC 3 byte /256 byte data: Read in first 256 byte, get ecc, */
- this->enable_hwecc (NAND_ECC_READ);
- while (j < ecc)
- data_poi[j++] = readb (this->IO_ADDR_R);
- this->calculate_ecc (&data_poi[0], &ecc_calc[0]); /* read from hardware */
-
- if (mtd->oobblock == 512) { /* read second, if pagesize = 512 */
- this->enable_hwecc (NAND_ECC_READ);
- while (j < end)
- data_poi[j++] = readb (this->IO_ADDR_R);
- this->calculate_ecc (&data_poi[256], &ecc_calc[3]); /* read from hardware */
- }
- break;
-
- case NAND_ECC_HW3_512:
- case NAND_ECC_HW6_512: /* Hardware ECC 3/6 byte / 512 byte data : Read in a page */
- this->enable_hwecc (NAND_ECC_READ);
- while (j < end)
- data_poi[j++] = readb (this->IO_ADDR_R);
- this->calculate_ecc (&data_poi[0], &ecc_calc[0]); /* read from hardware */
- break;
-
- default:
- printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
- BUG();
- }
-
- /* read oobdata */
- for (j = 0; j < mtd->oobsize; j++)
- oob_data[oob + j] = readb (this->IO_ADDR_R);
-
- /* Skip ECC, if not active */
- if (eccmode == NAND_ECC_NONE)
- goto readdata;
-
- /* Pick the ECC bytes out of the oob data */
- for (j = 0; j < 6; j++)
- ecc_code[j] = oob_data[oob + oob_config[j]];
-
- /* correct data, if neccecary */
- ecc_status = this->correct_data (&data_poi[0], &ecc_code[0], &ecc_calc[0]);
- /* check, if we have a fs supplied oob-buffer */
- if (oob_buf) {
- oob += mtd->oobsize;
- *((int *)&oob_data[oob]) = ecc_status;
- oob += sizeof(int);
- }
- if (ecc_status == -1) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
- ecc_failed++;
- }
-
- if (mtd->oobblock == 512 && eccmode != NAND_ECC_HW3_512) {
- ecc_status = this->correct_data (&data_poi[256], &ecc_code[3], &ecc_calc[3]);
- if (oob_buf) {
- *((int *)&oob_data[oob]) = ecc_status;
- oob += sizeof(int);
- }
- if (ecc_status == -1) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page);
- ecc_failed++;
- }
- }
-readdata:
- if (col || (len - read) < end) {
- for (j = col; j < end && read < len; j++)
- buf[read++] = data_poi[j];
- } else
- read += mtd->oobblock;
- /* For subsequent reads align to page boundary. */
- col = 0;
- /* Increment page address */
- page++;
- }
-
- /* De-select the NAND device */
- nand_deselect ();
-
- /* Wake up anyone waiting on the device */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- wake_up (&this->wq);
- spin_unlock_bh (&this->chip_lock);
-
- /*
- * Return success, if no ECC failures, else -EIO
- * fs driver will take care of that, because
- * retlen == desired len and result == -EIO
- */
- *retlen = read;
- return ecc_failed ? -EIO : 0;
-}
-
-/*
- * NAND read out-of-band
- */
-static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf)
-{
- int i, col, page;
- int erase_state = 0;
- struct nand_chip *this = mtd->priv;
-
- DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
-
- /* Shift to get page */
- page = ((int) from) >> this->page_shift;
-
- /* Mask to get column */
- col = from & 0x0f;
-
- /* Initialize return length value */
- *retlen = 0;
-
- /* Do not allow reads past end of device */
- if ((from + len) > mtd->size) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n");
- *retlen = 0;
- return -EINVAL;
- }
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd , FL_READING, &erase_state);
-
- /* Select the NAND device */
- nand_select ();
-
- /* Send the read command */
- this->cmdfunc (mtd, NAND_CMD_READOOB, col, page);
- /*
- * Read the data, if we read more than one page
- * oob data, let the device transfer the data !
- */
- for (i = 0; i < len; i++) {
- buf[i] = readb (this->IO_ADDR_R);
- if ((col++ & (mtd->oobsize - 1)) == (mtd->oobsize - 1))
- udelay (this->chip_delay);
- }
- /* De-select the NAND device */
- nand_deselect ();
-
- /* Wake up anyone waiting on the device */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- wake_up (&this->wq);
- spin_unlock_bh (&this->chip_lock);
-
- /* Return happy */
- *retlen = len;
- return 0;
-}
-
-#define NOTALIGNED(x) (x & (mtd->oobblock-1)) != 0
-
-/*
-* Use NAND write ECC
-*/
-static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
- return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL));
-}
-/*
- * NAND write with ECC
- */
-static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
- size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
-{
- int page, ret = 0, oob = 0, written = 0;
- struct nand_chip *this = mtd->priv;
-
- DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
- /* Do not allow write past end of device */
- if ((to + len) > mtd->size) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n");
- return -EINVAL;
- }
-
- /* reject writes, which are not page aligned */
- if (NOTALIGNED (to) || NOTALIGNED(len)) {
- printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
- return -EINVAL;
- }
-
- // if oobsel is NULL, use chip defaults
- if (oobsel == NULL)
- oobsel = &mtd->oobinfo;
-
- /* Shift to get page */
- page = ((int) to) >> this->page_shift;
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd, FL_WRITING, NULL);
-
- /* Select the NAND device */
- nand_select ();
-
- /* Check the WP bit */
- this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
- if (!(readb (this->IO_ADDR_R) & 0x80)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Device is write protected!!!\n");
- ret = -EIO;
- goto out;
- }
-
- /* Loop until all data is written */
- while (written < len) {
- int cnt = mtd->oobblock;
- this->data_poi = (u_char*) &buf[written];
- /* We use the same function for write and writev */
- if (eccbuf) {
- ret = nand_write_page (mtd, this, page, &eccbuf[oob], oobsel);
- oob += mtd->oobsize;
- } else
- ret = nand_write_page (mtd, this, page, NULL, oobsel);
-
- if (ret)
- goto out;
-
- /* Update written bytes count */
- written += cnt;
- /* Increment page address */
- page++;
- }
-
-out:
- /* De-select the NAND device */
- nand_deselect ();
-
- /* Wake up anyone waiting on the device */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- wake_up (&this->wq);
- spin_unlock_bh (&this->chip_lock);
-
- *retlen = written;
- return ret;
-}
-
-/*
- * NAND write out-of-band
- */
-static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf)
-{
- int i, column, page, status, ret = 0;
- struct nand_chip *this = mtd->priv;
-
- DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
-
- /* Shift to get page */
- page = ((int) to) >> this->page_shift;
-
- /* Mask to get column */
- column = to & 0x1f;
-
- /* Initialize return length value */
- *retlen = 0;
-
- /* Do not allow write past end of page */
- if ((column + len) > mtd->oobsize) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n");
- return -EINVAL;
- }
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd, FL_WRITING, NULL);
-
- /* Select the NAND device */
- nand_select ();
-
- /* Check the WP bit */
- this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
- if (!(readb (this->IO_ADDR_R) & 0x80)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Device is write protected!!!\n");
- ret = -EIO;
- goto out;
- }
-
- /* Write out desired data */
- this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page);
- /* prepad 0xff for partial programming */
- for (i = 0; i < column; i++)
- writeb (0xff, this->IO_ADDR_W);
- /* write data */
- for (i = 0; i < len; i++)
- writeb (buf[i], this->IO_ADDR_W);
- /* postpad 0xff for partial programming */
- for (i = len + column; i < mtd->oobsize; i++)
- writeb (0xff, this->IO_ADDR_W);
-
- /* Send command to program the OOB data */
- this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1);
-
- status = this->waitfunc (mtd, this, FL_WRITING);
-
- /* See if device thinks it succeeded */
- if (status & 0x01) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page);
- ret = -EIO;
- goto out;
- }
- /* Return happy */
- *retlen = len;
-
-#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
- /* Send command to read back the data */
- this->cmdfunc (mtd, NAND_CMD_READOOB, column, page);
-
- /* Loop through and verify the data */
- for (i = 0; i < len; i++) {
- if (buf[i] != readb (this->IO_ADDR_R)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page);
- ret = -EIO;
- goto out;
- }
- }
-#endif
-
-out:
- /* De-select the NAND device */
- nand_deselect ();
-
- /* Wake up anyone waiting on the device */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- wake_up (&this->wq);
- spin_unlock_bh (&this->chip_lock);
-
- return ret;
-}
-
-
-/*
- * NAND write with iovec
- */
-static int nand_writev (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count,
- loff_t to, size_t * retlen)
-{
- return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, 0));
-}
-
-static int nand_writev_ecc (struct mtd_info *mtd, const struct iovec *vecs, unsigned long count,
- loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel)
-{
- int i, page, len, total_len, ret = 0, written = 0;
- struct nand_chip *this = mtd->priv;
-
- /* Calculate total length of data */
- total_len = 0;
- for (i = 0; i < count; i++)
- total_len += (int) vecs[i].iov_len;
-
- DEBUG (MTD_DEBUG_LEVEL3,
- "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
-
- /* Do not allow write past end of page */
- if ((to + total_len) > mtd->size) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n");
- return -EINVAL;
- }
-
- /* reject writes, which are not page aligned */
- if (NOTALIGNED (to) || NOTALIGNED(total_len)) {
- printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n");
- return -EINVAL;
- }
-
- // if oobsel is NULL, use chip defaults
- if (oobsel == NULL)
- oobsel = &mtd->oobinfo;
-
- /* Shift to get page */
- page = ((int) to) >> this->page_shift;
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd, FL_WRITING, NULL);
-
- /* Select the NAND device */
- nand_select ();
-
- /* Check the WP bit */
- this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
- if (!(readb (this->IO_ADDR_R) & 0x80)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Device is write protected!!!\n");
- ret = -EIO;
- goto out;
- }
-
- /* Loop until all iovecs' data has been written */
- len = 0;
- while (count) {
- /*
- * Check, if the tuple gives us not enough data for a
- * full page write. Then we can use the iov direct,
- * else we have to copy into data_buf.
- */
- if ((vecs->iov_len - len) >= mtd->oobblock) {
- this->data_poi = (u_char *) vecs->iov_base;
- this->data_poi += len;
- len += mtd->oobblock;
- /* Check, if we have to switch to the next tuple */
- if (len >= (int) vecs->iov_len) {
- vecs++;
- len = 0;
- count--;
- }
- } else {
- /*
- * Read data out of each tuple until we have a full page
- * to write or we've read all the tuples.
- */
- int cnt = 0;
- while ((cnt < mtd->oobblock) && count) {
- if (vecs->iov_base != NULL && vecs->iov_len) {
- this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++];
- }
- /* Check, if we have to switch to the next tuple */
- if (len >= (int) vecs->iov_len) {
- vecs++;
- len = 0;
- count--;
- }
- }
- this->data_poi = this->data_buf;
- }
-
- /* We use the same function for write and writev !) */
- ret = nand_write_page (mtd, this, page, NULL, oobsel);
- if (ret)
- goto out;
-
- /* Update written bytes count */
- written += mtd->oobblock;
-
- /* Increment page address */
- page++;
- }
-
-out:
- /* De-select the NAND device */
- nand_deselect ();
-
- /* Wake up anyone waiting on the device */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- wake_up (&this->wq);
- spin_unlock_bh (&this->chip_lock);
-
- *retlen = written;
- return ret;
-}
-
-/*
- * NAND erase a block
- */
-static int nand_erase (struct mtd_info *mtd, struct erase_info *instr)
-{
- int page, len, status, pages_per_block, ret;
- struct nand_chip *this = mtd->priv;
- DECLARE_WAITQUEUE (wait, current);
-
- DEBUG (MTD_DEBUG_LEVEL3,
- "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
-
- /* Start address must align on block boundary */
- if (instr->addr & (mtd->erasesize - 1)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n");
- return -EINVAL;
- }
-
- /* Length must align on block boundary */
- if (instr->len & (mtd->erasesize - 1)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n");
- return -EINVAL;
- }
-
- /* Do not allow erase past end of device */
- if ((instr->len + instr->addr) > mtd->size) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n");
- return -EINVAL;
- }
-
- /* Grab the lock and see if the device is available */
- nand_get_chip (this, mtd, FL_ERASING, NULL);
-
- /* Shift to get first page */
- page = (int) (instr->addr >> this->page_shift);
-
- /* Calculate pages in each block */
- pages_per_block = mtd->erasesize / mtd->oobblock;
-
- /* Select the NAND device */
- nand_select ();
-
- /* Check the WP bit */
- this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
- if (!(readb (this->IO_ADDR_R) & 0x80)) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n");
- instr->state = MTD_ERASE_FAILED;
- goto erase_exit;
- }
-
- /* Loop through the pages */
- len = instr->len;
-
- instr->state = MTD_ERASING;
-
- while (len) {
- /* Check if we have a bad block, we do not erase bad blocks ! */
- this->cmdfunc (mtd, NAND_CMD_READOOB, NAND_BADBLOCK_POS, page);
- if (readb (this->IO_ADDR_R) != 0xff) {
- printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page);
- instr->state = MTD_ERASE_FAILED;
- goto erase_exit;
- }
-
- /* Send commands to erase a page */
- this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
- this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
-
- spin_unlock_bh (&this->chip_lock);
- status = this->waitfunc (mtd, this, FL_ERASING);
-
- /* Get spinlock, in case we exit */
- spin_lock_bh (&this->chip_lock);
- /* See if block erase succeeded */
- if (status & 0x01) {
- DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page);
- instr->state = MTD_ERASE_FAILED;
- goto erase_exit;
- }
-
- /* Check, if we were interupted */
- if (this->state == FL_ERASING) {
- /* Increment page address and decrement length */
- len -= mtd->erasesize;
- page += pages_per_block;
- }
- /* Release the spin lock */
- spin_unlock_bh (&this->chip_lock);
-erase_retry:
- spin_lock_bh (&this->chip_lock);
- /* Check the state and sleep if it changed */
- if (this->state == FL_ERASING || this->state == FL_READY) {
- /* Select the NAND device again, if we were interrupted */
- this->state = FL_ERASING;
- nand_select ();
- continue;
- } else {
- set_current_state (TASK_UNINTERRUPTIBLE);
- add_wait_queue (&this->wq, &wait);
- spin_unlock_bh (&this->chip_lock);
- schedule ();
- remove_wait_queue (&this->wq, &wait);
- goto erase_retry;
- }
- }
- instr->state = MTD_ERASE_DONE;
-
-erase_exit:
- /* De-select the NAND device */
- nand_deselect ();
- spin_unlock_bh (&this->chip_lock);
-
- ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
- /* Do call back function */
- if (!ret && instr->callback)
- instr->callback (instr);
-
- /* The device is ready */
- spin_lock_bh (&this->chip_lock);
- this->state = FL_READY;
- spin_unlock_bh (&this->chip_lock);
-
- /* Return more or less happy */
- return ret;
-}
-
-/*
- * NAND sync
- */
-static void nand_sync (struct mtd_info *mtd)
-{
- struct nand_chip *this = mtd->priv;
- DECLARE_WAITQUEUE (wait, current);
-
- DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n");
-
-retry:
- /* Grab the spinlock */
- spin_lock_bh (&this->chip_lock);
-
- /* See what's going on */
- switch (this->state) {
- case FL_READY:
- case FL_SYNCING:
- this->state = FL_SYNCING;
- spin_unlock_bh (&this->chip_lock);
- break;
-
- default:
- /* Not an idle state */
- add_wait_queue (&this->wq, &wait);
- spin_unlock_bh (&this->chip_lock);
- schedule ();
-
- remove_wait_queue (&this->wq, &wait);
- goto retry;
- }
-
- /* Lock the device */
- spin_lock_bh (&this->chip_lock);
-
- /* Set the device to be ready again */
- if (this->state == FL_SYNCING) {
- this->state = FL_READY;
- wake_up (&this->wq);
- }
-
- /* Unlock the device */
- spin_unlock_bh (&this->chip_lock);
-}
-
-/*
- * Scan for the NAND device
- */
-int nand_scan (struct mtd_info *mtd)
-{
- int i, nand_maf_id, nand_dev_id;
- struct nand_chip *this = mtd->priv;
-
- /* check for proper chip_delay setup, set 20us if not */
- if (!this->chip_delay)
- this->chip_delay = 20;
-
- /* check, if a user supplied command function given */
- if (this->cmdfunc == NULL)
- this->cmdfunc = nand_command;
-
- /* check, if a user supplied wait function given */
- if (this->waitfunc == NULL)
- this->waitfunc = nand_wait;
-
- /* Select the device */
- nand_select ();
-
- /* Send the command for reading device ID */
- this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
- /* Read manufacturer and device IDs */
- nand_maf_id = readb (this->IO_ADDR_R);
- nand_dev_id = readb (this->IO_ADDR_R);
-
- /* Print and store flash device information */
- for (i = 0; nand_flash_ids[i].name != NULL; i++) {
- if (nand_dev_id == nand_flash_ids[i].id && !mtd->size) {
- mtd->name = nand_flash_ids[i].name;
- mtd->erasesize = nand_flash_ids[i].erasesize;
- mtd->size = (1 << nand_flash_ids[i].chipshift);
- mtd->eccsize = 256;
- if (nand_flash_ids[i].page256) {
- mtd->oobblock = 256;
- mtd->oobsize = 8;
- this->page_shift = 8;
- } else {
- mtd->oobblock = 512;
- mtd->oobsize = 16;
- this->page_shift = 9;
- }
- /* Try to identify manufacturer */
- for (i = 0; nand_manuf_ids[i].id != 0x0; i++) {
- if (nand_manuf_ids[i].id == nand_maf_id)
- break;
- }
- printk (KERN_INFO "NAND device: Manufacture ID:"
- " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id,
- nand_manuf_ids[i].name , mtd->name);
- break;
- }
- }
-
- /*
- * check ECC mode, default to software
- * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize
- * fallback to software ECC
- */
- this->eccsize = 256; /* set default eccsize */
-
- switch (this->eccmode) {
-
- case NAND_ECC_HW3_512:
- if (mtd->oobblock == 256) {
- printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n");
- this->eccmode = NAND_ECC_SOFT;
- this->calculate_ecc = nand_calculate_ecc;
- this->correct_data = nand_correct_data;
- break;
- } else
- this->eccsize = 512; /* set eccsize to 512 and fall through for function check */
-
- case NAND_ECC_HW3_256:
- if (this->calculate_ecc && this->correct_data && this->enable_hwecc)
- break;
- printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n");
- BUG();
-
- case NAND_ECC_NONE:
- printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n");
- this->eccmode = NAND_ECC_NONE;
- break;
-
- case NAND_ECC_SOFT:
- this->calculate_ecc = nand_calculate_ecc;
- this->correct_data = nand_correct_data;
- break;
-
- default:
- printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode);
- BUG();
- }
-
- /* Initialize state, waitqueue and spinlock */
- this->state = FL_READY;
- init_waitqueue_head (&this->wq);
- spin_lock_init (&this->chip_lock);
-
- /* De-select the device */
- nand_deselect ();
-
- /* Print warning message for no device */
- if (!mtd->size) {
- printk (KERN_WARNING "No NAND device found!!!\n");
- return 1;
- }
-
- /* Fill in remaining MTD driver data */
- mtd->type = MTD_NANDFLASH;
- mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC;
- mtd->ecctype = MTD_ECC_SW;
- mtd->erase = nand_erase;
- mtd->point = NULL;
- mtd->unpoint = NULL;
- mtd->read = nand_read;
- mtd->write = nand_write;
- mtd->read_ecc = nand_read_ecc;
- mtd->write_ecc = nand_write_ecc;
- mtd->read_oob = nand_read_oob;
- mtd->write_oob = nand_write_oob;
- mtd->readv = NULL;
- mtd->writev = nand_writev;
- mtd->writev_ecc = nand_writev_ecc;
- mtd->sync = nand_sync;
- mtd->lock = NULL;
- mtd->unlock = NULL;
- mtd->suspend = NULL;
- mtd->resume = NULL;
- mtd->owner = THIS_MODULE;
-
- /* Return happy */
- return 0;
-}
-
-EXPORT_SYMBOL (nand_scan);
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>");
-MODULE_DESCRIPTION ("Generic NAND flash driver code");
+++ /dev/null
-/* auto_irq.c: Auto-configure IRQ lines for linux. */
-/*
- Written 1994 by Donald Becker.
-
- The author may be reached as becker@scyld.com
-
- This code is a general-purpose IRQ line detector for devices with
- jumpered IRQ lines. If you can make the device raise an IRQ (and
- that IRQ line isn't already being used), these routines will tell
- you what IRQ line it's using -- perfect for those oh-so-cool boot-time
- device probes!
-
- To use this, first call autoirq_setup(timeout). TIMEOUT is how many
- 'jiffies' (1/100 sec.) to detect other devices that have active IRQ lines,
- and can usually be zero at boot. 'autoirq_setup()' returns the bit
- vector of nominally-available IRQ lines (lines may be physically in-use,
- but not yet registered to a device).
- Next, set up your device to trigger an interrupt.
- Finally call autoirq_report(TIMEOUT) to find out which IRQ line was
- most recently active. The TIMEOUT should usually be zero, but may
- be set to the number of jiffies to wait for a slow device to raise an IRQ.
-
- The idea of using the setup timeout to filter out bogus IRQs came from
- the serial driver.
-*/
-
-
-#ifdef version
-static const char *version=
-"auto_irq.c:v1.11 Donald Becker (becker@scyld.com)";
-#endif
-
-#include <linux/module.h>
-#include <linux/jiffies.h>
-#include <linux/delay.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <linux/netdevice.h>
-
-static unsigned long irqs;
-
-void autoirq_setup(int waittime)
-{
- irqs = probe_irq_on();
-}
-
-#define BUSY_LOOP_UNTIL(j) while ((long)(jiffies-(j)) < 0) ;
-int autoirq_report(int waittime)
-{
- unsigned long delay = jiffies + waittime;
- BUSY_LOOP_UNTIL(delay)
- return probe_irq_off(irqs);
-}
-
-EXPORT_SYMBOL(autoirq_setup);
-EXPORT_SYMBOL(autoirq_report);
-
-\f
-/*
- * Local variables:
- * compile-command: "gcc -DKERNEL -Wall -O6 -fomit-frame-pointer -I/usr/src/linux/net/tcp -c auto_irq.c"
- * version-control: t
- * kept-new-versions: 5
- * c-indent-level: 4
- * tab-width: 4
- * End:
- */
+++ /dev/null
-/*
-
- ne2k_cbus.c: A driver for the NE2000 like ethernet on NEC PC-9800.
-
- This is a copy of the 2.5.66 Linux ISA NE2000 driver "ne.c"
- (Donald Becker/Paul Gortmaker) with the NEC PC-9800 specific
- changes added by Osamu Tomita.
-
-From ne.c:
------------
- Copyright 1993 United States Government as represented by the
- Director, National Security Agency.
-
- This software may be used and distributed according to the terms
- of the GNU General Public License, incorporated herein by reference.
------------
-
-*/
-
-/* Routines for the NatSemi-based designs (NE[12]000). */
-
-static const char version[] =
-"ne2k_cbus.c:v1.0 3/24/03 Osamu Tomita\n";
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/isapnp.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-
-#include "8390.h"
-
-/* Some defines that people can play with if so inclined. */
-
-/* Do we support clones that don't adhere to 14,15 of the SAprom ? */
-#define SUPPORT_NE_BAD_CLONES
-
-/* Do we perform extra sanity checks on stuff ? */
-/* #define NE_SANITY_CHECK */
-
-/* Do we implement the read before write bugfix ? */
-/* #define NE_RW_BUGFIX */
-
-/* Do we have a non std. amount of memory? (in units of 256 byte pages) */
-/* #define PACKETBUF_MEMSIZE 0x40 */
-
-#ifdef SUPPORT_NE_BAD_CLONES
-/* A list of bad clones that we none-the-less recognize. */
-static struct { const char *name8, *name16; unsigned char SAprefix[4];}
-bad_clone_list[] __initdata = {
- {"LA/T-98?", "LA/T-98", {0x00, 0xa0, 0xb0}}, /* I/O Data */
- {"EGY-98?", "EGY-98", {0x00, 0x40, 0x26}}, /* Melco EGY98 */
- {"ICM?", "ICM-27xx-ET", {0x00, 0x80, 0xc8}}, /* ICM IF-27xx-ET */
- {"CNET-98/EL?", "CNET(98)E/L", {0x00, 0x80, 0x4C}}, /* Contec CNET-98/EL */
- {0,}
-};
-#endif
-
-/* ---- No user-serviceable parts below ---- */
-
-#define NE_BASE (dev->base_addr)
-#define NE_CMD EI_SHIFT(0x00)
-#define NE_DATAPORT EI_SHIFT(0x10) /* NatSemi-defined port window offset. */
-#define NE_RESET EI_SHIFT(0x1f) /* Issue a read to reset, a write to clear. */
-#define NE_IO_EXTENT 0x20
-
-#define NE1SM_START_PG 0x20 /* First page of TX buffer */
-#define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
-#define NESM_START_PG 0x40 /* First page of TX buffer */
-#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
-
-#include "ne2k_cbus.h"
-
-static int ne_probe1(struct net_device *dev, int ioaddr);
-static int ne_open(struct net_device *dev);
-static int ne_close(struct net_device *dev);
-
-static void ne_reset_8390(struct net_device *dev);
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
- int ring_page);
-static void ne_block_input(struct net_device *dev, int count,
- struct sk_buff *skb, int ring_offset);
-static void ne_block_output(struct net_device *dev, const int count,
- const unsigned char *buf, const int start_page);
-
-\f
-/* Probe for various non-shared-memory ethercards.
-
- NEx000-clone boards have a Station Address PROM (SAPROM) in the packet
- buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of
- the SAPROM, while other supposed NE2000 clones must be detected by their
- SA prefix.
-
- Reading the SAPROM from a word-wide card with the 8390 set in byte-wide
- mode results in doubled values, which can be detected and compensated for.
-
- The probe is also responsible for initializing the card and filling
- in the 'dev' and 'ei_status' structures.
-
- We use the minimum memory size for some ethercard product lines, iff we can't
- distinguish models. You can increase the packet buffer size by setting
- PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are:
- E1010 starts at 0x100 and ends at 0x2000.
- E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory")
- E2010 starts at 0x100 and ends at 0x4000.
- E2010-x starts at 0x100 and ends at 0xffff. */
-
-static int __init do_ne_probe(struct net_device *dev)
-{
- unsigned int base_addr = dev->base_addr;
- int irq = dev->irq;
-
- SET_MODULE_OWNER(dev);
-
- if (ei_debug > 2)
- printk(KERN_DEBUG "ne_probe(): entered.\n");
-
- /* If CONFIG_NET_CBUS,
- we need dev->priv->reg_offset BEFORE to probe */
- if (ne2k_cbus_init(dev) != 0)
- return -ENOMEM;
-
- /* First check any supplied i/o locations. User knows best. <cough> */
- if (base_addr > 0) {
- int result;
- const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
- if (ei_debug > 2)
- printk(KERN_DEBUG "ne_probe(): call ne_probe_cbus(base_addr=0x%x)\n", base_addr);
-
- result = ne_probe_cbus(dev, hw, base_addr, irq);
- if (result != 0)
- ne2k_cbus_destroy(dev);
-
- return result;
- }
-
- if (ei_debug > 2)
- printk(KERN_DEBUG "ne_probe(): base_addr is not specified.\n");
-
-#ifndef MODULE
- /* Last resort. The semi-risky C-Bus auto-probe. */
- if (ei_debug > 2)
- printk(KERN_DEBUG "ne_probe(): auto-probe start.\n");
-
- {
- const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
- if (hw && hw->hwtype) {
- const unsigned short *plist;
- for (plist = hw->portlist; *plist; plist++)
- if (ne_probe_cbus(dev, hw, *plist, irq) == 0)
- return 0;
- } else {
- for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
- const unsigned short *plist;
- for (plist = hw->portlist; *plist; plist++)
- if (ne_probe_cbus(dev, hw, *plist, irq) == 0)
- return 0;
- }
- }
- }
-#endif
-
- ne2k_cbus_destroy(dev);
-
- return -ENODEV;
-}
-
-static void cleanup_card(struct net_device *dev)
-{
- const struct ne2k_cbus_region *rlist;
- const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
-
- free_irq(dev->irq, dev);
- for (rlist = hw->regionlist; rlist->range; rlist++) {
- release_region(dev->base_addr + rlist->start,
- rlist->range);
- }
- ne2k_cbus_destroy(dev);
-}
-
-struct net_device * __init ne_probe(int unit)
-{
- struct net_device *dev = alloc_ei_netdev();
- int err;
-
- if (!dev)
- return ERR_PTR(-ENOMEM);
-
- sprintf(dev->name, "eth%d", unit);
- netdev_boot_setup_check(dev);
-
- err = do_ne_probe(dev);
- if (err)
- goto out;
- err = register_netdev(dev);
- if (err)
- goto out1;
- return dev;
-out1:
- cleanup_card(dev);
-out:
- free_netdev(dev);
- return ERR_PTR(err);
-}
-
-static int __init ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr, int irq)
-{
- if (ei_debug > 2)
- printk(KERN_DEBUG "ne_probe_cbus(): entered. (called from %p)\n",
- __builtin_return_address(0));
-
- if (hw && hw->hwtype) {
- ne2k_cbus_set_hwtype(dev, hw, ioaddr);
- dev->irq = irq;
- return ne_probe1(dev, ioaddr);
- } else {
- /* auto detect */
-
- printk(KERN_DEBUG "ne_probe_cbus(): try to determine hardware types.\n");
- for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
- ne2k_cbus_set_hwtype(dev, hw, ioaddr);
- dev->irq = irq;
- if (ne_probe1(dev, ioaddr) == 0)
- return 0;
- }
- }
- return -ENODEV;
-}
-
-static int __init ne_probe1(struct net_device *dev, int ioaddr)
-{
- int i;
- unsigned char SA_prom[32];
- int wordlength = 2;
- const char *name = NULL;
- int start_page, stop_page;
- int neX000, bad_card;
- int reg0, ret;
- static unsigned version_printed;
- const struct ne2k_cbus_region *rlist;
- const struct ne2k_cbus_hwinfo *hw = ne2k_cbus_get_hwinfo((int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
- if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
- outb_p(0, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE);
- /* udelay(5000); */
- outb_p(1, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE);
- /* udelay(5000); */
- outb_p((ioaddr & 0xf000) >> 8 | 0x08 | 0x01, CONFIG_NE2K_CBUS_CNET98EL_IO_BASE + 2);
- /* udelay(5000); */
- }
-#endif
-
- for (rlist = hw->regionlist; rlist->range; rlist++)
- if (!request_region(ioaddr + rlist->start,
- rlist->range, dev->name)) {
- ret = -EBUSY;
- goto err_out;
- }
-
- reg0 = inb_p(ioaddr + EI_SHIFT(0));
- if (reg0 == 0xFF) {
- ret = -ENODEV;
- goto err_out;
- }
-
- /* Do a preliminary verification that we have a 8390. */
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
- if (hw->hwtype != NE2K_CBUS_HARDWARE_TYPE_CNET98EL)
-#endif
- {
- int regd;
- outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD);
- regd = inb_p(ioaddr + EI_SHIFT(0x0d));
- outb_p(0xff, ioaddr + EI_SHIFT(0x0d));
- outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD);
- inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */
- if (inb_p(ioaddr + EN0_COUNTER0) != 0) {
- outb_p(reg0, ioaddr);
- outb_p(regd, ioaddr + EI_SHIFT(0x0d)); /* Restore the old values. */
- ret = -ENODEV;
- goto err_out;
- }
- }
-
- if (ei_debug && version_printed++ == 0)
- printk(KERN_INFO "%s", version);
-
- printk(KERN_INFO "NE*000 ethercard probe at %#3x:", ioaddr);
-
- /* A user with a poor card that fails to ack the reset, or that
- does not have a valid 0x57,0x57 signature can still use this
- without having to recompile. Specifying an i/o address along
- with an otherwise unused dev->mem_end value of "0xBAD" will
- cause the driver to skip these parts of the probe. */
-
- bad_card = ((dev->base_addr != 0) && (dev->mem_end == 0xbad));
-
- /* Reset card. Who knows what dain-bramaged state it was left in. */
-
- {
- unsigned long reset_start_time = jiffies;
-
- /* derived from CNET98EL-patch for bad clones */
- outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD);
-
- /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
- outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
-
- while ((inb_p(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
- if (jiffies - reset_start_time > 2*HZ/100) {
- if (bad_card) {
- printk(" (warning: no reset ack)");
- break;
- } else {
- printk(" not found (no reset ack).\n");
- ret = -ENODEV;
- goto err_out;
- }
- }
-
- outb_p(0xff, ioaddr + EN0_ISR); /* Ack all intr. */
- }
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
- if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
- static const char pat[32] ="AbcdeFghijKlmnoPqrstUvwxyZ789012";
- char buf[32];
- int maxwait = 200;
-
- if (ei_debug > 2)
- printk(" [CNET98EL-specific initialize...");
- outb_p(E8390_NODMA | E8390_STOP, ioaddr + E8390_CMD); /* 0x20|0x1 */
- ret = -ENODEV;
- i = inb(ioaddr);
- if ((i & ~0x2) != (0x20 | 0x01))
- goto err_out;
- if ((inb(ioaddr + 0x7) & 0x80) != 0x80)
- goto err_out;
- outb_p(E8390_RXOFF, ioaddr + EN0_RXCR); /* out(ioaddr+0xc, 0x20) */
- /* outb_p(ENDCFG_WTS|ENDCFG_FT1|ENDCFG_LS, ioaddr+EN0_DCFG); */
- outb_p(ENDCFG_WTS | 0x48, ioaddr + EN0_DCFG); /* 0x49 */
- outb_p(CNET98EL_START_PG, ioaddr + EN0_STARTPG);
- outb_p(CNET98EL_STOP_PG, ioaddr + EN0_STOPPG);
- if (ei_debug > 2)
- printk("memory check");
- for (i = 0; i < 65536; i += 1024) {
- if (ei_debug > 2)
- printk(" %04x", i);
- ne2k_cbus_writemem(dev, ioaddr, i, pat, 32);
- while (((inb(ioaddr + EN0_ISR) & ENISR_RDC) != ENISR_RDC) && --maxwait)
- ;
- ne2k_cbus_readmem(dev, ioaddr, i, buf, 32);
- if (memcmp(pat, buf, 32)) {
- if (ei_debug > 2)
- printk(" failed.");
- break;
- }
- }
- if (i != 16384) {
- if (ei_debug > 2)
- printk("] ");
- printk("memory failure at %x\n", i);
- goto err_out;
- }
- if (ei_debug > 2)
- printk(" good...");
- if (!dev->irq) {
- if (ei_debug > 2)
- printk("] ");
- printk("IRQ must be specified for C-NET(98)E/L. probe failed.\n");
- goto err_out;
- }
- outb((dev->irq > 5) ? (dev->irq & 4):(dev->irq >> 1), ioaddr + (0x2 | 0x400));
- outb(0x7e, ioaddr + (0x4 | 0x400));
- ne2k_cbus_readmem(dev, ioaddr, 16384, SA_prom, 32);
- outb(0xff, ioaddr + EN0_ISR);
- if (ei_debug > 2)
- printk("done]");
- } else
-#endif /* CONFIG_NE2K_CBUS_CNET98EL */
- /* Read the 16 bytes of station address PROM.
- We must first initialize registers, similar to NS8390_init(eifdev, 0).
- We can't reliably read the SAPROM address without this.
- (I learned the hard way!). */
- {
- struct {unsigned char value; unsigned short offset;} program_seq[] =
- {
- {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/
- /* NEC PC-9800: some board can only handle word-wide access? */
- {0x48 | ENDCFG_WTS, EN0_DCFG}, /* Set word-wide (0x48) access. */
- {16384 / 256, EN0_STARTPG},
- {32768 / 256, EN0_STOPPG},
- {0x00, EN0_RCNTLO}, /* Clear the count regs. */
- {0x00, EN0_RCNTHI},
- {0x00, EN0_IMR}, /* Mask completion irq. */
- {0xFF, EN0_ISR},
- {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */
- {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */
- {32, EN0_RCNTLO},
- {0x00, EN0_RCNTHI},
- {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */
- {0x00, EN0_RSARHI},
- {E8390_RREAD+E8390_START, E8390_CMD},
- };
-
- for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++)
- outb_p(program_seq[i].value, ioaddr + program_seq[i].offset);
- insw(ioaddr + NE_DATAPORT, SA_prom, 32 >> 1);
-
- }
-
- if (wordlength == 2)
- {
- for (i = 0; i < 16; i++)
- SA_prom[i] = SA_prom[i+i];
- start_page = NESM_START_PG;
- stop_page = NESM_STOP_PG;
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
- if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_CNET98EL) {
- start_page = CNET98EL_START_PG;
- stop_page = CNET98EL_STOP_PG;
- }
-#endif
- } else {
- start_page = NE1SM_START_PG;
- stop_page = NE1SM_STOP_PG;
- }
-
- neX000 = (SA_prom[14] == 0x57 && SA_prom[15] == 0x57);
- if (neX000) {
- name = "C-Bus-NE2K-compat";
- }
- else
- {
-#ifdef SUPPORT_NE_BAD_CLONES
- /* Ack! Well, there might be a *bad* NE*000 clone there.
- Check for total bogus addresses. */
- for (i = 0; bad_clone_list[i].name8; i++)
- {
- if (SA_prom[0] == bad_clone_list[i].SAprefix[0] &&
- SA_prom[1] == bad_clone_list[i].SAprefix[1] &&
- SA_prom[2] == bad_clone_list[i].SAprefix[2])
- {
- if (wordlength == 2)
- {
- name = bad_clone_list[i].name16;
- } else {
- name = bad_clone_list[i].name8;
- }
- break;
- }
- }
- if (bad_clone_list[i].name8 == NULL)
- {
- printk(" not found (invalid signature %2.2x %2.2x).\n",
- SA_prom[14], SA_prom[15]);
- ret = -ENXIO;
- goto err_out;
- }
-#else
- printk(" not found.\n");
- ret = -ENXIO;
- goto err_out;
-#endif
- }
-
- if (dev->irq < 2)
- {
- unsigned long cookie = probe_irq_on();
- outb_p(0x50, ioaddr + EN0_IMR); /* Enable one interrupt. */
- outb_p(0x00, ioaddr + EN0_RCNTLO);
- outb_p(0x00, ioaddr + EN0_RCNTHI);
- outb_p(E8390_RREAD+E8390_START, ioaddr); /* Trigger it... */
- mdelay(10); /* wait 10ms for interrupt to propagate */
- outb_p(0x00, ioaddr + EN0_IMR); /* Mask it again. */
- dev->irq = probe_irq_off(cookie);
- if (ei_debug > 2)
- printk(" autoirq is %d\n", dev->irq);
- } else if (dev->irq == 7)
- /* Fixup for users that don't know that IRQ 7 is really IRQ 11,
- or don't know which one to set. */
- dev->irq = 11;
-
- if (! dev->irq) {
- printk(" failed to detect IRQ line.\n");
- ret = -EAGAIN;
- goto err_out;
- }
-
- /* Snarf the interrupt now. There's no point in waiting since we cannot
- share and the board will usually be enabled. */
- ret = request_irq(dev->irq, ei_interrupt, 0, name, dev);
- if (ret) {
- printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);
- goto err_out_kfree;
- }
-
- dev->base_addr = ioaddr;
-
- for(i = 0; i < ETHER_ADDR_LEN; i++) {
- printk(" %2.2x", SA_prom[i]);
- dev->dev_addr[i] = SA_prom[i];
- }
-
- printk("\n%s: %s found at %#x, hardware type %d(%s), using IRQ %d.\n",
- dev->name, name, ioaddr, hw->hwtype, hw->hwident, dev->irq);
-
- ei_status.name = name;
- ei_status.tx_start_page = start_page;
- ei_status.stop_page = stop_page;
- ei_status.word16 = (wordlength == 2);
-
- ei_status.rx_start_page = start_page + TX_PAGES;
-#ifdef PACKETBUF_MEMSIZE
- /* Allow the packet buffer size to be overridden by know-it-alls. */
- ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE;
-#endif
-
- ei_status.reset_8390 = &ne_reset_8390;
- ei_status.block_input = &ne_block_input;
- ei_status.block_output = &ne_block_output;
- ei_status.get_8390_hdr = &ne_get_8390_hdr;
- ei_status.priv = 0;
- dev->open = &ne_open;
- dev->stop = &ne_close;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = ei_poll;
-#endif
- NS8390_init(dev, 0);
- return 0;
-
-err_out_kfree:
- ne2k_cbus_destroy(dev);
-err_out:
- while (rlist > hw->regionlist) {
- rlist --;
- release_region(ioaddr + rlist->start, rlist->range);
- }
- return ret;
-}
-
-static int ne_open(struct net_device *dev)
-{
- ei_open(dev);
- return 0;
-}
-
-static int ne_close(struct net_device *dev)
-{
- if (ei_debug > 1)
- printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
- ei_close(dev);
- return 0;
-}
-
-/* Hard reset the card. This used to pause for the same period that a
- 8390 reset command required, but that shouldn't be necessary. */
-
-static void ne_reset_8390(struct net_device *dev)
-{
- unsigned long reset_start_time = jiffies;
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
- if (ei_debug > 1)
- printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies);
-
- /* derived from CNET98EL-patch for bad clones... */
- outb_p(E8390_NODMA | E8390_STOP, NE_BASE + E8390_CMD); /* 0x20 | 0x1 */
-
- /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
- outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
-
- ei_status.txing = 0;
- ei_status.dmaing = 0;
-
- /* This check _should_not_ be necessary, omit eventually. */
- while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0)
- if (jiffies - reset_start_time > 2*HZ/100) {
- printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name);
- break;
- }
- outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */
-}
-
-/* Grab the 8390 specific header. Similar to the block_input routine, but
- we don't need to be concerned with ring wrap as the header will be at
- the start of a page, so we optimize accordingly. */
-
-static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
-{
- int nic_base = dev->base_addr;
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
-
- if (ei_status.dmaing)
- {
- printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr "
- "[DMAstat:%d][irqlock:%d].\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
-
- ei_status.dmaing |= 0x01;
- outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
- outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
- outb_p(0, nic_base + EN0_RCNTHI);
- outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
- outb_p(ring_page, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
-
- if (ei_status.word16)
- insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
- else
- insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
-
- le16_to_cpus(&hdr->count);
-}
-
-/* Block input and output, similar to the Crynwr packet driver. If you
- are porting to a new ethercard, look at the packet driver source for hints.
- The NEx000 doesn't share the on-board packet memory -- you have to put
- the packet out through the "remote DMA" dataport using outb. */
-
-static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
-{
-#ifdef NE_SANITY_CHECK
- int xfer_count = count;
-#endif
- int nic_base = dev->base_addr;
- char *buf = skb->data;
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
- if (ei_status.dmaing)
- {
- printk(KERN_EMERG "%s: DMAing conflict in ne_block_input "
- "[DMAstat:%d][irqlock:%d].\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
- ei_status.dmaing |= 0x01;
-
- /* round up count to a word (derived from ICM-patch) */
- count = (count + 1) & ~1;
-
- outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD);
- outb_p(count & 0xff, nic_base + EN0_RCNTLO);
- outb_p(count >> 8, nic_base + EN0_RCNTHI);
- outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
- outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
- if (ei_status.word16)
- {
- insw(NE_BASE + NE_DATAPORT,buf,count>>1);
- if (count & 0x01)
- {
- buf[count-1] = inb(NE_BASE + NE_DATAPORT);
-#ifdef NE_SANITY_CHECK
- xfer_count++;
-#endif
- }
- } else {
- insb(NE_BASE + NE_DATAPORT, buf, count);
- }
-
-#ifdef NE_SANITY_CHECK
- /* This was for the ALPHA version only, but enough people have
- been encountering problems so it is still here. If you see
- this message you either 1) have a slightly incompatible clone
- or 2) have noise/speed problems with your bus. */
-
- if (ei_debug > 1)
- {
- /* DMA termination address check... */
- int addr, tries = 20;
- do {
- /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
- -- it's broken for Rx on some cards! */
- int high = inb_p(nic_base + EN0_RSARHI);
- int low = inb_p(nic_base + EN0_RSARLO);
- addr = (high << 8) + low;
- if (((ring_offset + xfer_count) & 0xff) == low)
- break;
- } while (--tries > 0);
- if (tries <= 0)
- printk(KERN_WARNING "%s: RX transfer address mismatch,"
- "%#4.4x (expected) vs. %#4.4x (actual).\n",
- dev->name, ring_offset + xfer_count, addr);
- }
-#endif
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
-}
-
-static void ne_block_output(struct net_device *dev, int count,
- const unsigned char *buf, const int start_page)
-{
- int nic_base = NE_BASE;
- unsigned long dma_start;
-#ifdef NE_SANITY_CHECK
- int retries = 0;
-#endif
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
-
- /* Round the count up for word writes. Do we need to do this?
- What effect will an odd byte count have on the 8390?
- I should check someday. */
-
- if (ei_status.word16 && (count & 0x01))
- count++;
-
- /* This *shouldn't* happen. If it does, it's the last thing you'll see */
- if (ei_status.dmaing)
- {
- printk(KERN_EMERG "%s: DMAing conflict in ne_block_output."
- "[DMAstat:%d][irqlock:%d]\n",
- dev->name, ei_status.dmaing, ei_status.irqlock);
- return;
- }
- ei_status.dmaing |= 0x01;
- /* We should already be in page 0, but to be safe... */
- outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD);
-
-#ifdef NE_SANITY_CHECK
-retry:
-#endif
-
-#ifdef NE8390_RW_BUGFIX
- /* Handle the read-before-write bug the same way as the
- Crynwr packet driver -- the NatSemi method doesn't work.
- Actually this doesn't always work either, but if you have
- problems with your NEx000 this is better than nothing! */
-
- outb_p(0x42, nic_base + EN0_RCNTLO);
- outb_p(0x00, nic_base + EN0_RCNTHI);
- outb_p(0x42, nic_base + EN0_RSARLO);
- outb_p(0x00, nic_base + EN0_RSARHI);
- outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
- /* Make certain that the dummy read has occurred. */
- udelay(6);
-#endif
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR);
-
- /* Now the normal output. */
- outb_p(count & 0xff, nic_base + EN0_RCNTLO);
- outb_p(count >> 8, nic_base + EN0_RCNTHI);
- outb_p(0x00, nic_base + EN0_RSARLO);
- outb_p(start_page, nic_base + EN0_RSARHI);
-
- outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD);
- if (ei_status.word16) {
- outsw(NE_BASE + NE_DATAPORT, buf, count>>1);
- } else {
- outsb(NE_BASE + NE_DATAPORT, buf, count);
- }
-
- dma_start = jiffies;
-
-#ifdef NE_SANITY_CHECK
- /* This was for the ALPHA version only, but enough people have
- been encountering problems so it is still here. */
-
- if (ei_debug > 1)
- {
- /* DMA termination address check... */
- int addr, tries = 20;
- do {
- int high = inb_p(nic_base + EN0_RSARHI);
- int low = inb_p(nic_base + EN0_RSARLO);
- addr = (high << 8) + low;
- if ((start_page << 8) + count == addr)
- break;
- } while (--tries > 0);
-
- if (tries <= 0)
- {
- printk(KERN_WARNING "%s: Tx packet transfer address mismatch,"
- "%#4.4x (expected) vs. %#4.4x (actual).\n",
- dev->name, (start_page << 8) + count, addr);
- if (retries++ == 0)
- goto retry;
- }
- }
-#endif
-
- while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0)
- if (jiffies - dma_start > 2*HZ/100) { /* 20ms */
- printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
- ne_reset_8390(dev);
- NS8390_init(dev,1);
- break;
- }
-
- outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
- ei_status.dmaing &= ~0x01;
- return;
-}
-
-\f
-#ifdef MODULE
-#define MAX_NE_CARDS 4 /* Max number of NE cards per module */
-static struct net_device *dev_ne[MAX_NE_CARDS];
-static int io[MAX_NE_CARDS];
-static int irq[MAX_NE_CARDS];
-static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */
-static int hwtype[MAX_NE_CARDS] = { 0, }; /* board type */
-
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(hwtype, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM_DESC(io, "I/O base address(es),required");
-MODULE_PARM_DESC(irq, "IRQ number(s)");
-MODULE_PARM_DESC(bad, "Accept card(s) with bad signatures");
-MODULE_PARM_DESC(hwtype, "Board type of PC-9800 C-Bus NIC");
-MODULE_DESCRIPTION("NE1000/NE2000 PC-9800 C-bus Ethernet driver");
-MODULE_LICENSE("GPL");
-
-/* This is set up so that no ISA autoprobe takes place. We can't guarantee
-that the ne2k probe is the last 8390 based probe to take place (as it
-is at boot) and so the probe will get confused by any other 8390 cards.
-ISA device autoprobes on a running machine are not recommended anyway. */
-
-int init_module(void)
-{
- int this_dev, found = 0;
-
- for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
- struct net_device *dev = alloc_ei_netdev();
- if (!dev)
- break;
- dev->irq = irq[this_dev];
- dev->mem_end = bad[this_dev];
- dev->base_addr = io[this_dev];
- dev->mem_start = hwtype[this_dev];
- if (do_ne_probe(dev) == 0) {
- if (register_netdev(dev) == 0) {
- dev_ne[found++] = dev;
- continue;
- }
- cleanup_card(dev);
- }
- free_netdev(dev);
- if (found)
- break;
- if (io[this_dev] != 0)
- printk(KERN_WARNING "ne2k_cbus: No NE*000 card found at i/o = %#x\n", io[this_dev]);
- else
- printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n");
- return -ENXIO;
- }
- if (found)
- return 0;
- return -ENODEV;
-}
-
-void cleanup_module(void)
-{
- int this_dev;
-
- for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
- struct net_device *dev = dev_ne[this_dev];
- if (dev) {
- unregister_netdev(dev);
- cleanup_card(dev);
- free_netdev(dev);
- }
- }
-}
-#endif /* MODULE */
-
+++ /dev/null
-/* ne2k_cbus.h:
- vender-specific information definition for NEC PC-9800
- C-bus Ethernet Cards
- Used in ne.c
-
- (C)1998,1999 KITAGWA Takurou & Linux/98 project
-*/
-
-#include <linux/config.h>
-
-#undef NE_RESET
-#define NE_RESET EI_SHIFT(0x11) /* Issue a read to reset, a write to clear. */
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-#ifndef CONFIG_NE2K_CBUS_CNET98EL_IO_BASE
-#warning CONFIG_NE2K_CBUS_CNET98EL_IO_BASE is not defined(config error?)
-#warning use 0xaaed as default
-#define CONFIG_NE2K_CBUS_CNET98EL_IO_BASE 0xaaed /* or 0x55ed */
-#endif
-#define CNET98EL_START_PG 0x00
-#define CNET98EL_STOP_PG 0x40
-#endif
-
-/* Hardware type definition (derived from *BSD) */
-#define NE2K_CBUS_HARDWARE_TYPE_MASK 0xff
-
-/* 0: reserved for auto-detect */
-/* 1: (not tested)
- Allied Telesis CentreCom LA-98-T */
-#define NE2K_CBUS_HARDWARE_TYPE_ATLA98 1
-/* 2: (not tested)
- ELECOM Laneed
- LD-BDN[123]A
- PLANET SMART COM 98 EN-2298-C
- MACNICA ME98 */
-#define NE2K_CBUS_HARDWARE_TYPE_BDN 2
-/* 3:
- Melco EGY-98
- Contec C-NET(98)E*A/L*A,C-NET(98)P */
-#define NE2K_CBUS_HARDWARE_TYPE_EGY98 3
-/* 4:
- Melco LGY-98,IND-SP,IND-SS
- MACNICA NE2098 */
-#define NE2K_CBUS_HARDWARE_TYPE_LGY98 4
-/* 5:
- ICM DT-ET-25,DT-ET-T5,IF-2766ET,IF-2771ET
- PLANET SMART COM 98 EN-2298-T,EN-2298P-T
- D-Link DE-298PT,DE-298PCAT
- ELECOM Laneed LD-98P */
-#define NE2K_CBUS_HARDWARE_TYPE_ICM 5
-/* 6: (reserved for SIC-98, which is not supported in this driver.) */
-/* 7: (unused in *BSD?)
- <Original NE2000 compatible>
- <for PCI/PCMCIA cards>
-*/
-#define NE2K_CBUS_HARDWARE_TYPE_NE2K 7
-/* 8:
- NEC PC-9801-108 */
-#define NE2K_CBUS_HARDWARE_TYPE_NEC108 8
-/* 9:
- I-O DATA LA-98,LA/T-98 */
-#define NE2K_CBUS_HARDWARE_TYPE_IOLA98 9
-/* 10: (reserved for C-NET(98), which is not supported in this driver.) */
-/* 11:
- Contec C-NET(98)E,L */
-#define NE2K_CBUS_HARDWARE_TYPE_CNET98EL 11
-
-#define NE2K_CBUS_HARDWARE_TYPE_MAX 11
-
-/* HARDWARE TYPE ID 12-31: reserved */
-
-struct ne2k_cbus_offsetinfo {
- unsigned short skip;
- unsigned short offset8; /* +0x8 - +0xf */
- unsigned short offset10; /* +0x10 */
- unsigned short offset1f; /* +0x1f */
-};
-
-struct ne2k_cbus_region {
- unsigned short start;
- short range;
-};
-
-struct ne2k_cbus_hwinfo {
- const unsigned short hwtype;
- const unsigned char *hwident;
-#ifndef MODULE
- const unsigned short *portlist;
-#endif
- const struct ne2k_cbus_offsetinfo *offsetinfo;
- const struct ne2k_cbus_region *regionlist;
-};
-
-#ifdef CONFIG_NE2K_CBUS_ATLA98
-#ifndef MODULE
-static unsigned short atla98_portlist[] __initdata = {
- 0xd0,
- 0
-};
-#endif
-#define atla98_offsetinfo ne2k_offsetinfo
-#define atla98_regionlist ne2k_regionlist
-#endif /* CONFIG_NE2K_CBUS_ATLA98 */
-
-#ifdef CONFIG_NE2K_CBUS_BDN
-#ifndef MODULE
-static unsigned short bdn_portlist[] __initdata = {
- 0xd0,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo bdn_offsetinfo __initdata = {
-#if 0
- /* comes from FreeBSD(98) ed98.h */
- 0x1000, 0x8000, 0x100, 0xc200 /* ??? */
-#else
- /* comes from NetBSD/pc98 if_ne_isa.c */
- 0x1000, 0x8000, 0x100, 0x7f00 /* ??? */
-#endif
-};
-static struct ne2k_cbus_region bdn_regionlist[] __initdata = {
- {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000,1},
- {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1},
- {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1},
- {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1},
- {0x100, 1}, {0x7f00, 1},
- {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_BDN */
-
-#ifdef CONFIG_NE2K_CBUS_EGY98
-#ifndef MODULE
-static unsigned short egy98_portlist[] __initdata = {
- 0xd0,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo egy98_offsetinfo __initdata = {
- 0x02, 0x100, 0x200, 0x300
-};
-static struct ne2k_cbus_region egy98_regionlist[] __initdata = {
- {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1},
- {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1},
- {0x100, 1}, {0x102, 1}, {0x104, 1}, {0x106, 1},
- {0x108, 1}, {0x10a, 1}, {0x10c, 1}, {0x10e, 1},
- {0x200, 1}, {0x300, 1},
- {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_EGY98 */
-
-#ifdef CONFIG_NE2K_CBUS_LGY98
-#ifndef MODULE
-static unsigned short lgy98_portlist[] __initdata = {
- 0xd0, 0x10d0, 0x20d0, 0x30d0, 0x40d0, 0x50d0, 0x60d0, 0x70d0,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo lgy98_offsetinfo __initdata = {
- 0x01, 0x08, 0x200, 0x300
-};
-static struct ne2k_cbus_region lgy98_regionlist[] __initdata = {
- {0x0, 16}, {0x200, 1}, {0x300, 1},
- {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_LGY98 */
-
-#ifdef CONFIG_NE2K_CBUS_ICM
-#ifndef MODULE
-static unsigned short icm_portlist[] __initdata = {
- /* ICM */
- 0x56d0,
- /* LD-98PT */
- 0x46d0, 0x66d0, 0x76d0, 0x86d0, 0x96d0, 0xa6d0, 0xb6d0, 0xc6d0,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo icm_offsetinfo __initdata = {
- 0x01, 0x08, 0x100, 0x10f
-};
-static struct ne2k_cbus_region icm_regionlist[] __initdata = {
- {0x0, 16}, {0x100, 16},
- {0x0, 0}
-};
-#endif /* CONFIG_NE2K_CBUS_ICM */
-
-#if defined(CONFIG_NE2K_CBUS_NE2K) && !defined(MODULE)
-static unsigned short ne2k_portlist[] __initdata = {
- 0xd0, 0x300, 0x280, 0x320, 0x340, 0x360, 0x380,
- 0
-};
-#endif
-#if defined(CONFIG_NE2K_CBUS_NE2K) || defined(CONFIG_NE2K_CBUS_ATLA98)
-static struct ne2k_cbus_offsetinfo ne2k_offsetinfo __initdata = {
- 0x01, 0x08, 0x10, 0x1f
-};
-static struct ne2k_cbus_region ne2k_regionlist[] __initdata = {
- {0x0, 32},
- {0x0, 0}
-};
-#endif
-
-#ifdef CONFIG_NE2K_CBUS_NEC108
-#ifndef MODULE
-static unsigned short nec108_portlist[] __initdata = {
- 0x770, 0x2770, 0x4770, 0x6770,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo nec108_offsetinfo __initdata = {
- 0x02, 0x1000, 0x888, 0x88a
-};
-static struct ne2k_cbus_region nec108_regionlist[] __initdata = {
- {0x0, 1}, {0x2, 1}, {0x4, 1}, {0x6, 1},
- {0x8, 1}, {0xa, 1}, {0xc, 1}, {0xe, 1},
- {0x1000, 1}, {0x1002, 1}, {0x1004, 1}, {0x1006, 1},
- {0x1008, 1}, {0x100a, 1}, {0x100c, 1}, {0x100e, 1},
- {0x888, 1}, {0x88a, 1}, {0x88c, 1}, {0x88e, 1},
- {0x0, 0}
-};
-#endif
-
-#ifdef CONFIG_NE2K_CBUS_IOLA98
-#ifndef MODULE
-static unsigned short iola98_portlist[] __initdata = {
- 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo iola98_offsetinfo __initdata = {
- 0x1000, 0x8000, 0x100, 0xf100
-};
-static struct ne2k_cbus_region iola98_regionlist[] __initdata = {
- {0x0, 1}, {0x1000, 1}, {0x2000, 1}, {0x3000, 1},
- {0x4000, 1}, {0x5000, 1}, {0x6000, 1}, {0x7000, 1},
- {0x8000, 1}, {0x9000, 1}, {0xa000, 1}, {0xb000, 1},
- {0xc000, 1}, {0xd000, 1}, {0xe000, 1}, {0xf000, 1},
- {0x100, 1}, {0xf100, 1},
- {0x0,0}
-};
-#endif /* CONFIG_NE2K_CBUS_IOLA98 */
-
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
-#ifndef MODULE
-static unsigned short cnet98el_portlist[] __initdata = {
- 0x3d0, 0x13d0, 0x23d0, 0x33d0, 0x43d0, 0x53d0, 0x60d0, 0x70d0,
- 0
-};
-#endif
-static struct ne2k_cbus_offsetinfo cnet98el_offsetinfo __initdata = {
- 0x01, 0x08, 0x40e, 0x400
-};
-static struct ne2k_cbus_region cnet98el_regionlist[] __initdata = {
- {0x0, 16}, {0x400, 16},
- {0x0, 0}
-};
-#endif
-
-
-/* port information table (for ne.c initialize/probe process) */
-
-static struct ne2k_cbus_hwinfo ne2k_cbus_hwinfo_list[] __initdata = {
-#ifdef CONFIG_NE2K_CBUS_ATLA98
-/* NOT TESTED */
- {
- NE2K_CBUS_HARDWARE_TYPE_ATLA98,
- "LA-98-T",
-#ifndef MODULE
- atla98_portlist,
-#endif
- &atla98_offsetinfo, atla98_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_BDN
-/* NOT TESTED */
- {
- NE2K_CBUS_HARDWARE_TYPE_BDN,
- "LD-BDN[123]A",
-#ifndef MODULE
- bdn_portlist,
-#endif
- &bdn_offsetinfo, bdn_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_ICM
- {
- NE2K_CBUS_HARDWARE_TYPE_ICM,
- "IF-27xxET",
-#ifndef MODULE
- icm_portlist,
-#endif
- &icm_offsetinfo, icm_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_NE2K
- {
- NE2K_CBUS_HARDWARE_TYPE_NE2K,
- "NE2000 compat.",
-#ifndef MODULE
- ne2k_portlist,
-#endif
- &ne2k_offsetinfo, ne2k_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_NEC108
- {
- NE2K_CBUS_HARDWARE_TYPE_NEC108,
- "PC-9801-108",
-#ifndef MODULE
- nec108_portlist,
-#endif
- &nec108_offsetinfo, nec108_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_IOLA98
- {
- NE2K_CBUS_HARDWARE_TYPE_IOLA98,
- "LA-98",
-#ifndef MODULE
- iola98_portlist,
-#endif
- &iola98_offsetinfo, iola98_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_CNET98EL
- {
- NE2K_CBUS_HARDWARE_TYPE_CNET98EL,
- "C-NET(98)E/L",
-#ifndef MODULE
- cnet98el_portlist,
-#endif
- &cnet98el_offsetinfo, cnet98el_regionlist
- },
-#endif
-/* NOTE: LGY98 must be probed before EGY98, or system stalled!? */
-#ifdef CONFIG_NE2K_CBUS_LGY98
- {
- NE2K_CBUS_HARDWARE_TYPE_LGY98,
- "LGY-98",
-#ifndef MODULE
- lgy98_portlist,
-#endif
- &lgy98_offsetinfo, lgy98_regionlist
- },
-#endif
-#ifdef CONFIG_NE2K_CBUS_EGY98
- {
- NE2K_CBUS_HARDWARE_TYPE_EGY98,
- "EGY-98",
-#ifndef MODULE
- egy98_portlist,
-#endif
- &egy98_offsetinfo, egy98_regionlist
- },
-#endif
- {
- 0,
- "unsupported hardware",
-#ifndef MODULE
- NULL,
-#endif
- NULL, NULL
- }
-};
-
-static int __init ne2k_cbus_init(struct net_device *dev)
-{
- struct ei_device *ei_local;
- if (dev->priv == NULL) {
- ei_local = kmalloc(sizeof(struct ei_device), GFP_KERNEL);
- if (ei_local == NULL)
- return -ENOMEM;
- memset(ei_local, 0, sizeof(struct ei_device));
- ei_local->reg_offset = kmalloc(sizeof(typeof(*ei_local->reg_offset))*18, GFP_KERNEL);
- if (ei_local->reg_offset == NULL) {
- kfree(ei_local);
- return -ENOMEM;
- }
- spin_lock_init(&ei_local->page_lock);
- dev->priv = ei_local;
- }
- return 0;
-}
-
-static void ne2k_cbus_destroy(struct net_device *dev)
-{
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
- if (ei_local != NULL) {
- if (ei_local->reg_offset)
- kfree(ei_local->reg_offset);
- kfree(dev->priv);
- dev->priv = NULL;
- }
-}
-
-static const struct ne2k_cbus_hwinfo * __init ne2k_cbus_get_hwinfo(int hwtype)
-{
- const struct ne2k_cbus_hwinfo *hw;
-
- for (hw = &ne2k_cbus_hwinfo_list[0]; hw->hwtype; hw++) {
- if (hw->hwtype == hwtype) break;
- }
- return hw;
-}
-
-static void __init ne2k_cbus_set_hwtype(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr)
-{
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
- int i;
- int hwtype_old = dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK;
-
- if (!ei_local)
- panic("Gieee! ei_local == NULL!! (from %p)",
- __builtin_return_address(0));
-
- dev->mem_start &= ~NE2K_CBUS_HARDWARE_TYPE_MASK;
- dev->mem_start |= hw->hwtype & NE2K_CBUS_HARDWARE_TYPE_MASK;
-
- if (ei_debug > 2) {
- printk(KERN_DEBUG "hwtype changed: %d -> %d\n",hwtype_old,(int)(dev->mem_start & NE2K_CBUS_HARDWARE_TYPE_MASK));
- }
-
- if (hw->offsetinfo) {
- for (i = 0; i < 8; i++) {
- ei_local->reg_offset[i] = hw->offsetinfo->skip * i;
- }
- for (i = 8; i < 16; i++) {
- ei_local->reg_offset[i] =
- hw->offsetinfo->skip*(i-8) + hw->offsetinfo->offset8;
- }
-#ifdef CONFIG_NE2K_CBUS_NEC108
- if (hw->hwtype == NE2K_CBUS_HARDWARE_TYPE_NEC108) {
- int adj = (ioaddr & 0xf000) /2;
- ei_local->reg_offset[16] =
- (hw->offsetinfo->offset10 | adj) - ioaddr;
- ei_local->reg_offset[17] =
- (hw->offsetinfo->offset1f | adj) - ioaddr;
- } else {
-#endif /* CONFIG_NE2K_CBUS_NEC108 */
- ei_local->reg_offset[16] = hw->offsetinfo->offset10;
- ei_local->reg_offset[17] = hw->offsetinfo->offset1f;
-#ifdef CONFIG_NE2K_CBUS_NEC108
- }
-#endif
- } else {
- /* make dummmy offset list */
- for (i = 0; i < 16; i++) {
- ei_local->reg_offset[i] = i;
- }
- ei_local->reg_offset[16] = 0x10;
- ei_local->reg_offset[17] = 0x1f;
- }
-}
-
-#if defined(CONFIG_NE2K_CBUS_ICM) || defined(CONFIG_NE2K_CBUS_CNET98EL)
-static void __init ne2k_cbus_readmem(struct net_device *dev, int ioaddr, unsigned short memaddr, char *buf, unsigned short len)
-{
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
- outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD);
- outb_p(len & 0xff, ioaddr+EN0_RCNTLO);
- outb_p(len >> 8, ioaddr+EN0_RCNTHI);
- outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO);
- outb_p(memaddr >> 8, ioaddr+EN0_RSARHI);
- outb_p(E8390_RREAD | E8390_START, ioaddr+E8390_CMD);
- insw(ioaddr+NE_DATAPORT, buf, len >> 1);
-}
-static void __init ne2k_cbus_writemem(struct net_device *dev, int ioaddr, unsigned short memaddr, const char *buf, unsigned short len)
-{
- struct ei_device *ei_local = (struct ei_device *)(dev->priv);
- outb_p(E8390_NODMA | E8390_START, ioaddr+E8390_CMD);
- outb_p(ENISR_RDC, ioaddr+EN0_ISR);
- outb_p(len & 0xff, ioaddr+EN0_RCNTLO);
- outb_p(len >> 8, ioaddr+EN0_RCNTHI);
- outb_p(memaddr & 0xff, ioaddr+EN0_RSARLO);
- outb_p(memaddr >> 8, ioaddr+EN0_RSARHI);
- outb_p(E8390_RWRITE | E8390_START, ioaddr+E8390_CMD);
- outsw(ioaddr+NE_DATAPORT, buf, len >> 1);
-}
-#endif
-
-static int ne_probe_cbus(struct net_device *dev, const struct ne2k_cbus_hwinfo *hw, int ioaddr, int irq);
-/* End of ne2k_cbus.h */
+++ /dev/null
-/*
-** *************************************************************************
-**
-**
-** R C I F . H
-**
-**
-** RedCreek InterFace include file.
-**
-** ---------------------------------------------------------------------
-** --- Copyright (c) 1998-1999, RedCreek Communications Inc. ---
-** --- All rights reserved. ---
-** ---------------------------------------------------------------------
-**
-** File Description:
-**
-** Header file private ioctl commands.
-**
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-** *************************************************************************
-*/
-
-#ifndef RCIF_H
-#define RCIF_H
-
-/* The following protocol revision # should be incremented every time
- a new protocol or new structures are used in this file. */
-int USER_PROTOCOL_REV = 2; /* used to track different protocol revisions */
-
-/* define a single TCB & buffer */
-typedef struct { /* a single buffer */
- U32 context; /* context */
- U32 scount; /* segment count */
- U32 size; /* segment size */
- U32 addr; /* segment physical address */
-} __attribute__ ((packed))
- singleB, *psingleB;
-typedef struct { /* a single TCB */
- /*
- ** +-----------------------+
- ** | 1 | one buffer in the TCB
- ** +-----------------------+
- ** | <user's Context> | user's buffer reference
- ** +-----------------------+
- ** | 1 | one segment buffer
- ** +-----------------------+ _
- ** | <buffer size> | size \
- ** +-----------------------+ \ segment descriptor
- ** | <physical address> | physical address of buffer /
- ** +-----------------------+ _/
- */
- U32 bcount; /* buffer count */
- singleB b; /* buffer */
-
-} __attribute__ ((packed))
- singleTCB, *psingleTCB;
-
-/*
- When adding new entries, please add all 5 related changes, since
- it helps keep everything consistent:
- 1) User structure entry
- 2) User data entry
- 3) Structure short-cut entry
- 4) Data short-cut entry
- 5) Command identifier entry
-
- For Example ("GETSPEED"):
- 1) struct RCgetspeed_tag { U32 LinkSpeedCode; } RCgetspeed;
- 2) struct RCgetspeed_tag *getspeed;
- 3) #define RCUS_GETSPEED data.RCgetspeed;
- 4) #define RCUD_GETSPEED _RC_user_data.getspeed
- 5) #define RCUC_GETSPEED 0x02
-
- Notes for the "GETSPEED" entry, above:
- 1) RCgetspeed - RC{name}
- RCgetspeed_tag - RC{name}_tag
- LinkSpeedCode - create any structure format desired (not too large,
- since memory will be unioned with all other entries)
- 2) RCgetspeed_tag - RC{name}_tag chosen in #1
- getspeed - arbitrary name (ptr to structure in #1)
- 3) RCUS_GETSPEED - RCUS_{NAME} ("NAME" & "name" do not have to the same)
- data.RCgetspeed - data.RC{name} ("RC{name}" from #1)
- 4) RCUD_GETSPEED - _RC_user_data.getspeed ("getspeed" from #2)
- 5) RCUC_GETSPEED - unique hex identifier entry.
-*/
-
-typedef struct RC_user_tag RCuser_struct;
-
-/* 1) User structure entry */
-struct RC_user_tag {
- int cmd;
- union {
- /* GETINFO structure */
- struct RCgetinfo_tag {
- unsigned long int mem_start;
- unsigned long int mem_end;
- unsigned long int base_addr;
- unsigned char irq;
- unsigned char dma;
- unsigned char port;
- } RCgetinfo; /* <---- RCgetinfo */
-
- /* GETSPEED structure */
- struct RCgetspeed_tag {
- U32 LinkSpeedCode;
- } RCgetspeed; /* <---- RCgetspeed */
-
- /* SETSPEED structure */
- struct RCsetspeed_tag {
- U16 LinkSpeedCode;
- } RCsetspeed; /* <---- RCsetspeed */
-
- /* GETPROM structure */
- struct RCgetprom_tag {
- U32 PromMode;
- } RCgetprom; /* <---- RCgetprom */
-
- /* SETPROM structure */
- struct RCsetprom_tag {
- U16 PromMode;
- } RCsetprom; /* <---- RCsetprom */
-
- /* GETBROADCAST structure */
- struct RCgetbroadcast_tag {
- U32 BroadcastMode;
- } RCgetbroadcast; /* <---- RCgetbroadcast */
-
- /* SETBROADCAST structure */
- struct RCsetbroadcast_tag {
- U16 BroadcastMode;
- } RCsetbroadcast; /* <---- RCsetbroadcast */
-
- /* GETFIRMWAREVER structure */
-#define FirmStringLen 80
- struct RCgetfwver_tag {
- U8 FirmString[FirmStringLen];
- } RCgetfwver; /* <---- RCgetfwver */
-
- /* GETIPANDMASK structure */
- struct RCgetipnmask_tag {
- U32 IpAddr;
- U32 NetMask;
- } RCgetipandmask; /* <---- RCgetipandmask */
-
- /* SETIPANDMASK structure */
- struct RCsetipnmask_tag {
- U32 IpAddr;
- U32 NetMask;
- } RCsetipandmask; /* <---- RCsetipandmask */
-
- /* GETMAC structure */
-#define MAC_SIZE 10
- struct RCgetmac_tag {
- U8 mac[MAC_SIZE];
- } RCgetmac; /* <---- RCgetmac */
-
- /* SETMAC structure */
- struct RCsetmac_tag {
- U8 mac[MAC_SIZE];
- } RCsetmac; /* <---- RCsetmac */
-
- /* GETLINKSTATUS structure */
- struct RCgetlnkstatus_tag {
- U32 ReturnStatus;
- } RCgetlnkstatus; /* <---- RCgetlnkstatus */
-
- /* GETLINKSTATISTICS structure */
- struct RCgetlinkstats_tag {
- RCLINKSTATS StatsReturn;
- } RCgetlinkstats; /* <---- RCgetlinkstats */
-
- /* DEFAULT structure (when no command was recognized) */
- struct RCdefault_tag {
- int rc;
- } RCdefault; /* <---- RCdefault */
-
- } data;
-
-}; /* struct RC_user_tag { ... } */
-
-/* 2) User data entry */
-/* RCUD = RedCreek User Data */
-union RC_user_data_tag { /* structure tags used are taken from RC_user_tag structure above */
- struct RCgetinfo_tag *getinfo;
- struct RCgetspeed_tag *getspeed;
- struct RCgetprom_tag *getprom;
- struct RCgetbroadcast_tag *getbroadcast;
- struct RCgetfwver_tag *getfwver;
- struct RCgetipnmask_tag *getipandmask;
- struct RCgetmac_tag *getmac;
- struct RCgetlnkstatus_tag *getlinkstatus;
- struct RCgetlinkstats_tag *getlinkstatistics;
- struct RCdefault_tag *rcdefault;
- struct RCsetspeed_tag *setspeed;
- struct RCsetprom_tag *setprom;
- struct RCsetbroadcast_tag *setbroadcast;
- struct RCsetipnmask_tag *setipandmask;
- struct RCsetmac_tag *setmac;
-} _RC_user_data; /* declare as a global, so the defines below will work */
-
-/* 3) Structure short-cut entry */
-/* define structure short-cuts *//* structure names are taken from RC_user_tag structure above */
-#define RCUS_GETINFO data.RCgetinfo;
-#define RCUS_GETSPEED data.RCgetspeed;
-#define RCUS_GETPROM data.RCgetprom;
-#define RCUS_GETBROADCAST data.RCgetbroadcast;
-#define RCUS_GETFWVER data.RCgetfwver;
-#define RCUS_GETIPANDMASK data.RCgetipandmask;
-#define RCUS_GETMAC data.RCgetmac;
-#define RCUS_GETLINKSTATUS data.RCgetlnkstatus;
-#define RCUS_GETLINKSTATISTICS data.RCgetlinkstats;
-#define RCUS_DEFAULT data.RCdefault;
-#define RCUS_SETSPEED data.RCsetspeed;
-#define RCUS_SETPROM data.RCsetprom;
-#define RCUS_SETBROADCAST data.RCsetbroadcast;
-#define RCUS_SETIPANDMASK data.RCsetipandmask;
-#define RCUS_SETMAC data.RCsetmac;
-
-/* 4) Data short-cut entry */
-/* define data short-cuts *//* pointer names are from RC_user_data_tag union (just below RC_user_tag) */
-#define RCUD_GETINFO _RC_user_data.getinfo
-#define RCUD_GETSPEED _RC_user_data.getspeed
-#define RCUD_GETPROM _RC_user_data.getprom
-#define RCUD_GETBROADCAST _RC_user_data.getbroadcast
-#define RCUD_GETFWVER _RC_user_data.getfwver
-#define RCUD_GETIPANDMASK _RC_user_data.getipandmask
-#define RCUD_GETMAC _RC_user_data.getmac
-#define RCUD_GETLINKSTATUS _RC_user_data.getlinkstatus
-#define RCUD_GETLINKSTATISTICS _RC_user_data.getlinkstatistics
-#define RCUD_DEFAULT _RC_user_data.rcdefault
-#define RCUD_SETSPEED _RC_user_data.setspeed
-#define RCUD_SETPROM _RC_user_data.setprom
-#define RCUD_SETBROADCAST _RC_user_data.setbroadcast
-#define RCUD_SETIPANDMASK _RC_user_data.setipandmask
-#define RCUD_SETMAC _RC_user_data.setmac
-
-/* 5) Command identifier entry */
-/* define command identifiers */
-#define RCUC_GETINFO 0x01
-#define RCUC_GETSPEED 0x02
-#define RCUC_GETFWVER 0x03
-#define RCUC_GETIPANDMASK 0x04
-#define RCUC_GETMAC 0x05
-#define RCUC_GETLINKSTATUS 0x06
-#define RCUC_GETLINKSTATISTICS 0x07
-#define RCUC_GETPROM 0x14
-#define RCUC_GETBROADCAST 0x15
-#define RCUC_DEFAULT 0xff
-#define RCUC_SETSPEED 0x08
-#define RCUC_SETIPANDMASK 0x09
-#define RCUC_SETMAC 0x0a
-#define RCUC_SETPROM 0x16
-#define RCUC_SETBROADCAST 0x17
-
-/* define ioctl commands to use, when talking to RC 45/PCI driver */
-#define RCU_PROTOCOL_REV SIOCDEVPRIVATE
-#define RCU_COMMAND SIOCDEVPRIVATE+1
-
-/*
- Intended use for the above defines is shown below (GETINFO, as this example):
-
- RCuser_struct RCuser; // declare RCuser structure
- struct ifreq ifr; // declare an interface request structure
-
- RCuser.cmd = RCUC_GETINFO; // set user command to GETINFO
- ifr->ifr_data = (caddr_t) &RCuser; // set point to user structure
-
- sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); // get a socket
- ioctl(sock, RCU_COMMAND, &ifr); // do ioctl on socket
-
- RCUD_GETINFO = &RCuser.RCUS_GETINFO; // set data pointer for GETINFO
-
- // print results
- printf("memory 0x%lx-0x%lx, base address 0x%x, irq 0x%x\n",
- RCUD_GETINFO->mem_start, RCUD_GETINFO->mem_end,
- RCUD_GETINFO->base_addr, RCUD_GETINFO->irq);
-*/
-
-#endif /* RCIF_H */
+++ /dev/null
-/*
-** *************************************************************************
-**
-**
-** R C L A N M T L . C $Revision: 6 $
-**
-**
-** RedCreek I2O LAN Message Transport Layer program module.
-**
-** ---------------------------------------------------------------------
-** --- Copyright (c) 1997-1999, RedCreek Communications Inc. ---
-** --- All rights reserved. ---
-** ---------------------------------------------------------------------
-**
-** File Description:
-**
-** Host side I2O (Intelligent I/O) LAN message transport layer.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** 1998-1999, LAN API was modified and enhanced by Alice Hennessy.
-**
-** Sometime in 1997, LAN API was written from scratch by Wendell Nichols.
-** *************************************************************************
-*/
-
-#define DEBUG 1
-
-#define RC_LINUX_MODULE
-#include "rclanmtl.h"
-
- /* RedCreek LAN device Target ID */
-#define RC_LAN_TARGET_ID 0x10
- /* RedCreek's OSM default LAN receive Initiator */
-#define DEFAULT_RECV_INIT_CONTEXT 0xA17
-
-/*
-** I2O message structures
-*/
-
-#define I2O_TID_SZ 12
-#define I2O_FUNCTION_SZ 8
-
-/* Transaction Reply Lists (TRL) Control Word structure */
-
-#define I2O_TRL_FLAGS_SINGLE_FIXED_LENGTH 0x00
-#define I2O_TRL_FLAGS_SINGLE_VARIABLE_LENGTH 0x40
-#define I2O_TRL_FLAGS_MULTIPLE_FIXED_LENGTH 0x80
-
-/* LAN Class specific functions */
-
-#define I2O_LAN_PACKET_SEND 0x3B
-#define I2O_LAN_SDU_SEND 0x3D
-#define I2O_LAN_RECEIVE_POST 0x3E
-#define I2O_LAN_RESET 0x35
-#define I2O_LAN_SHUTDOWN 0x37
-
-/* Private Class specfic function */
-#define I2O_PRIVATE 0xFF
-
-/* I2O Executive Function Codes. */
-
-#define I2O_EXEC_ADAPTER_ASSIGN 0xB3
-#define I2O_EXEC_ADAPTER_READ 0xB2
-#define I2O_EXEC_ADAPTER_RELEASE 0xB5
-#define I2O_EXEC_BIOS_INFO_SET 0xA5
-#define I2O_EXEC_BOOT_DEVICE_SET 0xA7
-#define I2O_EXEC_CONFIG_VALIDATE 0xBB
-#define I2O_EXEC_CONN_SETUP 0xCA
-#define I2O_EXEC_DEVICE_ASSIGN 0xB7
-#define I2O_EXEC_DEVICE_RELEASE 0xB9
-#define I2O_EXEC_HRT_GET 0xA8
-#define I2O_EXEC_IOP_CLEAR 0xBE
-#define I2O_EXEC_IOP_CONNECT 0xC9
-#define I2O_EXEC_IOP_RESET 0xBD
-#define I2O_EXEC_LCT_NOTIFY 0xA2
-#define I2O_EXEC_OUTBOUND_INIT 0xA1
-#define I2O_EXEC_PATH_ENABLE 0xD3
-#define I2O_EXEC_PATH_QUIESCE 0xC5
-#define I2O_EXEC_PATH_RESET 0xD7
-#define I2O_EXEC_STATIC_MF_CREATE 0xDD
-#define I2O_EXEC_STATIC_MF_RELEASE 0xDF
-#define I2O_EXEC_STATUS_GET 0xA0
-#define I2O_EXEC_SW_DOWNLOAD 0xA9
-#define I2O_EXEC_SW_UPLOAD 0xAB
-#define I2O_EXEC_SW_REMOVE 0xAD
-#define I2O_EXEC_SYS_ENABLE 0xD1
-#define I2O_EXEC_SYS_MODIFY 0xC1
-#define I2O_EXEC_SYS_QUIESCE 0xC3
-#define I2O_EXEC_SYS_TAB_SET 0xA3
-
- /* Init Outbound Q status */
-#define I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS 0x01
-#define I2O_EXEC_OUTBOUND_INIT_REJECTED 0x02
-#define I2O_EXEC_OUTBOUND_INIT_FAILED 0x03
-#define I2O_EXEC_OUTBOUND_INIT_COMPLETE 0x04
-
-#define I2O_UTIL_NOP 0x00
-
-/* I2O Get Status State values */
-
-#define I2O_IOP_STATE_INITIALIZING 0x01
-#define I2O_IOP_STATE_RESET 0x02
-#define I2O_IOP_STATE_HOLD 0x04
-#define I2O_IOP_STATE_READY 0x05
-#define I2O_IOP_STATE_OPERATIONAL 0x08
-#define I2O_IOP_STATE_FAILED 0x10
-#define I2O_IOP_STATE_FAULTED 0x11
-
-/* Defines for Request Status Codes: Table 3-1 Reply Status Codes. */
-
-#define I2O_REPLY_STATUS_SUCCESS 0x00
-#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
-#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
-#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
-#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
-#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
-#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
-#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x07
-#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x08
-#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x09
-#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0A
-#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
-
-/* DetailedStatusCode defines for ALL messages: Table 3-2 Detailed Status Codes.*/
-
-#define I2O_DETAIL_STATUS_SUCCESS 0x0000
-#define I2O_DETAIL_STATUS_BAD_KEY 0x0001
-#define I2O_DETAIL_STATUS_CHAIN_BUFFER_TOO_LARGE 0x0002
-#define I2O_DETAIL_STATUS_DEVICE_BUSY 0x0003
-#define I2O_DETAIL_STATUS_DEVICE_LOCKED 0x0004
-#define I2O_DETAIL_STATUS_DEVICE_NOT_AVAILABLE 0x0005
-#define I2O_DETAIL_STATUS_DEVICE_RESET 0x0006
-#define I2O_DETAIL_STATUS_INAPPROPRIATE_FUNCTION 0x0007
-#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_HARD 0x0008
-#define I2O_DETAIL_STATUS_INSUFFICIENT_RESOURCE_SOFT 0x0009
-#define I2O_DETAIL_STATUS_INVALID_INITIATOR_ADDRESS 0x000A
-#define I2O_DETAIL_STATUS_INVALID_MESSAGE_FLAGS 0x000B
-#define I2O_DETAIL_STATUS_INVALID_OFFSET 0x000C
-#define I2O_DETAIL_STATUS_INVALID_PARAMETER 0x000D
-#define I2O_DETAIL_STATUS_INVALID_REQUEST 0x000E
-#define I2O_DETAIL_STATUS_INVALID_TARGET_ADDRESS 0x000F
-#define I2O_DETAIL_STATUS_MESSAGE_TOO_LARGE 0x0010
-#define I2O_DETAIL_STATUS_MESSAGE_TOO_SMALL 0x0011
-#define I2O_DETAIL_STATUS_MISSING_PARAMETER 0x0012
-#define I2O_DETAIL_STATUS_NO_SUCH_PAGE 0x0013
-#define I2O_DETAIL_STATUS_REPLY_BUFFER_FULL 0x0014
-#define I2O_DETAIL_STATUS_TCL_ERROR 0x0015
-#define I2O_DETAIL_STATUS_TIMEOUT 0x0016
-#define I2O_DETAIL_STATUS_UNKNOWN_ERROR 0x0017
-#define I2O_DETAIL_STATUS_UNKNOWN_FUNCTION 0x0018
-#define I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION 0x0019
-#define I2O_DETAIL_STATUS_UNSUPPORTED_VERSION 0x001A
-
- /* I2O msg header defines for VersionOffset */
-#define I2OMSGVER_1_5 0x0001
-#define SGL_OFFSET_0 I2OMSGVER_1_5
-#define SGL_OFFSET_4 (0x0040 | I2OMSGVER_1_5)
-#define TRL_OFFSET_5 (0x0050 | I2OMSGVER_1_5)
-#define TRL_OFFSET_6 (0x0060 | I2OMSGVER_1_5)
-
- /* I2O msg header defines for MsgFlags */
-#define MSG_STATIC 0x0100
-#define MSG_64BIT_CNTXT 0x0200
-#define MSG_MULTI_TRANS 0x1000
-#define MSG_FAIL 0x2000
-#define MSG_LAST 0x4000
-#define MSG_REPLY 0x8000
-
- /* normal LAN request message MsgFlags and VersionOffset (0x1041) */
-#define LAN_MSG_REQST (MSG_MULTI_TRANS | SGL_OFFSET_4)
-
- /* minimum size msg */
-#define THREE_WORD_MSG_SIZE 0x00030000
-#define FOUR_WORD_MSG_SIZE 0x00040000
-#define FIVE_WORD_MSG_SIZE 0x00050000
-#define SIX_WORD_MSG_SIZE 0x00060000
-#define SEVEN_WORD_MSG_SIZE 0x00070000
-#define EIGHT_WORD_MSG_SIZE 0x00080000
-#define NINE_WORD_MSG_SIZE 0x00090000
-
-/* Special TID Assignments */
-
-#define I2O_IOP_TID 0
-#define I2O_HOST_TID 0xB91
-
- /* RedCreek I2O private message codes */
-#define RC_PRIVATE_GET_MAC_ADDR 0x0001/**/ /* OBSOLETE */
-#define RC_PRIVATE_SET_MAC_ADDR 0x0002
-#define RC_PRIVATE_GET_NIC_STATS 0x0003
-#define RC_PRIVATE_GET_LINK_STATUS 0x0004
-#define RC_PRIVATE_SET_LINK_SPEED 0x0005
-#define RC_PRIVATE_SET_IP_AND_MASK 0x0006
-/* #define RC_PRIVATE_GET_IP_AND_MASK 0x0007 *//* OBSOLETE */
-#define RC_PRIVATE_GET_LINK_SPEED 0x0008
-#define RC_PRIVATE_GET_FIRMWARE_REV 0x0009
-/* #define RC_PRIVATE_GET_MAC_ADDR 0x000A */
-#define RC_PRIVATE_GET_IP_AND_MASK 0x000B
-#define RC_PRIVATE_DEBUG_MSG 0x000C
-#define RC_PRIVATE_REPORT_DRIVER_CAPABILITY 0x000D
-#define RC_PRIVATE_SET_PROMISCUOUS_MODE 0x000e
-#define RC_PRIVATE_GET_PROMISCUOUS_MODE 0x000f
-#define RC_PRIVATE_SET_BROADCAST_MODE 0x0010
-#define RC_PRIVATE_GET_BROADCAST_MODE 0x0011
-
-#define RC_PRIVATE_REBOOT 0x00FF
-
-/* I2O message header */
-typedef struct _I2O_MESSAGE_FRAME {
- U8 VersionOffset;
- U8 MsgFlags;
- U16 MessageSize;
- BF TargetAddress:I2O_TID_SZ;
- BF InitiatorAddress:I2O_TID_SZ;
- BF Function:I2O_FUNCTION_SZ;
- U32 InitiatorContext;
- /* SGL[] */
-} I2O_MESSAGE_FRAME, *PI2O_MESSAGE_FRAME;
-
- /* assumed a 16K minus 256 byte space for outbound queue message frames */
-#define MSG_FRAME_SIZE 512
-#define NMBR_MSG_FRAMES 30
-
- /*
- ** in reserved space right after PAB in host memory is area for returning
- ** values from card
- */
-
-/*
-** typedef NICSTAT
-**
-** Data structure for NIC statistics retruned from PCI card. Data copied from
-** here to user allocated RCLINKSTATS (see rclanmtl.h) structure.
-*/
-typedef struct tag_NicStat {
- unsigned long TX_good;
- unsigned long TX_maxcol;
- unsigned long TX_latecol;
- unsigned long TX_urun;
- unsigned long TX_crs; /* lost carrier sense */
- unsigned long TX_def; /* transmit deferred */
- unsigned long TX_singlecol; /* single collisions */
- unsigned long TX_multcol;
- unsigned long TX_totcol;
- unsigned long Rcv_good;
- unsigned long Rcv_CRCerr;
- unsigned long Rcv_alignerr;
- unsigned long Rcv_reserr; /* rnr'd pkts */
- unsigned long Rcv_orun;
- unsigned long Rcv_cdt;
- unsigned long Rcv_runt;
- unsigned long dump_status; /* last field directly from the chip */
-} NICSTAT, *P_NICSTAT;
-
-#define DUMP_DONE 0x0000A005 /* completed statistical dump */
-#define DUMP_CLEAR 0x0000A007 /* completed stat dump and clear counters */
-
-static volatile int msgFlag;
-
-/* local function prototypes */
-static void ProcessOutboundI2OMsg (PPAB pPab, U32 phyMsgAddr);
-static int FillI2OMsgSGLFromTCB (PU32 pMsg, PRCTCB pXmitCntrlBlock);
-static int GetI2OStatus (PPAB pPab);
-static int SendI2OOutboundQInitMsg (PPAB pPab);
-static int SendEnableSysMsg (PPAB pPab);
-
-/*
-** =========================================================================
-** RCInitI2OMsgLayer()
-**
-** Initialize the RedCreek I2O Module and adapter.
-**
-** Inputs: dev - the devices net_device struct
-** TransmitCallbackFunction - address of transmit callback function
-** ReceiveCallbackFunction - address of receive callback function
-**
-** private message block is allocated by user. It must be in locked pages.
-** p_msgbuf and p_phymsgbuf point to the same location. Must be contigous
-** memory block of a minimum of 16K byte and long word aligned.
-** =========================================================================
-*/
-RC_RETURN
-RCInitI2OMsgLayer (struct net_device *dev,
- PFNTXCALLBACK TransmitCallbackFunction,
- PFNRXCALLBACK ReceiveCallbackFunction,
- PFNCALLBACK RebootCallbackFunction)
-{
- int result;
- PPAB pPab;
- U32 pciBaseAddr = dev->base_addr;
- PDPA pDpa = dev->priv;
- PU8 p_msgbuf = pDpa->msgbuf;
- PU8 p_phymsgbuf = (PU8) pDpa->msgbuf_dma;
-
- dprintk
- ("InitI2O: Adapter:0x%04ux ATU:0x%08ulx msgbuf:%p phymsgbuf:0x%08ulx\n"
- "TransmitCallbackFunction:0x%08ulx ReceiveCallbackFunction:0x%08ulx\n",
- pDpa->id, pciBaseAddr, p_msgbuf, (u32) p_phymsgbuf,
- (u32) TransmitCallbackFunction, (u32) ReceiveCallbackFunction);
-
- /* Check if this interface already initialized - if so, shut it down */
- if (pDpa->pPab != NULL) {
- printk (KERN_WARNING
- "(rcpci45 driver:) pDpa->pPab [%d] != NULL\n",
- pDpa->id);
-/* RCResetLANCard(pDpa->id, 0, (PU32)NULL, (PFNCALLBACK)NULL); */
- pDpa->pPab = NULL;
- }
-
- /* store adapter instance values in adapter block.
- * Adapter block is at beginning of message buffer */
-
- pPab = kmalloc (sizeof (*pPab), GFP_KERNEL);
- if (!pPab) {
- printk (KERN_ERR
- "(rcpci45 driver:) RCInitI2OMsgLayer: Could not allocate memory for PAB struct!\n");
- result = RC_RTN_MALLOC_ERROR;
- goto err_out;
- }
-
- memset (pPab, 0, sizeof (*pPab));
- pDpa->pPab = pPab;
- pPab->p_atu = (PATU) pciBaseAddr;
- pPab->pPci45LinBaseAddr = (PU8) pciBaseAddr;
-
- /* Set outbound message frame addr */
- pPab->outMsgBlockPhyAddr = (U32) p_phymsgbuf;
- pPab->pLinOutMsgBlock = (PU8) p_msgbuf;
-
- /* store callback function addresses */
- pPab->pTransCallbackFunc = TransmitCallbackFunction;
- pPab->pRecvCallbackFunc = ReceiveCallbackFunction;
- pPab->pRebootCallbackFunc = RebootCallbackFunction;
- pPab->pCallbackFunc = (PFNCALLBACK) NULL;
-
- /*
- ** Initialize I2O IOP
- */
- result = GetI2OStatus (pPab);
-
- if (result != RC_RTN_NO_ERROR)
- goto err_out_dealloc;
-
- if (pPab->IOPState == I2O_IOP_STATE_OPERATIONAL) {
- printk (KERN_INFO
- "(rcpci45 driver:) pPab->IOPState == op: resetting adapter\n");
- RCResetLANCard (dev, 0, (PU32) NULL, (PFNCALLBACK) NULL);
- }
-
- result = SendI2OOutboundQInitMsg (pPab);
-
- if (result != RC_RTN_NO_ERROR)
- goto err_out_dealloc;
-
- result = SendEnableSysMsg (pPab);
-
- if (result != RC_RTN_NO_ERROR)
- goto err_out_dealloc;
-
- return RC_RTN_NO_ERROR;
-
- err_out_dealloc:
- kfree (pPab);
- err_out:
- return result;
-}
-
-/*
-** =========================================================================
-** Disable and Enable I2O interrupts. I2O interrupts are enabled at Init time
-** but can be disabled and re-enabled through these two function calls.
-** Packets will still be put into any posted received buffers and packets will
-** be sent through RCI2OSendPacket() functions. Disabling I2O interrupts
-** will prevent hardware interrupt to host even though the outbound I2O msg
-** queue is not emtpy.
-** =========================================================================
-*/
-#define i960_OUT_POST_Q_INT_BIT 0x0008 /* bit set masks interrupts */
-
-RC_RETURN
-RCDisableI2OInterrupts (struct net_device * dev)
-{
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- pPab->p_atu->OutIntMask |= i960_OUT_POST_Q_INT_BIT;
-
- return RC_RTN_NO_ERROR;
-}
-
-RC_RETURN
-RCEnableI2OInterrupts (struct net_device * dev)
-{
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- pPab->p_atu->OutIntMask &= ~i960_OUT_POST_Q_INT_BIT;
-
- return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCI2OSendPacket()
-** =========================================================================
-*/
-RC_RETURN
-RCI2OSendPacket (struct net_device * dev, U32 InitiatorContext,
- PRCTCB pTransCtrlBlock)
-{
- U32 msgOffset;
- PU32 pMsg;
- int size;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- dprintk ("RCI2OSendPacket()...\n");
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- /* get Inbound free Q entry - reading from In Q gets free Q entry */
- /* offset to Msg Frame in PCI msg block */
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("RCI2OSendPacket(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
-
- if (size == -1) { /* error processing TCB - send NOP msg */
- dprintk ("RCI2OSendPacket(): Error Rrocess TCB!\n");
- pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] =
- I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- return RC_RTN_TCB_ERROR;
- } else { /* send over msg header */
-
- pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST; /* send over message size and flags */
- pMsg[1] =
- I2O_LAN_PACKET_SEND << 24 | I2O_HOST_TID << 12 |
- RC_LAN_TARGET_ID;
- pMsg[2] = InitiatorContext;
- pMsg[3] = 0; /* batch reply */
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
- return RC_RTN_NO_ERROR;
- }
-}
-
-/*
-** =========================================================================
-** RCI2OPostRecvBuffer()
-**
-** inputs: pBufrCntrlBlock - pointer to buffer control block
-**
-** returns TRUE if successful in sending message, else FALSE.
-** =========================================================================
-*/
-RC_RETURN
-RCPostRecvBuffers (struct net_device * dev, PRCTCB pTransCtrlBlock)
-{
- U32 msgOffset;
- PU32 pMsg;
- int size;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- dprintk ("RCPostRecvBuffers()...\n");
-
- /* search for DeviceHandle */
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- /* get Inbound free Q entry - reading from In Q gets free Q entry */
- /* offset to Msg Frame in PCI msg block */
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("RCPostRecvBuffers(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- size = FillI2OMsgSGLFromTCB (pMsg + 4, pTransCtrlBlock);
-
- if (size == -1) { /* error prcessing TCB - send 3 DWORD private msg == NOP */
- dprintk
- ("RCPostRecvBuffers(): Error Processing TCB! size = %d\n",
- size);
- pMsg[0] = THREE_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] =
- I2O_UTIL_NOP << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- /* post to Post Q */
- pPab->p_atu->InQueue = msgOffset;
- return RC_RTN_TCB_ERROR;
- } else { /* send over size msg header */
-
- pMsg[0] = (size + 4) << 16 | LAN_MSG_REQST; /* send over message size and flags */
- pMsg[1] =
- I2O_LAN_RECEIVE_POST << 24 | I2O_HOST_TID << 12 |
- RC_LAN_TARGET_ID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = *(PU32) pTransCtrlBlock; /* number of packet buffers */
- /* post to Post Q */
- pPab->p_atu->InQueue = msgOffset;
- return RC_RTN_NO_ERROR;
- }
-}
-
-/*
-** =========================================================================
-** RCProcI2OMsgQ()
-**
-** Process I2O outbound message queue until empty.
-** =========================================================================
-*/
-irqreturn_t
-RCProcI2OMsgQ (struct net_device *dev)
-{
- U32 phyAddrMsg;
- PU8 p8Msg;
- PU32 p32;
- U16 count;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- unsigned char debug_msg[20];
-
- if (pPab == NULL)
- return IRQ_NONE;
-
- phyAddrMsg = pPab->p_atu->OutQueue;
-
- while (phyAddrMsg != 0xFFFFFFFF) {
- p8Msg =
- pPab->pLinOutMsgBlock + (phyAddrMsg -
- pPab->outMsgBlockPhyAddr);
- p32 = (PU32) p8Msg;
-
- dprintk ("msg: 0x%x 0x%x \n", p8Msg[7], p32[5]);
-
- /* Send Packet Reply Msg */
- if (I2O_LAN_PACKET_SEND == p8Msg[7]) { /* function code byte */
- count = *(PU16) (p8Msg + 2);
- count -= p8Msg[0] >> 4;
- /* status, count, context[], adapter */
- (*pPab->pTransCallbackFunc) (p8Msg[19], count, p32 + 5,
- dev);
- } else if (I2O_LAN_RECEIVE_POST == p8Msg[7]) { /* Receive Packet Reply Msg */
- dprintk
- ("I2O_RECV_REPLY pPab:0x%08ulx p8Msg:0x%08ulx p32:0x%08ulx\n",
- (u32) pPab, (u32) p8Msg, (u32) p32);
- dprintk ("msg: 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- p32[0], p32[1], p32[2], p32[3]);
- dprintk (" 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- p32[4], p32[5], p32[6], p32[7]);
- dprintk (" 0x%08ulx:0X%08ulx:0x%08ulx:0x%08ulx\n",
- p32[8], p32[9], p32[10], p32[11]);
- /* status, count, buckets remaining, packetParmBlock, adapter */
- (*pPab->pRecvCallbackFunc) (p8Msg[19], p8Msg[12],
- p32[5], p32 + 6, dev);
- } else if (I2O_LAN_RESET == p8Msg[7]
- || I2O_LAN_SHUTDOWN == p8Msg[7])
- if (pPab->pCallbackFunc)
- (*pPab->pCallbackFunc) (p8Msg[19], 0, 0, dev);
- else
- pPab->pCallbackFunc = (PFNCALLBACK) 1;
- else if (I2O_PRIVATE == p8Msg[7]) {
- dprintk ("i2o private 0x%x, 0x%x \n", p8Msg[7], p32[5]);
- switch (p32[5]) {
- case RC_PRIVATE_DEBUG_MSG:
- msgFlag = 1;
- dprintk ("Received I2O_PRIVATE msg\n");
- debug_msg[15] = (p32[6] & 0xff000000) >> 24;
- debug_msg[14] = (p32[6] & 0x00ff0000) >> 16;
- debug_msg[13] = (p32[6] & 0x0000ff00) >> 8;
- debug_msg[12] = (p32[6] & 0x000000ff);
-
- debug_msg[11] = (p32[7] & 0xff000000) >> 24;
- debug_msg[10] = (p32[7] & 0x00ff0000) >> 16;
- debug_msg[9] = (p32[7] & 0x0000ff00) >> 8;
- debug_msg[8] = (p32[7] & 0x000000ff);
-
- debug_msg[7] = (p32[8] & 0xff000000) >> 24;
- debug_msg[6] = (p32[8] & 0x00ff0000) >> 16;
- debug_msg[5] = (p32[8] & 0x0000ff00) >> 8;
- debug_msg[4] = (p32[8] & 0x000000ff);
-
- debug_msg[3] = (p32[9] & 0xff000000) >> 24;
- debug_msg[2] = (p32[9] & 0x00ff0000) >> 16;
- debug_msg[1] = (p32[9] & 0x0000ff00) >> 8;
- debug_msg[0] = (p32[9] & 0x000000ff);
-
- debug_msg[16] = '\0';
- dprintk ("%s", debug_msg);
- break;
- case RC_PRIVATE_REBOOT:
- dprintk ("Adapter reboot initiated...\n");
- if (pPab->pRebootCallbackFunc)
- (*pPab->pRebootCallbackFunc) (0, 0, 0,
- dev);
- break;
- default:
- printk (KERN_WARNING
- "(rcpci45 driver:) Unknown private I2O msg received: 0x%x\n",
- p32[5]);
- break;
- }
- }
-
- /*
- ** Process other Msg's
- */
- else
- ProcessOutboundI2OMsg (pPab, phyAddrMsg);
-
- /* return MFA to outbound free Q */
- pPab->p_atu->OutQueue = phyAddrMsg;
-
- /* any more msgs? */
- phyAddrMsg = pPab->p_atu->OutQueue;
- }
-
- return IRQ_HANDLED;
-}
-
-/*
-** =========================================================================
-** Returns LAN interface statistical counters to space provided by caller at
-** StatsReturnAddr. Returns 0 if success, else RC_RETURN code.
-** This function will call the WaitCallback function provided by
-** user while waiting for card to respond.
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkStatistics (struct net_device *dev,
- P_RCLINKSTATS StatsReturnAddr,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset;
- volatile U32 timeout;
- volatile PU32 pMsg;
- volatile PU32 p32, pReturnAddr;
- P_NICSTAT pStats;
- int i;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
-/*dprintk("Get82558Stats() StatsReturnAddr:0x%08ulx\n", StatsReturnAddr); */
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("Get8255XStats(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
-/*dprintk("Get82558Stats - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintk("Get82558Stats - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
-
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = 0x112; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_NIC_STATS;
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- p32 = (PU32) pPab->outMsgBlockPhyAddr;
- pStats = (P_NICSTAT) pPab->pLinOutMsgBlock;
- pStats->dump_status = 0xFFFFFFFF;
-
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
-
- timeout = 100000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10);
-
- if (pStats->dump_status != 0xFFFFFFFF)
- break;
-
- if (!timeout--) {
- dprintk
- ("RCGet82558Stats() Timeout waiting for NIC statistics\n");
- return RC_RTN_MSG_REPLY_TIMEOUT;
- }
- }
-
- pReturnAddr = (PU32) StatsReturnAddr;
-
- /* copy Nic stats to user's structure */
- for (i = 0; i < (int) sizeof (RCLINKSTATS) / 4; i++)
- pReturnAddr[i] = p32[i];
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** Get82558LinkStatus()
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkStatus (struct net_device * dev, PU32 ReturnAddr,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset;
- volatile U32 timeout;
- volatile PU32 pMsg;
- volatile PU32 p32;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- dprintk ("Get82558LinkStatus() ReturnPhysAddr:0x%08ulx\n",
- (u32) ReturnAddr);
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("Get82558LinkStatus(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-/*dprintk("Get82558LinkStatus - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n", pMsg, msgOffset);*/
-/*dprintk("Get82558LinkStatus - pMsg = 0x%08X, InQ msgOffset = 0x%08X\n", pMsg, msgOffset);*/
-
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = 0x112; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_STATUS;
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- p32 = (PU32) pPab->pLinOutMsgBlock;
- *p32 = 0xFFFFFFFF;
-
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
-
- timeout = 100000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10);
-
- if (*p32 != 0xFFFFFFFF)
- break;
-
- if (!timeout--) {
- dprintk ("Timeout waiting for link status\n");
- return RC_RTN_MSG_REPLY_TIMEOUT;
- }
- }
-
- *ReturnAddr = *p32; /* 1 = up 0 = down */
-
- return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCGetMAC()
-**
-** get the MAC address the adapter is listening for in non-promiscous mode.
-** MAC address is in media format.
-** =========================================================================
-*/
-RC_RETURN
-RCGetMAC (struct net_device * dev, PFNWAITCALLBACK WaitCallback)
-{
- unsigned timeout;
- U32 off;
- PU8 mac = dev->dev_addr;
- PU32 p;
- U32 temp[2];
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- PATU p_atu;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- p_atu = pPab->p_atu;
-
- p_atu->EtherMacLow = 0; /* first zero return data */
- p_atu->EtherMacHi = 0;
-
- off = p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- p = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- dprintk ("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
- (uint) p_atu, (uint) off, (uint) p);
- /* setup private message */
- p[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
- p[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- p[2] = 0; /* initiator context */
- p[3] = 0x218; /* transaction context */
- p[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_MAC_ADDR;
-
- p_atu->InQueue = off; /* send it to the I2O device */
- dprintk ("RCGetMAC: p_atu 0x%08x, off 0x%08x, p 0x%08x\n",
- (uint) p_atu, (uint) off, (uint) p);
-
- /* wait for the rcpci45 board to update the info */
- timeout = 1000000;
- while (0 == p_atu->EtherMacLow) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10);
-
- if (!timeout--) {
- printk ("rc_getmac: Timeout\n");
- return RC_RTN_MSG_REPLY_TIMEOUT;
- }
- }
-
- /* read the mac address */
- temp[0] = p_atu->EtherMacLow;
- temp[1] = p_atu->EtherMacHi;
- memcpy ((char *) mac, (char *) temp, 6);
-
- dprintk ("rc_getmac: 0x%x\n", (u32) mac);
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetMAC()
-**
-** set MAC address the adapter is listening for in non-promiscous mode.
-** MAC address is in media format.
-** =========================================================================
-*/
-RC_RETURN
-RCSetMAC (struct net_device * dev, PU8 mac)
-{
- U32 off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_MAC_ADDR;
- pMsg[5] = *(unsigned *) mac; /* first four bytes */
- pMsg[6] = *(unsigned *) (mac + 4); /* last two bytes */
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetLinkSpeed()
-**
-** set ethernet link speed.
-** input: speedControl - determines action to take as follows
-** 0 = reset and auto-negotiate (NWay)
-** 1 = Full Duplex 100BaseT
-** 2 = Half duplex 100BaseT
-** 3 = Full Duplex 10BaseT
-** 4 = Half duplex 10BaseT
-** all other values are ignore (do nothing)
-** =========================================================================
-*/
-RC_RETURN
-RCSetLinkSpeed (struct net_device * dev, U16 LinkSpeedCode)
-{
- U32 off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_LINK_SPEED;
- pMsg[5] = LinkSpeedCode; /* link speed code */
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetPromiscuousMode()
-**
-** Defined values for Mode:
-** 0 - turn off promiscuous mode
-** 1 - turn on promiscuous mode
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetPromiscuousMode (struct net_device * dev, U16 Mode)
-{
- U32 off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_PROMISCUOUS_MODE;
- pMsg[5] = Mode; /* promiscuous mode setting */
-
- pPab->p_atu->InQueue = off; /* send it to the device */
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetPromiscuousMode()
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-** 0 = promisuous mode not set
-** 1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetPromiscuousMode (struct net_device * dev, PU32 pMode,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- volatile PU32 p32;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- printk (KERN_WARNING
- "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0xff;
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_PROMISCUOUS_MODE;
- /* phys address to return status - area right after PAB */
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- /* post to Inbound Post Q */
-
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] != 0xff)
- break;
-
- if (!timeout--) {
- dprintk
- ("Timeout waiting for promiscuous mode from adapter\n");
- dprintk ("0x%8x\n", p32[0]);
- return RC_RTN_NO_LINK_SPEED;
- }
- }
-
- /* get mode */
- *pMode = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetBroadcastMode()
-**
-** Defined values for Mode:
-** 0 - turn off promiscuous mode
-** 1 - turn on promiscuous mode
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetBroadcastMode (struct net_device * dev, U16 Mode)
-{
- U32 off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_BROADCAST_MODE;
- pMsg[5] = Mode; /* promiscuous mode setting */
-
- pPab->p_atu->InQueue = off; /* send it to the device */
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetBroadcastMode()
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-** 0 = promisuous mode not set
-** 1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetBroadcastMode (struct net_device * dev, PU32 pMode,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- volatile PU32 p32;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- printk (KERN_WARNING
- "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0xff;
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_BROADCAST_MODE;
- /* phys address to return status - area right after PAB */
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- /* post to Inbound Post Q */
-
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] != 0xff)
- break;
-
- if (!timeout--) {
- printk (KERN_WARNING
- "(rcpci45 driver:) Timeout waiting for promiscuous mode from adapter\n");
- printk (KERN_WARNING "(rcpci45 driver:) 0x%8x\n",
- p32[0]);
- return RC_RTN_NO_LINK_SPEED;
- }
- }
-
- /* get mode */
- *pMode = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetLinkSpeed()
-**
-** get ethernet link speed.
-**
-** 0 = Unknown
-** 1 = Full Duplex 100BaseT
-** 2 = Half duplex 100BaseT
-** 3 = Full Duplex 10BaseT
-** 4 = Half duplex 10BaseT
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetLinkSpeed (struct net_device * dev, PU32 pLinkSpeedCode,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- volatile PU32 p32;
- U8 IOPLinkSpeed;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- printk (KERN_WARNING
- "(rcpci45 driver:) RCGetLinkSpeed(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0xff;
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_LINK_SPEED;
- /* phys address to return status - area right after PAB */
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- /* post to Inbound Post Q */
-
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] != 0xff)
- break;
-
- if (!timeout--) {
- dprintk ("Timeout waiting for link speed from IOP\n");
- dprintk ("0x%8x\n", p32[0]);
- return RC_RTN_NO_LINK_SPEED;
- }
- }
-
- /* get Link speed */
- IOPLinkSpeed = (U8) ((volatile PU8) p32)[0] & 0x0f;
-
- *pLinkSpeedCode = IOPLinkSpeed;
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCReportDriverCapability(struct net_device *dev, U32 capability)
-**
-** Currently defined bits:
-** WARM_REBOOT_CAPABLE 0x01
-**
-** =========================================================================
-*/
-RC_RETURN
-RCReportDriverCapability (struct net_device * dev, U32 capability)
-{
- U32 off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] =
- RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_REPORT_DRIVER_CAPABILITY;
- pMsg[5] = capability;
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCGetFirmwareVer()
-**
-** Return firmware version in the form "SoftwareVersion : Bt BootVersion"
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetFirmwareVer (struct net_device * dev, PU8 pFirmString,
- PFNWAITCALLBACK WaitCallback)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- volatile PU32 p32;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- msgOffset = pPab->p_atu->InQueue;
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("RCGetFirmwareVer(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0xff;
-
- /* setup private message */
- pMsg[0] = SIX_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_FIRMWARE_REV;
- /* phys address to return status - area right after PAB */
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- /* post to Inbound Post Q */
-
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] != 0xff)
- break;
-
- if (!timeout--) {
- dprintk ("Timeout waiting for link speed from IOP\n");
- return RC_RTN_NO_FIRM_VER;
- }
- }
-
- strcpy (pFirmString, (PU8) p32);
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCResetLANCard()
-**
-** ResourceFlags indicates whether to return buffer resource explicitly
-** to host or keep and reuse.
-** CallbackFunction (if not NULL) is the function to be called when
-** reset is complete.
-** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
-** reset is done (if not NULL).
-**
-** =========================================================================
-*/
-RC_RETURN
-RCResetLANCard (struct net_device * dev, U16 ResourceFlags, PU32 ReturnAddr,
- PFNCALLBACK CallbackFunction)
-{
- unsigned long off;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- long timeout = 0;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pPab->pCallbackFunc = CallbackFunction;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup message */
- pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_LAN_RESET << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = ResourceFlags << 16; /* resource flags */
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
-
- if (CallbackFunction == (PFNCALLBACK) NULL) {
- /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
- or until timer goes off */
- while (pPab->pCallbackFunc == (PFNCALLBACK) NULL) {
- RCProcI2OMsgQ (dev);
- udelay (1000); /* please don't hog the bus!!! */
- timeout++;
- if (timeout > 10000) {
- break;
- }
- }
- if (ReturnAddr != (PU32) NULL)
- *ReturnAddr = (U32) pPab->pCallbackFunc;
- }
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCResetIOP()
-**
-** Send StatusGet Msg, wait for results return directly to buffer.
-**
-** =========================================================================
-*/
-RC_RETURN
-RCResetIOP (struct net_device * dev)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- volatile PU32 p32;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_EXEC_IOP_RESET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
- pMsg[2] = 0; /* universal context */
- pMsg[3] = 0; /* universal context */
- pMsg[4] = 0; /* universal context */
- pMsg[5] = 0; /* universal context */
- /* phys address to return status - area right after PAB */
- pMsg[6] = pPab->outMsgBlockPhyAddr;
- pMsg[7] = 0;
- pMsg[8] = 1; /* return 1 byte */
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0;
- p32[1] = 0;
-
- /* post to Inbound Post Q */
-
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] || p32[1])
- break;
-
- if (!timeout--) {
- dprintk ("RCResetIOP timeout\n");
- return RC_RTN_MSG_REPLY_TIMEOUT;
- }
- }
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCShutdownLANCard()
-**
-** ResourceFlags indicates whether to return buffer resource explicitly
-** to host or keep and reuse.
-** CallbackFunction (if not NULL) is the function to be called when
-** shutdown is complete.
-** If CallbackFunction is NULL, ReturnAddr will have a 1 placed in it when
-** shutdown is done (if not NULL).
-**
-** =========================================================================
-*/
-RC_RETURN
-RCShutdownLANCard (struct net_device * dev, U16 ResourceFlags,
- PU32 ReturnAddr, PFNCALLBACK CallbackFunction)
-{
- volatile PU32 pMsg;
- U32 off;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- long timeout = 0;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pPab->pCallbackFunc = CallbackFunction;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup message */
- pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] =
- I2O_LAN_SHUTDOWN << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = ResourceFlags << 16; /* resource flags */
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
-
- if (CallbackFunction == (PFNCALLBACK) NULL) {
- /* call RCProcI2OMsgQ() until something in pPab->pCallbackFunc
- or until timer goes off */
- while (pPab->pCallbackFunc == (PFNCALLBACK) NULL) {
- RCProcI2OMsgQ (dev);
- udelay (1000); /* please don't hog the bus!!! */
- timeout++;
- if (timeout > 10000) {
- printk (KERN_WARNING
- "(rcpci45 driver:) RCShutdownLANCard(): timeout\n");
- break;
- }
- }
- if (ReturnAddr != (PU32) NULL)
- *ReturnAddr = (U32) pPab->pCallbackFunc;
- }
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** RCSetRavlinIPandMask()
-**
-** Set the Ravlin 45/PCI cards IP address and network mask.
-**
-** IP address and mask must be in network byte order.
-** For example, IP address 1.2.3.4 and mask 255.255.255.0 would be
-** 0x04030201 and 0x00FFFFFF on a little endian machine.
-**
-** =========================================================================
-*/
-RC_RETURN
-RCSetRavlinIPandMask (struct net_device * dev, U32 ipAddr, U32 netMask)
-{
- volatile PU32 pMsg;
- U32 off;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- off = pPab->p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- /* setup private message */
- pMsg[0] = SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x219; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_SET_IP_AND_MASK;
- pMsg[5] = ipAddr;
- pMsg[6] = netMask;
-
- pPab->p_atu->InQueue = off; /* send it to the I2O device */
- return RC_RTN_NO_ERROR;
-
-}
-
-/*
-** =========================================================================
-** RCGetRavlinIPandMask()
-**
-** get the IP address and MASK from the card
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetRavlinIPandMask (struct net_device * dev, PU32 pIpAddr, PU32 pNetMask,
- PFNWAITCALLBACK WaitCallback)
-{
- unsigned timeout;
- U32 off;
- PU32 pMsg, p32;
- PPAB pPab = ((PDPA) dev->priv)->pPab;
- PATU p_atu;
-
- dprintk
- ("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n",
- (u32) pIpAddr, *pIpAddr);
-
- if (pPab == NULL)
- return RC_RTN_ADPTR_NOT_REGISTERED;
-
- p_atu = pPab->p_atu;
- off = p_atu->InQueue; /* get addresss of message */
-
- if (0xFFFFFFFF == off)
- return RC_RTN_FREE_Q_EMPTY;
-
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- *p32 = 0xFFFFFFFF;
-
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + off);
-
- dprintk
- ("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n",
- (u32) p_atu, off, (u32) p32);
- /* setup private message */
- pMsg[0] = FIVE_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_PRIVATE << 24 | I2O_HOST_TID << 12 | RC_LAN_TARGET_ID;
- pMsg[2] = 0; /* initiator context */
- pMsg[3] = 0x218; /* transaction context */
- pMsg[4] = RC_PCI45_VENDOR_ID << 16 | RC_PRIVATE_GET_IP_AND_MASK;
- pMsg[5] = pPab->outMsgBlockPhyAddr;
-
- p_atu->InQueue = off; /* send it to the I2O device */
- dprintk
- ("RCGetRavlinIPandMask: p_atu 0x%08ulx, off 0x%08ulx, p32 0x%08ulx\n",
- (u32) p_atu, off, (u32) p32);
-
- /* wait for the rcpci45 board to update the info */
- timeout = 100000;
- while (0xffffffff == *p32) {
- if (WaitCallback)
- (*WaitCallback) ();
-
- udelay (10);
-
- if (!timeout--) {
- dprintk ("RCGetRavlinIPandMask: Timeout\n");
- return RC_RTN_MSG_REPLY_TIMEOUT;
- }
- }
-
- dprintk
- ("RCGetRavlinIPandMask: after time out\np32[0] (IpAddr) 0x%08ulx, p32[1] (IPmask) 0x%08ulx\n",
- p32[0], p32[1]);
-
- /* send IP and mask to user's space */
- *pIpAddr = p32[0];
- *pNetMask = p32[1];
-
- dprintk
- ("RCGetRavlinIPandMask: pIpAddr is 0x%08ulx, *IpAddr is 0x%08ulx\n",
- (u32) pIpAddr, *pIpAddr);
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** /////////////////////////////////////////////////////////////////////////
-** /////////////////////////////////////////////////////////////////////////
-**
-** local functions
-**
-** /////////////////////////////////////////////////////////////////////////
-** /////////////////////////////////////////////////////////////////////////
-*/
-
-/*
-** =========================================================================
-** SendI2OOutboundQInitMsg()
-**
-** =========================================================================
-*/
-static int
-SendI2OOutboundQInitMsg (PPAB pPab)
-{
- U32 msgOffset, timeout, phyOutQFrames, i;
- volatile PU32 pMsg;
- volatile PU32 p32;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("SendI2OOutboundQInitMsg(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- dprintk
- ("SendI2OOutboundQInitMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n",
- (u32) pMsg, msgOffset);
-
- pMsg[0] = EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6;
- pMsg[1] =
- I2O_EXEC_OUTBOUND_INIT << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = 0x106; /* transaction context */
- pMsg[4] = 4096; /* Host page frame size */
- pMsg[5] = MSG_FRAME_SIZE << 16 | 0x80; /* outbound msg frame size and Initcode */
- pMsg[6] = 0xD0000004; /* simple sgl element LE, EOB */
- /* phys address to return status - area right after PAB */
- pMsg[7] = pPab->outMsgBlockPhyAddr;
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0;
-
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
-
- /* wait for response */
- timeout = 100000;
- while (1) {
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0])
- break;
-
- if (!timeout--) {
- dprintk
- ("Timeout wait for InitOutQ InPrgress status from IOP\n");
- return RC_RTN_NO_I2O_STATUS;
- }
- }
-
- timeout = 100000;
- while (1) {
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] == I2O_EXEC_OUTBOUND_INIT_COMPLETE)
- break;
-
- if (!timeout--) {
- dprintk
- ("Timeout wait for InitOutQ Complete status from IOP\n");
- return RC_RTN_NO_I2O_STATUS;
- }
- }
-
- /* load PCI outbound free Q with MF physical addresses */
- phyOutQFrames = pPab->outMsgBlockPhyAddr;
-
- for (i = 0; i < NMBR_MSG_FRAMES; i++) {
- pPab->p_atu->OutQueue = phyOutQFrames;
- phyOutQFrames += MSG_FRAME_SIZE;
- }
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** GetI2OStatus()
-**
-** Send StatusGet Msg, wait for results return directly to buffer.
-**
-** =========================================================================
-*/
-static int
-GetI2OStatus (PPAB pPab)
-{
- U32 msgOffset, timeout;
- PU32 pMsg;
- volatile PU32 p32;
-
- msgOffset = pPab->p_atu->InQueue;
- dprintk ("GetI2OStatus: msg offset = 0x%x\n", msgOffset);
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("GetI2OStatus(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- pMsg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_EXEC_STATUS_GET << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
- pMsg[2] = 0; /* universal context */
- pMsg[3] = 0; /* universal context */
- pMsg[4] = 0; /* universal context */
- pMsg[5] = 0; /* universal context */
- /* phys address to return status - area right after PAB */
- pMsg[6] = pPab->outMsgBlockPhyAddr;
- pMsg[7] = 0;
- pMsg[8] = 88; /* return 88 bytes */
-
- /* virtual pointer to return buffer - clear first two dwords */
- p32 = (volatile PU32) pPab->pLinOutMsgBlock;
- p32[0] = 0;
- p32[1] = 0;
-
- dprintk
- ("GetI2OStatus - pMsg:0x%08ulx, msgOffset:0x%08ulx, [1]:0x%08ulx, [6]:0x%08ulx\n",
- (u32) pMsg, msgOffset, pMsg[1], pMsg[6]);
-
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
-
- dprintk ("Return status to p32 = 0x%08ulx\n", (u32) p32);
-
- /* wait for response */
- timeout = 1000000;
- while (1) {
- udelay (10); /* please don't hog the bus!!! */
-
- if (p32[0] && p32[1])
- break;
-
- if (!timeout--) {
- dprintk ("Timeout waiting for status from IOP\n");
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- p32[0], p32[1], p32[2], p32[3]);
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- p32[4], p32[5], p32[6], p32[7]);
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- p32[8], p32[9], p32[10], p32[11]);
- return RC_RTN_NO_I2O_STATUS;
- }
- }
-
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1],
- p32[2], p32[3]);
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5],
- p32[6], p32[7]);
- dprintk ("0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[8], p32[9],
- p32[10], p32[11]);
- /* get IOP state */
- pPab->IOPState = ((volatile PU8) p32)[10];
- pPab->InboundMFrameSize = ((volatile PU16) p32)[6];
-
- dprintk ("IOP state 0x%02x InFrameSize = 0x%04x\n",
- pPab->IOPState, pPab->InboundMFrameSize);
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** SendEnableSysMsg()
-**
-**
-** =========================================================================
-*/
-static int
-SendEnableSysMsg (PPAB pPab)
-{
- U32 msgOffset;
- volatile PU32 pMsg;
-
- msgOffset = pPab->p_atu->InQueue;
-
- if (msgOffset == 0xFFFFFFFF) {
- dprintk ("SendEnableSysMsg(): Inbound Free Q empty!\n");
- return RC_RTN_FREE_Q_EMPTY;
- }
-
- /* calc virtual address of msg - virtual already mapped to physical */
- pMsg = (PU32) (pPab->pPci45LinBaseAddr + msgOffset);
-
- dprintk
- ("SendEnableSysMsg - pMsg = 0x%08ulx, InQ msgOffset = 0x%08ulx\n",
- (u32) pMsg, msgOffset);
-
- pMsg[0] = FOUR_WORD_MSG_SIZE | SGL_OFFSET_0;
- pMsg[1] = I2O_EXEC_SYS_ENABLE << 24 | I2O_HOST_TID << 12 | I2O_IOP_TID;
- pMsg[2] = DEFAULT_RECV_INIT_CONTEXT;
- pMsg[3] = 0x110; /* transaction context */
- pMsg[4] = 0x50657465; /* RedCreek Private */
-
- /* post to Inbound Post Q */
- pPab->p_atu->InQueue = msgOffset;
-
- return RC_RTN_NO_ERROR;
-}
-
-/*
-** =========================================================================
-** FillI2OMsgFromTCB()
-**
-** inputs pMsgU32 - virtual pointer (mapped to physical) of message frame
-** pXmitCntrlBlock - pointer to caller buffer control block.
-**
-** fills in LAN SGL after Transaction Control Word or Bucket Count.
-** =========================================================================
-*/
-static int
-FillI2OMsgSGLFromTCB (PU32 pMsgFrame, PRCTCB pTransCtrlBlock)
-{
- unsigned int nmbrBuffers, nmbrSeg, nmbrDwords, context, flags;
- PU32 pTCB, pMsg;
-
- /* SGL element flags */
-#define EOB 0x40000000
-#define LE 0x80000000
-#define SIMPLE_SGL 0x10000000
-#define BC_PRESENT 0x01000000
-
- pTCB = (PU32) pTransCtrlBlock;
- pMsg = pMsgFrame;
- nmbrDwords = 0;
-
- dprintk ("FillI2OMsgSGLFromTCBX\n");
- dprintk ("TCB 0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n",
- pTCB[0], pTCB[1], pTCB[2], pTCB[3], pTCB[4]);
- dprintk ("pTCB 0x%08ulx, pMsg 0x%08ulx\n", (u32) pTCB, (u32) pMsg);
-
- nmbrBuffers = *pTCB++;
-
- if (!nmbrBuffers) {
- return -1;
- }
-
- do {
- context = *pTCB++; /* buffer tag (context) */
- nmbrSeg = *pTCB++; /* number of segments */
-
- if (!nmbrSeg) {
- return -1;
- }
-
- flags = SIMPLE_SGL | BC_PRESENT;
-
- if (1 == nmbrSeg) {
- flags |= EOB;
-
- if (1 == nmbrBuffers)
- flags |= LE;
- }
-
- /* 1st SGL buffer element has context */
- pMsg[0] = pTCB[0] | flags; /* send over count (segment size) */
- pMsg[1] = context;
- pMsg[2] = pTCB[1]; /* send buffer segment physical address */
- nmbrDwords += 3;
- pMsg += 3;
- pTCB += 2;
-
- if (--nmbrSeg) {
- do {
- flags = SIMPLE_SGL;
-
- if (1 == nmbrSeg) {
- flags |= EOB;
-
- if (1 == nmbrBuffers)
- flags |= LE;
- }
-
- pMsg[0] = pTCB[0] | flags; /* send over count */
- pMsg[1] = pTCB[1]; /* send buffer segment physical address */
- nmbrDwords += 2;
- pTCB += 2;
- pMsg += 2;
-
- } while (--nmbrSeg);
- }
-
- } while (--nmbrBuffers);
-
- return nmbrDwords;
-}
-
-/*
-** =========================================================================
-** ProcessOutboundI2OMsg()
-**
-** process I2O reply message
-** * change to msg structure *
-** =========================================================================
-*/
-static void
-ProcessOutboundI2OMsg (PPAB pPab, U32 phyAddrMsg)
-{
- PU8 p8Msg;
- PU32 p32;
-/* U16 count; */
-
- p8Msg = pPab->pLinOutMsgBlock + (phyAddrMsg - pPab->outMsgBlockPhyAddr);
- p32 = (PU32) p8Msg;
-
- dprintk
- ("VXD: ProcessOutboundI2OMsg - pPab 0x%08ulx, phyAdr 0x%08ulx, linAdr 0x%08ulx\n",
- (u32) pPab, phyAddrMsg, (u32) p8Msg);
- dprintk ("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[0], p32[1],
- p32[2], p32[3]);
- dprintk ("msg :0x%08ulx:0x%08ulx:0x%08ulx:0x%08ulx\n", p32[4], p32[5],
- p32[6], p32[7]);
-
- if (p32[4] >> 24 != I2O_REPLY_STATUS_SUCCESS) {
- dprintk ("Message reply status not success\n");
- return;
- }
-
- switch (p8Msg[7]) { /* function code byte */
- case I2O_EXEC_SYS_TAB_SET:
- msgFlag = 1;
- dprintk ("Received I2O_EXEC_SYS_TAB_SET reply\n");
- break;
-
- case I2O_EXEC_HRT_GET:
- msgFlag = 1;
- dprintk ("Received I2O_EXEC_HRT_GET reply\n");
- break;
-
- case I2O_EXEC_LCT_NOTIFY:
- msgFlag = 1;
- dprintk ("Received I2O_EXEC_LCT_NOTIFY reply\n");
- break;
-
- case I2O_EXEC_SYS_ENABLE:
- msgFlag = 1;
- dprintk ("Received I2O_EXEC_SYS_ENABLE reply\n");
- break;
-
- default:
- dprintk ("Received UNKNOWN reply\n");
- break;
- }
-}
+++ /dev/null
-/*
-** *************************************************************************
-**
-**
-** R C L A N M T L . H $Revision: 6 $
-**
-**
-** RedCreek I2O LAN Message Transport Layer header file.
-**
-** ---------------------------------------------------------------------
-** --- Copyright (c) 1997-1999, RedCreek Communications Inc. ---
-** --- All rights reserved. ---
-** ---------------------------------------------------------------------
-**
-** File Description:
-**
-** Header file for host I2O (Intelligent I/O) LAN message transport layer
-** API and data types.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** *************************************************************************
-*/
-
-#ifndef RCLANMTL_H
-#define RCLANMTL_H
-
-/* Linux specific includes */
-#include <asm/types.h>
-#ifdef RC_LINUX_MODULE /* linux modules need non-library version of string functions */
-#include <linux/string.h>
-#else
-#include <string.h>
-#endif
-#include <linux/delay.h> /* for udelay() */
-
-#include <linux/netdevice.h>
-#include <linux/if_ether.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-
-#include <asm/io.h>
-
-/* Debug stuff. Define for debug output */
-#undef RCDEBUG
-
-#ifdef RCDEBUG
-#define dprintk(args...) printk(KERN_DEBUG "rc: " args)
-#else
-#define dprintk(args...) { }
-#endif
-
-/* Typedefs */
-
- /* scalar data types */
-typedef __u8 U8;
-typedef __u16 U16;
-typedef __u32 U32;
-typedef __u8 *PU8;
-typedef __u16 *PU16;
-typedef __u32 *PU32;
-typedef unsigned long BF;
-typedef int RC_RETURN;
-
- /*
- ** type PFNWAITCALLBACK
- **
- ** pointer to void function - type used for WaitCallback in some functions
- */
-typedef void (*PFNWAITCALLBACK) (void); /* void argument avoids compiler complaint */
-
- /*
- ** type PFNTXCALLBACK
- **
- ** Pointer to user's transmit callback function. This user function is
- ** called from RCProcI2OMsgQ() when packet have been transmitted from buffers
- ** given in the RCI2OSendPacket() function. BufferContext is a pointer to
- ** an array of 32 bit context values. These are the values the user assigned
- ** and passed in the TCB to the RCI2OSendPacket() function. PcktCount
- ** indicates the number of buffer context values in the BufferContext[] array.
- ** The User's TransmitCallbackFunction should recover (put back in free queue)
- ** the packet buffers associated with the buffer context values.
- */
-typedef void (*PFNTXCALLBACK) (U32 Status,
- U16 PcktCount,
- PU32 BufferContext, struct net_device *);
-
- /*
- ** type PFNRXCALLBACK
- **
- ** Pointer to user's receive callback function. This user function
- ** is called from RCProcI2OMsgQ() when packets have been received into
- ** previously posted packet buffers throught the RCPostRecvBuffers() function.
- ** The received callback function should process the Packet Descriptor Block
- ** pointed to by PacketDescBlock. See Packet Decription Block below.
- */
-typedef void (*PFNRXCALLBACK) (U32 Status,
- U8 PktCount,
- U32 BucketsRemain,
- PU32 PacketDescBlock, struct net_device *);
-
- /*
- ** type PFNCALLBACK
- **
- ** Pointer to user's generic callback function. This user function
- ** can be passed to LANReset or LANShutdown and is called when the
- ** the reset or shutdown is complete.
- ** Param1 and Param2 are invalid for LANReset and LANShutdown.
- */
-typedef void (*PFNCALLBACK) (U32 Status,
- U32 Param1, U32 Param2, struct net_device * dev);
-
-/*
-** Message Unit CSR definitions for RedCreek PCI45 board
-*/
-typedef struct tag_rcatu {
- volatile unsigned long APICRegSel; /* APIC Register Select */
- volatile unsigned long reserved0;
- volatile unsigned long APICWinReg; /* APIC Window Register */
- volatile unsigned long reserved1;
- volatile unsigned long InMsgReg0; /* inbound message register 0 */
- volatile unsigned long InMsgReg1; /* inbound message register 1 */
- volatile unsigned long OutMsgReg0; /* outbound message register 0 */
- volatile unsigned long OutMsgReg1; /* outbound message register 1 */
- volatile unsigned long InDoorReg; /* inbound doorbell register */
- volatile unsigned long InIntStat; /* inbound interrupt status register */
- volatile unsigned long InIntMask; /* inbound interrupt mask register */
- volatile unsigned long OutDoorReg; /* outbound doorbell register */
- volatile unsigned long OutIntStat; /* outbound interrupt status register */
- volatile unsigned long OutIntMask; /* outbound interrupt mask register */
- volatile unsigned long reserved2;
- volatile unsigned long reserved3;
- volatile unsigned long InQueue; /* inbound queue port */
- volatile unsigned long OutQueue; /* outbound queue port */
- volatile unsigned long reserved4;
- volatile unsigned long reserver5;
- /* RedCreek extension */
- volatile unsigned long EtherMacLow;
- volatile unsigned long EtherMacHi;
- volatile unsigned long IPaddr;
- volatile unsigned long IPmask;
-} *PATU;
-
- /*
- ** typedef PAB
- **
- ** PCI Adapter Block - holds instance specific information.
- */
-typedef struct {
- PATU p_atu; /* ptr to ATU register block */
- PU8 pPci45LinBaseAddr;
- PU8 pLinOutMsgBlock;
- U32 outMsgBlockPhyAddr;
- PFNTXCALLBACK pTransCallbackFunc;
- PFNRXCALLBACK pRecvCallbackFunc;
- PFNCALLBACK pRebootCallbackFunc;
- PFNCALLBACK pCallbackFunc;
- U16 IOPState;
- U16 InboundMFrameSize;
-} *PPAB;
-
-/*
- * Driver Private Area, DPA.
- */
-typedef struct {
- U8 id; /* the AdapterID */
-
- /* These two field are basically for the RCioctl function.
- * I could not determine if they could be avoided. (RAA)*/
- U32 pci_addr; /* the pci address of the adapter */
- U32 pci_addr_len;
-
- struct pci_dev *pci_dev;
- struct timer_list timer; /* timer */
- struct net_device_stats stats; /* the statistics structure */
- unsigned long numOutRcvBuffers; /* number of outstanding receive buffers */
- unsigned char shutdown;
- unsigned char reboot;
- unsigned char nexus;
- PU8 msgbuf; /* Pointer to Lan Api Private Area */
- dma_addr_t msgbuf_dma;
- PPAB pPab; /* Pointer to the PCI Adapter Block */
-} *PDPA;
-
-/* PCI/45 Configuration space values */
-#define RC_PCI45_VENDOR_ID 0x4916
-#define RC_PCI45_DEVICE_ID 0x1960
-
- /* RedCreek API function return values */
-#define RC_RTN_NO_ERROR 0
-#define RC_RTN_I2O_NOT_INIT 1
-#define RC_RTN_FREE_Q_EMPTY 2
-#define RC_RTN_TCB_ERROR 3
-#define RC_RTN_TRANSACTION_ERROR 4
-#define RC_RTN_ADAPTER_ALREADY_INIT 5
-#define RC_RTN_MALLOC_ERROR 6
-#define RC_RTN_ADPTR_NOT_REGISTERED 7
-#define RC_RTN_MSG_REPLY_TIMEOUT 8
-#define RC_RTN_NO_I2O_STATUS 9
-#define RC_RTN_NO_FIRM_VER 10
-#define RC_RTN_NO_LINK_SPEED 11
-
-/* Driver capability flags */
-#define WARM_REBOOT_CAPABLE 0x01
-
-/*
-** Status - Transmit and Receive callback status word
-**
-** A 32 bit Status is returned to the TX and RX callback functions. This value
-** contains both the reply status and the detailed status as follows:
-**
-** 32 24 16 0
-** +------+------+------------+
-** | Reply| | Detailed |
-** |Status| 0 | Status |
-** +------+------+------------+
-**
-** Reply Status and Detailed Status of zero indicates No Errors.
-*/
- /* reply message status defines */
-#define I2O_REPLY_STATUS_SUCCESS 0x00
-#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
-#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0A
-
-/* DetailedStatusCode defines */
-#define I2O_LAN_DSC_SUCCESS 0x0000
-#define I2O_LAN_DSC_DEVICE_FAILURE 0x0001
-#define I2O_LAN_DSC_DESTINATION_NOT_FOUND 0x0002
-#define I2O_LAN_DSC_TRANSMIT_ERROR 0x0003
-#define I2O_LAN_DSC_TRANSMIT_ABORTED 0x0004
-#define I2O_LAN_DSC_RECEIVE_ERROR 0x0005
-#define I2O_LAN_DSC_RECEIVE_ABORTED 0x0006
-#define I2O_LAN_DSC_DMA_ERROR 0x0007
-#define I2O_LAN_DSC_BAD_PACKET_DETECTED 0x0008
-#define I2O_LAN_DSC_OUT_OF_MEMORY 0x0009
-#define I2O_LAN_DSC_BUCKET_OVERRUN 0x000A
-#define I2O_LAN_DSC_IOP_INTERNAL_ERROR 0x000B
-#define I2O_LAN_DSC_CANCELED 0x000C
-#define I2O_LAN_DSC_INVALID_TRANSACTION_CONTEXT 0x000D
-#define I2O_LAN_DSC_DESTINATION_ADDRESS_DETECTED 0x000E
-#define I2O_LAN_DSC_DESTINATION_ADDRESS_OMITTED 0x000F
-#define I2O_LAN_DSC_PARTIAL_PACKET_RETURNED 0x0010
-
-/*
-** Packet Description Block (Received packets)
-**
-** A pointer to this block structure is returned to the ReceiveCallback
-** function. It contains the list of packet buffers which have either been
-** filled with a packet or returned to host due to a LANReset function.
-** Currently there will only be one packet per receive bucket (buffer) posted.
-**
-** 32 24 0
-** +-----------------------+ -\
-** | Buffer 1 Context | \
-** +-----------------------+ \
-** | 0xC0000000 | / First Bucket Descriptor
-** +-----+-----------------+ /
-** | 0 | packet 1 length | /
-** +-----------------------+ -\
-** | Buffer 2 Context | \
-** +-----------------------+ \
-** | 0xC0000000 | / Second Bucket Descriptor
-** +-----+-----------------+ /
-** | 0 | packet 2 length | /
-** +-----+-----------------+ -
-** | ... | ----- more bucket descriptors
-** +-----------------------+ -\
-** | Buffer n Context | \
-** +-----------------------+ \
-** | 0xC0000000 | / Last Bucket Descriptor
-** +-----+-----------------+ /
-** | 0 | packet n length | /
-** +-----+-----------------+ -
-**
-** Buffer Context values are those given to adapter in the TCB on calls to
-** RCPostRecvBuffers().
-**
-*/
-
-/*
-** Transaction Control Block (TCB) structure
-**
-** A structure like this is filled in by the user and passed by reference to
-** RCI2OSendPacket() and RCPostRecvBuffers() functions. Minimum size is five
-** 32-bit words for one buffer with one segment descriptor.
-** MAX_NMBR_POST_BUFFERS_PER_MSG defines the maximum single segment buffers
-** that can be described in a given TCB.
-**
-** 32 0
-** +-----------------------+
-** | Buffer Count | Number of buffers in the TCB
-** +-----------------------+
-** | Buffer 1 Context | first buffer reference
-** +-----------------------+
-** | Buffer 1 Seg Count | number of segments in buffer
-** +-----------------------+
-** | Buffer 1 Seg Desc 1 | first segment descriptor (size, physical address)
-** +-----------------------+
-** | ... | more segment descriptors (size, physical address)
-** +-----------------------+
-** | Buffer 1 Seg Desc n | last segment descriptor (size, physical address)
-** +-----------------------+
-** | Buffer 2 Context | second buffer reference
-** +-----------------------+
-** | Buffer 2 Seg Count | number of segments in buffer
-** +-----------------------+
-** | Buffer 2 Seg Desc 1 | segment descriptor (size, physical address)
-** +-----------------------+
-** | ... | more segment descriptors (size, physical address)
-** +-----------------------+
-** | Buffer 2 Seg Desc n |
-** +-----------------------+
-** | ... | more buffer descriptor blocks ...
-** +-----------------------+
-** | Buffer n Context |
-** +-----------------------+
-** | Buffer n Seg Count |
-** +-----------------------+
-** | Buffer n Seg Desc 1 |
-** +-----------------------+
-** | ... |
-** +-----------------------+
-** | Buffer n Seg Desc n |
-** +-----------------------+
-**
-**
-** A TCB for one contigous packet buffer would look like the following:
-**
-** 32 0
-** +-----------------------+
-** | 1 | one buffer in the TCB
-** +-----------------------+
-** | <user's Context> | user's buffer reference
-** +-----------------------+
-** | 1 | one segment buffer
-** +-----------------------+ _
-** | <buffer size> | size \
-** +-----------------------+ \ segment descriptor
-** | <physical address> | physical address of buffer /
-** +-----------------------+ _/
-**
-*/
-
- /* Buffer Segment Descriptor */
-typedef struct {
- U32 size;
- U32 phyAddress;
-} BSD, *PBSD;
-
-typedef PU32 PRCTCB;
-/*
-** -------------------------------------------------------------------------
-** Exported functions comprising the API to the LAN I2O message transport layer
-** -------------------------------------------------------------------------
-*/
-
- /*
- ** InitRCI2OMsgLayer()
- **
- ** Called once prior to using the I2O LAN message transport layer. User
- ** provides both the physical and virual address of a locked page buffer
- ** that is used as a private buffer for the RedCreek I2O message
- ** transport layer. This buffer must be a contigous memory block of a
- ** minimum of 16K bytes and long word aligned. The user also must provide
- ** the base address of the RedCreek PCI adapter assigned by BIOS or operating
- ** system.
- **
- ** Inputs: dev - the net_device struct for the device.
- ** TransmitCallbackFunction - address of user's TX callback function
- ** ReceiveCallbackFunction - address of user's RX callback function
- ** RebootCallbackFunction - address of user's reboot callback function
- **
- */
-RC_RETURN RCInitI2OMsgLayer (struct net_device *dev,
- PFNTXCALLBACK TransmitCallbackFunction,
- PFNRXCALLBACK ReceiveCallbackFunction,
- PFNCALLBACK RebootCallbackFunction);
-
- /*
- ** RCSetRavlinIPandMask()
- **
- ** Set the Ravlin 45/PCI cards IP address and network mask.
- **
- ** IP address and mask must be in network byte order.
- ** For example, IP address 1.2.3.4 and mask 255.255.255.0 would be
- ** 0x04030201 and 0x00FFFFFF on a little endian machine.
- **
- */
-RC_RETURN RCSetRavlinIPandMask (struct net_device *dev, U32 ipAddr,
- U32 netMask);
-
-/*
-** =========================================================================
-** RCGetRavlinIPandMask()
-**
-** get the IP address and MASK from the card
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetRavlinIPandMask (struct net_device *dev, PU32 pIpAddr, PU32 pNetMask,
- PFNWAITCALLBACK WaitCallback);
-
- /*
- ** RCProcI2OMsgQ()
- **
- ** Called from user's polling loop or Interrupt Service Routine for a PCI
- ** interrupt from the RedCreek PCI adapter. User responsible for determining
- ** and hooking the PCI interrupt. This function will call the registered
- ** callback functions, TransmitCallbackFunction or ReceiveCallbackFunction,
- ** if a TX or RX transaction has completed.
- */
-irqreturn_t RCProcI2OMsgQ (struct net_device *dev);
-
- /*
- ** Disable and Enable I2O interrupts. I2O interrupts are enabled at Init time
- ** but can be disabled and re-enabled through these two function calls.
- ** Packets will still be put into any posted received buffers and packets will
- ** be sent through RCI2OSendPacket() functions. Disabling I2O interrupts
- ** will prevent hardware interrupt to host even though the outbound I2O msg
- ** queue is not emtpy.
- */
-RC_RETURN RCEnableI2OInterrupts (struct net_device *dev);
-RC_RETURN RCDisableI2OInterrupts (struct net_device *dev);
-
- /*
- ** RCPostRecvBuffers()
- **
- ** Post user's page locked buffers for use by the PCI adapter to
- ** return ethernet packets received from the LAN. Transaction Control Block,
- ** provided by user, contains buffer descriptor(s) which includes a buffer
- ** context number along with buffer size and physical address. See TCB above.
- ** The buffer context and actual packet length are returned to the
- ** ReceiveCallbackFunction when packets have been received. Buffers posted
- ** to the RedCreek adapter are considered owned by the adapter until the
- ** context is return to user through the ReceiveCallbackFunction.
- */
-RC_RETURN RCPostRecvBuffers (struct net_device *dev,
- PRCTCB pTransactionCtrlBlock);
-#define MAX_NMBR_POST_BUFFERS_PER_MSG 32
-
- /*
- ** RCI2OSendPacket()
- **
- ** Send user's ethernet packet from a locked page buffer.
- ** Packet must have full MAC header, however without a CRC.
- ** Initiator context is a user provided value that is returned
- ** to the TransmitCallbackFunction when packet buffer is free.
- ** Transmit buffer are considered owned by the adapter until context's
- ** returned to user through the TransmitCallbackFunction.
- */
-RC_RETURN RCI2OSendPacket (struct net_device *dev,
- U32 context, PRCTCB pTransactionCtrlBlock);
-
- /* Ethernet Link Statistics structure */
-typedef struct tag_RC_link_stats {
- U32 TX_good; /* good transmit frames */
- U32 TX_maxcol; /* frames not TX due to MAX collisions */
- U32 TX_latecol; /* frames not TX due to late collisions */
- U32 TX_urun; /* frames not TX due to DMA underrun */
- U32 TX_crs; /* frames TX with lost carrier sense */
- U32 TX_def; /* frames deferred due to activity on link */
- U32 TX_singlecol; /* frames TX with one and only on collision */
- U32 TX_multcol; /* frames TX with more than one collision */
- U32 TX_totcol; /* total collisions detected during TX */
- U32 Rcv_good; /* good frames received */
- U32 Rcv_CRCerr; /* frames RX and discarded with CRC errors */
- U32 Rcv_alignerr; /* frames RX with alignment and CRC errors */
- U32 Rcv_reserr; /* good frames discarded due to no RX buffer */
- U32 Rcv_orun; /* RX frames lost due to FIFO overrun */
- U32 Rcv_cdt; /* RX frames with collision during RX */
- U32 Rcv_runt; /* RX frames shorter than 64 bytes */
-} RCLINKSTATS, *P_RCLINKSTATS;
-
- /*
- ** RCGetLinkStatistics()
- **
- ** Returns link statistics in user's structure at address StatsReturnAddr
- ** If given, not NULL, the function WaitCallback is called during the wait
- ** loop while waiting for the adapter to respond.
- */
-RC_RETURN RCGetLinkStatistics (struct net_device *dev,
- P_RCLINKSTATS StatsReturnAddr,
- PFNWAITCALLBACK WaitCallback);
-
- /*
- ** RCGetLinkStatus()
- **
- ** Return link status, up or down, to user's location addressed by ReturnAddr.
- ** If given, not NULL, the function WaitCallback is called during the wait
- ** loop while waiting for the adapter to respond.
- */
-RC_RETURN RCGetLinkStatus (struct net_device *dev,
- PU32 pReturnStatus, PFNWAITCALLBACK WaitCallback);
-
- /* Link Status defines - value returned in pReturnStatus */
-#define RC_LAN_LINK_STATUS_DOWN 0
-#define RC_LAN_LINK_STATUS_UP 1
-
- /*
- ** RCGetMAC()
- **
- ** Get the current MAC address assigned to user. RedCreek Ravlin 45/PCI
- ** has two MAC addresses. One which is private to the PCI Card, and
- ** another MAC which is given to the user as its link layer MAC address. The
- ** adapter runs in promiscous mode because of the dual address requirement.
- ** The MAC address is returned to the unsigned char array pointer to by mac.
- */
-RC_RETURN RCGetMAC (struct net_device *dev, PFNWAITCALLBACK WaitCallback);
-
- /*
- ** RCSetMAC()
- **
- ** Set a new user port MAC address. This address will be returned on
- ** subsequent RCGetMAC() calls.
- */
-RC_RETURN RCSetMAC (struct net_device *dev, PU8 mac);
-
- /*
- ** RCSetLinkSpeed()
- **
- ** set adapter's link speed based on given input code.
- */
-RC_RETURN RCSetLinkSpeed (struct net_device *dev, U16 LinkSpeedCode);
- /* Set link speed codes */
-#define LNK_SPD_AUTO_NEG_NWAY 0
-#define LNK_SPD_100MB_FULL 1
-#define LNK_SPD_100MB_HALF 2
-#define LNK_SPD_10MB_FULL 3
-#define LNK_SPD_10MB_HALF 4
-
- /*
- ** RCGetLinkSpeed()
- **
- ** Return link speed code.
- */
- /* Return link speed codes */
-#define LNK_SPD_UNKNOWN 0
-#define LNK_SPD_100MB_FULL 1
-#define LNK_SPD_100MB_HALF 2
-#define LNK_SPD_10MB_FULL 3
-#define LNK_SPD_10MB_HALF 4
-
-RC_RETURN
-RCGetLinkSpeed (struct net_device *dev, PU32 pLinkSpeedCode,
- PFNWAITCALLBACK WaitCallback);
-/*
-** =========================================================================
-** RCSetPromiscuousMode(struct net_device *dev, U16 Mode)
-**
-** Defined values for Mode:
-** 0 - turn off promiscuous mode
-** 1 - turn on promiscuous mode
-**
-** =========================================================================
-*/
-#define PROMISCUOUS_MODE_OFF 0
-#define PROMISCUOUS_MODE_ON 1
-RC_RETURN RCSetPromiscuousMode (struct net_device *dev, U16 Mode);
-/*
-** =========================================================================
-** RCGetPromiscuousMode(struct net_device *dev, PU32 pMode, PFNWAITCALLBACK WaitCallback)
-**
-** get promiscuous mode setting
-**
-** Possible return values placed in pMode:
-** 0 = promisuous mode not set
-** 1 = promisuous mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetPromiscuousMode (struct net_device *dev, PU32 pMode,
- PFNWAITCALLBACK WaitCallback);
-
-/*
-** =========================================================================
-** RCSetBroadcastMode(struct net_device *dev, U16 Mode)
-**
-** Defined values for Mode:
-** 0 - turn off promiscuous mode
-** 1 - turn on promiscuous mode
-**
-** =========================================================================
-*/
-#define BROADCAST_MODE_OFF 0
-#define BROADCAST_MODE_ON 1
-RC_RETURN RCSetBroadcastMode (struct net_device *dev, U16 Mode);
-/*
-** =========================================================================
-** RCGetBroadcastMode(struct net_device *dev, PU32 pMode, PFNWAITCALLBACK WaitCallback)
-**
-** get broadcast mode setting
-**
-** Possible return values placed in pMode:
-** 0 = broadcast mode not set
-** 1 = broadcast mode is set
-**
-** =========================================================================
-*/
-RC_RETURN
-RCGetBroadcastMode (struct net_device *dev, PU32 pMode,
- PFNWAITCALLBACK WaitCallback);
-/*
-** =========================================================================
-** RCReportDriverCapability(struct net_device *dev, U32 capability)
-**
-** Currently defined bits:
-** WARM_REBOOT_CAPABLE 0x01
-**
-** =========================================================================
-*/
-RC_RETURN RCReportDriverCapability (struct net_device *dev, U32 capability);
-
-/*
-** RCGetFirmwareVer()
-**
-** Return firmware version in the form "SoftwareVersion : Bt BootVersion"
-**
-** WARNING: user's space pointed to by pFirmString should be at least 60 bytes.
-*/
-RC_RETURN
-RCGetFirmwareVer (struct net_device *dev, PU8 pFirmString,
- PFNWAITCALLBACK WaitCallback);
-
-/*
-** ----------------------------------------------
-** LAN adapter Reset and Shutdown functions
-** ----------------------------------------------
-*/
- /* resource flag bit assignments for RCResetLANCard() & RCShutdownLANCard() */
-#define RC_RESOURCE_RETURN_POSTED_RX_BUCKETS 0x0001
-#define RC_RESOURCE_RETURN_PEND_TX_BUFFERS 0x0002
-
- /*
- ** RCResetLANCard()
- **
- ** Reset LAN card operation. Causes a software reset of the ethernet
- ** controller and restarts the command and receive units. Depending on
- ** the ResourceFlags given, the buffers are either returned to the
- ** host with reply status of I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER and
- ** detailed status of I2O_LAN_DSC_CANCELED (new receive buffers must be
- ** posted after issuing this) OR the buffers are kept and reused by
- ** the ethernet controller. If CallbackFunction is not NULL, the function
- ** will be called when the reset is complete. If the CallbackFunction is
- ** NULL,a 1 will be put into the ReturnAddr after waiting for the reset
- ** to complete (please disable I2O interrupts during this method).
- ** Any outstanding transmit or receive buffers that are complete will be
- ** returned via the normal reply messages before the requested resource
- ** buffers are returned.
- ** A call to RCPostRecvBuffers() is needed to return the ethernet to full
- ** operation if the receive buffers were returned during LANReset.
- ** Note: The IOP status is not affected by a LAN reset.
- */
-RC_RETURN RCResetLANCard (struct net_device *dev, U16 ResourceFlags,
- PU32 ReturnAddr, PFNCALLBACK CallbackFunction);
-
- /*
- ** RCShutdownLANCard()
- **
- ** Shutdown LAN card operation and put into an idle (suspended) state.
- ** The LAN card is restarted with RCResetLANCard() function.
- ** Depending on the ResourceFlags given, the buffers are either returned
- ** to the host with reply status of I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER
- ** and detailed status of I2O_LAN_DSC_CANCELED (new receive buffers must be
- ** posted after issuing this) OR the buffers are kept and reused by
- ** the ethernet controller. If CallbackFunction is not NULL, the function
- ** will be called when the reset is complete. If the CallbackFunction is
- ** NULL,a 1 will be put into the ReturnAddr after waiting for the reset
- ** to complete (please disable I2O interrupts during this method).
- ** Any outstanding transmit or receive buffers that are complete will be
- ** returned via the normal reply messages before the requested resource
- ** buffers are returned.
- ** Note: The IOP status is not affected by a LAN shutdown.
- */
-RC_RETURN
-RCShutdownLANCard (struct net_device *dev, U16 ResourceFlags, PU32 ReturnAddr,
- PFNCALLBACK CallbackFunction);
-
- /*
- ** RCResetIOP();
- ** Initializes IOPState to I2O_IOP_STATE_RESET.
- ** Stops access to outbound message Q.
- ** Discards any outstanding transmit or posted receive buffers.
- ** Clears outbound message Q.
- */
-RC_RETURN RCResetIOP (struct net_device *dev);
-
-#endif /* RCLANMTL_H */
+++ /dev/null
-/*
-**
-** RCpci45.c
-**
-**
-**
-** ---------------------------------------------------------------------
-** --- Copyright (c) 1998, 1999, RedCreek Communications Inc. ---
-** --- All rights reserved. ---
-** ---------------------------------------------------------------------
-**
-** Written by Pete Popov and Brian Moyle.
-**
-** Known Problems
-**
-** None known at this time.
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** Francois Romieu, Apr 2003: Converted to pci DMA mapping API.
-**
-** Pete Popov, Oct 2001: Fixed a few bugs to make the driver functional
-** again. Note that this card is not supported or manufactured by
-** RedCreek anymore.
-**
-** Rasmus Andersen, December 2000: Converted to new PCI API and general
-** cleanup.
-**
-** Pete Popov, January 11,99: Fixed a couple of 2.1.x problems
-** (virt_to_bus() not called), tested it under 2.2pre5 (as a module), and
-** added a #define(s) to enable the use of the same file for both, the 2.0.x
-** kernels as well as the 2.1.x.
-**
-** Ported to 2.1.x by Alan Cox 1998/12/9.
-**
-** Sometime in mid 1998, written by Pete Popov and Brian Moyle.
-**
-***************************************************************************/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/in.h>
-#include <linux/init.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/timer.h>
-
-#include <asm/irq.h> /* For NR_IRQS only. */
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-
-static char version[] __initdata =
- "RedCreek Communications PCI linux driver version 2.21\n";
-
-#define RC_LINUX_MODULE
-#include "rclanmtl.h"
-#include "rcif.h"
-
-#define RUN_AT(x) (jiffies + (x))
-
-#define NEW_MULTICAST
-
-#define MAX_ETHER_SIZE 1520
-#define MAX_NMBR_RCV_BUFFERS 96
-#define RC_POSTED_BUFFERS_LOW_MARK MAX_NMBR_RCV_BUFFERS-16
-#define BD_SIZE 3 /* Bucket Descriptor size */
-#define BD_LEN_OFFSET 2 /* Bucket Descriptor offset to length field */
-
-/* RedCreek LAN device Target ID */
-#define RC_LAN_TARGET_ID 0x10
-/* RedCreek's OSM default LAN receive Initiator */
-#define DEFAULT_RECV_INIT_CONTEXT 0xA17
-
-/* minimum msg buffer size needed by the card
- * Note that the size of this buffer is hard code in the
- * ipsec card's firmware. Thus, the size MUST be a minimum
- * of 16K. Otherwise the card will end up using memory
- * that does not belong to it.
- */
-#define MSG_BUF_SIZE 16384
-
-/* 2003/04/20: I don't know about the hardware ability but the driver won't
- * play safe with 64 bit addressing and DAC without NETIF_F_HIGHDMA doesn't
- * really make sense anyway. Let's play safe - romieu.
- */
-#define RCPCI45_DMA_MASK ((u64) 0xffffffff)
-
-static U32 DriverControlWord;
-
-static void rc_timer (unsigned long);
-
-static int RCopen (struct net_device *);
-static int RC_xmit_packet (struct sk_buff *, struct net_device *);
-static irqreturn_t RCinterrupt (int, void *, struct pt_regs *);
-static int RCclose (struct net_device *dev);
-static struct net_device_stats *RCget_stats (struct net_device *);
-static int RCioctl (struct net_device *, struct ifreq *, int);
-static int RCconfig (struct net_device *, struct ifmap *);
-static void RCxmit_callback (U32, U16, PU32, struct net_device *);
-static void RCrecv_callback (U32, U8, U32, PU32, struct net_device *);
-static void RCreset_callback (U32, U32, U32, struct net_device *);
-static void RCreboot_callback (U32, U32, U32, struct net_device *);
-static int RC_allocate_and_post_buffers (struct net_device *, int);
-
-static struct pci_device_id rcpci45_pci_table[] = {
- { PCI_VENDOR_ID_REDCREEK, PCI_DEVICE_ID_RC45, PCI_ANY_ID, PCI_ANY_ID,},
- {}
-};
-MODULE_DEVICE_TABLE (pci, rcpci45_pci_table);
-MODULE_LICENSE("GPL");
-
-static void __devexit
-rcpci45_remove_one (struct pci_dev *pdev)
-{
- struct net_device *dev = pci_get_drvdata (pdev);
- PDPA pDpa = dev->priv;
-
- RCResetIOP (dev);
- unregister_netdev (dev);
- free_irq (dev->irq, dev);
- iounmap ((void *) dev->base_addr);
- pci_release_regions (pdev);
- pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
- pDpa->msgbuf_dma);
- if (pDpa->pPab)
- kfree (pDpa->pPab);
- free_netdev (dev);
- pci_set_drvdata (pdev, NULL);
-}
-
-static int
-rcpci45_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- unsigned long *vaddr;
- PDPA pDpa;
- int error;
- static int card_idx = -1;
- struct net_device *dev;
- unsigned long pci_start, pci_len;
-
- card_idx++;
-
- /*
- * Allocate and fill new device structure.
- * We need enough for struct net_device plus DPA plus the LAN
- * API private area, which requires a minimum of 16KB. The top
- * of the allocated area will be assigned to struct net_device;
- * the next chunk will be assigned to DPA; and finally, the rest
- * will be assigned to the LAN API layer.
- */
-
- dev = alloc_etherdev(sizeof(*pDpa));
- if (!dev) {
- printk (KERN_ERR
- "(rcpci45 driver:) alloc_etherdev alloc failed\n");
- error = -ENOMEM;
- goto err_out;
- }
-
- SET_MODULE_OWNER(dev);
- SET_NETDEV_DEV(dev, &pdev->dev);
-
- error = pci_enable_device (pdev);
- if (error) {
- printk (KERN_ERR
- "(rcpci45 driver:) %d: pci enable device error\n",
- card_idx);
- goto err_out;
- }
- pci_start = pci_resource_start (pdev, 0);
- pci_len = pci_resource_len (pdev, 0);
- printk("pci_start %lx pci_len %lx\n", pci_start, pci_len);
-
- pci_set_drvdata (pdev, dev);
-
- pDpa = dev->priv;
- pDpa->id = card_idx;
- pDpa->pci_dev = pdev;
- pDpa->pci_addr = pci_start;
-
- if (!pci_start || !(pci_resource_flags (pdev, 0) & IORESOURCE_MEM)) {
- printk (KERN_ERR
- "(rcpci45 driver:) No PCI mem resources! Aborting\n");
- error = -EBUSY;
- goto err_out_free_dev;
- }
-
- /*
- * pDpa->msgbuf is where the card will dma the I2O
- * messages. Thus, we need contiguous physical pages of memory.
- * 2003/04/20: pci_alloc_consistent() provides well over the needed
- * alignment on a 256 bytes boundary for the LAN API private area.
- * Thus it isn't needed anymore to align it by hand.
- */
- pDpa->msgbuf = pci_alloc_consistent (pdev, MSG_BUF_SIZE,
- &pDpa->msgbuf_dma);
- if (!pDpa->msgbuf) {
- printk (KERN_ERR "(rcpci45 driver:) \
- Could not allocate %d byte memory for the \
- private msgbuf!\n", MSG_BUF_SIZE);
- error = -ENOMEM;
- goto err_out_free_dev;
- }
-
- /* The adapter is accessible through memory-access read/write, not
- * I/O read/write. Thus, we need to map it to some virtual address
- * area in order to access the registers as normal memory.
- */
- error = pci_request_regions (pdev, dev->name);
- if (error)
- goto err_out_free_msgbuf;
-
- error = pci_set_dma_mask (pdev, RCPCI45_DMA_MASK);
- if (error) {
- printk (KERN_ERR
- "(rcpci45 driver:) pci_set_dma_mask failed!\n");
- goto err_out_free_region;
- }
-
- vaddr = (ulong *) ioremap (pci_start, pci_len);
- if (!vaddr) {
- printk (KERN_ERR
- "(rcpci45 driver:) \
- Unable to remap address range from %lu to %lu\n",
- pci_start, pci_start + pci_len);
- error = -EIO;
- goto err_out_free_region;
- }
-
- dev->base_addr = (unsigned long) vaddr;
- dev->irq = pdev->irq;
- dev->open = &RCopen;
- dev->hard_start_xmit = &RC_xmit_packet;
- dev->stop = &RCclose;
- dev->get_stats = &RCget_stats;
- dev->do_ioctl = &RCioctl;
- dev->set_config = &RCconfig;
-
- if ((error = register_netdev(dev)))
- goto err_out_iounmap;
-
- return 0; /* success */
-
-err_out_iounmap:
- iounmap((void *) dev->base_addr);
-err_out_free_region:
- pci_release_regions (pdev);
-err_out_free_msgbuf:
- pci_free_consistent (pdev, MSG_BUF_SIZE, pDpa->msgbuf,
- pDpa->msgbuf_dma);
-err_out_free_dev:
- free_netdev (dev);
-err_out:
- card_idx--;
- return error;
-}
-
-static struct pci_driver rcpci45_driver = {
- .name = "rcpci45",
- .id_table = rcpci45_pci_table,
- .probe = rcpci45_init_one,
- .remove = __devexit_p(rcpci45_remove_one),
-};
-
-static int __init
-rcpci_init_module (void)
-{
- int rc = pci_module_init (&rcpci45_driver);
- if (!rc)
- printk (KERN_ERR "%s", version);
- return rc;
-}
-
-static int
-RCopen (struct net_device *dev)
-{
- int post_buffers = MAX_NMBR_RCV_BUFFERS;
- PDPA pDpa = dev->priv;
- int count = 0;
- int requested = 0;
- int error;
-
- if (pDpa->nexus) {
- /* This is not the first time RCopen is called. Thus,
- * the interface was previously opened and later closed
- * by RCclose(). RCclose() does a Shutdown; to wake up
- * the adapter, a reset is mandatory before we can post
- * receive buffers. However, if the adapter initiated
- * a reboot while the interface was closed -- and interrupts
- * were turned off -- we need will need to reinitialize
- * the adapter, rather than simply waking it up.
- */
- printk (KERN_INFO "Waking up adapter...\n");
- RCResetLANCard (dev, 0, 0, 0);
- } else {
- pDpa->nexus = 1;
- /*
- * RCInitI2OMsgLayer is done only once, unless the
- * adapter was sent a warm reboot
- */
- error = RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
- (PFNRXCALLBACK) RCrecv_callback,
- (PFNCALLBACK) RCreboot_callback);
- if (error) {
- printk (KERN_ERR "%s: Unable to init msg layer (%x)\n",
- dev->name, error);
- goto err_out;
- }
- if ((error = RCGetMAC (dev, NULL))) {
- printk (KERN_ERR "%s: Unable to get adapter MAC\n",
- dev->name);
- goto err_out;
- }
- }
-
- /* Request a shared interrupt line. */
- error = request_irq (dev->irq, RCinterrupt, SA_SHIRQ, dev->name, dev);
- if (error) {
- printk (KERN_ERR "%s: unable to get IRQ %d\n",
- dev->name, dev->irq);
- goto err_out;
- }
-
- DriverControlWord |= WARM_REBOOT_CAPABLE;
- RCReportDriverCapability (dev, DriverControlWord);
-
- printk (KERN_INFO "%s: RedCreek Communications IPSEC VPN adapter\n",
- dev->name);
-
- RCEnableI2OInterrupts (dev);
-
- while (post_buffers) {
- if (post_buffers > MAX_NMBR_POST_BUFFERS_PER_MSG)
- requested = MAX_NMBR_POST_BUFFERS_PER_MSG;
- else
- requested = post_buffers;
- count = RC_allocate_and_post_buffers (dev, requested);
-
- if (count < requested) {
- /*
- * Check to see if we were able to post
- * any buffers at all.
- */
- if (post_buffers == MAX_NMBR_RCV_BUFFERS) {
- printk (KERN_ERR "%s: \
- unable to allocate any buffers\n",
- dev->name);
- goto err_out_free_irq;
- }
- printk (KERN_WARNING "%s: \
- unable to allocate all requested buffers\n", dev->name);
- break; /* we'll try to post more buffers later */
- } else
- post_buffers -= count;
- }
- pDpa->numOutRcvBuffers = MAX_NMBR_RCV_BUFFERS - post_buffers;
- pDpa->shutdown = 0; /* just in case */
- netif_start_queue (dev);
- return 0;
-
-err_out_free_irq:
- free_irq (dev->irq, dev);
-err_out:
- return error;
-}
-
-static int
-RC_xmit_packet (struct sk_buff *skb, struct net_device *dev)
-{
-
- PDPA pDpa = dev->priv;
- singleTCB tcb;
- psingleTCB ptcb = &tcb;
- RC_RETURN status = 0;
-
- netif_stop_queue (dev);
-
- if (pDpa->shutdown || pDpa->reboot) {
- printk ("RC_xmit_packet: tbusy!\n");
- return 1;
- }
-
- /*
- * The user is free to reuse the TCB after RCI2OSendPacket()
- * returns, since the function copies the necessary info into its
- * own private space. Thus, our TCB can be a local structure.
- * The skb, on the other hand, will be freed up in our interrupt
- * handler.
- */
-
- ptcb->bcount = 1;
-
- /*
- * we'll get the context when the adapter interrupts us to tell us that
- * the transmission is done. At that time, we can free skb.
- */
- ptcb->b.context = (U32) skb;
- ptcb->b.scount = 1;
- ptcb->b.size = skb->len;
- ptcb->b.addr = pci_map_single(pDpa->pci_dev, skb->data, skb->len,
- PCI_DMA_TODEVICE);
-
- if ((status = RCI2OSendPacket (dev, (U32) NULL, (PRCTCB) ptcb))
- != RC_RTN_NO_ERROR) {
- printk ("%s: send error 0x%x\n", dev->name, (uint) status);
- return 1;
- } else {
- dev->trans_start = jiffies;
- netif_wake_queue (dev);
- }
- /*
- * That's it!
- */
- return 0;
-}
-
-/*
- * RCxmit_callback()
- *
- * The transmit callback routine. It's called by RCProcI2OMsgQ()
- * because the adapter is done with one or more transmit buffers and
- * it's returning them to us, or we asked the adapter to return the
- * outstanding transmit buffers by calling RCResetLANCard() with
- * RC_RESOURCE_RETURN_PEND_TX_BUFFERS flag.
- * All we need to do is free the buffers.
- */
-static void
-RCxmit_callback (U32 Status,
- U16 PcktCount, PU32 BufferContext, struct net_device *dev)
-{
- struct sk_buff *skb;
- PDPA pDpa = dev->priv;
-
- if (!pDpa) {
- printk (KERN_ERR "%s: Fatal Error in xmit callback, !pDpa\n",
- dev->name);
- return;
- }
-
- if (Status != I2O_REPLY_STATUS_SUCCESS)
- printk (KERN_INFO "%s: xmit_callback: Status = 0x%x\n",
- dev->name, (uint) Status);
- if (pDpa->shutdown || pDpa->reboot)
- printk (KERN_INFO "%s: xmit callback: shutdown||reboot\n",
- dev->name);
-
- while (PcktCount--) {
- skb = (struct sk_buff *) (BufferContext[0]);
- BufferContext++;
- pci_unmap_single(pDpa->pci_dev, BufferContext[1], skb->len,
- PCI_DMA_TODEVICE);
- dev_kfree_skb_irq (skb);
- }
- netif_wake_queue (dev);
-}
-
-static void
-RCreset_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
-{
- PDPA pDpa = dev->priv;
-
- printk ("RCreset_callback Status 0x%x\n", (uint) Status);
- /*
- * Check to see why we were called.
- */
- if (pDpa->shutdown) {
- printk (KERN_INFO "%s: shutting down interface\n",
- dev->name);
- pDpa->shutdown = 0;
- pDpa->reboot = 0;
- } else if (pDpa->reboot) {
- printk (KERN_INFO "%s: reboot, shutdown adapter\n",
- dev->name);
- /*
- * We don't set any of the flags in RCShutdownLANCard()
- * and we don't pass a callback routine to it.
- * The adapter will have already initiated the reboot by
- * the time the function returns.
- */
- RCDisableI2OInterrupts (dev);
- RCShutdownLANCard (dev, 0, 0, 0);
- printk (KERN_INFO "%s: scheduling timer...\n", dev->name);
- init_timer (&pDpa->timer);
- pDpa->timer.expires = RUN_AT ((40 * HZ) / 10); /* 4 sec. */
- pDpa->timer.data = (unsigned long) dev;
- pDpa->timer.function = &rc_timer; /* timer handler */
- add_timer (&pDpa->timer);
- }
-}
-
-static void
-RCreboot_callback (U32 Status, U32 p1, U32 p2, struct net_device *dev)
-{
- PDPA pDpa = dev->priv;
-
- printk (KERN_INFO "%s: reboot: rcv buffers outstanding = %d\n",
- dev->name, (uint) pDpa->numOutRcvBuffers);
-
- if (pDpa->shutdown) {
- printk (KERN_INFO "%s: skip reboot, shutdown initiated\n",
- dev->name);
- return;
- }
- pDpa->reboot = 1;
- /*
- * OK, we reset the adapter and ask it to return all
- * outstanding transmit buffers as well as the posted
- * receive buffers. When the adapter is done returning
- * those buffers, it will call our RCreset_callback()
- * routine. In that routine, we'll call RCShutdownLANCard()
- * to tell the adapter that it's OK to start the reboot and
- * schedule a timer callback routine to execute 3 seconds
- * later; this routine will reinitialize the adapter at that time.
- */
- RCResetLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
- RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
- (PFNCALLBACK) RCreset_callback);
-}
-
-/*
- * RCrecv_callback()
- *
- * The receive packet callback routine. This is called by
- * RCProcI2OMsgQ() after the adapter posts buffers which have been
- * filled (one ethernet packet per buffer).
- */
-static void
-RCrecv_callback (U32 Status,
- U8 PktCount,
- U32 BucketsRemain,
- PU32 PacketDescBlock, struct net_device *dev)
-{
-
- U32 len, count;
- PDPA pDpa = dev->priv;
- struct sk_buff *skb;
- singleTCB tcb;
- psingleTCB ptcb = &tcb;
-
- ptcb->bcount = 1;
-
- if ((pDpa->shutdown || pDpa->reboot) && !Status)
- printk (KERN_INFO "%s: shutdown||reboot && !Status (%d)\n",
- dev->name, PktCount);
-
- if ((Status != I2O_REPLY_STATUS_SUCCESS) || pDpa->shutdown) {
- /*
- * Free whatever buffers the adapter returned, but don't
- * pass them to the kernel.
- */
-
- if (!pDpa->shutdown && !pDpa->reboot)
- printk (KERN_INFO "%s: recv error status = 0x%x\n",
- dev->name, (uint) Status);
- else
- printk (KERN_DEBUG "%s: Returning %d buffs stat 0x%x\n",
- dev->name, PktCount, (uint) Status);
- /*
- * TO DO: check the nature of the failure and put the
- * adapter in failed mode if it's a hard failure.
- * Send a reset to the adapter and free all outstanding memory.
- */
- if (PacketDescBlock) {
- while (PktCount--) {
- skb = (struct sk_buff *) PacketDescBlock[0];
- dev_kfree_skb (skb);
- pDpa->numOutRcvBuffers--;
- /* point to next context field */
- PacketDescBlock += BD_SIZE;
- }
- }
- return;
- } else {
- while (PktCount--) {
- skb = (struct sk_buff *) PacketDescBlock[0];
- len = PacketDescBlock[2];
- skb->dev = dev;
- skb_put (skb, len); /* adjust length and tail */
- skb->protocol = eth_type_trans (skb, dev);
- netif_rx (skb); /* send the packet to the kernel */
- dev->last_rx = jiffies;
- pDpa->numOutRcvBuffers--;
- /* point to next context field */
- PacketDescBlock += BD_SIZE;
- }
- }
-
- /*
- * Replenish the posted receive buffers.
- * DO NOT replenish buffers if the driver has already
- * initiated a reboot or shutdown!
- */
-
- if (!pDpa->shutdown && !pDpa->reboot) {
- count = RC_allocate_and_post_buffers (dev,
- MAX_NMBR_RCV_BUFFERS -
- pDpa->numOutRcvBuffers);
- pDpa->numOutRcvBuffers += count;
- }
-
-}
-
-/*
- * RCinterrupt()
- *
- * Interrupt handler.
- * This routine sets up a couple of pointers and calls
- * RCProcI2OMsgQ(), which in turn process the message and
- * calls one of our callback functions.
- */
-static irqreturn_t
-RCinterrupt (int irq, void *dev_id, struct pt_regs *regs)
-{
-
- PDPA pDpa;
- struct net_device *dev = dev_id;
-
- pDpa = dev->priv;
-
- if (pDpa->shutdown)
- printk (KERN_DEBUG "%s: shutdown, service irq\n",
- dev->name);
-
- return RCProcI2OMsgQ (dev);
-}
-
-#define REBOOT_REINIT_RETRY_LIMIT 4
-static void
-rc_timer (unsigned long data)
-{
- struct net_device *dev = (struct net_device *) data;
- PDPA pDpa = dev->priv;
- int init_status;
- static int retry;
- int post_buffers = MAX_NMBR_RCV_BUFFERS;
- int count = 0;
- int requested = 0;
-
- if (pDpa->reboot) {
- init_status =
- RCInitI2OMsgLayer (dev, (PFNTXCALLBACK) RCxmit_callback,
- (PFNRXCALLBACK) RCrecv_callback,
- (PFNCALLBACK) RCreboot_callback);
-
- switch (init_status) {
- case RC_RTN_NO_ERROR:
-
- pDpa->reboot = 0;
- pDpa->shutdown = 0; /* just in case */
- RCReportDriverCapability (dev, DriverControlWord);
- RCEnableI2OInterrupts (dev);
-
-
- if (!(dev->flags & IFF_UP)) {
- retry = 0;
- return;
- }
- while (post_buffers) {
- if (post_buffers >
- MAX_NMBR_POST_BUFFERS_PER_MSG)
- requested =
- MAX_NMBR_POST_BUFFERS_PER_MSG;
- else
- requested = post_buffers;
- count =
- RC_allocate_and_post_buffers (dev,
- requested);
- post_buffers -= count;
- if (count < requested)
- break;
- }
- pDpa->numOutRcvBuffers =
- MAX_NMBR_RCV_BUFFERS - post_buffers;
- printk ("Initialization done.\n");
- netif_wake_queue (dev);
- retry = 0;
- return;
- case RC_RTN_FREE_Q_EMPTY:
- retry++;
- printk (KERN_WARNING "%s inbound free q empty\n",
- dev->name);
- break;
- default:
- retry++;
- printk (KERN_WARNING "%s bad stat after reboot: %d\n",
- dev->name, init_status);
- break;
- }
-
- if (retry > REBOOT_REINIT_RETRY_LIMIT) {
- printk (KERN_WARNING "%s unable to reinitialize adapter after reboot\n", dev->name);
- printk (KERN_WARNING "%s shutting down interface\n", dev->name);
- RCDisableI2OInterrupts (dev);
- dev->flags &= ~IFF_UP;
- } else {
- printk (KERN_INFO "%s: rescheduling timer...\n",
- dev->name);
- init_timer (&pDpa->timer);
- pDpa->timer.expires = RUN_AT ((40 * HZ) / 10);
- pDpa->timer.data = (unsigned long) dev;
- pDpa->timer.function = &rc_timer;
- add_timer (&pDpa->timer);
- }
- } else
- printk (KERN_WARNING "%s: unexpected timer irq\n", dev->name);
-}
-
-static int
-RCclose (struct net_device *dev)
-{
- PDPA pDpa = dev->priv;
-
- printk("RCclose\n");
- netif_stop_queue (dev);
-
- if (pDpa->reboot) {
- printk (KERN_INFO "%s skipping reset -- adapter already in reboot mode\n", dev->name);
- dev->flags &= ~IFF_UP;
- pDpa->shutdown = 1;
- return 0;
- }
-
- pDpa->shutdown = 1;
-
- /*
- * We can't allow the driver to be unloaded until the adapter returns
- * all posted receive buffers. It doesn't hurt to tell the adapter
- * to return all posted receive buffers and outstanding xmit buffers,
- * even if there are none.
- */
-
- RCShutdownLANCard (dev, RC_RESOURCE_RETURN_POSTED_RX_BUCKETS |
- RC_RESOURCE_RETURN_PEND_TX_BUFFERS, 0,
- (PFNCALLBACK) RCreset_callback);
-
- dev->flags &= ~IFF_UP;
- return 0;
-}
-
-static struct net_device_stats *
-RCget_stats (struct net_device *dev)
-{
- RCLINKSTATS RCstats;
-
- PDPA pDpa = dev->priv;
-
- if (!pDpa) {
- return 0;
- } else if (!(dev->flags & IFF_UP)) {
- return 0;
- }
-
- memset (&RCstats, 0, sizeof (RCLINKSTATS));
- if ((RCGetLinkStatistics (dev, &RCstats, (void *) 0)) ==
- RC_RTN_NO_ERROR) {
-
- /* total packets received */
- pDpa->stats.rx_packets = RCstats.Rcv_good
- /* total packets transmitted */;
- pDpa->stats.tx_packets = RCstats.TX_good;
-
- pDpa->stats.rx_errors = RCstats.Rcv_CRCerr +
- RCstats.Rcv_alignerr + RCstats.Rcv_reserr +
- RCstats.Rcv_orun + RCstats.Rcv_cdt + RCstats.Rcv_runt;
-
- pDpa->stats.tx_errors = RCstats.TX_urun + RCstats.TX_crs +
- RCstats.TX_def + RCstats.TX_totcol;
-
- /*
- * This needs improvement.
- */
- pDpa->stats.rx_dropped = 0; /* no space in linux buffers */
- pDpa->stats.tx_dropped = 0; /* no space available in linux */
- pDpa->stats.multicast = 0; /* multicast packets received */
- pDpa->stats.collisions = RCstats.TX_totcol;
-
- /* detailed rx_errors: */
- pDpa->stats.rx_length_errors = 0;
- pDpa->stats.rx_over_errors = RCstats.Rcv_orun;
- pDpa->stats.rx_crc_errors = RCstats.Rcv_CRCerr;
- pDpa->stats.rx_frame_errors = 0;
- pDpa->stats.rx_fifo_errors = 0;
- pDpa->stats.rx_missed_errors = 0;
-
- /* detailed tx_errors */
- pDpa->stats.tx_aborted_errors = 0;
- pDpa->stats.tx_carrier_errors = 0;
- pDpa->stats.tx_fifo_errors = 0;
- pDpa->stats.tx_heartbeat_errors = 0;
- pDpa->stats.tx_window_errors = 0;
-
- return ((struct net_device_stats *) &(pDpa->stats));
- }
- return 0;
-}
-
-static int
-RCioctl (struct net_device *dev, struct ifreq *rq, int cmd)
-{
- RCuser_struct RCuser;
- PDPA pDpa = dev->priv;
-
- if (!capable (CAP_NET_ADMIN))
- return -EPERM;
-
- switch (cmd) {
-
- case RCU_PROTOCOL_REV:
- /*
- * Assign user protocol revision, to tell user-level
- * controller program whether or not it's in sync.
- */
- rq->ifr_ifru.ifru_data = (caddr_t) USER_PROTOCOL_REV;
- break;
-
- case RCU_COMMAND:
- {
- if (copy_from_user
- (&RCuser, rq->ifr_data, sizeof (RCuser)))
- return -EFAULT;
-
- dprintk ("RCioctl: RCuser_cmd = 0x%x\n", RCuser.cmd);
-
- switch (RCuser.cmd) {
- case RCUC_GETFWVER:
- RCUD_GETFWVER = &RCuser.RCUS_GETFWVER;
- RCGetFirmwareVer (dev,
- (PU8) & RCUD_GETFWVER->
- FirmString, NULL);
- break;
- case RCUC_GETINFO:
- RCUD_GETINFO = &RCuser.RCUS_GETINFO;
- RCUD_GETINFO->mem_start = dev->base_addr;
- RCUD_GETINFO->mem_end =
- dev->base_addr + pDpa->pci_addr_len;
- RCUD_GETINFO->base_addr = pDpa->pci_addr;
- RCUD_GETINFO->irq = dev->irq;
- break;
- case RCUC_GETIPANDMASK:
- RCUD_GETIPANDMASK = &RCuser.RCUS_GETIPANDMASK;
- RCGetRavlinIPandMask (dev,
- (PU32) &
- RCUD_GETIPANDMASK->IpAddr,
- (PU32) &
- RCUD_GETIPANDMASK->
- NetMask, NULL);
- break;
- case RCUC_GETLINKSTATISTICS:
- RCUD_GETLINKSTATISTICS =
- &RCuser.RCUS_GETLINKSTATISTICS;
- RCGetLinkStatistics (dev,
- (P_RCLINKSTATS) &
- RCUD_GETLINKSTATISTICS->
- StatsReturn, NULL);
- break;
- case RCUC_GETLINKSTATUS:
- RCUD_GETLINKSTATUS = &RCuser.RCUS_GETLINKSTATUS;
- RCGetLinkStatus (dev,
- (PU32) & RCUD_GETLINKSTATUS->
- ReturnStatus, NULL);
- break;
- case RCUC_GETMAC:
- RCUD_GETMAC = &RCuser.RCUS_GETMAC;
- RCGetMAC (dev, NULL);
- memcpy(RCUD_GETMAC, dev->dev_addr, 8);
- break;
- case RCUC_GETPROM:
- RCUD_GETPROM = &RCuser.RCUS_GETPROM;
- RCGetPromiscuousMode (dev,
- (PU32) & RCUD_GETPROM->
- PromMode, NULL);
- break;
- case RCUC_GETBROADCAST:
- RCUD_GETBROADCAST = &RCuser.RCUS_GETBROADCAST;
- RCGetBroadcastMode (dev,
- (PU32) & RCUD_GETBROADCAST->
- BroadcastMode, NULL);
- break;
- case RCUC_GETSPEED:
- if (!(dev->flags & IFF_UP)) {
- return -ENODATA;
- }
- RCUD_GETSPEED = &RCuser.RCUS_GETSPEED;
- RCGetLinkSpeed (dev,
- (PU32) & RCUD_GETSPEED->
- LinkSpeedCode, NULL);
- break;
- case RCUC_SETIPANDMASK:
- RCUD_SETIPANDMASK = &RCuser.RCUS_SETIPANDMASK;
- RCSetRavlinIPandMask (dev,
- (U32) RCUD_SETIPANDMASK->
- IpAddr,
- (U32) RCUD_SETIPANDMASK->
- NetMask);
- break;
- case RCUC_SETMAC:
- RCSetMAC (dev, (PU8) & RCUD_SETMAC->mac);
- break;
- case RCUC_SETSPEED:
- RCUD_SETSPEED = &RCuser.RCUS_SETSPEED;
- RCSetLinkSpeed (dev,
- (U16) RCUD_SETSPEED->
- LinkSpeedCode);
- break;
- case RCUC_SETPROM:
- RCUD_SETPROM = &RCuser.RCUS_SETPROM;
- RCSetPromiscuousMode (dev,
- (U16) RCUD_SETPROM->
- PromMode);
- break;
- case RCUC_SETBROADCAST:
- RCUD_SETBROADCAST = &RCuser.RCUS_SETBROADCAST;
- RCSetBroadcastMode (dev,
- (U16) RCUD_SETBROADCAST->
- BroadcastMode);
- break;
- default:
- RCUD_DEFAULT = &RCuser.RCUS_DEFAULT;
- RCUD_DEFAULT->rc = 0x11223344;
- break;
- }
- if (copy_to_user (rq->ifr_data, &RCuser,
- sizeof (RCuser)))
- return -EFAULT;
- break;
- } /* RCU_COMMAND */
-
- default:
- rq->ifr_ifru.ifru_data = (caddr_t) 0x12345678;
- return -EINVAL;
- }
- return 0;
-}
-
-static int
-RCconfig (struct net_device *dev, struct ifmap *map)
-{
- /*
- * To be completed ...
- */
- return 0;
- if (dev->flags & IFF_UP) /* can't act on a running interface */
- return -EBUSY;
-
- /* Don't allow changing the I/O address */
- if (map->base_addr != dev->base_addr) {
- printk (KERN_WARNING "%s Change I/O address not implemented\n",
- dev->name);
- return -EOPNOTSUPP;
- }
- return 0;
-}
-
-static void __exit
-rcpci_cleanup_module (void)
-{
- pci_unregister_driver (&rcpci45_driver);
-}
-
-module_init (rcpci_init_module);
-module_exit (rcpci_cleanup_module);
-
-static int
-RC_allocate_and_post_buffers (struct net_device *dev, int numBuffers)
-{
-
- int i;
- PU32 p;
- psingleB pB;
- struct sk_buff *skb;
- PDPA pDpa = dev->priv;
- RC_RETURN status;
- U32 res = 0;
-
- if (!numBuffers)
- return 0;
- else if (numBuffers > MAX_NMBR_POST_BUFFERS_PER_MSG) {
- printk (KERN_ERR "%s: Too many buffers requested!\n",
- dev->name);
- numBuffers = 32;
- }
-
- p = (PU32) kmalloc (sizeof (U32) + numBuffers * sizeof (singleB),
- GFP_DMA | GFP_ATOMIC);
-
- if (!p) {
- printk (KERN_WARNING "%s unable to allocate TCB\n",
- dev->name);
- goto out;
- }
-
- p[0] = 0; /* Buffer Count */
- pB = (psingleB) ((U32) p + sizeof (U32));/* point to the first buffer */
-
- for (i = 0; i < numBuffers; i++) {
- skb = dev_alloc_skb (MAX_ETHER_SIZE + 2);
- if (!skb) {
- printk (KERN_WARNING
- "%s: unable to allocate enough skbs!\n",
- dev->name);
- goto err_out_unmap;
- }
- skb_reserve (skb, 2); /* Align IP on 16 byte boundaries */
- pB->context = (U32) skb;
- pB->scount = 1; /* segment count */
- pB->size = MAX_ETHER_SIZE;
- pB->addr = pci_map_single(pDpa->pci_dev, skb->data,
- MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE);
- p[0]++;
- pB++;
- }
-
- if ((status = RCPostRecvBuffers (dev, (PRCTCB) p)) != RC_RTN_NO_ERROR) {
- printk (KERN_WARNING "%s: Post buffer failed, error 0x%x\n",
- dev->name, status);
- goto err_out_unmap;
- }
-out_free:
- res = p[0];
- kfree (p);
-out:
- return (res); /* return the number of posted buffers */
-
-err_out_unmap:
- for (; p[0] > 0; p[0]--) {
- --pB;
- skb = (struct sk_buff *) pB->context;
- pci_unmap_single(pDpa->pci_dev, pB->addr, MAX_ETHER_SIZE,
- PCI_DMA_FROMDEVICE);
- dev_kfree_skb (skb);
- }
- goto out_free;
-}
+++ /dev/null
-/*
- * Hardware-level driver for the COMX and HICOMX cards
- * for Linux kernel 2.2.X
- *
- * Original authors: Arpad Bakay <bakay.arpad@synergon.hu>,
- * Peter Bajan <bajan.peter@synergon.hu>,
- * Rewritten by: Tivadar Szemethy <tiv@itc.hu>
- * Currently maintained by: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-2000 ITConsult-Pro Co. <info@itc.hu>
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 0.86
- * Daniele Bellucci <bellucda@tiscali.it> - 0.87
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/11):
- * - port back to kernel, add support builtin driver
- * - cleaned up the source code a bit
- *
- * Version 0.81 (99/06/22):
- * - cleaned up the board load functions, no more long reset
- * timeouts
- * - lower modem lines on close
- * - some interrupt handling fixes
- *
- * Version 0.82 (99/08/24):
- * - fix multiple board support
- *
- * Version 0.83 (99/11/30):
- * - interrupt handling and locking fixes during initalization
- * - really fix multiple board support
- *
- * Version 0.84 (99/12/02):
- * - some workarounds for problematic hardware/firmware
- *
- * Version 0.85 (00/01/14):
- * - some additional workarounds :/
- * - printk cleanups
- * Version 0.86 (00/08/15):
- * - resource release on failure at COMX_init
- *
- * Version 0.87 (03/07/09)
- * - audit copy_from_user in comxhw_write_proc
- */
-
-#define VERSION "0.87"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#include "comx.h"
-#include "comxhw.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>, Tivadar Szemethy <tiv@itc.hu>, Arpad Bakay");
-MODULE_DESCRIPTION("Hardware-level driver for the COMX and HICOMX adapters\n");
-MODULE_LICENSE("GPL");
-
-#define COMX_readw(dev, offset) (readw(dev->mem_start + offset + \
- (unsigned int)(((struct comx_privdata *)\
- ((struct comx_channel *)dev->priv)->HW_privdata)->channel) \
- * COMX_CHANNEL_OFFSET))
-
-#define COMX_WRITE(dev, offset, value) (writew(value, dev->mem_start + offset \
- + (unsigned int)(((struct comx_privdata *) \
- ((struct comx_channel *)dev->priv)->HW_privdata)->channel) \
- * COMX_CHANNEL_OFFSET))
-
-#define COMX_CMD(dev, cmd) (COMX_WRITE(dev, OFF_A_L2_CMD, cmd))
-
-struct comx_firmware {
- int len;
- unsigned char *data;
-};
-
-struct comx_privdata {
- struct comx_firmware *firmware;
- u16 clock;
- char channel; // channel no.
- int memory_size;
- short io_extent;
- u_long histogram[5];
-};
-
-static struct net_device *memory_used[(COMX_MEM_MAX - COMX_MEM_MIN) / 0x10000];
-extern struct comx_hardware hicomx_hw;
-extern struct comx_hardware comx_hw;
-extern struct comx_hardware cmx_hw;
-
-static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static void COMX_board_on(struct net_device *dev)
-{
- outb_p( (byte) (((dev->mem_start & 0xf0000) >> 16) |
- COMX_ENABLE_BOARD_IT | COMX_ENABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void COMX_board_off(struct net_device *dev)
-{
- outb_p( (byte) (((dev->mem_start & 0xf0000) >> 16) |
- COMX_ENABLE_BOARD_IT), dev->base_addr);
-}
-
-static void HICOMX_board_on(struct net_device *dev)
-{
- outb_p( (byte) (((dev->mem_start & 0xf0000) >> 12) |
- HICOMX_ENABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void HICOMX_board_off(struct net_device *dev)
-{
- outb_p( (byte) (((dev->mem_start & 0xf0000) >> 12) |
- HICOMX_DISABLE_BOARD_MEM), dev->base_addr);
-}
-
-static void COMX_set_clock(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
-
- COMX_WRITE(dev, OFF_A_L1_CLKINI, hw->clock);
-}
-
-static struct net_device *COMX_access_board(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct net_device *ret;
- int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
- unsigned long flags;
-
-
- save_flags(flags); cli();
-
- ret = memory_used[mempos];
-
- if(ret == dev) {
- goto out;
- }
-
- memory_used[mempos] = dev;
-
- if (!ch->twin || ret != ch->twin) {
- if (ret) ((struct comx_channel *)ret->priv)->HW_board_off(ret);
- ch->HW_board_on(dev);
- }
-out:
- restore_flags(flags);
- return ret;
-}
-
-static void COMX_release_board(struct net_device *dev, struct net_device *savep)
-{
- unsigned long flags;
- int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
- struct comx_channel *ch = dev->priv;
-
- save_flags(flags); cli();
-
- if (memory_used[mempos] == savep) {
- goto out;
- }
-
- memory_used[mempos] = savep;
- if (!ch->twin || ch->twin != savep) {
- ch->HW_board_off(dev);
- if (savep) ((struct comx_channel*)savep->priv)->HW_board_on(savep);
- }
-out:
- restore_flags(flags);
-}
-
-static int COMX_txe(struct net_device *dev)
-{
- struct net_device *savep;
- struct comx_channel *ch = dev->priv;
- int rc = 0;
-
- savep = ch->HW_access_board(dev);
- if (COMX_readw(dev,OFF_A_L2_LINKUP) == LINKUP_READY) {
- rc = COMX_readw(dev,OFF_A_L2_TxEMPTY);
- }
- ch->HW_release_board(dev,savep);
- if(rc==0xffff) {
- printk(KERN_ERR "%s, OFF_A_L2_TxEMPTY is %d\n",dev->name, rc);
- }
- return rc;
-}
-
-static int COMX_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
- struct net_device *savep;
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- int ret = FRAME_DROPPED;
- word tmp;
-
- savep = ch->HW_access_board(dev);
-
- if (ch->debug_flags & DEBUG_HW_TX) {
- comx_debug_bytes(dev, skb->data, skb->len,"COMX_send packet");
- }
-
- if (skb->len > COMX_MAX_TX_SIZE) {
- ret=FRAME_DROPPED;
- goto out;
- }
-
- tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
- if ((ch->line_status & LINE_UP) && tmp==1) {
- int lensave = skb->len;
- int dest = COMX_readw(dev, OFF_A_L2_TxBUFP);
- word *data = (word *)skb->data;
-
- if(dest==0xffff) {
- printk(KERN_ERR "%s: OFF_A_L2_TxBUFP is %d\n", dev->name, dest);
- ret=FRAME_DROPPED;
- goto out;
- }
-
- writew((unsigned short)skb->len, dev->mem_start + dest);
- dest += 2;
- while (skb->len > 1) {
- writew(*data++, dev->mem_start + dest);
- dest += 2; skb->len -= 2;
- }
- if (skb->len == 1) {
- writew(*((byte *)data), dev->mem_start + dest);
- }
- writew(0, dev->mem_start + (int)hw->channel *
- COMX_CHANNEL_OFFSET + OFF_A_L2_TxEMPTY);
- ch->stats.tx_packets++;
- ch->stats.tx_bytes += lensave;
- ret = FRAME_ACCEPTED;
- } else {
- ch->stats.tx_dropped++;
- printk(KERN_INFO "%s: frame dropped\n",dev->name);
- if(tmp) {
- printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n",dev->name,tmp);
- }
- }
-
-out:
- ch->HW_release_board(dev, savep);
- dev_kfree_skb(skb);
- return ret;
-}
-
-static inline int comx_read_buffer(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- word rbuf_offs;
- struct sk_buff *skb;
- word len;
- int i=0;
- word *writeptr;
-
- i = 0;
- rbuf_offs = COMX_readw(dev, OFF_A_L2_RxBUFP);
- if(rbuf_offs == 0xffff) {
- printk(KERN_ERR "%s: OFF_A_L2_RxBUFP is %d\n",dev->name,rbuf_offs);
- return 0;
- }
- len = readw(dev->mem_start + rbuf_offs);
- if(len > COMX_MAX_RX_SIZE) {
- printk(KERN_ERR "%s: packet length is %d\n",dev->name,len);
- return 0;
- }
- if ((skb = dev_alloc_skb(len + 16)) == NULL) {
- ch->stats.rx_dropped++;
- COMX_WRITE(dev, OFF_A_L2_DAV, 0);
- return 0;
- }
- rbuf_offs += 2;
- skb_reserve(skb, 16);
- skb_put(skb, len);
- skb->dev = dev;
- writeptr = (word *)skb->data;
- while (i < len) {
- *writeptr++ = readw(dev->mem_start + rbuf_offs);
- rbuf_offs += 2;
- i += 2;
- }
- COMX_WRITE(dev, OFF_A_L2_DAV, 0);
- ch->stats.rx_packets++;
- ch->stats.rx_bytes += len;
- if (ch->debug_flags & DEBUG_HW_RX) {
- comx_debug_skb(dev, skb, "COMX_interrupt receiving");
- }
- ch->LINE_rx(dev, skb);
- return 1;
-}
-
-static inline char comx_line_change(struct net_device *dev, char linestat)
-{
- struct comx_channel *ch=dev->priv;
- char idle=1;
-
-
- if (linestat & LINE_UP) { /* Vonal fol */
- if (ch->lineup_delay) {
- if (!test_and_set_bit(0, &ch->lineup_pending)) {
- ch->lineup_timer.function = comx_lineup_func;
- ch->lineup_timer.data = (unsigned long)dev;
- ch->lineup_timer.expires = jiffies +
- HZ*ch->lineup_delay;
- add_timer(&ch->lineup_timer);
- idle=0;
- }
- } else {
- idle=0;
- ch->LINE_status(dev, ch->line_status |= LINE_UP);
- }
- } else { /* Vonal le */
- idle=0;
- if (test_and_clear_bit(0, &ch->lineup_pending)) {
- del_timer(&ch->lineup_timer);
- } else {
- ch->line_status &= ~LINE_UP;
- if (ch->LINE_status) {
- ch->LINE_status(dev, ch->line_status);
- }
- }
- }
- return idle;
-}
-
-
-
-static irqreturn_t COMX_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct net_device *dev = dev_id;
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct net_device *interrupted;
- unsigned long jiffs;
- char idle = 0;
- int count = 0;
- word tmp;
-
- if (dev == NULL) {
- printk(KERN_ERR "COMX_interrupt: irq %d for unknown device\n", irq);
- return IRQ_NONE;
- }
-
- jiffs = jiffies;
-
- interrupted = ch->HW_access_board(dev);
-
- while (!idle && count < 5000) {
- char channel = 0;
- idle = 1;
-
- while (channel < 2) {
- char linestat = 0;
- char buffers_emptied = 0;
-
- if (channel == 1) {
- if (ch->twin) {
- dev = ch->twin;
- ch = dev->priv;
- hw = ch->HW_privdata;
- } else {
- break;
- }
- } else {
- COMX_WRITE(dev, OFF_A_L1_REPENA,
- COMX_readw(dev, OFF_A_L1_REPENA) & 0xFF00);
- }
- channel++;
-
- if ((ch->init_status & (HW_OPEN | LINE_OPEN)) !=
- (HW_OPEN | LINE_OPEN)) {
- continue;
- }
-
- /* Collect stats */
- tmp = COMX_readw(dev, OFF_A_L1_ABOREC);
- COMX_WRITE(dev, OFF_A_L1_ABOREC, 0);
- if(tmp==0xffff) {
- printk(KERN_ERR "%s: OFF_A_L1_ABOREC is %d\n",dev->name,tmp);
- break;
- } else {
- ch->stats.rx_missed_errors += (tmp >> 8) & 0xff;
- ch->stats.rx_over_errors += tmp & 0xff;
- }
- tmp = COMX_readw(dev, OFF_A_L1_CRCREC);
- COMX_WRITE(dev, OFF_A_L1_CRCREC, 0);
- if(tmp==0xffff) {
- printk(KERN_ERR "%s: OFF_A_L1_CRCREC is %d\n",dev->name,tmp);
- break;
- } else {
- ch->stats.rx_crc_errors += (tmp >> 8) & 0xff;
- ch->stats.rx_missed_errors += tmp & 0xff;
- }
-
- if ((ch->line_status & LINE_UP) && ch->LINE_rx) {
- tmp=COMX_readw(dev, OFF_A_L2_DAV);
- while (tmp==1) {
- idle=0;
- buffers_emptied+=comx_read_buffer(dev);
- tmp=COMX_readw(dev, OFF_A_L2_DAV);
- }
- if(tmp) {
- printk(KERN_ERR "%s: OFF_A_L2_DAV is %d\n", dev->name, tmp);
- break;
- }
- }
-
- tmp=COMX_readw(dev, OFF_A_L2_TxEMPTY);
- if (tmp==1 && ch->LINE_tx) {
- ch->LINE_tx(dev);
- }
- if(tmp==0xffff) {
- printk(KERN_ERR "%s: OFF_A_L2_TxEMPTY is %d\n", dev->name, tmp);
- break;
- }
-
- if (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) {
- linestat &= ~LINE_UP;
- } else {
- linestat |= LINE_UP;
- }
-
- if ((linestat & LINE_UP) != (ch->line_status & LINE_UP)) {
- ch->stats.tx_carrier_errors++;
- idle &= comx_line_change(dev,linestat);
- }
-
- hw->histogram[(int)buffers_emptied]++;
- }
- count++;
- }
-
- if(count==5000) {
- printk(KERN_WARNING "%s: interrupt stuck\n",dev->name);
- }
-
- ch->HW_release_board(dev, interrupted);
- return IRQ_HANDLED;
-}
-
-static int COMX_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- unsigned long jiffs;
- int twin_open=0;
- int retval;
- struct net_device *savep;
-
- if (!dev->base_addr || !dev->irq || !dev->mem_start) {
- return -ENODEV;
- }
-
- if (ch->twin && (((struct comx_channel *)(ch->twin->priv))->init_status & HW_OPEN)) {
- twin_open=1;
- }
-
- if (!twin_open) {
- if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
- return -EAGAIN;
- }
- if (request_irq(dev->irq, COMX_interrupt, 0, dev->name,
- (void *)dev)) {
- printk(KERN_ERR "comx-hw-comx: unable to obtain irq %d\n", dev->irq);
- release_region(dev->base_addr, hw->io_extent);
- return -EAGAIN;
- }
- ch->init_status |= IRQ_ALLOCATED;
- if (!ch->HW_load_board || ch->HW_load_board(dev)) {
- ch->init_status &= ~IRQ_ALLOCATED;
- retval=-ENODEV;
- goto error;
- }
- }
-
- savep = ch->HW_access_board(dev);
- COMX_WRITE(dev, OFF_A_L2_LINKUP, 0);
-
- if (ch->HW_set_clock) {
- ch->HW_set_clock(dev);
- }
-
- COMX_CMD(dev, COMX_CMD_INIT);
- jiffs = jiffies;
- while (COMX_readw(dev, OFF_A_L2_LINKUP) != 1 && time_before(jiffies, jiffs + HZ)) {
- schedule_timeout(1);
- }
-
- if (time_after_eq(jiffies, jiffs + HZ)) {
- printk(KERN_ERR "%s: board timeout on INIT command\n", dev->name);
- ch->HW_release_board(dev, savep);
- retval=-EIO;
- goto error;
- }
- udelay(1000);
-
- COMX_CMD(dev, COMX_CMD_OPEN);
-
- jiffs = jiffies;
- while (COMX_readw(dev, OFF_A_L2_LINKUP) != 3 && time_before(jiffies, jiffs + HZ)) {
- schedule_timeout(1);
- }
-
- if (time_after_eq(jiffies, jiffs + HZ)) {
- printk(KERN_ERR "%s: board timeout on OPEN command\n", dev->name);
- ch->HW_release_board(dev, savep);
- retval=-EIO;
- goto error;
- }
-
- ch->init_status |= HW_OPEN;
-
- /* Ez eleg ciki, de ilyen a rendszer */
- if (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) {
- ch->line_status &= ~LINE_UP;
- } else {
- ch->line_status |= LINE_UP;
- }
-
- if (ch->LINE_status) {
- ch->LINE_status(dev, ch->line_status);
- }
-
- ch->HW_release_board(dev, savep);
-
- for ( ; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IRQ) == 0
- || strcmp(procfile->name, FILENAME_IO) == 0
- || strcmp(procfile->name, FILENAME_MEMADDR) == 0
- || strcmp(procfile->name, FILENAME_CHANNEL) == 0
- || strcmp(procfile->name, FILENAME_FIRMWARE) == 0
- || strcmp(procfile->name, FILENAME_CLOCK) == 0) {
- procfile->mode = S_IFREG | 0444;
-
- }
- }
-
- return 0;
-
-error:
- if(!twin_open) {
- release_region(dev->base_addr, hw->io_extent);
- free_irq(dev->irq, (void *)dev);
- }
- return retval;
-
-}
-
-static int COMX_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- struct comx_privdata *hw = ch->HW_privdata;
- struct comx_channel *twin_ch;
- struct net_device *savep;
-
- savep = ch->HW_access_board(dev);
-
- COMX_CMD(dev, COMX_CMD_CLOSE);
- udelay(1000);
- COMX_CMD(dev, COMX_CMD_EXIT);
-
- ch->HW_release_board(dev, savep);
-
- if (ch->init_status & IRQ_ALLOCATED) {
- free_irq(dev->irq, (void *)dev);
- ch->init_status &= ~IRQ_ALLOCATED;
- }
- release_region(dev->base_addr, hw->io_extent);
-
- if (ch->twin && (twin_ch = ch->twin->priv) &&
- (twin_ch->init_status & HW_OPEN)) {
- /* Pass the irq to the twin */
- if (request_irq(dev->irq, COMX_interrupt, 0, ch->twin->name,
- (void *)ch->twin) == 0) {
- twin_ch->init_status |= IRQ_ALLOCATED;
- }
- }
-
- for ( ; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IRQ) == 0
- || strcmp(procfile->name, FILENAME_IO) == 0
- || strcmp(procfile->name, FILENAME_MEMADDR) == 0
- || strcmp(procfile->name, FILENAME_CHANNEL) == 0
- || strcmp(procfile->name, FILENAME_FIRMWARE) == 0
- || strcmp(procfile->name, FILENAME_CLOCK) == 0) {
- procfile->mode = S_IFREG | 0644;
- }
- }
-
- ch->init_status &= ~HW_OPEN;
- return 0;
-}
-
-static int COMX_statistics(struct net_device *dev, char *page)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct net_device *savep;
- int len = 0;
-
- savep = ch->HW_access_board(dev);
-
- len += sprintf(page + len, "Board data: %s %s %s %s\nPBUFOVR: %02x, "
- "MODSTAT: %02x, LINKUP: %02x, DAV: %02x\nRxBUFP: %02x, "
- "TxEMPTY: %02x, TxBUFP: %02x\n",
- (ch->init_status & HW_OPEN) ? "HW_OPEN" : "",
- (ch->init_status & LINE_OPEN) ? "LINE_OPEN" : "",
- (ch->init_status & FW_LOADED) ? "FW_LOADED" : "",
- (ch->init_status & IRQ_ALLOCATED) ? "IRQ_ALLOCATED" : "",
- COMX_readw(dev, OFF_A_L1_PBUFOVR) & 0xff,
- (COMX_readw(dev, OFF_A_L1_PBUFOVR) >> 8) & 0xff,
- COMX_readw(dev, OFF_A_L2_LINKUP) & 0xff,
- COMX_readw(dev, OFF_A_L2_DAV) & 0xff,
- COMX_readw(dev, OFF_A_L2_RxBUFP) & 0xff,
- COMX_readw(dev, OFF_A_L2_TxEMPTY) & 0xff,
- COMX_readw(dev, OFF_A_L2_TxBUFP) & 0xff);
-
- len += sprintf(page + len, "hist[0]: %8lu hist[1]: %8lu hist[2]: %8lu\n"
- "hist[3]: %8lu hist[4]: %8lu\n",hw->histogram[0],hw->histogram[1],
- hw->histogram[2],hw->histogram[3],hw->histogram[4]);
-
- ch->HW_release_board(dev, savep);
-
- return len;
-}
-
-static int COMX_load_board(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct comx_firmware *fw = hw->firmware;
- word board_segment = dev->mem_start >> 16;
- int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
- unsigned long flags;
- unsigned char id1, id2;
- struct net_device *saved;
- int retval;
- int loopcount;
- int len;
- byte *COMX_address;
-
- if (!fw || !fw->len) {
- struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
- struct comx_privdata *twin_hw;
-
- if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
- return -EAGAIN;
- }
-
- if (!(fw = twin_hw->firmware) || !fw->len) {
- return -EAGAIN;
- }
- }
-
- id1 = fw->data[OFF_FW_L1_ID];
- id2 = fw->data[OFF_FW_L1_ID + 1];
-
- if (id1 != FW_L1_ID_1 || id2 != FW_L1_ID_2_COMX) {
- printk(KERN_ERR "%s: incorrect firmware, load aborted\n",
- dev->name);
- return -EAGAIN;
- }
-
- printk(KERN_INFO "%s: Loading COMX Layer 1 firmware %s\n", dev->name,
- (char *)(fw->data + OFF_FW_L1_ID + 2));
-
- id1 = fw->data[OFF_FW_L2_ID];
- id2 = fw->data[OFF_FW_L2_ID + 1];
- if (id1 == FW_L2_ID_1 && (id2 == 0xc0 || id2 == 0xc1 || id2 == 0xc2)) {
- printk(KERN_INFO "with Layer 2 code %s\n",
- (char *)(fw->data + OFF_FW_L2_ID + 2));
- }
-
- outb_p(board_segment | COMX_BOARD_RESET, dev->base_addr);
- /* 10 usec should be enough here */
- udelay(100);
-
- save_flags(flags); cli();
- saved=memory_used[mempos];
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_off(saved);
- }
- memory_used[mempos]=dev;
-
- outb_p(board_segment | COMX_ENABLE_BOARD_MEM, dev->base_addr);
-
- writeb(0, dev->mem_start + COMX_JAIL_OFFSET);
-
- loopcount=0;
- while(loopcount++ < 10000 &&
- readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
- udelay(100);
- }
-
- if (readb(dev->mem_start + COMX_JAIL_OFFSET) != COMX_JAIL_VALUE) {
- printk(KERN_ERR "%s: Can't reset board, JAIL value is %02x\n",
- dev->name, readb(dev->mem_start + COMX_JAIL_OFFSET));
- retval=-ENODEV;
- goto out;
- }
-
- writeb(0x55, dev->mem_start + 0x18ff);
-
- loopcount=0;
- while(loopcount++ < 10000 && readb(dev->mem_start + 0x18ff) != 0) {
- udelay(100);
- }
-
- if(readb(dev->mem_start + 0x18ff) != 0) {
- printk(KERN_ERR "%s: Can't reset board, reset timeout\n",
- dev->name);
- retval=-ENODEV;
- goto out;
- }
-
- len = 0;
- COMX_address = (byte *)dev->mem_start;
- while (fw->len > len) {
- writeb(fw->data[len++], COMX_address++);
- }
-
- len = 0;
- COMX_address = (byte *)dev->mem_start;
- while (len != fw->len && readb(COMX_address++) == fw->data[len]) {
- len++;
- }
-
- if (len != fw->len) {
- printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
- "instead of 0x%02x\n", dev->name, len,
- readb(COMX_address - 1), fw->data[len]);
- retval=-EAGAIN;
- goto out;
- }
-
- writeb(0, dev->mem_start + COMX_JAIL_OFFSET);
-
- loopcount = 0;
- while ( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
- udelay(100);
- }
-
- if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
- printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
- dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
- retval=-EAGAIN;
- goto out;
- }
-
-
- ch->init_status |= FW_LOADED;
- retval=0;
-
-out:
- outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_on(saved);
- }
- memory_used[mempos]=saved;
- restore_flags(flags);
- return retval;
-}
-
-static int CMX_load_board(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct comx_firmware *fw = hw->firmware;
- word board_segment = dev->mem_start >> 16;
- int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
- #if 0
- unsigned char id1, id2;
- #endif
- struct net_device *saved;
- unsigned long flags;
- int retval;
- int loopcount;
- int len;
- byte *COMX_address;
-
- if (!fw || !fw->len) {
- struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
- struct comx_privdata *twin_hw;
-
- if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
- return -EAGAIN;
- }
-
- if (!(fw = twin_hw->firmware) || !fw->len) {
- return -EAGAIN;
- }
- }
-
- /* Ide kell olyat tenni, hogy ellenorizze az ID-t */
-
- if (inb_p(dev->base_addr) != CMX_ID_BYTE) {
- printk(KERN_ERR "%s: CMX id byte is invalid(%02x)\n", dev->name,
- inb_p(dev->base_addr));
- return -ENODEV;
- }
-
- printk(KERN_INFO "%s: Loading CMX Layer 1 firmware %s\n", dev->name,
- (char *)(fw->data + OFF_FW_L1_ID + 2));
-
- save_flags(flags); cli();
- saved=memory_used[mempos];
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_off(saved);
- }
- memory_used[mempos]=dev;
-
- outb_p(board_segment | COMX_ENABLE_BOARD_MEM | COMX_BOARD_RESET,
- dev->base_addr);
-
- len = 0;
- COMX_address = (byte *)dev->mem_start;
- while (fw->len > len) {
- writeb(fw->data[len++], COMX_address++);
- }
-
- len = 0;
- COMX_address = (byte *)dev->mem_start;
- while (len != fw->len && readb(COMX_address++) == fw->data[len]) {
- len++;
- }
-
- outb_p(board_segment | COMX_ENABLE_BOARD_MEM, dev->base_addr);
-
- if (len != fw->len) {
- printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
- "instead of 0x%02x\n", dev->name, len,
- readb(COMX_address - 1), fw->data[len]);
- retval=-EAGAIN;
- goto out;
- }
-
- loopcount=0;
- while( loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
- udelay(100);
- }
-
- if (COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
- printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
- dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
- retval=-EAGAIN;
- goto out;
- }
-
- ch->init_status |= FW_LOADED;
- retval=0;
-
-out:
- outb_p(board_segment | COMX_DISABLE_ALL, dev->base_addr);
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_on(saved);
- }
- memory_used[mempos]=saved;
- restore_flags(flags);
- return retval;
-}
-
-static int HICOMX_load_board(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- struct comx_firmware *fw = hw->firmware;
- word board_segment = dev->mem_start >> 12;
- int mempos = (dev->mem_start - COMX_MEM_MIN) >> 16;
- struct net_device *saved;
- unsigned char id1, id2;
- unsigned long flags;
- int retval;
- int loopcount;
- int len;
- word *HICOMX_address;
- char id = 1;
-
- if (!fw || !fw->len) {
- struct comx_channel *twin_ch = ch->twin ? ch->twin->priv : NULL;
- struct comx_privdata *twin_hw;
-
- if (!twin_ch || !(twin_hw = twin_ch->HW_privdata)) {
- return -EAGAIN;
- }
-
- if (!(fw = twin_hw->firmware) || !fw->len) {
- return -EAGAIN;
- }
- }
-
- while (id != 4) {
- if (inb_p(dev->base_addr + id++) != HICOMX_ID_BYTE) {
- break;
- }
- }
-
- if (id != 4) {
- printk(KERN_ERR "%s: can't find HICOMX at 0x%04x, id[%d] = %02x\n",
- dev->name, (unsigned int)dev->base_addr, id - 1,
- inb_p(dev->base_addr + id - 1));
- return -1;
- }
-
- id1 = fw->data[OFF_FW_L1_ID];
- id2 = fw->data[OFF_FW_L1_ID + 1];
- if (id1 != FW_L1_ID_1 || id2 != FW_L1_ID_2_HICOMX) {
- printk(KERN_ERR "%s: incorrect firmware, load aborted\n", dev->name);
- return -EAGAIN;
- }
-
- printk(KERN_INFO "%s: Loading HICOMX Layer 1 firmware %s\n", dev->name,
- (char *)(fw->data + OFF_FW_L1_ID + 2));
-
- id1 = fw->data[OFF_FW_L2_ID];
- id2 = fw->data[OFF_FW_L2_ID + 1];
- if (id1 == FW_L2_ID_1 && (id2 == 0xc0 || id2 == 0xc1 || id2 == 0xc2)) {
- printk(KERN_INFO "with Layer 2 code %s\n",
- (char *)(fw->data + OFF_FW_L2_ID + 2));
- }
-
- outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
- udelay(10);
-
- save_flags(flags); cli();
- saved=memory_used[mempos];
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_off(saved);
- }
- memory_used[mempos]=dev;
-
- outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
- outb_p(HICOMX_PRG_MEM, dev->base_addr + 1);
-
- len = 0;
- HICOMX_address = (word *)dev->mem_start;
- while (fw->len > len) {
- writeb(fw->data[len++], HICOMX_address++);
- }
-
- len = 0;
- HICOMX_address = (word *)dev->mem_start;
- while (len != fw->len && (readw(HICOMX_address++) & 0xff) == fw->data[len]) {
- len++;
- }
-
- if (len != fw->len) {
- printk(KERN_ERR "%s: error loading firmware: [%d] is 0x%02x "
- "instead of 0x%02x\n", dev->name, len,
- readw(HICOMX_address - 1) & 0xff, fw->data[len]);
- retval=-EAGAIN;
- goto out;
- }
-
- outb_p(board_segment | HICOMX_BOARD_RESET, dev->base_addr);
- outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
-
- outb_p(board_segment | HICOMX_ENABLE_BOARD_MEM, dev->base_addr);
-
- loopcount=0;
- while(loopcount++ < 10000 && COMX_readw(dev, OFF_A_L2_LINKUP) != 1) {
- udelay(100);
- }
-
- if ( COMX_readw(dev, OFF_A_L2_LINKUP) != 1 ) {
- printk(KERN_ERR "%s: error starting firmware, linkup word is %04x\n",
- dev->name, COMX_readw(dev, OFF_A_L2_LINKUP));
- retval=-EAGAIN;
- goto out;
- }
-
- ch->init_status |= FW_LOADED;
- retval=0;
-
-out:
- outb_p(board_segment | HICOMX_DISABLE_ALL, dev->base_addr);
- outb_p(HICOMX_DATA_MEM, dev->base_addr + 1);
-
- if(saved) {
- ((struct comx_channel *)saved->priv)->HW_board_on(saved);
- }
- memory_used[mempos]=saved;
- restore_flags(flags);
- return retval;
-}
-
-static struct net_device *comx_twin_check(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *procfile = ch->procdir->parent->subdir;
- struct comx_privdata *hw = ch->HW_privdata;
-
- struct net_device *twin;
- struct comx_channel *ch_twin;
- struct comx_privdata *hw_twin;
-
-
- for ( ; procfile ; procfile = procfile->next) {
-
- if(!S_ISDIR(procfile->mode)) {
- continue;
- }
-
- twin=procfile->data;
- ch_twin=twin->priv;
- hw_twin=ch_twin->HW_privdata;
-
-
- if (twin != dev && dev->irq && dev->base_addr && dev->mem_start &&
- dev->irq == twin->irq && dev->base_addr == twin->base_addr &&
- dev->mem_start == twin->mem_start &&
- hw->channel == (1 - hw_twin->channel) &&
- ch->hardware == ch_twin->hardware) {
- return twin;
- }
- }
- return NULL;
-}
-
-static int comxhw_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = entry->parent->data;
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- char *page;
-
-
- if(ch->init_status & HW_OPEN) {
- return -EAGAIN;
- }
-
- if (strcmp(FILENAME_FIRMWARE, entry->name) != 0) {
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
- return -ENOMEM;
- }
- if(copy_from_user(page, buffer, count = (min_t(int, count, PAGE_SIZE))))
- {
- count = -EFAULT;
- goto out;
- }
- if (page[count-1] == '\n')
- page[count-1] = '\0';
- else if (count < PAGE_SIZE)
- page[count] = '\0';
- else if (page[count]) {
- count = -EINVAL;
- goto out;
- }
- page[count]=0; /* Null terminate */
- } else {
- byte *tmp;
-
- if (!hw->firmware) {
- if ((hw->firmware = kmalloc(sizeof(struct comx_firmware),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- hw->firmware->len = 0;
- hw->firmware->data = NULL;
- }
-
- if ((tmp = kmalloc(count + file->f_pos, GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
-
- /* Ha nem 0 a fpos, akkor meglevo file-t irunk. Gyenge trukk. */
- if (hw->firmware && hw->firmware->len && file->f_pos
- && hw->firmware->len < count + file->f_pos) {
- memcpy(tmp, hw->firmware->data, hw->firmware->len);
- }
- if (hw->firmware->data) {
- kfree(hw->firmware->data);
- }
- if (copy_from_user(tmp + file->f_pos, buffer, count))
- return -EFAULT;
- hw->firmware->len = entry->size = file->f_pos + count;
- hw->firmware->data = tmp;
- file->f_pos += count;
- return count;
- }
-
- if (strcmp(entry->name, FILENAME_CHANNEL) == 0) {
- hw->channel = simple_strtoul(page, NULL, 0);
- if (hw->channel >= MAX_CHANNELNO) {
- printk(KERN_ERR "Invalid channel number\n");
- hw->channel = 0;
- }
- if ((ch->twin = comx_twin_check(dev)) != NULL) {
- struct comx_channel *twin_ch = ch->twin->priv;
- twin_ch->twin = dev;
- }
- } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
- dev->irq = simple_strtoul(page, NULL, 0);
- if (dev->irq == 2) {
- dev->irq = 9;
- }
- if (dev->irq < 3 || dev->irq > 15) {
- printk(KERN_ERR "comxhw: Invalid irq number\n");
- dev->irq = 0;
- }
- if ((ch->twin = comx_twin_check(dev)) != NULL) {
- struct comx_channel *twin_ch = ch->twin->priv;
- twin_ch->twin = dev;
- }
- } else if (strcmp(entry->name, FILENAME_IO) == 0) {
- dev->base_addr = simple_strtoul(page, NULL, 0);
- if ((dev->base_addr & 3) != 0 || dev->base_addr < 0x300
- || dev->base_addr > 0x3fc) {
- printk(KERN_ERR "Invalid io value\n");
- dev->base_addr = 0;
- }
- if ((ch->twin = comx_twin_check(dev)) != NULL) {
- struct comx_channel *twin_ch = ch->twin->priv;
-
- twin_ch->twin = dev;
- }
- } else if (strcmp(entry->name, FILENAME_MEMADDR) == 0) {
- dev->mem_start = simple_strtoul(page, NULL, 0);
- if (dev->mem_start <= 0xf000 && dev->mem_start >= 0xa000) {
- dev->mem_start *= 16;
- }
- if ((dev->mem_start & 0xfff) != 0 || dev->mem_start < COMX_MEM_MIN
- || dev->mem_start + hw->memory_size > COMX_MEM_MAX) {
- printk(KERN_ERR "Invalid memory page\n");
- dev->mem_start = 0;
- }
- dev->mem_end = dev->mem_start + hw->memory_size;
- if ((ch->twin = comx_twin_check(dev)) != NULL) {
- struct comx_channel *twin_ch = ch->twin->priv;
-
- twin_ch->twin = dev;
- }
- } else if (strcmp(entry->name, FILENAME_CLOCK) == 0) {
- if (strncmp("ext", page, 3) == 0) {
- hw->clock = 0;
- } else {
- int kbps;
-
- kbps = simple_strtoul(page, NULL, 0);
- hw->clock = kbps ? COMX_CLOCK_CONST/kbps : 0;
- }
- }
-out:
- free_page((unsigned long)page);
- return count;
-}
-
-static int comxhw_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
- int len = 0;
-
-
- if (strcmp(file->name, FILENAME_IO) == 0) {
- len = sprintf(page, "0x%03x\n", (unsigned int)dev->base_addr);
- } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
- len = sprintf(page, "0x%02x\n", dev->irq == 9 ? 2 : dev->irq);
- } else if (strcmp(file->name, FILENAME_CHANNEL) == 0) {
- len = sprintf(page, "%01d\n", hw->channel);
- } else if (strcmp(file->name, FILENAME_MEMADDR) == 0) {
- len = sprintf(page, "0x%05x\n", (unsigned int)dev->mem_start);
- } else if (strcmp(file->name, FILENAME_TWIN) == 0) {
- len = sprintf(page, "%s\n", ch->twin ? ch->twin->name : "none");
- } else if (strcmp(file->name, FILENAME_CLOCK) == 0) {
- if (hw->clock) {
- len = sprintf(page, "%-8d\n", COMX_CLOCK_CONST/hw->clock);
- } else {
- len = sprintf(page, "external\n");
- }
- } else if (strcmp(file->name, FILENAME_FIRMWARE) == 0) {
- len = min_t(int, FILE_PAGESIZE,
- min_t(int, count,
- hw->firmware ?
- (hw->firmware->len - off) : 0));
- if (len < 0) {
- len = 0;
- }
- *start = hw->firmware ? (hw->firmware->data + off) : NULL;
- if (off + len >= (hw->firmware ? hw->firmware->len : 0) || len == 0) {
- *eof = 1;
- }
- return len;
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) {
- *eof = 1;
- }
- return min_t(int, count, len - off);
-}
-
-/* Called on echo comx >boardtype */
-static int COMX_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw;
- struct proc_dir_entry *new_file;
-
- if ((ch->HW_privdata = kmalloc(sizeof(struct comx_privdata),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- memset(hw = ch->HW_privdata, 0, sizeof(struct comx_privdata));
-
- if (ch->hardware == &comx_hw || ch->hardware == &cmx_hw) {
- hw->memory_size = COMX_MEMORY_SIZE;
- hw->io_extent = COMX_IO_EXTENT;
- dev->base_addr = COMX_DEFAULT_IO;
- dev->irq = COMX_DEFAULT_IRQ;
- dev->mem_start = COMX_DEFAULT_MEMADDR;
- dev->mem_end = COMX_DEFAULT_MEMADDR + COMX_MEMORY_SIZE;
- } else if (ch->hardware == &hicomx_hw) {
- hw->memory_size = HICOMX_MEMORY_SIZE;
- hw->io_extent = HICOMX_IO_EXTENT;
- dev->base_addr = HICOMX_DEFAULT_IO;
- dev->irq = HICOMX_DEFAULT_IRQ;
- dev->mem_start = HICOMX_DEFAULT_MEMADDR;
- dev->mem_end = HICOMX_DEFAULT_MEMADDR + HICOMX_MEMORY_SIZE;
- } else {
- printk(KERN_ERR "SERIOUS INTERNAL ERROR in %s, line %d\n", __FILE__, __LINE__);
- }
-
- if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644, ch->procdir))
- == NULL) {
- goto cleanup_HW_privdata;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->size = 6;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644, ch->procdir))
- == NULL) {
- goto cleanup_filename_io;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->size = 5;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_CHANNEL, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_irq;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->size = 2; // Ezt tudjuk
- new_file->nlink = 1;
-
- if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw) {
- if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_channel;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->size = 9;
- new_file->nlink = 1;
- }
-
- if ((new_file = create_proc_entry(FILENAME_MEMADDR, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_clock;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->size = 8;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_TWIN, S_IFREG | 0444,
- ch->procdir)) == NULL) {
- goto cleanup_filename_memaddr;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = NULL;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_FIRMWARE, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_twin;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxhw_read_proc;
- new_file->write_proc = &comxhw_write_proc;
- new_file->nlink = 1;
-
- if (ch->hardware == &comx_hw) {
- ch->HW_board_on = COMX_board_on;
- ch->HW_board_off = COMX_board_off;
- ch->HW_load_board = COMX_load_board;
- } else if (ch->hardware == &cmx_hw) {
- ch->HW_board_on = COMX_board_on;
- ch->HW_board_off = COMX_board_off;
- ch->HW_load_board = CMX_load_board;
- ch->HW_set_clock = COMX_set_clock;
- } else if (ch->hardware == &hicomx_hw) {
- ch->HW_board_on = HICOMX_board_on;
- ch->HW_board_off = HICOMX_board_off;
- ch->HW_load_board = HICOMX_load_board;
- ch->HW_set_clock = COMX_set_clock;
- } else {
- printk(KERN_ERR "SERIOUS INTERNAL ERROR in %s, line %d\n", __FILE__, __LINE__);
- }
-
- ch->HW_access_board = COMX_access_board;
- ch->HW_release_board = COMX_release_board;
- ch->HW_txe = COMX_txe;
- ch->HW_open = COMX_open;
- ch->HW_close = COMX_close;
- ch->HW_send_packet = COMX_send_packet;
- ch->HW_statistics = COMX_statistics;
-
- if ((ch->twin = comx_twin_check(dev)) != NULL) {
- struct comx_channel *twin_ch = ch->twin->priv;
-
- twin_ch->twin = dev;
- }
-
- MOD_INC_USE_COUNT;
- return 0;
-
-cleanup_filename_twin:
- remove_proc_entry(FILENAME_TWIN, ch->procdir);
-cleanup_filename_memaddr:
- remove_proc_entry(FILENAME_MEMADDR, ch->procdir);
-cleanup_filename_clock:
- if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw)
- remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-cleanup_filename_channel:
- remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-cleanup_filename_irq:
- remove_proc_entry(FILENAME_IRQ, ch->procdir);
-cleanup_filename_io:
- remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
- kfree(ch->HW_privdata);
- return -EIO;
-}
-
-/* Called on echo valami >boardtype */
-static int COMX_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_privdata *hw = ch->HW_privdata;
-
- if (hw->firmware) {
- if (hw->firmware->data) kfree(hw->firmware->data);
- kfree(hw->firmware);
- } if (ch->twin) {
- struct comx_channel *twin_ch = ch->twin->priv;
-
- twin_ch->twin = NULL;
- }
-
- kfree(ch->HW_privdata);
- remove_proc_entry(FILENAME_IO, ch->procdir);
- remove_proc_entry(FILENAME_IRQ, ch->procdir);
- remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
- remove_proc_entry(FILENAME_MEMADDR, ch->procdir);
- remove_proc_entry(FILENAME_FIRMWARE, ch->procdir);
- remove_proc_entry(FILENAME_TWIN, ch->procdir);
- if (ch->hardware == &hicomx_hw || ch->hardware == &cmx_hw) {
- remove_proc_entry(FILENAME_CLOCK, ch->procdir);
- }
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int COMX_dump(struct net_device *dev)
-{
- printk(KERN_INFO "%s: COMX_dump called, why ?\n", dev->name);
- return 0;
-}
-
-static struct comx_hardware comx_hw = {
- "comx",
- VERSION,
- COMX_init,
- COMX_exit,
- COMX_dump,
- NULL
-};
-
-static struct comx_hardware cmx_hw = {
- "cmx",
- VERSION,
- COMX_init,
- COMX_exit,
- COMX_dump,
- NULL
-};
-
-static struct comx_hardware hicomx_hw = {
- "hicomx",
- VERSION,
- COMX_init,
- COMX_exit,
- COMX_dump,
- NULL
-};
-
-static int __init comx_hw_comx_init(void)
-{
- comx_register_hardware(&comx_hw);
- comx_register_hardware(&cmx_hw);
- comx_register_hardware(&hicomx_hw);
- return 0;
-}
-
-static void __exit comx_hw_comx_exit(void)
-{
- comx_unregister_hardware("comx");
- comx_unregister_hardware("cmx");
- comx_unregister_hardware("hicomx");
-}
-
-module_init(comx_hw_comx_init);
-module_exit(comx_hw_comx_exit);
+++ /dev/null
-/*
- * Hardware driver for the LoCOMX card, using the generic z85230
- * functions
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * Based on skeleton code and old LoCOMX driver by Tivadar Szemethy <tiv@itc.hu>
- * and the hostess_sv11 driver
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.14)
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.10 (99/06/17):
- * - rewritten for the z85230 layer
- *
- * Version 0.11 (99/06/21):
- * - some printk's fixed
- * - get rid of a memory leak (it was impossible though :))
- *
- * Version 0.12 (99/07/07):
- * - check CTS for modem lines, not DCD (which is always high
- * in case of this board)
- * Version 0.13 (99/07/08):
- * - Fix the transmitter status check
- * - Handle the net device statistics better
- * Version 0.14 (00/08/15):
- * - resource release on failure at LOCOMX_init
- */
-
-#define VERSION "0.14"
-
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-#include <asm/dma.h>
-
-#include "comx.h"
-#include "z85230.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Hardware driver for the LoCOMX board");
-MODULE_LICENSE("GPL");
-
-#define RX_DMA 3
-#define TX_DMA 1
-#define LOCOMX_ID 0x33
-#define LOCOMX_IO_EXTENT 8
-#define LOCOMX_DEFAULT_IO 0x368
-#define LOCOMX_DEFAULT_IRQ 7
-
-u8 z8530_locomx[] = {
- 11, TCRTxCP,
- 14, DTRREQ,
- 255
-};
-
-struct locomx_data {
- int io_extent;
- struct z8530_dev board;
- struct timer_list status_timer;
-};
-
-static int LOCOMX_txe(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw = ch->HW_privdata;
-
- return (!hw->board.chanA.tx_next_skb);
-}
-
-
-static void locomx_rx(struct z8530_channel *c, struct sk_buff *skb)
-{
- struct net_device *dev = c->netdevice;
- struct comx_channel *ch = netdev_priv(dev);
-
- if (ch->debug_flags & DEBUG_HW_RX) {
- comx_debug_skb(dev, skb, "locomx_rx receiving");
- }
- ch->LINE_rx(dev,skb);
-}
-
-static int LOCOMX_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw = ch->HW_privdata;
-
- if (ch->debug_flags & DEBUG_HW_TX) {
- comx_debug_bytes(dev, skb->data, skb->len, "LOCOMX_send_packet");
- }
-
- if (!(ch->line_status & LINE_UP)) {
- return FRAME_DROPPED;
- }
-
- if(z8530_queue_xmit(&hw->board.chanA,skb)) {
- printk(KERN_WARNING "%s: FRAME_DROPPED\n",dev->name);
- return FRAME_DROPPED;
- }
-
- if (ch->debug_flags & DEBUG_HW_TX) {
- comx_debug(dev, "%s: LOCOMX_send_packet was successful\n\n", dev->name);
- }
-
- if(!hw->board.chanA.tx_next_skb) {
- return FRAME_QUEUED;
- } else {
- return FRAME_ACCEPTED;
- }
-}
-
-static void locomx_status_timerfun(unsigned long d)
-{
- struct net_device *dev = (struct net_device *)d;
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw = ch->HW_privdata;
-
- if(!(ch->line_status & LINE_UP) &&
- (hw->board.chanA.status & CTS)) {
- ch->LINE_status(dev, ch->line_status | LINE_UP);
- }
- if((ch->line_status & LINE_UP) &&
- !(hw->board.chanA.status & CTS)) {
- ch->LINE_status(dev, ch->line_status & ~LINE_UP);
- }
- mod_timer(&hw->status_timer,jiffies + ch->lineup_delay * HZ);
-}
-
-
-static int LOCOMX_open(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- unsigned long flags;
- int ret;
-
- if (!dev->base_addr || !dev->irq) {
- return -ENODEV;
- }
-
- if (!request_region(dev->base_addr, hw->io_extent, dev->name)) {
- return -EAGAIN;
- }
-
- hw->board.chanA.ctrlio=dev->base_addr + 5;
- hw->board.chanA.dataio=dev->base_addr + 7;
-
- hw->board.irq=dev->irq;
- hw->board.chanA.netdevice=dev;
- hw->board.chanA.dev=&hw->board;
- hw->board.name=dev->name;
- hw->board.chanA.txdma=TX_DMA;
- hw->board.chanA.rxdma=RX_DMA;
- hw->board.chanA.irqs=&z8530_nop;
- hw->board.chanB.irqs=&z8530_nop;
-
- if(request_irq(dev->irq, z8530_interrupt, SA_INTERRUPT,
- dev->name, &hw->board)) {
- printk(KERN_ERR "%s: unable to obtain irq %d\n", dev->name,
- dev->irq);
- ret=-EAGAIN;
- goto irq_fail;
- }
- if(request_dma(TX_DMA,"LoCOMX (TX)")) {
- printk(KERN_ERR "%s: unable to obtain TX DMA (DMA channel %d)\n",
- dev->name, TX_DMA);
- ret=-EAGAIN;
- goto dma1_fail;
- }
-
- if(request_dma(RX_DMA,"LoCOMX (RX)")) {
- printk(KERN_ERR "%s: unable to obtain RX DMA (DMA channel %d)\n",
- dev->name, RX_DMA);
- ret=-EAGAIN;
- goto dma2_fail;
- }
-
- save_flags(flags);
- cli();
-
- if(z8530_init(&hw->board)!=0)
- {
- printk(KERN_ERR "%s: Z8530 device not found.\n",dev->name);
- ret=-ENODEV;
- goto z8530_fail;
- }
-
- hw->board.chanA.dcdcheck=CTS;
-
- z8530_channel_load(&hw->board.chanA, z8530_hdlc_kilostream_85230);
- z8530_channel_load(&hw->board.chanA, z8530_locomx);
- z8530_channel_load(&hw->board.chanB, z8530_dead_port);
-
- z8530_describe(&hw->board, "I/O", dev->base_addr);
-
- if((ret=z8530_sync_dma_open(dev, &hw->board.chanA))!=0) {
- goto z8530_fail;
- }
-
- restore_flags(flags);
-
-
- hw->board.active=1;
- hw->board.chanA.rx_function=locomx_rx;
-
- ch->init_status |= HW_OPEN;
- if (hw->board.chanA.status & DCD) {
- ch->line_status |= LINE_UP;
- } else {
- ch->line_status &= ~LINE_UP;
- }
-
- comx_status(dev, ch->line_status);
-
- init_timer(&hw->status_timer);
- hw->status_timer.function=locomx_status_timerfun;
- hw->status_timer.data=(unsigned long)dev;
- hw->status_timer.expires=jiffies + ch->lineup_delay * HZ;
- add_timer(&hw->status_timer);
-
- for (; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IO) == 0 ||
- strcmp(procfile->name, FILENAME_IRQ) == 0) {
- procfile->mode = S_IFREG | 0444;
- }
- }
- return 0;
-
-z8530_fail:
- restore_flags(flags);
- free_dma(RX_DMA);
-dma2_fail:
- free_dma(TX_DMA);
-dma1_fail:
- free_irq(dev->irq, &hw->board);
-irq_fail:
- release_region(dev->base_addr, hw->io_extent);
- return ret;
-}
-
-static int LOCOMX_close(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
-
- hw->board.chanA.rx_function=z8530_null_rx;
- netif_stop_queue(dev);
- z8530_sync_dma_close(dev, &hw->board.chanA);
-
- z8530_shutdown(&hw->board);
-
- del_timer(&hw->status_timer);
- free_dma(RX_DMA);
- free_dma(TX_DMA);
- free_irq(dev->irq,&hw->board);
- release_region(dev->base_addr,8);
-
- for (; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IO) == 0 ||
- strcmp(procfile->name, FILENAME_IRQ) == 0) {
- procfile->mode = S_IFREG | 0644;
- }
- }
-
- ch->init_status &= ~HW_OPEN;
- return 0;
-}
-
-static int LOCOMX_statistics(struct net_device *dev,char *page)
-{
- int len = 0;
-
- len += sprintf(page + len, "Hello\n");
-
- return len;
-}
-
-static int LOCOMX_dump(struct net_device *dev) {
- printk(KERN_INFO "LOCOMX_dump called\n");
- return(-1);
-}
-
-static int locomx_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- int len = 0;
-
- if (strcmp(file->name, FILENAME_IO) == 0) {
- len = sprintf(page, "0x%x\n", (unsigned int)dev->base_addr);
- } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
- len = sprintf(page, "%d\n", (unsigned int)dev->irq);
- } else {
- printk(KERN_ERR "hw_read_proc: internal error, filename %s\n",
- file->name);
- return -EBADF;
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) {
- *eof = 1;
- }
- return min_t(int, count, len - off);
-}
-
-static int locomx_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = (struct net_device *)entry->parent->data;
- int val;
- char *page;
-
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
- return -ENOMEM;
- }
-
- if (copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE))) {
- free_page((unsigned long)page);
- return -EBADF;
- }
- if (*(page + count - 1) == '\n') {
- *(page + count - 1) = 0;
- }
-
- if (strcmp(entry->name, FILENAME_IO) == 0) {
- val = simple_strtoul(page, NULL, 0);
- if (val != 0x360 && val != 0x368 && val != 0x370 &&
- val != 0x378) {
- printk(KERN_ERR "LoCOMX: incorrect io address!\n");
- } else {
- dev->base_addr = val;
- }
- } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
- val = simple_strtoul(page, NULL, 0);
- if (val != 3 && val != 4 && val != 5 && val != 6 && val != 7) {
- printk(KERN_ERR "LoCOMX: incorrect irq value!\n");
- } else {
- dev->irq = val;
- }
- } else {
- printk(KERN_ERR "locomx_write_proc: internal error, filename %s\n",
- entry->name);
- free_page((unsigned long)page);
- return -EBADF;
- }
-
- free_page((unsigned long)page);
- return count;
-}
-
-
-
-static int LOCOMX_init(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct locomx_data *hw;
- struct proc_dir_entry *new_file;
-
- /* Alloc data for private structure */
- if ((ch->HW_privdata = kmalloc(sizeof(struct locomx_data),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
-
- memset(hw = ch->HW_privdata, 0, sizeof(struct locomx_data));
- hw->io_extent = LOCOMX_IO_EXTENT;
-
- /* Register /proc files */
- if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_HW_privdata;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &locomx_read_proc;
- new_file->write_proc = &locomx_write_proc;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_io;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &locomx_read_proc;
- new_file->write_proc = &locomx_write_proc;
- new_file->nlink = 1;
-
-/* No clock yet */
-/*
- if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- return -EIO;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &locomx_read_proc;
- new_file->write_proc = &locomx_write_proc;
- new_file->nlink = 1;
-*/
-
- ch->HW_access_board = NULL;
- ch->HW_release_board = NULL;
- ch->HW_txe = LOCOMX_txe;
- ch->HW_open = LOCOMX_open;
- ch->HW_close = LOCOMX_close;
- ch->HW_send_packet = LOCOMX_send_packet;
- ch->HW_statistics = LOCOMX_statistics;
- ch->HW_set_clock = NULL;
-
- ch->current_stats = &hw->board.chanA.stats;
- memcpy(ch->current_stats, &ch->stats, sizeof(struct net_device_stats));
-
- dev->base_addr = LOCOMX_DEFAULT_IO;
- dev->irq = LOCOMX_DEFAULT_IRQ;
-
-
- /* O.K. Count one more user on this module */
- MOD_INC_USE_COUNT;
- return 0;
-cleanup_filename_io:
- remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
- kfree(ch->HW_privdata);
- return -EIO;
-}
-
-
-static int LOCOMX_exit(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
-
- ch->HW_access_board = NULL;
- ch->HW_release_board = NULL;
- ch->HW_txe = NULL;
- ch->HW_open = NULL;
- ch->HW_close = NULL;
- ch->HW_send_packet = NULL;
- ch->HW_statistics = NULL;
- ch->HW_set_clock = NULL;
- memcpy(&ch->stats, ch->current_stats, sizeof(struct net_device_stats));
- ch->current_stats = &ch->stats;
-
- kfree(ch->HW_privdata);
-
- remove_proc_entry(FILENAME_IO, ch->procdir);
- remove_proc_entry(FILENAME_IRQ, ch->procdir);
-// remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static struct comx_hardware locomx_hw = {
- "locomx",
- VERSION,
- LOCOMX_init,
- LOCOMX_exit,
- LOCOMX_dump,
- NULL
-};
-
-static int __init comx_hw_locomx_init(void)
-{
- comx_register_hardware(&locomx_hw);
- return 0;
-}
-
-static void __exit comx_hw_locomx_exit(void)
-{
- comx_unregister_hardware("locomx");
-}
-
-module_init(comx_hw_locomx_init);
-module_exit(comx_hw_locomx_exit);
+++ /dev/null
-/*
- * Hardware driver for the MixCom synchronous serial board
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * based on skeleton driver code and a preliminary hscx driver by
- * Tivadar Szemethy <tiv@itc.hu>
- *
- * Copyright (C) 1998-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.65)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.60 (99/06/11):
- * - ported to the kernel, now works as builtin code
- *
- * Version 0.61 (99/06/11):
- * - recognize the one-channel MixCOM card (id byte = 0x13)
- * - printk fixes
- *
- * Version 0.62 (99/07/15):
- * - fixes according to the new hw docs
- * - report line status when open
- *
- * Version 0.63 (99/09/21):
- * - line status report fixes
- *
- * Version 0.64 (99/12/01):
- * - some more cosmetical fixes
- *
- * Version 0.65 (00/08/15)
- * - resource release on failure at MIXCOM_init
- */
-
-#define VERSION "0.65"
-
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/init.h>
-
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#include "comx.h"
-#include "mixcom.h"
-#include "hscx.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Hardware-level driver for the serial port of the MixCom board");
-MODULE_LICENSE("GPL");
-
-#define MIXCOM_DATA(d) ((struct mixcom_privdata *)(COMX_CHANNEL(d)-> \
- HW_privdata))
-
-#define MIXCOM_BOARD_BASE(d) (d->base_addr - MIXCOM_SERIAL_OFFSET - \
- (1 - MIXCOM_DATA(d)->channel) * MIXCOM_CHANNEL_OFFSET)
-
-#define MIXCOM_DEV_BASE(port,channel) (port + MIXCOM_SERIAL_OFFSET + \
- (1 - channel) * MIXCOM_CHANNEL_OFFSET)
-
-/* Values used to set the IRQ line */
-static unsigned char mixcom_set_irq[]={0xFF, 0xFF, 0xFF, 0x0, 0xFF, 0x2, 0x4, 0x6, 0xFF, 0xFF, 0x8, 0xA, 0xC, 0xFF, 0xE, 0xFF};
-
-static unsigned char* hscx_versions[]={"A1", NULL, "A2", NULL, "A3", "2.1"};
-
-struct mixcom_privdata {
- u16 clock;
- char channel;
- long txbusy;
- struct sk_buff *sending;
- unsigned tx_ptr;
- struct sk_buff *recving;
- unsigned rx_ptr;
- unsigned char status;
- char card_has_status;
-};
-
-static inline void wr_hscx(struct net_device *dev, int reg, unsigned char val)
-{
- outb(val, dev->base_addr + reg);
-}
-
-static inline unsigned char rd_hscx(struct net_device *dev, int reg)
-{
- return inb(dev->base_addr + reg);
-}
-
-static inline void hscx_cmd(struct net_device *dev, int cmd)
-{
- unsigned long jiffs = jiffies;
- unsigned char cec;
- unsigned delay = 0;
-
- while ((cec = (rd_hscx(dev, HSCX_STAR) & HSCX_CEC) != 0) &&
- time_before(jiffies, jiffs + HZ)) {
- udelay(1);
- if (++delay > (100000 / HZ)) break;
- }
- if (cec) {
- printk(KERN_WARNING "%s: CEC stuck, probably no clock!\n",dev->name);
- } else {
- wr_hscx(dev, HSCX_CMDR, cmd);
- }
-}
-
-static inline void hscx_fill_fifo(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- register word to_send = hw->sending->len - hw->tx_ptr;
-
-
- outsb(dev->base_addr + HSCX_FIFO,
- &(hw->sending->data[hw->tx_ptr]), min_t(unsigned int, to_send, 32));
- if (to_send <= 32) {
- hscx_cmd(dev, HSCX_XTF | HSCX_XME);
- kfree_skb(hw->sending);
- hw->sending = NULL;
- hw->tx_ptr = 0;
- } else {
- hscx_cmd(dev, HSCX_XTF);
- hw->tx_ptr += 32;
- }
-}
-
-static inline void hscx_empty_fifo(struct net_device *dev, int cnt)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
-
- if (hw->recving == NULL) {
- if (!(hw->recving = dev_alloc_skb(HSCX_MTU + 16))) {
- ch->stats.rx_dropped++;
- hscx_cmd(dev, HSCX_RHR);
- } else {
- skb_reserve(hw->recving, 16);
- skb_put(hw->recving, HSCX_MTU);
- }
- hw->rx_ptr = 0;
- }
- if (cnt > 32 || !cnt || hw->recving == NULL) {
- printk(KERN_ERR "hscx_empty_fifo: cnt is %d, hw->recving %p\n",
- cnt, (void *)hw->recving);
- return;
- }
-
- insb(dev->base_addr + HSCX_FIFO, &(hw->recving->data[hw->rx_ptr]),cnt);
- hw->rx_ptr += cnt;
- hscx_cmd(dev, HSCX_RMC);
-}
-
-
-static int MIXCOM_txe(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
-
- return !test_bit(0, &hw->txbusy);
-}
-
-static int mixcom_probe(struct net_device *dev)
-{
- unsigned long flags;
- int id, vstr, ret=0;
-
- save_flags(flags); cli();
-
- id=inb_p(MIXCOM_BOARD_BASE(dev) + MIXCOM_ID_OFFSET) & 0x7f;
-
- if (id != MIXCOM_ID ) {
- ret=-ENODEV;
- printk(KERN_WARNING "%s: no MixCOM board found at 0x%04lx\n",dev->name, dev->base_addr);
- goto out;
- }
-
- vstr=inb_p(dev->base_addr + HSCX_VSTR) & 0x0f;
- if(vstr>=sizeof(hscx_versions)/sizeof(char*) ||
- hscx_versions[vstr]==NULL) {
- printk(KERN_WARNING "%s: board found but no HSCX chip detected at 0x%4lx (vstr = 0x%1x)\n",dev->name,dev->base_addr,vstr);
- ret = -ENODEV;
- } else {
- printk(KERN_INFO "%s: HSCX chip version %s\n",dev->name,hscx_versions[vstr]);
- ret = 0;
- }
-
-out:
-
- restore_flags(flags);
- return ret;
-}
-
-#if 0
-static void MIXCOM_set_clock(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
-
- if (hw->clock) {
- ;
- } else {
- ;
- }
-}
-#endif
-
-static void mixcom_board_on(struct net_device *dev)
-{
- outb_p(MIXCOM_OFF , MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
- udelay(1000);
- outb_p(mixcom_set_irq[dev->irq] | MIXCOM_ON,
- MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
- udelay(1000);
-}
-
-static void mixcom_board_off(struct net_device *dev)
-{
- outb_p(MIXCOM_OFF , MIXCOM_BOARD_BASE(dev) + MIXCOM_IT_OFFSET);
- udelay(1000);
-}
-
-static void mixcom_off(struct net_device *dev)
-{
- wr_hscx(dev, HSCX_CCR1, 0x0);
-}
-
-static void mixcom_on(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- wr_hscx(dev, HSCX_CCR1, HSCX_PU | HSCX_ODS | HSCX_ITF); // power up, push-pull
- wr_hscx(dev, HSCX_CCR2, HSCX_CIE /* | HSCX_RIE */ );
- wr_hscx(dev, HSCX_MODE, HSCX_TRANS | HSCX_ADM8 | HSCX_RAC | HSCX_RTS );
- wr_hscx(dev, HSCX_RLCR, HSCX_RC | 47); // 1504 bytes
- wr_hscx(dev, HSCX_MASK, HSCX_RSC | HSCX_TIN );
- hscx_cmd(dev, HSCX_XRES | HSCX_RHR);
-
- if (ch->HW_set_clock) ch->HW_set_clock(dev);
-
-}
-
-static int MIXCOM_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- unsigned long flags;
-
- if (ch->debug_flags & DEBUG_HW_TX) {
- comx_debug_bytes(dev, skb->data, skb->len, "MIXCOM_send_packet");
- }
-
- if (!(ch->line_status & LINE_UP)) {
- return FRAME_DROPPED;
- }
-
- if (skb->len > HSCX_MTU) {
- ch->stats.tx_errors++;
- return FRAME_ERROR;
- }
-
- save_flags(flags); cli();
-
- if (test_and_set_bit(0, &hw->txbusy)) {
- printk(KERN_ERR "%s: transmitter called while busy... dropping frame (length %d)\n", dev->name, skb->len);
- restore_flags(flags);
- return FRAME_DROPPED;
- }
-
-
- hw->sending = skb;
- hw->tx_ptr = 0;
- hw->txbusy = 1;
-// atomic_inc(&skb->users); // save it
- hscx_fill_fifo(dev);
- restore_flags(flags);
-
- ch->stats.tx_packets++;
- ch->stats.tx_bytes += skb->len;
-
- if (ch->debug_flags & DEBUG_HW_TX) {
- comx_debug(dev, "MIXCOM_send_packet was successful\n\n");
- }
-
- return FRAME_ACCEPTED;
-}
-
-static inline void mixcom_receive_frame(struct net_device *dev)
-{
- struct comx_channel *ch=dev->priv;
- struct mixcom_privdata *hw=ch->HW_privdata;
- register byte rsta;
- register word length;
-
- rsta = rd_hscx(dev, HSCX_RSTA) & (HSCX_VFR | HSCX_RDO |
- HSCX_CRC | HSCX_RAB);
- length = ((rd_hscx(dev, HSCX_RBCH) & 0x0f) << 8) |
- rd_hscx(dev, HSCX_RBCL);
-
- if ( length > hw->rx_ptr ) {
- hscx_empty_fifo(dev, length - hw->rx_ptr);
- }
-
- if (!(rsta & HSCX_VFR)) {
- ch->stats.rx_length_errors++;
- }
- if (rsta & HSCX_RDO) {
- ch->stats.rx_over_errors++;
- }
- if (!(rsta & HSCX_CRC)) {
- ch->stats.rx_crc_errors++;
- }
- if (rsta & HSCX_RAB) {
- ch->stats.rx_frame_errors++;
- }
- ch->stats.rx_packets++;
- ch->stats.rx_bytes += length;
-
- if (rsta == (HSCX_VFR | HSCX_CRC) && hw->recving) {
- skb_trim(hw->recving, hw->rx_ptr - 1);
- if (ch->debug_flags & DEBUG_HW_RX) {
- comx_debug_skb(dev, hw->recving,
- "MIXCOM_interrupt receiving");
- }
- hw->recving->dev = dev;
- if (ch->LINE_rx) {
- ch->LINE_rx(dev, hw->recving);
- }
- }
- else if(hw->recving) {
- kfree_skb(hw->recving);
- }
- hw->recving = NULL;
- hw->rx_ptr = 0;
-}
-
-
-static inline void mixcom_extended_interrupt(struct net_device *dev)
-{
- struct comx_channel *ch=dev->priv;
- struct mixcom_privdata *hw=ch->HW_privdata;
- register byte exir;
-
- exir = rd_hscx(dev, HSCX_EXIR) & (HSCX_XDU | HSCX_RFO | HSCX_CSC );
-
- if (exir & HSCX_RFO) {
- ch->stats.rx_over_errors++;
- if (hw->rx_ptr) {
- kfree_skb(hw->recving);
- hw->recving = NULL; hw->rx_ptr = 0;
- }
- printk(KERN_ERR "MIXCOM: rx overrun\n");
- hscx_cmd(dev, HSCX_RHR);
- }
-
- if (exir & HSCX_XDU) { // xmit underrun
- ch->stats.tx_errors++;
- ch->stats.tx_aborted_errors++;
- if (hw->tx_ptr) {
- kfree_skb(hw->sending);
- hw->sending = NULL;
- hw->tx_ptr = 0;
- }
- hscx_cmd(dev, HSCX_XRES);
- clear_bit(0, &hw->txbusy);
- if (ch->LINE_tx) {
- ch->LINE_tx(dev);
- }
- printk(KERN_ERR "MIXCOM: tx underrun\n");
- }
-
- if (exir & HSCX_CSC) {
- ch->stats.tx_carrier_errors++;
- if ((rd_hscx(dev, HSCX_STAR) & HSCX_CTS) == 0) { // Vonal le
- if (test_and_clear_bit(0, &ch->lineup_pending)) {
- del_timer(&ch->lineup_timer);
- } else if (ch->line_status & LINE_UP) {
- ch->line_status &= ~LINE_UP;
- if (ch->LINE_status) {
- ch->LINE_status(dev,ch->line_status);
- }
- }
- }
- if (!(ch->line_status & LINE_UP) && (rd_hscx(dev, HSCX_STAR) &
- HSCX_CTS)) { // Vonal fol
- if (!test_and_set_bit(0,&ch->lineup_pending)) {
- ch->lineup_timer.function = comx_lineup_func;
- ch->lineup_timer.data = (unsigned long)dev;
- ch->lineup_timer.expires = jiffies + HZ *
- ch->lineup_delay;
- add_timer(&ch->lineup_timer);
- hscx_cmd(dev, HSCX_XRES);
- clear_bit(0, &hw->txbusy);
- if (hw->sending) {
- kfree_skb(hw->sending);
- }
- hw->sending=NULL;
- hw->tx_ptr = 0;
- }
- }
- }
-}
-
-
-static irqreturn_t MIXCOM_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- unsigned long flags;
- struct net_device *dev = (struct net_device *)dev_id;
- struct comx_channel *ch, *twin_ch;
- struct mixcom_privdata *hw, *twin_hw;
- register unsigned char ista;
-
- if (dev==NULL) {
- printk(KERN_ERR "comx_interrupt: irq %d for unknown device\n",irq);
- return IRQ_NONE;
- }
-
- ch = dev->priv;
- hw = ch->HW_privdata;
-
- save_flags(flags); cli();
-
- while((ista = (rd_hscx(dev, HSCX_ISTA) & (HSCX_RME | HSCX_RPF |
- HSCX_XPR | HSCX_EXB | HSCX_EXA | HSCX_ICA)))) {
- register byte ista2 = 0;
-
- if (ista & HSCX_RME) {
- mixcom_receive_frame(dev);
- }
- if (ista & HSCX_RPF) {
- hscx_empty_fifo(dev, 32);
- }
- if (ista & HSCX_XPR) {
- if (hw->tx_ptr) {
- hscx_fill_fifo(dev);
- } else {
- clear_bit(0, &hw->txbusy);
- ch->LINE_tx(dev);
- }
- }
-
- if (ista & HSCX_EXB) {
- mixcom_extended_interrupt(dev);
- }
-
- if ((ista & HSCX_EXA) && ch->twin) {
- mixcom_extended_interrupt(ch->twin);
- }
-
- if ((ista & HSCX_ICA) && ch->twin &&
- (ista2 = rd_hscx(ch->twin, HSCX_ISTA) &
- (HSCX_RME | HSCX_RPF | HSCX_XPR ))) {
- if (ista2 & HSCX_RME) {
- mixcom_receive_frame(ch->twin);
- }
- if (ista2 & HSCX_RPF) {
- hscx_empty_fifo(ch->twin, 32);
- }
- if (ista2 & HSCX_XPR) {
- twin_ch=ch->twin->priv;
- twin_hw=twin_ch->HW_privdata;
- if (twin_hw->tx_ptr) {
- hscx_fill_fifo(ch->twin);
- } else {
- clear_bit(0, &twin_hw->txbusy);
- ch->LINE_tx(ch->twin);
- }
- }
- }
- }
-
- restore_flags(flags);
- return IRQ_HANDLED;
-}
-
-static int MIXCOM_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- unsigned long flags;
- int ret = -ENODEV;
-
- if (!dev->base_addr || !dev->irq)
- goto err_ret;
-
-
- if(hw->channel==1) {
- if(!TWIN(dev) || !(COMX_CHANNEL(TWIN(dev))->init_status &
- IRQ_ALLOCATED)) {
- printk(KERN_ERR "%s: channel 0 not yet initialized\n",dev->name);
- ret = -EAGAIN;
- goto err_ret;
- }
- }
-
-
- /* Is our hw present at all ? Not checking for channel 0 if it is already
- open */
- if(hw->channel!=0 || !(ch->init_status & IRQ_ALLOCATED)) {
- if (!request_region(dev->base_addr, MIXCOM_IO_EXTENT, dev->name)) {
- ret = -EAGAIN;
- goto err_ret;
- }
- if (mixcom_probe(dev)) {
- ret = -ENODEV;
- goto err_release_region;
- }
- }
-
- if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
- if (request_irq(dev->irq, MIXCOM_interrupt, 0,
- dev->name, (void *)dev)) {
- printk(KERN_ERR "MIXCOM: unable to obtain irq %d\n", dev->irq);
- ret = -EAGAIN;
- goto err_release_region;
- }
- }
-
- save_flags(flags); cli();
-
- if(hw->channel==0 && !(ch->init_status & IRQ_ALLOCATED)) {
- ch->init_status|=IRQ_ALLOCATED;
- mixcom_board_on(dev);
- }
-
- mixcom_on(dev);
-
-
- hw->status=inb(MIXCOM_BOARD_BASE(dev) + MIXCOM_STATUS_OFFSET);
- if(hw->status != 0xff) {
- printk(KERN_DEBUG "%s: board has status register, good\n", dev->name);
- hw->card_has_status=1;
- }
-
- hw->txbusy = 0;
- ch->init_status |= HW_OPEN;
-
- if (rd_hscx(dev, HSCX_STAR) & HSCX_CTS) {
- ch->line_status |= LINE_UP;
- } else {
- ch->line_status &= ~LINE_UP;
- }
-
- restore_flags(flags);
-
- ch->LINE_status(dev, ch->line_status);
-
- for (; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IO) == 0 ||
- strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
- strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
- strcmp(procfile->name, FILENAME_IRQ) == 0) {
- procfile->mode = S_IFREG | 0444;
- }
- }
-
- return 0;
-
-err_release_region:
- release_region(dev->base_addr, MIXCOM_IO_EXTENT);
-err_ret:
- return ret;
-}
-
-static int MIXCOM_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- unsigned long flags;
-
-
- save_flags(flags); cli();
-
- mixcom_off(dev);
-
- /* This is channel 0, twin is not open, we can safely turn off everything */
- if(hw->channel==0 && (!(TWIN(dev)) ||
- !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN))) {
- mixcom_board_off(dev);
- free_irq(dev->irq, dev);
- release_region(dev->base_addr, MIXCOM_IO_EXTENT);
- ch->init_status &= ~IRQ_ALLOCATED;
- }
-
- /* This is channel 1, channel 0 has already been shutdown, we can release
- this one too */
- if(hw->channel==1 && !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN)) {
- if(COMX_CHANNEL(TWIN(dev))->init_status & IRQ_ALLOCATED) {
- mixcom_board_off(TWIN(dev));
- free_irq(TWIN(dev)->irq, TWIN(dev));
- release_region(TWIN(dev)->base_addr, MIXCOM_IO_EXTENT);
- COMX_CHANNEL(TWIN(dev))->init_status &= ~IRQ_ALLOCATED;
- }
- }
-
- /* the ioports for channel 1 can be safely released */
- if(hw->channel==1) {
- release_region(dev->base_addr, MIXCOM_IO_EXTENT);
- }
-
- restore_flags(flags);
-
- /* If we don't hold any hardware open */
- if(!(ch->init_status & IRQ_ALLOCATED)) {
- for (; procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IO) == 0 ||
- strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
- strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
- strcmp(procfile->name, FILENAME_IRQ) == 0) {
- procfile->mode = S_IFREG | 0644;
- }
- }
- }
-
- /* channel 0 was only waiting for us to close channel 1
- close it completely */
-
- if(hw->channel==1 && !(COMX_CHANNEL(TWIN(dev))->init_status & HW_OPEN)) {
- for (procfile=COMX_CHANNEL(TWIN(dev))->procdir->subdir;
- procfile ; procfile = procfile->next) {
- if (strcmp(procfile->name, FILENAME_IO) == 0 ||
- strcmp(procfile->name, FILENAME_CHANNEL) == 0 ||
- strcmp(procfile->name, FILENAME_CLOCK) == 0 ||
- strcmp(procfile->name, FILENAME_IRQ) == 0) {
- procfile->mode = S_IFREG | 0644;
- }
- }
- }
-
- ch->init_status &= ~HW_OPEN;
- return 0;
-}
-
-static int MIXCOM_statistics(struct net_device *dev,char *page)
-{
- struct comx_channel *ch = dev->priv;
- // struct mixcom_privdata *hw = ch->HW_privdata;
- int len = 0;
-
- if(ch->init_status && IRQ_ALLOCATED) {
- len += sprintf(page + len, "Mixcom board: hardware open\n");
- }
-
- return len;
-}
-
-static int MIXCOM_dump(struct net_device *dev) {
- return 0;
-}
-
-static int mixcom_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- int len = 0;
-
- if (strcmp(file->name, FILENAME_IO) == 0) {
- len = sprintf(page, "0x%x\n",
- (unsigned int)MIXCOM_BOARD_BASE(dev));
- } else if (strcmp(file->name, FILENAME_IRQ) == 0) {
- len = sprintf(page, "%d\n", (unsigned int)dev->irq);
- } else if (strcmp(file->name, FILENAME_CLOCK) == 0) {
- if (hw->clock) len = sprintf(page, "%d\n", hw->clock);
- else len = sprintf(page, "external\n");
- } else if (strcmp(file->name, FILENAME_CHANNEL) == 0) {
- len = sprintf(page, "%01d\n", hw->channel);
- } else if (strcmp(file->name, FILENAME_TWIN) == 0) {
- if (ch->twin) {
- len = sprintf(page, "%s\n",ch->twin->name);
- } else {
- len = sprintf(page, "none\n");
- }
- } else {
- printk(KERN_ERR "mixcom_read_proc: internal error, filename %s\n", file->name);
- return -EBADF;
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
- *start = page + off;
- if (count >= len - off) *eof = 1;
- return min_t(int, count, len - off);
-}
-
-
-static struct net_device *mixcom_twin_check(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *procfile = ch->procdir->parent->subdir;
- struct mixcom_privdata *hw = ch->HW_privdata;
-
- struct net_device *twin;
- struct comx_channel *ch_twin;
- struct mixcom_privdata *hw_twin;
-
-
- for ( ; procfile ; procfile = procfile->next) {
- if(!S_ISDIR(procfile->mode)) continue;
-
- twin = procfile->data;
- ch_twin = twin->priv;
- hw_twin = ch_twin->HW_privdata;
-
-
- if (twin != dev && dev->irq && dev->base_addr &&
- dev->irq == twin->irq &&
- ch->hardware == ch_twin->hardware &&
- dev->base_addr == twin->base_addr +
- (1-2*hw->channel)*MIXCOM_CHANNEL_OFFSET &&
- hw->channel == (1 - hw_twin->channel)) {
- if (!TWIN(twin) || TWIN(twin)==dev) {
- return twin;
- }
- }
- }
- return NULL;
-}
-
-
-static void setup_twin(struct net_device* dev)
-{
-
- if(TWIN(dev) && TWIN(TWIN(dev))) {
- TWIN(TWIN(dev))=NULL;
- }
- if ((TWIN(dev) = mixcom_twin_check(dev)) != NULL) {
- if (TWIN(TWIN(dev)) && TWIN(TWIN(dev)) != dev) {
- TWIN(dev)=NULL;
- } else {
- TWIN(TWIN(dev))=dev;
- }
- }
-}
-
-static int mixcom_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = (struct net_device *)entry->parent->data;
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
- char *page;
- int value;
-
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
- return -ENOMEM;
- }
-
- if (copy_from_user(page, buffer, count = min_t(unsigned long, count, PAGE_SIZE))) {
- free_page((unsigned long)page);
- return -EFAULT;
- }
- if (*(page + count - 1) == '\n') {
- *(page + count - 1) = 0;
- }
-
- if (strcmp(entry->name, FILENAME_IO) == 0) {
- value = simple_strtoul(page, NULL, 0);
- if (value != 0x180 && value != 0x280 && value != 0x380) {
- printk(KERN_ERR "MIXCOM: incorrect io address!\n");
- } else {
- dev->base_addr = MIXCOM_DEV_BASE(value,hw->channel);
- }
- } else if (strcmp(entry->name, FILENAME_IRQ) == 0) {
- value = simple_strtoul(page, NULL, 0);
- if (value < 0 || value > 15 || mixcom_set_irq[value]==0xFF) {
- printk(KERN_ERR "MIXCOM: incorrect irq value!\n");
- } else {
- dev->irq = value;
- }
- } else if (strcmp(entry->name, FILENAME_CLOCK) == 0) {
- if (strncmp("ext", page, 3) == 0) {
- hw->clock = 0;
- } else {
- int kbps;
-
- kbps = simple_strtoul(page, NULL, 0);
- if (!kbps) {
- hw->clock = 0;
- } else {
- hw->clock = kbps;
- }
- if (hw->clock < 32 || hw->clock > 2000) {
- hw->clock = 0;
- printk(KERN_ERR "MIXCOM: invalid clock rate!\n");
- }
- }
- if (ch->init_status & HW_OPEN && ch->HW_set_clock) {
- ch->HW_set_clock(dev);
- }
- } else if (strcmp(entry->name, FILENAME_CHANNEL) == 0) {
- value = simple_strtoul(page, NULL, 0);
- if (value > 2) {
- printk(KERN_ERR "Invalid channel number\n");
- } else {
- dev->base_addr+=(hw->channel - value) * MIXCOM_CHANNEL_OFFSET;
- hw->channel = value;
- }
- } else {
- printk(KERN_ERR "hw_read_proc: internal error, filename %s\n",
- entry->name);
- return -EBADF;
- }
-
- setup_twin(dev);
-
- free_page((unsigned long)page);
- return count;
-}
-
-static int MIXCOM_init(struct net_device *dev) {
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw;
- struct proc_dir_entry *new_file;
-
- if ((ch->HW_privdata = kmalloc(sizeof(struct mixcom_privdata),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
-
- memset(hw = ch->HW_privdata, 0, sizeof(struct mixcom_privdata));
-
- if ((new_file = create_proc_entry(FILENAME_IO, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_HW_privdata;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &mixcom_read_proc;
- new_file->write_proc = &mixcom_write_proc;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_IRQ, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_io;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &mixcom_read_proc;
- new_file->write_proc = &mixcom_write_proc;
- new_file->nlink = 1;
-
-#if 0
- if ((new_file = create_proc_entry(FILENAME_CLOCK, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- return -EIO;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &mixcom_read_proc;
- new_file->write_proc = &mixcom_write_proc;
- new_file->nlink = 1;
-#endif
-
- if ((new_file = create_proc_entry(FILENAME_CHANNEL, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_irq;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &mixcom_read_proc;
- new_file->write_proc = &mixcom_write_proc;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_TWIN, S_IFREG | 0444,
- ch->procdir)) == NULL) {
- goto cleanup_filename_channel;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &mixcom_read_proc;
- new_file->write_proc = &mixcom_write_proc;
- new_file->nlink = 1;
-
- setup_twin(dev);
-
- /* Fill in ch_struct hw specific pointers */
- ch->HW_access_board = NULL;
- ch->HW_release_board = NULL;
- ch->HW_txe = MIXCOM_txe;
- ch->HW_open = MIXCOM_open;
- ch->HW_close = MIXCOM_close;
- ch->HW_send_packet = MIXCOM_send_packet;
- ch->HW_statistics = MIXCOM_statistics;
- ch->HW_set_clock = NULL;
-
- dev->base_addr = MIXCOM_DEV_BASE(MIXCOM_DEFAULT_IO,0);
- dev->irq = MIXCOM_DEFAULT_IRQ;
-
- MOD_INC_USE_COUNT;
- return 0;
-cleanup_filename_channel:
- remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
-cleanup_filename_irq:
- remove_proc_entry(FILENAME_IRQ, ch->procdir);
-cleanup_filename_io:
- remove_proc_entry(FILENAME_IO, ch->procdir);
-cleanup_HW_privdata:
- kfree(ch->HW_privdata);
- return -EIO;
-}
-
-static int MIXCOM_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct mixcom_privdata *hw = ch->HW_privdata;
-
- if(hw->channel==0 && TWIN(dev)) {
- return -EBUSY;
- }
-
- if(hw->channel==1 && TWIN(dev)) {
- TWIN(TWIN(dev))=NULL;
- }
-
- kfree(ch->HW_privdata);
- remove_proc_entry(FILENAME_IO, ch->procdir);
- remove_proc_entry(FILENAME_IRQ, ch->procdir);
-#if 0
- remove_proc_entry(FILENAME_CLOCK, ch->procdir);
-#endif
- remove_proc_entry(FILENAME_CHANNEL, ch->procdir);
- remove_proc_entry(FILENAME_TWIN, ch->procdir);
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static struct comx_hardware mixcomhw = {
- "mixcom",
- VERSION,
- MIXCOM_init,
- MIXCOM_exit,
- MIXCOM_dump,
- NULL
-};
-
-static int __init comx_hw_mixcom_init(void)
-{
- return comx_register_hardware(&mixcomhw);
-}
-
-static void __exit comx_hw_mixcom_exit(void)
-{
- comx_unregister_hardware("mixcom");
-}
-
-module_init(comx_hw_mixcom_init);
-module_exit(comx_hw_mixcom_exit);
+++ /dev/null
-/*
- * Hardware-level driver for the SliceCOM board for Linux kernels 2.4.X
- *
- * Current maintainer / latest changes: Pasztor Szilard <don@itc.hu>
- *
- * Original author: Bartok Istvan <bartoki@itc.hu>
- * Based on skeleton by Tivadar Szemethy <tiv@itc.hu>
- *
- * 0.51:
- * - port for 2.4.x
- * - clean up some code, make it more portable
- * - busted direct hardware access through mapped memory
- * - fix a possible race
- * - prevent procfs buffer overflow
- *
- * 0.50:
- * - support for the pcicom board, lots of rearrangements
- * - handle modem status lines
- *
- * 0.50a:
- * - fix for falc version 1.0
- *
- * 0.50b: T&t
- * - fix for bad localbus
- */
-
-#define VERSION "0.51"
-#define VERSIONSTR "SliceCOM v" VERSION ", 2002/01/07\n"
-
-#include <linux/config.h>
-#include <linux/ctype.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/ioport.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-
-#include <asm/delay.h>
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
-#define COMX_NEW
-
-#ifndef COMX_NEW
-#include "../include/comx.h"
-#include "../include/munich32x.h"
-#include "../include/falc-lh.h"
-#else
-#include "comx.h"
-#include "munich32x.h"
-#include "falc-lh.h"
-#endif
-
-MODULE_AUTHOR("Bartok Istvan <bartoki@itc.hu>, Gergely Madarasz <gorgo@itc.hu>, Szilard Pasztor <don@itc.hu>");
-MODULE_DESCRIPTION("Hardware-level driver for the SliceCOM and PciCOM (WelCOM) adapters");
-MODULE_LICENSE("GPL");
-/*
- * TODO: az ilyenek a comxhw.h -ban szoktak lenni, idovel menjenek majd oda:
- */
-
-#define FILENAME_BOARDNUM "boardnum" /* /proc/comx/comx0.1/boardnum */
-#define FILENAME_TIMESLOTS "timeslots" /* /proc/comx/comx0.1/timeslots */
-#define FILENAME_FRAMING "framing" /* /proc/comx/comx0.1/framing */
-#define FILENAME_LINECODE "linecode" /* /proc/comx/comx0.1/linecode */
-#define FILENAME_CLOCK_SOURCE "clock_source" /* /proc/comx/comx0.1/clock_source */
-#define FILENAME_LOOPBACK "loopback" /* /proc/comx/comx0.1/loopback */
-#define FILENAME_REG "reg" /* /proc/comx/comx0.1/reg */
-#define FILENAME_LBIREG "lbireg" /* /proc/comx/comx0.1/lbireg */
-
-#define SLICECOM_BOARDNUM_DEFAULT 0
-
-#define SLICECOM_FRAMING_CRC4 1
-#define SLICECOM_FRAMING_NO_CRC4 2
-#define SLICECOM_FRAMING_DEFAULT SLICECOM_FRAMING_CRC4
-
-#define SLICECOM_LINECODE_HDB3 1
-#define SLICECOM_LINECODE_AMI 2
-#define SLICECOM_LINECODE_DEFAULT SLICECOM_LINECODE_HDB3
-
-#define SLICECOM_CLOCK_SOURCE_LINE 1
-#define SLICECOM_CLOCK_SOURCE_INTERNAL 2
-#define SLICECOM_CLOCK_SOURCE_DEFAULT SLICECOM_CLOCK_SOURCE_LINE
-
-#define SLICECOM_LOOPBACK_NONE 1
-#define SLICECOM_LOOPBACK_LOCAL 2
-#define SLICECOM_LOOPBACK_REMOTE 3
-#define SLICECOM_LOOPBACK_DEFAULT SLICECOM_LOOPBACK_NONE
-
-#define MUNICH_VIRT(addr) (void *)(&bar1[addr])
-
-struct slicecom_stringtable
-{
- char *name;
- int value;
-};
-
-/* A convention: keep "default" the last not NULL when reading from /proc,
- "error" is an indication that something went wrong, we have an undefined value */
-
-struct slicecom_stringtable slicecom_framings[] =
-{
- {"crc4", SLICECOM_FRAMING_CRC4},
- {"no-crc4", SLICECOM_FRAMING_NO_CRC4},
- {"default", SLICECOM_FRAMING_DEFAULT},
- {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_linecodes[] =
-{
- {"hdb3", SLICECOM_LINECODE_HDB3},
- {"ami", SLICECOM_LINECODE_AMI},
- {"default", SLICECOM_LINECODE_DEFAULT},
- {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_clock_sources[] =
-{
- {"line", SLICECOM_CLOCK_SOURCE_LINE},
- {"internal", SLICECOM_CLOCK_SOURCE_INTERNAL},
- {"default", SLICECOM_CLOCK_SOURCE_DEFAULT},
- {"error", 0}
-};
-
-struct slicecom_stringtable slicecom_loopbacks[] =
-{
- {"none", SLICECOM_LOOPBACK_NONE},
- {"local", SLICECOM_LOOPBACK_LOCAL},
- {"remote", SLICECOM_LOOPBACK_REMOTE},
- {"default", SLICECOM_LOOPBACK_DEFAULT},
- {"error", 0}
-};
-
-/*
- * Some tunable values...
- *
- * Note: when tuning values which change the length of text in
- * /proc/comx/comx[n]/status, keep in mind that it must be shorter then
- * PAGESIZE !
- */
-
-#define MAX_BOARDS 4 /* ezzel 4 kartya lehet a gepben: 0..3 */
-#define RX_DESC_MAX 8 /* Rx ring size, must be >= 4 */
-#define TX_DESC_MAX 4 /* Tx ring size, must be >= 2 */
- /* a sokkal hosszabb Tx ring mar ronthatja a nem-FIFO packet */
- /* schedulerek (fair queueing, stb.) hatekonysagat. */
-#define MAX_WORK 10 /* TOD: update the info max. ennyi-1 esemenyt dolgoz fel egy interrupt hivasnal */
-
-/*
- * These are tunable too, but don't touch them without fully understanding what is happening
- */
-
-#define UDELAY 20 /* We wait UDELAY usecs with disabled interrupts before and */
- /* after each command to avoid writing into each other's */
- /* ccb->action_spec. A _send_packet nem var, mert azt az */
- /* _interrupt()-bol is meghivhatja a LINE_tx() */
-
-/*
- * Just to avoid warnings about implicit declarations:
- */
-
-static int MUNICH_close(struct net_device *dev);
-static struct comx_hardware slicecomhw;
-static struct comx_hardware pcicomhw;
-
-static unsigned long flags;
-static spinlock_t mister_lock = SPIN_LOCK_UNLOCKED;
-
-typedef volatile struct /* Time Slot Assignment */
-{
- u32 rxfillmask:8, // ----------------------------+------+
- // | |
- rxchannel:5, // ----------------------+---+ | |
- rti:1, // ---------------------+| | | |
- res2:2, // -------------------++|| | | |
- // |||| | | |
- txfillmask:8, // ----------+------+ |||| | | |
- // | | |||| | | |
- txchannel:5, // ----+---+ | | |||| | | |
- tti:1, // ---+| | | | |||| | | |
- res1:2; // -++|| | | | |||| | | |
- // 3 2 1
- // 10987654 32109876 54321098 76543210
-} timeslot_spec_t;
-
-typedef volatile struct /* Receive Descriptor */
-{
- u32 zero1:16, no:13, hi:1, hold:1, zero2:1;
-
- u32 next;
- u32 data;
-
- u32 zero3:8, status:8, bno:13, zero4:1, c:1, fe:1;
-} rx_desc_t;
-
-typedef volatile struct /* Transmit Descriptor */
-{
- u32 fnum:11, csm:1, no13:1, zero1:2, v110:1, no:13, hi:1, hold:1, fe:1;
-
- u32 next;
- u32 data;
-
-} tx_desc_t;
-
-typedef volatile struct /* Channel Specification */
-{
- u32 iftf:1, mode:2, fa:1, trv:2, crc:1, inv:1, cs:1, tflag:7, ra:1, ro:1,
- th:1, ta:1, to:1, ti:1, ri:1, nitbs:1, fit:1, fir:1, re:1, te:1, ch:1,
- ifc:1, sfe:1, fe2:1;
-
- u32 frda;
- u32 ftda;
-
- u32 itbs:6, zero1:26;
-
-} channel_spec_t;
-
-typedef volatile struct /* Configuration Control Block */
-{
- u32 action_spec;
- u32 reserved1;
- u32 reserved2;
- timeslot_spec_t timeslot_spec[32];
- channel_spec_t channel_spec[32];
- u32 current_rx_desc[32];
- u32 current_tx_desc[32];
- u32 csa; /* Control Start Address. CSA = *CCBA; CCB = *CSA */
- /* MUNICH does it like: CCB = *( *CCBA ) */
-} munich_ccb_t;
-
-typedef volatile struct /* Entry in the interrupt queue */
-{
- u32 all;
-} munich_intq_t;
-
-#define MUNICH_INTQLEN 63 /* Rx/Tx Interrupt Queue Length
- (not the real len, but the TIQL/RIQL value) */
-#define MUNICH_INTQMAX ( 16*(MUNICH_INTQLEN+1) ) /* Rx/Tx/Periph Interrupt Queue size in munich_intq_t's */
-#define MUNICH_INTQSIZE ( 4*MUNICH_INTQMAX ) /* Rx/Tx/Periph Interrupt Queue size in bytes */
-
-#define MUNICH_PIQLEN 4 /* Peripheral Interrupt Queue Length. Unlike the RIQL/TIQL, */
-#define MUNICH_PIQMAX ( 4*MUNICH_PIQLEN ) /* PIQL register needs it like this */
-#define MUNICH_PIQSIZE ( 4*MUNICH_PIQMAX )
-
-typedef volatile u32 vol_u32; /* TOD: ezek megszunnek ha atirom readw()/writew()-re - kész */
-typedef volatile u8 vol_u8;
-
-typedef volatile struct /* counters of E1-errors and errored seconds, see rfc2495 */
-{
- /* use here only unsigned ints, we depend on it when calculating the sum for the last N intervals */
-
- unsigned line_code_violations, /* AMI: bipolar violations, HDB3: hdb3 violations */
- path_code_violations, /* FAS errors and CRC4 errors */
- e_bit_errors, /* E-Bit Errors (the remote side received from us with CRC4-error) */
- slip_secs, /* number of seconds with (receive) Controlled Slip(s) */
- fr_loss_secs, /* number of seconds an Out Of Frame defect was detected */
- line_err_secs, /* number of seconds with one or more Line Code Violations */
- degraded_mins, /* Degraded Minute - the estimated error rate is >1E-6, but <1E-3 */
- errored_secs, /* Errored Second - at least one of these happened:
- - Path Code Violation
- - Out Of Frame defect
- - Slip
- - receiving AIS
- - not incremented during an Unavailable Second */
- bursty_err_secs, /* Bursty Errored Second: (rfc2495 says it does not apply to E1)
- - Path Code Violations >1, but <320
- - not a Severely Errored Second
- - no AIS
- - not incremented during an Unavailabla Second */
- severely_err_secs, /* Severely Errored Second:
- - CRC4: >=832 Path COde Violations || >0 Out Of Frame defects
- - noCRC4: >=2048 Line Code Violations
- - not incremented during an Unavailable Second */
- unavail_secs; /* number of Unavailable Seconds. Unavailable state is said after:
- - 10 contiguous Severely Errored Seconds
- - or RAI || AIS || LOF || LOS
- - (any) loopback has been set */
-
- /*
- * we do not strictly comply to the rfc: we do not retroactively reduce errored_secs,
- * bursty_err_secs, severely_err_secs when 'unavailable state' is reached
- */
-
-} e1_stats_t;
-
-typedef volatile struct /* ezek board-adatok, nem lehetnek a slicecom_privdata -ban */
-{
- int use_count; /* num. of interfaces using the board */
- int irq; /* a kartya irq-ja. belemasoljuk a dev->irq -kba is, de csak hogy */
- /* szebb legyen az ifconfig outputja */
- /* ha != 0, az azt jelenti hogy az az irq most nekunk sikeresen */
- /* le van foglalva */
- struct pci_dev *pci; /* a kartya PCI strukturaja. NULL, ha nincs kartya */
- u32 *bar1; /* pci->base_address[0] ioremap()-ed by munich_probe(), */
- /* on x86 can be used both as a bus or virtual address. */
- /* These are the Munich's registers */
- u8 *lbi; /* pci->base_address[1] ioremap()-ed by munich_probe(), */
- /* this is a 256-byte range, the start of the LBI on the board */
- munich_ccb_t *ccb; /* virtual address of CCB */
- munich_intq_t *tiq; /* Tx Interrupt Queue */
- munich_intq_t *riq; /* Rx Interrupt Queue */
- munich_intq_t *piq; /* Peripheral Interrupt Queue (FALC interrupts arrive here) */
- int tiq_ptr, /* A 'current' helyek a tiq/riq/piq -ban. */
- riq_ptr, /* amikor feldolgoztam az interruptokat, a legelso ures */
- piq_ptr; /* interrupt_information szora mutatnak. */
- struct net_device *twins[32]; /* MUNICH channel -> network interface assignment */
-
- unsigned long lastcheck; /* When were the Rx rings last checked. Time in jiffies */
-
- struct timer_list modemline_timer;
- char isx21;
- char lineup;
- char framing; /* a beallitasok tarolasa */
- char linecode;
- char clock_source;
- char loopback;
-
- char devname[30]; /* what to show in /proc/interrupts */
- unsigned histogram[MAX_WORK]; /* number of processed events in the interrupt loop */
- unsigned stat_pri_races; /* number of special events, we try to handle them */
- unsigned stat_pti_races;
- unsigned stat_pri_races_missed; /* when it can not be handled, because of MAX_WORK */
- unsigned stat_pti_races_missed;
-
-#define SLICECOM_BOARD_INTERVALS_SIZE 97
- e1_stats_t intervals[SLICECOM_BOARD_INTERVALS_SIZE]; /* E1 line statistics */
- unsigned current_interval; /* pointer to the current interval */
- unsigned elapsed_seconds; /* elapsed seconds from the start of the current interval */
- unsigned ses_seconds; /* counter of contiguous Severely Errored Seconds */
- unsigned is_unavailable; /* set to 1 after 10 contiguous Severely Errored Seconds */
- unsigned no_ses_seconds; /* contiguous Severely Error -free seconds in unavail state */
-
- unsigned deg_elapsed_seconds; /* for counting the 'Degraded Mins' */
- unsigned deg_cumulated_errors;
-
- struct module *owner; /* pointer to our module to avoid module load races */
-} munich_board_t;
-
-struct slicecom_privdata
-{
- int busy; /* transmitter busy - number of packets in the Tx ring */
- int channel; /* Munich logical channel ('channel-group' in Cisco) */
- unsigned boardnum;
- u32 timeslots; /* i-th bit means i-th timeslot is our */
-
- int tx_ring_hist[TX_DESC_MAX]; /* histogram: number of packets in Tx ring when _send_packet is called */
-
- tx_desc_t tx_desc[TX_DESC_MAX]; /* the ring of Tx descriptors */
- u8 tx_data[TX_DESC_MAX][TXBUFFER_SIZE]; /* buffers for data to transmit */
- int tx_desc_ptr; /* hanyadik descriptornal tartunk a beirassal */
- /* ahol ez all, oda irtunk utoljara */
-
- rx_desc_t rx_desc[RX_DESC_MAX]; /* the ring of Rx descriptors */
- u8 rx_data[RX_DESC_MAX][RXBUFFER_SIZE]; /* buffers for received data */
- int rx_desc_ptr; /* hanyadik descriptornal tartunk az olvasassal */
-
- int rafutott;
-};
-
-static u32 reg, reg_ertek; /* why static: don't write stack trash into regs if strtoul() fails */
-static u32 lbireg;
-static u8 lbireg_ertek; /* why static: don't write stack trash into regs if strtoul() fails */
-
-static munich_board_t slicecom_boards[MAX_BOARDS];
-static munich_board_t pcicom_boards[MAX_BOARDS];
-
-/*
- * Reprogram Idle Channel Registers in the FALC - send special code in not used channels
- * Should be called from the open and close, when the timeslot assignment changes
- */
-
-void rework_idle_channels(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- munich_board_t *board = slicecom_boards + hw->boardnum;
- munich_ccb_t *ccb = board->ccb;
-
- u8 *lbi = board->lbi;
- int i, j, tmp;
-
-
- spin_lock_irqsave(&mister_lock, flags);
-
- for (i = 0; i < 4; i++)
- {
- tmp = 0xFF;
- for (j = 0; j < 8; j++)
- if (ccb->timeslot_spec[8 * i + j].tti == 0) tmp ^= (0x80 >> j);
- writeb(tmp, lbi + 0x30 + i);
- }
-
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM framing - /proc/comx/comx0/framing
- */
-
-void slicecom_set_framing(int boardnum, int value)
-{
- u8 *lbi = slicecom_boards[boardnum].lbi;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- slicecom_boards[boardnum].framing = value;
- switch (value)
- {
- case SLICECOM_FRAMING_CRC4:
- writeb(readb(lbi + FMR1) | 8, lbi + FMR1);
- writeb((readb(lbi + FMR2) & 0x3f) | 0x80, lbi + FMR2);
- break;
- case SLICECOM_FRAMING_NO_CRC4:
- writeb(readb(lbi + FMR1) & 0xf7, lbi + FMR1);
- writeb(readb(lbi + FMR2) & 0x3f, lbi + FMR2);
- break;
- default:
- printk("slicecom: board %d: unhandled " FILENAME_FRAMING
- " value %d\n", boardnum, value);
- }
-
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM linecode - /proc/comx/comx0/linecode
- */
-
-void slicecom_set_linecode(int boardnum, int value)
-{
- u8 *lbi = slicecom_boards[boardnum].lbi;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- slicecom_boards[boardnum].linecode = value;
- switch (value)
- {
- case SLICECOM_LINECODE_HDB3:
- writeb(readb(lbi + FMR0) | 0xf0, lbi + FMR0);
- break;
- case SLICECOM_LINECODE_AMI:
- writeb((readb(lbi + FMR0) & 0x0f) | 0xa0, lbi + FMR0);
- break;
- default:
- printk("slicecom: board %d: unhandled " FILENAME_LINECODE
- " value %d\n", boardnum, value);
- }
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set PCM clock source - /proc/comx/comx0/clock_source
- */
-
-void slicecom_set_clock_source(int boardnum, int value)
-{
- u8 *lbi = slicecom_boards[boardnum].lbi;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- slicecom_boards[boardnum].clock_source = value;
- switch (value)
- {
- case SLICECOM_CLOCK_SOURCE_LINE:
- writeb(readb(lbi + LIM0) & ~1, lbi + LIM0);
- break;
- case SLICECOM_CLOCK_SOURCE_INTERNAL:
- writeb(readb(lbi + LIM0) | 1, lbi + LIM0);
- break;
- default:
- printk("slicecom: board %d: unhandled " FILENAME_CLOCK_SOURCE
- " value %d\n", boardnum, value);
- }
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Set loopbacks - /proc/comx/comx0/loopback
- */
-
-void slicecom_set_loopback(int boardnum, int value)
-{
- u8 *lbi = slicecom_boards[boardnum].lbi;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- slicecom_boards[boardnum].loopback = value;
- switch (value)
- {
- case SLICECOM_LOOPBACK_NONE:
- writeb(readb(lbi + LIM0) & ~2, lbi + LIM0); /* Local Loop OFF */
- writeb(readb(lbi + LIM1) & ~2, lbi + LIM1); /* Remote Loop OFF */
- break;
- case SLICECOM_LOOPBACK_LOCAL:
- writeb(readb(lbi + LIM1) & ~2, lbi + LIM1); /* Remote Loop OFF */
- writeb(readb(lbi + LIM0) | 2, lbi + LIM0); /* Local Loop ON */
- break;
- case SLICECOM_LOOPBACK_REMOTE:
- writeb(readb(lbi + LIM0) & ~2, lbi + LIM0); /* Local Loop OFF */
- writeb(readb(lbi + LIM1) | 2, lbi + LIM1); /* Remote Loop ON */
- break;
- default:
- printk("slicecom: board %d: unhandled " FILENAME_LOOPBACK
- " value %d\n", boardnum, value);
- }
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * Update E1 line status LEDs on the adapter
- */
-
-void slicecom_update_leds(munich_board_t * board)
-{
- u32 *bar1 = board->bar1;
- u8 *lbi = board->lbi;
- u8 frs0;
- u32 leds;
- int i;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- leds = 0;
- frs0 = readb(lbi + FRS0); /* FRS0 bits described on page 137 */
-
- if (!(frs0 & 0xa0))
- {
- leds |= 0x2000; /* Green LED: Input signal seems to be OK, no LOS, no LFA */
- if (frs0 & 0x10)
- leds |= 0x8000; /* Red LED: Receiving Remote Alarm */
- }
- writel(leds, MUNICH_VIRT(GPDATA));
-
- if (leds == 0x2000 && !board->lineup)
- { /* line up */
- board->lineup = 1;
- for (i = 0; i < 32; i++)
- {
- if (board->twins[i] && (board->twins[i]->flags & IFF_RUNNING))
- {
- struct comx_channel *ch = board->twins[i]->priv;
-
- if (!test_and_set_bit(0, &ch->lineup_pending))
- {
- ch->lineup_timer.function = comx_lineup_func;
- ch->lineup_timer.data = (unsigned long)board->twins[i];
- ch->lineup_timer.expires = jiffies + HZ * ch->lineup_delay;
- add_timer(&ch->lineup_timer);
- }
- }
- }
- }
- else if (leds != 0x2000 && board->lineup)
- { /* line down */
- board->lineup = 0;
- for (i = 0; i < 32; i++)
- if (board->twins[i] && (board->twins[i]->flags & IFF_RUNNING))
- {
- struct comx_channel *ch = board->twins[i]->priv;
-
- if (test_and_clear_bit(0, &ch->lineup_pending))
- del_timer(&ch->lineup_timer);
- else if (ch->line_status & LINE_UP)
- {
- ch->line_status &= ~LINE_UP;
- if (ch->LINE_status)
- ch->LINE_status(board->twins[i], ch->line_status);
- }
- }
- }
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-/*
- * This function gets called every second when the FALC issues the interrupt.
- * Hardware counters contain error counts for last 1-second time interval.
- * We add them to the global counters here.
- * Read rfc2495 to understand this.
- */
-
-void slicecom_update_line_counters(munich_board_t * board)
-{
- e1_stats_t *curr_int = &board->intervals[board->current_interval];
-
- u8 *lbi = board->lbi;
-
- unsigned framing_errors, code_violations, path_code_violations, crc4_errors,
- e_bit_errors;
- unsigned slip_detected, /* this one has logical value, not the number of slips! */
- out_of_frame_defect, /* logical value */
- ais_defect, /* logical value */
- errored_sec, bursty_err_sec, severely_err_sec = 0, failure_sec;
- u8 isr2, isr3, isr5, frs0;
-
- spin_lock_irqsave(&mister_lock, flags);
-
- isr2 = readb(lbi + ISR2); /* ISR0-5 described on page 156 */
- isr3 = readb(lbi + ISR3);
- isr5 = readb(lbi + ISR5);
- frs0 = readb(lbi + FRS0); /* FRS0 described on page 137 */
-
- /* Error Events: */
-
- code_violations = readb(lbi + CVCL) + (readb(lbi + CVCH) << 8);
- framing_errors = readb(lbi + FECL) + (readb(lbi + FECH) << 8);
- crc4_errors = readb(lbi + CEC1L) + (readb(lbi + CEC1H) << 8);
- e_bit_errors = readb(lbi + EBCL) + (readb(lbi + EBCH) << 8);
- slip_detected = isr3 & (ISR3_RSN | ISR3_RSP);
-
- path_code_violations = framing_errors + crc4_errors;
-
- curr_int->line_code_violations += code_violations;
- curr_int->path_code_violations += path_code_violations;
- curr_int->e_bit_errors += e_bit_errors;
-
- /* Performance Defects: */
-
- /* there was an LFA in the last second, but maybe disappeared: */
- out_of_frame_defect = (isr2 & ISR2_LFA) || (frs0 & FRS0_LFA);
-
- /* there was an AIS in the last second, but maybe disappeared: */
- ais_defect = (isr2 & ISR2_AIS) || (frs0 & FRS0_AIS);
-
- /* Performance Parameters: */
-
- if (out_of_frame_defect)
- curr_int->fr_loss_secs++;
- if (code_violations)
- curr_int->line_err_secs++;
-
- errored_sec = ((board->framing == SLICECOM_FRAMING_NO_CRC4) &&
- (code_violations)) || path_code_violations ||
- out_of_frame_defect || slip_detected || ais_defect;
-
- bursty_err_sec = !out_of_frame_defect && !ais_defect &&
- (path_code_violations > 1) && (path_code_violations < 320);
-
- switch (board->framing)
- {
- case SLICECOM_FRAMING_CRC4:
- severely_err_sec = out_of_frame_defect ||
- (path_code_violations >= 832);
- break;
- case SLICECOM_FRAMING_NO_CRC4:
- severely_err_sec = (code_violations >= 2048);
- break;
- }
-
- /*
- * failure_sec: true if there was a condition leading to a failure
- * (and leading to unavailable state) in this second:
- */
-
- failure_sec = (isr2 & ISR2_RA) || (frs0 & FRS0_RRA) /* Remote/Far End/Distant Alarm Failure */
- || ais_defect || out_of_frame_defect /* AIS or LOF Failure */
- || (isr2 & ISR2_LOS) || (frs0 & FRS0_LOS) /* Loss Of Signal Failure */
- || (board->loopback != SLICECOM_LOOPBACK_NONE); /* Loopback has been set */
-
- if (board->is_unavailable)
- {
- if (severely_err_sec)
- board->no_ses_seconds = 0;
- else
- board->no_ses_seconds++;
-
- if ((board->no_ses_seconds >= 10) && !failure_sec)
- {
- board->is_unavailable = 0;
- board->ses_seconds = 0;
- board->no_ses_seconds = 0;
- }
- }
- else
- {
- if (severely_err_sec)
- board->ses_seconds++;
- else
- board->ses_seconds = 0;
-
- if ((board->ses_seconds >= 10) || failure_sec)
- {
- board->is_unavailable = 1;
- board->ses_seconds = 0;
- board->no_ses_seconds = 0;
- }
- }
-
- if (board->is_unavailable)
- curr_int->unavail_secs++;
- else
- {
- if (slip_detected)
- curr_int->slip_secs++;
- curr_int->errored_secs += errored_sec;
- curr_int->bursty_err_secs += bursty_err_sec;
- curr_int->severely_err_secs += severely_err_sec;
- }
-
- /* the RFC does not say clearly which errors to count here, we try to count bit errors */
-
- if (!board->is_unavailable && !severely_err_sec)
- {
- board->deg_cumulated_errors += code_violations;
- board->deg_elapsed_seconds++;
- if (board->deg_elapsed_seconds >= 60)
- {
- if (board->deg_cumulated_errors >= 123)
- curr_int->degraded_mins++;
- board->deg_cumulated_errors = 0;
- board->deg_elapsed_seconds = 0;
- }
-
- }
-
- board->elapsed_seconds++;
- if (board->elapsed_seconds >= 900)
- {
- board->current_interval =
- (board->current_interval + 1) % SLICECOM_BOARD_INTERVALS_SIZE;
- memset((void *)&board->intervals[board->current_interval], 0,
- sizeof(e1_stats_t));
- board->elapsed_seconds = 0;
- }
-
- spin_unlock_irqrestore(&mister_lock, flags);
-}
-
-static void pcicom_modemline(unsigned long b)
-{
- munich_board_t *board = (munich_board_t *) b;
- struct net_device *dev = board->twins[0];
- struct comx_channel *ch = netdev_priv(dev);
- unsigned long regs;
-
- regs = readl((void *)(&board->bar1[GPDATA]));
- if ((ch->line_status & LINE_UP) && (regs & 0x0800))
- {
- ch->line_status &= ~LINE_UP;
- board->lineup = 0;
- if (ch->LINE_status)
- {
- ch->LINE_status(dev, ch->line_status);
- }
- }
-
- if (!(ch->line_status & LINE_UP) && !(regs & 0x0800))
- {
- ch->line_status |= LINE_UP;
- board->lineup = 1;
- if (ch->LINE_status)
- {
- ch->LINE_status(dev, ch->line_status);
- }
- }
-
- mod_timer((struct timer_list *)&board->modemline_timer, jiffies + HZ);
-}
-
-/*
- * Is it possible to transmit ?
- * Called (may be called) by the protocol layer
- */
-
-static int MUNICH_txe(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
-
- return (hw->busy < TX_DESC_MAX - 1);
-}
-
-/*
- * Hw probe function. Detects all the boards in the system,
- * and fills up slicecom_boards[] and pcicom_boards[]
- * Returns 0 on success.
- * We do not disable interrupts!
- */
-static int munich_probe(void)
-{
- struct pci_dev *pci;
- int boardnum;
- int slicecom_boardnum;
- int pcicom_boardnum;
- u32 *bar1;
- u8 *lbi;
- munich_board_t *board;
-
- for (boardnum = 0; boardnum < MAX_BOARDS; boardnum++)
- {
- pcicom_boards[boardnum].pci = 0;
- pcicom_boards[boardnum].bar1 = 0;
- pcicom_boards[boardnum].lbi = 0;
- slicecom_boards[boardnum].pci = 0;
- slicecom_boards[boardnum].bar1 = 0;
- slicecom_boards[boardnum].lbi = 0;
- }
-
- pci = NULL;
- board = NULL;
- slicecom_boardnum = 0;
- pcicom_boardnum = 0;
-
- for (boardnum = 0;
- boardnum < MAX_BOARDS && (pci = pci_find_device(PCI_VENDOR_ID_SIEMENS,
- PCI_DEVICE_ID_SIEMENS_MUNICH32X, pci)); boardnum++)
- {
- if (pci_enable_device(pci))
- continue;
-
- printk("munich_probe: munich chip found, IRQ %d\n", pci->irq);
-
- bar1 = ioremap_nocache(pci->resource[0].start, 0x100);
- lbi = ioremap_nocache(pci->resource[1].start, 0x100);
-
- if (bar1 && lbi)
- {
- pci_write_config_dword(pci, MUNICH_PCI_PCIRES, 0xe0000);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- pci_write_config_dword(pci, MUNICH_PCI_PCIRES, 0);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- /* check the type of the card */
- writel(LREG0_MAGIC, MUNICH_VIRT(LREG0));
- writel(LREG1_MAGIC, MUNICH_VIRT(LREG1));
- writel(LREG2_MAGIC, MUNICH_VIRT(LREG2));
- writel(LREG3_MAGIC, MUNICH_VIRT(LREG3));
- writel(LREG4_MAGIC, MUNICH_VIRT(LREG4));
- writel(LREG5_MAGIC, MUNICH_VIRT(LREG5));
- writel(LCONF_MAGIC2,MUNICH_VIRT(LCONF)); /* enable the DMSM */
-
- if ((readb(lbi + VSTR) == 0x13) || (readb(lbi + VSTR) == 0x10))
- {
- board = slicecom_boards + slicecom_boardnum;
- sprintf((char *)board->devname, "slicecom%d",
- slicecom_boardnum);
- board->isx21 = 0;
- slicecom_boardnum++;
- }
- else if ((readb(lbi + VSTR) == 0x6) || (readb(lbi + GIS) == 0x6))
- {
- board = pcicom_boards + pcicom_boardnum;
- sprintf((char *)board->devname, "pcicom%d", pcicom_boardnum);
- board->isx21 = 1;
- pcicom_boardnum++;
- }
- if (board)
- {
- printk("munich_probe: %s board found\n", board->devname);
- writel(LCONF_MAGIC1, MUNICH_VIRT(LCONF)); /* reset the DMSM */
- board->pci = pci;
- board->bar1 = bar1;
- board->lbi = lbi;
- board->framing = SLICECOM_FRAMING_DEFAULT;
- board->linecode = SLICECOM_LINECODE_DEFAULT;
- board->clock_source = SLICECOM_CLOCK_SOURCE_DEFAULT;
- board->loopback = SLICECOM_LOOPBACK_DEFAULT;
- board->owner = THIS_MODULE;
- }
- else
- {
- printk("munich_probe: Board error, VSTR: %02X\n",
- readb(lbi + VSTR));
- iounmap((void *)bar1);
- iounmap((void *)lbi);
- }
- }
- else
- {
- printk("munich_probe: ioremap() failed, not enabling this board!\n");
- /* .pci = NULL, so the MUNICH_open will not try to open it */
- if (bar1) iounmap((void *)bar1);
- if (lbi) iounmap((void *)lbi);
- }
- }
-
- if (!pci && !boardnum)
- {
- printk("munich_probe: no PCI present!\n");
- return -ENODEV;
- }
-
- if (pcicom_boardnum + slicecom_boardnum == 0)
- {
- printk
- ("munich_probe: Couldn't find any munich board: vendor:device %x:%x not found\n",
- PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_MUNICH32X);
- return -ENODEV;
- }
-
- /* Found some */
- if (pcicom_boardnum)
- printk("%d pcicom board(s) found.\n", pcicom_boardnum);
- if (slicecom_boardnum)
- printk("%d slicecom board(s) found.\n", slicecom_boardnum);
-
- return 0;
-}
-
-/*
- * Reset the hardware. Get called only from within this module if needed.
- */
-#if 0
-static int slicecom_reset(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
-
- printk("slicecom_reset: resetting the hardware\n");
-
- /* Begin to reset the hardware */
-
- if (ch->HW_set_clock)
- ch->HW_set_clock(dev);
-
- /* And finish it */
-
- return 0;
-}
-#endif
-
-/*
- * Transmit a packet.
- * Called by the protocol layer
- * Return values:
- * FRAME_ACCEPTED: frame is being transmited, transmitter is busy
- * FRAME_QUEUED: frame is being transmitted, there's more room in
- * the transmitter for additional packet(s)
- * FRAME_ERROR:
- * FRAME_DROPPED: there was some error
- */
-
-static int MUNICH_send_packet(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
-
- /* Send it to the debug facility too if needed: */
-
- if (ch->debug_flags & DEBUG_HW_TX)
- comx_debug_bytes(dev, skb->data, skb->len, "MUNICH_send_packet");
-
- /* If the line is inactive, don't accept: */
-
- /* TODO: atgondolni hogy mi is legyen itt */
- /* if (!(ch->line_status & LINE_UP)) return FRAME_DROPPED; */
-
- /* More check, to be sure: */
-
- if (skb->len > TXBUFFER_SIZE)
- {
- ch->stats.tx_errors++;
- kfree_skb(skb);
- return FRAME_ERROR;
- }
-
- /* Maybe you have to disable irq's while programming the hw: */
-
- spin_lock_irqsave(&mister_lock, flags);
-
- /* And more check: */
-
- if (hw->busy >= TX_DESC_MAX - 1)
- {
- printk(KERN_ERR
- "%s: Transmitter called while busy... dropping frame, busy = %d\n",
- dev->name, hw->busy);
- spin_unlock_irqrestore(&mister_lock, flags);
- kfree_skb(skb);
- return FRAME_DROPPED;
- }
-
- if (hw->busy >= 0)
- hw->tx_ring_hist[hw->busy]++;
- /* DELL: */
- else
- printk("slicecom: %s: FATAL: busy = %d\n", dev->name, hw->busy);
-
-// /* DEL: */
-// printk("slicecom: %s: _send_packet called, busy = %d\n", dev->name, hw->busy );
-
- /* Packet can go, update stats: */
-
- ch->stats.tx_packets++;
- ch->stats.tx_bytes += skb->len;
-
- /* Pass the packet to the HW: */
- /* Step forward with the transmit descriptors: */
-
- hw->tx_desc_ptr = (hw->tx_desc_ptr + 1) % TX_DESC_MAX;
-
- memcpy(&(hw->tx_data[hw->tx_desc_ptr][0]), skb->data, skb->len);
- hw->tx_desc[hw->tx_desc_ptr].no = skb->len;
-
- /* We don't issue any command, just step with the HOLD bit */
-
- hw->tx_desc[hw->tx_desc_ptr].hold = 1;
- hw->tx_desc[(hw->tx_desc_ptr + TX_DESC_MAX - 1) % TX_DESC_MAX].hold = 0;
-
-#ifdef COMX_NEW
- dev_kfree_skb(skb);
-#endif
- /* csomag kerult a Tx ringbe: */
-
- hw->busy++;
-
- /* Report it: */
-
- if (ch->debug_flags & DEBUG_HW_TX)
- comx_debug(dev, "%s: MUNICH_send_packet was successful\n\n", dev->name);
-
- if (hw->busy >= TX_DESC_MAX - 1)
- {
- spin_unlock_irqrestore(&mister_lock, flags);
- return FRAME_ACCEPTED;
- }
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- /* All done */
-
- return FRAME_QUEUED;
-}
-
-/*
- * Interrupt handler routine.
- * Called by the Linux kernel.
- * BEWARE! The interrupts are enabled on the call!
- */
-static irqreturn_t MUNICH_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct sk_buff *skb;
- int length;
- int rx_status;
- int work; /* hany esemenyt kezeltem mar le */
- u32 *bar1;
- u8 *lbi;
- u32 stat, /* az esemenyek, amiket a ebben a loop korben le kell meg kezelni */
- race_stat = 0, /* race eseten ebben uzenek magamnak hogy mit kell meg lekezelni */
- ack; /* ezt fogom a vegen a STAT-ba irni, kiveszek belole 1-1 bitet ha */
-
- /* az adott dolgot nem kell ack-olni mert volt vele munkam, es */
- /* legjobb ha visszaterek ide megegyszer */
- munich_intq_t int_info;
-
- struct net_device *dev;
- struct comx_channel *ch;
- struct slicecom_privdata *hw;
- munich_board_t *board = (munich_board_t *) dev_id;
- int channel;
-
- // , boardnum = (int)dev_id;
-
- // board = munich_boards + boardnum;
- bar1 = board->bar1;
- lbi = board->lbi;
-
- // Do not uncomment this under heavy load! :->
- // printk("MUNICH_interrupt: masked STAT=0x%08x, tiq=0x%08x, riq=0x%08x, piq=0x%08x\n", stat, board->tiq[0].all, board->riq[0].all, board->piq[0].all );
-
- for (work = 0; (stat = (race_stat | (readl(MUNICH_VIRT(STAT)) & ~STAT_NOT_HANDLED_BY_INTERRUPT))) && (work < MAX_WORK - 1); work++)
- {
- ack = stat & (STAT_PRI | STAT_PTI | STAT_LBII);
-
- /* Handle the interrupt information in the Rx queue. We don't really trust */
- /* info from this queue, because it can be overflowed, so later check */
- /* every Rx ring for received packets. But there are some errors which can't */
- /* be counted from the Rx rings, so we parse it. */
-
- int_info = board->riq[board->riq_ptr];
- if (int_info.all & 0xF0000000) /* ha ez nem 0, akkor itt interrupt_info van */
- {
- ack &= ~STAT_PRI; /* don't ack the interrupt, we had some work to do */
-
- channel = PCM_INT_CHANNEL(int_info.all);
- dev = board->twins[channel];
-
- if (dev == NULL)
- {
- printk
- ("MUNICH_interrupt: got an Rx interrupt info for NULL device "
- "%s.twins[%d], int_info = 0x%08x\n", board->devname,
- channel, int_info.all);
- goto go_for_next_interrupt;
- }
-
- ch = netdev_priv(dev);
- hw = (struct slicecom_privdata *)ch->HW_privdata;
-
- // printk("Rx STAT=0x%08x int_info=0x%08x rx_desc_ptr=%d rx_desc.status=0x%01x\n",
- // stat, int_info.all, hw->rx_desc_ptr, hw->rx_desc[ hw->rx_desc_ptr ].status );
-
- if (int_info.all & PCM_INT_HI)
- printk("SliceCOM: %s: Host Initiated interrupt\n", dev->name);
- if (int_info.all & PCM_INT_IFC)
- printk("SliceCOM: %s: Idle/Flag Change\n", dev->name);
- /* TOD: jo ez az Idle/Flag Change valamire? - azonnal latszik belole hogy mikor ad a masik oldal */
- /* TOD: ilyen IT most nem is jon, mert ki van maszkolva az interrupt, biztosan kell ez? */
-
- if (int_info.all & PCM_INT_FO)
- /* Internal buffer (RB) overrun */
- ch->stats.rx_over_errors++; /* TOD: Ez azt jelenti hogy a belso RB nem volt hozzaferheto, es ezert kihagyott valamit. De nem csak csomag lehetett, hanem esemeny, stb. is. lasd page 247. Ezzel a 'cat status'-hoz igazodok, de a netdevice.h szerint nem egyertelmu hogy ide ez kellene. Nem lehet hogy rx_missed ? */
- /* DE: nem gotozok sehova, elvileg jo igy */
- /* kesobb meg visszaterek az FO-ra, ha packet-FO volt. Keresd a "packet-FO"-t. */
- if (int_info.all & PCM_INT_FI) /* frame received, but we do not trust the int_info queue */
- if (int_info.all & PCM_INT_SF)
- { /* Short Frame: rovidebb mint a CRC */
- /* "rovidebb mint CRC+2byte" vizsgalat a "CRC+2"-nel */
- ch->stats.rx_length_errors++; /* TOD: noveljem? ne noveljem? */
- goto go_for_next_interrupt;
- }
-
- go_for_next_interrupt: /* One step in the interrupt queue */
- board->riq[board->riq_ptr].all = 0; /* megjelolom hogy itt meg nem jart a hw */
- board->riq_ptr = (board->riq_ptr + 1) % MUNICH_INTQMAX;
-
- }
-
- /* Check every Rx ring for incomed packets: */
-
- for (channel = 0; channel < 32; channel++)
- {
- dev = board->twins[channel];
-
- if (dev != NULL)
- {
- ch = netdev_priv(dev);
- hw = (struct slicecom_privdata *)ch->HW_privdata;
-
- rx_status = hw->rx_desc[hw->rx_desc_ptr].status;
-
- if (!(rx_status & 0x80)) /* mar jart itt a hardver */
- {
- ack &= ~STAT_PRI; /* Don't ack, we had some work */
-
- /* Ez most egy kicsit zuros, mert itt mar nem latom az int_infot */
- if (rx_status & RX_STATUS_ROF)
- ch->stats.rx_over_errors++; /* TOD: 'cat status'-hoz igazodok */
-
- if (rx_status & RX_STATUS_RA)
- /* Abort received or issued on channel */
- ch->stats.rx_frame_errors++; /* or HOLD bit in the descriptor */
- /* TOD: 'cat status'-hoz igazodok */
-
- if (rx_status & RX_STATUS_LFD)
- { /* Long Frame (longer then MFL in the MODE1) */
- ch->stats.rx_length_errors++;
- goto go_for_next_frame;
- }
-
- if (rx_status & RX_STATUS_NOB)
- { /* Not n*8 bits long frame - frame alignment */
- ch->stats.rx_frame_errors++; /* ez viszont nem igazodik a 'cat status'-hoz */
- goto go_for_next_frame;
- }
-
- if (rx_status & RX_STATUS_CRCO)
- { /* CRC error */
- ch->stats.rx_crc_errors++;
- goto go_for_next_frame;
- }
-
- if (rx_status & RX_STATUS_SF)
- { /* Short Frame: rovidebb mint CRC+2byte */
- ch->stats.rx_errors++; /* The HW does not set PCI_INT_ERR bit for this one, see page 246 */
- ch->stats.rx_length_errors++;
- goto go_for_next_frame;
- }
-
- if (rx_status != 0)
- {
- printk("SliceCOM: %s: unhandled rx_status: 0x%02x\n",
- dev->name, rx_status);
- goto go_for_next_frame;
- }
-
- /* frame received without errors: */
-
- length = hw->rx_desc[hw->rx_desc_ptr].bno;
- ch->stats.rx_packets++; /* Count only 'good' packets */
- ch->stats.rx_bytes += length;
-
- /* Allocate a larger skb and reserve the heading for efficiency: */
-
- if ((skb = dev_alloc_skb(length + 16)) == NULL)
- {
- ch->stats.rx_dropped++;
- goto go_for_next_frame;
- }
-
- /* Do bookkeeping: */
-
- skb_reserve(skb, 16);
- skb_put(skb, length);
- skb->dev = dev;
-
- /* Now copy the data into the buffer: */
-
- memcpy(skb->data, &(hw->rx_data[hw->rx_desc_ptr][0]), length);
-
- /* DEL: UGLY HACK!!!! */
- if (*((int *)skb->data) == 0x02000000 &&
- *(((int *)skb->data) + 1) == 0x3580008f)
- {
- printk("%s: swapping hack\n", dev->name);
- *((int *)skb->data) = 0x3580008f;
- *(((int *)skb->data) + 1) = 0x02000000;
- }
-
- if (ch->debug_flags & DEBUG_HW_RX)
- comx_debug_skb(dev, skb, "MUNICH_interrupt receiving");
-
- /* Pass it to the protocol entity: */
-
- ch->LINE_rx(dev, skb);
-
- go_for_next_frame:
- /* DEL: rafutott-e a HOLD bitre -detektalas */
- {
- if( ((rx_desc_t*)phys_to_virt(board->ccb->current_rx_desc[channel]))->hold
- && ((rx_desc_t*)phys_to_virt(board->ccb->current_rx_desc[channel]))->status != 0xff)
- hw->rafutott++; /* rafutott: hanyszor volt olyan hogy a current descriptoron HOLD bit volt, es a hw mar befejezte az irast (azaz a hw rafutott a HOLD bitre) */
- }
-
- // if( jiffies % 2 ) /* DELL: okozzunk egy kis Rx ring slipet :) */
- // {
- /* Step forward with the receive descriptors: */
- /* if you change this, change the copy of it below too! Search for: "RxSlip" */
- hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 1) % RX_DESC_MAX].hold = 1;
- hw->rx_desc[hw->rx_desc_ptr].status = 0xFF; /* megjelolom hogy itt meg nem jart a hw */
- hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 2) % RX_DESC_MAX].hold = 0;
- hw->rx_desc_ptr = (hw->rx_desc_ptr + 1) % RX_DESC_MAX;
- // }
- }
- }
- }
-
- stat &= ~STAT_PRI;
-
-// }
-
-// if( stat & STAT_PTI ) /* TOD: primko megvalositas: mindig csak egy esemenyt dolgozok fel, */
- /* es nem torlom a STAT-ot, ezert ujra visszajon ide a rendszer. Amikor */
- /* jon interrupt, de nincs mit feldolgozni, akkor torlom a STAT-ot. */
- /* 'needs a rewrite', de elso megoldasnak jo lesz */
-// {
- int_info = board->tiq[board->tiq_ptr];
- if (int_info.all & 0xF0000000) /* ha ez nem 0, akkor itt interrupt_info van */
- {
- ack &= ~STAT_PTI; /* don't ack the interrupt, we had some work to do */
-
- channel = PCM_INT_CHANNEL(int_info.all);
- dev = board->twins[channel];
-
- if (dev == NULL)
- {
- printk("MUNICH_interrupt: got a Tx interrupt for NULL device "
- "%s.twins[%d], int_info = 0x%08x\n",
- board->isx21 ? "pcicom" : "slicecom", channel, int_info.all);
- goto go_for_next_tx_interrupt;
- }
-
- ch = netdev_priv(dev);
- hw = (struct slicecom_privdata *)ch->HW_privdata;
-
- // printk("Tx STAT=0x%08x int_info=0x%08x tiq_ptr=%d\n", stat, int_info.all, board->tiq_ptr );
-
- if (int_info.all & PCM_INT_FE2)
- { /* "Tx available" */
- /* do nothing */
- }
- else if (int_info.all & PCM_INT_FO)
- { /* Internal buffer (RB) overrun */
- ch->stats.rx_over_errors++;
- }
- else
- {
- printk("slicecom: %s: unhandled Tx int_info: 0x%08x\n",
- dev->name, int_info.all);
- }
-
- go_for_next_tx_interrupt:
- board->tiq[board->tiq_ptr].all = 0;
- board->tiq_ptr = (board->tiq_ptr + 1) % MUNICH_INTQMAX;
- }
-
- /* Check every Tx ring for incoming packets: */
-
- for (channel = 0; channel < 32; channel++)
- {
- dev = board->twins[channel];
-
- if (dev != NULL)
- {
- int newbusy;
-
- ch = netdev_priv(dev);
- hw = (struct slicecom_privdata *)ch->HW_privdata;
-
- /* We don't trust the "Tx available" info from the TIQ, but check */
- /* every ring if there is some free room */
-
- if (ch->init_status && netif_running(dev))
- {
- newbusy = ( TX_DESC_MAX + (& hw->tx_desc[ hw->tx_desc_ptr ]) -
- (tx_desc_t*)phys_to_virt(board->ccb->current_tx_desc[ hw->channel ]) ) % TX_DESC_MAX;
-
- if(newbusy < 0)
- {
- printk("slicecom: %s: FATAL: fresly computed busy = %d, HW: 0x%p, SW: 0x%p\n",
- dev->name, newbusy,
- phys_to_virt(board->ccb->current_tx_desc[hw->channel]),
- & hw->tx_desc[hw->tx_desc_ptr]);
- }
-
- /* Fogyott valami a Tx ringbol? */
-
- if (newbusy < hw->busy)
- {
- // ack &= ~STAT_PTI; /* Don't ack, we had some work */
- hw->busy = newbusy;
- if (ch->LINE_tx)
- ch->LINE_tx(dev); /* Report it to protocol driver */
- }
- else if (newbusy > hw->busy)
- printk("slicecom: %s: newbusy > hw->busy, this should not happen!\n", dev->name);
- }
- }
- }
- stat &= ~STAT_PTI;
-
- int_info = board->piq[board->piq_ptr];
- if (int_info.all & 0xF0000000) /* ha ez nem 0, akkor itt interrupt_info van */
- {
- ack &= ~STAT_LBII; /* don't ack the interrupt, we had some work to do */
-
- /* We do not really use (yet) the interrupt info from this queue, */
-
- // printk("slicecom: %s: LBI Interrupt event: %08x\n", board->devname, int_info.all);
-
- if (!board->isx21)
- {
- slicecom_update_leds(board);
- slicecom_update_line_counters(board);
- }
-
- goto go_for_next_lbi_interrupt; /* To avoid warning about unused label */
-
- go_for_next_lbi_interrupt: /* One step in the interrupt queue */
- board->piq[board->piq_ptr].all = 0; /* megjelolom hogy itt meg nem jart a hw */
- board->piq_ptr = (board->piq_ptr + 1) % MUNICH_PIQMAX;
- }
- stat &= ~STAT_LBII;
-
- writel(ack, MUNICH_VIRT(STAT));
-
- if (stat & STAT_TSPA)
- {
- // printk("slicecom: %s: PCM TSP Asynchronous\n", board->devname);
- writel(STAT_TSPA, MUNICH_VIRT(STAT));
- stat &= ~STAT_TSPA;
- }
-
- if (stat & STAT_RSPA)
- {
- // printk("slicecom: %s: PCM RSP Asynchronous\n", board->devname);
- writel(STAT_RSPA, MUNICH_VIRT(STAT));
- stat &= ~STAT_RSPA;
- }
- if (stat)
- {
- printk("MUNICH_interrupt: unhandled interrupt, STAT=0x%08x\n",
- stat);
- writel(stat, MUNICH_VIRT(STAT)); /* ha valamit megsem kezeltunk le, azert ack-ot kuldunk neki */
- }
-
- }
- board->histogram[work]++;
-
- /* We can miss these if we reach the MAX_WORK */
- /* Count it to see how often it happens */
-
- if (race_stat & STAT_PRI)
- board->stat_pri_races_missed++;
- if (race_stat & STAT_PTI)
- board->stat_pti_races_missed++;
- return IRQ_HANDLED;
-}
-
-/*
- * Hardware open routine.
- * Called by comx (upper) layer when the user wants to bring up the interface
- * with ifconfig.
- * Initializes hardware, allocates resources etc.
- * Returns 0 on OK, or standard error value on error.
- */
-
-static int MUNICH_open(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- munich_board_t *board;
- munich_ccb_t *ccb;
-
- u32 *bar1;
- u8 *lbi;
- u32 stat;
- unsigned long flags, jiffs;
-
- int i, channel;
- u32 timeslots = hw->timeslots;
-
- board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- bar1 = board->bar1;
- lbi = board->lbi;
-
- /* TODO: a timeslotok ellenorzese kell majd ide .. hat, biztos? mar a write_proc-ban is
- ellenorzom valamennyire.
- if (!dev->io || !dev->irq) return -ENODEV;
- */
-
- if (!board->pci)
- {
- printk("MUNICH_open: no %s board with boardnum = %d\n",
- ch->hardware->name, hw->boardnum);
- return -ENODEV;
- }
-
- spin_lock_irqsave(&mister_lock, flags);
- /* lock the section to avoid race with multiple opens and make sure
- that no interrupts get called while this lock is active */
-
- if (board->use_count == 0) /* bring up the board if it was unused */
- /* if fails, frees allocated resources and returns. */
- /* TOD: is it safe? nem kellene resetelni a kartyat? */
- {
- printk("MUNICH_open: %s: bringing up board\n", board->devname);
-
- /* Clean up the board's static struct if messed: */
-
- for (i = 0; i < 32; i++)
- board->twins[i] = NULL;
- for (i = 0; i < MAX_WORK; i++)
- board->histogram[i] = 0;
-
- board->lineup = 0;
-
- /* Allocate CCB: */
- board->ccb = kmalloc(sizeof(munich_ccb_t), GFP_KERNEL);
- if (board->ccb == NULL)
- {
- spin_unlock_irqrestore(&mister_lock, flags);
- return -ENOMEM;
- }
- memset((void *)board->ccb, 0, sizeof(munich_ccb_t));
- board->ccb->csa = virt_to_phys(board->ccb);
- ccb = board->ccb;
- for (i = 0; i < 32; i++)
- {
- ccb->timeslot_spec[i].tti = 1;
- ccb->timeslot_spec[i].rti = 1;
- }
-
- /* Interrupt queues: */
-
- board->tiq = kmalloc(MUNICH_INTQSIZE, GFP_KERNEL);
- if (board->tiq == NULL)
- {
- spin_unlock_irqrestore(&mister_lock, flags);
- return -ENOMEM;
- }
- memset((void *)board->tiq, 0, MUNICH_INTQSIZE);
-
- board->riq = kmalloc(MUNICH_INTQSIZE, GFP_KERNEL);
- if (board->riq == NULL)
- {
- spin_unlock_irqrestore(&mister_lock, flags);
- return -ENOMEM;
- }
- memset((void *)board->riq, 0, MUNICH_INTQSIZE);
-
- board->piq = kmalloc(MUNICH_PIQSIZE, GFP_KERNEL);
- if (board->piq == NULL)
- {
- spin_unlock_irqrestore(&mister_lock, flags);
- return -ENOMEM;
- }
- memset((void *)board->piq, 0, MUNICH_PIQSIZE);
-
- board->tiq_ptr = 0;
- board->riq_ptr = 0;
- board->piq_ptr = 0;
-
- /* Request irq: */
-
- board->irq = 0;
-
- /* (char*) cast to avoid warning about discarding volatile: */
- if (request_irq(board->pci->irq, MUNICH_interrupt, 0,
- (char *)board->devname, (void *)board))
- {
- printk("MUNICH_open: %s: unable to obtain irq %d\n", board->devname,
- board->pci->irq);
- /* TOD: free other resources (a sok malloc feljebb) */
- spin_unlock_irqrestore(&mister_lock, flags);
- return -EAGAIN;
- }
- board->irq = board->pci->irq; /* csak akkor legyen != 0, ha tenyleg le van foglalva nekunk */
-
- /* Programming device: */
-
- /* Reset the board like a power-on: */
- /* TOD:
- - It is not a real power-on: if a DMA transaction fails with master abort, the board
- stays in half-dead state.
- - It doesn't reset the FALC line driver */
-
- pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0xe0000);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0);
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- writel(virt_to_phys(&ccb->csa), MUNICH_VIRT(CCBA));
- writel(virt_to_phys( board->tiq ), MUNICH_VIRT(TIQBA));
- writel(MUNICH_INTQLEN, MUNICH_VIRT(TIQL));
- writel(virt_to_phys( board->riq ), MUNICH_VIRT(RIQBA));
- writel(MUNICH_INTQLEN, MUNICH_VIRT(RIQL));
- writel(virt_to_phys( board->piq ), MUNICH_VIRT(PIQBA));
- writel(MUNICH_PIQLEN, MUNICH_VIRT(PIQL));
-
- /* Put the magic values into the registers: */
-
- writel(MODE1_MAGIC, MUNICH_VIRT(MODE1));
- writel(MODE2_MAGIC, MUNICH_VIRT(MODE2));
-
- writel(LREG0_MAGIC, MUNICH_VIRT(LREG0));
- writel(LREG1_MAGIC, MUNICH_VIRT(LREG1));
- writel(LREG2_MAGIC, MUNICH_VIRT(LREG2));
- writel(LREG3_MAGIC, MUNICH_VIRT(LREG3));
- writel(LREG4_MAGIC, MUNICH_VIRT(LREG4));
- writel(LREG5_MAGIC, MUNICH_VIRT(LREG5));
-
- writel(LCONF_MAGIC1, MUNICH_VIRT(LCONF)); /* reset the DMSM */
- writel(LCONF_MAGIC2, MUNICH_VIRT(LCONF)); /* enable the DMSM */
-
- writel(~0, MUNICH_VIRT(TXPOLL));
- writel(board->isx21 ? 0x1400 : 0xa000, MUNICH_VIRT(GPDIR));
-
- if (readl(MUNICH_VIRT(STAT))) writel(readl(MUNICH_VIRT(STAT)), MUNICH_VIRT(STAT));
-
- ccb->action_spec = CCB_ACTIONSPEC_RES | CCB_ACTIONSPEC_IA;
- writel(CMD_ARPCM, MUNICH_VIRT(CMD)); /* Start the PCM core reset */
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- stat = 0; /* Wait for the action to complete max. 1 second */
- jiffs = jiffies;
- while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
- {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- }
-
- if (stat & STAT_PCMF)
- {
- printk(KERN_ERR
- "MUNICH_open: %s: Initial ARPCM failed. STAT=0x%08x\n",
- board->devname, stat);
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
- free_irq(board->irq, (void *)board); /* TOD: free other resources too *//* maybe shut down hw? */
- board->irq = 0;
- spin_unlock_irqrestore(&mister_lock, flags);
- return -EAGAIN;
- }
- else if (!(stat & STAT_PCMA))
- {
- printk(KERN_ERR
- "MUNICH_open: %s: Initial ARPCM timeout. STAT=0x%08x\n",
- board->devname, stat);
- free_irq(board->irq, (void *)board); /* TOD: free other resources too *//* maybe shut off the hw? */
- board->irq = 0;
- spin_unlock_irqrestore(&mister_lock, flags);
- return -EIO;
- }
-
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT)); /* Acknowledge */
-
- if (board->isx21) writel(0, MUNICH_VIRT(GPDATA));
-
- printk("MUNICH_open: %s: succesful HW-open took %ld jiffies\n",
- board->devname, jiffies - jiffs);
-
- /* Set up the FALC hanging on the Local Bus: */
-
- if (!board->isx21)
- {
- writeb(0x0e, lbi + FMR1);
- writeb(0, lbi + LIM0);
- writeb(0xb0, lbi + LIM1); /* TODO: input threshold */
- writeb(0xf7, lbi + XPM0);
- writeb(0x02, lbi + XPM1);
- writeb(0x00, lbi + XPM2);
- writeb(0xf0, lbi + FMR0);
- writeb(0x80, lbi + PCD);
- writeb(0x80, lbi + PCR);
- writeb(0x00, lbi + LIM2);
- writeb(0x07, lbi + XC0);
- writeb(0x3d, lbi + XC1);
- writeb(0x05, lbi + RC0);
- writeb(0x00, lbi + RC1);
- writeb(0x83, lbi + FMR2);
- writeb(0x9f, lbi + XSW);
- writeb(0x0f, lbi + XSP);
- writeb(0x00, lbi + TSWM);
- writeb(0xe0, lbi + MODE);
- writeb(0xff, lbi + IDLE); /* Idle Code to send in unused timeslots */
- writeb(0x83, lbi + IPC); /* interrupt query line mode: Push/pull output, active high */
- writeb(0xbf, lbi + IMR3); /* send an interrupt every second */
-
- slicecom_set_framing(hw->boardnum, board->framing);
- slicecom_set_linecode(hw->boardnum, board->linecode);
- slicecom_set_clock_source(hw->boardnum, board->clock_source);
- slicecom_set_loopback(hw->boardnum, board->loopback);
-
- memset((void *)board->intervals, 0, sizeof(board->intervals));
- board->current_interval = 0;
- board->elapsed_seconds = 0;
- board->ses_seconds = 0;
- board->is_unavailable = 0;
- board->no_ses_seconds = 0;
- board->deg_elapsed_seconds = 0;
- board->deg_cumulated_errors = 0;
- }
-
- /* Enable the interrupts last */
- /* These interrupts will be enabled. We do not need the others. */
-
- writel(readl(MUNICH_VIRT(IMASK)) & ~(STAT_PTI | STAT_PRI | STAT_LBII | STAT_TSPA | STAT_RSPA), MUNICH_VIRT(IMASK));
- }
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- dev->irq = board->irq; /* hogy szep legyen az ifconfig outputja */
- ccb = board->ccb; /* TODO: ez igy csunya egy kicsit hogy benn is meg kinn is beletoltom :( */
-
- spin_lock_irqsave(&mister_lock, flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- /* Check if the selected timeslots aren't used already */
-
- for (i = 0; i < 32; i++)
- if (((1 << i) & timeslots) && !ccb->timeslot_spec[i].tti)
- {
- printk("MUNICH_open: %s: timeslot %d already used by %s\n",
- dev->name, i, board->twins[ccb->timeslot_spec[i].txchannel]->name);
- spin_unlock_irqrestore(&mister_lock, flags);
- return -EBUSY; /* TODO: lehet hogy valami mas errno kellene? */
- }
-
- /* find a free channel: */
- /* TODO: ugly, rewrite it */
-
- for (channel = 0; channel <= 32; channel++)
- {
- if (channel == 32)
- { /* not found a free one */
- printk
- ("MUNICH_open: %s: FATAL: can not find a free channel - this should not happen!\n",
- dev->name);
- spin_unlock_irqrestore(&mister_lock, flags);
- return -ENODEV;
- }
- if (board->twins[channel] == NULL)
- break; /* found the first free one */
- }
-
- board->lastcheck = jiffies; /* avoid checking uninitialized hardware channel */
-
- /* Open the channel. If fails, calls MUNICH_close() to properly free resources and stop the HW */
-
- hw->channel = channel;
- board->twins[channel] = dev;
-
- board->use_count++; /* meg nem nyitottuk meg a csatornat, de a twins-ben
- mar elfoglaltunk egyet, es ha a _close-t akarjuk hivni, akkor ez kell. */
- for (i = 0; i < 32; i++)
- if ((1 << i) & timeslots)
- {
- ccb->timeslot_spec[i].tti = 0;
- ccb->timeslot_spec[i].txchannel = channel;
- ccb->timeslot_spec[i].txfillmask = ~0;
-
- ccb->timeslot_spec[i].rti = 0;
- ccb->timeslot_spec[i].rxchannel = channel;
- ccb->timeslot_spec[i].rxfillmask = ~0;
- }
-
- if (!board->isx21) rework_idle_channels(dev);
-
- memset((void *)&(hw->tx_desc), 0, TX_DESC_MAX * sizeof(tx_desc_t));
- memset((void *)&(hw->rx_desc), 0, RX_DESC_MAX * sizeof(rx_desc_t));
-
- for (i = 0; i < TX_DESC_MAX; i++)
- {
- hw->tx_desc[i].fe = 1;
- hw->tx_desc[i].fnum = 2;
- hw->tx_desc[i].data = virt_to_phys( & (hw->tx_data[i][0]) );
- hw->tx_desc[i].next = virt_to_phys( & (hw->tx_desc[ (i+1) % TX_DESC_MAX ]) );
-
- }
- hw->tx_desc_ptr = 0; /* we will send an initial packet so it is correct: "oda irtunk utoljara" */
- hw->busy = 0;
- hw->tx_desc[hw->tx_desc_ptr].hold = 1;
- hw->tx_desc[hw->tx_desc_ptr].no = 1; /* TOD: inkabb csak 0 hosszut kuldjunk ki az initkor? */
-
- for (i = 0; i < RX_DESC_MAX; i++)
- {
- hw->rx_desc[i].no = RXBUFFER_SIZE;
- hw->rx_desc[i].data = virt_to_phys(&(hw->rx_data[i][0]));
- hw->rx_desc[i].next = virt_to_phys(&(hw->rx_desc[(i+1) % RX_DESC_MAX]));
- hw->rx_desc[i].status = 0xFF;
- }
- hw->rx_desc_ptr = 0;
-
- hw->rx_desc[(hw->rx_desc_ptr + RX_DESC_MAX - 2) % RX_DESC_MAX].hold = 1;
-
- memset((void *)&ccb->channel_spec[channel], 0, sizeof(channel_spec_t));
-
- ccb->channel_spec[channel].ti = 0; /* Transmit off */
- ccb->channel_spec[channel].to = 1;
- ccb->channel_spec[channel].ta = 0;
-
- ccb->channel_spec[channel].th = 1; /* Transmit hold */
-
- ccb->channel_spec[channel].ri = 0; /* Receive off */
- ccb->channel_spec[channel].ro = 1;
- ccb->channel_spec[channel].ra = 0;
-
- ccb->channel_spec[channel].mode = 3; /* HDLC */
-
- ccb->action_spec = CCB_ACTIONSPEC_IN | (channel << 8);
- writel(CMD_ARPCM, MUNICH_VIRT(CMD));
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- stat = 0;
- jiffs = jiffies;
- while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
- {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- }
-
- if (stat & STAT_PCMF)
- {
- printk(KERN_ERR "MUNICH_open: %s: %s channel %d off failed\n",
- dev->name, board->devname, channel);
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
- MUNICH_close(dev);
- return -EAGAIN;
- }
- else if (!(stat & STAT_PCMA))
- {
- printk(KERN_ERR "MUNICH_open: %s: %s channel %d off timeout\n",
- dev->name, board->devname, channel);
- MUNICH_close(dev);
- return -EIO;
- }
-
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
- // printk("MUNICH_open: %s: succesful channel off took %ld jiffies\n", board->devname, jiffies-jiffs);
-
- spin_lock_irqsave(&mister_lock, flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- ccb->channel_spec[channel].ifc = 1; /* 1 .. 'Idle/Flag change' interrupt letiltva */
- ccb->channel_spec[channel].fit = 1;
- ccb->channel_spec[channel].nitbs = 1;
- ccb->channel_spec[channel].itbs = 2;
-
- /* TODOO: lehet hogy jo lenne igy, de utana kellene nezni hogy nem okoz-e fragmentaciot */
- // ccb->channel_spec[channel].itbs = 2 * number_of_timeslots;
- // printk("open: %s: number_of_timeslots: %d\n", dev->name, number_of_timeslots);
-
- ccb->channel_spec[channel].mode = 3; /* HDLC */
- ccb->channel_spec[channel].ftda = virt_to_phys(&(hw->tx_desc));
- ccb->channel_spec[channel].frda = virt_to_phys(&(hw->rx_desc[0]));
-
- ccb->channel_spec[channel].ti = 1; /* Transmit init */
- ccb->channel_spec[channel].to = 0;
- ccb->channel_spec[channel].ta = 1;
-
- ccb->channel_spec[channel].th = 0;
-
- ccb->channel_spec[channel].ri = 1; /* Receive init */
- ccb->channel_spec[channel].ro = 0;
- ccb->channel_spec[channel].ra = 1;
-
- ccb->action_spec = CCB_ACTIONSPEC_ICO | (channel << 8);
- writel(CMD_ARPCM, MUNICH_VIRT(CMD)); /* Start the channel init */
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- stat = 0; /* Wait for the action to complete max. 1 second */
- jiffs = jiffies;
- while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
- {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- }
-
- if (stat & STAT_PCMF)
- {
- printk(KERN_ERR "MUNICH_open: %s: channel open ARPCM failed\n",
- board->devname);
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
- MUNICH_close(dev);
- return -EAGAIN;
- }
- else if (!(stat & STAT_PCMA))
- {
- printk(KERN_ERR "MUNICH_open: %s: channel open ARPCM timeout\n",
- board->devname);
- MUNICH_close(dev);
- return -EIO;
- }
-
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
- // printk("MUNICH_open: %s: succesful channel open took %ld jiffies\n", board->devname, jiffies-jiffs);
-
- spin_lock_irqsave(&mister_lock, flags);
-
- ccb->channel_spec[channel].nitbs = 0; /* once ITBS defined, these must be 0 */
- ccb->channel_spec[channel].itbs = 0;
-
- if (board->isx21)
- {
- init_timer(&board->modemline_timer);
- board->modemline_timer.data = (unsigned long)board;
- board->modemline_timer.function = pcicom_modemline;
- board->modemline_timer.expires = jiffies + HZ;
- add_timer((struct timer_list *)&board->modemline_timer);
- }
-
- /* It is done. Declare that we're open: */
- hw->busy = 0; /* It may be 1 if the frame at Tx init already ended, but it is not */
- /* a real problem: we compute hw->busy on every interrupt */
- hw->rafutott = 0;
- ch->init_status |= HW_OPEN;
-
- /* Initialize line state: */
- if (board->lineup)
- ch->line_status |= LINE_UP;
- else
- ch->line_status &= ~LINE_UP;
-
- /* Remove w attribute from /proc files associated to hw parameters:
- no write when the device is open */
-
- for (; procfile; procfile = procfile->next)
- if (strcmp(procfile->name, FILENAME_BOARDNUM) == 0 ||
- strcmp(procfile->name, FILENAME_TIMESLOTS) == 0)
- procfile->mode = S_IFREG | 0444;
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- return 0;
-}
-
-/*
- * Hardware close routine.
- * Called by comx (upper) layer when the user wants to bring down the interface
- * with ifconfig.
- * We also call it from MUNICH_open, if the open fails.
- * Brings down hardware, frees resources, stops receiver
- * Returns 0 on OK, or standard error value on error.
- */
-
-static int MUNICH_close(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- struct proc_dir_entry *procfile = ch->procdir->subdir;
- munich_board_t *board;
- munich_ccb_t *ccb;
-
- u32 *bar1;
- u32 timeslots = hw->timeslots;
- int stat, i, channel = hw->channel;
- unsigned long jiffs;
-
- board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- ccb = board->ccb;
- bar1 = board->bar1;
-
- if (board->isx21)
- del_timer((struct timer_list *)&board->modemline_timer);
-
- spin_lock_irqsave(&mister_lock, flags);
-
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- /* Disable receiver for the channel: */
-
- for (i = 0; i < 32; i++)
- if ((1 << i) & timeslots)
- {
- ccb->timeslot_spec[i].tti = 1;
- ccb->timeslot_spec[i].txfillmask = 0; /* just to be double-sure :) */
-
- ccb->timeslot_spec[i].rti = 1;
- ccb->timeslot_spec[i].rxfillmask = 0;
- }
-
- if (!board->isx21) rework_idle_channels(dev);
-
- ccb->channel_spec[channel].ti = 0; /* Receive off, Transmit off */
- ccb->channel_spec[channel].to = 1;
- ccb->channel_spec[channel].ta = 0;
- ccb->channel_spec[channel].th = 1;
-
- ccb->channel_spec[channel].ri = 0;
- ccb->channel_spec[channel].ro = 1;
- ccb->channel_spec[channel].ra = 0;
-
- board->twins[channel] = NULL;
-
- ccb->action_spec = CCB_ACTIONSPEC_IN | (channel << 8);
- writel(CMD_ARPCM, MUNICH_VIRT(CMD));
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- stat = 0;
- jiffs = jiffies;
- while (!((stat = readl(MUNICH_VIRT(STAT))) & (STAT_PCMA | STAT_PCMF)) && time_before(jiffies, jiffs + HZ))
- {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- }
-
- if (stat & STAT_PCMF)
- {
- printk(KERN_ERR
- "MUNICH_close: %s: FATAL: channel off ARPCM failed, not closing!\n",
- dev->name);
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMF, MUNICH_VIRT(STAT));
- /* If we return success, the privdata (and the descriptor list) will be freed */
- return -EIO;
- }
- else if (!(stat & STAT_PCMA))
- printk(KERN_ERR "MUNICH_close: %s: channel off ARPCM timeout\n",
- board->devname);
-
- writel(readl(MUNICH_VIRT(STAT)) & STAT_PCMA, MUNICH_VIRT(STAT));
- // printk("MUNICH_close: %s: channel off took %ld jiffies\n", board->devname, jiffies-jiffs);
-
- spin_lock_irqsave(&mister_lock, flags);
-
- if (board->use_count) board->use_count--;
-
- if (!board->use_count) /* we were the last user of the board */
- {
- printk("MUNICH_close: bringing down board %s\n", board->devname);
-
- /* program down the board: */
-
- writel(0x0000FF7F, MUNICH_VIRT(IMASK)); /* do not send any interrupts */
- writel(0, MUNICH_VIRT(CMD)); /* stop the timer if someone started it */
- writel(~0U, MUNICH_VIRT(STAT)); /* if an interrupt came between the cli()-sti(), quiet it */
- if (ch->hardware == &pcicomhw)
- writel(0x1400, MUNICH_VIRT(GPDATA));
-
- /* Put the board into 'reset' state: */
- pci_write_config_dword(board->pci, MUNICH_PCI_PCIRES, 0xe0000);
-
- /* Free irq and other resources: */
- if (board->irq)
- free_irq(board->irq, (void *)board); /* Ha nem inicializalta magat, akkor meg nincs irq */
- board->irq = 0;
-
- /* Free CCB and the interrupt queues */
- if (board->ccb) kfree((void *)board->ccb);
- if (board->tiq) kfree((void *)board->tiq);
- if (board->riq) kfree((void *)board->riq);
- if (board->piq) kfree((void *)board->piq);
- board->ccb = NULL;
- board->tiq = board->riq = board->piq = NULL;
- }
-
- /* Enable setting of hw parameters */
- for (; procfile; procfile = procfile->next)
- if (strcmp(procfile->name, FILENAME_BOARDNUM) == 0 ||
- strcmp(procfile->name, FILENAME_TIMESLOTS) == 0)
- procfile->mode = S_IFREG | 0644;
-
- /* We're not open anymore */
- ch->init_status &= ~HW_OPEN;
-
- spin_unlock_irqrestore(&mister_lock, flags);
-
- return 0;
-}
-
-/*
- * Give (textual) status information.
- * The text it returns will be a part of what appears when the user does a
- * cat /proc/comx/comx[n]/status
- * Don't write more than PAGESIZE.
- * Return value: number of bytes written (length of the string, incl. 0)
- */
-
-static int MUNICH_minden(struct net_device *dev, char *page)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- munich_board_t *board;
- struct net_device *devp;
-
- u8 *lbi;
- e1_stats_t *curr_int, *prev_int;
- e1_stats_t last4, last96; /* sum of last 4, resp. last 96 intervals */
- unsigned *sump, /* running pointer for the sum data */
- *p; /* running pointer for the interval data */
-
- int len = 0;
- u8 frs0, frs1;
- u8 fmr2;
- int i, j;
- u32 timeslots;
-
- board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- lbi = board->lbi;
- curr_int = &board->intervals[board->current_interval];
- prev_int =
- &board->
- intervals[(board->current_interval + SLICECOM_BOARD_INTERVALS_SIZE -
- 1) % SLICECOM_BOARD_INTERVALS_SIZE];
-
- if (!board->isx21)
- {
- frs0 = readb(lbi + FRS0);
- fmr2 = readb(lbi + FMR2);
- len += scnprintf(page + len, PAGE_SIZE - len, "Controller status:\n");
- if (frs0 == 0)
- len += scnprintf(page + len, PAGE_SIZE - len, "\tNo alarms\n");
- else
- {
- if (frs0 & FRS0_LOS)
- len += scnprintf(page + len, PAGE_SIZE - len, "\tLoss Of Signal\n");
- else
- {
- if (frs0 & FRS0_AIS)
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tAlarm Indication Signal\n");
- else
- {
- if (frs0 & FRS0_AUXP)
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tAuxiliary Pattern Indication\n");
- if (frs0 & FRS0_LFA)
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tLoss of Frame Alignment\n");
- else
- {
- if (frs0 & FRS0_RRA)
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tReceive Remote Alarm\n");
-
- /* You can't set this framing with the /proc interface, but it */
- /* may be good to have here this alarm if you set it by hand: */
-
- if ((board->framing == SLICECOM_FRAMING_CRC4) &&
- (frs0 & FRS0_LMFA))
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tLoss of CRC4 Multiframe Alignment\n");
-
- if (((fmr2 & 0xc0) == 0xc0) && (frs0 & FRS0_NMF))
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tNo CRC4 Multiframe alignment Found after 400 msec\n");
- }
- }
- }
- }
-
- frs1 = readb(lbi + FRS1);
- if (FRS1_XLS & frs1)
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tTransmit Line Short\n");
-
- /* debug Rx ring: DEL: - vagy meghagyni, de akkor legyen kicsit altalanosabb */
- }
-
- len += scnprintf(page + len, PAGE_SIZE - len, "Rx ring:\n");
- len += scnprintf(page + len, PAGE_SIZE - len, "\trafutott: %d\n", hw->rafutott);
- len += scnprintf(page + len, PAGE_SIZE - len,
- "\tlastcheck: %ld, jiffies: %ld\n", board->lastcheck, jiffies);
- len += scnprintf(page + len, PAGE_SIZE - len, "\tbase: %08x\n",
- (u32) virt_to_phys(&hw->rx_desc[0]));
- len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %d\n",
- hw->rx_desc_ptr);
- len += scnprintf(page + len, PAGE_SIZE - len, "\trx_desc_ptr: %08x\n",
- (u32) virt_to_phys(&hw->rx_desc[hw->rx_desc_ptr]));
- len += scnprintf(page + len, PAGE_SIZE - len, "\thw_curr_ptr: %08x\n",
- board->ccb->current_rx_desc[hw->channel]);
-
- for (i = 0; i < RX_DESC_MAX; i++)
- len += scnprintf(page + len, PAGE_SIZE - len, "\t%08x %08x %08x %08x\n",
- *((u32 *) & hw->rx_desc[i] + 0),
- *((u32 *) & hw->rx_desc[i] + 1),
- *((u32 *) & hw->rx_desc[i] + 2),
- *((u32 *) & hw->rx_desc[i] + 3));
-
- if (!board->isx21)
- {
- len += scnprintf(page + len, PAGE_SIZE - len,
- "Interfaces using this board: (channel-group, interface, timeslots)\n");
- for (i = 0; i < 32; i++)
- {
- devp = board->twins[i];
- if (devp != NULL)
- {
- timeslots =
- ((struct slicecom_privdata *)((struct comx_channel *)devp->
- priv)->HW_privdata)->
- timeslots;
- len += scnprintf(page + len, PAGE_SIZE - len, "\t%2d %s: ", i,
- devp->name);
- for (j = 0; j < 32; j++)
- if ((1 << j) & timeslots)
- len += scnprintf(page + len, PAGE_SIZE - len, "%d ", j);
- len += scnprintf(page + len, PAGE_SIZE - len, "\n");
- }
- }
- }
-
- len += scnprintf(page + len, PAGE_SIZE - len, "Interrupt work histogram:\n");
- for (i = 0; i < MAX_WORK; i++)
- len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
- board->histogram[i], (i &&
- ((i + 1) % 4 == 0 ||
- i == MAX_WORK - 1)) ? '\n' : ' ');
-
- len += scnprintf(page + len, PAGE_SIZE - len, "Tx ring histogram:\n");
- for (i = 0; i < TX_DESC_MAX; i++)
- len += scnprintf(page + len, PAGE_SIZE - len, "hist[%2d]: %8u%c", i,
- hw->tx_ring_hist[i], (i &&
- ((i + 1) % 4 == 0 ||
- i ==
- TX_DESC_MAX - 1)) ? '\n' : ' ');
-
- if (!board->isx21)
- {
-
- memset((void *)&last4, 0, sizeof(last4));
- memset((void *)&last96, 0, sizeof(last96));
-
- /* Calculate the sum of last 4 intervals: */
-
- for (i = 1; i <= 4; i++)
- {
- p = (unsigned *)&board->intervals[(board->current_interval +
- SLICECOM_BOARD_INTERVALS_SIZE -
- i) % SLICECOM_BOARD_INTERVALS_SIZE];
- sump = (unsigned *)&last4;
- for (j = 0; j < (sizeof(e1_stats_t) / sizeof(unsigned)); j++)
- sump[j] += p[j];
- }
-
- /* Calculate the sum of last 96 intervals: */
-
- for (i = 1; i <= 96; i++)
- {
- p = (unsigned *)&board->intervals[(board->current_interval +
- SLICECOM_BOARD_INTERVALS_SIZE -
- i) % SLICECOM_BOARD_INTERVALS_SIZE];
- sump = (unsigned *)&last96;
- for (j = 0; j < (sizeof(e1_stats_t) / sizeof(unsigned)); j++)
- sump[j] += p[j];
- }
-
- len += scnprintf(page + len, PAGE_SIZE - len,
- "Data in current interval (%d seconds elapsed):\n",
- board->elapsed_seconds);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
- curr_int->line_code_violations,
- curr_int->path_code_violations, curr_int->e_bit_errors);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
- curr_int->slip_secs, curr_int->fr_loss_secs,
- curr_int->line_err_secs, curr_int->degraded_mins);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
- curr_int->errored_secs, curr_int->bursty_err_secs,
- curr_int->severely_err_secs, curr_int->unavail_secs);
-
- len += scnprintf(page + len, PAGE_SIZE - len,
- "Data in Interval 1 (15 minutes):\n");
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
- prev_int->line_code_violations,
- prev_int->path_code_violations, prev_int->e_bit_errors);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
- prev_int->slip_secs, prev_int->fr_loss_secs,
- prev_int->line_err_secs, prev_int->degraded_mins);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
- prev_int->errored_secs, prev_int->bursty_err_secs,
- prev_int->severely_err_secs, prev_int->unavail_secs);
-
- len += scnprintf(page + len, PAGE_SIZE - len,
- "Data in last 4 intervals (1 hour):\n");
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
- last4.line_code_violations, last4.path_code_violations,
- last4.e_bit_errors);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
- last4.slip_secs, last4.fr_loss_secs, last4.line_err_secs,
- last4.degraded_mins);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
- last4.errored_secs, last4.bursty_err_secs,
- last4.severely_err_secs, last4.unavail_secs);
-
- len += scnprintf(page + len, PAGE_SIZE - len,
- "Data in last 96 intervals (24 hours):\n");
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Line Code Violations, %d Path Code Violations, %d E-Bit Errors\n",
- last96.line_code_violations, last96.path_code_violations,
- last96.e_bit_errors);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Slip Secs, %d Fr Loss Secs, %d Line Err Secs, %d Degraded Mins\n",
- last96.slip_secs, last96.fr_loss_secs,
- last96.line_err_secs, last96.degraded_mins);
- len += scnprintf(page + len, PAGE_SIZE - len,
- " %d Errored Secs, %d Bursty Err Secs, %d Severely Err Secs, %d Unavail Secs\n",
- last96.errored_secs, last96.bursty_err_secs,
- last96.severely_err_secs, last96.unavail_secs);
-
- }
-
-// len +=scnprintf( page + len, PAGE_SIZE - len, "Special events:\n" );
-// len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pri/missed: %u / %u\n", board->stat_pri_races, board->stat_pri_races_missed );
-// len +=scnprintf( page + len, PAGE_SIZE - len, "\tstat_pti/missed: %u / %u\n", board->stat_pti_races, board->stat_pti_races_missed );
- return len;
-}
-
-/*
- * Memory dump function. Not used currently.
- */
-static int BOARD_dump(struct net_device *dev)
-{
- printk
- ("BOARD_dump() requested. It is unimplemented, it should not be called\n");
- return (-1);
-}
-
-/*
- * /proc file read function for the files registered by this module.
- * This function is called by the procfs implementation when a user
- * wants to read from a file registered by this module.
- * page is the workspace, start should point to the real start of data,
- * off is the file offset, data points to the file's proc_dir_entry
- * structure.
- * Returns the number of bytes copied to the request buffer.
- */
-
-static int munich_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- munich_board_t *board;
-
- int len = 0, i;
- u32 timeslots = hw->timeslots;
-
- board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- if (!strcmp(file->name, FILENAME_BOARDNUM))
- len = sprintf(page, "%d\n", hw->boardnum);
- else if (!strcmp(file->name, FILENAME_TIMESLOTS))
- {
- for (i = 0; i < 32; i++)
- if ((1 << i) & timeslots)
- len += scnprintf(page + len, PAGE_SIZE - len, "%d ", i);
- len += scnprintf(page + len, PAGE_SIZE - len, "\n");
- }
- else if (!strcmp(file->name, FILENAME_FRAMING))
- {
- i = 0;
- while (slicecom_framings[i].value &&
- slicecom_framings[i].value != board->framing)
- i++;
- len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
- slicecom_framings[i].name);
- }
- else if (!strcmp(file->name, FILENAME_LINECODE))
- {
- i = 0;
- while (slicecom_linecodes[i].value &&
- slicecom_linecodes[i].value != board->linecode)
- i++;
- len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
- slicecom_linecodes[i].name);
- }
- else if (!strcmp(file->name, FILENAME_CLOCK_SOURCE))
- {
- i = 0;
- while (slicecom_clock_sources[i].value &&
- slicecom_clock_sources[i].value != board->clock_source)
- i++;
- len +=
- scnprintf(page + len, PAGE_SIZE - len, "%s\n",
- slicecom_clock_sources[i].name);
- }
- else if (!strcmp(file->name, FILENAME_LOOPBACK))
- {
- i = 0;
- while (slicecom_loopbacks[i].value &&
- slicecom_loopbacks[i].value != board->loopback)
- i++;
- len += scnprintf(page + len, PAGE_SIZE - len, "%s\n",
- slicecom_loopbacks[i].name);
- }
- /* We set permissions to write-only for REG and LBIREG, but root can read them anyway: */
- else if (!strcmp(file->name, FILENAME_REG))
- {
- len += scnprintf(page + len, PAGE_SIZE - len,
- "%s: " FILENAME_REG ": write-only file\n", dev->name);
- }
- else if (!strcmp(file->name, FILENAME_LBIREG))
- {
- len += scnprintf(page + len, PAGE_SIZE - len,
- "%s: " FILENAME_LBIREG ": write-only file\n", dev->name);
- }
- else
- {
- printk("slicecom_read_proc: internal error, filename %s\n", file->name);
- return -EBADF;
- }
- /* file handling administration: count eof status, offset, start address
- and count: */
-
- if (off >= len)
- {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off)
- *eof = 1;
- return min((off_t) count, (off_t) len - off);
-}
-
-/*
- * Write function for /proc files registered by us.
- * See the comment on read function above.
- * Beware! buffer is in userspace!!!
- * Returns the number of bytes written
- */
-
-static int munich_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = (struct net_device *)entry->parent->data;
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw = ch->HW_privdata;
- munich_board_t *board;
-
- unsigned long ts, tmp_boardnum;
-
- u32 tmp_timeslots = 0;
- char *page, *p;
- int i;
-
- board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- /* Paranoia checking: */
-
- if (PDE(file->f_dentry->d_inode) != entry)
- {
- printk(KERN_ERR "munich_write_proc: file <-> data internal error\n");
- return -EIO;
- }
-
- /* Request tmp buffer */
- if (!(page = (char *)__get_free_page(GFP_KERNEL)))
- return -ENOMEM;
-
- /* Copy user data and cut trailing \n */
- if (copy_from_user(page, buffer, count = min(count, PAGE_SIZE))) {
- free_page((unsigned long)page);
- return -EFAULT;
- }
- if (*(page + count - 1) == '\n')
- *(page + count - 1) = 0;
- *(page + PAGE_SIZE - 1) = 0;
-
- if (!strcmp(entry->name, FILENAME_BOARDNUM))
- {
- tmp_boardnum = simple_strtoul(page, NULL, 0);
- if (0 <= tmp_boardnum && tmp_boardnum < MAX_BOARDS)
- hw->boardnum = tmp_boardnum;
- else
- {
- printk("%s: " FILENAME_BOARDNUM " range is 0...%d\n", dev->name,
- MAX_BOARDS - 1);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- else if (!strcmp(entry->name, FILENAME_TIMESLOTS))
- {
- p = page;
- while (*p)
- {
- if (isspace(*p))
- p++;
- else
- {
- ts = simple_strtoul(p, &p, 10); /* base = 10: Don't read 09 as an octal number */
- /* ts = 0 ha nem tudta beolvasni a stringet, erre egy kicsit epitek itt: */
- if (0 <= ts && ts < 32)
- {
- tmp_timeslots |= (1 << ts);
- }
- else
- {
- printk("%s: " FILENAME_TIMESLOTS " range is 1...31\n",
- dev->name);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- }
- hw->timeslots = tmp_timeslots;
- }
- else if (!strcmp(entry->name, FILENAME_FRAMING))
- {
- i = 0;
- while (slicecom_framings[i].value &&
- strncmp(slicecom_framings[i].name, page,
- strlen(slicecom_framings[i].name)))
- i++;
- if (!slicecom_framings[i].value)
- {
- printk("slicecom: %s: Invalid " FILENAME_FRAMING " '%s'\n",
- dev->name, page);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- else
- { /*
- * If somebody says:
- * echo >boardnum 0
- * echo >framing no-crc4
- * echo >boardnum 1
- * - when the framing was set, hw->boardnum was 0, so it would set the framing for board 0
- * Workaround: allow to set it only if interface is administrative UP
- */
- if (netif_running(dev))
- slicecom_set_framing(hw->boardnum, slicecom_framings[i].value);
- else
- {
- printk("%s: " FILENAME_FRAMING
- " can not be set while the interface is DOWN\n",
- dev->name);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- }
- else if (!strcmp(entry->name, FILENAME_LINECODE))
- {
- i = 0;
- while (slicecom_linecodes[i].value &&
- strncmp(slicecom_linecodes[i].name, page,
- strlen(slicecom_linecodes[i].name)))
- i++;
- if (!slicecom_linecodes[i].value)
- {
- printk("slicecom: %s: Invalid " FILENAME_LINECODE " '%s'\n",
- dev->name, page);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- else
- { /*
- * Allow to set it only if interface is administrative UP,
- * for the same reason as FILENAME_FRAMING
- */
- if (netif_running(dev))
- slicecom_set_linecode(hw->boardnum,
- slicecom_linecodes[i].value);
- else
- {
- printk("%s: " FILENAME_LINECODE
- " can not be set while the interface is DOWN\n",
- dev->name);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- }
- else if (!strcmp(entry->name, FILENAME_CLOCK_SOURCE))
- {
- i = 0;
- while (slicecom_clock_sources[i].value &&
- strncmp(slicecom_clock_sources[i].name, page,
- strlen(slicecom_clock_sources[i].name)))
- i++;
- if (!slicecom_clock_sources[i].value)
- {
- printk("%s: Invalid " FILENAME_CLOCK_SOURCE " '%s'\n", dev->name,
- page);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- else
- { /*
- * Allow to set it only if interface is administrative UP,
- * for the same reason as FILENAME_FRAMING
- */
- if (netif_running(dev))
- slicecom_set_clock_source(hw->boardnum,
- slicecom_clock_sources[i].value);
- else
- {
- printk("%s: " FILENAME_CLOCK_SOURCE
- " can not be set while the interface is DOWN\n",
- dev->name);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- }
- else if (!strcmp(entry->name, FILENAME_LOOPBACK))
- {
- i = 0;
- while (slicecom_loopbacks[i].value &&
- strncmp(slicecom_loopbacks[i].name, page,
- strlen(slicecom_loopbacks[i].name)))
- i++;
- if (!slicecom_loopbacks[i].value)
- {
- printk("%s: Invalid " FILENAME_LOOPBACK " '%s'\n", dev->name, page);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- else
- { /*
- * Allow to set it only if interface is administrative UP,
- * for the same reason as FILENAME_FRAMING
- */
- if (netif_running(dev))
- slicecom_set_loopback(hw->boardnum,
- slicecom_loopbacks[i].value);
- else
- {
- printk("%s: " FILENAME_LOOPBACK
- " can not be set while the interface is DOWN\n",
- dev->name);
- free_page((unsigned long)page);
- return -EINVAL;
- }
- }
- }
- else if (!strcmp(entry->name, FILENAME_REG))
- { /* DEL: 'reg' csak tmp */
- char *p;
- u32 *bar1 = board->bar1;
-
- reg = simple_strtoul(page, &p, 0);
- reg_ertek = simple_strtoul(p + 1, NULL, 0);
-
- if (reg < 0x100)
- {
- printk("reg(0x%02x) := 0x%08x jiff: %lu\n", reg, reg_ertek, jiffies);
- writel(reg_ertek, MUNICH_VIRT(reg >> 2));
- }
- else
- {
- printk("reg(0x%02x) is 0x%08x jiff: %lu\n", reg - 0x100,
- readl(MUNICH_VIRT((reg - 0x100) >> 2)), jiffies);
- }
- }
- else if (!strcmp(entry->name, FILENAME_LBIREG))
- { /* DEL: 'lbireg' csak tmp */
- char *p;
- u8 *lbi = board->lbi;
-
- lbireg = simple_strtoul(page, &p, 0);
- lbireg_ertek = simple_strtoul(p + 1, NULL, 0);
-
- if (lbireg < 0x100)
- {
- printk("lbireg(0x%02x) := 0x%02x jiff: %lu\n", lbireg,
- lbireg_ertek, jiffies);
- writeb(lbireg_ertek, lbi + lbireg);
- }
- else
- printk("lbireg(0x%02x) is 0x%02x jiff: %lu\n", lbireg - 0x100,
- readb(lbi + lbireg - 0x100), jiffies);
- }
- else
- {
- printk(KERN_ERR "munich_write_proc: internal error, filename %s\n",
- entry->name);
- free_page((unsigned long)page);
- return -EBADF;
- }
-
- /* Don't forget to free the workspace */
- free_page((unsigned long)page);
- return count;
-}
-
-/*
- * Boardtype init function.
- * Called by the comx (upper) layer, when you set boardtype.
- * Allocates resources associated to using munich board for this device,
- * initializes ch_struct pointers etc.
- * Returns 0 on success and standard error codes on error.
- */
-
-static int init_escape(struct comx_channel *ch)
-{
- kfree(ch->HW_privdata);
- return -EIO;
-}
-
-static int BOARD_init(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
- struct slicecom_privdata *hw;
- struct proc_dir_entry *new_file;
-
- /* Alloc data for private structure */
- if ((ch->HW_privdata =
- kmalloc(sizeof(struct slicecom_privdata), GFP_KERNEL)) == NULL)
- return -ENOMEM;
-
- memset(hw = ch->HW_privdata, 0, sizeof(struct slicecom_privdata));
-
- /* Register /proc files */
- if ((new_file = create_proc_entry(FILENAME_BOARDNUM, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- if (ch->hardware == &slicecomhw)
- {
- if ((new_file = create_proc_entry(FILENAME_TIMESLOTS, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_FRAMING, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_LINECODE, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_CLOCK_SOURCE, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_LOOPBACK, S_IFREG | 0644,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
- }
-
- /* DEL: ez itt csak fejlesztesi celokra!! */
- if ((new_file = create_proc_entry(FILENAME_REG, S_IFREG | 0200, ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- /* DEL: ez itt csak fejlesztesi celokra!! */
- if ((new_file = create_proc_entry(FILENAME_LBIREG, S_IFREG | 0200,
- ch->procdir)) == NULL)
- return init_escape(ch);
- new_file->data = (void *)new_file;
- new_file->read_proc = &munich_read_proc;
- new_file->write_proc = &munich_write_proc;
-// new_file->proc_iops = &comx_normal_inode_ops;
- new_file->nlink = 1;
-
- /* Fill in ch_struct hw specific pointers: */
-
- ch->HW_txe = MUNICH_txe;
- ch->HW_open = MUNICH_open;
- ch->HW_close = MUNICH_close;
- ch->HW_send_packet = MUNICH_send_packet;
-#ifndef COMX_NEW
- ch->HW_minden = MUNICH_minden;
-#else
- ch->HW_statistics = MUNICH_minden;
-#endif
-
- hw->boardnum = SLICECOM_BOARDNUM_DEFAULT;
- hw->timeslots = ch->hardware == &pcicomhw ? 0xffffffff : 2;
-
- /* O.K. Count one more user on this module */
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-/*
- * Boardtype exit function.
- * Called by the comx (upper) layer, when you clear boardtype from munich.
- * Frees resources associated to using munich board for this device,
- * resets ch_struct pointers etc.
- */
-static int BOARD_exit(struct net_device *dev)
-{
- struct comx_channel *ch = netdev_priv(dev);
-
- /* Free private data area */
-// board = hw->boardnum + (ch->hardware == &pcicomhw ? pcicom_boards : slicecom_boards);
-
- kfree(ch->HW_privdata);
- /* Remove /proc files */
- remove_proc_entry(FILENAME_BOARDNUM, ch->procdir);
- if (ch->hardware == &slicecomhw)
- {
- remove_proc_entry(FILENAME_TIMESLOTS, ch->procdir);
- remove_proc_entry(FILENAME_FRAMING, ch->procdir);
- remove_proc_entry(FILENAME_LINECODE, ch->procdir);
- remove_proc_entry(FILENAME_CLOCK_SOURCE, ch->procdir);
- remove_proc_entry(FILENAME_LOOPBACK, ch->procdir);
- }
- remove_proc_entry(FILENAME_REG, ch->procdir);
- remove_proc_entry(FILENAME_LBIREG, ch->procdir);
-
- /* Minus one user for the module accounting */
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static struct comx_hardware slicecomhw =
-{
- "slicecom",
-#ifdef COMX_NEW
- VERSION,
-#endif
- BOARD_init,
- BOARD_exit,
- BOARD_dump,
- NULL
-};
-
-static struct comx_hardware pcicomhw =
-{
- "pcicom",
-#ifdef COMX_NEW
- VERSION,
-#endif
- BOARD_init,
- BOARD_exit,
- BOARD_dump,
- NULL
-};
-
-/* Module management */
-
-static int __init init_mister(void)
-{
- printk(VERSIONSTR);
- comx_register_hardware(&slicecomhw);
- comx_register_hardware(&pcicomhw);
- return munich_probe();
-}
-
-static void __exit cleanup_mister(void)
-{
- int i;
-
- comx_unregister_hardware("slicecom");
- comx_unregister_hardware("pcicom");
-
- for (i = 0; i < MAX_BOARDS; i++)
- {
- if (slicecom_boards[i].bar1)
- iounmap((void *)slicecom_boards[i].bar1);
- if (slicecom_boards[i].lbi)
- iounmap((void *)slicecom_boards[i].lbi);
- if (pcicom_boards[i].bar1)
- iounmap((void *)pcicom_boards[i].bar1);
- if (pcicom_boards[i].lbi)
- iounmap((void *)pcicom_boards[i].lbi);
- }
-}
-
-module_init(init_mister);
-module_exit(cleanup_mister);
+++ /dev/null
-/*
- * Frame-relay protocol module for the COMX driver
- * for Linux 2.2.X
- *
- * Original author: Tivadar Szemethy <tiv@itc.hu>
- * Maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1998-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.73)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.70 (99/06/14):
- * - cleaned up the source code a bit
- * - ported back to kernel, now works as builtin code
- *
- * Version 0.71 (99/06/25):
- * - use skb priorities and queues for sending keepalive
- * - use device queues for slave->master data transmit
- * - set IFF_RUNNING only line protocol up
- * - fixes on slave device flags
- *
- * Version 0.72 (99/07/09):
- * - handle slave tbusy with master tbusy (should be fixed)
- * - fix the keepalive timer addition/deletion
- *
- * Version 0.73 (00/08/15)
- * - resource release on failure at fr_master_init and
- * fr_slave_init
- */
-
-#define VERSION "0.73"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <linux/pkt_sched.h>
-#include <linux/init.h>
-
-#include <asm/uaccess.h>
-
-#include "comx.h"
-#include "comxhw.h"
-
-MODULE_AUTHOR("Author: Tivadar Szemethy <tiv@itc.hu>");
-MODULE_DESCRIPTION("Frame Relay protocol implementation for the COMX drivers"
- "for Linux kernel 2.4.X");
-MODULE_LICENSE("GPL");
-
-#define FRAD_UI 0x03
-#define NLPID_IP 0xcc
-#define NLPID_Q933_LMI 0x08
-#define NLPID_CISCO_LMI 0x09
-#define Q933_ENQ 0x75
-#define Q933_LINESTAT 0x51
-#define Q933_COUNTERS 0x53
-
-#define MAXALIVECNT 3 /* No. of failures */
-
-struct fr_data {
- u16 dlci;
- struct net_device *master;
- char keepa_pend;
- char keepa_freq;
- char keepalivecnt, keeploopcnt;
- struct timer_list keepa_timer;
- u8 local_cnt, remote_cnt;
-};
-
-static struct comx_protocol fr_master_protocol;
-static struct comx_protocol fr_slave_protocol;
-static struct comx_hardware fr_dlci;
-
-static void fr_keepalive_send(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct sk_buff *skb;
- u8 *fr_packet;
-
- skb=alloc_skb(dev->hard_header_len + 13, GFP_ATOMIC);
-
- if(skb==NULL)
- return;
-
- skb_reserve(skb, dev->hard_header_len);
-
- fr_packet=(u8*)skb_put(skb, 13);
-
- fr_packet[0] = (fr->dlci & (1024 - 15)) >> 2;
- fr_packet[1] = (fr->dlci & 15) << 4 | 1; // EA bit 1
- fr_packet[2] = FRAD_UI;
- fr_packet[3] = NLPID_Q933_LMI;
- fr_packet[4] = 0;
- fr_packet[5] = Q933_ENQ;
- fr_packet[6] = Q933_LINESTAT;
- fr_packet[7] = 0x01;
- fr_packet[8] = 0x01;
- fr_packet[9] = Q933_COUNTERS;
- fr_packet[10] = 0x02;
- fr_packet[11] = ++fr->local_cnt;
- fr_packet[12] = fr->remote_cnt;
-
- skb->dev = dev;
- skb->priority = TC_PRIO_CONTROL;
- dev_queue_xmit(skb);
-}
-
-static void fr_keepalive_timerfun(unsigned long d)
-{
- struct net_device *dev = (struct net_device *)d;
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct comx_channel *sch;
- struct fr_data *sfr;
- struct net_device *sdev;
-
- if (ch->init_status & LINE_OPEN) {
- if (fr->keepalivecnt == MAXALIVECNT) {
- comx_status(dev, ch->line_status & ~PROTO_UP);
- dev->flags &= ~IFF_RUNNING;
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
-
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata)
- && (sfr->master == dev) &&
- (sdev->flags & IFF_UP)) {
- sdev->flags &= ~IFF_RUNNING;
- comx_status(sdev,
- sch->line_status & ~PROTO_UP);
- }
- }
- }
- if (fr->keepalivecnt <= MAXALIVECNT) {
- ++fr->keepalivecnt;
- }
- fr_keepalive_send(dev);
- }
- mod_timer(&fr->keepa_timer, jiffies + HZ * fr->keepa_freq);
-}
-
-static void fr_rx_lmi(struct net_device *dev, struct sk_buff *skb,
- u16 dlci, u8 nlpid)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct comx_channel *sch;
- struct fr_data *sfr;
- struct net_device *sdev;
-
- if (dlci != fr->dlci || nlpid != NLPID_Q933_LMI || !fr->keepa_freq) {
- return;
- }
-
- fr->remote_cnt = skb->data[7];
- if (skb->data[8] == fr->local_cnt) { // keepalive UP!
- fr->keepalivecnt = 0;
- if ((ch->line_status & LINE_UP) &&
- !(ch->line_status & PROTO_UP)) {
- comx_status(dev, ch->line_status |= PROTO_UP);
- dev->flags |= IFF_RUNNING;
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
-
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata)
- && (sfr->master == dev) &&
- (sdev->flags & IFF_UP)) {
- sdev->flags |= IFF_RUNNING;
- comx_status(sdev,
- sch->line_status | PROTO_UP);
- }
- }
- }
- }
-}
-
-static void fr_set_keepalive(struct net_device *dev, int keepa)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
-
- if (!keepa && fr->keepa_freq) { // switch off
- fr->keepa_freq = 0;
- if (ch->line_status & LINE_UP) {
- comx_status(dev, ch->line_status | PROTO_UP);
- dev->flags |= IFF_RUNNING;
- del_timer(&fr->keepa_timer);
- }
- return;
- }
-
- if (keepa) { // bekapcs
- if(fr->keepa_freq && (ch->line_status & LINE_UP)) {
- del_timer(&fr->keepa_timer);
- }
- fr->keepa_freq = keepa;
- fr->local_cnt = fr->remote_cnt = 0;
- init_timer(&fr->keepa_timer);
- fr->keepa_timer.expires = jiffies + HZ;
- fr->keepa_timer.function = fr_keepalive_timerfun;
- fr->keepa_timer.data = (unsigned long)dev;
- ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
- dev->flags &= ~IFF_RUNNING;
- comx_status(dev, ch->line_status);
- if(ch->line_status & LINE_UP) {
- add_timer(&fr->keepa_timer);
- }
- }
-}
-
-static void fr_rx(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct net_device *sdev = dev;
- struct comx_channel *sch;
- struct fr_data *sfr;
- u16 dlci;
- u8 nlpid;
-
- if(skb->len <= 4 || skb->data[2] != FRAD_UI) {
- kfree_skb(skb);
- return;
- }
-
- /* Itt majd ki kell talalni, melyik slave kapja a csomagot */
- dlci = ((skb->data[0] & 0xfc) << 2) | ((skb->data[1] & 0xf0) >> 4);
- if ((nlpid = skb->data[3]) == 0) { // Optional padding
- nlpid = skb->data[4];
- skb_pull(skb, 1);
- }
- skb_pull(skb, 4); /* DLCI and header throw away */
-
- if (ch->debug_flags & DEBUG_COMX_DLCI) {
- comx_debug(dev, "Frame received, DLCI: %d, NLPID: 0x%02x\n",
- dlci, nlpid);
- comx_debug_skb(dev, skb, "Contents");
- }
-
- /* Megkeressuk, kihez tartozik */
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
- (sfr->master == dev) && (sfr->dlci == dlci)) {
- skb->dev = sdev;
- if (ch->debug_flags & DEBUG_COMX_DLCI) {
- comx_debug(dev, "Passing it to %s\n",sdev->name);
- }
- if (dev != sdev) {
- sch->stats.rx_packets++;
- sch->stats.rx_bytes += skb->len;
- }
- break;
- }
- }
- switch(nlpid) {
- case NLPID_IP:
- skb->protocol = htons(ETH_P_IP);
- skb->mac.raw = skb->data;
- comx_rx(sdev, skb);
- break;
- case NLPID_Q933_LMI:
- fr_rx_lmi(dev, skb, dlci, nlpid);
- default:
- kfree_skb(skb);
- break;
- }
-}
-
-static int fr_tx(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct net_device *sdev;
- struct comx_channel *sch;
- struct fr_data *sfr;
- int cnt = 1;
-
- /* Ha minden igaz, 2 helyen fog allni a tbusy: a masternel,
- es annal a slave-nel aki eppen kuldott.
- Egy helyen akkor all, ha a master kuldott.
- Ez megint jo lesz majd, ha utemezni akarunk */
-
- /* This should be fixed, the slave tbusy should be set when
- the masters queue is full and reset when not */
-
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
- (sfr->master == dev) && (netif_queue_stopped(sdev))) {
- netif_wake_queue(sdev);
- cnt++;
- }
- }
-
- netif_wake_queue(dev);
- return 0;
-}
-
-static void fr_status(struct net_device *dev, unsigned short status)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct net_device *sdev;
- struct comx_channel *sch;
- struct fr_data *sfr;
-
- if (status & LINE_UP) {
- if (!fr->keepa_freq) {
- status |= PROTO_UP;
- }
- } else {
- status &= ~(PROTO_UP | PROTO_LOOP);
- }
-
- if (dev == fr->master && fr->keepa_freq) {
- if (status & LINE_UP) {
- fr->keepa_timer.expires = jiffies + HZ;
- add_timer(&fr->keepa_timer);
- fr->keepalivecnt = MAXALIVECNT + 1;
- fr->keeploopcnt = 0;
- } else {
- del_timer(&fr->keepa_timer);
- }
- }
-
- /* Itt a status valtozast vegig kell vinni az osszes slave-n */
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
-
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_FRAD || sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata) && (sfr->master == dev)) {
- if(status & LINE_UP) {
- netif_wake_queue(sdev);
- }
- comx_status(sdev, status);
- if(status & (PROTO_UP | PROTO_LOOP)) {
- dev->flags |= IFF_RUNNING;
- } else {
- dev->flags &= ~IFF_RUNNING;
- }
- }
- }
-}
-
-static int fr_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct proc_dir_entry *comxdir = ch->procdir;
- struct comx_channel *mch;
-
- if (!(ch->init_status & HW_OPEN)) {
- return -ENODEV;
- }
-
- if ((ch->hardware == &fr_dlci && ch->protocol != &fr_slave_protocol) ||
- (ch->protocol == &fr_slave_protocol && ch->hardware != &fr_dlci)) {
- printk(KERN_ERR "Trying to open an improperly set FR interface, giving up\n");
- return -EINVAL;
- }
-
- if (!fr->master) {
- return -ENODEV;
- }
- mch = fr->master->priv;
- if (fr->master != dev && (!(mch->init_status & LINE_OPEN)
- || (mch->protocol != &fr_master_protocol))) {
- printk(KERN_ERR "Master %s is inactive, or incorrectly set up, "
- "unable to open %s\n", fr->master->name, dev->name);
- return -ENODEV;
- }
-
- ch->init_status |= LINE_OPEN;
- ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
- dev->flags &= ~IFF_RUNNING;
-
- if (fr->master == dev) {
- if (fr->keepa_freq) {
- fr->keepa_timer.function = fr_keepalive_timerfun;
- fr->keepa_timer.data = (unsigned long)dev;
- add_timer(&fr->keepa_timer);
- } else {
- if (ch->line_status & LINE_UP) {
- ch->line_status |= PROTO_UP;
- dev->flags |= IFF_RUNNING;
- }
- }
- } else {
- ch->line_status = mch->line_status;
- if(fr->master->flags & IFF_RUNNING) {
- dev->flags |= IFF_RUNNING;
- }
- }
-
- for (; comxdir ; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_DLCI) == 0 ||
- strcmp(comxdir->name, FILENAME_MASTER) == 0 ||
- strcmp(comxdir->name, FILENAME_KEEPALIVE) == 0) {
- comxdir->mode = S_IFREG | 0444;
- }
- }
-// comx_status(dev, ch->line_status);
- return 0;
-}
-
-static int fr_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct proc_dir_entry *comxdir = ch->procdir;
-
- if (fr->master == dev) { // Ha master
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct net_device *sdev = dev;
- struct comx_channel *sch;
- struct fr_data *sfr;
-
- if (!(ch->init_status & HW_OPEN)) {
- return -ENODEV;
- }
-
- if (fr->keepa_freq) {
- del_timer(&fr->keepa_timer);
- }
-
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata) &&
- (sfr->master == dev) &&
- (sch->init_status & LINE_OPEN)) {
- dev_close(sdev);
- }
- }
- }
-
- ch->init_status &= ~LINE_OPEN;
- ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
- dev->flags &= ~IFF_RUNNING;
-
- for (; comxdir ; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_DLCI) == 0 ||
- strcmp(comxdir->name, FILENAME_MASTER) == 0 ||
- strcmp(comxdir->name, FILENAME_KEEPALIVE) == 0) {
- comxdir->mode = S_IFREG | 0444;
- }
- }
-
- return 0;
-}
-
-static int fr_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct comx_channel *sch, *mch;
- struct fr_data *fr = ch->LINE_privdata;
- struct fr_data *sfr;
- struct net_device *sdev;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-
- if (!fr->master) {
- printk(KERN_ERR "BUG: fr_xmit without a master!!! dev: %s\n", dev->name);
- return 0;
- }
-
- mch = fr->master->priv;
-
- /* Ennek majd a slave utemezeskor lesz igazan jelentosege */
- if (ch->debug_flags & DEBUG_COMX_DLCI) {
- comx_debug_skb(dev, skb, "Sending frame");
- }
-
- if (dev != fr->master) {
- struct sk_buff *newskb=skb_clone(skb, GFP_ATOMIC);
- if (!newskb)
- return -ENOMEM;
- newskb->dev=fr->master;
- dev_queue_xmit(newskb);
- ch->stats.tx_bytes += skb->len;
- ch->stats.tx_packets++;
- dev_kfree_skb(skb);
- } else {
- netif_stop_queue(dev);
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) && (sfr = sch->LINE_privdata) &&
- (sfr->master == dev) && (netif_queue_stopped(sdev))) {
- netif_stop_queue(sdev);
- }
- }
-
- switch(mch->HW_send_packet(dev, skb)) {
- case FRAME_QUEUED:
- netif_wake_queue(dev);
- break;
- case FRAME_ACCEPTED:
- case FRAME_DROPPED:
- break;
- case FRAME_ERROR:
- printk(KERN_ERR "%s: Transmit frame error (len %d)\n",
- dev->name, skb->len);
- break;
- }
- }
- return 0;
-}
-
-static int fr_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr, unsigned len)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
-
- skb_push(skb, dev->hard_header_len);
- /* Put in DLCI */
- skb->data[0] = (fr->dlci & (1024 - 15)) >> 2;
- skb->data[1] = (fr->dlci & 15) << 4 | 1; // EA bit 1
- skb->data[2] = FRAD_UI;
- skb->data[3] = NLPID_IP;
-
- return dev->hard_header_len;
-}
-
-static int fr_statistics(struct net_device *dev, char *page)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- int len = 0;
-
- if (fr->master == dev) {
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
- struct net_device *sdev;
- struct comx_channel *sch;
- struct fr_data *sfr;
- int slaves = 0;
-
- len += sprintf(page + len,
- "This is a Frame Relay master device\nSlaves: ");
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata) &&
- (sfr->master == dev) && (sdev != dev)) {
- slaves++;
- len += sprintf(page + len, "%s ", sdev->name);
- }
- }
- len += sprintf(page + len, "%s\n", slaves ? "" : "(none)");
- if (fr->keepa_freq) {
- len += sprintf(page + len, "Line keepalive (value %d) "
- "status %s [%d]\n", fr->keepa_freq,
- ch->line_status & PROTO_LOOP ? "LOOP" :
- ch->line_status & PROTO_UP ? "UP" : "DOWN",
- fr->keepalivecnt);
- } else {
- len += sprintf(page + len, "Line keepalive protocol "
- "is not set\n");
- }
- } else { // if slave
- len += sprintf(page + len,
- "This is a Frame Relay slave device, master: %s\n",
- fr->master ? fr->master->name : "(not set)");
- }
- return len;
-}
-
-static int fr_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = NULL;
- int len = 0;
-
- if (ch) {
- fr = ch->LINE_privdata;
- }
-
- if (strcmp(file->name, FILENAME_DLCI) == 0) {
- len = sprintf(page, "%04d\n", fr->dlci);
- } else if (strcmp(file->name, FILENAME_MASTER) == 0) {
- len = sprintf(page, "%-9s\n", fr->master ? fr->master->name :
- "(none)");
- } else if (strcmp(file->name, FILENAME_KEEPALIVE) == 0) {
- len = fr->keepa_freq ? sprintf(page, "% 3d\n", fr->keepa_freq)
- : sprintf(page, "off\n");
- } else {
- printk(KERN_ERR "comxfr: internal error, filename %s\n", file->name);
- return -EBADF;
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) *eof = 1;
- return min_t(int, count, len - off);
-}
-
-static int fr_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = entry->parent->data;
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = NULL;
- char *page;
-
- if (ch) {
- fr = ch->LINE_privdata;
- }
-
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
- return -ENOMEM;
- }
-
- if (copy_from_user(page, buffer, count)) {
- free_page((unsigned long)page);
- return -EFAULT;
- }
- if (*(page + count - 1) == '\n') {
- *(page + count - 1) = 0;
- }
-
- if (strcmp(entry->name, FILENAME_DLCI) == 0) {
- u16 dlci_new = simple_strtoul(page, NULL, 10);
-
- if (dlci_new > 1023) {
- printk(KERN_ERR "Invalid DLCI value\n");
- }
- else fr->dlci = dlci_new;
- } else if (strcmp(entry->name, FILENAME_MASTER) == 0) {
- struct net_device *new_master = dev_get_by_name(page);
-
- if (new_master && new_master->type == ARPHRD_FRAD) {
- struct comx_channel *sch = new_master->priv;
- struct fr_data *sfr = sch->LINE_privdata;
-
- if (sfr && sfr->master == new_master) {
- if(fr->master)
- dev_put(fr->master);
- fr->master = new_master;
- /* Megorokli a master statuszat */
- ch->line_status = sch->line_status;
- }
- }
- } else if (strcmp(entry->name, FILENAME_KEEPALIVE) == 0) {
- int keepa_new = -1;
-
- if (strcmp(page, KEEPALIVE_OFF) == 0) {
- keepa_new = 0;
- } else {
- keepa_new = simple_strtoul(page, NULL, 10);
- }
-
- if (keepa_new < 0 || keepa_new > 100) {
- printk(KERN_ERR "invalid keepalive\n");
- } else {
- if (fr->keepa_freq && keepa_new != fr->keepa_freq) {
- fr_set_keepalive(dev, 0);
- }
- if (keepa_new) {
- fr_set_keepalive(dev, keepa_new);
- }
- }
- } else {
- printk(KERN_ERR "comxfr_write_proc: internal error, filename %s\n",
- entry->name);
- count = -EBADF;
- }
-
- free_page((unsigned long)page);
- return count;
-}
-
-static int fr_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
- struct net_device *sdev = dev;
- struct comx_channel *sch;
- struct fr_data *sfr;
- struct proc_dir_entry *dir = ch->procdir->parent->subdir;
-
- /* Ha lezarunk egy master-t, le kell kattintani a slave-eket is */
- if (fr->master && fr->master == dev) {
- for (; dir ; dir = dir->next) {
- if(!S_ISDIR(dir->mode)) {
- continue;
- }
- if ((sdev = dir->data) && (sch = sdev->priv) &&
- (sdev->type == ARPHRD_DLCI) &&
- (sfr = sch->LINE_privdata) && (sfr->master == dev)) {
- dev_close(sdev);
- sfr->master = NULL;
- }
- }
- }
- dev->flags = 0;
- dev->type = 0;
- dev->mtu = 0;
- dev->hard_header_len = 0;
-
- ch->LINE_rx = NULL;
- ch->LINE_tx = NULL;
- ch->LINE_status = NULL;
- ch->LINE_open = NULL;
- ch->LINE_close = NULL;
- ch->LINE_xmit = NULL;
- ch->LINE_header = NULL;
- ch->LINE_rebuild_header = NULL;
- ch->LINE_statistics = NULL;
-
- ch->LINE_status = 0;
-
- if (fr->master != dev) { // if not master, remove dlci
- if(fr->master)
- dev_put(fr->master);
- remove_proc_entry(FILENAME_DLCI, ch->procdir);
- remove_proc_entry(FILENAME_MASTER, ch->procdir);
- } else {
- if (fr->keepa_freq) {
- fr_set_keepalive(dev, 0);
- }
- remove_proc_entry(FILENAME_KEEPALIVE, ch->procdir);
- remove_proc_entry(FILENAME_DLCI, ch->procdir);
- }
-
- kfree(fr);
- ch->LINE_privdata = NULL;
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int fr_master_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr;
- struct proc_dir_entry *new_file;
-
- if ((fr = ch->LINE_privdata = kmalloc(sizeof(struct fr_data),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- memset(fr, 0, sizeof(struct fr_data));
- fr->master = dev; // this means master
- fr->dlci = 0; // let's say default
-
- dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
- dev->type = ARPHRD_FRAD;
- dev->mtu = 1500;
- dev->hard_header_len = 4;
- dev->addr_len = 0;
-
- ch->LINE_rx = fr_rx;
- ch->LINE_tx = fr_tx;
- ch->LINE_status = fr_status;
- ch->LINE_open = fr_open;
- ch->LINE_close = fr_close;
- ch->LINE_xmit = fr_xmit;
- ch->LINE_header = fr_header;
- ch->LINE_rebuild_header = NULL;
- ch->LINE_statistics = fr_statistics;
-
- if ((new_file = create_proc_entry(FILENAME_DLCI, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_LINE_privdata;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &fr_read_proc;
- new_file->write_proc = &fr_write_proc;
- new_file->size = 5;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_KEEPALIVE, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_dlci;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &fr_read_proc;
- new_file->write_proc = &fr_write_proc;
- new_file->size = 4;
- new_file->nlink = 1;
-
- fr_set_keepalive(dev, 0);
-
- MOD_INC_USE_COUNT;
- return 0;
-cleanup_filename_dlci:
- remove_proc_entry(FILENAME_DLCI, ch->procdir);
-cleanup_LINE_privdata:
- kfree(fr);
- return -EIO;
-}
-
-static int fr_slave_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr;
- struct proc_dir_entry *new_file;
-
- if ((fr = ch->LINE_privdata = kmalloc(sizeof(struct fr_data),
- GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- memset(fr, 0, sizeof(struct fr_data));
-
- dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
- dev->type = ARPHRD_DLCI;
- dev->mtu = 1500;
- dev->hard_header_len = 4;
- dev->addr_len = 0;
-
- ch->LINE_rx = fr_rx;
- ch->LINE_tx = fr_tx;
- ch->LINE_status = fr_status;
- ch->LINE_open = fr_open;
- ch->LINE_close = fr_close;
- ch->LINE_xmit = fr_xmit;
- ch->LINE_header = fr_header;
- ch->LINE_rebuild_header = NULL;
- ch->LINE_statistics = fr_statistics;
-
- if ((new_file = create_proc_entry(FILENAME_DLCI, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_LINE_privdata;
- }
-
- new_file->data = (void *)new_file;
- new_file->read_proc = &fr_read_proc;
- new_file->write_proc = &fr_write_proc;
- new_file->size = 5;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_MASTER, S_IFREG | 0644,
- ch->procdir)) == NULL) {
- goto cleanup_filename_dlci;
- }
- new_file->data = (void *)new_file;
- new_file->read_proc = &fr_read_proc;
- new_file->write_proc = &fr_write_proc;
- new_file->size = 10;
- new_file->nlink = 1;
- MOD_INC_USE_COUNT;
- return 0;
-cleanup_filename_dlci:
- remove_proc_entry(FILENAME_DLCI, ch->procdir);
-cleanup_LINE_privdata:
- kfree(fr);
- return -EIO;
-}
-
-static int dlci_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- ch->init_status |= HW_OPEN;
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int dlci_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- ch->init_status &= ~HW_OPEN;
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int dlci_txe(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct fr_data *fr = ch->LINE_privdata;
-
- if (!fr->master) {
- return 0;
- }
-
- ch = fr->master->priv;
- fr = ch->LINE_privdata;
- return ch->HW_txe(fr->master);
-}
-
-static int dlci_statistics(struct net_device *dev, char *page)
-{
- return 0;
-}
-
-static int dlci_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- ch->HW_open = dlci_open;
- ch->HW_close = dlci_close;
- ch->HW_txe = dlci_txe;
- ch->HW_statistics = dlci_statistics;
-
- /* Nincs egyeb hw info, mert ugyis a fr->master-bol fog minden kiderulni */
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int dlci_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- ch->HW_open = NULL;
- ch->HW_close = NULL;
- ch->HW_txe = NULL;
- ch->HW_statistics = NULL;
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int dlci_dump(struct net_device *dev)
-{
- printk(KERN_INFO "dlci_dump %s, HOGY MI ???\n", dev->name);
- return -1;
-}
-
-static struct comx_protocol fr_master_protocol = {
- .name = "frad",
- .version = VERSION,
- .encap_type = ARPHRD_FRAD,
- .line_init = fr_master_init,
- .line_exit = fr_exit,
-};
-
-static struct comx_protocol fr_slave_protocol = {
- .name = "ietf-ip",
- .version = VERSION,
- .encap_type = ARPHRD_DLCI,
- .line_init = fr_slave_init,
- .line_exit = fr_exit,
-};
-
-static struct comx_hardware fr_dlci = {
- .name = "dlci",
- .version = VERSION,
- .hw_init = dlci_init,
- .hw_exit = dlci_exit,
- .hw_dump = dlci_dump,
-};
-
-static int __init comx_proto_fr_init(void)
-{
- int ret;
-
- if ((ret = comx_register_hardware(&fr_dlci))) {
- return ret;
- }
- if ((ret = comx_register_protocol(&fr_master_protocol))) {
- return ret;
- }
- return comx_register_protocol(&fr_slave_protocol);
-}
-
-static void __exit comx_proto_fr_exit(void)
-{
- comx_unregister_hardware(fr_dlci.name);
- comx_unregister_protocol(fr_master_protocol.name);
- comx_unregister_protocol(fr_slave_protocol.name);
-}
-
-module_init(comx_proto_fr_init);
-module_exit(comx_proto_fr_exit);
+++ /dev/null
-/*
- * LAPB protocol module for the COMX driver
- * for Linux kernel 2.2.X
- *
- * Original author: Tivadar Szemethy <tiv@itc.hu>
- * Maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1997-1999 (C) ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/14):
- * - cleaned up the source code a bit
- * - ported back to kernel, now works as non-module
- *
- * Changed (00/10/29, Henner Eisen):
- * - comx_rx() / comxlapb_data_indication() return status.
- *
- */
-
-#define VERSION "0.80"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-#include <linux/lapb.h>
-#include <linux/init.h>
-
-#include "comx.h"
-#include "comxhw.h"
-
-static struct proc_dir_entry *create_comxlapb_proc_entry(char *name, int mode,
- int size, struct proc_dir_entry *dir);
-
-static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb)
-{
- if (!dev || !dev->priv) {
- dev_kfree_skb(skb);
- } else {
- lapb_data_received(dev, skb);
- }
-}
-
-static int comxlapb_tx(struct net_device *dev)
-{
- netif_wake_queue(dev);
- return 0;
-}
-
-static int comxlapb_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr, unsigned len)
-{
- return dev->hard_header_len;
-}
-
-static void comxlapb_status(struct net_device *dev, unsigned short status)
-{
- struct comx_channel *ch;
-
- if (!dev || !(ch = dev->priv)) {
- return;
- }
- if (status & LINE_UP) {
- netif_wake_queue(dev);
- }
- comx_status(dev, status);
-}
-
-static int comxlapb_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- int err = 0;
-
- if (!(ch->init_status & HW_OPEN)) {
- return -ENODEV;
- }
-
- err = lapb_connect_request(dev);
-
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(dev, "%s: lapb opened, error code: %d\n",
- dev->name, err);
- }
-
- if (!err) {
- ch->init_status |= LINE_OPEN;
- MOD_INC_USE_COUNT;
- }
- return err;
-}
-
-static int comxlapb_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- if (!(ch->init_status & HW_OPEN)) {
- return -ENODEV;
- }
-
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(dev, "%s: lapb closed\n", dev->name);
- }
-
- lapb_disconnect_request(dev);
-
- ch->init_status &= ~LINE_OPEN;
- ch->line_status &= ~PROTO_UP;
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct sk_buff *skb2;
-
- if (!dev || !(ch = dev->priv) || !(dev->flags & (IFF_UP | IFF_RUNNING))) {
- return -ENODEV;
- }
-
- if (dev->type == ARPHRD_X25) { // first byte tells what to do
- switch(skb->data[0]) {
- case 0x00:
- break; // transmit
- case 0x01:
- lapb_connect_request(dev);
- kfree_skb(skb);
- return 0;
- case 0x02:
- lapb_disconnect_request(dev);
- default:
- kfree_skb(skb);
- return 0;
- }
- skb_pull(skb,1);
- }
-
- netif_stop_queue(dev);
-
- if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
- lapb_data_request(dev, skb2);
- }
-
- return FRAME_ACCEPTED;
-}
-
-static int comxlapb_statistics(struct net_device *dev, char *page)
-{
- struct lapb_parms_struct parms;
- int len = 0;
-
- len += sprintf(page + len, "Line status: ");
- if (lapb_getparms(dev, &parms) != LAPB_OK) {
- len += sprintf(page + len, "not initialized\n");
- return len;
- }
- len += sprintf(page + len, "%s (%s), T1: %d/%d, T2: %d/%d, N2: %d/%d, "
- "window: %d\n", parms.mode & LAPB_DCE ? "DCE" : "DTE",
- parms.mode & LAPB_EXTENDED ? "EXTENDED" : "STANDARD",
- parms.t1timer, parms.t1, parms.t2timer, parms.t2,
- parms.n2count, parms.n2, parms.window);
-
- return len;
-}
-
-static int comxlapb_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct lapb_parms_struct parms;
- int len = 0;
-
- if (lapb_getparms(dev, &parms)) {
- return -ENODEV;
- }
-
- if (strcmp(file->name, FILENAME_T1) == 0) {
- len += sprintf(page + len, "%02u / %02u\n",
- parms.t1timer, parms.t1);
- } else if (strcmp(file->name, FILENAME_T2) == 0) {
- len += sprintf(page + len, "%02u / %02u\n",
- parms.t2timer, parms.t2);
- } else if (strcmp(file->name, FILENAME_N2) == 0) {
- len += sprintf(page + len, "%02u / %02u\n",
- parms.n2count, parms.n2);
- } else if (strcmp(file->name, FILENAME_WINDOW) == 0) {
- len += sprintf(page + len, "%u\n", parms.window);
- } else if (strcmp(file->name, FILENAME_MODE) == 0) {
- len += sprintf(page + len, "%s, %s\n",
- parms.mode & LAPB_DCE ? "DCE" : "DTE",
- parms.mode & LAPB_EXTENDED ? "EXTENDED" : "STANDARD");
- } else {
- printk(KERN_ERR "comxlapb: internal error, filename %s\n", file->name);
- return -EBADF;
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) {
- *eof = 1;
- }
- return min_t(int, count, len - off);
-}
-
-static int comxlapb_write_proc(struct file *file, const char *buffer,
- u_long count, void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = entry->parent->data;
- struct lapb_parms_struct parms;
- unsigned long parm;
- char *page;
-
- if (lapb_getparms(dev, &parms)) {
- return -ENODEV;
- }
-
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) {
- return -ENOMEM;
- }
-
- if (copy_from_user(page, buffer, count)) {
- free_page((unsigned long)page);
- return -EFAULT;
- }
- if (*(page + count - 1) == '\n') {
- *(page + count - 1) = 0;
- }
-
- if (strcmp(entry->name, FILENAME_T1) == 0) {
- parm=simple_strtoul(page,NULL,10);
- if (parm > 0 && parm < 100) {
- parms.t1=parm;
- lapb_setparms(dev, &parms);
- }
- } else if (strcmp(entry->name, FILENAME_T2) == 0) {
- parm=simple_strtoul(page, NULL, 10);
- if (parm > 0 && parm < 100) {
- parms.t2=parm;
- lapb_setparms(dev, &parms);
- }
- } else if (strcmp(entry->name, FILENAME_N2) == 0) {
- parm=simple_strtoul(page, NULL, 10);
- if (parm > 0 && parm < 100) {
- parms.n2=parm;
- lapb_setparms(dev, &parms);
- }
- } else if (strcmp(entry->name, FILENAME_WINDOW) == 0) {
- parms.window = simple_strtoul(page, NULL, 10);
- lapb_setparms(dev, &parms);
- } else if (strcmp(entry->name, FILENAME_MODE) == 0) {
- if (comx_strcasecmp(page, "dte") == 0) {
- parms.mode &= ~(LAPB_DCE | LAPB_DTE);
- parms.mode |= LAPB_DTE;
- } else if (comx_strcasecmp(page, "dce") == 0) {
- parms.mode &= ~(LAPB_DTE | LAPB_DCE);
- parms.mode |= LAPB_DCE;
- } else if (comx_strcasecmp(page, "std") == 0 ||
- comx_strcasecmp(page, "standard") == 0) {
- parms.mode &= ~LAPB_EXTENDED;
- parms.mode |= LAPB_STANDARD;
- } else if (comx_strcasecmp(page, "ext") == 0 ||
- comx_strcasecmp(page, "extended") == 0) {
- parms.mode &= ~LAPB_STANDARD;
- parms.mode |= LAPB_EXTENDED;
- }
- lapb_setparms(dev, &parms);
- } else {
- printk(KERN_ERR "comxlapb_write_proc: internal error, filename %s\n",
- entry->name);
- return -EBADF;
- }
-
- free_page((unsigned long)page);
- return count;
-}
-
-static void comxlapb_connected(struct net_device *dev, int reason)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *comxdir = ch->procdir->subdir;
-
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(ch->dev, "%s: lapb connected, reason: %d\n",
- ch->dev->name, reason);
- }
-
- if (ch->dev->type == ARPHRD_X25) {
- unsigned char *p;
- struct sk_buff *skb;
-
- if ((skb = dev_alloc_skb(1)) == NULL) {
- printk(KERN_ERR "comxlapb: out of memory!\n");
- return;
- }
- p = skb_put(skb,1);
- *p = 0x01; // link established
- skb->dev = ch->dev;
- skb->protocol = htons(ETH_P_X25);
- skb->mac.raw = skb->data;
- skb->pkt_type = PACKET_HOST;
-
- netif_rx(skb);
- ch->dev->last_rx = jiffies;
- }
-
- for (; comxdir; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_MODE) == 0) {
- comxdir->mode = S_IFREG | 0444;
- }
- }
-
-
- ch->line_status |= PROTO_UP;
- comx_status(ch->dev, ch->line_status);
-}
-
-static void comxlapb_disconnected(struct net_device *dev, int reason)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *comxdir = ch->procdir->subdir;
-
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(ch->dev, "%s: lapb disconnected, reason: %d\n",
- ch->dev->name, reason);
- }
-
- if (ch->dev->type == ARPHRD_X25) {
- unsigned char *p;
- struct sk_buff *skb;
-
- if ((skb = dev_alloc_skb(1)) == NULL) {
- printk(KERN_ERR "comxlapb: out of memory!\n");
- return;
- }
- p = skb_put(skb,1);
- *p = 0x02; // link disconnected
- skb->dev = ch->dev;
- skb->protocol = htons(ETH_P_X25);
- skb->mac.raw = skb->data;
- skb->pkt_type = PACKET_HOST;
-
- netif_rx(skb);
- ch->dev->last_rx = jiffies;
- }
-
- for (; comxdir; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_MODE) == 0) {
- comxdir->mode = S_IFREG | 0644;
- }
- }
-
- ch->line_status &= ~PROTO_UP;
- comx_status(ch->dev, ch->line_status);
-}
-
-static int comxlapb_data_indication(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = dev->priv;
-
- if (ch->dev->type == ARPHRD_X25) {
- skb_push(skb, 1);
-
- if (skb_cow(skb, 1))
- return NET_RX_DROP;
-
- skb->data[0] = 0; // indicate data for X25
- skb->protocol = htons(ETH_P_X25);
- } else {
- skb->protocol = htons(ETH_P_IP);
- }
-
- skb->dev = ch->dev;
- skb->mac.raw = skb->data;
- return comx_rx(ch->dev, skb);
-}
-
-static void comxlapb_data_transmit(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = dev->priv;
-
- if (ch->HW_send_packet) {
- ch->HW_send_packet(ch->dev, skb);
- }
-}
-
-static int comxlapb_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- dev->flags = 0;
- dev->type = 0;
- dev->mtu = 0;
- dev->hard_header_len = 0;
-
- ch->LINE_rx = NULL;
- ch->LINE_tx = NULL;
- ch->LINE_status = NULL;
- ch->LINE_open = NULL;
- ch->LINE_close = NULL;
- ch->LINE_xmit = NULL;
- ch->LINE_header = NULL;
- ch->LINE_statistics = NULL;
-
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(dev, "%s: unregistering lapb\n", dev->name);
- }
- lapb_unregister(dev);
-
- remove_proc_entry(FILENAME_T1, ch->procdir);
- remove_proc_entry(FILENAME_T2, ch->procdir);
- remove_proc_entry(FILENAME_N2, ch->procdir);
- remove_proc_entry(FILENAME_MODE, ch->procdir);
- remove_proc_entry(FILENAME_WINDOW, ch->procdir);
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int comxlapb_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct lapb_register_struct lapbreg;
-
- dev->mtu = 1500;
- dev->hard_header_len = 4;
- dev->addr_len = 0;
-
- ch->LINE_rx = comxlapb_rx;
- ch->LINE_tx = comxlapb_tx;
- ch->LINE_status = comxlapb_status;
- ch->LINE_open = comxlapb_open;
- ch->LINE_close = comxlapb_close;
- ch->LINE_xmit = comxlapb_xmit;
- ch->LINE_header = comxlapb_header;
- ch->LINE_statistics = comxlapb_statistics;
-
- lapbreg.connect_confirmation = comxlapb_connected;
- lapbreg.connect_indication = comxlapb_connected;
- lapbreg.disconnect_confirmation = comxlapb_disconnected;
- lapbreg.disconnect_indication = comxlapb_disconnected;
- lapbreg.data_indication = comxlapb_data_indication;
- lapbreg.data_transmit = comxlapb_data_transmit;
- if (lapb_register(dev, &lapbreg)) {
- return -ENOMEM;
- }
- if (ch->debug_flags & DEBUG_COMX_LAPB) {
- comx_debug(dev, "%s: lapb registered\n", dev->name);
- }
-
- if (!create_comxlapb_proc_entry(FILENAME_T1, 0644, 8, ch->procdir)) {
- return -ENOMEM;
- }
- if (!create_comxlapb_proc_entry(FILENAME_T2, 0644, 8, ch->procdir)) {
- return -ENOMEM;
- }
- if (!create_comxlapb_proc_entry(FILENAME_N2, 0644, 8, ch->procdir)) {
- return -ENOMEM;
- }
- if (!create_comxlapb_proc_entry(FILENAME_MODE, 0644, 14, ch->procdir)) {
- return -ENOMEM;
- }
- if (!create_comxlapb_proc_entry(FILENAME_WINDOW, 0644, 0, ch->procdir)) {
- return -ENOMEM;
- }
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static int comxlapb_init_lapb(struct net_device *dev)
-{
- dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
- dev->type = ARPHRD_LAPB;
-
- return(comxlapb_init(dev));
-}
-
-static int comxlapb_init_x25(struct net_device *dev)
-{
- dev->flags = IFF_NOARP;
- dev->type = ARPHRD_X25;
-
- return(comxlapb_init(dev));
-}
-
-static struct proc_dir_entry *create_comxlapb_proc_entry(char *name, int mode,
- int size, struct proc_dir_entry *dir)
-{
- struct proc_dir_entry *new_file;
-
- if ((new_file = create_proc_entry(name, S_IFREG | mode, dir)) != NULL) {
- new_file->data = (void *)new_file;
- new_file->read_proc = &comxlapb_read_proc;
- new_file->write_proc = &comxlapb_write_proc;
- new_file->size = size;
- new_file->nlink = 1;
- }
- return(new_file);
-}
-
-static struct comx_protocol comxlapb_protocol = {
- "lapb",
- VERSION,
- ARPHRD_LAPB,
- comxlapb_init_lapb,
- comxlapb_exit,
- NULL
-};
-
-static struct comx_protocol comx25_protocol = {
- "x25",
- VERSION,
- ARPHRD_X25,
- comxlapb_init_x25,
- comxlapb_exit,
- NULL
-};
-
-static int __init comx_proto_lapb_init(void)
-{
- int ret;
-
- if ((ret = comx_register_protocol(&comxlapb_protocol)) != 0) {
- return ret;
- }
- return comx_register_protocol(&comx25_protocol);
-}
-
-static void __exit comx_proto_lapb_exit(void)
-{
- comx_unregister_protocol(comxlapb_protocol.name);
- comx_unregister_protocol(comx25_protocol.name);
-}
-
-module_init(comx_proto_lapb_init);
-module_exit(comx_proto_lapb_exit);
-
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * Synchronous PPP / Cisco-HDLC driver for the COMX boards
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * based on skeleton code by Tivadar Szemethy <tiv@itc.hu>
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- *
- * Version 0.10 (99/06/10):
- * - written the first code :)
- *
- * Version 0.20 (99/06/16):
- * - added hdlc protocol
- * - protocol up is IFF_RUNNING
- *
- * Version 0.21 (99/07/15):
- * - some small fixes with the line status
- *
- * Version 0.22 (99/08/05):
- * - don't test IFF_RUNNING but the pp_link_state of the sppp
- *
- * Version 0.23 (99/12/02):
- * - tbusy fixes
- *
- */
-
-#define VERSION "0.23"
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <linux/if_arp.h>
-#include <linux/inetdevice.h>
-#include <asm/uaccess.h>
-#include <linux/init.h>
-
-#include <net/syncppp.h>
-#include "comx.h"
-
-MODULE_AUTHOR("Author: Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Cisco-HDLC / Synchronous PPP driver for the COMX sync serial boards");
-MODULE_LICENSE("GPL");
-
-static struct comx_protocol syncppp_protocol;
-static struct comx_protocol hdlc_protocol;
-
-struct syncppp_data {
- struct timer_list status_timer;
-};
-
-static void syncppp_status_timerfun(unsigned long d) {
- struct net_device *dev=(struct net_device *)d;
- struct comx_channel *ch=dev->priv;
- struct syncppp_data *spch=ch->LINE_privdata;
- struct sppp *sp = (struct sppp *)sppp_of(dev);
-
- if(!(ch->line_status & PROTO_UP) &&
- (sp->pp_link_state==SPPP_LINK_UP)) {
- comx_status(dev, ch->line_status | PROTO_UP);
- }
- if((ch->line_status & PROTO_UP) &&
- (sp->pp_link_state==SPPP_LINK_DOWN)) {
- comx_status(dev, ch->line_status & ~PROTO_UP);
- }
- mod_timer(&spch->status_timer,jiffies + HZ*3);
-}
-
-static int syncppp_tx(struct net_device *dev)
-{
- struct comx_channel *ch=dev->priv;
-
- if(ch->line_status & LINE_UP) {
- netif_wake_queue(dev);
- }
- return 0;
-}
-
-static void syncppp_status(struct net_device *dev, unsigned short status)
-{
- status &= ~(PROTO_UP | PROTO_LOOP);
- if(status & LINE_UP) {
- netif_wake_queue(dev);
- sppp_open(dev);
- } else {
- /* Line went down */
- netif_stop_queue(dev);
- sppp_close(dev);
- }
- comx_status(dev, status);
-}
-
-static int syncppp_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct syncppp_data *spch = ch->LINE_privdata;
-
- if (!(ch->init_status & HW_OPEN)) return -ENODEV;
-
- ch->init_status |= LINE_OPEN;
- ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-
- if(ch->line_status & LINE_UP) {
- sppp_open(dev);
- }
-
- init_timer(&spch->status_timer);
- spch->status_timer.function=syncppp_status_timerfun;
- spch->status_timer.data=(unsigned long)dev;
- spch->status_timer.expires=jiffies + HZ*3;
- add_timer(&spch->status_timer);
-
- return 0;
-}
-
-static int syncppp_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct syncppp_data *spch = ch->LINE_privdata;
-
- if (!(ch->init_status & HW_OPEN)) return -ENODEV;
- del_timer(&spch->status_timer);
-
- sppp_close(dev);
-
- ch->init_status &= ~LINE_OPEN;
- ch->line_status &= ~(PROTO_UP | PROTO_LOOP);
-
- return 0;
-}
-
-static int syncppp_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- netif_stop_queue(dev);
- switch(ch->HW_send_packet(dev, skb)) {
- case FRAME_QUEUED:
- netif_wake_queue(dev);
- break;
- case FRAME_ACCEPTED:
- case FRAME_DROPPED:
- break;
- case FRAME_ERROR:
- printk(KERN_ERR "%s: Transmit frame error (len %d)\n",
- dev->name, skb->len);
- break;
- }
- return 0;
-}
-
-
-static int syncppp_statistics(struct net_device *dev, char *page)
-{
- int len = 0;
-
- len += sprintf(page + len, " ");
- return len;
-}
-
-
-static int syncppp_exit(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- sppp_detach(dev);
-
- dev->flags = 0;
- dev->type = 0;
- dev->mtu = 0;
-
- ch->LINE_rx = NULL;
- ch->LINE_tx = NULL;
- ch->LINE_status = NULL;
- ch->LINE_open = NULL;
- ch->LINE_close = NULL;
- ch->LINE_xmit = NULL;
- ch->LINE_header = NULL;
- ch->LINE_rebuild_header = NULL;
- ch->LINE_statistics = NULL;
-
- kfree(ch->LINE_privdata);
- ch->LINE_privdata = NULL;
-
- MOD_DEC_USE_COUNT;
- return 0;
-}
-
-static int syncppp_init(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct ppp_device *pppdev = (struct ppp_device *)ch->if_ptr;
-
- ch->LINE_privdata = kmalloc(sizeof(struct syncppp_data), GFP_KERNEL);
- if (!ch->LINE_privdata)
- return -ENOMEM;
-
- pppdev->dev = dev;
- sppp_attach(pppdev);
-
- if(ch->protocol == &hdlc_protocol) {
- pppdev->sppp.pp_flags |= PP_CISCO;
- dev->type = ARPHRD_HDLC;
- } else {
- pppdev->sppp.pp_flags &= ~PP_CISCO;
- dev->type = ARPHRD_PPP;
- }
-
- ch->LINE_rx = sppp_input;
- ch->LINE_tx = syncppp_tx;
- ch->LINE_status = syncppp_status;
- ch->LINE_open = syncppp_open;
- ch->LINE_close = syncppp_close;
- ch->LINE_xmit = syncppp_xmit;
- ch->LINE_header = NULL;
- ch->LINE_statistics = syncppp_statistics;
-
-
- MOD_INC_USE_COUNT;
- return 0;
-}
-
-static struct comx_protocol syncppp_protocol = {
- "ppp",
- VERSION,
- ARPHRD_PPP,
- syncppp_init,
- syncppp_exit,
- NULL
-};
-
-static struct comx_protocol hdlc_protocol = {
- "hdlc",
- VERSION,
- ARPHRD_PPP,
- syncppp_init,
- syncppp_exit,
- NULL
-};
-
-static int __init comx_proto_ppp_init(void)
-{
- int ret;
-
- ret = comx_register_protocol(&hdlc_protocol);
- if (!ret) {
- ret = comx_register_protocol(&syncppp_protocol);
- if (ret)
- comx_unregister_protocol(hdlc_protocol.name);
- }
- return ret;
-}
-
-static void __exit comx_proto_ppp_exit(void)
-{
- comx_unregister_protocol(syncppp_protocol.name);
- comx_unregister_protocol(hdlc_protocol.name);
-}
-
-module_init(comx_proto_ppp_init);
-module_exit(comx_proto_ppp_exit);
+++ /dev/null
-/*
- * Device driver framework for the COMX line of synchronous serial boards
- *
- * for Linux kernel 2.2.X / 2.4.X
- *
- * Original authors: Arpad Bakay <bakay.arpad@synergon.hu>,
- * Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Current maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co.
- *
- * Contributors:
- * Arnaldo Carvalho de Melo <acme@conectiva.com.br> (0.85)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Version 0.80 (99/06/11):
- * - clean up source code (playing a bit of indent)
- * - port back to kernel, add support for non-module versions
- * - add support for board resets when channel protocol is down
- * - reset the device structure after protocol exit
- * the syncppp driver needs it
- * - add support for /proc/comx/protocols and
- * /proc/comx/boardtypes
- *
- * Version 0.81 (99/06/21):
- * - comment out the board reset support code, the locomx
- * driver seems not buggy now
- * - printk() levels fixed
- *
- * Version 0.82 (99/07/08):
- * - Handle stats correctly if the lowlevel driver is
- * is not a comx one (locomx - z85230)
- *
- * Version 0.83 (99/07/15):
- * - reset line_status when interface is down
- *
- * Version 0.84 (99/12/01):
- * - comx_status should not check for IFF_UP (to report
- * line status from dev->open())
- *
- * Version 0.85 (00/08/15):
- * - resource release on failure in comx_mkdir
- * - fix return value on failure at comx_write_proc
- *
- * Changed (00/10/29, Henner Eisen):
- * - comx_rx() / comxlapb_data_indication() return status.
- */
-
-#define VERSION "0.85"
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/jiffies.h>
-#include <linux/netdevice.h>
-#include <linux/proc_fs.h>
-#include <asm/uaccess.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-#include <linux/smp_lock.h>
-
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
-
-#ifndef CONFIG_PROC_FS
-#error For now, COMX really needs the /proc filesystem
-#endif
-
-#include <net/syncppp.h>
-#include "comx.h"
-
-MODULE_AUTHOR("Gergely Madarasz <gorgo@itc.hu>");
-MODULE_DESCRIPTION("Common code for the COMX synchronous serial adapters");
-MODULE_LICENSE("GPL");
-
-static struct comx_hardware *comx_channels = NULL;
-static struct comx_protocol *comx_lines = NULL;
-
-static int comx_mkdir(struct inode *, struct dentry *, int);
-static int comx_rmdir(struct inode *, struct dentry *);
-static struct dentry *comx_lookup(struct inode *, struct dentry *, struct nameidata *);
-
-static struct inode_operations comx_root_inode_ops = {
- .lookup = comx_lookup,
- .mkdir = comx_mkdir,
- .rmdir = comx_rmdir,
-};
-
-static int comx_delete_dentry(struct dentry *dentry);
-static struct proc_dir_entry *create_comx_proc_entry(char *name, int mode,
- int size, struct proc_dir_entry *dir);
-
-static struct dentry_operations comx_dentry_operations = {
- .d_delete = comx_delete_dentry,
-};
-
-
-static struct proc_dir_entry * comx_root_dir;
-
-struct comx_debugflags_struct comx_debugflags[] = {
- { "comx_rx", DEBUG_COMX_RX },
- { "comx_tx", DEBUG_COMX_TX },
- { "hw_tx", DEBUG_HW_TX },
- { "hw_rx", DEBUG_HW_RX },
- { "hdlc_keepalive", DEBUG_HDLC_KEEPALIVE },
- { "comxppp", DEBUG_COMX_PPP },
- { "comxlapb", DEBUG_COMX_LAPB },
- { "dlci", DEBUG_COMX_DLCI },
- { NULL, 0 }
-};
-
-
-int comx_debug(struct net_device *dev, char *fmt, ...)
-{
- struct comx_channel *ch = dev->priv;
- char *page,*str;
- va_list args;
- int len;
-
- if (!ch->debug_area) return 0;
-
- if (!(page = (char *)__get_free_page(GFP_ATOMIC))) return -ENOMEM;
-
- va_start(args, fmt);
- len = vsprintf(str = page, fmt, args);
- va_end(args);
-
- if (len >= PAGE_SIZE) {
- printk(KERN_ERR "comx_debug: PANIC! len = %d !!!\n", len);
- free_page((unsigned long)page);
- return -EINVAL;
- }
-
- while (len) {
- int to_copy;
- int free = (ch->debug_start - ch->debug_end + ch->debug_size)
- % ch->debug_size;
-
- to_copy = min_t(int, free ? free : ch->debug_size,
- min_t(int, ch->debug_size - ch->debug_end, len));
- memcpy(ch->debug_area + ch->debug_end, str, to_copy);
- str += to_copy;
- len -= to_copy;
- ch->debug_end = (ch->debug_end + to_copy) % ch->debug_size;
- if (ch->debug_start == ch->debug_end) // Full ? push start away
- ch->debug_start = (ch->debug_start + len + 1) %
- ch->debug_size;
- ch->debug_file->size = (ch->debug_end - ch->debug_start +
- ch->debug_size) % ch->debug_size;
- }
-
- free_page((unsigned long)page);
- return 0;
-}
-
-int comx_debug_skb(struct net_device *dev, struct sk_buff *skb, char *msg)
-{
- struct comx_channel *ch = dev->priv;
-
- if (!ch->debug_area) return 0;
- if (!skb) comx_debug(dev, "%s: %s NULL skb\n\n", dev->name, msg);
- if (!skb->len) comx_debug(dev, "%s: %s empty skb\n\n", dev->name, msg);
-
- return comx_debug_bytes(dev, skb->data, skb->len, msg);
-}
-
-int comx_debug_bytes(struct net_device *dev, unsigned char *bytes, int len,
- char *msg)
-{
- int pos = 0;
- struct comx_channel *ch = dev->priv;
-
- if (!ch->debug_area) return 0;
-
- comx_debug(dev, "%s: %s len %d\n", dev->name, msg, len);
-
- while (pos != len) {
- char line[80];
- int i = 0;
-
- memset(line, 0, 80);
- sprintf(line,"%04d ", pos);
- do {
- sprintf(line + 5 + (pos % 16) * 3, "%02x", bytes[pos]);
- sprintf(line + 60 + (pos % 16), "%c",
- isprint(bytes[pos]) ? bytes[pos] : '.');
- pos++;
- } while (pos != len && pos % 16);
-
- while ( i++ != 78 ) if (line[i] == 0) line[i] = ' ';
- line[77] = '\n';
- line[78] = 0;
-
- comx_debug(dev, "%s", line);
- }
- comx_debug(dev, "\n");
- return 0;
-}
-
-static void comx_loadavg_timerfun(unsigned long d)
-{
- struct net_device *dev = (struct net_device *)d;
- struct comx_channel *ch = dev->priv;
-
- ch->avg_bytes[ch->loadavg_counter] = ch->current_stats->rx_bytes;
- ch->avg_bytes[ch->loadavg_counter + ch->loadavg_size] =
- ch->current_stats->tx_bytes;
-
- ch->loadavg_counter = (ch->loadavg_counter + 1) % ch->loadavg_size;
-
- mod_timer(&ch->loadavg_timer,jiffies + HZ * ch->loadavg[0]);
-}
-
-#if 0
-static void comx_reset_timerfun(unsigned long d)
-{
- struct net_device *dev = (struct net_device *)d;
- struct comx_channel *ch = dev->priv;
-
- if(!(ch->line_status & (PROTO_LOOP | PROTO_UP))) {
- if(test_and_set_bit(0,&ch->reset_pending) && ch->HW_reset) {
- ch->HW_reset(dev);
- }
- }
-
- mod_timer(&ch->reset_timer, jiffies + HZ * ch->reset_timeout);
-}
-#endif
-
-static int comx_open(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *comxdir = ch->procdir->subdir;
- int ret=0;
-
- if (!ch->protocol || !ch->hardware) return -ENODEV;
-
- if ((ret = ch->HW_open(dev))) return ret;
- if ((ret = ch->LINE_open(dev))) {
- ch->HW_close(dev);
- return ret;
- };
-
- for (; comxdir ; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_HARDWARE) == 0 ||
- strcmp(comxdir->name, FILENAME_PROTOCOL) == 0)
- comxdir->mode = S_IFREG | 0444;
- }
-
-#if 0
- ch->reset_pending = 1;
- ch->reset_timeout = 30;
- ch->reset_timer.function = comx_reset_timerfun;
- ch->reset_timer.data = (unsigned long)dev;
- ch->reset_timer.expires = jiffies + HZ * ch->reset_timeout;
- add_timer(&ch->reset_timer);
-#endif
-
- return 0;
-}
-
-static int comx_close(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- struct proc_dir_entry *comxdir = ch->procdir->subdir;
- int ret = -ENODEV;
-
- if (test_and_clear_bit(0, &ch->lineup_pending)) {
- del_timer(&ch->lineup_timer);
- }
-
-#if 0
- del_timer(&ch->reset_timer);
-#endif
-
- if (ch->init_status & LINE_OPEN && ch->protocol && ch->LINE_close) {
- ret = ch->LINE_close(dev);
- }
-
- if (ret) return ret;
-
- if (ch->init_status & HW_OPEN && ch->hardware && ch->HW_close) {
- ret = ch->HW_close(dev);
- }
-
- ch->line_status=0;
-
- for (; comxdir ; comxdir = comxdir->next) {
- if (strcmp(comxdir->name, FILENAME_HARDWARE) == 0 ||
- strcmp(comxdir->name, FILENAME_PROTOCOL) == 0)
- comxdir->mode = S_IFREG | 0644;
- }
-
- return ret;
-}
-
-void comx_status(struct net_device *dev, int status)
-{
- struct comx_channel *ch = dev->priv;
-
-#if 0
- if(status & (PROTO_UP | PROTO_LOOP)) {
- clear_bit(0,&ch->reset_pending);
- }
-#endif
-
- printk(KERN_NOTICE "Interface %s: modem status %s, line protocol %s\n",
- dev->name, status & LINE_UP ? "UP" : "DOWN",
- status & PROTO_LOOP ? "LOOP" : status & PROTO_UP ?
- "UP" : "DOWN");
-
- ch->line_status = status;
-}
-
-static int comx_xmit(struct sk_buff *skb, struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
- int rc;
-
- if (skb->len > dev->mtu + dev->hard_header_len) {
- printk(KERN_ERR "comx_xmit: %s: skb->len %d > dev->mtu %d\n", dev->name,
- (int)skb->len, dev->mtu);
- }
-
- if (ch->debug_flags & DEBUG_COMX_TX) {
- comx_debug_skb(dev, skb, "comx_xmit skb");
- }
-
- rc=ch->LINE_xmit(skb, dev);
-// if (!rc) dev_kfree_skb(skb);
-
- return rc;
-}
-
-static int comx_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, void *daddr, void *saddr, unsigned len)
-{
- struct comx_channel *ch = dev->priv;
-
- if (ch->LINE_header) {
- return (ch->LINE_header(skb, dev, type, daddr, saddr, len));
- } else {
- return 0;
- }
-}
-
-static int comx_rebuild_header(struct sk_buff *skb)
-{
- struct net_device *dev = skb->dev;
- struct comx_channel *ch = dev->priv;
-
- if (ch->LINE_rebuild_header) {
- return(ch->LINE_rebuild_header(skb));
- } else {
- return 0;
- }
-}
-
-int comx_rx(struct net_device *dev, struct sk_buff *skb)
-{
- struct comx_channel *ch = dev->priv;
-
- if (ch->debug_flags & DEBUG_COMX_RX) {
- comx_debug_skb(dev, skb, "comx_rx skb");
- }
- if (skb) {
- netif_rx(skb);
- dev->last_rx = jiffies;
- }
- return 0;
-}
-
-static struct net_device_stats *comx_stats(struct net_device *dev)
-{
- struct comx_channel *ch = dev->priv;
-
- return ch->current_stats;
-}
-
-void comx_lineup_func(unsigned long d)
-{
- struct net_device *dev = (struct net_device *)d;
- struct comx_channel *ch = dev->priv;
-
- del_timer(&ch->lineup_timer);
- clear_bit(0, &ch->lineup_pending);
-
- if (ch->LINE_status) {
- ch->LINE_status(dev, ch->line_status |= LINE_UP);
- }
-}
-
-#define LOADAVG(avg, off) (int) \
- ((ch->avg_bytes[(ch->loadavg_counter - 1 + ch->loadavg_size * 2) \
- % ch->loadavg_size + off] - ch->avg_bytes[(ch->loadavg_counter - 1 \
- - ch->loadavg[avg] / ch->loadavg[0] + ch->loadavg_size * 2) \
- % ch->loadavg_size + off]) / ch->loadavg[avg] * 8)
-
-static int comx_statistics(struct net_device *dev, char *page)
-{
- struct comx_channel *ch = dev->priv;
- int len = 0;
- int tmp;
- int i = 0;
- char tmpstr[20];
- int tmpstrlen = 0;
-
- len += sprintf(page + len, "Interface administrative status is %s, "
- "modem status is %s, protocol is %s\n",
- dev->flags & IFF_UP ? "UP" : "DOWN",
- ch->line_status & LINE_UP ? "UP" : "DOWN",
- ch->line_status & PROTO_LOOP ? "LOOP" :
- ch->line_status & PROTO_UP ? "UP" : "DOWN");
- len += sprintf(page + len, "Modem status changes: %lu, Transmitter status "
- "is %s, tbusy: %d\n", ch->current_stats->tx_carrier_errors, ch->HW_txe ?
- ch->HW_txe(dev) ? "IDLE" : "BUSY" : "NOT READY", netif_running(dev));
- len += sprintf(page + len, "Interface load (input): %d / %d / %d bits/s (",
- LOADAVG(0,0), LOADAVG(1, 0), LOADAVG(2, 0));
- tmpstr[0] = 0;
- for (i=0; i != 3; i++) {
- char tf;
-
- tf = ch->loadavg[i] % 60 == 0 &&
- ch->loadavg[i] / 60 > 0 ? 'm' : 's';
- tmpstrlen += sprintf(tmpstr + tmpstrlen, "%d%c%s",
- ch->loadavg[i] / (tf == 'm' ? 60 : 1), tf,
- i == 2 ? ")\n" : "/");
- }
- len += sprintf(page + len,
- "%s (output): %d / %d / %d bits/s (%s", tmpstr,
- LOADAVG(0,ch->loadavg_size), LOADAVG(1, ch->loadavg_size),
- LOADAVG(2, ch->loadavg_size), tmpstr);
-
- len += sprintf(page + len, "Debug flags: ");
- tmp = len; i = 0;
- while (comx_debugflags[i].name) {
- if (ch->debug_flags & comx_debugflags[i].value)
- len += sprintf(page + len, "%s ",
- comx_debugflags[i].name);
- i++;
- }
- len += sprintf(page + len, "%s\n", tmp == len ? "none" : "");
-
- len += sprintf(page + len, "RX errors: len: %lu, overrun: %lu, crc: %lu, "
- "aborts: %lu\n buffer overrun: %lu, pbuffer overrun: %lu\n"
- "TX errors: underrun: %lu\n",
- ch->current_stats->rx_length_errors, ch->current_stats->rx_over_errors,
- ch->current_stats->rx_crc_errors, ch->current_stats->rx_frame_errors,
- ch->current_stats->rx_missed_errors, ch->current_stats->rx_fifo_errors,
- ch->current_stats->tx_fifo_errors);
-
- if (ch->LINE_statistics && (ch->init_status & LINE_OPEN)) {
- len += ch->LINE_statistics(dev, page + len);
- } else {
- len += sprintf(page+len, "Line status: driver not initialized\n");
- }
- if (ch->HW_statistics && (ch->init_status & HW_OPEN)) {
- len += ch->HW_statistics(dev, page + len);
- } else {
- len += sprintf(page+len, "Board status: driver not initialized\n");
- }
-
- return len;
-}
-
-static int comx_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
-{
- struct comx_channel *ch = dev->priv;
-
- if (ch->LINE_ioctl) {
- return(ch->LINE_ioctl(dev, ifr, cmd));
- }
- return -EINVAL;
-}
-
-static void comx_reset_dev(struct net_device *dev)
-{
- dev->open = comx_open;
- dev->stop = comx_close;
- dev->hard_start_xmit = comx_xmit;
- dev->hard_header = comx_header;
- dev->rebuild_header = comx_rebuild_header;
- dev->get_stats = comx_stats;
- dev->do_ioctl = comx_ioctl;
- dev->change_mtu = NULL;
- dev->tx_queue_len = 20;
- dev->flags = IFF_NOARP;
-}
-
-static int comx_init_dev(struct net_device *dev)
-{
- struct comx_channel *ch;
-
- if ((ch = kmalloc(sizeof(struct comx_channel), GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- memset(ch, 0, sizeof(struct comx_channel));
-
- ch->loadavg[0] = 5;
- ch->loadavg[1] = 300;
- ch->loadavg[2] = 900;
- ch->loadavg_size = ch->loadavg[2] / ch->loadavg[0] + 1;
- if ((ch->avg_bytes = kmalloc(ch->loadavg_size *
- sizeof(unsigned long) * 2, GFP_KERNEL)) == NULL) {
- kfree(ch);
- return -ENOMEM;
- }
-
- memset(ch->avg_bytes, 0, ch->loadavg_size * sizeof(unsigned long) * 2);
- ch->loadavg_counter = 0;
- ch->loadavg_timer.function = comx_loadavg_timerfun;
- ch->loadavg_timer.data = (unsigned long)dev;
- ch->loadavg_timer.expires = jiffies + HZ * ch->loadavg[0];
- add_timer(&ch->loadavg_timer);
-
- dev->priv = (void *)ch;
- ch->dev = dev;
- ch->line_status &= ~LINE_UP;
-
- ch->current_stats = &ch->stats;
-
- comx_reset_dev(dev);
- return 0;
-}
-
-static int comx_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct net_device *dev = file->parent->data;
- struct comx_channel *ch = dev->priv;
- int len = 0;
-
- if (strcmp(file->name, FILENAME_STATUS) == 0) {
- len = comx_statistics(dev, page);
- } else if (strcmp(file->name, FILENAME_HARDWARE) == 0) {
- len = sprintf(page, "%s\n", ch->hardware ?
- ch->hardware->name : HWNAME_NONE);
- } else if (strcmp(file->name, FILENAME_PROTOCOL) == 0) {
- len = sprintf(page, "%s\n", ch->protocol ?
- ch->protocol->name : PROTONAME_NONE);
- } else if (strcmp(file->name, FILENAME_LINEUPDELAY) == 0) {
- len = sprintf(page, "%01d\n", ch->lineup_delay);
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) {
- *eof = 1;
- }
- return min_t(int, count, len - off);
-}
-
-
-static int comx_root_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- struct proc_dir_entry *file = (struct proc_dir_entry *)data;
- struct comx_hardware *hw;
- struct comx_protocol *line;
-
- int len = 0;
-
- if (strcmp(file->name, FILENAME_HARDWARELIST) == 0) {
- for(hw=comx_channels;hw;hw=hw->next)
- len+=sprintf(page+len, "%s\n", hw->name);
- } else if (strcmp(file->name, FILENAME_PROTOCOLLIST) == 0) {
- for(line=comx_lines;line;line=line->next)
- len+=sprintf(page+len, "%s\n", line->name);
- }
-
- if (off >= len) {
- *eof = 1;
- return 0;
- }
-
- *start = page + off;
- if (count >= len - off) {
- *eof = 1;
- }
- return min_t(int, count, len - off);
-}
-
-
-
-static int comx_write_proc(struct file *file, const char *buffer, u_long count,
- void *data)
-{
- struct proc_dir_entry *entry = (struct proc_dir_entry *)data;
- struct net_device *dev = (struct net_device *)entry->parent->data;
- struct comx_channel *ch = dev->priv;
- char *page;
- struct comx_hardware *hw = comx_channels;
- struct comx_protocol *line = comx_lines;
- int ret=0;
-
- if (count > PAGE_SIZE) {
- printk(KERN_ERR "count is %lu > %d!!!\n", count, (int)PAGE_SIZE);
- return -ENOSPC;
- }
-
- if (!(page = (char *)__get_free_page(GFP_KERNEL))) return -ENOMEM;
-
- if(copy_from_user(page, buffer, count))
- {
- count = -EFAULT;
- goto out;
- }
-
- if (page[count-1] == '\n')
- page[count-1] = '\0';
- else if (count < PAGE_SIZE)
- page[count] = '\0';
- else if (page[count]) {
- count = -EINVAL;
- goto out;
- }
-
- if (strcmp(entry->name, FILENAME_DEBUG) == 0) {
- int i;
- int ret = 0;
-
- if ((i = simple_strtoul(page, NULL, 10)) != 0) {
- unsigned long flags;
-
- save_flags(flags); cli();
- if (ch->debug_area) kfree(ch->debug_area);
- if ((ch->debug_area = kmalloc(ch->debug_size = i,
- GFP_KERNEL)) == NULL) {
- ret = -ENOMEM;
- }
- ch->debug_start = ch->debug_end = 0;
- restore_flags(flags);
- free_page((unsigned long)page);
- return ret ? ret : count;
- }
-
- if (*page != '+' && *page != '-') {
- free_page((unsigned long)page);
- return -EINVAL;
- }
- while (comx_debugflags[i].value &&
- strncmp(comx_debugflags[i].name, page + 1,
- strlen(comx_debugflags[i].name))) {
- i++;
- }
-
- if (comx_debugflags[i].value == 0) {
- printk(KERN_ERR "Invalid debug option\n");
- free_page((unsigned long)page);
- return -EINVAL;
- }
- if (*page == '+') {
- ch->debug_flags |= comx_debugflags[i].value;
- } else {
- ch->debug_flags &= ~comx_debugflags[i].value;
- }
- } else if (strcmp(entry->name, FILENAME_HARDWARE) == 0) {
- if(strlen(page)>10) {
- free_page((unsigned long)page);
- return -EINVAL;
- }
- while (hw) {
- if (strcmp(hw->name, page) == 0) {
- break;
- } else {
- hw = hw->next;
- }
- }
-#ifdef CONFIG_KMOD
- if(!hw && comx_strcasecmp(HWNAME_NONE,page) != 0){
- request_module("comx-hw-%s",page);
- }
- hw=comx_channels;
- while (hw) {
- if (comx_strcasecmp(hw->name, page) == 0) {
- break;
- } else {
- hw = hw->next;
- }
- }
-#endif
-
- if (comx_strcasecmp(HWNAME_NONE, page) != 0 && !hw) {
- free_page((unsigned long)page);
- return -ENODEV;
- }
- if (ch->init_status & HW_OPEN) {
- free_page((unsigned long)page);
- return -EBUSY;
- }
- if (ch->hardware && ch->hardware->hw_exit &&
- (ret=ch->hardware->hw_exit(dev))) {
- free_page((unsigned long)page);
- return ret;
- }
- ch->hardware = hw;
- entry->size = strlen(page) + 1;
- if (hw && hw->hw_init) hw->hw_init(dev);
- } else if (strcmp(entry->name, FILENAME_PROTOCOL) == 0) {
- if(strlen(page)>10) {
- free_page((unsigned long)page);
- return -EINVAL;
- }
- while (line) {
- if (comx_strcasecmp(line->name, page) == 0) {
- break;
- } else {
- line = line->next;
- }
- }
-#ifdef CONFIG_KMOD
- if(!line && comx_strcasecmp(PROTONAME_NONE, page) != 0) {
- request_module("comx-proto-%s",page);
- }
- line=comx_lines;
- while (line) {
- if (comx_strcasecmp(line->name, page) == 0) {
- break;
- } else {
- line = line->next;
- }
- }
-#endif
-
- if (comx_strcasecmp(PROTONAME_NONE, page) != 0 && !line) {
- free_page((unsigned long)page);
- return -ENODEV;
- }
-
- if (ch->init_status & LINE_OPEN) {
- free_page((unsigned long)page);
- return -EBUSY;
- }
-
- if (ch->protocol && ch->protocol->line_exit &&
- (ret=ch->protocol->line_exit(dev))) {
- free_page((unsigned long)page);
- return ret;
- }
- ch->protocol = line;
- entry->size = strlen(page) + 1;
- comx_reset_dev(dev);
- if (line && line->line_init) line->line_init(dev);
- } else if (strcmp(entry->name, FILENAME_LINEUPDELAY) == 0) {
- int i;
-
- if ((i = simple_strtoul(page, NULL, 10)) != 0) {
- if (i >=0 && i < 10) {
- ch->lineup_delay = i;
- } else {
- printk(KERN_ERR "comx: invalid lineup_delay value\n");
- }
- }
- }
-out:
- free_page((unsigned long)page);
- return count;
-}
-
-static int comx_mkdir(struct inode *dir, struct dentry *dentry, int mode)
-{
- struct proc_dir_entry *new_dir, *debug_file;
- struct net_device *dev;
- struct comx_channel *ch;
- int ret = -EIO;
-
- if ((dev = kmalloc(sizeof(struct net_device), GFP_KERNEL)) == NULL) {
- return -ENOMEM;
- }
- memset(dev, 0, sizeof(struct net_device));
-
- lock_kernel();
- if ((new_dir = create_proc_entry(dentry->d_name.name, mode | S_IFDIR,
- comx_root_dir)) == NULL) {
- goto cleanup_dev;
- }
-
- new_dir->nlink = 2;
- new_dir->data = NULL; // ide jon majd a struct dev
-
- /* Ezek kellenek */
- if (!create_comx_proc_entry(FILENAME_HARDWARE, 0644,
- strlen(HWNAME_NONE) + 1, new_dir)) {
- goto cleanup_new_dir;
- }
- if (!create_comx_proc_entry(FILENAME_PROTOCOL, 0644,
- strlen(PROTONAME_NONE) + 1, new_dir)) {
- goto cleanup_filename_hardware;
- }
- if (!create_comx_proc_entry(FILENAME_STATUS, 0444, 0, new_dir)) {
- goto cleanup_filename_protocol;
- }
- if (!create_comx_proc_entry(FILENAME_LINEUPDELAY, 0644, 2, new_dir)) {
- goto cleanup_filename_status;
- }
-
- if ((debug_file = create_proc_entry(FILENAME_DEBUG,
- S_IFREG | 0644, new_dir)) == NULL) {
- goto cleanup_filename_lineupdelay;
- }
- debug_file->data = (void *)debug_file;
- debug_file->read_proc = NULL; // see below
- debug_file->write_proc = &comx_write_proc;
- debug_file->nlink = 1;
-
- strcpy(dev->name, (char *)new_dir->name);
- dev->init = comx_init_dev;
-
- if (register_netdevice(dev)) {
- goto cleanup_filename_debug;
- }
- ch = dev->priv;
- if((ch->if_ptr = (void *)kmalloc(sizeof(struct ppp_device),
- GFP_KERNEL)) == NULL) {
- goto cleanup_register;
- }
- memset(ch->if_ptr, 0, sizeof(struct ppp_device));
- ch->debug_file = debug_file;
- ch->procdir = new_dir;
- new_dir->data = dev;
-
- ch->debug_start = ch->debug_end = 0;
- if ((ch->debug_area = kmalloc(ch->debug_size = DEFAULT_DEBUG_SIZE,
- GFP_KERNEL)) == NULL) {
- ret = -ENOMEM;
- goto cleanup_if_ptr;
- }
-
- ch->lineup_delay = DEFAULT_LINEUP_DELAY;
-
- MOD_INC_USE_COUNT;
- unlock_kernel();
- return 0;
-cleanup_if_ptr:
- kfree(ch->if_ptr);
-cleanup_register:
- unregister_netdevice(dev);
-cleanup_filename_debug:
- remove_proc_entry(FILENAME_DEBUG, new_dir);
-cleanup_filename_lineupdelay:
- remove_proc_entry(FILENAME_LINEUPDELAY, new_dir);
-cleanup_filename_status:
- remove_proc_entry(FILENAME_STATUS, new_dir);
-cleanup_filename_protocol:
- remove_proc_entry(FILENAME_PROTOCOL, new_dir);
-cleanup_filename_hardware:
- remove_proc_entry(FILENAME_HARDWARE, new_dir);
-cleanup_new_dir:
- remove_proc_entry(dentry->d_name.name, comx_root_dir);
-cleanup_dev:
- kfree(dev);
- unlock_kernel();
- return ret;
-}
-
-static int comx_rmdir(struct inode *dir, struct dentry *dentry)
-{
- struct proc_dir_entry *entry = PDE(dentry->d_inode);
- struct net_device *dev;
- struct comx_channel *ch;
- int ret;
-
- lock_kernel();
- dev = entry->data;
- ch = dev->priv;
- if (dev->flags & IFF_UP) {
- printk(KERN_ERR "%s: down interface before removing it\n", dev->name);
- unlock_kernel();
- return -EBUSY;
- }
-
- if (ch->protocol && ch->protocol->line_exit &&
- (ret=ch->protocol->line_exit(dev))) {
- unlock_kernel();
- return ret;
- }
- if (ch->hardware && ch->hardware->hw_exit &&
- (ret=ch->hardware->hw_exit(dev))) {
- if(ch->protocol && ch->protocol->line_init) {
- ch->protocol->line_init(dev);
- }
- unlock_kernel();
- return ret;
- }
- ch->protocol = NULL;
- ch->hardware = NULL;
-
- del_timer(&ch->loadavg_timer);
- kfree(ch->avg_bytes);
-
- unregister_netdev(dev);
- if (ch->debug_area) {
- kfree(ch->debug_area);
- }
- if (dev->priv) {
- kfree(dev->priv);
- }
- free_netdev(dev);
-
- remove_proc_entry(FILENAME_DEBUG, entry);
- remove_proc_entry(FILENAME_LINEUPDELAY, entry);
- remove_proc_entry(FILENAME_STATUS, entry);
- remove_proc_entry(FILENAME_HARDWARE, entry);
- remove_proc_entry(FILENAME_PROTOCOL, entry);
- remove_proc_entry(dentry->d_name.name, comx_root_dir);
-
- MOD_DEC_USE_COUNT;
- unlock_kernel();
- return 0;
-}
-
-static struct dentry *comx_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
-{
- struct proc_dir_entry *de;
- struct inode *inode = NULL;
-
- lock_kernel();
- if ((de = PDE(dir)) != NULL) {
- for (de = de->subdir ; de ; de = de->next) {
- if ((de->namelen == dentry->d_name.len) &&
- (memcmp(dentry->d_name.name, de->name,
- de->namelen) == 0)) {
- if ((inode = proc_get_inode(dir->i_sb,
- de->low_ino, de)) == NULL) {
- printk(KERN_ERR "COMX: lookup error\n");
- unlock_kernel();
- return ERR_PTR(-EINVAL);
- }
- break;
- }
- }
- }
- unlock_kernel();
- dentry->d_op = &comx_dentry_operations;
- d_add(dentry, inode);
- return NULL;
-}
-
-int comx_strcasecmp(const char *cs, const char *ct)
-{
- register signed char __res;
-
- while (1) {
- if ((__res = toupper(*cs) - toupper(*ct++)) != 0 || !*cs++) {
- break;
- }
- }
- return __res;
-}
-
-static int comx_delete_dentry(struct dentry *dentry)
-{
- return 1;
-}
-
-static struct proc_dir_entry *create_comx_proc_entry(char *name, int mode,
- int size, struct proc_dir_entry *dir)
-{
- struct proc_dir_entry *new_file;
-
- if ((new_file = create_proc_entry(name, S_IFREG | mode, dir)) != NULL) {
- new_file->data = (void *)new_file;
- new_file->read_proc = &comx_read_proc;
- new_file->write_proc = &comx_write_proc;
- new_file->size = size;
- new_file->nlink = 1;
- }
- return(new_file);
-}
-
-int comx_register_hardware(struct comx_hardware *comx_hw)
-{
- struct comx_hardware *hw = comx_channels;
-
- if (!hw) {
- comx_channels = comx_hw;
- } else {
- while (hw->next != NULL && strcmp(comx_hw->name, hw->name) != 0) {
- hw = hw->next;
- }
- if (strcmp(comx_hw->name, hw->name) == 0) {
- return -1;
- }
- hw->next = comx_hw;
- }
-
- printk(KERN_INFO "COMX: driver for hardware type %s, version %s\n", comx_hw->name, comx_hw->version);
- return 0;
-}
-
-int comx_unregister_hardware(char *name)
-{
- struct comx_hardware *hw = comx_channels;
-
- if (!hw) {
- return -1;
- }
-
- if (strcmp(hw->name, name) == 0) {
- comx_channels = comx_channels->next;
- return 0;
- }
-
- while (hw->next != NULL && strcmp(hw->next->name,name) != 0) {
- hw = hw->next;
- }
-
- if (hw->next != NULL && strcmp(hw->next->name, name) == 0) {
- hw->next = hw->next->next;
- return 0;
- }
- return -1;
-}
-
-int comx_register_protocol(struct comx_protocol *comx_line)
-{
- struct comx_protocol *pr = comx_lines;
-
- if (!pr) {
- comx_lines = comx_line;
- } else {
- while (pr->next != NULL && strcmp(comx_line->name, pr->name) !=0) {
- pr = pr->next;
- }
- if (strcmp(comx_line->name, pr->name) == 0) {
- return -1;
- }
- pr->next = comx_line;
- }
-
- printk(KERN_INFO "COMX: driver for protocol type %s, version %s\n", comx_line->name, comx_line->version);
- return 0;
-}
-
-int comx_unregister_protocol(char *name)
-{
- struct comx_protocol *pr = comx_lines;
-
- if (!pr) {
- return -1;
- }
-
- if (strcmp(pr->name, name) == 0) {
- comx_lines = comx_lines->next;
- return 0;
- }
-
- while (pr->next != NULL && strcmp(pr->next->name,name) != 0) {
- pr = pr->next;
- }
-
- if (pr->next != NULL && strcmp(pr->next->name, name) == 0) {
- pr->next = pr->next->next;
- return 0;
- }
- return -1;
-}
-
-static int __init comx_init(void)
-{
- struct proc_dir_entry *new_file;
-
- comx_root_dir = create_proc_entry("comx",
- S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, &proc_root);
- if (!comx_root_dir)
- return -ENOMEM;
- comx_root_dir->proc_iops = &comx_root_inode_ops;
-
- if ((new_file = create_proc_entry(FILENAME_HARDWARELIST,
- S_IFREG | 0444, comx_root_dir)) == NULL) {
- return -ENOMEM;
- }
-
- new_file->data = new_file;
- new_file->read_proc = &comx_root_read_proc;
- new_file->write_proc = NULL;
- new_file->nlink = 1;
-
- if ((new_file = create_proc_entry(FILENAME_PROTOCOLLIST,
- S_IFREG | 0444, comx_root_dir)) == NULL) {
- return -ENOMEM;
- }
-
- new_file->data = new_file;
- new_file->read_proc = &comx_root_read_proc;
- new_file->write_proc = NULL;
- new_file->nlink = 1;
-
-
- printk(KERN_INFO "COMX: driver version %s (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>\n",
- VERSION);
- return 0;
-}
-
-static void __exit comx_exit(void)
-{
- remove_proc_entry(FILENAME_HARDWARELIST, comx_root_dir);
- remove_proc_entry(FILENAME_PROTOCOLLIST, comx_root_dir);
- remove_proc_entry(comx_root_dir->name, &proc_root);
-}
-
-module_init(comx_init);
-module_exit(comx_exit);
-
-EXPORT_SYMBOL(comx_register_hardware);
-EXPORT_SYMBOL(comx_unregister_hardware);
-EXPORT_SYMBOL(comx_register_protocol);
-EXPORT_SYMBOL(comx_unregister_protocol);
-EXPORT_SYMBOL(comx_debug_skb);
-EXPORT_SYMBOL(comx_debug_bytes);
-EXPORT_SYMBOL(comx_debug);
-EXPORT_SYMBOL(comx_lineup_func);
-EXPORT_SYMBOL(comx_status);
-EXPORT_SYMBOL(comx_rx);
-EXPORT_SYMBOL(comx_strcasecmp);
-EXPORT_SYMBOL(comx_root_dir);
+++ /dev/null
-/*
- * General definitions for the COMX driver
- *
- * Original authors: Arpad Bakay <bakay.arpad@synergon.hu>,
- * Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Currently maintained by: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- *
- * net_device_stats:
- * rx_length_errors rec_len < 4 || rec_len > 2000
- * rx_over_errors receive overrun (OVR)
- * rx_crc_errors rx crc error
- * rx_frame_errors aborts rec'd (ABO)
- * rx_fifo_errors status fifo overrun (PBUFOVR)
- * rx_missed_errors receive buffer overrun (BUFOVR)
- * tx_aborted_errors ?
- * tx_carrier_errors modem line status changes
- * tx_fifo_errors tx underrun (locomx)
- */
-#include <linux/config.h>
-
-struct comx_protocol {
- char *name;
- char *version;
- unsigned short encap_type;
- int (*line_init)(struct net_device *dev);
- int (*line_exit)(struct net_device *dev);
- struct comx_protocol *next;
- };
-
-struct comx_hardware {
- char *name;
- char *version;
- int (*hw_init)(struct net_device *dev);
- int (*hw_exit)(struct net_device *dev);
- int (*hw_dump)(struct net_device *dev);
- struct comx_hardware *next;
- };
-
-struct comx_channel {
- void *if_ptr; // General purpose pointer
- struct net_device *dev; // Where we belong to
- struct net_device *twin; // On dual-port cards
- struct proc_dir_entry *procdir; // the directory
-
- unsigned char init_status;
- unsigned char line_status;
-
- struct timer_list lineup_timer; // against line jitter
- long int lineup_pending;
- unsigned char lineup_delay;
-
-#if 0
- struct timer_list reset_timer; // for board resetting
- long reset_pending;
- int reset_timeout;
-#endif
-
- struct net_device_stats stats;
- struct net_device_stats *current_stats;
-#if 0
- unsigned long board_resets;
-#endif
- unsigned long *avg_bytes;
- int loadavg_counter, loadavg_size;
- int loadavg[3];
- struct timer_list loadavg_timer;
- int debug_flags;
- char *debug_area;
- int debug_start, debug_end, debug_size;
- struct proc_dir_entry *debug_file;
-#ifdef CONFIG_COMX_DEBUG_RAW
- char *raw;
- int raw_len;
-#endif
- // LINE specific
- struct comx_protocol *protocol;
- void (*LINE_rx)(struct net_device *dev, struct sk_buff *skb);
- int (*LINE_tx)(struct net_device *dev);
- void (*LINE_status)(struct net_device *dev, u_short status);
- int (*LINE_open)(struct net_device *dev);
- int (*LINE_close)(struct net_device *dev);
- int (*LINE_xmit)(struct sk_buff *skb, struct net_device *dev);
- int (*LINE_header)(struct sk_buff *skb, struct net_device *dev,
- u_short type,void *daddr, void *saddr,
- unsigned len);
- int (*LINE_rebuild_header)(struct sk_buff *skb);
- int (*LINE_statistics)(struct net_device *dev, char *page);
- int (*LINE_parameter_check)(struct net_device *dev);
- int (*LINE_ioctl)(struct net_device *dev, struct ifreq *ifr,
- int cmd);
- void (*LINE_mod_use)(int);
- void * LINE_privdata;
-
- // HW specific
-
- struct comx_hardware *hardware;
- void (*HW_board_on)(struct net_device *dev);
- void (*HW_board_off)(struct net_device *dev);
- struct net_device *(*HW_access_board)(struct net_device *dev);
- void (*HW_release_board)(struct net_device *dev, struct net_device *savep);
- int (*HW_txe)(struct net_device *dev);
- int (*HW_open)(struct net_device *dev);
- int (*HW_close)(struct net_device *dev);
- int (*HW_send_packet)(struct net_device *dev,struct sk_buff *skb);
- int (*HW_statistics)(struct net_device *dev, char *page);
-#if 0
- int (*HW_reset)(struct net_device *dev, char *page);
-#endif
- int (*HW_load_board)(struct net_device *dev);
- void (*HW_set_clock)(struct net_device *dev);
- void *HW_privdata;
- };
-
-struct comx_debugflags_struct {
- char *name;
- int value;
- };
-
-#define COMX_ROOT_DIR_NAME "comx"
-
-#define FILENAME_HARDWARE "boardtype"
-#define FILENAME_HARDWARELIST "boardtypes"
-#define FILENAME_PROTOCOL "protocol"
-#define FILENAME_PROTOCOLLIST "protocols"
-#define FILENAME_DEBUG "debug"
-#define FILENAME_CLOCK "clock"
-#define FILENAME_STATUS "status"
-#define FILENAME_IO "io"
-#define FILENAME_IRQ "irq"
-#define FILENAME_KEEPALIVE "keepalive"
-#define FILENAME_LINEUPDELAY "lineup_delay"
-#define FILENAME_CHANNEL "channel"
-#define FILENAME_FIRMWARE "firmware"
-#define FILENAME_MEMADDR "memaddr"
-#define FILENAME_TWIN "twin"
-#define FILENAME_T1 "t1"
-#define FILENAME_T2 "t2"
-#define FILENAME_N2 "n2"
-#define FILENAME_WINDOW "window"
-#define FILENAME_MODE "mode"
-#define FILENAME_DLCI "dlci"
-#define FILENAME_MASTER "master"
-#ifdef CONFIG_COMX_DEBUG_RAW
-#define FILENAME_RAW "raw"
-#endif
-
-#define PROTONAME_NONE "none"
-#define HWNAME_NONE "none"
-#define KEEPALIVE_OFF "off"
-
-#define FRAME_ACCEPTED 0 /* sending and xmitter busy */
-#define FRAME_DROPPED 1
-#define FRAME_ERROR 2 /* xmitter error */
-#define FRAME_QUEUED 3 /* sending but more can come */
-
-#define LINE_UP 1 /* Modem UP */
-#define PROTO_UP 2
-#define PROTO_LOOP 4
-
-#define HW_OPEN 1
-#define LINE_OPEN 2
-#define FW_LOADED 4
-#define IRQ_ALLOCATED 8
-
-#define DEBUG_COMX_RX 2
-#define DEBUG_COMX_TX 4
-#define DEBUG_HW_TX 16
-#define DEBUG_HW_RX 32
-#define DEBUG_HDLC_KEEPALIVE 64
-#define DEBUG_COMX_PPP 128
-#define DEBUG_COMX_LAPB 256
-#define DEBUG_COMX_DLCI 512
-
-#define DEBUG_PAGESIZE 3072
-#define DEFAULT_DEBUG_SIZE 4096
-#define DEFAULT_LINEUP_DELAY 1
-#define FILE_PAGESIZE 3072
-
-#ifndef COMX_PPP_MAJOR
-#define COMX_PPP_MAJOR 88
-#endif
-
-
-#define COMX_CHANNEL(dev) ((struct comx_channel*)dev->priv)
-
-#define TWIN(dev) (COMX_CHANNEL(dev)->twin)
-
-
-#ifndef byte
-typedef u8 byte;
-#endif
-#ifndef word
-typedef u16 word;
-#endif
-
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-extern struct proc_dir_entry * comx_root_dir;
-
-extern int comx_register_hardware(struct comx_hardware *comx_hw);
-extern int comx_unregister_hardware(char *name);
-extern int comx_register_protocol(struct comx_protocol *comx_line);
-extern int comx_unregister_protocol(char *name);
-
-extern int comx_rx(struct net_device *dev, struct sk_buff *skb);
-extern void comx_status(struct net_device *dev, int status);
-extern void comx_lineup_func(unsigned long d);
-
-extern int comx_debug(struct net_device *dev, char *fmt, ...);
-extern int comx_debug_skb(struct net_device *dev, struct sk_buff *skb, char *msg);
-extern int comx_debug_bytes(struct net_device *dev, unsigned char *bytes, int len,
- char *msg);
-extern int comx_strcasecmp(const char *cs, const char *ct);
-
-extern struct inode_operations comx_normal_inode_ops;
+++ /dev/null
-/*
- * Defines for comxhw.c
- *
- * Original authors: Arpad Bakay <bakay.arpad@synergon.hu>,
- * Peter Bajan <bajan.peter@synergon.hu>,
- * Previous maintainer: Tivadar Szemethy <tiv@itc.hu>
- * Current maintainer: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1995-1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- */
-
-#define LOCOMX_IO_EXTENT 8
-#define COMX_IO_EXTENT 4
-#define HICOMX_IO_EXTENT 16
-
-#define COMX_MAX_TX_SIZE 1600
-#define COMX_MAX_RX_SIZE 2048
-
-#define COMX_JAIL_OFFSET 0xffff
-#define COMX_JAIL_VALUE 0xfe
-#define COMX_MEMORY_SIZE 65536
-#define HICOMX_MEMORY_SIZE 16384
-#define COMX_MEM_MIN 0xa0000
-#define COMX_MEM_MAX 0xf0000
-
-#define COMX_DEFAULT_IO 0x360
-#define COMX_DEFAULT_IRQ 10
-#define COMX_DEFAULT_MEMADDR 0xd0000
-#define HICOMX_DEFAULT_IO 0x320
-#define HICOMX_DEFAULT_IRQ 10
-#define HICOMX_DEFAULT_MEMADDR 0xd0000
-#define LOCOMX_DEFAULT_IO 0x368
-#define LOCOMX_DEFAULT_IRQ 7
-
-#define MAX_CHANNELNO 2
-
-#define COMX_CHANNEL_OFFSET 0x2000
-
-#define COMX_ENABLE_BOARD_IT 0x40
-#define COMX_BOARD_RESET 0x20
-#define COMX_ENABLE_BOARD_MEM 0x10
-#define COMX_DISABLE_BOARD_MEM 0
-#define COMX_DISABLE_ALL 0x00
-
-#define HICOMX_DISABLE_ALL 0x00
-#define HICOMX_ENABLE_BOARD_MEM 0x02
-#define HICOMX_DISABLE_BOARD_MEM 0x0
-#define HICOMX_BOARD_RESET 0x01
-#define HICOMX_PRG_MEM 4
-#define HICOMX_DATA_MEM 0
-#define HICOMX_ID_BYTE 0x55
-
-#define CMX_ID_BYTE 0x31
-#define COMX_CLOCK_CONST 8000
-
-#define LINKUP_READY 3
-
-#define OFF_FW_L1_ID 0x01e /* ID bytes */
-#define OFF_FW_L2_ID 0x1006
-#define FW_L1_ID_1 0xab
-#define FW_L1_ID_2_COMX 0xc0
-#define FW_L1_ID_2_HICOMX 0xc1
-#define FW_L2_ID_1 0xab
-
-#define OFF_A_L2_CMD 0x130 /* command register for L2 */
-#define OFF_A_L2_CMDPAR 0x131 /* command parameter byte */
-#define OFF_A_L1_STATB 0x122 /* stat. block for L1 */
-#define OFF_A_L1_ABOREC 0x122 /* receive ABORT counter */
-#define OFF_A_L1_OVERRUN 0x123 /* receive overrun counter */
-#define OFF_A_L1_CRCREC 0x124 /* CRC error counter */
-#define OFF_A_L1_BUFFOVR 0x125 /* buffer overrun counter */
-#define OFF_A_L1_PBUFOVR 0x126 /* priority buffer overrun counter */
-#define OFF_A_L1_MODSTAT 0x127 /* current state of modem ctrl lines */
-#define OFF_A_L1_STATE 0x127 /* end of stat. block for L1 */
-#define OFF_A_L1_TXPC 0x128 /* Tx counter for the PC */
-#define OFF_A_L1_TXZ80 0x129 /* Tx counter for the Z80 */
-#define OFF_A_L1_RXPC 0x12a /* Rx counter for the PC */
-#define OFF_A_L1_RXZ80 0x12b /* Rx counter for the Z80 */
-#define OFF_A_L1_REPENA 0x12c /* IT rep disable */
-#define OFF_A_L1_CHNR 0x12d /* L1 channel logical number */
-#define OFF_A_L1_CLKINI 0x12e /* Timer Const */
-#define OFF_A_L2_LINKUP 0x132 /* Linkup byte */
-#define OFF_A_L2_DAV 0x134 /* Rx DAV */
-#define OFF_A_L2_RxBUFP 0x136 /* Rx buff relative to membase */
-#define OFF_A_L2_TxEMPTY 0x138 /* Tx Empty */
-#define OFF_A_L2_TxBUFP 0x13a /* Tx Buf */
-#define OFF_A_L2_NBUFFS 0x144 /* Number of buffers to fetch */
-
-#define OFF_A_L2_SABMREC 0x164 /* LAPB no. of SABMs received */
-#define OFF_A_L2_SABMSENT 0x165 /* LAPB no. of SABMs sent */
-#define OFF_A_L2_REJREC 0x166 /* LAPB no. of REJs received */
-#define OFF_A_L2_REJSENT 0x167 /* LAPB no. of REJs sent */
-#define OFF_A_L2_FRMRREC 0x168 /* LAPB no. of FRMRs received */
-#define OFF_A_L2_FRMRSENT 0x169 /* LAPB no. of FRMRs sent */
-#define OFF_A_L2_PROTERR 0x16A /* LAPB no. of protocol errors rec'd */
-#define OFF_A_L2_LONGREC 0x16B /* LAPB no. of long frames */
-#define OFF_A_L2_INVNR 0x16C /* LAPB no. of invalid N(R)s rec'd */
-#define OFF_A_L2_UNDEFFR 0x16D /* LAPB no. of invalid frames */
-
-#define OFF_A_L2_T1 0x174 /* T1 timer */
-#define OFF_A_L2_ADDR 0x176 /* DCE = 1, DTE = 3 */
-
-#define COMX_CMD_INIT 1
-#define COMX_CMD_EXIT 2
-#define COMX_CMD_OPEN 16
-#define COMX_CMD_CLOSE 17
-
+++ /dev/null
-/*
- * Defines for comx-hw-slicecom.c - FALC-LH specific
- *
- * Author: Bartok Istvan <bartoki@itc.hu>
- * Last modified: Mon Feb 7 20:00:38 CET 2000
- *
- * :set tabstop=6
- */
-
-/*
- * Control register offsets on the LBI (page 90)
- * use it like:
- * lbi[ MODE ] = 0x34;
- */
-
-#define MODE 0x03
-#define IPC 0x08
-#define IMR0 0x14 /* Interrupt Mask Register 0 */
-#define IMR1 0x15
-#define IMR2 0x16
-#define IMR3 0x17
-#define IMR4 0x18
-#define IMR5 0x19
-#define FMR0 0x1a /* Framer Mode Register 0 */
-#define FMR1 0x1b
-#define FMR2 0x1c
-#define XSW 0x1e
-#define XSP 0x1f
-#define XC0 0x20
-#define XC1 0x21
-#define RC0 0x22
-#define RC1 0x23
-#define XPM0 0x24
-#define XPM1 0x25
-#define XPM2 0x26
-#define TSWM 0x27
-#define IDLE 0x29 /* Idle Code */
-#define LIM0 0x34
-#define LIM1 0x35
-#define PCD 0x36
-#define PCR 0x37
-#define LIM2 0x38
-
-/*
- * Status registers on the LBI (page 134)
- * these are read-only, use it like:
- * if( lbi[ FRS0 ] ) ...
- */
-
-#define FRS0 0x4c /* Framer Receive Status register 0 */
-#define FRS1 0x4d /* Framer Receive Status register 1 */
-#define FECL 0x50 /* Framing Error Counter low byte */ /* Counts FAS word receive errors */
-#define FECH 0x51 /* high byte */
-#define CVCL 0x52 /* Code Violation Counter low byte */ /* Counts bipolar and HDB3 code violations */
-#define CVCH 0x53 /* high byte */
-#define CEC1L 0x54 /* CRC4 Error Counter 1 low byte */ /* Counts CRC4 errors in the incoming stream */
-#define CEC1H 0x55 /* high byte */
-#define EBCL 0x56 /* E Bit error Counter low byte */ /* E-bits: the remote end sends them, when */
-#define EBCH 0x57 /* high byte */ /* it detected a CRC4-error */
-#define ISR0 0x68 /* Interrupt Status Register 0 */
-#define ISR1 0x69 /* Interrupt Status Register 1 */
-#define ISR2 0x6a /* Interrupt Status Register 2 */
-#define ISR3 0x6b /* Interrupt Status Register 3 */
-#define ISR5 0x6c /* Interrupt Status Register 5 */
-#define GIS 0x6e /* Global Interrupt Status Register */
-#define VSTR 0x6f /* version information */
-
-/*
- * Bit fields
- */
-
-#define FRS0_LOS (1 << 7)
-#define FRS0_AIS (1 << 6)
-#define FRS0_LFA (1 << 5)
-#define FRS0_RRA (1 << 4)
-#define FRS0_AUXP (1 << 3)
-#define FRS0_NMF (1 << 2)
-#define FRS0_LMFA (1 << 1)
-
-#define FRS1_XLS (1 << 1)
-#define FRS1_XLO (1)
-
-#define ISR2_FAR (1 << 7)
-#define ISR2_LFA (1 << 6)
-#define ISR2_MFAR (1 << 5)
-#define ISR2_T400MS (1 << 4)
-#define ISR2_AIS (1 << 3)
-#define ISR2_LOS (1 << 2)
-#define ISR2_RAR (1 << 1)
-#define ISR2_RA (1)
-
-#define ISR3_ES (1 << 7)
-#define ISR3_SEC (1 << 6)
-#define ISR3_LMFA16 (1 << 5)
-#define ISR3_AIS16 (1 << 4)
-#define ISR3_RA16 (1 << 3)
-#define ISR3_API (1 << 2)
-#define ISR3_RSN (1 << 1)
-#define ISR3_RSP (1)
-
-#define ISR5_XSP (1 << 7)
-#define ISR5_XSN (1 << 6)
+++ /dev/null
-#define HSCX_MTU 1600
-
-#define HSCX_ISTA 0x00
-#define HSCX_MASK 0x00
-#define HSCX_STAR 0x01
-#define HSCX_CMDR 0x01
-#define HSCX_MODE 0x02
-#define HSCX_TIMR 0x03
-#define HSCX_EXIR 0x04
-#define HSCX_XAD1 0x04
-#define HSCX_RBCL 0x05
-#define HSCX_SAD2 0x05
-#define HSCX_RAH1 0x06
-#define HSCX_RSTA 0x07
-#define HSCX_RAH2 0x07
-#define HSCX_RAL1 0x08
-#define HSCX_RCHR 0x09
-#define HSCX_RAL2 0x09
-#define HSCX_XBCL 0x0a
-#define HSCX_BGR 0x0b
-#define HSCX_CCR2 0x0c
-#define HSCX_RBCH 0x0d
-#define HSCX_XBCH 0x0d
-#define HSCX_VSTR 0x0e
-#define HSCX_RLCR 0x0e
-#define HSCX_CCR1 0x0f
-#define HSCX_FIFO 0x1e
-
-#define HSCX_HSCX_CHOFFS 0x400
-#define HSCX_SEROFFS 0x1000
-
-#define HSCX_RME 0x80
-#define HSCX_RPF 0x40
-#define HSCX_RSC 0x20
-#define HSCX_XPR 0x10
-#define HSCX_TIN 0x08
-#define HSCX_ICA 0x04
-#define HSCX_EXA 0x02
-#define HSCX_EXB 0x01
-
-#define HSCX_XMR 0x80
-#define HSCX_XDU 0x40
-#define HSCX_EXE 0x40
-#define HSCX_PCE 0x20
-#define HSCX_RFO 0x10
-#define HSCX_CSC 0x08
-#define HSCX_RFS 0x04
-
-#define HSCX_XDOV 0x80
-#define HSCX_XFW 0x40
-#define HSCX_XRNR 0x20
-#define HSCX_RRNR 0x10
-#define HSCX_RLI 0x08
-#define HSCX_CEC 0x04
-#define HSCX_CTS 0x02
-#define HSCX_WFA 0x01
-
-#define HSCX_RMC 0x80
-#define HSCX_RHR 0x40
-#define HSCX_RNR 0x20
-#define HSCX_XREP 0x20
-#define HSCX_STI 0x10
-#define HSCX_XTF 0x08
-#define HSCX_XIF 0x04
-#define HSCX_XME 0x02
-#define HSCX_XRES 0x01
-
-#define HSCX_AUTO 0x00
-#define HSCX_NONAUTO 0x40
-#define HSCX_TRANS 0x80
-#define HSCX_XTRANS 0xc0
-#define HSCX_ADM16 0x20
-#define HSCX_ADM8 0x00
-#define HSCX_TMD_EXT 0x00
-#define HSCX_TMD_INT 0x10
-#define HSCX_RAC 0x08
-#define HSCX_RTS 0x04
-#define HSCX_TLP 0x01
-
-#define HSCX_VFR 0x80
-#define HSCX_RDO 0x40
-#define HSCX_CRC 0x20
-#define HSCX_RAB 0x10
-
-#define HSCX_CIE 0x04
-#define HSCX_RIE 0x02
-
-#define HSCX_DMA 0x80
-#define HSCX_NRM 0x40
-#define HSCX_CAS 0x20
-#define HSCX_XC 0x10
-
-#define HSCX_OV 0x10
-
-#define HSCX_CD 0x80
-
-#define HSCX_RC 0x80
-
-#define HSCX_PU 0x80
-#define HSCX_NRZ 0x00
-#define HSCX_NRZI 0x40
-#define HSCX_ODS 0x10
-#define HSCX_ITF 0x08
+++ /dev/null
-/*
- * Defines for the mixcom board
- *
- * Author: Gergely Madarasz <gorgo@itc.hu>
- *
- * Copyright (C) 1999 ITConsult-Pro Co. <info@itc.hu>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- */
-
-#define MIXCOM_IO_EXTENT 0x20
-
-#define MIXCOM_DEFAULT_IO 0x180
-#define MIXCOM_DEFAULT_IRQ 5
-
-#define MIXCOM_ID 0x11
-#define MIXCOM_SERIAL_OFFSET 0x1000
-#define MIXCOM_CHANNEL_OFFSET 0x400
-#define MIXCOM_IT_OFFSET 0xc14
-#define MIXCOM_STATUS_OFFSET 0xc14
-#define MIXCOM_ID_OFFSET 0xc10
-#define MIXCOM_ON 0x1
-#define MIXCOM_OFF 0x0
-
-/* Status register bits */
-
-#define MIXCOM_CTSB 0x1
-#define MIXCOM_CTSA 0x2
-#define MIXCOM_CHANNELNO 0x20
-#define MIXCOM_POWERFAIL 0x40
-#define MIXCOM_BOOT 0x80
+++ /dev/null
-/*
- * Defines for comx-hw-slicecom.c - MUNICH32X specific
- *
- * Author: Bartok Istvan <bartoki@itc.hu>
- * Last modified: Tue Jan 11 14:27:36 CET 2000
- *
- * :set tabstop=6
- */
-
-#define TXBUFFER_SIZE 1536 /* Max mennyit tud a kartya hardver atvenni */
-#define RXBUFFER_SIZE (TXBUFFER_SIZE+4) /* For Rx reasons it must be a multiple of 4, and =>4 (page 265) */
- /* +4 .. see page 265, bit FE */
- /* TOD: a MODE1-be nem is ezt teszem, hanem a TXBUFFER-t, lehet hogy nem is kell? */
-
-//#define PCI_VENDOR_ID_SIEMENS 0x110a
-#define PCI_DEVICE_ID_SIEMENS_MUNICH32X 0x2101
-
-/*
- * PCI config space registers (page 120)
- */
-
-#define MUNICH_PCI_PCIRES 0x4c /* 0xe0000 resets the chip */
-
-
-/*
- * MUNICH slave register offsets relative to base_address[0] (PCI BAR1) (page 181):
- * offsets are in bytes, registers are u32's, so we need a >>2 for indexing
- * the int[] by byte offsets. Use it like:
- *
- * bar1[ STAT ] = ~0L; or
- * x = bar1[ STAT ];
- */
-
-#define CONF (0x00 >> 2)
-#define CMD (0x04 >> 2)
-#define STAT (0x08 >> 2)
-#define STACK (0x08 >> 2)
-#define IMASK (0x0c >> 2)
-#define PIQBA (0x14 >> 2)
-#define PIQL (0x18 >> 2)
-#define MODE1 (0x20 >> 2)
-#define MODE2 (0x24 >> 2)
-#define CCBA (0x28 >> 2)
-#define TXPOLL (0x2c >> 2)
-#define TIQBA (0x30 >> 2)
-#define TIQL (0x34 >> 2)
-#define RIQBA (0x38 >> 2)
-#define RIQL (0x3c >> 2)
-#define LCONF (0x40 >> 2) /* LBI Configuration Register */
-#define LCCBA (0x44 >> 2) /* LBI Configuration Control Block */ /* DE: lehet hogy nem is kell? */
-#define LTIQBA (0x50 >> 2) /* DE: lehet hogy nem is kell? page 210: LBI DMA Controller intq - nem hasznalunk DMA-t.. */
-#define LTIQL (0x54 >> 2) /* DE: lehet hogy nem is kell? */
-#define LRIQBA (0x58 >> 2) /* DE: lehet hogy nem is kell? */
-#define LRIQL (0x5c >> 2) /* DE: lehet hogy nem is kell? */
-#define LREG0 (0x60 >> 2) /* LBI Indirect External Configuration register 0 */
-#define LREG1 (0x64 >> 2)
-#define LREG2 (0x68 >> 2)
-#define LREG3 (0x6c >> 2)
-#define LREG4 (0x70 >> 2)
-#define LREG5 (0x74 >> 2)
-#define LREG6 (0x78 >> 2) /* LBI Indirect External Configuration register 6 */
-#define LSTAT (0x7c >> 2) /* LBI Status Register */
-#define GPDIR (0x80 >> 2) /* General Purpose Bus DIRection - 0..input, 1..output */
-#define GPDATA (0x84 >> 2) /* General Purpose Bus DATA */
-
-
-/*
- * MUNICH commands: (they go into register CMD)
- */
-
-#define CMD_ARPCM 0x01 /* Action Request Serial PCM Core */
-#define CMD_ARLBI 0x02 /* Action Request LBI */
-
-
-/*
- * MUNICH event bits in the STAT, STACK, IMASK registers (page 188,189)
- */
-
-#define STAT_PTI (1 << 15)
-#define STAT_PRI (1 << 14)
-#define STAT_LTI (1 << 13)
-#define STAT_LRI (1 << 12)
-#define STAT_IOMI (1 << 11)
-#define STAT_SSCI (1 << 10)
-#define STAT_LBII (1 << 9)
-#define STAT_MBI (1 << 8)
-
-#define STAT_TI (1 << 6)
-#define STAT_TSPA (1 << 5)
-#define STAT_RSPA (1 << 4)
-#define STAT_LBIF (1 << 3)
-#define STAT_LBIA (1 << 2)
-#define STAT_PCMF (1 << 1)
-#define STAT_PCMA (1)
-
-/*
- * We do not handle these (and do not touch their STAT bits) in the interrupt loop
- */
-
-#define STAT_NOT_HANDLED_BY_INTERRUPT (STAT_PCMF | STAT_PCMA)
-
-
-/*
- * MUNICH MODE1/MODE2 slave register fields (page 193,196)
- * these are not all masks, MODE1_XX_YY are my magic values!
- */
-
-#define MODE1_PCM_E1 (1 << 31) /* E1, 2.048 Mbit/sec */
-#define MODE1_TBS_4 (1 << 24) /* TBS = 4 .. no Tx bit shift */
-#define MODE1_RBS_4 (1 << 18) /* RBS = 4 .. no Rx bit shift */
-#define MODE1_REN (1 << 15) /* Rx Enable */
-#define MODE1_MFL_MY TXBUFFER_SIZE /* Maximum Frame Length */
-#define MODE1_MAGIC (MODE1_PCM_E1 | MODE1_TBS_4 | MODE1_RBS_4 | MODE1_REN | MODE1_MFL_MY)
-
-#define MODE2_HPOLL (1 << 8) /* Hold Poll */
-#define MODE2_SPOLL (1 << 7) /* Slow Poll */
-#define MODE2_TSF (1) /* real magic - discovered by probing :) */
-// #define MODE2_MAGIC (MODE2_TSF)
-#define MODE2_MAGIC (MODE2_SPOLL | MODE2_TSF)
-
-
-/*
- * LCONF bits (page 205)
- * these are not all masks, LCONF_XX_YY are my magic values!
- */
-
-#define LCONF_IPA (1 << 31) /* Interrupt Pass. Use 1 for FALC54 */
-#define LCONF_DCA (1 << 30) /* Disregard the int's for Channel A - DMSM does not try to handle them */
-#define LCONF_DCB (1 << 29) /* Disregard the int's for Channel B */
-#define LCONF_EBCRES (1 << 22) /* Reset LBI External Bus Controller, 0..reset, 1..normal operation */
-#define LCONF_LBIRES (1 << 21) /* Reset LBI DMSM, 0..reset, 1..normal operation */
-#define LCONF_BTYP_16DEMUX (1 << 7) /* 16-bit demultiplexed bus */
-#define LCONF_ABM (1 << 4) /* Arbitration Master */
-
-/* writing LCONF_MAGIC1 followed by a LCONF_MAGIC2 into LCONF resets the EBC and DMSM: */
-
-#define LCONF_MAGIC1 (LCONF_BTYP_16DEMUX | LCONF_ABM | LCONF_IPA | LCONF_DCA | LCONF_DCB)
-#define LCONF_MAGIC2 (LCONF_MAGIC1 | LCONF_EBCRES | LCONF_LBIRES)
-
-
-/*
- * LREGx magic values if a FALC54 is on the LBI (page 217)
- */
-
-#define LREG0_MAGIC 0x00000264
-#define LREG1_MAGIC 0x6e6a6b66
-#define LREG2_MAGIC 0x00000264
-#define LREG3_MAGIC 0x6e686966
-#define LREG4_MAGIC 0x00000000
-#define LREG5_MAGIC ( (7<<27) | (3<<24) | (1<<21) | (7<<3) | (2<<9) )
-
-
-/*
- * PCM Action Specification fields (munich_ccb_t.action_spec)
- */
-
-#define CCB_ACTIONSPEC_IN (1 << 15) /* init */
-#define CCB_ACTIONSPEC_ICO (1 << 14) /* init only this channel */
-#define CCB_ACTIONSPEC_RES (1 << 6) /* reset all channels */
-#define CCB_ACTIONSPEC_LOC (1 << 5)
-#define CCB_ACTIONSPEC_LOOP (1 << 4)
-#define CCB_ACTIONSPEC_LOOPI (1 << 3)
-#define CCB_ACTIONSPEC_IA (1 << 2)
-
-
-/*
- * Interrupt Information bits in the TIQ, RIQ
- */
-
-#define PCM_INT_HI (1 << 12)
-#define PCM_INT_FI (1 << 11)
-#define PCM_INT_IFC (1 << 10)
-#define PCM_INT_SF (1 << 9)
-#define PCM_INT_ERR (1 << 8)
-#define PCM_INT_FO (1 << 7)
-#define PCM_INT_FE2 (1 << 6)
-
-#define PCM_INT_CHANNEL( info ) (info & 0x1F)
-
-
-/*
- * Rx status info in the rx_desc_t.status
- */
-
-#define RX_STATUS_SF (1 << 6)
-#define RX_STATUS_LOSS (1 << 5)
-#define RX_STATUS_CRCO (1 << 4)
-#define RX_STATUS_NOB (1 << 3)
-#define RX_STATUS_LFD (1 << 2)
-#define RX_STATUS_RA (1 << 1)
-#define RX_STATUS_ROF 1
+++ /dev/null
-static u8 firmware[]={
-0x60,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0xB9,0x40,0x00,0x00,0x00,0x00,0x00,
-0x10,0x14,0x42,0x80,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x67,0x00,0x00,0x0E,
-0x06,0xB0,0x40,0x00,0x00,0x00,0x09,0xB0,0x00,0x00,0x10,0x04,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xDE,0x21,0xFC,0x00,0x00,0x16,0xBC,0x00,0x6C,
-0x21,0xFC,0x00,0x00,0x17,0x5E,0x01,0x00,0x21,0xFC,0x00,0x00,0x16,0xDE,0x01,0x78,
-0x21,0xFC,0x00,0x00,0x16,0xFE,0x01,0x74,0x21,0xFC,0x00,0x00,0x17,0x1E,0x01,0x70,
-0x21,0xFC,0x00,0x00,0x17,0x3E,0x01,0x6C,0x21,0xFC,0x00,0x00,0x18,0x4C,0x02,0x00,
-0x23,0xFC,0x78,0x00,0x00,0x00,0xFF,0xFC,0x15,0x48,0x33,0xFC,0x04,0x80,0xFF,0xFC,
-0x10,0x26,0x33,0xFC,0x01,0x10,0xFF,0xFC,0x10,0x2A,0x23,0xFC,0x00,0xD4,0x9F,0x40,
-0xFF,0xFC,0x15,0x40,0x23,0xFC,0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x00,0x23,0xFC,
-0x00,0x00,0x05,0x43,0xFF,0xF9,0x01,0x14,0x23,0xFC,0x00,0x00,0x00,0x00,0xFF,0xF9,
-0x01,0x10,0x23,0xFC,0x00,0x00,0x00,0x08,0xFF,0xF9,0x01,0x24,0x23,0xFC,0x00,0x00,
-0x01,0x01,0xFF,0xF9,0x01,0x28,0x00,0xB9,0x00,0x0F,0x03,0x00,0xFF,0xF9,0x00,0xE8,
-0x23,0xFC,0x00,0x00,0x00,0x01,0xFF,0xF9,0x00,0xD4,0x61,0x00,0x06,0x74,0x33,0xFC,
-0xFF,0xFF,0xFF,0xFC,0x15,0x52,0x42,0x79,0xFF,0xFC,0x15,0x50,0x42,0x79,0xFF,0xFC,
-0x15,0x64,0x2E,0x3A,0x08,0x50,0x42,0xB9,0x00,0x00,0x19,0x54,0x4A,0x87,0x66,0x00,
-0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE6,0x42,0x80,
-0x42,0x86,0x08,0x07,0x00,0x04,0x67,0x00,0x00,0x0A,0x08,0x87,0x00,0x00,0x61,0x00,
-0x02,0xA0,0x08,0x07,0x00,0x00,0x67,0x00,0x00,0x06,0x61,0x00,0x00,0x36,0x08,0x07,
-0x00,0x08,0x67,0x00,0x00,0x06,0x61,0x00,0x02,0xB8,0x08,0x07,0x00,0x0C,0x67,0x00,
-0x00,0x0A,0x61,0x00,0x04,0x94,0x61,0x00,0x03,0x60,0xE2,0x8F,0x58,0x80,0x0C,0x80,
-0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0xBC,0x23,0xC6,0xFF,0xF9,0x00,0xE4,0x60,0x00,
-0xFF,0x92,0x20,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0x4A,0xA8,0x00,0x00,0x66,0x00,
-0x02,0x4E,0x21,0x7C,0x00,0x00,0x00,0x01,0x00,0x00,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x68,0x42,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x42,0xB0,0x09,0xB0,0x00,0x00,0x19,0x88,0x22,0x39,0xFF,0xFC,0x16,0xEC,
-0xC2,0xB0,0x09,0xB0,0x00,0x00,0x18,0xF2,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x18,
-0x66,0x00,0x00,0x0E,0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xE2,0x60,0x00,0x00,0x0A,
-0x82,0xB0,0x09,0xB0,0x00,0x00,0x18,0xD2,0x23,0xC1,0xFF,0xFC,0x16,0xEC,0x00,0x70,
-0x10,0x00,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,0x05,0x76,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x18,0x92,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x72,0x74,0x08,0x26,0x3C,
-0x18,0x00,0x00,0x00,0x0C,0xA8,0x00,0x00,0x00,0x01,0x00,0x10,0x67,0x00,0x00,0x06,
-0x08,0xC3,0x00,0x1A,0x22,0xC3,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,
-0xFF,0xF4,0x08,0xC3,0x00,0x1D,0x22,0xC3,0x22,0xC1,0x74,0x1C,0x22,0xFC,0x90,0x00,
-0x00,0x00,0x22,0xC1,0x06,0x81,0x00,0x00,0x05,0xFC,0x51,0xCA,0xFF,0xF0,0x22,0xFC,
-0xB0,0x00,0x00,0x00,0x22,0xC1,0x22,0x70,0x09,0xB0,0x00,0x00,0x18,0x62,0x24,0x70,
-0x09,0xB0,0x00,0x00,0x18,0x52,0x25,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x10,0x25,0x7C,
-0x00,0x00,0x00,0x00,0x00,0x14,0x22,0x30,0x09,0xB0,0x00,0x00,0x18,0x72,0x33,0x41,
-0x00,0x02,0x06,0x81,0x00,0x00,0x00,0x50,0x33,0x41,0x00,0x00,0x13,0x7C,0x00,0x08,
-0x00,0x04,0x13,0x7C,0x00,0x08,0x00,0x05,0x0C,0xA8,0x00,0x00,0x00,0x05,0x00,0x10,
-0x66,0x00,0x00,0x2A,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xFA,0x00,0x46,0x31,0xBC,
-0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,0x00,0xBC,0x0C,0xA8,0x00,0x00,
-0x00,0x07,0x00,0x10,0x66,0x00,0x00,0x2C,0x35,0x7C,0x08,0x00,0x00,0x08,0x23,0x7C,
-0xDE,0xBB,0x20,0xE3,0x00,0x34,0x23,0x7C,0xFF,0xFF,0xFF,0xFF,0x00,0x38,0x33,0x7C,
-0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x86,0x0C,0xA8,0x00,0x00,0x00,0x04,0x00,0x10,0x66,0x00,0x00,0x26,0x42,0x6A,
-0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,0x42,0xA9,0x00,0x38,0x33,0x7C,
-0x05,0xFA,0x00,0x46,0x31,0xBC,0x00,0x02,0x09,0xB0,0x00,0x00,0x19,0x9C,0x60,0x00,
-0x00,0x56,0x0C,0xA8,0x00,0x00,0x00,0x06,0x00,0x10,0x66,0x00,0x00,0x28,0x35,0x7C,
-0x08,0x00,0x00,0x08,0x23,0x7C,0xDE,0xBB,0x20,0xE3,0x00,0x34,0x42,0xA9,0x00,0x38,
-0x33,0x7C,0x05,0xFC,0x00,0x46,0x31,0xBC,0x00,0x04,0x09,0xB0,0x00,0x00,0x19,0x9C,
-0x60,0x00,0x00,0x24,0x42,0x6A,0x00,0x08,0x23,0x7C,0x00,0x00,0xF0,0xB8,0x00,0x34,
-0x23,0x7C,0x00,0x00,0xFF,0xFF,0x00,0x38,0x33,0x7C,0x05,0xF8,0x00,0x46,0x42,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x25,0x7C,0x00,0x00,0x00,0x03,0x00,0x04,0x0C,0xA8,
-0x00,0x00,0x00,0x02,0x00,0x14,0x66,0x00,0x00,0x0E,0x25,0x7C,0x10,0x04,0x09,0x00,
-0x00,0x00,0x60,0x00,0x00,0x0A,0x25,0x7C,0x10,0x04,0x00,0x00,0x00,0x00,0x33,0x7C,
-0x05,0xFC,0x00,0x06,0x22,0x00,0xE9,0x89,0x00,0x81,0x00,0x00,0x00,0x01,0x33,0xC1,
-0xFF,0xFC,0x15,0xC0,0x08,0x39,0x00,0x00,0xFF,0xFC,0x15,0xC0,0x66,0x00,0xFF,0xF6,
-0x35,0x7C,0x00,0x1F,0x00,0x14,0x00,0xAA,0x00,0x00,0x00,0x30,0x00,0x00,0x4E,0x75,
-0x20,0x70,0x09,0xB0,0x00,0x00,0x18,0x52,0x42,0x68,0x00,0x14,0x02,0xA8,0xFF,0xFF,
-0xFF,0xCF,0x00,0x00,0x02,0x70,0xEF,0xFF,0x09,0xB0,0x00,0x00,0x19,0xAA,0x61,0x00,
-0x03,0x70,0x22,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x42,0xB0,0x19,0x90,0x4E,0x75,
-0x0C,0xB0,0x00,0x00,0x00,0x0A,0x09,0xB0,0x00,0x00,0x19,0x78,0x67,0x00,0x00,0xA8,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x68,0x24,0x01,0x4C,0x3C,0x20,0x00,0x00,0x00,
-0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,
-0x0C,0xB0,0x00,0x00,0x00,0x10,0x29,0x90,0x66,0x00,0x00,0x7C,0x20,0x70,0x29,0xA0,
-0x00,0x04,0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x22,0x70,0x19,0xA0,
-0x00,0x04,0x24,0x30,0x29,0xA0,0x00,0x08,0x31,0x82,0x19,0xA0,0x00,0x02,0x56,0x82,
-0x02,0x82,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,0xFF,0xF9,0x01,0x04,0x23,0xC9,0xFF,0xF9,
-0x01,0x08,0x23,0xC2,0xFF,0xF9,0x01,0x0C,0x23,0xFC,0x00,0x00,0x01,0x03,0xFF,0xF9,
-0x01,0x28,0x61,0x00,0x01,0xF6,0x08,0xF0,0x00,0x1F,0x19,0x90,0x22,0x30,0x09,0xB0,
-0x00,0x00,0x19,0x68,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,
-0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x68,0x52,0xB0,0x09,0xB0,0x00,0x00,
-0x19,0x78,0x60,0x00,0xFF,0x4C,0x4E,0x75,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,
-0xE7,0x89,0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x82,0x34,0x30,0x19,0x90,0x08,0x02,
-0x00,0x0F,0x66,0x00,0x01,0x12,0x08,0x02,0x00,0x01,0x66,0x00,0x00,0xE6,0x4A,0x70,
-0x09,0xB0,0x00,0x00,0x19,0x9C,0x66,0x00,0x00,0x06,0x08,0x82,0x00,0x02,0x02,0x42,
-0x0C,0xBC,0x0C,0x42,0x0C,0x00,0x66,0x00,0x00,0xDC,0x42,0x83,0x36,0x30,0x19,0xA0,
-0x00,0x02,0x96,0x70,0x09,0xB0,0x00,0x00,0x19,0x9C,0x0C,0x43,0x05,0xF8,0x6E,0x00,
-0x00,0xC4,0x24,0x3A,0x04,0x84,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xBA,
-0xFA,0xF4,0x0C,0xB0,0x00,0x00,0x00,0x00,0x29,0x90,0x66,0x00,0x00,0x96,0x21,0x83,
-0x29,0xA0,0x00,0x08,0x20,0x70,0x19,0xA0,0x00,0x04,0x22,0x70,0x29,0xA0,0x00,0x04,
-0x4A,0x89,0x67,0x00,0x00,0x2A,0x56,0x83,0x02,0x83,0xFF,0xFF,0xFF,0xFC,0x23,0xC8,
-0xFF,0xF9,0x01,0x1C,0x23,0xC9,0xFF,0xF9,0x01,0x18,0x23,0xC3,0xFF,0xF9,0x01,0x20,
-0x23,0xFC,0x00,0x00,0x03,0x01,0xFF,0xF9,0x01,0x28,0x61,0x00,0x01,0x2C,0x21,0xB0,
-0x09,0xB0,0x00,0x00,0x18,0xC2,0x29,0x90,0x08,0xC6,0x00,0x04,0x24,0x3A,0x04,0x1A,
-0x52,0x82,0x0C,0x82,0x00,0x00,0x00,0x28,0x66,0x00,0x00,0x04,0x42,0x82,0x23,0xC2,
-0x00,0x00,0x19,0x98,0x02,0x70,0xF0,0x00,0x19,0x90,0x08,0xF0,0x00,0x1F,0x19,0x90,
-0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x88,0x52,0x81,0x0C,0x81,0x00,0x00,0x00,0x1E,
-0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,0x19,0x88,0x60,0x00,
-0xFE,0xF8,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,0x00,0x08,
-0x60,0x00,0xFF,0xC2,0x24,0x30,0x09,0xB0,0x00,0x00,0x10,0x04,0x52,0xB0,0x29,0xA0,
-0x00,0x0C,0x60,0x00,0xFF,0xB0,0x4E,0x75,0x4A,0xB0,0x09,0xB0,0x00,0x00,0x19,0x78,
-0x67,0x00,0x00,0x86,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x24,0x01,0xE7,0x89,
-0xD2,0xB0,0x09,0xB0,0x00,0x00,0x18,0x72,0x36,0x30,0x19,0x90,0x08,0x03,0x00,0x0F,
-0x66,0x00,0x00,0x66,0x8C,0xB0,0x09,0xB0,0x00,0x00,0x18,0xA2,0x53,0xB0,0x09,0xB0,
-0x00,0x00,0x19,0x78,0x22,0x30,0x09,0xB0,0x00,0x00,0x19,0x58,0x52,0x81,0x0C,0x81,
-0x00,0x00,0x00,0x0A,0x66,0x00,0x00,0x04,0x42,0x81,0x21,0x81,0x09,0xB0,0x00,0x00,
-0x19,0x58,0x4C,0x3C,0x20,0x00,0x00,0x00,0x00,0x0C,0xD4,0xB0,0x09,0xB0,0x00,0x00,
-0x10,0x04,0x06,0x82,0x00,0x00,0x00,0x1C,0x08,0x03,0x00,0x01,0x66,0x00,0x00,0x0E,
-0x21,0xBC,0x00,0x00,0x00,0x20,0x29,0x90,0x60,0x00,0xFF,0x7E,0x21,0xBC,0x00,0x00,
-0x00,0x30,0x29,0x90,0x60,0x00,0xFF,0x72,0x4E,0x75,0x2F,0x00,0x40,0xE7,0x20,0x39,
-0xFF,0xF9,0x01,0x28,0x08,0x00,0x00,0x04,0x66,0x00,0x00,0x2C,0x4E,0x72,0x22,0x00,
-0x46,0xFC,0x27,0x00,0x60,0x00,0xFF,0xE8,0x2F,0x00,0x40,0xE7,0x20,0x39,0xFF,0xF9,
-0x01,0x28,0x08,0x00,0x00,0x0C,0x66,0x00,0x00,0x0E,0x4E,0x72,0x22,0x00,0x46,0xFC,
-0x27,0x00,0x60,0x00,0xFF,0xE8,0x46,0xDF,0x20,0x1F,0x4E,0x75,0x2F,0x00,0x20,0x39,
-0xFF,0xF9,0x00,0xE0,0x23,0xC0,0xFF,0xF9,0x00,0xE0,0x81,0xB9,0x00,0x00,0x19,0x54,
-0x23,0xFC,0x00,0x00,0x09,0x09,0xFF,0xF9,0x01,0x28,0x20,0x1F,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x10,0x00,0xB9,0x00,0x00,0x10,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x40,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x30,0x00,0xB9,0x00,0x00,0x20,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x20,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x50,0x00,0xB9,0x00,0x00,0x40,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x10,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x00,0xB9,
-0x00,0x00,0x00,0x00,0xFF,0xFC,0x16,0x70,0x00,0xB9,0x00,0x00,0x80,0x00,0x00,0x00,
-0x19,0x54,0x23,0xFC,0x08,0x00,0x00,0x00,0xFF,0xFC,0x15,0x4C,0x4E,0x73,0x4E,0x73,
-0x2F,0x00,0x2F,0x01,0x2F,0x02,0x2F,0x08,0x2F,0x09,0x42,0x80,0x20,0x7C,0xFF,0xFB,
-0x00,0x00,0x32,0x10,0x02,0x81,0x00,0x00,0x00,0xE7,0x0C,0x41,0x00,0x42,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0E,0x08,0x60,0x00,0x00,0x3E,0x0C,0x41,0x00,0x63,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x04,0x08,0x60,0x00,0x00,0x2E,0x0C,0x41,0x00,0x84,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x02,0x08,0x60,0x00,0x00,0x1E,0x0C,0x41,0x00,0xA5,0x66,0x00,
-0x00,0x0A,0x32,0x3C,0x0D,0x08,0x60,0x00,0x00,0x0E,0x32,0x3C,0x00,0x08,0x34,0x3C,
-0x80,0xE7,0x60,0x00,0x00,0x14,0x34,0x30,0x09,0xB0,0x00,0x00,0x19,0xAA,0x02,0x42,
-0x30,0x00,0x82,0x42,0x34,0x3C,0x80,0xFF,0xB2,0x70,0x09,0xB0,0x00,0x00,0x19,0xAC,
-0x67,0x00,0x00,0x0C,0x31,0x81,0x09,0xB0,0x00,0x00,0x19,0xAC,0x30,0x81,0x32,0x39,
-0xFF,0xFC,0x15,0x66,0xC2,0x70,0x09,0xB0,0x00,0x00,0x19,0x02,0x67,0x00,0x00,0x0C,
-0x32,0x10,0x02,0x41,0xFF,0xF7,0x60,0x00,0x00,0x08,0x32,0x10,0x00,0x41,0x00,0x08,
-0xC2,0x42,0x22,0x70,0x09,0xB0,0x00,0x00,0x10,0x04,0xB2,0xA9,0x00,0x04,0x67,0x00,
-0x00,0x12,0x23,0x41,0x00,0x04,0x23,0xF0,0x09,0xB0,0x00,0x00,0x18,0xB2,0xFF,0xF9,
-0x00,0xE4,0x54,0x88,0x58,0x80,0x0C,0x80,0x00,0x00,0x00,0x10,0x66,0x00,0xFF,0x34,
-0x22,0x5F,0x20,0x5F,0x24,0x1F,0x22,0x1F,0x20,0x1F,0x4E,0x75,0x61,0x00,0xFF,0x12,
-0x4E,0x73,0xFF,0xFC,0x16,0x00,0xFF,0xFC,0x16,0x20,0xFF,0xFC,0x16,0x40,0xFF,0xFC,
-0x16,0x60,0xFF,0xFC,0x0C,0x00,0xFF,0xFC,0x0D,0x00,0xFF,0xFC,0x0E,0x00,0xFF,0xFC,
-0x0F,0x00,0xFF,0xFC,0x00,0x00,0xFF,0xFC,0x01,0x40,0xFF,0xFC,0x02,0x80,0xFF,0xFC,
-0x03,0xC0,0xFF,0xFC,0x00,0x50,0xFF,0xFC,0x01,0x90,0xFF,0xFC,0x02,0xD0,0xFF,0xFC,
-0x04,0x10,0x00,0x00,0x40,0x00,0x00,0x01,0x2F,0x60,0x00,0x02,0x1E,0xC0,0x00,0x03,
-0x0E,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,
-0x00,0x08,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x80,0x00,0x00,
-0x01,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x12,0x00,0x00,
-0x00,0x13,0x00,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,0x00,0x2C,0x00,0x00,0x3E,0x00,
-0x00,0x00,0x00,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,0x00,0x2D,0x00,0x00,0x3F,0x00,
-0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,
-0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x80,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,
-0x77,0x61,0x6E,0x58,0x4C,0x20,0x66,0x69,0x72,0x6D,0x77,0x61,0x72,0x65,0x0A,0x43,
-0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x32,0x30,0x30,
-0x33,0x20,0x4B,0x72,0x7A,0x79,0x73,0x7A,0x74,0x6F,0x66,0x20,0x48,0x61,0x6C,0x61,
-0x73,0x61,0x20,0x3C,0x6B,0x68,0x63,0x40,0x70,0x6D,0x2E,0x77,0x61,0x77,0x2E,0x70,
-0x6C,0x3E,0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-};
+++ /dev/null
-/*======================================================================
-
- Device driver for the PCMCIA control functionality of StrongARM
- SA-1100 microprocessors.
-
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The initial developer of the original code is John G. Dorsey
- <john+@cs.cmu.edu>. Portions created by John G. Dorsey are
- Copyright (C) 1999 John G. Dorsey. All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU Public License version 2 (the "GPL"), in which
- case the provisions of the GPL are applicable instead of the
- above. If you wish to allow the use of your version of this file
- only under the terms of the GPL and not to allow others to use
- your version of this file under the MPL, indicate your decision
- by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
-======================================================================*/
-
-#if !defined(_PCMCIA_SA1100_H)
-# define _PCMCIA_SA1100_H
-
-#include <pcmcia/cs_types.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/bulkmem.h>
-#include <pcmcia/cistpl.h>
-#include "cs_internal.h"
-#include "sa1100_generic.h"
-
-/* MECR: Expansion Memory Configuration Register
- * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24)
- *
- * MECR layout is:
- *
- * FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0>
- *
- * (This layout is actually true only for the SA-1110; the FASTn bits are
- * reserved on the SA-1100.)
- */
-
-#define MECR_SOCKET_0_SHIFT (0)
-#define MECR_SOCKET_1_SHIFT (16)
-
-#define MECR_BS_MASK (0x1f)
-#define MECR_FAST_MODE_MASK (0x01)
-
-#define MECR_BSIO_SHIFT (0)
-#define MECR_BSA_SHIFT (5)
-#define MECR_BSM_SHIFT (10)
-#define MECR_FAST_SHIFT (15)
-
-#define MECR_SET(mecr, sock, shift, mask, bs) \
-((mecr)=((mecr)&~(((mask)<<(shift))<<\
- ((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))|\
- (((bs)<<(shift))<<((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))
-
-#define MECR_GET(mecr, sock, shift, mask) \
-((((mecr)>>(((sock)==0)?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))>>\
- (shift))&(mask))
-
-#define MECR_BSIO_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSIO_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK)
-
-#define MECR_BSA_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSA_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK)
-
-#define MECR_BSM_SET(mecr, sock, bs) \
-MECR_SET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK, (bs))
-
-#define MECR_BSM_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK)
-
-#define MECR_FAST_SET(mecr, sock, fast) \
-MECR_SET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK, (fast))
-
-#define MECR_FAST_GET(mecr, sock) \
-MECR_GET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK)
-
-
-/* This function implements the BS value calculation for setting the MECR
- * using integer arithmetic:
- */
-static inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns,
- unsigned int cpu_clock_khz){
- unsigned int t = ((pcmcia_cycle_ns * cpu_clock_khz) / 6) - 1000000;
- return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1);
-}
-
-/* This function returns the (approxmiate) command assertion period, in
- * nanoseconds, for a given CPU clock frequency and MECR BS value:
- */
-static inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz,
- unsigned int pcmcia_mecr_bs){
- return (((10000000 * 2) / cpu_clock_khz) * (3 * (pcmcia_mecr_bs + 1))) / 10;
-}
-
-
-/* SA-1100 PCMCIA Memory and I/O timing
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * The SA-1110 Developer's Manual, section 10.2.5, says the following:
- *
- * "To calculate the recommended BS_xx value for each address space:
- * divide the command width time (the greater of twIOWR and twIORD,
- * or the greater of twWE and twOE) by processor cycle time; divide
- * by 2; divide again by 3 (number of BCLK's per command assertion);
- * round up to the next whole number; and subtract 1."
- *
- * The PC Card Standard, Release 7, section 4.13.4, says that twIORD
- * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
- * a minimum value of 165ns, as well. Section 4.7.2 (describing
- * common and attribute memory write timing) says that twWE has a
- * minimum value of 150ns for a 250ns cycle time (for 5V operation;
- * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
- * operation, also section 4.7.4). Section 4.7.3 says that taOE
- * has a maximum value of 150ns for a 300ns cycle time (for 5V
- * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
- *
- * When configuring memory maps, Card Services appears to adopt the policy
- * that a memory access time of "0" means "use the default." The default
- * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
- * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
- * memory command width time is 300ns.
- */
-#define SA1100_PCMCIA_IO_ACCESS (165)
-#define SA1100_PCMCIA_5V_MEM_ACCESS (150)
-#define SA1100_PCMCIA_3V_MEM_ACCESS (300)
-
-
-/* The socket driver actually works nicely in interrupt-driven form,
- * so the (relatively infrequent) polling is "just to be sure."
- */
-#define SA1100_PCMCIA_POLL_PERIOD (2*HZ)
-
-struct pcmcia_low_level;
-
-/* I/O pins replacing memory pins
- * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
- *
- * These signals change meaning when going from memory-only to
- * memory-or-I/O interface:
- */
-#define iostschg bvd1
-#define iospkr bvd2
-
-#endif /* !defined(_PCMCIA_SA1100_H) */
+++ /dev/null
-/*======================================================================
-
- Device driver for the PCMCIA control functionality of StrongARM
- SA-1100 microprocessors.
-
- The contents of this file are subject to the Mozilla Public
- License Version 1.1 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of
- the License at http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- implied. See the License for the specific language governing
- rights and limitations under the License.
-
- The initial developer of the original code is John G. Dorsey
- <john+@cs.cmu.edu>. Portions created by John G. Dorsey are
- Copyright (C) 1999 John G. Dorsey. All Rights Reserved.
-
- Alternatively, the contents of this file may be used under the
- terms of the GNU Public License version 2 (the "GPL"), in which
- case the provisions of the GPL are applicable instead of the
- above. If you wish to allow the use of your version of this file
- only under the terms of the GPL and not to allow others to use
- your version of this file under the MPL, indicate your decision
- by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL. If you do not delete
- the provisions above, a recipient may use your version of this
- file under either the MPL or the GPL.
-
-======================================================================*/
-/*
- * Please see linux/Documentation/arm/SA1100/PCMCIA for more information
- * on the low-level kernel interface.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/config.h>
-#include <linux/cpufreq.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/notifier.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-
-#include "sa11xx_core.h"
-#include "sa1100.h"
-
-#ifdef DEBUG
-static int pc_debug;
-
-module_param(pc_debug, int, 0644);
-
-#define debug(skt, lvl, fmt, arg...) do { \
- if (pc_debug > (lvl)) \
- printk(KERN_DEBUG "skt%u: %s: " fmt, \
- (skt)->nr, __func__ , ## arg); \
-} while (0)
-
-#else
-#define debug(skt, lvl, fmt, arg...) do { } while (0)
-#endif
-
-#define to_sa1100_socket(x) container_of(x, struct sa1100_pcmcia_socket, socket)
-
-/*
- * sa1100_pcmcia_default_mecr_timing
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Calculate MECR clock wait states for given CPU clock
- * speed and command wait state. This function can be over-
- * written by a board specific version.
- *
- * The default is to simply calculate the BS values as specified in
- * the INTEL SA1100 development manual
- * "Expansion Memory (PCMCIA) Configuration Register (MECR)"
- * that's section 10.2.5 in _my_ version of the manual ;)
- */
-static unsigned int
-sa1100_pcmcia_default_mecr_timing(struct sa1100_pcmcia_socket *skt,
- unsigned int cpu_speed,
- unsigned int cmd_time)
-{
- return sa1100_pcmcia_mecr_bs(cmd_time, cpu_speed);
-}
-
-static unsigned short
-calc_speed(unsigned short *spds, int num, unsigned short dflt)
-{
- unsigned short speed = 0;
- int i;
-
- for (i = 0; i < num; i++)
- if (speed < spds[i])
- speed = spds[i];
- if (speed == 0)
- speed = dflt;
-
- return speed;
-}
-
-/* sa1100_pcmcia_set_mecr()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * set MECR value for socket <sock> based on this sockets
- * io, mem and attribute space access speed.
- * Call board specific BS value calculation to allow boards
- * to tweak the BS values.
- */
-static int
-sa1100_pcmcia_set_mecr(struct sa1100_pcmcia_socket *skt, unsigned int cpu_clock)
-{
- u32 mecr, old_mecr;
- unsigned long flags;
- unsigned short speed;
- unsigned int bs_io, bs_mem, bs_attr;
-
- speed = calc_speed(skt->spd_io, MAX_IO_WIN, SA1100_PCMCIA_IO_ACCESS);
- bs_io = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
- speed = calc_speed(skt->spd_mem, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS);
- bs_mem = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
- speed = calc_speed(skt->spd_attr, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS);
- bs_attr = skt->ops->socket_get_timing(skt, cpu_clock, speed);
-
- local_irq_save(flags);
-
- old_mecr = mecr = MECR;
- MECR_FAST_SET(mecr, skt->nr, 0);
- MECR_BSIO_SET(mecr, skt->nr, bs_io);
- MECR_BSA_SET(mecr, skt->nr, bs_attr);
- MECR_BSM_SET(mecr, skt->nr, bs_mem);
- if (old_mecr != mecr)
- MECR = mecr;
-
- local_irq_restore(flags);
-
- debug(skt, 2, "FAST %X BSM %X BSA %X BSIO %X\n",
- MECR_FAST_GET(mecr, skt->nr),
- MECR_BSM_GET(mecr, skt->nr), MECR_BSA_GET(mecr, skt->nr),
- MECR_BSIO_GET(mecr, skt->nr));
-
- return 0;
-}
-
-static unsigned int sa1100_pcmcia_skt_state(struct sa1100_pcmcia_socket *skt)
-{
- struct pcmcia_state state;
- unsigned int stat;
-
- memset(&state, 0, sizeof(struct pcmcia_state));
-
- skt->ops->socket_state(skt, &state);
-
- stat = state.detect ? SS_DETECT : 0;
- stat |= state.ready ? SS_READY : 0;
- stat |= state.wrprot ? SS_WRPROT : 0;
- stat |= state.vs_3v ? SS_3VCARD : 0;
- stat |= state.vs_Xv ? SS_XVCARD : 0;
-
- /* The power status of individual sockets is not available
- * explicitly from the hardware, so we just remember the state
- * and regurgitate it upon request:
- */
- stat |= skt->cs_state.Vcc ? SS_POWERON : 0;
-
- if (skt->cs_state.flags & SS_IOCARD)
- stat |= state.bvd1 ? SS_STSCHG : 0;
- else {
- if (state.bvd1 == 0)
- stat |= SS_BATDEAD;
- else if (state.bvd2 == 0)
- stat |= SS_BATWARN;
- }
- return stat;
-}
-
-/*
- * sa1100_pcmcia_config_skt
- * ^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Convert PCMCIA socket state to our socket configure structure.
- */
-static int
-sa1100_pcmcia_config_skt(struct sa1100_pcmcia_socket *skt, socket_state_t *state)
-{
- int ret;
-
- ret = skt->ops->configure_socket(skt, state);
- if (ret == 0) {
- /*
- * This really needs a better solution. The IRQ
- * may or may not be claimed by the driver.
- */
- if (skt->irq_state != 1 && state->io_irq) {
- skt->irq_state = 1;
- set_irq_type(skt->irq, IRQT_FALLING);
- } else if (skt->irq_state == 1 && state->io_irq == 0) {
- skt->irq_state = 0;
- set_irq_type(skt->irq, IRQT_NOEDGE);
- }
-
- skt->cs_state = *state;
- }
-
- if (ret < 0)
- printk(KERN_ERR "sa1100_pcmcia: unable to configure "
- "socket %d\n", skt->nr);
-
- return ret;
-}
-
-/* sa1100_pcmcia_sock_init()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^
- *
- * (Re-)Initialise the socket, turning on status interrupts
- * and PCMCIA bus. This must wait for power to stabilise
- * so that the card status signals report correctly.
- *
- * Returns: 0
- */
-static int sa1100_pcmcia_sock_init(struct pcmcia_socket *sock)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
- debug(skt, 2, "initializing socket\n");
-
- skt->ops->socket_init(skt);
- return 0;
-}
-
-
-/*
- * sa1100_pcmcia_suspend()
- * ^^^^^^^^^^^^^^^^^^^^^^^
- *
- * Remove power on the socket, disable IRQs from the card.
- * Turn off status interrupts, and disable the PCMCIA bus.
- *
- * Returns: 0
- */
-static int sa1100_pcmcia_suspend(struct pcmcia_socket *sock)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
- int ret;
-
- debug(skt, 2, "suspending socket\n");
-
- ret = sa1100_pcmcia_config_skt(skt, &dead_socket);
- if (ret == 0)
- skt->ops->socket_suspend(skt);
-
- return ret;
-}
-
-static spinlock_t status_lock = SPIN_LOCK_UNLOCKED;
-
-/* sa1100_check_status()
- * ^^^^^^^^^^^^^^^^^^^^^
- */
-static void sa1100_check_status(struct sa1100_pcmcia_socket *skt)
-{
- unsigned int events;
-
- debug(skt, 4, "entering PCMCIA monitoring thread\n");
-
- do {
- unsigned int status;
- unsigned long flags;
-
- status = sa1100_pcmcia_skt_state(skt);
-
- spin_lock_irqsave(&status_lock, flags);
- events = (status ^ skt->status) & skt->cs_state.csc_mask;
- skt->status = status;
- spin_unlock_irqrestore(&status_lock, flags);
-
- debug(skt, 4, "events: %s%s%s%s%s%s\n",
- events == 0 ? "<NONE>" : "",
- events & SS_DETECT ? "DETECT " : "",
- events & SS_READY ? "READY " : "",
- events & SS_BATDEAD ? "BATDEAD " : "",
- events & SS_BATWARN ? "BATWARN " : "",
- events & SS_STSCHG ? "STSCHG " : "");
-
- if (events)
- pcmcia_parse_events(&skt->socket, events);
- } while (events);
-}
-
-/* sa1100_pcmcia_poll_event()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Let's poll for events in addition to IRQs since IRQ only is unreliable...
- */
-static void sa1100_pcmcia_poll_event(unsigned long dummy)
-{
- struct sa1100_pcmcia_socket *skt = (struct sa1100_pcmcia_socket *)dummy;
- debug(skt, 4, "polling for events\n");
-
- mod_timer(&skt->poll_timer, jiffies + SA1100_PCMCIA_POLL_PERIOD);
-
- sa1100_check_status(skt);
-}
-
-
-/* sa1100_pcmcia_interrupt()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^
- * Service routine for socket driver interrupts (requested by the
- * low-level PCMCIA init() operation via sa1100_pcmcia_thread()).
- * The actual interrupt-servicing work is performed by
- * sa1100_pcmcia_thread(), largely because the Card Services event-
- * handling code performs scheduling operations which cannot be
- * executed from within an interrupt context.
- */
-static irqreturn_t sa1100_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
-{
- struct sa1100_pcmcia_socket *skt = dev;
-
- debug(skt, 3, "servicing IRQ %d\n", irq);
-
- sa1100_check_status(skt);
-
- return IRQ_HANDLED;
-}
-
-
-/* sa1100_pcmcia_get_status()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the get_status() operation for the in-kernel PCMCIA
- * service (formerly SS_GetStatus in Card Services). Essentially just
- * fills in bits in `status' according to internal driver state or
- * the value of the voltage detect chipselect register.
- *
- * As a debugging note, during card startup, the PCMCIA core issues
- * three set_socket() commands in a row the first with RESET deasserted,
- * the second with RESET asserted, and the last with RESET deasserted
- * again. Following the third set_socket(), a get_status() command will
- * be issued. The kernel is looking for the SS_READY flag (see
- * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
- skt->status = sa1100_pcmcia_skt_state(skt);
- *status = skt->status;
-
- return 0;
-}
-
-
-/* sa1100_pcmcia_get_socket()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the get_socket() operation for the in-kernel PCMCIA
- * service (formerly SS_GetSocket in Card Services). Not a very
- * exciting routine.
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
- debug(skt, 2, "\n");
-
- *state = skt->cs_state;
-
- return 0;
-}
-
-/* sa1100_pcmcia_set_socket()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_socket() operation for the in-kernel PCMCIA
- * service (formerly SS_SetSocket in Card Services). We more or
- * less punt all of this work and let the kernel handle the details
- * of power configuration, reset, &c. We also record the value of
- * `state' in order to regurgitate it to the PCMCIA core later.
- *
- * Returns: 0
- */
-static int
-sa1100_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
-
- debug(skt, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
- (state->csc_mask==0)?"<NONE> ":"",
- (state->csc_mask&SS_DETECT)?"DETECT ":"",
- (state->csc_mask&SS_READY)?"READY ":"",
- (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
- (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
- (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
- (state->flags==0)?"<NONE> ":"",
- (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
- (state->flags&SS_IOCARD)?"IOCARD ":"",
- (state->flags&SS_RESET)?"RESET ":"",
- (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
- (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
- state->Vcc, state->Vpp, state->io_irq);
-
- return sa1100_pcmcia_config_skt(skt, state);
-} /* sa1100_pcmcia_set_socket() */
-
-
-/* sa1100_pcmcia_set_io_map()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_io_map() operation for the in-kernel PCMCIA
- * service (formerly SS_SetIOMap in Card Services). We configure
- * the map speed as requested, but override the address ranges
- * supplied by Card Services.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
- unsigned short speed = map->speed;
-
- debug(skt, 2, "map %u speed %u start 0x%08x stop 0x%08x\n",
- map->map, map->speed, map->start, map->stop);
- debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
- (map->flags==0)?"<NONE>":"",
- (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
- (map->flags&MAP_16BIT)?"16BIT ":"",
- (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
- (map->flags&MAP_0WS)?"0WS ":"",
- (map->flags&MAP_WRPROT)?"WRPROT ":"",
- (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"",
- (map->flags&MAP_PREFETCH)?"PREFETCH ":"");
-
- if (map->map >= MAX_IO_WIN) {
- printk(KERN_ERR "%s(): map (%d) out of range\n", __FUNCTION__,
- map->map);
- return -1;
- }
-
- if (map->flags & MAP_ACTIVE) {
- if (speed == 0)
- speed = SA1100_PCMCIA_IO_ACCESS;
- } else {
- speed = 0;
- }
-
- skt->spd_io[map->map] = speed;
- sa1100_pcmcia_set_mecr(skt, cpufreq_get(0));
-
- if (map->stop == 1)
- map->stop = PAGE_SIZE-1;
-
- map->stop -= map->start;
- map->stop += (unsigned long)skt->virt_io;
- map->start = (unsigned long)skt->virt_io;
-
- return 0;
-} /* sa1100_pcmcia_set_io_map() */
-
-
-/* sa1100_pcmcia_set_mem_map()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the set_mem_map() operation for the in-kernel PCMCIA
- * service (formerly SS_SetMemMap in Card Services). We configure
- * the map speed as requested, but override the address ranges
- * supplied by Card Services.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
-{
- struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
- struct resource *res;
- unsigned short speed = map->speed;
-
- debug(skt, 2, "map %u speed %u card_start %08x\n",
- map->map, map->speed, map->card_start);
- debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
- (map->flags==0)?"<NONE>":"",
- (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
- (map->flags&MAP_16BIT)?"16BIT ":"",
- (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
- (map->flags&MAP_0WS)?"0WS ":"",
- (map->flags&MAP_WRPROT)?"WRPROT ":"",
- (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
- (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
-
- if (map->map >= MAX_WIN)
- return -EINVAL;
-
- if (map->flags & MAP_ACTIVE) {
- if (speed == 0)
- speed = 300;
- } else {
- speed = 0;
- }
-
- if (map->flags & MAP_ATTRIB) {
- res = &skt->res_attr;
- skt->spd_attr[map->map] = speed;
- skt->spd_mem[map->map] = 0;
- } else {
- res = &skt->res_mem;
- skt->spd_attr[map->map] = 0;
- skt->spd_mem[map->map] = speed;
- }
-
- sa1100_pcmcia_set_mecr(skt, cpufreq_get(0));
-
- map->sys_stop -= map->sys_start;
- map->sys_stop += res->start + map->card_start;
- map->sys_start = res->start + map->card_start;
-
- return 0;
-}
-
-struct bittbl {
- unsigned int mask;
- const char *name;
-};
-
-static struct bittbl status_bits[] = {
- { SS_WRPROT, "SS_WRPROT" },
- { SS_BATDEAD, "SS_BATDEAD" },
- { SS_BATWARN, "SS_BATWARN" },
- { SS_READY, "SS_READY" },
- { SS_DETECT, "SS_DETECT" },
- { SS_POWERON, "SS_POWERON" },
- { SS_STSCHG, "SS_STSCHG" },
- { SS_3VCARD, "SS_3VCARD" },
- { SS_XVCARD, "SS_XVCARD" },
-};
-
-static struct bittbl conf_bits[] = {
- { SS_PWR_AUTO, "SS_PWR_AUTO" },
- { SS_IOCARD, "SS_IOCARD" },
- { SS_RESET, "SS_RESET" },
- { SS_DMA_MODE, "SS_DMA_MODE" },
- { SS_SPKR_ENA, "SS_SPKR_ENA" },
- { SS_OUTPUT_ENA, "SS_OUTPUT_ENA" },
-};
-
-static void
-dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, int sz)
-{
- char *b = *p;
- int i;
-
- b += sprintf(b, "%-9s:", prefix);
- for (i = 0; i < sz; i++)
- if (val & bits[i].mask)
- b += sprintf(b, " %s", bits[i].name);
- *b++ = '\n';
- *p = b;
-}
-
-/* show_status()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * Implements the /sys/class/pcmcia_socket/??/status file.
- *
- * Returns: the number of characters added to the buffer
- */
-static ssize_t show_status(struct class_device *class_dev, char *buf)
-{
- struct sa1100_pcmcia_socket *skt = container_of(class_dev,
- struct sa1100_pcmcia_socket, socket.dev);
- unsigned int clock = cpufreq_get(0);
- unsigned long mecr = MECR;
- char *p = buf;
-
- p+=sprintf(p, "slot : %d\n", skt->nr);
-
- dump_bits(&p, "status", skt->status,
- status_bits, ARRAY_SIZE(status_bits));
- dump_bits(&p, "csc_mask", skt->cs_state.csc_mask,
- status_bits, ARRAY_SIZE(status_bits));
- dump_bits(&p, "cs_flags", skt->cs_state.flags,
- conf_bits, ARRAY_SIZE(conf_bits));
-
- p+=sprintf(p, "Vcc : %d\n", skt->cs_state.Vcc);
- p+=sprintf(p, "Vpp : %d\n", skt->cs_state.Vpp);
- p+=sprintf(p, "IRQ : %d (%d)\n", skt->cs_state.io_irq, skt->irq);
-
- p+=sprintf(p, "I/O : %u (%u)\n",
- calc_speed(skt->spd_io, MAX_IO_WIN, SA1100_PCMCIA_IO_ACCESS),
- sa1100_pcmcia_cmd_time(clock, MECR_BSIO_GET(mecr, skt->nr)));
-
- p+=sprintf(p, "attribute: %u (%u)\n",
- calc_speed(skt->spd_attr, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS),
- sa1100_pcmcia_cmd_time(clock, MECR_BSA_GET(mecr, skt->nr)));
-
- p+=sprintf(p, "common : %u (%u)\n",
- calc_speed(skt->spd_mem, MAX_WIN, SA1100_PCMCIA_3V_MEM_ACCESS),
- sa1100_pcmcia_cmd_time(clock, MECR_BSM_GET(mecr, skt->nr)));
-
- return p-buf;
-}
-static CLASS_DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
-
-
-static struct pccard_operations sa11xx_pcmcia_operations = {
- .init = sa1100_pcmcia_sock_init,
- .suspend = sa1100_pcmcia_suspend,
- .get_status = sa1100_pcmcia_get_status,
- .get_socket = sa1100_pcmcia_get_socket,
- .set_socket = sa1100_pcmcia_set_socket,
- .set_io_map = sa1100_pcmcia_set_io_map,
- .set_mem_map = sa1100_pcmcia_set_mem_map,
-};
-
-int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
- int i, res = 0;
-
- for (i = 0; i < nr; i++) {
- if (irqs[i].sock != skt->nr)
- continue;
- res = request_irq(irqs[i].irq, sa1100_pcmcia_interrupt,
- SA_INTERRUPT, irqs[i].str, skt);
- if (res)
- break;
- set_irq_type(irqs[i].irq, IRQT_NOEDGE);
- }
-
- if (res) {
- printk(KERN_ERR "PCMCIA: request for IRQ%d failed (%d)\n",
- irqs[i].irq, res);
-
- while (i--)
- if (irqs[i].sock == skt->nr)
- free_irq(irqs[i].irq, skt);
- }
- return res;
-}
-EXPORT_SYMBOL(sa11xx_request_irqs);
-
-void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
- int i;
-
- for (i = 0; i < nr; i++)
- if (irqs[i].sock == skt->nr)
- free_irq(irqs[i].irq, skt);
-}
-EXPORT_SYMBOL(sa11xx_free_irqs);
-
-void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
- int i;
-
- for (i = 0; i < nr; i++)
- if (irqs[i].sock == skt->nr)
- set_irq_type(irqs[i].irq, IRQT_NOEDGE);
-}
-EXPORT_SYMBOL(sa11xx_disable_irqs);
-
-void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr)
-{
- int i;
-
- for (i = 0; i < nr; i++)
- if (irqs[i].sock == skt->nr) {
- set_irq_type(irqs[i].irq, IRQT_RISING);
- set_irq_type(irqs[i].irq, IRQT_BOTHEDGE);
- }
-}
-EXPORT_SYMBOL(sa11xx_enable_irqs);
-
-static LIST_HEAD(sa1100_sockets);
-static DECLARE_MUTEX(sa1100_sockets_lock);
-
-static const char *skt_names[] = {
- "PCMCIA socket 0",
- "PCMCIA socket 1",
-};
-
-struct skt_dev_info {
- int nskt;
- struct sa1100_pcmcia_socket skt[0];
-};
-
-#define SKT_DEV_INFO_SIZE(n) \
- (sizeof(struct skt_dev_info) + (n)*sizeof(struct sa1100_pcmcia_socket))
-
-int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
-{
- struct skt_dev_info *sinfo;
- unsigned int cpu_clock;
- int ret, i;
-
- /*
- * set default MECR calculation if the board specific
- * code did not specify one...
- */
- if (!ops->socket_get_timing)
- ops->socket_get_timing = sa1100_pcmcia_default_mecr_timing;
-
- down(&sa1100_sockets_lock);
-
- sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
- if (!sinfo) {
- ret = -ENOMEM;
- goto out;
- }
-
- memset(sinfo, 0, SKT_DEV_INFO_SIZE(nr));
- sinfo->nskt = nr;
-
- cpu_clock = cpufreq_get(0);
-
- /*
- * Initialise the per-socket structure.
- */
- for (i = 0; i < nr; i++) {
- struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
- skt->socket.ops = &sa11xx_pcmcia_operations;
- skt->socket.owner = ops->owner;
- skt->socket.dev.dev = dev;
-
- init_timer(&skt->poll_timer);
- skt->poll_timer.function = sa1100_pcmcia_poll_event;
- skt->poll_timer.data = (unsigned long)skt;
- skt->poll_timer.expires = jiffies + SA1100_PCMCIA_POLL_PERIOD;
-
- skt->nr = first + i;
- skt->irq = NO_IRQ;
- skt->dev = dev;
- skt->ops = ops;
-
- skt->res_skt.start = _PCMCIA(skt->nr);
- skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
- skt->res_skt.name = skt_names[skt->nr];
- skt->res_skt.flags = IORESOURCE_MEM;
-
- ret = request_resource(&iomem_resource, &skt->res_skt);
- if (ret)
- goto out_err_1;
-
- skt->res_io.start = _PCMCIAIO(skt->nr);
- skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
- skt->res_io.name = "io";
- skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-
- ret = request_resource(&skt->res_skt, &skt->res_io);
- if (ret)
- goto out_err_2;
-
- skt->res_mem.start = _PCMCIAMem(skt->nr);
- skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
- skt->res_mem.name = "memory";
- skt->res_mem.flags = IORESOURCE_MEM;
-
- ret = request_resource(&skt->res_skt, &skt->res_mem);
- if (ret)
- goto out_err_3;
-
- skt->res_attr.start = _PCMCIAAttr(skt->nr);
- skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
- skt->res_attr.name = "attribute";
- skt->res_attr.flags = IORESOURCE_MEM;
-
- ret = request_resource(&skt->res_skt, &skt->res_attr);
- if (ret)
- goto out_err_4;
-
- skt->virt_io = ioremap(skt->res_io.start, 0x10000);
- if (skt->virt_io == NULL) {
- ret = -ENOMEM;
- goto out_err_5;
- }
-
- list_add(&skt->node, &sa1100_sockets);
-
- /*
- * We initialize the MECR to default values here, because
- * we are not guaranteed to see a SetIOMap operation at
- * runtime.
- */
- sa1100_pcmcia_set_mecr(skt, cpu_clock);
-
- ret = ops->hw_init(skt);
- if (ret)
- goto out_err_6;
-
- skt->socket.features = SS_CAP_STATIC_MAP|SS_CAP_PCCARD;
- skt->socket.irq_mask = 0;
- skt->socket.map_size = PAGE_SIZE;
- skt->socket.pci_irq = skt->irq;
- skt->socket.io_offset = (unsigned long)skt->virt_io;
-
- skt->status = sa1100_pcmcia_skt_state(skt);
-
- ret = pcmcia_register_socket(&skt->socket);
- if (ret)
- goto out_err_7;
-
- WARN_ON(skt->socket.sock != i);
-
- add_timer(&skt->poll_timer);
-
- class_device_create_file(&skt->socket.dev, &class_device_attr_status);
- }
-
- dev_set_drvdata(dev, sinfo);
- ret = 0;
- goto out;
-
- do {
- struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
- del_timer_sync(&skt->poll_timer);
- pcmcia_unregister_socket(&skt->socket);
-
- out_err_7:
- flush_scheduled_work();
-
- ops->hw_shutdown(skt);
- out_err_6:
- list_del(&skt->node);
- iounmap(skt->virt_io);
- out_err_5:
- release_resource(&skt->res_attr);
- out_err_4:
- release_resource(&skt->res_mem);
- out_err_3:
- release_resource(&skt->res_io);
- out_err_2:
- release_resource(&skt->res_skt);
- out_err_1:
- i--;
- } while (i > 0);
-
- kfree(sinfo);
-
- out:
- up(&sa1100_sockets_lock);
- return ret;
-}
-EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe);
-
-int sa11xx_drv_pcmcia_remove(struct device *dev)
-{
- struct skt_dev_info *sinfo = dev_get_drvdata(dev);
- int i;
-
- dev_set_drvdata(dev, NULL);
-
- down(&sa1100_sockets_lock);
- for (i = 0; i < sinfo->nskt; i++) {
- struct sa1100_pcmcia_socket *skt = &sinfo->skt[i];
-
- del_timer_sync(&skt->poll_timer);
-
- pcmcia_unregister_socket(&skt->socket);
-
- flush_scheduled_work();
-
- skt->ops->hw_shutdown(skt);
-
- sa1100_pcmcia_config_skt(skt, &dead_socket);
-
- list_del(&skt->node);
- iounmap(skt->virt_io);
- skt->virt_io = NULL;
- release_resource(&skt->res_attr);
- release_resource(&skt->res_mem);
- release_resource(&skt->res_io);
- release_resource(&skt->res_skt);
- }
- up(&sa1100_sockets_lock);
-
- kfree(sinfo);
-
- return 0;
-}
-EXPORT_SYMBOL(sa11xx_drv_pcmcia_remove);
-
-#ifdef CONFIG_CPU_FREQ
-
-/* sa1100_pcmcia_update_mecr()
- * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
- * When sa1100_pcmcia_notifier() decides that a MECR adjustment (due
- * to a core clock frequency change) is needed, this routine establishes
- * new BS_xx values consistent with the clock speed `clock'.
- */
-static void sa1100_pcmcia_update_mecr(unsigned int clock)
-{
- struct sa1100_pcmcia_socket *skt;
-
- down(&sa1100_sockets_lock);
- list_for_each_entry(skt, &sa1100_sockets, node)
- sa1100_pcmcia_set_mecr(skt, clock);
- up(&sa1100_sockets_lock);
-}
-
-/* sa1100_pcmcia_notifier()
- * ^^^^^^^^^^^^^^^^^^^^^^^^
- * When changing the processor core clock frequency, it is necessary
- * to adjust the MECR timings accordingly. We've recorded the timings
- * requested by Card Services, so this is just a matter of finding
- * out what our current speed is, and then recomputing the new MECR
- * values.
- *
- * Returns: 0 on success, -1 on error
- */
-static int
-sa1100_pcmcia_notifier(struct notifier_block *nb, unsigned long val,
- void *data)
-{
- struct cpufreq_freqs *freqs = data;
-
- switch (val) {
- case CPUFREQ_PRECHANGE:
- if (freqs->new > freqs->old)
- sa1100_pcmcia_update_mecr(freqs->new);
- break;
-
- case CPUFREQ_POSTCHANGE:
- if (freqs->new < freqs->old)
- sa1100_pcmcia_update_mecr(freqs->new);
- break;
- }
-
- return 0;
-}
-
-static struct notifier_block sa1100_pcmcia_notifier_block = {
- .notifier_call = sa1100_pcmcia_notifier
-};
-
-static int __init sa11xx_pcmcia_init(void)
-{
- int ret;
-
- printk(KERN_INFO "SA11xx PCMCIA\n");
-
- ret = cpufreq_register_notifier(&sa1100_pcmcia_notifier_block,
- CPUFREQ_TRANSITION_NOTIFIER);
- if (ret < 0)
- printk(KERN_ERR "Unable to register CPU frequency change "
- "notifier (%d)\n", ret);
-
- return ret;
-}
-module_init(sa11xx_pcmcia_init);
-
-static void __exit sa11xx_pcmcia_exit(void)
-{
- cpufreq_unregister_notifier(&sa1100_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
-}
-
-module_exit(sa11xx_pcmcia_exit);
-#endif
-
-MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
-MODULE_DESCRIPTION("Linux PCMCIA Card Services: SA-11xx core socket driver");
-MODULE_LICENSE("Dual MPL/GPL");
+++ /dev/null
-/*
- * linux/include/asm/arch/pcmcia.h
- *
- * Copyright (C) 2000 John G Dorsey <john+@cs.cmu.edu>
- *
- * This file contains definitions for the low-level SA-1100 kernel PCMCIA
- * interface. Please see linux/Documentation/arm/SA1100/PCMCIA for details.
- */
-#ifndef _ASM_ARCH_PCMCIA
-#define _ASM_ARCH_PCMCIA
-
-/* include the world */
-#include <pcmcia/version.h>
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/bulkmem.h>
-#include <pcmcia/cistpl.h>
-#include "cs_internal.h"
-
-struct device;
-
-/* Ideally, we'd support up to MAX_SOCK sockets, but the SA-1100 only
- * has support for two. This shows up in lots of hardwired ways, such
- * as the fact that MECR only has enough bits to configure two sockets.
- * Since it's so entrenched in the hardware, limiting the software
- * in this way doesn't seem too terrible.
- */
-#define SA1100_PCMCIA_MAX_SOCK (2)
-
-struct pcmcia_state {
- unsigned detect: 1,
- ready: 1,
- bvd1: 1,
- bvd2: 1,
- wrprot: 1,
- vs_3v: 1,
- vs_Xv: 1;
-};
-
-/*
- * This structure encapsulates per-socket state which we might need to
- * use when responding to a Card Services query of some kind.
- */
-struct sa1100_pcmcia_socket {
- struct pcmcia_socket socket;
-
- /*
- * Info from low level handler
- */
- struct device *dev;
- unsigned int nr;
- unsigned int irq;
-
- /*
- * Core PCMCIA state
- */
- struct pcmcia_low_level *ops;
-
- unsigned int status;
- socket_state_t cs_state;
-
- unsigned short spd_io[MAX_IO_WIN];
- unsigned short spd_mem[MAX_WIN];
- unsigned short spd_attr[MAX_WIN];
-
- struct resource res_skt;
- struct resource res_io;
- struct resource res_mem;
- struct resource res_attr;
- void *virt_io;
-
- unsigned int irq_state;
-
- struct timer_list poll_timer;
- struct list_head node;
-};
-
-struct pcmcia_low_level {
- struct module *owner;
-
- int (*hw_init)(struct sa1100_pcmcia_socket *);
- void (*hw_shutdown)(struct sa1100_pcmcia_socket *);
-
- void (*socket_state)(struct sa1100_pcmcia_socket *, struct pcmcia_state *);
- int (*configure_socket)(struct sa1100_pcmcia_socket *, const socket_state_t *);
-
- /*
- * Enable card status IRQs on (re-)initialisation. This can
- * be called at initialisation, power management event, or
- * pcmcia event.
- */
- void (*socket_init)(struct sa1100_pcmcia_socket *);
-
- /*
- * Disable card status IRQs and PCMCIA bus on suspend.
- */
- void (*socket_suspend)(struct sa1100_pcmcia_socket *);
-
- /*
- * Calculate MECR timing clock wait states
- */
- unsigned int (*socket_get_timing)(struct sa1100_pcmcia_socket *,
- unsigned int cpu_speed, unsigned int cmd_time);
-};
-
-struct pcmcia_irqs {
- int sock;
- int irq;
- const char *str;
-};
-
-int sa11xx_request_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_free_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_disable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-void sa11xx_enable_irqs(struct sa1100_pcmcia_socket *skt, struct pcmcia_irqs *irqs, int nr);
-
-extern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr);
-extern int sa11xx_drv_pcmcia_remove(struct device *dev);
-
-#endif
+++ /dev/null
-/*
- * drivers/s390/cio/requestirq.c
- * S/390 common I/O routines -- enabling and disabling of devices
- * $Revision: 1.46 $
- *
- * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
- * IBM Corporation
- * Author(s): Ingo Adlung (adlung@de.ibm.com)
- * Cornelia Huck (cohuck@de.ibm.com)
- * Arnd Bergmann (arndb@de.ibm.com)
- */
-
-#include <linux/module.h>
-#include <linux/config.h>
-#include <linux/device.h>
-#include <linux/init.h>
-#include <asm/lowcore.h>
-
-#include "css.h"
-
-struct pgid global_pgid;
-EXPORT_SYMBOL_GPL(global_pgid);
-
-/*
- * init_IRQ is now only used to set the pgid as early as possible
- */
-void __init
-init_IRQ(void)
-{
- /*
- * Let's build our path group ID here.
- */
- if (MACHINE_NEW_STIDP)
- global_pgid.cpu_addr = 0x8000;
- else {
-#ifdef CONFIG_SMP
- global_pgid.cpu_addr = hard_smp_processor_id();
-#else
- global_pgid.cpu_addr = 0;
-#endif
- }
- global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident;
- global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine;
- global_pgid.tod_high = (__u32) (get_clock() >> 32);
-}
+++ /dev/null
-/***********************************************************************
- * FILE NAME : DC390.H *
- * BY : C.L. Huang *
- * Description: Device Driver for Tekram DC-390(T) PCI SCSI *
- * Bus Master Host Adapter *
- ***********************************************************************/
-/* $Id: dc390.h,v 2.43.2.22 2000/12/20 00:39:36 garloff Exp $ */
-
-/*
- * DC390/AMD 53C974 driver, header file
- */
-
-#ifndef DC390_H
-#define DC390_H
-
-#include <linux/version.h>
-
-#define DC390_BANNER "Tekram DC390/AM53C974"
-#define DC390_VERSION "2.1d 2004-05-27"
-
-/* We don't have eh_abort_handler, eh_device_reset_handler,
- * eh_bus_reset_handler, eh_host_reset_handler yet!
- * So long: Use old exception handling :-( */
-#define OLD_EH
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION (2,1,70) || defined (OLD_EH)
-# define NEW_EH
-#else
-# define NEW_EH use_new_eh_code: 1,
-# define USE_NEW_EH
-#endif
-#endif /* DC390_H */
+++ /dev/null
-/*
- *
- * drivers/scsi/pc980155.c
- *
- * PC-9801-55 SCSI host adapter driver
- *
- * Copyright (C) 1997-2003 Kyoto University Microcomputer Club
- * (Linux/98 project)
- * Tomoharu Ugawa <ohirune@kmc.gr.jp>
- *
- */
-
-#include <linux/module.h>
-#include <linux/blkdev.h>
-#include <linux/ioport.h>
-#include <linux/interrupt.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-
-#include <asm/dma.h>
-
-#include "scsi.h"
-#include "hosts.h"
-#include "wd33c93.h"
-#include "pc980155.h"
-
-extern int pc98_bios_param(struct scsi_device *, struct block_device *,
- sector_t, int *);
-static int scsi_pc980155_detect(Scsi_Host_Template *);
-static int scsi_pc980155_release(struct Scsi_Host *);
-
-#ifndef CMD_PER_LUN
-#define CMD_PER_LUN 2
-#endif
-
-#ifndef CAN_QUEUE
-#define CAN_QUEUE 16
-#endif
-
-#undef PC_9801_55_DEBUG
-#undef PC_9801_55_DEBUG_VERBOSE
-
-#define NR_BASE_IOS 4
-static int nr_base_ios = NR_BASE_IOS;
-static unsigned int base_ios[NR_BASE_IOS] = {0xcc0, 0xcd0, 0xce0, 0xcf0};
-static wd33c93_regs init_regs;
-static int io;
-
-static struct Scsi_Host *pc980155_host = NULL;
-
-static void pc980155_intr_handle(int irq, void *dev_id, struct pt_regs *regp);
-
-static inline void pc980155_dma_enable(unsigned int base_io)
-{
- outb(0x01, REG_CWRITE);
-}
-
-static inline void pc980155_dma_disable(unsigned int base_io)
-{
- outb(0x02, REG_CWRITE);
-}
-
-
-static void pc980155_intr_handle(int irq, void *dev_id, struct pt_regs *regp)
-{
- wd33c93_intr(pc980155_host);
-}
-
-static int dma_setup(Scsi_Cmnd *sc, int dir_in)
-{
- /*
- * sc->SCp.this_residual : transfer count
- * sc->SCp.ptr : distination address (virtual address)
- * dir_in : data direction (DATA_OUT_DIR:0 or DATA_IN_DIR:1)
- *
- * if success return 0
- */
-
- /*
- * DMA WRITE MODE
- * bit 7,6 01b single mode (this mode only)
- * bit 5 inc/dec (default:0 = inc)
- * bit 4 auto initialize (normaly:0 = off)
- * bit 3,2 01b memory -> io
- * 10b io -> memory
- * 00b verify
- * bit 1,0 channel
- */
- disable_dma(sc->device->host->dma_channel);
- set_dma_mode(sc->device->host->dma_channel,
- 0x40 | (dir_in ? 0x04 : 0x08));
- clear_dma_ff(sc->device->host->dma_channel);
- set_dma_addr(sc->device->host->dma_channel, virt_to_phys(sc->SCp.ptr));
- set_dma_count(sc->device->host->dma_channel, sc->SCp.this_residual);
-#ifdef PC_9801_55_DEBUG
- printk("D%d(%x)D", sc->device->host->dma_channel,
- sc->SCp.this_residual);
-#endif
- enable_dma(sc->device->host->dma_channel);
- pc980155_dma_enable(sc->device->host->io_port);
- return 0;
-}
-
-static void dma_stop(struct Scsi_Host *instance, Scsi_Cmnd *sc, int status)
-{
- /*
- * instance: Hostadapter's instance
- * sc: scsi command
- * status: True if success
- */
- pc980155_dma_disable(sc->device->host->io_port);
- disable_dma(sc->device->host->dma_channel);
-}
-
-/* return non-zero on detection */
-static inline int pc980155_test_port(wd33c93_regs regs)
-{
- /* Quick and dirty test for presence of the card. */
- if (inb(regs.SASR) == 0xff)
- return 0;
-
- return 1;
-}
-
-static inline int pc980155_getconfig(unsigned int base_io, wd33c93_regs regs,
- unsigned char* irq, unsigned char* dma,
- unsigned char* scsi_id)
-{
- static unsigned char irqs[] = {3, 5, 6, 9, 12, 13};
- unsigned char result;
-
- printk(KERN_DEBUG "PC-9801-55: base_io=%x SASR=%x SCMD=%x\n",
- base_io, regs.SASR, regs.SCMD);
- result = read_pc980155_resetint(regs);
- printk(KERN_DEBUG "PC-9801-55: getting config (%x)\n", result);
- *scsi_id = result & 0x07;
- *irq = (result >> 3) & 0x07;
- if (*irq > 5) {
- printk(KERN_ERR "PC-9801-55 (base %#x): impossible IRQ (%d)"
- " - other device here?\n", base_io, *irq);
- return 0;
- }
-
- *irq = irqs[*irq];
- result = inb(REG_STATRD);
- *dma = result & 0x03;
- if (*dma == 1) {
- printk(KERN_ERR
- "PC-9801-55 (base %#x): impossible DMA channl (%d)"
- " - other device here?\n", base_io, *dma);
- return 0;
- }
-#ifdef PC_9801_55_DEBUG
- printk("PC-9801-55: end of getconfig\n");
-#endif
- return 1;
-}
-
-/* return non-zero on detection */
-static int scsi_pc980155_detect(Scsi_Host_Template* tpnt)
-{
- unsigned int base_io;
- unsigned char irq, dma, scsi_id;
- int i;
-#ifdef PC_9801_55_DEBUG
- unsigned char debug;
-#endif
-
- if (io) {
- base_ios[0] = io;
- nr_base_ios = 1;
- }
-
- for (i = 0; i < nr_base_ios; i++) {
- base_io = base_ios[i];
- init_regs.SASR = REG_ADDRST;
- init_regs.SCMD = REG_CONTRL;
-#ifdef PC_9801_55_DEBUG
- printk("PC-9801-55: SASR(%x = %x)\n", SASR, REG_ADDRST);
-#endif
- if (!request_region(base_io, 6, "PC-9801-55"))
- continue;
-
- if (pc980155_test_port(init_regs) &&
- pc980155_getconfig(base_io, init_regs,
- &irq, &dma, &scsi_id))
- goto found;
-
- release_region(base_io, 6);
- }
-
- printk("PC-9801-55: not found\n");
- return 0;
-
- found:
-#ifdef PC_9801_55_DEBUG
- printk("PC-9801-55: config: base io = %x, irq = %d, dma channel = %d, scsi id = %d\n", base_io, irq, dma, scsi_id);
-#endif
- if (request_irq(irq, pc980155_intr_handle, 0, "PC-9801-55", NULL)) {
- printk(KERN_ERR "PC-9801-55: unable to allocate IRQ %d\n", irq);
- goto err1;
- }
-
- if (request_dma(dma, "PC-9801-55")) {
- printk(KERN_ERR "PC-9801-55: unable to allocate DMA channel %d\n", dma);
- goto err2;
- }
-
- pc980155_host = scsi_register(tpnt, sizeof(struct WD33C93_hostdata));
- if (pc980155_host) {
- pc980155_host->this_id = scsi_id;
- pc980155_host->io_port = base_io;
- pc980155_host->n_io_port = 6;
- pc980155_host->irq = irq;
- pc980155_host->dma_channel = dma;
- printk("PC-9801-55: scsi host found at %x irq = %d, use dma channel %d.\n", base_io, irq, dma);
- pc980155_int_enable(init_regs);
- wd33c93_init(pc980155_host, init_regs, dma_setup, dma_stop,
- WD33C93_FS_12_15);
- return 1;
- }
-
- printk(KERN_ERR "PC-9801-55: failed to register device\n");
-
-err2:
- free_irq(irq, NULL);
-err1:
- release_region(base_io, 6);
- return 0;
-}
-
-static int scsi_pc980155_release(struct Scsi_Host *shost)
-{
- struct WD33C93_hostdata *hostdata
- = (struct WD33C93_hostdata *)shost->hostdata;
-
- pc980155_int_disable(hostdata->regs);
- release_region(shost->io_port, shost->n_io_port);
- free_irq(shost->irq, NULL);
- free_dma(shost->dma_channel);
- wd33c93_release();
- return 1;
-}
-
-static int pc980155_bus_reset(Scsi_Cmnd *cmd)
-{
- struct WD33C93_hostdata *hostdata
- = (struct WD33C93_hostdata *)cmd->device->host->hostdata;
-
- pc980155_int_disable(hostdata->regs);
- pc980155_assert_bus_reset(hostdata->regs);
- udelay(50);
- pc980155_negate_bus_reset(hostdata->regs);
- (void) inb(hostdata->regs.SASR);
- (void) read_pc980155(hostdata->regs, WD_SCSI_STATUS);
- pc980155_int_enable(hostdata->regs);
- wd33c93_host_reset(cmd);
- return SUCCESS;
-}
-
-
-#ifndef MODULE
-static int __init pc980155_setup(char *str)
-{
- int ints[4];
-
- str = get_options(str, ARRAY_SIZE(ints), ints);
- if (ints[0] > 0)
- io = ints[1];
- return 1;
-}
-__setup("pc980155_io=", pc980155_setup);
-#endif
-
-MODULE_PARM(io, "i");
-MODULE_AUTHOR("Tomoharu Ugawa <ohirune@kmc.gr.jp>");
-MODULE_DESCRIPTION("PC-9801-55 SCSI host adapter driver");
-MODULE_LICENSE("GPL");
-
-static Scsi_Host_Template driver_template = {
- .proc_info = wd33c93_proc_info,
- .name = "SCSI PC-9801-55",
- .detect = scsi_pc980155_detect,
- .release = scsi_pc980155_release,
- .queuecommand = wd33c93_queuecommand,
- .eh_abort_handler = wd33c93_abort,
- .eh_bus_reset_handler = pc980155_bus_reset,
- .eh_host_reset_handler = wd33c93_host_reset,
- .bios_param = pc98_bios_param,
- .can_queue = CAN_QUEUE,
- .this_id = 7,
- .sg_tablesize = SG_ALL,
- .cmd_per_lun = CMD_PER_LUN, /* dont use link command */
- .unchecked_isa_dma = 1, /* use dma **XXXX***/
- .use_clustering = ENABLE_CLUSTERING,
- .proc_name = "PC_9801_55",
-};
-
-#include "scsi_module.c"
+++ /dev/null
-/*
- *
- * drivers/scsi/pc980155.h
- *
- * PC-9801-55 SCSI host adapter driver
- *
- * Copyright (C) 1997-2003 Kyoto University Microcomputer Club
- * (Linux/98 project)
- * Tomoharu Ugawa <ohirune@kmc.gr.jp>
- *
- */
-
-#ifndef __PC980155_H
-#define __PC980155_H
-
-#include "wd33c93.h"
-
-#define REG_ADDRST (base_io)
-#define REG_CONTRL (base_io + 2)
-#define REG_CWRITE (base_io + 4)
-#define REG_STATRD (base_io + 4)
-
-#define WD_MEMORYBANK 0x30
-#define WD_RESETINT 0x33
-
-static inline uchar read_pc980155(const wd33c93_regs regs, uchar reg_num)
-{
- outb(reg_num, regs.SASR);
- return (uchar)inb(regs.SCMD);
-}
-
-static inline void write_memorybank(const wd33c93_regs regs, uchar value)
-{
- outb(WD_MEMORYBANK, regs.SASR);
- outb(value, regs.SCMD);
-}
-
-#define read_pc980155_resetint(regs) \
- read_pc980155((regs), WD_RESETINT)
-#define pc980155_int_enable(regs) \
- write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) | 0x04)
-
-#define pc980155_int_disable(regs) \
- write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) & ~0x04)
-
-#define pc980155_assert_bus_reset(regs) \
- write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) | 0x02)
-
-#define pc980155_negate_bus_reset(regs) \
- write_memorybank((regs), read_pc980155((regs), WD_MEMORYBANK) & ~0x02)
-
-#endif /* __PC980155_H */
+++ /dev/null
-#define PCMCIA 1
-#include "qlogicfas.c"
+++ /dev/null
-/******************************************************************************
- * QLOGIC LINUX SOFTWARE
- *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2004 QLogic Corporation
- * (www.qlogic.com)
- *
- * Portions (C) Arjan van de Ven <arjanv@redhat.com> for Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- ******************************************************************************/
-
-#ifndef __QLA_OS_H
-#define __QLA_OS_H
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/sched.h>
-#include <linux/pci.h>
-#include <linux/proc_fs.h>
-#include <linux/blkdev.h>
-#include <linux/interrupt.h>
-#include <linux/stat.h>
-#include <linux/slab.h>
-#include <linux/mempool.h>
-#include <linux/vmalloc.h>
-#include <linux/smp_lock.h>
-#include <linux/bio.h>
-#include <linux/moduleparam.h>
-#include <linux/capability.h>
-#include <linux/list.h>
-
-#include <asm/system.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/segment.h>
-#include <asm/byteorder.h>
-#include <asm/pgtable.h>
-
-#include <linux/ioctl.h>
-#include <asm/uaccess.h>
-
-#include "scsi.h"
-#include "hosts.h"
-
-#include <scsi/scsicam.h>
-#include <scsi/scsi_ioctl.h>
-#include <scsi/scsi_transport.h>
-#include <scsi/scsi_transport_fc.h>
-
-//TODO Fix this!!!
-/*
-* String arrays
-*/
-#define LINESIZE 256
-#define MAXARGS 26
-
-/***********************************************************************
-* We use the struct scsi_pointer structure that's included with each
-* command SCSI_Cmnd as a scratchpad.
-*
-* SCp is defined as follows:
-* - SCp.ptr -- > pointer to the SRB
-* - SCp.this_residual -- > HBA completion status for ioctl code.
-*
-* Cmnd->host_scribble --> Used to hold the hba actived handle (1..255).
-***********************************************************************/
-#define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
-#define CMD_COMPL_STATUS(Cmnd) ((Cmnd)->SCp.this_residual)
-/* Additional fields used by ioctl passthru */
-#define CMD_RESID_LEN(Cmnd) ((Cmnd)->SCp.buffers_residual)
-#define CMD_SCSI_STATUS(Cmnd) ((Cmnd)->SCp.Status)
-#define CMD_ACTUAL_SNSLEN(Cmnd) ((Cmnd)->SCp.Message)
-#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
-
-#endif
+++ /dev/null
-/* to be used by qlogicfas and qlogic_cs */
-#ifndef __QLOGICFAS_H
-#define __QLOGICFAS_H
-
-/*----------------------------------------------------------------*/
-/* Configuration */
-
-/* Set the following to 2 to use normal interrupt (active high/totempole-
- tristate), otherwise use 0 (REQUIRED FOR PCMCIA) for active low, open
- drain */
-
-#define QL_INT_ACTIVE_HIGH 2
-
-/* Set the following to max out the speed of the PIO PseudoDMA transfers,
- again, 0 tends to be slower, but more stable. */
-
-#define QL_TURBO_PDMA 1
-
-/* This should be 1 to enable parity detection */
-
-#define QL_ENABLE_PARITY 1
-
-/* This will reset all devices when the driver is initialized (during bootup).
- The other linux drivers don't do this, but the DOS drivers do, and after
- using DOS or some kind of crash or lockup this will bring things back
- without requiring a cold boot. It does take some time to recover from a
- reset, so it is slower, and I have seen timeouts so that devices weren't
- recognized when this was set. */
-
-#define QL_RESET_AT_START 0
-
-/* crystal frequency in megahertz (for offset 5 and 9)
- Please set this for your card. Most Qlogic cards are 40 Mhz. The
- Control Concepts ISA (not VLB) is 24 Mhz */
-
-#define XTALFREQ 40
-
-/**********/
-/* DANGER! modify these at your own risk */
-/* SLOWCABLE can usually be reset to zero if you have a clean setup and
- proper termination. The rest are for synchronous transfers and other
- advanced features if your device can transfer faster than 5Mb/sec.
- If you are really curious, email me for a quick howto until I have
- something official */
-/**********/
-
-/*****/
-/* config register 1 (offset 8) options */
-/* This needs to be set to 1 if your cabling is long or noisy */
-#define SLOWCABLE 1
-
-/*****/
-/* offset 0xc */
-/* This will set fast (10Mhz) synchronous timing when set to 1
- For this to have an effect, FASTCLK must also be 1 */
-#define FASTSCSI 0
-
-/* This when set to 1 will set a faster sync transfer rate */
-#define FASTCLK 0 /*(XTALFREQ>25?1:0)*/
-
-/*****/
-/* offset 6 */
-/* This is the sync transfer divisor, XTALFREQ/X will be the maximum
- achievable data rate (assuming the rest of the system is capable
- and set properly) */
-#define SYNCXFRPD 5 /*(XTALFREQ/5)*/
-
-/*****/
-/* offset 7 */
-/* This is the count of how many synchronous transfers can take place
- i.e. how many reqs can occur before an ack is given.
- The maximum value for this is 15, the upper bits can modify
- REQ/ACK assertion and deassertion during synchronous transfers
- If this is 0, the bus will only transfer asynchronously */
-#define SYNCOFFST 0
-/* for the curious, bits 7&6 control the deassertion delay in 1/2 cycles
- of the 40Mhz clock. If FASTCLK is 1, specifying 01 (1/2) will
- cause the deassertion to be early by 1/2 clock. Bits 5&4 control
- the assertion delay, also in 1/2 clocks (FASTCLK is ignored here). */
-
-/*----------------------------------------------------------------*/
-#ifdef PCMCIA
-#undef QL_INT_ACTIVE_HIGH
-#define QL_INT_ACTIVE_HIGH 0
-#endif
-
-struct qlogicfas_priv;
-typedef struct qlogicfas_priv *qlogicfas_priv_t;
-struct qlogicfas_priv {
- int qbase; /* Port */
- int qinitid; /* initiator ID */
- int qabort; /* Flag to cause an abort */
- int qlirq; /* IRQ being used */
- char qinfo[80]; /* description */
- Scsi_Cmnd *qlcmd; /* current command being processed */
- struct Scsi_Host *shost; /* pointer back to host */
- qlogicfas_priv_t next; /* next private struct */
-};
-
-extern int qlcfg5;
-extern int qlcfg6;
-extern int qlcfg7;
-extern int qlcfg8;
-extern int qlcfg9;
-extern int qlcfgc;
-
-/* The qlogic card uses two register maps - These macros select which one */
-#define REG0 ( outb( inb( qbase + 0xd ) & 0x7f , qbase + 0xd ), outb( 4 , qbase + 0xd ))
-#define REG1 ( outb( inb( qbase + 0xd ) | 0x80 , qbase + 0xd ), outb( 0xb4 | QL_INT_ACTIVE_HIGH , qbase + 0xd ))
-
-/* following is watchdog timeout in microseconds */
-#define WATCHDOG 5000000
-
-/*----------------------------------------------------------------*/
-/* the following will set the monitor border color (useful to find
- where something crashed or gets stuck at and as a simple profiler) */
-
-#if 0
-#define rtrc(i) {inb(0x3da);outb(0x31,0x3c0);outb((i),0x3c0);}
-#else
-#define rtrc(i) {}
-#endif
-#endif /* __QLOGICFAS_H */
-
+++ /dev/null
-/*
- * Copyright (C) 2003 Osamu Tomita <tomita@cinet.co.jp>
- *
- * PC9801 BIOS geometry handling.
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/genhd.h>
-#include <linux/blkdev.h>
-#include <asm/pc9800.h>
-
-#include "scsi.h"
-#include "hosts.h"
-
-
-static int pc98_first_bios_param(struct scsi_device *sdev, int *ip)
-{
- const u8 *p = (&__PC9800SCA(u8, PC9800SCA_SCSI_PARAMS) + sdev->id * 4);
-
- ip[0] = p[1]; /* # of heads */
- ip[1] = p[0]; /* # of sectors/track */
- ip[2] = *(u16 *)&p[2] & 0x0fff; /* # of cylinders */
- if (p[3] & (1 << 6)) { /* #-of-cylinders is 16-bit */
- ip[2] |= (ip[0] & 0xf0) << 8;
- ip[0] &= 0x0f;
- }
-
- return 0;
-}
-
-int pc98_bios_param(struct scsi_device *sdev, struct block_device *bdev,
- sector_t capacity, int *ip)
-{
- struct Scsi_Host *first_real = first_real_host();
-
- /*
- * XXX
- * XXX This needs to become a sysfs attribute that's set
- * XXX by code that knows which host is the first one.
- * XXX
- * XXX Currently we support only one host on with a
- * XXX PC98ish HBA.
- * XXX
- */
- if (1 || sdev->host == first_real && sdev->id < 7 &&
- __PC9800SCA_TEST_BIT(PC9800SCA_DISK_EQUIPS, sdev->id))
- return pc98_first_bios_param(sdev, ip);
-
- /* Assume PC-9801-92 compatible parameters for HAs without BIOS. */
- ip[0] = 8;
- ip[1] = 32;
- ip[2] = capacity / (8 * 32);
- if (ip[2] > 65535) { /* if capacity >= 8GB */
- /* Recent on-board adapters seem to use this parameter. */
- ip[1] = 128;
- ip[2] = capacity / (8 * 128);
- if (ip[2] > 65535) { /* if capacity >= 32GB */
- /* Clip the number of cylinders. Currently
- this is the limit that we deal with. */
- ip[2] = 65535;
- }
- }
-
- return 0;
-}
-
-EXPORT_SYMBOL(pc98_bios_param);
+++ /dev/null
-/*
- * linux/drivers/char/hcdp_serial.c
- *
- * Copyright (C) 2002 Hewlett-Packard Co.
- * Khalid Aziz <khalid_aziz@hp.com>
- *
- * Parse the EFI HCDP table to locate serial console and debug ports and
- * initialize them.
- *
- * 2002/08/29 davidm Adjust it to new 2.5 serial driver infrastructure.
- */
-
-#include <linux/config.h>
-#include <linux/console.h>
-#include <linux/kernel.h>
-#include <linux/efi.h>
-#include <linux/init.h>
-#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/serial_core.h>
-#include <linux/types.h>
-#include <linux/acpi.h>
-
-#include <asm/io.h>
-#include <asm/serial.h>
-#include <asm/acpi.h>
-
-#include "8250_hcdp.h"
-
-#undef SERIAL_DEBUG_HCDP
-
-/*
- * Parse the HCDP table to find descriptions for headless console and debug
- * serial ports and add them to rs_table[]. A pointer to HCDP table is
- * passed as parameter. This function should be called before
- * serial_console_init() is called to make sure the HCDP serial console will
- * be available for use. IA-64 kernel calls this function from setup_arch()
- * after the EFI and ACPI tables have been parsed.
- */
-void __init
-setup_serial_hcdp(void *tablep)
-{
- hcdp_dev_t *hcdp_dev;
- struct uart_port port;
- unsigned long iobase;
- hcdp_t hcdp;
- int gsi, nr;
- static char options[16];
-#if 0
- static int shift_once = 1;
-#endif
-
-#ifdef SERIAL_DEBUG_HCDP
- printk("Entering setup_serial_hcdp()\n");
-#endif
-
- /* Verify we have a valid table pointer */
- if (!tablep)
- return;
-
- memset(&port, 0, sizeof(port));
-
- /*
- * Don't trust firmware to give us a table starting at an aligned
- * address. Make a local copy of the HCDP table with aligned
- * structures.
- */
- memcpy(&hcdp, tablep, sizeof(hcdp));
-
- /*
- * Perform a sanity check on the table. Table should have a signature
- * of "HCDP" and it should be atleast 82 bytes long to have any
- * useful information.
- */
- if ((strncmp(hcdp.signature, HCDP_SIGNATURE, HCDP_SIG_LEN) != 0))
- return;
- if (hcdp.len < 82)
- return;
-
-#ifdef SERIAL_DEBUG_HCDP
- printk("setup_serial_hcdp(): table pointer = 0x%p, sig = '%.4s'\n",
- tablep, hcdp.signature);
- printk(" length = %d, rev = %d, ", hcdp.len, hcdp.rev);
- printk("OEM ID = %.6s, # of entries = %d\n", hcdp.oemid,
- hcdp.num_entries);
-#endif
-
- /*
- * Parse each device entry
- */
- for (nr = 0; nr < hcdp.num_entries; nr++) {
- hcdp_dev = hcdp.hcdp_dev + nr;
- /*
- * We will parse only the primary console device which is
- * the first entry for these devices. We will ignore rest
- * of the entries for the same type device that has already
- * been parsed and initialized
- */
- if (hcdp_dev->type != HCDP_DEV_CONSOLE)
- continue;
-
- iobase = ((u64) hcdp_dev->base_addr.addrhi << 32) |
- hcdp_dev->base_addr.addrlo;
- gsi = hcdp_dev->global_int;
-
- /* See PCI spec v2.2, Appendix D (Class Codes): */
- switch (hcdp_dev->pci_prog_intfc) {
- case 0x00:
- port.type = PORT_8250;
- break;
- case 0x01:
- port.type = PORT_16450;
- break;
- case 0x02:
- port.type = PORT_16550;
- break;
- case 0x03:
- port.type = PORT_16650;
- break;
- case 0x04:
- port.type = PORT_16750;
- break;
- case 0x05:
- port.type = PORT_16850;
- break;
- case 0x06:
- port.type = PORT_16C950;
- break;
- default:
- printk(KERN_WARNING "warning: EFI HCDP table reports "
- "unknown serial programming interface 0x%02x; "
- "will autoprobe.\n", hcdp_dev->pci_prog_intfc);
- port.type = PORT_UNKNOWN;
- break;
- }
-
-#ifdef SERIAL_DEBUG_HCDP
- printk(" type = %s, uart = %d\n",
- ((hcdp_dev->type == HCDP_DEV_CONSOLE) ?
- "Headless Console" :
- ((hcdp_dev->type == HCDP_DEV_DEBUG) ?
- "Debug port" : "Huh????")), port.type);
- printk(" base address space = %s, base address = 0x%lx\n",
- ((hcdp_dev->base_addr.space_id == ACPI_MEM_SPACE) ?
- "Memory Space" :
- ((hcdp_dev->base_addr.space_id == ACPI_IO_SPACE) ?
- "I/O space" : "PCI space")),
- iobase);
- printk(" gsi = %d, baud rate = %lu, bits = %d, clock = %d\n",
- gsi, (unsigned long) hcdp_dev->baud, hcdp_dev->bits,
- hcdp_dev->clock_rate);
- if (HCDP_PCI_UART(hcdp_dev))
- printk(" PCI id: %02x:%02x:%02x, vendor ID=0x%x, "
- "dev ID=0x%x\n", hcdp_dev->pci_seg,
- hcdp_dev->pci_bus, hcdp_dev->pci_dev,
- hcdp_dev->pci_vendor_id, hcdp_dev->pci_dev_id);
-#endif
- /*
- * Now fill in a port structure to update the 8250 port table..
- */
- if (hcdp_dev->clock_rate)
- port.uartclk = hcdp_dev->clock_rate;
- else
- port.uartclk = BASE_BAUD * 16;
-
- /*
- * Check if this is an I/O mapped address or a memory mapped
- * address
- */
- if (hcdp_dev->base_addr.space_id == ACPI_MEM_SPACE) {
- port.iobase = 0;
- port.mapbase = iobase;
- port.membase = ioremap(iobase, 64);
- port.iotype = SERIAL_IO_MEM;
- } else if (hcdp_dev->base_addr.space_id == ACPI_IO_SPACE) {
- port.iobase = iobase;
- port.mapbase = 0;
- port.membase = NULL;
- port.iotype = SERIAL_IO_PORT;
- } else if (hcdp_dev->base_addr.space_id == ACPI_PCICONF_SPACE) {
- printk(KERN_WARNING"warning: No support for PCI serial console\n");
- return;
- }
-
- if (HCDP_IRQ_SUPPORTED(hcdp_dev)) {
-#ifdef CONFIG_IA64
- if (HCDP_PCI_UART(hcdp_dev))
- port.irq = acpi_register_irq(gsi,
- ACPI_ACTIVE_LOW, ACPI_LEVEL_SENSITIVE);
- else
- port.irq = acpi_register_irq(gsi,
- ACPI_ACTIVE_HIGH, ACPI_EDGE_SENSITIVE);
-#else
- port.irq = gsi;
-#endif
- port.flags |= UPF_AUTO_IRQ;
-
- if (HCDP_PCI_UART(hcdp_dev))
- port.flags |= UPF_SHARE_IRQ;
- }
-
- port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_RESOURCES;
-
- /*
- * Note: the above memset() initializes port.line to 0,
- * so we register this port as ttyS0.
- */
- if (early_serial_setup(&port) < 0) {
- printk("setup_serial_hcdp(): early_serial_setup() "
- "for HCDP serial console port failed. "
- "Will try any additional consoles in HCDP.\n");
- memset(&port, 0, sizeof(port));
- continue;
- }
-
- if (efi_uart_console_only()) {
- snprintf(options, sizeof(options), "%lun%d",
- hcdp_dev->baud, hcdp_dev->bits);
- add_preferred_console("ttyS", port.line, options);
- }
- break;
- }
-
-#ifdef SERIAL_DEBUG_HCDP
- printk("Leaving setup_serial_hcdp()\n");
-#endif
-}
-
-#ifdef CONFIG_IA64_EARLY_PRINTK_UART
-unsigned long
-hcdp_early_uart (void)
-{
- efi_system_table_t *systab;
- efi_config_table_t *config_tables;
- unsigned long addr = 0;
- hcdp_t *hcdp = 0;
- hcdp_dev_t *dev;
- int i;
-
- systab = (efi_system_table_t *) ia64_boot_param->efi_systab;
- if (!systab)
- return 0;
- systab = __va(systab);
-
- config_tables = (efi_config_table_t *) systab->tables;
- if (!config_tables)
- return 0;
- config_tables = __va(config_tables);
-
- for (i = 0; i < systab->nr_tables; i++) {
- if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
- hcdp = (hcdp_t *) config_tables[i].table;
- break;
- }
- }
- if (!hcdp)
- return 0;
- hcdp = __va(hcdp);
-
- for (i = 0, dev = hcdp->hcdp_dev; i < hcdp->num_entries; i++, dev++) {
- if (dev->type == HCDP_DEV_CONSOLE) {
- addr = (u64) dev->base_addr.addrhi << 32 | dev->base_addr.addrlo;
- break;
- }
- }
- return addr;
-}
-#endif /* CONFIG_IA64_EARLY_PRINTK_UART */
+++ /dev/null
-/*
- * drivers/serial/8250_hcdp.h
- *
- * Copyright (C) 2002 Hewlett-Packard Co.
- * Khalid Aziz <khalid_aziz@hp.com>
- *
- * Definitions for HCDP defined serial ports (Serial console and debug
- * ports)
- */
-
-/* ACPI table signatures */
-#define HCDP_SIG_LEN 4
-#define HCDP_SIGNATURE "HCDP"
-
-/* Space ID as defined in ACPI generic address structure */
-#define ACPI_MEM_SPACE 0
-#define ACPI_IO_SPACE 1
-#define ACPI_PCICONF_SPACE 2
-
-/*
- * Maximum number of HCDP devices we want to read in
- */
-#define MAX_HCDP_DEVICES 6
-
-/*
- * Default UART clock rate if clock rate is 0 in HCDP table.
- */
-#define DEFAULT_UARTCLK 115200
-
-/*
- * ACPI Generic Address Structure
- */
-typedef struct {
- u8 space_id;
- u8 bit_width;
- u8 bit_offset;
- u8 resv;
- u32 addrlo;
- u32 addrhi;
-} acpi_gen_addr;
-
-/* HCDP Device descriptor entry types */
-#define HCDP_DEV_CONSOLE 0
-#define HCDP_DEV_DEBUG 1
-
-/* HCDP Device descriptor type */
-typedef struct {
- u8 type;
- u8 bits;
- u8 parity;
- u8 stop_bits;
- u8 pci_seg;
- u8 pci_bus;
- u8 pci_dev;
- u8 pci_func;
- u64 baud;
- acpi_gen_addr base_addr;
- u16 pci_dev_id;
- u16 pci_vendor_id;
- u32 global_int;
- u32 clock_rate;
- u8 pci_prog_intfc;
- u8 resv;
-} hcdp_dev_t;
-
-/* HCDP Table format */
-typedef struct {
- u8 signature[4];
- u32 len;
- u8 rev;
- u8 chksum;
- u8 oemid[6];
- u8 oem_tabid[8];
- u32 oem_rev;
- u8 creator_id[4];
- u32 creator_rev;
- u32 num_entries;
- hcdp_dev_t hcdp_dev[MAX_HCDP_DEVICES];
-} hcdp_t;
-
-#define HCDP_PCI_UART(x) (x->pci_func & 1UL<<7)
-#define HCDP_IRQ_SUPPORTED(x) (x->pci_func & 1UL<<6)
+++ /dev/null
-/*
- * linux/drivers/serial/serial98.c
- *
- * Driver for NEC PC-9801/PC-9821 standard serial ports
- *
- * Based on drivers/serial/8250.c, by Russell King.
- * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
- *
- * Copyright (C) 2002 Osamu Tomita <tomita@cinet.co.jp>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/serial_reg.h>
-#include <linux/delay.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/pc9800.h>
-#include <asm/pc9800_sca.h>
-
-#if defined(CONFIG_SERIAL98_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#include <linux/serial_core.h>
-
-#define SERIAL98_NR 1
-#define SERIAL98_ISR_PASS_LIMIT 256
-#define SERIAL98_EXT 0x434
-
-//#define RX_8251F 0x130 /* In: Receive buffer */
-//#define TX_8251F 0x130 /* Out: Transmit buffer */
-//#define LSR_8251F 0x132 /* In: Line Status Register */
-//#define MSR_8251F 0x134 /* In: Modem Status Register */
-#define IIR_8251F 0x136 /* In: Interrupt ID Register */
-#define FCR_8251F 0x138 /* I/O: FIFO Control Register */
-#define VFAST_8251F 0x13a /* I/O: VFAST mode Register */
-
-#define CMD_8251F 0x32 /* Out: 8251 Command Resister */
-#define IER2_8251F 0x34 /* I/O: Interrupt Enable Register */
-#define IER1_8251F 0x35 /* I/O: Interrupt Enable Register */
-#define IER1_CTL 0x37 /* Out: Interrupt Enable Register */
-#define DIS_RXR_INT 0x00 /* disable RxRDY Interrupt */
-#define ENA_RXR_INT 0x01 /* enable RxRDY Interrupt */
-#define DIS_TXE_INT 0x02 /* disable TxEMPTY Interrupt */
-#define ENA_TXE_INT 0x03 /* enable TxEMPTY Interrupt */
-#define DIS_TXR_INT 0x04 /* disable TxRDY Interrupt */
-#define ENA_TXR_INT 0x05 /* enable TxRDY Interrupt */
-
-#define CMD_RESET 0x40 /* Reset Command */
-#define CMD_RTS 0x20 /* Set RTS line */
-#define CMD_CLR_ERR 0x10 /* Clear error flag */
-#define CMD_BREAK 0x08 /* Send Break */
-#define CMD_RXE 0x04 /* Enable receive */
-#define CMD_DTR 0x02 /* Set DTR line */
-#define CMD_TXE 0x01 /* Enable send */
-#define CMD_DUMMY 0x00 /* Dummy Command */
-
-#define VFAST_ENABLE 0x80 /* V.Fast mode Enable */
-
-/* Interrupt masks */
-#define INTR_8251_TXRE 0x04
-#define INTR_8251_TXEE 0x02
-#define INTR_8251_RXRE 0x01
-/* I/O Port */
-//#define PORT_8251_DATA 0
-//#define PORT_8251_CMD 2
-//#define PORT_8251_MOD 2
-//#define PORT_8251_STS 2
-/* status read */
-#define STAT_8251_TXRDY 0x01
-#define STAT_8251_RXRDY 0x02
-#define STAT_8251_TXEMP 0x04
-#define STAT_8251_PER 0x08
-#define STAT_8251_OER 0x10
-#define STAT_8251_FER 0x20
-#define STAT_8251_BRK 0x40
-#define STAT_8251_DSR 0x80
-#if 1
-#define STAT_8251F_TXEMP 0x01
-#define STAT_8251F_TXRDY 0x02
-#define STAT_8251F_RXRDY 0x04
-#define STAT_8251F_DSR 0x08
-#define STAT_8251F_OER 0x10
-#define STAT_8251F_PER 0x20
-#define STAT_8251F_FER 0x40
-#define STAT_8251F_BRK 0x80
-#else
-#define STAT_8251F_TXEMP 0x01
-#define STAT_8251F_TEMT 0x01
-#define STAT_8251F_TXRDY 0x02
-#define STAT_8251F_THRE 0x02
-#define STAT_8251F_RXRDY 0x04
-#define STAT_8251F_DSR 0x04
-#define STAT_8251F_PER 0x08
-#define STAT_8251F_OER 0x10
-#define STAT_8251F_FER 0x20
-#define STAT_8251F_BRK 0x40
-#endif
-
-/*
- * We wrap our port structure around the generic uart_port.
- */
-struct serial98_port {
- struct uart_port port;
- unsigned int type;
- unsigned int ext;
- unsigned int lsr_break_flag;
- unsigned char cmd;
- unsigned char mode;
- unsigned char msr;
- unsigned char ier;
- unsigned char rxchk;
- unsigned char txemp;
- unsigned char txrdy;
- unsigned char rxrdy;
- unsigned char brk;
- unsigned char fe;
- unsigned char oe;
- unsigned char pe;
- unsigned char dr;
-};
-
-#ifdef CONFIG_SERIAL98_CONSOLE
-static void
-serial98_console_write(struct console *co, const char *s, unsigned int count);
-static int __init serial98_console_setup(struct console *co, char *options);
-
-extern struct uart_driver serial98_reg;
-static struct console serial98_console = {
- .name = "ttyS",
- .write = serial98_console_write,
- .device = uart_console_device,
- .setup = serial98_console_setup,
- .flags = CON_PRINTBUFFER,
- .index = -1,
- .data = &serial98_reg,
-};
-
-#define SERIAL98_CONSOLE &serial98_console
-#else
-#define SERIAL98_CONSOLE NULL
-#endif
-
-static struct uart_driver serial98_reg = {
- .owner = THIS_MODULE,
- .driver_name = "serial98",
- .dev_name = "ttyS",
- .major = TTY_MAJOR,
- .minor = 64,
- .nr = SERIAL98_NR,
- .cons = SERIAL98_CONSOLE,
-};
-
-static int serial98_clk;
-static char type_str[48];
-
-#define PORT98 ((struct serial98_port *)port)
-#define PORT (PORT98->port)
-
-static void serial98_fifo_enable(struct uart_port *port, int enable)
-{
- unsigned char fcr;
-
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- fcr = inb(FCR_8251F);
- if (enable)
- fcr |= UART_FCR_ENABLE_FIFO;
- else
- fcr &= ~UART_FCR_ENABLE_FIFO;
- outb(fcr, FCR_8251F);
- }
-
- if (!enable)
- return;
-
- outb(0, 0x5f); /* wait */
- outb(0, 0x5f);
- outb(0, 0x5f);
- outb(0, 0x5f);
-}
-
-static void serial98_cmd_out(struct uart_port *port, unsigned char cmd)
-{
- serial98_fifo_enable(port, 0);
- outb(cmd, CMD_8251F);
- serial98_fifo_enable(port, 1);
-}
-
-static void serial98_mode_set(struct uart_port *port)
-{
- serial98_cmd_out(port, CMD_DUMMY);
- serial98_cmd_out(port, CMD_DUMMY);
- serial98_cmd_out(port, CMD_DUMMY);
- serial98_cmd_out(port, CMD_RESET);
- serial98_cmd_out(port, PORT98->mode);
-}
-
-static unsigned char serial98_msr_in(struct uart_port *port)
-{
- unsigned long flags;
- unsigned int ms, st;
- unsigned int tmp;
-
- spin_lock_irqsave(&PORT.lock, flags);
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- PORT98->msr = inb(PORT.iobase + 4);
- } else {
- ms = inb(0x33);
- st = inb(0x32);
- tmp = 0;
- if(!(ms & 0x20))
- tmp |= UART_MSR_DCD;
- if(!(ms & 0x80)) {
- tmp |= UART_MSR_RI;
- PORT98->msr |= UART_MSR_RI;
- }
- if(!(ms & 0x40))
- tmp |= UART_MSR_CTS;
- if(st & 0x80)
- tmp |= UART_MSR_DSR;
- PORT98->msr = ((PORT98->msr ^ tmp) >> 4) | tmp;
- }
-
- spin_unlock_irqrestore(&PORT.lock, flags);
- return PORT98->msr;
-}
-
-static void serial98_stop_tx(struct uart_port *port, unsigned int tty_stop)
-{
- unsigned int ier = inb(IER1_8251F);
-
- ier &= ~(INTR_8251_TXRE | INTR_8251_TXEE);
- outb(ier, IER1_8251F);
-}
-
-static void serial98_start_tx(struct uart_port *port, unsigned int tty_start)
-{
- unsigned int ier = inb(IER1_8251F);
-
- ier |= INTR_8251_TXRE | INTR_8251_TXEE;
- outb(ier, IER1_8251F);
-}
-
-static void serial98_stop_rx(struct uart_port *port)
-{
- PORT.read_status_mask &= ~PORT98->dr;
- outb(DIS_RXR_INT, IER1_CTL);
-}
-
-static void serial98_enable_ms(struct uart_port *port)
-{
- outb(PORT98->ier | 0x80, IER2_8251F);
-}
-
-static void serial98_rx_chars(struct uart_port *port, int *status,
- struct pt_regs *regs)
-{
- struct tty_struct *tty = PORT.info->tty;
- unsigned char ch;
- int max_count = 256;
-
- do {
- if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
- tty->flip.work.func((void *)tty);
- if (tty->flip.count >= TTY_FLIPBUF_SIZE)
- return; // if TTY_DONT_FLIP is set
- }
- ch = inb(PORT.iobase);
- *tty->flip.char_buf_ptr = ch;
- *tty->flip.flag_buf_ptr = TTY_NORMAL;
- PORT.icount.rx++;
-
- if (unlikely(*status & (PORT98->brk | PORT98->pe |
- PORT98->fe | PORT98->oe))) {
- /*
- * For statistics only
- */
- if (*status & PORT98->brk) {
- *status &= ~(PORT98->fe | PORT98->pe);
- PORT.icount.brk++;
- /*
- * We do the SysRQ and SAK checking
- * here because otherwise the break
- * may get masked by ignore_status_mask
- * or read_status_mask.
- */
- if (uart_handle_break(&PORT))
- goto ignore_char;
- } else if (*status & PORT98->pe)
- PORT.icount.parity++;
- else if (*status & PORT98->fe)
- PORT.icount.frame++;
- if (*status & PORT98->oe)
- PORT.icount.overrun++;
-
- /*
- * Mask off conditions which should be ingored.
- */
- *status &= PORT.read_status_mask;
-
-#ifdef CONFIG_SERIAL98_CONSOLE
- if (PORT.line == PORT.cons->index) {
- /* Recover the break flag from console xmit */
- *status |= PORT98->lsr_break_flag;
- PORT98->lsr_break_flag = 0;
- }
-#endif
- if (*status & PORT98->brk) {
- *tty->flip.flag_buf_ptr = TTY_BREAK;
- } else if (*status & PORT98->pe)
- *tty->flip.flag_buf_ptr = TTY_PARITY;
- else if (*status & PORT98->fe)
- *tty->flip.flag_buf_ptr = TTY_FRAME;
- }
- if (uart_handle_sysrq_char(&PORT, ch, regs))
- goto ignore_char;
- if ((*status & PORT.ignore_status_mask) == 0) {
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- tty->flip.count++;
- }
- if ((*status & PORT98->oe) &&
- tty->flip.count < TTY_FLIPBUF_SIZE) {
- /*
- * Overrun is special, since it's reported
- * immediately, and doesn't affect the current
- * character.
- */
- *tty->flip.flag_buf_ptr = TTY_OVERRUN;
- tty->flip.flag_buf_ptr++;
- tty->flip.char_buf_ptr++;
- tty->flip.count++;
- }
- ignore_char:
- *status = inb(PORT.iobase + 2);
- } while ((*status & PORT98->rxchk) && (max_count-- > 0));
- tty_flip_buffer_push(tty);
-}
-
-static void serial98_tx_chars(struct uart_port *port)
-{
- struct circ_buf *xmit = &PORT.info->xmit;
- int count;
-
- if (PORT.x_char) {
- outb(PORT.x_char, PORT.iobase);
- PORT.icount.tx++;
- PORT.x_char = 0;
- return;
- }
- if (uart_circ_empty(xmit) || uart_tx_stopped(&PORT)) {
- serial98_stop_tx(port, 0);
- return;
- }
-
- count = PORT.fifosize;
- do {
- outb(xmit->buf[xmit->tail], PORT.iobase);
- xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
- PORT.icount.tx++;
- if (uart_circ_empty(xmit))
- break;
- } while (--count > 0);
-
- if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
- uart_write_wakeup(&PORT);
-
- if (uart_circ_empty(xmit))
- serial98_stop_tx(&PORT, 0);
-}
-
-static void serial98_modem_status(struct uart_port *port)
-{
- int status;
-
- status = serial98_msr_in(port);
-
- if ((status & UART_MSR_ANY_DELTA) == 0)
- return;
-
- if (status & UART_MSR_TERI)
- PORT.icount.rng++;
- if (status & UART_MSR_DDSR)
- PORT.icount.dsr++;
- if (status & UART_MSR_DDCD)
- uart_handle_dcd_change(&PORT, status & UART_MSR_DCD);
- if (status & UART_MSR_DCTS)
- uart_handle_cts_change(&PORT, status & UART_MSR_CTS);
-
- wake_up_interruptible(&PORT.info->delta_msr_wait);
-}
-
-static void serial98_int(int irq, void *port, struct pt_regs *regs)
-{
- unsigned int status;
-
- spin_lock(&PORT.lock);
- status = inb(PORT.iobase + 2);
- if (status & PORT98->rxrdy) {
- serial98_rx_chars(port, &status, regs);
- }
- serial98_modem_status(port);
- if (status & PORT98->txrdy) {
- serial98_tx_chars(port);
- }
- spin_unlock(&PORT.lock);
-}
-
-static unsigned int serial98_tx_empty(struct uart_port *port)
-{
- unsigned long flags;
- unsigned int ret = 0;
-
- spin_lock_irqsave(&PORT.lock, flags);
- if (inb(PORT.iobase + 2) & PORT98->txemp)
- ret = TIOCSER_TEMT;
-
- spin_unlock_irqrestore(&PORT.lock, flags);
- return ret;
-}
-
-static unsigned int serial98_get_mctrl(struct uart_port *port)
-{
- unsigned char status;
- unsigned int ret = 0;
-
- status = serial98_msr_in(port);
- if (status & UART_MSR_DCD)
- ret |= TIOCM_CAR;
- if (status & UART_MSR_RI)
- ret |= TIOCM_RNG;
- if (status & UART_MSR_DSR)
- ret |= TIOCM_DSR;
- if (status & UART_MSR_CTS)
- ret |= TIOCM_CTS;
- return ret;
-}
-
-static void serial98_set_mctrl(struct uart_port *port, unsigned int mctrl)
-{
- PORT98->cmd &= 0xdd;
- if (mctrl & TIOCM_RTS)
- PORT98->cmd |= CMD_RTS;
-
- if (mctrl & TIOCM_DTR)
- PORT98->cmd |= CMD_DTR;
-
- serial98_cmd_out(port, PORT98->cmd);
-}
-
-static void serial98_break_ctl(struct uart_port *port, int break_state)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&PORT.lock, flags);
- if (break_state == -1)
- PORT98->cmd |= CMD_BREAK;
- else
- PORT98->cmd &= ~CMD_BREAK;
-
- serial98_cmd_out(port, PORT98->cmd);
- spin_unlock_irqrestore(&PORT.lock, flags);
-}
-
-static int serial98_startup(struct uart_port *port)
-{
- int retval;
-
- if (PORT.type == PORT_8251_PC98) {
- /* Wake up UART */
- PORT98->mode = 0xfc;
- serial98_mode_set(port);
- outb(DIS_RXR_INT, IER1_CTL);
- outb(DIS_TXE_INT, IER1_CTL);
- outb(DIS_TXR_INT, IER1_CTL);
- PORT98->mode = 0;
- serial98_mode_set(port);
- }
-
- /*
- * Clear the FIFO buffers and disable them.
- * (they will be reeanbled in set_termios())
- */
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- outb(UART_FCR_ENABLE_FIFO, FCR_8251F);
- outb((UART_FCR_ENABLE_FIFO
- | UART_FCR_CLEAR_RCVR
- | UART_FCR_CLEAR_XMIT), FCR_8251F);
- outb(0, FCR_8251F);
- }
-
- /* Clear the interrupt registers. */
- inb(0x30);
- inb(0x32);
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- inb(PORT.iobase);
- inb(PORT.iobase + 2);
- inb(PORT.iobase + 4);
- inb(PORT.iobase + 6);
- }
-
- /* Allocate the IRQ */
- retval = request_irq(PORT.irq, serial98_int, 0,
- serial98_reg.driver_name, port);
- if (retval)
- return retval;
-
- /*
- * Now, initialize the UART
- */
- PORT98->mode = 0x4e;
- serial98_mode_set(port);
- PORT98->cmd = 0x15;
- serial98_cmd_out(port, PORT98->cmd);
- PORT98->cmd = 0x05;
-
- /*
- * Finally, enable interrupts
- */
- outb(0x00, IER2_8251F);
- outb(ENA_RXR_INT, IER1_CTL);
-
- /*
- * And clear the interrupt registers again for luck.
- */
- inb(0x30);
- inb(0x32);
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- inb(PORT.iobase);
- inb(PORT.iobase + 2);
- inb(PORT.iobase + 4);
- inb(PORT.iobase + 6);
- }
-
- return 0;
-}
-
-static void serial98_shutdown(struct uart_port *port)
-{
- unsigned long flags;
-
- /*
- * disable all interrupts
- */
- spin_lock_irqsave(&PORT.lock, flags);
- if (PORT.type == PORT_VFAST_PC98)
- outb(0, VFAST_8251F); /* V.FAST mode off */
-
- /* disnable all modem status interrupt */
- outb(0x80, IER2_8251F);
-
- /* disnable TX/RX interrupt */
- outb(0x00, IER2_8251F);
- outb(DIS_RXR_INT, IER1_CTL);
- outb(DIS_TXE_INT, IER1_CTL);
- outb(DIS_TXR_INT, IER1_CTL);
- PORT98->ier = 0;
-
- spin_unlock_irqrestore(&PORT.lock, flags);
-
- /*
- * Free the interrupt
- */
- free_irq(PORT.irq, port);
-
- /* disable break condition and disable the port */
- serial98_mode_set(port);
-
- /* disable FIFO's */
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- outb((UART_FCR_ENABLE_FIFO
- | UART_FCR_CLEAR_RCVR
- | UART_FCR_CLEAR_XMIT), FCR_8251F);
- outb(0, FCR_8251F);
- }
-
- inb(PORT.iobase);
-}
-
-static void
-serial98_set_termios(struct uart_port *port, struct termios *termios,
- struct termios *old)
-{
- unsigned char stopbit, cval, fcr = 0, ier = 0;
- unsigned long flags;
- unsigned int baud, quot;
-
- stopbit = 0x80;
- switch (termios->c_cflag & CSIZE) {
- case CS5:
- cval = 0x42;
- stopbit = 0xc0;
- break;
- case CS6:
- cval = 0x46;
- break;
- case CS7:
- cval = 0x4a;
- break;
- default:
- case CS8:
- cval = 0x4e;
- break;
- }
-
- if (termios->c_cflag & CSTOPB)
- cval ^= stopbit;
- if (termios->c_cflag & PARENB)
- cval |= 0x10;
- if (!(termios->c_cflag & PARODD))
- cval |= 0x20;
-
- /*
- * Ask the core to calculate the divisor for us.
- */
- baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
- quot = uart_get_divisor(port, baud);
-
- if (PORT.type == PORT_FIFO_PC98 || PORT.type == PORT_VFAST_PC98) {
- if ((PORT.uartclk / quot) < (2400 * 16))
- fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
- else
- fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
- }
-
- /*
- * Ok, we're now changing the port state. Do it with
- * interrupts disabled.
- */
- spin_lock_irqsave(&PORT.lock, flags);
-
- /*
- * Update the per-port timeout.
- */
- uart_update_timeout(port, termios->c_cflag, baud);
-
- PORT.read_status_mask = PORT98->oe | PORT98->txemp | PORT98->dr;
- if (termios->c_iflag & INPCK)
- PORT.read_status_mask |= PORT98->fe | PORT98->pe;
-
- if (termios->c_iflag & (BRKINT | PARMRK))
- PORT.read_status_mask |= PORT98->brk;
- /*
- * Characters to ignore
- */
- PORT.ignore_status_mask = 0;
- if (termios->c_iflag & IGNPAR)
- PORT.ignore_status_mask |= PORT98->fe | PORT98->pe;
-
- if (termios->c_iflag & IGNBRK) {
- PORT.ignore_status_mask |= PORT98->brk;
- /*
- * If we're ignoring parity and break indicators,
- * ignore overruns too (for real raw support).
- */
- if (termios->c_iflag & IGNPAR)
- PORT.ignore_status_mask |= PORT98->oe;
- }
-
- /*
- * ignore all characters if CREAD is not set
- */
- if ((termios->c_cflag & CREAD) == 0)
- PORT.ignore_status_mask |= PORT98->dr;
-
- /*
- * CTS flow control flag and modem status interrupts
- */
- if (PORT.flags & UPF_HARDPPS_CD)
- ier |= 0x80; /* enable modem status interrupt */
- if (termios->c_cflag & CRTSCTS) {
- ier |= 0x08; /* enable CTS interrupt */
- ier |= 0x80; /* enable modem status interrupt */
- }
- if (!(termios->c_cflag & CLOCAL)) {
- ier |= 0x20; /* enable CD interrupt */
- ier |= 0x80; /* enable modem status interrupt */
- }
- PORT98->ier = ier;
-
- PORT98->mode = cval;
- serial98_mode_set(port);
- if (PORT.type == PORT_VFAST_PC98 && quot <= 48) {
- quot /= 4;
- if (quot < 1)
- quot = 1;
- outb(quot | VFAST_ENABLE, VFAST_8251F);
- } else {
- quot /= 3;
- if (quot < 1)
- quot = 1;
- if (PORT.type == PORT_VFAST_PC98)
- outb(0, VFAST_8251F); /* V.FAST mode off */
- outb(0xb6, 0x77);
- outb(quot & 0xff, 0x75); /* LS of divisor */
- outb(quot >> 8, 0x75); /* MS of divisor */
- }
-
- if (fcr & UART_FCR_ENABLE_FIFO) {
- outb(UART_FCR_ENABLE_FIFO, FCR_8251F);
- outb(fcr, FCR_8251F);
- }
-
- /* enable RX/TX */
- PORT98->cmd = 0x15;
- serial98_cmd_out(port, PORT98->cmd);
- PORT98->cmd = 0x05;
- /* enable interrupts */
- outb(0x00, IER2_8251F);
- outb(ENA_RXR_INT, IER1_CTL);
- spin_unlock_irqrestore(&PORT.lock, flags);
-}
-
-static const char *serial98_type(struct uart_port *port)
-{
- char *p;
-
- switch (PORT.type) {
- case PORT_8251_PC98:
- p = "PC98 onboard legacy 8251";
- break;
- case PORT_19K_PC98:
- p = "PC98 onboard max 19200bps";
- break;
- case PORT_FIFO_PC98:
- p = "PC98 onboard with FIFO";
- break;
- case PORT_VFAST_PC98:
- p = "PC98 onboard V.FAST";
- break;
- case PORT_PC9861:
- p = "PC-9861K RS-232C ext. board";
- break;
- case PORT_PC9801_101:
- p = "PC-9801-101 RS-232C ext. board";
- break;
- default:
- return NULL;
- }
-
- sprintf(type_str, "%s Clock %dMHz", p, serial98_clk);
- return type_str;
-}
-
-/* Release the region(s) being used by 'port' */
-static void serial98_release_port(struct uart_port *port)
-{
- switch (PORT.type) {
- case PORT_VFAST_PC98:
- release_region(PORT.iobase + 0xa, 1);
- case PORT_FIFO_PC98:
- release_region(PORT.iobase + 8, 1);
- release_region(PORT.iobase + 6, 1);
- release_region(PORT.iobase + 4, 1);
- release_region(PORT.iobase + 2, 1);
- release_region(PORT.iobase, 1);
- case PORT_19K_PC98:
- release_region(SERIAL98_EXT, 1);
- release_region(0x34, 1);
- case PORT_8251_PC98:
- release_region(0x32, 1);
- release_region(0x30, 1);
- }
-}
-
-/* Request the region(s) being used by 'port' */
-#define REQ_REGION98(base) (request_region((base), 1, serial98_reg.driver_name))
-static int serial98_request_region(unsigned int type)
-{
- if (!REQ_REGION98(0x30))
- return -EBUSY;
- if (REQ_REGION98(0x32)) {
- if (type == PORT_8251_PC98)
- return 0;
- if (REQ_REGION98(0x34)) {
- if (REQ_REGION98(SERIAL98_EXT)) {
- unsigned long base;
-
- if (type == PORT_19K_PC98)
- return 0;
- for (base = 0x130; base <= 0x138; base += 2) {
- if (!REQ_REGION98(base)) {
- base -= 2;
- goto err;
- }
- }
- if (type == PORT_FIFO_PC98)
- return 0;
- if (type == PORT_VFAST_PC98) {
- if (REQ_REGION98(0x13a))
- return 0;
- }
- err:
- while (base >= 0x130) {
- release_region(base, 1);
- base -= 2;
- }
- release_region(SERIAL98_EXT, 1);
- }
- release_region(0x34, 1);
- }
- release_region(0x32, 1);
- }
- release_region(0x30, 1);
- return -EBUSY;
-}
-
-static int serial98_request_port(struct uart_port *port)
-{
- return serial98_request_region(PORT.type);
-}
-
-/*
- * Configure/autoconfigure the port.
- */
-static void serial98_config_port(struct uart_port *port, int flags)
-{
- if (flags & UART_CONFIG_TYPE)
- PORT.type = PORT98->type;
-}
-
-/*
- * verify the new serial_struct (for TIOCSSERIAL).
- */
-static int serial98_verify_port(struct uart_port *port, struct serial_struct *ser)
-{
- switch (ser->type) {
- case PORT_VFAST_PC98:
- case PORT_FIFO_PC98:
- case PORT_19K_PC98:
- case PORT_8251_PC98:
- /* not implemented yet
- case PORT_PC9861:
- case PORT_PC9801_101:
- */
- case PORT_UNKNOWN:
- break;
- default:
- return -EINVAL;
- }
- if (ser->irq < 0 || ser->irq >= NR_IRQS)
- return -EINVAL;
- if (ser->baud_base < 9600)
- return -EINVAL;
- return 0;
-}
-
-static struct uart_ops serial98_ops = {
- .tx_empty = serial98_tx_empty,
- .set_mctrl = serial98_set_mctrl,
- .get_mctrl = serial98_get_mctrl,
- .stop_tx = serial98_stop_tx,
- .start_tx = serial98_start_tx,
- .stop_rx = serial98_stop_rx,
- .enable_ms = serial98_enable_ms,
- .break_ctl = serial98_break_ctl,
- .startup = serial98_startup,
- .shutdown = serial98_shutdown,
- .set_termios = serial98_set_termios,
- .type = serial98_type,
- .release_port = serial98_release_port,
- .request_port = serial98_request_port,
- .config_port = serial98_config_port,
- .verify_port = serial98_verify_port,
-};
-
-static struct serial98_port serial98_ports[SERIAL98_NR] = {
- {
- .port = {
- .iobase = 0x30,
- .iotype = SERIAL_IO_PORT,
- .irq = 4,
- .fifosize = 1,
- .ops = &serial98_ops,
- .flags = ASYNC_BOOT_AUTOCONF,
- .line = 0,
- },
- .rxchk = STAT_8251_RXRDY,
- .txemp = STAT_8251_TXEMP,
- .txrdy = STAT_8251_TXRDY,
- .rxrdy = STAT_8251_RXRDY,
- .brk = STAT_8251_BRK,
- .fe = STAT_8251_FER,
- .oe = STAT_8251_OER,
- .pe = STAT_8251_PER,
- .dr = STAT_8251_DSR,
- },
-};
-
-#ifdef CONFIG_SERIAL98_CONSOLE
-
-#define BOTH_EMPTY (PORT98->txemp | PORT98->txrdy)
-
-/*
- * Wait for transmitter & holding register to empty
- */
-static inline void wait_for_xmitr(struct uart_port *port)
-{
- unsigned int status, tmout = 10000;
-
- /* Wait up to 10ms for the character(s) to be sent. */
- do {
- status = inb(PORT.iobase + 2);
-
- if (status & PORT98->brk)
- PORT98->lsr_break_flag = PORT98->brk;
-
- if (--tmout == 0)
- break;
- udelay(1);
- } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
-
- /* Wait up to 1s for flow control if necessary */
- if (PORT.flags & UPF_CONS_FLOW) {
- tmout = 1000000;
- while (--tmout &&
- ((serial98_msr_in(port) & UART_MSR_CTS) == 0))
- udelay(1);
- }
-}
-
-/*
- * Print a string to the serial port trying not to disturb
- * any possible real use of the port...
- *
- * The console_lock must be held when we get here.
- */
-static void
-serial98_console_write(struct console *co, const char *s, unsigned int count)
-{
- struct uart_port *port = (struct uart_port *)&serial98_ports[co->index];
- unsigned int ier1, ier2;
- int i;
-
- /*
- * First save the UER then disable the interrupts
- */
- ier1 = inb(IER1_8251F);
- ier2 = inb(IER2_8251F);
- /* disnable all modem status interrupt */
- outb(0x80, IER2_8251F);
-
- /* disnable TX/RX interrupt */
- outb(0x00, IER2_8251F);
- outb(DIS_RXR_INT, IER1_CTL);
- outb(DIS_TXE_INT, IER1_CTL);
- outb(DIS_TXR_INT, IER1_CTL);
-
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(port);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- outb(*s, PORT.iobase);
- if (*s == 10) {
- wait_for_xmitr(port);
- outb(13, PORT.iobase);
- }
- }
-
- /*
- * Finally, wait for transmitter to become empty
- * and restore the IER
- */
- wait_for_xmitr(port);
-
- /* restore TX/RX interrupt */
- outb(0x00, IER2_8251F);
- if (ier1 & 0x01)
- outb(ENA_RXR_INT, IER1_CTL);
- if (ier1 & 0x02)
- outb(ENA_TXE_INT, IER1_CTL);
- if (ier1 & 0x04)
- outb(ENA_TXR_INT, IER1_CTL);
-
- /* restore modem status interrupt */
- outb(ier2, IER2_8251F);
-}
-
-static int __init serial98_console_setup(struct console *co, char *options)
-{
- struct uart_port *port;
- int baud = 9600;
- int bits = 8;
- int parity = 'n';
- int flow = 'n';
-
- /*
- * Check whether an invalid uart number has been specified, and
- * if so, search for the first available port that does have
- * console support.
- */
- if (co->index >= SERIAL98_NR)
- co->index = 0;
- port = &serial98_ports[co->index].port;
-
- /*
- * Temporary fix.
- */
- spin_lock_init(&port->lock);
-
- if (options)
- uart_parse_options(options, &baud, &parity, &bits, &flow);
-
- return uart_set_options(port, co, baud, parity, bits, flow);
-}
-
-void __init serial98_console_init(void)
-{
- register_console(&serial98_console);
-}
-
-#endif /* CONFIG_SERIAL98_CONSOLE */
-
-
-static int __init serial98_init(void)
-{
- int ret;
- unsigned char iir1, iir2;
-
- if (PC9800_8MHz_P()) {
- serial98_clk = 8;
- serial98_ports[0].port.uartclk = 374400 * 16;
- } else {
- serial98_clk = 5;
- serial98_ports[0].port.uartclk = 460800 * 16;
- }
-
- printk(KERN_INFO "serial98: PC-9801 standard serial port driver Version 0.1alpha\n");
- serial98_ports[0].type = PORT_8251_PC98;
- /* Check FIFO exist */
- iir1 = inb(IIR_8251F);
- iir2 = inb(IIR_8251F);
- if ((iir1 & 0x40) != (iir2 & 0x40) && (iir1 & 0x20) == (iir2 & 0x20)) {
- serial98_ports[0].port.iobase = 0x130;
- serial98_ports[0].port.fifosize = 16;
- serial98_ports[0].rxchk = STAT_8251F_DSR;
- serial98_ports[0].txemp = STAT_8251F_TXEMP;
- serial98_ports[0].txrdy = STAT_8251F_TXRDY;
- serial98_ports[0].rxrdy = STAT_8251F_RXRDY;
- serial98_ports[0].brk = STAT_8251F_BRK;
- serial98_ports[0].fe = STAT_8251F_FER;
- serial98_ports[0].oe = STAT_8251F_OER;
- serial98_ports[0].pe = STAT_8251F_PER;
- serial98_ports[0].dr = STAT_8251F_DSR;
-
- if (*(unsigned char*)__va(PC9821SCA_RSFLAGS) & 0x10)
- serial98_ports[0].type = PORT_VFAST_PC98;
- else {
- outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT);
- serial98_ports[0].port.uartclk *= 4;
- serial98_ports[0].type = PORT_FIFO_PC98;
- }
- } else if ((serial98_ports[0].ext = inb(SERIAL98_EXT)) != 0xff) {
- outb(serial98_ports[0].ext | 0x40, SERIAL98_EXT);
- if (inb(SERIAL98_EXT) == (serial98_ports[0].ext | 0x40)) {
- serial98_ports[0].port.uartclk *= 4;
- serial98_ports[0].type = PORT_19K_PC98;
- } else {
- serial98_ops.enable_ms = NULL;
- outb(serial98_ports[0].ext, SERIAL98_EXT);
- }
- }
-
- if (serial98_request_region(serial98_ports[0].type))
- return -EBUSY;
-
- ret = uart_register_driver(&serial98_reg);
- if (ret == 0) {
- int i;
-
- for (i = 0; i < SERIAL98_NR; i++) {
- uart_add_one_port(&serial98_reg,
- (struct uart_port *)&serial98_ports[i]);
- }
- }
-
- return ret;
-}
-
-static void __exit serial98_exit(void)
-{
- int i;
-
- if (serial98_ports[0].type == PORT_19K_PC98
- || serial98_ports[0].type == PORT_FIFO_PC98)
- outb(serial98_ports[0].ext, SERIAL98_EXT);
-
- for (i = 0; i < SERIAL98_NR; i++) {
- uart_remove_one_port(&serial98_reg,
- (struct uart_port *)&serial98_ports[i]);
- }
-
- uart_unregister_driver(&serial98_reg);
-}
-
-module_init(serial98_init);
-module_exit(serial98_exit);
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_DESCRIPTION("PC-9801 standard serial port driver Version 0.1alpha");
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * drivers/usb/core/driverfs.c
- *
- * (C) Copyright 2002 David Brownell
- * (C) Copyright 2002 Greg Kroah-Hartman
- * (C) Copyright 2002 IBM Corp.
- *
- * All of the driverfs file attributes for usb devices and interfaces.
- *
- */
-
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-
-#ifdef CONFIG_USB_DEBUG
- #define DEBUG
-#else
- #undef DEBUG
-#endif
-#include <linux/usb.h>
-
-#include "usb.h"
-
-/* Active configuration fields */
-#define usb_actconfig_show(field, multiplier, format_string) \
-static ssize_t show_##field (struct device *dev, char *buf) \
-{ \
- struct usb_device *udev; \
- \
- udev = to_usb_device (dev); \
- if (udev->actconfig) \
- return sprintf (buf, format_string, \
- udev->actconfig->desc.field * multiplier); \
- else \
- return 0; \
-} \
-
-#define usb_actconfig_attr(field, multiplier, format_string) \
-usb_actconfig_show(field, multiplier, format_string) \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_actconfig_attr (bNumInterfaces, 1, "%2d\n")
-usb_actconfig_attr (bmAttributes, 1, "%2x\n")
-usb_actconfig_attr (bMaxPower, 2, "%3dmA\n")
-
-/* configuration value is always present, and r/w */
-usb_actconfig_show(bConfigurationValue, 1, "%u\n");
-
-static ssize_t
-set_bConfigurationValue (struct device *dev, const char *buf, size_t count)
-{
- struct usb_device *udev = udev = to_usb_device (dev);
- int config, value;
-
- if (sscanf (buf, "%u", &config) != 1 || config > 255)
- return -EINVAL;
- down(&udev->serialize);
- value = usb_set_configuration (udev, config);
- up(&udev->serialize);
- return (value < 0) ? value : count;
-}
-
-static DEVICE_ATTR(bConfigurationValue, S_IRUGO | S_IWUSR,
- show_bConfigurationValue, set_bConfigurationValue);
-
-/* String fields */
-#define usb_string_attr(name, field) \
-static ssize_t show_##name(struct device *dev, char *buf) \
-{ \
- struct usb_device *udev; \
- int len; \
- \
- udev = to_usb_device (dev); \
- len = usb_string(udev, udev->descriptor.field, buf, PAGE_SIZE); \
- if (len < 0) \
- return 0; \
- buf[len] = '\n'; \
- buf[len+1] = 0; \
- return len+1; \
-} \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
-
-usb_string_attr(product, iProduct);
-usb_string_attr(manufacturer, iManufacturer);
-usb_string_attr(serial, iSerialNumber);
-
-static ssize_t
-show_speed (struct device *dev, char *buf)
-{
- struct usb_device *udev;
- char *speed;
-
- udev = to_usb_device (dev);
-
- switch (udev->speed) {
- case USB_SPEED_LOW:
- speed = "1.5";
- break;
- case USB_SPEED_UNKNOWN:
- case USB_SPEED_FULL:
- speed = "12";
- break;
- case USB_SPEED_HIGH:
- speed = "480";
- break;
- default:
- speed = "unknown";
- }
- return sprintf (buf, "%s\n", speed);
-}
-static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
-
-static ssize_t
-show_devnum (struct device *dev, char *buf)
-{
- struct usb_device *udev;
-
- udev = to_usb_device (dev);
- return sprintf (buf, "%d\n", udev->devnum);
-}
-static DEVICE_ATTR(devnum, S_IRUGO, show_devnum, NULL);
-
-static ssize_t
-show_version (struct device *dev, char *buf)
-{
- struct usb_device *udev;
-
- udev = to_usb_device (dev);
- return sprintf (buf, "%2x.%02x\n", udev->descriptor.bcdUSB >> 8,
- udev->descriptor.bcdUSB & 0xff);
-}
-static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
-
-static ssize_t
-show_maxchild (struct device *dev, char *buf)
-{
- struct usb_device *udev;
-
- udev = to_usb_device (dev);
- return sprintf (buf, "%d\n", udev->maxchild);
-}
-static DEVICE_ATTR(maxchild, S_IRUGO, show_maxchild, NULL);
-
-/* Descriptor fields */
-#define usb_descriptor_attr(field, format_string) \
-static ssize_t \
-show_##field (struct device *dev, char *buf) \
-{ \
- struct usb_device *udev; \
- \
- udev = to_usb_device (dev); \
- return sprintf (buf, format_string, udev->descriptor.field); \
-} \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_descriptor_attr (idVendor, "%04x\n")
-usb_descriptor_attr (idProduct, "%04x\n")
-usb_descriptor_attr (bcdDevice, "%04x\n")
-usb_descriptor_attr (bDeviceClass, "%02x\n")
-usb_descriptor_attr (bDeviceSubClass, "%02x\n")
-usb_descriptor_attr (bDeviceProtocol, "%02x\n")
-usb_descriptor_attr (bNumConfigurations, "%d\n")
-
-
-void usb_create_driverfs_dev_files (struct usb_device *udev)
-{
- struct device *dev = &udev->dev;
-
- /* current configuration's attributes */
- device_create_file (dev, &dev_attr_bNumInterfaces);
- device_create_file (dev, &dev_attr_bConfigurationValue);
- device_create_file (dev, &dev_attr_bmAttributes);
- device_create_file (dev, &dev_attr_bMaxPower);
-
- /* device attributes */
- device_create_file (dev, &dev_attr_idVendor);
- device_create_file (dev, &dev_attr_idProduct);
- device_create_file (dev, &dev_attr_bcdDevice);
- device_create_file (dev, &dev_attr_bDeviceClass);
- device_create_file (dev, &dev_attr_bDeviceSubClass);
- device_create_file (dev, &dev_attr_bDeviceProtocol);
- device_create_file (dev, &dev_attr_bNumConfigurations);
-
- /* speed varies depending on how you connect the device */
- device_create_file (dev, &dev_attr_speed);
- // FIXME iff there are other speed configs, show how many
-
- if (udev->descriptor.iManufacturer)
- device_create_file (dev, &dev_attr_manufacturer);
- if (udev->descriptor.iProduct)
- device_create_file (dev, &dev_attr_product);
- if (udev->descriptor.iSerialNumber)
- device_create_file (dev, &dev_attr_serial);
-
- device_create_file (dev, &dev_attr_devnum);
- device_create_file (dev, &dev_attr_version);
- device_create_file (dev, &dev_attr_maxchild);
-}
-
-/* Interface fields */
-#define usb_intf_attr(field, format_string) \
-static ssize_t \
-show_##field (struct device *dev, char *buf) \
-{ \
- struct usb_interface *intf = to_usb_interface (dev); \
- \
- return sprintf (buf, format_string, intf->cur_altsetting->desc.field); \
-} \
-static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
-
-usb_intf_attr (bInterfaceNumber, "%02x\n")
-usb_intf_attr (bAlternateSetting, "%2d\n")
-usb_intf_attr (bNumEndpoints, "%02x\n")
-usb_intf_attr (bInterfaceClass, "%02x\n")
-usb_intf_attr (bInterfaceSubClass, "%02x\n")
-usb_intf_attr (bInterfaceProtocol, "%02x\n")
-usb_intf_attr (iInterface, "%02x\n")
-
-void usb_create_driverfs_intf_files (struct usb_interface *intf)
-{
- device_create_file (&intf->dev, &dev_attr_bInterfaceNumber);
- device_create_file (&intf->dev, &dev_attr_bAlternateSetting);
- device_create_file (&intf->dev, &dev_attr_bNumEndpoints);
- device_create_file (&intf->dev, &dev_attr_bInterfaceClass);
- device_create_file (&intf->dev, &dev_attr_bInterfaceSubClass);
- device_create_file (&intf->dev, &dev_attr_bInterfaceProtocol);
- device_create_file (&intf->dev, &dev_attr_iInterface);
-}
+++ /dev/null
-/*
- * linux/drivers/usb/host/ohci-omap.h
- *
- * OMAP OHCI USB controller specific defines
- */
-
-/* OMAP USB OHCI common defines */
-#define OMAP_OHCI_NAME "omap-ohci"
-#define OMAP_OHCI_BASE 0xfffba000
-#define OMAP_OHCI_SIZE 4096
-
-#define HMC_CLEAR (0x3f << 1)
-#define APLL_NDPLL_SWITCH 0x0001
-#define DPLL_PLL_ENABLE 0x0010
-#define DPLL_LOCK 0x0001
-#define SOFT_REQ_REG_REQ 0x0001
-#define USB_MCLK_EN 0x0010
-#define USB_HOST_HHC_UHOST_EN 0x00000200
-#define SOFT_USB_OTG_REQ (1 << 8)
-#define SOFT_USB_REQ (1 << 3)
-#define STATUS_REQ_REG 0xfffe0840
-#define USB_HOST_DPLL_REQ (1 << 8)
-#define SOFT_DPLL_REQ (1 << 0)
-
-/* OMAP-1510 USB OHCI defines */
-#define OMAP1510_LB_MEMSIZE 32 /* Should be same as SDRAM size */
-#define OMAP1510_LB_CLOCK_DIV 0xfffec10c
-#define OMAP1510_LB_MMU_CTL 0xfffec208
-#define OMAP1510_LB_MMU_LCK 0xfffec224
-#define OMAP1510_LB_MMU_LD_TLB 0xfffec228
-#define OMAP1510_LB_MMU_CAM_H 0xfffec22c
-#define OMAP1510_LB_MMU_CAM_L 0xfffec230
-#define OMAP1510_LB_MMU_RAM_H 0xfffec234
-#define OMAP1510_LB_MMU_RAM_L 0xfffec238
-
-/* OMAP-1610 USB OHCI defines */
-#define USB_TRANSCEIVER_CTRL 0xfffe1064
-#define OTG_REV 0xfffb0400
-
-#define OTG_SYSCON_1 0xfffb0404
-#define OTG_IDLE_EN (1 << 15)
-#define DEV_IDLE_EN (1 << 13)
-
-#define OTG_SYSCON_2 0xfffb0408
-#define OTG_CTRL 0xfffb040c
-#define OTG_IRQ_EN 0xfffb0410
-#define OTG_IRQ_SRC 0xfffb0414
-
-#define OTG_EN (1 << 31)
-#define USBX_SYNCHRO (1 << 30)
-#define SRP_VBUS (1 << 12)
-#define OTG_PADEN (1 << 10)
-#define HMC_PADEN (1 << 9)
-#define UHOST_EN (1 << 8)
-
-/* Hardware specific defines */
-#define OMAP1510_FPGA_HOST_CTRL 0xe800020c
+++ /dev/null
-/* Driver for Philips webcam
- Functions that send various control messages to the webcam, including
- video modes.
- (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-/*
- Changes
- 2001/08/03 Alvarado Added methods for changing white balance and
- red/green gains
- */
-
-/* Control functions for the cam; brightness, contrast, video mode, etc. */
-
-#ifdef __KERNEL__
-#include <asm/uaccess.h>
-#endif
-#include <asm/errno.h>
-#include <linux/version.h>
-
-#include "pwc.h"
-#include "pwc-ioctl.h"
-#include "pwc-uncompress.h"
-
-/* Request types: video */
-#define SET_LUM_CTL 0x01
-#define GET_LUM_CTL 0x02
-#define SET_CHROM_CTL 0x03
-#define GET_CHROM_CTL 0x04
-#define SET_STATUS_CTL 0x05
-#define GET_STATUS_CTL 0x06
-#define SET_EP_STREAM_CTL 0x07
-#define GET_EP_STREAM_CTL 0x08
-#define SET_MPT_CTL 0x0D
-#define GET_MPT_CTL 0x0E
-
-/* Selectors for the Luminance controls [GS]ET_LUM_CTL */
-#define AGC_MODE_FORMATTER 0x2000
-#define PRESET_AGC_FORMATTER 0x2100
-#define SHUTTER_MODE_FORMATTER 0x2200
-#define PRESET_SHUTTER_FORMATTER 0x2300
-#define PRESET_CONTOUR_FORMATTER 0x2400
-#define AUTO_CONTOUR_FORMATTER 0x2500
-#define BACK_LIGHT_COMPENSATION_FORMATTER 0x2600
-#define CONTRAST_FORMATTER 0x2700
-#define DYNAMIC_NOISE_CONTROL_FORMATTER 0x2800
-#define FLICKERLESS_MODE_FORMATTER 0x2900
-#define AE_CONTROL_SPEED 0x2A00
-#define BRIGHTNESS_FORMATTER 0x2B00
-#define GAMMA_FORMATTER 0x2C00
-
-/* Selectors for the Chrominance controls [GS]ET_CHROM_CTL */
-#define WB_MODE_FORMATTER 0x1000
-#define AWB_CONTROL_SPEED_FORMATTER 0x1100
-#define AWB_CONTROL_DELAY_FORMATTER 0x1200
-#define PRESET_MANUAL_RED_GAIN_FORMATTER 0x1300
-#define PRESET_MANUAL_BLUE_GAIN_FORMATTER 0x1400
-#define COLOUR_MODE_FORMATTER 0x1500
-#define SATURATION_MODE_FORMATTER1 0x1600
-#define SATURATION_MODE_FORMATTER2 0x1700
-
-/* Selectors for the Status controls [GS]ET_STATUS_CTL */
-#define SAVE_USER_DEFAULTS_FORMATTER 0x0200
-#define RESTORE_USER_DEFAULTS_FORMATTER 0x0300
-#define RESTORE_FACTORY_DEFAULTS_FORMATTER 0x0400
-#define READ_AGC_FORMATTER 0x0500
-#define READ_SHUTTER_FORMATTER 0x0600
-#define READ_RED_GAIN_FORMATTER 0x0700
-#define READ_BLUE_GAIN_FORMATTER 0x0800
-#define SENSOR_TYPE_FORMATTER1 0x0C00
-#define READ_RAW_Y_MEAN_FORMATTER 0x3100
-#define SET_POWER_SAVE_MODE_FORMATTER 0x3200
-#define MIRROR_IMAGE_FORMATTER 0x3300
-#define LED_FORMATTER 0x3400
-#define SENSOR_TYPE_FORMATTER2 0x3700
-
-/* Formatters for the Video Endpoint controls [GS]ET_EP_STREAM_CTL */
-#define VIDEO_OUTPUT_CONTROL_FORMATTER 0x0100
-
-/* Formatters for the motorized pan & tilt [GS]ET_MPT_CTL */
-#define PT_RELATIVE_CONTROL_FORMATTER 0x01
-#define PT_RESET_CONTROL_FORMATTER 0x02
-#define PT_STATUS_FORMATTER 0x03
-
-static char *size2name[PSZ_MAX] =
-{
- "subQCIF",
- "QSIF",
- "QCIF",
- "SIF",
- "CIF",
- "VGA",
-};
-
-/********/
-
-/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
- preferences, so you either get compressed or non-compressed streams.
-
- An alternate value of 0 means this mode is not available at all.
- */
-
-struct Nala_table_entry {
- char alternate; /* USB alternate setting */
- int compressed; /* Compressed yes/no */
-
- unsigned char mode[3]; /* precomputed mode table */
-};
-
-static struct Nala_table_entry Nala_table[PSZ_MAX][8] =
-{
-#include "pwc_nala.h"
-};
-
-/* This tables contains entries for the 675/680/690 (Timon) camera, with
- 4 different qualities (no compression, low, medium, high).
- It lists the bandwidth requirements for said mode by its alternate interface
- number. An alternate of 0 means that the mode is unavailable.
-
- There are 6 * 4 * 4 entries:
- 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
- 6 framerates: 5, 10, 15, 20, 25, 30
- 4 compression modi: none, low, medium, high
-
- When an uncompressed mode is not available, the next available compressed mode
- will be chosen (unless the decompressor is absent). Sometimes there are only
- 1 or 2 compressed modes available; in that case entries are duplicated.
-*/
-struct Timon_table_entry
-{
- char alternate; /* USB alternate interface */
- unsigned short packetsize; /* Normal packet size */
- unsigned short bandlength; /* Bandlength when decompressing */
- unsigned char mode[13]; /* precomputed mode settings for cam */
-};
-
-static struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
-{
-#include "pwc_timon.h"
-};
-
-/* Entries for the Kiara (730/740/750) camera */
-
-struct Kiara_table_entry
-{
- char alternate; /* USB alternate interface */
- unsigned short packetsize; /* Normal packet size */
- unsigned short bandlength; /* Bandlength when decompressing */
- unsigned char mode[12]; /* precomputed mode settings for cam */
-};
-
-static struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
-{
-#include "pwc_kiara.h"
-};
-
-
-/****************************************************************************/
-
-
-#define SendControlMsg(request, value, buflen) \
- usb_control_msg(pdev->udev, usb_sndctrlpipe(pdev->udev, 0), \
- request, \
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, \
- value, \
- pdev->vcinterface, \
- &buf, buflen, HZ / 2)
-
-#define RecvControlMsg(request, value, buflen) \
- usb_control_msg(pdev->udev, usb_rcvctrlpipe(pdev->udev, 0), \
- request, \
- USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, \
- value, \
- pdev->vcinterface, \
- &buf, buflen, HZ / 2)
-
-
-#if PWC_DEBUG
-void pwc_hexdump(void *p, int len)
-{
- int i;
- unsigned char *s;
- char buf[100], *d;
-
- s = (unsigned char *)p;
- d = buf;
- *d = '\0';
- Debug("Doing hexdump @ %p, %d bytes.\n", p, len);
- for (i = 0; i < len; i++) {
- d += sprintf(d, "%02X ", *s++);
- if ((i & 0xF) == 0xF) {
- Debug("%s\n", buf);
- d = buf;
- *d = '\0';
- }
- }
- if ((i & 0xF) != 0)
- Debug("%s\n", buf);
-}
-#endif
-
-static inline int send_video_command(struct usb_device *udev, int index, void *buf, int buflen)
-{
- return usb_control_msg(udev,
- usb_sndctrlpipe(udev, 0),
- SET_EP_STREAM_CTL,
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- VIDEO_OUTPUT_CONTROL_FORMATTER,
- index,
- buf, buflen, HZ);
-}
-
-
-
-static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
-{
- unsigned char buf[3];
- int ret, fps;
- struct Nala_table_entry *pEntry;
- int frames2frames[31] =
- { /* closest match of framerate */
- 0, 0, 0, 0, 4, /* 0-4 */
- 5, 5, 7, 7, 10, /* 5-9 */
- 10, 10, 12, 12, 15, /* 10-14 */
- 15, 15, 15, 20, 20, /* 15-19 */
- 20, 20, 20, 24, 24, /* 20-24 */
- 24, 24, 24, 24, 24, /* 25-29 */
- 24 /* 30 */
- };
- int frames2table[31] =
- { 0, 0, 0, 0, 0, /* 0-4 */
- 1, 1, 1, 2, 2, /* 5-9 */
- 3, 3, 4, 4, 4, /* 10-14 */
- 5, 5, 5, 5, 5, /* 15-19 */
- 6, 6, 6, 6, 7, /* 20-24 */
- 7, 7, 7, 7, 7, /* 25-29 */
- 7 /* 30 */
- };
-
- if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25)
- return -EINVAL;
- frames = frames2frames[frames];
- fps = frames2table[frames];
- pEntry = &Nala_table[size][fps];
- if (pEntry->alternate == 0)
- return -EINVAL;
-
- if (pEntry->compressed && pdev->decompressor == NULL)
- return -ENOENT; /* Not supported. */
-
- memcpy(buf, pEntry->mode, 3);
- ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3);
- if (ret < 0) {
- Debug("Failed to send video command... %d\n", ret);
- return ret;
- }
- if (pEntry->compressed && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
- pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
-
- pdev->cmd_len = 3;
- memcpy(pdev->cmd_buf, buf, 3);
-
- /* Set various parameters */
- pdev->vframes = frames;
- pdev->vsize = size;
- pdev->valternate = pEntry->alternate;
- pdev->image = pwc_image_sizes[size];
- pdev->frame_size = (pdev->image.x * pdev->image.y * 3) / 2;
- if (pEntry->compressed) {
- if (pdev->release < 5) { /* 4 fold compression */
- pdev->vbandlength = 528;
- pdev->frame_size /= 4;
- }
- else {
- pdev->vbandlength = 704;
- pdev->frame_size /= 3;
- }
- }
- else
- pdev->vbandlength = 0;
- return 0;
-}
-
-
-static inline int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, int compression, int snapshot)
-{
- unsigned char buf[13];
- struct Timon_table_entry *pChoose;
- int ret, fps;
-
- if (size >= PSZ_MAX || frames < 5 || frames > 30 || compression < 0 || compression > 3)
- return -EINVAL;
- if (size == PSZ_VGA && frames > 15)
- return -EINVAL;
- fps = (frames / 5) - 1;
-
- /* Find a supported framerate with progressively higher compression ratios
- if the preferred ratio is not available.
- */
- pChoose = NULL;
- if (pdev->decompressor == NULL) {
-#if PWC_DEBUG
- Debug("Trying to find uncompressed mode.\n");
-#endif
- pChoose = &Timon_table[size][fps][0];
- }
- else {
- while (compression <= 3) {
- pChoose = &Timon_table[size][fps][compression];
- if (pChoose->alternate != 0)
- break;
- compression++;
- }
- }
- if (pChoose == NULL || pChoose->alternate == 0)
- return -ENOENT; /* Not supported. */
-
- memcpy(buf, pChoose->mode, 13);
- if (snapshot)
- buf[0] |= 0x80;
- ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 13);
- if (ret < 0)
- return ret;
-
- if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
- pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
-
- pdev->cmd_len = 13;
- memcpy(pdev->cmd_buf, buf, 13);
-
- /* Set various parameters */
- pdev->vframes = frames;
- pdev->vsize = size;
- pdev->vsnapshot = snapshot;
- pdev->valternate = pChoose->alternate;
- pdev->image = pwc_image_sizes[size];
- pdev->vbandlength = pChoose->bandlength;
- if (pChoose->bandlength > 0)
- pdev->frame_size = (pChoose->bandlength * pdev->image.y) / 4;
- else
- pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8;
- return 0;
-}
-
-
-static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, int compression, int snapshot)
-{
- struct Kiara_table_entry *pChoose = NULL;
- int fps, ret;
- unsigned char buf[12];
- struct Kiara_table_entry RawEntry = {6, 773, 1272, {0xAD, 0xF4, 0x10, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}};
-
- if (size >= PSZ_MAX || frames < 5 || frames > 30 || compression < 0 || compression > 3)
- return -EINVAL;
- if (size == PSZ_VGA && frames > 15)
- return -EINVAL;
- fps = (frames / 5) - 1;
-
- /* special case: VGA @ 5 fps and snapshot is raw bayer mode */
- if (size == PSZ_VGA && frames == 5 && snapshot)
- {
- /* Only available in case the raw palette is selected or
- we have the decompressor available. This mode is
- only available in compressed form
- */
- if (pdev->vpalette == VIDEO_PALETTE_RAW || pdev->decompressor != NULL)
- {
- Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
- pChoose = &RawEntry;
- }
- else
- {
- Info("VGA/5 BAYER mode _must_ have a decompressor available, or use RAW palette.\n");
- }
- }
- else
- {
- /* Find a supported framerate with progressively higher compression ratios
- if the preferred ratio is not available.
- Skip this step when using RAW modes.
- */
- if (pdev->decompressor == NULL && pdev->vpalette != VIDEO_PALETTE_RAW) {
-#if PWC_DEBUG
- Debug("Trying to find uncompressed mode.\n");
-#endif
- pChoose = &Kiara_table[size][fps][0];
- }
- else {
- while (compression <= 3) {
- pChoose = &Kiara_table[size][fps][compression];
- if (pChoose->alternate != 0)
- break;
- compression++;
- }
- }
- }
- if (pChoose == NULL || pChoose->alternate == 0)
- return -ENOENT; /* Not supported. */
-
- /* usb_control_msg won't take staticly allocated arrays as argument?? */
- memcpy(buf, pChoose->mode, 12);
- if (snapshot)
- buf[0] |= 0x80;
-
- /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */
- ret = send_video_command(pdev->udev, 4 /* pdev->vendpoint */, buf, 12);
- if (ret < 0)
- return ret;
-
- if (pChoose->bandlength > 0 && pdev->decompressor != 0 && pdev->vpalette != VIDEO_PALETTE_RAW)
- pdev->decompressor->init(pdev->type, pdev->release, buf, pdev->decompress_data);
-
- pdev->cmd_len = 12;
- memcpy(pdev->cmd_buf, buf, 12);
- /* All set and go */
- pdev->vframes = frames;
- pdev->vsize = size;
- pdev->vsnapshot = snapshot;
- pdev->valternate = pChoose->alternate;
- pdev->image = pwc_image_sizes[size];
- pdev->vbandlength = pChoose->bandlength;
- if (pdev->vbandlength > 0)
- pdev->frame_size = (pdev->vbandlength * pdev->image.y) / 4;
- else
- pdev->frame_size = (pdev->image.x * pdev->image.y * 12) / 8;
- return 0;
-}
-
-
-
-/**
- @pdev: device structure
- @width: viewport width
- @height: viewport height
- @frame: framerate, in fps
- @compression: preferred compression ratio
- @snapshot: snapshot mode or streaming
- */
-int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
-{
- int ret, size;
-
- Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
- size = pwc_decode_size(pdev, width, height);
- if (size < 0) {
- Debug("Could not find suitable size.\n");
- return -ERANGE;
- }
- Debug("decode_size = %d.\n", size);
-
- ret = -EINVAL;
- switch(pdev->type) {
- case 645:
- case 646:
- ret = set_video_mode_Nala(pdev, size, frames);
- break;
-
- case 675:
- case 680:
- case 690:
- ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot);
- break;
-
- case 720:
- case 730:
- case 740:
- case 750:
- ret = set_video_mode_Kiara(pdev, size, frames, compression, snapshot);
- break;
- }
- if (ret < 0) {
- if (ret == -ENOENT)
- Info("Video mode %s@%d fps is only supported with the decompressor module (pwcx).\n", size2name[size], frames);
- else {
- Err("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
- }
- return ret;
- }
- pdev->view.x = width;
- pdev->view.y = height;
- pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size;
- pwc_set_image_buffer_size(pdev);
- Trace(TRACE_SIZE, "Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y);
- return 0;
-}
-
-
-void pwc_set_image_buffer_size(struct pwc_device *pdev)
-{
- int i, factor = 0, filler = 0;
-
- /* for PALETTE_YUV420P */
- switch(pdev->vpalette)
- {
- case VIDEO_PALETTE_YUV420P:
- factor = 6;
- filler = 128;
- break;
- case VIDEO_PALETTE_RAW:
- factor = 6; /* can be uncompressed YUV420P */
- filler = 0;
- break;
- }
-
- /* Set sizes in bytes */
- pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
- pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
-
- /* Align offset, or you'll get some very weird results in
- YUV420 mode... x must be multiple of 4 (to get the Y's in
- place), and y even (or you'll mixup U & V). This is less of a
- problem for YUV420P.
- */
- pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
- pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
-
- /* Fill buffers with gray or black */
- for (i = 0; i < MAX_IMAGES; i++) {
- if (pdev->image_ptr[i] != NULL)
- memset(pdev->image_ptr[i], filler, pdev->view.size);
- }
-}
-
-
-
-/* BRIGHTNESS */
-
-int pwc_get_brightness(struct pwc_device *pdev)
-{
- char buf;
- int ret;
-
- ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
- if (ret < 0)
- return ret;
- return buf << 9;
-}
-
-int pwc_set_brightness(struct pwc_device *pdev, int value)
-{
- char buf;
-
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- buf = (value >> 9) & 0x7f;
- return SendControlMsg(SET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
-}
-
-/* CONTRAST */
-
-int pwc_get_contrast(struct pwc_device *pdev)
-{
- char buf;
- int ret;
-
- ret = RecvControlMsg(GET_LUM_CTL, CONTRAST_FORMATTER, 1);
- if (ret < 0)
- return ret;
- return buf << 10;
-}
-
-int pwc_set_contrast(struct pwc_device *pdev, int value)
-{
- char buf;
-
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- buf = (value >> 10) & 0x3f;
- return SendControlMsg(SET_LUM_CTL, CONTRAST_FORMATTER, 1);
-}
-
-/* GAMMA */
-
-int pwc_get_gamma(struct pwc_device *pdev)
-{
- char buf;
- int ret;
-
- ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1);
- if (ret < 0)
- return ret;
- return buf << 11;
-}
-
-int pwc_set_gamma(struct pwc_device *pdev, int value)
-{
- char buf;
-
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- buf = (value >> 11) & 0x1f;
- return SendControlMsg(SET_LUM_CTL, GAMMA_FORMATTER, 1);
-}
-
-
-/* SATURATION */
-
-int pwc_get_saturation(struct pwc_device *pdev)
-{
- char buf;
- int ret;
-
- if (pdev->type < 675)
- return -1;
- ret = RecvControlMsg(GET_CHROM_CTL, pdev->type < 730 ? SATURATION_MODE_FORMATTER2 : SATURATION_MODE_FORMATTER1, 1);
- if (ret < 0)
- return ret;
- return 32768 + buf * 327;
-}
-
-int pwc_set_saturation(struct pwc_device *pdev, int value)
-{
- char buf;
-
- if (pdev->type < 675)
- return -EINVAL;
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- /* saturation ranges from -100 to +100 */
- buf = (value - 32768) / 327;
- return SendControlMsg(SET_CHROM_CTL, pdev->type < 730 ? SATURATION_MODE_FORMATTER2 : SATURATION_MODE_FORMATTER1, 1);
-}
-
-/* AGC */
-
-static inline int pwc_set_agc(struct pwc_device *pdev, int mode, int value)
-{
- char buf;
- int ret;
-
- if (mode)
- buf = 0x0; /* auto */
- else
- buf = 0xff; /* fixed */
-
- ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1);
-
- if (!mode && ret >= 0) {
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- buf = (value >> 10) & 0x3F;
- ret = SendControlMsg(SET_LUM_CTL, PRESET_AGC_FORMATTER, 1);
- }
- if (ret < 0)
- return ret;
- return 0;
-}
-
-static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1);
- if (ret < 0)
- return ret;
-
- if (buf != 0) { /* fixed */
- ret = RecvControlMsg(GET_LUM_CTL, PRESET_AGC_FORMATTER, 1);
- if (ret < 0)
- return ret;
- if (buf > 0x3F)
- buf = 0x3F;
- *value = (buf << 10);
- }
- else { /* auto */
- ret = RecvControlMsg(GET_STATUS_CTL, READ_AGC_FORMATTER, 1);
- if (ret < 0)
- return ret;
- /* Gah... this value ranges from 0x00 ... 0x9F */
- if (buf > 0x9F)
- buf = 0x9F;
- *value = -(48 + buf * 409);
- }
-
- return 0;
-}
-
-static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int value)
-{
- char buf[2];
- int speed, ret;
-
-
- if (mode)
- buf[0] = 0x0; /* auto */
- else
- buf[0] = 0xff; /* fixed */
-
- ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1);
-
- if (!mode && ret >= 0) {
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- switch(pdev->type) {
- case 675:
- case 680:
- case 690:
- /* speed ranges from 0x0 to 0x290 (656) */
- speed = (value / 100);
- buf[1] = speed >> 8;
- buf[0] = speed & 0xff;
- break;
- case 720:
- case 730:
- case 740:
- case 750:
- /* speed seems to range from 0x0 to 0xff */
- buf[1] = 0;
- buf[0] = value >> 8;
- break;
- }
-
- ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2);
- }
- return ret;
-}
-
-
-/* POWER */
-
-int pwc_camera_power(struct pwc_device *pdev, int power)
-{
- char buf;
-
- if (pdev->type < 675 || (pdev->type < 730 && pdev->release < 6))
- return 0; /* Not supported by Nala or Timon < release 6 */
-
- if (power)
- buf = 0x00; /* active */
- else
- buf = 0xFF; /* power save */
- return SendControlMsg(SET_STATUS_CTL, SET_POWER_SAVE_MODE_FORMATTER, 1);
-}
-
-
-
-/* private calls */
-
-static inline int pwc_restore_user(struct pwc_device *pdev)
-{
- char buf; /* dummy */
- return SendControlMsg(SET_STATUS_CTL, RESTORE_USER_DEFAULTS_FORMATTER, 0);
-}
-
-static inline int pwc_save_user(struct pwc_device *pdev)
-{
- char buf; /* dummy */
- return SendControlMsg(SET_STATUS_CTL, SAVE_USER_DEFAULTS_FORMATTER, 0);
-}
-
-static inline int pwc_restore_factory(struct pwc_device *pdev)
-{
- char buf; /* dummy */
- return SendControlMsg(SET_STATUS_CTL, RESTORE_FACTORY_DEFAULTS_FORMATTER, 0);
-}
-
- /* ************************************************* */
- /* Patch by Alvarado: (not in the original version */
-
- /*
- * the camera recognizes modes from 0 to 4:
- *
- * 00: indoor (incandescant lighting)
- * 01: outdoor (sunlight)
- * 02: fluorescent lighting
- * 03: manual
- * 04: auto
- */
-static inline int pwc_set_awb(struct pwc_device *pdev, int mode)
-{
- char buf;
- int ret;
-
- if (mode < 0)
- mode = 0;
-
- if (mode > 4)
- mode = 4;
-
- buf = mode & 0x07; /* just the lowest three bits */
-
- ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1);
-
- if (ret < 0)
- return ret;
- return 0;
-}
-
-static inline int pwc_get_awb(struct pwc_device *pdev)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1);
-
- if (ret < 0)
- return ret;
- return buf;
-}
-
-static inline int pwc_set_red_gain(struct pwc_device *pdev, int value)
-{
- unsigned char buf;
-
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- /* only the msb is considered */
- buf = value >> 8;
- return SendControlMsg(SET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1);
-}
-
-static inline int pwc_get_red_gain(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf << 8;
- return 0;
-}
-
-
-static inline int pwc_set_blue_gain(struct pwc_device *pdev, int value)
-{
- unsigned char buf;
-
- if (value < 0)
- value = 0;
- if (value > 0xffff)
- value = 0xffff;
- /* only the msb is considered */
- buf = value >> 8;
- return SendControlMsg(SET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1);
-}
-
-static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf << 8;
- return 0;
-}
-
-
-/* The following two functions are different, since they only read the
- internal red/blue gains, which may be different from the manual
- gains set or read above.
- */
-static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf << 8;
- return 0;
-}
-
-static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf << 8;
- return 0;
-}
-
-
-static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed)
-{
- unsigned char buf;
-
- /* useful range is 0x01..0x20 */
- buf = speed / 0x7f0;
- return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
-}
-
-static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf * 0x7f0;
- return 0;
-}
-
-
-static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay)
-{
- unsigned char buf;
-
- /* useful range is 0x01..0x3F */
- buf = (delay >> 10);
- return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
-}
-
-static inline int pwc_get_wb_delay(struct pwc_device *pdev, int *value)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *value = buf << 10;
- return 0;
-}
-
-
-int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
-{
- unsigned char buf[2];
-
- if (pdev->type < 730)
- return 0;
- on_value /= 100;
- off_value /= 100;
- if (on_value < 0)
- on_value = 0;
- if (on_value > 0xff)
- on_value = 0xff;
- if (off_value < 0)
- off_value = 0;
- if (off_value > 0xff)
- off_value = 0xff;
-
- buf[0] = on_value;
- buf[1] = off_value;
-
- return SendControlMsg(SET_STATUS_CTL, LED_FORMATTER, 2);
-}
-
-int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
-{
- unsigned char buf[2];
- int ret;
-
- if (pdev->type < 730) {
- *on_value = -1;
- *off_value = -1;
- return 0;
- }
-
- ret = RecvControlMsg(GET_STATUS_CTL, LED_FORMATTER, 2);
- if (ret < 0)
- return ret;
- *on_value = buf[0] * 100;
- *off_value = buf[1] * 100;
- return 0;
-}
-
-static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
-{
- unsigned char buf;
- int ret;
-
- if (contour < 0)
- buf = 0xff; /* auto contour on */
- else
- buf = 0x0; /* auto contour off */
- ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
- if (ret < 0)
- return ret;
-
- if (contour < 0)
- return 0;
- if (contour > 0xffff)
- contour = 0xffff;
-
- buf = (contour >> 10); /* contour preset is [0..3f] */
- ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
- if (ret < 0)
- return ret;
- return 0;
-}
-
-static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
-{
- unsigned char buf;
- int ret;
-
- ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
- if (ret < 0)
- return ret;
-
- if (buf == 0) {
- /* auto mode off, query current preset value */
- ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *contour = buf << 10;
- }
- else
- *contour = -1;
- return 0;
-}
-
-
-static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight)
-{
- unsigned char buf;
-
- if (backlight)
- buf = 0xff;
- else
- buf = 0x0;
- return SendControlMsg(SET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1);
-}
-
-static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
-{
- int ret;
- unsigned char buf;
-
- ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *backlight = buf;
- return 0;
-}
-
-
-static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker)
-{
- unsigned char buf;
-
- if (flicker)
- buf = 0xff;
- else
- buf = 0x0;
- return SendControlMsg(SET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1);
-}
-
-static inline int pwc_get_flicker(struct pwc_device *pdev, int *flicker)
-{
- int ret;
- unsigned char buf;
-
- ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *flicker = buf;
- return 0;
-}
-
-
-static inline int pwc_set_dynamic_noise(struct pwc_device *pdev, int noise)
-{
- unsigned char buf;
-
- if (noise < 0)
- noise = 0;
- if (noise > 3)
- noise = 3;
- buf = noise;
- return SendControlMsg(SET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1);
-}
-
-static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
-{
- int ret;
- unsigned char buf;
-
- ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1);
- if (ret < 0)
- return ret;
- *noise = buf;
- return 0;
-}
-
-int pwc_mpt_reset(struct pwc_device *pdev, int flags)
-{
- unsigned char buf;
-
- buf = flags & 0x03; // only lower two bits are currently used
- return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1);
-}
-
-static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
-{
- unsigned char buf[4];
-
- /* set new relative angle; angles are expressed in degrees * 100,
- but cam as .5 degree resolution, hence devide by 200. Also
- the angle must be multiplied by 64 before it's send to
- the cam (??)
- */
- pan = 64 * pan / 100;
- tilt = -64 * tilt / 100; /* positive tilt is down, which is not what the user would expect */
- buf[0] = pan & 0xFF;
- buf[1] = (pan >> 8) & 0xFF;
- buf[2] = tilt & 0xFF;
- buf[3] = (tilt >> 8) & 0xFF;
- return SendControlMsg(SET_MPT_CTL, PT_RELATIVE_CONTROL_FORMATTER, 4);
-}
-
-static inline int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_status *status)
-{
- int ret;
- unsigned char buf[5];
-
- ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5);
- if (ret < 0)
- return ret;
- status->status = buf[0] & 0x7; // 3 bits are used for reporting
- status->time_pan = (buf[1] << 8) + buf[2];
- status->time_tilt = (buf[3] << 8) + buf[4];
- return 0;
-}
-
-
-int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
-{
- unsigned char buf;
- int ret = -1, request;
-
- if (pdev->type < 675)
- request = SENSOR_TYPE_FORMATTER1;
- else if (pdev->type < 730)
- return -1; /* The Vesta series doesn't have this call */
- else
- request = SENSOR_TYPE_FORMATTER2;
-
- ret = RecvControlMsg(GET_STATUS_CTL, request, 1);
- if (ret < 0)
- return ret;
- if (pdev->type < 675)
- *sensor = buf | 0x100;
- else
- *sensor = buf;
- return 0;
-}
-
-
- /* End of Add-Ons */
- /* ************************************************* */
-
-/* Linux 2.5.something and 2.6 pass direct pointers to arguments of
- ioctl() calls. With 2.4, you have to do tedious copy_from_user()
- and copy_to_user() calls. With these macros we circumvent this,
- and let me maintain only one source file. The functionality is
- exactly the same otherwise.
- */
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
-
-/* define local variable for arg */
-#define ARG_DEF(ARG_type, ARG_name)\
- ARG_type *ARG_name = arg;
-/* copy arg to local variable */
-#define ARG_IN(ARG_name) /* nothing */
-/* argument itself (referenced) */
-#define ARGR(ARG_name) (*ARG_name)
-/* argument address */
-#define ARGA(ARG_name) ARG_name
-/* copy local variable to arg */
-#define ARG_OUT(ARG_name) /* nothing */
-
-#else
-
-#define ARG_DEF(ARG_type, ARG_name)\
- ARG_type ARG_name;
-#define ARG_IN(ARG_name)\
- if (copy_from_user(&ARG_name, arg, sizeof(ARG_name))) {\
- ret = -EFAULT;\
- break;\
- }
-#define ARGR(ARG_name) ARG_name
-#define ARGA(ARG_name) &ARG_name
-#define ARG_OUT(ARG_name)\
- if (copy_to_user(arg, &ARG_name, sizeof(ARG_name))) {\
- ret = -EFAULT;\
- break;\
- }
-
-#endif
-
-int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
-{
- int ret = 0;
-
- switch(cmd) {
- case VIDIOCPWCRUSER:
- {
- if (pwc_restore_user(pdev))
- ret = -EINVAL;
- break;
- }
-
- case VIDIOCPWCSUSER:
- {
- if (pwc_save_user(pdev))
- ret = -EINVAL;
- break;
- }
-
- case VIDIOCPWCFACTORY:
- {
- if (pwc_restore_factory(pdev))
- ret = -EINVAL;
- break;
- }
-
- case VIDIOCPWCSCQUAL:
- {
- ARG_DEF(int, qual)
-
- ARG_IN(qual)
- if (ARGR(qual) < 0 || ARGR(qual) > 3)
- ret = -EINVAL;
- else
- ret = pwc_try_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot);
- if (ret >= 0)
- pdev->vcompression = ARGR(qual);
- break;
- }
-
- case VIDIOCPWCGCQUAL:
- {
- ARG_DEF(int, qual)
-
- ARGR(qual) = pdev->vcompression;
- ARG_OUT(qual)
- break;
- }
-
- case VIDIOCPWCPROBE:
- {
- ARG_DEF(struct pwc_probe, probe)
-
- strcpy(ARGR(probe).name, pdev->vdev->name);
- ARGR(probe).type = pdev->type;
- ARG_OUT(probe)
- break;
- }
-
- case VIDIOCPWCGSERIAL:
- {
- ARG_DEF(struct pwc_serial, serial)
-
- strcpy(ARGR(serial).serial, pdev->serial);
- ARG_OUT(serial)
- break;
- }
-
- case VIDIOCPWCSAGC:
- {
- ARG_DEF(int, agc)
-
- ARG_IN(agc)
- if (pwc_set_agc(pdev, ARGR(agc) < 0 ? 1 : 0, ARGR(agc)))
- ret = -EINVAL;
- break;
- }
-
- case VIDIOCPWCGAGC:
- {
- ARG_DEF(int, agc)
-
- if (pwc_get_agc(pdev, ARGA(agc)))
- ret = -EINVAL;
- ARG_OUT(agc)
- break;
- }
-
- case VIDIOCPWCSSHUTTER:
- {
- ARG_DEF(int, shutter_speed)
-
- ARG_IN(shutter_speed)
- ret = pwc_set_shutter_speed(pdev, ARGR(shutter_speed) < 0 ? 1 : 0, ARGR(shutter_speed));
- break;
- }
-
- case VIDIOCPWCSAWB:
- {
- ARG_DEF(struct pwc_whitebalance, wb)
-
- ARG_IN(wb)
- ret = pwc_set_awb(pdev, ARGR(wb).mode);
- if (ret >= 0 && ARGR(wb).mode == PWC_WB_MANUAL) {
- pwc_set_red_gain(pdev, ARGR(wb).manual_red);
- pwc_set_blue_gain(pdev, ARGR(wb).manual_blue);
- }
- break;
- }
-
- case VIDIOCPWCGAWB:
- {
- ARG_DEF(struct pwc_whitebalance, wb)
-
- memset(ARGA(wb), 0, sizeof(struct pwc_whitebalance));
- ARGR(wb).mode = pwc_get_awb(pdev);
- if (ARGR(wb).mode < 0)
- ret = -EINVAL;
- else {
- if (ARGR(wb).mode == PWC_WB_MANUAL) {
- ret = pwc_get_red_gain(pdev, &ARGR(wb).manual_red);
- if (ret < 0)
- break;
- ret = pwc_get_blue_gain(pdev, &ARGR(wb).manual_blue);
- if (ret < 0)
- break;
- }
- if (ARGR(wb).mode == PWC_WB_AUTO) {
- ret = pwc_read_red_gain(pdev, &ARGR(wb).read_red);
- if (ret < 0)
- break;
- ret =pwc_read_blue_gain(pdev, &ARGR(wb).read_blue);
- if (ret < 0)
- break;
- }
- }
- ARG_OUT(wb)
- break;
- }
-
- case VIDIOCPWCSAWBSPEED:
- {
- ARG_DEF(struct pwc_wb_speed, wbs)
-
- if (ARGR(wbs).control_speed > 0) {
- ret = pwc_set_wb_speed(pdev, ARGR(wbs).control_speed);
- }
- if (ARGR(wbs).control_delay > 0) {
- ret = pwc_set_wb_delay(pdev, ARGR(wbs).control_delay);
- }
- break;
- }
-
- case VIDIOCPWCGAWBSPEED:
- {
- ARG_DEF(struct pwc_wb_speed, wbs)
-
- ret = pwc_get_wb_speed(pdev, &ARGR(wbs).control_speed);
- if (ret < 0)
- break;
- ret = pwc_get_wb_delay(pdev, &ARGR(wbs).control_delay);
- if (ret < 0)
- break;
- ARG_OUT(wbs)
- break;
- }
-
- case VIDIOCPWCSLED:
- {
- ARG_DEF(struct pwc_leds, leds)
-
- ARG_IN(leds)
- ret = pwc_set_leds(pdev, ARGR(leds).led_on, ARGR(leds).led_off);
- break;
- }
-
-
- case VIDIOCPWCGLED:
- {
- ARG_DEF(struct pwc_leds, leds)
-
- ret = pwc_get_leds(pdev, &ARGR(leds).led_on, &ARGR(leds).led_off);
- ARG_OUT(leds)
- break;
- }
-
- case VIDIOCPWCSCONTOUR:
- {
- ARG_DEF(int, contour)
-
- ARG_IN(contour)
- ret = pwc_set_contour(pdev, ARGR(contour));
- break;
- }
-
- case VIDIOCPWCGCONTOUR:
- {
- ARG_DEF(int, contour)
-
- ret = pwc_get_contour(pdev, ARGA(contour));
- ARG_OUT(contour)
- break;
- }
-
- case VIDIOCPWCSBACKLIGHT:
- {
- ARG_DEF(int, backlight)
-
- ARG_IN(backlight)
- ret = pwc_set_backlight(pdev, ARGR(backlight));
- break;
- }
-
- case VIDIOCPWCGBACKLIGHT:
- {
- ARG_DEF(int, backlight)
-
- ret = pwc_get_backlight(pdev, ARGA(backlight));
- ARG_OUT(backlight)
- break;
- }
-
- case VIDIOCPWCSFLICKER:
- {
- ARG_DEF(int, flicker)
-
- ARG_IN(flicker)
- ret = pwc_set_flicker(pdev, ARGR(flicker));
- break;
- }
-
- case VIDIOCPWCGFLICKER:
- {
- ARG_DEF(int, flicker)
-
- ret = pwc_get_flicker(pdev, ARGA(flicker));
- ARG_OUT(flicker)
- break;
- }
-
- case VIDIOCPWCSDYNNOISE:
- {
- ARG_DEF(int, dynnoise)
-
- ARG_IN(dynnoise)
- ret = pwc_set_dynamic_noise(pdev, ARGR(dynnoise));
- break;
- }
-
- case VIDIOCPWCGDYNNOISE:
- {
- ARG_DEF(int, dynnoise)
-
- ret = pwc_get_dynamic_noise(pdev, ARGA(dynnoise));
- ARG_OUT(dynnoise);
- break;
- }
-
- case VIDIOCPWCGREALSIZE:
- {
- ARG_DEF(struct pwc_imagesize, size)
-
- ARGR(size).width = pdev->image.x;
- ARGR(size).height = pdev->image.y;
- ARG_OUT(size)
- break;
- }
-
- case VIDIOCPWCMPTRESET:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- ARG_DEF(int, flags)
-
- ARG_IN(flags)
- ret = pwc_mpt_reset(pdev, ARGR(flags));
- if (ret >= 0)
- {
- pdev->pan_angle = 0;
- pdev->tilt_angle = 0;
- }
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTGRANGE:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- ARG_DEF(struct pwc_mpt_range, range)
-
- ARGR(range) = pdev->angle_range;
- ARG_OUT(range)
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTSANGLE:
- {
- int new_pan, new_tilt;
-
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- ARG_DEF(struct pwc_mpt_angles, angles)
-
- ARG_IN(angles)
- /* The camera can only set relative angles, so
- do some calculations when getting an absolute angle .
- */
- if (ARGR(angles).absolute)
- {
- new_pan = ARGR(angles).pan;
- new_tilt = ARGR(angles).tilt;
- }
- else
- {
- new_pan = pdev->pan_angle + ARGR(angles).pan;
- new_tilt = pdev->tilt_angle + ARGR(angles).tilt;
- }
- /* check absolute ranges */
- if (new_pan < pdev->angle_range.pan_min ||
- new_pan > pdev->angle_range.pan_max ||
- new_tilt < pdev->angle_range.tilt_min ||
- new_tilt > pdev->angle_range.tilt_max)
- {
- ret = -ERANGE;
- }
- else
- {
- /* go to relative range, check again */
- new_pan -= pdev->pan_angle;
- new_tilt -= pdev->tilt_angle;
- /* angles are specified in degrees * 100, thus the limit = 36000 */
- if (new_pan < -36000 || new_pan > 36000 || new_tilt < -36000 || new_tilt > 36000)
- ret = -ERANGE;
- }
- if (ret == 0) /* no errors so far */
- {
- ret = pwc_mpt_set_angle(pdev, new_pan, new_tilt);
- if (ret >= 0)
- {
- pdev->pan_angle += new_pan;
- pdev->tilt_angle += new_tilt;
- }
- if (ret == -EPIPE) /* stall -> out of range */
- ret = -ERANGE;
- }
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTGANGLE:
- {
-
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- ARG_DEF(struct pwc_mpt_angles, angles)
-
- ARGR(angles).absolute = 1;
- ARGR(angles).pan = pdev->pan_angle;
- ARGR(angles).tilt = pdev->tilt_angle;
- ARG_OUT(angles)
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTSTATUS:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- ARG_DEF(struct pwc_mpt_status, status)
-
- ret = pwc_mpt_get_status(pdev, ARGA(status));
- ARG_OUT(status)
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCGVIDCMD:
- {
- ARG_DEF(struct pwc_video_command, cmd);
-
- ARGR(cmd).type = pdev->type;
- ARGR(cmd).release = pdev->release;
- ARGR(cmd).command_len = pdev->cmd_len;
- memcpy(&ARGR(cmd).command_buf, pdev->cmd_buf, pdev->cmd_len);
- ARGR(cmd).bandlength = pdev->vbandlength;
- ARGR(cmd).frame_size = pdev->frame_size;
- ARG_OUT(cmd)
- break;
- }
-
- default:
- ret = -ENOIOCTLCMD;
- break;
- }
-
- if (ret > 0)
- return 0;
- return ret;
-}
-
-
-
+++ /dev/null
-/* Linux driver for Philips webcam
- USB and Video4Linux interface part.
- (C) 1999-2004 Nemosoft Unv.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-/*
- This code forms the interface between the USB layers and the Philips
- specific stuff. Some adanved stuff of the driver falls under an
- NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and
- is thus not distributed in source form. The binary pwcx.o module
- contains the code that falls under the NDA.
-
- In case you're wondering: 'pwc' stands for "Philips WebCam", but
- I really didn't want to type 'philips_web_cam' every time (I'm lazy as
- any Linux kernel hacker, but I don't like uncomprehensible abbreviations
- without explanation).
-
- Oh yes, convention: to disctinguish between all the various pointers to
- device-structures, I use these names for the pointer variables:
- udev: struct usb_device *
- vdev: struct video_device *
- pdev: struct pwc_devive *
-*/
-
-/* Contributors:
- - Alvarado: adding whitebalance code
- - Alistar Moire: QuickCam 3000 Pro device/product ID
- - Tony Hoyle: Creative Labs Webcam 5 device/product ID
- - Mark Burazin: solving hang in VIDIOCSYNC when camera gets unplugged
- - Jk Fang: Sotec Afina Eye ID
- - Xavier Roche: QuickCam Pro 4000 ID
- - Jens Knudsen: QuickCam Zoom ID
- - J. Debert: QuickCam for Notebooks ID
-*/
-
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/mm.h>
-#include <linux/module.h>
-#include <linux/poll.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/io.h>
-
-#include "pwc.h"
-#include "pwc-ioctl.h"
-#include "pwc-uncompress.h"
-
-/* Function prototypes and driver templates */
-
-/* hotplug device table support */
-static struct usb_device_id pwc_device_table [] = {
- { USB_DEVICE(0x0471, 0x0302) }, /* Philips models */
- { USB_DEVICE(0x0471, 0x0303) },
- { USB_DEVICE(0x0471, 0x0304) },
- { USB_DEVICE(0x0471, 0x0307) },
- { USB_DEVICE(0x0471, 0x0308) },
- { USB_DEVICE(0x0471, 0x030C) },
- { USB_DEVICE(0x0471, 0x0310) },
- { USB_DEVICE(0x0471, 0x0311) },
- { USB_DEVICE(0x0471, 0x0312) },
- { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */
- { USB_DEVICE(0x069A, 0x0001) }, /* Askey */
- { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */
- { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */
- { USB_DEVICE(0x046D, 0x08B2) }, /* Logitech QuickCam Pro 4000 */
- { USB_DEVICE(0x046D, 0x08B3) }, /* Logitech QuickCam Zoom (old model) */
- { USB_DEVICE(0x046D, 0x08B4) }, /* Logitech QuickCam Zoom (new model) */
- { USB_DEVICE(0x046D, 0x08B5) }, /* Logitech QuickCam Orbit/Sphere */
- { USB_DEVICE(0x046D, 0x08B6) }, /* Logitech (reserved) */
- { USB_DEVICE(0x046D, 0x08B7) }, /* Logitech (reserved) */
- { USB_DEVICE(0x046D, 0x08B8) }, /* Logitech (reserved) */
- { USB_DEVICE(0x055D, 0x9000) }, /* Samsung */
- { USB_DEVICE(0x055D, 0x9001) },
- { USB_DEVICE(0x041E, 0x400C) }, /* Creative Webcam 5 */
- { USB_DEVICE(0x041E, 0x4011) }, /* Creative Webcam Pro Ex */
- { USB_DEVICE(0x04CC, 0x8116) }, /* Afina Eye */
- { USB_DEVICE(0x06BE, 0x8116) }, /* new Afina Eye */
- { USB_DEVICE(0x0d81, 0x1910) }, /* Visionite */
- { USB_DEVICE(0x0d81, 0x1900) },
- { }
-};
-MODULE_DEVICE_TABLE(usb, pwc_device_table);
-
-static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id);
-static void usb_pwc_disconnect(struct usb_interface *intf);
-
-static struct usb_driver pwc_driver = {
- .owner = THIS_MODULE,
- .name = "Philips webcam", /* name */
- .id_table = pwc_device_table,
- .probe = usb_pwc_probe, /* probe() */
- .disconnect = usb_pwc_disconnect, /* disconnect() */
-};
-
-#define MAX_DEV_HINTS 20
-#define MAX_ISOC_ERRORS 20
-
-static int default_size = PSZ_QCIF;
-static int default_fps = 10;
-static int default_fbufs = 3; /* Default number of frame buffers */
-static int default_mbufs = 2; /* Default number of mmap() buffers */
- int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX;
-static int power_save = 0;
-static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */
- int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */
-static struct {
- int type;
- char serial_number[30];
- int device_node;
- struct pwc_device *pdev;
-} device_hint[MAX_DEV_HINTS];
-
-/***/
-
-static int pwc_video_open(struct inode *inode, struct file *file);
-static int pwc_video_close(struct inode *inode, struct file *file);
-static ssize_t pwc_video_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos);
-static unsigned int pwc_video_poll(struct file *file, poll_table *wait);
-static int pwc_video_ioctl(struct inode *inode, struct file *file,
- unsigned int ioctlnr, unsigned long arg);
-static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma);
-
-static struct file_operations pwc_fops = {
- .owner = THIS_MODULE,
- .open = pwc_video_open,
- .release = pwc_video_close,
- .read = pwc_video_read,
- .poll = pwc_video_poll,
- .mmap = pwc_video_mmap,
- .ioctl = pwc_video_ioctl,
- .llseek = no_llseek,
-};
-static struct video_device pwc_template = {
- .owner = THIS_MODULE,
- .name = "Philips Webcam", /* Filled in later */
- .type = VID_TYPE_CAPTURE,
- .hardware = VID_HARDWARE_PWC,
- .release = video_device_release,
- .fops = &pwc_fops,
- .minor = -1,
-};
-
-/***************************************************************************/
-
-/* Okay, this is some magic that I worked out and the reasoning behind it...
-
- The biggest problem with any USB device is of course: "what to do
- when the user unplugs the device while it is in use by an application?"
- We have several options:
- 1) Curse them with the 7 plagues when they do (requires divine intervention)
- 2) Tell them not to (won't work: they'll do it anyway)
- 3) Oops the kernel (this will have a negative effect on a user's uptime)
- 4) Do something sensible.
-
- Of course, we go for option 4.
-
- It happens that this device will be linked to two times, once from
- usb_device and once from the video_device in their respective 'private'
- pointers. This is done when the device is probed() and all initialization
- succeeded. The pwc_device struct links back to both structures.
-
- When a device is unplugged while in use it will be removed from the
- list of known USB devices; I also de-register it as a V4L device, but
- unfortunately I can't free the memory since the struct is still in use
- by the file descriptor. This free-ing is then deferend until the first
- opportunity. Crude, but it works.
-
- A small 'advantage' is that if a user unplugs the cam and plugs it back
- in, it should get assigned the same video device minor, but unfortunately
- it's non-trivial to re-link the cam back to the video device... (that
- would surely be magic! :))
-*/
-
-/***************************************************************************/
-/* Private functions */
-
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
- unsigned long kva, ret;
-
- kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
- kva |= adr & (PAGE_SIZE-1); /* restore the offset */
- ret = __pa(kva);
- return ret;
-}
-
-static void * rvmalloc(unsigned long size)
-{
- void * mem;
- unsigned long adr;
-
- size=PAGE_ALIGN(size);
- mem=vmalloc_32(size);
- if (mem)
- {
- memset(mem, 0, size); /* Clear the ram out, no junk to the user */
- adr=(unsigned long) mem;
- while (size > 0)
- {
- SetPageReserved(vmalloc_to_page((void *)adr));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- }
- return mem;
-}
-
-static void rvfree(void * mem, unsigned long size)
-{
- unsigned long adr;
-
- if (mem)
- {
- adr=(unsigned long) mem;
- while ((long) size > 0)
- {
- ClearPageReserved(vmalloc_to_page((void *)adr));
- adr+=PAGE_SIZE;
- size-=PAGE_SIZE;
- }
- vfree(mem);
- }
-}
-
-
-
-
-static int pwc_allocate_buffers(struct pwc_device *pdev)
-{
- int i;
- void *kbuf;
-
- Trace(TRACE_MEMORY, ">> pwc_allocate_buffers(pdev = 0x%p)\n", pdev);
-
- if (pdev == NULL)
- return -ENXIO;
-
-#ifdef PWC_MAGIC
- if (pdev->magic != PWC_MAGIC) {
- Err("allocate_buffers(): magic failed.\n");
- return -ENXIO;
- }
-#endif
- /* Allocate Isochronuous pipe buffers */
- for (i = 0; i < MAX_ISO_BUFS; i++) {
- if (pdev->sbuf[i].data == NULL) {
- kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
- if (kbuf == NULL) {
- Err("Failed to allocate iso buffer %d.\n", i);
- return -ENOMEM;
- }
- Trace(TRACE_MEMORY, "Allocated iso buffer at %p.\n", kbuf);
- pdev->sbuf[i].data = kbuf;
- memset(kbuf, 0, ISO_BUFFER_SIZE);
- }
- }
-
- /* Allocate frame buffer structure */
- if (pdev->fbuf == NULL) {
- kbuf = kmalloc(default_fbufs * sizeof(struct pwc_frame_buf), GFP_KERNEL);
- if (kbuf == NULL) {
- Err("Failed to allocate frame buffer structure.\n");
- return -ENOMEM;
- }
- Trace(TRACE_MEMORY, "Allocated frame buffer structure at %p.\n", kbuf);
- pdev->fbuf = kbuf;
- memset(kbuf, 0, default_fbufs * sizeof(struct pwc_frame_buf));
- }
- /* create frame buffers, and make circular ring */
- for (i = 0; i < default_fbufs; i++) {
- if (pdev->fbuf[i].data == NULL) {
- kbuf = vmalloc(PWC_FRAME_SIZE); /* need vmalloc since frame buffer > 128K */
- if (kbuf == NULL) {
- Err("Failed to allocate frame buffer %d.\n", i);
- return -ENOMEM;
- }
- Trace(TRACE_MEMORY, "Allocated frame buffer %d at %p.\n", i, kbuf);
- pdev->fbuf[i].data = kbuf;
- memset(kbuf, 128, PWC_FRAME_SIZE);
- }
- }
-
- /* Allocate decompressor table space */
- kbuf = NULL;
- if (pdev->decompressor != NULL) {
- kbuf = kmalloc(pdev->decompressor->table_size, GFP_KERNEL);
- if (kbuf == NULL) {
- Err("Failed to allocate decompress table.\n");
- return -ENOMEM;
- }
- Trace(TRACE_MEMORY, "Allocated decompress table %p.\n", kbuf);
- }
- pdev->decompress_data = kbuf;
-
- /* Allocate image buffer; double buffer for mmap() */
- kbuf = rvmalloc(default_mbufs * pdev->len_per_image);
- if (kbuf == NULL) {
- Err("Failed to allocate image buffer(s).\n");
- return -ENOMEM;
- }
- Trace(TRACE_MEMORY, "Allocated image buffer at %p.\n", kbuf);
- pdev->image_data = kbuf;
- for (i = 0; i < default_mbufs; i++)
- pdev->image_ptr[i] = kbuf + i * pdev->len_per_image;
- for (; i < MAX_IMAGES; i++)
- pdev->image_ptr[i] = NULL;
-
- kbuf = NULL;
-
- Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n");
- return 0;
-}
-
-static void pwc_free_buffers(struct pwc_device *pdev)
-{
- int i;
-
- Trace(TRACE_MEMORY, "Entering free_buffers(%p).\n", pdev);
-
- if (pdev == NULL)
- return;
-#ifdef PWC_MAGIC
- if (pdev->magic != PWC_MAGIC) {
- Err("free_buffers(): magic failed.\n");
- return;
- }
-#endif
-
- /* Release Iso-pipe buffers */
- for (i = 0; i < MAX_ISO_BUFS; i++)
- if (pdev->sbuf[i].data != NULL) {
- Trace(TRACE_MEMORY, "Freeing ISO buffer at %p.\n", pdev->sbuf[i].data);
- kfree(pdev->sbuf[i].data);
- pdev->sbuf[i].data = NULL;
- }
-
- /* The same for frame buffers */
- if (pdev->fbuf != NULL) {
- for (i = 0; i < default_fbufs; i++) {
- if (pdev->fbuf[i].data != NULL) {
- Trace(TRACE_MEMORY, "Freeing frame buffer %d at %p.\n", i, pdev->fbuf[i].data);
- vfree(pdev->fbuf[i].data);
- pdev->fbuf[i].data = NULL;
- }
- }
- kfree(pdev->fbuf);
- pdev->fbuf = NULL;
- }
-
- /* Intermediate decompression buffer & tables */
- if (pdev->decompress_data != NULL) {
- Trace(TRACE_MEMORY, "Freeing decompression buffer at %p.\n", pdev->decompress_data);
- kfree(pdev->decompress_data);
- pdev->decompress_data = NULL;
- }
- pdev->decompressor = NULL;
-
- /* Release image buffers */
- if (pdev->image_data != NULL) {
- Trace(TRACE_MEMORY, "Freeing image buffer at %p.\n", pdev->image_data);
- rvfree(pdev->image_data, default_mbufs * pdev->len_per_image);
- }
- pdev->image_data = NULL;
-
- Trace(TRACE_MEMORY, "Leaving free_buffers().\n");
-}
-
-/* The frame & image buffer mess.
-
- Yes, this is a mess. Well, it used to be simple, but alas... In this
- module, 3 buffers schemes are used to get the data from the USB bus to
- the user program. The first scheme involves the ISO buffers (called thus
- since they transport ISO data from the USB controller), and not really
- interesting. Suffices to say the data from this buffer is quickly
- gathered in an interrupt handler (pwc_isoc_handler) and placed into the
- frame buffer.
-
- The frame buffer is the second scheme, and is the central element here.
- It collects the data from a single frame from the camera (hence, the
- name). Frames are delimited by the USB camera with a short USB packet,
- so that's easy to detect. The frame buffers form a list that is filled
- by the camera+USB controller and drained by the user process through
- either read() or mmap().
-
- The image buffer is the third scheme, in which frames are decompressed
- and converted into planar format. For mmap() there is more than
- one image buffer available.
-
- The frame buffers provide the image buffering. In case the user process
- is a bit slow, this introduces lag and some undesired side-effects.
- The problem arises when the frame buffer is full. I used to drop the last
- frame, which makes the data in the queue stale very quickly. But dropping
- the frame at the head of the queue proved to be a litte bit more difficult.
- I tried a circular linked scheme, but this introduced more problems than
- it solved.
-
- Because filling and draining are completely asynchronous processes, this
- requires some fiddling with pointers and mutexes.
-
- Eventually, I came up with a system with 2 lists: an 'empty' frame list
- and a 'full' frame list:
- * Initially, all frame buffers but one are on the 'empty' list; the one
- remaining buffer is our initial fill frame.
- * If a frame is needed for filling, we try to take it from the 'empty'
- list, unless that list is empty, in which case we take the buffer at
- the head of the 'full' list.
- * When our fill buffer has been filled, it is appended to the 'full'
- list.
- * If a frame is needed by read() or mmap(), it is taken from the head of
- the 'full' list, handled, and then appended to the 'empty' list. If no
- buffer is present on the 'full' list, we wait.
- The advantage is that the buffer that is currently being decompressed/
- converted, is on neither list, and thus not in our way (any other scheme
- I tried had the problem of old data lingering in the queue).
-
- Whatever strategy you choose, it always remains a tradeoff: with more
- frame buffers the chances of a missed frame are reduced. On the other
- hand, on slower machines it introduces lag because the queue will
- always be full.
- */
-
-/**
- \brief Find next frame buffer to fill. Take from empty or full list, whichever comes first.
- */
-static inline int pwc_next_fill_frame(struct pwc_device *pdev)
-{
- int ret;
- unsigned long flags;
-
- ret = 0;
- spin_lock_irqsave(&pdev->ptrlock, flags);
- if (pdev->fill_frame != NULL) {
- /* append to 'full' list */
- if (pdev->full_frames == NULL) {
- pdev->full_frames = pdev->fill_frame;
- pdev->full_frames_tail = pdev->full_frames;
- }
- else {
- pdev->full_frames_tail->next = pdev->fill_frame;
- pdev->full_frames_tail = pdev->fill_frame;
- }
- }
- if (pdev->empty_frames != NULL) {
- /* We have empty frames available. That's easy */
- pdev->fill_frame = pdev->empty_frames;
- pdev->empty_frames = pdev->empty_frames->next;
- }
- else {
- /* Hmm. Take it from the full list */
-#if PWC_DEBUG
- /* sanity check */
- if (pdev->full_frames == NULL) {
- Err("Neither empty or full frames available!\n");
- spin_unlock_irqrestore(&pdev->ptrlock, flags);
- return -EINVAL;
- }
-#endif
- pdev->fill_frame = pdev->full_frames;
- pdev->full_frames = pdev->full_frames->next;
- ret = 1;
- }
- pdev->fill_frame->next = NULL;
-#if PWC_DEBUG
- Trace(TRACE_SEQUENCE, "Assigning sequence number %d.\n", pdev->sequence);
- pdev->fill_frame->sequence = pdev->sequence++;
-#endif
- spin_unlock_irqrestore(&pdev->ptrlock, flags);
- return ret;
-}
-
-
-/**
- \brief Reset all buffers, pointers and lists, except for the image_used[] buffer.
-
- If the image_used[] buffer is cleared too, mmap()/VIDIOCSYNC will run into trouble.
- */
-static void pwc_reset_buffers(struct pwc_device *pdev)
-{
- int i;
- unsigned long flags;
-
- spin_lock_irqsave(&pdev->ptrlock, flags);
- pdev->full_frames = NULL;
- pdev->full_frames_tail = NULL;
- for (i = 0; i < default_fbufs; i++) {
- pdev->fbuf[i].filled = 0;
- if (i > 0)
- pdev->fbuf[i].next = &pdev->fbuf[i - 1];
- else
- pdev->fbuf->next = NULL;
- }
- pdev->empty_frames = &pdev->fbuf[default_fbufs - 1];
- pdev->empty_frames_tail = pdev->fbuf;
- pdev->read_frame = NULL;
- pdev->fill_frame = pdev->empty_frames;
- pdev->empty_frames = pdev->empty_frames->next;
-
- pdev->image_read_pos = 0;
- pdev->fill_image = 0;
- spin_unlock_irqrestore(&pdev->ptrlock, flags);
-}
-
-
-/**
- \brief Do all the handling for getting one frame: get pointer, decompress, advance pointers.
- */
-static int pwc_handle_frame(struct pwc_device *pdev)
-{
- int ret = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&pdev->ptrlock, flags);
- /* First grab our read_frame; this is removed from all lists, so
- we can release the lock after this without problems */
- if (pdev->read_frame != NULL) {
- /* This can't theoretically happen */
- Err("Huh? Read frame still in use?\n");
- }
- else {
- if (pdev->full_frames == NULL) {
- Err("Woops. No frames ready.\n");
- }
- else {
- pdev->read_frame = pdev->full_frames;
- pdev->full_frames = pdev->full_frames->next;
- pdev->read_frame->next = NULL;
- }
-
- if (pdev->read_frame != NULL) {
-#if PWC_DEBUG
- Trace(TRACE_SEQUENCE, "Decompressing frame %d\n", pdev->read_frame->sequence);
-#endif
- /* Decompression is a lenghty process, so it's outside of the lock.
- This gives the isoc_handler the opportunity to fill more frames
- in the mean time.
- */
- spin_unlock_irqrestore(&pdev->ptrlock, flags);
- ret = pwc_decompress(pdev);
- spin_lock_irqsave(&pdev->ptrlock, flags);
-
- /* We're done with read_buffer, tack it to the end of the empty buffer list */
- if (pdev->empty_frames == NULL) {
- pdev->empty_frames = pdev->read_frame;
- pdev->empty_frames_tail = pdev->empty_frames;
- }
- else {
- pdev->empty_frames_tail->next = pdev->read_frame;
- pdev->empty_frames_tail = pdev->read_frame;
- }
- pdev->read_frame = NULL;
- }
- }
- spin_unlock_irqrestore(&pdev->ptrlock, flags);
- return ret;
-}
-
-/**
- \brief Advance pointers of image buffer (after each user request)
-*/
-static inline void pwc_next_image(struct pwc_device *pdev)
-{
- pdev->image_used[pdev->fill_image] = 0;
- pdev->fill_image = (pdev->fill_image + 1) % default_mbufs;
-}
-
-
-/* This gets called for the Isochronous pipe (video). This is done in
- * interrupt time, so it has to be fast, not crash, and not stall. Neat.
- */
-static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
-{
- struct pwc_device *pdev;
- int i, fst, flen;
- int awake;
- struct pwc_frame_buf *fbuf;
- unsigned char *fillptr = NULL;
- unsigned char *iso_buf = NULL;
-
- awake = 0;
- pdev = (struct pwc_device *)urb->context;
- if (pdev == NULL) {
- Err("isoc_handler() called with NULL device?!\n");
- return;
- }
-#ifdef PWC_MAGIC
- if (pdev->magic != PWC_MAGIC) {
- Err("isoc_handler() called with bad magic!\n");
- return;
- }
-#endif
- if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
- Trace(TRACE_OPEN, "pwc_isoc_handler(): URB (%p) unlinked %ssynchronuously.\n", urb, urb->status == -ENOENT ? "" : "a");
- return;
- }
- if (urb->status != -EINPROGRESS && urb->status != 0) {
- const char *errmsg;
-
- errmsg = "Unknown";
- switch(urb->status) {
- case -ENOSR: errmsg = "Buffer error (overrun)"; break;
- case -EPIPE: errmsg = "Stalled (device not responding)"; break;
- case -EOVERFLOW: errmsg = "Babble (bad cable?)"; break;
- case -EPROTO: errmsg = "Bit-stuff error (bad cable?)"; break;
- case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break;
- case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break;
- }
- Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
- /* Give up after a number of contiguous errors on the USB bus.
- Appearantly something is wrong so we simulate an unplug event.
- */
- if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
- {
- Info("Too many ISOC errors, bailing out.\n");
- pdev->error_status = EIO;
- awake = 1;
- wake_up_interruptible(&pdev->frameq);
- }
- goto handler_end; // ugly, but practical
- }
-
- fbuf = pdev->fill_frame;
- if (fbuf == NULL) {
- Err("pwc_isoc_handler without valid fill frame.\n");
- awake = 1;
- goto handler_end;
- }
- else {
- fillptr = fbuf->data + fbuf->filled;
- }
-
- /* Reset ISOC error counter. We did get here, after all. */
- pdev->visoc_errors = 0;
-
- /* vsync: 0 = don't copy data
- 1 = sync-hunt
- 2 = synched
- */
- /* Compact data */
- for (i = 0; i < urb->number_of_packets; i++) {
- fst = urb->iso_frame_desc[i].status;
- flen = urb->iso_frame_desc[i].actual_length;
- iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset;
- if (fst == 0) {
- if (flen > 0) { /* if valid data... */
- if (pdev->vsync > 0) { /* ...and we are not sync-hunting... */
- pdev->vsync = 2;
-
- /* ...copy data to frame buffer, if possible */
- if (flen + fbuf->filled > pdev->frame_total_size) {
- Trace(TRACE_FLOW, "Frame buffer overflow (flen = %d, frame_total_size = %d).\n", flen, pdev->frame_total_size);
- pdev->vsync = 0; /* Hmm, let's wait for an EOF (end-of-frame) */
- pdev->vframes_error++;
- }
- else {
- memmove(fillptr, iso_buf, flen);
- fillptr += flen;
- }
- }
- fbuf->filled += flen;
- } /* ..flen > 0 */
-
- if (flen < pdev->vlast_packet_size) {
- /* Shorter packet... We probably have the end of an image-frame;
- wake up read() process and let select()/poll() do something.
- Decompression is done in user time over there.
- */
- if (pdev->vsync == 2) {
- /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
- frames on the USB wire after an exposure change. This conditition is
- however detected in the cam and a bit is set in the header.
- */
- if (pdev->type == 730) {
- unsigned char *ptr = (unsigned char *)fbuf->data;
-
- if (ptr[1] == 1 && ptr[0] & 0x10) {
-#if PWC_DEBUG
- Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence);
-#endif
- pdev->drop_frames += 2;
- pdev->vframes_error++;
- }
- if ((ptr[0] ^ pdev->vmirror) & 0x01) {
- if (ptr[0] & 0x01)
- Info("Snapshot button pressed.\n");
- else
- Info("Snapshot button released.\n");
- }
- if ((ptr[0] ^ pdev->vmirror) & 0x02) {
- if (ptr[0] & 0x02)
- Info("Image is mirrored.\n");
- else
- Info("Image is normal.\n");
- }
- pdev->vmirror = ptr[0] & 0x03;
- /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
- after a short frame; this condition is filtered out specifically. A 4 byte
- frame doesn't make sense anyway.
- So we get either this sequence:
- drop_bit set -> 4 byte frame -> short frame -> good frame
- Or this one:
- drop_bit set -> short frame -> good frame
- So we drop either 3 or 2 frames in all!
- */
- if (fbuf->filled == 4)
- pdev->drop_frames++;
- }
-
- /* In case we were instructed to drop the frame, do so silently.
- The buffer pointers are not updated either (but the counters are reset below).
- */
- if (pdev->drop_frames > 0)
- pdev->drop_frames--;
- else {
- /* Check for underflow first */
- if (fbuf->filled < pdev->frame_total_size) {
- Trace(TRACE_FLOW, "Frame buffer underflow (%d bytes); discarded.\n", fbuf->filled);
- pdev->vframes_error++;
- }
- else {
- /* Send only once per EOF */
- awake = 1; /* delay wake_ups */
-
- /* Find our next frame to fill. This will always succeed, since we
- * nick a frame from either empty or full list, but if we had to
- * take it from the full list, it means a frame got dropped.
- */
- if (pwc_next_fill_frame(pdev)) {
- pdev->vframes_dumped++;
- if ((pdev->vframe_count > FRAME_LOWMARK) && (pwc_trace & TRACE_FLOW)) {
- if (pdev->vframes_dumped < 20)
- Trace(TRACE_FLOW, "Dumping frame %d.\n", pdev->vframe_count);
- if (pdev->vframes_dumped == 20)
- Trace(TRACE_FLOW, "Dumping frame %d (last message).\n", pdev->vframe_count);
- }
- }
- fbuf = pdev->fill_frame;
- }
- } /* !drop_frames */
- pdev->vframe_count++;
- }
- fbuf->filled = 0;
- fillptr = fbuf->data;
- pdev->vsync = 1;
- } /* .. flen < last_packet_size */
- pdev->vlast_packet_size = flen;
- } /* ..status == 0 */
-#if PWC_DEBUG
- /* This is normally not interesting to the user, unless you are really debugging something */
- else {
- static int iso_error = 0;
- iso_error++;
- if (iso_error < 20)
- Trace(TRACE_FLOW, "Iso frame %d of USB has error %d\n", i, fst);
- }
-#endif
- }
-
-handler_end:
- if (awake)
- wake_up_interruptible(&pdev->frameq);
-
- urb->dev = pdev->udev;
- i = usb_submit_urb(urb, GFP_ATOMIC);
- if (i != 0)
- Err("Error (%d) re-submitting urb in pwc_isoc_handler.\n", i);
-}
-
-
-static int pwc_isoc_init(struct pwc_device *pdev)
-{
- struct usb_device *udev;
- struct urb *urb;
- int i, j, ret;
-
- struct usb_interface *intf;
- struct usb_host_interface *idesc = NULL;
-
- if (pdev == NULL)
- return -EFAULT;
- if (pdev->iso_init)
- return 0;
- pdev->vsync = 0;
- udev = pdev->udev;
-
- /* Get the current alternate interface, adjust packet size */
- if (!udev->actconfig)
- return -EFAULT;
- intf = usb_ifnum_to_if(udev, 0);
- if (intf)
- idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
- if (!idesc)
- return -EFAULT;
-
- /* Search video endpoint */
- pdev->vmax_packet_size = -1;
- for (i = 0; i < idesc->desc.bNumEndpoints; i++)
- if ((idesc->endpoint[i].desc.bEndpointAddress & 0xF) == pdev->vendpoint) {
- pdev->vmax_packet_size = idesc->endpoint[i].desc.wMaxPacketSize;
- break;
- }
-
- if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
- Err("Failed to find packet size for video endpoint in current alternate setting.\n");
- return -ENFILE; /* Odd error, that should be noticable */
- }
-
- /* Set alternate interface */
- ret = 0;
- Trace(TRACE_OPEN, "Setting alternate interface %d\n", pdev->valternate);
- ret = usb_set_interface(pdev->udev, 0, pdev->valternate);
- if (ret < 0)
- return ret;
-
- for (i = 0; i < MAX_ISO_BUFS; i++) {
- urb = usb_alloc_urb(ISO_FRAMES_PER_DESC, GFP_KERNEL);
- if (urb == NULL) {
- Err("Failed to allocate urb %d\n", i);
- ret = -ENOMEM;
- break;
- }
- pdev->sbuf[i].urb = urb;
- Trace(TRACE_MEMORY, "Allocated URB at 0x%p\n", urb);
- }
- if (ret) {
- /* De-allocate in reverse order */
- while (i >= 0) {
- if (pdev->sbuf[i].urb != NULL)
- usb_free_urb(pdev->sbuf[i].urb);
- pdev->sbuf[i].urb = NULL;
- i--;
- }
- return ret;
- }
-
- /* init URB structure */
- for (i = 0; i < MAX_ISO_BUFS; i++) {
- urb = pdev->sbuf[i].urb;
-
- urb->interval = 1; // devik
- urb->dev = udev;
- urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
- urb->transfer_flags = URB_ISO_ASAP;
- urb->transfer_buffer = pdev->sbuf[i].data;
- urb->transfer_buffer_length = ISO_BUFFER_SIZE;
- urb->complete = pwc_isoc_handler;
- urb->context = pdev;
- urb->start_frame = 0;
- urb->number_of_packets = ISO_FRAMES_PER_DESC;
- for (j = 0; j < ISO_FRAMES_PER_DESC; j++) {
- urb->iso_frame_desc[j].offset = j * ISO_MAX_FRAME_SIZE;
- urb->iso_frame_desc[j].length = pdev->vmax_packet_size;
- }
- }
-
- /* link */
- for (i = 0; i < MAX_ISO_BUFS; i++) {
- ret = usb_submit_urb(pdev->sbuf[i].urb, GFP_KERNEL);
- if (ret)
- Err("isoc_init() submit_urb %d failed with error %d\n", i, ret);
- else
- Trace(TRACE_MEMORY, "URB 0x%p submitted.\n", pdev->sbuf[i].urb);
- }
-
- /* All is done... */
- pdev->iso_init = 1;
- Trace(TRACE_OPEN, "<< pwc_isoc_init()\n");
- return 0;
-}
-
-static void pwc_isoc_cleanup(struct pwc_device *pdev)
-{
- int i;
-
- Trace(TRACE_OPEN, ">> pwc_isoc_cleanup()\n");
- if (pdev == NULL)
- return;
-
- /* Unlinking ISOC buffers one by one */
- for (i = 0; i < MAX_ISO_BUFS; i++) {
- struct urb *urb;
-
- urb = pdev->sbuf[i].urb;
- if (urb != 0) {
- if (pdev->iso_init) {
- Trace(TRACE_MEMORY, "Unlinking URB %p\n", urb);
- usb_unlink_urb(urb);
- }
- Trace(TRACE_MEMORY, "Freeing URB\n");
- usb_free_urb(urb);
- pdev->sbuf[i].urb = NULL;
- }
- }
-
- /* Stop camera, but only if we are sure the camera is still there (unplug
- is signalled by EPIPE)
- */
- if (pdev->error_status && pdev->error_status != EPIPE) {
- Trace(TRACE_OPEN, "Setting alternate interface 0.\n");
- usb_set_interface(pdev->udev, 0, 0);
- }
-
- pdev->iso_init = 0;
- Trace(TRACE_OPEN, "<< pwc_isoc_cleanup()\n");
-}
-
-int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot)
-{
- int ret, start;
-
- /* Stop isoc stuff */
- pwc_isoc_cleanup(pdev);
- /* Reset parameters */
- pwc_reset_buffers(pdev);
- /* Try to set video mode... */
- start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot);
- if (ret) {
- Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n");
- /* That failed... restore old mode (we know that worked) */
- start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
- if (start) {
- Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n");
- }
- }
- if (start == 0)
- {
- if (pwc_isoc_init(pdev) < 0)
- {
- Info("Failed to restart ISOC transfers in pwc_try_video_mode.\n");
- ret = -EAGAIN; /* let's try again, who knows if it works a second time */
- }
- }
- pdev->drop_frames++; /* try to avoid garbage during switch */
- return ret; /* Return original error code */
-}
-
-
-/***************************************************************************/
-/* Video4Linux functions */
-
-static int pwc_video_open(struct inode *inode, struct file *file)
-{
- int i;
- struct video_device *vdev = video_devdata(file);
- struct pwc_device *pdev;
-
- Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev);
-
- pdev = (struct pwc_device *)vdev->priv;
- if (pdev == NULL)
- BUG();
- if (pdev->vopen)
- return -EBUSY;
-
- down(&pdev->modlock);
- if (!pdev->usb_init) {
- Trace(TRACE_OPEN, "Doing first time initialization.\n");
- pdev->usb_init = 1;
-
- if (pwc_trace & TRACE_OPEN)
- {
- /* Query sensor type */
- const char *sensor_type = NULL;
- int ret;
-
- ret = pwc_get_cmos_sensor(pdev, &i);
- if (ret >= 0)
- {
- switch(i) {
- case 0x00: sensor_type = "Hyundai CMOS sensor"; break;
- case 0x20: sensor_type = "Sony CCD sensor + TDA8787"; break;
- case 0x2E: sensor_type = "Sony CCD sensor + Exas 98L59"; break;
- case 0x2F: sensor_type = "Sony CCD sensor + ADI 9804"; break;
- case 0x30: sensor_type = "Sharp CCD sensor + TDA8787"; break;
- case 0x3E: sensor_type = "Sharp CCD sensor + Exas 98L59"; break;
- case 0x3F: sensor_type = "Sharp CCD sensor + ADI 9804"; break;
- case 0x40: sensor_type = "UPA 1021 sensor"; break;
- case 0x100: sensor_type = "VGA sensor"; break;
- case 0x101: sensor_type = "PAL MR sensor"; break;
- default: sensor_type = "unknown type of sensor"; break;
- }
- }
- if (sensor_type != NULL)
- Info("This %s camera is equipped with a %s (%d).\n", pdev->vdev->name, sensor_type, i);
- }
- }
-
- /* Turn on camera */
- if (power_save) {
- i = pwc_camera_power(pdev, 1);
- if (i < 0)
- Info("Failed to restore power to the camera! (%d)\n", i);
- }
- /* Set LED on/off time */
- if (pwc_set_leds(pdev, led_on, led_off) < 0)
- Info("Failed to set LED on/off time.\n");
-
- /* Find our decompressor, if any */
- pdev->decompressor = pwc_find_decompressor(pdev->type);
-#if PWC_DEBUG
- Debug("Found decompressor for %d at 0x%p\n", pdev->type, pdev->decompressor);
-#endif
- pwc_construct(pdev); /* set min/max sizes correct */
-
- /* So far, so good. Allocate memory. */
- i = pwc_allocate_buffers(pdev);
- if (i < 0) {
- Trace(TRACE_OPEN, "Failed to allocate buffer memory.\n");
- up(&pdev->modlock);
- return i;
- }
-
- /* Reset buffers & parameters */
- pwc_reset_buffers(pdev);
- for (i = 0; i < default_mbufs; i++)
- pdev->image_used[i] = 0;
- pdev->vframe_count = 0;
- pdev->vframes_dumped = 0;
- pdev->vframes_error = 0;
- pdev->visoc_errors = 0;
- pdev->error_status = 0;
-#if PWC_DEBUG
- pdev->sequence = 0;
-#endif
- pwc_construct(pdev); /* set min/max sizes correct */
-
- /* Set some defaults */
- pdev->vsnapshot = 0;
-
- /* Start iso pipe for video; first try the last used video size
- (or the default one); if that fails try QCIF/10 or QSIF/10;
- it that fails too, give up.
- */
- i = pwc_set_video_mode(pdev, pwc_image_sizes[pdev->vsize].x, pwc_image_sizes[pdev->vsize].y, pdev->vframes, pdev->vcompression, 0);
- if (i) {
- Trace(TRACE_OPEN, "First attempt at set_video_mode failed.\n");
- if (pdev->type == 730 || pdev->type == 740 || pdev->type == 750)
- i = pwc_set_video_mode(pdev, pwc_image_sizes[PSZ_QSIF].x, pwc_image_sizes[PSZ_QSIF].y, 10, pdev->vcompression, 0);
- else
- i = pwc_set_video_mode(pdev, pwc_image_sizes[PSZ_QCIF].x, pwc_image_sizes[PSZ_QCIF].y, 10, pdev->vcompression, 0);
- }
- if (i) {
- Trace(TRACE_OPEN, "Second attempt at set_video_mode failed.\n");
- up(&pdev->modlock);
- return i;
- }
-
- i = pwc_isoc_init(pdev);
- if (i) {
- Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i);
- up(&pdev->modlock);
- return i;
- }
-
- pdev->vopen++;
- file->private_data = vdev;
- /* lock decompressor; this has a small race condition, since we
- could in theory unload pwcx.o between pwc_find_decompressor()
- above and this call. I doubt it's ever going to be a problem.
- */
- if (pdev->decompressor != NULL)
- pdev->decompressor->lock();
- up(&pdev->modlock);
- Trace(TRACE_OPEN, "<< video_open() returns 0.\n");
- return 0;
-}
-
-/* Note that all cleanup is done in the reverse order as in _open */
-static int pwc_video_close(struct inode *inode, struct file *file)
-{
- struct video_device *vdev = file->private_data;
- struct pwc_device *pdev;
- int i;
-
- Trace(TRACE_OPEN, ">> video_close called(vdev = 0x%p).\n", vdev);
-
- pdev = (struct pwc_device *)vdev->priv;
- if (pdev->vopen == 0)
- Info("video_close() called on closed device?\n");
-
- /* Dump statistics, but only if a reasonable amount of frames were
- processed (to prevent endless log-entries in case of snap-shot
- programs)
- */
- if (pdev->vframe_count > 20)
- Info("Closing video device: %d frames received, dumped %d frames, %d frames with errors.\n", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error);
-
- if (pdev->decompressor != NULL) {
- pdev->decompressor->exit();
- pdev->decompressor->unlock();
- pdev->decompressor = NULL;
- }
-
- pwc_isoc_cleanup(pdev);
- pwc_free_buffers(pdev);
-
- /* Turn off LEDS and power down camera, but only when not unplugged */
- if (pdev->error_status != EPIPE) {
- /* Turn LEDs off */
- if (pwc_set_leds(pdev, 0, 0) < 0)
- Info("Failed to set LED on/off time.\n");
- if (power_save) {
- i = pwc_camera_power(pdev, 0);
- if (i < 0)
- Err("Failed to power down camera (%d)\n", i);
- }
- }
- pdev->vopen = 0;
- Trace(TRACE_OPEN, "<< video_close()\n");
- return 0;
-}
-
-/*
- * FIXME: what about two parallel reads ????
- * ANSWER: Not supported. You can't open the device more than once,
- despite what the V4L1 interface says. First, I don't see
- the need, second there's no mechanism of alerting the
- 2nd/3rd/... process of events like changing image size.
- And I don't see the point of blocking that for the
- 2nd/3rd/... process.
- In multi-threaded environments reading parallel from any
- device is tricky anyhow.
- */
-
-static ssize_t pwc_video_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct video_device *vdev = file->private_data;
- struct pwc_device *pdev;
- int noblock = file->f_flags & O_NONBLOCK;
- DECLARE_WAITQUEUE(wait, current);
- int bytes_to_read;
-
- Trace(TRACE_READ, "video_read(0x%p, %p, %zd) called.\n", vdev, buf, count);
- if (vdev == NULL)
- return -EFAULT;
- pdev = vdev->priv;
- if (pdev == NULL)
- return -EFAULT;
- if (pdev->error_status)
- return -pdev->error_status; /* Something happened, report what. */
-
- /* In case we're doing partial reads, we don't have to wait for a frame */
- if (pdev->image_read_pos == 0) {
- /* Do wait queueing according to the (doc)book */
- add_wait_queue(&pdev->frameq, &wait);
- while (pdev->full_frames == NULL) {
- /* Check for unplugged/etc. here */
- if (pdev->error_status) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -pdev->error_status ;
- }
- if (noblock) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -EWOULDBLOCK;
- }
- if (signal_pending(current)) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -ERESTARTSYS;
- }
- schedule();
- set_current_state(TASK_INTERRUPTIBLE);
- }
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
-
- /* Decompress and release frame */
- if (pwc_handle_frame(pdev))
- return -EFAULT;
- }
-
- Trace(TRACE_READ, "Copying data to user space.\n");
- if (pdev->vpalette == VIDEO_PALETTE_RAW)
- bytes_to_read = pdev->frame_size;
- else
- bytes_to_read = pdev->view.size;
-
- /* copy bytes to user space; we allow for partial reads */
- if (count + pdev->image_read_pos > bytes_to_read)
- count = bytes_to_read - pdev->image_read_pos;
- if (copy_to_user(buf, pdev->image_ptr[pdev->fill_image] + pdev->image_read_pos, count))
- return -EFAULT;
- pdev->image_read_pos += count;
- if (pdev->image_read_pos >= bytes_to_read) { /* All data has been read */
- pdev->image_read_pos = 0;
- pwc_next_image(pdev);
- }
- return count;
-}
-
-static unsigned int pwc_video_poll(struct file *file, poll_table *wait)
-{
- struct video_device *vdev = file->private_data;
- struct pwc_device *pdev;
-
- if (vdev == NULL)
- return -EFAULT;
- pdev = vdev->priv;
- if (pdev == NULL)
- return -EFAULT;
-
- poll_wait(file, &pdev->frameq, wait);
- if (pdev->error_status)
- return POLLERR;
- if (pdev->full_frames != NULL) /* we have frames waiting */
- return (POLLIN | POLLRDNORM);
-
- return 0;
-}
-
-static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg)
-{
- struct video_device *vdev = file->private_data;
- struct pwc_device *pdev;
- DECLARE_WAITQUEUE(wait, current);
-
- if (vdev == NULL)
- return -EFAULT;
- pdev = vdev->priv;
- if (pdev == NULL)
- return -EFAULT;
-
- switch (cmd) {
- /* Query cabapilities */
- case VIDIOCGCAP:
- {
- struct video_capability *caps = arg;
-
- strcpy(caps->name, vdev->name);
- caps->type = VID_TYPE_CAPTURE;
- caps->channels = 1;
- caps->audios = 1;
- caps->minwidth = pdev->view_min.x;
- caps->minheight = pdev->view_min.y;
- caps->maxwidth = pdev->view_max.x;
- caps->maxheight = pdev->view_max.y;
- break;
- }
-
- /* Channel functions (simulate 1 channel) */
- case VIDIOCGCHAN:
- {
- struct video_channel *v = arg;
-
- if (v->channel != 0)
- return -EINVAL;
- v->flags = 0;
- v->tuners = 0;
- v->type = VIDEO_TYPE_CAMERA;
- strcpy(v->name, "Webcam");
- return 0;
- }
-
- case VIDIOCSCHAN:
- {
- /* The spec says the argument is an integer, but
- the bttv driver uses a video_channel arg, which
- makes sense becasue it also has the norm flag.
- */
- struct video_channel *v = arg;
- if (v->channel != 0)
- return -EINVAL;
- return 0;
- }
-
-
- /* Picture functions; contrast etc. */
- case VIDIOCGPICT:
- {
- struct video_picture *p = arg;
- int val;
-
- val = pwc_get_brightness(pdev);
- if (val >= 0)
- p->brightness = val;
- else
- p->brightness = 0xffff;
- val = pwc_get_contrast(pdev);
- if (val >= 0)
- p->contrast = val;
- else
- p->contrast = 0xffff;
- /* Gamma, Whiteness, what's the difference? :) */
- val = pwc_get_gamma(pdev);
- if (val >= 0)
- p->whiteness = val;
- else
- p->whiteness = 0xffff;
- val = pwc_get_saturation(pdev);
- if (val >= 0)
- p->colour = val;
- else
- p->colour = 0xffff;
- p->depth = 24;
- p->palette = pdev->vpalette;
- p->hue = 0xFFFF; /* N/A */
- break;
- }
-
- case VIDIOCSPICT:
- {
- struct video_picture *p = arg;
- /*
- * FIXME: Suppose we are mid read
- ANSWER: No problem: the firmware of the camera
- can handle brightness/contrast/etc
- changes at _any_ time, and the palette
- is used exactly once in the uncompress
- routine.
- */
- pwc_set_brightness(pdev, p->brightness);
- pwc_set_contrast(pdev, p->contrast);
- pwc_set_gamma(pdev, p->whiteness);
- pwc_set_saturation(pdev, p->colour);
- if (p->palette && p->palette != pdev->vpalette) {
- switch (p->palette) {
- case VIDEO_PALETTE_YUV420P:
- case VIDEO_PALETTE_RAW:
- pdev->vpalette = p->palette;
- return pwc_try_video_mode(pdev, pdev->image.x, pdev->image.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
- break;
- default:
- return -EINVAL;
- break;
- }
- }
- break;
- }
-
- /* Window/size parameters */
- case VIDIOCGWIN:
- {
- struct video_window *vw = arg;
-
- vw->x = 0;
- vw->y = 0;
- vw->width = pdev->view.x;
- vw->height = pdev->view.y;
- vw->chromakey = 0;
- vw->flags = (pdev->vframes << PWC_FPS_SHIFT) |
- (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0);
- break;
- }
-
- case VIDIOCSWIN:
- {
- struct video_window *vw = arg;
- int fps, snapshot, ret;
-
- fps = (vw->flags & PWC_FPS_FRMASK) >> PWC_FPS_SHIFT;
- snapshot = vw->flags & PWC_FPS_SNAPSHOT;
- if (fps == 0)
- fps = pdev->vframes;
- if (pdev->view.x == vw->width && pdev->view.y && fps == pdev->vframes && snapshot == pdev->vsnapshot)
- return 0;
- ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot);
- if (ret)
- return ret;
- break;
- }
-
- /* We don't have overlay support (yet) */
- case VIDIOCGFBUF:
- {
- struct video_buffer *vb = arg;
-
- memset(vb,0,sizeof(*vb));
- break;
- }
-
- /* mmap() functions */
- case VIDIOCGMBUF:
- {
- /* Tell the user program how much memory is needed for a mmap() */
- struct video_mbuf *vm = arg;
- int i;
-
- memset(vm, 0, sizeof(*vm));
- vm->size = default_mbufs * pdev->len_per_image;
- vm->frames = default_mbufs; /* double buffering should be enough for most applications */
- for (i = 0; i < default_mbufs; i++)
- vm->offsets[i] = i * pdev->len_per_image;
- break;
- }
-
- case VIDIOCMCAPTURE:
- {
- /* Start capture into a given image buffer (called 'frame' in video_mmap structure) */
- struct video_mmap *vm = arg;
-
- Trace(TRACE_READ, "VIDIOCMCAPTURE: %dx%d, frame %d, format %d\n", vm->width, vm->height, vm->frame, vm->format);
- if (vm->frame < 0 || vm->frame >= default_mbufs)
- return -EINVAL;
-
- /* xawtv is nasty. It probes the available palettes
- by setting a very small image size and trying
- various palettes... The driver doesn't support
- such small images, so I'm working around it.
- */
- if (vm->format)
- {
- switch (vm->format)
- {
- case VIDEO_PALETTE_YUV420P:
- case VIDEO_PALETTE_RAW:
- break;
- default:
- return -EINVAL;
- break;
- }
- }
-
- if ((vm->width != pdev->view.x || vm->height != pdev->view.y) &&
- (vm->width >= pdev->view_min.x && vm->height >= pdev->view_min.y)) {
- int ret;
-
- Trace(TRACE_OPEN, "VIDIOCMCAPTURE: changing size to please xawtv :-(.\n");
- ret = pwc_try_video_mode(pdev, vm->width, vm->height, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
- if (ret)
- return ret;
- } /* ... size mismatch */
-
- /* FIXME: should we lock here? */
- if (pdev->image_used[vm->frame])
- return -EBUSY; /* buffer wasn't available. Bummer */
- pdev->image_used[vm->frame] = 1;
-
- /* Okay, we're done here. In the SYNC call we wait until a
- frame comes available, then expand image into the given
- buffer.
- In contrast to the CPiA cam the Philips cams deliver a
- constant stream, almost like a grabber card. Also,
- we have separate buffers for the rawdata and the image,
- meaning we can nearly always expand into the requested buffer.
- */
- Trace(TRACE_READ, "VIDIOCMCAPTURE done.\n");
- break;
- }
-
- case VIDIOCSYNC:
- {
- /* The doc says: "Whenever a buffer is used it should
- call VIDIOCSYNC to free this frame up and continue."
-
- The only odd thing about this whole procedure is
- that MCAPTURE flags the buffer as "in use", and
- SYNC immediately unmarks it, while it isn't
- after SYNC that you know that the buffer actually
- got filled! So you better not start a CAPTURE in
- the same frame immediately (use double buffering).
- This is not a problem for this cam, since it has
- extra intermediate buffers, but a hardware
- grabber card will then overwrite the buffer
- you're working on.
- */
- int *mbuf = arg;
- int ret;
-
- Trace(TRACE_READ, "VIDIOCSYNC called (%d).\n", *mbuf);
-
- /* bounds check */
- if (*mbuf < 0 || *mbuf >= default_mbufs)
- return -EINVAL;
- /* check if this buffer was requested anyway */
- if (pdev->image_used[*mbuf] == 0)
- return -EINVAL;
-
- /* Add ourselves to the frame wait-queue.
-
- FIXME: needs auditing for safety.
- QUESTION: In what respect? I think that using the
- frameq is safe now.
- */
- add_wait_queue(&pdev->frameq, &wait);
- while (pdev->full_frames == NULL) {
- if (pdev->error_status) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -pdev->error_status;
- }
-
- if (signal_pending(current)) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -ERESTARTSYS;
- }
- schedule();
- set_current_state(TASK_INTERRUPTIBLE);
- }
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
-
- /* The frame is ready. Expand in the image buffer
- requested by the user. I don't care if you
- mmap() 5 buffers and request data in this order:
- buffer 4 2 3 0 1 2 3 0 4 3 1 . . .
- Grabber hardware may not be so forgiving.
- */
- Trace(TRACE_READ, "VIDIOCSYNC: frame ready.\n");
- pdev->fill_image = *mbuf; /* tell in which buffer we want the image to be expanded */
- /* Decompress, etc */
- ret = pwc_handle_frame(pdev);
- pdev->image_used[*mbuf] = 0;
- if (ret)
- return -EFAULT;
- break;
- }
-
- case VIDIOCGAUDIO:
- {
- struct video_audio *v = arg;
-
- strcpy(v->name, "Microphone");
- v->audio = -1; /* unknown audio minor */
- v->flags = 0;
- v->mode = VIDEO_SOUND_MONO;
- v->volume = 0;
- v->bass = 0;
- v->treble = 0;
- v->balance = 0x8000;
- v->step = 1;
- break;
- }
-
- case VIDIOCSAUDIO:
- {
- /* Dummy: nothing can be set */
- break;
- }
-
- case VIDIOCGUNIT:
- {
- struct video_unit *vu = arg;
-
- vu->video = pdev->vdev->minor & 0x3F;
- vu->audio = -1; /* not known yet */
- vu->vbi = -1;
- vu->radio = -1;
- vu->teletext = -1;
- break;
- }
- default:
- return pwc_ioctl(pdev, cmd, arg);
- } /* ..switch */
- return 0;
-}
-
-static int pwc_video_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return video_usercopy(inode, file, cmd, arg, pwc_video_do_ioctl);
-}
-
-
-static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
-{
- struct video_device *vdev = file->private_data;
- struct pwc_device *pdev;
- unsigned long start = vma->vm_start;
- unsigned long size = vma->vm_end-vma->vm_start;
- unsigned long page, pos;
-
- Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size);
- pdev = vdev->priv;
-
- pos = (unsigned long)pdev->image_data;
- while (size > 0) {
- page = kvirt_to_pa(pos);
- if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
- return -EAGAIN;
-
- start += PAGE_SIZE;
- pos += PAGE_SIZE;
- if (size > PAGE_SIZE)
- size -= PAGE_SIZE;
- else
- size = 0;
- }
-
- return 0;
-}
-
-/***************************************************************************/
-/* USB functions */
-
-/* This function gets called when a new device is plugged in or the usb core
- * is loaded.
- */
-
-static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
- struct pwc_device *pdev = NULL;
- int vendor_id, product_id, type_id;
- int i, hint;
- int features = 0;
- int video_nr = -1; /* default: use next available device */
- char serial_number[30], *name;
-
- /* Check if we can handle this device */
- Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n",
- udev->descriptor.idVendor, udev->descriptor.idProduct,
- intf->altsetting->desc.bInterfaceNumber);
-
- /* the interfaces are probed one by one. We are only interested in the
- video interface (0) now.
- Interface 1 is the Audio Control, and interface 2 Audio itself.
- */
- if (intf->altsetting->desc.bInterfaceNumber > 0)
- return -ENODEV;
-
- vendor_id = udev->descriptor.idVendor;
- product_id = udev->descriptor.idProduct;
-
- if (vendor_id == 0x0471) {
- switch (product_id) {
- case 0x0302:
- Info("Philips PCA645VC USB webcam detected.\n");
- name = "Philips 645 webcam";
- type_id = 645;
- break;
- case 0x0303:
- Info("Philips PCA646VC USB webcam detected.\n");
- name = "Philips 646 webcam";
- type_id = 646;
- break;
- case 0x0304:
- Info("Askey VC010 type 2 USB webcam detected.\n");
- name = "Askey VC010 webcam";
- type_id = 646;
- break;
- case 0x0307:
- Info("Philips PCVC675K (Vesta) USB webcam detected.\n");
- name = "Philips 675 webcam";
- type_id = 675;
- break;
- case 0x0308:
- Info("Philips PCVC680K (Vesta Pro) USB webcam detected.\n");
- name = "Philips 680 webcam";
- type_id = 680;
- break;
- case 0x030C:
- Info("Philips PCVC690K (Vesta Pro Scan) USB webcam detected.\n");
- name = "Philips 690 webcam";
- type_id = 690;
- break;
- case 0x0310:
- Info("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n");
- name = "Philips 730 webcam";
- type_id = 730;
- break;
- case 0x0311:
- Info("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n");
- name = "Philips 740 webcam";
- type_id = 740;
- break;
- case 0x0312:
- Info("Philips PCVC750K (ToUCam Pro Scan) USB webcam detected.\n");
- name = "Philips 750 webcam";
- type_id = 750;
- break;
- case 0x0313:
- Info("Philips PCVC720K/40 (ToUCam XS) USB webcam detected.\n");
- name = "Philips 720K/40 webcam";
- type_id = 720;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x069A) {
- switch(product_id) {
- case 0x0001:
- Info("Askey VC010 type 1 USB webcam detected.\n");
- name = "Askey VC010 webcam";
- type_id = 645;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x046d) {
- switch(product_id) {
- case 0x08b0:
- Info("Logitech QuickCam Pro 3000 USB webcam detected.\n");
- name = "Logitech QuickCam Pro 3000";
- type_id = 740; /* CCD sensor */
- break;
- case 0x08b1:
- Info("Logitech QuickCam Notebook Pro USB webcam detected.\n");
- name = "Logitech QuickCam Notebook Pro";
- type_id = 740; /* CCD sensor */
- break;
- case 0x08b2:
- Info("Logitech QuickCam 4000 Pro USB webcam detected.\n");
- name = "Logitech QuickCam Pro 4000";
- type_id = 740; /* CCD sensor */
- break;
- case 0x08b3:
- Info("Logitech QuickCam Zoom USB webcam detected.\n");
- name = "Logitech QuickCam Zoom";
- type_id = 740; /* CCD sensor */
- break;
- case 0x08B4:
- Info("Logitech QuickCam Zoom (new model) USB webcam detected.\n");
- name = "Logitech QuickCam Zoom";
- type_id = 740; /* CCD sensor */
- break;
- case 0x08b5:
- Info("Logitech QuickCam Orbit/Sphere USB webcam detected.\n");
- name = "Logitech QuickCam Orbit";
- type_id = 740; /* CCD sensor */
- features |= FEATURE_MOTOR_PANTILT;
- break;
- case 0x08b6:
- case 0x08b7:
- case 0x08b8:
- Info("Logitech QuickCam detected (reserved ID).\n");
- name = "Logitech QuickCam (res.)";
- type_id = 730; /* Assuming CMOS */
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x055d) {
- /* I don't know the difference between the C10 and the C30;
- I suppose the difference is the sensor, but both cameras
- work equally well with a type_id of 675
- */
- switch(product_id) {
- case 0x9000:
- Info("Samsung MPC-C10 USB webcam detected.\n");
- name = "Samsung MPC-C10";
- type_id = 675;
- break;
- case 0x9001:
- Info("Samsung MPC-C30 USB webcam detected.\n");
- name = "Samsung MPC-C30";
- type_id = 675;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x041e) {
- switch(product_id) {
- case 0x400c:
- Info("Creative Labs Webcam 5 detected.\n");
- name = "Creative Labs Webcam 5";
- type_id = 730;
- break;
- case 0x4011:
- Info("Creative Labs Webcam Pro Ex detected.\n");
- name = "Creative Labs Webcam Pro Ex";
- type_id = 740;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x04cc) {
- switch(product_id) {
- case 0x8116:
- Info("Sotec Afina Eye USB webcam detected.\n");
- name = "Sotec Afina Eye";
- type_id = 730;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x06be) {
- switch(product_id) {
- case 0x8116:
- /* Basicly the same as the Sotec Afina Eye */
- Info("AME CU-001 USB webcam detected.\n");
- name = "AME CU-001";
- type_id = 730;
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else if (vendor_id == 0x06be) {
- switch(product_id) {
- case 0x8116:
- /* This is essentially the same cam as the Sotec Afina Eye */
- Info("AME Co. Afina Eye USB webcam detected.\n");
- name = "AME Co. Afina Eye";
- type_id = 750;
- break;
- default:
- return -ENODEV;
- break;
- }
-
- }
- else if (vendor_id == 0x0d81) {
- switch(product_id) {
- case 0x1900:
- Info("Visionite VCS-UC300 USB webcam detected.\n");
- name = "Visionite VCS-UC300";
- type_id = 740; /* CCD sensor */
- break;
- case 0x1910:
- Info("Visionite VCS-UM100 USB webcam detected.\n");
- name = "Visionite VCS-UM100";
- type_id = 730; /* CMOS sensor */
- break;
- default:
- return -ENODEV;
- break;
- }
- }
- else
- return -ENODEV; /* Not any of the know types; but the list keeps growing. */
-
- memset(serial_number, 0, 30);
- usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29);
- Trace(TRACE_PROBE, "Device serial number is %s\n", serial_number);
-
- if (udev->descriptor.bNumConfigurations > 1)
- Info("Warning: more than 1 configuration available.\n");
-
- /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */
- pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL);
- if (pdev == NULL) {
- Err("Oops, could not allocate memory for pwc_device.\n");
- return -ENOMEM;
- }
- memset(pdev, 0, sizeof(struct pwc_device));
- pdev->type = type_id;
- pdev->vsize = default_size;
- pdev->vframes = default_fps;
- strcpy(pdev->serial, serial_number);
- pdev->features = features;
- if (vendor_id == 0x046D && product_id == 0x08B5)
- {
- /* Logitech QuickCam Orbit
- The ranges have been determined experimentally; they may differ from cam to cam.
- Also, the exact ranges left-right and up-down are different for my cam
- */
- pdev->angle_range.pan_min = -7000;
- pdev->angle_range.pan_max = 7000;
- pdev->angle_range.tilt_min = -3000;
- pdev->angle_range.tilt_max = 2500;
- }
-
- init_MUTEX(&pdev->modlock);
- pdev->ptrlock = SPIN_LOCK_UNLOCKED;
-
- pdev->udev = udev;
- init_waitqueue_head(&pdev->frameq);
- pdev->vcompression = pwc_preferred_compression;
-
- /* Allocate video_device structure */
- pdev->vdev = video_device_alloc();
- if (pdev->vdev == 0)
- {
- Err("Err, cannot allocate video_device struture. Failing probe.");
- kfree(pdev);
- return -ENOMEM;
- }
- memcpy(pdev->vdev, &pwc_template, sizeof(pwc_template));
- strcpy(pdev->vdev->name, name);
- pdev->vdev->owner = THIS_MODULE;
- video_set_drvdata(pdev->vdev, pdev);
-
- pdev->release = udev->descriptor.bcdDevice;
- Trace(TRACE_PROBE, "Release: %04x\n", pdev->release);
-
- /* Now search device_hint[] table for a match, so we can hint a node number. */
- for (hint = 0; hint < MAX_DEV_HINTS; hint++) {
- if (((device_hint[hint].type == -1) || (device_hint[hint].type == pdev->type)) &&
- (device_hint[hint].pdev == NULL)) {
- /* so far, so good... try serial number */
- if ((device_hint[hint].serial_number[0] == '*') || !strcmp(device_hint[hint].serial_number, serial_number)) {
- /* match! */
- video_nr = device_hint[hint].device_node;
- Trace(TRACE_PROBE, "Found hint, will try to register as /dev/video%d\n", video_nr);
- break;
- }
- }
- }
-
- pdev->vdev->release = video_device_release;
- i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
- if (i < 0) {
- Err("Failed to register as video device (%d).\n", i);
- video_device_release(pdev->vdev); /* Drip... drip... drip... */
- kfree(pdev); /* Oops, no memory leaks please */
- return -EIO;
- }
- else {
- Info("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F);
- }
-
- /* occupy slot */
- if (hint < MAX_DEV_HINTS)
- device_hint[hint].pdev = pdev;
-
- Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev);
- usb_set_intfdata (intf, pdev);
- return 0;
-}
-
-/* The user janked out the cable... */
-static void usb_pwc_disconnect(struct usb_interface *intf)
-{
- struct pwc_device *pdev;
- int hint;
-
- lock_kernel();
- pdev = usb_get_intfdata (intf);
- usb_set_intfdata (intf, NULL);
- if (pdev == NULL) {
- Err("pwc_disconnect() Called without private pointer.\n");
- goto disconnect_out;
- }
- if (pdev->udev == NULL) {
- Err("pwc_disconnect() already called for %p\n", pdev);
- goto disconnect_out;
- }
- if (pdev->udev != interface_to_usbdev(intf)) {
- Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n");
- goto disconnect_out;
- }
-#ifdef PWC_MAGIC
- if (pdev->magic != PWC_MAGIC) {
- Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n");
- goto disconnect_out;
- }
-#endif
-
- /* We got unplugged; this is signalled by an EPIPE error code */
- if (pdev->vopen) {
- Info("Disconnected while webcam is in use!\n");
- pdev->error_status = EPIPE;
- }
-
- /* Alert waiting processes */
- wake_up_interruptible(&pdev->frameq);
- /* Wait until device is closed */
- while (pdev->vopen)
- schedule();
- /* Device is now closed, so we can safely unregister it */
- Trace(TRACE_PROBE, "Unregistering video device in disconnect().\n");
- video_unregister_device(pdev->vdev);
-
- /* Free memory (don't set pdev to 0 just yet) */
- kfree(pdev);
-
-disconnect_out:
- /* search device_hint[] table if we occupy a slot, by any chance */
- for (hint = 0; hint < MAX_DEV_HINTS; hint++)
- if (device_hint[hint].pdev == pdev)
- device_hint[hint].pdev = NULL;
-
- unlock_kernel();
-}
-
-
-/* *grunt* We have to do atoi ourselves :-( */
-static int pwc_atoi(const char *s)
-{
- int k = 0;
-
- k = 0;
- while (*s != '\0' && *s >= '0' && *s <= '9') {
- k = 10 * k + (*s - '0');
- s++;
- }
- return k;
-}
-
-
-/*
- * Initialization code & module stuff
- */
-
-static char *size = NULL;
-static int fps = 0;
-static int fbufs = 0;
-static int mbufs = 0;
-static int trace = -1;
-static int compression = -1;
-static int leds[2] = { -1, -1 };
-static char *dev_hint[MAX_DEV_HINTS] = { };
-
-MODULE_PARM(size, "s");
-MODULE_PARM_DESC(size, "Initial image size. One of sqcif, qsif, qcif, sif, cif, vga");
-MODULE_PARM(fps, "i");
-MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful range 5-30");
-MODULE_PARM(fbufs, "i");
-MODULE_PARM_DESC(fbufs, "Number of internal frame buffers to reserve");
-MODULE_PARM(mbufs, "i");
-MODULE_PARM_DESC(mbufs, "Number of external (mmap()ed) image buffers");
-MODULE_PARM(trace, "i");
-MODULE_PARM_DESC(trace, "For debugging purposes");
-MODULE_PARM(power_save, "i");
-MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off");
-MODULE_PARM(compression, "i");
-MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)");
-MODULE_PARM(leds, "2i");
-MODULE_PARM_DESC(leds, "LED on,off time in milliseconds");
-MODULE_PARM(dev_hint, "0-20s");
-MODULE_PARM_DESC(dev_hint, "Device node hints");
-
-MODULE_DESCRIPTION("Philips & OEM USB webcam driver");
-MODULE_AUTHOR("Nemosoft Unv. <webcam@smcc.demon.nl>");
-MODULE_LICENSE("GPL");
-
-static int __init usb_pwc_init(void)
-{
- int i, sz;
- char *sizenames[PSZ_MAX] = { "sqcif", "qsif", "qcif", "sif", "cif", "vga" };
-
- Info("Philips webcam module version " PWC_VERSION " loaded.\n");
- Info("Supports Philips PCA645/646, PCVC675/680/690, PCVC720[40]/730/740/750 & PCVC830/840.\n");
- Info("Also supports the Askey VC010, various Logitech Quickcams, Samsung MPC-C10 and MPC-C30,\n");
- Info("the Creative WebCam 5 & Pro Ex, SOTEC Afina Eye and Visionite VCS-UC300 and VCS-UM100.\n");
-
- if (fps) {
- if (fps < 4 || fps > 30) {
- Err("Framerate out of bounds (4-30).\n");
- return -EINVAL;
- }
- default_fps = fps;
- Info("Default framerate set to %d.\n", default_fps);
- }
-
- if (size) {
- /* string; try matching with array */
- for (sz = 0; sz < PSZ_MAX; sz++) {
- if (!strcmp(sizenames[sz], size)) { /* Found! */
- default_size = sz;
- break;
- }
- }
- if (sz == PSZ_MAX) {
- Err("Size not recognized; try size=[sqcif | qsif | qcif | sif | cif | vga].\n");
- return -EINVAL;
- }
- Info("Default image size set to %s [%dx%d].\n", sizenames[default_size], pwc_image_sizes[default_size].x, pwc_image_sizes[default_size].y);
- }
- if (mbufs) {
- if (mbufs < 1 || mbufs > MAX_IMAGES) {
- Err("Illegal number of mmap() buffers; use a number between 1 and %d.\n", MAX_IMAGES);
- return -EINVAL;
- }
- default_mbufs = mbufs;
- Info("Number of image buffers set to %d.\n", default_mbufs);
- }
- if (fbufs) {
- if (fbufs < 2 || fbufs > MAX_FRAMES) {
- Err("Illegal number of frame buffers; use a number between 2 and %d.\n", MAX_FRAMES);
- return -EINVAL;
- }
- default_fbufs = fbufs;
- Info("Number of frame buffers set to %d.\n", default_fbufs);
- }
- if (trace >= 0) {
- Info("Trace options: 0x%04x\n", trace);
- pwc_trace = trace;
- }
- if (compression >= 0) {
- if (compression > 3) {
- Err("Invalid compression setting; use a number between 0 (uncompressed) and 3 (high).\n");
- return -EINVAL;
- }
- pwc_preferred_compression = compression;
- Info("Preferred compression set to %d.\n", pwc_preferred_compression);
- }
- if (power_save)
- Info("Enabling power save on open/close.\n");
- if (leds[0] >= 0)
- led_on = leds[0];
- if (leds[1] >= 0)
- led_off = leds[1];
-
- /* Big device node whoopla. Basicly, it allows you to assign a
- device node (/dev/videoX) to a camera, based on its type
- & serial number. The format is [type[.serialnumber]:]node.
-
- Any camera that isn't matched by these rules gets the next
- available free device node.
- */
- for (i = 0; i < MAX_DEV_HINTS; i++) {
- char *s, *colon, *dot;
-
- /* This loop also initializes the array */
- device_hint[i].pdev = NULL;
- s = dev_hint[i];
- if (s != NULL && *s != '\0') {
- device_hint[i].type = -1; /* wildcard */
- strcpy(device_hint[i].serial_number, "*");
-
- /* parse string: chop at ':' & '/' */
- colon = dot = s;
- while (*colon != '\0' && *colon != ':')
- colon++;
- while (*dot != '\0' && *dot != '.')
- dot++;
- /* Few sanity checks */
- if (*dot != '\0' && dot > colon) {
- Err("Malformed camera hint: the colon must be after the dot.\n");
- return -EINVAL;
- }
-
- if (*colon == '\0') {
- /* No colon */
- if (*dot != '\0') {
- Err("Malformed camera hint: no colon + device node given.\n");
- return -EINVAL;
- }
- else {
- /* No type or serial number specified, just a number. */
- device_hint[i].device_node = pwc_atoi(s);
- }
- }
- else {
- /* There's a colon, so we have at least a type and a device node */
- device_hint[i].type = pwc_atoi(s);
- device_hint[i].device_node = pwc_atoi(colon + 1);
- if (*dot != '\0') {
- /* There's a serial number as well */
- int k;
-
- dot++;
- k = 0;
- while (*dot != ':' && k < 29) {
- device_hint[i].serial_number[k++] = *dot;
- dot++;
- }
- device_hint[i].serial_number[k] = '\0';
- }
- }
-#if PWC_DEBUG
- Debug("device_hint[%d]:\n", i);
- Debug(" type : %d\n", device_hint[i].type);
- Debug(" serial# : %s\n", device_hint[i].serial_number);
- Debug(" node : %d\n", device_hint[i].device_node);
-#endif
- }
- else
- device_hint[i].type = 0; /* not filled */
- } /* ..for MAX_DEV_HINTS */
-
- Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver);
- return usb_register(&pwc_driver);
-}
-
-static void __exit usb_pwc_exit(void)
-{
- Trace(TRACE_MODULE, "Deregistering driver.\n");
- usb_deregister(&pwc_driver);
- Info("Philips webcam module removed.\n");
-}
-
-module_init(usb_pwc_init);
-module_exit(usb_pwc_exit);
-
+++ /dev/null
-#ifndef PWC_IOCTL_H
-#define PWC_IOCTL_H
-
-/* (C) 2001-2004 Nemosoft Unv. webcam@smcc.demon.nl
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-/* This is pwc-ioctl.h belonging to PWC 8.12.1
- It contains structures and defines to communicate from user space
- directly to the driver.
- */
-
-/*
- Changes
- 2001/08/03 Alvarado Added ioctl constants to access methods for
- changing white balance and red/blue gains
- 2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
- 2003/12/13 Nemosft Unv. Some modifications to make interfacing to
- PWCX easier
- */
-
-/* These are private ioctl() commands, specific for the Philips webcams.
- They contain functions not found in other webcams, and settings not
- specified in the Video4Linux API.
-
- The #define names are built up like follows:
- VIDIOC VIDeo IOCtl prefix
- PWC Philps WebCam
- G optional: Get
- S optional: Set
- ... the function
- */
-
-
- /* Enumeration of image sizes */
-#define PSZ_SQCIF 0x00
-#define PSZ_QSIF 0x01
-#define PSZ_QCIF 0x02
-#define PSZ_SIF 0x03
-#define PSZ_CIF 0x04
-#define PSZ_VGA 0x05
-#define PSZ_MAX 6
-
-
-/* The frame rate is encoded in the video_window.flags parameter using
- the upper 16 bits, since some flags are defined nowadays. The following
- defines provide a mask and shift to filter out this value.
-
- In 'Snapshot' mode the camera freezes its automatic exposure and colour
- balance controls.
- */
-#define PWC_FPS_SHIFT 16
-#define PWC_FPS_MASK 0x00FF0000
-#define PWC_FPS_FRMASK 0x003F0000
-#define PWC_FPS_SNAPSHOT 0x00400000
-
-
-/* structure for transfering x & y coordinates */
-struct pwc_coord
-{
- int x, y; /* guess what */
- int size; /* size, or offset */
-};
-
-
-/* Used with VIDIOCPWCPROBE */
-struct pwc_probe
-{
- char name[32];
- int type;
-};
-
-struct pwc_serial
-{
- char serial[30]; /* String with serial number. Contains terminating 0 */
-};
-
-/* pwc_whitebalance.mode values */
-#define PWC_WB_INDOOR 0
-#define PWC_WB_OUTDOOR 1
-#define PWC_WB_FL 2
-#define PWC_WB_MANUAL 3
-#define PWC_WB_AUTO 4
-
-/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
- Set mode to one of the PWC_WB_* values above.
- *red and *blue are the respective gains of these colour components inside
- the camera; range 0..65535
- When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
- otherwise undefined.
- 'read_red' and 'read_blue' are read-only.
-*/
-struct pwc_whitebalance
-{
- int mode;
- int manual_red, manual_blue; /* R/W */
- int read_red, read_blue; /* R/O */
-};
-
-/*
- 'control_speed' and 'control_delay' are used in automatic whitebalance mode,
- and tell the camera how fast it should react to changes in lighting, and
- with how much delay. Valid values are 0..65535.
-*/
-struct pwc_wb_speed
-{
- int control_speed;
- int control_delay;
-
-};
-
-/* Used with VIDIOCPWC[SG]LED */
-struct pwc_leds
-{
- int led_on; /* Led on-time; range = 0..25000 */
- int led_off; /* Led off-time; range = 0..25000 */
-};
-
-/* Image size (used with GREALSIZE) */
-struct pwc_imagesize
-{
- int width;
- int height;
-};
-
-/* Defines and structures for Motorized Pan & Tilt */
-#define PWC_MPT_PAN 0x01
-#define PWC_MPT_TILT 0x02
-#define PWC_MPT_TIMEOUT 0x04 /* for status */
-
-/* Set angles; when absolute != 0, the angle is absolute and the
- driver calculates the relative offset for you. This can only
- be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
- absolute angles.
- */
-struct pwc_mpt_angles
-{
- int absolute; /* write-only */
- int pan; /* degrees * 100 */
- int tilt; /* degress * 100 */
-};
-
-/* Range of angles of the camera, both horizontally and vertically.
- */
-struct pwc_mpt_range
-{
- int pan_min, pan_max; /* degrees * 100 */
- int tilt_min, tilt_max;
-};
-
-struct pwc_mpt_status
-{
- int status;
- int time_pan;
- int time_tilt;
-};
-
-
-/* This is used for out-of-kernel decompression. With it, you can get
- all the necessary information to initialize and use the decompressor
- routines in standalone applications.
- */
-struct pwc_video_command
-{
- int type; /* camera type (645, 675, 730, etc.) */
- int release; /* release number */
-
- int size; /* one of PSZ_* */
- int alternate;
- int command_len; /* length of USB video command */
- unsigned char command_buf[13]; /* Actual USB video command */
- int bandlength; /* >0 = compressed */
- int frame_size; /* Size of one (un)compressed frame */
-};
-
-/* Flags for PWCX subroutines. Not all modules honour all flags. */
-#define PWCX_FLAG_PLANAR 0x0001
-#define PWCX_FLAG_BAYER 0x0008
-
-
-/* IOCTL definitions */
-
- /* Restore user settings */
-#define VIDIOCPWCRUSER _IO('v', 192)
- /* Save user settings */
-#define VIDIOCPWCSUSER _IO('v', 193)
- /* Restore factory settings */
-#define VIDIOCPWCFACTORY _IO('v', 194)
-
- /* You can manipulate the compression factor. A compression preference of 0
- means use uncompressed modes when available; 1 is low compression, 2 is
- medium and 3 is high compression preferred. Of course, the higher the
- compression, the lower the bandwidth used but more chance of artefacts
- in the image. The driver automatically chooses a higher compression when
- the preferred mode is not available.
- */
- /* Set preferred compression quality (0 = uncompressed, 3 = highest compression) */
-#define VIDIOCPWCSCQUAL _IOW('v', 195, int)
- /* Get preferred compression quality */
-#define VIDIOCPWCGCQUAL _IOR('v', 195, int)
-
-
-/* Retrieve serial number of camera */
-#define VIDIOCPWCGSERIAL _IOR('v', 198, struct pwc_serial)
-
- /* This is a probe function; since so many devices are supported, it
- becomes difficult to include all the names in programs that want to
- check for the enhanced Philips stuff. So in stead, try this PROBE;
- it returns a structure with the original name, and the corresponding
- Philips type.
- To use, fill the structure with zeroes, call PROBE and if that succeeds,
- compare the name with that returned from VIDIOCGCAP; they should be the
- same. If so, you can be assured it is a Philips (OEM) cam and the type
- is valid.
- */
-#define VIDIOCPWCPROBE _IOR('v', 199, struct pwc_probe)
-
- /* Set AGC (Automatic Gain Control); int < 0 = auto, 0..65535 = fixed */
-#define VIDIOCPWCSAGC _IOW('v', 200, int)
- /* Get AGC; int < 0 = auto; >= 0 = fixed, range 0..65535 */
-#define VIDIOCPWCGAGC _IOR('v', 200, int)
- /* Set shutter speed; int < 0 = auto; >= 0 = fixed, range 0..65535 */
-#define VIDIOCPWCSSHUTTER _IOW('v', 201, int)
-
- /* Color compensation (Auto White Balance) */
-#define VIDIOCPWCSAWB _IOW('v', 202, struct pwc_whitebalance)
-#define VIDIOCPWCGAWB _IOR('v', 202, struct pwc_whitebalance)
-
- /* Auto WB speed */
-#define VIDIOCPWCSAWBSPEED _IOW('v', 203, struct pwc_wb_speed)
-#define VIDIOCPWCGAWBSPEED _IOR('v', 203, struct pwc_wb_speed)
-
- /* LEDs on/off/blink; int range 0..65535 */
-#define VIDIOCPWCSLED _IOW('v', 205, struct pwc_leds)
-#define VIDIOCPWCGLED _IOR('v', 205, struct pwc_leds)
-
- /* Contour (sharpness); int < 0 = auto, 0..65536 = fixed */
-#define VIDIOCPWCSCONTOUR _IOW('v', 206, int)
-#define VIDIOCPWCGCONTOUR _IOR('v', 206, int)
-
- /* Backlight compensation; 0 = off, otherwise on */
-#define VIDIOCPWCSBACKLIGHT _IOW('v', 207, int)
-#define VIDIOCPWCGBACKLIGHT _IOR('v', 207, int)
-
- /* Flickerless mode; = 0 off, otherwise on */
-#define VIDIOCPWCSFLICKER _IOW('v', 208, int)
-#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
-
- /* Dynamic noise reduction; 0 off, 3 = high noise reduction */
-#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
-#define VIDIOCPWCGDYNNOISE _IOR('v', 209, int)
-
- /* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
-#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
-
- /* Motorized pan & tilt functions */
-#define VIDIOCPWCMPTRESET _IOW('v', 211, int)
-#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
-#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
-#define VIDIOCPWCMPTGANGLE _IOR('v', 212, struct pwc_mpt_angles)
-#define VIDIOCPWCMPTSTATUS _IOR('v', 213, struct pwc_mpt_status)
-
- /* Get the USB set-video command; needed for initializing libpwcx */
-#define VIDIOCPWCGVIDCMD _IOR('v', 215, struct pwc_video_command)
-
-#endif
+++ /dev/null
-/* Linux driver for Philips webcam
- Various miscellaneous functions and tables.
- (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include <linux/slab.h>
-
-#include "pwc.h"
-
-struct pwc_coord pwc_image_sizes[PSZ_MAX] =
-{
- { 128, 96, 0 },
- { 160, 120, 0 },
- { 176, 144, 0 },
- { 320, 240, 0 },
- { 352, 288, 0 },
- { 640, 480, 0 },
-};
-
-/* x,y -> PSZ_ */
-int pwc_decode_size(struct pwc_device *pdev, int width, int height)
-{
- int i, find;
-
- /* Make sure we don't go beyond our max size.
- NB: we have different limits for RAW and normal modes. In case
- you don't have the decompressor loaded or use RAW mode,
- the maximum viewable size is smaller.
- */
- if (pdev->vpalette == VIDEO_PALETTE_RAW)
- {
- if (width > pdev->abs_max.x || height > pdev->abs_max.y)
- {
- Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
- return -1;
- }
- }
- else
- {
- if (width > pdev->view_max.x || height > pdev->view_max.y)
- {
- Debug("VIDEO_PALETTE_ not RAW: going beyond view_max.\n");
- return -1;
- }
- }
-
- /* Find the largest size supported by the camera that fits into the
- requested size.
- */
- find = -1;
- for (i = 0; i < PSZ_MAX; i++) {
- if (pdev->image_mask & (1 << i)) {
- if (pwc_image_sizes[i].x <= width && pwc_image_sizes[i].y <= height)
- find = i;
- }
- }
- return find;
-}
-
-/* initialize variables depending on type and decompressor*/
-void pwc_construct(struct pwc_device *pdev)
-{
- switch(pdev->type) {
- case 645:
- case 646:
- pdev->view_min.x = 128;
- pdev->view_min.y = 96;
- pdev->view_max.x = 352;
- pdev->view_max.y = 288;
- pdev->abs_max.x = 352;
- pdev->abs_max.y = 288;
- pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
- pdev->vcinterface = 2;
- pdev->vendpoint = 4;
- pdev->frame_header_size = 0;
- pdev->frame_trailer_size = 0;
- break;
- case 675:
- case 680:
- case 690:
- pdev->view_min.x = 128;
- pdev->view_min.y = 96;
- /* Anthill bug #38: PWC always reports max size, even without PWCX */
- if (pdev->decompressor != NULL) {
- pdev->view_max.x = 640;
- pdev->view_max.y = 480;
- }
- else {
- pdev->view_max.x = 352;
- pdev->view_max.y = 288;
- }
- pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
- pdev->abs_max.x = 640;
- pdev->abs_max.y = 480;
- pdev->vcinterface = 3;
- pdev->vendpoint = 4;
- pdev->frame_header_size = 0;
- pdev->frame_trailer_size = 0;
- break;
- case 720:
- case 730:
- case 740:
- case 750:
- pdev->view_min.x = 160;
- pdev->view_min.y = 120;
- /* Anthill bug #38: PWC always reports max size, even without PWCX */
- if (pdev->decompressor != NULL) {
- pdev->view_max.x = 640;
- pdev->view_max.y = 480;
- }
- else {
- /* We use CIF, not SIF since some tools really need CIF. So we cheat a bit. */
- pdev->view_max.x = 352;
- pdev->view_max.y = 288;
- }
- pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
- pdev->abs_max.x = 640;
- pdev->abs_max.y = 480;
- pdev->vcinterface = 3;
- pdev->vendpoint = 5;
- pdev->frame_header_size = TOUCAM_HEADER_SIZE;
- pdev->frame_trailer_size = TOUCAM_TRAILER_SIZE;
- break;
- }
- pdev->vpalette = VIDEO_PALETTE_YUV420P; /* default */
- pdev->view_min.size = pdev->view_min.x * pdev->view_min.y;
- pdev->view_max.size = pdev->view_max.x * pdev->view_max.y;
- /* length of image, in YUV format; always allocate enough memory. */
- pdev->len_per_image = (pdev->abs_max.x * pdev->abs_max.y * 3) / 2;
-}
-
-
+++ /dev/null
-/* Linux driver for Philips webcam
- Decompression frontend.
- (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-/*
- This is where the decompression routines register and unregister
- themselves. It also has a decompressor wrapper function.
-*/
-
-#include <asm/current.h>
-#include <asm/types.h>
-// #include <linux/sched.h>
-
-#include "pwc.h"
-#include "pwc-uncompress.h"
-
-
-/* This contains a list of all registered decompressors */
-static LIST_HEAD(pwc_decompressor_list);
-
-/* Should the pwc_decompress structure ever change, we increase the
- version number so that we don't get nasty surprises, or can
- dynamically adjust our structure.
- */
-const int pwc_decompressor_version = PWC_MAJOR;
-
-/* Add decompressor to list, ignoring duplicates */
-void pwc_register_decompressor(struct pwc_decompressor *pwcd)
-{
- if (pwc_find_decompressor(pwcd->type) == NULL) {
- Trace(TRACE_PWCX, "Adding decompressor for model %d.\n", pwcd->type);
- list_add_tail(&pwcd->pwcd_list, &pwc_decompressor_list);
- }
-}
-
-/* Remove decompressor from list */
-void pwc_unregister_decompressor(int type)
-{
- struct pwc_decompressor *find;
-
- find = pwc_find_decompressor(type);
- if (find != NULL) {
- Trace(TRACE_PWCX, "Removing decompressor for model %d.\n", type);
- list_del(&find->pwcd_list);
- }
-}
-
-/* Find decompressor in list */
-struct pwc_decompressor *pwc_find_decompressor(int type)
-{
- struct list_head *tmp;
- struct pwc_decompressor *pwcd;
-
- list_for_each(tmp, &pwc_decompressor_list) {
- pwcd = list_entry(tmp, struct pwc_decompressor, pwcd_list);
- if (pwcd->type == type)
- return pwcd;
- }
- return NULL;
-}
-
-
-
-int pwc_decompress(struct pwc_device *pdev)
-{
- struct pwc_frame_buf *fbuf;
- int n, line, col, stride;
- void *yuv, *image;
- u16 *src;
- u16 *dsty, *dstu, *dstv;
-
- if (pdev == NULL)
- return -EFAULT;
-#if defined(__KERNEL__) && defined(PWC_MAGIC)
- if (pdev->magic != PWC_MAGIC) {
- Err("pwc_decompress(): magic failed.\n");
- return -EFAULT;
- }
-#endif
-
- fbuf = pdev->read_frame;
- if (fbuf == NULL)
- return -EFAULT;
- image = pdev->image_ptr[pdev->fill_image];
- if (!image)
- return -EFAULT;
-
- yuv = fbuf->data + pdev->frame_header_size; /* Skip header */
-
- /* Raw format; that's easy... */
- if (pdev->vpalette == VIDEO_PALETTE_RAW)
- {
- memcpy(image, yuv, pdev->frame_size);
- return 0;
- }
-
- if (pdev->vbandlength == 0) {
- /* Uncompressed mode. We copy the data into the output buffer,
- using the viewport size (which may be larger than the image
- size). Unfortunately we have to do a bit of byte stuffing
- to get the desired output format/size.
- */
- /*
- * We do some byte shuffling here to go from the
- * native format to YUV420P.
- */
- src = (u16 *)yuv;
- n = pdev->view.x * pdev->view.y;
-
- /* offset in Y plane */
- stride = pdev->view.x * pdev->offset.y + pdev->offset.x;
- dsty = (u16 *)(image + stride);
-
- /* offsets in U/V planes */
- stride = pdev->view.x * pdev->offset.y / 4 + pdev->offset.x / 2;
- dstu = (u16 *)(image + n + stride);
- dstv = (u16 *)(image + n + n / 4 + stride);
-
- /* increment after each line */
- stride = (pdev->view.x - pdev->image.x) / 2; /* u16 is 2 bytes */
-
- for (line = 0; line < pdev->image.y; line++) {
- for (col = 0; col < pdev->image.x; col += 4) {
- *dsty++ = *src++;
- *dsty++ = *src++;
- if (line & 1)
- *dstv++ = *src++;
- else
- *dstu++ = *src++;
- }
- dsty += stride;
- if (line & 1)
- dstv += (stride >> 1);
- else
- dstu += (stride >> 1);
- }
- }
- else {
- /* Compressed; the decompressor routines will write the data
- in planar format immediately.
- */
- int flags;
-
- flags = PWCX_FLAG_PLANAR;
- if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
- flags |= PWCX_FLAG_BAYER;
-
- if (pdev->decompressor)
- pdev->decompressor->decompress(
- &pdev->image, &pdev->view, &pdev->offset,
- yuv, image,
- flags,
- pdev->decompress_data, pdev->vbandlength);
- else
- return -ENXIO; /* No such device or address: missing decompressor */
- }
- return 0;
-}
-
-/* Make sure these functions are available for the decompressor plugin
- both when this code is compiled into the kernel or as as module.
- */
-
-EXPORT_SYMBOL_NOVERS(pwc_decompressor_version);
-EXPORT_SYMBOL(pwc_register_decompressor);
-EXPORT_SYMBOL(pwc_unregister_decompressor);
+++ /dev/null
-/* (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-/* This file is the bridge between the kernel module and the plugin; it
- describes the structures and datatypes used in both modules. Any
- significant change should be reflected by increasing the
- pwc_decompressor_version major number.
- */
-#ifndef PWC_UNCOMPRESS_H
-#define PWC_UNCOMPRESS_H
-
-#include <linux/config.h>
-#include <linux/linkage.h>
-#include <linux/list.h>
-
-#include "pwc-ioctl.h"
-
-/* from pwc-dec.h */
-#define PWCX_FLAG_PLANAR 0x0001
-/* */
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* The decompressor structure.
- Every type of decompressor registers itself with the main module.
- When a device is opened, it looks up the correct compressor, and
- uses that when a compressed video mode is requested.
- */
-struct pwc_decompressor
-{
- int type; /* type of camera (645, 680, etc) */
- int table_size; /* memory needed */
-
- void (* init)(int type, int release, void *buffer, void *table); /* Initialization routine; should be called after each set_video_mode */
- void (* exit)(void); /* Cleanup routine */
- void (* decompress)(struct pwc_coord *image, struct pwc_coord *view,
- struct pwc_coord *offset,
- void *src, void *dst, int flags,
- void *table, int bandlength);
- void (* lock)(void); /* make sure module cannot be unloaded */
- void (* unlock)(void); /* release lock on module */
-
- struct list_head pwcd_list;
-};
-
-
-/* Our structure version number. Is set to the version number major */
-extern const int pwc_decompressor_version;
-
-/* Adds decompressor to list, based on its 'type' field (which matches the 'type' field in pwc_device; ignores any double requests */
-extern void pwc_register_decompressor(struct pwc_decompressor *pwcd);
-/* Removes decompressor, based on the type number */
-extern void pwc_unregister_decompressor(int type);
-/* Returns pointer to decompressor struct, or NULL if it doesn't exist */
-extern struct pwc_decompressor *pwc_find_decompressor(int type);
-
-#ifdef CONFIG_USB_PWCX
-/* If the decompressor is compiled in, we must call these manually */
-extern int usb_pwcx_init(void);
-extern void usb_pwcx_exit(void);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/* (C) 1999-2003 Nemosoft Unv. (webcam@smcc.demon.nl)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef PWC_H
-#define PWC_H
-
-#include <linux/version.h>
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/usb.h>
-#include <linux/spinlock.h>
-#include <linux/videodev.h>
-#include <linux/wait.h>
-#include <linux/smp_lock.h>
-#include <asm/semaphore.h>
-#include <asm/errno.h>
-
-#include "pwc-uncompress.h"
-#include "pwc-ioctl.h"
-
-/* Defines and structures for the Philips webcam */
-/* Used for checking memory corruption/pointer validation */
-#define PWC_MAGIC 0x89DC10ABUL
-#undef PWC_MAGIC
-
-/* Turn some debugging options on/off */
-#define PWC_DEBUG 0
-
-/* Trace certain actions in the driver */
-#define TRACE_MODULE 0x0001
-#define TRACE_PROBE 0x0002
-#define TRACE_OPEN 0x0004
-#define TRACE_READ 0x0008
-#define TRACE_MEMORY 0x0010
-#define TRACE_FLOW 0x0020
-#define TRACE_SIZE 0x0040
-#define TRACE_PWCX 0x0080
-#define TRACE_SEQUENCE 0x1000
-
-#define Trace(R, A...) if (pwc_trace & R) printk(KERN_DEBUG PWC_NAME " " A)
-#define Debug(A...) printk(KERN_DEBUG PWC_NAME " " A)
-#define Info(A...) printk(KERN_INFO PWC_NAME " " A)
-#define Err(A...) printk(KERN_ERR PWC_NAME " " A)
-
-
-/* Defines for ToUCam cameras */
-#define TOUCAM_HEADER_SIZE 8
-#define TOUCAM_TRAILER_SIZE 4
-
-#define FEATURE_MOTOR_PANTILT 0x0001
-
-/* Version block */
-#define PWC_MAJOR 9
-#define PWC_MINOR 0
-#define PWC_VERSION "9.0.1"
-#define PWC_NAME "pwc"
-
-/* Turn certain features on/off */
-#define PWC_INT_PIPE 0
-
-/* Ignore errors in the first N frames, to allow for startup delays */
-#define FRAME_LOWMARK 5
-
-/* Size and number of buffers for the ISO pipe. */
-#define MAX_ISO_BUFS 2
-#define ISO_FRAMES_PER_DESC 10
-#define ISO_MAX_FRAME_SIZE 960
-#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
-
-/* Frame buffers: contains compressed or uncompressed video data. */
-#define MAX_FRAMES 5
-/* Maximum size after decompression is 640x480 YUV data, 1.5 * 640 * 480 */
-#define PWC_FRAME_SIZE (460800 + TOUCAM_HEADER_SIZE + TOUCAM_TRAILER_SIZE)
-
-/* Absolute maximum number of buffers available for mmap() */
-#define MAX_IMAGES 10
-
-/* The following structures were based on cpia.h. Why reinvent the wheel? :-) */
-struct pwc_iso_buf
-{
- void *data;
- int length;
- int read;
- struct urb *urb;
-};
-
-/* intermediate buffers with raw data from the USB cam */
-struct pwc_frame_buf
-{
- void *data;
- volatile int filled; /* number of bytes filled */
- struct pwc_frame_buf *next; /* list */
-#if PWC_DEBUG
- int sequence; /* Sequence number */
-#endif
-};
-
-struct pwc_device
-{
- struct video_device *vdev;
-#ifdef PWC_MAGIC
- int magic;
-#endif
- /* Pointer to our usb_device */
- struct usb_device *udev;
-
- int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
- int release; /* release number */
- int features; /* feature bits */
- char serial[30]; /* serial number (string) */
- int error_status; /* set when something goes wrong with the cam (unplugged, USB errors) */
- int usb_init; /* set when the cam has been initialized over USB */
-
- /*** Video data ***/
- int vopen; /* flag */
- int vendpoint; /* video isoc endpoint */
- int vcinterface; /* video control interface */
- int valternate; /* alternate interface needed */
- int vframes, vsize; /* frames-per-second & size (see PSZ_*) */
- int vpalette; /* palette: 420P, RAW or RGBBAYER */
- int vframe_count; /* received frames */
- int vframes_dumped; /* counter for dumped frames */
- int vframes_error; /* frames received in error */
- int vmax_packet_size; /* USB maxpacket size */
- int vlast_packet_size; /* for frame synchronisation */
- int visoc_errors; /* number of contiguous ISOC errors */
- int vcompression; /* desired compression factor */
- int vbandlength; /* compressed band length; 0 is uncompressed */
- char vsnapshot; /* snapshot mode */
- char vsync; /* used by isoc handler */
- char vmirror; /* for ToUCaM series */
-
- int cmd_len;
- unsigned char cmd_buf[13];
-
- /* The image acquisition requires 3 to 4 steps:
- 1. data is gathered in short packets from the USB controller
- 2. data is synchronized and packed into a frame buffer
- 3a. in case data is compressed, decompress it directly into image buffer
- 3b. in case data is uncompressed, copy into image buffer with viewport
- 4. data is transferred to the user process
-
- Note that MAX_ISO_BUFS != MAX_FRAMES != MAX_IMAGES....
- We have in effect a back-to-back-double-buffer system.
- */
- /* 1: isoc */
- struct pwc_iso_buf sbuf[MAX_ISO_BUFS];
- char iso_init;
-
- /* 2: frame */
- struct pwc_frame_buf *fbuf; /* all frames */
- struct pwc_frame_buf *empty_frames, *empty_frames_tail; /* all empty frames */
- struct pwc_frame_buf *full_frames, *full_frames_tail; /* all filled frames */
- struct pwc_frame_buf *fill_frame; /* frame currently being filled */
- struct pwc_frame_buf *read_frame; /* frame currently read by user process */
- int frame_header_size, frame_trailer_size;
- int frame_size;
- int frame_total_size; /* including header & trailer */
- int drop_frames;
-#if PWC_DEBUG
- int sequence; /* Debugging aid */
-#endif
-
- /* 3: decompression */
- struct pwc_decompressor *decompressor; /* function block with decompression routines */
- void *decompress_data; /* private data for decompression engine */
-
- /* 4: image */
- /* We have an 'image' and a 'view', where 'image' is the fixed-size image
- as delivered by the camera, and 'view' is the size requested by the
- program. The camera image is centered in this viewport, laced with
- a gray or black border. view_min <= image <= view <= view_max;
- */
- int image_mask; /* bitmask of supported sizes */
- struct pwc_coord view_min, view_max; /* minimum and maximum viewable sizes */
- struct pwc_coord abs_max; /* maximum supported size with compression */
- struct pwc_coord image, view; /* image and viewport size */
- struct pwc_coord offset; /* offset within the viewport */
-
- void *image_data; /* total buffer, which is subdivided into ... */
- void *image_ptr[MAX_IMAGES]; /* ...several images... */
- int fill_image; /* ...which are rotated. */
- int len_per_image; /* length per image */
- int image_read_pos; /* In case we read data in pieces, keep track of were we are in the imagebuffer */
- int image_used[MAX_IMAGES]; /* For MCAPTURE and SYNC */
-
- struct semaphore modlock; /* to prevent races in video_open(), etc */
- spinlock_t ptrlock; /* for manipulating the buffer pointers */
-
- /*** motorized pan/tilt feature */
- struct pwc_mpt_range angle_range;
- int pan_angle; /* in degrees * 100 */
- int tilt_angle; /* absolute angle; 0,0 is home position */
-
- /*** Misc. data ***/
- wait_queue_head_t frameq; /* When waiting for a frame to finish... */
-#if PWC_INT_PIPE
- void *usb_int_handler; /* for the interrupt endpoint */
-#endif
-};
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Global variables */
-extern int pwc_trace;
-extern int pwc_preferred_compression;
-
-/** functions in pwc-if.c */
-int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot);
-
-/** Functions in pwc-misc.c */
-/* sizes in pixels */
-extern struct pwc_coord pwc_image_sizes[PSZ_MAX];
-
-int pwc_decode_size(struct pwc_device *pdev, int width, int height);
-void pwc_construct(struct pwc_device *pdev);
-
-/** Functions in pwc-ctrl.c */
-/* Request a certain video mode. Returns < 0 if not possible */
-extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot);
-/* Calculate the number of bytes per image (not frame) */
-extern void pwc_set_image_buffer_size(struct pwc_device *pdev);
-
-/* Various controls; should be obvious. Value 0..65535, or < 0 on error */
-extern int pwc_get_brightness(struct pwc_device *pdev);
-extern int pwc_set_brightness(struct pwc_device *pdev, int value);
-extern int pwc_get_contrast(struct pwc_device *pdev);
-extern int pwc_set_contrast(struct pwc_device *pdev, int value);
-extern int pwc_get_gamma(struct pwc_device *pdev);
-extern int pwc_set_gamma(struct pwc_device *pdev, int value);
-extern int pwc_get_saturation(struct pwc_device *pdev);
-extern int pwc_set_saturation(struct pwc_device *pdev, int value);
-extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
-extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
-extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
-
-/* Power down or up the camera; not supported by all models */
-extern int pwc_camera_power(struct pwc_device *pdev, int power);
-
-/* Private ioctl()s; see pwc-ioctl.h */
-extern int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
-
-
-/** pwc-uncompress.c */
-/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
-extern int pwc_decompress(struct pwc_device *pdev);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
+++ /dev/null
- /* SQCIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* QSIF */
- {
- /* 5 fps */
- {
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- },
- /* 10 fps */
- {
- {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- },
- /* 15 fps */
- {
- {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
- {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
- {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
- {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
- },
- /* 20 fps */
- {
- {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
- {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
- {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
- {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
- },
- /* 25 fps */
- {
- {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
- {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
- {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
- {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
- },
- /* 30 fps */
- {
- {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
- {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
- {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
- {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
- },
- },
- /* QCIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* SIF */
- {
- /* 5 fps */
- {
- {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
- {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
- {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
- {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
- },
- /* 10 fps */
- {
- {0, },
- {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
- {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
- {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
- {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
- {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
- {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
- {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
- {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
- {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
- {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
- {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
- },
- },
- /* CIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* VGA */
- {
- /* 5 fps */
- {
- {0, },
- {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
- {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
- {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
- {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
- {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
- {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
- {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
+++ /dev/null
- /* SQCIF */
- {
- {0, 0, {0x04, 0x01, 0x03}},
- {8, 0, {0x05, 0x01, 0x03}},
- {7, 0, {0x08, 0x01, 0x03}},
- {7, 0, {0x0A, 0x01, 0x03}},
- {6, 0, {0x0C, 0x01, 0x03}},
- {5, 0, {0x0F, 0x01, 0x03}},
- {4, 0, {0x14, 0x01, 0x03}},
- {3, 0, {0x18, 0x01, 0x03}},
- },
- /* QSIF */
- {
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- },
- /* QCIF */
- {
- {0, 0, {0x04, 0x01, 0x02}},
- {8, 0, {0x05, 0x01, 0x02}},
- {7, 0, {0x08, 0x01, 0x02}},
- {6, 0, {0x0A, 0x01, 0x02}},
- {5, 0, {0x0C, 0x01, 0x02}},
- {4, 0, {0x0F, 0x01, 0x02}},
- {1, 0, {0x14, 0x01, 0x02}},
- {1, 0, {0x18, 0x01, 0x02}},
- },
- /* SIF */
- {
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- },
- /* CIF */
- {
- {4, 0, {0x04, 0x01, 0x01}},
- {7, 1, {0x05, 0x03, 0x01}},
- {6, 1, {0x08, 0x03, 0x01}},
- {4, 1, {0x0A, 0x03, 0x01}},
- {3, 1, {0x0C, 0x03, 0x01}},
- {2, 1, {0x0F, 0x03, 0x01}},
- {0},
- {0},
- },
- /* VGA */
- {
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- {0},
- },
+++ /dev/null
- /* SQCIF */
- {
- /* 5 fps */
- {
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- },
- /* 10 fps */
- {
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- },
- /* 15 fps */
- {
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- },
- /* 20 fps */
- {
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- },
- /* 25 fps */
- {
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- },
- /* 30 fps */
- {
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- },
- },
- /* QSIF */
- {
- /* 5 fps */
- {
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- },
- /* 10 fps */
- {
- {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- },
- /* 15 fps */
- {
- {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
- {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- },
- /* 20 fps */
- {
- {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
- {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
- },
- /* 25 fps */
- {
- {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
- {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
- {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
- {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
- {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
- },
- },
- /* QCIF */
- {
- /* 5 fps */
- {
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- },
- /* 10 fps */
- {
- {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
- {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
- },
- /* 15 fps */
- {
- {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
- {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
- },
- /* 20 fps */
- {
- {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
- {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
- {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
- },
- /* 25 fps */
- {
- {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
- {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
- {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
- {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
- {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
- },
- },
- /* SIF */
- {
- /* 5 fps */
- {
- {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
- {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
- {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
- {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
- {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
- {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
- {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
- {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
- {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
- {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
- {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
- {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
- {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
- {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
- },
- },
- /* CIF */
- {
- /* 5 fps */
- {
- {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
- {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
- {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
- {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
- {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
- {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
- {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
- {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
- {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
- {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
- {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
- {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
- {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
- {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
- },
- },
- /* VGA */
- {
- /* 5 fps */
- {
- {0, },
- {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
- {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
- {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
- {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
- {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
- {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
- {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
+++ /dev/null
-/***************************************************************************
- * Various definitions for compatibility with OVCAMCHIP external module. *
- * This file is part of the W996[87]CF driver for Linux. *
- * *
- * The definitions have been taken from the OVCAMCHIP module written by *
- * Mark McClelland. *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
- ***************************************************************************/
-
-#ifndef _W9968CF_EXTERNALDEF_H_
-#define _W9968CF_EXTERNALDEF_H_
-
-#include <linux/videodev.h>
-#include <linux/i2c.h>
-#include <asm/ioctl.h>
-#include <asm/types.h>
-
-#ifndef I2C_DRIVERID_OVCAMCHIP
-# define I2C_DRIVERID_OVCAMCHIP 0xf00f
-#endif
-
-/* Controls */
-enum {
- OVCAMCHIP_CID_CONT, /* Contrast */
- OVCAMCHIP_CID_BRIGHT, /* Brightness */
- OVCAMCHIP_CID_SAT, /* Saturation */
- OVCAMCHIP_CID_HUE, /* Hue */
- OVCAMCHIP_CID_EXP, /* Exposure */
- OVCAMCHIP_CID_FREQ, /* Light frequency */
- OVCAMCHIP_CID_BANDFILT, /* Banding filter */
- OVCAMCHIP_CID_AUTOBRIGHT, /* Auto brightness */
- OVCAMCHIP_CID_AUTOEXP, /* Auto exposure */
- OVCAMCHIP_CID_BACKLIGHT, /* Back light compensation */
- OVCAMCHIP_CID_MIRROR, /* Mirror horizontally */
-};
-
-/* I2C addresses */
-#define OV7xx0_SID (0x42 >> 1)
-#define OV6xx0_SID (0xC0 >> 1)
-
-/* Sensor types */
-enum {
- CC_UNKNOWN,
- CC_OV76BE,
- CC_OV7610,
- CC_OV7620,
- CC_OV7620AE,
- CC_OV6620,
- CC_OV6630,
- CC_OV6630AE,
- CC_OV6630AF,
-};
-
-/* API */
-struct ovcamchip_control {
- __u32 id;
- __s32 value;
-};
-
-struct ovcamchip_window {
- int x;
- int y;
- int width;
- int height;
- int format;
- int quarter; /* Scale width and height down 2x */
-
- /* This stuff will be removed eventually */
- int clockdiv; /* Clock divisor setting */
-};
-
-/* Commands.
- You must call OVCAMCHIP_CMD_INITIALIZE before any of other commands */
-#define OVCAMCHIP_CMD_Q_SUBTYPE _IOR (0x88, 0x00, int)
-#define OVCAMCHIP_CMD_INITIALIZE _IOW (0x88, 0x01, int)
-#define OVCAMCHIP_CMD_S_CTRL _IOW (0x88, 0x02, struct ovcamchip_control)
-#define OVCAMCHIP_CMD_G_CTRL _IOWR (0x88, 0x03, struct ovcamchip_control)
-#define OVCAMCHIP_CMD_S_MODE _IOW (0x88, 0x04, struct ovcamchip_window)
-#define OVCAMCHIP_MAX_CMD _IO (0x88, 0x3f)
-
-#endif /* _W9968CF_EXTERNALDEF_H_ */
+++ /dev/null
-/*
- * linux/fs/ext3/resize.c
- *
- * Support for resizing an ext3 filesystem while it is mounted.
- *
- * Copyright (C) 2001, 2002 Andreas Dilger <adilger@clusterfs.com>
- *
- * This could probably be made into a module, because it is not often in use.
- */
-
-#include <linux/config.h>
-
-#define EXT3FS_DEBUG
-
-#include <linux/sched.h>
-#include <linux/smp_lock.h>
-#include <linux/ext3_jbd.h>
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-
-#define outside(b, first, last) ((b) < (first) || (b) >= (last))
-#define inside(b, first, last) ((b) >= (first) && (b) < (last))
-
-static int verify_group_input(struct super_block *sb,
- struct ext3_new_group_data *input)
-{
- struct ext3_sb_info *sbi = EXT3_SB(sb);
- struct ext3_super_block *es = sbi->s_es;
- unsigned start = le32_to_cpu(es->s_blocks_count);
- unsigned end = start + input->blocks_count;
- unsigned group = input->group;
- unsigned itend = input->inode_table + EXT3_SB(sb)->s_itb_per_group;
- unsigned overhead = ext3_bg_has_super(sb, group) ?
- (1 + ext3_bg_num_gdb(sb, group) +
- le16_to_cpu(es->s_reserved_gdt_blocks)) : 0;
- unsigned metaend = start + overhead;
- struct buffer_head *bh;
- int free_blocks_count;
- int err = -EINVAL;
-
- input->free_blocks_count = free_blocks_count =
- input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
-
- if (test_opt(sb, DEBUG))
- printk("EXT3-fs: adding %s group %u: %u blocks "
- "(%d free, %u reserved)\n",
- ext3_bg_has_super(sb, input->group) ? "normal" :
- "no-super", input->group, input->blocks_count,
- free_blocks_count, input->reserved_blocks);
-
- if (group != sbi->s_groups_count)
- ext3_warning(sb, __FUNCTION__,
- "Cannot add at group %u (only %lu groups)",
- input->group, sbi->s_groups_count);
- else if ((start - le32_to_cpu(es->s_first_data_block)) %
- EXT3_BLOCKS_PER_GROUP(sb))
- ext3_warning(sb, __FUNCTION__, "Last group not full");
- else if (input->reserved_blocks > input->blocks_count / 5)
- ext3_warning(sb, __FUNCTION__, "Reserved blocks too high (%u)",
- input->reserved_blocks);
- else if (free_blocks_count < 0)
- ext3_warning(sb, __FUNCTION__, "Bad blocks count %u",
- input->blocks_count);
- else if (!(bh = sb_bread(sb, end - 1)))
- ext3_warning(sb, __FUNCTION__, "Cannot read last block (%u)",
- end - 1);
- else if (outside(input->block_bitmap, start, end))
- ext3_warning(sb, __FUNCTION__,
- "Block bitmap not in group (block %u)",
- input->block_bitmap);
- else if (outside(input->inode_bitmap, start, end))
- ext3_warning(sb, __FUNCTION__,
- "Inode bitmap not in group (block %u)",
- input->inode_bitmap);
- else if (outside(input->inode_table, start, end) ||
- outside(itend - 1, start, end))
- ext3_warning(sb, __FUNCTION__,
- "Inode table not in group (blocks %u-%u)",
- input->inode_table, itend - 1);
- else if (input->inode_bitmap == input->block_bitmap)
- ext3_warning(sb, __FUNCTION__,
- "Block bitmap same as inode bitmap (%u)",
- input->block_bitmap);
- else if (inside(input->block_bitmap, input->inode_table, itend))
- ext3_warning(sb, __FUNCTION__,
- "Block bitmap (%u) in inode table (%u-%u)",
- input->block_bitmap, input->inode_table, itend-1);
- else if (inside(input->inode_bitmap, input->inode_table, itend))
- ext3_warning(sb, __FUNCTION__,
- "Inode bitmap (%u) in inode table (%u-%u)",
- input->inode_bitmap, input->inode_table, itend-1);
- else if (inside(input->block_bitmap, start, metaend))
- ext3_warning(sb, __FUNCTION__,
- "Block bitmap (%u) in GDT table (%u-%u)",
- input->block_bitmap, start, metaend - 1);
- else if (inside(input->inode_bitmap, start, metaend))
- ext3_warning(sb, __FUNCTION__,
- "Inode bitmap (%u) in GDT table (%u-%u)",
- input->inode_bitmap, start, metaend - 1);
- else if (inside(input->inode_table, start, metaend) ||
- inside(itend - 1, start, metaend))
- ext3_warning(sb, __FUNCTION__,
- "Inode table (%u-%u) overlaps GDT table (%u-%u)",
- input->inode_table, itend - 1, start, metaend - 1);
- else {
- brelse(bh);
- err = 0;
- }
-
- return err;
-}
-
-static struct buffer_head *bclean(handle_t *handle, struct super_block *sb,
- unsigned long blk)
-{
- struct buffer_head *bh;
- int err;
-
- bh = sb_getblk(sb, blk);
- set_buffer_uptodate(bh);
- if ((err = ext3_journal_get_write_access(handle, bh))) {
- brelse(bh);
- bh = ERR_PTR(err);
- } else
- memset(bh->b_data, 0, sb->s_blocksize);
-
- return bh;
-}
-
-/*
- * To avoid calling the atomic setbit hundreds or thousands of times, we only
- * need to use it within a single byte (to ensure we get endianness right).
- * We can use memset for the rest of the bitmap as there are no other users.
- */
-static void mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
-{
- int i;
-
- if (start_bit >= end_bit)
- return;
-
- ext3_debug("mark end bits +%d through +%d used\n", start_bit, end_bit);
- for (i = start_bit; i < ((start_bit + 7) & ~7UL); i++)
- ext3_set_bit(i, bitmap);
- if (i < end_bit)
- memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
-}
-
-/*
- * Set up the block and inode bitmaps, and the inode table for the new group.
- * This doesn't need to be part of the main transaction, since we are only
- * changing blocks outside the actual filesystem. We still do journaling to
- * ensure the recovery is correct in case of a failure just after resize.
- * If any part of this fails, we simply abort the resize.
- *
- * We only pass inode because of the ext3 journal wrappers.
- */
-static int setup_new_group_blocks(struct super_block *sb, struct inode *inode,
- struct ext3_new_group_data *input)
-{
- struct ext3_sb_info *sbi = EXT3_SB(sb);
- unsigned long start = input->group * sbi->s_blocks_per_group +
- le32_to_cpu(sbi->s_es->s_first_data_block);
- int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
- le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) : 0;
- unsigned long gdblocks = ext3_bg_num_gdb(sb, input->group);
- struct buffer_head *bh;
- handle_t *handle;
- unsigned long block;
- int bit;
- int i;
- int err = 0, err2;
-
- handle = ext3_journal_start(inode, reserved_gdb + gdblocks +
- 2 + sbi->s_itb_per_group);
- if (IS_ERR(handle))
- return PTR_ERR(handle);
-
- lock_super(sb);
- if (input->group != sbi->s_groups_count) {
- err = -EBUSY;
- goto exit_journal;
- }
-
- if (IS_ERR(bh = bclean(handle, sb, input->block_bitmap))) {
- err = PTR_ERR(bh);
- goto exit_journal;
- }
-
- if (ext3_bg_has_super(sb, input->group)) {
- ext3_debug("mark backup superblock %#04lx (+0)\n", start);
- ext3_set_bit(0, bh->b_data);
- }
-
- /* Copy all of the GDT blocks into the backup in this group */
- for (i = 0, bit = 1, block = start + 1;
- i < gdblocks; i++, block++, bit++) {
- struct buffer_head *gdb;
-
- ext3_debug("update backup group %#04lx (+%d)\n", block, bit);
-
- gdb = sb_getblk(sb, block);
- set_buffer_uptodate(gdb);
- if ((err = ext3_journal_get_write_access(handle, gdb))) {
- brelse(gdb);
- goto exit_bh;
- }
- memcpy(gdb->b_data, sbi->s_group_desc[i], bh->b_size);
- ext3_journal_dirty_metadata(handle, gdb);
- ext3_set_bit(bit, bh->b_data);
- brelse(gdb);
- }
-
- /* Zero out all of the reserved backup group descriptor table blocks */
- for (i = 0, bit = gdblocks + 1, block = start + bit;
- i < reserved_gdb; i++, block++, bit++) {
- struct buffer_head *gdb;
-
- ext3_debug("clear reserved block %#04lx (+%d)\n", block, bit);
-
- if (IS_ERR(gdb = bclean(handle, sb, block))) {
- err = PTR_ERR(bh);
- goto exit_bh;
- }
- ext3_journal_dirty_metadata(handle, gdb);
- ext3_set_bit(bit, bh->b_data);
- brelse(gdb);
- }
- ext3_debug("mark block bitmap %#04x (+%ld)\n", input->block_bitmap,
- input->block_bitmap - start);
- ext3_set_bit(input->block_bitmap - start, bh->b_data);
- ext3_debug("mark inode bitmap %#04x (+%ld)\n", input->inode_bitmap,
- input->inode_bitmap - start);
- ext3_set_bit(input->inode_bitmap - start, bh->b_data);
-
- /* Zero out all of the inode table blocks */
- for (i = 0, block = input->inode_table, bit = block - start;
- i < sbi->s_itb_per_group; i++, bit++, block++) {
- struct buffer_head *it;
-
- ext3_debug("clear inode block %#04x (+%ld)\n", block, bit);
- if (IS_ERR(it = bclean(handle, sb, block))) {
- err = PTR_ERR(it);
- goto exit_bh;
- }
- ext3_journal_dirty_metadata(handle, it);
- brelse(it);
- ext3_set_bit(bit, bh->b_data);
- }
- mark_bitmap_end(input->blocks_count, EXT3_BLOCKS_PER_GROUP(sb),
- bh->b_data);
- ext3_journal_dirty_metadata(handle, bh);
- brelse(bh);
-
- /* Mark unused entries in inode bitmap used */
- ext3_debug("clear inode bitmap %#04x (+%ld)\n",
- input->inode_bitmap, input->inode_bitmap - start);
- if (IS_ERR(bh = bclean(handle, sb, input->inode_bitmap))) {
- err = PTR_ERR(bh);
- goto exit_journal;
- }
-
- mark_bitmap_end(EXT3_INODES_PER_GROUP(sb), EXT3_BLOCKS_PER_GROUP(sb),
- bh->b_data);
- ext3_journal_dirty_metadata(handle, bh);
-exit_bh:
- brelse(bh);
-
-exit_journal:
- unlock_super(sb);
- if ((err2 = ext3_journal_stop(handle)) && !err)
- err = err2;
-
- return err;
-}
-
-/*
- * Iterate through the groups which hold BACKUP superblock/GDT copies in an
- * ext3 filesystem. The counters should be initialized to 1, 5, and 7 before
- * calling this for the first time. In a sparse filesystem it will be the
- * sequence of powers of 3, 5, and 7: 1, 3, 5, 7, 9, 25, 27, 49, 81, ...
- * For a non-sparse filesystem it will be every group: 1, 2, 3, 4, ...
- */
-unsigned ext3_list_backups(struct super_block *sb, unsigned *three,
- unsigned *five, unsigned *seven)
-{
- unsigned *min = three;
- int mult = 3;
- unsigned ret;
-
- if (!EXT3_HAS_RO_COMPAT_FEATURE(sb,
- EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
- ret = *min;
- *min += 1;
- return ret;
- }
-
- if (*five < *min) {
- min = five;
- mult = 5;
- }
- if (*seven < *min) {
- min = seven;
- mult = 7;
- }
-
- ret = *min;
- *min *= mult;
-
- return ret;
-}
-
-/*
- * Check that all of the backup GDT blocks are held in the primary GDT block.
- * It is assumed that they are stored in group order. Returns the number of
- * groups in current filesystem that have BACKUPS, or -ve error code.
- */
-static int verify_reserved_gdb(struct super_block *sb,
- struct buffer_head *primary)
-{
- const unsigned long blk = primary->b_blocknr;
- const unsigned long end = EXT3_SB(sb)->s_groups_count;
- unsigned three = 1;
- unsigned five = 5;
- unsigned seven = 7;
- unsigned grp;
- __u32 *p = (__u32 *)primary->b_data;
- int gdbackups = 0;
-
- while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
- if (le32_to_cpu(*p++) != grp * EXT3_BLOCKS_PER_GROUP(sb) + blk){
- ext3_warning(sb, __FUNCTION__,
- "reserved GDT %ld missing grp %d (%ld)\n",
- blk, grp,
- grp * EXT3_BLOCKS_PER_GROUP(sb) + blk);
- return -EINVAL;
- }
- if (++gdbackups > EXT3_ADDR_PER_BLOCK(sb))
- return -EFBIG;
- }
-
- return gdbackups;
-}
-
-/*
- * Called when we need to bring a reserved group descriptor table block into
- * use from the resize inode. The primary copy of the new GDT block currently
- * is an indirect block (under the double indirect block in the resize inode).
- * The new backup GDT blocks will be stored as leaf blocks in this indirect
- * block, in group order. Even though we know all the block numbers we need,
- * we check to ensure that the resize inode has actually reserved these blocks.
- *
- * Don't need to update the block bitmaps because the blocks are still in use.
- *
- * We get all of the error cases out of the way, so that we are sure to not
- * fail once we start modifying the data on disk, because JBD has no rollback.
- */
-static int add_new_gdb(handle_t *handle, struct inode *inode,
- struct ext3_new_group_data *input,
- struct buffer_head **primary)
-{
- struct super_block *sb = inode->i_sb;
- struct ext3_super_block *es = EXT3_SB(sb)->s_es;
- unsigned long gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
- unsigned long gdb_off = input->group % EXT3_DESC_PER_BLOCK(sb);
- unsigned long gdblock = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + gdb_num;
- struct buffer_head **o_group_desc, **n_group_desc;
- struct buffer_head *dind;
- int gdbackups;
- struct ext3_iloc iloc;
- __u32 *data;
- int err;
-
- if (test_opt(sb, DEBUG))
- printk("EXT3-fs: ext3_add_new_gdb: adding group block %lu\n",
- gdb_num);
-
- /*
- * If we are not using the primary superblock/GDT copy don't resize,
- * because the user tools have no way of handling this. Probably a
- * bad time to do it anyways.
- */
- if (EXT3_SB(sb)->s_sbh->b_blocknr !=
- le32_to_cpu(EXT3_SB(sb)->s_es->s_first_data_block)) {
- ext3_warning(sb, __FUNCTION__,
- "won't resize using backup superblock at %lu\n",
- EXT3_SB(sb)->s_sbh->b_blocknr);
- return -EPERM;
- }
-
- *primary = sb_bread(sb, gdblock);
- if (!*primary)
- return -EIO;
-
- if ((gdbackups = verify_reserved_gdb(sb, *primary)) < 0) {
- err = gdbackups;
- goto exit_bh;
- }
-
- data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
- dind = sb_bread(sb, le32_to_cpu(*data));
- if (!dind) {
- err = -EIO;
- goto exit_bh;
- }
-
- data = (__u32 *)dind->b_data;
- if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
- ext3_warning(sb, __FUNCTION__,
- "new group %u GDT block %lu not reserved\n",
- input->group, gdblock);
- err = -EINVAL;
- goto exit_dind;
- }
-
- if ((err = ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh)))
- goto exit_dind;
-
- if ((err = ext3_journal_get_write_access(handle, *primary)))
- goto exit_sbh;
-
- if ((err = ext3_journal_get_write_access(handle, dind)))
- goto exit_primary;
-
- /* ext3_reserve_inode_write() gets a reference on the iloc */
- if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
- goto exit_dindj;
-
- n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) *
- sizeof(struct buffer_head *), GFP_KERNEL);
- if (!n_group_desc) {
- err = -ENOMEM;
- ext3_warning (sb, __FUNCTION__,
- "not enough memory for %lu groups", gdb_num + 1);
- goto exit_inode;
- }
-
- /*
- * Finally, we have all of the possible failures behind us...
- *
- * Remove new GDT block from inode double-indirect block and clear out
- * the new GDT block for use (which also "frees" the backup GDT blocks
- * from the reserved inode). We don't need to change the bitmaps for
- * these blocks, because they are marked as in-use from being in the
- * reserved inode, and will become GDT blocks (primary and backup).
- */
- /*
- printk("removing block %d = %ld from dindir %ld[%ld]\n",
- ((__u32 *)(dind->b_data))[gdb_off], gdblock, dind->b_blocknr,
- gdb_num); */
- data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)] = 0;
- ext3_journal_dirty_metadata(handle, dind);
- brelse(dind);
- inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
- ext3_mark_iloc_dirty(handle, inode, &iloc);
- memset((*primary)->b_data, 0, sb->s_blocksize);
- ext3_journal_dirty_metadata(handle, *primary);
-
- o_group_desc = EXT3_SB(sb)->s_group_desc;
- memcpy(n_group_desc, o_group_desc,
- EXT3_SB(sb)->s_gdb_count * sizeof(struct buffer_head *));
- n_group_desc[gdb_num] = *primary;
- EXT3_SB(sb)->s_group_desc = n_group_desc;
- EXT3_SB(sb)->s_gdb_count++;
- kfree(o_group_desc);
-
- es->s_reserved_gdt_blocks =
- cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
- ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
-
- return 0;
-
-exit_inode:
- //ext3_journal_release_buffer(handle, iloc.bh);
- brelse(iloc.bh);
-exit_dindj:
- //ext3_journal_release_buffer(handle, dind);
-exit_primary:
- //ext3_journal_release_buffer(handle, *primary);
-exit_sbh:
- //ext3_journal_release_buffer(handle, *primary);
-exit_dind:
- brelse(dind);
-exit_bh:
- brelse(*primary);
-
- ext3_debug("leaving with error %d\n", err);
- return err;
-}
-
-/*
- * Called when we are adding a new group which has a backup copy of each of
- * the GDT blocks (i.e. sparse group) and there are reserved GDT blocks.
- * We need to add these reserved backup GDT blocks to the resize inode, so
- * that they are kept for future resizing and not allocated to files.
- *
- * Each reserved backup GDT block will go into a different indirect block.
- * The indirect blocks are actually the primary reserved GDT blocks,
- * so we know in advance what their block numbers are. We only get the
- * double-indirect block to verify it is pointing to the primary reserved
- * GDT blocks so we don't overwrite a data block by accident. The reserved
- * backup GDT blocks are stored in their reserved primary GDT block.
- */
-static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
- struct ext3_new_group_data *input)
-{
- struct super_block *sb = inode->i_sb;
- int reserved_gdb =le16_to_cpu(EXT3_SB(sb)->s_es->s_reserved_gdt_blocks);
- struct buffer_head **primary;
- struct buffer_head *dind;
- struct ext3_iloc iloc;
- unsigned long blk;
- __u32 *data, *end;
- int gdbackups = 0;
- int res, i;
- int err;
-
- primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_KERNEL);
- if (!primary)
- return -ENOMEM;
-
- data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
- dind = sb_bread(sb, le32_to_cpu(*data));
- if (!dind) {
- err = -EIO;
- goto exit_free;
- }
-
- blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
- data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
- end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
-
- /* Get each reserved primary GDT block and verify it holds backups */
- for (res = 0; res < reserved_gdb; res++, blk++) {
- if (le32_to_cpu(*data) != blk) {
- ext3_warning(sb, __FUNCTION__,
- "reserved block %lu not at offset %ld\n",
- blk, (long)(data - (__u32 *)dind->b_data));
- err = -EINVAL;
- goto exit_bh;
- }
- primary[res] = sb_bread(sb, blk);
- if (!primary[res]) {
- err = -EIO;
- goto exit_bh;
- }
- if ((gdbackups = verify_reserved_gdb(sb, primary[res])) < 0) {
- brelse(primary[res]);
- err = gdbackups;
- goto exit_bh;
- }
- if (++data >= end)
- data = (__u32 *)dind->b_data;
- }
-
- for (i = 0; i < reserved_gdb; i++) {
- if ((err = ext3_journal_get_write_access(handle, primary[i]))) {
- /*
- int j;
- for (j = 0; j < i; j++)
- ext3_journal_release_buffer(handle, primary[j]);
- */
- goto exit_bh;
- }
- }
-
- if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
- goto exit_bh;
-
- /*
- * Finally we can add each of the reserved backup GDT blocks from
- * the new group to its reserved primary GDT block.
- */
- blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
- for (i = 0; i < reserved_gdb; i++) {
- int err2;
- data = (__u32 *)primary[i]->b_data;
- /* printk("reserving backup %lu[%u] = %lu\n",
- primary[i]->b_blocknr, gdbackups,
- blk + primary[i]->b_blocknr); */
- data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
- err2 = ext3_journal_dirty_metadata(handle, primary[i]);
- if (!err)
- err = err2;
- }
- inode->i_blocks += reserved_gdb * sb->s_blocksize >> 9;
- ext3_mark_iloc_dirty(handle, inode, &iloc);
-
-exit_bh:
- while (--res >= 0)
- brelse(primary[res]);
- brelse(dind);
-
-exit_free:
- kfree(primary);
-
- return err;
-}
-
-/*
- * Update the backup copies of the ext3 metadata. These don't need to be part
- * of the main resize transaction, because e2fsck will re-write them if there
- * is a problem (basically only OOM will cause a problem). However, we
- * _should_ update the backups if possible, in case the primary gets trashed
- * for some reason and we need to run e2fsck from a backup superblock. The
- * important part is that the new block and inode counts are in the backup
- * superblocks, and the location of the new group metadata in the GDT backups.
- *
- * We do not need lock_super() for this, because these blocks are not
- * otherwise touched by the filesystem code when it is mounted. We don't
- * need to worry about last changing from sbi->s_groups_count, because the
- * worst that can happen is that we do not copy the full number of backups
- * at this time. The resize which changed s_groups_count will backup again.
- *
- * We only pass inode because of the ext3 journal wrappers.
- */
-static void update_backups(struct super_block *sb, struct inode *inode,
- int blk_off, char *data, int size)
-{
- struct ext3_sb_info *sbi = EXT3_SB(sb);
- const unsigned long last = sbi->s_groups_count;
- const int bpg = EXT3_BLOCKS_PER_GROUP(sb);
- unsigned three = 1;
- unsigned five = 5;
- unsigned seven = 7;
- unsigned group;
- int rest = sb->s_blocksize - size;
- handle_t *handle;
- int err = 0, err2;
-
- handle = ext3_journal_start(inode, EXT3_MAX_TRANS_DATA);
- if (IS_ERR(handle)) {
- group = 1;
- err = PTR_ERR(handle);
- goto exit_err;
- }
-
- while ((group = ext3_list_backups(sb, &three, &five, &seven)) < last) {
- struct buffer_head *bh;
-
- /* Out of journal space, and can't get more - abort - so sad */
- if (handle->h_buffer_credits == 0 &&
- ext3_journal_extend(handle, EXT3_MAX_TRANS_DATA) &&
- (err = ext3_journal_restart(handle, EXT3_MAX_TRANS_DATA)))
- break;
-
- bh = sb_getblk(sb, group * bpg + blk_off);
- set_buffer_uptodate(bh);
- ext3_debug(sb, __FUNCTION__, "update metadata backup %#04lx\n",
- bh->b_blocknr);
- if ((err = ext3_journal_get_write_access(handle, bh)))
- break;
- memcpy(bh->b_data, data, size);
- if (rest)
- memset(bh->b_data + size, 0, rest);
- ext3_journal_dirty_metadata(handle, bh);
- brelse(bh);
- }
- if ((err2 = ext3_journal_stop(handle)) && !err)
- err = err2;
-
- /*
- * Ugh! Need to have e2fsck write the backup copies. It is too
- * late to revert the resize, we shouldn't fail just because of
- * the backup copies (they are only needed in case of corruption).
- *
- * However, if we got here we have a journal problem too, so we
- * can't really start a transaction to mark the superblock.
- * Chicken out and just set the flag on the hope it will be written
- * to disk, and if not - we will simply wait until next fsck.
- */
-exit_err:
- if (err) {
- ext3_warning(sb, __FUNCTION__,
- "can't update backup for group %d (err %d), "
- "forcing fsck on next reboot\n", group, err);
- sbi->s_mount_state &= ~EXT3_VALID_FS;
- sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
- mark_buffer_dirty(sbi->s_sbh);
- }
-}
-
-/* Add group descriptor data to an existing or new group descriptor block.
- * Ensure we handle all possible error conditions _before_ we start modifying
- * the filesystem, because we cannot abort the transaction and not have it
- * write the data to disk.
- *
- * If we are on a GDT block boundary, we need to get the reserved GDT block.
- * Otherwise, we may need to add backup GDT blocks for a sparse group.
- *
- * We only need to hold the superblock lock while we are actually adding
- * in the new group's counts to the superblock. Prior to that we have
- * not really "added" the group at all. We re-check that we are still
- * adding in the last group in case things have changed since verifying.
- */
-int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
-{
- struct ext3_sb_info *sbi = EXT3_SB(sb);
- struct ext3_super_block *es = sbi->s_es;
- int reserved_gdb = ext3_bg_has_super(sb, input->group) ?
- le16_to_cpu(es->s_reserved_gdt_blocks) : 0;
- struct buffer_head *primary = NULL;
- struct ext3_group_desc *gdp;
- struct inode *inode = NULL;
- struct inode bogus;
- handle_t *handle;
- int gdb_off, gdb_num;
- int err, err2;
-
- gdb_num = input->group / EXT3_DESC_PER_BLOCK(sb);
- gdb_off = input->group % EXT3_DESC_PER_BLOCK(sb);
-
- if (gdb_off == 0 && !EXT3_HAS_RO_COMPAT_FEATURE(sb,
- EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
- ext3_warning(sb, __FUNCTION__,
- "Can't resize non-sparse filesystem further\n");
- return -EPERM;
- }
-
- if (reserved_gdb || gdb_off == 0) {
- if (!EXT3_HAS_COMPAT_FEATURE(sb,
- EXT3_FEATURE_COMPAT_RESIZE_INODE)){
- ext3_warning(sb, __FUNCTION__,
- "No reserved GDT blocks, can't resize\n");
- return -EPERM;
- }
- inode = iget(sb, EXT3_RESIZE_INO);
- if (!inode || is_bad_inode(inode)) {
- ext3_warning(sb, __FUNCTION__,
- "Error opening resize inode\n");
- iput(inode);
- return -ENOENT;
- }
- } else {
- /* Used only for ext3 journal wrapper functions to get sb */
- inode = &bogus;
- bogus.i_sb = sb;
- }
-
- if ((err = verify_group_input(sb, input)))
- goto exit_put;
-
- if ((err = setup_new_group_blocks(sb, inode, input)))
- goto exit_put;
-
- /*
- * We will always be modifying at least the superblock and a GDT
- * block. If we are adding a group past the last current GDT block,
- * we will also modify the inode and the dindirect block. If we
- * are adding a group with superblock/GDT backups we will also
- * modify each of the reserved GDT dindirect blocks.
- */
- handle = ext3_journal_start(inode, ext3_bg_has_super(sb, input->group) ?
- 3 + reserved_gdb : 4);
- if (IS_ERR(handle)) {
- err = PTR_ERR(handle);
- goto exit_put;
- }
-
- lock_super(sb);
- if (input->group != EXT3_SB(sb)->s_groups_count) {
- ext3_warning(sb, __FUNCTION__,
- "multiple resizers run on filesystem!\n");
- goto exit_journal;
- }
-
- if ((err = ext3_journal_get_write_access(handle, sbi->s_sbh)))
- goto exit_journal;
-
- /*
- * We will only either add reserved group blocks to a backup group
- * or remove reserved blocks for the first group in a new group block.
- * Doing both would be mean more complex code, and sane people don't
- * use non-sparse filesystems anymore. This is already checked above.
- */
- if (gdb_off) {
- primary = sbi->s_group_desc[gdb_num];
- if ((err = ext3_journal_get_write_access(handle, primary)))
- goto exit_journal;
-
- if (reserved_gdb && ext3_bg_num_gdb(sb, input->group) &&
- (err = reserve_backup_gdb(handle, inode, input)))
- goto exit_journal;
- } else if ((err = add_new_gdb(handle, inode, input, &primary)))
- goto exit_journal;
-
- /* Finally update group descriptor block for new group */
- gdp = (struct ext3_group_desc *)primary->b_data + gdb_off;
-
- gdp->bg_block_bitmap = cpu_to_le32(input->block_bitmap);
- gdp->bg_inode_bitmap = cpu_to_le32(input->inode_bitmap);
- gdp->bg_inode_table = cpu_to_le32(input->inode_table);
- gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
- gdp->bg_free_inodes_count = cpu_to_le16(EXT3_INODES_PER_GROUP(sb));
-
- EXT3_SB(sb)->s_groups_count++;
- ext3_journal_dirty_metadata(handle, primary);
-
- /* Update superblock with new block counts */
- es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) +
- input->blocks_count);
- es->s_free_blocks_count =
- cpu_to_le32(le32_to_cpu(es->s_free_blocks_count) +
- input->free_blocks_count);
- es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) +
- input->reserved_blocks);
- es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
- EXT3_INODES_PER_GROUP(sb));
- es->s_free_inodes_count =
- cpu_to_le32(le32_to_cpu(es->s_free_inodes_count) +
- EXT3_INODES_PER_GROUP(sb));
- ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
- sb->s_dirt = 1;
-
-exit_journal:
- unlock_super(sb);
- handle->h_sync = 1;
- if ((err2 = ext3_journal_stop(handle)) && !err)
- err = err2;
- if (!err) {
- update_backups(sb, inode, sbi->s_sbh->b_blocknr, (char *)es,
- sizeof(struct ext3_super_block));
- update_backups(sb, inode, primary->b_blocknr, primary->b_data,
- primary->b_size);
- }
-exit_put:
- if (inode != &bogus)
- iput(inode);
- return err;
-} /* ext3_group_add */
-
-/* Extend the filesystem to the new number of blocks specified. This entry
- * point is only used to extend the current filesystem to the end of the last
- * existing group. It can be accessed via ioctl, or by "remount,resize=<size>"
- * for emergencies (because it has no dependencies on reserved blocks).
- *
- * If we _really_ wanted, we could use default values to call ext3_group_add()
- * allow the "remount" trick to work for arbitrary resizing, assuming enough
- * GDT blocks are reserved to grow to the desired size.
- */
-int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
- unsigned long n_blocks_count)
-{
- unsigned long o_blocks_count;
- unsigned long o_groups_count;
- unsigned long last;
- int add;
- struct inode *inode;
- struct buffer_head * bh;
- handle_t *handle;
- int err;
-
- o_blocks_count = le32_to_cpu(es->s_blocks_count);
- o_groups_count = EXT3_SB(sb)->s_groups_count;
-
- if (test_opt(sb, DEBUG))
- printk("EXT3-fs: extending last group from %lu to %lu blocks\n",
- o_blocks_count, n_blocks_count);
-
- if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
- return 0;
-
- if (n_blocks_count < o_blocks_count) {
- ext3_warning(sb, __FUNCTION__,
- "can't shrink FS - resize aborted");
- return -EBUSY;
- }
-
- /* Handle the remaining blocks in the last group only. */
- last = (o_blocks_count - le32_to_cpu(es->s_first_data_block)) %
- EXT3_BLOCKS_PER_GROUP(sb);
-
- if (last == 0) {
- ext3_warning(sb, __FUNCTION__,
- "need to use ext2online to resize further\n");
- return -EPERM;
- }
-
- add = EXT3_BLOCKS_PER_GROUP(sb) - last;
-
- if (o_blocks_count + add > n_blocks_count)
- add = n_blocks_count - o_blocks_count;
-
- if (o_blocks_count + add < n_blocks_count)
- ext3_warning(sb, __FUNCTION__,
- "will only finish group (%lu blocks, %u new)",
- o_blocks_count + add, add);
-
- /* See if the device is actually as big as what was requested */
- bh = sb_bread(sb, o_blocks_count + add -1);
- if (!bh) {
- ext3_warning(sb, __FUNCTION__,
- "can't read last block, resize aborted");
- return -ENOSPC;
- }
- brelse(bh);
-
- /* Get a bogus inode to "free" the new blocks in this group. */
- if (!(inode = new_inode(sb))) {
- ext3_warning(sb, __FUNCTION__,
- "error getting dummy resize inode");
- return -ENOMEM;
- }
- inode->i_ino = 0;
-
- EXT3_I(inode)->i_state = EXT3_STATE_RESIZE;
-
- /* We will update the superblock, one block bitmap, and
- * one group descriptor via ext3_free_blocks().
- */
- handle = ext3_journal_start(inode, 3);
- if (IS_ERR(handle)) {
- err = PTR_ERR(handle);
- ext3_warning(sb, __FUNCTION__, "error %d on journal start",err);
- goto exit_put;
- }
-
- lock_super(sb);
- if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
- ext3_warning(sb, __FUNCTION__,
- "multiple resizers run on filesystem!\n");
- err = -EBUSY;
- goto exit_put;
- }
-
- if ((err = ext3_journal_get_write_access(handle,
- EXT3_SB(sb)->s_sbh))) {
- ext3_warning(sb, __FUNCTION__,
- "error %d on journal write access", err);
- unlock_super(sb);
- ext3_journal_stop(handle);
- goto exit_put;
- }
- es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
- ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
- sb->s_dirt = 1;
- unlock_super(sb);
- ext3_debug("freeing blocks %ld through %ld\n", o_blocks_count,
- o_blocks_count + add);
- ext3_free_blocks(handle, inode, o_blocks_count, add);
- ext3_debug("freed blocks %ld through %ld\n", o_blocks_count,
- o_blocks_count + add);
- if ((err = ext3_journal_stop(handle)))
- goto exit_put;
- if (test_opt(sb, DEBUG))
- printk("EXT3-fs: extended group to %u blocks\n",
- le32_to_cpu(es->s_blocks_count));
- update_backups(sb, inode, EXT3_SB(sb)->s_sbh->b_blocknr, (char *)es,
- sizeof(struct ext3_super_block));
-exit_put:
- iput(inode);
-
- return err;
-} /* ext3_group_extend */
+++ /dev/null
-#
-# Makefile 1.00 Peter Braam <braam@clusterfs.com>
-#
-
-obj-$(CONFIG_INTERMEZZO_FS) += intermezzo.o
-
-intermezzo-objs := cache.o dcache.o dir.o ext_attr.o file.o fileset.o \
- inode.o journal.o journal_ext2.o journal_ext3.o \
- journal_obdfs.o journal_reiserfs.o journal_tmpfs.o journal_xfs.o \
- kml_reint.o kml_unpack.o methods.o presto.o psdev.o replicator.o \
- super.o sysctl.o upcall.o vfs.o
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/module.h>
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-/*
- This file contains the routines associated with managing a
- cache of files for InterMezzo. These caches have two reqs:
- - need to be found fast so they are hashed by the device,
- with an attempt to have collision chains of length 1.
- The methods for the cache are set up in methods.
-*/
-
-extern kmem_cache_t * presto_dentry_slab;
-
-/* the intent of this hash is to have collision chains of length 1 */
-#define CACHES_BITS 8
-#define CACHES_SIZE (1 << CACHES_BITS)
-#define CACHES_MASK CACHES_SIZE - 1
-static struct list_head presto_caches[CACHES_SIZE];
-
-static inline int presto_cache_hash(struct super_block *s)
-{
- return (CACHES_MASK) & ((unsigned long)s >> L1_CACHE_SHIFT);
-}
-
-inline void presto_cache_add(struct presto_cache *cache)
-{
- list_add(&cache->cache_chain,
- &presto_caches[presto_cache_hash(cache->cache_sb)]);
-}
-
-inline void presto_cache_init_hash(void)
-{
- int i;
- for ( i = 0; i < CACHES_SIZE; i++ ) {
- INIT_LIST_HEAD(&presto_caches[i]);
- }
-}
-
-int izo_ioctl_packlen(struct izo_ioctl_data *data)
-{
- int len = sizeof(struct izo_ioctl_data);
- len += size_round(data->ioc_inllen1);
- len += size_round(data->ioc_inllen2);
- return len;
-}
-
-/* map a device to a cache */
-struct presto_cache *presto_cache_find(struct super_block *s)
-{
- struct presto_cache *cache;
- struct list_head *lh, *tmp;
-
- lh = tmp = &(presto_caches[presto_cache_hash(s)]);
- while ( (tmp = lh->next) != lh ) {
- cache = list_entry(tmp, struct presto_cache, cache_chain);
- if (cache->cache_sb == s)
- return cache;
- }
- return NULL;
-}
-
-
-/* map an inode to a cache */
-struct presto_cache *presto_get_cache(struct inode *inode)
-{
- struct presto_cache *cache;
- ENTRY;
- /* find the correct presto_cache here, based on the device */
- cache = presto_cache_find(inode->i_sb);
- if ( !cache ) {
- CERROR("WARNING: no presto cache for %s, ino %ld\n",
- inode->i_sb->s_id, inode->i_ino);
- EXIT;
- return NULL;
- }
- EXIT;
- return cache;
-}
-
-/* another debugging routine: check fs is InterMezzo fs */
-int presto_ispresto(struct inode *inode)
-{
- struct presto_cache *cache;
-
- if ( !inode )
- return 0;
- cache = presto_get_cache(inode);
- if ( !cache )
- return 0;
- return inode->i_sb == cache->cache_sb;
-}
-
-/* setup a cache structure when we need one */
-struct presto_cache *presto_cache_init(void)
-{
- struct presto_cache *cache;
-
- PRESTO_ALLOC(cache, sizeof(struct presto_cache));
- if ( cache ) {
- memset(cache, 0, sizeof(struct presto_cache));
- INIT_LIST_HEAD(&cache->cache_chain);
- INIT_LIST_HEAD(&cache->cache_fset_list);
- cache->cache_lock = SPIN_LOCK_UNLOCKED;
- cache->cache_reserved = 0;
- }
- return cache;
-}
-
-/* free a cache structure and all of the memory it is pointing to */
-inline void presto_free_cache(struct presto_cache *cache)
-{
- if (!cache)
- return;
-
- list_del(&cache->cache_chain);
- if (cache->cache_sb && cache->cache_sb->s_root &&
- presto_d2d(cache->cache_sb->s_root)) {
- kmem_cache_free(presto_dentry_slab,
- presto_d2d(cache->cache_sb->s_root));
- cache->cache_sb->s_root->d_fsdata = NULL;
- }
-
- PRESTO_FREE(cache, sizeof(struct presto_cache));
-}
-
-int presto_reserve_space(struct presto_cache *cache, loff_t req)
-{
- struct filter_fs *filter;
- loff_t avail;
- struct super_block *sb = cache->cache_sb;
- filter = cache->cache_filter;
- if (!filter ) {
- EXIT;
- return 0;
- }
- if (!filter->o_trops ) {
- EXIT;
- return 0;
- }
- if (!filter->o_trops->tr_avail ) {
- EXIT;
- return 0;
- }
-
- spin_lock(&cache->cache_lock);
- avail = filter->o_trops->tr_avail(cache, sb);
- CDEBUG(D_SUPER, "ESC::%ld +++> %ld \n", (long) cache->cache_reserved,
- (long) (cache->cache_reserved + req));
- CDEBUG(D_SUPER, "ESC::Avail::%ld \n", (long) avail);
- if (req + cache->cache_reserved > avail) {
- spin_unlock(&cache->cache_lock);
- EXIT;
- return -ENOSPC;
- }
- cache->cache_reserved += req;
- spin_unlock(&cache->cache_lock);
-
- EXIT;
- return 0;
-}
-
-void presto_release_space(struct presto_cache *cache, loff_t req)
-{
- CDEBUG(D_SUPER, "ESC::%ld ---> %ld \n", (long) cache->cache_reserved,
- (long) (cache->cache_reserved - req));
- spin_lock(&cache->cache_lock);
- cache->cache_reserved -= req;
- spin_unlock(&cache->cache_lock);
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Original version: Copyright (C) 1996 P. Braam and M. Callahan
- * Rewritten for Linux 2.1. Copyright (C) 1997 Carnegie Mellon University
- * d_fsdata and NFS compatiblity fixes Copyright (C) 2001 Tacit Networks, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Directory operations for InterMezzo filesystem
- */
-
-/* inode dentry alias list walking code adapted from linux/fs/dcache.c
- *
- * fs/dcache.c
- *
- * (C) 1997 Thomas Schoebel-Theuer,
- * with heavy changes by Linus Torvalds
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#include <linux/vmalloc.h>
-
-#include "intermezzo_fs.h"
-
-kmem_cache_t * presto_dentry_slab;
-
-/* called when a cache lookup succeeds */
-static int presto_d_revalidate(struct dentry *de, struct nameidata *nd)
-{
- struct inode *inode = de->d_inode;
- struct presto_file_set * root_fset;
-
- ENTRY;
- if (!inode) {
- EXIT;
- return 0;
- }
-
- if (is_bad_inode(inode)) {
- EXIT;
- return 0;
- }
-
- if (!presto_d2d(de)) {
- presto_set_dd(de);
- }
-
- if (!presto_d2d(de)) {
- EXIT;
- return 0;
- }
-
- root_fset = presto_d2d(de->d_inode->i_sb->s_root)->dd_fset;
- if (root_fset->fset_flags & FSET_FLAT_BRANCH &&
- (presto_d2d(de)->dd_fset != root_fset )) {
- presto_d2d(de)->dd_fset = root_fset;
- }
-
- EXIT;
- return 1;
-
-#if 0
- /* The following is needed for metadata on demand. */
- if ( S_ISDIR(inode->i_mode) ) {
- EXIT;
- return (presto_chk(de, PRESTO_DATA) &&
- (presto_chk(de, PRESTO_ATTR)));
- } else {
- EXIT;
- return presto_chk(de, PRESTO_ATTR);
- }
-#endif
-}
-
-static void presto_d_release(struct dentry *dentry)
-{
- if (!presto_d2d(dentry)) {
- /* This can happen for dentries from NFSd */
- return;
- }
- presto_d2d(dentry)->dd_count--;
-
- if (!presto_d2d(dentry)->dd_count) {
- kmem_cache_free(presto_dentry_slab, presto_d2d(dentry));
- dentry->d_fsdata = NULL;
- }
-}
-
-struct dentry_operations presto_dentry_ops =
-{
- .d_revalidate = presto_d_revalidate,
- .d_release = presto_d_release
-};
-
-static inline int presto_is_dentry_ROOT (struct dentry *dentry)
-{
- return(dentry_name_cmp(dentry,"ROOT") &&
- !dentry_name_cmp(dentry->d_parent,".intermezzo"));
-}
-
-static struct presto_file_set* presto_try_find_fset(struct dentry* dentry,
- int *is_under_d_intermezzo)
-{
- struct dentry* temp_dentry;
- struct presto_dentry_data *d_data;
- int found_root=0;
-
- ENTRY;
- CDEBUG(D_FSDATA, "finding fileset for %p:%s\n", dentry,
- dentry->d_name.name);
-
- *is_under_d_intermezzo = 0;
-
- /* walk up through the branch to get the fileset */
- /* The dentry we are passed presumably does not have the correct
- * fset information. However, we still want to start walking up
- * the branch from this dentry to get our found_root and
- * is_under_d_intermezzo decisions correct
- */
- for (temp_dentry = dentry ; ; temp_dentry = temp_dentry->d_parent) {
- CDEBUG(D_FSDATA, "--->dentry %p:%*s\n", temp_dentry,
- temp_dentry->d_name.len,temp_dentry->d_name.name);
- if (presto_is_dentry_ROOT(temp_dentry))
- found_root = 1;
- if (!found_root &&
- dentry_name_cmp(temp_dentry, ".intermezzo")) {
- *is_under_d_intermezzo = 1;
- }
- d_data = presto_d2d(temp_dentry);
- if (d_data) {
- /* If we found a "ROOT" dentry while walking up the
- * branch, we will journal regardless of whether
- * we are under .intermezzo or not.
- * If we are already under d_intermezzo don't reverse
- * the decision here...even if we found a "ROOT"
- * dentry above .intermezzo (if we were ever to
- * modify the directory structure).
- */
- if (!*is_under_d_intermezzo)
- *is_under_d_intermezzo = !found_root &&
- (d_data->dd_flags & PRESTO_DONT_JOURNAL);
- EXIT;
- return d_data->dd_fset;
- }
- if (temp_dentry->d_parent == temp_dentry) {
- break;
- }
- }
- EXIT;
- return NULL;
-}
-
-/* Only call this function on positive dentries */
-static struct presto_dentry_data* presto_try_find_alias_with_dd (
- struct dentry* dentry)
-{
- struct inode *inode=dentry->d_inode;
- struct list_head *head, *next, *tmp;
- struct dentry *tmp_dentry;
-
- /* Search through the alias list for dentries with d_fsdata */
- spin_lock(&dcache_lock);
- head = &inode->i_dentry;
- next = inode->i_dentry.next;
- while (next != head) {
- tmp = next;
- next = tmp->next;
- tmp_dentry = list_entry(tmp, struct dentry, d_alias);
- if (!presto_d2d(tmp_dentry)) {
- spin_unlock(&dcache_lock);
- return presto_d2d(tmp_dentry);
- }
- }
- spin_unlock(&dcache_lock);
- return NULL;
-}
-
-/* Only call this function on positive dentries */
-static void presto_set_alias_dd (struct dentry *dentry,
- struct presto_dentry_data* dd)
-{
- struct inode *inode=dentry->d_inode;
- struct list_head *head, *next, *tmp;
- struct dentry *tmp_dentry;
-
- /* Set d_fsdata for this dentry */
- dd->dd_count++;
- dentry->d_fsdata = dd;
-
- /* Now set d_fsdata for all dentries in the alias list. */
- spin_lock(&dcache_lock);
- head = &inode->i_dentry;
- next = inode->i_dentry.next;
- while (next != head) {
- tmp = next;
- next = tmp->next;
- tmp_dentry = list_entry(tmp, struct dentry, d_alias);
- if (!presto_d2d(tmp_dentry)) {
- dd->dd_count++;
- tmp_dentry->d_fsdata = dd;
- }
- }
- spin_unlock(&dcache_lock);
- return;
-}
-
-inline struct presto_dentry_data *izo_alloc_ddata(void)
-{
- struct presto_dentry_data *dd;
-
- dd = kmem_cache_alloc(presto_dentry_slab, SLAB_KERNEL);
- if (dd == NULL) {
- CERROR("IZO: out of memory trying to allocate presto_dentry_data\n");
- return NULL;
- }
- memset(dd, 0, sizeof(*dd));
- dd->dd_count = 1;
-
- return dd;
-}
-
-/* This uses the BKL! */
-int presto_set_dd(struct dentry * dentry)
-{
- struct presto_file_set *fset;
- struct presto_dentry_data *dd;
- int is_under_d_izo;
- int error=0;
-
- ENTRY;
-
- if (!dentry)
- BUG();
-
- lock_kernel();
-
- /* Did we lose a race? */
- if (dentry->d_fsdata) {
- CERROR("dentry %p already has d_fsdata set\n", dentry);
- if (dentry->d_inode)
- CERROR(" inode: %ld\n", dentry->d_inode->i_ino);
- EXIT;
- goto out_unlock;
- }
-
- if (dentry->d_inode != NULL) {
- /* NFSd runs find_fh_dentry which instantiates disconnected
- * dentries which are then connected without a lookup().
- * So it is possible to have connected dentries that do not
- * have d_fsdata set. So we walk the list trying to find
- * an alias which has its d_fsdata set and then use that
- * for all the other dentries as well.
- * - SHP,Vinny.
- */
-
- /* If there is an alias with d_fsdata use it. */
- if ((dd = presto_try_find_alias_with_dd (dentry))) {
- presto_set_alias_dd (dentry, dd);
- EXIT;
- goto out_unlock;
- }
- } else {
- /* Negative dentry */
- CDEBUG(D_FSDATA,"negative dentry %p: %*s\n", dentry,
- dentry->d_name.len, dentry->d_name.name);
- }
-
- /* No pre-existing d_fsdata, we need to construct one.
- * First, we must walk up the tree to find the fileset
- * If a fileset can't be found, we leave a null fsdata
- * and return EROFS to indicate that we can't journal
- * updates.
- */
- fset = presto_try_find_fset (dentry, &is_under_d_izo);
- if (!fset) {
-#ifdef PRESTO_NO_NFS
- CERROR("No fileset for dentry %p: %*s\n", dentry,
- dentry->d_name.len, dentry->d_name.name);
-#endif
- error = -EROFS;
- EXIT;
- goto out_unlock;
- }
-
- dentry->d_fsdata = izo_alloc_ddata();
- if (!presto_d2d(dentry)) {
- CERROR ("InterMezzo: out of memory allocating d_fsdata\n");
- error = -ENOMEM;
- goto out_unlock;
- }
- presto_d2d(dentry)->dd_fset = fset;
- if (is_under_d_izo)
- presto_d2d(dentry)->dd_flags |= PRESTO_DONT_JOURNAL;
- EXIT;
-
-out_unlock:
- CDEBUG(D_FSDATA,"presto_set_dd dentry %p: %*s, d_fsdata %p\n",
- dentry, dentry->d_name.len, dentry->d_name.name,
- dentry->d_fsdata);
- unlock_kernel();
- return error;
-}
-
-int presto_init_ddata_cache(void)
-{
- ENTRY;
- presto_dentry_slab =
- kmem_cache_create("presto_cache",
- sizeof(struct presto_dentry_data), 0,
- SLAB_HWCACHE_ALIGN, NULL,
- NULL);
- EXIT;
- return (presto_dentry_slab != NULL);
-}
-
-void presto_cleanup_ddata_cache(void)
-{
- kmem_cache_destroy(presto_dentry_slab);
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Tacitus Systems
- * Copyright (C) 2000 Peter J. Braam
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <asm/bitops.h>
-#include <asm/termios.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static inline void presto_relock_sem(struct inode *dir)
-{
- /* the lock from sys_mkdir / lookup_create */
- down(&dir->i_sem);
- /* the rest is done by the do_{create,mkdir, ...} */
-}
-
-static inline void presto_relock_other(struct inode *dir)
-{
- /* vfs_mkdir locks */
- // down(&dir->i_zombie);
- //lock_kernel();
-}
-
-static inline void presto_fulllock(struct inode *dir)
-{
- /* the lock from sys_mkdir / lookup_create */
- down(&dir->i_sem);
- /* vfs_mkdir locks */
- // down(&dir->i_zombie);
- //lock_kernel();
-}
-
-static inline void presto_unlock(struct inode *dir)
-{
- /* vfs_mkdir locks */
- //unlock_kernel();
- // up(&dir->i_zombie);
- /* the lock from sys_mkdir / lookup_create */
- up(&dir->i_sem);
-}
-
-
-/*
- * these are initialized in super.c
- */
-extern int presto_permission(struct inode *inode, int mask, struct nameidata *nd);
-static int izo_authorized_uid;
-
-int izo_dentry_is_ilookup(struct dentry *dentry, ino_t *id,
- unsigned int *generation)
-{
- char tmpname[64];
- char *next;
-
- ENTRY;
- /* prefix is 7 characters: '...ino:' */
- if ( dentry->d_name.len < 7 || dentry->d_name.len > 64 ||
- memcmp(dentry->d_name.name, PRESTO_ILOOKUP_MAGIC, 7) != 0 ) {
- EXIT;
- return 0;
- }
-
- memcpy(tmpname, dentry->d_name.name + 7, dentry->d_name.len - 7);
- *(tmpname + dentry->d_name.len - 7) = '\0';
-
- /* name is of the form ...ino:<inode number>:<generation> */
- *id = simple_strtoul(tmpname, &next, 16);
- if ( *next == PRESTO_ILOOKUP_SEP ) {
- *generation = simple_strtoul(next + 1, 0, 16);
- CDEBUG(D_INODE, "ino string: %s, Id = %lx (%lu), "
- "generation %x (%d)\n",
- tmpname, *id, *id, *generation, *generation);
- EXIT;
- return 1;
- } else {
- EXIT;
- return 0;
- }
-}
-
-struct dentry *presto_tmpfs_ilookup(struct inode *dir,
- struct dentry *dentry,
- ino_t ino,
- unsigned int generation)
-{
- return dentry;
-}
-
-
-inline int presto_can_ilookup(void)
-{
- return (current->euid == izo_authorized_uid ||
- capable(CAP_DAC_READ_SEARCH));
-}
-
-struct dentry *presto_iget_ilookup(struct inode *dir,
- struct dentry *dentry,
- ino_t ino,
- unsigned int generation)
-{
- struct inode *inode;
- int error;
-
- ENTRY;
-
- if ( !presto_can_ilookup() ) {
- CERROR("ilookup denied: euid %u, authorized_uid %u\n",
- current->euid, izo_authorized_uid);
- return ERR_PTR(-EPERM);
- }
- error = -ENOENT;
- inode = iget(dir->i_sb, ino);
- if (!inode) {
- CERROR("fatal: NULL inode ino %lu\n", ino);
- goto cleanup_iput;
- }
- if (is_bad_inode(inode) || inode->i_nlink == 0) {
- CERROR("fatal: bad inode ino %lu, links %d\n", ino, inode->i_nlink);
- goto cleanup_iput;
- }
- if (inode->i_generation != generation) {
- CERROR("fatal: bad generation %u (want %u)\n",
- inode->i_generation, generation);
- goto cleanup_iput;
- }
-
- d_instantiate(dentry, inode);
- dentry->d_flags |= DCACHE_DISCONNECTED; /* NFS hack */
-
- EXIT;
- return NULL;
-
-cleanup_iput:
- if (inode)
- iput(inode);
- return ERR_PTR(error);
-}
-
-struct dentry *presto_add_ilookup_dentry(struct dentry *parent,
- struct dentry *real)
-{
- struct inode *inode = real->d_inode;
- struct dentry *de;
- char buf[32];
- char *ptr = buf;
- struct dentry *inodir;
- struct presto_dentry_data *dd;
-
- inodir = lookup_one_len("..iopen..", parent, strlen("..iopen.."));
- if (!inodir || IS_ERR(inodir) || !inodir->d_inode ) {
- CERROR("%s: bad ..iopen.. lookup\n", __FUNCTION__);
- return NULL;
- }
- inodir->d_inode->i_op = &presto_dir_iops;
-
- snprintf(ptr, 32, "...ino:%lx:%x", inode->i_ino, inode->i_generation);
-
- de = lookup_one_len(ptr, inodir, strlen(ptr));
- if (!de || IS_ERR(de)) {
- CERROR("%s: bad ...ino lookup %ld\n",
- __FUNCTION__, PTR_ERR(de));
- dput(inodir);
- return NULL;
- }
-
- dd = presto_d2d(real);
- if (!dd)
- BUG();
-
- /* already exists */
- if (de->d_inode)
- BUG();
-#if 0
- if (de->d_inode != inode ) {
- CERROR("XX de->d_inode %ld, inode %ld\n",
- de->d_inode->i_ino, inode->i_ino);
- BUG();
- }
- if (dd->dd_inodentry) {
- CERROR("inodentry exists %ld \n", inode->i_ino);
- BUG();
- }
- dput(inodir);
- return de;
- }
-#endif
-
- if (presto_d2d(de))
- BUG();
-
- atomic_inc(&inode->i_count);
- de->d_op = &presto_dentry_ops;
- d_add(de, inode);
- if (!de->d_op)
- CERROR("DD: no ops dentry %p, dd %p\n", de, dd);
- dd->dd_inodentry = de;
- dd->dd_count++;
- de->d_fsdata = dd;
-
- dput(inodir);
- return de;
-}
-
-struct dentry *presto_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd)
-{
- int rc = 0;
- struct dentry *de;
- struct presto_cache *cache;
- int minor;
- ino_t ino;
- unsigned int generation;
- struct inode_operations *iops;
- int is_ilookup = 0;
-
- ENTRY;
- cache = presto_get_cache(dir);
- if (cache == NULL) {
- CERROR("InterMezzo BUG: no cache in presto_lookup "
- "(dir ino: %ld)!\n", dir->i_ino);
- EXIT;
- return NULL;
- }
- minor = presto_c2m(cache);
-
- iops = filter_c2cdiops(cache->cache_filter);
- if (!iops || !iops->lookup) {
- CERROR("InterMezzo BUG: filesystem has no lookup\n");
- EXIT;
- return NULL;
- }
-
-
- CDEBUG(D_CACHE, "dentry %p, dir ino: %ld, name: %*s, islento: %d\n",
- dentry, dir->i_ino, dentry->d_name.len, dentry->d_name.name,
- ISLENTO(minor));
-
- if (dentry->d_fsdata)
- CERROR("DD -- BAD dentry %p has data\n", dentry);
-
- dentry->d_fsdata = NULL;
-#if 0
- if (ext2_check_for_iopen(dir, dentry))
- de = NULL;
- else {
-#endif
- if ( izo_dentry_is_ilookup(dentry, &ino, &generation) ) {
- de = cache->cache_filter->o_trops->tr_ilookup
- (dir, dentry, ino, generation);
- is_ilookup = 1;
- } else
- de = iops->lookup(dir, dentry, nd);
-#if 0
- }
-#endif
-
- if ( IS_ERR(de) ) {
- CERROR("dentry lookup error %ld\n", PTR_ERR(de));
- return de;
- }
-
- /* some file systems have no read_inode: set methods here */
- if (dentry->d_inode)
- presto_set_ops(dentry->d_inode, cache->cache_filter);
-
- filter_setup_dentry_ops(cache->cache_filter,
- dentry->d_op, &presto_dentry_ops);
- dentry->d_op = filter_c2udops(cache->cache_filter);
-
- /* In lookup we will tolerate EROFS return codes from presto_set_dd
- * to placate NFS. EROFS indicates that a fileset was not found but
- * we should still be able to continue through a lookup.
- * Anything else is a hard error and must be returned to VFS. */
- if (!is_ilookup)
- rc = presto_set_dd(dentry);
- if (rc && rc != -EROFS) {
- CERROR("presto_set_dd failed (dir %ld, name %*s): %d\n",
- dir->i_ino, dentry->d_name.len, dentry->d_name.name, rc);
- return ERR_PTR(rc);
- }
-
- EXIT;
- return NULL;
-}
-
-static inline int presto_check_set_fsdata (struct dentry *de)
-{
- if (presto_d2d(de) == NULL) {
-#ifdef PRESTO_NO_NFS
- CERROR("dentry without fsdata: %p: %*s\n", de,
- de->d_name.len, de->d_name.name);
- BUG();
-#endif
- return presto_set_dd (de);
- }
-
- return 0;
-}
-
-int presto_setattr(struct dentry *de, struct iattr *iattr)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct lento_vfs_context info = { 0, {0}, 0 };
-
- ENTRY;
-
- error = presto_prep(de, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- if (!iattr->ia_valid)
- CDEBUG(D_INODE, "presto_setattr: iattr is not valid\n");
-
- CDEBUG(D_INODE, "valid %#x, mode %#o, uid %u, gid %u, size %Lu, "
- "atime %lu mtime %lu ctime %lu flags %d\n",
- iattr->ia_valid, iattr->ia_mode, iattr->ia_uid, iattr->ia_gid,
- iattr->ia_size, iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec,
- iattr->ia_ctime.tv_sec, iattr->ia_attr_flags);
-
- if ( presto_get_permit(de->d_inode) < 0 ) {
- EXIT;
- return -EROFS;
- }
-
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_setattr(fset, de, iattr, &info);
- presto_put_permit(de->d_inode);
- return error;
-}
-
-/*
- * Now the meat: the fs operations that require journaling
- *
- *
- * XXX: some of these need modifications for hierarchical filesets
- */
-
-int presto_prep(struct dentry *dentry, struct presto_cache **cache,
- struct presto_file_set **fset)
-{
- int rc;
-
- /* NFS might pass us dentries which have not gone through lookup.
- * Test and set d_fsdata for such dentries
- */
- rc = presto_check_set_fsdata (dentry);
- if (rc) return rc;
-
- *fset = presto_fset(dentry);
- if ( *fset == NULL ) {
- CERROR("No file set for dentry at %p: %*s\n", dentry,
- dentry->d_name.len, dentry->d_name.name);
- return -EROFS;
- }
-
- *cache = (*fset)->fset_cache;
- if ( *cache == NULL ) {
- CERROR("PRESTO: BAD, BAD: cannot find cache\n");
- return -EBADF;
- }
-
- CDEBUG(D_PIOCTL, "---> cache flags %x, fset flags %x\n",
- (*cache)->cache_flags, (*fset)->fset_flags);
- if( presto_is_read_only(*fset) ) {
- CERROR("PRESTO: cannot modify read-only fileset, minor %d.\n",
- presto_c2m(*cache));
- return -EROFS;
- }
- return 0;
-}
-
-static int presto_create(struct inode * dir, struct dentry * dentry, int mode,
- struct nameidata *nd)
-{
- int error;
- struct presto_cache *cache;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
- struct presto_file_set *fset;
-
- ENTRY;
- error = presto_check_set_fsdata(dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
- presto_unlock(dir);
-
- /* Does blocking and non-blocking behavious need to be
- checked for. Without blocking (return 1), the permit
- was acquired without reintegration
- */
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- presto_relock_sem(dir);
- parent = dentry->d_parent;
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_create(fset, parent, dentry, mode, &info);
-
- presto_relock_other(dir);
- presto_put_permit(dir);
- EXIT;
- return error;
-}
-
-static int presto_link(struct dentry *old_dentry, struct inode *dir,
- struct dentry *new_dentry)
-{
- int error;
- struct presto_cache *cache, *new_cache;
- struct presto_file_set *fset, *new_fset;
- struct dentry *parent = new_dentry->d_parent;
- struct lento_vfs_context info;
-
- ENTRY;
- error = presto_prep(old_dentry, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_check_set_fsdata(new_dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(new_dentry->d_parent, &new_cache, &new_fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- if (fset != new_fset) {
- EXIT;
- return -EXDEV;
- }
-
- presto_unlock(dir);
- if ( presto_get_permit(old_dentry->d_inode) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- presto_relock_sem(dir);
- parent = new_dentry->d_parent;
-
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_link(fset, old_dentry, parent,
- new_dentry, &info);
-
-#if 0
- /* XXX for links this is not right */
- if (cache->cache_filter->o_trops->tr_add_ilookup ) {
- struct dentry *d;
- d = cache->cache_filter->o_trops->tr_add_ilookup
- (dir->i_sb->s_root, new_dentry, 1);
- }
-#endif
-
- presto_relock_other(dir);
- presto_put_permit(dir);
- presto_put_permit(old_dentry->d_inode);
- return error;
-}
-
-static int presto_mkdir(struct inode * dir, struct dentry * dentry, int mode)
-{
- int error;
- struct presto_file_set *fset;
- struct presto_cache *cache;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
-
- ENTRY;
-
- error = presto_check_set_fsdata(dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- presto_unlock(dir);
-
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
-
- presto_relock_sem(dir);
- parent = dentry->d_parent;
- error = presto_do_mkdir(fset, parent, dentry, mode, &info);
- presto_relock_other(dir);
- presto_put_permit(dir);
- return error;
-}
-
-
-
-static int presto_symlink(struct inode *dir, struct dentry *dentry,
- const char *name)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
-
- ENTRY;
- error = presto_check_set_fsdata(dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- presto_unlock(dir);
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- presto_relock_sem(dir);
- parent = dentry->d_parent;
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_symlink(fset, parent, dentry, name, &info);
- presto_relock_other(dir);
- presto_put_permit(dir);
- return error;
-}
-
-int presto_unlink(struct inode *dir, struct dentry *dentry)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
-
- ENTRY;
- error = presto_check_set_fsdata(dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- presto_unlock(dir);
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- presto_relock_sem(dir);
- parent = dentry->d_parent;
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
-
- error = presto_do_unlink(fset, parent, dentry, &info);
-
- presto_relock_other(dir);
- presto_put_permit(dir);
- return error;
-}
-
-static int presto_rmdir(struct inode *dir, struct dentry *dentry)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
-
- ENTRY;
- CDEBUG(D_FILE, "prepping presto\n");
- error = presto_check_set_fsdata(dentry);
-
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- CDEBUG(D_FILE, "unlocking\n");
- /* We need to dget() before the dput in double_unlock, to ensure we
- * still have dentry references. double_lock doesn't do dget for us.
- */
- if (d_unhashed(dentry))
- d_rehash(dentry);
- // double_up(&dir->i_zombie, &dentry->d_inode->i_zombie);
- up(&dentry->d_inode->i_sem);
- up(&dir->i_sem);
-
- CDEBUG(D_FILE, "getting permit\n");
- if ( presto_get_permit(parent->d_inode) < 0 ) {
- EXIT;
- down(&dir->i_sem);
- down(&dentry->d_inode->i_sem);
- // double_down(&dir->i_sem, &dentry->d_inode->i_sem);
- // double_down(&dir->i_zombie, &dentry->d_inode->i_zombie);
-
- lock_kernel();
- return -EROFS;
- }
- CDEBUG(D_FILE, "locking\n");
-
- down(&dir->i_sem);
- down(&dentry->d_inode->i_sem);
- parent = dentry->d_parent;
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_rmdir(fset, parent, dentry, &info);
- presto_put_permit(parent->d_inode);
- lock_kernel();
- EXIT;
- return error;
-}
-
-static int presto_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t rdev)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct dentry *parent = dentry->d_parent;
- struct lento_vfs_context info;
-
- if (!old_valid_dev(rdev))
- return -EINVAL;
-
- ENTRY;
- error = presto_check_set_fsdata(dentry);
- if ( error ) {
- EXIT;
- return error;
- }
-
- error = presto_prep(dentry->d_parent, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- presto_unlock(dir);
- if ( presto_get_permit(dir) < 0 ) {
- EXIT;
- presto_fulllock(dir);
- return -EROFS;
- }
-
- presto_relock_sem(dir);
- parent = dentry->d_parent;
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = presto_do_mknod(fset, parent, dentry, mode, rdev, &info);
- presto_relock_other(dir);
- presto_put_permit(dir);
- EXIT;
- return error;
-}
-
-
-
-// XXX this can be optimized: renamtes across filesets only require
-// multiple KML records, but can locally be executed normally.
-int presto_rename(struct inode *old_dir, struct dentry *old_dentry,
- struct inode *new_dir, struct dentry *new_dentry)
-{
- int error;
- struct presto_cache *cache, *new_cache;
- struct presto_file_set *fset, *new_fset;
- struct lento_vfs_context info;
- struct dentry *old_parent = old_dentry->d_parent;
- struct dentry *new_parent = new_dentry->d_parent;
- int triple;
-
- ENTRY;
- error = presto_prep(old_dentry, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
- error = presto_prep(new_parent, &new_cache, &new_fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- if ( fset != new_fset ) {
- EXIT;
- return -EXDEV;
- }
-
- /* We need to do dget before the dput in double_unlock, to ensure we
- * still have dentry references. double_lock doesn't do dget for us.
- */
-
- triple = (S_ISDIR(old_dentry->d_inode->i_mode) && new_dentry->d_inode)?
- 1:0;
-
- unlock_rename(new_dentry->d_parent, old_dentry->d_parent);
-
- if ( presto_get_permit(old_dir) < 0 ) {
- EXIT;
- return -EROFS;
- }
- if ( presto_get_permit(new_dir) < 0 ) {
- EXIT;
- return -EROFS;
- }
-
- lock_rename(new_dentry->d_parent, old_dentry->d_parent);
- memset(&info, 0, sizeof(info));
- if (!ISLENTO(presto_c2m(cache)))
- info.flags = LENTO_FL_KML;
- info.flags |= LENTO_FL_IGNORE_TIME;
- error = do_rename(fset, old_parent, old_dentry, new_parent,
- new_dentry, &info);
-
- presto_put_permit(new_dir);
- presto_put_permit(old_dir);
- return error;
-}
-
-/* basically this allows the ilookup processes access to all files for
- * reading, while not making ilookup totally insecure. This could all
- * go away if we could set the CAP_DAC_READ_SEARCH capability for the client.
- */
-/* If posix acls are available, the underlying cache fs will export the
- * appropriate permission function. Thus we do not worry here about ACLs
- * or EAs. -SHP
- */
-int presto_permission(struct inode *inode, int mask, struct nameidata *nd)
-{
- unsigned short mode = inode->i_mode;
- struct presto_cache *cache;
- int rc;
-
- ENTRY;
- if ( presto_can_ilookup() && !(mask & S_IWOTH)) {
- CDEBUG(D_CACHE, "ilookup on %ld OK\n", inode->i_ino);
- EXIT;
- return 0;
- }
-
- cache = presto_get_cache(inode);
-
- if ( cache ) {
- /* we only override the file/dir permission operations */
- struct inode_operations *fiops = filter_c2cfiops(cache->cache_filter);
- struct inode_operations *diops = filter_c2cdiops(cache->cache_filter);
-
- if ( S_ISREG(mode) && fiops && fiops->permission ) {
- EXIT;
- return fiops->permission(inode, mask, nd);
- }
- if ( S_ISDIR(mode) && diops && diops->permission ) {
- EXIT;
- return diops->permission(inode, mask, nd);
- }
- }
-
- /* The cache filesystem doesn't have its own permission function,
- * so we call the default one.
- */
- rc = vfs_permission(inode, mask);
-
- EXIT;
- return rc;
-}
-
-
-int presto_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- char buf[1024];
- struct izo_ioctl_data *data = NULL;
- struct presto_dentry_data *dd;
- int rc;
-
- ENTRY;
-
- /* Try the filesystem's ioctl first, and return if it succeeded. */
- dd = presto_d2d(file->f_dentry);
- if (dd && dd->dd_fset) {
- int (*cache_ioctl)(struct inode *, struct file *, unsigned int, unsigned long ) = filter_c2cdfops(dd->dd_fset->fset_cache->cache_filter)->ioctl;
- rc = -ENOTTY;
- if (cache_ioctl)
- rc = cache_ioctl(inode, file, cmd, arg);
- if (rc != -ENOTTY) {
- EXIT;
- return rc;
- }
- }
-
- if (current->euid != 0 && current->euid != izo_authorized_uid) {
- EXIT;
- return -EPERM;
- }
-
- memset(buf, 0, sizeof(buf));
-
- if (izo_ioctl_getdata(buf, buf + 1024, (void *)arg)) {
- CERROR("intermezzo ioctl: data error\n");
- return -EINVAL;
- }
- data = (struct izo_ioctl_data *)buf;
-
- switch(cmd) {
- case IZO_IOC_REINTKML: {
- int rc;
- int cperr;
- rc = kml_reint_rec(file, data);
-
- EXIT;
- cperr = copy_to_user((char *)arg, data, sizeof(*data));
- if (cperr) {
- CERROR("WARNING: cperr %d\n", cperr);
- rc = -EFAULT;
- }
- return rc;
- }
-
- case IZO_IOC_GET_RCVD: {
- struct izo_rcvd_rec rec;
- struct presto_file_set *fset;
- int rc;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- rc = izo_rcvd_get(&rec, fset, data->ioc_uuid);
- if (rc < 0) {
- EXIT;
- return rc;
- }
-
- EXIT;
- return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0;
- }
-
- case IZO_IOC_REPSTATUS: {
- __u64 client_kmlsize;
- struct izo_rcvd_rec *lr_client;
- struct izo_rcvd_rec rec;
- struct presto_file_set *fset;
- int minor;
- int rc;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- client_kmlsize = data->ioc_kmlsize;
- lr_client = (struct izo_rcvd_rec *) data->ioc_pbuf1;
-
- rc = izo_repstatus(fset, client_kmlsize,
- lr_client, &rec);
- if (rc < 0) {
- EXIT;
- return rc;
- }
-
- EXIT;
- return copy_to_user((char *)arg, &rec, sizeof(rec))? -EFAULT : 0;
- }
-
- case IZO_IOC_GET_CHANNEL: {
- struct presto_file_set *fset;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
-
- data->ioc_dev = fset->fset_cache->cache_psdev->uc_minor;
- CDEBUG(D_PSDEV, "CHANNEL %d\n", data->ioc_dev);
- EXIT;
- return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
- }
-
- case IZO_IOC_SET_IOCTL_UID:
- izo_authorized_uid = data->ioc_uid;
- EXIT;
- return 0;
-
- case IZO_IOC_SET_PID:
- rc = izo_psdev_setpid(data->ioc_dev);
- EXIT;
- return rc;
-
- case IZO_IOC_SET_CHANNEL:
- rc = izo_psdev_setchannel(file, data->ioc_dev);
- EXIT;
- return rc;
-
- case IZO_IOC_GET_KML_SIZE: {
- struct presto_file_set *fset;
- __u64 kmlsize;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
-
- kmlsize = presto_kml_offset(fset) + fset->fset_kml_logical_off;
-
- EXIT;
- return copy_to_user((char *)arg, &kmlsize, sizeof(kmlsize))?-EFAULT : 0;
- }
-
- case IZO_IOC_PURGE_FILE_DATA: {
- struct presto_file_set *fset;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
-
- rc = izo_purge_file(fset, data->ioc_inlbuf1);
- EXIT;
- return rc;
- }
-
- case IZO_IOC_GET_FILEID: {
- rc = izo_get_fileid(file, data);
- EXIT;
- if (rc)
- return rc;
- return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
- }
-
- case IZO_IOC_SET_FILEID: {
- rc = izo_set_fileid(file, data);
- EXIT;
- if (rc)
- return rc;
- return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
- }
-
- case IZO_IOC_ADJUST_LML: {
- struct lento_vfs_context *info;
- info = (struct lento_vfs_context *)data->ioc_inlbuf1;
- rc = presto_adjust_lml(file, info);
- EXIT;
- return rc;
- }
-
- case IZO_IOC_CONNECT: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_connect(minor, data->ioc_ino,
- data->ioc_generation, data->ioc_uuid,
- data->ioc_flags);
- EXIT;
- return rc;
- }
-
- case IZO_IOC_GO_FETCH_KML: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_go_fetch_kml(minor, fset->fset_name,
- data->ioc_uuid, data->ioc_kmlsize);
- EXIT;
- return rc;
- }
-
- case IZO_IOC_REVOKE_PERMIT:
- if (data->ioc_flags)
- rc = izo_revoke_permit(file->f_dentry, data->ioc_uuid);
- else
- rc = izo_revoke_permit(file->f_dentry, NULL);
- EXIT;
- return rc;
-
- case IZO_IOC_CLEAR_FSET:
- rc = izo_clear_fsetroot(file->f_dentry);
- EXIT;
- return rc;
-
- case IZO_IOC_CLEAR_ALL_FSETS: {
- struct presto_file_set *fset;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
-
- rc = izo_clear_all_fsetroots(fset->fset_cache);
- EXIT;
- return rc;
- }
-
- case IZO_IOC_SET_FSET:
- /*
- * Mark this dentry as being a fileset root.
- */
- rc = presto_set_fsetroot_from_ioc(file->f_dentry,
- data->ioc_inlbuf1,
- data->ioc_flags);
- EXIT;
- return rc;
-
-
- case IZO_IOC_MARK: {
- int res = 0; /* resulting flags - returned to user */
- int error;
-
- CDEBUG(D_DOWNCALL, "mark inode: %ld, and: %x, or: %x, what %d\n",
- file->f_dentry->d_inode->i_ino, data->ioc_and_flag,
- data->ioc_or_flag, data->ioc_mark_what);
-
- switch (data->ioc_mark_what) {
- case MARK_DENTRY:
- error = izo_mark_dentry(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag, &res);
- break;
- case MARK_FSET:
- error = izo_mark_fset(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag, &res);
- break;
- case MARK_CACHE:
- error = izo_mark_cache(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag, &res);
- break;
- case MARK_GETFL: {
- int fflags, cflags;
- data->ioc_and_flag = 0xffffffff;
- data->ioc_or_flag = 0;
- error = izo_mark_dentry(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag, &res);
- if (error)
- break;
- error = izo_mark_fset(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag, &fflags);
- if (error)
- break;
- error = izo_mark_cache(file->f_dentry,
- data->ioc_and_flag,
- data->ioc_or_flag,
- &cflags);
-
- if (error)
- break;
- data->ioc_and_flag = fflags;
- data->ioc_or_flag = cflags;
- break;
- }
- default:
- error = -EINVAL;
- }
-
- if (error) {
- EXIT;
- return error;
- }
- data->ioc_mark_what = res;
- CDEBUG(D_DOWNCALL, "mark inode: %ld, and: %x, or: %x, what %x\n",
- file->f_dentry->d_inode->i_ino, data->ioc_and_flag,
- data->ioc_or_flag, data->ioc_mark_what);
-
- EXIT;
- return copy_to_user((char *)arg, data, sizeof(*data))? -EFAULT : 0;
- }
-#if 0
- case IZO_IOC_CLIENT_MAKE_BRANCH: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_client_make_branch(minor, fset->fset_name,
- data->ioc_inlbuf1,
- data->ioc_inlbuf2);
- EXIT;
- return rc;
- }
-#endif
- case IZO_IOC_SERVER_MAKE_BRANCH: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- izo_upc_server_make_branch(minor, data->ioc_inlbuf1);
- EXIT;
- return 0;
- }
- case IZO_IOC_SET_KMLSIZE: {
- struct presto_file_set *fset;
- int minor;
- struct izo_rcvd_rec rec;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_set_kmlsize(minor, fset->fset_name, data->ioc_uuid,
- data->ioc_kmlsize);
-
- if (rc != 0) {
- EXIT;
- return rc;
- }
-
- rc = izo_rcvd_get(&rec, fset, data->ioc_uuid);
- if (rc == -EINVAL) {
- /* We don't know anything about this uuid yet; no
- * worries. */
- memset(&rec, 0, sizeof(rec));
- } else if (rc <= 0) {
- CERROR("InterMezzo: error reading last_rcvd: %d\n", rc);
- EXIT;
- return rc;
- }
- rec.lr_remote_offset = data->ioc_kmlsize;
- rc = izo_rcvd_write(fset, &rec);
- if (rc <= 0) {
- CERROR("InterMezzo: error writing last_rcvd: %d\n", rc);
- EXIT;
- return rc;
- }
- EXIT;
- return rc;
- }
- case IZO_IOC_BRANCH_UNDO: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_branch_undo(minor, fset->fset_name,
- data->ioc_inlbuf1);
- EXIT;
- return rc;
- }
- case IZO_IOC_BRANCH_REDO: {
- struct presto_file_set *fset;
- int minor;
-
- fset = presto_fset(file->f_dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
- minor = presto_f2m(fset);
-
- rc = izo_upc_branch_redo(minor, fset->fset_name,
- data->ioc_inlbuf1);
- EXIT;
- return rc;
- }
-
- default:
- EXIT;
- return -ENOTTY;
-
- }
- EXIT;
- return 0;
-}
-
-struct file_operations presto_dir_fops = {
- .ioctl = presto_ioctl
-};
-
-struct inode_operations presto_dir_iops = {
- .create = presto_create,
- .lookup = presto_lookup,
- .link = presto_link,
- .unlink = presto_unlink,
- .symlink = presto_symlink,
- .mkdir = presto_mkdir,
- .rmdir = presto_rmdir,
- .mknod = presto_mknod,
- .rename = presto_rename,
- .permission = presto_permission,
- .setattr = presto_setattr,
-#ifdef CONFIG_FS_EXT_ATTR
- .set_ext_attr = presto_set_ext_attr,
-#endif
-};
-
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Tacit Networks, Inc.
- * Author: Shirish H. Phatak <shirish@tacitnetworks.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Extended attribute handling for presto.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/segment.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_FS_EXT_ATTR
-#include <linux/ext_attr.h>
-
-extern inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
- unsigned long value);
-
-
-/* VFS interface */
-/* XXX! Fixme test for user defined attributes */
-int presto_set_ext_attr(struct inode *inode,
- const char *name, void *buffer,
- size_t buffer_len, int flags)
-{
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct lento_vfs_context info;
- struct dentry *dentry;
- int minor = presto_i2m(inode);
- char *buf = NULL;
-
- ENTRY;
- if (minor < 0) {
- EXIT;
- return -1;
- }
-
- if ( ISLENTO(minor) ) {
- EXIT;
- return -EINVAL;
- }
-
- /* BAD...vfs should really pass down the dentry to use, especially
- * since every other operation in iops does. But for now
- * we do a reverse mapping from inode to the first dentry
- */
- if (list_empty(&inode->i_dentry)) {
- CERROR("No alias for inode %d\n", (int) inode->i_ino);
- EXIT;
- return -EINVAL;
- }
-
- dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
- error = presto_prep(dentry, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- if ((buffer != NULL) && (buffer_len != 0)) {
- /* If buffer is a user space pointer copy it to kernel space
- * and reset the flag. We do this since the journal functions need
- * access to the contents of the buffer, and the file system
- * does not care. When we actually invoke the function, we remove
- * the EXT_ATTR_FLAG_USER flag.
- *
- * XXX:Check if the "fs does not care" assertion is always true -SHP
- * (works for ext3)
- */
- if (flags & EXT_ATTR_FLAG_USER) {
- PRESTO_ALLOC(buf, buffer_len);
- if (!buf) {
- CERROR("InterMezzo: out of memory!!!\n");
- return -ENOMEM;
- }
- error = copy_from_user(buf, buffer, buffer_len);
- if (error)
- return -EFAULT;
- } else
- buf = buffer;
- } else
- buf = buffer;
-
- if ( presto_get_permit(inode) < 0 ) {
- EXIT;
- if (buffer_len && (flags & EXT_ATTR_FLAG_USER))
- PRESTO_FREE(buf, buffer_len);
- return -EROFS;
- }
-
- /* Simulate presto_setup_info */
- memset(&info, 0, sizeof(info));
- /* For now redundant..but we keep it around just in case */
- info.flags = LENTO_FL_IGNORE_TIME;
- if (!ISLENTO(cache->cache_psdev->uc_minor))
- info.flags |= LENTO_FL_KML;
-
- /* We pass in the kernel space pointer and reset the
- * EXT_ATTR_FLAG_USER flag.
- * See comments above.
- */
- /* Note that mode is already set by VFS so we send in a NULL */
- error = presto_do_set_ext_attr(fset, dentry, name, buf,
- buffer_len, flags & ~EXT_ATTR_FLAG_USER,
- NULL, &info);
- presto_put_permit(inode);
-
- if (buffer_len && (flags & EXT_ATTR_FLAG_USER))
- PRESTO_FREE(buf, buffer_len);
- EXIT;
- return error;
-}
-
-/* Lento Interface */
-/* XXX: ignore flags? We should be forcing these operations through? -SHP*/
-int lento_set_ext_attr(const char *path, const char *name,
- void *buffer, size_t buffer_len, int flags, mode_t mode,
- struct lento_vfs_context *info)
-{
- int error;
- char * pathname;
- struct nameidata nd;
- struct dentry *dentry;
- struct presto_file_set *fset;
-
- ENTRY;
- lock_kernel();
-
- pathname=getname(path);
- error = PTR_ERR(pathname);
- if (IS_ERR(pathname)) {
- EXIT;
- goto exit;
- }
-
- /* Note that ext_attrs apply to both files and directories..*/
- error=presto_walk(pathname,&nd);
- if (error)
- goto exit;
- dentry = nd.dentry;
-
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit_dentry;
- }
-
- if (buffer==NULL) buffer_len=0;
-
- error = presto_do_set_ext_attr(fset, dentry, name, buffer,
- buffer_len, flags, &mode, info);
-exit_dentry:
- path_release(&nd);
-exit_path:
- putname(pathname);
-exit:
- unlock_kernel();
- return error;
-}
-
-#endif /*CONFIG_FS_EXT_ATTR*/
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory.
- * Copyright (C) 2000, 2001 Tacit Networks, Inc.
- * Copyright (C) 2000 Peter J. Braam
- * Copyright (C) 2001 Mountain View Data, Inc.
- * Copyright (C) 2001 Cluster File Systems, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * This file manages file I/O
- *
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include <linux/fsfilter.h>
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-/*
- * these are initialized in super.c
- */
-extern int presto_permission(struct inode *inode, int mask, struct nameidata *nd);
-
-
-static int presto_open_upcall(int minor, struct dentry *de)
-{
- int rc = 0;
- char *path, *buffer;
- struct presto_file_set *fset;
- int pathlen;
- struct lento_vfs_context info;
- struct presto_dentry_data *dd = presto_d2d(de);
-
- PRESTO_ALLOC(buffer, PAGE_SIZE);
- if ( !buffer ) {
- CERROR("PRESTO: out of memory!\n");
- return -ENOMEM;
- }
- fset = presto_fset(de);
- path = presto_path(de, fset->fset_dentry, buffer, PAGE_SIZE);
- pathlen = MYPATHLEN(buffer, path);
-
- CDEBUG(D_FILE, "de %p, dd %p\n", de, dd);
- if (dd->remote_ino == 0) {
- rc = presto_get_fileid(minor, fset, de);
- }
- memset (&info, 0, sizeof(info));
- if (dd->remote_ino > 0) {
- info.remote_ino = dd->remote_ino;
- info.remote_generation = dd->remote_generation;
- } else
- CERROR("get_fileid failed %d, ino: %Lx, fetching by name\n", rc,
- (unsigned long long) dd->remote_ino);
-
- rc = izo_upc_open(minor, pathlen, path, fset->fset_name, &info);
- PRESTO_FREE(buffer, PAGE_SIZE);
- return rc;
-}
-
-static inline int open_check_dod(struct file *file,
- struct presto_file_set *fset)
-{
- int gen, is_iopen = 0, minor;
- struct presto_cache *cache = fset->fset_cache;
- ino_t inum;
-
- minor = presto_c2m(cache);
-
- if ( ISLENTO(minor) ) {
- CDEBUG(D_CACHE, "is lento, not doing DOD.\n");
- return 0;
- }
-
- /* Files are only ever opened by inode during backfetches, when by
- * definition we have the authoritative copy of the data. No DOD. */
- is_iopen = izo_dentry_is_ilookup(file->f_dentry, &inum, &gen);
-
- if (is_iopen) {
- CDEBUG(D_CACHE, "doing iopen, not doing DOD.\n");
- return 0;
- }
-
- if (!(fset->fset_flags & FSET_DATA_ON_DEMAND)) {
- CDEBUG(D_CACHE, "fileset not on demand.\n");
- return 0;
- }
-
- if (file->f_flags & O_TRUNC) {
- CDEBUG(D_CACHE, "fileset dod: O_TRUNC.\n");
- return 0;
- }
-
- if (presto_chk(file->f_dentry, PRESTO_DONT_JOURNAL)) {
- CDEBUG(D_CACHE, "file under .intermezzo, not doing DOD\n");
- return 0;
- }
-
- if (presto_chk(file->f_dentry, PRESTO_DATA)) {
- CDEBUG(D_CACHE, "PRESTO_DATA is set, not doing DOD.\n");
- return 0;
- }
-
- if (cache->cache_filter->o_trops->tr_all_data(file->f_dentry->d_inode)) {
- CDEBUG(D_CACHE, "file not sparse, not doing DOD.\n");
- return 0;
- }
-
- return 1;
-}
-
-static int presto_file_open(struct inode *inode, struct file *file)
-{
- int rc = 0;
- struct file_operations *fops;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct presto_file_data *fdata;
- int writable = (file->f_flags & (O_RDWR | O_WRONLY));
- int minor, i;
-
- ENTRY;
-
- if (presto_prep(file->f_dentry, &cache, &fset) < 0) {
- EXIT;
- return -EBADF;
- }
-
- minor = presto_c2m(cache);
-
- CDEBUG(D_CACHE, "DATA_OK: %d, ino: %ld, islento: %d\n",
- presto_chk(file->f_dentry, PRESTO_DATA), inode->i_ino,
- ISLENTO(minor));
-
- if ( !ISLENTO(minor) && (file->f_flags & O_RDWR ||
- file->f_flags & O_WRONLY)) {
- CDEBUG(D_CACHE, "calling presto_get_permit\n");
- if ( presto_get_permit(inode) < 0 ) {
- EXIT;
- return -EROFS;
- }
- presto_put_permit(inode);
- }
-
- if (open_check_dod(file, fset)) {
- CDEBUG(D_CACHE, "presto_open_upcall\n");
- CDEBUG(D_CACHE, "dentry: %p setting DATA, ATTR\n", file->f_dentry);
- presto_set(file->f_dentry, PRESTO_ATTR | PRESTO_DATA);
- rc = presto_open_upcall(minor, file->f_dentry);
- if (rc) {
- EXIT;
- CERROR("%s: returning error %d\n", __FUNCTION__, rc);
- return rc;
- }
-
- }
-
- /* file was truncated upon open: do not refetch */
- if (file->f_flags & O_TRUNC) {
- CDEBUG(D_CACHE, "setting DATA, ATTR\n");
- presto_set(file->f_dentry, PRESTO_ATTR | PRESTO_DATA);
- }
-
- fops = filter_c2cffops(cache->cache_filter);
- if ( fops->open ) {
- CDEBUG(D_CACHE, "calling fs open\n");
- rc = fops->open(inode, file);
-
- if (rc) {
- EXIT;
- return rc;
- }
- }
-
- if (writable) {
- PRESTO_ALLOC(fdata, sizeof(*fdata));
- if (!fdata) {
- EXIT;
- return -ENOMEM;
- }
- /* LOCK: XXX check that the kernel lock protects this alloc */
- fdata->fd_do_lml = 0;
- fdata->fd_bytes_written = 0;
- fdata->fd_fsuid = current->fsuid;
- fdata->fd_fsgid = current->fsgid;
- fdata->fd_mode = file->f_dentry->d_inode->i_mode;
- fdata->fd_uid = file->f_dentry->d_inode->i_uid;
- fdata->fd_gid = file->f_dentry->d_inode->i_gid;
- fdata->fd_ngroups = current->group_info->ngroups;
- for (i=0 ; i < current->group_info->ngroups ; i++)
- fdata->fd_groups[i] = GROUP_AT(current->group_info,i);
- if (!ISLENTO(minor))
- fdata->fd_info.flags = LENTO_FL_KML;
- else {
- /* this is for the case of DOD,
- reint_close will adjust flags if needed */
- fdata->fd_info.flags = 0;
- }
-
- presto_getversion(&fdata->fd_version, inode);
- file->private_data = fdata;
- } else {
- file->private_data = NULL;
- }
-
- EXIT;
- return 0;
-}
-
-int presto_adjust_lml(struct file *file, struct lento_vfs_context *info)
-{
- struct presto_file_data *fdata =
- (struct presto_file_data *) file->private_data;
-
- if (!fdata) {
- EXIT;
- return -EINVAL;
- }
-
- memcpy(&fdata->fd_info, info, sizeof(*info));
- EXIT;
- return 0;
-}
-
-
-static int presto_file_release(struct inode *inode, struct file *file)
-{
- int rc;
- struct file_operations *fops;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct presto_file_data *fdata =
- (struct presto_file_data *)file->private_data;
- ENTRY;
-
- rc = presto_prep(file->f_dentry, &cache, &fset);
- if ( rc ) {
- EXIT;
- return rc;
- }
-
- fops = filter_c2cffops(cache->cache_filter);
- if (fops && fops->release)
- rc = fops->release(inode, file);
-
- CDEBUG(D_CACHE, "islento = %d (minor %d), rc %d, data %p\n",
- ISLENTO(cache->cache_psdev->uc_minor),
- cache->cache_psdev->uc_minor, rc, fdata);
-
- /* this file was modified: ignore close errors, write KML */
- if (fdata && fdata->fd_do_lml) {
- /* XXX: remove when lento gets file granularity cd */
- if ( presto_get_permit(inode) < 0 ) {
- EXIT;
- return -EROFS;
- }
-
- fdata->fd_info.updated_time = file->f_dentry->d_inode->i_mtime;
- rc = presto_do_close(fset, file);
- presto_put_permit(inode);
- }
-
- if (!rc && fdata) {
- PRESTO_FREE(fdata, sizeof(*fdata));
- file->private_data = NULL;
- }
-
- EXIT;
- return rc;
-}
-
-static void presto_apply_write_policy(struct file *file,
- struct presto_file_set *fset, loff_t res)
-{
- struct presto_file_data *fdata =
- (struct presto_file_data *)file->private_data;
- struct presto_cache *cache = fset->fset_cache;
- struct presto_version new_file_ver;
- int error;
- struct rec_info rec;
-
- /* Here we do a journal close after a fixed or a specified
- amount of KBytes, currently a global parameter set with
- sysctl. If files are open for a long time, this gives added
- protection. (XXX todo: per cache, add ioctl, handle
- journaling in a thread, add more options etc.)
- */
-
- if ((fset->fset_flags & FSET_JCLOSE_ON_WRITE) &&
- (!ISLENTO(cache->cache_psdev->uc_minor))) {
- fdata->fd_bytes_written += res;
-
- if (fdata->fd_bytes_written >= fset->fset_file_maxio) {
- presto_getversion(&new_file_ver,
- file->f_dentry->d_inode);
- /* This is really heavy weight and should be fixed
- ASAP. At most we should be recording the number
- of bytes written and not locking the kernel,
- wait for permits, etc, on the write path. SHP
- */
- lock_kernel();
- if ( presto_get_permit(file->f_dentry->d_inode) < 0 ) {
- EXIT;
- /* we must be disconnected, not to worry */
- unlock_kernel();
- return;
- }
- error = presto_journal_close(&rec, fset, fdata,
- file->f_dentry,
- &fdata->fd_version,
- &new_file_ver);
- presto_put_permit(file->f_dentry->d_inode);
- unlock_kernel();
- if ( error ) {
- CERROR("presto_close: cannot journal close\n");
- /* XXX these errors are really bad */
- /* panic(); */
- return;
- }
- fdata->fd_bytes_written = 0;
- }
- }
-}
-
-static ssize_t presto_file_write(struct file *file, const char *buf,
- size_t size, loff_t *off)
-{
- struct rec_info rec;
- int error;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct file_operations *fops;
- ssize_t res;
- int do_lml_here;
- void *handle = NULL;
- unsigned long blocks;
- struct presto_file_data *fdata;
- loff_t res_size;
-
- error = presto_prep(file->f_dentry, &cache, &fset);
- if ( error ) {
- EXIT;
- return error;
- }
-
- blocks = (size >> file->f_dentry->d_inode->i_sb->s_blocksize_bits) + 1;
- /* XXX 3 is for ext2 indirect blocks ... */
- res_size = 2 * PRESTO_REQHIGH + ((blocks+3)
- << file->f_dentry->d_inode->i_sb->s_blocksize_bits);
-
- error = presto_reserve_space(fset->fset_cache, res_size);
- CDEBUG(D_INODE, "Reserved %Ld for %Zd\n", res_size, size);
- if ( error ) {
- EXIT;
- return -ENOSPC;
- }
-
- CDEBUG(D_INODE, "islento %d, minor: %d\n",
- ISLENTO(cache->cache_psdev->uc_minor),
- cache->cache_psdev->uc_minor);
-
- /*
- * XXX this lock should become a per inode lock when
- * Vinny's changes are in; we could just use i_sem.
- */
- read_lock(&fset->fset_lml.fd_lock);
- fdata = (struct presto_file_data *)file->private_data;
- do_lml_here = size && (fdata->fd_do_lml == 0) &&
- !presto_chk(file->f_dentry, PRESTO_DONT_JOURNAL);
-
- if (do_lml_here)
- fdata->fd_do_lml = 1;
- read_unlock(&fset->fset_lml.fd_lock);
-
- /* XXX
- There might be a bug here. We need to make
- absolutely sure that the ext3_file_write commits
- after our transaction that writes the LML record.
- Nesting the file write helps if new blocks are allocated.
- */
- res = 0;
- if (do_lml_here) {
- struct presto_version file_version;
- /* handle different space reqs from file system below! */
- handle = presto_trans_start(fset, file->f_dentry->d_inode,
- KML_OPCODE_WRITE);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, res_size);
- CERROR("presto_write: no space for transaction\n");
- return -ENOSPC;
- }
-
- presto_getversion(&file_version, file->f_dentry->d_inode);
- res = presto_write_lml_close(&rec, fset, file,
- fdata->fd_info.remote_ino,
- fdata->fd_info.remote_generation,
- &fdata->fd_info.remote_version,
- &file_version);
- fdata->fd_lml_offset = rec.offset;
- if ( res ) {
- CERROR("intermezzo: PANIC failed to write LML\n");
- *(int *)0 = 1;
- EXIT;
- goto exit_write;
- }
- presto_trans_commit(fset, handle);
- }
-
- fops = filter_c2cffops(cache->cache_filter);
- res = fops->write(file, buf, size, off);
- if ( res != size ) {
- CDEBUG(D_FILE, "file write returns short write: size %Zd, res %Zd\n", size, res);
- }
-
- if ( (res > 0) && fdata )
- presto_apply_write_policy(file, fset, res);
-
- exit_write:
- presto_release_space(fset->fset_cache, res_size);
- return res;
-}
-
-struct file_operations presto_file_fops = {
- .write = presto_file_write,
- .open = presto_file_open,
- .release = presto_file_release,
- .ioctl = presto_ioctl
-};
-
-struct inode_operations presto_file_iops = {
- .permission = presto_permission,
- .setattr = presto_setattr,
-#ifdef CONFIG_FS_EXT_ATTR
- .set_ext_attr = presto_set_ext_attr,
-#endif
-};
-
-/* FIXME: I bet we want to add a lock here and in presto_file_open. */
-int izo_purge_file(struct presto_file_set *fset, char *file)
-{
-#if 0
- void *handle = NULL;
- char *path = NULL;
- struct nameidata nd;
- struct dentry *dentry;
- int rc = 0, len;
- loff_t oldsize;
-
- /* FIXME: not mtpt it's gone */
- len = strlen(fset->fset_cache->cache_mtpt) + strlen(file) + 1;
- PRESTO_ALLOC(path, len + 1);
- if (path == NULL)
- return -1;
-
- sprintf(path, "%s/%s", fset->fset_cache->cache_mtpt, file);
- rc = izo_lookup_file(fset, path, &nd);
- if (rc)
- goto error;
- dentry = nd.dentry;
-
- /* FIXME: take a lock here */
-
- if (dentry->d_inode->i_atime.tv_sec > get_seconds() - 5) {
- /* We lost the race; this file was accessed while we were doing
- * ioctls and lookups and whatnot. */
- rc = -EBUSY;
- goto error_unlock;
- }
-
- /* FIXME: Check if this file is open. */
-
- handle = presto_trans_start(fset, dentry->d_inode, KML_OPCODE_TRUNC);
- if (IS_ERR(handle)) {
- rc = -ENOMEM;
- goto error_unlock;
- }
-
- /* FIXME: Write LML record */
-
- oldsize = dentry->d_inode->i_size;
- rc = izo_do_truncate(fset, dentry, 0, oldsize);
- if (rc != 0)
- goto error_clear;
- rc = izo_do_truncate(fset, dentry, oldsize, 0);
- if (rc != 0)
- goto error_clear;
-
- error_clear:
- /* FIXME: clear LML record */
-
- error_unlock:
- /* FIXME: release the lock here */
-
- error:
- if (handle != NULL && !IS_ERR(handle))
- presto_trans_commit(fset, handle);
- if (path != NULL)
- PRESTO_FREE(path, len + 1);
- return rc;
-#else
- return 0;
-#endif
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Managing filesets
- *
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static inline struct presto_file_set *presto_dentry2fset(struct dentry *dentry)
-{
- if (presto_d2d(dentry) == NULL) {
- EXIT;
- return NULL;
- }
- return presto_d2d(dentry)->dd_fset;
-}
-
-/* find the fileset dentry for this dentry */
-struct presto_file_set *presto_fset(struct dentry *de)
-{
- struct dentry *fsde;
- ENTRY;
- if ( !de->d_inode ) {
- /* FIXME: is this ok to be NULL? */
- CDEBUG(D_INODE,"presto_fset: warning %*s has NULL inode.\n",
- de->d_name.len, de->d_name.name);
- }
- for (fsde = de;; fsde = fsde->d_parent) {
- if ( presto_dentry2fset(fsde) ) {
- EXIT;
- return presto_dentry2fset(fsde);
- }
- if (fsde->d_parent == fsde)
- break;
- }
- EXIT;
- return NULL;
-}
-
-int presto_get_lastrecno(char *path, off_t *recno)
-{
- struct nameidata nd;
- struct presto_file_set *fset;
- struct dentry *dentry;
- int error;
- ENTRY;
-
- error = presto_walk(path, &nd);
- if (error) {
- EXIT;
- return error;
- }
-
- dentry = nd.dentry;
-
- error = -ENXIO;
- if ( !presto_ispresto(dentry->d_inode) ) {
- EXIT;
- goto kml_out;
- }
-
- error = -EINVAL;
- if ( ! presto_dentry2fset(dentry)) {
- EXIT;
- goto kml_out;
- }
-
- fset = presto_dentry2fset(dentry);
- if (!fset) {
- EXIT;
- goto kml_out;
- }
- error = 0;
- *recno = fset->fset_kml.fd_recno;
-
- kml_out:
- path_release(&nd);
- return error;
-}
-
-static char * _izo_make_path(char *fsetname, char *name)
-{
- char *path = NULL;
- int len;
-
- len = strlen("/.intermezzo/") + strlen(fsetname)
- + 1 + strlen(name) + 1;
-
- PRESTO_ALLOC(path, len);
- if (path == NULL)
- return NULL;
-
- sprintf(path, "/.intermezzo/%s/%s", fsetname, name);
-
- return path;
-}
-
-char * izo_make_path(struct presto_file_set *fset, char *name)
-{
- return _izo_make_path(fset->fset_name, name);
-}
-
-static struct file *_izo_fset_open(char *fsetname, char *name, int flags, int mode)
-{
- char *path;
- struct file *f;
- int error;
- ENTRY;
-
- path = _izo_make_path(fsetname, name);
- if (path == NULL) {
- EXIT;
- return ERR_PTR(-ENOMEM);
- }
-
- CDEBUG(D_INODE, "opening file %s\n", path);
- f = filp_open(path, flags, mode);
- error = PTR_ERR(f);
- if (IS_ERR(f)) {
- CDEBUG(D_INODE, "Error %d\n", error);
- }
-
- PRESTO_FREE(path, strlen(path));
-
- EXIT;
- return f;
-
-}
-
-struct file *izo_fset_open(struct presto_file_set *fset, char *name, int flags, int mode)
-{
- return _izo_fset_open(fset->fset_name, name, flags, mode);
-}
-
-
-
-/*
- * note: this routine "pins" a dentry for a fileset root
- */
-int presto_set_fsetroot(struct dentry *ioctl_dentry, char *fsetname,
- unsigned int flags)
-{
- struct presto_file_set *fset = NULL;
- struct presto_cache *cache;
- int error;
- struct file *fset_root;
- struct dentry *dentry;
-
- ENTRY;
-
- fset_root = _izo_fset_open(fsetname, "ROOT", O_RDONLY, 000);
- if (IS_ERR(fset_root)) {
- CERROR("Can't open %s/ROOT\n", fsetname);
- EXIT;
- error = PTR_ERR(fset_root);
- goto out;
- }
- dentry = dget(fset_root->f_dentry);
- filp_close(fset_root, NULL);
-
- dentry->d_inode->i_op = ioctl_dentry->d_inode->i_op;
- dentry->d_inode->i_fop = ioctl_dentry->d_inode->i_fop;
- dentry->d_op = ioctl_dentry->d_op;
- fset = presto_dentry2fset(dentry);
- if (fset && (fset->fset_dentry == dentry) ) {
- CERROR("Fsetroot already set (inode %ld)\n",
- dentry->d_inode->i_ino);
- /* XXX: ignore because clear_fsetroot is broken */
-#if 0
- dput(dentry);
- EXIT;
- error = -EEXIST;
- goto out;
-#endif
- }
-
- cache = presto_get_cache(dentry->d_inode);
- if (!cache) {
- CERROR("No cache found for inode %ld\n",
- dentry->d_inode->i_ino);
- EXIT;
- error = -ENODEV;
- goto out_free;
- }
-
- PRESTO_ALLOC(fset, sizeof(*fset));
- if ( !fset ) {
- CERROR("No memory allocating fset for %s\n", fsetname);
- EXIT;
- error = -ENOMEM;
- goto out_free;
- }
- CDEBUG(D_INODE, "fset at %p\n", fset);
-
- CDEBUG(D_INODE, "InterMezzo: fsetroot: inode %ld, fileset name %s\n",
- dentry->d_inode->i_ino, fsetname);
-
- fset->fset_mnt = mntget(current->fs->pwdmnt);
- fset->fset_cache = cache;
- fset->fset_dentry = dentry;
- fset->fset_name = strdup(fsetname);
- fset->fset_chunkbits = CHUNK_BITS;
- fset->fset_flags = flags;
- fset->fset_file_maxio = FSET_DEFAULT_MAX_FILEIO;
- fset->fset_permit_lock = SPIN_LOCK_UNLOCKED;
- PRESTO_ALLOC(fset->fset_reint_buf, 64 * 1024);
- if (fset->fset_reint_buf == NULL) {
- EXIT;
- error = -ENOMEM;
- goto out_free;
- }
- init_waitqueue_head(&fset->fset_permit_queue);
-
- if (presto_d2d(dentry) == NULL) {
- dentry->d_fsdata = izo_alloc_ddata();
- }
- if (presto_d2d(dentry) == NULL) {
- CERROR("InterMezzo: %s: no memory\n", __FUNCTION__);
- EXIT;
- error = -ENOMEM;
- goto out_free;
- }
- presto_d2d(dentry)->dd_fset = fset;
- list_add(&fset->fset_list, &cache->cache_fset_list);
-
- error = izo_init_kml_file(fset, &fset->fset_kml);
- if ( error ) {
- EXIT;
- CDEBUG(D_JOURNAL, "Error init_kml %d\n", error);
- goto out_list_del;
- }
-
- error = izo_init_lml_file(fset, &fset->fset_lml);
- if ( error ) {
- int rc;
- EXIT;
- rc = izo_log_close(&fset->fset_kml);
- CDEBUG(D_JOURNAL, "Error init_lml %d, cleanup %d\n", error, rc);
- goto out_list_del;
- }
-
- /* init_last_rcvd_file could trigger a presto_file_write(), which
- * requires that the lml structure be initialized. -phil */
- error = izo_init_last_rcvd_file(fset, &fset->fset_rcvd);
- if ( error ) {
- int rc;
- EXIT;
- rc = izo_log_close(&fset->fset_kml);
- rc = izo_log_close(&fset->fset_lml);
- CDEBUG(D_JOURNAL, "Error init_lastrcvd %d, cleanup %d\n", error, rc);
- goto out_list_del;
- }
-
- CDEBUG(D_PIOCTL, "-------> fset at %p, dentry at %p, mtpt %p,"
- "fset %s, cache %p, presto_d2d(dentry)->dd_fset %p\n",
- fset, dentry, fset->fset_dentry, fset->fset_name, cache,
- presto_d2d(dentry)->dd_fset);
-
- EXIT;
- return 0;
-
- out_list_del:
- list_del(&fset->fset_list);
- presto_d2d(dentry)->dd_fset = NULL;
- out_free:
- if (fset) {
- mntput(fset->fset_mnt);
- if (fset->fset_reint_buf != NULL)
- PRESTO_FREE(fset->fset_reint_buf, 64 * 1024);
- PRESTO_FREE(fset, sizeof(*fset));
- }
- dput(dentry);
- out:
- return error;
-}
-
-static int izo_cleanup_fset(struct presto_file_set *fset)
-{
- int error;
- struct presto_cache *cache;
-
- ENTRY;
-
- CERROR("Cleaning up fset %s\n", fset->fset_name);
-
- error = izo_log_close(&fset->fset_kml);
- if (error)
- CERROR("InterMezzo: Closing kml for fset %s: %d\n",
- fset->fset_name, error);
- error = izo_log_close(&fset->fset_lml);
- if (error)
- CERROR("InterMezzo: Closing lml for fset %s: %d\n",
- fset->fset_name, error);
- error = izo_log_close(&fset->fset_rcvd);
- if (error)
- CERROR("InterMezzo: Closing last_rcvd for fset %s: %d\n",
- fset->fset_name, error);
-
- cache = fset->fset_cache;
-
- list_del(&fset->fset_list);
-
- presto_d2d(fset->fset_dentry)->dd_fset = NULL;
- dput(fset->fset_dentry);
- mntput(fset->fset_mnt);
-
- PRESTO_FREE(fset->fset_name, strlen(fset->fset_name) + 1);
- PRESTO_FREE(fset->fset_reint_buf, 64 * 1024);
- PRESTO_FREE(fset, sizeof(*fset));
- EXIT;
- return error;
-}
-
-int izo_clear_fsetroot(struct dentry *dentry)
-{
- struct presto_file_set *fset;
-
- ENTRY;
-
- fset = presto_dentry2fset(dentry);
- if (!fset) {
- EXIT;
- return -EINVAL;
- }
-
- izo_cleanup_fset(fset);
- EXIT;
- return 0;
-}
-
-int izo_clear_all_fsetroots(struct presto_cache *cache)
-{
- struct presto_file_set *fset;
- struct list_head *tmp,*tmpnext;
- int error;
-
- error = 0;
- tmp = &cache->cache_fset_list;
- tmpnext = tmp->next;
- while ( tmpnext != &cache->cache_fset_list) {
- tmp = tmpnext;
- tmpnext = tmp->next;
- fset = list_entry(tmp, struct presto_file_set, fset_list);
-
- error = izo_cleanup_fset(fset);
- if (error)
- break;
- }
- return error;
-}
-
-static struct vfsmount *izo_alloc_vfsmnt(void)
-{
- struct vfsmount *mnt;
- PRESTO_ALLOC(mnt, sizeof(*mnt));
- if (mnt) {
- memset(mnt, 0, sizeof(struct vfsmount));
- atomic_set(&mnt->mnt_count,1);
- INIT_LIST_HEAD(&mnt->mnt_hash);
- INIT_LIST_HEAD(&mnt->mnt_child);
- INIT_LIST_HEAD(&mnt->mnt_mounts);
- INIT_LIST_HEAD(&mnt->mnt_list);
- }
- return mnt;
-}
-
-
-static void izo_setup_ctxt(struct dentry *root, struct vfsmount *mnt,
- struct run_ctxt *save)
-{
- struct run_ctxt new;
-
- mnt->mnt_root = root;
- mnt->mnt_sb = root->d_inode->i_sb;
- unlock_super(mnt->mnt_sb);
-
- new.rootmnt = mnt;
- new.root = root;
- new.pwdmnt = mnt;
- new.pwd = root;
- new.fsuid = 0;
- new.fsgid = 0;
- new.fs = get_fs();
- /* XXX where can we get the groups from? */
- new.group_info = groups_alloc(0);
-
- push_ctxt(save, &new);
-}
-
-static void izo_cleanup_ctxt(struct vfsmount *mnt, struct run_ctxt *save)
-{
- lock_super(mnt->mnt_sb);
- pop_ctxt(save);
-}
-
-static int izo_simple_mkdir(struct dentry *dir, char *name, int mode)
-{
- struct dentry *dchild;
- int err;
- ENTRY;
-
- dchild = lookup_one_len(name, dir, strlen(name));
- if (IS_ERR(dchild)) {
- EXIT;
- return PTR_ERR(dchild);
- }
-
- if (dchild->d_inode) {
- dput(dchild);
- EXIT;
- return -EEXIST;
- }
-
- err = vfs_mkdir(dir->d_inode, dchild, mode);
- dput(dchild);
-
- EXIT;
- return err;
-}
-
-static int izo_simple_symlink(struct dentry *dir, char *name, char *tgt)
-{
- struct dentry *dchild;
- int err;
- ENTRY;
-
- dchild = lookup_one_len(name, dir, strlen(name));
- if (IS_ERR(dchild)) {
- EXIT;
- return PTR_ERR(dchild);
- }
-
- if (dchild->d_inode) {
- dput(dchild);
- EXIT;
- return -EEXIST;
- }
-
- err = vfs_symlink(dir->d_inode, dchild, tgt);
- dput(dchild);
-
- EXIT;
- return err;
-}
-
-/*
- * run set_fsetroot in chroot environment
- */
-int presto_set_fsetroot_from_ioc(struct dentry *root, char *fsetname,
- unsigned int flags)
-{
- int rc;
- struct presto_cache *cache;
- struct vfsmount *mnt;
- struct run_ctxt save;
-
- if (root != root->d_inode->i_sb->s_root) {
- CERROR ("IOC_SET_FSET must be called on mount point\n");
- return -ENODEV;
- }
-
- cache = presto_get_cache(root->d_inode);
- mnt = cache->cache_vfsmount;
- if (!mnt) {
- EXIT;
- return -ENOMEM;
- }
-
- izo_setup_ctxt(root, mnt, &save);
- rc = presto_set_fsetroot(root, fsetname, flags);
- izo_cleanup_ctxt(mnt, &save);
- return rc;
-}
-
-/* XXX: this function should detect if fsetname is already in use for
- the cache under root
-*/
-int izo_prepare_fileset(struct dentry *root, char *fsetname)
-{
- int err;
- struct dentry *dotizo = NULL, *fsetdir = NULL, *dotiopen = NULL;
- struct presto_cache *cache;
- struct vfsmount *mnt;
- struct run_ctxt save;
-
- cache = presto_get_cache(root->d_inode);
- mnt = cache->cache_vfsmount = izo_alloc_vfsmnt();
- if (!mnt) {
- EXIT;
- return -ENOMEM;
- }
-
- if (!fsetname)
- fsetname = "rootfset";
-
- izo_setup_ctxt(root, mnt, &save);
-
- err = izo_simple_mkdir(root, ".intermezzo", 0755);
- CDEBUG(D_CACHE, "mkdir on .intermezzo err %d\n", err);
-
- err = izo_simple_mkdir(root, "..iopen..", 0755);
- CDEBUG(D_CACHE, "mkdir on ..iopen.. err %d\n", err);
-
- dotiopen = lookup_one_len("..iopen..", root, strlen("..iopen.."));
- if (IS_ERR(dotiopen)) {
- EXIT;
- goto out;
- }
- dotiopen->d_inode->i_op = &presto_dir_iops;
- dput(dotiopen);
-
-
- dotizo = lookup_one_len(".intermezzo", root, strlen(".intermezzo"));
- if (IS_ERR(dotizo)) {
- EXIT;
- goto out;
- }
-
-
- err = izo_simple_mkdir(dotizo, fsetname, 0755);
- CDEBUG(D_CACHE, "mkdir err %d\n", err);
-
- /* XXX find the dentry of the root of the fileset (root for now) */
- fsetdir = lookup_one_len(fsetname, dotizo, strlen(fsetname));
- if (IS_ERR(fsetdir)) {
- EXIT;
- goto out;
- }
-
- err = izo_simple_symlink(fsetdir, "ROOT", "../..");
-
- /* XXX read flags from flags file */
- err = presto_set_fsetroot(root, fsetname, 0);
- CDEBUG(D_CACHE, "set_fsetroot err %d\n", err);
-
- out:
- if (dotizo && !IS_ERR(dotizo))
- dput(dotizo);
- if (fsetdir && !IS_ERR(fsetdir))
- dput(fsetdir);
- izo_cleanup_ctxt(mnt, &save);
- return err;
-}
-
-int izo_set_fileid(struct file *dir, struct izo_ioctl_data *data)
-{
- int rc = 0;
- struct presto_cache *cache;
- struct vfsmount *mnt;
- struct run_ctxt save;
- struct nameidata nd;
- struct dentry *dentry;
- struct presto_dentry_data *dd;
- struct dentry *root;
- char *buf = NULL;
-
- ENTRY;
-
-
- root = dir->f_dentry;
-
- /* actually, needs to be called on ROOT of fset, not mount point
- if (root != root->d_inode->i_sb->s_root) {
- CERROR ("IOC_SET_FSET must be called on mount point\n");
- return -ENODEV;
- }
- */
-
- cache = presto_get_cache(root->d_inode);
- mnt = cache->cache_vfsmount;
- if (!mnt) {
- EXIT;
- return -ENOMEM;
- }
-
- izo_setup_ctxt(root, mnt, &save);
-
- PRESTO_ALLOC(buf, data->ioc_plen1);
- if (!buf) {
- rc = -ENOMEM;
- EXIT;
- goto out;
- }
- if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
- rc = -EFAULT;
- EXIT;
- goto out;
- }
-
- rc = presto_walk(buf, &nd);
- if (rc) {
- CERROR("Unable to open: %s\n", buf);
- EXIT;
- goto out;
- }
- dentry = nd.dentry;
- if (!dentry) {
- CERROR("no dentry!\n");
- rc = -EINVAL;
- EXIT;
- goto out_close;
- }
- dd = presto_d2d(dentry);
- if (!dd) {
- CERROR("no dentry_data!\n");
- rc = -EINVAL;
- EXIT;
- goto out_close;
- }
-
- CDEBUG(D_FILE,"de:%p dd:%p\n", dentry, dd);
-
- if (dd->remote_ino != 0) {
- CERROR("remote_ino already set? %Lx:%Lx\n",
- (unsigned long long) dd->remote_ino,
- (unsigned long long) dd->remote_generation);
- rc = 0;
- EXIT;
- goto out_close;
- }
-
-
- CDEBUG(D_FILE,"setting %p %p, %s to %Lx:%Lx\n", dentry, dd,
- buf,
- (unsigned long long) data->ioc_ino,
- (unsigned long long) data->ioc_generation);
- dd->remote_ino = data->ioc_ino;
- dd->remote_generation = data->ioc_generation;
-
- EXIT;
- out_close:
- path_release(&nd);
- out:
- if (buf)
- PRESTO_FREE(buf, data->ioc_plen1);
- izo_cleanup_ctxt(mnt, &save);
- return rc;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1996 Peter J. Braam <braam@maths.ox.ac.uk> and
- * Michael Callahan <callahan@maths.ox.ac.uk>
- * Copyright (C) 1999 Carnegie Mellon University
- * Rewritten for Linux 2.1. Peter Braam <braam@cs.cmu.edu>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Super block/filesystem wide operations
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <asm/segment.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-extern void presto_free_cache(struct presto_cache *);
-
-void presto_set_ops(struct inode *inode, struct filter_fs *filter)
-{
- ENTRY;
-
- if (!inode || is_bad_inode(inode))
- return;
-
- if (S_ISREG(inode->i_mode)) {
- if ( !filter_c2cfiops(filter) ) {
- filter_setup_file_ops(filter,
- inode, &presto_file_iops,
- &presto_file_fops);
- }
- inode->i_op = filter_c2ufiops(filter);
- inode->i_fop = filter_c2uffops(filter);
- CDEBUG(D_INODE, "set file methods for %ld to %p\n",
- inode->i_ino, inode->i_op);
- } else if (S_ISDIR(inode->i_mode)) {
- inode->i_op = filter_c2udiops(filter);
- inode->i_fop = filter_c2udfops(filter);
- CDEBUG(D_INODE, "set dir methods for %ld to %p ioctl %p\n",
- inode->i_ino, inode->i_op, inode->i_fop->ioctl);
- } else if (S_ISLNK(inode->i_mode)) {
- if ( !filter_c2csiops(filter)) {
- filter_setup_symlink_ops(filter,
- inode,
- &presto_sym_iops,
- &presto_sym_fops);
- }
- inode->i_op = filter_c2usiops(filter);
- inode->i_fop = filter_c2usfops(filter);
- CDEBUG(D_INODE, "set link methods for %ld to %p\n",
- inode->i_ino, inode->i_op);
- }
- EXIT;
-}
-
-void presto_read_inode(struct inode *inode)
-{
- struct presto_cache *cache;
-
- cache = presto_get_cache(inode);
- if ( !cache ) {
- CERROR("PRESTO: BAD, BAD: cannot find cache\n");
- make_bad_inode(inode);
- return ;
- }
-
- filter_c2csops(cache->cache_filter)->read_inode(inode);
-
- CDEBUG(D_INODE, "presto_read_inode: ino %ld, gid %d\n",
- inode->i_ino, inode->i_gid);
-
- presto_set_ops(inode, cache->cache_filter);
- /* XXX handle special inodes here or not - probably not? */
-}
-
-static void presto_put_super(struct super_block *sb)
-{
- struct presto_cache *cache;
- struct upc_channel *channel;
- struct super_operations *sops;
- struct list_head *lh;
- int err;
-
- ENTRY;
- cache = presto_cache_find(sb);
- if (!cache) {
- EXIT;
- goto exit;
- }
- channel = &izo_channels[presto_c2m(cache)];
- sops = filter_c2csops(cache->cache_filter);
- err = izo_clear_all_fsetroots(cache);
- if (err) {
- CERROR("%s: err %d\n", __FUNCTION__, err);
- }
- PRESTO_FREE(cache->cache_vfsmount, sizeof(struct vfsmount));
-
- /* look at kill_super - fsync_super is not exported GRRR but
- probably not needed */
- unlock_super(sb);
- shrink_dcache_parent(cache->cache_root);
- dput(cache->cache_root);
- //fsync_super(sb);
- lock_super(sb);
-
- if (sops->write_super)
- sops->write_super(sb);
-
- if (sops->put_super)
- sops->put_super(sb);
-
- /* free any remaining async upcalls when the filesystem is unmounted */
- spin_lock(&channel->uc_lock);
- lh = channel->uc_pending.next;
- while ( lh != &channel->uc_pending) {
- struct upc_req *req;
- req = list_entry(lh, struct upc_req, rq_chain);
-
- /* assignment must be here: we are about to free &lh */
- lh = lh->next;
- if ( ! (req->rq_flags & REQ_ASYNC) )
- continue;
- list_del(&(req->rq_chain));
- PRESTO_FREE(req->rq_data, req->rq_bufsize);
- PRESTO_FREE(req, sizeof(struct upc_req));
- }
- list_del(&cache->cache_channel_list);
- spin_unlock(&channel->uc_lock);
-
- presto_free_cache(cache);
-
-exit:
- CDEBUG(D_MALLOC, "after umount: kmem %ld, vmem %ld\n",
- presto_kmemory, presto_vmemory);
- return ;
-}
-
-struct super_operations presto_super_ops = {
- .read_inode = presto_read_inode,
- .put_super = presto_put_super,
-};
-
-
-/* symlinks can be chowned */
-struct inode_operations presto_sym_iops = {
- .setattr = presto_setattr
-};
-
-/* NULL for now */
-struct file_operations presto_sym_fops;
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- * Copyright (C) 2001 Tacitus Systems, Inc.
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __INTERMEZZO_FS_H_
-#define __INTERMEZZO_FS_H_ 1
-
-#include "intermezzo_lib.h"
-#include "intermezzo_idl.h"
-
-
-#ifdef __KERNEL__
-typedef __u8 uuid_t[16];
-#else
-# include <uuid/uuid.h>
-#endif
-
-struct lento_vfs_context {
- __u64 kml_offset;
- struct timespec updated_time;
- __u64 remote_ino;
- __u64 remote_generation;
- __u32 slot_offset;
- __u32 recno;
- __u32 flags;
- uuid_t uuid;
- struct presto_version remote_version;
-};
-
-#ifdef __KERNEL__
-# include <linux/smp.h>
-# include <linux/fsfilter.h>
-# include <linux/mount.h>
-# include <linux/slab.h>
-# include <linux/vmalloc.h>
-# include <linux/smp_lock.h>
-
-/* fixups for fs.h */
-# ifndef fs_down
-# define fs_down(sem) down(sem)
-# endif
-
-# ifndef fs_up
-# define fs_up(sem) up(sem)
-# endif
-
-# define KML_IDLE 0
-# define KML_DECODE 1
-# define KML_OPTIMIZE 2
-# define KML_REINT 3
-
-# define KML_OPEN_REINT 0x0100
-# define KML_REINT_BEGIN 0x0200
-# define KML_BACKFETCH 0x0400
-# define KML_REINT_END 0x0800
-# define KML_CLOSE_REINT 0x1000
-# define KML_REINT_MAXBUF (64 * 1024)
-
-# define CACHE_CLIENT_RO 0x4
-# define CACHE_LENTO_RO 0x8
-
-/* global variables */
-extern int presto_debug;
-extern int presto_print_entry;
-extern long presto_kmemory;
-extern long presto_vmemory;
-
-# define PRESTO_DEBUG
-# ifdef PRESTO_DEBUG
-/* debugging masks */
-# define D_SUPER 1
-# define D_INODE 2
-# define D_FILE 4
-# define D_CACHE 8 /* cache debugging */
-# define D_MALLOC 16 /* print malloc, de-alloc information */
-# define D_JOURNAL 32
-# define D_UPCALL 64 /* up and downcall debugging */
-# define D_PSDEV 128
-# define D_PIOCTL 256
-# define D_SPECIAL 512
-# define D_TIMING 1024
-# define D_DOWNCALL 2048
-# define D_KML 4096
-# define D_FSDATA 8192
-
-# define CDEBUG(mask, format, a...) \
- do { \
- if (presto_debug & mask) { \
- printk("(%s:%s,l. %d %d): " format, __FILE__, \
- __FUNCTION__, __LINE__, current->pid \
- , ## a); \
- } \
- } while (0)
-
-#define CERROR(format, a...) \
-do { \
- printk("(%s:%s,l. %d %d): " format, __FILE__, __FUNCTION__, \
- __LINE__, current->pid , ## a); \
-} while (0)
-
-# define ENTRY \
- if (presto_print_entry) \
- printk("Process %d entered %s\n", current->pid, __FUNCTION__)
-
-# define EXIT \
- if (presto_print_entry) \
- printk("Process %d leaving %s at %d\n", current->pid, \
- __FUNCTION__, __LINE__)
-
-# define presto_kmem_inc(ptr, size) presto_kmemory += (size)
-# define presto_kmem_dec(ptr, size) presto_kmemory -= (size)
-# define presto_vmem_inc(ptr, size) presto_vmemory += (size)
-# define presto_vmem_dec(ptr, size) presto_vmemory -= (size)
-# else /* !PRESTO_DEBUG */
-# define CDEBUG(mask, format, a...) do {} while (0)
-# define ENTRY do {} while (0)
-# define EXIT do {} while (0)
-# define presto_kmem_inc(ptr, size) do {} while (0)
-# define presto_kmem_dec(ptr, size) do {} while (0)
-# define presto_vmem_inc(ptr, size) do {} while (0)
-# define presto_vmem_dec(ptr, size) do {} while (0)
-# endif /* PRESTO_DEBUG */
-
-
-struct run_ctxt {
- struct vfsmount *pwdmnt;
- struct dentry *pwd;
- struct vfsmount *rootmnt;
- struct dentry *root;
- uid_t fsuid;
- gid_t fsgid;
- mm_segment_t fs;
- struct group_info * group_info;
-/* int ngroups;
- gid_t groups[NGROUPS];*/
-
-};
-
-static inline void push_ctxt(struct run_ctxt *save, struct run_ctxt *new)
-{
- save->fs = get_fs();
- save->pwd = dget(current->fs->pwd);
- save->pwdmnt = mntget(current->fs->pwdmnt);
- save->fsgid = current->fsgid;
- save->fsuid = current->fsuid;
- save->root = current->fs->root;
- save->rootmnt = current->fs->rootmnt;
- save->group_info = current->group_info;
-/* save->ngroups = current->ngroups;
- for (i = 0; i< current->ngroups; i++)
- save->groups[i] = current->groups[i];*/
-
- set_fs(new->fs);
- lock_kernel();
- set_fs_pwd(current->fs, new->pwdmnt, new->pwd);
- if (new->root)
- set_fs_root(current->fs, new->rootmnt, new->root);
- unlock_kernel();
- current->fsuid = new->fsuid;
- current->fsgid = new->fsgid;
- /*if (new->ngroups > 0) {
- current->ngroups = new->ngroups;
- for (i = 0; i< new->ngroups; i++)
- current->groups[i] = new->groups[i];
- }*/
- current->group_info = new->group_info;
-
-}
-
-static inline void pop_ctxt(struct run_ctxt *saved)
-{
- set_fs(saved->fs);
- lock_kernel();
- set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
- if (saved->root)
- set_fs_root(current->fs, saved->rootmnt, saved->root);
- unlock_kernel();
- current->fsuid = saved->fsuid;
- current->fsgid = saved->fsgid;
- current->group_info = saved->group_info;
-/*
- current->ngroups = saved->ngroups;
- for (i = 0; i< saved->ngroups; i++)
- current->groups[i] = saved->groups[i];
-*/
- mntput(saved->pwdmnt);
- dput(saved->pwd);
-}
-
-static inline struct presto_dentry_data *presto_d2d(struct dentry *dentry)
-{
- return (struct presto_dentry_data *)(dentry->d_fsdata);
-}
-
-struct presto_cache {
- spinlock_t cache_lock;
- loff_t cache_reserved;
- struct vfsmount *cache_vfsmount;
- struct super_block *cache_sb;
- struct dentry *cache_root;
- struct list_head cache_chain; /* for the dev/cache hash */
-
- int cache_flags;
-
- char *cache_type; /* filesystem type of cache */
- struct filter_fs *cache_filter;
-
- struct upc_channel *cache_psdev; /* points to channel used */
- struct list_head cache_channel_list;
- struct list_head cache_fset_list; /* filesets mounted in cache */
-};
-
-struct presto_log_fd {
- rwlock_t fd_lock;
- loff_t fd_offset; /* offset where next record should go */
- struct file *fd_file;
- int fd_truncating;
- unsigned int fd_recno; /* last recno written */
- struct list_head fd_reservations;
-};
-
-/* file sets */
-# define CHUNK_BITS 16
-
-struct presto_file_set {
- struct list_head fset_list;
- struct presto_log_fd fset_kml;
- struct presto_log_fd fset_lml;
- struct presto_log_fd fset_rcvd;
- struct list_head *fset_clients; /* cache of clients */
- struct dentry *fset_dentry;
- struct vfsmount *fset_mnt;
- struct presto_cache *fset_cache;
-
- unsigned int fset_lento_recno; /* last recno mentioned to lento */
- loff_t fset_lento_off; /* last offset mentioned to lento */
- loff_t fset_kml_logical_off; /* logical offset of kml file byte 0 */
- char * fset_name;
-
- int fset_flags;
- int fset_chunkbits;
- char *fset_reint_buf; /* temporary buffer holds kml during reint */
-
- spinlock_t fset_permit_lock;
- int fset_permit_count;
- int fset_permit_upcall_count;
- /* This queue is used both for processes waiting for the kernel to give
- * up the permit as well as processes waiting for the kernel to be given
- * the permit, depending on the state of FSET_HASPERMIT. */
- wait_queue_head_t fset_permit_queue;
-
- loff_t fset_file_maxio; /* writing more than this causes a close */
- unsigned long int kml_truncate_size;
-};
-
-/* This is the default number of bytes written before a close is recorded*/
-#define FSET_DEFAULT_MAX_FILEIO (1024<<10)
-
-struct dentry *presto_tmpfs_ilookup(struct inode *dir, struct dentry *dentry,
- ino_t ino, unsigned int generation);
-struct dentry *presto_iget_ilookup(struct inode *dir, struct dentry *dentry,
- ino_t ino, unsigned int generation);
-struct dentry *presto_add_ilookup_dentry(struct dentry *parent,
- struct dentry *real);
-
-struct journal_ops {
- int (*tr_all_data)(struct inode *);
- loff_t (*tr_avail)(struct presto_cache *fset, struct super_block *);
- void *(*tr_start)(struct presto_file_set *, struct inode *, int op);
- void (*tr_commit)(struct presto_file_set *, void *handle);
- void (*tr_journal_data)(struct inode *);
- struct dentry *(*tr_ilookup)(struct inode *dir, struct dentry *dentry, ino_t ino, unsigned int generation);
- struct dentry *(*tr_add_ilookup)(struct dentry *parent, struct dentry *real);
-};
-
-extern struct journal_ops presto_ext2_journal_ops;
-extern struct journal_ops presto_ext3_journal_ops;
-extern struct journal_ops presto_tmpfs_journal_ops;
-extern struct journal_ops presto_xfs_journal_ops;
-extern struct journal_ops presto_reiserfs_journal_ops;
-extern struct journal_ops presto_obdfs_journal_ops;
-
-# define LENTO_FL_KML 0x0001
-# define LENTO_FL_EXPECT 0x0002
-# define LENTO_FL_VFSCHECK 0x0004
-# define LENTO_FL_JUSTLOG 0x0008
-# define LENTO_FL_WRITE_KML 0x0010
-# define LENTO_FL_CANCEL_LML 0x0020
-# define LENTO_FL_WRITE_EXPECT 0x0040
-# define LENTO_FL_IGNORE_TIME 0x0080
-# define LENTO_FL_TOUCH_PARENT 0x0100
-# define LENTO_FL_TOUCH_NEWOBJ 0x0200
-# define LENTO_FL_SET_DDFILEID 0x0400
-
-struct presto_cache *presto_get_cache(struct inode *inode);
-int presto_sprint_mounts(char *buf, int buflen, int minor);
-struct presto_file_set *presto_fset(struct dentry *de);
-int presto_journal(struct dentry *dentry, char *buf, size_t size);
-int presto_fwrite(struct file *file, const char *str, int len, loff_t *off);
-int presto_ispresto(struct inode *);
-
-/* super.c */
-extern struct file_system_type presto_fs_type;
-extern int init_intermezzo_fs(void);
-
-/* fileset.c */
-extern int izo_prepare_fileset(struct dentry *root, char *fsetname);
-char * izo_make_path(struct presto_file_set *fset, char *name);
-struct file *izo_fset_open(struct presto_file_set *fset, char *name, int flags, int mode);
-
-/* psdev.c */
-int izo_psdev_get_free_channel(void);
-int presto_psdev_init(void);
-int izo_psdev_setpid(int minor);
-extern void presto_psdev_cleanup(void);
-int presto_lento_up(int minor);
-int izo_psdev_setchannel(struct file *file, int fd);
-
-/* inode.c */
-extern struct super_operations presto_super_ops;
-void presto_set_ops(struct inode *inode, struct filter_fs *filter);
-
-/* dcache.c */
-void presto_frob_dop(struct dentry *de);
-char *presto_path(struct dentry *dentry, struct dentry *root,
- char *buffer, int buflen);
-struct presto_dentry_data *izo_alloc_ddata(void);
-int presto_set_dd(struct dentry *);
-int presto_init_ddata_cache(void);
-void presto_cleanup_ddata_cache(void);
-extern struct dentry_operations presto_dentry_ops;
-
-/* dir.c */
-extern struct inode_operations presto_dir_iops;
-extern struct inode_operations presto_file_iops;
-extern struct inode_operations presto_sym_iops;
-extern struct file_operations presto_dir_fops;
-extern struct file_operations presto_file_fops;
-extern struct file_operations presto_sym_fops;
-int presto_setattr(struct dentry *de, struct iattr *iattr);
-int presto_settime(struct presto_file_set *fset, struct dentry *newobj,
- struct dentry *parent, struct dentry *target,
- struct lento_vfs_context *ctx, int valid);
-int presto_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
-
-extern int presto_ilookup_uid;
-# define PRESTO_ILOOKUP_MAGIC "...ino:"
-# define PRESTO_ILOOKUP_SEP ':'
-int izo_dentry_is_ilookup(struct dentry *, ino_t *id, unsigned int *generation);
-struct dentry *presto_lookup(struct inode * dir, struct dentry *dentry, struct nameidata *nd);
-
-struct presto_dentry_data {
- int dd_count; /* how mnay dentries are using this dentry */
- struct presto_file_set *dd_fset;
- struct dentry *dd_inodentry;
- loff_t dd_kml_offset;
- int dd_flags;
- __u64 remote_ino;
- __u64 remote_generation;
-};
-
-struct presto_file_data {
- int fd_do_lml;
- loff_t fd_lml_offset;
- size_t fd_bytes_written;
- /* authorization related data of file at open time */
- uid_t fd_uid;
- gid_t fd_gid;
- mode_t fd_mode;
- /* identification data of calling process */
- uid_t fd_fsuid;
- gid_t fd_fsgid;
- int fd_ngroups;
- gid_t fd_groups[NGROUPS_SMALL];
- /* information how to complete the close operation */
- struct lento_vfs_context fd_info;
- struct presto_version fd_version;
-};
-
-/* presto.c and Lento::Downcall */
-
-int presto_walk(const char *name, struct nameidata *nd);
-int izo_clear_fsetroot(struct dentry *dentry);
-int izo_clear_all_fsetroots(struct presto_cache *cache);
-int presto_get_kmlsize(char *path, __u64 *size);
-int presto_get_lastrecno(char *path, off_t *size);
-int presto_set_fsetroot(struct dentry *dentry, char *fsetname,
- unsigned int flags);
-int presto_set_fsetroot_from_ioc(struct dentry *dentry, char *fsetname,
- unsigned int flags);
-int presto_is_read_only(struct presto_file_set *);
-int presto_truncate_lml(struct presto_file_set *fset);
-int lento_write_lml(char *path,
- __u64 remote_ino,
- __u32 remote_generation,
- __u32 remote_version,
- struct presto_version *remote_file_version);
-int lento_complete_closes(char *path);
-int presto_f2m(struct presto_file_set *fset);
-int presto_prep(struct dentry *, struct presto_cache **,
- struct presto_file_set **);
-/* cache.c */
-extern struct presto_cache *presto_cache_init(void);
-extern void presto_cache_add(struct presto_cache *cache);
-extern void presto_cache_init_hash(void);
-
-struct presto_cache *presto_cache_find(struct super_block *sb);
-
-#define PRESTO_REQLOW (3 * 4096)
-#define PRESTO_REQHIGH (6 * 4096)
-void presto_release_space(struct presto_cache *cache, loff_t req);
-int presto_reserve_space(struct presto_cache *cache, loff_t req);
-
-#define PRESTO_DATA 0x00000002 /* cached data is valid */
-#define PRESTO_ATTR 0x00000004 /* attributes cached */
-#define PRESTO_DONT_JOURNAL 0x00000008 /* things like .intermezzo/ */
-
-struct presto_file_set *presto_path2fileset(const char *name);
-int izo_revoke_permit(struct dentry *, uuid_t uuid);
-int presto_chk(struct dentry *dentry, int flag);
-void presto_set(struct dentry *dentry, int flag);
-int presto_get_permit(struct inode *inode);
-int presto_put_permit(struct inode *inode);
-int presto_set_max_kml_size(const char *path, unsigned long max_size);
-int izo_mark_dentry(struct dentry *dentry, int and, int or, int *res);
-int izo_mark_cache(struct dentry *dentry, int and_bits, int or_bits, int *);
-int izo_mark_fset(struct dentry *dentry, int and_bits, int or_bits, int *);
-void presto_getversion(struct presto_version *pv, struct inode *inode);
-int presto_i2m(struct inode *inode);
-int presto_c2m(struct presto_cache *cache);
-
-
-/* file.c */
-int izo_purge_file(struct presto_file_set *fset, char *file);
-int presto_adjust_lml(struct file *file, struct lento_vfs_context *info);
-
-/* journal.c */
-struct rec_info {
- loff_t offset;
- int size;
- int recno;
- int is_kml;
-};
-
-void presto_trans_commit(struct presto_file_set *fset, void *handle);
-void *presto_trans_start(struct presto_file_set *fset, struct inode *inode,
- int op);
-int presto_fread(struct file *file, char *str, int len, loff_t *off);
-int presto_clear_lml_close(struct presto_file_set *fset,
- loff_t lml_offset);
-int presto_complete_lml(struct presto_file_set *fset);
-int presto_read_kml_logical_offset(struct rec_info *recinfo,
- struct presto_file_set *fset);
-int presto_write_kml_logical_offset(struct presto_file_set *fset);
-struct file *presto_copy_kml_tail(struct presto_file_set *fset,
- unsigned long int start);
-int presto_finish_kml_truncate(struct presto_file_set *fset,
- unsigned long int offset);
-int izo_lookup_file(struct presto_file_set *fset, char *path,
- struct nameidata *nd);
-int izo_do_truncate(struct presto_file_set *fset, struct dentry *dentry,
- loff_t length, loff_t size_check);
-int izo_log_close(struct presto_log_fd *logfd);
-struct file *izo_log_open(struct presto_file_set *fset, char *name, int flags);
-int izo_init_kml_file(struct presto_file_set *, struct presto_log_fd *);
-int izo_init_lml_file(struct presto_file_set *, struct presto_log_fd *);
-int izo_init_last_rcvd_file(struct presto_file_set *, struct presto_log_fd *);
-
-/* vfs.c */
-
-/* Extra data needed in the KML for rollback operations; this structure is
- * passed around during the KML-writing process. */
-struct izo_rollback_data {
- __u32 rb_mode;
- __u32 rb_rdev;
- __u64 rb_uid;
- __u64 rb_gid;
-};
-
-int presto_write_last_rcvd(struct rec_info *recinfo,
- struct presto_file_set *fset,
- struct lento_vfs_context *info);
-void izo_get_rollback_data(struct inode *inode, struct izo_rollback_data *rb);
-int presto_do_close(struct presto_file_set *fset, struct file *file);
-int presto_do_setattr(struct presto_file_set *fset, struct dentry *dentry,
- struct iattr *iattr, struct lento_vfs_context *info);
-int presto_do_create(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode,
- struct lento_vfs_context *info);
-int presto_do_link(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *old_dentry, struct dentry *new_dentry,
- struct lento_vfs_context *info);
-int presto_do_unlink(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, struct lento_vfs_context *info);
-int presto_do_symlink(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, const char *name,
- struct lento_vfs_context *info);
-int presto_do_mkdir(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode,
- struct lento_vfs_context *info);
-int presto_do_rmdir(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, struct lento_vfs_context *info);
-int presto_do_mknod(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode, dev_t dev,
- struct lento_vfs_context *info);
-int do_rename(struct presto_file_set *fset, struct dentry *old_dir,
- struct dentry *old_dentry, struct dentry *new_dir,
- struct dentry *new_dentry, struct lento_vfs_context *info);
-int presto_do_statfs (struct presto_file_set *fset,
- struct kstatfs * buf);
-
-int lento_setattr(const char *name, struct iattr *iattr,
- struct lento_vfs_context *info);
-int lento_create(const char *name, int mode, struct lento_vfs_context *info);
-int lento_link(const char *oldname, const char *newname,
- struct lento_vfs_context *info);
-int lento_unlink(const char *name, struct lento_vfs_context *info);
-int lento_symlink(const char *oldname,const char *newname,
- struct lento_vfs_context *info);
-int lento_mkdir(const char *name, int mode, struct lento_vfs_context *info);
-int lento_rmdir(const char *name, struct lento_vfs_context *info);
-int lento_mknod(const char *name, int mode, dev_t dev,
- struct lento_vfs_context *info);
-int lento_rename(const char *oldname, const char *newname,
- struct lento_vfs_context *info);
-int lento_iopen(const char *name, ino_t ino, unsigned int generation,int flags);
-
-/* journal.c */
-
-#define JOURNAL_PAGE_SZ PAGE_SIZE
-
-int presto_no_journal(struct presto_file_set *fset);
-int journal_fetch(int minor);
-int presto_log(struct presto_file_set *fset, struct rec_info *rec,
- const char *buf, size_t size,
- const char *string1, int len1,
- const char *string2, int len2,
- const char *string3, int len3);
-int presto_get_fileid(int minor, struct presto_file_set *fset,
- struct dentry *dentry);
-int presto_journal_setattr(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry, struct presto_version *old_ver,
- struct izo_rollback_data *, struct iattr *iattr);
-int presto_journal_create(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_file_ver, int mode);
-int presto_journal_link(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *src, struct dentry *tgt,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_link_ver);
-int presto_journal_unlink(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dir,
- struct presto_version *tgt_dir_ver,
- struct presto_version *old_file_ver,
- struct izo_rollback_data *, struct dentry *dentry,
- char *old_target, int old_targetlen);
-int presto_journal_symlink(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry, const char *target,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_link_ver);
-int presto_journal_mkdir(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_dir_ver, int mode);
-int presto_journal_rmdir(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *old_dir_ver,
- struct izo_rollback_data *, int len, const char *name);
-int presto_journal_mknod(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_node_ver, int mode,
- int dmajor, int dminor);
-int presto_journal_rename(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *src, struct dentry *tgt,
- struct presto_version *src_dir_ver,
- struct presto_version *tgt_dir_ver);
-int presto_journal_open(struct rec_info *, struct presto_file_set *,
- struct dentry *, struct presto_version *old_ver);
-int presto_journal_close(struct rec_info *rec, struct presto_file_set *,
- struct presto_file_data *, struct dentry *,
- struct presto_version *old_file_ver,
- struct presto_version *new_file_ver);
-int presto_write_lml_close(struct rec_info *rec,
- struct presto_file_set *fset,
- struct file *file,
- __u64 remote_ino,
- __u64 remote_generation,
- struct presto_version *remote_version,
- struct presto_version *new_file_ver);
-void presto_log_op(void *data, int len);
-loff_t presto_kml_offset(struct presto_file_set *fset);
-
-/* upcall.c */
-#define SYNCHRONOUS 0
-#define ASYNCHRONOUS 1
-/* asynchronous calls */
-int izo_upc_kml(int minor, __u64 offset, __u32 first_recno, __u64 length,
- __u32 last_recno, char *fsetname);
-int izo_upc_kml_truncate(int minor, __u64 length, __u32 last_recno,
- char *fsetname);
-int izo_upc_go_fetch_kml(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);
-int izo_upc_backfetch(int minor, char *path, char *fileset,
- struct lento_vfs_context *);
-
-/* synchronous calls */
-int izo_upc_get_fileid(int minor, __u32 reclen, char *rec,
- __u32 pathlen, char *path, char *fsetname);
-int izo_upc_permit(int minor, struct dentry *, __u32 pathlen, char *path,
- char *fset);
-int izo_upc_open(int minor, __u32 pathlen, char *path, char *fsetname,
- struct lento_vfs_context *info);
-int izo_upc_connect(int minor, __u64 ip_address, __u64 port, __u8 uuid[16],
- int client_flag);
-int izo_upc_revoke_permit(int minor, char *fsetname, uuid_t uuid);
-int izo_upc_set_kmlsize(int minor, char *fsetname, uuid_t uuid, __u64 kmlsize);
-int izo_upc_client_make_branch(int minor, char *fsetname);
-int izo_upc_server_make_branch(int minor, char *fsetname);
-int izo_upc_branch_undo(int minor, char *fsetname, char *branchname);
-int izo_upc_branch_redo(int minor, char *fsetname, char *branchname);
-int izo_upc_repstatus(int minor, char * fsetname, struct izo_rcvd_rec *lr_server);
-
-/* general mechanism */
-int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *, int async);
-
-/* replicator.c */
-int izo_repstatus(struct presto_file_set *fset, __u64 client_kmlsize,
- struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server);
-int izo_rep_cache_init(struct presto_file_set *);
-loff_t izo_rcvd_get(struct izo_rcvd_rec *, struct presto_file_set *, char *uuid);
-loff_t izo_rcvd_write(struct presto_file_set *, struct izo_rcvd_rec *);
-loff_t izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid, __u64 remote_recno,
- __u64 remote_offset);
-
-int izo_ioctl_packlen(struct izo_ioctl_data *data);
-
-/* sysctl.c */
-int init_intermezzo_sysctl(void);
-void cleanup_intermezzo_sysctl(void);
-
-/* ext_attr.c */
-/* We will be more tolerant than the default ea patch with attr name sizes and
- * the size of value. If these come via VFS from the default ea patches, the
- * corresponding character strings will be truncated anyway. During journalling- * we journal length for both name and value. See journal_set_ext_attr.
- */
-#define PRESTO_EXT_ATTR_NAME_MAX 128
-#define PRESTO_EXT_ATTR_VALUE_MAX 8192
-
-#define PRESTO_ALLOC(ptr, size) \
-do { \
- long s = (size); \
- (ptr) = kmalloc(s, GFP_KERNEL); \
- if ((ptr) == NULL) \
- CERROR("IZO: out of memory at %s:%d (trying to " \
- "allocate %ld)\n", __FILE__, __LINE__, s); \
- else { \
- presto_kmem_inc((ptr), s); \
- memset((ptr), 0, s); \
- } \
- CDEBUG(D_MALLOC, "kmalloced: %ld at %p (tot %ld).\n", \
- s, (ptr), presto_kmemory); \
-} while (0)
-
-#define PRESTO_FREE(ptr, size) \
-do { \
- long s = (size); \
- if ((ptr) == NULL) { \
- CERROR("IZO: free NULL pointer (%ld bytes) at " \
- "%s:%d\n", s, __FILE__, __LINE__); \
- break; \
- } \
- kfree(ptr); \
- CDEBUG(D_MALLOC, "kfreed: %ld at %p (tot %ld).\n", \
- s, (ptr), presto_kmemory); \
- presto_kmem_dec((ptr), s); \
-} while (0)
-
-static inline int dentry_name_cmp(struct dentry *dentry, char *name)
-{
- return (strlen(name) == dentry->d_name.len &&
- memcmp(name, dentry->d_name.name, dentry->d_name.len) == 0);
-}
-
-static inline char *strdup(char *str)
-{
- char *tmp;
- tmp = kmalloc(strlen(str) + 1, GFP_KERNEL);
- if (tmp)
- memcpy(tmp, str, strlen(str) + 1);
-
- return tmp;
-}
-
-static inline int izo_ioctl_is_invalid(struct izo_ioctl_data *data)
-{
- if (data->ioc_len > (1<<30)) {
- CERROR("IZO ioctl: ioc_len larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen1 > (1<<30)) {
- CERROR("IZO ioctl: ioc_inllen1 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen2 > (1<<30)) {
- CERROR("IZO ioctl: ioc_inllen2 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
- CERROR("IZO ioctl: inlbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
- CERROR("IZO ioctl: inlbuf2 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf1 && !data->ioc_plen1) {
- CERROR("IZO ioctl: pbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf2 && !data->ioc_plen2) {
- CERROR("IZO ioctl: pbuf2 pointer but 0 length\n");
- return 1;
- }
- if (izo_ioctl_packlen(data) != data->ioc_len ) {
- CERROR("IZO ioctl: packlen exceeds ioc_len\n");
- return 1;
- }
- if (data->ioc_inllen1 &&
- data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
- CERROR("IZO ioctl: inlbuf1 not 0 terminated\n");
- return 1;
- }
- if (data->ioc_inllen2 &&
- data->ioc_bulk[size_round(data->ioc_inllen1) + data->ioc_inllen2
- - 1] != '\0') {
- CERROR("IZO ioctl: inlbuf2 not 0 terminated\n");
- return 1;
- }
- return 0;
-}
-
-/* buffer MUST be at least the size of izo_ioctl_hdr */
-static inline int izo_ioctl_getdata(char *buf, char *end, void *arg)
-{
- struct izo_ioctl_hdr *hdr;
- struct izo_ioctl_data *data;
- int err;
- ENTRY;
-
- hdr = (struct izo_ioctl_hdr *)buf;
- data = (struct izo_ioctl_data *)buf;
-
- err = copy_from_user(buf, (void *)arg, sizeof(*hdr));
- if ( err ) {
- EXIT;
- return err;
- }
-
- if (hdr->ioc_version != IZO_IOCTL_VERSION) {
- CERROR("IZO: version mismatch kernel vs application\n");
- return -EINVAL;
- }
-
- if (hdr->ioc_len + buf >= end) {
- CERROR("IZO: user buffer exceeds kernel buffer\n");
- return -EINVAL;
- }
-
- if (hdr->ioc_len < sizeof(struct izo_ioctl_data)) {
- CERROR("IZO: user buffer too small for ioctl\n");
- return -EINVAL;
- }
-
- err = copy_from_user(buf, (void *)arg, hdr->ioc_len);
- if ( err ) {
- EXIT;
- return err;
- }
-
- if (izo_ioctl_is_invalid(data)) {
- CERROR("IZO: ioctl not correctly formatted\n");
- return -EINVAL;
- }
-
- if (data->ioc_inllen1) {
- data->ioc_inlbuf1 = &data->ioc_bulk[0];
- }
-
- if (data->ioc_inllen2) {
- data->ioc_inlbuf2 = &data->ioc_bulk[0] +
- size_round(data->ioc_inllen1);
- }
-
- EXIT;
- return 0;
-}
-
-# define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))
-
-# define free kfree
-# define malloc(a) kmalloc(a, GFP_KERNEL)
-# define printf printk
-int kml_reint_rec(struct file *dir, struct izo_ioctl_data *data);
-int izo_get_fileid(struct file *dir, struct izo_ioctl_data *data);
-int izo_set_fileid(struct file *dir, struct izo_ioctl_data *data);
-
-#else /* __KERNEL__ */
-# include <stdlib.h>
-# include <stdio.h>
-# include <sys/types.h>
-# include <sys/ioctl.h>
-# include <string.h>
-
-# define printk printf
-# ifndef CERROR
-# define CERROR printf
-# endif
-# define kmalloc(a,b) malloc(a)
-
-void init_fsreintdata (void);
-int kml_fsreint(struct kml_rec *rec, char *basedir);
-int kml_iocreint(__u32 size, char *ptr, __u32 offset, int dird,
- uuid_t uuid, __u32 generate_kml);
-
-static inline void izo_ioctl_init(struct izo_ioctl_data *data)
-{
- memset(data, 0, sizeof(*data));
- data->ioc_len = sizeof(*data);
- data->ioc_version = IZO_IOCTL_VERSION;
-}
-
-static inline int
-izo_ioctl_pack(struct izo_ioctl_data *data, char **pbuf, int max)
-{
- char *ptr;
- struct izo_ioctl_data *overlay;
- data->ioc_len = izo_ioctl_packlen(data);
- data->ioc_version = IZO_IOCTL_VERSION;
-
- if (*pbuf && izo_ioctl_packlen(data) > max)
- return 1;
- if (*pbuf == NULL)
- *pbuf = malloc(data->ioc_len);
- if (*pbuf == NULL)
- return 1;
- overlay = (struct izo_ioctl_data *)*pbuf;
- memcpy(*pbuf, data, sizeof(*data));
-
- ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1)
- LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
- if (data->ioc_inlbuf2)
- LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
- if (izo_ioctl_is_invalid(overlay))
- return 1;
-
- return 0;
-}
-
-#endif /* __KERNEL__*/
-
-#define IZO_ERROR_NAME 1
-#define IZO_ERROR_UPDATE 2
-#define IZO_ERROR_DELETE 3
-#define IZO_ERROR_RENAME 4
-
-static inline char *izo_error(int err)
-{
-#ifndef __KERNEL__
- if (err <= 0)
- return strerror(-err);
-#endif
- switch (err) {
- case IZO_ERROR_NAME:
- return "InterMezzo name/name conflict";
- case IZO_ERROR_UPDATE:
- return "InterMezzo update/update conflict";
- case IZO_ERROR_DELETE:
- return "InterMezzo update/delete conflict";
- case IZO_ERROR_RENAME:
- return "InterMezzo rename/rename conflict";
- }
- return "Unknown InterMezzo error";
-}
-
-/* kml_unpack.c */
-char *kml_print_rec(struct kml_rec *rec, int brief);
-int kml_unpack(struct kml_rec *rec, char **buf, char *end);
-
-/* fs 2.5 compat */
-
-/* is_read_only() is replaced by bdev_read_only which takes struct
- block_device *. Since this is only needed for debugging, it can be
- safely ignored now.
-*/
-#define is_read_only(dev) 0
-
-#endif
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- * Copyright (C) 2001 Tacit Networks, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __INTERMEZZO_IDL_H__
-#define __INTERMEZZO_IDL_H__
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-/* this file contains all data structures used in InterMezzo's interfaces:
- * - upcalls
- * - ioctl's
- * - KML records
- * - RCVD records
- * - rpc's
- */
-
-/* UPCALL */
-#define INTERMEZZO_MINOR 248
-
-
-#define IZO_UPC_VERSION 0x00010002
-#define IZO_UPC_PERMIT 1
-#define IZO_UPC_CONNECT 2
-#define IZO_UPC_GO_FETCH_KML 3
-#define IZO_UPC_OPEN 4
-#define IZO_UPC_REVOKE_PERMIT 5
-#define IZO_UPC_KML 6
-#define IZO_UPC_BACKFETCH 7
-#define IZO_UPC_KML_TRUNC 8
-#define IZO_UPC_SET_KMLSIZE 9
-#define IZO_UPC_BRANCH_UNDO 10
-#define IZO_UPC_BRANCH_REDO 11
-#define IZO_UPC_GET_FILEID 12
-#define IZO_UPC_CLIENT_MAKE_BRANCH 13
-#define IZO_UPC_SERVER_MAKE_BRANCH 14
-#define IZO_UPC_REPSTATUS 15
-
-#define IZO_UPC_LARGEST_OPCODE 15
-
-struct izo_upcall_hdr {
- __u32 u_len;
- __u32 u_version;
- __u32 u_opc;
- __u32 u_uniq;
- __u32 u_pid;
- __u32 u_uid;
- __u32 u_pathlen;
- __u32 u_fsetlen;
- __u64 u_offset;
- __u64 u_length;
- __u32 u_first_recno;
- __u32 u_last_recno;
- __u32 u_async;
- __u32 u_reclen;
- __u8 u_uuid[16];
-};
-
-/* This structure _must_ sit at the beginning of the buffer */
-struct izo_upcall_resp {
- __u32 opcode;
- __u32 unique;
- __u32 result;
-};
-
-
-/* IOCTL */
-
-#define IZO_IOCTL_VERSION 0x00010003
-
-/* maximum size supported for ioc_pbuf1 */
-#define KML_MAX_BUF (64*1024)
-
-struct izo_ioctl_hdr {
- __u32 ioc_len;
- __u32 ioc_version;
-};
-
-struct izo_ioctl_data {
- __u32 ioc_len;
- __u32 ioc_version;
- __u32 ioc_izodev;
- __u32 ioc_kmlrecno;
- __u64 ioc_kmlsize;
- __u32 ioc_flags;
- __s32 ioc_inofd;
- __u64 ioc_ino;
- __u64 ioc_generation;
- __u32 ioc_mark_what;
- __u32 ioc_and_flag;
- __u32 ioc_or_flag;
- __u32 ioc_dev;
- __u32 ioc_offset;
- __u32 ioc_slot;
- __u64 ioc_uid;
- __u8 ioc_uuid[16];
-
- __u32 ioc_inllen1; /* path */
- char *ioc_inlbuf1;
- __u32 ioc_inllen2; /* fileset */
- char *ioc_inlbuf2;
-
- __u32 ioc_plen1; /* buffers in user space (KML) */
- char *ioc_pbuf1;
- __u32 ioc_plen2; /* buffers in user space (KML) */
- char *ioc_pbuf2;
-
- char ioc_bulk[0];
-};
-
-#define IZO_IOC_DEVICE _IOW ('p',0x50, void *)
-#define IZO_IOC_REINTKML _IOW ('p',0x51, void *)
-#define IZO_IOC_GET_RCVD _IOW ('p',0x52, void *)
-#define IZO_IOC_SET_IOCTL_UID _IOW ('p',0x53, void *)
-#define IZO_IOC_GET_KML_SIZE _IOW ('p',0x54, void *)
-#define IZO_IOC_PURGE_FILE_DATA _IOW ('p',0x55, void *)
-#define IZO_IOC_CONNECT _IOW ('p',0x56, void *)
-#define IZO_IOC_GO_FETCH_KML _IOW ('p',0x57, void *)
-#define IZO_IOC_MARK _IOW ('p',0x58, void *)
-#define IZO_IOC_CLEAR_FSET _IOW ('p',0x59, void *)
-#define IZO_IOC_CLEAR_ALL_FSETS _IOW ('p',0x60, void *)
-#define IZO_IOC_SET_FSET _IOW ('p',0x61, void *)
-#define IZO_IOC_REVOKE_PERMIT _IOW ('p',0x62, void *)
-#define IZO_IOC_SET_KMLSIZE _IOW ('p',0x63, void *)
-#define IZO_IOC_CLIENT_MAKE_BRANCH _IOW ('p',0x64, void *)
-#define IZO_IOC_SERVER_MAKE_BRANCH _IOW ('p',0x65, void *)
-#define IZO_IOC_BRANCH_UNDO _IOW ('p',0x66, void *)
-#define IZO_IOC_BRANCH_REDO _IOW ('p',0x67, void *)
-#define IZO_IOC_SET_PID _IOW ('p',0x68, void *)
-#define IZO_IOC_SET_CHANNEL _IOW ('p',0x69, void *)
-#define IZO_IOC_GET_CHANNEL _IOW ('p',0x70, void *)
-#define IZO_IOC_GET_FILEID _IOW ('p',0x71, void *)
-#define IZO_IOC_ADJUST_LML _IOW ('p',0x72, void *)
-#define IZO_IOC_SET_FILEID _IOW ('p',0x73, void *)
-#define IZO_IOC_REPSTATUS _IOW ('p',0x74, void *)
-
-/* marking flags for fsets */
-#define FSET_CLIENT_RO 0x00000001
-#define FSET_LENTO_RO 0x00000002
-#define FSET_HASPERMIT 0x00000004 /* we have a permit to WB */
-#define FSET_INSYNC 0x00000008 /* this fileset is in sync */
-#define FSET_PERMIT_WAITING 0x00000010 /* Lento is waiting for permit */
-#define FSET_STEAL_PERMIT 0x00000020 /* take permit if Lento is dead */
-#define FSET_JCLOSE_ON_WRITE 0x00000040 /* Journal closes on writes */
-#define FSET_DATA_ON_DEMAND 0x00000080 /* update data on file_open() */
-#define FSET_PERMIT_EXCLUSIVE 0x00000100 /* only one permitholder allowed */
-#define FSET_HAS_BRANCHES 0x00000200 /* this fileset contains branches */
-#define FSET_IS_BRANCH 0x00000400 /* this fileset is a branch */
-#define FSET_FLAT_BRANCH 0x00000800 /* this fileset is ROOT with branches */
-
-/* what to mark indicator (ioctl parameter) */
-#define MARK_DENTRY 101
-#define MARK_FSET 102
-#define MARK_CACHE 103
-#define MARK_GETFL 104
-
-/* KML */
-
-#define KML_MAJOR_VERSION 0x00010000
-#define KML_MINOR_VERSION 0x00000002
-#define KML_OPCODE_NOOP 0
-#define KML_OPCODE_CREATE 1
-#define KML_OPCODE_MKDIR 2
-#define KML_OPCODE_UNLINK 3
-#define KML_OPCODE_RMDIR 4
-#define KML_OPCODE_CLOSE 5
-#define KML_OPCODE_SYMLINK 6
-#define KML_OPCODE_RENAME 7
-#define KML_OPCODE_SETATTR 8
-#define KML_OPCODE_LINK 9
-#define KML_OPCODE_OPEN 10
-#define KML_OPCODE_MKNOD 11
-#define KML_OPCODE_WRITE 12
-#define KML_OPCODE_RELEASE 13
-#define KML_OPCODE_TRUNC 14
-#define KML_OPCODE_SETEXTATTR 15
-#define KML_OPCODE_DELEXTATTR 16
-#define KML_OPCODE_KML_TRUNC 17
-#define KML_OPCODE_GET_FILEID 18
-#define KML_OPCODE_NUM 19
-/* new stuff */
-struct presto_version {
- __u32 pv_mtime_sec;
- __u32 pv_mtime_nsec;
- __u32 pv_ctime_sec;
- __u32 pv_ctime_nsec;
- __u64 pv_size;
-};
-
-struct kml_prefix_hdr {
- __u32 len;
- __u32 version;
- __u32 pid;
- __u32 auid;
- __u32 fsuid;
- __u32 fsgid;
- __u32 opcode;
- __u32 ngroups;
-};
-
-struct kml_prefix {
- struct kml_prefix_hdr *hdr;
- __u32 *groups;
-};
-
-struct kml_suffix {
- __u32 prevrec;
- __u32 recno;
- __u32 time;
- __u32 len;
-};
-
-struct kml_rec {
- char *buf;
- struct kml_prefix prefix;
- __u64 offset;
- char *path;
- int pathlen;
- char *name;
- int namelen;
- char *target;
- int targetlen;
- struct presto_version *old_objectv;
- struct presto_version *new_objectv;
- struct presto_version *old_parentv;
- struct presto_version *new_parentv;
- struct presto_version *old_targetv;
- struct presto_version *new_targetv;
- __u32 valid;
- __u32 mode;
- __u32 uid;
- __u32 gid;
- __u64 size;
- __u32 mtime_sec;
- __u32 mtime_nsec;
- __u32 ctime_sec;
- __u32 ctime_nsec;
- __u32 flags;
- __u32 ino;
- __u32 rdev;
- __u32 major;
- __u32 minor;
- __u32 generation;
- __u32 old_mode;
- __u32 old_rdev;
- __u64 old_uid;
- __u64 old_gid;
- char *old_target;
- int old_targetlen;
- struct kml_suffix *suffix;
-};
-
-
-/* RCVD */
-
-/* izo_rcvd_rec fills the .intermezzo/fset/last_rcvd file and provides data about
- * our view of reintegration offsets for a given peer.
- *
- * The only exception is the last_rcvd record which has a UUID consisting of all
- * zeroes; this record's lr_local_offset field is the logical byte offset of our
- * KML, which is updated when KML truncation takes place. All other fields are
- * reserved. */
-
-/* XXX - document how clean shutdowns are recorded */
-
-struct izo_rcvd_rec {
- __u8 lr_uuid[16]; /* which peer? */
- __u64 lr_remote_recno; /* last confirmed remote recno */
- __u64 lr_remote_offset; /* last confirmed remote offset */
- __u64 lr_local_recno; /* last locally reinted recno */
- __u64 lr_local_offset; /* last locally reinted offset */
- __u64 lr_last_ctime; /* the largest ctime that has reintegrated */
-};
-
-/* Cache purge database
- *
- * Each DB entry is this structure followed by the path name, no trailing NUL. */
-struct izo_purge_entry {
- __u64 p_atime;
- __u32 p_pathlen;
-};
-
-/* RPC */
-
-#endif
+++ /dev/null
-#ifndef __PRESTO_JOURNAL_H
-#define __PRESTO_JOURNAL_H
-
-
-struct journal_prefix {
- int len;
- u32 version;
- int pid;
- int uid;
- int fsuid;
- int fsgid;
- int opcode;
- u32 ngroups;
- u32 groups[0];
-};
-
-struct journal_suffix {
- unsigned long prevrec; /* offset of previous record for dentry */
- int recno;
- int time;
- int len;
-};
-
-#endif
+++ /dev/null
-#ifndef __INTERMEZZO_KML_H
-#define __INTERMEZZO_KML_H
-
-#include "intermezzo_psdev.h"
-#include <linux/fs.h>
-#include "intermezzo_journal.h"
-
-#define PRESTO_KML_MAJOR_VERSION 0x00010000
-#define PRESTO_KML_MINOR_VERSION 0x00002001
-#define PRESTO_OP_NOOP 0
-#define PRESTO_OP_CREATE 1
-#define PRESTO_OP_MKDIR 2
-#define PRESTO_OP_UNLINK 3
-#define PRESTO_OP_RMDIR 4
-#define PRESTO_OP_CLOSE 5
-#define PRESTO_OP_SYMLINK 6
-#define PRESTO_OP_RENAME 7
-#define PRESTO_OP_SETATTR 8
-#define PRESTO_OP_LINK 9
-#define PRESTO_OP_OPEN 10
-#define PRESTO_OP_MKNOD 11
-#define PRESTO_OP_WRITE 12
-#define PRESTO_OP_RELEASE 13
-#define PRESTO_OP_TRUNC 14
-#define PRESTO_OP_SETEXTATTR 15
-#define PRESTO_OP_DELEXTATTR 16
-
-#define PRESTO_LML_DONE 1 /* flag to get first write to do LML */
-#define KML_KOP_MARK 0xffff
-
-struct presto_lml_data {
- loff_t rec_offset;
-};
-
-struct big_journal_prefix {
- u32 len;
- u32 version;
- u32 pid;
- u32 uid;
- u32 fsuid;
- u32 fsgid;
- u32 opcode;
- u32 ngroups;
- u32 groups[NGROUPS_SMALL];
-};
-
-enum kml_opcode {
- KML_CREATE = 1,
- KML_MKDIR,
- KML_UNLINK,
- KML_RMDIR,
- KML_CLOSE,
- KML_SYMLINK,
- KML_RENAME,
- KML_SETATTR,
- KML_LINK,
- KML_OPEN,
- KML_MKNOD,
- KML_ENDMARK = 0xff
-};
-
-struct kml_create {
- char *path;
- struct presto_version new_objectv,
- old_parentv,
- new_parentv;
- int mode;
- int uid;
- int gid;
-};
-
-struct kml_open {
-};
-
-struct kml_mkdir {
- char *path;
- struct presto_version new_objectv,
- old_parentv,
- new_parentv;
- int mode;
- int uid;
- int gid;
-};
-
-struct kml_unlink {
- char *path,
- *name;
- struct presto_version old_tgtv,
- old_parentv,
- new_parentv;
-};
-
-struct kml_rmdir {
- char *path,
- *name;
- struct presto_version old_tgtv,
- old_parentv,
- new_parentv;
-};
-
-struct kml_close {
- int open_mode,
- open_uid,
- open_gid;
- char *path;
- struct presto_version new_objectv;
- __u64 ino;
- int generation;
-};
-
-struct kml_symlink {
- char *sourcepath,
- *targetpath;
- struct presto_version new_objectv,
- old_parentv,
- new_parentv;
- int uid;
- int gid;
-};
-
-struct kml_rename {
- char *sourcepath,
- *targetpath;
- struct presto_version old_objectv,
- new_objectv,
- old_tgtv,
- new_tgtv;
-};
-
-struct kml_setattr {
- char *path;
- struct presto_version old_objectv;
- struct iattr iattr;
-};
-
-struct kml_link {
- char *sourcepath,
- *targetpath;
- struct presto_version new_objectv,
- old_parentv,
- new_parentv;
-};
-
-struct kml_mknod {
- char *path;
- struct presto_version new_objectv,
- old_parentv,
- new_parentv;
- int mode;
- int uid;
- int gid;
- int major;
- int minor;
-};
-
-/* kml record items for optimizing */
-struct kml_kop_node
-{
- u32 kml_recno;
- u32 kml_flag;
- u32 kml_op;
- nlink_t i_nlink;
- u32 i_ino;
-};
-
-struct kml_kop_lnode
-{
- struct list_head chains;
- struct kml_kop_node node;
-};
-
-struct kml_endmark {
- u32 total;
- struct kml_kop_node *kop;
-};
-
-/* kml_flag */
-#define KML_REC_DELETE 1
-#define KML_REC_EXIST 0
-
-struct kml_optimize {
- struct list_head kml_chains;
- u32 kml_flag;
- u32 kml_op;
- nlink_t i_nlink;
- u32 i_ino;
-};
-
-struct kml_rec {
- /* attribute of this record */
- int rec_size;
- int rec_kml_offset;
-
- struct big_journal_prefix rec_head;
- union {
- struct kml_create create;
- struct kml_open open;
- struct kml_mkdir mkdir;
- struct kml_unlink unlink;
- struct kml_rmdir rmdir;
- struct kml_close close;
- struct kml_symlink symlink;
- struct kml_rename rename;
- struct kml_setattr setattr;
- struct kml_mknod mknod;
- struct kml_link link;
- struct kml_endmark endmark;
- } rec_kml;
- struct journal_suffix rec_tail;
-
- /* for kml optimize only */
- struct kml_optimize kml_optimize;
-};
-
-/* kml record items for optimizing */
-extern void kml_kop_init (struct presto_file_set *fset);
-extern void kml_kop_addrec (struct presto_file_set *fset,
- struct inode *ino, u32 op, u32 flag);
-extern int kml_kop_flush (struct presto_file_set *fset);
-
-/* defined in kml_setup.c */
-extern int kml_init (struct presto_file_set *fset);
-extern int kml_cleanup (struct presto_file_set *fset);
-
-/* defined in kml.c */
-extern int begin_kml_reint (struct file *file, unsigned long arg);
-extern int do_kml_reint (struct file *file, unsigned long arg);
-extern int end_kml_reint (struct file *file, unsigned long arg);
-
-/* kml_utils.c */
-extern char *dlogit (void *tbuf, const void *sbuf, int size);
-extern char * bdup_printf (char *format, ...);
-
-/* defined in kml_decode.c */
-/* printop */
-#define PRINT_KML_PREFIX 0x1
-#define PRINT_KML_SUFFIX 0x2
-#define PRINT_KML_REC 0x4
-#define PRINT_KML_OPTIMIZE 0x8
-#define PRINT_KML_EXIST 0x10
-#define PRINT_KML_DELETE 0x20
-extern void kml_printrec (struct kml_rec *rec, int printop);
-extern int print_allkmlrec (struct list_head *head, int printop);
-extern int delete_kmlrec (struct list_head *head);
-extern int kml_decoderec (char *buf, int pos, int buflen, int *size,
- struct kml_rec **newrec);
-extern int decode_kmlrec (struct list_head *head, char *kml_buf, int buflen);
-extern void kml_freerec (struct kml_rec *rec);
-
-/* defined in kml_reint.c */
-#define KML_CLOSE_BACKFETCH 1
-extern int kml_reintbuf (struct kml_fsdata *kml_fsdata,
- char *mtpt, struct kml_rec **rec);
-
-/* defined in kml_setup.c */
-extern int kml_init (struct presto_file_set *fset);
-extern int kml_cleanup (struct presto_file_set *fset);
-
-#endif
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Data structures unpacking/packing macros & inlines
- *
- */
-
-#ifndef _INTERMEZZO_LIB_H
-#define _INTERMEZZO_LIB_H
-
-#ifdef __KERNEL__
-# include <linux/types.h>
-#else
-# include <string.h>
-# include <sys/types.h>
-#endif
-
-static inline int size_round (int val)
-{
- return (val + 3) & (~0x3);
-}
-
-static inline int size_round0(int val)
-{
- if (!val)
- return 0;
- return (val + 1 + 3) & (~0x3);
-}
-
-static inline size_t round_strlen(char *fset)
-{
- return size_round(strlen(fset) + 1);
-}
-
-#ifdef __KERNEL__
-# define NTOH__u32(var) le32_to_cpu(var)
-# define NTOH__u64(var) le64_to_cpu(var)
-# define HTON__u32(var) cpu_to_le32(var)
-# define HTON__u64(var) cpu_to_le64(var)
-#else
-# include <glib.h>
-# define NTOH__u32(var) GUINT32_FROM_LE(var)
-# define NTOH__u64(var) GUINT64_FROM_LE(var)
-# define HTON__u32(var) GUINT32_TO_LE(var)
-# define HTON__u64(var) GUINT64_TO_LE(var)
-#endif
-
-/*
- * copy sizeof(type) bytes from pointer to var and move ptr forward.
- * return EFAULT if pointer goes beyond end
- */
-#define UNLOGV(var,type,ptr,end) \
-do { \
- var = *(type *)ptr; \
- ptr += sizeof(type); \
- if (ptr > end ) \
- return -EFAULT; \
-} while (0)
-
-/* the following two macros convert to little endian */
-/* type MUST be __u32 or __u64 */
-#define LUNLOGV(var,type,ptr,end) \
-do { \
- var = NTOH##type(*(type *)ptr); \
- ptr += sizeof(type); \
- if (ptr > end ) \
- return -EFAULT; \
-} while (0)
-
-/* now log values */
-#define LOGV(var,type,ptr) \
-do { \
- *((type *)ptr) = var; \
- ptr += sizeof(type); \
-} while (0)
-
-/* and in network order */
-#define LLOGV(var,type,ptr) \
-do { \
- *((type *)ptr) = HTON##type(var); \
- ptr += sizeof(type); \
-} while (0)
-
-
-/*
- * set var to point at (type *)ptr, move ptr forward with sizeof(type)
- * return from function with EFAULT if ptr goes beyond end
- */
-#define UNLOGP(var,type,ptr,end) \
-do { \
- var = (type *)ptr; \
- ptr += sizeof(type); \
- if (ptr > end ) \
- return -EFAULT; \
-} while (0)
-
-#define LOGP(var,type,ptr) \
-do { \
- memcpy(ptr, var, sizeof(type)); \
- ptr += sizeof(type); \
-} while (0)
-
-/*
- * set var to point at (char *)ptr, move ptr forward by size_round(len);
- * return from function with EFAULT if ptr goes beyond end
- */
-#define UNLOGL(var,type,len,ptr,end) \
-do { \
- if (len == 0) \
- var = (type *)0; \
- else { \
- var = (type *)ptr; \
- ptr += size_round(len * sizeof(type)); \
- } \
- if (ptr > end ) \
- return -EFAULT; \
-} while (0)
-
-#define UNLOGL0(var,type,len,ptr,end) \
-do { \
- UNLOGL(var,type,len+1,ptr,end); \
- if ( *((char *)ptr - size_round(len+1) + len) != '\0') \
- return -EFAULT; \
-} while (0)
-
-#define LOGL(var,len,ptr) \
-do { \
- size_t __fill = size_round(len); \
- /* Prevent data leakage. */ \
- if (__fill > 0) \
- memset((char *)ptr, 0, __fill); \
- memcpy((char *)ptr, (const char *)var, len); \
- ptr += __fill; \
-} while (0)
-
-#define LOGL0(var,len,ptr) \
-do { \
- if (!len) break; \
- memcpy((char *)ptr, (const char *)var, len); \
- *((char *)(ptr) + len) = 0; \
- ptr += size_round(len + 1); \
-} while (0)
-
-#endif /* _INTERMEZZO_LIB_H */
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- */
-
-#ifndef __PRESTO_PSDEV_H
-#define __PRESTO_PSDEV_H
-
-#define MAX_CHANNEL 16
-#define PROCNAME_SIZE 32
-#include <linux/smp_lock.h>
-
-/* represents state of an instance reached with /dev/intermezzo */
-/* communication pending & processing queues */
-struct upc_channel {
- unsigned int uc_seq;
- wait_queue_head_t uc_waitq; /* Lento wait queue */
- struct list_head uc_pending;
- struct list_head uc_processing;
- spinlock_t uc_lock;
- int uc_pid; /* Lento's pid */
- int uc_hard; /* allows signals during upcalls */
- int uc_no_filter;
- int uc_no_journal;
- int uc_no_upcall;
- int uc_timeout; /* . sec: signals will dequeue upc */
- long uc_errorval; /* for testing I/O failures */
- struct list_head uc_cache_list;
- int uc_minor;
-};
-
-#define ISLENTO(minor) (current->pid == izo_channels[minor].uc_pid \
- || current->real_parent->pid == izo_channels[minor].uc_pid \
- || current->real_parent->real_parent->pid == izo_channels[minor].uc_pid)
-
-extern struct upc_channel izo_channels[MAX_CHANNEL];
-
-/* message types between presto filesystem in kernel */
-#define REQ_READ 1
-#define REQ_WRITE 2
-#define REQ_ASYNC 4
-#define REQ_DEAD 8
-
-struct upc_req {
- struct list_head rq_chain;
- caddr_t rq_data;
- int rq_flags;
- int rq_bufsize;
- int rq_rep_size;
- int rq_opcode; /* copied from data to save lookup */
- int rq_unique;
- wait_queue_head_t rq_sleep; /* process' wait queue */
- unsigned long rq_posttime;
-};
-
-#endif
+++ /dev/null
-/*
- * Based on cfs.h from Coda, but revamped for increased simplicity.
- * Linux modifications by Peter Braam, Aug 1996
- * Rewritten for InterMezzo
- */
-
-#ifndef _PRESTO_HEADER_
-#define _PRESTO_HEADER_
-
-
-/* upcall.c */
-#define SYNCHRONOUS 0
-#define ASYNCHRONOUS 1
-
-int lento_permit(int minor, int pathlen, int fsetnamelen, char *path, char *fset);
-int lento_opendir(int minor, int pathlen, char *path, int async);
-int lento_kml(int minor, unsigned int offset, unsigned int first_recno,
- unsigned int length, unsigned int last_recno, int namelen,
- char *fsetname);
-int lento_open(int minor, int pathlen, char *path);
-int lento_journal(int minor, char *page, int async);
-int lento_release_permit(int minor, int cookie);
-
-/*
- * Kernel <--> Lento communications.
- */
-/* upcalls */
-#define LENTO_PERMIT 1
-#define LENTO_JOURNAL 2
-#define LENTO_OPENDIR 3
-#define LENTO_OPEN 4
-#define LENTO_SIGNAL 5
-#define LENTO_KML 6
-#define LENTO_COOKIE 7
-
-/* Lento <-> Presto RPC arguments */
-struct lento_up_hdr {
- unsigned int opcode;
- unsigned int unique; /* Keep multiple outstanding msgs distinct */
- u_short pid; /* Common to all */
- u_short uid;
-};
-
-/* This structure _must_ sit at the beginning of the buffer */
-struct lento_down_hdr {
- unsigned int opcode;
- unsigned int unique;
- unsigned int result;
-};
-
-/* lento_permit: */
-struct lento_permit_in {
- struct lento_up_hdr uh;
- int pathlen;
- int fsetnamelen;
- char path[0];
-};
-struct lento_permit_out {
- struct lento_down_hdr dh;
-};
-
-
-/* lento_opendir: */
-struct lento_opendir_in {
- struct lento_up_hdr uh;
- int async;
- int pathlen;
- char path[0];
-};
-struct lento_opendir_out {
- struct lento_down_hdr dh;
-};
-
-
-/* lento_kml: */
-struct lento_kml_in {
- struct lento_up_hdr uh;
- unsigned int offset;
- unsigned int first_recno;
- unsigned int length;
- unsigned int last_recno;
- int namelen;
- char fsetname[0];
-};
-
-struct lento_kml_out {
- struct lento_down_hdr dh;
-};
-
-
-/* lento_open: */
-struct lento_open_in {
- struct lento_up_hdr uh;
- int pathlen;
- char path[0];
-};
-struct lento_open_out {
- struct lento_down_hdr dh;
-};
-
-/* lento_response_cookie */
-struct lento_response_cookie_in {
- struct lento_up_hdr uh;
- int cookie;
-};
-
-struct lento_response_cookie_out {
- struct lento_down_hdr dh;
-};
-
-
-struct lento_mknod {
- struct lento_down_hdr dh;
- int major;
- int minor;
- int mode;
- char path[0];
-};
-
-
-/* NB: every struct below begins with an up_hdr */
-union up_args {
- struct lento_up_hdr uh;
- struct lento_permit_in lento_permit;
- struct lento_open_in lento_open;
- struct lento_opendir_in lento_opendir;
- struct lento_kml_in lento_kml;
- struct lento_response_cookie_in lento_response_cookie;
-};
-
-union down_args {
- struct lento_down_hdr dh;
- struct lento_permit_out lento_permit;
- struct lento_open_out lento_open;
- struct lento_opendir_out lento_opendir;
- struct lento_kml_out lento_kml;
- struct lento_response_cookie_out lento_response_cookie;
-};
-
-#include "intermezzo_psdev.h"
-
-int lento_upcall(int minor, int read_size, int *rep_size,
- union up_args *buffer, int async,
- struct upc_req *rq );
-#endif
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam
- * Copyright (C) 2001 Cluster File Systems, Inc.
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- * Support for journalling extended attributes
- * Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-struct presto_reservation_data {
- unsigned int ri_recno;
- loff_t ri_offset;
- loff_t ri_size;
- struct list_head ri_list;
-};
-
-/*
- * Locking Semantics
- *
- * write lock in struct presto_log_fd:
- * - name: fd_lock
- * - required for: accessing any field in a presto_log_fd
- * - may not be held across I/O
- * -
- *
- */
-
-/*
- * reserve record space and/or atomically request state of the log
- * rec will hold the location reserved record upon return
- * this reservation will be placed in the queue
- */
-static void presto_reserve_record(struct presto_file_set *fset,
- struct presto_log_fd *fd,
- struct rec_info *rec,
- struct presto_reservation_data *rd)
-{
- int chunked_record = 0;
- ENTRY;
-
- write_lock(&fd->fd_lock);
- if ( rec->is_kml ) {
- int chunk = 1 << fset->fset_chunkbits;
- int chunk_mask = ~(chunk -1);
- loff_t boundary;
-
- boundary = (fd->fd_offset + chunk - 1) & chunk_mask;
- if ( fd->fd_offset + rec->size >= boundary ) {
- chunked_record = 1;
- fd->fd_offset = boundary;
- }
- }
-
- fd->fd_recno++;
-
- /* this moves the fd_offset back after truncation */
- if ( list_empty(&fd->fd_reservations) &&
- !chunked_record) {
- fd->fd_offset = fd->fd_file->f_dentry->d_inode->i_size;
- }
-
- rec->offset = fd->fd_offset;
- if (rec->is_kml)
- rec->offset += fset->fset_kml_logical_off;
-
- rec->recno = fd->fd_recno;
-
- /* add the reservation data to the end of the list */
- rd->ri_offset = fd->fd_offset;
- rd->ri_size = rec->size;
- rd->ri_recno = rec->recno;
- list_add(&rd->ri_list, fd->fd_reservations.prev);
-
- fd->fd_offset += rec->size;
-
- write_unlock(&fd->fd_lock);
-
- EXIT;
-}
-
-static inline void presto_release_record(struct presto_log_fd *fd,
- struct presto_reservation_data *rd)
-{
- write_lock(&fd->fd_lock);
- list_del(&rd->ri_list);
- write_unlock(&fd->fd_lock);
-}
-
-/* XXX should we ask for do_truncate to be exported? */
-int izo_do_truncate(struct presto_file_set *fset, struct dentry *dentry,
- loff_t length, loff_t size_check)
-{
- struct inode *inode = dentry->d_inode;
- int error;
- struct iattr newattrs;
-
- ENTRY;
-
- if (length < 0) {
- EXIT;
- return -EINVAL;
- }
-
- down(&inode->i_sem);
- lock_kernel();
-
- if (size_check != inode->i_size) {
- unlock_kernel();
- up(&inode->i_sem);
- EXIT;
- return -EALREADY;
- }
-
- newattrs.ia_size = length;
- newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-
- if (inode->i_op && inode->i_op->setattr)
- error = inode->i_op->setattr(dentry, &newattrs);
- else {
- inode_setattr(dentry->d_inode, &newattrs);
- error = 0;
- }
-
- unlock_kernel();
- up(&inode->i_sem);
- EXIT;
- return error;
-}
-
-static void presto_kml_truncate(struct presto_file_set *fset)
-{
- int rc;
- ENTRY;
-
- write_lock(&fset->fset_kml.fd_lock);
- if (fset->fset_kml.fd_truncating == 1 ) {
- write_unlock(&fset->fset_kml.fd_lock);
- EXIT;
- return;
- }
-
- fset->fset_kml.fd_truncating = 1;
- write_unlock(&fset->fset_kml.fd_lock);
-
- CERROR("islento: %d, count: %d\n",
- ISLENTO(presto_i2m(fset->fset_dentry->d_inode)),
- fset->fset_permit_count);
-
- rc = izo_upc_kml_truncate(fset->fset_cache->cache_psdev->uc_minor,
- fset->fset_lento_off, fset->fset_lento_recno,
- fset->fset_name);
-
- /* Userspace is the only permitholder now, and will retain an exclusive
- * hold on the permit until KML truncation completes. */
- /* FIXME: double check this code path now that the precise semantics of
- * fset->fset_permit_count have changed. */
-
- if (rc != 0) {
- write_lock(&fset->fset_kml.fd_lock);
- fset->fset_kml.fd_truncating = 0;
- write_unlock(&fset->fset_kml.fd_lock);
- }
-
- EXIT;
-}
-
-void *presto_trans_start(struct presto_file_set *fset, struct inode *inode,
- int op)
-{
- ENTRY;
- if ( !fset->fset_cache->cache_filter->o_trops ) {
- EXIT;
- return NULL;
- }
- EXIT;
- return fset->fset_cache->cache_filter->o_trops->tr_start
- (fset, inode, op);
-}
-
-void presto_trans_commit(struct presto_file_set *fset, void *handle)
-{
- ENTRY;
- if (!fset->fset_cache->cache_filter->o_trops ) {
- EXIT;
- return;
- }
-
- fset->fset_cache->cache_filter->o_trops->tr_commit(fset, handle);
-
- /* Check to see if the KML needs truncated. */
- if (fset->kml_truncate_size > 0 &&
- !fset->fset_kml.fd_truncating &&
- fset->fset_kml.fd_offset > fset->kml_truncate_size) {
- CDEBUG(D_JOURNAL, "kml size: %lu; truncating\n",
- (unsigned long)fset->fset_kml.fd_offset);
- presto_kml_truncate(fset);
- }
- EXIT;
-}
-
-inline int presto_no_journal(struct presto_file_set *fset)
-{
- int minor = fset->fset_cache->cache_psdev->uc_minor;
- return izo_channels[minor].uc_no_journal;
-}
-
-#define size_round(x) (((x)+3) & ~0x3)
-
-#define BUFF_FREE(buf) PRESTO_FREE(buf, PAGE_SIZE)
-#define BUFF_ALLOC(newbuf, oldbuf) \
- PRESTO_ALLOC(newbuf, PAGE_SIZE); \
- if ( !newbuf ) { \
- if (oldbuf) \
- BUFF_FREE(oldbuf); \
- return -ENOMEM; \
- }
-
-/*
- * "buflen" should be PAGE_SIZE or more.
- * Give relative path wrt to a fsetroot
- */
-char * presto_path(struct dentry *dentry, struct dentry *root,
- char *buffer, int buflen)
-{
- char * end = buffer+buflen;
- char * retval;
-
- *--end = '\0';
- buflen--;
- if (dentry->d_parent != dentry && d_unhashed(dentry)) {
- buflen -= 10;
- end -= 10;
- memcpy(end, " (deleted)", 10);
- }
-
- /* Get '/' right */
- retval = end-1;
- *retval = '/';
-
- for (;;) {
- struct dentry * parent;
- int namelen;
-
- if (dentry == root)
- break;
- parent = dentry->d_parent;
- if (dentry == parent)
- break;
- namelen = dentry->d_name.len;
- buflen -= namelen + 1;
- if (buflen < 0)
- break;
- end -= namelen;
- memcpy(end, dentry->d_name.name, namelen);
- *--end = '/';
- retval = end;
- dentry = parent;
- }
- return retval;
-}
-
-static inline char *logit(char *buf, const void *value, int size)
-{
- char *ptr = (char *)value;
-
- memcpy(buf, ptr, size);
- buf += size;
- return buf;
-}
-
-
-static inline char *
-journal_log_prefix_with_groups_and_ids(char *buf, int opcode,
- struct rec_info *rec,
- __u32 ngroups, gid_t *groups,
- __u32 fsuid, __u32 fsgid)
-{
- struct kml_prefix_hdr p;
- u32 loggroups[NGROUPS_SMALL];
-
- int i;
-
- p.len = cpu_to_le32(rec->size);
- p.version = KML_MAJOR_VERSION | KML_MINOR_VERSION;
- p.pid = cpu_to_le32(current->pid);
- p.auid = cpu_to_le32(current->uid);
- p.fsuid = cpu_to_le32(fsuid);
- p.fsgid = cpu_to_le32(fsgid);
- p.ngroups = cpu_to_le32(ngroups);
- p.opcode = cpu_to_le32(opcode);
- for (i=0 ; i < ngroups ; i++)
- loggroups[i] = cpu_to_le32((__u32) groups[i]);
-
- buf = logit(buf, &p, sizeof(struct kml_prefix_hdr));
- buf = logit(buf, &loggroups, sizeof(__u32) * ngroups);
- return buf;
-}
-
-static inline char *
-journal_log_prefix(char *buf, int opcode, struct rec_info *rec)
-{
- __u32 groups[NGROUPS_SMALL];
- int i;
-
- /* convert 16 bit gid's to 32 bit gid's */
- for (i=0; i<current->group_info->ngroups; i++)
- groups[i] = GROUP_AT(current->group_info,i);
-
- return journal_log_prefix_with_groups_and_ids(buf, opcode, rec,
- (__u32)current->group_info->ngroups,
- groups,
- (__u32)current->fsuid,
- (__u32)current->fsgid);
-}
-
-static inline char *
-journal_log_prefix_with_groups(char *buf, int opcode, struct rec_info *rec,
- __u32 ngroups, gid_t *groups)
-{
- return journal_log_prefix_with_groups_and_ids(buf, opcode, rec,
- ngroups, groups,
- (__u32)current->fsuid,
- (__u32)current->fsgid);
-}
-
-static inline char *log_dentry_version(char *buf, struct dentry *dentry)
-{
- struct presto_version version;
-
- presto_getversion(&version, dentry->d_inode);
-
- version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
- version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
- version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
- version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
- version.pv_size = HTON__u64(version.pv_size);
-
- return logit(buf, &version, sizeof(version));
-}
-
-static inline char *log_version(char *buf, struct presto_version *pv)
-{
- struct presto_version version;
-
- memcpy(&version, pv, sizeof(version));
-
- version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
- version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
- version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
- version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
- version.pv_size = HTON__u64(version.pv_size);
-
- return logit(buf, &version, sizeof(version));
-}
-
-static inline char *log_rollback(char *buf, struct izo_rollback_data *rb)
-{
- struct izo_rollback_data rollback;
-
- rollback.rb_mode = HTON__u32(rb->rb_mode);
- rollback.rb_rdev = HTON__u32(rb->rb_rdev);
- rollback.rb_uid = HTON__u64(rb->rb_uid);
- rollback.rb_gid = HTON__u64(rb->rb_gid);
-
- return logit(buf, &rollback, sizeof(rollback));
-}
-
-static inline char *journal_log_suffix(char *buf, char *log,
- struct presto_file_set *fset,
- struct dentry *dentry,
- struct rec_info *rec)
-{
- struct kml_suffix s;
- struct kml_prefix_hdr *p = (struct kml_prefix_hdr *)log;
-
-#if 0
- /* XXX needs to be done after reservation,
- disable ths until version 1.2 */
- if ( dentry ) {
- s.prevrec = cpu_to_le32(rec->offset -
- presto_d2d(dentry)->dd_kml_offset);
- presto_d2d(dentry)->dd_kml_offset = rec->offset;
- } else {
- s.prevrec = -1;
- }
-#endif
- s.prevrec = 0;
-
- /* record number needs to be filled in after reservation
- s.recno = cpu_to_le32(rec->recno); */
- s.time = cpu_to_le32(get_seconds());
- s.len = p->len;
- return logit(buf, &s, sizeof(s));
-}
-
-int izo_log_close(struct presto_log_fd *logfd)
-{
- int rc = 0;
-
- if (logfd->fd_file) {
- rc = filp_close(logfd->fd_file, 0);
- logfd->fd_file = NULL;
- } else
- CERROR("InterMezzo: %s: no filp\n", __FUNCTION__);
- if (rc != 0)
- CERROR("InterMezzo: close files: filp won't close: %d\n", rc);
-
- return rc;
-}
-
-int presto_fwrite(struct file *file, const char *str, int len, loff_t *off)
-{
- int rc;
- mm_segment_t old_fs;
- ENTRY;
-
- rc = -EINVAL;
- if ( !off ) {
- EXIT;
- return rc;
- }
-
- if ( ! file ) {
- EXIT;
- return rc;
- }
-
- if ( ! file->f_op ) {
- EXIT;
- return rc;
- }
-
- if ( ! file->f_op->write ) {
- EXIT;
- return rc;
- }
-
- old_fs = get_fs();
- set_fs(get_ds());
- rc = file->f_op->write(file, str, len, off);
- if (rc != len) {
- CERROR("presto_fwrite: wrote %d bytes instead of "
- "%d at %ld\n", rc, len, (long)*off);
- rc = -EIO;
- }
- set_fs(old_fs);
- EXIT;
- return rc;
-}
-
-int presto_fread(struct file *file, char *str, int len, loff_t *off)
-{
- int rc;
- mm_segment_t old_fs;
- ENTRY;
-
- if (len > 512)
- CERROR("presto_fread: read at %Ld for %d bytes, ino %ld\n",
- *off, len, file->f_dentry->d_inode->i_ino);
-
- rc = -EINVAL;
- if ( !off ) {
- EXIT;
- return rc;
- }
-
- if ( ! file ) {
- EXIT;
- return rc;
- }
-
- if ( ! file->f_op ) {
- EXIT;
- return rc;
- }
-
- if ( ! file->f_op->read ) {
- EXIT;
- return rc;
- }
-
- old_fs = get_fs();
- set_fs(get_ds());
- rc = file->f_op->read(file, str, len, off);
- if (rc != len) {
- CDEBUG(D_FILE, "presto_fread: read %d bytes instead of "
- "%d at %Ld\n", rc, len, *off);
- rc = -EIO;
- }
- set_fs(old_fs);
- EXIT;
- return rc;
-}
-
-loff_t presto_kml_offset(struct presto_file_set *fset)
-{
- unsigned int kml_recno;
- struct presto_log_fd *fd = &fset->fset_kml;
- loff_t offset;
- ENTRY;
-
- write_lock(&fd->fd_lock);
-
- /* Determine the largest valid offset, i.e. up until the first
- * reservation held on the file. */
- if ( !list_empty(&fd->fd_reservations) ) {
- struct presto_reservation_data *rd;
- rd = list_entry(fd->fd_reservations.next,
- struct presto_reservation_data,
- ri_list);
- offset = rd->ri_offset;
- kml_recno = rd->ri_recno;
- } else {
- offset = fd->fd_file->f_dentry->d_inode->i_size;
- kml_recno = fset->fset_kml.fd_recno;
- }
- write_unlock(&fd->fd_lock);
- return offset;
-}
-
-static int presto_kml_dispatch(struct presto_file_set *fset)
-{
- int rc = 0;
- unsigned int kml_recno;
- struct presto_log_fd *fd = &fset->fset_kml;
- loff_t offset;
- ENTRY;
-
- write_lock(&fd->fd_lock);
-
- /* Determine the largest valid offset, i.e. up until the first
- * reservation held on the file. */
- if ( !list_empty(&fd->fd_reservations) ) {
- struct presto_reservation_data *rd;
- rd = list_entry(fd->fd_reservations.next,
- struct presto_reservation_data,
- ri_list);
- offset = rd->ri_offset;
- kml_recno = rd->ri_recno;
- } else {
- offset = fd->fd_file->f_dentry->d_inode->i_size;
- kml_recno = fset->fset_kml.fd_recno;
- }
-
- if ( kml_recno < fset->fset_lento_recno ) {
- CERROR("presto_kml_dispatch: smoke is coming\n");
- write_unlock(&fd->fd_lock);
- EXIT;
- return 0;
- } else if ( kml_recno == fset->fset_lento_recno ) {
- write_unlock(&fd->fd_lock);
- EXIT;
- return 0;
- /* XXX add a further "if" here to delay the KML upcall */
-#if 0
- } else if ( kml_recno < fset->fset_lento_recno + 100) {
- write_unlock(&fd->fd_lock);
- EXIT;
- return 0;
-#endif
- }
- CDEBUG(D_PIOCTL, "fset: %s\n", fset->fset_name);
-
- rc = izo_upc_kml(fset->fset_cache->cache_psdev->uc_minor,
- fset->fset_lento_off, fset->fset_lento_recno,
- offset + fset->fset_kml_logical_off, kml_recno,
- fset->fset_name);
-
- if ( rc ) {
- write_unlock(&fd->fd_lock);
- EXIT;
- return rc;
- }
-
- fset->fset_lento_off = offset;
- fset->fset_lento_recno = kml_recno;
- write_unlock(&fd->fd_lock);
- EXIT;
- return 0;
-}
-
-int izo_lookup_file(struct presto_file_set *fset, char *path,
- struct nameidata *nd)
-{
- int error = 0;
-
- CDEBUG(D_CACHE, "looking up: %s\n", path);
-
- error = path_lookup(path, LOOKUP_PARENT, nd);
- if (error) {
- EXIT;
- return error;
- }
-
- return 0;
-}
-
-/* FIXME: this function is a mess of locking and error handling. There's got to
- * be a better way. */
-static int do_truncate_rename(struct presto_file_set *fset, char *oldname,
- char *newname)
-{
- struct dentry *old_dentry, *new_dentry;
- struct nameidata oldnd, newnd;
- char *oldpath, *newpath;
- int error;
-
- ENTRY;
-
- oldpath = izo_make_path(fset, oldname);
- if (oldpath == NULL) {
- EXIT;
- return -ENOENT;
- }
-
- newpath = izo_make_path(fset, newname);
- if (newpath == NULL) {
- error = -ENOENT;
- EXIT;
- goto exit;
- }
-
- if ((error = izo_lookup_file(fset, oldpath, &oldnd)) != 0) {
- EXIT;
- goto exit1;
- }
-
- if ((error = izo_lookup_file(fset, newpath, &newnd)) != 0) {
- EXIT;
- goto exit2;
- }
-
- lock_rename(newnd.dentry, oldnd.dentry);
- old_dentry = lookup_hash(&oldnd.last, oldnd.dentry);
- error = PTR_ERR(old_dentry);
- if (IS_ERR(old_dentry)) {
- EXIT;
- goto exit3;
- }
- error = -ENOENT;
- if (!old_dentry->d_inode) {
- EXIT;
- goto exit4;
- }
- new_dentry = lookup_hash(&newnd.last, newnd.dentry);
- error = PTR_ERR(new_dentry);
- if (IS_ERR(new_dentry)) {
- EXIT;
- goto exit4;
- }
-
- {
- extern int presto_rename(struct inode *old_dir,struct dentry *old_dentry,
- struct inode *new_dir,struct dentry *new_dentry);
- error = presto_rename(old_dentry->d_parent->d_inode, old_dentry,
- new_dentry->d_parent->d_inode, new_dentry);
- }
-
- dput(new_dentry);
- EXIT;
- exit4:
- dput(old_dentry);
- exit3:
- unlock_rename(newnd.dentry, oldnd.dentry);
- path_release(&newnd);
- exit2:
- path_release(&oldnd);
- exit1:
- PRESTO_FREE(newpath, strlen(newpath) + 1);
- exit:
- PRESTO_FREE(oldpath, strlen(oldpath) + 1);
- return error;
-}
-
-/* This function is called with the fset->fset_kml.fd_lock held */
-int presto_finish_kml_truncate(struct presto_file_set *fset,
- unsigned long int offset)
-{
- struct lento_vfs_context info;
- void *handle;
- struct file *f;
- struct dentry *dentry;
- int error = 0, len;
- struct nameidata nd;
- char *kmlpath = NULL, *smlpath = NULL;
- ENTRY;
-
- if (offset == 0) {
- /* Lento couldn't do what it needed to; abort the truncation. */
- fset->fset_kml.fd_truncating = 0;
- EXIT;
- return 0;
- }
-
- /* someone is about to write to the end of the KML; try again later. */
- if ( !list_empty(&fset->fset_kml.fd_reservations) ) {
- EXIT;
- return -EAGAIN;
- }
-
- f = presto_copy_kml_tail(fset, offset);
- if (IS_ERR(f)) {
- EXIT;
- return PTR_ERR(f);
- }
-
- /* In a single transaction:
- *
- * - unlink 'kml'
- * - rename 'kml_tmp' to 'kml'
- * - unlink 'sml'
- * - rename 'sml_tmp' to 'sml'
- * - rewrite the first record of last_rcvd with the new kml
- * offset.
- */
- handle = presto_trans_start(fset, fset->fset_dentry->d_inode,
- KML_OPCODE_KML_TRUNC);
- if (IS_ERR(handle)) {
- presto_release_space(fset->fset_cache, PRESTO_REQLOW);
- CERROR("ERROR: presto_finish_kml_truncate: no space for transaction\n");
- EXIT;
- return -ENOMEM;
- }
-
- memset(&info, 0, sizeof(info));
- info.flags = LENTO_FL_IGNORE_TIME;
-
- kmlpath = izo_make_path(fset, "kml");
- if (kmlpath == NULL) {
- error = -ENOMEM;
- CERROR("make_path failed: ENOMEM\n");
- EXIT;
- goto exit_commit;
- }
-
- if ((error = izo_lookup_file(fset, kmlpath, &nd)) != 0) {
- CERROR("izo_lookup_file(kml) failed: %d.\n", error);
- EXIT;
- goto exit_commit;
- }
- down(&nd.dentry->d_inode->i_sem);
- dentry = lookup_hash(&nd.last, nd.dentry);
- error = PTR_ERR(dentry);
- if (IS_ERR(dentry)) {
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
- CERROR("lookup_hash failed\n");
- EXIT;
- goto exit_commit;
- }
- error = presto_do_unlink(fset, dentry->d_parent, dentry, &info);
- dput(dentry);
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
-
- if (error != 0) {
- CERROR("presto_do_unlink(kml) failed: %d.\n", error);
- EXIT;
- goto exit_commit;
- }
-
- smlpath = izo_make_path(fset, "sml");
- if (smlpath == NULL) {
- error = -ENOMEM;
- CERROR("make_path() failed: ENOMEM\n");
- EXIT;
- goto exit_commit;
- }
-
- if ((error = izo_lookup_file(fset, smlpath, &nd)) != 0) {
- CERROR("izo_lookup_file(sml) failed: %d.\n", error);
- EXIT;
- goto exit_commit;
- }
- down(&nd.dentry->d_inode->i_sem);
- dentry = lookup_hash(&nd.last, nd.dentry);
- error = PTR_ERR(dentry);
- if (IS_ERR(dentry)) {
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
- CERROR("lookup_hash failed\n");
- EXIT;
- goto exit_commit;
- }
- error = presto_do_unlink(fset, dentry->d_parent, dentry, &info);
- dput(dentry);
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
-
- if (error != 0) {
- CERROR("presto_do_unlink(sml) failed: %d.\n", error);
- EXIT;
- goto exit_commit;
- }
-
- error = do_truncate_rename(fset, "kml_tmp", "kml");
- if (error != 0)
- CERROR("do_truncate_rename(kml_tmp, kml) failed: %d\n", error);
- error = do_truncate_rename(fset, "sml_tmp", "sml");
- if (error != 0)
- CERROR("do_truncate_rename(sml_tmp, sml) failed: %d\n", error);
-
- /* Write a new 'last_rcvd' record with the new KML offset */
- fset->fset_kml_logical_off += offset;
- CDEBUG(D_CACHE, "new kml_logical_offset: %Lu\n",
- fset->fset_kml_logical_off);
- if (presto_write_kml_logical_offset(fset) != 0) {
- CERROR("presto_write_kml_logical_offset failed\n");
- }
-
- presto_trans_commit(fset, handle);
-
- /* Everything was successful, so swap the KML file descriptors */
- filp_close(fset->fset_kml.fd_file, NULL);
- fset->fset_kml.fd_file = f;
- fset->fset_kml.fd_offset -= offset;
- fset->fset_kml.fd_truncating = 0;
-
- EXIT;
- return 0;
-
- exit_commit:
- presto_trans_commit(fset, handle);
- len = strlen("/.intermezzo/") + strlen(fset->fset_name) +strlen("sml");
- if (kmlpath != NULL)
- PRESTO_FREE(kmlpath, len);
- if (smlpath != NULL)
- PRESTO_FREE(smlpath, len);
- return error;
-}
-
-/* structure of an extended log record:
-
- buf-prefix buf-body [string1 [string2 [string3]]] buf-suffix
-
- note: moves offset forward
-*/
-static inline int presto_write_record(struct file *f, loff_t *off,
- const char *buf, size_t size,
- const char *string1, int len1,
- const char *string2, int len2,
- const char *string3, int len3)
-{
- size_t prefix_size;
- int rc;
-
- prefix_size = size - sizeof(struct kml_suffix);
- rc = presto_fwrite(f, buf, prefix_size, off);
- if ( rc != prefix_size ) {
- CERROR("Write error!\n");
- EXIT;
- return -EIO;
- }
-
- if ( string1 && len1 ) {
- rc = presto_fwrite(f, string1, len1, off);
- if ( rc != len1 ) {
- CERROR("Write error!\n");
- EXIT;
- return -EIO;
- }
- }
-
- if ( string2 && len2 ) {
- rc = presto_fwrite(f, string2, len2, off);
- if ( rc != len2 ) {
- CERROR("Write error!\n");
- EXIT;
- return -EIO;
- }
- }
-
- if ( string3 && len3 ) {
- rc = presto_fwrite(f, string3, len3, off);
- if ( rc != len3 ) {
- CERROR("Write error!\n");
- EXIT;
- return -EIO;
- }
- }
-
- rc = presto_fwrite(f, buf + prefix_size,
- sizeof(struct kml_suffix), off);
- if ( rc != sizeof(struct kml_suffix) ) {
- CERROR("Write error!\n");
- EXIT;
- return -EIO;
- }
- return 0;
-}
-
-
-/*
- * rec->size must be valid prior to calling this function.
- *
- * had to export this for branch_reinter in kml_reint.c
- */
-int presto_log(struct presto_file_set *fset, struct rec_info *rec,
- const char *buf, size_t size,
- const char *string1, int len1,
- const char *string2, int len2,
- const char *string3, int len3)
-{
- int rc;
- struct presto_reservation_data rd;
- loff_t offset;
- struct presto_log_fd *fd;
- struct kml_suffix *s;
- int prefix_size;
-
- ENTRY;
-
- /* buf is NULL when no_journal is in effect */
- if (!buf) {
- EXIT;
- return -EINVAL;
- }
-
- if (rec->is_kml) {
- fd = &fset->fset_kml;
- } else {
- fd = &fset->fset_lml;
- }
-
- presto_reserve_record(fset, fd, rec, &rd);
-
- if (rec->is_kml) {
- if (rec->offset < fset->fset_kml_logical_off) {
- CERROR("record with pre-trunc offset. tell phil.\n");
- BUG();
- }
- offset = rec->offset - fset->fset_kml_logical_off;
- } else {
- offset = rec->offset;
- }
-
- /* now we know the record number */
- prefix_size = size - sizeof(struct kml_suffix);
- s = (struct kml_suffix *) (buf + prefix_size);
- s->recno = cpu_to_le32(rec->recno);
-
- rc = presto_write_record(fd->fd_file, &offset, buf, size,
- string1, len1, string2, len2, string3, len3);
- if (rc) {
- CERROR("presto: error writing record to %s\n",
- rec->is_kml ? "KML" : "LML");
- return rc;
- }
- presto_release_record(fd, &rd);
-
- rc = presto_kml_dispatch(fset);
-
- EXIT;
- return rc;
-}
-
-/* read from the record at tail */
-static int presto_last_record(struct presto_log_fd *fd, loff_t *size,
- loff_t *tail_offset, __u32 *recno, loff_t tail)
-{
- struct kml_suffix suffix;
- int rc;
- loff_t zeroes;
-
- *recno = 0;
- *tail_offset = 0;
- *size = 0;
-
- if (tail < sizeof(struct kml_prefix_hdr) + sizeof(suffix)) {
- EXIT;
- return 0;
- }
-
- zeroes = tail - sizeof(int);
- while ( zeroes >= 0 ) {
- int data;
- rc = presto_fread(fd->fd_file, (char *)&data, sizeof(data),
- &zeroes);
- if ( rc != sizeof(data) ) {
- rc = -EIO;
- return rc;
- }
- if (data)
- break;
- zeroes -= 2 * sizeof(data);
- }
-
- /* zeroes at the begining of file. this is needed to prevent
- presto_fread errors -SHP
- */
- if (zeroes <= 0) return 0;
-
- zeroes -= sizeof(suffix) + sizeof(int);
- rc = presto_fread(fd->fd_file, (char *)&suffix, sizeof(suffix), &zeroes);
- if ( rc != sizeof(suffix) ) {
- EXIT;
- return rc;
- }
- if ( suffix.len > 500 ) {
- CERROR("InterMezzo: Warning long record tail at %ld, rec tail_offset at %ld (size %d)\n",
- (long) zeroes, (long)*tail_offset, suffix.len);
- }
-
- *recno = suffix.recno;
- *size = suffix.len;
- *tail_offset = zeroes;
- return 0;
-}
-
-static int izo_kml_last_recno(struct presto_log_fd *logfd)
-{
- int rc;
- loff_t size;
- loff_t tail_offset;
- int recno;
- loff_t tail = logfd->fd_file->f_dentry->d_inode->i_size;
-
- rc = presto_last_record(logfd, &size, &tail_offset, &recno, tail);
- if (rc != 0) {
- EXIT;
- return rc;
- }
-
- logfd->fd_offset = tail_offset;
- logfd->fd_recno = recno;
- CDEBUG(D_JOURNAL, "setting fset_kml->fd_recno to %d, offset %Ld\n",
- recno, tail_offset);
- EXIT;
- return 0;
-}
-
-struct file *izo_log_open(struct presto_file_set *fset, char *name, int flags)
-{
- struct presto_cache *cache = fset->fset_cache;
- struct file *f;
- int error;
- ENTRY;
-
- f = izo_fset_open(fset, name, flags, 0644);
- error = PTR_ERR(f);
- if (IS_ERR(f)) {
- EXIT;
- return f;
- }
-
- error = -EINVAL;
- if ( cache != presto_get_cache(f->f_dentry->d_inode) ) {
- CERROR("InterMezzo: %s cache does not match fset cache!\n",name);
- fset->fset_kml.fd_file = NULL;
- filp_close(f, NULL);
- f = NULL;
- EXIT;
- return f;
- }
-
- if (cache->cache_filter && cache->cache_filter->o_trops &&
- cache->cache_filter->o_trops->tr_journal_data) {
- cache->cache_filter->o_trops->tr_journal_data
- (f->f_dentry->d_inode);
- } else {
- CERROR("InterMezzo WARNING: no file data logging!\n");
- }
-
- EXIT;
-
- return f;
-}
-
-int izo_init_kml_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
- int error = 0;
- struct file *f;
-
- ENTRY;
- if (logfd->fd_file) {
- CDEBUG(D_INODE, "fset already has KML open\n");
- EXIT;
- return 0;
- }
-
- logfd->fd_lock = RW_LOCK_UNLOCKED;
- INIT_LIST_HEAD(&logfd->fd_reservations);
- f = izo_log_open(fset, "kml", O_RDWR | O_CREAT);
- if (IS_ERR(f)) {
- error = PTR_ERR(f);
- return error;
- }
-
- logfd->fd_file = f;
- error = izo_kml_last_recno(logfd);
-
- if (error) {
- logfd->fd_file = NULL;
- filp_close(f, NULL);
- CERROR("InterMezzo: IO error in KML of fset %s\n",
- fset->fset_name);
- EXIT;
- return error;
- }
- fset->fset_lento_off = logfd->fd_offset;
- fset->fset_lento_recno = logfd->fd_recno;
-
- EXIT;
- return error;
-}
-
-int izo_init_last_rcvd_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
- int error = 0;
- struct file *f;
- struct rec_info recinfo;
-
- ENTRY;
- if (logfd->fd_file != NULL) {
- CDEBUG(D_INODE, "fset already has last_rcvd open\n");
- EXIT;
- return 0;
- }
-
- logfd->fd_lock = RW_LOCK_UNLOCKED;
- INIT_LIST_HEAD(&logfd->fd_reservations);
- f = izo_log_open(fset, "last_rcvd", O_RDWR | O_CREAT);
- if (IS_ERR(f)) {
- error = PTR_ERR(f);
- return error;
- }
-
- logfd->fd_file = f;
- logfd->fd_offset = f->f_dentry->d_inode->i_size;
-
- error = izo_rep_cache_init(fset);
-
- if (presto_read_kml_logical_offset(&recinfo, fset) == 0) {
- fset->fset_kml_logical_off = recinfo.offset;
- } else {
- /* The 'last_rcvd' file doesn't contain a kml offset record,
- * probably because we just created 'last_rcvd'. Write one. */
- fset->fset_kml_logical_off = 0;
- presto_write_kml_logical_offset(fset);
- }
-
- EXIT;
- return error;
-}
-
-int izo_init_lml_file(struct presto_file_set *fset, struct presto_log_fd *logfd)
-{
- int error = 0;
- struct file *f;
-
- ENTRY;
- if (logfd->fd_file) {
- CDEBUG(D_INODE, "fset already has lml open\n");
- EXIT;
- return 0;
- }
-
- logfd->fd_lock = RW_LOCK_UNLOCKED;
- INIT_LIST_HEAD(&logfd->fd_reservations);
- f = izo_log_open(fset, "lml", O_RDWR | O_CREAT);
- if (IS_ERR(f)) {
- error = PTR_ERR(f);
- return error;
- }
-
- logfd->fd_file = f;
- logfd->fd_offset = f->f_dentry->d_inode->i_size;
-
- EXIT;
- return error;
-}
-
-/* Get the KML-offset record from the last_rcvd file */
-int presto_read_kml_logical_offset(struct rec_info *recinfo,
- struct presto_file_set *fset)
-{
- loff_t off;
- struct izo_rcvd_rec rec;
- char uuid[16] = {0};
-
- off = izo_rcvd_get(&rec, fset, uuid);
- if (off < 0)
- return -1;
-
- recinfo->offset = rec.lr_local_offset;
- return 0;
-}
-
-int presto_write_kml_logical_offset(struct presto_file_set *fset)
-{
- loff_t rc;
- struct izo_rcvd_rec rec;
- char uuid[16] = {0};
-
- rc = izo_rcvd_get(&rec, fset, uuid);
- if (rc < 0)
- memset(&rec, 0, sizeof(rec));
-
- rec.lr_local_offset =
- cpu_to_le64(fset->fset_kml_logical_off);
-
- return izo_rcvd_write(fset, &rec);
-}
-
-struct file * presto_copy_kml_tail(struct presto_file_set *fset,
- unsigned long int start)
-{
- struct file *f;
- int len;
- loff_t read_off, write_off, bytes;
-
- ENTRY;
-
- /* Copy the tail of 'kml' to 'kml_tmp' */
- f = izo_log_open(fset, "kml_tmp", O_RDWR);
- if (IS_ERR(f)) {
- EXIT;
- return f;
- }
-
- write_off = 0;
- read_off = start;
- bytes = fset->fset_kml.fd_offset - start;
- while (bytes > 0) {
- char buf[4096];
- int toread;
-
- if (bytes > sizeof(buf))
- toread = sizeof(buf);
- else
- toread = bytes;
-
- len = presto_fread(fset->fset_kml.fd_file, buf, toread,
- &read_off);
- if (len <= 0)
- break;
-
- if (presto_fwrite(f, buf, len, &write_off) != len) {
- filp_close(f, NULL);
- EXIT;
- return ERR_PTR(-EIO);
- }
-
- bytes -= len;
- }
-
- EXIT;
- return f;
-}
-
-
-/* LML records here */
-/* this writes an LML record to the LML file (rec->is_kml =0) */
-int presto_write_lml_close(struct rec_info *rec,
- struct presto_file_set *fset,
- struct file *file,
- __u64 remote_ino,
- __u64 remote_generation,
- struct presto_version *remote_version,
- struct presto_version *new_file_ver)
-{
- int opcode = KML_OPCODE_CLOSE;
- char *buffer;
- struct dentry *dentry = file->f_dentry;
- __u64 ino;
- __u32 pathlen;
- char *path;
- __u32 generation;
- int size;
- char *logrecord;
- char record[292];
- struct dentry *root;
- int error;
-
- ENTRY;
-
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
- root = fset->fset_dentry;
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- CDEBUG(D_INODE, "Path: %s\n", path);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- ino = cpu_to_le64(dentry->d_inode->i_ino);
- generation = cpu_to_le32(dentry->d_inode->i_generation);
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + sizeof(*new_file_ver) +
- sizeof(ino) + sizeof(generation) + sizeof(pathlen) +
- sizeof(remote_ino) + sizeof(remote_generation) +
- sizeof(remote_version) + sizeof(rec->offset) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 0;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, new_file_ver);
- logrecord = logit(logrecord, &ino, sizeof(ino));
- logrecord = logit(logrecord, &generation, sizeof(generation));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, &remote_ino, sizeof(remote_ino));
- logrecord = logit(logrecord, &remote_generation,
- sizeof(remote_generation));
- logrecord = log_version(logrecord, remote_version);
- logrecord = logit(logrecord, &rec->offset, sizeof(rec->offset));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- BUFF_FREE(buffer);
-
- EXIT;
- return error;
-}
-
-/*
- * Check if the given record is at the end of the file. If it is, truncate
- * the lml to the record's offset, removing it. Repeat on prior record,
- * until we reach an active record or a reserved record (as defined by the
- * reservations list).
- */
-static int presto_truncate_lml_tail(struct presto_file_set *fset)
-{
- loff_t lml_tail;
- loff_t lml_last_rec;
- loff_t lml_last_recsize;
- loff_t local_offset;
- int recno;
- struct kml_prefix_hdr prefix;
- struct inode *inode = fset->fset_lml.fd_file->f_dentry->d_inode;
- void *handle;
- int rc;
-
- ENTRY;
- /* If someone else is already truncating the LML, return. */
- write_lock(&fset->fset_lml.fd_lock);
- if (fset->fset_lml.fd_truncating == 1 ) {
- write_unlock(&fset->fset_lml.fd_lock);
- EXIT;
- return 0;
- }
- /* someone is about to write to the end of the LML */
- if ( !list_empty(&fset->fset_lml.fd_reservations) ) {
- write_unlock(&fset->fset_lml.fd_lock);
- EXIT;
- return 0;
- }
- lml_tail = fset->fset_lml.fd_file->f_dentry->d_inode->i_size;
- /* Nothing to truncate?*/
- if (lml_tail == 0) {
- write_unlock(&fset->fset_lml.fd_lock);
- EXIT;
- return 0;
- }
- fset->fset_lml.fd_truncating = 1;
- write_unlock(&fset->fset_lml.fd_lock);
-
- presto_last_record(&fset->fset_lml, &lml_last_recsize,
- &lml_last_rec, &recno, lml_tail);
- /* Do we have a record to check? If not we have zeroes at the
- beginning of the file. -SHP
- */
- if (lml_last_recsize != 0) {
- local_offset = lml_last_rec - lml_last_recsize;
- rc = presto_fread(fset->fset_lml.fd_file, (char *)&prefix,
- sizeof(prefix), &local_offset);
- if (rc != sizeof(prefix)) {
- EXIT;
- goto tr_out;
- }
-
- if ( prefix.opcode != KML_OPCODE_NOOP ) {
- EXIT;
- rc = 0;
- /* We may have zeroes at the end of the file, should
- we clear them out? -SHP
- */
- goto tr_out;
- }
- } else
- lml_last_rec=0;
-
- handle = presto_trans_start(fset, inode, KML_OPCODE_TRUNC);
- if ( IS_ERR(handle) ) {
- EXIT;
- rc = -ENOMEM;
- goto tr_out;
- }
-
- rc = izo_do_truncate(fset, fset->fset_lml.fd_file->f_dentry,
- lml_last_rec - lml_last_recsize, lml_tail);
- presto_trans_commit(fset, handle);
- if ( rc == 0 ) {
- rc = 1;
- }
- EXIT;
-
- tr_out:
- CDEBUG(D_JOURNAL, "rc = %d\n", rc);
- write_lock(&fset->fset_lml.fd_lock);
- fset->fset_lml.fd_truncating = 0;
- write_unlock(&fset->fset_lml.fd_lock);
- return rc;
-}
-
-int presto_truncate_lml(struct presto_file_set *fset)
-{
- int rc;
- ENTRY;
-
- while ( (rc = presto_truncate_lml_tail(fset)) > 0);
- if ( rc < 0 && rc != -EALREADY) {
- CERROR("truncate_lml error %d\n", rc);
- }
- EXIT;
- return rc;
-}
-
-int presto_clear_lml_close(struct presto_file_set *fset, loff_t lml_offset)
-{
- int rc;
- struct kml_prefix_hdr record;
- loff_t offset = lml_offset;
-
- ENTRY;
-
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- CDEBUG(D_JOURNAL, "reading prefix: off %ld, size %Zd\n",
- (long)lml_offset, sizeof(record));
- rc = presto_fread(fset->fset_lml.fd_file, (char *)&record,
- sizeof(record), &offset);
-
- if ( rc != sizeof(record) ) {
- CERROR("presto: clear_lml io error %d\n", rc);
- EXIT;
- return -EIO;
- }
-
- /* overwrite the prefix */
- CDEBUG(D_JOURNAL, "overwriting prefix: off %ld\n", (long)lml_offset);
- record.opcode = KML_OPCODE_NOOP;
- offset = lml_offset;
- /* note: this does just a single transaction in the cache */
- rc = presto_fwrite(fset->fset_lml.fd_file, (char *)(&record),
- sizeof(record), &offset);
- if ( rc != sizeof(record) ) {
- EXIT;
- return -EIO;
- }
-
- EXIT;
- return 0;
-}
-
-
-
-/* now a journal function for every operation */
-
-int presto_journal_setattr(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry, struct presto_version *old_ver,
- struct izo_rollback_data *rb, struct iattr *iattr)
-{
- int opcode = KML_OPCODE_SETATTR;
- char *buffer, *path, *logrecord, record[316];
- struct dentry *root;
- __u32 uid, gid, mode, valid, flags, pathlen;
- __u64 fsize, mtime, ctime;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0)
- || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + sizeof(*old_ver) +
- sizeof(valid) + sizeof(mode) + sizeof(uid) + sizeof(gid) +
- sizeof(fsize) + sizeof(mtime) + sizeof(ctime) + sizeof(flags) +
- sizeof(pathlen) + sizeof(*rb) + sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- /* Only journal one kind of mtime, and not atime at all. Also don't
- * journal bogus data in iattr, to make the journal more compressible.
- */
- if (iattr->ia_valid & ATTR_MTIME_SET)
- iattr->ia_valid = iattr->ia_valid | ATTR_MTIME;
- valid = cpu_to_le32(iattr->ia_valid & ~(ATTR_ATIME | ATTR_MTIME_SET |
- ATTR_ATIME_SET));
- mode = iattr->ia_valid & ATTR_MODE ? cpu_to_le32(iattr->ia_mode): 0;
- uid = iattr->ia_valid & ATTR_UID ? cpu_to_le32(iattr->ia_uid): 0;
- gid = iattr->ia_valid & ATTR_GID ? cpu_to_le32(iattr->ia_gid): 0;
- fsize = iattr->ia_valid & ATTR_SIZE ? cpu_to_le64(iattr->ia_size): 0;
- mtime = iattr->ia_valid & ATTR_MTIME ? cpu_to_le64(iattr->ia_mtime.tv_sec): 0;
- ctime = iattr->ia_valid & ATTR_CTIME ? cpu_to_le64(iattr->ia_ctime.tv_sec): 0;
- flags = iattr->ia_valid & ATTR_ATTR_FLAG ?
- cpu_to_le32(iattr->ia_attr_flags): 0;
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, old_ver);
- logrecord = logit(logrecord, &valid, sizeof(valid));
- logrecord = logit(logrecord, &mode, sizeof(mode));
- logrecord = logit(logrecord, &uid, sizeof(uid));
- logrecord = logit(logrecord, &gid, sizeof(gid));
- logrecord = logit(logrecord, &fsize, sizeof(fsize));
- logrecord = logit(logrecord, &mtime, sizeof(mtime));
- logrecord = logit(logrecord, &ctime, sizeof(ctime));
- logrecord = logit(logrecord, &flags, sizeof(flags));
- logrecord = log_rollback(logrecord, rb);
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int presto_get_fileid(int minor, struct presto_file_set *fset,
- struct dentry *dentry)
-{
- int opcode = KML_OPCODE_GET_FILEID;
- struct rec_info rec;
- char *buffer, *path, *logrecord, record[4096]; /*include path*/
- struct dentry *root;
- __u32 uid, gid, pathlen;
- int error, size;
- struct kml_suffix *suffix;
-
- ENTRY;
-
- root = fset->fset_dentry;
-
- uid = cpu_to_le32(dentry->d_inode->i_uid);
- gid = cpu_to_le32(dentry->d_inode->i_gid);
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + sizeof(pathlen) +
- size_round(le32_to_cpu(pathlen)) +
- sizeof(struct kml_suffix);
-
- CDEBUG(D_FILE, "kml size: %d\n", size);
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- memset(&rec, 0, sizeof(rec));
- rec.is_kml = 1;
- rec.size = size;
-
- logrecord = journal_log_prefix(record, opcode, &rec);
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, path, size_round(le32_to_cpu(pathlen)));
- suffix = (struct kml_suffix *)logrecord;
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, &rec);
- /* journal_log_suffix expects journal_log to set this */
- suffix->recno = 0;
-
- CDEBUG(D_FILE, "actual kml size: %Zd\n", logrecord - record);
- CDEBUG(D_FILE, "get fileid: uid %d, gid %d, path: %s\n", uid, gid,path);
-
- error = izo_upc_get_fileid(minor, size, record,
- size_round(le32_to_cpu(pathlen)), path,
- fset->fset_name);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int presto_journal_create(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_file_ver, int mode)
-{
- int opcode = KML_OPCODE_CREATE;
- char *buffer, *path, *logrecord, record[292];
- struct dentry *root;
- __u32 uid, gid, lmode, pathlen;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- uid = cpu_to_le32(dentry->d_inode->i_uid);
- gid = cpu_to_le32(dentry->d_inode->i_gid);
- lmode = cpu_to_le32(mode);
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dentry->d_parent);
- logrecord = log_version(logrecord, new_file_ver);
- logrecord = logit(logrecord, &lmode, sizeof(lmode));
- logrecord = logit(logrecord, &uid, sizeof(uid));
- logrecord = logit(logrecord, &gid, sizeof(gid));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int presto_journal_symlink(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry, const char *target,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_link_ver)
-{
- int opcode = KML_OPCODE_SYMLINK;
- char *buffer, *path, *logrecord, record[292];
- struct dentry *root;
- __u32 uid, gid, pathlen;
- __u32 targetlen = cpu_to_le32(strlen(target));
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- uid = cpu_to_le32(dentry->d_inode->i_uid);
- gid = cpu_to_le32(dentry->d_inode->i_gid);
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
- sizeof(targetlen) + sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen)) +
- size_round(le32_to_cpu(targetlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dentry->d_parent);
- logrecord = log_version(logrecord, new_link_ver);
- logrecord = logit(logrecord, &uid, sizeof(uid));
- logrecord = logit(logrecord, &gid, sizeof(gid));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, &targetlen, sizeof(targetlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- target, size_round(le32_to_cpu(targetlen)),
- NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int presto_journal_mkdir(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_dir_ver, int mode)
-{
- int opcode = KML_OPCODE_MKDIR;
- char *buffer, *path, *logrecord, record[292];
- struct dentry *root;
- __u32 uid, gid, lmode, pathlen;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- uid = cpu_to_le32(dentry->d_inode->i_uid);
- gid = cpu_to_le32(dentry->d_inode->i_gid);
- lmode = cpu_to_le32(mode);
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
- logrecord = journal_log_prefix(record, opcode, rec);
-
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dentry->d_parent);
- logrecord = log_version(logrecord, new_dir_ver);
- logrecord = logit(logrecord, &lmode, sizeof(lmode));
- logrecord = logit(logrecord, &uid, sizeof(uid));
- logrecord = logit(logrecord, &gid, sizeof(gid));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-
-int
-presto_journal_rmdir(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dir, struct presto_version *tgt_dir_ver,
- struct presto_version *old_dir_ver,
- struct izo_rollback_data *rb, int len, const char *name)
-{
- int opcode = KML_OPCODE_RMDIR;
- char *buffer, *path, *logrecord, record[316];
- __u32 pathlen, llen;
- struct dentry *root;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- llen = cpu_to_le32(len);
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dir, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(pathlen) + sizeof(llen) + sizeof(*rb) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- CDEBUG(D_JOURNAL, "path: %s (%d), name: %s (%d), size %d\n",
- path, pathlen, name, len, size);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen)) +
- size_round(len);
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dir);
- logrecord = log_version(logrecord, old_dir_ver);
- logrecord = logit(logrecord, rb, sizeof(*rb));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, &llen, sizeof(llen));
- logrecord = journal_log_suffix(logrecord, record, fset, dir, rec);
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- name, size_round(len),
- NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-
-int
-presto_journal_mknod(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dentry, struct presto_version *tgt_dir_ver,
- struct presto_version *new_node_ver, int mode,
- int dmajor, int dminor )
-{
- int opcode = KML_OPCODE_MKNOD;
- char *buffer, *path, *logrecord, record[292];
- struct dentry *root;
- __u32 uid, gid, lmode, lmajor, lminor, pathlen;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- uid = cpu_to_le32(dentry->d_inode->i_uid);
- gid = cpu_to_le32(dentry->d_inode->i_gid);
- lmode = cpu_to_le32(mode);
- lmajor = cpu_to_le32(dmajor);
- lminor = cpu_to_le32(dminor);
-
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(lmode) + sizeof(uid) + sizeof(gid) + sizeof(lmajor) +
- sizeof(lminor) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dentry->d_parent);
- logrecord = log_version(logrecord, new_node_ver);
- logrecord = logit(logrecord, &lmode, sizeof(lmode));
- logrecord = logit(logrecord, &uid, sizeof(uid));
- logrecord = logit(logrecord, &gid, sizeof(gid));
- logrecord = logit(logrecord, &lmajor, sizeof(lmajor));
- logrecord = logit(logrecord, &lminor, sizeof(lminor));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int
-presto_journal_link(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *src, struct dentry *tgt,
- struct presto_version *tgt_dir_ver,
- struct presto_version *new_link_ver)
-{
- int opcode = KML_OPCODE_LINK;
- char *buffer, *srcbuffer, *path, *srcpath, *logrecord, record[292];
- __u32 pathlen, srcpathlen;
- struct dentry *root;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- BUFF_ALLOC(srcbuffer, NULL);
- srcpath = presto_path(src, root, srcbuffer, PAGE_SIZE);
- srcpathlen = cpu_to_le32(MYPATHLEN(srcbuffer, srcpath));
-
- BUFF_ALLOC(buffer, srcbuffer);
- path = presto_path(tgt, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(srcpathlen) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen)) +
- size_round(le32_to_cpu(srcpathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, tgt->d_parent);
- logrecord = log_version(logrecord, new_link_ver);
- logrecord = logit(logrecord, &srcpathlen, sizeof(srcpathlen));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, tgt, rec);
-
- error = presto_log(fset, rec, record, size,
- srcpath, size_round(le32_to_cpu(srcpathlen)),
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0);
-
- BUFF_FREE(srcbuffer);
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-
-int presto_journal_rename(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *src, struct dentry *tgt,
- struct presto_version *src_dir_ver,
- struct presto_version *tgt_dir_ver)
-{
- int opcode = KML_OPCODE_RENAME;
- char *buffer, *srcbuffer, *path, *srcpath, *logrecord, record[292];
- __u32 pathlen, srcpathlen;
- struct dentry *root;
- int error, size;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- BUFF_ALLOC(srcbuffer, NULL);
- srcpath = presto_path(src, root, srcbuffer, PAGE_SIZE);
- srcpathlen = cpu_to_le32(MYPATHLEN(srcbuffer, srcpath));
-
- BUFF_ALLOC(buffer, srcbuffer);
- path = presto_path(tgt, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 4 * sizeof(*src_dir_ver) +
- sizeof(srcpathlen) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen)) +
- size_round(le32_to_cpu(srcpathlen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, src_dir_ver);
- logrecord = log_dentry_version(logrecord, src->d_parent);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, tgt->d_parent);
- logrecord = logit(logrecord, &srcpathlen, sizeof(srcpathlen));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, tgt, rec);
-
- error = presto_log(fset, rec, record, size,
- srcpath, size_round(le32_to_cpu(srcpathlen)),
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0);
-
- BUFF_FREE(buffer);
- BUFF_FREE(srcbuffer);
- EXIT;
- return error;
-}
-
-int presto_journal_unlink(struct rec_info *rec, struct presto_file_set *fset,
- struct dentry *dir, struct presto_version *tgt_dir_ver,
- struct presto_version *old_file_ver,
- struct izo_rollback_data *rb, struct dentry *dentry,
- char *old_target, int old_targetlen)
-{
- int opcode = KML_OPCODE_UNLINK;
- char *buffer, *path, *logrecord, record[316];
- const char *name;
- __u32 pathlen, llen;
- struct dentry *root;
- int error, size, len;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- name = dentry->d_name.name;
- len = dentry->d_name.len;
-
- llen = cpu_to_le32(len);
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dir, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) + 3 * sizeof(*tgt_dir_ver) +
- sizeof(pathlen) + sizeof(llen) + sizeof(*rb) +
- sizeof(old_targetlen) + sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen)) + size_round(len) +
- size_round(old_targetlen);
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, tgt_dir_ver);
- logrecord = log_dentry_version(logrecord, dir);
- logrecord = log_version(logrecord, old_file_ver);
- logrecord = log_rollback(logrecord, rb);
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, &llen, sizeof(llen));
- logrecord = logit(logrecord, &old_targetlen, sizeof(old_targetlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dir, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- name, size_round(len),
- old_target, size_round(old_targetlen));
-
- BUFF_FREE(buffer);
- EXIT;
- return error;
-}
-
-int
-presto_journal_close(struct rec_info *rec, struct presto_file_set *fset,
- struct presto_file_data *fd, struct dentry *dentry,
- struct presto_version *old_file_ver,
- struct presto_version *new_file_ver)
-{
- int opcode = KML_OPCODE_CLOSE;
- char *buffer, *path, *logrecord, record[316];
- struct dentry *root;
- int error, size, i;
- __u32 pathlen, generation;
- __u64 ino;
- __u32 open_fsuid;
- __u32 open_fsgid;
- __u32 open_ngroups;
- __u32 open_groups[NGROUPS_SMALL];
- __u32 open_mode;
- __u32 open_uid;
- __u32 open_gid;
-
- ENTRY;
-
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0)
- || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- if (fd) {
- open_ngroups = fd->fd_ngroups;
- for (i = 0; i < fd->fd_ngroups; i++)
- open_groups[i] = (__u32) fd->fd_groups[i];
- open_mode = fd->fd_mode;
- open_uid = fd->fd_uid;
- open_gid = fd->fd_gid;
- open_fsuid = fd->fd_fsuid;
- open_fsgid = fd->fd_fsgid;
- } else {
- open_ngroups = current->group_info->ngroups;
- for (i=0; i<current->group_info->ngroups; i++)
- open_groups[i] = (__u32) GROUP_AT(current->group_info,i);
- open_mode = dentry->d_inode->i_mode;
- open_uid = dentry->d_inode->i_uid;
- open_gid = dentry->d_inode->i_gid;
- open_fsuid = current->fsuid;
- open_fsgid = current->fsgid;
- }
- BUFF_ALLOC(buffer, NULL);
- path = presto_path(dentry, root, buffer, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(buffer, path));
- ino = cpu_to_le64(dentry->d_inode->i_ino);
- generation = cpu_to_le32(dentry->d_inode->i_generation);
- size = sizeof(__u32) * open_ngroups +
- sizeof(open_mode) + sizeof(open_uid) + sizeof(open_gid) +
- sizeof(struct kml_prefix_hdr) + sizeof(*old_file_ver) +
- sizeof(*new_file_ver) + sizeof(ino) + sizeof(generation) +
- sizeof(pathlen) + sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix_with_groups_and_ids(
- record, opcode, rec, open_ngroups, open_groups,
- open_fsuid, open_fsgid);
- logrecord = logit(logrecord, &open_mode, sizeof(open_mode));
- logrecord = logit(logrecord, &open_uid, sizeof(open_uid));
- logrecord = logit(logrecord, &open_gid, sizeof(open_gid));
- logrecord = log_version(logrecord, old_file_ver);
- logrecord = log_version(logrecord, new_file_ver);
- logrecord = logit(logrecord, &ino, sizeof(ino));
- logrecord = logit(logrecord, &generation, sizeof(generation));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
- BUFF_FREE(buffer);
-
- EXIT;
- return error;
-}
-
-int presto_rewrite_close(struct rec_info *rec, struct presto_file_set *fset,
- char *path, __u32 pathlen,
- int ngroups, __u32 *groups,
- __u64 ino, __u32 generation,
- struct presto_version *new_file_ver)
-{
- int opcode = KML_OPCODE_CLOSE;
- char *logrecord, record[292];
- struct dentry *root;
- int error, size;
-
- ENTRY;
-
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- size = sizeof(__u32) * ngroups +
- sizeof(struct kml_prefix_hdr) + sizeof(*new_file_ver) +
- sizeof(ino) + sizeof(generation) +
- sizeof(le32_to_cpu(pathlen)) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- rec->size = size + size_round(le32_to_cpu(pathlen));
-
- logrecord = journal_log_prefix_with_groups(record, opcode, rec,
- ngroups, groups);
- logrecord = log_version(logrecord, new_file_ver);
- logrecord = logit(logrecord, &ino, sizeof(ino));
- logrecord = logit(logrecord, &generation, sizeof(generation));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = journal_log_suffix(logrecord, record, fset, NULL, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- NULL, 0, NULL, 0);
-
- EXIT;
- return error;
-}
-
-
-/* write closes for the local close records in the LML */
-int presto_complete_lml(struct presto_file_set *fset)
-{
- __u32 groups[NGROUPS_SMALL];
- loff_t lml_offset;
- loff_t read_offset;
- char *buffer;
- void *handle;
- struct rec_info rec;
- struct close_rec {
- struct presto_version new_file_ver;
- __u64 ino;
- __u32 generation;
- __u32 pathlen;
- __u64 remote_ino;
- __u32 remote_generation;
- __u32 remote_version;
- __u64 lml_offset;
- } close_rec;
- struct file *file = fset->fset_lml.fd_file;
- struct kml_prefix_hdr prefix;
- int rc = 0;
- ENTRY;
-
- lml_offset = 0;
- again:
- if (lml_offset >= file->f_dentry->d_inode->i_size) {
- EXIT;
- return rc;
- }
-
- read_offset = lml_offset;
- rc = presto_fread(file, (char *)&prefix,
- sizeof(prefix), &read_offset);
- if ( rc != sizeof(prefix) ) {
- EXIT;
- CERROR("presto_complete_lml: ioerror - 1, tell Peter\n");
- return -EIO;
- }
-
- if ( prefix.opcode == KML_OPCODE_NOOP ) {
- lml_offset += prefix.len;
- goto again;
- }
-
- rc = presto_fread(file, (char *)groups,
- prefix.ngroups * sizeof(__u32), &read_offset);
- if ( rc != prefix.ngroups * sizeof(__u32) ) {
- EXIT;
- CERROR("presto_complete_lml: ioerror - 2, tell Peter\n");
- return -EIO;
- }
-
- rc = presto_fread(file, (char *)&close_rec,
- sizeof(close_rec), &read_offset);
- if ( rc != sizeof(close_rec) ) {
- EXIT;
- CERROR("presto_complete_lml: ioerror - 3, tell Peter\n");
- return -EIO;
- }
-
- /* is this a backfetch or a close record? */
- if ( le64_to_cpu(close_rec.remote_ino) != 0 ) {
- lml_offset += prefix.len;
- goto again;
- }
-
- BUFF_ALLOC(buffer, NULL);
- rc = presto_fread(file, (char *)buffer,
- le32_to_cpu(close_rec.pathlen), &read_offset);
- if ( rc != le32_to_cpu(close_rec.pathlen) ) {
- EXIT;
- CERROR("presto_complete_lml: ioerror - 4, tell Peter\n");
- return -EIO;
- }
-
- handle = presto_trans_start(fset, file->f_dentry->d_inode,
- KML_OPCODE_RELEASE);
- if ( IS_ERR(handle) ) {
- EXIT;
- return -ENOMEM;
- }
-
- rc = presto_clear_lml_close(fset, lml_offset);
- if ( rc ) {
- CERROR("error during clearing: %d\n", rc);
- presto_trans_commit(fset, handle);
- EXIT;
- return rc;
- }
-
- rc = presto_rewrite_close(&rec, fset, buffer, close_rec.pathlen,
- prefix.ngroups, groups,
- close_rec.ino, close_rec.generation,
- &close_rec.new_file_ver);
- if ( rc ) {
- CERROR("error during rewrite close: %d\n", rc);
- presto_trans_commit(fset, handle);
- EXIT;
- return rc;
- }
-
- presto_trans_commit(fset, handle);
- if ( rc ) {
- CERROR("error during truncation: %d\n", rc);
- EXIT;
- return rc;
- }
-
- lml_offset += prefix.len;
- CDEBUG(D_JOURNAL, "next LML record at: %ld\n", (long)lml_offset);
- goto again;
-
- EXIT;
- return -EINVAL;
-}
-
-
-#ifdef CONFIG_FS_EXT_ATTR
-/* Journal an ea operation. A NULL buffer implies the attribute is
- * getting deleted. In this case we simply change the opcode, but nothing
- * else is affected.
- */
-int presto_journal_set_ext_attr (struct rec_info *rec,
- struct presto_file_set *fset,
- struct dentry *dentry,
- struct presto_version *ver, const char *name,
- const char *buffer, int buffer_len,
- int flags)
-{
- int opcode = (buffer == NULL) ?
- KML_OPCODE_DELEXTATTR :
- KML_OPCODE_SETEXTATTR ;
- char *temp, *path, *logrecord, record[292];
- struct dentry *root;
- int error, size;
- __u32 namelen=cpu_to_le32(strnlen(name,PRESTO_EXT_ATTR_NAME_MAX));
- __u32 buflen=(buffer != NULL)? cpu_to_le32(buffer_len): cpu_to_le32(0);
- __u32 mode, pathlen;
-
- ENTRY;
- if ( presto_no_journal(fset) ) {
- EXIT;
- return 0;
- }
-
- if (!dentry->d_inode || (dentry->d_inode->i_nlink == 0)
- || ((dentry->d_parent != dentry) && d_unhashed(dentry))) {
- EXIT;
- return 0;
- }
-
- root = fset->fset_dentry;
-
- BUFF_ALLOC(temp, NULL);
- path = presto_path(dentry, root, temp, PAGE_SIZE);
- pathlen = cpu_to_le32(MYPATHLEN(temp, path));
-
- flags=cpu_to_le32(flags);
- /* Ugly, but needed. posix ACLs change the mode without using
- * setattr, we need to record these changes. The EA code per se
- * is not really affected.
- */
- mode=cpu_to_le32(dentry->d_inode->i_mode);
-
- size = sizeof(__u32) * current->group_info->ngroups +
- sizeof(struct kml_prefix_hdr) +
- 2 * sizeof(struct presto_version) +
- sizeof(flags) + sizeof(mode) + sizeof(namelen) +
- sizeof(buflen) + sizeof(pathlen) +
- sizeof(struct kml_suffix);
-
- if ( size > sizeof(record) )
- CERROR("InterMezzo: BUFFER OVERFLOW in %s!\n", __FUNCTION__);
-
- rec->is_kml = 1;
- /* Make space for a path, a attr name and value*/
- /* We use the buflen instead of buffer_len to make sure that we
- * journal the right length. This may be a little paranoid, but
- * with 64 bits round the corner, I would rather be safe than sorry!
- * Also this handles deletes with non-zero buffer_lengths correctly.
- * SHP
- */
- rec->size = size + size_round(le32_to_cpu(pathlen)) +
- size_round(le32_to_cpu(namelen)) +
- size_round(le32_to_cpu(buflen));
-
- logrecord = journal_log_prefix(record, opcode, rec);
- logrecord = log_version(logrecord, ver);
- logrecord = log_dentry_version(logrecord, dentry);
- logrecord = logit(logrecord, &flags, sizeof(flags));
- logrecord = logit(logrecord, &mode, sizeof(flags));
- logrecord = logit(logrecord, &pathlen, sizeof(pathlen));
- logrecord = logit(logrecord, &namelen, sizeof(namelen));
- logrecord = logit(logrecord, &buflen, sizeof(buflen));
- logrecord = journal_log_suffix(logrecord, record, fset, dentry, rec);
-
- error = presto_log(fset, rec, record, size,
- path, size_round(le32_to_cpu(pathlen)),
- name, size_round(le32_to_cpu(namelen)),
- buffer, size_round(le32_to_cpu(buflen)));
-
- BUFF_FREE(temp);
- EXIT;
- return error;
-}
-#endif
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#include <linux/ext2_fs.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_EXT2_FS)
-
-/* EXT2 has no journalling, so these functions do nothing */
-static loff_t presto_e2_freespace(struct presto_cache *cache,
- struct super_block *sb)
-{
- unsigned long freebl = le32_to_cpu(EXT2_SB(sb)->s_es->s_free_blocks_count);
- unsigned long avail = freebl - le32_to_cpu(EXT2_SB(sb)->s_es->s_r_blocks_count);
- return (avail << EXT2_BLOCK_SIZE_BITS(sb));
-}
-
-/* start the filesystem journal operations */
-static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op)
-{
- __u32 avail_kmlblocks;
-
- if ( presto_no_journal(fset) ||
- strcmp(fset->fset_cache->cache_type, "ext2"))
- return NULL;
-
- avail_kmlblocks = EXT2_SB(inode->i_sb)->s_es->s_free_blocks_count;
-
- if ( avail_kmlblocks < 3 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- if ( (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
- && avail_kmlblocks < 6 ) {
- return ERR_PTR(-ENOSPC);
- }
- return (void *) 1;
-}
-
-static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle)
-{
- do {} while (0);
-}
-
-static int presto_e2_has_all_data(struct inode *inode)
-{
- BUG();
- return 0;
-}
-
-struct journal_ops presto_ext2_journal_ops = {
- .tr_all_data = presto_e2_has_all_data,
- .tr_avail = presto_e2_freespace,
- .tr_start = presto_e2_trans_start,
- .tr_commit = presto_e2_trans_commit,
- .tr_journal_data = NULL
-};
-
-#endif /* CONFIG_EXT2_FS */
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2001 Mountain View Data, Inc.
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
-#include <linux/jbd.h>
-#include <linux/ext3_fs.h>
-#include <linux/ext3_jbd.h>
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
-
-#define MAX_PATH_BLOCKS(inode) (PATH_MAX >> EXT3_BLOCK_SIZE_BITS((inode)->i_sb))
-#define MAX_NAME_BLOCKS(inode) (NAME_MAX >> EXT3_BLOCK_SIZE_BITS((inode)->i_sb))
-
-/* space requirements:
- presto_do_truncate:
- used to truncate the KML forward to next fset->chunksize boundary
- - zero partial block
- - update inode
- presto_write_record:
- write header (< one block)
- write one path (< MAX_PATHLEN)
- possibly write another path (< MAX_PATHLEN)
- write suffix (< one block)
- presto_update_last_rcvd
- write one block
-*/
-
-static loff_t presto_e3_freespace(struct presto_cache *cache,
- struct super_block *sb)
-{
- loff_t freebl = le32_to_cpu(EXT3_SB(sb)->s_es->s_free_blocks_count);
- loff_t avail = freebl -
- le32_to_cpu(EXT3_SB(sb)->s_es->s_r_blocks_count);
- return (avail << EXT3_BLOCK_SIZE_BITS(sb));
-}
-
-/* start the filesystem journal operations */
-static void *presto_e3_trans_start(struct presto_file_set *fset,
- struct inode *inode,
- int op)
-{
- int jblocks;
- int trunc_blks, one_path_blks, extra_path_blks,
- extra_name_blks, lml_blks;
- __u32 avail_kmlblocks;
- handle_t *handle;
-
- if ( presto_no_journal(fset) ||
- strcmp(fset->fset_cache->cache_type, "ext3"))
- {
- CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
- fset->fset_cache->cache_type);
- return NULL;
- }
-
- avail_kmlblocks = EXT3_SB(inode->i_sb)->s_es->s_free_blocks_count;
-
- if ( avail_kmlblocks < 3 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- if ( (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
- && avail_kmlblocks < 6 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- /* Need journal space for:
- at least three writes to KML (two one block writes, one a path)
- possibly a second name (unlink, rmdir)
- possibly a second path (symlink, rename)
- a one block write to the last rcvd file
- */
-
- trunc_blks = EXT3_DATA_TRANS_BLOCKS + 1;
- one_path_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 3;
- lml_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 2;
- extra_path_blks = EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode);
- extra_name_blks = EXT3_DATA_TRANS_BLOCKS + MAX_NAME_BLOCKS(inode);
-
- /* additional blocks appear for "two pathname" operations
- and operations involving the LML records
- */
- switch (op) {
- case KML_OPCODE_TRUNC:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS;
- break;
- case KML_OPCODE_KML_TRUNC:
- /* Hopefully this is a little better, but I'm still mostly
- * guessing here. */
- /* unlink 1 */
- jblocks = extra_name_blks + trunc_blks +
- EXT3_DELETE_TRANS_BLOCKS + 2;
-
- /* unlink 2 */
- jblocks += extra_name_blks + trunc_blks +
- EXT3_DELETE_TRANS_BLOCKS + 2;
-
- /* rename 1 */
- jblocks += 2 * extra_path_blks + trunc_blks +
- 2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
-
- /* rename 2 */
- jblocks += 2 * extra_path_blks + trunc_blks +
- 2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
- break;
- case KML_OPCODE_RELEASE:
- /*
- jblocks = one_path_blks + lml_blks + 2*trunc_blks;
- */
- jblocks = one_path_blks;
- break;
- case KML_OPCODE_SETATTR:
- jblocks = one_path_blks + trunc_blks + 1 ;
- break;
- case KML_OPCODE_CREATE:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 3 + 2;
- break;
- case KML_OPCODE_LINK:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 2;
- break;
- case KML_OPCODE_UNLINK:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS + 2;
- break;
- case KML_OPCODE_SYMLINK:
- jblocks = one_path_blks + extra_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 5;
- break;
- case KML_OPCODE_MKDIR:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 4 + 2;
- break;
- case KML_OPCODE_RMDIR:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS + 1;
- break;
- case KML_OPCODE_MKNOD:
- jblocks = one_path_blks + trunc_blks +
- EXT3_DATA_TRANS_BLOCKS + 3 + 2;
- break;
- case KML_OPCODE_RENAME:
- jblocks = one_path_blks + extra_path_blks + trunc_blks +
- 2 * EXT3_DATA_TRANS_BLOCKS + 2 + 3;
- break;
- case KML_OPCODE_WRITE:
- jblocks = one_path_blks;
- /* add this when we can wrap our transaction with
- that of ext3_file_write (ordered writes)
- + EXT3_DATA_TRANS_BLOCKS;
- */
- break;
- default:
- CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
- return NULL;
- }
-
- CDEBUG(D_JOURNAL, "creating journal handle (%d blocks) for op %d\n",
- jblocks, op);
- /* journal_start/stop does not do its own locking while updating
- * the handle/transaction information. Hence we create our own
- * critical section to protect these calls. -SHP
- */
- lock_kernel();
- handle = journal_start(EXT3_JOURNAL(inode), jblocks);
- unlock_kernel();
- return handle;
-}
-
-static void presto_e3_trans_commit(struct presto_file_set *fset, void *handle)
-{
- if ( presto_no_journal(fset) || !handle)
- return;
-
- /* See comments before journal_start above. -SHP */
- lock_kernel();
- journal_stop(handle);
- unlock_kernel();
-}
-
-static void presto_e3_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
- EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-/* The logic here is a slightly modified version of ext3/inode.c:block_to_path
- */
-static int presto_e3_has_all_data(struct inode *inode)
-{
- int ptrs = EXT3_ADDR_PER_BLOCK(inode->i_sb);
- int ptrs_bits = EXT3_ADDR_PER_BLOCK_BITS(inode->i_sb);
- const long direct_blocks = EXT3_NDIR_BLOCKS,
- indirect_blocks = ptrs,
- double_blocks = (1 << (ptrs_bits * 2));
- long block = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
- inode->i_sb->s_blocksize_bits;
-
- ENTRY;
-
- if (inode->i_size == 0) {
- EXIT;
- return 1;
- }
-
- if (block < direct_blocks) {
- /* No indirect blocks, no problem. */
- } else if (block < indirect_blocks + direct_blocks) {
- block++;
- } else if (block < double_blocks + indirect_blocks + direct_blocks) {
- block += 2;
- } else if (((block - double_blocks - indirect_blocks - direct_blocks)
- >> (ptrs_bits * 2)) < ptrs) {
- block += 3;
- }
-
- block *= (inode->i_sb->s_blocksize / 512);
-
- CDEBUG(D_CACHE, "Need %ld blocks, have %ld.\n", block, inode->i_blocks);
-
- if (block > inode->i_blocks) {
- EXIT;
- return 0;
- }
-
- EXIT;
- return 1;
-}
-
-struct journal_ops presto_ext3_journal_ops = {
- .tr_all_data = presto_e3_has_all_data,
- .tr_avail = presto_e3_freespace,
- .tr_start = presto_e3_trans_start,
- .tr_commit = presto_e3_trans_commit,
- .tr_journal_data = presto_e3_journal_file_data,
- .tr_ilookup = presto_iget_ilookup
-};
-
-#endif /* CONFIG_EXT3_FS */
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2001 Mountain View Data, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#ifdef CONFIG_OBDFS_FS
-#include /usr/src/obd/include/linux/obdfs.h
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_OBDFS_FS
-
-
-static unsigned long presto_obdfs_freespace(struct presto_file_set *fset,
- struct super_block *sb)
-{
- return 0x0fffff;
-}
-
-/* start the filesystem journal operations */
-static void *presto_obdfs_trans_start(struct presto_file_set *fset,
- struct inode *inode,
- int op)
-{
-
- return (void *) 1;
-}
-
-#if 0
- int jblocks;
- int trunc_blks, one_path_blks, extra_path_blks,
- extra_name_blks, lml_blks;
- __u32 avail_kmlblocks;
-
- if ( presto_no_journal(fset) ||
- strcmp(fset->fset_cache->cache_type, "ext3"))
- {
- CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
- fset->fset_cache->cache_type);
- return NULL;
- }
-
- avail_kmlblocks = inode->i_sb->u.ext3_sb.s_es->s_free_blocks_count;
-
- if ( avail_kmlblocks < 3 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- if ( (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
- && avail_kmlblocks < 6 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- /* Need journal space for:
- at least three writes to KML (two one block writes, one a path)
- possibly a second name (unlink, rmdir)
- possibly a second path (symlink, rename)
- a one block write to the last rcvd file
- */
-
- trunc_blks = EXT3_DATA_TRANS_BLOCKS + 1;
- one_path_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 3;
- lml_blks = 4*EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode) + 2;
- extra_path_blks = EXT3_DATA_TRANS_BLOCKS + MAX_PATH_BLOCKS(inode);
- extra_name_blks = EXT3_DATA_TRANS_BLOCKS + MAX_NAME_BLOCKS(inode);
-
- /* additional blocks appear for "two pathname" operations
- and operations involving the LML records
- */
- switch (op) {
- case PRESTO_OP_TRUNC:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS;
- break;
- case PRESTO_OP_RELEASE:
- /*
- jblocks = one_path_blks + lml_blks + 2*trunc_blks;
- */
- jblocks = one_path_blks;
- break;
- case PRESTO_OP_SETATTR:
- jblocks = one_path_blks + trunc_blks + 1 ;
- break;
- case PRESTO_OP_CREATE:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 3;
- break;
- case PRESTO_OP_LINK:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS;
- break;
- case PRESTO_OP_UNLINK:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS;
- break;
- case PRESTO_OP_SYMLINK:
- jblocks = one_path_blks + extra_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 5;
- break;
- case PRESTO_OP_MKDIR:
- jblocks = one_path_blks + trunc_blks
- + EXT3_DATA_TRANS_BLOCKS + 4;
- break;
- case PRESTO_OP_RMDIR:
- jblocks = one_path_blks + extra_name_blks + trunc_blks
- + EXT3_DELETE_TRANS_BLOCKS;
- break;
- case PRESTO_OP_MKNOD:
- jblocks = one_path_blks + trunc_blks +
- EXT3_DATA_TRANS_BLOCKS + 3;
- break;
- case PRESTO_OP_RENAME:
- jblocks = one_path_blks + extra_path_blks + trunc_blks +
- 2 * EXT3_DATA_TRANS_BLOCKS + 2;
- break;
- case PRESTO_OP_WRITE:
- jblocks = one_path_blks;
- /* add this when we can wrap our transaction with
- that of ext3_file_write (ordered writes)
- + EXT3_DATA_TRANS_BLOCKS;
- */
- break;
- default:
- CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
- return NULL;
- }
-
- CDEBUG(D_JOURNAL, "creating journal handle (%d blocks)\n", jblocks);
- return journal_start(EXT3_JOURNAL(inode), jblocks);
-}
-#endif
-
-void presto_obdfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
-#if 0
- if ( presto_no_journal(fset) || !handle)
- return;
-
- journal_stop(handle);
-#endif
-}
-
-void presto_obdfs_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
- inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-struct journal_ops presto_obdfs_journal_ops = {
- .tr_avail = presto_obdfs_freespace,
- .tr_start = presto_obdfs_trans_start,
- .tr_commit = presto_obdfs_trans_commit,
- .tr_journal_data = presto_obdfs_journal_file_data
-};
-
-#endif
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2001 Mountain View Data, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if 0
-#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
-#include <linux/reiserfs_fs.h>
-#include <linux/reiserfs_fs_sb.h>
-#include <linux/reiserfs_fs_i.h>
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
-
-
-static loff_t presto_reiserfs_freespace(struct presto_cache *cache,
- struct super_block *sb)
-{
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (sb);
- loff_t avail;
-
- avail = le32_to_cpu(rs->s_free_blocks) *
- le16_to_cpu(rs->s_blocksize);
- return avail;
-}
-
-/* start the filesystem journal operations */
-static void *presto_reiserfs_trans_start(struct presto_file_set *fset,
- struct inode *inode,
- int op)
-{
- int jblocks;
- __u32 avail_kmlblocks;
- struct reiserfs_transaction_handle *th ;
-
- PRESTO_ALLOC(th, sizeof(*th));
- if (!th) {
- CERROR("presto: No memory for trans handle\n");
- return NULL;
- }
-
- avail_kmlblocks = presto_reiserfs_freespace(fset->fset_cache,
- inode->i_sb);
- if ( presto_no_journal(fset) ||
- strcmp(fset->fset_cache->cache_type, "reiserfs"))
- {
- CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
- fset->fset_cache->cache_type);
- return NULL;
- }
-
- if ( avail_kmlblocks < 3 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- if ( (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
- && avail_kmlblocks < 6 ) {
- return ERR_PTR(-ENOSPC);
- }
-
- jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
- CDEBUG(D_JOURNAL, "creating journal handle (%d blocks)\n", jblocks);
-
- lock_kernel();
- journal_begin(th, inode->i_sb, jblocks);
- unlock_kernel();
- return th;
-}
-
-static void presto_reiserfs_trans_commit(struct presto_file_set *fset,
- void *handle)
-{
- int jblocks;
- jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
-
- lock_kernel();
- journal_end(handle, fset->fset_cache->cache_sb, jblocks);
- unlock_kernel();
- PRESTO_FREE(handle, sizeof(struct reiserfs_transaction_handle));
-}
-
-static void presto_reiserfs_journal_file_data(struct inode *inode)
-{
-#ifdef EXT3_JOURNAL_DATA_FL
- inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
-#else
-#warning You must have a facility to enable journaled writes for recovery!
-#endif
-}
-
-static int presto_reiserfs_has_all_data(struct inode *inode)
-{
- BUG();
- return 0;
-}
-
-struct journal_ops presto_reiserfs_journal_ops = {
- .tr_all_data = presto_reiserfs_has_all_data,
- .tr_avail = presto_reiserfs_freespace,
- .tr_start = presto_reiserfs_trans_start,
- .tr_commit = presto_reiserfs_trans_commit,
- .tr_journal_data = presto_reiserfs_journal_file_data
-};
-
-#endif
-#endif
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Los Alamos National Laboratory
- * Copyright (C) 2000 TurboLinux, Inc.
- * Copyright (C) 2001 Mountain View Data, Inc.
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/param.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if defined(CONFIG_TMPFS)
-#include <linux/jbd.h>
-#if defined(CONFIG_EXT3)
-#include <linux/ext3_fs.h>
-#include <linux/ext3_jbd.h>
-#endif
-#endif
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#if defined(CONFIG_TMPFS)
-
-/* space requirements:
- presto_do_truncate:
- used to truncate the KML forward to next fset->chunksize boundary
- - zero partial block
- - update inode
- presto_write_record:
- write header (< one block)
- write one path (< MAX_PATHLEN)
- possibly write another path (< MAX_PATHLEN)
- write suffix (< one block)
- presto_update_last_rcvd
- write one block
-*/
-
-static loff_t presto_tmpfs_freespace(struct presto_cache *cache,
- struct super_block *sb)
-{
- return (1<<30);
-}
-
-/* start the filesystem journal operations */
-static void *presto_tmpfs_trans_start(struct presto_file_set *fset,
- struct inode *inode,
- int op)
-{
- return (void *)1;
-}
-
-static void presto_tmpfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
- return;
-}
-
-static void presto_tmpfs_journal_file_data(struct inode *inode)
-{
- return;
-}
-
-/* The logic here is a slightly modified version of ext3/inode.c:block_to_path
- */
-static int presto_tmpfs_has_all_data(struct inode *inode)
-{
- return 0;
-}
-
-struct journal_ops presto_tmpfs_journal_ops = {
- .tr_all_data = presto_tmpfs_has_all_data,
- .tr_avail = presto_tmpfs_freespace,
- .tr_start = presto_tmpfs_trans_start,
- .tr_commit = presto_tmpfs_trans_commit,
- .tr_journal_data = presto_tmpfs_journal_file_data,
- .tr_ilookup = presto_tmpfs_ilookup,
- .tr_add_ilookup = presto_add_ilookup_dentry
-};
-
-#endif /* CONFIG_EXT3_FS */
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-#if 0
-/* XFS Support not there yet */
-#ifdef CONFIG_FS_XFS
-#include <linux/xfs_fs.h>
-#endif
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_journal.h"
-
-#if 0
-
-/* XFS has journalling, but these functions do nothing yet... */
-
-static unsigned long presto_xfs_freespace(struct presto_file_set *fset,
- struct super_block *sb)
-{
-
-#if 0
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- struct statvfs_t stat;
- bhv_desc_t *bdp;
- unsigned long avail;
- int rc;
-
- VFS_STATVFS(vfsp, &stat, NULL, rc);
- avail = statp.f_bfree;
-
- return sbp->sb_fdblocks;
-#endif
- return 0x0fffffff;
-}
-
-
-/* start the filesystem journal operations */
-static void *
-presto_xfs_trans_start(struct presto_file_set *fset,
- struct inode *inode, int op)
-{
- int xfs_op;
- /* do a free blocks check as in journal_ext3? does anything protect
- * the space in that case or can it disappear out from under us
- * anyway? */
-
-/* copied from xfs_trans.h, skipping header maze for now */
-#define XFS_TRANS_SETATTR_NOT_SIZE 1
-#define XFS_TRANS_SETATTR_SIZE 2
-#define XFS_TRANS_INACTIVE 3
-#define XFS_TRANS_CREATE 4
-#define XFS_TRANS_CREATE_TRUNC 5
-#define XFS_TRANS_TRUNCATE_FILE 6
-#define XFS_TRANS_REMOVE 7
-#define XFS_TRANS_LINK 8
-#define XFS_TRANS_RENAME 9
-#define XFS_TRANS_MKDIR 10
-#define XFS_TRANS_RMDIR 11
-#define XFS_TRANS_SYMLINK 12
-
- /* map the op onto the values for XFS so it can do reservation. if
- * we don't have enough info to differentiate between e.g. setattr
- * with or without size, what do we do? will it adjust? */
- switch (op) {
- case PRESTO_OP_SETATTR:
- /* or XFS_TRANS_SETATTR_NOT_SIZE? */
- xfs_op = XFS_TRANS_SETATTR_SIZE;
- break;
- case PRESTO_OP_CREATE:
- /* or CREATE_TRUNC? */
- xfs_op = XFS_TRANS_CREATE;
- break;
- case PRESTO_OP_LINK:
- xfs_op = XFS_TRANS_LINK;
- break;
- case PRESTO_OP_UNLINK:
- xfs_op = XFS_TRANS_REMOVE;
- break;
- case PRESTO_OP_SYMLINK:
- xfs_op = XFS_TRANS_SYMLINK;
- break;
- case PRESTO_OP_MKDIR:
- xfs_op = XFS_TRANS_MKDIR;
- break;
- case PRESTO_OP_RMDIR:
- xfs_op = XFS_TRANS_RMDIR;
- break;
- case PRESTO_OP_MKNOD:
- /* XXX can't find an analog for mknod? */
- xfs_op = XFS_TRANS_CREATE;
- break;
- case PRESTO_OP_RENAME:
- xfs_op = XFS_TRANS_RENAME;
- break;
- default:
- CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
- return NULL;
- }
-
- return xfs_trans_start(inode, xfs_op);
-}
-
-static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle)
-{
- /* assert (handle == current->j_handle) */
- xfs_trans_stop(handle);
-}
-
-static void presto_xfs_journal_file_data(struct inode *inode)
-{
- return;
-}
-
-static int presto_xfs_has_all_data(struct inode *inode)
-{
- BUG();
- return 0;
-}
-
-struct journal_ops presto_xfs_journal_ops = {
- .tr_all_data = presto_xfs_has_all_data,
- .tr_avail = presto_xfs_freespace,
- .tr_start = presto_xfs_trans_start,
- .tr_commit = presto_xfs_trans_commit,
- .tr_journal_data = presto_xfs_journal_file_data
-};
-
-#endif
-
-
-#endif /* CONFIG_XFS_FS */
-
+++ /dev/null
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_upcall.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_kml.h"
-
-static struct presto_file_set * kml_getfset (char *path)
-{
- return presto_path2fileset(path);
-}
-
-/* Send the KML buffer and related volume info into kernel */
-int begin_kml_reint (struct file *file, unsigned long arg)
-{
- struct {
- char *volname;
- int namelen;
- char *recbuf;
- int reclen; /* int newpos; */
- } input;
- struct kml_fsdata *kml_fsdata = NULL;
- struct presto_file_set *fset = NULL;
- char *path;
- int error;
-
- ENTRY;
- /* allocate buffer & copy it to kernel space */
- if (copy_from_user(&input, (char *)arg, sizeof(input))) {
- EXIT;
- return -EFAULT;
- }
-
- if (input.reclen > kml_fsdata->kml_maxsize)
- return -ENOMEM; /* we'll find solution to this in the future */
-
- PRESTO_ALLOC(path, char *, input.namelen + 1);
- if ( !path ) {
- EXIT;
- return -ENOMEM;
- }
- if (copy_from_user(path, input.volname, input.namelen)) {
- PRESTO_FREE(path, input.namelen + 1);
- EXIT;
- return -EFAULT;
- }
- path[input.namelen] = '\0';
- fset = kml_getfset (path);
- PRESTO_FREE(path, input.namelen + 1);
-
- kml_fsdata = FSET_GET_KMLDATA(fset);
- /* read the buf from user memory here */
- if (copy_from_user(kml_fsdata->kml_buf, input.recbuf, input.reclen)) {
- EXIT;
- return -EFAULT;
- }
- kml_fsdata->kml_len = input.reclen;
-
- decode_kmlrec (&kml_fsdata->kml_reint_cache,
- kml_fsdata->kml_buf, kml_fsdata->kml_len);
-
- kml_fsdata->kml_reint_current = kml_fsdata->kml_reint_cache.next;
- kml_fsdata->kml_reintpos = 0;
- kml_fsdata->kml_count = 0;
- return 0;
-}
-
-/* DO_KML_REINT */
-int do_kml_reint (struct file *file, unsigned long arg)
-{
- struct {
- char *volname;
- int namelen;
- char *path;
- int pathlen;
- int recno;
- int offset;
- int len;
- int generation;
- __u64 ino;
- } input;
- int error;
- char *path;
- struct kml_rec *close_rec;
- struct kml_fsdata *kml_fsdata;
- struct presto_file_set *fset;
-
- ENTRY;
- if (copy_from_user(&input, (char *)arg, sizeof(input))) {
- EXIT;
- return -EFAULT;
- }
- PRESTO_ALLOC(path, char *, input.namelen + 1);
- if ( !path ) {
- EXIT;
- return -ENOMEM;
- }
- if (copy_from_user(path, input.volname, input.namelen)) {
- PRESTO_FREE(path, input.namelen + 1);
- EXIT;
- return -EFAULT;
- }
- path[input.namelen] = '\0';
- fset = kml_getfset (path);
- PRESTO_FREE(path, input.namelen + 1);
-
- kml_fsdata = FSET_GET_KMLDATA(fset);
-
- error = kml_reintbuf(kml_fsdata,
- fset->fset_mtpt->d_name.name,
- &close_rec);
-
- if (error == KML_CLOSE_BACKFETCH && close_rec != NULL) {
- struct kml_close *close = &close_rec->rec_kml.close;
- input.ino = close->ino;
- input.generation = close->generation;
- if (strlen (close->path) + 1 < input.pathlen) {
- strcpy (input.path, close->path);
- input.pathlen = strlen (close->path) + 1;
- input.recno = close_rec->rec_tail.recno;
- input.offset = close_rec->rec_kml_offset;
- input.len = close_rec->rec_size;
- input.generation = close->generation;
- input.ino = close->ino;
- }
- else {
- CDEBUG(D_KML, "KML_DO_REINT::no space to save:%d < %d",
- strlen (close->path) + 1, input.pathlen);
- error = -ENOMEM;
- }
- if (copy_to_user((char *)arg, &input, sizeof (input)))
- return -EFAULT;
- }
- return error;
-}
-
-/* END_KML_REINT */
-int end_kml_reint (struct file *file, unsigned long arg)
-{
- /* Free KML buffer and related volume info */
- struct {
- char *volname;
- int namelen;
-#if 0
- int count;
- int newpos;
-#endif
- } input;
- struct presto_file_set *fset = NULL;
- struct kml_fsdata *kml_fsdata = NULL;
- int error;
- char *path;
-
- ENTRY;
- if (copy_from_user(&input, (char *)arg, sizeof(input))) {
- EXIT;
- return -EFAULT;
- }
-
- PRESTO_ALLOC(path, char *, input.namelen + 1);
- if ( !path ) {
- EXIT;
- return -ENOMEM;
- }
- if (copy_from_user(path, input.volname, input.namelen)) {
- if ( error ) {
- PRESTO_FREE(path, input.namelen + 1);
- EXIT;
- return -EFAULT;
- }
- path[input.namelen] = '\0';
- fset = kml_getfset (path);
- PRESTO_FREE(path, input.namelen + 1);
-
- kml_fsdata = FSET_GET_KMLDATA(fset);
- delete_kmlrec (&kml_fsdata->kml_reint_cache);
-
- /* kml reint support */
- kml_fsdata->kml_reint_current = NULL;
- kml_fsdata->kml_len = 0;
- kml_fsdata->kml_reintpos = 0;
- kml_fsdata->kml_count = 0;
-#if 0
- input.newpos = kml_upc->newpos;
- input.count = kml_upc->count;
- if (copy_to_user((char *)arg, &input, sizeof (input)))
- return -EFAULT;
-#endif
- return error;
-}
+++ /dev/null
-/*
- * KML Decoding
- *
- * Copryright (C) 1996 Arthur Ma <arthur.ma@mountainviewdata.com>
- *
- * Copyright (C) 2001 Mountainview Data, Inc.
- */
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include "intermezzo_fs.h"
-#include "intermezzo_kml.h"
-
-static int size_round (int val);
-static int unpack_create (struct kml_create *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_open (struct kml_open *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_symlink (struct kml_symlink *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_mknod (struct kml_mknod *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_link (struct kml_link *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_rename (struct kml_rename *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_unlink (struct kml_unlink *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_rmdir (struct kml_rmdir *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_setattr (struct kml_setattr *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_close (struct kml_close *rec, char *buf,
- int pos, int *rec_offs);
-static int unpack_mkdir (struct kml_mkdir *rec, char *buf,
- int pos, int *rec_offs);
-
-#if 0
-static int unpack_endmark (struct kml_endmark *rec, char *buf,
- int pos, int *rec_offs);
-static void print_kml_endmark (struct kml_endmark *rec);
-#endif
-
-static int kml_unpack (char *kml_buf, int rec_size, int kml_offset,
- struct kml_rec **newrec);
-static char *kml_version (struct presto_version *ver);
-static void print_kml_prefix (struct big_journal_prefix *head);
-static void print_kml_create (struct kml_create *rec);
-static void print_kml_mkdir (struct kml_mkdir *rec);
-static void print_kml_unlink (struct kml_unlink *rec);
-static void print_kml_rmdir (struct kml_rmdir *rec);
-static void print_kml_close (struct kml_close *rec);
-static void print_kml_symlink (struct kml_symlink *rec);
-static void print_kml_rename (struct kml_rename *rec);
-static void print_kml_setattr (struct kml_setattr *rec);
-static void print_kml_link (struct kml_link *rec);
-static void print_kml_mknod (struct kml_mknod *rec);
-static void print_kml_open (struct kml_open *rec);
-static void print_kml_suffix (struct journal_suffix *tail);
-static char *readrec (char *recbuf, int reclen, int pos, int *size);
-
-#define KML_PREFIX_WORDS 8
-static int kml_unpack (char *kml_buf, int rec_size, int kml_offset,
- struct kml_rec **newrec)
-{
- struct kml_rec *rec;
- char *p;
- int pos, rec_offs;
- int error;
-
- ENTRY;
- if (rec_size < sizeof (struct journal_prefix) +
- sizeof (struct journal_suffix))
- return -EBADF;
-
- PRESTO_ALLOC(rec, struct kml_rec *, sizeof (struct kml_rec));
- if (rec == NULL) {
- EXIT;
- return -ENOMEM;
- }
- rec->rec_kml_offset = kml_offset;
- rec->rec_size = rec_size;
- p = kml_buf;
- p = dlogit (&rec->rec_head, p, KML_PREFIX_WORDS * sizeof (int));
- p = dlogit (&rec->rec_head.groups, p,
- sizeof (int) * rec->rec_head.ngroups);
-
- pos = sizeof (struct journal_prefix) +
- sizeof (int) * rec->rec_head.ngroups;
- switch (rec->rec_head.opcode)
- {
- case KML_CREATE:
- error = unpack_create (&rec->rec_kml.create,
- kml_buf, pos, &rec_offs);
- break;
- case KML_MKDIR:
- error = unpack_mkdir (&rec->rec_kml.mkdir,
- kml_buf, pos, &rec_offs);
- break;
- case KML_UNLINK:
- error = unpack_unlink (&rec->rec_kml.unlink,
- kml_buf, pos, &rec_offs);
- break;
- case KML_RMDIR:
- error = unpack_rmdir (&rec->rec_kml.rmdir,
- kml_buf, pos, &rec_offs);
- break;
- case KML_CLOSE:
- error = unpack_close (&rec->rec_kml.close,
- kml_buf, pos, &rec_offs);
- break;
- case KML_SYMLINK:
- error = unpack_symlink (&rec->rec_kml.symlink,
- kml_buf, pos, &rec_offs);
- break;
- case KML_RENAME:
- error = unpack_rename (&rec->rec_kml.rename,
- kml_buf, pos, &rec_offs);
- break;
- case KML_SETATTR:
- error = unpack_setattr (&rec->rec_kml.setattr,
- kml_buf, pos, &rec_offs);
- break;
- case KML_LINK:
- error = unpack_link (&rec->rec_kml.link,
- kml_buf, pos, &rec_offs);
- break;
- case KML_OPEN:
- error = unpack_open (&rec->rec_kml.open,
- kml_buf, pos, &rec_offs);
- break;
- case KML_MKNOD:
- error = unpack_mknod (&rec->rec_kml.mknod,
- kml_buf, pos, &rec_offs);
- break;
-#if 0
- case KML_ENDMARK:
- error = unpack_endmark (&rec->rec_kml.endmark,
- kml_buf, pos, &rec_offs);
- break;
-#endif
- default:
- CDEBUG (D_KML, "wrong opcode::%u\n",
- rec->rec_head.opcode);
- EXIT;
- return -EINVAL;
- }
- if (error) {
- PRESTO_FREE (rec, sizeof (struct kml_rec));
- return -EINVAL;
- }
- p = kml_buf + rec_offs;
- p = dlogit (&rec->rec_tail, p, sizeof (struct journal_suffix));
- memset (&rec->kml_optimize, 0, sizeof (struct kml_optimize));
- *newrec = rec;
- EXIT;
- return 0;
-}
-
-static int size_round (int val)
-{
- return (val + 3) & (~0x3);
-}
-
-static int unpack_create (struct kml_create *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 88;
- int pathlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->mode, p, sizeof (int));
- p = dlogit (&rec->uid, p, sizeof (int));
- p = dlogit (&rec->gid, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen);
- EXIT;
- return 0;
-}
-
-static int unpack_open (struct kml_open *rec, char *buf,
- int pos, int *rec_offs)
-{
- *rec_offs = pos;
- return 0;
-}
-
-static int unpack_symlink (struct kml_symlink *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 88;
- int pathlen, targetlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->uid, p, sizeof (int));
- p = dlogit (&rec->gid, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
- p = dlogit (&targetlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->sourcepath = q;
-
- PRESTO_ALLOC(q, char *, targetlen + 1);
- if (q == NULL) {
- PRESTO_FREE (rec->sourcepath, pathlen + 1);
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, targetlen);
- q[targetlen] = '\0';
- rec->targetpath = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen) +
- size_round(targetlen);
- EXIT;
- return 0;
-}
-
-static int unpack_mknod (struct kml_mknod *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 96;
- int pathlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->mode, p, sizeof (int));
- p = dlogit (&rec->uid, p, sizeof (int));
- p = dlogit (&rec->gid, p, sizeof (int));
- p = dlogit (&rec->major, p, sizeof (int));
- p = dlogit (&rec->minor, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen);
- EXIT;
- return 0;
-}
-
-static int unpack_link (struct kml_link *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 80;
- int pathlen, targetlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&pathlen, p, sizeof (int));
- p = dlogit (&targetlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->sourcepath = q;
- p += size_round (pathlen);
-
- PRESTO_ALLOC(q, char *, targetlen + 1);
- if (q == NULL) {
- PRESTO_FREE (rec->sourcepath, pathlen + 1);
- EXIT;
- return -ENOMEM;
- }
- memcpy (q, p, targetlen);
- q[targetlen] = '\0';
- rec->targetpath = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen) +
- size_round(targetlen);
- EXIT;
- return 0;
-}
-
-static int unpack_rename (struct kml_rename *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 104;
- int pathlen, targetlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_tgtv, p, sizeof (struct presto_version));
- p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
- p = dlogit (&pathlen, p, sizeof (int));
- p = dlogit (&targetlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->sourcepath = q;
- p += size_round (pathlen);
-
- PRESTO_ALLOC(q, char *, targetlen + 1);
- if (q == NULL) {
- PRESTO_FREE (rec->sourcepath, pathlen + 1);
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, targetlen);
- q[targetlen] = '\0';
- rec->targetpath = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen) +
- size_round(targetlen);
- EXIT;
- return 0;
-}
-
-static int unpack_unlink (struct kml_unlink *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 80;
- int pathlen, targetlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
- p = dlogit (&pathlen, p, sizeof (int));
- p = dlogit (&targetlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
- p += size_round (pathlen);
-
- PRESTO_ALLOC(q, char *, targetlen + 1);
- if (q == NULL) {
- PRESTO_FREE (rec->path, pathlen + 1);
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, targetlen);
- q[targetlen] = '\0';
- rec->name = q;
-
- /* fix the presto_journal_unlink problem */
- *rec_offs = pos + unpack_size + size_round(pathlen) +
- size_round(targetlen);
- EXIT;
- return 0;
-}
-
-static int unpack_rmdir (struct kml_rmdir *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 80;
- int pathlen, targetlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->old_tgtv, p, sizeof (struct presto_version));
- p = dlogit (&pathlen, p, sizeof (int));
- p = dlogit (&targetlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
- p += size_round (pathlen);
-
- PRESTO_ALLOC(q, char *, targetlen + 1);
- if (q == NULL) {
- PRESTO_FREE (rec->path, pathlen + 1);
- EXIT;
- return -ENOMEM;
- }
- memcpy (q, p, targetlen);
- q[targetlen] = '\0';
- rec->name = q;
-
- *rec_offs = pos + unpack_size + size_round(pathlen) +
- size_round(targetlen);
- EXIT;
- return 0;
-}
-
-static int unpack_setattr (struct kml_setattr *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 72;
- struct kml_attr {
- __u64 size, mtime, ctime;
- } objattr;
- int valid, mode, uid, gid, flags;
- int pathlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_objectv, p, sizeof (struct presto_version));
- p = dlogit (&valid, p, sizeof (int));
- p = dlogit (&mode, p, sizeof (int));
- p = dlogit (&uid, p, sizeof (int));
- p = dlogit (&gid, p, sizeof (int));
- p = dlogit (&objattr, p, sizeof (struct kml_attr));
- p = dlogit (&flags, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
-
- rec->iattr.ia_valid = valid;
- rec->iattr.ia_mode = mode;
- rec->iattr.ia_uid = uid;
- rec->iattr.ia_gid = gid;
- rec->iattr.ia_size = objattr.size;
- rec->iattr.ia_mtime = objattr.mtime;
- rec->iattr.ia_ctime = objattr.ctime;
- rec->iattr.ia_atime = 0;
- rec->iattr.ia_attr_flags = flags;
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
- p += pathlen;
-
- *rec_offs = pos + unpack_size + size_round(pathlen);
- EXIT;
- return 0;
-}
-
-static int unpack_close (struct kml_close *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 52;
- int pathlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->open_mode, p, sizeof (int));
- p = dlogit (&rec->open_uid, p, sizeof (int));
- p = dlogit (&rec->open_gid, p, sizeof (int));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->ino, p, sizeof (__u64));
- p = dlogit (&rec->generation, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
- p += pathlen;
-
- *rec_offs = pos + unpack_size + size_round(pathlen);
- EXIT;
- return 0;
-}
-
-static int unpack_mkdir (struct kml_mkdir *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p, *q;
- int unpack_size = 88;
- int pathlen;
-
- ENTRY;
- p = buf + pos;
- p = dlogit (&rec->old_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_parentv, p, sizeof (struct presto_version));
- p = dlogit (&rec->new_objectv, p, sizeof (struct presto_version));
- p = dlogit (&rec->mode, p, sizeof (int));
- p = dlogit (&rec->uid, p, sizeof (int));
- p = dlogit (&rec->gid, p, sizeof (int));
- p = dlogit (&pathlen, p, sizeof (int));
-
- PRESTO_ALLOC(q, char *, pathlen + 1);
- if (q == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- memcpy (q, p, pathlen);
- q[pathlen] = '\0';
- rec->path = q;
- p += pathlen;
-
- *rec_offs = pos + unpack_size + size_round(pathlen);
- EXIT;
- return 0;
-}
-
-#if 0
-static int unpack_endmark (struct kml_endmark *rec, char *buf,
- int pos, int *rec_offs)
-{
- char *p;
- p = buf + pos;
- p = dlogit (&rec->total, p, sizeof (int));
-
- PRESTO_ALLOC (rec->kop, struct kml_kop_node *,
- sizeof (struct kml_kop_node) * rec->total);
- if (rec->kop == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- p = dlogit (rec->kop, p, sizeof (struct kml_kop_node) * rec->total);
-
- *rec_offs = pos + sizeof (int) + sizeof (struct kml_kop_node) * rec->total;
- return 0;
-}
-#endif
-
-static char *kml_version (struct presto_version *ver)
-{
- static char buf[256];
- sprintf (buf, "mt::%lld, ct::%lld, size::%lld",
- ver->pv_mtime, ver->pv_ctime, ver->pv_size);
- return buf;
-}
-
-static void print_kml_prefix (struct big_journal_prefix *head)
-{
- int i;
-
- CDEBUG (D_KML, " === KML PREFIX\n");
- CDEBUG (D_KML, " len = %u\n", head->len);
- CDEBUG (D_KML, " version = %u\n", head->version);
- CDEBUG (D_KML, " pid = %u\n", head->pid);
- CDEBUG (D_KML, " uid = %u\n", head->uid);
- CDEBUG (D_KML, " fsuid = %u\n", head->fsuid);
- CDEBUG (D_KML, " fsgid = %u\n", head->fsgid);
- CDEBUG (D_KML, " opcode = %u\n", head->opcode);
- CDEBUG (D_KML, " ngroup = %u", head->ngroups);
- for (i = 0; i < head->ngroups; i++)
- CDEBUG (D_KML, "%u ", head->groups[i]);
- CDEBUG (D_KML, "\n");
-}
-
-static void print_kml_create (struct kml_create *rec)
-{
- CDEBUG (D_KML, " === CREATE\n");
- CDEBUG (D_KML, " path::%s\n", rec->path);
- CDEBUG (D_KML, " new_objv::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
- CDEBUG (D_KML, " mode::%o\n", rec->mode);
- CDEBUG (D_KML, " uid::%d\n", rec->uid);
- CDEBUG (D_KML, " gid::%d\n", rec->gid);
-}
-
-static void print_kml_mkdir (struct kml_mkdir *rec)
-{
- CDEBUG (D_KML, " === MKDIR\n");
- CDEBUG (D_KML, " path::%s\n", rec->path);
- CDEBUG (D_KML, " new_objv::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
- CDEBUG (D_KML, " mode::%o\n", rec->mode);
- CDEBUG (D_KML, " uid::%d\n", rec->uid);
- CDEBUG (D_KML, " gid::%d\n", rec->gid);
-}
-
-static void print_kml_unlink (struct kml_unlink *rec)
-{
- CDEBUG (D_KML, " === UNLINK\n");
- CDEBUG (D_KML, " path::%s/%s\n", rec->path, rec->name);
- CDEBUG (D_KML, " old_tgtv::%s\n", kml_version (&rec->old_tgtv));
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_rmdir (struct kml_rmdir *rec)
-{
- CDEBUG (D_KML, " === RMDIR\n");
- CDEBUG (D_KML, " path::%s/%s\n", rec->path, rec->name);
- CDEBUG (D_KML, " old_tgtv::%s\n", kml_version (&rec->old_tgtv));
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_close (struct kml_close *rec)
-{
- CDEBUG (D_KML, " === CLOSE\n");
- CDEBUG (D_KML, " mode::%o\n", rec->open_mode);
- CDEBUG (D_KML, " uid::%d\n", rec->open_uid);
- CDEBUG (D_KML, " gid::%d\n", rec->open_gid);
- CDEBUG (D_KML, " path::%s\n", rec->path);
- CDEBUG (D_KML, " new_objv::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " ino::%lld\n", rec->ino);
- CDEBUG (D_KML, " gen::%u\n", rec->generation);
-}
-
-static void print_kml_symlink (struct kml_symlink *rec)
-{
- CDEBUG (D_KML, " === SYMLINK\n");
- CDEBUG (D_KML, " s-path::%s\n", rec->sourcepath);
- CDEBUG (D_KML, " t-path::%s\n", rec->targetpath);
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
- CDEBUG (D_KML, " new_objv::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " uid::%d\n", rec->uid);
- CDEBUG (D_KML, " gid::%d\n", rec->gid);
-}
-
-static void print_kml_rename (struct kml_rename *rec)
-{
- CDEBUG (D_KML, " === RENAME\n");
- CDEBUG (D_KML, " s-path::%s\n", rec->sourcepath);
- CDEBUG (D_KML, " t-path::%s\n", rec->targetpath);
- CDEBUG (D_KML, " old_tgtv::%s\n", kml_version (&rec->old_tgtv));
- CDEBUG (D_KML, " new_tgtv::%s\n", kml_version (&rec->new_tgtv));
- CDEBUG (D_KML, " new_objv::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " old_objv::%s\n", kml_version (&rec->old_objectv));
-}
-
-static void print_kml_setattr (struct kml_setattr *rec)
-{
- CDEBUG (D_KML, " === SETATTR\n");
- CDEBUG (D_KML, " path::%s\n", rec->path);
- CDEBUG (D_KML, " old_objv::%s\n", kml_version (&rec->old_objectv));
- CDEBUG (D_KML, " valid::0x%x\n", rec->iattr.ia_valid);
- CDEBUG (D_KML, " mode::%o\n", rec->iattr.ia_mode);
- CDEBUG (D_KML, " uid::%d\n", rec->iattr.ia_uid);
- CDEBUG (D_KML, " gid::%d\n", rec->iattr.ia_gid);
- CDEBUG (D_KML, " size::%u\n", (u32) rec->iattr.ia_size);
- CDEBUG (D_KML, " mtime::%u\n", (u32) rec->iattr.ia_mtime);
- CDEBUG (D_KML, " ctime::%u\n", (u32) rec->iattr.ia_ctime);
- CDEBUG (D_KML, " flags::%u\n", (u32) rec->iattr.ia_attr_flags);
-}
-
-static void print_kml_link (struct kml_link *rec)
-{
- CDEBUG (D_KML, " === LINK\n");
- CDEBUG (D_KML, " path::%s ==> %s\n", rec->sourcepath, rec->targetpath);
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_obj::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
-}
-
-static void print_kml_mknod (struct kml_mknod *rec)
-{
- CDEBUG (D_KML, " === MKNOD\n");
- CDEBUG (D_KML, " path::%s\n", rec->path);
- CDEBUG (D_KML, " new_obj::%s\n", kml_version (&rec->new_objectv));
- CDEBUG (D_KML, " old_parv::%s\n", kml_version (&rec->old_parentv));
- CDEBUG (D_KML, " new_parv::%s\n", kml_version (&rec->new_parentv));
- CDEBUG (D_KML, " mode::%o\n", rec->mode);
- CDEBUG (D_KML, " uid::%d\n", rec->uid);
- CDEBUG (D_KML, " gid::%d\n", rec->gid);
- CDEBUG (D_KML, " major::%d\n", rec->major);
- CDEBUG (D_KML, " minor::%d\n", rec->minor);
-}
-
-static void print_kml_open (struct kml_open *rec)
-{
- CDEBUG (D_KML, " === OPEN\n");
-}
-
-#if 0
-static void print_kml_endmark (struct kml_endmark *rec)
-{
- int i;
- CDEBUG (D_KML, " === ENDMARK\n");
- CDEBUG (D_KML, " total::%u\n", rec->total);
- for (i = 0; i < rec->total; i++)
- {
- CDEBUG (D_KML, " recno=%ld::flag=%ld,op=%ld, i_ino=%ld, \
- i_nlink=%ld\n", (long) rec->kop[i].kml_recno,
- (long) rec->kop[i].kml_flag, (long) rec->kop[i].kml_op,
- (long) rec->kop[i].i_ino, (long) rec->kop[i].i_nlink);
- }
-}
-#endif
-
-static void print_kml_optimize (struct kml_optimize *rec)
-{
- CDEBUG (D_KML, " === OPTIMIZE\n");
- if (rec->kml_flag == KML_REC_DELETE)
- CDEBUG (D_KML, " kml_flag::deleted\n");
- else
- CDEBUG (D_KML, " kml_flag::exist\n");
- CDEBUG (D_KML, " kml_op::%u\n", rec->kml_op);
- CDEBUG (D_KML, " i_nlink::%d\n", rec->i_nlink);
- CDEBUG (D_KML, " i_ino::%u\n", rec->i_ino);
-}
-
-static void print_kml_suffix (struct journal_suffix *tail)
-{
- CDEBUG (D_KML, " === KML SUFFIX\n");
- CDEBUG (D_KML, " prevrec::%ld\n", tail->prevrec);
- CDEBUG (D_KML, " recno::%ld\n", (long) tail->recno);
- CDEBUG (D_KML, " time::%d\n", tail->time);
- CDEBUG (D_KML, " len::%d\n", tail->len);
-}
-
-void kml_printrec (struct kml_rec *rec, int kml_printop)
-{
- if (kml_printop & PRINT_KML_PREFIX)
- print_kml_prefix (&rec->rec_head);
- if (kml_printop & PRINT_KML_REC)
- {
- switch (rec->rec_head.opcode)
- {
- case KML_CREATE:
- print_kml_create (&rec->rec_kml.create);
- break;
- case KML_MKDIR:
- print_kml_mkdir (&rec->rec_kml.mkdir);
- break;
- case KML_UNLINK:
- print_kml_unlink (&rec->rec_kml.unlink);
- break;
- case KML_RMDIR:
- print_kml_rmdir (&rec->rec_kml.rmdir);
- break;
- case KML_CLOSE:
- print_kml_close (&rec->rec_kml.close);
- break;
- case KML_SYMLINK:
- print_kml_symlink (&rec->rec_kml.symlink);
- break;
- case KML_RENAME:
- print_kml_rename (&rec->rec_kml.rename);
- break;
- case KML_SETATTR:
- print_kml_setattr (&rec->rec_kml.setattr);
- break;
- case KML_LINK:
- print_kml_link (&rec->rec_kml.link);
- break;
- case KML_OPEN:
- print_kml_open (&rec->rec_kml.open);
- break;
- case KML_MKNOD:
- print_kml_mknod (&rec->rec_kml.mknod);
- break;
-#if 0
- case KML_ENDMARK:
- print_kml_endmark (&rec->rec_kml.endmark);
-#endif
- break;
- default:
- CDEBUG (D_KML, " === BAD RECORD, opcode=%u\n",
- rec->rec_head.opcode);
- break;
- }
- }
- if (kml_printop & PRINT_KML_SUFFIX)
- print_kml_suffix (&rec->rec_tail);
- if (kml_printop & PRINT_KML_OPTIMIZE)
- print_kml_optimize (&rec->kml_optimize);
-}
-
-void kml_freerec (struct kml_rec *rec)
-{
- char *sourcepath = NULL,
- *targetpath = NULL;
- switch (rec->rec_head.opcode)
- {
- case KML_CREATE:
- sourcepath = rec->rec_kml.create.path;
- break;
- case KML_MKDIR:
- sourcepath = rec->rec_kml.create.path;
- break;
- case KML_UNLINK:
- sourcepath = rec->rec_kml.unlink.path;
- targetpath = rec->rec_kml.unlink.name;
- break;
- case KML_RMDIR:
- sourcepath = rec->rec_kml.rmdir.path;
- targetpath = rec->rec_kml.rmdir.name;
- break;
- case KML_CLOSE:
- sourcepath = rec->rec_kml.close.path;
- break;
- case KML_SYMLINK:
- sourcepath = rec->rec_kml.symlink.sourcepath;
- targetpath = rec->rec_kml.symlink.targetpath;
- break;
- case KML_RENAME:
- sourcepath = rec->rec_kml.rename.sourcepath;
- targetpath = rec->rec_kml.rename.targetpath;
- break;
- case KML_SETATTR:
- sourcepath = rec->rec_kml.setattr.path;
- break;
- case KML_LINK:
- sourcepath = rec->rec_kml.link.sourcepath;
- targetpath = rec->rec_kml.link.targetpath;
- break;
- case KML_OPEN:
- break;
- case KML_MKNOD:
- sourcepath = rec->rec_kml.mknod.path;
- break;
-#if 0
- case KML_ENDMARK:
- PRESTO_FREE (rec->rec_kml.endmark.kop, sizeof (int) +
- sizeof (struct kml_kop_node) *
- rec->rec_kml.endmark.total);
-#endif
- break;
- default:
- break;
- }
- if (sourcepath != NULL)
- PRESTO_FREE (sourcepath, strlen (sourcepath) + 1);
- if (targetpath != NULL)
- PRESTO_FREE (targetpath, strlen (targetpath) + 1);
-}
-
-char *readrec (char *recbuf, int reclen, int pos, int *size)
-{
- char *p = recbuf + pos;
- *size = *((int *) p);
- if (*size > (reclen - pos))
- return NULL;
- return p;
-}
-
-int kml_decoderec (char *buf, int pos, int buflen, int *size,
- struct kml_rec **newrec)
-{
- char *tmp;
- int error;
- tmp = readrec (buf, buflen, pos, size);
- if (tmp == NULL)
- return -EBADF;
- error = kml_unpack (tmp, *size, pos, newrec);
- return error;
-}
-
-#if 0
-static void fill_kmlrec_optimize (struct list_head *head,
- struct kml_rec *optrec)
-{
- struct kml_rec *kmlrec;
- struct list_head *tmp;
- struct kml_endmark *km;
- struct kml_optimize *ko;
- int n;
-
- if (optrec->rec_kml.endmark.total == 0)
- return;
- n = optrec->rec_kml.endmark.total - 1;
- tmp = head->prev;
- km = &optrec->rec_kml.endmark;
- while ( n >= 0 && tmp != head )
- {
- kmlrec = list_entry(tmp, struct kml_rec,
- kml_optimize.kml_chains);
- tmp = tmp->prev;
- if (kmlrec->rec_tail.recno == km->kop[n].kml_recno)
- {
- ko = &kmlrec->kml_optimize;
- ko->kml_flag = km->kop[n].kml_flag;
- ko->kml_op = km->kop[n].kml_op;
- ko->i_nlink = km->kop[n].i_nlink;
- ko->i_ino = km->kop[n].i_ino;
- n --;
- }
- }
- if (n != -1)
- CDEBUG (D_KML, "Yeah!!!, KML optimize error, recno=%d, n=%d\n",
- optrec->rec_tail.recno, n);
-}
-#endif
-
-int decode_kmlrec (struct list_head *head, char *kml_buf, int buflen)
-{
- struct kml_rec *rec;
- int pos = 0, size;
- int err;
- while (pos < buflen) {
- err = kml_decoderec (kml_buf, pos, buflen, &size, &rec);
- if (err != 0)
- break;
-#if 0
- if (rec->rec_head.opcode == KML_ENDMARK) {
- fill_kmlrec_optimize (head, rec);
- mark_rec_deleted (rec);
- }
-#endif
- list_add_tail (&rec->kml_optimize.kml_chains, head);
- pos += size;
- }
- return err;
-}
-
-int delete_kmlrec (struct list_head *head)
-{
- struct kml_rec *rec;
- struct list_head *tmp;
-
- if (list_empty(head))
- return 0;
- tmp = head->next;
- while ( tmp != head ) {
- rec = list_entry(tmp, struct kml_rec,
- kml_optimize.kml_chains);
- tmp = tmp->next;
- kml_freerec (rec);
- }
- INIT_LIST_HEAD(head);
- return 0;
-}
-
-int print_allkmlrec (struct list_head *head, int printop)
-{
- struct kml_rec *rec;
- struct list_head *tmp;
-
- if (list_empty(head))
- return 0;
- tmp = head->next;
- while ( tmp != head ) {
- rec = list_entry(tmp, struct kml_rec,
- kml_optimize.kml_chains);
- tmp = tmp->next;
-#if 0
- if (printop & PRINT_KML_EXIST) {
- if (is_deleted_node (rec))
- continue;
- }
- else if (printop & PRINT_KML_DELETE) {
- if (! is_deleted_node (rec))
- continue;
- }
-#endif
- kml_printrec (rec, printop);
- }
- INIT_LIST_HEAD(head);
- return 0;
-}
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Reintegration of KML records
- *
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <asm/uaccess.h>
-#include <asm/pgtable.h>
-#include <asm/mmu_context.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-static void kmlreint_pre_secure(struct kml_rec *rec, struct file *dir,
- struct run_ctxt *saved)
-{
- struct run_ctxt ctxt;
- struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
- int i;
-
- ctxt.fsuid = rec->prefix.hdr->fsuid;
- ctxt.fsgid = rec->prefix.hdr->fsgid;
- ctxt.fs = KERNEL_DS;
- ctxt.pwd = dd->dd_fset->fset_dentry;
- ctxt.pwdmnt = dd->dd_fset->fset_mnt;
-
- ctxt.root = ctxt.pwd;
- ctxt.rootmnt = ctxt.pwdmnt;
- if (rec->prefix.hdr->ngroups > 0) {
- ctxt.group_info = groups_alloc(rec->prefix.hdr->ngroups);
- for (i = 0; i< ctxt.group_info->ngroups; i++)
- GROUP_AT(ctxt.group_info,i)= rec->prefix.groups[i];
- } else
- ctxt.group_info = groups_alloc(0);
-
- push_ctxt(saved, &ctxt);
-}
-
-
-/* Append two strings in a less-retarded fashion. */
-static char * path_join(char *p1, int p1len, char *p2, int p2len)
-{
- int size = p1len + p2len + 2; /* possibly one extra /, one NULL */
- char *path;
-
- path = kmalloc(size, GFP_KERNEL);
- if (path == NULL)
- return NULL;
-
- memcpy(path, p1, p1len);
- if (path[p1len - 1] != '/') {
- path[p1len] = '/';
- p1len++;
- }
- memcpy(path + p1len, p2, p2len);
- path[p1len + p2len] = '\0';
-
- return path;
-}
-
-static inline int kml_recno_equal(struct kml_rec *rec,
- struct presto_file_set *fset)
-{
- return (rec->suffix->recno == fset->fset_lento_recno + 1);
-}
-
-static inline int version_equal(struct presto_version *a, struct inode *inode)
-{
- if (a == NULL)
- return 1;
-
- if (inode == NULL) {
- CERROR("InterMezzo: NULL inode in version_equal()\n");
- return 0;
- }
-
- if (inode->i_mtime.tv_sec == a->pv_mtime_sec &&
- inode->i_mtime.tv_nsec == a->pv_mtime_nsec &&
- (S_ISDIR(inode->i_mode) || inode->i_size == a->pv_size))
- return 1;
-
- return 0;
-}
-
-static int reint_close(struct kml_rec *rec, struct file *file,
- struct lento_vfs_context *given_info)
-{
- struct run_ctxt saved_ctxt;
- int error;
- struct presto_file_set *fset;
- struct lento_vfs_context info;
- ENTRY;
-
- memcpy(&info, given_info, sizeof(*given_info));
-
-
- CDEBUG (D_KML, "=====REINT_CLOSE::%s\n", rec->path);
-
- fset = presto_fset(file->f_dentry);
- if (fset->fset_flags & FSET_DATA_ON_DEMAND) {
- struct iattr iattr;
-
- iattr.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_SIZE;
- iattr.ia_mtime.tv_sec = (time_t)rec->new_objectv->pv_mtime_sec;
- iattr.ia_mtime.tv_nsec = (time_t)rec->new_objectv->pv_mtime_nsec;
- iattr.ia_ctime.tv_sec = (time_t)rec->new_objectv->pv_ctime_sec;
- iattr.ia_ctime.tv_nsec = (time_t)rec->new_objectv->pv_ctime_nsec;
- iattr.ia_size = (time_t)rec->new_objectv->pv_size;
-
- /* no kml record, but update last rcvd */
- /* save fileid in dentry for later backfetch */
- info.flags |= LENTO_FL_EXPECT | LENTO_FL_SET_DDFILEID;
- info.remote_ino = rec->ino;
- info.remote_generation = rec->generation;
- info.flags &= ~LENTO_FL_KML;
- kmlreint_pre_secure(rec, file, &saved_ctxt);
- error = lento_setattr(rec->path, &iattr, &info);
- pop_ctxt(&saved_ctxt);
-
- presto_d2d(file->f_dentry)->dd_flags &= ~PRESTO_DATA;
- } else {
- int minor = presto_f2m(fset);
-
- info.updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
- info.updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
- memcpy(&info.remote_version, rec->old_objectv,
- sizeof(*rec->old_objectv));
- info.remote_ino = rec->ino;
- info.remote_generation = rec->generation;
- error = izo_upc_backfetch(minor, rec->path, fset->fset_name,
- &info);
- if (error) {
- CERROR("backfetch error %d\n", error);
- /* if file doesn't exist anymore, then ignore the CLOSE
- * and just update the last_rcvd.
- */
- if (error == ENOENT) {
- CDEBUG(D_KML, "manually updating remote offset uuid %s"
- "recno %d offset %Lu\n", info.uuid, info.recno,
- (unsigned long long) info.kml_offset);
- error = izo_rcvd_upd_remote(fset, info.uuid, info.recno, info.kml_offset);
- if(error)
- CERROR("izo_rcvd_upd_remote error %d\n", error);
-
- }
- }
-
- /* propagate error to avoid further reint */
- }
-
- EXIT;
- return error;
-}
-
-static int reint_create(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error; ENTRY;
-
- CDEBUG (D_KML, "=====REINT_CREATE::%s\n", rec->path);
- info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_create(rec->path, rec->mode, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_link(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
-
- ENTRY;
-
- CDEBUG (D_KML, "=====REINT_LINK::%s -> %s\n", rec->path, rec->target);
- info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_link(rec->path, rec->target, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_mkdir(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
-
- ENTRY;
-
- CDEBUG (D_KML, "=====REINT_MKDIR::%s\n", rec->path);
- info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_mkdir(rec->path, rec->mode, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_mknod(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
- dev_t dev;
-
- ENTRY;
-
- CDEBUG (D_KML, "=====REINT_MKNOD::%s\n", rec->path);
- info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
-
- dev = rec->rdev ? old_decode_dev(rec->rdev) : MKDEV(rec->major, rec->minor);
-
- error = lento_mknod(rec->path, rec->mode, dev, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-
-static int reint_noop(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- return 0;
-}
-
-static int reint_rename(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
-
- ENTRY;
-
- CDEBUG (D_KML, "=====REINT_RENAME::%s -> %s\n", rec->path, rec->target);
- info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_rename(rec->path, rec->target, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_rmdir(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
- char *path;
-
- ENTRY;
-
- path = path_join(rec->path, rec->pathlen - 1, rec->target, rec->targetlen);
- if (path == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- CDEBUG (D_KML, "=====REINT_RMDIR::%s\n", path);
- info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
- info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_rmdir(path, info);
- pop_ctxt(&saved_ctxt);
-
- kfree(path);
- EXIT;
- return error;
-}
-
-static int reint_setattr(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- struct iattr iattr;
- int error;
-
- ENTRY;
-
- iattr.ia_valid = rec->valid;
- iattr.ia_mode = (umode_t)rec->mode;
- iattr.ia_uid = (uid_t)rec->uid;
- iattr.ia_gid = (gid_t)rec->gid;
- iattr.ia_size = (off_t)rec->size;
- iattr.ia_ctime.tv_sec = rec->ctime_sec;
- iattr.ia_ctime.tv_nsec = rec->ctime_nsec;
- iattr.ia_mtime.tv_sec = rec->mtime_sec;
- iattr.ia_mtime.tv_nsec = rec->mtime_nsec;
- iattr.ia_atime = iattr.ia_mtime; /* We don't track atimes. */
- iattr.ia_attr_flags = rec->flags;
-
- CDEBUG (D_KML, "=====REINT_SETATTR::%s (%d)\n", rec->path, rec->valid);
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_setattr(rec->path, &iattr, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_symlink(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
-
- ENTRY;
-
- CDEBUG (D_KML, "=====REINT_SYMLINK::%s -> %s\n", rec->path, rec->target);
- info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
- info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_symlink(rec->target, rec->path, info);
- pop_ctxt(&saved_ctxt);
-
- EXIT;
- return error;
-}
-
-static int reint_unlink(struct kml_rec *rec, struct file *dir,
- struct lento_vfs_context *info)
-{
- struct run_ctxt saved_ctxt;
- int error;
- char *path;
-
- ENTRY;
-
- path = path_join(rec->path, rec->pathlen - 1, rec->target, rec->targetlen);
- if (path == NULL) {
- EXIT;
- return -ENOMEM;
- }
-
- CDEBUG (D_KML, "=====REINT_UNLINK::%s\n", path);
- info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
- info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
- kmlreint_pre_secure(rec, dir, &saved_ctxt);
- error = lento_unlink(path, info);
- pop_ctxt(&saved_ctxt);
-
- kfree(path);
- EXIT;
- return error;
-}
-
-static int branch_reint_rename(struct presto_file_set *fset, struct kml_rec *rec,
- struct file *dir, struct lento_vfs_context *info,
- char * kml_data, __u64 kml_size)
-{
- int error;
-
- ENTRY;
-
- error = reint_rename(rec, dir, info);
- if (error == -ENOENT) {
- /* normal reint failed because path was not found */
- struct rec_info rec;
-
- CDEBUG(D_KML, "saving branch rename kml\n");
- rec.is_kml = 1;
- rec.size = kml_size;
- error = presto_log(fset, &rec, kml_data, kml_size,
- NULL, 0, NULL, 0, NULL, 0);
- if (error == 0)
- error = presto_write_last_rcvd(&rec, fset, info);
- }
-
- EXIT;
- return error;
-}
-
-int branch_reinter(struct presto_file_set *fset, struct kml_rec *rec,
- struct file *dir, struct lento_vfs_context *info,
- char * kml_data, __u64 kml_size)
-{
- int error = 0;
- int op = rec->prefix.hdr->opcode;
-
- if (op == KML_OPCODE_CLOSE) {
- /* regular close and backfetch */
- error = reint_close(rec, dir, info);
- } else if (op == KML_OPCODE_RENAME) {
- /* rename only if name already exists */
- error = branch_reint_rename(fset, rec, dir, info,
- kml_data, kml_size);
- } else {
- /* just rewrite kml into branch/kml and update last_rcvd */
- struct rec_info rec;
-
- CDEBUG(D_KML, "Saving branch kml\n");
- rec.is_kml = 1;
- rec.size = kml_size;
- error = presto_log(fset, &rec, kml_data, kml_size,
- NULL, 0, NULL, 0, NULL, 0);
- if (error == 0)
- error = presto_write_last_rcvd(&rec, fset, info);
- }
-
- return error;
-}
-
-typedef int (*reinter_t)(struct kml_rec *rec, struct file *basedir,
- struct lento_vfs_context *info);
-
-static reinter_t presto_reinters[KML_OPCODE_NUM] =
-{
- [KML_OPCODE_CLOSE] = reint_close,
- [KML_OPCODE_CREATE] = reint_create,
- [KML_OPCODE_LINK] = reint_link,
- [KML_OPCODE_MKDIR] = reint_mkdir,
- [KML_OPCODE_MKNOD] = reint_mknod,
- [KML_OPCODE_NOOP] = reint_noop,
- [KML_OPCODE_RENAME] = reint_rename,
- [KML_OPCODE_RMDIR] = reint_rmdir,
- [KML_OPCODE_SETATTR] = reint_setattr,
- [KML_OPCODE_SYMLINK] = reint_symlink,
- [KML_OPCODE_UNLINK] = reint_unlink,
-};
-
-static inline reinter_t get_reinter(int op)
-{
- if (op < 0 || op >= sizeof(presto_reinters) / sizeof(reinter_t))
- return NULL;
- else
- return presto_reinters[op];
-}
-
-int kml_reint_rec(struct file *dir, struct izo_ioctl_data *data)
-{
- char *ptr;
- char *end;
- struct kml_rec rec;
- int error = 0;
- struct lento_vfs_context info;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
- int op;
- reinter_t reinter;
-
- struct izo_rcvd_rec lr_rec;
- int off;
-
- ENTRY;
-
- error = presto_prep(dir->f_dentry, &cache, &fset);
- if ( error ) {
- CERROR("intermezzo: Reintegration on invalid file\n");
- return error;
- }
-
- if (!dd || !dd->dd_fset || dd->dd_fset->fset_dentry != dir->f_dentry) {
- CERROR("intermezzo: reintegration on non-fset root (ino %ld)\n",
- dir->f_dentry->d_inode->i_ino);
-
- return -EINVAL;
- }
-
- if (data->ioc_plen1 > 64 * 1024) {
- EXIT;
- return -ENOSPC;
- }
-
- ptr = fset->fset_reint_buf;
- end = ptr + data->ioc_plen1;
-
- if (copy_from_user(ptr, data->ioc_pbuf1, data->ioc_plen1)) {
- EXIT;
- error = -EFAULT;
- goto out;
- }
-
- error = kml_unpack(&rec, &ptr, end);
- if (error) {
- EXIT;
- error = -EFAULT;
- goto out;
- }
-
- off = izo_rcvd_get(&lr_rec, fset, data->ioc_uuid);
- if (off < 0) {
- CERROR("No last_rcvd record, setting to 0\n");
- memset(&lr_rec, 0, sizeof(lr_rec));
- }
-
- data->ioc_kmlsize = ptr - fset->fset_reint_buf;
-
- if (rec.suffix->recno != lr_rec.lr_remote_recno + 1) {
- CERROR("KML record number %Lu expected, not %d\n",
- (unsigned long long) (lr_rec.lr_remote_recno + 1),
- rec.suffix->recno);
-
-#if 0
- if (!version_check(&rec, dd->dd_fset, &info)) {
- /* FIXME: do an upcall to resolve conflicts */
- CERROR("intermezzo: would be a conflict!\n");
- error = -EINVAL;
- EXIT;
- goto out;
- }
-#endif
- }
-
- op = rec.prefix.hdr->opcode;
-
- reinter = get_reinter(op);
- if (!reinter) {
- CERROR("%s: Unrecognized KML opcode %d\n", __FUNCTION__, op);
- error = -EINVAL;
- EXIT;
- goto out;
- }
-
- info.kml_offset = data->ioc_offset + data->ioc_kmlsize;
- info.recno = rec.suffix->recno;
- info.flags = LENTO_FL_EXPECT;
- if (data->ioc_flags)
- info.flags |= LENTO_FL_KML;
-
- memcpy(info.uuid, data->ioc_uuid, sizeof(info.uuid));
-
- if (fset->fset_flags & FSET_IS_BRANCH && data->ioc_flags)
- error = branch_reinter(fset, &rec, dir, &info, fset->fset_reint_buf,
- data->ioc_kmlsize);
- else
- error = reinter(&rec, dir, &info);
- out:
- EXIT;
- return error;
-}
-
-int izo_get_fileid(struct file *dir, struct izo_ioctl_data *data)
-{
- char *buf = NULL;
- char *ptr;
- char *end;
- struct kml_rec rec;
- struct file *file;
- struct presto_cache *cache;
- struct presto_file_set *fset;
- struct presto_dentry_data *dd = presto_d2d(dir->f_dentry);
- struct run_ctxt saved_ctxt;
- int error;
-
- ENTRY;
-
- error = presto_prep(dir->f_dentry, &cache, &fset);
- if ( error ) {
- CERROR("intermezzo: Reintegration on invalid file\n");
- return error;
- }
-
- if (!dd || !dd->dd_fset || dd->dd_fset->fset_dentry != dir->f_dentry) {
- CERROR("intermezzo: reintegration on non-fset root (ino %ld)\n",
- dir->f_dentry->d_inode->i_ino);
-
- return -EINVAL;
- }
-
-
- PRESTO_ALLOC(buf, data->ioc_plen1);
- if (!buf) {
- EXIT;
- return -ENOMEM;
- }
- ptr = buf;
- end = buf + data->ioc_plen1;
-
- if (copy_from_user(buf, data->ioc_pbuf1, data->ioc_plen1)) {
- EXIT;
- PRESTO_FREE(buf, data->ioc_plen1);
- return -EFAULT;
- }
-
- error = kml_unpack(&rec, &ptr, end);
- if (error) {
- EXIT;
- PRESTO_FREE(buf, data->ioc_plen1);
- return -EFAULT;
- }
-
- kmlreint_pre_secure(&rec, dir, &saved_ctxt);
-
- file = filp_open(rec.path, O_RDONLY, 0);
- if (!file || IS_ERR(file)) {
- error = PTR_ERR(file);
- goto out;
- }
- data->ioc_ino = file->f_dentry->d_inode->i_ino;
- data->ioc_generation = file->f_dentry->d_inode->i_generation;
- filp_close(file, 0);
-
- CDEBUG(D_FILE, "%s ino %Lx, gen %Lx\n", rec.path,
- (unsigned long long) data->ioc_ino,
- (unsigned long long) data->ioc_generation);
-
- out:
- if (buf)
- PRESTO_FREE(buf, data->ioc_plen1);
- pop_ctxt(&saved_ctxt);
- EXIT;
- return error;
-}
-
-
+++ /dev/null
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_upcall.h"
-#include "intermezzo_psdev.h"
-#include "intermezzo_kml.h"
-
-int kml_init (struct presto_file_set *fset)
-{
- struct kml_fsdata *data;
-
- ENTRY;
- PRESTO_ALLOC (data, struct kml_fsdata *, sizeof (struct kml_fsdata));
- if (data == NULL) {
- EXIT;
- return -ENOMEM;
- }
- INIT_LIST_HEAD (&data->kml_reint_cache);
- INIT_LIST_HEAD (&data->kml_kop_cache);
-
- PRESTO_ALLOC (data->kml_buf, char *, KML_REINT_MAXBUF);
- if (data->kml_buf == NULL) {
- PRESTO_FREE (data, sizeof (struct kml_fsdata));
- EXIT;
- return -ENOMEM;
- }
-
- data->kml_maxsize = KML_REINT_MAXBUF;
- data->kml_len = 0;
- data->kml_reintpos = 0;
- data->kml_count = 0;
- fset->fset_kmldata = data;
- EXIT;
- return 0;
-}
-
-int kml_cleanup (struct presto_file_set *fset)
-{
- struct kml_fsdata *data = fset->fset_kmldata;
-
- if (data == NULL)
- return 0;
-
- fset->fset_kmldata = NULL;
-#if 0
- kml_sop_cleanup (&data->kml_reint_cache);
- kml_kop_cleanup (&data->kml_kop_cache);
-#endif
- PRESTO_FREE (data->kml_buf, KML_REINT_MAXBUF);
- PRESTO_FREE (data, sizeof (struct kml_fsdata));
- return 0;
-}
-
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Unpacking of KML records
- *
- */
-
-#ifdef __KERNEL__
-# include <linux/module.h>
-# include <linux/errno.h>
-# include <linux/kernel.h>
-# include <linux/major.h>
-# include <linux/sched.h>
-# include <linux/lp.h>
-# include <linux/slab.h>
-# include <linux/ioport.h>
-# include <linux/fcntl.h>
-# include <linux/delay.h>
-# include <linux/skbuff.h>
-# include <linux/proc_fs.h>
-# include <linux/vmalloc.h>
-# include <linux/fs.h>
-# include <linux/poll.h>
-# include <linux/init.h>
-# include <linux/list.h>
-# include <linux/stat.h>
-# include <asm/io.h>
-# include <asm/segment.h>
-# include <asm/system.h>
-# include <asm/poll.h>
-# include <asm/uaccess.h>
-#else
-# include <time.h>
-# include <stdio.h>
-# include <string.h>
-# include <stdlib.h>
-# include <errno.h>
-# include <sys/stat.h>
-# include <glib.h>
-#endif
-
-#include "intermezzo_lib.h"
-#include "intermezzo_idl.h"
-#include "intermezzo_fs.h"
-
-int kml_unpack_version(struct presto_version **ver, char **buf, char *end)
-{
- char *ptr = *buf;
- struct presto_version *pv;
-
- UNLOGP(*ver, struct presto_version, ptr, end);
- pv = *ver;
- pv->pv_mtime_sec = NTOH__u32(pv->pv_mtime_sec);
- pv->pv_mtime_nsec = NTOH__u32(pv->pv_mtime_nsec);
- pv->pv_ctime_sec = NTOH__u32(pv->pv_ctime_sec);
- pv->pv_ctime_nsec = NTOH__u32(pv->pv_ctime_nsec);
- pv->pv_size = NTOH__u64(pv->pv_size);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_noop(struct kml_rec *rec, char **buf, char *end)
-{
- return 0;
-}
-
-
-static int kml_unpack_get_fileid(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
- return 0;
-}
-
-static int kml_unpack_create(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->uid, __u32, ptr, end);
- LUNLOGV(rec->gid, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_mkdir(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->uid, __u32, ptr, end);
- LUNLOGV(rec->gid, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_unlink(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- LUNLOGV(rec->old_mode, __u32, ptr, end);
- LUNLOGV(rec->old_rdev, __u32, ptr, end);
- LUNLOGV(rec->old_uid, __u64, ptr, end);
- LUNLOGV(rec->old_gid, __u64, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- LUNLOGV(rec->old_targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
- UNLOGL(rec->old_target, char, rec->old_targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_rmdir(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- LUNLOGV(rec->old_mode, __u32, ptr, end);
- LUNLOGV(rec->old_rdev, __u32, ptr, end);
- LUNLOGV(rec->old_uid, __u64, ptr, end);
- LUNLOGV(rec->old_gid, __u64, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_close(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- LUNLOGV(rec->mode, __u32, ptr, end); // used for open_mode
- LUNLOGV(rec->uid, __u32, ptr, end); // used for open_uid
- LUNLOGV(rec->gid, __u32, ptr, end); // used for open_gid
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->ino, __u64, ptr, end);
- LUNLOGV(rec->generation, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_symlink(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->uid, __u32, ptr, end);
- LUNLOGV(rec->gid, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_rename(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_setattr(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- LUNLOGV(rec->valid, __u32, ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->uid, __u32, ptr, end);
- LUNLOGV(rec->gid, __u32, ptr, end);
- LUNLOGV(rec->size, __u64, ptr, end);
- LUNLOGV(rec->mtime_sec, __u32, ptr, end);
- LUNLOGV(rec->mtime_nsec, __u32, ptr, end);
- LUNLOGV(rec->ctime_sec, __u32, ptr, end);
- LUNLOGV(rec->ctime_nsec, __u32, ptr, end);
- LUNLOGV(rec->flags, __u32, ptr, end);
- LUNLOGV(rec->old_mode, __u32, ptr, end);
- LUNLOGV(rec->old_rdev, __u32, ptr, end);
- LUNLOGV(rec->old_uid, __u64, ptr, end);
- LUNLOGV(rec->old_gid, __u64, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_link(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-static int kml_unpack_mknod(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_parentv, &ptr, end);
- kml_unpack_version(&rec->new_parentv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->uid, __u32, ptr, end);
- LUNLOGV(rec->gid, __u32, ptr, end);
- LUNLOGV(rec->major, __u32, ptr, end);
- LUNLOGV(rec->minor, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_write(struct kml_rec *rec, char **buf, char *end)
-{
- printf("NOT IMPLEMENTED");
- return 0;
-}
-
-
-static int kml_unpack_release(struct kml_rec *rec, char **buf, char *end)
-{
- printf("NOT IMPLEMENTED");
- return 0;
-}
-
-
-static int kml_unpack_trunc(struct kml_rec *rec, char **buf, char *end)
-{
- printf("NOT IMPLEMENTED");
- return 0;
-}
-
-
-static int kml_unpack_setextattr(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->flags, __u32, ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->namelen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->name, char, rec->namelen, ptr, end);
- UNLOGL(rec->target, char, rec->targetlen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-
-static int kml_unpack_delextattr(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- kml_unpack_version(&rec->old_objectv, &ptr, end);
- kml_unpack_version(&rec->new_objectv, &ptr, end);
- LUNLOGV(rec->flags, __u32, ptr, end);
- LUNLOGV(rec->mode, __u32, ptr, end);
- LUNLOGV(rec->pathlen, __u32, ptr, end);
- LUNLOGV(rec->namelen, __u32, ptr, end);
- LUNLOGV(rec->targetlen, __u32, ptr, end);
- UNLOGL(rec->path, char, rec->pathlen, ptr, end);
- UNLOGL(rec->name, char, rec->namelen, ptr, end);
-
- *buf = ptr;
-
- return 0;
-}
-
-static int kml_unpack_open(struct kml_rec *rec, char **buf, char *end)
-{
- printf("NOT IMPLEMENTED");
- return 0;
-}
-
-static int kml_unpack_kml_trunc(struct kml_rec *rec, char **buf, char *end)
-{
-
- printf("NOT IMPLEMENTED");
- return 0;
-}
-
-
-typedef int (*unpacker)(struct kml_rec *rec, char **buf, char *end);
-
-static unpacker unpackers[KML_OPCODE_NUM] =
-{
- [KML_OPCODE_NOOP] = kml_unpack_noop,
- [KML_OPCODE_CREATE] = kml_unpack_create,
- [KML_OPCODE_MKDIR] = kml_unpack_mkdir,
- [KML_OPCODE_UNLINK] = kml_unpack_unlink,
- [KML_OPCODE_RMDIR] = kml_unpack_rmdir,
- [KML_OPCODE_CLOSE] = kml_unpack_close,
- [KML_OPCODE_SYMLINK] = kml_unpack_symlink,
- [KML_OPCODE_RENAME] = kml_unpack_rename,
- [KML_OPCODE_SETATTR] = kml_unpack_setattr,
- [KML_OPCODE_LINK] = kml_unpack_link,
- [KML_OPCODE_OPEN] = kml_unpack_open,
- [KML_OPCODE_MKNOD] = kml_unpack_mknod,
- [KML_OPCODE_WRITE] = kml_unpack_write,
- [KML_OPCODE_RELEASE] = kml_unpack_release,
- [KML_OPCODE_TRUNC] = kml_unpack_trunc,
- [KML_OPCODE_SETEXTATTR] = kml_unpack_setextattr,
- [KML_OPCODE_DELEXTATTR] = kml_unpack_delextattr,
- [KML_OPCODE_KML_TRUNC] = kml_unpack_kml_trunc,
- [KML_OPCODE_GET_FILEID] = kml_unpack_get_fileid
-};
-
-int kml_unpack_prefix(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
- int n;
-
- UNLOGP(rec->prefix.hdr, struct kml_prefix_hdr, ptr, end);
- rec->prefix.hdr->len = NTOH__u32(rec->prefix.hdr->len);
- rec->prefix.hdr->version = NTOH__u32(rec->prefix.hdr->version);
- rec->prefix.hdr->pid = NTOH__u32(rec->prefix.hdr->pid);
- rec->prefix.hdr->auid = NTOH__u32(rec->prefix.hdr->auid);
- rec->prefix.hdr->fsuid = NTOH__u32(rec->prefix.hdr->fsuid);
- rec->prefix.hdr->fsgid = NTOH__u32(rec->prefix.hdr->fsgid);
- rec->prefix.hdr->opcode = NTOH__u32(rec->prefix.hdr->opcode);
- rec->prefix.hdr->ngroups = NTOH__u32(rec->prefix.hdr->ngroups);
-
- UNLOGL(rec->prefix.groups, __u32, rec->prefix.hdr->ngroups, ptr, end);
- for (n = 0; n < rec->prefix.hdr->ngroups; n++) {
- rec->prefix.groups[n] = NTOH__u32(rec->prefix.groups[n]);
- }
-
- *buf = ptr;
-
- return 0;
-}
-
-int kml_unpack_suffix(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
-
- UNLOGP(rec->suffix, struct kml_suffix, ptr, end);
- rec->suffix->prevrec = NTOH__u32(rec->suffix->prevrec);
- rec->suffix->recno = NTOH__u32(rec->suffix->recno);
- rec->suffix->time = NTOH__u32(rec->suffix->time);
- rec->suffix->len = NTOH__u32(rec->suffix->len);
-
- *buf = ptr;
-
- return 0;
-}
-
-int kml_unpack(struct kml_rec *rec, char **buf, char *end)
-{
- char *ptr = *buf;
- int err;
-
- if (((unsigned long)ptr % 4) != 0) {
- printf("InterMezzo: %s: record misaligned.\n", __FUNCTION__);
- return -EINVAL;
- }
-
- while (ptr < end) {
- __u32 *i = (__u32 *)ptr;
- if (*i)
- break;
- ptr += sizeof(*i);
- }
- *buf = ptr;
-
- memset(rec, 0, sizeof(*rec));
-
- err = kml_unpack_prefix(rec, &ptr, end);
- if (err) {
- printf("InterMezzo: %s: unpack_prefix failed: %d\n",
- __FUNCTION__, err);
- return err;
- }
-
- if (rec->prefix.hdr->opcode < 0 ||
- rec->prefix.hdr->opcode >= KML_OPCODE_NUM) {
- printf("InterMezzo: %s: invalid opcode (%d)\n",
- __FUNCTION__, rec->prefix.hdr->opcode);
- return -EINVAL;
- }
- err = unpackers[rec->prefix.hdr->opcode](rec, &ptr, end);
- if (err) {
- printf("InterMezzo: %s: unpacker failed: %d\n",
- __FUNCTION__, err);
- return err;
- }
-
- err = kml_unpack_suffix(rec, &ptr, end);
- if (err) {
- printf("InterMezzo: %s: unpack_suffix failed: %d\n",
- __FUNCTION__, err);
- return err;
- }
-
-
- if (rec->prefix.hdr->len != rec->suffix->len) {
- printf("InterMezzo: %s: lengths don't match\n",
- __FUNCTION__);
- return -EINVAL;
- }
- if ((rec->prefix.hdr->len % 4) != 0) {
- printf("InterMezzo: %s: record length not a "
- "multiple of 4.\n", __FUNCTION__);
- return -EINVAL;
- }
- if (ptr - *buf != rec->prefix.hdr->len) {
- printf("InterMezzo: %s: unpacking error\n",
- __FUNCTION__);
- return -EINVAL;
- }
- while (ptr < end) {
- __u32 *i = (__u32 *)ptr;
- if (*i)
- break;
- ptr += sizeof(*i);
- }
- *buf = ptr;
- return 0;
-}
-
-
-#ifndef __KERNEL__
-#define STR(ptr) ((ptr))? (ptr) : ""
-
-#define OPNAME(n) [KML_OPCODE_##n] = #n
-static char *opnames[KML_OPCODE_NUM] = {
- OPNAME(NOOP),
- OPNAME(CREATE),
- OPNAME(MKDIR),
- OPNAME(UNLINK),
- OPNAME(RMDIR),
- OPNAME(CLOSE),
- OPNAME(SYMLINK),
- OPNAME(RENAME),
- OPNAME(SETATTR),
- OPNAME(LINK),
- OPNAME(OPEN),
- OPNAME(MKNOD),
- OPNAME(WRITE),
- OPNAME(RELEASE),
- OPNAME(TRUNC),
- OPNAME(SETEXTATTR),
- OPNAME(DELEXTATTR),
- OPNAME(KML_TRUNC),
- OPNAME(GET_FILEID)
-};
-#undef OPNAME
-
-static char *print_opname(int op)
-{
- if (op < 0 || op >= sizeof (opnames) / sizeof (*opnames))
- return NULL;
- return opnames[op];
-}
-
-
-static char *print_time(__u64 i)
-{
- char buf[128];
-
- memset(buf, 0, 128);
-
-#ifndef __KERNEL__
- strftime(buf, 128, "%Y/%m/%d %H:%M:%S", gmtime((time_t *)&i));
-#else
- sprintf(buf, "%Ld\n", i);
-#endif
-
- return strdup(buf);
-}
-
-static char *print_version(struct presto_version *ver)
-{
- char ver_buf[128];
- char *mtime;
- char *ctime;
-
- if (!ver || ver->pv_ctime == 0) {
- return strdup("");
- }
- mtime = print_time(ver->pv_mtime);
- ctime = print_time(ver->pv_ctime);
- sprintf(ver_buf, "mtime %s, ctime %s, len %lld",
- mtime, ctime, ver->pv_size);
- free(mtime);
- free(ctime);
- return strdup(ver_buf);
-}
-
-
-char *kml_print_rec(struct kml_rec *rec, int brief)
-{
- char *str;
- char *nov, *oov, *ntv, *otv, *npv, *opv;
- char *rectime, *mtime, *ctime;
-
- if (brief) {
- str = g_strdup_printf(" %08d %7s %*s %*s",
- rec->suffix->recno,
- print_opname (rec->prefix.hdr->opcode),
- rec->pathlen, STR(rec->path),
- rec->targetlen, STR(rec->target));
-
- return str;
- }
-
- rectime = print_time(rec->suffix->time);
- mtime = print_time(rec->mtime);
- ctime = print_time(rec->ctime);
-
- nov = print_version(rec->new_objectv);
- oov = print_version(rec->old_objectv);
- ntv = print_version(rec->new_targetv);
- otv = print_version(rec->old_targetv);
- npv = print_version(rec->new_parentv);
- opv = print_version(rec->old_parentv);
-
- str = g_strdup_printf("\n -- Record:\n"
- " Recno %d\n"
- " KML off %lld\n"
- " Version %d\n"
- " Len %d\n"
- " Suf len %d\n"
- " Time %s\n"
- " Opcode %d\n"
- " Op %s\n"
- " Pid %d\n"
- " AUid %d\n"
- " Fsuid %d\n"
- " Fsgid %d\n"
- " Prevrec %d\n"
- " Ngroups %d\n"
- //" Groups @{$self->{groups}}\n"
- " -- Path:\n"
- " Inode %d\n"
- " Gen num %u\n"
- " Old mode %o\n"
- " Old rdev %x\n"
- " Old uid %llu\n"
- " Old gid %llu\n"
- " Path %*s\n"
- //" Open_mode %o\n",
- " Pathlen %d\n"
- " Tgt %*s\n"
- " Tgtlen %d\n"
- " Old Tgt %*s\n"
- " Old Tgtln %d\n"
- " -- Attr:\n"
- " Valid %x\n"
- " mode %o, uid %d, gid %d, size %lld, mtime %s, ctime %s rdev %x (%d:%d)\n"
- " -- Versions:\n"
- " New object %s\n"
- " Old object %s\n"
- " New target %s\n"
- " Old target %s\n"
- " New parent %s\n"
- " Old parent %s\n",
-
- rec->suffix->recno,
- rec->offset,
- rec->prefix.hdr->version,
- rec->prefix.hdr->len,
- rec->suffix->len,
- rectime,
- rec->prefix.hdr->opcode,
- print_opname (rec->prefix.hdr->opcode),
- rec->prefix.hdr->pid,
- rec->prefix.hdr->auid,
- rec->prefix.hdr->fsuid,
- rec->prefix.hdr->fsgid,
- rec->suffix->prevrec,
- rec->prefix.hdr->ngroups,
- rec->ino,
- rec->generation,
- rec->old_mode,
- rec->old_rdev,
- rec->old_uid,
- rec->old_gid,
- rec->pathlen,
- STR(rec->path),
- rec->pathlen,
- rec->targetlen,
- STR(rec->target),
- rec->targetlen,
- rec->old_targetlen,
- STR(rec->old_target),
- rec->old_targetlen,
-
- rec->valid,
- rec->mode,
- rec->uid,
- rec->gid,
- rec->size,
- mtime,
- ctime,
- rec->rdev, rec->major, rec->minor,
- nov, oov, ntv, otv, npv, opv);
-
- free(nov);
- free(oov);
- free(ntv);
- free(otv);
- free(npv);
- free(opv);
-
- free(rectime);
- free(ctime);
- free(mtime);
-
- return str;
-}
-#endif
+++ /dev/null
-#include <linux/list.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_kml.h"
-
-
-// dlogit -- oppsite to logit ()
-// return the sbuf + size;
-char *dlogit (void *tbuf, const void *sbuf, int size)
-{
- char *ptr = (char *)sbuf;
- memcpy(tbuf, ptr, size);
- ptr += size;
- return ptr;
-}
-
-static spinlock_t kml_lock = SPIN_LOCK_UNLOCKED;
-static char buf[1024];
-char * bdup_printf (char *format, ...)
-{
- va_list args;
- int i;
- char *path;
- unsigned long flags;
-
- spin_lock_irqsave(&kml_lock, flags);
- va_start(args, format);
- i = vsprintf(buf, format, args); /* hopefully i < sizeof(buf) */
- va_end(args);
-
- PRESTO_ALLOC (path, char *, i + 1);
- if (path == NULL)
- return NULL;
- strcpy (path, buf);
-
- spin_unlock_irqrestore(&kml_lock, flags);
- return path;
-}
-
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- * Copyright (C) 2000 Mountain View Data, Inc.
- *
- * Extended Attribute Support
- * Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/module.h>
-
-#include <linux/fsfilter.h>
-#include "intermezzo_fs.h"
-
-
-int filter_print_entry = 0;
-int filter_debug = 0xfffffff;
-/*
- * The function in this file are responsible for setting up the
- * correct methods layered file systems like InterMezzo and snapfs
- */
-
-
-static struct filter_fs filter_oppar[FILTER_FS_TYPES];
-
-/* get to the upper methods (intermezzo, snapfs) */
-inline struct super_operations *filter_c2usops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_sops;
-}
-
-inline struct inode_operations *filter_c2udiops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_dir_iops;
-}
-
-
-inline struct inode_operations *filter_c2ufiops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_file_iops;
-}
-
-inline struct inode_operations *filter_c2usiops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_sym_iops;
-}
-
-
-inline struct file_operations *filter_c2udfops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_dir_fops;
-}
-
-inline struct file_operations *filter_c2uffops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_file_fops;
-}
-
-inline struct file_operations *filter_c2usfops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_sym_fops;
-}
-
-inline struct dentry_operations *filter_c2udops(struct filter_fs *cache)
-{
- return &cache->o_fops.filter_dentry_ops;
-}
-
-/* get to the cache (lower) methods */
-inline struct super_operations *filter_c2csops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_sops;
-}
-
-inline struct inode_operations *filter_c2cdiops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_dir_iops;
-}
-
-inline struct inode_operations *filter_c2cfiops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_file_iops;
-}
-
-inline struct inode_operations *filter_c2csiops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_sym_iops;
-}
-
-inline struct file_operations *filter_c2cdfops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_dir_fops;
-}
-
-inline struct file_operations *filter_c2cffops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_file_fops;
-}
-
-inline struct file_operations *filter_c2csfops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_sym_fops;
-}
-
-inline struct dentry_operations *filter_c2cdops(struct filter_fs *cache)
-{
- return cache->o_caops.cache_dentry_ops;
-}
-
-
-void filter_setup_journal_ops(struct filter_fs *ops, char *cache_type)
-{
- if ( strlen(cache_type) == strlen("ext2") &&
- memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
-#ifdef CONFIG_EXT2_FS
- ops->o_trops = &presto_ext2_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("ext3") &&
- memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
-#if defined(CONFIG_EXT3_FS) || defined (CONFIG_EXT3_FS_MODULE)
- ops->o_trops = &presto_ext3_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("tmpfs") &&
- memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
-#if defined(CONFIG_TMPFS)
- ops->o_trops = &presto_tmpfs_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("reiserfs") &&
- memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
-#if 0
- /* #if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE) */
- ops->o_trops = &presto_reiserfs_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("xfs") &&
- memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
-#if 0
-/*#if defined(CONFIG_XFS_FS) || defined (CONFIG_XFS_FS_MODULE) */
- ops->o_trops = &presto_xfs_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("obdfs") &&
- memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
-#if defined(CONFIG_OBDFS_FS) || defined (CONFIG_OBDFS_FS_MODULE)
- ops->o_trops = presto_obdfs_journal_ops;
-#else
- ops->o_trops = NULL;
-#endif
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-}
-
-
-/* find the cache for this FS */
-struct filter_fs *filter_get_filter_fs(const char *cache_type)
-{
- struct filter_fs *ops = NULL;
- FENTRY;
-
- if ( strlen(cache_type) == strlen("ext2") &&
- memcmp(cache_type, "ext2", strlen("ext2")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_EXT2];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("xfs") &&
- memcmp(cache_type, "xfs", strlen("xfs")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_XFS];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("ext3") &&
- memcmp(cache_type, "ext3", strlen("ext3")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_EXT3];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("tmpfs") &&
- memcmp(cache_type, "tmpfs", strlen("tmpfs")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_TMPFS];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if ( strlen(cache_type) == strlen("reiserfs") &&
- memcmp(cache_type, "reiserfs", strlen("reiserfs")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_REISERFS];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
- if ( strlen(cache_type) == strlen("obdfs") &&
- memcmp(cache_type, "obdfs", strlen("obdfs")) == 0 ) {
- ops = &filter_oppar[FILTER_FS_OBDFS];
- FDEBUG(D_SUPER, "ops at %p\n", ops);
- }
-
- if (ops == NULL) {
- CERROR("prepare to die: unrecognized cache type for Filter\n");
- }
- FEXIT;
- return ops;
-}
-
-
-/*
- * Frobnicate the InterMezzo operations
- * this establishes the link between the InterMezzo file system
- * and the underlying file system used for the cache.
- */
-
-void filter_setup_super_ops(struct filter_fs *cache, struct super_operations *cache_sops, struct super_operations *filter_sops)
-{
- /* Get ptr to the shared struct snapfs_ops structure. */
- struct filter_ops *props = &cache->o_fops;
- /* Get ptr to the shared struct cache_ops structure. */
- struct cache_ops *caops = &cache->o_caops;
-
- FENTRY;
-
- if ( cache->o_flags & FILTER_DID_SUPER_OPS ) {
- FEXIT;
- return;
- }
- cache->o_flags |= FILTER_DID_SUPER_OPS;
-
- /* Set the cache superblock operations to point to the
- superblock operations of the underlying file system. */
- caops->cache_sops = cache_sops;
-
- /*
- * Copy the cache (real fs) superblock ops to the "filter"
- * superblock ops as defaults. Some will be changed below
- */
- memcpy(&props->filter_sops, cache_sops, sizeof(*cache_sops));
-
- /* 'put_super' unconditionally is that of filter */
- if (filter_sops->put_super) {
- props->filter_sops.put_super = filter_sops->put_super;
- }
-
- if (cache_sops->read_inode) {
- props->filter_sops.read_inode = filter_sops->read_inode;
- FDEBUG(D_INODE, "setting filter_read_inode, cache_ops %p, cache %p, ri at %p\n",
- cache, cache, props->filter_sops.read_inode);
- }
-
- if (cache_sops->remount_fs)
- props->filter_sops.remount_fs = filter_sops->remount_fs;
- FEXIT;
-}
-
-
-void filter_setup_dir_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
- struct inode_operations *cache_filter_iops;
- struct inode_operations *cache_iops = inode->i_op;
- struct file_operations *cache_fops = inode->i_fop;
- FENTRY;
-
- if ( cache->o_flags & FILTER_DID_DIR_OPS ) {
- FEXIT;
- return;
- }
- cache->o_flags |= FILTER_DID_DIR_OPS;
-
- /* former ops become cache_ops */
- cache->o_caops.cache_dir_iops = cache_iops;
- cache->o_caops.cache_dir_fops = cache_fops;
- FDEBUG(D_SUPER, "filter at %p, cache iops %p, iops %p\n",
- cache, cache_iops, filter_c2udiops(cache));
-
- /* setup our dir iops: copy and modify */
- memcpy(filter_c2udiops(cache), cache_iops, sizeof(*cache_iops));
-
- /* abbreviate */
- cache_filter_iops = filter_c2udiops(cache);
-
- /* methods that filter if cache filesystem has these ops */
- if (cache_iops->lookup && filter_iops->lookup)
- cache_filter_iops->lookup = filter_iops->lookup;
- if (cache_iops->create && filter_iops->create)
- cache_filter_iops->create = filter_iops->create;
- if (cache_iops->link && filter_iops->link)
- cache_filter_iops->link = filter_iops->link;
- if (cache_iops->unlink && filter_iops->unlink)
- cache_filter_iops->unlink = filter_iops->unlink;
- if (cache_iops->mkdir && filter_iops->mkdir)
- cache_filter_iops->mkdir = filter_iops->mkdir;
- if (cache_iops->rmdir && filter_iops->rmdir)
- cache_filter_iops->rmdir = filter_iops->rmdir;
- if (cache_iops->symlink && filter_iops->symlink)
- cache_filter_iops->symlink = filter_iops->symlink;
- if (cache_iops->rename && filter_iops->rename)
- cache_filter_iops->rename = filter_iops->rename;
- if (cache_iops->mknod && filter_iops->mknod)
- cache_filter_iops->mknod = filter_iops->mknod;
- if (cache_iops->permission && filter_iops->permission)
- cache_filter_iops->permission = filter_iops->permission;
- if (cache_iops->getattr)
- cache_filter_iops->getattr = filter_iops->getattr;
- /* Some filesystems do not use a setattr method of their own
- instead relying on inode_setattr/write_inode. We still need to
- journal these so we make setattr an unconditional operation.
- XXX: we should probably check for write_inode. SHP
- */
- /*if (cache_iops->setattr)*/
- cache_filter_iops->setattr = filter_iops->setattr;
-#ifdef CONFIG_FS_EXT_ATTR
- /* For now we assume that posix acls are handled through extended
- * attributes. If this is not the case, we must explicitly trap
- * posix_set_acl. SHP
- */
- if (cache_iops->set_ext_attr && filter_iops->set_ext_attr)
- cache_filter_iops->set_ext_attr = filter_iops->set_ext_attr;
-#endif
-
-
- /* copy dir fops */
- memcpy(filter_c2udfops(cache), cache_fops, sizeof(*cache_fops));
-
- /* unconditional filtering operations */
- filter_c2udfops(cache)->ioctl = filter_fops->ioctl;
-
- FEXIT;
-}
-
-
-void filter_setup_file_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
- struct inode_operations *pr_iops;
- struct inode_operations *cache_iops = inode->i_op;
- struct file_operations *cache_fops = inode->i_fop;
- FENTRY;
-
- if ( cache->o_flags & FILTER_DID_FILE_OPS ) {
- FEXIT;
- return;
- }
- cache->o_flags |= FILTER_DID_FILE_OPS;
-
- /* steal the old ops */
- /* former ops become cache_ops */
- cache->o_caops.cache_file_iops = cache_iops;
- cache->o_caops.cache_file_fops = cache_fops;
-
- /* abbreviate */
- pr_iops = filter_c2ufiops(cache);
-
- /* setup our dir iops: copy and modify */
- memcpy(pr_iops, cache_iops, sizeof(*cache_iops));
-
- /* copy dir fops */
- CERROR("*** cache file ops at %p\n", cache_fops);
- memcpy(filter_c2uffops(cache), cache_fops, sizeof(*cache_fops));
-
- /* assign */
- /* See comments above in filter_setup_dir_ops. SHP */
- /*if (cache_iops->setattr)*/
- pr_iops->setattr = filter_iops->setattr;
- if (cache_iops->getattr)
- pr_iops->getattr = filter_iops->getattr;
- /* XXX Should this be conditional rmr ? */
- pr_iops->permission = filter_iops->permission;
-#ifdef CONFIG_FS_EXT_ATTR
- /* For now we assume that posix acls are handled through extended
- * attributes. If this is not the case, we must explicitly trap and
- * posix_set_acl
- */
- if (cache_iops->set_ext_attr && filter_iops->set_ext_attr)
- pr_iops->set_ext_attr = filter_iops->set_ext_attr;
-#endif
-
-
- /* unconditional filtering operations */
- filter_c2uffops(cache)->open = filter_fops->open;
- filter_c2uffops(cache)->release = filter_fops->release;
- filter_c2uffops(cache)->write = filter_fops->write;
- filter_c2uffops(cache)->ioctl = filter_fops->ioctl;
-
- FEXIT;
-}
-
-/* XXX in 2.3 there are "fast" and "slow" symlink ops for ext2 XXX */
-void filter_setup_symlink_ops(struct filter_fs *cache, struct inode *inode, struct inode_operations *filter_iops, struct file_operations *filter_fops)
-{
- struct inode_operations *pr_iops;
- struct inode_operations *cache_iops = inode->i_op;
- struct file_operations *cache_fops = inode->i_fop;
- FENTRY;
-
- if ( cache->o_flags & FILTER_DID_SYMLINK_OPS ) {
- FEXIT;
- return;
- }
- cache->o_flags |= FILTER_DID_SYMLINK_OPS;
-
- /* steal the old ops */
- cache->o_caops.cache_sym_iops = cache_iops;
- cache->o_caops.cache_sym_fops = cache_fops;
-
- /* abbreviate */
- pr_iops = filter_c2usiops(cache);
-
- /* setup our dir iops: copy and modify */
- memcpy(pr_iops, cache_iops, sizeof(*cache_iops));
-
- /* See comments above in filter_setup_dir_ops. SHP */
- /* if (cache_iops->setattr) */
- pr_iops->setattr = filter_iops->setattr;
- if (cache_iops->getattr)
- pr_iops->getattr = filter_iops->getattr;
-
- /* assign */
- /* copy fops - careful for symlinks they might be NULL */
- if ( cache_fops ) {
- memcpy(filter_c2usfops(cache), cache_fops, sizeof(*cache_fops));
- }
-
- FEXIT;
-}
-
-void filter_setup_dentry_ops(struct filter_fs *cache,
- struct dentry_operations *cache_dop,
- struct dentry_operations *filter_dop)
-{
- if ( cache->o_flags & FILTER_DID_DENTRY_OPS ) {
- FEXIT;
- return;
- }
- cache->o_flags |= FILTER_DID_DENTRY_OPS;
-
- cache->o_caops.cache_dentry_ops = cache_dop;
- memcpy(&cache->o_fops.filter_dentry_ops,
- filter_dop, sizeof(*filter_dop));
-
- if (cache_dop && cache_dop != filter_dop && cache_dop->d_revalidate){
- CERROR("WARNING: filter overriding revalidation!\n");
- }
- return;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Author: Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 1998 Stelias Computing Inc
- * Copyright (C) 1999 Red Hat Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * This file implements basic routines supporting the semantics
- */
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/string.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-int presto_walk(const char *name, struct nameidata *nd)
-{
- int err;
- /* we do not follow symlinks to support symlink operations
- correctly. The vfs should always hand us resolved dentries
- so we should not be required to use LOOKUP_FOLLOW. At the
- reintegrating end, lento again should be working with the
- resolved pathname and not the symlink. SHP
- XXX: This code implies that direct symlinks do not work. SHP
- */
- unsigned int flags = 0; //LOOKUP_POSITIVE;
-
- ENTRY;
- err = path_lookup(name, flags, nd);
- return err;
-}
-
-
-/* find the presto minor device for this inode */
-int presto_i2m(struct inode *inode)
-{
- struct presto_cache *cache;
- ENTRY;
- cache = presto_get_cache(inode);
- CDEBUG(D_PSDEV, "\n");
- if ( !cache ) {
- CERROR("PRESTO: BAD: cannot find cache for dev %s, ino %ld\n",
- inode->i_sb->s_id, inode->i_ino);
- EXIT;
- return -1;
- }
- EXIT;
- return cache->cache_psdev->uc_minor;
-}
-
-inline int presto_f2m(struct presto_file_set *fset)
-{
- return fset->fset_cache->cache_psdev->uc_minor;
-
-}
-
-inline int presto_c2m(struct presto_cache *cache)
-{
- return cache->cache_psdev->uc_minor;
-
-}
-
-/* XXX check this out */
-struct presto_file_set *presto_path2fileset(const char *name)
-{
- struct nameidata nd;
- struct presto_file_set *fileset;
- int error;
- ENTRY;
-
- error = presto_walk(name, &nd);
- if (!error) {
-#if 0
- error = do_revalidate(nd.dentry);
-#endif
- if (!error)
- fileset = presto_fset(nd.dentry);
- path_release(&nd);
- EXIT;
- } else
- fileset = ERR_PTR(error);
-
- EXIT;
- return fileset;
-}
-
-/* check a flag on this dentry or fset root. Semantics:
- - most flags: test if it is set
- - PRESTO_ATTR, PRESTO_DATA return 1 if PRESTO_FSETINSYNC is set
-*/
-int presto_chk(struct dentry *dentry, int flag)
-{
- int minor;
- struct presto_file_set *fset = presto_fset(dentry);
-
- ENTRY;
- minor = presto_i2m(dentry->d_inode);
- if ( izo_channels[minor].uc_no_filter ) {
- EXIT;
- return ~0;
- }
-
- /* if the fileset is in sync DATA and ATTR are OK */
- if ( fset &&
- (flag == PRESTO_ATTR || flag == PRESTO_DATA) &&
- (fset->fset_flags & FSET_INSYNC) ) {
- CDEBUG(D_INODE, "fset in sync (ino %ld)!\n",
- fset->fset_dentry->d_inode->i_ino);
- EXIT;
- return 1;
- }
-
- EXIT;
- return (presto_d2d(dentry)->dd_flags & flag);
-}
-
-/* set a bit in the dentry flags */
-void presto_set(struct dentry *dentry, int flag)
-{
- ENTRY;
- if ( dentry->d_inode ) {
- CDEBUG(D_INODE, "SET ino %ld, flag %x\n",
- dentry->d_inode->i_ino, flag);
- }
- if ( presto_d2d(dentry) == NULL) {
- CERROR("dentry without d_fsdata in presto_set: %p: %*s", dentry,
- dentry->d_name.len, dentry->d_name.name);
- BUG();
- }
- presto_d2d(dentry)->dd_flags |= flag;
- EXIT;
-}
-
-/* given a path: complete the closes on the fset */
-int lento_complete_closes(char *path)
-{
- struct nameidata nd;
- struct dentry *dentry;
- int error;
- struct presto_file_set *fset;
- ENTRY;
-
- error = presto_walk(path, &nd);
- if (error) {
- EXIT;
- return error;
- }
-
- dentry = nd.dentry;
-
- error = -ENXIO;
- if ( !presto_ispresto(dentry->d_inode) ) {
- EXIT;
- goto out_complete;
- }
-
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto out_complete;
- }
-
- /* transactions and locking are internal to this function */
- error = presto_complete_lml(fset);
-
- EXIT;
- out_complete:
- path_release(&nd);
- return error;
-}
-
-#if 0
-/* given a path: write a close record and cancel an LML record, finally
- call truncate LML. Lento is doing this so it goes in with uid/gid's
- root.
-*/
-int lento_cancel_lml(char *path,
- __u64 lml_offset,
- __u64 remote_ino,
- __u32 remote_generation,
- __u32 remote_version,
- struct lento_vfs_context *info)
-{
- struct nameidata nd;
- struct rec_info rec;
- struct dentry *dentry;
- int error;
- struct presto_file_set *fset;
- void *handle;
- struct presto_version new_ver;
- ENTRY;
-
-
- error = presto_walk(path, &nd);
- if (error) {
- EXIT;
- return error;
- }
- dentry = nd.dentry;
-
- error = -ENXIO;
- if ( !presto_ispresto(dentry->d_inode) ) {
- EXIT;
- goto out_cancel_lml;
- }
-
- fset = presto_fset(dentry);
-
- error=-EINVAL;
- if (fset==NULL) {
- CERROR("No fileset!\n");
- EXIT;
- goto out_cancel_lml;
- }
-
- /* this only requires a transaction below which is automatic */
- handle = presto_trans_start(fset, dentry->d_inode, PRESTO_OP_RELEASE);
- if ( IS_ERR(handle) ) {
- error = -ENOMEM;
- EXIT;
- goto out_cancel_lml;
- }
-
- if (info->flags & LENTO_FL_CANCEL_LML) {
- error = presto_clear_lml_close(fset, lml_offset);
- if ( error ) {
- presto_trans_commit(fset, handle);
- EXIT;
- goto out_cancel_lml;
- }
- }
-
-
- if (info->flags & LENTO_FL_WRITE_KML) {
- presto_getversion(&new_ver, dentry->d_inode);
- error = presto_journal_close(&rec, fset, NULL, dentry,
- &new_ver);
- if ( error ) {
- EXIT;
- presto_trans_commit(fset, handle);
- goto out_cancel_lml;
- }
- }
-
- if (info->flags & LENTO_FL_WRITE_EXPECT) {
- error = presto_write_last_rcvd(&rec, fset, info);
- if ( error < 0 ) {
- EXIT;
- presto_trans_commit(fset, handle);
- goto out_cancel_lml;
- }
- }
-
- presto_trans_commit(fset, handle);
-
- if (info->flags & LENTO_FL_CANCEL_LML) {
- presto_truncate_lml(fset);
- }
-
-
- out_cancel_lml:
- EXIT;
- path_release(&nd);
- return error;
-}
-#endif
-
-/* given a dentry, operate on the flags in its dentry. Used by downcalls */
-int izo_mark_dentry(struct dentry *dentry, int and_flag, int or_flag,
- int *res)
-{
- int error = 0;
-
- if (presto_d2d(dentry) == NULL) {
- CERROR("InterMezzo: no ddata for inode %ld in %s\n",
- dentry->d_inode->i_ino, __FUNCTION__);
- return -EINVAL;
- }
-
- CDEBUG(D_INODE, "inode: %ld, and flag %x, or flag %x, dd_flags %x\n",
- dentry->d_inode->i_ino, and_flag, or_flag,
- presto_d2d(dentry)->dd_flags);
-
- presto_d2d(dentry)->dd_flags &= and_flag;
- presto_d2d(dentry)->dd_flags |= or_flag;
- if (res)
- *res = presto_d2d(dentry)->dd_flags;
-
- return error;
-}
-
-/* given a path, operate on the flags in its cache. Used by mark_ioctl */
-int izo_mark_cache(struct dentry *dentry, int and_flag, int or_flag,
- int *res)
-{
- struct presto_cache *cache;
-
- if (presto_d2d(dentry) == NULL) {
- CERROR("InterMezzo: no ddata for inode %ld in %s\n",
- dentry->d_inode->i_ino, __FUNCTION__);
- return -EINVAL;
- }
-
- CDEBUG(D_INODE, "inode: %ld, and flag %x, or flag %x, dd_flags %x\n",
- dentry->d_inode->i_ino, and_flag, or_flag,
- presto_d2d(dentry)->dd_flags);
-
- cache = presto_get_cache(dentry->d_inode);
- if ( !cache ) {
- CERROR("PRESTO: BAD: cannot find cache in izo_mark_cache\n");
- return -EBADF;
- }
-
- cache->cache_flags &= and_flag;
- cache->cache_flags |= or_flag;
- if (res)
- *res = (int)cache->cache_flags;
-
- return 0;
-}
-
-int presto_set_max_kml_size(const char *path, unsigned long max_size)
-{
- struct presto_file_set *fset;
-
- ENTRY;
-
- fset = presto_path2fileset(path);
- if (IS_ERR(fset)) {
- EXIT;
- return PTR_ERR(fset);
- }
-
- fset->kml_truncate_size = max_size;
- CDEBUG(D_CACHE, "KML truncate size set to %lu bytes for fset %s.\n",
- max_size, path);
-
- EXIT;
- return 0;
-}
-
-int izo_mark_fset(struct dentry *dentry, int and_flag, int or_flag,
- int * res)
-{
- struct presto_file_set *fset;
-
- fset = presto_fset(dentry);
- if ( !fset ) {
- CERROR("PRESTO: BAD: cannot find cache in izo_mark_cache\n");
- make_bad_inode(dentry->d_inode);
- return -EBADF;
- }
- fset->fset_flags &= and_flag;
- fset->fset_flags |= or_flag;
- if (res)
- *res = (int)fset->fset_flags;
-
- return 0;
-}
-
-/* talk to Lento about the permit */
-static int presto_permit_upcall(struct dentry *dentry)
-{
- int rc;
- char *path, *buffer;
- int pathlen;
- int minor;
- int fsetnamelen;
- struct presto_file_set *fset = NULL;
-
- ENTRY;
-
- if ( (minor = presto_i2m(dentry->d_inode)) < 0) {
- EXIT;
- return -EINVAL;
- }
-
- fset = presto_fset(dentry);
- if (!fset) {
- EXIT;
- return -ENOTCONN;
- }
-
- if ( !presto_lento_up(minor) ) {
- if ( fset->fset_flags & FSET_STEAL_PERMIT ) {
- EXIT;
- return 0;
- } else {
- EXIT;
- return -ENOTCONN;
- }
- }
-
- PRESTO_ALLOC(buffer, PAGE_SIZE);
- if ( !buffer ) {
- CERROR("PRESTO: out of memory!\n");
- EXIT;
- return -ENOMEM;
- }
- path = presto_path(dentry, fset->fset_dentry, buffer, PAGE_SIZE);
- pathlen = MYPATHLEN(buffer, path);
- fsetnamelen = strlen(fset->fset_name);
- rc = izo_upc_permit(minor, dentry, pathlen, path, fset->fset_name);
- PRESTO_FREE(buffer, PAGE_SIZE);
- EXIT;
- return rc;
-}
-
-/* get a write permit for the fileset of this inode
- * - if this returns a negative value there was an error
- * - if 0 is returned the permit was already in the kernel -- or --
- * Lento gave us the permit without reintegration
- * - lento returns the number of records it reintegrated
- *
- * Note that if this fileset has branches, a permit will -never- to a normal
- * process for writing in the data area (ie, outside of .intermezzo)
- */
-int presto_get_permit(struct inode * inode)
-{
- struct dentry *de;
- struct presto_file_set *fset;
- int minor = presto_i2m(inode);
- int rc = 0;
-
- ENTRY;
- if (minor < 0) {
- EXIT;
- return -1;
- }
-
- if ( ISLENTO(minor) ) {
- EXIT;
- return 0;
- }
-
- if (list_empty(&inode->i_dentry)) {
- CERROR("No alias for inode %d\n", (int) inode->i_ino);
- EXIT;
- return -EINVAL;
- }
-
- de = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
- if (presto_chk(de, PRESTO_DONT_JOURNAL)) {
- EXIT;
- return 0;
- }
-
- fset = presto_fset(de);
- if ( !fset ) {
- CERROR("Presto: no fileset in presto_get_permit!\n");
- EXIT;
- return -EINVAL;
- }
-
- if (fset->fset_flags & FSET_HAS_BRANCHES) {
- EXIT;
- return -EROFS;
- }
-
- spin_lock(&fset->fset_permit_lock);
- if (fset->fset_flags & FSET_HASPERMIT) {
- fset->fset_permit_count++;
- CDEBUG(D_INODE, "permit count now %d, inode %lx\n",
- fset->fset_permit_count, inode->i_ino);
- spin_unlock(&fset->fset_permit_lock);
- EXIT;
- return 0;
- }
-
- /* Allow reintegration to proceed without locks -SHP */
- fset->fset_permit_upcall_count++;
- if (fset->fset_permit_upcall_count == 1) {
- spin_unlock(&fset->fset_permit_lock);
- rc = presto_permit_upcall(fset->fset_dentry);
- spin_lock(&fset->fset_permit_lock);
- fset->fset_permit_upcall_count--;
- if (rc == 0) {
- izo_mark_fset(fset->fset_dentry, ~0, FSET_HASPERMIT,
- NULL);
- fset->fset_permit_count++;
- } else if (rc == ENOTCONN) {
- CERROR("InterMezzo: disconnected operation. stealing permit.\n");
- izo_mark_fset(fset->fset_dentry, ~0, FSET_HASPERMIT,
- NULL);
- fset->fset_permit_count++;
- /* set a disconnected flag here to stop upcalls */
- rc = 0;
- } else {
- CERROR("InterMezzo: presto_permit_upcall failed: %d\n", rc);
- rc = -EROFS;
- /* go to sleep here and try again? */
- }
- wake_up_interruptible(&fset->fset_permit_queue);
- } else {
- /* Someone is already doing an upcall; go to sleep. */
- DECLARE_WAITQUEUE(wait, current);
-
- spin_unlock(&fset->fset_permit_lock);
- add_wait_queue(&fset->fset_permit_queue, &wait);
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
-
- spin_lock(&fset->fset_permit_lock);
- if (fset->fset_permit_upcall_count == 0)
- break;
- spin_unlock(&fset->fset_permit_lock);
-
- if (signal_pending(current)) {
- remove_wait_queue(&fset->fset_permit_queue,
- &wait);
- return -ERESTARTSYS;
- }
- schedule();
- }
- remove_wait_queue(&fset->fset_permit_queue, &wait);
- /* We've been woken up: do we have the permit? */
- if (fset->fset_flags & FSET_HASPERMIT)
- /* FIXME: Is this the right thing? */
- rc = -EAGAIN;
- }
-
- CDEBUG(D_INODE, "permit count now %d, ino %ld (likely 1), "
- "rc %d\n", fset->fset_permit_count, inode->i_ino, rc);
- spin_unlock(&fset->fset_permit_lock);
- EXIT;
- return rc;
-}
-
-int presto_put_permit(struct inode * inode)
-{
- struct dentry *de;
- struct presto_file_set *fset;
- int minor = presto_i2m(inode);
-
- ENTRY;
- if (minor < 0) {
- EXIT;
- return -1;
- }
-
- if ( ISLENTO(minor) ) {
- EXIT;
- return 0;
- }
-
- if (list_empty(&inode->i_dentry)) {
- CERROR("No alias for inode %d\n", (int) inode->i_ino);
- EXIT;
- return -1;
- }
-
- de = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-
- fset = presto_fset(de);
- if ( !fset ) {
- CERROR("InterMezzo: no fileset in %s!\n", __FUNCTION__);
- EXIT;
- return -1;
- }
-
- if (presto_chk(de, PRESTO_DONT_JOURNAL)) {
- EXIT;
- return 0;
- }
-
- spin_lock(&fset->fset_permit_lock);
- if (fset->fset_flags & FSET_HASPERMIT) {
- if (fset->fset_permit_count > 0)
- fset->fset_permit_count--;
- else
- CERROR("Put permit while permit count is 0, "
- "inode %ld!\n", inode->i_ino);
- } else {
- fset->fset_permit_count = 0;
- CERROR("InterMezzo: put permit while no permit, inode %ld, "
- "flags %x!\n", inode->i_ino, fset->fset_flags);
- }
-
- CDEBUG(D_INODE, "permit count now %d, inode %ld\n",
- fset->fset_permit_count, inode->i_ino);
-
- if (fset->fset_flags & FSET_PERMIT_WAITING &&
- fset->fset_permit_count == 0) {
- CDEBUG(D_INODE, "permit count now 0, ino %ld, wake sleepers\n",
- inode->i_ino);
- wake_up_interruptible(&fset->fset_permit_queue);
- }
- spin_unlock(&fset->fset_permit_lock);
-
- EXIT;
- return 0;
-}
-
-void presto_getversion(struct presto_version * presto_version,
- struct inode * inode)
-{
- presto_version->pv_mtime_sec = inode->i_mtime.tv_sec;
- presto_version->pv_mtime_nsec = inode->i_mtime.tv_nsec;
- presto_version->pv_ctime_sec = inode->i_ctime.tv_sec;
- presto_version->pv_ctime_nsec = inode->i_ctime.tv_nsec;
- presto_version->pv_size = (__u64)inode->i_size;
-}
-
-
-/* If uuid is non-null, it is the uuid of the peer that's making the revocation
- * request. If it is null, this request was made locally, without external
- * pressure to give up the permit. This most often occurs when a client
- * starts up.
- *
- * FIXME: this function needs to be refactored slightly once we start handling
- * multiple clients.
- */
-int izo_revoke_permit(struct dentry *dentry, __u8 uuid[16])
-{
- struct presto_file_set *fset;
- DECLARE_WAITQUEUE(wait, current);
- int minor, rc;
-
- ENTRY;
-
- minor = presto_i2m(dentry->d_inode);
- if (minor < 0) {
- EXIT;
- return -ENODEV;
- }
-
- fset = presto_fset(dentry);
- if (fset == NULL) {
- EXIT;
- return -ENODEV;
- }
-
- spin_lock(&fset->fset_permit_lock);
- if (fset->fset_flags & FSET_PERMIT_WAITING) {
- CERROR("InterMezzo: Two processes are waiting on the same permit--this not yet supported! Aborting this particular permit request...\n");
- EXIT;
- spin_unlock(&fset->fset_permit_lock);
- return -EINVAL;
- }
-
- if (fset->fset_permit_count == 0)
- goto got_permit;
-
- /* Something is still using this permit. Mark that we're waiting for it
- * and go to sleep. */
- rc = izo_mark_fset(dentry, ~0, FSET_PERMIT_WAITING, NULL);
- spin_unlock(&fset->fset_permit_lock);
- if (rc < 0) {
- EXIT;
- return rc;
- }
-
- add_wait_queue(&fset->fset_permit_queue, &wait);
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
-
- spin_lock(&fset->fset_permit_lock);
- if (fset->fset_permit_count == 0)
- break;
- spin_unlock(&fset->fset_permit_lock);
-
- if (signal_pending(current)) {
- /* FIXME: there must be a better thing to return... */
- remove_wait_queue(&fset->fset_permit_queue, &wait);
- EXIT;
- return -ERESTARTSYS;
- }
-
- /* FIXME: maybe there should be a timeout here. */
-
- schedule();
- }
-
- remove_wait_queue(&fset->fset_permit_queue, &wait);
- got_permit:
- /* By this point fset->fset_permit_count is zero and we're holding the
- * lock. */
- CDEBUG(D_CACHE, "InterMezzo: releasing permit inode %ld\n",
- dentry->d_inode->i_ino);
-
- if (uuid != NULL) {
- rc = izo_upc_revoke_permit(minor, fset->fset_name, uuid);
- if (rc < 0) {
- spin_unlock(&fset->fset_permit_lock);
- EXIT;
- return rc;
- }
- }
-
- izo_mark_fset(fset->fset_dentry, ~FSET_PERMIT_WAITING, 0, NULL);
- izo_mark_fset(fset->fset_dentry, ~FSET_HASPERMIT, 0, NULL);
- spin_unlock(&fset->fset_permit_lock);
- EXIT;
- return 0;
-}
-
-inline int presto_is_read_only(struct presto_file_set * fset)
-{
- int minor, mask;
- struct presto_cache *cache = fset->fset_cache;
-
- minor= cache->cache_psdev->uc_minor;
- mask= (ISLENTO(minor)? FSET_LENTO_RO : FSET_CLIENT_RO);
- if ( fset->fset_flags & mask )
- return 1;
- mask= (ISLENTO(minor)? CACHE_LENTO_RO : CACHE_CLIENT_RO);
- return ((cache->cache_flags & mask)? 1 : 0);
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * An implementation of a loadable kernel mode driver providing
- * multiple kernel/user space bidirectional communications links.
- *
- * Author: Alan Cox <alan@cymru.net>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * Adapted to become the Linux 2.0 Coda pseudo device
- * Peter Braam <braam@maths.ox.ac.uk>
- * Michael Callahan <mjc@emmy.smith.edu>
- *
- * Changes for Linux 2.1
- * Copyright (c) 1997 Carnegie-Mellon University
- *
- * Redone again for InterMezzo
- * Copyright (c) 1998 Peter J. Braam
- * Copyright (c) 2000 Mountain View Data, Inc.
- * Copyright (c) 2000 Tacitus Systems, Inc.
- * Copyright (c) 2001 Cluster File Systems, Inc.
- *
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/major.h>
-#include <linux/sched.h>
-#include <linux/lp.h>
-#include <linux/slab.h>
-#include <linux/ioport.h>
-#include <linux/fcntl.h>
-#include <linux/delay.h>
-#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/list.h>
-#include <linux/devfs_fs_kernel.h>
-#include <asm/io.h>
-#include <asm/segment.h>
-#include <asm/system.h>
-#include <asm/poll.h>
-#include <asm/uaccess.h>
-#include <linux/miscdevice.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-
-#ifdef PRESTO_DEVEL
-int presto_print_entry = 1;
-int presto_debug = 4095;
-#else
-int presto_print_entry = 0;
-int presto_debug = 0;
-#endif
-
-/* Like inode.c (presto_sym_iops), the initializer is just to prevent
- izo_channels from appearing as a COMMON symbol (and therefore
- interfering with other modules that use the same variable name). */
-struct upc_channel izo_channels[MAX_CHANNEL] = {{0}};
-
-int izo_psdev_get_free_channel(void)
-{
- int i, result = -1;
-
- for (i = 0 ; i < MAX_CHANNEL ; i++ ) {
- if (list_empty(&(izo_channels[i].uc_cache_list))) {
- result = i;
- break;
- }
- }
- return result;
-}
-
-
-int izo_psdev_setpid(int minor)
-{
- struct upc_channel *channel;
- if (minor < 0 || minor >= MAX_CHANNEL) {
- return -EINVAL;
- }
-
- channel = &(izo_channels[minor]);
- /*
- * This ioctl is performed by each Lento that starts up
- * and wants to do further communication with presto.
- */
- CDEBUG(D_PSDEV, "Setting current pid to %d channel %d\n",
- current->pid, minor);
- channel->uc_pid = current->pid;
- spin_lock(&channel->uc_lock);
- if ( !list_empty(&channel->uc_processing) ) {
- struct list_head *lh;
- struct upc_req *req;
- CERROR("WARNING: setpid & processing not empty!\n");
- list_for_each(lh, &channel->uc_processing) {
- req = list_entry(lh, struct upc_req, rq_chain);
- /* freeing of req and data is done by the sleeper */
- wake_up(&req->rq_sleep);
- }
- }
- if ( !list_empty(&channel->uc_processing) ) {
- CERROR("BAD: FAILDED TO CLEAN PROCESSING LIST!\n");
- }
- spin_unlock(&channel->uc_lock);
- EXIT;
- return 0;
-}
-
-int izo_psdev_setchannel(struct file *file, int fd)
-{
-
- struct file *psdev_file = fget(fd);
- struct presto_cache *cache = presto_get_cache(file->f_dentry->d_inode);
-
- if (!psdev_file) {
- CERROR("%s: no psdev_file!\n", __FUNCTION__);
- return -EINVAL;
- }
-
- if (!cache) {
- CERROR("%s: no cache!\n", __FUNCTION__);
- fput(psdev_file);
- return -EINVAL;
- }
-
- if (psdev_file->private_data) {
- CERROR("%s: channel already set!\n", __FUNCTION__);
- fput(psdev_file);
- return -EINVAL;
- }
-
- psdev_file->private_data = cache->cache_psdev;
- fput(psdev_file);
- EXIT;
- return 0;
-}
-
-inline int presto_lento_up(int minor)
-{
- return izo_channels[minor].uc_pid;
-}
-
-static unsigned int presto_psdev_poll(struct file *file, poll_table * wait)
- {
- struct upc_channel *channel = (struct upc_channel *)file->private_data;
- unsigned int mask = POLLOUT | POLLWRNORM;
-
- /* ENTRY; this will flood you */
- if ( ! channel ) {
- CERROR("%s: bad psdev file\n", __FUNCTION__);
- return -EBADF;
- }
-
- poll_wait(file, &(channel->uc_waitq), wait);
-
- spin_lock(&channel->uc_lock);
- if (!list_empty(&channel->uc_pending)) {
- CDEBUG(D_PSDEV, "Non-empty pending list.\n");
- mask |= POLLIN | POLLRDNORM;
- }
- spin_unlock(&channel->uc_lock);
-
- /* EXIT; will flood you */
- return mask;
-}
-
-/*
- * Receive a message written by Lento to the psdev
- */
-static ssize_t presto_psdev_write(struct file *file, const char *buf,
- size_t count, loff_t *off)
-{
- struct upc_channel *channel = (struct upc_channel *)file->private_data;
- struct upc_req *req = NULL;
- struct upc_req *tmp;
- struct list_head *lh;
- struct izo_upcall_resp hdr;
- int error;
-
- if ( ! channel ) {
- CERROR("%s: bad psdev file\n", __FUNCTION__);
- return -EBADF;
- }
-
- /* Peek at the opcode, uniquefier */
- if ( count < sizeof(hdr) ) {
- CERROR("presto_psdev_write: Lento didn't write full hdr.\n");
- return -EINVAL;
- }
-
- error = copy_from_user(&hdr, buf, sizeof(hdr));
- if ( error )
- return -EFAULT;
-
- CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%d,%d)\n",
- current->pid, hdr.opcode, hdr.unique);
-
- spin_lock(&channel->uc_lock);
- /* Look for the message on the processing queue. */
- list_for_each(lh, &channel->uc_processing) {
- tmp = list_entry(lh, struct upc_req , rq_chain);
- if (tmp->rq_unique == hdr.unique) {
- req = tmp;
- /* unlink here: keeps search length minimal */
- list_del_init(&req->rq_chain);
- CDEBUG(D_PSDEV,"Eureka opc %d uniq %d!\n",
- hdr.opcode, hdr.unique);
- break;
- }
- }
- spin_unlock(&channel->uc_lock);
- if (!req) {
- CERROR("psdev_write: msg (%d, %d) not found\n",
- hdr.opcode, hdr.unique);
- return(-ESRCH);
- }
-
- /* move data into response buffer. */
- if (req->rq_bufsize < count) {
- CERROR("psdev_write: too much cnt: %d, cnt: %Zd, "
- "opc: %d, uniq: %d.\n",
- req->rq_bufsize, count, hdr.opcode, hdr.unique);
- count = req->rq_bufsize; /* don't have more space! */
- }
- error = copy_from_user(req->rq_data, buf, count);
- if ( error )
- return -EFAULT;
-
- /* adjust outsize: good upcalls can be aware of this */
- req->rq_rep_size = count;
- req->rq_flags |= REQ_WRITE;
-
- wake_up(&req->rq_sleep);
- return(count);
-}
-
-/*
- * Read a message from the kernel to Lento
- */
-static ssize_t presto_psdev_read(struct file * file, char * buf,
- size_t count, loff_t *off)
-{
- struct upc_channel *channel = (struct upc_channel *)file->private_data;
- struct upc_req *req;
- int result = count;
-
- if ( ! channel ) {
- CERROR("%s: bad psdev file\n", __FUNCTION__);
- return -EBADF;
- }
-
- spin_lock(&channel->uc_lock);
- if (list_empty(&(channel->uc_pending))) {
- CDEBUG(D_UPCALL, "Empty pending list in read, not good\n");
- spin_unlock(&channel->uc_lock);
- return -EINVAL;
- }
- req = list_entry((channel->uc_pending.next), struct upc_req, rq_chain);
- list_del(&(req->rq_chain));
- if (! (req->rq_flags & REQ_ASYNC) ) {
- list_add(&(req->rq_chain), channel->uc_processing.prev);
- }
- spin_unlock(&channel->uc_lock);
-
- req->rq_flags |= REQ_READ;
-
- /* Move the input args into userspace */
- CDEBUG(D_PSDEV, "\n");
- if (req->rq_bufsize <= count) {
- result = req->rq_bufsize;
- }
-
- if (count < req->rq_bufsize) {
- CERROR ("psdev_read: buffer too small, read %Zd of %d bytes\n",
- count, req->rq_bufsize);
- }
-
- if ( copy_to_user(buf, req->rq_data, result) ) {
- BUG();
- return -EFAULT;
- }
-
- /* If request was asynchronous don't enqueue, but free */
- if (req->rq_flags & REQ_ASYNC) {
- CDEBUG(D_PSDEV, "psdev_read: async msg (%d, %d), result %d\n",
- req->rq_opcode, req->rq_unique, result);
- PRESTO_FREE(req->rq_data, req->rq_bufsize);
- PRESTO_FREE(req, sizeof(*req));
- return result;
- }
-
- return result;
-}
-
-
-static int presto_psdev_open(struct inode * inode, struct file * file)
-{
- ENTRY;
-
- file->private_data = NULL;
-
- CDEBUG(D_PSDEV, "Psdev_open: caller: %d, flags: %d\n", current->pid, file->f_flags);
-
- EXIT;
- return 0;
-}
-
-
-
-static int presto_psdev_release(struct inode * inode, struct file * file)
-{
- struct upc_channel *channel = (struct upc_channel *)file->private_data;
- struct upc_req *req;
- struct list_head *lh;
- ENTRY;
-
- if ( ! channel ) {
- CERROR("%s: bad psdev file\n", __FUNCTION__);
- return -EBADF;
- }
-
- CDEBUG(D_PSDEV, "Lento: pid %d\n", current->pid);
- channel->uc_pid = 0;
-
- /* Wake up clients so they can return. */
- CDEBUG(D_PSDEV, "Wake up clients sleeping for pending.\n");
- spin_lock(&channel->uc_lock);
- list_for_each(lh, &channel->uc_pending) {
- req = list_entry(lh, struct upc_req, rq_chain);
-
- /* Async requests stay around for a new lento */
- if (req->rq_flags & REQ_ASYNC) {
- continue;
- }
- /* the sleeper will free the req and data */
- req->rq_flags |= REQ_DEAD;
- wake_up(&req->rq_sleep);
- }
-
- CDEBUG(D_PSDEV, "Wake up clients sleeping for processing\n");
- list_for_each(lh, &channel->uc_processing) {
- req = list_entry(lh, struct upc_req, rq_chain);
- /* freeing of req and data is done by the sleeper */
- req->rq_flags |= REQ_DEAD;
- wake_up(&req->rq_sleep);
- }
- spin_unlock(&channel->uc_lock);
- CDEBUG(D_PSDEV, "Done.\n");
-
- EXIT;
- return 0;
-}
-
-static struct file_operations presto_psdev_fops = {
- .owner = THIS_MODULE,
- .read = presto_psdev_read,
- .write = presto_psdev_write,
- .poll = presto_psdev_poll,
- .open = presto_psdev_open,
- .release = presto_psdev_release
-};
-
-/* modules setup */
-static struct miscdevice intermezzo_psdev = {
- INTERMEZZO_MINOR,
- "intermezzo",
- &presto_psdev_fops
-};
-
-int presto_psdev_init(void)
-{
- int i;
- int err;
-
- if ( (err = misc_register(&intermezzo_psdev)) ) {
- CERROR("%s: cannot register %d err %d\n",
- __FUNCTION__, INTERMEZZO_MINOR, err);
- return -EIO;
- }
-
- memset(&izo_channels, 0, sizeof(izo_channels));
- for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
- struct upc_channel *channel = &(izo_channels[i]);
- INIT_LIST_HEAD(&channel->uc_pending);
- INIT_LIST_HEAD(&channel->uc_processing);
- INIT_LIST_HEAD(&channel->uc_cache_list);
- init_waitqueue_head(&channel->uc_waitq);
- channel->uc_lock = SPIN_LOCK_UNLOCKED;
- channel->uc_hard = 0;
- channel->uc_no_filter = 0;
- channel->uc_no_journal = 0;
- channel->uc_no_upcall = 0;
- channel->uc_timeout = 30;
- channel->uc_errorval = 0;
- channel->uc_minor = i;
- }
- return 0;
-}
-
-void presto_psdev_cleanup(void)
-{
- int i;
-
- misc_deregister(&intermezzo_psdev);
-
- for ( i = 0 ; i < MAX_CHANNEL ; i++ ) {
- struct upc_channel *channel = &(izo_channels[i]);
- struct list_head *lh, *next;
-
- spin_lock(&channel->uc_lock);
- if ( ! list_empty(&channel->uc_pending)) {
- CERROR("Weird, tell Peter: module cleanup and pending list not empty dev %d\n", i);
- }
- if ( ! list_empty(&channel->uc_processing)) {
- CERROR("Weird, tell Peter: module cleanup and processing list not empty dev %d\n", i);
- }
- if ( ! list_empty(&channel->uc_cache_list)) {
- CERROR("Weird, tell Peter: module cleanup and cache listnot empty dev %d\n", i);
- }
- list_for_each_safe(lh, next, &channel->uc_pending) {
- struct upc_req *req;
-
- req = list_entry(lh, struct upc_req, rq_chain);
- if ( req->rq_flags & REQ_ASYNC ) {
- list_del(&(req->rq_chain));
- CDEBUG(D_UPCALL, "free pending upcall type %d\n",
- req->rq_opcode);
- PRESTO_FREE(req->rq_data, req->rq_bufsize);
- PRESTO_FREE(req, sizeof(struct upc_req));
- } else {
- req->rq_flags |= REQ_DEAD;
- wake_up(&req->rq_sleep);
- }
- }
- list_for_each(lh, &channel->uc_processing) {
- struct upc_req *req;
- req = list_entry(lh, struct upc_req, rq_chain);
- list_del(&(req->rq_chain));
- req->rq_flags |= REQ_DEAD;
- wake_up(&req->rq_sleep);
- }
- spin_unlock(&channel->uc_lock);
- }
-}
-
-/*
- * lento_upcall and lento_downcall routines
- */
-static inline unsigned long lento_waitfor_upcall
- (struct upc_channel *channel, struct upc_req *req, int minor)
-{
- DECLARE_WAITQUEUE(wait, current);
- unsigned long posttime;
-
- req->rq_posttime = posttime = jiffies;
-
- add_wait_queue(&req->rq_sleep, &wait);
- for (;;) {
- if ( izo_channels[minor].uc_hard == 0 )
- set_current_state(TASK_INTERRUPTIBLE);
- else
- set_current_state(TASK_UNINTERRUPTIBLE);
-
- /* got a reply */
- if ( req->rq_flags & (REQ_WRITE | REQ_DEAD) )
- break;
-
- /* these cases only apply when TASK_INTERRUPTIBLE */
- if ( !izo_channels[minor].uc_hard && signal_pending(current) ) {
- /* if this process really wants to die, let it go */
- if (sigismember(&(current->pending.signal), SIGKILL)||
- sigismember(&(current->pending.signal), SIGINT) )
- break;
- /* signal is present: after timeout always return
- really smart idea, probably useless ... */
- if ( time_after(jiffies, req->rq_posttime +
- izo_channels[minor].uc_timeout * HZ) )
- break;
- }
- schedule();
- }
-
- spin_lock(&channel->uc_lock);
- list_del_init(&req->rq_chain);
- spin_unlock(&channel->uc_lock);
- remove_wait_queue(&req->rq_sleep, &wait);
- set_current_state(TASK_RUNNING);
-
- CDEBUG(D_SPECIAL, "posttime: %ld, returned: %ld\n",
- posttime, jiffies-posttime);
- return (jiffies - posttime);
-}
-
-/*
- * lento_upcall will return an error in the case of
- * failed communication with Lento _or_ will peek at Lento
- * reply and return Lento's error.
- *
- * As lento has 2 types of errors, normal errors (positive) and internal
- * errors (negative), normal errors are negated, while internal errors
- * are all mapped to -EINTR, while showing a nice warning message. (jh)
- *
- * lento_upcall will always free buffer, either directly, when an upcall
- * is read (in presto_psdev_read), when the filesystem is unmounted, or
- * when the module is unloaded.
- */
-int izo_upc_upcall(int minor, int *size, struct izo_upcall_hdr *buffer,
- int async)
-{
- unsigned long runtime;
- struct upc_channel *channel;
- struct izo_upcall_resp *out;
- struct upc_req *req;
- int error = 0;
-
- ENTRY;
- channel = &(izo_channels[minor]);
-
- if (channel->uc_no_upcall) {
- EXIT;
- goto exit_buf;
- }
- if (!channel->uc_pid && !async) {
- EXIT;
- error = -ENXIO;
- goto exit_buf;
- }
-
- /* Format the request message. */
- PRESTO_ALLOC(req, sizeof(struct upc_req));
- if ( !req ) {
- EXIT;
- error = -ENOMEM;
- goto exit_buf;
- }
- req->rq_data = (void *)buffer;
- req->rq_flags = 0;
- req->rq_bufsize = *size;
- req->rq_rep_size = 0;
- req->rq_opcode = buffer->u_opc;
- req->rq_unique = ++channel->uc_seq;
- init_waitqueue_head(&req->rq_sleep);
-
- /* Fill in the common input args. */
- buffer->u_uniq = req->rq_unique;
- buffer->u_async = async;
-
- /* Remove potential datarace possibility*/
- if ( async )
- req->rq_flags = REQ_ASYNC;
-
- spin_lock(&channel->uc_lock);
- /* Append msg to pending queue and poke Lento. */
- list_add(&req->rq_chain, channel->uc_pending.prev);
- spin_unlock(&channel->uc_lock);
- CDEBUG(D_UPCALL,
- "Proc %d waking Lento %d for(opc,uniq) =(%d,%d) msg at %p.\n",
- current->pid, channel->uc_pid, req->rq_opcode,
- req->rq_unique, req);
- wake_up_interruptible(&channel->uc_waitq);
-
- if ( async ) {
- /* req, rq_data are freed in presto_psdev_read for async */
- /* req->rq_flags = REQ_ASYNC;*/
- EXIT;
- return 0;
- }
-
- /* We can be interrupted while we wait for Lento to process
- * our request. If the interrupt occurs before Lento has read
- * the request, we dequeue and return. If it occurs after the
- * read but before the reply, we dequeue, send a signal
- * message, and return. If it occurs after the reply we ignore
- * it. In no case do we want to restart the syscall. If it
- * was interrupted by a lento shutdown (psdev_close), return
- * ENODEV. */
-
- /* Go to sleep. Wake up on signals only after the timeout. */
- runtime = lento_waitfor_upcall(channel, req, minor);
-
- CDEBUG(D_TIMING, "opc: %d time: %ld uniq: %d size: %d\n",
- req->rq_opcode, jiffies - req->rq_posttime,
- req->rq_unique, req->rq_rep_size);
- CDEBUG(D_UPCALL,
- "..process %d woken up by Lento for req at 0x%p, data at %p\n",
- current->pid, req, req->rq_data);
-
- if (channel->uc_pid) { /* i.e. Lento is still alive */
- /* Op went through, interrupt or not we go on */
- if (req->rq_flags & REQ_WRITE) {
- out = (struct izo_upcall_resp *)req->rq_data;
- /* here we map positive Lento errors to kernel errors */
- if ( out->result < 0 ) {
- CERROR("Tell Peter: Lento returns negative error %d, for oc %d!\n",
- out->result, out->opcode);
- out->result = EINVAL;
- }
- error = -out->result;
- CDEBUG(D_UPCALL, "upcall: (u,o,r) (%d, %d, %d) out at %p\n",
- out->unique, out->opcode, out->result, out);
- *size = req->rq_rep_size;
- EXIT;
- goto exit_req;
- }
- /* Interrupted before lento read it. */
- if ( !(req->rq_flags & REQ_READ) && signal_pending(current)) {
- CDEBUG(D_UPCALL,
- "Interrupt before read: (op,un)=(%d,%d), flags %x\n",
- req->rq_opcode, req->rq_unique, req->rq_flags);
- /* perhaps the best way to convince the app to give up? */
- error = -EINTR;
- EXIT;
- goto exit_req;
- }
-
- /* interrupted after Lento did its read, send signal */
- if ( (req->rq_flags & REQ_READ) && signal_pending(current) ) {
- CDEBUG(D_UPCALL,"Interrupt after read: op = %d.%d, flags = %x\n",
- req->rq_opcode, req->rq_unique, req->rq_flags);
-
- error = -EINTR;
- } else {
- CERROR("Lento: Strange interruption - tell Peter.\n");
- error = -EINTR;
- }
- } else { /* If lento died i.e. !UC_OPEN(channel) */
- CERROR("lento_upcall: Lento dead on (op,un) (%d.%d) flags %d\n",
- req->rq_opcode, req->rq_unique, req->rq_flags);
- error = -ENODEV;
- }
-
-exit_req:
- PRESTO_FREE(req, sizeof(struct upc_req));
-exit_buf:
- PRESTO_FREE(buffer,*size);
- return error;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Manage RCVD records for clients in the kernel
- *
- */
-
-#include <linux/module.h>
-#include <asm/uaccess.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/fsfilter.h>
-
-#include "intermezzo_fs.h"
-
-/*
- * this file contains a hash table of replicators/clients for a
- * fileset. It allows fast lookup and update of reintegration status
- */
-
-struct izo_offset_rec {
- struct list_head or_list;
- char or_uuid[16];
- loff_t or_offset;
-};
-
-#define RCACHE_BITS 8
-#define RCACHE_SIZE (1 << RCACHE_BITS)
-#define RCACHE_MASK (RCACHE_SIZE - 1)
-
-static struct list_head *
-izo_rep_cache(void)
-{
- int i;
- struct list_head *cache;
- PRESTO_ALLOC(cache, sizeof(struct list_head) * RCACHE_SIZE);
- if (cache == NULL) {
- CERROR("intermezzo-fatal: no memory for replicator cache\n");
- return NULL;
- }
- memset(cache, 0, sizeof(struct list_head) * RCACHE_SIZE);
- for (i = 0; i < RCACHE_SIZE; i++)
- INIT_LIST_HEAD(&cache[i]);
-
- return cache;
-}
-
-static struct list_head *
-izo_rep_hash(struct list_head *cache, char *uuid)
-{
- return &cache[(RCACHE_MASK & uuid[1])];
-}
-
-static void
-izo_rep_cache_clean(struct presto_file_set *fset)
-{
- int i;
- struct list_head *bucket;
- struct list_head *tmp;
-
- if (fset->fset_clients == NULL)
- return;
- for (i = 0; i < RCACHE_SIZE; i++) {
- tmp = bucket = &fset->fset_clients[i];
-
- tmp = tmp->next;
- while (tmp != bucket) {
- struct izo_offset_rec *offrec;
- tmp = tmp->next;
- list_del(tmp);
- offrec = list_entry(tmp, struct izo_offset_rec,
- or_list);
- PRESTO_FREE(offrec, sizeof(struct izo_offset_rec));
- }
- }
-}
-
-struct izo_offset_rec *
-izo_rep_cache_find(struct presto_file_set *fset, char *uuid)
-{
- struct list_head *tmp, *buck = izo_rep_hash(fset->fset_clients, uuid);
- struct izo_offset_rec *rec = NULL;
-
- list_for_each(tmp, buck) {
- rec = list_entry(tmp, struct izo_offset_rec, or_list);
- if ( memcmp(rec->or_uuid, uuid, sizeof(rec->or_uuid)) == 0 )
- return rec;
- }
-
- return NULL;
-}
-
-static int
-izo_rep_cache_add(struct presto_file_set *fset, struct izo_rcvd_rec *rec,
- loff_t offset)
-{
- struct izo_offset_rec *offrec;
-
- if (izo_rep_cache_find(fset, rec->lr_uuid)) {
- CERROR("izo: duplicate client entry %s off %Ld\n",
- fset->fset_name, offset);
- return -EINVAL;
- }
-
- PRESTO_ALLOC(offrec, sizeof(*offrec));
- if (offrec == NULL) {
- CERROR("izo: cannot allocate offrec\n");
- return -ENOMEM;
- }
-
- memcpy(offrec->or_uuid, rec->lr_uuid, sizeof(rec->lr_uuid));
- offrec->or_offset = offset;
-
- list_add(&offrec->or_list,
- izo_rep_hash(fset->fset_clients, rec->lr_uuid));
- return 0;
-}
-
-int
-izo_rep_cache_init(struct presto_file_set *fset)
-{
- struct izo_rcvd_rec rec;
- loff_t offset = 0, last_offset = 0;
-
- fset->fset_clients = izo_rep_cache();
- if (fset->fset_clients == NULL) {
- CERROR("Error initializing client cache\n");
- return -ENOMEM;
- }
-
- while ( presto_fread(fset->fset_rcvd.fd_file, (char *)&rec,
- sizeof(rec), &offset) == sizeof(rec) ) {
- int rc;
-
- if ((rc = izo_rep_cache_add(fset, &rec, last_offset)) < 0) {
- izo_rep_cache_clean(fset);
- return rc;
- }
-
- last_offset = offset;
- }
-
- return 0;
-}
-
-/*
- * Return local last_rcvd record for the client. Update or create
- * if necessary.
- *
- * XXX: After this call, any -EINVAL from izo_rcvd_get is a real error.
- */
-int
-izo_repstatus(struct presto_file_set *fset, __u64 client_kmlsize,
- struct izo_rcvd_rec *lr_client, struct izo_rcvd_rec *lr_server)
-{
- int rc;
- rc = izo_rcvd_get(lr_server, fset, lr_client->lr_uuid);
- if (rc < 0 && rc != -EINVAL) {
- return rc;
- }
-
- /* client is new or has been reset. */
- if (rc < 0 || (client_kmlsize == 0 && lr_client->lr_remote_offset == 0)) {
- memset(lr_server, 0, sizeof(*lr_server));
- memcpy(lr_server->lr_uuid, lr_client->lr_uuid, sizeof(lr_server->lr_uuid));
- rc = izo_rcvd_write(fset, lr_server);
- if (rc < 0)
- return rc;
- }
-
- /* update intersync */
- rc = izo_upc_repstatus(presto_f2m(fset), fset->fset_name, lr_server);
- return rc;
-}
-
-loff_t
-izo_rcvd_get(struct izo_rcvd_rec *rec, struct presto_file_set *fset, char *uuid)
-{
- struct izo_offset_rec *offrec;
- struct izo_rcvd_rec tmprec;
- loff_t offset;
-
- offrec = izo_rep_cache_find(fset, uuid);
- if (offrec == NULL) {
- CDEBUG(D_SPECIAL, "izo_get_rcvd: uuid not in hash.\n");
- return -EINVAL;
- }
- offset = offrec->or_offset;
-
- if (rec == NULL)
- return offset;
-
- if (presto_fread(fset->fset_rcvd.fd_file, (char *)&tmprec,
- sizeof(tmprec), &offset) != sizeof(tmprec)) {
- CERROR("izo_get_rcvd: Unable to read from last_rcvd file offset "
- "%Lu\n", offset);
- return -EIO;
- }
-
- memcpy(rec->lr_uuid, tmprec.lr_uuid, sizeof(tmprec.lr_uuid));
- rec->lr_remote_recno = le64_to_cpu(tmprec.lr_remote_recno);
- rec->lr_remote_offset = le64_to_cpu(tmprec.lr_remote_offset);
- rec->lr_local_recno = le64_to_cpu(tmprec.lr_local_recno);
- rec->lr_local_offset = le64_to_cpu(tmprec.lr_local_offset);
- rec->lr_last_ctime = le64_to_cpu(tmprec.lr_last_ctime);
-
- return offrec->or_offset;
-}
-
-/* Try to lookup the UUID in the hash. Insert it if it isn't found. Write the
- * data to the file.
- *
- * Returns the offset of the beginning of the record in the last_rcvd file. */
-loff_t
-izo_rcvd_write(struct presto_file_set *fset, struct izo_rcvd_rec *rec)
-{
- struct izo_offset_rec *offrec;
- loff_t offset, rc;
-
- ENTRY;
-
- offrec = izo_rep_cache_find(fset, rec->lr_uuid);
- if (offrec == NULL) {
- /* I don't think it should be possible for an entry to be not in
- * the hash table without also having an invalid offset, but we
- * handle it gracefully regardless. */
- write_lock(&fset->fset_rcvd.fd_lock);
- offset = fset->fset_rcvd.fd_offset;
- fset->fset_rcvd.fd_offset += sizeof(*rec);
- write_unlock(&fset->fset_rcvd.fd_lock);
-
- rc = izo_rep_cache_add(fset, rec, offset);
- if (rc < 0) {
- EXIT;
- return rc;
- }
- } else
- offset = offrec->or_offset;
-
-
- rc = presto_fwrite(fset->fset_rcvd.fd_file, (char *)rec, sizeof(*rec),
- &offset);
- if (rc == sizeof(*rec))
- /* presto_fwrite() advances 'offset' */
- rc = offset - sizeof(*rec);
-
- EXIT;
- return rc;
-}
-
-loff_t
-izo_rcvd_upd_remote(struct presto_file_set *fset, char * uuid, __u64 remote_recno,
- __u64 remote_offset)
-{
- struct izo_rcvd_rec rec;
-
- loff_t rc;
-
- ENTRY;
- rc = izo_rcvd_get(&rec, fset, uuid);
- if (rc < 0)
- return rc;
- rec.lr_remote_recno = remote_recno;
- rec.lr_remote_offset = remote_offset;
-
- rc = izo_rcvd_write(fset, &rec);
- EXIT;
- if (rc < 0)
- return rc;
- return 0;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * presto's super.c
- */
-
-static char rcsid[] __attribute ((unused)) = "$Id: super.c,v 1.4 2002/10/12 02:16:19 rread Exp $";
-#define INTERMEZZO_VERSION "$Revision: 1.4 $"
-
-#include <asm/bitops.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/ext2_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/sched.h>
-#include <linux/stat.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/init.h>
-#include <linux/devfs_fs_kernel.h>
-#include <linux/module.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef PRESTO_DEBUG
-long presto_vmemory = 0;
-long presto_kmemory = 0;
-#endif
-
-/* returns an allocated string, copied out from data if opt is found */
-static char *opt_read(const char *opt, char *data)
-{
- char *value;
- char *retval;
-
- CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
- if ( strncmp(opt, data, strlen(opt)) )
- return NULL;
-
- if ( (value = strchr(data, '=')) == NULL )
- return NULL;
-
- value++;
- PRESTO_ALLOC(retval, strlen(value) + 1);
- if ( !retval ) {
- CERROR("InterMezzo: Out of memory!\n");
- return NULL;
- }
-
- strcpy(retval, value);
- CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval);
- return retval;
-}
-
-static void opt_store(char **dst, char *opt)
-{
- if (!dst)
- CERROR("intermezzo: store_opt, error dst == NULL\n");
-
- if (*dst)
- PRESTO_FREE(*dst, strlen(*dst) + 1);
- *dst = opt;
-}
-
-static void opt_set_default(char **dst, char *defval)
-{
- if (!dst)
- CERROR("intermezzo: store_opt, error dst == NULL\n");
-
- if (*dst)
- PRESTO_FREE(*dst, strlen(*dst) + 1);
- if (defval) {
- char *def_alloced;
- PRESTO_ALLOC(def_alloced, strlen(defval)+1);
- if (!def_alloced) {
- CERROR("InterMezzo: Out of memory!\n");
- return ;
- }
- strcpy(def_alloced, defval);
- *dst = def_alloced;
- }
-}
-
-
-/* Find the options for InterMezzo in "options", saving them into the
- * passed pointers. If the pointer is null, the option is discarded.
- * Copy out all non-InterMezzo options into cache_data (to be passed
- * to the read_super operation of the cache). The return value will
- * be a pointer to the end of the cache_data.
- */
-static char *presto_options(struct file_system_type *fstype,
- char *options, char *cache_data,
- char **cache_type, char **fileset,
- char **channel)
-{
- char *this_char;
- char *opt_ptr = options;
- char *cache_data_end = cache_data;
-
- /* set the defaults */
- if (strcmp(fstype->name, "intermezzo") == 0)
- opt_set_default(cache_type, "ext3");
- else
- opt_set_default(cache_type, "tmpfs");
-
- if (!options || !cache_data)
- return cache_data_end;
-
-
- CDEBUG(D_SUPER, "parsing options\n");
- while ((this_char = strsep (&opt_ptr, ",")) != NULL) {
- char *opt;
- if (!*this_char)
- continue;
- CDEBUG(D_SUPER, "this_char %s\n", this_char);
-
- if ( (opt = opt_read("fileset", this_char)) ) {
- opt_store(fileset, opt);
- continue;
- }
- if ( (opt = opt_read("cache_type", this_char)) ) {
- opt_store(cache_type, opt);
- continue;
- }
- if ( (opt = opt_read("channel", this_char)) ) {
- opt_store(channel, opt);
- continue;
- }
-
- cache_data_end +=
- sprintf(cache_data_end, "%s%s",
- cache_data_end != cache_data ? ",":"",
- this_char);
- }
-
- return cache_data_end;
-}
-
-static int presto_set_channel(struct presto_cache *cache, char *channel)
-{
- int minor;
-
- ENTRY;
- if (!channel) {
- minor = izo_psdev_get_free_channel();
- } else {
- minor = simple_strtoul(channel, NULL, 0);
- }
- if (minor < 0 || minor >= MAX_CHANNEL) {
- CERROR("all channels in use or channel too large %d\n",
- minor);
- return -EINVAL;
- }
-
- cache->cache_psdev = &(izo_channels[minor]);
- list_add(&cache->cache_channel_list,
- &cache->cache_psdev->uc_cache_list);
-
- EXIT;
- return minor;
-}
-
-/* We always need to remove the presto options before passing
- mount options to cache FS */
-struct super_block *
-presto_get_sb(struct file_system_type *izo_type, int flags,
- const char *devname, void *data)
-{
- struct file_system_type *fstype;
- struct presto_cache *cache = NULL;
- char *cache_data = NULL;
- char *cache_data_end;
- char *cache_type = NULL;
- char *fileset = NULL;
- char *channel = NULL;
- struct super_block *sb;
- int err;
- unsigned int minor;
-
- ENTRY;
-
- /* reserve space for the cache's data */
- PRESTO_ALLOC(cache_data, PAGE_SIZE);
- if ( !cache_data ) {
- CERROR("presto_read_super: Cannot allocate data page.\n");
- EXIT;
- goto out_err;
- }
-
- /* read and validate options */
- cache_data_end = presto_options(izo_type, data, cache_data, &cache_type,
- &fileset, &channel);
-
- /* was there anything for the cache filesystem in the data? */
- if (cache_data_end == cache_data) {
- PRESTO_FREE(cache_data, PAGE_SIZE);
- cache_data_end = cache_data = NULL;
- } else {
- CDEBUG(D_SUPER, "cache_data at %p is: %s\n", cache_data,
- cache_data);
- }
-
- /* set up the cache */
- cache = presto_cache_init();
- if ( !cache ) {
- CERROR("presto_read_super: failure allocating cache.\n");
- EXIT;
- goto out_err;
- }
- cache->cache_type = cache_type;
-
- /* link cache to channel */
- minor = presto_set_channel(cache, channel);
- if (minor < 0) {
- EXIT;
- goto out_err;
- }
-
- CDEBUG(D_SUPER, "Presto: type=%s, fset=%s, dev= %d, flags %x\n",
- cache_type, fileset?fileset:"NULL", minor, cache->cache_flags);
-
- /* get the filter for the cache */
- fstype = get_fs_type(cache_type);
- cache->cache_filter = filter_get_filter_fs((const char *)cache_type);
- if ( !fstype || !cache->cache_filter) {
- CERROR("Presto: unrecognized fs type or cache type\n");
- EXIT;
- goto out_err;
- }
-
- sb = fstype->get_sb(fstype, flags, devname, cache_data);
-
- if ( !sb || IS_ERR(sb)) {
- CERROR("InterMezzo: cache mount failure.\n");
- EXIT;
- goto out_err;
- }
-
- /* can we in fact mount the cache */
- if (sb->s_bdev && (strcmp(fstype->name, "vintermezzo") == 0)) {
- CERROR("vintermezzo must not be used with a block device\n");
- EXIT;
- goto out_err;
- }
-
- /* this might have been freed above */
- if (cache_data) {
- PRESTO_FREE(cache_data, PAGE_SIZE);
- cache_data = NULL;
- }
-
- cache->cache_sb = sb;
- cache->cache_root = dget(sb->s_root);
-
- /* we now know the dev of the cache: hash the cache */
- presto_cache_add(cache);
- err = izo_prepare_fileset(sb->s_root, fileset);
-
- filter_setup_journal_ops(cache->cache_filter, cache->cache_type);
-
- /* make sure we have our own super operations: sb
- still contains the cache operations */
- filter_setup_super_ops(cache->cache_filter, sb->s_op,
- &presto_super_ops);
- sb->s_op = filter_c2usops(cache->cache_filter);
-
- /* get izo directory operations: sb->s_root->d_inode exists now */
- filter_setup_dir_ops(cache->cache_filter, sb->s_root->d_inode,
- &presto_dir_iops, &presto_dir_fops);
- filter_setup_dentry_ops(cache->cache_filter, sb->s_root->d_op,
- &presto_dentry_ops);
- sb->s_root->d_inode->i_op = filter_c2udiops(cache->cache_filter);
- sb->s_root->d_inode->i_fop = filter_c2udfops(cache->cache_filter);
- sb->s_root->d_op = filter_c2udops(cache->cache_filter);
-
- EXIT;
- return sb;
-
- out_err:
- CDEBUG(D_SUPER, "out_err called\n");
- if (cache)
- PRESTO_FREE(cache, sizeof(struct presto_cache));
- if (cache_data)
- PRESTO_FREE(cache_data, PAGE_SIZE);
- if (fileset)
- PRESTO_FREE(fileset, strlen(fileset) + 1);
- if (channel)
- PRESTO_FREE(channel, strlen(channel) + 1);
- if (cache_type)
- PRESTO_FREE(cache_type, strlen(cache_type) + 1);
-
- CDEBUG(D_MALLOC, "mount error exit: kmem %ld, vmem %ld\n",
- presto_kmemory, presto_vmemory);
- return ERR_PTR(-EINVAL);
-}
-
-
-
-
-#ifdef PRESTO_DEVEL
-static DECLARE_FSTYPE(presto_fs_type, "izo", presto_read_super, FS_REQUIRES_DEV);
-static DECLARE_FSTYPE(vpresto_fs_type, "vintermezzo", presto_read_super, FS_LITTER);
-#else
-static struct file_system_type vpresto_fs_type = {
- .owner = THIS_MODULE,
- .name = "vintermezzo",
- .get_sb = presto_get_sb,
- .kill_sb = kill_litter_super,
-};
-static struct file_system_type presto_fs_type = {
- .owner = THIS_MODULE,
- .name = "intermezzo",
- .get_sb = presto_get_sb,
- .kill_sb = kill_block_super,
- .fs_flags = FS_REQUIRES_DEV,
-};
-#endif
-
-
-
-int __init init_intermezzo_fs(void)
-{
- int status;
-
- printk(KERN_INFO "InterMezzo Kernel/Intersync communications " INTERMEZZO_VERSION
- " info@clusterfs.com\n");
-
- status = presto_psdev_init();
- if ( status ) {
- CERROR("Problem (%d) in init_intermezzo_psdev\n", status);
- return status;
- }
-
- status = init_intermezzo_sysctl();
- if (status) {
- CERROR("presto: failed in init_intermezzo_sysctl!\n");
- }
-
- presto_cache_init_hash();
-
- if (!presto_init_ddata_cache()) {
- CERROR("presto out of memory!\n");
- return -ENOMEM;
- }
-
- status = register_filesystem(&presto_fs_type);
- if (status) {
- CERROR("presto: failed in register_filesystem!\n");
- }
- status = register_filesystem(&vpresto_fs_type);
- if (status) {
- CERROR("vpresto: failed in register_filesystem!\n");
- }
- return status;
-}
-
-void __exit exit_intermezzo_fs(void)
-{
- int err;
-
- ENTRY;
-
- if ( (err = unregister_filesystem(&presto_fs_type)) != 0 ) {
- CERROR("presto: failed to unregister filesystem\n");
- }
- if ( (err = unregister_filesystem(&vpresto_fs_type)) != 0 ) {
- CERROR("vpresto: failed to unregister filesystem\n");
- }
-
- presto_psdev_cleanup();
- cleanup_intermezzo_sysctl();
- presto_cleanup_ddata_cache();
- CERROR("after cleanup: kmem %ld, vmem %ld\n",
- presto_kmemory, presto_vmemory);
-}
-
-
-MODULE_AUTHOR("Cluster Filesystems Inc. <info@clusterfs.com>");
-MODULE_DESCRIPTION("InterMezzo Kernel/Intersync communications " INTERMEZZO_VERSION);
-MODULE_LICENSE("GPL");
-
-module_init(init_intermezzo_fs)
-module_exit(exit_intermezzo_fs)
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 1999 Peter J. Braam <braam@clusterfs.com>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Sysctrl entries for Intermezzo!
- */
-
-#include <linux/config.h> /* for CONFIG_PROC_FS */
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/stat.h>
-#include <linux/ctype.h>
-#include <linux/init.h>
-#include <asm/bitops.h>
-#include <asm/segment.h>
-#include <asm/uaccess.h>
-#include <linux/utsname.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-/* /proc entries */
-
-#ifdef CONFIG_PROC_FS
-struct proc_dir_entry *proc_fs_intermezzo;
-int intermezzo_mount_get_info( char * buffer, char ** start, off_t offset,
- int length)
-{
- int len=0;
-
- /* this works as long as we are below 1024 characters! */
- *start = buffer + offset;
- len -= offset;
-
- if ( len < 0 )
- return -EINVAL;
-
- return len;
-}
-
-#endif
-
-
-/* SYSCTL below */
-
-static struct ctl_table_header *intermezzo_table_header = NULL;
-/* 0x100 to avoid any chance of collisions at any point in the tree with
- * non-directories
- */
-#define PSDEV_INTERMEZZO (0x100)
-
-#define PSDEV_DEBUG 1 /* control debugging */
-#define PSDEV_TRACE 2 /* control enter/leave pattern */
-#define PSDEV_TIMEOUT 3 /* timeout on upcalls to become intrble */
-#define PSDEV_HARD 4 /* mount type "hard" or "soft" */
-#define PSDEV_NO_FILTER 5 /* controls presto_chk */
-#define PSDEV_NO_JOURNAL 6 /* controls presto_chk */
-#define PSDEV_NO_UPCALL 7 /* controls lento_upcall */
-#define PSDEV_ERRORVAL 8 /* controls presto_debug_fail_blkdev */
-#define PSDEV_EXCL_GID 9 /* which GID is ignored by presto */
-#define PSDEV_BYTES_TO_CLOSE 11 /* bytes to write before close */
-
-/* These are global presto control options */
-#define PRESTO_PRIMARY_CTLCNT 2
-static struct ctl_table presto_table[ PRESTO_PRIMARY_CTLCNT + MAX_CHANNEL + 1] =
-{
- {PSDEV_DEBUG, "debug", &presto_debug, sizeof(int), 0644, NULL, &proc_dointvec},
- {PSDEV_TRACE, "trace", &presto_print_entry, sizeof(int), 0644, NULL, &proc_dointvec},
-};
-
-/*
- * Intalling the sysctl entries: strategy
- * - have templates for each /proc/sys/intermezzo/ entry
- * such an entry exists for each /dev/presto
- * (proto_channel_entry)
- * - have a template for the contents of such directories
- * (proto_psdev_table)
- * - have the master table (presto_table)
- *
- * When installing, malloc, memcpy and fix up the pointers to point to
- * the appropriate constants in izo_channels[your_minor]
- */
-
-static ctl_table proto_psdev_table[] = {
- {PSDEV_HARD, "hard", 0, sizeof(int), 0644, NULL, &proc_dointvec},
- {PSDEV_NO_FILTER, "no_filter", 0, sizeof(int), 0644, NULL, &proc_dointvec},
- {PSDEV_NO_JOURNAL, "no_journal", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
- {PSDEV_NO_UPCALL, "no_upcall", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
- {PSDEV_TIMEOUT, "timeout", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-#ifdef PRESTO_DEBUG
- {PSDEV_ERRORVAL, "errorval", NULL, sizeof(int), 0644, NULL, &proc_dointvec},
-#endif
- { 0 }
-};
-
-static ctl_table proto_channel_entry = {
- PSDEV_INTERMEZZO, 0, NULL, 0, 0555, 0,
-};
-
-static ctl_table intermezzo_table[2] = {
- {PSDEV_INTERMEZZO, "intermezzo", NULL, 0, 0555, presto_table},
- {0}
-};
-
-/* support for external setting and getting of opts. */
-/* particularly via ioctl. The Right way to do this is via sysctl,
- * but that will have to wait until intermezzo gets its own nice set of
- * sysctl IDs
- */
-/* we made these separate as setting may in future be more restricted
- * than getting
- */
-#ifdef RON_MINNICH
-int dosetopt(int minor, struct psdev_opt *opt)
-{
- int retval = 0;
- int newval = opt->optval;
-
- ENTRY;
-
- switch(opt->optname) {
-
- case PSDEV_TIMEOUT:
- izo_channels[minor].uc_timeout = newval;
- break;
-
- case PSDEV_HARD:
- izo_channels[minor].uc_hard = newval;
- break;
-
- case PSDEV_NO_FILTER:
- izo_channels[minor].uc_no_filter = newval;
- break;
-
- case PSDEV_NO_JOURNAL:
- izo_channels[minor].uc_no_journal = newval;
- break;
-
- case PSDEV_NO_UPCALL:
- izo_channels[minor].uc_no_upcall = newval;
- break;
-
-#ifdef PRESTO_DEBUG
- case PSDEV_ERRORVAL: {
- /* If we have a positive arg, set a breakpoint for that
- * value. If we have a negative arg, make that device
- * read-only. FIXME It would be much better to only
- * allow setting the underlying device read-only for the
- * current presto cache.
- */
- int errorval = izo_channels[minor].uc_errorval;
- if (errorval < 0) {
- if (newval == 0)
- set_device_ro(-errorval, 0);
- else
- CERROR("device %s already read only\n",
- kdevname(-errorval));
- } else {
- if (newval < 0)
- set_device_ro(-newval, 1);
- izo_channels[minor].uc_errorval = newval;
- CDEBUG(D_PSDEV, "setting errorval to %d\n", newval);
- }
-
- break;
- }
-#endif
-
- case PSDEV_TRACE:
- case PSDEV_DEBUG:
- case PSDEV_BYTES_TO_CLOSE:
- default:
- CDEBUG(D_PSDEV,
- "ioctl: dosetopt: minor %d, bad optname 0x%x, \n",
- minor, opt->optname);
-
- retval = -EINVAL;
- }
-
- EXIT;
- return retval;
-}
-
-int dogetopt(int minor, struct psdev_opt *opt)
-{
- int retval = 0;
-
- ENTRY;
-
- switch(opt->optname) {
-
- case PSDEV_TIMEOUT:
- opt->optval = izo_channels[minor].uc_timeout;
- break;
-
- case PSDEV_HARD:
- opt->optval = izo_channels[minor].uc_hard;
- break;
-
- case PSDEV_NO_FILTER:
- opt->optval = izo_channels[minor].uc_no_filter;
- break;
-
- case PSDEV_NO_JOURNAL:
- opt->optval = izo_channels[minor].uc_no_journal;
- break;
-
- case PSDEV_NO_UPCALL:
- opt->optval = izo_channels[minor].uc_no_upcall;
- break;
-
-#ifdef PSDEV_DEBUG
- case PSDEV_ERRORVAL: {
- int errorval = izo_channels[minor].uc_errorval;
- if (errorval < 0 && is_read_only(-errorval))
- CERROR("device %s has been set read-only\n",
- kdevname(-errorval));
- opt->optval = izo_channels[minor].uc_errorval;
- break;
- }
-#endif
-
- case PSDEV_TRACE:
- case PSDEV_DEBUG:
- case PSDEV_BYTES_TO_CLOSE:
- default:
- CDEBUG(D_PSDEV,
- "ioctl: dogetopt: minor %d, bad optval 0x%x, \n",
- minor, opt->optname);
-
- retval = -EINVAL;
- }
-
- EXIT;
- return retval;
-}
-#endif
-
-
-/* allocate the tables for the presto devices. We need
- * sizeof(proto_channel_table)/sizeof(proto_channel_table[0])
- * entries for each dev
- */
-int /* __init */ init_intermezzo_sysctl(void)
-{
- int i;
- int total_dev = MAX_CHANNEL;
- int entries_per_dev = sizeof(proto_psdev_table) /
- sizeof(proto_psdev_table[0]);
- int total_entries = entries_per_dev * total_dev;
- ctl_table *dev_ctl_table;
-
- PRESTO_ALLOC(dev_ctl_table, sizeof(ctl_table) * total_entries);
-
- if (! dev_ctl_table) {
- CERROR("WARNING: presto couldn't allocate dev_ctl_table\n");
- EXIT;
- return -ENOMEM;
- }
-
- /* now fill in the entries ... we put the individual presto<x>
- * entries at the end of the table, and the per-presto stuff
- * starting at the front. We assume that the compiler makes
- * this code more efficient, but really, who cares ... it
- * happens once per reboot.
- */
- for(i = 0; i < total_dev; i++) {
- void *p;
-
- /* entry for this /proc/sys/intermezzo/intermezzo"i" */
- ctl_table *psdev = &presto_table[i + PRESTO_PRIMARY_CTLCNT];
- /* entries for the individual "files" in this "directory" */
- ctl_table *psdev_entries = &dev_ctl_table[i * entries_per_dev];
- /* init the psdev and psdev_entries with the prototypes */
- *psdev = proto_channel_entry;
- memcpy(psdev_entries, proto_psdev_table,
- sizeof(proto_psdev_table));
- /* now specialize them ... */
- /* the psdev has to point to psdev_entries, and fix the number */
- psdev->ctl_name = psdev->ctl_name + i + 1; /* sorry */
-
- PRESTO_ALLOC(p, PROCNAME_SIZE);
- psdev->procname = p;
- if (!psdev->procname) {
- PRESTO_FREE(dev_ctl_table,
- sizeof(ctl_table) * total_entries);
- return -ENOMEM;
- }
- sprintf((char *) psdev->procname, "intermezzo%d", i);
- /* hook presto into */
- psdev->child = psdev_entries;
-
- /* now for each psdev entry ... */
- psdev_entries[0].data = &(izo_channels[i].uc_hard);
- psdev_entries[1].data = &(izo_channels[i].uc_no_filter);
- psdev_entries[2].data = &(izo_channels[i].uc_no_journal);
- psdev_entries[3].data = &(izo_channels[i].uc_no_upcall);
- psdev_entries[4].data = &(izo_channels[i].uc_timeout);
-#ifdef PRESTO_DEBUG
- psdev_entries[5].data = &(izo_channels[i].uc_errorval);
-#endif
- }
-
-
-#ifdef CONFIG_SYSCTL
- if ( !intermezzo_table_header )
- intermezzo_table_header =
- register_sysctl_table(intermezzo_table, 0);
-#endif
-#ifdef CONFIG_PROC_FS
- proc_fs_intermezzo = proc_mkdir("intermezzo", proc_root_fs);
- proc_fs_intermezzo->owner = THIS_MODULE;
- create_proc_info_entry("mounts", 0, proc_fs_intermezzo,
- intermezzo_mount_get_info);
-#endif
- return 0;
-}
-
-void cleanup_intermezzo_sysctl(void)
-{
- int total_dev = MAX_CHANNEL;
- int entries_per_dev = sizeof(proto_psdev_table) /
- sizeof(proto_psdev_table[0]);
- int total_entries = entries_per_dev * total_dev;
- int i;
-
-#ifdef CONFIG_SYSCTL
- if ( intermezzo_table_header )
- unregister_sysctl_table(intermezzo_table_header);
- intermezzo_table_header = NULL;
-#endif
- for(i = 0; i < total_dev; i++) {
- /* entry for this /proc/sys/intermezzo/intermezzo"i" */
- ctl_table *psdev = &presto_table[i + PRESTO_PRIMARY_CTLCNT];
- PRESTO_FREE(psdev->procname, PROCNAME_SIZE);
- }
- /* presto_table[PRESTO_PRIMARY_CTLCNT].child points to the
- * dev_ctl_table previously allocated in init_intermezzo_psdev()
- */
- PRESTO_FREE(presto_table[PRESTO_PRIMARY_CTLCNT].child, sizeof(ctl_table) * total_entries);
-
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("mounts", proc_fs_intermezzo);
- remove_proc_entry("intermezzo", proc_root_fs);
-#endif
-}
-
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc. <braam@clusterfs.com>
- * Copyright (C) 2001 Tacit Networks, Inc. <phil@off.net>
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Mostly platform independent upcall operations to a cache manager:
- * -- upcalls
- * -- upcall routines
- *
- */
-
-#include <asm/system.h>
-#include <asm/segment.h>
-#include <asm/signal.h>
-#include <linux/signal.h>
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/vmalloc.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-#include "intermezzo_lib.h"
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#include "intermezzo_idl.h"
-
-/*
- At present:
- -- Asynchronous calls:
- - kml: give a "more" kml indication to userland
- - kml_truncate: initiate KML truncation
- - release_permit: kernel is done with permit
- -- Synchronous
- - open: fetch file
- - permit: get a permit
-
- Errors returned by user level code are positive
-
- */
-
-static struct izo_upcall_hdr *upc_pack(__u32 opcode, int pathlen, char *path,
- char *fsetname, int reclen, char *rec,
- int *size)
-{
- struct izo_upcall_hdr *hdr;
- char *ptr;
- ENTRY;
-
- *size = sizeof(struct izo_upcall_hdr);
- if ( fsetname ) {
- *size += round_strlen(fsetname);
- }
- if ( path ) {
- *size += round_strlen(path);
- }
- if ( rec ) {
- *size += size_round(reclen);
- }
- PRESTO_ALLOC(hdr, *size);
- if (!hdr) {
- CERROR("intermezzo upcall: out of memory (opc %d)\n", opcode);
- EXIT;
- return NULL;
- }
- memset(hdr, 0, *size);
-
- ptr = (char *)hdr + sizeof(*hdr);
-
- /* XXX do we need fsuid ? */
- hdr->u_len = *size;
- hdr->u_version = IZO_UPC_VERSION;
- hdr->u_opc = opcode;
- hdr->u_pid = current->pid;
- hdr->u_uid = current->fsuid;
-
- if (path) {
- /*XXX Robert: please review what len to pass in for
- NUL terminated strings */
- hdr->u_pathlen = strlen(path);
- LOGL0(path, hdr->u_pathlen, ptr);
- }
- if (fsetname) {
- hdr->u_fsetlen = strlen(fsetname);
- LOGL0(fsetname, strlen(fsetname), ptr);
- }
- if (rec) {
- hdr->u_reclen = reclen;
- LOGL(rec, reclen, ptr);
- }
-
- EXIT;
- return hdr;
-}
-
-/* the upcalls */
-int izo_upc_kml(int minor, __u64 offset, __u32 first_recno, __u64 length, __u32 last_recno, char *fsetname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
-
- ENTRY;
- if (!presto_lento_up(minor)) {
- EXIT;
- return 0;
- }
-
- hdr = upc_pack(IZO_UPC_KML, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- hdr->u_offset = offset;
- hdr->u_first_recno = first_recno;
- hdr->u_length = length;
- hdr->u_last_recno = last_recno;
-
- CDEBUG(D_UPCALL, "KML: fileset %s, offset %Lu, length %Lu, "
- "first %u, last %d; minor %d\n",
- fsetname,
- (unsigned long long) hdr->u_offset,
- (unsigned long long) hdr->u_length,
- hdr->u_first_recno,
- hdr->u_last_recno, minor);
-
- error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_kml_truncate(int minor, __u64 length, __u32 last_recno, char *fsetname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
-
- ENTRY;
- if (!presto_lento_up(minor)) {
- EXIT;
- return 0;
- }
-
- hdr = upc_pack(IZO_UPC_KML_TRUNC, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- hdr->u_length = length;
- hdr->u_last_recno = last_recno;
-
- CDEBUG(D_UPCALL, "KML TRUNCATE: fileset %s, length %Lu, "
- "last recno %d, minor %d\n",
- fsetname,
- (unsigned long long) hdr->u_length,
- hdr->u_last_recno, minor);
-
- error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
-
- EXIT;
- return error;
-}
-
-int izo_upc_open(int minor, __u32 pathlen, char *path, char *fsetname, struct lento_vfs_context *info)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_OPEN, pathlen, path, fsetname,
- sizeof(*info), (char*)info, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- CDEBUG(D_UPCALL, "path %s\n", path);
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_get_fileid(int minor, __u32 reclen, char *rec,
- __u32 pathlen, char *path, char *fsetname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_GET_FILEID, pathlen, path, fsetname, reclen, rec, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- CDEBUG(D_UPCALL, "path %s\n", path);
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_backfetch(int minor, char *path, char *fsetname, struct lento_vfs_context *info)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_BACKFETCH, strlen(path), path, fsetname,
- sizeof(*info), (char *)info, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- /* This is currently synchronous, kml_reint_record blocks */
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_permit(int minor, struct dentry *dentry, __u32 pathlen, char *path,
- char *fsetname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
-
- ENTRY;
-
- hdr = upc_pack(IZO_UPC_PERMIT, pathlen, path, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- CDEBUG(D_UPCALL, "Permit minor %d path %s\n", minor, path);
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-
- if (error == -EROFS) {
- int err;
- CERROR("InterMezzo: ERROR - requested permit for read-only "
- "fileset.\n Setting \"%s\" read-only!\n", path);
- err = izo_mark_cache(dentry, 0xFFFFFFFF, CACHE_CLIENT_RO, NULL);
- if (err)
- CERROR("InterMezzo ERROR: mark_cache %d\n", err);
- } else if (error) {
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
- }
-
- EXIT;
- return error;
-}
-
-/* This is a ping-pong upcall handled on the server when a client (uuid)
- * requests the permit for itself. */
-int izo_upc_revoke_permit(int minor, char *fsetname, __u8 uuid[16])
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
-
- ENTRY;
-
- hdr = upc_pack(IZO_UPC_REVOKE_PERMIT, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
-
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_go_fetch_kml(int minor, char *fsetname, __u8 uuid[16],
- __u64 kmlsize)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_GO_FETCH_KML, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- hdr->u_offset = kmlsize;
- memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
-
- error = izo_upc_upcall(minor, &size, hdr, ASYNCHRONOUS);
- if (error)
- CERROR("%s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_connect(int minor, __u64 ip_address, __u64 port, __u8 uuid[16],
- int client_flag)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_CONNECT, 0, NULL, NULL, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- hdr->u_offset = ip_address;
- hdr->u_length = port;
- memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
- hdr->u_first_recno = client_flag;
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error) {
- CERROR("%s: error %d\n", __FUNCTION__, error);
- }
-
- EXIT;
- return -error;
-}
-
-int izo_upc_set_kmlsize(int minor, char *fsetname, __u8 uuid[16], __u64 kmlsize)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_SET_KMLSIZE, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- memcpy(hdr->u_uuid, uuid, sizeof(hdr->u_uuid));
- hdr->u_length = kmlsize;
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("%s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_repstatus(int minor, char * fsetname, struct izo_rcvd_rec *lr_server)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_REPSTATUS, 0, NULL, fsetname,
- sizeof(*lr_server), (char*)lr_server,
- &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("%s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-
-#if 0
-int izo_upc_client_make_branch(int minor, char *fsetname, char *tagname,
- char *branchname)
-{
- int size, error;
- struct izo_upcall_hdr *hdr;
- int pathlen;
- char *path;
- ENTRY;
-
- hdr = upc_pack(IZO_UPC_CLIENT_MAKE_BRANCH, strlen(tagname), tagname,
- fsetname, strlen(branchname) + 1, branchname, &size);
- if (!hdr || IS_ERR(hdr)) {
- error = -PTR_ERR(hdr);
- goto error;
- }
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: error %d\n", error);
-
- error:
- PRESTO_FREE(path, pathlen);
- EXIT;
- return error;
-}
-#endif
-
-int izo_upc_server_make_branch(int minor, char *fsetname)
-{
- int size, error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- hdr = upc_pack(IZO_UPC_SERVER_MAKE_BRANCH, 0, NULL, fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- error = -PTR_ERR(hdr);
- goto error;
- }
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: error %d\n", error);
-
- error:
- EXIT;
- return -error;
-}
-
-int izo_upc_branch_undo(int minor, char *fsetname, char *branchname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_BRANCH_UNDO, strlen(branchname), branchname,
- fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
-
-int izo_upc_branch_redo(int minor, char *fsetname, char *branchname)
-{
- int size;
- int error;
- struct izo_upcall_hdr *hdr;
- ENTRY;
-
- if (!presto_lento_up(minor)) {
- EXIT;
- return -EIO;
- }
-
- hdr = upc_pack(IZO_UPC_BRANCH_REDO, strlen(branchname) + 1, branchname,
- fsetname, 0, NULL, &size);
- if (!hdr || IS_ERR(hdr)) {
- EXIT;
- return -PTR_ERR(hdr);
- }
-
- error = izo_upc_upcall(minor, &size, hdr, SYNCHRONOUS);
- if (error)
- CERROR("InterMezzo: %s: error %d\n", __FUNCTION__, error);
-
- EXIT;
- return -error;
-}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
- * Copyright (C) 2000 Stelias Computing, Inc.
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This file is part of InterMezzo, http://www.inter-mezzo.org.
- *
- * InterMezzo is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * InterMezzo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with InterMezzo; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * vfs.c
- *
- * This file implements kernel downcalls from lento.
- *
- * Author: Rob Simmonds <simmonds@stelias.com>
- * Andreas Dilger <adilger@stelias.com>
- * Copyright (C) 2000 Stelias Computing Inc
- * Copyright (C) 2000 Red Hat Inc.
- *
- * Extended attribute support
- * Copyright (C) 2001 Shirish H. Phatak, Tacit Networks, Inc.
- *
- * This code is based on code from namei.c in the linux file system;
- * see copyright notice below.
- */
-
-/** namei.c copyright **/
-
-/*
- * linux/fs/namei.c
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-/*
- * Some corrections by tytso.
- */
-
-/* [Feb 1997 T. Schoebel-Theuer] Complete rewrite of the pathname
- * lookup logic.
- */
-
-/** end of namei.c copyright **/
-
-#include <linux/mm.h>
-#include <linux/proc_fs.h>
-#include <linux/quotaops.h>
-
-#include <asm/uaccess.h>
-#include <asm/unaligned.h>
-#include <asm/semaphore.h>
-#include <asm/pgtable.h>
-
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/namei.h>
-#include <linux/genhd.h>
-
-#include "intermezzo_fs.h"
-#include "intermezzo_psdev.h"
-
-#ifdef CONFIG_FS_EXT_ATTR
-# include <linux/ext_attr.h>
-
-# if 0 /* was a broken check for Posix ACLs */
-# include <linux/posix_acl.h>
-# endif
-#endif
-
-extern struct inode_operations presto_sym_iops;
-
-/* Write the last_rcvd values to the last_rcvd file. We don't know what the
- * UUID or last_ctime values are, so we have to read from the file first
- * (sigh).
- * exported for branch_reinter in kml_reint.c*/
-int presto_write_last_rcvd(struct rec_info *recinfo,
- struct presto_file_set *fset,
- struct lento_vfs_context *info)
-{
- int rc;
- struct izo_rcvd_rec rcvd_rec;
-
- ENTRY;
-
- memset(&rcvd_rec, 0, sizeof(rcvd_rec));
- memcpy(rcvd_rec.lr_uuid, info->uuid, sizeof(rcvd_rec.lr_uuid));
- rcvd_rec.lr_remote_recno = HTON__u64(info->recno);
- rcvd_rec.lr_remote_offset = HTON__u64(info->kml_offset);
- rcvd_rec.lr_local_recno = HTON__u64(recinfo->recno);
- rcvd_rec.lr_local_offset = HTON__u64(recinfo->offset + recinfo->size);
-
- rc = izo_rcvd_write(fset, &rcvd_rec);
- if (rc < 0) {
- /* izo_rcvd_write returns negative errors and non-negative
- * offsets */
- CERROR("InterMezzo: izo_rcvd_write failed: %d\n", rc);
- EXIT;
- return rc;
- }
- EXIT;
- return 0;
-}
-
-/*
- * It's inline, so penalty for filesystems that don't use sticky bit is
- * minimal.
- */
-static inline int check_sticky(struct inode *dir, struct inode *inode)
-{
- if (!(dir->i_mode & S_ISVTX))
- return 0;
- if (inode->i_uid == current->fsuid)
- return 0;
- if (dir->i_uid == current->fsuid)
- return 0;
- return !capable(CAP_FOWNER);
-}
-
-/* from linux/fs/namei.c */
-static inline int may_delete(struct inode *dir,struct dentry *victim, int isdir)
-{
- int error;
- if (!victim->d_inode || victim->d_parent->d_inode != dir)
- return -ENOENT;
- error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
- if (error)
- return error;
- if (IS_APPEND(dir))
- return -EPERM;
- if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
- IS_IMMUTABLE(victim->d_inode))
- return -EPERM;
- if (isdir) {
- if (!S_ISDIR(victim->d_inode->i_mode))
- return -ENOTDIR;
- if (IS_ROOT(victim))
- return -EBUSY;
- } else if (S_ISDIR(victim->d_inode->i_mode))
- return -EISDIR;
- return 0;
-}
-
-/* from linux/fs/namei.c */
-static inline int may_create(struct inode *dir, struct dentry *child) {
- if (child->d_inode)
- return -EEXIST;
- if (IS_DEADDIR(dir))
- return -ENOENT;
- return permission(dir,MAY_WRITE | MAY_EXEC, NULL);
-}
-
-#ifdef PRESTO_DEBUG
-/* The loop_discard_io() function is available via a kernel patch to the
- * loop block device. It "works" by accepting writes, but throwing them
- * away, rather than trying to write them to disk. The old method worked
- * by setting the underlying device read-only, but that has the problem
- * that dirty buffers are kept in memory, and ext3 didn't like that at all.
- */
-#ifdef CONFIG_LOOP_DISCARD
-#define BLKDEV_FAIL(dev,fail) loop_discard_io(dev,fail)
-#else
-#define BLKDEV_FAIL(dev,fail) set_device_ro(dev, 1)
-#endif
-
-/* If a breakpoint has been set via /proc/sys/intermezzo/intermezzoX/errorval,
- * that is the same as "value", the underlying device will "fail" now.
- */
-inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
- unsigned long value)
-{
- int minor = presto_f2m(fset);
- int errorval = izo_channels[minor].uc_errorval;
- struct block_device *bdev = fset->fset_dentry->d_inode->i_sb->s_bdev;
- char b[BDEVNAME_SIZE];
-
- if (errorval && errorval == (long)value && !bdev_read_only(bdev)) {
- CDEBUG(D_SUPER, "setting device %s read only\n",
- bdevname(bdev, b));
- BLKDEV_FAIL(bdev, 1);
- izo_channels[minor].uc_errorval = -bdev->bd_dev;
- }
-}
-#else
-#define presto_debug_fail_blkdev(dev,value) do {} while (0)
-#endif
-
-
-static inline int presto_do_kml(struct lento_vfs_context *info,
- struct dentry *dentry)
-{
- if ( ! (info->flags & LENTO_FL_KML) )
- return 0;
- if ( presto_chk(dentry, PRESTO_DONT_JOURNAL) )
- return 0;
- return 1;
-}
-
-static inline int presto_do_rcvd(struct lento_vfs_context *info,
- struct dentry *dentry)
-{
- if ( ! (info->flags & LENTO_FL_EXPECT) )
- return 0;
- if ( presto_chk(dentry, PRESTO_DONT_JOURNAL) )
- return 0;
- return 1;
-}
-
-
-/* XXX fixme: this should not fail, all these dentries are in memory
- when _we_ call this */
-int presto_settime(struct presto_file_set *fset,
- struct dentry *newobj,
- struct dentry *parent,
- struct dentry *target,
- struct lento_vfs_context *ctx,
- int valid)
-{
- int error = 0;
- struct dentry *dentry;
- struct inode *inode;
- struct inode_operations *iops;
- struct iattr iattr;
-
- ENTRY;
- if (ctx->flags & LENTO_FL_IGNORE_TIME ) {
- EXIT;
- return 0;
- }
-
- iattr.ia_ctime = ctx->updated_time;
- iattr.ia_mtime = ctx->updated_time;
- iattr.ia_valid = valid;
-
- while (1) {
- if (parent && ctx->flags & LENTO_FL_TOUCH_PARENT) {
- dentry = parent;
- parent = NULL;
- } else if (newobj && ctx->flags & LENTO_FL_TOUCH_NEWOBJ) {
- dentry = newobj;
- newobj = NULL;
- } else if (target) {
- dentry = target;
- target = NULL;
- } else
- break;
-
- inode = dentry->d_inode;
-
- error = -EROFS;
- if (IS_RDONLY(inode)) {
- EXIT;
- return -EROFS;
- }
-
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- EXIT;
- return -EPERM;
- }
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops) {
- EXIT;
- return error;
- }
-
- if (iops->setattr != NULL)
- error = iops->setattr(dentry, &iattr);
- else {
- error = 0;
- inode_setattr(dentry->d_inode, &iattr);
- }
- }
- EXIT;
- return error;
-}
-
-void izo_get_rollback_data(struct inode *inode, struct izo_rollback_data *rb)
-{
- rb->rb_mode = (__u32)inode->i_mode;
- rb->rb_rdev = (__u32)old_encode_dev(inode->i_rdev);
- rb->rb_uid = (__u64)inode->i_uid;
- rb->rb_gid = (__u64)inode->i_gid;
-}
-
-
-int presto_do_close(struct presto_file_set *fset, struct file *file)
-{
- struct rec_info rec;
- int rc = -ENOSPC;
- void *handle;
- struct inode *inode = file->f_dentry->d_inode;
- struct presto_file_data *fdata =
- (struct presto_file_data *)file->private_data;
-
- ENTRY;
- presto_getversion(&fdata->fd_info.remote_version, inode);
-
- rc = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (rc) {
- EXIT;
- return rc;
- }
-
- handle = presto_trans_start(fset, file->f_dentry->d_inode,
- KML_OPCODE_RELEASE);
- if ( IS_ERR(handle) ) {
- CERROR("presto_release: no space for transaction\n");
- return rc;
- }
-
- if (fdata->fd_info.flags & LENTO_FL_KML)
- rc = presto_journal_close(&rec, fset, fdata, file->f_dentry,
- &fdata->fd_version,
- &fdata->fd_info.remote_version);
- if (rc) {
- CERROR("presto_close: cannot journal close\n");
- goto out;
- }
-
- if (fdata->fd_info.flags & LENTO_FL_EXPECT)
- rc = presto_write_last_rcvd(&rec, fset, &fdata->fd_info);
-
- if (rc) {
- CERROR("presto_close: cannot journal last_rcvd\n");
- goto out;
- }
- presto_trans_commit(fset, handle);
-
- /* cancel the LML record */
- handle = presto_trans_start(fset, inode, KML_OPCODE_WRITE);
- if ( IS_ERR(handle) ) {
- CERROR("presto_release: no space for clear\n");
- return -ENOSPC;
- }
-
- rc = presto_clear_lml_close(fset, fdata->fd_lml_offset);
- if (rc < 0 ) {
- CERROR("presto_close: cannot journal close\n");
- goto out;
- }
- presto_truncate_lml(fset);
-
- out:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- presto_trans_commit(fset, handle);
- EXIT;
- return rc;
-}
-
-int presto_do_setattr(struct presto_file_set *fset, struct dentry *dentry,
- struct iattr *iattr, struct lento_vfs_context *info)
-{
- struct rec_info rec;
- struct inode *inode = dentry->d_inode;
- struct inode_operations *iops;
- int error;
- struct presto_version old_ver, new_ver;
- struct izo_rollback_data rb;
- void *handle;
- loff_t old_size=inode->i_size;
-
- ENTRY;
- error = -EROFS;
- if (IS_RDONLY(inode)) {
- EXIT;
- return -EROFS;
- }
-
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- EXIT;
- return -EPERM;
- }
-
- presto_getversion(&old_ver, dentry->d_inode);
- izo_get_rollback_data(dentry->d_inode, &rb);
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
-
- error = presto_reserve_space(fset->fset_cache, 2*PRESTO_REQHIGH);
- if (error) {
- EXIT;
- return error;
- }
-
- if (iattr->ia_valid & ATTR_SIZE) {
- if (izo_mark_dentry(dentry, ~PRESTO_DATA, 0, NULL) != 0)
- CERROR("izo_mark_dentry(inode %ld, ~PRESTO_DATA) "
- "failed\n", dentry->d_inode->i_ino);
- handle = presto_trans_start(fset, dentry->d_inode,
- KML_OPCODE_TRUNC);
- } else {
- handle = presto_trans_start(fset, dentry->d_inode,
- KML_OPCODE_SETATTR);
- }
-
- if ( IS_ERR(handle) ) {
- CERROR("presto_do_setattr: no space for transaction\n");
- presto_release_space(fset->fset_cache, 2*PRESTO_REQHIGH);
- return -ENOSPC;
- }
-
- if (dentry->d_inode && iops && iops->setattr) {
- error = iops->setattr(dentry, iattr);
- } else {
- error = inode_change_ok(dentry->d_inode, iattr);
- if (!error)
- inode_setattr(inode, iattr);
- }
-
- if (!error && (iattr->ia_valid & ATTR_SIZE))
- vmtruncate(inode, iattr->ia_size);
-
- if (error) {
- EXIT;
- goto exit;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x10);
-
- if ( presto_do_kml(info, dentry) ) {
- if ((iattr->ia_valid & ATTR_SIZE) && (old_size != inode->i_size)) {
- /* Journal a close whenever we see a potential truncate
- * At the receiving end, lento should explicitly remove
- * ATTR_SIZE from the list of valid attributes */
- presto_getversion(&new_ver, inode);
- error = presto_journal_close(&rec, fset, NULL, dentry,
- &old_ver, &new_ver);
- }
-
- if (!error)
- error = presto_journal_setattr(&rec, fset, dentry,
- &old_ver, &rb, iattr);
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x20);
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETATTR | 0x30);
-
- EXIT;
-exit:
- presto_release_space(fset->fset_cache, 2*PRESTO_REQHIGH);
- presto_trans_commit(fset, handle);
- return error;
-}
-
-int lento_setattr(const char *name, struct iattr *iattr,
- struct lento_vfs_context *info)
-{
- struct nameidata nd;
- struct dentry *dentry;
- struct presto_file_set *fset;
- int error;
-#if 0 /* was a broken check for Posix ACLs */
- int (*set_posix_acl)(struct inode *, int type, posix_acl_t *)=NULL;
-#endif
-
- ENTRY;
- CDEBUG(D_PIOCTL,"name %s, valid %#x, mode %#o, uid %d, gid %d, size %Ld\n",
- name, iattr->ia_valid, iattr->ia_mode, iattr->ia_uid,
- iattr->ia_gid, iattr->ia_size);
- CDEBUG(D_PIOCTL, "atime %#lx, mtime %#lx, ctime %#lx, attr_flags %#x\n",
- iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec, iattr->ia_ctime.tv_sec,
- iattr->ia_attr_flags);
- CDEBUG(D_PIOCTL, "offset %d, recno %d, flags %#x\n",
- info->slot_offset, info->recno, info->flags);
-
- lock_kernel();
- error = presto_walk(name, &nd);
- if (error) {
- EXIT;
- goto exit;
- }
- dentry = nd.dentry;
-
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit_lock;
- }
-
- /* NOTE: this prevents us from changing the filetype on setattr,
- * as we normally only want to change permission bits.
- * If this is not correct, then we need to fix the perl code
- * to always send the file type OR'ed with the permission.
- */
- if (iattr->ia_valid & ATTR_MODE) {
- int set_mode = iattr->ia_mode;
- iattr->ia_mode = (iattr->ia_mode & S_IALLUGO) |
- (dentry->d_inode->i_mode & ~S_IALLUGO);
- CDEBUG(D_PIOCTL, "chmod: orig %#o, set %#o, result %#o\n",
- dentry->d_inode->i_mode, set_mode, iattr->ia_mode);
-#if 0 /* was a broken check for Posix ACLs */
- /* ACl code interacts badly with setattr
- * since it tries to modify the ACL using
- * set_ext_attr which recurses back into presto.
- * This only happens if ATTR_MODE is set.
- * Here we are doing a "forced" mode set
- * (initiated by lento), so we disable the
- * set_posix_acl operation which
- * prevents such recursion. -SHP
- *
- * This will probably still be required when native
- * acl journalling is in place.
- */
- set_posix_acl=dentry->d_inode->i_op->set_posix_acl;
- dentry->d_inode->i_op->set_posix_acl=NULL;
-#endif
- }
-
- error = presto_do_setattr(fset, dentry, iattr, info);
-
- if (info->flags & LENTO_FL_SET_DDFILEID) {
- struct presto_dentry_data *dd = presto_d2d(dentry);
- if (dd) {
- dd->remote_ino = info->remote_ino;
- dd->remote_generation = info->remote_generation;
- }
- }
-
-#if 0 /* was a broken check for Posix ACLs */
- /* restore the inode_operations if we changed them*/
- if (iattr->ia_valid & ATTR_MODE)
- dentry->d_inode->i_op->set_posix_acl=set_posix_acl;
-#endif
-
-
- EXIT;
-exit_lock:
- path_release(&nd);
-exit:
- unlock_kernel();
- return error;
-}
-
-int presto_do_create(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error;
- struct presto_version tgt_dir_ver, new_file_ver;
- struct inode_operations *iops;
- void *handle;
-
- ENTRY;
- mode &= S_IALLUGO;
- mode |= S_IFREG;
-
- // down(&dir->d_inode->i_zombie);
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- error = may_create(dir->d_inode, dentry);
- if (error) {
- EXIT;
- goto exit_pre_lock;
- }
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->create) {
- EXIT;
- goto exit_pre_lock;
- }
-
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_CREATE);
- if ( IS_ERR(handle) ) {
- EXIT;
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- CERROR("presto_do_create: no space for transaction\n");
- error=-ENOSPC;
- goto exit_pre_lock;
- }
- DQUOT_INIT(dir->d_inode);
- lock_kernel();
- error = iops->create(dir->d_inode, dentry, mode, NULL);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- if (dentry->d_inode) {
- struct presto_cache *cache = fset->fset_cache;
- /* was this already done? */
- presto_set_ops(dentry->d_inode, cache->cache_filter);
-
- filter_setup_dentry_ops(cache->cache_filter,
- dentry->d_op,
- &presto_dentry_ops);
- dentry->d_op = filter_c2udops(cache->cache_filter);
-
- /* if Lento creates this file, we won't have data */
- if ( ISLENTO(presto_c2m(cache)) ) {
- presto_set(dentry, PRESTO_ATTR);
- } else {
- presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
- }
- }
-
- info->flags |= LENTO_FL_TOUCH_PARENT;
- error = presto_settime(fset, NULL, dir, dentry,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x10);
-
- if ( presto_do_kml(info, dentry) ) {
- presto_getversion(&new_file_ver, dentry->d_inode);
- error = presto_journal_create(&rec, fset, dentry, &tgt_dir_ver,
- &new_file_ver,
- dentry->d_inode->i_mode);
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x20);
-
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_CREATE | 0x30);
-
- /* add inode dentry */
- if (fset->fset_cache->cache_filter->o_trops->tr_add_ilookup ) {
- struct dentry *d;
- d = fset->fset_cache->cache_filter->o_trops->tr_add_ilookup
- (dir->d_inode->i_sb->s_root, dentry);
- }
-
- EXIT;
-
- exit_lock:
- unlock_kernel();
- presto_trans_commit(fset, handle);
- exit_pre_lock:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- // up(&dir->d_inode->i_zombie);
- return error;
-}
-
-int lento_create(const char *name, int mode, struct lento_vfs_context *info)
-{
- int error;
- struct nameidata nd;
- char * pathname;
- struct dentry *dentry;
- struct presto_file_set *fset;
-
- ENTRY;
- pathname = getname(name);
- error = PTR_ERR(pathname);
- if (IS_ERR(pathname)) {
- EXIT;
- goto exit;
- }
-
- /* this looks up the parent */
- error = path_lookup(pathname, LOOKUP_PARENT, &nd);
- if (error) {
- EXIT;
- goto exit;
- }
- dentry = lookup_create(&nd, 0);
- error = PTR_ERR(dentry);
- if (IS_ERR(dentry)) {
- EXIT;
- goto exit_lock;
- }
-
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit_lock;
- }
- error = presto_do_create(fset, dentry->d_parent, dentry, (mode&S_IALLUGO)|S_IFREG,
- info);
-
- EXIT;
-
- exit_lock:
- path_release (&nd);
- dput(dentry);
- up(&dentry->d_parent->d_inode->i_sem);
- putname(pathname);
-exit:
- return error;
-}
-
-int presto_do_link(struct presto_file_set *fset, struct dentry *old_dentry,
- struct dentry *dir, struct dentry *new_dentry,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- struct inode *inode;
- int error;
- struct inode_operations *iops;
- struct presto_version tgt_dir_ver;
- struct presto_version new_link_ver;
- void *handle;
-
- // down(&dir->d_inode->i_zombie);
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
- error = -ENOENT;
- inode = old_dentry->d_inode;
- if (!inode)
- goto exit_lock;
-
- error = may_create(dir->d_inode, new_dentry);
- if (error)
- goto exit_lock;
-
- error = -EXDEV;
- if (dir->d_inode->i_sb != inode->i_sb)
- goto exit_lock;
-
- /*
- * A link to an append-only or immutable file cannot be created.
- */
- error = -EPERM;
- if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) {
- EXIT;
- goto exit_lock;
- }
-
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->link) {
- EXIT;
- goto exit_lock;
- }
-
-
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_LINK);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- CERROR("presto_do_link: no space for transaction\n");
- return -ENOSPC;
- }
-
- DQUOT_INIT(dir->d_inode);
- lock_kernel();
- error = iops->link(old_dentry, dir->d_inode, new_dentry);
- unlock_kernel();
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- /* link dd data to that of existing dentry */
- old_dentry->d_op->d_release(new_dentry);
- if (!presto_d2d(old_dentry))
- BUG();
- presto_d2d(old_dentry)->dd_count++;
-
- new_dentry->d_fsdata = presto_d2d(old_dentry);
-
- info->flags |= LENTO_FL_TOUCH_PARENT;
- error = presto_settime(fset, NULL, dir, new_dentry,
- info, ATTR_CTIME);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x10);
- presto_getversion(&new_link_ver, new_dentry->d_inode);
- if ( presto_do_kml(info, old_dentry) )
- error = presto_journal_link(&rec, fset, old_dentry, new_dentry,
- &tgt_dir_ver, &new_link_ver);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x20);
- if ( presto_do_rcvd(info, old_dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_LINK | 0x30);
- EXIT;
- presto_trans_commit(fset, handle);
-exit_lock:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- // up(&dir->d_inode->i_zombie);
- return error;
-}
-
-
-int lento_link(const char * oldname, const char * newname,
- struct lento_vfs_context *info)
-{
- int error;
- char * to;
- struct presto_file_set *fset;
-
- to = getname(newname);
- error = PTR_ERR(to);
- if (!IS_ERR(to)) {
- struct dentry *new_dentry;
- struct nameidata nd, old_nd;
-
- error = __user_walk(oldname, 0, &old_nd);
- if (error)
- goto exit;
- error = path_lookup(to, LOOKUP_PARENT, &nd);
- if (error)
- goto out;
- error = -EXDEV;
- if (old_nd.mnt != nd.mnt)
- goto out;
- new_dentry = lookup_create(&nd, 0);
- error = PTR_ERR(new_dentry);
-
- if (!IS_ERR(new_dentry)) {
- fset = presto_fset(new_dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto out2;
- }
- error = presto_do_link(fset, old_nd.dentry,
- nd.dentry,
- new_dentry, info);
- dput(new_dentry);
- }
- out2:
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
- out:
- path_release(&old_nd);
- exit:
- putname(to);
- }
- return error;
-}
-
-int presto_do_unlink(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, struct lento_vfs_context *info)
-{
- struct rec_info rec;
- struct inode_operations *iops;
- struct presto_version tgt_dir_ver, old_file_ver;
- struct izo_rollback_data rb;
- void *handle;
- int do_kml = 0, do_rcvd = 0, linkno = 0, error, old_targetlen = 0;
- char *old_target = NULL;
-
- ENTRY;
- // down(&dir->d_inode->i_zombie);
- error = may_delete(dir->d_inode, dentry, 0);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->unlink) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQLOW);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
-
- if (presto_d2d(dentry)) {
- struct presto_dentry_data *dd = presto_d2d(dentry);
- struct dentry *de = dd->dd_inodentry;
- if (de && dentry->d_inode->i_nlink == 1) {
- dd->dd_count--;
- dd->dd_inodentry = NULL;
- de->d_fsdata = NULL;
- atomic_dec(&de->d_inode->i_count);
- de->d_inode = NULL;
- dput(de);
- }
- }
-
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- presto_getversion(&old_file_ver, dentry->d_inode);
- izo_get_rollback_data(dentry->d_inode, &rb);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_UNLINK);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQLOW);
- CERROR("ERROR: presto_do_unlink: no space for transaction. Tell Peter.\n");
- // up(&dir->d_inode->i_zombie);
- return -ENOSPC;
- }
- DQUOT_INIT(dir->d_inode);
- if (d_mountpoint(dentry))
- error = -EBUSY;
- else {
- lock_kernel();
- linkno = dentry->d_inode->i_nlink;
- if (linkno > 1) {
- dget(dentry);
- }
-
- if (S_ISLNK(dentry->d_inode->i_mode)) {
- mm_segment_t old_fs;
- struct inode_operations *riops;
- riops = filter_c2csiops(fset->fset_cache->cache_filter);
-
- PRESTO_ALLOC(old_target, PATH_MAX);
- if (old_target == NULL) {
- error = -ENOMEM;
- EXIT;
- goto exit;
- }
-
- old_fs = get_fs();
- set_fs(get_ds());
-
- if (riops->readlink == NULL)
- CERROR("InterMezzo %s: no readlink iops.\n",
- __FUNCTION__);
- else
- old_targetlen =
- riops->readlink(dentry, old_target,
- PATH_MAX);
- if (old_targetlen < 0) {
- CERROR("InterMezzo: readlink failed: %ld\n",
- PTR_ERR(old_target));
- PRESTO_FREE(old_target, PATH_MAX);
- old_target = NULL;
- old_targetlen = 0;
- }
- set_fs(old_fs);
- }
-
- do_kml = presto_do_kml(info, dir);
- do_rcvd = presto_do_rcvd(info, dir);
- error = iops->unlink(dir->d_inode, dentry);
- unlock_kernel();
- }
-
- if (linkno > 1) {
- /* FIXME: Combine this with the next call? */
- error = presto_settime(fset, NULL, NULL, dentry,
- info, ATTR_CTIME);
- dput(dentry);
- if (error) {
- EXIT;
- goto exit;
- }
- }
-
- error = presto_settime(fset, NULL, NULL, dir,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- goto exit;
- }
-
- // up(&dir->d_inode->i_zombie);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x10);
- if ( do_kml )
- error = presto_journal_unlink(&rec, fset, dir, &tgt_dir_ver,
- &old_file_ver, &rb, dentry,
- old_target, old_targetlen);
- presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x20);
- if ( do_rcvd ) {
- error = presto_write_last_rcvd(&rec, fset, info);
- }
- presto_debug_fail_blkdev(fset, KML_OPCODE_UNLINK | 0x30);
- EXIT;
-exit:
- presto_release_space(fset->fset_cache, PRESTO_REQLOW);
- presto_trans_commit(fset, handle);
- if (old_target != NULL)
- PRESTO_FREE(old_target, PATH_MAX);
- return error;
-}
-
-
-int lento_unlink(const char *pathname, struct lento_vfs_context *info)
-{
- int error = 0;
- char * name;
- struct dentry *dentry;
- struct nameidata nd;
- struct presto_file_set *fset;
-
- ENTRY;
-
- name = getname(pathname);
- if(IS_ERR(name))
- return PTR_ERR(name);
-
- error = path_lookup(name, LOOKUP_PARENT, &nd);
- if (error)
- goto exit;
- error = -EISDIR;
- if (nd.last_type != LAST_NORM)
- goto exit1;
- down(&nd.dentry->d_inode->i_sem);
- dentry = lookup_hash(&nd.last, nd.dentry);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit2;
- }
- /* Why not before? Because we want correct error value */
- if (nd.last.name[nd.last.len])
- goto slashes;
- error = presto_do_unlink(fset, nd.dentry, dentry, info);
- if (!error)
- d_delete(dentry);
- exit2:
- EXIT;
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
-exit1:
- path_release(&nd);
-exit:
- putname(name);
-
- return error;
-
-slashes:
- error = !dentry->d_inode ? -ENOENT :
- S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;
- goto exit2;
-}
-
-int presto_do_symlink(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, const char *oldname,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error;
- struct presto_version tgt_dir_ver, new_link_ver;
- struct inode_operations *iops;
- void *handle;
-
- ENTRY;
- // down(&dir->d_inode->i_zombie);
- /* record + max path len + space to free */
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- error = may_create(dir->d_inode, dentry);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->symlink) {
- EXIT;
- goto exit_lock;
- }
-
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_SYMLINK);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- CERROR("ERROR: presto_do_symlink: no space for transaction. Tell Peter.\n");
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return -ENOSPC;
- }
- DQUOT_INIT(dir->d_inode);
- lock_kernel();
- error = iops->symlink(dir->d_inode, dentry, oldname);
- if (error) {
- EXIT;
- goto exit;
- }
-
- if (dentry->d_inode) {
- struct presto_cache *cache = fset->fset_cache;
-
- presto_set_ops(dentry->d_inode, cache->cache_filter);
-
- filter_setup_dentry_ops(cache->cache_filter, dentry->d_op,
- &presto_dentry_ops);
- dentry->d_op = filter_c2udops(cache->cache_filter);
- /* XXX ? Cache state ? if Lento creates a symlink */
- if ( ISLENTO(presto_c2m(cache)) ) {
- presto_set(dentry, PRESTO_ATTR);
- } else {
- presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
- }
- }
-
- info->flags |= LENTO_FL_TOUCH_PARENT;
- error = presto_settime(fset, NULL, dir, dentry,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- goto exit;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x10);
- presto_getversion(&new_link_ver, dentry->d_inode);
- if ( presto_do_kml(info, dentry) )
- error = presto_journal_symlink(&rec, fset, dentry, oldname,
- &tgt_dir_ver, &new_link_ver);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x20);
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SYMLINK | 0x30);
- EXIT;
-exit:
- unlock_kernel();
- presto_trans_commit(fset, handle);
- exit_lock:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- // up(&dir->d_inode->i_zombie);
- return error;
-}
-
-int lento_symlink(const char *oldname, const char *newname,
- struct lento_vfs_context *info)
-{
- int error;
- char *from;
- char *to;
- struct dentry *dentry;
- struct presto_file_set *fset;
- struct nameidata nd;
-
- ENTRY;
- lock_kernel();
- from = getname(oldname);
- error = PTR_ERR(from);
- if (IS_ERR(from)) {
- EXIT;
- goto exit;
- }
-
- to = getname(newname);
- error = PTR_ERR(to);
- if (IS_ERR(to)) {
- EXIT;
- goto exit_from;
- }
-
- error = path_lookup(to, LOOKUP_PARENT, &nd);
- if (error) {
- EXIT;
- goto exit_to;
- }
-
- dentry = lookup_create(&nd, 0);
- error = PTR_ERR(dentry);
- if (IS_ERR(dentry)) {
- path_release(&nd);
- EXIT;
- goto exit_to;
- }
-
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- path_release(&nd);
- EXIT;
- goto exit_lock;
- }
- error = presto_do_symlink(fset, nd.dentry,
- dentry, from, info);
- path_release(&nd);
- EXIT;
- exit_lock:
- up(&nd.dentry->d_inode->i_sem);
- dput(dentry);
- exit_to:
- putname(to);
- exit_from:
- putname(from);
- exit:
- unlock_kernel();
- return error;
-}
-
-int presto_do_mkdir(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error;
- struct presto_version tgt_dir_ver, new_dir_ver;
- void *handle;
-
- ENTRY;
- // down(&dir->d_inode->i_zombie);
-
- /* one journal record + directory block + room for removals*/
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- error = may_create(dir->d_inode, dentry);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- error = -EPERM;
- if (!filter_c2cdiops(fset->fset_cache->cache_filter)->mkdir) {
- EXIT;
- goto exit_lock;
- }
-
- error = -ENOSPC;
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_MKDIR);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- CERROR("presto_do_mkdir: no space for transaction\n");
- goto exit_lock;
- }
-
- DQUOT_INIT(dir->d_inode);
- mode &= (S_IRWXUGO|S_ISVTX);
- lock_kernel();
- error = filter_c2cdiops(fset->fset_cache->cache_filter)->mkdir(dir->d_inode, dentry, mode);
- if (error) {
- EXIT;
- goto exit;
- }
-
- if ( dentry->d_inode && !error) {
- struct presto_cache *cache = fset->fset_cache;
-
- presto_set_ops(dentry->d_inode, cache->cache_filter);
-
- filter_setup_dentry_ops(cache->cache_filter,
- dentry->d_op,
- &presto_dentry_ops);
- dentry->d_op = filter_c2udops(cache->cache_filter);
- /* if Lento does this, we won't have data */
- if ( ISLENTO(presto_c2m(cache)) ) {
- presto_set(dentry, PRESTO_ATTR);
- } else {
- presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
- }
- }
-
- info->flags |= LENTO_FL_TOUCH_PARENT;
- error = presto_settime(fset, NULL, dir, dentry,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- goto exit;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x10);
- presto_getversion(&new_dir_ver, dentry->d_inode);
- if ( presto_do_kml(info, dir) )
- error = presto_journal_mkdir(&rec, fset, dentry, &tgt_dir_ver,
- &new_dir_ver,
- dentry->d_inode->i_mode);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x20);
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKDIR | 0x30);
- EXIT;
-exit:
- unlock_kernel();
- presto_trans_commit(fset, handle);
- exit_lock:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH + 4096);
- // up(&dir->d_inode->i_zombie);
- return error;
-}
-
-/*
- * Look out: this function may change a normal dentry
- * into a directory dentry (different size)..
- */
-int lento_mkdir(const char *name, int mode, struct lento_vfs_context *info)
-{
- int error;
- char *pathname;
- struct dentry *dentry;
- struct presto_file_set *fset;
- struct nameidata nd;
-
- ENTRY;
- CDEBUG(D_PIOCTL, "name: %s, mode %o, offset %d, recno %d, flags %x\n",
- name, mode, info->slot_offset, info->recno, info->flags);
- pathname = getname(name);
- error = PTR_ERR(pathname);
- if (IS_ERR(pathname)) {
- EXIT;
- return error;
- }
-
- error = path_lookup(pathname, LOOKUP_PARENT, &nd);
- if (error)
- goto out_name;
-
- dentry = lookup_create(&nd, 1);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- fset = presto_fset(dentry);
- error = -EINVAL;
- if (!fset) {
- CERROR("No fileset!\n");
- EXIT;
- goto out_dput;
- }
-
- error = presto_do_mkdir(fset, nd.dentry, dentry,
- mode & S_IALLUGO, info);
-out_dput:
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
-out_name:
- EXIT;
- putname(pathname);
- CDEBUG(D_PIOCTL, "error: %d\n", error);
- return error;
-}
-
-static void d_unhash(struct dentry *dentry)
-{
- dget(dentry);
- switch (atomic_read(&dentry->d_count)) {
- default:
- shrink_dcache_parent(dentry);
- if (atomic_read(&dentry->d_count) != 2)
- break;
- case 2:
- d_drop(dentry);
- }
-}
-
-int presto_do_rmdir(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error;
- struct presto_version tgt_dir_ver, old_dir_ver;
- struct izo_rollback_data rb;
- struct inode_operations *iops;
- void *handle;
- int do_kml, do_rcvd;
- int size;
-
- ENTRY;
- error = may_delete(dir->d_inode, dentry, 1);
- if (error)
- return error;
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->rmdir) {
- EXIT;
- return error;
- }
-
- size = PRESTO_REQHIGH - dentry->d_inode->i_size;
- error = presto_reserve_space(fset->fset_cache, size);
- if (error) {
- EXIT;
- return error;
- }
-
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- presto_getversion(&old_dir_ver, dentry->d_inode);
- izo_get_rollback_data(dentry->d_inode, &rb);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_RMDIR);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, size);
- CERROR("ERROR: presto_do_rmdir: no space for transaction. Tell Peter.\n");
- return -ENOSPC;
- }
-
- DQUOT_INIT(dir->d_inode);
-
- do_kml = presto_do_kml(info, dir);
- do_rcvd = presto_do_rcvd(info, dir);
-
- // double_down(&dir->d_inode->i_zombie, &dentry->d_inode->i_zombie);
- d_unhash(dentry);
- if (IS_DEADDIR(dir->d_inode))
- error = -ENOENT;
- else if (d_mountpoint(dentry)) {
- CERROR("foo: d_mountpoint(dentry): ino %ld\n",
- dentry->d_inode->i_ino);
- error = -EBUSY;
- } else {
- lock_kernel();
- error = iops->rmdir(dir->d_inode, dentry);
- unlock_kernel();
- if (!error) {
- dentry->d_inode->i_flags |= S_DEAD;
- error = presto_settime(fset, NULL, NULL, dir, info,
- ATTR_CTIME | ATTR_MTIME);
- }
- }
- // double_up(&dir->d_inode->i_zombie, &dentry->d_inode->i_zombie);
- if (!error)
- d_delete(dentry);
- dput(dentry);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x10);
- if ( !error && do_kml )
- error = presto_journal_rmdir(&rec, fset, dir, &tgt_dir_ver,
- &old_dir_ver, &rb,
- dentry->d_name.len,
- dentry->d_name.name);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x20);
- if ( !error && do_rcvd )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_RMDIR | 0x30);
- EXIT;
-
- presto_trans_commit(fset, handle);
- presto_release_space(fset->fset_cache, size);
- return error;
-}
-
-int lento_rmdir(const char *pathname, struct lento_vfs_context *info)
-{
- int error = 0;
- char * name;
- struct dentry *dentry;
- struct presto_file_set *fset;
- struct nameidata nd;
-
- ENTRY;
- name = getname(pathname);
- if(IS_ERR(name)) {
- EXIT;
- return PTR_ERR(name);
- }
-
- error = path_lookup(name, LOOKUP_PARENT, &nd);
- if (error) {
- EXIT;
- goto exit;
- }
- switch(nd.last_type) {
- case LAST_DOTDOT:
- error = -ENOTEMPTY;
- EXIT;
- goto exit1;
- case LAST_ROOT:
- case LAST_DOT:
- error = -EBUSY;
- EXIT;
- goto exit1;
- }
- down(&nd.dentry->d_inode->i_sem);
- dentry = lookup_hash(&nd.last, nd.dentry);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit_put;
- }
- error = presto_do_rmdir(fset, nd.dentry, dentry, info);
- exit_put:
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
-exit1:
- path_release(&nd);
-exit:
- putname(name);
- EXIT;
- return error;
-}
-
-int presto_do_mknod(struct presto_file_set *fset, struct dentry *dir,
- struct dentry *dentry, int mode, dev_t dev,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error = -EPERM;
- struct presto_version tgt_dir_ver, new_node_ver;
- struct inode_operations *iops;
- void *handle;
-
- ENTRY;
-
- // down(&dir->d_inode->i_zombie);
- /* one KML entry */
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (error) {
- EXIT;
- // up(&dir->d_inode->i_zombie);
- return error;
- }
-
- if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) {
- EXIT;
- goto exit_lock;
- }
-
- error = may_create(dir->d_inode, dentry);
- if (error) {
- EXIT;
- goto exit_lock;
- }
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops->mknod) {
- EXIT;
- goto exit_lock;
- }
-
- DQUOT_INIT(dir->d_inode);
- lock_kernel();
-
- error = -ENOSPC;
- presto_getversion(&tgt_dir_ver, dir->d_inode);
- handle = presto_trans_start(fset, dir->d_inode, KML_OPCODE_MKNOD);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- CERROR("presto_do_mknod: no space for transaction\n");
- goto exit_lock2;
- }
-
- error = iops->mknod(dir->d_inode, dentry, mode, dev);
- if (error) {
- EXIT;
- goto exit_commit;
- }
- if ( dentry->d_inode) {
- struct presto_cache *cache = fset->fset_cache;
-
- presto_set_ops(dentry->d_inode, cache->cache_filter);
-
- filter_setup_dentry_ops(cache->cache_filter, dentry->d_op,
- &presto_dentry_ops);
- dentry->d_op = filter_c2udops(cache->cache_filter);
-
- /* if Lento does this, we won't have data */
- if ( ISLENTO(presto_c2m(cache)) ) {
- presto_set(dentry, PRESTO_ATTR);
- } else {
- presto_set(dentry, PRESTO_ATTR | PRESTO_DATA);
- }
- }
-
- error = presto_settime(fset, NULL, NULL, dir,
- info, ATTR_MTIME);
- if (error) {
- EXIT;
- }
- error = presto_settime(fset, NULL, NULL, dentry,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- }
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x10);
- presto_getversion(&new_node_ver, dentry->d_inode);
- if ( presto_do_kml(info, dentry) )
- error = presto_journal_mknod(&rec, fset, dentry, &tgt_dir_ver,
- &new_node_ver,
- dentry->d_inode->i_mode,
- MAJOR(dev), MINOR(dev) );
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x20);
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_MKNOD | 0x30);
- EXIT;
- exit_commit:
- presto_trans_commit(fset, handle);
- exit_lock2:
- unlock_kernel();
- exit_lock:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- // up(&dir->d_inode->i_zombie);
- return error;
-}
-
-int lento_mknod(const char *filename, int mode, dev_t dev,
- struct lento_vfs_context *info)
-{
- int error = 0;
- char * tmp;
- struct dentry * dentry;
- struct nameidata nd;
- struct presto_file_set *fset;
-
- ENTRY;
-
- if (S_ISDIR(mode))
- return -EPERM;
- tmp = getname(filename);
- if (IS_ERR(tmp))
- return PTR_ERR(tmp);
-
- error = path_lookup(tmp, LOOKUP_PARENT, &nd);
- if (error)
- goto out;
- dentry = lookup_create(&nd, 0);
- error = PTR_ERR(dentry);
- if (!IS_ERR(dentry)) {
- fset = presto_fset(dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit_put;
- }
- switch (mode & S_IFMT) {
- case 0: case S_IFREG:
- error = -EOPNOTSUPP;
- break;
- case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
- error = presto_do_mknod(fset, nd.dentry, dentry,
- mode, dev, info);
- break;
- case S_IFDIR:
- error = -EPERM;
- break;
- default:
- error = -EINVAL;
- }
- exit_put:
- dput(dentry);
- }
- up(&nd.dentry->d_inode->i_sem);
- path_release(&nd);
-out:
- putname(tmp);
-
- return error;
-}
-
-int do_rename(struct presto_file_set *fset,
- struct dentry *old_parent, struct dentry *old_dentry,
- struct dentry *new_parent, struct dentry *new_dentry,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- int error;
- struct inode_operations *iops;
- struct presto_version src_dir_ver, tgt_dir_ver;
- void *handle;
- int new_inode_unlink = 0;
- struct inode *old_dir = old_parent->d_inode;
- struct inode *new_dir = new_parent->d_inode;
-
- ENTRY;
- presto_getversion(&src_dir_ver, old_dir);
- presto_getversion(&tgt_dir_ver, new_dir);
-
- error = -EPERM;
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- if (!iops || !iops->rename) {
- EXIT;
- return error;
- }
-
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (error) {
- EXIT;
- return error;
- }
- handle = presto_trans_start(fset, old_dir, KML_OPCODE_RENAME);
- if ( IS_ERR(handle) ) {
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- CERROR("presto_do_rename: no space for transaction\n");
- return -ENOSPC;
- }
- if (new_dentry->d_inode && new_dentry->d_inode->i_nlink > 1) {
- dget(new_dentry);
- new_inode_unlink = 1;
- }
-
- error = iops->rename(old_dir, old_dentry, new_dir, new_dentry);
-
- if (error) {
- EXIT;
- goto exit;
- }
-
- if (new_inode_unlink) {
- error = presto_settime(fset, NULL, NULL, old_dentry,
- info, ATTR_CTIME);
- dput(old_dentry);
- if (error) {
- EXIT;
- goto exit;
- }
- }
- info->flags |= LENTO_FL_TOUCH_PARENT;
- error = presto_settime(fset, NULL, new_parent, old_parent,
- info, ATTR_CTIME | ATTR_MTIME);
- if (error) {
- EXIT;
- goto exit;
- }
-
- /* XXX make a distinction between cross file set
- * and intra file set renames here
- */
- presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x10);
- if ( presto_do_kml(info, old_dentry) )
- error = presto_journal_rename(&rec, fset, old_dentry,
- new_dentry,
- &src_dir_ver, &tgt_dir_ver);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x20);
-
- if ( presto_do_rcvd(info, old_dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_RENAME | 0x30);
- EXIT;
-exit:
- presto_trans_commit(fset, handle);
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- return error;
-}
-
-static
-int presto_rename_dir(struct presto_file_set *fset, struct dentry *old_parent,
- struct dentry *old_dentry, struct dentry *new_parent,
- struct dentry *new_dentry, struct lento_vfs_context *info)
-{
- int error;
- struct inode *target;
- struct inode *old_dir = old_parent->d_inode;
- struct inode *new_dir = new_parent->d_inode;
-
- if (old_dentry->d_inode == new_dentry->d_inode)
- return 0;
-
- error = may_delete(old_dir, old_dentry, 1);
- if (error)
- return error;
-
- if (new_dir->i_sb != old_dir->i_sb)
- return -EXDEV;
-
- if (!new_dentry->d_inode)
- error = may_create(new_dir, new_dentry);
- else
- error = may_delete(new_dir, new_dentry, 1);
- if (error)
- return error;
-
- if (!old_dir->i_op || !old_dir->i_op->rename)
- return -EPERM;
-
- /*
- * If we are going to change the parent - check write permissions,
- * we'll need to flip '..'.
- */
- if (new_dir != old_dir) {
- error = permission(old_dentry->d_inode, MAY_WRITE, NULL);
- }
- if (error)
- return error;
-
- DQUOT_INIT(old_dir);
- DQUOT_INIT(new_dir);
- down(&old_dir->i_sb->s_vfs_rename_sem);
- error = -EINVAL;
- if (is_subdir(new_dentry, old_dentry))
- goto out_unlock;
- target = new_dentry->d_inode;
- if (target) { /* Hastur! Hastur! Hastur! */
- // triple_down(&old_dir->i_zombie,
- // &new_dir->i_zombie,
- // &target->i_zombie);
- d_unhash(new_dentry);
- } else
- // double_down(&old_dir->i_zombie,
- // &new_dir->i_zombie);
- if (IS_DEADDIR(old_dir)||IS_DEADDIR(new_dir))
- error = -ENOENT;
- else if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
- error = -EBUSY;
- else
- error = do_rename(fset, old_parent, old_dentry,
- new_parent, new_dentry, info);
- if (target) {
- if (!error)
- target->i_flags |= S_DEAD;
- // triple_up(&old_dir->i_zombie,
- // &new_dir->i_zombie,
- // &target->i_zombie);
- if (d_unhashed(new_dentry))
- d_rehash(new_dentry);
- dput(new_dentry);
- } else
- // double_up(&old_dir->i_zombie,
- // &new_dir->i_zombie);
-
- if (!error)
- d_move(old_dentry,new_dentry);
-out_unlock:
- up(&old_dir->i_sb->s_vfs_rename_sem);
- return error;
-}
-
-static
-int presto_rename_other(struct presto_file_set *fset, struct dentry *old_parent,
- struct dentry *old_dentry, struct dentry *new_parent,
- struct dentry *new_dentry, struct lento_vfs_context *info)
-{
- struct inode *old_dir = old_parent->d_inode;
- struct inode *new_dir = new_parent->d_inode;
- int error;
-
- if (old_dentry->d_inode == new_dentry->d_inode)
- return 0;
-
- error = may_delete(old_dir, old_dentry, 0);
- if (error)
- return error;
-
- if (new_dir->i_sb != old_dir->i_sb)
- return -EXDEV;
-
- if (!new_dentry->d_inode)
- error = may_create(new_dir, new_dentry);
- else
- error = may_delete(new_dir, new_dentry, 0);
- if (error)
- return error;
-
- if (!old_dir->i_op || !old_dir->i_op->rename)
- return -EPERM;
-
- DQUOT_INIT(old_dir);
- DQUOT_INIT(new_dir);
- // double_down(&old_dir->i_zombie, &new_dir->i_zombie);
- if (d_mountpoint(old_dentry)||d_mountpoint(new_dentry))
- error = -EBUSY;
- else
- error = do_rename(fset, old_parent, old_dentry,
- new_parent, new_dentry, info);
- // double_up(&old_dir->i_zombie, &new_dir->i_zombie);
- if (error)
- return error;
- /* The following d_move() should become unconditional */
- if (!(old_dir->i_sb->s_type->fs_flags & FS_ODD_RENAME)) {
- d_move(old_dentry, new_dentry);
- }
- return 0;
-}
-
-int presto_do_rename(struct presto_file_set *fset,
- struct dentry *old_parent, struct dentry *old_dentry,
- struct dentry *new_parent, struct dentry *new_dentry,
- struct lento_vfs_context *info)
-{
- if (S_ISDIR(old_dentry->d_inode->i_mode))
- return presto_rename_dir(fset, old_parent,old_dentry,new_parent,
- new_dentry, info);
- else
- return presto_rename_other(fset, old_parent, old_dentry,
- new_parent,new_dentry, info);
-}
-
-
-int lento_do_rename(const char *oldname, const char *newname,
- struct lento_vfs_context *info)
-{
- int error = 0;
- struct dentry * old_dir, * new_dir;
- struct dentry * old_dentry, *new_dentry;
- struct nameidata oldnd, newnd;
- struct presto_file_set *fset;
-
- ENTRY;
-
- error = path_lookup(oldname, LOOKUP_PARENT, &oldnd);
- if (error)
- goto exit;
-
- error = path_lookup(newname, LOOKUP_PARENT, &newnd);
- if (error)
- goto exit1;
-
- error = -EXDEV;
- if (oldnd.mnt != newnd.mnt)
- goto exit2;
-
- old_dir = oldnd.dentry;
- error = -EBUSY;
- if (oldnd.last_type != LAST_NORM)
- goto exit2;
-
- new_dir = newnd.dentry;
- if (newnd.last_type != LAST_NORM)
- goto exit2;
-
- lock_rename(new_dir, old_dir);
-
- old_dentry = lookup_hash(&oldnd.last, old_dir);
- error = PTR_ERR(old_dentry);
- if (IS_ERR(old_dentry))
- goto exit3;
- /* source must exist */
- error = -ENOENT;
- if (!old_dentry->d_inode)
- goto exit4;
- fset = presto_fset(old_dentry);
- error = -EINVAL;
- if ( !fset ) {
- CERROR("No fileset!\n");
- EXIT;
- goto exit4;
- }
- /* unless the source is a directory trailing slashes give -ENOTDIR */
- if (!S_ISDIR(old_dentry->d_inode->i_mode)) {
- error = -ENOTDIR;
- if (oldnd.last.name[oldnd.last.len])
- goto exit4;
- if (newnd.last.name[newnd.last.len])
- goto exit4;
- }
- new_dentry = lookup_hash(&newnd.last, new_dir);
- error = PTR_ERR(new_dentry);
- if (IS_ERR(new_dentry))
- goto exit4;
-
- lock_kernel();
- error = presto_do_rename(fset, old_dir, old_dentry,
- new_dir, new_dentry, info);
- unlock_kernel();
-
- dput(new_dentry);
-exit4:
- dput(old_dentry);
-exit3:
- unlock_rename(new_dir, old_dir);
-exit2:
- path_release(&newnd);
-exit1:
- path_release(&oldnd);
-exit:
- return error;
-}
-
-int lento_rename(const char * oldname, const char * newname,
- struct lento_vfs_context *info)
-{
- int error;
- char * from;
- char * to;
-
- from = getname(oldname);
- if(IS_ERR(from))
- return PTR_ERR(from);
- to = getname(newname);
- error = PTR_ERR(to);
- if (!IS_ERR(to)) {
- error = lento_do_rename(from,to, info);
- putname(to);
- }
- putname(from);
- return error;
-}
-
-struct dentry *presto_iopen(struct dentry *dentry,
- ino_t ino, unsigned int generation)
-{
- struct presto_file_set *fset;
- char name[48];
- int error;
-
- ENTRY;
- /* see if we already have the dentry we want */
- if (dentry->d_inode && dentry->d_inode->i_ino == ino &&
- dentry->d_inode->i_generation == generation) {
- EXIT;
- return dentry;
- }
-
- /* Make sure we have a cache beneath us. We should always find at
- * least one dentry inside the cache (if it exists), otherwise not
- * even the cache root exists, or we passed in a bad name.
- */
- fset = presto_fset(dentry);
- error = -EINVAL;
- if (!fset) {
- CERROR("No fileset for %*s!\n",
- dentry->d_name.len, dentry->d_name.name);
- EXIT;
- dput(dentry);
- return ERR_PTR(error);
- }
- dput(dentry);
-
- sprintf(name, "%s%#lx%c%#x",
- PRESTO_ILOOKUP_MAGIC, ino, PRESTO_ILOOKUP_SEP, generation);
- CDEBUG(D_PIOCTL, "opening %ld by number (as %s)\n", ino, name);
- return lookup_one_len(name, fset->fset_dentry, strlen(name));
-}
-
-static struct file *presto_filp_dopen(struct dentry *dentry, int flags)
-{
- struct file *f;
- struct inode *inode;
- int flag, error;
-
- ENTRY;
- error = -ENFILE;
- f = get_empty_filp();
- if (!f) {
- CDEBUG(D_PIOCTL, "error getting file pointer\n");
- EXIT;
- goto out;
- }
- f->f_flags = flag = flags;
- f->f_mode = (flag+1) & O_ACCMODE;
- inode = dentry->d_inode;
- if (f->f_mode & FMODE_WRITE) {
- error = get_write_access(inode);
- if (error) {
- CDEBUG(D_PIOCTL, "error getting write access\n");
- EXIT; goto cleanup_file;
- }
- }
-
- /* XXX: where the fuck is ->f_vfsmnt? */
- f->f_dentry = dentry;
- f->f_mapping = dentry->d_inode->i_mapping;
- f->f_pos = 0;
- //f->f_reada = 0;
- f->f_op = NULL;
- if (inode->i_op)
- /* XXX should we set to presto ops, or leave at cache ops? */
- f->f_op = inode->i_fop;
- if (f->f_op && f->f_op->open) {
- error = f->f_op->open(inode, f);
- if (error) {
- CDEBUG(D_PIOCTL, "error calling cache 'open'\n");
- EXIT;
- goto cleanup_all;
- }
- }
- f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
-
- return f;
-
-cleanup_all:
- if (f->f_mode & FMODE_WRITE)
- put_write_access(inode);
-cleanup_file:
- put_filp(f);
-out:
- return ERR_PTR(error);
-}
-
-
-/* Open an inode by number. We pass in the cache root name (or a subdirectory
- * from the cache that is guaranteed to exist) to be able to access the cache.
- */
-int lento_iopen(const char *name, ino_t ino, unsigned int generation,
- int flags)
-{
- char * tmp;
- struct dentry *dentry;
- struct nameidata nd;
- int fd;
- int error;
-
- ENTRY;
- CDEBUG(D_PIOCTL,
- "open %s:inode %#lx (%ld), generation %x (%d), flags %d \n",
- name, ino, ino, generation, generation, flags);
- /* We don't allow creation of files by number only, as it would
- * lead to a dangling files not in any directory. We could also
- * just turn off the flag and ignore it.
- */
- if (flags & O_CREAT) {
- CERROR("%s: create file by inode number (%ld) not allowed\n",
- __FUNCTION__, ino);
- EXIT;
- return -EACCES;
- }
-
- tmp = getname(name);
- if (IS_ERR(tmp)) {
- EXIT;
- return PTR_ERR(tmp);
- }
-
- lock_kernel();
-again: /* look the named file or a parent directory so we can get the cache */
- error = presto_walk(tmp, &nd);
- if ( error && error != -ENOENT ) {
- EXIT;
- unlock_kernel();
- putname(tmp);
- return error;
- }
- if (error == -ENOENT)
- dentry = NULL;
- else
- dentry = nd.dentry;
-
- /* we didn't find the named file, so see if a parent exists */
- if (!dentry) {
- char *slash;
-
- slash = strrchr(tmp, '/');
- if (slash && slash != tmp) {
- *slash = '\0';
- path_release(&nd);
- goto again;
- }
- /* we should never get here... */
- CDEBUG(D_PIOCTL, "no more path components to try!\n");
- fd = -ENOENT;
- goto exit;
- }
- CDEBUG(D_PIOCTL, "returned dentry %p\n", dentry);
-
- dentry = presto_iopen(dentry, ino, generation);
- fd = PTR_ERR(dentry);
- if (IS_ERR(dentry)) {
- EXIT;
- goto exit;
- }
-
- /* XXX start of code that might be replaced by something like:
- * if (flags & (O_WRONLY | O_RDWR)) {
- * error = get_write_access(dentry->d_inode);
- * if (error) {
- * EXIT;
- * goto cleanup_dput;
- * }
- * }
- * fd = open_dentry(dentry, flags);
- *
- * including the presto_filp_dopen() function (check dget counts!)
- */
- fd = get_unused_fd();
- if (fd < 0) {
- EXIT;
- goto exit;
- }
-
- {
- int error;
- struct file * f = presto_filp_dopen(dentry, flags);
- error = PTR_ERR(f);
- if (IS_ERR(f)) {
- put_unused_fd(fd);
- fd = error;
- } else {
- fd_install(fd, f);
- }
- }
- /* end of code that might be replaced by open_dentry */
-
- EXIT;
-exit:
- unlock_kernel();
- path_release(&nd);
- putname(tmp);
- return fd;
-}
-
-#ifdef CONFIG_FS_EXT_ATTR
-
-#if 0 /* was a broken check for Posix ACLs */
-/* Posix ACL code changes i_mode without using a notify_change (or
- * a mark_inode_dirty!). We need to duplicate this at the reintegrator
- * which is done by this function. This function also takes care of
- * resetting the cached posix acls in this inode. If we don't reset these
- * VFS continues using the old acl information, which by now may be out of
- * date.
- */
-int presto_setmode(struct presto_file_set *fset, struct dentry *dentry,
- mode_t mode)
-{
- struct inode *inode = dentry->d_inode;
-
- ENTRY;
- /* The extended attributes for this inode were modified.
- * At this point we can not be sure if any of the ACL
- * information for this inode was updated. So we will
- * force VFS to reread the acls. Note that we do this
- * only when called from the SETEXTATTR ioctl, which is why we
- * do this while setting the mode of the file. Also note
- * that mark_inode_dirty is not be needed for i_*acl only
- * to force i_mode info to disk, and should be removed once
- * we use notify_change to update the mode.
- * XXX: is mode setting really needed? Just setting acl's should
- * be enough! VFS should change the i_mode as needed? SHP
- */
- if (inode->i_acl &&
- inode->i_acl != POSIX_ACL_NOT_CACHED)
- posix_acl_release(inode->i_acl);
- if (inode->i_default_acl &&
- inode->i_default_acl != POSIX_ACL_NOT_CACHED)
- posix_acl_release(inode->i_default_acl);
- inode->i_acl = POSIX_ACL_NOT_CACHED;
- inode->i_default_acl = POSIX_ACL_NOT_CACHED;
- inode->i_mode = mode;
- /* inode should already be dirty...but just in case */
- mark_inode_dirty(inode);
- return 0;
-
-#if 0
- /* XXX: The following code is the preferred way to set mode,
- * however, I need to carefully go through possible recursion
- * paths back into presto. See comments in presto_do_setattr.
- */
- {
- int error=0;
- struct super_operations *sops;
- struct iattr iattr;
-
- iattr.ia_mode = mode;
- iattr.ia_valid = ATTR_MODE|ATTR_FORCE;
-
- error = -EPERM;
- sops = filter_c2csops(fset->fset_cache->cache_filter);
- if (!sops &&
- !sops->notify_change) {
- EXIT;
- return error;
- }
-
- error = sops->notify_change(dentry, &iattr);
-
- EXIT;
- return error;
- }
-#endif
-}
-#endif
-
-/* setextattr Interface to cache filesystem */
-int presto_do_set_ext_attr(struct presto_file_set *fset,
- struct dentry *dentry,
- const char *name, void *buffer,
- size_t buffer_len, int flags, mode_t *mode,
- struct lento_vfs_context *info)
-{
- struct rec_info rec;
- struct inode *inode = dentry->d_inode;
- struct inode_operations *iops;
- int error;
- struct presto_version ver;
- void *handle;
- char temp[PRESTO_EXT_ATTR_NAME_MAX+1];
-
- ENTRY;
- error = -EROFS;
- if (IS_RDONLY(inode)) {
- EXIT;
- return -EROFS;
- }
-
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- EXIT;
- return -EPERM;
- }
-
- presto_getversion(&ver, inode);
- error = -EPERM;
- /* We need to invoke different filters based on whether
- * this dentry is a regular file, directory or symlink.
- */
- switch (inode->i_mode & S_IFMT) {
- case S_IFLNK: /* symlink */
- iops = filter_c2csiops(fset->fset_cache->cache_filter);
- break;
- case S_IFDIR: /* directory */
- iops = filter_c2cdiops(fset->fset_cache->cache_filter);
- break;
- case S_IFREG:
- default: /* everything else including regular files */
- iops = filter_c2cfiops(fset->fset_cache->cache_filter);
- }
-
- if (!iops && !iops->set_ext_attr) {
- EXIT;
- return error;
- }
-
- error = presto_reserve_space(fset->fset_cache, PRESTO_REQHIGH);
- if (error) {
- EXIT;
- return error;
- }
-
-
- handle = presto_trans_start(fset,dentry->d_inode,KML_OPCODE_SETEXTATTR);
- if ( IS_ERR(handle) ) {
- CERROR("presto_do_set_ext_attr: no space for transaction\n");
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- return -ENOSPC;
- }
-
- /* We first "truncate" name to the maximum allowable in presto */
- /* This simulates the strncpy_from_use code in fs/ext_attr.c */
- strlcpy(temp,name,sizeof(temp));
-
- /* Pass down to cache*/
- error = iops->set_ext_attr(inode,temp,buffer,buffer_len,flags);
- if (error) {
- EXIT;
- goto exit;
- }
-
-#if 0 /* was a broken check for Posix ACLs */
- /* Reset mode if specified*/
- /* XXX: when we do native acl support, move this code out! */
- if (mode != NULL) {
- error = presto_setmode(fset, dentry, *mode);
- if (error) {
- EXIT;
- goto exit;
- }
- }
-#endif
-
- /* Reset ctime. Only inode change time (ctime) is affected */
- error = presto_settime(fset, NULL, NULL, dentry, info, ATTR_CTIME);
- if (error) {
- EXIT;
- goto exit;
- }
-
- if (flags & EXT_ATTR_FLAG_USER) {
- CERROR(" USER flag passed to presto_do_set_ext_attr!\n");
- BUG();
- }
-
- /* We are here, so set_ext_attr succeeded. We no longer need to keep
- * track of EXT_ATTR_FLAG_{EXISTS,CREATE}, instead, we will force
- * the attribute value during log replay. -SHP
- */
- flags &= ~(EXT_ATTR_FLAG_EXISTS | EXT_ATTR_FLAG_CREATE);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x10);
- if ( presto_do_kml(info, dentry) )
- error = presto_journal_set_ext_attr
- (&rec, fset, dentry, &ver, name, buffer,
- buffer_len, flags);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x20);
- if ( presto_do_rcvd(info, dentry) )
- error = presto_write_last_rcvd(&rec, fset, info);
-
- presto_debug_fail_blkdev(fset, KML_OPCODE_SETEXTATTR | 0x30);
- EXIT;
-exit:
- presto_release_space(fset->fset_cache, PRESTO_REQHIGH);
- presto_trans_commit(fset, handle);
-
- return error;
-}
-#endif
+++ /dev/null
-/*
- * NEC PC-9800 series partition supports
- *
- * Copyright (C) 1999 Kyoto University Microcomputer Club
- */
-
-#include <linux/config.h>
-#include <linux/fs.h>
-#include <linux/genhd.h>
-#include <linux/kernel.h>
-#include <linux/hdreg.h>
-
-#include "check.h"
-#include "nec98.h"
-
-struct nec98_partition {
- __u8 mid; /* 0x80 - active */
- __u8 sid; /* 0x80 - bootable */
- __u16 pad1; /* dummy for padding */
- __u8 ipl_sector; /* IPL sector */
- __u8 ipl_head; /* IPL head */
- __u16 ipl_cyl; /* IPL cylinder */
- __u8 sector; /* starting sector */
- __u8 head; /* starting head */
- __u16 cyl; /* starting cylinder */
- __u8 end_sector; /* end sector */
- __u8 end_head; /* end head */
- __u16 end_cyl; /* end cylinder */
- unsigned char name[16];
-} __attribute__((__packed__));
-
-#define NEC98_BSD_PARTITION_MID 0x14
-#define NEC98_BSD_PARTITION_SID 0x44
-#define MID_SID_16(mid, sid) (((mid) & 0xFF) | (((sid) & 0xFF) << 8))
-#define NEC98_BSD_PARTITION_MID_SID \
- MID_SID_16(NEC98_BSD_PARTITION_MID, NEC98_BSD_PARTITION_SID)
-#define NEC98_VALID_PTABLE_ENTRY(P) \
- (!(P)->pad1 && (P)->cyl <= (P)->end_cyl)
-
-extern int pc98_bios_param(struct block_device *bdev, int *ip);
-
-static inline int
-is_valid_nec98_partition_table(const struct nec98_partition *ptable,
- __u8 nsectors, __u8 nheads)
-{
- int i;
- int valid = 0;
-
- for (i = 0; i < 16; i++) {
- if (!*(__u16 *)&ptable[i])
- continue; /* empty slot */
- if (ptable[i].pad1 /* `pad1' contains junk */
- || ptable[i].ipl_sector >= nsectors
- || ptable[i].sector >= nsectors
- || ptable[i].end_sector >= nsectors
- || ptable[i].ipl_head >= nheads
- || ptable[i].head >= nheads
- || ptable[i].end_head >= nheads
- || ptable[i].cyl > ptable[i].end_cyl)
- return 0;
- valid = 1; /* We have a valid partition. */
- }
- /* If no valid PC-9800-style partitions found,
- the disk may have other type of partition table. */
- return valid;
-}
-
-int nec98_partition(struct parsed_partitions *state, struct block_device *bdev)
-{
- unsigned int nr;
- struct hd_geometry geo;
- Sector sect;
- const struct nec98_partition *part;
- unsigned char *data;
- int sector_size = bdev_hardsect_size(bdev);
-
- if (ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)&geo) != 0) {
- printk(" unsupported disk (%s)\n", bdev->bd_disk->disk_name);
- return 0;
- }
-
-#ifdef NEC98_PARTITION_DEBUG
- printk("ioctl_by_bdev head=%d sect=%d\n", geo.heads, geo.sectors);
-#endif
- data = read_dev_sector(bdev, 0, §);
- if (!data) {
- if (warn_no_part)
- printk(" unable to read partition table\n");
- return -1;
- }
-
- /* magic(?) check */
- if (*(__u16 *)(data + sector_size - 2) != NEC98_PTABLE_MAGIC) {
- put_dev_sector(sect);
- return 0;
- }
-
- put_dev_sector(sect);
- data = read_dev_sector(bdev, 1, §);
- if (!data) {
- if (warn_no_part)
- printk(" unable to read partition table\n");
- return -1;
- }
-
- if (!is_valid_nec98_partition_table((struct nec98_partition *)data,
- geo.sectors, geo.heads)) {
-#ifdef NEC98_PARTITION_DEBUG
- if (warn_no_part)
- printk(" partition table consistency check failed"
- " (not PC-9800 disk?)\n");
-#endif
- put_dev_sector(sect);
- return 0;
- }
-
- part = (const struct nec98_partition *)data;
- for (nr = 0; nr < 16; nr++, part++) {
- unsigned int start_sect, end_sect;
-
- if (part->mid == 0 || part->sid == 0)
- continue;
-
- if (nr)
- printk(" ");
-
- { /* Print partition name. Fdisk98 might put NUL
- characters in partition name... */
-
- int j;
- unsigned char *p;
- unsigned char buf[sizeof (part->name) * 2 + 1];
-
- for (p = buf, j = 0; j < sizeof (part->name); j++, p++)
- if ((*p = part->name[j]) < ' ') {
- *p++ = '^';
- *p = part->name[j] + '@';
- }
-
- *p = 0;
- printk(" <%s>", buf);
- }
- start_sect = (part->cyl * geo.heads + part->head) * geo.sectors
- + part->sector;
- end_sect = (part->end_cyl + 1) * geo.heads * geo.sectors;
- if (end_sect <= start_sect) {
- printk(" (invalid partition info)\n");
- continue;
- }
-
- put_partition(state, nr + 1, start_sect, end_sect - start_sect);
-#ifdef CONFIG_BSD_DISKLABEL
- if ((*(__u16 *)&part->mid & 0x7F7F)
- == NEC98_BSD_PARTITION_MID_SID) {
- printk("!");
- /* NEC98_BSD_PARTITION_MID_SID is not valid SYSIND for
- IBM PC's MS-DOS partition table, so we simply pass
- it to bsd_disklabel_partition;
- it will just print `<bsd: ... >'. */
- parse_bsd(state, bdev, start_sect,
- end_sect - start_sect, nr + 1,
- "bsd98", BSD_MAXPARTITIONS);
- }
-#endif
- { /* Pretty size printing. */
- /* XXX sector size? */
- unsigned int psize = (end_sect - start_sect) / 2;
- int unit_char = 'K';
-
- if (psize > 99999) {
- psize >>= 10;
- unit_char = 'M';
- }
- printk(" %5d%cB (%5d-%5d)\n",
- psize, unit_char, part->cyl, part->end_cyl);
- }
- }
-
- put_dev_sector(sect);
-
- return nr ? 1 : 0;
-}
-\f
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
+++ /dev/null
-/*
- * NEC PC-9800 series partition supports
- *
- * Copyright (C) 1998-2000 Kyoto University Microcomputer Club
- */
-
-#define NEC98_PTABLE_MAGIC 0xAA55
-
-extern int nec98_partition(struct parsed_partitions *state,
- struct block_device *bdev);
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_KMEM_H__
-#define __XFS_SUPPORT_KMEM_H__
-
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-
-/*
- * Cutoff point to use vmalloc instead of kmalloc.
- */
-#define MAX_SLAB_SIZE 0x10000
-
-/*
- * XFS uses slightly different names for these due to the
- * IRIX heritage.
- */
-#define kmem_zone kmem_cache_s
-#define kmem_zone_t kmem_cache_t
-
-#define KM_SLEEP 0x0001
-#define KM_NOSLEEP 0x0002
-#define KM_NOFS 0x0004
-
-typedef unsigned long xfs_pflags_t;
-
-#define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS)
-
-/* these could be nested, so we save state */
-#define PFLAGS_SET_FSTRANS(STATEP) do { \
- *(STATEP) = current->flags; \
- current->flags |= PF_FSTRANS; \
-} while (0)
-
-#define PFLAGS_CLEAR_FSTRANS(STATEP) do { \
- *(STATEP) = current->flags; \
- current->flags &= ~PF_FSTRANS; \
-} while (0)
-
-/* Restore the PF_FSTRANS state to what was saved in STATEP */
-#define PFLAGS_RESTORE_FSTRANS(STATEP) do { \
- current->flags = ((current->flags & ~PF_FSTRANS) | \
- (*(STATEP) & PF_FSTRANS)); \
-} while (0)
-
-#define PFLAGS_DUP(OSTATEP, NSTATEP) do { \
- *(NSTATEP) = *(OSTATEP); \
-} while (0)
-
-/*
- * XXX get rid of the unconditional __GFP_NOFAIL by adding
- * a KM_FAIL flag and using it where we're allowed to fail.
- */
-static __inline unsigned int
-kmem_flags_convert(int flags)
-{
- int lflags;
-
-#if DEBUG
- if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS))) {
- printk(KERN_WARNING
- "XFS: memory allocation with wrong flags (%x)\n", flags);
- BUG();
- }
-#endif
-
- lflags = (flags & KM_NOSLEEP) ? GFP_ATOMIC : (GFP_KERNEL|__GFP_NOFAIL);
-
- /* avoid recusive callbacks to filesystem during transactions */
- if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
- lflags &= ~__GFP_FS;
-
- return lflags;
-}
-
-static __inline void *
-kmem_alloc(size_t size, int flags)
-{
- if (unlikely(MAX_SLAB_SIZE < size))
- /* Avoid doing filesystem sensitive stuff to get this */
- return __vmalloc(size, kmem_flags_convert(flags), PAGE_KERNEL);
- return kmalloc(size, kmem_flags_convert(flags));
-}
-
-static __inline void *
-kmem_zalloc(size_t size, int flags)
-{
- void *ptr = kmem_alloc(size, flags);
- if (likely(ptr != NULL))
- memset(ptr, 0, size);
- return ptr;
-}
-
-static __inline void
-kmem_free(void *ptr, size_t size)
-{
- if (unlikely((unsigned long)ptr < VMALLOC_START ||
- (unsigned long)ptr >= VMALLOC_END))
- kfree(ptr);
- else
- vfree(ptr);
-}
-
-static __inline void *
-kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
-{
- void *new = kmem_alloc(newsize, flags);
-
- if (likely(ptr != NULL)) {
- if (likely(new != NULL))
- memcpy(new, ptr, min(oldsize, newsize));
- kmem_free(ptr, oldsize);
- }
-
- return new;
-}
-
-static __inline kmem_zone_t *
-kmem_zone_init(int size, char *zone_name)
-{
- return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
-}
-
-static __inline void *
-kmem_zone_alloc(kmem_zone_t *zone, int flags)
-{
- return kmem_cache_alloc(zone, kmem_flags_convert(flags));
-}
-
-static __inline void *
-kmem_zone_zalloc(kmem_zone_t *zone, int flags)
-{
- void *ptr = kmem_zone_alloc(zone, flags);
- if (likely(ptr != NULL))
- memset(ptr, 0, kmem_cache_size(zone));
- return ptr;
-}
-
-static __inline void
-kmem_zone_free(kmem_zone_t *zone, void *ptr)
-{
- kmem_cache_free(zone, ptr);
-}
-
-typedef struct shrinker *kmem_shaker_t;
-typedef int (*kmem_shake_func_t)(int, unsigned int);
-
-static __inline kmem_shaker_t
-kmem_shake_register(kmem_shake_func_t sfunc)
-{
- return set_shrinker(DEFAULT_SEEKS, sfunc);
-}
-
-static __inline void
-kmem_shake_deregister(kmem_shaker_t shrinker)
-{
- remove_shrinker(shrinker);
-}
-
-static __inline int
-kmem_shake_allow(unsigned int gfp_mask)
-{
- return (gfp_mask & __GFP_WAIT);
-}
-
-#endif /* __XFS_SUPPORT_KMEM_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_MRLOCK_H__
-#define __XFS_SUPPORT_MRLOCK_H__
-
-#include <linux/rwsem.h>
-
-enum { MR_NONE, MR_ACCESS, MR_UPDATE };
-
-typedef struct {
- struct rw_semaphore mr_lock;
- int mr_writer;
-} mrlock_t;
-
-#define mrinit(mrp, name) \
- ( (mrp)->mr_writer = 0, init_rwsem(&(mrp)->mr_lock) )
-#define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
-#define mrfree(mrp) do { } while (0)
-#define mraccess(mrp) mraccessf(mrp, 0)
-#define mrupdate(mrp) mrupdatef(mrp, 0)
-
-static inline void mraccessf(mrlock_t *mrp, int flags)
-{
- down_read(&mrp->mr_lock);
-}
-
-static inline void mrupdatef(mrlock_t *mrp, int flags)
-{
- down_write(&mrp->mr_lock);
- mrp->mr_writer = 1;
-}
-
-static inline int mrtryaccess(mrlock_t *mrp)
-{
- return down_read_trylock(&mrp->mr_lock);
-}
-
-static inline int mrtryupdate(mrlock_t *mrp)
-{
- if (!down_write_trylock(&mrp->mr_lock))
- return 0;
- mrp->mr_writer = 1;
- return 1;
-}
-
-static inline void mrunlock(mrlock_t *mrp)
-{
- if (mrp->mr_writer) {
- mrp->mr_writer = 0;
- up_write(&mrp->mr_lock);
- } else {
- up_read(&mrp->mr_lock);
- }
-}
-
-static inline void mrdemote(mrlock_t *mrp)
-{
- mrp->mr_writer = 0;
- downgrade_write(&mrp->mr_lock);
-}
-
-#ifdef DEBUG
-/*
- * Debug-only routine, without some platform-specific asm code, we can
- * now only answer requests regarding whether we hold the lock for write
- * (reader state is outside our visibility, we only track writer state).
- * Note: means !ismrlocked would give false positivies, so don't do that.
- */
-static inline int ismrlocked(mrlock_t *mrp, int type)
-{
- if (mrp && type == MR_UPDATE)
- return mrp->mr_writer;
- return 1;
-}
-#endif
-
-#endif /* __XFS_SUPPORT_MRLOCK_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_MUTEX_H__
-#define __XFS_SUPPORT_MUTEX_H__
-
-#include <linux/spinlock.h>
-#include <asm/semaphore.h>
-
-/*
- * Map the mutex'es from IRIX to Linux semaphores.
- *
- * Destroy just simply initializes to -99 which should block all other
- * callers.
- */
-#define MUTEX_DEFAULT 0x0
-typedef struct semaphore mutex_t;
-
-#define mutex_init(lock, type, name) sema_init(lock, 1)
-#define mutex_destroy(lock) sema_init(lock, -99)
-#define mutex_lock(lock, num) down(lock)
-#define mutex_trylock(lock) (down_trylock(lock) ? 0 : 1)
-#define mutex_unlock(lock) up(lock)
-
-#endif /* __XFS_SUPPORT_MUTEX_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SEMA_H__
-#define __XFS_SUPPORT_SEMA_H__
-
-#include <linux/time.h>
-#include <linux/wait.h>
-#include <asm/atomic.h>
-#include <asm/semaphore.h>
-
-/*
- * sema_t structure just maps to struct semaphore in Linux kernel.
- */
-
-typedef struct semaphore sema_t;
-
-#define init_sema(sp, val, c, d) sema_init(sp, val)
-#define initsema(sp, val) sema_init(sp, val)
-#define initnsema(sp, val, name) sema_init(sp, val)
-#define psema(sp, b) down(sp)
-#define vsema(sp) up(sp)
-#define valusema(sp) (atomic_read(&(sp)->count))
-#define freesema(sema)
-
-/*
- * Map cpsema (try to get the sema) to down_trylock. We need to switch
- * the return values since cpsema returns 1 (acquired) 0 (failed) and
- * down_trylock returns the reverse 0 (acquired) 1 (failed).
- */
-
-#define cpsema(sp) (down_trylock(sp) ? 0 : 1)
-
-/*
- * Didn't do cvsema(sp). Not sure how to map this to up/down/...
- * It does a vsema if the values is < 0 other wise nothing.
- */
-
-#endif /* __XFS_SUPPORT_SEMA_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SPIN_H__
-#define __XFS_SUPPORT_SPIN_H__
-
-#include <linux/sched.h> /* preempt needs this */
-#include <linux/spinlock.h>
-
-/*
- * Map lock_t from IRIX to Linux spinlocks.
- *
- * Note that linux turns on/off spinlocks depending on CONFIG_SMP.
- * We don't need to worry about SMP or not here.
- */
-
-#define SPLDECL(s) unsigned long s
-
-typedef spinlock_t lock_t;
-
-#define spinlock_init(lock, name) spin_lock_init(lock)
-#define spinlock_destroy(lock)
-
-static inline unsigned long mutex_spinlock(lock_t *lock)
-{
- spin_lock(lock);
- return 0;
-}
-
-/*ARGSUSED*/
-static inline void mutex_spinunlock(lock_t *lock, unsigned long s)
-{
- spin_unlock(lock);
-}
-
-static inline void nested_spinlock(lock_t *lock)
-{
- spin_lock(lock);
-}
-
-static inline void nested_spinunlock(lock_t *lock)
-{
- spin_unlock(lock);
-}
-
-#endif /* __XFS_SUPPORT_SPIN_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_SV_H__
-#define __XFS_SUPPORT_SV_H__
-
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-
-/*
- * Synchronisation variables.
- *
- * (Parameters "pri", "svf" and "rts" are not implemented)
- */
-
-typedef struct sv_s {
- wait_queue_head_t waiters;
-} sv_t;
-
-#define SV_FIFO 0x0 /* sv_t is FIFO type */
-#define SV_LIFO 0x2 /* sv_t is LIFO type */
-#define SV_PRIO 0x4 /* sv_t is PRIO type */
-#define SV_KEYED 0x6 /* sv_t is KEYED type */
-#define SV_DEFAULT SV_FIFO
-
-
-static inline void _sv_wait(sv_t *sv, spinlock_t *lock, int state,
- unsigned long timeout)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- add_wait_queue_exclusive(&sv->waiters, &wait);
- __set_current_state(state);
- spin_unlock(lock);
-
- schedule_timeout(timeout);
-
- remove_wait_queue(&sv->waiters, &wait);
-}
-
-#define init_sv(sv,type,name,flag) \
- init_waitqueue_head(&(sv)->waiters)
-#define sv_init(sv,flag,name) \
- init_waitqueue_head(&(sv)->waiters)
-#define sv_destroy(sv) \
- /*NOTHING*/
-#define sv_wait(sv, pri, lock, s) \
- _sv_wait(sv, lock, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT)
-#define sv_wait_sig(sv, pri, lock, s) \
- _sv_wait(sv, lock, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT)
-#define sv_timedwait(sv, pri, lock, s, svf, ts, rts) \
- _sv_wait(sv, lock, TASK_UNINTERRUPTIBLE, timespec_to_jiffies(ts))
-#define sv_timedwait_sig(sv, pri, lock, s, svf, ts, rts) \
- _sv_wait(sv, lock, TASK_INTERRUPTIBLE, timespec_to_jiffies(ts))
-#define sv_signal(sv) \
- wake_up(&(sv)->waiters)
-#define sv_broadcast(sv) \
- wake_up_all(&(sv)->waiters)
-
-#endif /* __XFS_SUPPORT_SV_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPPORT_TIME_H__
-#define __XFS_SUPPORT_TIME_H__
-
-#include <linux/sched.h>
-#include <linux/time.h>
-
-typedef struct timespec timespec_t;
-
-static inline void delay(long ticks)
-{
- current->state = TASK_UNINTERRUPTIBLE;
- schedule_timeout(ticks);
-}
-
-static inline void nanotime(struct timespec *tvp)
-{
- *tvp = CURRENT_TIME;
-}
-
-#endif /* __XFS_SUPPORT_TIME_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_trans.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_alloc.h"
-#include "xfs_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_error.h"
-#include "xfs_rw.h"
-#include "xfs_iomap.h"
-#include <linux/mpage.h>
-
-STATIC void xfs_count_page_state(struct page *, int *, int *, int *);
-STATIC void xfs_convert_page(struct inode *, struct page *,
- xfs_iomap_t *, void *, int, int);
-
-#if defined(XFS_RW_TRACE)
-void
-xfs_page_trace(
- int tag,
- struct inode *inode,
- struct page *page,
- int mask)
-{
- xfs_inode_t *ip;
- bhv_desc_t *bdp;
- vnode_t *vp = LINVFS_GET_VP(inode);
- loff_t isize = i_size_read(inode);
- loff_t offset = page->index << PAGE_CACHE_SHIFT;
- int delalloc = -1, unmapped = -1, unwritten = -1;
-
- if (page_has_buffers(page))
- xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-
- bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops);
- ip = XFS_BHVTOI(bdp);
- if (!ip->i_rwtrace)
- return;
-
- ktrace_enter(ip->i_rwtrace,
- (void *)((unsigned long)tag),
- (void *)ip,
- (void *)inode,
- (void *)page,
- (void *)((unsigned long)mask),
- (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
- (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
- (void *)((unsigned long)((isize >> 32) & 0xffffffff)),
- (void *)((unsigned long)(isize & 0xffffffff)),
- (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
- (void *)((unsigned long)(offset & 0xffffffff)),
- (void *)((unsigned long)delalloc),
- (void *)((unsigned long)unmapped),
- (void *)((unsigned long)unwritten),
- (void *)NULL,
- (void *)NULL);
-}
-#else
-#define xfs_page_trace(tag, inode, page, mask)
-#endif
-
-void
-linvfs_unwritten_done(
- struct buffer_head *bh,
- int uptodate)
-{
- xfs_buf_t *pb = (xfs_buf_t *)bh->b_private;
-
- ASSERT(buffer_unwritten(bh));
- bh->b_end_io = NULL;
- clear_buffer_unwritten(bh);
- if (!uptodate)
- pagebuf_ioerror(pb, EIO);
- if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
- pagebuf_iodone(pb, 1, 1);
- }
- end_buffer_async_write(bh, uptodate);
-}
-
-/*
- * Issue transactions to convert a buffer range from unwritten
- * to written extents (buffered IO).
- */
-STATIC void
-linvfs_unwritten_convert(
- xfs_buf_t *bp)
-{
- vnode_t *vp = XFS_BUF_FSPRIVATE(bp, vnode_t *);
- int error;
-
- BUG_ON(atomic_read(&bp->pb_hold) < 1);
- VOP_BMAP(vp, XFS_BUF_OFFSET(bp), XFS_BUF_SIZE(bp),
- BMAPI_UNWRITTEN, NULL, NULL, error);
- XFS_BUF_SET_FSPRIVATE(bp, NULL);
- XFS_BUF_CLR_IODONE_FUNC(bp);
- XFS_BUF_UNDATAIO(bp);
- iput(LINVFS_GET_IP(vp));
- pagebuf_iodone(bp, 0, 0);
-}
-
-/*
- * Issue transactions to convert a buffer range from unwritten
- * to written extents (direct IO).
- */
-STATIC void
-linvfs_unwritten_convert_direct(
- struct inode *inode,
- loff_t offset,
- ssize_t size,
- void *private)
-{
- ASSERT(!private || inode == (struct inode *)private);
-
- /* private indicates an unwritten extent lay beneath this IO,
- * see linvfs_get_block_core.
- */
- if (private && size > 0) {
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error;
-
- VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
- }
-}
-
-STATIC int
-xfs_map_blocks(
- struct inode *inode,
- loff_t offset,
- ssize_t count,
- xfs_iomap_t *iomapp,
- int flags)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error, niomaps = 1;
-
- if (((flags & (BMAPI_DIRECT|BMAPI_SYNC)) == BMAPI_DIRECT) &&
- (offset >= i_size_read(inode)))
- count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
-retry:
- VOP_BMAP(vp, offset, count, flags, iomapp, &niomaps, error);
- if ((error == EAGAIN) || (error == EIO))
- return -error;
- if (unlikely((flags & (BMAPI_WRITE|BMAPI_DIRECT)) ==
- (BMAPI_WRITE|BMAPI_DIRECT) && niomaps &&
- (iomapp->iomap_flags & IOMAP_DELAY))) {
- flags = BMAPI_ALLOCATE;
- goto retry;
- }
- if (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
- VMODIFY(vp);
- }
- return -error;
-}
-
-/*
- * Finds the corresponding mapping in block @map array of the
- * given @offset within a @page.
- */
-STATIC xfs_iomap_t *
-xfs_offset_to_map(
- struct page *page,
- xfs_iomap_t *iomapp,
- unsigned long offset)
-{
- loff_t full_offset; /* offset from start of file */
-
- ASSERT(offset < PAGE_CACHE_SIZE);
-
- full_offset = page->index; /* NB: using 64bit number */
- full_offset <<= PAGE_CACHE_SHIFT; /* offset from file start */
- full_offset += offset; /* offset from page start */
-
- if (full_offset < iomapp->iomap_offset)
- return NULL;
- if (iomapp->iomap_offset + iomapp->iomap_bsize > full_offset)
- return iomapp;
- return NULL;
-}
-
-STATIC void
-xfs_map_at_offset(
- struct page *page,
- struct buffer_head *bh,
- unsigned long offset,
- int block_bits,
- xfs_iomap_t *iomapp)
-{
- xfs_daddr_t bn;
- loff_t delta;
- int sector_shift;
-
- ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
- ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
- ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
-
- delta = page->index;
- delta <<= PAGE_CACHE_SHIFT;
- delta += offset;
- delta -= iomapp->iomap_offset;
- delta >>= block_bits;
-
- sector_shift = block_bits - BBSHIFT;
- bn = iomapp->iomap_bn >> sector_shift;
- bn += delta;
- ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
-
- lock_buffer(bh);
- bh->b_blocknr = bn;
- bh->b_bdev = iomapp->iomap_target->pbr_bdev;
- set_buffer_mapped(bh);
- clear_buffer_delay(bh);
-}
-
-/*
- * Look for a page at index which is unlocked and contains our
- * unwritten extent flagged buffers at its head. Returns page
- * locked and with an extra reference count, and length of the
- * unwritten extent component on this page that we can write,
- * in units of filesystem blocks.
- */
-STATIC struct page *
-xfs_probe_unwritten_page(
- struct address_space *mapping,
- pgoff_t index,
- xfs_iomap_t *iomapp,
- xfs_buf_t *pb,
- unsigned long max_offset,
- unsigned long *fsbs,
- unsigned int bbits)
-{
- struct page *page;
-
- page = find_trylock_page(mapping, index);
- if (!page)
- return 0;
- if (PageWriteback(page))
- goto out;
-
- if (page->mapping && page_has_buffers(page)) {
- struct buffer_head *bh, *head;
- unsigned long p_offset = 0;
-
- *fsbs = 0;
- bh = head = page_buffers(page);
- do {
- if (!buffer_unwritten(bh))
- break;
- if (!xfs_offset_to_map(page, iomapp, p_offset))
- break;
- if (p_offset >= max_offset)
- break;
- xfs_map_at_offset(page, bh, p_offset, bbits, iomapp);
- set_buffer_unwritten_io(bh);
- bh->b_private = pb;
- p_offset += bh->b_size;
- (*fsbs)++;
- } while ((bh = bh->b_this_page) != head);
-
- if (p_offset)
- return page;
- }
-
-out:
- unlock_page(page);
- return NULL;
-}
-
-/*
- * Look for a page at index which is unlocked and not mapped
- * yet - clustering for mmap write case.
- */
-STATIC unsigned int
-xfs_probe_unmapped_page(
- struct address_space *mapping,
- pgoff_t index,
- unsigned int pg_offset)
-{
- struct page *page;
- int ret = 0;
-
- page = find_trylock_page(mapping, index);
- if (!page)
- return 0;
- if (PageWriteback(page))
- goto out;
-
- if (page->mapping && PageDirty(page)) {
- if (page_has_buffers(page)) {
- struct buffer_head *bh, *head;
-
- bh = head = page_buffers(page);
- do {
- if (buffer_mapped(bh) || !buffer_uptodate(bh))
- break;
- ret += bh->b_size;
- if (ret >= pg_offset)
- break;
- } while ((bh = bh->b_this_page) != head);
- } else
- ret = PAGE_CACHE_SIZE;
- }
-
-out:
- unlock_page(page);
- return ret;
-}
-
-STATIC unsigned int
-xfs_probe_unmapped_cluster(
- struct inode *inode,
- struct page *startpage,
- struct buffer_head *bh,
- struct buffer_head *head)
-{
- pgoff_t tindex, tlast, tloff;
- unsigned int pg_offset, len, total = 0;
- struct address_space *mapping = inode->i_mapping;
-
- /* First sum forwards in this page */
- do {
- if (buffer_mapped(bh))
- break;
- total += bh->b_size;
- } while ((bh = bh->b_this_page) != head);
-
- /* If we reached the end of the page, sum forwards in
- * following pages.
- */
- if (bh == head) {
- tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
- /* Prune this back to avoid pathological behavior */
- tloff = min(tlast, startpage->index + 64);
- for (tindex = startpage->index + 1; tindex < tloff; tindex++) {
- len = xfs_probe_unmapped_page(mapping, tindex,
- PAGE_CACHE_SIZE);
- if (!len)
- return total;
- total += len;
- }
- if (tindex == tlast &&
- (pg_offset = i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
- total += xfs_probe_unmapped_page(mapping,
- tindex, pg_offset);
- }
- }
- return total;
-}
-
-/*
- * Probe for a given page (index) in the inode and test if it is delayed
- * and without unwritten buffers. Returns page locked and with an extra
- * reference count.
- */
-STATIC struct page *
-xfs_probe_delalloc_page(
- struct inode *inode,
- pgoff_t index)
-{
- struct page *page;
-
- page = find_trylock_page(inode->i_mapping, index);
- if (!page)
- return NULL;
- if (PageWriteback(page))
- goto out;
-
- if (page->mapping && page_has_buffers(page)) {
- struct buffer_head *bh, *head;
- int acceptable = 0;
-
- bh = head = page_buffers(page);
- do {
- if (buffer_unwritten(bh)) {
- acceptable = 0;
- break;
- } else if (buffer_delay(bh)) {
- acceptable = 1;
- }
- } while ((bh = bh->b_this_page) != head);
-
- if (acceptable)
- return page;
- }
-
-out:
- unlock_page(page);
- return NULL;
-}
-
-STATIC int
-xfs_map_unwritten(
- struct inode *inode,
- struct page *start_page,
- struct buffer_head *head,
- struct buffer_head *curr,
- unsigned long p_offset,
- int block_bits,
- xfs_iomap_t *iomapp,
- int startio,
- int all_bh)
-{
- struct buffer_head *bh = curr;
- xfs_iomap_t *tmp;
- xfs_buf_t *pb;
- loff_t offset, size;
- unsigned long nblocks = 0;
-
- offset = start_page->index;
- offset <<= PAGE_CACHE_SHIFT;
- offset += p_offset;
-
- /* get an "empty" pagebuf to manage IO completion
- * Proper values will be set before returning */
- pb = pagebuf_lookup(iomapp->iomap_target, 0, 0, 0);
- if (!pb)
- return -EAGAIN;
-
- /* Take a reference to the inode to prevent it from
- * being reclaimed while we have outstanding unwritten
- * extent IO on it.
- */
- if ((igrab(inode)) != inode) {
- pagebuf_free(pb);
- return -EAGAIN;
- }
-
- /* Set the count to 1 initially, this will stop an I/O
- * completion callout which happens before we have started
- * all the I/O from calling pagebuf_iodone too early.
- */
- atomic_set(&pb->pb_io_remaining, 1);
-
- /* First map forwards in the page consecutive buffers
- * covering this unwritten extent
- */
- do {
- if (!buffer_unwritten(bh))
- break;
- tmp = xfs_offset_to_map(start_page, iomapp, p_offset);
- if (!tmp)
- break;
- xfs_map_at_offset(start_page, bh, p_offset, block_bits, iomapp);
- set_buffer_unwritten_io(bh);
- bh->b_private = pb;
- p_offset += bh->b_size;
- nblocks++;
- } while ((bh = bh->b_this_page) != head);
-
- atomic_add(nblocks, &pb->pb_io_remaining);
-
- /* If we reached the end of the page, map forwards in any
- * following pages which are also covered by this extent.
- */
- if (bh == head) {
- struct address_space *mapping = inode->i_mapping;
- pgoff_t tindex, tloff, tlast;
- unsigned long bs;
- unsigned int pg_offset, bbits = inode->i_blkbits;
- struct page *page;
-
- tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
- tloff = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
- tloff = min(tlast, tloff);
- for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
- page = xfs_probe_unwritten_page(mapping,
- tindex, iomapp, pb,
- PAGE_CACHE_SIZE, &bs, bbits);
- if (!page)
- break;
- nblocks += bs;
- atomic_add(bs, &pb->pb_io_remaining);
- xfs_convert_page(inode, page, iomapp, pb,
- startio, all_bh);
- /* stop if converting the next page might add
- * enough blocks that the corresponding byte
- * count won't fit in our ulong page buf length */
- if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
- goto enough;
- }
-
- if (tindex == tlast &&
- (pg_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
- page = xfs_probe_unwritten_page(mapping,
- tindex, iomapp, pb,
- pg_offset, &bs, bbits);
- if (page) {
- nblocks += bs;
- atomic_add(bs, &pb->pb_io_remaining);
- xfs_convert_page(inode, page, iomapp, pb,
- startio, all_bh);
- if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
- goto enough;
- }
- }
- }
-
-enough:
- size = nblocks; /* NB: using 64bit number here */
- size <<= block_bits; /* convert fsb's to byte range */
-
- XFS_BUF_DATAIO(pb);
- XFS_BUF_ASYNC(pb);
- XFS_BUF_SET_SIZE(pb, size);
- XFS_BUF_SET_COUNT(pb, size);
- XFS_BUF_SET_OFFSET(pb, offset);
- XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode));
- XFS_BUF_SET_IODONE_FUNC(pb, linvfs_unwritten_convert);
-
- if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
- pagebuf_iodone(pb, 1, 1);
- }
-
- return 0;
-}
-
-STATIC void
-xfs_submit_page(
- struct page *page,
- struct buffer_head *bh_arr[],
- int cnt)
-{
- struct buffer_head *bh;
- int i;
-
- BUG_ON(PageWriteback(page));
- set_page_writeback(page);
- clear_page_dirty(page);
- unlock_page(page);
-
- if (cnt) {
- for (i = 0; i < cnt; i++) {
- bh = bh_arr[i];
- mark_buffer_async_write(bh);
- if (buffer_unwritten(bh))
- set_buffer_unwritten_io(bh);
- set_buffer_uptodate(bh);
- clear_buffer_dirty(bh);
- }
-
- for (i = 0; i < cnt; i++)
- submit_bh(WRITE, bh_arr[i]);
- } else
- end_page_writeback(page);
-}
-
-/*
- * Allocate & map buffers for page given the extent map. Write it out.
- * except for the original page of a writepage, this is called on
- * delalloc/unwritten pages only, for the original page it is possible
- * that the page has no mapping at all.
- */
-STATIC void
-xfs_convert_page(
- struct inode *inode,
- struct page *page,
- xfs_iomap_t *iomapp,
- void *private,
- int startio,
- int all_bh)
-{
- struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
- xfs_iomap_t *mp = iomapp, *tmp;
- unsigned long end, offset;
- pgoff_t end_index;
- int i = 0, index = 0;
- int bbits = inode->i_blkbits;
-
- end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
- if (page->index < end_index) {
- end = PAGE_CACHE_SIZE;
- } else {
- end = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
- }
- bh = head = page_buffers(page);
- do {
- offset = i << bbits;
- if (!(PageUptodate(page) || buffer_uptodate(bh)))
- continue;
- if (buffer_mapped(bh) && all_bh &&
- !buffer_unwritten(bh) && !buffer_delay(bh)) {
- if (startio && (offset < end)) {
- lock_buffer(bh);
- bh_arr[index++] = bh;
- }
- continue;
- }
- tmp = xfs_offset_to_map(page, mp, offset);
- if (!tmp)
- continue;
- ASSERT(!(tmp->iomap_flags & IOMAP_HOLE));
- ASSERT(!(tmp->iomap_flags & IOMAP_DELAY));
-
- /* If this is a new unwritten extent buffer (i.e. one
- * that we haven't passed in private data for, we must
- * now map this buffer too.
- */
- if (buffer_unwritten(bh) && !bh->b_end_io) {
- ASSERT(tmp->iomap_flags & IOMAP_UNWRITTEN);
- xfs_map_unwritten(inode, page, head, bh,
- offset, bbits, tmp, startio, all_bh);
- } else if (! (buffer_unwritten(bh) && buffer_locked(bh))) {
- xfs_map_at_offset(page, bh, offset, bbits, tmp);
- if (buffer_unwritten(bh)) {
- set_buffer_unwritten_io(bh);
- bh->b_private = private;
- ASSERT(private);
- }
- }
- if (startio && (offset < end)) {
- bh_arr[index++] = bh;
- } else {
- set_buffer_dirty(bh);
- unlock_buffer(bh);
- mark_buffer_dirty(bh);
- }
- } while (i++, (bh = bh->b_this_page) != head);
-
- if (startio) {
- xfs_submit_page(page, bh_arr, index);
- } else {
- unlock_page(page);
- }
-}
-
-/*
- * Convert & write out a cluster of pages in the same extent as defined
- * by mp and following the start page.
- */
-STATIC void
-xfs_cluster_write(
- struct inode *inode,
- pgoff_t tindex,
- xfs_iomap_t *iomapp,
- int startio,
- int all_bh)
-{
- pgoff_t tlast;
- struct page *page;
-
- tlast = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
- for (; tindex < tlast; tindex++) {
- page = xfs_probe_delalloc_page(inode, tindex);
- if (!page)
- break;
- xfs_convert_page(inode, page, iomapp, NULL, startio, all_bh);
- }
-}
-
-/*
- * Calling this without startio set means we are being asked to make a dirty
- * page ready for freeing it's buffers. When called with startio set then
- * we are coming from writepage.
- *
- * When called with startio set it is important that we write the WHOLE
- * page if possible.
- * The bh->b_state's cannot know if any of the blocks or which block for
- * that matter are dirty due to mmap writes, and therefore bh uptodate is
- * only vaild if the page itself isn't completely uptodate. Some layers
- * may clear the page dirty flag prior to calling write page, under the
- * assumption the entire page will be written out; by not writing out the
- * whole page the page can be reused before all valid dirty data is
- * written out. Note: in the case of a page that has been dirty'd by
- * mapwrite and but partially setup by block_prepare_write the
- * bh->b_states's will not agree and only ones setup by BPW/BCW will have
- * valid state, thus the whole page must be written out thing.
- */
-
-STATIC int
-xfs_page_state_convert(
- struct inode *inode,
- struct page *page,
- int startio,
- int unmapped) /* also implies page uptodate */
-{
- struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
- xfs_iomap_t *iomp, iomap;
- unsigned long p_offset = 0;
- pgoff_t end_index;
- loff_t offset;
- unsigned long long end_offset;
- int len, err, i, cnt = 0, uptodate = 1;
- int flags = startio ? 0 : BMAPI_TRYLOCK;
- int page_dirty = 1;
-
-
- /* Are we off the end of the file ? */
- end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
- if (page->index >= end_index) {
- if ((page->index >= end_index + 1) ||
- !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
- err = -EIO;
- goto error;
- }
- }
-
- offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
- end_offset = min_t(unsigned long long,
- offset + PAGE_CACHE_SIZE, i_size_read(inode));
-
- bh = head = page_buffers(page);
- iomp = NULL;
-
- len = bh->b_size;
- do {
- if (offset >= end_offset)
- break;
- if (!buffer_uptodate(bh))
- uptodate = 0;
- if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)
- continue;
-
- if (iomp) {
- iomp = xfs_offset_to_map(page, &iomap, p_offset);
- }
-
- /*
- * First case, map an unwritten extent and prepare for
- * extent state conversion transaction on completion.
- */
- if (buffer_unwritten(bh)) {
- if (!iomp) {
- err = xfs_map_blocks(inode, offset, len, &iomap,
- BMAPI_READ|BMAPI_IGNSTATE);
- if (err) {
- goto error;
- }
- iomp = xfs_offset_to_map(page, &iomap,
- p_offset);
- }
- if (iomp && startio) {
- if (!bh->b_end_io) {
- err = xfs_map_unwritten(inode, page,
- head, bh, p_offset,
- inode->i_blkbits, iomp,
- startio, unmapped);
- if (err) {
- goto error;
- }
- }
- bh_arr[cnt++] = bh;
- page_dirty = 0;
- }
- /*
- * Second case, allocate space for a delalloc buffer.
- * We can return EAGAIN here in the release page case.
- */
- } else if (buffer_delay(bh)) {
- if (!iomp) {
- err = xfs_map_blocks(inode, offset, len, &iomap,
- BMAPI_ALLOCATE | flags);
- if (err) {
- goto error;
- }
- iomp = xfs_offset_to_map(page, &iomap,
- p_offset);
- }
- if (iomp) {
- xfs_map_at_offset(page, bh, p_offset,
- inode->i_blkbits, iomp);
- if (startio) {
- bh_arr[cnt++] = bh;
- } else {
- set_buffer_dirty(bh);
- unlock_buffer(bh);
- mark_buffer_dirty(bh);
- }
- page_dirty = 0;
- }
- } else if ((buffer_uptodate(bh) || PageUptodate(page)) &&
- (unmapped || startio)) {
-
- if (!buffer_mapped(bh)) {
- int size;
-
- /*
- * Getting here implies an unmapped buffer
- * was found, and we are in a path where we
- * need to write the whole page out.
- */
- if (!iomp) {
- size = xfs_probe_unmapped_cluster(
- inode, page, bh, head);
- err = xfs_map_blocks(inode, offset,
- size, &iomap,
- BMAPI_WRITE|BMAPI_MMAP);
- if (err) {
- goto error;
- }
- iomp = xfs_offset_to_map(page, &iomap,
- p_offset);
- }
- if (iomp) {
- xfs_map_at_offset(page,
- bh, p_offset,
- inode->i_blkbits, iomp);
- if (startio) {
- bh_arr[cnt++] = bh;
- } else {
- set_buffer_dirty(bh);
- unlock_buffer(bh);
- mark_buffer_dirty(bh);
- }
- page_dirty = 0;
- }
- } else if (startio) {
- if (buffer_uptodate(bh) &&
- !test_and_set_bit(BH_Lock, &bh->b_state)) {
- bh_arr[cnt++] = bh;
- page_dirty = 0;
- }
- }
- }
- } while (offset += len, p_offset += len,
- ((bh = bh->b_this_page) != head));
-
- if (uptodate && bh == head)
- SetPageUptodate(page);
-
- if (startio)
- xfs_submit_page(page, bh_arr, cnt);
-
- if (iomp)
- xfs_cluster_write(inode, page->index + 1, iomp, startio, unmapped);
-
- return page_dirty;
-
-error:
- for (i = 0; i < cnt; i++) {
- unlock_buffer(bh_arr[i]);
- }
-
- /*
- * If it's delalloc and we have nowhere to put it,
- * throw it away, unless the lower layers told
- * us to try again.
- */
- if (err != -EAGAIN) {
- if (!unmapped) {
- block_invalidatepage(page, 0);
- }
- ClearPageUptodate(page);
- }
- return err;
-}
-
-STATIC int
-linvfs_get_block_core(
- struct inode *inode,
- sector_t iblock,
- unsigned long blocks,
- struct buffer_head *bh_result,
- int create,
- int direct,
- bmapi_flags_t flags)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- xfs_iomap_t iomap;
- int retpbbm = 1;
- int error;
- ssize_t size;
- loff_t offset = (loff_t)iblock << inode->i_blkbits;
-
- /* If we are doing writes at the end of the file,
- * allocate in chunks
- */
- if (blocks)
- size = blocks << inode->i_blkbits;
- else if (create && (offset >= i_size_read(inode)))
- size = 1 << XFS_WRITE_IO_LOG;
- else
- size = 1 << inode->i_blkbits;
-
- VOP_BMAP(vp, offset, size,
- create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
- if (error)
- return -error;
-
- if (retpbbm == 0)
- return 0;
-
- if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
- xfs_daddr_t bn;
- loff_t delta;
-
- /* For unwritten extents do not report a disk address on
- * the read case (treat as if we're reading into a hole).
- */
- if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
- delta = offset - iomap.iomap_offset;
- delta >>= inode->i_blkbits;
-
- bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
- bn += delta;
-
- bh_result->b_blocknr = bn;
- bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
- set_buffer_mapped(bh_result);
- }
- if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
- if (direct)
- bh_result->b_private = inode;
- set_buffer_unwritten(bh_result);
- set_buffer_delay(bh_result);
- }
- }
-
- /* If this is a realtime file, data might be on a new device */
- bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
-
- /* If we previously allocated a block out beyond eof and
- * we are now coming back to use it then we will need to
- * flag it as new even if it has a disk address.
- */
- if (create &&
- ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
- (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) {
- set_buffer_new(bh_result);
- }
-
- if (iomap.iomap_flags & IOMAP_DELAY) {
- if (unlikely(direct))
- BUG();
- if (create) {
- set_buffer_mapped(bh_result);
- set_buffer_uptodate(bh_result);
- }
- bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
- set_buffer_delay(bh_result);
- }
-
- if (blocks) {
- loff_t iosize;
- iosize = (iomap.iomap_bsize - iomap.iomap_delta);
- bh_result->b_size =
- (ssize_t)min(iosize, (loff_t)(blocks << inode->i_blkbits));
- }
-
- return 0;
-}
-
-int
-linvfs_get_block(
- struct inode *inode,
- sector_t iblock,
- struct buffer_head *bh_result,
- int create)
-{
- return linvfs_get_block_core(inode, iblock, 0, bh_result,
- create, 0, BMAPI_WRITE);
-}
-
-STATIC int
-linvfs_get_block_sync(
- struct inode *inode,
- sector_t iblock,
- struct buffer_head *bh_result,
- int create)
-{
- return linvfs_get_block_core(inode, iblock, 0, bh_result,
- create, 0, BMAPI_SYNC|BMAPI_WRITE);
-}
-
-STATIC int
-linvfs_get_blocks_direct(
- struct inode *inode,
- sector_t iblock,
- unsigned long max_blocks,
- struct buffer_head *bh_result,
- int create)
-{
- return linvfs_get_block_core(inode, iblock, max_blocks, bh_result,
- create, 1, BMAPI_WRITE|BMAPI_DIRECT);
-}
-
-STATIC ssize_t
-linvfs_direct_IO(
- int rw,
- struct kiocb *iocb,
- const struct iovec *iov,
- loff_t offset,
- unsigned long nr_segs)
-{
- struct file *file = iocb->ki_filp;
- struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- xfs_iomap_t iomap;
- int maps = 1;
- int error;
-
- VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
- if (error)
- return -error;
-
- return blockdev_direct_IO_no_locking(rw, iocb, inode,
- iomap.iomap_target->pbr_bdev,
- iov, offset, nr_segs,
- linvfs_get_blocks_direct,
- linvfs_unwritten_convert_direct);
-}
-
-
-STATIC sector_t
-linvfs_bmap(
- struct address_space *mapping,
- sector_t block)
-{
- struct inode *inode = (struct inode *)mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error;
-
- vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address);
-
- VOP_RWLOCK(vp, VRWLOCK_READ);
- VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
- VOP_RWUNLOCK(vp, VRWLOCK_READ);
- return generic_block_bmap(mapping, block, linvfs_get_block);
-}
-
-STATIC int
-linvfs_readpage(
- struct file *unused,
- struct page *page)
-{
- return mpage_readpage(page, linvfs_get_block);
-}
-
-STATIC int
-linvfs_readpages(
- struct file *unused,
- struct address_space *mapping,
- struct list_head *pages,
- unsigned nr_pages)
-{
- return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block);
-}
-
-STATIC void
-xfs_count_page_state(
- struct page *page,
- int *delalloc,
- int *unmapped,
- int *unwritten)
-{
- struct buffer_head *bh, *head;
-
- *delalloc = *unmapped = *unwritten = 0;
-
- bh = head = page_buffers(page);
- do {
- if (buffer_uptodate(bh) && !buffer_mapped(bh))
- (*unmapped) = 1;
- else if (buffer_unwritten(bh) && !buffer_delay(bh))
- clear_buffer_unwritten(bh);
- else if (buffer_unwritten(bh))
- (*unwritten) = 1;
- else if (buffer_delay(bh))
- (*delalloc) = 1;
- } while ((bh = bh->b_this_page) != head);
-}
-
-
-/*
- * writepage: Called from one of two places:
- *
- * 1. we are flushing a delalloc buffer head.
- *
- * 2. we are writing out a dirty page. Typically the page dirty
- * state is cleared before we get here. In this case is it
- * conceivable we have no buffer heads.
- *
- * For delalloc space on the page we need to allocate space and
- * flush it. For unmapped buffer heads on the page we should
- * allocate space if the page is uptodate. For any other dirty
- * buffer heads on the page we should flush them.
- *
- * If we detect that a transaction would be required to flush
- * the page, we have to check the process flags first, if we
- * are already in a transaction or disk I/O during allocations
- * is off, we need to fail the writepage and redirty the page.
- */
-
-STATIC int
-linvfs_writepage(
- struct page *page,
- struct writeback_control *wbc)
-{
- int error;
- int need_trans;
- int delalloc, unmapped, unwritten;
- struct inode *inode = page->mapping->host;
-
- xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
-
- /*
- * We need a transaction if:
- * 1. There are delalloc buffers on the page
- * 2. The page is uptodate and we have unmapped buffers
- * 3. The page is uptodate and we have no buffers
- * 4. There are unwritten buffers on the page
- */
-
- if (!page_has_buffers(page)) {
- unmapped = 1;
- need_trans = 1;
- } else {
- xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
- if (!PageUptodate(page))
- unmapped = 0;
- need_trans = delalloc + unmapped + unwritten;
- }
-
- /*
- * If we need a transaction and the process flags say
- * we are already in a transaction, or no IO is allowed
- * then mark the page dirty again and leave the page
- * as is.
- */
- if (PFLAGS_TEST_FSTRANS() && need_trans)
- goto out_fail;
-
- /*
- * Delay hooking up buffer heads until we have
- * made our go/no-go decision.
- */
- if (!page_has_buffers(page))
- create_empty_buffers(page, 1 << inode->i_blkbits, 0);
-
- /*
- * Convert delayed allocate, unwritten or unmapped space
- * to real space and flush out to disk.
- */
- error = xfs_page_state_convert(inode, page, 1, unmapped);
- if (error == -EAGAIN)
- goto out_fail;
- if (unlikely(error < 0))
- goto out_unlock;
-
- return 0;
-
-out_fail:
- set_page_dirty(page);
- unlock_page(page);
- return 0;
-out_unlock:
- unlock_page(page);
- return error;
-}
-
-/*
- * Called to move a page into cleanable state - and from there
- * to be released. Possibly the page is already clean. We always
- * have buffer heads in this call.
- *
- * Returns 0 if the page is ok to release, 1 otherwise.
- *
- * Possible scenarios are:
- *
- * 1. We are being called to release a page which has been written
- * to via regular I/O. buffer heads will be dirty and possibly
- * delalloc. If no delalloc buffer heads in this case then we
- * can just return zero.
- *
- * 2. We are called to release a page which has been written via
- * mmap, all we need to do is ensure there is no delalloc
- * state in the buffer heads, if not we can let the caller
- * free them and we should come back later via writepage.
- */
-STATIC int
-linvfs_release_page(
- struct page *page,
- int gfp_mask)
-{
- struct inode *inode = page->mapping->host;
- int dirty, delalloc, unmapped, unwritten;
-
- xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
-
- xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
- if (!delalloc && !unwritten)
- goto free_buffers;
-
- if (!(gfp_mask & __GFP_FS))
- return 0;
-
- /* If we are already inside a transaction or the thread cannot
- * do I/O, we cannot release this page.
- */
- if (PFLAGS_TEST_FSTRANS())
- return 0;
-
- /*
- * Convert delalloc space to real space, do not flush the
- * data out to disk, that will be done by the caller.
- * Never need to allocate space here - we will always
- * come back to writepage in that case.
- */
- dirty = xfs_page_state_convert(inode, page, 0, 0);
- if (dirty == 0 && !unwritten)
- goto free_buffers;
- return 0;
-
-free_buffers:
- return try_to_free_buffers(page);
-}
-
-STATIC int
-linvfs_prepare_write(
- struct file *file,
- struct page *page,
- unsigned int from,
- unsigned int to)
-{
- if (file && (file->f_flags & O_SYNC)) {
- return block_prepare_write(page, from, to,
- linvfs_get_block_sync);
- } else {
- return block_prepare_write(page, from, to,
- linvfs_get_block);
- }
-}
-
-struct address_space_operations linvfs_aops = {
- .readpage = linvfs_readpage,
- .readpages = linvfs_readpages,
- .writepage = linvfs_writepage,
- .sync_page = block_sync_page,
- .releasepage = linvfs_release_page,
- .prepare_write = linvfs_prepare_write,
- .commit_write = generic_commit_write,
- .bmap = linvfs_bmap,
- .direct_IO = linvfs_direct_IO,
-};
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * The xfs_buf.c code provides an abstract buffer cache model on top
- * of the Linux page cache. Cached metadata blocks for a file system
- * are hashed to the inode for the block device. xfs_buf.c assembles
- * buffers (xfs_buf_t) on demand to aggregate such cached pages for I/O.
- *
- * Written by Steve Lord, Jim Mostek, Russell Cattelan
- * and Rajagopal Ananthanarayanan ("ananth") at SGI.
- *
- */
-
-#include <linux/stddef.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/vmalloc.h>
-#include <linux/bio.h>
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-#include <linux/workqueue.h>
-#include <linux/suspend.h>
-#include <linux/percpu.h>
-
-#include "xfs_linux.h"
-
-#ifndef GFP_READAHEAD
-#define GFP_READAHEAD (__GFP_NOWARN|__GFP_NORETRY)
-#endif
-
-/*
- * File wide globals
- */
-
-STATIC kmem_cache_t *pagebuf_cache;
-STATIC void pagebuf_daemon_wakeup(void);
-STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
-STATIC struct workqueue_struct *pagebuf_logio_workqueue;
-STATIC struct workqueue_struct *pagebuf_dataio_workqueue;
-
-/*
- * Pagebuf debugging
- */
-
-#ifdef PAGEBUF_TRACE
-void
-pagebuf_trace(
- xfs_buf_t *pb,
- char *id,
- void *data,
- void *ra)
-{
- ktrace_enter(pagebuf_trace_buf,
- pb, id,
- (void *)(unsigned long)pb->pb_flags,
- (void *)(unsigned long)pb->pb_hold.counter,
- (void *)(unsigned long)pb->pb_sema.count.counter,
- (void *)current,
- data, ra,
- (void *)(unsigned long)((pb->pb_file_offset>>32) & 0xffffffff),
- (void *)(unsigned long)(pb->pb_file_offset & 0xffffffff),
- (void *)(unsigned long)pb->pb_buffer_length,
- NULL, NULL, NULL, NULL, NULL);
-}
-ktrace_t *pagebuf_trace_buf;
-#define PAGEBUF_TRACE_SIZE 4096
-#define PB_TRACE(pb, id, data) \
- pagebuf_trace(pb, id, (void *)data, (void *)__builtin_return_address(0))
-#else
-#define PB_TRACE(pb, id, data) do { } while (0)
-#endif
-
-#ifdef PAGEBUF_LOCK_TRACKING
-# define PB_SET_OWNER(pb) ((pb)->pb_last_holder = current->pid)
-# define PB_CLEAR_OWNER(pb) ((pb)->pb_last_holder = -1)
-# define PB_GET_OWNER(pb) ((pb)->pb_last_holder)
-#else
-# define PB_SET_OWNER(pb) do { } while (0)
-# define PB_CLEAR_OWNER(pb) do { } while (0)
-# define PB_GET_OWNER(pb) do { } while (0)
-#endif
-
-/*
- * Pagebuf allocation / freeing.
- */
-
-#define pb_to_gfp(flags) \
- (((flags) & PBF_READ_AHEAD) ? GFP_READAHEAD : \
- ((flags) & PBF_DONT_BLOCK) ? GFP_NOFS : GFP_KERNEL)
-
-#define pb_to_km(flags) \
- (((flags) & PBF_DONT_BLOCK) ? KM_NOFS : KM_SLEEP)
-
-
-#define pagebuf_allocate(flags) \
- kmem_zone_alloc(pagebuf_cache, pb_to_km(flags))
-#define pagebuf_deallocate(pb) \
- kmem_zone_free(pagebuf_cache, (pb));
-
-/*
- * Pagebuf hashing
- */
-
-#define NBITS 8
-#define NHASH (1<<NBITS)
-
-typedef struct {
- struct list_head pb_hash;
- spinlock_t pb_hash_lock;
-} pb_hash_t;
-
-STATIC pb_hash_t pbhash[NHASH];
-#define pb_hash(pb) &pbhash[pb->pb_hash_index]
-
-STATIC int
-_bhash(
- struct block_device *bdev,
- loff_t base)
-{
- int bit, hval;
-
- base >>= 9;
- base ^= (unsigned long)bdev / L1_CACHE_BYTES;
- for (bit = hval = 0; base && bit < sizeof(base) * 8; bit += NBITS) {
- hval ^= (int)base & (NHASH-1);
- base >>= NBITS;
- }
- return hval;
-}
-
-/*
- * Mapping of multi-page buffers into contiguous virtual space
- */
-
-typedef struct a_list {
- void *vm_addr;
- struct a_list *next;
-} a_list_t;
-
-STATIC a_list_t *as_free_head;
-STATIC int as_list_len;
-STATIC spinlock_t as_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Try to batch vunmaps because they are costly.
- */
-STATIC void
-free_address(
- void *addr)
-{
- a_list_t *aentry;
-
- aentry = kmalloc(sizeof(a_list_t), GFP_ATOMIC);
- if (aentry) {
- spin_lock(&as_lock);
- aentry->next = as_free_head;
- aentry->vm_addr = addr;
- as_free_head = aentry;
- as_list_len++;
- spin_unlock(&as_lock);
- } else {
- vunmap(addr);
- }
-}
-
-STATIC void
-purge_addresses(void)
-{
- a_list_t *aentry, *old;
-
- if (as_free_head == NULL)
- return;
-
- spin_lock(&as_lock);
- aentry = as_free_head;
- as_free_head = NULL;
- as_list_len = 0;
- spin_unlock(&as_lock);
-
- while ((old = aentry) != NULL) {
- vunmap(aentry->vm_addr);
- aentry = aentry->next;
- kfree(old);
- }
-}
-
-/*
- * Internal pagebuf object manipulation
- */
-
-STATIC void
-_pagebuf_initialize(
- xfs_buf_t *pb,
- xfs_buftarg_t *target,
- loff_t range_base,
- size_t range_length,
- page_buf_flags_t flags)
-{
- /*
- * We don't want certain flags to appear in pb->pb_flags.
- */
- flags &= ~(PBF_LOCK|PBF_MAPPED|PBF_DONT_BLOCK|PBF_READ_AHEAD);
-
- memset(pb, 0, sizeof(xfs_buf_t));
- atomic_set(&pb->pb_hold, 1);
- init_MUTEX_LOCKED(&pb->pb_iodonesema);
- INIT_LIST_HEAD(&pb->pb_list);
- INIT_LIST_HEAD(&pb->pb_hash_list);
- init_MUTEX_LOCKED(&pb->pb_sema); /* held, no waiters */
- PB_SET_OWNER(pb);
- pb->pb_target = target;
- pb->pb_file_offset = range_base;
- /*
- * Set buffer_length and count_desired to the same value initially.
- * I/O routines should use count_desired, which will be the same in
- * most cases but may be reset (e.g. XFS recovery).
- */
- pb->pb_buffer_length = pb->pb_count_desired = range_length;
- pb->pb_flags = flags | PBF_NONE;
- pb->pb_bn = XFS_BUF_DADDR_NULL;
- atomic_set(&pb->pb_pin_count, 0);
- init_waitqueue_head(&pb->pb_waiters);
-
- XFS_STATS_INC(pb_create);
- PB_TRACE(pb, "initialize", target);
-}
-
-/*
- * Allocate a page array capable of holding a specified number
- * of pages, and point the page buf at it.
- */
-STATIC int
-_pagebuf_get_pages(
- xfs_buf_t *pb,
- int page_count,
- page_buf_flags_t flags)
-{
- /* Make sure that we have a page list */
- if (pb->pb_pages == NULL) {
- pb->pb_offset = page_buf_poff(pb->pb_file_offset);
- pb->pb_page_count = page_count;
- if (page_count <= PB_PAGES) {
- pb->pb_pages = pb->pb_page_array;
- } else {
- pb->pb_pages = kmem_alloc(sizeof(struct page *) *
- page_count, pb_to_km(flags));
- if (pb->pb_pages == NULL)
- return -ENOMEM;
- }
- memset(pb->pb_pages, 0, sizeof(struct page *) * page_count);
- }
- return 0;
-}
-
-/*
- * Frees pb_pages if it was malloced.
- */
-STATIC void
-_pagebuf_free_pages(
- xfs_buf_t *bp)
-{
- if (bp->pb_pages != bp->pb_page_array) {
- kmem_free(bp->pb_pages,
- bp->pb_page_count * sizeof(struct page *));
- }
-}
-
-/*
- * Releases the specified buffer.
- *
- * The modification state of any associated pages is left unchanged.
- * The buffer most not be on any hash - use pagebuf_rele instead for
- * hashed and refcounted buffers
- */
-void
-pagebuf_free(
- xfs_buf_t *bp)
-{
- PB_TRACE(bp, "free", 0);
-
- ASSERT(list_empty(&bp->pb_hash_list));
-
- if (bp->pb_flags & _PBF_PAGE_CACHE) {
- uint i;
-
- if ((bp->pb_flags & PBF_MAPPED) && (bp->pb_page_count > 1))
- free_address(bp->pb_addr - bp->pb_offset);
-
- for (i = 0; i < bp->pb_page_count; i++)
- page_cache_release(bp->pb_pages[i]);
- _pagebuf_free_pages(bp);
- } else if (bp->pb_flags & _PBF_KMEM_ALLOC) {
- /*
- * XXX(hch): bp->pb_count_desired might be incorrect (see
- * pagebuf_associate_memory for details), but fortunately
- * the Linux version of kmem_free ignores the len argument..
- */
- kmem_free(bp->pb_addr, bp->pb_count_desired);
- _pagebuf_free_pages(bp);
- }
-
- pagebuf_deallocate(bp);
-}
-
-/*
- * Finds all pages for buffer in question and builds it's page list.
- */
-STATIC int
-_pagebuf_lookup_pages(
- xfs_buf_t *bp,
- uint flags)
-{
- struct address_space *mapping = bp->pb_target->pbr_mapping;
- unsigned int sectorshift = bp->pb_target->pbr_sshift;
- size_t blocksize = bp->pb_target->pbr_bsize;
- size_t size = bp->pb_count_desired;
- size_t nbytes, offset;
- int gfp_mask = pb_to_gfp(flags);
- unsigned short page_count, i;
- pgoff_t first;
- loff_t end;
- int error;
-
- end = bp->pb_file_offset + bp->pb_buffer_length;
- page_count = page_buf_btoc(end) - page_buf_btoct(bp->pb_file_offset);
-
- error = _pagebuf_get_pages(bp, page_count, flags);
- if (unlikely(error))
- return error;
-
- offset = bp->pb_offset;
- first = bp->pb_file_offset >> PAGE_CACHE_SHIFT;
-
- for (i = 0; i < bp->pb_page_count; i++) {
- struct page *page;
- uint retries = 0;
-
- retry:
- page = find_or_create_page(mapping, first + i, gfp_mask);
- if (unlikely(page == NULL)) {
- if (flags & PBF_READ_AHEAD)
- return -ENOMEM;
-
- /*
- * This could deadlock.
- *
- * But until all the XFS lowlevel code is revamped to
- * handle buffer allocation failures we can't do much.
- */
- if (!(++retries % 100)) {
- printk(KERN_ERR "possibly deadlocking in %s\n",
- __FUNCTION__);
- }
-
- XFS_STATS_INC(pb_page_retries);
- pagebuf_daemon_wakeup();
- current->state = TASK_UNINTERRUPTIBLE;
- schedule_timeout(10);
- goto retry;
- }
-
- XFS_STATS_INC(pb_page_found);
-
- nbytes = min_t(size_t, size, PAGE_CACHE_SIZE - offset);
- size -= nbytes;
-
- if (!PageUptodate(page)) {
- page_count--;
- if (blocksize == PAGE_CACHE_SIZE) {
- if (flags & PBF_READ)
- bp->pb_locked = 1;
- } else if (!PagePrivate(page)) {
- unsigned long j, range;
-
- /*
- * In this case page->private holds a bitmap
- * of uptodate sectors within the page
- */
- ASSERT(blocksize < PAGE_CACHE_SIZE);
- range = (offset + nbytes) >> sectorshift;
- for (j = offset >> sectorshift; j < range; j++)
- if (!test_bit(j, &page->private))
- break;
- if (j == range)
- page_count++;
- }
- }
-
- bp->pb_pages[i] = page;
- offset = 0;
- }
-
- if (!bp->pb_locked) {
- for (i = 0; i < bp->pb_page_count; i++)
- unlock_page(bp->pb_pages[i]);
- }
-
- bp->pb_flags |= _PBF_PAGE_CACHE;
-
- if (page_count) {
- /* if we have any uptodate pages, mark that in the buffer */
- bp->pb_flags &= ~PBF_NONE;
-
- /* if some pages aren't uptodate, mark that in the buffer */
- if (page_count != bp->pb_page_count)
- bp->pb_flags |= PBF_PARTIAL;
- }
-
- PB_TRACE(bp, "lookup_pages", (long)page_count);
- return error;
-}
-
-/*
- * Map buffer into kernel address-space if nessecary.
- */
-STATIC int
-_pagebuf_map_pages(
- xfs_buf_t *bp,
- uint flags)
-{
- /* A single page buffer is always mappable */
- if (bp->pb_page_count == 1) {
- bp->pb_addr = page_address(bp->pb_pages[0]) + bp->pb_offset;
- bp->pb_flags |= PBF_MAPPED;
- } else if (flags & PBF_MAPPED) {
- if (as_list_len > 64)
- purge_addresses();
- bp->pb_addr = vmap(bp->pb_pages, bp->pb_page_count,
- VM_MAP, PAGE_KERNEL);
- if (unlikely(bp->pb_addr == NULL))
- return -ENOMEM;
- bp->pb_addr += bp->pb_offset;
- bp->pb_flags |= PBF_MAPPED;
- }
-
- return 0;
-}
-
-/*
- * Finding and Reading Buffers
- */
-
-/*
- * _pagebuf_find
- *
- * Looks up, and creates if absent, a lockable buffer for
- * a given range of an inode. The buffer is returned
- * locked. If other overlapping buffers exist, they are
- * released before the new buffer is created and locked,
- * which may imply that this call will block until those buffers
- * are unlocked. No I/O is implied by this call.
- */
-STATIC xfs_buf_t *
-_pagebuf_find( /* find buffer for block */
- xfs_buftarg_t *target,/* target for block */
- loff_t ioff, /* starting offset of range */
- size_t isize, /* length of range */
- page_buf_flags_t flags, /* PBF_TRYLOCK */
- xfs_buf_t *new_pb)/* newly allocated buffer */
-{
- loff_t range_base;
- size_t range_length;
- int hval;
- pb_hash_t *h;
- xfs_buf_t *pb, *n;
- int not_locked;
-
- range_base = (ioff << BBSHIFT);
- range_length = (isize << BBSHIFT);
-
- /* Ensure we never do IOs smaller than the sector size */
- BUG_ON(range_length < (1 << target->pbr_sshift));
-
- /* Ensure we never do IOs that are not sector aligned */
- BUG_ON(range_base & (loff_t)target->pbr_smask);
-
- hval = _bhash(target->pbr_bdev, range_base);
- h = &pbhash[hval];
-
- spin_lock(&h->pb_hash_lock);
- list_for_each_entry_safe(pb, n, &h->pb_hash, pb_hash_list) {
- if (pb->pb_target == target &&
- pb->pb_file_offset == range_base &&
- pb->pb_buffer_length == range_length) {
- /* If we look at something bring it to the
- * front of the list for next time
- */
- atomic_inc(&pb->pb_hold);
- list_move(&pb->pb_hash_list, &h->pb_hash);
- goto found;
- }
- }
-
- /* No match found */
- if (new_pb) {
- _pagebuf_initialize(new_pb, target, range_base,
- range_length, flags);
- new_pb->pb_hash_index = hval;
- list_add(&new_pb->pb_hash_list, &h->pb_hash);
- } else {
- XFS_STATS_INC(pb_miss_locked);
- }
-
- spin_unlock(&h->pb_hash_lock);
- return (new_pb);
-
-found:
- spin_unlock(&h->pb_hash_lock);
-
- /* Attempt to get the semaphore without sleeping,
- * if this does not work then we need to drop the
- * spinlock and do a hard attempt on the semaphore.
- */
- not_locked = down_trylock(&pb->pb_sema);
- if (not_locked) {
- if (!(flags & PBF_TRYLOCK)) {
- /* wait for buffer ownership */
- PB_TRACE(pb, "get_lock", 0);
- pagebuf_lock(pb);
- XFS_STATS_INC(pb_get_locked_waited);
- } else {
- /* We asked for a trylock and failed, no need
- * to look at file offset and length here, we
- * know that this pagebuf at least overlaps our
- * pagebuf and is locked, therefore our buffer
- * either does not exist, or is this buffer
- */
-
- pagebuf_rele(pb);
- XFS_STATS_INC(pb_busy_locked);
- return (NULL);
- }
- } else {
- /* trylock worked */
- PB_SET_OWNER(pb);
- }
-
- if (pb->pb_flags & PBF_STALE)
- pb->pb_flags &= PBF_MAPPED;
- PB_TRACE(pb, "got_lock", 0);
- XFS_STATS_INC(pb_get_locked);
- return (pb);
-}
-
-
-/*
- * pagebuf_find
- *
- * pagebuf_find returns a buffer matching the specified range of
- * data for the specified target, if any of the relevant blocks
- * are in memory. The buffer may have unallocated holes, if
- * some, but not all, of the blocks are in memory. Even where
- * pages are present in the buffer, not all of every page may be
- * valid.
- */
-xfs_buf_t *
-pagebuf_find( /* find buffer for block */
- /* if the block is in memory */
- xfs_buftarg_t *target,/* target for block */
- loff_t ioff, /* starting offset of range */
- size_t isize, /* length of range */
- page_buf_flags_t flags) /* PBF_TRYLOCK */
-{
- return _pagebuf_find(target, ioff, isize, flags, NULL);
-}
-
-/*
- * pagebuf_get
- *
- * pagebuf_get assembles a buffer covering the specified range.
- * Some or all of the blocks in the range may be valid. Storage
- * in memory for all portions of the buffer will be allocated,
- * although backing storage may not be. If PBF_READ is set in
- * flags, pagebuf_iostart is called also.
- */
-xfs_buf_t *
-pagebuf_get( /* allocate a buffer */
- xfs_buftarg_t *target,/* target for buffer */
- loff_t ioff, /* starting offset of range */
- size_t isize, /* length of range */
- page_buf_flags_t flags) /* PBF_TRYLOCK */
-{
- xfs_buf_t *pb, *new_pb;
- int error = 0, i;
-
- new_pb = pagebuf_allocate(flags);
- if (unlikely(!new_pb))
- return NULL;
-
- pb = _pagebuf_find(target, ioff, isize, flags, new_pb);
- if (pb == new_pb) {
- error = _pagebuf_lookup_pages(pb, flags);
- if (unlikely(error)) {
- printk(KERN_WARNING
- "pagebuf_get: failed to lookup pages\n");
- goto no_buffer;
- }
- } else {
- pagebuf_deallocate(new_pb);
- if (unlikely(pb == NULL))
- return NULL;
- }
-
- for (i = 0; i < pb->pb_page_count; i++)
- mark_page_accessed(pb->pb_pages[i]);
-
- if (!(pb->pb_flags & PBF_MAPPED)) {
- error = _pagebuf_map_pages(pb, flags);
- if (unlikely(error)) {
- printk(KERN_WARNING
- "pagebuf_get: failed to map pages\n");
- goto no_buffer;
- }
- }
-
- XFS_STATS_INC(pb_get);
-
- /*
- * Always fill in the block number now, the mapped cases can do
- * their own overlay of this later.
- */
- pb->pb_bn = ioff;
- pb->pb_count_desired = pb->pb_buffer_length;
-
- if (flags & PBF_READ) {
- if (PBF_NOT_DONE(pb)) {
- PB_TRACE(pb, "get_read", (unsigned long)flags);
- XFS_STATS_INC(pb_get_read);
- pagebuf_iostart(pb, flags);
- } else if (flags & PBF_ASYNC) {
- PB_TRACE(pb, "get_read_async", (unsigned long)flags);
- /*
- * Read ahead call which is already satisfied,
- * drop the buffer
- */
- goto no_buffer;
- } else {
- PB_TRACE(pb, "get_read_done", (unsigned long)flags);
- /* We do not want read in the flags */
- pb->pb_flags &= ~PBF_READ;
- }
- } else {
- PB_TRACE(pb, "get_write", (unsigned long)flags);
- }
-
- return pb;
-
-no_buffer:
- if (flags & (PBF_LOCK | PBF_TRYLOCK))
- pagebuf_unlock(pb);
- pagebuf_rele(pb);
- return NULL;
-}
-
-/*
- * Create a skeletal pagebuf (no pages associated with it).
- */
-xfs_buf_t *
-pagebuf_lookup(
- xfs_buftarg_t *target,
- loff_t ioff,
- size_t isize,
- page_buf_flags_t flags)
-{
- xfs_buf_t *pb;
-
- pb = pagebuf_allocate(flags);
- if (pb) {
- _pagebuf_initialize(pb, target, ioff, isize, flags);
- }
- return pb;
-}
-
-/*
- * If we are not low on memory then do the readahead in a deadlock
- * safe manner.
- */
-void
-pagebuf_readahead(
- xfs_buftarg_t *target,
- loff_t ioff,
- size_t isize,
- page_buf_flags_t flags)
-{
- struct backing_dev_info *bdi;
-
- bdi = target->pbr_mapping->backing_dev_info;
- if (bdi_read_congested(bdi))
- return;
- if (bdi_write_congested(bdi))
- return;
-
- flags |= (PBF_TRYLOCK|PBF_READ|PBF_ASYNC|PBF_READ_AHEAD);
- pagebuf_get(target, ioff, isize, flags);
-}
-
-xfs_buf_t *
-pagebuf_get_empty(
- size_t len,
- xfs_buftarg_t *target)
-{
- xfs_buf_t *pb;
-
- pb = pagebuf_allocate(0);
- if (pb)
- _pagebuf_initialize(pb, target, 0, len, 0);
- return pb;
-}
-
-static inline struct page *
-mem_to_page(
- void *addr)
-{
- if (((unsigned long)addr < VMALLOC_START) ||
- ((unsigned long)addr >= VMALLOC_END)) {
- return virt_to_page(addr);
- } else {
- return vmalloc_to_page(addr);
- }
-}
-
-int
-pagebuf_associate_memory(
- xfs_buf_t *pb,
- void *mem,
- size_t len)
-{
- int rval;
- int i = 0;
- size_t ptr;
- size_t end, end_cur;
- off_t offset;
- int page_count;
-
- page_count = PAGE_CACHE_ALIGN(len) >> PAGE_CACHE_SHIFT;
- offset = (off_t) mem - ((off_t)mem & PAGE_CACHE_MASK);
- if (offset && (len > PAGE_CACHE_SIZE))
- page_count++;
-
- /* Free any previous set of page pointers */
- if (pb->pb_pages)
- _pagebuf_free_pages(pb);
-
- pb->pb_pages = NULL;
- pb->pb_addr = mem;
-
- rval = _pagebuf_get_pages(pb, page_count, 0);
- if (rval)
- return rval;
-
- pb->pb_offset = offset;
- ptr = (size_t) mem & PAGE_CACHE_MASK;
- end = PAGE_CACHE_ALIGN((size_t) mem + len);
- end_cur = end;
- /* set up first page */
- pb->pb_pages[0] = mem_to_page(mem);
-
- ptr += PAGE_CACHE_SIZE;
- pb->pb_page_count = ++i;
- while (ptr < end) {
- pb->pb_pages[i] = mem_to_page((void *)ptr);
- pb->pb_page_count = ++i;
- ptr += PAGE_CACHE_SIZE;
- }
- pb->pb_locked = 0;
-
- pb->pb_count_desired = pb->pb_buffer_length = len;
- pb->pb_flags |= PBF_MAPPED;
-
- return 0;
-}
-
-xfs_buf_t *
-pagebuf_get_no_daddr(
- size_t len,
- xfs_buftarg_t *target)
-{
- size_t malloc_len = len;
- xfs_buf_t *bp;
- void *data;
- int error;
-
- if (unlikely(len > 0x20000))
- goto fail;
-
- bp = pagebuf_allocate(0);
- if (unlikely(bp == NULL))
- goto fail;
- _pagebuf_initialize(bp, target, 0, len, PBF_FORCEIO);
-
- try_again:
- data = kmem_alloc(malloc_len, KM_SLEEP);
- if (unlikely(data == NULL))
- goto fail_free_buf;
-
- /* check whether alignment matches.. */
- if ((__psunsigned_t)data !=
- ((__psunsigned_t)data & ~target->pbr_smask)) {
- /* .. else double the size and try again */
- kmem_free(data, malloc_len);
- malloc_len <<= 1;
- goto try_again;
- }
-
- error = pagebuf_associate_memory(bp, data, len);
- if (error)
- goto fail_free_mem;
- bp->pb_flags |= _PBF_KMEM_ALLOC;
-
- pagebuf_unlock(bp);
-
- PB_TRACE(bp, "no_daddr", data);
- return bp;
- fail_free_mem:
- kmem_free(data, malloc_len);
- fail_free_buf:
- pagebuf_free(bp);
- fail:
- return NULL;
-}
-
-/*
- * pagebuf_hold
- *
- * Increment reference count on buffer, to hold the buffer concurrently
- * with another thread which may release (free) the buffer asynchronously.
- *
- * Must hold the buffer already to call this function.
- */
-void
-pagebuf_hold(
- xfs_buf_t *pb)
-{
- atomic_inc(&pb->pb_hold);
- PB_TRACE(pb, "hold", 0);
-}
-
-/*
- * pagebuf_rele
- *
- * pagebuf_rele releases a hold on the specified buffer. If the
- * the hold count is 1, pagebuf_rele calls pagebuf_free.
- */
-void
-pagebuf_rele(
- xfs_buf_t *pb)
-{
- pb_hash_t *hash = pb_hash(pb);
-
- PB_TRACE(pb, "rele", pb->pb_relse);
-
- if (atomic_dec_and_lock(&pb->pb_hold, &hash->pb_hash_lock)) {
- int do_free = 1;
-
- if (pb->pb_relse) {
- atomic_inc(&pb->pb_hold);
- spin_unlock(&hash->pb_hash_lock);
- (*(pb->pb_relse)) (pb);
- spin_lock(&hash->pb_hash_lock);
- do_free = 0;
- }
-
- if (pb->pb_flags & PBF_DELWRI) {
- pb->pb_flags |= PBF_ASYNC;
- atomic_inc(&pb->pb_hold);
- pagebuf_delwri_queue(pb, 0);
- do_free = 0;
- } else if (pb->pb_flags & PBF_FS_MANAGED) {
- do_free = 0;
- }
-
- if (do_free) {
- list_del_init(&pb->pb_hash_list);
- spin_unlock(&hash->pb_hash_lock);
- pagebuf_free(pb);
- } else {
- spin_unlock(&hash->pb_hash_lock);
- }
- }
-}
-
-
-/*
- * Mutual exclusion on buffers. Locking model:
- *
- * Buffers associated with inodes for which buffer locking
- * is not enabled are not protected by semaphores, and are
- * assumed to be exclusively owned by the caller. There is a
- * spinlock in the buffer, used by the caller when concurrent
- * access is possible.
- */
-
-/*
- * pagebuf_cond_lock
- *
- * pagebuf_cond_lock locks a buffer object, if it is not already locked.
- * Note that this in no way
- * locks the underlying pages, so it is only useful for synchronizing
- * concurrent use of page buffer objects, not for synchronizing independent
- * access to the underlying pages.
- */
-int
-pagebuf_cond_lock( /* lock buffer, if not locked */
- /* returns -EBUSY if locked) */
- xfs_buf_t *pb)
-{
- int locked;
-
- locked = down_trylock(&pb->pb_sema) == 0;
- if (locked) {
- PB_SET_OWNER(pb);
- }
- PB_TRACE(pb, "cond_lock", (long)locked);
- return(locked ? 0 : -EBUSY);
-}
-
-/*
- * pagebuf_lock_value
- *
- * Return lock value for a pagebuf
- */
-int
-pagebuf_lock_value(
- xfs_buf_t *pb)
-{
- return(atomic_read(&pb->pb_sema.count));
-}
-
-/*
- * pagebuf_lock
- *
- * pagebuf_lock locks a buffer object. Note that this in no way
- * locks the underlying pages, so it is only useful for synchronizing
- * concurrent use of page buffer objects, not for synchronizing independent
- * access to the underlying pages.
- */
-int
-pagebuf_lock(
- xfs_buf_t *pb)
-{
- PB_TRACE(pb, "lock", 0);
- if (atomic_read(&pb->pb_io_remaining))
- blk_run_address_space(pb->pb_target->pbr_mapping);
- down(&pb->pb_sema);
- PB_SET_OWNER(pb);
- PB_TRACE(pb, "locked", 0);
- return 0;
-}
-
-/*
- * pagebuf_unlock
- *
- * pagebuf_unlock releases the lock on the buffer object created by
- * pagebuf_lock or pagebuf_cond_lock (not any
- * pinning of underlying pages created by pagebuf_pin).
- */
-void
-pagebuf_unlock( /* unlock buffer */
- xfs_buf_t *pb) /* buffer to unlock */
-{
- PB_CLEAR_OWNER(pb);
- up(&pb->pb_sema);
- PB_TRACE(pb, "unlock", 0);
-}
-
-
-/*
- * Pinning Buffer Storage in Memory
- */
-
-/*
- * pagebuf_pin
- *
- * pagebuf_pin locks all of the memory represented by a buffer in
- * memory. Multiple calls to pagebuf_pin and pagebuf_unpin, for
- * the same or different buffers affecting a given page, will
- * properly count the number of outstanding "pin" requests. The
- * buffer may be released after the pagebuf_pin and a different
- * buffer used when calling pagebuf_unpin, if desired.
- * pagebuf_pin should be used by the file system when it wants be
- * assured that no attempt will be made to force the affected
- * memory to disk. It does not assure that a given logical page
- * will not be moved to a different physical page.
- */
-void
-pagebuf_pin(
- xfs_buf_t *pb)
-{
- atomic_inc(&pb->pb_pin_count);
- PB_TRACE(pb, "pin", (long)pb->pb_pin_count.counter);
-}
-
-/*
- * pagebuf_unpin
- *
- * pagebuf_unpin reverses the locking of memory performed by
- * pagebuf_pin. Note that both functions affected the logical
- * pages associated with the buffer, not the buffer itself.
- */
-void
-pagebuf_unpin(
- xfs_buf_t *pb)
-{
- if (atomic_dec_and_test(&pb->pb_pin_count)) {
- wake_up_all(&pb->pb_waiters);
- }
- PB_TRACE(pb, "unpin", (long)pb->pb_pin_count.counter);
-}
-
-int
-pagebuf_ispin(
- xfs_buf_t *pb)
-{
- return atomic_read(&pb->pb_pin_count);
-}
-
-/*
- * pagebuf_wait_unpin
- *
- * pagebuf_wait_unpin waits until all of the memory associated
- * with the buffer is not longer locked in memory. It returns
- * immediately if none of the affected pages are locked.
- */
-static inline void
-_pagebuf_wait_unpin(
- xfs_buf_t *pb)
-{
- DECLARE_WAITQUEUE (wait, current);
-
- if (atomic_read(&pb->pb_pin_count) == 0)
- return;
-
- add_wait_queue(&pb->pb_waiters, &wait);
- for (;;) {
- current->state = TASK_UNINTERRUPTIBLE;
- if (atomic_read(&pb->pb_pin_count) == 0)
- break;
- if (atomic_read(&pb->pb_io_remaining))
- blk_run_address_space(pb->pb_target->pbr_mapping);
- schedule();
- }
- remove_wait_queue(&pb->pb_waiters, &wait);
- current->state = TASK_RUNNING;
-}
-
-/*
- * Buffer Utility Routines
- */
-
-/*
- * pagebuf_iodone
- *
- * pagebuf_iodone marks a buffer for which I/O is in progress
- * done with respect to that I/O. The pb_iodone routine, if
- * present, will be called as a side-effect.
- */
-void
-pagebuf_iodone_work(
- void *v)
-{
- xfs_buf_t *bp = (xfs_buf_t *)v;
-
- if (bp->pb_iodone)
- (*(bp->pb_iodone))(bp);
- else if (bp->pb_flags & PBF_ASYNC)
- xfs_buf_relse(bp);
-}
-
-void
-pagebuf_iodone(
- xfs_buf_t *pb,
- int dataio,
- int schedule)
-{
- pb->pb_flags &= ~(PBF_READ | PBF_WRITE);
- if (pb->pb_error == 0) {
- pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE);
- }
-
- PB_TRACE(pb, "iodone", pb->pb_iodone);
-
- if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
- if (schedule) {
- INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
- queue_work(dataio ? pagebuf_dataio_workqueue :
- pagebuf_logio_workqueue, &pb->pb_iodone_work);
- } else {
- pagebuf_iodone_work(pb);
- }
- } else {
- up(&pb->pb_iodonesema);
- }
-}
-
-/*
- * pagebuf_ioerror
- *
- * pagebuf_ioerror sets the error code for a buffer.
- */
-void
-pagebuf_ioerror( /* mark/clear buffer error flag */
- xfs_buf_t *pb, /* buffer to mark */
- int error) /* error to store (0 if none) */
-{
- ASSERT(error >= 0 && error <= 0xffff);
- pb->pb_error = (unsigned short)error;
- PB_TRACE(pb, "ioerror", (unsigned long)error);
-}
-
-/*
- * pagebuf_iostart
- *
- * pagebuf_iostart initiates I/O on a buffer, based on the flags supplied.
- * If necessary, it will arrange for any disk space allocation required,
- * and it will break up the request if the block mappings require it.
- * The pb_iodone routine in the buffer supplied will only be called
- * when all of the subsidiary I/O requests, if any, have been completed.
- * pagebuf_iostart calls the pagebuf_ioinitiate routine or
- * pagebuf_iorequest, if the former routine is not defined, to start
- * the I/O on a given low-level request.
- */
-int
-pagebuf_iostart( /* start I/O on a buffer */
- xfs_buf_t *pb, /* buffer to start */
- page_buf_flags_t flags) /* PBF_LOCK, PBF_ASYNC, PBF_READ, */
- /* PBF_WRITE, PBF_DELWRI, */
- /* PBF_DONT_BLOCK */
-{
- int status = 0;
-
- PB_TRACE(pb, "iostart", (unsigned long)flags);
-
- if (flags & PBF_DELWRI) {
- pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC);
- pb->pb_flags |= flags & (PBF_DELWRI | PBF_ASYNC);
- pagebuf_delwri_queue(pb, 1);
- return status;
- }
-
- pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC | PBF_DELWRI | \
- PBF_READ_AHEAD | _PBF_RUN_QUEUES);
- pb->pb_flags |= flags & (PBF_READ | PBF_WRITE | PBF_ASYNC | \
- PBF_READ_AHEAD | _PBF_RUN_QUEUES);
-
- BUG_ON(pb->pb_bn == XFS_BUF_DADDR_NULL);
-
- /* For writes allow an alternate strategy routine to precede
- * the actual I/O request (which may not be issued at all in
- * a shutdown situation, for example).
- */
- status = (flags & PBF_WRITE) ?
- pagebuf_iostrategy(pb) : pagebuf_iorequest(pb);
-
- /* Wait for I/O if we are not an async request.
- * Note: async I/O request completion will release the buffer,
- * and that can already be done by this point. So using the
- * buffer pointer from here on, after async I/O, is invalid.
- */
- if (!status && !(flags & PBF_ASYNC))
- status = pagebuf_iowait(pb);
-
- return status;
-}
-
-/*
- * Helper routine for pagebuf_iorequest
- */
-
-STATIC __inline__ int
-_pagebuf_iolocked(
- xfs_buf_t *pb)
-{
- ASSERT(pb->pb_flags & (PBF_READ|PBF_WRITE));
- if (pb->pb_flags & PBF_READ)
- return pb->pb_locked;
- return 0;
-}
-
-STATIC __inline__ void
-_pagebuf_iodone(
- xfs_buf_t *pb,
- int schedule)
-{
- if (atomic_dec_and_test(&pb->pb_io_remaining) == 1) {
- pb->pb_locked = 0;
- pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), schedule);
- }
-}
-
-STATIC int
-bio_end_io_pagebuf(
- struct bio *bio,
- unsigned int bytes_done,
- int error)
-{
- xfs_buf_t *pb = (xfs_buf_t *)bio->bi_private;
- unsigned int i, blocksize = pb->pb_target->pbr_bsize;
- unsigned int sectorshift = pb->pb_target->pbr_sshift;
- struct bio_vec *bvec = bio->bi_io_vec;
-
- if (bio->bi_size)
- return 1;
-
- if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
- pb->pb_error = EIO;
-
- for (i = 0; i < bio->bi_vcnt; i++, bvec++) {
- struct page *page = bvec->bv_page;
-
- if (pb->pb_error) {
- SetPageError(page);
- } else if (blocksize == PAGE_CACHE_SIZE) {
- SetPageUptodate(page);
- } else if (!PagePrivate(page) &&
- (pb->pb_flags & _PBF_PAGE_CACHE)) {
- unsigned long j, range;
-
- ASSERT(blocksize < PAGE_CACHE_SIZE);
- range = (bvec->bv_offset + bvec->bv_len) >> sectorshift;
- for (j = bvec->bv_offset >> sectorshift; j < range; j++)
- set_bit(j, &page->private);
- if (page->private == (unsigned long)(PAGE_CACHE_SIZE-1))
- SetPageUptodate(page);
- }
-
- if (_pagebuf_iolocked(pb)) {
- unlock_page(page);
- }
- }
-
- _pagebuf_iodone(pb, 1);
- bio_put(bio);
- return 0;
-}
-
-void
-_pagebuf_ioapply(
- xfs_buf_t *pb)
-{
- int i, map_i, total_nr_pages, nr_pages;
- struct bio *bio;
- int offset = pb->pb_offset;
- int size = pb->pb_count_desired;
- sector_t sector = pb->pb_bn;
- unsigned int blocksize = pb->pb_target->pbr_bsize;
- int locking = _pagebuf_iolocked(pb);
-
- total_nr_pages = pb->pb_page_count;
- map_i = 0;
-
- /* Special code path for reading a sub page size pagebuf in --
- * we populate up the whole page, and hence the other metadata
- * in the same page. This optimization is only valid when the
- * filesystem block size and the page size are equal.
- */
- if ((pb->pb_buffer_length < PAGE_CACHE_SIZE) &&
- (pb->pb_flags & PBF_READ) && locking &&
- (blocksize == PAGE_CACHE_SIZE)) {
- bio = bio_alloc(GFP_NOIO, 1);
-
- bio->bi_bdev = pb->pb_target->pbr_bdev;
- bio->bi_sector = sector - (offset >> BBSHIFT);
- bio->bi_end_io = bio_end_io_pagebuf;
- bio->bi_private = pb;
-
- bio_add_page(bio, pb->pb_pages[0], PAGE_CACHE_SIZE, 0);
- size = 0;
-
- atomic_inc(&pb->pb_io_remaining);
-
- goto submit_io;
- }
-
- /* Lock down the pages which we need to for the request */
- if (locking && (pb->pb_flags & PBF_WRITE) && (pb->pb_locked == 0)) {
- for (i = 0; size; i++) {
- int nbytes = PAGE_CACHE_SIZE - offset;
- struct page *page = pb->pb_pages[i];
-
- if (nbytes > size)
- nbytes = size;
-
- lock_page(page);
-
- size -= nbytes;
- offset = 0;
- }
- offset = pb->pb_offset;
- size = pb->pb_count_desired;
- }
-
-next_chunk:
- atomic_inc(&pb->pb_io_remaining);
- nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
- if (nr_pages > total_nr_pages)
- nr_pages = total_nr_pages;
-
- bio = bio_alloc(GFP_NOIO, nr_pages);
- bio->bi_bdev = pb->pb_target->pbr_bdev;
- bio->bi_sector = sector;
- bio->bi_end_io = bio_end_io_pagebuf;
- bio->bi_private = pb;
-
- for (; size && nr_pages; nr_pages--, map_i++) {
- int nbytes = PAGE_CACHE_SIZE - offset;
-
- if (nbytes > size)
- nbytes = size;
-
- if (bio_add_page(bio, pb->pb_pages[map_i],
- nbytes, offset) < nbytes)
- break;
-
- offset = 0;
- sector += nbytes >> BBSHIFT;
- size -= nbytes;
- total_nr_pages--;
- }
-
-submit_io:
- if (likely(bio->bi_size)) {
- submit_bio((pb->pb_flags & PBF_READ) ? READ : WRITE, bio);
- if (size)
- goto next_chunk;
- } else {
- bio_put(bio);
- pagebuf_ioerror(pb, EIO);
- }
-
- if (pb->pb_flags & _PBF_RUN_QUEUES) {
- pb->pb_flags &= ~_PBF_RUN_QUEUES;
- if (atomic_read(&pb->pb_io_remaining) > 1)
- blk_run_address_space(pb->pb_target->pbr_mapping);
- }
-}
-
-/*
- * pagebuf_iorequest -- the core I/O request routine.
- */
-int
-pagebuf_iorequest( /* start real I/O */
- xfs_buf_t *pb) /* buffer to convey to device */
-{
- PB_TRACE(pb, "iorequest", 0);
-
- if (pb->pb_flags & PBF_DELWRI) {
- pagebuf_delwri_queue(pb, 1);
- return 0;
- }
-
- if (pb->pb_flags & PBF_WRITE) {
- _pagebuf_wait_unpin(pb);
- }
-
- pagebuf_hold(pb);
-
- /* Set the count to 1 initially, this will stop an I/O
- * completion callout which happens before we have started
- * all the I/O from calling pagebuf_iodone too early.
- */
- atomic_set(&pb->pb_io_remaining, 1);
- _pagebuf_ioapply(pb);
- _pagebuf_iodone(pb, 0);
-
- pagebuf_rele(pb);
- return 0;
-}
-
-/*
- * pagebuf_iowait
- *
- * pagebuf_iowait waits for I/O to complete on the buffer supplied.
- * It returns immediately if no I/O is pending. In any case, it returns
- * the error code, if any, or 0 if there is no error.
- */
-int
-pagebuf_iowait(
- xfs_buf_t *pb)
-{
- PB_TRACE(pb, "iowait", 0);
- if (atomic_read(&pb->pb_io_remaining))
- blk_run_address_space(pb->pb_target->pbr_mapping);
- down(&pb->pb_iodonesema);
- PB_TRACE(pb, "iowaited", (long)pb->pb_error);
- return pb->pb_error;
-}
-
-caddr_t
-pagebuf_offset(
- xfs_buf_t *pb,
- size_t offset)
-{
- struct page *page;
-
- offset += pb->pb_offset;
-
- page = pb->pb_pages[offset >> PAGE_CACHE_SHIFT];
- return (caddr_t) page_address(page) + (offset & (PAGE_CACHE_SIZE - 1));
-}
-
-/*
- * pagebuf_iomove
- *
- * Move data into or out of a buffer.
- */
-void
-pagebuf_iomove(
- xfs_buf_t *pb, /* buffer to process */
- size_t boff, /* starting buffer offset */
- size_t bsize, /* length to copy */
- caddr_t data, /* data address */
- page_buf_rw_t mode) /* read/write flag */
-{
- size_t bend, cpoff, csize;
- struct page *page;
-
- bend = boff + bsize;
- while (boff < bend) {
- page = pb->pb_pages[page_buf_btoct(boff + pb->pb_offset)];
- cpoff = page_buf_poff(boff + pb->pb_offset);
- csize = min_t(size_t,
- PAGE_CACHE_SIZE-cpoff, pb->pb_count_desired-boff);
-
- ASSERT(((csize + cpoff) <= PAGE_CACHE_SIZE));
-
- switch (mode) {
- case PBRW_ZERO:
- memset(page_address(page) + cpoff, 0, csize);
- break;
- case PBRW_READ:
- memcpy(data, page_address(page) + cpoff, csize);
- break;
- case PBRW_WRITE:
- memcpy(page_address(page) + cpoff, data, csize);
- }
-
- boff += csize;
- data += csize;
- }
-}
-
-/*
- * Handling of buftargs.
- */
-
-void
-xfs_free_buftarg(
- xfs_buftarg_t *btp,
- int external)
-{
- xfs_flush_buftarg(btp, 1);
- if (external)
- xfs_blkdev_put(btp->pbr_bdev);
- kmem_free(btp, sizeof(*btp));
-}
-
-void
-xfs_incore_relse(
- xfs_buftarg_t *btp,
- int delwri_only,
- int wait)
-{
- invalidate_bdev(btp->pbr_bdev, 1);
- truncate_inode_pages(btp->pbr_mapping, 0LL);
-}
-
-void
-xfs_setsize_buftarg(
- xfs_buftarg_t *btp,
- unsigned int blocksize,
- unsigned int sectorsize)
-{
- btp->pbr_bsize = blocksize;
- btp->pbr_sshift = ffs(sectorsize) - 1;
- btp->pbr_smask = sectorsize - 1;
-
- if (set_blocksize(btp->pbr_bdev, sectorsize)) {
- printk(KERN_WARNING
- "XFS: Cannot set_blocksize to %u on device %s\n",
- sectorsize, XFS_BUFTARG_NAME(btp));
- }
-}
-
-xfs_buftarg_t *
-xfs_alloc_buftarg(
- struct block_device *bdev)
-{
- xfs_buftarg_t *btp;
-
- btp = kmem_zalloc(sizeof(*btp), KM_SLEEP);
-
- btp->pbr_dev = bdev->bd_dev;
- btp->pbr_bdev = bdev;
- btp->pbr_mapping = bdev->bd_inode->i_mapping;
- xfs_setsize_buftarg(btp, PAGE_CACHE_SIZE, bdev_hardsect_size(bdev));
-
- return btp;
-}
-
-
-/*
- * Pagebuf delayed write buffer handling
- */
-
-STATIC LIST_HEAD(pbd_delwrite_queue);
-STATIC spinlock_t pbd_delwrite_lock = SPIN_LOCK_UNLOCKED;
-
-STATIC void
-pagebuf_delwri_queue(
- xfs_buf_t *pb,
- int unlock)
-{
- PB_TRACE(pb, "delwri_q", (long)unlock);
- ASSERT(pb->pb_flags & PBF_DELWRI);
-
- spin_lock(&pbd_delwrite_lock);
- /* If already in the queue, dequeue and place at tail */
- if (!list_empty(&pb->pb_list)) {
- if (unlock) {
- atomic_dec(&pb->pb_hold);
- }
- list_del(&pb->pb_list);
- }
-
- list_add_tail(&pb->pb_list, &pbd_delwrite_queue);
- pb->pb_queuetime = jiffies;
- spin_unlock(&pbd_delwrite_lock);
-
- if (unlock)
- pagebuf_unlock(pb);
-}
-
-void
-pagebuf_delwri_dequeue(
- xfs_buf_t *pb)
-{
- PB_TRACE(pb, "delwri_uq", 0);
- spin_lock(&pbd_delwrite_lock);
- list_del_init(&pb->pb_list);
- pb->pb_flags &= ~PBF_DELWRI;
- spin_unlock(&pbd_delwrite_lock);
-}
-
-STATIC void
-pagebuf_runall_queues(
- struct workqueue_struct *queue)
-{
- flush_workqueue(queue);
-}
-
-/* Defines for pagebuf daemon */
-STATIC DECLARE_COMPLETION(pagebuf_daemon_done);
-STATIC struct task_struct *pagebuf_daemon_task;
-STATIC int pagebuf_daemon_active;
-STATIC int force_flush;
-
-STATIC void
-pagebuf_daemon_wakeup(void)
-{
- force_flush = 1;
- barrier();
- wake_up_process(pagebuf_daemon_task);
-}
-
-STATIC int
-pagebuf_daemon(
- void *data)
-{
- struct list_head tmp;
- xfs_buf_t *pb, *n;
-
- /* Set up the thread */
- daemonize("xfsbufd");
- current->flags |= PF_MEMALLOC;
-
- pagebuf_daemon_task = current;
- pagebuf_daemon_active = 1;
- barrier();
-
- INIT_LIST_HEAD(&tmp);
- do {
- /* swsusp */
- if (current->flags & PF_FREEZE)
- refrigerator(PF_FREEZE);
-
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(xfs_flush_interval);
-
- spin_lock(&pbd_delwrite_lock);
- list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
- PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
- ASSERT(pb->pb_flags & PBF_DELWRI);
-
- if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) {
- if (!force_flush &&
- time_before(jiffies,
- pb->pb_queuetime +
- xfs_age_buffer)) {
- pagebuf_unlock(pb);
- break;
- }
-
- pb->pb_flags &= ~PBF_DELWRI;
- pb->pb_flags |= PBF_WRITE;
- list_move(&pb->pb_list, &tmp);
- }
- }
- spin_unlock(&pbd_delwrite_lock);
-
- while (!list_empty(&tmp)) {
- pb = list_entry(tmp.next, xfs_buf_t, pb_list);
- list_del_init(&pb->pb_list);
- pagebuf_iostrategy(pb);
- blk_run_address_space(pb->pb_target->pbr_mapping);
- }
-
- if (as_list_len > 0)
- purge_addresses();
-
- force_flush = 0;
- } while (pagebuf_daemon_active);
-
- complete_and_exit(&pagebuf_daemon_done, 0);
-}
-
-/*
- * Go through all incore buffers, and release buffers if they belong to
- * the given device. This is used in filesystem error handling to
- * preserve the consistency of its metadata.
- */
-int
-xfs_flush_buftarg(
- xfs_buftarg_t *target,
- int wait)
-{
- struct list_head tmp;
- xfs_buf_t *pb, *n;
- int pincount = 0;
-
- pagebuf_runall_queues(pagebuf_dataio_workqueue);
- pagebuf_runall_queues(pagebuf_logio_workqueue);
-
- INIT_LIST_HEAD(&tmp);
- spin_lock(&pbd_delwrite_lock);
- list_for_each_entry_safe(pb, n, &pbd_delwrite_queue, pb_list) {
-
- if (pb->pb_target != target)
- continue;
-
- ASSERT(pb->pb_flags & PBF_DELWRI);
- PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
- if (pagebuf_ispin(pb)) {
- pincount++;
- continue;
- }
-
- pb->pb_flags &= ~PBF_DELWRI;
- pb->pb_flags |= PBF_WRITE;
- list_move(&pb->pb_list, &tmp);
- }
- spin_unlock(&pbd_delwrite_lock);
-
- /*
- * Dropped the delayed write list lock, now walk the temporary list
- */
- list_for_each_entry_safe(pb, n, &tmp, pb_list) {
- if (wait)
- pb->pb_flags &= ~PBF_ASYNC;
- else
- list_del_init(&pb->pb_list);
-
- pagebuf_lock(pb);
- pagebuf_iostrategy(pb);
- }
-
- /*
- * Remaining list items must be flushed before returning
- */
- while (!list_empty(&tmp)) {
- pb = list_entry(tmp.next, xfs_buf_t, pb_list);
-
- list_del_init(&pb->pb_list);
- xfs_iowait(pb);
- xfs_buf_relse(pb);
- }
-
- if (wait)
- blk_run_address_space(target->pbr_mapping);
-
- return pincount;
-}
-
-STATIC int
-pagebuf_daemon_start(void)
-{
- int rval;
-
- pagebuf_logio_workqueue = create_workqueue("xfslogd");
- if (!pagebuf_logio_workqueue)
- return -ENOMEM;
-
- pagebuf_dataio_workqueue = create_workqueue("xfsdatad");
- if (!pagebuf_dataio_workqueue) {
- destroy_workqueue(pagebuf_logio_workqueue);
- return -ENOMEM;
- }
-
- rval = kernel_thread(pagebuf_daemon, NULL, CLONE_FS|CLONE_FILES);
- if (rval < 0) {
- destroy_workqueue(pagebuf_logio_workqueue);
- destroy_workqueue(pagebuf_dataio_workqueue);
- }
-
- return rval;
-}
-
-/*
- * pagebuf_daemon_stop
- *
- * Note: do not mark as __exit, it is called from pagebuf_terminate.
- */
-STATIC void
-pagebuf_daemon_stop(void)
-{
- pagebuf_daemon_active = 0;
- barrier();
- wait_for_completion(&pagebuf_daemon_done);
-
- destroy_workqueue(pagebuf_logio_workqueue);
- destroy_workqueue(pagebuf_dataio_workqueue);
-}
-
-/*
- * Initialization and Termination
- */
-
-int __init
-pagebuf_init(void)
-{
- int i;
-
- pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0,
- SLAB_HWCACHE_ALIGN, NULL, NULL);
- if (pagebuf_cache == NULL) {
- printk("pagebuf: couldn't init pagebuf cache\n");
- pagebuf_terminate();
- return -ENOMEM;
- }
-
- for (i = 0; i < NHASH; i++) {
- spin_lock_init(&pbhash[i].pb_hash_lock);
- INIT_LIST_HEAD(&pbhash[i].pb_hash);
- }
-
-#ifdef PAGEBUF_TRACE
- pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
-#endif
-
- pagebuf_daemon_start();
- return 0;
-}
-
-
-/*
- * pagebuf_terminate.
- *
- * Note: do not mark as __exit, this is also called from the __init code.
- */
-void
-pagebuf_terminate(void)
-{
- pagebuf_daemon_stop();
-
-#ifdef PAGEBUF_TRACE
- ktrace_free(pagebuf_trace_buf);
-#endif
-
- kmem_cache_destroy(pagebuf_cache);
-}
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * Written by Steve Lord, Jim Mostek, Russell Cattelan at SGI
- */
-
-#ifndef __XFS_BUF_H__
-#define __XFS_BUF_H__
-
-#include <linux/config.h>
-#include <linux/list.h>
-#include <linux/types.h>
-#include <linux/spinlock.h>
-#include <asm/system.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include <linux/buffer_head.h>
-#include <linux/uio.h>
-
-/*
- * Base types
- */
-
-#define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL))
-
-#define page_buf_ctob(pp) ((pp) * PAGE_CACHE_SIZE)
-#define page_buf_btoc(dd) (((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
-#define page_buf_btoct(dd) ((dd) >> PAGE_CACHE_SHIFT)
-#define page_buf_poff(aa) ((aa) & ~PAGE_CACHE_MASK)
-
-typedef enum page_buf_rw_e {
- PBRW_READ = 1, /* transfer into target memory */
- PBRW_WRITE = 2, /* transfer from target memory */
- PBRW_ZERO = 3 /* Zero target memory */
-} page_buf_rw_t;
-
-
-typedef enum page_buf_flags_e { /* pb_flags values */
- PBF_READ = (1 << 0), /* buffer intended for reading from device */
- PBF_WRITE = (1 << 1), /* buffer intended for writing to device */
- PBF_MAPPED = (1 << 2), /* buffer mapped (pb_addr valid) */
- PBF_PARTIAL = (1 << 3), /* buffer partially read */
- PBF_ASYNC = (1 << 4), /* initiator will not wait for completion */
- PBF_NONE = (1 << 5), /* buffer not read at all */
- PBF_DELWRI = (1 << 6), /* buffer has dirty pages */
- PBF_STALE = (1 << 7), /* buffer has been staled, do not find it */
- PBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */
- PBF_FS_DATAIOD = (1 << 9), /* schedule IO completion on fs datad */
- PBF_FORCEIO = (1 << 10), /* ignore any cache state */
- PBF_FLUSH = (1 << 11), /* flush disk write cache */
- PBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */
-
- /* flags used only as arguments to access routines */
- PBF_LOCK = (1 << 14), /* lock requested */
- PBF_TRYLOCK = (1 << 15), /* lock requested, but do not wait */
- PBF_DONT_BLOCK = (1 << 16), /* do not block in current thread */
-
- /* flags used only internally */
- _PBF_PAGE_CACHE = (1 << 17),/* backed by pagecache */
- _PBF_KMEM_ALLOC = (1 << 18),/* backed by kmem_alloc() */
- _PBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
-} page_buf_flags_t;
-
-#define PBF_UPDATE (PBF_READ | PBF_WRITE)
-#define PBF_NOT_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) != 0)
-#define PBF_DONE(pb) (((pb)->pb_flags & (PBF_PARTIAL|PBF_NONE)) == 0)
-
-typedef struct xfs_buftarg {
- dev_t pbr_dev;
- struct block_device *pbr_bdev;
- struct address_space *pbr_mapping;
- unsigned int pbr_bsize;
- unsigned int pbr_sshift;
- size_t pbr_smask;
-} xfs_buftarg_t;
-
-/*
- * xfs_buf_t: Buffer structure for page cache-based buffers
- *
- * This buffer structure is used by the page cache buffer management routines
- * to refer to an assembly of pages forming a logical buffer. The actual
- * I/O is performed with buffer_head or bio structures, as required by drivers,
- * for drivers which do not understand this structure. The buffer structure is
- * used on temporary basis only, and discarded when released.
- *
- * The real data storage is recorded in the page cache. Metadata is
- * hashed to the inode for the block device on which the file system resides.
- * File data is hashed to the inode for the file. Pages which are only
- * partially filled with data have bits set in their block_map entry
- * to indicate which disk blocks in the page are not valid.
- */
-
-struct xfs_buf;
-typedef void (*page_buf_iodone_t)(struct xfs_buf *);
- /* call-back function on I/O completion */
-typedef void (*page_buf_relse_t)(struct xfs_buf *);
- /* call-back function on I/O completion */
-typedef int (*page_buf_bdstrat_t)(struct xfs_buf *);
-
-#define PB_PAGES 4
-
-typedef struct xfs_buf {
- struct semaphore pb_sema; /* semaphore for lockables */
- unsigned long pb_queuetime; /* time buffer was queued */
- atomic_t pb_pin_count; /* pin count */
- wait_queue_head_t pb_waiters; /* unpin waiters */
- struct list_head pb_list;
- page_buf_flags_t pb_flags; /* status flags */
- struct list_head pb_hash_list;
- xfs_buftarg_t *pb_target; /* logical object */
- atomic_t pb_hold; /* reference count */
- xfs_daddr_t pb_bn; /* block number for I/O */
- loff_t pb_file_offset; /* offset in file */
- size_t pb_buffer_length; /* size of buffer in bytes */
- size_t pb_count_desired; /* desired transfer size */
- void *pb_addr; /* virtual address of buffer */
- struct work_struct pb_iodone_work;
- atomic_t pb_io_remaining;/* #outstanding I/O requests */
- page_buf_iodone_t pb_iodone; /* I/O completion function */
- page_buf_relse_t pb_relse; /* releasing function */
- page_buf_bdstrat_t pb_strat; /* pre-write function */
- struct semaphore pb_iodonesema; /* Semaphore for I/O waiters */
- void *pb_fspriv;
- void *pb_fspriv2;
- void *pb_fspriv3;
- unsigned short pb_error; /* error code on I/O */
- unsigned short pb_page_count; /* size of page array */
- unsigned short pb_offset; /* page offset in first page */
- unsigned char pb_locked; /* page array is locked */
- unsigned char pb_hash_index; /* hash table index */
- struct page **pb_pages; /* array of page pointers */
- struct page *pb_page_array[PB_PAGES]; /* inline pages */
-#ifdef PAGEBUF_LOCK_TRACKING
- int pb_last_holder;
-#endif
-} xfs_buf_t;
-
-
-/* Finding and Reading Buffers */
-
-extern xfs_buf_t *pagebuf_find( /* find buffer for block if */
- /* the block is in memory */
- xfs_buftarg_t *, /* inode for block */
- loff_t, /* starting offset of range */
- size_t, /* length of range */
- page_buf_flags_t); /* PBF_LOCK */
-
-extern xfs_buf_t *pagebuf_get( /* allocate a buffer */
- xfs_buftarg_t *, /* inode for buffer */
- loff_t, /* starting offset of range */
- size_t, /* length of range */
- page_buf_flags_t); /* PBF_LOCK, PBF_READ, */
- /* PBF_ASYNC */
-
-extern xfs_buf_t *pagebuf_lookup(
- xfs_buftarg_t *,
- loff_t, /* starting offset of range */
- size_t, /* length of range */
- page_buf_flags_t); /* PBF_READ, PBF_WRITE, */
- /* PBF_FORCEIO, */
-
-extern xfs_buf_t *pagebuf_get_empty( /* allocate pagebuf struct with */
- /* no memory or disk address */
- size_t len,
- xfs_buftarg_t *); /* mount point "fake" inode */
-
-extern xfs_buf_t *pagebuf_get_no_daddr(/* allocate pagebuf struct */
- /* without disk address */
- size_t len,
- xfs_buftarg_t *); /* mount point "fake" inode */
-
-extern int pagebuf_associate_memory(
- xfs_buf_t *,
- void *,
- size_t);
-
-extern void pagebuf_hold( /* increment reference count */
- xfs_buf_t *); /* buffer to hold */
-
-extern void pagebuf_readahead( /* read ahead into cache */
- xfs_buftarg_t *, /* target for buffer (or NULL) */
- loff_t, /* starting offset of range */
- size_t, /* length of range */
- page_buf_flags_t); /* additional read flags */
-
-/* Releasing Buffers */
-
-extern void pagebuf_free( /* deallocate a buffer */
- xfs_buf_t *); /* buffer to deallocate */
-
-extern void pagebuf_rele( /* release hold on a buffer */
- xfs_buf_t *); /* buffer to release */
-
-/* Locking and Unlocking Buffers */
-
-extern int pagebuf_cond_lock( /* lock buffer, if not locked */
- /* (returns -EBUSY if locked) */
- xfs_buf_t *); /* buffer to lock */
-
-extern int pagebuf_lock_value( /* return count on lock */
- xfs_buf_t *); /* buffer to check */
-
-extern int pagebuf_lock( /* lock buffer */
- xfs_buf_t *); /* buffer to lock */
-
-extern void pagebuf_unlock( /* unlock buffer */
- xfs_buf_t *); /* buffer to unlock */
-
-/* Buffer Read and Write Routines */
-
-extern void pagebuf_iodone( /* mark buffer I/O complete */
- xfs_buf_t *, /* buffer to mark */
- int, /* use data/log helper thread. */
- int); /* run completion locally, or in
- * a helper thread. */
-
-extern void pagebuf_ioerror( /* mark buffer in error (or not) */
- xfs_buf_t *, /* buffer to mark */
- int); /* error to store (0 if none) */
-
-extern int pagebuf_iostart( /* start I/O on a buffer */
- xfs_buf_t *, /* buffer to start */
- page_buf_flags_t); /* PBF_LOCK, PBF_ASYNC, */
- /* PBF_READ, PBF_WRITE, */
- /* PBF_DELWRI */
-
-extern int pagebuf_iorequest( /* start real I/O */
- xfs_buf_t *); /* buffer to convey to device */
-
-extern int pagebuf_iowait( /* wait for buffer I/O done */
- xfs_buf_t *); /* buffer to wait on */
-
-extern void pagebuf_iomove( /* move data in/out of pagebuf */
- xfs_buf_t *, /* buffer to manipulate */
- size_t, /* starting buffer offset */
- size_t, /* length in buffer */
- caddr_t, /* data pointer */
- page_buf_rw_t); /* direction */
-
-static inline int pagebuf_iostrategy(xfs_buf_t *pb)
-{
- return pb->pb_strat ? pb->pb_strat(pb) : pagebuf_iorequest(pb);
-}
-
-static inline int pagebuf_geterror(xfs_buf_t *pb)
-{
- return pb ? pb->pb_error : ENOMEM;
-}
-
-/* Buffer Utility Routines */
-
-extern caddr_t pagebuf_offset( /* pointer at offset in buffer */
- xfs_buf_t *, /* buffer to offset into */
- size_t); /* offset */
-
-/* Pinning Buffer Storage in Memory */
-
-extern void pagebuf_pin( /* pin buffer in memory */
- xfs_buf_t *); /* buffer to pin */
-
-extern void pagebuf_unpin( /* unpin buffered data */
- xfs_buf_t *); /* buffer to unpin */
-
-extern int pagebuf_ispin( /* check if buffer is pinned */
- xfs_buf_t *); /* buffer to check */
-
-/* Delayed Write Buffer Routines */
-
-extern void pagebuf_delwri_dequeue(xfs_buf_t *);
-
-/* Buffer Daemon Setup Routines */
-
-extern int pagebuf_init(void);
-extern void pagebuf_terminate(void);
-
-
-#ifdef PAGEBUF_TRACE
-extern ktrace_t *pagebuf_trace_buf;
-extern void pagebuf_trace(
- xfs_buf_t *, /* buffer being traced */
- char *, /* description of operation */
- void *, /* arbitrary diagnostic value */
- void *); /* return address */
-#else
-# define pagebuf_trace(pb, id, ptr, ra) do { } while (0)
-#endif
-
-#define pagebuf_target_name(target) \
- ({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; })
-
-
-
-
-
-/* These are just for xfs_syncsub... it sets an internal variable
- * then passes it to VOP_FLUSH_PAGES or adds the flags to a newly gotten buf_t
- */
-#define XFS_B_ASYNC PBF_ASYNC
-#define XFS_B_DELWRI PBF_DELWRI
-#define XFS_B_READ PBF_READ
-#define XFS_B_WRITE PBF_WRITE
-#define XFS_B_STALE PBF_STALE
-
-#define XFS_BUF_TRYLOCK PBF_TRYLOCK
-#define XFS_INCORE_TRYLOCK PBF_TRYLOCK
-#define XFS_BUF_LOCK PBF_LOCK
-#define XFS_BUF_MAPPED PBF_MAPPED
-
-#define BUF_BUSY PBF_DONT_BLOCK
-
-#define XFS_BUF_BFLAGS(x) ((x)->pb_flags)
-#define XFS_BUF_ZEROFLAGS(x) \
- ((x)->pb_flags &= ~(PBF_READ|PBF_WRITE|PBF_ASYNC|PBF_DELWRI))
-
-#define XFS_BUF_STALE(x) ((x)->pb_flags |= XFS_B_STALE)
-#define XFS_BUF_UNSTALE(x) ((x)->pb_flags &= ~XFS_B_STALE)
-#define XFS_BUF_ISSTALE(x) ((x)->pb_flags & XFS_B_STALE)
-#define XFS_BUF_SUPER_STALE(x) do { \
- XFS_BUF_STALE(x); \
- xfs_buf_undelay(x); \
- XFS_BUF_DONE(x); \
- } while (0)
-
-#define XFS_BUF_MANAGE PBF_FS_MANAGED
-#define XFS_BUF_UNMANAGE(x) ((x)->pb_flags &= ~PBF_FS_MANAGED)
-
-static inline void xfs_buf_undelay(xfs_buf_t *pb)
-{
- if (pb->pb_flags & PBF_DELWRI) {
- if (pb->pb_list.next != &pb->pb_list) {
- pagebuf_delwri_dequeue(pb);
- pagebuf_rele(pb);
- } else {
- pb->pb_flags &= ~PBF_DELWRI;
- }
- }
-}
-
-#define XFS_BUF_DELAYWRITE(x) ((x)->pb_flags |= PBF_DELWRI)
-#define XFS_BUF_UNDELAYWRITE(x) xfs_buf_undelay(x)
-#define XFS_BUF_ISDELAYWRITE(x) ((x)->pb_flags & PBF_DELWRI)
-
-#define XFS_BUF_ERROR(x,no) pagebuf_ioerror(x,no)
-#define XFS_BUF_GETERROR(x) pagebuf_geterror(x)
-#define XFS_BUF_ISERROR(x) (pagebuf_geterror(x)?1:0)
-
-#define XFS_BUF_DONE(x) ((x)->pb_flags &= ~(PBF_PARTIAL|PBF_NONE))
-#define XFS_BUF_UNDONE(x) ((x)->pb_flags |= PBF_PARTIAL|PBF_NONE)
-#define XFS_BUF_ISDONE(x) (!(PBF_NOT_DONE(x)))
-
-#define XFS_BUF_BUSY(x) ((x)->pb_flags |= PBF_FORCEIO)
-#define XFS_BUF_UNBUSY(x) ((x)->pb_flags &= ~PBF_FORCEIO)
-#define XFS_BUF_ISBUSY(x) (1)
-
-#define XFS_BUF_ASYNC(x) ((x)->pb_flags |= PBF_ASYNC)
-#define XFS_BUF_UNASYNC(x) ((x)->pb_flags &= ~PBF_ASYNC)
-#define XFS_BUF_ISASYNC(x) ((x)->pb_flags & PBF_ASYNC)
-
-#define XFS_BUF_FLUSH(x) ((x)->pb_flags |= PBF_FLUSH)
-#define XFS_BUF_UNFLUSH(x) ((x)->pb_flags &= ~PBF_FLUSH)
-#define XFS_BUF_ISFLUSH(x) ((x)->pb_flags & PBF_FLUSH)
-
-#define XFS_BUF_SHUT(x) printk("XFS_BUF_SHUT not implemented yet\n")
-#define XFS_BUF_UNSHUT(x) printk("XFS_BUF_UNSHUT not implemented yet\n")
-#define XFS_BUF_ISSHUT(x) (0)
-
-#define XFS_BUF_HOLD(x) pagebuf_hold(x)
-#define XFS_BUF_READ(x) ((x)->pb_flags |= PBF_READ)
-#define XFS_BUF_UNREAD(x) ((x)->pb_flags &= ~PBF_READ)
-#define XFS_BUF_ISREAD(x) ((x)->pb_flags & PBF_READ)
-
-#define XFS_BUF_WRITE(x) ((x)->pb_flags |= PBF_WRITE)
-#define XFS_BUF_UNWRITE(x) ((x)->pb_flags &= ~PBF_WRITE)
-#define XFS_BUF_ISWRITE(x) ((x)->pb_flags & PBF_WRITE)
-
-#define XFS_BUF_ISUNINITIAL(x) (0)
-#define XFS_BUF_UNUNINITIAL(x) (0)
-
-#define XFS_BUF_BP_ISMAPPED(bp) 1
-
-#define XFS_BUF_DATAIO(x) ((x)->pb_flags |= PBF_FS_DATAIOD)
-#define XFS_BUF_UNDATAIO(x) ((x)->pb_flags &= ~PBF_FS_DATAIOD)
-
-#define XFS_BUF_IODONE_FUNC(buf) (buf)->pb_iodone
-#define XFS_BUF_SET_IODONE_FUNC(buf, func) \
- (buf)->pb_iodone = (func)
-#define XFS_BUF_CLR_IODONE_FUNC(buf) \
- (buf)->pb_iodone = NULL
-#define XFS_BUF_SET_BDSTRAT_FUNC(buf, func) \
- (buf)->pb_strat = (func)
-#define XFS_BUF_CLR_BDSTRAT_FUNC(buf) \
- (buf)->pb_strat = NULL
-
-#define XFS_BUF_FSPRIVATE(buf, type) \
- ((type)(buf)->pb_fspriv)
-#define XFS_BUF_SET_FSPRIVATE(buf, value) \
- (buf)->pb_fspriv = (void *)(value)
-#define XFS_BUF_FSPRIVATE2(buf, type) \
- ((type)(buf)->pb_fspriv2)
-#define XFS_BUF_SET_FSPRIVATE2(buf, value) \
- (buf)->pb_fspriv2 = (void *)(value)
-#define XFS_BUF_FSPRIVATE3(buf, type) \
- ((type)(buf)->pb_fspriv3)
-#define XFS_BUF_SET_FSPRIVATE3(buf, value) \
- (buf)->pb_fspriv3 = (void *)(value)
-#define XFS_BUF_SET_START(buf)
-
-#define XFS_BUF_SET_BRELSE_FUNC(buf, value) \
- (buf)->pb_relse = (value)
-
-#define XFS_BUF_PTR(bp) (xfs_caddr_t)((bp)->pb_addr)
-
-extern inline xfs_caddr_t xfs_buf_offset(xfs_buf_t *bp, size_t offset)
-{
- if (bp->pb_flags & PBF_MAPPED)
- return XFS_BUF_PTR(bp) + offset;
- return (xfs_caddr_t) pagebuf_offset(bp, offset);
-}
-
-#define XFS_BUF_SET_PTR(bp, val, count) \
- pagebuf_associate_memory(bp, val, count)
-#define XFS_BUF_ADDR(bp) ((bp)->pb_bn)
-#define XFS_BUF_SET_ADDR(bp, blk) \
- ((bp)->pb_bn = (blk))
-#define XFS_BUF_OFFSET(bp) ((bp)->pb_file_offset)
-#define XFS_BUF_SET_OFFSET(bp, off) \
- ((bp)->pb_file_offset = (off))
-#define XFS_BUF_COUNT(bp) ((bp)->pb_count_desired)
-#define XFS_BUF_SET_COUNT(bp, cnt) \
- ((bp)->pb_count_desired = (cnt))
-#define XFS_BUF_SIZE(bp) ((bp)->pb_buffer_length)
-#define XFS_BUF_SET_SIZE(bp, cnt) \
- ((bp)->pb_buffer_length = (cnt))
-#define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
-#define XFS_BUF_SET_VTYPE(bp, type)
-#define XFS_BUF_SET_REF(bp, ref)
-
-#define XFS_BUF_ISPINNED(bp) pagebuf_ispin(bp)
-
-#define XFS_BUF_VALUSEMA(bp) pagebuf_lock_value(bp)
-#define XFS_BUF_CPSEMA(bp) (pagebuf_cond_lock(bp) == 0)
-#define XFS_BUF_VSEMA(bp) pagebuf_unlock(bp)
-#define XFS_BUF_PSEMA(bp,x) pagebuf_lock(bp)
-#define XFS_BUF_V_IODONESEMA(bp) up(&bp->pb_iodonesema);
-
-/* setup the buffer target from a buftarg structure */
-#define XFS_BUF_SET_TARGET(bp, target) \
- (bp)->pb_target = (target)
-#define XFS_BUF_TARGET(bp) ((bp)->pb_target)
-#define XFS_BUFTARG_NAME(target) \
- pagebuf_target_name(target)
-
-#define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
-#define XFS_BUF_SET_VTYPE(bp, type)
-#define XFS_BUF_SET_REF(bp, ref)
-
-#define xfs_buf_read(target, blkno, len, flags) \
- pagebuf_get((target), (blkno), (len), \
- PBF_LOCK | PBF_READ | PBF_MAPPED)
-#define xfs_buf_get(target, blkno, len, flags) \
- pagebuf_get((target), (blkno), (len), \
- PBF_LOCK | PBF_MAPPED)
-
-#define xfs_buf_read_flags(target, blkno, len, flags) \
- pagebuf_get((target), (blkno), (len), PBF_READ | (flags))
-#define xfs_buf_get_flags(target, blkno, len, flags) \
- pagebuf_get((target), (blkno), (len), (flags))
-
-static inline int xfs_bawrite(void *mp, xfs_buf_t *bp)
-{
- bp->pb_fspriv3 = mp;
- bp->pb_strat = xfs_bdstrat_cb;
- xfs_buf_undelay(bp);
- return pagebuf_iostart(bp, PBF_WRITE | PBF_ASYNC | _PBF_RUN_QUEUES);
-}
-
-static inline void xfs_buf_relse(xfs_buf_t *bp)
-{
- if (!bp->pb_relse)
- pagebuf_unlock(bp);
- pagebuf_rele(bp);
-}
-
-#define xfs_bpin(bp) pagebuf_pin(bp)
-#define xfs_bunpin(bp) pagebuf_unpin(bp)
-
-#define xfs_buftrace(id, bp) \
- pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
-
-#define xfs_biodone(pb) \
- pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
-
-#define xfs_incore(buftarg,blkno,len,lockit) \
- pagebuf_find(buftarg, blkno ,len, lockit)
-
-
-#define xfs_biomove(pb, off, len, data, rw) \
- pagebuf_iomove((pb), (off), (len), (data), \
- ((rw) == XFS_B_WRITE) ? PBRW_WRITE : PBRW_READ)
-
-#define xfs_biozero(pb, off, len) \
- pagebuf_iomove((pb), (off), (len), NULL, PBRW_ZERO)
-
-
-static inline int XFS_bwrite(xfs_buf_t *pb)
-{
- int iowait = (pb->pb_flags & PBF_ASYNC) == 0;
- int error = 0;
-
- if (!iowait)
- pb->pb_flags |= _PBF_RUN_QUEUES;
-
- xfs_buf_undelay(pb);
- pagebuf_iostrategy(pb);
- if (iowait) {
- error = pagebuf_iowait(pb);
- xfs_buf_relse(pb);
- }
- return error;
-}
-
-#define XFS_bdwrite(pb) \
- pagebuf_iostart(pb, PBF_DELWRI | PBF_ASYNC)
-
-static inline int xfs_bdwrite(void *mp, xfs_buf_t *bp)
-{
- bp->pb_strat = xfs_bdstrat_cb;
- bp->pb_fspriv3 = mp;
-
- return pagebuf_iostart(bp, PBF_DELWRI | PBF_ASYNC);
-}
-
-#define XFS_bdstrat(bp) pagebuf_iorequest(bp)
-
-#define xfs_iowait(pb) pagebuf_iowait(pb)
-
-#define xfs_baread(target, rablkno, ralen) \
- pagebuf_readahead((target), (rablkno), (ralen), PBF_DONT_BLOCK)
-
-#define xfs_buf_get_empty(len, target) pagebuf_get_empty((len), (target))
-#define xfs_buf_get_noaddr(len, target) pagebuf_get_no_daddr((len), (target))
-#define xfs_buf_free(bp) pagebuf_free(bp)
-
-
-/*
- * Handling of buftargs.
- */
-
-extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *);
-extern void xfs_free_buftarg(xfs_buftarg_t *, int);
-extern void xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
-extern void xfs_incore_relse(xfs_buftarg_t *, int, int);
-extern int xfs_flush_buftarg(xfs_buftarg_t *, int);
-
-#define xfs_getsize_buftarg(buftarg) \
- block_size((buftarg)->pbr_bdev)
-#define xfs_readonly_buftarg(buftarg) \
- bdev_read_only((buftarg)->pbr_bdev)
-#define xfs_binval(buftarg) \
- xfs_flush_buftarg(buftarg, 1)
-#define XFS_bflush(buftarg) \
- xfs_flush_buftarg(buftarg, 1)
-
-#endif /* __XFS_BUF_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_CRED_H__
-#define __XFS_CRED_H__
-
-/*
- * Credentials
- */
-typedef struct cred {
- /* EMPTY */
-} cred_t;
-
-extern struct cred *sys_cred;
-
-/* this is a hack.. (assums sys_cred is the only cred_t in the system) */
-static __inline int capable_cred(cred_t *cr, int cid)
-{
- return (cr == sys_cred) ? 1 : capable(cid);
-}
-
-#endif /* __XFS_CRED_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_trans.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_alloc.h"
-#include "xfs_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_error.h"
-#include "xfs_rw.h"
-
-#include <linux/dcache.h>
-
-static struct vm_operations_struct linvfs_file_vm_ops;
-
-
-STATIC inline ssize_t
-__linvfs_read(
- struct kiocb *iocb,
- char __user *buf,
- int ioflags,
- size_t count,
- loff_t pos)
-{
- struct iovec iov = {buf, count};
- struct file *file = iocb->ki_filp;
- vnode_t *vp = LINVFS_GET_VP(file->f_dentry->d_inode);
- ssize_t rval;
-
- BUG_ON(iocb->ki_pos != pos);
-
- if (unlikely(file->f_flags & O_DIRECT))
- ioflags |= IO_ISDIRECT;
- VOP_READ(vp, iocb, &iov, 1, &iocb->ki_pos, ioflags, NULL, rval);
- return rval;
-}
-
-
-STATIC ssize_t
-linvfs_read(
- struct kiocb *iocb,
- char __user *buf,
- size_t count,
- loff_t pos)
-{
- return __linvfs_read(iocb, buf, 0, count, pos);
-}
-
-STATIC ssize_t
-linvfs_read_invis(
- struct kiocb *iocb,
- char __user *buf,
- size_t count,
- loff_t pos)
-{
- return __linvfs_read(iocb, buf, IO_INVIS, count, pos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_write(
- struct kiocb *iocb,
- const char *buf,
- int ioflags,
- size_t count,
- loff_t pos)
-{
- struct iovec iov = {(void *)buf, count};
- struct file *file = iocb->ki_filp;
- struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- ssize_t rval;
-
- BUG_ON(iocb->ki_pos != pos);
- if (unlikely(file->f_flags & O_DIRECT)) {
- ioflags |= IO_ISDIRECT;
- VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
- ioflags, NULL, rval);
- } else {
- down(&inode->i_sem);
- VOP_WRITE(vp, iocb, &iov, 1, &iocb->ki_pos,
- ioflags, NULL, rval);
- up(&inode->i_sem);
- }
-
- return rval;
-}
-
-
-STATIC ssize_t
-linvfs_write(
- struct kiocb *iocb,
- const char __user *buf,
- size_t count,
- loff_t pos)
-{
- return __linvfs_write(iocb, buf, 0, count, pos);
-}
-
-STATIC ssize_t
-linvfs_write_invis(
- struct kiocb *iocb,
- const char __user *buf,
- size_t count,
- loff_t pos)
-{
- return __linvfs_write(iocb, buf, IO_INVIS, count, pos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_readv(
- struct file *file,
- const struct iovec *iov,
- int ioflags,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- struct kiocb kiocb;
- ssize_t rval;
-
- init_sync_kiocb(&kiocb, file);
- kiocb.ki_pos = *ppos;
-
- if (unlikely(file->f_flags & O_DIRECT))
- ioflags |= IO_ISDIRECT;
- VOP_READ(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos, ioflags, NULL, rval);
- if (rval == -EIOCBQUEUED)
- rval = wait_on_sync_kiocb(&kiocb);
-
- *ppos = kiocb.ki_pos;
- return rval;
-}
-
-STATIC ssize_t
-linvfs_readv(
- struct file *file,
- const struct iovec *iov,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- return __linvfs_readv(file, iov, 0, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_readv_invis(
- struct file *file,
- const struct iovec *iov,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos);
-}
-
-
-STATIC inline ssize_t
-__linvfs_writev(
- struct file *file,
- const struct iovec *iov,
- int ioflags,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- struct kiocb kiocb;
- ssize_t rval;
-
- init_sync_kiocb(&kiocb, file);
- kiocb.ki_pos = *ppos;
- if (unlikely(file->f_flags & O_DIRECT)) {
- ioflags |= IO_ISDIRECT;
- VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
- ioflags, NULL, rval);
- } else {
- down(&inode->i_sem);
- VOP_WRITE(vp, &kiocb, iov, nr_segs, &kiocb.ki_pos,
- ioflags, NULL, rval);
- up(&inode->i_sem);
- }
-
- if (rval == -EIOCBQUEUED)
- rval = wait_on_sync_kiocb(&kiocb);
-
- *ppos = kiocb.ki_pos;
- return rval;
-}
-
-
-STATIC ssize_t
-linvfs_writev(
- struct file *file,
- const struct iovec *iov,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- return __linvfs_writev(file, iov, 0, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_writev_invis(
- struct file *file,
- const struct iovec *iov,
- unsigned long nr_segs,
- loff_t *ppos)
-{
- return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos);
-}
-
-STATIC ssize_t
-linvfs_sendfile(
- struct file *filp,
- loff_t *ppos,
- size_t count,
- read_actor_t actor,
- void *target)
-{
- vnode_t *vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
- int error;
-
- VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, error);
- return error;
-}
-
-
-STATIC int
-linvfs_open(
- struct inode *inode,
- struct file *filp)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error;
-
- if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
- return -EFBIG;
-
- ASSERT(vp);
- VOP_OPEN(vp, NULL, error);
- return -error;
-}
-
-
-STATIC int
-linvfs_release(
- struct inode *inode,
- struct file *filp)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error = 0;
-
- if (vp)
- VOP_RELEASE(vp, error);
- return -error;
-}
-
-
-STATIC int
-linvfs_fsync(
- struct file *filp,
- struct dentry *dentry,
- int datasync)
-{
- struct inode *inode = dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error;
- int flags = FSYNC_WAIT;
-
- if (datasync)
- flags |= FSYNC_DATA;
-
- ASSERT(vp);
- VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
- return -error;
-}
-
-/*
- * linvfs_readdir maps to VOP_READDIR().
- * We need to build a uio, cred, ...
- */
-
-#define nextdp(dp) ((struct xfs_dirent *)((char *)(dp) + (dp)->d_reclen))
-
-STATIC int
-linvfs_readdir(
- struct file *filp,
- void *dirent,
- filldir_t filldir)
-{
- int error = 0;
- vnode_t *vp;
- uio_t uio;
- iovec_t iov;
- int eof = 0;
- caddr_t read_buf;
- int namelen, size = 0;
- size_t rlen = PAGE_CACHE_SIZE;
- xfs_off_t start_offset, curr_offset;
- xfs_dirent_t *dbp = NULL;
-
- vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
- ASSERT(vp);
-
- /* Try fairly hard to get memory */
- do {
- if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL)))
- break;
- rlen >>= 1;
- } while (rlen >= 1024);
-
- if (read_buf == NULL)
- return -ENOMEM;
-
- uio.uio_iov = &iov;
- uio.uio_segflg = UIO_SYSSPACE;
- curr_offset = filp->f_pos;
- if (filp->f_pos != 0x7fffffff)
- uio.uio_offset = filp->f_pos;
- else
- uio.uio_offset = 0xffffffff;
-
- while (!eof) {
- uio.uio_resid = iov.iov_len = rlen;
- iov.iov_base = read_buf;
- uio.uio_iovcnt = 1;
-
- start_offset = uio.uio_offset;
-
- VOP_READDIR(vp, &uio, NULL, &eof, error);
- if ((uio.uio_offset == start_offset) || error) {
- size = 0;
- break;
- }
-
- size = rlen - uio.uio_resid;
- dbp = (xfs_dirent_t *)read_buf;
- while (size > 0) {
- namelen = strlen(dbp->d_name);
-
- if (filldir(dirent, dbp->d_name, namelen,
- (loff_t) curr_offset & 0x7fffffff,
- (ino_t) dbp->d_ino,
- DT_UNKNOWN)) {
- goto done;
- }
- size -= dbp->d_reclen;
- curr_offset = (loff_t)dbp->d_off /* & 0x7fffffff */;
- dbp = nextdp(dbp);
- }
- }
-done:
- if (!error) {
- if (size == 0)
- filp->f_pos = uio.uio_offset & 0x7fffffff;
- else if (dbp)
- filp->f_pos = curr_offset;
- }
-
- kfree(read_buf);
- return -error;
-}
-
-
-STATIC int
-linvfs_file_mmap(
- struct file *filp,
- struct vm_area_struct *vma)
-{
- struct inode *ip = filp->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(ip);
- vattr_t va = { .va_mask = XFS_AT_UPDATIME };
- int error;
-
- if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
- xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
-
- error = -XFS_SEND_MMAP(mp, vma, 0);
- if (error)
- return error;
- }
-
- vma->vm_ops = &linvfs_file_vm_ops;
-
- VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
- return 0;
-}
-
-
-STATIC int
-linvfs_ioctl(
- struct inode *inode,
- struct file *filp,
- unsigned int cmd,
- unsigned long arg)
-{
- int error;
- vnode_t *vp = LINVFS_GET_VP(inode);
-
- ASSERT(vp);
- VOP_IOCTL(vp, inode, filp, 0, cmd, arg, error);
- VMODIFY(vp);
-
- /* NOTE: some of the ioctl's return positive #'s as a
- * byte count indicating success, such as
- * readlink_by_handle. So we don't "sign flip"
- * like most other routines. This means true
- * errors need to be returned as a negative value.
- */
- return error;
-}
-
-STATIC int
-linvfs_ioctl_invis(
- struct inode *inode,
- struct file *filp,
- unsigned int cmd,
- unsigned long arg)
-{
- int error;
- vnode_t *vp = LINVFS_GET_VP(inode);
-
- ASSERT(vp);
- VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, arg, error);
- VMODIFY(vp);
-
- /* NOTE: some of the ioctl's return positive #'s as a
- * byte count indicating success, such as
- * readlink_by_handle. So we don't "sign flip"
- * like most other routines. This means true
- * errors need to be returned as a negative value.
- */
- return error;
-}
-
-#ifdef HAVE_VMOP_MPROTECT
-STATIC int
-linvfs_mprotect(
- struct vm_area_struct *vma,
- unsigned int newflags)
-{
- vnode_t *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
- int error = 0;
-
- if ((vp->v_type == VREG) && (vp->v_vfsp->vfs_flag & VFS_DMI)) {
- if ((vma->vm_flags & VM_MAYSHARE) &&
- (newflags & VM_WRITE) && !(vma->vm_flags & VM_WRITE)) {
- xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
-
- error = XFS_SEND_MMAP(mp, vma, VM_WRITE);
- }
- }
- return error;
-}
-#endif /* HAVE_VMOP_MPROTECT */
-
-
-struct file_operations linvfs_file_operations = {
- .llseek = generic_file_llseek,
- .read = do_sync_read,
- .write = do_sync_write,
- .readv = linvfs_readv,
- .writev = linvfs_writev,
- .aio_read = linvfs_read,
- .aio_write = linvfs_write,
- .sendfile = linvfs_sendfile,
- .ioctl = linvfs_ioctl,
- .mmap = linvfs_file_mmap,
- .open = linvfs_open,
- .release = linvfs_release,
- .fsync = linvfs_fsync,
-};
-
-struct file_operations linvfs_invis_file_operations = {
- .llseek = generic_file_llseek,
- .read = do_sync_read,
- .write = do_sync_write,
- .readv = linvfs_readv_invis,
- .writev = linvfs_writev_invis,
- .aio_read = linvfs_read_invis,
- .aio_write = linvfs_write_invis,
- .sendfile = linvfs_sendfile,
- .ioctl = linvfs_ioctl_invis,
- .mmap = linvfs_file_mmap,
- .open = linvfs_open,
- .release = linvfs_release,
- .fsync = linvfs_fsync,
-};
-
-
-struct file_operations linvfs_dir_operations = {
- .read = generic_read_dir,
- .readdir = linvfs_readdir,
- .ioctl = linvfs_ioctl,
- .fsync = linvfs_fsync,
-};
-
-static struct vm_operations_struct linvfs_file_vm_ops = {
- .nopage = filemap_nopage,
-#ifdef HAVE_VMOP_MPROTECT
- .mprotect = linvfs_mprotect,
-#endif
-};
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-/*
- * Stub for no-op vnode operations that return error status.
- */
-int
-fs_noerr()
-{
- return 0;
-}
-
-/*
- * Operation unsupported under this file system.
- */
-int
-fs_nosys()
-{
- return ENOSYS;
-}
-
-/*
- * Stub for inactive, strategy, and read/write lock/unlock. Does nothing.
- */
-/* ARGSUSED */
-void
-fs_noval()
-{
-}
-
-/*
- * vnode pcache layer for vnode_tosspages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-void
-fs_tosspages(
- bhv_desc_t *bdp,
- xfs_off_t first,
- xfs_off_t last,
- int fiopt)
-{
- vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
-
- if (VN_CACHED(vp))
- truncate_inode_pages(ip->i_mapping, first);
-}
-
-
-/*
- * vnode pcache layer for vnode_flushinval_pages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-void
-fs_flushinval_pages(
- bhv_desc_t *bdp,
- xfs_off_t first,
- xfs_off_t last,
- int fiopt)
-{
- vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
-
- if (VN_CACHED(vp)) {
- filemap_fdatawrite(ip->i_mapping);
- filemap_fdatawait(ip->i_mapping);
-
- truncate_inode_pages(ip->i_mapping, first);
- }
-}
-
-/*
- * vnode pcache layer for vnode_flush_pages.
- * 'last' parameter unused but left in for IRIX compatibility
- */
-int
-fs_flush_pages(
- bhv_desc_t *bdp,
- xfs_off_t first,
- xfs_off_t last,
- uint64_t flags,
- int fiopt)
-{
- vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
-
- if (VN_CACHED(vp)) {
- filemap_fdatawrite(ip->i_mapping);
- filemap_fdatawait(ip->i_mapping);
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUBR_H__
-#define __XFS_SUBR_H__
-
-/*
- * Utilities shared among file system implementations.
- */
-
-struct cred;
-
-extern int fs_noerr(void);
-extern int fs_nosys(void);
-extern int fs_nodev(void);
-extern void fs_noval(void);
-extern void fs_tosspages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern void fs_flushinval_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-extern int fs_flush_pages(bhv_desc_t *, xfs_off_t, xfs_off_t, uint64_t, int);
-
-#endif /* __XFS_FS_SUBR_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * This file contains globals needed by XFS that were normally defined
- * somewhere else in IRIX.
- */
-
-#include "xfs.h"
-#include "xfs_cred.h"
-#include "xfs_sysctl.h"
-
-/*
- * System memory size - used to scale certain data structures in XFS.
- */
-unsigned long xfs_physmem;
-
-/*
- * Tunable XFS parameters. xfs_params is required even when CONFIG_SYSCTL=n,
- * other XFS code uses these values.
- */
-
-xfs_param_t xfs_params = {
- /* MIN DFLT MAX */
- .restrict_chown = { 0, 1, 1 },
- .sgid_inherit = { 0, 0, 1 },
- .symlink_mode = { 0, 0, 1 },
- .panic_mask = { 0, 0, 127 },
- .error_level = { 0, 3, 11 },
- .sync_interval = { USER_HZ, 30*USER_HZ, 7200*USER_HZ },
- .stats_clear = { 0, 0, 1 },
- .inherit_sync = { 0, 1, 1 },
- .inherit_nodump = { 0, 1, 1 },
- .inherit_noatim = { 0, 1, 1 },
- .flush_interval = { USER_HZ/2, USER_HZ, 30*USER_HZ },
- .age_buffer = { 1*USER_HZ, 15*USER_HZ, 7200*USER_HZ },
-};
-
-/*
- * Global system credential structure.
- */
-cred_t sys_cred_val, *sys_cred = &sys_cred_val;
-
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_GLOBALS_H__
-#define __XFS_GLOBALS_H__
-
-/*
- * This file declares globals needed by XFS that were normally defined
- * somewhere else in IRIX.
- */
-
-extern uint64_t xfs_panic_mask; /* set to cause more panics */
-extern unsigned long xfs_physmem;
-extern struct cred *sys_cred;
-
-#endif /* __XFS_GLOBALS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_dfrag.h"
-#include "xfs_fsops.h"
-
-#include <linux/dcache.h>
-#include <linux/mount.h>
-#include <linux/namei.h>
-#include <linux/pagemap.h>
-
-/*
- * ioctl commands that are used by Linux filesystems
- */
-#define XFS_IOC_GETXFLAGS _IOR('f', 1, long)
-#define XFS_IOC_SETXFLAGS _IOW('f', 2, long)
-#define XFS_IOC_GETVERSION _IOR('v', 1, long)
-
-
-/*
- * xfs_find_handle maps from userspace xfs_fsop_handlereq structure to
- * a file or fs handle.
- *
- * XFS_IOC_PATH_TO_FSHANDLE
- * returns fs handle for a mount point or path within that mount point
- * XFS_IOC_FD_TO_HANDLE
- * returns full handle for a FD opened in user space
- * XFS_IOC_PATH_TO_HANDLE
- * returns full handle for a path
- */
-STATIC int
-xfs_find_handle(
- unsigned int cmd,
- unsigned long arg)
-{
- int hsize;
- xfs_handle_t handle;
- xfs_fsop_handlereq_t hreq;
- struct inode *inode;
- struct vnode *vp;
-
- if (copy_from_user(&hreq, (xfs_fsop_handlereq_t *)arg, sizeof(hreq)))
- return -XFS_ERROR(EFAULT);
-
- memset((char *)&handle, 0, sizeof(handle));
-
- switch (cmd) {
- case XFS_IOC_PATH_TO_FSHANDLE:
- case XFS_IOC_PATH_TO_HANDLE: {
- struct nameidata nd;
- int error;
-
- error = user_path_walk_link(hreq.path, &nd);
- if (error)
- return error;
-
- ASSERT(nd.dentry);
- ASSERT(nd.dentry->d_inode);
- inode = igrab(nd.dentry->d_inode);
- path_release(&nd);
- break;
- }
-
- case XFS_IOC_FD_TO_HANDLE: {
- struct file *file;
-
- file = fget(hreq.fd);
- if (!file)
- return -EBADF;
-
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_inode);
- inode = igrab(file->f_dentry->d_inode);
- fput(file);
- break;
- }
-
- default:
- ASSERT(0);
- return -XFS_ERROR(EINVAL);
- }
-
- if (inode->i_sb->s_magic != XFS_SB_MAGIC) {
- /* we're not in XFS anymore, Toto */
- iput(inode);
- return -XFS_ERROR(EINVAL);
- }
-
- /* we need the vnode */
- vp = LINVFS_GET_VP(inode);
- if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
- iput(inode);
- return -XFS_ERROR(EBADF);
- }
-
- /* now we can grab the fsid */
- memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
- hsize = sizeof(xfs_fsid_t);
-
- if (cmd != XFS_IOC_PATH_TO_FSHANDLE) {
- xfs_inode_t *ip;
- bhv_desc_t *bhv;
- int lock_mode;
-
- /* need to get access to the xfs_inode to read the generation */
- bhv = vn_bhv_lookup_unlocked(VN_BHV_HEAD(vp), &xfs_vnodeops);
- ASSERT(bhv);
- ip = XFS_BHVTOI(bhv);
- ASSERT(ip);
- lock_mode = xfs_ilock_map_shared(ip);
-
- /* fill in fid section of handle from inode */
- handle.ha_fid.xfs_fid_len = sizeof(xfs_fid_t) -
- sizeof(handle.ha_fid.xfs_fid_len);
- handle.ha_fid.xfs_fid_pad = 0;
- handle.ha_fid.xfs_fid_gen = ip->i_d.di_gen;
- handle.ha_fid.xfs_fid_ino = ip->i_ino;
-
- xfs_iunlock_map_shared(ip, lock_mode);
-
- hsize = XFS_HSIZE(handle);
- }
-
- /* now copy our handle into the user buffer & write out the size */
- if (copy_to_user((xfs_handle_t *)hreq.ohandle, &handle, hsize) ||
- copy_to_user(hreq.ohandlen, &hsize, sizeof(__s32))) {
- iput(inode);
- return -XFS_ERROR(EFAULT);
- }
-
- iput(inode);
- return 0;
-}
-
-
-/*
- * Convert userspace handle data into vnode (and inode).
- * We [ab]use the fact that all the fsop_handlereq ioctl calls
- * have a data structure argument whose first component is always
- * a xfs_fsop_handlereq_t, so we can cast to and from this type.
- * This allows us to optimise the copy_from_user calls and gives
- * a handy, shared routine.
- *
- * If no error, caller must always VN_RELE the returned vp.
- */
-STATIC int
-xfs_vget_fsop_handlereq(
- xfs_mount_t *mp,
- struct inode *parinode, /* parent inode pointer */
- int cap, /* capability level for op */
- unsigned long arg, /* userspace data pointer */
- unsigned long size, /* size of expected struct */
- /* output arguments */
- xfs_fsop_handlereq_t *hreq,
- vnode_t **vp,
- struct inode **inode)
-{
- void *hanp;
- size_t hlen;
- xfs_fid_t *xfid;
- xfs_handle_t *handlep;
- xfs_handle_t handle;
- xfs_inode_t *ip;
- struct inode *inodep;
- vnode_t *vpp;
- xfs_ino_t ino;
- __u32 igen;
- int error;
-
- if (!capable(cap))
- return XFS_ERROR(EPERM);
-
- /*
- * Only allow handle opens under a directory.
- */
- if (!S_ISDIR(parinode->i_mode))
- return XFS_ERROR(ENOTDIR);
-
- /*
- * Copy the handle down from the user and validate
- * that it looks to be in the correct format.
- */
- if (copy_from_user(hreq, (struct xfs_fsop_handlereq *)arg, size))
- return XFS_ERROR(EFAULT);
-
- hanp = hreq->ihandle;
- hlen = hreq->ihandlen;
- handlep = &handle;
-
- if (hlen < sizeof(handlep->ha_fsid) || hlen > sizeof(*handlep))
- return XFS_ERROR(EINVAL);
- if (copy_from_user(handlep, hanp, hlen))
- return XFS_ERROR(EFAULT);
- if (hlen < sizeof(*handlep))
- memset(((char *)handlep) + hlen, 0, sizeof(*handlep) - hlen);
- if (hlen > sizeof(handlep->ha_fsid)) {
- if (handlep->ha_fid.xfs_fid_len !=
- (hlen - sizeof(handlep->ha_fsid)
- - sizeof(handlep->ha_fid.xfs_fid_len))
- || handlep->ha_fid.xfs_fid_pad)
- return XFS_ERROR(EINVAL);
- }
-
- /*
- * Crack the handle, obtain the inode # & generation #
- */
- xfid = (struct xfs_fid *)&handlep->ha_fid;
- if (xfid->xfs_fid_len == sizeof(*xfid) - sizeof(xfid->xfs_fid_len)) {
- ino = xfid->xfs_fid_ino;
- igen = xfid->xfs_fid_gen;
- } else {
- return XFS_ERROR(EINVAL);
- }
-
- /*
- * Get the XFS inode, building a vnode to go with it.
- */
- error = xfs_iget(mp, NULL, ino, XFS_ILOCK_SHARED, &ip, 0);
- if (error)
- return error;
- if (ip == NULL)
- return XFS_ERROR(EIO);
- if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) {
- xfs_iput_new(ip, XFS_ILOCK_SHARED);
- return XFS_ERROR(ENOENT);
- }
-
- vpp = XFS_ITOV(ip);
- inodep = LINVFS_GET_IP(vpp);
- xfs_iunlock(ip, XFS_ILOCK_SHARED);
-
- *vp = vpp;
- *inode = inodep;
- return 0;
-}
-
-STATIC int
-xfs_open_by_handle(
- xfs_mount_t *mp,
- unsigned long arg,
- struct file *parfilp,
- struct inode *parinode)
-{
- int error;
- int new_fd;
- int permflag;
- struct file *filp;
- struct inode *inode;
- struct dentry *dentry;
- vnode_t *vp;
- xfs_fsop_handlereq_t hreq;
-
- error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
- sizeof(xfs_fsop_handlereq_t),
- &hreq, &vp, &inode);
- if (error)
- return -error;
-
- /* Restrict xfs_open_by_handle to directories & regular files. */
- if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) {
- iput(inode);
- return -XFS_ERROR(EINVAL);
- }
-
-#if BITS_PER_LONG != 32
- hreq.oflags |= O_LARGEFILE;
-#endif
- /* Put open permission in namei format. */
- permflag = hreq.oflags;
- if ((permflag+1) & O_ACCMODE)
- permflag++;
- if (permflag & O_TRUNC)
- permflag |= 2;
-
- if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
- (permflag & FMODE_WRITE) && IS_APPEND(inode)) {
- iput(inode);
- return -XFS_ERROR(EPERM);
- }
-
- if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
- iput(inode);
- return -XFS_ERROR(EACCES);
- }
-
- /* Can't write directories. */
- if ( S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) {
- iput(inode);
- return -XFS_ERROR(EISDIR);
- }
-
- if ((new_fd = get_unused_fd()) < 0) {
- iput(inode);
- return new_fd;
- }
-
- dentry = d_alloc_anon(inode);
- if (dentry == NULL) {
- iput(inode);
- put_unused_fd(new_fd);
- return -XFS_ERROR(ENOMEM);
- }
-
- /* Ensure umount returns EBUSY on umounts while this file is open. */
- mntget(parfilp->f_vfsmnt);
-
- /* Create file pointer. */
- filp = dentry_open(dentry, parfilp->f_vfsmnt, hreq.oflags);
- if (IS_ERR(filp)) {
- put_unused_fd(new_fd);
- return -XFS_ERROR(-PTR_ERR(filp));
- }
- if (inode->i_mode & S_IFREG)
- filp->f_op = &linvfs_invis_file_operations;
-
- fd_install(new_fd, filp);
- return new_fd;
-}
-
-STATIC int
-xfs_readlink_by_handle(
- xfs_mount_t *mp,
- unsigned long arg,
- struct file *parfilp,
- struct inode *parinode)
-{
- int error;
- struct iovec aiov;
- struct uio auio;
- struct inode *inode;
- xfs_fsop_handlereq_t hreq;
- vnode_t *vp;
- __u32 olen;
-
- error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
- sizeof(xfs_fsop_handlereq_t),
- &hreq, &vp, &inode);
- if (error)
- return -error;
-
- /* Restrict this handle operation to symlinks only. */
- if (vp->v_type != VLNK) {
- VN_RELE(vp);
- return -XFS_ERROR(EINVAL);
- }
-
- if (copy_from_user(&olen, hreq.ohandlen, sizeof(__u32))) {
- VN_RELE(vp);
- return -XFS_ERROR(EFAULT);
- }
- aiov.iov_len = olen;
- aiov.iov_base = hreq.ohandle;
-
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_resid = olen;
-
- VOP_READLINK(vp, &auio, IO_INVIS, NULL, error);
-
- VN_RELE(vp);
- return (olen - auio.uio_resid);
-}
-
-STATIC int
-xfs_fssetdm_by_handle(
- xfs_mount_t *mp,
- unsigned long arg,
- struct file *parfilp,
- struct inode *parinode)
-{
- int error;
- struct fsdmidata fsd;
- xfs_fsop_setdm_handlereq_t dmhreq;
- struct inode *inode;
- bhv_desc_t *bdp;
- vnode_t *vp;
-
- error = xfs_vget_fsop_handlereq(mp, parinode, CAP_MKNOD, arg,
- sizeof(xfs_fsop_setdm_handlereq_t),
- (xfs_fsop_handlereq_t *)&dmhreq,
- &vp, &inode);
- if (error)
- return -error;
-
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- VN_RELE(vp);
- return -XFS_ERROR(EPERM);
- }
-
- if (copy_from_user(&fsd, dmhreq.data, sizeof(fsd))) {
- VN_RELE(vp);
- return -XFS_ERROR(EFAULT);
- }
-
- bdp = bhv_base_unlocked(VN_BHV_HEAD(vp));
- error = xfs_set_dmattrs(bdp, fsd.fsd_dmevmask, fsd.fsd_dmstate, NULL);
-
- VN_RELE(vp);
- if (error)
- return -error;
- return 0;
-}
-
-STATIC int
-xfs_attrlist_by_handle(
- xfs_mount_t *mp,
- unsigned long arg,
- struct file *parfilp,
- struct inode *parinode)
-{
- int error;
- attrlist_cursor_kern_t *cursor;
- xfs_fsop_attrlist_handlereq_t al_hreq;
- struct inode *inode;
- vnode_t *vp;
-
- error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
- sizeof(xfs_fsop_attrlist_handlereq_t),
- (xfs_fsop_handlereq_t *)&al_hreq,
- &vp, &inode);
- if (error)
- return -error;
-
- cursor = (attrlist_cursor_kern_t *)&al_hreq.pos;
- VOP_ATTR_LIST(vp, al_hreq.buffer, al_hreq.buflen, al_hreq.flags,
- cursor, NULL, error);
- VN_RELE(vp);
- if (error)
- return -error;
- return 0;
-}
-
-STATIC int
-xfs_attrmulti_by_handle(
- xfs_mount_t *mp,
- unsigned long arg,
- struct file *parfilp,
- struct inode *parinode)
-{
- int error;
- xfs_attr_multiop_t *ops;
- xfs_fsop_attrmulti_handlereq_t am_hreq;
- struct inode *inode;
- vnode_t *vp;
- int i, size;
-
- error = xfs_vget_fsop_handlereq(mp, parinode, CAP_SYS_ADMIN, arg,
- sizeof(xfs_fsop_attrmulti_handlereq_t),
- (xfs_fsop_handlereq_t *)&am_hreq,
- &vp, &inode);
- if (error)
- return -error;
-
- size = am_hreq.opcount * sizeof(attr_multiop_t);
- ops = (xfs_attr_multiop_t *)kmalloc(size, GFP_KERNEL);
- if (!ops) {
- VN_RELE(vp);
- return -XFS_ERROR(ENOMEM);
- }
-
- if (copy_from_user(ops, am_hreq.ops, size)) {
- kfree(ops);
- VN_RELE(vp);
- return -XFS_ERROR(EFAULT);
- }
-
- for (i = 0; i < am_hreq.opcount; i++) {
- switch(ops[i].am_opcode) {
- case ATTR_OP_GET:
- VOP_ATTR_GET(vp,ops[i].am_attrname, ops[i].am_attrvalue,
- &ops[i].am_length, ops[i].am_flags,
- NULL, ops[i].am_error);
- break;
- case ATTR_OP_SET:
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- ops[i].am_error = EPERM;
- break;
- }
- VOP_ATTR_SET(vp,ops[i].am_attrname, ops[i].am_attrvalue,
- ops[i].am_length, ops[i].am_flags,
- NULL, ops[i].am_error);
- break;
- case ATTR_OP_REMOVE:
- if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) {
- ops[i].am_error = EPERM;
- break;
- }
- VOP_ATTR_REMOVE(vp, ops[i].am_attrname, ops[i].am_flags,
- NULL, ops[i].am_error);
- break;
- default:
- ops[i].am_error = EINVAL;
- }
- }
-
- if (copy_to_user(am_hreq.ops, ops, size))
- error = -XFS_ERROR(EFAULT);
-
- kfree(ops);
- VN_RELE(vp);
- return error;
-}
-
-/* prototypes for a few of the stack-hungry cases that have
- * their own functions. Functions are defined after their use
- * so gcc doesn't get fancy and inline them with -03 */
-
-STATIC int
-xfs_ioc_space(
- bhv_desc_t *bdp,
- vnode_t *vp,
- struct file *filp,
- int flags,
- unsigned int cmd,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_bulkstat(
- xfs_mount_t *mp,
- unsigned int cmd,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_fsgeometry_v1(
- xfs_mount_t *mp,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_fsgeometry(
- xfs_mount_t *mp,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_xattr(
- vnode_t *vp,
- xfs_inode_t *ip,
- struct file *filp,
- unsigned int cmd,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_getbmap(
- bhv_desc_t *bdp,
- struct file *filp,
- int flags,
- unsigned int cmd,
- unsigned long arg);
-
-STATIC int
-xfs_ioc_getbmapx(
- bhv_desc_t *bdp,
- unsigned long arg);
-
-int
-xfs_ioctl(
- bhv_desc_t *bdp,
- struct inode *inode,
- struct file *filp,
- int ioflags,
- unsigned int cmd,
- unsigned long arg)
-{
- int error;
- vnode_t *vp;
- xfs_inode_t *ip;
- xfs_mount_t *mp;
-
- vp = LINVFS_GET_VP(inode);
-
- vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
-
- ip = XFS_BHVTOI(bdp);
- mp = ip->i_mount;
-
- switch (cmd) {
-
- case XFS_IOC_ALLOCSP:
- case XFS_IOC_FREESP:
- case XFS_IOC_RESVSP:
- case XFS_IOC_UNRESVSP:
- case XFS_IOC_ALLOCSP64:
- case XFS_IOC_FREESP64:
- case XFS_IOC_RESVSP64:
- case XFS_IOC_UNRESVSP64:
- /*
- * Only allow the sys admin to reserve space unless
- * unwritten extents are enabled.
- */
- if (!XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) &&
- !capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- return xfs_ioc_space(bdp, vp, filp, ioflags, cmd, arg);
-
- case XFS_IOC_DIOINFO: {
- struct dioattr da;
- xfs_buftarg_t *target =
- (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
- mp->m_rtdev_targp : mp->m_ddev_targp;
-
- da.d_mem = da.d_miniosz = 1 << target->pbr_sshift;
- /* The size dio will do in one go */
- da.d_maxiosz = 64 * PAGE_CACHE_SIZE;
-
- if (copy_to_user((struct dioattr *)arg, &da, sizeof(da)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_FSBULKSTAT_SINGLE:
- case XFS_IOC_FSBULKSTAT:
- case XFS_IOC_FSINUMBERS:
- return xfs_ioc_bulkstat(mp, cmd, arg);
-
- case XFS_IOC_FSGEOMETRY_V1:
- return xfs_ioc_fsgeometry_v1(mp, arg);
-
- case XFS_IOC_FSGEOMETRY:
- return xfs_ioc_fsgeometry(mp, arg);
-
- case XFS_IOC_GETVERSION:
- case XFS_IOC_GETXFLAGS:
- case XFS_IOC_SETXFLAGS:
- case XFS_IOC_FSGETXATTR:
- case XFS_IOC_FSSETXATTR:
- case XFS_IOC_FSGETXATTRA:
- return xfs_ioc_xattr(vp, ip, filp, cmd, arg);
-
- case XFS_IOC_FSSETDM: {
- struct fsdmidata dmi;
-
- if (copy_from_user(&dmi, (struct fsdmidata *)arg, sizeof(dmi)))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_set_dmattrs(bdp, dmi.fsd_dmevmask, dmi.fsd_dmstate,
- NULL);
- return -error;
- }
-
- case XFS_IOC_GETBMAP:
- case XFS_IOC_GETBMAPA:
- return xfs_ioc_getbmap(bdp, filp, ioflags, cmd, arg);
-
- case XFS_IOC_GETBMAPX:
- return xfs_ioc_getbmapx(bdp, arg);
-
- case XFS_IOC_FD_TO_HANDLE:
- case XFS_IOC_PATH_TO_HANDLE:
- case XFS_IOC_PATH_TO_FSHANDLE:
- return xfs_find_handle(cmd, arg);
-
- case XFS_IOC_OPEN_BY_HANDLE:
- return xfs_open_by_handle(mp, arg, filp, inode);
-
- case XFS_IOC_FSSETDM_BY_HANDLE:
- return xfs_fssetdm_by_handle(mp, arg, filp, inode);
-
- case XFS_IOC_READLINK_BY_HANDLE:
- return xfs_readlink_by_handle(mp, arg, filp, inode);
-
- case XFS_IOC_ATTRLIST_BY_HANDLE:
- return xfs_attrlist_by_handle(mp, arg, filp, inode);
-
- case XFS_IOC_ATTRMULTI_BY_HANDLE:
- return xfs_attrmulti_by_handle(mp, arg, filp, inode);
-
- case XFS_IOC_SWAPEXT: {
- error = xfs_swapext((struct xfs_swapext *)arg);
- return -error;
- }
-
- case XFS_IOC_FSCOUNTS: {
- xfs_fsop_counts_t out;
-
- error = xfs_fs_counts(mp, &out);
- if (error)
- return -error;
-
- if (copy_to_user((char *)arg, &out, sizeof(out)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_SET_RESBLKS: {
- xfs_fsop_resblks_t inout;
- __uint64_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&inout, (char *)arg, sizeof(inout)))
- return -XFS_ERROR(EFAULT);
-
- /* input parameter is passed in resblks field of structure */
- in = inout.resblks;
- error = xfs_reserve_blocks(mp, &in, &inout);
- if (error)
- return -error;
-
- if (copy_to_user((char *)arg, &inout, sizeof(inout)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_GET_RESBLKS: {
- xfs_fsop_resblks_t out;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- error = xfs_reserve_blocks(mp, NULL, &out);
- if (error)
- return -error;
-
- if (copy_to_user((char *)arg, &out, sizeof(out)))
- return -XFS_ERROR(EFAULT);
-
- return 0;
- }
-
- case XFS_IOC_FSGROWFSDATA: {
- xfs_growfs_data_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_growfs_data(mp, &in);
- return -error;
- }
-
- case XFS_IOC_FSGROWFSLOG: {
- xfs_growfs_log_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_growfs_log(mp, &in);
- return -error;
- }
-
- case XFS_IOC_FSGROWFSRT: {
- xfs_growfs_rt_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_growfs_rt(mp, &in);
- return -error;
- }
-
- case XFS_IOC_FREEZE:
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- freeze_bdev(inode->i_sb->s_bdev);
- return 0;
-
- case XFS_IOC_THAW:
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
- thaw_bdev(inode->i_sb->s_bdev, inode->i_sb);
- return 0;
-
- case XFS_IOC_GOINGDOWN: {
- __uint32_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (get_user(in, (__uint32_t *)arg))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_fs_goingdown(mp, in);
- return -error;
- }
-
- case XFS_IOC_ERROR_INJECTION: {
- xfs_error_injection_t in;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (copy_from_user(&in, (char *)arg, sizeof(in)))
- return -XFS_ERROR(EFAULT);
-
- error = xfs_errortag_add(in.errtag, mp);
- return -error;
- }
-
- case XFS_IOC_ERROR_CLEARALL:
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- error = xfs_errortag_clearall(mp);
- return -error;
-
- default:
- return -ENOTTY;
- }
-}
-
-STATIC int
-xfs_ioc_space(
- bhv_desc_t *bdp,
- vnode_t *vp,
- struct file *filp,
- int ioflags,
- unsigned int cmd,
- unsigned long arg)
-{
- xfs_flock64_t bf;
- int attr_flags = 0;
- int error;
-
- if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
- return -XFS_ERROR(EPERM);
-
- if (!(filp->f_flags & FMODE_WRITE))
- return -XFS_ERROR(EBADF);
-
- if (vp->v_type != VREG)
- return -XFS_ERROR(EINVAL);
-
- if (copy_from_user(&bf, (xfs_flock64_t *)arg, sizeof(bf)))
- return -XFS_ERROR(EFAULT);
-
- if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
- attr_flags |= ATTR_NONBLOCK;
- if (ioflags & IO_INVIS)
- attr_flags |= ATTR_DMI;
-
- error = xfs_change_file_space(bdp, cmd, &bf, filp->f_pos,
- NULL, attr_flags);
- return -error;
-}
-
-STATIC int
-xfs_ioc_bulkstat(
- xfs_mount_t *mp,
- unsigned int cmd,
- unsigned long arg)
-{
- xfs_fsop_bulkreq_t bulkreq;
- int count; /* # of records returned */
- xfs_ino_t inlast; /* last inode number */
- int done;
- int error;
-
- /* done = 1 if there are more stats to get and if bulkstat */
- /* should be called again (unused here, but used in dmapi) */
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (XFS_FORCED_SHUTDOWN(mp))
- return -XFS_ERROR(EIO);
-
- if (copy_from_user(&bulkreq, (xfs_fsop_bulkreq_t *)arg,
- sizeof(xfs_fsop_bulkreq_t)))
- return -XFS_ERROR(EFAULT);
-
- if (copy_from_user(&inlast, (__s64 *)bulkreq.lastip,
- sizeof(__s64)))
- return -XFS_ERROR(EFAULT);
-
- if ((count = bulkreq.icount) <= 0)
- return -XFS_ERROR(EINVAL);
-
- if (cmd == XFS_IOC_FSINUMBERS)
- error = xfs_inumbers(mp, NULL, &inlast, &count,
- bulkreq.ubuffer);
- else if (cmd == XFS_IOC_FSBULKSTAT_SINGLE)
- error = xfs_bulkstat_single(mp, &inlast,
- bulkreq.ubuffer, &done);
- else { /* XFS_IOC_FSBULKSTAT */
- if (count == 1 && inlast != 0) {
- inlast++;
- error = xfs_bulkstat_single(mp, &inlast,
- bulkreq.ubuffer, &done);
- } else {
- error = xfs_bulkstat(mp, NULL, &inlast, &count,
- (bulkstat_one_pf)xfs_bulkstat_one, NULL,
- sizeof(xfs_bstat_t), bulkreq.ubuffer,
- BULKSTAT_FG_QUICK, &done);
- }
- }
-
- if (error)
- return -error;
-
- if (bulkreq.ocount != NULL) {
- if (copy_to_user((xfs_ino_t *)bulkreq.lastip, &inlast,
- sizeof(xfs_ino_t)))
- return -XFS_ERROR(EFAULT);
-
- if (copy_to_user((__s32 *)bulkreq.ocount, &count,
- sizeof(count)))
- return -XFS_ERROR(EFAULT);
- }
-
- return 0;
-}
-
-STATIC int
-xfs_ioc_fsgeometry_v1(
- xfs_mount_t *mp,
- unsigned long arg)
-{
- xfs_fsop_geom_v1_t fsgeo;
- int error;
-
- error = xfs_fs_geometry(mp, (xfs_fsop_geom_t *)&fsgeo, 3);
- if (error)
- return -error;
-
- if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
- return -XFS_ERROR(EFAULT);
- return 0;
-}
-
-STATIC int
-xfs_ioc_fsgeometry(
- xfs_mount_t *mp,
- unsigned long arg)
-{
- xfs_fsop_geom_t fsgeo;
- int error;
-
- error = xfs_fs_geometry(mp, &fsgeo, 4);
- if (error)
- return -error;
-
- if (copy_to_user((xfs_fsop_geom_t *)arg, &fsgeo, sizeof(fsgeo)))
- return -XFS_ERROR(EFAULT);
- return 0;
-}
-
-/*
- * Linux extended inode flags interface.
- */
-#define LINUX_XFLAG_SYNC 0x00000008 /* Synchronous updates */
-#define LINUX_XFLAG_IMMUTABLE 0x00000010 /* Immutable file */
-#define LINUX_XFLAG_APPEND 0x00000020 /* writes to file may only append */
-#define LINUX_XFLAG_NODUMP 0x00000040 /* do not dump file */
-#define LINUX_XFLAG_NOATIME 0x00000080 /* do not update atime */
-
-STATIC unsigned int
-xfs_merge_ioc_xflags(
- unsigned int flags,
- unsigned int start)
-{
- unsigned int xflags = start;
-
- if (flags & LINUX_XFLAG_IMMUTABLE)
- xflags |= XFS_XFLAG_IMMUTABLE;
- else
- xflags &= ~XFS_XFLAG_IMMUTABLE;
- if (flags & LINUX_XFLAG_APPEND)
- xflags |= XFS_XFLAG_APPEND;
- else
- xflags &= ~XFS_XFLAG_APPEND;
- if (flags & LINUX_XFLAG_SYNC)
- xflags |= XFS_XFLAG_SYNC;
- else
- xflags &= ~XFS_XFLAG_SYNC;
- if (flags & LINUX_XFLAG_NOATIME)
- xflags |= XFS_XFLAG_NOATIME;
- else
- xflags &= ~XFS_XFLAG_NOATIME;
- if (flags & LINUX_XFLAG_NODUMP)
- xflags |= XFS_XFLAG_NODUMP;
- else
- xflags &= ~XFS_XFLAG_NODUMP;
-
- return xflags;
-}
-
-STATIC int
-xfs_ioc_xattr(
- vnode_t *vp,
- xfs_inode_t *ip,
- struct file *filp,
- unsigned int cmd,
- unsigned long arg)
-{
- struct fsxattr fa;
- vattr_t va;
- int error;
- int attr_flags;
- unsigned int flags;
-
- switch (cmd) {
- case XFS_IOC_FSGETXATTR: {
- va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_NEXTENTS;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (error)
- return -error;
-
- fa.fsx_xflags = va.va_xflags;
- fa.fsx_extsize = va.va_extsize;
- fa.fsx_nextents = va.va_nextents;
-
- if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_FSSETXATTR: {
- if (copy_from_user(&fa, (struct fsxattr *)arg, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
-
- attr_flags = 0;
- if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
- attr_flags |= ATTR_NONBLOCK;
-
- va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE;
- va.va_xflags = fa.fsx_xflags;
- va.va_extsize = fa.fsx_extsize;
-
- VOP_SETATTR(vp, &va, attr_flags, NULL, error);
- if (!error)
- vn_revalidate(vp); /* update Linux inode flags */
- return -error;
- }
-
- case XFS_IOC_FSGETXATTRA: {
- va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_ANEXTENTS;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (error)
- return -error;
-
- fa.fsx_xflags = va.va_xflags;
- fa.fsx_extsize = va.va_extsize;
- fa.fsx_nextents = va.va_anextents;
-
- if (copy_to_user((struct fsxattr *)arg, &fa, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_GETXFLAGS: {
- flags = 0;
- if (ip->i_d.di_flags & XFS_XFLAG_IMMUTABLE)
- flags |= LINUX_XFLAG_IMMUTABLE;
- if (ip->i_d.di_flags & XFS_XFLAG_APPEND)
- flags |= LINUX_XFLAG_APPEND;
- if (ip->i_d.di_flags & XFS_XFLAG_SYNC)
- flags |= LINUX_XFLAG_SYNC;
- if (ip->i_d.di_flags & XFS_XFLAG_NOATIME)
- flags |= LINUX_XFLAG_NOATIME;
- if (ip->i_d.di_flags & XFS_XFLAG_NODUMP)
- flags |= LINUX_XFLAG_NODUMP;
- if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- case XFS_IOC_SETXFLAGS: {
- if (copy_from_user(&flags, (unsigned int *)arg, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
-
- if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
- LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \
- LINUX_XFLAG_SYNC))
- return -XFS_ERROR(EOPNOTSUPP);
-
- attr_flags = 0;
- if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
- attr_flags |= ATTR_NONBLOCK;
-
- va.va_mask = XFS_AT_XFLAGS;
- va.va_xflags = xfs_merge_ioc_xflags(flags, ip->i_d.di_flags);
-
- VOP_SETATTR(vp, &va, attr_flags, NULL, error);
- if (!error)
- vn_revalidate(vp); /* update Linux inode flags */
- return -error;
- }
-
- case XFS_IOC_GETVERSION: {
- flags = LINVFS_GET_IP(vp)->i_generation;
- if (copy_to_user((unsigned int *)arg, &flags, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
- return 0;
- }
-
- default:
- return -ENOTTY;
- }
-}
-
-STATIC int
-xfs_ioc_getbmap(
- bhv_desc_t *bdp,
- struct file *filp,
- int ioflags,
- unsigned int cmd,
- unsigned long arg)
-{
- struct getbmap bm;
- int iflags;
- int error;
-
- if (copy_from_user(&bm, (struct getbmap *)arg, sizeof(bm)))
- return -XFS_ERROR(EFAULT);
-
- if (bm.bmv_count < 2)
- return -XFS_ERROR(EINVAL);
-
- iflags = (cmd == XFS_IOC_GETBMAPA ? BMV_IF_ATTRFORK : 0);
- if (ioflags & IO_INVIS)
- iflags |= BMV_IF_NO_DMAPI_READ;
-
- error = xfs_getbmap(bdp, &bm, (struct getbmap *)arg+1, iflags);
- if (error)
- return -error;
-
- if (copy_to_user((struct getbmap *)arg, &bm, sizeof(bm)))
- return -XFS_ERROR(EFAULT);
- return 0;
-}
-
-STATIC int
-xfs_ioc_getbmapx(
- bhv_desc_t *bdp,
- unsigned long arg)
-{
- struct getbmapx bmx;
- struct getbmap bm;
- int iflags;
- int error;
-
- if (copy_from_user(&bmx, (struct getbmapx *)arg, sizeof(bmx)))
- return -XFS_ERROR(EFAULT);
-
- if (bmx.bmv_count < 2)
- return -XFS_ERROR(EINVAL);
-
- /*
- * Map input getbmapx structure to a getbmap
- * structure for xfs_getbmap.
- */
- GETBMAP_CONVERT(bmx, bm);
-
- iflags = bmx.bmv_iflags;
-
- if (iflags & (~BMV_IF_VALID))
- return -XFS_ERROR(EINVAL);
-
- iflags |= BMV_IF_EXTENDED;
-
- error = xfs_getbmap(bdp, &bm, (struct getbmapx *)arg+1, iflags);
- if (error)
- return -error;
-
- GETBMAP_CONVERT(bm, bmx);
-
- if (copy_to_user((struct getbmapx *)arg, &bmx, sizeof(bmx)))
- return -XFS_ERROR(EFAULT);
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-
-#include <linux/xattr.h>
-
-
-/*
- * Pull the link count and size up from the xfs inode to the linux inode
- */
-STATIC void
-validate_fields(
- struct inode *ip)
-{
- vnode_t *vp = LINVFS_GET_VP(ip);
- vattr_t va;
- int error;
-
- va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
- VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error);
- if (likely(!error)) {
- ip->i_nlink = va.va_nlink;
- ip->i_blocks = va.va_nblocks;
-
- /* we're under i_sem so i_size can't change under us */
- if (i_size_read(ip) != va.va_size)
- i_size_write(ip, va.va_size);
- }
-}
-
-/*
- * Determine whether a process has a valid fs_struct (kernel daemons
- * like knfsd don't have an fs_struct).
- *
- * XXX(hch): nfsd is broken, better fix it instead.
- */
-STATIC inline int
-has_fs_struct(struct task_struct *task)
-{
- return (task->fs != init_task.fs);
-}
-
-STATIC int
-linvfs_mknod(
- struct inode *dir,
- struct dentry *dentry,
- int mode,
- dev_t rdev)
-{
- struct inode *ip;
- vattr_t va;
- vnode_t *vp = NULL, *dvp = LINVFS_GET_VP(dir);
- xfs_acl_t *default_acl = NULL;
- attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
- int error;
-
- /*
- * Irix uses Missed'em'V split, but doesn't want to see
- * the upper 5 bits of (14bit) major.
- */
- if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)
- return -EINVAL;
-
- if (test_default_acl && test_default_acl(dvp)) {
- if (!_ACL_ALLOC(default_acl))
- return -ENOMEM;
- if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
- _ACL_FREE(default_acl);
- default_acl = NULL;
- }
- }
-
- if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current))
- mode &= ~current->fs->umask;
-
- memset(&va, 0, sizeof(va));
- va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
- va.va_type = IFTOVT(mode);
- va.va_mode = mode;
-
- switch (mode & S_IFMT) {
- case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
- va.va_rdev = sysv_encode_dev(rdev);
- va.va_mask |= XFS_AT_RDEV;
- /*FALLTHROUGH*/
- case S_IFREG:
- VOP_CREATE(dvp, dentry, &va, &vp, NULL, error);
- break;
- case S_IFDIR:
- VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- if (default_acl) {
- if (!error) {
- error = _ACL_INHERIT(vp, &va, default_acl);
- if (!error) {
- VMODIFY(vp);
- } else {
- struct dentry teardown = {};
- int err2;
-
- /* Oh, the horror.
- * If we can't add the ACL we must back out.
- * ENOSPC can hit here, among other things.
- */
- teardown.d_inode = ip = LINVFS_GET_IP(vp);
- teardown.d_name = dentry->d_name;
- remove_inode_hash(ip);
- make_bad_inode(ip);
- if (S_ISDIR(mode))
- VOP_RMDIR(dvp, &teardown, NULL, err2);
- else
- VOP_REMOVE(dvp, &teardown, NULL, err2);
- VN_RELE(vp);
- }
- }
- _ACL_FREE(default_acl);
- }
-
- if (!error) {
- ASSERT(vp);
- ip = LINVFS_GET_IP(vp);
-
- if (S_ISCHR(mode) || S_ISBLK(mode))
- ip->i_rdev = rdev;
- else if (S_ISDIR(mode))
- validate_fields(ip);
- d_instantiate(dentry, ip);
- validate_fields(dir);
- }
- return -error;
-}
-
-STATIC int
-linvfs_create(
- struct inode *dir,
- struct dentry *dentry,
- int mode,
- struct nameidata *nd)
-{
- return linvfs_mknod(dir, dentry, mode, 0);
-}
-
-STATIC int
-linvfs_mkdir(
- struct inode *dir,
- struct dentry *dentry,
- int mode)
-{
- return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
-}
-
-STATIC struct dentry *
-linvfs_lookup(
- struct inode *dir,
- struct dentry *dentry,
- struct nameidata *nd)
-{
- struct inode *ip = NULL;
- vnode_t *vp, *cvp = NULL;
- int error;
-
- if (dentry->d_name.len >= MAXNAMELEN)
- return ERR_PTR(-ENAMETOOLONG);
-
- vp = LINVFS_GET_VP(dir);
- VOP_LOOKUP(vp, dentry, &cvp, 0, NULL, NULL, error);
- if (!error) {
- ASSERT(cvp);
- ip = LINVFS_GET_IP(cvp);
- if (!ip) {
- VN_RELE(cvp);
- return ERR_PTR(-EACCES);
- }
- }
- if (error && (error != ENOENT))
- return ERR_PTR(-error);
- return d_splice_alias(ip, dentry);
-}
-
-STATIC int
-linvfs_link(
- struct dentry *old_dentry,
- struct inode *dir,
- struct dentry *dentry)
-{
- struct inode *ip; /* inode of guy being linked to */
- vnode_t *tdvp; /* target directory for new name/link */
- vnode_t *vp; /* vp of name being linked */
- int error;
-
- ip = old_dentry->d_inode; /* inode being linked to */
- if (S_ISDIR(ip->i_mode))
- return -EPERM;
-
- tdvp = LINVFS_GET_VP(dir);
- vp = LINVFS_GET_VP(ip);
-
- VOP_LINK(tdvp, vp, dentry, NULL, error);
- if (!error) {
- VMODIFY(tdvp);
- VN_HOLD(vp);
- validate_fields(ip);
- d_instantiate(dentry, ip);
- }
- return -error;
-}
-
-STATIC int
-linvfs_unlink(
- struct inode *dir,
- struct dentry *dentry)
-{
- struct inode *inode;
- vnode_t *dvp; /* directory containing name to remove */
- int error;
-
- inode = dentry->d_inode;
- dvp = LINVFS_GET_VP(dir);
-
- VOP_REMOVE(dvp, dentry, NULL, error);
- if (!error) {
- validate_fields(dir); /* For size only */
- validate_fields(inode);
- }
-
- return -error;
-}
-
-STATIC int
-linvfs_symlink(
- struct inode *dir,
- struct dentry *dentry,
- const char *symname)
-{
- struct inode *ip;
- vattr_t va;
- vnode_t *dvp; /* directory containing name to remove */
- vnode_t *cvp; /* used to lookup symlink to put in dentry */
- int error;
-
- dvp = LINVFS_GET_VP(dir);
- cvp = NULL;
-
- memset(&va, 0, sizeof(va));
- va.va_type = VLNK;
- va.va_mode = irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO;
- va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
-
- error = 0;
- VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
- if (!error && cvp) {
- ASSERT(cvp->v_type == VLNK);
- ip = LINVFS_GET_IP(cvp);
- d_instantiate(dentry, ip);
- validate_fields(dir);
- validate_fields(ip); /* size needs update */
- }
- return -error;
-}
-
-STATIC int
-linvfs_rmdir(
- struct inode *dir,
- struct dentry *dentry)
-{
- struct inode *inode = dentry->d_inode;
- vnode_t *dvp = LINVFS_GET_VP(dir);
- int error;
-
- VOP_RMDIR(dvp, dentry, NULL, error);
- if (!error) {
- validate_fields(inode);
- validate_fields(dir);
- }
- return -error;
-}
-
-STATIC int
-linvfs_rename(
- struct inode *odir,
- struct dentry *odentry,
- struct inode *ndir,
- struct dentry *ndentry)
-{
- struct inode *new_inode = ndentry->d_inode;
- vnode_t *fvp; /* from directory */
- vnode_t *tvp; /* target directory */
- int error;
-
- fvp = LINVFS_GET_VP(odir);
- tvp = LINVFS_GET_VP(ndir);
-
- VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
- if (error)
- return -error;
-
- if (new_inode)
- validate_fields(new_inode);
-
- validate_fields(odir);
- if (ndir != odir)
- validate_fields(ndir);
- return 0;
-}
-
-STATIC int
-linvfs_readlink(
- struct dentry *dentry,
- char *buf,
- int size)
-{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
- uio_t uio;
- iovec_t iov;
- int error;
-
- iov.iov_base = buf;
- iov.iov_len = size;
-
- uio.uio_iov = &iov;
- uio.uio_offset = 0;
- uio.uio_segflg = UIO_USERSPACE;
- uio.uio_resid = size;
- uio.uio_iovcnt = 1;
-
- VOP_READLINK(vp, &uio, 0, NULL, error);
- if (error)
- return -error;
-
- return (size - uio.uio_resid);
-}
-
-/*
- * careful here - this function can get called recursively, so
- * we need to be very careful about how much stack we use.
- * uio is kmalloced for this reason...
- */
-STATIC int
-linvfs_follow_link(
- struct dentry *dentry,
- struct nameidata *nd)
-{
- vnode_t *vp;
- uio_t *uio;
- iovec_t iov;
- int error;
- char *link;
-
- ASSERT(dentry);
- ASSERT(nd);
-
- link = (char *)kmalloc(MAXNAMELEN+1, GFP_KERNEL);
- if (!link)
- return -ENOMEM;
-
- uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL);
- if (!uio) {
- kfree(link);
- return -ENOMEM;
- }
-
- vp = LINVFS_GET_VP(dentry->d_inode);
-
- iov.iov_base = link;
- iov.iov_len = MAXNAMELEN;
-
- uio->uio_iov = &iov;
- uio->uio_offset = 0;
- uio->uio_segflg = UIO_SYSSPACE;
- uio->uio_resid = MAXNAMELEN;
- uio->uio_iovcnt = 1;
-
- VOP_READLINK(vp, uio, 0, NULL, error);
- if (error) {
- kfree(uio);
- kfree(link);
- return -error;
- }
-
- link[MAXNAMELEN - uio->uio_resid] = '\0';
- kfree(uio);
-
- /* vfs_follow_link returns (-) errors */
- error = vfs_follow_link(nd, link);
- kfree(link);
- return error;
-}
-
-#ifdef CONFIG_XFS_POSIX_ACL
-STATIC int
-linvfs_permission(
- struct inode *inode,
- int mode,
- struct nameidata *nd)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error;
-
- mode <<= 6; /* convert from linux to vnode access bits */
- VOP_ACCESS(vp, mode, NULL, error);
- return -error;
-}
-#else
-#define linvfs_permission NULL
-#endif
-
-STATIC int
-linvfs_getattr(
- struct vfsmount *mnt,
- struct dentry *dentry,
- struct kstat *stat)
-{
- struct inode *inode = dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error = 0;
-
- if (unlikely(vp->v_flag & VMODIFIED))
- error = vn_revalidate(vp);
- if (!error)
- generic_fillattr(inode, stat);
- return 0;
-}
-
-STATIC int
-linvfs_setattr(
- struct dentry *dentry,
- struct iattr *attr)
-{
- struct inode *inode = dentry->d_inode;
- unsigned int ia_valid = attr->ia_valid;
- vnode_t *vp = LINVFS_GET_VP(inode);
- vattr_t vattr;
- int flags = 0;
- int error;
-
- memset(&vattr, 0, sizeof(vattr_t));
- if (ia_valid & ATTR_UID) {
- vattr.va_mask |= XFS_AT_UID;
- vattr.va_uid = attr->ia_uid;
- }
- if (ia_valid & ATTR_GID) {
- vattr.va_mask |= XFS_AT_GID;
- vattr.va_gid = attr->ia_gid;
- }
- if (ia_valid & ATTR_SIZE) {
- vattr.va_mask |= XFS_AT_SIZE;
- vattr.va_size = attr->ia_size;
- }
- if (ia_valid & ATTR_ATIME) {
- vattr.va_mask |= XFS_AT_ATIME;
- vattr.va_atime = attr->ia_atime;
- }
- if (ia_valid & ATTR_MTIME) {
- vattr.va_mask |= XFS_AT_MTIME;
- vattr.va_mtime = attr->ia_mtime;
- }
- if (ia_valid & ATTR_CTIME) {
- vattr.va_mask |= XFS_AT_CTIME;
- vattr.va_ctime = attr->ia_ctime;
- }
- if (ia_valid & ATTR_MODE) {
- vattr.va_mask |= XFS_AT_MODE;
- vattr.va_mode = attr->ia_mode;
- if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
- inode->i_mode &= ~S_ISGID;
- }
-
- if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET))
- flags = ATTR_UTIME;
-#ifdef ATTR_NO_BLOCK
- if ((ia_valid & ATTR_NO_BLOCK))
- flags |= ATTR_NONBLOCK;
-#endif
-
- VOP_SETATTR(vp, &vattr, flags, NULL, error);
- if (error)
- return(-error); /* Positive error up from XFS */
- if (ia_valid & ATTR_SIZE) {
- error = vmtruncate(inode, attr->ia_size);
- }
-
- if (!error) {
- vn_revalidate(vp);
- }
- return error;
-}
-
-STATIC void
-linvfs_truncate(
- struct inode *inode)
-{
- block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
-}
-
-STATIC int
-linvfs_setxattr(
- struct dentry *dentry,
- const char *name,
- const void *data,
- size_t size,
- int flags)
-{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
- char *attr = (char *)name;
- attrnames_t *namesp;
- int xflags = 0;
- int error;
-
- namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
- if (!namesp)
- return -EOPNOTSUPP;
- attr += namesp->attr_namelen;
- error = namesp->attr_capable(vp, NULL);
- if (error)
- return error;
-
- /* Convert Linux syscall to XFS internal ATTR flags */
- if (flags & XATTR_CREATE)
- xflags |= ATTR_CREATE;
- if (flags & XATTR_REPLACE)
- xflags |= ATTR_REPLACE;
- xflags |= namesp->attr_flag;
- return namesp->attr_set(vp, attr, (void *)data, size, xflags);
-}
-
-STATIC ssize_t
-linvfs_getxattr(
- struct dentry *dentry,
- const char *name,
- void *data,
- size_t size)
-{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
- char *attr = (char *)name;
- attrnames_t *namesp;
- int xflags = 0;
- ssize_t error;
-
- namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
- if (!namesp)
- return -EOPNOTSUPP;
- attr += namesp->attr_namelen;
- error = namesp->attr_capable(vp, NULL);
- if (error)
- return error;
-
- /* Convert Linux syscall to XFS internal ATTR flags */
- if (!size) {
- xflags |= ATTR_KERNOVAL;
- data = NULL;
- }
- xflags |= namesp->attr_flag;
- return namesp->attr_get(vp, attr, (void *)data, size, xflags);
-}
-
-STATIC ssize_t
-linvfs_listxattr(
- struct dentry *dentry,
- char *data,
- size_t size)
-{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
- int error, xflags = ATTR_KERNAMELS;
- ssize_t result;
-
- if (!size)
- xflags |= ATTR_KERNOVAL;
- xflags |= capable(CAP_SYS_ADMIN) ? ATTR_KERNFULLS : ATTR_KERNORMALS;
-
- error = attr_generic_list(vp, data, size, xflags, &result);
- if (error < 0)
- return error;
- return result;
-}
-
-STATIC int
-linvfs_removexattr(
- struct dentry *dentry,
- const char *name)
-{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
- char *attr = (char *)name;
- attrnames_t *namesp;
- int xflags = 0;
- int error;
-
- namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
- if (!namesp)
- return -EOPNOTSUPP;
- attr += namesp->attr_namelen;
- error = namesp->attr_capable(vp, NULL);
- if (error)
- return error;
- xflags |= namesp->attr_flag;
- return namesp->attr_remove(vp, attr, xflags);
-}
-
-
-struct inode_operations linvfs_file_inode_operations = {
- .permission = linvfs_permission,
- .truncate = linvfs_truncate,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
-};
-
-struct inode_operations linvfs_dir_inode_operations = {
- .create = linvfs_create,
- .lookup = linvfs_lookup,
- .link = linvfs_link,
- .unlink = linvfs_unlink,
- .symlink = linvfs_symlink,
- .mkdir = linvfs_mkdir,
- .rmdir = linvfs_rmdir,
- .mknod = linvfs_mknod,
- .rename = linvfs_rename,
- .permission = linvfs_permission,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
-};
-
-struct inode_operations linvfs_symlink_inode_operations = {
- .readlink = linvfs_readlink,
- .follow_link = linvfs_follow_link,
- .permission = linvfs_permission,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
-};
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_IOPS_H__
-#define __XFS_IOPS_H__
-
-extern struct inode_operations linvfs_file_inode_operations;
-extern struct inode_operations linvfs_dir_inode_operations;
-extern struct inode_operations linvfs_symlink_inode_operations;
-
-extern struct file_operations linvfs_file_operations;
-extern struct file_operations linvfs_invis_file_operations;
-extern struct file_operations linvfs_dir_operations;
-
-extern struct address_space_operations linvfs_aops;
-
-extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
-extern void linvfs_unwritten_done(struct buffer_head *, int);
-
-extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
- int, unsigned int, unsigned long);
-
-#endif /* __XFS_IOPS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_LINUX__
-#define __XFS_LINUX__
-
-#include <linux/types.h>
-#include <linux/config.h>
-
-/*
- * Some types are conditional depending on the target system.
- * XFS_BIG_BLKNOS needs block layer disk addresses to be 64 bits.
- * XFS_BIG_INUMS needs the VFS inode number to be 64 bits, as well
- * as requiring XFS_BIG_BLKNOS to be set.
- */
-#if defined(CONFIG_LBD) || (BITS_PER_LONG == 64)
-# define XFS_BIG_BLKNOS 1
-# if BITS_PER_LONG == 64
-# define XFS_BIG_INUMS 1
-# else
-# define XFS_BIG_INUMS 0
-# endif
-#else
-# define XFS_BIG_BLKNOS 0
-# define XFS_BIG_INUMS 0
-#endif
-
-#include <xfs_types.h>
-#include <xfs_arch.h>
-
-#include <kmem.h>
-#include <mrlock.h>
-#include <spin.h>
-#include <sv.h>
-#include <mutex.h>
-#include <sema.h>
-#include <time.h>
-
-#include <support/qsort.h>
-#include <support/ktrace.h>
-#include <support/debug.h>
-#include <support/move.h>
-#include <support/uuid.h>
-
-#include <linux/mm.h>
-#include <linux/kernel.h>
-#include <linux/blkdev.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/file.h>
-#include <linux/swap.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/bitops.h>
-#include <linux/major.h>
-#include <linux/pagemap.h>
-#include <linux/vfs.h>
-#include <linux/seq_file.h>
-#include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <linux/version.h>
-
-#include <asm/page.h>
-#include <asm/div64.h>
-#include <asm/param.h>
-#include <asm/uaccess.h>
-#include <asm/byteorder.h>
-#include <asm/unaligned.h>
-
-#include <xfs_behavior.h>
-#include <xfs_vfs.h>
-#include <xfs_cred.h>
-#include <xfs_vnode.h>
-#include <xfs_stats.h>
-#include <xfs_sysctl.h>
-#include <xfs_iops.h>
-#include <xfs_super.h>
-#include <xfs_globals.h>
-#include <xfs_fs_subr.h>
-#include <xfs_lrw.h>
-#include <xfs_buf.h>
-
-/*
- * Feature macros (disable/enable)
- */
-#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */
-#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */
-
-/*
- * State flag for unwritten extent buffers.
- *
- * We need to be able to distinguish between these and delayed
- * allocate buffers within XFS. The generic IO path code does
- * not need to distinguish - we use the BH_Delay flag for both
- * delalloc and these ondisk-uninitialised buffers.
- */
-BUFFER_FNS(PrivateStart, unwritten);
-static inline void set_buffer_unwritten_io(struct buffer_head *bh)
-{
- bh->b_end_io = linvfs_unwritten_done;
-}
-
-#define xfs_refcache_size xfs_params.refcache_size.val
-#define xfs_refcache_purge_count xfs_params.refcache_purge.val
-#define restricted_chown xfs_params.restrict_chown.val
-#define irix_sgid_inherit xfs_params.sgid_inherit.val
-#define irix_symlink_mode xfs_params.symlink_mode.val
-#define xfs_panic_mask xfs_params.panic_mask.val
-#define xfs_error_level xfs_params.error_level.val
-#define xfs_syncd_interval (xfs_params.sync_interval.val * HZ / USER_HZ)
-#define xfs_stats_clear xfs_params.stats_clear.val
-#define xfs_inherit_sync xfs_params.inherit_sync.val
-#define xfs_inherit_nodump xfs_params.inherit_nodump.val
-#define xfs_inherit_noatime xfs_params.inherit_noatim.val
-#define xfs_flush_interval (xfs_params.flush_interval.val * HZ / USER_HZ)
-#define xfs_age_buffer (xfs_params.age_buffer.val * HZ / USER_HZ)
-
-#define current_cpu() smp_processor_id()
-#define current_pid() (current->pid)
-#define current_fsuid(cred) (current->fsuid)
-#define current_fsgid(cred) (current->fsgid)
-
-#define NBPP PAGE_SIZE
-#define DPPSHFT (PAGE_SHIFT - 9)
-#define NDPP (1 << (PAGE_SHIFT - 9))
-#define dtop(DD) (((DD) + NDPP - 1) >> DPPSHFT)
-#define dtopt(DD) ((DD) >> DPPSHFT)
-#define dpoff(DD) ((DD) & (NDPP-1))
-
-#define NBBY 8 /* number of bits per byte */
-#define NBPC PAGE_SIZE /* Number of bytes per click */
-#define BPCSHIFT PAGE_SHIFT /* LOG2(NBPC) if exact */
-
-/*
- * Size of block device i/o is parameterized here.
- * Currently the system supports page-sized i/o.
- */
-#define BLKDEV_IOSHIFT BPCSHIFT
-#define BLKDEV_IOSIZE (1<<BLKDEV_IOSHIFT)
-/* number of BB's per block device block */
-#define BLKDEV_BB BTOBB(BLKDEV_IOSIZE)
-
-/* bytes to clicks */
-#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT)
-#define btoc64(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define btoct64(x) ((__uint64_t)(x)>>BPCSHIFT)
-#define io_btoc(x) (((__psunsigned_t)(x)+(IO_NBPC-1))>>IO_BPCSHIFT)
-#define io_btoct(x) ((__psunsigned_t)(x)>>IO_BPCSHIFT)
-
-/* off_t bytes to clicks */
-#define offtoc(x) (((__uint64_t)(x)+(NBPC-1))>>BPCSHIFT)
-#define offtoct(x) ((xfs_off_t)(x)>>BPCSHIFT)
-
-/* clicks to off_t bytes */
-#define ctooff(x) ((xfs_off_t)(x)<<BPCSHIFT)
-
-/* clicks to bytes */
-#define ctob(x) ((__psunsigned_t)(x)<<BPCSHIFT)
-#define btoct(x) ((__psunsigned_t)(x)>>BPCSHIFT)
-#define ctob64(x) ((__uint64_t)(x)<<BPCSHIFT)
-#define io_ctob(x) ((__psunsigned_t)(x)<<IO_BPCSHIFT)
-
-/* bytes to clicks */
-#define btoc(x) (((__psunsigned_t)(x)+(NBPC-1))>>BPCSHIFT)
-
-#ifndef CELL_CAPABLE
-#define FSC_NOTIFY_NAME_CHANGED(vp)
-#endif
-
-#ifndef ENOATTR
-#define ENOATTR ENODATA /* Attribute not found */
-#endif
-
-/* Note: EWRONGFS never visible outside the kernel */
-#define EWRONGFS EINVAL /* Mount with wrong filesystem type */
-
-/*
- * XXX EFSCORRUPTED needs a real value in errno.h. asm-i386/errno.h won't
- * return codes out of its known range in errno.
- * XXX Also note: needs to be < 1000 and fairly unique on Linux (mustn't
- * conflict with any code we use already or any code a driver may use)
- * XXX Some options (currently we do #2):
- * 1/ New error code ["Filesystem is corrupted", _after_ glibc updated]
- * 2/ 990 ["Unknown error 990"]
- * 3/ EUCLEAN ["Structure needs cleaning"]
- * 4/ Convert EFSCORRUPTED to EIO [just prior to return into userspace]
- */
-#define EFSCORRUPTED 990 /* Filesystem is corrupted */
-
-#define SYNCHRONIZE() barrier()
-#define __return_address __builtin_return_address(0)
-
-/*
- * IRIX (BSD) quotactl makes use of separate commands for user/group,
- * whereas on Linux the syscall encodes this information into the cmd
- * field (see the QCMD macro in quota.h). These macros help keep the
- * code portable - they are not visible from the syscall interface.
- */
-#define Q_XSETGQLIM XQM_CMD(0x8) /* set groups disk limits */
-#define Q_XGETGQUOTA XQM_CMD(0x9) /* get groups disk limits */
-
-/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */
-/* we may well need to fine-tune this if it ever becomes an issue. */
-#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */
-#define ndquot DQUOT_MAX_HEURISTIC
-
-/* IRIX uses the current size of the name cache to guess a good value */
-/* - this isn't the same but is a good enough starting point for now. */
-#define DQUOT_HASH_HEURISTIC files_stat.nr_files
-
-/* IRIX inodes maintain the project ID also, zero this field on Linux */
-#define DEFAULT_PROJID 0
-#define dfltprid DEFAULT_PROJID
-
-#define MAXPATHLEN 1024
-
-#define MIN(a,b) (min(a,b))
-#define MAX(a,b) (max(a,b))
-#define howmany(x, y) (((x)+((y)-1))/(y))
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-
-#define xfs_stack_trace() dump_stack()
-
-#define xfs_itruncate_data(ip, off) \
- (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
-
-
-/* Move the kernel do_div definition off to one side */
-
-#if defined __i386__
-/* For ia32 we need to pull some tricks to get past various versions
- * of the compiler which do not like us using do_div in the middle
- * of large functions.
- */
-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
-{
- __u32 mod;
-
- switch (n) {
- case 4:
- mod = *(__u32 *)a % b;
- *(__u32 *)a = *(__u32 *)a / b;
- return mod;
- case 8:
- {
- unsigned long __upper, __low, __high, __mod;
- __u64 c = *(__u64 *)a;
- __upper = __high = c >> 32;
- __low = c;
- if (__high) {
- __upper = __high % (b);
- __high = __high / (b);
- }
- asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
- asm("":"=A" (c):"a" (__low),"d" (__high));
- *(__u64 *)a = c;
- return __mod;
- }
- }
-
- /* NOTREACHED */
- return 0;
-}
-
-/* Side effect free 64 bit mod operation */
-static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
-{
- switch (n) {
- case 4:
- return *(__u32 *)a % b;
- case 8:
- {
- unsigned long __upper, __low, __high, __mod;
- __u64 c = *(__u64 *)a;
- __upper = __high = c >> 32;
- __low = c;
- if (__high) {
- __upper = __high % (b);
- __high = __high / (b);
- }
- asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (b), "0" (__low), "1" (__upper));
- asm("":"=A" (c):"a" (__low),"d" (__high));
- return __mod;
- }
- }
-
- /* NOTREACHED */
- return 0;
-}
-#else
-static inline __u32 xfs_do_div(void *a, __u32 b, int n)
-{
- __u32 mod;
-
- switch (n) {
- case 4:
- mod = *(__u32 *)a % b;
- *(__u32 *)a = *(__u32 *)a / b;
- return mod;
- case 8:
- mod = do_div(*(__u64 *)a, b);
- return mod;
- }
-
- /* NOTREACHED */
- return 0;
-}
-
-/* Side effect free 64 bit mod operation */
-static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
-{
- switch (n) {
- case 4:
- return *(__u32 *)a % b;
- case 8:
- {
- __u64 c = *(__u64 *)a;
- return do_div(c, b);
- }
- }
-
- /* NOTREACHED */
- return 0;
-}
-#endif
-
-#undef do_div
-#define do_div(a, b) xfs_do_div(&(a), (b), sizeof(a))
-#define do_mod(a, b) xfs_do_mod(&(a), (b), sizeof(a))
-
-static inline __uint64_t roundup_64(__uint64_t x, __uint32_t y)
-{
- x += y - 1;
- do_div(x, y);
- return(x * y);
-}
-
-#endif /* __XFS_LINUX__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-/*
- * fs/xfs/linux/xfs_lrw.c (Linux Read Write stuff)
- *
- */
-
-#include "xfs.h"
-
-#include "xfs_fs.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_inode_item.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_iomap.h"
-
-#include <linux/capability.h>
-
-
-#if defined(XFS_RW_TRACE)
-void
-xfs_rw_enter_trace(
- int tag,
- xfs_iocore_t *io,
- const struct iovec *iovp,
- size_t segs,
- loff_t offset,
- int ioflags)
-{
- xfs_inode_t *ip = XFS_IO_INODE(io);
-
- if (ip->i_rwtrace == NULL)
- return;
- ktrace_enter(ip->i_rwtrace,
- (void *)(unsigned long)tag,
- (void *)ip,
- (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
- (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
- (void *)(__psint_t)iovp,
- (void *)((unsigned long)segs),
- (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
- (void *)((unsigned long)(offset & 0xffffffff)),
- (void *)((unsigned long)ioflags),
- (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
- (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
- (void *)NULL,
- (void *)NULL,
- (void *)NULL,
- (void *)NULL,
- (void *)NULL);
-}
-
-void
-xfs_inval_cached_trace(
- xfs_iocore_t *io,
- xfs_off_t offset,
- xfs_off_t len,
- xfs_off_t first,
- xfs_off_t last)
-{
- xfs_inode_t *ip = XFS_IO_INODE(io);
-
- if (ip->i_rwtrace == NULL)
- return;
- ktrace_enter(ip->i_rwtrace,
- (void *)(__psint_t)XFS_INVAL_CACHED,
- (void *)ip,
- (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
- (void *)((unsigned long)(offset & 0xffffffff)),
- (void *)((unsigned long)((len >> 32) & 0xffffffff)),
- (void *)((unsigned long)(len & 0xffffffff)),
- (void *)((unsigned long)((first >> 32) & 0xffffffff)),
- (void *)((unsigned long)(first & 0xffffffff)),
- (void *)((unsigned long)((last >> 32) & 0xffffffff)),
- (void *)((unsigned long)(last & 0xffffffff)),
- (void *)NULL,
- (void *)NULL,
- (void *)NULL,
- (void *)NULL,
- (void *)NULL,
- (void *)NULL);
-}
-#endif
-
-/*
- * xfs_iozero
- *
- * xfs_iozero clears the specified range of buffer supplied,
- * and marks all the affected blocks as valid and modified. If
- * an affected block is not allocated, it will be allocated. If
- * an affected block is not completely overwritten, and is not
- * valid before the operation, it will be read from disk before
- * being partially zeroed.
- */
-STATIC int
-xfs_iozero(
- struct inode *ip, /* inode */
- loff_t pos, /* offset in file */
- size_t count, /* size of data to zero */
- loff_t end_size) /* max file size to set */
-{
- unsigned bytes;
- struct page *page;
- struct address_space *mapping;
- char *kaddr;
- int status;
-
- mapping = ip->i_mapping;
- do {
- unsigned long index, offset;
-
- offset = (pos & (PAGE_CACHE_SIZE -1)); /* Within page */
- index = pos >> PAGE_CACHE_SHIFT;
- bytes = PAGE_CACHE_SIZE - offset;
- if (bytes > count)
- bytes = count;
-
- status = -ENOMEM;
- page = grab_cache_page(mapping, index);
- if (!page)
- break;
-
- kaddr = kmap(page);
- status = mapping->a_ops->prepare_write(NULL, page, offset,
- offset + bytes);
- if (status) {
- goto unlock;
- }
-
- memset((void *) (kaddr + offset), 0, bytes);
- flush_dcache_page(page);
- status = mapping->a_ops->commit_write(NULL, page, offset,
- offset + bytes);
- if (!status) {
- pos += bytes;
- count -= bytes;
- if (pos > i_size_read(ip))
- i_size_write(ip, pos < end_size ? pos : end_size);
- }
-
-unlock:
- kunmap(page);
- unlock_page(page);
- page_cache_release(page);
- if (status)
- break;
- } while (count);
-
- return (-status);
-}
-
-/*
- * xfs_inval_cached_pages
- *
- * This routine is responsible for keeping direct I/O and buffered I/O
- * somewhat coherent. From here we make sure that we're at least
- * temporarily holding the inode I/O lock exclusively and then call
- * the page cache to flush and invalidate any cached pages. If there
- * are no cached pages this routine will be very quick.
- */
-void
-xfs_inval_cached_pages(
- vnode_t *vp,
- xfs_iocore_t *io,
- xfs_off_t offset,
- int write,
- int relock)
-{
- xfs_mount_t *mp;
-
- if (!VN_CACHED(vp)) {
- return;
- }
-
- mp = io->io_mount;
-
- /*
- * We need to get the I/O lock exclusively in order
- * to safely invalidate pages and mappings.
- */
- if (relock) {
- XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
- XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
- }
-
- /* Writing beyond EOF creates a hole that must be zeroed */
- if (write && (offset > XFS_SIZE(mp, io))) {
- xfs_fsize_t isize;
-
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
- isize = XFS_SIZE(mp, io);
- if (offset > isize) {
- xfs_zero_eof(vp, io, offset, isize, offset);
- }
- XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
- }
-
- xfs_inval_cached_trace(io, offset, -1, ctooff(offtoct(offset)), -1);
- VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
- if (relock) {
- XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
- }
-}
-
-ssize_t /* bytes read, or (-) error */
-xfs_read(
- bhv_desc_t *bdp,
- struct kiocb *iocb,
- const struct iovec *iovp,
- unsigned int segs,
- loff_t *offset,
- int ioflags,
- cred_t *credp)
-{
- struct file *file = iocb->ki_filp;
- size_t size = 0;
- ssize_t ret;
- xfs_fsize_t n;
- xfs_inode_t *ip;
- xfs_mount_t *mp;
- vnode_t *vp;
- unsigned long seg;
-
- ip = XFS_BHVTOI(bdp);
- vp = BHV_TO_VNODE(bdp);
- mp = ip->i_mount;
-
- XFS_STATS_INC(xs_read_calls);
-
- /* START copy & waste from filemap.c */
- for (seg = 0; seg < segs; seg++) {
- const struct iovec *iv = &iovp[seg];
-
- /*
- * If any segment has a negative length, or the cumulative
- * length ever wraps negative then return -EINVAL.
- */
- size += iv->iov_len;
- if (unlikely((ssize_t)(size|iv->iov_len) < 0))
- return XFS_ERROR(-EINVAL);
- }
- /* END copy & waste from filemap.c */
-
- if (ioflags & IO_ISDIRECT) {
- xfs_buftarg_t *target =
- (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
- mp->m_rtdev_targp : mp->m_ddev_targp;
- if ((*offset & target->pbr_smask) ||
- (size & target->pbr_smask)) {
- if (*offset == ip->i_d.di_size) {
- return (0);
- }
- return -XFS_ERROR(EINVAL);
- }
- }
-
- n = XFS_MAXIOFFSET(mp) - *offset;
- if ((n <= 0) || (size == 0))
- return 0;
-
- if (n < size)
- size = n;
-
- if (XFS_FORCED_SHUTDOWN(mp)) {
- return -EIO;
- }
-
- /* OK so we are holding the I/O lock for the duration
- * of the submission, then what happens if the I/O
- * does not really happen here, but is scheduled
- * later?
- */
- xfs_ilock(ip, XFS_IOLOCK_SHARED);
-
- if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
- !(ioflags & IO_INVIS)) {
- vrwlock_t locktype = VRWLOCK_READ;
-
- ret = XFS_SEND_DATA(mp, DM_EVENT_READ,
- BHV_TO_VNODE(bdp), *offset, size,
- FILP_DELAY_FLAG(file), &locktype);
- if (ret) {
- xfs_iunlock(ip, XFS_IOLOCK_SHARED);
- return -ret;
- }
- }
-
- xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
- iovp, segs, *offset, ioflags);
- ret = __generic_file_aio_read(iocb, iovp, segs, offset);
- xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
- if (ret > 0)
- XFS_STATS_ADD(xs_read_bytes, ret);
-
- if (likely(!(ioflags & IO_INVIS)))
- xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
-
- return ret;
-}
-
-ssize_t
-xfs_sendfile(
- bhv_desc_t *bdp,
- struct file *filp,
- loff_t *offset,
- int ioflags,
- size_t count,
- read_actor_t actor,
- void *target,
- cred_t *credp)
-{
- ssize_t ret;
- xfs_fsize_t n;
- xfs_inode_t *ip;
- xfs_mount_t *mp;
- vnode_t *vp;
-
- ip = XFS_BHVTOI(bdp);
- vp = BHV_TO_VNODE(bdp);
- mp = ip->i_mount;
-
- XFS_STATS_INC(xs_read_calls);
-
- n = XFS_MAXIOFFSET(mp) - *offset;
- if ((n <= 0) || (count == 0))
- return 0;
-
- if (n < count)
- count = n;
-
- if (XFS_FORCED_SHUTDOWN(ip->i_mount))
- return -EIO;
-
- xfs_ilock(ip, XFS_IOLOCK_SHARED);
-
- if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
- (!(ioflags & IO_INVIS))) {
- vrwlock_t locktype = VRWLOCK_READ;
- int error;
-
- error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,
- FILP_DELAY_FLAG(filp), &locktype);
- if (error) {
- xfs_iunlock(ip, XFS_IOLOCK_SHARED);
- return -error;
- }
- }
- xfs_rw_enter_trace(XFS_SENDFILE_ENTER, &ip->i_iocore,
- target, count, *offset, ioflags);
- ret = generic_file_sendfile(filp, offset, count, actor, target);
- xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
- XFS_STATS_ADD(xs_read_bytes, ret);
- xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
- return ret;
-}
-
-/*
- * This routine is called to handle zeroing any space in the last
- * block of the file that is beyond the EOF. We do this since the
- * size is being increased without writing anything to that block
- * and we don't want anyone to read the garbage on the disk.
- */
-STATIC int /* error (positive) */
-xfs_zero_last_block(
- struct inode *ip,
- xfs_iocore_t *io,
- xfs_off_t offset,
- xfs_fsize_t isize,
- xfs_fsize_t end_size)
-{
- xfs_fileoff_t last_fsb;
- xfs_mount_t *mp;
- int nimaps;
- int zero_offset;
- int zero_len;
- int isize_fsb_offset;
- int error = 0;
- xfs_bmbt_irec_t imap;
- loff_t loff;
- size_t lsize;
-
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
- ASSERT(offset > isize);
-
- mp = io->io_mount;
-
- isize_fsb_offset = XFS_B_FSB_OFFSET(mp, isize);
- if (isize_fsb_offset == 0) {
- /*
- * There are no extra bytes in the last block on disk to
- * zero, so return.
- */
- return 0;
- }
-
- last_fsb = XFS_B_TO_FSBT(mp, isize);
- nimaps = 1;
- error = XFS_BMAPI(mp, NULL, io, last_fsb, 1, 0, NULL, 0, &imap,
- &nimaps, NULL);
- if (error) {
- return error;
- }
- ASSERT(nimaps > 0);
- /*
- * If the block underlying isize is just a hole, then there
- * is nothing to zero.
- */
- if (imap.br_startblock == HOLESTARTBLOCK) {
- return 0;
- }
- /*
- * Zero the part of the last block beyond the EOF, and write it
- * out sync. We need to drop the ilock while we do this so we
- * don't deadlock when the buffer cache calls back to us.
- */
- XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
- loff = XFS_FSB_TO_B(mp, last_fsb);
- lsize = XFS_FSB_TO_B(mp, 1);
-
- zero_offset = isize_fsb_offset;
- zero_len = mp->m_sb.sb_blocksize - isize_fsb_offset;
-
- error = xfs_iozero(ip, loff + zero_offset, zero_len, end_size);
-
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
- ASSERT(error >= 0);
- return error;
-}
-
-/*
- * Zero any on disk space between the current EOF and the new,
- * larger EOF. This handles the normal case of zeroing the remainder
- * of the last block in the file and the unusual case of zeroing blocks
- * out beyond the size of the file. This second case only happens
- * with fixed size extents and when the system crashes before the inode
- * size was updated but after blocks were allocated. If fill is set,
- * then any holes in the range are filled and zeroed. If not, the holes
- * are left alone as holes.
- */
-
-int /* error (positive) */
-xfs_zero_eof(
- vnode_t *vp,
- xfs_iocore_t *io,
- xfs_off_t offset, /* starting I/O offset */
- xfs_fsize_t isize, /* current inode size */
- xfs_fsize_t end_size) /* terminal inode size */
-{
- struct inode *ip = LINVFS_GET_IP(vp);
- xfs_fileoff_t start_zero_fsb;
- xfs_fileoff_t end_zero_fsb;
- xfs_fileoff_t prev_zero_fsb;
- xfs_fileoff_t zero_count_fsb;
- xfs_fileoff_t last_fsb;
- xfs_extlen_t buf_len_fsb;
- xfs_extlen_t prev_zero_count;
- xfs_mount_t *mp;
- int nimaps;
- int error = 0;
- xfs_bmbt_irec_t imap;
- loff_t loff;
- size_t lsize;
-
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
-
- mp = io->io_mount;
-
- /*
- * First handle zeroing the block on which isize resides.
- * We only zero a part of that block so it is handled specially.
- */
- error = xfs_zero_last_block(ip, io, offset, isize, end_size);
- if (error) {
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
- return error;
- }
-
- /*
- * Calculate the range between the new size and the old
- * where blocks needing to be zeroed may exist. To get the
- * block where the last byte in the file currently resides,
- * we need to subtract one from the size and truncate back
- * to a block boundary. We subtract 1 in case the size is
- * exactly on a block boundary.
- */
- last_fsb = isize ? XFS_B_TO_FSBT(mp, isize - 1) : (xfs_fileoff_t)-1;
- start_zero_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)isize);
- end_zero_fsb = XFS_B_TO_FSBT(mp, offset - 1);
- ASSERT((xfs_sfiloff_t)last_fsb < (xfs_sfiloff_t)start_zero_fsb);
- if (last_fsb == end_zero_fsb) {
- /*
- * The size was only incremented on its last block.
- * We took care of that above, so just return.
- */
- return 0;
- }
-
- ASSERT(start_zero_fsb <= end_zero_fsb);
- prev_zero_fsb = NULLFILEOFF;
- prev_zero_count = 0;
- while (start_zero_fsb <= end_zero_fsb) {
- nimaps = 1;
- zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;
- error = XFS_BMAPI(mp, NULL, io, start_zero_fsb, zero_count_fsb,
- 0, NULL, 0, &imap, &nimaps, NULL);
- if (error) {
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
- return error;
- }
- ASSERT(nimaps > 0);
-
- if (imap.br_state == XFS_EXT_UNWRITTEN ||
- imap.br_startblock == HOLESTARTBLOCK) {
- /*
- * This loop handles initializing pages that were
- * partially initialized by the code below this
- * loop. It basically zeroes the part of the page
- * that sits on a hole and sets the page as P_HOLE
- * and calls remapf if it is a mapped file.
- */
- prev_zero_fsb = NULLFILEOFF;
- prev_zero_count = 0;
- start_zero_fsb = imap.br_startoff +
- imap.br_blockcount;
- ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
- continue;
- }
-
- /*
- * There are blocks in the range requested.
- * Zero them a single write at a time. We actually
- * don't zero the entire range returned if it is
- * too big and simply loop around to get the rest.
- * That is not the most efficient thing to do, but it
- * is simple and this path should not be exercised often.
- */
- buf_len_fsb = XFS_FILBLKS_MIN(imap.br_blockcount,
- mp->m_writeio_blocks << 8);
- /*
- * Drop the inode lock while we're doing the I/O.
- * We'll still have the iolock to protect us.
- */
- XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
-
- loff = XFS_FSB_TO_B(mp, start_zero_fsb);
- lsize = XFS_FSB_TO_B(mp, buf_len_fsb);
-
- error = xfs_iozero(ip, loff, lsize, end_size);
-
- if (error) {
- goto out_lock;
- }
-
- prev_zero_fsb = start_zero_fsb;
- prev_zero_count = buf_len_fsb;
- start_zero_fsb = imap.br_startoff + buf_len_fsb;
- ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
-
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
- }
-
- return 0;
-
-out_lock:
-
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
- ASSERT(error >= 0);
- return error;
-}
-
-ssize_t /* bytes written, or (-) error */
-xfs_write(
- bhv_desc_t *bdp,
- struct kiocb *iocb,
- const struct iovec *iovp,
- unsigned int segs,
- loff_t *offset,
- int ioflags,
- cred_t *credp)
-{
- struct file *file = iocb->ki_filp;
- size_t size = 0;
- xfs_inode_t *xip;
- xfs_mount_t *mp;
- ssize_t ret;
- int error = 0;
- xfs_fsize_t isize, new_size;
- xfs_fsize_t n, limit;
- xfs_iocore_t *io;
- vnode_t *vp;
- unsigned long seg;
- int iolock;
- int eventsent = 0;
- vrwlock_t locktype;
-
- XFS_STATS_INC(xs_write_calls);
-
- vp = BHV_TO_VNODE(bdp);
- xip = XFS_BHVTOI(bdp);
-
- /* START copy & waste from filemap.c */
- for (seg = 0; seg < segs; seg++) {
- const struct iovec *iv = &iovp[seg];
-
- /*
- * If any segment has a negative length, or the cumulative
- * length ever wraps negative then return -EINVAL.
- */
- size += iv->iov_len;
- if (unlikely((ssize_t)(size|iv->iov_len) < 0))
- return XFS_ERROR(-EINVAL);
- }
- /* END copy & waste from filemap.c */
-
- if (size == 0)
- return 0;
-
- io = &xip->i_iocore;
- mp = io->io_mount;
-
- if (XFS_FORCED_SHUTDOWN(mp)) {
- return -EIO;
- }
-
- if (ioflags & IO_ISDIRECT) {
- xfs_buftarg_t *target =
- (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
- mp->m_rtdev_targp : mp->m_ddev_targp;
-
- if ((*offset & target->pbr_smask) ||
- (size & target->pbr_smask)) {
- return XFS_ERROR(-EINVAL);
- }
- iolock = XFS_IOLOCK_SHARED;
- locktype = VRWLOCK_WRITE_DIRECT;
- } else {
- iolock = XFS_IOLOCK_EXCL;
- locktype = VRWLOCK_WRITE;
- }
-
- xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
-
- isize = xip->i_d.di_size;
- limit = XFS_MAXIOFFSET(mp);
-
- if (file->f_flags & O_APPEND)
- *offset = isize;
-
-start:
- n = limit - *offset;
- if (n <= 0) {
- xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
- return -EFBIG;
- }
-
- if (n < size)
- size = n;
-
- new_size = *offset + size;
- if (new_size > isize) {
- io->io_new_size = new_size;
- }
-
- if ((DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_WRITE) &&
- !(ioflags & IO_INVIS) && !eventsent)) {
- loff_t savedsize = *offset;
- int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
-
- xfs_iunlock(xip, XFS_ILOCK_EXCL);
- error = XFS_SEND_DATA(xip->i_mount, DM_EVENT_WRITE, vp,
- *offset, size,
- dmflags, &locktype);
- if (error) {
- xfs_iunlock(xip, iolock);
- return -error;
- }
- xfs_ilock(xip, XFS_ILOCK_EXCL);
- eventsent = 1;
-
- /*
- * The iolock was dropped and reaquired in XFS_SEND_DATA
- * so we have to recheck the size when appending.
- * We will only "goto start;" once, since having sent the
- * event prevents another call to XFS_SEND_DATA, which is
- * what allows the size to change in the first place.
- */
- if ((file->f_flags & O_APPEND) &&
- savedsize != xip->i_d.di_size) {
- *offset = isize = xip->i_d.di_size;
- goto start;
- }
- }
-
- /*
- * On Linux, generic_file_write updates the times even if
- * no data is copied in so long as the write had a size.
- *
- * We must update xfs' times since revalidate will overcopy xfs.
- */
- if (size && !(ioflags & IO_INVIS))
- xfs_ichgtime(xip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-
- /*
- * If the offset is beyond the size of the file, we have a couple
- * of things to do. First, if there is already space allocated
- * we need to either create holes or zero the disk or ...
- *
- * If there is a page where the previous size lands, we need
- * to zero it out up to the new size.
- */
-
- if (!(ioflags & IO_ISDIRECT) && (*offset > isize && isize)) {
- error = xfs_zero_eof(BHV_TO_VNODE(bdp), io, *offset,
- isize, *offset + size);
- if (error) {
- xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
- return(-error);
- }
- }
- xfs_iunlock(xip, XFS_ILOCK_EXCL);
-
- /*
- * If we're writing the file then make sure to clear the
- * setuid and setgid bits if the process is not being run
- * by root. This keeps people from modifying setuid and
- * setgid binaries.
- */
-
- if (((xip->i_d.di_mode & S_ISUID) ||
- ((xip->i_d.di_mode & (S_ISGID | S_IXGRP)) ==
- (S_ISGID | S_IXGRP))) &&
- !capable(CAP_FSETID)) {
- error = xfs_write_clear_setuid(xip);
- if (error) {
- xfs_iunlock(xip, iolock);
- return -error;
- }
- }
-
-retry:
- if (ioflags & IO_ISDIRECT) {
- xfs_inval_cached_pages(vp, io, *offset, 1, 1);
- xfs_rw_enter_trace(XFS_DIOWR_ENTER,
- io, iovp, segs, *offset, ioflags);
- } else {
- xfs_rw_enter_trace(XFS_WRITE_ENTER,
- io, iovp, segs, *offset, ioflags);
- }
- ret = generic_file_aio_write_nolock(iocb, iovp, segs, offset);
-
- if ((ret == -ENOSPC) &&
- DM_EVENT_ENABLED(vp->v_vfsp, xip, DM_EVENT_NOSPACE) &&
- !(ioflags & IO_INVIS)) {
-
- xfs_rwunlock(bdp, locktype);
- error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
- DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
- 0, 0, 0); /* Delay flag intentionally unused */
- if (error)
- return -error;
- xfs_rwlock(bdp, locktype);
- *offset = xip->i_d.di_size;
- goto retry;
- }
-
- if (*offset > xip->i_d.di_size) {
- xfs_ilock(xip, XFS_ILOCK_EXCL);
- if (*offset > xip->i_d.di_size) {
- struct inode *inode = LINVFS_GET_IP(vp);
-
- xip->i_d.di_size = *offset;
- i_size_write(inode, *offset);
- xip->i_update_core = 1;
- xip->i_update_size = 1;
- }
- xfs_iunlock(xip, XFS_ILOCK_EXCL);
- }
-
- if (ret <= 0) {
- xfs_rwunlock(bdp, locktype);
- return ret;
- }
-
- XFS_STATS_ADD(xs_write_bytes, ret);
-
- /* Handle various SYNC-type writes */
- if ((file->f_flags & O_SYNC) || IS_SYNC(file->f_dentry->d_inode)) {
-
- /*
- * If we're treating this as O_DSYNC and we have not updated the
- * size, force the log.
- */
-
- if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC)
- && !(xip->i_update_size)) {
- /*
- * If an allocation transaction occurred
- * without extending the size, then we have to force
- * the log up the proper point to ensure that the
- * allocation is permanent. We can't count on
- * the fact that buffered writes lock out direct I/O
- * writes - the direct I/O write could have extended
- * the size nontransactionally, then finished before
- * we started. xfs_write_file will think that the file
- * didn't grow but the update isn't safe unless the
- * size change is logged.
- *
- * Force the log if we've committed a transaction
- * against the inode or if someone else has and
- * the commit record hasn't gone to disk (e.g.
- * the inode is pinned). This guarantees that
- * all changes affecting the inode are permanent
- * when we return.
- */
-
- xfs_inode_log_item_t *iip;
- xfs_lsn_t lsn;
-
- iip = xip->i_itemp;
- if (iip && iip->ili_last_lsn) {
- lsn = iip->ili_last_lsn;
- xfs_log_force(mp, lsn,
- XFS_LOG_FORCE | XFS_LOG_SYNC);
- } else if (xfs_ipincount(xip) > 0) {
- xfs_log_force(mp, (xfs_lsn_t)0,
- XFS_LOG_FORCE | XFS_LOG_SYNC);
- }
-
- } else {
- xfs_trans_t *tp;
-
- /*
- * O_SYNC or O_DSYNC _with_ a size update are handled
- * the same way.
- *
- * If the write was synchronous then we need to make
- * sure that the inode modification time is permanent.
- * We'll have updated the timestamp above, so here
- * we use a synchronous transaction to log the inode.
- * It's not fast, but it's necessary.
- *
- * If this a dsync write and the size got changed
- * non-transactionally, then we need to ensure that
- * the size change gets logged in a synchronous
- * transaction.
- */
-
- tp = xfs_trans_alloc(mp, XFS_TRANS_WRITE_SYNC);
- if ((error = xfs_trans_reserve(tp, 0,
- XFS_SWRITE_LOG_RES(mp),
- 0, 0, 0))) {
- /* Transaction reserve failed */
- xfs_trans_cancel(tp, 0);
- } else {
- /* Transaction reserve successful */
- xfs_ilock(xip, XFS_ILOCK_EXCL);
- xfs_trans_ijoin(tp, xip, XFS_ILOCK_EXCL);
- xfs_trans_ihold(tp, xip);
- xfs_trans_log_inode(tp, xip, XFS_ILOG_CORE);
- xfs_trans_set_sync(tp);
- error = xfs_trans_commit(tp, 0, (xfs_lsn_t)0);
- xfs_iunlock(xip, XFS_ILOCK_EXCL);
- }
- }
- } /* (ioflags & O_SYNC) */
-
- xfs_rwunlock(bdp, locktype);
- return(ret);
-}
-
-/*
- * All xfs metadata buffers except log state machine buffers
- * get this attached as their b_bdstrat callback function.
- * This is so that we can catch a buffer
- * after prematurely unpinning it to forcibly shutdown the filesystem.
- */
-int
-xfs_bdstrat_cb(struct xfs_buf *bp)
-{
- xfs_mount_t *mp;
-
- mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *);
- if (!XFS_FORCED_SHUTDOWN(mp)) {
- pagebuf_iorequest(bp);
- return 0;
- } else {
- xfs_buftrace("XFS__BDSTRAT IOERROR", bp);
- /*
- * Metadata write that didn't get logged but
- * written delayed anyway. These aren't associated
- * with a transaction, and can be ignored.
- */
- if (XFS_BUF_IODONE_FUNC(bp) == NULL &&
- (XFS_BUF_ISREAD(bp)) == 0)
- return (xfs_bioerror_relse(bp));
- else
- return (xfs_bioerror(bp));
- }
-}
-
-
-int
-xfs_bmap(bhv_desc_t *bdp,
- xfs_off_t offset,
- ssize_t count,
- int flags,
- xfs_iomap_t *iomapp,
- int *niomaps)
-{
- xfs_inode_t *ip = XFS_BHVTOI(bdp);
- xfs_iocore_t *io = &ip->i_iocore;
-
- ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
- ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
- ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
-
- return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
-}
-
-/*
- * Wrapper around bdstrat so that we can stop data
- * from going to disk in case we are shutting down the filesystem.
- * Typically user data goes thru this path; one of the exceptions
- * is the superblock.
- */
-int
-xfsbdstrat(
- struct xfs_mount *mp,
- struct xfs_buf *bp)
-{
- ASSERT(mp);
- if (!XFS_FORCED_SHUTDOWN(mp)) {
- /* Grio redirection would go here
- * if (XFS_BUF_IS_GRIO(bp)) {
- */
-
- pagebuf_iorequest(bp);
- return 0;
- }
-
- xfs_buftrace("XFSBDSTRAT IOERROR", bp);
- return (xfs_bioerror_relse(bp));
-}
-
-/*
- * If the underlying (data/log/rt) device is readonly, there are some
- * operations that cannot proceed.
- */
-int
-xfs_dev_is_read_only(
- xfs_mount_t *mp,
- char *message)
-{
- if (xfs_readonly_buftarg(mp->m_ddev_targp) ||
- xfs_readonly_buftarg(mp->m_logdev_targp) ||
- (mp->m_rtdev_targp && xfs_readonly_buftarg(mp->m_rtdev_targp))) {
- cmn_err(CE_NOTE,
- "XFS: %s required on read-only device.", message);
- cmn_err(CE_NOTE,
- "XFS: write access unavailable, cannot proceed.");
- return EROFS;
- }
- return 0;
-}
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_LRW_H__
-#define __XFS_LRW_H__
-
-struct vnode;
-struct bhv_desc;
-struct xfs_mount;
-struct xfs_iocore;
-struct xfs_inode;
-struct xfs_bmbt_irec;
-struct xfs_buf;
-struct xfs_iomap;
-
-#if defined(XFS_RW_TRACE)
-/*
- * Defines for the trace mechanisms in xfs_lrw.c.
- */
-#define XFS_RW_KTRACE_SIZE 128
-
-#define XFS_READ_ENTER 1
-#define XFS_WRITE_ENTER 2
-#define XFS_IOMAP_READ_ENTER 3
-#define XFS_IOMAP_WRITE_ENTER 4
-#define XFS_IOMAP_READ_MAP 5
-#define XFS_IOMAP_WRITE_MAP 6
-#define XFS_IOMAP_WRITE_NOSPACE 7
-#define XFS_ITRUNC_START 8
-#define XFS_ITRUNC_FINISH1 9
-#define XFS_ITRUNC_FINISH2 10
-#define XFS_CTRUNC1 11
-#define XFS_CTRUNC2 12
-#define XFS_CTRUNC3 13
-#define XFS_CTRUNC4 14
-#define XFS_CTRUNC5 15
-#define XFS_CTRUNC6 16
-#define XFS_BUNMAPI 17
-#define XFS_INVAL_CACHED 18
-#define XFS_DIORD_ENTER 19
-#define XFS_DIOWR_ENTER 20
-#define XFS_SENDFILE_ENTER 21
-#define XFS_WRITEPAGE_ENTER 22
-#define XFS_RELEASEPAGE_ENTER 23
-#define XFS_IOMAP_ALLOC_ENTER 24
-#define XFS_IOMAP_ALLOC_MAP 25
-#define XFS_IOMAP_UNWRITTEN 26
-extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
- const struct iovec *, size_t, loff_t, int);
-extern void xfs_inval_cached_trace(struct xfs_iocore *,
- xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
-#else
-#define xfs_rw_enter_trace(tag, io, iovec, segs, offset, ioflags)
-#define xfs_inval_cached_trace(io, offset, len, first, last)
-#endif
-
-/*
- * Maximum count of bmaps used by read and write paths.
- */
-#define XFS_MAX_RW_NBMAPS 4
-
-extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
- struct xfs_iomap *, int *);
-extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
-extern int xfs_bdstrat_cb(struct xfs_buf *);
-
-extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
- xfs_fsize_t, xfs_fsize_t);
-extern void xfs_inval_cached_pages(struct vnode *, struct xfs_iocore *,
- xfs_off_t, int, int);
-extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
- const struct iovec *, unsigned int,
- loff_t *, int, struct cred *);
-extern ssize_t xfs_write(struct bhv_desc *, struct kiocb *,
- const struct iovec *, unsigned int,
- loff_t *, int, struct cred *);
-extern ssize_t xfs_sendfile(struct bhv_desc *, struct file *,
- loff_t *, int, size_t, read_actor_t,
- void *, struct cred *);
-
-extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
-
-#define XFS_FSB_TO_DB_IO(io,fsb) \
- (((io)->io_flags & XFS_IOCORE_RT) ? \
- XFS_FSB_TO_BB((io)->io_mount, (fsb)) : \
- XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
-
-#endif /* __XFS_LRW_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include <linux/proc_fs.h>
-
-DEFINE_PER_CPU(struct xfsstats, xfsstats);
-
-STATIC int
-xfs_read_xfsstats(
- char *buffer,
- char **start,
- off_t offset,
- int count,
- int *eof,
- void *data)
-{
- int c, i, j, len, val;
- __uint64_t xs_xstrat_bytes = 0;
- __uint64_t xs_write_bytes = 0;
- __uint64_t xs_read_bytes = 0;
-
- static struct xstats_entry {
- char *desc;
- int endpoint;
- } xstats[] = {
- { "extent_alloc", XFSSTAT_END_EXTENT_ALLOC },
- { "abt", XFSSTAT_END_ALLOC_BTREE },
- { "blk_map", XFSSTAT_END_BLOCK_MAPPING },
- { "bmbt", XFSSTAT_END_BLOCK_MAP_BTREE },
- { "dir", XFSSTAT_END_DIRECTORY_OPS },
- { "trans", XFSSTAT_END_TRANSACTIONS },
- { "ig", XFSSTAT_END_INODE_OPS },
- { "log", XFSSTAT_END_LOG_OPS },
- { "push_ail", XFSSTAT_END_TAIL_PUSHING },
- { "xstrat", XFSSTAT_END_WRITE_CONVERT },
- { "rw", XFSSTAT_END_READ_WRITE_OPS },
- { "attr", XFSSTAT_END_ATTRIBUTE_OPS },
- { "icluster", XFSSTAT_END_INODE_CLUSTER },
- { "vnodes", XFSSTAT_END_VNODE_OPS },
- { "buf", XFSSTAT_END_BUF },
- };
-
- /* Loop over all stats groups */
- for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
- len += sprintf(buffer + len, xstats[i].desc);
- /* inner loop does each group */
- while (j < xstats[i].endpoint) {
- val = 0;
- /* sum over all cpus */
- for (c = 0; c < NR_CPUS; c++) {
- if (!cpu_possible(c)) continue;
- val += *(((__u32*)&per_cpu(xfsstats, c) + j));
- }
- len += sprintf(buffer + len, " %u", val);
- j++;
- }
- buffer[len++] = '\n';
- }
- /* extra precision counters */
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_possible(i)) continue;
- xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
- xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
- xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
- }
-
- len += sprintf(buffer + len, "xpc %Lu %Lu %Lu\n",
- xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
- len += sprintf(buffer + len, "debug %u\n",
-#if defined(XFSDEBUG)
- 1);
-#else
- 0);
-#endif
-
- if (offset >= len) {
- *start = buffer;
- *eof = 1;
- return 0;
- }
- *start = buffer + offset;
- if ((len -= offset) > count)
- return count;
- *eof = 1;
-
- return len;
-}
-
-void
-xfs_init_procfs(void)
-{
- if (!proc_mkdir("fs/xfs", 0))
- return;
- create_proc_read_entry("fs/xfs/stat", 0, 0, xfs_read_xfsstats, NULL);
-}
-
-void
-xfs_cleanup_procfs(void)
-{
- remove_proc_entry("fs/xfs/stat", NULL);
- remove_proc_entry("fs/xfs", NULL);
-}
+++ /dev/null
-/*
- * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_STATS_H__
-#define __XFS_STATS_H__
-
-
-#if defined(CONFIG_PROC_FS) && !defined(XFS_STATS_OFF)
-
-#include <linux/percpu.h>
-
-/*
- * XFS global statistics
- */
-struct xfsstats {
-# define XFSSTAT_END_EXTENT_ALLOC 4
- __uint32_t xs_allocx;
- __uint32_t xs_allocb;
- __uint32_t xs_freex;
- __uint32_t xs_freeb;
-# define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4)
- __uint32_t xs_abt_lookup;
- __uint32_t xs_abt_compare;
- __uint32_t xs_abt_insrec;
- __uint32_t xs_abt_delrec;
-# define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7)
- __uint32_t xs_blk_mapr;
- __uint32_t xs_blk_mapw;
- __uint32_t xs_blk_unmap;
- __uint32_t xs_add_exlist;
- __uint32_t xs_del_exlist;
- __uint32_t xs_look_exlist;
- __uint32_t xs_cmp_exlist;
-# define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4)
- __uint32_t xs_bmbt_lookup;
- __uint32_t xs_bmbt_compare;
- __uint32_t xs_bmbt_insrec;
- __uint32_t xs_bmbt_delrec;
-# define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4)
- __uint32_t xs_dir_lookup;
- __uint32_t xs_dir_create;
- __uint32_t xs_dir_remove;
- __uint32_t xs_dir_getdents;
-# define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3)
- __uint32_t xs_trans_sync;
- __uint32_t xs_trans_async;
- __uint32_t xs_trans_empty;
-# define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7)
- __uint32_t xs_ig_attempts;
- __uint32_t xs_ig_found;
- __uint32_t xs_ig_frecycle;
- __uint32_t xs_ig_missed;
- __uint32_t xs_ig_dup;
- __uint32_t xs_ig_reclaims;
- __uint32_t xs_ig_attrchg;
-# define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5)
- __uint32_t xs_log_writes;
- __uint32_t xs_log_blocks;
- __uint32_t xs_log_noiclogs;
- __uint32_t xs_log_force;
- __uint32_t xs_log_force_sleep;
-# define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10)
- __uint32_t xs_try_logspace;
- __uint32_t xs_sleep_logspace;
- __uint32_t xs_push_ail;
- __uint32_t xs_push_ail_success;
- __uint32_t xs_push_ail_pushbuf;
- __uint32_t xs_push_ail_pinned;
- __uint32_t xs_push_ail_locked;
- __uint32_t xs_push_ail_flushing;
- __uint32_t xs_push_ail_restarts;
- __uint32_t xs_push_ail_flush;
-# define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2)
- __uint32_t xs_xstrat_quick;
- __uint32_t xs_xstrat_split;
-# define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2)
- __uint32_t xs_write_calls;
- __uint32_t xs_read_calls;
-# define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4)
- __uint32_t xs_attr_get;
- __uint32_t xs_attr_set;
- __uint32_t xs_attr_remove;
- __uint32_t xs_attr_list;
-# define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3)
- __uint32_t xs_iflush_count;
- __uint32_t xs_icluster_flushcnt;
- __uint32_t xs_icluster_flushinode;
-# define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8)
- __uint32_t vn_active; /* # vnodes not on free lists */
- __uint32_t vn_alloc; /* # times vn_alloc called */
- __uint32_t vn_get; /* # times vn_get called */
- __uint32_t vn_hold; /* # times vn_hold called */
- __uint32_t vn_rele; /* # times vn_rele called */
- __uint32_t vn_reclaim; /* # times vn_reclaim called */
- __uint32_t vn_remove; /* # times vn_remove called */
- __uint32_t vn_free; /* # times vn_free called */
-#define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9)
- __uint32_t pb_get;
- __uint32_t pb_create;
- __uint32_t pb_get_locked;
- __uint32_t pb_get_locked_waited;
- __uint32_t pb_busy_locked;
- __uint32_t pb_miss_locked;
- __uint32_t pb_page_retries;
- __uint32_t pb_page_found;
- __uint32_t pb_get_read;
-/* Extra precision counters */
- __uint64_t xs_xstrat_bytes;
- __uint64_t xs_write_bytes;
- __uint64_t xs_read_bytes;
-};
-
-DECLARE_PER_CPU(struct xfsstats, xfsstats);
-
-/* We don't disable preempt, not too worried about poking the
- * wrong cpu's stat for now */
-#define XFS_STATS_INC(count) (__get_cpu_var(xfsstats).count++)
-#define XFS_STATS_DEC(count) (__get_cpu_var(xfsstats).count--)
-#define XFS_STATS_ADD(count, inc) (__get_cpu_var(xfsstats).count += (inc))
-
-extern void xfs_init_procfs(void);
-extern void xfs_cleanup_procfs(void);
-
-
-#else /* !CONFIG_PROC_FS */
-
-# define XFS_STATS_INC(count)
-# define XFS_STATS_DEC(count)
-# define XFS_STATS_ADD(count, inc)
-
-static __inline void xfs_init_procfs(void) { };
-static __inline void xfs_cleanup_procfs(void) { };
-
-#endif /* !CONFIG_PROC_FS */
-
-#endif /* __XFS_STATS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_clnt.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_quota.h"
-#include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_bmap.h"
-#include "xfs_bit.h"
-#include "xfs_rtalloc.h"
-#include "xfs_error.h"
-#include "xfs_itable.h"
-#include "xfs_rw.h"
-#include "xfs_acl.h"
-#include "xfs_cap.h"
-#include "xfs_mac.h"
-#include "xfs_attr.h"
-#include "xfs_buf_item.h"
-#include "xfs_utils.h"
-#include "xfs_version.h"
-
-#include <linux/namei.h>
-#include <linux/init.h>
-#include <linux/mount.h>
-#include <linux/suspend.h>
-
-STATIC struct quotactl_ops linvfs_qops;
-STATIC struct super_operations linvfs_sops;
-STATIC struct export_operations linvfs_export_ops;
-STATIC kmem_cache_t * linvfs_inode_cachep;
-
-STATIC struct xfs_mount_args *
-xfs_args_allocate(
- struct super_block *sb)
-{
- struct xfs_mount_args *args;
-
- args = kmem_zalloc(sizeof(struct xfs_mount_args), KM_SLEEP);
- args->logbufs = args->logbufsize = -1;
- strncpy(args->fsname, sb->s_id, MAXNAMELEN);
-
- /* Copy the already-parsed mount(2) flags we're interested in */
- if (sb->s_flags & MS_NOATIME)
- args->flags |= XFSMNT_NOATIME;
-
- /* Default to 32 bit inodes on Linux all the time */
- args->flags |= XFSMNT_32BITINODES;
-
- return args;
-}
-
-__uint64_t
-xfs_max_file_offset(
- unsigned int blockshift)
-{
- unsigned int pagefactor = 1;
- unsigned int bitshift = BITS_PER_LONG - 1;
-
- /* Figure out maximum filesize, on Linux this can depend on
- * the filesystem blocksize (on 32 bit platforms).
- * __block_prepare_write does this in an [unsigned] long...
- * page->index << (PAGE_CACHE_SHIFT - bbits)
- * So, for page sized blocks (4K on 32 bit platforms),
- * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is
- * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
- * but for smaller blocksizes it is less (bbits = log2 bsize).
- * Note1: get_block_t takes a long (implicit cast from above)
- * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch
- * can optionally convert the [unsigned] long from above into
- * an [unsigned] long long.
- */
-
-#if BITS_PER_LONG == 32
-# if defined(CONFIG_LBD)
- ASSERT(sizeof(sector_t) == 8);
- pagefactor = PAGE_CACHE_SIZE;
- bitshift = BITS_PER_LONG;
-# else
- pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift);
-# endif
-#endif
-
- return (((__uint64_t)pagefactor) << bitshift) - 1;
-}
-
-STATIC __inline__ void
-xfs_set_inodeops(
- struct inode *inode)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
-
- if (vp->v_type == VNON) {
- make_bad_inode(inode);
- } else if (S_ISREG(inode->i_mode)) {
- inode->i_op = &linvfs_file_inode_operations;
- inode->i_fop = &linvfs_file_operations;
- inode->i_mapping->a_ops = &linvfs_aops;
- } else if (S_ISDIR(inode->i_mode)) {
- inode->i_op = &linvfs_dir_inode_operations;
- inode->i_fop = &linvfs_dir_operations;
- } else if (S_ISLNK(inode->i_mode)) {
- inode->i_op = &linvfs_symlink_inode_operations;
- if (inode->i_blocks)
- inode->i_mapping->a_ops = &linvfs_aops;
- } else {
- inode->i_op = &linvfs_file_inode_operations;
- init_special_inode(inode, inode->i_mode, inode->i_rdev);
- }
-}
-
-STATIC __inline__ void
-xfs_revalidate_inode(
- xfs_mount_t *mp,
- vnode_t *vp,
- xfs_inode_t *ip)
-{
- struct inode *inode = LINVFS_GET_IP(vp);
-
- inode->i_mode = (ip->i_d.di_mode & MODEMASK) | VTTOIF(vp->v_type);
- inode->i_nlink = ip->i_d.di_nlink;
- inode->i_uid = ip->i_d.di_uid;
- inode->i_gid = ip->i_d.di_gid;
- if (((1 << vp->v_type) & ((1<<VBLK) | (1<<VCHR))) == 0) {
- inode->i_rdev = 0;
- } else {
- xfs_dev_t dev = ip->i_df.if_u2.if_rdev;
- inode->i_rdev = MKDEV(sysv_major(dev) & 0x1ff, sysv_minor(dev));
- }
- inode->i_blksize = PAGE_CACHE_SIZE;
- inode->i_generation = ip->i_d.di_gen;
- i_size_write(inode, ip->i_d.di_size);
- inode->i_blocks =
- XFS_FSB_TO_BB(mp, ip->i_d.di_nblocks + ip->i_delayed_blks);
- inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
- inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
- inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
- inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
- inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
- inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
- if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
- inode->i_flags |= S_IMMUTABLE;
- else
- inode->i_flags &= ~S_IMMUTABLE;
- if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
- inode->i_flags |= S_APPEND;
- else
- inode->i_flags &= ~S_APPEND;
- if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
- inode->i_flags |= S_SYNC;
- else
- inode->i_flags &= ~S_SYNC;
- if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
- inode->i_flags |= S_NOATIME;
- else
- inode->i_flags &= ~S_NOATIME;
- vp->v_flag &= ~VMODIFIED;
-}
-
-void
-xfs_initialize_vnode(
- bhv_desc_t *bdp,
- vnode_t *vp,
- bhv_desc_t *inode_bhv,
- int unlock)
-{
- xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
- struct inode *inode = LINVFS_GET_IP(vp);
-
- if (!inode_bhv->bd_vobj) {
- vp->v_vfsp = bhvtovfs(bdp);
- bhv_desc_init(inode_bhv, ip, vp, &xfs_vnodeops);
- bhv_insert(VN_BHV_HEAD(vp), inode_bhv);
- }
-
- vp->v_type = IFTOVT(ip->i_d.di_mode);
-
- /* Have we been called during the new inode create process,
- * in which case we are too early to fill in the Linux inode.
- */
- if (vp->v_type == VNON)
- return;
-
- xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
-
- /* For new inodes we need to set the ops vectors,
- * and unlock the inode.
- */
- if (unlock && (inode->i_state & I_NEW)) {
- xfs_set_inodeops(inode);
- unlock_new_inode(inode);
- }
-}
-
-void
-xfs_flush_inode(
- xfs_inode_t *ip)
-{
- struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
-
- filemap_flush(inode->i_mapping);
-}
-
-void
-xfs_flush_device(
- xfs_inode_t *ip)
-{
- sync_blockdev(XFS_ITOV(ip)->v_vfsp->vfs_super->s_bdev);
- xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
-}
-
-int
-xfs_blkdev_get(
- xfs_mount_t *mp,
- const char *name,
- struct block_device **bdevp)
-{
- int error = 0;
-
- *bdevp = open_bdev_excl(name, 0, mp);
- if (IS_ERR(*bdevp)) {
- error = PTR_ERR(*bdevp);
- printk("XFS: Invalid device [%s], error=%d\n", name, error);
- }
-
- return -error;
-}
-
-void
-xfs_blkdev_put(
- struct block_device *bdev)
-{
- if (bdev)
- close_bdev_excl(bdev);
-}
-
-
-STATIC struct inode *
-linvfs_alloc_inode(
- struct super_block *sb)
-{
- vnode_t *vp;
-
- vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_cachep,
- kmem_flags_convert(KM_SLEEP));
- if (!vp)
- return NULL;
- return LINVFS_GET_IP(vp);
-}
-
-STATIC void
-linvfs_destroy_inode(
- struct inode *inode)
-{
- kmem_cache_free(linvfs_inode_cachep, LINVFS_GET_VP(inode));
-}
-
-STATIC void
-init_once(
- void *data,
- kmem_cache_t *cachep,
- unsigned long flags)
-{
- vnode_t *vp = (vnode_t *)data;
-
- if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
- SLAB_CTOR_CONSTRUCTOR)
- inode_init_once(LINVFS_GET_IP(vp));
-}
-
-STATIC int
-init_inodecache( void )
-{
- linvfs_inode_cachep = kmem_cache_create("linvfs_icache",
- sizeof(vnode_t), 0,
- SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- init_once, NULL);
-
- if (linvfs_inode_cachep == NULL)
- return -ENOMEM;
- return 0;
-}
-
-STATIC void
-destroy_inodecache( void )
-{
- if (kmem_cache_destroy(linvfs_inode_cachep))
- printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__);
-}
-
-/*
- * Attempt to flush the inode, this will actually fail
- * if the inode is pinned, but we dirty the inode again
- * at the point when it is unpinned after a log write,
- * since this is when the inode itself becomes flushable.
- */
-STATIC void
-linvfs_write_inode(
- struct inode *inode,
- int sync)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
- int error, flags = FLUSH_INODE;
-
- if (vp) {
- vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
- if (sync)
- flags |= FLUSH_SYNC;
- VOP_IFLUSH(vp, flags, error);
- }
-}
-
-STATIC void
-linvfs_clear_inode(
- struct inode *inode)
-{
- vnode_t *vp = LINVFS_GET_VP(inode);
-
- if (vp) {
- vn_rele(vp);
- vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
- /*
- * Do all our cleanup, and remove this vnode.
- */
- vn_remove(vp);
- }
-}
-
-
-#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR)
-
-STATIC int
-xfssyncd(
- void *arg)
-{
- vfs_t *vfsp = (vfs_t *) arg;
- int error;
-
- daemonize("xfssyncd");
-
- vfsp->vfs_sync_task = current;
- wmb();
- wake_up(&vfsp->vfs_wait_sync_task);
-
- for (;;) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(xfs_syncd_interval);
- /* swsusp */
- if (current->flags & PF_FREEZE)
- refrigerator(PF_FREEZE);
- if (vfsp->vfs_flag & VFS_UMOUNT)
- break;
- if (vfsp->vfs_flag & VFS_RDONLY)
- continue;
- VFS_SYNC(vfsp, SYNCD_FLAGS, NULL, error);
- }
-
- vfsp->vfs_sync_task = NULL;
- wmb();
- wake_up(&vfsp->vfs_wait_sync_task);
-
- return 0;
-}
-
-STATIC int
-linvfs_start_syncd(
- vfs_t *vfsp)
-{
- int pid;
-
- pid = kernel_thread(xfssyncd, (void *) vfsp,
- CLONE_VM | CLONE_FS | CLONE_FILES);
- if (pid < 0)
- return -pid;
- wait_event(vfsp->vfs_wait_sync_task, vfsp->vfs_sync_task);
- return 0;
-}
-
-STATIC void
-linvfs_stop_syncd(
- vfs_t *vfsp)
-{
- vfsp->vfs_flag |= VFS_UMOUNT;
- wmb();
-
- wake_up_process(vfsp->vfs_sync_task);
- wait_event(vfsp->vfs_wait_sync_task, !vfsp->vfs_sync_task);
-}
-
-STATIC void
-linvfs_put_super(
- struct super_block *sb)
-{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- linvfs_stop_syncd(vfsp);
- VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
- if (!error)
- VFS_UNMOUNT(vfsp, 0, NULL, error);
- if (error) {
- printk("XFS unmount got error %d\n", error);
- printk("%s: vfsp/0x%p left dangling!\n", __FUNCTION__, vfsp);
- return;
- }
-
- vfs_deallocate(vfsp);
-}
-
-STATIC void
-linvfs_write_super(
- struct super_block *sb)
-{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- if (sb->s_flags & MS_RDONLY) {
- sb->s_dirt = 0; /* paranoia */
- return;
- }
- /* Push the log and superblock a little */
- VFS_SYNC(vfsp, SYNC_FSDATA, NULL, error);
- sb->s_dirt = 0;
-}
-
-STATIC int
-linvfs_sync_super(
- struct super_block *sb,
- int wait)
-{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- int error;
- int flags = SYNC_FSDATA;
-
- if (wait)
- flags |= SYNC_WAIT;
-
- VFS_SYNC(vfsp, flags, NULL, error);
- sb->s_dirt = 0;
-
- return -error;
-}
-
-STATIC int
-linvfs_statfs(
- struct super_block *sb,
- struct kstatfs *statp)
-{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- VFS_STATVFS(vfsp, statp, NULL, error);
- return -error;
-}
-
-STATIC int
-linvfs_remount(
- struct super_block *sb,
- int *flags,
- char *options)
-{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- struct xfs_mount_args *args = xfs_args_allocate(sb);
- int error;
-
- VFS_PARSEARGS(vfsp, options, args, 1, error);
- if (!error)
- VFS_MNTUPDATE(vfsp, flags, args, error);
- kmem_free(args, sizeof(*args));
- return -error;
-}
-
-STATIC void
-linvfs_freeze_fs(
- struct super_block *sb)
-{
- VFS_FREEZE(LINVFS_GET_VFS(sb));
-}
-
-STATIC struct dentry *
-linvfs_get_parent(
- struct dentry *child)
-{
- int error;
- vnode_t *vp, *cvp;
- struct dentry *parent;
- struct inode *ip = NULL;
- struct dentry dotdot;
-
- dotdot.d_name.name = "..";
- dotdot.d_name.len = 2;
- dotdot.d_inode = 0;
-
- cvp = NULL;
- vp = LINVFS_GET_VP(child->d_inode);
- VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
-
- if (!error) {
- ASSERT(cvp);
- ip = LINVFS_GET_IP(cvp);
- if (!ip) {
- VN_RELE(cvp);
- return ERR_PTR(-EACCES);
- }
- }
- if (error)
- return ERR_PTR(-error);
- parent = d_alloc_anon(ip);
- if (!parent) {
- VN_RELE(cvp);
- parent = ERR_PTR(-ENOMEM);
- }
- return parent;
-}
-
-STATIC struct dentry *
-linvfs_get_dentry(
- struct super_block *sb,
- void *data)
-{
- vnode_t *vp;
- struct inode *inode;
- struct dentry *result;
- xfs_fid2_t xfid;
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- xfid.fid_len = sizeof(xfs_fid2_t) - sizeof(xfid.fid_len);
- xfid.fid_pad = 0;
- xfid.fid_gen = ((__u32 *)data)[1];
- xfid.fid_ino = ((__u32 *)data)[0];
-
- VFS_VGET(vfsp, &vp, (fid_t *)&xfid, error);
- if (error || vp == NULL)
- return ERR_PTR(-ESTALE) ;
-
- inode = LINVFS_GET_IP(vp);
- result = d_alloc_anon(inode);
- if (!result) {
- iput(inode);
- return ERR_PTR(-ENOMEM);
- }
- return result;
-}
-
-STATIC int
-linvfs_show_options(
- struct seq_file *m,
- struct vfsmount *mnt)
-{
- struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb);
- int error;
-
- VFS_SHOWARGS(vfsp, m, error);
- return error;
-}
-
-STATIC int
-linvfs_getxstate(
- struct super_block *sb,
- struct fs_quota_stat *fqs)
-{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
- return -error;
-}
-
-STATIC int
-linvfs_setxstate(
- struct super_block *sb,
- unsigned int flags,
- int op)
-{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
- int error;
-
- VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
- return -error;
-}
-
-STATIC int
-linvfs_getxquota(
- struct super_block *sb,
- int type,
- qid_t id,
- struct fs_disk_quota *fdq)
-{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
- int error, getmode;
-
- getmode = (type == GRPQUOTA) ? Q_XGETGQUOTA : Q_XGETQUOTA;
- VFS_QUOTACTL(vfsp, getmode, id, (caddr_t)fdq, error);
- return -error;
-}
-
-STATIC int
-linvfs_setxquota(
- struct super_block *sb,
- int type,
- qid_t id,
- struct fs_disk_quota *fdq)
-{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
- int error, setmode;
-
- setmode = (type == GRPQUOTA) ? Q_XSETGQLIM : Q_XSETQLIM;
- VFS_QUOTACTL(vfsp, setmode, id, (caddr_t)fdq, error);
- return -error;
-}
-
-STATIC int
-linvfs_fill_super(
- struct super_block *sb,
- void *data,
- int silent)
-{
- vnode_t *rootvp;
- struct vfs *vfsp = vfs_allocate();
- struct xfs_mount_args *args = xfs_args_allocate(sb);
- struct kstatfs statvfs;
- int error, error2;
-
- vfsp->vfs_super = sb;
- LINVFS_SET_VFS(sb, vfsp);
- if (sb->s_flags & MS_RDONLY)
- vfsp->vfs_flag |= VFS_RDONLY;
- bhv_insert_all_vfsops(vfsp);
-
- VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
- if (error) {
- bhv_remove_all_vfsops(vfsp, 1);
- goto fail_vfsop;
- }
-
- sb_min_blocksize(sb, BBSIZE);
- sb->s_export_op = &linvfs_export_ops;
- sb->s_qcop = &linvfs_qops;
- sb->s_op = &linvfs_sops;
-
- VFS_MOUNT(vfsp, args, NULL, error);
- if (error) {
- bhv_remove_all_vfsops(vfsp, 1);
- goto fail_vfsop;
- }
-
- VFS_STATVFS(vfsp, &statvfs, NULL, error);
- if (error)
- goto fail_unmount;
-
- sb->s_dirt = 1;
- sb->s_magic = statvfs.f_type;
- sb->s_blocksize = statvfs.f_bsize;
- sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1;
- sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
- set_posix_acl_flag(sb);
-
- VFS_ROOT(vfsp, &rootvp, error);
- if (error)
- goto fail_unmount;
-
- sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp));
- if (!sb->s_root) {
- error = ENOMEM;
- goto fail_vnrele;
- }
- if (is_bad_inode(sb->s_root->d_inode)) {
- error = EINVAL;
- goto fail_vnrele;
- }
- if ((error = linvfs_start_syncd(vfsp)))
- goto fail_vnrele;
- vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
-
- kmem_free(args, sizeof(*args));
- return 0;
-
-fail_vnrele:
- if (sb->s_root) {
- dput(sb->s_root);
- sb->s_root = NULL;
- } else {
- VN_RELE(rootvp);
- }
-
-fail_unmount:
- VFS_UNMOUNT(vfsp, 0, NULL, error2);
-
-fail_vfsop:
- vfs_deallocate(vfsp);
- kmem_free(args, sizeof(*args));
- return -error;
-}
-
-STATIC struct super_block *
-linvfs_get_sb(
- struct file_system_type *fs_type,
- int flags,
- const char *dev_name,
- void *data)
-{
- return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super);
-}
-
-
-STATIC struct export_operations linvfs_export_ops = {
- .get_parent = linvfs_get_parent,
- .get_dentry = linvfs_get_dentry,
-};
-
-STATIC struct super_operations linvfs_sops = {
- .alloc_inode = linvfs_alloc_inode,
- .destroy_inode = linvfs_destroy_inode,
- .write_inode = linvfs_write_inode,
- .clear_inode = linvfs_clear_inode,
- .put_super = linvfs_put_super,
- .write_super = linvfs_write_super,
- .sync_fs = linvfs_sync_super,
- .write_super_lockfs = linvfs_freeze_fs,
- .statfs = linvfs_statfs,
- .remount_fs = linvfs_remount,
- .show_options = linvfs_show_options,
-};
-
-STATIC struct quotactl_ops linvfs_qops = {
- .get_xstate = linvfs_getxstate,
- .set_xstate = linvfs_setxstate,
- .get_xquota = linvfs_getxquota,
- .set_xquota = linvfs_setxquota,
-};
-
-STATIC struct file_system_type xfs_fs_type = {
- .owner = THIS_MODULE,
- .name = "xfs",
- .get_sb = linvfs_get_sb,
- .kill_sb = kill_block_super,
- .fs_flags = FS_REQUIRES_DEV,
-};
-
-
-STATIC int __init
-init_xfs_fs( void )
-{
- int error;
- struct sysinfo si;
- static char message[] __initdata = KERN_INFO \
- XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
-
- printk(message);
-
- si_meminfo(&si);
- xfs_physmem = si.totalram;
-
- ktrace_init(64);
-
- error = init_inodecache();
- if (error < 0)
- goto undo_inodecache;
-
- error = pagebuf_init();
- if (error < 0)
- goto undo_pagebuf;
-
- vn_init();
- xfs_init();
- uuid_init();
- vfs_initdmapi();
- vfs_initquota();
-
- error = register_filesystem(&xfs_fs_type);
- if (error)
- goto undo_register;
- return 0;
-
-undo_register:
- pagebuf_terminate();
-
-undo_pagebuf:
- destroy_inodecache();
-
-undo_inodecache:
- return error;
-}
-
-STATIC void __exit
-exit_xfs_fs( void )
-{
- vfs_exitquota();
- vfs_exitdmapi();
- unregister_filesystem(&xfs_fs_type);
- xfs_cleanup();
- pagebuf_terminate();
- destroy_inodecache();
- ktrace_uninit();
-}
-
-module_init(init_xfs_fs);
-module_exit(exit_xfs_fs);
-
-MODULE_AUTHOR("Silicon Graphics, Inc.");
-MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_SUPER_H__
-#define __XFS_SUPER_H__
-
-#ifdef CONFIG_XFS_DMAPI
-# define vfs_insertdmapi(vfs) vfs_insertops(vfsp, &xfs_dmops)
-# define vfs_initdmapi() dmapi_init()
-# define vfs_exitdmapi() dmapi_uninit()
-#else
-# define vfs_insertdmapi(vfs) do { } while (0)
-# define vfs_initdmapi() do { } while (0)
-# define vfs_exitdmapi() do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_QUOTA
-# define vfs_insertquota(vfs) vfs_insertops(vfsp, &xfs_qmops)
-extern void xfs_qm_init(void);
-extern void xfs_qm_exit(void);
-# define vfs_initquota() xfs_qm_init()
-# define vfs_exitquota() xfs_qm_exit()
-#else
-# define vfs_insertquota(vfs) do { } while (0)
-# define vfs_initquota() do { } while (0)
-# define vfs_exitquota() do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_POSIX_ACL
-# define XFS_ACL_STRING "ACLs, "
-# define set_posix_acl_flag(sb) ((sb)->s_flags |= MS_POSIXACL)
-#else
-# define XFS_ACL_STRING
-# define set_posix_acl_flag(sb) do { } while (0)
-#endif
-
-#ifdef CONFIG_XFS_SECURITY
-# define XFS_SECURITY_STRING "security attributes, "
-# define ENOSECURITY 0
-#else
-# define XFS_SECURITY_STRING
-# define ENOSECURITY EOPNOTSUPP
-#endif
-
-#ifdef CONFIG_XFS_RT
-# define XFS_REALTIME_STRING "realtime, "
-#else
-# define XFS_REALTIME_STRING
-#endif
-
-#if XFS_BIG_BLKNOS
-# if XFS_BIG_INUMS
-# define XFS_BIGFS_STRING "large block/inode numbers, "
-# else
-# define XFS_BIGFS_STRING "large block numbers, "
-# endif
-#else
-# define XFS_BIGFS_STRING
-#endif
-
-#ifdef CONFIG_XFS_TRACE
-# define XFS_TRACE_STRING "tracing, "
-#else
-# define XFS_TRACE_STRING
-#endif
-
-#ifdef XFSDEBUG
-# define XFS_DBG_STRING "debug"
-#else
-# define XFS_DBG_STRING "no debug"
-#endif
-
-#define XFS_BUILD_OPTIONS XFS_ACL_STRING \
- XFS_SECURITY_STRING \
- XFS_REALTIME_STRING \
- XFS_BIGFS_STRING \
- XFS_TRACE_STRING \
- XFS_DBG_STRING /* DBG must be last */
-
-#define LINVFS_GET_VFS(s) \
- (vfs_t *)((s)->s_fs_info)
-#define LINVFS_SET_VFS(s, vfsp) \
- ((s)->s_fs_info = vfsp)
-
-struct xfs_inode;
-struct xfs_mount;
-struct xfs_buftarg;
-struct block_device;
-
-extern __uint64_t xfs_max_file_offset(unsigned int);
-
-extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
-
-extern void xfs_flush_inode(struct xfs_inode *);
-extern void xfs_flush_device(struct xfs_inode *);
-
-extern int xfs_blkdev_get(struct xfs_mount *, const char *,
- struct block_device **);
-extern void xfs_blkdev_put(struct block_device *);
-
-#endif /* __XFS_SUPER_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_rw.h"
-#include <linux/sysctl.h>
-#include <linux/proc_fs.h>
-
-
-static struct ctl_table_header *xfs_table_header;
-
-
-#ifdef CONFIG_PROC_FS
-STATIC int
-xfs_stats_clear_proc_handler(
- ctl_table *ctl,
- int write,
- struct file *filp,
- void *buffer,
- size_t *lenp)
-{
- int c, ret, *valp = ctl->data;
- __uint32_t vn_active;
-
- ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
-
- if (!ret && write && *valp) {
- printk("XFS Clearing xfsstats\n");
- for (c = 0; c < NR_CPUS; c++) {
- if (!cpu_possible(c)) continue;
- preempt_disable();
- /* save vn_active, it's a universal truth! */
- vn_active = per_cpu(xfsstats, c).vn_active;
- memset(&per_cpu(xfsstats, c), 0,
- sizeof(struct xfsstats));
- per_cpu(xfsstats, c).vn_active = vn_active;
- preempt_enable();
- }
- xfs_stats_clear = 0;
- }
-
- return ret;
-}
-#endif /* CONFIG_PROC_FS */
-
-STATIC ctl_table xfs_table[] = {
- {XFS_RESTRICT_CHOWN, "restrict_chown", &xfs_params.restrict_chown.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.restrict_chown.min, &xfs_params.restrict_chown.max},
-
- {XFS_SGID_INHERIT, "irix_sgid_inherit", &xfs_params.sgid_inherit.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.sgid_inherit.min, &xfs_params.sgid_inherit.max},
-
- {XFS_SYMLINK_MODE, "irix_symlink_mode", &xfs_params.symlink_mode.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.symlink_mode.min, &xfs_params.symlink_mode.max},
-
- {XFS_PANIC_MASK, "panic_mask", &xfs_params.panic_mask.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.panic_mask.min, &xfs_params.panic_mask.max},
-
- {XFS_ERRLEVEL, "error_level", &xfs_params.error_level.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.error_level.min, &xfs_params.error_level.max},
-
- {XFS_SYNC_INTERVAL, "sync_interval", &xfs_params.sync_interval.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.sync_interval.min, &xfs_params.sync_interval.max},
-
- {XFS_INHERIT_SYNC, "inherit_sync", &xfs_params.inherit_sync.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.inherit_sync.min, &xfs_params.inherit_sync.max},
-
- {XFS_INHERIT_NODUMP, "inherit_nodump", &xfs_params.inherit_nodump.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.inherit_nodump.min, &xfs_params.inherit_nodump.max},
-
- {XFS_INHERIT_NOATIME, "inherit_noatime", &xfs_params.inherit_noatim.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.inherit_noatim.min, &xfs_params.inherit_noatim.max},
-
- {XFS_FLUSH_INTERVAL, "flush_interval", &xfs_params.flush_interval.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.flush_interval.min, &xfs_params.flush_interval.max},
-
- {XFS_AGE_BUFFER, "age_buffer", &xfs_params.age_buffer.val,
- sizeof(int), 0644, NULL, &proc_dointvec_minmax,
- &sysctl_intvec, NULL,
- &xfs_params.age_buffer.min, &xfs_params.age_buffer.max},
-
- /* please keep this the last entry */
-#ifdef CONFIG_PROC_FS
- {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
- sizeof(int), 0644, NULL, &xfs_stats_clear_proc_handler,
- &sysctl_intvec, NULL,
- &xfs_params.stats_clear.min, &xfs_params.stats_clear.max},
-#endif /* CONFIG_PROC_FS */
-
- {0}
-};
-
-STATIC ctl_table xfs_dir_table[] = {
- {FS_XFS, "xfs", NULL, 0, 0555, xfs_table},
- {0}
-};
-
-STATIC ctl_table xfs_root_table[] = {
- {CTL_FS, "fs", NULL, 0, 0555, xfs_dir_table},
- {0}
-};
-
-void
-xfs_sysctl_register(void)
-{
- xfs_table_header = register_sysctl_table(xfs_root_table, 1);
-}
-
-void
-xfs_sysctl_unregister(void)
-{
- if (xfs_table_header)
- unregister_sysctl_table(xfs_table_header);
-}
+++ /dev/null
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#ifndef __XFS_SYSCTL_H__
-#define __XFS_SYSCTL_H__
-
-#include <linux/sysctl.h>
-
-/*
- * Tunable xfs parameters
- */
-
-typedef struct xfs_sysctl_val {
- int min;
- int val;
- int max;
-} xfs_sysctl_val_t;
-
-typedef struct xfs_param {
- xfs_sysctl_val_t restrict_chown;/* Root/non-root can give away files.*/
- xfs_sysctl_val_t sgid_inherit; /* Inherit S_ISGID bit if process' GID
- * is not a member of the parent dir
- * GID */
- xfs_sysctl_val_t symlink_mode; /* Link creat mode affected by umask */
- xfs_sysctl_val_t panic_mask; /* bitmask to cause panic on errors. */
- xfs_sysctl_val_t error_level; /* Degree of reporting for problems */
- xfs_sysctl_val_t sync_interval; /* time between sync calls */
- xfs_sysctl_val_t stats_clear; /* Reset all XFS statistics to zero. */
- xfs_sysctl_val_t inherit_sync; /* Inherit the "sync" inode flag. */
- xfs_sysctl_val_t inherit_nodump;/* Inherit the "nodump" inode flag. */
- xfs_sysctl_val_t inherit_noatim;/* Inherit the "noatime" inode flag. */
- xfs_sysctl_val_t flush_interval;/* interval between runs of the
- * delwri flush daemon. */
- xfs_sysctl_val_t age_buffer; /* time for buffer to age before
- * we flush it. */
-} xfs_param_t;
-
-/*
- * xfs_error_level:
- *
- * How much error reporting will be done when internal problems are
- * encountered. These problems normally return an EFSCORRUPTED to their
- * caller, with no other information reported.
- *
- * 0 No error reports
- * 1 Report EFSCORRUPTED errors that will cause a filesystem shutdown
- * 5 Report all EFSCORRUPTED errors (all of the above errors, plus any
- * additional errors that are known to not cause shutdowns)
- *
- * xfs_panic_mask bit 0x8 turns the error reports into panics
- */
-
-enum {
- XFS_RESTRICT_CHOWN = 3,
- XFS_SGID_INHERIT = 4,
- XFS_SYMLINK_MODE = 5,
- XFS_PANIC_MASK = 6,
- XFS_ERRLEVEL = 7,
- XFS_SYNC_INTERVAL = 8,
- XFS_STATS_CLEAR = 12,
- XFS_INHERIT_SYNC = 13,
- XFS_INHERIT_NODUMP = 14,
- XFS_INHERIT_NOATIME = 15,
- XFS_FLUSH_INTERVAL = 16,
- XFS_AGE_BUFFER = 17,
-};
-
-extern xfs_param_t xfs_params;
-
-#ifdef CONFIG_SYSCTL
-extern void xfs_sysctl_register(void);
-extern void xfs_sysctl_unregister(void);
-#else
-# define xfs_sysctl_register() do { } while (0)
-# define xfs_sysctl_unregister() do { } while (0)
-#endif /* CONFIG_SYSCTL */
-
-#endif /* __XFS_SYSCTL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-/*
- * Dummy file that can contain a timestamp to put into the
- * XFS init string, to help users keep track of what they're
- * running
- */
-
-#ifndef __XFS_VERSION_H__
-#define __XFS_VERSION_H__
-
-#define XFS_VERSION_STRING "SGI XFS"
-
-#endif /* __XFS_VERSION_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_macros.h"
-#include "xfs_inum.h"
-#include "xfs_log.h"
-#include "xfs_clnt.h"
-#include "xfs_trans.h"
-#include "xfs_sb.h"
-#include "xfs_ag.h"
-#include "xfs_dir.h"
-#include "xfs_dir2.h"
-#include "xfs_imap.h"
-#include "xfs_alloc.h"
-#include "xfs_dmapi.h"
-#include "xfs_mount.h"
-#include "xfs_quota.h"
-
-int
-vfs_mount(
- struct bhv_desc *bdp,
- struct xfs_mount_args *args,
- struct cred *cr)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_mount)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_mount)(next, args, cr));
-}
-
-int
-vfs_parseargs(
- struct bhv_desc *bdp,
- char *s,
- struct xfs_mount_args *args,
- int f)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_parseargs)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_parseargs)(next, s, args, f));
-}
-
-int
-vfs_showargs(
- struct bhv_desc *bdp,
- struct seq_file *m)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_showargs)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_showargs)(next, m));
-}
-
-int
-vfs_unmount(
- struct bhv_desc *bdp,
- int fl,
- struct cred *cr)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_unmount)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_unmount)(next, fl, cr));
-}
-
-int
-vfs_mntupdate(
- struct bhv_desc *bdp,
- int *fl,
- struct xfs_mount_args *args)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_mntupdate)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_mntupdate)(next, fl, args));
-}
-
-int
-vfs_root(
- struct bhv_desc *bdp,
- struct vnode **vpp)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_root)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_root)(next, vpp));
-}
-
-int
-vfs_statvfs(
- struct bhv_desc *bdp,
- xfs_statfs_t *sp,
- struct vnode *vp)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_statvfs)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_statvfs)(next, sp, vp));
-}
-
-int
-vfs_sync(
- struct bhv_desc *bdp,
- int fl,
- struct cred *cr)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_sync)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_sync)(next, fl, cr));
-}
-
-int
-vfs_vget(
- struct bhv_desc *bdp,
- struct vnode **vpp,
- struct fid *fidp)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_vget)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_vget)(next, vpp, fidp));
-}
-
-int
-vfs_dmapiops(
- struct bhv_desc *bdp,
- caddr_t addr)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_dmapiops)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_dmapiops)(next, addr));
-}
-
-int
-vfs_quotactl(
- struct bhv_desc *bdp,
- int cmd,
- int id,
- caddr_t addr)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_quotactl)
- next = BHV_NEXT(next);
- return ((*bhvtovfsops(next)->vfs_quotactl)(next, cmd, id, addr));
-}
-
-void
-vfs_init_vnode(
- struct bhv_desc *bdp,
- struct vnode *vp,
- struct bhv_desc *bp,
- int unlock)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_init_vnode)
- next = BHV_NEXT(next);
- ((*bhvtovfsops(next)->vfs_init_vnode)(next, vp, bp, unlock));
-}
-
-void
-vfs_force_shutdown(
- struct bhv_desc *bdp,
- int fl,
- char *file,
- int line)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_force_shutdown)
- next = BHV_NEXT(next);
- ((*bhvtovfsops(next)->vfs_force_shutdown)(next, fl, file, line));
-}
-
-void
-vfs_freeze(
- struct bhv_desc *bdp)
-{
- struct bhv_desc *next = bdp;
-
- ASSERT(next);
- while (! (bhvtovfsops(next))->vfs_freeze)
- next = BHV_NEXT(next);
- ((*bhvtovfsops(next)->vfs_freeze)(next));
-}
-
-vfs_t *
-vfs_allocate( void )
-{
- struct vfs *vfsp;
-
- vfsp = kmem_zalloc(sizeof(vfs_t), KM_SLEEP);
- bhv_head_init(VFS_BHVHEAD(vfsp), "vfs");
- init_waitqueue_head(&vfsp->vfs_wait_sync_task);
- return vfsp;
-}
-
-void
-vfs_deallocate(
- struct vfs *vfsp)
-{
- bhv_head_destroy(VFS_BHVHEAD(vfsp));
- kmem_free(vfsp, sizeof(vfs_t));
-}
-
-void
-vfs_insertops(
- struct vfs *vfsp,
- struct bhv_vfsops *vfsops)
-{
- struct bhv_desc *bdp;
-
- bdp = kmem_alloc(sizeof(struct bhv_desc), KM_SLEEP);
- bhv_desc_init(bdp, NULL, vfsp, vfsops);
- bhv_insert(&vfsp->vfs_bh, bdp);
-}
-
-void
-vfs_insertbhv(
- struct vfs *vfsp,
- struct bhv_desc *bdp,
- struct vfsops *vfsops,
- void *mount)
-{
- bhv_desc_init(bdp, mount, vfsp, vfsops);
- bhv_insert_initial(&vfsp->vfs_bh, bdp);
-}
-
-void
-bhv_remove_vfsops(
- struct vfs *vfsp,
- int pos)
-{
- struct bhv_desc *bhv;
-
- bhv = bhv_lookup_range(&vfsp->vfs_bh, pos, pos);
- if (!bhv)
- return;
- bhv_remove(&vfsp->vfs_bh, bhv);
- kmem_free(bhv, sizeof(*bhv));
-}
-
-void
-bhv_remove_all_vfsops(
- struct vfs *vfsp,
- int freebase)
-{
- struct xfs_mount *mp;
-
- bhv_remove_vfsops(vfsp, VFS_POSITION_QM);
- bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
- if (!freebase)
- return;
- mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
- VFS_REMOVEBHV(vfsp, &mp->m_bhv);
- xfs_mount_free(mp, 0);
-}
-
-void
-bhv_insert_all_vfsops(
- struct vfs *vfsp)
-{
- struct xfs_mount *mp;
-
- mp = xfs_mount_init();
- vfs_insertbhv(vfsp, &mp->m_bhv, &xfs_vfsops, mp);
- vfs_insertdmapi(vfsp);
- vfs_insertquota(vfsp);
-}
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-#ifndef __XFS_VFS_H__
-#define __XFS_VFS_H__
-
-#include <linux/vfs.h>
-#include "xfs_fs.h"
-
-struct fid;
-struct cred;
-struct vnode;
-struct kstatfs;
-struct seq_file;
-struct super_block;
-struct xfs_mount_args;
-
-typedef struct kstatfs xfs_statfs_t;
-
-typedef struct vfs {
- u_int vfs_flag; /* flags */
- xfs_fsid_t vfs_fsid; /* file system ID */
- xfs_fsid_t *vfs_altfsid; /* An ID fixed for life of FS */
- bhv_head_t vfs_bh; /* head of vfs behavior chain */
- struct super_block *vfs_super; /* Linux superblock structure */
- struct task_struct *vfs_sync_task;
- wait_queue_head_t vfs_wait_sync_task;
-} vfs_t;
-
-#define vfs_fbhv vfs_bh.bh_first /* 1st on vfs behavior chain */
-
-#define bhvtovfs(bdp) ( (struct vfs *)BHV_VOBJ(bdp) )
-#define bhvtovfsops(bdp) ( (struct vfsops *)BHV_OPS(bdp) )
-#define VFS_BHVHEAD(vfs) ( &(vfs)->vfs_bh )
-#define VFS_REMOVEBHV(vfs, bdp) ( bhv_remove(VFS_BHVHEAD(vfs), bdp) )
-
-#define VFS_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
-#define VFS_POSITION_TOP BHV_POSITION_TOP /* chain top */
-#define VFS_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
-
-typedef enum {
- VFS_BHV_UNKNOWN, /* not specified */
- VFS_BHV_XFS, /* xfs */
- VFS_BHV_DM, /* data migration */
- VFS_BHV_QM, /* quota manager */
- VFS_BHV_IO, /* IO path */
- VFS_BHV_END /* housekeeping end-of-range */
-} vfs_bhv_t;
-
-#define VFS_POSITION_XFS (BHV_POSITION_BASE)
-#define VFS_POSITION_DM (VFS_POSITION_BASE+10)
-#define VFS_POSITION_QM (VFS_POSITION_BASE+20)
-#define VFS_POSITION_IO (VFS_POSITION_BASE+30)
-
-#define VFS_RDONLY 0x0001 /* read-only vfs */
-#define VFS_GRPID 0x0002 /* group-ID assigned from directory */
-#define VFS_DMI 0x0004 /* filesystem has the DMI enabled */
-#define VFS_UMOUNT 0x0008 /* unmount in progress */
-#define VFS_END 0x0008 /* max flag */
-
-#define SYNC_ATTR 0x0001 /* sync attributes */
-#define SYNC_CLOSE 0x0002 /* close file system down */
-#define SYNC_DELWRI 0x0004 /* look at delayed writes */
-#define SYNC_WAIT 0x0008 /* wait for i/o to complete */
-#define SYNC_BDFLUSH 0x0010 /* BDFLUSH is calling -- don't block */
-#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
-#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
-#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
-
-typedef int (*vfs_mount_t)(bhv_desc_t *,
- struct xfs_mount_args *, struct cred *);
-typedef int (*vfs_parseargs_t)(bhv_desc_t *, char *,
- struct xfs_mount_args *, int);
-typedef int (*vfs_showargs_t)(bhv_desc_t *, struct seq_file *);
-typedef int (*vfs_unmount_t)(bhv_desc_t *, int, struct cred *);
-typedef int (*vfs_mntupdate_t)(bhv_desc_t *, int *,
- struct xfs_mount_args *);
-typedef int (*vfs_root_t)(bhv_desc_t *, struct vnode **);
-typedef int (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
-typedef int (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
-typedef int (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
-typedef int (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
-typedef int (*vfs_quotactl_t)(bhv_desc_t *, int, int, caddr_t);
-typedef void (*vfs_init_vnode_t)(bhv_desc_t *,
- struct vnode *, bhv_desc_t *, int);
-typedef void (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
-typedef void (*vfs_freeze_t)(bhv_desc_t *);
-
-typedef struct vfsops {
- bhv_position_t vf_position; /* behavior chain position */
- vfs_mount_t vfs_mount; /* mount file system */
- vfs_parseargs_t vfs_parseargs; /* parse mount options */
- vfs_showargs_t vfs_showargs; /* unparse mount options */
- vfs_unmount_t vfs_unmount; /* unmount file system */
- vfs_mntupdate_t vfs_mntupdate; /* update file system options */
- vfs_root_t vfs_root; /* get root vnode */
- vfs_statvfs_t vfs_statvfs; /* file system statistics */
- vfs_sync_t vfs_sync; /* flush files */
- vfs_vget_t vfs_vget; /* get vnode from fid */
- vfs_dmapiops_t vfs_dmapiops; /* data migration */
- vfs_quotactl_t vfs_quotactl; /* disk quota */
- vfs_init_vnode_t vfs_init_vnode; /* initialize a new vnode */
- vfs_force_shutdown_t vfs_force_shutdown; /* crash and burn */
- vfs_freeze_t vfs_freeze; /* freeze fs for snapshot */
-} vfsops_t;
-
-/*
- * VFS's. Operates on vfs structure pointers (starts at bhv head).
- */
-#define VHEAD(v) ((v)->vfs_fbhv)
-#define VFS_MOUNT(v, ma,cr, rv) ((rv) = vfs_mount(VHEAD(v), ma,cr))
-#define VFS_PARSEARGS(v, o,ma,f, rv) ((rv) = vfs_parseargs(VHEAD(v), o,ma,f))
-#define VFS_SHOWARGS(v, m, rv) ((rv) = vfs_showargs(VHEAD(v), m))
-#define VFS_UNMOUNT(v, f, cr, rv) ((rv) = vfs_unmount(VHEAD(v), f,cr))
-#define VFS_MNTUPDATE(v, fl, args, rv) ((rv) = vfs_mntupdate(VHEAD(v), fl, args))
-#define VFS_ROOT(v, vpp, rv) ((rv) = vfs_root(VHEAD(v), vpp))
-#define VFS_STATVFS(v, sp,vp, rv) ((rv) = vfs_statvfs(VHEAD(v), sp,vp))
-#define VFS_SYNC(v, flag,cr, rv) ((rv) = vfs_sync(VHEAD(v), flag,cr))
-#define VFS_VGET(v, vpp,fidp, rv) ((rv) = vfs_vget(VHEAD(v), vpp,fidp))
-#define VFS_DMAPIOPS(v, p, rv) ((rv) = vfs_dmapiops(VHEAD(v), p))
-#define VFS_QUOTACTL(v, c,id,p, rv) ((rv) = vfs_quotactl(VHEAD(v), c,id,p))
-#define VFS_INIT_VNODE(v, vp,b,ul) ( vfs_init_vnode(VHEAD(v), vp,b,ul) )
-#define VFS_FORCE_SHUTDOWN(v, fl,f,l) ( vfs_force_shutdown(VHEAD(v), fl,f,l) )
-#define VFS_FREEZE(v) ( vfs_freeze(VHEAD(v)) )
-
-/*
- * PVFS's. Operates on behavior descriptor pointers.
- */
-#define PVFS_MOUNT(b, ma,cr, rv) ((rv) = vfs_mount(b, ma,cr))
-#define PVFS_PARSEARGS(b, o,ma,f, rv) ((rv) = vfs_parseargs(b, o,ma,f))
-#define PVFS_SHOWARGS(b, m, rv) ((rv) = vfs_showargs(b, m))
-#define PVFS_UNMOUNT(b, f,cr, rv) ((rv) = vfs_unmount(b, f,cr))
-#define PVFS_MNTUPDATE(b, fl, args, rv) ((rv) = vfs_mntupdate(b, fl, args))
-#define PVFS_ROOT(b, vpp, rv) ((rv) = vfs_root(b, vpp))
-#define PVFS_STATVFS(b, sp,vp, rv) ((rv) = vfs_statvfs(b, sp,vp))
-#define PVFS_SYNC(b, flag,cr, rv) ((rv) = vfs_sync(b, flag,cr))
-#define PVFS_VGET(b, vpp,fidp, rv) ((rv) = vfs_vget(b, vpp,fidp))
-#define PVFS_DMAPIOPS(b, p, rv) ((rv) = vfs_dmapiops(b, p))
-#define PVFS_QUOTACTL(b, c,id,p, rv) ((rv) = vfs_quotactl(b, c,id,p))
-#define PVFS_INIT_VNODE(b, vp,b2,ul) ( vfs_init_vnode(b, vp,b2,ul) )
-#define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) )
-#define PVFS_FREEZE(b) ( vfs_freeze(b) )
-
-extern int vfs_mount(bhv_desc_t *, struct xfs_mount_args *, struct cred *);
-extern int vfs_parseargs(bhv_desc_t *, char *, struct xfs_mount_args *, int);
-extern int vfs_showargs(bhv_desc_t *, struct seq_file *);
-extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
-extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
-extern int vfs_root(bhv_desc_t *, struct vnode **);
-extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
-extern int vfs_sync(bhv_desc_t *, int, struct cred *);
-extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
-extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
-extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
-extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
-extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
-extern void vfs_freeze(bhv_desc_t *);
-
-typedef struct bhv_vfsops {
- struct vfsops bhv_common;
- void * bhv_custom;
-} bhv_vfsops_t;
-
-#define vfs_bhv_lookup(v, id) ( bhv_lookup_range(&(v)->vfs_bh, (id), (id)) )
-#define vfs_bhv_custom(b) ( ((bhv_vfsops_t *)BHV_OPS(b))->bhv_custom )
-#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o))
-#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL )
-
-extern vfs_t *vfs_allocate(void);
-extern void vfs_deallocate(vfs_t *);
-extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
-extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
-
-extern void bhv_insert_all_vfsops(struct vfs *);
-extern void bhv_remove_all_vfsops(struct vfs *, int);
-extern void bhv_remove_vfsops(struct vfs *, int);
-
-#endif /* __XFS_VFS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-
-uint64_t vn_generation; /* vnode generation number */
-spinlock_t vnumber_lock = SPIN_LOCK_UNLOCKED;
-
-/*
- * Dedicated vnode inactive/reclaim sync semaphores.
- * Prime number of hash buckets since address is used as the key.
- */
-#define NVSYNC 37
-#define vptosync(v) (&vsync[((unsigned long)v) % NVSYNC])
-sv_t vsync[NVSYNC];
-
-/*
- * Translate stat(2) file types to vnode types and vice versa.
- * Aware of numeric order of S_IFMT and vnode type values.
- */
-enum vtype iftovt_tab[] = {
- VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
- VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VNON
-};
-
-u_short vttoif_tab[] = {
- 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFIFO, 0, S_IFSOCK
-};
-
-
-void
-vn_init(void)
-{
- register sv_t *svp;
- register int i;
-
- for (svp = vsync, i = 0; i < NVSYNC; i++, svp++)
- init_sv(svp, SV_DEFAULT, "vsy", i);
-}
-
-/*
- * Clean a vnode of filesystem-specific data and prepare it for reuse.
- */
-STATIC int
-vn_reclaim(
- struct vnode *vp)
-{
- int error;
-
- XFS_STATS_INC(vn_reclaim);
- vn_trace_entry(vp, "vn_reclaim", (inst_t *)__return_address);
-
- /*
- * Only make the VOP_RECLAIM call if there are behaviors
- * to call.
- */
- if (vp->v_fbhv) {
- VOP_RECLAIM(vp, error);
- if (error)
- return -error;
- }
- ASSERT(vp->v_fbhv == NULL);
-
- VN_LOCK(vp);
- vp->v_flag &= (VRECLM|VWAIT);
- VN_UNLOCK(vp, 0);
-
- vp->v_type = VNON;
- vp->v_fbhv = NULL;
-
-#ifdef XFS_VNODE_TRACE
- ktrace_free(vp->v_trace);
- vp->v_trace = NULL;
-#endif
-
- return 0;
-}
-
-STATIC void
-vn_wakeup(
- struct vnode *vp)
-{
- VN_LOCK(vp);
- if (vp->v_flag & VWAIT)
- sv_broadcast(vptosync(vp));
- vp->v_flag &= ~(VRECLM|VWAIT|VMODIFIED);
- VN_UNLOCK(vp, 0);
-}
-
-int
-vn_wait(
- struct vnode *vp)
-{
- VN_LOCK(vp);
- if (vp->v_flag & (VINACT | VRECLM)) {
- vp->v_flag |= VWAIT;
- sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
- return 1;
- }
- VN_UNLOCK(vp, 0);
- return 0;
-}
-
-struct vnode *
-vn_initialize(
- struct inode *inode)
-{
- struct vnode *vp = LINVFS_GET_VP(inode);
-
- XFS_STATS_INC(vn_active);
- XFS_STATS_INC(vn_alloc);
-
- vp->v_flag = VMODIFIED;
- spinlock_init(&vp->v_lock, "v_lock");
-
- spin_lock(&vnumber_lock);
- if (!++vn_generation) /* v_number shouldn't be zero */
- vn_generation++;
- vp->v_number = vn_generation;
- spin_unlock(&vnumber_lock);
-
- ASSERT(VN_CACHED(vp) == 0);
-
- /* Initialize the first behavior and the behavior chain head. */
- vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
-
-#ifdef XFS_VNODE_TRACE
- vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
- printk("Allocated VNODE_TRACE at 0x%p\n", vp->v_trace);
-#endif /* XFS_VNODE_TRACE */
-
- vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
- return vp;
-}
-
-/*
- * Get a reference on a vnode.
- */
-vnode_t *
-vn_get(
- struct vnode *vp,
- vmap_t *vmap)
-{
- struct inode *inode;
-
- XFS_STATS_INC(vn_get);
- inode = LINVFS_GET_IP(vp);
- if (inode->i_state & I_FREEING)
- return NULL;
-
- inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
- if (!inode) /* Inode not present */
- return NULL;
-
- vn_trace_exit(vp, "vn_get", (inst_t *)__return_address);
-
- return vp;
-}
-
-/*
- * Revalidate the Linux inode from the vnode.
- */
-int
-vn_revalidate(
- struct vnode *vp)
-{
- struct inode *inode;
- vattr_t va;
- int error;
-
- vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address);
- ASSERT(vp->v_fbhv != NULL);
-
- va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (!error) {
- inode = LINVFS_GET_IP(vp);
- inode->i_mode = VTTOIF(va.va_type) | va.va_mode;
- inode->i_nlink = va.va_nlink;
- inode->i_uid = va.va_uid;
- inode->i_gid = va.va_gid;
- inode->i_blocks = va.va_nblocks;
- inode->i_mtime = va.va_mtime;
- inode->i_ctime = va.va_ctime;
- inode->i_atime = va.va_atime;
- if (va.va_xflags & XFS_XFLAG_IMMUTABLE)
- inode->i_flags |= S_IMMUTABLE;
- else
- inode->i_flags &= ~S_IMMUTABLE;
- if (va.va_xflags & XFS_XFLAG_APPEND)
- inode->i_flags |= S_APPEND;
- else
- inode->i_flags &= ~S_APPEND;
- if (va.va_xflags & XFS_XFLAG_SYNC)
- inode->i_flags |= S_SYNC;
- else
- inode->i_flags &= ~S_SYNC;
- if (va.va_xflags & XFS_XFLAG_NOATIME)
- inode->i_flags |= S_NOATIME;
- else
- inode->i_flags &= ~S_NOATIME;
- VUNMODIFY(vp);
- }
- return -error;
-}
-
-/*
- * purge a vnode from the cache
- * At this point the vnode is guaranteed to have no references (vn_count == 0)
- * The caller has to make sure that there are no ways someone could
- * get a handle (via vn_get) on the vnode (usually done via a mount/vfs lock).
- */
-void
-vn_purge(
- struct vnode *vp,
- vmap_t *vmap)
-{
- vn_trace_entry(vp, "vn_purge", (inst_t *)__return_address);
-
-again:
- /*
- * Check whether vp has already been reclaimed since our caller
- * sampled its version while holding a filesystem cache lock that
- * its VOP_RECLAIM function acquires.
- */
- VN_LOCK(vp);
- if (vp->v_number != vmap->v_number) {
- VN_UNLOCK(vp, 0);
- return;
- }
-
- /*
- * If vp is being reclaimed or inactivated, wait until it is inert,
- * then proceed. Can't assume that vnode is actually reclaimed
- * just because the reclaimed flag is asserted -- a vn_alloc
- * reclaim can fail.
- */
- if (vp->v_flag & (VINACT | VRECLM)) {
- ASSERT(vn_count(vp) == 0);
- vp->v_flag |= VWAIT;
- sv_wait(vptosync(vp), PINOD, &vp->v_lock, 0);
- goto again;
- }
-
- /*
- * Another process could have raced in and gotten this vnode...
- */
- if (vn_count(vp) > 0) {
- VN_UNLOCK(vp, 0);
- return;
- }
-
- XFS_STATS_DEC(vn_active);
- vp->v_flag |= VRECLM;
- VN_UNLOCK(vp, 0);
-
- /*
- * Call VOP_RECLAIM and clean vp. The FSYNC_INVAL flag tells
- * vp's filesystem to flush and invalidate all cached resources.
- * When vn_reclaim returns, vp should have no private data,
- * either in a system cache or attached to v_data.
- */
- if (vn_reclaim(vp) != 0)
- panic("vn_purge: cannot reclaim");
-
- /*
- * Wakeup anyone waiting for vp to be reclaimed.
- */
- vn_wakeup(vp);
-}
-
-/*
- * Add a reference to a referenced vnode.
- */
-struct vnode *
-vn_hold(
- struct vnode *vp)
-{
- struct inode *inode;
-
- XFS_STATS_INC(vn_hold);
-
- VN_LOCK(vp);
- inode = igrab(LINVFS_GET_IP(vp));
- ASSERT(inode);
- VN_UNLOCK(vp, 0);
-
- return vp;
-}
-
-/*
- * Call VOP_INACTIVE on last reference.
- */
-void
-vn_rele(
- struct vnode *vp)
-{
- int vcnt;
- int cache;
-
- XFS_STATS_INC(vn_rele);
-
- VN_LOCK(vp);
-
- vn_trace_entry(vp, "vn_rele", (inst_t *)__return_address);
- vcnt = vn_count(vp);
-
- /*
- * Since we always get called from put_inode we know
- * that i_count won't be decremented after we
- * return.
- */
- if (!vcnt) {
- /*
- * As soon as we turn this on, noone can find us in vn_get
- * until we turn off VINACT or VRECLM
- */
- vp->v_flag |= VINACT;
- VN_UNLOCK(vp, 0);
-
- /*
- * Do not make the VOP_INACTIVE call if there
- * are no behaviors attached to the vnode to call.
- */
- if (vp->v_fbhv)
- VOP_INACTIVE(vp, NULL, cache);
-
- VN_LOCK(vp);
- if (vp->v_flag & VWAIT)
- sv_broadcast(vptosync(vp));
-
- vp->v_flag &= ~(VINACT|VWAIT|VRECLM|VMODIFIED);
- }
-
- VN_UNLOCK(vp, 0);
-
- vn_trace_exit(vp, "vn_rele", (inst_t *)__return_address);
-}
-
-/*
- * Finish the removal of a vnode.
- */
-void
-vn_remove(
- struct vnode *vp)
-{
- vmap_t vmap;
-
- /* Make sure we don't do this to the same vnode twice */
- if (!(vp->v_fbhv))
- return;
-
- XFS_STATS_INC(vn_remove);
- vn_trace_exit(vp, "vn_remove", (inst_t *)__return_address);
-
- /*
- * After the following purge the vnode
- * will no longer exist.
- */
- VMAP(vp, vmap);
- vn_purge(vp, &vmap);
-}
-
-
-#ifdef XFS_VNODE_TRACE
-
-#define KTRACE_ENTER(vp, vk, s, line, ra) \
- ktrace_enter( (vp)->v_trace, \
-/* 0 */ (void *)(__psint_t)(vk), \
-/* 1 */ (void *)(s), \
-/* 2 */ (void *)(__psint_t) line, \
-/* 3 */ (void *)(vn_count(vp)), \
-/* 4 */ (void *)(ra), \
-/* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \
-/* 6 */ (void *)(__psint_t)smp_processor_id(), \
-/* 7 */ (void *)(__psint_t)(current->pid), \
-/* 8 */ (void *)__return_address, \
-/* 9 */ 0, 0, 0, 0, 0, 0, 0)
-
-/*
- * Vnode tracing code.
- */
-void
-vn_trace_entry(vnode_t *vp, char *func, inst_t *ra)
-{
- KTRACE_ENTER(vp, VNODE_KTRACE_ENTRY, func, 0, ra);
-}
-
-void
-vn_trace_exit(vnode_t *vp, char *func, inst_t *ra)
-{
- KTRACE_ENTER(vp, VNODE_KTRACE_EXIT, func, 0, ra);
-}
-
-void
-vn_trace_hold(vnode_t *vp, char *file, int line, inst_t *ra)
-{
- KTRACE_ENTER(vp, VNODE_KTRACE_HOLD, file, line, ra);
-}
-
-void
-vn_trace_ref(vnode_t *vp, char *file, int line, inst_t *ra)
-{
- KTRACE_ENTER(vp, VNODE_KTRACE_REF, file, line, ra);
-}
-
-void
-vn_trace_rele(vnode_t *vp, char *file, int line, inst_t *ra)
-{
- KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
-}
-#endif /* XFS_VNODE_TRACE */
+++ /dev/null
-/*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- *
- * Portions Copyright (c) 1989, 1993
- * The Regents of the University of California. 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. 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 __XFS_VNODE_H__
-#define __XFS_VNODE_H__
-
-struct uio;
-struct file;
-struct vattr;
-struct xfs_iomap;
-struct attrlist_cursor_kern;
-
-/*
- * Vnode types. VNON means no type.
- */
-enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VFIFO, VBAD, VSOCK };
-
-typedef xfs_ino_t vnumber_t;
-typedef struct dentry vname_t;
-typedef bhv_head_t vn_bhv_head_t;
-
-/*
- * MP locking protocols:
- * v_flag, v_vfsp VN_LOCK/VN_UNLOCK
- * v_type read-only or fs-dependent
- */
-typedef struct vnode {
- __u32 v_flag; /* vnode flags (see below) */
- enum vtype v_type; /* vnode type */
- struct vfs *v_vfsp; /* ptr to containing VFS */
- vnumber_t v_number; /* in-core vnode number */
- vn_bhv_head_t v_bh; /* behavior head */
- spinlock_t v_lock; /* VN_LOCK/VN_UNLOCK */
- struct inode v_inode; /* Linux inode */
-#ifdef XFS_VNODE_TRACE
- struct ktrace *v_trace; /* trace header structure */
-#endif
-} vnode_t;
-
-#define v_fbhv v_bh.bh_first /* first behavior */
-#define v_fops v_bh.bh_first->bd_ops /* first behavior ops */
-
-#define VNODE_POSITION_BASE BHV_POSITION_BASE /* chain bottom */
-#define VNODE_POSITION_TOP BHV_POSITION_TOP /* chain top */
-#define VNODE_POSITION_INVALID BHV_POSITION_INVALID /* invalid pos. num */
-
-typedef enum {
- VN_BHV_UNKNOWN, /* not specified */
- VN_BHV_XFS, /* xfs */
- VN_BHV_DM, /* data migration */
- VN_BHV_QM, /* quota manager */
- VN_BHV_IO, /* IO path */
- VN_BHV_END /* housekeeping end-of-range */
-} vn_bhv_t;
-
-#define VNODE_POSITION_XFS (VNODE_POSITION_BASE)
-#define VNODE_POSITION_DM (VNODE_POSITION_BASE+10)
-#define VNODE_POSITION_QM (VNODE_POSITION_BASE+20)
-#define VNODE_POSITION_IO (VNODE_POSITION_BASE+30)
-
-/*
- * Macros for dealing with the behavior descriptor inside of the vnode.
- */
-#define BHV_TO_VNODE(bdp) ((vnode_t *)BHV_VOBJ(bdp))
-#define BHV_TO_VNODE_NULL(bdp) ((vnode_t *)BHV_VOBJNULL(bdp))
-
-#define VN_BHV_HEAD(vp) ((bhv_head_t *)(&((vp)->v_bh)))
-#define vn_bhv_head_init(bhp,name) bhv_head_init(bhp,name)
-#define vn_bhv_remove(bhp,bdp) bhv_remove(bhp,bdp)
-#define vn_bhv_lookup(bhp,ops) bhv_lookup(bhp,ops)
-#define vn_bhv_lookup_unlocked(bhp,ops) bhv_lookup_unlocked(bhp,ops)
-
-/*
- * Vnode to Linux inode mapping.
- */
-#define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode))
-#define LINVFS_GET_IP(vp) (&(vp)->v_inode)
-
-/*
- * Convert between vnode types and inode formats (since POSIX.1
- * defines mode word of stat structure in terms of inode formats).
- */
-extern enum vtype iftovt_tab[];
-extern u_short vttoif_tab[];
-#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
-#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
-#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
-
-
-/*
- * Vnode flags.
- */
-#define VINACT 0x1 /* vnode is being inactivated */
-#define VRECLM 0x2 /* vnode is being reclaimed */
-#define VWAIT 0x4 /* waiting for VINACT/VRECLM to end */
-#define VMODIFIED 0x8 /* XFS inode state possibly differs */
- /* to the Linux inode state. */
-
-/*
- * Values for the VOP_RWLOCK and VOP_RWUNLOCK flags parameter.
- */
-typedef enum vrwlock {
- VRWLOCK_NONE,
- VRWLOCK_READ,
- VRWLOCK_WRITE,
- VRWLOCK_WRITE_DIRECT,
- VRWLOCK_TRY_READ,
- VRWLOCK_TRY_WRITE
-} vrwlock_t;
-
-/*
- * Return values for VOP_INACTIVE. A return value of
- * VN_INACTIVE_NOCACHE implies that the file system behavior
- * has disassociated its state and bhv_desc_t from the vnode.
- */
-#define VN_INACTIVE_CACHE 0
-#define VN_INACTIVE_NOCACHE 1
-
-/*
- * Values for the cmd code given to VOP_VNODE_CHANGE.
- */
-typedef enum vchange {
- VCHANGE_FLAGS_FRLOCKS = 0,
- VCHANGE_FLAGS_ENF_LOCKING = 1,
- VCHANGE_FLAGS_TRUNCATED = 2,
- VCHANGE_FLAGS_PAGE_DIRTY = 3,
- VCHANGE_FLAGS_IOEXCL_COUNT = 4
-} vchange_t;
-
-
-typedef int (*vop_open_t)(bhv_desc_t *, struct cred *);
-typedef ssize_t (*vop_read_t)(bhv_desc_t *, struct kiocb *,
- const struct iovec *, unsigned int,
- loff_t *, int, struct cred *);
-typedef ssize_t (*vop_write_t)(bhv_desc_t *, struct kiocb *,
- const struct iovec *, unsigned int,
- loff_t *, int, struct cred *);
-typedef ssize_t (*vop_sendfile_t)(bhv_desc_t *, struct file *,
- loff_t *, int, size_t, read_actor_t,
- void *, struct cred *);
-typedef int (*vop_ioctl_t)(bhv_desc_t *, struct inode *, struct file *,
- int, unsigned int, unsigned long);
-typedef int (*vop_getattr_t)(bhv_desc_t *, struct vattr *, int,
- struct cred *);
-typedef int (*vop_setattr_t)(bhv_desc_t *, struct vattr *, int,
- struct cred *);
-typedef int (*vop_access_t)(bhv_desc_t *, int, struct cred *);
-typedef int (*vop_lookup_t)(bhv_desc_t *, vname_t *, vnode_t **,
- int, vnode_t *, struct cred *);
-typedef int (*vop_create_t)(bhv_desc_t *, vname_t *, struct vattr *,
- vnode_t **, struct cred *);
-typedef int (*vop_remove_t)(bhv_desc_t *, vname_t *, struct cred *);
-typedef int (*vop_link_t)(bhv_desc_t *, vnode_t *, vname_t *,
- struct cred *);
-typedef int (*vop_rename_t)(bhv_desc_t *, vname_t *, vnode_t *, vname_t *,
- struct cred *);
-typedef int (*vop_mkdir_t)(bhv_desc_t *, vname_t *, struct vattr *,
- vnode_t **, struct cred *);
-typedef int (*vop_rmdir_t)(bhv_desc_t *, vname_t *, struct cred *);
-typedef int (*vop_readdir_t)(bhv_desc_t *, struct uio *, struct cred *,
- int *);
-typedef int (*vop_symlink_t)(bhv_desc_t *, vname_t *, struct vattr *,
- char *, vnode_t **, struct cred *);
-typedef int (*vop_readlink_t)(bhv_desc_t *, struct uio *, int,
- struct cred *);
-typedef int (*vop_fsync_t)(bhv_desc_t *, int, struct cred *,
- xfs_off_t, xfs_off_t);
-typedef int (*vop_inactive_t)(bhv_desc_t *, struct cred *);
-typedef int (*vop_fid2_t)(bhv_desc_t *, struct fid *);
-typedef int (*vop_release_t)(bhv_desc_t *);
-typedef int (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
-typedef void (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
-typedef int (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
- struct xfs_iomap *, int *);
-typedef int (*vop_reclaim_t)(bhv_desc_t *);
-typedef int (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
- struct cred *);
-typedef int (*vop_attr_set_t)(bhv_desc_t *, char *, char *, int, int,
- struct cred *);
-typedef int (*vop_attr_remove_t)(bhv_desc_t *, char *, int, struct cred *);
-typedef int (*vop_attr_list_t)(bhv_desc_t *, char *, int, int,
- struct attrlist_cursor_kern *, struct cred *);
-typedef void (*vop_link_removed_t)(bhv_desc_t *, vnode_t *, int);
-typedef void (*vop_vnode_change_t)(bhv_desc_t *, vchange_t, __psint_t);
-typedef void (*vop_ptossvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-typedef void (*vop_pflushinvalvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t, int);
-typedef int (*vop_pflushvp_t)(bhv_desc_t *, xfs_off_t, xfs_off_t,
- uint64_t, int);
-typedef int (*vop_iflush_t)(bhv_desc_t *, int);
-
-
-typedef struct vnodeops {
- bhv_position_t vn_position; /* position within behavior chain */
- vop_open_t vop_open;
- vop_read_t vop_read;
- vop_write_t vop_write;
- vop_sendfile_t vop_sendfile;
- vop_ioctl_t vop_ioctl;
- vop_getattr_t vop_getattr;
- vop_setattr_t vop_setattr;
- vop_access_t vop_access;
- vop_lookup_t vop_lookup;
- vop_create_t vop_create;
- vop_remove_t vop_remove;
- vop_link_t vop_link;
- vop_rename_t vop_rename;
- vop_mkdir_t vop_mkdir;
- vop_rmdir_t vop_rmdir;
- vop_readdir_t vop_readdir;
- vop_symlink_t vop_symlink;
- vop_readlink_t vop_readlink;
- vop_fsync_t vop_fsync;
- vop_inactive_t vop_inactive;
- vop_fid2_t vop_fid2;
- vop_rwlock_t vop_rwlock;
- vop_rwunlock_t vop_rwunlock;
- vop_bmap_t vop_bmap;
- vop_reclaim_t vop_reclaim;
- vop_attr_get_t vop_attr_get;
- vop_attr_set_t vop_attr_set;
- vop_attr_remove_t vop_attr_remove;
- vop_attr_list_t vop_attr_list;
- vop_link_removed_t vop_link_removed;
- vop_vnode_change_t vop_vnode_change;
- vop_ptossvp_t vop_tosspages;
- vop_pflushinvalvp_t vop_flushinval_pages;
- vop_pflushvp_t vop_flush_pages;
- vop_release_t vop_release;
- vop_iflush_t vop_iflush;
-} vnodeops_t;
-
-/*
- * VOP's.
- */
-#define _VOP_(op, vp) (*((vnodeops_t *)(vp)->v_fops)->op)
-
-#define VOP_READ(vp,file,iov,segs,offset,ioflags,cr,rv) \
- rv = _VOP_(vop_read, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
-#define VOP_WRITE(vp,file,iov,segs,offset,ioflags,cr,rv) \
- rv = _VOP_(vop_write, vp)((vp)->v_fbhv,file,iov,segs,offset,ioflags,cr)
-#define VOP_SENDFILE(vp,f,off,ioflags,cnt,act,targ,cr,rv) \
- rv = _VOP_(vop_sendfile, vp)((vp)->v_fbhv,f,off,ioflags,cnt,act,targ,cr)
-#define VOP_BMAP(vp,of,sz,rw,b,n,rv) \
- rv = _VOP_(vop_bmap, vp)((vp)->v_fbhv,of,sz,rw,b,n)
-#define VOP_OPEN(vp, cr, rv) \
- rv = _VOP_(vop_open, vp)((vp)->v_fbhv, cr)
-#define VOP_GETATTR(vp, vap, f, cr, rv) \
- rv = _VOP_(vop_getattr, vp)((vp)->v_fbhv, vap, f, cr)
-#define VOP_SETATTR(vp, vap, f, cr, rv) \
- rv = _VOP_(vop_setattr, vp)((vp)->v_fbhv, vap, f, cr)
-#define VOP_ACCESS(vp, mode, cr, rv) \
- rv = _VOP_(vop_access, vp)((vp)->v_fbhv, mode, cr)
-#define VOP_LOOKUP(vp,d,vpp,f,rdir,cr,rv) \
- rv = _VOP_(vop_lookup, vp)((vp)->v_fbhv,d,vpp,f,rdir,cr)
-#define VOP_CREATE(dvp,d,vap,vpp,cr,rv) \
- rv = _VOP_(vop_create, dvp)((dvp)->v_fbhv,d,vap,vpp,cr)
-#define VOP_REMOVE(dvp,d,cr,rv) \
- rv = _VOP_(vop_remove, dvp)((dvp)->v_fbhv,d,cr)
-#define VOP_LINK(tdvp,fvp,d,cr,rv) \
- rv = _VOP_(vop_link, tdvp)((tdvp)->v_fbhv,fvp,d,cr)
-#define VOP_RENAME(fvp,fnm,tdvp,tnm,cr,rv) \
- rv = _VOP_(vop_rename, fvp)((fvp)->v_fbhv,fnm,tdvp,tnm,cr)
-#define VOP_MKDIR(dp,d,vap,vpp,cr,rv) \
- rv = _VOP_(vop_mkdir, dp)((dp)->v_fbhv,d,vap,vpp,cr)
-#define VOP_RMDIR(dp,d,cr,rv) \
- rv = _VOP_(vop_rmdir, dp)((dp)->v_fbhv,d,cr)
-#define VOP_READDIR(vp,uiop,cr,eofp,rv) \
- rv = _VOP_(vop_readdir, vp)((vp)->v_fbhv,uiop,cr,eofp)
-#define VOP_SYMLINK(dvp,d,vap,tnm,vpp,cr,rv) \
- rv = _VOP_(vop_symlink, dvp) ((dvp)->v_fbhv,d,vap,tnm,vpp,cr)
-#define VOP_READLINK(vp,uiop,fl,cr,rv) \
- rv = _VOP_(vop_readlink, vp)((vp)->v_fbhv,uiop,fl,cr)
-#define VOP_FSYNC(vp,f,cr,b,e,rv) \
- rv = _VOP_(vop_fsync, vp)((vp)->v_fbhv,f,cr,b,e)
-#define VOP_INACTIVE(vp, cr, rv) \
- rv = _VOP_(vop_inactive, vp)((vp)->v_fbhv, cr)
-#define VOP_RELEASE(vp, rv) \
- rv = _VOP_(vop_release, vp)((vp)->v_fbhv)
-#define VOP_FID2(vp, fidp, rv) \
- rv = _VOP_(vop_fid2, vp)((vp)->v_fbhv, fidp)
-#define VOP_RWLOCK(vp,i) \
- (void)_VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
-#define VOP_RWLOCK_TRY(vp,i) \
- _VOP_(vop_rwlock, vp)((vp)->v_fbhv, i)
-#define VOP_RWUNLOCK(vp,i) \
- (void)_VOP_(vop_rwunlock, vp)((vp)->v_fbhv, i)
-#define VOP_FRLOCK(vp,c,fl,flags,offset,fr,rv) \
- rv = _VOP_(vop_frlock, vp)((vp)->v_fbhv,c,fl,flags,offset,fr)
-#define VOP_RECLAIM(vp, rv) \
- rv = _VOP_(vop_reclaim, vp)((vp)->v_fbhv)
-#define VOP_ATTR_GET(vp, name, val, vallenp, fl, cred, rv) \
- rv = _VOP_(vop_attr_get, vp)((vp)->v_fbhv,name,val,vallenp,fl,cred)
-#define VOP_ATTR_SET(vp, name, val, vallen, fl, cred, rv) \
- rv = _VOP_(vop_attr_set, vp)((vp)->v_fbhv,name,val,vallen,fl,cred)
-#define VOP_ATTR_REMOVE(vp, name, flags, cred, rv) \
- rv = _VOP_(vop_attr_remove, vp)((vp)->v_fbhv,name,flags,cred)
-#define VOP_ATTR_LIST(vp, buf, buflen, fl, cursor, cred, rv) \
- rv = _VOP_(vop_attr_list, vp)((vp)->v_fbhv,buf,buflen,fl,cursor,cred)
-#define VOP_LINK_REMOVED(vp, dvp, linkzero) \
- (void)_VOP_(vop_link_removed, vp)((vp)->v_fbhv, dvp, linkzero)
-#define VOP_VNODE_CHANGE(vp, cmd, val) \
- (void)_VOP_(vop_vnode_change, vp)((vp)->v_fbhv,cmd,val)
-/*
- * These are page cache functions that now go thru VOPs.
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_TOSS_PAGES(vp, first, last, fiopt) \
- _VOP_(vop_tosspages, vp)((vp)->v_fbhv,first, last, fiopt)
-/*
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_FLUSHINVAL_PAGES(vp, first, last, fiopt) \
- _VOP_(vop_flushinval_pages, vp)((vp)->v_fbhv,first,last,fiopt)
-/*
- * 'last' parameter is unused and left in for IRIX compatibility
- */
-#define VOP_FLUSH_PAGES(vp, first, last, flags, fiopt, rv) \
- rv = _VOP_(vop_flush_pages, vp)((vp)->v_fbhv,first,last,flags,fiopt)
-#define VOP_IOCTL(vp, inode, filp, fl, cmd, arg, rv) \
- rv = _VOP_(vop_ioctl, vp)((vp)->v_fbhv,inode,filp,fl,cmd,arg)
-#define VOP_IFLUSH(vp, flags, rv) \
- rv = _VOP_(vop_iflush, vp)((vp)->v_fbhv, flags)
-
-/*
- * Flags for read/write calls - same values as IRIX
- */
-#define IO_ISDIRECT 0x00004 /* bypass page cache */
-#define IO_INVIS 0x00020 /* don't update inode timestamps */
-
-/*
- * Flags for VOP_IFLUSH call
- */
-#define FLUSH_SYNC 1 /* wait for flush to complete */
-#define FLUSH_INODE 2 /* flush the inode itself */
-#define FLUSH_LOG 4 /* force the last log entry for
- * this inode out to disk */
-
-/*
- * Flush/Invalidate options for VOP_TOSS_PAGES, VOP_FLUSHINVAL_PAGES and
- * VOP_FLUSH_PAGES.
- */
-#define FI_NONE 0 /* none */
-#define FI_REMAPF 1 /* Do a remapf prior to the operation */
-#define FI_REMAPF_LOCKED 2 /* Do a remapf prior to the operation.
- Prevent VM access to the pages until
- the operation completes. */
-
-/*
- * Vnode attributes. va_mask indicates those attributes the caller
- * wants to set or extract.
- */
-typedef struct vattr {
- int va_mask; /* bit-mask of attributes present */
- enum vtype va_type; /* vnode type (for create) */
- mode_t va_mode; /* file access mode and type */
- nlink_t va_nlink; /* number of references to file */
- uid_t va_uid; /* owner user id */
- gid_t va_gid; /* owner group id */
- xfs_ino_t va_nodeid; /* file id */
- xfs_off_t va_size; /* file size in bytes */
- u_long va_blocksize; /* blocksize preferred for i/o */
- struct timespec va_atime; /* time of last access */
- struct timespec va_mtime; /* time of last modification */
- struct timespec va_ctime; /* time file changed */
- u_int va_gen; /* generation number of file */
- xfs_dev_t va_rdev; /* device the special file represents */
- __int64_t va_nblocks; /* number of blocks allocated */
- u_long va_xflags; /* random extended file flags */
- u_long va_extsize; /* file extent size */
- u_long va_nextents; /* number of extents in file */
- u_long va_anextents; /* number of attr extents in file */
- int va_projid; /* project id */
-} vattr_t;
-
-/*
- * setattr or getattr attributes
- */
-#define XFS_AT_TYPE 0x00000001
-#define XFS_AT_MODE 0x00000002
-#define XFS_AT_UID 0x00000004
-#define XFS_AT_GID 0x00000008
-#define XFS_AT_FSID 0x00000010
-#define XFS_AT_NODEID 0x00000020
-#define XFS_AT_NLINK 0x00000040
-#define XFS_AT_SIZE 0x00000080
-#define XFS_AT_ATIME 0x00000100
-#define XFS_AT_MTIME 0x00000200
-#define XFS_AT_CTIME 0x00000400
-#define XFS_AT_RDEV 0x00000800
-#define XFS_AT_BLKSIZE 0x00001000
-#define XFS_AT_NBLOCKS 0x00002000
-#define XFS_AT_VCODE 0x00004000
-#define XFS_AT_MAC 0x00008000
-#define XFS_AT_UPDATIME 0x00010000
-#define XFS_AT_UPDMTIME 0x00020000
-#define XFS_AT_UPDCTIME 0x00040000
-#define XFS_AT_ACL 0x00080000
-#define XFS_AT_CAP 0x00100000
-#define XFS_AT_INF 0x00200000
-#define XFS_AT_XFLAGS 0x00400000
-#define XFS_AT_EXTSIZE 0x00800000
-#define XFS_AT_NEXTENTS 0x01000000
-#define XFS_AT_ANEXTENTS 0x02000000
-#define XFS_AT_PROJID 0x04000000
-#define XFS_AT_SIZE_NOPERM 0x08000000
-#define XFS_AT_GENCOUNT 0x10000000
-
-#define XFS_AT_ALL (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
- XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
- XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
- XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|XFS_AT_MAC|\
- XFS_AT_ACL|XFS_AT_CAP|XFS_AT_INF|XFS_AT_XFLAGS|XFS_AT_EXTSIZE|\
- XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_PROJID|XFS_AT_GENCOUNT)
-
-#define XFS_AT_STAT (XFS_AT_TYPE|XFS_AT_MODE|XFS_AT_UID|XFS_AT_GID|\
- XFS_AT_FSID|XFS_AT_NODEID|XFS_AT_NLINK|XFS_AT_SIZE|\
- XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME|XFS_AT_RDEV|\
- XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_PROJID)
-
-#define XFS_AT_TIMES (XFS_AT_ATIME|XFS_AT_MTIME|XFS_AT_CTIME)
-
-#define XFS_AT_UPDTIMES (XFS_AT_UPDATIME|XFS_AT_UPDMTIME|XFS_AT_UPDCTIME)
-
-#define XFS_AT_NOSET (XFS_AT_NLINK|XFS_AT_RDEV|XFS_AT_FSID|XFS_AT_NODEID|\
- XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\
- XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT)
-
-/*
- * Modes.
- */
-#define VSUID S_ISUID /* set user id on execution */
-#define VSGID S_ISGID /* set group id on execution */
-#define VSVTX S_ISVTX /* save swapped text even after use */
-#define VREAD S_IRUSR /* read, write, execute permissions */
-#define VWRITE S_IWUSR
-#define VEXEC S_IXUSR
-
-#define MODEMASK S_IALLUGO /* mode bits plus permission bits */
-
-/*
- * Check whether mandatory file locking is enabled.
- */
-#define MANDLOCK(vp, mode) \
- ((vp)->v_type == VREG && ((mode) & (VSGID|(VEXEC>>3))) == VSGID)
-
-extern void vn_init(void);
-extern int vn_wait(struct vnode *);
-extern vnode_t *vn_initialize(struct inode *);
-
-/*
- * Acquiring and invalidating vnodes:
- *
- * if (vn_get(vp, version, 0))
- * ...;
- * vn_purge(vp, version);
- *
- * vn_get and vn_purge must be called with vmap_t arguments, sampled
- * while a lock that the vnode's VOP_RECLAIM function acquires is
- * held, to ensure that the vnode sampled with the lock held isn't
- * recycled (VOP_RECLAIMed) or deallocated between the release of the lock
- * and the subsequent vn_get or vn_purge.
- */
-
-/*
- * vnode_map structures _must_ match vn_epoch and vnode structure sizes.
- */
-typedef struct vnode_map {
- vfs_t *v_vfsp;
- vnumber_t v_number; /* in-core vnode number */
- xfs_ino_t v_ino; /* inode # */
-} vmap_t;
-
-#define VMAP(vp, vmap) {(vmap).v_vfsp = (vp)->v_vfsp, \
- (vmap).v_number = (vp)->v_number, \
- (vmap).v_ino = (vp)->v_inode.i_ino; }
-
-extern void vn_purge(struct vnode *, vmap_t *);
-extern vnode_t *vn_get(struct vnode *, vmap_t *);
-extern int vn_revalidate(struct vnode *);
-extern void vn_remove(struct vnode *);
-
-static inline int vn_count(struct vnode *vp)
-{
- return atomic_read(&LINVFS_GET_IP(vp)->i_count);
-}
-
-/*
- * Vnode reference counting functions (and macros for compatibility).
- */
-extern vnode_t *vn_hold(struct vnode *);
-extern void vn_rele(struct vnode *);
-
-#if defined(XFS_VNODE_TRACE)
-#define VN_HOLD(vp) \
- ((void)vn_hold(vp), \
- vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
-#define VN_RELE(vp) \
- (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
- iput(LINVFS_GET_IP(vp)))
-#else
-#define VN_HOLD(vp) ((void)vn_hold(vp))
-#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
-#endif
-
-/*
- * Vname handling macros.
- */
-#define VNAME(dentry) ((char *) (dentry)->d_name.name)
-#define VNAMELEN(dentry) ((dentry)->d_name.len)
-#define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode))
-
-/*
- * Vnode spinlock manipulation.
- */
-#define VN_LOCK(vp) mutex_spinlock(&(vp)->v_lock)
-#define VN_UNLOCK(vp, s) mutex_spinunlock(&(vp)->v_lock, s)
-#define VN_FLAGSET(vp,b) vn_flagset(vp,b)
-#define VN_FLAGCLR(vp,b) vn_flagclr(vp,b)
-
-static __inline__ void vn_flagset(struct vnode *vp, uint flag)
-{
- spin_lock(&vp->v_lock);
- vp->v_flag |= flag;
- spin_unlock(&vp->v_lock);
-}
-
-static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
-{
- spin_lock(&vp->v_lock);
- vp->v_flag &= ~flag;
- spin_unlock(&vp->v_lock);
-}
-
-/*
- * Update modify/access/change times on the vnode
- */
-#define VN_MTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
-#define VN_ATIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_atime = *(tvp))
-#define VN_CTIMESET(vp, tvp) (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
-
-/*
- * Some useful predicates.
- */
-#define VN_MAPPED(vp) mapping_mapped(LINVFS_GET_IP(vp)->i_mapping)
-#define VN_CACHED(vp) (LINVFS_GET_IP(vp)->i_mapping->nrpages)
-#define VN_DIRTY(vp) mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \
- PAGECACHE_TAG_DIRTY)
-#define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED)
-#define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED)
-
-/*
- * Flags to VOP_SETATTR/VOP_GETATTR.
- */
-#define ATTR_UTIME 0x01 /* non-default utime(2) request */
-#define ATTR_DMI 0x08 /* invocation from a DMI function */
-#define ATTR_LAZY 0x80 /* set/get attributes lazily */
-#define ATTR_NONBLOCK 0x100 /* return EAGAIN if operation would block */
-
-/*
- * Flags to VOP_FSYNC and VOP_RECLAIM.
- */
-#define FSYNC_NOWAIT 0 /* asynchronous flush */
-#define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
-#define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
-#define FSYNC_DATA 0x4 /* synchronous fsync of data only */
-
-/*
- * Tracking vnode activity.
- */
-#if defined(XFS_VNODE_TRACE)
-
-#define VNODE_TRACE_SIZE 16 /* number of trace entries */
-#define VNODE_KTRACE_ENTRY 1
-#define VNODE_KTRACE_EXIT 2
-#define VNODE_KTRACE_HOLD 3
-#define VNODE_KTRACE_REF 4
-#define VNODE_KTRACE_RELE 5
-
-extern void vn_trace_entry(struct vnode *, char *, inst_t *);
-extern void vn_trace_exit(struct vnode *, char *, inst_t *);
-extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
-extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
-extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
-
-#define VN_TRACE(vp) \
- vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
-#else
-#define vn_trace_entry(a,b,c)
-#define vn_trace_exit(a,b,c)
-#define vn_trace_hold(a,b,c,d)
-#define vn_trace_ref(a,b,c,d)
-#define vn_trace_rele(a,b,c,d)
-#define VN_TRACE(vp)
-#endif
-
-#endif /* __XFS_VNODE_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-STATIC int xfs_cap_allow_set(vnode_t *);
-
-
-/*
- * Test for existence of capability attribute as efficiently as possible.
- */
-int
-xfs_cap_vhascap(
- vnode_t *vp)
-{
- int error;
- int len = sizeof(xfs_cap_set_t);
- int flags = ATTR_KERNOVAL|ATTR_ROOT;
-
- VOP_ATTR_GET(vp, SGI_CAP_LINUX, NULL, &len, flags, sys_cred, error);
- return (error == 0);
-}
-
-/*
- * Convert from extended attribute representation to in-memory for XFS.
- */
-STATIC int
-posix_cap_xattr_to_xfs(
- posix_cap_xattr *src,
- size_t size,
- xfs_cap_set_t *dest)
-{
- if (!src || !dest)
- return EINVAL;
-
- if (src->c_version != cpu_to_le32(POSIX_CAP_XATTR_VERSION))
- return EINVAL;
- if (src->c_abiversion != cpu_to_le32(_LINUX_CAPABILITY_VERSION))
- return EINVAL;
-
- if (size < sizeof(posix_cap_xattr))
- return EINVAL;
-
- ASSERT(sizeof(dest->cap_effective) == sizeof(src->c_effective));
-
- dest->cap_effective = src->c_effective;
- dest->cap_permitted = src->c_permitted;
- dest->cap_inheritable = src->c_inheritable;
-
- return 0;
-}
-
-/*
- * Convert from in-memory XFS to extended attribute representation.
- */
-STATIC int
-posix_cap_xfs_to_xattr(
- xfs_cap_set_t *src,
- posix_cap_xattr *xattr_cap,
- size_t size)
-{
- size_t new_size = posix_cap_xattr_size();
-
- if (size < new_size)
- return -ERANGE;
-
- ASSERT(sizeof(xattr_cap->c_effective) == sizeof(src->cap_effective));
-
- xattr_cap->c_version = cpu_to_le32(POSIX_CAP_XATTR_VERSION);
- xattr_cap->c_abiversion = cpu_to_le32(_LINUX_CAPABILITY_VERSION);
- xattr_cap->c_effective = src->cap_effective;
- xattr_cap->c_permitted = src->cap_permitted;
- xattr_cap->c_inheritable= src->cap_inheritable;
-
- return new_size;
-}
-
-int
-xfs_cap_vget(
- vnode_t *vp,
- void *cap,
- size_t size)
-{
- int error;
- int len = sizeof(xfs_cap_set_t);
- int flags = ATTR_ROOT;
- xfs_cap_set_t xfs_cap = { 0 };
- posix_cap_xattr *xattr_cap = cap;
- char *data = (char *)&xfs_cap;
-
- VN_HOLD(vp);
- if ((error = _MAC_VACCESS(vp, NULL, VREAD)))
- goto out;
-
- if (!size) {
- flags |= ATTR_KERNOVAL;
- data = NULL;
- }
- VOP_ATTR_GET(vp, SGI_CAP_LINUX, data, &len, flags, sys_cred, error);
- if (error)
- goto out;
- ASSERT(len == sizeof(xfs_cap_set_t));
-
- error = (size)? -posix_cap_xattr_size() :
- -posix_cap_xfs_to_xattr(&xfs_cap, xattr_cap, size);
-out:
- VN_RELE(vp);
- return -error;
-}
-
-int
-xfs_cap_vremove(
- vnode_t *vp)
-{
- int error;
-
- VN_HOLD(vp);
- error = xfs_cap_allow_set(vp);
- if (!error) {
- VOP_ATTR_REMOVE(vp, SGI_CAP_LINUX, ATTR_ROOT, sys_cred, error);
- if (error == ENOATTR)
- error = 0; /* 'scool */
- }
- VN_RELE(vp);
- return -error;
-}
-
-int
-xfs_cap_vset(
- vnode_t *vp,
- void *cap,
- size_t size)
-{
- posix_cap_xattr *xattr_cap = cap;
- xfs_cap_set_t xfs_cap;
- int error;
-
- if (!cap)
- return -EINVAL;
-
- error = posix_cap_xattr_to_xfs(xattr_cap, size, &xfs_cap);
- if (error)
- return -error;
-
- VN_HOLD(vp);
- error = xfs_cap_allow_set(vp);
- if (error)
- goto out;
-
- VOP_ATTR_SET(vp, SGI_CAP_LINUX, (char *)&xfs_cap,
- sizeof(xfs_cap_set_t), ATTR_ROOT, sys_cred, error);
-out:
- VN_RELE(vp);
- return -error;
-}
-
-STATIC int
-xfs_cap_allow_set(
- vnode_t *vp)
-{
- vattr_t va;
- int error;
-
- if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
- return EROFS;
- if (vp->v_inode.i_flags & (S_IMMUTABLE|S_APPEND))
- return EPERM;
- if ((error = _MAC_VACCESS(vp, NULL, VWRITE)))
- return error;
- va.va_mask = XFS_AT_UID;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (error)
- return error;
- if (va.va_uid != current->fsuid && !capable(CAP_FOWNER))
- return EPERM;
- return error;
-}
+++ /dev/null
-/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like. Any license provided herein, whether implied or
- * otherwise, applies only to this software file. Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
- */
-
-#include "xfs.h"
-
-static xfs_mac_label_t *mac_low_high_lp;
-static xfs_mac_label_t *mac_high_low_lp;
-static xfs_mac_label_t *mac_admin_high_lp;
-static xfs_mac_label_t *mac_equal_equal_lp;
-
-/*
- * Test for the existence of a MAC label as efficiently as possible.
- */
-int
-xfs_mac_vhaslabel(
- vnode_t *vp)
-{
- int error;
- int len = sizeof(xfs_mac_label_t);
- int flags = ATTR_KERNOVAL|ATTR_ROOT;
-
- VOP_ATTR_GET(vp, SGI_MAC_FILE, NULL, &len, flags, sys_cred, error);
- return (error == 0);
-}
-
-int
-xfs_mac_iaccess(xfs_inode_t *ip, mode_t mode, struct cred *cr)
-{
- xfs_mac_label_t mac;
- xfs_mac_label_t *mp = mac_high_low_lp;
-
- if (cr == NULL || sys_cred == NULL ) {
- return EACCES;
- }
-
- if (xfs_attr_fetch(ip, SGI_MAC_FILE, (char *)&mac, sizeof(mac)) == 0) {
- if ((mp = mac_add_label(&mac)) == NULL) {
- return mac_access(mac_high_low_lp, cr, mode);
- }
- }
-
- return mac_access(mp, cr, mode);
-}
+++ /dev/null
-#ifndef _ASM_ALPHA_CPUMASK_H
-#define _ASM_ALPHA_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ALPHA_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _ALPHA_RMAP_H
-#define _ALPHA_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm/arch-80200fcc/adi_evb.h
- *
- * ADI 80200FCC evaluation board definitions
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#define ADI_EVB__RAMBASE 0xa0000000
-#define ADI_EVB__UART 0x00400000 /* UART */
-#define ADI_EVB_7SEG_1 0x00500000 /* 7-Segment */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-80200fcc/dma.h
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __ASM_ARCH_DMA_H
-#define __ASM_ARCH_DMA_H
-
-#define MAX_DMA_ADDRESS 0xffffffff
-
-/* No DMA */
-#define MAX_DMA_CHANNELS 0
-
-#endif /* _ASM_ARCH_DMA_H */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/hardware.h
- *
- * Hardware definitions for ADI based systems
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2000-2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-#include <linux/config.h>
-
-#define PCIO_BASE 0
-
-#if defined(CONFIG_ARCH_ADI_EVB)
-#include "adi_evb.h"
-#endif
-
-#endif /* _ASM_ARCH_HARDWARE_H */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/io.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffffffff
-
-#define __io(a) (PCIO_BASE + (a))
-#define __mem_pci(a) ((unsigned long)(a))
-#define __mem_isa(a) ((unsigned long)(a))
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-80200fcc/irqs.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define IRQ_XS80200_BCU 0 /* Bus Control Unit */
-#define IRQ_XS80200_PMU 1 /* Performance Monitoring Unit */
-#define IRQ_XS80200_EXTIRQ 2 /* external IRQ signal */
-#define IRQ_XS80200_EXTFIQ 3 /* external IRQ signal */
-
-#define NR_XS80200_IRQS 4
-#define NR_IRQS NR_XS80200_IRQS
-
-#define IRQ_XSCALE_PMU IRQ_XS80200_PMU
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/memory.h
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- */
-
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET (0xC0000000UL)
-
-/*
- * Virtual view <-> DMA view memory address translations
- * virt_to_bus: Used to translate the virtual address to an
- * address suitable to be passed to set_dma_addr
- * bus_to_virt: Used to convert an address for DMA operations
- * to an address that the kernel can use.
- *
- * These are dummies for now.
- */
-#define __virt_to_bus(x) __virt_to_phys(x)
-#define __bus_to_virt(x) __phys_to_virt(x)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/param.h
- */
+++ /dev/null
-/*
- * include/asm-arm/arch-adifcc/serial.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- */
-#include <linux/config.h>
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD ( 1852000 / 16 )
-
-/* Standard COM flags */
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-#ifdef CONFIG_ARCH_ADI_EVB
-
-/*
- * One serial port, int goes to FIQ, so we run in polled mode
- */
-#define STD_SERIAL_PORT_DEFNS \
- /* UART CLK PORT IRQ FLAGS */ \
- { 0, BASE_BAUD, 0xff400000, 0, STD_COM_FLAGS } /* ttyS0 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/system.h
- *
- * Copyright (C) 2001 MontaVista Software, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-static inline void arch_idle(void)
-{
-#if 0
- cpu_do_idle();
-#endif
-}
-
-
-static inline void arch_reset(char mode)
-{
- if ( 1 && mode == 's') {
- /* Jump into ROM at address 0 */
- cpu_reset(0);
- } else {
- /* Use on-chip reset capability */
- }
-}
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/time.h
- *
- */
-
-/*
- * No on board timer, implementation @ arch/arm/kernel/xscale-time.c
- */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/timex.h
- *
- * XScale architecture timex specifications
- */
-
-/* This is for a timer based on the XS80200's PMU counter */
-
-#define CLOCK_TICK_RATE 600000000 /* Underlying HZ */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/uncompress.h
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright (c) 2001 MontaVista Software, Inc.
- *
- */
-
-#define UART_BASE ((volatile unsigned char *)0x00400000)
-
-static __inline__ void putc(char c)
-{
- while ((UART_BASE[5] & 0x60) != 0x60);
- UART_BASE[0] = c;
-}
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
- while (*s) {
- putc(*s);
- if (*s == '\n')
- putc('\r');
- s++;
- }
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-#define arch_decomp_wdog()
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-adifcc/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts. That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET (8*1024*1024)
-#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END (0xe8000000)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-cl7500/ide.h
- *
- * Copyright (c) 1997 Russell King
- *
- * Modifications:
- * 29-07-1998 RMK Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-#include <asm/arch/hardware.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- if (ctrl_port) {
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- } else {
- hw->io_ports[IDE_CONTROL_OFFSET] = data_port + 0x206;
- }
- if (irq != NULL)
- *irq = 0;
- hw->io_ports[IDE_IRQ_OFFSET] = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
- hw_regs_t hw;
-
- ide_init_hwif_ports(&hw, ISASLOT_IO + 0x1f0, ISASLOT_IO + 0x3f6, NULL);
- hw.irq = IRQ_ISA_14;
- ide_register_hw(&hw);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-cl7500/keyboard.h
- * from linux/include/asm-arm/arch-rpc/keyboard.h
- *
- * Keyboard driver definitions for CL7500 architecture
- *
- * Copyright (C) 1998-2001 Russell King
- */
-#include <asm/irq.h>
-#define NR_SCANCODES 128
-
-extern int ps2kbd_init_hw(void);
-
-#define kbd_disable_irq() disable_irq(IRQ_KEYBOARDRX)
-#define kbd_enable_irq() enable_irq(IRQ_KEYBOARDRX)
-#define kbd_init_hw() ps2kbd_init_hw()
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-cl7500/time.h
- *
- * Copyright (c) 1996-2000 Russell King.
- *
- * Changelog:
- * 24-Sep-1996 RMK Created
- * 10-Oct-1996 RMK Brought up to date with arch-sa110eval
- * 04-Dec-1997 RMK Updated for new arch/arm/time.c
- */
-
-extern void ioctime_init(void);
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- do_timer(regs);
- do_set_rtc();
- do_profile(regs);
-
- {
- /* Twinkle the lights. */
- static int count, state = 0xff00;
- if (count-- == 0) {
- state ^= 0x100;
- count = 25;
- *((volatile unsigned int *)LED_ADDRESS) = state;
- }
- }
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
- ioctime_init();
-
- timer_irq.handler = timer_interrupt;
-
- setup_irq(IRQ_TIMER, &timer_irq);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-clps711x/keyboard.h
- *
- * Copyright (C) 1998-2001 Russell King
- */
-#include <asm/mach-types.h>
-
-#define NR_SCANCODES 128
-
-#define kbd_disable_irq() do { } while (0)
-#define kbd_enable_irq() do { } while (0)
-
-/*
- * EDB7211 keyboard driver
- */
-extern void edb7211_kbd_init_hw(void);
-extern void clps711x_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
- if (machine_is_edb7211())
- edb7211_kbd_init_hw();
-
- if (machine_is_autcpu12())
- clps711x_kbd_init_hw();
-}
+++ /dev/null
-/* no ide */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-ebsa110/time.h
- *
- * Copyright (C) 1996,1997,1998 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * No real time clock on the evalulation board!
- *
- * Changelog:
- * 10-Oct-1996 RMK Created
- * 04-Dec-1997 RMK Updated for new arch/arm/kernel/time.c
- * 07-Aug-1998 RMK Updated for arch/arm/kernel/leds.c
- * 28-Dec-1998 APH Made leds code optional
- */
-
-#include <asm/leds.h>
-#include <asm/io.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-#define PIT_CTRL (PIT_BASE + 0x0d)
-#define PIT_T2 (PIT_BASE + 0x09)
-#define PIT_T1 (PIT_BASE + 0x05)
-#define PIT_T0 (PIT_BASE + 0x01)
-
-/*
- * This is the rate at which your MCLK signal toggles (in Hz)
- * This was measured on a 10 digit frequency counter sampling
- * over 1 second.
- */
-#define MCLK 47894000
-
-/*
- * This is the rate at which the PIT timers get clocked
- */
-#define CLKBY7 (MCLK / 7)
-
-/*
- * This is the counter value. We tick at 200Hz on this platform.
- */
-#define COUNT ((CLKBY7 + (HZ / 2)) / HZ)
-
-/*
- * Get the time offset from the system PIT. Note that if we have missed an
- * interrupt, then the PIT counter will roll over (ie, be negative).
- * This actually works out to be convenient.
- */
-static unsigned long ebsa110_gettimeoffset(void)
-{
- unsigned long offset, count;
-
- __raw_writeb(0x40, PIT_CTRL);
- count = __raw_readb(PIT_T1);
- count |= __raw_readb(PIT_T1) << 8;
-
- /*
- * If count > COUNT, make the number negative.
- */
- if (count > COUNT)
- count |= 0xffff0000;
-
- offset = COUNT;
- offset -= count;
-
- /*
- * `offset' is in units of timer counts. Convert
- * offset to units of microseconds.
- */
- offset = offset * (1000000 / HZ) / COUNT;
-
- return offset;
-}
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- u32 count;
-
- /* latch and read timer 1 */
- __raw_writeb(0x40, PIT_CTRL);
- count = __raw_readb(PIT_T1);
- count |= __raw_readb(PIT_T1) << 8;
-
- count += COUNT;
-
- __raw_writeb(count & 0xff, PIT_T1);
- __raw_writeb(count >> 8, PIT_T1);
-
- do_leds();
- do_timer(regs);
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
- /*
- * Timer 1, mode 2, LSB/MSB
- */
- __raw_writeb(0x70, PIT_CTRL);
- __raw_writeb(COUNT & 0xff, PIT_T1);
- __raw_writeb(COUNT >> 8, PIT_T1);
-
- gettimeoffset = ebsa110_gettimeoffset;
-
- timer_irq.handler = timer_interrupt;
-
- setup_irq(IRQ_EBSA110_TIMER0, &timer_irq);
-}
-
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-ebsa285/ide.h
- *
- * Copyright (C) 1998 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Modifications:
- * 29-07-1998 RMK Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- if (irq)
- *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
-#if 0
- hw_regs_t hw;
-
- memset(hw, 0, sizeof(*hw));
-
- ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
- hw.irq = IRQ_HARDDISK;
- ide_register_hw(&hw);
-#endif
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-ebsa285/time.h
- *
- * Copyright (C) 1998 Russell King.
- * Copyright (C) 1998 Phil Blundell
- *
- * CATS has a real-time clock, though the evaluation board doesn't.
- *
- * Changelog:
- * 21-Mar-1998 RMK Created
- * 27-Aug-1998 PJB CATS support
- * 28-Dec-1998 APH Made leds optional
- * 20-Jan-1999 RMK Started merge of EBSA285, CATS and NetWinder
- * 16-Mar-1999 RMK More support for EBSA285-like machines with RTCs in
- */
-
-#define RTC_PORT(x) (rtc_base+(x))
-#define RTC_ALWAYS_BCD 0
-
-#include <linux/mc146818rtc.h>
-#include <linux/bcd.h>
-
-#include <asm/hardware/dec21285.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
-
-static int rtc_base;
-
-#define mSEC_10_from_14 ((14318180 + 100) / 200)
-
-static unsigned long isa_gettimeoffset(void)
-{
- int count;
-
- static int count_p = (mSEC_10_from_14/6); /* for the first call after boot */
- static unsigned long jiffies_p = 0;
-
- /*
- * cache volatile jiffies temporarily; we have IRQs turned off.
- */
- unsigned long jiffies_t;
-
- /* timer count may underflow right here */
- outb_p(0x00, 0x43); /* latch the count ASAP */
-
- count = inb_p(0x40); /* read the latched count */
-
- /*
- * We do this guaranteed double memory access instead of a _p
- * postfix in the previous port access. Wheee, hackady hack
- */
- jiffies_t = jiffies;
-
- count |= inb_p(0x40) << 8;
-
- /* Detect timer underflows. If we haven't had a timer tick since
- the last time we were called, and time is apparently going
- backwards, the counter must have wrapped during this routine. */
- if ((jiffies_t == jiffies_p) && (count > count_p))
- count -= (mSEC_10_from_14/6);
- else
- jiffies_p = jiffies_t;
-
- count_p = count;
-
- count = (((mSEC_10_from_14/6)-1) - count) * (tick_nsec / 1000);
- count = (count + (mSEC_10_from_14/6)/2) / (mSEC_10_from_14/6);
-
- return count;
-}
-
-static irqreturn_t
-isa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- if (machine_is_netwinder())
- do_leds();
-
- do_timer(regs);
- do_set_rtc();
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-static unsigned long __init get_isa_cmos_time(void)
-{
- unsigned int year, mon, day, hour, min, sec;
- int i;
-
- // check to see if the RTC makes sense.....
- if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
- return mktime(1970, 1, 1, 0, 0, 0);
-
- /* The Linux interpretation of the CMOS clock register contents:
- * When the Update-In-Progress (UIP) flag goes from 1 to 0, the
- * RTC registers show the second which has precisely just started.
- * Let's hope other operating systems interpret the RTC the same way.
- */
- /* read RTC exactly on falling edge of update flag */
- for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */
- if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)
- break;
-
- for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */
- if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP))
- break;
-
- do { /* Isn't this overkill ? UIP above should guarantee consistency */
- sec = CMOS_READ(RTC_SECONDS);
- min = CMOS_READ(RTC_MINUTES);
- hour = CMOS_READ(RTC_HOURS);
- day = CMOS_READ(RTC_DAY_OF_MONTH);
- mon = CMOS_READ(RTC_MONTH);
- year = CMOS_READ(RTC_YEAR);
- } while (sec != CMOS_READ(RTC_SECONDS));
-
- if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
- BCD_TO_BIN(sec);
- BCD_TO_BIN(min);
- BCD_TO_BIN(hour);
- BCD_TO_BIN(day);
- BCD_TO_BIN(mon);
- BCD_TO_BIN(year);
- }
- if ((year += 1900) < 1970)
- year += 100;
- return mktime(year, mon, day, hour, min, sec);
-}
-
-static int
-set_isa_cmos_time(void)
-{
- int retval = 0;
- int real_seconds, real_minutes, cmos_minutes;
- unsigned char save_control, save_freq_select;
- unsigned long nowtime = xtime.tv_sec;
-
- save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
- CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
-
- save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
- CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
-
- cmos_minutes = CMOS_READ(RTC_MINUTES);
- if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
- BCD_TO_BIN(cmos_minutes);
-
- /*
- * since we're only adjusting minutes and seconds,
- * don't interfere with hour overflow. This avoids
- * messing with unknown time zones but requires your
- * RTC not to be off by more than 15 minutes
- */
- real_seconds = nowtime % 60;
- real_minutes = nowtime / 60;
- if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
- real_minutes += 30; /* correct for half hour time zone */
- real_minutes %= 60;
-
- if (abs(real_minutes - cmos_minutes) < 30) {
- if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
- BIN_TO_BCD(real_seconds);
- BIN_TO_BCD(real_minutes);
- }
- CMOS_WRITE(real_seconds,RTC_SECONDS);
- CMOS_WRITE(real_minutes,RTC_MINUTES);
- } else
- retval = -1;
-
- /* The following flags have to be released exactly in this order,
- * otherwise the DS12887 (popular MC146818A clone with integrated
- * battery and quartz) will not reset the oscillator and will not
- * update precisely 500 ms later. You won't find this mentioned in
- * the Dallas Semiconductor data sheets, but who believes data
- * sheets anyway ... -- Markus Kuhn
- */
- CMOS_WRITE(save_control, RTC_CONTROL);
- CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-
- return retval;
-}
-
-
-static unsigned long timer1_latch;
-
-static unsigned long timer1_gettimeoffset (void)
-{
- unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
-
- return ((tick_nsec / 1000) * value) / timer1_latch;
-}
-
-static irqreturn_t
-timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- *CSR_TIMER1_CLR = 0;
-
- /* Do the LEDs things */
- do_leds();
- do_timer(regs);
- do_set_rtc();
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
- int irq;
-
- if (machine_is_co285() ||
- machine_is_personal_server())
- /*
- * Add-in 21285s shouldn't access the RTC
- */
- rtc_base = 0;
- else
- rtc_base = 0x70;
-
- if (rtc_base) {
- int reg_d, reg_b;
-
- /*
- * Probe for the RTC.
- */
- reg_d = CMOS_READ(RTC_REG_D);
-
- /*
- * make sure the divider is set
- */
- CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
-
- /*
- * Set control reg B
- * (24 hour mode, update enabled)
- */
- reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
- reg_b |= 2;
- CMOS_WRITE(reg_b, RTC_REG_B);
-
- if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
- CMOS_READ(RTC_REG_B) == reg_b) {
- struct timespec tv;
-
- /*
- * We have a RTC. Check the battery
- */
- if ((reg_d & 0x80) == 0)
- printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
-
- tv.tv_nsec = 0;
- tv.tv_sec = get_isa_cmos_time();
- do_settimeofday(&tv);
- set_rtc = set_isa_cmos_time;
- } else
- rtc_base = 0;
- }
-
- if (machine_is_ebsa285() ||
- machine_is_co285() ||
- machine_is_personal_server()) {
- gettimeoffset = timer1_gettimeoffset;
-
- timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
-
- *CSR_TIMER1_CLR = 0;
- *CSR_TIMER1_LOAD = timer1_latch;
- *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
-
- timer_irq.handler = timer1_interrupt;
- irq = IRQ_TIMER1;
- } else {
- /* enable PIT timer */
- /* set for periodic (4) and LSB/MSB write (0x30) */
- outb(0x34, 0x43);
- outb((mSEC_10_from_14/6) & 0xFF, 0x40);
- outb((mSEC_10_from_14/6) >> 8, 0x40);
-
- gettimeoffset = isa_gettimeoffset;
- timer_irq.handler = isa_timer_interrupt;
- irq = IRQ_ISA_TIMER;
- }
- setup_irq(irq, &timer_irq);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-epxa10db/time.h
- *
- * Copyright (C) 2001 Altera Corporation
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <asm/system.h>
-#include <asm/leds.h>
-#include <asm/arch/hardware.h>
-#define TIMER00_TYPE (volatile unsigned int*)
-#include <asm/arch/timer00.h>
-
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t
-excalibur_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
-
- // ...clear the interrupt
- *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;
-
- do_leds();
- do_timer(regs);
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
- timer_irq.handler = excalibur_timer_interrupt;
-
- /*
- * Make irqs happen for the system timer
- */
- setup_irq(IRQ_TIMER0, &timer_irq);
-
- /* Start the timer */
- *TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
- *TIMER0_PRESCALE(IO_ADDRESS(EXC_TIMER00_BASE))=1;
- *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))=TIMER0_CR_IE_MSK | TIMER0_CR_S_MSK;
-}
+++ /dev/null
-/*
- * include/asm-arm/arch-iop3xx/ide.h
- *
- * Generic IDE functions for IOP310 systems
- *
- * Author: Deepak Saxena <dsaxena@mvista.com>
- *
- * Copyright 2001 MontaVista Software Inc.
- *
- * 09/26/2001 - Sharon Baartmans
- * Fixed so it actually works.
- */
-
-#ifndef _ASM_ARCH_IDE_H_
-#define _ASM_ARCH_IDE_H_
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
- int regincr = 1;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += regincr;
- }
-
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-
- if (irq) *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
- /* There are no standard ports */
-}
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-iop310/irqs.h
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * 06/13/01: Added 80310 on-chip interrupt sources <dsaxena@mvista.com>
- *
- */
-#include <linux/config.h>
-
-/*
- * XS80200 specific IRQs
- */
-#define IRQ_XS80200_BCU 0 /* Bus Control Unit */
-#define IRQ_XS80200_PMU 1 /* Performance Monitoring Unit */
-#define IRQ_XS80200_EXTIRQ 2 /* external IRQ signal */
-#define IRQ_XS80200_EXTFIQ 3 /* external IRQ signal */
-
-#define NR_XS80200_IRQS 4
-
-#define XSCALE_PMU_IRQ IRQ_XS80200_PMU
-
-/*
- * IOP80310 chipset interrupts
- */
-#define IOP310_IRQ_OFS NR_XS80200_IRQS
-#define IOP310_IRQ(x) (IOP310_IRQ_OFS + (x))
-
-/*
- * On FIQ1ISR register
- */
-#define IRQ_IOP310_DMA0 IOP310_IRQ(0) /* DMA Channel 0 */
-#define IRQ_IOP310_DMA1 IOP310_IRQ(1) /* DMA Channel 1 */
-#define IRQ_IOP310_DMA2 IOP310_IRQ(2) /* DMA Channel 2 */
-#define IRQ_IOP310_PMON IOP310_IRQ(3) /* Bus performance Unit */
-#define IRQ_IOP310_AAU IOP310_IRQ(4) /* Application Accelator Unit */
-
-/*
- * On FIQ2ISR register
- */
-#define IRQ_IOP310_I2C IOP310_IRQ(5) /* I2C unit */
-#define IRQ_IOP310_MU IOP310_IRQ(6) /* messaging unit */
-
-#define NR_IOP310_IRQS (IOP310_IRQ(6) + 1)
-
-#define NR_IRQS NR_IOP310_IRQS
-
-
-/*
- * Interrupts available on the Cyclone IQ80310 board
- */
-#ifdef CONFIG_ARCH_IQ80310
-
-#define IQ80310_IRQ_OFS NR_IOP310_IRQS
-#define IQ80310_IRQ(y) ((IQ80310_IRQ_OFS) + (y))
-
-#define IRQ_IQ80310_TIMER IQ80310_IRQ(0) /* Timer Interrupt */
-#define IRQ_IQ80310_I82559 IQ80310_IRQ(1) /* I82559 Ethernet Interrupt */
-#define IRQ_IQ80310_UART1 IQ80310_IRQ(2) /* UART1 Interrupt */
-#define IRQ_IQ80310_UART2 IQ80310_IRQ(3) /* UART2 Interrupt */
-#define IRQ_IQ80310_INTD IQ80310_IRQ(4) /* PCI INTD */
-
-
-/*
- * ONLY AVAILABLE ON REV F OR NEWER BOARDS!
- */
-#define IRQ_IQ80310_INTA IQ80310_IRQ(5) /* PCI INTA */
-#define IRQ_IQ80310_INTB IQ80310_IRQ(6) /* PCI INTB */
-#define IRQ_IQ80310_INTC IQ80310_IRQ(7) /* PCI INTC */
-
-#undef NR_IRQS
-#define NR_IRQS (IQ80310_IRQ(7) + 1)
-
-#endif // CONFIG_ARCH_IQ80310
-
+++ /dev/null
-/*
- * linux/include/asm/arch-iop3xx/iop310.h
- *
- * Intel IOP310 Companion Chip definitions
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _IOP310_HW_H_
-#define _IOP310_HW_H_
-
-/*
- * This is needed for mixed drivers that need to work on all
- * IOP3xx variants but behave slightly differently on each.
- */
-#ifndef __ASSEMBLY__
-#define iop_is_310() ((processor_id & 0xffffe3f0) == 0x69052000)
-#endif
-
-/*
- * IOP310 I/O and Mem space regions for PCI autoconfiguration
- */
-#define IOP310_PCISEC_LOWER_IO 0x90010000
-#define IOP310_PCISEC_UPPER_IO 0x9001ffff
-#define IOP310_PCISEC_LOWER_MEM 0x88000000
-#define IOP310_PCISEC_UPPER_MEM 0x8bffffff
-
-#define IOP310_PCIPRI_LOWER_IO 0x90000000
-#define IOP310_PCIPRI_UPPER_IO 0x9000ffff
-#define IOP310_PCIPRI_LOWER_MEM 0x80000000
-#define IOP310_PCIPRI_UPPER_MEM 0x83ffffff
-
-#define IOP310_PCI_WINDOW_SIZE 64 * 0x100000
-
-/*
- * IOP310 chipset registers
- */
-#define IOP310_VIRT_MEM_BASE 0xe8001000 /* chip virtual mem address*/
-#define IOP310_PHY_MEM_BASE 0x00001000 /* chip physical memory address */
-#define IOP310_REG_ADDR(reg) (IOP310_VIRT_MEM_BASE | IOP310_PHY_MEM_BASE | (reg))
-
-/* PCI-to-PCI Bridge Unit 0x00001000 through 0x000010FF */
-#define IOP310_VIDR (volatile u16 *)IOP310_REG_ADDR(0x00001000)
-#define IOP310_DIDR (volatile u16 *)IOP310_REG_ADDR(0x00001002)
-#define IOP310_PCR (volatile u16 *)IOP310_REG_ADDR(0x00001004)
-#define IOP310_PSR (volatile u16 *)IOP310_REG_ADDR(0x00001006)
-#define IOP310_RIDR (volatile u8 *)IOP310_REG_ADDR(0x00001008)
-#define IOP310_CCR (volatile u32 *)IOP310_REG_ADDR(0x00001009)
-#define IOP310_CLSR (volatile u8 *)IOP310_REG_ADDR(0x0000100C)
-#define IOP310_PLTR (volatile u8 *)IOP310_REG_ADDR(0x0000100D)
-#define IOP310_HTR (volatile u8 *)IOP310_REG_ADDR(0x0000100E)
-/* Reserved 0x0000100F through 0x00001017 */
-#define IOP310_PBNR (volatile u8 *)IOP310_REG_ADDR(0x00001018)
-#define IOP310_SBNR (volatile u8 *)IOP310_REG_ADDR(0x00001019)
-#define IOP310_SUBBNR (volatile u8 *)IOP310_REG_ADDR(0x0000101A)
-#define IOP310_SLTR (volatile u8 *)IOP310_REG_ADDR(0x0000101B)
-#define IOP310_IOBR (volatile u8 *)IOP310_REG_ADDR(0x0000101C)
-#define IOP310_IOLR (volatile u8 *)IOP310_REG_ADDR(0x0000101D)
-#define IOP310_SSR (volatile u16 *)IOP310_REG_ADDR(0x0000101E)
-#define IOP310_MBR (volatile u16 *)IOP310_REG_ADDR(0x00001020)
-#define IOP310_MLR (volatile u16 *)IOP310_REG_ADDR(0x00001022)
-#define IOP310_PMBR (volatile u16 *)IOP310_REG_ADDR(0x00001024)
-#define IOP310_PMLR (volatile u16 *)IOP310_REG_ADDR(0x00001026)
-/* Reserved 0x00001028 through 0x00001033 */
-#define IOP310_CAPR (volatile u8 *)IOP310_REG_ADDR(0x00001034)
-/* Reserved 0x00001035 through 0x0000103D */
-#define IOP310_BCR (volatile u16 *)IOP310_REG_ADDR(0x0000103E)
-#define IOP310_EBCR (volatile u16 *)IOP310_REG_ADDR(0x00001040)
-#define IOP310_SISR (volatile u16 *)IOP310_REG_ADDR(0x00001042)
-#define IOP310_PBISR (volatile u32 *)IOP310_REG_ADDR(0x00001044)
-#define IOP310_SBISR (volatile u32 *)IOP310_REG_ADDR(0x00001048)
-#define IOP310_SACR (volatile u32 *)IOP310_REG_ADDR(0x0000104C)
-#define IOP310_PIRSR (volatile u32 *)IOP310_REG_ADDR(0x00001050)
-#define IOP310_SIOBR (volatile u8 *)IOP310_REG_ADDR(0x00001054)
-#define IOP310_SIOLR (volatile u8 *)IOP310_REG_ADDR(0x00001055)
-#define IOP310_SCDR (volatile u8 *)IOP310_REG_ADDR(0x00001056)
-
-#define IOP310_SMBR (volatile u16 *)IOP310_REG_ADDR(0x00001058)
-#define IOP310_SMLR (volatile u16 *)IOP310_REG_ADDR(0x0000105A)
-#define IOP310_SDER (volatile u16 *)IOP310_REG_ADDR(0x0000105C)
-#define IOP310_QCR (volatile u16 *)IOP310_REG_ADDR(0x0000105E)
-#define IOP310_CAPID (volatile u8 *)IOP310_REG_ADDR(0x00001068)
-#define IOP310_NIPTR (volatile u8 *)IOP310_REG_ADDR(0x00001069)
-#define IOP310_PMCR (volatile u16 *)IOP310_REG_ADDR(0x0000106A)
-#define IOP310_PMCSR (volatile u16 *)IOP310_REG_ADDR(0x0000106C)
-#define IOP310_PMCSRBSE (volatile u8 *)IOP310_REG_ADDR(0x0000106E)
-/* Reserved 0x00001064 through 0x000010FFH */
-
-/* Performance monitoring unit 0x00001100 through 0x000011FF*/
-#define IOP310_PMONGTMR (volatile u32 *)IOP310_REG_ADDR(0x00001100)
-#define IOP310_PMONESR (volatile u32 *)IOP310_REG_ADDR(0x00001104)
-#define IOP310_PMONEMISR (volatile u32 *)IOP310_REG_ADDR(0x00001108)
-#define IOP310_PMONGTSR (volatile u32 *)IOP310_REG_ADDR(0x00001110)
-#define IOP310_PMONPECR1 (volatile u32 *)IOP310_REG_ADDR(0x00001114)
-#define IOP310_PMONPECR2 (volatile u32 *)IOP310_REG_ADDR(0x00001118)
-#define IOP310_PMONPECR3 (volatile u32 *)IOP310_REG_ADDR(0x0000111C)
-#define IOP310_PMONPECR4 (volatile u32 *)IOP310_REG_ADDR(0x00001120)
-#define IOP310_PMONPECR5 (volatile u32 *)IOP310_REG_ADDR(0x00001124)
-#define IOP310_PMONPECR6 (volatile u32 *)IOP310_REG_ADDR(0x00001128)
-#define IOP310_PMONPECR7 (volatile u32 *)IOP310_REG_ADDR(0x0000112C)
-#define IOP310_PMONPECR8 (volatile u32 *)IOP310_REG_ADDR(0x00001130)
-#define IOP310_PMONPECR9 (volatile u32 *)IOP310_REG_ADDR(0x00001134)
-#define IOP310_PMONPECR10 (volatile u32 *)IOP310_REG_ADDR(0x00001138)
-#define IOP310_PMONPECR11 (volatile u32 *)IOP310_REG_ADDR(0x0000113C)
-#define IOP310_PMONPECR12 (volatile u32 *)IOP310_REG_ADDR(0x00001140)
-#define IOP310_PMONPECR13 (volatile u32 *)IOP310_REG_ADDR(0x00001144)
-#define IOP310_PMONPECR14 (volatile u32 *)IOP310_REG_ADDR(0x00001148)
-
-/* Address Translation Unit 0x00001200 through 0x000012FF */
-#define IOP310_ATUVID (volatile u16 *)IOP310_REG_ADDR(0x00001200)
-#define IOP310_ATUDID (volatile u16 *)IOP310_REG_ADDR(0x00001202)
-#define IOP310_PATUCMD (volatile u16 *)IOP310_REG_ADDR(0x00001204)
-#define IOP310_PATUSR (volatile u16 *)IOP310_REG_ADDR(0x00001206)
-#define IOP310_ATURID (volatile u8 *)IOP310_REG_ADDR(0x00001208)
-#define IOP310_ATUCCR (volatile u32 *)IOP310_REG_ADDR(0x00001209)
-#define IOP310_ATUCLSR (volatile u8 *)IOP310_REG_ADDR(0x0000120C)
-#define IOP310_ATULT (volatile u8 *)IOP310_REG_ADDR(0x0000120D)
-#define IOP310_ATUHTR (volatile u8 *)IOP310_REG_ADDR(0x0000120E)
-
-#define IOP310_PIABAR (volatile u32 *)IOP310_REG_ADDR(0x00001210)
-/* Reserved 0x00001214 through 0x0000122B */
-#define IOP310_ASVIR (volatile u16 *)IOP310_REG_ADDR(0x0000122C)
-#define IOP310_ASIR (volatile u16 *)IOP310_REG_ADDR(0x0000122E)
-#define IOP310_ERBAR (volatile u32 *)IOP310_REG_ADDR(0x00001230)
-#define IOP310_ATUCAPPTR (volatile u8 *)IOP310_REG_ADDR(0x00001234)
-/* Reserved 0x00001235 through 0x0000123B */
-#define IOP310_ATUILR (volatile u8 *)IOP310_REG_ADDR(0x0000123C)
-#define IOP310_ATUIPR (volatile u8 *)IOP310_REG_ADDR(0x0000123D)
-#define IOP310_ATUMGNT (volatile u8 *)IOP310_REG_ADDR(0x0000123E)
-#define IOP310_ATUMLAT (volatile u8 *)IOP310_REG_ADDR(0x0000123F)
-#define IOP310_PIALR (volatile u32 *)IOP310_REG_ADDR(0x00001240)
-#define IOP310_PIATVR (volatile u32 *)IOP310_REG_ADDR(0x00001244)
-#define IOP310_SIABAR (volatile u32 *)IOP310_REG_ADDR(0x00001248)
-#define IOP310_SIALR (volatile u32 *)IOP310_REG_ADDR(0x0000124C)
-#define IOP310_SIATVR (volatile u32 *)IOP310_REG_ADDR(0x00001250)
-#define IOP310_POMWVR (volatile u32 *)IOP310_REG_ADDR(0x00001254)
-/* Reserved 0x00001258 through 0x0000125B */
-#define IOP310_POIOWVR (volatile u32 *)IOP310_REG_ADDR(0x0000125C)
-#define IOP310_PODWVR (volatile u32 *)IOP310_REG_ADDR(0x00001260)
-#define IOP310_POUDR (volatile u32 *)IOP310_REG_ADDR(0x00001264)
-#define IOP310_SOMWVR (volatile u32 *)IOP310_REG_ADDR(0x00001268)
-#define IOP310_SOIOWVR (volatile u32 *)IOP310_REG_ADDR(0x0000126C)
-/* Reserved 0x00001270 through 0x00001273*/
-#define IOP310_ERLR (volatile u32 *)IOP310_REG_ADDR(0x00001274)
-#define IOP310_ERTVR (volatile u32 *)IOP310_REG_ADDR(0x00001278)
-/* Reserved 0x00001279 through 0x0000127C*/
-#define IOP310_ATUCAPID (volatile u8 *)IOP310_REG_ADDR(0x00001280)
-#define IOP310_ATUNIPTR (volatile u8 *)IOP310_REG_ADDR(0x00001281)
-#define IOP310_APMCR (volatile u16 *)IOP310_REG_ADDR(0x00001282)
-#define IOP310_APMCSR (volatile u16 *)IOP310_REG_ADDR(0x00001284)
-/* Reserved 0x00001286 through 0x00001287 */
-#define IOP310_ATUCR (volatile u32 *)IOP310_REG_ADDR(0x00001288)
-/* Reserved 0x00001289 through 0x0000128C*/
-#define IOP310_PATUISR (volatile u32 *)IOP310_REG_ADDR(0x00001290)
-#define IOP310_SATUISR (volatile u32 *)IOP310_REG_ADDR(0x00001294)
-#define IOP310_SATUCMD (volatile u16 *)IOP310_REG_ADDR(0x00001298)
-#define IOP310_SATUSR (volatile u16 *)IOP310_REG_ADDR(0x0000129A)
-#define IOP310_SODWVR (volatile u32 *)IOP310_REG_ADDR(0x0000129C)
-#define IOP310_SOUDR (volatile u32 *)IOP310_REG_ADDR(0x000012A0)
-#define IOP310_POCCAR (volatile u32 *)IOP310_REG_ADDR(0x000012A4)
-#define IOP310_SOCCAR (volatile u32 *)IOP310_REG_ADDR(0x000012A8)
-#define IOP310_POCCDR (volatile u32 *)IOP310_REG_ADDR(0x000012AC)
-#define IOP310_SOCCDR (volatile u32 *)IOP310_REG_ADDR(0x000012B0)
-#define IOP310_PAQCR (volatile u32 *)IOP310_REG_ADDR(0x000012B4)
-#define IOP310_SAQCR (volatile u32 *)IOP310_REG_ADDR(0x000012B8)
-#define IOP310_PATUIMR (volatile u32 *)IOP310_REG_ADDR(0x000012BC)
-#define IOP310_SATUIMR (volatile u32 *)IOP310_REG_ADDR(0x000012C0)
-/* Reserved 0x000012C4 through 0x000012FF */
-/* Messaging Unit 0x00001300 through 0x000013FF */
-#define IOP310_MUIMR0 (volatile u32 *)IOP310_REG_ADDR(0x00001310)
-#define IOP310_MUIMR1 (volatile u32 *)IOP310_REG_ADDR(0x00001314)
-#define IOP310_MUOMR0 (volatile u32 *)IOP310_REG_ADDR(0x00001318)
-#define IOP310_MUOMR1 (volatile u32 *)IOP310_REG_ADDR(0x0000131C)
-#define IOP310_MUIDR (volatile u32 *)IOP310_REG_ADDR(0x00001320)
-#define IOP310_MUIISR (volatile u32 *)IOP310_REG_ADDR(0x00001324)
-#define IOP310_MUIIMR (volatile u32 *)IOP310_REG_ADDR(0x00001328)
-#define IOP310_MUODR (volatile u32 *)IOP310_REG_ADDR(0x0000132C)
-#define IOP310_MUOISR (volatile u32 *)IOP310_REG_ADDR(0x00001330)
-#define IOP310_MUOIMR (volatile u32 *)IOP310_REG_ADDR(0x00001334)
-#define IOP310_MUMUCR (volatile u32 *)IOP310_REG_ADDR(0x00001350)
-#define IOP310_MUQBAR (volatile u32 *)IOP310_REG_ADDR(0x00001354)
-#define IOP310_MUIFHPR (volatile u32 *)IOP310_REG_ADDR(0x00001360)
-#define IOP310_MUIFTPR (volatile u32 *)IOP310_REG_ADDR(0x00001364)
-#define IOP310_MUIPHPR (volatile u32 *)IOP310_REG_ADDR(0x00001368)
-#define IOP310_MUIPTPR (volatile u32 *)IOP310_REG_ADDR(0x0000136C)
-#define IOP310_MUOFHPR (volatile u32 *)IOP310_REG_ADDR(0x00001370)
-#define IOP310_MUOFTPR (volatile u32 *)IOP310_REG_ADDR(0x00001374)
-#define IOP310_MUOPHPR (volatile u32 *)IOP310_REG_ADDR(0x00001378)
-#define IOP310_MUOPTPR (volatile u32 *)IOP310_REG_ADDR(0x0000137C)
-#define IOP310_MUIAR (volatile u32 *)IOP310_REG_ADDR(0x00001380)
-/* DMA Controller 0x00001400 through 0x000014FF */
-#define IOP310_DMA0CCR (volatile u32 *)IOP310_REG_ADDR(0x00001400)
-#define IOP310_DMA0CSR (volatile u32 *)IOP310_REG_ADDR(0x00001404)
-/* Reserved 0x001408 through 0x00140B */
-#define IOP310_DMA0DAR (volatile u32 *)IOP310_REG_ADDR(0x0000140C)
-#define IOP310_DMA0NDAR (volatile u32 *)IOP310_REG_ADDR(0x00001410)
-#define IOP310_DMA0PADR (volatile u32 *)IOP310_REG_ADDR(0x00001414)
-#define IOP310_DMA0PUADR (volatile u32 *)IOP310_REG_ADDR(0x00001418)
-#define IOP310_DMA0LADR (volatile u32 *)IOP310_REG_ADDR(0x0000141C)
-#define IOP310_DMA0BCR (volatile u32 *)IOP310_REG_ADDR(0x00001420)
-#define IOP310_DMA0DCR (volatile u32 *)IOP310_REG_ADDR(0x00001424)
-/* Reserved 0x00001428 through 0x0000143F */
-#define IOP310_DMA1CCR (volatile u32 *)IOP310_REG_ADDR(0x00001440)
-#define IOP310_DMA1CSR (volatile u32 *)IOP310_REG_ADDR(0x00001444)
-/* Reserved 0x00001448 through 0x0000144B */
-#define IOP310_DMA1DAR (volatile u32 *)IOP310_REG_ADDR(0x0000144C)
-#define IOP310_DMA1NDAR (volatile u32 *)IOP310_REG_ADDR(0x00001450)
-#define IOP310_DMA1PADR (volatile u32 *)IOP310_REG_ADDR(0x00001454)
-#define IOP310_DMA1PUADR (volatile u32 *)IOP310_REG_ADDR(0x00001458)
-#define IOP310_DMA1LADR (volatile u32 *)IOP310_REG_ADDR(0x0000145C)
-#define IOP310_DMA1BCR (volatile u32 *)IOP310_REG_ADDR(0x00001460)
-#define IOP310_DMA1DCR (volatile u32 *)IOP310_REG_ADDR(0x00001464)
-/* Reserved 0x00001468 through 0x0000147F */
-#define IOP310_DMA2CCR (volatile u32 *)IOP310_REG_ADDR(0x00001480)
-#define IOP310_DMA2CSR (volatile u32 *)IOP310_REG_ADDR(0x00001484)
-/* Reserved 0x00001488 through 0x0000148B */
-#define IOP310_DMA2DAR (volatile u32 *)IOP310_REG_ADDR(0x0000148C)
-#define IOP310_DMA2NDAR (volatile u32 *)IOP310_REG_ADDR(0x00001490)
-#define IOP310_DMA2PADR (volatile u32 *)IOP310_REG_ADDR(0x00001494)
-#define IOP310_DMA2PUADR (volatile u32 *)IOP310_REG_ADDR(0x00001498)
-#define IOP310_DMA2LADR (volatile u32 *)IOP310_REG_ADDR(0x0000149C)
-#define IOP310_DMA2BCR (volatile u32 *)IOP310_REG_ADDR(0x000014A0)
-#define IOP310_DMA2DCR (volatile u32 *)IOP310_REG_ADDR(0x000014A4)
-
-/* Memory controller 0x00001500 through 0x0015FF */
-
-/* core interface unit 0x00001640 - 0x0000167F */
-#define IOP310_CIUISR (volatile u32 *)IOP310_REG_ADDR(0x00001644)
-
-/* PCI and Peripheral Interrupt Controller 0x00001700 - 0x0000171B */
-#define IOP310_IRQISR (volatile u32 *)IOP310_REG_ADDR(0x00001700)
-#define IOP310_FIQ2ISR (volatile u32 *)IOP310_REG_ADDR(0x00001704)
-#define IOP310_FIQ1ISR (volatile u32 *)IOP310_REG_ADDR(0x00001708)
-#define IOP310_PDIDR (volatile u32 *)IOP310_REG_ADDR(0x00001710)
-
-/* AAU registers. DJ 0x00001800 - 0x00001838 */
-#define IOP310_AAUACR (volatile u32 *)IOP310_REG_ADDR(0x00001800)
-#define IOP310_AAUASR (volatile u32 *)IOP310_REG_ADDR(0x00001804)
-#define IOP310_AAUADAR (volatile u32 *)IOP310_REG_ADDR(0x00001808)
-#define IOP310_AAUANDAR (volatile u32 *)IOP310_REG_ADDR(0x0000180C)
-#define IOP310_AAUSAR1 (volatile u32 *)IOP310_REG_ADDR(0x00001810)
-#define IOP310_AAUSAR2 (volatile u32 *)IOP310_REG_ADDR(0x00001814)
-#define IOP310_AAUSAR3 (volatile u32 *)IOP310_REG_ADDR(0x00001818)
-#define IOP310_AAUSAR4 (volatile u32 *)IOP310_REG_ADDR(0x0000181C)
-#define IOP310_AAUDAR (volatile u32 *)IOP310_REG_ADDR(0x00001820)
-#define IOP310_AAUABCR (volatile u32 *)IOP310_REG_ADDR(0x00001824)
-#define IOP310_AAUADCR (volatile u32 *)IOP310_REG_ADDR(0x00001828)
-#define IOP310_AAUSAR5 (volatile u32 *)IOP310_REG_ADDR(0x0000182C)
-#define IOP310_AAUSAR6 (volatile u32 *)IOP310_REG_ADDR(0x00001830)
-#define IOP310_AAUSAR7 (volatile u32 *)IOP310_REG_ADDR(0x00001834)
-#define IOP310_AAUSAR8 (volatile u32 *)IOP310_REG_ADDR(0x00001838)
-
-#endif // _IOP310_HW_H_
+++ /dev/null
-/*
- * linux/include/asm/arch-iop80310/iq80310.h
- *
- * Intel IQ-80310 evaluation board registers
- */
-
-#ifndef _IQ80310_H_
-#define _IQ80310_H_
-
-#define IQ80310_RAMBASE 0xa0000000
-#define IQ80310_UART1 0xfe800000 /* UART #1 */
-#define IQ80310_UART2 0xfe810000 /* UART #2 */
-#define IQ80310_INT_STAT 0xfe820000 /* Interrupt (XINT3#) Status */
-#define IQ80310_BOARD_REV 0xfe830000 /* Board revision register */
-#define IQ80310_CPLD_REV 0xfe840000 /* CPLD revision register */
-#define IQ80310_7SEG_1 0xfe840000 /* 7-Segment MSB */
-#define IQ80310_7SEG_0 0xfe850000 /* 7-Segment LSB (WO) */
-#define IQ80310_PCI_INT_STAT 0xfe850000 /* PCI Interrupt Status */
-#define IQ80310_INT_MASK 0xfe860000 /* Interrupt (XINT3#) Mask */
-#define IQ80310_BACKPLANE 0xfe870000 /* Backplane Detect */
-#define IQ80310_TIMER_LA0 0xfe880000 /* Timer LA0 */
-#define IQ80310_TIMER_LA1 0xfe890000 /* Timer LA1 */
-#define IQ80310_TIMER_LA2 0xfe8a0000 /* Timer LA2 */
-#define IQ80310_TIMER_LA3 0xfe8b0000 /* Timer LA3 */
-#define IQ80310_TIMER_EN 0xfe8c0000 /* Timer Enable */
-#define IQ80310_ROTARY_SW 0xfe8d0000 /* Rotary Switch */
-#define IQ80310_JTAG 0xfe8e0000 /* JTAG Port Access */
-#define IQ80310_BATT_STAT 0xfe8f0000 /* Battery Status */
-
-#endif // _IQ80310_H_
+++ /dev/null
-/*
- * Definitions for XScale 80312 PMON
- * (C) 2001 Intel Corporation
- * Author: Chen Chen(chen.chen@intel.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _IOP310_PMON_H_
-#define _IOP310_PMON_H_
-
-/*
- * Different modes for Event Select Register for intel 80312
- */
-
-#define IOP310_PMON_MODE0 0x00000000
-#define IOP310_PMON_MODE1 0x00000001
-#define IOP310_PMON_MODE2 0x00000002
-#define IOP310_PMON_MODE3 0x00000003
-#define IOP310_PMON_MODE4 0x00000004
-#define IOP310_PMON_MODE5 0x00000005
-#define IOP310_PMON_MODE6 0x00000006
-#define IOP310_PMON_MODE7 0x00000007
-
-typedef struct _iop310_pmon_result
-{
- u32 timestamp; /* Global Time Stamp Register */
- u32 timestamp_overflow; /* Time Stamp overflow count */
- u32 event_count[14]; /* Programmable Event Counter
- Registers 1-14 */
- u32 event_overflow[14]; /* Overflow counter for PECR1-14 */
-} iop310_pmon_res_t;
-
-/* function prototypes */
-
-/* Claim IQ80312 PMON for usage */
-int iop310_pmon_claim(void);
-
-/* Start IQ80312 PMON */
-int iop310_pmon_start(int, int);
-
-/* Stop Performance Monitor Unit */
-int iop310_pmon_stop(iop310_pmon_res_t *);
-
-/* Release IQ80312 PMON */
-int iop310_pmon_release(int);
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-iop80310/time.h
- *
- * Author: Nicolas Pitre
- * Copyright: (C) 2001 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-ixp4xx/time.h
- *
- * We implement timer code in arch/arm/mach-ixp4xx/time.c
- *
- */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-l7200/ide.h
- *
- * Copyright (c) 2000 Steve Hill (sjhill@cotw.com)
- *
- * Changelog:
- * 03-29-2000 SJH Created file placeholder
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-l7200/keyboard.h
- *
- * Keyboard driver definitions for LinkUp Systems L7200 architecture
- *
- * Copyright (C) 2000 Scott A McConnell (samcconn@cotw.com)
- * Steve Hill (sjhill@cotw.com)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of this archive for
- * more details.
- *
- * Changelog:
- * 07-18-2000 SAM Created file
- * 07-28-2000 SJH Complete rewrite
- */
-
-#include <asm/irq.h>
-
-#error This needs fixing --rmk
-
-/*
- * Layout of L7200 keyboard registers
- */
-struct KBD_Port {
- unsigned int KBDR;
- unsigned int KBDMR;
- unsigned int KBSBSR;
- unsigned int Reserved;
- unsigned int KBKSR;
-};
-
-#define KBD_BASE IO_BASE_2 + 0x4000
-#define l7200kbd_hwregs ((volatile struct KBD_Port *) (KBD_BASE))
-
-extern void l7200kbd_init_hw(void);
-extern int l7200kbd_translate(unsigned char scancode, unsigned char *keycode,
- char raw_mode);
-
-#define kbd_setkeycode(sc,kc) (-EINVAL)
-#define kbd_getkeycode(sc) (-EINVAL)
-
-#define kbd_translate(sc, kcp, rm) ({ *(kcp) = (sc); 1; })
-#define kbd_unexpected_up(kc) (0200)
-#define kbd_leds(leds) do {} while (0)
-#define kbd_init_hw() l7200kbd_init_hw()
-#define kbd_sysrq_xlate ((unsigned char *)NULL)
-#define kbd_disable_irq() disable_irq(IRQ_GCTC2)
-#define kbd_enable_irq() enable_irq(IRQ_GCTC2)
-
-#define SYSRQ_KEY 13
+++ /dev/null
-/* include/asm-arm/arch-lh7a40x/ide.h
- *
- * Copyright (C) 2004 Logic Product Development
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- */
-
-#ifndef __ASM_ARCH_IDE_H
-#define __ASM_ARCH_IDE_H
-
-#if defined (CONFIG_MACH_LPD7A400) || defined (CONFIG_MACH_LPD7A404)
-
-/* This implementation of ide.h only applies to the LPD CardEngines.
- * Thankfully, there is less to do for the KEV.
- */
-
-#include <linux/config.h>
-#include <asm/irq.h>
-#include <asm/hardware.h>
-#include <asm/arch/registers.h>
-
-#define IDE_REG_LINE (1<<12) /* A12 drives !REG */
-#define IDE_ALT_LINE (1<<11) /* Unused A11 allows non-overlapping regions */
-#define IDE_CONTROLREG_OFFSET (0xe)
-
-void lpd7a40x_hwif_ioops (struct hwif_s* hwif);
-
-static __inline__ void ide_init_hwif_ports (hw_regs_t *hw, int data_port,
- int ctrl_port, int *irq)
-{
- ide_ioreg_t reg;
- int i;
- int regincr = 1;
-
- memset (hw, 0, sizeof (*hw));
-
- reg = (ide_ioreg_t) data_port;
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += regincr;
- }
-
- hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t) ctrl_port;
-
- if (irq)
- *irq = IDE_NO_IRQ;
-}
-
-static __inline__ void ide_init_default_hwifs (void)
-{
- hw_regs_t hw;
- struct hwif_s* hwif;
-
- ide_init_hwif_ports (&hw,
- CF_VIRT + IDE_REG_LINE,
- CF_VIRT + IDE_REG_LINE + IDE_ALT_LINE
- + IDE_CONTROLREG_OFFSET,
- NULL);
-
- ide_register_hw (&hw, &hwif);
- lpd7a40x_hwif_ioops (hwif); /* Override IO routines */
-}
-#endif
-
-#endif
+++ /dev/null
-/* include/asm-arm/arch-lh7a40x/time.h
- *
- * Copyright (C) 2004 Logic Product Development
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- */
-
-#if HZ < 100
-# define TIMER_CONTROL TIMER_CONTROL1
-# define TIMER_LOAD TIMER_LOAD1
-# define TIMER_CONSTANT (508469/HZ)
-# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC | TIMER_C_508KHZ)
-# define TIMER_EOI TIMER_EOI1
-# define TIMER_IRQ IRQ_T1UI
-#else
-# define TIMER_CONTROL TIMER_CONTROL3
-# define TIMER_LOAD TIMER_LOAD3
-# define TIMER_CONSTANT (3686400/HZ)
-# define TIMER_MODE (TIMER_C_ENABLE | TIMER_C_PERIODIC)
-# define TIMER_EOI TIMER_EOI3
-# define TIMER_IRQ IRQ_T3UI
-#endif
-
-static irqreturn_t
-lh7a40x_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- TIMER_EOI = 0;
- do_profile (regs);
- do_leds();
- do_set_rtc();
- do_timer (regs);
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- /* Stop/disable all timers */
- TIMER_CONTROL1 = 0;
- TIMER_CONTROL2 = 0;
- TIMER_CONTROL3 = 0;
-
- timer_irq.handler = lh7a40x_timer_interrupt;
- timer_irq.flags |= SA_INTERRUPT;
- setup_irq (TIMER_IRQ, &timer_irq);
-
- TIMER_LOAD = TIMER_CONSTANT;
- TIMER_CONTROL = TIMER_MODE;
-}
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/dma.h
- *
- * Architecture DMA routines
- *
- * Copyright (C) 1998, 1999 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * This is the maximum DMA address that can be DMAd to.
- */
-#define MAX_DMA_ADDRESS 0xffffffff
-#define MAX_DMA_CHANNELS 0
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/hardware.h
- *
- * Copyright (C) 1998, 1999, 2000 FutureTV Labs Ltd.
- *
- * This file contains the hardware definitions of the FTV PCI card.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-/* Logical Physical
- * 0xffe00000 0x20000000 INTCONT
- * 0xffd00000 0x30000000 Status
- * 0xffc00000 0x60000000 PLX registers
- * 0xfe000000 0xC0000000 PCI I/O
- * 0xfd000000 0x70000000 cache flush
- * 0xfc000000 0x80000000 PCI/ISA memory
- * 0xe0000000 0x10000000 SCC2691 DUART
- */
-
-/*
- * Mapping areas
- */
-#define INTCONT_BASE 0xffe00000
-#define STATUS_BASE 0xffd00000
-#define PLX_BASE 0xffc00000
-#define PCIO_BASE 0xfe000000
-#define FLUSH_BASE 0xfd000000
-#define DUART_BASE 0xe0000000
-#define PCIMEM_BASE 0xfc000000
-
-#define PLX_IO_START 0xC0000000
-#define PLX_MEM_START 0x80000000
-#define PLX_START 0x60000000
-#define STATUS_START 0x30000000
-#define INTCONT_START 0x20000000
-#define DUART_START 0x10000000
-
-/*
- * RAM definitions
- */
-#define RAM_BASE 0x40000000
-#define FLUSH_BASE_PHYS 0x70000000
-
-/*
- * Miscellaneous INTCONT bits
- */
-#define INTCONT_FIQ_PLX 0x00
-#define INTCONT_FIQ_D 0x02
-#define INTCONT_FIQ_C 0x04
-#define INTCONT_FIQ_B 0x06
-#define INTCONT_FIQ_A 0x08
-#define INTCONT_FIQ_SYSERR 0x0a
-#define INTCONT_IRQ_DUART 0x0c
-#define INTCONT_IRQ_PLX 0x0e
-#define INTCONT_IRQ_D 0x10
-#define INTCONT_IRQ_C 0x12
-#define INTCONT_IRQ_B 0x14
-#define INTCONT_IRQ_A 0x16
-#define INTCONT_IRQ_SYSERR 0x1e
-
-#define INTCONT_WATCHDOG 0x18
-#define INTCONT_LED 0x1a
-#define INTCONT_PCI_RESET 0x1c
-
-#define UNCACHEABLE_ADDR STATUS_BASE
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/ide.h
- *
- * Copyright (c) 1998 Russell King
- *
- * Modifications:
- * 29-07-1998 RMK Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- if (irq)
- *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void ide_init_default_hwifs(void)
-{
- /* There are no standard ports */
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/io.h
- *
- * Copyright (C) 1997-1999 Russell King
- * Copyright (C) 2000 FutureTV Labs Ltd.
- */
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffff
-
-/*
- * Translation of various region addresses to virtual addresses
- */
-#define __io(a) (PCIO_BASE + (a))
-#if 1
-#define __mem_pci(a) ((unsigned long)(a))
-#define __mem_isa(a) (PCIMEM_BASE + (unsigned long)(a))
-#else
-
-static inline unsigned long ___mem_pci(unsigned long a)
-{
- /* PCI addresses must have been ioremapped */
- if (a <= 0xc0000000 || a >= 0xe0000000)
- *((int *)0) = 0;
- return a;
-}
-
-static inline unsigned long ___mem_isa(unsigned long a)
-{
- BUG_ON(a >= 16*1048576);
- return PCIMEM_BASE + a;
-}
-#define __mem_pci(a) ___mem_pci((unsigned long)(a))
-#define __mem_isa(a) ___mem_isa((unsigned long)(a))
-#endif
-
-/*
- * ioremap support - validate a PCI memory address,
- * and convert a PCI memory address to a physical
- * address for the page tables.
- */
-#define iomem_valid_addr(iomem,sz) \
- ((iomem) < 0x80000000 && (iomem) + (sz) <= 0x80000000)
-#define iomem_to_phys(iomem) ((iomem) + PLX_MEM_START)
-
-#define __arch_ioremap(off,sz,nocache) \
- ({ \
- unsigned long _off = (off), _size = (sz); \
- void *_ret = (void *)0; \
- if (iomem_valid_addr(_off, _size)) \
- _ret = __ioremap(iomem_to_phys(_off),_size,0); \
- _ret; \
- })
-
-#define __arch_iounmap __iounmap
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/irqs.h
- *
- * Copyright (C) 1997, 1998, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * The hardware is capable of routing any interrupt source (except the
- * DUART) to either IRQ or FIQ. We ignore FIQ and use IRQ exclusively
- * for simplicity.
- */
-
-#define IRQ_DUART 0
-#define IRQ_PLX 1
-#define IRQ_PCI_D 2
-#define IRQ_PCI_C 3
-#define IRQ_PCI_B 4
-#define IRQ_PCI_A 5
-#define IRQ_SYSERR 6 /* only from IOSLAVE rev B */
-
-#define FIRST_IRQ IRQ_DUART
-#define LAST_IRQ IRQ_SYSERR
-
-/* timer is part of the DUART */
-#define IRQ_TIMER IRQ_DUART
-
-#define irq_canonicalize(i) (i)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/memory.h
- *
- * Copyright (c) 1997, 1998, 2000 FutureTV Labs Ltd.
- * Copyright (c) 1999 Russell King
- *
- */
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET (0x40000000UL)
-#define BUS_OFFSET (0xe0000000UL)
-
-/*
- * On the PCI bus the DRAM appears at address 0xe0000000
- */
-#define __virt_to_bus(x) ((unsigned long)(x) - PAGE_OFFSET + BUS_OFFSET)
-#define __bus_to_virt(x) ((unsigned long)(x) + PAGE_OFFSET - BUS_OFFSET)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/param.h
- */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/system.h
- *
- * Copyright (c) 1996, 97, 98, 99, 2000 FutureTV Labs Ltd.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_SYSTEM_H
-#define __ASM_ARCH_SYSTEM_H
-
-static inline void arch_idle(void)
-{
- cpu_do_idle();
-}
-
-#define arch_reset(mode) do { } while (0)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/time.h
- *
- * Copyright (c) 1997, 1998, 1999, 2000 FutureTV Labs Ltd.
- *
- * The FTV PCI card has no real-time clock. We get timer ticks from the
- * SCC chip.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- static int count = 25;
- unsigned char stat = __raw_readb(DUART_BASE + 0x14);
- if (!(stat & 0x10))
- return; /* Not for us */
-
- /* Reset counter */
- __raw_writeb(0x90, DUART_BASE + 8);
-
- if (--count == 0) {
- static int state = 1;
- state ^= 1;
- __raw_writeb(0x1a + state, INTCONT_BASE);
- __raw_writeb(0x18 + state, INTCONT_BASE);
- count = 50;
- }
-
- /* Wait for slow rise time */
- __raw_readb(DUART_BASE + 0x14);
- __raw_readb(DUART_BASE + 0x14);
- __raw_readb(DUART_BASE + 0x14);
- __raw_readb(DUART_BASE + 0x14);
- __raw_readb(DUART_BASE + 0x14);
- __raw_readb(DUART_BASE + 0x14);
-
- do_timer(regs);
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- int tick = 3686400 / 16 / 2 / 100;
-
- __raw_writeb(tick & 0xff, DUART_BASE + 0x1c);
- __raw_writeb(tick >> 8, DUART_BASE + 0x18);
- __raw_writeb(0x80, DUART_BASE + 8);
- __raw_writeb(0x10, DUART_BASE + 0x14);
-
- timer_irq.handler = timer_interrupt;
- timer_irq.flags = SA_SHIRQ;
-
- setup_irq(IRQ_TIMER, &timer_irq);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/timex.h
- *
- * NexusPCI StrongARM card timex specifications
- *
- * Copyright (C) 1998 Philip Blundell
- */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/uncompress.h
- *
- * Copyright (C) 1998, 1999, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <asm/hardware.h>
-#include <asm/io.h>
-
-/*
- * Write a character to the UART
- */
-void _ll_write_char(char c)
-{
- while (!(__raw_readb(DUART_START + 0x4) & 0x4))
- ;
- __raw_writeb(c, DUART_START + 0xc);
-}
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
- while (*s) {
- if (*s == '\n')
- _ll_write_char('\r');
- _ll_write_char(*(s++));
- }
-}
-
-/*
- * Set up for decompression
- */
-static void arch_decomp_setup(void)
-{
- /* LED off */
- __raw_writel(INTCONT_LED, INTCONT_START);
-
- /* Set up SCC */
- __raw_writeb(42, DUART_START + 8);
- __raw_writeb(48, DUART_START + 8);
- __raw_writeb(16, DUART_START + 8);
- __raw_writeb(0x93, DUART_START);
- __raw_writeb(0x17, DUART_START);
- __raw_writeb(0xbb, DUART_START + 4);
- __raw_writeb(0x78, DUART_START + 16);
- __raw_writeb(0xa0, DUART_START + 8);
- __raw_writeb(5, DUART_START + 8);
-}
-
-/*
- * Stroke the watchdog so we don't get reset during decompression.
- */
-static inline void arch_decomp_wdog(void)
-{
- __raw_writel(INTCONT_WATCHDOG, INTCONT_START);
- __raw_writel(INTCONT_WATCHDOG | 1, INTCONT_START);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts. That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET (8*1024*1024)
-#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END (PAGE_OFFSET + 0x20000000)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-omap/bus.h
- *
- * Virtual bus for OMAP. Allows better power management, such as managing
- * shared clocks, and mapping of bus addresses to Local Bus addresses.
- *
- * See drivers/usb/host/ohci-omap.c or drivers/video/omap/omapfb.c for
- * examples on how to register drivers to this bus.
- *
- * Copyright (C) 2003 - 2004 Nokia Corporation
- * Written by Tony Lindgren <tony@atomide.com>
- * Portions of code based on sa1111.c.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __ASM_ARM_ARCH_OMAP_BUS_H
-#define __ASM_ARM_ARCH_OMAP_BUS_H
-
-extern struct bus_type omap_bus_types[];
-
-/*
- * Description for physical device
- */
-struct omap_dev {
- struct device dev; /* Standard device description */
- char *name;
- unsigned int devid; /* OMAP device id */
- unsigned int busid; /* OMAP virtual busid */
- struct resource res; /* Standard resource description */
- void *mapbase; /* OMAP physical address */
- unsigned int irq[6]; /* OMAP interrupts */
- u64 *dma_mask; /* Used by USB OHCI only */
- u64 coherent_dma_mask; /* Used by USB OHCI only */
-};
-
-#define OMAP_DEV(_d) container_of((_d), struct omap_dev, dev)
-
-#define omap_get_drvdata(d) dev_get_drvdata(&(d)->dev)
-#define omap_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p)
-
-/*
- * Description for device driver
- */
-struct omap_driver {
- struct device_driver drv; /* Standard driver description */
- unsigned int devid; /* OMAP device id for bus */
- unsigned int busid; /* OMAP virtual busid */
- unsigned int clocks; /* OMAP shared clocks */
- int (*probe)(struct omap_dev *);
- int (*remove)(struct omap_dev *);
- int (*suspend)(struct omap_dev *, u32);
- int (*resume)(struct omap_dev *);
-};
-
-#define OMAP_DRV(_d) container_of((_d), struct omap_driver, drv)
-#define OMAP_DRIVER_NAME(_omapdev) ((_omapdev)->dev.driver->name)
-
-/*
- * Device ID numbers for bus types
- */
-#define OMAP_OCP_DEVID_USB 0
-
-#define OMAP_TIPB_DEVID_OHCI 0
-#define OMAP_TIPB_DEVID_LCD 1
-#define OMAP_TIPB_DEVID_MMC 2
-#define OMAP_TIPB_DEVID_OTG 3
-#define OMAP_TIPB_DEVID_UDC 4
-
-/*
- * Virtual bus definitions for OMAP
- */
-#define OMAP_NR_BUSES 2
-
-#define OMAP_BUS_NAME_TIPB "tipb"
-#define OMAP_BUS_NAME_LBUS "lbus"
-
-enum {
- OMAP_BUS_TIPB = 0,
- OMAP_BUS_LBUS,
-};
-
-/* See arch/arm/mach-omap/bus.c for the rest of the bus definitions. */
-
-extern int omap_driver_register(struct omap_driver *driver);
-extern void omap_driver_unregister(struct omap_driver *driver);
-extern int omap_device_register(struct omap_dev *odev);
-extern void omap_device_unregister(struct omap_dev *odev);
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-omap/omap-h2.h
- *
- * Hardware definitions for TI OMAP1610 H2 board.
- *
- * Cleanup for Linux-2.6 by Dirk Behme <dirk.behme@de.bosch.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef __ASM_ARCH_OMAP_H2_H
-#define __ASM_ARCH_OMAP_H2_H
-
-/* Placeholder for H2 specific defines */
-
-#endif /* __ASM_ARCH_OMAP_H2_H */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-omap/omap-innovator.h
- *
- * Copyright (C) 2001 RidgeRun, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __ASM_ARCH_OMAP_INNOVATOR_H
-#define __ASM_ARCH_OMAP_INNOVATOR_H
-
-#if defined (CONFIG_ARCH_OMAP1510)
-
-/*
- * ---------------------------------------------------------------------------
- * OMAP-1510 FPGA
- * ---------------------------------------------------------------------------
- */
-#define OMAP1510P1_FPGA_BASE 0xE8000000 /* Virtual */
-#define OMAP1510P1_FPGA_SIZE SZ_4K
-#define OMAP1510P1_FPGA_START 0x08000000 /* Physical */
-
-/* Revision */
-#define OMAP1510P1_FPGA_REV_LOW (OMAP1510P1_FPGA_BASE + 0x0)
-#define OMAP1510P1_FPGA_REV_HIGH (OMAP1510P1_FPGA_BASE + 0x1)
-
-#define OMAP1510P1_FPGA_LCD_PANEL_CONTROL (OMAP1510P1_FPGA_BASE + 0x2)
-#define OMAP1510P1_FPGA_LED_DIGIT (OMAP1510P1_FPGA_BASE + 0x3)
-#define INNOVATOR_FPGA_HID_SPI (OMAP1510P1_FPGA_BASE + 0x4)
-#define OMAP1510P1_FPGA_POWER (OMAP1510P1_FPGA_BASE + 0x5)
-
-/* Interrupt status */
-#define OMAP1510P1_FPGA_ISR_LO (OMAP1510P1_FPGA_BASE + 0x6)
-#define OMAP1510P1_FPGA_ISR_HI (OMAP1510P1_FPGA_BASE + 0x7)
-
-/* Interrupt mask */
-#define OMAP1510P1_FPGA_IMR_LO (OMAP1510P1_FPGA_BASE + 0x8)
-#define OMAP1510P1_FPGA_IMR_HI (OMAP1510P1_FPGA_BASE + 0x9)
-
-/* Reset registers */
-#define OMAP1510P1_FPGA_HOST_RESET (OMAP1510P1_FPGA_BASE + 0xa)
-#define OMAP1510P1_FPGA_RST (OMAP1510P1_FPGA_BASE + 0xb)
-
-#define OMAP1510P1_FPGA_AUDIO (OMAP1510P1_FPGA_BASE + 0xc)
-#define OMAP1510P1_FPGA_DIP (OMAP1510P1_FPGA_BASE + 0xe)
-#define OMAP1510P1_FPGA_FPGA_IO (OMAP1510P1_FPGA_BASE + 0xf)
-#define OMAP1510P1_FPGA_UART1 (OMAP1510P1_FPGA_BASE + 0x14)
-#define OMAP1510P1_FPGA_UART2 (OMAP1510P1_FPGA_BASE + 0x15)
-#define OMAP1510P1_FPGA_OMAP1510_STATUS (OMAP1510P1_FPGA_BASE + 0x16)
-#define OMAP1510P1_FPGA_BOARD_REV (OMAP1510P1_FPGA_BASE + 0x18)
-#define OMAP1510P1_PPT_DATA (OMAP1510P1_FPGA_BASE + 0x100)
-#define OMAP1510P1_PPT_STATUS (OMAP1510P1_FPGA_BASE + 0x101)
-#define OMAP1510P1_PPT_CONTROL (OMAP1510P1_FPGA_BASE + 0x102)
-
-#define OMAP1510P1_FPGA_TOUCHSCREEN (OMAP1510P1_FPGA_BASE + 0x204)
-
-#define INNOVATOR_FPGA_INFO (OMAP1510P1_FPGA_BASE + 0x205)
-#define INNOVATOR_FPGA_LCD_BRIGHT_LO (OMAP1510P1_FPGA_BASE + 0x206)
-#define INNOVATOR_FPGA_LCD_BRIGHT_HI (OMAP1510P1_FPGA_BASE + 0x207)
-#define INNOVATOR_FPGA_LED_GRN_LO (OMAP1510P1_FPGA_BASE + 0x208)
-#define INNOVATOR_FPGA_LED_GRN_HI (OMAP1510P1_FPGA_BASE + 0x209)
-#define INNOVATOR_FPGA_LED_RED_LO (OMAP1510P1_FPGA_BASE + 0x20a)
-#define INNOVATOR_FPGA_LED_RED_HI (OMAP1510P1_FPGA_BASE + 0x20b)
-#define INNOVATOR_FPGA_CAM_USB_CONTROL (OMAP1510P1_FPGA_BASE + 0x20c)
-#define INNOVATOR_FPGA_EXP_CONTROL (OMAP1510P1_FPGA_BASE + 0x20d)
-#define INNOVATOR_FPGA_ISR2 (OMAP1510P1_FPGA_BASE + 0x20e)
-#define INNOVATOR_FPGA_IMR2 (OMAP1510P1_FPGA_BASE + 0x210)
-
-#define OMAP1510P1_FPGA_ETHR_START (OMAP1510P1_FPGA_START + 0x300)
-#define OMAP1510P1_FPGA_ETHR_BASE (OMAP1510P1_FPGA_BASE + 0x300)
-
-/*
- * Power up Giga UART driver, turn on HID clock.
- * Turn off BT power, since we're not using it and it
- * draws power.
- */
-#define OMAP1510P1_FPGA_RESET_VALUE 0x42
-
-#define OMAP1510P1_FPGA_PCR_IF_PD0 (1 << 7)
-#define OMAP1510P1_FPGA_PCR_COM2_EN (1 << 6)
-#define OMAP1510P1_FPGA_PCR_COM1_EN (1 << 5)
-#define OMAP1510P1_FPGA_PCR_EXP_PD0 (1 << 4)
-#define OMAP1510P1_FPGA_PCR_EXP_PD1 (1 << 3)
-#define OMAP1510P1_FPGA_PCR_48MHZ_CLK (1 << 2)
-#define OMAP1510P1_FPGA_PCR_4MHZ_CLK (1 << 1)
-#define OMAP1510P1_FPGA_PCR_RSRVD_BIT0 (1 << 0)
-
-/*
- * Innovator/OMAP1510 FPGA HID register bit definitions
- */
-#define FPGA_HID_SCLK (1<<0) /* output */
-#define FPGA_HID_MOSI (1<<1) /* output */
-#define FPGA_HID_nSS (1<<2) /* output 0/1 chip idle/select */
-#define FPGA_HID_nHSUS (1<<3) /* output 0/1 host active/suspended */
-#define FPGA_HID_MISO (1<<4) /* input */
-#define FPGA_HID_ATN (1<<5) /* input 0/1 chip idle/ATN */
-#define FPGA_HID_rsrvd (1<<6)
-#define FPGA_HID_RESETn (1<<7) /* output - 0/1 USAR reset/run */
-
-#ifndef OMAP_SDRAM_DEVICE
-#define OMAP_SDRAM_DEVICE D256M_1X16_4B
-#endif
-
-#define OMAP1510P1_IMIF_PRI_VALUE 0x00
-#define OMAP1510P1_EMIFS_PRI_VALUE 0x00
-#define OMAP1510P1_EMIFF_PRI_VALUE 0x00
-
-/*
- * These definitions define an area of FLASH set aside
- * for the use of MTD/JFFS2. This is the area of flash
- * that a JFFS2 filesystem will reside which is mounted
- * at boot with the "root=/dev/mtdblock/0 rw"
- * command line option. The flash address used here must
- * fall within the legal range defined by rrload for storing
- * the filesystem component. This address will be sufficiently
- * deep into the overall flash range to avoid the other
- * components also stored in flash such as the bootloader,
- * the bootloader params, and the kernel.
- * The SW2 settings for the map below are:
- * 1 off, 2 off, 3 on, 4 off.
- */
-
-/* Intel flash_0, partitioned as expected by rrload */
-#define OMAP_FLASH_0_BASE 0xD8000000
-#define OMAP_FLASH_0_START 0x00000000
-#define OMAP_FLASH_0_SIZE SZ_16M
-
-/* Intel flash_1, used for cramfs or other flash file systems */
-#define OMAP_FLASH_1_BASE 0xD9000000
-#define OMAP_FLASH_1_START 0x01000000
-#define OMAP_FLASH_1_SIZE SZ_16M
-
-/* The FPGA IRQ is cascaded through GPIO_13 */
-#define INT_FPGA (IH_GPIO_BASE + 13)
-
-/* IRQ Numbers for interrupts muxed through the FPGA */
-#define IH_FPGA_BASE IH_BOARD_BASE
-#define INT_FPGA_ATN (IH_FPGA_BASE + 0)
-#define INT_FPGA_ACK (IH_FPGA_BASE + 1)
-#define INT_FPGA2 (IH_FPGA_BASE + 2)
-#define INT_FPGA3 (IH_FPGA_BASE + 3)
-#define INT_FPGA4 (IH_FPGA_BASE + 4)
-#define INT_FPGA5 (IH_FPGA_BASE + 5)
-#define INT_FPGA6 (IH_FPGA_BASE + 6)
-#define INT_FPGA7 (IH_FPGA_BASE + 7)
-#define INT_FPGA8 (IH_FPGA_BASE + 8)
-#define INT_FPGA9 (IH_FPGA_BASE + 9)
-#define INT_FPGA10 (IH_FPGA_BASE + 10)
-#define INT_FPGA11 (IH_FPGA_BASE + 11)
-#define INT_FPGA12 (IH_FPGA_BASE + 12)
-#define INT_ETHER (IH_FPGA_BASE + 13)
-#define INT_FPGAUART1 (IH_FPGA_BASE + 14)
-#define INT_FPGAUART2 (IH_FPGA_BASE + 15)
-#define INT_FPGA_TS (IH_FPGA_BASE + 16)
-#define INT_FPGA17 (IH_FPGA_BASE + 17)
-#define INT_FPGA_CAM (IH_FPGA_BASE + 18)
-#define INT_FPGA_RTC_A (IH_FPGA_BASE + 19)
-#define INT_FPGA_RTC_B (IH_FPGA_BASE + 20)
-#define INT_FPGA_CD (IH_FPGA_BASE + 21)
-#define INT_FPGA22 (IH_FPGA_BASE + 22)
-#define INT_FPGA23 (IH_FPGA_BASE + 23)
-
-#define NR_FPGA_IRQS 24
-
-#define MAXIRQNUM (IH_FPGA_BASE + NR_FPGA_IRQS - 1)
-#define MAXFIQNUM MAXIRQNUM
-#define MAXSWINUM MAXIRQNUM
-
-#define NR_IRQS 256
-
-#ifndef __ASSEMBLY__
-void fpga_write(unsigned char val, int reg);
-unsigned char fpga_read(int reg);
-#endif
-
-#elif defined (CONFIG_ARCH_OMAP1610)
-
-/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
-#define OMAP1610_ETHR_BASE 0xE8000000
-#define OMAP1610_ETHR_SIZE SZ_4K
-#define OMAP1610_ETHR_START 0x04000000
-
-/* Intel STRATA NOR flash at CS3 */
-#define OMAP1610_NOR_FLASH_BASE 0xD8000000
-#define OMAP1610_NOR_FLASH_SIZE SZ_32M
-#define OMAP1610_NOR_FLASH_START 0x0C000000
-
-#define MAXIRQNUM (IH_BOARD_BASE)
-#define MAXFIQNUM MAXIRQNUM
-#define MAXSWINUM MAXIRQNUM
-
-#define NR_IRQS (MAXIRQNUM + 1)
-
-#else
-#error "Only OMAP1510 and OMAP1610 Innovator supported!"
-#endif
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-omap/omap-perseus2.h
- *
- * Copyright 2003 by Texas Instruments Incorporated
- * OMAP730 / P2-sample additions
- * Author: Jean Pihet
- *
- * Copyright (C) 2001 RidgeRun, Inc. (http://www.ridgerun.com)
- * Author: RidgeRun, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __ASM_ARCH_OMAP_P2SAMPLE_H
-#define __ASM_ARCH_OMAP_P2SAMPLE_H
-
-#if defined(CONFIG_ARCH_OMAP730) && defined (CONFIG_MACH_OMAP_PERSEUS2)
-
-/*
- * NOTE: ALL DEFINITIONS IN THIS FILE NEED TO BE PREFIXED BY IDENTIFIER
- * P2SAMPLE_ since they are specific to the EVM and not the chip.
- */
-
-/* ---------------------------------------------------------------------------
- * OMAP730 Debug Board FPGA
- * ---------------------------------------------------------------------------
- *
- */
-
-/* maps in the FPGA registers and the ETHR registers */
-#define OMAP730_FPGA_BASE 0xE8000000 /* VA */
-#define OMAP730_FPGA_SIZE SZ_4K /* SIZE */
-#define OMAP730_FPGA_START 0x04000000 /* PA */
-
-#define OMAP730_FPGA_ETHR_START OMAP730_FPGA_START
-#define OMAP730_FPGA_ETHR_BASE OMAP730_FPGA_BASE
-#define OMAP730_FPGA_FPGA_REV (OMAP730_FPGA_BASE + 0x10) /* FPGA Revision */
-#define OMAP730_FPGA_BOARD_REV (OMAP730_FPGA_BASE + 0x12) /* Board Revision */
-#define OMAP730_FPGA_GPIO (OMAP730_FPGA_BASE + 0x14) /* GPIO outputs */
-#define OMAP730_FPGA_LEDS (OMAP730_FPGA_BASE + 0x16) /* LEDs outputs */
-#define OMAP730_FPGA_MISC_INPUTS (OMAP730_FPGA_BASE + 0x18) /* Misc inputs */
-#define OMAP730_FPGA_LAN_STATUS (OMAP730_FPGA_BASE + 0x1A) /* LAN Status line */
-#define OMAP730_FPGA_LAN_RESET (OMAP730_FPGA_BASE + 0x1C) /* LAN Reset line */
-
-// LEDs definition on debug board (16 LEDs)
-#define OMAP730_FPGA_LED_CLAIMRELEASE (1 << 15)
-#define OMAP730_FPGA_LED_STARTSTOP (1 << 14)
-#define OMAP730_FPGA_LED_HALTED (1 << 13)
-#define OMAP730_FPGA_LED_IDLE (1 << 12)
-#define OMAP730_FPGA_LED_TIMER (1 << 11)
-// cpu0 load-meter LEDs
-#define OMAP730_FPGA_LOAD_METER (1 << 0) // A bit of fun on our board ...
-#define OMAP730_FPGA_LOAD_METER_SIZE 11
-#define OMAP730_FPGA_LOAD_METER_MASK ((1 << OMAP730_FPGA_LOAD_METER_SIZE) - 1)
-
-#ifndef OMAP_SDRAM_DEVICE
-#define OMAP_SDRAM_DEVICE D256M_1X16_4B
-#endif
-
-
-/*
- * These definitions define an area of FLASH set aside
- * for the use of MTD/JFFS2. This is the area of flash
- * that a JFFS2 filesystem will reside which is mounted
- * at boot with the "root=/dev/mtdblock/0 rw"
- * command line option.
- */
-
-/* Intel flash_0, partitioned as expected by rrload */
-#define OMAP_FLASH_0_BASE 0xD8000000 /* VA */
-#define OMAP_FLASH_0_START 0x00000000 /* PA */
-#define OMAP_FLASH_0_SIZE SZ_32M
-
-/* 2.9.6 Traffic Controller Memory Interface Registers */
-#define OMAP_FLASH_CFG_0 0xfffecc10
-#define OMAP_FLASH_ACFG_0 0xfffecc50
-
-#define OMAP_FLASH_CFG_1 0xfffecc14
-#define OMAP_FLASH_ACFG_1 0xfffecc54
-
-/*
- * Configuration Registers
- */
-#define PERSEUS2_CONFIG_BASE 0xfffe1000
-#define PERSEUS2_IO_CONF_0 0xfffe1070
-#define PERSEUS2_IO_CONF_1 0xfffe1074
-#define PERSEUS2_IO_CONF_2 0xfffe1078
-#define PERSEUS2_IO_CONF_3 0xfffe107c
-#define PERSEUS2_IO_CONF_4 0xfffe1080
-#define PERSEUS2_IO_CONF_5 0xfffe1084
-#define PERSEUS2_IO_CONF_6 0xfffe1088
-#define PERSEUS2_IO_CONF_7 0xfffe108c
-#define PERSEUS2_IO_CONF_8 0xfffe1090
-#define PERSEUS2_IO_CONF_9 0xfffe1094
-#define PERSEUS2_IO_CONF_10 0xfffe1098
-#define PERSEUS2_IO_CONF_11 0xfffe109c
-#define PERSEUS2_IO_CONF_12 0xfffe10a0
-#define PERSEUS2_IO_CONF_13 0xfffe10a4
-
-#define PERSEUS2_MODE_1 0xfffe1010
-#define PERSEUS2_MODE_2 0xfffe1014
-
-/* CSMI specials: in terms of base + offset */
-#define PERSEUS2_MODE2_OFFSET 0x14
-
-/* DSP control: ICR registers */
-#define ICR_BASE 0xfffbb800
-/* M_CTL */
-#define DSP_M_CTL ((volatile __u16 *)0xfffbb804)
-/* DSP control: MMU registers */
-#define DSP_MMU_BASE ((volatile __u16 *)0xfffed200)
-
-/* The Ethernet Controller IRQ is cascaded to MPU_EXT_nIRQ througb the FPGA */
-#define INT_ETHER INT_730_MPU_EXT_NIRQ
-
-#define MAXIRQNUM IH_BOARD_BASE
-#define MAXFIQNUM MAXIRQNUM
-#define MAXSWINUM MAXIRQNUM
-
-#define NR_IRQS (MAXIRQNUM + 1)
-
-#ifndef __ASSEMBLY__
-void fpga_write(unsigned char val, int reg);
-unsigned char fpga_read(int reg);
-#endif
-
-/* PCC_UPLD control register: OMAP730 */
-#define PCC_UPLD_CTRL_REG_BASE (0xfffe0900)
-#define PCC_UPLD_CTRL_REG (volatile __u16 *)(PCC_UPLD_CTRL_REG_BASE + 0x00)
-
-#else
-#error "Only OMAP730 Perseus2 supported!"
-#endif
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-omap/time.h
- *
- * 32kHz timer definition
- *
- * Copyright (C) 2000 RidgeRun, Inc.
- * Author: Greg Lonnon <glonnon@ridgerun.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#if !defined(__ASM_ARCH_OMAP_TIME_H)
-#define __ASM_ARCH_OMAP_TIME_H
-
-#include <linux/config.h>
-#include <linux/delay.h>
-#include <asm/system.h>
-#include <asm/hardware.h>
-#include <asm/io.h>
-#include <asm/leds.h>
-#include <asm/irq.h>
-#include <asm/mach/irq.h>
-#include <asm/arch/clocks.h>
-
-#ifndef __instrument
-#define __instrument
-#define __noinstrument __attribute__ ((no_instrument_function))
-#endif
-
-typedef struct {
- u32 cntl; /* CNTL_TIMER, R/W */
- u32 load_tim; /* LOAD_TIM, W */
- u32 read_tim; /* READ_TIM, R */
-} mputimer_regs_t;
-
-#define mputimer_base(n) \
- ((volatile mputimer_regs_t*)IO_ADDRESS(OMAP_MPUTIMER_BASE + \
- (n)*OMAP_MPUTIMER_OFFSET))
-
-static inline unsigned long timer32k_read(int reg) {
- unsigned long val;
- val = omap_readw(reg + OMAP_32kHz_TIMER_BASE);
- return val;
-}
-static inline void timer32k_write(int reg,int val) {
- omap_writew(val, reg + OMAP_32kHz_TIMER_BASE);
-}
-
-/*
- * How long is the timer interval? 100 HZ, right...
- * IRQ rate = (TVR + 1) / 32768 seconds
- * TVR = 32768 * IRQ_RATE -1
- * IRQ_RATE = 1/100
- * TVR = 326
- */
-#define TIMER32k_PERIOD 326
-//#define TIMER32k_PERIOD 0x7ff
-
-static inline void start_timer32k(void) {
- timer32k_write(TIMER32k_CR,
- TIMER32k_TSS | TIMER32k_TRB |
- TIMER32k_INT | TIMER32k_ARL);
-}
-
-#ifdef CONFIG_MACH_OMAP_PERSEUS2
-/*
- * After programming PTV with 0 and setting the MPUTIM_CLOCK_ENABLE
- * (external clock enable) bit, the timer count rate is 6.5 MHz (13
- * MHZ input/2). !! The divider by 2 is undocumented !!
- */
-#define MPUTICKS_PER_SEC (13000000/2)
-#else
-/*
- * After programming PTV with 0, the timer count rate is 6 MHz.
- * WARNING! this must be an even number, or machinecycles_to_usecs
- * below will break.
- */
-#define MPUTICKS_PER_SEC (12000000/2)
-#endif
-
-static int mputimer_started[3] = {0,0,0};
-
-static inline void __noinstrument start_mputimer(int n,
- unsigned long load_val)
-{
- volatile mputimer_regs_t* timer = mputimer_base(n);
-
- mputimer_started[n] = 0;
- timer->cntl = MPUTIM_CLOCK_ENABLE;
- udelay(1);
-
- timer->load_tim = load_val;
- udelay(1);
- timer->cntl = (MPUTIM_CLOCK_ENABLE | MPUTIM_AR | MPUTIM_ST);
- mputimer_started[n] = 1;
-}
-
-static inline unsigned long __noinstrument
-read_mputimer(int n)
-{
- volatile mputimer_regs_t* timer = mputimer_base(n);
- return (mputimer_started[n] ? timer->read_tim : 0);
-}
-
-void __noinstrument start_mputimer1(unsigned long load_val)
-{
- start_mputimer(0, load_val);
-}
-void __noinstrument start_mputimer2(unsigned long load_val)
-{
- start_mputimer(1, load_val);
-}
-void __noinstrument start_mputimer3(unsigned long load_val)
-{
- start_mputimer(2, load_val);
-}
-
-unsigned long __noinstrument read_mputimer1(void)
-{
- return read_mputimer(0);
-}
-unsigned long __noinstrument read_mputimer2(void)
-{
- return read_mputimer(1);
-}
-unsigned long __noinstrument read_mputimer3(void)
-{
- return read_mputimer(2);
-}
-
-unsigned long __noinstrument do_getmachinecycles(void)
-{
- return 0 - read_mputimer(0);
-}
-
-unsigned long __noinstrument machinecycles_to_usecs(unsigned long mputicks)
-{
- /* Round up to nearest usec */
- return ((mputicks * 1000) / (MPUTICKS_PER_SEC / 2 / 1000) + 1) >> 1;
-}
-
-/*
- * This marks the time of the last system timer interrupt
- * that was *processed by the ISR* (timer 2).
- */
-static unsigned long systimer_mark;
-
-static unsigned long omap1510_gettimeoffset(void)
-{
- /* Return elapsed usecs since last system timer ISR */
- return machinecycles_to_usecs(do_getmachinecycles() - systimer_mark);
-}
-
-static irqreturn_t
-omap1510_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- unsigned long now, ilatency;
-
- /*
- * Mark the time at which the timer interrupt ocurred using
- * timer1. We need to remove interrupt latency, which we can
- * retrieve from the current system timer2 counter. Both the
- * offset timer1 and the system timer2 are counting at 6MHz,
- * so we're ok.
- */
- now = 0 - read_mputimer1();
- ilatency = MPUTICKS_PER_SEC / 100 - read_mputimer2();
- systimer_mark = now - ilatency;
-
- do_leds();
- do_timer(regs);
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- /* Since we don't call request_irq, we must init the structure */
- gettimeoffset = omap1510_gettimeoffset;
-
- timer_irq.handler = omap1510_timer_interrupt;
- timer_irq.flags = SA_INTERRUPT;
-#ifdef OMAP1510_USE_32KHZ_TIMER
- timer32k_write(TIMER32k_CR, 0x0);
- timer32k_write(TIMER32k_TVR,TIMER32k_PERIOD);
- setup_irq(INT_OS_32kHz_TIMER, &timer_irq);
- start_timer32k();
-#else
- setup_irq(INT_TIMER2, &timer_irq);
- start_mputimer2(MPUTICKS_PER_SEC / 100 - 1);
-#endif
-}
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-pxa/ide.h
- *
- * Author: George Davis
- * Created: Jan 10, 2002
- * Copyright: MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *
- * Originally based upon linux/include/asm-arm/arch-sa1100/ide.h
- *
- */
-
-#include <asm/irq.h>
-#include <asm/hardware.h>
-#include <asm/mach-types.h>
-
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
- int regincr = 1;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += regincr;
- }
-
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
-
- if (irq)
- *irq = 0;
-}
-
-
-/*
- * Register the standard ports for this architecture with the IDE driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
- /* Nothing to declare... */
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-pxa/keyboard.h
- *
- * This file contains the architecture specific keyboard definitions
- */
-
-#ifndef _PXA_KEYBOARD_H
-#define _PXA_KEYBOARD_H
-
-#include <asm/mach-types.h>
-#include <asm/hardware.h>
-
-extern struct kbd_ops_struct *kbd_ops;
-
-#define kbd_disable_irq() do { } while(0);
-#define kbd_enable_irq() do { } while(0);
-
-extern int sa1111_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
- if (machine_is_lubbock())
- sa1111_kbd_init_hw();
-}
-
-
-#endif /* _PXA_KEYBOARD_H */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-pxa/time.h
- *
- * Author: Nicolas Pitre
- * Created: Jun 15, 2001
- * Copyright: MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-
-static inline unsigned long pxa_get_rtc_time(void)
-{
- return RCNR;
-}
-
-static int pxa_set_rtc(void)
-{
- unsigned long current_time = xtime.tv_sec;
-
- if (RTSR & RTSR_ALE) {
- /* make sure not to forward the clock over an alarm */
- unsigned long alarm = RTAR;
- if (current_time >= alarm && alarm >= RCNR)
- return -ERESTARTSYS;
- }
- RCNR = current_time;
- return 0;
-}
-
-/* IRQs are disabled before entering here from do_gettimeofday() */
-static unsigned long pxa_gettimeoffset (void)
-{
- long ticks_to_match, elapsed, usec;
-
- /* Get ticks before next timer match */
- ticks_to_match = OSMR0 - OSCR;
-
- /* We need elapsed ticks since last match */
- elapsed = LATCH - ticks_to_match;
-
- /* don't get fooled by the workaround in pxa_timer_interrupt() */
- if (elapsed <= 0)
- return 0;
-
- /* Now convert them to usec */
- usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
-
- return usec;
-}
-
-static irqreturn_t
-pxa_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- int next_match;
-
- do_profile(regs);
-
- /* Loop until we get ahead of the free running timer.
- * This ensures an exact clock tick count and time accuracy.
- * IRQs are disabled inside the loop to ensure coherence between
- * lost_ticks (updated in do_timer()) and the match reg value, so we
- * can use do_gettimeofday() from interrupt handlers.
- *
- * HACK ALERT: it seems that the PXA timer regs aren't updated right
- * away in all cases when a write occurs. We therefore compare with
- * 8 instead of 0 in the while() condition below to avoid missing a
- * match if OSCR has already reached the next OSMR value.
- * Experience has shown that up to 6 ticks are needed to work around
- * this problem, but let's use 8 to be conservative. Note that this
- * affect things only when the timer IRQ has been delayed by nearly
- * exactly one tick period which should be a pretty rare event.
- */
- do {
- do_leds();
- do_set_rtc();
- do_timer(regs);
- OSSR = OSSR_M0; /* Clear match on timer 0 */
- next_match = (OSMR0 += LATCH);
- } while( (signed long)(next_match - OSCR) <= 8 );
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- struct timespec tv;
-
- gettimeoffset = pxa_gettimeoffset;
- set_rtc = pxa_set_rtc;
-
- tv.tv_nsec = 0;
- tv.tv_sec = pxa_get_rtc_time();
- do_settimeofday(&tv);
-
- timer_irq.handler = pxa_timer_interrupt;
- OSMR0 = 0; /* set initial match at 0 */
- OSSR = 0xf; /* clear status on all timers */
- setup_irq(IRQ_OST0, &timer_irq);
- OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */
- OSCR = 0; /* initialize free-running timer, force first match */
-}
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-rpc/ide.h
- *
- * Copyright (C) 1997 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Modifications:
- * 29-07-1998 RMK Major re-work of IDE architecture specific code
- */
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- if (irq)
- *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
- hw_regs_t hw;
-
- ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
- hw.irq = IRQ_HARDDISK;
- ide_register_hw(&hw, NULL);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-rpc/time.h
- *
- * Copyright (C) 1996-2000 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 24-Sep-1996 RMK Created
- * 10-Oct-1996 RMK Brought up to date with arch-sa110eval
- * 04-Dec-1997 RMK Updated for new arch/arm/time.c
- */
-extern void ioctime_init(void);
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- do_timer(regs);
- do_set_rtc();
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt.
- */
-void __init time_init(void)
-{
- ioctime_init();
-
- timer_irq.handler = timer_interrupt;
-
- setup_irq(IRQ_TIMER, &timer_irq);
-}
+++ /dev/null
-/* linux/include/asm-arm/arch-s3c2410/ide.h
- *
- * Copyright (C) 1997 Russell King
- * Copyright (C) 2003 Simtec Electronics
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Modifications:
- * 29-07-1998 RMK Major re-work of IDE architecture specific code
- * 16-05-2003 BJD Changed to work with BAST IDE ports
- * 04-09-2003 BJD Modifications for V2.6
- */
-
-#ifndef __ASM_ARCH_IDE_H
-#define __ASM_ARCH_IDE_H
-
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- if (irq)
- *irq = 0;
-}
-
-/* we initialise our ide devices from the main ide core, due to problems
- * with doing it in this function
-*/
-
-#define ide_init_default_hwifs() do { } while(0)
-
-#endif /* __ASM_ARCH_IDE_H */
+++ /dev/null
-/* linux/include/asm-arm/arch-s3c2410/time.h
- *
- * Copyright (C) 2003 Simtec Electronics <linux@simtec.co.uk>
- * Ben Dooks, <ben@simtec.co.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <asm/system.h>
-#include <asm/leds.h>
-#include <asm/mach-types.h>
-
-#include <asm/io.h>
-#include <asm/arch/map.h>
-#include <asm/arch/regs-timer.h>
-
-extern unsigned long (*gettimeoffset)(void);
-
-static unsigned long timer_startval;
-static unsigned long timer_ticks_usec;
-
-#ifdef CONFIG_S3C2410_RTC
-extern void s3c2410_rtc_check();
-#endif
-
-/* with an 12MHz clock, we get 12 ticks per-usec
- */
-
-
-/***
- * Returns microsecond since last clock interrupt. Note that interrupts
- * will have been disabled by do_gettimeoffset()
- * IRQs are disabled before entering here from do_gettimeofday()
- */
-static unsigned long s3c2410_gettimeoffset (void)
-{
- unsigned long tdone;
- unsigned long usec;
-
- /* work out how many ticks have gone since last timer interrupt */
-
- tdone = timer_startval - __raw_readl(S3C2410_TCNTO(4));
-
- /* currently, tcnt is in 12MHz units, but this may change
- * for non-bast machines...
- */
-
- usec = tdone / timer_ticks_usec;
-
- return usec;
-}
-
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t
-s3c2410_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- do_leds();
- do_timer(regs);
-
- do_set_rtc();
- //s3c2410_rtc_check();
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-
-/* currently we only use timer4, as it is the only timer which has no
- * other function that can be exploited externally
-*/
-
-void __init time_init (void)
-{
- unsigned long tcon;
- unsigned long tcnt;
- unsigned long tcfg1;
- unsigned long tcfg0;
-
- gettimeoffset = s3c2410_gettimeoffset;
- timer_irq.handler = s3c2410_timer_interrupt;
-
- tcnt = 0xffff; /* default value for tcnt */
-
- /* read the current timer configuration bits */
-
- tcon = __raw_readl(S3C2410_TCON);
- tcfg1 = __raw_readl(S3C2410_TCFG1);
- tcfg0 = __raw_readl(S3C2410_TCFG0);
-
- /* configure the system for whichever machine is in use */
-
- if (machine_is_bast() || machine_is_vr1000()) {
- timer_ticks_usec = 12; /* timer is at 12MHz */
- tcnt = (timer_ticks_usec * (1000*1000)) / HZ;
- }
-
- /* for the h1940, we use the pclk from the core to generate
- * the timer values. since 67.5MHz is not a value we can directly
- * generate the timer value from, we need to pre-scale and
- * divied before using it.
- *
- * overall divsior to get 200Hz is 337500
- * we can fit tcnt if we pre-scale by 6, producing a tick rate
- * of 11.25MHz, and a tcnt of 56250.
- */
-
- if (machine_is_h1940() || machine_is_smdk2410() ) {
- timer_ticks_usec = s3c2410_pclk / (1000*1000);
- timer_ticks_usec /= 6;
-
- tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
- tcfg1 |= S3C2410_TCFG1_MUX4_DIV2;
-
- tcfg0 &= ~S3C2410_TCFG_PRESCALER1_MASK;
- tcfg0 |= ((6 - 1) / 2) << S3C2410_TCFG_PRESCALER1_SHIFT;
-
- tcnt = (s3c2410_pclk / 6) / HZ;
- }
-
-
- printk("setup_timer tcon=%08lx, tcnt %04lx, tcfg %08lx,%08lx\n",
- tcon, tcnt, tcfg0, tcfg1);
-
- /* check to see if timer is within 16bit range... */
- if (tcnt > 0xffff) {
- panic("setup_timer: HZ is too small, cannot configure timer!");
- return;
- }
-
- __raw_writel(tcfg1, S3C2410_TCFG1);
- __raw_writel(tcfg0, S3C2410_TCFG0);
-
- timer_startval = tcnt;
- __raw_writel(tcnt, S3C2410_TCNTB(4));
-
- /* ensure timer is stopped... */
-
- tcon &= ~(7<<20);
- tcon |= S3C2410_TCON_T4RELOAD;
- tcon |= S3C2410_TCON_T4MANUALUPD;
-
- __raw_writel(tcon, S3C2410_TCON);
- __raw_writel(tcnt, S3C2410_TCNTB(4));
- __raw_writel(tcnt, S3C2410_TCMPB(4));
-
- setup_irq(IRQ_TIMER4, &timer_irq);
-
- /* start the timer running */
- tcon |= S3C2410_TCON_T4START;
- tcon &= ~S3C2410_TCON_T4MANUALUPD;
- __raw_writel(tcon, S3C2410_TCON);
-}
-
-
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-sa1100/keyboard.h
- * Created 16 Dec 1999 by Nicolas Pitre <nico@cam.org>
- * This file contains the SA1100 architecture specific keyboard definitions
- */
-#ifndef _SA1100_KEYBOARD_H
-#define _SA1100_KEYBOARD_H
-
-#include <linux/config.h>
-#include <asm/mach-types.h>
-
-extern void gc_kbd_init_hw(void);
-extern void smartio_kbd_init_hw(void);
-
-static inline void kbd_init_hw(void)
-{
- if (machine_is_graphicsclient())
- gc_kbd_init_hw();
- if (machine_is_adsbitsy())
- smartio_kbd_init_hw();
-}
-
-#endif /* _SA1100_KEYBOARD_H */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-sa1100/time.h
- *
- * Copyright (C) 1998 Deborah Wallach.
- * Twiddles (C) 1999 Hugo Fiennes <hugo@empeg.com>
- *
- * 2000/03/29 (C) Nicolas Pitre <nico@cam.org>
- * Rewritten: big cleanup, much simpler, better HZ accuracy.
- *
- */
-
-
-#define RTC_DEF_DIVIDER (32768 - 1)
-#define RTC_DEF_TRIM 0
-
-static unsigned long __init sa1100_get_rtc_time(void)
-{
- /*
- * According to the manual we should be able to let RTTR be zero
- * and then a default diviser for a 32.768KHz clock is used.
- * Apparently this doesn't work, at least for my SA1110 rev 5.
- * If the clock divider is uninitialized then reset it to the
- * default value to get the 1Hz clock.
- */
- if (RTTR == 0) {
- RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
- printk(KERN_WARNING "Warning: uninitialized Real Time Clock\n");
- /* The current RTC value probably doesn't make sense either */
- RCNR = 0;
- return 0;
- }
- return RCNR;
-}
-
-static int sa1100_set_rtc(void)
-{
- unsigned long current_time = xtime.tv_sec;
-
- if (RTSR & RTSR_ALE) {
- /* make sure not to forward the clock over an alarm */
- unsigned long alarm = RTAR;
- if (current_time >= alarm && alarm >= RCNR)
- return -ERESTARTSYS;
- }
- RCNR = current_time;
- return 0;
-}
-
-/* IRQs are disabled before entering here from do_gettimeofday() */
-static unsigned long sa1100_gettimeoffset (void)
-{
- unsigned long ticks_to_match, elapsed, usec;
-
- /* Get ticks before next timer match */
- ticks_to_match = OSMR0 - OSCR;
-
- /* We need elapsed ticks since last match */
- elapsed = LATCH - ticks_to_match;
-
- /* Now convert them to usec */
- usec = (unsigned long)(elapsed * (tick_nsec / 1000))/LATCH;
-
- return usec;
-}
-
-/*
- * We will be entered with IRQs enabled.
- *
- * Loop until we get ahead of the free running timer.
- * This ensures an exact clock tick count and time accuracy.
- * IRQs are disabled inside the loop to ensure coherence between
- * lost_ticks (updated in do_timer()) and the match reg value, so we
- * can use do_gettimeofday() from interrupt handlers.
- */
-static irqreturn_t
-sa1100_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- unsigned int next_match;
-
- do {
- do_leds();
- do_timer(regs);
- OSSR = OSSR_M0; /* Clear match on timer 0 */
- next_match = (OSMR0 += LATCH);
- do_set_rtc();
- } while ((signed long)(next_match - OSCR) <= 0);
-
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- struct timespec tv;
-
- gettimeoffset = sa1100_gettimeoffset;
- set_rtc = sa1100_set_rtc;
-
- tv.tv_nsec = 0;
- tv.tv_sec = sa1100_get_rtc_time();
- do_settimeofday(&tv);
-
- timer_irq.handler = sa1100_timer_interrupt;
- OSMR0 = 0; /* set initial match at 0 */
- OSSR = 0xf; /* clear status on all timers */
- setup_irq(IRQ_OST0, &timer_irq);
- OIER |= OIER_E0; /* enable match on timer 0 to cause interrupts */
- OSCR = 0; /* initialize free-running timer, force first match */
-}
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-shark/ide.h
- *
- * by Alexander Schulz
- *
- * derived from:
- * linux/include/asm-arm/arch-ebsa285/ide.h
- * Copyright (c) 1998 Russell King
- */
-
-#include <asm/irq.h>
-
-/*
- * Set up a hw structure for a specified data port, control port and IRQ.
- * This should follow whatever the default interface uses.
- */
-static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
- unsigned long ctrl_port, int *irq)
-{
- unsigned long reg = data_port;
- int i;
-
- memset(hw, 0, sizeof(*hw));
-
- for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
- hw->io_ports[i] = reg;
- reg += 1;
- }
- hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
- if (irq)
- *irq = 0;
-}
-
-/*
- * This registers the standard ports for this architecture with the IDE
- * driver.
- */
-static __inline__ void
-ide_init_default_hwifs(void)
-{
- hw_regs_t hw;
-
- ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
- hw.irq = 14;
- ide_register_hw(&hw,NULL);
-}
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-shark/keyboard.h
- * by Alexander Schulz
- *
- * Derived from linux/include/asm-arm/arch-ebsa285/keyboard.h
- * (C) 1998 Russell King
- * (C) 1998 Phil Blundell
- */
-#include <linux/config.h>
-#include <linux/ioport.h>
-#include <asm/irq.h>
-#include <asm/io.h>
-#include <asm/system.h>
-
-#define KEYBOARD_IRQ IRQ_ISA_KEYBOARD
-#define NR_SCANCODES 128
-
-#define kbd_disable_irq() do { } while (0)
-#define kbd_enable_irq() do { } while (0)
-
-extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
-extern int pckbd_getkeycode(unsigned int scancode);
-extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
- char raw_mode);
-extern char pckbd_unexpected_up(unsigned char keycode);
-extern void pckbd_leds(unsigned char leds);
-extern void pckbd_init_hw(void);
-extern unsigned char pckbd_sysrq_xlate[128];
-
-static inline void kbd_init_hw(void)
-{
- k_setkeycode = pckbd_setkeycode;
- k_getkeycode = pckbd_getkeycode;
- k_translate = pckbd_translate;
- k_unexpected_up = pckbd_unexpected_up;
- k_leds = pckbd_leds;
-#ifdef CONFIG_MAGIC_SYSRQ
- k_sysrq_key = 0x54;
- k_sysrq_xlate = pckbd_sysrq_xlate;
-#endif
- pckbd_init_hw();
-}
-
-/*
- * PC Keyboard specifics
- */
-
-/* resource allocation */
-#define kbd_request_region() request_region(0x60, 16, "keyboard")
-#define kbd_request_irq(handler) request_irq(KEYBOARD_IRQ, handler, 0, \
- "keyboard", NULL)
-
-/* How to access the keyboard macros on this platform. */
-#define kbd_read_input() inb(KBD_DATA_REG)
-#define kbd_read_status() inb(KBD_STATUS_REG)
-#define kbd_write_output(val) outb(val, KBD_DATA_REG)
-#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
-
-/* Some stoneage hardware needs delays after some operations. */
-#define kbd_pause() do { } while(0)
-
-/*
- * Machine specific bits for the PS/2 driver
- */
-#define aux_request_irq(hand, dev_id) \
- request_irq(AUX_IRQ, hand, SA_SHIRQ, "PS/2 Mouse", dev_id)
-
-#define aux_free_irq(dev_id) free_irq(AUX_IRQ, dev_id)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-shark/time.h
- *
- * by Alexander Schulz
- *
- * derived from include/asm-arm/arch-ebsa110/time.h
- * Copyright (c) 1996,1997,1998 Russell King.
- */
-
-#include <asm/leds.h>
-#include <asm/param.h>
-
-#define IRQ_TIMER 0
-#define HZ_TIME ((1193180 + HZ/2) / HZ)
-
-static irqreturn_t
-timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- do_leds();
- do_timer(regs);
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
- unsigned long flags;
-
- outb(0x34, 0x43); /* binary, mode 0, LSB/MSB, Ch 0 */
- outb(HZ_TIME & 0xff, 0x40); /* LSB of count */
- outb(HZ_TIME >> 8, 0x40);
-
- timer_irq.handler = timer_interrupt;
- setup_irq(IRQ_TIMER, &timer_irq);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/dma.h
- *
- * Architecture DMA routines. We have to contend with the bizarre DMA
- * machine built into the Tbox hardware.
- *
- * Copyright (C) 1998 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-/*
- * DMA channel definitions. Some of these are physically strange but
- * we sort it out inside dma.c so the user never has to care. The
- * exception is the double-buffering which we can't really abstract
- * away sensibly.
- */
-#define DMA_VIDEO 0
-#define DMA_MPEG_B 1
-#define DMA_AUDIO_B 2
-#define DMA_ASHRX_B 3
-#define DMA_ASHTX 4
-#define DMA_MPEG 5
-#define DMA_AUDIO 6
-#define DMA_ASHRX 7
-
-#define MAX_DMA_CHANNELS 0 /* XXX */
-
-/*
- * This is the maximum DMA address that can be DMAd to.
- */
-#define MAX_DMA_ADDRESS 0xffffffff
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/hardware.h
- *
- * Copyright (C) 1998, 1999, 2000 Philip Blundell
- * Copyright (C) 2000 FutureTV Labs Ltd
- *
- * This file contains the hardware definitions of the Tbox
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef __ASM_ARCH_HARDWARE_H
-#define __ASM_ARCH_HARDWARE_H
-
-/* Logical Physical
- * 0xfff00000 0x00100000 I/O
- * 0xfff00000 0x00100000 Expansion CS0
- * 0xfff10000 0x00110000 DMA
- * 0xfff20000 0x00120000 C-Cube
- * 0xfff30000 0x00130000 FPGA 1
- * 0xfff40000 0x00140000 UART 2
- * 0xfff50000 0x00150000 UART 1
- * 0xfff60000 0x00160000 CS8900
- * 0xfff70000 0x00170000 INTCONT
- * 0xfff80000 0x00180000 RAMDAC
- * 0xfff90000 0x00190000 Control 0
- * 0xfffa0000 0x001a0000 Control 1
- * 0xfffb0000 0x001b0000 Control 2
- * 0xfffc0000 0x001c0000 FPGA 2
- * 0xfffd0000 0x001d0000 INTRESET
- * 0xfffe0000 0x001e0000 C-Cube DMA throttle
- * 0xffff0000 0x001f0000 Expansion CS1
- * 0xffe00000 0x82000000 cache flush
- */
-
-/*
- * Mapping areas
- */
-#define IO_BASE 0xfff00000
-#define IO_START 0x00100000
-#define FLUSH_BASE 0xffe00000
-
-#define INTCONT 0xfff70000
-
-#define FPGA1CONT 0xffff3000
-
-/*
- * RAM definitions
- */
-#define RAM_BASE 0x80000000
-#define FLUSH_BASE_PHYS 0x82000000
-
-#define UNCACHEABLE_ADDR INTCONT
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/ide.h
- */
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/io.h
- *
- * Copyright (C) 1996-1999 Russell King
- * Copyright (C) 1998, 1999 Philip Blundell
- *
- */
-#ifndef __ASM_ARM_ARCH_IO_H
-#define __ASM_ARM_ARCH_IO_H
-
-#define IO_SPACE_LIMIT 0xffffffff
-
-#define __io(_x) ((_x) << 2)
-
-/*
- * Generic virtual read/write
- */
-static inline unsigned int __arch_getw(unsigned long a)
-{
- unsigned int value;
- __asm__ __volatile__("ldr%?h %0, [%1, #0] @ getw"
- : "=&r" (value)
- : "r" (a));
- return value;
-}
-
-static inline void __arch_putw(unsigned int value, unsigned long a)
-{
- __asm__ __volatile__("str%?h %0, [%1, #0] @ putw"
- : : "r" (value), "r" (a));
-}
-
-/* Idem, for devices on the upper byte lanes */
-#define inb_u(p) __arch_getb(__io_pc(p) + 2)
-#define inw_u(p) __arch_getw(__io_pc(p) + 2)
-
-#define outb_u(v,p) __arch_putb(v,__io_pc(p) + 2)
-#define outw_u(v,p) __arch_putw(v,__io_pc(p) + 2)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/irqs.h
- *
- * Copyright (C) 1998, 2000 Philip Blundell
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#define IRQ_MPEGDMA 0
-#define IRQ_ASHTX 1
-#define IRQ_ASHRX 2
-#define IRQ_VSYNC 3
-#define IRQ_HSYNC 4
-#define IRQ_MPEG 5
-#define IRQ_UART2 6
-#define IRQ_UART1 7
-#define IRQ_ETHERNET 8
-#define IRQ_TIMER 9
-#define IRQ_AUDIODMA 10
-/* bit 11 used for video field ident */
-#define IRQ_EXPMODCS0 12
-#define IRQ_EXPMODCS1 13
-
-#define irq_canonicalize(i) (i)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/memory.h
- *
- * Copyright (c) 1996-1999 Russell King.
- * Copyright (c) 1998-1999 Phil Blundell
- */
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PHYS_OFFSET (0x80000000UL)
-
-/*
- * Bus view is the same as physical view
- */
-#define __virt_to_bus(x) __virt_to_phys(x)
-#define __bus_to_virt(x) __phys_to_virt(x)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/param.h
- */
-#define __KERNEL_HZ 1000
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/serial.h
- *
- * Copyright (c) 1996 Russell King.
- * Copyright (c) 1998 Phil Blundell
- *
- * Changelog:
- * 15-10-1996 RMK Created
- * 09-06-1998 PJB tbox version
- */
-#ifndef __ASM_ARCH_SERIAL_H
-#define __ASM_ARCH_SERIAL_H
-
-/*
- * This assumes you have a 1.8432 MHz clock for your UART.
- *
- * It'd be nice if someone built a serial card with a 24.576 MHz
- * clock, since the 16550A is capable of handling a top speed of 1.5
- * megabits/second; but this requires the faster clock.
- */
-#define BASE_BAUD (1843200 / 16)
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
- /* UART CLK PORT IRQ FLAGS */
-#define STD_SERIAL_PORT_DEFNS \
- { 0, BASE_BAUD, 0xffff4000 >> 2, 6, STD_COM_FLAGS }, /* ttyS0 */ \
- { 0, BASE_BAUD, 0xffff5000 >> 2, 7, STD_COM_FLAGS }, /* ttyS1 */
-
-#define EXTRA_SERIAL_PORT_DEFNS
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/system.h
- *
- * Copyright (c) 1996-1999 Russell King.
- */
-#ifndef __ASM_ARCH_SYSTEM_H
-#define __ASM_ARCH_SYSTEM_H
-
-static inline void arch_idle(void)
-{
- cpu_do_idle();
-}
-
-#define arch_reset(mode) do { } while (0)
-
-#endif
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/time.h
- *
- * Copyright (c) 1997, 1999 Phil Blundell.
- * Copyright (c) 2000 FutureTV Labs Ltd
- *
- * Tbox has no real-time clock -- we get millisecond ticks to update
- * our soft copy.
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#include <asm/io.h>
-#include <asm/hardware.h>
-
-#define update_rtc()
-
-static irqreturn_t
-timer_interrupt (int irq, void *dev_id, struct pt_regs *regs)
-{
- /* Clear irq */
- __raw_writel(1, FPGA1CONT + 0xc);
- __raw_writel(0, FPGA1CONT + 0xc);
-
- do_timer(regs);
-
- return IRQ_HANDLED;
-}
-
-void __init time_init(void)
-{
- timer_irq.handler = timer_interrupt;
- setup_irq(IRQ_TIMER, &timer_irq);
-}
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/timex.h
- *
- * Tbox timex specifications
- *
- * Copyright (C) 1999 Philip Blundell
- */
-
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-nexuspci/uncompress.h
- * from linux/include/asm-arm/arch-ebsa110/uncompress.h
- *
- * Copyright (C) 1996,1997,1998 Russell King
- * Copyright (C) 1998, 1999 Phil Blundell
- */
-
-#include <asm/io.h>
-
-#define UARTBASE 0x00400000
-
-/*
- * This does not append a newline
- */
-static void puts(const char *s)
-{
- while (*s)
- {
- char c = *(s++);
- while (!(__raw_readb(UARTBASE + 0x14) & 0x20));
- __raw_writeb(c, UARTBASE);
- if (c == 10) {
- while (!(__raw_readb(UARTBASE + 0x14) & 0x20));
- __raw_writeb(13, UARTBASE);
- }
- }
-}
-
-/*
- * nothing to do
- */
-#define arch_decomp_setup()
-
-/*
- * Stroke the watchdog so we don't get reset during decompression.
- */
-#define arch_decomp_wdog() \
- do { \
- __raw_writel(1, 0xa00000); \
- __raw_writel(0, 0xa00000); \
- } while (0)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-tbox/vmalloc.h
- */
-
-/*
- * Just any arbitrary offset to the start of the vmalloc VM area: the
- * current 8MB value just means that there will be a 8MB "hole" after the
- * physical memory until the kernel virtual memory starts. That means that
- * any out-of-bounds memory accesses will hopefully be caught.
- * The vmalloc() routines leaves a hole of 4kB between each vmalloced
- * area for the same reason. ;)
- */
-#define VMALLOC_OFFSET (8*1024*1024)
-#define VMALLOC_START (((unsigned long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
-#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
+++ /dev/null
-/*
- * linux/include/asm-arm/arch-versatile/time.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <asm/system.h>
-#include <asm/leds.h>
-
-/*
- * Where is the timer (VA)?
- */
-#define TIMER0_VA_BASE IO_ADDRESS(VERSATILE_TIMER0_1_BASE)
-#define TIMER1_VA_BASE (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20)
-#define TIMER2_VA_BASE IO_ADDRESS(VERSATILE_TIMER2_3_BASE)
-#define TIMER3_VA_BASE (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20)
-#define VA_IC_BASE IO_ADDRESS(VERSATILE_VIC_BASE)
-
-/*
- * How long is the timer interval?
- */
-#define TIMER_INTERVAL (TICKS_PER_uSEC * mSEC_10)
-#if TIMER_INTERVAL >= 0x100000
-#define TIMER_RELOAD (TIMER_INTERVAL >> 8) /* Divide by 256 */
-#define TIMER_CTRL 0x88 /* Enable, Clock / 256 */
-#define TICKS2USECS(x) (256 * (x) / TICKS_PER_uSEC)
-#elif TIMER_INTERVAL >= 0x10000
-#define TIMER_RELOAD (TIMER_INTERVAL >> 4) /* Divide by 16 */
-#define TIMER_CTRL 0x84 /* Enable, Clock / 16 */
-#define TICKS2USECS(x) (16 * (x) / TICKS_PER_uSEC)
-#else
-#define TIMER_RELOAD (TIMER_INTERVAL)
-#define TIMER_CTRL 0x80 /* Enable */
-#define TICKS2USECS(x) ((x) / TICKS_PER_uSEC)
-#endif
-
-#define TIMER_CTRL_IE (1 << 5) /* Interrupt Enable */
-
-/*
- * What does it look like?
- */
-typedef struct TimerStruct {
- unsigned long TimerLoad;
- unsigned long TimerValue;
- unsigned long TimerControl;
- unsigned long TimerClear;
-} TimerStruct_t;
-
-extern unsigned long (*gettimeoffset)(void);
-
-/*
- * Returns number of ms since last clock interrupt. Note that interrupts
- * will have been disabled by do_gettimeoffset()
- */
-static unsigned long versatile_gettimeoffset(void)
-{
- volatile TimerStruct_t *timer0 = (TimerStruct_t *)TIMER0_VA_BASE;
- unsigned long ticks1, ticks2, status;
-
- /*
- * Get the current number of ticks. Note that there is a race
- * condition between us reading the timer and checking for
- * an interrupt. We get around this by ensuring that the
- * counter has not reloaded between our two reads.
- */
- ticks2 = timer0->TimerValue & 0xffff;
- do {
- ticks1 = ticks2;
- status = __raw_readl(VA_IC_BASE + VIC_IRQ_RAW_STATUS);
- ticks2 = timer0->TimerValue & 0xffff;
- } while (ticks2 > ticks1);
-
- /*
- * Number of ticks since last interrupt.
- */
- ticks1 = TIMER_RELOAD - ticks2;
-
- /*
- * Interrupt pending? If so, we've reloaded once already.
- *
- * FIXME: Need to check this is effectively timer 0 that expires
- */
- if (status & IRQMASK_TIMERINT0_1)
- ticks1 += TIMER_RELOAD;
-
- /*
- * Convert the ticks to usecs
- */
- return TICKS2USECS(ticks1);
-}
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t versatile_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
-{
- volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
-
- // ...clear the interrupt
- timer0->TimerClear = 1;
-
- do_leds();
- do_timer(regs);
- do_profile(regs);
-
- return IRQ_HANDLED;
-}
-
-/*
- * Set up timer interrupt, and return the current time in seconds.
- */
-void __init time_init(void)
-{
- volatile TimerStruct_t *timer0 = (volatile TimerStruct_t *)TIMER0_VA_BASE;
- volatile TimerStruct_t *timer1 = (volatile TimerStruct_t *)TIMER1_VA_BASE;
- volatile TimerStruct_t *timer2 = (volatile TimerStruct_t *)TIMER2_VA_BASE;
- volatile TimerStruct_t *timer3 = (volatile TimerStruct_t *)TIMER3_VA_BASE;
-
- /*
- * set clock frequency:
- * VERSATILE_REFCLK is 32KHz
- * VERSATILE_TIMCLK is 1MHz
- */
- *(volatile unsigned int *)IO_ADDRESS(VERSATILE_SCTL_BASE) |=
- ((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) |
- (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel));
-
- timer_irq.handler = versatile_timer_interrupt;
-
- /*
- * Initialise to a known state (all timers off)
- */
- timer0->TimerControl = 0;
- timer1->TimerControl = 0;
- timer2->TimerControl = 0;
- timer3->TimerControl = 0;
-
- timer0->TimerLoad = TIMER_RELOAD;
- timer0->TimerValue = TIMER_RELOAD;
- timer0->TimerControl = TIMER_CTRL | 0x40 | TIMER_CTRL_IE; /* periodic + IE */
-
- /*
- * Make irqs happen for the system timer
- */
- setup_irq(IRQ_TIMERINT0_1, &timer_irq);
- gettimeoffset = versatile_gettimeoffset;
-}
+++ /dev/null
-#ifndef _ASM_ARM_CPUMASK_H
-#define _ASM_ARM_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ARM_CPUMASK_H */
+++ /dev/null
-#ifndef _ARM_RMAP_H
-#define _ARM_RMAP_H
-
-#include <asm-generic/rmap.h>
-
-#endif /* _ARM_RMAP_H */
+++ /dev/null
-#ifndef _ASM_ARM26_CPUMASK_H
-#define _ASM_ARM26_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_ARM26_CPUMASK_H */
+++ /dev/null
-#ifndef _ARM_RMAP_H
-#define _ARM_RMAP_H
-
-/*
- * linux/include/asm-arm26/proc-armv/rmap.h
- *
- * Architecture dependant parts of the reverse mapping code,
- *
- * ARM is different since hardware page tables are smaller than
- * the page size and Linux uses a "duplicate" one with extra info.
- * For rmap this means that the first 2 kB of a page are the hardware
- * page tables and the last 2 kB are the software page tables.
- */
-
-static inline void pgtable_add_rmap(struct page *page, struct mm_struct * mm, unsigned long address)
-{
- page->mapping = (void *)mm;
- page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
- inc_page_state(nr_page_table_pages);
-}
-
-static inline void pgtable_remove_rmap(struct page *page)
-{
- page->mapping = NULL;
- page->index = 0;
- dec_page_state(nr_page_table_pages);
-}
-
-static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
-{
- struct page * page = virt_to_page(ptep);
- return (struct mm_struct *)page->mapping;
-}
-
-/* The page table takes half of the page */
-#define PTE_MASK ((PAGE_SIZE / 2) - 1)
-
-static inline unsigned long ptep_to_address(pte_t * ptep)
-{
- struct page * page = virt_to_page(ptep);
- unsigned long low_bits;
-
- low_bits = ((unsigned long)ptep & PTE_MASK) * PTRS_PER_PTE;
- return page->index + low_bits;
-}
-
-//FIXME!!! IS these correct?
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
- return (pte_addr_t)ptep;
-}
-
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
- return (pte_t *)pte_paddr;
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
- return;
-}
-
-
-//#include <asm-generic/rmap.h>
-
-#endif /* _ARM_RMAP_H */
+++ /dev/null
-#ifndef _ASM_CRIS_CPUMASK_H
-#define _ASM_CRIS_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_CRIS_CPUMASK_H */
+++ /dev/null
-#ifndef _CRIS_RMAP_H
-#define _CRIS_RMAP_H
-
-/* nothing to see, move along :) */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_H
-#define __ASM_GENERIC_CPUMASK_H
-
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/threads.h>
-#include <linux/types.h>
-#include <linux/bitmap.h>
-
-#if NR_CPUS > BITS_PER_LONG && NR_CPUS != 1
-#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
-
-struct cpumask
-{
- unsigned long mask[CPU_ARRAY_SIZE];
-};
-
-typedef struct cpumask cpumask_t;
-
-#else
-typedef unsigned long cpumask_t;
-#endif
-
-#ifdef CONFIG_SMP
-#if NR_CPUS > BITS_PER_LONG
-#include <asm-generic/cpumask_array.h>
-#else
-#include <asm-generic/cpumask_arith.h>
-#endif
-#else
-#include <asm-generic/cpumask_up.h>
-#endif
-
-#if NR_CPUS <= 4*BITS_PER_LONG
-#include <asm-generic/cpumask_const_value.h>
-#else
-#include <asm-generic/cpumask_const_reference.h>
-#endif
-
-#endif /* __ASM_GENERIC_CPUMASK_H */
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_ARITH_H
-#define __ASM_GENERIC_CPUMASK_ARITH_H
-
-/*
- * Arithmetic type -based cpu bitmaps. A single unsigned long is used
- * to contain the whole cpu bitmap.
- */
-
-#define cpu_set(cpu, map) set_bit(cpu, &(map))
-#define cpu_clear(cpu, map) clear_bit(cpu, &(map))
-#define cpu_isset(cpu, map) test_bit(cpu, &(map))
-#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, &(map))
-
-#define cpus_and(dst,src1,src2) do { dst = (src1) & (src2); } while (0)
-#define cpus_or(dst,src1,src2) do { dst = (src1) | (src2); } while (0)
-#define cpus_clear(map) do { map = 0; } while (0)
-#define cpus_complement(map) do { map = ~(map); } while (0)
-#define cpus_equal(map1, map2) ((map1) == (map2))
-#define cpus_empty(map) ((map) == 0)
-#define cpus_addr(map) (&(map))
-
-#if BITS_PER_LONG == 32
-#define cpus_weight(map) hweight32(map)
-#elif BITS_PER_LONG == 64
-#define cpus_weight(map) hweight64(map)
-#endif
-
-#define cpus_shift_right(dst, src, n) do { dst = (src) >> (n); } while (0)
-#define cpus_shift_left(dst, src, n) do { dst = (src) << (n); } while (0)
-
-#define any_online_cpu(map) \
-({ \
- cpumask_t __tmp__; \
- cpus_and(__tmp__, map, cpu_online_map); \
- __tmp__ ? first_cpu(__tmp__) : NR_CPUS; \
-})
-
-#define CPU_MASK_ALL (~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS))
-#define CPU_MASK_NONE ((cpumask_t)0)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce(map) ((unsigned long)(map))
-#define cpus_promote(map) ({ map; })
-#define cpumask_of_cpu(cpu) ({ ((cpumask_t)1) << (cpu); })
-
-#define first_cpu(map) find_first_bit(&(map), NR_CPUS)
-#define next_cpu(cpu, map) find_next_bit(&(map), NR_CPUS, cpu + 1)
-
-#endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_ARRAY_H
-#define __ASM_GENERIC_CPUMASK_ARRAY_H
-
-/*
- * Array-based cpu bitmaps. An array of unsigned longs is used to contain
- * the bitmap, and then contained in a structure so it may be passed by
- * value.
- */
-
-#define CPU_ARRAY_SIZE BITS_TO_LONGS(NR_CPUS)
-
-#define cpu_set(cpu, map) set_bit(cpu, (map).mask)
-#define cpu_clear(cpu, map) clear_bit(cpu, (map).mask)
-#define cpu_isset(cpu, map) test_bit(cpu, (map).mask)
-#define cpu_test_and_set(cpu, map) test_and_set_bit(cpu, (map).mask)
-
-#define cpus_and(dst,src1,src2) bitmap_and((dst).mask,(src1).mask, (src2).mask, NR_CPUS)
-#define cpus_or(dst,src1,src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, NR_CPUS)
-#define cpus_clear(map) bitmap_zero((map).mask, NR_CPUS)
-#define cpus_complement(map) bitmap_complement((map).mask, NR_CPUS)
-#define cpus_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, NR_CPUS)
-#define cpus_empty(map) bitmap_empty(map.mask, NR_CPUS)
-#define cpus_addr(map) ((map).mask)
-#define cpus_weight(map) bitmap_weight((map).mask, NR_CPUS)
-#define cpus_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, NR_CPUS)
-#define cpus_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, NR_CPUS)
-#define first_cpu(map) find_first_bit((map).mask, NR_CPUS)
-#define next_cpu(cpu, map) find_next_bit((map).mask, NR_CPUS, cpu + 1)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce(map) ((map).mask[0])
-#define cpus_promote(map) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
- __cpu_mask.mask[0] = map; \
- __cpu_mask; \
- })
-#define cpumask_of_cpu(cpu) ({ cpumask_t __cpu_mask = CPU_MASK_NONE;\
- cpu_set(cpu, __cpu_mask); \
- __cpu_mask; \
- })
-#define any_online_cpu(map) \
-({ \
- cpumask_t __tmp__; \
- cpus_and(__tmp__, map, cpu_online_map); \
- find_first_bit(__tmp__.mask, NR_CPUS); \
-})
-
-
-/*
- * um, these need to be usable as static initializers
- */
-#define CPU_MASK_ALL ((cpumask_t) { {[0 ... CPU_ARRAY_SIZE-1] = ~0UL} })
-#define CPU_MASK_NONE ((cpumask_t) { {[0 ... CPU_ARRAY_SIZE-1] = 0UL} })
-
-#endif /* __ASM_GENERIC_CPUMASK_ARRAY_H */
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
-#define __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H
-
-struct cpumask_ref {
- const cpumask_t *val;
-};
-
-typedef const struct cpumask_ref cpumask_const_t;
-
-#define mk_cpumask_const(map) ((cpumask_const_t){ &(map) })
-#define cpu_isset_const(cpu, map) cpu_isset(cpu, *(map).val)
-
-#define cpus_and_const(dst,src1,src2) cpus_and(dst,*(src1).val,*(src2).val)
-#define cpus_or_const(dst,src1,src2) cpus_or(dst,*(src1).val,*(src2).val)
-
-#define cpus_equal_const(map1, map2) cpus_equal(*(map1).val, *(map2).val)
-
-#define cpus_copy_const(map1, map2) bitmap_copy((map1).mask, (map2).val->mask, NR_CPUS)
-
-#define cpus_empty_const(map) cpus_empty(*(map).val)
-#define cpus_weight_const(map) cpus_weight(*(map).val)
-#define first_cpu_const(map) first_cpu(*(map).val)
-#define next_cpu_const(cpu, map) next_cpu(cpu, *(map).val)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce_const(map) cpus_coerce(*(map).val)
-#define any_online_cpu_const(map) any_online_cpu(*(map).val)
-
-#endif /* __ASM_GENERIC_CPUMASK_CONST_REFERENCE_H */
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_CONST_VALUE_H
-#define __ASM_GENERIC_CPUMASK_CONST_VALUE_H
-
-typedef const cpumask_t cpumask_const_t;
-
-#define mk_cpumask_const(map) (map)
-#define cpu_isset_const(cpu, map) cpu_isset(cpu, map)
-#define cpus_and_const(dst,src1,src2) cpus_and(dst, src1, src2)
-#define cpus_or_const(dst,src1,src2) cpus_or(dst, src1, src2)
-#define cpus_equal_const(map1, map2) cpus_equal(map1, map2)
-#define cpus_empty_const(map) cpus_empty(map)
-#define cpus_copy_const(map1, map2) do { map1 = (cpumask_t)map2; } while (0)
-#define cpus_weight_const(map) cpus_weight(map)
-#define first_cpu_const(map) first_cpu(map)
-#define next_cpu_const(cpu, map) next_cpu(cpu, map)
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_coerce_const(map) cpus_coerce(map)
-#define any_online_cpu_const(map) any_online_cpu(map)
-
-#endif /* __ASM_GENERIC_CPUMASK_CONST_VALUE_H */
+++ /dev/null
-#ifndef __ASM_GENERIC_CPUMASK_UP_H
-#define __ASM_GENERIC_CPUMASK_UP_H
-
-#define cpus_coerce(map) (map)
-
-#define cpu_set(cpu, map) do { (void)(cpu); cpus_coerce(map) = 1UL; } while (0)
-#define cpu_clear(cpu, map) do { (void)(cpu); cpus_coerce(map) = 0UL; } while (0)
-#define cpu_isset(cpu, map) ((void)(cpu), cpus_coerce(map) != 0UL)
-#define cpu_test_and_set(cpu, map) ((void)(cpu), test_and_set_bit(0, &(map)))
-
-#define cpus_and(dst, src1, src2) \
- do { \
- if (cpus_coerce(src1) && cpus_coerce(src2)) \
- cpus_coerce(dst) = 1UL; \
- else \
- cpus_coerce(dst) = 0UL; \
- } while (0)
-
-#define cpus_or(dst, src1, src2) \
- do { \
- if (cpus_coerce(src1) || cpus_coerce(src2)) \
- cpus_coerce(dst) = 1UL; \
- else \
- cpus_coerce(dst) = 0UL; \
- } while (0)
-
-#define cpus_clear(map) do { cpus_coerce(map) = 0UL; } while (0)
-
-#define cpus_complement(map) \
- do { \
- cpus_coerce(map) = !cpus_coerce(map); \
- } while (0)
-
-#define cpus_equal(map1, map2) (cpus_coerce(map1) == cpus_coerce(map2))
-#define cpus_empty(map) (cpus_coerce(map) == 0UL)
-#define cpus_addr(map) (&(map))
-#define cpus_weight(map) (cpus_coerce(map) ? 1UL : 0UL)
-#define cpus_shift_right(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
-#define cpus_shift_left(d, s, n) do { cpus_coerce(d) = 0UL; } while (0)
-#define first_cpu(map) (cpus_coerce(map) ? 0 : 1)
-#define next_cpu(cpu, map) 1
-
-/* only ever use this for things that are _never_ used on large boxen */
-#define cpus_promote(map) \
- ({ \
- cpumask_t __tmp__; \
- cpus_coerce(__tmp__) = map; \
- __tmp__; \
- })
-#define cpumask_of_cpu(cpu) ((void)(cpu), cpus_promote(1))
-#define any_online_cpu(map) (cpus_coerce(map) ? 0 : 1)
-
-/*
- * um, these need to be usable as static initializers
- */
-#define CPU_MASK_ALL 1UL
-#define CPU_MASK_NONE 0UL
-
-#endif /* __ASM_GENERIC_CPUMASK_UP_H */
+++ /dev/null
-#ifndef _GENERIC_RMAP_H
-#define _GENERIC_RMAP_H
-/*
- * linux/include/asm-generic/rmap.h
- *
- * Architecture dependent parts of the reverse mapping code,
- * this version should work for most architectures with a
- * 'normal' page table layout.
- *
- * We use the struct page of the page table page to find out
- * the process and full address of a page table entry:
- * - page->mapping points to the process' mm_struct
- * - page->index has the high bits of the address
- * - the lower bits of the address are calculated from the
- * offset of the page table entry within the page table page
- *
- * For CONFIG_HIGHPTE, we need to represent the address of a pte in a
- * scalar pte_addr_t. The pfn of the pte's page is shifted left by PAGE_SIZE
- * bits and is then ORed with the byte offset of the pte within its page.
- *
- * For CONFIG_HIGHMEM4G, the pte_addr_t is 32 bits. 20 for the pfn, 12 for
- * the offset.
- *
- * For CONFIG_HIGHMEM64G, the pte_addr_t is 64 bits. 52 for the pfn, 12 for
- * the offset.
- */
-#include <linux/mm.h>
-
-static inline void pgtable_add_rmap(struct page * page, struct mm_struct * mm, unsigned long address)
-{
-#ifdef BROKEN_PPC_PTE_ALLOC_ONE
- /* OK, so PPC calls pte_alloc() before mem_map[] is setup ... ;( */
- extern int mem_init_done;
-
- if (!mem_init_done)
- return;
-#endif
- page->mapping = (void *)mm;
- page->index = address & ~((PTRS_PER_PTE * PAGE_SIZE) - 1);
- inc_page_state(nr_page_table_pages);
-}
-
-static inline void pgtable_remove_rmap(struct page * page)
-{
- page->mapping = NULL;
- page->index = 0;
- dec_page_state(nr_page_table_pages);
-}
-
-static inline struct mm_struct * ptep_to_mm(pte_t * ptep)
-{
- struct page * page = kmap_atomic_to_page(ptep);
- return (struct mm_struct *) page->mapping;
-}
-
-static inline unsigned long ptep_to_address(pte_t * ptep)
-{
- struct page * page = kmap_atomic_to_page(ptep);
- unsigned long low_bits;
- low_bits = ((unsigned long)ptep & (PTRS_PER_PTE*sizeof(pte_t) - 1))
- * (PAGE_SIZE/sizeof(pte_t));
- return page->index + low_bits;
-}
-
-#ifdef CONFIG_HIGHPTE
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
- pte_addr_t paddr;
- paddr = ((pte_addr_t)page_to_pfn(kmap_atomic_to_page(ptep))) << PAGE_SHIFT;
- return paddr + (pte_addr_t)((unsigned long)ptep & ~PAGE_MASK);
-}
-#else
-static inline pte_addr_t ptep_to_paddr(pte_t *ptep)
-{
- return (pte_addr_t)ptep;
-}
-#endif
-
-#ifndef CONFIG_HIGHPTE
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
- return (pte_t *)pte_paddr;
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
- return;
-}
-#endif
-
-#endif /* _GENERIC_RMAP_H */
+++ /dev/null
-/* AE-3068 board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 20000*10/8192
-#define H8300_TIMER_FREQ 20000*1000/8192
-#endif
-
-/* AE-3068 RTL8019AS Config */
-#ifdef H8300_NE_DEFINE
-
-#define NE2000_ADDR 0x200000
-#define NE2000_IRQ 5
-#define NE2000_BYTE volatile unsigned short
-
-#define WCRL 0xfee023
-#define MAR0A 0xffff20
-#define ETCR0A 0xffff24
-#define DTCR0A 0xffff27
-#define MAR0B 0xffff28
-#define DTCR0B 0xffff2f
-
-#define H8300_INIT_NE() \
-do { \
- wordlength = 1; \
- outb_p(0x48, ioaddr + EN0_DCFG); \
-} while(0)
-
-#endif
+++ /dev/null
-#ifndef _ASM_H8300_CPUMASK_H
-#define _ASM_H8300_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_H8300_CPUMASK_H */
+++ /dev/null
-/* EDOSK2674 board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 33000*10/8192
-#define H8300_TIMER_FREQ 33000*1000/8192
-#endif
-
-/* EDOSK-2674R SMSC Network Controler Target Depend impliments */
-#ifdef H8300_SMSC_DEFINE
-
-#define SMSC_BASE 0xf80000
-#define SMSC_IRQ 16
-
-/* sorry quick hack */
-#if defined(outw)
-# undef outw
-#endif
-#define outw(d,a) edosk2674_smsc_outw(d,(volatile unsigned short *)(a))
-#if defined(inw)
-# undef inw
-#endif
-#define inw(a) edosk2674_smsc_inw((volatile unsigned short *)(a))
-#if defined(outsw)
-# undef outsw
-#endif
-#define outsw(a,p,l) edosk2674_smsc_outsw((volatile unsigned short *)(a),p,l)
-#if defined(insw)
-# undef insw
-#endif
-#define insw(a,p,l) edosk2674_smsc_insw((volatile unsigned short *)(a),p,l)
-
-static inline void edosk2674_smsc_outw(
- unsigned short d,
- volatile unsigned short *a
- )
-{
- *a = (d >> 8) | (d << 8);
-}
-
-static inline unsigned short edosk2674_smsc_inw(
- volatile unsigned short *a
- )
-{
- unsigned short d;
- d = *a;
- return (d >> 8) | (d << 8);
-}
-
-static inline void edosk2674_smsc_outsw(
- volatile unsigned short *a,
- unsigned short *p,
- unsigned long l
- )
-{
- for (; l != 0; --l, p++)
- *a = *p;
-}
-
-static inline void edosk2674_smsc_insw(
- volatile unsigned short *a,
- unsigned short *p,
- unsigned long l
- )
-{
- for (; l != 0; --l, p++)
- *p = *a;
-}
-
-#endif
+++ /dev/null
-/* machine depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#include <linux/config.h>
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068) || defined(CONFIG_H8S2678)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
-#endif
-
-#if defined(CONFIG_H8_3002) || defined(CONFIG_H83048)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8
-#endif
-
-#endif
-
+++ /dev/null
-#include <linux/config.h>
-
-#if defined(CONFIG_H83007) || defined(CONFIG_H83068) || defined(CONFIG_H8S2678)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8192
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8192
-#endif
-
-#if defined(H8_3002) || defined(CONFIG_H83048)
-#define H8300_TIMER_COUNT_DATA CONFIG_CPU_CLOCK*10/8
-#define H8300_TIMER_FREQ CONFIG_CPU_CLOCK*1000/8
-#endif
-
-#if !defined(H8300_TIMER_COUNT_DATA)
-#error illigal configuration
-#endif
+++ /dev/null
-/****************************************************************************/
-
-/*
- * h8300_ne.h -- NE2000 in H8/300H Evalution Board.
- *
- * (C) Copyright 2002, Yoshinori Sato <ysato@users.sourceforge.jp>
- */
-
-/****************************************************************************/
-#ifndef h8300ne_h
-#define h8300ne_h
-/****************************************************************************/
-
-#define H8300_NE_DEFINE
-#include <asm/machine-depend.h>
-#define NE2000_IRQ_VECTOR (12 + NE2000_IRQ)
-#undef H8300_NE_DEFINE
-
-/****************************************************************************/
-#endif /* h8300ne_h */
+++ /dev/null
-/****************************************************************************/
-
-/*
- * h8300_smsc.h -- SMSC in H8/300H and H8S Evalution Board.
- *
- * (C) Copyright 2003, Yoshinori Sato <ysato@users.sourceforge.jp>
- */
-
-/****************************************************************************/
-#ifndef h8300smsc_h
-#define h8300smsc_h
-/****************************************************************************/
-
-/* Such a description is OK ? */
-#define H8300_SMSC_DEFINE
-#include <asm/machine-depend.h>
-#undef H8300_SMSC_DEFINE
-
-/****************************************************************************/
-#endif /* h8300smsc_h */
+++ /dev/null
-/* H8MAX board depend header */
-
-/* TIMER rate define */
-#ifdef H8300_TIMER_DEFINE
-#define H8300_TIMER_COUNT_DATA 25000*10/8192
-#define H8300_TIMER_FREQ 25000*1000/8192
-#endif
-
-/* H8MAX RTL8019AS Config */
-#ifdef H8300_NE_DEFINE
-
-#define NE2000_ADDR 0x800600
-#define NE2000_IRQ 4
-#define NE2000_IRQ_VECTOR (12 + NE2000_IRQ)
-#define NE2000_BYTE volatile unsigned short
-
-/* sorry quick hack */
-#if defined(outb)
-# undef outb
-#endif
-#define outb(d,a) h8max_outb((d),(a) - NE2000_ADDR)
-#if defined(inb)
-# undef inb
-#endif
-#define inb(a) h8max_inb((a) - NE2000_ADDR)
-#if defined(outb_p)
-# undef outb_p
-#endif
-#define outb_p(d,a) h8max_outb((d),(a) - NE2000_ADDR)
-#if defined(inb_p)
-# undef inb_p
-#endif
-#define inb_p(a) h8max_inb((a) - NE2000_ADDR)
-#if defined(outsw)
-# undef outsw
-#endif
-#define outsw(a,p,l) h8max_outsw((a) - NE2000_ADDR,(unsigned short *)p,l)
-#if defined(insw)
-# undef insw
-#endif
-#define insw(a,p,l) h8max_insw((a) - NE2000_ADDR,(unsigned short *)p,l)
-#if defined(outsb)
-# undef outsb
-#endif
-#define outsb(a,p,l) h8max_outsb((a) - NE2000_ADDR,(unsigned char *)p,l)
-#if defined(insb)
-# undef insb
-#endif
-#define insb(a,p,l) h8max_insb((a) - NE2000_ADDR,(unsigned char *)p,l)
-
-#define H8300_INIT_NE() \
-do { \
- wordlength = 2; \
- h8max_outb(0x49, ioaddr + EN0_DCFG); \
- SA_prom[14] = SA_prom[15] = 0x57;\
-} while(0)
-
-static inline void h8max_outb(unsigned char d,unsigned char a)
-{
- *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
-}
-
-static inline unsigned char h8max_inb(unsigned char a)
-{
- return *(unsigned char *)(NE2000_ADDR + (a << 1) +1);
-}
-
-static inline void h8max_outsw(unsigned char a,unsigned short *p,unsigned long l)
-{
- unsigned short d;
- for (; l != 0; --l, p++) {
- d = (((*p) >> 8) & 0xff) | ((*p) << 8);
- *(unsigned short *)(NE2000_ADDR + (a << 1)) = d;
- }
-}
-
-static inline void h8max_insw(unsigned char a,unsigned short *p,unsigned long l)
-{
- unsigned short d;
- for (; l != 0; --l, p++) {
- d = *(unsigned short *)(NE2000_ADDR + (a << 1));
- *p = (d << 8)|((d >> 8) & 0xff);
- }
-}
-
-static inline void h8max_outsb(unsigned char a,unsigned char *p,unsigned long l)
-{
- for (; l != 0; --l, p++) {
- *(unsigned short *)(NE2000_ADDR + (a << 1)) = *p;
- }
-}
-
-static inline void h8max_insb(unsigned char a,unsigned char *p,unsigned long l)
-{
- for (; l != 0; --l, p++) {
- *p = *((unsigned char *)(NE2000_ADDR + (a << 1))+1);
- }
-}
-
-#endif
+++ /dev/null
-#ifndef _H8300_INIT_H
-#define _H8300_INIT_H
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-/* For assembly routines */
-#define __INIT .section ".text.init",#alloc,#execinstr
-#define __FINIT .previous
-#define __INITDATA .section ".data.init",#alloc,#write
-
-#endif
+++ /dev/null
-#ifndef __ASM_SOFTIRQ_H
-#define __ASM_SOFTIRQ_H
-
-#include <linux/preempt.h>
-#include <asm/hardirq.h>
-
-#define local_bh_disable() \
- do { preempt_count() += SOFTIRQ_OFFSET; barrier(); } while (0)
-#define __local_bh_enable() \
- do { barrier(); preempt_count() -= SOFTIRQ_OFFSET; } while (0)
-
-#define local_bh_enable() \
-do { \
- __local_bh_enable(); \
- if (unlikely(!in_interrupt() && softirq_pending(smp_processor_id()))) \
- do_softirq(); \
- preempt_check_resched(); \
-} while (0)
-
-#endif /* __ASM_SOFTIRQ_H */
+++ /dev/null
-#ifndef _ASM_I386_CPUMASK_H
-#define _ASM_I386_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_I386_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-/*
- * include/asm-i386/mach-pc9800/apm.h
- *
- * Machine specific APM BIOS functions for NEC PC9800.
- * Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
- */
-
-#ifndef _ASM_APM_H
-#define _ASM_APM_H
-
-#include <linux/apm_bios.h>
-
-#ifdef APM_ZERO_SEGS
-# define APM_DO_ZERO_SEGS \
- "pushl %%ds\n\t" \
- "pushl %%es\n\t" \
- "xorl %%edx, %%edx\n\t" \
- "mov %%dx, %%ds\n\t" \
- "mov %%dx, %%es\n\t" \
- "mov %%dx, %%fs\n\t" \
- "mov %%dx, %%gs\n\t"
-# define APM_DO_POP_SEGS \
- "popl %%es\n\t" \
- "popl %%ds\n\t"
-#else
-# define APM_DO_ZERO_SEGS
-# define APM_DO_POP_SEGS
-#endif
-
-static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
- u32 *eax, u32 *ebx, u32 *ecx,
- u32 *edx, u32 *esi)
-{
- /*
- * N.B. We do NOT need a cld after the BIOS call
- * because we always save and restore the flags.
- */
- __asm__ __volatile__(APM_DO_ZERO_SEGS
- "pushl %%edi\n\t"
- "pushl %%ebp\n\t"
- "pushfl\n\t"
- "lcall *%%cs:apm_bios_entry\n\t"
- "setc %%al\n\t"
- "popl %%ebp\n\t"
- "popl %%edi\n\t"
- APM_DO_POP_SEGS
- : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx),
- "=S" (*esi)
- : "a" (func), "b" (ebx_in), "c" (ecx_in)
- : "memory", "cc");
-}
-
-static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
- u32 ecx_in, u32 *eax)
-{
- int cx, dx, si;
- u8 error;
-
- /*
- * N.B. We do NOT need a cld after the BIOS call
- * because we always save and restore the flags.
- */
- __asm__ __volatile__(APM_DO_ZERO_SEGS
- "pushl %%edi\n\t"
- "pushl %%ebp\n\t"
- "pushfl\n\t"
- "lcall *%%cs:apm_bios_entry\n\t"
- "setc %%bl\n\t"
- "popl %%ebp\n\t"
- "popl %%edi\n\t"
- APM_DO_POP_SEGS
- : "=a" (*eax), "=b" (error), "=c" (cx), "=d" (dx),
- "=S" (si)
- : "a" (func), "b" (ebx_in), "c" (ecx_in)
- : "memory", "cc");
- if (func == APM_FUNC_VERSION)
- *eax = (*eax & 0xff00) | ((*eax & 0x00f0) >> 4);
-
- return error;
-}
-
-#endif /* _ASM_APM_H */
+++ /dev/null
-#ifndef _MACH_BIOS_EBDA_H
-#define _MACH_BIOS_EBDA_H
-
-/*
- * PC-9800 has no EBDA.
- * Its BIOS uses 0x40E for other purpose,
- * Not pointer to 4K EBDA area.
- */
-static inline unsigned int get_bios_ebda(void)
-{
- return 0; /* 0 means none */
-}
-
-#endif /* _MACH_BIOS_EBDA_H */
+++ /dev/null
-/* defines for inline arch setup functions */
-
-#include <asm/apic.h>
-
-/**
- * do_timer_interrupt_hook - hook into timer tick
- * @regs: standard registers from interrupt
- *
- * Description:
- * This hook is called immediately after the timer interrupt is ack'd.
- * It's primary purpose is to allow architectures that don't possess
- * individual per CPU clocks (like the CPU APICs supply) to broadcast the
- * timer interrupt as a means of triggering reschedules etc.
- **/
-
-static inline void do_timer_interrupt_hook(struct pt_regs *regs)
-{
- do_timer(regs);
-/*
- * In the SMP case we use the local APIC timer interrupt to do the
- * profiling, except when we simulate SMP mode on a uniprocessor
- * system, in that case we have to call the local interrupt handler.
- */
-#ifndef CONFIG_X86_LOCAL_APIC
- x86_do_profile(regs);
-#else
- if (!using_apic_timer)
- smp_local_timer_interrupt(regs);
-#endif
-}
-
-
-/* you can safely undefine this if you don't have the Neptune chipset */
-
-#define BUGGY_NEPTUN_TIMER
-
-/**
- * do_timer_overflow - process a detected timer overflow condition
- * @count: hardware timer interrupt count on overflow
- *
- * Description:
- * This call is invoked when the jiffies count has not incremented but
- * the hardware timer interrupt has. It means that a timer tick interrupt
- * came along while the previous one was pending, thus a tick was missed
- **/
-static inline int do_timer_overflow(int count)
-{
- int i;
-
- spin_lock(&i8259A_lock);
- /*
- * This is tricky when I/O APICs are used;
- * see do_timer_interrupt().
- */
- i = inb(0x00);
- spin_unlock(&i8259A_lock);
-
- /* assumption about timer being IRQ0 */
- if (i & 0x01) {
- /*
- * We cannot detect lost timer interrupts ...
- * well, that's why we call them lost, don't we? :)
- * [hmm, on the Pentium and Alpha we can ... sort of]
- */
- count -= LATCH;
- } else {
-#ifdef BUGGY_NEPTUN_TIMER
- /*
- * for the Neptun bug we know that the 'latch'
- * command doesn't latch the high and low value
- * of the counter atomically. Thus we have to
- * substract 256 from the counter
- * ... funny, isnt it? :)
- */
-
- count -= 256;
-#else
- printk("do_slow_gettimeoffset(): hardware timer problem?\n");
-#endif
- }
- return count;
-}
+++ /dev/null
-/*
- * arch/i386/mach-pc9800/io_ports.h
- *
- * Machine specific IO port address definition for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_IO_PORTS_H
-#define _MACH_IO_PORTS_H
-
-/* i8253A PIT registers */
-#define PIT_MODE 0x77
-#define PIT_CH0 0x71
-#define PIT_CH2 0x75
-
-/* i8259A PIC registers */
-#define PIC_MASTER_CMD 0x00
-#define PIC_MASTER_IMR 0x02
-#define PIC_MASTER_ISR PIC_MASTER_CMD
-#define PIC_MASTER_POLL PIC_MASTER_ISR
-#define PIC_MASTER_OCW3 PIC_MASTER_ISR
-#define PIC_SLAVE_CMD 0x08
-#define PIC_SLAVE_IMR 0x0a
-
-/* i8259A PIC related values */
-#define PIC_CASCADE_IR 7
-#define MASTER_ICW4_DEFAULT 0x1d
-#define SLAVE_ICW4_DEFAULT 0x09
-#define PIC_ICW4_AEOI 0x02
-
-#endif /* !_MACH_IO_PORTS_H */
+++ /dev/null
-/*
- * This file should contain #defines for all of the interrupt vector
- * numbers used by this architecture.
- *
- * In addition, there are some standard defines:
- *
- * FIRST_EXTERNAL_VECTOR:
- * The first free place for external interrupts
- *
- * SYSCALL_VECTOR:
- * The IRQ vector a syscall makes the user to kernel transition
- * under.
- *
- * TIMER_IRQ:
- * The IRQ number the timer interrupt comes in at.
- *
- * NR_IRQS:
- * The total number of interrupt vectors (including all the
- * architecture specific interrupts) needed.
- *
- * NR_IRQ_VECTORS:
- * The total number of IO APIC vector inputs
- *
- */
-#ifndef _ASM_IRQ_VECTORS_H
-#define _ASM_IRQ_VECTORS_H
-
-/*
- * IDT vectors usable for external interrupt sources start
- * at 0x20:
- */
-#define FIRST_EXTERNAL_VECTOR 0x20
-
-#define SYSCALL_VECTOR 0x80
-
-/*
- * Vectors 0x20-0x2f are used for ISA interrupts.
- */
-
-/*
- * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
- *
- * some of the following vectors are 'rare', they are merged
- * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
- * TLB, reschedule and local APIC vectors are performance-critical.
- *
- * Vectors 0xf0-0xfa are free (reserved for future Linux use).
- */
-#define SPURIOUS_APIC_VECTOR 0xff
-#define ERROR_APIC_VECTOR 0xfe
-#define INVALIDATE_TLB_VECTOR 0xfd
-#define RESCHEDULE_VECTOR 0xfc
-#define CALL_FUNCTION_VECTOR 0xfb
-
-#define THERMAL_APIC_VECTOR 0xf0
-/*
- * Local APIC timer IRQ vector is on a different priority level,
- * to work around the 'lost local interrupt if more than 2 IRQ
- * sources per level' errata.
- */
-#define LOCAL_TIMER_VECTOR 0xef
-
-/*
- * First APIC vector available to drivers: (vectors 0x30-0xee)
- * we start at 0x31 to spread out vectors evenly between priority
- * levels. (0x80 is the syscall vector)
- */
-#define FIRST_DEVICE_VECTOR 0x31
-#define FIRST_SYSTEM_VECTOR 0xef
-
-#define TIMER_IRQ 0
-
-/*
- * 16 8259A IRQ's, 208 potential APIC interrupt sources.
- * Right now the APIC is mostly only used for SMP.
- * 256 vectors is an architectural limit. (we can have
- * more than 256 devices theoretically, but they will
- * have to use shared interrupts)
- * Since vectors 0x00-0x1f are used/reserved for the CPU,
- * the usable vector space is 0x20-0xff (224 vectors)
- */
-#ifdef CONFIG_X86_IO_APIC
-#define NR_IRQS 224
-#else
-#define NR_IRQS 16
-#endif
-
-#define NR_VECTORS 256
-#define NR_IRQ_VECTORS NR_IRQS
-
-#define FPU_IRQ 8
-
-#define FIRST_VM86_IRQ 2
-#define LAST_VM86_IRQ 15
-#define invalid_vm86_irq(irq) ((irq) < 2 || (irq) == 7 || (irq) > 15)
-
-#endif /* _ASM_IRQ_VECTORS_H */
-
-
+++ /dev/null
-/*
- * arch/i386/mach-pc9800/mach_reboot.h
- *
- * Machine specific reboot functions for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_REBOOT_H
-#define _MACH_REBOOT_H
-
-#ifdef CMOS_WRITE
-#undef CMOS_WRITE
-#define CMOS_WRITE(a,b) do{}while(0)
-#endif
-
-static inline void mach_reboot(void)
-{
- outb(0, 0xf0); /* signal CPU reset */
- mdelay(1);
-}
-
-#endif /* !_MACH_REBOOT_H */
+++ /dev/null
-/*
- * include/asm-i386/mach-pc9800/mach_time.h
- *
- * Machine specific set RTC function for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_TIME_H
-#define _MACH_TIME_H
-
-#include <linux/bcd.h>
-#include <linux/upd4990a.h>
-
-/* for check timing call set_rtc_mmss() */
-/* used in arch/i386/time.c::do_timer_interrupt() */
-/*
- * Because PC-9800's RTC (NEC uPD4990A) does not allow setting
- * time partially, we always have to read-modify-write the
- * entire time (including year) so that set_rtc_mmss() will
- * take quite much time to execute. You may want to relax
- * RTC resetting interval (currently ~11 minuts)...
- */
-#define USEC_AFTER 1000000
-#define USEC_BEFORE 0
-
-static inline int mach_set_rtc_mmss(unsigned long nowtime)
-{
- int retval = 0;
- int real_seconds, real_minutes, cmos_minutes;
- struct upd4990a_raw_data data;
-
- upd4990a_get_time(&data, 1);
- cmos_minutes = BCD2BIN(data.min);
-
- /*
- * since we're only adjusting minutes and seconds,
- * don't interfere with hour overflow. This avoids
- * messing with unknown time zones but requires your
- * RTC not to be off by more than 15 minutes
- */
- real_seconds = nowtime % 60;
- real_minutes = nowtime / 60;
- if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
- real_minutes += 30; /* correct for half hour time zone */
- real_minutes %= 60;
-
- if (abs(real_minutes - cmos_minutes) < 30) {
- u8 temp_seconds = (real_seconds / 10) * 16 + real_seconds % 10;
- u8 temp_minutes = (real_minutes / 10) * 16 + real_minutes % 10;
-
- if (data.sec != temp_seconds || data.min != temp_minutes) {
- data.sec = temp_seconds;
- data.min = temp_minutes;
- upd4990a_set_time(&data, 1);
- }
- } else {
- printk(KERN_WARNING
- "set_rtc_mmss: can't update from %d to %d\n",
- cmos_minutes, real_minutes);
- retval = -1;
- }
-
- /* uPD4990A users' manual says we should issue Register Hold
- * command after reading time, or future Time Read command
- * may not work. When we have set the time, this also starts
- * the clock.
- */
- upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-
- return retval;
-}
-
-static inline unsigned long mach_get_cmos_time(void)
-{
- int i;
- u8 prev, cur;
- unsigned int year;
- struct upd4990a_raw_data data;
-
- /* Connect uPD4990A's DATA OUT pin to its 1Hz reference clock. */
- upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-
- /* Catch rising edge of reference clock. */
- prev = ~UPD4990A_READ_DATA();
- for (i = 0; i < 1800000; i++) { /* may take up to 1 second... */
- __asm__ ("outb %%al,%0" : : "N" (0x5f)); /* 0.6usec delay */
- cur = UPD4990A_READ_DATA();
- if (!(prev & cur & 1))
- break;
- prev = ~cur;
- }
-
- upd4990a_get_time(&data, 0);
-
- if ((year = BCD2BIN(data.year) + 1900) < 1995)
- year += 100;
- return mktime(year, data.mon, BCD2BIN(data.mday), BCD2BIN(data.hour),
- BCD2BIN(data.min), BCD2BIN(data.sec));
-}
-
-#endif /* !_MACH_TIME_H */
+++ /dev/null
-/*
- * include/asm-i386/mach-pc9800/mach_timer.h
- *
- * Machine specific calibrate_tsc() for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-/* ------ Calibrate the TSC -------
- * PC-9800:
- * CTC cannot be used because some models (especially
- * note-machines) may disable clock to speaker channel (#1)
- * unless speaker is enabled. We use ARTIC instead.
- */
-#ifndef _MACH_TIMER_H
-#define _MACH_TIMER_H
-
-#define CALIBRATE_LATCH (5 * 307200/HZ) /* 0.050sec * 307200Hz = 15360 */
-
-static inline void mach_prepare_counter(void)
-{
- /* ARTIC can't be stopped nor reset. So we wait roundup. */
- while (inw(0x5c));
-}
-
-static inline void mach_countup(unsigned long *count)
-{
- do {
- *count = inw(0x5c);
- } while (*count < CALIBRATE_LATCH);
-}
-
-#endif /* !_MACH_TIMER_H */
+++ /dev/null
-/*
- * include/asm-i386/mach-pc9800/mach_traps.h
- *
- * Machine specific NMI handling for PC-9800.
- * Written by Osamu Tomita <tomita@cinet.co.jp>
- */
-#ifndef _MACH_TRAPS_H
-#define _MACH_TRAPS_H
-
-static inline void clear_mem_error(unsigned char reason)
-{
- outb(0x08, 0x37);
- outb(0x09, 0x37);
-}
-
-static inline unsigned char get_nmi_reason(void)
-{
- return (inb(0x33) & 6) ? 0x80 : 0;
-}
-
-static inline void reassert_nmi(void)
-{
- outb(0x09, 0x50); /* disable NMI once */
- outb(0x09, 0x52); /* re-enable it */
-}
-
-#endif /* !_MACH_TRAPS_H */
+++ /dev/null
-#ifndef __ASM_MACH_WAKECPU_H
-#define __ASM_MACH_WAKECPU_H
-
-/*
- * This file copes with machines that wakeup secondary CPUs by the
- * INIT, INIT, STARTUP sequence.
- */
-
-#define WAKE_SECONDARY_VIA_INIT
-
-/*
- * On PC-9800, continuation on warm reset is done by loading
- * %ss:%sp from 0x0000:0404 and executing 'lret', so:
- */
-#define TRAMPOLINE_LOW phys_to_virt(0x4fa)
-#define TRAMPOLINE_HIGH phys_to_virt(0x4fc)
-
-#define boot_cpu_apicid boot_cpu_physical_apicid
-
-static inline void wait_for_init_deassert(atomic_t *deassert)
-{
- while (!atomic_read(deassert));
- return;
-}
-
-/* Nothing to do for most platforms, since cleared by the INIT cycle */
-static inline void smp_callin_clear_local_apic(void)
-{
-}
-
-static inline void store_NMI_vector(unsigned short *high, unsigned short *low)
-{
-}
-
-static inline void restore_NMI_vector(unsigned short *high, unsigned short *low)
-{
-}
-
-#if APIC_DEBUG
- #define inquire_remote_apic(apicid) __inquire_remote_apic(apicid)
-#else
- #define inquire_remote_apic(apicid) {}
-#endif
-
-#endif /* __ASM_MACH_WAKECPU_H */
+++ /dev/null
-/*
- * PCI BIOS function codes for the PC9800. Different to
- * standard PC systems
- */
-
-/* Note: PC-9800 confirms PCI 2.1 on only few models */
-
-#define PCIBIOS_PCI_FUNCTION_ID 0xccXX
-#define PCIBIOS_PCI_BIOS_PRESENT 0xcc81
-#define PCIBIOS_FIND_PCI_DEVICE 0xcc82
-#define PCIBIOS_FIND_PCI_CLASS_CODE 0xcc83
-/* PCIBIOS_GENERATE_SPECIAL_CYCLE 0xcc86 (not supported by bios) */
-#define PCIBIOS_READ_CONFIG_BYTE 0xcc88
-#define PCIBIOS_READ_CONFIG_WORD 0xcc89
-#define PCIBIOS_READ_CONFIG_DWORD 0xcc8a
-#define PCIBIOS_WRITE_CONFIG_BYTE 0xcc8b
-#define PCIBIOS_WRITE_CONFIG_WORD 0xcc8c
-#define PCIBIOS_WRITE_CONFIG_DWORD 0xcc8d
-#define PCIBIOS_GET_ROUTING_OPTIONS 0xcc8e /* PCI 2.1 only */
-#define PCIBIOS_SET_PCI_HW_INT 0xcc8f /* PCI 2.1 only */
+++ /dev/null
-/**
- * machine_specific_memory_setup - Hook for machine specific memory setup.
- *
- * Description:
- * This is included late in kernel/setup.c so that it can make
- * use of all of the static functions.
- **/
-
-static inline char * __init machine_specific_memory_setup(void)
-{
- char *who;
- unsigned long low_mem_size, lower_high, higher_high;
-
-
- who = "BIOS (common area)";
-
- low_mem_size = ((*(unsigned char *)__va(PC9800SCA_BIOS_FLAG) & 7) + 1) << 17;
- add_memory_region(0, low_mem_size, 1);
- lower_high = (__u32) *(__u8 *) bus_to_virt(PC9800SCA_EXPMMSZ) << 17;
- higher_high = (__u32) *(__u16 *) bus_to_virt(PC9800SCA_MMSZ16M) << 20;
- if (lower_high != 0x00f00000UL) {
- add_memory_region(HIGH_MEMORY, lower_high, 1);
- add_memory_region(0x01000000UL, higher_high, 1);
- }
- else
- add_memory_region(HIGH_MEMORY, lower_high + higher_high, 1);
-
- return who;
-}
+++ /dev/null
-/* Hook to call BIOS initialisation function */
-
-/* no action for generic */
-
-#define ARCH_SETUP arch_setup_pc9800();
-
-#include <linux/timex.h>
-#include <asm/io.h>
-#include <asm/pc9800.h>
-#include <asm/pc9800_sca.h>
-
-int CLOCK_TICK_RATE;
-extern unsigned long tick_usec; /* ACTHZ period (usec) */
-extern unsigned long tick_nsec; /* USER_HZ period (nsec) */
-unsigned char pc9800_misc_flags;
-/* (bit 0) 1:High Address Video ram exists 0:otherwise */
-
-#ifdef CONFIG_SMP
-#define MPC_TABLE_SIZE 512
-#define MPC_TABLE ((char *) (PARAM+0x400))
-char mpc_table[MPC_TABLE_SIZE];
-#endif
-
-static inline void arch_setup_pc9800(void)
-{
- CLOCK_TICK_RATE = PC9800_8MHz_P() ? 1996800 : 2457600;
- printk(KERN_DEBUG "CLOCK_TICK_RATE = %d\n", CLOCK_TICK_RATE);
- tick_usec = TICK_USEC; /* USER_HZ period (usec) */
- tick_nsec = TICK_NSEC; /* ACTHZ period (nsec) */
-
- pc9800_misc_flags = PC9800_MISC_FLAGS;
-#ifdef CONFIG_SMP
- if ((*(u32 *)(MPC_TABLE)) == 0x504d4350)
- memcpy(mpc_table, MPC_TABLE, *(u16 *)(MPC_TABLE + 4));
-#endif /* CONFIG_SMP */
-}
+++ /dev/null
-/* two abstractions specific to kernel/smpboot.c, mainly to cater to visws
- * which needs to alter them. */
-
-static inline void smpboot_clear_io_apic_irqs(void)
-{
- io_apic_irqs = 0;
-}
-
-static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
-{
- /* reset code is stored in 8255 on PC-9800. */
- outb(0x0e, 0x37); /* SHUT0 = 0 */
- local_flush_tlb();
- Dprintk("1.\n");
- *((volatile unsigned short *) TRAMPOLINE_HIGH) = start_eip >> 4;
- Dprintk("2.\n");
- *((volatile unsigned short *) TRAMPOLINE_LOW) = start_eip & 0xf;
- Dprintk("3.\n");
- /*
- * On PC-9800, continuation on warm reset is done by loading
- * %ss:%sp from 0x0000:0404 and executing 'lret', so:
- */
- /* 0x3f0 is on unused interrupt vector and should be safe... */
- *((volatile unsigned long *) phys_to_virt(0x404)) = 0x000003f0;
- Dprintk("4.\n");
-}
-
-static inline void smpboot_restore_warm_reset_vector(void)
-{
- /*
- * Install writable page 0 entry to set BIOS data area.
- */
- local_flush_tlb();
-
- /*
- * Paranoid: Set warm reset code and vector here back
- * to default values.
- */
- outb(0x0f, 0x37); /* SHUT0 = 1 */
-
- *((volatile long *) phys_to_virt(0x404)) = 0;
-}
-
-static inline void smpboot_setup_io_apic(void)
-{
- /*
- * Here we can be sure that there is an IO-APIC in the system. Let's
- * go and set it up:
- */
- if (!skip_ioapic_setup && nr_ioapics)
- setup_IO_APIC();
-}
+++ /dev/null
-/*
- * PC-9800 machine types.
- *
- * Copyright (C) 1999 TAKAI Kosuke <tak@kmc.kyoto-u.ac.jp>
- * (Linux/98 Project)
- */
-
-#ifndef _ASM_PC9800_H_
-#define _ASM_PC9800_H_
-
-#include <asm/pc9800_sca.h>
-#include <asm/types.h>
-
-#define __PC9800SCA(type, pa) (*(type *) phys_to_virt(pa))
-#define __PC9800SCA_TEST_BIT(pa, n) \
- ((__PC9800SCA(u8, pa) & (1U << (n))) != 0)
-
-#define PC9800_HIGHRESO_P() __PC9800SCA_TEST_BIT(PC9800SCA_BIOS_FLAG, 3)
-#define PC9800_8MHz_P() __PC9800SCA_TEST_BIT(PC9800SCA_BIOS_FLAG, 7)
-
- /* 0x2198 is 98 21 on memory... */
-#define PC9800_9821_P() (__PC9800SCA(u16, PC9821SCA_ROM_ID) == 0x2198)
-
-/* Note PC9821_...() are valid only when PC9800_9821_P() was true. */
-#define PC9821_IDEIF_DOUBLE_P() __PC9800SCA_TEST_BIT(PC9821SCA_ROM_FLAG4, 4)
-
-#endif
+++ /dev/null
-/*
- * System-common area definitions for NEC PC-9800 series
- *
- * Copyright (C) 1999 TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>,
- * Kyoto University Microcomputer Club.
- */
-
-#ifndef _ASM_I386_PC9800SCA_H_
-#define _ASM_I386_PC9800SCA_H_
-
-#define PC9800SCA_EXPMMSZ (0x0401) /* B */
-#define PC9800SCA_SCSI_PARAMS (0x0460) /* 8 * 4B */
-#define PC9800SCA_DISK_EQUIPS (0x0482) /* B */
-#define PC9800SCA_XROM_ID (0x04C0) /* 52B */
-#define PC9800SCA_BIOS_FLAG (0x0501) /* B */
-#define PC9800SCA_MMSZ16M (0x0594) /* W */
-
-/* PC-9821 have additional system common area in their BIOS-ROM segment. */
-
-#define PC9821SCA__BASE (0xF8E8 << 4)
-#define PC9821SCA_ROM_ID (PC9821SCA__BASE + 0x00)
-#define PC9821SCA_ROM_FLAG4 (PC9821SCA__BASE + 0x05)
-#define PC9821SCA_RSFLAGS (PC9821SCA__BASE + 0x11) /* B */
-
-#endif /* !_ASM_I386_PC9800SCA_H_ */
+++ /dev/null
-#ifndef _I386_RMAP_H
-#define _I386_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#ifdef CONFIG_HIGHPTE
-static inline pte_t *rmap_ptep_map(pte_addr_t pte_paddr)
-{
- unsigned long pfn = (unsigned long)(pte_paddr >> PAGE_SHIFT);
- unsigned long off = ((unsigned long)pte_paddr) & ~PAGE_MASK;
- return (pte_t *)((char *)kmap_atomic(pfn_to_page(pfn), KM_PTE2) + off);
-}
-
-static inline void rmap_ptep_unmap(pte_t *pte)
-{
- kunmap_atomic(pte, KM_PTE2);
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * include/asm-i386/std_resources.h
- */
-
-#ifndef __ASM_I386_STD_RESOURCES_H
-#define __ASM_I386_STD_RESOURCES_H
-
-#include <linux/init.h>
-
-void probe_roms(void) __init;
-void request_graphics_resource(void) __init;
-void request_standard_io_resources(void) __init;
-
-#endif
+++ /dev/null
-/*
- * Architecture dependent definitions
- * for NEC uPD4990A serial I/O real-time clock.
- *
- * Copyright 2001 TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>
- * Kyoto University Microcomputer Club (KMC).
- *
- * References:
- * uPD4990A serial I/O real-time clock users' manual (Japanese)
- * No. S12828JJ4V0UM00 (4th revision), NEC Corporation, 1999.
- */
-
-#ifndef _ASM_I386_uPD4990A_H
-#define _ASM_I386_uPD4990A_H
-
-#include <asm/io.h>
-
-#define UPD4990A_IO (0x0020)
-#define UPD4990A_IO_DATAOUT (0x0033)
-
-#define UPD4990A_OUTPUT_DATA_CLK(data, clk) \
- outb((((data) & 1) << 5) | (((clk) & 1) << 4) \
- | UPD4990A_PAR_SERIAL_MODE, UPD4990A_IO)
-
-#define UPD4990A_OUTPUT_CLK(clk) UPD4990A_OUTPUT_DATA_CLK(0, (clk))
-
-#define UPD4990A_OUTPUT_STROBE(stb) \
- outb(((stb) << 3) | UPD4990A_PAR_SERIAL_MODE, UPD4990A_IO)
-
-/*
- * Note: udelay() is *not* usable for UPD4990A_DELAY because
- * the Linux kernel reads uPD4990A to set up system clock
- * before calibrating delay...
- */
-#define UPD4990A_DELAY(usec) \
- do { \
- if (__builtin_constant_p((usec)) && (usec) < 5) \
- __asm__ (".rept %c1\n\toutb %%al,%0\n\t.endr" \
- : : "N" (0x5F), \
- "i" (((usec) * 10 + 5) / 6)); \
- else { \
- int _count = ((usec) * 10 + 5) / 6; \
- __asm__ volatile ("1: outb %%al,%1\n\tloop 1b" \
- : "=c" (_count) \
- : "N" (0x5F), "0" (_count)); \
- } \
- } while (0)
-
-/* Caller should ignore all bits except bit0 */
-#define UPD4990A_READ_DATA() inb(UPD4990A_IO_DATAOUT)
-
-#endif
+++ /dev/null
-#ifndef _ASM_IA64_CPUMASK_H
-#define _ASM_IA64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_IA64_CPUMASK_H */
+++ /dev/null
-#ifndef _ASM_IA64_RMAP_H
-#define _ASM_IA64_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif /* _ASM_IA64_RMAP_H */
+++ /dev/null
-#ifndef _ASM_M68K_CPUMASK_H
-#define _ASM_M68K_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_M68K_CPUMASK_H */
+++ /dev/null
-#ifndef _M68K_INIT_H
-#define _M68K_INIT_H
-
-#define __init __attribute__ ((__section__ (".text.init")))
-#define __initdata __attribute__ ((__section__ (".data.init")))
-/* For assembly routines */
-#define __INIT .section ".text.init",#alloc,#execinstr
-#define __FINIT .previous
-#define __INITDATA .section ".data.init",#alloc,#write
-
-#endif
+++ /dev/null
-#ifndef _M68K_RMAP_H
-#define _M68K_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef _ASM_M68KNOMMU_CPUMASK_H
-#define _ASM_M68KNOMMU_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_M68KNOMMU_CPUMASK_H */
+++ /dev/null
-#include <asm-m68k/init.h>
+++ /dev/null
-/* Do not need anything here */
-
+++ /dev/null
-#ifndef _ASM_MIPS_CPUMASK_H
-#define _ASM_MIPS_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_MIPS_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-/*
- * mv64340.h - MV-64340 Internal registers definition file.
- *
- * Copyright 2002 Momentum Computer, Inc.
- * Author: Matthew Dharm <mdharm@momenco.com>
- * Copyright 2002 GALILEO TECHNOLOGY, LTD.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#ifndef __ASM_MV64340_H
-#define __ASM_MV64340_H
-
-#include <asm/addrspace.h>
-#include <asm/marvell.h>
-
-/****************************************/
-/* Processor Address Space */
-/****************************************/
-
-/* DDR SDRAM BAR and size registers */
-
-#define MV64340_CS_0_BASE_ADDR 0x008
-#define MV64340_CS_0_SIZE 0x010
-#define MV64340_CS_1_BASE_ADDR 0x208
-#define MV64340_CS_1_SIZE 0x210
-#define MV64340_CS_2_BASE_ADDR 0x018
-#define MV64340_CS_2_SIZE 0x020
-#define MV64340_CS_3_BASE_ADDR 0x218
-#define MV64340_CS_3_SIZE 0x220
-
-/* Devices BAR and size registers */
-
-#define MV64340_DEV_CS0_BASE_ADDR 0x028
-#define MV64340_DEV_CS0_SIZE 0x030
-#define MV64340_DEV_CS1_BASE_ADDR 0x228
-#define MV64340_DEV_CS1_SIZE 0x230
-#define MV64340_DEV_CS2_BASE_ADDR 0x248
-#define MV64340_DEV_CS2_SIZE 0x250
-#define MV64340_DEV_CS3_BASE_ADDR 0x038
-#define MV64340_DEV_CS3_SIZE 0x040
-#define MV64340_BOOTCS_BASE_ADDR 0x238
-#define MV64340_BOOTCS_SIZE 0x240
-
-/* PCI 0 BAR and size registers */
-
-#define MV64340_PCI_0_IO_BASE_ADDR 0x048
-#define MV64340_PCI_0_IO_SIZE 0x050
-#define MV64340_PCI_0_MEMORY0_BASE_ADDR 0x058
-#define MV64340_PCI_0_MEMORY0_SIZE 0x060
-#define MV64340_PCI_0_MEMORY1_BASE_ADDR 0x080
-#define MV64340_PCI_0_MEMORY1_SIZE 0x088
-#define MV64340_PCI_0_MEMORY2_BASE_ADDR 0x258
-#define MV64340_PCI_0_MEMORY2_SIZE 0x260
-#define MV64340_PCI_0_MEMORY3_BASE_ADDR 0x280
-#define MV64340_PCI_0_MEMORY3_SIZE 0x288
-
-/* PCI 1 BAR and size registers */
-#define MV64340_PCI_1_IO_BASE_ADDR 0x090
-#define MV64340_PCI_1_IO_SIZE 0x098
-#define MV64340_PCI_1_MEMORY0_BASE_ADDR 0x0a0
-#define MV64340_PCI_1_MEMORY0_SIZE 0x0a8
-#define MV64340_PCI_1_MEMORY1_BASE_ADDR 0x0b0
-#define MV64340_PCI_1_MEMORY1_SIZE 0x0b8
-#define MV64340_PCI_1_MEMORY2_BASE_ADDR 0x2a0
-#define MV64340_PCI_1_MEMORY2_SIZE 0x2a8
-#define MV64340_PCI_1_MEMORY3_BASE_ADDR 0x2b0
-#define MV64340_PCI_1_MEMORY3_SIZE 0x2b8
-
-/* SRAM base address */
-#define MV64340_INTEGRATED_SRAM_BASE_ADDR 0x268
-
-/* internal registers space base address */
-#define MV64340_INTERNAL_SPACE_BASE_ADDR 0x068
-
-/* Enables the CS , DEV_CS , PCI 0 and PCI 1
- windows above */
-#define MV64340_BASE_ADDR_ENABLE 0x278
-
-/****************************************/
-/* PCI remap registers */
-/****************************************/
- /* PCI 0 */
-#define MV64340_PCI_0_IO_ADDR_REMAP 0x0f0
-#define MV64340_PCI_0_MEMORY0_LOW_ADDR_REMAP 0x0f8
-#define MV64340_PCI_0_MEMORY0_HIGH_ADDR_REMAP 0x320
-#define MV64340_PCI_0_MEMORY1_LOW_ADDR_REMAP 0x100
-#define MV64340_PCI_0_MEMORY1_HIGH_ADDR_REMAP 0x328
-#define MV64340_PCI_0_MEMORY2_LOW_ADDR_REMAP 0x2f8
-#define MV64340_PCI_0_MEMORY2_HIGH_ADDR_REMAP 0x330
-#define MV64340_PCI_0_MEMORY3_LOW_ADDR_REMAP 0x300
-#define MV64340_PCI_0_MEMORY3_HIGH_ADDR_REMAP 0x338
- /* PCI 1 */
-#define MV64340_PCI_1_IO_ADDR_REMAP 0x108
-#define MV64340_PCI_1_MEMORY0_LOW_ADDR_REMAP 0x110
-#define MV64340_PCI_1_MEMORY0_HIGH_ADDR_REMAP 0x340
-#define MV64340_PCI_1_MEMORY1_LOW_ADDR_REMAP 0x118
-#define MV64340_PCI_1_MEMORY1_HIGH_ADDR_REMAP 0x348
-#define MV64340_PCI_1_MEMORY2_LOW_ADDR_REMAP 0x310
-#define MV64340_PCI_1_MEMORY2_HIGH_ADDR_REMAP 0x350
-#define MV64340_PCI_1_MEMORY3_LOW_ADDR_REMAP 0x318
-#define MV64340_PCI_1_MEMORY3_HIGH_ADDR_REMAP 0x358
-
-#define MV64340_CPU_PCI_0_HEADERS_RETARGET_CONTROL 0x3b0
-#define MV64340_CPU_PCI_0_HEADERS_RETARGET_BASE 0x3b8
-#define MV64340_CPU_PCI_1_HEADERS_RETARGET_CONTROL 0x3c0
-#define MV64340_CPU_PCI_1_HEADERS_RETARGET_BASE 0x3c8
-#define MV64340_CPU_GE_HEADERS_RETARGET_CONTROL 0x3d0
-#define MV64340_CPU_GE_HEADERS_RETARGET_BASE 0x3d8
-#define MV64340_CPU_IDMA_HEADERS_RETARGET_CONTROL 0x3e0
-#define MV64340_CPU_IDMA_HEADERS_RETARGET_BASE 0x3e8
-
-/****************************************/
-/* CPU Control Registers */
-/****************************************/
-
-#define MV64340_CPU_CONFIG 0x000
-#define MV64340_CPU_MODE 0x120
-#define MV64340_CPU_MASTER_CONTROL 0x160
-#define MV64340_CPU_CROSS_BAR_CONTROL_LOW 0x150
-#define MV64340_CPU_CROSS_BAR_CONTROL_HIGH 0x158
-#define MV64340_CPU_CROSS_BAR_TIMEOUT 0x168
-
-/****************************************/
-/* SMP RegisterS */
-/****************************************/
-
-#define MV64340_SMP_WHO_AM_I 0x200
-#define MV64340_SMP_CPU0_DOORBELL 0x214
-#define MV64340_SMP_CPU0_DOORBELL_CLEAR 0x21C
-#define MV64340_SMP_CPU1_DOORBELL 0x224
-#define MV64340_SMP_CPU1_DOORBELL_CLEAR 0x22C
-#define MV64340_SMP_CPU0_DOORBELL_MASK 0x234
-#define MV64340_SMP_CPU1_DOORBELL_MASK 0x23C
-#define MV64340_SMP_SEMAPHOR0 0x244
-#define MV64340_SMP_SEMAPHOR1 0x24c
-#define MV64340_SMP_SEMAPHOR2 0x254
-#define MV64340_SMP_SEMAPHOR3 0x25c
-#define MV64340_SMP_SEMAPHOR4 0x264
-#define MV64340_SMP_SEMAPHOR5 0x26c
-#define MV64340_SMP_SEMAPHOR6 0x274
-#define MV64340_SMP_SEMAPHOR7 0x27c
-
-/****************************************/
-/* CPU Sync Barrier Register */
-/****************************************/
-
-#define MV64340_CPU_0_SYNC_BARRIER_TRIGGER 0x0c0
-#define MV64340_CPU_0_SYNC_BARRIER_VIRTUAL 0x0c8
-#define MV64340_CPU_1_SYNC_BARRIER_TRIGGER 0x0d0
-#define MV64340_CPU_1_SYNC_BARRIER_VIRTUAL 0x0d8
-
-/****************************************/
-/* CPU Access Protect */
-/****************************************/
-
-#define MV64340_CPU_PROTECT_WINDOW_0_BASE_ADDR 0x180
-#define MV64340_CPU_PROTECT_WINDOW_0_SIZE 0x188
-#define MV64340_CPU_PROTECT_WINDOW_1_BASE_ADDR 0x190
-#define MV64340_CPU_PROTECT_WINDOW_1_SIZE 0x198
-#define MV64340_CPU_PROTECT_WINDOW_2_BASE_ADDR 0x1a0
-#define MV64340_CPU_PROTECT_WINDOW_2_SIZE 0x1a8
-#define MV64340_CPU_PROTECT_WINDOW_3_BASE_ADDR 0x1b0
-#define MV64340_CPU_PROTECT_WINDOW_3_SIZE 0x1b8
-
-
-/****************************************/
-/* CPU Error Report */
-/****************************************/
-
-#define MV64340_CPU_ERROR_ADDR_LOW 0x070
-#define MV64340_CPU_ERROR_ADDR_HIGH 0x078
-#define MV64340_CPU_ERROR_DATA_LOW 0x128
-#define MV64340_CPU_ERROR_DATA_HIGH 0x130
-#define MV64340_CPU_ERROR_PARITY 0x138
-#define MV64340_CPU_ERROR_CAUSE 0x140
-#define MV64340_CPU_ERROR_MASK 0x148
-
-/****************************************/
-/* CPU Interface Debug Registers */
-/****************************************/
-
-#define MV64340_PUNIT_SLAVE_DEBUG_LOW 0x360
-#define MV64340_PUNIT_SLAVE_DEBUG_HIGH 0x368
-#define MV64340_PUNIT_MASTER_DEBUG_LOW 0x370
-#define MV64340_PUNIT_MASTER_DEBUG_HIGH 0x378
-#define MV64340_PUNIT_MMASK 0x3e4
-
-/****************************************/
-/* Integrated SRAM Registers */
-/****************************************/
-
-#define MV64340_SRAM_CONFIG 0x380
-#define MV64340_SRAM_TEST_MODE 0X3F4
-#define MV64340_SRAM_ERROR_CAUSE 0x388
-#define MV64340_SRAM_ERROR_ADDR 0x390
-#define MV64340_SRAM_ERROR_ADDR_HIGH 0X3F8
-#define MV64340_SRAM_ERROR_DATA_LOW 0x398
-#define MV64340_SRAM_ERROR_DATA_HIGH 0x3a0
-#define MV64340_SRAM_ERROR_DATA_PARITY 0x3a8
-
-/****************************************/
-/* SDRAM Configuration */
-/****************************************/
-
-#define MV64340_SDRAM_CONFIG 0x1400
-#define MV64340_D_UNIT_CONTROL_LOW 0x1404
-#define MV64340_D_UNIT_CONTROL_HIGH 0x1424
-#define MV64340_SDRAM_TIMING_CONTROL_LOW 0x1408
-#define MV64340_SDRAM_TIMING_CONTROL_HIGH 0x140c
-#define MV64340_SDRAM_ADDR_CONTROL 0x1410
-#define MV64340_SDRAM_OPEN_PAGES_CONTROL 0x1414
-#define MV64340_SDRAM_OPERATION 0x1418
-#define MV64340_SDRAM_MODE 0x141c
-#define MV64340_EXTENDED_DRAM_MODE 0x1420
-#define MV64340_SDRAM_CROSS_BAR_CONTROL_LOW 0x1430
-#define MV64340_SDRAM_CROSS_BAR_CONTROL_HIGH 0x1434
-#define MV64340_SDRAM_CROSS_BAR_TIMEOUT 0x1438
-#define MV64340_SDRAM_ADDR_CTRL_PADS_CALIBRATION 0x14c0
-#define MV64340_SDRAM_DATA_PADS_CALIBRATION 0x14c4
-
-/****************************************/
-/* SDRAM Error Report */
-/****************************************/
-
-#define MV64340_SDRAM_ERROR_DATA_LOW 0x1444
-#define MV64340_SDRAM_ERROR_DATA_HIGH 0x1440
-#define MV64340_SDRAM_ERROR_ADDR 0x1450
-#define MV64340_SDRAM_RECEIVED_ECC 0x1448
-#define MV64340_SDRAM_CALCULATED_ECC 0x144c
-#define MV64340_SDRAM_ECC_CONTROL 0x1454
-#define MV64340_SDRAM_ECC_ERROR_COUNTER 0x1458
-
-/******************************************/
-/* Controlled Delay Line (CDL) Registers */
-/******************************************/
-
-#define MV64340_DFCDL_CONFIG0 0x1480
-#define MV64340_DFCDL_CONFIG1 0x1484
-#define MV64340_DLL_WRITE 0x1488
-#define MV64340_DLL_READ 0x148c
-#define MV64340_SRAM_ADDR 0x1490
-#define MV64340_SRAM_DATA0 0x1494
-#define MV64340_SRAM_DATA1 0x1498
-#define MV64340_SRAM_DATA2 0x149c
-#define MV64340_DFCL_PROBE 0x14a0
-
-/******************************************/
-/* Debug Registers */
-/******************************************/
-
-#define MV64340_DUNIT_DEBUG_LOW 0x1460
-#define MV64340_DUNIT_DEBUG_HIGH 0x1464
-#define MV64340_DUNIT_MMASK 0X1b40
-
-/****************************************/
-/* Device Parameters */
-/****************************************/
-
-#define MV64340_DEVICE_BANK0_PARAMETERS 0x45c
-#define MV64340_DEVICE_BANK1_PARAMETERS 0x460
-#define MV64340_DEVICE_BANK2_PARAMETERS 0x464
-#define MV64340_DEVICE_BANK3_PARAMETERS 0x468
-#define MV64340_DEVICE_BOOT_BANK_PARAMETERS 0x46c
-#define MV64340_DEVICE_INTERFACE_CONTROL 0x4c0
-#define MV64340_DEVICE_INTERFACE_CROSS_BAR_CONTROL_LOW 0x4c8
-#define MV64340_DEVICE_INTERFACE_CROSS_BAR_CONTROL_HIGH 0x4cc
-#define MV64340_DEVICE_INTERFACE_CROSS_BAR_TIMEOUT 0x4c4
-
-/****************************************/
-/* Device interrupt registers */
-/****************************************/
-
-#define MV64340_DEVICE_INTERRUPT_CAUSE 0x4d0
-#define MV64340_DEVICE_INTERRUPT_MASK 0x4d4
-#define MV64340_DEVICE_ERROR_ADDR 0x4d8
-#define MV64340_DEVICE_ERROR_DATA 0x4dc
-#define MV64340_DEVICE_ERROR_PARITY 0x4e0
-
-/****************************************/
-/* Device debug registers */
-/****************************************/
-
-#define MV64340_DEVICE_DEBUG_LOW 0x4e4
-#define MV64340_DEVICE_DEBUG_HIGH 0x4e8
-#define MV64340_RUNIT_MMASK 0x4f0
-
-/****************************************/
-/* PCI Slave Address Decoding registers */
-/****************************************/
-
-#define MV64340_PCI_0_CS_0_BANK_SIZE 0xc08
-#define MV64340_PCI_1_CS_0_BANK_SIZE 0xc88
-#define MV64340_PCI_0_CS_1_BANK_SIZE 0xd08
-#define MV64340_PCI_1_CS_1_BANK_SIZE 0xd88
-#define MV64340_PCI_0_CS_2_BANK_SIZE 0xc0c
-#define MV64340_PCI_1_CS_2_BANK_SIZE 0xc8c
-#define MV64340_PCI_0_CS_3_BANK_SIZE 0xd0c
-#define MV64340_PCI_1_CS_3_BANK_SIZE 0xd8c
-#define MV64340_PCI_0_DEVCS_0_BANK_SIZE 0xc10
-#define MV64340_PCI_1_DEVCS_0_BANK_SIZE 0xc90
-#define MV64340_PCI_0_DEVCS_1_BANK_SIZE 0xd10
-#define MV64340_PCI_1_DEVCS_1_BANK_SIZE 0xd90
-#define MV64340_PCI_0_DEVCS_2_BANK_SIZE 0xd18
-#define MV64340_PCI_1_DEVCS_2_BANK_SIZE 0xd98
-#define MV64340_PCI_0_DEVCS_3_BANK_SIZE 0xc14
-#define MV64340_PCI_1_DEVCS_3_BANK_SIZE 0xc94
-#define MV64340_PCI_0_DEVCS_BOOT_BANK_SIZE 0xd14
-#define MV64340_PCI_1_DEVCS_BOOT_BANK_SIZE 0xd94
-#define MV64340_PCI_0_P2P_MEM0_BAR_SIZE 0xd1c
-#define MV64340_PCI_1_P2P_MEM0_BAR_SIZE 0xd9c
-#define MV64340_PCI_0_P2P_MEM1_BAR_SIZE 0xd20
-#define MV64340_PCI_1_P2P_MEM1_BAR_SIZE 0xda0
-#define MV64340_PCI_0_P2P_I_O_BAR_SIZE 0xd24
-#define MV64340_PCI_1_P2P_I_O_BAR_SIZE 0xda4
-#define MV64340_PCI_0_CPU_BAR_SIZE 0xd28
-#define MV64340_PCI_1_CPU_BAR_SIZE 0xda8
-#define MV64340_PCI_0_INTERNAL_SRAM_BAR_SIZE 0xe00
-#define MV64340_PCI_1_INTERNAL_SRAM_BAR_SIZE 0xe80
-#define MV64340_PCI_0_EXPANSION_ROM_BAR_SIZE 0xd2c
-#define MV64340_PCI_1_EXPANSION_ROM_BAR_SIZE 0xd9c
-#define MV64340_PCI_0_BASE_ADDR_REG_ENABLE 0xc3c
-#define MV64340_PCI_1_BASE_ADDR_REG_ENABLE 0xcbc
-#define MV64340_PCI_0_CS_0_BASE_ADDR_REMAP 0xc48
-#define MV64340_PCI_1_CS_0_BASE_ADDR_REMAP 0xcc8
-#define MV64340_PCI_0_CS_1_BASE_ADDR_REMAP 0xd48
-#define MV64340_PCI_1_CS_1_BASE_ADDR_REMAP 0xdc8
-#define MV64340_PCI_0_CS_2_BASE_ADDR_REMAP 0xc4c
-#define MV64340_PCI_1_CS_2_BASE_ADDR_REMAP 0xccc
-#define MV64340_PCI_0_CS_3_BASE_ADDR_REMAP 0xd4c
-#define MV64340_PCI_1_CS_3_BASE_ADDR_REMAP 0xdcc
-#define MV64340_PCI_0_CS_0_BASE_HIGH_ADDR_REMAP 0xF04
-#define MV64340_PCI_1_CS_0_BASE_HIGH_ADDR_REMAP 0xF84
-#define MV64340_PCI_0_CS_1_BASE_HIGH_ADDR_REMAP 0xF08
-#define MV64340_PCI_1_CS_1_BASE_HIGH_ADDR_REMAP 0xF88
-#define MV64340_PCI_0_CS_2_BASE_HIGH_ADDR_REMAP 0xF0C
-#define MV64340_PCI_1_CS_2_BASE_HIGH_ADDR_REMAP 0xF8C
-#define MV64340_PCI_0_CS_3_BASE_HIGH_ADDR_REMAP 0xF10
-#define MV64340_PCI_1_CS_3_BASE_HIGH_ADDR_REMAP 0xF90
-#define MV64340_PCI_0_DEVCS_0_BASE_ADDR_REMAP 0xc50
-#define MV64340_PCI_1_DEVCS_0_BASE_ADDR_REMAP 0xcd0
-#define MV64340_PCI_0_DEVCS_1_BASE_ADDR_REMAP 0xd50
-#define MV64340_PCI_1_DEVCS_1_BASE_ADDR_REMAP 0xdd0
-#define MV64340_PCI_0_DEVCS_2_BASE_ADDR_REMAP 0xd58
-#define MV64340_PCI_1_DEVCS_2_BASE_ADDR_REMAP 0xdd8
-#define MV64340_PCI_0_DEVCS_3_BASE_ADDR_REMAP 0xc54
-#define MV64340_PCI_1_DEVCS_3_BASE_ADDR_REMAP 0xcd4
-#define MV64340_PCI_0_DEVCS_BOOTCS_BASE_ADDR_REMAP 0xd54
-#define MV64340_PCI_1_DEVCS_BOOTCS_BASE_ADDR_REMAP 0xdd4
-#define MV64340_PCI_0_P2P_MEM0_BASE_ADDR_REMAP_LOW 0xd5c
-#define MV64340_PCI_1_P2P_MEM0_BASE_ADDR_REMAP_LOW 0xddc
-#define MV64340_PCI_0_P2P_MEM0_BASE_ADDR_REMAP_HIGH 0xd60
-#define MV64340_PCI_1_P2P_MEM0_BASE_ADDR_REMAP_HIGH 0xde0
-#define MV64340_PCI_0_P2P_MEM1_BASE_ADDR_REMAP_LOW 0xd64
-#define MV64340_PCI_1_P2P_MEM1_BASE_ADDR_REMAP_LOW 0xde4
-#define MV64340_PCI_0_P2P_MEM1_BASE_ADDR_REMAP_HIGH 0xd68
-#define MV64340_PCI_1_P2P_MEM1_BASE_ADDR_REMAP_HIGH 0xde8
-#define MV64340_PCI_0_P2P_I_O_BASE_ADDR_REMAP 0xd6c
-#define MV64340_PCI_1_P2P_I_O_BASE_ADDR_REMAP 0xdec
-#define MV64340_PCI_0_CPU_BASE_ADDR_REMAP_LOW 0xd70
-#define MV64340_PCI_1_CPU_BASE_ADDR_REMAP_LOW 0xdf0
-#define MV64340_PCI_0_CPU_BASE_ADDR_REMAP_HIGH 0xd74
-#define MV64340_PCI_1_CPU_BASE_ADDR_REMAP_HIGH 0xdf4
-#define MV64340_PCI_0_INTEGRATED_SRAM_BASE_ADDR_REMAP 0xf00
-#define MV64340_PCI_1_INTEGRATED_SRAM_BASE_ADDR_REMAP 0xf80
-#define MV64340_PCI_0_EXPANSION_ROM_BASE_ADDR_REMAP 0xf38
-#define MV64340_PCI_1_EXPANSION_ROM_BASE_ADDR_REMAP 0xfb8
-#define MV64340_PCI_0_ADDR_DECODE_CONTROL 0xd3c
-#define MV64340_PCI_1_ADDR_DECODE_CONTROL 0xdbc
-#define MV64340_PCI_0_HEADERS_RETARGET_CONTROL 0xF40
-#define MV64340_PCI_1_HEADERS_RETARGET_CONTROL 0xFc0
-#define MV64340_PCI_0_HEADERS_RETARGET_BASE 0xF44
-#define MV64340_PCI_1_HEADERS_RETARGET_BASE 0xFc4
-#define MV64340_PCI_0_HEADERS_RETARGET_HIGH 0xF48
-#define MV64340_PCI_1_HEADERS_RETARGET_HIGH 0xFc8
-
-/***********************************/
-/* PCI Control Register Map */
-/***********************************/
-
-#define MV64340_PCI_0_DLL_STATUS_AND_COMMAND 0x1d20
-#define MV64340_PCI_1_DLL_STATUS_AND_COMMAND 0x1da0
-#define MV64340_PCI_0_MPP_PADS_DRIVE_CONTROL 0x1d1C
-#define MV64340_PCI_1_MPP_PADS_DRIVE_CONTROL 0x1d9C
-#define MV64340_PCI_0_COMMAND 0xc00
-#define MV64340_PCI_1_COMMAND 0xc80
-#define MV64340_PCI_0_MODE 0xd00
-#define MV64340_PCI_1_MODE 0xd80
-#define MV64340_PCI_0_RETRY 0xc04
-#define MV64340_PCI_1_RETRY 0xc84
-#define MV64340_PCI_0_READ_BUFFER_DISCARD_TIMER 0xd04
-#define MV64340_PCI_1_READ_BUFFER_DISCARD_TIMER 0xd84
-#define MV64340_PCI_0_MSI_TRIGGER_TIMER 0xc38
-#define MV64340_PCI_1_MSI_TRIGGER_TIMER 0xcb8
-#define MV64340_PCI_0_ARBITER_CONTROL 0x1d00
-#define MV64340_PCI_1_ARBITER_CONTROL 0x1d80
-#define MV64340_PCI_0_CROSS_BAR_CONTROL_LOW 0x1d08
-#define MV64340_PCI_1_CROSS_BAR_CONTROL_LOW 0x1d88
-#define MV64340_PCI_0_CROSS_BAR_CONTROL_HIGH 0x1d0c
-#define MV64340_PCI_1_CROSS_BAR_CONTROL_HIGH 0x1d8c
-#define MV64340_PCI_0_CROSS_BAR_TIMEOUT 0x1d04
-#define MV64340_PCI_1_CROSS_BAR_TIMEOUT 0x1d84
-#define MV64340_PCI_0_SYNC_BARRIER_TRIGGER_REG 0x1D18
-#define MV64340_PCI_1_SYNC_BARRIER_TRIGGER_REG 0x1D98
-#define MV64340_PCI_0_SYNC_BARRIER_VIRTUAL_REG 0x1d10
-#define MV64340_PCI_1_SYNC_BARRIER_VIRTUAL_REG 0x1d90
-#define MV64340_PCI_0_P2P_CONFIG 0x1d14
-#define MV64340_PCI_1_P2P_CONFIG 0x1d94
-
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_0_LOW 0x1e00
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_0_HIGH 0x1e04
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_0 0x1e08
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_1_LOW 0x1e10
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_1_HIGH 0x1e14
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_1 0x1e18
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_2_LOW 0x1e20
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_2_HIGH 0x1e24
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_2 0x1e28
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_3_LOW 0x1e30
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_3_HIGH 0x1e34
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_3 0x1e38
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_4_LOW 0x1e40
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_4_HIGH 0x1e44
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_4 0x1e48
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_5_LOW 0x1e50
-#define MV64340_PCI_0_ACCESS_CONTROL_BASE_5_HIGH 0x1e54
-#define MV64340_PCI_0_ACCESS_CONTROL_SIZE_5 0x1e58
-
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_0_LOW 0x1e80
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_0_HIGH 0x1e84
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_0 0x1e88
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_1_LOW 0x1e90
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_1_HIGH 0x1e94
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_1 0x1e98
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_2_LOW 0x1ea0
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_2_HIGH 0x1ea4
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_2 0x1ea8
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_3_LOW 0x1eb0
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_3_HIGH 0x1eb4
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_3 0x1eb8
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_4_LOW 0x1ec0
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_4_HIGH 0x1ec4
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_4 0x1ec8
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_5_LOW 0x1ed0
-#define MV64340_PCI_1_ACCESS_CONTROL_BASE_5_HIGH 0x1ed4
-#define MV64340_PCI_1_ACCESS_CONTROL_SIZE_5 0x1ed8
-
-/****************************************/
-/* PCI Configuration Access Registers */
-/****************************************/
-
-#define MV64340_PCI_0_CONFIG_ADDR 0xcf8
-#define MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG 0xcfc
-#define MV64340_PCI_1_CONFIG_ADDR 0xc78
-#define MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG 0xc7c
-#define MV64340_PCI_0_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG 0xc34
-#define MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG 0xcb4
-
-/****************************************/
-/* PCI Error Report Registers */
-/****************************************/
-
-#define MV64340_PCI_0_SERR_MASK 0xc28
-#define MV64340_PCI_1_SERR_MASK 0xca8
-#define MV64340_PCI_0_ERROR_ADDR_LOW 0x1d40
-#define MV64340_PCI_1_ERROR_ADDR_LOW 0x1dc0
-#define MV64340_PCI_0_ERROR_ADDR_HIGH 0x1d44
-#define MV64340_PCI_1_ERROR_ADDR_HIGH 0x1dc4
-#define MV64340_PCI_0_ERROR_ATTRIBUTE 0x1d48
-#define MV64340_PCI_1_ERROR_ATTRIBUTE 0x1dc8
-#define MV64340_PCI_0_ERROR_COMMAND 0x1d50
-#define MV64340_PCI_1_ERROR_COMMAND 0x1dd0
-#define MV64340_PCI_0_ERROR_CAUSE 0x1d58
-#define MV64340_PCI_1_ERROR_CAUSE 0x1dd8
-#define MV64340_PCI_0_ERROR_MASK 0x1d5c
-#define MV64340_PCI_1_ERROR_MASK 0x1ddc
-
-/****************************************/
-/* PCI Debug Registers */
-/****************************************/
-
-#define MV64340_PCI_0_MMASK 0X1D24
-#define MV64340_PCI_1_MMASK 0X1DA4
-
-/*********************************************/
-/* PCI Configuration, Function 0, Registers */
-/*********************************************/
-
-#define MV64340_PCI_DEVICE_AND_VENDOR_ID 0x000
-#define MV64340_PCI_STATUS_AND_COMMAND 0x004
-#define MV64340_PCI_CLASS_CODE_AND_REVISION_ID 0x008
-#define MV64340_PCI_BIST_HEADER_TYPE_LATENCY_TIMER_CACHE_LINE 0x00C
-
-#define MV64340_PCI_SCS_0_BASE_ADDR_LOW 0x010
-#define MV64340_PCI_SCS_0_BASE_ADDR_HIGH 0x014
-#define MV64340_PCI_SCS_1_BASE_ADDR_LOW 0x018
-#define MV64340_PCI_SCS_1_BASE_ADDR_HIGH 0x01C
-#define MV64340_PCI_INTERNAL_REG_MEM_MAPPED_BASE_ADDR_LOW 0x020
-#define MV64340_PCI_INTERNAL_REG_MEM_MAPPED_BASE_ADDR_HIGH 0x024
-#define MV64340_PCI_SUBSYSTEM_ID_AND_SUBSYSTEM_VENDOR_ID 0x02c
-#define MV64340_PCI_EXPANSION_ROM_BASE_ADDR_REG 0x030
-#define MV64340_PCI_CAPABILTY_LIST_POINTER 0x034
-#define MV64340_PCI_INTERRUPT_PIN_AND_LINE 0x03C
- /* capability list */
-#define MV64340_PCI_POWER_MANAGEMENT_CAPABILITY 0x040
-#define MV64340_PCI_POWER_MANAGEMENT_STATUS_AND_CONTROL 0x044
-#define MV64340_PCI_VPD_ADDR 0x048
-#define MV64340_PCI_VPD_DATA 0x04c
-#define MV64340_PCI_MSI_MESSAGE_CONTROL 0x050
-#define MV64340_PCI_MSI_MESSAGE_ADDR 0x054
-#define MV64340_PCI_MSI_MESSAGE_UPPER_ADDR 0x058
-#define MV64340_PCI_MSI_MESSAGE_DATA 0x05c
-#define MV64340_PCI_X_COMMAND 0x060
-#define MV64340_PCI_X_STATUS 0x064
-#define MV64340_PCI_COMPACT_PCI_HOT_SWAP 0x068
-
-/***********************************************/
-/* PCI Configuration, Function 1, Registers */
-/***********************************************/
-
-#define MV64340_PCI_SCS_2_BASE_ADDR_LOW 0x110
-#define MV64340_PCI_SCS_2_BASE_ADDR_HIGH 0x114
-#define MV64340_PCI_SCS_3_BASE_ADDR_LOW 0x118
-#define MV64340_PCI_SCS_3_BASE_ADDR_HIGH 0x11c
-#define MV64340_PCI_INTERNAL_SRAM_BASE_ADDR_LOW 0x120
-#define MV64340_PCI_INTERNAL_SRAM_BASE_ADDR_HIGH 0x124
-
-/***********************************************/
-/* PCI Configuration, Function 2, Registers */
-/***********************************************/
-
-#define MV64340_PCI_DEVCS_0_BASE_ADDR_LOW 0x210
-#define MV64340_PCI_DEVCS_0_BASE_ADDR_HIGH 0x214
-#define MV64340_PCI_DEVCS_1_BASE_ADDR_LOW 0x218
-#define MV64340_PCI_DEVCS_1_BASE_ADDR_HIGH 0x21c
-#define MV64340_PCI_DEVCS_2_BASE_ADDR_LOW 0x220
-#define MV64340_PCI_DEVCS_2_BASE_ADDR_HIGH 0x224
-
-/***********************************************/
-/* PCI Configuration, Function 3, Registers */
-/***********************************************/
-
-#define MV64340_PCI_DEVCS_3_BASE_ADDR_LOW 0x310
-#define MV64340_PCI_DEVCS_3_BASE_ADDR_HIGH 0x314
-#define MV64340_PCI_BOOT_CS_BASE_ADDR_LOW 0x318
-#define MV64340_PCI_BOOT_CS_BASE_ADDR_HIGH 0x31c
-#define MV64340_PCI_CPU_BASE_ADDR_LOW 0x220
-#define MV64340_PCI_CPU_BASE_ADDR_HIGH 0x224
-
-/***********************************************/
-/* PCI Configuration, Function 4, Registers */
-/***********************************************/
-
-#define MV64340_PCI_P2P_MEM0_BASE_ADDR_LOW 0x410
-#define MV64340_PCI_P2P_MEM0_BASE_ADDR_HIGH 0x414
-#define MV64340_PCI_P2P_MEM1_BASE_ADDR_LOW 0x418
-#define MV64340_PCI_P2P_MEM1_BASE_ADDR_HIGH 0x41c
-#define MV64340_PCI_P2P_I_O_BASE_ADDR 0x420
-#define MV64340_PCI_INTERNAL_REGS_I_O_MAPPED_BASE_ADDR 0x424
-
-/****************************************/
-/* Messaging Unit Registers (I20) */
-/****************************************/
-
-#define MV64340_I2O_INBOUND_MESSAGE_REG0_PCI_0_SIDE 0x010
-#define MV64340_I2O_INBOUND_MESSAGE_REG1_PCI_0_SIDE 0x014
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_PCI_0_SIDE 0x018
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_PCI_0_SIDE 0x01C
-#define MV64340_I2O_INBOUND_DOORBELL_REG_PCI_0_SIDE 0x020
-#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_PCI_0_SIDE 0x024
-#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_PCI_0_SIDE 0x028
-#define MV64340_I2O_OUTBOUND_DOORBELL_REG_PCI_0_SIDE 0x02C
-#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_PCI_0_SIDE 0x030
-#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_PCI_0_SIDE 0x034
-#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_0_SIDE 0x040
-#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_0_SIDE 0x044
-#define MV64340_I2O_QUEUE_CONTROL_REG_PCI_0_SIDE 0x050
-#define MV64340_I2O_QUEUE_BASE_ADDR_REG_PCI_0_SIDE 0x054
-#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_PCI_0_SIDE 0x060
-#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_PCI_0_SIDE 0x064
-#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_PCI_0_SIDE 0x068
-#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_PCI_0_SIDE 0x06C
-#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_PCI_0_SIDE 0x070
-#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_PCI_0_SIDE 0x074
-#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_PCI_0_SIDE 0x0F8
-#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_PCI_0_SIDE 0x0FC
-
-#define MV64340_I2O_INBOUND_MESSAGE_REG0_PCI_1_SIDE 0x090
-#define MV64340_I2O_INBOUND_MESSAGE_REG1_PCI_1_SIDE 0x094
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_PCI_1_SIDE 0x098
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_PCI_1_SIDE 0x09C
-#define MV64340_I2O_INBOUND_DOORBELL_REG_PCI_1_SIDE 0x0A0
-#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_PCI_1_SIDE 0x0A4
-#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_PCI_1_SIDE 0x0A8
-#define MV64340_I2O_OUTBOUND_DOORBELL_REG_PCI_1_SIDE 0x0AC
-#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_PCI_1_SIDE 0x0B0
-#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_PCI_1_SIDE 0x0B4
-#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_1_SIDE 0x0C0
-#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_PCI_1_SIDE 0x0C4
-#define MV64340_I2O_QUEUE_CONTROL_REG_PCI_1_SIDE 0x0D0
-#define MV64340_I2O_QUEUE_BASE_ADDR_REG_PCI_1_SIDE 0x0D4
-#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_PCI_1_SIDE 0x0E0
-#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_PCI_1_SIDE 0x0E4
-#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_PCI_1_SIDE 0x0E8
-#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_PCI_1_SIDE 0x0EC
-#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_PCI_1_SIDE 0x0F0
-#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_PCI_1_SIDE 0x0F4
-#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_PCI_1_SIDE 0x078
-#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_PCI_1_SIDE 0x07C
-
-#define MV64340_I2O_INBOUND_MESSAGE_REG0_CPU0_SIDE 0x1C10
-#define MV64340_I2O_INBOUND_MESSAGE_REG1_CPU0_SIDE 0x1C14
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_CPU0_SIDE 0x1C18
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_CPU0_SIDE 0x1C1C
-#define MV64340_I2O_INBOUND_DOORBELL_REG_CPU0_SIDE 0x1C20
-#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_CPU0_SIDE 0x1C24
-#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_CPU0_SIDE 0x1C28
-#define MV64340_I2O_OUTBOUND_DOORBELL_REG_CPU0_SIDE 0x1C2C
-#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_CPU0_SIDE 0x1C30
-#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_CPU0_SIDE 0x1C34
-#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_CPU0_SIDE 0x1C40
-#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_CPU0_SIDE 0x1C44
-#define MV64340_I2O_QUEUE_CONTROL_REG_CPU0_SIDE 0x1C50
-#define MV64340_I2O_QUEUE_BASE_ADDR_REG_CPU0_SIDE 0x1C54
-#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_CPU0_SIDE 0x1C60
-#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_CPU0_SIDE 0x1C64
-#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_CPU0_SIDE 0x1C68
-#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_CPU0_SIDE 0x1C6C
-#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_CPU0_SIDE 0x1C70
-#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_CPU0_SIDE 0x1C74
-#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_CPU0_SIDE 0x1CF8
-#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_CPU0_SIDE 0x1CFC
-#define MV64340_I2O_INBOUND_MESSAGE_REG0_CPU1_SIDE 0x1C90
-#define MV64340_I2O_INBOUND_MESSAGE_REG1_CPU1_SIDE 0x1C94
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG0_CPU1_SIDE 0x1C98
-#define MV64340_I2O_OUTBOUND_MESSAGE_REG1_CPU1_SIDE 0x1C9C
-#define MV64340_I2O_INBOUND_DOORBELL_REG_CPU1_SIDE 0x1CA0
-#define MV64340_I2O_INBOUND_INTERRUPT_CAUSE_REG_CPU1_SIDE 0x1CA4
-#define MV64340_I2O_INBOUND_INTERRUPT_MASK_REG_CPU1_SIDE 0x1CA8
-#define MV64340_I2O_OUTBOUND_DOORBELL_REG_CPU1_SIDE 0x1CAC
-#define MV64340_I2O_OUTBOUND_INTERRUPT_CAUSE_REG_CPU1_SIDE 0x1CB0
-#define MV64340_I2O_OUTBOUND_INTERRUPT_MASK_REG_CPU1_SIDE 0x1CB4
-#define MV64340_I2O_INBOUND_QUEUE_PORT_VIRTUAL_REG_CPU1_SIDE 0x1CC0
-#define MV64340_I2O_OUTBOUND_QUEUE_PORT_VIRTUAL_REG_CPU1_SIDE 0x1CC4
-#define MV64340_I2O_QUEUE_CONTROL_REG_CPU1_SIDE 0x1CD0
-#define MV64340_I2O_QUEUE_BASE_ADDR_REG_CPU1_SIDE 0x1CD4
-#define MV64340_I2O_INBOUND_FREE_HEAD_POINTER_REG_CPU1_SIDE 0x1CE0
-#define MV64340_I2O_INBOUND_FREE_TAIL_POINTER_REG_CPU1_SIDE 0x1CE4
-#define MV64340_I2O_INBOUND_POST_HEAD_POINTER_REG_CPU1_SIDE 0x1CE8
-#define MV64340_I2O_INBOUND_POST_TAIL_POINTER_REG_CPU1_SIDE 0x1CEC
-#define MV64340_I2O_OUTBOUND_FREE_HEAD_POINTER_REG_CPU1_SIDE 0x1CF0
-#define MV64340_I2O_OUTBOUND_FREE_TAIL_POINTER_REG_CPU1_SIDE 0x1CF4
-#define MV64340_I2O_OUTBOUND_POST_HEAD_POINTER_REG_CPU1_SIDE 0x1C78
-#define MV64340_I2O_OUTBOUND_POST_TAIL_POINTER_REG_CPU1_SIDE 0x1C7C
-
-/****************************************/
-/* Ethernet Unit Registers */
-/****************************************/
-
-#define MV64340_ETH_PHY_ADDR_REG 0x2000
-#define MV64340_ETH_SMI_REG 0x2004
-#define MV64340_ETH_UNIT_DEFAULT_ADDR_REG 0x2008
-#define MV64340_ETH_UNIT_DEFAULTID_REG 0x200c
-#define MV64340_ETH_UNIT_INTERRUPT_CAUSE_REG 0x2080
-#define MV64340_ETH_UNIT_INTERRUPT_MASK_REG 0x2084
-#define MV64340_ETH_UNIT_INTERNAL_USE_REG 0x24fc
-#define MV64340_ETH_UNIT_ERROR_ADDR_REG 0x2094
-#define MV64340_ETH_BAR_0 0x2200
-#define MV64340_ETH_BAR_1 0x2208
-#define MV64340_ETH_BAR_2 0x2210
-#define MV64340_ETH_BAR_3 0x2218
-#define MV64340_ETH_BAR_4 0x2220
-#define MV64340_ETH_BAR_5 0x2228
-#define MV64340_ETH_SIZE_REG_0 0x2204
-#define MV64340_ETH_SIZE_REG_1 0x220c
-#define MV64340_ETH_SIZE_REG_2 0x2214
-#define MV64340_ETH_SIZE_REG_3 0x221c
-#define MV64340_ETH_SIZE_REG_4 0x2224
-#define MV64340_ETH_SIZE_REG_5 0x222c
-#define MV64340_ETH_HEADERS_RETARGET_BASE_REG 0x2230
-#define MV64340_ETH_HEADERS_RETARGET_CONTROL_REG 0x2234
-#define MV64340_ETH_HIGH_ADDR_REMAP_REG_0 0x2280
-#define MV64340_ETH_HIGH_ADDR_REMAP_REG_1 0x2284
-#define MV64340_ETH_HIGH_ADDR_REMAP_REG_2 0x2288
-#define MV64340_ETH_HIGH_ADDR_REMAP_REG_3 0x228c
-#define MV64340_ETH_BASE_ADDR_ENABLE_REG 0x2290
-#define MV64340_ETH_ACCESS_PROTECTION_REG(port) (0x2294 + (port<<2))
-#define MV64340_ETH_MIB_COUNTERS_BASE(port) (0x3000 + (port<<7))
-#define MV64340_ETH_PORT_CONFIG_REG(port) (0x2400 + (port<<10))
-#define MV64340_ETH_PORT_CONFIG_EXTEND_REG(port) (0x2404 + (port<<10))
-#define MV64340_ETH_MII_SERIAL_PARAMETRS_REG(port) (0x2408 + (port<<10))
-#define MV64340_ETH_GMII_SERIAL_PARAMETRS_REG(port) (0x240c + (port<<10))
-#define MV64340_ETH_VLAN_ETHERTYPE_REG(port) (0x2410 + (port<<10))
-#define MV64340_ETH_MAC_ADDR_LOW(port) (0x2414 + (port<<10))
-#define MV64340_ETH_MAC_ADDR_HIGH(port) (0x2418 + (port<<10))
-#define MV64340_ETH_SDMA_CONFIG_REG(port) (0x241c + (port<<10))
-#define MV64340_ETH_DSCP_0(port) (0x2420 + (port<<10))
-#define MV64340_ETH_DSCP_1(port) (0x2424 + (port<<10))
-#define MV64340_ETH_DSCP_2(port) (0x2428 + (port<<10))
-#define MV64340_ETH_DSCP_3(port) (0x242c + (port<<10))
-#define MV64340_ETH_DSCP_4(port) (0x2430 + (port<<10))
-#define MV64340_ETH_DSCP_5(port) (0x2434 + (port<<10))
-#define MV64340_ETH_DSCP_6(port) (0x2438 + (port<<10))
-#define MV64340_ETH_PORT_SERIAL_CONTROL_REG(port) (0x243c + (port<<10))
-#define MV64340_ETH_VLAN_PRIORITY_TAG_TO_PRIORITY(port) (0x2440 + (port<<10))
-#define MV64340_ETH_PORT_STATUS_REG(port) (0x2444 + (port<<10))
-#define MV64340_ETH_TRANSMIT_QUEUE_COMMAND_REG(port) (0x2448 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_FIXED_PRIORITY(port) (0x244c + (port<<10))
-#define MV64340_ETH_PORT_TX_TOKEN_BUCKET_RATE_CONFIG(port) (0x2450 + (port<<10))
-#define MV64340_ETH_MAXIMUM_TRANSMIT_UNIT(port) (0x2458 + (port<<10))
-#define MV64340_ETH_PORT_MAXIMUM_TOKEN_BUCKET_SIZE(port) (0x245c + (port<<10))
-#define MV64340_ETH_INTERRUPT_CAUSE_REG(port) (0x2460 + (port<<10))
-#define MV64340_ETH_INTERRUPT_CAUSE_EXTEND_REG(port) (0x2464 + (port<<10))
-#define MV64340_ETH_INTERRUPT_MASK_REG(port) (0x2468 + (port<<10))
-#define MV64340_ETH_INTERRUPT_EXTEND_MASK_REG(port) (0x246c + (port<<10))
-#define MV64340_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + (port<<10))
-#define MV64340_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + (port<<10))
-#define MV64340_ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (0x247c + (port<<10))
-#define MV64340_ETH_RX_DISCARDED_FRAMES_COUNTER(port) (0x2484 + (port<<10)
-#define MV64340_ETH_PORT_DEBUG_0_REG(port) (0x248c + (port<<10))
-#define MV64340_ETH_PORT_DEBUG_1_REG(port) (0x2490 + (port<<10))
-#define MV64340_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + (port<<10))
-#define MV64340_ETH_INTERNAL_USE_REG(port) (0x24fc + (port<<10))
-#define MV64340_ETH_RECEIVE_QUEUE_COMMAND_REG(port) (0x2680 + (port<<10))
-#define MV64340_ETH_CURRENT_SERVED_TX_DESC_PTR(port) (0x2684 + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port) (0x260c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_1(port) (0x261c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_2(port) (0x262c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_3(port) (0x263c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_4(port) (0x264c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_5(port) (0x265c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_6(port) (0x266c + (port<<10))
-#define MV64340_ETH_RX_CURRENT_QUEUE_DESC_PTR_7(port) (0x267c + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port) (0x26c0 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_1(port) (0x26c4 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_2(port) (0x26c8 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_3(port) (0x26cc + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_4(port) (0x26d0 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_5(port) (0x26d4 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_6(port) (0x26d8 + (port<<10))
-#define MV64340_ETH_TX_CURRENT_QUEUE_DESC_PTR_7(port) (0x26dc + (port<<10))
-#define MV64340_ETH_TX_QUEUE_0_TOKEN_BUCKET_COUNT(port) (0x2700 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_1_TOKEN_BUCKET_COUNT(port) (0x2710 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_2_TOKEN_BUCKET_COUNT(port) (0x2720 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_3_TOKEN_BUCKET_COUNT(port) (0x2730 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_4_TOKEN_BUCKET_COUNT(port) (0x2740 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_5_TOKEN_BUCKET_COUNT(port) (0x2750 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_6_TOKEN_BUCKET_COUNT(port) (0x2760 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_7_TOKEN_BUCKET_COUNT(port) (0x2770 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_0_TOKEN_BUCKET_CONFIG(port) (0x2704 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_1_TOKEN_BUCKET_CONFIG(port) (0x2714 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_2_TOKEN_BUCKET_CONFIG(port) (0x2724 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_3_TOKEN_BUCKET_CONFIG(port) (0x2734 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_4_TOKEN_BUCKET_CONFIG(port) (0x2744 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_5_TOKEN_BUCKET_CONFIG(port) (0x2754 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_6_TOKEN_BUCKET_CONFIG(port) (0x2764 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_7_TOKEN_BUCKET_CONFIG(port) (0x2774 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_0_ARBITER_CONFIG(port) (0x2708 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_1_ARBITER_CONFIG(port) (0x2718 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_2_ARBITER_CONFIG(port) (0x2728 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_3_ARBITER_CONFIG(port) (0x2738 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_4_ARBITER_CONFIG(port) (0x2748 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_5_ARBITER_CONFIG(port) (0x2758 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_6_ARBITER_CONFIG(port) (0x2768 + (port<<10))
-#define MV64340_ETH_TX_QUEUE_7_ARBITER_CONFIG(port) (0x2778 + (port<<10))
-#define MV64340_ETH_PORT_TX_TOKEN_BUCKET_COUNT(port) (0x2780 + (port<<10))
-#define MV64340_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(port) (0x3400 + (port<<10))
-#define MV64340_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(port) (0x3500 + (port<<10))
-#define MV64340_ETH_DA_FILTER_UNICAST_TABLE_BASE(port) (0x3600 + (port<<10))
-
-/*******************************************/
-/* CUNIT Registers */
-/*******************************************/
-
- /* Address Decoding Register Map */
-
-#define MV64340_CUNIT_BASE_ADDR_REG0 0xf200
-#define MV64340_CUNIT_BASE_ADDR_REG1 0xf208
-#define MV64340_CUNIT_BASE_ADDR_REG2 0xf210
-#define MV64340_CUNIT_BASE_ADDR_REG3 0xf218
-#define MV64340_CUNIT_SIZE0 0xf204
-#define MV64340_CUNIT_SIZE1 0xf20c
-#define MV64340_CUNIT_SIZE2 0xf214
-#define MV64340_CUNIT_SIZE3 0xf21c
-#define MV64340_CUNIT_HIGH_ADDR_REMAP_REG0 0xf240
-#define MV64340_CUNIT_HIGH_ADDR_REMAP_REG1 0xf244
-#define MV64340_CUNIT_BASE_ADDR_ENABLE_REG 0xf250
-#define MV64340_MPSC0_ACCESS_PROTECTION_REG 0xf254
-#define MV64340_MPSC1_ACCESS_PROTECTION_REG 0xf258
-#define MV64340_CUNIT_INTERNAL_SPACE_BASE_ADDR_REG 0xf25C
-
- /* Error Report Registers */
-
-#define MV64340_CUNIT_INTERRUPT_CAUSE_REG 0xf310
-#define MV64340_CUNIT_INTERRUPT_MASK_REG 0xf314
-#define MV64340_CUNIT_ERROR_ADDR 0xf318
-
- /* Cunit Control Registers */
-
-#define MV64340_CUNIT_ARBITER_CONTROL_REG 0xf300
-#define MV64340_CUNIT_CONFIG_REG 0xb40c
-#define MV64340_CUNIT_CRROSBAR_TIMEOUT_REG 0xf304
-
- /* Cunit Debug Registers */
-
-#define MV64340_CUNIT_DEBUG_LOW 0xf340
-#define MV64340_CUNIT_DEBUG_HIGH 0xf344
-#define MV64340_CUNIT_MMASK 0xf380
-
- /* MPSCs Clocks Routing Registers */
-
-#define MV64340_MPSC_ROUTING_REG 0xb400
-#define MV64340_MPSC_RX_CLOCK_ROUTING_REG 0xb404
-#define MV64340_MPSC_TX_CLOCK_ROUTING_REG 0xb408
-
- /* MPSCs Interrupts Registers */
-
-#define MV64340_MPSC_CAUSE_REG(port) (0xb804 + (port<<3))
-#define MV64340_MPSC_MASK_REG(port) (0xb884 + (port<<3))
-
-#define MV64340_MPSC_MAIN_CONFIG_LOW(port) (0x8000 + (port<<12))
-#define MV64340_MPSC_MAIN_CONFIG_HIGH(port) (0x8004 + (port<<12))
-#define MV64340_MPSC_PROTOCOL_CONFIG(port) (0x8008 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG1(port) (0x800c + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG2(port) (0x8010 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG3(port) (0x8014 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG4(port) (0x8018 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG5(port) (0x801c + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG6(port) (0x8020 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG7(port) (0x8024 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG8(port) (0x8028 + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG9(port) (0x802c + (port<<12))
-#define MV64340_MPSC_CHANNEL_REG10(port) (0x8030 + (port<<12))
-
- /* MPSC0 Registers */
-
-
-/***************************************/
-/* SDMA Registers */
-/***************************************/
-
-#define MV64340_SDMA_CONFIG_REG(channel) (0x4000 + (channel<<13))
-#define MV64340_SDMA_COMMAND_REG(channel) (0x4008 + (channel<<13))
-#define MV64340_SDMA_CURRENT_RX_DESCRIPTOR_POINTER(channel) (0x4810 + (channel<<13))
-#define MV64340_SDMA_CURRENT_TX_DESCRIPTOR_POINTER(channel) (0x4c10 + (channel<<13))
-#define MV64340_SDMA_FIRST_TX_DESCRIPTOR_POINTER(channel) (0x4c14 + (channel<<13))
-
-#define MV64340_SDMA_CAUSE_REG 0xb800
-#define MV64340_SDMA_MASK_REG 0xb880
-
-/* BRG Interrupts */
-
-#define MV64340_BRG_CONFIG_REG(brg) (0xb200 + (brg<<3))
-#define MV64340_BRG_BAUDE_TUNING_REG(brg) (0xb208 + (brg<<3))
-#define MV64340_BRG_CAUSE_REG 0xb834
-#define MV64340_BRG_MASK_REG 0xb8b4
-
-/****************************************/
-/* DMA Channel Control */
-/****************************************/
-
-#define MV64340_DMA_CHANNEL0_CONTROL 0x840
-#define MV64340_DMA_CHANNEL0_CONTROL_HIGH 0x880
-#define MV64340_DMA_CHANNEL1_CONTROL 0x844
-#define MV64340_DMA_CHANNEL1_CONTROL_HIGH 0x884
-#define MV64340_DMA_CHANNEL2_CONTROL 0x848
-#define MV64340_DMA_CHANNEL2_CONTROL_HIGH 0x888
-#define MV64340_DMA_CHANNEL3_CONTROL 0x84C
-#define MV64340_DMA_CHANNEL3_CONTROL_HIGH 0x88C
-
-
-/****************************************/
-/* IDMA Registers */
-/****************************************/
-
-#define MV64340_DMA_CHANNEL0_BYTE_COUNT 0x800
-#define MV64340_DMA_CHANNEL1_BYTE_COUNT 0x804
-#define MV64340_DMA_CHANNEL2_BYTE_COUNT 0x808
-#define MV64340_DMA_CHANNEL3_BYTE_COUNT 0x80C
-#define MV64340_DMA_CHANNEL0_SOURCE_ADDR 0x810
-#define MV64340_DMA_CHANNEL1_SOURCE_ADDR 0x814
-#define MV64340_DMA_CHANNEL2_SOURCE_ADDR 0x818
-#define MV64340_DMA_CHANNEL3_SOURCE_ADDR 0x81c
-#define MV64340_DMA_CHANNEL0_DESTINATION_ADDR 0x820
-#define MV64340_DMA_CHANNEL1_DESTINATION_ADDR 0x824
-#define MV64340_DMA_CHANNEL2_DESTINATION_ADDR 0x828
-#define MV64340_DMA_CHANNEL3_DESTINATION_ADDR 0x82C
-#define MV64340_DMA_CHANNEL0_NEXT_DESCRIPTOR_POINTER 0x830
-#define MV64340_DMA_CHANNEL1_NEXT_DESCRIPTOR_POINTER 0x834
-#define MV64340_DMA_CHANNEL2_NEXT_DESCRIPTOR_POINTER 0x838
-#define MV64340_DMA_CHANNEL3_NEXT_DESCRIPTOR_POINTER 0x83C
-#define MV64340_DMA_CHANNEL0_CURRENT_DESCRIPTOR_POINTER 0x870
-#define MV64340_DMA_CHANNEL1_CURRENT_DESCRIPTOR_POINTER 0x874
-#define MV64340_DMA_CHANNEL2_CURRENT_DESCRIPTOR_POINTER 0x878
-#define MV64340_DMA_CHANNEL3_CURRENT_DESCRIPTOR_POINTER 0x87C
-
- /* IDMA Address Decoding Base Address Registers */
-
-#define MV64340_DMA_BASE_ADDR_REG0 0xa00
-#define MV64340_DMA_BASE_ADDR_REG1 0xa08
-#define MV64340_DMA_BASE_ADDR_REG2 0xa10
-#define MV64340_DMA_BASE_ADDR_REG3 0xa18
-#define MV64340_DMA_BASE_ADDR_REG4 0xa20
-#define MV64340_DMA_BASE_ADDR_REG5 0xa28
-#define MV64340_DMA_BASE_ADDR_REG6 0xa30
-#define MV64340_DMA_BASE_ADDR_REG7 0xa38
-
- /* IDMA Address Decoding Size Address Register */
-
-#define MV64340_DMA_SIZE_REG0 0xa04
-#define MV64340_DMA_SIZE_REG1 0xa0c
-#define MV64340_DMA_SIZE_REG2 0xa14
-#define MV64340_DMA_SIZE_REG3 0xa1c
-#define MV64340_DMA_SIZE_REG4 0xa24
-#define MV64340_DMA_SIZE_REG5 0xa2c
-#define MV64340_DMA_SIZE_REG6 0xa34
-#define MV64340_DMA_SIZE_REG7 0xa3C
-
- /* IDMA Address Decoding High Address Remap and Access
- Protection Registers */
-
-#define MV64340_DMA_HIGH_ADDR_REMAP_REG0 0xa60
-#define MV64340_DMA_HIGH_ADDR_REMAP_REG1 0xa64
-#define MV64340_DMA_HIGH_ADDR_REMAP_REG2 0xa68
-#define MV64340_DMA_HIGH_ADDR_REMAP_REG3 0xa6C
-#define MV64340_DMA_BASE_ADDR_ENABLE_REG 0xa80
-#define MV64340_DMA_CHANNEL0_ACCESS_PROTECTION_REG 0xa70
-#define MV64340_DMA_CHANNEL1_ACCESS_PROTECTION_REG 0xa74
-#define MV64340_DMA_CHANNEL2_ACCESS_PROTECTION_REG 0xa78
-#define MV64340_DMA_CHANNEL3_ACCESS_PROTECTION_REG 0xa7c
-#define MV64340_DMA_ARBITER_CONTROL 0x860
-#define MV64340_DMA_CROSS_BAR_TIMEOUT 0x8d0
-
- /* IDMA Headers Retarget Registers */
-
-#define MV64340_DMA_HEADERS_RETARGET_CONTROL 0xa84
-#define MV64340_DMA_HEADERS_RETARGET_BASE 0xa88
-
- /* IDMA Interrupt Register */
-
-#define MV64340_DMA_INTERRUPT_CAUSE_REG 0x8c0
-#define MV64340_DMA_INTERRUPT_CAUSE_MASK 0x8c4
-#define MV64340_DMA_ERROR_ADDR 0x8c8
-#define MV64340_DMA_ERROR_SELECT 0x8cc
-
- /* IDMA Debug Register ( for internal use ) */
-
-#define MV64340_DMA_DEBUG_LOW 0x8e0
-#define MV64340_DMA_DEBUG_HIGH 0x8e4
-#define MV64340_DMA_SPARE 0xA8C
-
-/****************************************/
-/* Timer_Counter */
-/****************************************/
-
-#define MV64340_TIMER_COUNTER0 0x850
-#define MV64340_TIMER_COUNTER1 0x854
-#define MV64340_TIMER_COUNTER2 0x858
-#define MV64340_TIMER_COUNTER3 0x85C
-#define MV64340_TIMER_COUNTER_0_3_CONTROL 0x864
-#define MV64340_TIMER_COUNTER_0_3_INTERRUPT_CAUSE 0x868
-#define MV64340_TIMER_COUNTER_0_3_INTERRUPT_MASK 0x86c
-
-/****************************************/
-/* Watchdog registers */
-/****************************************/
-
-#define MV64340_WATCHDOG_CONFIG_REG 0xb410
-#define MV64340_WATCHDOG_VALUE_REG 0xb414
-
-/****************************************/
-/* I2C Registers */
-/****************************************/
-
-#define MV64340_I2C_SLAVE_ADDR 0xc000
-#define MV64340_I2C_EXTENDED_SLAVE_ADDR 0xc010
-#define MV64340_I2C_DATA 0xc004
-#define MV64340_I2C_CONTROL 0xc008
-#define MV64340_I2C_STATUS_BAUDE_RATE 0xc00C
-#define MV64340_I2C_SOFT_RESET 0xc01c
-
-/****************************************/
-/* GPP Interface Registers */
-/****************************************/
-
-#define MV64340_GPP_IO_CONTROL 0xf100
-#define MV64340_GPP_LEVEL_CONTROL 0xf110
-#define MV64340_GPP_VALUE 0xf104
-#define MV64340_GPP_INTERRUPT_CAUSE 0xf108
-#define MV64340_GPP_INTERRUPT_MASK0 0xf10c
-#define MV64340_GPP_INTERRUPT_MASK1 0xf114
-#define MV64340_GPP_VALUE_SET 0xf118
-#define MV64340_GPP_VALUE_CLEAR 0xf11c
-
-/****************************************/
-/* Interrupt Controller Registers */
-/****************************************/
-
-/****************************************/
-/* Interrupts */
-/****************************************/
-
-#define MV64340_MAIN_INTERRUPT_CAUSE_LOW 0x004
-#define MV64340_MAIN_INTERRUPT_CAUSE_HIGH 0x00c
-#define MV64340_CPU_INTERRUPT0_MASK_LOW 0x014
-#define MV64340_CPU_INTERRUPT0_MASK_HIGH 0x01c
-#define MV64340_CPU_INTERRUPT0_SELECT_CAUSE 0x024
-#define MV64340_CPU_INTERRUPT1_MASK_LOW 0x034
-#define MV64340_CPU_INTERRUPT1_MASK_HIGH 0x03c
-#define MV64340_CPU_INTERRUPT1_SELECT_CAUSE 0x044
-#define MV64340_INTERRUPT0_MASK_0_LOW 0x054
-#define MV64340_INTERRUPT0_MASK_0_HIGH 0x05c
-#define MV64340_INTERRUPT0_SELECT_CAUSE 0x064
-#define MV64340_INTERRUPT1_MASK_0_LOW 0x074
-#define MV64340_INTERRUPT1_MASK_0_HIGH 0x07c
-#define MV64340_INTERRUPT1_SELECT_CAUSE 0x084
-
-/****************************************/
-/* MPP Interface Registers */
-/****************************************/
-
-#define MV64340_MPP_CONTROL0 0xf000
-#define MV64340_MPP_CONTROL1 0xf004
-#define MV64340_MPP_CONTROL2 0xf008
-#define MV64340_MPP_CONTROL3 0xf00c
-
-/****************************************/
-/* Serial Initialization registers */
-/****************************************/
-
-#define MV64340_SERIAL_INIT_LAST_DATA 0xf324
-#define MV64340_SERIAL_INIT_CONTROL 0xf328
-#define MV64340_SERIAL_INIT_STATUS 0xf32c
-
-extern void mv64340_irq_init(unsigned int base);
-
-#endif /* __ASM_MV64340_H */
+++ /dev/null
-#ifndef __ASM_RMAP_H
-#define __ASM_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif /* __ASM_RMAP_H */
+++ /dev/null
-/*
- * FILE NAME
- * include/asm-mips/vr41xx/eagle.h
- *
- * BRIEF MODULE DESCRIPTION
- * Include file for NEC Eagle board.
- *
- * Author: MontaVista Software, Inc.
- * yyuasa@mvista.com or source@mvista.com
- *
- * Copyright 2001-2003 MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * THIS SOFTWARE IS PROVIDED ``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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __NEC_EAGLE_H
-#define __NEC_EAGLE_H
-
-#include <asm/addrspace.h>
-#include <asm/vr41xx/vr41xx.h>
-
-/*
- * Board specific address mapping
- */
-#define VR41XX_PCI_MEM1_BASE 0x10000000
-#define VR41XX_PCI_MEM1_SIZE 0x04000000
-#define VR41XX_PCI_MEM1_MASK 0x7c000000
-
-#define VR41XX_PCI_MEM2_BASE 0x14000000
-#define VR41XX_PCI_MEM2_SIZE 0x02000000
-#define VR41XX_PCI_MEM2_MASK 0x7e000000
-
-#define VR41XX_PCI_IO_BASE 0x16000000
-#define VR41XX_PCI_IO_SIZE 0x02000000
-#define VR41XX_PCI_IO_MASK 0x7e000000
-
-#define VR41XX_PCI_IO_START 0x01000000
-#define VR41XX_PCI_IO_END 0x01ffffff
-
-#define VR41XX_PCI_MEM_START 0x12000000
-#define VR41XX_PCI_MEM_END 0x15ffffff
-
-#define IO_PORT_BASE KSEG1ADDR(VR41XX_PCI_IO_BASE)
-#define IO_PORT_RESOURCE_START 0
-#define IO_PORT_RESOURCE_END VR41XX_PCI_IO_SIZE
-#define IO_MEM1_RESOURCE_START VR41XX_PCI_MEM1_BASE
-#define IO_MEM1_RESOURCE_END (VR41XX_PCI_MEM1_BASE + VR41XX_PCI_MEM1_SIZE)
-#define IO_MEM2_RESOURCE_START VR41XX_PCI_MEM2_BASE
-#define IO_MEM2_RESOURCE_END (VR41XX_PCI_MEM2_BASE + VR41XX_PCI_MEM2_SIZE)
-
-/*
- * General-Purpose I/O Pin Number
- */
-#define VRC4173_PIN 1
-#define PCISLOT_PIN 4
-#define FPGA_PIN 5
-#define DCD_PIN 15
-
-/*
- * Interrupt Number
- */
-#define VRC4173_CASCADE_IRQ GIU_IRQ(VRC4173_PIN)
-#define PCISLOT_IRQ GIU_IRQ(PCISLOT_PIN)
-#define FPGA_CASCADE_IRQ GIU_IRQ(FPGA_PIN)
-#define DCD_IRQ GIU_IRQ(DCD_PIN)
-
-#define SDBINT_IRQ_BASE 88
-#define SDBINT_IRQ(x) (SDBINT_IRQ_BASE + (x))
-/* RFU */
-#define DEG_IRQ SDBINT_IRQ(1)
-#define ENUM_IRQ SDBINT_IRQ(2)
-#define SIO1INT_IRQ SDBINT_IRQ(3)
-#define SIO2INT_IRQ SDBINT_IRQ(4)
-#define PARINT_IRQ SDBINT_IRQ(5)
-#define SDBINT_IRQ_LAST PARINT_IRQ
-
-#define PCIINT_IRQ_BASE 96
-#define PCIINT_IRQ(x) (PCIINT_IRQ_BASE + (x))
-#define CP_INTA_IRQ PCIINT_IRQ(0)
-#define CP_INTB_IRQ PCIINT_IRQ(1)
-#define CP_INTC_IRQ PCIINT_IRQ(2)
-#define CP_INTD_IRQ PCIINT_IRQ(3)
-#define LANINTA_IRQ PCIINT_IRQ(4)
-#define PCIINT_IRQ_LAST LANINTA_IRQ
-
-/*
- * On board Devices I/O Mapping
- */
-#define NEC_EAGLE_SIO1RB KSEG1ADDR(0x0DFFFEC0)
-#define NEC_EAGLE_SIO1TH KSEG1ADDR(0x0DFFFEC0)
-#define NEC_EAGLE_SIO1IE KSEG1ADDR(0x0DFFFEC2)
-#define NEC_EAGLE_SIO1IID KSEG1ADDR(0x0DFFFEC4)
-#define NEC_EAGLE_SIO1FC KSEG1ADDR(0x0DFFFEC4)
-#define NEC_EAGLE_SIO1LC KSEG1ADDR(0x0DFFFEC6)
-#define NEC_EAGLE_SIO1MC KSEG1ADDR(0x0DFFFEC8)
-#define NEC_EAGLE_SIO1LS KSEG1ADDR(0x0DFFFECA)
-#define NEC_EAGLE_SIO1MS KSEG1ADDR(0x0DFFFECC)
-#define NEC_EAGLE_SIO1SC KSEG1ADDR(0x0DFFFECE)
-
-#define NEC_EAGLE_SIO2TH KSEG1ADDR(0x0DFFFED0)
-#define NEC_EAGLE_SIO2IE KSEG1ADDR(0x0DFFFED2)
-#define NEC_EAGLE_SIO2IID KSEG1ADDR(0x0DFFFED4)
-#define NEC_EAGLE_SIO2FC KSEG1ADDR(0x0DFFFED4)
-#define NEC_EAGLE_SIO2LC KSEG1ADDR(0x0DFFFED6)
-#define NEC_EAGLE_SIO2MC KSEG1ADDR(0x0DFFFED8)
-#define NEC_EAGLE_SIO2LS KSEG1ADDR(0x0DFFFEDA)
-#define NEC_EAGLE_SIO2MS KSEG1ADDR(0x0DFFFEDC)
-#define NEC_EAGLE_SIO2SC KSEG1ADDR(0x0DFFFEDE)
-
-#define NEC_EAGLE_PIOPP_DATA KSEG1ADDR(0x0DFFFEE0)
-#define NEC_EAGLE_PIOPP_STATUS KSEG1ADDR(0x0DFFFEE2)
-#define NEC_EAGLE_PIOPP_CNT KSEG1ADDR(0x0DFFFEE4)
-#define NEC_EAGLE_PIOPP_EPPADDR KSEG1ADDR(0x0DFFFEE6)
-#define NEC_EAGLE_PIOPP_EPPDATA0 KSEG1ADDR(0x0DFFFEE8)
-#define NEC_EAGLE_PIOPP_EPPDATA1 KSEG1ADDR(0x0DFFFEEA)
-#define NEC_EAGLE_PIOPP_EPPDATA2 KSEG1ADDR(0x0DFFFEEC)
-
-#define NEC_EAGLE_PIOECP_DATA KSEG1ADDR(0x0DFFFEF0)
-#define NEC_EAGLE_PIOECP_CONFIG KSEG1ADDR(0x0DFFFEF2)
-#define NEC_EAGLE_PIOECP_EXTCNT KSEG1ADDR(0x0DFFFEF4)
-
-/*
- * FLSHCNT Register
- */
-#define NEC_EAGLE_FLSHCNT KSEG1ADDR(0x0DFFFFA0)
-#define NEC_EAGLE_FLSHCNT_FRDY 0x80
-#define NEC_EAGLE_FLSHCNT_VPPE 0x40
-#define NEC_EAGLE_FLSHCNT_WP2 0x01
-
-/*
- * FLSHBANK Register
- */
-#define NEC_EAGLE_FLSHBANK KSEG1ADDR(0x0DFFFFA4)
-#define NEC_EAGLE_FLSHBANK_S_BANK2 0x40
-#define NEC_EAGLE_FLSHBANK_S_BANK1 0x20
-#define NEC_EAGLE_FLSHBANK_BNKQ4 0x10
-#define NEC_EAGLE_FLSHBANK_BNKQ3 0x08
-#define NEC_EAGLE_FLSHBANK_BNKQ2 0x04
-#define NEC_EAGLE_FLSHBANK_BNKQ1 0x02
-#define NEC_EAGLE_FLSHBANK_BNKQ0 0x01
-
-/*
- * SWITCH Setting Register
- */
-#define NEC_EAGLE_SWTCHSET KSEG1ADDR(0x0DFFFFA8)
-#define NEC_EAGLE_SWTCHSET_DP2SW4 0x80
-#define NEC_EAGLE_SWTCHSET_DP2SW3 0x40
-#define NEC_EAGLE_SWTCHSET_DP2SW2 0x20
-#define NEC_EAGLE_SWTCHSET_DP2SW1 0x10
-#define NEC_EAGLE_SWTCHSET_DP1SW4 0x08
-#define NEC_EAGLE_SWTCHSET_DP1SW3 0x04
-#define NEC_EAGLE_SWTCHSET_DP1SW2 0x02
-#define NEC_EAGLE_SWTCHSET_DP1SW1 0x01
-
-/*
- * PPT Parallel Port Device Controller
- */
-#define NEC_EAGLE_PPT_WRITE_DATA KSEG1ADDR(0x0DFFFFB0)
-#define NEC_EAGLE_PPT_READ_DATA KSEG1ADDR(0x0DFFFFB2)
-#define NEC_EAGLE_PPT_CNT KSEG1ADDR(0x0DFFFFB4)
-#define NEC_EAGLE_PPT_CNT2 KSEG1ADDR(0x0DFFFFB4)
-
-/* Control Register */
-#define NEC_EAGLE_PPT_INTMSK 0x20
-#define NEC_EAGLE_PPT_PARIINT 0x10
-#define NEC_EAGLE_PPT_SELECTIN 0x08
-#define NEC_EAGLE_PPT_INIT 0x04
-#define NEC_EAGLE_PPT_AUTOFD 0x02
-#define NEC_EAGLE_PPT_STROBE 0x01
-
-/* Control Rgister 2 */
-#define NEC_EAGLE_PPT_PAREN 0x80
-#define NEC_EAGLE_PPT_AUTOEN 0x20
-#define NEC_EAGLE_PPT_BUSY 0x10
-#define NEC_EAGLE_PPT_ACK 0x08
-#define NEC_EAGLE_PPT_PE 0x04
-#define NEC_EAGLE_PPT_SELECT 0x02
-#define NEC_EAGLE_PPT_FAULT 0x01
-
-/*
- * LEDWR Register
- */
-#define NEC_EAGLE_LEDWR1 KSEG1ADDR(0x0DFFFFC0)
-#define NEC_EAGLE_LEDWR2 KSEG1ADDR(0x0DFFFFC4)
-
-/*
- * SDBINT Register
- */
-#define NEC_EAGLE_SDBINT KSEG1ADDR(0x0DFFFFD0)
-#define NEC_EAGLE_SDBINT_PARINT 0x20
-#define NEC_EAGLE_SDBINT_SIO2INT 0x10
-#define NEC_EAGLE_SDBINT_SIO1INT 0x08
-#define NEC_EAGLE_SDBINT_ENUM 0x04
-#define NEC_EAGLE_SDBINT_DEG 0x02
-
-/*
- * SDB INTMSK Register
- */
-#define NEC_EAGLE_SDBINTMSK KSEG1ADDR(0x0DFFFFD4)
-#define NEC_EAGLE_SDBINTMSK_MSKPAR 0x20
-#define NEC_EAGLE_SDBINTMSK_MSKSIO2 0x10
-#define NEC_EAGLE_SDBINTMSK_MSKSIO1 0x08
-#define NEC_EAGLE_SDBINTMSK_MSKENUM 0x04
-#define NEC_EAGLE_SDBINTMSK_MSKDEG 0x02
-
-/*
- * RSTREG Register
- */
-#define NEC_EAGLE_RSTREG KSEG1ADDR(0x0DFFFFD8)
-#define NEC_EAGLE_RST_RSTSW 0x02
-#define NEC_EAGLE_RST_LEDOFF 0x01
-
-/*
- * PCI INT Rgister
- */
-#define NEC_EAGLE_PCIINTREG KSEG1ADDR(0x0DFFFFDC)
-#define NEC_EAGLE_PCIINT_LANINT 0x10
-#define NEC_EAGLE_PCIINT_CP_INTD 0x08
-#define NEC_EAGLE_PCIINT_CP_INTC 0x04
-#define NEC_EAGLE_PCIINT_CP_INTB 0x02
-#define NEC_EAGLE_PCIINT_CP_INTA 0x01
-
-/*
- * PCI INT Mask Register
- */
-#define NEC_EAGLE_PCIINTMSKREG KSEG1ADDR(0x0DFFFFE0)
-#define NEC_EAGLE_PCIINTMSK_MSKLANINT 0x10
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTD 0x08
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTC 0x04
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTB 0x02
-#define NEC_EAGLE_PCIINTMSK_MSKCP_INTA 0x01
-
-/*
- * CLK Division Register
- */
-#define NEC_EAGLE_CLKDIV KSEG1ADDR(0x0DFFFFE4)
-#define NEC_EAGLE_CLKDIV_PCIDIV1 0x10
-#define NEC_EAGLE_CLKDIV_PCIDIV0 0x08
-#define NEC_EAGLE_CLKDIV_VTDIV2 0x04
-#define NEC_EAGLE_CLKDIV_VTDIV1 0x02
-#define NEC_EAGLE_CLKDIV_VTDIV0 0x01
-
-/*
- * Source Revision Register
- */
-#define NEC_EAGLE_REVISION KSEG1ADDR(0x0DFFFFE8)
-
-#endif /* __NEC_EAGLE_H */
+++ /dev/null
-/*
- * FILE NAME
- * include/asm-mips/vr41xx/tb0229.h
- *
- * BRIEF MODULE DESCRIPTION
- * Include file for TANBAC TB0229 and TB0219.
- *
- * Copyright 2002,2003 Yoichi Yuasa
- * yuasa@hh.iij4u.or.jp
- *
- * Modified for TANBAC TB0229:
- * Copyright 2003 Megasolution Inc.
- * matsu@megasolution.jp
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-#ifndef __TANBAC_TB0229_H
-#define __TANBAC_TB0229_H
-
-#include <asm/addrspace.h>
-#include <asm/vr41xx/vr41xx.h>
-
-/*
- * Board specific address mapping
- */
-#define VR41XX_PCI_MEM1_BASE 0x10000000
-#define VR41XX_PCI_MEM1_SIZE 0x04000000
-#define VR41XX_PCI_MEM1_MASK 0x7c000000
-
-#define VR41XX_PCI_MEM2_BASE 0x14000000
-#define VR41XX_PCI_MEM2_SIZE 0x02000000
-#define VR41XX_PCI_MEM2_MASK 0x7e000000
-
-#define VR41XX_PCI_IO_BASE 0x16000000
-#define VR41XX_PCI_IO_SIZE 0x02000000
-#define VR41XX_PCI_IO_MASK 0x7e000000
-
-#define VR41XX_PCI_IO_START 0x01000000
-#define VR41XX_PCI_IO_END 0x01ffffff
-
-#define VR41XX_PCI_MEM_START 0x12000000
-#define VR41XX_PCI_MEM_END 0x15ffffff
-
-#define IO_PORT_BASE KSEG1ADDR(VR41XX_PCI_IO_BASE)
-#define IO_PORT_RESOURCE_START 0
-#define IO_PORT_RESOURCE_END VR41XX_PCI_IO_SIZE
-#define IO_MEM1_RESOURCE_START VR41XX_PCI_MEM1_BASE
-#define IO_MEM1_RESOURCE_END (VR41XX_PCI_MEM1_BASE + VR41XX_PCI_MEM1_SIZE)
-#define IO_MEM2_RESOURCE_START VR41XX_PCI_MEM2_BASE
-#define IO_MEM2_RESOURCE_END (VR41XX_PCI_MEM2_BASE + VR41XX_PCI_MEM2_SIZE)
-
-/*
- * General-Purpose I/O Pin Number
- */
-#define TB0219_PCI_SLOT1_PIN 2
-#define TB0219_PCI_SLOT2_PIN 3
-#define TB0219_PCI_SLOT3_PIN 4
-
-/*
- * Interrupt Number
- */
-#define TB0219_PCI_SLOT1_IRQ GIU_IRQ(TB0219_PCI_SLOT1_PIN)
-#define TB0219_PCI_SLOT2_IRQ GIU_IRQ(TB0219_PCI_SLOT2_PIN)
-#define TB0219_PCI_SLOT3_IRQ GIU_IRQ(TB0219_PCI_SLOT3_PIN)
-
-#define TB0219_RESET_REGS KSEG1ADDR(0x0a00000e)
-
-extern void tanbac_tb0229_restart(char *command);
-
-#endif /* __TANBAC_TB0229_H */
+++ /dev/null
-#ifndef _ASM_PARISC_CPUMASK_H
-#define _ASM_PARISC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PARISC_CPUMASK_H */
+++ /dev/null
-#ifndef _PARISC_RMAP_H
-#define _PARISC_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-/*
- * MPC8260 Communication Processor Module.
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- *
- * This file contains structures and information for the communication
- * processor channels found in the dual port RAM or parameter RAM.
- * All CPM control and status is available through the MPC8260 internal
- * memory map. See immap.h for details.
- */
-#ifdef __KERNEL__
-#ifndef __CPM_82XX__
-#define __CPM_82XX__
-
-#include <asm/immap_8260.h>
-
-/* CPM Command register.
-*/
-#define CPM_CR_RST ((uint)0x80000000)
-#define CPM_CR_PAGE ((uint)0x7c000000)
-#define CPM_CR_SBLOCK ((uint)0x03e00000)
-#define CPM_CR_FLG ((uint)0x00010000)
-#define CPM_CR_MCN ((uint)0x00003fc0)
-#define CPM_CR_OPCODE ((uint)0x0000000f)
-
-/* Device sub-block and page codes.
-*/
-#define CPM_CR_SCC1_SBLOCK (0x04)
-#define CPM_CR_SCC2_SBLOCK (0x05)
-#define CPM_CR_SCC3_SBLOCK (0x06)
-#define CPM_CR_SCC4_SBLOCK (0x07)
-#define CPM_CR_SMC1_SBLOCK (0x08)
-#define CPM_CR_SMC2_SBLOCK (0x09)
-#define CPM_CR_SPI_SBLOCK (0x0a)
-#define CPM_CR_I2C_SBLOCK (0x0b)
-#define CPM_CR_TIMER_SBLOCK (0x0f)
-#define CPM_CR_RAND_SBLOCK (0x0e)
-#define CPM_CR_FCC1_SBLOCK (0x10)
-#define CPM_CR_FCC2_SBLOCK (0x11)
-#define CPM_CR_FCC3_SBLOCK (0x12)
-#define CPM_CR_IDMA1_SBLOCK (0x14)
-#define CPM_CR_IDMA2_SBLOCK (0x15)
-#define CPM_CR_IDMA3_SBLOCK (0x16)
-#define CPM_CR_IDMA4_SBLOCK (0x17)
-#define CPM_CR_MCC1_SBLOCK (0x1c)
-
-#define CPM_CR_SCC1_PAGE (0x00)
-#define CPM_CR_SCC2_PAGE (0x01)
-#define CPM_CR_SCC3_PAGE (0x02)
-#define CPM_CR_SCC4_PAGE (0x03)
-#define CPM_CR_SMC1_PAGE (0x07)
-#define CPM_CR_SMC2_PAGE (0x08)
-#define CPM_CR_SPI_PAGE (0x09)
-#define CPM_CR_I2C_PAGE (0x0a)
-#define CPM_CR_TIMER_PAGE (0x0a)
-#define CPM_CR_RAND_PAGE (0x0a)
-#define CPM_CR_FCC1_PAGE (0x04)
-#define CPM_CR_FCC2_PAGE (0x05)
-#define CPM_CR_FCC3_PAGE (0x06)
-#define CPM_CR_IDMA1_PAGE (0x07)
-#define CPM_CR_IDMA2_PAGE (0x08)
-#define CPM_CR_IDMA3_PAGE (0x09)
-#define CPM_CR_IDMA4_PAGE (0x0a)
-#define CPM_CR_MCC1_PAGE (0x07)
-#define CPM_CR_MCC2_PAGE (0x08)
-
-/* Some opcodes (there are more...later)
-*/
-#define CPM_CR_INIT_TRX ((ushort)0x0000)
-#define CPM_CR_INIT_RX ((ushort)0x0001)
-#define CPM_CR_INIT_TX ((ushort)0x0002)
-#define CPM_CR_HUNT_MODE ((ushort)0x0003)
-#define CPM_CR_STOP_TX ((ushort)0x0004)
-#define CPM_CR_RESTART_TX ((ushort)0x0006)
-#define CPM_CR_SET_GADDR ((ushort)0x0008)
-
-#define mk_cr_cmd(PG, SBC, MCN, OP) \
- ((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
-
-/* Dual Port RAM addresses. The first 16K is available for almost
- * any CPM use, so we put the BDs there. The first 128 bytes are
- * used for SMC1 and SMC2 parameter RAM, so we start allocating
- * BDs above that. All of this must change when we start
- * downloading RAM microcode.
- */
-#define CPM_DATAONLY_BASE ((uint)128)
-#define CPM_DATAONLY_SIZE ((uint)(16 * 1024) - CPM_DATAONLY_BASE)
-#define CPM_DP_NOSPACE ((uint)0x7fffffff)
-#define CPM_FCC_SPECIAL_BASE ((uint)0x0000b000)
-
-/* The number of pages of host memory we allocate for CPM. This is
- * done early in kernel initialization to get physically contiguous
- * pages.
- */
-#define NUM_CPM_HOST_PAGES 2
-
-
-/* Export the base address of the communication processor registers
- * and dual port ram.
- */
-extern cpm8260_t *cpmp; /* Pointer to comm processor */
-uint m8260_cpm_dpalloc(uint size, uint align);
-uint m8260_cpm_hostalloc(uint size, uint align);
-void m8260_cpm_setbrg(uint brg, uint rate);
-void m8260_cpm_fastbrg(uint brg, uint rate, int div16);
-
-/* Buffer descriptors used by many of the CPM protocols.
-*/
-typedef struct cpm_buf_desc {
- ushort cbd_sc; /* Status and Control */
- ushort cbd_datlen; /* Data length in buffer */
- uint cbd_bufaddr; /* Buffer address in host memory */
-} cbd_t;
-
-#define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */
-#define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
-#define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
-#define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
-#define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
-#define BD_SC_CM ((ushort)0x0200) /* Continous mode */
-#define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
-#define BD_SC_P ((ushort)0x0100) /* xmt preamble */
-#define BD_SC_BR ((ushort)0x0020) /* Break received */
-#define BD_SC_FR ((ushort)0x0010) /* Framing error */
-#define BD_SC_PR ((ushort)0x0008) /* Parity error */
-#define BD_SC_OV ((ushort)0x0002) /* Overrun */
-#define BD_SC_CD ((ushort)0x0001) /* ?? */
-
-/* Function code bits, usually generic to devices.
-*/
-#define CPMFCR_GBL ((u_char)0x20) /* Set memory snooping */
-#define CPMFCR_EB ((u_char)0x10) /* Set big endian byte order */
-#define CPMFCR_TC2 ((u_char)0x04) /* Transfer code 2 value */
-#define CPMFCR_DTB ((u_char)0x02) /* Use local bus for data when set */
-#define CPMFCR_BDB ((u_char)0x01) /* Use local bus for BD when set */
-
-/* Parameter RAM offsets from the base.
-*/
-#define PROFF_SCC1 ((uint)0x8000)
-#define PROFF_SCC2 ((uint)0x8100)
-#define PROFF_SCC3 ((uint)0x8200)
-#define PROFF_SCC4 ((uint)0x8300)
-#define PROFF_FCC1 ((uint)0x8400)
-#define PROFF_FCC2 ((uint)0x8500)
-#define PROFF_FCC3 ((uint)0x8600)
-#define PROFF_MCC1 ((uint)0x8700)
-#define PROFF_SMC1_BASE ((uint)0x87fc)
-#define PROFF_IDMA1_BASE ((uint)0x87fe)
-#define PROFF_MCC2 ((uint)0x8800)
-#define PROFF_SMC2_BASE ((uint)0x88fc)
-#define PROFF_IDMA2_BASE ((uint)0x88fe)
-#define PROFF_SPI_BASE ((uint)0x89fc)
-#define PROFF_IDMA3_BASE ((uint)0x89fe)
-#define PROFF_TIMERS ((uint)0x8ae0)
-#define PROFF_REVNUM ((uint)0x8af0)
-#define PROFF_RAND ((uint)0x8af8)
-#define PROFF_I2C_BASE ((uint)0x8afc)
-#define PROFF_IDMA4_BASE ((uint)0x8afe)
-
-/* The SMCs are relocated to any of the first eight DPRAM pages.
- * We will fix these at the first locations of DPRAM, until we
- * get some microcode patches :-).
- * The parameter ram space for the SMCs is fifty-some bytes, and
- * they are required to start on a 64 byte boundary.
- */
-#define PROFF_SMC1 (0)
-#define PROFF_SMC2 (64)
-
-
-/* Define enough so I can at least use the serial port as a UART.
- */
-typedef struct smc_uart {
- ushort smc_rbase; /* Rx Buffer descriptor base address */
- ushort smc_tbase; /* Tx Buffer descriptor base address */
- u_char smc_rfcr; /* Rx function code */
- u_char smc_tfcr; /* Tx function code */
- ushort smc_mrblr; /* Max receive buffer length */
- uint smc_rstate; /* Internal */
- uint smc_idp; /* Internal */
- ushort smc_rbptr; /* Internal */
- ushort smc_ibc; /* Internal */
- uint smc_rxtmp; /* Internal */
- uint smc_tstate; /* Internal */
- uint smc_tdp; /* Internal */
- ushort smc_tbptr; /* Internal */
- ushort smc_tbc; /* Internal */
- uint smc_txtmp; /* Internal */
- ushort smc_maxidl; /* Maximum idle characters */
- ushort smc_tmpidl; /* Temporary idle counter */
- ushort smc_brklen; /* Last received break length */
- ushort smc_brkec; /* rcv'd break condition counter */
- ushort smc_brkcr; /* xmt break count register */
- ushort smc_rmask; /* Temporary bit mask */
- uint smc_stmp; /* SDMA Temp */
-} smc_uart_t;
-
-/* SMC uart mode register (Internal memory map).
-*/
-#define SMCMR_REN ((ushort)0x0001)
-#define SMCMR_TEN ((ushort)0x0002)
-#define SMCMR_DM ((ushort)0x000c)
-#define SMCMR_SM_GCI ((ushort)0x0000)
-#define SMCMR_SM_UART ((ushort)0x0020)
-#define SMCMR_SM_TRANS ((ushort)0x0030)
-#define SMCMR_SM_MASK ((ushort)0x0030)
-#define SMCMR_PM_EVEN ((ushort)0x0100) /* Even parity, else odd */
-#define SMCMR_REVD SMCMR_PM_EVEN
-#define SMCMR_PEN ((ushort)0x0200) /* Parity enable */
-#define SMCMR_BS SMCMR_PEN
-#define SMCMR_SL ((ushort)0x0400) /* Two stops, else one */
-#define SMCR_CLEN_MASK ((ushort)0x7800) /* Character length */
-#define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK)
-
-/* SMC Event and Mask register.
-*/
-#define SMCM_BRKE ((unsigned char)0x40) /* When in UART Mode */
-#define SMCM_BRK ((unsigned char)0x10) /* When in UART Mode */
-#define SMCM_TXE ((unsigned char)0x10)
-#define SMCM_BSY ((unsigned char)0x04)
-#define SMCM_TX ((unsigned char)0x02)
-#define SMCM_RX ((unsigned char)0x01)
-
-/* Baud rate generators.
-*/
-#define CPM_BRG_RST ((uint)0x00020000)
-#define CPM_BRG_EN ((uint)0x00010000)
-#define CPM_BRG_EXTC_INT ((uint)0x00000000)
-#define CPM_BRG_EXTC_CLK3_9 ((uint)0x00004000)
-#define CPM_BRG_EXTC_CLK5_15 ((uint)0x00008000)
-#define CPM_BRG_ATB ((uint)0x00002000)
-#define CPM_BRG_CD_MASK ((uint)0x00001ffe)
-#define CPM_BRG_DIV16 ((uint)0x00000001)
-
-/* SCCs.
-*/
-#define SCC_GSMRH_IRP ((uint)0x00040000)
-#define SCC_GSMRH_GDE ((uint)0x00010000)
-#define SCC_GSMRH_TCRC_CCITT ((uint)0x00008000)
-#define SCC_GSMRH_TCRC_BISYNC ((uint)0x00004000)
-#define SCC_GSMRH_TCRC_HDLC ((uint)0x00000000)
-#define SCC_GSMRH_REVD ((uint)0x00002000)
-#define SCC_GSMRH_TRX ((uint)0x00001000)
-#define SCC_GSMRH_TTX ((uint)0x00000800)
-#define SCC_GSMRH_CDP ((uint)0x00000400)
-#define SCC_GSMRH_CTSP ((uint)0x00000200)
-#define SCC_GSMRH_CDS ((uint)0x00000100)
-#define SCC_GSMRH_CTSS ((uint)0x00000080)
-#define SCC_GSMRH_TFL ((uint)0x00000040)
-#define SCC_GSMRH_RFW ((uint)0x00000020)
-#define SCC_GSMRH_TXSY ((uint)0x00000010)
-#define SCC_GSMRH_SYNL16 ((uint)0x0000000c)
-#define SCC_GSMRH_SYNL8 ((uint)0x00000008)
-#define SCC_GSMRH_SYNL4 ((uint)0x00000004)
-#define SCC_GSMRH_RTSM ((uint)0x00000002)
-#define SCC_GSMRH_RSYN ((uint)0x00000001)
-
-#define SCC_GSMRL_SIR ((uint)0x80000000) /* SCC2 only */
-#define SCC_GSMRL_EDGE_NONE ((uint)0x60000000)
-#define SCC_GSMRL_EDGE_NEG ((uint)0x40000000)
-#define SCC_GSMRL_EDGE_POS ((uint)0x20000000)
-#define SCC_GSMRL_EDGE_BOTH ((uint)0x00000000)
-#define SCC_GSMRL_TCI ((uint)0x10000000)
-#define SCC_GSMRL_TSNC_3 ((uint)0x0c000000)
-#define SCC_GSMRL_TSNC_4 ((uint)0x08000000)
-#define SCC_GSMRL_TSNC_14 ((uint)0x04000000)
-#define SCC_GSMRL_TSNC_INF ((uint)0x00000000)
-#define SCC_GSMRL_RINV ((uint)0x02000000)
-#define SCC_GSMRL_TINV ((uint)0x01000000)
-#define SCC_GSMRL_TPL_128 ((uint)0x00c00000)
-#define SCC_GSMRL_TPL_64 ((uint)0x00a00000)
-#define SCC_GSMRL_TPL_48 ((uint)0x00800000)
-#define SCC_GSMRL_TPL_32 ((uint)0x00600000)
-#define SCC_GSMRL_TPL_16 ((uint)0x00400000)
-#define SCC_GSMRL_TPL_8 ((uint)0x00200000)
-#define SCC_GSMRL_TPL_NONE ((uint)0x00000000)
-#define SCC_GSMRL_TPP_ALL1 ((uint)0x00180000)
-#define SCC_GSMRL_TPP_01 ((uint)0x00100000)
-#define SCC_GSMRL_TPP_10 ((uint)0x00080000)
-#define SCC_GSMRL_TPP_ZEROS ((uint)0x00000000)
-#define SCC_GSMRL_TEND ((uint)0x00040000)
-#define SCC_GSMRL_TDCR_32 ((uint)0x00030000)
-#define SCC_GSMRL_TDCR_16 ((uint)0x00020000)
-#define SCC_GSMRL_TDCR_8 ((uint)0x00010000)
-#define SCC_GSMRL_TDCR_1 ((uint)0x00000000)
-#define SCC_GSMRL_RDCR_32 ((uint)0x0000c000)
-#define SCC_GSMRL_RDCR_16 ((uint)0x00008000)
-#define SCC_GSMRL_RDCR_8 ((uint)0x00004000)
-#define SCC_GSMRL_RDCR_1 ((uint)0x00000000)
-#define SCC_GSMRL_RENC_DFMAN ((uint)0x00003000)
-#define SCC_GSMRL_RENC_MANCH ((uint)0x00002000)
-#define SCC_GSMRL_RENC_FM0 ((uint)0x00001000)
-#define SCC_GSMRL_RENC_NRZI ((uint)0x00000800)
-#define SCC_GSMRL_RENC_NRZ ((uint)0x00000000)
-#define SCC_GSMRL_TENC_DFMAN ((uint)0x00000600)
-#define SCC_GSMRL_TENC_MANCH ((uint)0x00000400)
-#define SCC_GSMRL_TENC_FM0 ((uint)0x00000200)
-#define SCC_GSMRL_TENC_NRZI ((uint)0x00000100)
-#define SCC_GSMRL_TENC_NRZ ((uint)0x00000000)
-#define SCC_GSMRL_DIAG_LE ((uint)0x000000c0) /* Loop and echo */
-#define SCC_GSMRL_DIAG_ECHO ((uint)0x00000080)
-#define SCC_GSMRL_DIAG_LOOP ((uint)0x00000040)
-#define SCC_GSMRL_DIAG_NORM ((uint)0x00000000)
-#define SCC_GSMRL_ENR ((uint)0x00000020)
-#define SCC_GSMRL_ENT ((uint)0x00000010)
-#define SCC_GSMRL_MODE_ENET ((uint)0x0000000c)
-#define SCC_GSMRL_MODE_DDCMP ((uint)0x00000009)
-#define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008)
-#define SCC_GSMRL_MODE_V14 ((uint)0x00000007)
-#define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006)
-#define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
-#define SCC_GSMRL_MODE_UART ((uint)0x00000004)
-#define SCC_GSMRL_MODE_SS7 ((uint)0x00000003)
-#define SCC_GSMRL_MODE_ATALK ((uint)0x00000002)
-#define SCC_GSMRL_MODE_HDLC ((uint)0x00000000)
-
-#define SCC_TODR_TOD ((ushort)0x8000)
-
-/* SCC Event and Mask register.
-*/
-#define SCCM_TXE ((unsigned char)0x10)
-#define SCCM_BSY ((unsigned char)0x04)
-#define SCCM_TX ((unsigned char)0x02)
-#define SCCM_RX ((unsigned char)0x01)
-
-typedef struct scc_param {
- ushort scc_rbase; /* Rx Buffer descriptor base address */
- ushort scc_tbase; /* Tx Buffer descriptor base address */
- u_char scc_rfcr; /* Rx function code */
- u_char scc_tfcr; /* Tx function code */
- ushort scc_mrblr; /* Max receive buffer length */
- uint scc_rstate; /* Internal */
- uint scc_idp; /* Internal */
- ushort scc_rbptr; /* Internal */
- ushort scc_ibc; /* Internal */
- uint scc_rxtmp; /* Internal */
- uint scc_tstate; /* Internal */
- uint scc_tdp; /* Internal */
- ushort scc_tbptr; /* Internal */
- ushort scc_tbc; /* Internal */
- uint scc_txtmp; /* Internal */
- uint scc_rcrc; /* Internal */
- uint scc_tcrc; /* Internal */
-} sccp_t;
-
-/* CPM Ethernet through SCC1.
- */
-typedef struct scc_enet {
- sccp_t sen_genscc;
- uint sen_cpres; /* Preset CRC */
- uint sen_cmask; /* Constant mask for CRC */
- uint sen_crcec; /* CRC Error counter */
- uint sen_alec; /* alignment error counter */
- uint sen_disfc; /* discard frame counter */
- ushort sen_pads; /* Tx short frame pad character */
- ushort sen_retlim; /* Retry limit threshold */
- ushort sen_retcnt; /* Retry limit counter */
- ushort sen_maxflr; /* maximum frame length register */
- ushort sen_minflr; /* minimum frame length register */
- ushort sen_maxd1; /* maximum DMA1 length */
- ushort sen_maxd2; /* maximum DMA2 length */
- ushort sen_maxd; /* Rx max DMA */
- ushort sen_dmacnt; /* Rx DMA counter */
- ushort sen_maxb; /* Max BD byte count */
- ushort sen_gaddr1; /* Group address filter */
- ushort sen_gaddr2;
- ushort sen_gaddr3;
- ushort sen_gaddr4;
- uint sen_tbuf0data0; /* Save area 0 - current frame */
- uint sen_tbuf0data1; /* Save area 1 - current frame */
- uint sen_tbuf0rba; /* Internal */
- uint sen_tbuf0crc; /* Internal */
- ushort sen_tbuf0bcnt; /* Internal */
- ushort sen_paddrh; /* physical address (MSB) */
- ushort sen_paddrm;
- ushort sen_paddrl; /* physical address (LSB) */
- ushort sen_pper; /* persistence */
- ushort sen_rfbdptr; /* Rx first BD pointer */
- ushort sen_tfbdptr; /* Tx first BD pointer */
- ushort sen_tlbdptr; /* Tx last BD pointer */
- uint sen_tbuf1data0; /* Save area 0 - current frame */
- uint sen_tbuf1data1; /* Save area 1 - current frame */
- uint sen_tbuf1rba; /* Internal */
- uint sen_tbuf1crc; /* Internal */
- ushort sen_tbuf1bcnt; /* Internal */
- ushort sen_txlen; /* Tx Frame length counter */
- ushort sen_iaddr1; /* Individual address filter */
- ushort sen_iaddr2;
- ushort sen_iaddr3;
- ushort sen_iaddr4;
- ushort sen_boffcnt; /* Backoff counter */
-
- /* NOTE: Some versions of the manual have the following items
- * incorrectly documented. Below is the proper order.
- */
- ushort sen_taddrh; /* temp address (MSB) */
- ushort sen_taddrm;
- ushort sen_taddrl; /* temp address (LSB) */
-} scc_enet_t;
-
-
-/* SCC Event register as used by Ethernet.
-*/
-#define SCCE_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */
-#define SCCE_ENET_TXE ((ushort)0x0010) /* Transmit Error */
-#define SCCE_ENET_RXF ((ushort)0x0008) /* Full frame received */
-#define SCCE_ENET_BSY ((ushort)0x0004) /* All incoming buffers full */
-#define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */
-#define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */
-
-/* SCC Mode Register (PSMR) as used by Ethernet.
-*/
-#define SCC_PSMR_HBC ((ushort)0x8000) /* Enable heartbeat */
-#define SCC_PSMR_FC ((ushort)0x4000) /* Force collision */
-#define SCC_PSMR_RSH ((ushort)0x2000) /* Receive short frames */
-#define SCC_PSMR_IAM ((ushort)0x1000) /* Check individual hash */
-#define SCC_PSMR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */
-#define SCC_PSMR_PRO ((ushort)0x0200) /* Promiscuous mode */
-#define SCC_PSMR_BRO ((ushort)0x0100) /* Catch broadcast pkts */
-#define SCC_PSMR_SBT ((ushort)0x0080) /* Special backoff timer */
-#define SCC_PSMR_LPB ((ushort)0x0040) /* Set Loopback mode */
-#define SCC_PSMR_SIP ((ushort)0x0020) /* Sample Input Pins */
-#define SCC_PSMR_LCW ((ushort)0x0010) /* Late collision window */
-#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */
-#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */
-
-/* Buffer descriptor control/status used by Ethernet receive.
- * Common to SCC and FCC.
- */
-#define BD_ENET_RX_EMPTY ((ushort)0x8000)
-#define BD_ENET_RX_WRAP ((ushort)0x2000)
-#define BD_ENET_RX_INTR ((ushort)0x1000)
-#define BD_ENET_RX_LAST ((ushort)0x0800)
-#define BD_ENET_RX_FIRST ((ushort)0x0400)
-#define BD_ENET_RX_MISS ((ushort)0x0100)
-#define BD_ENET_RX_BC ((ushort)0x0080) /* FCC Only */
-#define BD_ENET_RX_MC ((ushort)0x0040) /* FCC Only */
-#define BD_ENET_RX_LG ((ushort)0x0020)
-#define BD_ENET_RX_NO ((ushort)0x0010)
-#define BD_ENET_RX_SH ((ushort)0x0008)
-#define BD_ENET_RX_CR ((ushort)0x0004)
-#define BD_ENET_RX_OV ((ushort)0x0002)
-#define BD_ENET_RX_CL ((ushort)0x0001)
-#define BD_ENET_RX_STATS ((ushort)0x01ff) /* All status bits */
-
-/* Buffer descriptor control/status used by Ethernet transmit.
- * Common to SCC and FCC.
- */
-#define BD_ENET_TX_READY ((ushort)0x8000)
-#define BD_ENET_TX_PAD ((ushort)0x4000)
-#define BD_ENET_TX_WRAP ((ushort)0x2000)
-#define BD_ENET_TX_INTR ((ushort)0x1000)
-#define BD_ENET_TX_LAST ((ushort)0x0800)
-#define BD_ENET_TX_TC ((ushort)0x0400)
-#define BD_ENET_TX_DEF ((ushort)0x0200)
-#define BD_ENET_TX_HB ((ushort)0x0100)
-#define BD_ENET_TX_LC ((ushort)0x0080)
-#define BD_ENET_TX_RL ((ushort)0x0040)
-#define BD_ENET_TX_RCMASK ((ushort)0x003c)
-#define BD_ENET_TX_UN ((ushort)0x0002)
-#define BD_ENET_TX_CSL ((ushort)0x0001)
-#define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
-
-/* SCC as UART
-*/
-typedef struct scc_uart {
- sccp_t scc_genscc;
- uint scc_res1; /* Reserved */
- uint scc_res2; /* Reserved */
- ushort scc_maxidl; /* Maximum idle chars */
- ushort scc_idlc; /* temp idle counter */
- ushort scc_brkcr; /* Break count register */
- ushort scc_parec; /* receive parity error counter */
- ushort scc_frmec; /* receive framing error counter */
- ushort scc_nosec; /* receive noise counter */
- ushort scc_brkec; /* receive break condition counter */
- ushort scc_brkln; /* last received break length */
- ushort scc_uaddr1; /* UART address character 1 */
- ushort scc_uaddr2; /* UART address character 2 */
- ushort scc_rtemp; /* Temp storage */
- ushort scc_toseq; /* Transmit out of sequence char */
- ushort scc_char1; /* control character 1 */
- ushort scc_char2; /* control character 2 */
- ushort scc_char3; /* control character 3 */
- ushort scc_char4; /* control character 4 */
- ushort scc_char5; /* control character 5 */
- ushort scc_char6; /* control character 6 */
- ushort scc_char7; /* control character 7 */
- ushort scc_char8; /* control character 8 */
- ushort scc_rccm; /* receive control character mask */
- ushort scc_rccr; /* receive control character register */
- ushort scc_rlbc; /* receive last break character */
-} scc_uart_t;
-
-/* SCC Event and Mask registers when it is used as a UART.
-*/
-#define UART_SCCM_GLR ((ushort)0x1000)
-#define UART_SCCM_GLT ((ushort)0x0800)
-#define UART_SCCM_AB ((ushort)0x0200)
-#define UART_SCCM_IDL ((ushort)0x0100)
-#define UART_SCCM_GRA ((ushort)0x0080)
-#define UART_SCCM_BRKE ((ushort)0x0040)
-#define UART_SCCM_BRKS ((ushort)0x0020)
-#define UART_SCCM_CCR ((ushort)0x0008)
-#define UART_SCCM_BSY ((ushort)0x0004)
-#define UART_SCCM_TX ((ushort)0x0002)
-#define UART_SCCM_RX ((ushort)0x0001)
-
-/* The SCC PMSR when used as a UART.
-*/
-#define SCU_PMSR_FLC ((ushort)0x8000)
-#define SCU_PMSR_SL ((ushort)0x4000)
-#define SCU_PMSR_CL ((ushort)0x3000)
-#define SCU_PMSR_UM ((ushort)0x0c00)
-#define SCU_PMSR_FRZ ((ushort)0x0200)
-#define SCU_PMSR_RZS ((ushort)0x0100)
-#define SCU_PMSR_SYN ((ushort)0x0080)
-#define SCU_PMSR_DRT ((ushort)0x0040)
-#define SCU_PMSR_PEN ((ushort)0x0010)
-#define SCU_PMSR_RPM ((ushort)0x000c)
-#define SCU_PMSR_REVP ((ushort)0x0008)
-#define SCU_PMSR_TPM ((ushort)0x0003)
-#define SCU_PMSR_TEVP ((ushort)0x0003)
-
-/* CPM Transparent mode SCC.
- */
-typedef struct scc_trans {
- sccp_t st_genscc;
- uint st_cpres; /* Preset CRC */
- uint st_cmask; /* Constant mask for CRC */
-} scc_trans_t;
-
-#define BD_SCC_TX_LAST ((ushort)0x0800)
-
-/* How about some FCCs.....
-*/
-#define FCC_GFMR_DIAG_NORM ((uint)0x00000000)
-#define FCC_GFMR_DIAG_LE ((uint)0x40000000)
-#define FCC_GFMR_DIAG_AE ((uint)0x80000000)
-#define FCC_GFMR_DIAG_ALE ((uint)0xc0000000)
-#define FCC_GFMR_TCI ((uint)0x20000000)
-#define FCC_GFMR_TRX ((uint)0x10000000)
-#define FCC_GFMR_TTX ((uint)0x08000000)
-#define FCC_GFMR_TTX ((uint)0x08000000)
-#define FCC_GFMR_CDP ((uint)0x04000000)
-#define FCC_GFMR_CTSP ((uint)0x02000000)
-#define FCC_GFMR_CDS ((uint)0x01000000)
-#define FCC_GFMR_CTSS ((uint)0x00800000)
-#define FCC_GFMR_SYNL_NONE ((uint)0x00000000)
-#define FCC_GFMR_SYNL_AUTO ((uint)0x00004000)
-#define FCC_GFMR_SYNL_8 ((uint)0x00008000)
-#define FCC_GFMR_SYNL_16 ((uint)0x0000c000)
-#define FCC_GFMR_RTSM ((uint)0x00002000)
-#define FCC_GFMR_RENC_NRZ ((uint)0x00000000)
-#define FCC_GFMR_RENC_NRZI ((uint)0x00000800)
-#define FCC_GFMR_REVD ((uint)0x00000400)
-#define FCC_GFMR_TENC_NRZ ((uint)0x00000000)
-#define FCC_GFMR_TENC_NRZI ((uint)0x00000100)
-#define FCC_GFMR_TCRC_16 ((uint)0x00000000)
-#define FCC_GFMR_TCRC_32 ((uint)0x00000080)
-#define FCC_GFMR_ENR ((uint)0x00000020)
-#define FCC_GFMR_ENT ((uint)0x00000010)
-#define FCC_GFMR_MODE_ENET ((uint)0x0000000c)
-#define FCC_GFMR_MODE_ATM ((uint)0x0000000a)
-#define FCC_GFMR_MODE_HDLC ((uint)0x00000000)
-
-/* Generic FCC parameter ram.
-*/
-typedef struct fcc_param {
- ushort fcc_riptr; /* Rx Internal temp pointer */
- ushort fcc_tiptr; /* Tx Internal temp pointer */
- ushort fcc_res1;
- ushort fcc_mrblr; /* Max receive buffer length, mod 32 bytes */
- uint fcc_rstate; /* Upper byte is Func code, must be set */
- uint fcc_rbase; /* Receive BD base */
- ushort fcc_rbdstat; /* RxBD status */
- ushort fcc_rbdlen; /* RxBD down counter */
- uint fcc_rdptr; /* RxBD internal data pointer */
- uint fcc_tstate; /* Upper byte is Func code, must be set */
- uint fcc_tbase; /* Transmit BD base */
- ushort fcc_tbdstat; /* TxBD status */
- ushort fcc_tbdlen; /* TxBD down counter */
- uint fcc_tdptr; /* TxBD internal data pointer */
- uint fcc_rbptr; /* Rx BD Internal buf pointer */
- uint fcc_tbptr; /* Tx BD Internal buf pointer */
- uint fcc_rcrc; /* Rx temp CRC */
- uint fcc_res2;
- uint fcc_tcrc; /* Tx temp CRC */
-} fccp_t;
-
-
-/* Ethernet controller through FCC.
-*/
-typedef struct fcc_enet {
- fccp_t fen_genfcc;
- uint fen_statbuf; /* Internal status buffer */
- uint fen_camptr; /* CAM address */
- uint fen_cmask; /* Constant mask for CRC */
- uint fen_cpres; /* Preset CRC */
- uint fen_crcec; /* CRC Error counter */
- uint fen_alec; /* alignment error counter */
- uint fen_disfc; /* discard frame counter */
- ushort fen_retlim; /* Retry limit */
- ushort fen_retcnt; /* Retry counter */
- ushort fen_pper; /* Persistence */
- ushort fen_boffcnt; /* backoff counter */
- uint fen_gaddrh; /* Group address filter, high 32-bits */
- uint fen_gaddrl; /* Group address filter, low 32-bits */
- ushort fen_tfcstat; /* out of sequence TxBD */
- ushort fen_tfclen;
- uint fen_tfcptr;
- ushort fen_mflr; /* Maximum frame length (1518) */
- ushort fen_paddrh; /* MAC address */
- ushort fen_paddrm;
- ushort fen_paddrl;
- ushort fen_ibdcount; /* Internal BD counter */
- ushort fen_idbstart; /* Internal BD start pointer */
- ushort fen_ibdend; /* Internal BD end pointer */
- ushort fen_txlen; /* Internal Tx frame length counter */
- uint fen_ibdbase[8]; /* Internal use */
- uint fen_iaddrh; /* Individual address filter */
- uint fen_iaddrl;
- ushort fen_minflr; /* Minimum frame length (64) */
- ushort fen_taddrh; /* Filter transfer MAC address */
- ushort fen_taddrm;
- ushort fen_taddrl;
- ushort fen_padptr; /* Pointer to pad byte buffer */
- ushort fen_cftype; /* control frame type */
- ushort fen_cfrange; /* control frame range */
- ushort fen_maxb; /* maximum BD count */
- ushort fen_maxd1; /* Max DMA1 length (1520) */
- ushort fen_maxd2; /* Max DMA2 length (1520) */
- ushort fen_maxd; /* internal max DMA count */
- ushort fen_dmacnt; /* internal DMA counter */
- uint fen_octc; /* Total octect counter */
- uint fen_colc; /* Total collision counter */
- uint fen_broc; /* Total broadcast packet counter */
- uint fen_mulc; /* Total multicast packet count */
- uint fen_uspc; /* Total packets < 64 bytes */
- uint fen_frgc; /* Total packets < 64 bytes with errors */
- uint fen_ospc; /* Total packets > 1518 */
- uint fen_jbrc; /* Total packets > 1518 with errors */
- uint fen_p64c; /* Total packets == 64 bytes */
- uint fen_p65c; /* Total packets 64 < bytes <= 127 */
- uint fen_p128c; /* Total packets 127 < bytes <= 255 */
- uint fen_p256c; /* Total packets 256 < bytes <= 511 */
- uint fen_p512c; /* Total packets 512 < bytes <= 1023 */
- uint fen_p1024c; /* Total packets 1024 < bytes <= 1518 */
- uint fen_cambuf; /* Internal CAM buffer poiner */
- ushort fen_rfthr; /* Received frames threshold */
- ushort fen_rfcnt; /* Received frames count */
-} fcc_enet_t;
-
-/* FCC Event/Mask register as used by Ethernet.
-*/
-#define FCC_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */
-#define FCC_ENET_RXC ((ushort)0x0040) /* Control Frame Received */
-#define FCC_ENET_TXC ((ushort)0x0020) /* Out of seq. Tx sent */
-#define FCC_ENET_TXE ((ushort)0x0010) /* Transmit Error */
-#define FCC_ENET_RXF ((ushort)0x0008) /* Full frame received */
-#define FCC_ENET_BSY ((ushort)0x0004) /* Busy. Rx Frame dropped */
-#define FCC_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */
-#define FCC_ENET_RXB ((ushort)0x0001) /* A buffer was received */
-
-/* FCC Mode Register (FPSMR) as used by Ethernet.
-*/
-#define FCC_PSMR_HBC ((uint)0x80000000) /* Enable heartbeat */
-#define FCC_PSMR_FC ((uint)0x40000000) /* Force Collision */
-#define FCC_PSMR_SBT ((uint)0x20000000) /* Stop backoff timer */
-#define FCC_PSMR_LPB ((uint)0x10000000) /* Local protect. 1 = FDX */
-#define FCC_PSMR_LCW ((uint)0x08000000) /* Late collision select */
-#define FCC_PSMR_FDE ((uint)0x04000000) /* Full Duplex Enable */
-#define FCC_PSMR_MON ((uint)0x02000000) /* RMON Enable */
-#define FCC_PSMR_PRO ((uint)0x00400000) /* Promiscuous Enable */
-#define FCC_PSMR_FCE ((uint)0x00200000) /* Flow Control Enable */
-#define FCC_PSMR_RSH ((uint)0x00100000) /* Receive Short Frames */
-#define FCC_PSMR_CAM ((uint)0x00000400) /* CAM enable */
-#define FCC_PSMR_BRO ((uint)0x00000200) /* Broadcast pkt discard */
-#define FCC_PSMR_ENCRC ((uint)0x00000080) /* Use 32-bit CRC */
-
-/* IIC parameter RAM.
-*/
-typedef struct iic {
- ushort iic_rbase; /* Rx Buffer descriptor base address */
- ushort iic_tbase; /* Tx Buffer descriptor base address */
- u_char iic_rfcr; /* Rx function code */
- u_char iic_tfcr; /* Tx function code */
- ushort iic_mrblr; /* Max receive buffer length */
- uint iic_rstate; /* Internal */
- uint iic_rdp; /* Internal */
- ushort iic_rbptr; /* Internal */
- ushort iic_rbc; /* Internal */
- uint iic_rxtmp; /* Internal */
- uint iic_tstate; /* Internal */
- uint iic_tdp; /* Internal */
- ushort iic_tbptr; /* Internal */
- ushort iic_tbc; /* Internal */
- uint iic_txtmp; /* Internal */
-} iic_t;
-
-#define BD_IIC_START ((ushort)0x0400)
-
-#endif /* __CPM_82XX__ */
-#endif /* __KERNEL__ */
+++ /dev/null
-#ifndef _ASM_PPC_CPUMASK_H
-#define _ASM_PPC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PPC_CPUMASK_H */
+++ /dev/null
-/*
- * MPC8260 Internal Memory Map
- * Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
- *
- * The Internal Memory Map of the 8260. I don't know how generic
- * this will be, as I don't have any knowledge of the subsequent
- * parts at this time. I copied this from the 8xx_immap.h.
- */
-#ifdef __KERNEL__
-#ifndef __IMMAP_82XX__
-#define __IMMAP_82XX__
-
-/* System configuration registers.
-*/
-typedef struct sys_conf {
- uint sc_siumcr;
- uint sc_sypcr;
- char res1[6];
- ushort sc_swsr;
- char res2[20];
- uint sc_bcr;
- u_char sc_ppc_acr;
- char res3[3];
- uint sc_ppc_alrh;
- uint sc_ppc_alrl;
- u_char sc_lcl_acr;
- char res4[3];
- uint sc_lcl_alrh;
- uint sc_lcl_alrl;
- uint sc_tescr1;
- uint sc_tescr2;
- uint sc_ltescr1;
- uint sc_ltescr2;
- uint sc_pdtea;
- u_char sc_pdtem;
- char res5[3];
- uint sc_ldtea;
- u_char sc_ldtem;
- char res6[163];
-} sysconf8260_t;
-
-
-/* Memory controller registers.
-*/
-typedef struct mem_ctlr {
- uint memc_br0;
- uint memc_or0;
- uint memc_br1;
- uint memc_or1;
- uint memc_br2;
- uint memc_or2;
- uint memc_br3;
- uint memc_or3;
- uint memc_br4;
- uint memc_or4;
- uint memc_br5;
- uint memc_or5;
- uint memc_br6;
- uint memc_or6;
- uint memc_br7;
- uint memc_or7;
- uint memc_br8;
- uint memc_or8;
- uint memc_br9;
- uint memc_or9;
- uint memc_br10;
- uint memc_or10;
- uint memc_br11;
- uint memc_or11;
- char res1[8];
- uint memc_mar;
- char res2[4];
- uint memc_mamr;
- uint memc_mbmr;
- uint memc_mcmr;
- char res3[8];
- ushort memc_mptpr;
- char res4[2];
- uint memc_mdr;
- char res5[4];
- uint memc_psdmr;
- uint memc_lsdmr;
- u_char memc_purt;
- char res6[3];
- u_char memc_psrt;
- char res7[3];
- u_char memc_lurt;
- char res8[3];
- u_char memc_lsrt;
- char res9[3];
- uint memc_immr;
- char res10[84];
-} memctl8260_t;
-
-/* System Integration Timers.
-*/
-typedef struct sys_int_timers {
- char res1[32];
- ushort sit_tmcntsc;
- char res2[2];
- uint sit_tmcnt;
- char res3[4];
- uint sit_tmcntal;
- char res4[16];
- ushort sit_piscr;
- char res5[2];
- uint sit_pitc;
- uint sit_pitr;
- char res6[94];
- char res7[2390];
-} sit8260_t;
-
-#define PISCR_PIRQ_MASK ((ushort)0xff00)
-#define PISCR_PS ((ushort)0x0080)
-#define PISCR_PIE ((ushort)0x0004)
-#define PISCR_PTF ((ushort)0x0002)
-#define PISCR_PTE ((ushort)0x0001)
-
-/* Interrupt Controller.
-*/
-typedef struct interrupt_controller {
- ushort ic_sicr;
- char res1[2];
- uint ic_sivec;
- uint ic_sipnrh;
- uint ic_sipnrl;
- uint ic_siprr;
- uint ic_scprrh;
- uint ic_scprrl;
- uint ic_simrh;
- uint ic_simrl;
- uint ic_siexr;
- char res2[88];
-} intctl8260_t;
-
-/* Clocks and Reset.
-*/
-typedef struct clk_and_reset {
- uint car_sccr;
- char res1[4];
- uint car_scmr;
- char res2[4];
- uint car_rsr;
- uint car_rmr;
- char res[104];
-} car8260_t;
-
-/* Input/Output Port control/status registers.
- * Names consistent with processor manual, although they are different
- * from the original 8xx names.......
- */
-typedef struct io_port {
- uint iop_pdira;
- uint iop_ppara;
- uint iop_psora;
- uint iop_podra;
- uint iop_pdata;
- char res1[12];
- uint iop_pdirb;
- uint iop_pparb;
- uint iop_psorb;
- uint iop_podrb;
- uint iop_pdatb;
- char res2[12];
- uint iop_pdirc;
- uint iop_pparc;
- uint iop_psorc;
- uint iop_podrc;
- uint iop_pdatc;
- char res3[12];
- uint iop_pdird;
- uint iop_ppard;
- uint iop_psord;
- uint iop_podrd;
- uint iop_pdatd;
- char res4[12];
-} iop8260_t;
-
-/* Communication Processor Module Timers
-*/
-typedef struct cpm_timers {
- u_char cpmt_tgcr1;
- char res1[3];
- u_char cpmt_tgcr2;
- char res2[11];
- ushort cpmt_tmr1;
- ushort cpmt_tmr2;
- ushort cpmt_trr1;
- ushort cpmt_trr2;
- ushort cpmt_tcr1;
- ushort cpmt_tcr2;
- ushort cpmt_tcn1;
- ushort cpmt_tcn2;
- ushort cpmt_tmr3;
- ushort cpmt_tmr4;
- ushort cpmt_trr3;
- ushort cpmt_trr4;
- ushort cpmt_tcr3;
- ushort cpmt_tcr4;
- ushort cpmt_tcn3;
- ushort cpmt_tcn4;
- ushort cpmt_ter1;
- ushort cpmt_ter2;
- ushort cpmt_ter3;
- ushort cpmt_ter4;
- char res3[584];
-} cpmtimer8260_t;
-
-/* DMA control/status registers.
-*/
-typedef struct sdma_csr {
- char res0[24];
- u_char sdma_sdsr;
- char res1[3];
- u_char sdma_sdmr;
- char res2[3];
- u_char sdma_idsr1;
- char res3[3];
- u_char sdma_idmr1;
- char res4[3];
- u_char sdma_idsr2;
- char res5[3];
- u_char sdma_idmr2;
- char res6[3];
- u_char sdma_idsr3;
- char res7[3];
- u_char sdma_idmr3;
- char res8[3];
- u_char sdma_idsr4;
- char res9[3];
- u_char sdma_idmr4;
- char res10[707];
-} sdma8260_t;
-
-/* Fast controllers
-*/
-typedef struct fcc {
- uint fcc_gfmr;
- uint fcc_fpsmr;
- ushort fcc_ftodr;
- char res1[2];
- ushort fcc_fdsr;
- char res2[2];
- ushort fcc_fcce;
- char res3[2];
- ushort fcc_fccm;
- char res4[2];
- u_char fcc_fccs;
- char res5[3];
- u_char fcc_ftirr_phy[4];
-} fcc_t;
-
-/* I2C
-*/
-typedef struct i2c {
- u_char i2c_i2mod;
- char res1[3];
- u_char i2c_i2add;
- char res2[3];
- u_char i2c_i2brg;
- char res3[3];
- u_char i2c_i2com;
- char res4[3];
- u_char i2c_i2cer;
- char res5[3];
- u_char i2c_i2cmr;
- char res6[331];
-} i2c8260_t;
-
-typedef struct scc { /* Serial communication channels */
- uint scc_gsmrl;
- uint scc_gsmrh;
- ushort scc_pmsr;
- char res1[2];
- ushort scc_todr;
- ushort scc_dsr;
- ushort scc_scce;
- char res2[2];
- ushort scc_sccm;
- char res3;
- u_char scc_sccs;
- char res4[8];
-} scc_t;
-
-typedef struct smc { /* Serial management channels */
- char res1[2];
- ushort smc_smcmr;
- char res2[2];
- u_char smc_smce;
- char res3[3];
- u_char smc_smcm;
- char res4[5];
-} smc_t;
-
-/* Serial Peripheral Interface.
-*/
-typedef struct spi {
- ushort spi_spmode;
- char res1[4];
- u_char spi_spie;
- char res2[3];
- u_char spi_spim;
- char res3[2];
- u_char spi_spcom;
- char res4[82];
-} spi_t;
-
-/* CPM Mux.
-*/
-typedef struct cpmux {
- u_char cmx_si1cr;
- char res1;
- u_char cmx_si2cr;
- char res2;
- uint cmx_fcr;
- uint cmx_scr;
- u_char cmx_smr;
- char res3;
- ushort cmx_uar;
- char res4[16];
-} cpmux_t;
-
-/* SIRAM control
-*/
-typedef struct siram {
- ushort si_amr;
- ushort si_bmr;
- ushort si_cmr;
- ushort si_dmr;
- u_char si_gmr;
- char res1;
- u_char si_cmdr;
- char res2;
- u_char si_str;
- char res3;
- ushort si_rsr;
-} siramctl_t;
-
-typedef struct mcc {
- ushort mcc_mcce;
- char res1[2];
- ushort mcc_mccm;
- char res2[2];
- u_char mcc_mccf;
- char res3[7];
-} mcc_t;
-
-typedef struct comm_proc {
- uint cp_cpcr;
- uint cp_rccr;
- char res1[14];
- ushort cp_rter;
- char res2[2];
- ushort cp_rtmr;
- ushort cp_rtscr;
- char res3[2];
- uint cp_rtsr;
- char res4[12];
-} cpm8260_t;
-
-/* ...and the whole thing wrapped up....
-*/
-typedef struct immap {
- /* Some references are into the unique and known dpram spaces,
- * others are from the generic base.
- */
-#define im_dprambase im_dpram1
- u_char im_dpram1[16*1024];
- char res1[16*1024];
- u_char im_dpram2[4*1024];
- char res2[8*1024];
- u_char im_dpram3[4*1024];
- char res3[16*1024];
-
- sysconf8260_t im_siu_conf; /* SIU Configuration */
- memctl8260_t im_memctl; /* Memory Controller */
- sit8260_t im_sit; /* System Integration Timers */
- intctl8260_t im_intctl; /* Interrupt Controller */
- car8260_t im_clkrst; /* Clocks and reset */
- iop8260_t im_ioport; /* IO Port control/status */
- cpmtimer8260_t im_cpmtimer; /* CPM timers */
- sdma8260_t im_sdma; /* SDMA control/status */
-
- fcc_t im_fcc[3]; /* Three FCCs */
-
- char res4[159];
-
- /* First set of baud rate generators.
- */
- char res4a[496];
- uint im_brgc5;
- uint im_brgc6;
- uint im_brgc7;
- uint im_brgc8;
-
- char res5[608];
-
- i2c8260_t im_i2c; /* I2C control/status */
- cpm8260_t im_cpm; /* Communication processor */
-
- /* Second set of baud rate generators.
- */
- uint im_brgc1;
- uint im_brgc2;
- uint im_brgc3;
- uint im_brgc4;
-
- scc_t im_scc[4]; /* Four SCCs */
- smc_t im_smc[2]; /* Couple of SMCs */
- spi_t im_spi; /* A SPI */
- cpmux_t im_cpmux; /* CPM clock route mux */
- siramctl_t im_siramctl1; /* First SI RAM Control */
- mcc_t im_mcc1; /* First MCC */
- siramctl_t im_siramctl2; /* Second SI RAM Control */
- mcc_t im_mcc2; /* Second MCC */
-
- char res6[1184];
-
- ushort im_si1txram[256];
- char res7[512];
- ushort im_si1rxram[256];
- char res8[512];
- ushort im_si2txram[256];
- char res9[512];
- ushort im_si2rxram[256];
- char res10[512];
- char res11[4096];
-} immap_t;
-
-extern immap_t *immr;
-
-#endif /* __IMMAP_82XX__ */
-#endif /* __KERNEL__ */
+++ /dev/null
-/*
- * include/asm-ppc/mv64x60.h
- *
- * Prototypes, etc. for the Marvell/Galileo MV64x60 host bridge routines.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#ifndef __ASMPPC_MV64x60_H
-#define __ASMPPC_MV64x60_H
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/config.h>
-
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mv64x60_defs.h>
-
-extern u8 mv64x60_pci_exclude_bridge;
-
-extern spinlock_t mv64x60_lock;
-extern spinlock_t mv64x60_rmw_lock;
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* 32-bit Window table entry defines */
-#define MV64x60_CPU2MEM_0_WIN 0
-#define MV64x60_CPU2MEM_1_WIN 1
-#define MV64x60_CPU2MEM_2_WIN 2
-#define MV64x60_CPU2MEM_3_WIN 3
-#define MV64x60_CPU2DEV_0_WIN 4
-#define MV64x60_CPU2DEV_1_WIN 5
-#define MV64x60_CPU2DEV_2_WIN 6
-#define MV64x60_CPU2DEV_3_WIN 7
-#define MV64x60_CPU2BOOT_WIN 8
-#define MV64x60_CPU2PCI0_IO_WIN 9
-#define MV64x60_CPU2PCI0_MEM_0_WIN 10
-#define MV64x60_CPU2PCI0_MEM_1_WIN 11
-#define MV64x60_CPU2PCI0_MEM_2_WIN 12
-#define MV64x60_CPU2PCI0_MEM_3_WIN 13
-#define MV64x60_CPU2PCI1_IO_WIN 14
-#define MV64x60_CPU2PCI1_MEM_0_WIN 15
-#define MV64x60_CPU2PCI1_MEM_1_WIN 16
-#define MV64x60_CPU2PCI1_MEM_2_WIN 17
-#define MV64x60_CPU2PCI1_MEM_3_WIN 18
-#define MV64x60_CPU2SRAM_WIN 19
-#define MV64x60_CPU2PCI0_IO_REMAP_WIN 20
-#define MV64x60_CPU2PCI1_IO_REMAP_WIN 21
-#define MV64x60_CPU_PROT_0_WIN 22
-#define MV64x60_CPU_PROT_1_WIN 23
-#define MV64x60_CPU_PROT_2_WIN 24
-#define MV64x60_CPU_PROT_3_WIN 25
-#define MV64x60_CPU_SNOOP_0_WIN 26
-#define MV64x60_CPU_SNOOP_1_WIN 27
-#define MV64x60_CPU_SNOOP_2_WIN 28
-#define MV64x60_CPU_SNOOP_3_WIN 29
-#define MV64x60_PCI02MEM_REMAP_0_WIN 30
-#define MV64x60_PCI02MEM_REMAP_1_WIN 31
-#define MV64x60_PCI02MEM_REMAP_2_WIN 32
-#define MV64x60_PCI02MEM_REMAP_3_WIN 33
-#define MV64x60_PCI12MEM_REMAP_0_WIN 34
-#define MV64x60_PCI12MEM_REMAP_1_WIN 35
-#define MV64x60_PCI12MEM_REMAP_2_WIN 36
-#define MV64x60_PCI12MEM_REMAP_3_WIN 37
-
-#define MV64x60_32BIT_WIN_COUNT 38
-
-/* 64-bit Window table entry defines */
-#define MV64x60_CPU2PCI0_MEM_0_REMAP_WIN 0
-#define MV64x60_CPU2PCI0_MEM_1_REMAP_WIN 1
-#define MV64x60_CPU2PCI0_MEM_2_REMAP_WIN 2
-#define MV64x60_CPU2PCI0_MEM_3_REMAP_WIN 3
-#define MV64x60_CPU2PCI1_MEM_0_REMAP_WIN 4
-#define MV64x60_CPU2PCI1_MEM_1_REMAP_WIN 5
-#define MV64x60_CPU2PCI1_MEM_2_REMAP_WIN 6
-#define MV64x60_CPU2PCI1_MEM_3_REMAP_WIN 7
-#define MV64x60_PCI02MEM_ACC_CNTL_0_WIN 8
-#define MV64x60_PCI02MEM_ACC_CNTL_1_WIN 9
-#define MV64x60_PCI02MEM_ACC_CNTL_2_WIN 10
-#define MV64x60_PCI02MEM_ACC_CNTL_3_WIN 11
-#define MV64x60_PCI12MEM_ACC_CNTL_0_WIN 12
-#define MV64x60_PCI12MEM_ACC_CNTL_1_WIN 13
-#define MV64x60_PCI12MEM_ACC_CNTL_2_WIN 14
-#define MV64x60_PCI12MEM_ACC_CNTL_3_WIN 15
-#define MV64x60_PCI02MEM_SNOOP_0_WIN 16
-#define MV64x60_PCI02MEM_SNOOP_1_WIN 17
-#define MV64x60_PCI02MEM_SNOOP_2_WIN 18
-#define MV64x60_PCI02MEM_SNOOP_3_WIN 19
-#define MV64x60_PCI12MEM_SNOOP_0_WIN 20
-#define MV64x60_PCI12MEM_SNOOP_1_WIN 21
-#define MV64x60_PCI12MEM_SNOOP_2_WIN 22
-#define MV64x60_PCI12MEM_SNOOP_3_WIN 23
-
-#define MV64x60_64BIT_WIN_COUNT 24
-
-
-/*
- * Define a structure that's used to pass in config information to the
- * core routines.
- */
-typedef struct {
- u32 cpu_base;
- u32 pci_base_hi;
- u32 pci_base_lo;
- u32 size;
- u32 swap;
-} mv64x60_pci_window_t;
-
-typedef struct {
- u8 enable_bus; /* allow access to this PCI bus? */
- u8 enumerate_bus; /* enumerate devices on this bus? */
-
- mv64x60_pci_window_t pci_io;
- mv64x60_pci_window_t pci_mem[3];
-
- u32 acc_cntl_options[MV64x60_CPU2MEM_WINDOWS];
- u32 snoop_options[MV64x60_CPU2MEM_WINDOWS];
- u16 pci_cmd_bits;
- u16 latency_timer;
-} mv64x60_pci_info_t;
-
-typedef struct {
- u32 phys_reg_base;
-
- u32 window_preserve_mask_32;
- u32 window_preserve_mask_64;
-
- u32 base_irq; /* Starting irq # for this intr ctlr */
- int ((*map_irq)(struct pci_dev *, unsigned char, unsigned char));
-
- u32 cpu_prot_options[MV64x60_CPU2MEM_WINDOWS];
- u32 cpu_snoop_options[MV64x60_CPU2MEM_WINDOWS];
-
- mv64x60_pci_info_t pci_0;
- mv64x60_pci_info_t pci_1;
-} mv64x60_setup_info_t;
-
-/*
- * Define the 'handle' struct that will be passed between the 64x60 core
- * code and the platform-specific code that will use it. The handle
- * will contain pointers to chip-specific routines & information.
- */
-typedef struct {
- u32 base_reg;
- u32 size_reg;
- u8 base_bits;
- u8 size_bits;
- u32 (*get_from_field)(u32 val, u32 num_bits);
- u32 (*map_to_field)(u32 val, u32 num_bits);
- u32 extra;
-} mv64x60_32bit_window_t;
-
-typedef struct {
- u32 base_hi_reg;
- u32 base_lo_reg;
- u32 size_reg;
- u8 base_lo_bits;
- u8 size_bits;
- u32 (*get_from_field)(u32 val, u32 num_bits);
- u32 (*map_to_field)(u32 val, u32 num_bits);
- u32 extra;
-} mv64x60_64bit_window_t;
-
-typedef struct mv64x60_handle mv64x60_handle_t;
-
-typedef struct {
- u32 (*translate_size)(u32 base, u32 size, u32 num_bits);
- u32 (*untranslate_size)(u32 base, u32 size, u32 num_bits);
- void (*set_pci2mem_window)(struct pci_controller *hose, u32 window,
- u32 base);
- u32 (*is_enabled_32bit)(mv64x60_handle_t *bh, u32 window);
- void (*enable_window_32bit)(mv64x60_handle_t *bh, u32 window);
- void (*disable_window_32bit)(mv64x60_handle_t *bh, u32 window);
- void (*enable_window_64bit)(mv64x60_handle_t *bh, u32 window);
- void (*disable_window_64bit)(mv64x60_handle_t *bh, u32 window);
- void (*disable_all_windows)(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
- void (*chip_specific_init)(mv64x60_handle_t *bh,
- mv64x60_setup_info_t *si);
-
- mv64x60_32bit_window_t *window_tab_32bit;
- mv64x60_64bit_window_t *window_tab_64bit;
-} mv64x60_chip_info_t;
-
-struct mv64x60_handle {
- u32 type; /* type of bridge */
- u32 v_base; /* virtual base addr of bridge regs */
- u32 p_base; /* physical base addr of bridge regs */
- u32 base_irq; /* Base irq # for intrs on this intr cltr */
-
- u32 io_base_a; /* vaddr of pci 0's I/O space */
- u32 io_base_b; /* vaddr of pci 1's I/O space */
-
- struct pci_controller *hose_a;
- struct pci_controller *hose_b;
-
- mv64x60_chip_info_t *ci; /* chip/bridge-specific info */
-};
-
-
-/* Define I/O routines for accessing registers on the 64x60 bridge. */
-extern inline void
-mv64x60_write(mv64x60_handle_t *bh, u32 offset, u32 val) {
- out_le32((volatile u32 *)(bh->v_base + offset), val);
-}
-
-extern inline u32
-mv64x60_read(mv64x60_handle_t *bh, u32 offset) {
- return in_le32((volatile u32 *)(bh->v_base + offset));
-}
-
-extern inline void
-mv64x60_modify(mv64x60_handle_t *bh, u32 offs, u32 data, u32 mask)
-{
- uint32_t reg;
- unsigned long flags;
-
- spin_lock_irqsave(&mv64x60_rmw_lock, flags);
- reg = mv64x60_read(bh, offs) & (~mask); /* zero any bits we care about*/
- reg |= data & mask; /* set bits from the data */
- mv64x60_write(bh, offs, reg);
- spin_unlock_irqrestore(&mv64x60_rmw_lock, flags);
-}
-
-#define mv64x60_set_bits(bh, offs, bits) mv64x60_modify(bh, offs, ~0, bits)
-#define mv64x60_clr_bits(bh, offs, bits) mv64x60_modify(bh, offs, 0, bits)
-
-
-/* Externally visible function prototypes */
-int mv64x60_init(mv64x60_handle_t *bh, mv64x60_setup_info_t *si);
-u32 mv64x60_get_mem_size(u32 bridge_base, u32 chip_type);
-void mv64x60_get_32bit_window(mv64x60_handle_t *bh, u32 window,
- u32 *base, u32 *size);
-void mv64x60_set_32bit_window(mv64x60_handle_t *bh, u32 window, u32 base,
- u32 size, u32 other_bits);
-void mv64x60_get_64bit_window(mv64x60_handle_t *bh, u32 window, u32 *base_hi,
- u32 *base_lo, u32 *size);
-void mv64x60_set_64bit_window(mv64x60_handle_t *bh, u32 window, u32 base_hi,
- u32 base_lo, u32 size, u32 other_bits);
-
-
-void gt64260_init_irq(void);
-int gt64260_get_irq(struct pt_regs *regs);
-
-/*
- * OCP Related Definitions
- */
-typedef struct {
- u8 mirror_regs;
- u8 cache_mgmt;
- u8 max_idle;
- int default_baud;
- int default_bits;
- int default_parity;
- int default_flow;
- u32 chr_1_val;
- u32 chr_2_val;
- u32 chr_10_val;
- u32 mpcr_val;
- u32 mrr_val;
- u32 rcrr_val;
- u32 tcrr_val;
- u32 intr_mask_val;
- u32 bcr_val;
- u32 sdma_irq;
- u8 brg_can_tune;
- u8 brg_clk_src;
- u32 brg_clk_freq;
-} mv64x60_ocp_mpsc_data_t;
-
-#define MV64x60_OCP_SYSFS_MPSC_DATA() \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, mirror_regs) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, cache_mgmt) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, max_idle) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, default_baud) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, default_bits) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%c\n", mpsc, default_parity) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%c\n", mpsc, default_flow) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_1_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_2_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, chr_10_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, mpcr_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, mrr_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, rcrr_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, tcrr_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, intr_mask_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "0x%x\n", mpsc, bcr_val) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, sdma_irq) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_can_tune) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_clk_src) \
-OCP_SYSFS_ADDTL(mv64x60_ocp_mpsc_data_t, "%d\n", mpsc, brg_clk_freq) \
- \
-void \
-mv64x60_ocp_show_mpsc(struct device *dev) \
-{ \
- device_create_file(dev, &dev_attr_mpsc_mirror_regs); \
- device_create_file(dev, &dev_attr_mpsc_cache_mgmt); \
- device_create_file(dev, &dev_attr_mpsc_max_idle); \
- device_create_file(dev, &dev_attr_mpsc_default_baud); \
- device_create_file(dev, &dev_attr_mpsc_default_bits); \
- device_create_file(dev, &dev_attr_mpsc_default_parity); \
- device_create_file(dev, &dev_attr_mpsc_default_flow); \
- device_create_file(dev, &dev_attr_mpsc_chr_1_val); \
- device_create_file(dev, &dev_attr_mpsc_chr_2_val); \
- device_create_file(dev, &dev_attr_mpsc_chr_10_val); \
- device_create_file(dev, &dev_attr_mpsc_mpcr_val); \
- device_create_file(dev, &dev_attr_mpsc_mrr_val); \
- device_create_file(dev, &dev_attr_mpsc_rcrr_val); \
- device_create_file(dev, &dev_attr_mpsc_tcrr_val); \
- device_create_file(dev, &dev_attr_mpsc_intr_mask_val); \
- device_create_file(dev, &dev_attr_mpsc_bcr_val); \
- device_create_file(dev, &dev_attr_mpsc_sdma_irq); \
- device_create_file(dev, &dev_attr_mpsc_brg_can_tune); \
- device_create_file(dev, &dev_attr_mpsc_brg_clk_src); \
- device_create_file(dev, &dev_attr_mpsc_brg_clk_freq); \
-}
-
-#endif /* __ASMPPC_MV64x60_H */
+++ /dev/null
-/*
- * include/asm-ppc/gt64260_defs.h
- *
- * Register definitions for the Marvell/Galileo GT64260, MV64360, etc.
- * host bridges.
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-#ifndef __ASMPPC_MV64x60_DEFS_H
-#define __ASMPPC_MV64x60_DEFS_H
-
-/*
- * Define the Marvell bridges that are supported
- */
-#define MV64x60_TYPE_INVALID 0
-#define MV64x60_TYPE_GT64260A 1
-#define MV64x60_TYPE_GT64260B 2
-#define MV64x60_TYPE_MV64360 3
-#define MV64x60_TYPE_MV64361 4
-#define MV64x60_TYPE_MV64362 5
-#define MV64x60_TYPE_MV64460 6
-
-
-/* Revisions of each supported chip */
-#define GT64260_REV_A 0x10
-#define GT64260_REV_B 0x20
-#define MV64360 0x01
-#define MV64460 0x01
-
-/* Minimum window size supported by 64260 is 1MB */
-#define GT64260_WINDOW_SIZE_MIN 0x00100000
-#define MV64360_WINDOW_SIZE_MIN 0x00010000
-
-/* IRQ's for embedded controllers */
-#define MV64x60_IRQ_DEV 1
-#define MV64x60_IRQ_CPU_ERR 3
-#define MV64x60_IRQ_TIMER_0_1 8
-#define MV64x60_IRQ_TIMER_2_3 9
-#define MV64x60_IRQ_TIMER_4_5 10
-#define MV64x60_IRQ_TIMER_6_7 11
-#define MV64x60_IRQ_ETH_0 32
-#define MV64x60_IRQ_ETH_1 33
-#define MV64x60_IRQ_ETH_2 34
-#define MV64x60_IRQ_SDMA_0 36
-#define MV64x60_IRQ_I2C 37
-#define MV64x60_IRQ_SDMA_1 38
-#define MV64x60_IRQ_BRG 39
-#define MV64x60_IRQ_MPSC_0 40
-#define MV64x60_IRQ_MPSC_1 42
-#define MV64x60_IRQ_COMM 43
-
-#define MV64360_IRQ_PCI0 12
-#define MV64360_IRQ_SRAM_PAR_ERR 13
-#define MV64360_IRQ_PCI1 16
-
-/* Offsets for register blocks */
-#define MV64x60_MPSC_0_OFFSET 0x8000
-#define MV64x60_MPSC_1_OFFSET 0x9000
-#define MV64x60_MPSC_ROUTING_OFFSET 0xb400
-#define MV64x60_SDMA_0_OFFSET 0x4000
-#define MV64x60_SDMA_1_OFFSET 0x6000
-#define MV64x60_SDMA_INTR_OFFSET 0xb800
-#define MV64x60_BRG_0_OFFSET 0xb200
-#define MV64x60_BRG_1_OFFSET 0xb208
-
-/*
- *****************************************************************************
- *
- * CPU Interface Registers
- *
- *****************************************************************************
- */
-
-/* CPU physical address of 64260's registers */
-#define MV64x60_INTERNAL_SPACE_DECODE 0x0068
-#define MV64x60_INTERNAL_SPACE_SIZE 0x10000
-#define MV64x60_INTERNAL_SPACE_DEFAULT_ADDR 0x14000000
-
-#define MV64360_CPU_BAR_ENABLE 0x0278
-
-/* CPU Memory Controller Window Registers (4 windows) */
-#define MV64x60_CPU2MEM_WINDOWS 4
-
-#define MV64x60_CPU2MEM_0_BASE 0x0008
-#define MV64x60_CPU2MEM_0_SIZE 0x0010
-#define MV64x60_CPU2MEM_1_BASE 0x0208
-#define MV64x60_CPU2MEM_1_SIZE 0x0210
-#define MV64x60_CPU2MEM_2_BASE 0x0018
-#define MV64x60_CPU2MEM_2_SIZE 0x0020
-#define MV64x60_CPU2MEM_3_BASE 0x0218
-#define MV64x60_CPU2MEM_3_SIZE 0x0220
-
-/* CPU Device Controller Window Registers (4 windows) */
-#define MV64x60_CPU2DEV_CS_WINDOWS 4
-
-#define MV64x60_CPU2DEV_0_BASE 0x0028
-#define MV64x60_CPU2DEV_0_SIZE 0x0030
-#define MV64x60_CPU2DEV_1_BASE 0x0228
-#define MV64x60_CPU2DEV_1_SIZE 0x0230
-#define MV64x60_CPU2DEV_2_BASE 0x0248
-#define MV64x60_CPU2DEV_2_SIZE 0x0250
-#define MV64x60_CPU2DEV_3_BASE 0x0038
-#define MV64x60_CPU2DEV_3_SIZE 0x0040
-
-#define MV64x60_CPU2BOOT_0_BASE 0x0238
-#define MV64x60_CPU2BOOT_0_SIZE 0x0240
-
-/* CPU Windows to PCI space (2 PCI buses each w/ 1 I/O & 4 MEM windows) */
-#define MV64x60_PCI_BUSES 2
-#define MV64x60_PCI_IO_WINDOWS_PER_BUS 1
-#define MV64x60_PCI_MEM_WINDOWS_PER_BUS 4
-
-#define MV64x60_CPU2PCI_SWAP_BYTE 0x00000000
-#define MV64x60_CPU2PCI_SWAP_NONE 0x01000000
-#define MV64x60_CPU2PCI_SWAP_BYTE_WORD 0x02000000
-#define MV64x60_CPU2PCI_SWAP_WORD 0x03000000
-
-#define MV64x60_CPU2PCI_MEM_REQ64 (1<<27)
-
-#define MV64x60_CPU2PCI0_IO_BASE 0x0048
-#define MV64x60_CPU2PCI0_IO_SIZE 0x0050
-#define MV64x60_CPU2PCI0_MEM_0_BASE 0x0058
-#define MV64x60_CPU2PCI0_MEM_0_SIZE 0x0060
-#define MV64x60_CPU2PCI0_MEM_1_BASE 0x0080
-#define MV64x60_CPU2PCI0_MEM_1_SIZE 0x0088
-#define MV64x60_CPU2PCI0_MEM_2_BASE 0x0258
-#define MV64x60_CPU2PCI0_MEM_2_SIZE 0x0260
-#define MV64x60_CPU2PCI0_MEM_3_BASE 0x0280
-#define MV64x60_CPU2PCI0_MEM_3_SIZE 0x0288
-
-#define MV64x60_CPU2PCI0_IO_REMAP 0x00f0
-#define MV64x60_CPU2PCI0_MEM_0_REMAP_LO 0x00f8
-#define MV64x60_CPU2PCI0_MEM_0_REMAP_HI 0x0320
-#define MV64x60_CPU2PCI0_MEM_1_REMAP_LO 0x0100
-#define MV64x60_CPU2PCI0_MEM_1_REMAP_HI 0x0328
-#define MV64x60_CPU2PCI0_MEM_2_REMAP_LO 0x02f8
-#define MV64x60_CPU2PCI0_MEM_2_REMAP_HI 0x0330
-#define MV64x60_CPU2PCI0_MEM_3_REMAP_LO 0x0300
-#define MV64x60_CPU2PCI0_MEM_3_REMAP_HI 0x0338
-
-#define MV64x60_CPU2PCI1_IO_BASE 0x0090
-#define MV64x60_CPU2PCI1_IO_SIZE 0x0098
-#define MV64x60_CPU2PCI1_MEM_0_BASE 0x00a0
-#define MV64x60_CPU2PCI1_MEM_0_SIZE 0x00a8
-#define MV64x60_CPU2PCI1_MEM_1_BASE 0x00b0
-#define MV64x60_CPU2PCI1_MEM_1_SIZE 0x00b8
-#define MV64x60_CPU2PCI1_MEM_2_BASE 0x02a0
-#define MV64x60_CPU2PCI1_MEM_2_SIZE 0x02a8
-#define MV64x60_CPU2PCI1_MEM_3_BASE 0x02b0
-#define MV64x60_CPU2PCI1_MEM_3_SIZE 0x02b8
-
-#define MV64360_CPU2SRAM_BASE 0x0268
-
-#define MV64x60_CPU2PCI1_IO_REMAP 0x0108
-#define MV64x60_CPU2PCI1_MEM_0_REMAP_LO 0x0110
-#define MV64x60_CPU2PCI1_MEM_0_REMAP_HI 0x0340
-#define MV64x60_CPU2PCI1_MEM_1_REMAP_LO 0x0118
-#define MV64x60_CPU2PCI1_MEM_1_REMAP_HI 0x0348
-#define MV64x60_CPU2PCI1_MEM_2_REMAP_LO 0x0310
-#define MV64x60_CPU2PCI1_MEM_2_REMAP_HI 0x0350
-#define MV64x60_CPU2PCI1_MEM_3_REMAP_LO 0x0318
-#define MV64x60_CPU2PCI1_MEM_3_REMAP_HI 0x0358
-
-/* CPU Control Registers */
-#define MV64x60_CPU_CONFIG 0x0000
-#define MV64x60_CPU_MODE 0x0120
-#define MV64x60_CPU_MASTER_CNTL 0x0160
-#define MV64x60_CPU_XBAR_CNTL_LO 0x0150
-#define MV64x60_CPU_XBAR_CNTL_HI 0x0158
-#define MV64x60_CPU_XBAR_TO 0x0168
-
-#define GT64260_CPU_RR_XBAR_CNTL_LO 0x0170
-#define GT64260_CPU_RR_XBAR_CNTL_HI 0x0178
-
-#define MV64360_CPU_PADS_CALIBRATION 0x03b4
-#define MV64360_CPU_RESET_SAMPLE_LO 0x03c4
-#define MV64360_CPU_RESET_SAMPLE_HI 0x03d4
-
-/* SMP Register Map */
-#define MV64360_WHO_AM_I 0x0200
-#define MV64360_CPU0_DOORBELL 0x0214
-#define MV64360_CPU0_DOORBELL_CLR 0x021c
-#define MV64360_CPU0_DOORBELL_MASK 0x0234
-#define MV64360_CPU1_DOORBELL 0x0224
-#define MV64360_CPU1_DOORBELL_CLR 0x022c
-#define MV64360_CPU1_DOORBELL_MASK 0x023c
-#define MV64360_CPUx_DOORBELL(x) (0x0214 + ((x)*0x10))
-#define MV64360_CPUx_DOORBELL_CLR(x) (0x021c + ((x)*0x10))
-#define MV64360_CPUx_DOORBELL_MASK(x) (0x0234 + ((x)*0x08))
-#define MV64360_SEMAPHORE_0 0x0244
-#define MV64360_SEMAPHORE_1 0x024c
-#define MV64360_SEMAPHORE_2 0x0254
-#define MV64360_SEMAPHORE_3 0x025c
-#define MV64360_SEMAPHORE_4 0x0264
-#define MV64360_SEMAPHORE_5 0x026c
-#define MV64360_SEMAPHORE_6 0x0274
-#define MV64360_SEMAPHORE_7 0x027c
-
-/* CPU Sync Barrier Registers */
-#define GT64260_CPU_SYNC_BARRIER_PCI0 0x00c0
-#define GT64260_CPU_SYNC_BARRIER_PCI1 0x00c8
-
-#define MV64360_CPU0_SYNC_BARRIER_TRIG 0x00c0
-#define MV64360_CPU0_SYNC_BARRIER_VIRT 0x00c8
-#define MV64360_CPU1_SYNC_BARRIER_TRIG 0x00d0
-#define MV64360_CPU1_SYNC_BARRIER_VIRT 0x00d8
-
-/* CPU Deadlock and Ordering registers (Rev B part only) */
-#define GT64260_CPU_DEADLOCK_ORDERING 0x02d0
-#define GT64260_CPU_WB_PRIORITY_BUFFER_DEPTH 0x02d8
-#define GT64260_CPU_COUNTERS_SYNC_BARRIER_ATTRIBUTE 0x02e0
-
-/* CPU Access Protection Registers (gt64260 realy has 8 but don't need) */
-#define MV64x260_CPU_PROT_WINDOWS 4
-
-#define GT64260_CPU_PROT_ACCPROTECT (1<<16)
-#define GT64260_CPU_PROT_WRPROTECT (1<<17)
-#define GT64260_CPU_PROT_CACHEPROTECT (1<<18)
-
-#define MV64360_CPU_PROT_ACCPROTECT (1<<20)
-#define MV64360_CPU_PROT_WRPROTECT (1<<21)
-#define MV64360_CPU_PROT_CACHEPROTECT (1<<22)
-#define MV64360_CPU_PROT_WIN_ENABLE (1<<31)
-
-#define MV64x60_CPU_PROT_BASE_0 0x0180
-#define MV64x60_CPU_PROT_SIZE_0 0x0188
-#define MV64x60_CPU_PROT_BASE_1 0x0190
-#define MV64x60_CPU_PROT_SIZE_1 0x0198
-#define MV64x60_CPU_PROT_BASE_2 0x01a0
-#define MV64x60_CPU_PROT_SIZE_2 0x01a8
-#define MV64x60_CPU_PROT_BASE_3 0x01b0
-#define MV64x60_CPU_PROT_SIZE_3 0x01b8
-
-#define GT64260_CPU_PROT_BASE_4 0x01c0
-#define GT64260_CPU_PROT_SIZE_4 0x01c8
-#define GT64260_CPU_PROT_BASE_5 0x01d0
-#define GT64260_CPU_PROT_SIZE_5 0x01d8
-#define GT64260_CPU_PROT_BASE_6 0x01e0
-#define GT64260_CPU_PROT_SIZE_6 0x01e8
-#define GT64260_CPU_PROT_BASE_7 0x01f0
-#define GT64260_CPU_PROT_SIZE_7 0x01f8
-
-/* CPU Snoop Control Registers (64260 only) */
-#define GT64260_CPU_SNOOP_WINDOWS 4
-
-#define GT64260_CPU_SNOOP_NONE 0x00000000
-#define GT64260_CPU_SNOOP_WT 0x00010000
-#define GT64260_CPU_SNOOP_WB 0x00020000
-#define GT64260_CPU_SNOOP_MASK 0x00030000
-#define GT64260_CPU_SNOOP_ALL_BITS GT64260_CPU_SNOOP_MASK
-
-#define GT64260_CPU_SNOOP_BASE_0 0x0380
-#define GT64260_CPU_SNOOP_SIZE_0 0x0388
-#define GT64260_CPU_SNOOP_BASE_1 0x0390
-#define GT64260_CPU_SNOOP_SIZE_1 0x0398
-#define GT64260_CPU_SNOOP_BASE_2 0x03a0
-#define GT64260_CPU_SNOOP_SIZE_2 0x03a8
-#define GT64260_CPU_SNOOP_BASE_3 0x03b0
-#define GT64260_CPU_SNOOP_SIZE_3 0x03b8
-
-/* CPU Error Report Registers */
-#define MV64x60_CPU_ERR_ADDR_LO 0x0070
-#define MV64x60_CPU_ERR_ADDR_HI 0x0078
-#define MV64x60_CPU_ERR_DATA_LO 0x0128
-#define MV64x60_CPU_ERR_DATA_HI 0x0130
-#define MV64x60_CPU_ERR_PARITY 0x0138
-#define MV64x60_CPU_ERR_CAUSE 0x0140
-#define MV64x60_CPU_ERR_MASK 0x0148
-
-/*
- *****************************************************************************
- *
- * SRAM Cotnroller Registers
- *
- *****************************************************************************
- */
-
-#define MV64360_SRAM_CONFIG 0x0380
-#define MV64360_SRAM_TEST_MODE 0x03f4
-#define MV64360_SRAM_ERR_CAUSE 0x0388
-#define MV64360_SRAM_ERR_ADDR_LO 0x0390
-#define MV64360_SRAM_ERR_ADDR_HI 0x03f8
-#define MV64360_SRAM_ERR_DATA_LO 0x0398
-#define MV64360_SRAM_ERR_DATA_HI 0x03a0
-#define MV64360_SRAM_ERR_PARITY 0x03a8
-
-
-/*
- *****************************************************************************
- *
- * SDRAM Cotnroller Registers
- *
- *****************************************************************************
- */
-
-/* SDRAM Config Registers (64260) */
-#define GT64260_SDRAM_CONFIG 0x0448
-
-/* SDRAM Error Report Registers (64260) */
-#define GT64260_SDRAM_ERR_DATA_LO 0x0484
-#define GT64260_SDRAM_ERR_DATA_HI 0x0480
-#define GT64260_SDRAM_ERR_ADDR 0x0490
-#define GT64260_SDRAM_ERR_ECC_RCVD 0x0488
-#define GT64260_SDRAM_ERR_ECC_CALC 0x048c
-#define GT64260_SDRAM_ERR_ECC_CNTL 0x0494
-#define GT64260_SDRAM_ERR_ECC_ERR_CNT 0x0498
-
-/* SDRAM Config Registers (64360) */
-#define MV64360_SDRAM_CONFIG 0x1400
-
-/* SDRAM Error Report Registers (64360) */
-#define MV64360_SDRAM_ERR_DATA_LO 0x1444
-#define MV64360_SDRAM_ERR_DATA_HI 0x1440
-#define MV64360_SDRAM_ERR_ADDR 0x1450
-#define MV64360_SDRAM_ERR_ECC_RCVD 0x1448
-#define MV64360_SDRAM_ERR_ECC_CALC 0x144c
-#define MV64360_SDRAM_ERR_ECC_CNTL 0x1454
-#define MV64360_SDRAM_ERR_ECC_ERR_CNT 0x1458
-
-
-/*
- *****************************************************************************
- *
- * Device/BOOT Cotnroller Registers
- *
- *****************************************************************************
- */
-
-/* Device Control Registers */
-#define MV64x60_DEV_BANK_PARAMS_0 0x045c
-#define MV64x60_DEV_BANK_PARAMS_1 0x0460
-#define MV64x60_DEV_BANK_PARAMS_2 0x0464
-#define MV64x60_DEV_BANK_PARAMS_3 0x0468
-#define MV64x60_DEV_BOOT_PARAMS 0x046c
-#define MV64x60_DEV_IF_CNTL 0x04c0
-#define MV64x60_DEV_IF_XBAR_CNTL_LO 0x04c8
-#define MV64x60_DEV_IF_XBAR_CNTL_HI 0x04cc
-#define MV64x60_DEV_IF_XBAR_CNTL_TO 0x04c4
-
-/* Device Interrupt Registers */
-#define MV64x60_DEV_INTR_CAUSE 0x04d0
-#define MV64x60_DEV_INTR_MASK 0x04d4
-#define MV64x60_DEV_INTR_ERR_ADDR 0x04d8
-
-#define MV64360_DEV_INTR_ERR_DATA 0x04dc
-#define MV64360_DEV_INTR_ERR_PAR 0x04e0
-
-
-/*
- *****************************************************************************
- *
- * PCI Bridge Interface Registers
- *
- *****************************************************************************
- */
-
-/* PCI Configuration Access Registers */
-#define MV64x60_PCI0_CONFIG_ADDR 0x0cf8
-#define MV64x60_PCI0_CONFIG_DATA 0x0cfc
-#define MV64x60_PCI0_IACK 0x0c34
-
-#define MV64x60_PCI1_CONFIG_ADDR 0x0c78
-#define MV64x60_PCI1_CONFIG_DATA 0x0c7c
-#define MV64x60_PCI1_IACK 0x0cb4
-
-/* PCI Control Registers */
-#define MV64x60_PCI0_CMD 0x0c00
-#define MV64x60_PCI0_MODE 0x0d00
-#define MV64x60_PCI0_TO_RETRY 0x0c04
-#define MV64x60_PCI0_RD_BUF_DISCARD_TIMER 0x0d04
-#define MV64x60_PCI0_MSI_TRIGGER_TIMER 0x0c38
-#define MV64x60_PCI0_ARBITER_CNTL 0x1d00
-#define MV64x60_PCI0_XBAR_CNTL_LO 0x1d08
-#define MV64x60_PCI0_XBAR_CNTL_HI 0x1d0c
-#define MV64x60_PCI0_XBAR_CNTL_TO 0x1d04
-#define MV64x60_PCI0_RD_RESP_XBAR_CNTL_LO 0x1d18
-#define MV64x60_PCI0_RD_RESP_XBAR_CNTL_HI 0x1d1c
-#define MV64x60_PCI0_SYNC_BARRIER 0x1d10
-#define MV64x60_PCI0_P2P_CONFIG 0x1d14
-#define MV64x60_PCI0_INTR_MASK
-
-#define GT64260_PCI0_P2P_SWAP_CNTL 0x1d54
-
-#define MV64x60_PCI1_CMD 0x0c80
-#define MV64x60_PCI1_MODE 0x0d80
-#define MV64x60_PCI1_TO_RETRY 0x0c84
-#define MV64x60_PCI1_RD_BUF_DISCARD_TIMER 0x0d84
-#define MV64x60_PCI1_MSI_TRIGGER_TIMER 0x0cb8
-#define MV64x60_PCI1_ARBITER_CNTL 0x1d80
-#define MV64x60_PCI1_XBAR_CNTL_LO 0x1d88
-#define MV64x60_PCI1_XBAR_CNTL_HI 0x1d8c
-#define MV64x60_PCI1_XBAR_CNTL_TO 0x1d84
-#define MV64x60_PCI1_RD_RESP_XBAR_CNTL_LO 0x1d98
-#define MV64x60_PCI1_RD_RESP_XBAR_CNTL_HI 0x1d9c
-#define MV64x60_PCI1_SYNC_BARRIER 0x1d90
-#define MV64x60_PCI1_P2P_CONFIG 0x1d94
-
-#define GT64260_PCI1_P2P_SWAP_CNTL 0x1dd4
-
-/* PCI Access Control Regions Registers */
-#define GT64260_PCI_ACC_CNTL_PREFETCHEN (1<<12)
-#define GT64260_PCI_ACC_CNTL_DREADEN (1<<13)
-#define GT64260_PCI_ACC_CNTL_RDPREFETCH (1<<16)
-#define GT64260_PCI_ACC_CNTL_RDLINEPREFETCH (1<<17)
-#define GT64260_PCI_ACC_CNTL_RDMULPREFETCH (1<<18)
-#define GT64260_PCI_ACC_CNTL_MBURST_32_BTYES 0x00000000
-#define GT64260_PCI_ACC_CNTL_MBURST_64_BYTES 0x00100000
-#define GT64260_PCI_ACC_CNTL_MBURST_128_BYTES 0x00200000
-#define GT64260_PCI_ACC_CNTL_MBURST_MASK 0x00300000
-#define GT64260_PCI_ACC_CNTL_SWAP_BYTE 0x00000000
-#define GT64260_PCI_ACC_CNTL_SWAP_NONE 0x01000000
-#define GT64260_PCI_ACC_CNTL_SWAP_BYTE_WORD 0x02000000
-#define GT64260_PCI_ACC_CNTL_SWAP_WORD 0x03000000
-#define GT64260_PCI_ACC_CNTL_SWAP_MASK 0x03000000
-#define GT64260_PCI_ACC_CNTL_ACCPROT (1<<28)
-#define GT64260_PCI_ACC_CNTL_WRPROT (1<<29)
-
-#define GT64260_PCI_ACC_CNTL_ALL_BITS (GT64260_PCI_ACC_CNTL_PREFETCHEN | \
- GT64260_PCI_ACC_CNTL_DREADEN | \
- GT64260_PCI_ACC_CNTL_RDPREFETCH | \
- GT64260_PCI_ACC_CNTL_RDLINEPREFETCH |\
- GT64260_PCI_ACC_CNTL_RDMULPREFETCH | \
- GT64260_PCI_ACC_CNTL_MBURST_MASK | \
- GT64260_PCI_ACC_CNTL_SWAP_MASK | \
- GT64260_PCI_ACC_CNTL_ACCPROT| \
- GT64260_PCI_ACC_CNTL_WRPROT)
-
-#define MV64360_PCI_ACC_CNTL_ENABLE (1<<0)
-#define MV64360_PCI_ACC_CNTL_REQ64 (1<<1)
-#define MV64360_PCI_ACC_CNTL_SNOOP_NONE 0x00000000
-#define MV64360_PCI_ACC_CNTL_SNOOP_WT 0x00000004
-#define MV64360_PCI_ACC_CNTL_SNOOP_WB 0x00000008
-#define MV64360_PCI_ACC_CNTL_SNOOP_MASK 0x0000000c
-#define MV64360_PCI_ACC_CNTL_ACCPROT (1<<4)
-#define MV64360_PCI_ACC_CNTL_WRPROT (1<<5)
-#define MV64360_PCI_ACC_CNTL_SWAP_BYTE 0x00000000
-#define MV64360_PCI_ACC_CNTL_SWAP_NONE 0x00000040
-#define MV64360_PCI_ACC_CNTL_SWAP_BYTE_WORD 0x00000080
-#define MV64360_PCI_ACC_CNTL_SWAP_WORD 0x000000c0
-#define MV64360_PCI_ACC_CNTL_SWAP_MASK 0x000000c0
-#define MV64360_PCI_ACC_CNTL_MBURST_32_BYTES 0x00000000
-#define MV64360_PCI_ACC_CNTL_MBURST_64_BYTES 0x00000100
-#define MV64360_PCI_ACC_CNTL_MBURST_128_BYTES 0x00000200
-#define MV64360_PCI_ACC_CNTL_MBURST_MASK 0x00000300
-#define MV64360_PCI_ACC_CNTL_RDSIZE_32_BYTES 0x00000000
-#define MV64360_PCI_ACC_CNTL_RDSIZE_64_BYTES 0x00000400
-#define MV64360_PCI_ACC_CNTL_RDSIZE_128_BYTES 0x00000800
-#define MV64360_PCI_ACC_CNTL_RDSIZE_256_BYTES 0x00000c00
-#define MV64360_PCI_ACC_CNTL_RDSIZE_MASK 0x00000c00
-
-#define MV64360_PCI_ACC_CNTL_ALL_BITS (MV64360_PCI_ACC_CNTL_ENABLE | \
- MV64360_PCI_ACC_CNTL_REQ64 | \
- MV64360_PCI_ACC_CNTL_SNOOP_MASK | \
- MV64360_PCI_ACC_CNTL_ACCPROT | \
- MV64360_PCI_ACC_CNTL_WRPROT | \
- MV64360_PCI_ACC_CNTL_SWAP_MASK | \
- MV64360_PCI_ACC_CNTL_MBURST_MASK | \
- MV64360_PCI_ACC_CNTL_RDSIZE_MASK)
-
-#define MV64x60_PCI0_ACC_CNTL_0_BASE_LO 0x1e00
-#define MV64x60_PCI0_ACC_CNTL_0_BASE_HI 0x1e04
-#define MV64x60_PCI0_ACC_CNTL_0_SIZE 0x1e08
-#define MV64x60_PCI0_ACC_CNTL_1_BASE_LO 0x1e10
-#define MV64x60_PCI0_ACC_CNTL_1_BASE_HI 0x1e14
-#define MV64x60_PCI0_ACC_CNTL_1_SIZE 0x1e18
-#define MV64x60_PCI0_ACC_CNTL_2_BASE_LO 0x1e20
-#define MV64x60_PCI0_ACC_CNTL_2_BASE_HI 0x1e24
-#define MV64x60_PCI0_ACC_CNTL_2_SIZE 0x1e28
-#define MV64x60_PCI0_ACC_CNTL_3_BASE_LO 0x1e30
-#define MV64x60_PCI0_ACC_CNTL_3_BASE_HI 0x1e34
-#define MV64x60_PCI0_ACC_CNTL_3_SIZE 0x1e38
-#define MV64x60_PCI0_ACC_CNTL_4_BASE_LO 0x1e40
-#define MV64x60_PCI0_ACC_CNTL_4_BASE_HI 0x1e44
-#define MV64x60_PCI0_ACC_CNTL_4_SIZE 0x1e48
-#define MV64x60_PCI0_ACC_CNTL_5_BASE_LO 0x1e50
-#define MV64x60_PCI0_ACC_CNTL_5_BASE_HI 0x1e54
-#define MV64x60_PCI0_ACC_CNTL_5_SIZE 0x1e58
-
-#define GT64260_PCI0_ACC_CNTL_6_BASE_LO 0x1e60
-#define GT64260_PCI0_ACC_CNTL_6_BASE_HI 0x1e64
-#define GT64260_PCI0_ACC_CNTL_6_SIZE 0x1e68
-#define GT64260_PCI0_ACC_CNTL_7_BASE_LO 0x1e70
-#define GT64260_PCI0_ACC_CNTL_7_BASE_HI 0x1e74
-#define GT64260_PCI0_ACC_CNTL_7_SIZE 0x1e78
-
-#define MV64x60_PCI1_ACC_CNTL_0_BASE_LO 0x1e80
-#define MV64x60_PCI1_ACC_CNTL_0_BASE_HI 0x1e84
-#define MV64x60_PCI1_ACC_CNTL_0_SIZE 0x1e88
-#define MV64x60_PCI1_ACC_CNTL_1_BASE_LO 0x1e90
-#define MV64x60_PCI1_ACC_CNTL_1_BASE_HI 0x1e94
-#define MV64x60_PCI1_ACC_CNTL_1_SIZE 0x1e98
-#define MV64x60_PCI1_ACC_CNTL_2_BASE_LO 0x1ea0
-#define MV64x60_PCI1_ACC_CNTL_2_BASE_HI 0x1ea4
-#define MV64x60_PCI1_ACC_CNTL_2_SIZE 0x1ea8
-#define MV64x60_PCI1_ACC_CNTL_3_BASE_LO 0x1eb0
-#define MV64x60_PCI1_ACC_CNTL_3_BASE_HI 0x1eb4
-#define MV64x60_PCI1_ACC_CNTL_3_SIZE 0x1eb8
-#define MV64x60_PCI1_ACC_CNTL_4_BASE_LO 0x1ec0
-#define MV64x60_PCI1_ACC_CNTL_4_BASE_HI 0x1ec4
-#define MV64x60_PCI1_ACC_CNTL_4_SIZE 0x1ec8
-#define MV64x60_PCI1_ACC_CNTL_5_BASE_LO 0x1ed0
-#define MV64x60_PCI1_ACC_CNTL_5_BASE_HI 0x1ed4
-#define MV64x60_PCI1_ACC_CNTL_5_SIZE 0x1ed8
-
-#define GT64260_PCI1_ACC_CNTL_6_BASE_LO 0x1ee0
-#define GT64260_PCI1_ACC_CNTL_6_BASE_HI 0x1ee4
-#define GT64260_PCI1_ACC_CNTL_6_SIZE 0x1ee8
-#define GT64260_PCI1_ACC_CNTL_7_BASE_LO 0x1ef0
-#define GT64260_PCI1_ACC_CNTL_7_BASE_HI 0x1ef4
-#define GT64260_PCI1_ACC_CNTL_7_SIZE 0x1ef8
-
-/* PCI Snoop Control Registers (64260 only) */
-#define GT64260_PCI_SNOOP_NONE 0x00000000
-#define GT64260_PCI_SNOOP_WT 0x00001000
-#define GT64260_PCI_SNOOP_WB 0x00002000
-
-#define GT64260_PCI0_SNOOP_0_BASE_LO 0x1f00
-#define GT64260_PCI0_SNOOP_0_BASE_HI 0x1f04
-#define GT64260_PCI0_SNOOP_0_SIZE 0x1f08
-#define GT64260_PCI0_SNOOP_1_BASE_LO 0x1f10
-#define GT64260_PCI0_SNOOP_1_BASE_HI 0x1f14
-#define GT64260_PCI0_SNOOP_1_SIZE 0x1f18
-#define GT64260_PCI0_SNOOP_2_BASE_LO 0x1f20
-#define GT64260_PCI0_SNOOP_2_BASE_HI 0x1f24
-#define GT64260_PCI0_SNOOP_2_SIZE 0x1f28
-#define GT64260_PCI0_SNOOP_3_BASE_LO 0x1f30
-#define GT64260_PCI0_SNOOP_3_BASE_HI 0x1f34
-#define GT64260_PCI0_SNOOP_3_SIZE 0x1f38
-
-#define GT64260_PCI1_SNOOP_0_BASE_LO 0x1f80
-#define GT64260_PCI1_SNOOP_0_BASE_HI 0x1f84
-#define GT64260_PCI1_SNOOP_0_SIZE 0x1f88
-#define GT64260_PCI1_SNOOP_1_BASE_LO 0x1f90
-#define GT64260_PCI1_SNOOP_1_BASE_HI 0x1f94
-#define GT64260_PCI1_SNOOP_1_SIZE 0x1f98
-#define GT64260_PCI1_SNOOP_2_BASE_LO 0x1fa0
-#define GT64260_PCI1_SNOOP_2_BASE_HI 0x1fa4
-#define GT64260_PCI1_SNOOP_2_SIZE 0x1fa8
-#define GT64260_PCI1_SNOOP_3_BASE_LO 0x1fb0
-#define GT64260_PCI1_SNOOP_3_BASE_HI 0x1fb4
-#define GT64260_PCI1_SNOOP_3_SIZE 0x1fb8
-
-/* PCI Error Report Registers */
-#define MV64x60_PCI0_ERR_SERR_MASK 0x0c28
-#define MV64x60_PCI0_ERR_ADDR_LO 0x1d40
-#define MV64x60_PCI0_ERR_ADDR_HI 0x1d44
-#define MV64x60_PCI0_ERR_DATA_LO 0x1d48
-#define MV64x60_PCI0_ERR_DATA_HI 0x1d4c
-#define MV64x60_PCI0_ERR_CMD 0x1d50
-#define MV64x60_PCI0_ERR_CAUSE 0x1d58
-#define MV64x60_PCI0_ERR_MASK 0x1d5c
-
-#define MV64x60_PCI1_ERR_SERR_MASK 0x0ca8
-#define MV64x60_PCI1_ERR_ADDR_LO 0x1dc0
-#define MV64x60_PCI1_ERR_ADDR_HI 0x1dc4
-#define MV64x60_PCI1_ERR_DATA_LO 0x1dc8
-#define MV64x60_PCI1_ERR_DATA_HI 0x1dcc
-#define MV64x60_PCI1_ERR_CMD 0x1dd0
-#define MV64x60_PCI1_ERR_CAUSE 0x1dd8
-#define MV64x60_PCI1_ERR_MASK 0x1ddc
-
-/* PCI Slave Address Decoding Registers */
-#define MV64x60_PCI0_MEM_0_SIZE 0x0c08
-#define MV64x60_PCI0_MEM_1_SIZE 0x0d08
-#define MV64x60_PCI0_MEM_2_SIZE 0x0c0c
-#define MV64x60_PCI0_MEM_3_SIZE 0x0d0c
-#define MV64x60_PCI1_MEM_0_SIZE 0x0c88
-#define MV64x60_PCI1_MEM_1_SIZE 0x0d88
-#define MV64x60_PCI1_MEM_2_SIZE 0x0c8c
-#define MV64x60_PCI1_MEM_3_SIZE 0x0d8c
-
-#define MV64x60_PCI0_BAR_ENABLE 0x0c3c
-#define MV64x60_PCI1_BAR_ENABLE 0x0cbc
-
-#define MV64x60_PCI0_PCI_DECODE_CNTL 0x0d3c
-
-
-
-
-
-#define MV64x60_PCI0_SLAVE_BAR_REG_ENABLES 0x0c3c
-#define MV64x60_PCI0_SLAVE_MEM_0_REMAP 0x0c48
-#define MV64x60_PCI0_SLAVE_MEM_1_REMAP 0x0d48
-#define MV64x60_PCI0_SLAVE_MEM_2_REMAP 0x0c4c
-#define MV64x60_PCI0_SLAVE_MEM_3_REMAP 0x0d4c
-#define MV64x60_PCI0_SLAVE_CS_0_REMAP 0x0c50
-#define MV64x60_PCI0_SLAVE_CS_1_REMAP 0x0d50
-#define MV64x60_PCI0_SLAVE_CS_2_REMAP 0x0d58
-#define MV64x60_PCI0_SLAVE_CS_3_REMAP 0x0c54
-#define MV64x60_PCI0_SLAVE_BOOT_REMAP 0x0d54
-#define MV64x60_PCI0_SLAVE_P2P_MEM_0_REMAP_LO 0x0d5c
-#define MV64x60_PCI0_SLAVE_P2P_MEM_0_REMAP_HI 0x0d60
-#define MV64x60_PCI0_SLAVE_P2P_MEM_1_REMAP_LO 0x0d64
-#define MV64x60_PCI0_SLAVE_P2P_MEM_1_REMAP_HI 0x0d68
-#define MV64x60_PCI0_SLAVE_P2P_IO_REMAP 0x0d6c
-#define MV64x60_PCI0_SLAVE_CPU_REMAP 0x0d70
-
-#define GT64260_PCI0_SLAVE_DAC_SCS_0_REMAP 0x0f00
-#define GT64260_PCI0_SLAVE_DAC_SCS_1_REMAP 0x0f04
-#define GT64260_PCI0_SLAVE_DAC_SCS_2_REMAP 0x0f08
-#define GT64260_PCI0_SLAVE_DAC_SCS_3_REMAP 0x0f0c
-#define GT64260_PCI0_SLAVE_DAC_CS_0_REMAP 0x0f10
-#define GT64260_PCI0_SLAVE_DAC_CS_1_REMAP 0x0f14
-#define GT64260_PCI0_SLAVE_DAC_CS_2_REMAP 0x0f18
-#define GT64260_PCI0_SLAVE_DAC_CS_3_REMAP 0x0f1c
-#define GT64260_PCI0_SLAVE_DAC_BOOT_REMAP 0x0f20
-#define GT64260_PCI0_SLAVE_DAC_P2P_MEM_0_REMAP_LO 0x0f24
-#define GT64260_PCI0_SLAVE_DAC_P2P_MEM_0_REMAP_HI 0x0f28
-#define GT64260_PCI0_SLAVE_DAC_P2P_MEM_1_REMAP_LO 0x0f2c
-#define GT64260_PCI0_SLAVE_DAC_P2P_MEM_1_REMAP_HI 0x0f30
-#define GT64260_PCI0_SLAVE_DAC_CPU_REMAP 0x0f34
-
-#define GT64260_PCI0_SLAVE_EXP_ROM_REMAP 0x0f38
-#define GT64260_PCI0_SLAVE_PCI_DECODE_CNTL 0x0d3c
-
-
-
-
-
-/* XXXX BEGIN */
-#define MV64x60_PCI1_PCI_DECODE_CNTL 0x0dbc
-
-#define MV64x60_PCI1_SLAVE_MEM_0_SIZE 0x0c88
-#define MV64x60_PCI1_SLAVE_MEM_1_SIZE 0x0d88
-#define MV64x60_PCI1_SLAVE_MEM_2_SIZE 0x0c8c
-#define MV64x60_PCI1_SLAVE_MEM_3_SIZE 0x0d8c
-#define MV64x60_PCI1_SLAVE_CS_0_SIZE 0x0c90
-#define MV64x60_PCI1_SLAVE_CS_1_SIZE 0x0d90
-#define MV64x60_PCI1_SLAVE_CS_2_SIZE 0x0d98
-#define MV64x60_PCI1_SLAVE_CS_3_SIZE 0x0c94
-#define MV64x60_PCI1_SLAVE_BOOT_SIZE 0x0d94
-#define MV64x60_PCI1_SLAVE_P2P_MEM_0_SIZE 0x0d9c
-#define MV64x60_PCI1_SLAVE_P2P_MEM_1_SIZE 0x0da0
-#define MV64x60_PCI1_SLAVE_P2P_IO_SIZE 0x0da4
-#define MV64x60_PCI1_SLAVE_CPU_SIZE 0x0da8
-
-
-/* XXXXX END */
-
-
-#define GT64260_PCI1_SLAVE_DAC_SCS_0_SIZE 0x0e80
-#define GT64260_PCI1_SLAVE_DAC_SCS_1_SIZE 0x0e84
-#define GT64260_PCI1_SLAVE_DAC_SCS_2_SIZE 0x0e88
-#define GT64260_PCI1_SLAVE_DAC_SCS_3_SIZE 0x0e8c
-#define GT64260_PCI1_SLAVE_DAC_CS_0_SIZE 0x0e90
-#define GT64260_PCI1_SLAVE_DAC_CS_1_SIZE 0x0e94
-#define GT64260_PCI1_SLAVE_DAC_CS_2_SIZE 0x0e98
-#define GT64260_PCI1_SLAVE_DAC_CS_3_SIZE 0x0e9c
-#define GT64260_PCI1_SLAVE_DAC_BOOT_SIZE 0x0ea0
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_SIZE 0x0ea4
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_SIZE 0x0ea8
-#define GT64260_PCI1_SLAVE_DAC_CPU_SIZE 0x0eac
-
-#define GT64260_PCI1_SLAVE_EXP_ROM_SIZE 0x0dac
-
-
-
-
-/* XXXX BEGIN */
-
-#define MV64x60_PCI1_SLAVE_BAR_REG_ENABLES 0x0cbc
-#define MV64x60_PCI1_SLAVE_MEM_0_REMAP 0x0cc8
-#define MV64x60_PCI1_SLAVE_MEM_1_REMAP 0x0dc8
-#define MV64x60_PCI1_SLAVE_MEM_2_REMAP 0x0ccc
-#define MV64x60_PCI1_SLAVE_MEM_3_REMAP 0x0dcc
-#define MV64x60_PCI1_SLAVE_CS_0_REMAP 0x0cd0
-#define MV64x60_PCI1_SLAVE_CS_1_REMAP 0x0dd0
-#define MV64x60_PCI1_SLAVE_CS_2_REMAP 0x0dd8
-#define MV64x60_PCI1_SLAVE_CS_3_REMAP 0x0cd4
-#define MV64x60_PCI1_SLAVE_BOOT_REMAP 0x0dd4
-#define MV64x60_PCI1_SLAVE_P2P_MEM_0_REMAP_LO 0x0ddc
-#define MV64x60_PCI1_SLAVE_P2P_MEM_0_REMAP_HI 0x0de0
-#define MV64x60_PCI1_SLAVE_P2P_MEM_1_REMAP_LO 0x0de4
-#define MV64x60_PCI1_SLAVE_P2P_MEM_1_REMAP_HI 0x0de8
-#define MV64x60_PCI1_SLAVE_P2P_IO_REMAP 0x0dec
-#define MV64x60_PCI1_SLAVE_CPU_REMAP 0x0df0
-
-/* XXXXX END */
-
-
-
-#define GT64260_PCI1_SLAVE_DAC_SCS_0_REMAP 0x0f80
-#define GT64260_PCI1_SLAVE_DAC_SCS_1_REMAP 0x0f84
-#define GT64260_PCI1_SLAVE_DAC_SCS_2_REMAP 0x0f88
-#define GT64260_PCI1_SLAVE_DAC_SCS_3_REMAP 0x0f8c
-#define GT64260_PCI1_SLAVE_DAC_CS_0_REMAP 0x0f90
-#define GT64260_PCI1_SLAVE_DAC_CS_1_REMAP 0x0f94
-#define GT64260_PCI1_SLAVE_DAC_CS_2_REMAP 0x0f98
-#define GT64260_PCI1_SLAVE_DAC_CS_3_REMAP 0x0f9c
-#define GT64260_PCI1_SLAVE_DAC_BOOT_REMAP 0x0fa0
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_REMAP_LO 0x0fa4
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_0_REMAP_HI 0x0fa8
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_REMAP_LO 0x0fac
-#define GT64260_PCI1_SLAVE_DAC_P2P_MEM_1_REMAP_HI 0x0fb0
-#define GT64260_PCI1_SLAVE_DAC_CPU_REMAP 0x0fb4
-
-#define GT64260_PCI1_SLAVE_EXP_ROM_REMAP 0x0fb8
-#define GT64260_PCI1_SLAVE_PCI_DECODE_CNTL 0x0dbc
-
-
-/*
- *****************************************************************************
- *
- * Timer/Counter Interface Registers
- *
- *****************************************************************************
- */
-
-#define MV64x60_TIMR_CNTR_0 0x0850
-#define MV64x60_TIMR_CNTR_1 0x0854
-#define MV64x60_TIMR_CNTR_2 0x0858
-#define MV64x60_TIMR_CNTR_3 0x085c
-#define MV64x60_TIMR_CNTR_0_3_CNTL 0x0864
-#define MV64x60_TIMR_CNTR_0_3_INTR_CAUSE 0x0868
-#define MV64x60_TIMR_CNTR_0_3_INTR_MASK 0x086c
-
-#define GT64260_TIMR_CNTR_4 0x0950
-#define GT64260_TIMR_CNTR_5 0x0954
-#define GT64260_TIMR_CNTR_6 0x0958
-#define GT64260_TIMR_CNTR_7 0x095c
-#define GT64260_TIMR_CNTR_4_7_CNTL 0x0964
-#define GT64260_TIMR_CNTR_4_7_INTR_CAUSE 0x0968
-#define GT64260_TIMR_CNTR_4_7_INTR_MASK 0x096c
-
-
-/*
- *****************************************************************************
- *
- * Communications Controller (Enet, Serial, etc.) Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_COMM_ENET_0_OFFSET 0xf200
-#define GT64260_COMM_ENET_1_OFFSET 0xf220
-#define GT64260_COMM_ENET_2_OFFSET 0xf240
-
-#define GT64260_ENET_CNTL_LO \
- (0xf200 - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_CNTL_HI \
- (0xf204 - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_RX_BUF_PCI_ADDR_HI \
- (0xf208 - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_TX_BUF_PCI_ADDR_HI \
- (0xf20c - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_RX_DESC_ADDR_HI \
- (0xf210 - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_TX_DESC_ADDR_HI \
- (0xf214 - GT64260_COMM_ENET_0_BASE)
-#define GT64260_ENET_HASH_TAB_PCI_ADDR_HI \
- (0xf218 - GT64260_COMM_ENET_0_BASE)
-
-#define GT64260_COMM_MPSC_0_OFFSET 0xf280
-#define GT64260_COMM_MPSC_1_OFFSET 0xf2c0
-
-#define GT64260_MPSC_CNTL_LO \
- (0xf280 - GT64260_COMM_MPSC_0_BASE)
-#define GT64260_MPSC_CNTL_HI \
- (0xf284 - GT64260_COMM_MPSC_0_BASE)
-#define GT64260_MPSC_RX_BUF_PCI_ADDR_HI \
- (0xf288 - GT64260_COMM_MPSC_0_BASE)
-#define GT64260_MPSC_TX_BUF_PCI_ADDR_HI \
- (0xf28c - GT64260_COMM_MPSC_0_BASE)
-#define GT64260_MPSC_RX_DESC_ADDR_HI \
- (0xf290 - GT64260_COMM_MPSC_0_BASE)
-#define GT64260_MPSC_TX_DESC_ADDR_HI \
- (0xf294 - GT64260_COMM_MPSC_0_BASE)
-
-#define GT64260_SER_INIT_PCI_ADDR_HI 0xf320
-#define GT64260_SER_INIT_LAST_DATA 0xf324
-#define GT64260_SER_INIT_CONTROL 0xf328
-#define GT64260_SER_INIT_STATUS 0xf32c
-
-#define GT64260_COMM_ARBITER_CNTL 0xf300
-#define GT64260_COMM_CONFIG 0xb40c
-#define GT64260_COMM_XBAR_TO 0xf304
-#define GT64260_COMM_INTR_CAUSE 0xf310
-#define GT64260_COMM_INTR_MASK 0xf314
-#define GT64260_COMM_ERR_ADDR 0xf318
-
-
-/*
- *****************************************************************************
- *
- * Fast Ethernet Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_ENET_PHY_ADDR 0x2000
-#define GT64260_ENET_ESMIR 0x2010
-
-#define GT64260_ENET_0_OFFSET 0x2400
-#define GT64260_ENET_1_OFFSET 0x2800
-#define GT64260_ENET_2_OFFSET 0x2c00
-
-#define GT64260_ENET_EPCR (0x2400 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EPCXR (0x2408 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EPCMR (0x2410 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EPSR (0x2418 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ESPR (0x2420 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EHTPR (0x2428 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFCSAL (0x2430 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFCSAH (0x2438 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ESDCR (0x2440 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ESDCMR (0x2448 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EICR (0x2450 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EIMR (0x2458 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFRDP0 (0x2480 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFRDP1 (0x2484 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFRDP2 (0x2488 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_EFRDP3 (0x248c - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECRDP0 (0x24a0 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECRDP1 (0x24a4 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECRDP2 (0x24a8 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECRDP3 (0x24ac - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECTDP0 (0x24e0 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_ECTDP1 (0x24e4 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_DSCP2P0L (0x2460 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_DSCP2P0H (0x2464 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_DSCP2P1L (0x2468 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_DSCP2P1H (0x246c - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_VPT2P (0x2470 - GT64260_ENET_0_OFFSET)
-#define GT64260_ENET_MIB_CTRS (0x2500 - GT64260_ENET_0_OFFSET)
-
-/*
- *****************************************************************************
- *
- * IDMA Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_IDMA_0_OFFSET 0x0800
-#define GT64260_IDMA_1_OFFSET 0x0804
-#define GT64260_IDMA_2_OFFSET 0x0808
-#define GT64260_IDMA_3_OFFSET 0x080c
-#define GT64260_IDMA_4_OFFSET 0x0900
-#define GT64260_IDMA_5_OFFSET 0x0904
-#define GT64260_IDMA_6_OFFSET 0x0908
-#define GT64260_IDMA_7_OFFSET 0x090c
-
-#define GT64260_IDMA_BYTE_COUNT (0x0800 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_SRC_ADDR (0x0810 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_DST_ADDR (0x0820 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_NEXT_DESC (0x0830 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_CUR_DESC (0x0870 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_SRC_PCI_ADDR_HI (0x0890 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_DST_PCI_ADDR_HI (0x08a0 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_NEXT_DESC_PCI_ADDR_HI (0x08b0 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_CONTROL_LO (0x0840 - GT64260_IDMA_0_OFFSET)
-#define GT64260_IDMA_CONTROL_HI (0x0880 - GT64260_IDMA_0_OFFSET)
-
-#define GT64260_IDMA_0_3_ARBITER_CNTL 0x0860
-#define GT64260_IDMA_4_7_ARBITER_CNTL 0x0960
-
-#define GT64260_IDMA_0_3_XBAR_TO 0x08d0
-#define GT64260_IDMA_4_7_XBAR_TO 0x09d0
-
-#define GT64260_IDMA_0_3_INTR_CAUSE 0x08c0
-#define GT64260_IDMA_0_3_INTR_MASK 0x08c4
-#define GT64260_IDMA_0_3_ERROR_ADDR 0x08c8
-#define GT64260_IDMA_0_3_ERROR_SELECT 0x08cc
-#define GT64260_IDMA_4_7_INTR_CAUSE 0x09c0
-#define GT64260_IDMA_4_7_INTR_MASK 0x09c4
-#define GT64260_IDMA_4_7_ERROR_ADDR 0x09c8
-#define GT64260_IDMA_4_7_ERROR_SELECT 0x09cc
-
-/*
- *****************************************************************************
- *
- * Watchdog Timer Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_WDT_WDC 0xb410
-#define GT64260_WDT_WDV 0xb414
-
-
-/*
- *****************************************************************************
- *
- * General Purpose Pins Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define MV64x60_GPP_IO_CNTL 0xf100
-#define MV64x60_GPP_LEVEL_CNTL 0xf110
-#define MV64x60_GPP_VALUE 0xf104
-#define MV64x60_GPP_INTR_CAUSE 0xf108
-#define MV64x60_GPP_INTR_MASK 0xf10c
-
-
-/*
- *****************************************************************************
- *
- * Multi-Purpose Pins Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define MV64x60_MPP_CNTL_0 0xf000
-#define MV64x60_MPP_CNTL_1 0xf004
-#define MV64x60_MPP_CNTL_2 0xf008
-#define MV64x60_MPP_CNTL_3 0xf00c
-#define GT64260_MPP_SERIAL_PORTS_MULTIPLEX 0xf010
-
-
-/*
- *****************************************************************************
- *
- * I2C Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_I2C_OFFSET 0xc000
-
-#define GT64260_I2C_ADDR (0xc000 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_EX_ADDR (0xc010 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_DATA (0xc004 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_CONTROL (0xc008 - GT64260_I2C_OFFSET)
-#define GT64260_I2C_STATUS (0xc00c - GT64260_I2C_OFFSET)
-#define GT64260_I2C_BAUD_RATE (0xc00c - GT64260_I2C_OFFSET)
-#define GT64260_I2C_RESET (0xc01c - GT64260_I2C_OFFSET)
-
-#define GT64260_I2C_ACK_BIT (1<<2)
-#define GT64260_I2C_IFLG_BIT (1<<3)
-#define GT64260_I2C_STOP_BIT (1<<4)
-#define GT64260_I2C_START_BIT (1<<5)
-#define GT64260_I2C_ENABLE_BIT (1<<6)
-#define GT64260_I2C_INT_ENABLE_BIT (1<<7)
-
-#define GT64260_I2C_DATA_READ_BIT 0x01
-
-#define GT64260_I2C_STATUS_SENT_START 0x08
-#define GT64260_I2C_STATUS_RESENT_START 0x10
-#define GT64260_I2C_STATUS_WRITE_ADDR_ACK 0x18
-#define GT64260_I2C_STATUS_WRITE_ACK 0x28
-#define GT64260_I2C_STATUS_READ_ADDR_ACK 0x40
-#define GT64260_I2C_STATUS_READ_ACK 0x50
-#define GT64260_I2C_STATUS_READ_NO_ACK 0x58
-#define GT64260_I2C_STATUS_IDLE 0xf8
-
-
-/*
- *****************************************************************************
- *
- * Interrupt Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define GT64260_IC_OFFSET 0x0c18
-
-#define GT64260_IC_MAIN_CAUSE_LO (0x0c18 - GT64260_IC_OFFSET)
-#define GT64260_IC_MAIN_CAUSE_HI (0x0c68 - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INTR_MASK_LO (0x0c1c - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INTR_MASK_HI (0x0c6c - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_SELECT_CAUSE (0x0c70 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI0_INTR_MASK_LO (0x0c24 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI0_INTR_MASK_HI (0x0c64 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI0_SELECT_CAUSE (0x0c74 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI1_INTR_MASK_LO (0x0ca4 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI1_INTR_MASK_HI (0x0ce4 - GT64260_IC_OFFSET)
-#define GT64260_IC_PCI1_SELECT_CAUSE (0x0cf4 - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INT_0_MASK (0x0e60 - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INT_1_MASK (0x0e64 - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INT_2_MASK (0x0e68 - GT64260_IC_OFFSET)
-#define GT64260_IC_CPU_INT_3_MASK (0x0e6c - GT64260_IC_OFFSET)
-
-#define MV64360_IC_OFFSET 0x0000
-
-#define MV64360_IC_MAIN_CAUSE_LO (0x0004 - MV64360_IC_OFFSET)
-#define MV64360_IC_MAIN_CAUSE_HI (0x000c - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU0_INTR_MASK_LO (0x0014 - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU0_INTR_MASK_HI (0x001c - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU0_SELECT_CAUSE (0x0024 - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU1_INTR_MASK_LO (0x0034 - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU1_INTR_MASK_HI (0x003c - MV64360_IC_OFFSET)
-#define MV64360_IC_CPU1_SELECT_CAUSE (0x0044 - MV64360_IC_OFFSET)
-#define MV64360_IC_INT0_MASK_LO (0x0054 - MV64360_IC_OFFSET)
-#define MV64360_IC_INT0_MASK_HI (0x005c - MV64360_IC_OFFSET)
-#define MV64360_IC_INT0_SELECT_CAUSE (0x0064 - MV64360_IC_OFFSET)
-#define MV64360_IC_INT1_MASK_LO (0x0074 - MV64360_IC_OFFSET)
-#define MV64360_IC_INT1_MASK_HI (0x007c - MV64360_IC_OFFSET)
-#define MV64360_IC_INT1_SELECT_CAUSE (0x0084 - MV64360_IC_OFFSET)
-
-#endif /* __ASMPPC_MV64x60_DEFS_H */
+++ /dev/null
-/*
- * Author: Pete Popov <ppopov@mvista.com>
- *
- * 2000 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- *
- * Data structures specific to the IBM PowerPC 405 on-chip DMA controller
- * and API.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASMPPC_405_DMA_H
-#define __ASMPPC_405_DMA_H
-
-#include <linux/types.h>
-
-/* #define DEBUG_405DMA */
-
-#define TRUE 1
-#define FALSE 0
-
-#define SGL_LIST_SIZE 4096
-/* #define PCI_ALLOC_IS_NONCONSISTENT */
-
-#define MAX_405GP_DMA_CHANNELS 4
-
-/* The maximum address that we can perform a DMA transfer to on this platform */
-/* Doesn't really apply... */
-#define MAX_DMA_ADDRESS 0xFFFFFFFF
-
-extern unsigned long ISA_DMA_THRESHOLD;
-
-#define dma_outb outb
-#define dma_inb inb
-
-
-/*
- * Function return status codes
- * These values are used to indicate whether or not the function
- * call was successful, or a bad/invalid parameter was passed.
- */
-#define DMA_STATUS_GOOD 0
-#define DMA_STATUS_BAD_CHANNEL 1
-#define DMA_STATUS_BAD_HANDLE 2
-#define DMA_STATUS_BAD_MODE 3
-#define DMA_STATUS_NULL_POINTER 4
-#define DMA_STATUS_OUT_OF_MEMORY 5
-#define DMA_STATUS_SGL_LIST_EMPTY 6
-#define DMA_STATUS_GENERAL_ERROR 7
-
-
-/*
- * These indicate status as returned from the DMA Status Register.
- */
-#define DMA_STATUS_NO_ERROR 0
-#define DMA_STATUS_CS 1 /* Count Status */
-#define DMA_STATUS_TS 2 /* Transfer Status */
-#define DMA_STATUS_DMA_ERROR 3 /* DMA Error Occurred */
-#define DMA_STATUS_DMA_BUSY 4 /* The channel is busy */
-
-
-/*
- * Transfer Modes
- * These modes are defined in a way that makes it possible to
- * simply "or" in the value in the control register.
- */
-#define DMA_MODE_READ DMA_TD /* Peripheral to Memory */
-#define DMA_MODE_WRITE 0 /* Memory to Peripheral */
-#define DMA_MODE_MM (SET_DMA_TM(TM_S_MM)) /* memory to memory */
-
- /* Device-paced memory to memory, */
- /* device is at source address */
-#define DMA_MODE_MM_DEVATSRC (DMA_TD | SET_DMA_TM(TM_D_MM))
-
- /* Device-paced memory to memory, */
- /* device is at destination address */
-#define DMA_MODE_MM_DEVATDST (SET_DMA_TM(TM_D_MM))
-
-
-/*
- * DMA Polarity Configuration Register
- */
-#define DMAReq0_ActiveLow (1<<31)
-#define DMAAck0_ActiveLow (1<<30)
-#define EOT0_ActiveLow (1<<29) /* End of Transfer */
-
-#define DMAReq1_ActiveLow (1<<28)
-#define DMAAck1_ActiveLow (1<<27)
-#define EOT1_ActiveLow (1<<26)
-
-#define DMAReq2_ActiveLow (1<<25)
-#define DMAAck2_ActiveLow (1<<24)
-#define EOT2_ActiveLow (1<<23)
-
-#define DMAReq3_ActiveLow (1<<22)
-#define DMAAck3_ActiveLow (1<<21)
-#define EOT3_ActiveLow (1<<20)
-
-/*
- * DMA Sleep Mode Register
- */
-#define SLEEP_MODE_ENABLE (1<<21)
-
-
-/*
- * DMA Status Register
- */
-#define DMA_CS0 (1<<31) /* Terminal Count has been reached */
-#define DMA_CS1 (1<<30)
-#define DMA_CS2 (1<<29)
-#define DMA_CS3 (1<<28)
-
-#define DMA_TS0 (1<<27) /* End of Transfer has been requested */
-#define DMA_TS1 (1<<26)
-#define DMA_TS2 (1<<25)
-#define DMA_TS3 (1<<24)
-
-#define DMA_CH0_ERR (1<<23) /* DMA Chanel 0 Error */
-#define DMA_CH1_ERR (1<<22)
-#define DMA_CH2_ERR (1<<21)
-#define DMA_CH3_ERR (1<<20)
-
-#define DMA_IN_DMA_REQ0 (1<<19) /* Internal DMA Request is pending */
-#define DMA_IN_DMA_REQ1 (1<<18)
-#define DMA_IN_DMA_REQ2 (1<<17)
-#define DMA_IN_DMA_REQ3 (1<<16)
-
-#define DMA_EXT_DMA_REQ0 (1<<15) /* External DMA Request is pending */
-#define DMA_EXT_DMA_REQ1 (1<<14)
-#define DMA_EXT_DMA_REQ2 (1<<13)
-#define DMA_EXT_DMA_REQ3 (1<<12)
-
-#define DMA_CH0_BUSY (1<<11) /* DMA Channel 0 Busy */
-#define DMA_CH1_BUSY (1<<10)
-#define DMA_CH2_BUSY (1<<9)
-#define DMA_CH3_BUSY (1<<8)
-
-#define DMA_SG0 (1<<7) /* DMA Channel 0 Scatter/Gather in progress */
-#define DMA_SG1 (1<<6)
-#define DMA_SG2 (1<<5)
-#define DMA_SG3 (1<<4)
-
-
-
-/*
- * DMA Channel Control Registers
- */
-#define DMA_CH_ENABLE (1<<31) /* DMA Channel Enable */
-#define SET_DMA_CH_ENABLE(x) (((x)&0x1)<<31)
-#define GET_DMA_CH_ENABLE(x) (((x)&DMA_CH_ENABLE)>>31)
-
-#define DMA_CIE_ENABLE (1<<30) /* DMA Channel Interrupt Enable */
-#define SET_DMA_CIE_ENABLE(x) (((x)&0x1)<<30)
-#define GET_DMA_CIE_ENABLE(x) (((x)&DMA_CIE_ENABLE)>>30)
-
-#define DMA_TD (1<<29)
-#define SET_DMA_TD(x) (((x)&0x1)<<29)
-#define GET_DMA_TD(x) (((x)&DMA_TD)>>29)
-
-#define DMA_PL (1<<28) /* Peripheral Location */
-#define SET_DMA_PL(x) (((x)&0x1)<<28)
-#define GET_DMA_PL(x) (((x)&DMA_PL)>>28)
-
-#define EXTERNAL_PERIPHERAL 0
-#define INTERNAL_PERIPHERAL 1
-
-
-#define SET_DMA_PW(x) (((x)&0x3)<<26) /* Peripheral Width */
-#define DMA_PW_MASK SET_DMA_PW(3)
-#define PW_8 0
-#define PW_16 1
-#define PW_32 2
-#define PW_64 3
-#define GET_DMA_PW(x) (((x)&DMA_PW_MASK)>>26)
-
-#define DMA_DAI (1<<25) /* Destination Address Increment */
-#define SET_DMA_DAI(x) (((x)&0x1)<<25)
-
-#define DMA_SAI (1<<24) /* Source Address Increment */
-#define SET_DMA_SAI(x) (((x)&0x1)<<24)
-
-#define DMA_BEN (1<<23) /* Buffer Enable */
-#define SET_DMA_BEN(x) (((x)&0x1)<<23)
-
-#define SET_DMA_TM(x) (((x)&0x3)<<21) /* Transfer Mode */
-#define DMA_TM_MASK SET_DMA_TM(3)
-#define TM_PERIPHERAL 0 /* Peripheral */
-#define TM_RESERVED 1 /* Reserved */
-#define TM_S_MM 2 /* Memory to Memory */
-#define TM_D_MM 3 /* Device Paced Memory to Memory */
-#define GET_DMA_TM(x) (((x)&DMA_TM_MASK)>>21)
-
-#define SET_DMA_PSC(x) (((x)&0x3)<<19) /* Peripheral Setup Cycles */
-#define DMA_PSC_MASK SET_DMA_PSC(3)
-#define GET_DMA_PSC(x) (((x)&DMA_PSC_MASK)>>19)
-
-#define SET_DMA_PWC(x) (((x)&0x3F)<<13) /* Peripheral Wait Cycles */
-#define DMA_PWC_MASK SET_DMA_PWC(0x3F)
-#define GET_DMA_PWC(x) (((x)&DMA_PWC_MASK)>>13)
-
-#define SET_DMA_PHC(x) (((x)&0x7)<<10) /* Peripheral Hold Cycles */
-#define DMA_PHC_MASK SET_DMA_PHC(0x7)
-#define GET_DMA_PHC(x) (((x)&DMA_PHC_MASK)>>10)
-
-#define DMA_ETD_OUTPUT (1<<9) /* EOT pin is a TC output */
-#define SET_DMA_ETD(x) (((x)&0x1)<<9)
-
-#define DMA_TCE_ENABLE (1<<8)
-#define SET_DMA_TCE(x) (((x)&0x1)<<8)
-
-#define SET_DMA_PRIORITY(x) (((x)&0x3)<<6) /* DMA Channel Priority */
-#define DMA_PRIORITY_MASK SET_DMA_PRIORITY(3)
-#define PRIORITY_LOW 0
-#define PRIORITY_MID_LOW 1
-#define PRIORITY_MID_HIGH 2
-#define PRIORITY_HIGH 3
-#define GET_DMA_PRIORITY(x) (((x)&DMA_PRIORITY_MASK)>>6)
-
-#define SET_DMA_PREFETCH(x) (((x)&0x3)<<4) /* Memory Read Prefetch */
-#define DMA_PREFETCH_MASK SET_DMA_PREFETCH(3)
-#define PREFETCH_1 0 /* Prefetch 1 Double Word */
-#define PREFETCH_2 1
-#define PREFETCH_4 2
-#define GET_DMA_PREFETCH(x) (((x)&DMA_PREFETCH_MASK)>>4)
-
-#define DMA_PCE (1<<3) /* Parity Check Enable */
-#define SET_DMA_PCE(x) (((x)&0x1)<<3)
-#define GET_DMA_PCE(x) (((x)&DMA_PCE)>>3)
-
-#define DMA_DEC (1<<2) /* Address Decrement */
-#define SET_DMA_DEC(x) (((x)&0x1)<<2)
-#define GET_DMA_DEC(x) (((x)&DMA_DEC)>>2)
-
-/*
- * DMA SG Command Register
- */
-#define SSG0_ENABLE (1<<31) /* Start Scatter Gather */
-#define SSG1_ENABLE (1<<30)
-#define SSG2_ENABLE (1<<29)
-#define SSG3_ENABLE (1<<28)
-#define SSG0_MASK_ENABLE (1<<15) /* Enable writing to SSG0 bit */
-#define SSG1_MASK_ENABLE (1<<14)
-#define SSG2_MASK_ENABLE (1<<13)
-#define SSG3_MASK_ENABLE (1<<12)
-
-
-/*
- * DMA Scatter/Gather Descriptor Bit fields
- */
-#define SG_LINK (1<<31) /* Link */
-#define SG_TCI_ENABLE (1<<29) /* Enable Terminal Count Interrupt */
-#define SG_ETI_ENABLE (1<<28) /* Enable End of Transfer Interrupt */
-#define SG_ERI_ENABLE (1<<27) /* Enable Error Interrupt */
-#define SG_COUNT_MASK 0xFFFF /* Count Field */
-
-
-
-
-typedef uint32_t sgl_handle_t;
-
-typedef struct {
-
- /*
- * Valid polarity settings:
- * DMAReq0_ActiveLow
- * DMAAck0_ActiveLow
- * EOT0_ActiveLow
- *
- * DMAReq1_ActiveLow
- * DMAAck1_ActiveLow
- * EOT1_ActiveLow
- *
- * DMAReq2_ActiveLow
- * DMAAck2_ActiveLow
- * EOT2_ActiveLow
- *
- * DMAReq3_ActiveLow
- * DMAAck3_ActiveLow
- * EOT3_ActiveLow
- */
- unsigned int polarity;
-
- char buffer_enable; /* Boolean: buffer enable */
- char tce_enable; /* Boolean: terminal count enable */
- char etd_output; /* Boolean: eot pin is a tc output */
- char pce; /* Boolean: parity check enable */
-
- /*
- * Peripheral location:
- * INTERNAL_PERIPHERAL (UART0 on the 405GP)
- * EXTERNAL_PERIPHERAL
- */
- char pl; /* internal/external peripheral */
-
- /*
- * Valid pwidth settings:
- * PW_8
- * PW_16
- * PW_32
- * PW_64
- */
- unsigned int pwidth;
-
- char dai; /* Boolean: dst address increment */
- char sai; /* Boolean: src address increment */
-
- /*
- * Valid psc settings: 0-3
- */
- unsigned int psc; /* Peripheral Setup Cycles */
-
- /*
- * Valid pwc settings:
- * 0-63
- */
- unsigned int pwc; /* Peripheral Wait Cycles */
-
- /*
- * Valid phc settings:
- * 0-7
- */
- unsigned int phc; /* Peripheral Hold Cycles */
-
- /*
- * Valid cp (channel priority) settings:
- * PRIORITY_LOW
- * PRIORITY_MID_LOW
- * PRIORITY_MID_HIGH
- * PRIORITY_HIGH
- */
- unsigned int cp; /* channel priority */
-
- /*
- * Valid pf (memory read prefetch) settings:
- *
- * PREFETCH_1
- * PREFETCH_2
- * PREFETCH_4
- */
- unsigned int pf; /* memory read prefetch */
-
- /*
- * Boolean: channel interrupt enable
- * NOTE: for sgl transfers, only the last descriptor will be setup to
- * interrupt.
- */
- char int_enable;
-
- char shift; /* easy access to byte_count shift, based on */
- /* the width of the channel */
-
- uint32_t control; /* channel control word */
-
-
- /* These variabled are used ONLY in single dma transfers */
- unsigned int mode; /* transfer mode */
- dma_addr_t addr;
-
-} ppc_dma_ch_t;
-
-
-typedef struct {
- uint32_t control;
- uint32_t src_addr;
- uint32_t dst_addr;
- uint32_t control_count;
- uint32_t next;
-} ppc_sgl_t;
-
-
-
-typedef struct {
- unsigned int dmanr;
- uint32_t control; /* channel ctrl word; loaded from each descrptr */
- uint32_t sgl_control; /* LK, TCI, ETI, and ERI bits in sgl descriptor */
- dma_addr_t dma_addr; /* dma (physical) address of this list */
- ppc_sgl_t *phead;
- ppc_sgl_t *ptail;
-
-} sgl_list_info_t;
-
-
-typedef struct {
- unsigned int *src_addr;
- unsigned int *dst_addr;
- dma_addr_t dma_src_addr;
- dma_addr_t dma_dst_addr;
-} pci_alloc_desc_t;
-
-
-extern ppc_dma_ch_t dma_channels[];
-
-/*
- *
- * DMA API inline functions
- * These functions are implemented here as inline functions for
- * performance reasons.
- *
- */
-
-static __inline__ int get_405gp_dma_status(void)
-{
- return (mfdcr(DCRN_DMASR));
-}
-
-
-static __inline__ int enable_405gp_dma(unsigned int dmanr)
-{
- unsigned int control;
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
- if (dmanr >= MAX_405GP_DMA_CHANNELS) {
- printk("enable_dma: bad channel: %d\n", dmanr);
- return DMA_STATUS_BAD_CHANNEL;
- }
-#endif
-
-
- switch (dmanr) {
- case 0:
- if (p_dma_ch->mode == DMA_MODE_READ) {
- /* peripheral to memory */
- mtdcr(DCRN_DMASA0, NULL);
- mtdcr(DCRN_DMADA0, p_dma_ch->addr);
- }
- else if (p_dma_ch->mode == DMA_MODE_WRITE) {
- /* memory to peripheral */
- mtdcr(DCRN_DMASA0, p_dma_ch->addr);
- mtdcr(DCRN_DMADA0, NULL);
- }
- /* for other xfer modes, the addresses are already set */
- control = mfdcr(DCRN_DMACR0);
- control &= ~(DMA_TM_MASK | DMA_TD); /* clear all mode bits */
- control |= (p_dma_ch->mode | DMA_CH_ENABLE);
- mtdcr(DCRN_DMACR0, control);
- break;
- case 1:
- if (p_dma_ch->mode == DMA_MODE_READ) {
- mtdcr(DCRN_DMASA1, NULL);
- mtdcr(DCRN_DMADA1, p_dma_ch->addr);
- } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
- mtdcr(DCRN_DMASA1, p_dma_ch->addr);
- mtdcr(DCRN_DMADA1, NULL);
- }
- control = mfdcr(DCRN_DMACR1);
- control &= ~(DMA_TM_MASK | DMA_TD);
- control |= (p_dma_ch->mode | DMA_CH_ENABLE);
- mtdcr(DCRN_DMACR1, control);
- break;
- case 2:
- if (p_dma_ch->mode == DMA_MODE_READ) {
- mtdcr(DCRN_DMASA2, NULL);
- mtdcr(DCRN_DMADA2, p_dma_ch->addr);
- } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
- mtdcr(DCRN_DMASA2, p_dma_ch->addr);
- mtdcr(DCRN_DMADA2, NULL);
- }
- control = mfdcr(DCRN_DMACR2);
- control &= ~(DMA_TM_MASK | DMA_TD);
- control |= (p_dma_ch->mode | DMA_CH_ENABLE);
- mtdcr(DCRN_DMACR2, control);
- break;
- case 3:
- if (p_dma_ch->mode == DMA_MODE_READ) {
- mtdcr(DCRN_DMASA3, NULL);
- mtdcr(DCRN_DMADA3, p_dma_ch->addr);
- } else if (p_dma_ch->mode == DMA_MODE_WRITE) {
- mtdcr(DCRN_DMASA3, p_dma_ch->addr);
- mtdcr(DCRN_DMADA3, NULL);
- }
- control = mfdcr(DCRN_DMACR3);
- control &= ~(DMA_TM_MASK | DMA_TD);
- control |= (p_dma_ch->mode | DMA_CH_ENABLE);
- mtdcr(DCRN_DMACR3, control);
- break;
- default:
- return DMA_STATUS_BAD_CHANNEL;
- }
- return DMA_STATUS_GOOD;
-}
-
-
-
-static __inline__ void disable_405gp_dma(unsigned int dmanr)
-{
- unsigned int control;
-
- switch (dmanr) {
- case 0:
- control = mfdcr(DCRN_DMACR0);
- control &= ~DMA_CH_ENABLE;
- mtdcr(DCRN_DMACR0, control);
- break;
- case 1:
- control = mfdcr(DCRN_DMACR1);
- control &= ~DMA_CH_ENABLE;
- mtdcr(DCRN_DMACR1, control);
- break;
- case 2:
- control = mfdcr(DCRN_DMACR2);
- control &= ~DMA_CH_ENABLE;
- mtdcr(DCRN_DMACR2, control);
- break;
- case 3:
- control = mfdcr(DCRN_DMACR3);
- control &= ~DMA_CH_ENABLE;
- mtdcr(DCRN_DMACR3, control);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("disable_dma: bad channel: %d\n", dmanr);
-#endif
- }
-}
-
-
-
-/*
- * Sets the dma mode for single DMA transfers only.
- * For scatter/gather transfers, the mode is passed to the
- * alloc_dma_handle() function as one of the parameters.
- *
- * The mode is simply saved and used later. This allows
- * the driver to call set_dma_mode() and set_dma_addr() in
- * any order.
- *
- * Valid mode values are:
- *
- * DMA_MODE_READ peripheral to memory
- * DMA_MODE_WRITE memory to peripheral
- * DMA_MODE_MM memory to memory
- * DMA_MODE_MM_DEVATSRC device-paced memory to memory, device at src
- * DMA_MODE_MM_DEVATDST device-paced memory to memory, device at dst
- */
-static __inline__ int set_405gp_dma_mode(unsigned int dmanr, unsigned int mode)
-{
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
- switch (mode) {
- case DMA_MODE_READ:
- case DMA_MODE_WRITE:
- case DMA_MODE_MM:
- case DMA_MODE_MM_DEVATSRC:
- case DMA_MODE_MM_DEVATDST:
- break;
- default:
- printk("set_dma_mode: bad mode 0x%x\n", mode);
- return DMA_STATUS_BAD_MODE;
- }
- if (dmanr >= MAX_405GP_DMA_CHANNELS) {
- printk("set_dma_mode: bad channel 0x%x\n", dmanr);
- return DMA_STATUS_BAD_CHANNEL;
- }
-#endif
-
- p_dma_ch->mode = mode;
- return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Sets the DMA Count register. Note that 'count' is in bytes.
- * However, the DMA Count register counts the number of "transfers",
- * where each transfer is equal to the bus width. Thus, count
- * MUST be a multiple of the bus width.
- */
-static __inline__ void
-set_405gp_dma_count(unsigned int dmanr, unsigned int count)
-{
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
-#ifdef DEBUG_405DMA
- {
- int error = 0;
- switch(p_dma_ch->pwidth) {
- case PW_8:
- break;
- case PW_16:
- if (count & 0x1)
- error = 1;
- break;
- case PW_32:
- if (count & 0x3)
- error = 1;
- break;
- case PW_64:
- if (count & 0x7)
- error = 1;
- break;
- default:
- printk("set_dma_count: invalid bus width: 0x%x\n",
- p_dma_ch->pwidth);
- return;
- }
- if (error)
- printk("Warning: set_dma_count count 0x%x bus width %d\n",
- count, p_dma_ch->pwidth);
- }
-#endif
-
- count = count >> p_dma_ch->shift;
- switch (dmanr) {
- case 0:
- mtdcr(DCRN_DMACT0, count);
- break;
- case 1:
- mtdcr(DCRN_DMACT1, count);
- break;
- case 2:
- mtdcr(DCRN_DMACT2, count);
- break;
- case 3:
- mtdcr(DCRN_DMACT3, count);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("set_dma_count: bad channel: %d\n", dmanr);
-#endif
- }
-}
-
-
-
-/*
- * Returns the number of bytes left to be transfered.
- * After a DMA transfer, this should return zero.
- * Reading this while a DMA transfer is still in progress will return
- * unpredictable results.
- */
-static __inline__ int get_405gp_dma_residue(unsigned int dmanr)
-{
- unsigned int count;
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
- switch (dmanr) {
- case 0:
- count = mfdcr(DCRN_DMACT0);
- break;
- case 1:
- count = mfdcr(DCRN_DMACT1);
- break;
- case 2:
- count = mfdcr(DCRN_DMACT2);
- break;
- case 3:
- count = mfdcr(DCRN_DMACT3);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("get_dma_residue: bad channel: %d\n", dmanr);
-#endif
- return 0;
- }
-
- return (count << p_dma_ch->shift);
-}
-
-
-
-/*
- * Sets the DMA address for a memory to peripheral or peripheral
- * to memory transfer. The address is just saved in the channel
- * structure for now and used later in enable_dma().
- */
-static __inline__ void set_405gp_dma_addr(unsigned int dmanr, dma_addr_t addr)
-{
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-#ifdef DEBUG_405DMA
- {
- int error = 0;
- switch(p_dma_ch->pwidth) {
- case PW_8:
- break;
- case PW_16:
- if ((unsigned)addr & 0x1)
- error = 1;
- break;
- case PW_32:
- if ((unsigned)addr & 0x3)
- error = 1;
- break;
- case PW_64:
- if ((unsigned)addr & 0x7)
- error = 1;
- break;
- default:
- printk("set_dma_addr: invalid bus width: 0x%x\n",
- p_dma_ch->pwidth);
- return;
- }
- if (error)
- printk("Warning: set_dma_addr addr 0x%x bus width %d\n",
- addr, p_dma_ch->pwidth);
- }
-#endif
-
- /* save dma address and program it later after we know the xfer mode */
- p_dma_ch->addr = addr;
-}
-
-
-
-
-/*
- * Sets both DMA addresses for a memory to memory transfer.
- * For memory to peripheral or peripheral to memory transfers
- * the function set_dma_addr() should be used instead.
- */
-static __inline__ void
-set_405gp_dma_addr2(unsigned int dmanr, dma_addr_t src_dma_addr,
- dma_addr_t dst_dma_addr)
-{
-#ifdef DEBUG_405DMA
- {
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
- int error = 0;
- switch(p_dma_ch->pwidth) {
- case PW_8:
- break;
- case PW_16:
- if (((unsigned)src_dma_addr & 0x1) ||
- ((unsigned)dst_dma_addr & 0x1)
- )
- error = 1;
- break;
- case PW_32:
- if (((unsigned)src_dma_addr & 0x3) ||
- ((unsigned)dst_dma_addr & 0x3)
- )
- error = 1;
- break;
- case PW_64:
- if (((unsigned)src_dma_addr & 0x7) ||
- ((unsigned)dst_dma_addr & 0x7)
- )
- error = 1;
- break;
- default:
- printk("set_dma_addr2: invalid bus width: 0x%x\n",
- p_dma_ch->pwidth);
- return;
- }
- if (error)
- printk("Warning: set_dma_addr2 src 0x%x dst 0x%x bus width %d\n",
- src_dma_addr, dst_dma_addr, p_dma_ch->pwidth);
- }
-#endif
-
- switch (dmanr) {
- case 0:
- mtdcr(DCRN_DMASA0, src_dma_addr);
- mtdcr(DCRN_DMADA0, dst_dma_addr);
- break;
- case 1:
- mtdcr(DCRN_DMASA1, src_dma_addr);
- mtdcr(DCRN_DMADA1, dst_dma_addr);
- break;
- case 2:
- mtdcr(DCRN_DMASA2, src_dma_addr);
- mtdcr(DCRN_DMADA2, dst_dma_addr);
- break;
- case 3:
- mtdcr(DCRN_DMASA3, src_dma_addr);
- mtdcr(DCRN_DMADA3, dst_dma_addr);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("set_dma_addr2: bad channel: %d\n", dmanr);
-#endif
- }
-}
-
-
-
-/*
- * Enables the channel interrupt.
- *
- * If performing a scatter/gatter transfer, this function
- * MUST be called before calling alloc_dma_handle() and building
- * the sgl list. Otherwise, interrupts will not be enabled, if
- * they were previously disabled.
- */
-static __inline__ int
-enable_405gp_dma_interrupt(unsigned int dmanr)
-{
- unsigned int control;
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
- p_dma_ch->int_enable = TRUE;
- switch (dmanr) {
- case 0:
- control = mfdcr(DCRN_DMACR0);
- control|= DMA_CIE_ENABLE; /* Channel Interrupt Enable */
- mtdcr(DCRN_DMACR0, control);
- break;
- case 1:
- control = mfdcr(DCRN_DMACR1);
- control|= DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR1, control);
- break;
- case 2:
- control = mfdcr(DCRN_DMACR2);
- control|= DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR2, control);
- break;
- case 3:
- control = mfdcr(DCRN_DMACR3);
- control|= DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR3, control);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("enable_dma_interrupt: bad channel: %d\n", dmanr);
-#endif
- return DMA_STATUS_BAD_CHANNEL;
- }
- return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Disables the channel interrupt.
- *
- * If performing a scatter/gatter transfer, this function
- * MUST be called before calling alloc_dma_handle() and building
- * the sgl list. Otherwise, interrupts will not be disabled, if
- * they were previously enabled.
- */
-static __inline__ int
-disable_405gp_dma_interrupt(unsigned int dmanr)
-{
- unsigned int control;
- ppc_dma_ch_t *p_dma_ch = &dma_channels[dmanr];
-
- p_dma_ch->int_enable = TRUE;
- switch (dmanr) {
- case 0:
- control = mfdcr(DCRN_DMACR0);
- control &= ~DMA_CIE_ENABLE; /* Channel Interrupt Enable */
- mtdcr(DCRN_DMACR0, control);
- break;
- case 1:
- control = mfdcr(DCRN_DMACR1);
- control &= ~DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR1, control);
- break;
- case 2:
- control = mfdcr(DCRN_DMACR2);
- control &= ~DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR2, control);
- break;
- case 3:
- control = mfdcr(DCRN_DMACR3);
- control &= ~DMA_CIE_ENABLE;
- mtdcr(DCRN_DMACR3, control);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("enable_dma_interrupt: bad channel: %d\n", dmanr);
-#endif
- return DMA_STATUS_BAD_CHANNEL;
- }
- return DMA_STATUS_GOOD;
-}
-
-
-#ifdef DCRNCAP_DMA_SG
-
-/*
- * Add a new sgl descriptor to the end of a scatter/gather list
- * which was created by alloc_dma_handle().
- *
- * For a memory to memory transfer, both dma addresses must be
- * valid. For a peripheral to memory transfer, one of the addresses
- * must be set to NULL, depending on the direction of the transfer:
- * memory to peripheral: set dst_addr to NULL,
- * peripheral to memory: set src_addr to NULL.
- */
-static __inline__ int
-add_405gp_dma_sgl(sgl_handle_t handle, dma_addr_t src_addr, dma_addr_t dst_addr,
- unsigned int count)
-{
- sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
- ppc_dma_ch_t *p_dma_ch;
-
- if (!handle) {
-#ifdef DEBUG_405DMA
- printk("add_dma_sgl: null handle\n");
-#endif
- return DMA_STATUS_BAD_HANDLE;
- }
-
-#ifdef DEBUG_405DMA
- if (psgl->dmanr >= MAX_405GP_DMA_CHANNELS) {
- printk("add_dma_sgl error: psgl->dmanr == %d\n", psgl->dmanr);
- return DMA_STATUS_BAD_CHANNEL;
- }
-#endif
-
- p_dma_ch = &dma_channels[psgl->dmanr];
-
-#ifdef DEBUG_405DMA
- {
- int error = 0;
- unsigned int aligned = (unsigned)src_addr | (unsigned)dst_addr | count;
- switch(p_dma_ch->pwidth) {
- case PW_8:
- break;
- case PW_16:
- if (aligned & 0x1)
- error = 1;
- break;
- case PW_32:
- if (aligned & 0x3)
- error = 1;
- break;
- case PW_64:
- if (aligned & 0x7)
- error = 1;
- break;
- default:
- printk("add_dma_sgl: invalid bus width: 0x%x\n",
- p_dma_ch->pwidth);
- return DMA_STATUS_GENERAL_ERROR;
- }
- if (error)
- printk("Alignment warning: add_dma_sgl src 0x%x dst 0x%x count 0x%x bus width var %d\n",
- src_addr, dst_addr, count, p_dma_ch->pwidth);
-
- }
-#endif
-
- if ((unsigned)(psgl->ptail + 1) >= ((unsigned)psgl + SGL_LIST_SIZE)) {
-#ifdef DEBUG_405DMA
- printk("sgl handle out of memory \n");
-#endif
- return DMA_STATUS_OUT_OF_MEMORY;
- }
-
-
- if (!psgl->ptail) {
- psgl->phead = (ppc_sgl_t *)
- ((unsigned)psgl + sizeof(sgl_list_info_t));
- psgl->ptail = psgl->phead;
- } else {
- psgl->ptail->next = virt_to_bus(psgl->ptail + 1);
- psgl->ptail++;
- }
-
- psgl->ptail->control = psgl->control;
- psgl->ptail->src_addr = src_addr;
- psgl->ptail->dst_addr = dst_addr;
- psgl->ptail->control_count = (count >> p_dma_ch->shift) |
- psgl->sgl_control;
- psgl->ptail->next = (uint32_t)NULL;
-
- return DMA_STATUS_GOOD;
-}
-
-
-
-/*
- * Enable (start) the DMA described by the sgl handle.
- */
-static __inline__ void enable_405gp_dma_sgl(sgl_handle_t handle)
-{
- sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
- ppc_dma_ch_t *p_dma_ch;
- uint32_t sg_command;
-
-#ifdef DEBUG_405DMA
- if (!handle) {
- printk("enable_dma_sgl: null handle\n");
- return;
- } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
- printk("enable_dma_sgl: bad channel in handle %d\n",
- psgl->dmanr);
- return;
- } else if (!psgl->phead) {
- printk("enable_dma_sgl: sg list empty\n");
- return;
- }
-#endif
-
- p_dma_ch = &dma_channels[psgl->dmanr];
- psgl->ptail->control_count &= ~SG_LINK; /* make this the last dscrptr */
- sg_command = mfdcr(DCRN_ASGC);
-
- switch(psgl->dmanr) {
- case 0:
- mtdcr(DCRN_ASG0, virt_to_bus(psgl->phead));
- sg_command |= SSG0_ENABLE;
- break;
- case 1:
- mtdcr(DCRN_ASG1, virt_to_bus(psgl->phead));
- sg_command |= SSG1_ENABLE;
- break;
- case 2:
- mtdcr(DCRN_ASG2, virt_to_bus(psgl->phead));
- sg_command |= SSG2_ENABLE;
- break;
- case 3:
- mtdcr(DCRN_ASG3, virt_to_bus(psgl->phead));
- sg_command |= SSG3_ENABLE;
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("enable_dma_sgl: bad channel: %d\n", psgl->dmanr);
-#endif
- }
-
-#if 0 /* debug */
- printk("\n\nenable_dma_sgl at dma_addr 0x%x\n",
- virt_to_bus(psgl->phead));
- {
- ppc_sgl_t *pnext, *sgl_addr;
-
- pnext = psgl->phead;
- while (pnext) {
- printk("dma descriptor at 0x%x, dma addr 0x%x\n",
- (unsigned)pnext, (unsigned)virt_to_bus(pnext));
- printk("control 0x%x src 0x%x dst 0x%x c_count 0x%x, next 0x%x\n",
- (unsigned)pnext->control, (unsigned)pnext->src_addr,
- (unsigned)pnext->dst_addr,
- (unsigned)pnext->control_count, (unsigned)pnext->next);
-
- (unsigned)pnext = bus_to_virt(pnext->next);
- }
- printk("sg_command 0x%x\n", sg_command);
- }
-#endif
-
-#ifdef PCI_ALLOC_IS_NONCONSISTENT
- /*
- * This is temporary only, until pci_alloc_consistent() really does
- * return "consistent" memory.
- */
- flush_dcache_range((unsigned)handle, (unsigned)handle + SGL_LIST_SIZE);
-#endif
-
- mtdcr(DCRN_ASGC, sg_command); /* start transfer */
-}
-
-
-
-/*
- * Halt an active scatter/gather DMA operation.
- */
-static __inline__ void disable_405gp_dma_sgl(sgl_handle_t handle)
-{
- sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
- uint32_t sg_command;
-
-#ifdef DEBUG_405DMA
- if (!handle) {
- printk("enable_dma_sgl: null handle\n");
- return;
- } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
- printk("enable_dma_sgl: bad channel in handle %d\n",
- psgl->dmanr);
- return;
- }
-#endif
- sg_command = mfdcr(DCRN_ASGC);
- switch(psgl->dmanr) {
- case 0:
- sg_command &= ~SSG0_ENABLE;
- break;
- case 1:
- sg_command &= ~SSG1_ENABLE;
- break;
- case 2:
- sg_command &= ~SSG2_ENABLE;
- break;
- case 3:
- sg_command &= ~SSG3_ENABLE;
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("enable_dma_sgl: bad channel: %d\n", psgl->dmanr);
-#endif
- }
-
- mtdcr(DCRN_ASGC, sg_command); /* stop transfer */
-}
-
-
-
-/*
- * Returns number of bytes left to be transferred from the entire sgl list.
- * *src_addr and *dst_addr get set to the source/destination address of
- * the sgl descriptor where the DMA stopped.
- *
- * An sgl transfer must NOT be active when this function is called.
- */
-static __inline__ int
-get_405gp_dma_sgl_residue(sgl_handle_t handle, dma_addr_t *src_addr,
- dma_addr_t *dst_addr)
-{
- sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
- ppc_dma_ch_t *p_dma_ch;
- ppc_sgl_t *pnext, *sgl_addr;
- uint32_t count_left;
-
-#ifdef DEBUG_405DMA
- if (!handle) {
- printk("get_dma_sgl_residue: null handle\n");
- return DMA_STATUS_BAD_HANDLE;
- } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
- printk("get_dma_sgl_residue: bad channel in handle %d\n",
- psgl->dmanr);
- return DMA_STATUS_BAD_CHANNEL;
- }
-#endif
-
- switch(psgl->dmanr) {
- case 0:
- sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG0));
- count_left = mfdcr(DCRN_DMACT0);
- break;
- case 1:
- sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG1));
- count_left = mfdcr(DCRN_DMACT1);
- break;
- case 2:
- sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG2));
- count_left = mfdcr(DCRN_DMACT2);
- break;
- case 3:
- sgl_addr = (ppc_sgl_t *)bus_to_virt(mfdcr(DCRN_ASG3));
- count_left = mfdcr(DCRN_DMACT3);
- break;
- default:
-#ifdef DEBUG_405DMA
- printk("get_dma_sgl_residue: bad channel: %d\n", psgl->dmanr);
-#endif
- goto error;
- }
-
- if (!sgl_addr) {
-#ifdef DEBUG_405DMA
- printk("get_dma_sgl_residue: sgl addr register is null\n");
-#endif
- goto error;
- }
-
- pnext = psgl->phead;
- while (pnext &&
- ((unsigned)pnext < ((unsigned)psgl + SGL_LIST_SIZE) &&
- (pnext != sgl_addr))
- ) {
- pnext = pnext++;
- }
-
- if (pnext == sgl_addr) { /* found the sgl descriptor */
-
- *src_addr = pnext->src_addr;
- *dst_addr = pnext->dst_addr;
-
- /*
- * Now search the remaining descriptors and add their count.
- * We already have the remaining count from this descriptor in
- * count_left.
- */
- pnext++;
-
- while ((pnext != psgl->ptail) &&
- ((unsigned)pnext < ((unsigned)psgl + SGL_LIST_SIZE))
- ) {
- count_left += pnext->control_count & SG_COUNT_MASK;
- }
-
- if (pnext != psgl->ptail) { /* should never happen */
-#ifdef DEBUG_405DMA
- printk("get_dma_sgl_residue error (1) psgl->ptail 0x%x handle 0x%x\n",
- (unsigned int)psgl->ptail,
- (unsigned int)handle);
-#endif
- goto error;
- }
-
- /* success */
- p_dma_ch = &dma_channels[psgl->dmanr];
- return (count_left << p_dma_ch->shift); /* count in bytes */
-
- } else {
- /* this shouldn't happen */
-#ifdef DEBUG_405DMA
- printk("get_dma_sgl_residue, unable to match current address 0x%x, handle 0x%x\n",
- (unsigned int)sgl_addr, (unsigned int)handle);
-
-#endif
- }
-
-
-error:
- *src_addr = (dma_addr_t)NULL;
- *dst_addr = (dma_addr_t)NULL;
- return 0;
-}
-
-
-
-
-/*
- * Returns the address(es) of the buffer(s) contained in the head element of
- * the scatter/gather list. The element is removed from the scatter/gather
- * list and the next element becomes the head.
- *
- * This function should only be called when the DMA is not active.
- */
-static __inline__ int
-delete_405gp_dma_sgl_element(sgl_handle_t handle, dma_addr_t *src_dma_addr,
- dma_addr_t *dst_dma_addr)
-{
- sgl_list_info_t *psgl = (sgl_list_info_t *)handle;
-
-#ifdef DEBUG_405DMA
- if (!handle) {
- printk("delete_sgl_element: null handle\n");
- return DMA_STATUS_BAD_HANDLE;
- } else if (psgl->dmanr > (MAX_405GP_DMA_CHANNELS - 1)) {
- printk("delete_sgl_element: bad channel in handle %d\n",
- psgl->dmanr);
- return DMA_STATUS_BAD_CHANNEL;
- }
-#endif
-
- if (!psgl->phead) {
-#ifdef DEBUG_405DMA
- printk("delete_sgl_element: sgl list empty\n");
-#endif
- *src_dma_addr = (dma_addr_t)NULL;
- *dst_dma_addr = (dma_addr_t)NULL;
- return DMA_STATUS_SGL_LIST_EMPTY;
- }
-
- *src_dma_addr = (dma_addr_t)psgl->phead->src_addr;
- *dst_dma_addr = (dma_addr_t)psgl->phead->dst_addr;
-
- if (psgl->phead == psgl->ptail) {
- /* last descriptor on the list */
- psgl->phead = NULL;
- psgl->ptail = NULL;
- } else {
- psgl->phead++;
- }
-
- return DMA_STATUS_GOOD;
-}
-
-#endif /* DCRNCAP_DMA_SG */
-
-/*
- * The rest of the DMA API, in ppc405_dma.c
- */
-extern int hw_init_dma_channel(unsigned int, ppc_dma_ch_t *);
-extern int get_channel_config(unsigned int, ppc_dma_ch_t *);
-extern int set_channel_priority(unsigned int, unsigned int);
-extern unsigned int get_peripheral_width(unsigned int);
-extern int alloc_dma_handle(sgl_handle_t *, unsigned int, unsigned int);
-extern void free_dma_handle(sgl_handle_t);
-
-#endif
-#endif /* __KERNEL__ */
+++ /dev/null
-#ifndef _PPC_RMAP_H
-#define _PPC_RMAP_H
-
-/* PPC calls pte_alloc() before mem_map[] is setup ... */
-#define BROKEN_PPC_PTE_ALLOC_ONE
-
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-/*
- * This file describes the structure passed from the BootX application
- * (for MacOS) when it is used to boot Linux.
- *
- * Written by Benjamin Herrenschmidt.
- */
-
-
-#ifndef __ASM_BOOTX_H__
-#define __ASM_BOOTX_H__
-
-#ifdef macintosh
-#include <Types.h>
-#include "linux_type_defs.h"
-#endif
-
-#ifdef macintosh
-/* All this requires PowerPC alignment */
-#pragma options align=power
-#endif
-
-/* On kernel entry:
- *
- * r3 = 0x426f6f58 ('BooX')
- * r4 = pointer to boot_infos
- * r5 = NULL
- *
- * Data and instruction translation disabled, interrupts
- * disabled, kernel loaded at physical 0x00000000 on PCI
- * machines (will be different on NuBus).
- */
-
-#define BOOT_INFO_VERSION 5
-#define BOOT_INFO_COMPATIBLE_VERSION 1
-
-/* Bit in the architecture flag mask. More to be defined in
- future versions. Note that either BOOT_ARCH_PCI or
- BOOT_ARCH_NUBUS is set. The other BOOT_ARCH_NUBUS_xxx are
- set additionally when BOOT_ARCH_NUBUS is set.
- */
-#define BOOT_ARCH_PCI 0x00000001UL
-#define BOOT_ARCH_NUBUS 0x00000002UL
-#define BOOT_ARCH_NUBUS_PDM 0x00000010UL
-#define BOOT_ARCH_NUBUS_PERFORMA 0x00000020UL
-#define BOOT_ARCH_NUBUS_POWERBOOK 0x00000040UL
-
-/* Maximum number of ranges in phys memory map */
-#define MAX_MEM_MAP_SIZE 26
-
-/* This is the format of an element in the physical memory map. Note that
- the map is optional and current BootX will only build it for pre-PCI
- machines */
-typedef struct boot_info_map_entry
-{
- __u32 physAddr; /* Physical starting address */
- __u32 size; /* Size in bytes */
-} boot_info_map_entry_t;
-
-
-/* Here are the boot informations that are passed to the bootstrap
- * Note that the kernel arguments and the device tree are appended
- * at the end of this structure. */
-typedef struct boot_infos
-{
- /* Version of this structure */
- __u32 version;
- /* backward compatible down to version: */
- __u32 compatible_version;
-
- /* NEW (vers. 2) this holds the current _logical_ base addr of
- the frame buffer (for use by early boot message) */
- __u8* logicalDisplayBase;
-
- /* NEW (vers. 4) Apple's machine identification */
- __u32 machineID;
-
- /* NEW (vers. 4) Detected hw architecture */
- __u32 architecture;
-
- /* The device tree (internal addresses relative to the beginning of the tree,
- * device tree offset relative to the beginning of this structure).
- * On pre-PCI macintosh (BOOT_ARCH_PCI bit set to 0 in architecture), this
- * field is 0.
- */
- __u32 deviceTreeOffset; /* Device tree offset */
- __u32 deviceTreeSize; /* Size of the device tree */
-
- /* Some infos about the current MacOS display */
- __u32 dispDeviceRect[4]; /* left,top,right,bottom */
- __u32 dispDeviceDepth; /* (8, 16 or 32) */
- __u8* dispDeviceBase; /* base address (physical) */
- __u32 dispDeviceRowBytes; /* rowbytes (in bytes) */
- __u32 dispDeviceColorsOffset; /* Colormap (8 bits only) or 0 (*) */
- /* Optional offset in the registry to the current
- * MacOS display. (Can be 0 when not detected) */
- __u32 dispDeviceRegEntryOffset;
-
- /* Optional pointer to boot ramdisk (offset from this structure) */
- __u32 ramDisk;
- __u32 ramDiskSize; /* size of ramdisk image */
-
- /* Kernel command line arguments (offset from this structure) */
- __u32 kernelParamsOffset;
-
- /* ALL BELOW NEW (vers. 4) */
-
- /* This defines the physical memory. Valid with BOOT_ARCH_NUBUS flag
- (non-PCI) only. On PCI, memory is contiguous and it's size is in the
- device-tree. */
- boot_info_map_entry_t
- physMemoryMap[MAX_MEM_MAP_SIZE]; /* Where the phys memory is */
- __u32 physMemoryMapSize; /* How many entries in map */
-
-
- /* The framebuffer size (optional, currently 0) */
- __u32 frameBufferSize; /* Represents a max size, can be 0. */
-
- /* NEW (vers. 5) */
-
- /* Total params size (args + colormap + device tree + ramdisk) */
- __u32 totalParamsSize;
-
-} boot_infos_t;
-
-/* (*) The format of the colormap is 256 * 3 * 2 bytes. Each color index is represented
- * by 3 short words containing a 16 bits (unsigned) color component.
- * Later versions may contain the gamma table for direct-color devices here.
- */
-#define BOOTX_COLORTABLE_SIZE (256UL*3UL*2UL)
-
-#ifdef macintosh
-#pragma options align=reset
-#endif
-
-#endif
+++ /dev/null
-#ifndef _ASM_PPC64_CPUMASK_H
-#define _ASM_PPC64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_PPC64_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _PPC64_RMAP_H
-#define _PPC64_RMAP_H
-
-/* PPC64 calls pte_alloc() before mem_map[] is setup ... */
-#define BROKEN_PPC_PTE_ALLOC_ONE
-
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef _ASM_S390_CPUMASK_H
-#define _ASM_S390_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_S390_CPUMASK_H */
+++ /dev/null
-/*
- * include/asm-s390/init.h
- *
- * S390 version
- */
-
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _S390_RMAP_H
-#define _S390_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef _ASM_SH_CPUMASK_H
-#define _ASM_SH_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SH_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _SH_RMAP_H
-#define _SH_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef __ASM_SH64_SMPLOCK_H
-#define __ASM_SH64_SMPLOCK_H
-
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * include/asm-sh64/smplock.h
- *
- * Copyright (C) 2000, 2001 Paolo Alberelli
- *
- */
-
-#include <linux/config.h>
-
-#ifndef CONFIG_SMP
-
-#define lock_kernel() do { } while(0)
-#define unlock_kernel() do { } while(0)
-#define release_kernel_lock(task, cpu, depth) ((depth) = 1)
-#define reacquire_kernel_lock(task, cpu, depth) do { } while(0)
-
-#else
-
-#error "We do not support SMP on SH64 yet"
-/*
- * Default SMP lock implementation
- */
-
-#include <linux/interrupt.h>
-#include <asm/spinlock.h>
-
-extern spinlock_t kernel_flag;
-
-/*
- * Getting the big kernel lock.
- *
- * This cannot happen asynchronously,
- * so we only need to worry about other
- * CPU's.
- */
-extern __inline__ void lock_kernel(void)
-{
- if (!++current->lock_depth)
- spin_lock(&kernel_flag);
-}
-
-extern __inline__ void unlock_kernel(void)
-{
- if (--current->lock_depth < 0)
- spin_unlock(&kernel_flag);
-}
-
-/*
- * Release global kernel lock and global interrupt lock
- */
-#define release_kernel_lock(task, cpu) \
-do { \
- if (task->lock_depth >= 0) \
- spin_unlock(&kernel_flag); \
- release_irqlock(cpu); \
- __sti(); \
-} while (0)
-
-/*
- * Re-acquire the kernel lock
- */
-#define reacquire_kernel_lock(task) \
-do { \
- if (task->lock_depth >= 0) \
- spin_lock(&kernel_flag); \
-} while (0)
-
-#endif /* CONFIG_SMP */
-
-#endif /* __ASM_SH64_SMPLOCK_H */
+++ /dev/null
-#ifndef __ASM_SH_SOFTIRQ_H
-#define __ASM_SH_SOFTIRQ_H
-
-#include <asm/atomic.h>
-#include <asm/hardirq.h>
-
-#define local_bh_disable() \
-do { \
- local_bh_count(smp_processor_id())++; \
- barrier(); \
-} while (0)
-
-#define __local_bh_enable() \
-do { \
- barrier(); \
- local_bh_count(smp_processor_id())--; \
-} while (0)
-
-#define local_bh_enable() \
-do { \
- barrier(); \
- if (!--local_bh_count(smp_processor_id()) \
- && softirq_pending(smp_processor_id())) { \
- do_softirq(); \
- } \
-} while (0)
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
-
-#endif /* __ASM_SH_SOFTIRQ_H */
+++ /dev/null
-#ifndef _ASM_SPARC_CPUMASK_H
-#define _ASM_SPARC_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SPARC_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _SPARC_RMAP_H
-#define _SPARC_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef _ASM_SPARC64_CPUMASK_H
-#define _ASM_SPARC64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_SPARC64_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _SPARC64_RMAP_H
-#define _SPARC64_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef _ASM_UM_CPUMASK_H
-#define _ASM_UM_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_UM_CPUMASK_H */
+++ /dev/null
-#ifndef _UM_INIT_H
-#define _UM_INIT_H
-
-#ifdef notdef
-#define __init
-#define __initdata
-#define __initfunc(__arginit) __arginit
-#define __cacheline_aligned
-#endif
-
-#endif
+++ /dev/null
-#ifndef __UM_MODULE_H
-#define __UM_MODULE_H
-
-/* UML is simple */
-struct mod_arch_specific
-{
-};
-
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
-
-#endif
+++ /dev/null
-#ifndef __UM_RMAP_H
-#define __UM_RMAP_H
-
-#include "asm/arch/rmap.h"
-
-#endif
+++ /dev/null
-#ifndef __UM_SMPLOCK_H
-#define __UM_SMPLOCK_H
-
-#include "asm/arch/smplock.h"
-
-#endif
+++ /dev/null
-#ifndef _ASM_V850_CPUMASK_H
-#define _ASM_V850_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_V850_CPUMASK_H */
+++ /dev/null
-/* Do not need anything here */
+++ /dev/null
-#ifndef _ASM_X86_64_CPUMASK_H
-#define _ASM_X86_64_CPUMASK_H
-
-#include <asm-generic/cpumask.h>
-
-#endif /* _ASM_X86_64_CPUMASK_H */
+++ /dev/null
-#error "<asm/init.h> should never be used - use <linux/init.h> instead"
+++ /dev/null
-#ifndef _X8664_RMAP_H
-#define _X8664_RMAP_H
-
-/* nothing to see, move along */
-#include <asm-generic/rmap.h>
-
-#endif
+++ /dev/null
-#ifndef IEEE_802_11
-#define IEEE_802_11
-
-#include <linux/types.h>
-
-enum ieee_802_11_link_status_failure_reason {
- reserved0, Unspecified=1, Previous_not_valid,
- Sender_Quits_ESS_or_IBSS,
- Due_Inactivity, AP_Overload,
- Class_2_from_NonAuth,
- Class_3_from_NonAuth,
- Sender_Quits_BSS,
- Association_requester_not_authenticated,
- Reserved10
-};
-
-
-#define IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS \
-{ \
- {reserved0, 0xff," Reserved reason "},\
- {Unspecified, 0xff," Unspecified Reason "},\
- {Previous_not_valid, 0xff," Previous Authentication no longer valid "},\
- {Sender_Quits_ESS_or_IBSS,0xff," Deauthenticated because sending station is leaving (has left) IBSS or ESS "},\
- {Due_Inactivity, 0xff," Disassociated due to inactivity "},\
- {AP_Overload, 0xff," Disassociated because AP is unable to handle all currently associated stations "},\
- {Class_2_from_NonAuth, 0xff," Class 2 frame received from non-Authenticated station"},\
- {Class_3_from_NonAuth, 0xff," Class 3 frame received from nonÂAssociated station"},\
- {Sender_Quits_BSS, 0xff," Disassociated because sending station is leaving (has left) BSS"},\
- {Association_requester_not_authenticated,0xff," Station requesting (Re)Association is not Authenticated with responding station"},\
- {Reserved10, 0xff," Reserved"},\
- {0,0,NULL}\
-};
-
-
-
-struct ieee_802_11_header {
- u16 frame_control;// needs to be subtyped
- u16 duration;
- u8 mac1[6];
- u8 mac2[6];
- u8 mac3[6];
- u16 SeqCtl;
- u8 mac4[6];
- u16 gapLen;
- u8 gap[8];
-};
-
-
-struct ieee_802_3_header {
-
- u16 status;
- u16 payload_length;
- u8 dst_mac[6];
- u8 src_mac[6];
-
-};
-
-#define P80211_OUI_LEN 3
-
-struct ieee_802_11_snap_header {
-
- u8 dsap; /* always 0xAA */
- u8 ssap; /* always 0xAA */
- u8 ctrl; /* always 0x03 */
- u8 oui[P80211_OUI_LEN]; /* organizational universal id */
-
-} __attribute__ ((packed));
-
-#define P80211_LLC_OUI_LEN 3
-
-struct ieee_802_11_802_1H_header {
-
- u8 dsap;
- u8 ssap; /* always 0xAA */
- u8 ctrl; /* always 0x03 */
- u8 oui[P80211_OUI_LEN]; /* organizational universal id */
- u16 unknown1; /* packet type ID fields */
- u16 unknown2; /* here is something like length in some cases */
-} __attribute__ ((packed));
-
-struct ieee_802_11_802_2_header {
-
- u8 dsap;
- u8 ssap; /* always 0xAA */
- u8 ctrl; /* always 0x03 */
- u8 oui[P80211_OUI_LEN]; /* organizational universal id */
- u8 type; /* packet type ID field. i guess, */
-
-} __attribute__ ((packed));
-
-
-
-// following is incoplete and may be incorrect and need reorganization
-
-#define ieee_802_11_frame_type_Management 0x00
-#define ieee_802_11_frame_type_Control 0x01
-#define ieee_802_11_frame_type_Data 0x10
-#define ieee_802_11_frame_type_Reserved 0x11
-
-#define ieee_802_11_frame_subtype_Association_Req 0x0 // Association Request
-#define ieee_802_11_frame_subtype_Association_Resp 0x1 // Association Response
-#define ieee_802_11_frame_subtype_Reassociation_Req 0x2 // Reassociation Request
-#define ieee_802_11_frame_subtype_Reassociation_Resp 0x3 // Reassociation Response
-#define ieee_802_11_frame_subtype_Probe_Req 0x4 // Probe Request
-#define ieee_802_11_frame_subtype_Probe_Resp 0x5 // Probe Response
-#define ieee_802_11_frame_subtype_Beacon 0x8 // Beacon
-#define ieee_802_11_frame_subtype_ATIM 0x9 // ATIM
-#define ieee_802_11_frame_subtype_Disassociation 0xA // Disassociation
-#define ieee_802_11_frame_subtype_Authentication 0xB // Authentication
-#define ieee_802_11_frame_subtype_Deauthentication 0xC // Deauthentication
-#define ieee_802_11_frame_subtype_PS_Poll 0xA // PS-Poll
-#define ieee_802_11_frame_subtype_RTS 0xB // RTS
-#define ieee_802_11_frame_subtype_CTS 0xC // CTS
-#define ieee_802_11_frame_subtype_ACK 0xD // ACK
-#define ieee_802_11_frame_subtype_CFEnd 0xE // CF-End
-#define ieee_802_11_frame_subtype_CFEnd_CFAck 0xF // CF-End + CF-Ack
-#define ieee_802_11_frame_subtype_Data 0x0 // Data
-#define ieee_802_11_frame_subtype_Data_CFAck 0x1 // Data + CF-Ack
-#define ieee_802_11_frame_subtype_Data_CF_Poll 0x2 // Data + CF-Poll
-#define ieee_802_11_frame_subtype_Data_CF_AckCF_Poll 0x3 // Data + CF-Ack + CF-Poll
-#define ieee_802_11_frame_subtype_NullFunction 0x4 // Null Function (no data)
-#define ieee_802_11_frame_subtype_CF_Ack 0x5 // CF-Ack (no data)
-#define ieee_802_11_frame_subtype_CF_Poll 0x6 // CF-Poll (no data)
-#define ieee_802_11_frame_subtype_CF_AckCF_Poll 0x7 // CF-Ack + CF-Poll (no data)
-
-
-#define ieee_802_11_frame_subtype_strings {\
- { ieee_802_11_frame_subtype_Association_Req, 0xF,"f Association Request"},\
- { ieee_802_11_frame_subtype_Association_Resp, 0xF,"1 Association Response"},\
- { ieee_802_11_frame_subtype_Reassociation_Req, 0xF,"2 Reassociation Request"},\
- { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,"3 Reassociation Response"},\
- { ieee_802_11_frame_subtype_Probe_Req , 0xF,"4 Probe Request"},\
- { ieee_802_11_frame_subtype_Probe_Resp , 0xF,"5 Probe Response"},\
- { ieee_802_11_frame_subtype_Beacon , 0xF,"8 Beacon"},\
- { ieee_802_11_frame_subtype_ATIM , 0xF,"9 ATIM"},\
- { ieee_802_11_frame_subtype_Disassociation, 0xF,"A Disassociation"},\
- { ieee_802_11_frame_subtype_Authentication, 0xF,"B Authentication"},\
- { ieee_802_11_frame_subtype_Deauthentication, 0xF,"C Deauthentication"},\
- { ieee_802_11_frame_subtype_PS_Poll , 0xF,"A PS-Poll"},\
- { ieee_802_11_frame_subtype_RTS , 0xF,"B RTS"},\
- { ieee_802_11_frame_subtype_CTS , 0xF,"C CTS"},\
- { ieee_802_11_frame_subtype_ACK , 0xF,"D ACK"},\
- { ieee_802_11_frame_subtype_CFEnd , 0xF,"E CF-End"},\
- { ieee_802_11_frame_subtype_CFEnd_CFAck , 0xF,"F CF-End + CF-Ack"},\
- { ieee_802_11_frame_subtype_Data , 0xF,"0 Data"},\
- { ieee_802_11_frame_subtype_Data_CFAck , 0xF,"1 Data + CF-Ack"},\
- { ieee_802_11_frame_subtype_Data_CFPoll , 0xF,"2 Data + CF-Poll"},\
- { ieee_802_11_frame_subtype_Data_CFAck_CFPoll, 0xF,"3 Data + CF-Ack + CF-Poll"},\
- { ieee_802_11_frame_subtype_Null_Function , 0xF,"4 Null Function (no data)"},\
- { ieee_802_11_frame_subtype_CFAck , 0xF,"5 CF-Ack (no data)"},\
- { ieee_802_11_frame_subtype_CFPoll , 0xF,"6 CF-Poll (no data)"},\
- { ieee_802_11_frame_subtype_CFAck_CFPoll, 0xF,"y7 CF-Ack + CF-Poll (no data)"},\
- { 0,0,NULL}\
-}
-struct ieee_802_11_frame_subtype_class {
- u8 subtype;
- u8 mask;
- u8 class;
- u8 type;
-};
-#define ieee_802_11_frame_subtype_classes {\
- { ieee_802_11_frame_subtype_Association_Req, 0xF,2,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Association_Resp, 0xF,2,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Reassociation_Req, 0xF,2,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Reassociation_Resp, 0xF,2,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Probe_Req , 0xF,1,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Probe_Resp , 0xF,1,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Beacon , 0xF,1,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_ATIM , 0xF,1,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Disassociation, 0xF,2,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Authentication, 0xF,1,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_Deauthentication, 0xF,3,ieee_802_11_frame_type_Management},\
- { ieee_802_11_frame_subtype_PS-Poll , 0xF,3,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_RTS , 0xF,1,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_CTS , 0xF,1,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_ACK , 0xF,1,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_CFEnd , 0xF,1,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_CFEnd_CFAck , 0xF,1,ieee_802_11_frame_type_Control},\
- { ieee_802_11_frame_subtype_Data , 0xF,3,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_Data_CFAck , 0xF,3,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_Data_CF_Poll 0xF,3,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_Data_CF_AckCF_Poll, 0xF,3,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_NullFunction 0xF,1,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_CF_Ack , 0xF,1,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_CF_Poll , 0xF,1,ieee_802_11_frame_type_Data},\
- { ieee_802_11_frame_subtype_CF_AckCF_Poll, 0xF,1,ieee_802_11_frame_type_Data},\
- { 0,0,NULL}\
-}
-
-
-#endif
+++ /dev/null
-/*
- * linux/include/linux/acpi_serial.h
- *
- * Copyright (C) 2000 Hewlett-Packard Co.
- * Copyright (C) 2000 Khalid Aziz <khalid_aziz@hp.com>
- *
- * Definitions for ACPI defined serial ports (headless console and
- * debug ports)
- *
- */
-
-#include <linux/serial.h>
-
-extern void setup_serial_acpi(void *);
-
-#define ACPI_SIG_LEN 4
-
-/* ACPI table signatures */
-#define ACPI_SPCRT_SIGNATURE "SPCR"
-#define ACPI_DBGPT_SIGNATURE "DBGP"
-
-/* Interface type as defined in ACPI serial port tables */
-#define ACPI_SERIAL_INTFC_16550 0
-#define ACPI_SERIAL_INTFC_16450 1
-
-/* Interrupt types for ACPI serial port tables */
-#define ACPI_SERIAL_INT_PCAT 0x01
-#define ACPI_SERIAL_INT_APIC 0x02
-#define ACPI_SERIAL_INT_SAPIC 0x04
-
-/* Baud rates as defined in ACPI serial port tables */
-#define ACPI_SERIAL_BAUD_9600 3
-#define ACPI_SERIAL_BAUD_19200 4
-#define ACPI_SERIAL_BAUD_57600 6
-#define ACPI_SERIAL_BAUD_115200 7
-
-/* Parity as defined in ACPI serial port tables */
-#define ACPI_SERIAL_PARITY_NONE 0
-
-/* Flow control methods as defined in ACPI serial port tables */
-#define ACPI_SERIAL_FLOW_DCD 0x01
-#define ACPI_SERIAL_FLOW_RTS 0x02
-#define ACPI_SERIAL_FLOW_XON 0x04
-
-/* Terminal types as defined in ACPI serial port tables */
-#define ACPI_SERIAL_TERM_VT100 0
-#define ACPI_SERIAL_TERM_VT100X 1
-
-/* PCI Flags as defined by SPCR table */
-#define ACPI_SERIAL_PCIFLAG_PNP 0x00000001
-
-/* Space ID as defined in base address structure in ACPI serial port tables */
-#define ACPI_SERIAL_MEM_SPACE 0
-#define ACPI_SERIAL_IO_SPACE 1
-#define ACPI_SERIAL_PCICONF_SPACE 2
-
-/*
- * Generic Register Address Structure - as defined by Microsoft
- * in http://www.microsoft.com/hwdev/onnow/download/LFreeACPI.doc
- *
-*/
-typedef struct {
- u8 space_id;
- u8 bit_width;
- u8 bit_offset;
- u8 resv;
- u32 addrl;
- u32 addrh;
-} gen_regaddr;
-
-/* Space ID for generic register address structure */
-#define REGADDR_SPACE_SYSMEM 0
-#define REGADDR_SPACE_SYSIO 1
-#define REGADDR_SPACE_PCICONFIG 2
-
-/* Serial Port Console Redirection and Debug Port Table formats */
-typedef struct {
- u8 signature[4];
- u32 length;
- u8 rev;
- u8 chksum;
- u8 oemid[6];
- u8 oem_tabid[8];
- u32 oem_rev;
- u8 creator_id[4];
- u32 creator_rev;
- u8 intfc_type;
- u8 resv1[3];
- gen_regaddr base_addr;
- u8 int_type;
- u8 irq;
- u8 global_int[4];
- u8 baud;
- u8 parity;
- u8 stop_bits;
- u8 flow_ctrl;
- u8 termtype;
- u8 language;
- u16 pci_dev_id;
- u16 pci_vendor_id;
- u8 pci_bus;
- u8 pci_dev;
- u8 pci_func;
- u8 pci_flags[4];
- u8 pci_seg;
- u32 resv2;
-} acpi_ser_t;
+++ /dev/null
-#ifndef _LINUX_ADB_MOUSE_H
-#define _LINUX_ADB_MOUSE_H
-
-/*
- * linux/include/linux/mac_mouse.h
- * header file for Macintosh ADB mouse driver
- * 27-10-97 Michael Schmitz
- * copied from:
- * header file for Atari Mouse driver
- * by Robert de Vries (robert@and.nl) on 19Jul93
- */
-
-struct mouse_status {
- char buttons;
- short dx;
- short dy;
- int ready;
- int active;
- struct wait_queue *wait;
- struct fasync_struct *fasyncptr;
-};
-
-#endif
+++ /dev/null
-/**** vi:set ts=8 sts=8 sw=8:************************************************
- *
- * Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- */
-
-#include <linux/types.h>
-#include <asm/byteorder.h>
-
-/*
- * With each packet command, we allocate a buffer.
- * This is used for several packet
- * commands (Not for READ/WRITE commands).
- */
-#define IDEFLOPPY_PC_BUFFER_SIZE 256
-#define IDETAPE_PC_BUFFER_SIZE 256
-
-/*
- * Packet flags bits.
- */
-
-#define PC_ABORT 0 /* set when an error is considered normal - we won't retry */
-#define PC_WAIT_FOR_DSC 1 /* 1 when polling for DSC on a media access command */
-#define PC_DMA_RECOMMENDED 2 /* 1 when we prefer to use DMA if possible */
-#define PC_DMA_IN_PROGRESS 3 /* 1 while DMA in progress */
-#define PC_DMA_ERROR 4 /* 1 when encountered problem during DMA */
-#define PC_WRITING 5 /* data direction */
-#define PC_SUPPRESS_ERROR 6 /* suppress error reporting */
-#define PC_TRANSFORM 7 /* transform SCSI commands */
-
-/* This struct get's shared between different drivers.
- */
-struct atapi_packet_command {
- u8 c[12]; /* Actual packet bytes */
- char *buffer; /* Data buffer */
- int buffer_size; /* Size of our data buffer */
- char *current_position; /* Pointer into the above buffer */
- int request_transfer; /* Bytes to transfer */
- int actually_transferred; /* Bytes actually transferred */
-
- unsigned long flags; /* Status/Action bit flags: long for set_bit */
-
- /* FIXME: the following is ugly as hell, but the only way we can start
- * actually to unify the code.
- */
- /* driver specific data. */
- /* floppy/tape */
- int retries; /* On each retry, we increment retries */
- int error; /* Error code */
- char *b_data; /* Pointer which runs on the buffers */
- unsigned int b_count; /* Missing/Available data on the current buffer */
- u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
- /* Called when this packet command is completed */
- void (*callback) (struct ata_device *, struct request *);
-
- /* only tape */
- struct bio *bio;
-
- /* only scsi */
- struct {
- unsigned int b_count; /* Bytes transferred from current entry */
- struct scatterlist *sg; /* Scatter gather table */
- struct scsi_cmnd *scsi_cmd; /* SCSI command */
- void (*done)(struct scsi_cmnd *); /* Scsi completion routine */
- unsigned long timeout; /* Command timeout */
- } s;
-};
-
-/*
- * ATAPI Status Register.
- */
-typedef union {
- u8 all : 8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 check : 1; /* Error occurred */
- u8 idx : 1; /* Reserved */
- u8 corr : 1; /* Correctable error occurred */
- u8 drq : 1; /* Data is request by the device */
- u8 dsc : 1; /* Media access command finished / Buffer availability */
- u8 reserved5 : 1; /* Reserved */
- u8 drdy : 1; /* Ignored for ATAPI commands (ready to accept ATA command) */
- u8 bsy : 1; /* The device has access to the command block */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 bsy : 1;
- u8 drdy : 1;
- u8 reserved5 : 1;
- u8 dsc : 1;
- u8 drq : 1;
- u8 corr : 1;
- u8 idx : 1;
- u8 check : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_status_reg_t;
-
-/*
- * ATAPI error register.
- */
-typedef union {
- u8 all : 8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 ili : 1; /* Illegal Length Indication */
- u8 eom : 1; /* End Of Media Detected */
- u8 abrt : 1; /* Aborted command - As defined by ATA */
- u8 mcr : 1; /* Media Change Requested - As defined by ATA */
- u8 sense_key : 4; /* Sense key of the last failed packet command */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 sense_key : 4;
- u8 mcr : 1;
- u8 abrt : 1;
- u8 eom : 1;
- u8 ili : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_error_reg_t;
-
-/* Currently unused, but please do not remove. --bkz */
-/*
- * ATAPI Feature Register.
- */
-typedef union {
- u8 all : 8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 dma : 1; /* Using DMA or PIO */
- u8 reserved321 : 3; /* Reserved */
- u8 reserved654 : 3; /* Reserved (Tag Type) */
- u8 reserved7 : 1; /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 reserved7 : 1;
- u8 reserved654 : 3;
- u8 reserved321 : 3;
- u8 dma : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_feature_reg_t;
-
-/*
- * ATAPI Byte Count Register.
- */
-typedef union {
- u16 all : 16;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 low; /* LSB */
- u8 high; /* MSB */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 high;
- u8 low;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_bcount_reg_t;
-
-/*
- * ATAPI Interrupt Reason Register.
- */
-typedef union {
- u8 all : 8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 cod : 1; /* Information transferred is command (1) or data (0) */
- u8 io : 1; /* The device requests us to read (1) or write (0) */
- u8 reserved : 6; /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 reserved : 6;
- u8 io : 1;
- u8 cod : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_ireason_reg_t;
-
-/* Currently unused, but please do not remove. --bkz */
-/*
- * ATAPI Drive Select Register.
- */
-typedef union {
- u8 all :8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 sam_lun :3; /* Logical unit number */
- u8 reserved3 :1; /* Reserved */
- u8 drv :1; /* The responding drive will be drive 0 (0) or drive 1 (1) */
- u8 one5 :1; /* Should be set to 1 */
- u8 reserved6 :1; /* Reserved */
- u8 one7 :1; /* Should be set to 1 */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 one7 :1;
- u8 reserved6 :1;
- u8 one5 :1;
- u8 drv :1;
- u8 reserved3 :1;
- u8 sam_lun :3;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_drivesel_reg_t;
-
-/* Currently unused, but please do not remove. --bkz */
-/*
- * ATAPI Device Control Register.
- */
-typedef union {
- u8 all : 8;
- struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 zero0 : 1; /* Should be set to zero */
- u8 nien : 1; /* Device interrupt is disabled (1) or enabled (0) */
- u8 srst : 1; /* ATA software reset. ATAPI devices should use the new ATAPI srst. */
- u8 one3 : 1; /* Should be set to 1 */
- u8 reserved4567 : 4; /* Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 reserved4567 : 4;
- u8 one3 : 1;
- u8 srst : 1;
- u8 nien : 1;
- u8 zero0 : 1;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- } b;
-} atapi_control_reg_t;
-
-/*
- * The following is used to format the general configuration word
- * of the ATAPI IDENTIFY DEVICE command.
- */
-struct atapi_id_gcw {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 packet_size : 2; /* Packet Size */
- u8 reserved234 : 3; /* Reserved */
- u8 drq_type : 2; /* Command packet DRQ type */
- u8 removable : 1; /* Removable media */
- u8 device_type : 5; /* Device type */
- u8 reserved13 : 1; /* Reserved */
- u8 protocol : 2; /* Protocol type */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 protocol : 2;
- u8 reserved13 : 1;
- u8 device_type : 5;
- u8 removable : 1;
- u8 drq_type : 2;
- u8 reserved234 : 3;
- u8 packet_size : 2;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
-};
-
-/*
- * INQUIRY packet command - Data Format.
- */
-typedef struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 device_type : 5; /* Peripheral Device Type */
- u8 reserved0_765 : 3; /* Peripheral Qualifier - Reserved */
- u8 reserved1_6t0 : 7; /* Reserved */
- u8 rmb : 1; /* Removable Medium Bit */
- u8 ansi_version : 3; /* ANSI Version */
- u8 ecma_version : 3; /* ECMA Version */
- u8 iso_version : 2; /* ISO Version */
- u8 response_format : 4; /* Response Data Format */
- u8 reserved3_45 : 2; /* Reserved */
- u8 reserved3_6 : 1; /* TrmIOP - Reserved */
- u8 reserved3_7 : 1; /* AENC - Reserved */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 reserved0_765 : 3;
- u8 device_type : 5;
- u8 rmb : 1;
- u8 reserved1_6t0 : 7;
- u8 iso_version : 2;
- u8 ecma_version : 3;
- u8 ansi_version : 3;
- u8 reserved3_7 : 1;
- u8 reserved3_6 : 1;
- u8 reserved3_45 : 2;
- u8 response_format : 4;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- u8 additional_length; /* Additional Length (total_length-4) */
- u8 rsv5, rsv6, rsv7; /* Reserved */
- u8 vendor_id[8]; /* Vendor Identification */
- u8 product_id[16]; /* Product Identification */
- u8 revision_level[4]; /* Revision Level */
- u8 vendor_specific[20]; /* Vendor Specific - Optional */
- u8 reserved56t95[40]; /* Reserved - Optional */
- /* Additional information may be returned */
-} atapi_inquiry_result_t;
-
-/*
- * REQUEST SENSE packet command result - Data Format.
- */
-typedef struct atapi_request_sense {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 error_code : 7; /* Error Code (0x70 - current or 0x71 - deferred) */
- u8 valid : 1; /* The information field conforms to standard */
- u8 reserved1 : 8; /* Reserved (Segment Number) */
- u8 sense_key : 4; /* Sense Key */
- u8 reserved2_4 : 1; /* Reserved */
- u8 ili : 1; /* Incorrect Length Indicator */
- u8 eom : 1; /* End Of Medium */
- u8 filemark : 1; /* Filemark */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 valid : 1;
- u8 error_code : 7;
- u8 reserved1 : 8;
- u8 filemark : 1;
- u8 eom : 1;
- u8 ili : 1;
- u8 reserved2_4 : 1;
- u8 sense_key : 4;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- u32 information __attribute__ ((packed));
- u8 asl; /* Additional sense length (n-7) */
- u32 command_specific; /* Additional command specific information */
- u8 asc; /* Additional Sense Code */
- u8 ascq; /* Additional Sense Code Qualifier */
- u8 replaceable_unit_code; /* Field Replaceable Unit Code */
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- u8 sk_specific1 : 7; /* Sense Key Specific */
- u8 sksv : 1; /* Sense Key Specific information is valid */
-#elif defined(__BIG_ENDIAN_BITFIELD)
- u8 sksv : 1; /* Sense Key Specific information is valid */
- u8 sk_specific1 : 7; /* Sense Key Specific */
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- u8 sk_specific[2]; /* Sense Key Specific */
- u8 pad[2]; /* Padding to 20 bytes */
-} atapi_request_sense_result_t;
-
-
-extern void atapi_init_pc(struct atapi_packet_command *pc);
-
-extern void atapi_discard_data(struct ata_device *, unsigned int);
-extern void atapi_write_zeros(struct ata_device *, unsigned int);
-
-extern void atapi_read(struct ata_device *, u8 *, unsigned int);
-extern void atapi_write(struct ata_device *, u8 *, unsigned int);
-
-typedef enum {
- ide_wait, /* insert rq at end of list, and wait for it */
- ide_preempt, /* insert rq in front of current request */
- ide_end /* insert rq at end of list, but don't wait for it */
-} ide_action_t;
-
-extern int ide_do_drive_cmd(struct ata_device *, struct request *, ide_action_t);
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- */
-
-#ifndef __FILTER_H_
-#define __FILTER_H_ 1
-
-#ifdef __KERNEL__
-
-/* cachetype.c */
-
-/*
- * it is important that things like inode, super and file operations
- * for intermezzo are not defined statically. If methods are NULL
- * the VFS takes special action based on that. Given that different
- * cache types have NULL ops at different slots, we must install opeation
- * talbes for InterMezzo with NULL's in the same spot
- */
-
-struct filter_ops {
- struct super_operations filter_sops;
-
- struct inode_operations filter_dir_iops;
- struct inode_operations filter_file_iops;
- struct inode_operations filter_sym_iops;
-
- struct file_operations filter_dir_fops;
- struct file_operations filter_file_fops;
- struct file_operations filter_sym_fops;
-
- struct dentry_operations filter_dentry_ops;
-};
-
-struct cache_ops {
- /* operations on the file store */
- struct super_operations *cache_sops;
-
- struct inode_operations *cache_dir_iops;
- struct inode_operations *cache_file_iops;
- struct inode_operations *cache_sym_iops;
-
- struct file_operations *cache_dir_fops;
- struct file_operations *cache_file_fops;
- struct file_operations *cache_sym_fops;
-
- struct dentry_operations *cache_dentry_ops;
-};
-
-
-#define FILTER_DID_SUPER_OPS 0x1
-#define FILTER_DID_INODE_OPS 0x2
-#define FILTER_DID_FILE_OPS 0x4
-#define FILTER_DID_DENTRY_OPS 0x8
-#define FILTER_DID_DEV_OPS 0x10
-#define FILTER_DID_SYMLINK_OPS 0x20
-#define FILTER_DID_DIR_OPS 0x40
-
-struct filter_fs {
- int o_flags;
- struct filter_ops o_fops;
- struct cache_ops o_caops;
- struct journal_ops *o_trops;
- struct snapshot_ops *o_snops;
-};
-
-#define FILTER_FS_TYPES 6
-#define FILTER_FS_EXT2 0
-#define FILTER_FS_EXT3 1
-#define FILTER_FS_REISERFS 2
-#define FILTER_FS_XFS 3
-#define FILTER_FS_OBDFS 4
-#define FILTER_FS_TMPFS 5
-extern struct filter_fs filter_oppar[FILTER_FS_TYPES];
-
-struct filter_fs *filter_get_filter_fs(const char *cache_type);
-void filter_setup_journal_ops(struct filter_fs *ops, char *cache_type);
-struct super_operations *filter_c2usops(struct filter_fs *cache);
-struct inode_operations *filter_c2ufiops(struct filter_fs *cache);
-struct inode_operations *filter_c2udiops(struct filter_fs *cache);
-struct inode_operations *filter_c2usiops(struct filter_fs *cache);
-struct file_operations *filter_c2uffops(struct filter_fs *cache);
-struct file_operations *filter_c2udfops(struct filter_fs *cache);
-struct file_operations *filter_c2usfops(struct filter_fs *cache);
-struct super_operations *filter_c2csops(struct filter_fs *cache);
-struct inode_operations *filter_c2cfiops(struct filter_fs *cache);
-struct inode_operations *filter_c2cdiops(struct filter_fs *cache);
-struct inode_operations *filter_c2csiops(struct filter_fs *cache);
-struct file_operations *filter_c2cffops(struct filter_fs *cache);
-struct file_operations *filter_c2cdfops(struct filter_fs *cache);
-struct file_operations *filter_c2csfops(struct filter_fs *cache);
-struct dentry_operations *filter_c2cdops(struct filter_fs *cache);
-struct dentry_operations *filter_c2udops(struct filter_fs *cache);
-
-void filter_setup_super_ops(struct filter_fs *cache, struct super_operations *cache_ops, struct super_operations *filter_sops);
-void filter_setup_dir_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *ffops);
-void filter_setup_file_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *filter_op);
-void filter_setup_symlink_ops(struct filter_fs *cache, struct inode *cache_inode, struct inode_operations *filter_iops, struct file_operations *filter_op);
-void filter_setup_dentry_ops(struct filter_fs *cache, struct dentry_operations *cache_dop, struct dentry_operations *filter_dop);
-
-
-#define PRESTO_DEBUG
-#ifdef PRESTO_DEBUG
-/* debugging masks */
-#define D_SUPER 1
-#define D_INODE 2 /* print entry and exit into procedure */
-#define D_FILE 4
-#define D_CACHE 8 /* cache debugging */
-#define D_MALLOC 16 /* print malloc, de-alloc information */
-#define D_JOURNAL 32
-#define D_UPCALL 64 /* up and downcall debugging */
-#define D_PSDEV 128
-#define D_PIOCTL 256
-#define D_SPECIAL 512
-#define D_TIMING 1024
-#define D_DOWNCALL 2048
-
-#define FDEBUG(mask, format, a...) \
- do { \
- if (filter_debug & mask) { \
- printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
- printk(format, ##a); } \
- } while (0)
-
-#define FENTRY \
- if(filter_print_entry) \
- printk("Process %d entered %s\n", current->pid, __FUNCTION__)
-
-#define FEXIT \
- if(filter_print_entry) \
- printk("Process %d leaving %s at %d\n", current->pid, \
- __FUNCTION__,__LINE__)
-#endif
-#endif
-#endif
+++ /dev/null
-/*
- * INET An implementation of the TCP/IP protocol suite for the LINUX
- * operating system. INET is implemented using the BSD Socket
- * interface as the means of communication with the user level.
- *
- * Miscellaneous internetwork definitions for kernel.
- *
- * Version: @(#)in_systm.h 1.0.0 12/17/93
- *
- * Authors: Original taken from Berkeley BSD UNIX 4.3-RENO.
- * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#ifndef _LINUX_IN_SYSTM_H
-#define _LINUX_IN_SYSTM_H
-
-/*
- * Network types.
- * The n_ types are network-order variants of their natural
- * equivalents. The Linux kernel NET-2 code does not use
- * them (yet), but it might in the future. This is mostly
- * there for compatibility with BSD user-level programs.
- */
-typedef u_short n_short; /* short as received from the net */
-typedef u_long n_long; /* long as received from the net */
-typedef u_long n_time; /* ms since 00:00 GMT, byte rev */
-
-#endif /* _LINUX_IN_SYSTM_H */
+++ /dev/null
-/* $Id: isdn_lzscomp.h,v 1.1.10.1 2001/09/23 22:25:05 kai Exp $
- *
- * Header for isdn_lzscomp.c
- * Concentrated here to not mess up half a dozen kernel headers with code
- * snippets
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- */
-
-#define CI_LZS_COMPRESS 17
-#define CILEN_LZS_COMPRESS 5
-
-#define LZS_CMODE_NONE 0
-#define LZS_CMODE_LCB 1
-#define LZS_CMODE_CRC 2
-#define LZS_CMODE_SEQNO 3 /* MUST be implemented (default) */
-#define LZS_CMODE_EXT 4 /* Seems to be what Win0.95 uses */
-
-#define LZS_COMP_MAX_HISTS 1 /* Don't waste peers ressources */
-#define LZS_COMP_DEF_HISTS 1 /* Most likely to negotiate */
-#define LZS_DECOMP_MAX_HISTS 32 /* More is really nonsense */
-#define LZS_DECOMP_DEF_HISTS 8 /* If we get it, this may be optimal */
-
-#define LZS_HIST_BYTE1(word) (word>>8) /* Just for better reading */
-#define LZS_HIST_BYTE2(word) (word&0xff) /* of this big endian stuff */
-#define LZS_HIST_WORD(b1,b2) ((b1<<8)|b2) /* (network byte order rulez) */
+++ /dev/null
-#ifndef _LINUX_MPP_H
-#define _LINUX_MPP_H
-
-/*
- * Definitions related to Massively Parallel Processing support.
- */
-
-/* All mpp implementations must supply these functions */
-
-extern void mpp_init(void);
-extern void mpp_hw_init(void);
-extern void mpp_procfs_init(void);
-
-extern int mpp_num_cells(void);
-extern int mpp_cid(void);
-extern int get_mppinfo(char *buffer);
-
-#endif
+++ /dev/null
-#ifndef _LINUX_NETBEUI_H
-#define _LINUX_NETBEUI_H
-
-#include <linux/if.h>
-
-#define NB_NAME_LEN 20 /* Set this properly from the full docs when
- I get them */
-
-struct sockaddr_netbeui
-{
- sa_family snb_family;
- char snb_name[NB_NAME_LEN];
- char snb_devhint[IFNAMSIZ];
-};
-
-#endif
+++ /dev/null
-#ifndef __LINUX_DDP_NETFILTER_H
-#define __LINUX_DDP_NETFILTER_H
-
-/* DDP-specific defines for netfilter. Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* Appletalk hooks */
-#define NF_DDP_INPUT 0
-#define NF_DDP_FORWARD 1
-#define NF_DDP_OUTPUT 2
-#endif /*__LINUX_DDP_NETFILTER_H*/
+++ /dev/null
-#ifndef _IP6T_REJECT_H
-#define _IP6T_REJECT_H
-
-enum ip6t_reject_with {
- IP6T_ICMP_NET_UNREACHABLE,
- IP6T_ICMP_HOST_UNREACHABLE,
- IP6T_ICMP_PROT_UNREACHABLE,
- IP6T_ICMP_PORT_UNREACHABLE,
- IP6T_ICMP_ECHOREPLY
-};
-
-struct ip6t_reject_info {
- enum ip6t_reject_with with; /* reject type */
-};
-
-#endif /*_IPT_REJECT_H*/
+++ /dev/null
-#ifndef __LINUX_IPX_NETFILTER_H
-#define __LINUX_IPX_NETFILTER_H
-
-/* IPX-specific defines for netfilter. Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* IPX Hooks */
-#define NF_IPX_INPUT 0
-#define NF_IPX_FORWARD 1
-#define NF_IPX_OUTPUT 2
-#endif /*__LINUX_IPX_NETFILTER_H*/
+++ /dev/null
-#ifndef __LINUX_X25_NETFILTER_H
-#define __LINUX_X25_NETFILTER_H
-
-/* X25-specific defines for netfilter. Complete me sometime.
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* Hooks */
-#define NF_X25_INPUT 0
-#define NF_X25_FORWARD 1
-#define NF_X25_OUTPUT 2
-
-#endif /*__LINUX_X25_NETFILTER_H*/
+++ /dev/null
-/*
- * Constant and architecture independent procedures
- * for NEC uPD4990A serial I/O real-time clock.
- *
- * Copyright 2001 TAKAI Kousuke <tak@kmc.kyoto-u.ac.jp>
- * Kyoto University Microcomputer Club (KMC).
- *
- * References:
- * uPD4990A serial I/O real-time clock users' manual (Japanese)
- * No. S12828JJ4V0UM00 (4th revision), NEC Corporation, 1999.
- */
-
-#ifndef _LINUX_uPD4990A_H
-#define _LINUX_uPD4990A_H
-
-#include <asm/byteorder.h>
-
-#include <asm/upd4990a.h>
-
-/* Serial commands (4 bits) */
-#define UPD4990A_REGISTER_HOLD (0x0)
-#define UPD4990A_REGISTER_SHIFT (0x1)
-#define UPD4990A_TIME_SET_AND_COUNTER_HOLD (0x2)
-#define UPD4990A_TIME_READ (0x3)
-#define UPD4990A_TP_64HZ (0x4)
-#define UPD4990A_TP_256HZ (0x5)
-#define UPD4990A_TP_2048HZ (0x6)
-#define UPD4990A_TP_4096HZ (0x7)
-#define UPD4990A_TP_1S (0x8)
-#define UPD4990A_TP_10S (0x9)
-#define UPD4990A_TP_30S (0xA)
-#define UPD4990A_TP_60S (0xB)
-#define UPD4990A_INTERRUPT_RESET (0xC)
-#define UPD4990A_INTERRUPT_TIMER_START (0xD)
-#define UPD4990A_INTERRUPT_TIMER_STOP (0xE)
-#define UPD4990A_TEST_MODE_SET (0xF)
-
-/* Parallel commands (3 bits)
- 0-6 are same with serial commands. */
-#define UPD4990A_PAR_SERIAL_MODE 7
-
-#ifndef UPD4990A_DELAY
-# include <linux/delay.h>
-# define UPD4990A_DELAY(usec) udelay((usec))
-#endif
-#ifndef UPD4990A_OUTPUT_DATA
-# define UPD4990A_OUTPUT_DATA(bit) \
- do { \
- UPD4990A_OUTPUT_DATA_CLK((bit), 0); \
- UPD4990A_DELAY(1); /* t-DSU */ \
- UPD4990A_OUTPUT_DATA_CLK((bit), 1); \
- UPD4990A_DELAY(1); /* t-DHLD */ \
- } while (0)
-#endif
-
-static __inline__ void upd4990a_serial_command(int command)
-{
- UPD4990A_OUTPUT_DATA(command >> 0);
- UPD4990A_OUTPUT_DATA(command >> 1);
- UPD4990A_OUTPUT_DATA(command >> 2);
- UPD4990A_OUTPUT_DATA(command >> 3);
- UPD4990A_DELAY(1); /* t-HLD */
- UPD4990A_OUTPUT_STROBE(1);
- UPD4990A_DELAY(1); /* t-STB & t-d1 */
- UPD4990A_OUTPUT_STROBE(0);
- /* 19 microseconds extra delay is needed
- iff previous mode is TIME READ command */
-}
-
-struct upd4990a_raw_data {
- u8 sec; /* BCD */
- u8 min; /* BCD */
- u8 hour; /* BCD */
- u8 mday; /* BCD */
-#if defined __LITTLE_ENDIAN_BITFIELD
- unsigned wday :4; /* 0-6 */
- unsigned mon :4; /* 1-based */
-#elif defined __BIG_ENDIAN_BITFIELD
- unsigned mon :4; /* 1-based */
- unsigned wday :4; /* 0-6 */
-#else
-# error Unknown bitfield endian!
-#endif
- u8 year; /* BCD */
-};
-
-static __inline__ void upd4990a_get_time(struct upd4990a_raw_data *buf,
- int leave_register_hold)
-{
- int byte;
-
- upd4990a_serial_command(UPD4990A_TIME_READ);
- upd4990a_serial_command(UPD4990A_REGISTER_SHIFT);
- UPD4990A_DELAY(19); /* t-d2 - t-d1 */
-
- for (byte = 0; byte < 6; byte++) {
- u8 tmp;
- int bit;
-
- for (tmp = 0, bit = 0; bit < 8; bit++) {
- tmp = (tmp | (UPD4990A_READ_DATA() << 8)) >> 1;
- UPD4990A_OUTPUT_CLK(1);
- UPD4990A_DELAY(1);
- UPD4990A_OUTPUT_CLK(0);
- UPD4990A_DELAY(1);
- }
- ((u8 *) buf)[byte] = tmp;
- }
-
- /* The uPD4990A users' manual says that we should issue `Register
- Hold' command after each data retrieval, or next `Time Read'
- command may not work correctly. */
- if (!leave_register_hold)
- upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-}
-
-static __inline__ void upd4990a_set_time(const struct upd4990a_raw_data *data,
- int time_set_only)
-{
- int byte;
-
- if (!time_set_only)
- upd4990a_serial_command(UPD4990A_REGISTER_SHIFT);
-
- for (byte = 0; byte < 6; byte++) {
- int bit;
- u8 tmp = ((const u8 *) data)[byte];
-
- for (bit = 0; bit < 8; bit++, tmp >>= 1)
- UPD4990A_OUTPUT_DATA(tmp);
- }
-
- upd4990a_serial_command(UPD4990A_TIME_SET_AND_COUNTER_HOLD);
-
- /* Release counter hold and start the clock. */
- if (!time_set_only)
- upd4990a_serial_command(UPD4990A_REGISTER_HOLD);
-}
-
-#endif /* _LINUX_uPD4990A_H */
+++ /dev/null
-#ifndef __SOUND_SNDMAGIC_H
-#define __SOUND_SNDMAGIC_H
-
-/*
- * Magic allocation, deallocation, check
- * Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-
-#ifdef CONFIG_SND_DEBUG_MEMORY
-
-void *_snd_magic_kcalloc(unsigned long magic, size_t size, int flags);
-void *_snd_magic_kmalloc(unsigned long magic, size_t size, int flags);
-
-/**
- * snd_magic_kmalloc - allocate a record with a magic-prefix
- * @type: the type to allocate a record (like xxx_t)
- * @extra: the extra size to allocate in bytes
- * @flags: the allocation condition (GFP_XXX)
- *
- * Allocates a record of the given type with the extra space and
- * returns its pointer. The allocated record has a secret magic-key
- * to be checked via snd_magic_cast() for safe casts.
- *
- * The allocated pointer must be released via snd_magic_kfree().
- *
- * The "struct xxx" style cannot be used as the type argument
- * because the magic-key constant is generated from the type-name
- * string.
- */
-#define snd_magic_kmalloc(type, extra, flags) \
- (type *) _snd_magic_kmalloc(type##_magic, sizeof(type) + extra, flags)
-/**
- * snd_magic_kcalloc - allocate a record with a magic-prefix and initialize
- * @type: the type to allocate a record (like xxx_t)
- * @extra: the extra size to allocate in bytes
- * @flags: the allocation condition (GFP_XXX)
- *
- * Works like snd_magic_kmalloc() but this clears the area with zero
- * automatically.
- */
-#define snd_magic_kcalloc(type, extra, flags) \
- (type *) _snd_magic_kcalloc(type##_magic, sizeof(type) + extra, flags)
-
-/**
- * snd_magic_kfree - release the allocated area
- * @ptr: the pointer allocated via snd_magic_kmalloc() or snd_magic_kcalloc()
- *
- * Releases the memory area allocated via snd_magic_kmalloc() or
- * snd_magic_kcalloc() function.
- */
-void snd_magic_kfree(void *ptr);
-
-static inline unsigned long _snd_magic_value(void *obj)
-{
- return obj == NULL ? (unsigned long)-1 : *(((unsigned long *)obj) - 1);
-}
-
-static inline int _snd_magic_bad(void *obj, unsigned long magic)
-{
- return _snd_magic_value(obj) != magic;
-}
-
-#define snd_magic_cast1(t, expr, cmd) snd_magic_cast(t, expr, cmd)
-
-/**
- * snd_magic_cast - check and cast the magic-allocated pointer
- * @type: the type of record to cast
- * @ptr: the magic-allocated pointer
- * @action...: the action to do if failed
- *
- * This macro provides a safe cast for the given type, which was
- * allocated via snd_magic_kmalloc() or snd_magic_kcallc().
- * If the pointer is invalid, i.e. the cast-type doesn't match,
- * the action arguments are called with a debug message.
- */
-#define snd_magic_cast(type, ptr, action...) \
- (type *) ({\
- void *__ptr = ptr;\
- unsigned long __magic = _snd_magic_value(__ptr);\
- if (__magic != type##_magic) {\
- snd_printk("bad MAGIC (0x%lx)\n", __magic);\
- action;\
- }\
- __ptr;\
-})
-
-#define snd_device_t_magic 0xa15a00ff
-#define snd_pcm_t_magic 0xa15a0101
-#define snd_pcm_file_t_magic 0xa15a0102
-#define snd_pcm_substream_t_magic 0xa15a0103
-#define snd_pcm_proc_private_t_magic 0xa15a0104
-#define snd_pcm_oss_file_t_magic 0xa15a0105
-#define snd_mixer_oss_t_magic 0xa15a0106
-// #define snd_pcm_sgbuf_t_magic 0xa15a0107
-
-#define snd_info_private_data_t_magic 0xa15a0201
-#define snd_info_entry_t_magic 0xa15a0202
-#define snd_ctl_file_t_magic 0xa15a0301
-#define snd_kcontrol_t_magic 0xa15a0302
-#define snd_rawmidi_t_magic 0xa15a0401
-#define snd_rawmidi_file_t_magic 0xa15a0402
-#define snd_virmidi_t_magic 0xa15a0403
-#define snd_virmidi_dev_t_magic 0xa15a0404
-#define snd_timer_t_magic 0xa15a0501
-#define snd_timer_user_t_magic 0xa15a0502
-#define snd_hwdep_t_magic 0xa15a0601
-#define snd_seq_device_t_magic 0xa15a0701
-
-#define es18xx_t_magic 0xa15a1101
-#define trident_t_magic 0xa15a1201
-#define es1938_t_magic 0xa15a1301
-#define cs46xx_t_magic 0xa15a1401
-#define cs46xx_pcm_t_magic 0xa15a1402
-#define ensoniq_t_magic 0xa15a1501
-#define sonicvibes_t_magic 0xa15a1601
-#define mpu401_t_magic 0xa15a1701
-#define fm801_t_magic 0xa15a1801
-#define ac97_t_magic 0xa15a1901
-#define ac97_bus_t_magic 0xa15a1902
-#define ak4531_t_magic 0xa15a1a01
-#define snd_uart16550_t_magic 0xa15a1b01
-#define emu10k1_t_magic 0xa15a1c01
-#define emu10k1_pcm_t_magic 0xa15a1c02
-#define emu10k1_midi_t_magic 0xa15a1c03
-#define snd_gus_card_t_magic 0xa15a1d01
-#define gus_pcm_private_t_magic 0xa15a1d02
-#define gus_proc_private_t_magic 0xa15a1d03
-#define tea6330t_t_magic 0xa15a1e01
-#define ad1848_t_magic 0xa15a1f01
-#define cs4231_t_magic 0xa15a2001
-#define es1688_t_magic 0xa15a2101
-#define opti93x_t_magic 0xa15a2201
-#define emu8000_t_magic 0xa15a2301
-#define emu8000_proc_private_t_magic 0xa15a2302
-#define snd_emux_t_magic 0xa15a2303
-#define snd_emux_port_t_magic 0xa15a2304
-#define sb_t_magic 0xa15a2401
-#define snd_sb_csp_t_magic 0xa15a2402
-#define snd_card_dummy_t_magic 0xa15a2501
-#define snd_card_dummy_pcm_t_magic 0xa15a2502
-#define opl3_t_magic 0xa15a2601
-#define opl4_t_magic 0xa15a2602
-#define snd_seq_dummy_port_t_magic 0xa15a2701
-#define ice1712_t_magic 0xa15a2801
-#define ad1816a_t_magic 0xa15a2901
-#define intel8x0_t_magic 0xa15a2a01
-#define es1968_t_magic 0xa15a2b01
-#define esschan_t_magic 0xa15a2b02
-#define via82xx_t_magic 0xa15a2c01
-#define pdplus_t_magic 0xa15a2d01
-#define cmipci_t_magic 0xa15a2e01
-#define ymfpci_t_magic 0xa15a2f01
-#define ymfpci_pcm_t_magic 0xa15a2f02
-#define cs4281_t_magic 0xa15a3001
-#define snd_i2c_bus_t_magic 0xa15a3101
-#define snd_i2c_device_t_magic 0xa15a3102
-#define cs8427_t_magic 0xa15a3111
-#define m3_t_magic 0xa15a3201
-#define m3_dma_t_magic 0xa15a3202
-#define nm256_t_magic 0xa15a3301
-#define nm256_dma_t_magic 0xa15a3302
-#define sam9407_t_magic 0xa15a3401
-#define pmac_t_magic 0xa15a3501
-#define ali_t_magic 0xa15a3601
-#define mtpav_t_magic 0xa15a3701
-#define mtpav_port_t_magic 0xa15a3702
-#define korg1212_t_magic 0xa15a3800
-#define opl3sa2_t_magic 0xa15a3900
-#define serialmidi_t_magic 0xa15a3a00
-#define sa11xx_uda1341_t_magic 0xa15a3b00
-#define uda1341_t_magic 0xa15a3c00
-#define l3_client_t_magic 0xa15a3d00
-#define snd_usb_audio_t_magic 0xa15a3e01
-#define usb_mixer_elem_info_t_magic 0xa15a3e02
-#define snd_usb_stream_t_magic 0xa15a3e03
-#define snd_usb_midi_t_magic 0xa15a3f01
-#define snd_usb_midi_out_endpoint_t_magic 0xa15a3f02
-#define snd_usb_midi_in_endpoint_t_magic 0xa15a3f03
-#define ak4117_t_magic 0xa15a4000
-#define psic_t_magic 0xa15a4100
-#define vx_core_t_magic 0xa15a4110
-#define vx_pipe_t_magic 0xa15a4112
-#define azf3328_t_magic 0xa15a4200
-#define snd_card_harmony_t_magic 0xa15a4300
-#define bt87x_t_magic 0xa15a4400
-#define pdacf_t_magic 0xa15a4500
-#define vortex_t_magic 0xa15a4601
-#define atiixp_t_magic 0xa15a4701
-#define amd7930_t_magic 0xa15a4801
-
-#else
-
-#define snd_magic_kcalloc(type, extra, flags) (type *) snd_kcalloc(sizeof(type) + extra, flags)
-#define snd_magic_kmalloc(type, extra, flags) (type *) kmalloc(sizeof(type) + extra, flags)
-#define snd_magic_cast(type, ptr, retval) (type *) ptr
-#define snd_magic_cast1(type, ptr, retval) snd_magic_cast(type, ptr, retval)
-#define snd_magic_kfree kfree
-
-#endif
-
-#endif /* __SOUND_SNDMAGIC_H */
+++ /dev/null
-/*
- * kernel/power/pmdisk.c - Suspend-to-disk implmentation
- *
- * This STD implementation is initially derived from swsusp (suspend-to-swap).
- * The original copyright on that was:
- *
- * Copyright (C) 1998-2001 Gabor Kuti <seasons@fornax.hu>
- * Copyright (C) 1998,2001,2002 Pavel Machek <pavel@suse.cz>
- *
- * The additional parts are:
- *
- * Copyright (C) 2003 Patrick Mochel
- * Copyright (C) 2003 Open Source Development Lab
- *
- * This file is released under the GPLv2.
- *
- * For more information, please see the text files in Documentation/power/
- *
- */
-
-#undef DEBUG
-
-#include <linux/mm.h>
-#include <linux/bio.h>
-#include <linux/suspend.h>
-#include <linux/version.h>
-#include <linux/reboot.h>
-#include <linux/device.h>
-#include <linux/swapops.h>
-#include <linux/bootmem.h>
-#include <linux/utsname.h>
-
-#include <asm/mmu_context.h>
-
-#include "power.h"
-
-
-extern asmlinkage int pmdisk_arch_suspend(int resume);
-
-#define __ADDRESS(x) ((unsigned long) phys_to_virt(x))
-#define ADDRESS(x) __ADDRESS((x) << PAGE_SHIFT)
-#define ADDRESS2(x) __ADDRESS(__pa(x)) /* Needed for x86-64 where some pages are in memory twice */
-
-/* References to section boundaries */
-extern char __nosave_begin, __nosave_end;
-
-extern int is_head_of_free_region(struct page *);
-
-/* Variables to be preserved over suspend */
-static int pagedir_order_check;
-static int nr_copy_pages_check;
-
-/* For resume= kernel option */
-static char resume_file[256] = CONFIG_PM_DISK_PARTITION;
-
-static dev_t resume_device;
-/* Local variables that should not be affected by save */
-unsigned int pmdisk_pages __nosavedata = 0;
-
-/* Suspend pagedir is allocated before final copy, therefore it
- must be freed after resume
-
- Warning: this is evil. There are actually two pagedirs at time of
- resume. One is "pagedir_save", which is empty frame allocated at
- time of suspend, that must be freed. Second is "pagedir_nosave",
- allocated at time of resume, that travels through memory not to
- collide with anything.
- */
-suspend_pagedir_t *pm_pagedir_nosave __nosavedata = NULL;
-static suspend_pagedir_t *pagedir_save;
-static int pagedir_order __nosavedata = 0;
-
-
-struct pmdisk_info {
- struct new_utsname uts;
- u32 version_code;
- unsigned long num_physpages;
- int cpus;
- unsigned long image_pages;
- unsigned long pagedir_pages;
- swp_entry_t pagedir[768];
-} __attribute__((aligned(PAGE_SIZE))) pmdisk_info;
-
-
-
-#define PMDISK_SIG "pmdisk-swap1"
-
-struct pmdisk_header {
- char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
- swp_entry_t pmdisk_info;
- char orig_sig[10];
- char sig[10];
-} __attribute__((packed, aligned(PAGE_SIZE))) pmdisk_header;
-
-/*
- * XXX: We try to keep some more pages free so that I/O operations succeed
- * without paging. Might this be more?
- */
-#define PAGES_FOR_IO 512
-
-
-/*
- * Saving part...
- */
-
-
-/* We memorize in swapfile_used what swap devices are used for suspension */
-#define SWAPFILE_UNUSED 0
-#define SWAPFILE_SUSPEND 1 /* This is the suspending device */
-#define SWAPFILE_IGNORED 2 /* Those are other swap devices ignored for suspension */
-
-static unsigned short swapfile_used[MAX_SWAPFILES];
-static unsigned short root_swap;
-
-
-static int mark_swapfiles(swp_entry_t prev)
-{
- int error;
-
- rw_swap_page_sync(READ,
- swp_entry(root_swap, 0),
- virt_to_page((unsigned long)&pmdisk_header));
- if (!memcmp("SWAP-SPACE",pmdisk_header.sig,10) ||
- !memcmp("SWAPSPACE2",pmdisk_header.sig,10)) {
- memcpy(pmdisk_header.orig_sig,pmdisk_header.sig,10);
- memcpy(pmdisk_header.sig,PMDISK_SIG,10);
- pmdisk_header.pmdisk_info = prev;
- error = rw_swap_page_sync(WRITE,
- swp_entry(root_swap, 0),
- virt_to_page((unsigned long)
- &pmdisk_header));
- } else {
- pr_debug("pmdisk: Partition is not swap space.\n");
- error = -ENODEV;
- }
- return error;
-}
-
-static int read_swapfiles(void) /* This is called before saving image */
-{
- int i, len;
-
- len=strlen(resume_file);
- root_swap = 0xFFFF;
-
- swap_list_lock();
- for(i=0; i<MAX_SWAPFILES; i++) {
- if (swap_info[i].flags == 0) {
- swapfile_used[i]=SWAPFILE_UNUSED;
- } else {
- if(!len) {
- pr_debug("pmdisk: Default resume partition not set.\n");
- if(root_swap == 0xFFFF) {
- swapfile_used[i] = SWAPFILE_SUSPEND;
- root_swap = i;
- } else
- swapfile_used[i] = SWAPFILE_IGNORED;
- } else {
- /* we ignore all swap devices that are not the resume_file */
- if (1) {
-// FIXME if(resume_device == swap_info[i].swap_device) {
- swapfile_used[i] = SWAPFILE_SUSPEND;
- root_swap = i;
- } else
- swapfile_used[i] = SWAPFILE_IGNORED;
- }
- }
- }
- swap_list_unlock();
- return (root_swap != 0xffff) ? 0 : -ENODEV;
-}
-
-
-/* This is called after saving image so modification
- will be lost after resume... and that's what we want. */
-static void lock_swapdevices(void)
-{
- int i;
-
- swap_list_lock();
- for(i = 0; i< MAX_SWAPFILES; i++)
- if(swapfile_used[i] == SWAPFILE_IGNORED) {
- swap_info[i].flags ^= 0xFF; /* we make the device unusable. A new call to
- lock_swapdevices can unlock the devices. */
- }
- swap_list_unlock();
-}
-
-
-
-/**
- * write_swap_page - Write one page to a fresh swap location.
- * @addr: Address we're writing.
- * @loc: Place to store the entry we used.
- *
- * Allocate a new swap entry and 'sync' it. Note we discard -EIO
- * errors. That is an artifact left over from swsusp. It did not
- * check the return of rw_swap_page_sync() at all, since most pages
- * written back to swap would return -EIO.
- * This is a partial improvement, since we will at least return other
- * errors, though we need to eventually fix the damn code.
- */
-
-static int write_swap_page(unsigned long addr, swp_entry_t * loc)
-{
- swp_entry_t entry;
- int error = 0;
-
- entry = get_swap_page();
- if (swp_offset(entry) &&
- swapfile_used[swp_type(entry)] == SWAPFILE_SUSPEND) {
- error = rw_swap_page_sync(WRITE, entry,
- virt_to_page(addr));
- if (error == -EIO)
- error = 0;
- if (!error)
- *loc = entry;
- } else
- error = -ENOSPC;
- return error;
-}
-
-
-/**
- * free_data - Free the swap entries used by the saved image.
- *
- * Walk the list of used swap entries and free each one.
- */
-
-static void free_data(void)
-{
- swp_entry_t entry;
- int i;
-
- for (i = 0; i < pmdisk_pages; i++) {
- entry = (pm_pagedir_nosave + i)->swap_address;
- if (entry.val)
- swap_free(entry);
- else
- break;
- (pm_pagedir_nosave + i)->swap_address = (swp_entry_t){0};
- }
-}
-
-
-/**
- * write_data - Write saved image to swap.
- *
- * Walk the list of pages in the image and sync each one to swap.
- */
-
-static int write_data(void)
-{
- int error = 0;
- int i;
-
- printk( "Writing data to swap (%d pages): ", pmdisk_pages );
- for (i = 0; i < pmdisk_pages && !error; i++) {
- if (!(i%100))
- printk( "." );
- error = write_swap_page((pm_pagedir_nosave+i)->address,
- &((pm_pagedir_nosave+i)->swap_address));
- }
- printk(" %d Pages done.\n",i);
- return error;
-}
-
-
-/**
- * free_pagedir - Free pages used by the page directory.
- */
-
-static void free_pagedir_entries(void)
-{
- int num = pmdisk_info.pagedir_pages;
- int i;
-
- for (i = 0; i < num; i++)
- swap_free(pmdisk_info.pagedir[i]);
-}
-
-
-/**
- * write_pagedir - Write the array of pages holding the page directory.
- * @last: Last swap entry we write (needed for header).
- */
-
-static int write_pagedir(void)
-{
- unsigned long addr = (unsigned long)pm_pagedir_nosave;
- int error = 0;
- int n = SUSPEND_PD_PAGES(pmdisk_pages);
- int i;
-
- pmdisk_info.pagedir_pages = n;
- printk( "Writing pagedir (%d pages)\n", n);
- for (i = 0; i < n && !error; i++, addr += PAGE_SIZE)
- error = write_swap_page(addr,&pmdisk_info.pagedir[i]);
- return error;
-}
-
-
-#ifdef DEBUG
-static void dump_pmdisk_info(void)
-{
- printk(" pmdisk: Version: %u\n",pmdisk_info.version_code);
- printk(" pmdisk: Num Pages: %ld\n",pmdisk_info.num_physpages);
- printk(" pmdisk: UTS Sys: %s\n",pmdisk_info.uts.sysname);
- printk(" pmdisk: UTS Node: %s\n",pmdisk_info.uts.nodename);
- printk(" pmdisk: UTS Release: %s\n",pmdisk_info.uts.release);
- printk(" pmdisk: UTS Version: %s\n",pmdisk_info.uts.version);
- printk(" pmdisk: UTS Machine: %s\n",pmdisk_info.uts.machine);
- printk(" pmdisk: UTS Domain: %s\n",pmdisk_info.uts.domainname);
- printk(" pmdisk: CPUs: %d\n",pmdisk_info.cpus);
- printk(" pmdisk: Image: %ld Pages\n",pmdisk_info.image_pages);
- printk(" pmdisk: Pagedir: %ld Pages\n",pmdisk_info.pagedir_pages);
-}
-#else
-static void dump_pmdisk_info(void)
-{
-
-}
-#endif
-
-static void init_header(void)
-{
- memset(&pmdisk_info,0,sizeof(pmdisk_info));
- pmdisk_info.version_code = LINUX_VERSION_CODE;
- pmdisk_info.num_physpages = num_physpages;
- memcpy(&pmdisk_info.uts,&system_utsname,sizeof(system_utsname));
-
- pmdisk_info.cpus = num_online_cpus();
- pmdisk_info.image_pages = pmdisk_pages;
-}
-
-/**
- * write_header - Fill and write the suspend header.
- * @entry: Location of the last swap entry used.
- *
- * Allocate a page, fill header, write header.
- *
- * @entry is the location of the last pagedir entry written on
- * entrance. On exit, it contains the location of the header.
- */
-
-static int write_header(swp_entry_t * entry)
-{
- dump_pmdisk_info();
- return write_swap_page((unsigned long)&pmdisk_info,entry);
-}
-
-
-
-/**
- * write_suspend_image - Write entire image and metadata.
- *
- */
-
-static int write_suspend_image(void)
-{
- int error;
- swp_entry_t prev = { 0 };
-
- init_header();
-
- if ((error = write_data()))
- goto FreeData;
-
- if ((error = write_pagedir()))
- goto FreePagedir;
-
- if ((error = write_header(&prev)))
- goto FreePagedir;
-
- error = mark_swapfiles(prev);
- Done:
- return error;
- FreePagedir:
- free_pagedir_entries();
- FreeData:
- free_data();
- goto Done;
-}
-
-
-
-/**
- * saveable - Determine whether a page should be cloned or not.
- * @pfn: The page
- *
- * We save a page if it's Reserved, and not in the range of pages
- * statically defined as 'unsaveable', or if it isn't reserved, and
- * isn't part of a free chunk of pages.
- * If it is part of a free chunk, we update @pfn to point to the last
- * page of the chunk.
- */
-
-static int saveable(unsigned long * pfn)
-{
- struct page * page = pfn_to_page(*pfn);
-
- if (PageNosave(page))
- return 0;
-
- if (!PageReserved(page)) {
- int chunk_size;
-
- if ((chunk_size = is_head_of_free_region(page))) {
- *pfn += chunk_size - 1;
- return 0;
- }
- } else if (PageReserved(page)) {
- /* Just copy whole code segment.
- * Hopefully it is not that big.
- */
- if ((ADDRESS(*pfn) >= (unsigned long) ADDRESS2(&__nosave_begin)) &&
- (ADDRESS(*pfn) < (unsigned long) ADDRESS2(&__nosave_end))) {
- pr_debug("[nosave %lx]\n", ADDRESS(*pfn));
- return 0;
- }
- /* Hmm, perhaps copying all reserved pages is not
- * too healthy as they may contain
- * critical bios data?
- */
- }
- return 1;
-}
-
-
-
-/**
- * count_pages - Determine size of page directory.
- *
- * Iterate over all the pages in the system and tally the number
- * we need to clone.
- */
-
-static void count_pages(void)
-{
- unsigned long pfn;
- int n = 0;
-
- for (pfn = 0; pfn < max_pfn; pfn++) {
- if (saveable(&pfn))
- n++;
- }
- pmdisk_pages = n;
-}
-
-
-/**
- * copy_pages - Atomically snapshot memory.
- *
- * Iterate over all the pages in the system and copy each one
- * into its corresponding location in the pagedir.
- * We rely on the fact that the number of pages that we're snap-
- * shotting hasn't changed since we counted them.
- */
-
-static void copy_pages(void)
-{
- struct pbe * p = pagedir_save;
- unsigned long pfn;
- int n = 0;
-
- for (pfn = 0; pfn < max_pfn; pfn++) {
- if (saveable(&pfn)) {
- n++;
- p->orig_address = ADDRESS(pfn);
- copy_page((void *) p->address,
- (void *) p->orig_address);
- p++;
- }
- }
- BUG_ON(n != pmdisk_pages);
-}
-
-
-/**
- * free_image_pages - Free each page allocated for snapshot.
- */
-
-static void free_image_pages(void)
-{
- struct pbe * p;
- int i;
-
- for (i = 0, p = pagedir_save; i < pmdisk_pages; i++, p++) {
- ClearPageNosave(virt_to_page(p->address));
- free_page(p->address);
- }
-}
-
-
-/**
- * free_pagedir - Free the page directory.
- */
-
-static void free_pagedir(void)
-{
- free_image_pages();
- free_pages((unsigned long)pagedir_save, pagedir_order);
-}
-
-
-static void calc_order(void)
-{
- int diff;
- int order;
-
- order = get_bitmask_order(SUSPEND_PD_PAGES(pmdisk_pages));
- pmdisk_pages += 1 << order;
- do {
- diff = get_bitmask_order(SUSPEND_PD_PAGES(pmdisk_pages)) - order;
- if (diff) {
- order += diff;
- pmdisk_pages += 1 << diff;
- }
- } while(diff);
- pagedir_order = order;
-}
-
-
-/**
- * alloc_pagedir - Allocate the page directory.
- *
- * First, determine exactly how many contiguous pages we need,
- * allocate them, then mark each 'unsavable'.
- */
-
-static int alloc_pagedir(void)
-{
- calc_order();
- pagedir_save = (suspend_pagedir_t *)__get_free_pages(GFP_ATOMIC | __GFP_COLD,
- pagedir_order);
- if(!pagedir_save)
- return -ENOMEM;
- memset(pagedir_save,0,(1 << pagedir_order) * PAGE_SIZE);
- pm_pagedir_nosave = pagedir_save;
- return 0;
-}
-
-
-/**
- * alloc_image_pages - Allocate pages for the snapshot.
- *
- */
-
-static int alloc_image_pages(void)
-{
- struct pbe * p;
- int i;
-
- for (i = 0, p = pagedir_save; i < pmdisk_pages; i++, p++) {
- p->address = get_zeroed_page(GFP_ATOMIC | __GFP_COLD);
- if(!p->address)
- goto Error;
- SetPageNosave(virt_to_page(p->address));
- }
- return 0;
- Error:
- do {
- if (p->address)
- free_page(p->address);
- p->address = 0;
- } while (p-- > pagedir_save);
- return -ENOMEM;
-}
-
-
-/**
- * enough_free_mem - Make sure we enough free memory to snapshot.
- *
- * Returns TRUE or FALSE after checking the number of available
- * free pages.
- */
-
-static int enough_free_mem(void)
-{
- if(nr_free_pages() < (pmdisk_pages + PAGES_FOR_IO)) {
- pr_debug("pmdisk: Not enough free pages: Have %d\n",
- nr_free_pages());
- return 0;
- }
- return 1;
-}
-
-
-/**
- * enough_swap - Make sure we have enough swap to save the image.
- *
- * Returns TRUE or FALSE after checking the total amount of swap
- * space avaiable.
- *
- * FIXME: si_swapinfo(&i) returns all swap devices information.
- * We should only consider resume_device.
- */
-
-static int enough_swap(void)
-{
- struct sysinfo i;
-
- si_swapinfo(&i);
- if (i.freeswap < (pmdisk_pages + PAGES_FOR_IO)) {
- pr_debug("pmdisk: Not enough swap. Need %ld\n",i.freeswap);
- return 0;
- }
- return 1;
-}
-
-
-/**
- * pmdisk_suspend - Atomically snapshot the system.
- *
- * This must be called with interrupts disabled, to prevent the
- * system changing at all from underneath us.
- *
- * To do this, we count the number of pages in the system that we
- * need to save; make sure we have enough memory and swap to clone
- * the pages and save them in swap, allocate the space to hold them,
- * and then snapshot them all.
- */
-
-int pmdisk_suspend(void)
-{
- int error = 0;
-
- if ((error = read_swapfiles()))
- return error;
-
- drain_local_pages();
-
- pm_pagedir_nosave = NULL;
- pr_debug("pmdisk: Counting pages to copy.\n" );
- count_pages();
-
- pr_debug("pmdisk: (pages needed: %d + %d free: %d)\n",
- pmdisk_pages,PAGES_FOR_IO,nr_free_pages());
-
- if (!enough_free_mem())
- return -ENOMEM;
-
- if (!enough_swap())
- return -ENOSPC;
-
- if ((error = alloc_pagedir())) {
- pr_debug("pmdisk: Allocating pagedir failed.\n");
- return error;
- }
- if ((error = alloc_image_pages())) {
- pr_debug("pmdisk: Allocating image pages failed.\n");
- free_pagedir();
- return error;
- }
-
- nr_copy_pages_check = pmdisk_pages;
- pagedir_order_check = pagedir_order;
-
- /* During allocating of suspend pagedir, new cold pages may appear.
- * Kill them
- */
- drain_local_pages();
-
- /* copy */
- copy_pages();
-
- /*
- * End of critical section. From now on, we can write to memory,
- * but we should not touch disk. This specially means we must _not_
- * touch swap space! Except we must write out our image of course.
- */
-
- pr_debug("pmdisk: %d pages copied\n", pmdisk_pages );
- return 0;
-}
-
-
-/**
- * suspend_save_image - Prepare and write saved image to swap.
- *
- * IRQs are re-enabled here so we can resume devices and safely write
- * to the swap devices. We disable them again before we leave.
- *
- * The second lock_swapdevices() will unlock ignored swap devices since
- * writing is finished.
- * It is important _NOT_ to umount filesystems at this point. We want
- * them synced (in case something goes wrong) but we DO not want to mark
- * filesystem clean: it is not. (And it does not matter, if we resume
- * correctly, we'll mark system clean, anyway.)
- */
-
-static int suspend_save_image(void)
-{
- int error;
- device_resume();
- lock_swapdevices();
- error = write_suspend_image();
- lock_swapdevices();
- return error;
-}
-
-/*
- * Magic happens here
- */
-
-int pmdisk_resume(void)
-{
- BUG_ON (nr_copy_pages_check != pmdisk_pages);
- BUG_ON (pagedir_order_check != pagedir_order);
-
- /* Even mappings of "global" things (vmalloc) need to be fixed */
- __flush_tlb_global();
- return 0;
-}
-
-/* pmdisk_arch_suspend() is implemented in arch/?/power/pmdisk.S,
- and basically does:
-
- if (!resume) {
- save_processor_state();
- SAVE_REGISTERS
- return pmdisk_suspend();
- }
- GO_TO_SWAPPER_PAGE_TABLES
- COPY_PAGES_BACK
- RESTORE_REGISTERS
- restore_processor_state();
- return pmdisk_resume();
-
- */
-
-
-/* More restore stuff */
-
-#define does_collide(addr) does_collide_order(pm_pagedir_nosave, addr, 0)
-
-/*
- * Returns true if given address/order collides with any orig_address
- */
-static int __init does_collide_order(suspend_pagedir_t *pagedir,
- unsigned long addr, int order)
-{
- int i;
- unsigned long addre = addr + (PAGE_SIZE<<order);
-
- for(i=0; i < pmdisk_pages; i++)
- if((pagedir+i)->orig_address >= addr &&
- (pagedir+i)->orig_address < addre)
- return 1;
-
- return 0;
-}
-
-/*
- * We check here that pagedir & pages it points to won't collide with pages
- * where we're going to restore from the loaded pages later
- */
-static int __init check_pagedir(void)
-{
- int i;
-
- for(i=0; i < pmdisk_pages; i++) {
- unsigned long addr;
-
- do {
- addr = get_zeroed_page(GFP_ATOMIC);
- if(!addr)
- return -ENOMEM;
- } while (does_collide(addr));
-
- (pm_pagedir_nosave+i)->address = addr;
- }
- return 0;
-}
-
-static int __init relocate_pagedir(void)
-{
- /*
- * We have to avoid recursion (not to overflow kernel stack),
- * and that's why code looks pretty cryptic
- */
- suspend_pagedir_t *old_pagedir = pm_pagedir_nosave;
- void **eaten_memory = NULL;
- void **c = eaten_memory, *m, *f;
- int err;
-
- pr_debug("pmdisk: Relocating pagedir\n");
-
- if(!does_collide_order(old_pagedir, (unsigned long)old_pagedir, pagedir_order)) {
- pr_debug("pmdisk: Relocation not necessary\n");
- return 0;
- }
-
- err = -ENOMEM;
- while ((m = (void *) __get_free_pages(GFP_ATOMIC, pagedir_order)) != NULL) {
- if (!does_collide_order(old_pagedir, (unsigned long)m,
- pagedir_order)) {
- pm_pagedir_nosave =
- memcpy(m, old_pagedir,
- PAGE_SIZE << pagedir_order);
- err = 0;
- break;
- }
- eaten_memory = m;
- printk( "." );
- *eaten_memory = c;
- c = eaten_memory;
- }
-
- c = eaten_memory;
- while(c) {
- printk(":");
- f = c;
- c = *c;
- free_pages((unsigned long)f, pagedir_order);
- }
- printk("|\n");
- return err;
-}
-
-
-static struct block_device * resume_bdev;
-
-
-/**
- * Using bio to read from swap.
- * This code requires a bit more work than just using buffer heads
- * but, it is the recommended way for 2.5/2.6.
- * The following are to signal the beginning and end of I/O. Bios
- * finish asynchronously, while we want them to happen synchronously.
- * A simple atomic_t, and a wait loop take care of this problem.
- */
-
-static atomic_t io_done = ATOMIC_INIT(0);
-
-static void start_io(void)
-{
- atomic_set(&io_done,1);
-}
-
-static int end_io(struct bio * bio, unsigned int num, int err)
-{
- atomic_set(&io_done,0);
- return 0;
-}
-
-static void wait_io(void)
-{
- while(atomic_read(&io_done))
- io_schedule();
-}
-
-
-/**
- * submit - submit BIO request.
- * @rw: READ or WRITE.
- * @off physical offset of page.
- * @page: page we're reading or writing.
- *
- * Straight from the textbook - allocate and initialize the bio.
- * If we're writing, make sure the page is marked as dirty.
- * Then submit it and wait.
- */
-
-static int submit(int rw, pgoff_t page_off, void * page)
-{
- int error = 0;
- struct bio * bio;
-
- bio = bio_alloc(GFP_ATOMIC,1);
- if (!bio)
- return -ENOMEM;
- bio->bi_sector = page_off * (PAGE_SIZE >> 9);
- bio_get(bio);
- bio->bi_bdev = resume_bdev;
- bio->bi_end_io = end_io;
-
- if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
- printk("pmdisk: ERROR: adding page to bio at %ld\n",page_off);
- error = -EFAULT;
- goto Done;
- }
-
- if (rw == WRITE)
- bio_set_pages_dirty(bio);
- start_io();
- submit_bio(rw | (1 << BIO_RW_SYNC), bio);
- wait_io();
- Done:
- bio_put(bio);
- return error;
-}
-
-static int
-read_page(pgoff_t page_off, void * page)
-{
- return submit(READ,page_off,page);
-}
-
-static int
-write_page(pgoff_t page_off, void * page)
-{
- return submit(WRITE,page_off,page);
-}
-
-
-extern dev_t __init name_to_dev_t(const char *line);
-
-
-static int __init check_sig(void)
-{
- int error;
-
- memset(&pmdisk_header,0,sizeof(pmdisk_header));
- if ((error = read_page(0,&pmdisk_header)))
- return error;
- if (!memcmp(PMDISK_SIG,pmdisk_header.sig,10)) {
- memcpy(pmdisk_header.sig,pmdisk_header.orig_sig,10);
-
- /*
- * Reset swap signature now.
- */
- error = write_page(0,&pmdisk_header);
- } else {
- pr_debug(KERN_ERR "pmdisk: Invalid partition type.\n");
- return -EINVAL;
- }
- if (!error)
- pr_debug("pmdisk: Signature found, resuming\n");
- return error;
-}
-
-
-/*
- * Sanity check if this image makes sense with this kernel/swap context
- * I really don't think that it's foolproof but more than nothing..
- */
-
-static const char * __init sanity_check(void)
-{
- dump_pmdisk_info();
- if(pmdisk_info.version_code != LINUX_VERSION_CODE)
- return "kernel version";
- if(pmdisk_info.num_physpages != num_physpages)
- return "memory size";
- if (strcmp(pmdisk_info.uts.sysname,system_utsname.sysname))
- return "system type";
- if (strcmp(pmdisk_info.uts.release,system_utsname.release))
- return "kernel release";
- if (strcmp(pmdisk_info.uts.version,system_utsname.version))
- return "version";
- if (strcmp(pmdisk_info.uts.machine,system_utsname.machine))
- return "machine";
- if(pmdisk_info.cpus != num_online_cpus())
- return "number of cpus";
- return NULL;
-}
-
-
-static int __init check_header(void)
-{
- const char * reason = NULL;
- int error;
-
- init_header();
-
- if ((error = read_page(swp_offset(pmdisk_header.pmdisk_info),
- &pmdisk_info)))
- return error;
-
- /* Is this same machine? */
- if ((reason = sanity_check())) {
- printk(KERN_ERR "pmdisk: Resume mismatch: %s\n",reason);
- return -EPERM;
- }
- pmdisk_pages = pmdisk_info.image_pages;
- return error;
-}
-
-
-static int __init read_pagedir(void)
-{
- unsigned long addr;
- int i, n = pmdisk_info.pagedir_pages;
- int error = 0;
-
- pagedir_order = get_bitmask_order(n);
-
- addr =__get_free_pages(GFP_ATOMIC, pagedir_order);
- if (!addr)
- return -ENOMEM;
- pm_pagedir_nosave = (struct pbe *)addr;
-
- pr_debug("pmdisk: Reading pagedir (%d Pages)\n",n);
-
- for (i = 0; i < n && !error; i++, addr += PAGE_SIZE) {
- unsigned long offset = swp_offset(pmdisk_info.pagedir[i]);
- if (offset)
- error = read_page(offset, (void *)addr);
- else
- error = -EFAULT;
- }
- if (error)
- free_pages((unsigned long)pm_pagedir_nosave,pagedir_order);
- return error;
-}
-
-
-/**
- * read_image_data - Read image pages from swap.
- *
- * You do not need to check for overlaps, check_pagedir()
- * already did that.
- */
-
-static int __init read_image_data(void)
-{
- struct pbe * p;
- int error = 0;
- int i;
-
- printk( "Reading image data (%d pages): ", pmdisk_pages );
- for(i = 0, p = pm_pagedir_nosave; i < pmdisk_pages && !error; i++, p++) {
- if (!(i%100))
- printk( "." );
- error = read_page(swp_offset(p->swap_address),
- (void *)p->address);
- }
- printk(" %d done.\n",i);
- return error;
-}
-
-
-static int __init read_suspend_image(void)
-{
- int error = 0;
-
- if ((error = check_sig()))
- return error;
- if ((error = check_header()))
- return error;
- if ((error = read_pagedir()))
- return error;
- if ((error = relocate_pagedir()))
- goto FreePagedir;
- if ((error = check_pagedir()))
- goto FreePagedir;
- if ((error = read_image_data()))
- goto FreePagedir;
- Done:
- return error;
- FreePagedir:
- free_pages((unsigned long)pm_pagedir_nosave,pagedir_order);
- goto Done;
-}
-
-/**
- * pmdisk_save - Snapshot memory
- */
-
-int pmdisk_save(void)
-{
- int error;
-
-#if defined (CONFIG_HIGHMEM) || defined (CONFIG_DISCONTIGMEM)
- pr_debug("pmdisk: not supported with high- or discontig-mem.\n");
- return -EPERM;
-#endif
- if ((error = arch_prepare_suspend()))
- return error;
- local_irq_disable();
- save_processor_state();
- error = pmdisk_arch_suspend(0);
- restore_processor_state();
- local_irq_enable();
- return error;
-}
-
-
-/**
- * pmdisk_write - Write saved memory image to swap.
- *
- * pmdisk_arch_suspend(0) returns after system is resumed.
- *
- * pmdisk_arch_suspend() copies all "used" memory to "free" memory,
- * then unsuspends all device drivers, and writes memory to disk
- * using normal kernel mechanism.
- */
-
-int pmdisk_write(void)
-{
- return suspend_save_image();
-}
-
-
-/**
- * pmdisk_read - Read saved image from swap.
- */
-
-int __init pmdisk_read(void)
-{
- int error;
-
- if (!strlen(resume_file))
- return -ENOENT;
-
- resume_device = name_to_dev_t(resume_file);
- pr_debug("pmdisk: Resume From Partition: %s\n", resume_file);
-
- resume_bdev = open_by_devnum(resume_device, FMODE_READ);
- if (!IS_ERR(resume_bdev)) {
- set_blocksize(resume_bdev, PAGE_SIZE);
- error = read_suspend_image();
- blkdev_put(resume_bdev);
- } else
- error = PTR_ERR(resume_bdev);
-
- if (!error)
- pr_debug("Reading resume file was successful\n");
- else
- pr_debug("pmdisk: Error %d resuming\n", error);
- return error;
-}
-
-
-/**
- * pmdisk_restore - Replace running kernel with saved image.
- */
-
-int __init pmdisk_restore(void)
-{
- int error;
- local_irq_disable();
- save_processor_state();
- error = pmdisk_arch_suspend(1);
- restore_processor_state();
- local_irq_enable();
- return error;
-}
-
-
-/**
- * pmdisk_free - Free memory allocated to hold snapshot.
- */
-
-int pmdisk_free(void)
-{
- pr_debug( "Freeing prev allocated pagedir\n" );
- free_pagedir();
- return 0;
-}
-
-static int __init pmdisk_setup(char *str)
-{
- if (strlen(str)) {
- if (!strcmp(str,"off"))
- resume_file[0] = '\0';
- else
- strncpy(resume_file, str, 255);
- } else
- resume_file[0] = '\0';
- return 1;
-}
-
-__setup("pmdisk=", pmdisk_setup);
-
+++ /dev/null
-/* inffixed.h -- table for decoding fixed codes
- * Generated automatically by the maketree.c program
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-static uInt fixed_bl = 9;
-static uInt fixed_bd = 5;
-static inflate_huft fixed_tl[] = {
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254},
- {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115},
- {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193},
- {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161},
- {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225},
- {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145},
- {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209},
- {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177},
- {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241},
- {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227},
- {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
- {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169},
- {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233},
- {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153},
- {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217},
- {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185},
- {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249},
- {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163},
- {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197},
- {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
- {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
- {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
- {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
- {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
- {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
- {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
- {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
- {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
- {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
- {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
- {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
- {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
- {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
- {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
- {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
- {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
- {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
- {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
- {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
- {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
- {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
- {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
- {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
- {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
- {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
- {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
- {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
- {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
- {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
- {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
- {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
- {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
- {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
- {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
- {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
- {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
- {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
- {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
- {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
- {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
- {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
- {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
- {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
- {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
- };
-static inflate_huft fixed_td[] = {
- {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
- {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
- {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
- {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
- {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
- {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
- {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
- {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
- };
+++ /dev/null
-/*
- BlueZ - Bluetooth protocol stack for Linux
- Copyright (C) 2000-2001 Qualcomm Incorporated
-
- Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation;
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
- CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
- COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
- SOFTWARE IS DISCLAIMED.
-*/
-
-/*
- * Bluetooth symbols.
- *
- * $Id: syms.c,v 1.1 2002/03/08 21:06:59 maxk Exp $
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/skbuff.h>
-#include <linux/socket.h>
-
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-
-/* HCI Core */
-EXPORT_SYMBOL(hci_alloc_dev);
-EXPORT_SYMBOL(hci_free_dev);
-EXPORT_SYMBOL(hci_register_dev);
-EXPORT_SYMBOL(hci_unregister_dev);
-EXPORT_SYMBOL(hci_suspend_dev);
-EXPORT_SYMBOL(hci_resume_dev);
-
-EXPORT_SYMBOL(hci_register_proto);
-EXPORT_SYMBOL(hci_unregister_proto);
-
-EXPORT_SYMBOL(hci_get_route);
-EXPORT_SYMBOL(hci_connect);
-EXPORT_SYMBOL(hci_dev_get);
-EXPORT_SYMBOL(hci_conn_auth);
-EXPORT_SYMBOL(hci_conn_encrypt);
-
-EXPORT_SYMBOL(hci_send_acl);
-EXPORT_SYMBOL(hci_send_sco);
-EXPORT_SYMBOL(hci_send_cmd);
-EXPORT_SYMBOL(hci_si_event);
-
-/* Bluetooth lib */
-EXPORT_SYMBOL(bt_dump);
-EXPORT_SYMBOL(baswap);
-EXPORT_SYMBOL(batostr);
-EXPORT_SYMBOL(bt_err);
-
-/* Bluetooth sockets */
-EXPORT_SYMBOL(bt_sock_register);
-EXPORT_SYMBOL(bt_sock_unregister);
-EXPORT_SYMBOL(bt_sock_alloc);
-EXPORT_SYMBOL(bt_sock_link);
-EXPORT_SYMBOL(bt_sock_unlink);
-EXPORT_SYMBOL(bt_sock_recvmsg);
-EXPORT_SYMBOL(bt_sock_poll);
-EXPORT_SYMBOL(bt_accept_enqueue);
-EXPORT_SYMBOL(bt_accept_dequeue);
-EXPORT_SYMBOL(bt_sock_wait_state);
-
-EXPORT_SYMBOL(proc_bt);
+++ /dev/null
-/*
- * INET An implementation of the TCP/IP protocol suite for the LINUX
- * operating system. INET is implemented using the BSD Socket
- * interface as the means of communication with the user level.
- *
- * Dumb Network Address Translation.
- *
- * Version: $Id: ip_nat_dumb.c,v 1.11 2000/12/13 18:31:48 davem Exp $
- *
- * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Fixes:
- * Rani Assaf : A zero checksum is a special case
- * only in UDP
- * Rani Assaf : Added ICMP messages rewriting
- * Rani Assaf : Repaired wrong changes, made by ANK.
- *
- *
- * NOTE: It is just working model of real NAT.
- */
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/sched.h>
-#include <linux/skbuff.h>
-#include <linux/ip.h>
-#include <linux/icmp.h>
-#include <linux/netdevice.h>
-#include <net/sock.h>
-#include <net/ip.h>
-#include <net/icmp.h>
-#include <linux/tcp.h>
-#include <linux/udp.h>
-#include <net/checksum.h>
-#include <linux/route.h>
-#include <net/route.h>
-#include <net/ip_fib.h>
-
-
-int
-ip_do_nat(struct sk_buff *skb)
-{
- struct rtable *rt = (struct rtable*)skb->dst;
- struct iphdr *iph = skb->nh.iph;
- u32 odaddr = iph->daddr;
- u32 osaddr = iph->saddr;
- u16 check;
-
- IPCB(skb)->flags |= IPSKB_TRANSLATED;
-
- /* Rewrite IP header */
- iph->daddr = rt->rt_dst_map;
- iph->saddr = rt->rt_src_map;
- iph->check = 0;
- iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
-
- /* If it is the first fragment, rewrite protocol headers */
-
- if (!(iph->frag_off & htons(IP_OFFSET))) {
- u16 *cksum;
-
- switch(iph->protocol) {
- case IPPROTO_TCP:
- cksum = (u16*)&((struct tcphdr*)(((char*)iph) + (iph->ihl<<2)))->check;
- if ((u8*)(cksum+1) > skb->tail)
- goto truncated;
- check = *cksum;
- if (skb->ip_summed != CHECKSUM_HW)
- check = ~check;
- check = csum_tcpudp_magic(iph->saddr, iph->daddr, 0, 0, check);
- check = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check);
- if (skb->ip_summed == CHECKSUM_HW)
- check = ~check;
- *cksum = check;
- break;
- case IPPROTO_UDP:
- cksum = (u16*)&((struct udphdr*)(((char*)iph) + (iph->ihl<<2)))->check;
- if ((u8*)(cksum+1) > skb->tail)
- goto truncated;
- if ((check = *cksum) != 0) {
- check = csum_tcpudp_magic(iph->saddr, iph->daddr, 0, 0, ~check);
- check = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check);
- *cksum = check ? : 0xFFFF;
- }
- break;
- case IPPROTO_ICMP:
- {
- struct icmphdr *icmph = (struct icmphdr*)((char*)iph + (iph->ihl<<2));
- struct iphdr *ciph;
- u32 idaddr, isaddr;
- int updated;
-
- if ((icmph->type != ICMP_DEST_UNREACH) &&
- (icmph->type != ICMP_TIME_EXCEEDED) &&
- (icmph->type != ICMP_PARAMETERPROB))
- break;
-
- ciph = (struct iphdr *) (icmph + 1);
-
- if ((u8*)(ciph+1) > skb->tail)
- goto truncated;
-
- isaddr = ciph->saddr;
- idaddr = ciph->daddr;
- updated = 0;
-
- if (rt->rt_flags&RTCF_DNAT && ciph->saddr == odaddr) {
- ciph->saddr = iph->daddr;
- updated = 1;
- }
- if (rt->rt_flags&RTCF_SNAT) {
- if (ciph->daddr != osaddr) {
- struct fib_result res;
- unsigned flags = 0;
- struct flowi fl = {
- .iif = skb->dev->ifindex,
- .nl_u =
- { .ip4_u =
- { .daddr = ciph->saddr,
- .saddr = ciph->daddr,
-#ifdef CONFIG_IP_ROUTE_TOS
- .tos = RT_TOS(ciph->tos)
-#endif
- } },
- .proto = ciph->protocol };
-
- /* Use fib_lookup() until we get our own
- * hash table of NATed hosts -- Rani
- */
- if (fib_lookup(&fl, &res) == 0) {
- if (res.r) {
- ciph->daddr = fib_rules_policy(ciph->daddr, &res, &flags);
- if (ciph->daddr != idaddr)
- updated = 1;
- }
- fib_res_put(&res);
- }
- } else {
- ciph->daddr = iph->saddr;
- updated = 1;
- }
- }
- if (updated) {
- cksum = &icmph->checksum;
- /* Using tcpudp primitive. Why not? */
- check = csum_tcpudp_magic(ciph->saddr, ciph->daddr, 0, 0, ~(*cksum));
- *cksum = csum_tcpudp_magic(~isaddr, ~idaddr, 0, 0, ~check);
- }
- break;
- }
- default:
- break;
- }
- }
- return NET_RX_SUCCESS;
-
-truncated:
- /* should be return NET_RX_BAD; */
- return -EINVAL;
-}
+++ /dev/null
-/*********************************************************************
- *
- * Filename: crc.c
- * Version: 0.1
- * Description: CRC calculation routines
- * Status: Experimental.
- * Author: Dag Brattli <dagb@cs.uit.no>
- * Created at: Mon Aug 4 20:40:53 1997
- * Modified at: Sun May 2 20:28:08 1999
- * Modified by: Dag Brattli <dagb@cs.uit.no>
- * Sources: ppp.c by Michael Callahan <callahan@maths.ox.ac.uk>
- * Al Longyear <longyear@netcom.com>
- *
- ********************************************************************/
-
-#include <net/irda/crc.h>
-#include <linux/module.h>
-
-/*
- * This mysterious table is just the CRC of each possible byte. It can be
- * computed using the standard bit-at-a-time methods. The polynomial can
- * be seen in entry 128, 0x8408. This corresponds to x^0 + x^5 + x^12.
- * Add the implicit x^16, and you have the standard CRC-CCITT.
- */
-__u16 const irda_crc16_table[256] =
-{
- 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
- 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
- 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
- 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
- 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
- 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
- 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
- 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
- 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
- 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
- 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
- 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
- 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
- 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
- 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
- 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
- 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
- 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
- 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
- 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
- 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
- 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
- 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
- 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
- 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
- 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
- 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
- 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
- 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
- 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
- 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
- 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
-};
-EXPORT_SYMBOL(irda_crc16_table);
-
-__u16 irda_calc_crc16( __u16 fcs, __u8 const *buf, size_t len)
-{
- while (len--)
- fcs = irda_fcs(fcs, *buf++);
- return fcs;
-}
-EXPORT_SYMBOL(irda_calc_crc16);
+++ /dev/null
-/*
- * net/sched/sch_csz.c Clark-Shenker-Zhang scheduler.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/bitops.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/jiffies.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/socket.h>
-#include <linux/sockios.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/notifier.h>
-#include <net/ip.h>
-#include <net/route.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <net/pkt_sched.h>
-
-
-/* Clark-Shenker-Zhang algorithm.
- =======================================
-
- SOURCE.
-
- David D. Clark, Scott Shenker and Lixia Zhang
- "Supporting Real-Time Applications in an Integrated Services Packet
- Network: Architecture and Mechanism".
-
- CBQ presents a flexible universal algorithm for packet scheduling,
- but it has pretty poor delay characteristics.
- Round-robin scheduling and link-sharing goals
- apparently contradict minimization of network delay and jitter.
- Moreover, correct handling of predictive flows seems to be
- impossible in CBQ.
-
- CSZ presents a more precise but less flexible and less efficient
- approach. As I understand it, the main idea is to create
- WFQ flows for each guaranteed service and to allocate
- the rest of bandwidth to dummy flow-0. Flow-0 comprises
- the predictive services and the best effort traffic;
- it is handled by a priority scheduler with the highest
- priority band allocated for predictive services, and the rest ---
- to the best effort packets.
-
- Note that in CSZ flows are NOT limited to their bandwidth. It
- is supposed that the flow passed admission control at the edge
- of the QoS network and it doesn't need further shaping. Any
- attempt to improve the flow or to shape it to a token bucket
- at intermediate hops will introduce undesired delays and raise
- jitter.
-
- At the moment CSZ is the only scheduler that provides
- true guaranteed service. Another schemes (including CBQ)
- do not provide guaranteed delay and randomize jitter.
- There is a proof (Sally Floyd), that delay
- can be estimated by a IntServ compliant formula.
- This result is true formally, but it is wrong in principle.
- It takes into account only round-robin delays,
- ignoring delays introduced by link sharing i.e. overlimiting.
- Note that temporary overlimits are inevitable because
- real links are not ideal, and the real algorithm must take this
- into account.
-
- ALGORITHM.
-
- --- Notations.
-
- $B$ is link bandwidth (bits/sec).
-
- $I$ is set of all flows, including flow $0$.
- Every flow $a \in I$ has associated bandwidth slice $r_a < 1$ and
- $\sum_{a \in I} r_a = 1$.
-
- --- Flow model.
-
- Let $m_a$ is the number of backlogged bits in flow $a$.
- The flow is {\em active}, if $m_a > 0$.
- This number is a discontinuous function of time;
- when a packet $i$ arrives:
- \[
- m_a(t_i+0) - m_a(t_i-0) = L^i,
- \]
- where $L^i$ is the length of the arrived packet.
- The flow queue is drained continuously until $m_a == 0$:
- \[
- {d m_a \over dt} = - { B r_a \over \sum_{b \in A} r_b}.
- \]
- I.e. flow rates are their allocated rates proportionally
- scaled to take all available link bandwidth. Apparently,
- it is not the only possible policy. F.e. CBQ classes
- without borrowing would be modelled by:
- \[
- {d m_a \over dt} = - B r_a .
- \]
- More complicated hierarchical bandwidth allocation
- policies are possible, but unfortunately, the basic
- flow equations have a simple solution only for proportional
- scaling.
-
- --- Departure times.
-
- We calculate the time until the last bit of packet is sent:
- \[
- E_a^i(t) = { m_a(t_i) - \delta_a(t) \over r_a },
- \]
- where $\delta_a(t)$ is number of bits drained since $t_i$.
- We have to evaluate $E_a^i$ for all queued packets,
- then find the packet with minimal $E_a^i$ and send it.
-
- This sounds good, but direct implementation of the algorithm
- is absolutely infeasible. Luckily, if flow rates
- are scaled proportionally, the equations have a simple solution.
-
- The differential equation for $E_a^i$ is
- \[
- {d E_a^i (t) \over dt } = - { d \delta_a(t) \over dt} { 1 \over r_a} =
- { B \over \sum_{b \in A} r_b}
- \]
- with initial condition
- \[
- E_a^i (t_i) = { m_a(t_i) \over r_a } .
- \]
-
- Let's introduce an auxiliary function $R(t)$:
-
- --- Round number.
-
- Consider the following model: we rotate over active flows,
- sending $r_a B$ bits from every flow, so that we send
- $B \sum_{a \in A} r_a$ bits per round, that takes
- $\sum_{a \in A} r_a$ seconds.
-
- Hence, $R(t)$ (round number) is a monotonically increasing
- linear function of time when $A$ is not changed
- \[
- { d R(t) \over dt } = { 1 \over \sum_{a \in A} r_a }
- \]
- and it is continuous when $A$ changes.
-
- The central observation is that the quantity
- $F_a^i = R(t) + E_a^i(t)/B$ does not depend on time at all!
- $R(t)$ does not depend on flow, so that $F_a^i$ can be
- calculated only once on packet arrival, and we need not
- recalculate $E$ numbers and resorting queues.
- The number $F_a^i$ is called finish number of the packet.
- It is just the value of $R(t)$ when the last bit of packet
- is sent out.
-
- Maximal finish number on flow is called finish number of flow
- and minimal one is "start number of flow".
- Apparently, flow is active if and only if $F_a \leq R$.
-
- When a packet of length $L_i$ bit arrives to flow $a$ at time $t_i$,
- we calculate $F_a^i$ as:
-
- If flow was inactive ($F_a < R$):
- $F_a^i = R(t) + {L_i \over B r_a}$
- otherwise
- $F_a^i = F_a + {L_i \over B r_a}$
-
- These equations complete the algorithm specification.
-
- It looks pretty hairy, but there is a simple
- procedure for solving these equations.
- See procedure csz_update(), that is a generalization of
- the algorithm from S. Keshav's thesis Chapter 3
- "Efficient Implementation of Fair Queuing".
-
- NOTES.
-
- * We implement only the simplest variant of CSZ,
- when flow-0 is a explicit 4band priority fifo.
- This is bad, but we need a "peek" operation in addition
- to "dequeue" to implement complete CSZ.
- I do not want to do that, unless it is absolutely
- necessary.
-
- * A primitive support for token bucket filtering
- presents itself too. It directly contradicts CSZ, but
- even though the Internet is on the globe ... :-)
- "the edges of the network" really exist.
-
- BUGS.
-
- * Fixed point arithmetic is overcomplicated, suboptimal and even
- wrong. Check it later. */
-
-
-/* This number is arbitrary */
-
-#define CSZ_GUARANTEED 16
-#define CSZ_FLOWS (CSZ_GUARANTEED+4)
-
-struct csz_head
-{
- struct csz_head *snext;
- struct csz_head *sprev;
- struct csz_head *fnext;
- struct csz_head *fprev;
-};
-
-struct csz_flow
-{
- struct csz_head *snext;
- struct csz_head *sprev;
- struct csz_head *fnext;
- struct csz_head *fprev;
-
-/* Parameters */
- struct tc_ratespec rate;
- struct tc_ratespec slice;
- u32 *L_tab; /* Lookup table for L/(B*r_a) values */
- unsigned long limit; /* Maximal length of queue */
-#ifdef CSZ_PLUS_TBF
- struct tc_ratespec peakrate;
- __u32 buffer; /* Depth of token bucket, normalized
- as L/(B*r_a) */
- __u32 mtu;
-#endif
-
-/* Variables */
-#ifdef CSZ_PLUS_TBF
- unsigned long tokens; /* Tokens number: usecs */
- psched_time_t t_tbf;
- unsigned long R_tbf;
- int throttled;
-#endif
- unsigned peeked;
- unsigned long start; /* Finish number of the first skb */
- unsigned long finish; /* Finish number of the flow */
-
- struct sk_buff_head q; /* FIFO queue */
-};
-
-#define L2R(f,L) ((f)->L_tab[(L)>>(f)->slice.cell_log])
-
-struct csz_sched_data
-{
-/* Parameters */
- unsigned char rate_log; /* fixed point position for rate;
- * really we need not it */
- unsigned char R_log; /* fixed point position for round number */
- unsigned char delta_log; /* 1<<delta_log is maximal timeout in usecs;
- * 21 <-> 2.1sec is MAXIMAL value */
-
-/* Variables */
- struct tcf_proto *filter_list;
- u8 prio2band[TC_PRIO_MAX+1];
-#ifdef CSZ_PLUS_TBF
- struct timer_list wd_timer;
- long wd_expires;
-#endif
- psched_time_t t_c; /* Time check-point */
- unsigned long R_c; /* R-number check-point */
- unsigned long rate; /* Current sum of rates of active flows */
- struct csz_head s; /* Flows sorted by "start" */
- struct csz_head f; /* Flows sorted by "finish" */
-
- struct sk_buff_head other[4];/* Predicted (0) and the best efforts
- classes (1,2,3) */
- struct csz_flow flow[CSZ_GUARANTEED]; /* Array of flows */
-};
-
-/* These routines (csz_insert_finish and csz_insert_start) are
- the most time consuming part of all the algorithm.
-
- We insert to sorted list, so that time
- is linear with respect to number of active flows in the worst case.
- Note that we have not very large number of guaranteed flows,
- so that logarithmic algorithms (heap etc.) are useless,
- they are slower than linear one when length of list <= 32.
-
- Heap would take sence if we used WFQ for best efforts
- flows, but SFQ is better choice in this case.
- */
-
-
-/* Insert flow "this" to the list "b" before
- flow with greater finish number.
- */
-
-#if 0
-/* Scan forward */
-static inline void csz_insert_finish(struct csz_head *b,
- struct csz_flow *this)
-{
- struct csz_head *f = b->fnext;
- unsigned long finish = this->finish;
-
- while (f != b) {
- if (((struct csz_flow*)f)->finish - finish > 0)
- break;
- f = f->fnext;
- }
- this->fnext = f;
- this->fprev = f->fprev;
- this->fnext->fprev = this->fprev->fnext = (struct csz_head*)this;
-}
-#else
-/* Scan backward */
-static inline void csz_insert_finish(struct csz_head *b,
- struct csz_flow *this)
-{
- struct csz_head *f = b->fprev;
- unsigned long finish = this->finish;
-
- while (f != b) {
- if (((struct csz_flow*)f)->finish - finish <= 0)
- break;
- f = f->fprev;
- }
- this->fnext = f->fnext;
- this->fprev = f;
- this->fnext->fprev = this->fprev->fnext = (struct csz_head*)this;
-}
-#endif
-
-/* Insert flow "this" to the list "b" before
- flow with greater start number.
- */
-
-static inline void csz_insert_start(struct csz_head *b,
- struct csz_flow *this)
-{
- struct csz_head *f = b->snext;
- unsigned long start = this->start;
-
- while (f != b) {
- if (((struct csz_flow*)f)->start - start > 0)
- break;
- f = f->snext;
- }
- this->snext = f;
- this->sprev = f->sprev;
- this->snext->sprev = this->sprev->snext = (struct csz_head*)this;
-}
-
-
-/* Calculate and return current round number.
- It is another time consuming part, but
- it is impossible to avoid it.
-
- It costs O(N) that make all the algorithm useful only
- to play with closest to ideal fluid model.
-
- There exist less academic, but more practical modifications,
- which might have even better characteristics (WF2Q+, HPFQ, HFSC)
- */
-
-static unsigned long csz_update(struct Qdisc *sch)
-{
- struct csz_sched_data *q = (struct csz_sched_data*)sch->data;
- struct csz_flow *a;
- unsigned long F;
- unsigned long tmp;
- psched_time_t now;
- unsigned long delay;
- unsigned long R_c;
-
- PSCHED_GET_TIME(now);
- delay = PSCHED_TDIFF_SAFE(now, q->t_c, 0, goto do_reset);
-
- if (delay>>q->delta_log) {
-do_reset:
- /* Delta is too large.
- It is possible if MTU/BW > 1<<q->delta_log
- (i.e. configuration error) or because of hardware
- fault. We have no choice...
- */
- qdisc_reset(sch);
- return 0;
- }
-
- q->t_c = now;
-
- for (;;) {
- a = (struct csz_flow*)q->f.fnext;
-
- /* No more active flows. Reset R and exit. */
- if (a == (struct csz_flow*)&q->f) {
-#ifdef CSZ_DEBUG
- if (q->rate) {
- printk("csz_update: rate!=0 on inactive csz\n");
- q->rate = 0;
- }
-#endif
- q->R_c = 0;
- return 0;
- }
-
- F = a->finish;
-
-#ifdef CSZ_DEBUG
- if (q->rate == 0) {
- printk("csz_update: rate=0 on active csz\n");
- goto do_reset;
- }
-#endif
-
- /*
- * tmp = (t - q->t_c)/q->rate;
- */
-
- tmp = ((delay<<(31-q->delta_log))/q->rate)>>(31-q->delta_log+q->R_log);
-
- tmp += q->R_c;
-
- /* OK, this flow (and all flows with greater
- finish numbers) is still active */
- if (F - tmp > 0)
- break;
-
- /* It is more not active */
-
- a->fprev->fnext = a->fnext;
- a->fnext->fprev = a->fprev;
-
- /*
- * q->t_c += (F - q->R_c)*q->rate
- */
-
- tmp = ((F-q->R_c)*q->rate)<<q->R_log;
- R_c = F;
- q->rate -= a->slice.rate;
-
- if ((long)(delay - tmp) >= 0) {
- delay -= tmp;
- continue;
- }
- delay = 0;
- }
-
- q->R_c = tmp;
- return tmp;
-}
-
-unsigned csz_classify(struct sk_buff *skb, struct csz_sched_data *q)
-{
- return CSZ_GUARANTEED;
-}
-
-static int
-csz_enqueue(struct sk_buff *skb, struct Qdisc* sch)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- unsigned flow_id = csz_classify(skb, q);
- unsigned long R;
- int prio = 0;
- struct csz_flow *this;
-
- if (flow_id >= CSZ_GUARANTEED) {
- prio = flow_id - CSZ_GUARANTEED;
- flow_id = 0;
- }
-
- this = &q->flow[flow_id];
- if (this->q.qlen >= this->limit || this->L_tab == NULL) {
- sch->stats.drops++;
- kfree_skb(skb);
- return NET_XMIT_DROP;
- }
-
- R = csz_update(sch);
-
- if ((long)(this->finish - R) >= 0) {
- /* It was active */
- this->finish += L2R(this,skb->len);
- } else {
- /* It is inactive; activate it */
- this->finish = R + L2R(this,skb->len);
- q->rate += this->slice.rate;
- csz_insert_finish(&q->f, this);
- }
-
- /* If this flow was empty, remember start number
- and insert it into start queue */
- if (this->q.qlen == 0) {
- this->start = this->finish;
- csz_insert_start(&q->s, this);
- }
- if (flow_id)
- skb_queue_tail(&this->q, skb);
- else
- skb_queue_tail(&q->other[prio], skb);
- sch->q.qlen++;
- sch->stats.bytes += skb->len;
- sch->stats.packets++;
- return 0;
-}
-
-static __inline__ struct sk_buff *
-skb_dequeue_best(struct csz_sched_data * q)
-{
- int i;
- struct sk_buff *skb;
-
- for (i=0; i<4; i++) {
- skb = skb_dequeue(&q->other[i]);
- if (skb) {
- q->flow[0].q.qlen--;
- return skb;
- }
- }
- return NULL;
-}
-
-static __inline__ struct sk_buff *
-skb_peek_best(struct csz_sched_data * q)
-{
- int i;
- struct sk_buff *skb;
-
- for (i=0; i<4; i++) {
- skb = skb_peek(&q->other[i]);
- if (skb)
- return skb;
- }
- return NULL;
-}
-
-#ifdef CSZ_PLUS_TBF
-
-static void csz_watchdog(unsigned long arg)
-{
- struct Qdisc *sch = (struct Qdisc*)arg;
-
- qdisc_wakeup(sch->dev);
-}
-
-static __inline__ void
-csz_move_queue(struct csz_flow *this, long delta)
-{
- this->fprev->fnext = this->fnext;
- this->fnext->fprev = this->fprev;
-
- this->start += delta;
- this->finish += delta;
-
- csz_insert_finish(this);
-}
-
-static __inline__ int csz_enough_tokens(struct csz_sched_data *q,
- struct csz_flow *this,
- struct sk_buff *skb)
-{
- long toks;
- long shift;
- psched_time_t now;
-
- PSCHED_GET_TIME(now);
-
- toks = PSCHED_TDIFF(now, t_tbf) + this->tokens - L2R(q,this,skb->len);
-
- shift = 0;
- if (this->throttled) {
- /* Remember aposteriory delay */
-
- unsigned long R = csz_update(q);
- shift = R - this->R_tbf;
- this->R_tbf = R;
- }
-
- if (toks >= 0) {
- /* Now we have enough tokens to proceed */
-
- this->tokens = toks <= this->depth ? toks : this->depth;
- this->t_tbf = now;
-
- if (!this->throttled)
- return 1;
-
- /* Flow was throttled. Update its start&finish numbers
- with delay calculated aposteriori.
- */
-
- this->throttled = 0;
- if (shift > 0)
- csz_move_queue(this, shift);
- return 1;
- }
-
- if (!this->throttled) {
- /* Flow has just been throttled; remember
- current round number to calculate aposteriori delay
- */
- this->throttled = 1;
- this->R_tbf = csz_update(q);
- }
-
- /* Move all the queue to the time when it will be allowed to send.
- We should translate time to round number, but it is impossible,
- so that we made the most conservative estimate i.e. we suppose
- that only this flow is active and, hence, R = t.
- Really toks <= R <= toks/r_a.
-
- This apriory shift in R will be adjusted later to reflect
- real delay. We cannot avoid it because of:
- - throttled flow continues to be active from the viewpoint
- of CSZ, so that it would acquire the highest priority,
- if you not adjusted start numbers.
- - Eventually, finish number would become less than round
- number and flow were declared inactive.
- */
-
- toks = -toks;
-
- /* Remember, that we should start watchdog */
- if (toks < q->wd_expires)
- q->wd_expires = toks;
-
- toks >>= q->R_log;
- shift += toks;
- if (shift > 0) {
- this->R_tbf += toks;
- csz_move_queue(this, shift);
- }
- csz_insert_start(this);
- return 0;
-}
-#endif
-
-
-static struct sk_buff *
-csz_dequeue(struct Qdisc* sch)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- struct sk_buff *skb;
- struct csz_flow *this;
-
-#ifdef CSZ_PLUS_TBF
- q->wd_expires = 0;
-#endif
- this = (struct csz_flow*)q->s.snext;
-
- while (this != (struct csz_flow*)&q->s) {
-
- /* First of all: unlink from start list */
- this->sprev->snext = this->snext;
- this->snext->sprev = this->sprev;
-
- if (this != &q->flow[0]) { /* Guaranteed flow */
- skb = __skb_dequeue(&this->q);
- if (skb) {
-#ifdef CSZ_PLUS_TBF
- if (this->depth) {
- if (!csz_enough_tokens(q, this, skb))
- continue;
- }
-#endif
- if (this->q.qlen) {
- struct sk_buff *nskb = skb_peek(&this->q);
- this->start += L2R(this,nskb->len);
- csz_insert_start(&q->s, this);
- }
- sch->q.qlen--;
- return skb;
- }
- } else { /* Predicted or best effort flow */
- skb = skb_dequeue_best(q);
- if (skb) {
- unsigned peeked = this->peeked;
- this->peeked = 0;
-
- if (--this->q.qlen) {
- struct sk_buff *nskb;
- unsigned dequeued = L2R(this,skb->len);
-
- /* We got not the same thing that
- peeked earlier; adjust start number
- */
- if (peeked != dequeued && peeked)
- this->start += dequeued - peeked;
-
- nskb = skb_peek_best(q);
- peeked = L2R(this,nskb->len);
- this->start += peeked;
- this->peeked = peeked;
- csz_insert_start(&q->s, this);
- }
- sch->q.qlen--;
- return skb;
- }
- }
- }
-#ifdef CSZ_PLUS_TBF
- /* We are about to return no skb.
- Schedule watchdog timer, if it occurred because of shaping.
- */
- if (q->wd_expires) {
- unsigned long delay = PSCHED_US2JIFFIE(q->wd_expires);
- if (delay == 0)
- delay = 1;
- mod_timer(&q->wd_timer, jiffies + delay);
- sch->stats.overlimits++;
- }
-#endif
- return NULL;
-}
-
-static void
-csz_reset(struct Qdisc* sch)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- int i;
-
- for (i=0; i<4; i++)
- skb_queue_purge(&q->other[i]);
-
- for (i=0; i<CSZ_GUARANTEED; i++) {
- struct csz_flow *this = q->flow + i;
- skb_queue_purge(&this->q);
- this->snext = this->sprev =
- this->fnext = this->fprev = (struct csz_head*)this;
- this->start = this->finish = 0;
- }
- q->s.snext = q->s.sprev = &q->s;
- q->f.fnext = q->f.fprev = &q->f;
- q->R_c = 0;
-#ifdef CSZ_PLUS_TBF
- PSCHED_GET_TIME(&q->t_tbf);
- q->tokens = q->depth;
- del_timer(&q->wd_timer);
-#endif
- sch->q.qlen = 0;
-}
-
-static void
-csz_destroy(struct Qdisc* sch)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- struct tcf_proto *tp;
-
- while ((tp = q->filter_list) != NULL) {
- q->filter_list = tp->next;
- tcf_destroy(tp);
- }
-}
-
-static int csz_init(struct Qdisc *sch, struct rtattr *opt)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- struct rtattr *tb[TCA_CSZ_PTAB];
- struct tc_csz_qopt *qopt;
- int i;
-
- rtattr_parse(tb, TCA_CSZ_PTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
- if (tb[TCA_CSZ_PARMS-1] == NULL ||
- RTA_PAYLOAD(tb[TCA_CSZ_PARMS-1]) < sizeof(*qopt))
- return -EINVAL;
- qopt = RTA_DATA(tb[TCA_CSZ_PARMS-1]);
-
- q->R_log = qopt->R_log;
- q->delta_log = qopt->delta_log;
- for (i=0; i<=TC_PRIO_MAX; i++) {
- if (qopt->priomap[i] >= CSZ_FLOWS)
- return -EINVAL;
- q->prio2band[i] = qopt->priomap[i];
- }
-
- for (i=0; i<4; i++)
- skb_queue_head_init(&q->other[i]);
-
- for (i=0; i<CSZ_GUARANTEED; i++) {
- struct csz_flow *this = q->flow + i;
- skb_queue_head_init(&this->q);
- this->snext = this->sprev =
- this->fnext = this->fprev = (struct csz_head*)this;
- this->start = this->finish = 0;
- }
- q->s.snext = q->s.sprev = &q->s;
- q->f.fnext = q->f.fprev = &q->f;
- q->R_c = 0;
-#ifdef CSZ_PLUS_TBF
- init_timer(&q->wd_timer);
- q->wd_timer.data = (unsigned long)sch;
- q->wd_timer.function = csz_watchdog;
-#endif
- return 0;
-}
-
-static int csz_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- unsigned char *b = skb->tail;
- struct rtattr *rta;
- struct tc_csz_qopt opt;
-
- rta = (struct rtattr*)b;
- RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
-
- opt.flows = CSZ_FLOWS;
- memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1);
- RTA_PUT(skb, TCA_CSZ_PARMS, sizeof(opt), &opt);
- rta->rta_len = skb->tail - b;
-
- return skb->len;
-
-rtattr_failure:
- skb_trim(skb, b - skb->data);
- return -1;
-}
-
-static int csz_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
- struct Qdisc **old)
-{
- return -EINVAL;
-}
-
-static struct Qdisc * csz_leaf(struct Qdisc *sch, unsigned long cl)
-{
- return NULL;
-}
-
-
-static unsigned long csz_get(struct Qdisc *sch, u32 classid)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- unsigned long band = TC_H_MIN(classid) - 1;
-
- if (band >= CSZ_FLOWS)
- return 0;
-
- if (band < CSZ_GUARANTEED && q->flow[band].L_tab == NULL)
- return 0;
-
- return band+1;
-}
-
-static unsigned long csz_bind(struct Qdisc *sch, unsigned long parent, u32 classid)
-{
- return csz_get(sch, classid);
-}
-
-
-static void csz_put(struct Qdisc *sch, unsigned long cl)
-{
- return;
-}
-
-static int csz_change(struct Qdisc *sch, u32 handle, u32 parent, struct rtattr **tca, unsigned long *arg)
-{
- unsigned long cl = *arg;
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- struct rtattr *opt = tca[TCA_OPTIONS-1];
- struct rtattr *tb[TCA_CSZ_PTAB];
- struct tc_csz_copt *copt;
-
- rtattr_parse(tb, TCA_CSZ_PTAB, RTA_DATA(opt), RTA_PAYLOAD(opt));
- if (tb[TCA_CSZ_PARMS-1] == NULL ||
- RTA_PAYLOAD(tb[TCA_CSZ_PARMS-1]) < sizeof(*copt))
- return -EINVAL;
- copt = RTA_DATA(tb[TCA_CSZ_PARMS-1]);
-
- if (tb[TCA_CSZ_RTAB-1] &&
- RTA_PAYLOAD(tb[TCA_CSZ_RTAB-1]) < 1024)
- return -EINVAL;
-
- if (cl) {
- struct csz_flow *a;
- cl--;
- if (cl >= CSZ_FLOWS)
- return -ENOENT;
- if (cl >= CSZ_GUARANTEED || q->flow[cl].L_tab == NULL)
- return -EINVAL;
-
- a = &q->flow[cl];
-
- spin_lock_bh(&sch->dev->queue_lock);
-#if 0
- a->rate_log = copt->rate_log;
-#endif
-#ifdef CSZ_PLUS_TBF
- a->limit = copt->limit;
- a->rate = copt->rate;
- a->buffer = copt->buffer;
- a->mtu = copt->mtu;
-#endif
-
- if (tb[TCA_CSZ_RTAB-1])
- memcpy(a->L_tab, RTA_DATA(tb[TCA_CSZ_RTAB-1]), 1024);
-
- spin_unlock_bh(&sch->dev->queue_lock);
- return 0;
- }
- /* NI */
- return 0;
-}
-
-static int csz_delete(struct Qdisc *sch, unsigned long cl)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- struct csz_flow *a;
-
- cl--;
-
- if (cl >= CSZ_FLOWS)
- return -ENOENT;
- if (cl >= CSZ_GUARANTEED || q->flow[cl].L_tab == NULL)
- return -EINVAL;
-
- a = &q->flow[cl];
-
- spin_lock_bh(&sch->dev->queue_lock);
- a->fprev->fnext = a->fnext;
- a->fnext->fprev = a->fprev;
- a->sprev->snext = a->snext;
- a->snext->sprev = a->sprev;
- a->start = a->finish = 0;
- kfree(xchg(&q->flow[cl].L_tab, NULL));
- spin_unlock_bh(&sch->dev->queue_lock);
-
- return 0;
-}
-
-static int csz_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- unsigned char *b = skb->tail;
- struct rtattr *rta;
- struct tc_csz_copt opt;
-
- tcm->tcm_handle = sch->handle|cl;
-
- cl--;
-
- if (cl > CSZ_FLOWS)
- goto rtattr_failure;
-
- if (cl < CSZ_GUARANTEED) {
- struct csz_flow *f = &q->flow[cl];
-
- if (f->L_tab == NULL)
- goto rtattr_failure;
-
- rta = (struct rtattr*)b;
- RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
-
- opt.limit = f->limit;
- opt.rate = f->rate;
- opt.slice = f->slice;
- memset(&opt.peakrate, 0, sizeof(opt.peakrate));
-#ifdef CSZ_PLUS_TBF
- opt.buffer = f->buffer;
- opt.mtu = f->mtu;
-#else
- opt.buffer = 0;
- opt.mtu = 0;
-#endif
-
- RTA_PUT(skb, TCA_CSZ_PARMS, sizeof(opt), &opt);
- rta->rta_len = skb->tail - b;
- }
-
- return skb->len;
-
-rtattr_failure:
- skb_trim(skb, b - skb->data);
- return -1;
-}
-
-static void csz_walk(struct Qdisc *sch, struct qdisc_walker *arg)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
- int prio = 0;
-
- if (arg->stop)
- return;
-
- for (prio = 0; prio < CSZ_FLOWS; prio++) {
- if (arg->count < arg->skip) {
- arg->count++;
- continue;
- }
- if (prio < CSZ_GUARANTEED && q->flow[prio].L_tab == NULL) {
- arg->count++;
- continue;
- }
- if (arg->fn(sch, prio+1, arg) < 0) {
- arg->stop = 1;
- break;
- }
- arg->count++;
- }
-}
-
-static struct tcf_proto ** csz_find_tcf(struct Qdisc *sch, unsigned long cl)
-{
- struct csz_sched_data *q = (struct csz_sched_data *)sch->data;
-
- if (cl)
- return NULL;
-
- return &q->filter_list;
-}
-
-struct Qdisc_class_ops csz_class_ops = {
- .graft = csz_graft,
- .leaf = csz_leaf,
- .get = csz_get,
- .put = csz_put,
- .change = csz_change,
- .delete = csz_delete,
- .walk = csz_walk,
- .tcf_chain = csz_find_tcf,
- .bind_tcf = csz_bind,
- .unbind_tcf = csz_put,
- .dump = csz_dump_class,
-};
-
-static struct Qdisc_ops csz_qdisc_ops = {
- .next = NULL,
- .cl_ops = &csz_class_ops,
- .id = "csz",
- .priv_size = sizeof(struct csz_sched_data),
- .enqueue = csz_enqueue,
- .dequeue = csz_dequeue,
- .requeue = NULL,
- .drop = NULL,
- .init = csz_init,
- .reset = csz_reset,
- .destroy = csz_destroy,
- .change = NULL,
- .dump = csz_dump,
- .owner = THIS_MODULE,
-};
-
-static int __init csz_module_init(void)
-{
- return register_qdisc(&csz_qdisc_ops);
-}
-static void __exit csz_module_exit(void)
-{
- unregister_qdisc(&csz_qdisc_ops);
-}
-module_init(csz_module_init)
-module_exit(csz_module_exit)
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * net/sched/sch_delay.c Simple constant delay
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Authors: Stephen Hemminger <shemminger@osdl.org>
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/socket.h>
-#include <linux/sockios.h>
-#include <linux/in.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/if_ether.h>
-#include <linux/inet.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/notifier.h>
-#include <net/ip.h>
-#include <net/route.h>
-#include <linux/skbuff.h>
-#include <net/sock.h>
-#include <net/pkt_sched.h>
-
-/* Network delay simulator
- This scheduler adds a fixed delay to all packets.
- Similar to NISTnet and BSD Dummynet.
-
- It uses byte fifo underneath similar to TBF */
-struct dly_sched_data {
- u32 latency;
- u32 limit;
- struct timer_list timer;
- struct Qdisc *qdisc;
-};
-
-/* Time stamp put into socket buffer control block */
-struct dly_skb_cb {
- psched_time_t queuetime;
-};
-
-/* Enqueue packets with underlying discipline (fifo)
- * but mark them with current time first.
- */
-static int dly_enqueue(struct sk_buff *skb, struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb;
- int ret;
-
- PSCHED_GET_TIME(cb->queuetime);
-
- /* Queue to underlying scheduler */
- ret = q->qdisc->enqueue(skb, q->qdisc);
- if (ret)
- sch->stats.drops++;
- else {
- sch->q.qlen++;
- sch->stats.bytes += skb->len;
- sch->stats.packets++;
- }
- return 0;
-}
-
-/* Requeue packets but don't change time stamp */
-static int dly_requeue(struct sk_buff *skb, struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- int ret;
-
- ret = q->qdisc->ops->requeue(skb, q->qdisc);
- if (ret == 0)
- sch->q.qlen++;
- return ret;
-}
-
-static unsigned int dly_drop(struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- unsigned int len;
-
- len = q->qdisc->ops->drop(q->qdisc);
- if (len) {
- sch->q.qlen--;
- sch->stats.drops++;
- }
- return len;
-}
-
-/* Dequeue packet.
- * If packet needs to be held up, then stop the
- * queue and set timer to wakeup later.
- */
-static struct sk_buff *dly_dequeue(struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- struct sk_buff *skb = q->qdisc->dequeue(q->qdisc);
-
- if (skb) {
- struct dly_skb_cb *cb = (struct dly_skb_cb *)skb->cb;
- psched_time_t now;
- long diff;
-
- PSCHED_GET_TIME(now);
- diff = q->latency - PSCHED_TDIFF(now, cb->queuetime);
-
- if (diff <= 0) {
- sch->q.qlen--;
- sch->flags &= ~TCQ_F_THROTTLED;
- return skb;
- }
-
- if (!netif_queue_stopped(sch->dev)) {
- long delay = PSCHED_US2JIFFIE(diff);
- if (delay <= 0)
- delay = 1;
- mod_timer(&q->timer, jiffies+delay);
- }
-
- if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
- sch->q.qlen--;
- sch->stats.drops++;
- }
- sch->flags |= TCQ_F_THROTTLED;
- }
- return NULL;
-}
-
-static void dly_reset(struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
- qdisc_reset(q->qdisc);
- sch->q.qlen = 0;
- sch->flags &= ~TCQ_F_THROTTLED;
- del_timer(&q->timer);
-}
-
-static void dly_timer(unsigned long arg)
-{
- struct Qdisc *sch = (struct Qdisc *)arg;
-
- sch->flags &= ~TCQ_F_THROTTLED;
- netif_schedule(sch->dev);
-}
-
-/* Tell Fifo the new limit. */
-static int change_limit(struct Qdisc *q, u32 limit)
-{
- struct rtattr *rta;
- int ret;
-
- rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
- if (!rta)
- return -ENOMEM;
-
- rta->rta_type = RTM_NEWQDISC;
- rta->rta_len = RTA_LENGTH(sizeof(struct tc_fifo_qopt));
- ((struct tc_fifo_qopt *)RTA_DATA(rta))->limit = limit;
- ret = q->ops->change(q, rta);
- kfree(rta);
-
- return ret;
-}
-
-/* Setup underlying FIFO discipline */
-static int dly_change(struct Qdisc *sch, struct rtattr *opt)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- struct tc_dly_qopt *qopt = RTA_DATA(opt);
- int err;
-
- if (q->qdisc == &noop_qdisc) {
- struct Qdisc *child
- = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops);
- if (!child)
- return -EINVAL;
- q->qdisc = child;
- }
-
- err = change_limit(q->qdisc, qopt->limit);
- if (err) {
- qdisc_destroy(q->qdisc);
- q->qdisc = &noop_qdisc;
- } else {
- q->latency = qopt->latency;
- q->limit = qopt->limit;
- }
- return err;
-}
-
-static int dly_init(struct Qdisc *sch, struct rtattr *opt)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
- if (!opt)
- return -EINVAL;
-
- init_timer(&q->timer);
- q->timer.function = dly_timer;
- q->timer.data = (unsigned long) sch;
- q->qdisc = &noop_qdisc;
-
- return dly_change(sch, opt);
-}
-
-static void dly_destroy(struct Qdisc *sch)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
-
- del_timer(&q->timer);
- qdisc_destroy(q->qdisc);
- q->qdisc = &noop_qdisc;
-}
-
-static int dly_dump(struct Qdisc *sch, struct sk_buff *skb)
-{
- struct dly_sched_data *q = (struct dly_sched_data *)sch->data;
- unsigned char *b = skb->tail;
- struct tc_dly_qopt qopt;
-
- qopt.latency = q->latency;
- qopt.limit = q->limit;
-
- RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
-
- return skb->len;
-
-rtattr_failure:
- skb_trim(skb, b - skb->data);
- return -1;
-}
-
-static struct Qdisc_ops dly_qdisc_ops = {
- .id = "delay",
- .priv_size = sizeof(struct dly_sched_data),
- .enqueue = dly_enqueue,
- .dequeue = dly_dequeue,
- .requeue = dly_requeue,
- .drop = dly_drop,
- .init = dly_init,
- .reset = dly_reset,
- .destroy = dly_destroy,
- .change = dly_change,
- .dump = dly_dump,
- .owner = THIS_MODULE,
-};
-
-
-static int __init dly_module_init(void)
-{
- return register_qdisc(&dly_qdisc_ops);
-}
-static void __exit dly_module_exit(void)
-{
- unregister_qdisc(&dly_qdisc_ops);
-}
-module_init(dly_module_init)
-module_exit(dly_module_exit)
-MODULE_LICENSE("GPL");
+++ /dev/null
-/*
- * generic xfrm output routines
- *
- * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- */
-#include <linux/config.h>
-#include <linux/kernel.h>
-#include <linux/skbuff.h>
-#include <net/xfrm.h>
-
-int xfrm_check_output(struct xfrm_state *x,
- struct sk_buff *skb, unsigned short family)
-{
- int err;
-
- err = xfrm_state_check_expire(x);
- if (err)
- goto out;
-
- if (x->props.mode) {
- switch (family) {
- case AF_INET:
- err = xfrm4_tunnel_check_size(skb);
- break;
-
- case AF_INET6:
- err = xfrm6_tunnel_check_size(skb);
- break;
-
- default:
- err = -EINVAL;
- }
-
- if (err)
- goto out;
- }
-
- err = xfrm_state_check_space(x, skb);
-out:
- return err;
-}
+++ /dev/null
-/* empty file to figure out endianness / word size */
+++ /dev/null
-/* Simple code to turn various tables in an ELF file into alias definitions.
- * This deals with kernel datastructures where they should be
- * dealt with: in the kernel source.
- *
- * Copyright 2002-2003 Rusty Russell, IBM Corporation
- * 2003 Kai Germaschewski
- *
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- */
-
-#include "modpost.h"
-
-/* We use the ELF typedefs, since we can't rely on stdint.h being present. */
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-typedef Elf32_Addr kernel_ulong_t;
-#else
-typedef Elf64_Addr kernel_ulong_t;
-#endif
-
-typedef Elf32_Word __u32;
-typedef Elf32_Half __u16;
-typedef unsigned char __u8;
-
-/* Big exception to the "don't include kernel headers into userspace, which
- * even potentially has different endianness and word sizes, since
- * we handle those differences explicitly below */
-#include "../include/linux/mod_devicetable.h"
-
-#define ADD(str, sep, cond, field) \
-do { \
- strcat(str, sep); \
- if (cond) \
- sprintf(str + strlen(str), \
- sizeof(field) == 1 ? "%02X" : \
- sizeof(field) == 2 ? "%04X" : \
- sizeof(field) == 4 ? "%08X" : "", \
- field); \
- else \
- sprintf(str + strlen(str), "*"); \
-} while(0)
-
-/* Looks like "usb:vNpNdlNdhNdcNdscNdpNicNiscNipN" */
-static int do_usb_entry(const char *filename,
- struct usb_device_id *id, char *alias)
-{
- id->match_flags = TO_NATIVE(id->match_flags);
- id->idVendor = TO_NATIVE(id->idVendor);
- id->idProduct = TO_NATIVE(id->idProduct);
- id->bcdDevice_lo = TO_NATIVE(id->bcdDevice_lo);
- id->bcdDevice_hi = TO_NATIVE(id->bcdDevice_hi);
-
- /*
- * Some modules (visor) have empty slots as placeholder for
- * run-time specification that results in catch-all alias
- */
- if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
- return 1;
-
- strcpy(alias, "usb:");
- ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
- id->idVendor);
- ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
- id->idProduct);
- ADD(alias, "dl", id->match_flags&USB_DEVICE_ID_MATCH_DEV_LO,
- id->bcdDevice_lo);
- ADD(alias, "dh", id->match_flags&USB_DEVICE_ID_MATCH_DEV_HI,
- id->bcdDevice_hi);
- ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
- id->bDeviceClass);
- ADD(alias, "dsc",
- id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
- id->bDeviceSubClass);
- ADD(alias, "dp",
- id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
- id->bDeviceProtocol);
- ADD(alias, "ic",
- id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
- id->bInterfaceClass);
- ADD(alias, "isc",
- id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
- id->bInterfaceSubClass);
- ADD(alias, "ip",
- id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
- id->bInterfaceProtocol);
- return 1;
-}
-
-/* Looks like: ieee1394:venNmoNspNverN */
-static int do_ieee1394_entry(const char *filename,
- struct ieee1394_device_id *id, char *alias)
-{
- id->match_flags = TO_NATIVE(id->match_flags);
- id->vendor_id = TO_NATIVE(id->vendor_id);
- id->model_id = TO_NATIVE(id->model_id);
- id->specifier_id = TO_NATIVE(id->specifier_id);
- id->version = TO_NATIVE(id->version);
-
- strcpy(alias, "ieee1394:");
- ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
- id->vendor_id);
- ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
- id->model_id);
- ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
- id->specifier_id);
- ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
- id->version);
-
- return 1;
-}
-
-/* Looks like: pci:vNdNsvNsdNbcNscNiN. */
-static int do_pci_entry(const char *filename,
- struct pci_device_id *id, char *alias)
-{
- /* Class field can be divided into these three. */
- unsigned char baseclass, subclass, interface,
- baseclass_mask, subclass_mask, interface_mask;
-
- id->vendor = TO_NATIVE(id->vendor);
- id->device = TO_NATIVE(id->device);
- id->subvendor = TO_NATIVE(id->subvendor);
- id->subdevice = TO_NATIVE(id->subdevice);
- id->class = TO_NATIVE(id->class);
- id->class_mask = TO_NATIVE(id->class_mask);
-
- strcpy(alias, "pci:");
- ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
- ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
- ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
- ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
-
- baseclass = (id->class) >> 16;
- baseclass_mask = (id->class_mask) >> 16;
- subclass = (id->class) >> 8;
- subclass_mask = (id->class_mask) >> 8;
- interface = id->class;
- interface_mask = id->class_mask;
-
- if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
- || (subclass_mask != 0 && subclass_mask != 0xFF)
- || (interface_mask != 0 && interface_mask != 0xFF)) {
- fprintf(stderr,
- "*** Warning: Can't handle masks in %s:%04X\n",
- filename, id->class_mask);
- return 0;
- }
-
- ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
- ADD(alias, "sc", subclass_mask == 0xFF, subclass);
- ADD(alias, "i", interface_mask == 0xFF, interface);
- return 1;
-}
-
-/* looks like: "ccw:tNmNdtNdmN" */
-static int do_ccw_entry(const char *filename,
- struct ccw_device_id *id, char *alias)
-{
- id->match_flags = TO_NATIVE(id->match_flags);
- id->cu_type = TO_NATIVE(id->cu_type);
- id->cu_model = TO_NATIVE(id->cu_model);
- id->dev_type = TO_NATIVE(id->dev_type);
- id->dev_model = TO_NATIVE(id->dev_model);
-
- strcpy(alias, "ccw:");
- ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
- id->cu_type);
- ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
- id->cu_model);
- ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
- id->dev_type);
- ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
- id->dev_model);
- return 1;
-}
-
-/* looks like: "pnp:dD" */
-static int do_pnp_entry(const char *filename,
- struct pnp_device_id *id, char *alias)
-{
- sprintf(alias, "pnp:d%s", id->id);
- return 1;
-}
-
-/* looks like: "pnp:cCdD..." */
-static int do_pnp_card_entry(const char *filename,
- struct pnp_card_device_id *id, char *alias)
-{
- int i;
-
- sprintf(alias, "pnp:c%s", id->id);
- for (i = 0; i < PNP_MAX_DEVICES; i++) {
- if (! *id->devs[i].id)
- break;
- sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
- }
- return 1;
-}
-
-/* Ignore any prefix, eg. v850 prepends _ */
-static inline int sym_is(const char *symbol, const char *name)
-{
- const char *match;
-
- match = strstr(symbol, name);
- if (!match)
- return 0;
- return match[strlen(symbol)] == '\0';
-}
-
-static void do_table(void *symval, unsigned long size,
- unsigned long id_size,
- void *function,
- struct module *mod)
-{
- unsigned int i;
- char alias[500];
- int (*do_entry)(const char *, void *entry, char *alias) = function;
-
- if (size % id_size || size < id_size) {
- fprintf(stderr, "*** Warning: %s ids %lu bad size "
- "(each on %lu)\n", mod->name, size, id_size);
- }
- /* Leave last one: it's the terminator. */
- size -= id_size;
-
- for (i = 0; i < size; i += id_size) {
- if (do_entry(mod->name, symval+i, alias)) {
- /* Always end in a wildcard, for future extension */
- if (alias[strlen(alias)-1] != '*')
- strcat(alias, "*");
- buf_printf(&mod->dev_table_buf,
- "MODULE_ALIAS(\"%s\");\n", alias);
- }
- }
-}
-
-/* Create MODULE_ALIAS() statements.
- * At this time, we cannot write the actual output C source yet,
- * so we write into the mod->dev_table_buf buffer. */
-void handle_moddevtable(struct module *mod, struct elf_info *info,
- Elf_Sym *sym, const char *symname)
-{
- void *symval;
-
- /* We're looking for a section relative symbol */
- if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
- return;
-
- symval = (void *)info->hdr
- + info->sechdrs[sym->st_shndx].sh_offset
- + sym->st_value;
-
- if (sym_is(symname, "__mod_pci_device_table"))
- do_table(symval, sym->st_size, sizeof(struct pci_device_id),
- do_pci_entry, mod);
- else if (sym_is(symname, "__mod_usb_device_table"))
- do_table(symval, sym->st_size, sizeof(struct usb_device_id),
- do_usb_entry, mod);
- else if (sym_is(symname, "__mod_ieee1394_device_table"))
- do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
- do_ieee1394_entry, mod);
- else if (sym_is(symname, "__mod_ccw_device_table"))
- do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
- do_ccw_entry, mod);
- else if (sym_is(symname, "__mod_pnp_device_table"))
- do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
- do_pnp_entry, mod);
- else if (sym_is(symname, "__mod_pnp_card_device_table"))
- do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
- do_pnp_card_entry, mod);
-}
-
-/* Now add out buffered information to the generated C source */
-void add_moddevtable(struct buffer *buf, struct module *mod)
-{
- buf_printf(buf, "\n");
- buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
- free(mod->dev_table_buf.p);
-}
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <elf.h>
-
-int
-main(int argc, char **argv)
-{
- unsigned char ei[EI_NIDENT];
- union { short s; char c[2]; } endian_test;
-
- if (argc != 2) {
- fprintf(stderr, "Error: no arch\n");
- }
- if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
- fprintf(stderr, "Error: input truncated\n");
- return 1;
- }
- if (memcmp(ei, ELFMAG, SELFMAG) != 0) {
- fprintf(stderr, "Error: not ELF\n");
- return 1;
- }
- switch (ei[EI_CLASS]) {
- case ELFCLASS32:
- printf("#define KERNEL_ELFCLASS ELFCLASS32\n");
- break;
- case ELFCLASS64:
- printf("#define KERNEL_ELFCLASS ELFCLASS64\n");
- break;
- default:
- abort();
- }
- switch (ei[EI_DATA]) {
- case ELFDATA2LSB:
- printf("#define KERNEL_ELFDATA ELFDATA2LSB\n");
- break;
- case ELFDATA2MSB:
- printf("#define KERNEL_ELFDATA ELFDATA2MSB\n");
- break;
- default:
- abort();
- }
-
- if (sizeof(unsigned long) == 4) {
- printf("#define HOST_ELFCLASS ELFCLASS32\n");
- } else if (sizeof(unsigned long) == 8) {
- printf("#define HOST_ELFCLASS ELFCLASS64\n");
- }
-
- endian_test.s = 0x0102;
- if (memcmp(endian_test.c, "\x01\x02", 2) == 0)
- printf("#define HOST_ELFDATA ELFDATA2MSB\n");
- else if (memcmp(endian_test.c, "\x02\x01", 2) == 0)
- printf("#define HOST_ELFDATA ELFDATA2LSB\n");
- else
- abort();
-
- if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
- printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
- else
- printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
-
- return 0;
-}
-
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2002 Khalid Aziz <khalid_aziz@hp.com>
-# Copyright (C) 2002 Randy Dunlap <rddunlap@osdl.org>
-# Copyright (C) 2002 Al Stone <ahs3@fc.hp.com>
-# Copyright (C) 2002 Hewlett-Packard Company
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-#
-# Rules to generate ikconfig.h from linux/.config:
-# - Retain lines that begin with "CONFIG_"
-# - Retain lines that begin with "# CONFIG_"
-# - lines that use double-quotes must \\-escape-quote them
-
-if [ $# -lt 2 ]
-then
- echo "Usage: `basename $0` <configuration_file> <Makefile>"
- exit 1
-fi
-
-config=$1
-makefile=$2
-
-echo "#ifndef _IKCONFIG_H"
-echo "#define _IKCONFIG_H"
-echo \
-"/*
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- *
- * This file is generated automatically by scripts/mkconfigs. Do not edit.
- *
- */"
-
-echo "static char const ikconfig_config[] __attribute__((unused)) = "
-echo "\"CONFIG_BEGIN=n\\n\\"
-echo "`cat $config | sed 's/\"/\\\\\"/g' | grep "^#\? \?CONFIG_" | awk '{ print $0 "\\\\n\\\\" }' `"
-echo "CONFIG_END=n\\n\";"
-echo "#endif /* _IKCONFIG_H */"
+++ /dev/null
-#!/bin/sh
-#
-# Output a simple RPM spec file that uses no fancy features requring
-# RPM v4. This is intended to work with any RPM distro.
-#
-# The only gothic bit here is redefining install_post to avoid
-# stripping the symbols from files in the kernel which we want
-#
-# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
-#
-# That's the voodoo to see if it's a x86.
-ISX86=`echo ${ARCH:=\`arch\`} | grep -ie i.86`
-if [ ! -z $ISX86 ]; then
- PC=1
-else
- PC=0
-fi
-# starting to output the spec
-if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
- PROVIDES=kernel-drm
-fi
-
-PROVIDES="$PROVIDES kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-
-echo "Name: kernel"
-echo "Summary: The Linux Kernel"
-echo "Version: "$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION | sed -e "s/-//g"
-# we need to determine the NEXT version number so that uname and
-# rpm -q will agree
-echo "Release: `. $srctree/scripts/mkversion`"
-echo "License: GPL"
-echo "Group: System Environment/Kernel"
-echo "Vendor: The Linux Community"
-echo "URL: http://www.kernel.org"
-echo -n "Source: kernel-$VERSION.$PATCHLEVEL.$SUBLEVEL"
-echo "$EXTRAVERSION.tar.gz" | sed -e "s/-//g"
-echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root"
-echo "Provides: $PROVIDES"
-echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
-echo "%define debug_package %{nil}"
-echo ""
-echo "%description"
-echo "The Linux Kernel, the operating system core itself"
-echo ""
-echo "%prep"
-echo "%setup -q"
-echo ""
-echo "%build"
-echo "make clean all"
-echo ""
-echo "%install"
-echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib $RPM_BUILD_ROOT/lib/modules'
-echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make modules_install'
-# This is the first disagreement between i386 and most others
-if [ $PC = 1 ]; then
- echo 'cp arch/i386/boot/bzImage $RPM_BUILD_ROOT'"/boot/vmlinuz-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-else
- echo 'cp vmlinux $RPM_BUILD_ROOT'"/boot/vmlinux-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-fi
-# Back on track
-echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo ""
-echo "%clean"
-echo '#echo -rf $RPM_BUILD_ROOT'
-echo ""
-echo "%files"
-echo '%defattr (-, root, root)'
-echo "%dir /lib/modules"
-echo "/lib/modules/$VERSION.$PATCHLEVEL.$SUBLEVEL$EXTRAVERSION"
-echo "/boot/*"
-echo ""
+++ /dev/null
-/* Postprocess module symbol versions
- *
- * Copyright 2003 Kai Germaschewski
- * 2002-2003 Rusty Russell, IBM Corporation
- *
- * Based in part on module-init-tools/depmod.c,file2alias
- *
- * This software may be used and distributed according to the terms
- * of the GNU General Public License, incorporated herein by reference.
- *
- * Usage: modpost vmlinux module1.o module2.o ...
- */
-
-#include <ctype.h>
-#include "modpost.h"
-
-/* Are we using CONFIG_MODVERSIONS? */
-int modversions = 0;
-/* Warn about undefined symbols? (do so if we have vmlinux) */
-int have_vmlinux = 0;
-
-void
-fatal(const char *fmt, ...)
-{
- va_list arglist;
-
- fprintf(stderr, "FATAL: ");
-
- va_start(arglist, fmt);
- vfprintf(stderr, fmt, arglist);
- va_end(arglist);
-
- exit(1);
-}
-
-void
-warn(const char *fmt, ...)
-{
- va_list arglist;
-
- fprintf(stderr, "WARNING: ");
-
- va_start(arglist, fmt);
- vfprintf(stderr, fmt, arglist);
- va_end(arglist);
-}
-
-void *do_nofail(void *ptr, const char *file, int line, const char *expr)
-{
- if (!ptr) {
- fatal("Memory allocation failure %s line %d: %s.\n",
- file, line, expr);
- }
- return ptr;
-}
-
-/* A list of all modules we processed */
-
-static struct module *modules;
-
-struct module *
-find_module(char *modname)
-{
- struct module *mod;
-
- for (mod = modules; mod; mod = mod->next)
- if (strcmp(mod->name, modname) == 0)
- break;
- return mod;
-}
-
-struct module *
-new_module(char *modname)
-{
- struct module *mod;
- char *p, *s;
-
- mod = NOFAIL(malloc(sizeof(*mod)));
- memset(mod, 0, sizeof(*mod));
- p = NOFAIL(strdup(modname));
-
- /* strip trailing .o */
- if ((s = strrchr(p, '.')) != NULL)
- if (strcmp(s, ".o") == 0)
- *s = '\0';
-
- /* add to list */
- mod->name = p;
- mod->next = modules;
- modules = mod;
-
- return mod;
-}
-
-/* A hash of all exported symbols,
- * struct symbol is also used for lists of unresolved symbols */
-
-#define SYMBOL_HASH_SIZE 1024
-
-struct symbol {
- struct symbol *next;
- struct module *module;
- unsigned int crc;
- int crc_valid;
- char name[0];
-};
-
-static struct symbol *symbolhash[SYMBOL_HASH_SIZE];
-
-/* This is based on the hash agorithm from gdbm, via tdb */
-static inline unsigned int tdb_hash(const char *name)
-{
- unsigned value; /* Used to compute the hash value. */
- unsigned i; /* Used to cycle through random values. */
-
- /* Set the initial value from the key size. */
- for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
- value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
-
- return (1103515243 * value + 12345);
-}
-
-/* Allocate a new symbols for use in the hash of exported symbols or
- * the list of unresolved symbols per module */
-
-struct symbol *
-alloc_symbol(const char *name, struct symbol *next)
-{
- struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
-
- memset(s, 0, sizeof(*s));
- strcpy(s->name, name);
- s->next = next;
- return s;
-}
-
-/* For the hash of exported symbols */
-
-void
-new_symbol(const char *name, struct module *module, unsigned int *crc)
-{
- unsigned int hash;
- struct symbol *new;
-
- hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
- new = symbolhash[hash] = alloc_symbol(name, symbolhash[hash]);
- new->module = module;
- if (crc) {
- new->crc = *crc;
- new->crc_valid = 1;
- }
-}
-
-struct symbol *
-find_symbol(const char *name)
-{
- struct symbol *s;
-
- /* For our purposes, .foo matches foo. PPC64 needs this. */
- if (name[0] == '.')
- name++;
-
- for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
- if (strcmp(s->name, name) == 0)
- return s;
- }
- return NULL;
-}
-
-/* Add an exported symbol - it may have already been added without a
- * CRC, in this case just update the CRC */
-void
-add_exported_symbol(const char *name, struct module *module, unsigned int *crc)
-{
- struct symbol *s = find_symbol(name);
-
- if (!s) {
- new_symbol(name, module, crc);
- return;
- }
- if (crc) {
- s->crc = *crc;
- s->crc_valid = 1;
- }
-}
-
-void *
-grab_file(const char *filename, unsigned long *size)
-{
- struct stat st;
- void *map;
- int fd;
-
- fd = open(filename, O_RDONLY);
- if (fd < 0 || fstat(fd, &st) != 0)
- return NULL;
-
- *size = st.st_size;
- map = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
- close(fd);
-
- if (map == MAP_FAILED)
- return NULL;
- return map;
-}
-
-/*
- Return a copy of the next line in a mmap'ed file.
- spaces in the beginning of the line is trimmed away.
- Return a pointer to a static buffer.
-*/
-char*
-get_next_line(unsigned long *pos, void *file, unsigned long size)
-{
- static char line[4096];
- int skip = 1;
- size_t len = 0;
- char *p = (char *)file + *pos;
- char *s = line;
-
- for (; *pos < size ; (*pos)++)
- {
- if (skip && isspace(*p)) {
- p++;
- continue;
- }
- skip = 0;
- if (*p != '\n' && (*pos < size)) {
- len++;
- *s++ = *p++;
- if (len > 4095)
- break; /* Too long, stop */
- } else {
- /* End of string */
- *s = '\0';
- return line;
- }
- }
- /* End of buffer */
- return NULL;
-}
-
-void
-release_file(void *file, unsigned long size)
-{
- munmap(file, size);
-}
-
-void
-parse_elf(struct elf_info *info, const char *filename)
-{
- unsigned int i;
- Elf_Ehdr *hdr = info->hdr;
- Elf_Shdr *sechdrs;
- Elf_Sym *sym;
-
- hdr = grab_file(filename, &info->size);
- if (!hdr) {
- perror(filename);
- abort();
- }
- info->hdr = hdr;
- if (info->size < sizeof(*hdr))
- goto truncated;
-
- /* Fix endianness in ELF header */
- hdr->e_shoff = TO_NATIVE(hdr->e_shoff);
- hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
- hdr->e_shnum = TO_NATIVE(hdr->e_shnum);
- hdr->e_machine = TO_NATIVE(hdr->e_machine);
- sechdrs = (void *)hdr + hdr->e_shoff;
- info->sechdrs = sechdrs;
-
- /* Fix endianness in section headers */
- for (i = 0; i < hdr->e_shnum; i++) {
- sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type);
- sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset);
- sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size);
- sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link);
- sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
- }
- /* Find symbol table. */
- for (i = 1; i < hdr->e_shnum; i++) {
- const char *secstrings
- = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-
- if (sechdrs[i].sh_offset > info->size)
- goto truncated;
- if (strcmp(secstrings+sechdrs[i].sh_name, ".modinfo") == 0) {
- info->modinfo = (void *)hdr + sechdrs[i].sh_offset;
- info->modinfo_len = sechdrs[i].sh_size;
- }
- if (sechdrs[i].sh_type != SHT_SYMTAB)
- continue;
-
- info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
- info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset
- + sechdrs[i].sh_size;
- info->strtab = (void *)hdr +
- sechdrs[sechdrs[i].sh_link].sh_offset;
- }
- if (!info->symtab_start) {
- fprintf(stderr, "modpost: %s no symtab?\n", filename);
- abort();
- }
- /* Fix endianness in symbols */
- for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
- sym->st_shndx = TO_NATIVE(sym->st_shndx);
- sym->st_name = TO_NATIVE(sym->st_name);
- sym->st_value = TO_NATIVE(sym->st_value);
- sym->st_size = TO_NATIVE(sym->st_size);
- }
- return;
-
- truncated:
- fprintf(stderr, "modpost: %s is truncated.\n", filename);
- abort();
-}
-
-void
-parse_elf_finish(struct elf_info *info)
-{
- release_file(info->hdr, info->size);
-}
-
-#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
-#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
-
-void
-handle_modversions(struct module *mod, struct elf_info *info,
- Elf_Sym *sym, const char *symname)
-{
- unsigned int crc;
-
- switch (sym->st_shndx) {
- case SHN_COMMON:
- fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n",
- symname, mod->name);
- break;
- case SHN_ABS:
- /* CRC'd symbol */
- if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
- crc = (unsigned int) sym->st_value;
- add_exported_symbol(symname + strlen(CRC_PFX),
- mod, &crc);
- modversions = 1;
- }
- break;
- case SHN_UNDEF:
- /* undefined symbol */
- if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
- break;
- /* ignore global offset table */
- if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
- break;
- /* ignore __this_module, it will be resolved shortly */
- if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
- break;
-#ifdef STT_REGISTER
- if (info->hdr->e_machine == EM_SPARC ||
- info->hdr->e_machine == EM_SPARCV9) {
- /* Ignore register directives. */
- if (ELF_ST_TYPE(sym->st_info) == STT_REGISTER)
- break;
- }
-#endif
-
- if (memcmp(symname, MODULE_SYMBOL_PREFIX,
- strlen(MODULE_SYMBOL_PREFIX)) == 0)
- mod->unres = alloc_symbol(symname +
- strlen(MODULE_SYMBOL_PREFIX),
- mod->unres);
- break;
- default:
- /* All exported symbols */
- if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
- add_exported_symbol(symname + strlen(KSYMTAB_PFX),
- mod, NULL);
- }
- break;
- }
-}
-
-int
-is_vmlinux(const char *modname)
-{
- const char *myname;
-
- if ((myname = strrchr(modname, '/')))
- myname++;
- else
- myname = modname;
-
- return strcmp(myname, "vmlinux") == 0;
-}
-
-void
-read_symbols(char *modname)
-{
- const char *symname;
- struct module *mod;
- struct elf_info info = { };
- Elf_Sym *sym;
-
- parse_elf(&info, modname);
-
- mod = new_module(modname);
-
- /* When there's no vmlinux, don't print warnings about
- * unresolved symbols (since there'll be too many ;) */
- if (is_vmlinux(modname)) {
- unsigned int fake_crc = 0;
- have_vmlinux = 1;
- /* May not have this if !CONFIG_MODULE_UNLOAD: fake it.
- If it appears, we'll get the real CRC. */
- add_exported_symbol("cleanup_module", mod, &fake_crc);
- add_exported_symbol("struct_module", mod, &fake_crc);
- mod->skip = 1;
- }
-
- for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
- symname = info.strtab + sym->st_name;
-
- handle_modversions(mod, &info, sym, symname);
- handle_moddevtable(mod, &info, sym, symname);
- }
- maybe_frob_version(modname, info.modinfo, info.modinfo_len,
- (void *)info.modinfo - (void *)info.hdr);
- parse_elf_finish(&info);
-
- /* Our trick to get versioning for struct_module - it's
- * never passed as an argument to an exported function, so
- * the automatic versioning doesn't pick it up, but it's really
- * important anyhow */
- if (modversions) {
- mod->unres = alloc_symbol("struct_module", mod->unres);
-
- /* Always version init_module and cleanup_module, in
- * case module doesn't have its own. */
- mod->unres = alloc_symbol("init_module", mod->unres);
- mod->unres = alloc_symbol("cleanup_module", mod->unres);
- }
-}
-
-#define SZ 500
-
-/* We first write the generated file into memory using the
- * following helper, then compare to the file on disk and
- * only update the later if anything changed */
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...)
-{
- char tmp[SZ];
- int len;
- va_list ap;
-
- va_start(ap, fmt);
- len = vsnprintf(tmp, SZ, fmt, ap);
- if (buf->size - buf->pos < len + 1) {
- buf->size += 128;
- buf->p = realloc(buf->p, buf->size);
- }
- strncpy(buf->p + buf->pos, tmp, len + 1);
- buf->pos += len;
- va_end(ap);
-}
-
-void
-buf_write(struct buffer *buf, const char *s, int len)
-{
- if (buf->size - buf->pos < len) {
- buf->size += len;
- buf->p = realloc(buf->p, buf->size);
- }
- strncpy(buf->p + buf->pos, s, len);
- buf->pos += len;
-}
-
-/* Header for the generated file */
-
-void
-add_header(struct buffer *b)
-{
- buf_printf(b, "#include <linux/module.h>\n");
- buf_printf(b, "#include <linux/vermagic.h>\n");
- buf_printf(b, "#include <linux/compiler.h>\n");
- buf_printf(b, "\n");
- buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");
- buf_printf(b, "\n");
- buf_printf(b, "#undef unix\n"); /* We have a module called "unix" */
- buf_printf(b, "struct module __this_module\n");
- buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");
- buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n");
- buf_printf(b, " .init = init_module,\n");
- buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n");
- buf_printf(b, " .exit = cleanup_module,\n");
- buf_printf(b, "#endif\n");
- buf_printf(b, "};\n");
-}
-
-/* Record CRCs for unresolved symbols */
-
-void
-add_versions(struct buffer *b, struct module *mod)
-{
- struct symbol *s, *exp;
-
- for (s = mod->unres; s; s = s->next) {
- exp = find_symbol(s->name);
- if (!exp || exp->module == mod) {
- if (have_vmlinux)
- fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
- "undefined!\n", s->name, mod->name);
- continue;
- }
- s->module = exp->module;
- s->crc_valid = exp->crc_valid;
- s->crc = exp->crc;
- }
-
- if (!modversions)
- return;
-
- buf_printf(b, "\n");
- buf_printf(b, "static const struct modversion_info ____versions[]\n");
- buf_printf(b, "__attribute_used__\n");
- buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
-
- for (s = mod->unres; s; s = s->next) {
- if (!s->module) {
- continue;
- }
- if (!s->crc_valid) {
- fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
- "has no CRC!\n",
- s->name, mod->name);
- continue;
- }
- buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name);
- }
-
- buf_printf(b, "};\n");
-}
-
-void
-add_depends(struct buffer *b, struct module *mod, struct module *modules)
-{
- struct symbol *s;
- struct module *m;
- int first = 1;
-
- for (m = modules; m; m = m->next) {
- m->seen = is_vmlinux(m->name);
- }
-
- buf_printf(b, "\n");
- buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
- buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
- buf_printf(b, "\"depends=");
- for (s = mod->unres; s; s = s->next) {
- if (!s->module)
- continue;
-
- if (s->module->seen)
- continue;
-
- s->module->seen = 1;
- buf_printf(b, "%s%s", first ? "" : ",",
- strrchr(s->module->name, '/') + 1);
- first = 0;
- }
- buf_printf(b, "\";\n");
-}
-
-void
-write_if_changed(struct buffer *b, const char *fname)
-{
- char *tmp;
- FILE *file;
- struct stat st;
-
- file = fopen(fname, "r");
- if (!file)
- goto write;
-
- if (fstat(fileno(file), &st) < 0)
- goto close_write;
-
- if (st.st_size != b->pos)
- goto close_write;
-
- tmp = NOFAIL(malloc(b->pos));
- if (fread(tmp, 1, b->pos, file) != b->pos)
- goto free_write;
-
- if (memcmp(tmp, b->p, b->pos) != 0)
- goto free_write;
-
- free(tmp);
- fclose(file);
- return;
-
- free_write:
- free(tmp);
- close_write:
- fclose(file);
- write:
- file = fopen(fname, "w");
- if (!file) {
- perror(fname);
- exit(1);
- }
- if (fwrite(b->p, 1, b->pos, file) != b->pos) {
- perror(fname);
- exit(1);
- }
- fclose(file);
-}
-
-void
-read_dump(const char *fname)
-{
- unsigned long size, pos = 0;
- void *file = grab_file(fname, &size);
- char *line;
-
- if (!file)
- /* No symbol versions, silently ignore */
- return;
-
- while ((line = get_next_line(&pos, file, size))) {
- char *symname, *modname, *d;
- unsigned int crc;
- struct module *mod;
-
- if (!(symname = strchr(line, '\t')))
- goto fail;
- *symname++ = '\0';
- if (!(modname = strchr(symname, '\t')))
- goto fail;
- *modname++ = '\0';
- if (strchr(modname, '\t'))
- goto fail;
- crc = strtoul(line, &d, 16);
- if (*symname == '\0' || *modname == '\0' || *d != '\0')
- goto fail;
-
- if (!(mod = find_module(modname))) {
- if (is_vmlinux(modname)) {
- modversions = 1;
- have_vmlinux = 1;
- }
- mod = new_module(NOFAIL(strdup(modname)));
- mod->skip = 1;
- }
- add_exported_symbol(symname, mod, &crc);
- }
- return;
-fail:
- fatal("parse error in symbol dump file\n");
-}
-
-void
-write_dump(const char *fname)
-{
- struct buffer buf = { };
- struct symbol *symbol;
- int n;
-
- for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
- symbol = symbolhash[n];
- while (symbol) {
- symbol = symbol->next;
- }
- }
-
- for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
- symbol = symbolhash[n];
- while (symbol) {
- buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
- symbol->name, symbol->module->name);
- symbol = symbol->next;
- }
- }
- write_if_changed(&buf, fname);
-}
-
-int
-main(int argc, char **argv)
-{
- struct module *mod;
- struct buffer buf = { };
- char fname[SZ];
- char *dump_read = NULL, *dump_write = NULL;
- int opt;
-
- while ((opt = getopt(argc, argv, "i:o:")) != -1) {
- switch(opt) {
- case 'i':
- dump_read = optarg;
- break;
- case 'o':
- dump_write = optarg;
- break;
- default:
- exit(1);
- }
- }
-
- if (dump_read)
- read_dump(dump_read);
-
- while (optind < argc) {
- read_symbols(argv[optind++]);
- }
-
- for (mod = modules; mod; mod = mod->next) {
- if (mod->skip)
- continue;
-
- buf.pos = 0;
-
- add_header(&buf);
- add_versions(&buf, mod);
- add_depends(&buf, mod, modules);
- add_moddevtable(&buf, mod);
-
- sprintf(fname, "%s.mod.c", mod->name);
- write_if_changed(&buf, fname);
- }
-
- if (dump_write)
- write_dump(dump_write);
-
- return 0;
-}
-
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <elf.h>
-
-#include "elfconfig.h"
-
-#if KERNEL_ELFCLASS == ELFCLASS32
-
-#define Elf_Ehdr Elf32_Ehdr
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define ELF_ST_BIND ELF32_ST_BIND
-#define ELF_ST_TYPE ELF32_ST_TYPE
-
-#else
-
-#define Elf_Ehdr Elf64_Ehdr
-#define Elf_Shdr Elf64_Shdr
-#define Elf_Sym Elf64_Sym
-#define ELF_ST_BIND ELF64_ST_BIND
-#define ELF_ST_TYPE ELF64_ST_TYPE
-
-#endif
-
-#if KERNEL_ELFDATA != HOST_ELFDATA
-
-static inline void __endian(const void *src, void *dest, unsigned int size)
-{
- unsigned int i;
- for (i = 0; i < size; i++)
- ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1];
-}
-
-
-
-#define TO_NATIVE(x) \
-({ \
- typeof(x) __x; \
- __endian(&(x), &(__x), sizeof(__x)); \
- __x; \
-})
-
-#else /* endianness matches */
-
-#define TO_NATIVE(x) (x)
-
-#endif
-
-#define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__, #ptr)
-void *do_nofail(void *ptr, const char *file, int line, const char *expr);
-
-struct buffer {
- char *p;
- int pos;
- int size;
-};
-
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...);
-
-void
-buf_write(struct buffer *buf, const char *s, int len);
-
-struct module {
- struct module *next;
- const char *name;
- struct symbol *unres;
- int seen;
- int skip;
- struct buffer dev_table_buf;
-};
-
-struct elf_info {
- unsigned long size;
- Elf_Ehdr *hdr;
- Elf_Shdr *sechdrs;
- Elf_Sym *symtab_start;
- Elf_Sym *symtab_stop;
- const char *strtab;
- char *modinfo;
- unsigned int modinfo_len;
-};
-
-void handle_moddevtable(struct module *mod, struct elf_info *info,
- Elf_Sym *sym, const char *symname);
-
-void add_moddevtable(struct buffer *buf, struct module *mod);
-
-void maybe_frob_version(const char *modfilename,
- void *modinfo,
- unsigned long modinfo_len,
- unsigned long modinfo_offset);
-
-void *grab_file(const char *filename, unsigned long *size);
-char* get_next_line(unsigned long *pos, void *file, unsigned long size);
-void release_file(void *file, unsigned long size);
+++ /dev/null
-#include <netinet/in.h>
-#include <stdint.h>
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-#include "modpost.h"
-
-/* Parse tag=value strings from .modinfo section */
-static char *next_string(char *string, unsigned long *secsize)
-{
- /* Skip non-zero chars */
- while (string[0]) {
- string++;
- if ((*secsize)-- <= 1)
- return NULL;
- }
-
- /* Skip any zero padding. */
- while (!string[0]) {
- string++;
- if ((*secsize)-- <= 1)
- return NULL;
- }
- return string;
-}
-
-static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
- const char *tag)
-{
- char *p;
- unsigned int taglen = strlen(tag);
- unsigned long size = modinfo_len;
-
- for (p = modinfo; p; p = next_string(p, &size)) {
- if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
- return p + taglen + 1;
- }
- return NULL;
-}
-
-/*
- * Stolen form Cryptographic API.
- *
- * MD4 Message Digest Algorithm (RFC1320).
- *
- * Implementation derived from Andrew Tridgell and Steve French's
- * CIFS MD4 implementation, and the cryptoapi implementation
- * originally based on the public domain implementation written
- * by Colin Plumb in 1993.
- *
- * Copyright (c) Andrew Tridgell 1997-1998.
- * Modified by Steve French (sfrench@us.ibm.com) 2002
- * Copyright (c) Cryptoapi developers.
- * Copyright (c) 2002 David S. Miller (davem@redhat.com)
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- */
-#define MD4_DIGEST_SIZE 16
-#define MD4_HMAC_BLOCK_SIZE 64
-#define MD4_BLOCK_WORDS 16
-#define MD4_HASH_WORDS 4
-
-struct md4_ctx {
- uint32_t hash[MD4_HASH_WORDS];
- uint32_t block[MD4_BLOCK_WORDS];
- uint64_t byte_count;
-};
-
-static inline uint32_t lshift(uint32_t x, unsigned int s)
-{
- x &= 0xFFFFFFFF;
- return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s));
-}
-
-static inline uint32_t F(uint32_t x, uint32_t y, uint32_t z)
-{
- return (x & y) | ((~x) & z);
-}
-
-static inline uint32_t G(uint32_t x, uint32_t y, uint32_t z)
-{
- return (x & y) | (x & z) | (y & z);
-}
-
-static inline uint32_t H(uint32_t x, uint32_t y, uint32_t z)
-{
- return x ^ y ^ z;
-}
-
-#define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s))
-#define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (uint32_t)0x5A827999,s))
-#define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (uint32_t)0x6ED9EBA1,s))
-
-/* XXX: this stuff can be optimized */
-static inline void le32_to_cpu_array(uint32_t *buf, unsigned int words)
-{
- while (words--) {
- *buf = ntohl(*buf);
- buf++;
- }
-}
-
-static inline void cpu_to_le32_array(uint32_t *buf, unsigned int words)
-{
- while (words--) {
- *buf = htonl(*buf);
- buf++;
- }
-}
-
-static void md4_transform(uint32_t *hash, uint32_t const *in)
-{
- uint32_t a, b, c, d;
-
- a = hash[0];
- b = hash[1];
- c = hash[2];
- d = hash[3];
-
- ROUND1(a, b, c, d, in[0], 3);
- ROUND1(d, a, b, c, in[1], 7);
- ROUND1(c, d, a, b, in[2], 11);
- ROUND1(b, c, d, a, in[3], 19);
- ROUND1(a, b, c, d, in[4], 3);
- ROUND1(d, a, b, c, in[5], 7);
- ROUND1(c, d, a, b, in[6], 11);
- ROUND1(b, c, d, a, in[7], 19);
- ROUND1(a, b, c, d, in[8], 3);
- ROUND1(d, a, b, c, in[9], 7);
- ROUND1(c, d, a, b, in[10], 11);
- ROUND1(b, c, d, a, in[11], 19);
- ROUND1(a, b, c, d, in[12], 3);
- ROUND1(d, a, b, c, in[13], 7);
- ROUND1(c, d, a, b, in[14], 11);
- ROUND1(b, c, d, a, in[15], 19);
-
- ROUND2(a, b, c, d,in[ 0], 3);
- ROUND2(d, a, b, c, in[4], 5);
- ROUND2(c, d, a, b, in[8], 9);
- ROUND2(b, c, d, a, in[12], 13);
- ROUND2(a, b, c, d, in[1], 3);
- ROUND2(d, a, b, c, in[5], 5);
- ROUND2(c, d, a, b, in[9], 9);
- ROUND2(b, c, d, a, in[13], 13);
- ROUND2(a, b, c, d, in[2], 3);
- ROUND2(d, a, b, c, in[6], 5);
- ROUND2(c, d, a, b, in[10], 9);
- ROUND2(b, c, d, a, in[14], 13);
- ROUND2(a, b, c, d, in[3], 3);
- ROUND2(d, a, b, c, in[7], 5);
- ROUND2(c, d, a, b, in[11], 9);
- ROUND2(b, c, d, a, in[15], 13);
-
- ROUND3(a, b, c, d,in[ 0], 3);
- ROUND3(d, a, b, c, in[8], 9);
- ROUND3(c, d, a, b, in[4], 11);
- ROUND3(b, c, d, a, in[12], 15);
- ROUND3(a, b, c, d, in[2], 3);
- ROUND3(d, a, b, c, in[10], 9);
- ROUND3(c, d, a, b, in[6], 11);
- ROUND3(b, c, d, a, in[14], 15);
- ROUND3(a, b, c, d, in[1], 3);
- ROUND3(d, a, b, c, in[9], 9);
- ROUND3(c, d, a, b, in[5], 11);
- ROUND3(b, c, d, a, in[13], 15);
- ROUND3(a, b, c, d, in[3], 3);
- ROUND3(d, a, b, c, in[11], 9);
- ROUND3(c, d, a, b, in[7], 11);
- ROUND3(b, c, d, a, in[15], 15);
-
- hash[0] += a;
- hash[1] += b;
- hash[2] += c;
- hash[3] += d;
-}
-
-static inline void md4_transform_helper(struct md4_ctx *ctx)
-{
- le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(uint32_t));
- md4_transform(ctx->hash, ctx->block);
-}
-
-static void md4_init(struct md4_ctx *mctx)
-{
- mctx->hash[0] = 0x67452301;
- mctx->hash[1] = 0xefcdab89;
- mctx->hash[2] = 0x98badcfe;
- mctx->hash[3] = 0x10325476;
- mctx->byte_count = 0;
-}
-
-static void md4_update(struct md4_ctx *mctx,
- const unsigned char *data, unsigned int len)
-{
- const uint32_t avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
-
- mctx->byte_count += len;
-
- if (avail > len) {
- memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
- data, len);
- return;
- }
-
- memcpy((char *)mctx->block + (sizeof(mctx->block) - avail),
- data, avail);
-
- md4_transform_helper(mctx);
- data += avail;
- len -= avail;
-
- while (len >= sizeof(mctx->block)) {
- memcpy(mctx->block, data, sizeof(mctx->block));
- md4_transform_helper(mctx);
- data += sizeof(mctx->block);
- len -= sizeof(mctx->block);
- }
-
- memcpy(mctx->block, data, len);
-}
-
-static void md4_final_ascii(struct md4_ctx *mctx, char *out, unsigned int len)
-{
- const unsigned int offset = mctx->byte_count & 0x3f;
- char *p = (char *)mctx->block + offset;
- int padding = 56 - (offset + 1);
-
- *p++ = 0x80;
- if (padding < 0) {
- memset(p, 0x00, padding + sizeof (uint64_t));
- md4_transform_helper(mctx);
- p = (char *)mctx->block;
- padding = 56;
- }
-
- memset(p, 0, padding);
- mctx->block[14] = mctx->byte_count << 3;
- mctx->block[15] = mctx->byte_count >> 29;
- le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
- sizeof(uint64_t)) / sizeof(uint32_t));
- md4_transform(mctx->hash, mctx->block);
- cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(uint32_t));
-
- snprintf(out, len, "%08X%08X%08X%08X",
- mctx->hash[0], mctx->hash[1], mctx->hash[2], mctx->hash[3]);
-}
-
-static inline void add_char(unsigned char c, struct md4_ctx *md)
-{
- md4_update(md, &c, 1);
-}
-
-static int parse_string(const char *file, unsigned long len,
- struct md4_ctx *md)
-{
- unsigned long i;
-
- add_char(file[0], md);
- for (i = 1; i < len; i++) {
- add_char(file[i], md);
- if (file[i] == '"' && file[i-1] != '\\')
- break;
- }
- return i;
-}
-
-static int parse_comment(const char *file, unsigned long len)
-{
- unsigned long i;
-
- for (i = 2; i < len; i++) {
- if (file[i-1] == '*' && file[i] == '/')
- break;
- }
- return i;
-}
-
-/* FIXME: Handle .s files differently (eg. # starts comments) --RR */
-static int parse_file(const char *fname, struct md4_ctx *md)
-{
- char *file;
- unsigned long i, len;
-
- file = grab_file(fname, &len);
- if (!file)
- return 0;
-
- for (i = 0; i < len; i++) {
- /* Collapse and ignore \ and CR. */
- if (file[i] == '\\' && (i+1 < len) && file[i+1] == '\n') {
- i++;
- continue;
- }
-
- /* Ignore whitespace */
- if (isspace(file[i]))
- continue;
-
- /* Handle strings as whole units */
- if (file[i] == '"') {
- i += parse_string(file+i, len - i, md);
- continue;
- }
-
- /* Comments: ignore */
- if (file[i] == '/' && file[i+1] == '*') {
- i += parse_comment(file+i, len - i);
- continue;
- }
-
- add_char(file[i], md);
- }
- release_file(file, len);
- return 1;
-}
-
-/* We have dir/file.o. Open dir/.file.o.cmd, look for deps_ line to
- * figure out source file. */
-static int parse_source_files(const char *objfile, struct md4_ctx *md)
-{
- char *cmd, *file, *line, *dir;
- const char *base;
- unsigned long flen, pos = 0;
- int dirlen, ret = 0, check_files = 0;
-
- cmd = NOFAIL(malloc(strlen(objfile) + sizeof("..cmd")));
-
- base = strrchr(objfile, '/');
- if (base) {
- base++;
- dirlen = base - objfile;
- sprintf(cmd, "%.*s.%s.cmd", dirlen, objfile, base);
- } else {
- dirlen = 0;
- sprintf(cmd, ".%s.cmd", objfile);
- }
- dir = NOFAIL(malloc(dirlen + 1));
- strncpy(dir, objfile, dirlen);
- dir[dirlen] = '\0';
-
- file = grab_file(cmd, &flen);
- if (!file) {
- fprintf(stderr, "Warning: could not find %s for %s\n",
- cmd, objfile);
- goto out;
- }
-
- /* There will be a line like so:
- deps_drivers/net/dummy.o := \
- drivers/net/dummy.c \
- $(wildcard include/config/net/fastroute.h) \
- include/linux/config.h \
- $(wildcard include/config/h.h) \
- include/linux/module.h \
-
- Sum all files in the same dir or subdirs.
- */
- while ((line = get_next_line(&pos, file, flen)) != NULL) {
- char* p = line;
- if (strncmp(line, "deps_", sizeof("deps_")-1) == 0) {
- check_files = 1;
- continue;
- }
- if (!check_files)
- continue;
-
- /* Continue until line does not end with '\' */
- if ( *(p + strlen(p)-1) != '\\')
- break;
- /* Terminate line at first space, to get rid of final ' \' */
- while (*p) {
- if (isspace(*p)) {
- *p = '\0';
- break;
- }
- p++;
- }
-
- /* Check if this file is in same dir as objfile */
- if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
- if (!parse_file(line, md)) {
- fprintf(stderr,
- "Warning: could not open %s: %s\n",
- line, strerror(errno));
- goto out_file;
- }
-
- }
-
- }
-
- /* Everyone parsed OK */
- ret = 1;
-out_file:
- release_file(file, flen);
-out:
- free(dir);
- free(cmd);
- return ret;
-}
-
-static int get_version(const char *modname, char sum[])
-{
- void *file;
- unsigned long len;
- int ret = 0;
- struct md4_ctx md;
- char *sources, *end, *fname;
- const char *basename;
- char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
-
- /* Source files for module are in .tmp_versions/modname.mod,
- after the first line. */
- if (strrchr(modname, '/'))
- basename = strrchr(modname, '/') + 1;
- else
- basename = modname;
- sprintf(filelist, ".tmp_versions/%s", basename);
- /* Truncate .o, add .mod */
- strcpy(filelist + strlen(filelist)-2, ".mod");
-
- file = grab_file(filelist, &len);
- if (!file) {
- fprintf(stderr, "Warning: could not find versions for %s\n",
- filelist);
- return 0;
- }
-
- sources = strchr(file, '\n');
- if (!sources) {
- fprintf(stderr, "Warning: malformed versions file for %s\n",
- modname);
- goto release;
- }
-
- sources++;
- end = strchr(sources, '\n');
- if (!end) {
- fprintf(stderr, "Warning: bad ending versions file for %s\n",
- modname);
- goto release;
- }
- *end = '\0';
-
- md4_init(&md);
- for (fname = strtok(sources, " "); fname; fname = strtok(NULL, " ")) {
- if (!parse_source_files(fname, &md))
- goto release;
- }
-
- /* sum is of form \0<padding>. */
- md4_final_ascii(&md, sum, 1 + strlen(sum+1));
- ret = 1;
-release:
- release_file(file, len);
- return ret;
-}
-
-static void write_version(const char *filename, const char *sum,
- unsigned long offset)
-{
- int fd;
-
- fd = open(filename, O_RDWR);
- if (fd < 0) {
- fprintf(stderr, "Warning: changing sum in %s failed: %s\n",
- filename, strerror(errno));
- return;
- }
-
- if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
- fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n",
- filename, offset, strerror(errno));
- goto out;
- }
-
- if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
- fprintf(stderr, "Warning: writing sum in %s failed: %s\n",
- filename, strerror(errno));
- goto out;
- }
-out:
- close(fd);
-}
-
-void strip_rcs_crap(char *version)
-{
- unsigned int len, full_len;
-
- if (strncmp(version, "$Revision", strlen("$Revision")) != 0)
- return;
-
- /* Space for version string follows. */
- full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2;
-
- /* Move string to start with version number: prefix will be
- * $Revision$ or $Revision: */
- len = strlen("$Revision");
- if (version[len] == ':' || version[len] == '$')
- len++;
- while (isspace(version[len]))
- len++;
- memmove(version, version+len, full_len-len);
- full_len -= len;
-
- /* Preserve up to next whitespace. */
- len = 0;
- while (version[len] && !isspace(version[len]))
- len++;
- memmove(version + len, version + strlen(version),
- full_len - strlen(version));
-}
-
-/* If the modinfo contains a "version" value, then set this. */
-void maybe_frob_version(const char *modfilename,
- void *modinfo,
- unsigned long modinfo_len,
- unsigned long modinfo_offset)
-{
- char *version, *csum;
-
- version = get_modinfo(modinfo, modinfo_len, "version");
- if (!version)
- return;
-
- /* RCS $Revision gets stripped out. */
- strip_rcs_crap(version);
-
- /* Check against double sumversion */
- if (strchr(version, ' '))
- return;
-
- /* Version contains embedded NUL: second half has space for checksum */
- csum = version + strlen(version);
- *(csum++) = ' ';
- if (get_version(modfilename, csum))
- write_version(modfilename, version,
- modinfo_offset + (version - (char *)modinfo));
-}
+++ /dev/null
-/*
- * Driver for CS4232 on NEC PC9800 series
- * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
- * Osamu Tomita <tomita@cinet.co.jp>
- * Takashi Iwai <tiwai@suse.de>
- * Hideaki Okubo <okubo@msh.biglobe.ne.jp>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <sound/driver.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/moduleparam.h>
-#include <sound/core.h>
-#include <sound/cs4231.h>
-#include <sound/mpu401.h>
-#include <sound/opl3.h>
-#include <sound/initval.h>
-#include "sound_pc9800.h"
-
-#define chip_t cs4231_t
-
-MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
-MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DESCRIPTION("NEC PC9800 CS4232");
-MODULE_DEVICES("{{NEC,PC9800}}");
-
-#define IDENT "PC98-CS4232"
-
-static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
-static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
-static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
-static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
-#if 0 /* NOT USED */
-static long cport[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
-#endif
-static long mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* PnP setup */
-static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
-static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
-static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 9,11,12,15 */
-static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
-static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
-static int pc98ii[SNDRV_CARDS]; /* PC98II */
-static int boot_devs;
-
-module_param_array(index, int, boot_devs, 0444);
-MODULE_PARM_DESC(index, "Index value for " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-module_param_array(id, charp, boot_devs, 0444);
-MODULE_PARM_DESC(id, "ID string for " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-module_param_array(enable, bool, boot_devs, 0444);
-MODULE_PARM_DESC(enable, "Enable " IDENT " soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
-module_param_array(port, long, boot_devs, 0444);
-MODULE_PARM_DESC(port, "Port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(port, SNDRV_PORT12_DESC);
-#if 0 /* NOT USED */
-module_param_array(cport, long, boot_devs, 0444);
-MODULE_PARM_DESC(cport, "Control port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(cport, SNDRV_PORT12_DESC);
-#endif
-module_param_array(mpu_port, long, boot_devs, 0444);
-MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT12_DESC);
-module_param_array(fm_port, long, boot_devs, 0444);
-MODULE_PARM_DESC(fm_port, "FM port # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(fm_port, SNDRV_PORT12_DESC);
-module_param_array(irq, int, boot_devs, 0444);
-MODULE_PARM_DESC(irq, "IRQ # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(irq, SNDRV_IRQ_DESC);
-module_param_array(mpu_irq, int, boot_devs, 0444);
-MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(mpu_irq, SNDRV_IRQ_DESC);
-module_param_array(dma1, int, boot_devs, 0444);
-MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(dma1, SNDRV_DMA_DESC);
-module_param_array(dma2, int, boot_devs, 0444);
-MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
-MODULE_PARM_SYNTAX(dma2, SNDRV_DMA_DESC);
-module_param_array(pc98ii, bool, boot_devs, 0444);
-MODULE_PARM_DESC(pc98ii, "Roland MPU-PC98II support.");
-MODULE_PARM_SYNTAX(pc98ii, SNDRV_BOOLEAN_FALSE_DESC);
-
-
-static snd_card_t *snd_pc98_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
-
-/*
- * initialize MPU401-UART
- */
-
-static int __init pc98_mpu401_init(int irq)
-{
-#include "pc9801_118_magic.h"
-#define outp118(reg,data) outb((reg),0x148e);outb((data),0x148f)
-#define WAIT118 outb(0x00,0x5f)
- int mpu_intr, count;
-#ifdef OOKUBO_ORIGINAL
- int err = 0;
-#endif /* OOKUBO_ORIGINAL */
-
- switch (irq) {
- case 3:
- mpu_intr = 3;
- break;
- case 5:
- mpu_intr = 2;
- break;
- case 6:
- mpu_intr = 1;
- break;
- case 10:
- mpu_intr = 0;
- break;
- default:
- snd_printk(KERN_ERR IDENT ": Bad IRQ %d\n", irq);
- return -EINVAL;
- }
-
- outp118(0x21, mpu_intr);
- WAIT118;
- outb(0x00, 0x148e);
- if (inb(0x148f) & 0x08) {
- snd_printk(KERN_INFO IDENT ": No MIDI daughter board found\n");
- return 0;
- }
-
- outp118(0x20, 0x00);
- outp118(0x05, 0x04);
- for (count = 0; count < 35000; count ++)
- WAIT118;
- outb(0x05, 0x148e);
- for (count = 0; count < 65000; count ++)
- if (inb(0x148f) == 0x04)
- goto set_mode_118;
- snd_printk(KERN_ERR IDENT ": MIDI daughter board initialize failed at stage1\n\n");
- return -EINVAL;
-
- set_mode_118:
- outp118(0x05, 0x0c);
- outb(0xaa, 0x485);
- outb(0x99, 0x485);
- outb(0x2a, 0x485);
- for (count = 0; count < sizeof(Data0485_99); count ++) {
- outb(Data0485_99[count], 0x485);
- WAIT118;
- }
-
- outb(0x00, 0x486);
- outb(0xaa, 0x485);
- outb(0x9e, 0x485);
- outb(0x2a, 0x485);
- for (count = 0; count < sizeof(Data0485_9E); count ++)
- if (inb(0x485) != Data0485_9E[count]) {
-#ifdef OOKUBO_ORIGINAL
- err = 1;
-#endif /* OOKUBO_ORIGINAL */
- break;
- }
- outb(0x00, 0x486);
- for (count = 0; count < 2000; count ++)
- WAIT118;
-#ifdef OOKUBO_ORIGINAL
- if (!err) {
- outb(0xaa, 0x485);
- outb(0x36, 0x485);
- outb(0x28, 0x485);
- for (count = 0; count < sizeof(Data0485_36); count ++)
- outb(Data0485_36[count], 0x485);
- outb(0x00, 0x486);
- for (count = 0; count < 1500; count ++)
- WAIT118;
- outp118(0x05, inb(0x148f) | 0x08);
- outb(0xff, 0x148c);
- outp118(0x05, inb(0x148f) & 0xf7);
- for (count = 0; count < 1500; count ++)
- WAIT118;
- }
-#endif /* OOKUBO_ORIGINAL */
-
- outb(0xaa, 0x485);
- outb(0xa9, 0x485);
- outb(0x21, 0x485);
- for (count = 0; count < sizeof(Data0485_A9); count ++) {
- outb(Data0485_A9[count], 0x485);
- WAIT118;
- }
-
- outb(0x00, 0x486);
- outb(0xaa, 0x485);
- outb(0x0c, 0x485);
- outb(0x20, 0x485);
- for (count = 0; count < sizeof(Data0485_0C); count ++) {
- outb(Data0485_0C[count], 0x485);
- WAIT118;
- }
-
- outb(0x00, 0x486);
- outb(0xaa, 0x485);
- outb(0x66, 0x485);
- outb(0x20, 0x485);
- for (count = 0; count < sizeof(Data0485_66); count ++) {
- outb(Data0485_66[count], 0x485);
- WAIT118;
- }
-
- outb(0x00, 0x486);
- outb(0xaa, 0x485);
- outb(0x60, 0x485);
- outb(0x20, 0x485);
- for (count = 0; count < sizeof(Data0485_60); count ++) {
- outb(Data0485_60[count], 0x485);
- WAIT118;
- }
-
- outb(0x00, 0x486);
- outp118(0x05, 0x04);
- outp118(0x05, 0x00);
- for (count = 0; count < 35000; count ++)
- WAIT118;
- outb(0x05, 0x148e);
- for (count = 0; count < 65000; count ++)
- if (inb(0x148f) == 0x00)
- goto end_mode_118;
- snd_printk(KERN_ERR IDENT ": MIDI daughter board initialize failed at stage2\n");
- return -EINVAL;
-
- end_mode_118:
- outb(0x3f, 0x148d);
- snd_printk(KERN_INFO IDENT ": MIDI daughter board initialized\n");
- return 0;
-}
-
-static int __init pc98_cs4231_chip_init(int dev)
-{
- int intr_bits, intr_bits2, dma_bits;
-
- switch (irq[dev]) {
- case 3:
- intr_bits = 0x08;
- intr_bits2 = 0x03;
- break;
- case 5:
- intr_bits = 0x10;
- intr_bits2 = 0x08;
- break;
- case 10:
- intr_bits = 0x18;
- intr_bits2 = 0x02;
- break;
- case 12:
- intr_bits = 0x20;
- intr_bits2 = 0x00;
- break;
- default:
- snd_printk(KERN_ERR IDENT ": Bad IRQ %d\n", irq[dev]);
- return -EINVAL;
- }
-
- switch (dma1[dev]) {
- case 0:
- dma_bits = 0x01;
- break;
- case 1:
- dma_bits = 0x02;
- break;
- case 3:
- dma_bits = 0x03;
- break;
- default:
- snd_printk(KERN_ERR IDENT ": Bad DMA %d\n", dma1[dev]);
- return -EINVAL;
- }
-
- if (dma2[dev] >= 2) {
- snd_printk(KERN_ERR IDENT ": Bad DMA %d\n", dma2[dev]);
- return -EINVAL;
- }
-
- outb(dma1[dev], 0x29); /* dma1 boundary 64KB */
- if (dma1[dev] != dma2[dev] && dma2[dev] >= 0) {
- outb(0, 0x5f); /* wait */
- outb(dma2[dev], 0x29); /* dma2 boundary 64KB */
- intr_bits |= 0x04;
- }
-
- if (PC9800_SOUND_ID() == PC9800_SOUND_ID_118) {
- /* Set up CanBe control registers. */
- snd_printd(KERN_INFO "Setting up CanBe Sound System\n");
- outb(inb(PC9800_SOUND_IO_ID) | 0x03, PC9800_SOUND_IO_ID);
- outb(0x01, 0x0f4a);
- outb(intr_bits2, 0x0f4b);
- }
-
- outb(intr_bits | dma_bits, 0xf40);
- return 0;
-}
-
-
-static int __init snd_card_pc98_probe(int dev)
-{
- snd_card_t *card;
- snd_pcm_t *pcm = NULL;
- cs4231_t *chip;
- opl3_t *opl3;
- int err;
-
- if (port[dev] == SNDRV_AUTO_PORT) {
- snd_printk(KERN_ERR IDENT ": specify port\n");
- return -EINVAL;
- }
- card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
- if (card == NULL)
- return -ENOMEM;
-
- if ((err = pc98_cs4231_chip_init(dev)) < 0) {
- snd_card_free(card);
- return err;
- }
-
- if ((err = snd_cs4231_create(card,
- port[dev],
- -1,
- irq[dev],
- dma1[dev],
- dma2[dev],
- CS4231_HW_DETECT,
- 0,
- &chip)) < 0) {
- snd_card_free(card);
- return err;
- }
- if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) {
- snd_card_free(card);
- return err;
- }
- if ((err = snd_cs4231_mixer(chip)) < 0) {
- snd_card_free(card);
- return err;
- }
-
- if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) {
- snd_card_free(card);
- return err;
- }
-
- if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
- /* ??? */
- outb(0x00, fm_port[dev] + 6);
- inb(fm_port[dev] + 7);
- /* Enable OPL-3 Function */
- outb(inb(PC9800_SOUND_IO_ID) | 0x03, PC9800_SOUND_IO_ID);
- if (snd_opl3_create(card,
- fm_port[dev], fm_port[dev] + 2,
- OPL3_HW_OPL3_PC98, 0, &opl3) < 0) {
- printk(KERN_ERR IDENT ": OPL3 not detected\n");
- } else {
- if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
- snd_card_free(card);
- return err;
- }
- }
- }
-
- if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) {
- err = pc98_mpu401_init(mpu_irq[dev]);
- if (! err) {
- err = snd_mpu401_uart_new(card, 0,
- pc98ii[dev] ? MPU401_HW_PC98II : MPU401_HW_MPU401,
- mpu_port[dev], 0,
- mpu_irq[dev], SA_INTERRUPT, NULL);
- if (err < 0)
- snd_printk(KERN_INFO IDENT ": MPU401 not detected\n");
- }
- }
-
- strcpy(card->driver, pcm->name);
- strcpy(card->shortname, pcm->name);
- sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i",
- pcm->name,
- chip->port,
- irq[dev],
- dma1[dev]);
- if (dma2[dev] >= 0)
- sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]);
- if ((err = snd_card_register(card)) < 0) {
- snd_card_free(card);
- return err;
- }
- snd_pc98_cards[dev] = card;
- return 0;
-}
-
-static int __init alsa_card_pc98_init(void)
-{
- int dev, cards = 0;
-
- for (dev = 0; dev < SNDRV_CARDS; dev++) {
- if (!enable[dev])
- continue;
- if (snd_card_pc98_probe(dev) >= 0)
- cards++;
- }
- if (!cards) {
-#ifdef MODULE
- printk(KERN_ERR IDENT " soundcard not found or device busy\n");
-#endif
- return -ENODEV;
- }
- return 0;
-}
-
-static void __exit alsa_card_pc98_exit(void)
-{
- int idx;
-
- for (idx = 0; idx < SNDRV_CARDS; idx++)
- snd_card_free(snd_pc98_cards[idx]);
-}
-
-module_init(alsa_card_pc98_init)
-module_exit(alsa_card_pc98_exit)
+++ /dev/null
- static unsigned char Data0485_A9[] = {
- 0x12, 0x03, 0x90, 0xc2, 0x2a, 0x75, 0x1e, 0x20,
- 0xe4, 0x12, 0x2b, 0x9b, 0x22, 0xa9, 0x16, 0x77,
- 0x33, 0xe9, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf5,
- 0x16, 0xc2, 0x2f, 0x22, 0xa9, 0x16, 0x77, 0x42,
- 0xe9, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf9, 0x77,
- 0xf8, 0x04, 0x54, 0x03, 0x44, 0xa8, 0xf5, 0x16,
- 0xc2, 0x2f, 0x22, 0x90, 0x25, 0x9f, 0x30, 0x04,
- 0x05, 0xc2, 0x04, 0x12, 0x1f, 0x62, 0x30, 0x00,
- 0x05, 0xc2, 0x00, 0x12, 0x15, 0xe6, 0x30, 0x01,
- 0x05, 0xc2, 0x01, 0x12, 0x29, 0xaf, 0x30, 0x02,
- 0x05, 0xc2, 0x02, 0x12, 0x29, 0xaf, 0x30, 0x05,
- 0x05, 0xc2, 0x05, 0x12, 0x16, 0x65, 0x30, 0x06,
- 0x08, 0xc2, 0x06, 0x12, 0x16, 0xb1, 0x12, 0x29,
- 0xaf, 0x30, 0x07, 0x08, 0xc2, 0x07, 0x12, 0x16,
- 0xe9, 0x12, 0x29, 0xaf, 0x22, 0x20, 0x97, 0x09,
- 0x53, 0xa8, 0xfb, 0x12, 0x04, 0x2c, 0x43, 0xa8,
- 0x04, 0x22, 0x71, 0xb8, 0x71, 0xb8, 0x71, 0xb8,
- 0x22, 0x20, 0x4b, 0x04, 0x75, 0x4e, 0x02, 0x22,
- 0xe5, 0x35, 0x24, 0xff, 0xf5, 0x35, 0xe5, 0x36,
- 0x34, 0xff, 0xf5, 0x36, 0x75, 0x4e, 0x02, 0x22,
- 0x10, 0x19, 0x02, 0x80, 0x08, 0x78, 0x00, 0xe2,
- 0x78, 0x07, 0xf2, 0x61, 0x9b, 0x78, 0x11, 0xe2,
- 0xc0, 0x01, 0xc0, 0xf0, 0xc0, 0xd0, 0xc0, 0x02,
- 0x71, 0x14, 0xe5, 0x30, 0xb4, 0x01, 0x02, 0x61,
- 0x93, 0x43, 0x08, 0x40, 0x12, 0x2a, 0x53, 0x61,
- 0x93, 0x79, 0x03, 0xe3, 0xa2, 0xe2, 0x92, 0x26,
- 0xa2, 0xe3, 0x92, 0x27, 0x22, 0xad, 0x2b, 0xbd,
- 0x04, 0x07, 0xf5, 0x72, 0x78, 0x27, 0x02, 0x11,
- 0x76, 0x02, 0x11, 0x30, 0x00, 0x00, 0x00, 0x12,
- 0x28, 0xba, 0x79, 0x01, 0xe3, 0x75, 0x21, 0x3f,
- 0x75, 0x49, 0x11, 0x75, 0x4c, 0x11, 0x31, 0xdc,
- 0x75, 0x1a, 0x80, 0x51, 0x72, 0x75, 0x81, 0xe3,
- 0x12, 0x25, 0xc9, 0x43, 0xa8, 0x01, 0x00, 0x53,
- 0xa8, 0xfe, 0x10, 0x50, 0x02, 0x80, 0x03, 0x12,
- 0x1a, 0x8d, 0xd1, 0x28, 0x12, 0x03, 0xd9, 0xd1,
- 0xf2, 0x12, 0x2d, 0xf0, 0xb0, 0x11, 0x92, 0xe0,
- 0xa2, 0x2a, 0xa0, 0xb5, 0x82, 0xe0, 0x50, 0x03,
- 0x79, 0x0f, 0xe3, 0x71, 0xca, 0x51, 0x1e, 0x91,
- 0xe4, 0x53, 0xa8, 0xfb, 0x10, 0x10, 0x02, 0x80,
- 0x26, 0xc2, 0x8e, 0xd2, 0xab, 0xa2, 0x1c, 0x40,
- 0x13, 0xa2, 0x1d, 0x50, 0x0a, 0x43, 0x08, 0x40,
- 0x12, 0x1a, 0x01, 0xd1, 0xd7, 0x80, 0x0b, 0x12,
- 0x26, 0x04, 0x61, 0x08, 0x43, 0x08, 0x40, 0x12,
- 0x1a, 0x01, 0xd2, 0x1f, 0x12, 0x17, 0x7f, 0x43,
- 0xa8, 0x04, 0x51, 0x1e, 0x91, 0xe4, 0x12, 0x13,
- 0x34, 0x80, 0x98, 0xa2, 0x17, 0x72, 0x16, 0x72,
- 0x15, 0x72, 0x2d, 0x50, 0x06, 0xfa, 0x12, 0x13,
- 0x66, 0x80, 0x25, 0xc2, 0x13, 0x30, 0x28, 0x05,
- 0x12, 0x02, 0xbe, 0x80, 0x1b, 0xb4, 0x10, 0x12,
- 0x78, 0x00, 0xf2, 0xe5, 0x30, 0xb4, 0x01, 0x06,
- 0x12, 0x03, 0x90, 0xd2, 0x19, 0x22, 0x12, 0x00,
- 0xdd, 0x22, 0x75, 0x30, 0x00, 0x12, 0x00, 0xa1,
- 0x22, 0x00, 0x00, 0x75, 0x1e, 0x00, 0x74, 0x0c,
- 0x12, 0x2b, 0x9b, 0x74, 0x40, 0x79, 0x05, 0xf3,
- 0x74, 0x49, 0x12, 0x2b, 0x9b, 0x74, 0x04, 0x79,
- 0x05, 0xf3, 0x75, 0x15, 0x04, 0x74, 0x10, 0x12,
- 0x2b, 0x9b, 0x74, 0x00, 0x79, 0x05, 0xf3, 0x74,
- 0x17, 0x12, 0x2b, 0x9b, 0x74, 0x00, 0x79, 0x05,
- 0xf3, 0x74, 0x1a, 0x12, 0x2b, 0x9b, 0x74, 0x00,
- 0x79, 0x05, 0xf3, 0x74, 0x0a, 0x12, 0x2b, 0x9b,
- 0x74, 0x20, 0x79, 0x05, 0xf3, 0x79, 0xe0, 0x77,
- 0x20, 0x22, 0xd0, 0x02, 0xd0, 0xd0, 0xd0, 0xf0,
- 0xd0, 0x01, 0xe5, 0x5f, 0xd0, 0xa8, 0x22, 0x00,
- 0x00, 0x90, 0x25, 0x9f, 0x75, 0x26, 0xff, 0x75,
- 0x27, 0xff, 0x75, 0x28, 0x03, 0x75, 0x13, 0xff,
- 0x75, 0x1f, 0x00, 0x75, 0x14, 0xff, 0x22, 0x79,
- 0x06, 0xe5, 0x29, 0x60, 0x0b, 0xe3, 0x30, 0xe1,
- 0xf8, 0xe5, 0x4f, 0x64, 0x80, 0x79, 0x07, 0xf3,
- 0x22, 0x10, 0x4c, 0x01, 0x22, 0x30, 0x4b, 0x0a,
- 0xc2, 0x4b, 0xe5, 0x4d, 0x64, 0x80, 0xf5, 0x4f,
- 0x80, 0x1d, 0xe5, 0x15, 0xa2, 0xe0, 0x82, 0xe6,
- 0x40, 0x02, 0x80, 0x35, 0x30, 0x4a, 0x04, 0xb1,
- 0xe6, 0x80, 0x0c, 0x30, 0x49, 0x04, 0x51, 0x2b,
- 0x80, 0x05, 0x30, 0x48, 0x24, 0x91, 0x7e, 0x79,
- 0x06, 0xe3, 0x30, 0xe0, 0x1a, 0x79, 0x06, 0xf3,
- 0xe5, 0x4e, 0x24, 0xff, 0x50, 0x04, 0xf5, 0x4e,
- 0x80, 0x0d, 0x79, 0x0f, 0xf3, 0x20, 0x2a, 0x07,
- 0x12, 0x2b, 0x32, 0x75, 0x29, 0x00, 0x22, 0x91,
- 0x1b, 0x22, 0x79, 0x0f, 0xe3, 0xc0, 0xa8, 0x75,
- 0xa8, 0x00, 0x30, 0x2b, 0x03, 0xd0, 0xa8, 0x22,
- 0x79, 0x0e, 0xf3, 0xd0, 0xa8, 0x22, 0x8a, 0xf0,
- 0xe5, 0x50, 0x10, 0xf3, 0x10, 0x23, 0x23, 0x23,
- 0x25, 0xf0, 0x12, 0x2c, 0xb8, 0xa2, 0xe7, 0x92,
- 0xe4, 0xc2, 0xe7, 0x80, 0x08, 0x23, 0x23, 0x23,
- 0x25, 0xf0, 0x12, 0x2c, 0x19, 0x25, 0x4f, 0x20,
- 0xd2, 0x04, 0xf5, 0x4f, 0x80, 0x0a, 0x40, 0x05,
- 0x75, 0x4f, 0x7f, 0x80, 0x03, 0x75, 0x4f, 0xff,
- 0xea, 0x12, 0x2c, 0x3c, 0x25, 0x50, 0x20, 0xe7,
- 0x05, 0xb4, 0x03, 0x07, 0x80, 0x0c, 0x75, 0x50,
- 0x00, 0x80, 0x09, 0x40, 0x05, 0x75, 0x50, 0x03,
- 0x80, 0x02, 0xf5, 0x50, 0x22, 0xe5, 0x4d, 0xc4,
- 0x54, 0x0c, 0x03, 0x03, 0xfa, 0x91, 0xa9, 0x71,
- 0xb8, 0xe5, 0x4d, 0xc4, 0x54, 0x03, 0xfa, 0x91,
- 0xa9, 0x71, 0xb8, 0xe5, 0x4d, 0x54, 0x0c, 0x03,
- 0x03, 0xfa, 0x91, 0xa9, 0x71, 0xb8, 0xe5, 0x4d,
- 0x54, 0x03, 0xfa, 0x91, 0xa9, 0x71, 0xb8, 0x22,
- 0x8a, 0xf0, 0xe5, 0x50, 0x23, 0x23, 0x25, 0xf0,
- 0x12, 0x2b, 0xf6, 0x25, 0x4f, 0x20, 0xd2, 0x04,
- 0xf5, 0x4f, 0x80, 0x0a, 0x40, 0x05, 0x75, 0x4f,
- 0x7f, 0x80, 0x03, 0x75, 0x4f, 0xff, 0xea, 0x12,
- 0x2c, 0x40, 0x25, 0x50, 0x20, 0xe7, 0x05, 0xb4,
- 0x05, 0x07, 0x80, 0x0c, 0x75, 0x50, 0x00, 0x80,
- 0x09, 0x40, 0x05, 0x75, 0x50, 0x05, 0x80, 0x02,
- 0xf5, 0x50, 0x22, 0x30, 0x26, 0x03, 0x12, 0x1e,
- 0xf5, 0x30, 0x27, 0x03, 0x12, 0x1f, 0x37, 0x30,
- 0x25, 0x09, 0x12, 0x1f, 0x4e, 0x30, 0x23, 0x03,
- 0x12, 0x1f, 0x1e, 0x10, 0x22, 0x02, 0x80, 0x0a,
- 0xe5, 0x3b, 0xb4, 0xff, 0x02, 0xc2, 0x20, 0x12,
- 0x1e, 0x79, 0x22, 0x78, 0x11, 0xe2, 0x20, 0xe0,
- 0x07, 0xc0, 0x01, 0x12, 0x28, 0xba, 0xd0, 0x01,
- 0x78, 0x00, 0xf2, 0x61, 0x9b, 0x12, 0x2b, 0x32,
- 0x12, 0x17, 0x7f, 0x78, 0x00, 0xf2, 0xaa, 0x35,
- 0xab, 0x36, 0xea, 0x24, 0xff, 0xfa, 0xeb, 0x34,
- 0xff, 0xfb, 0x50, 0x03, 0xd2, 0x10, 0x22, 0x75,
- 0x37, 0x01, 0x75, 0x38, 0x00, 0x75, 0x39, 0x00,
- 0x12, 0x04, 0x04, 0xd2, 0x8e, 0x22, 0xa8, 0x2b,
- 0xb8, 0x00, 0x02, 0x80, 0x03, 0x02, 0x11, 0xbd,
- 0xf5, 0x74, 0x78, 0x2a, 0x12, 0x11, 0xec, 0xe5,
- 0x74, 0x78, 0x29, 0x12, 0x11, 0xec, 0x22, 0xfa,
- 0xe5, 0x2b, 0x60, 0x01, 0x22, 0xea, 0x78, 0x2b,
- 0xf5, 0x75, 0x12, 0x11, 0xec, 0x22, 0x74, 0x10,
- 0x12, 0x2b, 0x9b, 0x74, 0x20, 0x78, 0x05, 0xf2,
- 0x74, 0x09, 0x12, 0x17, 0x75, 0xe5, 0x15, 0x44,
- 0x80, 0x79, 0x05, 0xf3, 0xf5, 0x15, 0x12, 0x17,
- 0x7f, 0x22, 0x12, 0x03, 0x84, 0x79, 0x0f, 0xe3,
- 0x78, 0x00, 0xf2, 0x12, 0x2b, 0x28, 0xe5, 0x81,
- 0x24, 0xfc, 0xf5, 0x81, 0x61, 0x93, 0xd2, 0x07,
- 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x4c, 0xc2,
- 0x0f, 0x12, 0x29, 0xa3, 0x61, 0x93, 0x02, 0x1b,
- 0x77, 0x00, 0xe1, 0x81, 0xe1, 0x9a, 0xd2, 0x2c,
- 0xa1, 0x0c, 0x20, 0x20, 0x02, 0xd2, 0x26, 0x02,
- 0x1e, 0x35, 0x02, 0x1e, 0x61, 0x02, 0x1d, 0x8f,
- 0xc2, 0x8e, 0x75, 0xa8, 0x9e, 0x22, 0x41, 0x49,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x29, 0x91, 0x00, 0x00, 0x00, 0xa1, 0xbb,
- 0xa1, 0xc3, 0x02, 0x1e, 0x6b, 0xe5, 0x4d, 0xc4,
- 0x54, 0x0f, 0xfa, 0x91, 0x2f, 0x71, 0xb8, 0xe5,
- 0x4d, 0x54, 0x0f, 0xfa, 0x91, 0x2f, 0x71, 0xb8,
- 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa1, 0xc6,
- 0x02, 0x1d, 0x8f, 0xc2, 0x8e, 0xd2, 0xab, 0xc2,
- 0x10, 0x79, 0x0f, 0xf3, 0x22, 0x00, 0x02, 0x2a,
- 0x84, 0x00, 0xe1, 0xbc, 0xe1, 0xc8, 0x02, 0x1e,
- 0x27, 0x00, 0x78, 0x00, 0xf2, 0x78, 0x0b, 0xe2,
- 0xf4, 0xf5, 0x4d, 0xd2, 0x4c, 0x61, 0x9b, 0x30,
- 0xb5, 0x02, 0xc2, 0x11, 0x22, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x79, 0xbd, 0xf1, 0x3d, 0x83,
- 0x22, 0xdd, 0xbd, 0xbd, 0xbd, 0x61, 0xbd, 0x8d,
- 0x7a, 0xbd, 0xbd, 0xbd, 0xbd, 0x30, 0xbd, 0xbd,
- 0xbd, 0x55, 0xbd, 0xbd, 0xbd, 0x52, 0xbd, 0xb6,
- 0xb6, 0xbd, 0xbd, 0xbd, 0xbd, 0x00, 0xbd, 0xbd,
- 0xbd, 0xe8, 0xda, 0xbd, 0xbd, 0xcf, 0xb9, 0xbd,
- 0xc4, 0xf1, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
- 0xbd, 0x7b, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
- 0xbd, 0x70, 0x6a, 0x57, 0x47, 0x34, 0xbd, 0xbd,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x29, 0xbd,
- 0xbd, 0xbd, 0xb6, 0xb6, 0xbd, 0xbd, 0xbd, 0xbd,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x2e, 0x25,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xfe, 0xf5,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x19, 0xbd,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x21, 0x8f,
- 0x09, 0xbd, 0xf9, 0x86, 0xbd, 0xbd, 0xbd, 0xd7,
- 0xbd, 0xa9, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x9b,
- 0xd1, 0x9d, 0xbd, 0xae, 0xbd, 0xbd, 0xbd, 0xcb,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
- 0xb6, 0xa5, 0xbd, 0xc5, 0xbd, 0xbd, 0xbd, 0xc3,
- 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0x74, 0x10,
- 0x12, 0x2b, 0x9b, 0xe4, 0x78, 0x05, 0xf2, 0x74,
- 0x09, 0x12, 0x17, 0x75, 0xe5, 0x15, 0x54, 0x7f,
- 0x79, 0x05, 0xf3, 0xf5, 0x15, 0x12, 0x17, 0x7f,
- 0x22, 0x30, 0x51, 0x01, 0x22, 0x53, 0xa8, 0xfb,
- 0x12, 0x2d, 0xf0, 0x50, 0x22, 0x79, 0x03, 0xe3,
- 0x20, 0xe4, 0x1c, 0xaa, 0x35, 0xab, 0x36, 0xea,
- 0x24, 0xf0, 0xfa, 0xeb, 0x34, 0xff, 0xfb, 0x50,
- 0x0e, 0x10, 0x1f, 0x02, 0x80, 0x09, 0x20, 0x2a,
- 0x03, 0x12, 0x2b, 0x32, 0x12, 0x2d, 0xd6, 0x43,
- 0xa8, 0x04, 0x22, 0xa2, 0x1c, 0x72, 0x1d, 0x40,
- 0x07, 0x53, 0x08, 0xbf, 0x78, 0x00, 0xf2, 0x22,
- 0xb1, 0x1e, 0x22, 0x00, 0x79, 0x02, 0x12, 0x27,
- 0x3d, 0x02, 0x2d, 0x37, 0x14, 0x54, 0xf0, 0x60,
- 0x21, 0xe5, 0xf0, 0x24, 0xb6, 0xe5, 0xf0, 0x50,
- 0x16, 0x24, 0x8b, 0x50, 0x15, 0xe5, 0xf0, 0x24,
- 0x56, 0xe5, 0xf0, 0x50, 0x08, 0x24, 0x2f, 0x50,
- 0x09, 0xe5, 0xf0, 0x24, 0xd9, 0x24, 0xd5, 0x24,
- 0xf0, 0x22, 0x15, 0x81, 0x15, 0x81, 0xe9, 0x22,
- 0x78, 0x13, 0x74, 0x00, 0xf2, 0x75, 0x2e, 0x01,
- 0xd2, 0x6a, 0xc2, 0x69, 0xc2, 0x68, 0xc2, 0x6c,
- 0x90, 0x25, 0x9f, 0x75, 0xb8, 0x07, 0x41, 0xa4,
- 0xc0, 0x01, 0xc0, 0xf0, 0xc0, 0xd0, 0xc0, 0x02,
- 0xe5, 0x3d, 0x54, 0x7d, 0x03, 0x10, 0xe5, 0x05,
- 0x90, 0x28, 0x4b, 0x80, 0x03, 0x90, 0x2b, 0x7c,
- 0x73, 0xe5, 0x3d, 0x30, 0xe5, 0x07, 0x74, 0xfd,
- 0x78, 0x00, 0xf2, 0x61, 0x9b, 0x90, 0x1a, 0x97,
- 0x74, 0xb6, 0xc0, 0xe0, 0x74, 0x27, 0xc0, 0xe0,
- 0xc0, 0xa8, 0x02, 0x1b, 0xab, 0x90, 0x25, 0x9f,
- 0xd0, 0xa8, 0x22, 0x90, 0x27, 0xb6, 0xc0, 0x82,
- 0xc0, 0x83, 0xc0, 0xa8, 0x02, 0x1d, 0xa6, 0x90,
- 0x27, 0xb6, 0xc0, 0x82, 0xc0, 0x83, 0xc0, 0xa8,
- 0x02, 0x1e, 0x0a, 0xea, 0x24, 0xf0, 0xfa, 0xeb,
- 0x34, 0xff, 0xfb, 0x50, 0x2e, 0x20, 0x0b, 0x05,
- 0x85, 0x44, 0xe0, 0x80, 0x03, 0x75, 0xe0, 0x00,
- 0x30, 0xe1, 0x20, 0xe5, 0x35, 0x24, 0xff, 0xf5,
- 0x35, 0xe5, 0x36, 0x34, 0xff, 0xf5, 0x36, 0xc3,
- 0xe5, 0x36, 0x13, 0xf5, 0x36, 0xe5, 0x35, 0x13,
- 0xf5, 0x35, 0x75, 0x3a, 0x10, 0x12, 0x1a, 0x77,
- 0x02, 0x18, 0x77, 0x75, 0x3a, 0x00, 0x12, 0x1a,
- 0x77, 0x02, 0x18, 0x1b, 0x20, 0x4b, 0x04, 0x75,
- 0x4e, 0x03, 0x22, 0xe5, 0x35, 0x24, 0xff, 0xf5,
- 0x35, 0xe5, 0x36, 0x34, 0xff, 0xf5, 0x36, 0x75,
- 0x4e, 0x03, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x02, 0x2c,
- 0x70, 0xd2, 0x00, 0x78, 0x11, 0xe2, 0x44, 0x11,
- 0xf5, 0x3f, 0xc2, 0x08, 0x12, 0x29, 0xa3, 0x02,
- 0x23, 0x93, 0x21, 0x62, 0x61, 0x40, 0x01, 0x3a,
- 0x01, 0x73, 0x21, 0x76, 0x61, 0xa8, 0x21, 0x39,
- 0x21, 0x4a, 0x02, 0x2a, 0x7b, 0x79, 0x06, 0xf3,
- 0xc0, 0xd0, 0x12, 0x03, 0xd9, 0x78, 0x00, 0xf2,
- 0xd0, 0xd0, 0x22, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x2c, 0xb4, 0x78, 0x11, 0xe2, 0x44, 0x11, 0x54,
- 0x0f, 0xf8, 0xc4, 0x48, 0xd2, 0x05, 0xf5, 0x48,
- 0xc2, 0x0d, 0x31, 0xa3, 0x02, 0x23, 0x93, 0x20,
- 0x4b, 0x04, 0x75, 0x4e, 0x01, 0x22, 0xe5, 0x35,
- 0x24, 0xff, 0xf5, 0x35, 0xe5, 0x36, 0x34, 0xff,
- 0xf5, 0x36, 0x75, 0x4e, 0x01, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x79, 0xd0, 0x77, 0x1b, 0x79, 0xd1, 0x77, 0x18,
- 0x79, 0xd2, 0x77, 0x77, 0x79, 0xd3, 0x77, 0x18,
- 0x22, 0x75, 0x29, 0x00, 0x75, 0x25, 0x00, 0x75,
- 0x34, 0x03, 0x75, 0x22, 0x00, 0x75, 0x23, 0x05,
- 0x75, 0x4f, 0x00, 0x75, 0x50, 0x00, 0x75, 0x30,
- 0x00, 0x79, 0xdc, 0x77, 0x03, 0xc2, 0x8e, 0x75,
- 0x17, 0xa8, 0x75, 0x16, 0xa8, 0x74, 0xaa, 0x79,
- 0x01, 0xf3, 0x79, 0xd7, 0x77, 0x74, 0x79, 0xd8,
- 0x77, 0xff, 0x79, 0xd9, 0x77, 0x07, 0x79, 0xda,
- 0x77, 0x00, 0x12, 0x25, 0x6f, 0x43, 0x08, 0x40,
- 0x71, 0x32, 0x79, 0x0e, 0xe3, 0x10, 0x51, 0x1c,
- 0x74, 0x06, 0x71, 0x9b, 0xe5, 0x11, 0x44, 0x80,
- 0x79, 0x05, 0xf3, 0xf5, 0x11, 0x74, 0x07, 0x71,
- 0x9b, 0xe5, 0x12, 0x44, 0x80, 0x79, 0x05, 0xf3,
- 0xf5, 0x12, 0x80, 0x18, 0x53, 0x27, 0xa0, 0x53,
- 0x28, 0x01, 0x75, 0x20, 0xf7, 0x12, 0x23, 0x4c,
- 0x75, 0x11, 0x80, 0x75, 0x12, 0x80, 0x12, 0x1f,
- 0xc0, 0x12, 0x21, 0xdc, 0x79, 0x06, 0xf3, 0x22,
- 0xd2, 0x02, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5,
- 0x43, 0xc2, 0x0a, 0x12, 0x29, 0xa3, 0x02, 0x23,
- 0x93, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x44,
- 0xc2, 0x0b, 0x12, 0x29, 0xa3, 0x02, 0x23, 0x93,
- 0x78, 0x00, 0xe2, 0x90, 0x25, 0x9f, 0x02, 0x23,
- 0x93, 0x78, 0x11, 0xe2, 0x75, 0x20, 0xf7, 0x75,
- 0x21, 0x3f, 0x75, 0x49, 0x11, 0x75, 0x4c, 0x11,
- 0x31, 0xa3, 0x02, 0x23, 0x93, 0x78, 0x11, 0xe2,
- 0x44, 0x11, 0x54, 0x0f, 0xf8, 0xc4, 0x48, 0xf8,
- 0xe5, 0x49, 0x45, 0x3f, 0x58, 0xf5, 0x49, 0xd2,
- 0x06, 0xc2, 0x0e, 0x31, 0xa3, 0x02, 0x23, 0x93,
- 0xc0, 0x01, 0x20, 0x2a, 0x04, 0x71, 0x32, 0xc2,
- 0x11, 0x11, 0x5e, 0xc2, 0x1f, 0xd0, 0x01, 0x02,
- 0x23, 0x9b, 0x12, 0x21, 0xdc, 0x78, 0x00, 0xf2,
- 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0xda,
- 0xe7, 0x70, 0x2b, 0x20, 0x0a, 0x05, 0x85, 0x43,
- 0xe0, 0x80, 0x03, 0x75, 0xe0, 0x00, 0x30, 0xe1,
- 0x1d, 0x20, 0xe2, 0x1f, 0x74, 0xe0, 0xca, 0x74,
- 0x00, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3, 0xf5,
- 0x09, 0xca, 0x74, 0x01, 0x71, 0x9b, 0xca, 0x79,
- 0x05, 0xf3, 0xf5, 0x0a, 0x80, 0x43, 0x12, 0x15,
- 0x3e, 0x80, 0x3e, 0xe5, 0x0b, 0xb4, 0x17, 0x02,
- 0x80, 0x0b, 0x50, 0x09, 0x74, 0x17, 0xc3, 0x95,
- 0x0b, 0x44, 0x60, 0x80, 0x02, 0x74, 0x60, 0xca,
- 0x74, 0x00, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3,
- 0xf5, 0x09, 0xe5, 0x0c, 0xb4, 0x17, 0x02, 0x80,
- 0x0b, 0x50, 0x09, 0x74, 0x17, 0xc3, 0x95, 0x0c,
- 0x44, 0x60, 0x80, 0x02, 0x74, 0x60, 0xca, 0x74,
- 0x01, 0x71, 0x9b, 0xca, 0x79, 0x05, 0xf3, 0xf5,
- 0x0a, 0x22, 0xd2, 0x04, 0x78, 0x11, 0xe2, 0x44,
- 0x11, 0xf5, 0x46, 0xc2, 0x0c, 0x31, 0xa3, 0x02,
- 0x23, 0x93, 0xd2, 0x05, 0x78, 0x11, 0xe2, 0x44,
- 0x11, 0xf5, 0x48, 0xc2, 0x0d, 0x31, 0xa3, 0x02,
- 0x23, 0x93, 0xd2, 0x06, 0x78, 0x11, 0xe2, 0x44,
- 0x11, 0xf5, 0x49, 0xc2, 0x0e, 0x31, 0xa3, 0x02,
- 0x23, 0x93, 0x30, 0x1c, 0x21, 0x20, 0x4d, 0x1e,
- 0xe5, 0x29, 0x60, 0x1a, 0xc2, 0x1c, 0x12, 0x19,
- 0xec, 0x12, 0x13, 0xcf, 0xd2, 0x4d, 0x12, 0x17,
- 0x7f, 0x78, 0x00, 0xf2, 0x79, 0x06, 0xf3, 0x43,
- 0xa8, 0x04, 0x12, 0x24, 0x1b, 0x22, 0x12, 0x27,
- 0x24, 0x22, 0x78, 0x00, 0xe2, 0x90, 0x25, 0x9f,
- 0x02, 0x23, 0x93, 0x78, 0x00, 0xe2, 0xa2, 0xe7,
- 0x72, 0xe3, 0x92, 0xe7, 0x02, 0x1d, 0x85, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x79, 0x04, 0xe3, 0x54, 0x80, 0x70, 0xf9, 0x22,
- 0xe5, 0x29, 0x79, 0xde, 0xf7, 0x75, 0x29, 0x00,
- 0x70, 0x12, 0xe5, 0x15, 0x79, 0xdd, 0xf7, 0x12,
- 0x2d, 0xf0, 0x40, 0x08, 0x20, 0x1c, 0x07, 0x20,
- 0x1d, 0x04, 0x80, 0x02, 0x71, 0x32, 0x30, 0xb5,
- 0x0c, 0x79, 0x06, 0xf3, 0x20, 0x2a, 0x06, 0x79,
- 0xdd, 0xe7, 0x54, 0xfc, 0xf7, 0xd2, 0x2b, 0x12,
- 0x25, 0x6f, 0x22, 0x00, 0x00, 0x00, 0x00, 0xe5,
- 0x15, 0xa2, 0xe0, 0xb0, 0xe6, 0x40, 0x31, 0xa2,
- 0xe1, 0xb0, 0xe7, 0x40, 0x38, 0x10, 0x2b, 0x02,
- 0x80, 0x26, 0x79, 0xde, 0xe7, 0x70, 0x0b, 0x79,
- 0xdd, 0xe7, 0x20, 0xe0, 0x12, 0x20, 0xe1, 0x28,
- 0x80, 0x16, 0xf5, 0x29, 0x30, 0x4d, 0x11, 0x20,
- 0x4c, 0x0e, 0x12, 0x24, 0x1b, 0x80, 0x09, 0x43,
- 0x08, 0x40, 0x12, 0x13, 0xcf, 0x12, 0x17, 0x7f,
- 0xe5, 0x13, 0x20, 0xe4, 0x05, 0x12, 0x18, 0x1b,
- 0x80, 0x03, 0x12, 0x18, 0x77, 0xc2, 0x2b, 0x22,
- 0x12, 0x26, 0xd7, 0x12, 0x13, 0xb7, 0x22, 0x78,
- 0x04, 0x79, 0x00, 0xd9, 0xfe, 0xd8, 0xfa, 0x22,
- 0x00, 0x74, 0x09, 0x71, 0x9b, 0xe5, 0x15, 0x54,
- 0xfc, 0x79, 0x05, 0xf3, 0xf5, 0x15, 0x22, 0x78,
- 0x11, 0xe2, 0x44, 0x11, 0x54, 0x0f, 0xf8, 0xc4,
- 0x48, 0xf5, 0x46, 0xc2, 0x0c, 0xd2, 0x04, 0x31,
- 0xa3, 0x02, 0x23, 0x93, 0x12, 0x26, 0xd7, 0x12,
- 0x00, 0xb7, 0x22, 0x00, 0x79, 0x06, 0xf3, 0x74,
- 0x0a, 0x71, 0x9b, 0x79, 0xe0, 0xe7, 0x44, 0x02,
- 0xf7, 0x79, 0x05, 0xf3, 0x22, 0x74, 0x0a, 0x71,
- 0x9b, 0x79, 0xe0, 0xe7, 0x54, 0xfd, 0xf7, 0x79,
- 0x05, 0xf3, 0x22, 0x21, 0x59, 0x41, 0x23, 0x21,
- 0x59, 0x41, 0x33, 0x41, 0x43, 0x21, 0x59, 0x21,
- 0x59, 0x02, 0x25, 0x9f, 0x00, 0x74, 0x0d, 0x71,
- 0x9b, 0x74, 0x4d, 0x79, 0x05, 0xf3, 0xd2, 0x52,
- 0x22, 0x00, 0x53, 0x08, 0x40, 0x45, 0x08, 0x45,
- 0x1e, 0x79, 0x04, 0xf3, 0xf5, 0x08, 0x22, 0xd2,
- 0x01, 0x78, 0x11, 0xe2, 0x44, 0x11, 0xf5, 0x42,
- 0xc2, 0x09, 0x31, 0xa3, 0x02, 0x23, 0x93, 0x00,
- 0x00, 0x00, 0x00, 0x71, 0x6e, 0x74, 0x09, 0x12,
- 0x17, 0x75, 0xe5, 0x15, 0x44, 0x40, 0x79, 0x05,
- 0xf3, 0xf5, 0x15, 0x75, 0x3a, 0x00, 0x12, 0x1a,
- 0x77, 0x02, 0x18, 0x1b, 0xf5, 0x38, 0xe5, 0x37,
- 0x24, 0x01, 0xf5, 0x37, 0xe5, 0x38, 0x34, 0x00,
- 0xf5, 0x38, 0x40, 0x05, 0x75, 0x39, 0x00, 0x80,
- 0x03, 0x75, 0x39, 0x01, 0x12, 0x04, 0x04, 0xd2,
- 0x8e, 0x02, 0x03, 0x8d, 0x00, 0xb4, 0x0d, 0x03,
- 0x74, 0x14, 0x22, 0x04, 0x83, 0x22, 0x00, 0x02,
- 0xff, 0x01, 0x00, 0x05, 0xfe, 0xff, 0x00, 0x0a,
- 0xfc, 0xfe, 0x00, 0xc0, 0xf8, 0xfc, 0x00, 0x28,
- 0xf0, 0xf8, 0x00, 0x30, 0xe0, 0xd0, 0x01, 0x88,
- 0x04, 0x83, 0x22, 0x00, 0xff, 0xfe, 0xfd, 0xfc,
- 0xfc, 0xfb, 0xfa, 0xfe, 0xfd, 0xfb, 0xf9, 0xf7,
- 0xf7, 0xf5, 0xf3, 0xfc, 0xfa, 0xf6, 0xf2, 0xee,
- 0xee, 0xea, 0xe6, 0xf8, 0xf4, 0xec, 0xe4, 0xdc,
- 0xd4, 0xcc, 0xc4, 0x24, 0x21, 0x83, 0x22, 0x04,
- 0x83, 0x22, 0xff, 0x01, 0xff, 0x01, 0x00, 0x00,
- 0x00, 0x02, 0x22, 0x32, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0xff,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x83,
- 0x22, 0x8a, 0x01, 0x20, 0x01, 0x0b, 0xea, 0xf3,
- 0xf9, 0x8b, 0x7e, 0x6b, 0xd5, 0x01, 0x00, 0x01,
- 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x3a, 0x01, 0x38, 0x01, 0x4b, 0x01,
- 0x49, 0x01, 0x5c, 0x01, 0x5a, 0x01, 0x08, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x15, 0x24, 0x48, 0x83, 0x22, 0x04,
- 0x83, 0x22, 0x00, 0x01, 0x02, 0x03, 0x04, 0x06,
- 0x07, 0x08, 0x00, 0x03, 0x05, 0x07, 0x09, 0x0d,
- 0x0f, 0x81, 0x00, 0x06, 0x0a, 0x0e, 0x82, 0x8a,
- 0x8e, 0x22, 0x00, 0x0c, 0x84, 0x8c, 0x24, 0x2c,
- 0xa4, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xaa, 0x35, 0xab, 0x36,
- 0x02, 0x27, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x25,
- 0x03, 0x03, 0x2b, 0x03, 0x00, 0x03, 0x00, 0x03,
- 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
- 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x22,
- 0x00, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
- 0x2b, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02,
- 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01,
- 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02,
- 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02,
- 0x21, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00,
- 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x21,
- 0x01, 0x02, 0x21, 0x02, 0x02, 0x02, 0x00, 0x02,
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x20, 0xb5, 0x05,
- 0x79, 0x0f, 0xf3, 0xc2, 0x11, 0x22, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5,
- 0x15, 0xa2, 0xe0, 0xb0, 0xe6, 0x50, 0x01, 0x22,
- 0xa2, 0xe1, 0xb0, 0xe7, 0x22, 0x02, 0x00};
- static unsigned char Data0485_0C[] = {
- 0x02, 0x27, 0x69};
- static unsigned char Data0485_66[] = {
- 0x02, 0x25, 0x47, 0x02, 0x25, 0x60};
- static unsigned char Data0485_60[] = {
- 0x02, 0x22, 0x7e};
- static unsigned char Data0485_99[] = {
- 0xc2, 0x53, 0x02, 0x12, 0x86};
- static unsigned char Data0485_9E[] = {
- 0x70, 0xf9, 0x22};
-#ifdef OOKUBO_ORIGINAL
- static unsigned char Data0485_36[] = {
- 0x78, 0x00, 0xf2, 0xc2, 0x53, 0x74, 0x86, 0xc0,
- 0xe0, 0x74, 0x12, 0xc0, 0xe0, 0x32};
-#endif /* OOKUBO_ORIGINAL */
+++ /dev/null
-#ifndef _SOUND_PC9800_H_
-#define _SOUND_PC9800_H_
-
-#include <asm/io.h>
-
-#define PC9800_SOUND_IO_ID 0xa460
-
-/* Sound Functions ID. */
-#define PC9800_SOUND_ID() ((inb(PC9800_SOUND_IO_ID) >> 4) & 0x0f)
-
-#define PC9800_SOUND_ID_DO 0x0 /* PC-98DO+ Internal */
-#define PC9800_SOUND_ID_GS 0x1 /* PC-98GS Internal */
-#define PC9800_SOUND_ID_73 0x2 /* PC-9801-73 (base 0x18x) */
-#define PC9800_SOUND_ID_73A 0x3 /* PC-9801-73/76 (base 0x28x) */
-#define PC9800_SOUND_ID_86 0x4 /* PC-9801-86 and compatible (base 0x18x) */
-#define PC9800_SOUND_ID_86A 0x5 /* PC-9801-86 (base 0x28x) */
-#define PC9800_SOUND_ID_NF 0x6 /* PC-9821Nf/Np Internal */
-#define PC9800_SOUND_ID_XMATE 0x7 /* X-Mate Internal and compatible */
-#define PC9800_SOUND_ID_118 0x8 /* PC-9801-118 and compatible(CanBe Internal, etc.) */
-
-#define PC9800_SOUND_ID_UNKNOWN 0xf /* Unknown (No Sound System or PC-9801-26) */
-
-#endif
+++ /dev/null
-/*
- * ALSA driver for ICEnsemble VT1724 (Envy24HT)
- *
- * Lowlevel functions for AudioTrak Prodigy 7.1 (and possibly 192) cards
- * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
- * based on the aureon.c code (c) 2003 by Takashi Iwai <tiwai@suse.de>
- *
- * version 0.82: Stable / not all features work yet (no communication with AC97 secondary)
- * added 64x/128x oversampling switch (should be 64x only for 96khz)
- * fixed some recording labels (still need to check the rest)
- * recording is working probably thanks to correct wm8770 initialization
- *
- * version 0.5: Initial release:
- * working: analog output, mixer, headphone amplifier switch
- * not working: prety much everything else, at least i could verify that
- * we have no digital output, no capture, pretty bad clicks and poops
- * on mixer switch and other coll stuff.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- *
- * NOTES:
- *
- *
- *
- * - we reuse the akm4xxx_t record for storing the wm8770 codec data.
- * both wm and akm codecs are pretty similar, so we can integrate
- * both controls in the future, once if wm codecs are reused in
- * many boards.
- *
- * - writing over SPI is implemented but reading is not yet.
- * the SPDIF-in channel status, etc. can be read from CS chip.
- *
- * - DAC digital volumes are not implemented in the mixer.
- * if they show better response than DAC analog volumes, we can use them
- * instead.
- *
- * - Prodigy boards are equipped with AC97 STAC9744 chip , too. it's used to do
- * the analog mixing but not easily controllable (it's not connected
- * directly from envy24ht chip). so let's leave it as it is.
- *
- */
-
-#define REVISION 0.82b
-
-#include <sound/driver.h>
-#include <asm/io.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-
-#include "ice1712.h"
-#include "envy24ht.h"
-#include "prodigy.h"
-
-
-static int prodigy_set_headphone_amp(ice1712_t *ice, int enable)
-{
- unsigned int tmp, tmp2;
-
- tmp2 = tmp = snd_ice1712_gpio_read(ice);
- if (enable)
- tmp |= PRODIGY_HP_AMP_EN;
- else
- tmp &= ~ PRODIGY_HP_AMP_EN;
- if (tmp != tmp2) {
- snd_ice1712_gpio_write(ice, tmp);
- return 1;
- }
- return 0;
-}
-
-
-static int prodigy_get_headphone_amp(ice1712_t *ice)
-{
- unsigned int tmp = snd_ice1712_gpio_read(ice);
-
- return ( tmp & PRODIGY_HP_AMP_EN )!= 0;
-}
-
-
-/*
- * write data in the SPI mode
- */
-static void prodigy_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits)
-{
- unsigned int tmp;
- int i;
-
- tmp = snd_ice1712_gpio_read(ice);
-
- snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_WM_RW|PRODIGY_WM_DATA|PRODIGY_WM_CLK|
- PRODIGY_WM_CS|PRODIGY_CS8415_CS|PRODIGY_HP_AMP_EN));
- tmp |= PRODIGY_WM_RW;
- tmp &= ~cs;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
-
- for (i = bits - 1; i >= 0; i--) {
- tmp &= ~PRODIGY_WM_CLK;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- if (data & (1 << i))
- tmp |= PRODIGY_WM_DATA;
- else
- tmp &= ~PRODIGY_WM_DATA;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- tmp |= PRODIGY_WM_CLK;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- }
-
- tmp &= ~PRODIGY_WM_CLK;
- tmp |= cs;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- tmp |= PRODIGY_WM_CLK;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
-}
-
-
-/*
- * get the current register value of WM codec
- */
-static unsigned short wm_get(ice1712_t *ice, int reg)
-{
- reg <<= 1;
- return ((unsigned short)ice->akm[0].images[reg] << 8) |
- ice->akm[0].images[reg + 1];
-}
-
-/*
- * set the register value of WM codec and remember it
- */
-static void wm_put(ice1712_t *ice, int reg, unsigned short val)
-{
- prodigy_spi_write(ice, PRODIGY_WM_CS, (reg << 9) | (val & 0x1ff), 16);
- reg <<= 1;
- ice->akm[0].images[reg] = val >> 8;
- ice->akm[0].images[reg + 1] = val;
-}
-
-
-/*********************************
- ********* Controls section ******
- *********************************/
-
-#define PRODIGY_CON_HPAMP \
- { \
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
- .name = "Headphone Amplifier", \
- .info = prodigy_hpamp_info, \
- .get = prodigy_hpamp_get, \
- .put = prodigy_hpamp_put \
- }
-
-static int prodigy_hpamp_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
- static char *texts[2] = {
- "Off", "On"
- };
-
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 1;
- uinfo->value.enumerated.items = 2;
-
- if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
- uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
- strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
- return 0;
-}
-
-
-static int prodigy_hpamp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
- ucontrol->value.integer.value[0] = prodigy_get_headphone_amp(ice);
- return 0;
-}
-
-
-static int prodigy_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
- return prodigy_set_headphone_amp(ice,ucontrol->value.integer.value[0]);
-}
-
-
-
-#define PRODIGY_CON_DEEMP \
- { \
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
- .name = "DAC De-emphasis", \
- .info = prodigy_deemp_info, \
- .get = prodigy_deemp_get, \
- .put = prodigy_deemp_put \
- }
-
-static int prodigy_deemp_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
- static char *texts[2] = { "Off", "On" };
-
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 1;
- uinfo->value.enumerated.items = 2;
-
- if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
- uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
- strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
- return 0;
-}
-
-static int prodigy_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- ucontrol->value.integer.value[0] = (wm_get(ice, 0x15) & 0xf) == 0xf;
- return 0;
-}
-
-static int prodigy_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- int temp, temp2;
- temp2 = temp = wm_get(ice, 0x15);
- temp = (temp & ~0xf) | ((ucontrol->value.integer.value[0])*0xf);
- if (temp != temp2) {
- wm_put(ice,0x15,temp);
- return 1;
- }
- return 0;
-}
-
-
-#define PRODIGY_CON_OVERSAMPLING \
- { \
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
- .name = "ADC Oversampling", \
- .info = prodigy_oversampling_info, \
- .get = prodigy_oversampling_get, \
- .put = prodigy_oversampling_put \
- }
-
-static int prodigy_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
-{
- static char *texts[2] = { "128x", "64x" };
-
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 1;
- uinfo->value.enumerated.items = 2;
-
- if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
- uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
- strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
-
- return 0;
-}
-
-static int prodigy_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- ucontrol->value.integer.value[0] = (wm_get(ice, 0x17) & 0x8) == 0x8;
- return 0;
-}
-
-static int prodigy_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- int temp, temp2;
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
-
- temp2 = temp = wm_get(ice, 0x17);
-
- if( ucontrol->value.integer.value[0] ) {
- temp |= 0x8;
- } else {
- temp &= ~0x8;
- }
-
- if (temp != temp2) {
- wm_put(ice,0x17,temp);
- return 1;
- }
- return 0;
-}
-
-
-
-
-/*
- * DAC volume attenuation mixer control
- */
-static int wm_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
- uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
- uinfo->count = 1;
- uinfo->value.integer.min = 0; /* mute */
- uinfo->value.integer.max = 101; /* 0dB */
- return 0;
-}
-
-static int wm_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- int idx;
- unsigned short vol;
-
- down(&ice->gpio_mutex);
- if (kcontrol->private_value)
- idx = WM_DAC_MASTER_ATTEN;
- else
- idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_DAC_ATTEN;
- vol = wm_get(ice, idx) & 0x7f;
- if (vol <= 0x1a)
- ucontrol->value.integer.value[0] = 0;
- else
- ucontrol->value.integer.value[0] = vol - 0x1a;
- up(&ice->gpio_mutex);
-
- return 0;
-}
-
-static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- int idx;
- unsigned short ovol, nvol;
- int change;
-
- snd_ice1712_save_gpio_status(ice);
- if (kcontrol->private_value)
- idx = WM_DAC_MASTER_ATTEN;
- else
- idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_DAC_ATTEN;
- nvol = ucontrol->value.integer.value[0] + 0x1a;
- ovol = wm_get(ice, idx) & 0x7f;
- change = (ovol != nvol);
- if (change) {
- if (nvol <= 0x1a && ovol <= 0x1a)
- change = 0;
- else
- wm_put(ice, idx, nvol | 0x180); /* update on zero detect */
- }
- snd_ice1712_restore_gpio_status(ice);
- return change;
-}
-
-/*
- * ADC gain mixer control
- */
-static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
- uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
- uinfo->count = 1;
- uinfo->value.integer.min = 0; /* -12dB */
- uinfo->value.integer.max = 0x1f; /* 19dB */
- return 0;
-}
-
-static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- int idx;
- unsigned short vol;
-
- down(&ice->gpio_mutex);
- idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_ADC_GAIN;
- vol = wm_get(ice, idx) & 0x1f;
- ucontrol->value.integer.value[0] = vol;
- up(&ice->gpio_mutex);
- return 0;
-}
-
-static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- int idx;
- unsigned short ovol, nvol;
- int change;
-
- snd_ice1712_save_gpio_status(ice);
- idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + WM_ADC_GAIN;
- nvol = ucontrol->value.integer.value[0];
- ovol = wm_get(ice, idx) & 0x1f;
- change = (ovol != nvol);
- if (change)
- wm_put(ice, idx, nvol);
- snd_ice1712_restore_gpio_status(ice);
- return change;
-}
-
-/*
- * ADC input mux mixer control
- */
-static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
-{
- static char *texts[] = {
- "CD Left",
- "CD Right",
- "Line Left",
- "Line Right",
- "Aux Left",
- "Aux Right",
- "Mic Left",
- "Mic Right",
- };
- uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
- uinfo->count = 2;
- uinfo->value.enumerated.items = 8;
- if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
- uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
- strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
- return 0;
-}
-
-static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- unsigned short val;
-
- down(&ice->gpio_mutex);
- val = wm_get(ice, WM_ADC_MUX);
- ucontrol->value.integer.value[0] = val & 7;
- ucontrol->value.integer.value[1] = (val >> 4) & 7;
- up(&ice->gpio_mutex);
- return 0;
-}
-
-static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)
-{
- ice1712_t *ice = snd_kcontrol_chip(kcontrol);
- unsigned short oval, nval;
- int change;
-
- snd_ice1712_save_gpio_status(ice);
- oval = wm_get(ice, WM_ADC_MUX);
- nval = oval & ~0x77;
- nval |= ucontrol->value.integer.value[0] & 7;
- nval |= (ucontrol->value.integer.value[1] & 7) << 4;
- change = (oval != nval);
- if (change)
- wm_put(ice, WM_ADC_MUX, nval);
- snd_ice1712_restore_gpio_status(ice);
- return 0;
-}
-
-/*
- * mixers
- */
-
-static snd_kcontrol_new_t prodigy71_dac_control __devinitdata = {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "DAC Volume",
- .count = 8,
- .info = wm_dac_vol_info,
- .get = wm_dac_vol_get,
- .put = wm_dac_vol_put,
-};
-
-static snd_kcontrol_new_t wm_controls[] __devinitdata = {
- {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Master Playback Volume",
- .info = wm_dac_vol_info,
- .get = wm_dac_vol_get,
- .put = wm_dac_vol_put,
- .private_value = 1,
- },
- {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "ADC Volume",
- .count = 2,
- .info = wm_adc_vol_info,
- .get = wm_adc_vol_get,
- .put = wm_adc_vol_put,
- },
- {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Capture Route",
- .info = wm_adc_mux_info,
- .get = wm_adc_mux_get,
- .put = wm_adc_mux_put,
- },
- PRODIGY_CON_HPAMP ,
- PRODIGY_CON_DEEMP ,
- PRODIGY_CON_OVERSAMPLING
-};
-
-
-static int __devinit prodigy_add_controls(ice1712_t *ice)
-{
- unsigned int i;
- int err;
-
- err = snd_ctl_add(ice->card, snd_ctl_new1(&prodigy71_dac_control, ice));
- if (err < 0)
- return err;
-
- for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
- err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
- if (err < 0)
- return err;
- }
- return 0;
-}
-
-
-/*
- * initialize the chip
- */
-static int __devinit prodigy_init(ice1712_t *ice)
-{
- static unsigned short wm_inits[] = {
-
- /* These come first to reduce init pop noise */
- 0x1b, 0x000, /* ADC Mux */
- 0x1c, 0x009, /* Out Mux1 */
- 0x1d, 0x009, /* Out Mux2 */
-
- 0x18, 0x000, /* All power-up */
-
- 0x16, 0x022, /* I2S, normal polarity, 24bit, high-pass on */
- 0x17, 0x006, /* 128fs, slave mode */
-
- 0x00, 0, /* DAC1 analog mute */
- 0x01, 0, /* DAC2 analog mute */
- 0x02, 0, /* DAC3 analog mute */
- 0x03, 0, /* DAC4 analog mute */
- 0x04, 0, /* DAC5 analog mute */
- 0x05, 0, /* DAC6 analog mute */
- 0x06, 0, /* DAC7 analog mute */
- 0x07, 0, /* DAC8 analog mute */
- 0x08, 0x100, /* master analog mute */
-
- 0x09, 0x7f, /* DAC1 digital full */
- 0x0a, 0x7f, /* DAC2 digital full */
- 0x0b, 0x7f, /* DAC3 digital full */
- 0x0c, 0x7f, /* DAC4 digital full */
- 0x0d, 0x7f, /* DAC5 digital full */
- 0x0e, 0x7f, /* DAC6 digital full */
- 0x0f, 0x7f, /* DAC7 digital full */
- 0x10, 0x7f, /* DAC8 digital full */
- 0x11, 0x1FF, /* master digital full */
-
- 0x12, 0x000, /* phase normal */
- 0x13, 0x090, /* unmute DAC L/R */
- 0x14, 0x000, /* all unmute */
- 0x15, 0x000, /* no deemphasis, no ZFLG */
-
- 0x19, 0x000, /* -12dB ADC/L */
- 0x1a, 0x000 /* -12dB ADC/R */
-
- };
-
- static unsigned short cs_inits[] = {
- 0x0441, /* RUN */
- 0x0100, /* no mute */
- 0x0200, /* */
- 0x0600, /* slave, 24bit */
- };
-
- unsigned int tmp;
- unsigned int i;
-
- printk(KERN_INFO "ice1724: AudioTrak Prodigy 7.1 driver rev. 0.82b\n");
- printk(KERN_INFO "ice1724: This driver is in beta stage. Forsuccess/failure reporting contact\n");
- printk(KERN_INFO "ice1724: Apostolos Dimitromanolakis <apostol@cs.utoronto.ca>\n");
-
- ice->num_total_dacs = 8;
- ice->num_total_adcs = 8;
-
- /* to remeber the register values */
- ice->akm = snd_kcalloc(sizeof(akm4xxx_t), GFP_KERNEL);
- if (! ice->akm)
- return -ENOMEM;
- ice->akm_codecs = 1;
-
- snd_ice1712_gpio_set_dir(ice, 0xbfffff); /* fix this for the time being */
-
- /* reset the wm codec as the SPI mode */
- snd_ice1712_save_gpio_status(ice);
- snd_ice1712_gpio_set_mask(ice,~( PRODIGY_WM_RESET|PRODIGY_WM_CS|
- PRODIGY_CS8415_CS|PRODIGY_HP_AMP_EN ));
-
- tmp = snd_ice1712_gpio_read(ice);
- tmp &= ~PRODIGY_WM_RESET;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- tmp |= PRODIGY_WM_CS | PRODIGY_CS8415_CS;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
- tmp |= PRODIGY_WM_RESET;
- snd_ice1712_gpio_write(ice, tmp);
- udelay(1);
-
- /* initialize WM8770 codec */
- for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
- wm_put(ice, wm_inits[i], wm_inits[i+1]);
-
- /* initialize CS8415A codec */
- for (i = 0; i < ARRAY_SIZE(cs_inits); i++)
- prodigy_spi_write(ice, PRODIGY_CS8415_CS,
- cs_inits[i] | 0x200000, 24);
-
-
- prodigy_set_headphone_amp(ice, 1);
-
- snd_ice1712_restore_gpio_status(ice);
-
- return 0;
-}
-
-/*
- * Prodigy boards don't provide the EEPROM data except for the vendor IDs.
- * hence the driver needs to sets up it properly.
- */
-
-static unsigned char prodigy71_eeprom[] __devinitdata = {
- 0x2b, /* SYSCONF: clock 512, mpu401, spdif-in/ADC, 4DACs */
- 0x80, /* ACLINK: I2S */
- 0xf8, /* I2S: vol, 96k, 24bit, 192k */
- 0xc3, /* SPDIF: out-en, out-int, spdif-in */
- 0xff, /* GPIO_DIR */
- 0xff, /* GPIO_DIR1 */
- 0xbf, /* GPIO_DIR2 */
- 0x00, /* GPIO_MASK */
- 0x00, /* GPIO_MASK1 */
- 0x00, /* GPIO_MASK2 */
- 0x00, /* GPIO_STATE */
- 0x00, /* GPIO_STATE1 */
- 0x00, /* GPIO_STATE2 */
-};
-
-/* entry point */
-struct snd_ice1712_card_info snd_vt1724_prodigy_cards[] __devinitdata = {
- {
- .subvendor = VT1724_SUBDEVICE_PRODIGY71,
- .name = "Audiotrak Prodigy 7.1",
- .chip_init = prodigy_init,
- .build_controls = prodigy_add_controls,
- .eeprom_size = sizeof(prodigy71_eeprom),
- .eeprom_data = prodigy71_eeprom,
- },
- { } /* terminator */
-};
+++ /dev/null
-#ifndef __SOUND_PRODIGY_H
-#define __SOUND_PRODIGY_H
-
-/*
- * ALSA driver for VIA VT1724 (Envy24HT)
- *
- * Lowlevel functions for Terratec PRODIGY cards
- *
- * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#define PRODIGY_DEVICE_DESC "{AudioTrak,Prodigy 7.1},"
-
-#define VT1724_SUBDEVICE_PRODIGY71 0x33495345 /* PRODIGY 7.1 */
-
-extern struct snd_ice1712_card_info snd_vt1724_prodigy_cards[];
-
-/* GPIO bits */
-#define PRODIGY_CS8415_CS (1 << 23)
-#define PRODIGY_CS8415_CDTO (1 << 22)
-#define PRODIGY_WM_RESET (1 << 20)
-#define PRODIGY_WM_CLK (1 << 19)
-#define PRODIGY_WM_DATA (1 << 18)
-#define PRODIGY_WM_RW (1 << 17)
-#define PRODIGY_AC97_RESET (1 << 16)
-#define PRODIGY_DIGITAL_SEL1 (1 << 15)
-// #define PRODIGY_HP_SEL (1 << 14)
-#define PRODIGY_WM_CS (1 << 12)
-
-#define PRODIGY_HP_AMP_EN (1 << 14)
-
-
-/* WM8770 registers */
-#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
-#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
-#define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
-#define WM_DAC_DIG_MATER_ATTEN 0x11 /* DAC master digital attenuation */
-#define WM_PHASE_SWAP 0x12 /* DAC phase */
-#define WM_DAC_CTRL1 0x13 /* DAC control bits */
-#define WM_MUTE 0x14 /* mute controls */
-#define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
-#define WM_INT_CTRL 0x16 /* interface control */
-#define WM_MASTER 0x17 /* master clock and mode */
-#define WM_POWERDOWN 0x18 /* power-down controls */
-#define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */
-#define WM_ADC_MUX 0x1b /* input MUX */
-#define WM_OUT_MUX1 0x1c /* output MUX */
-#define WM_OUT_MUX2 0x1e /* output MUX */
-#define WM_RESET 0x1f /* software reset */
-
-
-#endif /* __SOUND_PRODIGY_H */