lkml.org 
[lkml]   [1999]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: What is the right type to store virtual address ?
On Thu, Aug 19, 1999 at 11:12:12AM -0700, Linus Torvalds wrote:

> For _true_ cleanliness, it should probably be something like
>
> typedef struct {
> unsigned long base;
> } io_base_t;
>
> /*
> * The ISA legacy region 640kB-1M is always mapped,
> * here's the base
> */
> extern io_base_t isa_io_base;
>
> extern io_base_t ioremap(unsigned long addr, unsigned long len);
> extern unsigned char readb(io_base_t base, unsigned int offset);
> ...
>
> but while I'd potentially like to see that I also wonder about just the
> pain of doing the conversion.

I vote for it; it would help avoiding a number of bugs. For example
on the i386 the definition of

#define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
#define __io_phys(x) ((unsigned long)(x) & ~PAGE_OFFSET)

make wrong constructs which effectivly do things like
__io_virt(__io_virt(addr)) or __io_phys(__io_phys(addr)) work. They're
obviously wrong. If above definition's could be changed to something
like:

#define __io_virt(x) ((void *)(PAGE_OFFSET + (unsigned long)(x)))
#define __io_phys(x) ((unsigned long)(x) - PAGE_OFFSET)

such broken could at least wouldn't work anymore. It's also a less
intrusive change than your suggestion as it should only break broken
drivers. Nevertheless I like your above suggestion - even if it'd be
a pain.

Ralf

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.036 / U:0.776 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site