Can’t apply this patch to the main branch or Mark’s v2 branch, and I can’t be much help if we are not working from the same codebase.
On Jul 23, 2019, at 7:25 PM, BALATON Zoltan balaton@eik.bme.hu wrote:
I've finally ended up with the patch below that now can run the FCode ROM although I'm not sure if it's correct or whatever else it breaks or fixes. It could likely be enhanced e.g. to add other config access words and maybe cleaned up by someone who knows more about this than me. It may also allow to clean up other places (like vga.fs) to get rid of some hacks but I'll let you (other people on the list, not necessarily Mark alone) finish that, an acknowledgement like including my Signed-off-by is still expected but I probably don't want to spend more time with it to make it a propert patch at the moment but may come back to it later so comments are still welcome. This is good enough for me now to test the FCode ROM. It can talk to the card now and finish without exception but it cannot get EDID info (although it does poke the appropriate reg for that) and probably gets some unexpected results that may derail it. It does install the NDRV and adds some properties to device node though. The rest needs more debugging but I've run out of time for now. This is what I've got after FCode's run:
0 > .properties name "ATY,Rage128Pd" vendor-id 1002 device-id 5046 revision-id 0 class-code 30000 min-grant 0 max-latency 0 devsel-speed 0 subsystem-vendor-id 1af4 subsystem-id 1100 cache-line-size 0 device_type "display" model "ATY,Rage128Pro" compatible "VGA" assigned-addresses 42007810 00000000 81000000 00000000 01000000 01007814 00000000 00001000 00000000 00000100 02007818 00000000 82000000 00000000 00004000 reg 00007800 00000000 00000000 00000000 00000000 02007830 00000000 00000000 00000000 00020000 42007810 00000000 00000000 00000000 04000000 02007818 00000000 00000000 00000000 00004000 width 280 height 1e0 depth 8 linebytes 300 driver,AAPL,MacOS,PowerPC -- 14ae0 : 4a 6f 79 21 70 65 66 66 70 77 70 63 ... a lot more bytes here, maybe this should be changed to cut this at some sane amount rather than flooding output address 81000000 ATY,Status 0 ATY,Flags 73f0000 ATY,RefCLK 733c ATY,MCLK 222e0 ATY,SCLK 1ccf0 display-type "NONE" character-set "ISO8859-1" AGP_Address_Range -- 8 : 00 00 00 00 ff ff ff ff AGP_Address_Block 2000000 AGP_Alignment 2000000 AGP_AllowOverlap 1 ATY,Rom# "113-72701-136" ATY,Card# "109-72700-00" ATY,Fcode "1.78" ok
although the mode it's set is probably wrong or we can't handle that:
ati_vga_switch_mode: Switching to 640x480 768 8 @ 8000 qemu-system-ppc: VGA offset is not multiple of pitch, expect bad picture
8bpp 640 pixels per line with 768 pitch (bytes per line)? Starting with an offset? Strange, other drivers usually don't do this. Also display-type is not detected, probably because of EDID missing. I'll check these later when I'll have time, that may fix mode as well. I haven't tried if it does anything to MacOS or OSX yet. So here's the patch (surpisingly small, so Forth is at least really concise even if virtually unintelligible; oh and I managed to do it with avoiding reading the standard doc so far :-) thanks for all help in this):
Signed-off-by: BALATON Zoltan balaton@eik.bme.hu
diff --git a/drivers/pci.c b/drivers/pci.c index 4bc02c9..88b9aa0 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -408,20 +408,33 @@ static void ob_pci_unmap(ucell virt, ucell size) { static void ob_pci_bus_map_in(int *idx) {
- uint32_t ba;
- ucell size;
- ucell virt;
- PCI_DPRINTF("ob_pci_bar_map_in idx=%p\n", idx);
- PCI_DPRINTF("ob_pci_bar_map_in idx=%p\n", idx);
- fword("pci-map-in");
+}
- size = POP();
- POP();
- POP();
- ba = POP();
+static void +ob_pci_bus_map_out(int *idx) +{
- /* Should call pci-map-out but nothing to do in it yet */
- fword("2drop");
+}
- virt = ob_pci_map(ba, size);
+static void +ob_pci_config_read8(int *idx) +{
- cell hi = POP();
- pci_addr addr = PCI_ADDR(PCI_BUS(hi), PCI_DEV(hi), PCI_FN(hi));
- uint8_t val = pci_config_read8(addr, hi & 0xff);
- PUSH(val);
+}
- PUSH(virt);
+static void +ob_pci_config_write8(int *idx) +{
- cell hi = POP();
- pci_addr addr = PCI_ADDR(PCI_BUS(hi), PCI_DEV(hi), PCI_FN(hi));
- cell val = POP();
- pci_config_write8(addr, hi & 0xff, val & 0xff);
}
static void @@ -459,7 +472,10 @@ NODE_METHODS(ob_pci_bus_node) = { { "close", ob_pci_close }, { "decode-unit", ob_pci_decode_unit }, { "encode-unit", ob_pci_encode_unit },
- { "pci-map-in", ob_pci_bus_map_in },
- { "map-in", ob_pci_bus_map_in },
- { "map-out", ob_pci_bus_map_out },
- { "config-b@", ob_pci_config_read8 },
- { "config-b!", ob_pci_config_write8 }, { "dma-alloc", ob_pci_dma_alloc }, { "dma-free", ob_pci_dma_free }, { "dma-map-in", ob_pci_dma_map_in },
@@ -473,7 +489,14 @@ static void ob_pci_bridge_map_in(int *idx) { /* As per the IEEE-1275 PCI specification, chain up to the parent */
- call_parent_method("pci-map-in");
- call_parent_method("map-in");
+}
+static void +ob_pci_bridge_map_out(int *idx) +{
- /* As per the IEEE-1275 PCI specification, chain up to the parent */
- call_parent_method("map-out");
}
NODE_METHODS(ob_pci_bridge_node) = { @@ -481,7 +504,8 @@ NODE_METHODS(ob_pci_bridge_node) = { { "close", ob_pci_close }, { "decode-unit", ob_pci_decode_unit }, { "encode-unit", ob_pci_encode_unit },
- { "pci-map-in", ob_pci_bridge_map_in },
- { "map-in", ob_pci_bridge_map_in },
- { "map-out", ob_pci_bridge_map_out }, { "dma-alloc", ob_pci_dma_alloc }, { "dma-free", ob_pci_dma_free }, { "dma-map-in", ob_pci_dma_map_in },
diff --git a/drivers/pci.fs b/drivers/pci.fs index a7b56e1..327c9c9 100644 --- a/drivers/pci.fs +++ b/drivers/pci.fs @@ -37,4 +37,45 @@ then ;
+: pci-map-in ( addr.lo addr.mid addr.hi size -- virt )
- \ Ignore everything but addr.hi and find assigned addr for BAR
- drop nip nip
- \ Save my-self and set it to same as active package because otherwise
- \ decode-phys below seems to be confused. Maybe this should not be needed
- my-self swap active-package ihandle>phandle to my-self
- " assigned-addresses" active-package get-package-property 0= if
- begin
decode-phys ( bar prop prop-len phys.lo phys.mid phys.hi )
dup 0fffffff and 6 pick 0fffffff and = if
2drop -rot
decode-int drop decode-int drop 2drop
( bar addr.lo )
\ Now translate addr.lo, This may be wrong
\ maybe we should look at parent's ranges instead?
over 18 rshift 3 and 1 = if
" reg" active-package parent get-package-property 0= if
( bar addr.lo prop prop-len reg.addr reg.size )
decode-int -rot decode-int 3drop
+
then
then
nip swap to my-self
exit
else
3drop \ no match, try next
then
\ Drop the size as we don't need it
decode-int drop decode-int drop
dup 0=
- until
- 3drop
- to my-self
- -1 \ not found
- else
- drop
- to my-self
- -1 \ could not find assigned-addresses
- then
- ;
[THEN] diff --git a/drivers/vga.fs b/drivers/vga.fs index 53dcff0..f3ffda7 100644 --- a/drivers/vga.fs +++ b/drivers/vga.fs @@ -146,14 +146,14 @@ defer vbe-iow!
: map-fb ( -- ) cfg-bar0 pci-bar>pci-addr if \ ( pci-addr.lo pci-addr.mid pci-addr.hi size )
- " pci-map-in" $call-parent
- " map-in" $call-parent to fb-addr then
;
: map-mmio ( -- ) cfg-bar2 pci-bar>pci-addr if \ ( pci-addr.lo pci-addr.mid pci-addr.hi size )
- " pci-map-in" $call-parent
- " map-in" $call-parent to mmio-addr then
; diff --git a/forth/device/other.fs b/forth/device/other.fs index 1bed9b8..0ff34b6 100644 --- a/forth/device/other.fs +++ b/forth/device/other.fs @@ -58,21 +58,27 @@ defer (poke) \ 5.3.7.2 Device-register access
: rb@ ( addr -- byte )
- ioc@ ;
: rw@ ( waddr -- w )
- iow@ ;
: rl@ ( qaddr -- quad )
- iol@ ;
: rb! ( byte addr -- )
- ioc! ;
: rw! ( w waddr -- )
- iow! ;
: rl! ( quad qaddr -- )
- iol! ;
: rx@ ( oaddr - o ) _______________________________________________ OpenBIOS mailing list -- openbios@openbios.org To unsubscribe send an email to openbios-leave@openbios.org