Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Nov 2004 16:07:53 -0700
From:      Scott Long <scottl@freebsd.org>
To:        Willem Jan Withagen <wjw@withagen.nl>
Cc:        "arch@freebsd.org" <arch@freebsd.org>
Subject:   Re: Booting questions ....
Message-ID:  <418AB649.80809@freebsd.org>
In-Reply-To: <418AB176.9030604@withagen.nl>
References:  <418AB176.9030604@withagen.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?418AB649.80809>