Set up PCI nodes on board-qemu
Populate the PCI device tree nodes with additional properties and words, and provide enough of the SLOF PCI framework to be able to use the nodes with our device specific drivers. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
This commit is contained in:
parent
c3ef350a8a
commit
c691959389
|
@ -15,8 +15,8 @@
|
|||
s" io-apic" 2dup device-name device-type
|
||||
my-space pci-class-name type s" ( 8131 IO-APIC )" type
|
||||
|
||||
enable-io-access
|
||||
enable-mem-access
|
||||
pci-io-enable
|
||||
pci-mem-enable
|
||||
pci-master-enable
|
||||
|
||||
my-space b rshift \ Get slot #.
|
||||
|
|
|
@ -48,6 +48,7 @@ FCODE_FFS_FILES = \
|
|||
|
||||
|
||||
USB_FFS_FILES = \
|
||||
$(SLOFCMNDIR)/fs/devices/pci-class_02.fs \
|
||||
$(SLOFCMNDIR)/fs/devices/pci-class_0c.fs \
|
||||
$(SLOFCMNDIR)/fs/usb/usb-ohci.fs \
|
||||
$(SLOFCMNDIR)/fs/usb/usb-support.fs \
|
||||
|
|
|
@ -117,6 +117,15 @@ d# 512000000 VALUE tb-frequency \ default value - needed for "ms" to work
|
|||
|
||||
370 cp
|
||||
|
||||
\ Grab rtas from qemu
|
||||
#include "rtas.fs"
|
||||
|
||||
380 cp
|
||||
|
||||
#include "pci-setup.fs"
|
||||
|
||||
3f0 cp
|
||||
|
||||
#include "tree.fs"
|
||||
|
||||
800 cp
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
\ *****************************************************************************
|
||||
\ * Copyright (c) 2004, 2011 IBM Corporation
|
||||
\ * All rights reserved.
|
||||
\ * This program and the accompanying materials
|
||||
\ * are made available under the terms of the BSD License
|
||||
\ * which accompanies this distribution, and is available at
|
||||
\ * http://www.opensource.org/licenses/bsd-license.php
|
||||
\ *
|
||||
\ * Contributors:
|
||||
\ * IBM Corporation - initial implementation
|
||||
\ ****************************************************************************/
|
||||
|
||||
\ Starting alias number for net devices after the onboard devices.
|
||||
0 VALUE pci-net-num
|
||||
\ Starting alias number for disks after the onboard devices.
|
||||
0 VALUE pci-disk-num
|
||||
\ Starting alias number for cdroms after the onboard devices.
|
||||
0 VALUE pci-cdrom-num
|
||||
|
||||
\ define a new alias for this device
|
||||
: pci-set-alias ( str-addr str-len num -- )
|
||||
$cathex strdup \ create alias name
|
||||
get-node node>path \ get path string
|
||||
set-alias \ and set the alias
|
||||
;
|
||||
|
||||
\ define a new net alias
|
||||
: unknown-enet ( -- pci-net-num )
|
||||
pci-net-num dup 1+ TO pci-net-num
|
||||
;
|
||||
: pci-alias-net ( config-addr -- )
|
||||
drop \ forget the config address
|
||||
pci-net-num dup 1+ TO pci-net-num \ increase the pci-net-num
|
||||
s" net" rot pci-set-alias \ create the alias
|
||||
;
|
||||
|
||||
\ define a new disk alias
|
||||
: pci-alias-disk ( config-addr -- )
|
||||
drop \ forget the config address
|
||||
pci-disk-num dup 1+ TO pci-disk-num \ increase the pci-disk-num
|
||||
s" disk" rot pci-set-alias \ create the alias
|
||||
;
|
||||
\ define a new cdrom alias
|
||||
: pci-alias-cdrom ( config-addr -- )
|
||||
drop \ forget the config address
|
||||
pci-cdrom-num dup 1+ TO pci-cdrom-num \ increase the pci-cdrom-num
|
||||
s" cdrom" rot pci-set-alias \ create the alias
|
||||
;
|
||||
|
||||
\ define the alias for the calling device
|
||||
: pci-alias ( config-addr -- )
|
||||
dup pci-class@
|
||||
10 rshift CASE
|
||||
01 OF pci-alias-disk ENDOF
|
||||
02 OF pci-alias-net ENDOF
|
||||
dup OF drop ENDOF
|
||||
ENDCASE
|
||||
;
|
|
@ -55,3 +55,37 @@ setup-puid
|
|||
|
||||
: open true ;
|
||||
: close ;
|
||||
|
||||
|
||||
\ Scan the child nodes of the pci root node to assign bars, fixup
|
||||
\ properties etc.
|
||||
: setup-children
|
||||
my-self >r \ Save old value of my-self
|
||||
puid >r \ Save old value of puid
|
||||
my-puid TO puid \ Set current puid
|
||||
get-node child
|
||||
BEGIN
|
||||
dup \ Continue as long as there are children
|
||||
WHILE
|
||||
\ ." Working on " dup node>path type cr
|
||||
\ Open child node:
|
||||
dup set-node
|
||||
dup 0 0 rot open-node ?dup 0<> IF
|
||||
( child-phandle child-ihandle )
|
||||
dup to my-self
|
||||
dup ihandle>phandle node>instance-size @ \ Remember instance size
|
||||
\ Include the PCI device functions:
|
||||
s" pci-device.fs" included
|
||||
\ Clean up the temporary instance. Note that we can not use close-node
|
||||
\ or destroy-instance here since node>instance-size might have changed.
|
||||
( child-phandle child-ihandle instance-size )
|
||||
free-mem
|
||||
THEN ( child-phandle )
|
||||
peer
|
||||
REPEAT
|
||||
drop
|
||||
r> TO puid \ Restore previous puid
|
||||
r> to my-self \ Restore previous my-self
|
||||
;
|
||||
|
||||
setup-children
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
\ *****************************************************************************
|
||||
\ * Copyright (c) 2004, 2011 IBM Corporation
|
||||
\ * All rights reserved.
|
||||
\ * This program and the accompanying materials
|
||||
\ * are made available under the terms of the BSD License
|
||||
\ * which accompanies this distribution, and is available at
|
||||
\ * http://www.opensource.org/licenses/bsd-license.php
|
||||
\ *
|
||||
\ * Contributors:
|
||||
\ * IBM Corporation - initial implementation
|
||||
\ ****************************************************************************/
|
||||
\ * PCI setup functions
|
||||
\ *****************************************************************************
|
||||
|
||||
3a0 cp
|
||||
|
||||
#include "pci-helper.fs"
|
||||
|
||||
3b0 cp
|
||||
|
||||
\ provide the device-alias definition words
|
||||
#include "pci-aliases.fs"
|
||||
|
||||
3c0 cp
|
||||
|
||||
#include "pci-class-code-names.fs"
|
||||
|
||||
3d0 cp
|
||||
|
||||
\ Provide a generic setup function ... note that we
|
||||
\ do not assign BARs here, it's done by QEMU already.
|
||||
: pci-device-generic-setup ( config-addr -- )
|
||||
pci-class-name 2dup device-name device-type
|
||||
;
|
|
@ -108,6 +108,9 @@ find-qemu-rtas
|
|||
enter-rtas
|
||||
;
|
||||
|
||||
|
||||
0 value puid
|
||||
|
||||
: rtas-do-config-@ ( config-addr size -- value)
|
||||
\ We really want to cache this !
|
||||
" ibm,read-pci-config" rtas-get-token rtas-cb rtas>token l!
|
||||
|
|
|
@ -15,12 +15,6 @@
|
|||
|
||||
400 cp
|
||||
|
||||
0 value puid
|
||||
|
||||
440 cp
|
||||
|
||||
480 cp
|
||||
|
||||
\ The root of the device tree and some of its kids.
|
||||
" /" find-device
|
||||
|
||||
|
@ -32,6 +26,8 @@
|
|||
\ Yaboot is stupid. Without this, it can't/won't find /etc/yaboot.conf.
|
||||
s" chrp" device-type
|
||||
|
||||
480 cp
|
||||
|
||||
\ See 3.6.5, and the PowerPC OF binding document.
|
||||
new-device
|
||||
s" mmu" 2dup device-name device-type
|
||||
|
@ -57,11 +53,6 @@ device-end
|
|||
;
|
||||
fixup-tbfreq
|
||||
|
||||
4d0 cp
|
||||
|
||||
\ Grab rtas from qemu
|
||||
#include "rtas.fs"
|
||||
|
||||
500 cp
|
||||
|
||||
: populate-vios ( -- )
|
||||
|
|
|
@ -14,8 +14,8 @@ my-space pci-class-name type
|
|||
|
||||
my-space pci-device-generic-setup
|
||||
|
||||
enable-io-access
|
||||
enable-mem-access
|
||||
pci-io-enable
|
||||
pci-mem-enable
|
||||
|
||||
30 config-l@ pci-find-fcode execute-rom-fcode
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
\ ****************************************************************************/
|
||||
|
||||
\ get the PUID from the node above
|
||||
s" my-puid" $call-parent CONSTANT my-puid
|
||||
s" my-puid" get-node parent $call-static CONSTANT my-puid
|
||||
|
||||
\ define the config reads
|
||||
: config-b@ puid >r my-puid TO puid my-space + rtas-config-b@ r> TO puid ;
|
||||
|
|
Loading…
Reference in New Issue