[ECOS] PCI Address Mapping

Nick Garnett nickg@redhat.com
Tue Jan 22 05:11:00 GMT 2002


"Robert Cragie" <rcc@jennic.com> writes:

> > The PC is somewhat rare in that the mapping between the PCI address
> > space and the CPU physical address space is 1-1 and not windowed. This
> > means that you can give a PCI device any address in memory, and it can
> > access that memory directly. Any peculiarities you may see in the
> > i82559 driver are there to cope with targets where this is not the
> > case. So, your assumptions above are largely true.
> >
> > One important point to make, however, is that device drivers should
> > not use malloc(). If you look at the i82559 you will see that it has a
> > memory region reserved for it in the .ldi file and uses that for
> > allocating buffers.
> 
> As the earlier correspondent noticed, all of __pci_window is used by the
> i82559 driver, and the allocator for this window is wholly contained inside
> the driver. What is the preferred method of adding another section? Can this
> be done via the configuration file for the target build? I don't
> particularly want to have to hack the mlt_i386_pc_xxx.ldi/.h files in the
> repository. Perhaps it would be an idea to start to split out the PCI window
> allocator as already suggested after all, but I can imagine this would be
> quite a lot of work.

At present there is really no easy way to solve this problem.
Splitting out the PCI window allocator is the obvious fix, but it
needs someone with time to do this, fix all the drivers that have
thier own allocators, and then test that they all still work.

> 
> Would using malloc() work in this case? I can't see any reasons why it
> shouldn't, i.e. are you saying it shouldn't be used purely because it would
> limit the portability of the driver or because it's generally not a good
> idea to mix application and driver heap usage etc.?
> 

For your case, on the PC, since any memory will do for the purpose,
the best solution may be to just declare the buffers you want to use
statically. As you say, using malloc() limits the driver's
portability. Lots of the bits of a driver (ISRs and DSRs) run in
contexts where malloc() cannot be called. It may even be the case that
the driver init routine is called before the memory allocator is
initialized. 

-- 
Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK



More information about the Ecos-discuss mailing list