|
| 以 PDF 格式下載這本書
FCode Design Considerations
2
- This chapter contains information to consider when designing FCode code for PCI.
Adding a PCI Header to a PROM
- To add a PCI header to your PROM, look at the source code of fakeboot.c from DDK 2.5.1, and enhance it to add a PCI header for your PROM. Another approach is to use addhdr, available with the Solaris 2.6 DDK.
Accessing a PCI Device's Configuration Space Registers
- It isn't necessary to do anything extra to access your device's configuration space registers. They are always accessible.
Base Address Register Setting
- The base address registers used in configuration space are set by the CPU PROM.
- The CPU PROM (not the PCI card's FCode PROM) allocates the base address for memory andor I/O space on your PCI device and for the FCode PROM.
System Cache Line Size
- You must write the system's cash line size into the cash line size configuration space register of your PCI. To do this, look in the cache-line-size register of the configuration space; it refers to the cache line size supported by the PCI device.
Sun Ultra(TM) 1 UPA/PCI-Related Nodes
- The PCI-related nodes on the Sun Ultra(TM) 1 UPA/PCI system are /pci@1f,4000 and /pci@1f,2000. pcia and pcib are required for the NVRAM variables pcia-probe-list and pcib-probe-list and are determined as follows:
- Each PCI bus has a property named "slot-name" which gives information about slots on that PCI bus and sometimes indicate which NVRAM variable corresponds to it.
- To get a value for that property, type the following:
-
ok " </pci-bus-node>" select-dev
ok " slot-name" get-my-property drop decode-int .h cr type
|
- To get a PCI bus at /pci@1f,2000,type the following:
-
ok " /pci@1f,2000" select-dev
ok " slot-name" get-my-property drop decode-int .h cr type
|
- The display will be something like the following to indicate that the devices
-
6
pcia slot 1pcia slot 2
ok " /pci@1f.4000" select-dev
ok " slot-name" get-my-property drop decode-int .h cr type
4
32-bit slot 2
|
- under /pci@1f,2000 relate to pcia.
- In a Sun Ultra 1 UPA/PCI with four plug-in PCI slots, only slot 1 is physically present for pci@1f,2000. It can also support 66 Mhz., 64 bit PCI devices as shown in the following example.
-
ok " /pci@1f,4000" select-dev
ok " slot-name" get-my-property drop decode-int .h cr type
34
pcib slot 2pcib slot 4pcib slot 5
|
- This example indicates that devices under /pci@1f,4000 relate to pcib.
- The PCI slot in a Sun Ultra 1 UPA/PCI with a 4 plug-in is used as follows :
-
- Slots 2, 4, and 5 under /pci@1f,4000 support 33 Mhz., 32 bit PCI devices.
- Slot 3 under /pci@1f,4000 is used for an on-board SCSI device.
- Note that the value of the "slot-name" property differs for different systems. Some systems may not differentiate the PCI bus by the value of the "slot-name" property.
- In different releases of the PROM for the same system, the value of the "slot-name" property may also change. You may need to refer to your system documentation for details about using PCI buses on the system.
- Alternatively, you can find which NVRAM variable refers to which PCI bus by setting the NVRAM variables to different values or by plugging PCI cards in different slots.
Using Physical Addresses
- When you need to find and use physical addresses to access, for instance, configuration space registers on a Sun Ultra 1 UPA/PCI system, use MMU bypassing by selecting with the correct ASI space. The arguments for the space {c,d,w,l,x} command includes an address and ASI code (and data for a write operation.)
- On Sun Ultra 1 UPA/PCI systems, the PCI device configuration registers are viewed using the following address:
-
- where the 32-bit value of X is represented in bit format as:
-
bbbb.bbbb.dddd.dfff.rrrr.rrrr
|
- where
-
bbbb.bbbb is an 8-bit bus number dddd.d is a five bit device number fff is a three-bit function number rrrr.rrrr is an eight-bit register number
- For example, if the bus number is 81, device number is 0 and function number is 1, then x will be 81.0100, giving you a configuration register base.
- This will give you access to the 0th configuration register at 1fe.0181.0100 (physical address). On Sun Ultra 1 UPA/PCI systems, you can use ASI 0x15 for a non-cacheable address being accessed by MMU bypass. If you are accessing a little-endian device, use ASI 0xld.
- You can get bus number, device number, and function number from my-space after selecting that device or from the "reg" property value for that device. Look in IEEE 1275/PCI binding for the "reg" property format.
- In general, to get physical addresses for registers in any space, (configuration space, 32- bit memory space, and others) use the map-in command. map-in requires phys.lo, phys.mid, phys.hi, and length arguments. You can take the phys.lo, phys.mid, and phys.hi numbers from the corresponding "reg" property.
- In the case of configuration space, getting the physical address is easy since phys.lo and phys.mid are always zero. phys.hi is just the configuration space address.
- Table 2-1 is an example of getting the physical address of the configuration space registers, using onboard Ethernet on a Sun Ultra 1 UPA/PCI system:
-
Code Example 2-1 Configuration Space Registers Physical Address
-
ok " /pci@1f,4000/network@1,1" begin-select-dev
ok pwd
/pci@1f,4000/network@1,1
ok .properties
.
.
reg (Config Space ---->) 00000900 00000000 00000000 00000000 00000000
(32bit memory space ---->) 02000910 00000000 00000000 00000000 00007020
.
.
.
ok 0 0 900 100 " map-in" $call-parent constant my-cfg-vaddr
ok my-cfg-vaddr .
fff80900
ok my-cfg-vaddr map?
VA:fff80900
G:0 W:1 P:1 E:1 CV:0 CP:0 L:0 Soft1:1 PA[40:13]:ff00800 PA:1fe01000000
Diag:0 Soft2:0 IE:0 NFO:0 Size:0 V:1
PA:1fe01000900
|
- This results in the physical address for the base of configuration registers as 1fe.0100.0900 for this device. For plug-in PCI devices, the registers' physical address may vary if the device is plugged into a different slot, or if other devices are present. Similarly, use the "reg" entry for memory or I/O space, to find a physical address for those spaces.
Controlling PCI Slot Probing on an Ultra 1 UPA/PCI System
- You can control probing of PCI slots on your Sun Ultra 1 UPA/PCI system as follows: during normal system initialization on the Sun Ultra 1 UPA/PCI system, there are NVRAM variables that indicate to the CPU PROM which slots to probe and in what order.
- On the Sun Ultra 1 UPA/PCI system the slots are: pcia-probe-list and pcib-probe-list. The default value for pcia-probe-list is 1,2; for pcib-probe-list, it is 5,4,3,2. To disable slot 4 probing on pcib during normal initialization after a reset, change pcib-probe-list to:
-
ok setenv pcib-probe-list 5,3,2
|
- To probe slot 4 on pcib manually after a reset, type:
-
ok 4 probe-pci-slot /pci@1f,4000
|
- Note that not all CPU PROMs have the probe-pci-slot command. In future PROMs, this command may not work in the same way or may be eliminated.
Using 3.x Tokenizer and 3.x CPU PROMs
- When using the 3.x Tokenizer while testing FCode under CPU OpenBoot PROM 3.x versions, make sure that you use OpenBoot PROMs version 3.1 or later. You will need the following NVRAM patch for PROMs prior to 3.1
-
Code Example 2-2 NVRAM Patch for PROMS Prior to Version 3.1
-
ok nvedit
0:: nl-move( src dst len -- ) rot n->l rot n->l rot n->l
(move);
1: ['] nl-move is move
2: ['] l>>a 2 la+ dup l@ h# 1000 invert and swap l!
3: ['] lrshift 2 la+ dup l@ h# 1000 invert and swap l!
4: ^C
ok nvstore
ok setenv use-nvramrc? true
ok reset-all
|
- Note that while using the 2.x or 3.x tokenizer, literals or numbers that have bit 31 set to 1 will extend this bit (1) to bit 63 on 3.x CPU PROMs. For example, the following code will give a value of ffff.ffff.8000.000
-
- When such words or constants are used in address manipulation or otherwise, your code should clip them to a 32 bit value:
- Get a real 8000.0000 by:
-
-
ff ff ff ff bljoin constant x-num
: clip-num ( n -- l ) x-num and ;
8000.0000 clip-num constant xxx
- or
- use "xxx clip-num" wherever "xxx" is being used.
|
|