* Off by two error in au1000/common/setup.c?
@ 2005-03-22 14:31 Ulrich Eckhardt
2005-03-22 17:46 ` Pete Popov
0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Eckhardt @ 2005-03-22 14:31 UTC (permalink / raw)
To: linux-mips
Hi!
Could someone take a look at these lines from fixup_bigphys_addr():
// 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?
Uli
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Off by two error in au1000/common/setup.c?
2005-03-22 14:31 Off by two error in au1000/common/setup.c? Ulrich Eckhardt
@ 2005-03-22 17:46 ` Pete Popov
2005-03-23 7:36 ` Ulrich Eckhardt
0 siblings, 1 reply; 4+ messages in thread
From: Pete Popov @ 2005-03-22 17:46 UTC (permalink / raw)
To: Ulrich Eckhardt; +Cc: linux-mips
Ulrich Eckhardt wrote:
>Hi!
>
>Could someone take a look at these lines from fixup_bigphys_addr():
>
> // 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.
How about if I just make MEM_END 0x450000000 and the check " <= end" ?
Pete
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Off by two error in au1000/common/setup.c?
2005-03-22 17:46 ` Pete Popov
@ 2005-03-23 7:36 ` Ulrich Eckhardt
2005-03-23 7:43 ` Pete Popov
0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Eckhardt @ 2005-03-23 7:36 UTC (permalink / raw)
To: linux-mips
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
;)
> 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?
Uli
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Off by two error in au1000/common/setup.c?
2005-03-23 7:36 ` Ulrich Eckhardt
@ 2005-03-23 7:43 ` Pete Popov
0 siblings, 0 replies; 4+ messages in thread
From: Pete Popov @ 2005-03-23 7:43 UTC (permalink / raw)
To: Ulrich Eckhardt; +Cc: linux-mips
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-23 7:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-22 14:31 Off by two error in au1000/common/setup.c? Ulrich Eckhardt
2005-03-22 17:46 ` Pete Popov
2005-03-23 7:36 ` Ulrich Eckhardt
2005-03-23 7:43 ` Pete Popov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.