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.4 by gbeauche, 2004-05-10T16:16:26Z vs.
Revision 1.7 by gbeauche, 2005-01-30T21:48:19Z

# Line 1 | Line 1
1   /*
2   *  ether.cpp - SheepShaver Ethernet Device Driver (DLPI)
3   *
4 < *  SheepShaver (C) 1997-2004 Marc Hellwig and Christian Bauer
4 > *  SheepShaver (C) 1997-2005 Marc Hellwig and 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 37 | Line 37
37   #define DEBUG 0
38   #include "debug.h"
39  
40 + #if DIRECT_ADDRESSING
41 + #warning "This code is not direct addressing clean"
42 + #endif
43  
44   // Packet types
45   enum {
# Line 86 | Line 89 | struct DLPIStream {
89  
90          void AddMulticast(uint8 *addr)
91          {
92 <                multicast_node *n = (multicast_node *)Mac_sysalloc(sizeof(multicast_node));
92 >                multicast_node *n = (multicast_node *)Mac2HostAddr(Mac_sysalloc(sizeof(multicast_node)));
93                  memcpy(n->addr, addr, kEnetPhysicalAddressLength);
94                  n->next = multicast_list;
95                  multicast_list = n;
# Line 106 | Line 109 | struct DLPIStream {
109                  while (q) {
110                          if (q->next == p) {
111                                  q->next = p->next;
112 <                                Mac_sysfree(p);
112 >                                Mac_sysfree(Host2MacAddr((uint8 *)p));
113                                  return;
114                          }
115                          q = q->next;
# Line 180 | Line 183 | typedef mblk_t *(*allocb_ptr)(size_t siz
183   static uint32 allocb_tvect = 0;
184   mblk_t *allocb(size_t arg1, int arg2)
185   {
186 <        return (mblk_t *)CallMacOS2(allocb_ptr, allocb_tvect, arg1, arg2);
186 >        return (mblk_t *)Mac2HostAddr(CallMacOS2(allocb_ptr, allocb_tvect, arg1, arg2));
187   }
188   typedef void (*freeb_ptr)(mblk_t *);
189   static uint32 freeb_tvect = 0;
# Line 198 | Line 201 | typedef mblk_t *(*copyb_ptr)(mblk_t *);
201   static uint32 copyb_tvect = 0;
202   static inline mblk_t *copyb(mblk_t *arg1)
203   {
204 <        return (mblk_t *)CallMacOS1(copyb_ptr, copyb_tvect, arg1);
204 >        return (mblk_t *)Mac2HostAddr(CallMacOS1(copyb_ptr, copyb_tvect, arg1));
205   }
206   typedef mblk_t *(*dupmsg_ptr)(mblk_t *);
207   static uint32 dupmsg_tvect = 0;
208   static inline mblk_t *dupmsg(mblk_t *arg1)
209   {
210 <        return (mblk_t *)CallMacOS1(dupmsg_ptr, dupmsg_tvect, arg1);
210 >        return (mblk_t *)Mac2HostAddr(CallMacOS1(dupmsg_ptr, dupmsg_tvect, arg1));
211   }
212   typedef mblk_t *(*getq_ptr)(queue_t *);
213   static uint32 getq_tvect = 0;
214   static inline mblk_t *getq(queue_t *arg1)
215   {
216 <        return (mblk_t *)CallMacOS1(getq_ptr, getq_tvect, arg1);
216 >        return (mblk_t *)Mac2HostAddr(CallMacOS1(getq_ptr, getq_tvect, arg1));
217   }
218   typedef int (*putq_ptr)(queue_t *, mblk_t *);
219   static uint32 putq_tvect = 0;
# Line 282 | Line 285 | typedef DLPIStream *(*mi_next_ptr_ptr)(D
285   static uint32 mi_next_ptr_tvect = 0;
286   static inline DLPIStream *mi_next_ptr(DLPIStream *arg1)
287   {
288 <        return (DLPIStream *)CallMacOS1(mi_next_ptr_ptr, mi_next_ptr_tvect, arg1);
288 >        return (DLPIStream *)Mac2HostAddr(CallMacOS1(mi_next_ptr_ptr, mi_next_ptr_tvect, arg1));
289   }
290  
291  
# Line 318 | Line 321 | uint8 InitStreamModule(void *theID)
321          ether_driver_opened = false;
322  
323          // Import functions from OTKernelLib
324 <        allocb_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\006allocb");
324 >        allocb_tvect = FindLibSymbol("\013OTKernelLib", "\006allocb");
325          D(bug("allocb TVECT at %08lx\n", allocb_tvect));
326          if (allocb_tvect == 0)
327                  return false;
328 <        freeb_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\005freeb");
328 >        freeb_tvect = FindLibSymbol("\013OTKernelLib", "\005freeb");
329          D(bug("freeb TVECT at %08lx\n", freeb_tvect));
330          if (freeb_tvect == 0)
331                  return false;
332 <        freemsg_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\007freemsg");
332 >        freemsg_tvect = FindLibSymbol("\013OTKernelLib", "\007freemsg");
333          D(bug("freemsg TVECT at %08lx\n", freemsg_tvect));
334          if (freemsg_tvect == 0)
335                  return false;
336 <        copyb_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\005copyb");
336 >        copyb_tvect = FindLibSymbol("\013OTKernelLib", "\005copyb");
337          D(bug("copyb TVECT at %08lx\n", copyb_tvect));
338          if (copyb_tvect == 0)
339                  return false;
340 <        dupmsg_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\006dupmsg");
340 >        dupmsg_tvect = FindLibSymbol("\013OTKernelLib", "\006dupmsg");
341          D(bug("dupmsg TVECT at %08lx\n", dupmsg_tvect));
342          if (dupmsg_tvect == 0)
343                  return false;
344 <        getq_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\004getq");
344 >        getq_tvect = FindLibSymbol("\013OTKernelLib", "\004getq");
345          D(bug("getq TVECT at %08lx\n", getq_tvect));
346          if (getq_tvect == 0)
347                  return false;
348 <        putq_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\004putq");
348 >        putq_tvect = FindLibSymbol("\013OTKernelLib", "\004putq");
349          D(bug("putq TVECT at %08lx\n", putq_tvect));
350          if (putq_tvect == 0)
351                  return false;
352 <        putnext_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\007putnext");
352 >        putnext_tvect = FindLibSymbol("\013OTKernelLib", "\007putnext");
353          D(bug("putnext TVECT at %08lx\n", putnext_tvect));
354          if (putnext_tvect == 0)
355                  return false;
356 <        putnextctl1_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\013putnextctl1");
356 >        putnextctl1_tvect = FindLibSymbol("\013OTKernelLib", "\013putnextctl1");
357          D(bug("putnextctl1 TVECT at %08lx\n", putnextctl1_tvect));
358          if (putnextctl1_tvect == 0)
359                  return false;
360 <        canputnext_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\012canputnext");
360 >        canputnext_tvect = FindLibSymbol("\013OTKernelLib", "\012canputnext");
361          D(bug("canputnext TVECT at %08lx\n", canputnext_tvect));
362          if (canputnext_tvect == 0)
363                  return false;
364 <        qreply_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\006qreply");
364 >        qreply_tvect = FindLibSymbol("\013OTKernelLib", "\006qreply");
365          D(bug("qreply TVECT at %08lx\n", qreply_tvect));
366          if (qreply_tvect == 0)
367                  return false;
368 <        flushq_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\006flushq");
368 >        flushq_tvect = FindLibSymbol("\013OTKernelLib", "\006flushq");
369          D(bug("flushq TVECT at %08lx\n", flushq_tvect));
370          if (flushq_tvect == 0)
371                  return false;
372 <        msgdsize_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\010msgdsize");
372 >        msgdsize_tvect = FindLibSymbol("\013OTKernelLib", "\010msgdsize");
373          D(bug("msgdsize TVECT at %08lx\n", msgdsize_tvect));
374          if (msgdsize_tvect == 0)
375                  return false;
376 <        otenterint_tvect = (uint32)FindLibSymbol("\017OTKernelUtilLib", "\020OTEnterInterrupt");
376 >        otenterint_tvect = FindLibSymbol("\017OTKernelUtilLib", "\020OTEnterInterrupt");
377          D(bug("OTEnterInterrupt TVECT at %08lx\n", otenterint_tvect));
378          if (otenterint_tvect == 0)
379                  return false;
380 <        otleaveint_tvect = (uint32)FindLibSymbol("\017OTKernelUtilLib", "\020OTLeaveInterrupt");
380 >        otleaveint_tvect = FindLibSymbol("\017OTKernelUtilLib", "\020OTLeaveInterrupt");
381          D(bug("OTLeaveInterrupt TVECT at %08lx\n", otleaveint_tvect));
382          if (otleaveint_tvect == 0)
383                  return false;
384 <        mi_open_comm_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\014mi_open_comm");
384 >        mi_open_comm_tvect = FindLibSymbol("\013OTKernelLib", "\014mi_open_comm");
385          D(bug("mi_open_comm TVECT at %08lx\n", mi_open_comm_tvect));
386          if (mi_open_comm_tvect == 0)
387                  return false;
388 <        mi_close_comm_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\015mi_close_comm");
388 >        mi_close_comm_tvect = FindLibSymbol("\013OTKernelLib", "\015mi_close_comm");
389          D(bug("mi_close_comm TVECT at %08lx\n", mi_close_comm_tvect));
390          if (mi_close_comm_tvect == 0)
391                  return false;
392 <        mi_next_ptr_tvect = (uint32)FindLibSymbol("\013OTKernelLib", "\013mi_next_ptr");
392 >        mi_next_ptr_tvect = FindLibSymbol("\013OTKernelLib", "\013mi_next_ptr");
393          D(bug("mi_next_ptr TVECT at %08lx\n", mi_next_ptr_tvect));
394          if (mi_next_ptr_tvect == 0)
395                  return false;
# Line 1542 | Line 1545 | static void DLPI_enable_multi(DLPIStream
1545          AO_enable_multicast(reqaddr);
1546  
1547          // Add new address to multicast list
1548 <        uint8 *addr = (uint8 *)Mac_sysalloc(kEnetPhysicalAddressLength);
1548 >        uint8 *addr = Mac2HostAddr(Mac_sysalloc(kEnetPhysicalAddressLength));
1549          OTCopy48BitAddress(reqaddr, addr);
1550          the_stream->AddMulticast(addr);
1551  
# Line 1580 | Line 1583 | static void DLPI_disable_multi(DLPIStrea
1583  
1584          // Found, then remove
1585          the_stream->RemoveMulticast(addr);
1586 <        Mac_sysfree(addr);
1586 >        Mac_sysfree(Host2MacAddr(addr));
1587  
1588          // Tell add-on to disable multicast address
1589          AO_disable_multicast(reqaddr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines