Booting questions ....

Scott Long scottl at freebsd.org
Thu Nov 4 15:06:48 PST 2004


Willem Jan Withagen wrote:
> Hi,
> 
> I'm looking for a place to sensibly insert memorytest routines....
> 
> Currently I'd like to do that not in the loader, but in the kernel where 
> memory is already setup to be one flat address space. This makes 
> programming a lot simpler.
> 
> A sensible place, from what I can deduct, would be before the 
> vm_ksubmap_init in the chunck from machdep.c:
> ----
>         /*
>          * Display any holes after the first chunk of extended memory.
>          */
>         if (bootverbose) {
>                 int indx;
> 
>                 printf("Physical memory chunk(s):\n");
>                 for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
>                         vm_paddr_t size;
> 
>                         size = phys_avail[indx + 1] - phys_avail[indx];
>                         printf(
>                             "0x%016jx - 0x%016jx, %ju bytes (%ju pages)\n",
>                             (uintmax_t)phys_avail[indx],
>                             (uintmax_t)phys_avail[indx + 1] - 1,
>                             (uintmax_t)size, (uintmax_t)size / PAGE_SIZE);
>                 }
>         }
> #ifdef MEMTEST
>     if (bootmemtest) {
>                 for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
>                         vm_paddr_t size;
> 
>                         size = phys_avail[indx + 1] - phys_avail[indx];
>             memtest (
>                             /* start */ (uintmax_t)phys_avail[indx],
>                             /* end */   (uintmax_t)phys_avail[indx + 1] 
> - 1,
>                             /*size */   (uintmax_t)size
>             );
>                 }
>     }   
> #endif MEMTEST
>         vm_ksubmap_init(&kmi);
> ----
> 
> And in memtest I can just linearly iterate over the memory between these 
> pointers without getting pagefaults....
> 
> Next question is where to watch for already taken memory:
>  - code
>  - data
>  - stack
> What modules are already setup by the time we enter the code above???
> 
> Or the alternative would be to just exclude for the code and data of the 
> memtests routines them selves. But then printf would probably be 
> destroyed as well, and there would be no "tracing" of memtest activity.
> 
> Thanx,
> --WjW
> 

The loader has a protected mode environment.  It is apparently not all
that hard to port memtest86 into it.  I'd highly recommend doing this
rather than trying to hack up the early pmap initialization.

Scott


More information about the freebsd-arch mailing list