diff mbox series

[02/20] nubus-device: expose separate super slot memory region

Message ID 20210912074914.22048-3-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show
Series nubus: bus, device, bridge, IRQ and address space improvements | expand

Commit Message

Mark Cave-Ayland Sept. 12, 2021, 7:48 a.m. UTC
According to "Designing Cards and Drivers for the Macintosh Family" each physical
nubus slot can access 2 separate address ranges: a super slot memory region which
is 256MB and a standard slot memory region which is 16MB.

Currently a Nubus device uses the physical slot number to determine whether it is
using a standard slot memory region or a super slot memory region rather than
exposing both memory regions for use as required.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/nubus/nubus-device.c  | 36 ++++++++++++++++++------------------
 include/hw/nubus/nubus.h |  1 +
 2 files changed, 19 insertions(+), 18 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 12, 2021, 3:50 p.m. UTC | #1
On 9/12/21 9:48 AM, Mark Cave-Ayland wrote:
> According to "Designing Cards and Drivers for the Macintosh Family" each physical
> nubus slot can access 2 separate address ranges: a super slot memory region which
> is 256MB and a standard slot memory region which is 16MB.
> 
> Currently a Nubus device uses the physical slot number to determine whether it is
> using a standard slot memory region or a super slot memory region rather than
> exposing both memory regions for use as required.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/nubus/nubus-device.c  | 36 ++++++++++++++++++------------------
>  include/hw/nubus/nubus.h |  1 +
>  2 files changed, 19 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
> index be01269563..36203848e5 100644
> --- a/hw/nubus/nubus-device.c
> +++ b/hw/nubus/nubus-device.c
> @@ -168,26 +168,26 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
>      }
>  
>      nd->slot = nubus->current_slot++;
> -    name = g_strdup_printf("nubus-slot-%d", nd->slot);
> -
> -    if (nd->slot < NUBUS_FIRST_SLOT) {
> -        /* Super */
> -        slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
> -
> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name,
> -                           NUBUS_SUPER_SLOT_SIZE);
> -        memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
> -                                    &nd->slot_mem);
> -    } else {
> -        /* Normal */
> -        slot_offset = nd->slot * NUBUS_SLOT_SIZE;
> -
> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name, NUBUS_SLOT_SIZE);
> -        memory_region_add_subregion(&nubus->slot_io, slot_offset,
> -                                    &nd->slot_mem);
> -    }
>  
> +    /* Super */
> +    slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
> +
> +    name = g_strdup_printf("nubus-super-slot-%x", nd->slot);
> +    memory_region_init(&nd->super_slot_mem, OBJECT(dev), name,
> +                        NUBUS_SUPER_SLOT_SIZE);
> +    memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
> +                                &nd->super_slot_mem);
> +    g_free(name);
> +
> +    /* Normal */
> +    slot_offset = nd->slot * NUBUS_SLOT_SIZE;
> +
> +    name = g_strdup_printf("nubus-slot-%x", nd->slot);

I'd rather use "nubus-standard-slot-%x" or "nubus-normal-slot-%x"
to differentiate from super-bus. (This also applies to variable
names and trace events in this series).

Anyway,
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Mark Cave-Ayland Sept. 12, 2021, 5:20 p.m. UTC | #2
On 12/09/2021 16:50, Philippe Mathieu-Daudé wrote:

