This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Question about writing Device Driver(ask for more detail)



 Hi all:
  Thanks for all your help.
Could anyone give some more detail steps of creating such device driver?  Do
I need to write any component or package?
how to set up the memory map the external device in standard way? (I used to
access the ARM E7T register directly and set the memory map. I don't know
whether this is the standard way to do it or other way?)  how to access the
external device by standard function or ways?
Thanks for every help.

best regards!

huang qiang


-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com]On Behalf Of Nick Garnett
Sent: 25 October 2001 10:52
To: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] Question about writing Device Driver


Jonathan Larmour <jlarmour@redhat.com> writes:

> HuangQiang wrote:
> >
> > Hi all:
> >    I am currently using an ARM E7T board. And I want to add some
exteranl
> > device to this board. I would like to write the device driver for the
> > exteranl device. what I want to do is to access the external device via
the
> > system address and data bus then set the configuration register in the
> > external device. The external device has been memory mapped. So if I
want to
> > develop my own device driver in eCOS what should I do? and what
procedure
> > should I follow? In the eCOS manual I can't find any information about
> > setting the configuration registers of the exteranl device. Thank you
for
> > any help. (Or any sample code or example for such situation?)
>
> If it's memory mapped then it's simple. Many if not most device drivers in
> eCos right now are using memory mapped I/O. Simply access the device
> addresses through volatile pointers, e.g.
>
> #define DEV_BASE 0x1000000
> #define DEV_RXSTAT (*(volatile unsigned int *)(DEV_BASE + 0))
> #define DEV_TXSTAT (*(volatile unsigned int *)(DEV_BASE + 4))
>
> int rxstat = DEV_RXSTAT;
>

Actually, you should use the HAL_READ_*() and HAL_WRITE_*() macros
supplied in hal_io.h. This way the driver will be more portable and
the macro encapsulation gives you a chance to fix up any cache, MMU,
write buffer, endianness or addressing issues that might arise.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]