[OpenBIOS] [PATCH] More complete PowerPC OpenFirmware emulation -- adding bus-frequency

Blue Swirl blauwirbel at gmail.com
Wed Aug 10 20:00:47 CEST 2011


On Mon, Aug 8, 2011 at 3:07 PM, Alexander von Gluck
<kallisti5 at 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.



More information about the OpenBIOS mailing list