diff options
Diffstat (limited to 'roms/openbios/forth/util')
| -rw-r--r-- | roms/openbios/forth/util/apic.fs | 62 | ||||
| -rw-r--r-- | roms/openbios/forth/util/build.xml | 19 | ||||
| -rw-r--r-- | roms/openbios/forth/util/pci.fs | 92 | ||||
| -rw-r--r-- | roms/openbios/forth/util/util.fs | 95 | 
4 files changed, 268 insertions, 0 deletions
diff --git a/roms/openbios/forth/util/apic.fs b/roms/openbios/forth/util/apic.fs new file mode 100644 index 00000000..82a62aa7 --- /dev/null +++ b/roms/openbios/forth/util/apic.fs @@ -0,0 +1,62 @@ +\  +\ ioapic and local apic tester +\  +\ Copyright (C) 2003 Stefan Reinauer +\  +\ See the file "COPYING" for further information about +\ the copyright and warranty status of this work. +\  + +hex + +fee00000 constant lapic_base +fec00000 constant ioapic_base + +: read_lapic ( regoffset -- value ) +  lapic_base + l@ +  ; + +: write_lapic ( value regoffset -- ) +  lapic_base + l! +  ; + +: read_ioapic ( regoffset -- low_value high_value ) +  2* 10 + dup  +  ioapic_base l! ioapic_base 4 cells + l@ +  swap 1+  +  ioapic_base l! ioapic_base 4 cells + l@ +  ; + +: write_ioapic ( low high regoffset -- ) +  2* 10 + dup 					( low high offs offs )  +  ioapic_base l! rot ioapic_base 4 cells + l!	( high offs ) +  1+ +  ioapic_base l! ioapic_base 4 cells + l!	( high offs ) +  ; + +: test-lapic  +  s" Dumping local apic:" type cr +  3f0 0 do +    i dup ( lapic_base + ) s" 0x" type . s" = 0x" type read_lapic space .  +    i 30 and 0= if cr then +  10 +loop +  cr +  ; + +: test-ioapic +  s" Dumping io apic:" type cr +  17 0 do  +    i dup s" irq=" type . read_ioapic s" = 0x" type . s" ." type .  +    i 1 and 0<> if  +      cr +    then +  loop +  cr +  ; + +: dump-apics +  test-lapic +  test-ioapic +  ; + +\ tag: apic test utility diff --git a/roms/openbios/forth/util/build.xml b/roms/openbios/forth/util/build.xml new file mode 100644 index 00000000..4839d2cd --- /dev/null +++ b/roms/openbios/forth/util/build.xml @@ -0,0 +1,19 @@ +<build> + + <!-- +  build description for OpenBIOS utility functions +   +  Copyright (C) 2004-2005 by Stefan Reinauer +  See the file "COPYING" for further information about +  the copyright and warranty status of this work. +  --> + + <dictionary name="openbios" target="forth"> +  <object source="util.fs"/> +  <object source="pci.fs"/> +  <!-- We don't want/need these at the moment +  <object source="apic.fs"/> +  --> + </dictionary> + +</build> diff --git a/roms/openbios/forth/util/pci.fs b/roms/openbios/forth/util/pci.fs new file mode 100644 index 00000000..57ded626 --- /dev/null +++ b/roms/openbios/forth/util/pci.fs @@ -0,0 +1,92 @@ +\ tag: PCI helper functions +\  +\ Copyright (C) 2003-2004 Stefan Reinauer +\ Copyright (C) 2003 Samuel Rydh +\  +\ See the file "COPYING" for further information about +\ the copyright and warranty status of this work. +\  + +\ simple set of words for pci access, these are not  +\ compliant to the PCI bus binding of OpenFirmware. + +\ only forth +\ vocabulary pci  +\ also pci definitions + +hex + +: busdevfn ( bus dev fn -- busdevfn ) +  7 and swap  +  1f and 3 << or       ( dev fn -- devfn ) +  swap 8 << or            ( bus devfn -- busdevfn ) +  ; + +: config-command ( busdevfn reg -- reg addr ) +  dup -rot +  3 invert and  +  swap 8 << or  +  80000000 or +  ; + +: pci-c@ ( busdevfn reg -- x ) +  config-command +  cf8 iol! +  3 and cfc +  +  ioc@ +  ; + +: pci-w@ ( busdevfn reg -- x ) +  config-command +  cf8 iol! +  2 and cfc + iow@ +  ; + +: pci-l@ ( busdevfn reg -- x ) +  config-command +  cf8 iol!  +  drop +  cfc iol@ +  ; + +: pci-c! ( busdevfn reg val -- ) +  -rot config-command  +  cf8 iol!  +  3 and cfc + ioc! +  ; +   +: pci-w! ( busdevfn reg val -- ) +  -rot config-command  +  cf8 iol!  +  2 and cfc + iow! +  ; +   +: pci-l! ( busdevfn reg val -- ) +  -rot config-command  +  cf8 iol!  +  drop +  cfc iol! +  ; +  +: dump-pci-device ( bus dev fn -- ) +  2 pick (.) type 3a emit over  +  (.) type 2e emit dup (.) type 20 emit 5b emit  \ 0:18.0 [ +  busdevfn >r +  r@ 0 pci-w@ u. 2f emit r@ 2 pci-w@ u. 5d emit 	 \ 1022/1100] +  r> +  \ now we iterate +  10 0 do +    cr i todigit emit 30 emit 3a emit 20 emit +    10 0 do +      dup i j 4 << or  pci-c@  +      dup 4 >> todigit emit f and todigit emit +      20 emit +    loop +  loop +  drop +  cr cr +  ; +   +\ : test-pci +\   0  2 0 dump-pci-device +\   ; diff --git a/roms/openbios/forth/util/util.fs b/roms/openbios/forth/util/util.fs new file mode 100644 index 00000000..6f549bf5 --- /dev/null +++ b/roms/openbios/forth/util/util.fs @@ -0,0 +1,95 @@ +\ tag: Utility functions +\  +\ Utility functions +\  +\ Copyright (C) 2003, 2004 Samuel Rydh +\  +\ See the file "COPYING" for further information about +\ the copyright and warranty status of this work. +\  + +\ ------------------------------------------------------------------------- +\ package utils +\ ------------------------------------------------------------------------- + +( method-str method-len package-str package-len -- xt|0 ) +: $find-package-method +  find-package 0= if 2drop false exit then +  find-method 0= if 0 then +; + +\ like $call-parent but takes an xt +: call-parent ( ... xt -- ??? ) +  my-parent call-package +; + +: [active-package], +	['] (lit) , active-package , +; immediate + +\ ------------------------------------------------------------------------- +\ word creation +\ ------------------------------------------------------------------------- + +: ?mmissing ( name len -- 1 name len | 0 ) +  2dup active-package find-method +  if 3drop false else true then +; + +\ install trivial open and close functions +: is-open ( -- ) +  " open" ?mmissing if ['] true -rot is-xt-func then +  " close" ?mmissing if 0 -rot is-xt-func then +; + +\ is-relay installs a relay function (a function that calls +\ a function with the same name but belonging to a different node). +\ The execution behaviour of xt should be ( -- ptr-to-ihandle ). +\  +: is-relay ( xt ph name-str name-len -- ) +  rot >r 2dup r> find-method 0= if +    \ function missing (not necessarily an error) +    3drop exit +  then + +  -rot is-func-begin +  ( xt method-xt ) +  ['] (lit) , ,                 \ ['] method +  , ['] @ ,                     \ xt @ +  ['] call-package ,            \ call-package +  is-func-end +; + +\ ------------------------------------------------------------------------- +\ install deblocker bindings +\ ------------------------------------------------------------------------- + +: (open-deblocker) ( varaddr -- ) +  " deblocker" find-package if +    0 0 rot open-package +  else 0 then +  swap ! +; +   +: is-deblocker ( -- ) +  " deblocker" find-package 0= if exit then >r +  " deblocker" is-ivariable + +  \ create open-deblocker +  " open-deblocker" is-func-begin +  dup , ['] (open-deblocker) , +  is-func-end + +  \ create close-deblocker +  " close-deblocker" is-func-begin +  dup , ['] @ , ['] close-package , +  is-func-end +   +  ( save-ph deblk-xt R: deblocker-ph  ) +  r> +  2dup " read" is-relay +  2dup " seek" is-relay +  2dup " write" is-relay +  2dup " tell" is-relay +  2drop +;  | 
