ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/ether_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/ether_amiga.cpp (file contents):
Revision 1.4 by cebix, 2000-04-10T18:52:35Z vs.
Revision 1.13 by gbeauche, 2008-01-01T09:40:31Z

# Line 1 | Line 1
1   /*
2   *  ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2008 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 25 | Line 25
25   #include <dos/dosextens.h>
26   #include <dos/dostags.h>
27   #include <devices/sana2.h>
28 + #define __USE_SYSBASE
29   #include <proto/exec.h>
30   #include <proto/dos.h>
31 + #include <inline/exec.h>
32 + #include <inline/dos.h>
33 + #include <clib/alib_protos.h>
34  
35   #include "sysdeps.h"
36   #include "cpu_emulation.h"
# Line 116 | Line 120 | static int16 send_to_proc(uint32 what, u
120   *  Initialization
121   */
122  
123 < void EtherInit(void)
123 > bool ether_init(void)
124   {
125          // Do nothing if no Ethernet device specified
126          if (PrefsFindString("ether") == NULL)
127 <                return;
127 >                return false;
128  
129          // Initialize protocol list
130          NewList(&prot_list);
# Line 151 | Line 155 | void EtherInit(void)
155                  goto open_error;
156  
157          // Everything OK
158 <        net_open = true;
155 <        return;
158 >        return true;
159  
160   open_error:
161          net_proc = NULL;
# Line 160 | Line 163 | open_error:
163                  DeleteMsgPort(reply_port);
164                  reply_port = NULL;
165          }
166 +        return false;
167   }
168  
169  
# Line 167 | Line 171 | open_error:
171   *  Deinitialization
172   */
173  
174 < void EtherExit(void)
174 > void ether_exit(void)
175   {
176          // Stop process
177          if (net_proc) {
# Line 188 | Line 192 | void EtherExit(void)
192   *  Reset
193   */
194  
195 < void EtherReset(void)
195 > void ether_reset(void)
196   {
197          // Remove all protocols
198 <        if (net_open)
198 >        if (net_proc)
199                  send_to_proc(MSG_CLEANUP);
200   }
201  
# Line 346 | Line 350 | static __saveds __regargs LONG copy_from
350  
351   static __saveds void net_func(void)
352   {
353 +        const char *str;
354 +        BYTE od_error;
355          struct MsgPort *write_port = NULL, *control_port = NULL;
356          struct IOSana2Req *write_io = NULL, *control_io = NULL;
357          bool opened = false;
# Line 388 | Line 394 | static __saveds void net_func(void)
394          // Parse device name
395          char dev_name[256];
396          ULONG dev_unit;
397 <        if (sscanf(PrefsFindString("ether"), "%[^/]/%ld", dev_name, &dev_unit) < 2)
397 >
398 >        str = PrefsFindString("ether");
399 >        if (str) {
400 >                const char *FirstSlash = strchr(str, '/');
401 >                const char *LastSlash = strrchr(str, '/');
402 >
403 >                if (FirstSlash && FirstSlash && FirstSlash != LastSlash) {
404 >
405 >                        // Device name contains path, i.e. "Networks/xyzzy.device"
406 >                        const char *lp = str;
407 >                        char *dp = dev_name;
408 >
409 >                        while (lp != LastSlash)
410 >                                *dp++ = *lp++;
411 >                        *dp = '\0';
412 >
413 >                        if (strlen(dev_name) < 1)
414 >                                goto quit;
415 >
416 >                        if (sscanf(LastSlash, "/%ld", &dev_unit) != 1)
417 >                                goto quit;
418 >                } else {
419 >                        if (sscanf(str, "%[^/]/%ld", dev_name, &dev_unit) != 2)
420 >                                goto quit;
421 >                }
422 >        } else
423                  goto quit;
424  
425          // Open device
426          control_io->ios2_BufferManagement = buffer_tags;
427 <        if (OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0) || control_io->ios2_Req.io_Device == 0)
427 >        od_error = OpenDevice((UBYTE *) dev_name, dev_unit, (struct IORequest *)control_io, 0);
428 >        if (od_error != 0 || control_io->ios2_Req.io_Device == 0) {
429 >                printf("WARNING: OpenDevice(<%s>, unit=%d) returned error %d)\n", (UBYTE *)dev_name, dev_unit, od_error);
430                  goto quit;
431 +        }
432          opened = true;
433  
434          // Is it Ethernet?
# Line 548 | Line 582 | static __saveds void net_func(void)
582                                                  }
583                                                  write_io->ios2_DataLength = len;
584  
585 <                                                // Get destination address, set source address
585 >                                                // Get destination address
586                                                  uint32 hdr = ReadMacInt32(wds + 2);
587                                                  Mac2Host_memcpy(write_io->ios2_DstAddr, hdr, 6);
554                                                Host2Mac_memcpy(hdr + 6, ether_addr, 6);
588  
589                                                  // Get packet type
590                                                  uint32 type = ReadMacInt16(hdr + 12);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines