Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | /* * * Copyright (C) Eicon Technology Corporation, 2000. * * Eicon File Revision : 1.2 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * Unix Eicon active card driver * XLOG related functions */ #include "sys.h" #include "idi.h" #include "pc.h" #include "pc_maint.h" #include "divalog.h" #include "adapter.h" #include "uxio.h" /* * convert/copy XLOG info into a KLOG entry */ static void xlog_to_klog(byte *b, int size, int card_num) { typedef struct { word code; word time_hi; word time_lo; word xcode; byte data[2]; } card_xlog_t; card_xlog_t *x; klog_t klog; x = (card_xlog_t *) b; bzero(&klog, sizeof(klog)); klog.time_stamp = (dword) x->time_hi; klog.time_stamp = (klog.time_stamp << 16) | (dword) x->time_lo; klog.length = size > sizeof(klog.buffer) ? sizeof(klog.buffer) : size; klog.card = card_num; if (x->code == 1) { klog.type = KLOG_XTXT_MSG; klog.code = 0; bcopy(&x->xcode, klog.buffer, klog.length); } else if (x->code == 2) { klog.type = KLOG_XLOG_MSG; klog.code = x->xcode; bcopy(&x->data, klog.buffer, klog.length); } else { char *c; int i; klog.type = KLOG_TEXT_MSG; klog.code = 0; c = "divas: invalid xlog message code from card"; i = 0; while (*c) { klog.buffer[i] = *c; c++; i++; } klog.buffer[i] = *c; } /* send to the log driver and return */ DivasLogAdd(&klog, sizeof(klog)); return; } /* * send an XLOG request down to specified card * if response available from previous request then read it * if not then just send down new request, ready for next time */ void DivasXlogReq(int card_num) { card_t *card; ADAPTER *a; if ((card_num < 0) || (card_num > DivasCardNext)) { DPRINTF(("xlog: invalid card number")); return; } card = &DivasCards[card_num]; if (DivasXlogRetrieve(card)) { return; } /* send down request for next time */ a = &card->a; a->ram_out(a, (word *) (card->xlog_offset + 1), 0); a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG); return; } /* * retrieve XLOG request from specified card * returns non-zero if new request sent to card */ int DivasXlogRetrieve(card_t *card) { ADAPTER *a; struct mi_pc_maint pcm; a = &card->a; /* get status of last request */ pcm.rc = a->ram_in(a, (word *)(card->xlog_offset + 1)); /* if nothing there from previous request, send down a new one */ if (pcm.rc == OK) { /* read in response */ a->ram_in_buffer(a, (word *) (dword) card->xlog_offset, &pcm, sizeof(pcm)); xlog_to_klog((byte *) &pcm.data, sizeof(pcm.data), (int) (card - DivasCards)); } /* if any response received from card, re-send request */ if (pcm.rc) { a->ram_out(a, (word *) (card->xlog_offset + 1), 0); a->ram_out(a, (word *) (dword) (card->xlog_offset), DO_LOG); return 1; } return 0; } |