Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!latlog.UUCP!IAN From: IAN@latlog.UUCP Newsgroups: comp.sys.transputer Subject: Re: C Query Message-ID: <1043.8806092145@latlog.co.uk> Date: 9 Jun 88 23:45:34 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 32 Re: Ben Abbott's query about special hardware and C. The easiest way to access memory-mapped device registers in C is to declare a structure type with appropriate fields: struct uart_regs { int control; int status; int data_in; int data_out; }; Now we can create pointers into memory which is being used by such devices: struct uart_regs *first_uart = 0x80200000, *secnd_uart = 0x80201000; (For purists, the 0x...s should be cast into the appropriate type) Finally, you can make use of the device registers as follows: while (first_uart->status & NO_CHAR_READY) do_nothing(); in_char = first_uart->data_in; Less symbolically, you could just use an integer pointer like: int *first_uart = 0x80200000; Then, the device registers are just first_uart[0], first_uart[1] and so on. Hope this helps, -- Ian Young, 3L Ltd