--- SheepShaver/src/serial.cpp 2002/02/04 16:58:13 1.1.1.1 +++ SheepShaver/src/serial.cpp 2008/01/01 09:47:38 1.6 @@ -1,7 +1,7 @@ /* * serial.cpp - Serial device driver * - * SheepShaver (C) 1997-2002 Marc Hellwig and Christian Bauer + * SheepShaver (C) 1997-2008 Marc Hellwig and Christian Bauer * * 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 @@ -32,8 +32,12 @@ SERDPort *the_serd_port[2]; // Function pointers from imported functions -typedef int16 (*iocommandiscomplete_ptr)(uint32, int16); -static iocommandiscomplete_ptr IOCommandIsComplete; +typedef int16 (*iocic_ptr)(uint32, int16); +static uint32 iocic_tvect = 0; +static inline int16 IOCommandIsComplete(uint32 arg1, int16 arg2) +{ + return (int16)CallMacOS2(iocic_ptr, iocic_tvect, arg1, arg2); +} /* @@ -55,9 +59,9 @@ int16 SerialOpen(uint32 pb, uint32 dce) D(bug("SerialOpen pb %08lx, dce %08lx\n", pb, dce)); // Get IOCommandIsComplete function - IOCommandIsComplete = (iocommandiscomplete_ptr)FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete"); - D(bug("IOCommandIsComplete TVECT at %08lx\n", (uint32)IOCommandIsComplete)); - if (IOCommandIsComplete == NULL) { + iocic_tvect = FindLibSymbol("\021DriverServicesLib", "\023IOCommandIsComplete"); + D(bug("IOCommandIsComplete TVECT at %08lx\n", iocic_tvect)); + if (iocic_tvect == 0) { printf("FATAL: SerialOpen(): Can't find IOCommandIsComplete()\n"); return openErr; } @@ -78,8 +82,10 @@ int16 SerialOpen(uint32 pb, uint32 dce) return res; // Allocate Deferred Task structures - uint32 input_dt = the_port->input_dt = (uint32)the_port->dt_store; - uint32 output_dt = the_port->output_dt = (uint32)the_port->dt_store + SIZEOF_serdt; + if ((the_port->dt_store = Mac_sysalloc(SIZEOF_serdt * 2)) == 0) + return openErr; + uint32 input_dt = the_port->input_dt = the_port->dt_store; + uint32 output_dt = the_port->output_dt = the_port->dt_store + SIZEOF_serdt; D(bug(" input_dt %08lx, output_dt %08lx\n", input_dt, output_dt)); WriteMacInt16(input_dt + qType, dtQType); @@ -266,6 +272,7 @@ int16 SerialClose(uint32 pb, uint32 dce) // Close port if open SERDPort *the_port = the_serd_port[(-(int16)ReadMacInt16(dce + dCtlRefNum)-6) >> 1]; if (the_port->is_open) { + Mac_sysfree(the_port->dt_store); int16 res = the_port->close(); the_port->is_open = false; return res;