Lines Matching defs:undi

9 $Id: undi.c,v 1.8 2003/10/25 13:54:53 mcb30 Exp $
26 #include "undi.h"
34 static undi_t undi = { NULL, NULL, NULL, NULL, NULL, NULL, NULL,
75 undi.pxe->EntryPointSP.segment, undi.pxe->EntryPointSP.offset,
76 undi.pxe->Stack.Seg_Addr, undi.pxe->Stack.Seg_Size,
77 undi.pxe->UNDIData.Seg_Addr, undi.pxe->UNDIData.Seg_Size,
78 undi.pxe->UNDICode.Seg_Addr, undi.pxe->UNDICode.Seg_Size,
79 undi.pxe->BC_Data.Seg_Addr, undi.pxe->BC_Data.Seg_Size,
80 undi.pxe->BC_Code.Seg_Addr, undi.pxe->BC_Code.Seg_Size );
90 undi.base_mem_data = &undi_base_mem_data;
91 memset ( undi.base_mem_data, 0, sizeof(undi_base_mem_data_t) );
92 undi.undi_call_info = &undi.base_mem_data->undi_call_info;
93 undi.pxs = &undi.base_mem_data->pxs;
94 undi.xmit_data = &undi.base_mem_data->xmit_data;
95 undi.xmit_buffer = undi.base_mem_data->xmit_buffer;
100 if ( undi.base_mem_data == NULL ) {
101 undi.base_mem_data =
104 if ( undi.base_mem_data == NULL ) {
109 memset ( undi.base_mem_data, 0, sizeof(undi_base_mem_data_t) );
110 undi.undi_call_info = &undi.base_mem_data->undi_call_info;
111 undi.pxs = &undi.base_mem_data->pxs;
112 undi.xmit_data = &undi.base_mem_data->xmit_data;
113 undi.xmit_buffer = undi.base_mem_data->xmit_buffer;
114 copy_trivial_irq_handler ( undi.base_mem_data->irq_handler,
123 undi.base_mem_data = NULL;
124 undi.undi_call_info = NULL;
125 undi.pxs = NULL;
126 undi.xmit_data = NULL;
127 undi.xmit_buffer = NULL;
129 if ( undi.base_mem_data != NULL ) {
130 forget_base_memory ( undi.base_mem_data,
133 undi.base_mem_data = NULL;
134 undi.undi_call_info = NULL;
135 undi.pxs = NULL;
136 undi.xmit_data = NULL;
137 undi.xmit_buffer = NULL;
209 undi.pnp_bios = (pnp_bios_t *) phys_to_virt ( 0xf0000 + off );
210 if ( undi.pnp_bios->signature == PNP_BIOS_SIGNATURE ) {
212 if ( checksum(undi.pnp_bios,sizeof(pnp_bios_t)) !=0) {
221 undi.pnp_bios = NULL;
248 undi.pxe = pxe;
250 undi.pxe = NULL;
256 undi.pxe = pxe;
280 undi.rom = ( rom_t * ) phys_to_virt ( ptr );
281 if ( undi.rom->signature == ROM_SIGNATURE ) {
286 if ( undi.rom->pcir_off == 0 ) {
290 pcir_header = (pcir_header_t*)( ( void * ) undi.rom +
291 undi.rom->pcir_off );
298 if ( ( pcir_header->vendor_id != undi.pci.vendor ) ||
299 ( pcir_header->device_id != undi.pci.dev_id ) ) {
301 undi.pci.vendor,
302 undi.pci.dev_id );
305 if ( undi.rom->pnp_off == 0 ) {
309 pnp_header = (pnp_header_t*)( ( void * ) undi.rom +
310 undi.rom->pnp_off );
322 (void*)undi.rom+pnp_header->product_str_off,
324 (void*)undi.rom+pnp_header->manuf_str_off );
330 undi.rom = NULL;
339 if ( undi.rom->undi_rom_id_off == 0 ) {
343 undi.undi_rom_id = (undi_rom_id_t *)
344 ( (void *)undi.rom + undi.rom->undi_rom_id_off );
345 if ( undi.undi_rom_id->signature != UNDI_SIGNATURE ) {
350 undi.undi_rom_id->undi_rev[2],
351 undi.undi_rom_id->undi_rev[1],
352 undi.undi_rom_id->undi_rev[0] );
373 undi.undi_call_info->routine.segment = routine_seg;
374 undi.undi_call_info->routine.offset = routine_off;
375 undi.undi_call_info->stack[0] = st0;
376 undi.undi_call_info->stack[1] = st1;
377 undi.undi_call_info->stack[2] = st2;
378 ret = __undi_call ( SEGMENT( undi.undi_call_info ),
379 OFFSET( undi.undi_call_info ) );
402 pxenv_exit = _undi_call ( SEGMENT( undi.rom ),
403 undi.undi_rom_id->undi_loader_off,
404 OFFSET( undi.pxs ),
405 SEGMENT( undi.pxs ),
410 undi.pxs->Status );
424 pxenv_exit = _undi_call ( undi.pxe->EntryPointSP.segment,
425 undi.pxe->EntryPointSP.offset,
427 OFFSET( undi.pxs ),
428 SEGMENT( undi.pxs ) );
436 opcode, undi.pxs->Status );
451 undi.pxs->loader.ax = ( undi.pci.bus << 8 ) | undi.pci.devfn;
455 undi.pxs->loader.bx = 0xffff;
456 undi.pxs->loader.dx = 0xffff;
460 undi.pxs->loader.es = 0xf000;
461 undi.pxs->loader.di = virt_to_phys ( undi.pnp_bios ) - 0xf0000;
464 undi.driver_code_size = undi.undi_rom_id->code_size;
465 undi.driver_code = UNDI_HEAP;
466 if ( undi.driver_code == NULL ) {
468 undi.driver_code_size );
471 undi.pxs->loader.undi_cs = SEGMENT( undi.driver_code );
473 undi.driver_data_size = undi.undi_rom_id->data_size;
474 undi.driver_data = (void *)((((unsigned long)UNDI_HEAP + undi.undi_rom_id->code_size) | (1024 -1)) + 1);
475 if ( undi.driver_data == NULL ) {
477 undi.driver_data_size );
480 undi.pxs->loader.undi_ds = SEGMENT( undi.driver_data );
483 undi.pxs->loader.undi_cs, undi.pxs->loader.undi_ds );
488 pxe = VIRTUAL( undi.pxs->loader.undi_cs, undi.pxs->loader.pxe_off );
490 undi.pxs->loader.undi_cs, undi.pxs->loader.pxe_off );
500 undi.pxe = pxe;
512 undi.pxs->start_undi.ax = ( undi.pci.bus << 8 ) | undi.pci.devfn;
516 undi.pxs->start_undi.bx = 0xffff;
517 undi.pxs->start_undi.dx = 0xffff;
521 undi.pxs->start_undi.es = 0xf000;
522 undi.pxs->start_undi.di = virt_to_phys ( undi.pnp_bios ) - 0xf0000;
525 undi.pxs->start_undi.ax,
526 undi.pxs->start_undi.bx, undi.pxs->start_undi.dx,
527 undi.pxs->start_undi.es, undi.pxs->start_undi.di );
529 DBG ( "PXENV_START_UNDI <= Status=%s\n", UNDI_STATUS(undi.pxs) );
530 if ( success ) undi.prestarted = 1;
539 DBG ( "PXENV_UNDI_STARTUP <= Status=%s\n", UNDI_STATUS(undi.pxs) );
540 if ( success ) undi.started = 1;
549 DBG ( "PXENV_UNDI_CLEANUP <= Status=%s\n", UNDI_STATUS(undi.pxs) );
556 undi.pxs->undi_initialize.ProtocolIni = 0;
557 memset ( &undi.pxs->undi_initialize.reserved, 0,
558 sizeof ( undi.pxs->undi_initialize.reserved ) );
561 DBG ( "PXENV_UNDI_INITIALIZE <= Status=%s\n", UNDI_STATUS(undi.pxs) );
562 if ( success ) undi.initialized = 1;
571 DBG ( "PXENV_UNDI_SHUTDOWN <= Status=%s\n", UNDI_STATUS(undi.pxs) );
573 undi.initialized = 0;
574 undi.started = 0;
582 undi.pxs->undi_open.OpenFlag = 0;
583 undi.pxs->undi_open.PktFilter = FLTR_DIRECTED | FLTR_BRDCST;
586 undi.pxs->undi_open.R_Mcast_Buf.MCastAddrCount = 0;
589 undi.pxs->undi_open.OpenFlag, undi.pxs->undi_open.PktFilter,
590 undi.pxs->undi_open.R_Mcast_Buf.MCastAddrCount );
592 DBG ( "PXENV_UNDI_OPEN <= Status=%s\n", UNDI_STATUS(undi.pxs) );
593 if ( success ) undi.opened = 1;
602 DBG ( "PXENV_UNDI_CLOSE <= Status=%s\n", UNDI_STATUS(undi.pxs) );
603 if ( success ) undi.opened = 0;
612 if ( memcmp ( undi.xmit_data->destaddr, broadcast,
614 undi.pxs->undi_transmit.XmitFlag = XMT_BROADCAST;
616 undi.pxs->undi_transmit.XmitFlag = XMT_DESTADDR;
620 undi.pxs->undi_transmit.Reserved[0] = 0;
621 undi.pxs->undi_transmit.Reserved[1] = 0;
624 undi.pxs->undi_transmit.DestAddr.segment =
625 SEGMENT( undi.xmit_data->destaddr );
626 undi.pxs->undi_transmit.DestAddr.offset =
627 OFFSET( undi.xmit_data->destaddr );
630 undi.pxs->undi_transmit.TBD.segment = SEGMENT( &undi.xmit_data->tbd );
631 undi.pxs->undi_transmit.TBD.offset = OFFSET( &undi.xmit_data->tbd );
634 undi.xmit_data->tbd.DataBlkCount = 0;
638 undi.pxs->undi_transmit.Protocol,
639 undi.pxs->undi_transmit.XmitFlag,
640 undi.pxs->undi_transmit.DestAddr.segment,
641 undi.pxs->undi_transmit.DestAddr.offset,
642 undi.pxs->undi_transmit.TBD.segment,
643 undi.pxs->undi_transmit.TBD.offset );
645 undi.xmit_data->tbd.ImmedLength,
646 undi.xmit_data->tbd.Xmit.segment,
647 undi.xmit_data->tbd.Xmit.offset,
648 undi.xmit_data->tbd.DataBlkCount );
651 UNDI_STATUS(undi.pxs) );
663 undi.pxs->undi_set_station_address.StationAddress );
666 UNDI_STATUS(undi.pxs) );
672 memset ( undi.pxs, 0, sizeof ( undi.pxs ) );
680 UNDI_STATUS(undi.pxs),
681 undi.pxs->undi_get_information.BaseIo,
682 undi.pxs->undi_get_information.IntNumber,
683 undi.pxs->undi_get_information.MaxTranUnit,
684 undi.pxs->undi_get_information.HwType,
685 undi.pxs->undi_get_information.HwAddrLen,
686 undi.pxs->undi_get_information.CurrentNodeAddress,
687 undi.pxs->undi_get_information.PermNodeAddress,
688 undi.pxs->undi_get_information.ROMAddress,
689 undi.pxs->undi_get_information.RxBufCt,
690 undi.pxs->undi_get_information.TxBufCt );
701 UNDI_STATUS(undi.pxs),
702 undi.pxs->undi_get_iface_info.IfaceType,
703 undi.pxs->undi_get_iface_info.LinkSpeed,
704 undi.pxs->undi_get_iface_info.ServiceFlags );
712 undi.pxs->undi_isr.FuncFlag );
717 UNDI_STATUS(undi.pxs), undi.pxs->undi_isr.FuncFlag,
718 undi.pxs->undi_isr.BufferLength,
719 undi.pxs->undi_isr.FrameLength,
720 undi.pxs->undi_isr.FrameHeaderLength,
721 undi.pxs->undi_isr.Frame.segment,
722 undi.pxs->undi_isr.Frame.offset,
723 undi.pxs->undi_isr.ProtType,
724 undi.pxs->undi_isr.PktType );
733 DBG ( "PXENV_STOP_UNDI <= Status=%s\n", UNDI_STATUS(undi.pxs) );
734 if ( success ) undi.prestarted = 0;
741 memset ( undi.pxs, 0, sizeof ( undi.pxs ) );
745 UNDI_STATUS(undi.pxs),
746 ( undi.pxs->Status == PXENV_STATUS_SUCCESS ?
748 ( undi.pxs->Status == PXENV_STATUS_FAILURE ?
750 ( undi.pxs->Status == PXENV_STATUS_KEEP_ALL ?
761 DBG ( "PXENV_STOP_BASE <= Status=%s\n", UNDI_STATUS(undi.pxs) );
770 void *bc_code = VIRTUAL( undi.pxe->BC_Code.Seg_Addr, 0 );
771 size_t bc_code_size = undi.pxe->BC_Code.Seg_Size;
772 void *bc_data = VIRTUAL( undi.pxe->BC_Data.Seg_Addr, 0 );
773 size_t bc_data_size = undi.pxe->BC_Data.Seg_Size;
774 void *bc_stck = VIRTUAL( undi.pxe->Stack.Seg_Addr, 0 );
775 size_t bc_stck_size = undi.pxe->Stack.Seg_Size;
779 if ( undi.pxe->BC_Code.Seg_Addr == 0 ) return 1;
790 /* if ( ( undi.pxs->unload_stack.Status != PXENV_STATUS_SUCCESS ) &&
791 ( undi.pxs->unload_stack.Status != PXENV_STATUS_FAILURE ) ) {
817 VIRTUAL(undi.pxe->UNDICode.Seg_Addr, 0),
818 undi.pxe->UNDICode.Seg_Size, DONTSHOOT );
820 VIRTUAL(undi.pxe->UNDIData.Seg_Addr, 0),
821 undi.pxe->UNDIData.Seg_Size, DONTSHOOT );
823 //undi.pxe->BC_Code.Seg_Addr = 0;
824 //undi.pxe->BC_Data.Seg_Addr = 0;
825 //undi.pxe->Stack.Seg_Addr = 0;
849 undi.irq = undi.pxs->undi_get_information.IntNumber;
850 if ( ! install_undi_irq_handler ( undi.irq, undi.pxe->EntryPointSP ) ) {
851 undi.irq = IRQ_NONE;
854 memmove ( &undi.pxs->undi_set_station_address.StationAddress,
855 &undi.pxs->undi_get_information.PermNodeAddress,
856 sizeof (undi.pxs->undi_set_station_address.StationAddress) );
860 enable_irq ( undi.irq );
871 if ( undi.pxe != NULL ) {
876 if ( undi.driver_code == NULL ) {
877 undi.driver_code = VIRTUAL(undi.pxe->UNDICode.Seg_Addr,
879 undi.driver_code_size = undi.pxe->UNDICode.Seg_Size;
881 if ( undi.driver_data == NULL ) {
882 undi.driver_data = VIRTUAL(undi.pxe->UNDIData.Seg_Addr,
884 undi.driver_data_size = undi.pxe->UNDIData.Seg_Size;
890 if ( undi.opened ) eb_pxenv_undi_close();
891 if ( undi.started ) {
902 if ( undi.irq != IRQ_NONE ) {
903 remove_undi_irq_handler ( undi.irq );
904 undi.irq = IRQ_NONE;
907 if ( undi.prestarted ) {
913 if (( undi.pxs->Status == PXENV_STATUS_KEEP_UNDI ) ||
914 ( undi.pxs->Status == PXENV_STATUS_KEEP_ALL ) ) {
922 if ( undi.driver_code != NULL ) {
927 memset ( undi.driver_code, 0, undi.driver_code_size );
928 /* forget_base_memory ( undi.driver_code, undi.driver_code_size ); */
929 undi.driver_code = NULL;
930 undi.driver_code_size = 0;
932 if ( undi.driver_data != NULL ) {
933 /* forget_base_memory ( undi.driver_data, undi.driver_data_size ); */
934 undi.driver_data = NULL;
935 undi.driver_data_size = 0;
938 undi.pxe = NULL;
988 if ( ! undi_irq_triggered ( undi.irq ) )
998 undi.pxs->undi_isr.FuncFlag = undi_opcode;
1001 printf ("undi isr call failed: opcode = %d\n", undi_opcode);
1004 switch ( undi.pxs->undi_isr.FuncFlag ) {
1026 VIRTUAL( undi.pxs->undi_isr.Frame.segment,
1027 undi.pxs->undi_isr.Frame.offset ),
1028 undi.pxs->undi_isr.BufferLength );
1029 nic->packetlen += undi.pxs->undi_isr.BufferLength;
1034 undi.pxs->undi_isr.FuncFlag );
1054 memcpy ( undi.xmit_data->destaddr, d, sizeof(MAC_ADDR) );
1058 case IP : undi.pxs->undi_transmit.Protocol = P_IP; break;
1059 case ARP: undi.pxs->undi_transmit.Protocol = P_ARP; break;
1060 case RARP: undi.pxs->undi_transmit.Protocol = P_RARP; break;
1061 default: undi.pxs->undi_transmit.Protocol = P_UNKNOWN; break;
1065 undi.xmit_data->tbd.ImmedLength = s;
1072 undi.xmit_data->tbd.Xmit.segment = SEGMENT( p );
1073 undi.xmit_data->tbd.Xmit.offset = OFFSET( p );
1075 memcpy ( undi.xmit_buffer, p, s );
1076 undi.xmit_data->tbd.Xmit.segment = SEGMENT( undi.xmit_buffer );
1077 undi.xmit_data->tbd.Xmit.offset = OFFSET( undi.xmit_buffer );
1129 /* Zero out global undi structure */
1130 memset ( &undi, 0, sizeof(undi) );
1135 memcpy ( &undi.pci, pci, sizeof(undi.pci) );
1151 if ( undi.pxs->Status ==
1161 undi.pxs->undi_get_information.BaseIo,
1162 undi.pxs->undi_get_information.IntNumber,
1163 undi.pxs->undi_get_information.CurrentNodeAddress );
1166 undi.pxs->undi_get_information.CurrentNodeAddress,
1171 undi.pxs->undi_get_iface_info.IfaceType,
1172 undi.pxs->undi_get_iface_info.LinkSpeed / 1000000 );
1223 /* Zero out global undi structure */
1224 memset (&undi, 0, sizeof(undi));
1229 undi.pxe = pxe;
1252 memset(undi.pxs, 0, sizeof (undi.pxs));
1254 undi.pxs->get_cached_info.PacketType = type;
1255 undi.pxs->get_cached_info.BufferSize = 0;
1256 undi.pxs->get_cached_info.Buffer.segment = 0;
1257 undi.pxs->get_cached_info.Buffer.offset = 0;
1260 DBG ("PXENV_GET_CACHED_INFO <= Status=%s\n", UNDI_STATUS(undi.pxs));
1262 *info = (void *)VIRTUAL(undi.pxs->get_cached_info.Buffer.segment,
1263 undi.pxs->get_cached_info.Buffer.offset);
1272 memset(undi.pxs, 0, sizeof (undi.pxs));
1273 undi.pxs->tftp_open.ServerIPAddress = serverip;
1274 undi.pxs->tftp_open.GatewayIPAddress = gatewayip;
1275 undi.pxs->tftp_open.TFTPPort = htons(TFTP_PORT);
1276 undi.pxs->tftp_open.PacketSize = TFTP_MAX_PACKET;
1277 (void) sprintf(undi.pxs->tftp_open.FileName, "%s", file);
1279 DBG ("PXENV_TFTP_OPEN <= Status=%s\n", UNDI_STATUS(undi.pxs));
1280 *pktlen = undi.pxs->tftp_open.PacketSize;
1289 memset(undi.pxs, 0, sizeof (undi.pxs));
1290 undi.pxs->tftp_read.Buffer.segment = SEGMENT(buf);
1291 undi.pxs->tftp_read.Buffer.offset = OFFSET(buf);
1293 DBG ("PXENV_TFTP_READ <= Status=%s\n", UNDI_STATUS(undi.pxs));
1294 *len = undi.pxs->tftp_read.BufferSize;
1304 memset(undi.pxs, 0, sizeof (undi.pxs));
1306 DBG ("PXENV_TFTP_CLOSE <= Status=%s\n", UNDI_STATUS(undi.pxs));
1314 memset(undi.pxs, 0, sizeof (undi.pxs));
1315 undi.pxs->tftp_open.ServerIPAddress = serverip;
1316 undi.pxs->tftp_open.GatewayIPAddress = gatewayip;
1317 (void) sprintf(undi.pxs->tftp_open.FileName, "%s", file);
1319 DBG ("PXENV_TFTP_GET_FSIZE <= Status=%s\n", UNDI_STATUS(undi.pxs));
1320 *fsize = undi.pxs->tftp_get_fsize.FileSize;