xref: /minix3/minix/lib/libddekit/src/resource.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #include "common.h"
2*433d6423SLionel Sambuc #include <ddekit/panic.h>
3*433d6423SLionel Sambuc #include <ddekit/resources.h>
4*433d6423SLionel Sambuc #include <ddekit/pgtab.h>
5*433d6423SLionel Sambuc 
6*433d6423SLionel Sambuc #include <minix/vm.h>
7*433d6423SLionel Sambuc 
8*433d6423SLionel Sambuc #ifdef DDEBUG_LEVEL_RESOURCE
9*433d6423SLionel Sambuc #undef DDEBUG
10*433d6423SLionel Sambuc #define DDEBUG DDEBUG_LEVEL_RESOURCE
11*433d6423SLionel Sambuc #endif
12*433d6423SLionel Sambuc 
13*433d6423SLionel Sambuc #include "debug.h"
14*433d6423SLionel Sambuc #include "util.h"
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc /****************************************************************************/
17*433d6423SLionel Sambuc /*      ddekit_release_dma                                                  */
18*433d6423SLionel Sambuc /****************************************************************************/
ddekit_request_dma(int nr)19*433d6423SLionel Sambuc int ddekit_request_dma(int nr) {
20*433d6423SLionel Sambuc 	WARN_UNIMPL;
21*433d6423SLionel Sambuc 	/* do we stil use isa dma ? imho no.*/
22*433d6423SLionel Sambuc 	return -1;
23*433d6423SLionel Sambuc }
24*433d6423SLionel Sambuc 
25*433d6423SLionel Sambuc /****************************************************************************/
26*433d6423SLionel Sambuc /*      ddekit_request_dma                                                  */
27*433d6423SLionel Sambuc /****************************************************************************/
ddekit_release_dma(int nr)28*433d6423SLionel Sambuc int ddekit_release_dma(int nr) {
29*433d6423SLionel Sambuc 	WARN_UNIMPL;
30*433d6423SLionel Sambuc 	/* do we stil use isa dma ? imho no.*/
31*433d6423SLionel Sambuc 	return -1;
32*433d6423SLionel Sambuc }
33*433d6423SLionel Sambuc 
34*433d6423SLionel Sambuc /*
35*433d6423SLionel Sambuc  * In minix we don't need to explicitly request IO-ports, ...
36*433d6423SLionel Sambuc  */
37*433d6423SLionel Sambuc /****************************************************************************/
38*433d6423SLionel Sambuc /*      ddekit_release/request_io                                           */
39*433d6423SLionel Sambuc /****************************************************************************/
ddekit_request_io(ddekit_addr_t start,ddekit_addr_t count)40*433d6423SLionel Sambuc int ddekit_request_io (ddekit_addr_t start, ddekit_addr_t count) {
41*433d6423SLionel Sambuc 	return 0;
42*433d6423SLionel Sambuc }
ddekit_release_io(ddekit_addr_t start,ddekit_addr_t count)43*433d6423SLionel Sambuc int ddekit_release_io (ddekit_addr_t start, ddekit_addr_t count) {
44*433d6423SLionel Sambuc 	return 0;
45*433d6423SLionel Sambuc }
46*433d6423SLionel Sambuc 
47*433d6423SLionel Sambuc /****************************************************************************/
48*433d6423SLionel Sambuc /*      ddekit_request_mem                                                  */
49*433d6423SLionel Sambuc /****************************************************************************/
ddekit_request_mem(ddekit_addr_t start,ddekit_addr_t size,ddekit_addr_t * vaddr)50*433d6423SLionel Sambuc int ddekit_request_mem
51*433d6423SLionel Sambuc (ddekit_addr_t start, ddekit_addr_t size, ddekit_addr_t *vaddr) {
52*433d6423SLionel Sambuc 
53*433d6423SLionel Sambuc 	*vaddr = (ddekit_addr_t) vm_map_phys(SELF, (void *)start, size);
54*433d6423SLionel Sambuc 
55*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("start: %x, size: %d, virt: %x", start, size, *vaddr);
56*433d6423SLionel Sambuc 
57*433d6423SLionel Sambuc 	if( *vaddr == (ddekit_addr_t) NULL) {
58*433d6423SLionel Sambuc 		ddekit_panic("unable to map IO memory from %p of size %d",
59*433d6423SLionel Sambuc 		    start, size);
60*433d6423SLionel Sambuc 	}
61*433d6423SLionel Sambuc 	return (vaddr==NULL);
62*433d6423SLionel Sambuc }
63*433d6423SLionel Sambuc 
64*433d6423SLionel Sambuc /****************************************************************************/
65*433d6423SLionel Sambuc /*      ddekit_release_mem                                                  */
66*433d6423SLionel Sambuc /****************************************************************************/
ddekit_release_mem(ddekit_addr_t start,ddekit_addr_t size)67*433d6423SLionel Sambuc int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t size)
68*433d6423SLionel Sambuc {
69*433d6423SLionel Sambuc 	return	vm_unmap_phys(SELF,(void *) start, size );
70*433d6423SLionel Sambuc }
71*433d6423SLionel Sambuc 
72*433d6423SLionel Sambuc /****************************************************************************/
73*433d6423SLionel Sambuc /*      ddekit_inb                                                          */
74*433d6423SLionel Sambuc /****************************************************************************/
ddekit_inb(ddekit_addr_t port)75*433d6423SLionel Sambuc unsigned char ddekit_inb(ddekit_addr_t port) {
76*433d6423SLionel Sambuc 	u32_t ret;
77*433d6423SLionel Sambuc 	if (sys_inb(port, &ret)) {
78*433d6423SLionel Sambuc 		ddekit_panic("sys_inb failed.");
79*433d6423SLionel Sambuc 	}
80*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
81*433d6423SLionel Sambuc 	return (char) ret;
82*433d6423SLionel Sambuc }
83*433d6423SLionel Sambuc 
84*433d6423SLionel Sambuc /****************************************************************************/
85*433d6423SLionel Sambuc /*      ddekit_inw                                                          */
86*433d6423SLionel Sambuc /****************************************************************************/
ddekit_inw(ddekit_addr_t port)87*433d6423SLionel Sambuc unsigned short ddekit_inw(ddekit_addr_t port) {
88*433d6423SLionel Sambuc 	u32_t ret;
89*433d6423SLionel Sambuc 	if (sys_inw(port, &ret)) {
90*433d6423SLionel Sambuc 		ddekit_panic("sys_inw failed.");
91*433d6423SLionel Sambuc 	}
92*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
93*433d6423SLionel Sambuc 	return (short) ret;
94*433d6423SLionel Sambuc }
95*433d6423SLionel Sambuc 
96*433d6423SLionel Sambuc /****************************************************************************/
97*433d6423SLionel Sambuc /*      ddekit_inl                                                          */
98*433d6423SLionel Sambuc /****************************************************************************/
ddekit_inl(ddekit_addr_t port)99*433d6423SLionel Sambuc unsigned long ddekit_inl(ddekit_addr_t port){
100*433d6423SLionel Sambuc 	u32_t ret;
101*433d6423SLionel Sambuc 	if (sys_inl(port, &ret)) {
102*433d6423SLionel Sambuc 		ddekit_panic("sys_outl failed.");
103*433d6423SLionel Sambuc 	}
104*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
105*433d6423SLionel Sambuc 	return ret;
106*433d6423SLionel Sambuc }
107*433d6423SLionel Sambuc 
108*433d6423SLionel Sambuc /****************************************************************************/
109*433d6423SLionel Sambuc /*      ddekit_outb                                                         */
110*433d6423SLionel Sambuc /****************************************************************************/
ddekit_outb(ddekit_addr_t port,unsigned char val)111*433d6423SLionel Sambuc void ddekit_outb(ddekit_addr_t port, unsigned char val) {
112*433d6423SLionel Sambuc 	if (sys_outb(port,val)) {
113*433d6423SLionel Sambuc 		ddekit_panic("sys_outb failed.");
114*433d6423SLionel Sambuc 	}
115*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);
116*433d6423SLionel Sambuc }
117*433d6423SLionel Sambuc 
118*433d6423SLionel Sambuc /****************************************************************************/
119*433d6423SLionel Sambuc /*      ddekit_outw                                                         */
120*433d6423SLionel Sambuc /****************************************************************************/
ddekit_outw(ddekit_addr_t port,unsigned short val)121*433d6423SLionel Sambuc void ddekit_outw(ddekit_addr_t port, unsigned short val) {
122*433d6423SLionel Sambuc 	if (sys_outw(port,val)) {
123*433d6423SLionel Sambuc 		ddekit_panic("sys_outw failed.");
124*433d6423SLionel Sambuc 	}
125*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);
126*433d6423SLionel Sambuc }
127*433d6423SLionel Sambuc 
128*433d6423SLionel Sambuc /****************************************************************************/
129*433d6423SLionel Sambuc /*      ddekit_outl                                                         */
130*433d6423SLionel Sambuc /****************************************************************************/
ddekit_outl(ddekit_addr_t port,unsigned long val)131*433d6423SLionel Sambuc void ddekit_outl(ddekit_addr_t port, unsigned long val) {
132*433d6423SLionel Sambuc 	if (sys_outl(port,val)) {
133*433d6423SLionel Sambuc 		ddekit_panic("sys_outl failed.");
134*433d6423SLionel Sambuc 	}
135*433d6423SLionel Sambuc 	DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);
136*433d6423SLionel Sambuc }
137*433d6423SLionel Sambuc 
138*433d6423SLionel Sambuc 
139