Mac OS 9 Lives

Classic Mac OS Software => Hacking the System, Mac OS 9.3, and Beyond ! => Topic started by: nanopico on May 30, 2016, 10:38:27 AM

Title: Temporarily disabling devices from the device tree in Open Firmware
Post by: nanopico on May 30, 2016, 10:38:27 AM
So sometimes we are running into issues with unsupported hardware not setting up right, but may not really be needed.
Here is a way to temporarily disable the device so Mac OS 9 will not use or even attempt to initialize it. 
From open firmware go to the device you want to disable. (word of caution if there are child devices that are needed they also won't work).

I will use the usb controller on my G3 powerbook as an example
Code: [Select]
dev /pci/usb@10
" reg" delete-property
" interrupts" delete-property
" none" encode-string " compatible" property
device-end

In this case when I boot I will have no usb support.  If I reboot it will all come back.

Explanation:
The reg property give instructions for setting up and registering the device.  Clear it and no instructions.
the interrupts property indicates how many interrupts there are for the device.
The compatible property indicates what drivers the device is compatible with.
By removing and reseting these properties then OS 9 has no clue what to do with the device and pretty much skips over it.
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: nanopico on May 31, 2016, 06:55:47 PM
Just an fyi this does not disable child devices so if you disable something with children, then good luck having any sort of stable boot.
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Daniel on May 16, 2017, 06:08:40 AM
It appears that there is a better way to do this, but It was buried in another thread. I have found it.
Learned something new in my journey today.
I think it was asked how to delete a node from the device tree in open firmware.
I had provided some instruction somewhere on how to sort of disable and it would work for most things, but depending on how the interrupts are set up in hardware I found it can not work well.

If you can delete the node then it clears out those dependent interrupts so things are happy.

so with out further delay's here's how you can delete a node (and it deletes all the children below it as well)

I am not responsible for what you choose to do with this information.

So let's say we want to delete the mac-io node (fyi this will pretty much make your machine do pretty much nothing after this until you restart) located at /pci@f2000000/mac-io

Code: [Select]
" /pci@f2000000/mac-io" find-package drop delete-node

then just change the path to the node you want in the first part.  The space between the first " and the / is important.
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: darthnVader on February 17, 2019, 08:55:51 AM
Daniel, any way to drop the agp/@10?

Seems to give me and invalid memory access when I try:

Code: [Select]
" agp/@10" find-package drop delete-node
I picked up a 1Ghz iMac G4 with a NV18 Geforce4 MX( 0x0189 device ID ), and I've got OS 9 booting on it, but I can't seem to hack together the video drivers. The OS 9 Drivers should support the NV18( 0x0184 Device ID ), but I'm thinking the Fcode ROM must have the basic 'NDRV' nVidia used for all OS 9 compatible cards.

I have the Fcode ROM for the 0x0184, but I can't use it because the Fcode ROM built-in to the BootROM is already active for the device:

Code: [Select]
load hd:,\ppc\4mx.fc
dev agp/@10
800000 1 byte-load
" agp/@10" open-dev to my-self
800000 1 byte-load

the byte-load command returns ok, but nothing gets executed, assuming because of the BootROM Fcode.

So I need to find a way to delete the node, even if it makes the screen go dark and I have to telnet in to execute the Fcode I want to try?
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Daniel on February 17, 2019, 10:30:23 AM
I think I linked the PCI DDK to you at some point. One of the useful tools it has is a tokenizer for FCode.

According to its documentation, fcode images for pci encode the vendor#, device#, and class-code in their headers. If those 3 values are different from the pci device, the fcode won't load.

I suggest changing device-tree properties to make sure those 3 values match up.
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: darthnVader on February 17, 2019, 10:43:55 AM
You have to remove the PCI Header to load the FCode ROM via the load command, so the device ID's won't matter.

OS 9 Runtime Drivers are not fooled by OF changes to the Device ID, they read it direct from the PCI Registers on the PCI card, not the Device Tree.

I need to delete the node holding the Fcode ROM for the built-in GF4MX and load my custom Fcode.

I've done it with unflashed PC Graphics cards, but the FCode in the BootROM for the card is interfering in the process.

Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Daniel on February 17, 2019, 11:07:51 AM
Sorry. I have no clue how to help you here  :(
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Daniel on June 18, 2019, 12:49:10 PM
My work on the sil3124 project has forced me to figure out how to do this.

If you want to load fcode that does anything actually interesting, the device node has to have an open instance as you do it. Normally this would be handled by the system when it loads fcode from roms, but doing it from the user interface takes deep magic.

Code: [Select]
load hd:,\path\to\file
dev /your-device
: open true ; : close ; : init load-base 1 byte-load ;
" /your-device" select-dev
init
0 to my-self

Here is the exact incantation that I have to type every single time I want to test the fcode I am writing:
Code: [Select]
load hd:14,\sil3124.fcode
devalias s71 /pci@f2000000/pci1095,7124
devalias s31 /pci@f2000000/SIL3124
dev s71
: open true ; : close ; : init load-base 1 byte-load ;
" s71" select-dev
init
0 to my-self
" s31" open-dev constant s31-ih
dir s31/sil3124,port0/disk:,\

And then when the test invevitably fails, then I have to manually read and write chip registers to figure out where the show-stopping bug is this time. Low-level development is completely insane.
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: macStuff on June 18, 2019, 07:08:05 PM
daniel;
is there some type of OF emulation that you could run in a virtualized space to be able to cut + paste such stuff?
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Daniel on June 18, 2019, 07:34:32 PM
I suppose I could load it from a file or use telnet.

For some reason I never bother to do it :D
Title: Re: Temporarily disabling devices from the device tree in Open Firmware
Post by: Protools5LEGuy on June 19, 2019, 04:49:31 AM
http://macos9lives.com/smforum/index.php/topic,3827.0.html (http://macos9lives.com/smforum/index.php/topic,3827.0.html)

For Vault users only.