xref: /haiku/headers/os/drivers/ISA.h (revision 445d4fd926c569e7b9ae28017da86280aaecbae2)
1 /*
2  *	Copyright 2023, Haiku Inc. All Rights Reserved.
3  *	Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef ISA_H
7 #define ISA_H
8 
9 #include <bus_manager.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /*
16  *	ISA scatter/gather dma support.
17  */
18 
19 typedef struct {
20 	uint32				address;					// memory address in little endian
21 	uint16				transfer_count;				// number of transfers -1 in little endian
22 	uint8				reserved;					// empty space
23 	uint8				flag;						// end of link flag
24 } isa_dma_entry;
25 
26 #define B_LAST_ISA_DMA_ENTRY						0x80				// sets end of link flag
27 #define B_MAX_ISA_DMA_COUNT							0x10000
28 #define B_ISA_MODULE_NAME							"bus_managers/isa/v1"
29 
30 enum {
31 	B_8_BIT_TRANSFER,
32 	B_16_BIT_TRANSFER
33 };
34 
35 typedef struct isa_module_info {
36 	bus_manager_info    binfo;
37 
38 	uint8				(*read_io_8)				(int mapped_io_addr);
39 	void				(*write_io_8)				(int mapped_io_addr, uint8 value);
40 	uint16				(*read_io_16)				(int mapped_io_addr);
41 	void				(*write_io_16)				(int mapped_io_addr, uint16 value);
42 	uint32				(*read_io_32)				(int mapped_io_addr);
43 	void				(*write_io_32)				(int mapped_io_addr, uint32 value);
44 
45 	phys_addr_t			(*ram_address)				(phys_addr_t physical_address_in_system_memory);
46 
47 	long				(*make_isa_dma_table) (
48 							const void				*buffer,			// buffer for making table
49 							long					buffer_size,		// size of the buffer
50 							ulong					num_bits,			// dma transfer size
51 							isa_dma_entry			*table,				// -> caller-supplied
52 																		// scatter/gather table
53 							long					num_entries			// max # of entries in table
54 						);
55 	status_t			(*start_isa_dma) (
56 							long					channel,			// dma channel to use
57 							void					*buf,				// buffer to transfer
58 							long					transfer_count,		// number of transfers
59 							uchar					mode,				// mode flags
60 							uchar					e_mode				// extended mode flags
61 						);
62 	long				(*start_scattered_isa_dma) (
63 							long					channel,			// channel number to use
64 							const isa_dma_entry		*table,				// physical address of
65 																		// scatter/gather table
66 							uchar					mode,				// mode flags
67 							uchar					emode				// extended mode flags
68 						);
69 	status_t			(*lock_isa_dma_channel)		(long channel);
70 	status_t			(*unlock_isa_dma_channel)	(long channel);
71 } isa_module_info;
72 
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif	/* ISA_H */
78