1/** 2 * \file 3 * \brief Serial port driver. 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2012, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich, 13 * Attn: Systems Group. 14 */ 15 16#ifndef SERIAL_H 17#define SERIAL_H 18 19#include <barrelfish/barrelfish.h> 20 21struct serial_buffer { 22 char *buf; 23 size_t len; 24}; 25 26#define SERIAL_PORTBASE_INVALID 0xffffffff 27#define SERIAL_IRQ_INVALID 0xffffffff 28#define SERIAL_MEMBASE_INVALID 0xffffffffffffffffULL 29 30struct serial_common; 31 32typedef void (*serial_input_fn_t) 33 (void *arg, char *data, size_t length); 34typedef void (*serial_output_fn_t) 35 (void * arg, const char *c, size_t length); 36 37// Returned from init functions 38struct serial_common { 39 uint32_t irq; 40 uint64_t membase; 41 char *driver_name; 42 struct serial_buffer buffer; 43 44 // Handler for input from the serial line. Set in main. 45 // Module should call serial_input(..) to perform buffering. 46 serial_input_fn_t input_consumer; 47 void *input_consumer_arg; 48 49 // Output on the serial line. Set in module, called from main 50 serial_output_fn_t output; 51 void *output_arg; 52}; 53 54errval_t init_serial_common(struct serial_common *m); 55 56// Generic interface 57void serial_input(struct serial_common *main, char *data, size_t length); 58void serial_set_new_input_consumer(struct serial_common *main, 59 serial_input_fn_t fn, void *fn_arg); 60 61// Service interface 62void start_service(struct serial_common *main); 63void start_basic_service(struct serial_common *main); 64void start_terminal_service(struct serial_common *main); 65 66#endif 67