Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
Index: include/arch/common/fw_cfg.h =================================================================== --- include/arch/common/fw_cfg.h (revision 1046) +++ include/arch/common/fw_cfg.h (working copy) @@ -41,9 +41,10 @@ #define FW_CFG_PPC_DEPTH (FW_CFG_ARCH_LOCAL + 0x02) #define FW_CFG_PPC_TBFREQ (FW_CFG_ARCH_LOCAL + 0x03) #define FW_CFG_PPC_CPUFREQ (FW_CFG_ARCH_LOCAL + 0x04) -#define FW_CFG_PPC_IS_KVM (FW_CFG_ARCH_LOCAL + 0x05) -#define FW_CFG_PPC_KVM_HC (FW_CFG_ARCH_LOCAL + 0x06) -#define FW_CFG_PPC_KVM_PID (FW_CFG_ARCH_LOCAL + 0x07) +#define FW_CFG_PPC_IS_KVM (FW_CFG_ARCH_LOCAL + 0x05) +#define FW_CFG_PPC_KVM_HC (FW_CFG_ARCH_LOCAL + 0x06) +#define FW_CFG_PPC_KVM_PID (FW_CFG_ARCH_LOCAL + 0x07) +#define FW_CFG_PPC_BUSFREQ (FW_CFG_ARCH_LOCAL + 0x08)
#define FW_CFG_INVALID 0xffff
Index: config/scripts/switch-arch =================================================================== --- config/scripts/switch-arch (revision 1046) +++ config/scripts/switch-arch (working copy) @@ -97,7 +97,7 @@
select_prefix() { - for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi- + for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi- ${1}-apple-haiku- do if type ${TARGET}gcc > /dev/null 2>&1 then Index: arch/ppc/qemu/init.c =================================================================== --- arch/ppc/qemu/init.c (revision 1046) +++ arch/ppc/qemu/init.c (working copy) @@ -260,6 +260,11 @@ push_str("clock-frequency"); fword("property");
+ PUSH(fw_cfg_read_i32(FW_CFG_PPC_BUSFREQ)); + fword("encode-int"); + push_str("bus-frequency"); + fword("property"); + push_str("running"); fword("encode-string"); push_str("state"); Index: drivers/iommu.c =================================================================== --- drivers/iommu.c (revision 1046) +++ drivers/iommu.c (working copy) @@ -129,6 +129,7 @@ /* Tremendous alignment causes great waste... */ ptsize = (vasize / PAGE_SIZE) * sizeof(int); ret = ofmem_posix_memalign((void *)&ptab, ptsize, ptsize); + DPRINTF("Allocated IOMMU @ %p\n", (void *)&ptab); if (ret != 0) { DPRINTF("Cannot allocate IOMMU table [0x%x]\n", ptsize); for (;;) { }
On 08/08/11 16:07, Alexander von Gluck wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
This all looks sensible to me, however I'd like to leave this to either Alex or Andreas to do the final commit as they the current PPC maintainers.
BTW as a matter of interest, with this patch does Haiku now boot under QEMU or do you need additional patches for QEMU?
ATB,
Mark.
On Tue, 09 Aug 2011 10:12:20 +0100, Mark Cave-Ayland wrote:
On 08/08/11 16:07, Alexander von Gluck wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
This all looks sensible to me, however I'd like to leave this to either Alex or Andreas to do the final commit as they the current PPC maintainers.
BTW as a matter of interest, with this patch does Haiku now boot under QEMU or do you need additional patches for QEMU?
Nah, Haiku still gets stuck setting up the mmu under qemu (thus that extra trace I added in around OpenBIOS's mmu setup.)
I'll continue to poke at it, but i'm not expecting any huge breakthroughs anytime soon.
Thanks! -- Alex
Am 09.08.2011 um 11:12 schrieb Mark Cave-Ayland:
On 08/08/11 16:07, Alexander von Gluck wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
This all looks sensible to me, however I'd like to leave this to either Alex or Andreas to do the final commit as they the current PPC maintainers.
Am a bit busy ATM and out-of-sync with qemu-devel... The [PATCH] as such is inacceptable to me (should've been [RFC] or a series of [PATCH]es) and is missing an SoB.
The switch-arch part looked okay, and if you and Blue agree, I'd sign off and apply that part - Haiku uses ELF just like Linux.
In fw_cfg.h there appeared to be some unrelated tab-to-whitespace changes and the init.c part surely needs matching QEMU support. Like I said earlier, I think fw_cfg is the wrong way to go long-term for such cosmetic stuff (we'd get a huge influx) but I wouldn't object to it as an interim solution if QEMU / Alex G. feel it's okay. The value is pretty meaningless on QEMU, so we should critically question Haiku's reliance upon it rather than blindly supplying it.
Andreas
On Tue, 9 Aug 2011 22:18:47 +0200, Andreas Färber wrote:
Am 09.08.2011 um 11:12 schrieb Mark Cave-Ayland:
On 08/08/11 16:07, Alexander von Gluck wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
This all looks sensible to me, however I'd like to leave this to either Alex or Andreas to do the final commit as they the current PPC maintainers.
Am a bit busy ATM and out-of-sync with qemu-devel... The [PATCH] as such is inacceptable to me (should've been [RFC] or a series of [PATCH]es) and is missing an SoB.
The switch-arch part looked okay, and if you and Blue agree, I'd sign off and apply that part - Haiku uses ELF just like Linux.
In fw_cfg.h there appeared to be some unrelated tab-to-whitespace changes and the init.c part surely needs matching QEMU support. Like I said earlier, I think fw_cfg is the wrong way to go long-term for such cosmetic stuff (we'd get a huge influx) but I wouldn't object to it as an interim solution if QEMU / Alex G. feel it's okay. The value is pretty meaningless on QEMU, so we should critically question Haiku's reliance upon it rather than blindly supplying it.
The whitespace changes just fix the white spaces of those variables directly above that don't match anything else. feel free to leave them out.
I can see your argument on blindly supporting it, Haiku checks for it and cpu frequency and stops booting if it is missing. I could just change haiku's code to not require it.. but:
* I'd rather have the information then not (even if it is just 0) * the parameter exists on *every* Apple openfirmware implementation (i've verified this on a G3 bronze powerbook, G3 iBook, G4 QuickSilver, G5 iMac) * as the parameter exists on all new-world Apple systems, who knows what other operating systems this breaks compatibility with?
Thanks! -- Alex
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Hi all,
El 09/08/2011, a las 22:13, Alexander von Gluck escribió:
On Tue, 9 Aug 2011 22:18:47 +0200, Andreas Färber wrote:
Am 09.08.2011 um 11:12 schrieb Mark Cave-Ayland:
On 08/08/11 16:07, Alexander von Gluck wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
This all looks sensible to me, however I'd like to leave this to either Alex or Andreas to do the final commit as they the current PPC maintainers.
Am a bit busy ATM and out-of-sync with qemu-devel... The [PATCH] as such is inacceptable to me (should've been [RFC] or a series of [PATCH]es) and is missing an SoB.
The switch-arch part looked okay, and if you and Blue agree, I'd sign off and apply that part - Haiku uses ELF just like Linux.
In fw_cfg.h there appeared to be some unrelated tab-to-whitespace changes and the init.c part surely needs matching QEMU support. Like I said earlier, I think fw_cfg is the wrong way to go long-term for such cosmetic stuff (we'd get a huge influx) but I wouldn't object to it as an interim solution if QEMU / Alex G. feel it's okay. The value is pretty meaningless on QEMU, so we should critically question Haiku's reliance upon it rather than blindly supplying it.
The whitespace changes just fix the white spaces of those variables directly above that don't match anything else. feel free to leave them out.
I can see your argument on blindly supporting it, Haiku checks for it and cpu frequency and stops booting if it is missing. I could just change haiku's code to not require it.. but:
- I'd rather have the information then not (even if it is just 0)
- the parameter exists on *every* Apple openfirmware implementation (i've verified this on a G3 bronze powerbook, G3 iBook, G4 QuickSilver, G5 iMac)
- as the parameter exists on all new-world Apple systems, who knows what other operating systems this breaks compatibility with?
Mac OS X and probably also Mac OS.
Thanks! -- Alex
-- OpenBIOS http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
On 2011-Aug-9 17:13 , Alexander von Gluck wrote:
I can see your argument on blindly supporting it, Haiku checks for it and cpu frequency and stops booting if it is missing. I could just change haiku's code to not require it.. but:
- I'd rather have the information then not (even if it is just 0)
- the parameter exists on *every* Apple openfirmware implementation (i've verified this on a G3 bronze powerbook, G3 iBook, G4
QuickSilver, G5 iMac)
- as the parameter exists on all new-world Apple systems, who knows
what other operating systems this breaks compatibility with?
For what it's worth, Sun systems don't (currently) use a "bus-frequency" property. We do have a "stick-frequency" property, which relates the "stick" register to real-time nanoseconds, but that's specific to the sun4v series of platforms.
On 09/08/11 22:42, Tarl Neustaedter wrote:
For what it's worth, Sun systems don't (currently) use a "bus-frequency" property. We do have a "stick-frequency" property, which relates the "stick" register to real-time nanoseconds, but that's specific to the sun4v series of platforms.
Do sun4m systems actually benchmark the CPU within OBP? From Artyom's blog for example, it appears that OBP attempts to benchmark the CPU since its speed is listed as over 1GHz in QEMU in the Solaris kernel -v output which makes me feel that it does.
I think this may be related to some random hangs I see during CPU detection in SPARC32 which look like they are caused by an interaction between the level 14 timer and the kernel (as changing the values makes this more/less likely). In other words, I think that benchmarking the CPU during startup and writing the estimated frequency into the device tree may fix interesting issues caused by calling get_hrtime() within a tight loop during emulation.
ATB,
Mark.
On 2011-Aug-10 07:13 , Mark Cave-Ayland wrote:
Do sun4m systems actually benchmark the CPU within OBP? From Artyom's blog for example, it appears that OBP attempts to benchmark the CPU since its speed is listed as over 1GHz in QEMU in the Solaris kernel -v output which makes me feel that it does.
Ahh... Some of the FCodes do, as I recall. They needed to calibrate empty do loops so they could get higher-resolution timing waits than 1 millisecond.
On Mon, Aug 8, 2011 at 3:07 PM, Alexander von Gluck kallisti5@unixzen.com wrote:
Below is a quick patch to introduce the bus-frequency field for each CPU.
This exists on every Apple OpenFirmware i've seen and is expected on Haiku OS.
The change to config/scripts/switch-arch isn't required but lets you compile openbios using Haiku's PowerPC cross-compiler.
Also included is a extra tracing line for troubleshooting MMU issues.
Please split, the compiler and IOMMU changes are not related to frequency node issue.
Index: include/arch/common/fw_cfg.h
--- include/arch/common/fw_cfg.h (revision 1046) +++ include/arch/common/fw_cfg.h (working copy) @@ -41,9 +41,10 @@ #define FW_CFG_PPC_DEPTH (FW_CFG_ARCH_LOCAL + 0x02) #define FW_CFG_PPC_TBFREQ (FW_CFG_ARCH_LOCAL + 0x03) #define FW_CFG_PPC_CPUFREQ (FW_CFG_ARCH_LOCAL + 0x04) -#define FW_CFG_PPC_IS_KVM (FW_CFG_ARCH_LOCAL + 0x05) -#define FW_CFG_PPC_KVM_HC (FW_CFG_ARCH_LOCAL + 0x06) -#define FW_CFG_PPC_KVM_PID (FW_CFG_ARCH_LOCAL + 0x07) +#define FW_CFG_PPC_IS_KVM (FW_CFG_ARCH_LOCAL + 0x05) +#define FW_CFG_PPC_KVM_HC (FW_CFG_ARCH_LOCAL + 0x06) +#define FW_CFG_PPC_KVM_PID (FW_CFG_ARCH_LOCAL + 0x07) +#define FW_CFG_PPC_BUSFREQ (FW_CFG_ARCH_LOCAL + 0x08)
#define FW_CFG_INVALID 0xffff
Index: config/scripts/switch-arch
--- config/scripts/switch-arch (revision 1046) +++ config/scripts/switch-arch (working copy) @@ -97,7 +97,7 @@
select_prefix() {
- for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
- for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-
${1}-apple-haiku- do if type ${TARGET}gcc > /dev/null 2>&1 then Index: arch/ppc/qemu/init.c =================================================================== --- arch/ppc/qemu/init.c (revision 1046) +++ arch/ppc/qemu/init.c (working copy) @@ -260,6 +260,11 @@ push_str("clock-frequency"); fword("property");
- PUSH(fw_cfg_read_i32(FW_CFG_PPC_BUSFREQ));
- fword("encode-int");
- push_str("bus-frequency");
- fword("property");
push_str("running"); fword("encode-string"); push_str("state"); Index: drivers/iommu.c =================================================================== --- drivers/iommu.c (revision 1046) +++ drivers/iommu.c (working copy) @@ -129,6 +129,7 @@ /* Tremendous alignment causes great waste... */ ptsize = (vasize / PAGE_SIZE) * sizeof(int); ret = ofmem_posix_memalign((void *)&ptab, ptsize, ptsize);
- DPRINTF("Allocated IOMMU @ %p\n", (void *)&ptab);
if (ret != 0) { DPRINTF("Cannot allocate IOMMU table [0x%x]\n", ptsize); for (;;) { }
This is a driver for I/O MMU on Sparc32 (maybe the file should be renamed to sun4m_iommu.c like in QEMU), so adding debugging here would not affect PPC.