symbian-qemu-0.9.1-12/qemu-symbian-svp/pc-bios/bios-pq/0005_hpet.patch
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 BOCHS BIOS changes to support HPET in QEMU.
       
     2 
       
     3 Signed-off-by Beth Kon <eak@us.ibm.com>
       
     4 
       
     5 Index: bochs-2.3.7/bios/acpi-dsdt.dsl
       
     6 ===================================================================
       
     7 --- bochs-2.3.7.orig/bios/acpi-dsdt.dsl	2008-10-15 12:39:14.000000000 -0500
       
     8 +++ bochs-2.3.7/bios/acpi-dsdt.dsl	2008-10-28 07:58:40.000000000 -0500
       
     9 @@ -159,6 +159,26 @@
       
    10                  Return (MEMP)
       
    11              }
       
    12          }
       
    13 +#ifdef BX_QEMU
       
    14 +        Device(HPET) {
       
    15 +            Name(_HID,  EISAID("PNP0103"))
       
    16 +            Name(_UID, 0)
       
    17 +            Method (_STA, 0, NotSerialized) {
       
    18 +                    Return(0x0F)
       
    19 +            }
       
    20 +            Name(_CRS, ResourceTemplate() {
       
    21 +                DWordMemory(
       
    22 +                    ResourceConsumer, PosDecode, MinFixed, MaxFixed,
       
    23 +                    NonCacheable, ReadWrite,
       
    24 +                    0x00000000,
       
    25 +                    0xFED00000,
       
    26 +                    0xFED003FF,
       
    27 +                    0x00000000,
       
    28 +                    0x00000400 /* 1K memory: FED00000 - FED003FF */
       
    29 +                )
       
    30 +            })
       
    31 +        }
       
    32 +#endif
       
    33      }
       
    34  
       
    35      Scope(\_SB.PCI0) {
       
    36 Index: bochs-2.3.7/bios/rombios32.c
       
    37 ===================================================================
       
    38 --- bochs-2.3.7.orig/bios/rombios32.c	2008-10-15 12:39:36.000000000 -0500
       
    39 +++ bochs-2.3.7/bios/rombios32.c	2008-11-12 14:41:41.000000000 -0600
       
    40 @@ -1087,7 +1087,11 @@
       
    41  struct rsdt_descriptor_rev1
       
    42  {
       
    43  	ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
       
    44 +#ifdef BX_QEMU
       
    45 +	uint32_t                             table_offset_entry [4]; /* Array of pointers to other */
       
    46 +#else
       
    47  	uint32_t                             table_offset_entry [3]; /* Array of pointers to other */
       
    48 +#endif
       
    49  			 /* ACPI tables */
       
    50  };
       
    51  
       
    52 @@ -1227,6 +1231,32 @@
       
    53  #endif
       
    54  };
       
    55  
       
    56 +#ifdef BX_QEMU
       
    57 +/*
       
    58 + *  * ACPI 2.0 Generic Address Space definition.
       
    59 + *   */
       
    60 +struct acpi_20_generic_address {
       
    61 +    uint8_t  address_space_id;
       
    62 +    uint8_t  register_bit_width;
       
    63 +    uint8_t  register_bit_offset;
       
    64 +    uint8_t  reserved;
       
    65 +    uint64_t address;
       
    66 +};
       
    67 +
       
    68 +/*
       
    69 + *  * HPET Description Table
       
    70 + *   */
       
    71 +struct acpi_20_hpet {
       
    72 +    ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
       
    73 +    uint32_t           timer_block_id;
       
    74 +    struct acpi_20_generic_address addr;
       
    75 +    uint8_t            hpet_number;
       
    76 +    uint16_t           min_tick;
       
    77 +    uint8_t            page_protect;
       
    78 +};
       
    79 +#define ACPI_HPET_ADDRESS 0xFED00000UL
       
    80 +#endif
       
    81 +
       
    82  struct madt_io_apic
       
    83  {
       
    84  	APIC_HEADER_DEF
       
    85 @@ -1237,6 +1267,17 @@
       
    86  			  * lines start */
       
    87  };
       
    88  
       
    89 +#ifdef BX_QEMU
       
    90 +struct madt_int_override
       
    91 +{
       
    92 +	APIC_HEADER_DEF
       
    93 +	uint8_t                bus;     /* Identifies ISA Bus */
       
    94 +	uint8_t                source;  /* Bus-relative interrupt source */
       
    95 +	uint32_t               gsi;     /* GSI that source will signal */
       
    96 +	uint16_t               flags;   /* MPS INTI flags */
       
    97 +};
       
    98 +#endif
       
    99 +
       
   100  #include "acpi-dsdt.hex"
       
   101  
       
   102  static inline uint16_t cpu_to_le16(uint16_t x)
       
   103 @@ -1342,6 +1383,10 @@
       
   104      struct facs_descriptor_rev1 *facs;
       
   105      struct multiple_apic_table *madt;
       
   106      uint8_t *dsdt, *ssdt;
       
   107 +#ifdef BX_QEMU
       
   108 +    struct acpi_20_hpet *hpet;
       
   109 +    uint32_t hpet_addr;
       
   110 +#endif
       
   111      uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, ssdt_addr;
       
   112      uint32_t acpi_tables_size, madt_addr, madt_size;
       
   113      int i;
       
   114 @@ -1384,10 +1429,21 @@
       
   115      madt_addr = addr;
       
   116      madt_size = sizeof(*madt) +
       
   117          sizeof(struct madt_processor_apic) * smp_cpus +
       
   118 +#ifdef BX_QEMU
       
   119 +        sizeof(struct madt_io_apic) + sizeof(struct madt_int_override);
       
   120 +#else
       
   121          sizeof(struct madt_io_apic);
       
   122 +#endif
       
   123      madt = (void *)(addr);
       
   124      addr += madt_size;
       
   125  
       
   126 +#ifdef BX_QEMU
       
   127 +    addr = (addr + 7) & ~7;
       
   128 +    hpet_addr = addr;
       
   129 +    hpet = (void *)(addr);
       
   130 +    addr += sizeof(*hpet);
       
   131 +#endif
       
   132 +
       
   133      acpi_tables_size = addr - base_addr;
       
   134  
       
   135      BX_INFO("ACPI tables: RSDP addr=0x%08lx ACPI DATA addr=0x%08lx size=0x%x\n",
       
   136 @@ -1410,6 +1466,9 @@
       
   137      rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
       
   138      rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
       
   139      rsdt->table_offset_entry[2] = cpu_to_le32(ssdt_addr);
       
   140 +#ifdef BX_QEMU
       
   141 +    rsdt->table_offset_entry[3] = cpu_to_le32(hpet_addr);
       
   142 +#endif
       
   143      acpi_build_table_header((struct acpi_table_header *)rsdt,
       
   144                              "RSDT", sizeof(*rsdt), 1);
       
   145  
       
   146 @@ -1448,6 +1507,9 @@
       
   147      {
       
   148          struct madt_processor_apic *apic;
       
   149          struct madt_io_apic *io_apic;
       
   150 +#ifdef BX_QEMU
       
   151 +        struct madt_int_override *int_override;
       
   152 +#endif
       
   153  
       
   154          memset(madt, 0, madt_size);
       
   155          madt->local_apic_address = cpu_to_le32(0xfee00000);
       
   156 @@ -1467,10 +1529,34 @@
       
   157          io_apic->io_apic_id = smp_cpus;
       
   158          io_apic->address = cpu_to_le32(0xfec00000);
       
   159          io_apic->interrupt = cpu_to_le32(0);
       
   160 +#ifdef BX_QEMU
       
   161 +        io_apic++;
       
   162 +
       
   163 +        int_override = (void *)io_apic;
       
   164 +        int_override->type = APIC_XRUPT_OVERRIDE;
       
   165 +        int_override->length = sizeof(*int_override);
       
   166 +        int_override->bus = cpu_to_le32(0);
       
   167 +        int_override->source = cpu_to_le32(0);
       
   168 +        int_override->gsi = cpu_to_le32(2);
       
   169 +        int_override->flags = cpu_to_le32(0);
       
   170 +#endif
       
   171  
       
   172          acpi_build_table_header((struct acpi_table_header *)madt,
       
   173                                  "APIC", madt_size, 1);
       
   174      }
       
   175 +
       
   176 +#ifdef BX_QEMU
       
   177 +    /* HPET */
       
   178 +    memset(hpet, 0, sizeof(*hpet));
       
   179 +    /* Note timer_block_id value must be kept in sync with value advertised by
       
   180 +     * emulated hpet
       
   181 +     */
       
   182 +    hpet->timer_block_id = cpu_to_le32(0x8086a201);
       
   183 +    hpet->addr.address = cpu_to_le32(ACPI_HPET_ADDRESS);
       
   184 +    acpi_build_table_header((struct  acpi_table_header *)hpet,
       
   185 +                             "HPET", sizeof(*hpet), 1);
       
   186 +#endif
       
   187 +
       
   188  }
       
   189  
       
   190  /* SMBIOS entry point -- must be written to a 16-bit aligned address