linux-mips
[Top] [All Lists]

Re: Off by two error in au1000/common/setup.c?

To: Ulrich Eckhardt <eckhardt@satorlaser.com>
Subject: Re: Off by two error in au1000/common/setup.c?
From: Pete Popov <ppopov@embeddedalley.com>
Date: Tue, 22 Mar 2005 23:43:48 -0800
Cc: linux-mips@linux-mips.org
In-reply-to: <200503230836.29948.eckhardt@satorlaser.com>
Organization: Embedded Alley Solutions, Inc
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200503221531.46186.eckhardt@satorlaser.com> <424059E2.201@embeddedalley.com> <200503230836.29948.eckhardt@satorlaser.com>
Reply-to: ppopov@embeddedalley.com
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020
Ulrich Eckhardt wrote:
Pete Popov wrote:

// in au1000.h
#define Au1500_PCI_MEM_START      0x440000000ULL
#define Au1500_PCI_MEM_END        0x44FFFFFFFULL

// in setup.c
start = (u32)Au1500_PCI_MEM_START;
end = (u32)Au1500_PCI_MEM_END;
/* check for pci memory window */
if ((phys_addr >= start) && ((phys_addr + size) < end)) {
return (phys_addr - start) + Au1500_PCI_MEM_START;
}

For the (unlikely?) case that I want to use a size of 0x0 1000 0000,
'phys_addr+size == end+1'. IOW I need 'phys_addr+size-1' to get the last
address and use '<= end' to compare with the last valid address in the
range.

Right?

But the a size of 0x0 1000 0001 would pass the test since phys_addr +
1000 0001 - 1 <= end.


Really?
0x4 4000 0000 + 0x0 1000 0001 - 1 = 0x4 5000 0000 > 0x4 ffff ffff
;)

Yeh, I was already thinking about end==0x4 5000 0000 ...

How about if I just make MEM_END 0x450000000 and the check " <= end" ?


I'm not sure, it's a question of consistency: that solution would be the one-past-the-end address, which I'm fine with (being used to C++'s STL-style iterators..). The only problem I see arises if that one-past-the-end actually wraps around. Other than that, what is used generally, first and last valid address or first valid address and first not valid address? Or first valid address and size?

I'll check it out tomorrow.

Pete

<Prev in Thread] Current Thread [Next in Thread>