Subject: Proposed extension to bus.h interface
To: None <tech-kern@NetBSD.ORG>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 08/14/1996 10:51:52
I would like to propose the addition of the following 4 functions to the 
bus.h interface:

	int bus_mem_alloc(t, size, alignment, cacheable, bpap, mhp)
		bus_chipset_tag_t t;
		bus_mem_size_t size, alignment;
		int cacheable;
		bus_mem_addr_t *bpap;
		bus_mem_handle_t *mhp;

	Allocate bus physical address space of size `size' with alignment
	`alignment'.  If no alignment is required, the caller will pass
	the placeholder BUS_MEM_NOALIGN for the `alignment' argument.
	Place the resulting bus physical address in `*bpap'.  The
	bus physical address will be mapped, and the resulting mapping
	placed in `*mhp'.  If the `cacheable' argument is zero, the
	mapping will be cache-inhibited.  Returns zero on success,
	non-zero on error.

	void bus_mem_free(t, memh, size)
		bus_chipset_tag_t t;
		bus_mem_handle_t memh;
		bus_mem_size_t size;

	Unmap the bus physical address mapped by `memh' and free
	the bus physical address space as previously allocated by
	bus_mem_alloc().  If `memh' was not mapped by bus_mem_alloc(),
	behavior of this function is undefined.

	int bus_io_alloc(t, size, alignment, iohp)
		bus_chipset_tag_t t;
		bus_io_size_t size, alignment;
		bus_io_handle_t *iohp;

	Allocate bus i/o space of size `size' with alignment `alignment'.
	If no alignment is required, the caller will pass the placeholder
	BUS_IO_NOALIGN for the `alignment' argument.  Place the resulting
	bus i/o address in `*portp'.  Map bus i/o space will be mapped,
	and the resulting mapping placed in `*iohp'.  Returns zero
	on success, non-zero on error.

	void bus_io_free(u, ioh, size)
		bus_chipset_tag_t t;
		bus_io_handle_t ioh;
		bus_io_size_t size;

	Unmap the bus i/o space mapped by `ioh' and free the bus
	i/o space as previously allocated by bus_io_alloc().  If
	`ioh' was not mapped by bus_io_alloc(), behavior of this
	function is undefined.

The reason I propose this is that I have a current need for the
bus_mem_alloc()/bus_mem_free() functions (an EISA ATM card driver).
This particular card requires the host operating system to allocate
bus physical address space, and program an address decoder in order
to map the 1MB of shared memory on the card into host memory.

I don't currently have a need for the bus_io_alloc()/bus_io_free()
functions, but the obvious use for them is the implementation of
Plug N Play support.

I have implemented these functions for the i386 port.

Feedback is appreciated.  If there are no objections, I'll go ahead and
commit the necessary changes to the i386 port late next week.

 -- save the ancient forests - http://www.bayarea.net/~thorpej/forest/ -- 
Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939