1 /* 2 * Copyright 2008, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * François Revol, revol@free.fr 7 * 8 * Copyright 2005, François Revol. 9 */ 10 11 /* 12 Description: Implements a tty on top of the parallel port, 13 using PLIP-like byte-by-byte protocol. 14 Low level stuff. 15 */ 16 17 18 // LPT1 19 #define LPTBASE 0x378 20 #define LPTIRQ 7 21 #define LPTDONGLE "/dev/misc/dongle/parallel1" 22 #define LPTSPIN 30 23 #define LPTSOFTRIES 1000 24 #define LPTNIBTRIES 100 25 #define LAPLINK_MAX_FRAME 512 26 27 typedef struct laplink_state { 28 int32 port; 29 int32 irq; 30 31 uint8 rstate; 32 uint8 wstate; 33 } laplink_state; 34 35 // framing 36 extern status_t ll_send_sof(laplink_state *st); 37 extern status_t ll_check_sof(laplink_state *st); 38 extern status_t ll_ack_sof(laplink_state *st); 39 extern status_t ll_send_eof(laplink_state *st); 40 41 // nibbles 42 extern status_t ll_send_lnibble(laplink_state *st, uint8 v); 43 extern status_t ll_send_mnibble(laplink_state *st, uint8 v); 44 extern status_t ll_wait_lnibble(laplink_state *st, uint8 *v); 45 extern status_t ll_wait_mnibble(laplink_state *st, uint8 *v); 46 47 // byte mode 48 extern status_t ll_send_byte(laplink_state *st, uint8 v); 49 extern status_t ll_check_byte(laplink_state *st, uint8 *v); 50 extern status_t ll_wait_byte(laplink_state *st, uint8 *v); 51 52 // frame mode 53 extern status_t ll_send_frame(laplink_state *st, const uint8 *buff, size_t *len); 54 extern status_t ll_check_frame(laplink_state *st, uint8 *buff, size_t *len); 55 extern status_t ll_wait_frame(laplink_state *st, uint8 *buff, size_t *len); 56 57 58