pkgin_all: script to auto-install all packages
[minix.git] / lib / libddekit / src / resource.c
blob29965c3bc6572289057389be01c617c24617a098
1 #include "common.h"
2 #include <ddekit/panic.h>
3 #include <ddekit/resources.h>
4 #include <ddekit/pgtab.h>
6 #include <minix/vm.h>
8 #ifdef DDEBUG_LEVEL_RESOURCE
9 #undef DDEBUG
10 #define DDEBUG DDEBUG_LEVEL_RESOURCE
11 #endif
13 #include "debug.h"
14 #include "util.h"
16 /****************************************************************************/
17 /* ddekit_release_dma */
18 /****************************************************************************/
19 int ddekit_request_dma(int nr) {
20 WARN_UNIMPL;
21 /* do we stil use isa dma ? imho no.*/
22 return -1;
25 /****************************************************************************/
26 /* ddekit_request_dma */
27 /****************************************************************************/
28 int ddekit_release_dma(int nr) {
29 WARN_UNIMPL;
30 /* do we stil use isa dma ? imho no.*/
31 return -1;
34 /*
35 * In minix we don't need to explicitly request IO-ports, ...
37 /****************************************************************************/
38 /* ddekit_release/request_io */
39 /****************************************************************************/
40 int ddekit_request_io (ddekit_addr_t start, ddekit_addr_t count) {
41 return 0;
43 int ddekit_release_io (ddekit_addr_t start, ddekit_addr_t count) {
44 return 0;
47 /****************************************************************************/
48 /* ddekit_request_mem */
49 /****************************************************************************/
50 int ddekit_request_mem
51 (ddekit_addr_t start, ddekit_addr_t size, ddekit_addr_t *vaddr) {
53 *vaddr = (ddekit_addr_t) vm_map_phys(SELF, (void *)start, size);
55 DDEBUG_MSG_VERBOSE("start: %x, size: %d, virt: %x", start, size, *vaddr);
57 if( *vaddr == (ddekit_addr_t) NULL) {
58 ddekit_panic("unable to map IO memory from %p of size %d",
59 start, size);
61 return (vaddr==NULL);
64 /****************************************************************************/
65 /* ddekit_release_mem */
66 /****************************************************************************/
67 int ddekit_release_mem(ddekit_addr_t start, ddekit_addr_t size)
69 return vm_unmap_phys(SELF,(void *) start, size );
72 /****************************************************************************/
73 /* ddekit_inb */
74 /****************************************************************************/
75 unsigned char ddekit_inb(ddekit_addr_t port) {
76 u32_t ret;
77 if (sys_inb(port, &ret)) {
78 ddekit_panic("sys_inb failed.");
80 DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
81 return (char) ret;
84 /****************************************************************************/
85 /* ddekit_inw */
86 /****************************************************************************/
87 unsigned short ddekit_inw(ddekit_addr_t port) {
88 u32_t ret;
89 if (sys_inw(port, &ret)) {
90 ddekit_panic("sys_inw failed.");
92 DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
93 return (short) ret;
96 /****************************************************************************/
97 /* ddekit_inl */
98 /****************************************************************************/
99 unsigned long ddekit_inl(ddekit_addr_t port){
100 u32_t ret;
101 if (sys_inl(port, &ret)) {
102 ddekit_panic("sys_outl failed.");
104 DDEBUG_MSG_VERBOSE("read port %x: %x", port, ret);
105 return ret;
108 /****************************************************************************/
109 /* ddekit_outb */
110 /****************************************************************************/
111 void ddekit_outb(ddekit_addr_t port, unsigned char val) {
112 if (sys_outb(port,val)) {
113 ddekit_panic("sys_outb failed.");
115 DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);
118 /****************************************************************************/
119 /* ddekit_outw */
120 /****************************************************************************/
121 void ddekit_outw(ddekit_addr_t port, unsigned short val) {
122 if (sys_outw(port,val)) {
123 ddekit_panic("sys_outw failed.");
125 DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);
128 /****************************************************************************/
129 /* ddekit_outl */
130 /****************************************************************************/
131 void ddekit_outl(ddekit_addr_t port, unsigned long val) {
132 if (sys_outl(port,val)) {
133 ddekit_panic("sys_outl failed.");
135 DDEBUG_MSG_VERBOSE("write port %x: %x", port, val);