[SeaBIOS] Wrong address returned by container _of macro

Daniel Castro evil.dani at gmail.com
Sat Apr 7 13:20:14 CEST 2012


On Fri, Apr 6, 2012 at 9:57 PM, Kevin O'Connor <kevin at koconnor.net> wrote:
> On Wed, Apr 04, 2012 at 04:04:54PM +0900, Daniel Castro wrote:
>> Hello All,
>>
>> I have a little problem, when I try to get my drive on boot (16bit) I
>> am getting the wrong address:
>>
>> This code:
>>       struct xendrive_s * xendrive =
>> GLOBALFLAT2GLOBAL(container_of(GET_GLOBAL(op->drive_g), struct
>> xendrive_s, drive));
>
> op is on the stack, so one must not use GET_GLOBAL on it.  Also,
> drive_g is already a "global", so GLOBALFLAT2GLOBAL must not be called
> on it.  So, this should read:
>
> struct xendrive_s * xendrive = container_of(op->drive_g, struct xendrive_s, drive))
>
> If one looks at the other disk drivers, they'll see something similar
> - for example ahci_cmd_data() has:
>
>    struct ahci_port_s *port = container_of(
>        op->drive_g, struct ahci_port_s, drive);
Yes, indeed, I followed the same process as virtuo drivers, yet the
memory address returned by container_of made no sense, so I kept
trying stuff out. Anyway I have a work around now, maybe later when I
clean the code I will change it back to just container_of, I am
pushing forward to get a working prototype as soon as possible.

>
> -Kevin



-- 
+-=====---------------------------+
| +---------------------------------+ | This space intentionally blank
for notetaking.
| |   | Daniel Castro,                |
| |   | Consultant/Programmer.|
| |   | U Andes                         |
+-------------------------------------+



More information about the SeaBIOS mailing list