1 /*
2  * Copyright (c) 2008-2015 Travis Geiselbrecht
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #include <lib/io.h>
9 
10 #include <lk/err.h>
11 #include <ctype.h>
12 #include <lk/debug.h>
13 #include <assert.h>
14 
io_write(io_handle_t * io,const char * buf,size_t len)15 ssize_t io_write(io_handle_t *io, const char *buf, size_t len) {
16     DEBUG_ASSERT(io->magic == IO_HANDLE_MAGIC);
17 
18     if (!io->hooks->write)
19         return ERR_NOT_SUPPORTED;
20 
21     return io->hooks->write(io, buf, len);
22 }
23 
io_read(io_handle_t * io,char * buf,size_t len)24 ssize_t io_read(io_handle_t *io, char *buf, size_t len) {
25     DEBUG_ASSERT(io->magic == IO_HANDLE_MAGIC);
26 
27     if (!io->hooks->read)
28         return ERR_NOT_SUPPORTED;
29 
30     return io->hooks->read(io, buf, len);
31 }
32 
33