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

Comparing BasiliskII/src/BeOS/ether_beos.cpp (file contents):
Revision 1.5 by cebix, 2001-02-02T20:52:57Z vs.
Revision 1.7 by cebix, 2001-07-13T15:39:22Z

# Line 105 | Line 105 | static void remove_all_protocols(void)
105   *  Initialization
106   */
107  
108 < void EtherInit(void)
108 > bool ether_init(void)
109   {
110          // Do nothing if no Ethernet device specified
111          if (PrefsFindString("ether") == NULL)
112 <                return;
112 >                return false;
113  
114          // Find net_server team
115   i_wanna_try_that_again:
# Line 148 | Line 148 | i_wanna_try_that_again:
148                  // It was found, so something else must be wrong
149                  if (sheep_net_found) {
150                          WarningAlert(GetString(STR_NO_NET_ADDON_WARN));
151 <                        return;
151 >                        return false;
152                  }
153  
154                  // Not found, inform the user
155                  if (!ChoiceAlert(GetString(STR_NET_CONFIG_MODIFY_WARN), GetString(STR_OK_BUTTON), GetString(STR_CANCEL_BUTTON)))
156 <                        return;
156 >                        return false;
157  
158                  // Change the network config file and restart the network
159                  fin = fopen("/boot/home/config/settings/network", "r");
# Line 208 | Line 208 | i_wanna_try_that_again:
208          area_id handler_buffer;
209          if ((handler_buffer = find_area("packet buffer")) < B_NO_ERROR) {
210                  WarningAlert(GetString(STR_NET_ADDON_INIT_FAILED));
211 <                return;
211 >                return false;
212          }
213          if ((buffer_area = clone_area("local packet buffer", (void **)&net_buffer_ptr, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, handler_buffer)) < B_NO_ERROR) {
214                  D(bug("EtherInit: couldn't clone packet area\n"));
215                  WarningAlert(GetString(STR_NET_ADDON_CLONE_FAILED));
216 <                return;
216 >                return false;
217          }
218          if ((read_sem = create_sem(0, "ether read")) < B_NO_ERROR) {
219                  printf("FATAL: can't create Ethernet semaphore\n");
220 <                return;
220 >                return false;
221          }
222          net_buffer_ptr->read_sem = read_sem;
223          write_sem = net_buffer_ptr->write_sem;
# Line 233 | Line 233 | i_wanna_try_that_again:
233          D(bug("Ethernet address %02x %02x %02x %02x %02x %02x\n", ether_addr[0], ether_addr[1], ether_addr[2], ether_addr[3], ether_addr[4], ether_addr[5]));
234  
235          // Everything OK
236 <        net_open = true;
236 >        return true;
237   }
238  
239  
# Line 241 | Line 241 | i_wanna_try_that_again:
241   *  Deinitialization
242   */
243  
244 < void EtherExit(void)
244 > void ether_exit(void)
245   {
246 <        if (net_open) {
247 <
248 <                // Close communications with add-on
249 <                for (int i=0; i<WRITE_PACKET_COUNT; i++)
250 <                        net_buffer_ptr->write[i].cmd = IN_USE | (DEACTIVATE_SHEEP_NET << 8);
251 <                release_sem(write_sem);
246 >        // Close communications with add-on
247 >        for (int i=0; i<WRITE_PACKET_COUNT; i++)
248 >                net_buffer_ptr->write[i].cmd = IN_USE | (DEACTIVATE_SHEEP_NET << 8);
249 >        release_sem(write_sem);
250  
251 <                // Quit reception thread
252 <                ether_thread_active = false;
253 <                status_t result;
254 <                release_sem(read_sem);
255 <                wait_for_thread(read_thread, &result);
251 >        // Quit reception thread
252 >        ether_thread_active = false;
253 >        status_t result;
254 >        release_sem(read_sem);
255 >        wait_for_thread(read_thread, &result);
256  
257 <                delete_sem(read_sem);
258 <                delete_area(buffer_area);
257 >        delete_sem(read_sem);
258 >        delete_area(buffer_area);
259  
260 <                // Remove all protocols
261 <                remove_all_protocols();
264 <        }
260 >        // Remove all protocols
261 >        remove_all_protocols();
262   }
263  
264  
# Line 269 | Line 266 | void EtherExit(void)
266   *  Reset
267   */
268  
269 < void EtherReset(void)
269 > void ether_reset(void)
270   {
271          remove_all_protocols();
272   }
# Line 364 | Line 361 | int16 ether_write(uint32 wds)
361          } else {
362  
363                  // Copy packet to buffer
364 <                uint8 *start;
368 <                uint8 *bp = start = p->data;
369 <                for (;;) {
370 <                        int len = ReadMacInt16(wds);
371 <                        if (len == 0)
372 <                                break;
373 <                        Mac2Host_memcpy(bp, ReadMacInt32(wds + 2), len);
374 <                        bp += len;
375 <                        wds += 6;
376 <                }
364 >                int len = ether_wds_to_buffer(wds, p->data);
365  
366                  // Set source address
367 <                memcpy(start + 6, ether_addr, 6);
367 >                memcpy(p->data + 6, ether_addr, 6);
368  
369   #if MONITOR
370                  bug("Sending Ethernet packet:\n");
371 <                for (int i=0; i<(uint32)(bp-start); i++) {
372 <                        bug("%02x ", start[i]);
371 >                for (int i=0; i<len; i++) {
372 >                        bug("%02x ", p->data[i]);
373                  }
374                  bug("\n");
375   #endif
376  
377                  // Notify add-on
378 <                p->length = (uint32)(bp - start);
378 >                p->length = len;
379                  p->cmd = IN_USE | (SHEEP_PACKET << 8);
380                  wr_pos = (wr_pos + 1) % WRITE_PACKET_COUNT;
381                  release_sem(write_sem);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines