119
122
* @return ENOMEM if there was some problem in allocating memory.
122
int iospace_enable(task_id_t id, void *ioaddr, unsigned long size)
125
static int iospace_enable(task_id_t id, void *ioaddr, size_t size)
127
const ddi_ioarg_t arg = {
130
133
return __SYSCALL1(SYS_IOSPACE_ENABLE, (sysarg_t) &arg);
135
138
* @param pio_addr I/O start address.
136
139
* @param size Size of the I/O region.
137
140
* @param virt Virtual address for application's
141
* PIO operations. Can be NULL for PMIO.
140
143
* @return EOK on success.
141
144
* @return Negative error code on failure.
146
149
#ifdef IO_SPACE_BOUNDARY
147
150
if (pio_addr < IO_SPACE_BOUNDARY) {
149
153
return iospace_enable(task_get_id(), pio_addr, size);
156
(void) iospace_enable;
153
161
void *phys_frame =
154
162
(void *) ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);
155
163
size_t offset = pio_addr - phys_frame;
176
void pio_write_8(ioport8_t *reg, uint8_t val)
178
pio_trace_log(reg, val, true);
179
arch_pio_write_8(reg, val);
182
void pio_write_16(ioport16_t *reg, uint16_t val)
184
pio_trace_log(reg, val, true);
185
arch_pio_write_16(reg, val);
188
void pio_write_32(ioport32_t *reg, uint32_t val)
190
pio_trace_log(reg, val, true);
191
arch_pio_write_32(reg, val);
194
uint8_t pio_read_8(const ioport8_t *reg)
196
const uint8_t val = arch_pio_read_8(reg);
197
pio_trace_log(reg, val, false);
201
uint16_t pio_read_16(const ioport16_t *reg)
203
const uint16_t val = arch_pio_read_16(reg);
204
pio_trace_log(reg, val, false);
208
uint32_t pio_read_32(const ioport32_t *reg)
210
const uint32_t val = arch_pio_read_32(reg);
211
pio_trace_log(reg, val, false);
168
215
/** Register IRQ notification.
170
217
* @param inr IRQ number.