9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: jmk@plan9.bell-labs.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Question on mapping 0xfff00000
Date: Tue, 20 Mar 2001 20:30:21 -0500	[thread overview]
Message-ID: <20010321013034.07203199FB@mail.cse.psu.edu> (raw)

On Tue Mar 20 01:07:24 EST 2001, rminnich@lanl.gov wrote:
> 
> I need to map FLASH at 0xfff00000 into my flash driver. I have tried a
> number of variations, and keep coming back to:
> 
> flashbase = upamalloc(0xfff00000, 0x100000, 0);
> 
> Return value is 0xfff00000. But, any reference to this address provokes a
> fault, which leaves me believing I've got this wrong, even though a walk
> through that code also looks like it does set up the PTEs in the right
> way. The southbridge chip (PIIX4E) also has the right bits set to enable
> FLASH at these high addresses, and I've tested those settings in Linux.
> 
> The general problem is to map the last 2M of the 32-bit address space into
> memory, since on many boards that is the "reserved for BIOS flash" area.
> 
> What am I doing wrong? What's the right way to do this. I'm new to this
> kernel, needless to say. I'm also very happy it is now open source ...
> 
> ron

Looks like an arithmetic overflow problem. The clue is that the return
should be the ending address of the successfully mapped area. But if you
add 0xfff00000+0x100000 you get 0x100000000, which is 0 in 32-bits and the
mapping loop in mmu.c:^mmukmap() is

	pae = pa + size;
	lock(&mmukmaplock);
	while(pa < pae){

where pa = 0xfff00000 and size = 0x100000, so the loop will not be entered.

you could try rewriting the loop to be something like

	while(size > 0){
		...

and wherever you see
		pa += pgsz;
in the loop add
		size =- pgsz;
after it.

I think the comment in /sys/src/boot/pc/memory.c:^upamalloc() (which
contains the same mapping code) says it all. The whole memory thing is
slated for a rewrite but try the above suggestion and let me know how
it turns out.

--jim


             reply	other threads:[~2001-03-21  1:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-21  1:30 jmk [this message]
2001-03-24  1:43 ` Ronald G Minnich
  -- strict thread matches above, loose matches on Subject: below --
2001-03-20  6:06 Ronald G Minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010321013034.07203199FB@mail.cse.psu.edu \
    --to=jmk@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).