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

Comparing SheepShaver/src/ether.cpp (file contents):
Revision 1.7 by gbeauche, 2005-01-30T21:48:19Z vs.
Revision 1.8 by gbeauche, 2005-07-03T08:23:42Z

# Line 27 | Line 27
27   #include <string.h>
28  
29   #include "sysdeps.h"
30 + #include "cpu_emulation.h"
31   #include "ether.h"
32   #include "ether_defs.h"
33   #include "macos_util.h"
33 #include "cpu_emulation.h"
34   #include "emul_op.h"
35   #include "main.h"
36  
# Line 398 | Line 398 | uint8 InitStreamModule(void *theID)
398          dlpi_stream_list = NULL;
399  
400          // Ask add-on for ethernet hardware address
401 <        AO_get_ethernet_address(hardware_address);
401 >        AO_get_ethernet_address(Host2MacAddr(hardware_address));
402  
403          // Yes, we're open
404          ether_driver_opened = true;
# Line 479 | Line 479 | int ether_close(queue_t *rdq, int flag,
479  
480          // Disable all registered multicast addresses
481          while (the_stream->multicast_list) {
482 <                AO_disable_multicast(the_stream->multicast_list->addr);
482 >                AO_disable_multicast(Host2MacAddr(the_stream->multicast_list->addr));
483                  the_stream->RemoveMulticast(the_stream->multicast_list->addr);
484          }
485          the_stream->multicast_list = NULL;
# Line 929 | Line 929 | static void transmit_packet(mblk_t *mp)
929          OTCopy48BitAddress(hardware_address, enetHeader->fSourceAddr);
930  
931          // Tell add-on to transmit packet
932 <        AO_transmit_packet(mp);
932 >        AO_transmit_packet(Host2MacAddr((uint8 *)mp));
933          freemsg(mp);
934   }
935  
# Line 1101 | Line 1101 | type_found:
1101          }
1102   }
1103  
1104 + void ether_dispatch_packet(uint32 p, uint32 size)
1105 + {
1106 +        // Wrap packet in message block
1107 +        num_rx_packets++;
1108 +        mblk_t *mp;
1109 +        if ((mp = allocb(size, 0)) != NULL) {
1110 +                D(bug(" packet data at %p\n", (void *)mp->b_rptr));
1111 +                Mac2Host_memcpy(mp->b_rptr, p, size);
1112 +                mp->b_wptr += size;
1113 +                ether_packet_received(mp);
1114 +        } else {
1115 +                D(bug("WARNING: Cannot allocate mblk for received packet\n"));
1116 +                num_rx_no_mem++;
1117 +        }
1118 + }
1119 +
1120  
1121   /*
1122   *  Build and send an error acknowledge
# Line 1542 | Line 1558 | static void DLPI_enable_multi(DLPIStream
1558          }
1559  
1560          // Tell add-on to enable multicast address
1561 <        AO_enable_multicast(reqaddr);
1561 >        AO_enable_multicast(Host2MacAddr((uint8 *)reqaddr));
1562  
1563          // Add new address to multicast list
1564          uint8 *addr = Mac2HostAddr(Mac_sysalloc(kEnetPhysicalAddressLength));
# Line 1586 | Line 1602 | static void DLPI_disable_multi(DLPIStrea
1602          Mac_sysfree(Host2MacAddr(addr));
1603  
1604          // Tell add-on to disable multicast address
1605 <        AO_disable_multicast(reqaddr);
1605 >        AO_disable_multicast(Host2MacAddr((uint8 *)reqaddr));
1606          
1607          // No longer check multicast packets if no multicast addresses are registered
1608          if (the_stream->multicast_list == NULL)
# Line 1639 | Line 1655 | static void DLPI_unit_data(DLPIStream *t
1655          if ((mp = build_tx_packet_header(the_stream, mp, false)) != NULL)
1656                  transmit_packet(mp);
1657   }
1658 +
1659 +
1660 + /*
1661 + *  Ethernet packet allocator
1662 + */
1663 +
1664 + #if SIZEOF_VOID_P != 4 || REAL_ADDRESSING == 0
1665 + static uint32 ether_packet = 0;                 // Ethernet packet (cached allocation)
1666 + static uint32 n_ether_packets = 0;              // Number of ethernet packets allocated so far (should be at most 1)
1667 +
1668 + EthernetPacket::EthernetPacket()
1669 + {
1670 +        ++n_ether_packets;
1671 +        if (ether_packet && n_ether_packets == 1)
1672 +                packet = ether_packet;
1673 +        else {
1674 +                packet = Mac_sysalloc(1516);
1675 +                assert(packet != 0);
1676 +                Mac_memset(packet, 0, 1516);
1677 +                if (ether_packet == 0)
1678 +                        ether_packet = packet;
1679 +        }
1680 + }
1681 +
1682 + EthernetPacket::~EthernetPacket()
1683 + {
1684 +        --n_ether_packets;
1685 +        if (packet != ether_packet)
1686 +                Mac_sysfree(packet);
1687 +        if (n_ether_packets > 0) {
1688 +                bug("WARNING: Nested allocation of ethernet packets!\n");
1689 +        }
1690 + }
1691 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines