1 |
|
/* |
2 |
|
* ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 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 |
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" |
192 |
|
* Reset |
193 |
|
*/ |
194 |
|
|
195 |
< |
void EtherReset(void) |
195 |
> |
void ether_reset(void) |
196 |
|
{ |
197 |
|
// Remove all protocols |
198 |
|
if (net_proc) |
396 |
|
ULONG dev_unit; |
397 |
|
|
398 |
|
str = PrefsFindString("ether"); |
399 |
< |
if (str) |
396 |
< |
{ |
399 |
> |
if (str) { |
400 |
|
const char *FirstSlash = strchr(str, '/'); |
401 |
|
const char *LastSlash = strrchr(str, '/'); |
402 |
|
|
403 |
< |
if (FirstSlash && FirstSlash && FirstSlash != LastSlash) |
404 |
< |
{ |
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; |
413 |
|
if (strlen(dev_name) < 1) |
414 |
|
goto quit; |
415 |
|
|
416 |
< |
if (1 != sscanf(LastSlash, "/%ld", &dev_unit)) |
416 |
> |
if (sscanf(LastSlash, "/%ld", &dev_unit) != 1) |
417 |
|
goto quit; |
418 |
< |
|
419 |
< |
// printf("dev=<%s> unit=%d\n", dev_name, dev_unit); |
417 |
< |
} |
418 |
< |
else |
419 |
< |
{ |
420 |
< |
if (2 != sscanf(str, "%[^/]/%ld", dev_name, &dev_unit)) |
418 |
> |
} else { |
419 |
> |
if (sscanf(str, "%[^/]/%ld", dev_name, &dev_unit) != 2) |
420 |
|
goto quit; |
422 |
– |
} |
421 |
|
} |
422 |
< |
else |
422 |
> |
} else |
423 |
|
goto quit; |
424 |
|
|
425 |
|
// Open device |
426 |
|
control_io->ios2_BufferManagement = buffer_tags; |
427 |
< |
od_error = OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0); |
428 |
< |
if (0 != od_error || control_io->ios2_Req.io_Device == 0) |
431 |
< |
{ |
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 |
< |
} |
431 |
> |
} |
432 |
|
opened = true; |
433 |
|
|
434 |
|
// Is it Ethernet? |
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); |
591 |
– |
Host2Mac_memcpy(hdr + 6, ether_addr, 6); |
588 |
|
|
589 |
|
// Get packet type |
590 |
|
uint32 type = ReadMacInt16(hdr + 12); |