> On 9/12/21 9:48 AM, Mark Cave-Ayland wrote:
>> According to "Designing Cards and Drivers for the Macintosh Family" each physical
>> nubus slot can access 2 separate address ranges: a super slot memory region which
>> is 256MB and a standard slot memory region which is 16MB.
>>
>> Currently a Nubus device uses the physical slot number to determine whether it is
>> using a standard slot memory region or a super slot memory region rather than
>> exposing both memory regions for use as required.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>> ---
>>   hw/nubus/nubus-device.c  | 36 ++++++++++++++++++------------------
>>   include/hw/nubus/nubus.h |  1 +
>>   2 files changed, 19 insertions(+), 18 deletions(-)
>>
>> diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
>> index be01269563..36203848e5 100644
>> --- a/hw/nubus/nubus-device.c
>> +++ b/hw/nubus/nubus-device.c
>> @@ -168,26 +168,26 @@ static void nubus_device_realize(DeviceState *dev, Error **errp)
>>       }
>>   
>>       nd->slot = nubus->current_slot++;
>> -    name = g_strdup_printf("nubus-slot-%d", nd->slot);
>> -
>> -    if (nd->slot < NUBUS_FIRST_SLOT) {
>> -        /* Super */
>> -        slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
>> -
>> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name,
>> -                           NUBUS_SUPER_SLOT_SIZE);
>> -        memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
>> -                                    &nd->slot_mem);
>> -    } else {
>> -        /* Normal */
>> -        slot_offset = nd->slot * NUBUS_SLOT_SIZE;
>> -
>> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name, NUBUS_SLOT_SIZE);
>> -        memory_region_add_subregion(&nubus->slot_io, slot_offset,
>> -                                    &nd->slot_mem);
>> -    }
>>   
>> +    /* Super */
>> +    slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
>> +
>> +    name = g_strdup_printf("nubus-super-slot-%x", nd->slot);
>> +    memory_region_init(&nd->super_slot_mem, OBJECT(dev), name,
>> +                        NUBUS_SUPER_SLOT_SIZE);
>> +    memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
>> +                                &nd->super_slot_mem);
>> +    g_free(name);
>> +
>> +    /* Normal */
>> +    slot_offset = nd->slot * NUBUS_SLOT_SIZE;
>> +
>> +    name = g_strdup_printf("nubus-slot-%x", nd->slot);
> 
> I'd rather use "nubus-standard-slot-%x" or "nubus-normal-slot-%x"
> to differentiate from super-bus. (This also applies to variable
> names and trace events in this series).

I can see how this may seem ambiguous, however in "Designing Cards and Drivers for 
the Macintosh Family" the documentation always refers to "slot" as a standard slot so 
there shouldn't be any confusion for developers here.

> Anyway,
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


ATB,

Mark.
Philippe Mathieu-Daudé Sept. 12, 2021, 5:31 p.m. UTC | #3
On 9/12/21 7:20 PM, Mark Cave-Ayland wrote:
> On 12/09/2021 16:50, Philippe Mathieu-Daudé wrote:
> 
>> On 9/12/21 9:48 AM, Mark Cave-Ayland wrote:
>>> According to "Designing Cards and Drivers for the Macintosh Family"
>>> each physical
>>> nubus slot can access 2 separate address ranges: a super slot memory
>>> region which
>>> is 256MB and a standard slot memory region which is 16MB.
>>>
>>> Currently a Nubus device uses the physical slot number to determine
>>> whether it is
>>> using a standard slot memory region or a super slot memory region
>>> rather than
>>> exposing both memory regions for use as required.
>>>
>>> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>>> ---
>>>   hw/nubus/nubus-device.c  | 36 ++++++++++++++++++------------------
>>>   include/hw/nubus/nubus.h |  1 +
>>>   2 files changed, 19 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
>>> index be01269563..36203848e5 100644
>>> --- a/hw/nubus/nubus-device.c
>>> +++ b/hw/nubus/nubus-device.c
>>> @@ -168,26 +168,26 @@ static void nubus_device_realize(DeviceState
>>> *dev, Error **errp)
>>>       }
>>>         nd->slot = nubus->current_slot++;
>>> -    name = g_strdup_printf("nubus-slot-%d", nd->slot);
>>> -
>>> -    if (nd->slot < NUBUS_FIRST_SLOT) {
>>> -        /* Super */
>>> -        slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
>>> -
>>> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name,
>>> -                           NUBUS_SUPER_SLOT_SIZE);
>>> -        memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
>>> -                                    &nd->slot_mem);
>>> -    } else {
>>> -        /* Normal */
>>> -        slot_offset = nd->slot * NUBUS_SLOT_SIZE;
>>> -
>>> -        memory_region_init(&nd->slot_mem, OBJECT(dev), name,
>>> NUBUS_SLOT_SIZE);
>>> -        memory_region_add_subregion(&nubus->slot_io, slot_offset,
>>> -                                    &nd->slot_mem);
>>> -    }
>>>   +    /* Super */
>>> +    slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
>>> +
>>> +    name = g_strdup_printf("nubus-super-slot-%x", nd->slot);
>>> +    memory_region_init(&nd->super_slot_mem, OBJECT(dev), name,
>>> +                        NUBUS_SUPER_SLOT_SIZE);
>>> +    memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
>>> +                                &nd->super_slot_mem);
>>> +    g_free(name);
>>> +
>>> +    /* Normal */
>>> +    slot_offset = nd->slot * NUBUS_SLOT_SIZE;
>>> +
>>> +    name = g_strdup_printf("nubus-slot-%x", nd->slot);
>>
>> I'd rather use "nubus-standard-slot-%x" or "nubus-normal-slot-%x"
>> to differentiate from super-bus. (This also applies to variable
>> names and trace events in this series).
> 
> I can see how this may seem ambiguous, however in "Designing Cards and
> Drivers for the Macintosh Family" the documentation always refers to
> "slot" as a standard slot so there shouldn't be any confusion for
> developers here.

OK, fine then.

>> Anyway,
>> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
index be01269563..36203848e5 100644
--- a/hw/nubus/nubus-device.c
+++ b/hw/nubus/nubus-device.c
@@ -168,26 +168,26 @@  static void nubus_device_realize(DeviceState *dev, Error **errp)
     }
 
     nd->slot = nubus->current_slot++;
-    name = g_strdup_printf("nubus-slot-%d", nd->slot);
-
-    if (nd->slot < NUBUS_FIRST_SLOT) {
-        /* Super */
-        slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
-
-        memory_region_init(&nd->slot_mem, OBJECT(dev), name,
-                           NUBUS_SUPER_SLOT_SIZE);
-        memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
-                                    &nd->slot_mem);
-    } else {
-        /* Normal */
-        slot_offset = nd->slot * NUBUS_SLOT_SIZE;
-
-        memory_region_init(&nd->slot_mem, OBJECT(dev), name, NUBUS_SLOT_SIZE);
-        memory_region_add_subregion(&nubus->slot_io, slot_offset,
-                                    &nd->slot_mem);
-    }
 
+    /* Super */
+    slot_offset = (nd->slot - 6) * NUBUS_SUPER_SLOT_SIZE;
+
+    name = g_strdup_printf("nubus-super-slot-%x", nd->slot);
+    memory_region_init(&nd->super_slot_mem, OBJECT(dev), name,
+                        NUBUS_SUPER_SLOT_SIZE);
+    memory_region_add_subregion(&nubus->super_slot_io, slot_offset,
+                                &nd->super_slot_mem);
+    g_free(name);
+
+    /* Normal */
+    slot_offset = nd->slot * NUBUS_SLOT_SIZE;
+
+    name = g_strdup_printf("nubus-slot-%x", nd->slot);
+    memory_region_init(&nd->slot_mem, OBJECT(dev), name, NUBUS_SLOT_SIZE);
+    memory_region_add_subregion(&nubus->slot_io, slot_offset,
+                                &nd->slot_mem);
     g_free(name);
+
     nubus_register_format_block(nd);
 }
 
diff --git a/include/hw/nubus/nubus.h b/include/hw/nubus/nubus.h
index 424309dd73..89b0976aaa 100644
--- a/include/hw/nubus/nubus.h
+++ b/include/hw/nubus/nubus.h
@@ -43,6 +43,7 @@  struct NubusDevice {
     DeviceState qdev;
 
     int slot;
+    MemoryRegion super_slot_mem;
     MemoryRegion slot_mem;
 
     /* Format Block */