Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Sun, Sep 2, 2012 at 10:45 PM, Alexander Graf  wrote:
>
>
> On 02.09.2012, at 09:50, Li Zhang  wrote:
>
>> On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl  wrote:
>>> On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf  wrote:


 On 26.08.2012, at 10:34, Blue Swirl  wrote:

> On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:
>>
>>
>> On 25.08.2012, at 00:43, Blue Swirl  wrote:
>>
>>> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.

 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.

 USB option of machine options will be set either by:
 * -usb
 * -machine type=pseries,usb=on

 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.

 Signed-off-by: Li Zhang 
 ---
 v7->v8 :
 * Declare usb_enabled() and set_usb_option() in sysemu.h
 * Separate USB enablement on sPAPR platform.

 v8->v9:
 * Fix usb_enable() default value on sPAPR and MAC99

 Signed-off-by: Li Zhang 

 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
 char *boot_device,
   n8x0_dss_setup(s);
   n8x0_cbus_setup(s);
   n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))
>>>
>>> Please add braces.
>>>
>>> I don't like this usb_enabled(false) way very much but I don't have
>>> anything better to suggest.
>>>
   n8x0_usb_setup(s);

   if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
   pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
floppy, idebus[0], idebus[1], rtc_state);

 -if (pci_enabled && usb_enabled) {
 +if (pci_enabled && usb_enabled(false)) {
   pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
   }

 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
   ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
   ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 
 0x1a, pic[0x02]);

 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
   cuda_init(&cuda_mem, pic[0x19]);

   adb_kbd_init(&adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
  dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
   pci_create_simple(pci_bus, -1, "pci-ohci");
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create("keyboard");
 -usbdevice_create("mouse");
 +/* U3 needs to use USB for input because Linux doesn't 
 support via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create("keyboard");
 +usbdevice_create("mouse");
 +}
   }

   if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
  dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);

 -if (usb_enabled) {
 +if (usb_enabled(false)) {
   pci_cr

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Alexander Graf


On 02.09.2012, at 09:50, Li Zhang  wrote:

> On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl  wrote:
>> On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf  wrote:
>>> 
>>> 
>>> On 26.08.2012, at 10:34, Blue Swirl  wrote:
>>> 
 On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:
> 
> 
> On 25.08.2012, at 00:43, Blue Swirl  wrote:
> 
>> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
>>> When -usb option is used, global varible usb_enabled is set.
>>> And all the plafrom will create one USB controller according
>>> to this variable. In fact, global varibles make code hard
>>> to read.
>>> 
>>> So this patch is to remove global variable usb_enabled and
>>> add USB option in machine options. All the plaforms will get
>>> USB option value from machine options.
>>> 
>>> USB option of machine options will be set either by:
>>> * -usb
>>> * -machine type=pseries,usb=on
>>> 
>>> Both these ways can work now. They both set USB option in
>>> machine options. In the future, the first way will be removed.
>>> 
>>> Signed-off-by: Li Zhang 
>>> ---
>>> v7->v8 :
>>> * Declare usb_enabled() and set_usb_option() in sysemu.h
>>> * Separate USB enablement on sPAPR platform.
>>> 
>>> v8->v9:
>>> * Fix usb_enable() default value on sPAPR and MAC99
>>> 
>>> Signed-off-by: Li Zhang 
>>> 
>>> diff --git a/hw/nseries.c b/hw/nseries.c
>>> index 4df2670..c67e95a 100644
>>> --- a/hw/nseries.c
>>> +++ b/hw/nseries.c
>>> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
>>> char *boot_device,
>>>   n8x0_dss_setup(s);
>>>   n8x0_cbus_setup(s);
>>>   n8x0_uart_setup(s);
>>> -if (usb_enabled)
>>> +if (usb_enabled(false))
>> 
>> Please add braces.
>> 
>> I don't like this usb_enabled(false) way very much but I don't have
>> anything better to suggest.
>> 
>>>   n8x0_usb_setup(s);
>>> 
>>>   if (kernel_filename) {
>>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>>> index 0c0096f..b662192 100644
>>> --- a/hw/pc_piix.c
>>> +++ b/hw/pc_piix.c
>>> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>>>   pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>>>floppy, idebus[0], idebus[1], rtc_state);
>>> 
>>> -if (pci_enabled && usb_enabled) {
>>> +if (pci_enabled && usb_enabled(false)) {
>>>   pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>>   }
>>> 
>>> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
>>> index e95cfe8..1d4f494 100644
>>> --- a/hw/ppc_newworld.c
>>> +++ b/hw/ppc_newworld.c
>>> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>>   ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>>>   ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
>>> pic[0x02]);
>>> 
>>> -/* cuda also initialize ADB */
>>> -if (machine_arch == ARCH_MAC99_U3) {
>>> -usb_enabled = 1;
>>> -}
>>>   cuda_init(&cuda_mem, pic[0x19]);
>>> 
>>>   adb_kbd_init(&adb_bus);
>>> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>>   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>>>  dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>>> 
>>> -if (usb_enabled) {
>>> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>>>   pci_create_simple(pci_bus, -1, "pci-ohci");
>>> -}
>>> -
>>> -/* U3 needs to use USB for input because Linux doesn't support 
>>> via-cuda
>>> -   on PPC64 */
>>> -if (machine_arch == ARCH_MAC99_U3) {
>>> -usbdevice_create("keyboard");
>>> -usbdevice_create("mouse");
>>> +/* U3 needs to use USB for input because Linux doesn't support 
>>> via-cuda
>>> +on PPC64 */
>>> +if (machine_arch == ARCH_MAC99_U3) {
>>> +usbdevice_create("keyboard");
>>> +usbdevice_create("mouse");
>>> +}
>>>   }
>>> 
>>>   if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>>> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
>>> index 1dcd8a6..1468a32 100644
>>> --- a/hw/ppc_oldworld.c
>>> +++ b/hw/ppc_oldworld.c
>>> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>>>   macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>>>  dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>>> 
>>> -if (usb_enabled) {
>>> +if (usb_enabled(false)) {
>>>   pci_create_simple(pci_bus, -1, "pci-ohci");
>>>   }
>>> 
>>> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
>>> index 7a87616..feeb903 100644
>>> --- a

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Tue, Aug 28, 2012 at 2:08 AM, Blue Swirl  wrote:
> On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf  wrote:
>>
>>
>> On 26.08.2012, at 10:34, Blue Swirl  wrote:
>>
>>> On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:


 On 25.08.2012, at 00:43, Blue Swirl  wrote:

> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
>> When -usb option is used, global varible usb_enabled is set.
>> And all the plafrom will create one USB controller according
>> to this variable. In fact, global varibles make code hard
>> to read.
>>
>> So this patch is to remove global variable usb_enabled and
>> add USB option in machine options. All the plaforms will get
>> USB option value from machine options.
>>
>> USB option of machine options will be set either by:
>> * -usb
>> * -machine type=pseries,usb=on
>>
>> Both these ways can work now. They both set USB option in
>> machine options. In the future, the first way will be removed.
>>
>> Signed-off-by: Li Zhang 
>> ---
>> v7->v8 :
>> * Declare usb_enabled() and set_usb_option() in sysemu.h
>> * Separate USB enablement on sPAPR platform.
>>
>> v8->v9:
>> * Fix usb_enable() default value on sPAPR and MAC99
>>
>> Signed-off-by: Li Zhang 
>>
>> diff --git a/hw/nseries.c b/hw/nseries.c
>> index 4df2670..c67e95a 100644
>> --- a/hw/nseries.c
>> +++ b/hw/nseries.c
>> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
>> char *boot_device,
>>n8x0_dss_setup(s);
>>n8x0_cbus_setup(s);
>>n8x0_uart_setup(s);
>> -if (usb_enabled)
>> +if (usb_enabled(false))
>
> Please add braces.
>
> I don't like this usb_enabled(false) way very much but I don't have
> anything better to suggest.
>
>>n8x0_usb_setup(s);
>>
>>if (kernel_filename) {
>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>> index 0c0096f..b662192 100644
>> --- a/hw/pc_piix.c
>> +++ b/hw/pc_piix.c
>> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>>pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>> floppy, idebus[0], idebus[1], rtc_state);
>>
>> -if (pci_enabled && usb_enabled) {
>> +if (pci_enabled && usb_enabled(false)) {
>>pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>}
>>
>> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
>> index e95cfe8..1d4f494 100644
>> --- a/hw/ppc_newworld.c
>> +++ b/hw/ppc_newworld.c
>> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>>ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
>> pic[0x02]);
>>
>> -/* cuda also initialize ADB */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usb_enabled = 1;
>> -}
>>cuda_init(&cuda_mem, pic[0x19]);
>>
>>adb_kbd_init(&adb_bus);
>> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>>   dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>>pci_create_simple(pci_bus, -1, "pci-ohci");
>> -}
>> -
>> -/* U3 needs to use USB for input because Linux doesn't support 
>> via-cuda
>> -   on PPC64 */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usbdevice_create("keyboard");
>> -usbdevice_create("mouse");
>> +/* U3 needs to use USB for input because Linux doesn't support 
>> via-cuda
>> +on PPC64 */
>> +if (machine_arch == ARCH_MAC99_U3) {
>> +usbdevice_create("keyboard");
>> +usbdevice_create("mouse");
>> +}
>>}
>>
>>if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
>> index 1dcd8a6..1468a32 100644
>> --- a/hw/ppc_oldworld.c
>> +++ b/hw/ppc_oldworld.c
>> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>>macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>>   dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>>pci_create_simple(pci_bus, -1, "pci-ohci");
>>}
>>
>> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
>> index 7a87616..feeb903 100644
>> --- a/hw/ppc_prep.c
>> +++ b/hw/ppc_prep.c
>> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>>memory_region_add_subregion(sysmem, 0xFEFF, xcs

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-09-02 Thread Li Zhang
On Sat, Aug 25, 2012 at 3:43 PM, Blue Swirl  wrote:
> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
>> When -usb option is used, global varible usb_enabled is set.
>> And all the plafrom will create one USB controller according
>> to this variable. In fact, global varibles make code hard
>> to read.
>>
>> So this patch is to remove global variable usb_enabled and
>> add USB option in machine options. All the plaforms will get
>> USB option value from machine options.
>>
>> USB option of machine options will be set either by:
>>   * -usb
>>   * -machine type=pseries,usb=on
>>
>> Both these ways can work now. They both set USB option in
>> machine options. In the future, the first way will be removed.
>>
>> Signed-off-by: Li Zhang 
>> ---
>>  v7->v8 :
>>   * Declare usb_enabled() and set_usb_option() in sysemu.h
>>   * Separate USB enablement on sPAPR platform.
>>
>>  v8->v9:
>>   * Fix usb_enable() default value on sPAPR and MAC99
>>
>> Signed-off-by: Li Zhang 
>>
>> diff --git a/hw/nseries.c b/hw/nseries.c
>> index 4df2670..c67e95a 100644
>> --- a/hw/nseries.c
>> +++ b/hw/nseries.c
>> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
>> *boot_device,
>>  n8x0_dss_setup(s);
>>  n8x0_cbus_setup(s);
>>  n8x0_uart_setup(s);
>> -if (usb_enabled)
>> +if (usb_enabled(false))
>
> Please add braces.
OK, I will do that.

>
> I don't like this usb_enabled(false) way very much but I don't have
> anything better to suggest.

Thanks,
It seems that default value is false on most of platforms, only true
for several platforms.

>>  n8x0_usb_setup(s);
>>
>>  if (kernel_filename) {
>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>> index 0c0096f..b662192 100644
>> --- a/hw/pc_piix.c
>> +++ b/hw/pc_piix.c
>> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>>  pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>>   floppy, idebus[0], idebus[1], rtc_state);
>>
>> -if (pci_enabled && usb_enabled) {
>> +if (pci_enabled && usb_enabled(false)) {
>>  pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>  }
>>
>> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
>> index e95cfe8..1d4f494 100644
>> --- a/hw/ppc_newworld.c
>> +++ b/hw/ppc_newworld.c
>> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>  ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>>  ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
>> pic[0x02]);
>>
>> -/* cuda also initialize ADB */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usb_enabled = 1;
>> -}
>>  cuda_init(&cuda_mem, pic[0x19]);
>>
>>  adb_kbd_init(&adb_bus);
>> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>> dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>>  pci_create_simple(pci_bus, -1, "pci-ohci");
>> -}
>> -
>> -/* U3 needs to use USB for input because Linux doesn't support via-cuda
>> -   on PPC64 */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usbdevice_create("keyboard");
>> -usbdevice_create("mouse");
>> +/* U3 needs to use USB for input because Linux doesn't support 
>> via-cuda
>> +on PPC64 */
>> +if (machine_arch == ARCH_MAC99_U3) {
>> +usbdevice_create("keyboard");
>> +usbdevice_create("mouse");
>> +}
>>  }
>>
>>  if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
>> index 1dcd8a6..1468a32 100644
>> --- a/hw/ppc_oldworld.c
>> +++ b/hw/ppc_oldworld.c
>> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>>  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>> dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>>  pci_create_simple(pci_bus, -1, "pci-ohci");
>>  }
>>
>> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
>> index 7a87616..feeb903 100644
>> --- a/hw/ppc_prep.c
>> +++ b/hw/ppc_prep.c
>> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>>  memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
>>  #endif
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>>  pci_create_simple(pci_bus, -1, "pci-ohci");
>>  }
>>
>> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
>> index d5f1420..4787279 100644
>> --- a/hw/pxa2xx.c
>> +++ b/hw/pxa2xx.c
>> @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>>  s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>>  }
>>
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>>  sysbus_create_simple("sysbus-ohci", 0x4c00,
>> 

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-08-27 Thread Blue Swirl
On Mon, Aug 27, 2012 at 1:59 AM, Alexander Graf  wrote:
>
>
> On 26.08.2012, at 10:34, Blue Swirl  wrote:
>
>> On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:
>>>
>>>
>>> On 25.08.2012, at 00:43, Blue Swirl  wrote:
>>>
 On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
> When -usb option is used, global varible usb_enabled is set.
> And all the plafrom will create one USB controller according
> to this variable. In fact, global varibles make code hard
> to read.
>
> So this patch is to remove global variable usb_enabled and
> add USB option in machine options. All the plaforms will get
> USB option value from machine options.
>
> USB option of machine options will be set either by:
> * -usb
> * -machine type=pseries,usb=on
>
> Both these ways can work now. They both set USB option in
> machine options. In the future, the first way will be removed.
>
> Signed-off-by: Li Zhang 
> ---
> v7->v8 :
> * Declare usb_enabled() and set_usb_option() in sysemu.h
> * Separate USB enablement on sPAPR platform.
>
> v8->v9:
> * Fix usb_enable() default value on sPAPR and MAC99
>
> Signed-off-by: Li Zhang 
>
> diff --git a/hw/nseries.c b/hw/nseries.c
> index 4df2670..c67e95a 100644
> --- a/hw/nseries.c
> +++ b/hw/nseries.c
> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
> char *boot_device,
>n8x0_dss_setup(s);
>n8x0_cbus_setup(s);
>n8x0_uart_setup(s);
> -if (usb_enabled)
> +if (usb_enabled(false))

 Please add braces.

 I don't like this usb_enabled(false) way very much but I don't have
 anything better to suggest.

>n8x0_usb_setup(s);
>
>if (kernel_filename) {
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index 0c0096f..b662192 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
> floppy, idebus[0], idebus[1], rtc_state);
>
> -if (pci_enabled && usb_enabled) {
> +if (pci_enabled && usb_enabled(false)) {
>pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>}
>
> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
> index e95cfe8..1d4f494 100644
> --- a/hw/ppc_newworld.c
> +++ b/hw/ppc_newworld.c
> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
> pic[0x02]);
>
> -/* cuda also initialize ADB */
> -if (machine_arch == ARCH_MAC99_U3) {
> -usb_enabled = 1;
> -}
>cuda_init(&cuda_mem, pic[0x19]);
>
>adb_kbd_init(&adb_bus);
> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>   dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>
> -if (usb_enabled) {
> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>pci_create_simple(pci_bus, -1, "pci-ohci");
> -}
> -
> -/* U3 needs to use USB for input because Linux doesn't support 
> via-cuda
> -   on PPC64 */
> -if (machine_arch == ARCH_MAC99_U3) {
> -usbdevice_create("keyboard");
> -usbdevice_create("mouse");
> +/* U3 needs to use USB for input because Linux doesn't support 
> via-cuda
> +on PPC64 */
> +if (machine_arch == ARCH_MAC99_U3) {
> +usbdevice_create("keyboard");
> +usbdevice_create("mouse");
> +}
>}
>
>if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
> index 1dcd8a6..1468a32 100644
> --- a/hw/ppc_oldworld.c
> +++ b/hw/ppc_oldworld.c
> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>   dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>
> -if (usb_enabled) {
> +if (usb_enabled(false)) {
>pci_create_simple(pci_bus, -1, "pci-ohci");
>}
>
> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
> index 7a87616..feeb903 100644
> --- a/hw/ppc_prep.c
> +++ b/hw/ppc_prep.c
> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
> #endif
>
> -if (usb_enabled) {
> +if (usb_enabled(false)) {
>pci_create_simple(pci_bus, -1, "pci-ohci");
>}
>
> diff --git a/h

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-08-26 Thread Alexander Graf


On 26.08.2012, at 10:34, Blue Swirl  wrote:

> On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:
>> 
>> 
>> On 25.08.2012, at 00:43, Blue Swirl  wrote:
>> 
>>> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
 When -usb option is used, global varible usb_enabled is set.
 And all the plafrom will create one USB controller according
 to this variable. In fact, global varibles make code hard
 to read.
 
 So this patch is to remove global variable usb_enabled and
 add USB option in machine options. All the plaforms will get
 USB option value from machine options.
 
 USB option of machine options will be set either by:
 * -usb
 * -machine type=pseries,usb=on
 
 Both these ways can work now. They both set USB option in
 machine options. In the future, the first way will be removed.
 
 Signed-off-by: Li Zhang 
 ---
 v7->v8 :
 * Declare usb_enabled() and set_usb_option() in sysemu.h
 * Separate USB enablement on sPAPR platform.
 
 v8->v9:
 * Fix usb_enable() default value on sPAPR and MAC99
 
 Signed-off-by: Li Zhang 
 
 diff --git a/hw/nseries.c b/hw/nseries.c
 index 4df2670..c67e95a 100644
 --- a/hw/nseries.c
 +++ b/hw/nseries.c
 @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const 
 char *boot_device,
n8x0_dss_setup(s);
n8x0_cbus_setup(s);
n8x0_uart_setup(s);
 -if (usb_enabled)
 +if (usb_enabled(false))
>>> 
>>> Please add braces.
>>> 
>>> I don't like this usb_enabled(false) way very much but I don't have
>>> anything better to suggest.
>>> 
n8x0_usb_setup(s);
 
if (kernel_filename) {
 diff --git a/hw/pc_piix.c b/hw/pc_piix.c
 index 0c0096f..b662192 100644
 --- a/hw/pc_piix.c
 +++ b/hw/pc_piix.c
 @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
 floppy, idebus[0], idebus[1], rtc_state);
 
 -if (pci_enabled && usb_enabled) {
 +if (pci_enabled && usb_enabled(false)) {
pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
}
 
 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
 index e95cfe8..1d4f494 100644
 --- a/hw/ppc_newworld.c
 +++ b/hw/ppc_newworld.c
 @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
 pic[0x02]);
 
 -/* cuda also initialize ADB */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usb_enabled = 1;
 -}
cuda_init(&cuda_mem, pic[0x19]);
 
adb_kbd_init(&adb_bus);
 @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
   dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
 
 -if (usb_enabled) {
 +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
 -}
 -
 -/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 -   on PPC64 */
 -if (machine_arch == ARCH_MAC99_U3) {
 -usbdevice_create("keyboard");
 -usbdevice_create("mouse");
 +/* U3 needs to use USB for input because Linux doesn't support 
 via-cuda
 +on PPC64 */
 +if (machine_arch == ARCH_MAC99_U3) {
 +usbdevice_create("keyboard");
 +usbdevice_create("mouse");
 +}
}
 
if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
 index 1dcd8a6..1468a32 100644
 --- a/hw/ppc_oldworld.c
 +++ b/hw/ppc_oldworld.c
 @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
   dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
 
 -if (usb_enabled) {
 +if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
 
 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
 index 7a87616..feeb903 100644
 --- a/hw/ppc_prep.c
 +++ b/hw/ppc_prep.c
 @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif
 
 -if (usb_enabled) {
 +if (usb_enabled(false)) {
pci_create_simple(pci_bus, -1, "pci-ohci");
}
 
 diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
 index d5f1420..4787279 100644
 --- a/hw/pxa2xx.c
 +++ b/hw/pxa2xx.c
 @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion 

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-08-26 Thread Blue Swirl
On Sat, Aug 25, 2012 at 2:27 PM, Alexander Graf  wrote:
>
>
> On 25.08.2012, at 00:43, Blue Swirl  wrote:
>
>> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
>>> When -usb option is used, global varible usb_enabled is set.
>>> And all the plafrom will create one USB controller according
>>> to this variable. In fact, global varibles make code hard
>>> to read.
>>>
>>> So this patch is to remove global variable usb_enabled and
>>> add USB option in machine options. All the plaforms will get
>>> USB option value from machine options.
>>>
>>> USB option of machine options will be set either by:
>>>  * -usb
>>>  * -machine type=pseries,usb=on
>>>
>>> Both these ways can work now. They both set USB option in
>>> machine options. In the future, the first way will be removed.
>>>
>>> Signed-off-by: Li Zhang 
>>> ---
>>> v7->v8 :
>>>  * Declare usb_enabled() and set_usb_option() in sysemu.h
>>>  * Separate USB enablement on sPAPR platform.
>>>
>>> v8->v9:
>>>  * Fix usb_enable() default value on sPAPR and MAC99
>>>
>>> Signed-off-by: Li Zhang 
>>>
>>> diff --git a/hw/nseries.c b/hw/nseries.c
>>> index 4df2670..c67e95a 100644
>>> --- a/hw/nseries.c
>>> +++ b/hw/nseries.c
>>> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
>>> *boot_device,
>>> n8x0_dss_setup(s);
>>> n8x0_cbus_setup(s);
>>> n8x0_uart_setup(s);
>>> -if (usb_enabled)
>>> +if (usb_enabled(false))
>>
>> Please add braces.
>>
>> I don't like this usb_enabled(false) way very much but I don't have
>> anything better to suggest.
>>
>>> n8x0_usb_setup(s);
>>>
>>> if (kernel_filename) {
>>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>>> index 0c0096f..b662192 100644
>>> --- a/hw/pc_piix.c
>>> +++ b/hw/pc_piix.c
>>> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>>> pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>>>  floppy, idebus[0], idebus[1], rtc_state);
>>>
>>> -if (pci_enabled && usb_enabled) {
>>> +if (pci_enabled && usb_enabled(false)) {
>>> pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>>> }
>>>
>>> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
>>> index e95cfe8..1d4f494 100644
>>> --- a/hw/ppc_newworld.c
>>> +++ b/hw/ppc_newworld.c
>>> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>> ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>>> ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
>>> pic[0x02]);
>>>
>>> -/* cuda also initialize ADB */
>>> -if (machine_arch == ARCH_MAC99_U3) {
>>> -usb_enabled = 1;
>>> -}
>>> cuda_init(&cuda_mem, pic[0x19]);
>>>
>>> adb_kbd_init(&adb_bus);
>>> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>>> macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>>>dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>>>
>>> -if (usb_enabled) {
>>> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>>> pci_create_simple(pci_bus, -1, "pci-ohci");
>>> -}
>>> -
>>> -/* U3 needs to use USB for input because Linux doesn't support via-cuda
>>> -   on PPC64 */
>>> -if (machine_arch == ARCH_MAC99_U3) {
>>> -usbdevice_create("keyboard");
>>> -usbdevice_create("mouse");
>>> +/* U3 needs to use USB for input because Linux doesn't support 
>>> via-cuda
>>> +on PPC64 */
>>> +if (machine_arch == ARCH_MAC99_U3) {
>>> +usbdevice_create("keyboard");
>>> +usbdevice_create("mouse");
>>> +}
>>> }
>>>
>>> if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>>> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
>>> index 1dcd8a6..1468a32 100644
>>> --- a/hw/ppc_oldworld.c
>>> +++ b/hw/ppc_oldworld.c
>>> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>>> macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>>>dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>>>
>>> -if (usb_enabled) {
>>> +if (usb_enabled(false)) {
>>> pci_create_simple(pci_bus, -1, "pci-ohci");
>>> }
>>>
>>> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
>>> index 7a87616..feeb903 100644
>>> --- a/hw/ppc_prep.c
>>> +++ b/hw/ppc_prep.c
>>> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>>> memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
>>> #endif
>>>
>>> -if (usb_enabled) {
>>> +if (usb_enabled(false)) {
>>> pci_create_simple(pci_bus, -1, "pci-ohci");
>>> }
>>>
>>> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
>>> index d5f1420..4787279 100644
>>> --- a/hw/pxa2xx.c
>>> +++ b/hw/pxa2xx.c
>>> @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>>> s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>>> }
>>>
>>> -if (usb_enabled) {
>>> +if (usb_enabled(false)) {
>>> sysbus_create_

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-08-25 Thread Alexander Graf


On 25.08.2012, at 00:43, Blue Swirl  wrote:

> On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
>> When -usb option is used, global varible usb_enabled is set.
>> And all the plafrom will create one USB controller according
>> to this variable. In fact, global varibles make code hard
>> to read.
>> 
>> So this patch is to remove global variable usb_enabled and
>> add USB option in machine options. All the plaforms will get
>> USB option value from machine options.
>> 
>> USB option of machine options will be set either by:
>>  * -usb
>>  * -machine type=pseries,usb=on
>> 
>> Both these ways can work now. They both set USB option in
>> machine options. In the future, the first way will be removed.
>> 
>> Signed-off-by: Li Zhang 
>> ---
>> v7->v8 :
>>  * Declare usb_enabled() and set_usb_option() in sysemu.h
>>  * Separate USB enablement on sPAPR platform.
>> 
>> v8->v9:
>>  * Fix usb_enable() default value on sPAPR and MAC99
>> 
>> Signed-off-by: Li Zhang 
>> 
>> diff --git a/hw/nseries.c b/hw/nseries.c
>> index 4df2670..c67e95a 100644
>> --- a/hw/nseries.c
>> +++ b/hw/nseries.c
>> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
>> *boot_device,
>> n8x0_dss_setup(s);
>> n8x0_cbus_setup(s);
>> n8x0_uart_setup(s);
>> -if (usb_enabled)
>> +if (usb_enabled(false))
> 
> Please add braces.
> 
> I don't like this usb_enabled(false) way very much but I don't have
> anything better to suggest.
> 
>> n8x0_usb_setup(s);
>> 
>> if (kernel_filename) {
>> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
>> index 0c0096f..b662192 100644
>> --- a/hw/pc_piix.c
>> +++ b/hw/pc_piix.c
>> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>> pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>>  floppy, idebus[0], idebus[1], rtc_state);
>> 
>> -if (pci_enabled && usb_enabled) {
>> +if (pci_enabled && usb_enabled(false)) {
>> pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>> }
>> 
>> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
>> index e95cfe8..1d4f494 100644
>> --- a/hw/ppc_newworld.c
>> +++ b/hw/ppc_newworld.c
>> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>> ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>> ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
>> pic[0x02]);
>> 
>> -/* cuda also initialize ADB */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usb_enabled = 1;
>> -}
>> cuda_init(&cuda_mem, pic[0x19]);
>> 
>> adb_kbd_init(&adb_bus);
>> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>> macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
>>dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>> 
>> -if (usb_enabled) {
>> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>> pci_create_simple(pci_bus, -1, "pci-ohci");
>> -}
>> -
>> -/* U3 needs to use USB for input because Linux doesn't support via-cuda
>> -   on PPC64 */
>> -if (machine_arch == ARCH_MAC99_U3) {
>> -usbdevice_create("keyboard");
>> -usbdevice_create("mouse");
>> +/* U3 needs to use USB for input because Linux doesn't support 
>> via-cuda
>> +on PPC64 */
>> +if (machine_arch == ARCH_MAC99_U3) {
>> +usbdevice_create("keyboard");
>> +usbdevice_create("mouse");
>> +}
>> }
>> 
>> if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
>> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
>> index 1dcd8a6..1468a32 100644
>> --- a/hw/ppc_oldworld.c
>> +++ b/hw/ppc_oldworld.c
>> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>> macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
>>dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>> 
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>> pci_create_simple(pci_bus, -1, "pci-ohci");
>> }
>> 
>> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
>> index 7a87616..feeb903 100644
>> --- a/hw/ppc_prep.c
>> +++ b/hw/ppc_prep.c
>> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>> memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
>> #endif
>> 
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>> pci_create_simple(pci_bus, -1, "pci-ohci");
>> }
>> 
>> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
>> index d5f1420..4787279 100644
>> --- a/hw/pxa2xx.c
>> +++ b/hw/pxa2xx.c
>> @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>> s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>> }
>> 
>> -if (usb_enabled) {
>> +if (usb_enabled(false)) {
>> sysbus_create_simple("sysbus-ohci", 0x4c00,
>> qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
>> }
>> @@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion

Re: [Qemu-devel] [Qemu-ppc] [PATCH v9 1/1] Add USB option in machine options

2012-08-25 Thread Blue Swirl
On Wed, Aug 22, 2012 at 10:31 AM, Li Zhang  wrote:
> When -usb option is used, global varible usb_enabled is set.
> And all the plafrom will create one USB controller according
> to this variable. In fact, global varibles make code hard
> to read.
>
> So this patch is to remove global variable usb_enabled and
> add USB option in machine options. All the plaforms will get
> USB option value from machine options.
>
> USB option of machine options will be set either by:
>   * -usb
>   * -machine type=pseries,usb=on
>
> Both these ways can work now. They both set USB option in
> machine options. In the future, the first way will be removed.
>
> Signed-off-by: Li Zhang 
> ---
>  v7->v8 :
>   * Declare usb_enabled() and set_usb_option() in sysemu.h
>   * Separate USB enablement on sPAPR platform.
>
>  v8->v9:
>   * Fix usb_enable() default value on sPAPR and MAC99
>
> Signed-off-by: Li Zhang 
>
> diff --git a/hw/nseries.c b/hw/nseries.c
> index 4df2670..c67e95a 100644
> --- a/hw/nseries.c
> +++ b/hw/nseries.c
> @@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
> *boot_device,
>  n8x0_dss_setup(s);
>  n8x0_cbus_setup(s);
>  n8x0_uart_setup(s);
> -if (usb_enabled)
> +if (usb_enabled(false))

Please add braces.

I don't like this usb_enabled(false) way very much but I don't have
anything better to suggest.

>  n8x0_usb_setup(s);
>
>  if (kernel_filename) {
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index 0c0096f..b662192 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
>  pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
>   floppy, idebus[0], idebus[1], rtc_state);
>
> -if (pci_enabled && usb_enabled) {
> +if (pci_enabled && usb_enabled(false)) {
>  pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
>  }
>
> diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
> index e95cfe8..1d4f494 100644
> --- a/hw/ppc_newworld.c
> +++ b/hw/ppc_newworld.c
> @@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
>  ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
>  ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
> pic[0x02]);
>
> -/* cuda also initialize ADB */
> -if (machine_arch == ARCH_MAC99_U3) {
> -usb_enabled = 1;
> -}
>  cuda_init(&cuda_mem, pic[0x19]);
>
>  adb_kbd_init(&adb_bus);
> @@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
>  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
> dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
>
> -if (usb_enabled) {
> +if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
>  pci_create_simple(pci_bus, -1, "pci-ohci");
> -}
> -
> -/* U3 needs to use USB for input because Linux doesn't support via-cuda
> -   on PPC64 */
> -if (machine_arch == ARCH_MAC99_U3) {
> -usbdevice_create("keyboard");
> -usbdevice_create("mouse");
> +/* U3 needs to use USB for input because Linux doesn't support 
> via-cuda
> +on PPC64 */
> +if (machine_arch == ARCH_MAC99_U3) {
> +usbdevice_create("keyboard");
> +usbdevice_create("mouse");
> +}
>  }
>
>  if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
> diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
> index 1dcd8a6..1468a32 100644
> --- a/hw/ppc_oldworld.c
> +++ b/hw/ppc_oldworld.c
> @@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
>  macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
> dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
>
> -if (usb_enabled) {
> +if (usb_enabled(false)) {
>  pci_create_simple(pci_bus, -1, "pci-ohci");
>  }
>
> diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
> index 7a87616..feeb903 100644
> --- a/hw/ppc_prep.c
> +++ b/hw/ppc_prep.c
> @@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
>  memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
>  #endif
>
> -if (usb_enabled) {
> +if (usb_enabled(false)) {
>  pci_create_simple(pci_bus, -1, "pci-ohci");
>  }
>
> diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
> index d5f1420..4787279 100644
> --- a/hw/pxa2xx.c
> +++ b/hw/pxa2xx.c
> @@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>  s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>  }
>
> -if (usb_enabled) {
> +if (usb_enabled(false)) {
>  sysbus_create_simple("sysbus-ohci", 0x4c00,
>  qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
>  }
> @@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, 
> unsigned int sdram_size)
>  s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
>  }
>
> -if (usb_enabled) {
> +if (usb_enabled(false)

[Qemu-devel] [Qemu-ppc][PATCH v9 1/1] Add USB option in machine options

2012-08-22 Thread Li Zhang
When -usb option is used, global varible usb_enabled is set.
And all the plafrom will create one USB controller according
to this variable. In fact, global varibles make code hard
to read.

So this patch is to remove global variable usb_enabled and
add USB option in machine options. All the plaforms will get
USB option value from machine options.

USB option of machine options will be set either by:
  * -usb
  * -machine type=pseries,usb=on

Both these ways can work now. They both set USB option in
machine options. In the future, the first way will be removed.

Signed-off-by: Li Zhang 
---
 v7->v8 :
  * Declare usb_enabled() and set_usb_option() in sysemu.h
  * Separate USB enablement on sPAPR platform.

 v8->v9:
  * Fix usb_enable() default value on sPAPR and MAC99

Signed-off-by: Li Zhang 

diff --git a/hw/nseries.c b/hw/nseries.c
index 4df2670..c67e95a 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1322,7 +1322,7 @@ static void n8x0_init(ram_addr_t ram_size, const char 
*boot_device,
 n8x0_dss_setup(s);
 n8x0_cbus_setup(s);
 n8x0_uart_setup(s);
-if (usb_enabled)
+if (usb_enabled(false))
 n8x0_usb_setup(s);
 
 if (kernel_filename) {
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 0c0096f..b662192 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -267,7 +267,7 @@ static void pc_init1(MemoryRegion *system_memory,
 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
  floppy, idebus[0], idebus[1], rtc_state);
 
-if (pci_enabled && usb_enabled) {
+if (pci_enabled && usb_enabled(false)) {
 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
 }
 
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index e95cfe8..1d4f494 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -348,10 +348,6 @@ static void ppc_core99_init (ram_addr_t ram_size,
 ide_mem[1] = pmac_ide_init(hd, pic[0x0d], dbdma, 0x16, pic[0x02]);
 ide_mem[2] = pmac_ide_init(&hd[MAX_IDE_DEVS], pic[0x0e], dbdma, 0x1a, 
pic[0x02]);
 
-/* cuda also initialize ADB */
-if (machine_arch == ARCH_MAC99_U3) {
-usb_enabled = 1;
-}
 cuda_init(&cuda_mem, pic[0x19]);
 
 adb_kbd_init(&adb_bus);
@@ -360,15 +356,14 @@ static void ppc_core99_init (ram_addr_t ram_size,
 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem,
dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar);
 
-if (usb_enabled) {
+if (usb_enabled(machine_arch == ARCH_MAC99_U3)) {
 pci_create_simple(pci_bus, -1, "pci-ohci");
-}
-
-/* U3 needs to use USB for input because Linux doesn't support via-cuda
-   on PPC64 */
-if (machine_arch == ARCH_MAC99_U3) {
-usbdevice_create("keyboard");
-usbdevice_create("mouse");
+/* U3 needs to use USB for input because Linux doesn't support via-cuda
+on PPC64 */
+if (machine_arch == ARCH_MAC99_U3) {
+usbdevice_create("keyboard");
+usbdevice_create("mouse");
+}
 }
 
 if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 1dcd8a6..1468a32 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -286,7 +286,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
 macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem,
dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar);
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 pci_create_simple(pci_bus, -1, "pci-ohci");
 }
 
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 7a87616..feeb903 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -662,7 +662,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
 memory_region_add_subregion(sysmem, 0xFEFF, xcsr);
 #endif
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 pci_create_simple(pci_bus, -1, "pci-ohci");
 }
 
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index d5f1420..4787279 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
 s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
 }
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 sysbus_create_simple("sysbus-ohci", 0x4c00,
 qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
 }
@@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, 
unsigned int sdram_size)
 s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
 }
 
-if (usb_enabled) {
+if (usb_enabled(false)) {
 sysbus_create_simple("sysbus-ohci", 0x4c00,
 qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
 }
diff --git a/hw/realview.c b/hw/realview.c
index 19db4d0..a8d6f97 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -227,7 +227,7 @@ static void realview_init(ram_addr_t ram_size,
 sysbus_connect_irq(busdev, 2, pic[50]);
 sysbus_connect_irq(busdev, 3, pic[51]);