I agree with Hoa that you're using virtual addresses, and those are unrelated to the physical addresses you're trying to access. The second method is probably moving an immediate constant into the register, and not loading from a memory address. mmap-ing the physical pages you're interested in would help. Also you should use the "volatile" keyword to tell the compiler that this isn't just memory, and it shouldn't assume that the value won't change out from under it, and hence it needs to read from it or write to it for real every time you tell it to. If you're using caches, you'll also want to make sure that range is not cached, or the accesses will be handled by the cache and not actually make it out to the rest of the memory system.
Gabe On Sat, Oct 23, 2021 at 7:02 PM Hoa Nguyen via gem5-users < gem5-users@gem5.org> wrote: > Hi Andreas, > > My guess is that for Method 1, the pointer is of a virtual address so > there's a page fault there. > > I'm not sure why the write() function wasn't invoked on Method 2. I got > into the same problem recently where I used mmap() to write to a physical > address, which should be handled by a Pio device. Even though the generated > binary has a store instruction to that address, the write() function wasn't > called. I solved that problem by using printf() to print the value at that > physical address. I think using volatile keyword should have worked as well. > > I'm quite rusty on bare metal programming so I might be wrong :) > > Regards, > Hoa Nguyen > > On Sat, Oct 23, 2021, 4:37 PM diavastos--- via gem5-users < > gem5-users@gem5.org> wrote: > >> Hi all, >> >> I implemented a device using the BasicPioDevice class but I can't seem to >> get the read() & write() calls to work. >> I assigned a pioAddr=0x200000000 and a pioSize=4096 and I try to write to >> the device directly using these two methods: >> >> Method 1: >> ----------- >> >> uint32_t inp_params2 = 14; >> uint64_t *driver = (uint64_t*)0x200000000; >> *driver = inp_params2; >> >> Method 2: >> ----------- >> >> asm volatile ( >> "mov %0,0x200000000\n" >> : >> : "r" (inp_params2) >> : >> ); >> >> With the Method 2, the simulation completes with no error but the write() >> is never called on the device, With Method 1 I get the following error: >> panic: panic condition !handled occurred: Page table fault when accessing >> virtual address 0x200000000 >> >> Any help would be greatly appreciated! >> >> Many Thanks, >> andreas >> _______________________________________________ >> gem5-users mailing list -- gem5-users@gem5.org >> To unsubscribe send an email to gem5-users-le...@gem5.org >> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >> > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s