--- BasiliskII/src/AmigaOS/ether_amiga.cpp 1999/10/03 14:16:25 1.1 +++ BasiliskII/src/AmigaOS/ether_amiga.cpp 2001/07/13 15:39:22 1.8 @@ -1,7 +1,7 @@ /* * ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2001 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 @@ -116,11 +116,11 @@ static int16 send_to_proc(uint32 what, u * Initialization */ -void EtherInit(void) +bool ether_init(void) { // Do nothing if no Ethernet device specified if (PrefsFindString("ether") == NULL) - return; + return false; // Initialize protocol list NewList(&prot_list); @@ -135,8 +135,8 @@ void EtherInit(void) proc_error = false; SetSignal(0, SIGF_SINGLE); net_proc = CreateNewProcTags( - NP_Entry, net_func, - NP_Name, "Basilisk II Ethernet Task", + NP_Entry, (ULONG)net_func, + NP_Name, (ULONG)"Basilisk II Ethernet Task", NP_Priority, 1, TAG_END ); @@ -151,8 +151,7 @@ void EtherInit(void) goto open_error; // Everything OK - net_open = true; - return; + return true; open_error: net_proc = NULL; @@ -160,6 +159,7 @@ open_error: DeleteMsgPort(reply_port); reply_port = NULL; } + return false; } @@ -167,7 +167,7 @@ open_error: * Deinitialization */ -void EtherExit(void) +void ether_exit(void) { // Stop process if (net_proc) { @@ -188,10 +188,10 @@ void EtherExit(void) * Reset */ -void EtherReset(void) +void ether_reset(void) { // Remove all protocols - if (net_open) + if (net_proc) send_to_proc(MSG_CLEANUP); } @@ -287,7 +287,7 @@ static void remove_all_protocols(void) * Copy received network packet to Mac side */ -static __saveds __asm LONG copy_to_buff(register __a0 uint8 *to, register __a1 uint8 *from, register __d0 uint32 packet_len) +static __saveds __regargs LONG copy_to_buff(uint8 *to /*a0*/, uint8 *from /*a1*/, uint32 packet_len /*d0*/) { D(bug("CopyToBuff to %08lx, from %08lx, size %08lx\n", to, from, packet_len)); @@ -313,23 +313,23 @@ static __saveds __asm LONG copy_to_buff( * Copy data from Mac WDS to outgoing network packet */ -static __saveds __asm LONG copy_from_buff(register __a0 uint8 *to, register __a1 uint32 wds, register __d0 uint32 packet_len) +static __saveds __regargs LONG copy_from_buff(uint8 *to /*a0*/, char *wds /*a1*/, uint32 packet_len /*d0*/) { D(bug("CopyFromBuff to %08lx, wds %08lx, size %08lx\n", to, wds, packet_len)); #if MONITOR bug("Sending Ethernet packet:\n"); #endif for (;;) { - int len = ReadMacInt16(wds); + int len = ReadMacInt16((uint32)wds); if (len == 0) break; #if MONITOR - uint8 *adr = Mac2HostAddr(ReadMacInt32(wds + 2)); + uint8 *adr = Mac2HostAddr(ReadMacInt32((uint32)wds + 2)); for (int i=0; i unit=%d\n", dev_name, dev_unit); + } + else + { + if (2 != sscanf(str, "%[^/]/%ld", dev_name, &dev_unit)) + goto quit; + } + } + else goto quit; // Open device control_io->ios2_BufferManagement = buffer_tags; - if (OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0) || control_io->ios2_Req.io_Device == 0) + od_error = OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0); + if (0 != od_error || control_io->ios2_Req.io_Device == 0) + { + printf("WARNING: OpenDevice(<%s>, unit=%d) returned error %d)\n", (UBYTE *)dev_name, dev_unit, od_error); goto quit; + } opened = true; // Is it Ethernet? @@ -451,7 +488,7 @@ static __saveds void net_func(void) case MSG_ADD_MULTI: control_io->ios2_Req.io_Command = S2_ADDMULTICASTADDRESS; - memcpy(control_io->ios2_SrcAddr, Mac2HostAddr(msg->pointer + eMultiAddr), 6); + Mac2Host_memcpy(control_io->ios2_SrcAddr, msg->pointer + eMultiAddr, 6); DoIO((struct IORequest *)control_io); if (control_io->ios2_Req.io_Error == S2ERR_NOT_SUPPORTED) { WarningAlert(GetString(STR_NO_MULTICAST_WARN)); @@ -464,7 +501,7 @@ static __saveds void net_func(void) case MSG_DEL_MULTI: control_io->ios2_Req.io_Command = S2_DELMULTICASTADDRESS; - memcpy(control_io->ios2_SrcAddr, Mac2HostAddr(msg->pointer + eMultiAddr), 6); + Mac2Host_memcpy(control_io->ios2_SrcAddr, msg->pointer + eMultiAddr, 6); DoIO((struct IORequest *)control_io); if (control_io->ios2_Req.io_Error) msg->result = eMultiErr; @@ -550,8 +587,8 @@ static __saveds void net_func(void) // Get destination address, set source address uint32 hdr = ReadMacInt32(wds + 2); - memcpy(write_io->ios2_DstAddr, Mac2HostAddr(hdr), 6); - memcpy(Mac2HostAddr(hdr + 6), ether_addr, 6); + Mac2Host_memcpy(write_io->ios2_DstAddr, hdr, 6); + Host2Mac_memcpy(hdr + 6, ether_addr, 6); // Get packet type uint32 type = ReadMacInt16(hdr + 12); @@ -635,7 +672,7 @@ void EtherInterrupt(void) // Packet write done, enqueue DT to call IODone if (write_done) { - Enqueue(ether_data + ed_DeferredTask, 0xd92); + EnqueueMac(ether_data + ed_DeferredTask, 0xd92); write_done = false; } @@ -651,7 +688,7 @@ void EtherInterrupt(void) continue; // Copy header to RHA - memcpy(Mac2HostAddr(ether_data + ed_RHA), io->ios2_Data, 14); + Host2Mac_memcpy(ether_data + ed_RHA, io->ios2_Data, 14); D(bug(" header %08lx%04lx %08lx%04lx %04lx\n", ReadMacInt32(ether_data + ed_RHA), ReadMacInt16(ether_data + ed_RHA + 4), ReadMacInt32(ether_data + ed_RHA + 6), ReadMacInt16(ether_data + ed_RHA + 10), ReadMacInt16(ether_data + ed_RHA + 12))); // Call protocol handler